IF Commons GitHub

logical/query

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0003-planning-reconcile FR-011

The query algebra (0037-planning FR-020): a typed, pure and read-only question over the items, events, links and traces (select, filter by state, kind, label, assignee, severity and origin, join, order, limit). A proposed item is not counted unless the question says so, and a surface (the SQL relations, planctl query) is a projection of this and not a second definition.

import { runQuery } from "./query.ts";
// runQuery(data, { from: "items", where: { state: ["open"] }, order: { by: "title" }, limit: 10 })

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

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

logical.Datatypeno test imports it
type Data = { readonly items: readonly Item[]; readonly traces: readonly Trace[] };

What can be asked.

logical.ItemFiltertypeno test imports it
type ItemFilter = {
  readonly state?: readonly StateKind[];
  readonly kind?: readonly ItemKind[];
  readonly label?: string;
  readonly assignee?: string;
  readonly severity?: readonly Severity[];
  readonly origin?: readonly Origin[];
  /** A proposed item is not counted unless this is true. */
  readonly includeProposed?: boolean;
};

A filter on items.

logical.ItemOrdertypeno test imports it
type ItemOrder = "id" | "title" | "state" | "severity" | "openedAt" | "updatedAt";

The fields items are ordered by.

logical.Orderingtypeno test imports it
type Ordering = { readonly by: ItemOrder; readonly desc?: boolean };

An ordering.

logical.Querytypeno test imports it
type Query = | { readonly from: "items"; readonly where?: ItemFilter; readonly order?: Ordering; readonly limit?: numb… (565 characters)
type Query =
  | { readonly from: "items"; readonly where?: ItemFilter; readonly order?: Ordering; readonly limit?: number }
  | { readonly from: "events"; readonly where?: ItemFilter; readonly type?: readonly EventType[]; readonly limit?: number }
  | { readonly from: "links"; readonly where?: ItemFilter; readonly limit?: number }
  | { readonly from: "traces"; readonly where?: ItemFilter; readonly source?: string; readonly limit?: number }
  | { readonly from: "items-traces"; readonly where?: ItemFilter; readonly order?: Ordering; readonly limit?: number };

A question.

logical.Rowtypeno test imports it
type Row =
  | { readonly kind: "item"; readonly item: Item }
  | { readonly kind: "event"; readonly event: ItemEvent }
  | { readonly kind: "link"; readonly link: Link }
  | { readonly kind: "trace"; readonly trace: Trace }
  | { readonly kind: "item-trace"; readonly item: Item; readonly trace: Trace };

What a question gives back.

logical.passesfunctionno test imports it
function passes(item: Item, f: ItemFilter | undefined): boolean

Whether an item passes a filter.

logical.runQueryfunctionno test imports it
function runQuery(data: Data, q: Query): readonly Row[]

The rows a question gives, in an order that is a function of the data and the question alone.

Datatypeno test imports it
type Data = { readonly items: readonly Item[]; readonly traces: readonly Trace[] };

What can be asked.

ItemFiltertypeno test imports it
type ItemFilter = {
  readonly state?: readonly StateKind[];
  readonly kind?: readonly ItemKind[];
  readonly label?: string;
  readonly assignee?: string;
  readonly severity?: readonly Severity[];
  readonly origin?: readonly Origin[];
  /** A proposed item is not counted unless this is true. */
  readonly includeProposed?: boolean;
};

A filter on items.

ItemOrdertypeno test imports it
type ItemOrder = "id" | "title" | "state" | "severity" | "openedAt" | "updatedAt";

The fields items are ordered by.

Orderingtypeno test imports it
type Ordering = { readonly by: ItemOrder; readonly desc?: boolean };

An ordering.

Querytypeno test imports it
type Query = | { readonly from: "items"; readonly where?: ItemFilter; readonly order?: Ordering; readonly limit?: numb… (565 characters)
type Query =
  | { readonly from: "items"; readonly where?: ItemFilter; readonly order?: Ordering; readonly limit?: number }
  | { readonly from: "events"; readonly where?: ItemFilter; readonly type?: readonly EventType[]; readonly limit?: number }
  | { readonly from: "links"; readonly where?: ItemFilter; readonly limit?: number }
  | { readonly from: "traces"; readonly where?: ItemFilter; readonly source?: string; readonly limit?: number }
  | { readonly from: "items-traces"; readonly where?: ItemFilter; readonly order?: Ordering; readonly limit?: number };

A question.

Rowtypeno test imports it
type Row =
  | { readonly kind: "item"; readonly item: Item }
  | { readonly kind: "event"; readonly event: ItemEvent }
  | { readonly kind: "link"; readonly link: Link }
  | { readonly kind: "trace"; readonly trace: Trace }
  | { readonly kind: "item-trace"; readonly item: Item; readonly trace: Trace };

What a question gives back.

passesfunctionno test imports it
function passes(item: Item, f: ItemFilter | undefined): boolean

Whether an item passes a filter.

runQueryfunctionno test imports it
function runQuery(data: Data, q: Query): readonly Row[]

The rows a question gives, in an order that is a function of the data and the question alone.

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