@upstash/redis 1.34.1 → 1.34.2

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