Wordtypeno test imports ittype 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.
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"Wordtypeno test imports ittype 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 itconst MERGEABLE_ROLES: readonly ["versions", "blobs"]The tables a dump carries, by what each holds: the version rows and the blobs.
LOCAL_ROLESconstno test imports itconst 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 itconst 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_ROLESconstconst TABLE_ROLES: readonly ["versions", "blobs", "meta", "trust", "epochs", "cache", "search", "heads", "names", "siblings", "vector"]Every name of a store, by what it holds.
TableRoletypeno test imports ittype TableRole = (typeof TABLE_ROLES)[number];The role of one table or view.
Namingtypeno test imports ittype Naming = { readonly prefix: Word; readonly schema?: Word };The names of the tables of one store.
parseWordfunctionfunction parseWord(text: string): Result<Word, string>A word of a name, or why the text is not one.
NamingOptionstypeno test imports ittype NamingOptions = { readonly prefix?: string; readonly schema?: string };The options a naming is made from: the prefix is anyfs where none is given.
parseNamingfunctionfunction parseNaming(options?: NamingOptions): Result<Naming, string>A naming from text, or the reason a word of it is not one.
tableOffunctionfunction tableOf(naming: Naming, role: "blobs" | "cache" | "epochs" | "heads" | "meta" | "names" | "search" | "siblings" | "trust" | "vector" | "versions"): stringThe name of the table of a role: the prefix, an underscore and the role.
indexOffunctionno test imports itfunction indexOf(naming: Naming, role: "blobs" | "cache" | "epochs" | "heads" | "meta" | "names" | "search" | "siblings" | "trust" | "vector" | "versions", on: string): stringThe name of an index of a table of a role, by what it is on.