/** * Pure, testable pipeline steps extracted from the request handler. * * Each function here is a focused stage of the Gracile request lifecycle. * They are composed by `createGracileHandler` in `./request.ts`. * * @internal */ import { Readable } from 'node:stream'; import type { Logger, ViteDevServer } from 'vite'; import { renderRouteTemplate } from '../render/route-template.js'; import type { RouteInfos } from '../routes/match.js'; import type { GracileConfig } from '../user-config.js'; export type StandardResponse = { response: Response; body?: never; init?: never; }; export type ResponseWithNodeReadable = { response?: never; body: Readable; init: ResponseInit; }; export type HandlerResult = StandardResponse | ResponseWithNodeReadable | null; export declare const CONTENT_TYPE_HTML: { readonly 'Content-Type': "text/html"; }; export declare const PREMISE_REGEXES: { readonly properties: RegExp; readonly document: RegExp; }; /** Describes which premises endpoint was requested, if any. */ export interface PremisesDescriptor { propertiesOnly: boolean; documentOnly: boolean; } /** * Strip the `/__…` suffix so hidden-sibling URLs (premises) resolve to * the parent route. * * @example * rewriteHiddenRoutes('http://localhost/blog/__index.props.json') * // → 'http://localhost/blog/' */ export declare function rewriteHiddenRoutes(url: string): string; /** * Determine if the incoming request targets a premises endpoint * (`__index.props.json` or `__index.doc.html`) and whether the config * allows it. * * @returns A descriptor when premises are enabled, or `null` when not. * @throws When a premise URL is hit but premises are not enabled. */ export declare function resolvePremises(requestedUrl: string, gracileConfig: GracileConfig): PremisesDescriptor | null; export interface ExecuteHandlerOptions { routeInfos: RouteInfos; method: string; request: Request; fullUrl: string; locals: unknown; responseInit: ResponseInit; premises: PremisesDescriptor | null; routeTemplateOptions: Parameters[0]; } /** * Result from `executeHandler`: * * - `{ type: 'response', value }` — return this response directly * - `{ type: 'output', value }` — pass to response building * - `{ type: 'fallthrough' }` — no handler, proceed to template-only render */ export type ExecuteHandlerResult = { type: 'response'; value: StandardResponse; } | { type: 'output'; value: Readable | Response | null; } | { type: 'fallthrough'; }; /** * Dispatch the user's route handler (top-level function or method-map). * * This determines whether to call the handler, which method to use, * and whether to short-circuit with premises or a 405. */ export declare function executeHandler(options: ExecuteHandlerOptions): Promise; /** * Render a page that has no handler — just a document/template. * Handles premises short-circuits. */ export declare function renderWithoutHandler(options: { premises: PremisesDescriptor | null; routeTemplateOptions: Parameters[0]; }): Promise; export declare function isRedirect(response: Response): { location: string; } | null; /** * Convert a handler/render output (Response or Readable stream) into * the final `HandlerResult` shape expected by adapters. */ export declare function buildResponse(options: { output: Readable | Response | null; responseInit: ResponseInit; vite: ViteDevServer | undefined; logger: Logger; }): HandlerResult; //# sourceMappingURL=request-pipeline.d.ts.map