import type { StreamHandle } from '@purista/core'; import { StatusCode } from '@purista/core'; import type { ContentfulStatusCode } from 'hono/utils/http-status'; /** * Protocol-native SSE event passed through by stream handlers. */ export type ProtocolSseEvent = { /** SSE event name. */ event: string; /** JSON-serializable event data, or `[DONE]` for data-only completion frames. */ data: unknown; }; /** * Normalized payload shape used by HTTP stream transport frames. */ export type StreamTransportFramePayload = { /** Frame kind such as `chunk`, `complete`, `error` or transport control frames. */ frameType?: string; /** Monotonic stream frame sequence when provided by the stream source. */ sequence?: number; /** Incremental stream payload. */ chunk?: unknown; /** Final aggregate payload emitted by a completed stream. */ final?: unknown; /** Error payload forwarded as problem details or SSE error data. */ error?: { status?: number; message?: string; isHandledError?: boolean; /** * Runs the encodeProtocolSseEvent helper exported by @purista/hono-http-server. * Expose only schemas and metadata that are safe for clients to inspect. */ data?: unknown; traceId?: string; }; }; /** * Checks whether a stream chunk is already an SSE protocol event. */ export declare const isProtocolSseEvent: (value: unknown) => value is ProtocolSseEvent; /** * Encodes a protocol SSE event for the HTTP response stream. */ export declare const encodeProtocolSseEvent: (encoder: TextEncoder, event: ProtocolSseEvent) => Uint8Array; /** * Identifies stream lifecycle frames that are consumed by the HTTP transport. */ export declare const isTransportControlFrame: (frameType: unknown) => boolean; /** * Narrows a stream frame payload to an error frame. */ export declare const isStreamErrorPayload: (payload: StreamTransportFramePayload) => payload is StreamTransportFramePayload & { error: { status?: number; message?: string; }; }; /** * Resolves whether HTTP should stream frames or aggregate a stream's final payload. */ export declare const resolveHttpStreamingMode: (input: { explicitMode?: 'stream' | 'aggregate'; isDeclaredStreamDefinition: boolean; responseContentType: string; }) => 'stream' | 'aggregate'; /** * Consumes a PURISTA stream handle until a final or error frame is reached. */ export declare const collectAggregateStreamResult: (handle: StreamHandle) => Promise<{ status: 'error'; statusCode: ContentfulStatusCode | StatusCode; payload: { status?: number; message?: string; isHandledError?: boolean; /** * Runs the encodeProtocolSseEvent helper exported by @purista/hono-http-server. * Expose only schemas and metadata that are safe for clients to inspect. */ data?: unknown; traceId?: string; } & { status?: number; message?: string; }; } | { status: 'success'; statusCode: ContentfulStatusCode; payload: {} | null; }>; //# sourceMappingURL=streamTransport.d.ts.map