IF Commons GitHub

sql/meaning/mod

Written to: 6 requirements: 6 proved, 0 partly, 0 failing, 0 with no test recorded. 0061-meaning-registers FR-006, 0061-meaning-registers FR-007, 0061-meaning-registers FR-008, 0061-meaning-registers FR-009, 0061-meaning-registers FR-010, 0061-meaning-registers FR-011

The meaning registers at work (commons data 0061-meaning-registers): the code that reads the tables of the meaning model (models/meaning) and the checks that are made of data without one. A source value is translated by the mappings that are approved and hold at a time, and the coverage of a mapping says which observed values nothing maps; a null rule is applied to say what a missing value is; the variances that have expired are found; a column is profiled with counts only; and a seeded generator makes synthetic rows, with a rate of absence and of duplicates, that are the same for the same seed.

Source: commons/data/sql/meaning/mod.ts

6 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.

Translationtypeno test imports it
type Translation =
  | { readonly kind: "mapped"; readonly mappingId: string; readonly targetField: string; readonly targetValue: string | null; readonly relationshipType: string }
  | { readonly kind: "unmapped" }
  | { readonly kind: "ambiguous"; readonly mappingIds: readonly string[] };

What translating one source value found.

translatefunction
function translate(on: Runner, source: Source): Promise<Translation>

Translates one source value: by the approved mapping that holds at the time. Where two hold, it is ambiguous and nothing is chosen for the caller; where none does, it is unmapped.

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

Coverageinterfaceno test imports it
interface Coverage

How much of what was observed a field's mappings cover.

MemberTypeWhat it is
observednumberHow many observations there were, with repeats.
mappednumberHow many of them a mapping covers.
sharenumberThe share covered, 1 where nothing was observed.
unmappedreadonly { readonly value: string; readonly seen: number; }[]The values nothing maps, with how many times each was seen, the most seen first.
coveragefunction
function coverage(on: Runner, system: string, field: string, observed: Iterable<string | null | undefined>, asOf?: string | Date): Promise<Coverage>

Says which of the values observed in a field a mapping does not cover, as the mapping of the book's mapping-coverage check.

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

Resolvedtypeno test imports it
type Resolved =
  | { readonly kind: "present"; readonly value: string }
  | { readonly kind: "absent"; readonly absence: string }
  | { readonly kind: "defaulted"; readonly value: string; readonly absence: string | null }
  | { readonly kind: "rejected"; readonly why: string };

What a rule says of one value.

NullRuleRowinterfaceno test imports it
interface NullRuleRow

A null rule as a row of the table gives it.

MemberTypeWhat it is
policy"allow_absent" | "default_to" | "reject"
absence?string | null
defaultValue?string | null
isMissingconstno test imports it
const isMissing: (v: unknown) => boolean

Whether a value is missing: null, undefined or only spaces.

ruleOffunction
function ruleOf(on: Runner, subject: string): Promise<NullRuleRow | undefined>

Reads the rule of a table and column, none where it has none.

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

DueVarianceinterfaceno test imports it
interface DueVariance

A variance that is still accepted past its date, or that was never decided.

MemberTypeWhat it is
varianceIdstring
subjectstring
statusstring
expiresAtstring | null
why"expired" | "undecided"
dueVariancesfunction
function dueVariances(on: Runner, asOf?: string | Date): Promise<readonly DueVariance[]>

Finds the variances that need a decision: accepted and past their date, and open ones, which nobody has decided.

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

ColumnProfileinterfaceno test imports it
interface ColumnProfile

What profiling one column found: counts only, never the values it holds beyond the lowest and highest.

MemberTypeWhat it is
columnstring
rowsnumber
nullsnumber
distinctnumber
minunknown
maxunknown
profilefunction
function profile(on: Runner, table: Table<never, never, string>, columns: readonly string[]): Promise<readonly ColumnProfile[]>

Profiles columns of a table with counts, as one query for each: how many rows, how many null, how many distinct, and the lowest and highest.

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

randomfunctionno test imports it
function random(seed: number): () => number

The seeded pseudo-random source: the same seed makes the same numbers, on every engine.

SyntheticColumninterfaceno test imports it
interface SyntheticColumn

A column of synthetic rows.

MemberTypeWhat it is
makeGenerator
absent?numberThe share of rows where it is missing, 0 where not given.
SyntheticSpecinterfaceno test imports it
interface SyntheticSpec

What is asked of the generator.

MemberTypeWhat it is
seednumber
rowsnumber
columnsReadonly<Record<string, SyntheticColumn>>
duplicates?numberThe share of rows that repeat an earlier row, to make duplicates on purpose.
syntheticfunction
function synthetic(spec: SyntheticSpec): Record<string, string | number | null>[]

Makes synthetic rows: they hold no real person's data, and the same spec makes the same rows.

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

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