@upstash/redis 0.0.0-ci.a0519b405e783d33aa4660281b294551474ad898 → 0.0.0-ci.a08f1ca1ac3e3818ac32fe7e8306468d98e05e0e-20250131161917

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