/** * EventStore Factory * * Factory functions for creating EventStore instances based on configuration. * Supports Memory and Redis backends with automatic provider detection. * * @module transport/event-stores/event-store.factory */ import type { EventStore } from '@frontmcp/protocol'; import type { FrontMcpLogger, RedisOptionsInput, SqliteOptionsInput } from '../../common'; /** * EventStore configuration for SSE resumability support. */ export interface EventStoreConfig { /** * Whether EventStore is enabled. * When true, clients can reconnect and resume missed SSE messages using Last-Event-ID header. * @default false */ enabled: boolean; /** * Storage provider type. * - 'memory': In-memory storage (single-node only) * - 'redis': Redis-backed storage (distributed) * - 'sqlite': SQLite-backed storage (local persistence) * @default 'memory' */ provider?: 'memory' | 'redis' | 'sqlite'; /** * Maximum number of events to store before eviction. * @default 10000 */ maxEvents?: number; /** * TTL in milliseconds for stored events. * @default 300000 (5 minutes) */ ttlMs?: number; /** * Redis configuration (required if provider is 'redis'). */ redis?: RedisOptionsInput; /** * SQLite configuration (required if provider is 'sqlite'). */ sqlite?: SqliteOptionsInput; } /** * Result of creating an EventStore. */ export interface EventStoreResult { /** * The created EventStore instance, or undefined if disabled. */ eventStore: EventStore | undefined; /** * The type of storage backend used. */ type: 'memory' | 'redis' | 'sqlite' | 'disabled'; } /** * Create an EventStore based on configuration. * * If EventStore is disabled (config.enabled is false or undefined), * returns undefined. This disables SSE resumability support. * * @param config - EventStore configuration * @param logger - Optional logger for store operations * @returns EventStore instance and type, or undefined if disabled * * @example Disabled (default) * ```typescript * const { eventStore, type } = createEventStore(undefined); * // eventStore === undefined, type === 'disabled' * ``` * * @example Memory (single-node) * ```typescript * const { eventStore, type } = createEventStore({ * enabled: true, * provider: 'memory', * maxEvents: 10000, * ttlMs: 300000, * }); * // type === 'memory' * ``` * * @example Redis (distributed) * ```typescript * const { eventStore, type } = createEventStore({ * enabled: true, * provider: 'redis', * redis: { host: 'localhost', port: 6379 }, * maxEvents: 10000, * ttlMs: 300000, * }); * // type === 'redis' * ``` */ export declare function createEventStore(config: EventStoreConfig | undefined, logger?: FrontMcpLogger): EventStoreResult; //# sourceMappingURL=event-store.factory.d.ts.map