@upstash/redis 0.0.0-ci.c00b02de3221a40eb48a9e0e9fecd434abda4dc2-20240703080528 → 0.0.0-ci.c21ca079c33c67efb29ee43e778ab181aeed6386-20250530111221

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