import type { RouteHandlerContext } from "../contracts/route.js"; import type { BpStreamHandler, StreamErrorFrame } from "../contracts/streaming.js"; /** * Stream driving helpers (spec/streaming.md). * * The producer-side validation gate lives here: every yielded item is parsed * against the handler's itemSchema (and the generator return value against * summarySchema) BEFORE leaving the process, in every representation. */ type AnyStreamHandler = BpStreamHandler; type AnyCtx = RouteHandlerContext; export interface BufferedStreamResult { items: unknown[]; summary?: unknown; } /** Events surfaced to a frame consumer while driving the generator. */ export interface StreamDriverSink { onItem(item: unknown): Promise | void; onSummary(summary: unknown): Promise | void; /** Terminal - exactly one of onError / onEnd fires, then nothing. */ onError(frame: StreamErrorFrame): Promise | void; onEnd(count: number): Promise | void; } /** * Drive the generator, validating each frame payload, and report frames to * the sink in legal order: items -> summary? -> exactly one terminal. */ export declare function driveStream(handler: AnyStreamHandler, ctx: AnyCtx, sink: StreamDriverSink): Promise; /** * Run the stream to completion and assemble the derived buffered shape * `{ items, summary? }` (spec/streaming.md section 2.1). Throws on any failure so * buffered representations surface real HTTP status codes. */ export declare function driveStreamBuffered(handler: AnyStreamHandler, ctx: AnyCtx): Promise; /** * NDJSON representation (spec/streaming.md section 2.2): one frame per line, * flushed per frame, in-band terminal frame. */ export declare function ndjsonStreamResponse(handler: AnyStreamHandler, ctx: AnyCtx): Response; export {}; //# sourceMappingURL=stream.d.ts.map