import * as av from "anyvali"; import type { BaseSchema, Infer } from "anyvali"; import type { RouteHandlerContext } from "./route.js"; import type { HtmlRenderable } from "../runtime/view.js"; export declare const StreamErrorFrameSchema: av.ObjectSchema<{ kind: av.EnumSchema; error: av.StringSchema; message: av.StringSchema; issues: av.OptionalSchema; message: av.StringSchema; }>>>; }>; export type StreamErrorFrame = Infer; export declare const StreamEndFrameSchema: av.ObjectSchema<{ kind: av.EnumSchema; count: av.IntSchema; }>; export type StreamEndFrame = Infer; export interface StreamItemFrame { readonly kind: "item"; readonly data: TItem; } export interface StreamSummaryFrame { readonly kind: "summary"; readonly data: TSummary; } export type StreamFrame = StreamItemFrame | StreamSummaryFrame | StreamErrorFrame | StreamEndFrame; /** * Brand key identifying a stream handler in the registry's `handlers` map. * Stream handlers are objects (not callables); the adapter detects the brand * at request time and diverts to the streaming pipeline. */ export declare const BP_STREAM_HANDLER: unique symbol; /** * A streaming route handler. The generator yields validated-shape items and * MAY return a summary value. The adapter (not the generator) drives frame * encoding, per-frame validation, and representation negotiation. */ export interface BpStreamHandler, TQuery = Record, THeaders = Record> { readonly [BP_STREAM_HANDLER]: true; readonly itemSchema: BaseSchema; readonly summarySchema?: BaseSchema; /** * Derived buffered-JSON response schema: `{ items: array(itemSchema), summary? }`. * Used as the route's `schemas.response` and the manifest's `jsonResponseSchema` * so streaming views never hand-author a second response shape. */ readonly responseSchema: BaseSchema; run(ctx: RouteHandlerContext>): AsyncGenerator; } export declare function isStreamHandler(value: unknown): value is BpStreamHandler; /** * Context passed to a streaming view's shell renderer. * `sseConnectPath` is the relative SSE URL (path + original query string) the * shell should wire via `hx-sse:connect` - the client rewriter absolutizes it. */ export interface StreamShellContext { readonly sseConnectPath: string; readonly params: Record; readonly query: Record; } /** * Per-renderer implementations for a streaming view, sourced from * `_renderer./index.stream.tsx` exports. * Each function renders ONE frame; the buffered HTML page render uses the * regular `index.tsx` page renderer over the derived `{ items, summary }` data. */ export interface StreamRendererSet { readonly renderShell: (ctx: StreamShellContext) => HtmlRenderable; readonly renderItem: (item: any) => HtmlRenderable; readonly renderSummary?: (summary: any) => HtmlRenderable; readonly renderError?: (error: StreamErrorFrame) => HtmlRenderable; } //# sourceMappingURL=streaming.d.ts.map