@upstash/redis 0.0.0-ci.c00b02de3221a40eb48a9e0e9fecd434abda4dc2-20240704001524 → 0.0.0-ci.c2204f830cf3ca85c9f85a7dc63bd93a0e228f4b-20250403110828

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