@upstash/redis 1.24.0-next.1 → 1.24.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,15 @@ function deserialize(result) {
8
8
  const key = result.shift();
9
9
  const value = result.shift();
10
10
  try {
11
- obj[key] = JSON.parse(value);
11
+ // handle unsafe integer
12
+ const valueIsNumberAndNotSafeInteger = !isNaN(Number(value)) &&
13
+ !Number.isSafeInteger(value);
14
+ if (valueIsNumberAndNotSafeInteger) {
15
+ obj[key] = value;
16
+ }
17
+ else {
18
+ obj[key] = JSON.parse(value);
19
+ }
12
20
  }
13
21
  catch {
14
22
  obj[key] = value;
@@ -138,6 +138,7 @@ export * from "./zremrangebyscore.js";
138
138
  export * from "./zrevrank.js";
139
139
  export * from "./zscan.js";
140
140
  export * from "./zscore.js";
141
+ export * from "./zunion.js";
141
142
  export * from "./zunionstore.js";
142
143
  export * from "./xadd.js";
143
144
  export * from "./xrange.js";
@@ -0,0 +1,30 @@
1
+ import { Command } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/zunion
4
+ */
5
+ export class ZUnionCommand extends Command {
6
+ constructor([numKeys, keyOrKeys, opts], cmdOpts) {
7
+ const command = ["zunion", numKeys];
8
+ if (Array.isArray(keyOrKeys)) {
9
+ command.push(...keyOrKeys);
10
+ }
11
+ else {
12
+ command.push(keyOrKeys);
13
+ }
14
+ if (opts) {
15
+ if ("weights" in opts && opts.weights) {
16
+ command.push("weights", ...opts.weights);
17
+ }
18
+ else if ("weight" in opts && typeof opts.weight === "number") {
19
+ command.push("weights", opts.weight);
20
+ }
21
+ if ("aggregate" in opts) {
22
+ command.push("aggregate", opts.aggregate);
23
+ }
24
+ if (opts?.withScores) {
25
+ command.push("withscores");
26
+ }
27
+ }
28
+ super(command, cmdOpts);
29
+ }
30
+ }
@@ -1,4 +1,4 @@
1
- import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMGetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LMoveCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMIsMemberCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
1
+ import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMGetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LMoveCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMIsMemberCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionCommand, ZUnionStoreCommand, } from "./commands/mod.js";
2
2
  import { UpstashError } from "./error.js";
3
3
  import { ZMScoreCommand } from "./commands/zmscore.js";
4
4
  import { HRandFieldCommand } from "./commands/hrandfield.js";
@@ -1185,6 +1185,15 @@ export class Pipeline {
1185
1185
  writable: true,
1186
1186
  value: (...args) => this.chain(new ZUnionStoreCommand(args, this.commandOptions))
1187
1187
  });
1188
+ /**
1189
+ * @see https://redis.io/commands/zunion
1190
+ */
1191
+ Object.defineProperty(this, "zunion", {
1192
+ enumerable: true,
1193
+ configurable: true,
1194
+ writable: true,
1195
+ value: (...args) => this.chain(new ZUnionCommand(args, this.commandOptions))
1196
+ });
1188
1197
  this.client = opts.client;
1189
1198
  this.commands = []; // the TCommands generic in the class definition is only used for carrying through chained command types and should never be explicitly set when instantiating the class
1190
1199
  this.commandOptions = opts.commandOptions;
package/esm/pkg/redis.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GeoAddCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HRandFieldCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMGetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LMoveCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMIsMemberCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, XAddCommand, XRangeCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
1
+ import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GeoAddCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HRandFieldCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMGetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LMoveCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMIsMemberCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, XAddCommand, XRangeCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionCommand, ZUnionStoreCommand, } from "./commands/mod.js";
2
2
  import { Pipeline } from "./pipeline.js";
3
3
  import { Script } from "./script.js";
4
4
  import { ZMScoreCommand } from "./commands/zmscore.js";
@@ -1198,6 +1198,15 @@ export class Redis {
1198
1198
  writable: true,
1199
1199
  value: (key, member) => new ZScoreCommand([key, member], this.opts).exec(this.client)
1200
1200
  });
1201
+ /**
1202
+ * @see https://redis.io/commands/zunion
1203
+ */
1204
+ Object.defineProperty(this, "zunion", {
1205
+ enumerable: true,
1206
+ configurable: true,
1207
+ writable: true,
1208
+ value: (...args) => new ZUnionCommand(args, this.opts).exec(this.client)
1209
+ });
1201
1210
  /**
1202
1211
  * @see https://redis.io/commands/zunionstore
1203
1212
  */
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/platforms/nodejs.js",
4
4
  "types": "./types/platforms/nodejs.d.ts",
5
5
  "name": "@upstash/redis",
6
- "version": "1.24.0-next.1",
6
+ "version": "1.24.0-next.2",
7
7
  "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
