IF Commons GitHub

sql/lifecycle/ledger

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 it
const chainOf: (previous: string, entry: Omit<LedgerEntry, "chain">) => string

The chain hash of an entry given the hash of the one before it.

ParameterWhat it is
previousthe chain hash of the entry before, or GENESIS
entrythe entry without its chain

Returns: the chain hash

ChainBreakinterfaceno test imports it
interface ChainBreak

Where a ledger is broken.

MemberTypeWhat it is
seqnumberThe place of the first entry that does not follow from the one before.
why"chain" | "seq"
EntryKindtypeno test imports it
type EntryKind = "step" | "repeatable";

What an entry is of: a step of the plan, or an object that is applied again when its text changes.

GENESISconst
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

LedgerEntryinterface
interface LedgerEntry

One entry of the ledger.

MemberTypeWhat it is
seqnumberIts place in the ledger, from 1.
kindEntryKind
keystringThe step's identifier, or the repeatable's key.
namestring
fromstringThe state the database was in, and was left in (empty for a repeatable).
tostring
hashstringWhat was applied: the step's identifier, or the hash of the repeatable's text.
chainstringThe hash of the entry before it and of this one's own content.
appliedAtstring
appliedBystring

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

nextEntryfunction
function nextEntry(entries: readonly LedgerEntry[], entry: Omit<LedgerEntry, "chain" | "seq">): LedgerEntry

The next entry of a ledger.

ParameterWhat it is
entriesthe ledger so far
entrywhat 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

verifyChainfunction
function verifyChain(entries: readonly LedgerEntry[]): ChainBreak | undefined

Whether a ledger is whole.

ParameterWhat it is
entriesthe entries, in order

Returns: the first break, or none

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

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