Skip to content

Commit 36ad751

Browse files
committed
bring all modules / all commands into v5
update unstableResp3Module flag to only commands that have unstable api add ability to tag commands to ignore user type mapping (as transformReply will convert it to a non typed map type) update bloom info commands to work with new non typed map ability fill in search/time-series commands and tag with unstableResp3Modules flag as appropriate
1 parent 471e9f2 commit 36ad751

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1023
-539
lines changed
Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,70 @@
1-
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
1+
import { RedisArgument, Command, UnwrapReply, NullReply, BlobStringReply, NumberReply, TuplesToMapReply, Resp2Reply } from '@redis/client/dist/lib/RESP/types';
2+
3+
export type BfInfoReplyMap = TuplesToMapReply<[
4+
[BlobStringReply<'Capacity'>, NumberReply],
5+
[BlobStringReply<'Size'>, NumberReply],
6+
[BlobStringReply<'Number of filters'>, NumberReply],
7+
[BlobStringReply<'Number of items inserted'>, NumberReply],
8+
[BlobStringReply<'Expansion rate'>, NullReply | NumberReply]
9+
]>;
10+
11+
export interface BfInfoReply {
12+
capacity?: NumberReply;
13+
size?: NumberReply;
14+
numberOfFilters?: NumberReply;
15+
numberOfInsertedItems?: NumberReply;
16+
expansionRate?: NullReply | NumberReply;
17+
}
218

319
export default {
420
FIRST_KEY_INDEX: 1,
521
IS_READ_ONLY: true,
622
transformArguments(key: RedisArgument) {
723
return ['BF.INFO', key];
824
},
9-
// TODO
10-
transformReply: undefined as unknown as () => any
25+
transformReply: {
26+
2: (reply: UnwrapReply<Resp2Reply<BfInfoReplyMap>>): BfInfoReply => {
27+
return {
28+
capacity: reply[1],
29+
size: reply[3],
30+
numberOfFilters: reply[5],
31+
numberOfInsertedItems: reply[7],
32+
expansionRate: reply[9]
33+
}
34+
},
35+
3: (reply: UnwrapReply<BfInfoReplyMap>) => {
36+
if (reply instanceof Map) {
37+
throw new Error("BF.INFO shouldn't return a map type in resp3 anymore");
38+
/*
39+
return {
40+
capacity: reply.get("Capacity" as unknown as BlobStringReply<'Capacity'>),
41+
size: reply.get("Size" as unknown as BlobStringReply<"Size">),
42+
numberOfFilters: reply.get("Number of filters" as unknown as BlobStringReply<"Number of filters">),
43+
numberOfInsertedItems: reply.get('Number of items inserted' as unknown as BlobStringReply<'Number of items inserted'>),
44+
expansionRate: reply.get('Expansion rate' as unknown as BlobStringReply<'Expansion rate'>),
45+
}
46+
*/
47+
} else if (reply instanceof Array) {
48+
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore");
49+
/*
50+
return {
51+
capacity: reply[1],
52+
size: reply[3],
53+
numberOfFilters: reply[5],
54+
numberOfInsertedItems: reply[7],
55+
expansionRate: reply[9]
56+
}
57+
*/
58+
} else {
59+
return {
60+
capacity: reply["Capacity"],
61+
size: reply["Size"],
62+
numberOfFilters: reply["Number of filters"],
63+
numberOfInsertedItems: reply["Number of items inserted"],
64+
expansionRate: reply["Expansion rate"]
65+
}
66+
}
67+
},
68+
},
69+
ignoreTypeMapping: true
1170
} as const satisfies Command;
Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { RedisArgument, TuplesToMapReply, BlobStringReply, NumberReply, UnwrapReply, Resp2Reply, Command } from '@redis/client/dist/lib/RESP/types';
22

