Skip to content

Commit 9d891c7

Browse files
committed
Merge branch 'v5-search-broken' into cmd-parser-with-commands
2 parents e3eabcc + 9adac9d commit 9d891c7

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
@@ -285,7 +285,7 @@ export type Command = {
285285
parseCommand(this: void, parser: CommandParser, ...args: Array<any>): void;
286286
TRANSFORM_LEGACY_REPLY?: boolean;
287287
transformReply: TransformReply | Record<RespVersions, TransformReply>;
288-
unstableResp3SearchModule?: boolean;
288+
unstableResp3?: boolean;
289289
};
290290

291291
export type RedisCommands = Record<string, Command>;
@@ -319,7 +319,7 @@ export interface CommanderConfig<
319319
/**
320320
* TODO
321321
*/
322-
unstableResp3SearchModule?: boolean;
322+
unstableResp3?: boolean;
323323
}
324324

325325
type Resp2Array<T> = (

packages/client/lib/cluster/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ export interface RedisClusterOptions<
6666
* Useful when the cluster is running on another network
6767
*/
6868
nodeAddressMap?: NodeAddressMap;
69-
/**
70-
* TODO
71-
*/
72-
unstableResp3SearchModule?: boolean;
7369
}
7470

7571
// 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,6 +1,6 @@
11
import { CommandParser } from '../client/parser';
2-
import { Command, RedisArgument } from '../RESP/types';
3-
import { transformStreamsMessagesReplyResp2, transformStreamsMessagesReplyResp3 } from './generic-transformers';
2+
import { Command, RedisArgument, ReplyUnion } from '../RESP/types';
3+
import { transformStreamsMessagesReplyResp2 } from './generic-transformers';
44

55
export interface XReadStream {
66
key: RedisArgument;
@@ -47,6 +47,7 @@ export default {
4747
},
4848
transformReply: {
4949
2: transformStreamsMessagesReplyResp2,
50-
3: transformStreamsMessagesReplyResp3
51-
}
50+
3: undefined as unknown as () => ReplyUnion
51+
},
52+
unstableResp3: true
5253
} as const satisfies Command;

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

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

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

140-
assert.deepStrictEqual(readGroupReply, obj);
148+
assert.deepStrictEqual(readGroupReply, arr);
141149
}, {
142150
client: GLOBAL.SERVERS.OPEN,
143151
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,7 +1,7 @@
11
import { CommandParser } from '../client/parser';
2-
import { Command, RedisArgument } from '../RESP/types';
2+
import { Command, RedisArgument, ReplyUnion } from '../RESP/types';
33
import { XReadStreams, pushXReadStreams } from './XREAD';
4-
import { transformStreamsMessagesReplyResp2, transformStreamsMessagesReplyResp3 } from './generic-transformers';
4+
import { transformStreamsMessagesReplyResp2 } from './generic-transformers';
55

66
export interface XReadGroupOptions {
77
COUNT?: number;
@@ -36,6 +36,7 @@ export default {
3636
},
3737
transformReply: {
3838
2: transformStreamsMessagesReplyResp2,
39-
3: transformStreamsMessagesReplyResp3
40-
}
39+
3: undefined as unknown as () => ReplyUnion
40+
},
41+
unstableResp3: true,
4142
} 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
@@ -557,6 +557,7 @@ export function transformStreamsMessagesReplyResp2(
557557
if (reply === null) return null as unknown as NullReply;
558558

559559
switch (typeMapping? typeMapping[RESP_TYPES.MAP] : undefined) {
560+
/*
560561
case Map: {
561562
const ret = new Map<string, StreamMessagesReply>();
562563
@@ -571,6 +572,14 @@ export function transformStreamsMessagesReplyResp2(
571572
572573
return ret as unknown as MapReply<string, StreamMessagesReply>;
573574
}
575+
*/
576+
/* work around for now */
577+
default:
578+
if (!typeMapping) {
579+
typeMapping = {};
580+
}
581+
// console.log("forcing map type map to array");
582+
// typeMapping[RESP_TYPES.MAP] = Array;
574583
case Array: {
575584
const ret: Array<BlobStringReply | StreamMessagesReply> = [];
576585

@@ -581,11 +590,12 @@ export function transformStreamsMessagesReplyResp2(
581590
const rawMessages = stream[1];
582591

583592
ret.push(name);
584-
ret.push(transformStreamMessagesReply(rawMessages));
593+
ret.push(transformStreamMessagesReply(rawMessages, typeMapping));
585594
}
586595

587596
return ret as unknown as MapReply<string, StreamMessagesReply>;
588597
}
598+
/*
589599
default: {
590600
const ret: Record<string, StreamMessagesReply> = Object.create(null);
591601
@@ -600,6 +610,7 @@ export function transformStreamsMessagesReplyResp2(
600610
601611
return ret as unknown as MapReply<string, StreamMessagesReply>;
602612
}
613+
*/
603614
}
604615
}
605616

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
@@ -160,7 +160,7 @@ export default {
160160
},
161161
3: undefined as unknown as () => ReplyUnion
162162
},
163-
unstableResp3SearchModule: true
163+
unstableResp3: true
164164
} as const satisfies Command;
165165

166166
export function parseAggregateOptions(parser: CommandParser , options?: FtAggregateOptions) {

0 commit comments

Comments
 (0)