@upstash/redis 1.23.0-next.1 → 1.23.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.
- package/esm/pkg/commands/mod.js +2 -1
- package/esm/pkg/commands/xrange.js +37 -0
- package/esm/pkg/pipeline.js +0 -1
- package/esm/pkg/redis.js +19 -5
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/script/pkg/commands/mod.js +2 -1
- package/script/pkg/commands/xrange.js +41 -0
- package/script/pkg/pipeline.js +0 -1
- package/script/pkg/redis.js +18 -4
- package/script/version.js +1 -1
- package/types/pkg/commands/mod.d.ts +2 -1
- package/types/pkg/commands/xrange.d.ts +9 -0
- package/types/pkg/redis.d.ts +25 -0
- package/types/version.d.ts +1 -1
package/esm/pkg/commands/mod.js
CHANGED
|
@@ -120,7 +120,6 @@ export * from "./touch.js";
|
|
|
120
120
|
export * from "./ttl.js";
|
|
121
121
|
export * from "./type.js";
|
|
122
122
|
export * from "./unlink.js";
|
|
123
|
-
export * from "./xadd.js";
|
|
124
123
|
export * from "./zadd.js";
|
|
125
124
|
export * from "./zcard.js";
|
|
126
125
|
export * from "./zcount.js";
|
|
@@ -139,3 +138,5 @@ export * from "./zrevrank.js";
|
|
|
139
138
|
export * from "./zscan.js";
|
|
140
139
|
export * from "./zscore.js";
|
|
141
140
|
export * from "./zunionstore.js";
|
|
141
|
+
export * from "./xadd.js";
|
|
142
|
+
export * from "./xrange.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Command } from "./command.js";
|
|
2
|
+
function deserialize(result) {
|
|
3
|
+
if (result.length === 0) {
|
|
4
|
+
return {};
|
|
5
|
+
}
|
|
6
|
+
const obj = {};
|
|
7
|
+
while (result.length >= 2) {
|
|
8
|
+
const streamId = result.shift();
|
|
9
|
+
const entries = result.shift();
|
|
10
|
+
if (!(streamId in obj)) {
|
|
11
|
+
obj[streamId] = {};
|
|
12
|
+
}
|
|
13
|
+
while (entries.length >= 2) {
|
|
14
|
+
const field = entries.shift();
|
|
15
|
+
const value = entries.shift();
|
|
16
|
+
try {
|
|
17
|
+
obj[streamId][field] = JSON.parse(value);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
obj[streamId][field] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
export class XRangeCommand extends Command {
|
|
27
|
+
constructor([key, start, end, count], opts) {
|
|
28
|
+
const command = ["XRANGE", key, start, end];
|
|
29
|
+
if (typeof count === "number") {
|
|
30
|
+
command.push("COUNT", count);
|
|
31
|
+
}
|
|
32
|
+
super(command, {
|
|
33
|
+
deserialize: (result) => deserialize(result[0]),
|
|
34
|
+
...opts,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
package/esm/pkg/pipeline.js
CHANGED
|
@@ -92,7 +92,6 @@ export class Pipeline {
|
|
|
92
92
|
path,
|
|
93
93
|
body: Object.values(this.commands).map((c) => c.command),
|
|
94
94
|
}));
|
|
95
|
-
console.log("after req", { res });
|
|
96
95
|
return res.map(({ error, result }, i) => {
|
|
97
96
|
if (error) {
|
|
98
97
|
throw new UpstashError(`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`);
|
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, 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, 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, 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";
|
|
2
2
|
import { Pipeline } from "./pipeline.js";
|
|
3
3
|
import { Script } from "./script.js";
|
|
4
4
|
import { ZMScoreCommand } from "./commands/zmscore.js";
|
|
@@ -1005,10 +1005,24 @@ export class Redis {
|
|
|
1005
1005
|
writable: true,
|
|
1006
1006
|
value: (...args) => new UnlinkCommand(args, this.opts).exec(this.client)
|
|
1007
1007
|
});
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1008
|
+
/**
|
|
1009
|
+
* @see https://redis.io/commands/xadd
|
|
1010
|
+
*/
|
|
1011
|
+
Object.defineProperty(this, "xadd", {
|
|
1012
|
+
enumerable: true,
|
|
1013
|
+
configurable: true,
|
|
1014
|
+
writable: true,
|
|
1015
|
+
value: (...args) => new XAddCommand(args, this.opts).exec(this.client)
|
|
1016
|
+
});
|
|
1017
|
+
/**
|
|
1018
|
+
* @see https://redis.io/commands/xrange
|
|
1019
|
+
*/
|
|
1020
|
+
Object.defineProperty(this, "xrange", {
|
|
1021
|
+
enumerable: true,
|
|
1022
|
+
configurable: true,
|
|
1023
|
+
writable: true,
|
|
1024
|
+
value: (...args) => new XRangeCommand(args, this.opts).exec(this.client)
|
|
1025
|
+
});
|
|
1012
1026
|
/**
|
|
1013
1027
|
* @see https://redis.io/commands/zadd
|
|
1014
1028
|
*/
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "
|
|
1
|
+
export const VERSION = "v1.23.2";
|
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": "
|
|
6
|
+
"version": "v1.23.2",
|
|
7
7
|
"description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -136,7 +136,6 @@ __exportStar(require("./touch.js"), exports);
|
|
|
136
136
|
__exportStar(require("./ttl.js"), exports);
|
|
137
137
|
__exportStar(require("./type.js"), exports);
|
|
138
138
|
__exportStar(require("./unlink.js"), exports);
|
|
139
|
-
__exportStar(require("./xadd.js"), exports);
|
|
140
139
|
__exportStar(require("./zadd.js"), exports);
|
|
141
140
|
__exportStar(require("./zcard.js"), exports);
|
|
142
141
|
__exportStar(require("./zcount.js"), exports);
|
|
@@ -155,3 +154,5 @@ __exportStar(require("./zrevrank.js"), exports);
|
|
|
155
154
|
__exportStar(require("./zscan.js"), exports);
|
|
156
155
|
__exportStar(require("./zscore.js"), exports);
|
|
157
156
|
__exportStar(require("./zunionstore.js"), exports);
|
|
157
|
+
__exportStar(require("./xadd.js"), exports);
|
|
158
|
+
__exportStar(require("./xrange.js"), exports);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XRangeCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
function deserialize(result) {
|
|
6
|
+
if (result.length === 0) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
const obj = {};
|
|
10
|
+
while (result.length >= 2) {
|
|
11
|
+
const streamId = result.shift();
|
|
12
|
+
const entries = result.shift();
|
|
13
|
+
if (!(streamId in obj)) {
|
|
14
|
+
obj[streamId] = {};
|
|
15
|
+
}
|
|
16
|
+
while (entries.length >= 2) {
|
|
17
|
+
const field = entries.shift();
|
|
18
|
+
const value = entries.shift();
|
|
19
|
+
try {
|
|
20
|
+
obj[streamId][field] = JSON.parse(value);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
obj[streamId][field] = value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
class XRangeCommand extends command_js_1.Command {
|
|
30
|
+
constructor([key, start, end, count], opts) {
|
|
31
|
+
const command = ["XRANGE", key, start, end];
|
|
32
|
+
if (typeof count === "number") {
|
|
33
|
+
command.push("COUNT", count);
|
|
34
|
+
}
|
|
35
|
+
super(command, {
|
|
36
|
+
deserialize: (result) => deserialize(result[0]),
|
|
37
|
+
...opts,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.XRangeCommand = XRangeCommand;
|
package/script/pkg/pipeline.js
CHANGED
|
@@ -95,7 +95,6 @@ class Pipeline {
|
|
|
95
95
|
path,
|
|
96
96
|
body: Object.values(this.commands).map((c) => c.command),
|
|
97
97
|
}));
|
|
98
|
-
console.log("after req", { res });
|
|
99
98
|
return res.map(({ error, result }, i) => {
|
|
100
99
|
if (error) {
|
|
101
100
|
throw new error_js_1.UpstashError(`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`);
|
package/script/pkg/redis.js
CHANGED
|
@@ -1008,10 +1008,24 @@ class Redis {
|
|
|
1008
1008
|
writable: true,
|
|
1009
1009
|
value: (...args) => new mod_js_1.UnlinkCommand(args, this.opts).exec(this.client)
|
|
1010
1010
|
});
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1011
|
+
/**
|
|
1012
|
+
* @see https://redis.io/commands/xadd
|
|
1013
|
+
*/
|
|
1014
|
+
Object.defineProperty(this, "xadd", {
|
|
1015
|
+
enumerable: true,
|
|
1016
|
+
configurable: true,
|
|
1017
|
+
writable: true,
|
|
1018
|
+
value: (...args) => new mod_js_1.XAddCommand(args, this.opts).exec(this.client)
|
|
1019
|
+
});
|
|
1020
|
+
/**
|
|
1021
|
+
* @see https://redis.io/commands/xrange
|
|
1022
|
+
*/
|
|
1023
|
+
Object.defineProperty(this, "xrange", {
|
|
1024
|
+
enumerable: true,
|
|
1025
|
+
configurable: true,
|
|
1026
|
+
writable: true,
|
|
1027
|
+
value: (...args) => new mod_js_1.XRangeCommand(args, this.opts).exec(this.client)
|
|
1028
|
+
});
|
|
1015
1029
|
/**
|
|
1016
1030
|
* @see https://redis.io/commands/zadd
|
|
1017
1031
|
*/
|
package/script/version.js
CHANGED
|
@@ -120,7 +120,6 @@ export * from "./touch.js";
|
|
|
120
120
|
export * from "./ttl.js";
|
|
121
121
|
export * from "./type.js";
|
|
122
122
|
export * from "./unlink.js";
|
|
123
|
-
export * from "./xadd.js";
|
|
124
123
|
export * from "./zadd.js";
|
|
125
124
|
export * from "./zcard.js";
|
|
126
125
|
export * from "./zcount.js";
|
|
@@ -139,3 +138,5 @@ export * from "./zrevrank.js";
|
|
|
139
138
|
export * from "./zscan.js";
|
|
140
139
|
export * from "./zscore.js";
|
|
141
140
|
export * from "./zunionstore.js";
|
|
141
|
+
export * from "./xadd.js";
|
|
142
|
+
export * from "./xrange.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
export declare class XRangeCommand<TData extends Record<string, Record<string, unknown>>> extends Command<string[][], TData> {
|
|
3
|
+
constructor([key, start, end, count]: [
|
|
4
|
+
key: string,
|
|
5
|
+
start: string,
|
|
6
|
+
end: string,
|
|
7
|
+
count?: number
|
|
8
|
+
], opts?: CommandOptions<unknown[], TData[]>);
|
|
9
|
+
}
|
package/types/pkg/redis.d.ts
CHANGED
|
@@ -562,6 +562,31 @@ export declare class Redis {
|
|
|
562
562
|
* @see https://redis.io/commands/unlink
|
|
563
563
|
*/
|
|
564
564
|
unlink: (...args: CommandArgs<typeof UnlinkCommand>) => Promise<number>;
|
|
565
|
+
/**
|
|
566
|
+
* @see https://redis.io/commands/xadd
|
|
567
|
+
*/
|
|
568
|
+
xadd: (key: string, id: string, entries: {
|
|
569
|
+
[field: string]: unknown;
|
|
570
|
+
}, opts?: {
|
|
571
|
+
nomkStream?: boolean | undefined;
|
|
572
|
+
trim?: (({
|
|
573
|
+
type: "MAXLEN" | "maxlen";
|
|
574
|
+
threshold: number;
|
|
575
|
+
} | {
|
|
576
|
+
type: "MINID" | "minid";
|
|
577
|
+
threshold: string;
|
|
578
|
+
}) & ({
|
|
579
|
+
comparison: "~";
|
|
580
|
+
limit?: number | undefined;
|
|
581
|
+
} | {
|
|
582
|
+
comparison: "=";
|
|
583
|
+
limit?: undefined;
|
|
584
|
+
})) | undefined;
|
|
585
|
+
} | undefined) => Promise<string>;
|
|
586
|
+
/**
|
|
587
|
+
* @see https://redis.io/commands/xrange
|
|
588
|
+
*/
|
|
589
|
+
xrange: (key: string, start: string, end: string, count?: number | undefined) => Promise<Record<string, Record<string, unknown>>>;
|
|
565
590
|
/**
|
|
566
591
|
* @see https://redis.io/commands/zadd
|
|
567
592
|
*/
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "
|
|
1
|
+
export declare const VERSION = "v1.23.2";
|