/** * Build the TypeORM `cache:` config object from an explicit Redis config. * * Consumers own the env-var reading (so the wiring is visible in their config * tree) and pass us a plain object. We translate it into the TypeORM-native * shape, handling the standalone-vs-cluster fork plus the ElastiCache * cluster-mode safety defaults (enableOfflineQueue:false, checkServerIdentity * bypass for TLS — see project_elasticache_cluster_ioredis_tls). */ export type CacheMode = 'standalone' | 'cluster'; /** * `host` is `string | undefined` so consumers can populate this directly from * env vars without a guarding ternary — when REDIS_HOST is unset in dev/test, * `buildCache()` returns undefined and no cache is installed. */ export interface RedisConfig { host: string | undefined; port: number; tls: boolean; mode: CacheMode; } /** * Matches the shape of TypeORM's `DataSourceOptions.cache`. Fields are typed * loose (`any` / `unknown`) deliberately — TypeORM's own type is loose, and * tightening here would force `as any` casts at every consumer's callsite when * the result is spread into a `DeepPartial` config tree. */ export interface BuiltCacheConfig { type?: 'ioredis'; options?: any; client?: unknown; ignoreErrors?: boolean; } /** * Returns undefined when `config` is missing or has no host. Consumers can write: * * redis: { * host: process.env.REDIS_HOST, // string | undefined * port: Number(process.env.REDIS_PORT ?? '6379'), * tls: process.env.REDIS_TLS === 'true', * mode: (process.env.REDIS_MODE ?? 'standalone') as Cache.CacheMode, * } * cache: Cache.buildCache(config.redis) * * No ternary, no cast. In dev/test where REDIS_HOST is unset the cache is * simply not installed. */ export declare function buildCache(config: RedisConfig | undefined): BuiltCacheConfig | undefined;