@upstash/redis 0.0.0-ci.c4f9e888-20220808 → 0.0.0-ci.c586e271-20221116

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 (51) hide show
  1. package/README.md +0 -21
  2. package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +1 -0
  3. package/esm/deps/{denopkg.com/chiefbiiko/sha1@master → deno.land/x/sha1@v1.0.3}/mod.js +0 -0
  4. package/esm/deps/denopkg.com/chiefbiiko/{std-encoding@v1.1.1 → std-encoding@v1.0.0}/mod.js +4 -8
  5. package/esm/pkg/commands/getdel.js +9 -0
  6. package/esm/pkg/commands/mod.js +1 -0
  7. package/esm/pkg/commands/scan.js +3 -0
  8. package/esm/pkg/commands/zmscore.js +10 -0
  9. package/esm/pkg/http.js +73 -2
  10. package/esm/pkg/pipeline.js +33 -6
  11. package/esm/pkg/redis.js +44 -2
  12. package/esm/pkg/script.js +1 -1
  13. package/esm/platforms/cloudflare.js +1 -0
  14. package/esm/platforms/fastly.js +1 -0
  15. package/esm/platforms/node_with_fetch.js +2 -1
  16. package/esm/platforms/nodejs.js +2 -1
  17. package/package.json +1 -39
  18. package/script/deps/{denopkg.com/chiefbiiko/sha1@master → deno.land/x/sha1@v1.0.3}/deps.js +1 -1
  19. package/script/deps/{denopkg.com/chiefbiiko/sha1@master → deno.land/x/sha1@v1.0.3}/mod.js +0 -0
  20. package/script/deps/denopkg.com/chiefbiiko/{std-encoding@v1.1.1 → std-encoding@v1.0.0}/mod.js +4 -31
  21. package/script/pkg/commands/getdel.js +13 -0
  22. package/script/pkg/commands/mod.js +1 -0
  23. package/script/pkg/commands/scan.js +3 -0
  24. package/script/pkg/commands/zmscore.js +14 -0
  25. package/script/pkg/http.js +73 -2
  26. package/script/pkg/pipeline.js +32 -5
  27. package/script/pkg/redis.js +43 -1
  28. package/script/pkg/script.js +1 -1
  29. package/script/platforms/cloudflare.js +1 -0
  30. package/script/platforms/fastly.js +1 -0
  31. package/script/platforms/node_with_fetch.js +2 -1
  32. package/script/platforms/nodejs.js +2 -1
  33. package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +1 -0
  34. package/types/deps/{denopkg.com/chiefbiiko/sha1@master → deno.land/x/sha1@v1.0.3}/mod.d.ts +0 -0
  35. package/types/deps/denopkg.com/chiefbiiko/{std-encoding@v1.1.1 → std-encoding@v1.0.0}/mod.d.ts +0 -0
  36. package/types/pkg/commands/getdel.d.ts +7 -0
  37. package/types/pkg/commands/mod.d.ts +1 -0
  38. package/types/pkg/commands/scan.d.ts +1 -0
  39. package/types/pkg/commands/zmscore.d.ts +7 -0
  40. package/types/pkg/http.d.ts +35 -4
  41. package/types/pkg/pipeline.d.ts +16 -3
  42. package/types/pkg/redis.d.ts +19 -1
  43. package/types/platforms/cloudflare.d.ts +3 -6
  44. package/types/platforms/fastly.d.ts +2 -6
  45. package/types/platforms/node_with_fetch.d.ts +2 -21
  46. package/types/platforms/nodejs.d.ts +3 -6
  47. package/esm/deps/deno.land/x/base64@v0.2.1/mod.js +0 -13
  48. package/esm/deps/denopkg.com/chiefbiiko/sha1@master/deps.js +0 -1
  49. package/script/deps/deno.land/x/base64@v0.2.1/mod.js +0 -17
  50. package/types/deps/deno.land/x/base64@v0.2.1/mod.d.ts +0 -1
  51. package/types/deps/denopkg.com/chiefbiiko/sha1@master/deps.d.ts +0 -1
