import type { FileSystemAdapter } from "../../../platform/adapters/base.js"; import type { HandlerContext, HandlerResult } from "../types.js"; interface SourceSnapshotFreshnessReasons { readonly ensure: string; readonly refreshFallback: string; /** * Oldest freshness check this caller accepts, in milliseconds. Omit to take * the adapter's default lease, which is what sub-resource requests inside one * page load want. A document render passes 0, because the snapshot it serves * is the one hydration compares against. */ readonly maxAgeMs?: number; } export type PreviewDocumentSnapshotReclassifier = () => Promise; export interface PreviewSourceSnapshotMarker { readonly identity?: string; readonly version?: number; } /** Capture a stable, reusable identity for the adapter snapshot. */ export declare function capturePreviewSourceSnapshotMarker(fs: FileSystemAdapter): Promise; export declare function captureRequiredPreviewSourceSnapshotMarker(fs: FileSystemAdapter, projectSlug: string): Promise; export declare function previewSourceSnapshotMarkersEqual(left: PreviewSourceSnapshotMarker, right: PreviewSourceSnapshotMarker): boolean; /** Bind already-derived request configuration to its strict source snapshot. */ export declare function seedPreviewDocumentSourceSnapshot(ctx: HandlerContext, marker: PreviewSourceSnapshotMarker): void; interface RetainedPreviewDocumentSourceSnapshotOptions { /** Keep the validated marker available for a later request phase. */ readonly retainAfterOperation?: (result: T) => boolean; /** Re-enter request context before deferred response-body work. */ readonly runDeferredOperation?: (operation: () => Promise) => Promise; } /** * Keep a config-bound marker alive across an upstream operation and validate * both sides of it. A downstream document handler may release its WeakMap * entry before returning through project middleware, so the retained value is * the authority for the final check. */ export declare function runWithRetainedPreviewDocumentSourceSnapshot(ctx: HandlerContext, operation: () => Promise, options?: RetainedPreviewDocumentSourceSnapshotOptions): Promise; /** Establish strict freshness before API/page ownership is classified. */ export declare function preparePreviewDocumentSourceSnapshot(ctx: HandlerContext, reclassify?: PreviewDocumentSnapshotReclassifier): Promise; /** * Return the prepared classifier only when its page/API decision has become * stale. This probe never refreshes an unprepared direct SSR request, which * lets memory-pressure shedding stay cheap without hiding a newly API-owned * route behind an SSR 503. */ export declare function reclassifyPreviewDocumentSourceSnapshotIfChanged(ctx: HandlerContext): Promise; /** Validate and release the marker retained across one document render. */ export declare function finishPreviewDocumentSourceSnapshot(ctx: HandlerContext): Promise; /** * Reuse a strict snapshot prepared by the API/page classifier, or return the * continuation that can classify the current generation again. */ export declare function ensurePreviewDocumentSourceSnapshot(ctx: HandlerContext): Promise; /** * Establish the current mutable source snapshot before request routing or * rendering reads project files. * * Throws when the source can go stale and the adapter offers no way to bring * it up to date. Treating that as success is what lets an older snapshot reach * hydration, so the request fails instead. */ export declare function ensurePreviewSourceSnapshotFresh(ctx: HandlerContext, reasons?: SourceSnapshotFreshnessReasons): Promise; /** Establish zero-age freshness before loading preview document configuration. */ export declare function ensurePreviewDocumentConfigSourceSnapshotFresh(fs: FileSystemAdapter, projectSlug: string): Promise; export declare function refreshPreviewSourceSnapshot(ctx: HandlerContext, reason?: string): Promise; export {}; //# sourceMappingURL=source-snapshot-freshness.d.ts.map