Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0011-sql-lifecycle FR-010
The ledger (commons data 0011-sql-lifecycle FR-010): the record of what was applied to a database, in order, each entry holding the hash of the entry before it. An entry that is changed, taken out, put in or moved breaks the chain from that entry on, so a ledger that has been touched by hand is found out.
Source: commons/data/sql/lifecycle/ledger.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.
chainOfconstno test imports itconst chainOf: (previous: string, entry: Omit<LedgerEntry, "chain">) => string
The chain hash of an entry given the hash of the one before it.
| Parameter | What it is |
|---|
previous | the chain hash of the entry before, or GENESIS |
entry | the entry without its chain |
Returns: the chain hash
ChainBreakinterfaceno test imports itinterface ChainBreak
Where a ledger is broken.
| Member | Type | What it is |
|---|
seq | number | The place of the first entry that does not follow from the one before. |
why | "chain" | "seq" | |
EntryKindtypeno test imports ittype EntryKind = "step" | "repeatable";
What an entry is of: a step of the plan, or an object that is applied again when its text changes.
const GENESIS: string
The chain hash of the first entry's predecessor.
Imported by 21 tests of the run (21 passed, 0 failed): the library's results
interface LedgerEntry
One entry of the ledger.
| Member | Type | What it is |
|---|
seq | number | Its place in the ledger, from 1. |
kind | EntryKind | |
key | string | The step's identifier, or the repeatable's key. |
name | string | |
from | string | The state the database was in, and was left in (empty for a repeatable). |
to | string | |
hash | string | What was applied: the step's identifier, or the hash of the repeatable's text. |
chain | string | The hash of the entry before it and of this one's own content. |
appliedAt | string | |
appliedBy | string | |
Imported by 21 tests of the run (21 passed, 0 failed): the library's results
function nextEntry(entries: readonly LedgerEntry[], entry: Omit<LedgerEntry, "chain" | "seq">): LedgerEntry
The next entry of a ledger.
| Parameter | What it is |
|---|
entries | the ledger so far |
entry | what is applied |
Returns: the entry, with its place and its chain
Imported by 21 tests of the run (21 passed, 0 failed): the library's results
function verifyChain(entries: readonly LedgerEntry[]): ChainBreak | undefined
Whether a ledger is whole.
| Parameter | What it is |
|---|
entries | the entries, in order |
Returns: the first break, or none
Imported by 13 tests of the run (13 passed, 0 failed): the library's results