@upstash/redis 0.0.0-ci.d9c08accc3bdd7a1d21f3d860e54e9cb1570f23e-20231214113223 → 0.0.0-ci.da1a5cb507eab3a0864199c49d02985f16e8bcd0-20250729064120

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