export type HTTPHeaders = Record; export type WSHeaders = Record; export interface HTTPRequest { method: string; url: string; headers?: WSHeaders; body?: string; sent_at?: string; } export interface HTTPResponse { status: number; headers?: HTTPHeaders; body?: string; } export interface WSHttpRequestPayload { method: string; url: string; headers?: WSHeaders; body?: string; sent_at?: string; } export interface WSHttpResponsePayload { status: number; headers?: WSHeaders; body?: string; } export interface WSStreamChunkPayload { data: string; } export interface WSErrorPayload { error: string; status?: number; } export interface WSHttpRequestMessage { id: string; type: 'http_request'; payload: WSHttpRequestPayload; } export interface WSHttpResponseMessage { id: string; type: 'http_response'; payload: WSHttpResponsePayload; } export interface WSStreamStartMessage { id: string; type: 'stream_start'; payload: WSHttpResponsePayload; } export interface WSStreamChunkMessage { id: string; type: 'stream_chunk'; payload: WSStreamChunkPayload; } export interface WSStreamEndMessage { id: string; type: 'stream_end'; payload?: undefined; } export interface WSErrorMessage { id: string; type: 'error'; payload: WSErrorPayload; } export interface WSPingMessage { id: string; type: 'ping'; payload?: undefined; } export interface WSPongMessage { id: string; type: 'pong'; payload?: undefined; } export type WSMessage = WSHttpRequestMessage | WSHttpResponseMessage | WSStreamStartMessage | WSStreamChunkMessage | WSStreamEndMessage | WSErrorMessage | WSPingMessage | WSPongMessage; export interface ProviderOptions { baseUrl: string; accessKey?: string; managementKey?: string; } export type ProviderEvent = { type: 'error'; requestId?: string; error: string; } | { type: 'ws:open'; } | { type: 'ws:close'; code?: number; reason?: string; } | { type: 'request'; requestId: string; request: HTTPRequest; }; export interface WSRequestContext { requestId: string; respond: (resp: HTTPResponse) => void; streamStart: (status?: number, headers?: HTTPHeaders) => void; streamChunk: (chunk: string) => void; streamEnd: () => void; error: (message: string, status?: number) => void; }