IF Commons GitHub

governance/query

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-query-safety FR-001, 0004-query-safety FR-002

What a query is allowed and what it may cost (commons anyfs-query 0004-query-safety FR-001, FR-002): the consent a place is given, the budget of a run, the way a run ends short of its end, the statistics a run reports, and every way a query can fail as one value of one closed type with the span of what was wrong.

Source: commons/anyfs-query/src/governance/query.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.

Consenttypeno test imports it
type Consent = "none" | "metadata" | "content";

What a query may do at a place: nothing, read what a listing says, or read the objects too.

coversconst
const covers: (given: Consent, needed: Consent) => boolean

Whether a consent given covers a consent needed.

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

consentForconstno test imports it
const consentFor: (table: "content" | "files" | "places" | "revisions") => Consent

The consent a table needs: content reads objects; the others need only what a listing says.

Budgettypeno test imports it
type Budget = {
  readonly maxListed: number;
  readonly maxRead: number;
  readonly maxBytes: number;
  readonly maxRows: number;
  readonly deadlineMs: number;
};

The limits of a run: objects listed, objects read, bytes read, rows given, and the time in milliseconds.

DEFAULT_BUDGETconst
const DEFAULT_BUDGET: Budget

The budget of a run that was given none.

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

parseBudgetfunction
function parseBudget(given: Partial<Budget>): Result<Budget, string>

A budget of what is given over the default, or why it is not one: every limit is a whole number of at least 1.

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

Truncationtypeno test imports it
type Truncation = "listed" | "read" | "bytes" | "rows" | "deadline";

The limit a run ended at, short of its end.

Statstypeno test imports it
type Stats = { readonly listCalls: number; readonly listed: number; readonly statCalls: number; readonly read: number; readonly bytes: number };

What a run did.

Diagnostictypeno test imports it
type Diagnostic = { readonly start: number; readonly end: number; readonly message: string; readonly suggestion?: string };

Something wrong with the text of a query, with the half-open range of what it was in the text.

QueryProblemtypeno test imports it
type QueryProblem = | { readonly kind: "syntax"; readonly diagnostics: readonly Diagnostic[] } | { readonly kind: "p… (928 characters)
type QueryProblem =
  | { readonly kind: "syntax"; readonly diagnostics: readonly Diagnostic[] }
  | { readonly kind: "profile"; readonly diagnostics: readonly Diagnostic[] }
  | { readonly kind: "names"; readonly diagnostics: readonly Diagnostic[] }
  | { readonly kind: "plan"; readonly diagnostics: readonly Diagnostic[] }
  | { readonly kind: "run"; readonly diagnostics: readonly Diagnostic[] }
  | { readonly kind: "place"; readonly place: string; readonly reason: string }
  | { readonly kind: "consent"; readonly place: string; readonly needed: Consent; readonly granted: Consent }
  | { readonly kind: "capability"; readonly place: string; readonly table: TableName; readonly needed: Capability }
  | { readonly kind: "path-needed"; readonly table: TableName; readonly why: string }
  | { readonly kind: "budget"; readonly why: string }
  | { readonly kind: "store"; readonly place: string; readonly problem: Problem };

Every way a query fails.

positionOffunctionno test imports it
function positionOf(text: string, offset: number): { readonly line: number; readonly column: number; }

The line a person reads for the position in a text: its line and column, from one.

describeQueryProblemfunction
function describeQueryProblem(text: string, p: QueryProblem): string

A problem as the sentences a person reads, one to a line.

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

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