tcmts.cli.data_pages

Types

RowField type
A field of a row, as a form edits it: its name, its type as written, what kind of input it takes (text, a number, true or false, a date, one of its values, or else JSON), the values it takes (one of them), and whether it may be left out, or be null.

Server

dataPage (cb: Codebase, table: string, q: { offset: number; limit: number; search?: string | undefined; sort…
A page of a table's rows for a viewer: searched (anywhere in the row), filtered (fields equal to values), sorted (by a field, the id or when it was written; newest first by default) and paged in SQLite. Each row's cells (strings as they are, dates as ISO, small things inline, objects as one short line), and the row in full, and as JSON.
dataTables (cb: Codebase) => { table: string; rows: number; older: number; last?: number | undefined; path?: s…
Every table with data, and every table the codebase declares: rows, how many are stored as an older row type than the declaring definition's, when one was last written, and that definition.
deleteRow (cb: Codebase, table: string, id: string) => boolean
Delete row `id` of `table`: whether there was one.
readRow (cb: Codebase, table: string, id: string) => { value: unknown; updated: number; schema: string; } |…
Row `id` of `table` as it's stored: its value (decoded), when it was written, and the schema it was written with.
rowSummary (v: unknown) => string
A value in one short line.
withStore <T>(cb: Codebase, fn: (db: DatabaseSync) => T) => T | undefined
Open the app data store read-only, or undefined while there's no data yet.
withWritableStore <T>(cb: Codebase, fn: (db: DatabaseSync) => T) => T
Open the app data store to write (made, as the server makes it, if there's none yet), for `fn`, closed after.
writeRow (cb: Codebase, table: string, id: string | undefined, value: unknown) => string
Write `value` as row `id` of `table` (a new row, with a new id, if there's none), as the table's own writes are: checked against its row type first (the reason, if it doesn't fit), recorded with its schema, and refused when it would share a unique field with another row (that row named). Its id.

Shared

declaredTables (cb: Codebase) => Map<string, { path: string; hash: string; schema: string; fields: { name: string;…
Tables the codebase declares: their definition, row schema, the row type's fields (columns), and which are unique and indexed.
fromJson (s: Schema, v: unknown, defs: Schema[]) => unknown
JSON (as `toJson` writes it) as a value of schema `s`: strings where it has dates become dates, pairs where it has a map a map, arrays where it has a set a set, digits where it has a bigint a bigint; a union's first member it then fits. What doesn't fit is left as it is, for the check to say so.
rowFields (t: TableSchema) => RowField[]
A table's row fields as a form edits them (`RowField`), from its row type; none if its rows aren't objects.
sampleOf (s: Schema, defs: Schema[], depth?: number) => unknown
A value of schema `s` to start a new row from: each field a value of its type (the first of a union's, preferring one that isn't nothing), optional fields left out.
tableSchemaOf (cb: Codebase, table: string) => TableSchema | undefined
The table declared as `table` in the codebase (its name), with its row type: what writing to it needs.
toJson (v: unknown) => unknown
A row's value as JSON, to read and edit: dates as ISO strings, maps as [key, value] pairs, sets and arrays as arrays, bigints as their digits; `fromJson` brings it back by the table's row type.