physical.PlanningStoreBackendtypeno test imports ittype PlanningStoreBackend = Store<"read" | "write" | "list" | "cas">;An AnyFS store of what a planning store needs: read, write, list and the expectation of a revision.
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 });physical.PlanningStoreBackendtypeno test imports ittype 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 ittype StoreFinding = { readonly path: string; readonly message: string };A file of the store that could not be read, and why.
physical.StoreProblemtypeno test imports ittype StoreProblem = { readonly kind: "store"; readonly message: string };Why the store could not be read or written.
physical.Loadedtypeno test imports ittype 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 itfunction 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 itfunction 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 itfunction 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 itfunction writeTraces(store: PlanningStoreBackend, traces: readonly Trace[]): Promise<Result<number, StoreProblem>>Writes traces, each replacing the one before it.
physical.outboxPathconstno test imports itconst outboxPath: (e: OutboxEntry) => stringThe path of an outbox entry.
physical.writeOutboxfunctionno test imports itfunction writeOutbox(store: PlanningStoreBackend, entries: readonly OutboxEntry[]): Promise<Result<number, StoreProblem>>Writes outbox entries.
physical.mergeIntofunctionno test imports itfunction 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 ittype 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 ittype StoreFinding = { readonly path: string; readonly message: string };A file of the store that could not be read, and why.
StoreProblemtypeno test imports ittype StoreProblem = { readonly kind: "store"; readonly message: string };Why the store could not be read or written.
Loadedtypeno test imports ittype 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 itfunction 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 itfunction 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 itfunction tracePath(t: Pick<Trace, "fingerprint" | "source">): Promise<string>The path of a trace: the source and the hash of the fingerprint.
writeTracesfunctionno test imports itfunction writeTraces(store: PlanningStoreBackend, traces: readonly Trace[]): Promise<Result<number, StoreProblem>>Writes traces, each replacing the one before it.
outboxPathconstno test imports itconst outboxPath: (e: OutboxEntry) => stringThe path of an outbox entry.
writeOutboxfunctionno test imports itfunction writeOutbox(store: PlanningStoreBackend, entries: readonly OutboxEntry[]): Promise<Result<number, StoreProblem>>Writes outbox entries.
mergeIntofunctionno test imports itfunction 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.