IF Commons GitHub

sql/typed/generate

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0053-sql-typed FR-008, 0053-sql-typed FR-009

The typed tables of a model (commons data 0053-sql-typed): each model (a module of governance) gets a file <model>.auto.ts of the tables that it owns, made from the logical schema and governance and never written by hand: for each table a row type, an insert type (what the database fills may be left out), a key type, and a defineTable value whose columns are typed from the model (a closed list of codes is a union of its names). It reads nothing but the schema, the modules and the naming; the tool tools/typed.ts writes the files and checks that they are up to date.

Source: commons/data/sql/typed/generate.ts

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

stemOfconstno test imports it
const stemOf: (module: Module) => string

The words of a model's name (arcaParty) joined by hyphens: the stem of its file.

ownerOffunctionno test imports it
function ownerOf(table: Table, domain: string, modules: readonly Module[]): Module | undefined

The module that owns a table: the one that has the concept or the code list it was made from.

TypedOptionsinterfaceno test imports it
interface TypedOptions

What the generator is told.

MemberTypeWhat it is
modulesreadonly Module[]The modules of the composition, in the order they were composed; a table belongs to the one whose concept or code list it came from.
naming?Naming
TypedGenerateErrortypeno test imports it
type TypedGenerateError = { readonly kind: "orphan"; readonly table: string } | { readonly kind: "collision"; readonly module: string; readonly name: string };

What is wrong with a generation.

typedFilesfunctionno test imports it
function typedFiles(schema: LogicalSchema, options: TypedOptions): Result<readonly Artifact[], readonly TypedGenerateError[]>

The files of the typed tables: one for each module that owns a table, and mod.ts, which names them.

ParameterWhat it is
schemathe logical schema of the whole composition
optionsthe modules and the naming

Returns: the files, or the tables no module owns and the names that are the same

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