@upstash/redis 0.0.0-ci.e1d39d33 → 0.0.0-ci.efe72030

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 (47) hide show
  1. package/README.md +36 -274
  2. package/esm/pkg/commands/lpos.js +19 -0
  3. package/esm/pkg/commands/mod.js +1 -0
  4. package/esm/pkg/commands/script_exists.js +1 -10
  5. package/esm/pkg/commands/sdiffstore.js +1 -1
  6. package/esm/pkg/commands/zrange.js +6 -0
  7. package/esm/pkg/http.js +35 -7
  8. package/esm/pkg/pipeline.js +10 -1
  9. package/esm/pkg/redis.js +22 -1
  10. package/esm/platforms/cloudflare.js +5 -25
  11. package/esm/platforms/fastly.js +4 -25
  12. package/esm/platforms/node_with_fetch.js +4 -25
  13. package/esm/platforms/nodejs.js +4 -25
  14. package/package.json +24 -13
  15. package/script/pkg/commands/lpos.js +23 -0
  16. package/script/pkg/commands/mod.js +1 -0
  17. package/script/pkg/commands/script_exists.js +1 -10
  18. package/script/pkg/commands/sdiffstore.js +1 -1
  19. package/script/pkg/commands/zrange.js +6 -0
  20. package/script/pkg/http.js +35 -7
  21. package/script/pkg/pipeline.js +9 -0
  22. package/script/pkg/redis.js +21 -0
  23. package/script/platforms/cloudflare.js +5 -25
  24. package/script/platforms/fastly.js +4 -25
  25. package/script/platforms/node_with_fetch.js +4 -25
  26. package/script/platforms/nodejs.js +4 -25
  27. package/types/pkg/commands/bitop.d.ts +0 -1
  28. package/types/pkg/commands/bitpos.d.ts +1 -1
  29. package/types/pkg/commands/hmset.d.ts +2 -2
  30. package/types/pkg/commands/lpop.d.ts +1 -1
  31. package/types/pkg/commands/lpos.d.ts +15 -0
  32. package/types/pkg/commands/mget.d.ts +1 -1
  33. package/types/pkg/commands/mod.d.ts +1 -0
  34. package/types/pkg/commands/rpop.d.ts +2 -2
  35. package/types/pkg/commands/script_exists.d.ts +2 -4
  36. package/types/pkg/commands/sdiffstore.d.ts +1 -1
  37. package/types/pkg/commands/sinterstore.d.ts +2 -2
  38. package/types/pkg/commands/spop.d.ts +2 -2
  39. package/types/pkg/commands/zadd.d.ts +1 -1
  40. package/types/pkg/commands/zrange.d.ts +7 -0
  41. package/types/pkg/http.d.ts +27 -3
  42. package/types/pkg/pipeline.d.ts +14 -6
  43. package/types/pkg/redis.d.ts +22 -10
  44. package/types/platforms/cloudflare.d.ts +6 -2
  45. package/types/platforms/fastly.d.ts +5 -1
  46. package/types/platforms/node_with_fetch.d.ts +20 -1
  47. package/types/platforms/nodejs.d.ts +20 -1
@@ -1,6 +1,6 @@
1
1
  // deno-lint-ignore-file
2
2
  import * as core from "../pkg/redis.js";
3
- import { UpstashError } from "../pkg/error.js";
3
+ import { HttpClient, } from "../pkg/http.js";
4
4
  import "isomorphic-fetch";
