@upstash/redis 1.16.0-next.3 → 1.16.1-next.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.
package/README.md CHANGED
@@ -81,24 +81,6 @@ data = await redis.spop('animals', 1)
81
81
  console.log(data)
82
82
  ```
83
83
 
84
- ### Upgrading to v1.4.0 **(ReferenceError: fetch is not defined)**
85
-
86
- If you are running on nodejs v17 and earlier, `fetch` will not be natively
87
- supported. Platforms like Vercel, Netlify, Deno, Fastly etc. provide a polyfill
88
- for you. But if you are running on bare node, you need to either specify a
89
- polyfill yourself or change the import path to:
90
-
91
- ```typescript
92
- import { Redis } from "@upstash/redis/with-fetch";
93
- ```
94
-
95
- ### Upgrading from v0.2.0?
96
-
97
- Please read the
98
- [migration guide](https://docs.upstash.com/redis/sdks/javascriptsdk/migration).
99
- For further explanation we wrote a
100
- [blog post](https://blog.upstash.com/upstash-redis-sdk-v1).
101
-
102
84
  ## Docs
103
85
 
104
86
  See [the documentation](https://docs.upstash.com/features/javascriptsdk) for
@@ -118,6 +100,3 @@ the url and token
118
100
  ```sh
119
101
  UPSTASH_REDIS_REST_URL=".." UPSTASH_REDIS_REST_TOKEN=".." deno test -A
