@upstash/redis 0.0.0-ci.bc3aba1f-20221124 → 0.0.0-ci.bf6288e9-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 (131) 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/hgetall.js +9 -1
  5. package/esm/pkg/commands/json_arrappend.js +9 -0
  6. package/esm/pkg/commands/json_arrindex.js +9 -0
  7. package/esm/pkg/commands/json_arrinsert.js +9 -0
  8. package/esm/pkg/commands/json_arrlen.js +9 -0
  9. package/esm/pkg/commands/json_arrpop.js +9 -0
  10. package/esm/pkg/commands/json_arrtrim.js +12 -0
  11. package/esm/pkg/commands/json_clear.js +9 -0
  12. package/esm/pkg/commands/json_del.js +9 -0
  13. package/esm/pkg/commands/json_forget.js +9 -0
  14. package/esm/pkg/commands/json_get.js +30 -0
  15. package/esm/pkg/commands/json_mget.js +9 -0
  16. package/esm/pkg/commands/json_numincrby.js +9 -0
  17. package/esm/pkg/commands/json_nummultby.js +9 -0
  18. package/esm/pkg/commands/json_objkeys.js +9 -0
  19. package/esm/pkg/commands/json_objlen.js +9 -0
  20. package/esm/pkg/commands/json_resp.js +9 -0
  21. package/esm/pkg/commands/json_set.js +18 -0
  22. package/esm/pkg/commands/json_strappend.js +9 -0
  23. package/esm/pkg/commands/json_strlen.js +9 -0
  24. package/esm/pkg/commands/json_toggle.js +9 -0
  25. package/esm/pkg/commands/json_type.js +9 -0
  26. package/esm/pkg/commands/lmove.js +9 -0
  27. package/esm/pkg/commands/mod.js +27 -0
  28. package/esm/pkg/commands/set.js +1 -1
  29. package/esm/pkg/commands/smismember.js +9 -0
  30. package/esm/pkg/commands/xadd.js +26 -0
  31. package/esm/pkg/commands/xrange.js +36 -0
  32. package/esm/pkg/commands/zdiffstore.js +9 -0
  33. package/esm/pkg/commands/zunion.js +30 -0
  34. package/esm/pkg/http.js +42 -25
  35. package/esm/pkg/pipeline.js +143 -7
  36. package/esm/pkg/redis.js +177 -3
  37. package/esm/platforms/cloudflare.js +6 -6
  38. package/esm/platforms/fastly.js +5 -0
  39. package/esm/platforms/node_with_fetch.js +23 -11
  40. package/esm/platforms/nodejs.js +21 -11
  41. package/esm/version.js +1 -1
  42. package/package.json +53 -20
  43. package/script/pkg/commands/command.js +12 -3
  44. package/script/pkg/commands/geo_add.js +31 -0
  45. package/script/pkg/commands/hgetall.js +9 -1
  46. package/script/pkg/commands/json_arrappend.js +13 -0
  47. package/script/pkg/commands/json_arrindex.js +13 -0
  48. package/script/pkg/commands/json_arrinsert.js +13 -0
  49. package/script/pkg/commands/json_arrlen.js +13 -0
  50. package/script/pkg/commands/json_arrpop.js +13 -0
  51. package/script/pkg/commands/json_arrtrim.js +16 -0
  52. package/script/pkg/commands/json_clear.js +13 -0
  53. package/script/pkg/commands/json_del.js +13 -0
  54. package/script/pkg/commands/json_forget.js +13 -0
  55. package/script/pkg/commands/json_get.js +34 -0
  56. package/script/pkg/commands/json_mget.js +13 -0
  57. package/script/pkg/commands/json_numincrby.js +13 -0
  58. package/script/pkg/commands/json_nummultby.js +13 -0
  59. package/script/pkg/commands/json_objkeys.js +13 -0
  60. package/script/pkg/commands/json_objlen.js +13 -0
  61. package/script/pkg/commands/json_resp.js +13 -0
  62. package/script/pkg/commands/json_set.js +22 -0
  63. package/script/pkg/commands/json_strappend.js +13 -0
  64. package/script/pkg/commands/json_strlen.js +13 -0
  65. package/script/pkg/commands/json_toggle.js +13 -0
  66. package/script/pkg/commands/json_type.js +13 -0
  67. package/script/pkg/commands/lmove.js +13 -0
  68. package/script/pkg/commands/mod.js +27 -0
  69. package/script/pkg/commands/set.js +1 -1
  70. package/script/pkg/commands/smismember.js +13 -0
  71. package/script/pkg/commands/xadd.js +30 -0
  72. package/script/pkg/commands/xrange.js +40 -0
  73. package/script/pkg/commands/zdiffstore.js +13 -0
  74. package/script/pkg/commands/zunion.js +34 -0
  75. package/script/pkg/http.js +42 -25
  76. package/script/pkg/pipeline.js +142 -6
  77. package/script/pkg/redis.js +176 -2
  78. package/script/platforms/cloudflare.js +6 -6
  79. package/script/platforms/fastly.js +5 -0
  80. package/script/platforms/node_with_fetch.js +23 -11
  81. package/script/platforms/nodejs.js +21 -11
  82. package/script/version.js +1 -1
  83. package/types/pkg/commands/command.d.ts +5 -5
  84. package/types/pkg/commands/geo_add.d.ts +25 -0
  85. package/types/pkg/commands/hdel.d.ts +1 -1
  86. package/types/pkg/commands/json_arrappend.d.ts +7 -0
  87. package/types/pkg/commands/json_arrindex.d.ts +13 -0
  88. package/types/pkg/commands/json_arrinsert.d.ts +7 -0
  89. package/types/pkg/commands/json_arrlen.d.ts +7 -0
  90. package/types/pkg/commands/json_arrpop.d.ts +7 -0
  91. package/types/pkg/commands/json_arrtrim.d.ts +7 -0
  92. package/types/pkg/commands/json_clear.d.ts +7 -0
  93. package/types/pkg/commands/json_del.d.ts +7 -0
  94. package/types/pkg/commands/json_forget.d.ts +7 -0
  95. package/types/pkg/commands/json_get.d.ts +15 -0
  96. package/types/pkg/commands/json_mget.d.ts +7 -0
  97. package/types/pkg/commands/json_numincrby.d.ts +7 -0
  98. package/types/pkg/commands/json_nummultby.d.ts +7 -0
  99. package/types/pkg/commands/json_objkeys.d.ts +7 -0
  100. package/types/pkg/commands/json_objlen.d.ts +7 -0
  101. package/types/pkg/commands/json_resp.d.ts +7 -0
  102. package/types/pkg/commands/json_set.d.ts +18 -0
  103. package/types/pkg/commands/json_strappend.d.ts +7 -0
  104. package/types/pkg/commands/json_strlen.d.ts +7 -0
  105. package/types/pkg/commands/json_toggle.d.ts +7 -0
  106. package/types/pkg/commands/json_type.d.ts +7 -0
  107. package/types/pkg/commands/lmove.d.ts +12 -0
  108. package/types/pkg/commands/mod.d.ts +27 -0
  109. package/types/pkg/commands/scan.d.ts +1 -1
  110. package/types/pkg/commands/script_flush.d.ts +1 -1
  111. package/types/pkg/commands/set.d.ts +3 -3
  112. package/types/pkg/commands/smembers.d.ts +2 -2
  113. package/types/pkg/commands/smismember.d.ts +7 -0
  114. package/types/pkg/commands/type.d.ts +1 -1
  115. package/types/pkg/commands/xadd.d.ts +31 -0
  116. package/types/pkg/commands/xrange.d.ts +9 -0
  117. package/types/pkg/commands/zadd.d.ts +3 -3
  118. package/types/pkg/commands/zdiffstore.d.ts +7 -0
  119. package/types/pkg/commands/zinterstore.d.ts +1 -1
  120. package/types/pkg/commands/zrange.d.ts +1 -1
  121. package/types/pkg/commands/zunion.d.ts +29 -0
  122. package/types/pkg/commands/zunionstore.d.ts +1 -1
  123. package/types/pkg/http.d.ts +16 -23
  124. package/types/pkg/pipeline.d.ts +247 -126
  125. package/types/pkg/redis.d.ts +149 -13
  126. package/types/pkg/types.d.ts +27 -1
  127. package/types/platforms/cloudflare.d.ts +2 -2
  128. package/types/platforms/fastly.d.ts +1 -1
  129. package/types/platforms/node_with_fetch.d.ts +1 -1
  130. package/types/platforms/nodejs.d.ts +1 -1
  131. package/types/version.d.ts +1 -1
