IF Commons GitHub

sql/physical/generate

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0010-sql-generators FR-001, 0010-sql-generators FR-004, 0010-sql-generators FR-002, 0010-sql-generators FR-003

Generators (commons data 0010-sql-generators): what a person or a program reads of a schema is made from it. A generator is a value with an identifier and a function from a logical schema, a naming and an optional dialect to files, a path and a text each, or to error values; it knows no database and reads nothing else. An extension contributes it through the engine's point physical.generators, and generate runs the generators it is given.

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

4 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.

Artifactinterface
interface Artifact

A file a generator makes.

MemberTypeWhat it is
pathstringWhere it goes, relative to wherever the files are written, with /.
textstring

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

generatefunction
function generate(schema: LogicalSchema, options: GenerateOptions): Result<readonly Artifact[], readonly GenerateError[]>

Runs generators over a logical schema.

ParameterWhat it is
schemathe logical schema
optionsthe generators, the naming and the dialect

Returns: every file, in the order of the generators, or every error

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

GenerateContextinterfaceno test imports it
interface GenerateContext

What a generator is given.

MemberTypeWhat it is
schemaLogicalSchema
namingNaming
dialect?DialectThe dialect whose types a generator may write, where one is wanted.
GenerateErrortypeno test imports it
type GenerateError =
  | { readonly kind: "unsupported"; readonly generator: string; readonly element: LogicalId; readonly why: string }
  | { readonly kind: "path"; readonly path: string; readonly generators: readonly string[] };

What is wrong with a generation; generate returns all of it together.

GenerateOptionsinterfaceno test imports it
interface GenerateOptions

What generate is given besides the schema.

MemberTypeWhat it is
generatorsreadonly Generator[]
naming?NamingHow names are written; snake case where none is given.
dialect?Dialect
Generatorinterface
interface Generator

A generator.

MemberTypeWhat it is
idstring
describestringWhat it makes, in a few words.
generate(context: GenerateContext) => Result<readonly Artifact[], readonly GenerateError[]>

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

generatorsFromfunction
function generatorsFrom(composition: Composition): readonly Generator[]

The generators of a composition, in its order.

ParameterWhat it is
compositionthe project's composition

Returns: the generators its extensions contribute

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

generatorsPointconstno test imports it
const generatorsPoint: ContributionPoint<Generator>

The contribution point an extension fills to add a generator.

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