@upstash/redis 0.0.0-ci.e475de1f85007c6e91b7c723aae0092693599d18-20231218212441 → 0.0.0-ci.e4eab2833c7196d06833dccf8f132ddbc18c2cfa-20241008071408

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