import { Journal } from "./journal.js"; import { Fixture, HandlerDefaults } from "./types.js"; import http from "node:http"; //#region src/fal.d.ts type FalQueueStatus = "IN_QUEUE" | "IN_PROGRESS" | "COMPLETED" | "CANCELLED"; interface FalQueueJob { requestId: string; modelId: string; status: FalQueueStatus; result: unknown; /** * Billed quantity emitted as the `x-fal-billable-units` header on the * completed `queue-result` response. Sourced from the fixture's * `response.billableUnits`; `null` when the fixture omitted it (no header). */ billableUnits: number | null; /** Number of `/status` (or `/{id}`) polls the caller has made against this job. */ pollCount: number; /** Poll-count threshold for `IN_QUEUE → IN_PROGRESS` transition. */ pollsBeforeInProgress: number; /** Poll-count threshold for `IN_PROGRESS → COMPLETED` transition. */ pollsBeforeCompleted: number; submittedAt: number; completedAt: number | null; /** State-transition log entries surfaced in the `/status` response. */ logs: Array<{ timestamp: string; level: string; message: string; }>; createdAt: number; } /** * Per-testId queue state for the general fal handler. Mirrors FalJobMap from * fal-audio.ts but stores arbitrary JSON payloads instead of audio file * objects, so it can serve any fal model (image, video, motion, music, etc.). */ declare class FalQueueStateMap { private readonly entries; get(key: string): FalQueueJob | undefined; set(key: string, job: FalQueueJob): void; delete(key: string): boolean; clear(): void; get size(): number; } type HandleFalOutcome = "handled" | "passthrough"; /** * General fal.ai handler. Routes by `x-fal-target-host` header (the convention * used by `@fal-ai/client`'s server-side requestMiddleware workaround for the * fact that `proxyUrl` is browser-only). * * Returns `"passthrough"` when the request does not look like a host-mirrored * fal call, so the caller can fall back to the legacy `/fal/queue/...` and * `/fal/run/...` audio routes. */ declare function handleFal(req: http.IncomingMessage, res: http.ServerResponse, body: string, pathname: string, fixtures: Fixture[], defaults: HandlerDefaults, journal: Journal): Promise; /** * The result of a queue walk: the parsed final body plus the billed quantity * captured from the result fetch's `x-fal-billable-units` header (`null` when * upstream didn't set it). The caller persists `body` as the fixture and seeds * local queue state; `billableUnits` round-trips real fal billing so a recorded * fixture replays `x-fal-billable-units` without hand-editing. */ //#endregion export { FalQueueStateMap, handleFal }; //# sourceMappingURL=fal.d.ts.map