Skip to content

Commit 9adac9d

Browse files
committed
rename unstableResp3SearchModule cofnig + xread/group support
1 parent 3d0485b commit 9adac9d

18 files changed

+52
-31
lines changed

packages/client/lib/RESP/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export type Command = {
283283
transformArguments(this: void, ...args: Array<any>): CommandArguments;
284284
TRANSFORM_LEGACY_REPLY?: boolean;
285285
transformReply: TransformReply | Record<RespVersions, TransformReply>;
286-
unstableResp3SearchModule?: boolean;
286+
unstableResp3?: boolean;
287287
};
288288

289289
export type RedisCommands = Record<string, Command>;
@@ -317,7 +317,7 @@ export interface CommanderConfig<
317317
/**
318318
* TODO
319319
*/
320-
unstableResp3SearchModule?: boolean;
320+
unstableResp3?: boolean;
321321
}
322322

323323
type Resp2Array<T> = (

packages/client/lib/cluster/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ export interface RedisClusterOptions<
6363
* Useful when the cluster is running on another network
6464
*/
6565
nodeAddressMap?: NodeAddressMap;
66-
/**
67-
* TODO
68-
*/
69-
unstableResp3SearchModule?: boolean;
7066
}
7167

7268
// remove once request & response policies are ready

packages/client/lib/commander.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function attachConfig<
4545
for (const [moduleName, module] of Object.entries(config.modules)) {
4646
const fns = Object.create(null);
4747
for (const [name, command] of Object.entries(module)) {
48-
if (config.RESP == 3 && command.unstableResp3SearchModule && !config.unstableResp3SearchModule) {
48+
if (config.RESP == 3 && command.unstableResp3 && !config.unstableResp3) {
4949
fns[name] = throwResp3SearchModuleUnstableError;
5050
} else {
5151
fns[name] = createModuleCommand(command, RESP);

packages/client/lib/commands/XREAD.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ describe('XREAD', () => {
101101
}),
102102
])
103103

104+
const arr = ['key', [{
105+
'id': id,
106+
'message': [
107+
'field',
108+
'value',
109+
]
110+
}]];
111+
104112
const obj = Object.assign(Object.create(null), {
105113
'key': [{
106114
id: id,
@@ -114,7 +122,7 @@ describe('XREAD', () => {
114122
}]
115123
});
116124

117-
assert.deepStrictEqual(reply, obj);
125+
assert.deepStrictEqual(reply, arr);
118126
}, {
119127
client: GLOBAL.SERVERS.OPEN,
120128
cluster: GLOBAL.CLUSTERS.OPEN

packages/client/lib/commands/XREAD.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Command, RedisArgument } from '../RESP/types';
2-
import { transformStreamsMessagesReplyResp2, transformStreamsMessagesReplyResp3 } from './generic-transformers';
1+
import { Command, RedisArgument, ReplyUnion } from '../RESP/types';
2+
import { transformStreamsMessagesReplyResp2 } from './generic-transformers';
33

44
export interface XReadStream {
55
key: RedisArgument;
@@ -51,7 +51,8 @@ export default {
5151
},
5252
transformReply: {
5353
2: transformStreamsMessagesReplyResp2,
54-
3: transformStreamsMessagesReplyResp3
55-
}
54+
3: undefined as unknown as () => ReplyUnion
55+
},
56+
unstableResp3: true
5657
} as const satisfies Command;
5758

packages/client/lib/commands/XREADGROUP.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ describe('XREADGROUP', () => {
123123
})
124124
]);
125125

126+
const arr = ['key', [{
127+
'id': id,
128+
'message': [
129+
'field',
130+
'value',
131+
]
132+
}]];
133+
126134
const obj = Object.assign(Object.create(null), {
127135
'key': [{
128136
id: id,
@@ -136,7 +144,7 @@ describe('XREADGROUP', () => {
136144
}]
137145
});
138146

139-
assert.deepStrictEqual(readGroupReply, obj);
147+
assert.deepStrictEqual(readGroupReply, arr);
140148
}, {
141149
client: GLOBAL.SERVERS.OPEN,
142150
cluster: GLOBAL.CLUSTERS.OPEN

packages/client/lib/commands/XREADGROUP.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Command, RedisArgument } from '../RESP/types';
2-
import { transformStreamsMessagesReplyResp2, transformStreamsMessagesReplyResp3 } from './generic-transformers';
1+
import { Command, RedisArgument, ReplyUnion } from '../RESP/types';
2+
import { transformStreamsMessagesReplyResp2 } from './generic-transformers';
33
import XREAD, { XReadStreams, pushXReadStreams } from './XREAD';
44

55
export interface XReadGroupOptions {
@@ -43,6 +43,7 @@ export default {
4343
},
4444
transformReply: {
4545
2: transformStreamsMessagesReplyResp2,
46-
3: transformStreamsMessagesReplyResp3
47-
}
46+
3: undefined as unknown as () => ReplyUnion
47+
},
48+
unstableResp3: true,
4849
} as const satisfies Command;

