import { ILogger } from './types'; import { EventEmitter } from './event-emitter'; /** * SSE event types supported by FlagStreamClient */ export interface SSEvent { type: string; data: unknown; id?: string; } /** * Options for creating an SSE client */ export interface SSEClientOptions { url: string; apiKey?: string; headers?: Record; lastEventId?: string; logger: ILogger; events: EventEmitter; onConnected?: () => void; onError?: (error: Error) => void; onMessage?: (data: unknown) => void; /** Called when an SSE event with an id field is received, passing the id value */ onEventId?: (id: string) => void; } /** * Result of starting an SSE connection */ export interface SSEResult { abort: () => void; } /** * SSE Client that uses fetch with ReadableStream for authentication. * This avoids sending credentials in the URL. */ export declare class SSEClient { private readonly options; private abortController; private disposed; constructor(options: SSEClientOptions); /** * Start the SSE connection using fetch */ connect(): SSEResult | null; private startFetch; private processStream; private handleSSEvent; /** * Extract slugs from SSE message data. * Supports formats: * - { slug: 'checkout-v2', action: 'updated' } → ['checkout-v2'] * - { slugs: ['a', 'b'], action: 'batch' } → ['a', 'b'] * - Legacy messages without slug info → undefined (triggers full cache clear) */ private extractSlugsFromMessage; /** * Abort the current connection */ abort(): void; /** * Mark as disposed — prevents reconnection */ dispose(): void; }