/** * Platform-agnostic HTTP request handler for the workflow REST API. * Maps Request to Response with no Bun-specific dependencies. * * Dispatch model: REST-only meta and discovery endpoints are reserved direct * routes, using the table shared with the OpenAPI generator. Every other * operation-backed REST route is resolved through `RestBinding` entries and * the `dispatchViaExecuteOperation` pipeline. * * @module server/handler */ import type { RegistryAgnosticEngine } from '../../core/engine.ts'; import { type HandlerOptions } from './route-dispatch.ts'; export { authContextToPrincipal } from './auth-context-principal.ts'; export { isOperationFaultLike, type HandlerOptions } from './route-dispatch.ts'; export { extractRouteParameters, getRequiredRouteParameter } from './route-matching.ts'; export { createEngineEventFeedBackend } from '../engine-event-feed-backend.ts'; export { createFleetEventFeed, type FleetEventAppendOptions, type FleetEventEnvelope, type FleetEventFeed, type FleetEventFeedOptions, type FleetEventGapEnvelope, type FleetEventInput, type FleetWorkflowEventInput, } from '../fleet-event-feed.ts'; export { createWorkflowEventFeed, type Cursor, type EventEnvelope, type WorkflowEventFeed, type WorkflowEventFeedBackend, } from '../workflow-event-feed.ts'; /** * Pure HTTP request handler. Maps Request to Response. * * `engine` is typed as {@link RegistryAgnosticEngine} (see its JSDoc) rather * than the plain default `Engine`, so both `new Engine({ storage })` and * `Engine.create({ workflows })` type-check here directly. This module's * dispatch chain only calls registry-erased `Engine` methods, so the value is * registry-erased back to the plain `Engine` once, internally. * * @example * ```ts * import { workflow, Engine, MemoryStorage, handleRequest } from '@lostgradient/weft'; * * await using engine = new Engine({ storage: new MemoryStorage() }); * engine.register(workflow({ name: 'ping' }).execute(async function* () { return 'pong'; })); * * const request = new Request('http://localhost/v1/health'); * const response = await handleRequest(request, engine); * console.log(response.status); // 200 * ``` */ export declare function handleRequest(request: Request, engine: RegistryAgnosticEngine, options?: HandlerOptions): Promise;