IF Commons GitHub

sql/presets/mod

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0021-sql-presets FR-001

Presets (commons data 0021-sql-presets): the four ways a team works, each a strategy with the features it needs and the settings it calls for. A preset is data; nothing is applied by choosing one.

const p = must(preset("autonomous-convergence"));
connect(driver, dialect, schema, { dialect }, p.convergence!, { ...p.planOptions, run: p.runOptions(dialect) });

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

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

presetNamesconst
const presetNames: readonly ["reviewed-convergence", "autonomous-convergence", "team-managed", "dba-managed"]

The ways a team works, the primary ones first: convergence computes each database's plan from the state it is in, and history replays files that people prepared.

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

PresetNametypeno test imports it
type PresetName = (typeof presetNames)[number];

The name of a preset: a ready-made choice of models and settings.

defaultPresetconst
const defaultPreset: "autonomous-convergence" | "dba-managed" | "reviewed-convergence" | "team-managed"

The preset a project gets when it names none: convergence, reviewed by a person, is the primary way.

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

PresetChangesinterfaceno test imports it
interface PresetChanges

What a project changes of a preset; what is not said is the preset's.

MemberTypeWhat it is
history?HistorySettings
convergence?ConvergenceSettings
safety?SafetySettings
idempotency?IdempotencySettings
report?ReportSettings
Presetinterface
interface Preset

A preset with every setting filled.

MemberTypeWhat it is
name"autonomous-convergence" | "dba-managed" | "reviewed-convergence" | "team-managed"
strategy"convergence" | "history"
rolesstringWho writes the SQL, who reviews it and who applies it.
historyHistory | undefined
convergenceConvergence | undefined
safetySafetyKit
idempotencyIdempotencySettings
reportReport
planOptionsPick<PlanOptions, "requireIdempotent" | "transforms">What plan is given: the transforms (quarantine, locks, validation, verification, then idempotency) and whether a step only the ledger guards is refused.
runOptions(dialect: Dialect) => Omit<RunOptions, "empty">What execute is given: to try a step again on a lock timeout, where the dialect has one.

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

PresetErrortypeno test imports it
type PresetError =
  | { readonly kind: "unknown"; readonly name: string; readonly known: readonly string[] }
  | { readonly kind: "not-used"; readonly preset: PresetName; readonly settings: "history" | "convergence" };

Why a preset cannot be applied, as a value.

presetfunction
function preset(name?: string, changes?: PresetChanges): Result<Preset, PresetError>

A preset, with a project's changes.

ParameterWhat it is
nameone of the four names
changeswhat a project changes

Returns: the preset with every setting, or why not

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

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