sql/extensions/kinds/kinds
Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0026-sql-kinds FR-001, 0026-sql-kinds FR-002, 0026-sql-kinds FR-003, 0026-sql-kinds FR-004
Kinds (commons data 0026-sql-kinds): reference data kept as CSV, read into typed rows, checked against a table of a logical schema, written as a TypeScript module, and given to integrations and ephemeral targets as they are.
Source: commons/data/sql/extensions/kinds/kinds.ts
5 of 9 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.
CheckErrortypeno test imports ittype CheckError =
| { 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: "empty-required"; readonly table: string; readonly column: string; readonly line: number };
Why a seed that a kind defines does not hold, as a value.
function checkKinds(kinds: Kinds, schema: LogicalSchema, table: string): readonly CheckError[]
Checks rows against a table of a schema.
| Parameter | What it is |
|---|
kinds | the rows |
schema | the logical schema |
table | the table, by the words of its name |
Returns: nothing wrong, or what is
Imported by 3 tests of the run (3 passed, 0 failed): the library's results
interface Kinds
The rows of a file.
| Member | Type | What it is |
|---|
name | string | |
columns | readonly { readonly name: string; readonly type: KindType; readonly nullable: boolean; }[] | |
rows | readonly Readonly<Record<string, Cell>>[] | |
key | readonly string[] | |
Imported by 3 tests of the run (3 passed, 0 failed): the library's results
function kindsFromCsv(text: string, options: KindsOptions): Result<Kinds, readonly KindsError[]>
Typed rows from CSV text.
| Parameter | What it is |
|---|
text | the text, with a header |
options | the name, types, delimiter and key |
Returns: the rows, or why not
Imported by 3 tests of the run (3 passed, 0 failed): the library's results
KindsErrortypeno test imports ittype KindsError =
| { readonly kind: "header"; readonly why: string }
| { readonly kind: "fields"; readonly line: nu… (464 characters)
type KindsError =
| { readonly kind: "header"; readonly why: string }
| { readonly kind: "fields"; readonly line: number; readonly expected: number; readonly found: number }
| { readonly kind: "type"; readonly line: number; readonly column: string; readonly expected: KindType; readonly value: string }
| { readonly kind: "duplicate-key"; readonly line: number; readonly key: readonly Cell[] }
| { readonly kind: "unknown-key"; readonly column: string };
Why a kind cannot be defined or used, as a value.
function kindsModule(kinds: Kinds, options?: { readonly source?: string | undefined; readonly typeName?: string | undefined; readonly constName?: string | undefined; }): string
A TypeScript module of the rows.
| Parameter | What it is |
|---|
kinds | the rows |
options | the file's name for the header, and the names of the type and the array |
Returns: the text of the module
Imported by 3 tests of the run (3 passed, 0 failed): the library's results
KindsOptionsinterfaceno test imports itinterface KindsOptions
What a file is read with.
| Member | Type | What it is |
|---|
name | string | The name of what the rows are of, for the module. |
types? | Readonly<Record<string, KindType>> | The types of columns, by header; text where not said. |
delimiter? | string | The delimiter; a comma where not said. |
key? | readonly string[] | The columns of the key; the first column where not said. |
KindTypetypeno test imports ittype KindType = "text" | "integer" | "number" | "boolean";
The type of a member of a kind: text, integer, number or boolean.
const rowsOf: (kinds: Kinds) => readonly Readonly<Record<string, Cell>>[]
The rows as the records integrations and ephemeral targets take.
| Parameter | What it is |
|---|
kinds | the rows |
Returns: the records
Imported by 3 tests of the run (3 passed, 0 failed): the library's results