import { FlinkContext, FlinkRequest, RouteProps, HttpMethod } from "@flink-app/flink"; /** * Streaming format types */ export type StreamFormat = "sse" | "ndjson"; /** * Stream writer interface for sending data to clients */ export interface StreamWriter { /** * Write data to the stream */ write(data: T): void; /** * Send an error event to the stream */ error(error: Error | string): void; /** * End the stream */ end(): void; /** * Check if the connection is still open */ isOpen(): boolean; } /** * Props passed to streaming handlers */ export interface StreamHandlerProps { req: FlinkRequest; ctx: Ctx; stream: StreamWriter; origin?: string; } /** * Streaming handler function signature */ export type StreamHandler = ( props: StreamHandlerProps ) => Promise | void; /** * Route configuration for streaming endpoints */ export interface StreamingRouteProps extends Omit { /** * HTTP path for the streaming endpoint */ path: string; /** * HTTP method (defaults to GET) */ method?: HttpMethod; /** * Streaming format to use * - 'sse': Server-Sent Events (text/event-stream) * - 'ndjson': Newline-Delimited JSON (application/x-ndjson) * @default 'sse' */ format?: StreamFormat; /** * Must be true for streaming handlers (prevents auto-registration) */ skipAutoRegister: true; } /** * Options for creating the streaming plugin */ export interface StreamingPluginOptions { /** * Default format if not specified in route props * @default 'sse' */ defaultFormat?: StreamFormat; /** * Enable debug logging * @default false */ debug?: boolean; } /** * Handler module type (namespace import with default export and Route) */ export interface StreamHandlerModule { default: StreamHandler; Route: StreamingRouteProps; }