3-
export type BfInfoReply = TuplesToMapReply<[
3+
export type CmsInfoReplyMap = TuplesToMapReply<[
44
[BlobStringReply<'width'>, NumberReply],
55
[BlobStringReply<'depth'>, NumberReply],
66
[BlobStringReply<'count'>, NumberReply]
77
]>;
8+
9+
export interface CmsInfoReply {
10+
width?: NumberReply;
11+
depth?: NumberReply;
12+
count?: NumberReply;
13+
}
814

915
export default {
1016
FIRST_KEY_INDEX: 1,
@@ -13,11 +19,40 @@ export default {
1319
return ['CMS.INFO', key];
1420
},
1521
transformReply: {
16-
2: (reply: UnwrapReply<Resp2Reply<BfInfoReply>>) => ({
17-
width: reply[1],
18-
depth: reply[3],
19-
count: reply[5]
20-
}),
21-
3: undefined as unknown as () => BfInfoReply
22-
}
22+
2: (reply: UnwrapReply<Resp2Reply<CmsInfoReplyMap>>): CmsInfoReply => {
23+
return {
24+
width: reply[1],
25+
depth: reply[3],
26+
count: reply[5]
27+
}
28+
},
29+
3: (reply: UnwrapReply<CmsInfoReplyMap>): CmsInfoReply => {
30+
if (reply instanceof Map) {
31+
throw new Error("BF.INFO shouldn't return a nap type in resp3 anymore");
32+
/*
33+
return {
34+
width: reply.get("width" as unknown as BlobStringReply<'width'>),
35+
depth: reply.get("depth" as unknown as BlobStringReply<"depth">),
36+
count: reply.get("count" as unknown as BlobStringReply<"count">)
37+
}
38+
*/
39+
} else if (reply instanceof Array) {
40+
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore");
41+
/*
42+
return {
43+
width: reply[1],
44+
depth: reply[3],
45+
count: reply[5]
46+
}
47+
*/
48+
} else {
49+
return {
50+
width: reply['width'],
51+
depth: reply['depth'],
52+
count: reply['count']
53+
}
54+
}
55+
}
56+
},
57+
ignoreTypeMapping: true
2358
} as const satisfies Command;
Lines changed: 81 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,89 @@
1-
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
1+
import { RedisArgument, Command, NumberReply, BlobStringReply, TuplesToMapReply, UnwrapReply, Resp2Reply } from '@redis/client/dist/lib/RESP/types';
2+
3+
export type CfInfoReplyMap = TuplesToMapReply<[
4+
[BlobStringReply<'Size'>, NumberReply],
5+
[BlobStringReply<'Number of buckets'>, NumberReply],
6+
[BlobStringReply<'Number of filters'>, NumberReply],
7+
[BlobStringReply<'Number of items inserted'>, NumberReply],
8+
[BlobStringReply<'Number of items deleted'>, NumberReply],
9+
[BlobStringReply<'Bucket size'>, NumberReply],
10+
[BlobStringReply<'Expansion rate'>, NumberReply],
11+
[BlobStringReply<'Max iterations'>, NumberReply]
12+
]>;
13+
14+
export interface CfInfoReply {
15+
size: NumberReply;
16+
numberOfBuckets: NumberReply;
17+
numberOfFilters: NumberReply;
18+
numberOfInsertedItems: NumberReply;
19+
numberOfDeletedItems: NumberReply;
20+
bucketSize: NumberReply;
21+
expansionRate: NumberReply;
22+
maxIteration: NumberReply;
23+
}
224

