@upstash/redis 0.0.0-ci.8f707ef1-20220808 → 0.0.0-ci.9190cbfb-20230208
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/README.md +20 -18
- package/esm/deps/deno.land/x/base64@v0.2.1/base.js +100 -0
- package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +9 -0
- package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +1 -0
- package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +191 -0
- package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +50 -0
- package/esm/pkg/commands/command.js +12 -3
- package/esm/pkg/commands/getdel.js +9 -0
- package/esm/pkg/commands/hgetall.js +0 -4
- package/esm/pkg/commands/hrandfield.js +39 -0
- package/esm/pkg/commands/json_arrappend.js +9 -0
- package/esm/pkg/commands/json_arrindex.js +9 -0
- package/esm/pkg/commands/json_arrinsert.js +9 -0
- package/esm/pkg/commands/json_arrlen.js +9 -0
- package/esm/pkg/commands/json_arrpop.js +9 -0
- package/esm/pkg/commands/json_arrtrim.js +12 -0
- package/esm/pkg/commands/json_clear.js +9 -0
- package/esm/pkg/commands/json_del.js +9 -0
- package/esm/pkg/commands/json_forget.js +9 -0
- package/esm/pkg/commands/json_get.js +30 -0
- package/esm/pkg/commands/json_mget.js +9 -0
- package/esm/pkg/commands/json_numincrby.js +9 -0
- package/esm/pkg/commands/json_nummultby.js +9 -0
- package/esm/pkg/commands/json_objkeys.js +9 -0
- package/esm/pkg/commands/json_objlen.js +9 -0
- package/esm/pkg/commands/json_resp.js +9 -0
- package/esm/pkg/commands/json_set.js +18 -0
- package/esm/pkg/commands/json_strappend.js +9 -0
- package/esm/pkg/commands/json_strlen.js +9 -0
- package/esm/pkg/commands/json_toggle.js +9 -0
- package/esm/pkg/commands/json_type.js +9 -0
- package/esm/pkg/commands/lmove.js +9 -0
- package/esm/pkg/commands/mod.js +25 -0
- package/esm/pkg/commands/scan.js +3 -0
- package/esm/pkg/commands/smismember.js +9 -0
- package/esm/pkg/commands/zdiffstore.js +9 -0
- package/esm/pkg/commands/zmscore.js +10 -0
- package/esm/pkg/http.js +90 -2
- package/esm/pkg/pipeline.js +163 -6
- package/esm/pkg/redis.js +202 -2
- package/esm/pkg/script.js +77 -0
- package/esm/platforms/cloudflare.js +10 -2
- package/esm/platforms/fastly.js +6 -0
- package/esm/platforms/node_with_fetch.js +26 -1
- package/esm/platforms/nodejs.js +21 -1
- package/esm/version.js +1 -0
- package/package.json +41 -54
- package/script/deps/deno.land/x/base64@v0.2.1/base.js +104 -0
- package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +13 -0
- package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +6 -0
- package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +196 -0
- package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +55 -0
- package/script/pkg/commands/command.js +12 -3
- package/script/pkg/commands/getdel.js +13 -0
- package/script/pkg/commands/hgetall.js +0 -4
- package/script/pkg/commands/hrandfield.js +43 -0
- package/script/pkg/commands/json_arrappend.js +13 -0
- package/script/pkg/commands/json_arrindex.js +13 -0
- package/script/pkg/commands/json_arrinsert.js +13 -0
- package/script/pkg/commands/json_arrlen.js +13 -0
- package/script/pkg/commands/json_arrpop.js +13 -0
- package/script/pkg/commands/json_arrtrim.js +16 -0
- package/script/pkg/commands/json_clear.js +13 -0
- package/script/pkg/commands/json_del.js +13 -0
- package/script/pkg/commands/json_forget.js +13 -0
- package/script/pkg/commands/json_get.js +34 -0
- package/script/pkg/commands/json_mget.js +13 -0
- package/script/pkg/commands/json_numincrby.js +13 -0
- package/script/pkg/commands/json_nummultby.js +13 -0
- package/script/pkg/commands/json_objkeys.js +13 -0
- package/script/pkg/commands/json_objlen.js +13 -0
- package/script/pkg/commands/json_resp.js +13 -0
- package/script/pkg/commands/json_set.js +22 -0
- package/script/pkg/commands/json_strappend.js +13 -0
- package/script/pkg/commands/json_strlen.js +13 -0
- package/script/pkg/commands/json_toggle.js +13 -0
- package/script/pkg/commands/json_type.js +13 -0
- package/script/pkg/commands/lmove.js +13 -0
- package/script/pkg/commands/mod.js +25 -0
- package/script/pkg/commands/scan.js +3 -0
- package/script/pkg/commands/smismember.js +13 -0
- package/script/pkg/commands/zdiffstore.js +13 -0
- package/script/pkg/commands/zmscore.js +14 -0
- package/script/pkg/http.js +90 -2
- package/script/pkg/pipeline.js +162 -5
- package/script/pkg/redis.js +201 -1
- package/script/pkg/script.js +81 -0
- package/script/platforms/cloudflare.js +10 -2
- package/script/platforms/fastly.js +6 -0
- package/script/platforms/node_with_fetch.js +26 -1
- package/script/platforms/nodejs.js +21 -1
- package/script/version.js +4 -0
- package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +5 -0
- package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +1 -0
- package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +1 -0
- package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +26 -0
- package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +3 -0
- package/types/pkg/commands/command.d.ts +5 -5
- package/types/pkg/commands/getdel.d.ts +7 -0
- package/types/pkg/commands/hrandfield.d.ts +9 -0
- package/types/pkg/commands/json_arrappend.d.ts +7 -0
- package/types/pkg/commands/json_arrindex.d.ts +13 -0
- package/types/pkg/commands/json_arrinsert.d.ts +7 -0
- package/types/pkg/commands/json_arrlen.d.ts +7 -0
- package/types/pkg/commands/json_arrpop.d.ts +7 -0
- package/types/pkg/commands/json_arrtrim.d.ts +7 -0
- package/types/pkg/commands/json_clear.d.ts +7 -0
- package/types/pkg/commands/json_del.d.ts +7 -0
- package/types/pkg/commands/json_forget.d.ts +7 -0
- package/types/pkg/commands/json_get.d.ts +15 -0
- package/types/pkg/commands/json_mget.d.ts +7 -0
- package/types/pkg/commands/json_numincrby.d.ts +7 -0
- package/types/pkg/commands/json_nummultby.d.ts +7 -0
- package/types/pkg/commands/json_objkeys.d.ts +7 -0
- package/types/pkg/commands/json_objlen.d.ts +7 -0
- package/types/pkg/commands/json_resp.d.ts +7 -0
- package/types/pkg/commands/json_set.d.ts +18 -0
- package/types/pkg/commands/json_strappend.d.ts +7 -0
- package/types/pkg/commands/json_strlen.d.ts +7 -0
- package/types/pkg/commands/json_toggle.d.ts +7 -0
- package/types/pkg/commands/json_type.d.ts +7 -0
- package/types/pkg/commands/lmove.d.ts +12 -0
- package/types/pkg/commands/mod.d.ts +25 -0
- package/types/pkg/commands/scan.d.ts +2 -1
- package/types/pkg/commands/script_flush.d.ts +1 -1
- package/types/pkg/commands/set.d.ts +1 -1
- package/types/pkg/commands/smembers.d.ts +2 -2
- package/types/pkg/commands/smismember.d.ts +7 -0
- package/types/pkg/commands/type.d.ts +1 -1
- package/types/pkg/commands/zadd.d.ts +3 -3
- package/types/pkg/commands/zdiffstore.d.ts +7 -0
- package/types/pkg/commands/zinterstore.d.ts +1 -1
- package/types/pkg/commands/zmscore.d.ts +7 -0
- package/types/pkg/commands/zrange.d.ts +1 -1
- package/types/pkg/commands/zunionstore.d.ts +1 -1
- package/types/pkg/http.d.ts +41 -8
- package/types/pkg/pipeline.d.ts +60 -5
- package/types/pkg/redis.d.ts +141 -11
- package/types/pkg/script.d.ts +42 -0
- package/types/pkg/types.d.ts +27 -1
- package/types/platforms/cloudflare.d.ts +9 -8
- package/types/platforms/fastly.d.ts +3 -7
- package/types/platforms/node_with_fetch.d.ts +3 -22
- package/types/platforms/nodejs.d.ts +4 -7
- package/types/version.d.ts +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonNumIncrByCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.numincrby
|
|
7
|
+
*/
|
|
8
|
+
class JsonNumIncrByCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.NUMINCRBY", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonNumIncrByCommand = JsonNumIncrByCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonNumMultByCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.nummultby
|
|
7
|
+
*/
|
|
8
|
+
class JsonNumMultByCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.NUMMULTBY", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonNumMultByCommand = JsonNumMultByCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonObjKeysCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.objkeys
|
|
7
|
+
*/
|
|
8
|
+
class JsonObjKeysCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.OBJKEYS", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonObjKeysCommand = JsonObjKeysCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonObjLenCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.objlen
|
|
7
|
+
*/
|
|
8
|
+
class JsonObjLenCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.OBJLEN", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonObjLenCommand = JsonObjLenCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonRespCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.resp
|
|
7
|
+
*/
|
|
8
|
+
class JsonRespCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.RESP", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonRespCommand = JsonRespCommand;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonSetCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.set
|
|
7
|
+
*/
|
|
8
|
+
class JsonSetCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
const command = ["JSON.SET", cmd[0], cmd[1], cmd[2]];
|
|
11
|
+
if (cmd[3]) {
|
|
12
|
+
if (cmd[3].nx) {
|
|
13
|
+
command.push("NX");
|
|
14
|
+
}
|
|
15
|
+
else if (cmd[3].xx) {
|
|
16
|
+
command.push("XX");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
super(command, opts);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.JsonSetCommand = JsonSetCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonStrAppendCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.strappend
|
|
7
|
+
*/
|
|
8
|
+
class JsonStrAppendCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.STRAPPEND", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonStrAppendCommand = JsonStrAppendCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonStrLenCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.strlen
|
|
7
|
+
*/
|
|
8
|
+
class JsonStrLenCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.STRLEN", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonStrLenCommand = JsonStrLenCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonToggleCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.toggle
|
|
7
|
+
*/
|
|
8
|
+
class JsonToggleCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.TOGGLE", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonToggleCommand = JsonToggleCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonTypeCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/json.type
|
|
7
|
+
*/
|
|
8
|
+
class JsonTypeCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["JSON.TYPE", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.JsonTypeCommand = JsonTypeCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LMoveCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/lmove
|
|
7
|
+
*/
|
|
8
|
+
class LMoveCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["lmove", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.LMoveCommand = LMoveCommand;
|
|
@@ -33,6 +33,7 @@ __exportStar(require("./flushall.js"), exports);
|
|
|
33
33
|
__exportStar(require("./flushdb.js"), exports);
|
|
34
34
|
__exportStar(require("./get.js"), exports);
|
|
35
35
|
__exportStar(require("./getbit.js"), exports);
|
|
36
|
+
__exportStar(require("./getdel.js"), exports);
|
|
36
37
|
__exportStar(require("./getrange.js"), exports);
|
|
37
38
|
__exportStar(require("./getset.js"), exports);
|
|
38
39
|
__exportStar(require("./hdel.js"), exports);
|
|
@@ -45,6 +46,7 @@ __exportStar(require("./hkeys.js"), exports);
|
|
|
45
46
|
__exportStar(require("./hlen.js"), exports);
|
|
46
47
|
__exportStar(require("./hmget.js"), exports);
|
|
47
48
|
__exportStar(require("./hmset.js"), exports);
|
|
49
|
+
__exportStar(require("./hrandfield.js"), exports);
|
|
48
50
|
__exportStar(require("./hscan.js"), exports);
|
|
49
51
|
__exportStar(require("./hset.js"), exports);
|
|
50
52
|
__exportStar(require("./hsetnx.js"), exports);
|
|
@@ -53,10 +55,32 @@ __exportStar(require("./hvals.js"), exports);
|
|
|
53
55
|
__exportStar(require("./incr.js"), exports);
|
|
54
56
|
__exportStar(require("./incrby.js"), exports);
|
|
55
57
|
__exportStar(require("./incrbyfloat.js"), exports);
|
|
58
|
+
__exportStar(require("./json_arrappend.js"), exports);
|
|
59
|
+
__exportStar(require("./json_arrindex.js"), exports);
|
|
60
|
+
__exportStar(require("./json_arrinsert.js"), exports);
|
|
61
|
+
__exportStar(require("./json_arrlen.js"), exports);
|
|
62
|
+
__exportStar(require("./json_arrpop.js"), exports);
|
|
63
|
+
__exportStar(require("./json_arrtrim.js"), exports);
|
|
64
|
+
__exportStar(require("./json_clear.js"), exports);
|
|
65
|
+
__exportStar(require("./json_del.js"), exports);
|
|
66
|
+
__exportStar(require("./json_forget.js"), exports);
|
|
67
|
+
__exportStar(require("./json_get.js"), exports);
|
|
68
|
+
__exportStar(require("./json_mget.js"), exports);
|
|
69
|
+
__exportStar(require("./json_numincrby.js"), exports);
|
|
70
|
+
__exportStar(require("./json_nummultby.js"), exports);
|
|
71
|
+
__exportStar(require("./json_objkeys.js"), exports);
|
|
72
|
+
__exportStar(require("./json_objlen.js"), exports);
|
|
73
|
+
__exportStar(require("./json_resp.js"), exports);
|
|
74
|
+
__exportStar(require("./json_set.js"), exports);
|
|
75
|
+
__exportStar(require("./json_strappend.js"), exports);
|
|
76
|
+
__exportStar(require("./json_strlen.js"), exports);
|
|
77
|
+
__exportStar(require("./json_toggle.js"), exports);
|
|
78
|
+
__exportStar(require("./json_type.js"), exports);
|
|
56
79
|
__exportStar(require("./keys.js"), exports);
|
|
57
80
|
__exportStar(require("./lindex.js"), exports);
|
|
58
81
|
__exportStar(require("./linsert.js"), exports);
|
|
59
82
|
__exportStar(require("./llen.js"), exports);
|
|
83
|
+
__exportStar(require("./lmove.js"), exports);
|
|
60
84
|
__exportStar(require("./lpop.js"), exports);
|
|
61
85
|
__exportStar(require("./lpos.js"), exports);
|
|
62
86
|
__exportStar(require("./lpush.js"), exports);
|
|
@@ -98,6 +122,7 @@ __exportStar(require("./sinter.js"), exports);
|
|
|
98
122
|
__exportStar(require("./sinterstore.js"), exports);
|
|
99
123
|
__exportStar(require("./sismember.js"), exports);
|
|
100
124
|
__exportStar(require("./smembers.js"), exports);
|
|
125
|
+
__exportStar(require("./smismember.js"), exports);
|
|
101
126
|
__exportStar(require("./smove.js"), exports);
|
|
102
127
|
__exportStar(require("./spop.js"), exports);
|
|
103
128
|
__exportStar(require("./srandmember.js"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SMIsMemberCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/smismember
|
|
7
|
+
*/
|
|
8
|
+
class SMIsMemberCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["smismember", cmd[0], ...cmd[1]], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SMIsMemberCommand = SMIsMemberCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZDiffStoreCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/zdiffstore
|
|
7
|
+
*/
|
|
8
|
+
class ZDiffStoreCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["zdiffstore", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ZDiffStoreCommand = ZDiffStoreCommand;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZMScoreCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/zmscore
|
|
7
|
+
*/
|
|
8
|
+
class ZMScoreCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
const [key, members] = cmd;
|
|
11
|
+
super(["zmscore", key, ...members], opts);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ZMScoreCommand = ZMScoreCommand;
|
package/script/pkg/http.js
CHANGED
|
@@ -28,9 +28,19 @@ class HttpClient {
|
|
|
28
28
|
writable: true,
|
|
29
29
|
value: void 0
|
|
30
30
|
});
|
|
31
|
+
this.options = {
|
|
32
|
+
backend: config.options?.backend,
|
|
33
|
+
agent: config.agent,
|
|
34
|
+
responseEncoding: config.responseEncoding ?? "base64", // default to base64
|
|
35
|
+
};
|
|
31
36
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
32
|
-
this.headers = {
|
|
33
|
-
|
|
37
|
+
this.headers = {
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
...config.headers,
|
|
40
|
+
};
|
|
41
|
+
if (this.options.responseEncoding === "base64") {
|
|
42
|
+
this.headers["Upstash-Encoding"] = "base64";
|
|
43
|
+
}
|
|
34
44
|
if (typeof config?.retry === "boolean" && config?.retry === false) {
|
|
35
45
|
this.retry = {
|
|
36
46
|
attempts: 1,
|
|
@@ -45,12 +55,30 @@ class HttpClient {
|
|
|
45
55
|
};
|
|
46
56
|
}
|
|
47
57
|
}
|
|
58
|
+
mergeTelemetry(telemetry) {
|
|
59
|
+
function merge(obj, key, value) {
|
|
60
|
+
if (!value) {
|
|
61
|
+
return obj;
|
|
62
|
+
}
|
|
63
|
+
if (obj[key]) {
|
|
64
|
+
obj[key] = [obj[key], value].join(",");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
obj[key] = value;
|
|
68
|
+
}
|
|
69
|
+
return obj;
|
|
70
|
+
}
|
|
71
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
|
|
72
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
|
|
73
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
|
|
74
|
+
}
|
|
48
75
|
async request(req) {
|
|
49
76
|
const requestOptions = {
|
|
50
77
|
method: "POST",
|
|
51
78
|
headers: this.headers,
|
|
52
79
|
body: JSON.stringify(req.body),
|
|
53
80
|
keepalive: true,
|
|
81
|
+
agent: this.options?.agent,
|
|
54
82
|
/**
|
|
55
83
|
* Fastly specific
|
|
56
84
|
*/
|
|
@@ -75,7 +103,67 @@ class HttpClient {
|
|
|
75
103
|
if (!res.ok) {
|
|
76
104
|
throw new error_js_1.UpstashError(body.error);
|
|
77
105
|
}
|
|
106
|
+
if (this.options?.responseEncoding === "base64") {
|
|
107
|
+
return Array.isArray(body) ? body.map(decode) : decode(body);
|
|
108
|
+
}
|
|
78
109
|
return body;
|
|
79
110
|
}
|
|
80
111
|
}
|
|
81
112
|
exports.HttpClient = HttpClient;
|
|
113
|
+
function base64decode(b64) {
|
|
114
|
+
let dec = "";
|
|
115
|
+
try {
|
|
116
|
+
/**
|
|
117
|
+
* Using only atob() is not enough because it doesn't work with unicode characters
|
|
118
|
+
*/
|
|
119
|
+
const binString = atob(b64);
|
|
120
|
+
const size = binString.length;
|
|
121
|
+
const bytes = new Uint8Array(size);
|
|
122
|
+
for (let i = 0; i < size; i++) {
|
|
123
|
+
bytes[i] = binString.charCodeAt(i);
|
|
124
|
+
}
|
|
125
|
+
dec = new TextDecoder().decode(bytes);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
dec = b64;
|
|
129
|
+
}
|
|
130
|
+
return dec;
|
|
131
|
+
// try {
|
|
132
|
+
// return decodeURIComponent(dec);
|
|
133
|
+
// } catch {
|
|
134
|
+
// return dec;
|
|
135
|
+
// }
|
|
136
|
+
}
|
|
137
|
+
function decode(raw) {
|
|
138
|
+
let result = undefined;
|
|
139
|
+
switch (typeof raw.result) {
|
|
140
|
+
case "undefined":
|
|
141
|
+
return raw;
|
|
142
|
+
case "number": {
|
|
143
|
+
result = raw.result;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case "object": {
|
|
147
|
+
if (Array.isArray(raw.result)) {
|
|
148
|
+
result = raw.result.map((v) => typeof v === "string"
|
|
149
|
+
? base64decode(v)
|
|
150
|
+
: Array.isArray(v)
|
|
151
|
+
? v.map(base64decode)
|
|
152
|
+
: v);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
// If it's not an array it must be null
|
|
156
|
+
// Apparently null is an object in javascript
|
|
157
|
+
result = null;
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case "string": {
|
|
162
|
+
result = raw.result === "OK" ? "OK" : base64decode(raw.result);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
default:
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
return { result, error: raw.error };
|
|
169
|
+
}
|
package/script/pkg/pipeline.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Pipeline = void 0;
|
|
4
4
|
const mod_js_1 = require("./commands/mod.js");
|
|
5
5
|
const error_js_1 = require("./error.js");
|
|
6
|
+
const zmscore_js_1 = require("./commands/zmscore.js");
|
|
7
|
+
const hrandfield_js_1 = require("./commands/hrandfield.js");
|
|
8
|
+
const zdiffstore_js_1 = require("./commands/zdiffstore.js");
|
|
6
9
|
/**
|
|
7
10
|
* Upstash REST API supports command pipelining to send multiple commands in
|
|
8
11
|
* batch, instead of sending each command one by one and waiting for a response.
|
|
@@ -19,7 +22,7 @@ const error_js_1 = require("./error.js");
|
|
|
19
22
|
* **Examples:**
|
|
20
23
|
*
|
|
21
24
|
* ```ts
|
|
22
|
-
* const p = redis.pipeline()
|
|
25
|
+
* const p = redis.pipeline() // or redis.multi()
|
|
23
26
|
* p.set("key","value")
|
|
24
27
|
* p.get("key")
|
|
25
28
|
* const res = await p.exec()
|
|
@@ -42,7 +45,7 @@ const error_js_1 = require("./error.js");
|
|
|
42
45
|
* ```
|
|
43
46
|
*/
|
|
44
47
|
class Pipeline {
|
|
45
|
-
constructor(
|
|
48
|
+
constructor(opts) {
|
|
46
49
|
Object.defineProperty(this, "client", {
|
|
47
50
|
enumerable: true,
|
|
48
51
|
configurable: true,
|
|
@@ -61,6 +64,12 @@ class Pipeline {
|
|
|
61
64
|
writable: true,
|
|
62
65
|
value: void 0
|
|
63
66
|
});
|
|
67
|
+
Object.defineProperty(this, "multiExec", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true,
|
|
71
|
+
value: void 0
|
|
72
|
+
});
|
|
64
73
|
/**
|
|
65
74
|
* Send the pipeline request to upstash.
|
|
66
75
|
*
|
|
@@ -79,8 +88,9 @@ class Pipeline {
|
|
|
79
88
|
if (this.commands.length === 0) {
|
|
80
89
|
throw new Error("Pipeline is empty");
|
|
81
90
|
}
|
|
91
|
+
const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
|
|
82
92
|
const res = (await this.client.request({
|
|
83
|
-
path
|
|
93
|
+
path,
|
|
84
94
|
body: Object.values(this.commands).map((c) => c.command),
|
|
85
95
|
}));
|
|
86
96
|
return res.map(({ error, result }, i) => {
|
|
@@ -127,6 +137,15 @@ class Pipeline {
|
|
|
127
137
|
writable: true,
|
|
128
138
|
value: (...args) => this.chain(new mod_js_1.BitPosCommand(args, this.commandOptions))
|
|
129
139
|
});
|
|
140
|
+
/**
|
|
141
|
+
* @see https://redis.io/commands/zdiffstore
|
|
142
|
+
*/
|
|
143
|
+
Object.defineProperty(this, "zdiffstore", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
configurable: true,
|
|
146
|
+
writable: true,
|
|
147
|
+
value: (...args) => this.chain(new zdiffstore_js_1.ZDiffStoreCommand(args, this.commandOptions))
|
|
148
|
+
});
|
|
130
149
|
/**
|
|
131
150
|
* @see https://redis.io/commands/dbsize
|
|
132
151
|
*/
|
|
@@ -253,6 +272,15 @@ class Pipeline {
|
|
|
253
272
|
writable: true,
|
|
254
273
|
value: (...args) => this.chain(new mod_js_1.GetBitCommand(args, this.commandOptions))
|
|
255
274
|
});
|
|
275
|
+
/**
|
|
276
|
+
* @see https://redis.io/commands/getdel
|
|
277
|
+
*/
|
|
278
|
+
Object.defineProperty(this, "getdel", {
|
|
279
|
+
enumerable: true,
|
|
280
|
+
configurable: true,
|
|
281
|
+
writable: true,
|
|
282
|
+
value: (...args) => this.chain(new mod_js_1.GetDelCommand(args, this.commandOptions))
|
|
283
|
+
});
|
|
256
284
|
/**
|
|
257
285
|
* @see https://redis.io/commands/getrange
|
|
258
286
|
*/
|
|
@@ -361,6 +389,15 @@ class Pipeline {
|
|
|
361
389
|
writable: true,
|
|
362
390
|
value: (key, kv) => this.chain(new mod_js_1.HMSetCommand([key, kv], this.commandOptions))
|
|
363
391
|
});
|
|
392
|
+
/**
|
|
393
|
+
* @see https://redis.io/commands/hrandfield
|
|
394
|
+
*/
|
|
395
|
+
Object.defineProperty(this, "hrandfield", {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
configurable: true,
|
|
398
|
+
writable: true,
|
|
399
|
+
value: (key, count, withValues) => this.chain(new hrandfield_js_1.HRandFieldCommand([key, count, withValues], this.commandOptions))
|
|
400
|
+
});
|
|
364
401
|
/**
|
|
365
402
|
* @see https://redis.io/commands/hscan
|
|
366
403
|
*/
|
|
@@ -469,6 +506,15 @@ class Pipeline {
|
|
|
469
506
|
writable: true,
|
|
470
507
|
value: (...args) => this.chain(new mod_js_1.LLenCommand(args, this.commandOptions))
|
|
471
508
|
});
|
|
509
|
+
/**
|
|
510
|
+
* @see https://redis.io/commands/lmove
|
|
511
|
+
*/
|
|
512
|
+
Object.defineProperty(this, "lmove", {
|
|
513
|
+
enumerable: true,
|
|
514
|
+
configurable: true,
|
|
515
|
+
writable: true,
|
|
516
|
+
value: (...args) => this.chain(new mod_js_1.LMoveCommand(args, this.commandOptions))
|
|
517
|
+
});
|
|
472
518
|
/**
|
|
473
519
|
* @see https://redis.io/commands/lpop
|
|
474
520
|
*/
|
|
@@ -838,6 +884,15 @@ class Pipeline {
|
|
|
838
884
|
writable: true,
|
|
839
885
|
value: (...args) => this.chain(new mod_js_1.SMembersCommand(args, this.commandOptions))
|
|
840
886
|
});
|
|
887
|
+
/**
|
|
888
|
+
* @see https://redis.io/commands/smismember
|
|
889
|
+
*/
|
|
890
|
+
Object.defineProperty(this, "smismember", {
|
|
891
|
+
enumerable: true,
|
|
892
|
+
configurable: true,
|
|
893
|
+
writable: true,
|
|
894
|
+
value: (key, members) => this.chain(new mod_js_1.SMIsMemberCommand([key, members], this.commandOptions))
|
|
895
|
+
});
|
|
841
896
|
/**
|
|
842
897
|
* @see https://redis.io/commands/smove
|
|
843
898
|
*/
|
|
@@ -1014,6 +1069,15 @@ class Pipeline {
|
|
|
1014
1069
|
writable: true,
|
|
1015
1070
|
value: (...args) => this.chain(new mod_js_1.ZLexCountCommand(args, this.commandOptions))
|
|
1016
1071
|
});
|
|
1072
|
+
/**
|
|
1073
|
+
* @see https://redis.io/commands/zmscore
|
|
1074
|
+
*/
|
|
1075
|
+
Object.defineProperty(this, "zmscore", {
|
|
1076
|
+
enumerable: true,
|
|
1077
|
+
configurable: true,
|
|
1078
|
+
writable: true,
|
|
1079
|
+
value: (...args) => this.chain(new zmscore_js_1.ZMScoreCommand(args, this.commandOptions))
|
|
1080
|
+
});
|
|
1017
1081
|
/**
|
|
1018
1082
|
* @see https://redis.io/commands/zpopmax
|
|
1019
1083
|
*/
|
|
@@ -1122,9 +1186,10 @@ class Pipeline {
|
|
|
1122
1186
|
writable: true,
|
|
1123
1187
|
value: (...args) => this.chain(new mod_js_1.ZUnionStoreCommand(args, this.commandOptions))
|
|
1124
1188
|
});
|
|
1125
|
-
this.client = client;
|
|
1189
|
+
this.client = opts.client;
|
|
1126
1190
|
this.commands = [];
|
|
1127
|
-
this.commandOptions = commandOptions;
|
|
1191
|
+
this.commandOptions = opts.commandOptions;
|
|
1192
|
+
this.multiExec = opts.multiExec ?? false;
|
|
1128
1193
|
}
|
|
1129
1194
|
/**
|
|
1130
1195
|
* Pushes a command into the pipelien and returns a chainable instance of the
|
|
@@ -1134,5 +1199,97 @@ class Pipeline {
|
|
|
1134
1199
|
this.commands.push(command);
|
|
1135
1200
|
return this;
|
|
1136
1201
|
}
|
|
1202
|
+
/**
|
|
1203
|
+
* @see https://redis.io/commands/?group=json
|
|
1204
|
+
*/
|
|
1205
|
+
get json() {
|
|
1206
|
+
// For some reason we needed to define the types manually, otherwise Deno wouldn't build it
|
|
1207
|
+
return {
|
|
1208
|
+
/**
|
|
1209
|
+
* @see https://redis.io/commands/json.arrappend
|
|
1210
|
+
*/
|
|
1211
|
+
arrappend: (...args) => this.chain(new mod_js_1.JsonArrAppendCommand(args, this.commandOptions)),
|
|
1212
|
+
/**
|
|
1213
|
+
* @see https://redis.io/commands/json.arrindex
|
|
1214
|
+
*/
|
|
1215
|
+
arrindex: (...args) => this.chain(new mod_js_1.JsonArrIndexCommand(args, this.commandOptions)),
|
|
1216
|
+
/**
|
|
1217
|
+
* @see https://redis.io/commands/json.arrinsert
|
|
1218
|
+
*/
|
|
1219
|
+
arrinsert: (...args) => this.chain(new mod_js_1.JsonArrInsertCommand(args, this.commandOptions)),
|
|
1220
|
+
/**
|
|
1221
|
+
* @see https://redis.io/commands/json.arrlen
|
|
1222
|
+
*/
|
|
1223
|
+
arrlen: (...args) => this.chain(new mod_js_1.JsonArrLenCommand(args, this.commandOptions)),
|
|
1224
|
+
/**
|
|
1225
|
+
* @see https://redis.io/commands/json.arrpop
|
|
1226
|
+
*/
|
|
1227
|
+
arrpop: (...args) => this.chain(new mod_js_1.JsonArrPopCommand(args, this.commandOptions)),
|
|
1228
|
+
/**
|
|
1229
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
1230
|
+
*/
|
|
1231
|
+
arrtrim: (...args) => this.chain(new mod_js_1.JsonArrTrimCommand(args, this.commandOptions)),
|
|
1232
|
+
/**
|
|
1233
|
+
* @see https://redis.io/commands/json.clear
|
|
1234
|
+
*/
|
|
1235
|
+
clear: (...args) => this.chain(new mod_js_1.JsonClearCommand(args, this.commandOptions)),
|
|
1236
|
+
/**
|
|
1237
|
+
* @see https://redis.io/commands/json.del
|
|
1238
|
+
*/
|
|
1239
|
+
del: (...args) => this.chain(new mod_js_1.JsonDelCommand(args, this.commandOptions)),
|
|
1240
|
+
/**
|
|
1241
|
+
* @see https://redis.io/commands/json.forget
|
|
1242
|
+
*/
|
|
1243
|
+
forget: (...args) => this.chain(new mod_js_1.JsonForgetCommand(args, this.commandOptions)),
|
|
1244
|
+
/**
|
|
1245
|
+
* @see https://redis.io/commands/json.get
|
|
1246
|
+
*/
|
|
1247
|
+
get: (...args) => this.chain(new mod_js_1.JsonGetCommand(args, this.commandOptions)),
|
|
1248
|
+
/**
|
|
1249
|
+
* @see https://redis.io/commands/json.mget
|
|
1250
|
+
*/
|
|
1251
|
+
mget: (...args) => this.chain(new mod_js_1.JsonMGetCommand(args, this.commandOptions)),
|
|
1252
|
+
/**
|
|
1253
|
+
* @see https://redis.io/commands/json.numincrby
|
|
1254
|
+
*/
|
|
1255
|
+
numincrby: (...args) => this.chain(new mod_js_1.JsonNumIncrByCommand(args, this.commandOptions)),
|
|
1256
|
+
/**
|
|
1257
|
+
* @see https://redis.io/commands/json.nummultby
|
|
1258
|
+
*/
|
|
1259
|
+
nummultby: (...args) => this.chain(new mod_js_1.JsonNumMultByCommand(args, this.commandOptions)),
|
|
1260
|
+
/**
|
|
1261
|
+
* @see https://redis.io/commands/json.objkeys
|
|
1262
|
+
*/
|
|
1263
|
+
objkeys: (...args) => this.chain(new mod_js_1.JsonObjKeysCommand(args, this.commandOptions)),
|
|
1264
|
+
/**
|
|
1265
|
+
* @see https://redis.io/commands/json.objlen
|
|
1266
|
+
*/
|
|
1267
|
+
objlen: (...args) => this.chain(new mod_js_1.JsonObjLenCommand(args, this.commandOptions)),
|
|
1268
|
+
/**
|
|
1269
|
+
* @see https://redis.io/commands/json.resp
|
|
1270
|
+
*/
|
|
1271
|
+
resp: (...args) => this.chain(new mod_js_1.JsonRespCommand(args, this.commandOptions)),
|
|
1272
|
+
/**
|
|
1273
|
+
* @see https://redis.io/commands/json.set
|
|
1274
|
+
*/
|
|
1275
|
+
set: (...args) => this.chain(new mod_js_1.JsonSetCommand(args, this.commandOptions)),
|
|
1276
|
+
/**
|
|
1277
|
+
* @see https://redis.io/commands/json.strappend
|
|
1278
|
+
*/
|
|
1279
|
+
strappend: (...args) => this.chain(new mod_js_1.JsonStrAppendCommand(args, this.commandOptions)),
|
|
1280
|
+
/**
|
|
1281
|
+
* @see https://redis.io/commands/json.strlen
|
|
1282
|
+
*/
|
|
1283
|
+
strlen: (...args) => this.chain(new mod_js_1.JsonStrLenCommand(args, this.commandOptions)),
|
|
1284
|
+
/**
|
|
1285
|
+
* @see https://redis.io/commands/json.toggle
|
|
1286
|
+
*/
|
|
1287
|
+
toggle: (...args) => this.chain(new mod_js_1.JsonToggleCommand(args, this.commandOptions)),
|
|
1288
|
+
/**
|
|
1289
|
+
* @see https://redis.io/commands/json.type
|
|
1290
|
+
*/
|
|
1291
|
+
type: (...args) => this.chain(new mod_js_1.JsonTypeCommand(args, this.commandOptions)),
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1137
1294
|
}
|
|
1138
1295
|
exports.Pipeline = Pipeline;
|