@@ -28,9 +28,19 @@ class HttpClient {
28
28
  writable: true,
29
29
  value: void 0
30
30
  });
31
+ this.options = {
32
+ backend: config.options?.backend,
33
+ agent: config.agent,
34
+ responseEncoding: config.responseEncoding ?? "base64", // default to base64
35
+ };
31
36
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
32
- this.headers = { "Content-Type": "application/json", ...config.headers };
33
- this.options = { backend: config.options?.backend };
37
+ this.headers = {
38
+ "Content-Type": "application/json",
39
+ ...config.headers,
40
+ };
41
+ if (this.options.responseEncoding === "base64") {
42
+ this.headers["Upstash-Encoding"] = "base64";
43
+ }
34
44
  if (typeof config?.retry === "boolean" && config?.retry === false) {
35
45
  this.retry = {
36
46
  attempts: 1,
@@ -51,6 +61,7 @@ class HttpClient {
51
61
  headers: this.headers,
52
62
  body: JSON.stringify(req.body),
53
63
  keepalive: true,
64
+ agent: this.options?.agent,
54
65
  /**
55
66
  * Fastly specific
56
67
  */
@@ -75,7 +86,67 @@ class HttpClient {
75
86
  if (!res.ok) {
76
87
  throw new error_js_1.UpstashError(body.error);
77
88
  }
89
+ if (this.options?.responseEncoding === "base64") {
90
+ return Array.isArray(body) ? body.map(decode) : decode(body);
91
+ }
78
92
  return body;
79
93
  }
80
94
  }
81
95
  exports.HttpClient = HttpClient;
96
+ function base64decode(b64) {
97
+ let dec = "";
98
+ try {
99
+ /**
100
+ * Using only atob() is not enough because it doesn't work with unicode characters
101
+ */
102
+ const binString = atob(b64);
103
+ const size = binString.length;
104
+ const bytes = new Uint8Array(size);
105
+ for (let i = 0; i < size; i++) {
106
+ bytes[i] = binString.charCodeAt(i);
107
+ }
108
+ dec = new TextDecoder().decode(bytes);
109
+ }
110
+ catch {
111
+ dec = b64;
112
+ }
113
+ try {
114
+ return decodeURIComponent(dec);
115
+ }
116
+ catch {
117
+ return dec;
118
+ }
119
+ }
120
+ function decode(raw) {
121
+ let result = undefined;
122
+ switch (typeof raw.result) {
123
+ case "undefined":
124
+ return raw;
125
+ case "number": {
126
+ result = raw.result;
127
+ break;
128
+ }
129
+ case "object": {
130
+ if (Array.isArray(raw.result)) {
131
+ result = raw.result.map((v) => typeof v === "string"
132
+ ? base64decode(v)
133
+ : Array.isArray(v)
134
+ ? v.map(base64decode)
135
+ : v);
136
+ }
137
+ else {
138
+ // If it's not an array it must be null
139
+ // Apparently null is an object in javascript
140
+ result = null;
141
+ }
142
+ break;
143
+ }
144
+ case "string": {
145
+ result = raw.result === "OK" ? "OK" : base64decode(raw.result);
146
+ break;
147
+ }
148
+ default:
149
+ break;
150
+ }
151
+ return { result, error: raw.error };
152
+ }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Pipeline = void 0;
4
4
  const mod_js_1 = require("./commands/mod.js");
5
5
  const error_js_1 = require("./error.js");
6
+ const zmscore_js_1 = require("./commands/zmscore.js");
6
7
  /**
7
8
  * Upstash REST API supports command pipelining to send multiple commands in
8
9
  * batch, instead of sending each command one by one and waiting for a response.
@@ -19,7 +20,7 @@ const error_js_1 = require("./error.js");
19
20
  * **Examples:**
20
21
  *
21
22
  * ```ts
22
- * const p = redis.pipeline()
23
+ * const p = redis.pipeline() // or redis.multi()
23
24
  * p.set("key","value")
24
25
  * p.get("key")
25
26
  * const res = await p.exec()
@@ -42,7 +43,7 @@ const error_js_1 = require("./error.js");
42
43
  * ```
43
44
  */
44
45
  class Pipeline {
45
- constructor(client, commandOptions) {
46
+ constructor(opts) {
46
47
  Object.defineProperty(this, "client", {
47
48
  enumerable: true,
48
49
  configurable: true,
@@ -61,6 +62,12 @@ class Pipeline {
61
62
  writable: true,
62
63
  value: void 0
63
64
  });
65
+ Object.defineProperty(this, "multiExec", {
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true,
69
+ value: void 0
70
+ });
64
71
  /**
65
72
  * Send the pipeline request to upstash.
66
73
  *
@@ -79,8 +86,9 @@ class Pipeline {
79
86
  if (this.commands.length === 0) {
80
87
  throw new Error("Pipeline is empty");
81
88
  }
89
+ const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
82
90
  const res = (await this.client.request({
83
- path: ["pipeline"],
91
+ path,
84
92
  body: Object.values(this.commands).map((c) => c.command),
85
93
  }));
86
94
  return res.map(({ error, result }, i) => {
@@ -253,6 +261,15 @@ class Pipeline {
253
261
  writable: true,
254
262
  value: (...args) => this.chain(new mod_js_1.GetBitCommand(args, this.commandOptions))
255
263
  });
264
+ /**
265
+ * @see https://redis.io/commands/getdel
266
+ */
267
+ Object.defineProperty(this, "getdel", {
268
+ enumerable: true,
269
+ configurable: true,
270
+ writable: true,
271
+ value: (...args) => this.chain(new mod_js_1.GetDelCommand(args, this.commandOptions))
272
+ });
256
273
  /**
257
274
  * @see https://redis.io/commands/getrange
258
275
  */
@@ -1014,6 +1031,15 @@ class Pipeline {
1014
1031
  writable: true,
1015
1032
  value: (...args) => this.chain(new mod_js_1.ZLexCountCommand(args, this.commandOptions))
1016
1033
  });
1034
+ /**
1035
+ * @see https://redis.io/commands/zmscore
1036
+ */
1037
+ Object.defineProperty(this, "zmscore", {
1038
+ enumerable: true,
1039
+ configurable: true,
1040
+ writable: true,
1041
+ value: (...args) => this.chain(new zmscore_js_1.ZMScoreCommand(args, this.commandOptions))
1042
+ });
1017
1043
  /**
1018
1044
  * @see https://redis.io/commands/zpopmax
1019
1045
  */
@@ -1122,9 +1148,10 @@ class Pipeline {
1122
1148
  writable: true,
1123
1149
  value: (...args) => this.chain(new mod_js_1.ZUnionStoreCommand(args, this.commandOptions))
1124
1150
  });
1125
- this.client = client;
1151
+ this.client = opts.client;
1126
1152
  this.commands = [];
1127
- this.commandOptions = commandOptions;
1153
+ this.commandOptions = opts.commandOptions;
1154
+ this.multiExec = opts.multiExec ?? false;
1128
1155
  }
1129
1156
  /**
1130
1157
  * Pushes a command into the pipelien and returns a chainable instance of the
@@ -4,6 +4,7 @@ exports.Redis = void 0;
4
4
  const mod_js_1 = require("./commands/mod.js");
5
5
  const pipeline_js_1 = require("./pipeline.js");
6
6
  const script_js_1 = require("./script.js");
7
+ const zmscore_js_1 = require("./commands/zmscore.js");
7
8
  /**
8
9
  * Serverless redis client for upstash.
9
10
  */
@@ -53,7 +54,30 @@ class Redis {
53
54
  enumerable: true,
54
55
  configurable: true,
55
56
  writable: true,
56
- value: () => new pipeline_js_1.Pipeline(this.client, this.opts)
57
+ value: () => new pipeline_js_1.Pipeline({
58
+ client: this.client,
59
+ commandOptions: this.opts,
60
+ multiExec: false,
61
+ })
62
+ });
63
+ /**
64
+ * Create a new transaction to allow executing multiple steps atomically.
65
+ *
66
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
67
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
68
+ * guarantees that the commands are executed as a single isolated operation.
69
+ *
70
+ * @see {@link Pipeline}
71
+ */
72
+ Object.defineProperty(this, "multi", {
73
+ enumerable: true,
74
+ configurable: true,
75
+ writable: true,
76
+ value: () => new pipeline_js_1.Pipeline({
77
+ client: this.client,
78
+ commandOptions: this.opts,
79
+ multiExec: true,
80
+ })
57
81
  });
58
82
  /**
59
83
  * @see https://redis.io/commands/append
@@ -217,6 +241,15 @@ class Redis {
217
241
  writable: true,
218
242
  value: (...args) => new mod_js_1.GetBitCommand(args, this.opts).exec(this.client)
219
243
  });
244
+ /**
245
+ * @see https://redis.io/commands/getdel
246
+ */
247
+ Object.defineProperty(this, "getdel", {
248
+ enumerable: true,
249
+ configurable: true,
250
+ writable: true,
251
+ value: (...args) => new mod_js_1.GetDelCommand(args, this.opts).exec(this.client)
252
+ });
220
253
  /**
221
254
  * @see https://redis.io/commands/getrange
222
255
  */
@@ -978,6 +1011,15 @@ class Redis {
978
1011
  writable: true,
979
1012
  value: (...args) => new mod_js_1.ZLexCountCommand(args, this.opts).exec(this.client)
980
1013
  });
1014
+ /**
1015
+ * @see https://redis.io/commands/zmscore
1016
+ */
1017
+ Object.defineProperty(this, "zmscore", {
1018
+ enumerable: true,
1019
+ configurable: true,
1020
+ writable: true,
1021
+ value: (...args) => new zmscore_js_1.ZMScoreCommand(args, this.opts).exec(this.client)
1022
+ });
981
1023
  /**
982
1024
  * @see https://redis.io/commands/zpopmax
983
1025
  */
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Script = void 0;
4
- const mod_js_1 = require("../deps/denopkg.com/chiefbiiko/sha1@master/mod.js");
4
+ const mod_js_1 = require("../deps/deno.land/x/sha1@v1.0.3/mod.js");
5
5
  /**
6
6
  * Creates a new script.
7
7
  *
@@ -56,6 +56,7 @@ class Redis extends core.Redis {
56
56
  retry: config.retry,
57
57
  baseUrl: config.url,
58
58
  headers: { authorization: `Bearer ${config.token}` },
59
+ responseEncoding: config.responseEncoding,
59
60
  });
60
61
  super(client, {
61
62
  automaticDeserialization: config.automaticDeserialization,
@@ -58,6 +58,7 @@ class Redis extends core.Redis {
58
58
  retry: config.retry,
59
59
  headers: { authorization: `Bearer ${config.token}` },
60
60
  options: { backend: config.backend },
61
+ responseEncoding: config.responseEncoding,
61
62
  });
62
63
  super(client, {
63
64
  automaticDeserialization: config.automaticDeserialization,
@@ -51,7 +51,8 @@ class Redis extends core.Redis {
51
51
  baseUrl: configOrRequester.url,
52
52
  retry: configOrRequester.retry,
53
53
  headers: { authorization: `Bearer ${configOrRequester.token}` },
54
- // agent: configOrRequester.agent,
54
+ // agent: configOrRequester.agent,
55
+ responseEncoding: configOrRequester.responseEncoding,
55
56
  });
56
57
  super(client, {
57
58
  automaticDeserialization: configOrRequester.automaticDeserialization,
@@ -50,7 +50,8 @@ class Redis extends core.Redis {
50
50
  baseUrl: configOrRequester.url,
51
51
  retry: configOrRequester.retry,
52
52
  headers: { authorization: `Bearer ${configOrRequester.token}` },
53
- // agent: configOrRequester.agent,
53
+ agent: configOrRequester.agent,
54
+ responseEncoding: configOrRequester.responseEncoding,
54
55
  });
55
56
  super(client, {
56
57
  automaticDeserialization: configOrRequester.automaticDeserialization,
@@ -0,0 +1 @@
1
+ export { encode, decode } from "../../../denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js";
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/getdel
4
+ */
5
+ export declare class GetDelCommand<TData = string> extends Command<unknown | null, TData | null> {
6
+ constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
7
+ }
@@ -19,6 +19,7 @@ export * from "./get.js";
19
19
  export * from "./getbit.js";
20
20
  export * from "./getrange.js";
21
21
  export * from "./getset.js";
22
+ export * from "./getdel.js";
22
23
  export * from "./hdel.js";
23
24
  export * from "./hexists.js";
24
25
  export * from "./hget.js";
@@ -2,6 +2,7 @@ import { Command, CommandOptions } from "./command.js";
2
2
  export declare type ScanCommandOptions = {
3
3
  match?: string;
4
4
  count?: number;
5
+ type?: string;
5
6
  };
6
7
  /**
7
8
  * @see https://redis.io/commands/scan
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/zmscore
4
+ */
5
+ export declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] | null> {
6
+ constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
7
+ }
@@ -29,20 +29,52 @@ export declare type RetryConfig = false | {
29
29
  */
30
30
  backoff?: (retryCount: number) => number;
31
31
  };
