logical.CATALOGconstno test imports itconst CATALOG: CatalogThe catalog of the relations, made from the one list of them.
Asking the estate a question in SQL: one statement that only reads, refused with every reason before anything runs, bound to the catalog of the relations (an unknown table or column is said with the nearest), run by the engine of lang-sql over the relations built as the query names them, within a budget of rows, and given back as a table, JSON or CSV. Nothing here reads a file or the network: what an estate holds is given.
import { openEstateQuery } from "./query.ts";
const q = openEstateQuery({ assets: [], now: "2026-12-01T00:00:00Z" });
q.query("select count(*) as n from asset").kind; // "ok"logical.CATALOGconstno test imports itconst CATALOG: CatalogThe catalog of the relations, made from the one list of them.
logical.DEFAULT_BUDGETconstno test imports itconst DEFAULT_BUDGET: { readonly maxRows: 10000; readonly maxNodes: 2000; }The defaults: ten thousand rows and a statement of at most two thousand nodes.
logical.formatTablefunctionno test imports itfunction formatTable(t: Table, format: "csv" | "json" | "table"): stringA table as the text of one of its formats.
logical.openEstateQueryfunctionno test imports itfunction openEstateQuery(data: EstateData, budget?: Budget, live?: Live | undefined): EstateQueryThe estate, openable for questions.
logical.Budgettypeno test imports ittype Budget = { readonly maxRows?: number; readonly maxNodes?: number };What a question may cost.
logical.EstateQuerytypeno test imports ittype EstateQuery = {
/** One read-only statement, with `?` or `$1` for values given apart. */
readonly query: (sql: string, params?: readonly Value[]) => Result<Table, QueryProblem>;
};An estate that can be asked.
logical.Livetypeno test imports ittype Live = { readonly tables: Readonly<Record<string, Table>>; readonly status: Table };What the machines said, gathered before the question is asked: the live relations by name and the status of each machine and table.
logical.QueryProblemtypeno test imports ittype QueryProblem =
| { readonly kind: "refused"; readonly reasons: readonly string[] }
| { readonly kind: "failed"; readonly message: string }
| { readonly kind: "budget"; readonly message: string };Why a question was not answered.
CATALOGconstconst CATALOG: CatalogThe catalog of the relations, made from the one list of them.
DEFAULT_BUDGETconstno test imports itconst DEFAULT_BUDGET: { readonly maxRows: 10000; readonly maxNodes: 2000; }The defaults: ten thousand rows and a statement of at most two thousand nodes.
formatTablefunctionfunction formatTable(t: Table, format: "csv" | "json" | "table"): stringA table as the text of one of its formats.
openEstateQueryfunctionfunction openEstateQuery(data: EstateData, budget?: Budget, live?: Live | undefined): EstateQueryThe estate, openable for questions.
Budgettypeno test imports ittype Budget = { readonly maxRows?: number; readonly maxNodes?: number };What a question may cost.
EstateQuerytypeno test imports ittype EstateQuery = {
/** One read-only statement, with `?` or `$1` for values given apart. */
readonly query: (sql: string, params?: readonly Value[]) => Result<Table, QueryProblem>;
};An estate that can be asked.
Livetypeno test imports ittype Live = { readonly tables: Readonly<Record<string, Table>>; readonly status: Table };What the machines said, gathered before the question is asked: the live relations by name and the status of each machine and table.
QueryProblemtypeno test imports ittype QueryProblem =
| { readonly kind: "refused"; readonly reasons: readonly string[] }
| { readonly kind: "failed"; readonly message: string }
| { readonly kind: "budget"; readonly message: string };Why a question was not answered.