5
5
  /**
6
6
  * Serverless redis client for upstash.
@@ -21,8 +21,9 @@ export class Redis extends core.Redis {
21
21
  /\r|\n/.test(configOrRequester.token)) {
22
22
  console.warn("The redis token contains whitespace or newline, which can cause errors!");
23
23
  }
24
- const client = defaultRequester({
24
+ const client = new HttpClient({
25
25
  baseUrl: configOrRequester.url,
26
+ retry: configOrRequester.retry,
26
27
  headers: { authorization: `Bearer ${configOrRequester.token}` },
27
28
  // agent: configOrRequester.agent,
28
29
  });
@@ -54,28 +55,6 @@ export class Redis extends core.Redis {
54
55
  if (!token) {
55
56
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
56
57
  }
57
- return new Redis({ url, token, ...config });
58
+ return new Redis({ ...config, url, token });
58
59
  }
59
60
  }
60
- function defaultRequester(config) {
61
- return {
62
- request: async function (req) {
63
- if (!req.path) {
64
- req.path = [];
65
- }
66
- const res = await fetch([config.baseUrl, ...req.path].join("/"), {
67
- method: "POST",
68
- headers: { "Content-Type": "application/json", ...config.headers },
69
- body: JSON.stringify(req.body),
70
- keepalive: true,
71
- // @ts-ignore
72
- agent: config.agent,
73
- });
74
- const body = (await res.json());
75
- if (!res.ok) {
76
- throw new UpstashError(body.error);
77
- }
78
- return body;
79
- },
80
- };
81
- }
@@ -1,6 +1,6 @@
1
1
  // deno-lint-ignore-file
2
2
  import * as core from "../pkg/redis.js";
3
- import { UpstashError } from "../pkg/error.js";
3
+ import { HttpClient, } from "../pkg/http.js";
4
4
  /**
5
5
  * Serverless redis client for upstash.
6
6
  */
@@ -20,8 +20,9 @@ export class Redis extends core.Redis {
20
20
  /\r|\n/.test(configOrRequester.token)) {
21
21
  console.warn("The redis token contains whitespace or newline, which can cause errors!");
22
22
  }
