@upstash/redis 0.0.0-ci.af91db56 → 0.0.0-ci.b1e842dc-20220903
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 +36 -274
- package/esm/deps/deno.land/x/base64@v0.2.1/base.js +100 -0
- package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +9 -0
- package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +1 -0
- package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +191 -0
- package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +50 -0
- package/esm/pkg/commands/lpos.js +19 -0
- package/esm/pkg/commands/mod.js +1 -0
- package/esm/pkg/commands/scan.js +3 -0
- package/esm/pkg/commands/sdiffstore.js +1 -1
- package/esm/pkg/commands/set.js +16 -4
- package/esm/pkg/commands/zmscore.js +10 -0
- package/esm/pkg/commands/zrange.js +6 -0
- package/esm/pkg/http.js +35 -7
- package/esm/pkg/pipeline.js +20 -1
- package/esm/pkg/redis.js +36 -1
- package/esm/pkg/script.js +77 -0
- package/esm/platforms/cloudflare.js +5 -25
- package/esm/platforms/fastly.js +4 -25
- package/esm/platforms/node_with_fetch.js +4 -25
- package/esm/platforms/nodejs.js +4 -25
- package/package.json +1 -39
- package/script/deps/deno.land/x/base64@v0.2.1/base.js +104 -0
- package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +13 -0
- package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +6 -0
- package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +196 -0
- package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +55 -0
- package/script/pkg/commands/lpos.js +23 -0
- package/script/pkg/commands/mod.js +1 -0
- package/script/pkg/commands/scan.js +3 -0
- package/script/pkg/commands/sdiffstore.js +1 -1
- package/script/pkg/commands/set.js +16 -4
- package/script/pkg/commands/zmscore.js +14 -0
- package/script/pkg/commands/zrange.js +6 -0
- package/script/pkg/http.js +35 -7
- package/script/pkg/pipeline.js +19 -0
- package/script/pkg/redis.js +35 -0
- package/script/pkg/script.js +81 -0
- package/script/platforms/cloudflare.js +5 -25
- package/script/platforms/fastly.js +4 -25
- package/script/platforms/node_with_fetch.js +4 -25
- package/script/platforms/nodejs.js +4 -25
- package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +5 -0
- package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +1 -0
- package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +1 -0
- package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +26 -0
- package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +3 -0
- package/types/pkg/commands/bitop.d.ts +0 -1
- package/types/pkg/commands/bitpos.d.ts +1 -1
- package/types/pkg/commands/lpop.d.ts +1 -1
- package/types/pkg/commands/lpos.d.ts +15 -0
- package/types/pkg/commands/mget.d.ts +1 -1
- package/types/pkg/commands/mod.d.ts +1 -0
- package/types/pkg/commands/rpop.d.ts +2 -2
- package/types/pkg/commands/scan.d.ts +1 -0
- package/types/pkg/commands/sdiffstore.d.ts +1 -1
- package/types/pkg/commands/set.d.ts +31 -2
- package/types/pkg/commands/spop.d.ts +2 -2
- package/types/pkg/commands/zadd.d.ts +1 -1
- package/types/pkg/commands/zmscore.d.ts +7 -0
- package/types/pkg/commands/zrange.d.ts +7 -0
- package/types/pkg/http.d.ts +27 -3
- package/types/pkg/pipeline.d.ts +18 -6
- package/types/pkg/redis.d.ts +26 -8
- package/types/pkg/script.d.ts +42 -0
- package/types/platforms/cloudflare.d.ts +6 -2
- package/types/platforms/fastly.d.ts +5 -1
- package/types/platforms/node_with_fetch.d.ts +20 -1
- package/types/platforms/nodejs.d.ts +20 -1
package/script/pkg/redis.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Redis = void 0;
|
|
4
4
|
const mod_js_1 = require("./commands/mod.js");
|
|
5
5
|
const pipeline_js_1 = require("./pipeline.js");
|
|
6
|
+
const script_js_1 = require("./script.js");
|
|
7
|
+
const zmscore_js_1 = require("./commands/zmscore.js");
|
|
6
8
|
/**
|
|
7
9
|
* Serverless redis client for upstash.
|
|
8
10
|
*/
|
|
@@ -31,6 +33,18 @@ class Redis {
|
|
|
31
33
|
writable: true,
|
|
32
34
|
value: void 0
|
|
33
35
|
});
|
|
36
|
+
/**
|
|
37
|
+
* Wrap a new middleware around the HTTP client.
|
|
38
|
+
*/
|
|
39
|
+
Object.defineProperty(this, "use", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: (middleware) => {
|
|
44
|
+
const makeRequest = this.client.request.bind(this.client);
|
|
45
|
+
this.client.request = (req) => middleware(req, makeRequest);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
34
48
|
/**
|
|
35
49
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
36
50
|
*
|
|
@@ -429,6 +443,15 @@ class Redis {
|
|
|
429
443
|
writable: true,
|
|
430
444
|
value: (...args) => new mod_js_1.LPopCommand(args, this.opts).exec(this.client)
|
|
431
445
|
});
|
|
446
|
+
/**
|
|
447
|
+
* @see https://redis.io/commands/lpos
|
|
448
|
+
*/
|
|
449
|
+
Object.defineProperty(this, "lpos", {
|
|
450
|
+
enumerable: true,
|
|
451
|
+
configurable: true,
|
|
452
|
+
writable: true,
|
|
453
|
+
value: (...args) => new mod_js_1.LPosCommand(args, this.opts).exec(this.client)
|
|
454
|
+
});
|
|
432
455
|
/**
|
|
433
456
|
* @see https://redis.io/commands/lpush
|
|
434
457
|
*/
|
|
@@ -956,6 +979,15 @@ class Redis {
|
|
|
956
979
|
writable: true,
|
|
957
980
|
value: (...args) => new mod_js_1.ZLexCountCommand(args, this.opts).exec(this.client)
|
|
958
981
|
});
|
|
982
|
+
/**
|
|
983
|
+
* @see https://redis.io/commands/zmscore
|
|
984
|
+
*/
|
|
985
|
+
Object.defineProperty(this, "zmscore", {
|
|
986
|
+
enumerable: true,
|
|
987
|
+
configurable: true,
|
|
988
|
+
writable: true,
|
|
989
|
+
value: (...args) => new zmscore_js_1.ZMScoreCommand(args, this.opts).exec(this.client)
|
|
990
|
+
});
|
|
959
991
|
/**
|
|
960
992
|
* @see https://redis.io/commands/zpopmax
|
|
961
993
|
*/
|
|
@@ -1067,5 +1099,8 @@ class Redis {
|
|
|
1067
1099
|
this.client = client;
|
|
1068
1100
|
this.opts = opts;
|
|
1069
1101
|
}
|
|
1102
|
+
createScript(script) {
|
|
1103
|
+
return new script_js_1.Script(this, script);
|
|
1104
|
+
}
|
|
1070
1105
|
}
|
|
1071
1106
|
exports.Redis = Redis;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Script = void 0;
|
|
4
|
+
const mod_js_1 = require("../deps/deno.land/x/sha1@v1.0.3/mod.js");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new script.
|
|
7
|
+
*
|
|
8
|
+
* Scripts offer the ability to optimistically try to execute a script without having to send the
|
|
9
|
+
* entire script to the server. If the script is loaded on the server, it tries again by sending
|
|
10
|
+
* the entire script. Afterwards, the script is cached on the server.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const redis = new Redis({...})
|
|
15
|
+
*
|
|
16
|
+
* const script = redis.createScript<string>("return ARGV[1];")
|
|
17
|
+
* const arg1 = await script.eval([], ["Hello World"])
|
|
18
|
+
* assertEquals(arg1, "Hello World")
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
class Script {
|
|
22
|
+
constructor(redis, script) {
|
|
23
|
+
Object.defineProperty(this, "script", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "sha1", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "redis", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: void 0
|
|
40
|
+
});
|
|
41
|
+
this.redis = redis;
|
|
42
|
+
this.sha1 = this.digest(script);
|
|
43
|
+
this.script = script;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Send an `EVAL` command to redis.
|
|
47
|
+
*/
|
|
48
|
+
async eval(keys, args) {
|
|
49
|
+
return await this.redis.eval(this.script, keys, args);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Calculates the sha1 hash of the script and then calls `EVALSHA`.
|
|
53
|
+
*/
|
|
54
|
+
async evalsha(keys, args) {
|
|
55
|
+
return await this.redis.evalsha(this.sha1, keys, args);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Optimistically try to run `EVALSHA` first.
|
|
59
|
+
* If the script is not loaded in redis, it will fall back and try again with `EVAL`.
|
|
60
|
+
*
|
|
61
|
+
* Following calls will be able to use the cached script
|
|
62
|
+
*/
|
|
63
|
+
async exec(keys, args) {
|
|
64
|
+
const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (err) => {
|
|
65
|
+
if (err instanceof Error &&
|
|
66
|
+
err.message.toLowerCase().includes("noscript")) {
|
|
67
|
+
return await this.redis.eval(this.script, keys, args);
|
|
68
|
+
}
|
|
69
|
+
throw err;
|
|
70
|
+
});
|
|
71
|
+
return res;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Compute the sha1 hash of the script and return its hex representation.
|
|
75
|
+
*/
|
|
76
|
+
digest(s) {
|
|
77
|
+
const hash = (0, mod_js_1.sha1)(s, "utf8", "hex");
|
|
78
|
+
return typeof hash === "string" ? hash : new TextDecoder().decode(hash);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.Script = Script;
|
|
@@ -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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const byteLength: (b64: string) => number, toUint8Array: (b64: string) => Uint8Array, fromUint8Array: (buf: Uint8Array) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { encode, decode } from "../../../denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Byte length of a SHA1 digest. */
|
|
2
|
+
export declare const BYTES: number;
|
|
3
|
+
/** A class representation of the SHA1 algorithm. */
|
|
4
|
+
export declare class SHA1 {
|
|
5
|
+
readonly hashSize: number;
|
|
6
|
+
private _buf;
|
|
7
|
+
private _bufIdx;
|
|
8
|
+
private _count;
|
|
9
|
+
private _K;
|
|
10
|
+
private _H;
|
|
11
|
+
private _finalized;
|
|
12
|
+
/** Creates a SHA1 instance. */
|
|
13
|
+
constructor();
|
|
14
|
+
/** Reduces the four input numbers to a single one. */
|
|
15
|
+
protected static F(t: number, b: number, c: number, d: number): number;
|
|
16
|
+
/** Initializes a hash instance. */
|
|
17
|
+
init(): SHA1;
|
|
18
|
+
/** Updates a hash with additional message data. */
|
|
19
|
+
update(msg: string | Uint8Array, inputEncoding?: string): SHA1;
|
|
20
|
+
/** Finalizes a hash with additional message data. */
|
|
21
|
+
digest(outputEncoding?: string): string | Uint8Array;
|
|
22
|
+
/** Performs one transformation cycle. */
|
|
23
|
+
private transform;
|
|
24
|
+
}
|
|
25
|
+
/** Generates a SHA1 hash of the input data. */
|
|
26
|
+
export declare function sha1(msg: string | Uint8Array, inputEncoding?: string, outputEncoding?: string): string | Uint8Array;
|
|
@@ -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,
|
|
6
|
+
constructor(cmd: [key: string, bit: 0 | 1, start?: number, end?: number], opts?: CommandOptions<number, number>);
|
|
7
7
|
}
|
|
@@ -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:
|
|
6
|
+
constructor(cmd: [...keys: string[]], opts?: CommandOptions<(string | null)[], TData>);
|
|
7
7
|
}
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { Command, CommandOptions } from "./command.js";
|
|
2
2
|
/**
|
|
3
|
-
* @see https://redis.io/commands/
|
|
3
|
+
* @see https://redis.io/commands/sdiffstore
|
|
4
4
|
*/
|
|
5
5
|
export declare class SDiffStoreCommand extends Command<number, number> {
|
|
6
6
|
constructor(cmd: [destination: string, ...keys: string[]], opts?: CommandOptions<number, number>);
|
|
@@ -1,13 +1,42 @@
|
|
|
1
1
|
import { Command, CommandOptions } from "./command.js";
|
|
2
|
-
export declare type SetCommandOptions =
|
|
2
|
+
export declare type SetCommandOptions = {
|
|
3
|
+
get: boolean;
|
|
4
|
+
} | ({
|
|
3
5
|
ex: number;
|
|
4
6
|
px?: never;
|
|
7
|
+
exat?: never;
|
|
8
|
+
pxat?: never;
|
|
9
|
+
keepTtl?: never;
|
|
5
10
|
} | {
|
|
6
11
|
ex?: never;
|
|
7
12
|
px: number;
|
|
13
|
+
exat?: never;
|
|
14
|
+
pxat?: never;
|
|
15
|
+
keepTtl?: never;
|
|
8
16
|
} | {
|
|
9
17
|
ex?: never;
|
|
10
18
|
px?: never;
|
|
19
|
+
exat: number;
|
|
20
|
+
pxat?: never;
|
|
21
|
+
keepTtl?: never;
|
|
22
|
+
} | {
|
|
23
|
+
ex?: never;
|
|
24
|
+
px?: never;
|
|
25
|
+
exat?: never;
|
|
26
|
+
pxat: number;
|
|
27
|
+
keepTtl?: never;
|
|
28
|
+
} | {
|
|
29
|
+
ex?: never;
|
|
30
|
+
px?: never;
|
|
31
|
+
exat?: never;
|
|
32
|
+
pxat?: never;
|
|
33
|
+
keepTtl: true;
|
|
34
|
+
} | {
|
|
35
|
+
ex?: never;
|
|
36
|
+
px?: never;
|
|
37
|
+
exat?: never;
|
|
38
|
+
pxat?: never;
|
|
39
|
+
keepTtl?: never;
|
|
11
40
|
}) & ({
|
|
12
41
|
nx: true;
|
|
13
42
|
xx?: never;
|
|
@@ -21,6 +50,6 @@ export declare type SetCommandOptions = ({
|
|
|
21
50
|
/**
|
|
22
51
|
* @see https://redis.io/commands/set
|
|
23
52
|
*/
|
|
24
|
-
export declare class SetCommand<TData, TResult = "OK"> extends Command<TResult, TData> {
|
|
53
|
+
export declare class SetCommand<TData, TResult = TData | "OK" | null> extends Command<TResult, TData | "OK" | null> {
|
|
25
54
|
constructor([key, value, opts]: [key: string, value: TData, opts?: SetCommandOptions], cmdOpts?: CommandOptions<TResult, TData>);
|
|
26
55
|
}
|
|
@@ -2,6 +2,6 @@ import { Command, CommandOptions } from "./command.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* @see https://redis.io/commands/spop
|
|
4
4
|
*/
|
|
5
|
-
export declare class SPopCommand<TData> extends Command<string | null, TData | null> {
|
|
6
|
-
constructor([key, count]: [key: string, count?: number], opts?: CommandOptions<string | null, TData | null>);
|
|
5
|
+
export declare class SPopCommand<TData> extends Command<string | string[] | null, TData | null> {
|
|
6
|
+
constructor([key, count]: [key: string, count?: number], opts?: CommandOptions<string | string[] | null, TData | null>);
|
|
7
7
|
}
|
|
@@ -30,6 +30,6 @@ export declare class ZAddCommand<TData = string> extends Command<number | null,
|
|
|
30
30
|
constructor(cmd: [
|
|
31
31
|
key: string,
|
|
32
32
|
opts: ZAddCommandOptions | ZAddCommandOptionsWithIncr,
|
|
33
|
-
...scoreMemberPairs:
|
|
33
|
+
...scoreMemberPairs: ScoreMember<TData>[]
|
|
34
34
|
], opts?: CommandOptions<number | null, number | null>);
|
|
35
35
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/zscore
|
|
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
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command, CommandOptions } from "./command.js";
|
|
2
2
|
export declare type ZRangeCommandOptions = {
|
|
3
3
|
withScores?: boolean;
|
|
4
|
+
rev?: boolean;
|
|
4
5
|
} & ({
|
|
5
6
|
byScore: true;
|
|
6
7
|
byLex?: never;
|
|
@@ -10,6 +11,12 @@ export declare type ZRangeCommandOptions = {
|
|
|
10
11
|
} | {
|
|
11
12
|
byScore?: never;
|
|
12
13
|
byLex?: never;
|
|
14
|
+
}) & ({
|
|
15
|
+
offset: number;
|
|
16
|
+
count: number;
|
|
17
|
+
} | {
|
|
18
|
+
offset?: never;
|
|
19
|
+
count?: never;
|
|
13
20
|
});
|
|
14
21
|
/**
|
|
15
22
|
* @see https://redis.io/commands/zrange
|
package/types/pkg/http.d.ts
CHANGED
|
@@ -12,12 +12,31 @@ export declare type UpstashResponse<TResult> = {
|
|
|
12
12
|
export interface Requester {
|
|
13
13
|
request: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>;
|
|
14
14
|
}
|
|
15
|
+
export declare type RetryConfig = false | {
|
|
16
|
+
/**
|
|
17
|
+
* The number of retries to attempt before giving up.
|
|
18
|
+
*
|
|
19
|
+
* @default 5
|
|
20
|
+
*/
|
|
21
|
+
retries?: number;
|
|
22
|
+
/**
|
|
23
|
+
* A backoff function receives the current retry cound and returns a number in milliseconds to wait before retrying.
|
|
24
|
+
*
|
|
25
|
+
* @default
|
|
26
|
+
* ```ts
|
|
27
|
+
* Math.exp(retryCount) * 50
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
backoff?: (retryCount: number) => number;
|
|
31
|
+
};
|
|
32
|
+
declare type Options = {
|
|
33
|
+
backend?: string;
|
|
34
|
+
};
|
|
15
35
|
export declare type HttpClientConfig = {
|
|
16
36
|
headers?: Record<string, string>;
|
|
17
37
|
baseUrl: string;
|
|
18
|
-
options?:
|
|
19
|
-
|
|
20
|
-
};
|
|
38
|
+
options?: Options;
|
|
39
|
+
retry?: RetryConfig;
|
|
21
40
|
};
|
|
22
41
|
export declare class HttpClient implements Requester {
|
|
23
42
|
baseUrl: string;
|
|
@@ -25,6 +44,11 @@ export declare class HttpClient implements Requester {
|
|
|
25
44
|
readonly options?: {
|
|
26
45
|
backend?: string;
|
|
27
46
|
};
|
|
47
|
+
readonly retry: {
|
|
48
|
+
attempts: number;
|
|
49
|
+
backoff: (retryCount: number) => number;
|
|
50
|
+
};
|
|
28
51
|
constructor(config: HttpClientConfig);
|
|
29
52
|
request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
|
|
30
53
|
}
|
|
54
|
+
export {};
|