@upstash/redis 0.0.0-ci.8895aca4ac4b6a7430f4e15b010a71fd1735c231-20240408001502 → 0.0.0-ci.893d5822fe6324e13932f920ba66e56179dfdb9f-20260130092901

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