IF Commons GitHub

surfaces/query/mod

Written to: 5 requirements: 5 proved, 0 partly, 0 failing, 0 with no test recorded. 0015-grc-query FR-001, 0015-grc-query FR-002, 0015-grc-query FR-003, 0015-grc-query FR-004, 0015-grc-query FR-005

Questions of the records of GRC in SQL (0015-grc-query): the documents of an assessment made into relations, and a read-only SQL answered over them with the SQL language library: its guard judges that the text is one read and binds it to the catalog, its engine answers it. No database is made and no record can be changed by a question.

import { queryRecords } from "@intellectual-frontiers/grc/surfaces/query";
// queryRecords(records, "SELECT control, status FROM control_state WHERE freshness = 'stale'");

Source: commons/grc/src/surfaces/query/mod.ts

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

Recordstype
type Records = AsOfInput & {
  readonly findings?: readonly Finding[];
  readonly evidence?: readonly Evidence[];
  readonly attestations?: readonly Attestation[];
};

Everything a question may be about: the as-of input, and what an assessment adds to it.

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

QueryOptionstypeno test imports it
type QueryOptions = {
  /** The most rows of the answer (1000 where none is given). */
  readonly limit?: number;
  /** The values of the parameters (`?`). */
  readonly params?: readonly Value[];
  /** The instant of `control_state` (the newest recorded where none is given). */
  readonly at?: string;
};

What may be given to a question.

Answertypeno test imports it
type Answer = { readonly columns: readonly string[]; readonly rows: readonly (readonly Value[])[]; readonly truncated: boolean };

What a question gives.

catalogOffunction
function catalogOf(): Catalog

The catalog of the relations, with the type of each column.

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

relationsOffunction
function relationsOf(records: Records, at?: string | undefined): Readonly<Record<string, Table>>

The relations of the records, the state of the controls being at the instant at.

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

queryRecordsfunction
function queryRecords(records: Records, sql: string, options?: QueryOptions): Result<Answer, string>

The answer to one read-only question over the records, or why it is refused (with its place) or cannot be answered.

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

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