@upstash/redis 1.34.1 → 1.34.3-canary

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.
@@ -0,0 +1,3810 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // pkg/error.ts
8
+ var error_exports = {};
9
+ __export(error_exports, {
10
+ UpstashError: () => UpstashError,
11
+ UrlError: () => UrlError
12
+ });
13
+ var UpstashError = class extends Error {
14
+ constructor(message) {
15
+ super(message);
16
+ this.name = "UpstashError";
17
+ }
18
+ };
19
+ var UrlError = class extends Error {
20
+ constructor(url) {
21
+ super(
22
+ `Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "${url}". `
23
+ );
24
+ this.name = "UrlError";
25
+ }
26
+ };
27
+
28
+ // pkg/http.ts
29
+ var HttpClient = class {
30
+ baseUrl;
31
+ headers;
32
+ options;
33
+ readYourWrites;
34
+ upstashSyncToken = "";
35
+ hasCredentials;
36
+ retry;
37
+ constructor(config) {
38
+ this.options = {
39
+ backend: config.options?.backend,
40
+ agent: config.agent,
41
+ responseEncoding: config.responseEncoding ?? "base64",
42
+ // default to base64
43
+ cache: config.cache,
44
+ signal: config.signal,
45
+ keepAlive: config.keepAlive ?? true
46
+ };
47
+ this.upstashSyncToken = "";
48
+ this.readYourWrites = config.readYourWrites ?? true;
49
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
50
+ const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
51
+ if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
52
+ throw new UrlError(this.baseUrl);
53
+ }
54
+ this.headers = {
55
+ "Content-Type": "application/json",
56
+ ...config.headers
57
+ };
58
+ this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
59
+ if (this.options.responseEncoding === "base64") {
60
+ this.headers["Upstash-Encoding"] = "base64";
61
+ }
62
+ this.retry = typeof config.retry === "boolean" && !config.retry ? {
63
+ attempts: 1,
64
+ backoff: () => 0
65
+ } : {
66
+ attempts: config.retry?.retries ?? 5,
67
+ backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
68
+ };
69
+ }
70
+ mergeTelemetry(telemetry) {
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
+ }
75
+ async request(req) {
76
+ const requestOptions = {
77
+ //@ts-expect-error this should throw due to bun regression
78
+ cache: this.options.cache,
79
+ method: "POST",
80
+ headers: this.headers,
81
+ body: JSON.stringify(req.body),
82
+ keepalive: this.options.keepAlive,
83
+ agent: this.options.agent,
84
+ signal: this.options.signal,
85
+ /**
86
+ * Fastly specific
87
+ */
88
+ backend: this.options.backend
89
+ };
90
+ if (!this.hasCredentials) {
91
+ throw new Error(
92
+ "[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
93
+ );
94
+ }
95
+ if (this.readYourWrites) {
96
+ const newHeader = this.upstashSyncToken;
97
+ this.headers["upstash-sync-token"] = newHeader;
98
+ }
99
+ let res = null;
100
+ let error = null;
101
+ for (let i = 0; i <= this.retry.attempts; i++) {
102
+ try {
103
+ res = await fetch([this.baseUrl, ...req.path ?? []].join("/"), requestOptions);
104
+ break;
105
+ } catch (error_) {
106
+ if (this.options.signal?.aborted) {
107
+ const myBlob = new Blob([
108
+ JSON.stringify({ result: this.options.signal.reason ?? "Aborted" })
109
+ ]);
110
+ const myOptions = {
111
+ status: 200,
112
+ statusText: this.options.signal.reason ?? "Aborted"
113
+ };
114
+ res = new Response(myBlob, myOptions);
115
+ break;
116
+ }
117
+ error = error_;
118
+ await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
119
+ }
120
+ }
121
+ if (!res) {
122
+ throw error ?? new Error("Exhausted all retries");
123
+ }
124
+ const body = await res.json();
125
+ if (!res.ok) {
126
+ throw new UpstashError(`${body.error}, command was: ${JSON.stringify(req.body)}`);
127
+ }
128
+ if (this.readYourWrites) {
129
+ const headers = res.headers;
130
+ this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
131
+ }
132
+ if (this.readYourWrites) {
133
+ const headers = res.headers;
134
+ this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
135
+ }
136
+ if (this.options.responseEncoding === "base64") {
137
+ if (Array.isArray(body)) {
138
+ return body.map(({ result: result2, error: error2 }) => ({
139
+ result: decode(result2),
140
+ error: error2
141
+ }));
142
+ }
143
+ const result = decode(body.result);
144
+ return { result, error: body.error };
145
+ }
146
+ return body;
147
+ }
148
+ };
149
+ function base64decode(b64) {
150
+ let dec = "";
151
+ try {
152
+ const binString = atob(b64);
153
+ const size = binString.length;
154
+ const bytes = new Uint8Array(size);
155
+ for (let i = 0; i < size; i++) {
156
+ bytes[i] = binString.charCodeAt(i);
157
+ }
158
+ dec = new TextDecoder().decode(bytes);
159
+ } catch {
160
+ dec = b64;
161
+ }
162
+ return dec;
163
+ }
164
+ function decode(raw) {
165
+ let result = void 0;
166
+ switch (typeof raw) {
167
+ case "undefined": {
168
+ return raw;
169
+ }
170
+ case "number": {
171
+ result = raw;
172
+ break;
173
+ }
174
+ case "object": {
175
+ if (Array.isArray(raw)) {
176
+ result = raw.map(
177
+ (v) => typeof v === "string" ? base64decode(v) : Array.isArray(v) ? v.map((element) => decode(element)) : v
178
+ );
179
+ } else {
180
+ result = null;
181
+ }
182
+ break;
183
+ }
184
+ case "string": {
185
+ result = raw === "OK" ? "OK" : base64decode(raw);
186
+ break;
187
+ }
188
+ default: {
189
+ break;
190
+ }
191
+ }
192
+ return result;
193
+ }
194
+ function merge(obj, key, value) {
195
+ if (!value) {
196
+ return obj;
197
+ }
198
+ obj[key] = obj[key] ? [obj[key], value].join(",") : value;
199
+ return obj;
200
+ }
201
+
202
+ // pkg/util.ts
203
+ function parseRecursive(obj) {
204
+ const parsed = Array.isArray(obj) ? obj.map((o) => {
205
+ try {
206
+ return parseRecursive(o);
207
+ } catch {
208
+ return o;
209
+ }
210
+ }) : JSON.parse(obj);
211
+ if (typeof parsed === "number" && parsed.toString() !== obj) {
212
+ return obj;
213
+ }
214
+ return parsed;
215
+ }
216
+ function parseResponse(result) {
217
+ try {
218
+ return parseRecursive(result);
219
+ } catch {
220
+ return result;
221
+ }
222
+ }
223
+ function deserializeScanResponse(result) {
224
+ return [result[0], ...parseResponse(result.slice(1))];
225
+ }
226
+
227
+ // pkg/commands/command.ts
228
+ var defaultSerializer = (c) => {
229
+ switch (typeof c) {
230
+ case "string":
231
+ case "number":
232
+ case "boolean": {
233
+ return c;
234
+ }
235
+ default: {
236
+ return JSON.stringify(c);
237
+ }
238
+ }
239
+ };
240
+ var Command = class {
241
+ command;
242
+ serialize;
243
+ deserialize;
244
+ /**
245
+ * Create a new command instance.
246
+ *
247
+ * You can define a custom `deserialize` function. By default we try to deserialize as json.
248
+ */
249
+ constructor(command, opts) {
250
+ this.serialize = defaultSerializer;
251
+ this.deserialize = opts?.automaticDeserialization === void 0 || opts.automaticDeserialization ? opts?.deserialize ?? parseResponse : (x) => x;
252
+ this.command = command.map((c) => this.serialize(c));
253
+ if (opts?.latencyLogging) {
254
+ const originalExec = this.exec.bind(this);
255
+ this.exec = async (client) => {
256
+ const start = performance.now();
257
+ const result = await originalExec(client);
258
+ const end = performance.now();
259
+ const loggerResult = (end - start).toFixed(2);
260
+ console.log(
261
+ `Latency for \x1B[38;2;19;185;39m${this.command[0].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
262
+ );
263
+ return result;
264
+ };
265
+ }
266
+ }
267
+ /**
268
+ * Execute the command using a client.
269
+ */
270
+ async exec(client) {
271
+ const { result, error } = await client.request({
272
+ body: this.command,
273
+ upstashSyncToken: client.upstashSyncToken
274
+ });
275
+ if (error) {
276
+ throw new UpstashError(error);
277
+ }
278
+ if (result === void 0) {
279
+ throw new TypeError("Request did not return a result");
280
+ }
281
+ return this.deserialize(result);
282
+ }
283
+ };
284
+
285
+ // pkg/commands/hrandfield.ts
286
+ function deserialize(result) {
287
+ if (result.length === 0) {
288
+ return null;
289
+ }
290
+ const obj = {};
291
+ while (result.length >= 2) {
292
+ const key = result.shift();
293
+ const value = result.shift();
294
+ try {
295
+ obj[key] = JSON.parse(value);
296
+ } catch {
297
+ obj[key] = value;
298
+ }
299
+ }
300
+ return obj;
301
+ }
302
+ var HRandFieldCommand = class extends Command {
303
+ constructor(cmd, opts) {
304
+ const command = ["hrandfield", cmd[0]];
305
+ if (typeof cmd[1] === "number") {
306
+ command.push(cmd[1]);
307
+ }
308
+ if (cmd[2]) {
309
+ command.push("WITHVALUES");
310
+ }
311
+ super(command, {
312
+ // @ts-expect-error to silence compiler
313
+ deserialize: cmd[2] ? (result) => deserialize(result) : opts?.deserialize,
314
+ ...opts
315
+ });
316
+ }
317
+ };
318
+
319
+ // pkg/commands/append.ts
320
+ var AppendCommand = class extends Command {
321
+ constructor(cmd, opts) {
322
+ super(["append", ...cmd], opts);
323
+ }
324
+ };
325
+
326
+ // pkg/commands/bitcount.ts
327
+ var BitCountCommand = class extends Command {
328
+ constructor([key, start, end], opts) {
329
+ const command = ["bitcount", key];
330
+ if (typeof start === "number") {
331
+ command.push(start);
332
+ }
333
+ if (typeof end === "number") {
334
+ command.push(end);
335
+ }
336
+ super(command, opts);
337
+ }
338
+ };
339
+
340
+ // pkg/commands/bitfield.ts
341
+ var BitFieldCommand = class {
342
+ constructor(args, client, opts, execOperation = (command) => command.exec(this.client)) {
343
+ this.client = client;
344
+ this.opts = opts;
345
+ this.execOperation = execOperation;
346
+ this.command = ["bitfield", ...args];
347
+ }
348
+ command;
349
+ chain(...args) {
350
+ this.command.push(...args);
351
+ return this;
352
+ }
353
+ get(...args) {
354
+ return this.chain("get", ...args);
355
+ }
356
+ set(...args) {
357
+ return this.chain("set", ...args);
358
+ }
359
+ incrby(...args) {
360
+ return this.chain("incrby", ...args);
361
+ }
362
+ overflow(overflow) {
363
+ return this.chain("overflow", overflow);
364
+ }
365
+ exec() {
366
+ const command = new Command(this.command, this.opts);
367
+ return this.execOperation(command);
368
+ }
369
+ };
370
+
371
+ // pkg/commands/bitop.ts
372
+ var BitOpCommand = class extends Command {
373
+ constructor(cmd, opts) {
374
+ super(["bitop", ...cmd], opts);
375
+ }
376
+ };
377
+
378
+ // pkg/commands/bitpos.ts
379
+ var BitPosCommand = class extends Command {
380
+ constructor(cmd, opts) {
381
+ super(["bitpos", ...cmd], opts);
382
+ }
383
+ };
384
+
385
+ // pkg/commands/copy.ts
386
+ var CopyCommand = class extends Command {
387
+ constructor([key, destinationKey, opts], commandOptions) {
388
+ super(["COPY", key, destinationKey, ...opts?.replace ? ["REPLACE"] : []], {
389
+ ...commandOptions,
390
+ deserialize(result) {
391
+ if (result > 0) {
392
+ return "COPIED";
393
+ }
394
+ return "NOT_COPIED";
395
+ }
396
+ });
397
+ }
398
+ };
399
+
400
+ // pkg/commands/dbsize.ts
401
+ var DBSizeCommand = class extends Command {
402
+ constructor(opts) {
403
+ super(["dbsize"], opts);
404
+ }
405
+ };
406
+
407
+ // pkg/commands/decr.ts
408
+ var DecrCommand = class extends Command {
409
+ constructor(cmd, opts) {
410
+ super(["decr", ...cmd], opts);
411
+ }
412
+ };
413
+
414
+ // pkg/commands/decrby.ts
415
+ var DecrByCommand = class extends Command {
416
+ constructor(cmd, opts) {
417
+ super(["decrby", ...cmd], opts);
418
+ }
419
+ };
420
+
421
+ // pkg/commands/del.ts
422
+ var DelCommand = class extends Command {
423
+ constructor(cmd, opts) {
424
+ super(["del", ...cmd], opts);
425
+ }
426
+ };
427
+
428
+ // pkg/commands/echo.ts
429
+ var EchoCommand = class extends Command {
430
+ constructor(cmd, opts) {
431
+ super(["echo", ...cmd], opts);
432
+ }
433
+ };
434
+
435
+ // pkg/commands/eval.ts
436
+ var EvalCommand = class extends Command {
437
+ constructor([script, keys, args], opts) {
438
+ super(["eval", script, keys.length, ...keys, ...args ?? []], opts);
439
+ }
440
+ };
441
+
442
+ // pkg/commands/evalsha.ts
443
+ var EvalshaCommand = class extends Command {
444
+ constructor([sha, keys, args], opts) {
445
+ super(["evalsha", sha, keys.length, ...keys, ...args ?? []], opts);
446
+ }
447
+ };
448
+
449
+ // pkg/commands/exists.ts
450
+ var ExistsCommand = class extends Command {
451
+ constructor(cmd, opts) {
452
+ super(["exists", ...cmd], opts);
453
+ }
454
+ };
455
+
456
+ // pkg/commands/expire.ts
457
+ var ExpireCommand = class extends Command {
458
+ constructor(cmd, opts) {
459
+ super(["expire", ...cmd.filter(Boolean)], opts);
460
+ }
461
+ };
462
+
463
+ // pkg/commands/expireat.ts
464
+ var ExpireAtCommand = class extends Command {
465
+ constructor(cmd, opts) {
466
+ super(["expireat", ...cmd], opts);
467
+ }
468
+ };
469
+
470
+ // pkg/commands/flushall.ts
471
+ var FlushAllCommand = class extends Command {
472
+ constructor(args, opts) {
473
+ const command = ["flushall"];
474
+ if (args && args.length > 0 && args[0].async) {
475
+ command.push("async");
476
+ }
477
+ super(command, opts);
478
+ }
479
+ };
480
+
481
+ // pkg/commands/flushdb.ts
482
+ var FlushDBCommand = class extends Command {
483
+ constructor([opts], cmdOpts) {
484
+ const command = ["flushdb"];
485
+ if (opts?.async) {
486
+ command.push("async");
487
+ }
488
+ super(command, cmdOpts);
489
+ }
490
+ };
491
+
492
+ // pkg/commands/geo_add.ts
493
+ var GeoAddCommand = class extends Command {
494
+ constructor([key, arg1, ...arg2], opts) {
495
+ const command = ["geoadd", key];
496
+ if ("nx" in arg1 && arg1.nx) {
497
+ command.push("nx");
498
+ } else if ("xx" in arg1 && arg1.xx) {
499
+ command.push("xx");
500
+ }
501
+ if ("ch" in arg1 && arg1.ch) {
502
+ command.push("ch");
503
+ }
504
+ if ("latitude" in arg1 && arg1.latitude) {
505
+ command.push(arg1.longitude, arg1.latitude, arg1.member);
506
+ }
507
+ command.push(
508
+ ...arg2.flatMap(({ latitude, longitude, member }) => [longitude, latitude, member])
509
+ );
510
+ super(command, opts);
511
+ }
512
+ };
513
+
514
+ // pkg/commands/geo_dist.ts
515
+ var GeoDistCommand = class extends Command {
516
+ constructor([key, member1, member2, unit = "M"], opts) {
517
+ super(["GEODIST", key, member1, member2, unit], opts);
518
+ }
519
+ };
520
+
521
+ // pkg/commands/geo_hash.ts
522
+ var GeoHashCommand = class extends Command {
523
+ constructor(cmd, opts) {
524
+ const [key] = cmd;
525
+ const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
526
+ super(["GEOHASH", key, ...members], opts);
527
+ }
528
+ };
529
+
530
+ // pkg/commands/geo_pos.ts
531
+ var GeoPosCommand = class extends Command {
532
+ constructor(cmd, opts) {
533
+ const [key] = cmd;
534
+ const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
535
+ super(["GEOPOS", key, ...members], {
536
+ deserialize: (result) => transform(result),
537
+ ...opts
538
+ });
539
+ }
540
+ };
541
+ function transform(result) {
542
+ const final = [];
543
+ for (const pos of result) {
544
+ if (!pos?.[0] || !pos?.[1]) {
545
+ continue;
546
+ }
547
+ final.push({ lng: Number.parseFloat(pos[0]), lat: Number.parseFloat(pos[1]) });
548
+ }
549
+ return final;
550
+ }
551
+
552
+ // pkg/commands/geo_search.ts
553
+ var GeoSearchCommand = class extends Command {
554
+ constructor([key, centerPoint, shape, order, opts], commandOptions) {
555
+ const command = ["GEOSEARCH", key];
556
+ if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
557
+ command.push(centerPoint.type, centerPoint.member);
558
+ }
559
+ if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
560
+ command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
561
+ }
562
+ if (shape.type === "BYRADIUS" || shape.type === "byradius") {
563
+ command.push(shape.type, shape.radius, shape.radiusType);
564
+ }
565
+ if (shape.type === "BYBOX" || shape.type === "bybox") {
566
+ command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
567
+ }
568
+ command.push(order);
569
+ if (opts?.count) {
570
+ command.push("COUNT", opts.count.limit, ...opts.count.any ? ["ANY"] : []);
571
+ }
572
+ const transform2 = (result) => {
573
+ if (!opts?.withCoord && !opts?.withDist && !opts?.withHash) {
574
+ return result.map((member) => {
575
+ try {
576
+ return { member: JSON.parse(member) };
577
+ } catch {
578
+ return { member };
579
+ }
580
+ });
581
+ }
582
+ return result.map((members) => {
583
+ let counter = 1;
584
+ const obj = {};
585
+ try {
586
+ obj.member = JSON.parse(members[0]);
587
+ } catch {
588
+ obj.member = members[0];
589
+ }
590
+ if (opts.withDist) {
591
+ obj.dist = Number.parseFloat(members[counter++]);
592
+ }
593
+ if (opts.withHash) {
594
+ obj.hash = members[counter++].toString();
595
+ }
596
+ if (opts.withCoord) {
597
+ obj.coord = {
598
+ long: Number.parseFloat(members[counter][0]),
599
+ lat: Number.parseFloat(members[counter][1])
600
+ };
601
+ }
602
+ return obj;
603
+ });
604
+ };
605
+ super(
606
+ [
607
+ ...command,
608
+ ...opts?.withCoord ? ["WITHCOORD"] : [],
609
+ ...opts?.withDist ? ["WITHDIST"] : [],
610
+ ...opts?.withHash ? ["WITHHASH"] : []
611
+ ],
612
+ {
613
+ deserialize: transform2,
614
+ ...commandOptions
615
+ }
616
+ );
617
+ }
618
+ };
619
+
620
+ // pkg/commands/geo_search_store.ts
621
+ var GeoSearchStoreCommand = class extends Command {
622
+ constructor([destination, key, centerPoint, shape, order, opts], commandOptions) {
623
+ const command = ["GEOSEARCHSTORE", destination, key];
624
+ if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
625
+ command.push(centerPoint.type, centerPoint.member);
626
+ }
627
+ if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
628
+ command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
629
+ }
630
+ if (shape.type === "BYRADIUS" || shape.type === "byradius") {
631
+ command.push(shape.type, shape.radius, shape.radiusType);
632
+ }
633
+ if (shape.type === "BYBOX" || shape.type === "bybox") {
634
+ command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
635
+ }
636
+ command.push(order);
637
+ if (opts?.count) {
638
+ command.push("COUNT", opts.count.limit, ...opts.count.any ? ["ANY"] : []);
639
+ }
640
+ super([...command, ...opts?.storeDist ? ["STOREDIST"] : []], commandOptions);
641
+ }
642
+ };
643
+
644
+ // pkg/commands/get.ts
645
+ var GetCommand = class extends Command {
646
+ constructor(cmd, opts) {
647
+ super(["get", ...cmd], opts);
648
+ }
649
+ };
650
+
651
+ // pkg/commands/getbit.ts
652
+ var GetBitCommand = class extends Command {
653
+ constructor(cmd, opts) {
654
+ super(["getbit", ...cmd], opts);
655
+ }
656
+ };
657
+
658
+ // pkg/commands/getdel.ts
659
+ var GetDelCommand = class extends Command {
660
+ constructor(cmd, opts) {
661
+ super(["getdel", ...cmd], opts);
662
+ }
663
+ };
664
+
665
+ // pkg/commands/getrange.ts
666
+ var GetRangeCommand = class extends Command {
667
+ constructor(cmd, opts) {
668
+ super(["getrange", ...cmd], opts);
669
+ }
670
+ };
671
+
672
+ // pkg/commands/getset.ts
673
+ var GetSetCommand = class extends Command {
674
+ constructor(cmd, opts) {
675
+ super(["getset", ...cmd], opts);
676
+ }
677
+ };
678
+
679
+ // pkg/commands/hdel.ts
680
+ var HDelCommand = class extends Command {
681
+ constructor(cmd, opts) {
682
+ super(["hdel", ...cmd], opts);
683
+ }
684
+ };
685
+
686
+ // pkg/commands/hexists.ts
687
+ var HExistsCommand = class extends Command {
688
+ constructor(cmd, opts) {
689
+ super(["hexists", ...cmd], opts);
690
+ }
691
+ };
692
+
693
+ // pkg/commands/hget.ts
694
+ var HGetCommand = class extends Command {
695
+ constructor(cmd, opts) {
696
+ super(["hget", ...cmd], opts);
697
+ }
698
+ };
699
+
700
+ // pkg/commands/hgetall.ts
701
+ function deserialize2(result) {
702
+ if (result.length === 0) {
703
+ return null;
704
+ }
705
+ const obj = {};
706
+ while (result.length >= 2) {
707
+ const key = result.shift();
708
+ const value = result.shift();
709
+ try {
710
+ const valueIsNumberAndNotSafeInteger = !Number.isNaN(Number(value)) && !Number.isSafeInteger(Number(value));
711
+ obj[key] = valueIsNumberAndNotSafeInteger ? value : JSON.parse(value);
712
+ } catch {
713
+ obj[key] = value;
714
+ }
715
+ }
716
+ return obj;
717
+ }
718
+ var HGetAllCommand = class extends Command {
719
+ constructor(cmd, opts) {
720
+ super(["hgetall", ...cmd], {
721
+ deserialize: (result) => deserialize2(result),
722
+ ...opts
723
+ });
724
+ }
725
+ };
726
+
727
+ // pkg/commands/hincrby.ts
728
+ var HIncrByCommand = class extends Command {
729
+ constructor(cmd, opts) {
730
+ super(["hincrby", ...cmd], opts);
731
+ }
732
+ };
733
+
734
+ // pkg/commands/hincrbyfloat.ts
735
+ var HIncrByFloatCommand = class extends Command {
736
+ constructor(cmd, opts) {
737
+ super(["hincrbyfloat", ...cmd], opts);
738
+ }
739
+ };
740
+
741
+ // pkg/commands/hkeys.ts
742
+ var HKeysCommand = class extends Command {
743
+ constructor([key], opts) {
744
+ super(["hkeys", key], opts);
745
+ }
746
+ };
747
+
748
+ // pkg/commands/hlen.ts
749
+ var HLenCommand = class extends Command {
750
+ constructor(cmd, opts) {
751
+ super(["hlen", ...cmd], opts);
752
+ }
753
+ };
754
+
755
+ // pkg/commands/hmget.ts
756
+ function deserialize3(fields, result) {
757
+ if (result.every((field) => field === null)) {
758
+ return null;
759
+ }
760
+ const obj = {};
761
+ for (const [i, field] of fields.entries()) {
762
+ try {
763
+ obj[field] = JSON.parse(result[i]);
764
+ } catch {
765
+ obj[field] = result[i];
766
+ }
767
+ }
768
+ return obj;
769
+ }
770
+ var HMGetCommand = class extends Command {
771
+ constructor([key, ...fields], opts) {
772
+ super(["hmget", key, ...fields], {
773
+ deserialize: (result) => deserialize3(fields, result),
774
+ ...opts
775
+ });
776
+ }
777
+ };
778
+
779
+ // pkg/commands/hmset.ts
780
+ var HMSetCommand = class extends Command {
781
+ constructor([key, kv], opts) {
782
+ super(["hmset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
783
+ }
784
+ };
785
+
786
+ // pkg/commands/hscan.ts
787
+ var HScanCommand = class extends Command {
788
+ constructor([key, cursor, cmdOpts], opts) {
789
+ const command = ["hscan", key, cursor];
790
+ if (cmdOpts?.match) {
791
+ command.push("match", cmdOpts.match);
792
+ }
793
+ if (typeof cmdOpts?.count === "number") {
794
+ command.push("count", cmdOpts.count);
795
+ }
796
+ super(command, {
797
+ deserialize: deserializeScanResponse,
798
+ ...opts
799
+ });
800
+ }
801
+ };
802
+
803
+ // pkg/commands/hset.ts
804
+ var HSetCommand = class extends Command {
805
+ constructor([key, kv], opts) {
806
+ super(["hset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
807
+ }
808
+ };
809
+
810
+ // pkg/commands/hsetnx.ts
811
+ var HSetNXCommand = class extends Command {
812
+ constructor(cmd, opts) {
813
+ super(["hsetnx", ...cmd], opts);
814
+ }
815
+ };
816
+
817
+ // pkg/commands/hstrlen.ts
818
+ var HStrLenCommand = class extends Command {
819
+ constructor(cmd, opts) {
820
+ super(["hstrlen", ...cmd], opts);
821
+ }
822
+ };
823
+
824
+ // pkg/commands/hvals.ts
825
+ var HValsCommand = class extends Command {
826
+ constructor(cmd, opts) {
827
+ super(["hvals", ...cmd], opts);
828
+ }
829
+ };
830
+
831
+ // pkg/commands/incr.ts
832
+ var IncrCommand = class extends Command {
833
+ constructor(cmd, opts) {
834
+ super(["incr", ...cmd], opts);
835
+ }
836
+ };
837
+
838
+ // pkg/commands/incrby.ts
839
+ var IncrByCommand = class extends Command {
840
+ constructor(cmd, opts) {
841
+ super(["incrby", ...cmd], opts);
842
+ }
843
+ };
844
+
845
+ // pkg/commands/incrbyfloat.ts
846
+ var IncrByFloatCommand = class extends Command {
847
+ constructor(cmd, opts) {
848
+ super(["incrbyfloat", ...cmd], opts);
849
+ }
850
+ };
851
+
852
+ // pkg/commands/json_arrappend.ts
853
+ var JsonArrAppendCommand = class extends Command {
854
+ constructor(cmd, opts) {
855
+ super(["JSON.ARRAPPEND", ...cmd], opts);
856
+ }
857
+ };
858
+
859
+ // pkg/commands/json_arrindex.ts
860
+ var JsonArrIndexCommand = class extends Command {
861
+ constructor(cmd, opts) {
862
+ super(["JSON.ARRINDEX", ...cmd], opts);
863
+ }
864
+ };
865
+
866
+ // pkg/commands/json_arrinsert.ts
867
+ var JsonArrInsertCommand = class extends Command {
868
+ constructor(cmd, opts) {
869
+ super(["JSON.ARRINSERT", ...cmd], opts);
870
+ }
871
+ };
872
+
873
+ // pkg/commands/json_arrlen.ts
874
+ var JsonArrLenCommand = class extends Command {
875
+ constructor(cmd, opts) {
876
+ super(["JSON.ARRLEN", cmd[0], cmd[1] ?? "$"], opts);
877
+ }
878
+ };
879
+
880
+ // pkg/commands/json_arrpop.ts
881
+ var JsonArrPopCommand = class extends Command {
882
+ constructor(cmd, opts) {
883
+ super(["JSON.ARRPOP", ...cmd], opts);
884
+ }
885
+ };
886
+
887
+ // pkg/commands/json_arrtrim.ts
888
+ var JsonArrTrimCommand = class extends Command {
889
+ constructor(cmd, opts) {
890
+ const path = cmd[1] ?? "$";
891
+ const start = cmd[2] ?? 0;
892
+ const stop = cmd[3] ?? 0;
893
+ super(["JSON.ARRTRIM", cmd[0], path, start, stop], opts);
894
+ }
895
+ };
896
+
897
+ // pkg/commands/json_clear.ts
898
+ var JsonClearCommand = class extends Command {
899
+ constructor(cmd, opts) {
900
+ super(["JSON.CLEAR", ...cmd], opts);
901
+ }
902
+ };
903
+
904
+ // pkg/commands/json_del.ts
905
+ var JsonDelCommand = class extends Command {
906
+ constructor(cmd, opts) {
907
+ super(["JSON.DEL", ...cmd], opts);
908
+ }
909
+ };
910
+
911
+ // pkg/commands/json_forget.ts
912
+ var JsonForgetCommand = class extends Command {
913
+ constructor(cmd, opts) {
914
+ super(["JSON.FORGET", ...cmd], opts);
915
+ }
916
+ };
917
+
918
+ // pkg/commands/json_get.ts
919
+ var JsonGetCommand = class extends Command {
920
+ constructor(cmd, opts) {
921
+ const command = ["JSON.GET"];
922
+ if (typeof cmd[1] === "string") {
923
+ command.push(...cmd);
924
+ } else {
925
+ command.push(cmd[0]);
926
+ if (cmd[1]) {
927
+ if (cmd[1].indent) {
928
+ command.push("INDENT", cmd[1].indent);
929
+ }
930
+ if (cmd[1].newline) {
931
+ command.push("NEWLINE", cmd[1].newline);
932
+ }
933
+ if (cmd[1].space) {
934
+ command.push("SPACE", cmd[1].space);
935
+ }
936
+ }
937
+ command.push(...cmd.slice(2));
938
+ }
939
+ super(command, opts);
940
+ }
941
+ };
942
+
943
+ // pkg/commands/json_mget.ts
944
+ var JsonMGetCommand = class extends Command {
945
+ constructor(cmd, opts) {
946
+ super(["JSON.MGET", ...cmd[0], cmd[1]], opts);
947
+ }
948
+ };
949
+
950
+ // pkg/commands/json_mset.ts
951
+ var JsonMSetCommand = class extends Command {
952
+ constructor(cmd, opts) {
953
+ const command = ["JSON.MSET"];
954
+ for (const c of cmd) {
955
+ command.push(c.key, c.path, c.value);
956
+ }
957
+ super(command, opts);
958
+ }
959
+ };
960
+
961
+ // pkg/commands/json_numincrby.ts
962
+ var JsonNumIncrByCommand = class extends Command {
963
+ constructor(cmd, opts) {
964
+ super(["JSON.NUMINCRBY", ...cmd], opts);
965
+ }
966
+ };
967
+
968
+ // pkg/commands/json_nummultby.ts
969
+ var JsonNumMultByCommand = class extends Command {
970
+ constructor(cmd, opts) {
971
+ super(["JSON.NUMMULTBY", ...cmd], opts);
972
+ }
973
+ };
974
+
975
+ // pkg/commands/json_objkeys.ts
976
+ var JsonObjKeysCommand = class extends Command {
977
+ constructor(cmd, opts) {
978
+ super(["JSON.OBJKEYS", ...cmd], opts);
979
+ }
980
+ };
981
+
982
+ // pkg/commands/json_objlen.ts
983
+ var JsonObjLenCommand = class extends Command {
984
+ constructor(cmd, opts) {
985
+ super(["JSON.OBJLEN", ...cmd], opts);
986
+ }
987
+ };
988
+
989
+ // pkg/commands/json_resp.ts
990
+ var JsonRespCommand = class extends Command {
991
+ constructor(cmd, opts) {
992
+ super(["JSON.RESP", ...cmd], opts);
993
+ }
994
+ };
995
+
996
+ // pkg/commands/json_set.ts
997
+ var JsonSetCommand = class extends Command {
998
+ constructor(cmd, opts) {
999
+ const command = ["JSON.SET", cmd[0], cmd[1], cmd[2]];
1000
+ if (cmd[3]) {
1001
+ if (cmd[3].nx) {
1002
+ command.push("NX");
1003
+ } else if (cmd[3].xx) {
1004
+ command.push("XX");
1005
+ }
1006
+ }
1007
+ super(command, opts);
1008
+ }
1009
+ };
1010
+
1011
+ // pkg/commands/json_strappend.ts
1012
+ var JsonStrAppendCommand = class extends Command {
1013
+ constructor(cmd, opts) {
1014
+ super(["JSON.STRAPPEND", ...cmd], opts);
1015
+ }
1016
+ };
1017
+
1018
+ // pkg/commands/json_strlen.ts
1019
+ var JsonStrLenCommand = class extends Command {
1020
+ constructor(cmd, opts) {
1021
+ super(["JSON.STRLEN", ...cmd], opts);
1022
+ }
1023
+ };
1024
+
1025
+ // pkg/commands/json_toggle.ts
1026
+ var JsonToggleCommand = class extends Command {
1027
+ constructor(cmd, opts) {
1028
+ super(["JSON.TOGGLE", ...cmd], opts);
1029
+ }
1030
+ };
1031
+
1032
+ // pkg/commands/json_type.ts
1033
+ var JsonTypeCommand = class extends Command {
1034
+ constructor(cmd, opts) {
1035
+ super(["JSON.TYPE", ...cmd], opts);
1036
+ }
1037
+ };
1038
+
1039
+ // pkg/commands/keys.ts
1040
+ var KeysCommand = class extends Command {
1041
+ constructor(cmd, opts) {
1042
+ super(["keys", ...cmd], opts);
1043
+ }
1044
+ };
1045
+
1046
+ // pkg/commands/lindex.ts
1047
+ var LIndexCommand = class extends Command {
1048
+ constructor(cmd, opts) {
1049
+ super(["lindex", ...cmd], opts);
1050
+ }
1051
+ };
1052
+
1053
+ // pkg/commands/linsert.ts
1054
+ var LInsertCommand = class extends Command {
1055
+ constructor(cmd, opts) {
1056
+ super(["linsert", ...cmd], opts);
1057
+ }
1058
+ };
1059
+
1060
+ // pkg/commands/llen.ts
1061
+ var LLenCommand = class extends Command {
1062
+ constructor(cmd, opts) {
1063
+ super(["llen", ...cmd], opts);
1064
+ }
1065
+ };
1066
+
1067
+ // pkg/commands/lmove.ts
1068
+ var LMoveCommand = class extends Command {
1069
+ constructor(cmd, opts) {
1070
+ super(["lmove", ...cmd], opts);
1071
+ }
1072
+ };
1073
+
1074
+ // pkg/commands/lmpop.ts
1075
+ var LmPopCommand = class extends Command {
1076
+ constructor(cmd, opts) {
1077
+ const [numkeys, keys, direction, count] = cmd;
1078
+ super(["LMPOP", numkeys, ...keys, direction, ...count ? ["COUNT", count] : []], opts);
1079
+ }
1080
+ };
1081
+
1082
+ // pkg/commands/lpop.ts
1083
+ var LPopCommand = class extends Command {
1084
+ constructor(cmd, opts) {
1085
+ super(["lpop", ...cmd], opts);
1086
+ }
1087
+ };
1088
+
1089
+ // pkg/commands/lpos.ts
1090
+ var LPosCommand = class extends Command {
1091
+ constructor(cmd, opts) {
1092
+ const args = ["lpos", cmd[0], cmd[1]];
1093
+ if (typeof cmd[2]?.rank === "number") {
1094
+ args.push("rank", cmd[2].rank);
1095
+ }
1096
+ if (typeof cmd[2]?.count === "number") {
1097
+ args.push("count", cmd[2].count);
1098
+ }
1099
+ if (typeof cmd[2]?.maxLen === "number") {
1100
+ args.push("maxLen", cmd[2].maxLen);
1101
+ }
1102
+ super(args, opts);
1103
+ }
1104
+ };
1105
+
1106
+ // pkg/commands/lpush.ts
1107
+ var LPushCommand = class extends Command {
1108
+ constructor(cmd, opts) {
1109
+ super(["lpush", ...cmd], opts);
1110
+ }
1111
+ };
1112
+
1113
+ // pkg/commands/lpushx.ts
1114
+ var LPushXCommand = class extends Command {
1115
+ constructor(cmd, opts) {
1116
+ super(["lpushx", ...cmd], opts);
1117
+ }
1118
+ };
1119
+
1120
+ // pkg/commands/lrange.ts
1121
+ var LRangeCommand = class extends Command {
1122
+ constructor(cmd, opts) {
1123
+ super(["lrange", ...cmd], opts);
1124
+ }
1125
+ };
1126
+
1127
+ // pkg/commands/lrem.ts
1128
+ var LRemCommand = class extends Command {
1129
+ constructor(cmd, opts) {
1130
+ super(["lrem", ...cmd], opts);
1131
+ }
1132
+ };
1133
+
1134
+ // pkg/commands/lset.ts
1135
+ var LSetCommand = class extends Command {
1136
+ constructor(cmd, opts) {
1137
+ super(["lset", ...cmd], opts);
1138
+ }
1139
+ };
1140
+
1141
+ // pkg/commands/ltrim.ts
1142
+ var LTrimCommand = class extends Command {
1143
+ constructor(cmd, opts) {
1144
+ super(["ltrim", ...cmd], opts);
1145
+ }
1146
+ };
1147
+
1148
+ // pkg/commands/mget.ts
1149
+ var MGetCommand = class extends Command {
1150
+ constructor(cmd, opts) {
1151
+ const keys = Array.isArray(cmd[0]) ? cmd[0] : cmd;
1152
+ super(["mget", ...keys], opts);
1153
+ }
1154
+ };
1155
+
1156
+ // pkg/commands/mset.ts
1157
+ var MSetCommand = class extends Command {
1158
+ constructor([kv], opts) {
1159
+ super(["mset", ...Object.entries(kv).flatMap(([key, value]) => [key, value])], opts);
1160
+ }
1161
+ };
1162
+
1163
+ // pkg/commands/msetnx.ts
1164
+ var MSetNXCommand = class extends Command {
1165
+ constructor([kv], opts) {
1166
+ super(["msetnx", ...Object.entries(kv).flat()], opts);
1167
+ }
1168
+ };
1169
+
1170
+ // pkg/commands/persist.ts
1171
+ var PersistCommand = class extends Command {
1172
+ constructor(cmd, opts) {
1173
+ super(["persist", ...cmd], opts);
1174
+ }
1175
+ };
1176
+
1177
+ // pkg/commands/pexpire.ts
1178
+ var PExpireCommand = class extends Command {
1179
+ constructor(cmd, opts) {
1180
+ super(["pexpire", ...cmd], opts);
1181
+ }
1182
+ };
1183
+
1184
+ // pkg/commands/pexpireat.ts
1185
+ var PExpireAtCommand = class extends Command {
1186
+ constructor(cmd, opts) {
1187
+ super(["pexpireat", ...cmd], opts);
1188
+ }
1189
+ };
1190
+
1191
+ // pkg/commands/pfadd.ts
1192
+ var PfAddCommand = class extends Command {
1193
+ constructor(cmd, opts) {
1194
+ super(["pfadd", ...cmd], opts);
1195
+ }
1196
+ };
1197
+
1198
+ // pkg/commands/pfcount.ts
1199
+ var PfCountCommand = class extends Command {
1200
+ constructor(cmd, opts) {
1201
+ super(["pfcount", ...cmd], opts);
1202
+ }
1203
+ };
1204
+
1205
+ // pkg/commands/pfmerge.ts
1206
+ var PfMergeCommand = class extends Command {
1207
+ constructor(cmd, opts) {
1208
+ super(["pfmerge", ...cmd], opts);
1209
+ }
1210
+ };
1211
+
1212
+ // pkg/commands/ping.ts
1213
+ var PingCommand = class extends Command {
1214
+ constructor(cmd, opts) {
1215
+ const command = ["ping"];
1216
+ if (cmd?.[0] !== void 0) {
1217
+ command.push(cmd[0]);
1218
+ }
1219
+ super(command, opts);
1220
+ }
1221
+ };
1222
+
1223
+ // pkg/commands/psetex.ts
1224
+ var PSetEXCommand = class extends Command {
1225
+ constructor(cmd, opts) {
1226
+ super(["psetex", ...cmd], opts);
1227
+ }
1228
+ };
1229
+
1230
+ // pkg/commands/pttl.ts
1231
+ var PTtlCommand = class extends Command {
1232
+ constructor(cmd, opts) {
1233
+ super(["pttl", ...cmd], opts);
1234
+ }
1235
+ };
1236
+
1237
+ // pkg/commands/publish.ts
1238
+ var PublishCommand = class extends Command {
1239
+ constructor(cmd, opts) {
1240
+ super(["publish", ...cmd], opts);
1241
+ }
1242
+ };
1243
+
1244
+ // pkg/commands/randomkey.ts
1245
+ var RandomKeyCommand = class extends Command {
1246
+ constructor(opts) {
1247
+ super(["randomkey"], opts);
1248
+ }
1249
+ };
1250
+
1251
+ // pkg/commands/rename.ts
1252
+ var RenameCommand = class extends Command {
1253
+ constructor(cmd, opts) {
1254
+ super(["rename", ...cmd], opts);
1255
+ }
1256
+ };
1257
+
1258
+ // pkg/commands/renamenx.ts
1259
+ var RenameNXCommand = class extends Command {
1260
+ constructor(cmd, opts) {
1261
+ super(["renamenx", ...cmd], opts);
1262
+ }
1263
+ };
1264
+
1265
+ // pkg/commands/rpop.ts
1266
+ var RPopCommand = class extends Command {
1267
+ constructor(cmd, opts) {
1268
+ super(["rpop", ...cmd], opts);
1269
+ }
1270
+ };
1271
+
1272
+ // pkg/commands/rpush.ts
1273
+ var RPushCommand = class extends Command {
1274
+ constructor(cmd, opts) {
1275
+ super(["rpush", ...cmd], opts);
1276
+ }
1277
+ };
1278
+
1279
+ // pkg/commands/rpushx.ts
1280
+ var RPushXCommand = class extends Command {
1281
+ constructor(cmd, opts) {
1282
+ super(["rpushx", ...cmd], opts);
1283
+ }
1284
+ };
1285
+
1286
+ // pkg/commands/sadd.ts
1287
+ var SAddCommand = class extends Command {
1288
+ constructor(cmd, opts) {
1289
+ super(["sadd", ...cmd], opts);
1290
+ }
1291
+ };
1292
+
1293
+ // pkg/commands/scan.ts
1294
+ var ScanCommand = class extends Command {
1295
+ constructor([cursor, opts], cmdOpts) {
1296
+ const command = ["scan", cursor];
1297
+ if (opts?.match) {
1298
+ command.push("match", opts.match);
1299
+ }
1300
+ if (typeof opts?.count === "number") {
1301
+ command.push("count", opts.count);
1302
+ }
1303
+ if (opts?.type && opts.type.length > 0) {
1304
+ command.push("type", opts.type);
1305
+ }
1306
+ super(command, {
1307
+ deserialize: deserializeScanResponse,
1308
+ ...cmdOpts
1309
+ });
1310
+ }
1311
+ };
1312
+
1313
+ // pkg/commands/scard.ts
1314
+ var SCardCommand = class extends Command {
1315
+ constructor(cmd, opts) {
1316
+ super(["scard", ...cmd], opts);
1317
+ }
1318
+ };
1319
+
1320
+ // pkg/commands/script_exists.ts
1321
+ var ScriptExistsCommand = class extends Command {
1322
+ constructor(hashes, opts) {
1323
+ super(["script", "exists", ...hashes], {
1324
+ deserialize: (result) => result,
1325
+ ...opts
1326
+ });
1327
+ }
1328
+ };
1329
+
1330
+ // pkg/commands/script_flush.ts
1331
+ var ScriptFlushCommand = class extends Command {
1332
+ constructor([opts], cmdOpts) {
1333
+ const cmd = ["script", "flush"];
1334
+ if (opts?.sync) {
1335
+ cmd.push("sync");
1336
+ } else if (opts?.async) {
1337
+ cmd.push("async");
1338
+ }
1339
+ super(cmd, cmdOpts);
1340
+ }
1341
+ };
1342
+
1343
+ // pkg/commands/script_load.ts
1344
+ var ScriptLoadCommand = class extends Command {
1345
+ constructor(args, opts) {
1346
+ super(["script", "load", ...args], opts);
1347
+ }
1348
+ };
1349
+
1350
+ // pkg/commands/sdiff.ts
1351
+ var SDiffCommand = class extends Command {
1352
+ constructor(cmd, opts) {
1353
+ super(["sdiff", ...cmd], opts);
1354
+ }
1355
+ };
1356
+
1357
+ // pkg/commands/sdiffstore.ts
1358
+ var SDiffStoreCommand = class extends Command {
1359
+ constructor(cmd, opts) {
1360
+ super(["sdiffstore", ...cmd], opts);
1361
+ }
1362
+ };
1363
+
1364
+ // pkg/commands/set.ts
1365
+ var SetCommand = class extends Command {
1366
+ constructor([key, value, opts], cmdOpts) {
1367
+ const command = ["set", key, value];
1368
+ if (opts) {
1369
+ if ("nx" in opts && opts.nx) {
1370
+ command.push("nx");
1371
+ } else if ("xx" in opts && opts.xx) {
1372
+ command.push("xx");
1373
+ }
1374
+ if ("get" in opts && opts.get) {
1375
+ command.push("get");
1376
+ }
1377
+ if ("ex" in opts && typeof opts.ex === "number") {
1378
+ command.push("ex", opts.ex);
1379
+ } else if ("px" in opts && typeof opts.px === "number") {
1380
+ command.push("px", opts.px);
1381
+ } else if ("exat" in opts && typeof opts.exat === "number") {
1382
+ command.push("exat", opts.exat);
1383
+ } else if ("pxat" in opts && typeof opts.pxat === "number") {
1384
+ command.push("pxat", opts.pxat);
1385
+ } else if ("keepTtl" in opts && opts.keepTtl) {
1386
+ command.push("keepTtl");
1387
+ }
1388
+ }
1389
+ super(command, cmdOpts);
1390
+ }
1391
+ };
1392
+
1393
+ // pkg/commands/setbit.ts
1394
+ var SetBitCommand = class extends Command {
1395
+ constructor(cmd, opts) {
1396
+ super(["setbit", ...cmd], opts);
1397
+ }
1398
+ };
1399
+
1400
+ // pkg/commands/setex.ts
1401
+ var SetExCommand = class extends Command {
1402
+ constructor(cmd, opts) {
1403
+ super(["setex", ...cmd], opts);
1404
+ }
1405
+ };
1406
+
1407
+ // pkg/commands/setnx.ts
1408
+ var SetNxCommand = class extends Command {
1409
+ constructor(cmd, opts) {
1410
+ super(["setnx", ...cmd], opts);
1411
+ }
1412
+ };
1413
+
1414
+ // pkg/commands/setrange.ts
1415
+ var SetRangeCommand = class extends Command {
1416
+ constructor(cmd, opts) {
1417
+ super(["setrange", ...cmd], opts);
1418
+ }
1419
+ };
1420
+
1421
+ // pkg/commands/sinter.ts
1422
+ var SInterCommand = class extends Command {
1423
+ constructor(cmd, opts) {
1424
+ super(["sinter", ...cmd], opts);
1425
+ }
1426
+ };
1427
+
1428
+ // pkg/commands/sinterstore.ts
1429
+ var SInterStoreCommand = class extends Command {
1430
+ constructor(cmd, opts) {
1431
+ super(["sinterstore", ...cmd], opts);
1432
+ }
1433
+ };
1434
+
1435
+ // pkg/commands/sismember.ts
1436
+ var SIsMemberCommand = class extends Command {
1437
+ constructor(cmd, opts) {
1438
+ super(["sismember", ...cmd], opts);
1439
+ }
1440
+ };
1441
+
1442
+ // pkg/commands/smembers.ts
1443
+ var SMembersCommand = class extends Command {
1444
+ constructor(cmd, opts) {
1445
+ super(["smembers", ...cmd], opts);
1446
+ }
1447
+ };
1448
+
1449
+ // pkg/commands/smismember.ts
1450
+ var SMIsMemberCommand = class extends Command {
1451
+ constructor(cmd, opts) {
1452
+ super(["smismember", cmd[0], ...cmd[1]], opts);
1453
+ }
1454
+ };
1455
+
1456
+ // pkg/commands/smove.ts
1457
+ var SMoveCommand = class extends Command {
1458
+ constructor(cmd, opts) {
1459
+ super(["smove", ...cmd], opts);
1460
+ }
1461
+ };
1462
+
1463
+ // pkg/commands/spop.ts
1464
+ var SPopCommand = class extends Command {
1465
+ constructor([key, count], opts) {
1466
+ const command = ["spop", key];
1467
+ if (typeof count === "number") {
1468
+ command.push(count);
1469
+ }
1470
+ super(command, opts);
1471
+ }
1472
+ };
1473
+
1474
+ // pkg/commands/srandmember.ts
1475
+ var SRandMemberCommand = class extends Command {
1476
+ constructor([key, count], opts) {
1477
+ const command = ["srandmember", key];
1478
+ if (typeof count === "number") {
1479
+ command.push(count);
1480
+ }
1481
+ super(command, opts);
1482
+ }
1483
+ };
1484
+
1485
+ // pkg/commands/srem.ts
1486
+ var SRemCommand = class extends Command {
1487
+ constructor(cmd, opts) {
1488
+ super(["srem", ...cmd], opts);
1489
+ }
1490
+ };
1491
+
1492
+ // pkg/commands/sscan.ts
1493
+ var SScanCommand = class extends Command {
1494
+ constructor([key, cursor, opts], cmdOpts) {
1495
+ const command = ["sscan", key, cursor];
1496
+ if (opts?.match) {
1497
+ command.push("match", opts.match);
1498
+ }
1499
+ if (typeof opts?.count === "number") {
1500
+ command.push("count", opts.count);
1501
+ }
1502
+ super(command, {
1503
+ deserialize: deserializeScanResponse,
1504
+ ...cmdOpts
1505
+ });
1506
+ }
1507
+ };
1508
+
1509
+ // pkg/commands/strlen.ts
1510
+ var StrLenCommand = class extends Command {
1511
+ constructor(cmd, opts) {
1512
+ super(["strlen", ...cmd], opts);
1513
+ }
1514
+ };
1515
+
1516
+ // pkg/commands/sunion.ts
1517
+ var SUnionCommand = class extends Command {
1518
+ constructor(cmd, opts) {
1519
+ super(["sunion", ...cmd], opts);
1520
+ }
1521
+ };
1522
+
1523
+ // pkg/commands/sunionstore.ts
1524
+ var SUnionStoreCommand = class extends Command {
1525
+ constructor(cmd, opts) {
1526
+ super(["sunionstore", ...cmd], opts);
1527
+ }
1528
+ };
1529
+
1530
+ // pkg/commands/time.ts
1531
+ var TimeCommand = class extends Command {
1532
+ constructor(opts) {
1533
+ super(["time"], opts);
1534
+ }
1535
+ };
1536
+
1537
+ // pkg/commands/touch.ts
1538
+ var TouchCommand = class extends Command {
1539
+ constructor(cmd, opts) {
1540
+ super(["touch", ...cmd], opts);
1541
+ }
1542
+ };
1543
+
1544
+ // pkg/commands/ttl.ts
1545
+ var TtlCommand = class extends Command {
1546
+ constructor(cmd, opts) {
1547
+ super(["ttl", ...cmd], opts);
1548
+ }
1549
+ };
1550
+
1551
+ // pkg/commands/type.ts
1552
+ var TypeCommand = class extends Command {
1553
+ constructor(cmd, opts) {
1554
+ super(["type", ...cmd], opts);
1555
+ }
1556
+ };
1557
+
1558
+ // pkg/commands/unlink.ts
1559
+ var UnlinkCommand = class extends Command {
1560
+ constructor(cmd, opts) {
1561
+ super(["unlink", ...cmd], opts);
1562
+ }
1563
+ };
1564
+
1565
+ // pkg/commands/xack.ts
1566
+ var XAckCommand = class extends Command {
1567
+ constructor([key, group, id], opts) {
1568
+ const ids = Array.isArray(id) ? [...id] : [id];
1569
+ super(["XACK", key, group, ...ids], opts);
1570
+ }
1571
+ };
1572
+
1573
+ // pkg/commands/xadd.ts
1574
+ var XAddCommand = class extends Command {
1575
+ constructor([key, id, entries, opts], commandOptions) {
1576
+ const command = ["XADD", key];
1577
+ if (opts) {
1578
+ if (opts.nomkStream) {
1579
+ command.push("NOMKSTREAM");
1580
+ }
1581
+ if (opts.trim) {
1582
+ command.push(opts.trim.type, opts.trim.comparison, opts.trim.threshold);
1583
+ if (opts.trim.limit !== void 0) {
1584
+ command.push("LIMIT", opts.trim.limit);
1585
+ }
1586
+ }
1587
+ }
1588
+ command.push(id);
1589
+ for (const [k, v] of Object.entries(entries)) {
1590
+ command.push(k, v);
1591
+ }
1592
+ super(command, commandOptions);
1593
+ }
1594
+ };
1595
+
1596
+ // pkg/commands/xautoclaim.ts
1597
+ var XAutoClaim = class extends Command {
1598
+ constructor([key, group, consumer, minIdleTime, start, options], opts) {
1599
+ const commands = [];
1600
+ if (options?.count) {
1601
+ commands.push("COUNT", options.count);
1602
+ }
1603
+ if (options?.justId) {
1604
+ commands.push("JUSTID");
1605
+ }
1606
+ super(["XAUTOCLAIM", key, group, consumer, minIdleTime, start, ...commands], opts);
1607
+ }
1608
+ };
1609
+
1610
+ // pkg/commands/xclaim.ts
1611
+ var XClaimCommand = class extends Command {
1612
+ constructor([key, group, consumer, minIdleTime, id, options], opts) {
1613
+ const ids = Array.isArray(id) ? [...id] : [id];
1614
+ const commands = [];
1615
+ if (options?.idleMS) {
1616
+ commands.push("IDLE", options.idleMS);
1617
+ }
1618
+ if (options?.idleMS) {
1619
+ commands.push("TIME", options.timeMS);
1620
+ }
1621
+ if (options?.retryCount) {
1622
+ commands.push("RETRYCOUNT", options.retryCount);
1623
+ }
1624
+ if (options?.force) {
1625
+ commands.push("FORCE");
1626
+ }
1627
+ if (options?.justId) {
1628
+ commands.push("JUSTID");
1629
+ }
1630
+ if (options?.lastId) {
1631
+ commands.push("LASTID", options.lastId);
1632
+ }
1633
+ super(["XCLAIM", key, group, consumer, minIdleTime, ...ids, ...commands], opts);
1634
+ }
1635
+ };
1636
+
1637
+ // pkg/commands/xdel.ts
1638
+ var XDelCommand = class extends Command {
1639
+ constructor([key, ids], opts) {
1640
+ const cmds = Array.isArray(ids) ? [...ids] : [ids];
1641
+ super(["XDEL", key, ...cmds], opts);
1642
+ }
1643
+ };
1644
+
1645
+ // pkg/commands/xgroup.ts
1646
+ var XGroupCommand = class extends Command {
1647
+ constructor([key, opts], commandOptions) {
1648
+ const command = ["XGROUP"];
1649
+ switch (opts.type) {
1650
+ case "CREATE": {
1651
+ command.push("CREATE", key, opts.group, opts.id);
1652
+ if (opts.options) {
1653
+ if (opts.options.MKSTREAM) {
1654
+ command.push("MKSTREAM");
1655
+ }
1656
+ if (opts.options.ENTRIESREAD !== void 0) {
1657
+ command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
1658
+ }
1659
+ }
1660
+ break;
1661
+ }
1662
+ case "CREATECONSUMER": {
1663
+ command.push("CREATECONSUMER", key, opts.group, opts.consumer);
1664
+ break;
1665
+ }
1666
+ case "DELCONSUMER": {
1667
+ command.push("DELCONSUMER", key, opts.group, opts.consumer);
1668
+ break;
1669
+ }
1670
+ case "DESTROY": {
1671
+ command.push("DESTROY", key, opts.group);
1672
+ break;
1673
+ }
1674
+ case "SETID": {
1675
+ command.push("SETID", key, opts.group, opts.id);
1676
+ if (opts.options?.ENTRIESREAD !== void 0) {
1677
+ command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
1678
+ }
1679
+ break;
1680
+ }
1681
+ default: {
1682
+ throw new Error("Invalid XGROUP");
1683
+ }
1684
+ }
1685
+ super(command, commandOptions);
1686
+ }
1687
+ };
1688
+
1689
+ // pkg/commands/xinfo.ts
1690
+ var XInfoCommand = class extends Command {
1691
+ constructor([key, options], opts) {
1692
+ const cmds = [];
1693
+ if (options.type === "CONSUMERS") {
1694
+ cmds.push("CONSUMERS", key, options.group);
1695
+ } else {
1696
+ cmds.push("GROUPS", key);
1697
+ }
1698
+ super(["XINFO", ...cmds], opts);
1699
+ }
1700
+ };
1701
+
1702
+ // pkg/commands/xlen.ts
1703
+ var XLenCommand = class extends Command {
1704
+ constructor(cmd, opts) {
1705
+ super(["XLEN", ...cmd], opts);
1706
+ }
1707
+ };
1708
+
1709
+ // pkg/commands/xpending.ts
1710
+ var XPendingCommand = class extends Command {
1711
+ constructor([key, group, start, end, count, options], opts) {
1712
+ const consumers = options?.consumer === void 0 ? [] : Array.isArray(options.consumer) ? [...options.consumer] : [options.consumer];
1713
+ super(
1714
+ [
1715
+ "XPENDING",
1716
+ key,
1717
+ group,
1718
+ ...options?.idleTime ? ["IDLE", options.idleTime] : [],
1719
+ start,
1720
+ end,
1721
+ count,
1722
+ ...consumers
1723
+ ],
1724
+ opts
1725
+ );
1726
+ }
1727
+ };
1728
+
1729
+ // pkg/commands/xrange.ts
1730
+ function deserialize4(result) {
1731
+ const obj = {};
1732
+ for (const e of result) {
1733
+ while (e.length >= 2) {
1734
+ const streamId = e.shift();
1735
+ const entries = e.shift();
1736
+ if (!(streamId in obj)) {
1737
+ obj[streamId] = {};
1738
+ }
1739
+ while (entries.length >= 2) {
1740
+ const field = entries.shift();
1741
+ const value = entries.shift();
1742
+ try {
1743
+ obj[streamId][field] = JSON.parse(value);
1744
+ } catch {
1745
+ obj[streamId][field] = value;
1746
+ }
1747
+ }
1748
+ }
1749
+ }
1750
+ return obj;
1751
+ }
1752
+ var XRangeCommand = class extends Command {
1753
+ constructor([key, start, end, count], opts) {
1754
+ const command = ["XRANGE", key, start, end];
1755
+ if (typeof count === "number") {
1756
+ command.push("COUNT", count);
1757
+ }
1758
+ super(command, {
1759
+ deserialize: (result) => deserialize4(result),
1760
+ ...opts
1761
+ });
1762
+ }
1763
+ };
1764
+
1765
+ // pkg/commands/xread.ts
1766
+ var UNBALANCED_XREAD_ERR = "ERR Unbalanced XREAD list of streams: for each stream key an ID or '$' must be specified";
1767
+ var XReadCommand = class extends Command {
1768
+ constructor([key, id, options], opts) {
1769
+ if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
1770
+ throw new Error(UNBALANCED_XREAD_ERR);
1771
+ }
1772
+ const commands = [];
1773
+ if (typeof options?.count === "number") {
1774
+ commands.push("COUNT", options.count);
1775
+ }
1776
+ if (typeof options?.blockMS === "number") {
1777
+ commands.push("BLOCK", options.blockMS);
1778
+ }
1779
+ commands.push(
1780
+ "STREAMS",
1781
+ ...Array.isArray(key) ? [...key] : [key],
1782
+ ...Array.isArray(id) ? [...id] : [id]
1783
+ );
1784
+ super(["XREAD", ...commands], opts);
1785
+ }
1786
+ };
1787
+
1788
+ // pkg/commands/xreadgroup.ts
1789
+ var UNBALANCED_XREADGROUP_ERR = "ERR Unbalanced XREADGROUP list of streams: for each stream key an ID or '$' must be specified";
1790
+ var XReadGroupCommand = class extends Command {
1791
+ constructor([group, consumer, key, id, options], opts) {
1792
+ if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
1793
+ throw new Error(UNBALANCED_XREADGROUP_ERR);
1794
+ }
1795
+ const commands = [];
1796
+ if (typeof options?.count === "number") {
1797
+ commands.push("COUNT", options.count);
1798
+ }
1799
+ if (typeof options?.blockMS === "number") {
1800
+ commands.push("BLOCK", options.blockMS);
1801
+ }
1802
+ if (typeof options?.NOACK === "boolean" && options.NOACK) {
1803
+ commands.push("NOACK");
1804
+ }
1805
+ commands.push(
1806
+ "STREAMS",
1807
+ ...Array.isArray(key) ? [...key] : [key],
1808
+ ...Array.isArray(id) ? [...id] : [id]
1809
+ );
1810
+ super(["XREADGROUP", "GROUP", group, consumer, ...commands], opts);
1811
+ }
1812
+ };
1813
+
1814
+ // pkg/commands/xrevrange.ts
1815
+ var XRevRangeCommand = class extends Command {
1816
+ constructor([key, end, start, count], opts) {
1817
+ const command = ["XREVRANGE", key, end, start];
1818
+ if (typeof count === "number") {
1819
+ command.push("COUNT", count);
1820
+ }
1821
+ super(command, {
1822
+ deserialize: (result) => deserialize5(result),
1823
+ ...opts
1824
+ });
1825
+ }
1826
+ };
1827
+ function deserialize5(result) {
1828
+ const obj = {};
1829
+ for (const e of result) {
1830
+ while (e.length >= 2) {
1831
+ const streamId = e.shift();
1832
+ const entries = e.shift();
1833
+ if (!(streamId in obj)) {
1834
+ obj[streamId] = {};
1835
+ }
1836
+ while (entries.length >= 2) {
1837
+ const field = entries.shift();
1838
+ const value = entries.shift();
1839
+ try {
1840
+ obj[streamId][field] = JSON.parse(value);
1841
+ } catch {
1842
+ obj[streamId][field] = value;
1843
+ }
1844
+ }
1845
+ }
1846
+ }
1847
+ return obj;
1848
+ }
1849
+
1850
+ // pkg/commands/xtrim.ts
1851
+ var XTrimCommand = class extends Command {
1852
+ constructor([key, options], opts) {
1853
+ const { limit, strategy, threshold, exactness = "~" } = options;
1854
+ super(["XTRIM", key, strategy, exactness, threshold, ...limit ? ["LIMIT", limit] : []], opts);
1855
+ }
1856
+ };
1857
+
1858
+ // pkg/commands/zadd.ts
1859
+ var ZAddCommand = class extends Command {
1860
+ constructor([key, arg1, ...arg2], opts) {
1861
+ const command = ["zadd", key];
1862
+ if ("nx" in arg1 && arg1.nx) {
1863
+ command.push("nx");
1864
+ } else if ("xx" in arg1 && arg1.xx) {
1865
+ command.push("xx");
1866
+ }
1867
+ if ("ch" in arg1 && arg1.ch) {
1868
+ command.push("ch");
1869
+ }
1870
+ if ("incr" in arg1 && arg1.incr) {
1871
+ command.push("incr");
1872
+ }
1873
+ if ("lt" in arg1 && arg1.lt) {
1874
+ command.push("lt");
1875
+ } else if ("gt" in arg1 && arg1.gt) {
1876
+ command.push("gt");
1877
+ }
1878
+ if ("score" in arg1 && "member" in arg1) {
1879
+ command.push(arg1.score, arg1.member);
1880
+ }
1881
+ command.push(...arg2.flatMap(({ score, member }) => [score, member]));
1882
+ super(command, opts);
1883
+ }
1884
+ };
1885
+
1886
+ // pkg/commands/zcard.ts
1887
+ var ZCardCommand = class extends Command {
1888
+ constructor(cmd, opts) {
1889
+ super(["zcard", ...cmd], opts);
1890
+ }
1891
+ };
1892
+
1893
+ // pkg/commands/zcount.ts
1894
+ var ZCountCommand = class extends Command {
1895
+ constructor(cmd, opts) {
1896
+ super(["zcount", ...cmd], opts);
1897
+ }
1898
+ };
1899
+
1900
+ // pkg/commands/zincrby.ts
1901
+ var ZIncrByCommand = class extends Command {
1902
+ constructor(cmd, opts) {
1903
+ super(["zincrby", ...cmd], opts);
1904
+ }
1905
+ };
1906
+
1907
+ // pkg/commands/zinterstore.ts
1908
+ var ZInterStoreCommand = class extends Command {
1909
+ constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
1910
+ const command = ["zinterstore", destination, numKeys];
1911
+ if (Array.isArray(keyOrKeys)) {
1912
+ command.push(...keyOrKeys);
1913
+ } else {
1914
+ command.push(keyOrKeys);
1915
+ }
1916
+ if (opts) {
1917
+ if ("weights" in opts && opts.weights) {
1918
+ command.push("weights", ...opts.weights);
1919
+ } else if ("weight" in opts && typeof opts.weight === "number") {
1920
+ command.push("weights", opts.weight);
1921
+ }
1922
+ if ("aggregate" in opts) {
1923
+ command.push("aggregate", opts.aggregate);
1924
+ }
1925
+ }
1926
+ super(command, cmdOpts);
1927
+ }
1928
+ };
1929
+
1930
+ // pkg/commands/zlexcount.ts
1931
+ var ZLexCountCommand = class extends Command {
1932
+ constructor(cmd, opts) {
1933
+ super(["zlexcount", ...cmd], opts);
1934
+ }
1935
+ };
1936
+
1937
+ // pkg/commands/zpopmax.ts
1938
+ var ZPopMaxCommand = class extends Command {
1939
+ constructor([key, count], opts) {
1940
+ const command = ["zpopmax", key];
1941
+ if (typeof count === "number") {
1942
+ command.push(count);
1943
+ }
1944
+ super(command, opts);
1945
+ }
1946
+ };
1947
+
1948
+ // pkg/commands/zpopmin.ts
1949
+ var ZPopMinCommand = class extends Command {
1950
+ constructor([key, count], opts) {
1951
+ const command = ["zpopmin", key];
1952
+ if (typeof count === "number") {
1953
+ command.push(count);
1954
+ }
1955
+ super(command, opts);
1956
+ }
1957
+ };
1958
+
1959
+ // pkg/commands/zrange.ts
1960
+ var ZRangeCommand = class extends Command {
1961
+ constructor([key, min, max, opts], cmdOpts) {
1962
+ const command = ["zrange", key, min, max];
1963
+ if (opts?.byScore) {
1964
+ command.push("byscore");
1965
+ }
1966
+ if (opts?.byLex) {
1967
+ command.push("bylex");
1968
+ }
1969
+ if (opts?.rev) {
1970
+ command.push("rev");
1971
+ }
1972
+ if (opts?.count !== void 0 && opts.offset !== void 0) {
1973
+ command.push("limit", opts.offset, opts.count);
1974
+ }
1975
+ if (opts?.withScores) {
1976
+ command.push("withscores");
1977
+ }
1978
+ super(command, cmdOpts);
1979
+ }
1980
+ };
1981
+
1982
+ // pkg/commands/zrank.ts
1983
+ var ZRankCommand = class extends Command {
1984
+ constructor(cmd, opts) {
1985
+ super(["zrank", ...cmd], opts);
1986
+ }
1987
+ };
1988
+
1989
+ // pkg/commands/zrem.ts
1990
+ var ZRemCommand = class extends Command {
1991
+ constructor(cmd, opts) {
1992
+ super(["zrem", ...cmd], opts);
1993
+ }
1994
+ };
1995
+
1996
+ // pkg/commands/zremrangebylex.ts
1997
+ var ZRemRangeByLexCommand = class extends Command {
1998
+ constructor(cmd, opts) {
1999
+ super(["zremrangebylex", ...cmd], opts);
2000
+ }
2001
+ };
2002
+
2003
+ // pkg/commands/zremrangebyrank.ts
2004
+ var ZRemRangeByRankCommand = class extends Command {
2005
+ constructor(cmd, opts) {
2006
+ super(["zremrangebyrank", ...cmd], opts);
2007
+ }
2008
+ };
2009
+
2010
+ // pkg/commands/zremrangebyscore.ts
2011
+ var ZRemRangeByScoreCommand = class extends Command {
2012
+ constructor(cmd, opts) {
2013
+ super(["zremrangebyscore", ...cmd], opts);
2014
+ }
2015
+ };
2016
+
2017
+ // pkg/commands/zrevrank.ts
2018
+ var ZRevRankCommand = class extends Command {
2019
+ constructor(cmd, opts) {
2020
+ super(["zrevrank", ...cmd], opts);
2021
+ }
2022
+ };
2023
+
2024
+ // pkg/commands/zscan.ts
2025
+ var ZScanCommand = class extends Command {
2026
+ constructor([key, cursor, opts], cmdOpts) {
2027
+ const command = ["zscan", key, cursor];
2028
+ if (opts?.match) {
2029
+ command.push("match", opts.match);
2030
+ }
2031
+ if (typeof opts?.count === "number") {
2032
+ command.push("count", opts.count);
2033
+ }
2034
+ super(command, {
2035
+ deserialize: deserializeScanResponse,
2036
+ ...cmdOpts
2037
+ });
2038
+ }
2039
+ };
2040
+
2041
+ // pkg/commands/zscore.ts
2042
+ var ZScoreCommand = class extends Command {
2043
+ constructor(cmd, opts) {
2044
+ super(["zscore", ...cmd], opts);
2045
+ }
2046
+ };
2047
+
2048
+ // pkg/commands/zunion.ts
2049
+ var ZUnionCommand = class extends Command {
2050
+ constructor([numKeys, keyOrKeys, opts], cmdOpts) {
2051
+ const command = ["zunion", numKeys];
2052
+ if (Array.isArray(keyOrKeys)) {
2053
+ command.push(...keyOrKeys);
2054
+ } else {
2055
+ command.push(keyOrKeys);
2056
+ }
2057
+ if (opts) {
2058
+ if ("weights" in opts && opts.weights) {
2059
+ command.push("weights", ...opts.weights);
2060
+ } else if ("weight" in opts && typeof opts.weight === "number") {
2061
+ command.push("weights", opts.weight);
2062
+ }
2063
+ if ("aggregate" in opts) {
2064
+ command.push("aggregate", opts.aggregate);
2065
+ }
2066
+ if (opts.withScores) {
2067
+ command.push("withscores");
2068
+ }
2069
+ }
2070
+ super(command, cmdOpts);
2071
+ }
2072
+ };
2073
+
2074
+ // pkg/commands/zunionstore.ts
2075
+ var ZUnionStoreCommand = class extends Command {
2076
+ constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
2077
+ const command = ["zunionstore", destination, numKeys];
2078
+ if (Array.isArray(keyOrKeys)) {
2079
+ command.push(...keyOrKeys);
2080
+ } else {
2081
+ command.push(keyOrKeys);
2082
+ }
2083
+ if (opts) {
2084
+ if ("weights" in opts && opts.weights) {
2085
+ command.push("weights", ...opts.weights);
2086
+ } else if ("weight" in opts && typeof opts.weight === "number") {
2087
+ command.push("weights", opts.weight);
2088
+ }
2089
+ if ("aggregate" in opts) {
2090
+ command.push("aggregate", opts.aggregate);
2091
+ }
2092
+ }
2093
+ super(command, cmdOpts);
2094
+ }
2095
+ };
2096
+
2097
+ // pkg/commands/zdiffstore.ts
2098
+ var ZDiffStoreCommand = class extends Command {
2099
+ constructor(cmd, opts) {
2100
+ super(["zdiffstore", ...cmd], opts);
2101
+ }
2102
+ };
2103
+
2104
+ // pkg/commands/zmscore.ts
2105
+ var ZMScoreCommand = class extends Command {
2106
+ constructor(cmd, opts) {
2107
+ const [key, members] = cmd;
2108
+ super(["zmscore", key, ...members], opts);
2109
+ }
2110
+ };
2111
+
2112
+ // pkg/pipeline.ts
2113
+ var Pipeline = class {
2114
+ client;
2115
+ commands;
2116
+ commandOptions;
2117
+ multiExec;
2118
+ constructor(opts) {
2119
+ this.client = opts.client;
2120
+ this.commands = [];
2121
+ this.commandOptions = opts.commandOptions;
2122
+ this.multiExec = opts.multiExec ?? false;
2123
+ if (this.commandOptions?.latencyLogging) {
2124
+ const originalExec = this.exec.bind(this);
2125
+ this.exec = async () => {
2126
+ const start = performance.now();
2127
+ const result = await originalExec();
2128
+ const end = performance.now();
2129
+ const loggerResult = (end - start).toFixed(2);
2130
+ console.log(
2131
+ `Latency for \x1B[38;2;19;185;39m${this.multiExec ? ["MULTI-EXEC"] : ["PIPELINE"].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
2132
+ );
2133
+ return result;
2134
+ };
2135
+ }
2136
+ }
2137
+ /**
2138
+ * Send the pipeline request to upstash.
2139
+ *
2140
+ * Returns an array with the results of all pipelined commands.
2141
+ *
2142
+ * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
2143
+ * ```ts
2144
+ * const p = redis.pipeline()
2145
+ * p.get("key")
2146
+ * const result = p.exec<[{ greeting: string }]>()
2147
+ * ```
2148
+ */
2149
+ exec = async () => {
2150
+ if (this.commands.length === 0) {
2151
+ throw new Error("Pipeline is empty");
2152
+ }
2153
+ const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
2154
+ const res = await this.client.request({
2155
+ path,
2156
+ body: Object.values(this.commands).map((c) => c.command)
2157
+ });
2158
+ return res.map(({ error, result }, i) => {
2159
+ if (error) {
2160
+ throw new UpstashError(
2161
+ `Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
2162
+ );
2163
+ }
2164
+ return this.commands[i].deserialize(result);
2165
+ });
2166
+ };
2167
+ /**
2168
+ * Returns the length of pipeline before the execution
2169
+ */
2170
+ length() {
2171
+ return this.commands.length;
2172
+ }
2173
+ /**
2174
+ * Pushes a command into the pipeline and returns a chainable instance of the
2175
+ * pipeline
2176
+ */
2177
+ chain(command) {
2178
+ this.commands.push(command);
2179
+ return this;
2180
+ }
2181
+ /**
2182
+ * @see https://redis.io/commands/append
2183
+ */
2184
+ append = (...args) => this.chain(new AppendCommand(args, this.commandOptions));
2185
+ /**
2186
+ * @see https://redis.io/commands/bitcount
2187
+ */
2188
+ bitcount = (...args) => this.chain(new BitCountCommand(args, this.commandOptions));
2189
+ /**
2190
+ * Returns an instance that can be used to execute `BITFIELD` commands on one key.
2191
+ *
2192
+ * @example
2193
+ * ```typescript
2194
+ * redis.set("mykey", 0);
2195
+ * const result = await redis.pipeline()
2196
+ * .bitfield("mykey")
2197
+ * .set("u4", 0, 16)
2198
+ * .incr("u4", "#1", 1)
2199
+ * .exec();
2200
+ * console.log(result); // [[0, 1]]
2201
+ * ```
2202
+ *
2203
+ * @see https://redis.io/commands/bitfield
2204
+ */
2205
+ bitfield = (...args) => new BitFieldCommand(args, this.client, this.commandOptions, this.chain.bind(this));
2206
+ /**
2207
+ * @see https://redis.io/commands/bitop
2208
+ */
2209
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => this.chain(
2210
+ new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.commandOptions)
2211
+ );
2212
+ /**
2213
+ * @see https://redis.io/commands/bitpos
2214
+ */
2215
+ bitpos = (...args) => this.chain(new BitPosCommand(args, this.commandOptions));
2216
+ /**
2217
+ * @see https://redis.io/commands/copy
2218
+ */
2219
+ copy = (...args) => this.chain(new CopyCommand(args, this.commandOptions));
2220
+ /**
2221
+ * @see https://redis.io/commands/zdiffstore
2222
+ */
2223
+ zdiffstore = (...args) => this.chain(new ZDiffStoreCommand(args, this.commandOptions));
2224
+ /**
2225
+ * @see https://redis.io/commands/dbsize
2226
+ */
2227
+ dbsize = () => this.chain(new DBSizeCommand(this.commandOptions));
2228
+ /**
2229
+ * @see https://redis.io/commands/decr
2230
+ */
2231
+ decr = (...args) => this.chain(new DecrCommand(args, this.commandOptions));
2232
+ /**
2233
+ * @see https://redis.io/commands/decrby
2234
+ */
2235
+ decrby = (...args) => this.chain(new DecrByCommand(args, this.commandOptions));
2236
+ /**
2237
+ * @see https://redis.io/commands/del
2238
+ */
2239
+ del = (...args) => this.chain(new DelCommand(args, this.commandOptions));
2240
+ /**
2241
+ * @see https://redis.io/commands/echo
2242
+ */
2243
+ echo = (...args) => this.chain(new EchoCommand(args, this.commandOptions));
2244
+ /**
2245
+ * @see https://redis.io/commands/eval
2246
+ */
2247
+ eval = (...args) => this.chain(new EvalCommand(args, this.commandOptions));
2248
+ /**
2249
+ * @see https://redis.io/commands/evalsha
2250
+ */
2251
+ evalsha = (...args) => this.chain(new EvalshaCommand(args, this.commandOptions));
2252
+ /**
2253
+ * @see https://redis.io/commands/exists
2254
+ */
2255
+ exists = (...args) => this.chain(new ExistsCommand(args, this.commandOptions));
2256
+ /**
2257
+ * @see https://redis.io/commands/expire
2258
+ */
2259
+ expire = (...args) => this.chain(new ExpireCommand(args, this.commandOptions));
2260
+ /**
2261
+ * @see https://redis.io/commands/expireat
2262
+ */
2263
+ expireat = (...args) => this.chain(new ExpireAtCommand(args, this.commandOptions));
2264
+ /**
2265
+ * @see https://redis.io/commands/flushall
2266
+ */
2267
+ flushall = (args) => this.chain(new FlushAllCommand(args, this.commandOptions));
2268
+ /**
2269
+ * @see https://redis.io/commands/flushdb
2270
+ */
2271
+ flushdb = (...args) => this.chain(new FlushDBCommand(args, this.commandOptions));
2272
+ /**
2273
+ * @see https://redis.io/commands/geoadd
2274
+ */
2275
+ geoadd = (...args) => this.chain(new GeoAddCommand(args, this.commandOptions));
2276
+ /**
2277
+ * @see https://redis.io/commands/geodist
2278
+ */
2279
+ geodist = (...args) => this.chain(new GeoDistCommand(args, this.commandOptions));
2280
+ /**
2281
+ * @see https://redis.io/commands/geopos
2282
+ */
2283
+ geopos = (...args) => this.chain(new GeoPosCommand(args, this.commandOptions));
2284
+ /**
2285
+ * @see https://redis.io/commands/geohash
2286
+ */
2287
+ geohash = (...args) => this.chain(new GeoHashCommand(args, this.commandOptions));
2288
+ /**
2289
+ * @see https://redis.io/commands/geosearch
2290
+ */
2291
+ geosearch = (...args) => this.chain(new GeoSearchCommand(args, this.commandOptions));
2292
+ /**
2293
+ * @see https://redis.io/commands/geosearchstore
2294
+ */
2295
+ geosearchstore = (...args) => this.chain(new GeoSearchStoreCommand(args, this.commandOptions));
2296
+ /**
2297
+ * @see https://redis.io/commands/get
2298
+ */
2299
+ get = (...args) => this.chain(new GetCommand(args, this.commandOptions));
2300
+ /**
2301
+ * @see https://redis.io/commands/getbit
2302
+ */
2303
+ getbit = (...args) => this.chain(new GetBitCommand(args, this.commandOptions));
2304
+ /**
2305
+ * @see https://redis.io/commands/getdel
2306
+ */
2307
+ getdel = (...args) => this.chain(new GetDelCommand(args, this.commandOptions));
2308
+ /**
2309
+ * @see https://redis.io/commands/getrange
2310
+ */
2311
+ getrange = (...args) => this.chain(new GetRangeCommand(args, this.commandOptions));
2312
+ /**
2313
+ * @see https://redis.io/commands/getset
2314
+ */
2315
+ getset = (key, value) => this.chain(new GetSetCommand([key, value], this.commandOptions));
2316
+ /**
2317
+ * @see https://redis.io/commands/hdel
2318
+ */
2319
+ hdel = (...args) => this.chain(new HDelCommand(args, this.commandOptions));
2320
+ /**
2321
+ * @see https://redis.io/commands/hexists
2322
+ */
2323
+ hexists = (...args) => this.chain(new HExistsCommand(args, this.commandOptions));
2324
+ /**
2325
+ * @see https://redis.io/commands/hget
2326
+ */
2327
+ hget = (...args) => this.chain(new HGetCommand(args, this.commandOptions));
2328
+ /**
2329
+ * @see https://redis.io/commands/hgetall
2330
+ */
2331
+ hgetall = (...args) => this.chain(new HGetAllCommand(args, this.commandOptions));
2332
+ /**
2333
+ * @see https://redis.io/commands/hincrby
2334
+ */
2335
+ hincrby = (...args) => this.chain(new HIncrByCommand(args, this.commandOptions));
2336
+ /**
2337
+ * @see https://redis.io/commands/hincrbyfloat
2338
+ */
2339
+ hincrbyfloat = (...args) => this.chain(new HIncrByFloatCommand(args, this.commandOptions));
2340
+ /**
2341
+ * @see https://redis.io/commands/hkeys
2342
+ */
2343
+ hkeys = (...args) => this.chain(new HKeysCommand(args, this.commandOptions));
2344
+ /**
2345
+ * @see https://redis.io/commands/hlen
2346
+ */
2347
+ hlen = (...args) => this.chain(new HLenCommand(args, this.commandOptions));
2348
+ /**
2349
+ * @see https://redis.io/commands/hmget
2350
+ */
2351
+ hmget = (...args) => this.chain(new HMGetCommand(args, this.commandOptions));
2352
+ /**
2353
+ * @see https://redis.io/commands/hmset
2354
+ */
2355
+ hmset = (key, kv) => this.chain(new HMSetCommand([key, kv], this.commandOptions));
2356
+ /**
2357
+ * @see https://redis.io/commands/hrandfield
2358
+ */
2359
+ hrandfield = (key, count, withValues) => this.chain(new HRandFieldCommand([key, count, withValues], this.commandOptions));
2360
+ /**
2361
+ * @see https://redis.io/commands/hscan
2362
+ */
2363
+ hscan = (...args) => this.chain(new HScanCommand(args, this.commandOptions));
2364
+ /**
2365
+ * @see https://redis.io/commands/hset
2366
+ */
2367
+ hset = (key, kv) => this.chain(new HSetCommand([key, kv], this.commandOptions));
2368
+ /**
2369
+ * @see https://redis.io/commands/hsetnx
2370
+ */
2371
+ hsetnx = (key, field, value) => this.chain(new HSetNXCommand([key, field, value], this.commandOptions));
2372
+ /**
2373
+ * @see https://redis.io/commands/hstrlen
2374
+ */
2375
+ hstrlen = (...args) => this.chain(new HStrLenCommand(args, this.commandOptions));
2376
+ /**
2377
+ * @see https://redis.io/commands/hvals
2378
+ */
2379
+ hvals = (...args) => this.chain(new HValsCommand(args, this.commandOptions));
2380
+ /**
2381
+ * @see https://redis.io/commands/incr
2382
+ */
2383
+ incr = (...args) => this.chain(new IncrCommand(args, this.commandOptions));
2384
+ /**
2385
+ * @see https://redis.io/commands/incrby
2386
+ */
2387
+ incrby = (...args) => this.chain(new IncrByCommand(args, this.commandOptions));
2388
+ /**
2389
+ * @see https://redis.io/commands/incrbyfloat
2390
+ */
2391
+ incrbyfloat = (...args) => this.chain(new IncrByFloatCommand(args, this.commandOptions));
2392
+ /**
2393
+ * @see https://redis.io/commands/keys
2394
+ */
2395
+ keys = (...args) => this.chain(new KeysCommand(args, this.commandOptions));
2396
+ /**
2397
+ * @see https://redis.io/commands/lindex
2398
+ */
2399
+ lindex = (...args) => this.chain(new LIndexCommand(args, this.commandOptions));
2400
+ /**
2401
+ * @see https://redis.io/commands/linsert
2402
+ */
2403
+ linsert = (key, direction, pivot, value) => this.chain(new LInsertCommand([key, direction, pivot, value], this.commandOptions));
2404
+ /**
2405
+ * @see https://redis.io/commands/llen
2406
+ */
2407
+ llen = (...args) => this.chain(new LLenCommand(args, this.commandOptions));
2408
+ /**
2409
+ * @see https://redis.io/commands/lmove
2410
+ */
2411
+ lmove = (...args) => this.chain(new LMoveCommand(args, this.commandOptions));
2412
+ /**
2413
+ * @see https://redis.io/commands/lpop
2414
+ */
2415
+ lpop = (...args) => this.chain(new LPopCommand(args, this.commandOptions));
2416
+ /**
2417
+ * @see https://redis.io/commands/lmpop
2418
+ */
2419
+ lmpop = (...args) => this.chain(new LmPopCommand(args, this.commandOptions));
2420
+ /**
2421
+ * @see https://redis.io/commands/lpos
2422
+ */
2423
+ lpos = (...args) => this.chain(new LPosCommand(args, this.commandOptions));
2424
+ /**
2425
+ * @see https://redis.io/commands/lpush
2426
+ */
2427
+ lpush = (key, ...elements) => this.chain(new LPushCommand([key, ...elements], this.commandOptions));
2428
+ /**
2429
+ * @see https://redis.io/commands/lpushx
2430
+ */
2431
+ lpushx = (key, ...elements) => this.chain(new LPushXCommand([key, ...elements], this.commandOptions));
2432
+ /**
2433
+ * @see https://redis.io/commands/lrange
2434
+ */
2435
+ lrange = (...args) => this.chain(new LRangeCommand(args, this.commandOptions));
2436
+ /**
2437
+ * @see https://redis.io/commands/lrem
2438
+ */
2439
+ lrem = (key, count, value) => this.chain(new LRemCommand([key, count, value], this.commandOptions));
2440
+ /**
2441
+ * @see https://redis.io/commands/lset
2442
+ */
2443
+ lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
2444
+ /**
2445
+ * @see https://redis.io/commands/ltrim
2446
+ */
2447
+ ltrim = (...args) => this.chain(new LTrimCommand(args, this.commandOptions));
2448
+ /**
2449
+ * @see https://redis.io/commands/mget
2450
+ */
2451
+ mget = (...args) => this.chain(new MGetCommand(args, this.commandOptions));
2452
+ /**
2453
+ * @see https://redis.io/commands/mset
2454
+ */
2455
+ mset = (kv) => this.chain(new MSetCommand([kv], this.commandOptions));
2456
+ /**
2457
+ * @see https://redis.io/commands/msetnx
2458
+ */
2459
+ msetnx = (kv) => this.chain(new MSetNXCommand([kv], this.commandOptions));
2460
+ /**
2461
+ * @see https://redis.io/commands/persist
2462
+ */
2463
+ persist = (...args) => this.chain(new PersistCommand(args, this.commandOptions));
2464
+ /**
2465
+ * @see https://redis.io/commands/pexpire
2466
+ */
2467
+ pexpire = (...args) => this.chain(new PExpireCommand(args, this.commandOptions));
2468
+ /**
2469
+ * @see https://redis.io/commands/pexpireat
2470
+ */
2471
+ pexpireat = (...args) => this.chain(new PExpireAtCommand(args, this.commandOptions));
2472
+ /**
2473
+ * @see https://redis.io/commands/pfadd
2474
+ */
2475
+ pfadd = (...args) => this.chain(new PfAddCommand(args, this.commandOptions));
2476
+ /**
2477
+ * @see https://redis.io/commands/pfcount
2478
+ */
2479
+ pfcount = (...args) => this.chain(new PfCountCommand(args, this.commandOptions));
2480
+ /**
2481
+ * @see https://redis.io/commands/pfmerge
2482
+ */
2483
+ pfmerge = (...args) => this.chain(new PfMergeCommand(args, this.commandOptions));
2484
+ /**
2485
+ * @see https://redis.io/commands/ping
2486
+ */
2487
+ ping = (args) => this.chain(new PingCommand(args, this.commandOptions));
2488
+ /**
2489
+ * @see https://redis.io/commands/psetex
2490
+ */
2491
+ psetex = (key, ttl, value) => this.chain(new PSetEXCommand([key, ttl, value], this.commandOptions));
2492
+ /**
2493
+ * @see https://redis.io/commands/pttl
2494
+ */
2495
+ pttl = (...args) => this.chain(new PTtlCommand(args, this.commandOptions));
2496
+ /**
2497
+ * @see https://redis.io/commands/publish
2498
+ */
2499
+ publish = (...args) => this.chain(new PublishCommand(args, this.commandOptions));
2500
+ /**
2501
+ * @see https://redis.io/commands/randomkey
2502
+ */
2503
+ randomkey = () => this.chain(new RandomKeyCommand(this.commandOptions));
2504
+ /**
2505
+ * @see https://redis.io/commands/rename
2506
+ */
2507
+ rename = (...args) => this.chain(new RenameCommand(args, this.commandOptions));
2508
+ /**
2509
+ * @see https://redis.io/commands/renamenx
2510
+ */
2511
+ renamenx = (...args) => this.chain(new RenameNXCommand(args, this.commandOptions));
2512
+ /**
2513
+ * @see https://redis.io/commands/rpop
2514
+ */
2515
+ rpop = (...args) => this.chain(new RPopCommand(args, this.commandOptions));
2516
+ /**
2517
+ * @see https://redis.io/commands/rpush
2518
+ */
2519
+ rpush = (key, ...elements) => this.chain(new RPushCommand([key, ...elements], this.commandOptions));
2520
+ /**
2521
+ * @see https://redis.io/commands/rpushx
2522
+ */
2523
+ rpushx = (key, ...elements) => this.chain(new RPushXCommand([key, ...elements], this.commandOptions));
2524
+ /**
2525
+ * @see https://redis.io/commands/sadd
2526
+ */
2527
+ sadd = (key, member, ...members) => this.chain(new SAddCommand([key, member, ...members], this.commandOptions));
2528
+ /**
2529
+ * @see https://redis.io/commands/scan
2530
+ */
2531
+ scan = (...args) => this.chain(new ScanCommand(args, this.commandOptions));
2532
+ /**
2533
+ * @see https://redis.io/commands/scard
2534
+ */
2535
+ scard = (...args) => this.chain(new SCardCommand(args, this.commandOptions));
2536
+ /**
2537
+ * @see https://redis.io/commands/script-exists
2538
+ */
2539
+ scriptExists = (...args) => this.chain(new ScriptExistsCommand(args, this.commandOptions));
2540
+ /**
2541
+ * @see https://redis.io/commands/script-flush
2542
+ */
2543
+ scriptFlush = (...args) => this.chain(new ScriptFlushCommand(args, this.commandOptions));
2544
+ /**
2545
+ * @see https://redis.io/commands/script-load
2546
+ */
2547
+ scriptLoad = (...args) => this.chain(new ScriptLoadCommand(args, this.commandOptions));
2548
+ /*)*
2549
+ * @see https://redis.io/commands/sdiff
2550
+ */
2551
+ sdiff = (...args) => this.chain(new SDiffCommand(args, this.commandOptions));
2552
+ /**
2553
+ * @see https://redis.io/commands/sdiffstore
2554
+ */
2555
+ sdiffstore = (...args) => this.chain(new SDiffStoreCommand(args, this.commandOptions));
2556
+ /**
2557
+ * @see https://redis.io/commands/set
2558
+ */
2559
+ set = (key, value, opts) => this.chain(new SetCommand([key, value, opts], this.commandOptions));
2560
+ /**
2561
+ * @see https://redis.io/commands/setbit
2562
+ */
2563
+ setbit = (...args) => this.chain(new SetBitCommand(args, this.commandOptions));
2564
+ /**
2565
+ * @see https://redis.io/commands/setex
2566
+ */
2567
+ setex = (key, ttl, value) => this.chain(new SetExCommand([key, ttl, value], this.commandOptions));
2568
+ /**
2569
+ * @see https://redis.io/commands/setnx
2570
+ */
2571
+ setnx = (key, value) => this.chain(new SetNxCommand([key, value], this.commandOptions));
2572
+ /**
2573
+ * @see https://redis.io/commands/setrange
2574
+ */
2575
+ setrange = (...args) => this.chain(new SetRangeCommand(args, this.commandOptions));
2576
+ /**
2577
+ * @see https://redis.io/commands/sinter
2578
+ */
2579
+ sinter = (...args) => this.chain(new SInterCommand(args, this.commandOptions));
2580
+ /**
2581
+ * @see https://redis.io/commands/sinterstore
2582
+ */
2583
+ sinterstore = (...args) => this.chain(new SInterStoreCommand(args, this.commandOptions));
2584
+ /**
2585
+ * @see https://redis.io/commands/sismember
2586
+ */
2587
+ sismember = (key, member) => this.chain(new SIsMemberCommand([key, member], this.commandOptions));
2588
+ /**
2589
+ * @see https://redis.io/commands/smembers
2590
+ */
2591
+ smembers = (...args) => this.chain(new SMembersCommand(args, this.commandOptions));
2592
+ /**
2593
+ * @see https://redis.io/commands/smismember
2594
+ */
2595
+ smismember = (key, members) => this.chain(new SMIsMemberCommand([key, members], this.commandOptions));
2596
+ /**
2597
+ * @see https://redis.io/commands/smove
2598
+ */
2599
+ smove = (source, destination, member) => this.chain(new SMoveCommand([source, destination, member], this.commandOptions));
2600
+ /**
2601
+ * @see https://redis.io/commands/spop
2602
+ */
2603
+ spop = (...args) => this.chain(new SPopCommand(args, this.commandOptions));
2604
+ /**
2605
+ * @see https://redis.io/commands/srandmember
2606
+ */
2607
+ srandmember = (...args) => this.chain(new SRandMemberCommand(args, this.commandOptions));
2608
+ /**
2609
+ * @see https://redis.io/commands/srem
2610
+ */
2611
+ srem = (key, ...members) => this.chain(new SRemCommand([key, ...members], this.commandOptions));
2612
+ /**
2613
+ * @see https://redis.io/commands/sscan
2614
+ */
2615
+ sscan = (...args) => this.chain(new SScanCommand(args, this.commandOptions));
2616
+ /**
2617
+ * @see https://redis.io/commands/strlen
2618
+ */
2619
+ strlen = (...args) => this.chain(new StrLenCommand(args, this.commandOptions));
2620
+ /**
2621
+ * @see https://redis.io/commands/sunion
2622
+ */
2623
+ sunion = (...args) => this.chain(new SUnionCommand(args, this.commandOptions));
2624
+ /**
2625
+ * @see https://redis.io/commands/sunionstore
2626
+ */
2627
+ sunionstore = (...args) => this.chain(new SUnionStoreCommand(args, this.commandOptions));
2628
+ /**
2629
+ * @see https://redis.io/commands/time
2630
+ */
2631
+ time = () => this.chain(new TimeCommand(this.commandOptions));
2632
+ /**
2633
+ * @see https://redis.io/commands/touch
2634
+ */
2635
+ touch = (...args) => this.chain(new TouchCommand(args, this.commandOptions));
2636
+ /**
2637
+ * @see https://redis.io/commands/ttl
2638
+ */
2639
+ ttl = (...args) => this.chain(new TtlCommand(args, this.commandOptions));
2640
+ /**
2641
+ * @see https://redis.io/commands/type
2642
+ */
2643
+ type = (...args) => this.chain(new TypeCommand(args, this.commandOptions));
2644
+ /**
2645
+ * @see https://redis.io/commands/unlink
2646
+ */
2647
+ unlink = (...args) => this.chain(new UnlinkCommand(args, this.commandOptions));
2648
+ /**
2649
+ * @see https://redis.io/commands/zadd
2650
+ */
2651
+ zadd = (...args) => {
2652
+ if ("score" in args[1]) {
2653
+ return this.chain(
2654
+ new ZAddCommand([args[0], args[1], ...args.slice(2)], this.commandOptions)
2655
+ );
2656
+ }
2657
+ return this.chain(
2658
+ new ZAddCommand(
2659
+ [args[0], args[1], ...args.slice(2)],
2660
+ this.commandOptions
2661
+ )
2662
+ );
2663
+ };
2664
+ /**
2665
+ * @see https://redis.io/commands/xadd
2666
+ */
2667
+ xadd = (...args) => this.chain(new XAddCommand(args, this.commandOptions));
2668
+ /**
2669
+ * @see https://redis.io/commands/xack
2670
+ */
2671
+ xack = (...args) => this.chain(new XAckCommand(args, this.commandOptions));
2672
+ /**
2673
+ * @see https://redis.io/commands/xdel
2674
+ */
2675
+ xdel = (...args) => this.chain(new XDelCommand(args, this.commandOptions));
2676
+ /**
2677
+ * @see https://redis.io/commands/xgroup
2678
+ */
2679
+ xgroup = (...args) => this.chain(new XGroupCommand(args, this.commandOptions));
2680
+ /**
2681
+ * @see https://redis.io/commands/xread
2682
+ */
2683
+ xread = (...args) => this.chain(new XReadCommand(args, this.commandOptions));
2684
+ /**
2685
+ * @see https://redis.io/commands/xreadgroup
2686
+ */
2687
+ xreadgroup = (...args) => this.chain(new XReadGroupCommand(args, this.commandOptions));
2688
+ /**
2689
+ * @see https://redis.io/commands/xinfo
2690
+ */
2691
+ xinfo = (...args) => this.chain(new XInfoCommand(args, this.commandOptions));
2692
+ /**
2693
+ * @see https://redis.io/commands/xlen
2694
+ */
2695
+ xlen = (...args) => this.chain(new XLenCommand(args, this.commandOptions));
2696
+ /**
2697
+ * @see https://redis.io/commands/xpending
2698
+ */
2699
+ xpending = (...args) => this.chain(new XPendingCommand(args, this.commandOptions));
2700
+ /**
2701
+ * @see https://redis.io/commands/xclaim
2702
+ */
2703
+ xclaim = (...args) => this.chain(new XClaimCommand(args, this.commandOptions));
2704
+ /**
2705
+ * @see https://redis.io/commands/xautoclaim
2706
+ */
2707
+ xautoclaim = (...args) => this.chain(new XAutoClaim(args, this.commandOptions));
2708
+ /**
2709
+ * @see https://redis.io/commands/xtrim
2710
+ */
2711
+ xtrim = (...args) => this.chain(new XTrimCommand(args, this.commandOptions));
2712
+ /**
2713
+ * @see https://redis.io/commands/xrange
2714
+ */
2715
+ xrange = (...args) => this.chain(new XRangeCommand(args, this.commandOptions));
2716
+ /**
2717
+ * @see https://redis.io/commands/xrevrange
2718
+ */
2719
+ xrevrange = (...args) => this.chain(new XRevRangeCommand(args, this.commandOptions));
2720
+ /**
2721
+ * @see https://redis.io/commands/zcard
2722
+ */
2723
+ zcard = (...args) => this.chain(new ZCardCommand(args, this.commandOptions));
2724
+ /**
2725
+ * @see https://redis.io/commands/zcount
2726
+ */
2727
+ zcount = (...args) => this.chain(new ZCountCommand(args, this.commandOptions));
2728
+ /**
2729
+ * @see https://redis.io/commands/zincrby
2730
+ */
2731
+ zincrby = (key, increment, member) => this.chain(new ZIncrByCommand([key, increment, member], this.commandOptions));
2732
+ /**
2733
+ * @see https://redis.io/commands/zinterstore
2734
+ */
2735
+ zinterstore = (...args) => this.chain(new ZInterStoreCommand(args, this.commandOptions));
2736
+ /**
2737
+ * @see https://redis.io/commands/zlexcount
2738
+ */
2739
+ zlexcount = (...args) => this.chain(new ZLexCountCommand(args, this.commandOptions));
2740
+ /**
2741
+ * @see https://redis.io/commands/zmscore
2742
+ */
2743
+ zmscore = (...args) => this.chain(new ZMScoreCommand(args, this.commandOptions));
2744
+ /**
2745
+ * @see https://redis.io/commands/zpopmax
2746
+ */
2747
+ zpopmax = (...args) => this.chain(new ZPopMaxCommand(args, this.commandOptions));
2748
+ /**
2749
+ * @see https://redis.io/commands/zpopmin
2750
+ */
2751
+ zpopmin = (...args) => this.chain(new ZPopMinCommand(args, this.commandOptions));
2752
+ /**
2753
+ * @see https://redis.io/commands/zrange
2754
+ */
2755
+ zrange = (...args) => this.chain(new ZRangeCommand(args, this.commandOptions));
2756
+ /**
2757
+ * @see https://redis.io/commands/zrank
2758
+ */
2759
+ zrank = (key, member) => this.chain(new ZRankCommand([key, member], this.commandOptions));
2760
+ /**
2761
+ * @see https://redis.io/commands/zrem
2762
+ */
2763
+ zrem = (key, ...members) => this.chain(new ZRemCommand([key, ...members], this.commandOptions));
2764
+ /**
2765
+ * @see https://redis.io/commands/zremrangebylex
2766
+ */
2767
+ zremrangebylex = (...args) => this.chain(new ZRemRangeByLexCommand(args, this.commandOptions));
2768
+ /**
2769
+ * @see https://redis.io/commands/zremrangebyrank
2770
+ */
2771
+ zremrangebyrank = (...args) => this.chain(new ZRemRangeByRankCommand(args, this.commandOptions));
2772
+ /**
2773
+ * @see https://redis.io/commands/zremrangebyscore
2774
+ */
2775
+ zremrangebyscore = (...args) => this.chain(new ZRemRangeByScoreCommand(args, this.commandOptions));
2776
+ /**
2777
+ * @see https://redis.io/commands/zrevrank
2778
+ */
2779
+ zrevrank = (key, member) => this.chain(new ZRevRankCommand([key, member], this.commandOptions));
2780
+ /**
2781
+ * @see https://redis.io/commands/zscan
2782
+ */
2783
+ zscan = (...args) => this.chain(new ZScanCommand(args, this.commandOptions));
2784
+ /**
2785
+ * @see https://redis.io/commands/zscore
2786
+ */
2787
+ zscore = (key, member) => this.chain(new ZScoreCommand([key, member], this.commandOptions));
2788
+ /**
2789
+ * @see https://redis.io/commands/zunionstore
2790
+ */
2791
+ zunionstore = (...args) => this.chain(new ZUnionStoreCommand(args, this.commandOptions));
2792
+ /**
2793
+ * @see https://redis.io/commands/zunion
2794
+ */
2795
+ zunion = (...args) => this.chain(new ZUnionCommand(args, this.commandOptions));
2796
+ /**
2797
+ * @see https://redis.io/commands/?group=json
2798
+ */
2799
+ get json() {
2800
+ return {
2801
+ /**
2802
+ * @see https://redis.io/commands/json.arrappend
2803
+ */
2804
+ arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
2805
+ /**
2806
+ * @see https://redis.io/commands/json.arrindex
2807
+ */
2808
+ arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
2809
+ /**
2810
+ * @see https://redis.io/commands/json.arrinsert
2811
+ */
2812
+ arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
2813
+ /**
2814
+ * @see https://redis.io/commands/json.arrlen
2815
+ */
2816
+ arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
2817
+ /**
2818
+ * @see https://redis.io/commands/json.arrpop
2819
+ */
2820
+ arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
2821
+ /**
2822
+ * @see https://redis.io/commands/json.arrtrim
2823
+ */
2824
+ arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
2825
+ /**
2826
+ * @see https://redis.io/commands/json.clear
2827
+ */
2828
+ clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
2829
+ /**
2830
+ * @see https://redis.io/commands/json.del
2831
+ */
2832
+ del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
2833
+ /**
2834
+ * @see https://redis.io/commands/json.forget
2835
+ */
2836
+ forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
2837
+ /**
2838
+ * @see https://redis.io/commands/json.get
2839
+ */
2840
+ get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
2841
+ /**
2842
+ * @see https://redis.io/commands/json.mget
2843
+ */
2844
+ mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
2845
+ /**
2846
+ * @see https://redis.io/commands/json.mset
2847
+ */
2848
+ mset: (...args) => this.chain(new JsonMSetCommand(args, this.commandOptions)),
2849
+ /**
2850
+ * @see https://redis.io/commands/json.numincrby
2851
+ */
2852
+ numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
2853
+ /**
2854
+ * @see https://redis.io/commands/json.nummultby
2855
+ */
2856
+ nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
2857
+ /**
2858
+ * @see https://redis.io/commands/json.objkeys
2859
+ */
2860
+ objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
2861
+ /**
2862
+ * @see https://redis.io/commands/json.objlen
2863
+ */
2864
+ objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
2865
+ /**
2866
+ * @see https://redis.io/commands/json.resp
2867
+ */
2868
+ resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
2869
+ /**
2870
+ * @see https://redis.io/commands/json.set
2871
+ */
2872
+ set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
2873
+ /**
2874
+ * @see https://redis.io/commands/json.strappend
2875
+ */
2876
+ strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
2877
+ /**
2878
+ * @see https://redis.io/commands/json.strlen
2879
+ */
2880
+ strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
2881
+ /**
2882
+ * @see https://redis.io/commands/json.toggle
2883
+ */
2884
+ toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
2885
+ /**
2886
+ * @see https://redis.io/commands/json.type
2887
+ */
2888
+ type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
2889
+ };
2890
+ }
2891
+ };
2892
+
2893
+ // pkg/auto-pipeline.ts
2894
+ function createAutoPipelineProxy(_redis, json) {
2895
+ const redis = _redis;
2896
+ if (!redis.autoPipelineExecutor) {
2897
+ redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
2898
+ }
2899
+ return new Proxy(redis, {
2900
+ get: (redis2, command) => {
2901
+ if (command === "pipelineCounter") {
2902
+ return redis2.autoPipelineExecutor.pipelineCounter;
2903
+ }
2904
+ if (command === "json") {
2905
+ return createAutoPipelineProxy(redis2, true);
2906
+ }
2907
+ const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
2908
+ if (commandInRedisButNotPipeline) {
2909
+ return redis2[command];
2910
+ }
2911
+ const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
2912
+ if (isFunction) {
2913
+ return (...args) => {
2914
+ return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
2915
+ if (json) {
2916
+ pipeline.json[command](
2917
+ ...args
2918
+ );
2919
+ } else {
2920
+ pipeline[command](...args);
2921
+ }
2922
+ });
2923
+ };
2924
+ }
2925
+ return redis2.autoPipelineExecutor.pipeline[command];
2926
+ }
2927
+ });
2928
+ }
2929
+ var AutoPipelineExecutor = class {
2930
+ pipelinePromises = /* @__PURE__ */ new WeakMap();
2931
+ activePipeline = null;
2932
+ indexInCurrentPipeline = 0;
2933
+ redis;
2934
+ pipeline;
2935
+ // only to make sure that proxy can work
2936
+ pipelineCounter = 0;
2937
+ // to keep track of how many times a pipeline was executed
2938
+ constructor(redis) {
2939
+ this.redis = redis;
2940
+ this.pipeline = redis.pipeline();
2941
+ }
2942
+ async withAutoPipeline(executeWithPipeline) {
2943
+ const pipeline = this.activePipeline ?? this.redis.pipeline();
2944
+ if (!this.activePipeline) {
2945
+ this.activePipeline = pipeline;
2946
+ this.indexInCurrentPipeline = 0;
2947
+ }
2948
+ const index = this.indexInCurrentPipeline++;
2949
+ executeWithPipeline(pipeline);
2950
+ const pipelineDone = this.deferExecution().then(() => {
2951
+ if (!this.pipelinePromises.has(pipeline)) {
2952
+ const pipelinePromise = pipeline.exec();
2953
+ this.pipelineCounter += 1;
2954
+ this.pipelinePromises.set(pipeline, pipelinePromise);
2955
+ this.activePipeline = null;
2956
+ }
2957
+ return this.pipelinePromises.get(pipeline);
2958
+ });
2959
+ const results = await pipelineDone;
2960
+ return results[index];
2961
+ }
2962
+ async deferExecution() {
2963
+ await Promise.resolve();
2964
+ await Promise.resolve();
2965
+ }
2966
+ };
2967
+
2968
+ // pkg/script.ts
2969
+ import Hex from "crypto-js/enc-hex.js";
2970
+ import sha1 from "crypto-js/sha1.js";
2971
+ var Script = class {
2972
+ script;
2973
+ sha1;
2974
+ redis;
2975
+ constructor(redis, script) {
2976
+ this.redis = redis;
2977
+ this.sha1 = this.digest(script);
2978
+ this.script = script;
2979
+ }
2980
+ /**
2981
+ * Send an `EVAL` command to redis.
2982
+ */
2983
+ async eval(keys, args) {
2984
+ return await this.redis.eval(this.script, keys, args);
2985
+ }
2986
+ /**
2987
+ * Calculates the sha1 hash of the script and then calls `EVALSHA`.
2988
+ */
2989
+ async evalsha(keys, args) {
2990
+ return await this.redis.evalsha(this.sha1, keys, args);
2991
+ }
2992
+ /**
2993
+ * Optimistically try to run `EVALSHA` first.
2994
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL`.
2995
+ *
2996
+ * Following calls will be able to use the cached script
2997
+ */
2998
+ async exec(keys, args) {
2999
+ const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
3000
+ if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3001
+ return await this.redis.eval(this.script, keys, args);
3002
+ }
3003
+ throw error;
3004
+ });
3005
+ return res;
3006
+ }
3007
+ /**
3008
+ * Compute the sha1 hash of the script and return its hex representation.
3009
+ */
3010
+ digest(s) {
3011
+ return Hex.stringify(sha1(s));
3012
+ }
3013
+ };
3014
+
3015
+ // pkg/redis.ts
3016
+ var Redis = class {
3017
+ client;
3018
+ opts;
3019
+ enableTelemetry;
3020
+ enableAutoPipelining;
3021
+ /**
3022
+ * Create a new redis client
3023
+ *
3024
+ * @example
3025
+ * ```typescript
3026
+ * const redis = new Redis({
3027
+ * url: "<UPSTASH_REDIS_REST_URL>",
3028
+ * token: "<UPSTASH_REDIS_REST_TOKEN>",
3029
+ * });
3030
+ * ```
3031
+ */
3032
+ constructor(client, opts) {
3033
+ this.client = client;
3034
+ this.opts = opts;
3035
+ this.enableTelemetry = opts?.enableTelemetry ?? true;
3036
+ if (opts?.readYourWrites === false) {
3037
+ this.client.readYourWrites = false;
3038
+ }
3039
+ this.enableAutoPipelining = opts?.enableAutoPipelining ?? true;
3040
+ }
3041
+ get readYourWritesSyncToken() {
3042
+ return this.client.upstashSyncToken;
3043
+ }
3044
+ set readYourWritesSyncToken(session) {
3045
+ this.client.upstashSyncToken = session;
3046
+ }
3047
+ get json() {
3048
+ return {
3049
+ /**
3050
+ * @see https://redis.io/commands/json.arrappend
3051
+ */
3052
+ arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
3053
+ /**
3054
+ * @see https://redis.io/commands/json.arrindex
3055
+ */
3056
+ arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
3057
+ /**
3058
+ * @see https://redis.io/commands/json.arrinsert
3059
+ */
3060
+ arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
3061
+ /**
3062
+ * @see https://redis.io/commands/json.arrlen
3063
+ */
3064
+ arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
3065
+ /**
3066
+ * @see https://redis.io/commands/json.arrpop
3067
+ */
3068
+ arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
3069
+ /**
3070
+ * @see https://redis.io/commands/json.arrtrim
3071
+ */
3072
+ arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
3073
+ /**
3074
+ * @see https://redis.io/commands/json.clear
3075
+ */
3076
+ clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
3077
+ /**
3078
+ * @see https://redis.io/commands/json.del
3079
+ */
3080
+ del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
3081
+ /**
3082
+ * @see https://redis.io/commands/json.forget
3083
+ */
3084
+ forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
3085
+ /**
3086
+ * @see https://redis.io/commands/json.get
3087
+ */
3088
+ get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
3089
+ /**
3090
+ * @see https://redis.io/commands/json.mget
3091
+ */
3092
+ mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
3093
+ /**
3094
+ * @see https://redis.io/commands/json.mset
3095
+ */
3096
+ mset: (...args) => new JsonMSetCommand(args, this.opts).exec(this.client),
3097
+ /**
3098
+ * @see https://redis.io/commands/json.numincrby
3099
+ */
3100
+ numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
3101
+ /**
3102
+ * @see https://redis.io/commands/json.nummultby
3103
+ */
3104
+ nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
3105
+ /**
3106
+ * @see https://redis.io/commands/json.objkeys
3107
+ */
3108
+ objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
3109
+ /**
3110
+ * @see https://redis.io/commands/json.objlen
3111
+ */
3112
+ objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
3113
+ /**
3114
+ * @see https://redis.io/commands/json.resp
3115
+ */
3116
+ resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
3117
+ /**
3118
+ * @see https://redis.io/commands/json.set
3119
+ */
3120
+ set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
3121
+ /**
3122
+ * @see https://redis.io/commands/json.strappend
3123
+ */
3124
+ strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
3125
+ /**
3126
+ * @see https://redis.io/commands/json.strlen
3127
+ */
3128
+ strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
3129
+ /**
3130
+ * @see https://redis.io/commands/json.toggle
3131
+ */
3132
+ toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
3133
+ /**
3134
+ * @see https://redis.io/commands/json.type
3135
+ */
3136
+ type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
3137
+ };
3138
+ }
3139
+ /**
3140
+ * Wrap a new middleware around the HTTP client.
3141
+ */
3142
+ use = (middleware) => {
3143
+ const makeRequest = this.client.request.bind(this.client);
3144
+ this.client.request = (req) => middleware(req, makeRequest);
3145
+ };
3146
+ /**
3147
+ * Technically this is not private, we can hide it from intellisense by doing this
3148
+ */
3149
+ addTelemetry = (telemetry) => {
3150
+ if (!this.enableTelemetry) {
3151
+ return;
3152
+ }
3153
+ try {
3154
+ this.client.mergeTelemetry(telemetry);
3155
+ } catch {
3156
+ }
3157
+ };
3158
+ createScript(script) {
3159
+ return new Script(this, script);
3160
+ }
3161
+ /**
3162
+ * Create a new pipeline that allows you to send requests in bulk.
3163
+ *
3164
+ * @see {@link Pipeline}
3165
+ */
3166
+ pipeline = () => new Pipeline({
3167
+ client: this.client,
3168
+ commandOptions: this.opts,
3169
+ multiExec: false
3170
+ });
3171
+ autoPipeline = () => {
3172
+ return createAutoPipelineProxy(this);
3173
+ };
3174
+ /**
3175
+ * Create a new transaction to allow executing multiple steps atomically.
3176
+ *
3177
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
3178
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
3179
+ * guarantees that the commands are executed as a single isolated operation.
3180
+ *
3181
+ * @see {@link Pipeline}
3182
+ */
3183
+ multi = () => new Pipeline({
3184
+ client: this.client,
3185
+ commandOptions: this.opts,
3186
+ multiExec: true
3187
+ });
3188
+ /**
3189
+ * Returns an instance that can be used to execute `BITFIELD` commands on one key.
3190
+ *
3191
+ * @example
3192
+ * ```typescript
3193
+ * redis.set("mykey", 0);
3194
+ * const result = await redis.bitfield("mykey")
3195
+ * .set("u4", 0, 16)
3196
+ * .incr("u4", "#1", 1)
3197
+ * .exec();
3198
+ * console.log(result); // [0, 1]
3199
+ * ```
3200
+ *
3201
+ * @see https://redis.io/commands/bitfield
3202
+ */
3203
+ bitfield = (...args) => new BitFieldCommand(args, this.client, this.opts);
3204
+ /**
3205
+ * @see https://redis.io/commands/append
3206
+ */
3207
+ append = (...args) => new AppendCommand(args, this.opts).exec(this.client);
3208
+ /**
3209
+ * @see https://redis.io/commands/bitcount
3210
+ */
3211
+ bitcount = (...args) => new BitCountCommand(args, this.opts).exec(this.client);
3212
+ /**
3213
+ * @see https://redis.io/commands/bitop
3214
+ */
3215
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.opts).exec(
3216
+ this.client
3217
+ );
3218
+ /**
3219
+ * @see https://redis.io/commands/bitpos
3220
+ */
3221
+ bitpos = (...args) => new BitPosCommand(args, this.opts).exec(this.client);
3222
+ /**
3223
+ * @see https://redis.io/commands/copy
3224
+ */
3225
+ copy = (...args) => new CopyCommand(args, this.opts).exec(this.client);
3226
+ /**
3227
+ * @see https://redis.io/commands/dbsize
3228
+ */
3229
+ dbsize = () => new DBSizeCommand(this.opts).exec(this.client);
3230
+ /**
3231
+ * @see https://redis.io/commands/decr
3232
+ */
3233
+ decr = (...args) => new DecrCommand(args, this.opts).exec(this.client);
3234
+ /**
3235
+ * @see https://redis.io/commands/decrby
3236
+ */
3237
+ decrby = (...args) => new DecrByCommand(args, this.opts).exec(this.client);
3238
+ /**
3239
+ * @see https://redis.io/commands/del
3240
+ */
3241
+ del = (...args) => new DelCommand(args, this.opts).exec(this.client);
3242
+ /**
3243
+ * @see https://redis.io/commands/echo
3244
+ */
3245
+ echo = (...args) => new EchoCommand(args, this.opts).exec(this.client);
3246
+ /**
3247
+ * @see https://redis.io/commands/eval
3248
+ */
3249
+ eval = (...args) => new EvalCommand(args, this.opts).exec(this.client);
3250
+ /**
3251
+ * @see https://redis.io/commands/evalsha
3252
+ */
3253
+ evalsha = (...args) => new EvalshaCommand(args, this.opts).exec(this.client);
3254
+ /**
3255
+ * @see https://redis.io/commands/exists
3256
+ */
3257
+ exists = (...args) => new ExistsCommand(args, this.opts).exec(this.client);
3258
+ /**
3259
+ * @see https://redis.io/commands/expire
3260
+ */
3261
+ expire = (...args) => new ExpireCommand(args, this.opts).exec(this.client);
3262
+ /**
3263
+ * @see https://redis.io/commands/expireat
3264
+ */
3265
+ expireat = (...args) => new ExpireAtCommand(args, this.opts).exec(this.client);
3266
+ /**
3267
+ * @see https://redis.io/commands/flushall
3268
+ */
3269
+ flushall = (args) => new FlushAllCommand(args, this.opts).exec(this.client);
3270
+ /**
3271
+ * @see https://redis.io/commands/flushdb
3272
+ */
3273
+ flushdb = (...args) => new FlushDBCommand(args, this.opts).exec(this.client);
3274
+ /**
3275
+ * @see https://redis.io/commands/geoadd
3276
+ */
3277
+ geoadd = (...args) => new GeoAddCommand(args, this.opts).exec(this.client);
3278
+ /**
3279
+ * @see https://redis.io/commands/geopos
3280
+ */
3281
+ geopos = (...args) => new GeoPosCommand(args, this.opts).exec(this.client);
3282
+ /**
3283
+ * @see https://redis.io/commands/geodist
3284
+ */
3285
+ geodist = (...args) => new GeoDistCommand(args, this.opts).exec(this.client);
3286
+ /**
3287
+ * @see https://redis.io/commands/geohash
3288
+ */
3289
+ geohash = (...args) => new GeoHashCommand(args, this.opts).exec(this.client);
3290
+ /**
3291
+ * @see https://redis.io/commands/geosearch
3292
+ */
3293
+ geosearch = (...args) => new GeoSearchCommand(args, this.opts).exec(this.client);
3294
+ /**
3295
+ * @see https://redis.io/commands/geosearchstore
3296
+ */
3297
+ geosearchstore = (...args) => new GeoSearchStoreCommand(args, this.opts).exec(this.client);
3298
+ /**
3299
+ * @see https://redis.io/commands/get
3300
+ */
3301
+ get = (...args) => new GetCommand(args, this.opts).exec(this.client);
3302
+ /**
3303
+ * @see https://redis.io/commands/getbit
3304
+ */
3305
+ getbit = (...args) => new GetBitCommand(args, this.opts).exec(this.client);
3306
+ /**
3307
+ * @see https://redis.io/commands/getdel
3308
+ */
3309
+ getdel = (...args) => new GetDelCommand(args, this.opts).exec(this.client);
3310
+ /**
3311
+ * @see https://redis.io/commands/getrange
3312
+ */
3313
+ getrange = (...args) => new GetRangeCommand(args, this.opts).exec(this.client);
3314
+ /**
3315
+ * @see https://redis.io/commands/getset
3316
+ */
3317
+ getset = (key, value) => new GetSetCommand([key, value], this.opts).exec(this.client);
3318
+ /**
3319
+ * @see https://redis.io/commands/hdel
3320
+ */
3321
+ hdel = (...args) => new HDelCommand(args, this.opts).exec(this.client);
3322
+ /**
3323
+ * @see https://redis.io/commands/hexists
3324
+ */
3325
+ hexists = (...args) => new HExistsCommand(args, this.opts).exec(this.client);
3326
+ /**
3327
+ * @see https://redis.io/commands/hget
3328
+ */
3329
+ hget = (...args) => new HGetCommand(args, this.opts).exec(this.client);
3330
+ /**
3331
+ * @see https://redis.io/commands/hgetall
3332
+ */
3333
+ hgetall = (...args) => new HGetAllCommand(args, this.opts).exec(this.client);
3334
+ /**
3335
+ * @see https://redis.io/commands/hincrby
3336
+ */
3337
+ hincrby = (...args) => new HIncrByCommand(args, this.opts).exec(this.client);
3338
+ /**
3339
+ * @see https://redis.io/commands/hincrbyfloat
3340
+ */
3341
+ hincrbyfloat = (...args) => new HIncrByFloatCommand(args, this.opts).exec(this.client);
3342
+ /**
3343
+ * @see https://redis.io/commands/hkeys
3344
+ */
3345
+ hkeys = (...args) => new HKeysCommand(args, this.opts).exec(this.client);
3346
+ /**
3347
+ * @see https://redis.io/commands/hlen
3348
+ */
3349
+ hlen = (...args) => new HLenCommand(args, this.opts).exec(this.client);
3350
+ /**
3351
+ * @see https://redis.io/commands/hmget
3352
+ */
3353
+ hmget = (...args) => new HMGetCommand(args, this.opts).exec(this.client);
3354
+ /**
3355
+ * @see https://redis.io/commands/hmset
3356
+ */
3357
+ hmset = (key, kv) => new HMSetCommand([key, kv], this.opts).exec(this.client);
3358
+ /**
3359
+ * @see https://redis.io/commands/hrandfield
3360
+ */
3361
+ hrandfield = (key, count, withValues) => new HRandFieldCommand([key, count, withValues], this.opts).exec(this.client);
3362
+ /**
3363
+ * @see https://redis.io/commands/hscan
3364
+ */
3365
+ hscan = (...args) => new HScanCommand(args, this.opts).exec(this.client);
3366
+ /**
3367
+ * @see https://redis.io/commands/hset
3368
+ */
3369
+ hset = (key, kv) => new HSetCommand([key, kv], this.opts).exec(this.client);
3370
+ /**
3371
+ * @see https://redis.io/commands/hsetnx
3372
+ */
3373
+ hsetnx = (key, field, value) => new HSetNXCommand([key, field, value], this.opts).exec(this.client);
3374
+ /**
3375
+ * @see https://redis.io/commands/hstrlen
3376
+ */
3377
+ hstrlen = (...args) => new HStrLenCommand(args, this.opts).exec(this.client);
3378
+ /**
3379
+ * @see https://redis.io/commands/hvals
3380
+ */
3381
+ hvals = (...args) => new HValsCommand(args, this.opts).exec(this.client);
3382
+ /**
3383
+ * @see https://redis.io/commands/incr
3384
+ */
3385
+ incr = (...args) => new IncrCommand(args, this.opts).exec(this.client);
3386
+ /**
3387
+ * @see https://redis.io/commands/incrby
3388
+ */
3389
+ incrby = (...args) => new IncrByCommand(args, this.opts).exec(this.client);
3390
+ /**
3391
+ * @see https://redis.io/commands/incrbyfloat
3392
+ */
3393
+ incrbyfloat = (...args) => new IncrByFloatCommand(args, this.opts).exec(this.client);
3394
+ /**
3395
+ * @see https://redis.io/commands/keys
3396
+ */
3397
+ keys = (...args) => new KeysCommand(args, this.opts).exec(this.client);
3398
+ /**
3399
+ * @see https://redis.io/commands/lindex
3400
+ */
3401
+ lindex = (...args) => new LIndexCommand(args, this.opts).exec(this.client);
3402
+ /**
3403
+ * @see https://redis.io/commands/linsert
3404
+ */
3405
+ linsert = (key, direction, pivot, value) => new LInsertCommand([key, direction, pivot, value], this.opts).exec(this.client);
3406
+ /**
3407
+ * @see https://redis.io/commands/llen
3408
+ */
3409
+ llen = (...args) => new LLenCommand(args, this.opts).exec(this.client);
3410
+ /**
3411
+ * @see https://redis.io/commands/lmove
3412
+ */
3413
+ lmove = (...args) => new LMoveCommand(args, this.opts).exec(this.client);
3414
+ /**
3415
+ * @see https://redis.io/commands/lpop
3416
+ */
3417
+ lpop = (...args) => new LPopCommand(args, this.opts).exec(this.client);
3418
+ /**
3419
+ * @see https://redis.io/commands/lmpop
3420
+ */
3421
+ lmpop = (...args) => new LmPopCommand(args, this.opts).exec(this.client);
3422
+ /**
3423
+ * @see https://redis.io/commands/lpos
3424
+ */
3425
+ lpos = (...args) => new LPosCommand(args, this.opts).exec(this.client);
3426
+ /**
3427
+ * @see https://redis.io/commands/lpush
3428
+ */
3429
+ lpush = (key, ...elements) => new LPushCommand([key, ...elements], this.opts).exec(this.client);
3430
+ /**
3431
+ * @see https://redis.io/commands/lpushx
3432
+ */
3433
+ lpushx = (key, ...elements) => new LPushXCommand([key, ...elements], this.opts).exec(this.client);
3434
+ /**
3435
+ * @see https://redis.io/commands/lrange
3436
+ */
3437
+ lrange = (...args) => new LRangeCommand(args, this.opts).exec(this.client);
3438
+ /**
3439
+ * @see https://redis.io/commands/lrem
3440
+ */
3441
+ lrem = (key, count, value) => new LRemCommand([key, count, value], this.opts).exec(this.client);
3442
+ /**
3443
+ * @see https://redis.io/commands/lset
3444
+ */
3445
+ lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
3446
+ /**
3447
+ * @see https://redis.io/commands/ltrim
3448
+ */
3449
+ ltrim = (...args) => new LTrimCommand(args, this.opts).exec(this.client);
3450
+ /**
3451
+ * @see https://redis.io/commands/mget
3452
+ */
3453
+ mget = (...args) => new MGetCommand(args, this.opts).exec(this.client);
3454
+ /**
3455
+ * @see https://redis.io/commands/mset
3456
+ */
3457
+ mset = (kv) => new MSetCommand([kv], this.opts).exec(this.client);
3458
+ /**
3459
+ * @see https://redis.io/commands/msetnx
3460
+ */
3461
+ msetnx = (kv) => new MSetNXCommand([kv], this.opts).exec(this.client);
3462
+ /**
3463
+ * @see https://redis.io/commands/persist
3464
+ */
3465
+ persist = (...args) => new PersistCommand(args, this.opts).exec(this.client);
3466
+ /**
3467
+ * @see https://redis.io/commands/pexpire
3468
+ */
3469
+ pexpire = (...args) => new PExpireCommand(args, this.opts).exec(this.client);
3470
+ /**
3471
+ * @see https://redis.io/commands/pexpireat
3472
+ */
3473
+ pexpireat = (...args) => new PExpireAtCommand(args, this.opts).exec(this.client);
3474
+ /**
3475
+ * @see https://redis.io/commands/pfadd
3476
+ */
3477
+ pfadd = (...args) => new PfAddCommand(args, this.opts).exec(this.client);
3478
+ /**
3479
+ * @see https://redis.io/commands/pfcount
3480
+ */
3481
+ pfcount = (...args) => new PfCountCommand(args, this.opts).exec(this.client);
3482
+ /**
3483
+ * @see https://redis.io/commands/pfmerge
3484
+ */
3485
+ pfmerge = (...args) => new PfMergeCommand(args, this.opts).exec(this.client);
3486
+ /**
3487
+ * @see https://redis.io/commands/ping
3488
+ */
3489
+ ping = (args) => new PingCommand(args, this.opts).exec(this.client);
3490
+ /**
3491
+ * @see https://redis.io/commands/psetex
3492
+ */
3493
+ psetex = (key, ttl, value) => new PSetEXCommand([key, ttl, value], this.opts).exec(this.client);
3494
+ /**
3495
+ * @see https://redis.io/commands/pttl
3496
+ */
3497
+ pttl = (...args) => new PTtlCommand(args, this.opts).exec(this.client);
3498
+ /**
3499
+ * @see https://redis.io/commands/publish
3500
+ */
3501
+ publish = (...args) => new PublishCommand(args, this.opts).exec(this.client);
3502
+ /**
3503
+ * @see https://redis.io/commands/randomkey
3504
+ */
3505
+ randomkey = () => new RandomKeyCommand().exec(this.client);
3506
+ /**
3507
+ * @see https://redis.io/commands/rename
3508
+ */
3509
+ rename = (...args) => new RenameCommand(args, this.opts).exec(this.client);
3510
+ /**
3511
+ * @see https://redis.io/commands/renamenx
3512
+ */
3513
+ renamenx = (...args) => new RenameNXCommand(args, this.opts).exec(this.client);
3514
+ /**
3515
+ * @see https://redis.io/commands/rpop
3516
+ */
3517
+ rpop = (...args) => new RPopCommand(args, this.opts).exec(this.client);
3518
+ /**
3519
+ * @see https://redis.io/commands/rpush
3520
+ */
3521
+ rpush = (key, ...elements) => new RPushCommand([key, ...elements], this.opts).exec(this.client);
3522
+ /**
3523
+ * @see https://redis.io/commands/rpushx
3524
+ */
3525
+ rpushx = (key, ...elements) => new RPushXCommand([key, ...elements], this.opts).exec(this.client);
3526
+ /**
3527
+ * @see https://redis.io/commands/sadd
3528
+ */
3529
+ sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
3530
+ /**
3531
+ * @see https://redis.io/commands/scan
3532
+ */
3533
+ scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
3534
+ /**
3535
+ * @see https://redis.io/commands/scard
3536
+ */
3537
+ scard = (...args) => new SCardCommand(args, this.opts).exec(this.client);
3538
+ /**
3539
+ * @see https://redis.io/commands/script-exists
3540
+ */
3541
+ scriptExists = (...args) => new ScriptExistsCommand(args, this.opts).exec(this.client);
3542
+ /**
3543
+ * @see https://redis.io/commands/script-flush
3544
+ */
3545
+ scriptFlush = (...args) => new ScriptFlushCommand(args, this.opts).exec(this.client);
3546
+ /**
3547
+ * @see https://redis.io/commands/script-load
3548
+ */
3549
+ scriptLoad = (...args) => new ScriptLoadCommand(args, this.opts).exec(this.client);
3550
+ /**
3551
+ * @see https://redis.io/commands/sdiff
3552
+ */
3553
+ sdiff = (...args) => new SDiffCommand(args, this.opts).exec(this.client);
3554
+ /**
3555
+ * @see https://redis.io/commands/sdiffstore
3556
+ */
3557
+ sdiffstore = (...args) => new SDiffStoreCommand(args, this.opts).exec(this.client);
3558
+ /**
3559
+ * @see https://redis.io/commands/set
3560
+ */
3561
+ set = (key, value, opts) => new SetCommand([key, value, opts], this.opts).exec(this.client);
3562
+ /**
3563
+ * @see https://redis.io/commands/setbit
3564
+ */
3565
+ setbit = (...args) => new SetBitCommand(args, this.opts).exec(this.client);
3566
+ /**
3567
+ * @see https://redis.io/commands/setex
3568
+ */
3569
+ setex = (key, ttl, value) => new SetExCommand([key, ttl, value], this.opts).exec(this.client);
3570
+ /**
3571
+ * @see https://redis.io/commands/setnx
3572
+ */
3573
+ setnx = (key, value) => new SetNxCommand([key, value], this.opts).exec(this.client);
3574
+ /**
3575
+ * @see https://redis.io/commands/setrange
3576
+ */
3577
+ setrange = (...args) => new SetRangeCommand(args, this.opts).exec(this.client);
3578
+ /**
3579
+ * @see https://redis.io/commands/sinter
3580
+ */
3581
+ sinter = (...args) => new SInterCommand(args, this.opts).exec(this.client);
3582
+ /**
3583
+ * @see https://redis.io/commands/sinterstore
3584
+ */
3585
+ sinterstore = (...args) => new SInterStoreCommand(args, this.opts).exec(this.client);
3586
+ /**
3587
+ * @see https://redis.io/commands/sismember
3588
+ */
3589
+ sismember = (key, member) => new SIsMemberCommand([key, member], this.opts).exec(this.client);
3590
+ /**
3591
+ * @see https://redis.io/commands/smismember
3592
+ */
3593
+ smismember = (key, members) => new SMIsMemberCommand([key, members], this.opts).exec(this.client);
3594
+ /**
3595
+ * @see https://redis.io/commands/smembers
3596
+ */
3597
+ smembers = (...args) => new SMembersCommand(args, this.opts).exec(this.client);
3598
+ /**
3599
+ * @see https://redis.io/commands/smove
3600
+ */
3601
+ smove = (source, destination, member) => new SMoveCommand([source, destination, member], this.opts).exec(this.client);
3602
+ /**
3603
+ * @see https://redis.io/commands/spop
3604
+ */
3605
+ spop = (...args) => new SPopCommand(args, this.opts).exec(this.client);
3606
+ /**
3607
+ * @see https://redis.io/commands/srandmember
3608
+ */
3609
+ srandmember = (...args) => new SRandMemberCommand(args, this.opts).exec(this.client);
3610
+ /**
3611
+ * @see https://redis.io/commands/srem
3612
+ */
3613
+ srem = (key, ...members) => new SRemCommand([key, ...members], this.opts).exec(this.client);
3614
+ /**
3615
+ * @see https://redis.io/commands/sscan
3616
+ */
3617
+ sscan = (...args) => new SScanCommand(args, this.opts).exec(this.client);
3618
+ /**
3619
+ * @see https://redis.io/commands/strlen
3620
+ */
3621
+ strlen = (...args) => new StrLenCommand(args, this.opts).exec(this.client);
3622
+ /**
3623
+ * @see https://redis.io/commands/sunion
3624
+ */
3625
+ sunion = (...args) => new SUnionCommand(args, this.opts).exec(this.client);
3626
+ /**
3627
+ * @see https://redis.io/commands/sunionstore
3628
+ */
3629
+ sunionstore = (...args) => new SUnionStoreCommand(args, this.opts).exec(this.client);
3630
+ /**
3631
+ * @see https://redis.io/commands/time
3632
+ */
3633
+ time = () => new TimeCommand().exec(this.client);
3634
+ /**
3635
+ * @see https://redis.io/commands/touch
3636
+ */
3637
+ touch = (...args) => new TouchCommand(args, this.opts).exec(this.client);
3638
+ /**
3639
+ * @see https://redis.io/commands/ttl
3640
+ */
3641
+ ttl = (...args) => new TtlCommand(args, this.opts).exec(this.client);
3642
+ /**
3643
+ * @see https://redis.io/commands/type
3644
+ */
3645
+ type = (...args) => new TypeCommand(args, this.opts).exec(this.client);
3646
+ /**
3647
+ * @see https://redis.io/commands/unlink
3648
+ */
3649
+ unlink = (...args) => new UnlinkCommand(args, this.opts).exec(this.client);
3650
+ /**
3651
+ * @see https://redis.io/commands/xadd
3652
+ */
3653
+ xadd = (...args) => new XAddCommand(args, this.opts).exec(this.client);
3654
+ /**
3655
+ * @see https://redis.io/commands/xack
3656
+ */
3657
+ xack = (...args) => new XAckCommand(args, this.opts).exec(this.client);
3658
+ /**
3659
+ * @see https://redis.io/commands/xdel
3660
+ */
3661
+ xdel = (...args) => new XDelCommand(args, this.opts).exec(this.client);
3662
+ /**
3663
+ * @see https://redis.io/commands/xgroup
3664
+ */
3665
+ xgroup = (...args) => new XGroupCommand(args, this.opts).exec(this.client);
3666
+ /**
3667
+ * @see https://redis.io/commands/xread
3668
+ */
3669
+ xread = (...args) => new XReadCommand(args, this.opts).exec(this.client);
3670
+ /**
3671
+ * @see https://redis.io/commands/xreadgroup
3672
+ */
3673
+ xreadgroup = (...args) => new XReadGroupCommand(args, this.opts).exec(this.client);
3674
+ /**
3675
+ * @see https://redis.io/commands/xinfo
3676
+ */
3677
+ xinfo = (...args) => new XInfoCommand(args, this.opts).exec(this.client);
3678
+ /**
3679
+ * @see https://redis.io/commands/xlen
3680
+ */
3681
+ xlen = (...args) => new XLenCommand(args, this.opts).exec(this.client);
3682
+ /**
3683
+ * @see https://redis.io/commands/xpending
3684
+ */
3685
+ xpending = (...args) => new XPendingCommand(args, this.opts).exec(this.client);
3686
+ /**
3687
+ * @see https://redis.io/commands/xclaim
3688
+ */
3689
+ xclaim = (...args) => new XClaimCommand(args, this.opts).exec(this.client);
3690
+ /**
3691
+ * @see https://redis.io/commands/xautoclaim
3692
+ */
3693
+ xautoclaim = (...args) => new XAutoClaim(args, this.opts).exec(this.client);
3694
+ /**
3695
+ * @see https://redis.io/commands/xtrim
3696
+ */
3697
+ xtrim = (...args) => new XTrimCommand(args, this.opts).exec(this.client);
3698
+ /**
3699
+ * @see https://redis.io/commands/xrange
3700
+ */
3701
+ xrange = (...args) => new XRangeCommand(args, this.opts).exec(this.client);
3702
+ /**
3703
+ * @see https://redis.io/commands/xrevrange
3704
+ */
3705
+ xrevrange = (...args) => new XRevRangeCommand(args, this.opts).exec(this.client);
3706
+ /**
3707
+ * @see https://redis.io/commands/zadd
3708
+ */
3709
+ zadd = (...args) => {
3710
+ if ("score" in args[1]) {
3711
+ return new ZAddCommand([args[0], args[1], ...args.slice(2)], this.opts).exec(
3712
+ this.client
3713
+ );
3714
+ }
3715
+ return new ZAddCommand(
3716
+ [args[0], args[1], ...args.slice(2)],
3717
+ this.opts
3718
+ ).exec(this.client);
3719
+ };
3720
+ /**
3721
+ * @see https://redis.io/commands/zcard
3722
+ */
3723
+ zcard = (...args) => new ZCardCommand(args, this.opts).exec(this.client);
3724
+ /**
3725
+ * @see https://redis.io/commands/zcount
3726
+ */
3727
+ zcount = (...args) => new ZCountCommand(args, this.opts).exec(this.client);
3728
+ /**
3729
+ * @see https://redis.io/commands/zdiffstore
3730
+ */
3731
+ zdiffstore = (...args) => new ZDiffStoreCommand(args, this.opts).exec(this.client);
3732
+ /**
3733
+ * @see https://redis.io/commands/zincrby
3734
+ */
3735
+ zincrby = (key, increment, member) => new ZIncrByCommand([key, increment, member], this.opts).exec(this.client);
3736
+ /**
3737
+ * @see https://redis.io/commands/zinterstore
3738
+ */
3739
+ zinterstore = (...args) => new ZInterStoreCommand(args, this.opts).exec(this.client);
3740
+ /**
3741
+ * @see https://redis.io/commands/zlexcount
3742
+ */
3743
+ zlexcount = (...args) => new ZLexCountCommand(args, this.opts).exec(this.client);
3744
+ /**
3745
+ * @see https://redis.io/commands/zmscore
3746
+ */
3747
+ zmscore = (...args) => new ZMScoreCommand(args, this.opts).exec(this.client);
3748
+ /**
3749
+ * @see https://redis.io/commands/zpopmax
3750
+ */
3751
+ zpopmax = (...args) => new ZPopMaxCommand(args, this.opts).exec(this.client);
3752
+ /**
3753
+ * @see https://redis.io/commands/zpopmin
3754
+ */
3755
+ zpopmin = (...args) => new ZPopMinCommand(args, this.opts).exec(this.client);
3756
+ /**
3757
+ * @see https://redis.io/commands/zrange
3758
+ */
3759
+ zrange = (...args) => new ZRangeCommand(args, this.opts).exec(this.client);
3760
+ /**
3761
+ * @see https://redis.io/commands/zrank
3762
+ */
3763
+ zrank = (key, member) => new ZRankCommand([key, member], this.opts).exec(this.client);
3764
+ /**
3765
+ * @see https://redis.io/commands/zrem
3766
+ */
3767
+ zrem = (key, ...members) => new ZRemCommand([key, ...members], this.opts).exec(this.client);
3768
+ /**
3769
+ * @see https://redis.io/commands/zremrangebylex
3770
+ */
3771
+ zremrangebylex = (...args) => new ZRemRangeByLexCommand(args, this.opts).exec(this.client);
3772
+ /**
3773
+ * @see https://redis.io/commands/zremrangebyrank
3774
+ */
3775
+ zremrangebyrank = (...args) => new ZRemRangeByRankCommand(args, this.opts).exec(this.client);
3776
+ /**
3777
+ * @see https://redis.io/commands/zremrangebyscore
3778
+ */
3779
+ zremrangebyscore = (...args) => new ZRemRangeByScoreCommand(args, this.opts).exec(this.client);
3780
+ /**
3781
+ * @see https://redis.io/commands/zrevrank
3782
+ */
3783
+ zrevrank = (key, member) => new ZRevRankCommand([key, member], this.opts).exec(this.client);
3784
+ /**
3785
+ * @see https://redis.io/commands/zscan
3786
+ */
3787
+ zscan = (...args) => new ZScanCommand(args, this.opts).exec(this.client);
3788
+ /**
3789
+ * @see https://redis.io/commands/zscore
3790
+ */
3791
+ zscore = (key, member) => new ZScoreCommand([key, member], this.opts).exec(this.client);
3792
+ /**
3793
+ * @see https://redis.io/commands/zunion
3794
+ */
3795
+ zunion = (...args) => new ZUnionCommand(args, this.opts).exec(this.client);
3796
+ /**
3797
+ * @see https://redis.io/commands/zunionstore
3798
+ */
3799
+ zunionstore = (...args) => new ZUnionStoreCommand(args, this.opts).exec(this.client);
3800
+ };
3801
+
3802
+ // version.ts
3803
+ var VERSION = "1.34.3-canary";
3804
+
3805
+ export {
3806
+ error_exports,
3807
+ HttpClient,
3808
+ Redis,
3809
+ VERSION
3810
+ };