@@ -31,6 +31,7 @@ __exportStar(require("./expire.js"), exports);
31
31
  __exportStar(require("./expireat.js"), exports);
32
32
  __exportStar(require("./flushall.js"), exports);
33
33
  __exportStar(require("./flushdb.js"), exports);
34
+ __exportStar(require("./geo_add.js"), exports);
34
35
  __exportStar(require("./get.js"), exports);
35
36
  __exportStar(require("./getbit.js"), exports);
36
37
  __exportStar(require("./getdel.js"), exports);
@@ -55,10 +56,32 @@ __exportStar(require("./hvals.js"), exports);
55
56
  __exportStar(require("./incr.js"), exports);
56
57
  __exportStar(require("./incrby.js"), exports);
57
58
  __exportStar(require("./incrbyfloat.js"), exports);
59
+ __exportStar(require("./json_arrappend.js"), exports);
60
+ __exportStar(require("./json_arrindex.js"), exports);
61
+ __exportStar(require("./json_arrinsert.js"), exports);
62
+ __exportStar(require("./json_arrlen.js"), exports);
63
+ __exportStar(require("./json_arrpop.js"), exports);
64
+ __exportStar(require("./json_arrtrim.js"), exports);
65
+ __exportStar(require("./json_clear.js"), exports);
66
+ __exportStar(require("./json_del.js"), exports);
67
+ __exportStar(require("./json_forget.js"), exports);
68
+ __exportStar(require("./json_get.js"), exports);
69
+ __exportStar(require("./json_mget.js"), exports);
70
+ __exportStar(require("./json_numincrby.js"), exports);
71
+ __exportStar(require("./json_nummultby.js"), exports);
72
+ __exportStar(require("./json_objkeys.js"), exports);
73
+ __exportStar(require("./json_objlen.js"), exports);
74
+ __exportStar(require("./json_resp.js"), exports);
75
+ __exportStar(require("./json_set.js"), exports);
76
+ __exportStar(require("./json_strappend.js"), exports);
77
+ __exportStar(require("./json_strlen.js"), exports);
78
+ __exportStar(require("./json_toggle.js"), exports);
79
+ __exportStar(require("./json_type.js"), exports);
58
80
  __exportStar(require("./keys.js"), exports);