23
- const client = defaultRequester({
23
+ const client = new HttpClient({
24
24
  baseUrl: configOrRequester.url,
25
+ retry: configOrRequester.retry,
25
26
  headers: { authorization: `Bearer ${configOrRequester.token}` },
26
27
  // agent: configOrRequester.agent,
27
28
  });
@@ -53,28 +54,6 @@ export class Redis extends core.Redis {
53
54
  if (!token) {
54
55
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
55
56
  }
56
- return new Redis({ url, token, ...config });
57
+ return new Redis({ ...config, url, token });
57
58
  }
58
59
  }
59
- function defaultRequester(config) {
60
- return {
61
- request: async function (req) {
62
- if (!req.path) {
63
- req.path = [];
64
- }
65
- const res = await fetch([config.baseUrl, ...req.path].join("/"), {
66
- method: "POST",
67
- headers: { "Content-Type": "application/json", ...config.headers },
68
- body: JSON.stringify(req.body),
69
- keepalive: true,
70
- // @ts-ignore
71
- agent: config.agent,
72
- });
73
- const body = (await res.json());
74
- if (!res.ok) {
75
- throw new UpstashError(body.error);
76
- }
77
- return body;
78
- },
79
- };
80
- }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/platforms/nodejs.js",
4
4
  "types": "./types/platforms/nodejs.d.ts",
5
5
  "name": "@upstash/redis",
6
- "version": "v0.0.0-ci.e1d39d33",
6
+ "version": "v0.0.0-ci.efe72030",
7
7
  "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
8
8
  "repository": {
9
9
  "type": "git",
@@ -16,36 +16,43 @@
16
16
  "edge",
17
17
  "upstash"
18
18
  ],
19
- "author": "Andreas Thomas <andreas.thomas@chronark.com>",
19
+ "author": "Andreas Thomas <dev@chronark.com>",
20
20
  "license": "MIT",
21
21
  "bugs": {
22
22
  "url": "https://github.com/upstash/upstash-redis/issues"
23
23
  },
24
- "dependencies": {
25
- "isomorphic-fetch": "^3.0.0"
26
- },
27
24
  "homepage": "https://github.com/upstash/upstash-redis#readme",
28
- "browser": {
29
- "isomorphic-fetch": false,
30
- "http": false,
31
- "https": false
32
- },
33
25
  "devDependencies": {
34
26
  "@size-limit/preset-small-lib": "latest",
35
27
  "size-limit": "latest"
36
28
  },
29
+ "dependencies": {
30
+ "isomorphic-fetch": "^3.0.0"
31
+ },
32
+ "typesVersions": {
33
+ "*": {
34
+ "nodejs": "./types/platforms/nodejs.d.ts",
35
+ "cloudflare": "./types/platforms/cloudflare.d.ts",
36
+ "fastly": "./types/platforms/fastly.d.ts",
37
+ "with-fetch": "./types/platforms/node_with_fetch.d.ts"
38
+ }
39
+ },
37
40
  "size-limit": [
38
41
  {
39
42
  "path": "esm/platforms/nodejs.js",
40
- "limit": "5 KB"
43
+ "limit": "6 KB"
41
44
  },
42
45
  {
43
46
  "path": "esm/platforms/fastly.js",
44
- "limit": "5 KB"
47
+ "limit": "6 KB"
45
48
  },
46
49
  {
47
50
  "path": "esm/platforms/cloudflare.js",
48
- "limit": "5 KB"
51
+ "limit": "6 KB"
52
+ },
53
+ {
54
+ "path": "esm/platforms/node_with_fetch.js",
55
+ "limit": "15 KB"
49
56
  },
50
57
  {
51
58
  "path": "script/platforms/nodejs.js",
@@ -58,6 +65,10 @@
58
65
  {
59
66
  "path": "script/platforms/cloudflare.js",
60
67
  "limit": "10 KB"
68
+ },
69
+ {
70
+ "path": "script/platforms/node_with_fetch.js",
71
+ "limit": "15 KB"
61
72
  }
62
73
  ],
63
74
  "exports": {
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LPosCommand = void 0;
4
+ const command_js_1 = require("./command.js");
5
+ /**
6
+ * @see https://redis.io/commands/lpos
7
+ */
8
+ class LPosCommand extends command_js_1.Command {
9
+ constructor(cmd, opts) {
10
+ const args = ["lpos", cmd[0], cmd[1]];
11
+ if (typeof cmd[2]?.rank === "number") {
12
+ args.push("rank", cmd[2].rank);
13
+ }
14
+ if (typeof cmd[2]?.count === "number") {
15
+ args.push("count", cmd[2].count);
16
+ }
17
+ if (typeof cmd[2]?.maxLen === "number") {
18
+ args.push("maxLen", cmd[2].maxLen);
19
+ }
20
+ super(args, opts);
21
+ }
22
+ }
23
+ exports.LPosCommand = LPosCommand;
@@ -58,6 +58,7 @@ __exportStar(require("./lindex.js"), exports);
58
58
  __exportStar(require("./linsert.js"), exports);
59
59
  __exportStar(require("./llen.js"), exports);
60
60
  __exportStar(require("./lpop.js"), exports);
61
+ __exportStar(require("./lpos.js"), exports);
61
62
  __exportStar(require("./lpush.js"), exports);
62
63
  __exportStar(require("./lpushx.js"), exports);
63
64
  __exportStar(require("./lrange.js"), exports);
@@ -8,16 +8,7 @@ const command_js_1 = require("./command.js");
8
8
  class ScriptExistsCommand extends command_js_1.Command {
9
9
  constructor(hashes, opts) {
10
10
  super(["script", "exists", ...hashes], {
11
- deserialize: (result) => {
12
- /**
13
- * This isn't very pretty but it does the job.
14
- * The user facing api is clean and will return a single `string` if they provided
15
- * a single script hash, and an array of strings of the same length when given an
16
- * array of hashes.
17
- */
18
- const parsed = result;
19
- return parsed.length === 1 ? parsed[0] : parsed;
20
- },
11
+ deserialize: (result) => result,
21
12
  ...opts,
22
13
  });
23
14
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDiffStoreCommand = void 0;
4
4
  const command_js_1 = require("./command.js");
5
5
  /**
6
- * @see https://redis.io/commands/sdiffstpre
6
+ * @see https://redis.io/commands/sdiffstore
7
7
  */
8
8
  class SDiffStoreCommand extends command_js_1.Command {
9
9
  constructor(cmd, opts) {
@@ -15,6 +15,12 @@ class ZRangeCommand extends command_js_1.Command {
15
15
  if (opts?.byLex) {
16
16
  command.push("bylex");
17
17
  }
18
+ if (opts?.rev) {
19
+ command.push("rev");
20
+ }
21
+ if (typeof opts?.count !== "undefined" && typeof opts?.offset !== "undefined") {
22
+ command.push("limit", opts.offset, opts.count);
23
+ }
18
24
  if (opts?.withScores) {
19
25
  command.push("withscores");
20
26
  }
@@ -22,14 +22,30 @@ class HttpClient {
22
22
  writable: true,
23
23
  value: void 0
24
24
  });
25
+ Object.defineProperty(this, "retry", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: void 0
30
+ });
25
31
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
26
32
  this.headers = { "Content-Type": "application/json", ...config.headers };
27
- this.options = config.options;
33
+ this.options = { backend: config.options?.backend };
34
+ if (typeof config?.retry === "boolean" && config?.retry === false) {
35
+ this.retry = {
36
+ attempts: 1,
37
+ backoff: () => 0,
38
+ };
39
+ }
40
+ else {
41
+ this.retry = {
42
+ attempts: config?.retry?.retries ?? 5,
43
+ backoff: config?.retry?.backoff ??
44
+ ((retryCount) => Math.exp(retryCount) * 50),
45
+ };
46
+ }
28
47
  }
29
48
  async request(req) {
30
- if (!req.path) {
31
- req.path = [];
32
- }
33
49
  const requestOptions = {
34
50
  method: "POST",
35
51
  headers: this.headers,
@@ -40,9 +56,21 @@ class HttpClient {
40
56
  */
41
57
  backend: this.options?.backend,
42
58
  };
43
- // fetch is defined by isomorphic fetch
44
- // eslint-disable-next-line no-undef
45
- const res = await fetch([this.baseUrl, ...req.path].join("/"), requestOptions);
59
+ let res = null;
60
+ let error = null;
61
+ for (let i = 0; i <= this.retry.attempts; i++) {
62
+ try {
63
+ res = await fetch([this.baseUrl, ...(req.path ?? [])].join("/"), requestOptions);
64
+ break;
65
+ }
66
+ catch (err) {
67
+ error = err;
68
+ await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
69
+ }
70
+ }
71
+ if (!res) {
72
+ throw error ?? new Error("Exhausted all retries");
73
+ }
46
74
  const body = (await res.json());
47
75
  if (!res.ok) {
48
76
  throw new error_js_1.UpstashError(body.error);
@@ -478,6 +478,15 @@ class Pipeline {
478
478
  writable: true,
479
479
  value: (...args) => this.chain(new mod_js_1.LPopCommand(args, this.commandOptions))
480
480
  });
481
+ /**
482
+ * @see https://redis.io/commands/lpos
483
+ */
484
+ Object.defineProperty(this, "lpos", {
485
+ enumerable: true,
486
+ configurable: true,
487
+ writable: true,
488
+ value: (...args) => this.chain(new mod_js_1.LPosCommand(args, this.commandOptions))
489
+ });
481
490
  /**
482
491
  * @see https://redis.io/commands/lpush
483
492
  */
@@ -31,6 +31,18 @@ class Redis {
31
31
  writable: true,
32
32
  value: void 0
33
33
  });
34
+ /**
35
+ * Wrap a new middleware around the HTTP client.
36
+ */
37
+ Object.defineProperty(this, "use", {
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true,
41
+ value: (middleware) => {
42
+ const makeRequest = this.client.request.bind(this.client);
43
+ this.client.request = (req) => middleware(req, makeRequest);
44
+ }
45
+ });
34
46
  /**
35
47
  * Create a new pipeline that allows you to send requests in bulk.
36
48
  *
@@ -429,6 +441,15 @@ class Redis {
429
441
  writable: true,
430
442
  value: (...args) => new mod_js_1.LPopCommand(args, this.opts).exec(this.client)
431
443
  });
444
+ /**
445
+ * @see https://redis.io/commands/lpos
446
+ */
447
+ Object.defineProperty(this, "lpos", {
448
+ enumerable: true,
449
+ configurable: true,
450
+ writable: true,
451
+ value: (...args) => new mod_js_1.LPosCommand(args, this.opts).exec(this.client)
452
+ });
432
453
  /**
433
454
  * @see https://redis.io/commands/lpush
434
455
  */
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Redis = void 0;
27
27
  const core = __importStar(require("../pkg/redis.js"));
28
- const error_js_1 = require("../pkg/error.js");
28
+ const http_js_1 = require("../pkg/http.js");
29
29
  /**
30
30
  * Serverless redis client for upstash.
31
31
  */
@@ -52,7 +52,8 @@ class Redis extends core.Redis {
52
52
  /\r|\n/.test(config.token)) {
53
53
  console.warn("The redis token contains whitespace or newline, which can cause errors!");
54
54
  }
55
- const client = defaultRequester({
55
+ const client = new http_js_1.HttpClient({
56
+ retry: config.retry,
56
57
  baseUrl: config.url,
57
58
  headers: { authorization: `Bearer ${config.token}` },
58
59
  });
@@ -70,9 +71,8 @@ class Redis extends core.Redis {
70
71
  * ```ts
71
72
  * const redis = Redis.fromEnv(env)
72
73
  * ```
73
- *
74
74
  */
75
- static fromEnv(env) {
75
+ static fromEnv(env, opts) {
76
76
  // @ts-ignore These will be defined by cloudflare
77
77
  const url = env?.UPSTASH_REDIS_REST_URL ?? UPSTASH_REDIS_REST_URL;
78
78
  // @ts-ignore These will be defined by cloudflare
@@ -83,27 +83,7 @@ class Redis extends core.Redis {
83
83
  if (!token) {
84
84
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`");
85
85
  }
86
- return new Redis({ url, token });
86
+ return new Redis({ ...opts, url, token });
87
87
  }
88
88
  }
89
89
  exports.Redis = Redis;
90
- function defaultRequester(config) {
91
- return {
92
- request: async function (req) {
93
- if (!req.path) {
94
- req.path = [];
95
- }
96
- const res = await fetch([config.baseUrl, ...req.path].join("/"), {
97
- method: "POST",
98
- headers: { "Content-Type": "application/json", ...config.headers },
99
- body: JSON.stringify(req.body),
100
- keepalive: true,
101
- });
102
- const body = (await res.json());
103
- if (!res.ok) {
104
- throw new error_js_1.UpstashError(body.error);
105
- }
106
- return body;
107
- },
108
- };
109
- }
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Redis = void 0;
27
27
  const core = __importStar(require("../pkg/redis.js"));
28
- const error_js_1 = require("../pkg/error.js");
28
+ const http_js_1 = require("../pkg/http.js");
29
29
  /**
30
30
  * Serverless redis client for upstash.
31
31
  */
@@ -53,10 +53,11 @@ class Redis extends core.Redis {
53
53
  /\r|\n/.test(config.token)) {
54
54
  console.warn("The redis token contains whitespace or newline, which can cause errors!");
55
55
  }
56
- const client = defaultRequester({
56
+ const client = new http_js_1.HttpClient({
57
57
  baseUrl: config.url,
58
+ retry: config.retry,
58
59
  headers: { authorization: `Bearer ${config.token}` },
59
- backend: config.backend,
60
+ options: { backend: config.backend },
60
61
  });
61
62
  super(client, {
62
63
  automaticDeserialization: config.automaticDeserialization,
@@ -64,25 +65,3 @@ class Redis extends core.Redis {
64
65
  }
65
66
  }
66
67
  exports.Redis = Redis;
67
- function defaultRequester(config) {
68
- return {
69
- request: async function (req) {
70
- if (!req.path) {
71
- req.path = [];
72
- }
73
- const res = await fetch([config.baseUrl, ...req.path].join("/"), {
74
- method: "POST",
75
- headers: { "Content-Type": "application/json", ...config.headers },
76
- body: JSON.stringify(req.body),
77
- keepalive: true,
78
- // @ts-expect-error fastly requires `backend`
79
- backend: config.backend,
80
- });
81
- const body = (await res.json());
82
- if (!res.ok) {
83
- throw new error_js_1.UpstashError(body.error);
84
- }
85
- return body;
86
- },
87
- };
88
- }
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.Redis = void 0;
28
28
  const core = __importStar(require("../pkg/redis.js"));
29
- const error_js_1 = require("../pkg/error.js");
29
+ const http_js_1 = require("../pkg/http.js");
30
30
  require("isomorphic-fetch");
31
31
  /**
32
32
  * Serverless redis client for upstash.
@@ -47,8 +47,9 @@ class Redis extends core.Redis {
47
47
  /\r|\n/.test(configOrRequester.token)) {
48
48
  console.warn("The redis token contains whitespace or newline, which can cause errors!");
49
49
  }
50
- const client = defaultRequester({
50
+ const client = new http_js_1.HttpClient({
51
51
  baseUrl: configOrRequester.url,
52
+ retry: configOrRequester.retry,
52
53
  headers: { authorization: `Bearer ${configOrRequester.token}` },
53
54
  // agent: configOrRequester.agent,
54
55
  });
@@ -80,29 +81,7 @@ class Redis extends core.Redis {
80
81
  if (!token) {
81
82
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
82
83
  }
83
- return new Redis({ url, token, ...config });
84
+ return new Redis({ ...config, url, token });
84
85
  }
85
86
  }
86
87
  exports.Redis = Redis;
87
- function defaultRequester(config) {
88
- return {
89
- request: async function (req) {
90
- if (!req.path) {
91
- req.path = [];
92
- }
93
- const res = await fetch([config.baseUrl, ...req.path].join("/"), {
94
- method: "POST",
95
- headers: { "Content-Type": "application/json", ...config.headers },
96
- body: JSON.stringify(req.body),
97
- keepalive: true,
98
- // @ts-ignore
99
- agent: config.agent,
100
- });
101
- const body = (await res.json());
102
- if (!res.ok) {
103
- throw new error_js_1.UpstashError(body.error);
104
- }
105
- return body;
106
- },
107
- };
108
- }
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.Redis = void 0;
28
28
  const core = __importStar(require("../pkg/redis.js"));
29
- const error_js_1 = require("../pkg/error.js");
29
+ const http_js_1 = require("../pkg/http.js");
30
30
  /**
31
31
  * Serverless redis client for upstash.
32
32
  */
@@ -46,8 +46,9 @@ class Redis extends core.Redis {
46
46
  /\r|\n/.test(configOrRequester.token)) {
47
47
  console.warn("The redis token contains whitespace or newline, which can cause errors!");
48
48
  }
49
- const client = defaultRequester({
49
+ const client = new http_js_1.HttpClient({
50
50
  baseUrl: configOrRequester.url,
51
+ retry: configOrRequester.retry,
51
52
  headers: { authorization: `Bearer ${configOrRequester.token}` },
52
53
  // agent: configOrRequester.agent,
53
54
  });
@@ -79,29 +80,7 @@ class Redis extends core.Redis {
79
80
  if (!token) {
80
81
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
81
82
  }
82
- return new Redis({ url, token, ...config });
83
+ return new Redis({ ...config, url, token });
83
84
  }
84
85
  }
85
86
  exports.Redis = Redis;
86
- function defaultRequester(config) {
87
- return {
88
- request: async function (req) {
89
- if (!req.path) {
90
- req.path = [];
91
- }
92
- const res = await fetch([config.baseUrl, ...req.path].join("/"), {
93
- method: "POST",
94
- headers: { "Content-Type": "application/json", ...config.headers },
95
- body: JSON.stringify(req.body),
96
- keepalive: true,
97
- // @ts-ignore
98
- agent: config.agent,
99
- });
100
- const body = (await res.json());
101
- if (!res.ok) {
102
- throw new error_js_1.UpstashError(body.error);
103
- }
104
- return body;
105
- },
106
- };
107
- }
@@ -6,7 +6,6 @@ export declare class BitOpCommand extends Command<number, number> {
6
6
  constructor(cmd: [
7
7
  op: "and" | "or" | "xor",
8
8
  destinationKey: string,
9
- sourceKey: string,
10
9
  ...sourceKeys: string[]
11
10
  ], opts?: CommandOptions<number, number>);
12
11
  constructor(cmd: [op: "not", destinationKey: string, sourceKey: string], opts?: CommandOptions<number, number>);
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/bitpos
4
4
  */
5
5
  export declare class BitPosCommand extends Command<number, number> {
6
- constructor(cmd: [key: string, start: number, end: number], opts?: CommandOptions<number, number>);
6
+ constructor(cmd: [key: string, bit: 0 | 1, start?: number, end?: number], opts?: CommandOptions<number, number>);
7
7
  }
@@ -2,8 +2,8 @@ import { Command, CommandOptions } from "./command.js";
2
2
  /**
3
3
  * @see https://redis.io/commands/hmset
4
4
  */
5
- export declare class HMSetCommand<TData> extends Command<number, number> {
5
+ export declare class HMSetCommand<TData> extends Command<"OK", "OK"> {
6
6
  constructor([key, kv]: [key: string, kv: {
7
7
  [field: string]: TData;
8
- }], opts?: CommandOptions<number, number>);
8
+ }], opts?: CommandOptions<"OK", "OK">);
9
9
  }
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/lpop
4
4
  */
5
5
  export declare class LPopCommand<TData = string> extends Command<unknown | null, TData | null> {
6
- constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
6
+ constructor(cmd: [key: string, count?: number], opts?: CommandOptions<unknown | null, TData | null>);
7
7
  }
@@ -0,0 +1,15 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/lpos
4
+ */
5
+ export declare class LPosCommand<TData = number> extends Command<TData, TData> {
6
+ constructor(cmd: [
7
+ key: string,
8
+ element: unknown,
9
+ opts?: {
10
+ rank?: number;
11
+ count?: number;
12
+ maxLen?: number;
13
+ }
14
+ ], opts?: CommandOptions<TData, TData>);
15
+ }
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/mget
4
4
  */
5
5
  export declare class MGetCommand<TData extends unknown[]> extends Command<(string | null)[], TData> {
6
- constructor(cmd: [...keys: [string, ...string[]]], opts?: CommandOptions<(string | null)[], TData>);
6
+ constructor(cmd: [...keys: string[]], opts?: CommandOptions<(string | null)[], TData>);
7
7
  }
@@ -42,6 +42,7 @@ export * from "./lindex.js";
42
42
  export * from "./linsert.js";
43
43
  export * from "./llen.js";
44
44
  export * from "./lpop.js";
45
+ export * from "./lpos.js";
45
46
  export * from "./lpush.js";
46
47
  export * from "./lpushx.js";
47
48
  export * from "./lrange.js";
@@ -2,6 +2,6 @@ import { Command, CommandOptions } from "./command.js";
2
2
  /**
3
3
  * @see https://redis.io/commands/rpop
4
4
  */
5
- export declare class RPopCommand<TData = string> extends Command<unknown | null, TData | null> {
6
- constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
5
+ export declare class RPopCommand<TData extends unknown | unknown[] = string> extends Command<unknown | null, TData | null> {
6
+ constructor(cmd: [key: string, count?: number], opts?: CommandOptions<unknown | null, TData | null>);
7
7
  }
@@ -1,9 +1,7 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- declare type TupleOfLength<T, L extends number, R extends T[] = []> = R["length"] extends L ? R : TupleOfLength<T, L, [...R, T]>;
3
2
  /**
4
3
  * @see https://redis.io/commands/script-exists
5
4
  */
6
- export declare class ScriptExistsCommand<T extends [string, ...string[]]> extends Command<T extends [string] ? string : TupleOfLength<string, T["length"]>, TupleOfLength<string, T["length"]>> {
7
- constructor(hashes: T, opts?: CommandOptions<T extends [string] ? string : TupleOfLength<string, T["length"]>, TupleOfLength<string, T["length"]>>);
5
+ export declare class ScriptExistsCommand<T extends string[]> extends Command<string[], number[]> {
6
+ constructor(hashes: T, opts?: CommandOptions<string[], number[]>);
8
7
  }
9
- export {};