import { EventLog } from './events.js'; import { type DocRecord, type DocState } from './state.js'; import { type Attempts, type Bound, type StoreCtx } from './store-common.js'; import { type DecideReceipt, type DecideRequest, type DocSummary, type ListFilter, type ProblemView, type PublishReceipt, type PublishRequest, type ReadRequest, type ReadResult, type Refusal, type StoreErrorCode, type StoreEvent, type StoreGuard, type StoreListener, type TypeBinding } from './store-types.js'; import type { DocContract } from './types.js'; export interface StoreOptions { /** `/docs/`. */ dir: string; /** The run id (a snapshot written for another run is ignored). */ run: string; bindings: TypeBinding[]; now?: () => Date; /** Write a snapshot after every this many events; 0 disables the automatic one. Default 100. */ snapshotEvery?: number; guards?: StoreGuard[]; } export interface StoreInfo { run: string; seq: number; head_hash: string; /** Bytes of a torn final line cut off when the log was opened. */ torn_bytes_repaired: number; snapshot: { used: boolean; reason?: string; }; corrupt?: { code: StoreErrorCode; message: string; }; /** Versions whose committed event has no usable body file: reading or deciding them is refused. */ bad_bodies: { ref: string; code: StoreErrorCode; }[]; } export declare class DocumentStore implements StoreCtx { private readonly opts; /** @internal (StoreCtx) */ readonly bound: Map; /** @internal (StoreCtx) */ state: DocState; /** @internal (StoreCtx) */ readonly guards: StoreGuard[]; /** @internal (StoreCtx) */ readonly badBodies: Map; private readonly log; private corrupt?; private readonly listeners; private readonly now; private readonly snapEvery; private busy; private readonly tornRepaired; private snapInfo; constructor(opts: StoreOptions); /** @internal (StoreCtx) */ get run(): string; /** @internal (StoreCtx) */ bodyPath(d: Pick, version: number): string; info(): StoreInfo; /** The resolved contracts with the revision each is pinned to, and who produces and decides each type. */ contracts(): { type: string; revision: string; section: string; contract: DocContract; producers: string[]; consumers: TypeBinding['consumers']; }[]; /** Attempts used and left for a type under its current revision (publish, then consistency refusals). */ attempts(type: string): Attempts | undefined; private summary; list(filter?: ListFilter): DocSummary[]; /** A version with its body, read from disk and checked against the hash its event recorded; records nothing. */ peek(id: string, version?: number): ReadResult | Refusal; /** Add a check that runs after the store's own, before a commit (plan P3.10). */ addGuard(g: StoreGuard): void; /** Be told after each committed event, in order (plans P3.8 to P3.11). Returns the unsubscribe function. */ onCommitted(l: StoreListener): () => void; private guarded; /** @internal (StoreCtx) */ commit(body: Parameters[0]): StoreEvent; /** Write the derived state at the current event; the log stays the authority. */ snapshot(): void; /** @internal (StoreCtx): record a refusal that counts against a cap, and say how much of the cap is left. */ counted(op: 'publish' | 'decide', role: string, x: Bound, code: StoreErrorCode, message: string, counts: 'attempt' | 'consistency', problems?: ProblemView[], at?: { doc?: string; version?: number; }, guard_code?: string): Refusal; publish(req: PublishRequest): PublishReceipt | Refusal; /** `override`: the consuming section the root decides for on a thread whose rework cap is spent (P4.7). */ decide(req: DecideRequest, override?: string): DecideReceipt | Refusal; /** Read a version and record the read (`read` event: who, which version, why). */ read(req: ReadRequest): ReadResult | Refusal; } //# sourceMappingURL=store.d.ts.map