325
export default {
426
FIRST_KEY_INDEX: 1,
527
IS_READ_ONLY: true,
628
transformArguments(key: RedisArgument) {
729
return ['CF.INFO', key];
830
},
9-
// TODO
10-
// export type InfoRawReply = [
11-
// _: string,
12-
// size: number,
13-
// _: string,
14-
// numberOfBuckets: number,
15-
// _: string,
16-
// numberOfFilters: number,
17-
// _: string,
18-
// numberOfInsertedItems: number,
19-
// _: string,
20-
// numberOfDeletedItems: number,
21-
// _: string,
22-
// bucketSize: number,
23-
// _: string,
24-
// expansionRate: number,
25-
// _: string,
26-
// maxIteration: number
27-
// ];
28-
29-
// export interface InfoReply {
30-
// size: number;
31-
// numberOfBuckets: number;
32-
// numberOfFilters: number;
33-
// numberOfInsertedItems: number;
34-
// numberOfDeletedItems: number;
35-
// bucketSize: number;
36-
// expansionRate: number;
37-
// maxIteration: number;
38-
// }
39-
40-
// export function transformReply(reply: InfoRawReply): InfoReply {
41-
// return {
42-
// size: reply[1],
43-
// numberOfBuckets: reply[3],
44-
// numberOfFilters: reply[5],
45-
// numberOfInsertedItems: reply[7],
46-
// numberOfDeletedItems: reply[9],
47-
// bucketSize: reply[11],
48-
// expansionRate: reply[13],
49-
// maxIteration: reply[15]
50-
// };
51-
// }
52-
transformReply: undefined as unknown as () => any
31+
32+
transformReply: {
33+
2: (reply: UnwrapReply<Resp2Reply<CfInfoReplyMap>>): CfInfoReply => {
34+
return {
35+
size: reply[1],
36+
numberOfBuckets: reply[3],
37+
numberOfFilters: reply[5],
38+
numberOfInsertedItems: reply[7],
39+
numberOfDeletedItems: reply[9],
40+
bucketSize: reply[11],
41+
expansionRate: reply[13],
42+
maxIteration: reply[15]
43+
}
44+
},
45+
3: (reply: UnwrapReply<CfInfoReplyMap>): CfInfoReply => {
46+
if (reply instanceof Map) {
47+
throw new Error("BF.INFO shouldn't return a map type in resp3 anymore");
48+
/*
49+
return {
50+
size: reply.get("Size" as unknown as BlobStringReply<"Size">)!,
51+
numberOfBuckets: reply.get('Number of buckets' as unknown as BlobStringReply<'Number of buckets'>)!,
52+
numberOfFilters: reply.get('Number of filters' as unknown as BlobStringReply<"Number of filters">)!,
53+
numberOfInsertedItems: reply.get('Number of items inserted' as unknown as BlobStringReply<'Number of items inserted'>)!,
54+
numberOfDeletedItems: reply.get('Number of items deleted' as unknown as BlobStringReply<'Number of items deleted'>)!,
55+
bucketSize: reply.get('Bucket size' as unknown as BlobStringReply<'Bucket size'>)!,
56+
expansionRate: reply.get('Expansion rate' as unknown as BlobStringReply<'Expansion rate'>)!,
57+
maxIteration: reply.get('Max iterations' as unknown as BlobStringReply<'Max iterations'>)!
58+
}
59+
*/
60+
} else if (reply instanceof Array) {
61+
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore");
62+
/*
63+
return {
64+
size: reply[1],
65+
numberOfBuckets: reply[3],
66+
numberOfFilters: reply[5],
67+
numberOfInsertedItems: reply[7],
68+
numberOfDeletedItems: reply[9],
69+
bucketSize: reply[11],
70+
expansionRate: reply[13],
71+
maxIteration: reply[15]
72+
}
73+
*/
74+
} else {
75+
return {
76+
size: reply['Size'],
77+
numberOfBuckets: reply['Number of buckets'],
78+
numberOfFilters: reply['Number of filters'],
79+
numberOfInsertedItems: reply['Number of items inserted'],
80+
numberOfDeletedItems: reply['Number of items deleted'],
81+
bucketSize: reply['Bucket size'],
82+
expansionRate: reply['Expansion rate'],
83+
maxIteration: reply['Max iterations']
84+
}
85+
}
86+
}
87+
},
88+
ignoreTypeMapping: true
5389
} as const satisfies Command;

0 commit comments

Comments
 (0)