IF Commons GitHub

sql/extensions/target/build

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0025-sql-target FR-001, 0025-sql-target FR-002, 0025-sql-target FR-003, 0025-sql-target FR-006

An ephemeral target (commons data 0025-sql-target): one SQL file made from governance and typed rows, the same bytes every time, committed and diffed in Git, and a database made from it in one transaction.

Source: commons/data/sql/extensions/target/build.ts

5 of 8 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Celltypeno test imports it
type Cell = string | number | boolean | null;

A value of a row.

Rowstype
type Rows = Readonly<Record<string, readonly Readonly<Record<string, Cell>>[]>>;

Rows by table, each a record of columns, both by the words of their names.

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

SizeFindinginterfaceno test imports it
interface SizeFinding

One table that has more rows than a limit.

MemberTypeWhat it is
tablestring
rowsnumber
limitnumber
sizeFindingsconst
const sizeFindings: (build: TargetBuild, limit: number) => readonly SizeFinding[]

The tables of a build with more rows than a limit.

ParameterWhat it is
buildthe build
limitthe most rows a table may have

Returns: what is over the limit

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

targetBuildfunction
function targetBuild(schema: LogicalSchema, options: TargetOptions): Result<TargetBuild, readonly TargetError[]>

Makes a build.

ParameterWhat it is
schemathe logical schema
optionsthe dialect, naming, schema qualifier, extensions and rows

Returns: the build, or why not

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

TargetBuildinterface
interface TargetBuild

A build: what is run, and the text of the file.

MemberTypeWhat it is
dialectDialect
statementsreadonly string[]The statements, in order: the structure, then the rows.
textstringThe text of the file.
countsReadonly<Record<string, number>>The number of rows of each table, in the order they are written.
statestringThe hash of the schema's state.
datastringThe hash of the rows.

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

TargetErrortypeno test imports it
type TargetError = | { readonly kind: "physical"; readonly errors: readonly PhysicalError[] } | { readonly kind: "un… (678 characters)
type TargetError =
  | { readonly kind: "physical"; readonly errors: readonly PhysicalError[] }
  | { 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 row: number }
  | { readonly kind: "duplicate-key"; readonly table: string; readonly key: readonly Cell[] }
  | { readonly kind: "duplicate-column"; readonly table: string; readonly column: string; readonly row: number }
  | { readonly kind: "cycle"; readonly tables: readonly string[] }
  | { readonly kind: "state" };

Why a target cannot be made from its description, as a value.

TargetOptionsinterface
interface TargetOptions

What a build is made with.

MemberTypeWhat it is
dialectDialect
naming?Naming
schema?stringThe schema the tables are in.
sources?readonly StatementSource[]
tableClauses?readonly TableClause[]
rows?Readonly<Record<string, readonly Readonly<Record<string, Cell>>[]>>The rows.
module?stringThe module the file was made from, for its header.
batch?numberThe rows to an INSERT; 100 where it is not said.

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

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