diff --git a/packages/redis/index.ts b/packages/redis/index.ts index 7586846d12..572b45b707 100644 --- a/packages/redis/index.ts +++ b/packages/redis/index.ts @@ -4,12 +4,15 @@ import { RedisScripts, RespVersions, TypeMapping, - createClient as _createClient, + createClient as genericCreateClient, RedisClientOptions, - RedisClientType as _RedisClientType, - createCluster as _createCluster, + RedisClientType as GenericRedisClientType, + createCluster as genericCreateCluster, RedisClusterOptions, - RedisClusterType as _RedisClusterType, + RedisClusterType as genericRedisClusterType, + RedisSentinelOptions, + RedisSentinelType as genericRedisSentinelType, + createSentinel as genericCreateSentinel } from '@redis/client'; import RedisBloomModules from '@redis/bloom'; import RedisGraph from '@redis/graph'; @@ -40,7 +43,7 @@ export type RedisClientType< S extends RedisScripts = {}, RESP extends RespVersions = 2, TYPE_MAPPING extends TypeMapping = {} -> = _RedisClientType; +> = GenericRedisClientType; export function createClient< M extends RedisModules, @@ -50,8 +53,8 @@ export function createClient< TYPE_MAPPING extends TypeMapping >( options?: RedisClientOptions -): _RedisClientType { - return _createClient({ +): GenericRedisClientType { + return genericCreateClient({ ...options, modules: { ...modules, @@ -66,7 +69,7 @@ export type RedisClusterType< S extends RedisScripts = {}, RESP extends RespVersions = 2, TYPE_MAPPING extends TypeMapping = {} -> = _RedisClusterType; +> = genericRedisClusterType; export function createCluster< M extends RedisModules, @@ -77,7 +80,33 @@ export function createCluster< >( options: RedisClusterOptions ): RedisClusterType { - return _createCluster({ + return genericCreateCluster({ + ...options, + modules: { + ...modules, + ...(options?.modules as M) + } + }); +} + +export type RedisSentinelType< + M extends RedisModules = RedisDefaultModules, + F extends RedisFunctions = {}, + S extends RedisScripts = {}, + RESP extends RespVersions = 2, + TYPE_MAPPING extends TypeMapping = {} +> = genericRedisSentinelType; + +export function createSentinel< + M extends RedisModules, + F extends RedisFunctions, + S extends RedisScripts, + RESP extends RespVersions, + TYPE_MAPPING extends TypeMapping +>( + options: RedisSentinelOptions +): RedisSentinelType { + return genericCreateSentinel({ ...options, modules: { ...modules,