/** * Registration-compiled general route program. * * This is deliberately a data-and-control-flow compiler, not source generation: user functions and * schemas remain opaque references and no request value is ever converted into executable code. The * program is frozen at registration so the request path walks one immutable stage sequence instead * of rediscovering which lifecycle features are present. */ import type { StandardSchemaV1 } from "../schema/standard.js"; import type { Registry } from "../server/registry.js"; import { type ResponseResult } from "../server/runtime-core.js"; import type { CtxSet, MaybePromise, RawContext, RequestSource, Server } from "../server/server.js"; import type { InternalHandler, RawAfterHandle, RawBeforeHandle, RawDerive, RawErrorHandler, RouteEntry } from "./route-execution.js"; export type ProgramValidationKind = "headers" | "params" | "body" | "query"; export type RouteProgramStage = { readonly kind: ProgramValidationKind; readonly schema: StandardSchemaV1; } | { readonly kind: "derive"; readonly run: RawDerive; } | { readonly kind: "before"; readonly run: RawBeforeHandle; } | { readonly kind: "handler"; readonly run: InternalHandler; } | { readonly kind: "after"; readonly run: RawAfterHandle; }; /** The complete registration-time lifecycle, in semantic execution order. */ export interface RouteProgram { readonly stages: readonly RouteProgramStage[]; readonly validationStages: readonly Extract[]; readonly derives: readonly RawDerive[]; readonly beforeHandle: readonly RawBeforeHandle[]; readonly afterHandle: readonly RawAfterHandle[]; readonly onError: readonly RawErrorHandler[]; readonly handler: InternalHandler; readonly decorations: Record; readonly hasDecorations: boolean; readonly bodySchema: StandardSchemaV1 | undefined; readonly bodyLimit: RouteEntry["bodyLimit"]; readonly responseContract: RouteEntry["responseContract"]; } export interface RouteProgramInput { readonly schema: RouteEntry["schema"]; readonly handler: InternalHandler; readonly derives: readonly RawDerive[]; readonly beforeHandle: readonly RawBeforeHandle[]; readonly afterHandle: readonly RawAfterHandle[]; readonly onError: readonly RawErrorHandler[]; readonly decorations: Record; readonly hasDecorations: boolean; readonly bodySchema: StandardSchemaV1 | undefined; readonly bodyLimit: RouteEntry["bodyLimit"]; readonly responseContract: RouteEntry["responseContract"]; } /** Build the immutable stage sequence once, while the server is still configurable. */ export declare function compileRouteProgram(input: RouteProgramInput): RouteProgram; type ProgramResult = MaybePromise; /** Execute the general program. The first synchronous stage sequence stays synchronous. */ export declare function executeRouteProgram(runtime: Server, entry: RouteEntry, program: RouteProgram, source: RequestSource, ctx: RawContext, finalize: (result: unknown, set: CtxSet) => T, wrapResponse: (response: Response | ResponseResult) => T): ProgramResult; export {}; //# sourceMappingURL=route-program.d.ts.map