logicalnamespacenamespace logicalThe Logical layer of Planning Query: the rows of the relations made from the items, and asking a question in SQL (0002-planning-query-relations FR-002 to FR-004). 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 statement names them, within a budget of rows. Nothing here reads a file or the network: the items are given.
import { openPlanningQuery } from "./mod.ts";
const q = openPlanningQuery({ items: [], traces: [] });
q.query("select count(*) as n from issues").kind; // "ok"logicalnamespacenamespace logicallogical.PlanningDatatypeno test imports ittype PlanningData = { readonly items: readonly Item[]; readonly traces: readonly Trace[] };What can be asked: the items and the traces of the places they were seen in.
logical.tablesOffunctionno test imports itfunction tablesOf(data: PlanningData, includeProposed?: boolean): Readonly<Record<string, () => Table>>The relations of the items, each built when a statement names it; a proposed item is in issues only where includeProposed is true.
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.
logical.Budgettypeno test imports ittype Budget = { readonly maxRows?: number; readonly maxNodes?: number };What a question may cost.
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.PlanningQuerytypeno test imports ittype PlanningQuery = { readonly query: (sql: string, params?: readonly Value[]) => Result<Table, QueryProblem> };Items that can be asked.
logical.CATALOGconstno test imports itconst CATALOG: CatalogThe catalog of the relations, made from the one list of them.
logical.openPlanningQueryfunctionno test imports itfunction openPlanningQuery(data: PlanningData, options?: Budget & { readonly includeProposed?: boolean | undefined; }): PlanningQueryThe items, openable for questions.
logical.formatTablefunctionno test imports itfunction formatTable(t: Table, format: "csv" | "json" | "table"): stringA table as the text of one of its formats.
PlanningDatatypeno test imports ittype PlanningData = { readonly items: readonly Item[]; readonly traces: readonly Trace[] };What can be asked: the items and the traces of the places they were seen in.
tablesOffunctionfunction tablesOf(data: PlanningData, includeProposed?: boolean): Readonly<Record<string, () => Table>>The relations of the items, each built when a statement names it; a proposed item is in issues only where includeProposed is true.
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.
Budgettypeno test imports ittype Budget = { readonly maxRows?: number; readonly maxNodes?: number };What a question may cost.
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.
PlanningQuerytypeno test imports ittype PlanningQuery = { readonly query: (sql: string, params?: readonly Value[]) => Result<Table, QueryProblem> };Items that can be asked.
CATALOGconstconst CATALOG: CatalogThe catalog of the relations, made from the one list of them.
openPlanningQueryfunctionfunction openPlanningQuery(data: PlanningData, options?: Budget & { readonly includeProposed?: boolean | undefined; }): PlanningQueryThe items, openable for questions.
formatTablefunctionfunction formatTable(t: Table, format: "csv" | "json" | "table"): stringA table as the text of one of its formats.