59
81
  __exportStar(require("./lindex.js"), exports);
60
82
  __exportStar(require("./linsert.js"), exports);
61
83
  __exportStar(require("./llen.js"), exports);
84
+ __exportStar(require("./lmove.js"), exports);
62
85
  __exportStar(require("./lpop.js"), exports);
63
86
  __exportStar(require("./lpos.js"), exports);
64
87
  __exportStar(require("./lpush.js"), exports);
@@ -100,6 +123,7 @@ __exportStar(require("./sinter.js"), exports);
100
123
  __exportStar(require("./sinterstore.js"), exports);
101
124
  __exportStar(require("./sismember.js"), exports);
102
125
  __exportStar(require("./smembers.js"), exports);
126
+ __exportStar(require("./smismember.js"), exports);
103
127
  __exportStar(require("./smove.js"), exports);
104
128
  __exportStar(require("./spop.js"), exports);
105
129
  __exportStar(require("./srandmember.js"), exports);
@@ -130,4 +154,7 @@ __exportStar(require("./zremrangebyscore.js"), exports);
130
154
  __exportStar(require("./zrevrank.js"), exports);
131
155
  __exportStar(require("./zscan.js"), exports);
132
156
  __exportStar(require("./zscore.js"), exports);
157
+ __exportStar(require("./zunion.js"), exports);
133
158
  __exportStar(require("./zunionstore.js"), exports);
159
+ __exportStar(require("./xadd.js"), exports);
160
+ __exportStar(require("./xrange.js"), exports);
@@ -31,7 +31,7 @@ class SetCommand extends command_js_1.Command {
31
31
  command.push("pxat", opts.pxat);
32
32
  }
33
33
  else if ("keepTtl" in opts && opts.keepTtl) {
34
- command.push("keepTtl", opts.keepTtl);
34
+ command.push("keepTtl");
35
35
  }
36
36
  }
37
37
  super(command, cmdOpts);
