@upstash/redis 0.0.0-ci.bc3aba1f-20221124 → 0.0.0-ci.bc4f4560-20231018

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.
Files changed (134) hide show
  1. package/README.md +8 -1
  2. package/esm/pkg/commands/command.js +12 -3
  3. package/esm/pkg/commands/geo_add.js +27 -0
  4. package/esm/pkg/commands/geo_hash.js +14 -0
  5. package/esm/pkg/commands/hgetall.js +9 -1
  6. package/esm/pkg/commands/json_arrappend.js +9 -0
  7. package/esm/pkg/commands/json_arrindex.js +9 -0
  8. package/esm/pkg/commands/json_arrinsert.js +9 -0
  9. package/esm/pkg/commands/json_arrlen.js +9 -0
  10. package/esm/pkg/commands/json_arrpop.js +9 -0
  11. package/esm/pkg/commands/json_arrtrim.js +12 -0
  12. package/esm/pkg/commands/json_clear.js +9 -0
  13. package/esm/pkg/commands/json_del.js +9 -0
  14. package/esm/pkg/commands/json_forget.js +9 -0
  15. package/esm/pkg/commands/json_get.js +30 -0
  16. package/esm/pkg/commands/json_mget.js +9 -0
  17. package/esm/pkg/commands/json_numincrby.js +9 -0
  18. package/esm/pkg/commands/json_nummultby.js +9 -0
  19. package/esm/pkg/commands/json_objkeys.js +9 -0
  20. package/esm/pkg/commands/json_objlen.js +9 -0
  21. package/esm/pkg/commands/json_resp.js +9 -0
  22. package/esm/pkg/commands/json_set.js +18 -0
  23. package/esm/pkg/commands/json_strappend.js +9 -0
  24. package/esm/pkg/commands/json_strlen.js +9 -0
  25. package/esm/pkg/commands/json_toggle.js +9 -0
  26. package/esm/pkg/commands/json_type.js +9 -0
  27. package/esm/pkg/commands/lmove.js +9 -0
  28. package/esm/pkg/commands/mod.js +28 -0
  29. package/esm/pkg/commands/set.js +1 -1
  30. package/esm/pkg/commands/smismember.js +9 -0
  31. package/esm/pkg/commands/xadd.js +26 -0
  32. package/esm/pkg/commands/xrange.js +36 -0
  33. package/esm/pkg/commands/zdiffstore.js +9 -0
  34. package/esm/pkg/commands/zunion.js +30 -0
  35. package/esm/pkg/http.js +42 -25
  36. package/esm/pkg/pipeline.js +147 -7
  37. package/esm/pkg/redis.js +181 -1
  38. package/esm/platforms/cloudflare.js +6 -6
  39. package/esm/platforms/fastly.js +5 -0
  40. package/esm/platforms/node_with_fetch.js +23 -11
  41. package/esm/platforms/nodejs.js +21 -11
  42. package/esm/version.js +1 -1
  43. package/package.json +53 -20
  44. package/script/pkg/commands/command.js +12 -3
  45. package/script/pkg/commands/geo_add.js +31 -0
  46. package/script/pkg/commands/geo_hash.js +18 -0
  47. package/script/pkg/commands/hgetall.js +9 -1
  48. package/script/pkg/commands/json_arrappend.js +13 -0
  49. package/script/pkg/commands/json_arrindex.js +13 -0
  50. package/script/pkg/commands/json_arrinsert.js +13 -0
  51. package/script/pkg/commands/json_arrlen.js +13 -0
  52. package/script/pkg/commands/json_arrpop.js +13 -0
  53. package/script/pkg/commands/json_arrtrim.js +16 -0
  54. package/script/pkg/commands/json_clear.js +13 -0
  55. package/script/pkg/commands/json_del.js +13 -0
  56. package/script/pkg/commands/json_forget.js +13 -0
  57. package/script/pkg/commands/json_get.js +34 -0
  58. package/script/pkg/commands/json_mget.js +13 -0
  59. package/script/pkg/commands/json_numincrby.js +13 -0
  60. package/script/pkg/commands/json_nummultby.js +13 -0
  61. package/script/pkg/commands/json_objkeys.js +13 -0
  62. package/script/pkg/commands/json_objlen.js +13 -0
  63. package/script/pkg/commands/json_resp.js +13 -0
  64. package/script/pkg/commands/json_set.js +22 -0
  65. package/script/pkg/commands/json_strappend.js +13 -0
  66. package/script/pkg/commands/json_strlen.js +13 -0
  67. package/script/pkg/commands/json_toggle.js +13 -0
  68. package/script/pkg/commands/json_type.js +13 -0
  69. package/script/pkg/commands/lmove.js +13 -0
  70. package/script/pkg/commands/mod.js +28 -0
  71. package/script/pkg/commands/set.js +1 -1
  72. package/script/pkg/commands/smismember.js +13 -0
  73. package/script/pkg/commands/xadd.js +30 -0
  74. package/script/pkg/commands/xrange.js +40 -0
  75. package/script/pkg/commands/zdiffstore.js +13 -0
  76. package/script/pkg/commands/zunion.js +34 -0
  77. package/script/pkg/http.js +42 -25
  78. package/script/pkg/pipeline.js +146 -6
  79. package/script/pkg/redis.js +180 -0
  80. package/script/platforms/cloudflare.js +6 -6
  81. package/script/platforms/fastly.js +5 -0
  82. package/script/platforms/node_with_fetch.js +23 -11
  83. package/script/platforms/nodejs.js +21 -11
  84. package/script/version.js +1 -1
  85. package/types/pkg/commands/command.d.ts +5 -5
  86. package/types/pkg/commands/geo_add.d.ts +25 -0
  87. package/types/pkg/commands/geo_hash.d.ts +7 -0
  88. package/types/pkg/commands/hdel.d.ts +1 -1
  89. package/types/pkg/commands/json_arrappend.d.ts +7 -0
  90. package/types/pkg/commands/json_arrindex.d.ts +13 -0
  91. package/types/pkg/commands/json_arrinsert.d.ts +7 -0
  92. package/types/pkg/commands/json_arrlen.d.ts +7 -0
  93. package/types/pkg/commands/json_arrpop.d.ts +7 -0
  94. package/types/pkg/commands/json_arrtrim.d.ts +7 -0
  95. package/types/pkg/commands/json_clear.d.ts +7 -0
  96. package/types/pkg/commands/json_del.d.ts +7 -0
  97. package/types/pkg/commands/json_forget.d.ts +7 -0
  98. package/types/pkg/commands/json_get.d.ts +15 -0
  99. package/types/pkg/commands/json_mget.d.ts +7 -0
  100. package/types/pkg/commands/json_numincrby.d.ts +7 -0
  101. package/types/pkg/commands/json_nummultby.d.ts +7 -0
  102. package/types/pkg/commands/json_objkeys.d.ts +7 -0
  103. package/types/pkg/commands/json_objlen.d.ts +7 -0
  104. package/types/pkg/commands/json_resp.d.ts +7 -0
  105. package/types/pkg/commands/json_set.d.ts +18 -0
  106. package/types/pkg/commands/json_strappend.d.ts +7 -0
  107. package/types/pkg/commands/json_strlen.d.ts +7 -0
  108. package/types/pkg/commands/json_toggle.d.ts +7 -0
  109. package/types/pkg/commands/json_type.d.ts +7 -0
  110. package/types/pkg/commands/lmove.d.ts +12 -0
  111. package/types/pkg/commands/mod.d.ts +28 -0
  112. package/types/pkg/commands/scan.d.ts +1 -1
  113. package/types/pkg/commands/script_flush.d.ts +1 -1
  114. package/types/pkg/commands/set.d.ts +3 -3
  115. package/types/pkg/commands/smembers.d.ts +2 -2
  116. package/types/pkg/commands/smismember.d.ts +7 -0
  117. package/types/pkg/commands/type.d.ts +1 -1
  118. package/types/pkg/commands/xadd.d.ts +31 -0
  119. package/types/pkg/commands/xrange.d.ts +9 -0
  120. package/types/pkg/commands/zadd.d.ts +3 -3
  121. package/types/pkg/commands/zdiffstore.d.ts +7 -0
  122. package/types/pkg/commands/zinterstore.d.ts +1 -1
  123. package/types/pkg/commands/zrange.d.ts +1 -1
  124. package/types/pkg/commands/zunion.d.ts +29 -0
  125. package/types/pkg/commands/zunionstore.d.ts +1 -1
  126. package/types/pkg/http.d.ts +16 -23
  127. package/types/pkg/pipeline.d.ts +251 -126
  128. package/types/pkg/redis.d.ts +154 -13
  129. package/types/pkg/types.d.ts +27 -1
  130. package/types/platforms/cloudflare.d.ts +2 -2
  131. package/types/platforms/fastly.d.ts +1 -1
  132. package/types/platforms/node_with_fetch.d.ts +1 -1
  133. package/types/platforms/nodejs.d.ts +1 -1
  134. package/types/version.d.ts +1 -1
