IF Commons GitHub

logical/mod

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-planning-query-relations FR-003

The 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"

Source: commons/planning-query/src/logical/mod.ts

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

logicalnamespace
namespace logical
logical.PlanningDatatypeno test imports it
type 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 it
function 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 it
type 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 it
type Budget = { readonly maxRows?: number; readonly maxNodes?: number };

What a question may cost.

logical.DEFAULT_BUDGETconstno test imports it
const 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 it
type PlanningQuery = { readonly query: (sql: string, params?: readonly Value[]) => Result<Table, QueryProblem> };

Items that can be asked.

logical.CATALOGconstno test imports it
const CATALOG: Catalog

The catalog of the relations, made from the one list of them.

logical.openPlanningQueryfunctionno test imports it
function openPlanningQuery(data: PlanningData, options?: Budget & { readonly includeProposed?: boolean | undefined; }): PlanningQuery

The items, openable for questions.

logical.formatTablefunctionno test imports it
function formatTable(t: Table, format: "csv" | "json" | "table"): string

A table as the text of one of its formats.

PlanningDatatypeno test imports it
type 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.

tablesOffunction
function 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.

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

QueryProblemtypeno test imports it
type 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 it
type Budget = { readonly maxRows?: number; readonly maxNodes?: number };

What a question may cost.

DEFAULT_BUDGETconstno test imports it
const 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 it
type PlanningQuery = { readonly query: (sql: string, params?: readonly Value[]) => Result<Table, QueryProblem> };

Items that can be asked.

CATALOGconst
const CATALOG: Catalog

The catalog of the relations, made from the one list of them.

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

openPlanningQueryfunction
function openPlanningQuery(data: PlanningData, options?: Budget & { readonly includeProposed?: boolean | undefined; }): PlanningQuery

The items, openable for questions.

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

formatTablefunction
function formatTable(t: Table, format: "csv" | "json" | "table"): string

A table as the text of one of its formats.

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

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