@@ -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,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XAddCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/xadd
7
+ */
8
+ class XAddCommand extends command_js_1.Command {
9
+ constructor([key, id, entries, opts], commandOptions) {
10
+ const command = ["XADD", key];
11
+ if (opts) {
12
+ if (opts.nomkStream) {
13
+ command.push("NOMKSTREAM");
14
+ }
15
+ if (opts.trim) {
16
+ command.push(opts.trim.type, opts.trim.comparison, opts.trim.threshold);
17
+ if (typeof opts.trim.limit !== "undefined") {
18
+ command.push("LIMIT", opts.trim.limit);
19
+ }
20
+ }
21
+ }
22
+ command.push(id);
23
+ // entries
24
+ Object.entries(entries).forEach(([k, v]) => {
25
+ command.push(k, v);
26
+ });
27
+ super(command, commandOptions);
28
+ }
29
+ }
30
+ exports.XAddCommand = XAddCommand;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XRangeCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ function deserialize(result) {
6
+ const obj = {};
7
+ for (const e of result) {
8
+ while (e.length >= 2) {
9
+ const streamId = e.shift();
10
+ const entries = e.shift();
11
+ if (!(streamId in obj)) {
12
+ obj[streamId] = {};
13
+ }
14
+ while (entries.length >= 2) {
15
+ const field = entries.shift();
16
+ const value = entries.shift();
17
+ try {
18
+ obj[streamId][field] = JSON.parse(value);
19
+ }
20
+ catch {
21
+ obj[streamId][field] = value;
22
+ }
23
+ }
24
+ }
25
+ }
26
+ return obj;
27
+ }
28
+ class XRangeCommand extends command_js_1.Command {
29
+ constructor([key, start, end, count], opts) {
30
+ const command = ["XRANGE", key, start, end];
31
+ if (typeof count === "number") {
32
+ command.push("COUNT", count);
33
+ }
34
+ super(command, {
35
+ deserialize: (result) => deserialize(result),
36
+ ...opts,
37
+ });
38
+ }
39
+ }
40
+ exports.XRangeCommand = XRangeCommand;
@@ -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,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZUnionCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/zunion
7
+ */
8
+ class ZUnionCommand extends command_js_1.Command {
9
+ constructor([numKeys, keyOrKeys, opts], cmdOpts) {
10
+ const command = ["zunion", numKeys];
11
+ if (Array.isArray(keyOrKeys)) {
12
+ command.push(...keyOrKeys);
13
+ }
14
+ else {
15
+ command.push(keyOrKeys);
16
+ }
17
+ if (opts) {
18
+ if ("weights" in opts && opts.weights) {
19
+ command.push("weights", ...opts.weights);
20
+ }
21
+ else if ("weight" in opts && typeof opts.weight === "number") {
22
+ command.push("weights", opts.weight);
23
+ }
24
+ if ("aggregate" in opts) {
25
+ command.push("aggregate", opts.aggregate);
26
+ }
27
+ if (opts?.withScores) {
28
+ command.push("withscores");
29
+ }
30
+ }
31
+ super(command, cmdOpts);
32
+ }
33
+ }
34
+ exports.ZUnionCommand = ZUnionCommand;
@@ -31,22 +31,14 @@ class HttpClient {
31
31
  this.options = {
32
32
  backend: config.options?.backend,
33
33
  agent: config.agent,
34
- responseEncoding: config.responseEncoding ?? "base64", // default to base64
34
+ responseEncoding: config.responseEncoding ?? "base64",
35
+ cache: config.cache,
35
36
  };
36
37
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
37
38
  this.headers = {
38
39
  "Content-Type": "application/json",
39
40
  ...config.headers,
40
41
  };
41
- if (config.telemetry?.runtime) {
42
- this.headers["Upstash-Telemetry-Runtime"] = config.telemetry.runtime;
43
- }
44
- if (config.telemetry?.platform) {
45
- this.headers["Upstash-Telemetry-Platform"] = config.telemetry.platform;
46
- }
47
- if (config.telemetry?.sdk) {
48
- this.headers["Upstash-Telemetry-Sdk"] = config.telemetry.sdk;
49
- }
50
42
  if (this.options.responseEncoding === "base64") {
51
43
  this.headers["Upstash-Encoding"] = "base64";
52
44
  }
@@ -64,8 +56,26 @@ class HttpClient {
64
56
  };
65
57
  }
66
58
  }
