IF Commons GitHub

sql/extensions/convergence/connect

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0019-sql-convergence FR-007, 0019-sql-convergence FR-008, 0019-sql-convergence FR-009, 0019-sql-convergence FR-010

Autonomous convergence and the version gate (commons data 0019-sql-convergence FR-007 to FR-010): on first access the plan is computed and applied if the policy allows every step, held for a person if it does not, and resumed at the next access if a step fails; and a database is checked against the state an application expects.

Source: commons/data/sql/extensions/convergence/connect.ts

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

connectfunction
function connect(driver: Driver, dialect: Dialect, schema: LogicalSchema, desired: Desired, settings: Convergence, options?: ConnectOptions): Promise<ConnectResult>

The first access of an application to a database.

ParameterWhat it is
driverthe database
dialectits dialect
schemathe logical schema wanted
desiredthe dialect, naming, schema and what extensions add
settingsthe settings, with every default filled
optionswhat plan is given, a rehearsal and what the run is given

Returns: what it came to

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

ConnectOptionsinterfaceno test imports it
interface ConnectOptions extends PlanOptions

What a first access is given besides the settings.

MemberTypeWhat it is
rehearse?((plan: Plan) => Promise<boolean>)Said by a rehearsal of the plan on a copy: where it says no, the plan is held.
run?Omit<RunOptions, "empty">
allow?{ readonly destructive?: boolean | undefined; }
fallback?FallbackMakes what the core cannot make in place, such as a table that is made again.
manual?readonly ManualStep[]
transforms?readonly StepTransform[]
requireIdempotent?booleanRefuse, as an error value, a step that is only safe to run twice because of the ledger (0012-sql-idempotency FR-007).
ConnectResulttypeno test imports it
type ConnectResult =
  | { readonly kind: "current"; readonly applied: Applied }
  | { readonly kind: "applied"; readonly applied: Applied }
  | { readonly kind: "held"; readonly why: readonly Held[]; readonly plan?: Plan }
  | { readonly kind: "failed"; readonly error: RunError };

What a first access came to.

GateErrortypeno test imports it
type GateError =
  { readonly kind: "state"; readonly expected: string; readonly found: string } | { readonly kind: "unsupported"; readonly why: string };

Why a database is not where an application expects.

versionGatefunction
function versionGate(driver: Driver, dialect: Dialect, expected: State, ignore?: readonly string[]): Promise<Result<string, GateError>>

Whether a database is in the state an application expects.

ParameterWhat it is
driverthe database
dialectits dialect
expectedthe state the application expects
ignorethe names of tables the reader leaves out

Returns: the hash, or why the application should not start

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

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