import { Destination as Destination$1 } from '@walkeros/core'; import { DestinationServer } from '@walkeros/server-core'; /** * Arguments passed to Redis XADD. Strings or numbers (for MAXLEN counts). */ type XaddArg = string | number; /** * Mock-friendly Redis pipeline interface. Accumulates commands and * executes them with a single round-trip via exec(). */ interface RedisPipelineMock { xadd: (...args: XaddArg[]) => RedisPipelineMock; exec: () => Promise | null>; } /** * Mock-friendly Redis client interface used by the destination. * Tests provide this via env.Redis; production creates a real ioredis * client and uses it directly. */ interface RedisClientMock { xadd: (...args: XaddArg[]) => Promise; pipeline: () => RedisPipelineMock; quit: () => Promise; on?: (event: string, listener: (...args: unknown[]) => void) => unknown; } /** * Constructor signature for the Redis client. Accepts either a URL * string or an options object, matching ioredis's dual signature. */ interface RedisClientConstructor { new (url: string): RedisClientMock; new (options: RedisClientOptions): RedisClientMock; } /** * Minimal ioredis options subset the destination passes through. * Unknown options are preserved for the SDK to handle. */ interface RedisClientOptions { host?: string; port?: number; username?: string; password?: string; db?: number; tls?: boolean | Record; connectTimeout?: number; commandTimeout?: number; [key: string]: unknown; } type SerializationMode = 'json' | 'flat'; interface RedisSettings { /** Redis stream key name (e.g. 'walkeros:events'). */ streamKey: string; /** Redis connection URL (e.g. 'redis://localhost:6379' or 'rediss://...'). */ url?: string; /** ioredis connection options (used if no url provided). */ options?: RedisClientOptions; /** * Maximum stream length. Enables MAXLEN trimming on every XADD. * Uses approximate (~) trimming by default for performance. * Omit for unlimited stream length. */ maxLen?: number; /** * Use exact MAXLEN instead of approximate (~). * Not recommended for production -- significantly slower. * Default: false (approximate trimming). */ exactTrimming?: boolean; /** * Serialization mode for the event payload. * - 'json': Single 'event' field with JSON string (default) * - 'flat': Top-level event fields as separate stream fields */ serialization?: SerializationMode; _client?: RedisClientMock; _ownedClient?: boolean; } interface Settings { redis: RedisSettings; } type InitSettings = Partial; interface Mapping { /** Override stream key for this rule. */ streamKey?: string; } /** * Env -- optional Redis SDK override. Production leaves this undefined * and the destination creates real ioredis client instances. Tests provide * mocks via env.Redis. */ interface Env extends DestinationServer.Env { Redis?: { Client: RedisClientConstructor; }; } type Types = Destination$1.Types; interface Destination extends DestinationServer.Destination { init: DestinationServer.InitFn; } type Config = { settings: Settings; } & DestinationServer.Config; type InitFn = DestinationServer.InitFn; type PushFn = DestinationServer.PushFn; type PartialConfig = DestinationServer.PartialConfig; type PushEvents = DestinationServer.PushEvents; type index_Config = Config; type index_Destination = Destination; type index_Env = Env; type index_InitFn = InitFn; type index_InitSettings = InitSettings; type index_Mapping = Mapping; type index_PartialConfig = PartialConfig; type index_PushEvents = PushEvents; type index_PushFn = PushFn; type index_RedisClientConstructor = RedisClientConstructor; type index_RedisClientMock = RedisClientMock; type index_RedisClientOptions = RedisClientOptions; type index_RedisPipelineMock = RedisPipelineMock; type index_RedisSettings = RedisSettings; type index_SerializationMode = SerializationMode; type index_Settings = Settings; type index_Types = Types; type index_XaddArg = XaddArg; declare namespace index { export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_InitFn as InitFn, index_InitSettings as InitSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_RedisClientConstructor as RedisClientConstructor, index_RedisClientMock as RedisClientMock, index_RedisClientOptions as RedisClientOptions, index_RedisPipelineMock as RedisPipelineMock, index_RedisSettings as RedisSettings, index_SerializationMode as SerializationMode, index_Settings as Settings, index_Types as Types, index_XaddArg as XaddArg }; } declare const destinationRedis: Destination; export { index as DestinationRedis, destinationRedis as default, destinationRedis };