@@ -3,6 +3,19 @@ import * as core from "../pkg/redis.js";
3
3
  import { HttpClient, } from "../pkg/http.js";
4
4
  import { VERSION } from "../version.js";
5
5
  import "isomorphic-fetch";
6
+ // @ts-ignore Deno can't compile
7
+ // import https from "https";
8
+ // @ts-ignore Deno can't compile
9
+ // import http from "http";
10
+ // import "isomorphic-fetch";
11
+ /**
12
+ * Workaround for nodejs 14, where atob is not included in the standardlib
13
+ */
14
+ if (typeof atob === "undefined") {
15
+ global.atob = function (b64) {
16
+ return Buffer.from(b64, "base64").toString("utf-8");
17
+ };
18
+ }
6
19
  /**
7
20
  * Serverless redis client for upstash.
8
21
  */
@@ -22,26 +35,25 @@ export class Redis extends core.Redis {
22
35
  /\r|\n/.test(configOrRequester.token)) {
23
36
  console.warn("The redis token contains whitespace or newline, which can cause errors!");
24
37
  }
25
- const telemetry = {};
26
- if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
27
- telemetry.runtime = `node@${process.version}`;
28
- telemetry.platform = process.env.VERCEL
29
- ? "vercel"
30
- : process.env.AWS_REGION
31
- ? "aws"
32
- : "unknown";
33
- telemetry.sdk = `@upstash/redis@${VERSION}`;
34
- }
35
38
  const client = new HttpClient({
36
39
  baseUrl: configOrRequester.url,
37
40
  retry: configOrRequester.retry,
38
41
  headers: { authorization: `Bearer ${configOrRequester.token}` },
39
42
  // agent: configOrRequester.agent,
40
43
  responseEncoding: configOrRequester.responseEncoding,
41
- telemetry,
42
44
  });
