Skip to content

Commit 9baec20

Browse files
committed
reove ignoreTypeMapping per offline discussion
1 parent a91dded commit 9baec20

File tree

15 files changed

+40
-108
lines changed

15 files changed

+40
-108
lines changed

packages/bloom/lib/commands/bloom/INFO.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default {
3434
},
3535
3: (reply: UnwrapReply<BfInfoReplyMap>) => {
3636
if (reply instanceof Map) {
37-
throw new Error("BF.INFO shouldn't return a map type in resp3 anymore");
37+
throw new Error("BF.INFO shouldn't be used with type mapping to map or array");
3838
/*
3939
return {
4040
capacity: reply.get("Capacity" as unknown as BlobStringReply<'Capacity'>),
@@ -45,7 +45,7 @@ export default {
4545
}
4646
*/
4747
} else if (reply instanceof Array) {
48-
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore");
48+
throw new Error("BF.INFO shouldn't be used with type mapping to map or array");
4949
/*
5050
return {
5151
capacity: reply[1],
@@ -66,5 +66,4 @@ export default {
6666
}
6767
},
6868
},
69-
ignoreTypeMapping: true
7069
} as const satisfies Command;

packages/bloom/lib/commands/count-min-sketch/INFO.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
},
2929
3: (reply: UnwrapReply<CmsInfoReplyMap>): CmsInfoReply => {
3030
if (reply instanceof Map) {
31-
throw new Error("BF.INFO shouldn't return a nap type in resp3 anymore");
31+
throw new Error("CMS.INFO shouldn't be used with type mapping to map or array");
3232
/*
3333
return {
3434
width: reply.get("width" as unknown as BlobStringReply<'width'>),
@@ -37,7 +37,7 @@ export default {
3737
}
3838
*/
3939
} else if (reply instanceof Array) {
40-
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore");
40+
throw new Error("CMS.INFO shouldn't be used with type mapping to map or array");
4141
/*
4242
return {
4343
width: reply[1],
@@ -54,5 +54,4 @@ export default {
5454
}
5555
}
5656
},
57-
ignoreTypeMapping: true
5857
} as const satisfies Command;

packages/bloom/lib/commands/cuckoo/INFO.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default {
4444
},
4545
3: (reply: UnwrapReply<CfInfoReplyMap>): CfInfoReply => {
4646
if (reply instanceof Map) {
47-
throw new Error("BF.INFO shouldn't return a map type in resp3 anymore");
47+
throw new Error("CF.INFO shouldn't be used with type mapping to map or array");
4848
/*
4949
return {
5050
size: reply.get("Size" as unknown as BlobStringReply<"Size">)!,
@@ -58,7 +58,7 @@ export default {
5858
}
5959
*/
6060
} else if (reply instanceof Array) {
61-
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore");
61+
throw new Error("CF.INFO shouldn't be used with type mapping to map or array");
6262
/*
6363
return {
6464
size: reply[1],
@@ -85,5 +85,4 @@ export default {
8585
}
8686
}
8787
},
88-
ignoreTypeMapping: true
8988
} as const satisfies Command;

packages/bloom/lib/commands/t-digest/INFO.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@ export interface TdInfoReply {
2424
memoryUsage?: NumberReply
2525
}
2626

27-
/*
28-
const keyMap = {
29-
'Compression': { member: 'compression', index: 1 },
30-
'Capacity': { member: 'capacity', index: 3 },
31-
'Merged nodes': { member: 'mergedNodes', index: 5 },
32-
'Unmerged nodes': { member: 'unmergedNodes', index: 7 },
33-
'Merged weight': { member: 'mergedWeight', index: 9 },
34-
'Unmerged weight': { member: 'unmergedWeight', index: 11 },
35-
'Observations': { member: 'observations', index: 13 },
36-
'Total compressions': { member: 'totalCompression': index: 15 },
37-
'Memory usage': { member: 'memoryUsage', index: 17 }
38-
}
39-
*/
40-
4127
export default {
4228
FIRST_KEY_INDEX: 1,
4329
IS_READ_ONLY: true,
@@ -60,7 +46,7 @@ export default {
6046
},
6147
3: (reply: UnwrapReply<TdInfoReplyMap>): TdInfoReply => {
6248
if (reply instanceof Map) {
63-
throw new Error("BF.INFO shouldn't return a map type in resp3 anymore");
49+
throw new Error("TDIGEST.INFO shouldn't be used with type mapping to map or array");
6450
/*
6551
return {
6652
compression: reply.get('Compression' as unknown as BlobStringReply<any>),
@@ -75,7 +61,7 @@ export default {
7561
};
7662
*/
7763
} else if (reply instanceof Array) {
78-
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore");
64+
throw new Error("TDIGEST.INFO shouldn't be used with type mapping to map or array");
7965
/*
8066
return {
8167
compression: reply[1],
@@ -104,5 +90,4 @@ export default {
10490
}
10591
}
10692
},
107-
ignoreTypeMapping: true
10893
} as const satisfies Command;

packages/bloom/lib/commands/top-k/INFO.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default {
3131
},
3232
3: (reply: UnwrapReply<TopKInfoReplyMap>): TkInfoReply => {
3333
if (reply instanceof Map) {
34-
throw new Error("BF.INFO shouldn't return a map type in resp3 anymore");
34+
throw new Error("TOPK.INFO shouldn't be used with type mapping to map or array");
3535
/*
3636
return {
3737
k: reply.get('k' as unknown as BlobStringReply<'k'>) as NumberReply,
@@ -41,7 +41,7 @@ export default {
4141
};
4242
*/
4343
} else if (reply instanceof Array) {
44-
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore");
44+
throw new Error("TOPK.INFO shouldn't be used with type mapping to map or array");
4545
/*
4646
return {
4747
k: reply[1],
@@ -59,6 +59,5 @@ export default {
5959
};
6060
}
6161
}
62-
},
63-
ignoreTypeMapping: true
62+
}
6463
} as const satisfies Command

packages/client/lib/RESP/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ export type Command = {
278278
TRANSFORM_LEGACY_REPLY?: boolean;
279279
transformReply: TransformReply | Record<RespVersions, TransformReply>;
280280
unstableResp3Module?: boolean;
281-
ignoreTypeMapping?: boolean;
282281
};
283282

284283
export type RedisCommands = Record<string, Command>;

packages/client/lib/client/index.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ export default class RedisClient<
154154
return async function (this: ProxyClient, ...args: Array<unknown>) {
155155
const redisArgs = command.transformArguments(...args);
156156

157-
const commandOptions = this._commandOptions && command.ignoreTypeMapping ? { ...this._commandOptions, typeMapping: undefined} : undefined;
158-
159-
const reply = await this.sendCommand(redisArgs, commandOptions);
157+
const reply = await this.sendCommand(redisArgs, this._commandOptions);
160158
return transformReply ?
161159
transformReply(reply, redisArgs.preserve) :
162160
reply;
@@ -168,9 +166,7 @@ export default class RedisClient<
168166
return async function (this: NamespaceProxyClient, ...args: Array<unknown>) {
169167
const redisArgs = command.transformArguments(...args);
170168

171-
const commandOptions = this._self._commandOptions && command.ignoreTypeMapping ? { ...this._self._commandOptions, typeMapping: undefined} : undefined;
172-
173-
const reply = await this._self.sendCommand(redisArgs, commandOptions);
169+
const reply = await this._self.sendCommand(redisArgs, this._self._commandOptions);
174170
return transformReply ?
175171
transformReply(reply, redisArgs.preserve) :
176172
reply;
@@ -183,11 +179,9 @@ export default class RedisClient<
183179
return async function (this: NamespaceProxyClient, ...args: Array<unknown>) {
184180
const fnArgs = fn.transformArguments(...args);
185181

186-
const commandOptions = this._self._commandOptions && fn.ignoreTypeMapping ? { ...this._self._commandOptions, typeMapping: undefined} : undefined;
187-
188182
const reply = await this._self.sendCommand(
189183
prefix.concat(fnArgs),
190-
commandOptions
184+
this._self._commandOptions
191185
);
192186
return transformReply ?
193187
transformReply(reply, fnArgs.preserve) :
@@ -202,9 +196,7 @@ export default class RedisClient<
202196
const scriptArgs = script.transformArguments(...args);
203197
const redisArgs = prefix.concat(scriptArgs)
204198

205-
const commandOptions = this._commandOptions && script.ignoreTypeMapping ? { ...this._commandOptions, typeMapping: undefined} : undefined;
206-
207-
const reply = await this.executeScript(script, redisArgs, commandOptions);
199+
const reply = await this.executeScript(script, redisArgs, this._self._commandOptions);
208200
return transformReply ?
209201
transformReply(reply, scriptArgs.preserve) :
210202
reply;
@@ -804,9 +796,9 @@ export default class RedisClient<
804796

805797
const chainId = Symbol('Pipeline Chain'),
806798
promise = Promise.all(
807-
commands.map(({ args, ignoreTypeMapping }) => this._self.#queue.addCommand(args, {
799+
commands.map(({ args }) => this._self.#queue.addCommand(args, {
808800
chainId,
809-
typeMapping: !ignoreTypeMapping ? this._commandOptions?.typeMapping : undefined
801+
typeMapping: this._commandOptions?.typeMapping
810802
}))
811803
);
812804
this._self.#scheduleWrite();
@@ -849,11 +841,11 @@ export default class RedisClient<
849841
this._self.#queue.addCommand(['MULTI'], { chainId }),
850842
];
851843

852-
for (const { args, ignoreTypeMapping } of commands) {
844+
for (const { args} of commands) {
853845
promises.push(
854846
this._self.#queue.addCommand(args, {
855847
chainId: chainId,
856-
typeMapping: !ignoreTypeMapping ? typeMapping : undefined
848+
typeMapping: typeMapping
857849
})
858850
);
859851
}

packages/client/lib/client/legacy-mode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class LegacyMultiCommand {
126126
return function (this: LegacyMultiCommand, ...args: LegacyArguments) {
127127
const redisArgs = [name];
128128
RedisLegacyClient.pushArguments(redisArgs, args);
129-
this.#multi.addCommand(redisArgs, undefined, transformReply);
129+
this.#multi.addCommand(redisArgs, transformReply);
130130
return this;
131131
};
132132
}

packages/client/lib/client/multi-command.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export default class RedisClientMultiCommand<REPLIES = []> {
9191
return function (this: RedisClientMultiCommand, ...args: Array<unknown>) {
9292
return this.addCommand(
9393
command.transformArguments(...args),
94-
command.ignoreTypeMapping,
9594
transformReply
9695
);
9796
};
@@ -102,7 +101,6 @@ export default class RedisClientMultiCommand<REPLIES = []> {
102101
return function (this: { _self: RedisClientMultiCommand }, ...args: Array<unknown>) {
103102
return this._self.addCommand(
104103
command.transformArguments(...args),
105-
command.ignoreTypeMapping,
106104
transformReply
107105
);
108106
};
@@ -117,7 +115,6 @@ export default class RedisClientMultiCommand<REPLIES = []> {
117115
redisArgs.preserve = fnArgs.preserve;
118116
return this._self.addCommand(
119117
redisArgs,
120-
fn.ignoreTypeMapping,
121118
transformReply
122119
);
123120
};
@@ -129,7 +126,6 @@ export default class RedisClientMultiCommand<REPLIES = []> {
129126
this.#multi.addScript(
130127
script,
131128
script.transformArguments(...args),
132-
script.ignoreTypeMapping,
133129
transformReply
134130
);
135131
return this;
@@ -165,14 +161,14 @@ export default class RedisClientMultiCommand<REPLIES = []> {
165161

166162
SELECT(db: number, transformReply?: TransformReply): this {
167163
this.#selectedDB = db;
168-
this.#multi.addCommand(['SELECT', db.toString()], undefined, transformReply);
164+
this.#multi.addCommand(['SELECT', db.toString()], transformReply);
169165
return this;
170166
}
171167

172168
select = this.SELECT;
173169

174-
addCommand(args: CommandArguments, ignoreTypeMapping?: boolean, transformReply?: TransformReply) {
175-
this.#multi.addCommand(args, ignoreTypeMapping, transformReply);
170+
addCommand(args: CommandArguments, transformReply?: TransformReply) {
171+
this.#multi.addCommand(args, transformReply);
176172
return this;
177173
}
178174

packages/client/lib/client/pool.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ export class RedisClientPool<
6767
return async function (this: ProxyPool, ...args: Array<unknown>) {
6868
const redisArgs = command.transformArguments(...args);
6969

70-
const commandOptions = this._commandOptions && command.ignoreTypeMapping ? { ...this._commandOptions, typeMapping: undefined} : undefined;
71-
72-
const reply = await this.sendCommand(redisArgs, commandOptions);
70+
const reply = await this.sendCommand(redisArgs, this._commandOptions);
7371
return transformReply ?
7472
transformReply(reply, redisArgs.preserve) :
7573
reply;
@@ -81,9 +79,7 @@ export class RedisClientPool<
8179
return async function (this: NamespaceProxyPool, ...args: Array<unknown>) {
8280
const redisArgs = command.transformArguments(...args);
8381

84-
const commandOptions = this._self._commandOptions && command.ignoreTypeMapping ? { ...this._self._commandOptions, typeMapping: undefined} : undefined;
85-
86-
const reply = await this._self.sendCommand(redisArgs, commandOptions);
82+
const reply = await this._self.sendCommand(redisArgs, this._self._commandOptions);
8783
return transformReply ?
8884
transformReply(reply, redisArgs.preserve) :
8985
reply;
@@ -96,11 +92,9 @@ export class RedisClientPool<
9692
return async function (this: NamespaceProxyPool, ...args: Array<unknown>) {
9793
const fnArgs = fn.transformArguments(...args);
9894

99-
const commandOptions = this._self._commandOptions && fn.ignoreTypeMapping ? { ...this._self._commandOptions, typeMapping: undefined} : undefined;
100-
10195
const reply = await this._self.sendCommand(
10296
prefix.concat(fnArgs),
103-
commandOptions
97+
this._self._commandOptions
10498
);
10599
return transformReply ?
106100
transformReply(reply, fnArgs.preserve) :
@@ -115,9 +109,7 @@ export class RedisClientPool<
115109
const scriptArgs = script.transformArguments(...args);
116110
const redisArgs = prefix.concat(scriptArgs);
117111

118-
const commandOptions = this._commandOptions && script.ignoreTypeMapping ? { ...this._commandOptions, typeMapping: undefined} : undefined;
119-
120-
const reply = await this.executeScript(script, redisArgs, commandOptions);
112+
const reply = await this.executeScript(script, redisArgs, this._commandOptions);
121113
return transformReply ?
122114
transformReply(reply, scriptArgs.preserve) :
123115
reply;

0 commit comments

Comments
 (0)