sql/extensions/integrations/integration
Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0022-sql-integrations FR-001, 0022-sql-integrations FR-009
An integration resolved (commons data 0022-sql-integrations FR-001, FR-009): its table and columns found in a logical schema by the words of their names, written by the naming layer, with the types the target gives them, and its lineage.
Source: commons/data/sql/extensions/integrations/integration.ts
5 of 13 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.
ContractColumninterfaceno test imports itinterface ContractColumn
One column of the contract, resolved.
| Member | Type | What it is |
|---|
words | string | The words of its name, joined by a dot: how a row's keys and a CSV's header are matched. |
name | string | The name it is written by. |
type | string | The type as the target writes it. |
required | boolean | Whether the target requires a value: not optional and with no default. |
IntegrationErrortypeno test imports ittype IntegrationError =
| { readonly kind: "unknown-table"; readonly table: string }
| { readonly kind: "unknown-col… (496 characters)
type IntegrationError =
| { readonly kind: "unknown-table"; readonly table: string }
| { readonly kind: "unknown-column"; readonly table: string; readonly column: string }
| { readonly kind: "missing-required"; readonly table: string; readonly columns: readonly string[] }
| { readonly kind: "no-key"; readonly name: string; readonly strategy: Strategy }
| { readonly kind: "no-columns"; readonly name: string }
| { readonly kind: "names"; readonly errors: readonly PhysicalError[] };
Why an integration cannot be made or run, as a value.
interface IntegrationSpec
What a project says of an integration.
| Member | Type | What it is |
|---|
name | string | |
table | string | The target, by the words of its name. |
source | SourceSpec | |
columns? | readonly string[] | The contract: the columns the source gives, by the words of their names. Rows and CSV give them themselves; a table or an adapter must be told. |
strategy? | Strategy | upsert where it is not said. |
key? | readonly string[] | The columns a row is known by; the table's primary key where it is not said. |
Imported by 7 tests of the run (7 passed, 0 failed): the library's results
LineageEdgeinterfaceno test imports itinterface LineageEdge
Rows went from one node to another.
| Member | Type | What it is |
|---|
via | string | |
kind | "integration" | "load" | |
from | string | |
to | string | |
function lineageOf(l: Loader): readonly LineageEdge[]
The edges of an integration: its source to its landing, its landing to its target.
| Parameter | What it is |
|---|
l | the loader |
Returns: the edges, in that order
Imported by 7 tests of the run (7 passed, 0 failed): the library's results
function loader(schema: LogicalSchema, spec: IntegrationSpec, options: LoaderOptions): Result<Loader, readonly IntegrationError[]>
An integration resolved against a schema.
| Parameter | What it is |
|---|
schema | the logical schema |
spec | what the project says |
options | the dialect, naming and schema qualifier the tables were bound with |
Returns: the loader, or why not
Imported by 7 tests of the run (7 passed, 0 failed): the library's results
interface Loader
An integration resolved against a schema and a dialect.
| Member | Type | What it is |
|---|
spec | IntegrationSpec | |
ref | string | The target's reference, quoted and qualified. |
tableName | string | The target's name as written, with the schema's words where the dialect has no schemas. |
columns | readonly ContractColumn[] | |
key | readonly ContractColumn[] | |
strategy | Strategy | |
dialect | Dialect | |
naming | Naming | |
qualify | (name: string) => string | The reference to a table of the library's own (the ledger) in the target's schema. |
tableNameOf | (name: string) => string | The name a table of the library's own is written by. |
Imported by 7 tests of the run (7 passed, 0 failed): the library's results
LoaderOptionsinterfaceno test imports itinterface LoaderOptions
What a loader is made with.
| Member | Type | What it is |
|---|
dialect | Dialect | |
naming? | Naming | |
schema? | string | The schema the tables are in, as bind was given it. |
SourceAdapterinterfaceno test imports itinterface SourceAdapter
What a source that is not SQL is: a hook that reads rows, or says why it could not.
| Member | Type | What it is |
|---|
name | string | |
read | () => Promise<Result<readonly Readonly<Record<string, unknown>>[], string>> | |
sourceLabelconstno test imports itconst sourceLabel: (s: SourceSpec) => string
A label of where the rows come from.
SourceSpectypeno test imports ittype SourceSpec =
| { readonly kind: "rows"; readonly rows: readonly Readonly<Record<string, unknown>>[] }
| { readonly kind: "csv"; readonly text: string; readonly delimiter?: string; readonly label?: string }
| { readonly kind: "attached"; readonly file: string; readonly relation: string; readonly alias?: string }
| { readonly kind: "adapter"; readonly adapter: SourceAdapter };
Where an integration's rows come from.
Strategytypeno test imports ittype Strategy = "append" | "upsert" | "replace" | "snapshot";
How the landed rows are put in the target.
function upstream(edges: readonly LineageEdge[], node: string): readonly string[]
Every node whose rows reach a node, nearest first.
| Parameter | What it is |
|---|
edges | the lineage |
node | a node as the edges name it |
Returns: the nodes
Imported by 7 tests of the run (7 passed, 0 failed): the library's results