UNPKG

histoire

Version:

A fast story book powered by Vite

49 lines • 3.06 kB
import type { HistoireConfig } from '@histoire/shared'; import type { ConfigPatch } from '../../config/codemod/index.js'; import type { Context } from '../../context.js'; /** Private completion retained across the intended runtime restart, never config contents. */ export interface ConfigSaveCompletion { /** Browser-generated capability identifying only this explicit save. */ requestId: string; /** Pending writes/effective reloads do not retire local overrides. */ completion: 'pending' | 'saved' | 'failed'; /** Effective, verified option paths only. */ saved?: string[]; /** Controlled failure with no config execution output. */ error?: string; } /** A bounded server-owned save receipt; patch values are never returned to clients. */ interface ConfigSaveReceipt { /** Context that admitted the write. */ owner: WeakRef<Context>; /** Exact destination under the already guarded root. */ file: string; /** Validated snapshot used to check effective successor config. */ patches: ConfigPatch[]; /** Pending/final write identity, not a socket reference. */ hash?: string; /** Whether bytes changed and therefore require a successor generation. */ restart: boolean; /** Deliberate terminal error; missing means pending or verified. */ error?: string; /** Bound abandoned receipt retention to ten minutes. */ expires: number; /** Hooks already completed for an exact active generation. */ notified: WeakSet<Context>; } /** Registers server-owned override retirement after verified effective save. */ export declare function onVerifiedConfigSave(ctx: Context, callback: (paths: readonly string[], agents?: HistoireConfig['agents']) => Promise<void>): () => void; /** Admits bounded unique requests before queueing, preventing unknown-receipt races. */ export declare function beginConfigSave(ctx: Context, requestId: string, file: string, patches: ConfigPatch[]): ConfigSaveReceipt; /** Records only a successful real-path load; inactive owners may retain proof, not publish. */ export declare function verifyConfigSave(receipt: ConfigSaveReceipt, file: string, hash: string, previousHash?: string): void; /** Failed/retired queued writes retain explicit safe outcome for reconnect. */ export declare function failConfigSave(receipt: ConfigSaveReceipt | undefined, error: string): void; /** Refuses keyed preset operations which would invalidate their selector identity. */ export declare function assertStablePresetIdentities(patches: readonly ConfigPatch[], agents?: HistoireConfig['agents']): void; /** Checks loaded config values before bytes become visible to the project watcher. */ export declare function matchesConfigPatches(config: unknown, patches: readonly ConfigPatch[]): boolean; /** Successor publishes completion only after disk and effective config agree. */ export declare function resolveConfigSave(ctx: Context, requestId: string, isActive: () => boolean): Promise<ConfigSaveCompletion>; export {}; //# sourceMappingURL=config-receipts.d.ts.map