43
45
  super(client, {
44
46
  automaticDeserialization: configOrRequester.automaticDeserialization,
47
+ enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
48
+ });
49
+ this.addTelemetry({
50
+ runtime: `node@${process.version}`,
51
+ platform: process.env.VERCEL
52
+ ? "vercel"
53
+ : process.env.AWS_REGION
54
+ ? "aws"
55
+ : "unknown",
56
+ sdk: `@upstash/redis@${VERSION}`,
45
57
  });
46
58
  }
47
59
  /**
@@ -2,6 +2,14 @@
2
2
  import * as core from "../pkg/redis.js";
3
3
  import { HttpClient, } from "../pkg/http.js";
4
4
  import { VERSION } from "../version.js";
5
+ /**
6
+ * Workaround for nodejs 14, where atob is not included in the standardlib
7
+ */
8
+ if (typeof atob === "undefined") {
9
+ global.atob = function (b64) {
10
+ return Buffer.from(b64, "base64").toString("utf-8");
11
+ };
12
+ }
5
13
  /**
6
14
  * Serverless redis client for upstash.
7
15
  */
@@ -21,26 +29,28 @@ export class Redis extends core.Redis {
21
29
  /\r|\n/.test(configOrRequester.token)) {
22
30
  console.warn("The redis token contains whitespace or newline, which can cause errors!");
23
31
  }
