import { StreamingConfig, ILogger } from './types'; import { EventEmitter } from './event-emitter'; /** * Server-Sent Events (SSE) client for real-time feature flag updates. * Uses fetch-based SSE when apiKey is present (secure), falls back to * native EventSource when no apiKey (performance). */ export declare class FlagStreamClient { private readonly baseUrl; private eventSource; private sseClient; private readonly config; private readonly logger; private readonly events; private reconnectAttempts; private reconnectTimer; private disposed; private lastEventId; /** Tracks the last document version received to detect gaps */ private lastReceivedVersion; private apiKey; constructor(baseUrl: string, apiKey: string | undefined, config: StreamingConfig, logger: ILogger, events: EventEmitter); /** * Connect to the SSE endpoint. * Uses SSEClient (fetch-based) when apiKey is present for secure auth. * Falls back to native EventSource when no apiKey for better performance. */ connect(): void; /** * Connect using fetch-based SSE client (secure, supports custom headers). * Used when apiKey is present to avoid sending credentials in URL. */ private connectWithFetch; /** * Connect using native EventSource. * Used when no apiKey is present for better performance. */ private connectWithEventSource; private handleUpdateEvent; /** * Check if the document version has a gap indicating lost events. * Returns true if a gap was detected (events were lost), false otherwise. */ private checkVersionGap; /** * 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 → undefined (triggers full cache clear) */ private extractSlugsFromMessage; private scheduleReconnect; /** * Disconnect the stream. Automatically reconnects won't trigger unless connect() is called again. */ disconnect(): void; /** * Checks if the stream is currently connected. */ isConnected(): boolean; /** * Permanently dispose of the stream client. */ dispose(): void; }