32
- declare type Options = {
32
+ export declare type Options = {
33
33
  backend?: string;
34
34
  };
35
+ export declare type RequesterConfig = {
36
+ /**
37
+ * Configure the retry behaviour in case of network errors
38
+ */
39
+ retry?: RetryConfig;
40
+ /**
41
+ * Due to the nature of dynamic and custom data, it is possible to write data to redis that is not
42
+ * valid json and will therefore cause errors when deserializing. This used to happen very
43
+ * frequently with non-utf8 data, such as emojis.
44
+ *
45
+ * By default we will therefore encode the data as base64 on the server, before sending it to the
46
+ * client. The client will then decode the base64 data and parse it as utf8.
47
+ *
48
+ * For very large entries, this can add a few milliseconds, so if you are sure that your data is
49
+ * valid utf8, you can disable this behaviour by setting this option to false.
50
+ *
51
+ * Here's what the response body looks like:
52
+ *
53
+ * ```json
54
+ * {
55
+ * result?: "base64-encoded",
56
+ * error?: string
57
+ * }
58
+ * ```
59
+ *
60
+ * @default "base64"
61
+ */
62
+ responseEncoding?: false | "base64";
63
+ };
35
64
  export declare type HttpClientConfig = {
36
65
  headers?: Record<string, string>;
37
66
  baseUrl: string;
38
67
  options?: Options;
39
68
  retry?: RetryConfig;
40
- };
69
+ agent?: any;
70
+ } & RequesterConfig;
41
71
  export declare class HttpClient implements Requester {
42
72
  baseUrl: string;
43
73
  headers: Record<string, string>;
44
- readonly options?: {
74
+ readonly options: {
45
75
  backend?: string;
76
+ agent: any;
77
+ responseEncoding?: false | "base64";
46
78
  };
47
79
  readonly retry: {
48
80
  attempts: number;
@@ -51,4 +83,3 @@ export declare class HttpClient implements Requester {
51
83
  constructor(config: HttpClientConfig);
52
84
  request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
53
85
  }
54
- export {};
@@ -18,7 +18,7 @@ import { CommandArgs } from "./types.js";
18
18
  * **Examples:**
19
19
  *
20
20
  * ```ts
21
- * const p = redis.pipeline()
21
+ * const p = redis.pipeline() // or redis.multi()
22
22
  * p.set("key","value")
23
23
  * p.get("key")
24
24
  * const res = await p.exec()
@@ -44,7 +44,12 @@ export declare class Pipeline {
44
44
  private client;
45
45
  private commands;
46
46
  private commandOptions?;
47
- constructor(client: Requester, commandOptions?: CommandOptions<any, any>);
47
+ private multiExec;
48
+ constructor(opts: {
49
+ client: Requester;
50
+ commandOptions?: CommandOptions<any, any>;
51
+ multiExec?: boolean;
52
+ });
48
53
  /**
49
54
  * Send the pipeline request to upstash.
50
55
  *
@@ -138,6 +143,10 @@ export declare class Pipeline {
138
143
  * @see https://redis.io/commands/getbit
139
144
  */
140
145
  getbit: (key: string, offset: number) => this;
146
+ /**
147
+ * @see https://redis.io/commands/getdel
148
+ */
149
+ getdel: <TData>(key: string) => this;
141
150
  /**
142
151
  * @see https://redis.io/commands/getrange
143
152
  */
@@ -374,7 +383,7 @@ export declare class Pipeline {
374
383
  /**
375
384
  * @see https://redis.io/commands/set
376
385
  */
377
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => this;
386
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => this;
378
387
  /**
379
388
  * @see https://redis.io/commands/setbit
380
389
  */
@@ -483,6 +492,10 @@ export declare class Pipeline {
483
492
  * @see https://redis.io/commands/zlexcount
484
493
  */
485
494
  zlexcount: (key: string, min: string, max: string) => this;
495
+ /**
496
+ * @see https://redis.io/commands/zmscore
497
+ */
498
+ zmscore: (key: string, members: unknown[]) => this;
486
499
  /**
487
500
  * @see https://redis.io/commands/zpopmax
488
501
  */
@@ -40,6 +40,16 @@ export declare class Redis {
40
40
  * @see {@link Pipeline}
41
41
  */
42
42
  pipeline: () => Pipeline;
43
+ /**
44
+ * Create a new transaction to allow executing multiple steps atomically.
45
+ *
46
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
47
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
48
+ * guarantees that the commands are executed as a single isolated operation.
49
+ *
50
+ * @see {@link Pipeline}
51
+ */
52
+ multi: () => Pipeline;
43
53
  /**
44
54
  * @see https://redis.io/commands/append
45
55
  */
@@ -117,6 +127,10 @@ export declare class Redis {
117
127
  * @see https://redis.io/commands/getbit
118
128
  */
119
129
  getbit: (key: string, offset: number) => Promise<0 | 1>;
130
+ /**
131
+ * @see https://redis.io/commands/getdel
132
+ */
133
+ getdel: <TData>(key: string) => Promise<TData | null>;
120
134
  /**
121
135
  * @see https://redis.io/commands/getrange
122
136
  */
@@ -356,7 +370,7 @@ export declare class Redis {
356
370
  /**
357
371
  * @see https://redis.io/commands/set
358
372
  */
359
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => Promise<"OK" | TData | null>;
373
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => Promise<"OK" | TData | null>;
360
374
  /**
361
375
  * @see https://redis.io/commands/setbit
362
376
  */
@@ -465,6 +479,10 @@ export declare class Redis {
465
479
  * @see https://redis.io/commands/zlexcount
466
480
  */
467
481
  zlexcount: (key: string, min: string, max: string) => Promise<number>;
482
+ /**
483
+ * @see https://redis.io/commands/zmscore
484
+ */
485
+ zmscore: (key: string, members: unknown[]) => Promise<number[] | null>;
468
486
  /**
469
487
  * @see https://redis.io/commands/zpopmax
470
488
  */
@@ -1,5 +1,6 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import type { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import type { Requester, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
+ import { RequesterConfig } from "../pkg/http.js";
3
4
  export type { Requester, UpstashRequest, UpstashResponse };
4
5
  /**
5
6
  * Connection credentials for upstash redis.
@@ -14,11 +15,7 @@ export declare type RedisConfigCloudflare = {
14
15
  * UPSTASH_REDIS_REST_TOKEN
15
16
  */
16
17
  token: string;
17
- /**
18
- * Configure the retry behaviour in case of network errors
19
- */
20
- retry?: RetryConfig;
21
- } & core.RedisOptions;
18
+ } & core.RedisOptions & RequesterConfig;
22
19
  /**
23
20
  * Serverless redis client for upstash.
24
21
  */
@@ -1,5 +1,5 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import type { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import type { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  export type { Requester, UpstashRequest, UpstashResponse };
4
4
  /**
5
5
  * Connection credentials for upstash redis.
@@ -20,11 +20,7 @@ export declare type RedisConfigFastly = {
20
20
  * referenced by name.
21
21
  */
22
22
  backend: string;
23
- /**
24
- * Configure the retry behaviour in case of network errors
25
- */
26
- retry?: RetryConfig;
27
- } & core.RedisOptions;
23
+ } & core.RedisOptions & RequesterConfig;
28
24
  /**
29
25
  * Serverless redis client for upstash.
30
26
  */
@@ -1,5 +1,5 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  import "isomorphic-fetch";
4
4
  export type { Requester, UpstashRequest, UpstashResponse };
5
5
  /**
@@ -15,26 +15,7 @@ export declare type RedisConfigNodejs = {
15
15
  * UPSTASH_REDIS_REST_TOKEN
16
16
  */
17
17
  token: string;
18
- /**
19
- * An agent allows you to reuse connections to reduce latency for multiple sequential requests.
20
- *
21
- * This is a node specific implementation and is not supported in various runtimes like Vercel
22
- * edge functions.
23
- *
24
- * @example
25
- * ```ts
26
- * import https from "https"
27
- *
28
- * const options: RedisConfigNodejs = {
29
- * agent: new https.Agent({ keepAlive: true })
30
- * }
31
- * ```
32
- */
33
- /**
34
- * Configure the retry behaviour in case of network errors
35
- */
36
- retry?: RetryConfig;
37
- } & core.RedisOptions;
18
+ } & core.RedisOptions & RequesterConfig;
38
19
  /**
39
20
  * Serverless redis client for upstash.
40
21
  */
@@ -1,5 +1,5 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  export type { Requester, UpstashRequest, UpstashResponse };
4
4
  /**
5
5
  * Connection credentials for upstash redis.
@@ -29,11 +29,8 @@ export declare type RedisConfigNodejs = {
29
29
  * }
30
30
  * ```
31
31
  */
32
- /**
33
- * Configure the retry behaviour in case of network errors
34
- */
35
- retry?: RetryConfig;
36
- } & core.RedisOptions;
32
+ agent?: any;
33
+ } & core.RedisOptions & RequesterConfig;
37
34
  /**
38
35
  * Serverless redis client for upstash.
39
36
  */
@@ -1,13 +0,0 @@
1
- import { init } from "./base.js";
2
- const lookup = [];
3
- const revLookup = [];
4
- const code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
5
- for (let i = 0, l = code.length; i < l; ++i) {
6
- lookup[i] = code[i];
7
- revLookup[code.charCodeAt(i)] = i;
8
- }
9
- // Support decoding URL-safe base64 strings, as Node.js does.
10
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
11
- revLookup["-".charCodeAt(0)] = 62;
12
- revLookup["_".charCodeAt(0)] = 63;
13
- export const { byteLength, toUint8Array, fromUint8Array } = init(lookup, revLookup);
@@ -1 +0,0 @@
1
- export { encode, decode } from "../std-encoding@v1.1.1/mod.js";
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.fromUint8Array = exports.toUint8Array = exports.byteLength = void 0;
5
- const base_js_1 = require("./base.js");
6
- const lookup = [];
7
- const revLookup = [];
8
- const code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
9
- for (let i = 0, l = code.length; i < l; ++i) {
10
- lookup[i] = code[i];
11
- revLookup[code.charCodeAt(i)] = i;
12
- }
13
- // Support decoding URL-safe base64 strings, as Node.js does.
14
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
15
- revLookup["-".charCodeAt(0)] = 62;
16
- revLookup["_".charCodeAt(0)] = 63;
17
- _a = (0, base_js_1.init)(lookup, revLookup), exports.byteLength = _a.byteLength, exports.toUint8Array = _a.toUint8Array, exports.fromUint8Array = _a.fromUint8Array;
@@ -1 +0,0 @@
1
- export declare const byteLength: (b64: string) => number, toUint8Array: (b64: string) => Uint8Array, fromUint8Array: (buf: Uint8Array) => string;
@@ -1 +0,0 @@
1
- export { encode, decode } from "../std-encoding@v1.1.1/mod.js";