@upstash/redis 0.0.0-ci.ee21c87148cceb1a3548ec2eaef164f04178a10f → 0.0.0-ci.ef1ca9829e359ba31196db06ff1da80cd201974b-20241009150255

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,3800 @@
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 (options) => {
2119
+ const start = performance.now();
2120
+ const result = await (options ? originalExec(options) : 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
+ exec = async (options) => {
2131
+ if (this.commands.length === 0) {
2132
+ throw new Error("Pipeline is empty");
2133
+ }
2134
+ const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
2135
+ const res = await this.client.request({
2136
+ path,
2137
+ body: Object.values(this.commands).map((c) => c.command)
2138
+ });
2139
+ return options?.keepErrors ? res.map(({ error, result }, i) => {
2140
+ return {
2141
+ error,
2142
+ result: this.commands[i].deserialize(result)
2143
+ };
2144
+ }) : res.map(({ error, result }, i) => {
2145
+ if (error) {
2146
+ throw new UpstashError(
2147
+ `Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
2148
+ );
2149
+ }
2150
+ return this.commands[i].deserialize(result);
2151
+ });
2152
+ };
2153
+ /**
2154
+ * Returns the length of pipeline before the execution
2155
+ */
2156
+ length() {
2157
+ return this.commands.length;
2158
+ }
2159
+ /**
2160
+ * Pushes a command into the pipeline and returns a chainable instance of the
2161
+ * pipeline
2162
+ */
2163
+ chain(command) {
2164
+ this.commands.push(command);
2165
+ return this;
2166
+ }
2167
+ /**
2168
+ * @see https://redis.io/commands/append
2169
+ */
2170
+ append = (...args) => this.chain(new AppendCommand(args, this.commandOptions));
2171
+ /**
2172
+ * @see https://redis.io/commands/bitcount
2173
+ */
2174
+ bitcount = (...args) => this.chain(new BitCountCommand(args, this.commandOptions));
2175
+ /**
2176
+ * Returns an instance that can be used to execute `BITFIELD` commands on one key.
2177
+ *
2178
+ * @example
2179
+ * ```typescript
2180
+ * redis.set("mykey", 0);
2181
+ * const result = await redis.pipeline()
2182
+ * .bitfield("mykey")
2183
+ * .set("u4", 0, 16)
2184
+ * .incr("u4", "#1", 1)
2185
+ * .exec();
2186
+ * console.log(result); // [[0, 1]]
2187
+ * ```
2188
+ *
2189
+ * @see https://redis.io/commands/bitfield
2190
+ */
2191
+ bitfield = (...args) => new BitFieldCommand(args, this.client, this.commandOptions, this.chain.bind(this));
2192
+ /**
2193
+ * @see https://redis.io/commands/bitop
2194
+ */
2195
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => this.chain(
2196
+ new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.commandOptions)
2197
+ );
2198
+ /**
2199
+ * @see https://redis.io/commands/bitpos
2200
+ */
2201
+ bitpos = (...args) => this.chain(new BitPosCommand(args, this.commandOptions));
2202
+ /**
2203
+ * @see https://redis.io/commands/copy
2204
+ */
2205
+ copy = (...args) => this.chain(new CopyCommand(args, this.commandOptions));
2206
+ /**
2207
+ * @see https://redis.io/commands/zdiffstore
2208
+ */
2209
+ zdiffstore = (...args) => this.chain(new ZDiffStoreCommand(args, this.commandOptions));
2210
+ /**
2211
+ * @see https://redis.io/commands/dbsize
2212
+ */
2213
+ dbsize = () => this.chain(new DBSizeCommand(this.commandOptions));
2214
+ /**
2215
+ * @see https://redis.io/commands/decr
2216
+ */
2217
+ decr = (...args) => this.chain(new DecrCommand(args, this.commandOptions));
2218
+ /**
2219
+ * @see https://redis.io/commands/decrby
2220
+ */
2221
+ decrby = (...args) => this.chain(new DecrByCommand(args, this.commandOptions));
2222
+ /**
2223
+ * @see https://redis.io/commands/del
2224
+ */
2225
+ del = (...args) => this.chain(new DelCommand(args, this.commandOptions));
2226
+ /**
2227
+ * @see https://redis.io/commands/echo
2228
+ */
2229
+ echo = (...args) => this.chain(new EchoCommand(args, this.commandOptions));
2230
+ /**
2231
+ * @see https://redis.io/commands/eval
2232
+ */
2233
+ eval = (...args) => this.chain(new EvalCommand(args, this.commandOptions));
2234
+ /**
2235
+ * @see https://redis.io/commands/evalsha
2236
+ */
2237
+ evalsha = (...args) => this.chain(new EvalshaCommand(args, this.commandOptions));
2238
+ /**
2239
+ * @see https://redis.io/commands/exists
2240
+ */
2241
+ exists = (...args) => this.chain(new ExistsCommand(args, this.commandOptions));
2242
+ /**
2243
+ * @see https://redis.io/commands/expire
2244
+ */
2245
+ expire = (...args) => this.chain(new ExpireCommand(args, this.commandOptions));
2246
+ /**
2247
+ * @see https://redis.io/commands/expireat
2248
+ */
2249
+ expireat = (...args) => this.chain(new ExpireAtCommand(args, this.commandOptions));
2250
+ /**
2251
+ * @see https://redis.io/commands/flushall
2252
+ */
2253
+ flushall = (args) => this.chain(new FlushAllCommand(args, this.commandOptions));
2254
+ /**
2255
+ * @see https://redis.io/commands/flushdb
2256
+ */
2257
+ flushdb = (...args) => this.chain(new FlushDBCommand(args, this.commandOptions));
2258
+ /**
2259
+ * @see https://redis.io/commands/geoadd
2260
+ */
2261
+ geoadd = (...args) => this.chain(new GeoAddCommand(args, this.commandOptions));
2262
+ /**
2263
+ * @see https://redis.io/commands/geodist
2264
+ */
2265
+ geodist = (...args) => this.chain(new GeoDistCommand(args, this.commandOptions));
2266
+ /**
2267
+ * @see https://redis.io/commands/geopos
2268
+ */
2269
+ geopos = (...args) => this.chain(new GeoPosCommand(args, this.commandOptions));
2270
+ /**
2271
+ * @see https://redis.io/commands/geohash
2272
+ */
2273
+ geohash = (...args) => this.chain(new GeoHashCommand(args, this.commandOptions));
2274
+ /**
2275
+ * @see https://redis.io/commands/geosearch
2276
+ */
2277
+ geosearch = (...args) => this.chain(new GeoSearchCommand(args, this.commandOptions));
2278
+ /**
2279
+ * @see https://redis.io/commands/geosearchstore
2280
+ */
2281
+ geosearchstore = (...args) => this.chain(new GeoSearchStoreCommand(args, this.commandOptions));
2282
+ /**
2283
+ * @see https://redis.io/commands/get
2284
+ */
2285
+ get = (...args) => this.chain(new GetCommand(args, this.commandOptions));
2286
+ /**
2287
+ * @see https://redis.io/commands/getbit
2288
+ */
2289
+ getbit = (...args) => this.chain(new GetBitCommand(args, this.commandOptions));
2290
+ /**
2291
+ * @see https://redis.io/commands/getdel
2292
+ */
2293
+ getdel = (...args) => this.chain(new GetDelCommand(args, this.commandOptions));
2294
+ /**
2295
+ * @see https://redis.io/commands/getrange
2296
+ */
2297
+ getrange = (...args) => this.chain(new GetRangeCommand(args, this.commandOptions));
2298
+ /**
2299
+ * @see https://redis.io/commands/getset
2300
+ */
2301
+ getset = (key, value) => this.chain(new GetSetCommand([key, value], this.commandOptions));
2302
+ /**
2303
+ * @see https://redis.io/commands/hdel
2304
+ */
2305
+ hdel = (...args) => this.chain(new HDelCommand(args, this.commandOptions));
2306
+ /**
2307
+ * @see https://redis.io/commands/hexists
2308
+ */
2309
+ hexists = (...args) => this.chain(new HExistsCommand(args, this.commandOptions));
2310
+ /**
2311
+ * @see https://redis.io/commands/hget
2312
+ */
2313
+ hget = (...args) => this.chain(new HGetCommand(args, this.commandOptions));
2314
+ /**
2315
+ * @see https://redis.io/commands/hgetall
2316
+ */
2317
+ hgetall = (...args) => this.chain(new HGetAllCommand(args, this.commandOptions));
2318
+ /**
2319
+ * @see https://redis.io/commands/hincrby
2320
+ */
2321
+ hincrby = (...args) => this.chain(new HIncrByCommand(args, this.commandOptions));
2322
+ /**
2323
+ * @see https://redis.io/commands/hincrbyfloat
2324
+ */
2325
+ hincrbyfloat = (...args) => this.chain(new HIncrByFloatCommand(args, this.commandOptions));
2326
+ /**
2327
+ * @see https://redis.io/commands/hkeys
2328
+ */
2329
+ hkeys = (...args) => this.chain(new HKeysCommand(args, this.commandOptions));
2330
+ /**
2331
+ * @see https://redis.io/commands/hlen
2332
+ */
2333
+ hlen = (...args) => this.chain(new HLenCommand(args, this.commandOptions));
2334
+ /**
2335
+ * @see https://redis.io/commands/hmget
2336
+ */
2337
+ hmget = (...args) => this.chain(new HMGetCommand(args, this.commandOptions));
2338
+ /**
2339
+ * @see https://redis.io/commands/hmset
2340
+ */
2341
+ hmset = (key, kv) => this.chain(new HMSetCommand([key, kv], this.commandOptions));
2342
+ /**
2343
+ * @see https://redis.io/commands/hrandfield
2344
+ */
2345
+ hrandfield = (key, count, withValues) => this.chain(new HRandFieldCommand([key, count, withValues], this.commandOptions));
2346
+ /**
2347
+ * @see https://redis.io/commands/hscan
2348
+ */
2349
+ hscan = (...args) => this.chain(new HScanCommand(args, this.commandOptions));
2350
+ /**
2351
+ * @see https://redis.io/commands/hset
2352
+ */
2353
+ hset = (key, kv) => this.chain(new HSetCommand([key, kv], this.commandOptions));
2354
+ /**
2355
+ * @see https://redis.io/commands/hsetnx
2356
+ */
2357
+ hsetnx = (key, field, value) => this.chain(new HSetNXCommand([key, field, value], this.commandOptions));
2358
+ /**
2359
+ * @see https://redis.io/commands/hstrlen
2360
+ */
2361
+ hstrlen = (...args) => this.chain(new HStrLenCommand(args, this.commandOptions));
2362
+ /**
2363
+ * @see https://redis.io/commands/hvals
2364
+ */
2365
+ hvals = (...args) => this.chain(new HValsCommand(args, this.commandOptions));
2366
+ /**
2367
+ * @see https://redis.io/commands/incr
2368
+ */
2369
+ incr = (...args) => this.chain(new IncrCommand(args, this.commandOptions));
2370
+ /**
2371
+ * @see https://redis.io/commands/incrby
2372
+ */
2373
+ incrby = (...args) => this.chain(new IncrByCommand(args, this.commandOptions));
2374
+ /**
2375
+ * @see https://redis.io/commands/incrbyfloat
2376
+ */
2377
+ incrbyfloat = (...args) => this.chain(new IncrByFloatCommand(args, this.commandOptions));
2378
+ /**
2379
+ * @see https://redis.io/commands/keys
2380
+ */
2381
+ keys = (...args) => this.chain(new KeysCommand(args, this.commandOptions));
2382
+ /**
2383
+ * @see https://redis.io/commands/lindex
2384
+ */
2385
+ lindex = (...args) => this.chain(new LIndexCommand(args, this.commandOptions));
2386
+ /**
2387
+ * @see https://redis.io/commands/linsert
2388
+ */
2389
+ linsert = (key, direction, pivot, value) => this.chain(new LInsertCommand([key, direction, pivot, value], this.commandOptions));
2390
+ /**
2391
+ * @see https://redis.io/commands/llen
2392
+ */
2393
+ llen = (...args) => this.chain(new LLenCommand(args, this.commandOptions));
2394
+ /**
2395
+ * @see https://redis.io/commands/lmove
2396
+ */
2397
+ lmove = (...args) => this.chain(new LMoveCommand(args, this.commandOptions));
2398
+ /**
2399
+ * @see https://redis.io/commands/lpop
2400
+ */
2401
+ lpop = (...args) => this.chain(new LPopCommand(args, this.commandOptions));
2402
+ /**
2403
+ * @see https://redis.io/commands/lmpop
2404
+ */
2405
+ lmpop = (...args) => this.chain(new LmPopCommand(args, this.commandOptions));
2406
+ /**
2407
+ * @see https://redis.io/commands/lpos
2408
+ */
2409
+ lpos = (...args) => this.chain(new LPosCommand(args, this.commandOptions));
2410
+ /**
2411
+ * @see https://redis.io/commands/lpush
2412
+ */
2413
+ lpush = (key, ...elements) => this.chain(new LPushCommand([key, ...elements], this.commandOptions));
2414
+ /**
2415
+ * @see https://redis.io/commands/lpushx
2416
+ */
2417
+ lpushx = (key, ...elements) => this.chain(new LPushXCommand([key, ...elements], this.commandOptions));
2418
+ /**
2419
+ * @see https://redis.io/commands/lrange
2420
+ */
2421
+ lrange = (...args) => this.chain(new LRangeCommand(args, this.commandOptions));
2422
+ /**
2423
+ * @see https://redis.io/commands/lrem
2424
+ */
2425
+ lrem = (key, count, value) => this.chain(new LRemCommand([key, count, value], this.commandOptions));
2426
+ /**
2427
+ * @see https://redis.io/commands/lset
2428
+ */
2429
+ lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
2430
+ /**
2431
+ * @see https://redis.io/commands/ltrim
2432
+ */
2433
+ ltrim = (...args) => this.chain(new LTrimCommand(args, this.commandOptions));
2434
+ /**
2435
+ * @see https://redis.io/commands/mget
2436
+ */
2437
+ mget = (...args) => this.chain(new MGetCommand(args, this.commandOptions));
2438
+ /**
2439
+ * @see https://redis.io/commands/mset
2440
+ */
2441
+ mset = (kv) => this.chain(new MSetCommand([kv], this.commandOptions));
2442
+ /**
2443
+ * @see https://redis.io/commands/msetnx
2444
+ */
2445
+ msetnx = (kv) => this.chain(new MSetNXCommand([kv], this.commandOptions));
2446
+ /**
2447
+ * @see https://redis.io/commands/persist
2448
+ */
2449
+ persist = (...args) => this.chain(new PersistCommand(args, this.commandOptions));
2450
+ /**
2451
+ * @see https://redis.io/commands/pexpire
2452
+ */
2453
+ pexpire = (...args) => this.chain(new PExpireCommand(args, this.commandOptions));
2454
+ /**
2455
+ * @see https://redis.io/commands/pexpireat
2456
+ */
2457
+ pexpireat = (...args) => this.chain(new PExpireAtCommand(args, this.commandOptions));
2458
+ /**
2459
+ * @see https://redis.io/commands/pfadd
2460
+ */
2461
+ pfadd = (...args) => this.chain(new PfAddCommand(args, this.commandOptions));
2462
+ /**
2463
+ * @see https://redis.io/commands/pfcount
2464
+ */
2465
+ pfcount = (...args) => this.chain(new PfCountCommand(args, this.commandOptions));
2466
+ /**
2467
+ * @see https://redis.io/commands/pfmerge
2468
+ */
2469
+ pfmerge = (...args) => this.chain(new PfMergeCommand(args, this.commandOptions));
2470
+ /**
2471
+ * @see https://redis.io/commands/ping
2472
+ */
2473
+ ping = (args) => this.chain(new PingCommand(args, this.commandOptions));
2474
+ /**
2475
+ * @see https://redis.io/commands/psetex
2476
+ */
2477
+ psetex = (key, ttl, value) => this.chain(new PSetEXCommand([key, ttl, value], this.commandOptions));
2478
+ /**
2479
+ * @see https://redis.io/commands/pttl
2480
+ */
2481
+ pttl = (...args) => this.chain(new PTtlCommand(args, this.commandOptions));
2482
+ /**
2483
+ * @see https://redis.io/commands/publish
2484
+ */
2485
+ publish = (...args) => this.chain(new PublishCommand(args, this.commandOptions));
2486
+ /**
2487
+ * @see https://redis.io/commands/randomkey
2488
+ */
2489
+ randomkey = () => this.chain(new RandomKeyCommand(this.commandOptions));
2490
+ /**
2491
+ * @see https://redis.io/commands/rename
2492
+ */
2493
+ rename = (...args) => this.chain(new RenameCommand(args, this.commandOptions));
2494
+ /**
2495
+ * @see https://redis.io/commands/renamenx
2496
+ */
2497
+ renamenx = (...args) => this.chain(new RenameNXCommand(args, this.commandOptions));
2498
+ /**
2499
+ * @see https://redis.io/commands/rpop
2500
+ */
2501
+ rpop = (...args) => this.chain(new RPopCommand(args, this.commandOptions));
2502
+ /**
2503
+ * @see https://redis.io/commands/rpush
2504
+ */
2505
+ rpush = (key, ...elements) => this.chain(new RPushCommand([key, ...elements], this.commandOptions));
2506
+ /**
2507
+ * @see https://redis.io/commands/rpushx
2508
+ */
2509
+ rpushx = (key, ...elements) => this.chain(new RPushXCommand([key, ...elements], this.commandOptions));
2510
+ /**
2511
+ * @see https://redis.io/commands/sadd
2512
+ */
2513
+ sadd = (key, member, ...members) => this.chain(new SAddCommand([key, member, ...members], this.commandOptions));
2514
+ /**
2515
+ * @see https://redis.io/commands/scan
2516
+ */
2517
+ scan = (...args) => this.chain(new ScanCommand(args, this.commandOptions));
2518
+ /**
2519
+ * @see https://redis.io/commands/scard
2520
+ */
2521
+ scard = (...args) => this.chain(new SCardCommand(args, this.commandOptions));
2522
+ /**
2523
+ * @see https://redis.io/commands/script-exists
2524
+ */
2525
+ scriptExists = (...args) => this.chain(new ScriptExistsCommand(args, this.commandOptions));
2526
+ /**
2527
+ * @see https://redis.io/commands/script-flush
2528
+ */
2529
+ scriptFlush = (...args) => this.chain(new ScriptFlushCommand(args, this.commandOptions));
2530
+ /**
2531
+ * @see https://redis.io/commands/script-load
2532
+ */
2533
+ scriptLoad = (...args) => this.chain(new ScriptLoadCommand(args, this.commandOptions));
2534
+ /*)*
2535
+ * @see https://redis.io/commands/sdiff
2536
+ */
2537
+ sdiff = (...args) => this.chain(new SDiffCommand(args, this.commandOptions));
2538
+ /**
2539
+ * @see https://redis.io/commands/sdiffstore
2540
+ */
2541
+ sdiffstore = (...args) => this.chain(new SDiffStoreCommand(args, this.commandOptions));
2542
+ /**
2543
+ * @see https://redis.io/commands/set
2544
+ */
2545
+ set = (key, value, opts) => this.chain(new SetCommand([key, value, opts], this.commandOptions));
2546
+ /**
2547
+ * @see https://redis.io/commands/setbit
2548
+ */
2549
+ setbit = (...args) => this.chain(new SetBitCommand(args, this.commandOptions));
2550
+ /**
2551
+ * @see https://redis.io/commands/setex
2552
+ */
2553
+ setex = (key, ttl, value) => this.chain(new SetExCommand([key, ttl, value], this.commandOptions));
2554
+ /**
2555
+ * @see https://redis.io/commands/setnx
2556
+ */
2557
+ setnx = (key, value) => this.chain(new SetNxCommand([key, value], this.commandOptions));
2558
+ /**
2559
+ * @see https://redis.io/commands/setrange
2560
+ */
2561
+ setrange = (...args) => this.chain(new SetRangeCommand(args, this.commandOptions));
2562
+ /**
2563
+ * @see https://redis.io/commands/sinter
2564
+ */
2565
+ sinter = (...args) => this.chain(new SInterCommand(args, this.commandOptions));
2566
+ /**
2567
+ * @see https://redis.io/commands/sinterstore
2568
+ */
2569
+ sinterstore = (...args) => this.chain(new SInterStoreCommand(args, this.commandOptions));
2570
+ /**
2571
+ * @see https://redis.io/commands/sismember
2572
+ */
2573
+ sismember = (key, member) => this.chain(new SIsMemberCommand([key, member], this.commandOptions));
2574
+ /**
2575
+ * @see https://redis.io/commands/smembers
2576
+ */
2577
+ smembers = (...args) => this.chain(new SMembersCommand(args, this.commandOptions));
2578
+ /**
2579
+ * @see https://redis.io/commands/smismember
2580
+ */
2581
+ smismember = (key, members) => this.chain(new SMIsMemberCommand([key, members], this.commandOptions));
2582
+ /**
2583
+ * @see https://redis.io/commands/smove
2584
+ */
2585
+ smove = (source, destination, member) => this.chain(new SMoveCommand([source, destination, member], this.commandOptions));
2586
+ /**
2587
+ * @see https://redis.io/commands/spop
2588
+ */
2589
+ spop = (...args) => this.chain(new SPopCommand(args, this.commandOptions));
2590
+ /**
2591
+ * @see https://redis.io/commands/srandmember
2592
+ */
2593
+ srandmember = (...args) => this.chain(new SRandMemberCommand(args, this.commandOptions));
2594
+ /**
2595
+ * @see https://redis.io/commands/srem
2596
+ */
2597
+ srem = (key, ...members) => this.chain(new SRemCommand([key, ...members], this.commandOptions));
2598
+ /**
2599
+ * @see https://redis.io/commands/sscan
2600
+ */
2601
+ sscan = (...args) => this.chain(new SScanCommand(args, this.commandOptions));
2602
+ /**
2603
+ * @see https://redis.io/commands/strlen
2604
+ */
2605
+ strlen = (...args) => this.chain(new StrLenCommand(args, this.commandOptions));
2606
+ /**
2607
+ * @see https://redis.io/commands/sunion
2608
+ */
2609
+ sunion = (...args) => this.chain(new SUnionCommand(args, this.commandOptions));
2610
+ /**
2611
+ * @see https://redis.io/commands/sunionstore
2612
+ */
2613
+ sunionstore = (...args) => this.chain(new SUnionStoreCommand(args, this.commandOptions));
2614
+ /**
2615
+ * @see https://redis.io/commands/time
2616
+ */
2617
+ time = () => this.chain(new TimeCommand(this.commandOptions));
2618
+ /**
2619
+ * @see https://redis.io/commands/touch
2620
+ */
2621
+ touch = (...args) => this.chain(new TouchCommand(args, this.commandOptions));
2622
+ /**
2623
+ * @see https://redis.io/commands/ttl
2624
+ */
2625
+ ttl = (...args) => this.chain(new TtlCommand(args, this.commandOptions));
2626
+ /**
2627
+ * @see https://redis.io/commands/type
2628
+ */
2629
+ type = (...args) => this.chain(new TypeCommand(args, this.commandOptions));
2630
+ /**
2631
+ * @see https://redis.io/commands/unlink
2632
+ */
2633
+ unlink = (...args) => this.chain(new UnlinkCommand(args, this.commandOptions));
2634
+ /**
2635
+ * @see https://redis.io/commands/zadd
2636
+ */
2637
+ zadd = (...args) => {
2638
+ if ("score" in args[1]) {
2639
+ return this.chain(
2640
+ new ZAddCommand([args[0], args[1], ...args.slice(2)], this.commandOptions)
2641
+ );
2642
+ }
2643
+ return this.chain(
2644
+ new ZAddCommand(
2645
+ [args[0], args[1], ...args.slice(2)],
2646
+ this.commandOptions
2647
+ )
2648
+ );
2649
+ };
2650
+ /**
2651
+ * @see https://redis.io/commands/xadd
2652
+ */
2653
+ xadd = (...args) => this.chain(new XAddCommand(args, this.commandOptions));
2654
+ /**
2655
+ * @see https://redis.io/commands/xack
2656
+ */
2657
+ xack = (...args) => this.chain(new XAckCommand(args, this.commandOptions));
2658
+ /**
2659
+ * @see https://redis.io/commands/xdel
2660
+ */
2661
+ xdel = (...args) => this.chain(new XDelCommand(args, this.commandOptions));
2662
+ /**
2663
+ * @see https://redis.io/commands/xgroup
2664
+ */
2665
+ xgroup = (...args) => this.chain(new XGroupCommand(args, this.commandOptions));
2666
+ /**
2667
+ * @see https://redis.io/commands/xread
2668
+ */
2669
+ xread = (...args) => this.chain(new XReadCommand(args, this.commandOptions));
2670
+ /**
2671
+ * @see https://redis.io/commands/xreadgroup
2672
+ */
2673
+ xreadgroup = (...args) => this.chain(new XReadGroupCommand(args, this.commandOptions));
2674
+ /**
2675
+ * @see https://redis.io/commands/xinfo
2676
+ */
2677
+ xinfo = (...args) => this.chain(new XInfoCommand(args, this.commandOptions));
2678
+ /**
2679
+ * @see https://redis.io/commands/xlen
2680
+ */
2681
+ xlen = (...args) => this.chain(new XLenCommand(args, this.commandOptions));
2682
+ /**
2683
+ * @see https://redis.io/commands/xpending
2684
+ */
2685
+ xpending = (...args) => this.chain(new XPendingCommand(args, this.commandOptions));
2686
+ /**
2687
+ * @see https://redis.io/commands/xclaim
2688
+ */
2689
+ xclaim = (...args) => this.chain(new XClaimCommand(args, this.commandOptions));
2690
+ /**
2691
+ * @see https://redis.io/commands/xautoclaim
2692
+ */
2693
+ xautoclaim = (...args) => this.chain(new XAutoClaim(args, this.commandOptions));
2694
+ /**
2695
+ * @see https://redis.io/commands/xtrim
2696
+ */
2697
+ xtrim = (...args) => this.chain(new XTrimCommand(args, this.commandOptions));
2698
+ /**
2699
+ * @see https://redis.io/commands/xrange
2700
+ */
2701
+ xrange = (...args) => this.chain(new XRangeCommand(args, this.commandOptions));
2702
+ /**
2703
+ * @see https://redis.io/commands/xrevrange
2704
+ */
2705
+ xrevrange = (...args) => this.chain(new XRevRangeCommand(args, this.commandOptions));
2706
+ /**
2707
+ * @see https://redis.io/commands/zcard
2708
+ */
2709
+ zcard = (...args) => this.chain(new ZCardCommand(args, this.commandOptions));
2710
+ /**
2711
+ * @see https://redis.io/commands/zcount
2712
+ */
2713
+ zcount = (...args) => this.chain(new ZCountCommand(args, this.commandOptions));
2714
+ /**
2715
+ * @see https://redis.io/commands/zincrby
2716
+ */
2717
+ zincrby = (key, increment, member) => this.chain(new ZIncrByCommand([key, increment, member], this.commandOptions));
2718
+ /**
2719
+ * @see https://redis.io/commands/zinterstore
2720
+ */
2721
+ zinterstore = (...args) => this.chain(new ZInterStoreCommand(args, this.commandOptions));
2722
+ /**
2723
+ * @see https://redis.io/commands/zlexcount
2724
+ */
2725
+ zlexcount = (...args) => this.chain(new ZLexCountCommand(args, this.commandOptions));
2726
+ /**
2727
+ * @see https://redis.io/commands/zmscore
2728
+ */
2729
+ zmscore = (...args) => this.chain(new ZMScoreCommand(args, this.commandOptions));
2730
+ /**
2731
+ * @see https://redis.io/commands/zpopmax
2732
+ */
2733
+ zpopmax = (...args) => this.chain(new ZPopMaxCommand(args, this.commandOptions));
2734
+ /**
2735
+ * @see https://redis.io/commands/zpopmin
2736
+ */
2737
+ zpopmin = (...args) => this.chain(new ZPopMinCommand(args, this.commandOptions));
2738
+ /**
2739
+ * @see https://redis.io/commands/zrange
2740
+ */
2741
+ zrange = (...args) => this.chain(new ZRangeCommand(args, this.commandOptions));
2742
+ /**
2743
+ * @see https://redis.io/commands/zrank
2744
+ */
2745
+ zrank = (key, member) => this.chain(new ZRankCommand([key, member], this.commandOptions));
2746
+ /**
2747
+ * @see https://redis.io/commands/zrem
2748
+ */
2749
+ zrem = (key, ...members) => this.chain(new ZRemCommand([key, ...members], this.commandOptions));
2750
+ /**
2751
+ * @see https://redis.io/commands/zremrangebylex
2752
+ */
2753
+ zremrangebylex = (...args) => this.chain(new ZRemRangeByLexCommand(args, this.commandOptions));
2754
+ /**
2755
+ * @see https://redis.io/commands/zremrangebyrank
2756
+ */
2757
+ zremrangebyrank = (...args) => this.chain(new ZRemRangeByRankCommand(args, this.commandOptions));
2758
+ /**
2759
+ * @see https://redis.io/commands/zremrangebyscore
2760
+ */
2761
+ zremrangebyscore = (...args) => this.chain(new ZRemRangeByScoreCommand(args, this.commandOptions));
2762
+ /**
2763
+ * @see https://redis.io/commands/zrevrank
2764
+ */
2765
+ zrevrank = (key, member) => this.chain(new ZRevRankCommand([key, member], this.commandOptions));
2766
+ /**
2767
+ * @see https://redis.io/commands/zscan
2768
+ */
2769
+ zscan = (...args) => this.chain(new ZScanCommand(args, this.commandOptions));
2770
+ /**
2771
+ * @see https://redis.io/commands/zscore
2772
+ */
2773
+ zscore = (key, member) => this.chain(new ZScoreCommand([key, member], this.commandOptions));
2774
+ /**
2775
+ * @see https://redis.io/commands/zunionstore
2776
+ */
2777
+ zunionstore = (...args) => this.chain(new ZUnionStoreCommand(args, this.commandOptions));
2778
+ /**
2779
+ * @see https://redis.io/commands/zunion
2780
+ */
2781
+ zunion = (...args) => this.chain(new ZUnionCommand(args, this.commandOptions));
2782
+ /**
2783
+ * @see https://redis.io/commands/?group=json
2784
+ */
2785
+ get json() {
2786
+ return {
2787
+ /**
2788
+ * @see https://redis.io/commands/json.arrappend
2789
+ */
2790
+ arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
2791
+ /**
2792
+ * @see https://redis.io/commands/json.arrindex
2793
+ */
2794
+ arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
2795
+ /**
2796
+ * @see https://redis.io/commands/json.arrinsert
2797
+ */
2798
+ arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
2799
+ /**
2800
+ * @see https://redis.io/commands/json.arrlen
2801
+ */
2802
+ arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
2803
+ /**
2804
+ * @see https://redis.io/commands/json.arrpop
2805
+ */
2806
+ arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
2807
+ /**
2808
+ * @see https://redis.io/commands/json.arrtrim
2809
+ */
2810
+ arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
2811
+ /**
2812
+ * @see https://redis.io/commands/json.clear
2813
+ */
2814
+ clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
2815
+ /**
2816
+ * @see https://redis.io/commands/json.del
2817
+ */
2818
+ del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
2819
+ /**
2820
+ * @see https://redis.io/commands/json.forget
2821
+ */
2822
+ forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
2823
+ /**
2824
+ * @see https://redis.io/commands/json.get
2825
+ */
2826
+ get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
2827
+ /**
2828
+ * @see https://redis.io/commands/json.mget
2829
+ */
2830
+ mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
2831
+ /**
2832
+ * @see https://redis.io/commands/json.mset
2833
+ */
2834
+ mset: (...args) => this.chain(new JsonMSetCommand(args, this.commandOptions)),
2835
+ /**
2836
+ * @see https://redis.io/commands/json.numincrby
2837
+ */
2838
+ numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
2839
+ /**
2840
+ * @see https://redis.io/commands/json.nummultby
2841
+ */
2842
+ nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
2843
+ /**
2844
+ * @see https://redis.io/commands/json.objkeys
2845
+ */
2846
+ objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
2847
+ /**
2848
+ * @see https://redis.io/commands/json.objlen
2849
+ */
2850
+ objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
2851
+ /**
2852
+ * @see https://redis.io/commands/json.resp
2853
+ */
2854
+ resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
2855
+ /**
2856
+ * @see https://redis.io/commands/json.set
2857
+ */
2858
+ set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
2859
+ /**
2860
+ * @see https://redis.io/commands/json.strappend
2861
+ */
2862
+ strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
2863
+ /**
2864
+ * @see https://redis.io/commands/json.strlen
2865
+ */
2866
+ strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
2867
+ /**
2868
+ * @see https://redis.io/commands/json.toggle
2869
+ */
2870
+ toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
2871
+ /**
2872
+ * @see https://redis.io/commands/json.type
2873
+ */
2874
+ type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
2875
+ };
2876
+ }
2877
+ };
2878
+
2879
+ // pkg/auto-pipeline.ts
2880
+ function createAutoPipelineProxy(_redis, json) {
2881
+ const redis = _redis;
2882
+ if (!redis.autoPipelineExecutor) {
2883
+ redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
2884
+ }
2885
+ return new Proxy(redis, {
2886
+ get: (redis2, command) => {
2887
+ if (command === "pipelineCounter") {
2888
+ return redis2.autoPipelineExecutor.pipelineCounter;
2889
+ }
2890
+ if (command === "json") {
2891
+ return createAutoPipelineProxy(redis2, true);
2892
+ }
2893
+ const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
2894
+ if (commandInRedisButNotPipeline) {
2895
+ return redis2[command];
2896
+ }
2897
+ const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
2898
+ if (isFunction) {
2899
+ return (...args) => {
2900
+ return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
2901
+ if (json) {
2902
+ pipeline.json[command](
2903
+ ...args
2904
+ );
2905
+ } else {
2906
+ pipeline[command](...args);
2907
+ }
2908
+ });
2909
+ };
2910
+ }
2911
+ return redis2.autoPipelineExecutor.pipeline[command];
2912
+ }
2913
+ });
2914
+ }
2915
+ var AutoPipelineExecutor = class {
2916
+ pipelinePromises = /* @__PURE__ */ new WeakMap();
2917
+ activePipeline = null;
2918
+ indexInCurrentPipeline = 0;
2919
+ redis;
2920
+ pipeline;
2921
+ // only to make sure that proxy can work
2922
+ pipelineCounter = 0;
2923
+ // to keep track of how many times a pipeline was executed
2924
+ constructor(redis) {
2925
+ this.redis = redis;
2926
+ this.pipeline = redis.pipeline();
2927
+ }
2928
+ async withAutoPipeline(executeWithPipeline) {
2929
+ const pipeline = this.activePipeline ?? this.redis.pipeline();
2930
+ if (!this.activePipeline) {
2931
+ this.activePipeline = pipeline;
2932
+ this.indexInCurrentPipeline = 0;
2933
+ }
2934
+ const index = this.indexInCurrentPipeline++;
2935
+ executeWithPipeline(pipeline);
2936
+ const pipelineDone = this.deferExecution().then(() => {
2937
+ if (!this.pipelinePromises.has(pipeline)) {
2938
+ const pipelinePromise = pipeline.exec({ keepErrors: true });
2939
+ this.pipelineCounter += 1;
2940
+ this.pipelinePromises.set(pipeline, pipelinePromise);
2941
+ this.activePipeline = null;
2942
+ }
2943
+ return this.pipelinePromises.get(pipeline);
2944
+ });
2945
+ const results = await pipelineDone;
2946
+ const commandResult = results[index];
2947
+ if (commandResult.error) {
2948
+ throw new UpstashError(`Command failed: ${commandResult.error}`);
2949
+ }
2950
+ return commandResult.result;
2951
+ }
2952
+ async deferExecution() {
2953
+ await Promise.resolve();
2954
+ await Promise.resolve();
2955
+ }
2956
+ };
2957
+
2958
+ // pkg/script.ts
2959
+ import Hex from "crypto-js/enc-hex.js";
2960
+ import sha1 from "crypto-js/sha1.js";
2961
+ var Script = class {
2962
+ script;
2963
+ sha1;
2964
+ redis;
2965
+ constructor(redis, script) {
2966
+ this.redis = redis;
2967
+ this.sha1 = this.digest(script);
2968
+ this.script = script;
2969
+ }
2970
+ /**
2971
+ * Send an `EVAL` command to redis.
2972
+ */
2973
+ async eval(keys, args) {
2974
+ return await this.redis.eval(this.script, keys, args);
2975
+ }
2976
+ /**
2977
+ * Calculates the sha1 hash of the script and then calls `EVALSHA`.
2978
+ */
2979
+ async evalsha(keys, args) {
2980
+ return await this.redis.evalsha(this.sha1, keys, args);
2981
+ }
2982
+ /**
2983
+ * Optimistically try to run `EVALSHA` first.
2984
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL`.
2985
+ *
2986
+ * Following calls will be able to use the cached script
2987
+ */
2988
+ async exec(keys, args) {
2989
+ const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
2990
+ if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
2991
+ return await this.redis.eval(this.script, keys, args);
2992
+ }
2993
+ throw error;
2994
+ });
2995
+ return res;
2996
+ }
2997
+ /**
2998
+ * Compute the sha1 hash of the script and return its hex representation.
2999
+ */
3000
+ digest(s) {
3001
+ return Hex.stringify(sha1(s));
3002
+ }
3003
+ };
3004
+
3005
+ // pkg/redis.ts
3006
+ var Redis = class {
3007
+ client;
3008
+ opts;
3009
+ enableTelemetry;
3010
+ enableAutoPipelining;
3011
+ /**
3012
+ * Create a new redis client
3013
+ *
3014
+ * @example
3015
+ * ```typescript
3016
+ * const redis = new Redis({
3017
+ * url: "<UPSTASH_REDIS_REST_URL>",
3018
+ * token: "<UPSTASH_REDIS_REST_TOKEN>",
3019
+ * });
3020
+ * ```
3021
+ */
3022
+ constructor(client, opts) {
3023
+ this.client = client;
3024
+ this.opts = opts;
3025
+ this.enableTelemetry = opts?.enableTelemetry ?? true;
3026
+ if (opts?.readYourWrites === false) {
3027
+ this.client.readYourWrites = false;
3028
+ }
3029
+ this.enableAutoPipelining = opts?.enableAutoPipelining ?? true;
3030
+ }
3031
+ get readYourWritesSyncToken() {
3032
+ return this.client.upstashSyncToken;
3033
+ }
3034
+ set readYourWritesSyncToken(session) {
3035
+ this.client.upstashSyncToken = session;
3036
+ }
3037
+ get json() {
3038
+ return {
3039
+ /**
3040
+ * @see https://redis.io/commands/json.arrappend
3041
+ */
3042
+ arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
3043
+ /**
3044
+ * @see https://redis.io/commands/json.arrindex
3045
+ */
3046
+ arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
3047
+ /**
3048
+ * @see https://redis.io/commands/json.arrinsert
3049
+ */
3050
+ arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
3051
+ /**
3052
+ * @see https://redis.io/commands/json.arrlen
3053
+ */
3054
+ arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
3055
+ /**
3056
+ * @see https://redis.io/commands/json.arrpop
3057
+ */
3058
+ arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
3059
+ /**
3060
+ * @see https://redis.io/commands/json.arrtrim
3061
+ */
3062
+ arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
3063
+ /**
3064
+ * @see https://redis.io/commands/json.clear
3065
+ */
3066
+ clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
3067
+ /**
3068
+ * @see https://redis.io/commands/json.del
3069
+ */
3070
+ del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
3071
+ /**
3072
+ * @see https://redis.io/commands/json.forget
3073
+ */
3074
+ forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
3075
+ /**
3076
+ * @see https://redis.io/commands/json.get
3077
+ */
3078
+ get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
3079
+ /**
3080
+ * @see https://redis.io/commands/json.mget
3081
+ */
3082
+ mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
3083
+ /**
3084
+ * @see https://redis.io/commands/json.mset
3085
+ */
3086
+ mset: (...args) => new JsonMSetCommand(args, this.opts).exec(this.client),
3087
+ /**
3088
+ * @see https://redis.io/commands/json.numincrby
3089
+ */
3090
+ numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
3091
+ /**
3092
+ * @see https://redis.io/commands/json.nummultby
3093
+ */
3094
+ nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
3095
+ /**
3096
+ * @see https://redis.io/commands/json.objkeys
3097
+ */
3098
+ objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
3099
+ /**
3100
+ * @see https://redis.io/commands/json.objlen
3101
+ */
3102
+ objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
3103
+ /**
3104
+ * @see https://redis.io/commands/json.resp
3105
+ */
3106
+ resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
3107
+ /**
3108
+ * @see https://redis.io/commands/json.set
3109
+ */
3110
+ set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
3111
+ /**
3112
+ * @see https://redis.io/commands/json.strappend
3113
+ */
3114
+ strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
3115
+ /**
3116
+ * @see https://redis.io/commands/json.strlen
3117
+ */
3118
+ strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
3119
+ /**
3120
+ * @see https://redis.io/commands/json.toggle
3121
+ */
3122
+ toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
3123
+ /**
3124
+ * @see https://redis.io/commands/json.type
3125
+ */
3126
+ type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
3127
+ };
3128
+ }
3129
+ /**
3130
+ * Wrap a new middleware around the HTTP client.
3131
+ */
3132
+ use = (middleware) => {
3133
+ const makeRequest = this.client.request.bind(this.client);
3134
+ this.client.request = (req) => middleware(req, makeRequest);
3135
+ };
3136
+ /**
3137
+ * Technically this is not private, we can hide it from intellisense by doing this
3138
+ */
3139
+ addTelemetry = (telemetry) => {
3140
+ if (!this.enableTelemetry) {
3141
+ return;
3142
+ }
3143
+ try {
3144
+ this.client.mergeTelemetry(telemetry);
3145
+ } catch {
3146
+ }
3147
+ };
3148
+ createScript(script) {
3149
+ return new Script(this, script);
3150
+ }
3151
+ /**
3152
+ * Create a new pipeline that allows you to send requests in bulk.
3153
+ *
3154
+ * @see {@link Pipeline}
3155
+ */
3156
+ pipeline = () => new Pipeline({
3157
+ client: this.client,
3158
+ commandOptions: this.opts,
3159
+ multiExec: false
3160
+ });
3161
+ autoPipeline = () => {
3162
+ return createAutoPipelineProxy(this);
3163
+ };
3164
+ /**
3165
+ * Create a new transaction to allow executing multiple steps atomically.
3166
+ *
3167
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
3168
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
3169
+ * guarantees that the commands are executed as a single isolated operation.
3170
+ *
3171
+ * @see {@link Pipeline}
3172
+ */
3173
+ multi = () => new Pipeline({
3174
+ client: this.client,
3175
+ commandOptions: this.opts,
3176
+ multiExec: true
3177
+ });
3178
+ /**
3179
+ * Returns an instance that can be used to execute `BITFIELD` commands on one key.
3180
+ *
3181
+ * @example
3182
+ * ```typescript
3183
+ * redis.set("mykey", 0);
3184
+ * const result = await redis.bitfield("mykey")
3185
+ * .set("u4", 0, 16)
3186
+ * .incr("u4", "#1", 1)
3187
+ * .exec();
3188
+ * console.log(result); // [0, 1]
3189
+ * ```
3190
+ *
3191
+ * @see https://redis.io/commands/bitfield
3192
+ */
3193
+ bitfield = (...args) => new BitFieldCommand(args, this.client, this.opts);
3194
+ /**
3195
+ * @see https://redis.io/commands/append
3196
+ */
3197
+ append = (...args) => new AppendCommand(args, this.opts).exec(this.client);
3198
+ /**
3199
+ * @see https://redis.io/commands/bitcount
3200
+ */
3201
+ bitcount = (...args) => new BitCountCommand(args, this.opts).exec(this.client);
3202
+ /**
3203
+ * @see https://redis.io/commands/bitop
3204
+ */
3205
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.opts).exec(
3206
+ this.client
3207
+ );
3208
+ /**
3209
+ * @see https://redis.io/commands/bitpos
3210
+ */
3211
+ bitpos = (...args) => new BitPosCommand(args, this.opts).exec(this.client);
3212
+ /**
3213
+ * @see https://redis.io/commands/copy
3214
+ */
3215
+ copy = (...args) => new CopyCommand(args, this.opts).exec(this.client);
3216
+ /**
3217
+ * @see https://redis.io/commands/dbsize
3218
+ */
3219
+ dbsize = () => new DBSizeCommand(this.opts).exec(this.client);
3220
+ /**
3221
+ * @see https://redis.io/commands/decr
3222
+ */
3223
+ decr = (...args) => new DecrCommand(args, this.opts).exec(this.client);
3224
+ /**
3225
+ * @see https://redis.io/commands/decrby
3226
+ */
3227
+ decrby = (...args) => new DecrByCommand(args, this.opts).exec(this.client);
3228
+ /**
3229
+ * @see https://redis.io/commands/del
3230
+ */
3231
+ del = (...args) => new DelCommand(args, this.opts).exec(this.client);
3232
+ /**
3233
+ * @see https://redis.io/commands/echo
3234
+ */
3235
+ echo = (...args) => new EchoCommand(args, this.opts).exec(this.client);
3236
+ /**
3237
+ * @see https://redis.io/commands/eval
3238
+ */
3239
+ eval = (...args) => new EvalCommand(args, this.opts).exec(this.client);
3240
+ /**
3241
+ * @see https://redis.io/commands/evalsha
3242
+ */
3243
+ evalsha = (...args) => new EvalshaCommand(args, this.opts).exec(this.client);
3244
+ /**
3245
+ * @see https://redis.io/commands/exists
3246
+ */
3247
+ exists = (...args) => new ExistsCommand(args, this.opts).exec(this.client);
3248
+ /**
3249
+ * @see https://redis.io/commands/expire
3250
+ */
3251
+ expire = (...args) => new ExpireCommand(args, this.opts).exec(this.client);
3252
+ /**
3253
+ * @see https://redis.io/commands/expireat
3254
+ */
3255
+ expireat = (...args) => new ExpireAtCommand(args, this.opts).exec(this.client);
3256
+ /**
3257
+ * @see https://redis.io/commands/flushall
3258
+ */
3259
+ flushall = (args) => new FlushAllCommand(args, this.opts).exec(this.client);
3260
+ /**
3261
+ * @see https://redis.io/commands/flushdb
3262
+ */
3263
+ flushdb = (...args) => new FlushDBCommand(args, this.opts).exec(this.client);
3264
+ /**
3265
+ * @see https://redis.io/commands/geoadd
3266
+ */
3267
+ geoadd = (...args) => new GeoAddCommand(args, this.opts).exec(this.client);
3268
+ /**
3269
+ * @see https://redis.io/commands/geopos
3270
+ */
3271
+ geopos = (...args) => new GeoPosCommand(args, this.opts).exec(this.client);
3272
+ /**
3273
+ * @see https://redis.io/commands/geodist
3274
+ */
3275
+ geodist = (...args) => new GeoDistCommand(args, this.opts).exec(this.client);
3276
+ /**
3277
+ * @see https://redis.io/commands/geohash
3278
+ */
3279
+ geohash = (...args) => new GeoHashCommand(args, this.opts).exec(this.client);
3280
+ /**
3281
+ * @see https://redis.io/commands/geosearch
3282
+ */
3283
+ geosearch = (...args) => new GeoSearchCommand(args, this.opts).exec(this.client);
3284
+ /**
3285
+ * @see https://redis.io/commands/geosearchstore
3286
+ */
3287
+ geosearchstore = (...args) => new GeoSearchStoreCommand(args, this.opts).exec(this.client);
3288
+ /**
3289
+ * @see https://redis.io/commands/get
3290
+ */
3291
+ get = (...args) => new GetCommand(args, this.opts).exec(this.client);
3292
+ /**
3293
+ * @see https://redis.io/commands/getbit
3294
+ */
3295
+ getbit = (...args) => new GetBitCommand(args, this.opts).exec(this.client);
3296
+ /**
3297
+ * @see https://redis.io/commands/getdel
3298
+ */
3299
+ getdel = (...args) => new GetDelCommand(args, this.opts).exec(this.client);
3300
+ /**
3301
+ * @see https://redis.io/commands/getrange
3302
+ */
3303
+ getrange = (...args) => new GetRangeCommand(args, this.opts).exec(this.client);
3304
+ /**
3305
+ * @see https://redis.io/commands/getset
3306
+ */
3307
+ getset = (key, value) => new GetSetCommand([key, value], this.opts).exec(this.client);
3308
+ /**
3309
+ * @see https://redis.io/commands/hdel
3310
+ */
3311
+ hdel = (...args) => new HDelCommand(args, this.opts).exec(this.client);
3312
+ /**
3313
+ * @see https://redis.io/commands/hexists
3314
+ */
3315
+ hexists = (...args) => new HExistsCommand(args, this.opts).exec(this.client);
3316
+ /**
3317
+ * @see https://redis.io/commands/hget
3318
+ */
3319
+ hget = (...args) => new HGetCommand(args, this.opts).exec(this.client);
3320
+ /**
3321
+ * @see https://redis.io/commands/hgetall
3322
+ */
3323
+ hgetall = (...args) => new HGetAllCommand(args, this.opts).exec(this.client);
3324
+ /**
3325
+ * @see https://redis.io/commands/hincrby
3326
+ */
3327
+ hincrby = (...args) => new HIncrByCommand(args, this.opts).exec(this.client);
3328
+ /**
3329
+ * @see https://redis.io/commands/hincrbyfloat
3330
+ */
3331
+ hincrbyfloat = (...args) => new HIncrByFloatCommand(args, this.opts).exec(this.client);
3332
+ /**
3333
+ * @see https://redis.io/commands/hkeys
3334
+ */
3335
+ hkeys = (...args) => new HKeysCommand(args, this.opts).exec(this.client);
3336
+ /**
3337
+ * @see https://redis.io/commands/hlen
3338
+ */
3339
+ hlen = (...args) => new HLenCommand(args, this.opts).exec(this.client);
3340
+ /**
3341
+ * @see https://redis.io/commands/hmget
3342
+ */
3343
+ hmget = (...args) => new HMGetCommand(args, this.opts).exec(this.client);
3344
+ /**
3345
+ * @see https://redis.io/commands/hmset
3346
+ */
3347
+ hmset = (key, kv) => new HMSetCommand([key, kv], this.opts).exec(this.client);
3348
+ /**
3349
+ * @see https://redis.io/commands/hrandfield
3350
+ */
3351
+ hrandfield = (key, count, withValues) => new HRandFieldCommand([key, count, withValues], this.opts).exec(this.client);
3352
+ /**
3353
+ * @see https://redis.io/commands/hscan
3354
+ */
3355
+ hscan = (...args) => new HScanCommand(args, this.opts).exec(this.client);
3356
+ /**
3357
+ * @see https://redis.io/commands/hset
3358
+ */
3359
+ hset = (key, kv) => new HSetCommand([key, kv], this.opts).exec(this.client);
3360
+ /**
3361
+ * @see https://redis.io/commands/hsetnx
3362
+ */
3363
+ hsetnx = (key, field, value) => new HSetNXCommand([key, field, value], this.opts).exec(this.client);
3364
+ /**
3365
+ * @see https://redis.io/commands/hstrlen
3366
+ */
3367
+ hstrlen = (...args) => new HStrLenCommand(args, this.opts).exec(this.client);
3368
+ /**
3369
+ * @see https://redis.io/commands/hvals
3370
+ */
3371
+ hvals = (...args) => new HValsCommand(args, this.opts).exec(this.client);
3372
+ /**
3373
+ * @see https://redis.io/commands/incr
3374
+ */
3375
+ incr = (...args) => new IncrCommand(args, this.opts).exec(this.client);
3376
+ /**
3377
+ * @see https://redis.io/commands/incrby
3378
+ */
3379
+ incrby = (...args) => new IncrByCommand(args, this.opts).exec(this.client);
3380
+ /**
3381
+ * @see https://redis.io/commands/incrbyfloat
3382
+ */
3383
+ incrbyfloat = (...args) => new IncrByFloatCommand(args, this.opts).exec(this.client);
3384
+ /**
3385
+ * @see https://redis.io/commands/keys
3386
+ */
3387
+ keys = (...args) => new KeysCommand(args, this.opts).exec(this.client);
3388
+ /**
3389
+ * @see https://redis.io/commands/lindex
3390
+ */
3391
+ lindex = (...args) => new LIndexCommand(args, this.opts).exec(this.client);
3392
+ /**
3393
+ * @see https://redis.io/commands/linsert
3394
+ */
3395
+ linsert = (key, direction, pivot, value) => new LInsertCommand([key, direction, pivot, value], this.opts).exec(this.client);
3396
+ /**
3397
+ * @see https://redis.io/commands/llen
3398
+ */
3399
+ llen = (...args) => new LLenCommand(args, this.opts).exec(this.client);
3400
+ /**
3401
+ * @see https://redis.io/commands/lmove
3402
+ */
3403
+ lmove = (...args) => new LMoveCommand(args, this.opts).exec(this.client);
3404
+ /**
3405
+ * @see https://redis.io/commands/lpop
3406
+ */
3407
+ lpop = (...args) => new LPopCommand(args, this.opts).exec(this.client);
3408
+ /**
3409
+ * @see https://redis.io/commands/lmpop
3410
+ */
3411
+ lmpop = (...args) => new LmPopCommand(args, this.opts).exec(this.client);
3412
+ /**
3413
+ * @see https://redis.io/commands/lpos
3414
+ */
3415
+ lpos = (...args) => new LPosCommand(args, this.opts).exec(this.client);
3416
+ /**
3417
+ * @see https://redis.io/commands/lpush
3418
+ */
3419
+ lpush = (key, ...elements) => new LPushCommand([key, ...elements], this.opts).exec(this.client);
3420
+ /**
3421
+ * @see https://redis.io/commands/lpushx
3422
+ */
3423
+ lpushx = (key, ...elements) => new LPushXCommand([key, ...elements], this.opts).exec(this.client);
3424
+ /**
3425
+ * @see https://redis.io/commands/lrange
3426
+ */
3427
+ lrange = (...args) => new LRangeCommand(args, this.opts).exec(this.client);
3428
+ /**
3429
+ * @see https://redis.io/commands/lrem
3430
+ */
3431
+ lrem = (key, count, value) => new LRemCommand([key, count, value], this.opts).exec(this.client);
3432
+ /**
3433
+ * @see https://redis.io/commands/lset
3434
+ */
3435
+ lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
3436
+ /**
3437
+ * @see https://redis.io/commands/ltrim
3438
+ */
3439
+ ltrim = (...args) => new LTrimCommand(args, this.opts).exec(this.client);
3440
+ /**
3441
+ * @see https://redis.io/commands/mget
3442
+ */
3443
+ mget = (...args) => new MGetCommand(args, this.opts).exec(this.client);
3444
+ /**
3445
+ * @see https://redis.io/commands/mset
3446
+ */
3447
+ mset = (kv) => new MSetCommand([kv], this.opts).exec(this.client);
3448
+ /**
3449
+ * @see https://redis.io/commands/msetnx
3450
+ */
3451
+ msetnx = (kv) => new MSetNXCommand([kv], this.opts).exec(this.client);
3452
+ /**
3453
+ * @see https://redis.io/commands/persist
3454
+ */
3455
+ persist = (...args) => new PersistCommand(args, this.opts).exec(this.client);
3456
+ /**
3457
+ * @see https://redis.io/commands/pexpire
3458
+ */
3459
+ pexpire = (...args) => new PExpireCommand(args, this.opts).exec(this.client);
3460
+ /**
3461
+ * @see https://redis.io/commands/pexpireat
3462
+ */
3463
+ pexpireat = (...args) => new PExpireAtCommand(args, this.opts).exec(this.client);
3464
+ /**
3465
+ * @see https://redis.io/commands/pfadd
3466
+ */
3467
+ pfadd = (...args) => new PfAddCommand(args, this.opts).exec(this.client);
3468
+ /**
3469
+ * @see https://redis.io/commands/pfcount
3470
+ */
3471
+ pfcount = (...args) => new PfCountCommand(args, this.opts).exec(this.client);
3472
+ /**
3473
+ * @see https://redis.io/commands/pfmerge
3474
+ */
3475
+ pfmerge = (...args) => new PfMergeCommand(args, this.opts).exec(this.client);
3476
+ /**
3477
+ * @see https://redis.io/commands/ping
3478
+ */
3479
+ ping = (args) => new PingCommand(args, this.opts).exec(this.client);
3480
+ /**
3481
+ * @see https://redis.io/commands/psetex
3482
+ */
3483
+ psetex = (key, ttl, value) => new PSetEXCommand([key, ttl, value], this.opts).exec(this.client);
3484
+ /**
3485
+ * @see https://redis.io/commands/pttl
3486
+ */
3487
+ pttl = (...args) => new PTtlCommand(args, this.opts).exec(this.client);
3488
+ /**
3489
+ * @see https://redis.io/commands/publish
3490
+ */
3491
+ publish = (...args) => new PublishCommand(args, this.opts).exec(this.client);
3492
+ /**
3493
+ * @see https://redis.io/commands/randomkey
3494
+ */
3495
+ randomkey = () => new RandomKeyCommand().exec(this.client);
3496
+ /**
3497
+ * @see https://redis.io/commands/rename
3498
+ */
3499
+ rename = (...args) => new RenameCommand(args, this.opts).exec(this.client);
3500
+ /**
3501
+ * @see https://redis.io/commands/renamenx
3502
+ */
3503
+ renamenx = (...args) => new RenameNXCommand(args, this.opts).exec(this.client);
3504
+ /**
3505
+ * @see https://redis.io/commands/rpop
3506
+ */
3507
+ rpop = (...args) => new RPopCommand(args, this.opts).exec(this.client);
3508
+ /**
3509
+ * @see https://redis.io/commands/rpush
3510
+ */
3511
+ rpush = (key, ...elements) => new RPushCommand([key, ...elements], this.opts).exec(this.client);
3512
+ /**
3513
+ * @see https://redis.io/commands/rpushx
3514
+ */
3515
+ rpushx = (key, ...elements) => new RPushXCommand([key, ...elements], this.opts).exec(this.client);
3516
+ /**
3517
+ * @see https://redis.io/commands/sadd
3518
+ */
3519
+ sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
3520
+ /**
3521
+ * @see https://redis.io/commands/scan
3522
+ */
3523
+ scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
3524
+ /**
3525
+ * @see https://redis.io/commands/scard
3526
+ */
3527
+ scard = (...args) => new SCardCommand(args, this.opts).exec(this.client);
3528
+ /**
3529
+ * @see https://redis.io/commands/script-exists
3530
+ */
3531
+ scriptExists = (...args) => new ScriptExistsCommand(args, this.opts).exec(this.client);
3532
+ /**
3533
+ * @see https://redis.io/commands/script-flush
3534
+ */
3535
+ scriptFlush = (...args) => new ScriptFlushCommand(args, this.opts).exec(this.client);
3536
+ /**
3537
+ * @see https://redis.io/commands/script-load
3538
+ */
3539
+ scriptLoad = (...args) => new ScriptLoadCommand(args, this.opts).exec(this.client);
3540
+ /**
3541
+ * @see https://redis.io/commands/sdiff
3542
+ */
3543
+ sdiff = (...args) => new SDiffCommand(args, this.opts).exec(this.client);
3544
+ /**
3545
+ * @see https://redis.io/commands/sdiffstore
3546
+ */
3547
+ sdiffstore = (...args) => new SDiffStoreCommand(args, this.opts).exec(this.client);
3548
+ /**
3549
+ * @see https://redis.io/commands/set
3550
+ */
3551
+ set = (key, value, opts) => new SetCommand([key, value, opts], this.opts).exec(this.client);
3552
+ /**
3553
+ * @see https://redis.io/commands/setbit
3554
+ */
3555
+ setbit = (...args) => new SetBitCommand(args, this.opts).exec(this.client);
3556
+ /**
3557
+ * @see https://redis.io/commands/setex
3558
+ */
3559
+ setex = (key, ttl, value) => new SetExCommand([key, ttl, value], this.opts).exec(this.client);
3560
+ /**
3561
+ * @see https://redis.io/commands/setnx
3562
+ */
3563
+ setnx = (key, value) => new SetNxCommand([key, value], this.opts).exec(this.client);
3564
+ /**
3565
+ * @see https://redis.io/commands/setrange
3566
+ */
3567
+ setrange = (...args) => new SetRangeCommand(args, this.opts).exec(this.client);
3568
+ /**
3569
+ * @see https://redis.io/commands/sinter
3570
+ */
3571
+ sinter = (...args) => new SInterCommand(args, this.opts).exec(this.client);
3572
+ /**
3573
+ * @see https://redis.io/commands/sinterstore
3574
+ */
3575
+ sinterstore = (...args) => new SInterStoreCommand(args, this.opts).exec(this.client);
3576
+ /**
3577
+ * @see https://redis.io/commands/sismember
3578
+ */
3579
+ sismember = (key, member) => new SIsMemberCommand([key, member], this.opts).exec(this.client);
3580
+ /**
3581
+ * @see https://redis.io/commands/smismember
3582
+ */
3583
+ smismember = (key, members) => new SMIsMemberCommand([key, members], this.opts).exec(this.client);
3584
+ /**
3585
+ * @see https://redis.io/commands/smembers
3586
+ */
3587
+ smembers = (...args) => new SMembersCommand(args, this.opts).exec(this.client);
3588
+ /**
3589
+ * @see https://redis.io/commands/smove
3590
+ */
3591
+ smove = (source, destination, member) => new SMoveCommand([source, destination, member], this.opts).exec(this.client);
3592
+ /**
3593
+ * @see https://redis.io/commands/spop
3594
+ */
3595
+ spop = (...args) => new SPopCommand(args, this.opts).exec(this.client);
3596
+ /**
3597
+ * @see https://redis.io/commands/srandmember
3598
+ */
3599
+ srandmember = (...args) => new SRandMemberCommand(args, this.opts).exec(this.client);
3600
+ /**
3601
+ * @see https://redis.io/commands/srem
3602
+ */
3603
+ srem = (key, ...members) => new SRemCommand([key, ...members], this.opts).exec(this.client);
3604
+ /**
3605
+ * @see https://redis.io/commands/sscan
3606
+ */
3607
+ sscan = (...args) => new SScanCommand(args, this.opts).exec(this.client);
3608
+ /**
3609
+ * @see https://redis.io/commands/strlen
3610
+ */
3611
+ strlen = (...args) => new StrLenCommand(args, this.opts).exec(this.client);
3612
+ /**
3613
+ * @see https://redis.io/commands/sunion
3614
+ */
3615
+ sunion = (...args) => new SUnionCommand(args, this.opts).exec(this.client);
3616
+ /**
3617
+ * @see https://redis.io/commands/sunionstore
3618
+ */
3619
+ sunionstore = (...args) => new SUnionStoreCommand(args, this.opts).exec(this.client);
3620
+ /**
3621
+ * @see https://redis.io/commands/time
3622
+ */
3623
+ time = () => new TimeCommand().exec(this.client);
3624
+ /**
3625
+ * @see https://redis.io/commands/touch
3626
+ */
3627
+ touch = (...args) => new TouchCommand(args, this.opts).exec(this.client);
3628
+ /**
3629
+ * @see https://redis.io/commands/ttl
3630
+ */
3631
+ ttl = (...args) => new TtlCommand(args, this.opts).exec(this.client);
3632
+ /**
3633
+ * @see https://redis.io/commands/type
3634
+ */
3635
+ type = (...args) => new TypeCommand(args, this.opts).exec(this.client);
3636
+ /**
3637
+ * @see https://redis.io/commands/unlink
3638
+ */
3639
+ unlink = (...args) => new UnlinkCommand(args, this.opts).exec(this.client);
3640
+ /**
3641
+ * @see https://redis.io/commands/xadd
3642
+ */
3643
+ xadd = (...args) => new XAddCommand(args, this.opts).exec(this.client);
3644
+ /**
3645
+ * @see https://redis.io/commands/xack
3646
+ */
3647
+ xack = (...args) => new XAckCommand(args, this.opts).exec(this.client);
3648
+ /**
3649
+ * @see https://redis.io/commands/xdel
3650
+ */
3651
+ xdel = (...args) => new XDelCommand(args, this.opts).exec(this.client);
3652
+ /**
3653
+ * @see https://redis.io/commands/xgroup
3654
+ */
3655
+ xgroup = (...args) => new XGroupCommand(args, this.opts).exec(this.client);
3656
+ /**
3657
+ * @see https://redis.io/commands/xread
3658
+ */
3659
+ xread = (...args) => new XReadCommand(args, this.opts).exec(this.client);
3660
+ /**
3661
+ * @see https://redis.io/commands/xreadgroup
3662
+ */
3663
+ xreadgroup = (...args) => new XReadGroupCommand(args, this.opts).exec(this.client);
3664
+ /**
3665
+ * @see https://redis.io/commands/xinfo
3666
+ */
3667
+ xinfo = (...args) => new XInfoCommand(args, this.opts).exec(this.client);
3668
+ /**
3669
+ * @see https://redis.io/commands/xlen
3670
+ */
3671
+ xlen = (...args) => new XLenCommand(args, this.opts).exec(this.client);
3672
+ /**
3673
+ * @see https://redis.io/commands/xpending
3674
+ */
3675
+ xpending = (...args) => new XPendingCommand(args, this.opts).exec(this.client);
3676
+ /**
3677
+ * @see https://redis.io/commands/xclaim
3678
+ */
3679
+ xclaim = (...args) => new XClaimCommand(args, this.opts).exec(this.client);
3680
+ /**
3681
+ * @see https://redis.io/commands/xautoclaim
3682
+ */
3683
+ xautoclaim = (...args) => new XAutoClaim(args, this.opts).exec(this.client);
3684
+ /**
3685
+ * @see https://redis.io/commands/xtrim
3686
+ */
3687
+ xtrim = (...args) => new XTrimCommand(args, this.opts).exec(this.client);
3688
+ /**
3689
+ * @see https://redis.io/commands/xrange
3690
+ */
3691
+ xrange = (...args) => new XRangeCommand(args, this.opts).exec(this.client);
3692
+ /**
3693
+ * @see https://redis.io/commands/xrevrange
3694
+ */
3695
+ xrevrange = (...args) => new XRevRangeCommand(args, this.opts).exec(this.client);
3696
+ /**
3697
+ * @see https://redis.io/commands/zadd
3698
+ */
3699
+ zadd = (...args) => {
3700
+ if ("score" in args[1]) {
3701
+ return new ZAddCommand([args[0], args[1], ...args.slice(2)], this.opts).exec(
3702
+ this.client
3703
+ );
3704
+ }
3705
+ return new ZAddCommand(
3706
+ [args[0], args[1], ...args.slice(2)],
3707
+ this.opts
3708
+ ).exec(this.client);
3709
+ };
3710
+ /**
3711
+ * @see https://redis.io/commands/zcard
3712
+ */
3713
+ zcard = (...args) => new ZCardCommand(args, this.opts).exec(this.client);
3714
+ /**
3715
+ * @see https://redis.io/commands/zcount
3716
+ */
3717
+ zcount = (...args) => new ZCountCommand(args, this.opts).exec(this.client);
3718
+ /**
3719
+ * @see https://redis.io/commands/zdiffstore
3720
+ */
3721
+ zdiffstore = (...args) => new ZDiffStoreCommand(args, this.opts).exec(this.client);
3722
+ /**
3723
+ * @see https://redis.io/commands/zincrby
3724
+ */
3725
+ zincrby = (key, increment, member) => new ZIncrByCommand([key, increment, member], this.opts).exec(this.client);
3726
+ /**
3727
+ * @see https://redis.io/commands/zinterstore
3728
+ */
3729
+ zinterstore = (...args) => new ZInterStoreCommand(args, this.opts).exec(this.client);
3730
+ /**
3731
+ * @see https://redis.io/commands/zlexcount
3732
+ */
3733
+ zlexcount = (...args) => new ZLexCountCommand(args, this.opts).exec(this.client);
3734
+ /**
3735
+ * @see https://redis.io/commands/zmscore
3736
+ */
3737
+ zmscore = (...args) => new ZMScoreCommand(args, this.opts).exec(this.client);
3738
+ /**
3739
+ * @see https://redis.io/commands/zpopmax
3740
+ */
3741
+ zpopmax = (...args) => new ZPopMaxCommand(args, this.opts).exec(this.client);
3742
+ /**
3743
+ * @see https://redis.io/commands/zpopmin
3744
+ */
3745
+ zpopmin = (...args) => new ZPopMinCommand(args, this.opts).exec(this.client);
3746
+ /**
3747
+ * @see https://redis.io/commands/zrange
3748
+ */
3749
+ zrange = (...args) => new ZRangeCommand(args, this.opts).exec(this.client);
3750
+ /**
3751
+ * @see https://redis.io/commands/zrank
3752
+ */
3753
+ zrank = (key, member) => new ZRankCommand([key, member], this.opts).exec(this.client);
3754
+ /**
3755
+ * @see https://redis.io/commands/zrem
3756
+ */
3757
+ zrem = (key, ...members) => new ZRemCommand([key, ...members], this.opts).exec(this.client);
3758
+ /**
3759
+ * @see https://redis.io/commands/zremrangebylex
3760
+ */
3761
+ zremrangebylex = (...args) => new ZRemRangeByLexCommand(args, this.opts).exec(this.client);
3762
+ /**
3763
+ * @see https://redis.io/commands/zremrangebyrank
3764
+ */
3765
+ zremrangebyrank = (...args) => new ZRemRangeByRankCommand(args, this.opts).exec(this.client);
3766
+ /**
3767
+ * @see https://redis.io/commands/zremrangebyscore
3768
+ */
3769
+ zremrangebyscore = (...args) => new ZRemRangeByScoreCommand(args, this.opts).exec(this.client);
3770
+ /**
3771
+ * @see https://redis.io/commands/zrevrank
3772
+ */
3773
+ zrevrank = (key, member) => new ZRevRankCommand([key, member], this.opts).exec(this.client);
3774
+ /**
3775
+ * @see https://redis.io/commands/zscan
3776
+ */
3777
+ zscan = (...args) => new ZScanCommand(args, this.opts).exec(this.client);
3778
+ /**
3779
+ * @see https://redis.io/commands/zscore
3780
+ */
3781
+ zscore = (key, member) => new ZScoreCommand([key, member], this.opts).exec(this.client);
3782
+ /**
3783
+ * @see https://redis.io/commands/zunion
3784
+ */
3785
+ zunion = (...args) => new ZUnionCommand(args, this.opts).exec(this.client);
3786
+ /**
3787
+ * @see https://redis.io/commands/zunionstore
3788
+ */
3789
+ zunionstore = (...args) => new ZUnionStoreCommand(args, this.opts).exec(this.client);
3790
+ };
3791
+
3792
+ // version.ts
3793
+ var VERSION = "v1.30.2";
3794
+
3795
+ export {
3796
+ error_exports,
3797
+ HttpClient,
3798
+ Redis,
3799
+ VERSION
3800
+ };