import { type IdempotencyStore } from "../idempotency.js"; import type { Platform, RouteSchema } from "./context.js"; import type { IdentityPlugin } from "./server.js"; /** Registration-resolved idempotency for a route: the config with its store + defaults pinned. */ export interface ResolvedIdempotency { readonly store: IdempotencyStore; readonly ttlMs: number; readonly headerName: string; readonly namespace: NonNullable["namespace"]; readonly maxResponseBytes: number; } /** * What the dedupe lane needs from the server to run a fresh key: the app-wide body cap and a way to * run the buffered request through the route's normal lanes to a concrete `Response`. */ export interface IdempotencyHost { readonly maxBodyBytes: number; runLanes(buffered: Request, platform: Platform | undefined, entry: unknown, params: Record, search: string | undefined): Promise; } /** The injected idempotency implementation the kernel calls through when the plugin is installed. */ export interface IdempotencyRuntime { readonly trackEffect: (context: object, committed: boolean) => void; /** Resolve a route's declared idempotency into a pinned store + defaults, or `undefined` when off. */ resolve(schema: RouteSchema | undefined, authenticated: boolean, maxBodyBytes: number): ResolvedIdempotency | undefined; /** The dedupe lane: read the key, fingerprint the request, consult the store, run/replay/reject. */ run(config: ResolvedIdempotency, req: Request, platform: Platform | undefined, entry: unknown, params: Record, search: string | undefined, wrapResponse: (response: Response) => T, host: IdempotencyHost): Promise; } /** * Enable request idempotency. Routes that declare `schema.idempotency` get the dedupe lane: a repeat * `Idempotency-Key` replays the stored response instead of re-running the handler. Without this plugin, * declaring `schema.idempotency` is a registration error (the safety gate can never be silently * dropped). `store` is the app-wide default backing routes that do not pin their own; omit it for a * shared in-process store (development/tests only - inject a durable store in production). */ export interface IdempotencyPluginOptions { readonly store?: IdempotencyStore | undefined; } export declare function idempotency(options?: IdempotencyPluginOptions): IdentityPlugin; /** * Build an idempotency runtime. `store` is the app-wide default backing routes that declare * `schema.idempotency` without their own `store`; when omitted, a shared in-process * {@link MemoryIdempotencyStore} is created lazily on first idempotent route. */ export declare function createIdempotencyRuntime(options?: IdempotencyPluginOptions): IdempotencyRuntime; //# sourceMappingURL=idempotency-lane.d.ts.map