/** * Noydb-side snapshot facade. * * Holds the on-demand checkpoint (`snapshot`), listing (`listSnapshots`), * restore (`restoreSnapshot`), the automatic-snapshot cadence wiring * (`initCadence`), the dirty-vault set, and the cadence scheduler; * `Noydb.close()` calls {@link stop}. Every `Noydb` dependency arrives via * {@link NoydbSnapshotsDeps}. * * Internal service — reached through `noydb.snapshot(...)` etc. */ import { NO_SNAPSHOTS, type SnapshotStrategy, type SnapshotMeta } from './strategy.js'; import type { Vault } from '../../kernel/vault.js'; import type { WriteHook, Unsubscribe } from '../../port/with/write-hooks.js'; /** Everything the moving snapshot methods touched on the Noydb instance's `this.*`. */ export interface NoydbSnapshotsDeps { /** Resolved snapshot strategy (NO_SNAPSHOTS when not configured). */ readonly strategy: SnapshotStrategy; /** Acting user id, used as the snapshot `by`. */ readonly user: string; /** Whether the owning instance has been closed. */ isClosed(): boolean; /** Resolve an open vault from the instance's vault cache. */ getVault(name: string): Vault | undefined; /** Subscribe to post-write events (cadence dirty-marking). */ onAfterWrite(handler: WriteHook): Unsubscribe; } export declare class NoydbSnapshots { private readonly deps; private scheduler; private readonly dirtyVaults; constructor(deps: NoydbSnapshotsDeps); /** * Take an on-demand checkpoint of the given vault. * Requires `snapshotStrategy: withSnapshots({ store })` in `createNoydb`. * @throws ValidationError when the vault is not open */ snapshot(vault: string, opts?: { label?: string; note?: string; }): Promise; /** * Wire the automatic-snapshot cadence when a non-manual `snapshotPolicy` is * configured. Subscribes to `onAfterWrite` to mark the written vault dirty and * nudge the scheduler; the scheduler fires `autoSnapshot()` per dirty vault. * No-op for `mode:'manual'` or no policy. */ private initCadence; /** * List all snapshots for the given vault, newest first. * Reads only the sidecar index — does not download snapshot bytes. */ listSnapshots(vault: string): Promise; /** * Restore the vault to a previously snapshotted state. * Runs `verifyBackupIntegrity()` automatically on restore. * @throws SnapshotNotFoundError when `version` doesn't exist in the store * @throws ValidationError when the vault is not open */ restoreSnapshot(vault: string, version: string): Promise; /** Stop the cadence scheduler (called from `Noydb.close()`). */ stop(): void; } export { NO_SNAPSHOTS };