packages/client/lib/commands/generic-transformers.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ export function transformStreamsMessagesReplyResp2(
534534
if (reply === null) return null as unknown as NullReply;
535535

536536
switch (typeMapping? typeMapping[RESP_TYPES.MAP] : undefined) {
537+
/*
537538
case Map: {
538539
const ret = new Map<string, StreamMessagesReply>();
539540
@@ -548,6 +549,14 @@ export function transformStreamsMessagesReplyResp2(
548549
549550
return ret as unknown as MapReply<string, StreamMessagesReply>;
550551
}
552+
*/
553+
/* work around for now */
554+
default:
555+
if (!typeMapping) {
556+
typeMapping = {};
557+
}
558+
// console.log("forcing map type map to array");
559+
// typeMapping[RESP_TYPES.MAP] = Array;
551560
case Array: {
552561
const ret: Array<BlobStringReply | StreamMessagesReply> = [];
553562

@@ -558,11 +567,12 @@ export function transformStreamsMessagesReplyResp2(
558567
const rawMessages = stream[1];
559568

560569
ret.push(name);
561-
ret.push(transformStreamMessagesReply(rawMessages));
570+
ret.push(transformStreamMessagesReply(rawMessages, typeMapping));
562571
}
563572

564573
return ret as unknown as MapReply<string, StreamMessagesReply>;
565574
}
575+
/*
566576
default: {
567577
const ret: Record<string, StreamMessagesReply> = Object.create(null);
568578
@@ -577,6 +587,7 @@ export function transformStreamsMessagesReplyResp2(
577587
578588
return ret as unknown as MapReply<string, StreamMessagesReply>;
579589
}
590+
*/
580591
}
581592
}
582593

packages/client/lib/sentinel/types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ export interface RedisSentinelOptions<
5959
* When `false`, the sentinel object will wait for the first available client from the pool.
6060
*/
6161
reserveClient?: boolean;
62-
/**
63-
* TODO
64-
*/
65-
unstableResp3SearchModule?: boolean;
6662
}
6763

6864
export interface SentinelCommander<

packages/search/lib/commands/AGGREGATE.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export default {
159159
},
160160
3: undefined as unknown as () => ReplyUnion
161161
},
162-
unstableResp3SearchModule: true
162+
unstableResp3: true
163163
} as const satisfies Command;
164164

165165
export function pushAggregateOptions(args: Array<RedisArgument>, options?: FtAggregateOptions) {

packages/search/lib/commands/AGGREGATE_WITHCURSOR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ export default {
4242
},
4343
3: undefined as unknown as () => ReplyUnion
4444
},
45-
unstableResp3SearchModule: true
45+
unstableResp3: true
4646
} as const satisfies Command;
4747

packages/search/lib/commands/CURSOR_READ.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ export default {
1818
return args;
1919
},
2020
transformReply: AGGREGATE_WITHCURSOR.transformReply,
21-
unstableResp3SearchModule: true
21+
unstableResp3: true
2222
} as const satisfies Command;

packages/search/lib/commands/INFO.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
2: transformV2Reply,
1313
3: undefined as unknown as () => ReplyUnion
1414
},
15-
unstableResp3SearchModule: true
15+
unstableResp3: true
1616
} as const satisfies Command;
1717

1818
type InfoRawReply = [

packages/search/lib/commands/PROFILE_AGGREGATE.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
},
3333
3: undefined as unknown as () => ReplyUnion
3434
},
35-
unstableResp3SearchModule: true
35+
unstableResp3: true
3636
} as const satisfies Command;
3737

3838
type ProfileAggeregateRawReply = ProfileRawReply<AggregateRawReply>;

packages/search/lib/commands/PROFILE_SEARCH.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default {
5353
},
5454
3: undefined as unknown as () => ReplyUnion
5555
},
56-
unstableResp3SearchModule: true
56+
unstableResp3: true
5757
} as const satisfies Command;
5858

5959
export interface ProfileReply {

packages/search/lib/commands/SEARCH.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export default {
182182
},
183183
3: undefined as unknown as () => ReplyUnion
184184
},
185-
unstableResp3SearchModule: true
185+
unstableResp3: true
186186
} as const satisfies Command;
187187

188188
export type SearchRawReply = Array<any>;

packages/search/lib/commands/SEARCH_NOCONTENT.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
},
1919
3: undefined as unknown as () => ReplyUnion
2020
},
21-
unstableResp3SearchModule: true
21+
unstableResp3: true
2222
} as const satisfies Command;
2323

2424
export interface SearchNoContentReply {

packages/search/lib/commands/SPELLCHECK.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default {
4949
},
5050
3: undefined as unknown as () => ReplyUnion,
5151
},
52-
unstableResp3SearchModule: true
52+
unstableResp3: true
5353
} as const satisfies Command;
5454

5555
type SpellCheckRawReply = Array<[

0 commit comments

Comments
 (0)