24
- const telemetry = {};
25
- if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
26
- telemetry.runtime = `node@${process.version}`;
27
- telemetry.platform = process.env.VERCEL
28
- ? "vercel"
29
- : process.env.AWS_REGION
30
- ? "aws"
31
- : "unknown";
32
- telemetry.sdk = `@upstash/redis@${VERSION}`;
33
- }
34
32
  const client = new HttpClient({
35
33
  baseUrl: configOrRequester.url,
36
34
  retry: configOrRequester.retry,
37
35
  headers: { authorization: `Bearer ${configOrRequester.token}` },
38
36
  agent: configOrRequester.agent,
39
37
  responseEncoding: configOrRequester.responseEncoding,
40
- telemetry,
38
+ cache: configOrRequester.cache || "no-store",
41
39
  });
42
40
  super(client, {
43
41
  automaticDeserialization: configOrRequester.automaticDeserialization,
42
+ enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
43
+ });
44
+ this.addTelemetry({
45
+ runtime: typeof EdgeRuntime === "string"
46
+ ? "edge-light"
47
+ : `node@${process.version}`,
48
+ platform: process.env.VERCEL
49
+ ? "vercel"
50
+ : process.env.AWS_REGION
51
+ ? "aws"
52
+ : "unknown",
53
+ sdk: `@upstash/redis@${VERSION}`,
44
54
  });
45
55
  }