120
102
  ```
121
-
122
- ```
123
- ```
@@ -0,0 +1,9 @@
1
+ import { Command } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/getdel
4
+ */
5
+ export class GetDelCommand extends Command {
6
+ constructor(cmd, opts) {
7
+ super(["getdel", ...cmd], opts);
8
+ }
9
+ }
@@ -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";
package/esm/pkg/http.js CHANGED
@@ -25,13 +25,19 @@ export class HttpClient {
25
25
  writable: true,
26
26
  value: void 0
27
27
  });
28
+ this.options = {
29
+ backend: config.options?.backend,
30
+ agent: config.agent,
31
+ responseEncoding: config.responseEncoding ?? "base64", // default to base64
32
+ };
28
33
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
29
34
  this.headers = {
30
35
  "Content-Type": "application/json",
31
- "Upstash-Encoding": "base64",
32
36
  ...config.headers,
33
37
  };
34
- this.options = { backend: config.options?.backend, agent: config.agent };
38
+ if (this.options.responseEncoding === "base64") {
39
+ this.headers["Upstash-Encoding"] = "base64";
40
+ }
35
41
  if (typeof config?.retry === "boolean" && config?.retry === false) {
36
42
  this.retry = {
37
43
  attempts: 1,
@@ -77,23 +83,33 @@ export class HttpClient {
77
83
  if (!res.ok) {
78
84
  throw new UpstashError(body.error);
79
85
  }
80
- return Array.isArray(body) ? body.map(decode) : decode(body);
86
+ if (this.options?.responseEncoding === "base64") {
87
+ return Array.isArray(body) ? body.map(decode) : decode(body);
88
+ }
89
+ return body;
81
90
  }
82
91
  }
83
92
  function base64decode(b64) {
84
93
  let dec = "";
85
94
  try {
86
- dec = atob(b64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("");
95
+ /**
96
+ * Using only atob() is not enough because it doesn't work with unicode characters
97
+ */
98
+ const binString = atob(b64);
99
+ const size = binString.length;
100
+ const bytes = new Uint8Array(size);
101
+ for (let i = 0; i < size; i++) {
102
+ bytes[i] = binString.charCodeAt(i);
103
+ }
104
+ dec = new TextDecoder().decode(bytes);
87
105
  }
88
- catch (e) {
89
- console.warn(`Unable to decode base64 [${dec}]: ${e.message}`);
90
- return dec;
106
+ catch {
107
+ dec = b64;
91
108
  }
92
109
  try {
93
110
  return decodeURIComponent(dec);
94
111
  }
95
- catch (e) {
96
- console.warn(`Unable to decode URI [${dec}]: ${e.message}`);
112
+ catch {
97
113
  return dec;
98
114
  }
99
115
  }
@@ -102,10 +118,11 @@ function decode(raw) {
102
118
  switch (typeof raw.result) {
103
119
  case "undefined":
104
120
  return raw;
105
- case "number":
121
+ case "number": {
106
122
  result = raw.result;
107
123
  break;
108
- case "object":
124
+ }
125
+ case "object": {
109
126
  if (Array.isArray(raw.result)) {
110
127
  result = raw.result.map((v) => typeof v === "string"
111
128
  ? base64decode(v)
@@ -119,9 +136,11 @@ function decode(raw) {
119
136
  result = null;
120
137
  }
121
138
  break;
122
- case "string":
139
+ }
140
+ case "string": {
123
141
  result = raw.result === "OK" ? "OK" : base64decode(raw.result);
124
142
  break;
143
+ }
125
144
  default:
126
145
  break;
127
146
  }
@@ -1,4 +1,4 @@
1
- import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
1
+ import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
2
2
  import { UpstashError } from "./error.js";
3
3
  import { ZMScoreCommand } from "./commands/zmscore.js";
4
4
  /**
@@ -258,6 +258,15 @@ export class Pipeline {
258
258
  writable: true,
259
259
  value: (...args) => this.chain(new GetBitCommand(args, this.commandOptions))
260
260
  });
261
+ /**
262
+ * @see https://redis.io/commands/getdel
263
+ */
264
+ Object.defineProperty(this, "getdel", {
265
+ enumerable: true,
266
+ configurable: true,
267
+ writable: true,
268
+ value: (...args) => this.chain(new GetDelCommand(args, this.commandOptions))
269
+ });
261
270
  /**
262
271
  * @see https://redis.io/commands/getrange
263
272
  */
package/esm/pkg/redis.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
1
+ import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
2
2
  import { Pipeline } from "./pipeline.js";
3
3
  import { Script } from "./script.js";
4
4
  import { ZMScoreCommand } from "./commands/zmscore.js";
@@ -238,6 +238,15 @@ export class Redis {
238
238
  writable: true,
239
239
  value: (...args) => new GetBitCommand(args, this.opts).exec(this.client)
240
240
  });
241
+ /**
242
+ * @see https://redis.io/commands/getdel
243
+ */
244
+ Object.defineProperty(this, "getdel", {
245
+ enumerable: true,
246
+ configurable: true,
247
+ writable: true,
248
+ value: (...args) => new GetDelCommand(args, this.opts).exec(this.client)
249
+ });
241
250
  /**
242
251
  * @see https://redis.io/commands/getrange
243
252
  */
@@ -30,6 +30,7 @@ export class Redis extends core.Redis {
30
30
  retry: config.retry,
31
31
  baseUrl: config.url,
32
32
  headers: { authorization: `Bearer ${config.token}` },
33
+ responseEncoding: config.responseEncoding,
33
34
  });
34
35
  super(client, {
35
36
  automaticDeserialization: config.automaticDeserialization,
@@ -32,6 +32,7 @@ export class Redis extends core.Redis {
32
32
  retry: config.retry,
33
33
  headers: { authorization: `Bearer ${config.token}` },
34
34
  options: { backend: config.backend },
35
+ responseEncoding: config.responseEncoding,
35
36
  });
36
37
  super(client, {
37
38
  automaticDeserialization: config.automaticDeserialization,
@@ -25,7 +25,8 @@ export class Redis extends core.Redis {
25
25
  baseUrl: configOrRequester.url,
26
26
  retry: configOrRequester.retry,
27
27
  headers: { authorization: `Bearer ${configOrRequester.token}` },
28
- // agent: configOrRequester.agent,
28
+ // agent: configOrRequester.agent,
29
+ responseEncoding: configOrRequester.responseEncoding,
29
30
  });
30
31
  super(client, {
31
32
  automaticDeserialization: configOrRequester.automaticDeserialization,
@@ -25,6 +25,7 @@ export class Redis extends core.Redis {
25
25
  retry: configOrRequester.retry,
26
26
  headers: { authorization: `Bearer ${configOrRequester.token}` },
27
27
  agent: configOrRequester.agent,
28
+ responseEncoding: configOrRequester.responseEncoding,
28
29
  });
29
30
  super(client, {
30
31
  automaticDeserialization: configOrRequester.automaticDeserialization,
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "types": "./types/platforms/node_with_fetch.d.ts"
60
60
  }
61
61
  },
62
- "version": "1.16.0-next.3"
62
+ "version": "1.16.1-next.1"
63
63
  }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetDelCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/getdel
7
+ */
8
+ class GetDelCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ super(["getdel", ...cmd], opts);
11
+ }
12
+ }
13
+ exports.GetDelCommand = GetDelCommand;
@@ -35,6 +35,7 @@ __exportStar(require("./get.js"), exports);
35
35
  __exportStar(require("./getbit.js"), exports);
36
36
  __exportStar(require("./getrange.js"), exports);
37
37
  __exportStar(require("./getset.js"), exports);
38
+ __exportStar(require("./getdel.js"), exports);
38
39
  __exportStar(require("./hdel.js"), exports);
39
40
  __exportStar(require("./hexists.js"), exports);
40
41
  __exportStar(require("./hget.js"), exports);
@@ -28,13 +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
37
  this.headers = {
33
38
  "Content-Type": "application/json",
34
- "Upstash-Encoding": "base64",
35
39
  ...config.headers,
36
40
  };
37
- this.options = { backend: config.options?.backend, agent: config.agent };
41
+ if (this.options.responseEncoding === "base64") {
42
+ this.headers["Upstash-Encoding"] = "base64";
43
+ }
38
44
  if (typeof config?.retry === "boolean" && config?.retry === false) {
39
45
  this.retry = {
40
46
  attempts: 1,
@@ -80,24 +86,34 @@ class HttpClient {
80
86
  if (!res.ok) {
81
87
  throw new error_js_1.UpstashError(body.error);
82
88
  }
83
- return Array.isArray(body) ? body.map(decode) : decode(body);
89
+ if (this.options?.responseEncoding === "base64") {
90
+ return Array.isArray(body) ? body.map(decode) : decode(body);
91
+ }
92
+ return body;
84
93
  }
85
94
  }
86
95
  exports.HttpClient = HttpClient;
87
96
  function base64decode(b64) {
88
97
  let dec = "";
89
98
  try {
90
- dec = atob(b64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("");
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);
91
109
  }
92
- catch (e) {
93
- console.warn(`Unable to decode base64 [${dec}]: ${e.message}`);
94
- return dec;
110
+ catch {
111
+ dec = b64;
95
112
  }
96
113
  try {
97
114
  return decodeURIComponent(dec);
98
115
  }
99
- catch (e) {
100
- console.warn(`Unable to decode URI [${dec}]: ${e.message}`);
116
+ catch {
101
117
  return dec;
102
118
  }
103
119
  }
@@ -106,10 +122,11 @@ function decode(raw) {
106
122
  switch (typeof raw.result) {
107
123
  case "undefined":
108
124
  return raw;
109
- case "number":
125
+ case "number": {
110
126
  result = raw.result;
111
127
  break;
112
- case "object":
128
+ }
129
+ case "object": {
113
130
  if (Array.isArray(raw.result)) {
114
131
  result = raw.result.map((v) => typeof v === "string"
115
132
  ? base64decode(v)
@@ -123,9 +140,11 @@ function decode(raw) {
123
140
  result = null;
124
141
  }
125
142
  break;
126
- case "string":
143
+ }
144
+ case "string": {
127
145
  result = raw.result === "OK" ? "OK" : base64decode(raw.result);
128
146
  break;
147
+ }
129
148
  default:
130
149
  break;
131
150
  }
@@ -261,6 +261,15 @@ class Pipeline {
261
261
  writable: true,
262
262
  value: (...args) => this.chain(new mod_js_1.GetBitCommand(args, this.commandOptions))
263
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
+ });
264
273
  /**
265
274
  * @see https://redis.io/commands/getrange
266
275
  */
@@ -241,6 +241,15 @@ class Redis {
241
241
  writable: true,
242
242
  value: (...args) => new mod_js_1.GetBitCommand(args, this.opts).exec(this.client)
243
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
+ });
244
253
  /**
245
254
  * @see https://redis.io/commands/getrange
246
255
  */
@@ -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,
@@ -51,6 +51,7 @@ class Redis extends core.Redis {
51
51
  retry: configOrRequester.retry,
52
52
  headers: { authorization: `Bearer ${configOrRequester.token}` },
53
53
  agent: configOrRequester.agent,
54
+ responseEncoding: configOrRequester.responseEncoding,
54
55
  });
55
56
  super(client, {
56
57
  automaticDeserialization: configOrRequester.automaticDeserialization,
@@ -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";
@@ -29,22 +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;
41
- };
70
+ } & RequesterConfig;
42
71
  export declare class HttpClient implements Requester {
43
72
  baseUrl: string;
44
73
  headers: Record<string, string>;
45
- readonly options?: {
74
+ readonly options: {
46
75
  backend?: string;
47
76
  agent: any;
77
+ responseEncoding?: false | "base64";
48
78
  };
49
79
  readonly retry: {
50
80
  attempts: number;
@@ -53,4 +83,3 @@ export declare class HttpClient implements Requester {
53
83
  constructor(config: HttpClientConfig);
54
84
  request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
55
85
  }
56
- export {};
@@ -143,6 +143,10 @@ export declare class Pipeline {
143
143
  * @see https://redis.io/commands/getbit
144
144
  */
145
145
  getbit: (key: string, offset: number) => this;
146
+ /**
147
+ * @see https://redis.io/commands/getdel
148
+ */
149
+ getdel: <TData>(key: string) => this;
146
150
  /**
147
151
  * @see https://redis.io/commands/getrange
148
152
  */
@@ -127,6 +127,10 @@ export declare class Redis {
127
127
  * @see https://redis.io/commands/getbit
128
128
  */
129
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>;
130
134
  /**
131
135
  * @see https://redis.io/commands/getrange
132
136
  */
@@ -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.
@@ -30,11 +30,7 @@ export declare type RedisConfigNodejs = {
30
30
  * ```
31
31
  */
32
32
  agent?: any;
33
- /**
34
- * Configure the retry behaviour in case of network errors
35
- */
36
- retry?: RetryConfig;
37
- } & core.RedisOptions;
33
+ } & core.RedisOptions & RequesterConfig;
38
34
  /**
39
35
  * Serverless redis client for upstash.
40
36
  */