IF Commons GitHub

physical/store

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0004-planning-sources FR-001

The store of events over an AnyFS store (0037-planning FR-007, FR-038): one file for each event at <item>/<event>.json5, the traces of the sources under .traces/ and the outbox under .outbox/. Loading is total (a file that is not of the schema is a finding and is not read), gives each item by fold and gives the clock after every id it holds, so that the next id is after every id taken; an event is written expecting its file to be absent, so that an event is never replaced; two stores merge by the union of their event files.

import { loadStore } from "./store.ts";
// const loaded = await loadStore(store, { clock, wallMs, policy });

Source: commons/planning/src/physical/store.ts

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

physical.PlanningStoreBackendtypeno test imports it
type PlanningStoreBackend = Store<"read" | "write" | "list" | "cas">;

An AnyFS store of what a planning store needs: read, write, list and the expectation of a revision.

physical.StoreFindingtypeno test imports it
type StoreFinding = { readonly path: string; readonly message: string };

A file of the store that could not be read, and why.

physical.StoreProblemtypeno test imports it
type StoreProblem = { readonly kind: "store"; readonly message: string };

Why the store could not be read or written.

physical.Loadedtypeno test imports it
type Loaded = {
  readonly events: readonly ItemEvent[];
  readonly items: readonly Item[];
  readonly traces: readonly Trace[];
  readonly outbox: readonly OutboxEntry[];
  readonly findings: readonly StoreFinding[];
  /** The clock after every id the store holds: the next id made from it comes after them all. */
  readonly clock: Clock;
};

What a store holds.

physical.loadStorefunctionno test imports it
function loadStore(store: PlanningStoreBackend, options: { readonly clock: Clock; readonly wallMs: number; readonly policy?: Policy | undefined; }): Promise<Result<Loaded, StoreProblem>>

What a store holds: the events (each file read once), the items folded under the policy, the traces and the outbox.

physical.writeEventsfunctionno test imports it
function writeEvents(store: PlanningStoreBackend, events: readonly ItemEvent[]): Promise<Result<number, StoreProblem>>

Writes events: each file expects to be absent, an event already there with the same text is not an error and one with other text is. Returns how many were new.

physical.tracePathfunctionno test imports it
function tracePath(t: Pick<Trace, "fingerprint" | "source">): Promise<string>

The path of a trace: the source and the hash of the fingerprint.

physical.writeTracesfunctionno test imports it
function writeTraces(store: PlanningStoreBackend, traces: readonly Trace[]): Promise<Result<number, StoreProblem>>

Writes traces, each replacing the one before it.

physical.outboxPathconstno test imports it
const outboxPath: (e: OutboxEntry) => string

The path of an outbox entry.

physical.writeOutboxfunctionno test imports it
function writeOutbox(store: PlanningStoreBackend, entries: readonly OutboxEntry[]): Promise<Result<number, StoreProblem>>

Writes outbox entries.

physical.mergeIntofunctionno test imports it
function mergeInto(into: PlanningStoreBackend, from: PlanningStoreBackend): Promise<Result<number, StoreProblem>>

The union of two stores' event files: every event file of from that into lacks is written to it. Returns how many were copied.

PlanningStoreBackendtypeno test imports it
type PlanningStoreBackend = Store<"read" | "write" | "list" | "cas">;

An AnyFS store of what a planning store needs: read, write, list and the expectation of a revision.

StoreFindingtypeno test imports it
type StoreFinding = { readonly path: string; readonly message: string };

A file of the store that could not be read, and why.

StoreProblemtypeno test imports it
type StoreProblem = { readonly kind: "store"; readonly message: string };

Why the store could not be read or written.

Loadedtypeno test imports it
type Loaded = {
  readonly events: readonly ItemEvent[];
  readonly items: readonly Item[];
  readonly traces: readonly Trace[];
  readonly outbox: readonly OutboxEntry[];
  readonly findings: readonly StoreFinding[];
  /** The clock after every id the store holds: the next id made from it comes after them all. */
  readonly clock: Clock;
};

What a store holds.

loadStorefunctionno test imports it
function loadStore(store: PlanningStoreBackend, options: { readonly clock: Clock; readonly wallMs: number; readonly policy?: Policy | undefined; }): Promise<Result<Loaded, StoreProblem>>

What a store holds: the events (each file read once), the items folded under the policy, the traces and the outbox.

writeEventsfunctionno test imports it
function writeEvents(store: PlanningStoreBackend, events: readonly ItemEvent[]): Promise<Result<number, StoreProblem>>

Writes events: each file expects to be absent, an event already there with the same text is not an error and one with other text is. Returns how many were new.

tracePathfunctionno test imports it
function tracePath(t: Pick<Trace, "fingerprint" | "source">): Promise<string>

The path of a trace: the source and the hash of the fingerprint.

writeTracesfunctionno test imports it
function writeTraces(store: PlanningStoreBackend, traces: readonly Trace[]): Promise<Result<number, StoreProblem>>

Writes traces, each replacing the one before it.

outboxPathconstno test imports it
const outboxPath: (e: OutboxEntry) => string

The path of an outbox entry.

writeOutboxfunctionno test imports it
function writeOutbox(store: PlanningStoreBackend, entries: readonly OutboxEntry[]): Promise<Result<number, StoreProblem>>

Writes outbox entries.

mergeIntofunctionno test imports it
function mergeInto(into: PlanningStoreBackend, from: PlanningStoreBackend): Promise<Result<number, StoreProblem>>

The union of two stores' event files: every event file of from that into lacks is written to it. Returns how many were copied.

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