@skillrecordings/cli 0.1.0 → 0.2.1

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