46
56
  /**
package/esm/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "v0.0.0-ci.bc3aba1f-20221124";
1
+ export const VERSION = "v0.0.0-ci.bc4f4560-20231018";
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": "v0.0.0-ci.bc3aba1f-20221124",
6
+ "version": "v0.0.0-ci.bc4f4560-20231018",
7
7
  "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
8
8
  "repository": {
9
9
  "type": "git",
@@ -27,37 +27,70 @@
27
27
  },
28
28
  "typesVersions": {
29
29
  "*": {
30
- "nodejs": "./types/platforms/nodejs.d.ts",
31
- "cloudflare": "./types/platforms/cloudflare.d.ts",
32
- "fastly": "./types/platforms/fastly.d.ts",
33
- "with-fetch": "./types/platforms/node_with_fetch.d.ts"
30
+ "nodejs": [
31
+ "./types/platforms/nodejs.d.ts"
32
+ ],
33
+ "cloudflare": [
34
+ "./types/platforms/cloudflare.d.ts"
35
+ ],
36
+ "fastly": [
37
+ "./types/platforms/fastly.d.ts"
38
+ ],
39
+ "with-fetch": [
40
+ "./types/platforms/node_with_fetch.d.ts"
41
+ ]
34
42
  }
35
43
  },
36
44
  "exports": {
37
45
  ".": {
38
- "import": "./esm/platforms/nodejs.js",
39
- "require": "./script/platforms/nodejs.js",
40
- "types": "./types/platforms/nodejs.d.ts"
46
+ "import": {
47
+ "types": "./types/platforms/nodejs.d.ts",
48
+ "default": "./esm/platforms/nodejs.js"
49
+ },
50
+ "require": {
51
+ "types": "./types/platforms/nodejs.d.ts",
52
+ "default": "./script/platforms/nodejs.js"
53
+ }
41
54
  },
42
55
  "./nodejs": {
43
- "import": "./esm/platforms/nodejs.js",
44
- "require": "./script/platforms/nodejs.js",
45
- "types": "./types/platforms/nodejs.d.ts"
56
+ "import": {
57
+ "types": "./types/platforms/nodejs.d.ts",
58
+ "default": "./esm/platforms/nodejs.js"
59
+ },
60
+ "require": {
61
+ "types": "./types/platforms/nodejs.d.ts",
62
+ "default": "./script/platforms/nodejs.js"
63
+ }
46
64
  },
47
65
  "./cloudflare": {
48
- "import": "./esm/platforms/cloudflare.js",
49
- "require": "./script/platforms/cloudflare.js",
50
- "types": "./types/platforms/cloudflare.d.ts"
66
+ "import": {
67
+ "types": "./types/platforms/cloudflare.d.ts",
68
+ "default": "./esm/platforms/cloudflare.js"
69
+ },
70
+ "require": {
71
+ "types": "./types/platforms/cloudflare.d.ts",
72
+ "default": "./script/platforms/cloudflare.js"
73
+ }
51
74
  },
52
75
  "./fastly": {
53
- "import": "./esm/platforms/fastly.js",
54
- "require": "./script/platforms/fastly.js",
55
- "types": "./types/platforms/fastly.d.ts"
76
+ "import": {
77
+ "types": "./types/platforms/fastly.d.ts",
78
+ "default": "./esm/platforms/fastly.js"
79
+ },
80
+ "require": {
81
+ "types": "./types/platforms/fastly.d.ts",
82
+ "default": "./script/platforms/fastly.js"
83
+ }
56
84
  },
57
85
  "./with-fetch": {
58
- "import": "./esm/platforms/node_with_fetch.js",
59
- "require": "./script/platforms/node_with_fetch.js",
60
- "types": "./types/platforms/node_with_fetch.d.ts"
86
+ "import": {
87
+ "types": "./types/platforms/node_with_fetch.d.ts",
88
+ "default": "./esm/platforms/node_with_fetch.js"
89
+ },
90
+ "require": {
91
+ "types": "./types/platforms/node_with_fetch.d.ts",
92
+ "default": "./script/platforms/node_with_fetch.js"
93
+ }
61
94
  }
62
95
  }
63
96
  }
@@ -3,7 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Command = void 0;
4
4
  const error_js_1 = require("../error.js");
5
5
  const util_js_1 = require("../util.js");
6
- const defaultSerializer = (c) => typeof c === "string" ? c : JSON.stringify(c);
6
+ const defaultSerializer = (c) => {
7
+ switch (typeof c) {
8
+ case "string":
9
+ case "number":
10
+ case "boolean":
11
+ return c;
12
+ default:
13
+ return JSON.stringify(c);
14
+ }
15
+ };
7
16
  /**
8
17
  * Command offers default (de)serialization and the exec method to all commands.
9
18
  *
@@ -40,7 +49,7 @@ class Command {
40
49
  opts.automaticDeserialization
41
50
  ? opts?.deserialize ?? util_js_1.parseResponse
42
51
  : (x) => x;
43
- this.command = command.map(this.serialize);
52
+ this.command = command.map((c) => this.serialize(c));
44
53
  }
45
54
  /**
46
55
  * Execute the command using a client.
@@ -53,7 +62,7 @@ class Command {
53
62
  throw new error_js_1.UpstashError(error);
54
63
  }
55
64
  if (typeof result === "undefined") {
56
- throw new Error(`Request did not return a result`);
65
+ throw new Error("Request did not return a result");
57
66
  }
58
67
  return this.deserialize(result);
59
68
  }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeoAddCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/geoadd
7
+ */
8
+ class GeoAddCommand extends command_js_1.Command {
9
+ constructor([key, arg1, ...arg2], opts) {
10
+ const command = ["geoadd", key];
11
+ if ("nx" in arg1 && arg1.nx) {
12
+ command.push("nx");
13
+ }
14
+ else if ("xx" in arg1 && arg1.xx) {
15
+ command.push("xx");
16
+ }
17
+ if ("ch" in arg1 && arg1.ch) {
18
+ command.push("ch");
19
+ }
20
+ if ("latitude" in arg1 && arg1.latitude) {
21
+ command.push(arg1.longitude, arg1.latitude, arg1.member);
22
+ }
23
+ command.push(...arg2.flatMap(({ latitude, longitude, member }) => [
24
+ longitude,
25
+ latitude,
26
+ member,
27
+ ]));
28
+ super(command, opts);
29
+ }
30
+ }
31
+ exports.GeoAddCommand = GeoAddCommand;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeoHashCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/geohash
7
+ */
8
+ class GeoHashCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ const [key] = cmd;
11
+ // Check if the second argument is an array of strings (members).
12
+ // If it is, use it directly; if not, it means the members were passed individually,
13
+ // so we slice the cmd from the second element onwards to get the members.
14
+ const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
15
+ super(["GEOHASH", key, ...members], opts);
16
+ }
17
+ }
18
+ exports.GeoHashCommand = GeoHashCommand;
@@ -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;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonArrAppendCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.arrappend
7
+ */
8
+ class JsonArrAppendCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.ARRAPPEND", ...cmd], opts);
11
+ }
12
+ }
13
+ exports.JsonArrAppendCommand = JsonArrAppendCommand;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonArrIndexCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.arrindex
7
+ */
8
+ class JsonArrIndexCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.ARRINDEX", ...cmd], opts);
11
+ }
12
+ }
13
+ exports.JsonArrIndexCommand = JsonArrIndexCommand;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonArrInsertCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.arrinsert
7
+ */
8
+ class JsonArrInsertCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.ARRINSERT", ...cmd], opts);
11
+ }
12
+ }
13
+ exports.JsonArrInsertCommand = JsonArrInsertCommand;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonArrLenCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.arrlen
7
+ */
8
+ class JsonArrLenCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.ARRLEN", cmd[0], cmd[1] ?? "$"], opts);
11
+ }
12
+ }
13
+ exports.JsonArrLenCommand = JsonArrLenCommand;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonArrPopCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.arrpop
7
+ */
8
+ class JsonArrPopCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.ARRPOP", ...cmd], opts);
11
+ }
12
+ }
13
+ exports.JsonArrPopCommand = JsonArrPopCommand;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonArrTrimCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.arrtrim
7
+ */
8
+ class JsonArrTrimCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ const path = cmd[1] ?? "$";
11
+ const start = cmd[2] ?? 0;
12
+ const stop = cmd[3] ?? 0;
13
+ super(["JSON.ARRTRIM", cmd[0], path, start, stop], opts);
14
+ }
15
+ }
16
+ exports.JsonArrTrimCommand = JsonArrTrimCommand;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonClearCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.clear
7
+ */
8
+ class JsonClearCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.CLEAR", ...cmd], opts);
11
+ }
12
+ }
13
+ exports.JsonClearCommand = JsonClearCommand;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonDelCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.del
7
+ */
8
+ class JsonDelCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.DEL", ...cmd], opts);
11
+ }
12
+ }
13
+ exports.JsonDelCommand = JsonDelCommand;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonForgetCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.forget
7
+ */
8
+ class JsonForgetCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.FORGET", ...cmd], opts);
11
+ }
12
+ }
13
+ exports.JsonForgetCommand = JsonForgetCommand;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonGetCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.get
7
+ */
8
+ class JsonGetCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ const command = ["JSON.GET"];
11
+ if (typeof cmd[1] === "string") {
12
+ // @ts-ignore - we know this is a string
13
+ command.push(...cmd);
14
+ }
15
+ else {
16
+ command.push(cmd[0]);
17
+ if (cmd[1]) {
18
+ if (cmd[1].indent) {
19
+ command.push("INDENT", cmd[1].indent);
20
+ }
21
+ if (cmd[1].newline) {
22
+ command.push("NEWLINE", cmd[1].newline);
23
+ }
24
+ if (cmd[1].space) {
25
+ command.push("SPACE", cmd[1].space);
26
+ }
27
+ }
28
+ // @ts-ignore - we know this is a string
29
+ command.push(...cmd.slice(2));
30
+ }
31
+ super(command, opts);
32
+ }
33
+ }
34
+ exports.JsonGetCommand = JsonGetCommand;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonMGetCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/json.mget
7
+ */
8
+ class JsonMGetCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["JSON.MGET", ...cmd[0], cmd[1]], opts);
11
+ }
12
+ }
13
+ exports.JsonMGetCommand = JsonMGetCommand;
@@ -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;