IF Commons GitHub

governance/naming

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-sql-governance FR-002

The names of the tables of a store: a prefix, which every table carries, and a schema where the database has schemas. Both are made only by parseNaming, from lower case words, so that a name is written into a statement only as an identifier of the language and never by hand, and so that several stores live in one database side by side.

import { parseNaming, tableOf } from "./naming.ts";
const n = parseNaming({ prefix: "fleet" });
n.kind === "ok" && tableOf(n.value, "versions"); // "fleet_versions"

Source: commons/anyfs-sql/src/governance/naming.ts

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

Wordtypeno test imports it
type Word = Brand<string, "anyfs sql word">;

A word of a table name: lower case letters, digits and underscores, starting with a letter, at most 32 characters. Made only by parseWord.

MERGEABLE_ROLESconstno test imports it
const MERGEABLE_ROLES: readonly ["versions", "blobs"]

The tables a dump carries, by what each holds: the version rows and the blobs.

LOCAL_ROLESconstno test imports it
const LOCAL_ROLES: readonly ["meta", "trust", "epochs", "cache", "search"]

The tables that belong to one replica and that no import writes: its facts and identity, whom it trusts, the epochs it holds and its caches (the deltas held back, and the index of search).

VIEW_ROLESconstno test imports it
const VIEW_ROLES: readonly ["heads", "names", "siblings", "vector"]

The views made from the rows and nothing else: the heads of every path, the files that are there, the siblings and the version vector.

TABLE_ROLESconst
const TABLE_ROLES: readonly ["versions", "blobs", "meta", "trust", "epochs", "cache", "search", "heads", "names", "siblings", "vector"]

Every name of a store, by what it holds.

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

TableRoletypeno test imports it
type TableRole = (typeof TABLE_ROLES)[number];

The role of one table or view.

Namingtypeno test imports it
type Naming = { readonly prefix: Word; readonly schema?: Word };

The names of the tables of one store.

parseWordfunction
function parseWord(text: string): Result<Word, string>

A word of a name, or why the text is not one.

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

NamingOptionstypeno test imports it
type NamingOptions = { readonly prefix?: string; readonly schema?: string };

The options a naming is made from: the prefix is anyfs where none is given.

parseNamingfunction
function parseNaming(options?: NamingOptions): Result<Naming, string>

A naming from text, or the reason a word of it is not one.

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

tableOffunction
function tableOf(naming: Naming, role: "blobs" | "cache" | "epochs" | "heads" | "meta" | "names" | "search" | "siblings" | "trust" | "vector" | "versions"): string

The name of the table of a role: the prefix, an underscore and the role.

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

indexOffunctionno test imports it
function indexOf(naming: Naming, role: "blobs" | "cache" | "epochs" | "heads" | "meta" | "names" | "search" | "siblings" | "trust" | "vector" | "versions", on: string): string

The name of an index of a table of a role, by what it is on.

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