8
8
  "repository": {
9
9
  "type": "git",
@@ -11,7 +11,15 @@ function deserialize(result) {
11
11
  const key = result.shift();
12
12
  const value = result.shift();
13
13
  try {
14
- obj[key] = JSON.parse(value);
14
+ // handle unsafe integer
15
+ const valueIsNumberAndNotSafeInteger = !isNaN(Number(value)) &&
16
+ !Number.isSafeInteger(value);
17
+ if (valueIsNumberAndNotSafeInteger) {
18
+ obj[key] = value;
19
+ }
20
+ else {
21
+ obj[key] = JSON.parse(value);
22
+ }
15
23
  }
16
24
  catch {
17
25
  obj[key] = value;
@@ -154,6 +154,7 @@ __exportStar(require("./zremrangebyscore.js"), exports);
154
154
  __exportStar(require("./zrevrank.js"), exports);
155
155
  __exportStar(require("./zscan.js"), exports);
156
156
  __exportStar(require("./zscore.js"), exports);
157
+ __exportStar(require("./zunion.js"), exports);
157
158
  __exportStar(require("./zunionstore.js"), exports);
158
159
  __exportStar(require("./xadd.js"), exports);
159
160
  __exportStar(require("./xrange.js"), exports);
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZUnionCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/zunion
7
+ */
8
+ class ZUnionCommand extends command_js_1.Command {
9
+ constructor([numKeys, keyOrKeys, opts], cmdOpts) {
10
+ const command = ["zunion", numKeys];
11
+ if (Array.isArray(keyOrKeys)) {
12
+ command.push(...keyOrKeys);
13
+ }
14
+ else {
15
+ command.push(keyOrKeys);
16
+ }
17
+ if (opts) {
18
+ if ("weights" in opts && opts.weights) {
19
+ command.push("weights", ...opts.weights);
20
+ }
21
+ else if ("weight" in opts && typeof opts.weight === "number") {
22
+ command.push("weights", opts.weight);
23
+ }
24
+ if ("aggregate" in opts) {
25
+ command.push("aggregate", opts.aggregate);
26
+ }
27
+ if (opts?.withScores) {
28
+ command.push("withscores");
29
+ }
30
+ }
31
+ super(command, cmdOpts);
32
+ }
33
+ }
34
+ exports.ZUnionCommand = ZUnionCommand;
@@ -1188,6 +1188,15 @@ class Pipeline {
1188
1188
  writable: true,
1189
1189
  value: (...args) => this.chain(new mod_js_1.ZUnionStoreCommand(args, this.commandOptions))
1190
1190
  });
1191
+ /**
1192
+ * @see https://redis.io/commands/zunion
1193
+ */
1194
+ Object.defineProperty(this, "zunion", {
1195
+ enumerable: true,
1196
+ configurable: true,
1197
+ writable: true,
1198
+ value: (...args) => this.chain(new mod_js_1.ZUnionCommand(args, this.commandOptions))
1199
+ });
1191
1200
  this.client = opts.client;
1192
1201
  this.commands = []; // the TCommands generic in the class definition is only used for carrying through chained command types and should never be explicitly set when instantiating the class
1193
1202
  this.commandOptions = opts.commandOptions;
@@ -1201,6 +1201,15 @@ class Redis {
1201
1201
  writable: true,
1202
1202
  value: (key, member) => new mod_js_1.ZScoreCommand([key, member], this.opts).exec(this.client)
1203
1203
  });
1204
+ /**
1205
+ * @see https://redis.io/commands/zunion
1206
+ */
1207
+ Object.defineProperty(this, "zunion", {
1208
+ enumerable: true,
1209
+ configurable: true,
1210
+ writable: true,
1211
+ value: (...args) => new mod_js_1.ZUnionCommand(args, this.opts).exec(this.client)
1212
+ });
1204
1213
  /**
1205
1214
  * @see https://redis.io/commands/zunionstore
1206
1215
  */
@@ -138,6 +138,7 @@ export * from "./zremrangebyscore.js";
138
138
  export * from "./zrevrank.js";
139
139
  export * from "./zscan.js";
140
140
  export * from "./zscore.js";
141
+ export * from "./zunion.js";
141
142
  export * from "./zunionstore.js";
142
143
  export * from "./xadd.js";
143
144
  export * from "./xrange.js";
@@ -0,0 +1,29 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ export type ZUnionCommandOptions = {
3
+ withScores?: boolean;
4
+ aggregate?: "sum" | "min" | "max";
5
+ } & ({
6
+ weight: number;
7
+ weights?: never;
8
+ } | {
9
+ weight?: never;
10
+ weights: number[];
11
+ } | {
12
+ weight?: never;
13
+ weights?: never;
14
+ });
15
+ /**
16
+ * @see https://redis.io/commands/zunion
17
+ */
18
+ export declare class ZUnionCommand<TData extends unknown[]> extends Command<string[], TData> {
19
+ constructor(cmd: [
20
+ numKeys: 1,
21
+ key: string,
22
+ opts?: ZUnionCommandOptions
23
+ ], cmdOpts?: CommandOptions<string[], TData>);
24
+ constructor(cmd: [
25
+ numKeys: number,
26
+ keys: string[],
27
+ opts?: ZUnionCommandOptions
28
+ ], cmdOpts?: CommandOptions<string[], TData>);
29
+ }
@@ -583,6 +583,10 @@ export declare class Pipeline<TCommands extends Command<any, any>[] = []> {
583
583
  * @see https://redis.io/commands/zunionstore
584
584
  */
585
585
  zunionstore: (destination: string, numKeys: number, keys: string[], opts?: import("./commands/zunionstore.js").ZUnionStoreCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, number>]>;
586
+ /**
587
+ * @see https://redis.io/commands/zunion
588
+ */
589
+ zunion: (numKeys: number, keys: string[], opts?: import("./commands/zunion.js").ZUnionCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, any>]>;
586
590
  /**
587
591
  * @see https://redis.io/commands/?group=json
588
592
  */
@@ -681,6 +681,10 @@ export declare class Redis {
681
681
  * @see https://redis.io/commands/zscore
682
682
  */
683
683
  zscore: <TData>(key: string, member: TData) => Promise<number | null>;
684
+ /**
685
+ * @see https://redis.io/commands/zunion
686
+ */
687
+ zunion: (numKeys: number, keys: string[], opts?: import("./commands/zunion.js").ZUnionCommandOptions | undefined) => Promise<any>;
684
688
  /**
685
689
  * @see https://redis.io/commands/zunionstore
686
690
  */