@upstash/redis 0.0.0-ci.f5cad9e7bda3d77569d9df207b4e1565f75d6154 → 0.0.0-ci.f6da5d747c9564bc95fccdbfe16a9aa10cd30367-20251125191507

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