IF Commons GitHub

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 it
interface ContractColumn

One column of the contract, resolved.

MemberTypeWhat it is
wordsstringThe words of its name, joined by a dot: how a row's keys and a CSV's header are matched.
namestringThe name it is written by.
typestringThe type as the target writes it.
requiredbooleanWhether the target requires a value: not optional and with no default.
IntegrationErrortypeno test imports it
type 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.

IntegrationSpecinterface
interface IntegrationSpec

What a project says of an integration.

MemberTypeWhat it is
namestring
tablestringThe target, by the words of its name.
sourceSourceSpec
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?Strategyupsert 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 it
interface LineageEdge

Rows went from one node to another.

MemberTypeWhat it is
viastring
kind"integration" | "load"
fromstring
tostring
lineageOffunction
function lineageOf(l: Loader): readonly LineageEdge[]

The edges of an integration: its source to its landing, its landing to its target.

ParameterWhat it is
lthe loader

Returns: the edges, in that order

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

loaderfunction
function loader(schema: LogicalSchema, spec: IntegrationSpec, options: LoaderOptions): Result<Loader, readonly IntegrationError[]>

An integration resolved against a schema.

ParameterWhat it is
schemathe logical schema
specwhat the project says
optionsthe 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

Loaderinterface
interface Loader

An integration resolved against a schema and a dialect.

MemberTypeWhat it is
specIntegrationSpec
refstringThe target's reference, quoted and qualified.
tableNamestringThe target's name as written, with the schema's words where the dialect has no schemas.
columnsreadonly ContractColumn[]
keyreadonly ContractColumn[]
strategyStrategy
dialectDialect
namingNaming
qualify(name: string) => stringThe reference to a table of the library's own (the ledger) in the target's schema.
tableNameOf(name: string) => stringThe 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 it
interface LoaderOptions

What a loader is made with.

MemberTypeWhat it is
dialectDialect
naming?Naming
schema?stringThe schema the tables are in, as bind was given it.
SourceAdapterinterfaceno test imports it
interface SourceAdapter

What a source that is not SQL is: a hook that reads rows, or says why it could not.

MemberTypeWhat it is
namestring
read() => Promise<Result<readonly Readonly<Record<string, unknown>>[], string>>
sourceLabelconstno test imports it
const sourceLabel: (s: SourceSpec) => string

A label of where the rows come from.

SourceSpectypeno test imports it
type 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 it
type Strategy = "append" | "upsert" | "replace" | "snapshot";

How the landed rows are put in the target.

upstreamfunction
function upstream(edges: readonly LineageEdge[], node: string): readonly string[]

Every node whose rows reach a node, nearest first.

ParameterWhat it is
edgesthe lineage
nodea node as the edges name it

Returns: the nodes

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.