|
| 1 | +import { StreamConnectionConfig } from "../stream/interface.ts"; |
1 | 2 | /** |
2 | | - * Configuration object for SSE |
| 3 | + * SSE-specific configuration |
3 | 4 | */ |
4 | | -export interface SseConfig { |
| 5 | +export interface SseConfig extends StreamConnectionConfig { |
5 | 6 | /** Include cookies/credentials when connecting */ |
6 | 7 | withCredentials?: boolean; |
7 | | - /** Custom headers (Note: EventSource doesn't natively support headers; handled at app level if needed) */ |
8 | | - headers?: Record<string, string>; |
9 | | - /** Called when the connection is successfully opened */ |
10 | | - onOpen?: (event: Event) => void; |
11 | | - /** Called when a message event is received */ |
12 | | - onMessage?: (data: any, event: MessageEvent) => void; |
13 | | - /** Called on connection error */ |
14 | | - onError?: (err: Event) => void; |
15 | | - /** Transform raw SSE message data (default: JSON.parse if possible) */ |
16 | | - transformMessage?: (data: string) => any; |
17 | 8 | /** Optional query parameters appended to the URL */ |
18 | 9 | params?: Record<string, any>; |
19 | | - /** Called when the connection is being re-established */ |
20 | | - onReconnect?: (attempt: number) => void; |
21 | | - /** Delay in milliseconds before attempting to reconnect (default: 1000ms) */ |
22 | | - retryDelay?: number; |
23 | | - /** Maximum number of reconnect attempts (default: Infinity) */ |
24 | | - maxRetries?: number; |
25 | | - /** Heartbeat timeout in milliseconds; reconnect if no message within this time */ |
26 | | - heartbeatTimeout?: number; |
| 10 | + /** Custom headers (EventSource doesn't natively support headers) */ |
| 11 | + headers?: Record<string, string>; |
27 | 12 | } |
28 | 13 | /** |
29 | 14 | * Managed SSE connection object returned by $sse. |
|
0 commit comments