@upstash/redis 1.19.2 → 1.20.0-canary.0
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 +1 -1
- package/esm/pkg/commands/command.js +12 -3
- 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/mod.js +22 -1
- package/esm/pkg/http.js +0 -9
- package/esm/pkg/pipeline.js +93 -1
- package/esm/pkg/redis.js +99 -1
- package/esm/platforms/cloudflare.js +6 -6
- package/esm/platforms/fastly.js +5 -0
- package/esm/platforms/node_with_fetch.js +10 -11
- package/esm/platforms/nodejs.js +10 -11
- package/esm/version.js +1 -1
- package/package.json +41 -16
- package/script/pkg/commands/command.js +12 -3
- 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/mod.js +22 -1
- package/script/pkg/http.js +0 -9
- package/script/pkg/pipeline.js +92 -0
- package/script/pkg/redis.js +98 -0
- package/script/platforms/cloudflare.js +6 -6
- package/script/platforms/fastly.js +5 -0
- package/script/platforms/node_with_fetch.js +10 -11
- package/script/platforms/nodejs.js +10 -11
- package/script/version.js +1 -1
- package/types/pkg/commands/command.d.ts +5 -5
- 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/mod.d.ts +22 -1
- package/types/pkg/commands/scan.d.ts +1 -1
- package/types/pkg/commands/script_flush.d.ts +1 -1
- package/types/pkg/commands/set.d.ts +1 -1
- package/types/pkg/commands/type.d.ts +1 -1
- package/types/pkg/commands/zadd.d.ts +3 -3
- package/types/pkg/commands/zinterstore.d.ts +1 -1
- package/types/pkg/commands/zrange.d.ts +1 -1
- package/types/pkg/commands/zunionstore.d.ts +1 -1
- package/types/pkg/http.d.ts +6 -7
- package/types/pkg/pipeline.d.ts +27 -1
- package/types/pkg/redis.d.ts +96 -10
- package/types/pkg/types.d.ts +11 -2
- package/types/platforms/cloudflare.d.ts +2 -2
- package/types/platforms/fastly.d.ts +1 -1
- package/types/platforms/node_with_fetch.d.ts +1 -1
- package/types/platforms/nodejs.d.ts +1 -1
- package/types/version.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { UpstashError } from "../error.js";
|
|
2
2
|
import { parseResponse } from "../util.js";
|
|
3
|
-
const defaultSerializer = (c) =>
|
|
3
|
+
const defaultSerializer = (c) => {
|
|
4
|
+
switch (typeof c) {
|
|
5
|
+
case "string":
|
|
6
|
+
case "number":
|
|
7
|
+
case "boolean":
|
|
8
|
+
return c;
|
|
9
|
+
default:
|
|
10
|
+
return JSON.stringify(c);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
4
13
|
/**
|
|
5
14
|
* Command offers default (de)serialization and the exec method to all commands.
|
|
6
15
|
*
|
|
@@ -37,7 +46,7 @@ export class Command {
|
|
|
37
46
|
opts.automaticDeserialization
|
|
38
47
|
? opts?.deserialize ?? parseResponse
|
|
39
48
|
: (x) => x;
|
|
40
|
-
this.command = command.map(this.serialize);
|
|
49
|
+
this.command = command.map((c) => this.serialize(c));
|
|
41
50
|
}
|
|
42
51
|
/**
|
|
43
52
|
* Execute the command using a client.
|
|
@@ -50,7 +59,7 @@ export class Command {
|
|
|
50
59
|
throw new UpstashError(error);
|
|
51
60
|
}
|
|
52
61
|
if (typeof result === "undefined") {
|
|
53
|
-
throw new Error(
|
|
62
|
+
throw new Error("Request did not return a result");
|
|
54
63
|
}
|
|
55
64
|
return this.deserialize(result);
|
|
56
65
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
4
|
+
*/
|
|
5
|
+
export class JsonArrTrimCommand extends Command {
|
|
6
|
+
constructor(cmd, opts) {
|
|
7
|
+
const path = cmd[1] ?? "$";
|
|
8
|
+
const start = cmd[2] ?? 0;
|
|
9
|
+
const stop = cmd[3] ?? 0;
|
|
10
|
+
super(["JSON.ARRTRIM", cmd[0], path, start, stop], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Command } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/json.get
|
|
4
|
+
*/
|
|
5
|
+
export class JsonGetCommand extends Command {
|
|
6
|
+
constructor(cmd, opts) {
|
|
7
|
+
const command = ["JSON.GET"];
|
|
8
|
+
if (typeof cmd[1] === "string") {
|
|
9
|
+
// @ts-ignore - we know this is a string
|
|
10
|
+
command.push(...cmd);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
command.push(cmd[0]);
|
|
14
|
+
if (cmd[1]) {
|
|
15
|
+
if (cmd[1].indent) {
|
|
16
|
+
command.push("INDENT", cmd[1].indent);
|
|
17
|
+
}
|
|
18
|
+
if (cmd[1].newline) {
|
|
19
|
+
command.push("NEWLINE", cmd[1].newline);
|
|
20
|
+
}
|
|
21
|
+
if (cmd[1].space) {
|
|
22
|
+
command.push("SPACE", cmd[1].space);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// @ts-ignore - we know this is a string
|
|
26
|
+
command.push(...cmd.slice(2));
|
|
27
|
+
}
|
|
28
|
+
super(command, opts);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/json.set
|
|
4
|
+
*/
|
|
5
|
+
export class JsonSetCommand extends Command {
|
|
6
|
+
constructor(cmd, opts) {
|
|
7
|
+
const command = ["JSON.SET", cmd[0], cmd[1], cmd[2]];
|
|
8
|
+
if (cmd[3]) {
|
|
9
|
+
if (cmd[3].nx) {
|
|
10
|
+
command.push("NX");
|
|
11
|
+
}
|
|
12
|
+
else if (cmd[3].xx) {
|
|
13
|
+
command.push("XX");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
super(command, opts);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/esm/pkg/commands/mod.js
CHANGED
|
@@ -23,7 +23,6 @@ export * from "./getset.js";
|
|
|
23
23
|
export * from "./hdel.js";
|
|
24
24
|
export * from "./hexists.js";
|
|
25
25
|
export * from "./hget.js";
|
|
26
|
-
export * from "./smismember.js";
|
|
27
26
|
export * from "./hgetall.js";
|
|
28
27
|
export * from "./hincrby.js";
|
|
29
28
|
export * from "./hincrbyfloat.js";
|
|
@@ -40,6 +39,27 @@ export * from "./hvals.js";
|
|
|
40
39
|
export * from "./incr.js";
|
|
41
40
|
export * from "./incrby.js";
|
|
42
41
|
export * from "./incrbyfloat.js";
|
|
42
|
+
export * from "./json_arrappend.js";
|
|
43
|
+
export * from "./json_arrindex.js";
|
|
44
|
+
export * from "./json_arrinsert.js";
|
|
45
|
+
export * from "./json_arrlen.js";
|
|
46
|
+
export * from "./json_arrpop.js";
|
|
47
|
+
export * from "./json_arrtrim.js";
|
|
48
|
+
export * from "./json_clear.js";
|
|
49
|
+
export * from "./json_del.js";
|
|
50
|
+
export * from "./json_forget.js";
|
|
51
|
+
export * from "./json_get.js";
|
|
52
|
+
export * from "./json_mget.js";
|
|
53
|
+
export * from "./json_numincrby.js";
|
|
54
|
+
export * from "./json_nummultby.js";
|
|
55
|
+
export * from "./json_objkeys.js";
|
|
56
|
+
export * from "./json_objlen.js";
|
|
57
|
+
export * from "./json_resp.js";
|
|
58
|
+
export * from "./json_set.js";
|
|
59
|
+
export * from "./json_strappend.js";
|
|
60
|
+
export * from "./json_strlen.js";
|
|
61
|
+
export * from "./json_toggle.js";
|
|
62
|
+
export * from "./json_type.js";
|
|
43
63
|
export * from "./keys.js";
|
|
44
64
|
export * from "./lindex.js";
|
|
45
65
|
export * from "./linsert.js";
|
|
@@ -86,6 +106,7 @@ export * from "./sinter.js";
|
|
|
86
106
|
export * from "./sinterstore.js";
|
|
87
107
|
export * from "./sismember.js";
|
|
88
108
|
export * from "./smembers.js";
|
|
109
|
+
export * from "./smismember.js";
|
|
89
110
|
export * from "./smove.js";
|
|
90
111
|
export * from "./spop.js";
|
|
91
112
|
export * from "./srandmember.js";
|
package/esm/pkg/http.js
CHANGED
|
@@ -35,15 +35,6 @@ export class HttpClient {
|
|
|
35
35
|
"Content-Type": "application/json",
|
|
36
36
|
...config.headers,
|
|
37
37
|
};
|
|
38
|
-
if (config.telemetry?.runtime) {
|
|
39
|
-
this.headers["Upstash-Telemetry-Runtime"] = config.telemetry.runtime;
|
|
40
|
-
}
|
|
41
|
-
if (config.telemetry?.platform) {
|
|
42
|
-
this.headers["Upstash-Telemetry-Platform"] = config.telemetry.platform;
|
|
43
|
-
}
|
|
44
|
-
if (config.telemetry?.sdk) {
|
|
45
|
-
this.headers["Upstash-Telemetry-Sdk"] = config.telemetry.sdk;
|
|
46
|
-
}
|
|
47
38
|
if (this.options.responseEncoding === "base64") {
|
|
48
39
|
this.headers["Upstash-Encoding"] = "base64";
|
|
49
40
|
}
|
package/esm/pkg/pipeline.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, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, 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, 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";
|
|
@@ -1196,4 +1196,96 @@ export class Pipeline {
|
|
|
1196
1196
|
this.commands.push(command);
|
|
1197
1197
|
return this;
|
|
1198
1198
|
}
|
|
1199
|
+
/**
|
|
1200
|
+
* @see https://redis.io/commands/?group=json
|
|
1201
|
+
*/
|
|
1202
|
+
get json() {
|
|
1203
|
+
// For some reason we needed to define the types manually, otherwise Deno wouldn't build it
|
|
1204
|
+
return {
|
|
1205
|
+
/**
|
|
1206
|
+
* @see https://redis.io/commands/json.arrappend
|
|
1207
|
+
*/
|
|
1208
|
+
arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
|
|
1209
|
+
/**
|
|
1210
|
+
* @see https://redis.io/commands/json.arrindex
|
|
1211
|
+
*/
|
|
1212
|
+
arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
|
|
1213
|
+
/**
|
|
1214
|
+
* @see https://redis.io/commands/json.arrinsert
|
|
1215
|
+
*/
|
|
1216
|
+
arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
|
|
1217
|
+
/**
|
|
1218
|
+
* @see https://redis.io/commands/json.arrlen
|
|
1219
|
+
*/
|
|
1220
|
+
arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
|
|
1221
|
+
/**
|
|
1222
|
+
* @see https://redis.io/commands/json.arrpop
|
|
1223
|
+
*/
|
|
1224
|
+
arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
|
|
1225
|
+
/**
|
|
1226
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
1227
|
+
*/
|
|
1228
|
+
arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
|
|
1229
|
+
/**
|
|
1230
|
+
* @see https://redis.io/commands/json.clear
|
|
1231
|
+
*/
|
|
1232
|
+
clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
|
|
1233
|
+
/**
|
|
1234
|
+
* @see https://redis.io/commands/json.del
|
|
1235
|
+
*/
|
|
1236
|
+
del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
|
|
1237
|
+
/**
|
|
1238
|
+
* @see https://redis.io/commands/json.forget
|
|
1239
|
+
*/
|
|
1240
|
+
forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
|
|
1241
|
+
/**
|
|
1242
|
+
* @see https://redis.io/commands/json.get
|
|
1243
|
+
*/
|
|
1244
|
+
get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
|
|
1245
|
+
/**
|
|
1246
|
+
* @see https://redis.io/commands/json.mget
|
|
1247
|
+
*/
|
|
1248
|
+
mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
|
|
1249
|
+
/**
|
|
1250
|
+
* @see https://redis.io/commands/json.numincrby
|
|
1251
|
+
*/
|
|
1252
|
+
numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
|
|
1253
|
+
/**
|
|
1254
|
+
* @see https://redis.io/commands/json.nummultby
|
|
1255
|
+
*/
|
|
1256
|
+
nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
|
|
1257
|
+
/**
|
|
1258
|
+
* @see https://redis.io/commands/json.objkeys
|
|
1259
|
+
*/
|
|
1260
|
+
objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
|
|
1261
|
+
/**
|
|
1262
|
+
* @see https://redis.io/commands/json.objlen
|
|
1263
|
+
*/
|
|
1264
|
+
objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
|
|
1265
|
+
/**
|
|
1266
|
+
* @see https://redis.io/commands/json.resp
|
|
1267
|
+
*/
|
|
1268
|
+
resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
|
|
1269
|
+
/**
|
|
1270
|
+
* @see https://redis.io/commands/json.set
|
|
1271
|
+
*/
|
|
1272
|
+
set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
|
|
1273
|
+
/**
|
|
1274
|
+
* @see https://redis.io/commands/json.strappend
|
|
1275
|
+
*/
|
|
1276
|
+
strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
|
|
1277
|
+
/**
|
|
1278
|
+
* @see https://redis.io/commands/json.strlen
|
|
1279
|
+
*/
|
|
1280
|
+
strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
|
|
1281
|
+
/**
|
|
1282
|
+
* @see https://redis.io/commands/json.toggle
|
|
1283
|
+
*/
|
|
1284
|
+
toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
|
|
1285
|
+
/**
|
|
1286
|
+
* @see https://redis.io/commands/json.type
|
|
1287
|
+
*/
|
|
1288
|
+
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions)),
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1199
1291
|
}
|
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, 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, 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";
|
|
@@ -31,6 +31,12 @@ export class Redis {
|
|
|
31
31
|
writable: true,
|
|
32
32
|
value: void 0
|
|
33
33
|
});
|
|
34
|
+
Object.defineProperty(this, "enableTelemetry", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: void 0
|
|
39
|
+
});
|
|
34
40
|
/**
|
|
35
41
|
* Wrap a new middleware around the HTTP client.
|
|
36
42
|
*/
|
|
@@ -51,6 +57,9 @@ export class Redis {
|
|
|
51
57
|
configurable: true,
|
|
52
58
|
writable: true,
|
|
53
59
|
value: (telemetry) => {
|
|
60
|
+
if (!this.enableTelemetry) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
54
63
|
try {
|
|
55
64
|
// @ts-ignore - The `Requester` interface does not know about this method but it will be there
|
|
56
65
|
// as long as the user uses the standard HttpClient
|
|
@@ -1183,6 +1192,95 @@ export class Redis {
|
|
|
1183
1192
|
});
|
|
1184
1193
|
this.client = client;
|
|
1185
1194
|
this.opts = opts;
|
|
1195
|
+
this.enableTelemetry = opts?.enableTelemetry ?? true;
|
|
1196
|
+
}
|
|
1197
|
+
get json() {
|
|
1198
|
+
return {
|
|
1199
|
+
/**
|
|
1200
|
+
* @see https://redis.io/commands/json.arrappend
|
|
1201
|
+
*/
|
|
1202
|
+
arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
|
|
1203
|
+
/**
|
|
1204
|
+
* @see https://redis.io/commands/json.arrindex
|
|
1205
|
+
*/
|
|
1206
|
+
arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
|
|
1207
|
+
/**
|
|
1208
|
+
* @see https://redis.io/commands/json.arrinsert
|
|
1209
|
+
*/
|
|
1210
|
+
arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
|
|
1211
|
+
/**
|
|
1212
|
+
* @see https://redis.io/commands/json.arrlen
|
|
1213
|
+
*/
|
|
1214
|
+
arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
|
|
1215
|
+
/**
|
|
1216
|
+
* @see https://redis.io/commands/json.arrpop
|
|
1217
|
+
*/
|
|
1218
|
+
arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
|
|
1219
|
+
/**
|
|
1220
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
1221
|
+
*/
|
|
1222
|
+
arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
|
|
1223
|
+
/**
|
|
1224
|
+
* @see https://redis.io/commands/json.clear
|
|
1225
|
+
*/
|
|
1226
|
+
clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
|
|
1227
|
+
/**
|
|
1228
|
+
* @see https://redis.io/commands/json.del
|
|
1229
|
+
*/
|
|
1230
|
+
del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
|
|
1231
|
+
/**
|
|
1232
|
+
* @see https://redis.io/commands/json.forget
|
|
1233
|
+
*/
|
|
1234
|
+
forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
|
|
1235
|
+
/**
|
|
1236
|
+
* @see https://redis.io/commands/json.get
|
|
1237
|
+
*/
|
|
1238
|
+
get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
|
|
1239
|
+
/**
|
|
1240
|
+
* @see https://redis.io/commands/json.mget
|
|
1241
|
+
*/
|
|
1242
|
+
mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
|
|
1243
|
+
/**
|
|
1244
|
+
* @see https://redis.io/commands/json.numincrby
|
|
1245
|
+
*/
|
|
1246
|
+
numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
|
|
1247
|
+
/**
|
|
1248
|
+
* @see https://redis.io/commands/json.nummultby
|
|
1249
|
+
*/
|
|
1250
|
+
nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
|
|
1251
|
+
/**
|
|
1252
|
+
* @see https://redis.io/commands/json.objkeys
|
|
1253
|
+
*/
|
|
1254
|
+
objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
|
|
1255
|
+
/**
|
|
1256
|
+
* @see https://redis.io/commands/json.objlen
|
|
1257
|
+
*/
|
|
1258
|
+
objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
|
|
1259
|
+
/**
|
|
1260
|
+
* @see https://redis.io/commands/json.resp
|
|
1261
|
+
*/
|
|
1262
|
+
resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
|
|
1263
|
+
/**
|
|
1264
|
+
* @see https://redis.io/commands/json.set
|
|
1265
|
+
*/
|
|
1266
|
+
set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
|
|
1267
|
+
/**
|
|
1268
|
+
* @see https://redis.io/commands/json.strappend
|
|
1269
|
+
*/
|
|
1270
|
+
strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
|
|
1271
|
+
/**
|
|
1272
|
+
* @see https://redis.io/commands/json.strlen
|
|
1273
|
+
*/
|
|
1274
|
+
strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
|
|
1275
|
+
/**
|
|
1276
|
+
* @see https://redis.io/commands/json.toggle
|
|
1277
|
+
*/
|
|
1278
|
+
toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
|
|
1279
|
+
/**
|
|
1280
|
+
* @see https://redis.io/commands/json.type
|
|
1281
|
+
*/
|
|
1282
|
+
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client),
|
|
1283
|
+
};
|
|
1186
1284
|
}
|
|
1187
1285
|
createScript(script) {
|
|
1188
1286
|
return new Script(this, script);
|
|
@@ -27,21 +27,21 @@ export class Redis extends core.Redis {
|
|
|
27
27
|
/\r|\n/.test(config.token)) {
|
|
28
28
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
29
29
|
}
|
|
30
|
-
const telemetry = {};
|
|
31
|
-
if (!env?.UPSTASH_DISABLE_TELEMETRY) {
|
|
32
|
-
telemetry.platform = "cloudflare";
|
|
33
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
34
|
-
}
|
|
35
30
|
const client = new HttpClient({
|
|
36
31
|
retry: config.retry,
|
|
37
32
|
baseUrl: config.url,
|
|
38
33
|
headers: { authorization: `Bearer ${config.token}` },
|
|
39
34
|
responseEncoding: config.responseEncoding,
|
|
40
|
-
telemetry,
|
|
41
35
|
});
|
|
42
36
|
super(client, {
|
|
37
|
+
enableTelemetry: !env?.UPSTASH_DISABLE_TELEMETRY,
|
|
43
38
|
automaticDeserialization: config.automaticDeserialization,
|
|
44
39
|
});
|
|
40
|
+
// This is only added of the user has not disabled telemetry
|
|
41
|
+
this.addTelemetry({
|
|
42
|
+
platform: "cloudflare",
|
|
43
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
44
|
+
});
|
|
45
45
|
}
|
|
46
46
|
/*
|
|
47
47
|
* Create a new Upstash Redis instance from environment variables on cloudflare.
|
package/esm/platforms/fastly.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as core from "../pkg/redis.js";
|
|
2
2
|
import { HttpClient } from "../pkg/http.js";
|
|
3
|
+
import { VERSION } from "../version.js";
|
|
3
4
|
/**
|
|
4
5
|
* Serverless redis client for upstash.
|
|
5
6
|
*/
|
|
@@ -37,5 +38,9 @@ export class Redis extends core.Redis {
|
|
|
37
38
|
super(client, {
|
|
38
39
|
automaticDeserialization: config.automaticDeserialization,
|
|
39
40
|
});
|
|
41
|
+
this.addTelemetry({
|
|
42
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
43
|
+
platform: "fastly",
|
|
44
|
+
});
|
|
40
45
|
}
|
|
41
46
|
}
|