/** * Custom SSEServerTransport that supports session recreation. * * When recreating a session from Redis (e.g., in serverless environments * or after client reconnection), we need to restore the transport's state * including the event ID counter for proper SSE reconnection support. * * This class extends our custom SSEServerTransport to expose a public API * for session recreation, maintaining the event ID sequence across reconnections. */ import type { ServerResponse } from 'http'; import { SSEServerTransport, type SSEServerTransportOptions } from './base-sse-transport'; export interface RecreateableSSEServerTransportOptions extends SSEServerTransportOptions { /** * Initial event ID counter value for session recreation. * Use this when recreating a session to restore the event ID sequence. */ initialEventId?: number; } /** * SSEServerTransport with session recreation support. * * This is a drop-in replacement for SSEServerTransport that adds the ability * to recreate a session with preserved state. This is essential for: * - Serverless environments where the transport may be evicted from memory * - Client reconnection scenarios where event ID continuity is required * - Distributed systems where sessions are stored in Redis * * It extends SSEServerTransport to maintain full compatibility while * adding public methods to set initialization state and restore event IDs. */ export declare class RecreateableSSEServerTransport extends SSEServerTransport { private _isRecreatedSession; constructor(endpoint: string, res: ServerResponse, options?: RecreateableSSEServerTransportOptions); /** * Validates that an event ID is a valid non-negative integer. * Protects against negative values, NaN, Infinity, and non-integer values. */ private isValidEventId; /** * Returns whether this is a recreated session. */ get isRecreatedSession(): boolean; /** * Returns the current event ID counter value. * Alias for lastEventId for consistency with the recreation API. */ get eventIdCounter(): number; /** * Sets the event ID counter for session recreation. * Use this when recreating a session from stored state to maintain * event ID continuity for SSE reconnection support. * * @param eventId - The event ID to restore (must be a non-negative integer) */ setEventIdCounter(eventId: number): void; /** * Sets the transport to a recreated session state. * Use this when recreating a transport from a stored session. * * @param sessionId - The session ID (for verification, should match constructor) * @param lastEventId - The last event ID that was sent to the client */ setSessionState(sessionId: string, lastEventId?: number): void; } //# sourceMappingURL=sse-transport.d.ts.map