1
1
import COMMANDS from '../commands' ;
2
- import RedisMultiCommand , { MULTI_REPLY , MultiReply , MultiReplyType , RedisMultiQueuedCommand } from '../multi-command' ;
2
+ import RedisMultiCommand , { MULTI_MODE , MULTI_REPLY , MultiMode , MultiReply , MultiReplyType , RedisMultiQueuedCommand } from '../multi-command' ;
3
3
import { ReplyWithTypeMapping , CommandReply , Command , CommandArguments , CommanderConfig , RedisFunctions , RedisModules , RedisScripts , RespVersions , TransformReply , RedisScript , RedisFunction , TypeMapping } from '../RESP/types' ;
4
4
import { attachConfig , functionArgumentsPrefix , getTransformReply } from '../commander' ;
5
5
import { BasicCommandParser } from './parser' ;
@@ -13,7 +13,7 @@ type CommandSignature<
13
13
S extends RedisScripts ,
14
14
RESP extends RespVersions ,
15
15
TYPE_MAPPING extends TypeMapping
16
- > = ( ...args : Tail < Parameters < C [ 'parseCommand' ] > > ) => RedisClientMultiCommandType <
16
+ > = ( ...args : Tail < Parameters < C [ 'parseCommand' ] > > ) => InternalRedisClientMultiCommandType <
17
17
[ ...REPLIES , ReplyWithTypeMapping < CommandReply < C , RESP > , TYPE_MAPPING > ] ,
18
18
M ,
19
19
F ,
@@ -70,7 +70,7 @@ type WithScripts<
70
70
[ P in keyof S ] : CommandSignature < REPLIES , S [ P ] , M , F , S , RESP , TYPE_MAPPING > ;
71
71
} ;
72
72
73
- export type RedisClientMultiCommandType <
73
+ type InternalRedisClientMultiCommandType <
74
74
REPLIES extends Array < any > ,
75
75
M extends RedisModules ,
76
76
F extends RedisFunctions ,
@@ -85,6 +85,19 @@ export type RedisClientMultiCommandType<
85
85
WithScripts < REPLIES , M , F , S , RESP , TYPE_MAPPING >
86
86
) ;
87
87
88
+ type TypedOrAny < Flag extends MultiMode , T > =
89
+ [ Flag ] extends [ MULTI_MODE [ 'TYPED' ] ] ? T : any ;
90
+
91
+ export type RedisClientMultiCommandType <
92
+ isTyped extends MultiMode ,
93
+ REPLIES extends Array < any > ,
94
+ M extends RedisModules ,
95
+ F extends RedisFunctions ,
96
+ S extends RedisScripts ,
97
+ RESP extends RespVersions ,
98
+ TYPE_MAPPING extends TypeMapping
99
+ > = TypedOrAny < isTyped , InternalRedisClientMultiCommandType < REPLIES , M , F , S , RESP , TYPE_MAPPING > > ;
100
+
88
101
type ExecuteMulti = ( commands : Array < RedisMultiQueuedCommand > , selectedDB ?: number ) => Promise < Array < unknown > > ;
89
102
90
103
export default class RedisClientMultiCommand < REPLIES = [ ] > {
0 commit comments