IF Commons GitHub

sql/extensions/issues/sync

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0045-issues-model FR-003, 0045-issues-model FR-004, 0045-issues-model FR-005

Keeps the records of the issues model in step with the issues in the code (commons data 0045-issues-model): each issue is a record by its scope and number with a hash of what the code says, so that a sync adds what is new, rewrites what changed, marks what the code no longer has as withdrawn (never deleting it) and brings back what returns. All of it is one transaction and is recorded in a ledger; where the records already match the code nothing is written.

Source: commons/data/sql/extensions/issues/sync.ts

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

contentHashOfconstno test imports it
const contentHashOf: (i: Readonly<IssueSpec>) => string

The hash of what the code says of an issue; a change of anything of it changes the hash.

syncIssuesfunction
function syncIssues(driver: Driver, schema: LogicalSchema, dialect: Dialect, sets: readonly IssueSet[], options?: SyncOptions): Promise<Result<readonly SyncReport[], SyncError>>

Brings the records of the issues of some scopes in step with the code.

ParameterWhat it is
driverthe database
schemathe logical schema that has the issues model
dialecthow the engine writes SQL
setsthe issues of each scope, as the code has them
optionsthe naming, the schema, the clock

Returns: what each scope's sync did, or why nothing changed

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

SyncErrortypeno test imports it
type SyncError = { readonly kind: "schema"; readonly errors: readonly RefError[] } | { readonly kind: "database"; readonly message: string };

Why a sync changed nothing.

SyncOptionsinterfaceno test imports it
interface SyncOptions

What a sync is given besides the issues.

MemberTypeWhat it is
naming?Naming
schema?stringThe schema the tables are in.
now?(() => string)
newId?(() => string)
recordUnchanged?booleanWhether to record a run that found nothing to do; by default it writes nothing.
SyncReportinterfaceno test imports it
interface SyncReport

What one scope's sync did.

MemberTypeWhat it is
scopestring
outcome"synced" | "unchanged"
insertednumber
updatednumber
withdrawnnumber
reopenednumber
unchangednumber
sourceHashstringA hash of the issues of the code.

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