59
+ mergeTelemetry(telemetry) {
60
+ function merge(obj, key, value) {
61
+ if (!value) {
62
+ return obj;
63
+ }
64
+ if (obj[key]) {
65
+ obj[key] = [obj[key], value].join(",");
66
+ }
67
+ else {
68
+ obj[key] = value;
69
+ }
70
+ return obj;
71
+ }
72
+ this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
73
+ this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
74
+ this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
75
+ }
67
76
  async request(req) {
68
77
  const requestOptions = {
78
+ cache: this.options.cache,
69
79
  method: "POST",
70
80
  headers: this.headers,
71
81
  body: JSON.stringify(req.body),
@@ -93,10 +103,17 @@ class HttpClient {
93
103
  }
94
104
  const body = (await res.json());
95
105
  if (!res.ok) {
96
- throw new error_js_1.UpstashError(body.error);
106
+ throw new error_js_1.UpstashError(`${body.error}, command was: ${JSON.stringify(req.body)}`);
97
107
  }
98
108
  if (this.options?.responseEncoding === "base64") {
99
- return Array.isArray(body) ? body.map(decode) : decode(body);
109
+ if (Array.isArray(body)) {
110
+ return body.map(({ result, error }) => ({
111
+ result: decode(result),
112
+ error,
113
+ }));
114
+ }
115
+ const result = decode(body.result);
116
+ return { result, error: body.error };
100
117
  }
101
118
  return body;
102
119
  }
@@ -119,28 +136,28 @@ function base64decode(b64) {
119
136
  catch {
120
137
  dec = b64;
121
138
  }
122
- try {
123
- return decodeURIComponent(dec);
124
- }
125
- catch {
126
- return dec;
127
- }
139
+ return dec;
140
+ // try {
141
+ // return decodeURIComponent(dec);
142
+ // } catch {
143
+ // return dec;
144
+ // }
128
145
  }
129
146
  function decode(raw) {
130
147
  let result = undefined;
131
- switch (typeof raw.result) {
148
+ switch (typeof raw) {
132
149
  case "undefined":
133
150
  return raw;
134
151
  case "number": {
135
- result = raw.result;
152
+ result = raw;
136
153
  break;
137
154
  }
138
155
  case "object": {
139
- if (Array.isArray(raw.result)) {
140
- result = raw.result.map((v) => typeof v === "string"
156
+ if (Array.isArray(raw)) {
157
+ result = raw.map((v) => typeof v === "string"
141
158
  ? base64decode(v)
142
159
  : Array.isArray(v)
143
- ? v.map(base64decode)
160
+ ? v.map(decode)
144
161
  : v);
145
162
  }
146
163
  else {
@@ -151,11 +168,11 @@ function decode(raw) {
151
168
  break;
152
169
  }
153
170
  case "string": {
154
- result = raw.result === "OK" ? "OK" : base64decode(raw.result);
171
+ result = raw === "OK" ? "OK" : base64decode(raw);
155
172
  break;
156
173
  }
157
174
  default:
158
175
  break;
159
176
  }
160
- return { result, error: raw.error };
177
+ return result;
161
178
  }
@@ -5,6 +5,7 @@ const mod_js_1 = require("./commands/mod.js");
5
5
  const error_js_1 = require("./error.js");
6
6
  const zmscore_js_1 = require("./commands/zmscore.js");
7
7
  const hrandfield_js_1 = require("./commands/hrandfield.js");
8
+ const zdiffstore_js_1 = require("./commands/zdiffstore.js");
8
9
  /**
9
10
  * Upstash REST API supports command pipelining to send multiple commands in
10
11
  * batch, instead of sending each command one by one and waiting for a response.
@@ -33,7 +34,7 @@ const hrandfield_js_1 = require("./commands/hrandfield.js");
33
34
  * const res = await p.set("key","value").get("key").exec()
34
35
  * ```
35
36
  *
36
- * It's not possible to infer correct types with a dynamic pipeline, so you can
37
+ * Return types are inferred if all commands are chained, but you can still
37
38
  * override the response type manually:
38
39
  * ```ts
39
40
  * redis.pipeline()
@@ -74,9 +75,11 @@ class Pipeline {
74
75
  *
75
76
  * Returns an array with the results of all pipelined commands.
76
77
  *
77
- * You can define a return type manually to make working in typescript easier
78
+ * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
78
79
  * ```ts
79
- * redis.pipeline().get("key").exec<[{ greeting: string }]>()
80
+ * const p = redis.pipeline()
81
+ * p.get("key")
82
+ * const result = p.exec<[{ greeting: string }]>()
80
83
  * ```
81
84
  */
82
85
  Object.defineProperty(this, "exec", {
@@ -136,6 +139,15 @@ class Pipeline {
136
139
  writable: true,
137
140
  value: (...args) => this.chain(new mod_js_1.BitPosCommand(args, this.commandOptions))
138
141
  });
142
+ /**
143
+ * @see https://redis.io/commands/zdiffstore
144
+ */
145
+ Object.defineProperty(this, "zdiffstore", {
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true,
149
+ value: (...args) => this.chain(new zdiffstore_js_1.ZDiffStoreCommand(args, this.commandOptions))
150
+ });
139
151
  /**
140
152
  * @see https://redis.io/commands/dbsize
141
153
  */
@@ -496,6 +508,15 @@ class Pipeline {
496
508
  writable: true,
497
509
  value: (...args) => this.chain(new mod_js_1.LLenCommand(args, this.commandOptions))
498
510
  });
511
+ /**
512
+ * @see https://redis.io/commands/lmove
513
+ */
514
+ Object.defineProperty(this, "lmove", {
515
+ enumerable: true,
516
+ configurable: true,
517
+ writable: true,
518
+ value: (...args) => this.chain(new mod_js_1.LMoveCommand(args, this.commandOptions))
519
+ });
499
520
  /**
500
521
  * @see https://redis.io/commands/lpop
501
522
  */
@@ -865,6 +886,15 @@ class Pipeline {
865
886
  writable: true,
866
887
  value: (...args) => this.chain(new mod_js_1.SMembersCommand(args, this.commandOptions))
867
888
  });
889
+ /**
890
+ * @see https://redis.io/commands/smismember
891
+ */
892
+ Object.defineProperty(this, "smismember", {
893
+ enumerable: true,
894
+ configurable: true,
895
+ writable: true,
896
+ value: (key, members) => this.chain(new mod_js_1.SMIsMemberCommand([key, members], this.commandOptions))
897
+ });
868
898
  /**
869
899
  * @see https://redis.io/commands/smove
870
900
  */
@@ -1158,18 +1188,124 @@ class Pipeline {
1158
1188
  writable: true,
1159
1189
  value: (...args) => this.chain(new mod_js_1.ZUnionStoreCommand(args, this.commandOptions))
1160
1190
  });
1191
+ /**
1192
+ * @see https://redis.io/commands/zunion
1193
+ */
1194
+ Object.defineProperty(this, "zunion", {
1195
+ enumerable: true,
1196
+ configurable: true,
1197
+ writable: true,
1198
+ value: (...args) => this.chain(new mod_js_1.ZUnionCommand(args, this.commandOptions))
1199
+ });
1161
1200
  this.client = opts.client;
1162
- this.commands = [];
1201
+ this.commands = []; // the TCommands generic in the class definition is only used for carrying through chained command types and should never be explicitly set when instantiating the class
1163
1202
  this.commandOptions = opts.commandOptions;
1164
1203
  this.multiExec = opts.multiExec ?? false;
1165
1204
  }
1166
1205
  /**
1167
- * Pushes a command into the pipelien and returns a chainable instance of the
1206
+ * Returns the length of pipeline before the execution
1207
+ */
1208
+ length() {
1209
+ return this.commands.length;
1210
+ }
1211
+ /**
1212
+ * Pushes a command into the pipeline and returns a chainable instance of the
1168
1213
  * pipeline
1169
1214
  */
1170
1215
  chain(command) {
1171
1216
  this.commands.push(command);
1172
- return this;
1217
+ return this; // TS thinks we're returning Pipeline<[]> here, because we're not creating a new instance of the class, hence the cast
1218
+ }
1219
+ /**
1220
+ * @see https://redis.io/commands/?group=json
1221
+ */
1222
+ get json() {
1223
+ return {
1224
+ /**
1225
+ * @see https://redis.io/commands/json.arrappend
1226
+ */
1227
+ arrappend: (...args) => this.chain(new mod_js_1.JsonArrAppendCommand(args, this.commandOptions)),
1228
+ /**
1229
+ * @see https://redis.io/commands/json.arrindex
1230
+ */
1231
+ arrindex: (...args) => this.chain(new mod_js_1.JsonArrIndexCommand(args, this.commandOptions)),
1232
+ /**
1233
+ * @see https://redis.io/commands/json.arrinsert
1234
+ */
1235
+ arrinsert: (...args) => this.chain(new mod_js_1.JsonArrInsertCommand(args, this.commandOptions)),
1236
+ /**
1237
+ * @see https://redis.io/commands/json.arrlen
1238
+ */
1239
+ arrlen: (...args) => this.chain(new mod_js_1.JsonArrLenCommand(args, this.commandOptions)),
1240
+ /**
1241
+ * @see https://redis.io/commands/json.arrpop
1242
+ */
1243
+ arrpop: (...args) => this.chain(new mod_js_1.JsonArrPopCommand(args, this.commandOptions)),
1244
+ /**
1245
+ * @see https://redis.io/commands/json.arrtrim
1246
+ */
1247
+ arrtrim: (...args) => this.chain(new mod_js_1.JsonArrTrimCommand(args, this.commandOptions)),
1248
+ /**
1249
+ * @see https://redis.io/commands/json.clear
1250
+ */
1251
+ clear: (...args) => this.chain(new mod_js_1.JsonClearCommand(args, this.commandOptions)),
1252
+ /**
1253
+ * @see https://redis.io/commands/json.del
1254
+ */
1255
+ del: (...args) => this.chain(new mod_js_1.JsonDelCommand(args, this.commandOptions)),
1256
+ /**
1257
+ * @see https://redis.io/commands/json.forget
1258
+ */
1259
+ forget: (...args) => this.chain(new mod_js_1.JsonForgetCommand(args, this.commandOptions)),
1260
+ /**
1261
+ * @see https://redis.io/commands/json.get
1262
+ */
1263
+ get: (...args) => this.chain(new mod_js_1.JsonGetCommand(args, this.commandOptions)),
1264
+ /**
1265
+ * @see https://redis.io/commands/json.mget
1266
+ */
1267
+ mget: (...args) => this.chain(new mod_js_1.JsonMGetCommand(args, this.commandOptions)),
1268
+ /**
1269
+ * @see https://redis.io/commands/json.numincrby
1270
+ */
1271
+ numincrby: (...args) => this.chain(new mod_js_1.JsonNumIncrByCommand(args, this.commandOptions)),
1272
+ /**
1273
+ * @see https://redis.io/commands/json.nummultby
1274
+ */
1275
+ nummultby: (...args) => this.chain(new mod_js_1.JsonNumMultByCommand(args, this.commandOptions)),
1276
+ /**
1277
+ * @see https://redis.io/commands/json.objkeys
1278
+ */
1279
+ objkeys: (...args) => this.chain(new mod_js_1.JsonObjKeysCommand(args, this.commandOptions)),
1280
+ /**
1281
+ * @see https://redis.io/commands/json.objlen
1282
+ */
1283
+ objlen: (...args) => this.chain(new mod_js_1.JsonObjLenCommand(args, this.commandOptions)),
1284
+ /**
1285
+ * @see https://redis.io/commands/json.resp
1286
+ */
1287
+ resp: (...args) => this.chain(new mod_js_1.JsonRespCommand(args, this.commandOptions)),
1288
+ /**
1289
+ * @see https://redis.io/commands/json.set
1290
+ */
1291
+ set: (...args) => this.chain(new mod_js_1.JsonSetCommand(args, this.commandOptions)),
1292
+ /**
1293
+ * @see https://redis.io/commands/json.strappend
1294
+ */
1295
+ strappend: (...args) => this.chain(new mod_js_1.JsonStrAppendCommand(args, this.commandOptions)),
1296
+ /**
1297
+ * @see https://redis.io/commands/json.strlen
1298
+ */
1299
+ strlen: (...args) => this.chain(new mod_js_1.JsonStrLenCommand(args, this.commandOptions)),
1300
+ /**
1301
+ * @see https://redis.io/commands/json.toggle
1302
+ */
1303
+ toggle: (...args) => this.chain(new mod_js_1.JsonToggleCommand(args, this.commandOptions)),
1304
+ /**
1305
+ * @see https://redis.io/commands/json.type
1306
+ */
1307
+ type: (...args) => this.chain(new mod_js_1.JsonTypeCommand(args, this.commandOptions)),
1308
+ };
1173
1309
  }
1174
1310
  }
1175
1311
  exports.Pipeline = Pipeline;