@upstash/redis 0.2.1 → 1.0.0-alpha.0

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.
package/dist/index.js ADDED
@@ -0,0 +1,1750 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __reExport = (target, module2, copyDefault, desc) => {
25
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
26
+ for (let key of __getOwnPropNames(module2))
27
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
28
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
29
+ }
30
+ return target;
31
+ };
32
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
33
+ return (module2, temp) => {
34
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
35
+ };
36
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
37
+
38
+ // pkg/index.ts
39
+ var pkg_exports = {};
40
+ __export(pkg_exports, {
41
+ Redis: () => Redis,
42
+ UpstashError: () => UpstashError
43
+ });
44
+
45
+ // pkg/http.ts
46
+ var import_isomorphic_fetch = require("isomorphic-fetch");
47
+
48
+ // pkg/error.ts
49
+ var UpstashError = class extends Error {
50
+ constructor(message) {
51
+ super(message);
52
+ this.name = "UpstashError";
53
+ }
54
+ };
55
+
56
+ // pkg/http.ts
57
+ var HttpClient = class {
58
+ constructor(config) {
59
+ var _a;
60
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
61
+ this.headers = (_a = config.headers) != null ? _a : {};
62
+ }
63
+ async request(method, req) {
64
+ if (!req.path) {
65
+ req.path = [];
66
+ }
67
+ const headers = __spreadValues(__spreadValues({
68
+ "Content-Type": "application/json"
69
+ }, this.headers), req.headers);
70
+ const res = await fetch([this.baseUrl, ...req.path].join("/"), {
71
+ method,
72
+ headers,
73
+ body: JSON.stringify(req.body)
74
+ });
75
+ const body = await res.json();
76
+ if (!res.ok) {
77
+ throw new UpstashError(body.error);
78
+ }
79
+ return body;
80
+ }
81
+ async post(req) {
82
+ return await this.request("POST", req);
83
+ }
84
+ };
85
+
86
+ // pkg/util.ts
87
+ function parseRecursive(obj) {
88
+ return Array.isArray(obj) ? obj.map((o) => {
89
+ try {
90
+ return parseRecursive(o);
91
+ } catch {
92
+ return o;
93
+ }
94
+ }) : JSON.parse(obj);
95
+ }
96
+ function parseResponse(result) {
97
+ try {
98
+ return parseRecursive(result);
99
+ } catch {
100
+ return result;
101
+ }
102
+ }
103
+
104
+ // pkg/command.ts
105
+ var Command = class {
106
+ constructor(command, opts) {
107
+ var _a;
108
+ this.command = command.map((c) => typeof c === "string" ? c : JSON.stringify(c));
109
+ this.deserialize = (_a = opts == null ? void 0 : opts.deserialize) != null ? _a : parseResponse;
110
+ }
111
+ async exec(client) {
112
+ const { result, error } = await client.post({
113
+ body: this.command
114
+ });
115
+ if (error) {
116
+ throw new UpstashError(error);
117
+ }
118
+ if (typeof result === "undefined") {
119
+ throw new Error(`Request did not return a result`);
120
+ }
121
+ return this.deserialize(result);
122
+ }
123
+ };
124
+
125
+ // pkg/commands/append.ts
126
+ var AppendCommand = class extends Command {
127
+ constructor(key, value) {
128
+ super(["append", key, value]);
129
+ }
130
+ };
131
+
132
+ // pkg/commands/bitcount.ts
133
+ var BitCountCommand = class extends Command {
134
+ constructor(key, start, end) {
135
+ const command = ["bitcount", key];
136
+ if (typeof start === "number") {
137
+ command.push(start);
138
+ }
139
+ if (typeof end === "number") {
140
+ command.push(end);
141
+ }
142
+ super(command);
143
+ }
144
+ };
145
+
146
+ // pkg/commands/bitop.ts
147
+ var BitOpCommand = class extends Command {
148
+ constructor(op, destinationKey, sourceKey, ...sourceKeys) {
149
+ super(["bitop", op, destinationKey, sourceKey, ...sourceKeys]);
150
+ }
151
+ };
152
+
153
+ // pkg/commands/bitpos.ts
154
+ var BitPosCommand = class extends Command {
155
+ constructor(key, start, end) {
156
+ super(["bitpos", key, start, end]);
157
+ }
158
+ };
159
+
160
+ // pkg/commands/dbsize.ts
161
+ var DBSizeCommand = class extends Command {
162
+ constructor() {
163
+ super(["dbsize"]);
164
+ }
165
+ };
166
+
167
+ // pkg/commands/decr.ts
168
+ var DecrCommand = class extends Command {
169
+ constructor(key) {
170
+ super(["decr", key]);
171
+ }
172
+ };
173
+
174
+ // pkg/commands/decrby.ts
175
+ var DecrByCommand = class extends Command {
176
+ constructor(key, decrement) {
177
+ super(["decrby", key, decrement]);
178
+ }
179
+ };
180
+
181
+ // pkg/commands/del.ts
182
+ var DelCommand = class extends Command {
183
+ constructor(...keys) {
184
+ super(["del", ...keys]);
185
+ }
186
+ };
187
+
188
+ // pkg/commands/echo.ts
189
+ var EchoCommand = class extends Command {
190
+ constructor(message) {
191
+ super(["echo", message]);
192
+ }
193
+ };
194
+
195
+ // pkg/commands/exists.ts
196
+ var ExistsCommand = class extends Command {
197
+ constructor(...keys) {
198
+ super(["exists", ...keys]);
199
+ }
200
+ };
201
+
202
+ // pkg/commands/expire.ts
203
+ var ExpireCommand = class extends Command {
204
+ constructor(key, seconds) {
205
+ super(["expire", key, seconds]);
206
+ }
207
+ };
208
+
209
+ // pkg/commands/expireat.ts
210
+ var ExpireAtCommand = class extends Command {
211
+ constructor(key, unix) {
212
+ super(["expireat", key, unix]);
213
+ }
214
+ };
215
+
216
+ // pkg/commands/flushall.ts
217
+ var FlushAllCommand = class extends Command {
218
+ constructor(opts) {
219
+ const command = ["flushall"];
220
+ if (opts == null ? void 0 : opts.async) {
221
+ command.push("async");
222
+ }
223
+ super(command);
224
+ }
225
+ };
226
+
227
+ // pkg/commands/flushdb.ts
228
+ var FlushDBCommand = class extends Command {
229
+ constructor(opts) {
230
+ const command = ["flushdb"];
231
+ if (opts == null ? void 0 : opts.async) {
232
+ command.push("async");
233
+ }
234
+ super(command);
235
+ }
236
+ };
237
+
238
+ // pkg/commands/get.ts
239
+ var GetCommand = class extends Command {
240
+ constructor(key) {
241
+ super(["get", key]);
242
+ }
243
+ };
244
+
245
+ // pkg/commands/getbit.ts
246
+ var GetBitCommand = class extends Command {
247
+ constructor(key, offset) {
248
+ super(["getbit", key, offset]);
249
+ }
250
+ };
251
+
252
+ // pkg/commands/getrange.ts
253
+ var GetRangeCommand = class extends Command {
254
+ constructor(key, start, end) {
255
+ super(["getrange", key, start, end]);
256
+ }
257
+ };
258
+
259
+ // pkg/commands/getset.ts
260
+ var GetSetCommand = class extends Command {
261
+ constructor(key, value) {
262
+ super(["getset", key, value]);
263
+ }
264
+ };
265
+
266
+ // pkg/commands/hdel.ts
267
+ var HDelCommand = class extends Command {
268
+ constructor(key, field) {
269
+ super(["hdel", key, field]);
270
+ }
271
+ };
272
+
273
+ // pkg/commands/hexists.ts
274
+ var HExistsCommand = class extends Command {
275
+ constructor(key, field) {
276
+ super(["hexists", key, field]);
277
+ }
278
+ };
279
+
280
+ // pkg/commands/hget.ts
281
+ var HGetCommand = class extends Command {
282
+ constructor(key, field) {
283
+ super(["hget", key, field]);
284
+ }
285
+ };
286
+
287
+ // pkg/commands/hgetall.ts
288
+ function deserialize(result) {
289
+ if (result.length === 0) {
290
+ return null;
291
+ }
292
+ const obj = {};
293
+ while (result.length >= 2) {
294
+ const key = result.shift();
295
+ const value = result.shift();
296
+ try {
297
+ obj[key] = JSON.parse(value);
298
+ } catch {
299
+ obj[key] = value;
300
+ }
301
+ }
302
+ return obj;
303
+ }
304
+ var HGetAllCommand = class extends Command {
305
+ constructor(key) {
306
+ super(["hgetall", key], { deserialize: (result) => deserialize(result) });
307
+ }
308
+ };
309
+
310
+ // pkg/commands/hincrby.ts
311
+ var HIncrByCommand = class extends Command {
312
+ constructor(key, field, increment) {
313
+ super(["hincrby", key, field, increment]);
314
+ }
315
+ };
316
+
317
+ // pkg/commands/hincrbyfloat.ts
318
+ var HIncrByFloatCommand = class extends Command {
319
+ constructor(key, field, increment) {
320
+ super(["hincrbyfloat", key, field, increment]);
321
+ }
322
+ };
323
+
324
+ // pkg/commands/hkeys.ts
325
+ var HKeysCommand = class extends Command {
326
+ constructor(key) {
327
+ super(["hkeys", key]);
328
+ }
329
+ };
330
+
331
+ // pkg/commands/hlen.ts
332
+ var HLenCommand = class extends Command {
333
+ constructor(key) {
334
+ super(["hlen", key]);
335
+ }
336
+ };
337
+
338
+ // pkg/commands/hmget.ts
339
+ function deserialize2(fields, result) {
340
+ if (result.length === 0 || result.every((field) => field === null)) {
341
+ return null;
342
+ }
343
+ const obj = {};
344
+ for (let i = 0; i < fields.length; i++) {
345
+ try {
346
+ obj[fields[i]] = JSON.parse(result[i]);
347
+ } catch {
348
+ obj[fields[i]] = result[i];
349
+ }
350
+ }
351
+ return obj;
352
+ }
353
+ var HMGetCommand = class extends Command {
354
+ constructor(key, ...fields) {
355
+ super(["hmget", key, ...fields], {
356
+ deserialize: (result) => deserialize2(fields, result)
357
+ });
358
+ }
359
+ };
360
+
361
+ // pkg/commands/hmset.ts
362
+ var HMSetCommand = class extends Command {
363
+ constructor(key, kv) {
364
+ super(["hmset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])]);
365
+ }
366
+ };
367
+
368
+ // pkg/commands/hscan.ts
369
+ var HScanCommand = class extends Command {
370
+ constructor(key, cursor, opts) {
371
+ const command = ["hscan", key, cursor];
372
+ if (opts == null ? void 0 : opts.match) {
373
+ command.push("match", opts.match);
374
+ }
375
+ if (typeof (opts == null ? void 0 : opts.count) === "number") {
376
+ command.push("count", opts.count);
377
+ }
378
+ super(command);
379
+ }
380
+ };
381
+
382
+ // pkg/commands/hset.ts
383
+ var HSetCommand = class extends Command {
384
+ constructor(key, field, value) {
385
+ super(["hset", key, field, value]);
386
+ }
387
+ };
388
+
389
+ // pkg/commands/hsetnx.ts
390
+ var HSetNXCommand = class extends Command {
391
+ constructor(key, field, value) {
392
+ super(["hsetnx", key, field, value]);
393
+ }
394
+ };
395
+
396
+ // pkg/commands/hstrlen.ts
397
+ var HStrLenCommand = class extends Command {
398
+ constructor(key, field) {
399
+ super(["hstrlen", key, field]);
400
+ }
401
+ };
402
+
403
+ // pkg/commands/hvals.ts
404
+ var HValsCommand = class extends Command {
405
+ constructor(key) {
406
+ super(["hvals", key]);
407
+ }
408
+ };
409
+
410
+ // pkg/commands/incr.ts
411
+ var IncrCommand = class extends Command {
412
+ constructor(key) {
413
+ super(["incr", key]);
414
+ }
415
+ };
416
+
417
+ // pkg/commands/incrby.ts
418
+ var IncrByCommand = class extends Command {
419
+ constructor(key, value) {
420
+ super(["incrby", key, value]);
421
+ }
422
+ };
423
+
424
+ // pkg/commands/incrbyfloat.ts
425
+ var IncrByFloatCommand = class extends Command {
426
+ constructor(key, value) {
427
+ super(["incrbyfloat", key, value]);
428
+ }
429
+ };
430
+
431
+ // pkg/commands/keys.ts
432
+ var KeysCommand = class extends Command {
433
+ constructor(pattern) {
434
+ super(["keys", pattern]);
435
+ }
436
+ };
437
+
438
+ // pkg/commands/lindex.ts
439
+ var LIndexCommand = class extends Command {
440
+ constructor(key, index) {
441
+ super(["lindex", key, index]);
442
+ }
443
+ };
444
+
445
+ // pkg/commands/linsert.ts
446
+ var LInsertCommand = class extends Command {
447
+ constructor(key, direction, pivot, value) {
448
+ super(["linsert", key, direction, pivot, value]);
449
+ }
450
+ };
451
+
452
+ // pkg/commands/llen.ts
453
+ var LLenCommand = class extends Command {
454
+ constructor(key) {
455
+ super(["llen", key]);
456
+ }
457
+ };
458
+
459
+ // pkg/commands/lpop.ts
460
+ var LPopCommand = class extends Command {
461
+ constructor(key) {
462
+ super(["lpop", key]);
463
+ }
464
+ };
465
+
466
+ // pkg/commands/lpush.ts
467
+ var LPushCommand = class extends Command {
468
+ constructor(key, ...elements) {
469
+ super(["lpush", key, ...elements]);
470
+ }
471
+ };
472
+
473
+ // pkg/commands/lpushx.ts
474
+ var LPushXCommand = class extends Command {
475
+ constructor(key, ...elements) {
476
+ super(["lpushx", key, ...elements]);
477
+ }
478
+ };
479
+
480
+ // pkg/commands/lrange.ts
481
+ var LRangeCommand = class extends Command {
482
+ constructor(key, start, end) {
483
+ super(["lrange", key, start, end]);
484
+ }
485
+ };
486
+
487
+ // pkg/commands/lrem.ts
488
+ var LRemCommand = class extends Command {
489
+ constructor(key, count, value) {
490
+ super(["lrem", key, count, value]);
491
+ }
492
+ };
493
+
494
+ // pkg/commands/lset.ts
495
+ var LSetCommand = class extends Command {
496
+ constructor(key, value, index) {
497
+ super(["lset", key, index, value]);
498
+ }
499
+ };
500
+
501
+ // pkg/commands/ltrim.ts
502
+ var LTrimCommand = class extends Command {
503
+ constructor(key, start, end) {
504
+ super(["ltrim", key, start, end]);
505
+ }
506
+ };
507
+
508
+ // pkg/commands/mget.ts
509
+ var MGetCommand = class extends Command {
510
+ constructor(...keys) {
511
+ super(["mget", ...keys]);
512
+ }
513
+ };
514
+
515
+ // pkg/commands/mset.ts
516
+ var MSetCommand = class extends Command {
517
+ constructor(kv) {
518
+ super(["mset", ...Object.entries(kv).flatMap(([key, value]) => [key, value])]);
519
+ }
520
+ };
521
+
522
+ // pkg/commands/msetnx.ts
523
+ var MSetNXCommand = class extends Command {
524
+ constructor(kv) {
525
+ super(["msetnx", ...Object.entries(kv).flatMap((_) => _)]);
526
+ }
527
+ };
528
+
529
+ // pkg/commands/persist.ts
530
+ var PersistCommand = class extends Command {
531
+ constructor(key) {
532
+ super(["persist", key]);
533
+ }
534
+ };
535
+
536
+ // pkg/commands/pexpire.ts
537
+ var PExpireCommand = class extends Command {
538
+ constructor(key, milliseconds) {
539
+ super(["pexpire", key, milliseconds]);
540
+ }
541
+ };
542
+
543
+ // pkg/commands/pexpireat.ts
544
+ var PExpireAtCommand = class extends Command {
545
+ constructor(key, unix) {
546
+ super(["pexpireat", key, unix]);
547
+ }
548
+ };
549
+
550
+ // pkg/commands/ping.ts
551
+ var PingCommand = class extends Command {
552
+ constructor(message) {
553
+ const command = ["ping"];
554
+ if (typeof message !== "undefined") {
555
+ command.push(message);
556
+ }
557
+ super(command);
558
+ }
559
+ };
560
+
561
+ // pkg/commands/psetex.ts
562
+ var PSetEXCommand = class extends Command {
563
+ constructor(key, ttl, value) {
564
+ super(["psetex", key, ttl, value]);
565
+ }
566
+ };
567
+
568
+ // pkg/commands/pttl.ts
569
+ var PTtlCommand = class extends Command {
570
+ constructor(key) {
571
+ super(["pttl", key]);
572
+ }
573
+ };
574
+
575
+ // pkg/commands/randomkey.ts
576
+ var RandomKeyCommand = class extends Command {
577
+ constructor() {
578
+ super(["randomkey"]);
579
+ }
580
+ };
581
+
582
+ // pkg/commands/rename.ts
583
+ var RenameCommand = class extends Command {
584
+ constructor(source, destination) {
585
+ super(["rename", source, destination]);
586
+ }
587
+ };
588
+
589
+ // pkg/commands/renamenx.ts
590
+ var RenameNXCommand = class extends Command {
591
+ constructor(source, destination) {
592
+ super(["renamenx", source, destination]);
593
+ }
594
+ };
595
+
596
+ // pkg/commands/rpop.ts
597
+ var RPopCommand = class extends Command {
598
+ constructor(key) {
599
+ super(["rpop", key]);
600
+ }
601
+ };
602
+
603
+ // pkg/commands/rpush.ts
604
+ var RPushCommand = class extends Command {
605
+ constructor(key, ...elements) {
606
+ super(["rpush", key, ...elements]);
607
+ }
608
+ };
609
+
610
+ // pkg/commands/rpushx.ts
611
+ var RPushXCommand = class extends Command {
612
+ constructor(key, ...elements) {
613
+ super(["rpushx", key, ...elements]);
614
+ }
615
+ };
616
+
617
+ // pkg/commands/sadd.ts
618
+ var SAddCommand = class extends Command {
619
+ constructor(key, ...members) {
620
+ super(["sadd", key, ...members]);
621
+ }
622
+ };
623
+
624
+ // pkg/commands/scan.ts
625
+ var ScanCommand = class extends Command {
626
+ constructor(cursor, opts) {
627
+ const command = ["scan", cursor];
628
+ if (opts == null ? void 0 : opts.match) {
629
+ command.push("match", opts.match);
630
+ }
631
+ if (typeof (opts == null ? void 0 : opts.count) === "number") {
632
+ command.push("count", opts.count);
633
+ }
634
+ super(command);
635
+ }
636
+ };
637
+
638
+ // pkg/commands/scard.ts
639
+ var SCardCommand = class extends Command {
640
+ constructor(key) {
641
+ super(["scard", key]);
642
+ }
643
+ };
644
+
645
+ // pkg/commands/sdiff.ts
646
+ var SDiffCommand = class extends Command {
647
+ constructor(key, ...keys) {
648
+ super(["sdiff", key, ...keys]);
649
+ }
650
+ };
651
+
652
+ // pkg/commands/sdiffstore.ts
653
+ var SDiffStoreCommand = class extends Command {
654
+ constructor(destination, ...keys) {
655
+ super(["sdiffstore", destination, ...keys]);
656
+ }
657
+ };
658
+
659
+ // pkg/commands/set.ts
660
+ var SetCommand = class extends Command {
661
+ constructor(key, value, opts) {
662
+ const command = ["set", key, value];
663
+ if (opts) {
664
+ if ("ex" in opts && typeof opts.ex === "number") {
665
+ command.push("ex", opts.ex);
666
+ } else if ("px" in opts && typeof opts.px === "number") {
667
+ command.push("px", opts.px);
668
+ }
669
+ if ("nx" in opts && opts.nx) {
670
+ command.push("nx");
671
+ } else if ("xx" in opts && opts.xx) {
672
+ command.push("xx");
673
+ }
674
+ }
675
+ super(command);
676
+ }
677
+ };
678
+
679
+ // pkg/commands/setbit.ts
680
+ var SetBitCommand = class extends Command {
681
+ constructor(key, offset, value) {
682
+ super(["setbit", key, offset, value]);
683
+ }
684
+ };
685
+
686
+ // pkg/commands/setex.ts
687
+ var SetExCommand = class extends Command {
688
+ constructor(key, ttl, value) {
689
+ super(["setex", key, ttl, value]);
690
+ }
691
+ };
692
+
693
+ // pkg/commands/setnx.ts
694
+ var SetNxCommand = class extends Command {
695
+ constructor(key, value) {
696
+ super(["setnx", key, value]);
697
+ }
698
+ };
699
+
700
+ // pkg/commands/setrange.ts
701
+ var SetRangeCommand = class extends Command {
702
+ constructor(key, offset, value) {
703
+ super(["setrange", key, offset, value]);
704
+ }
705
+ };
706
+
707
+ // pkg/commands/sinter.ts
708
+ var SInterCommand = class extends Command {
709
+ constructor(key, ...keys) {
710
+ super(["sinter", key, ...keys]);
711
+ }
712
+ };
713
+
714
+ // pkg/commands/sinterstore.ts
715
+ var SInterStoreCommand = class extends Command {
716
+ constructor(destination, key, ...keys) {
717
+ super(["sinterstore", destination, key, ...keys]);
718
+ }
719
+ };
720
+
721
+ // pkg/commands/sismember.ts
722
+ var SIsMemberCommand = class extends Command {
723
+ constructor(key, member) {
724
+ super(["sismember", key, member]);
725
+ }
726
+ };
727
+
728
+ // pkg/commands/smembers.ts
729
+ var SMembersCommand = class extends Command {
730
+ constructor(key) {
731
+ super(["smembers", key]);
732
+ }
733
+ };
734
+
735
+ // pkg/commands/smove.ts
736
+ var SMoveCommand = class extends Command {
737
+ constructor(source, destination, member) {
738
+ super(["smove", source, destination, member]);
739
+ }
740
+ };
741
+
742
+ // pkg/commands/spop.ts
743
+ var SPopCommand = class extends Command {
744
+ constructor(key, count) {
745
+ const command = ["spop", key];
746
+ if (typeof count === "number") {
747
+ command.push(count);
748
+ }
749
+ super(command);
750
+ }
751
+ };
752
+
753
+ // pkg/commands/srandmember.ts
754
+ var SRandMemberCommand = class extends Command {
755
+ constructor(key, count) {
756
+ const command = ["srandmember", key];
757
+ if (typeof count === "number") {
758
+ command.push(count);
759
+ }
760
+ super(command);
761
+ }
762
+ };
763
+
764
+ // pkg/commands/srem.ts
765
+ var SRemCommand = class extends Command {
766
+ constructor(key, ...members) {
767
+ super(["srem", key, ...members]);
768
+ }
769
+ };
770
+
771
+ // pkg/commands/sscan.ts
772
+ var SScanCommand = class extends Command {
773
+ constructor(key, cursor, opts) {
774
+ const command = ["sscan", key, cursor];
775
+ if (opts == null ? void 0 : opts.match) {
776
+ command.push("match", opts.match);
777
+ }
778
+ if (typeof (opts == null ? void 0 : opts.count) === "number") {
779
+ command.push("count", opts.count);
780
+ }
781
+ super(command);
782
+ }
783
+ };
784
+
785
+ // pkg/commands/strlen.ts
786
+ var StrLenCommand = class extends Command {
787
+ constructor(key) {
788
+ super(["strlen", key]);
789
+ }
790
+ };
791
+
792
+ // pkg/commands/sunion.ts
793
+ var SUnionCommand = class extends Command {
794
+ constructor(key, ...keys) {
795
+ super(["sunion", key, ...keys]);
796
+ }
797
+ };
798
+
799
+ // pkg/commands/sunionstore.ts
800
+ var SUnionStoreCommand = class extends Command {
801
+ constructor(destination, key, ...keys) {
802
+ super(["sunionstore", destination, key, ...keys]);
803
+ }
804
+ };
805
+
806
+ // pkg/commands/time.ts
807
+ var TimeCommand = class extends Command {
808
+ constructor() {
809
+ super(["time"]);
810
+ }
811
+ };
812
+
813
+ // pkg/commands/touch.ts
814
+ var TouchCommand = class extends Command {
815
+ constructor(...keys) {
816
+ super(["touch", ...keys]);
817
+ }
818
+ };
819
+
820
+ // pkg/commands/ttl.ts
821
+ var TtlCommand = class extends Command {
822
+ constructor(key) {
823
+ super(["ttl", key]);
824
+ }
825
+ };
826
+
827
+ // pkg/commands/type.ts
828
+ var TypeCommand = class extends Command {
829
+ constructor(key) {
830
+ super(["type", key]);
831
+ }
832
+ };
833
+
834
+ // pkg/commands/unlink.ts
835
+ var UnlinkCommand = class extends Command {
836
+ constructor(...keys) {
837
+ super(["unlink", ...keys]);
838
+ }
839
+ };
840
+
841
+ // pkg/commands/zadd.ts
842
+ var ZAddCommand = class extends Command {
843
+ constructor(key, arg1, ...arg2) {
844
+ const command = ["zadd", key];
845
+ if ("nx" in arg1 && arg1.nx) {
846
+ command.push("nx");
847
+ } else if ("xx" in arg1 && arg1.xx) {
848
+ command.push("xx");
849
+ }
850
+ if ("ch" in arg1 && arg1.ch) {
851
+ command.push("ch");
852
+ }
853
+ if ("incr" in arg1 && arg1.incr) {
854
+ command.push("incr");
855
+ }
856
+ if ("score" in arg1 && "member" in arg1) {
857
+ command.push(arg1.score, arg1.member);
858
+ }
859
+ command.push(...arg2.flatMap(({ score, member }) => [score, member]));
860
+ super(command);
861
+ }
862
+ };
863
+
864
+ // pkg/commands/zcard.ts
865
+ var ZCardCommand = class extends Command {
866
+ constructor(key) {
867
+ super(["zcard", key]);
868
+ }
869
+ };
870
+
871
+ // pkg/commands/zcount.ts
872
+ var ZCountCommand = class extends Command {
873
+ constructor(key, min, max) {
874
+ super(["zcount", key, min, max]);
875
+ }
876
+ };
877
+
878
+ // pkg/commands/zincrby.ts
879
+ var ZIncrByComand = class extends Command {
880
+ constructor(key, increment, member) {
881
+ super(["zincrby", key, increment, member]);
882
+ }
883
+ };
884
+
885
+ // pkg/commands/zinterstore.ts
886
+ var ZInterStoreCommand = class extends Command {
887
+ constructor(destination, numKeys, keyOrKeys, opts) {
888
+ const command = ["zinterstore", destination, numKeys];
889
+ if (Array.isArray(keyOrKeys)) {
890
+ command.push(...keyOrKeys);
891
+ } else {
892
+ command.push(keyOrKeys);
893
+ }
894
+ if (opts) {
895
+ if ("weights" in opts && opts.weights) {
896
+ command.push("weights", ...opts.weights);
897
+ } else if ("weight" in opts && typeof opts.weight === "number") {
898
+ command.push("weights", opts.weight);
899
+ }
900
+ if ("aggregate" in opts) {
901
+ command.push("aggregate", opts.aggregate);
902
+ }
903
+ }
904
+ super(command);
905
+ }
906
+ };
907
+
908
+ // pkg/commands/zlexcount.ts
909
+ var ZLexCountCommand = class extends Command {
910
+ constructor(key, min, max) {
911
+ super(["zlexcount", key, min, max]);
912
+ }
913
+ };
914
+
915
+ // pkg/commands/zpopmax.ts
916
+ var ZPopMaxCommand = class extends Command {
917
+ constructor(key, count) {
918
+ const command = ["zpopmax", key];
919
+ if (typeof count === "number") {
920
+ command.push(count);
921
+ }
922
+ super(command);
923
+ }
924
+ };
925
+
926
+ // pkg/commands/zpopmin.ts
927
+ var ZPopMinCommand = class extends Command {
928
+ constructor(key, count) {
929
+ const command = ["zpopmin", key];
930
+ if (typeof count === "number") {
931
+ command.push(count);
932
+ }
933
+ super(command);
934
+ }
935
+ };
936
+
937
+ // pkg/commands/zrange.ts
938
+ var ZRangeCommand = class extends Command {
939
+ constructor(key, min, max, opts) {
940
+ const command = ["zrange", key, min, max];
941
+ if (opts == null ? void 0 : opts.withScores) {
942
+ command.push("withscores");
943
+ }
944
+ super(command);
945
+ }
946
+ };
947
+
948
+ // pkg/commands/zrank.ts
949
+ var ZRankCommand = class extends Command {
950
+ constructor(key, member) {
951
+ super(["zrank", key, member]);
952
+ }
953
+ };
954
+
955
+ // pkg/commands/zrem.ts
956
+ var ZRemCommand = class extends Command {
957
+ constructor(key, ...members) {
958
+ super(["zrem", key, ...members]);
959
+ }
960
+ };
961
+
962
+ // pkg/commands/zremrangebylex.ts
963
+ var ZRemRangeByLexCommand = class extends Command {
964
+ constructor(key, min, max) {
965
+ super(["zremrangebylex", key, min, max]);
966
+ }
967
+ };
968
+
969
+ // pkg/commands/zremrangebyrank.ts
970
+ var ZRemRangeByRankCommand = class extends Command {
971
+ constructor(key, start, stop) {
972
+ super(["zremrangebyrank", key, start, stop]);
973
+ }
974
+ };
975
+
976
+ // pkg/commands/zremrangebyscore.ts
977
+ var ZRemRangeByScoreCommand = class extends Command {
978
+ constructor(key, min, max) {
979
+ super(["zremrangebyscore", key, min, max]);
980
+ }
981
+ };
982
+
983
+ // pkg/commands/zrevrank.ts
984
+ var ZRevRankCommand = class extends Command {
985
+ constructor(key, member) {
986
+ super(["zrevrank", key, member]);
987
+ }
988
+ };
989
+
990
+ // pkg/commands/zscan.ts
991
+ var ZScanCommand = class extends Command {
992
+ constructor(key, cursor, opts) {
993
+ const command = ["zscan", key, cursor];
994
+ if (opts == null ? void 0 : opts.match) {
995
+ command.push("match", opts.match);
996
+ }
997
+ if (typeof (opts == null ? void 0 : opts.count) === "number") {
998
+ command.push("count", opts.count);
999
+ }
1000
+ super(command);
1001
+ }
1002
+ };
1003
+
1004
+ // pkg/commands/zscore.ts
1005
+ var ZScoreCommand = class extends Command {
1006
+ constructor(key, member) {
1007
+ super(["zscore", key, member]);
1008
+ }
1009
+ };
1010
+
1011
+ // pkg/commands/zunionstore.ts
1012
+ var ZUnionStoreCommand = class extends Command {
1013
+ constructor(destination, numKeys, keyOrKeys, opts) {
1014
+ const command = ["zunionstore", destination, numKeys];
1015
+ if (Array.isArray(keyOrKeys)) {
1016
+ command.push(...keyOrKeys);
1017
+ } else {
1018
+ command.push(keyOrKeys);
1019
+ }
1020
+ if (opts) {
1021
+ if ("weights" in opts && opts.weights) {
1022
+ command.push("weights", ...opts.weights);
1023
+ } else if ("weight" in opts && typeof opts.weight === "number") {
1024
+ command.push("weights", opts.weight);
1025
+ }
1026
+ if ("aggregate" in opts) {
1027
+ command.push("aggregate", opts.aggregate);
1028
+ }
1029
+ }
1030
+ super(command);
1031
+ }
1032
+ };
1033
+
1034
+ // pkg/pipeline.ts
1035
+ var Pipeline = class {
1036
+ constructor(client) {
1037
+ this.client = client;
1038
+ this.commands = [];
1039
+ }
1040
+ async exec() {
1041
+ if (this.commands.length === 0) {
1042
+ throw new Error("Pipeline is empty");
1043
+ }
1044
+ const res = await this.client.post({
1045
+ path: ["pipeline"],
1046
+ body: Object.values(this.commands).map((c) => c.command)
1047
+ });
1048
+ return res.map(({ error, result }, i) => {
1049
+ if (error) {
1050
+ throw new UpstashError(`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`);
1051
+ }
1052
+ return this.commands[i].deserialize(result);
1053
+ });
1054
+ }
1055
+ chain(command) {
1056
+ this.commands.push(command);
1057
+ return this;
1058
+ }
1059
+ append(...args) {
1060
+ return this.chain(new AppendCommand(...args));
1061
+ }
1062
+ bitcount(...args) {
1063
+ return this.chain(new BitCountCommand(...args));
1064
+ }
1065
+ bitop(op, destinationKey, sourceKey, ...sourceKeys) {
1066
+ return this.chain(new BitOpCommand(op, destinationKey, sourceKey, ...sourceKeys));
1067
+ }
1068
+ bitpos(...args) {
1069
+ return this.chain(new BitPosCommand(...args));
1070
+ }
1071
+ dbsize() {
1072
+ return this.chain(new DBSizeCommand());
1073
+ }
1074
+ decr(...args) {
1075
+ return this.chain(new DecrCommand(...args));
1076
+ }
1077
+ decrby(...args) {
1078
+ return this.chain(new DecrByCommand(...args));
1079
+ }
1080
+ del(...args) {
1081
+ return this.chain(new DelCommand(...args));
1082
+ }
1083
+ echo(...args) {
1084
+ return this.chain(new EchoCommand(...args));
1085
+ }
1086
+ exists(...args) {
1087
+ return this.chain(new ExistsCommand(...args));
1088
+ }
1089
+ expire(...args) {
1090
+ return this.chain(new ExpireCommand(...args));
1091
+ }
1092
+ expireat(...args) {
1093
+ return this.chain(new ExpireAtCommand(...args));
1094
+ }
1095
+ flushall(...args) {
1096
+ return this.chain(new FlushAllCommand(...args));
1097
+ }
1098
+ flushdb(...args) {
1099
+ return this.chain(new FlushDBCommand(...args));
1100
+ }
1101
+ get(...args) {
1102
+ return this.chain(new GetCommand(...args));
1103
+ }
1104
+ getbit(...args) {
1105
+ return this.chain(new GetBitCommand(...args));
1106
+ }
1107
+ getrange(...args) {
1108
+ return this.chain(new GetRangeCommand(...args));
1109
+ }
1110
+ getset(key, value) {
1111
+ return this.chain(new GetSetCommand(key, value));
1112
+ }
1113
+ hdel(...args) {
1114
+ return this.chain(new HDelCommand(...args));
1115
+ }
1116
+ hexists(...args) {
1117
+ return this.chain(new HExistsCommand(...args));
1118
+ }
1119
+ hget(...args) {
1120
+ return this.chain(new HGetCommand(...args));
1121
+ }
1122
+ hgetall(...args) {
1123
+ return this.chain(new HGetAllCommand(...args));
1124
+ }
1125
+ hincrby(...args) {
1126
+ return this.chain(new HIncrByCommand(...args));
1127
+ }
1128
+ hincrbyfloat(...args) {
1129
+ return this.chain(new HIncrByFloatCommand(...args));
1130
+ }
1131
+ hkeys(...args) {
1132
+ return this.chain(new HKeysCommand(...args));
1133
+ }
1134
+ hlen(...args) {
1135
+ return this.chain(new HLenCommand(...args));
1136
+ }
1137
+ hmget(...args) {
1138
+ return this.chain(new HMGetCommand(...args));
1139
+ }
1140
+ hmset(key, kv) {
1141
+ return this.chain(new HMSetCommand(key, kv));
1142
+ }
1143
+ hscan(...args) {
1144
+ return this.chain(new HScanCommand(...args));
1145
+ }
1146
+ hset(key, field, value) {
1147
+ return this.chain(new HSetCommand(key, field, value));
1148
+ }
1149
+ hsetnx(key, field, value) {
1150
+ return this.chain(new HSetNXCommand(key, field, value));
1151
+ }
1152
+ hstrlen(...args) {
1153
+ return this.chain(new HStrLenCommand(...args));
1154
+ }
1155
+ hvals(...args) {
1156
+ return this.chain(new HValsCommand(...args));
1157
+ }
1158
+ incr(...args) {
1159
+ return this.chain(new IncrCommand(...args));
1160
+ }
1161
+ incrby(...args) {
1162
+ return this.chain(new IncrByCommand(...args));
1163
+ }
1164
+ incrbyfloat(...args) {
1165
+ return this.chain(new IncrByFloatCommand(...args));
1166
+ }
1167
+ keys(...args) {
1168
+ return this.chain(new KeysCommand(...args));
1169
+ }
1170
+ lindex(...args) {
1171
+ return this.chain(new LIndexCommand(...args));
1172
+ }
1173
+ linsert(key, direction, pivot, value) {
1174
+ return this.chain(new LInsertCommand(key, direction, pivot, value));
1175
+ }
1176
+ llen(...args) {
1177
+ return this.chain(new LLenCommand(...args));
1178
+ }
1179
+ lpop(...args) {
1180
+ return this.chain(new LPopCommand(...args));
1181
+ }
1182
+ lpush(key, ...elements) {
1183
+ return this.chain(new LPushCommand(key, ...elements));
1184
+ }
1185
+ lpushx(key, ...elements) {
1186
+ return this.chain(new LPushXCommand(key, ...elements));
1187
+ }
1188
+ lrange(...args) {
1189
+ return this.chain(new LRangeCommand(...args));
1190
+ }
1191
+ lrem(key, count, value) {
1192
+ return this.chain(new LRemCommand(key, count, value));
1193
+ }
1194
+ lset(key, value, index) {
1195
+ return this.chain(new LSetCommand(key, value, index));
1196
+ }
1197
+ ltrim(...args) {
1198
+ return this.chain(new LTrimCommand(...args));
1199
+ }
1200
+ mget(...args) {
1201
+ return this.chain(new MGetCommand(...args));
1202
+ }
1203
+ mset(kv) {
1204
+ return this.chain(new MSetCommand(kv));
1205
+ }
1206
+ msetnx(kv) {
1207
+ return this.chain(new MSetNXCommand(kv));
1208
+ }
1209
+ persist(...args) {
1210
+ return this.chain(new PersistCommand(...args));
1211
+ }
1212
+ pexpire(...args) {
1213
+ return this.chain(new PExpireCommand(...args));
1214
+ }
1215
+ pexpireat(...args) {
1216
+ return this.chain(new PExpireAtCommand(...args));
1217
+ }
1218
+ ping(...args) {
1219
+ return this.chain(new PingCommand(...args));
1220
+ }
1221
+ psetex(key, ttl, value) {
1222
+ return this.chain(new PSetEXCommand(key, ttl, value));
1223
+ }
1224
+ pttl(...args) {
1225
+ return this.chain(new PTtlCommand(...args));
1226
+ }
1227
+ randomkey() {
1228
+ return this.chain(new RandomKeyCommand());
1229
+ }
1230
+ rename(...args) {
1231
+ return this.chain(new RenameCommand(...args));
1232
+ }
1233
+ renamenx(...args) {
1234
+ return this.chain(new RenameNXCommand(...args));
1235
+ }
1236
+ rpop(...args) {
1237
+ return this.chain(new RPopCommand(...args));
1238
+ }
1239
+ rpush(key, ...elements) {
1240
+ return this.chain(new RPushCommand(key, ...elements));
1241
+ }
1242
+ rpushx(key, ...elements) {
1243
+ return this.chain(new RPushXCommand(key, ...elements));
1244
+ }
1245
+ sadd(key, ...members) {
1246
+ return this.chain(new SAddCommand(key, ...members));
1247
+ }
1248
+ scan(...args) {
1249
+ return this.chain(new ScanCommand(...args));
1250
+ }
1251
+ scard(...args) {
1252
+ return this.chain(new SCardCommand(...args));
1253
+ }
1254
+ sdiff(...args) {
1255
+ return this.chain(new SDiffCommand(...args));
1256
+ }
1257
+ sdiffstore(...args) {
1258
+ return this.chain(new SDiffStoreCommand(...args));
1259
+ }
1260
+ set(key, value, opts) {
1261
+ return this.chain(new SetCommand(key, value, opts));
1262
+ }
1263
+ setbit(...args) {
1264
+ return this.chain(new SetBitCommand(...args));
1265
+ }
1266
+ setex(key, ttl, value) {
1267
+ return this.chain(new SetExCommand(key, ttl, value));
1268
+ }
1269
+ setnx(key, value) {
1270
+ return this.chain(new SetNxCommand(key, value));
1271
+ }
1272
+ setrange(...args) {
1273
+ return this.chain(new SetRangeCommand(...args));
1274
+ }
1275
+ sinter(...args) {
1276
+ return this.chain(new SInterCommand(...args));
1277
+ }
1278
+ sinterstore(...args) {
1279
+ return this.chain(new SInterStoreCommand(...args));
1280
+ }
1281
+ sismember(key, member) {
1282
+ return this.chain(new SIsMemberCommand(key, member));
1283
+ }
1284
+ smembers(...args) {
1285
+ return this.chain(new SMembersCommand(...args));
1286
+ }
1287
+ smove(source, destination, member) {
1288
+ return this.chain(new SMoveCommand(source, destination, member));
1289
+ }
1290
+ spop(...args) {
1291
+ return this.chain(new SPopCommand(...args));
1292
+ }
1293
+ srandmember(...args) {
1294
+ return this.chain(new SRandMemberCommand(...args));
1295
+ }
1296
+ srem(key, ...members) {
1297
+ return this.chain(new SRemCommand(key, ...members));
1298
+ }
1299
+ sscan(...args) {
1300
+ return this.chain(new SScanCommand(...args));
1301
+ }
1302
+ strlen(...args) {
1303
+ return this.chain(new StrLenCommand(...args));
1304
+ }
1305
+ sunion(...args) {
1306
+ return this.chain(new SUnionCommand(...args));
1307
+ }
1308
+ sunionstore(...args) {
1309
+ return this.chain(new SUnionStoreCommand(...args));
1310
+ }
1311
+ time() {
1312
+ return this.chain(new TimeCommand());
1313
+ }
1314
+ touch(...args) {
1315
+ return this.chain(new TouchCommand(...args));
1316
+ }
1317
+ ttl(...args) {
1318
+ return this.chain(new TtlCommand(...args));
1319
+ }
1320
+ type(...args) {
1321
+ return this.chain(new TypeCommand(...args));
1322
+ }
1323
+ unlink(...args) {
1324
+ return this.chain(new UnlinkCommand(...args));
1325
+ }
1326
+ zadd(key, arg1, ...arg2) {
1327
+ return this.chain(new ZAddCommand(key, arg1, ...arg2));
1328
+ }
1329
+ zcard(...args) {
1330
+ return this.chain(new ZCardCommand(...args));
1331
+ }
1332
+ zcount(...args) {
1333
+ return this.chain(new ZCountCommand(...args));
1334
+ }
1335
+ zincrby(key, increment, member) {
1336
+ return this.chain(new ZIncrByComand(key, increment, member));
1337
+ }
1338
+ zinterstore(...args) {
1339
+ return this.chain(new ZInterStoreCommand(...args));
1340
+ }
1341
+ zlexcount(...args) {
1342
+ return this.chain(new ZLexCountCommand(...args));
1343
+ }
1344
+ zpopmax(...args) {
1345
+ return this.chain(new ZPopMaxCommand(...args));
1346
+ }
1347
+ zpopmin(...args) {
1348
+ return this.chain(new ZPopMinCommand(...args));
1349
+ }
1350
+ zrange(...args) {
1351
+ return this.chain(new ZRangeCommand(...args));
1352
+ }
1353
+ zrank(key, member) {
1354
+ return this.chain(new ZRankCommand(key, member));
1355
+ }
1356
+ zrem(key, ...members) {
1357
+ return this.chain(new ZRemCommand(key, ...members));
1358
+ }
1359
+ zremrangebylex(...args) {
1360
+ return this.chain(new ZRemRangeByLexCommand(...args));
1361
+ }
1362
+ zremrangebyrank(...args) {
1363
+ return this.chain(new ZRemRangeByRankCommand(...args));
1364
+ }
1365
+ zremrangebyscore(...args) {
1366
+ return this.chain(new ZRemRangeByScoreCommand(...args));
1367
+ }
1368
+ zrevrank(key, member) {
1369
+ return this.chain(new ZRevRankCommand(key, member));
1370
+ }
1371
+ zscan(...args) {
1372
+ return this.chain(new ZScanCommand(...args));
1373
+ }
1374
+ zscore(key, member) {
1375
+ return this.chain(new ZScoreCommand(key, member));
1376
+ }
1377
+ zunionstore(...args) {
1378
+ return this.chain(new ZUnionStoreCommand(...args));
1379
+ }
1380
+ };
1381
+
1382
+ // pkg/redis.ts
1383
+ var Redis = class {
1384
+ constructor(config) {
1385
+ this.client = new HttpClient({
1386
+ baseUrl: config.url,
1387
+ headers: {
1388
+ authorization: `Bearer ${config.token}`
1389
+ }
1390
+ });
1391
+ }
1392
+ static fromEnv() {
1393
+ if (typeof (process == null ? void 0 : process.env) === "undefined") {
1394
+ throw new Error("Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please use `fromCloudflareEnv()` instead");
1395
+ }
1396
+ const url = process.env["UPSTASH_REDIS_REST_URL"];
1397
+ if (!url) {
1398
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
1399
+ }
1400
+ const token = process.env["UPSTASH_REDIS_REST_TOKEN"];
1401
+ if (!token) {
1402
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
1403
+ }
1404
+ return new Redis({ url, token });
1405
+ }
1406
+ static fromCloudflareEnv() {
1407
+ const url = UPSTASH_REDIS_REST_URL;
1408
+ const token = UPSTASH_REDIS_REST_TOKEN;
1409
+ if (!url) {
1410
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
1411
+ }
1412
+ if (!token) {
1413
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
1414
+ }
1415
+ return new Redis({ url, token });
1416
+ }
1417
+ pipeline() {
1418
+ return new Pipeline(this.client);
1419
+ }
1420
+ append(...args) {
1421
+ return new AppendCommand(...args).exec(this.client);
1422
+ }
1423
+ bitcount(...args) {
1424
+ return new BitCountCommand(...args).exec(this.client);
1425
+ }
1426
+ bitop(op, destinationKey, sourceKey, ...sourceKeys) {
1427
+ return new BitOpCommand(op, destinationKey, sourceKey, ...sourceKeys).exec(this.client);
1428
+ }
1429
+ bitpos(...args) {
1430
+ return new BitPosCommand(...args).exec(this.client);
1431
+ }
1432
+ dbsize() {
1433
+ return new DBSizeCommand().exec(this.client);
1434
+ }
1435
+ decr(...args) {
1436
+ return new DecrCommand(...args).exec(this.client);
1437
+ }
1438
+ decrby(...args) {
1439
+ return new DecrByCommand(...args).exec(this.client);
1440
+ }
1441
+ del(...args) {
1442
+ return new DelCommand(...args).exec(this.client);
1443
+ }
1444
+ echo(...args) {
1445
+ return new EchoCommand(...args).exec(this.client);
1446
+ }
1447
+ exists(...args) {
1448
+ return new ExistsCommand(...args).exec(this.client);
1449
+ }
1450
+ expire(...args) {
1451
+ return new ExpireCommand(...args).exec(this.client);
1452
+ }
1453
+ expireat(...args) {
1454
+ return new ExpireAtCommand(...args).exec(this.client);
1455
+ }
1456
+ flushall(...args) {
1457
+ return new FlushAllCommand(...args).exec(this.client);
1458
+ }
1459
+ flushdb(...args) {
1460
+ return new FlushDBCommand(...args).exec(this.client);
1461
+ }
1462
+ get(...args) {
1463
+ return new GetCommand(...args).exec(this.client);
1464
+ }
1465
+ getbit(...args) {
1466
+ return new GetBitCommand(...args).exec(this.client);
1467
+ }
1468
+ getrange(...args) {
1469
+ return new GetRangeCommand(...args).exec(this.client);
1470
+ }
1471
+ getset(key, value) {
1472
+ return new GetSetCommand(key, value).exec(this.client);
1473
+ }
1474
+ hdel(...args) {
1475
+ return new HDelCommand(...args).exec(this.client);
1476
+ }
1477
+ hexists(...args) {
1478
+ return new HExistsCommand(...args).exec(this.client);
1479
+ }
1480
+ hget(...args) {
1481
+ return new HGetCommand(...args).exec(this.client);
1482
+ }
1483
+ hgetall(...args) {
1484
+ return new HGetAllCommand(...args).exec(this.client);
1485
+ }
1486
+ hincrby(...args) {
1487
+ return new HIncrByCommand(...args).exec(this.client);
1488
+ }
1489
+ hincrbyfloat(...args) {
1490
+ return new HIncrByFloatCommand(...args).exec(this.client);
1491
+ }
1492
+ hkeys(...args) {
1493
+ return new HKeysCommand(...args).exec(this.client);
1494
+ }
1495
+ hlen(...args) {
1496
+ return new HLenCommand(...args).exec(this.client);
1497
+ }
1498
+ hmget(...args) {
1499
+ return new HMGetCommand(...args).exec(this.client);
1500
+ }
1501
+ hmset(key, kv) {
1502
+ return new HMSetCommand(key, kv).exec(this.client);
1503
+ }
1504
+ hscan(...args) {
1505
+ return new HScanCommand(...args).exec(this.client);
1506
+ }
1507
+ hset(key, field, value) {
1508
+ return new HSetCommand(key, field, value).exec(this.client);
1509
+ }
1510
+ hsetnx(key, field, value) {
1511
+ return new HSetNXCommand(key, field, value).exec(this.client);
1512
+ }
1513
+ hstrlen(...args) {
1514
+ return new HStrLenCommand(...args).exec(this.client);
1515
+ }
1516
+ hvals(...args) {
1517
+ return new HValsCommand(...args).exec(this.client);
1518
+ }
1519
+ incr(...args) {
1520
+ return new IncrCommand(...args).exec(this.client);
1521
+ }
1522
+ incrby(...args) {
1523
+ return new IncrByCommand(...args).exec(this.client);
1524
+ }
1525
+ incrbyfloat(...args) {
1526
+ return new IncrByFloatCommand(...args).exec(this.client);
1527
+ }
1528
+ keys(...args) {
1529
+ return new KeysCommand(...args).exec(this.client);
1530
+ }
1531
+ lindex(...args) {
1532
+ return new LIndexCommand(...args).exec(this.client);
1533
+ }
1534
+ linsert(key, direction, pivot, value) {
1535
+ return new LInsertCommand(key, direction, pivot, value).exec(this.client);
1536
+ }
1537
+ llen(...args) {
1538
+ return new LLenCommand(...args).exec(this.client);
1539
+ }
1540
+ lpop(...args) {
1541
+ return new LPopCommand(...args).exec(this.client);
1542
+ }
1543
+ lpush(key, ...elements) {
1544
+ return new LPushCommand(key, ...elements).exec(this.client);
1545
+ }
1546
+ lpushx(key, ...elements) {
1547
+ return new LPushXCommand(key, ...elements).exec(this.client);
1548
+ }
1549
+ lrange(...args) {
1550
+ return new LRangeCommand(...args).exec(this.client);
1551
+ }
1552
+ lrem(key, count, value) {
1553
+ return new LRemCommand(key, count, value).exec(this.client);
1554
+ }
1555
+ lset(key, value, index) {
1556
+ return new LSetCommand(key, value, index).exec(this.client);
1557
+ }
1558
+ ltrim(...args) {
1559
+ return new LTrimCommand(...args).exec(this.client);
1560
+ }
1561
+ mget(...args) {
1562
+ return new MGetCommand(...args).exec(this.client);
1563
+ }
1564
+ mset(kv) {
1565
+ return new MSetCommand(kv).exec(this.client);
1566
+ }
1567
+ msetnx(kv) {
1568
+ return new MSetNXCommand(kv).exec(this.client);
1569
+ }
1570
+ persist(...args) {
1571
+ return new PersistCommand(...args).exec(this.client);
1572
+ }
1573
+ pexpire(...args) {
1574
+ return new PExpireCommand(...args).exec(this.client);
1575
+ }
1576
+ pexpireat(...args) {
1577
+ return new PExpireAtCommand(...args).exec(this.client);
1578
+ }
1579
+ ping(...args) {
1580
+ return new PingCommand(...args).exec(this.client);
1581
+ }
1582
+ psetex(key, ttl, value) {
1583
+ return new PSetEXCommand(key, ttl, value).exec(this.client);
1584
+ }
1585
+ pttl(...args) {
1586
+ return new PTtlCommand(...args).exec(this.client);
1587
+ }
1588
+ randomkey() {
1589
+ return new RandomKeyCommand().exec(this.client);
1590
+ }
1591
+ rename(...args) {
1592
+ return new RenameCommand(...args).exec(this.client);
1593
+ }
1594
+ renamenx(...args) {
1595
+ return new RenameNXCommand(...args).exec(this.client);
1596
+ }
1597
+ rpop(...args) {
1598
+ return new RPopCommand(...args).exec(this.client);
1599
+ }
1600
+ rpush(key, ...elements) {
1601
+ return new RPushCommand(key, ...elements).exec(this.client);
1602
+ }
1603
+ rpushx(key, ...elements) {
1604
+ return new RPushXCommand(key, ...elements).exec(this.client);
1605
+ }
1606
+ sadd(key, ...members) {
1607
+ return new SAddCommand(key, ...members).exec(this.client);
1608
+ }
1609
+ scan(...args) {
1610
+ return new ScanCommand(...args).exec(this.client);
1611
+ }
1612
+ scard(...args) {
1613
+ return new SCardCommand(...args).exec(this.client);
1614
+ }
1615
+ sdiff(...args) {
1616
+ return new SDiffCommand(...args).exec(this.client);
1617
+ }
1618
+ sdiffstore(...args) {
1619
+ return new SDiffStoreCommand(...args).exec(this.client);
1620
+ }
1621
+ set(key, value, opts) {
1622
+ return new SetCommand(key, value, opts).exec(this.client);
1623
+ }
1624
+ setbit(...args) {
1625
+ return new SetBitCommand(...args).exec(this.client);
1626
+ }
1627
+ setex(key, ttl, value) {
1628
+ return new SetExCommand(key, ttl, value).exec(this.client);
1629
+ }
1630
+ setnx(key, value) {
1631
+ return new SetNxCommand(key, value).exec(this.client);
1632
+ }
1633
+ setrange(...args) {
1634
+ return new SetRangeCommand(...args).exec(this.client);
1635
+ }
1636
+ sinter(...args) {
1637
+ return new SInterCommand(...args).exec(this.client);
1638
+ }
1639
+ sinterstore(...args) {
1640
+ return new SInterStoreCommand(...args).exec(this.client);
1641
+ }
1642
+ sismember(key, member) {
1643
+ return new SIsMemberCommand(key, member).exec(this.client);
1644
+ }
1645
+ smembers(...args) {
1646
+ return new SMembersCommand(...args).exec(this.client);
1647
+ }
1648
+ smove(source, destination, member) {
1649
+ return new SMoveCommand(source, destination, member).exec(this.client);
1650
+ }
1651
+ spop(...args) {
1652
+ return new SPopCommand(...args).exec(this.client);
1653
+ }
1654
+ srandmember(...args) {
1655
+ return new SRandMemberCommand(...args).exec(this.client);
1656
+ }
1657
+ srem(key, ...members) {
1658
+ return new SRemCommand(key, ...members).exec(this.client);
1659
+ }
1660
+ sscan(...args) {
1661
+ return new SScanCommand(...args).exec(this.client);
1662
+ }
1663
+ strlen(...args) {
1664
+ return new StrLenCommand(...args).exec(this.client);
1665
+ }
1666
+ sunion(...args) {
1667
+ return new SUnionCommand(...args).exec(this.client);
1668
+ }
1669
+ sunionstore(...args) {
1670
+ return new SUnionStoreCommand(...args).exec(this.client);
1671
+ }
1672
+ time() {
1673
+ return new TimeCommand().exec(this.client);
1674
+ }
1675
+ touch(...args) {
1676
+ return new TouchCommand(...args).exec(this.client);
1677
+ }
1678
+ ttl(...args) {
1679
+ return new TtlCommand(...args).exec(this.client);
1680
+ }
1681
+ type(...args) {
1682
+ return new TypeCommand(...args).exec(this.client);
1683
+ }
1684
+ unlink(...args) {
1685
+ return new UnlinkCommand(...args).exec(this.client);
1686
+ }
1687
+ zadd(key, arg1, ...arg2) {
1688
+ if ("score" in arg1) {
1689
+ return new ZAddCommand(key, arg1, ...arg2).exec(this.client);
1690
+ }
1691
+ return new ZAddCommand(key, arg1, ...arg2).exec(this.client);
1692
+ }
1693
+ zcard(...args) {
1694
+ return new ZCardCommand(...args).exec(this.client);
1695
+ }
1696
+ zcount(...args) {
1697
+ return new ZCountCommand(...args).exec(this.client);
1698
+ }
1699
+ zincrby(key, increment, member) {
1700
+ return new ZIncrByComand(key, increment, member).exec(this.client);
1701
+ }
1702
+ zinterstore(...args) {
1703
+ return new ZInterStoreCommand(...args).exec(this.client);
1704
+ }
1705
+ zlexcount(...args) {
1706
+ return new ZLexCountCommand(...args).exec(this.client);
1707
+ }
1708
+ zpopmax(...args) {
1709
+ return new ZPopMaxCommand(...args).exec(this.client);
1710
+ }
1711
+ zpopmin(...args) {
1712
+ return new ZPopMinCommand(...args).exec(this.client);
1713
+ }
1714
+ zrange(...args) {
1715
+ return new ZRangeCommand(...args).exec(this.client);
1716
+ }
1717
+ zrank(key, member) {
1718
+ return new ZRankCommand(key, member).exec(this.client);
1719
+ }
1720
+ zrem(key, ...members) {
1721
+ return new ZRemCommand(key, ...members).exec(this.client);
1722
+ }
1723
+ zremrangebylex(...args) {
1724
+ return new ZRemRangeByLexCommand(...args).exec(this.client);
1725
+ }
1726
+ zremrangebyrank(...args) {
1727
+ return new ZRemRangeByRankCommand(...args).exec(this.client);
1728
+ }
1729
+ zremrangebyscore(...args) {
1730
+ return new ZRemRangeByScoreCommand(...args).exec(this.client);
1731
+ }
1732
+ zrevrank(key, member) {
1733
+ return new ZRevRankCommand(key, member).exec(this.client);
1734
+ }
1735
+ zscan(...args) {
1736
+ return new ZScanCommand(...args).exec(this.client);
1737
+ }
1738
+ zscore(key, member) {
1739
+ return new ZScoreCommand(key, member).exec(this.client);
1740
+ }
1741
+ zunionstore(...args) {
1742
+ return new ZUnionStoreCommand(...args).exec(this.client);
1743
+ }
1744
+ };
1745
+ module.exports = __toCommonJS(pkg_exports);
1746
+ // Annotate the CommonJS export names for ESM import in node:
1747
+ 0 && (module.exports = {
1748
+ Redis,
1749
+ UpstashError
1750
+ });