@upstash/redis 0.0.0-ci.b4d4a1cc → 0.0.0-ci.b8efaf97-20230119
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 +43 -279
- 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/getdel.js +9 -0
- package/esm/pkg/commands/hgetall.js +0 -4
- package/esm/pkg/commands/hrandfield.js +39 -0
- package/esm/pkg/commands/lmove.js +9 -0
- package/esm/pkg/commands/lpos.js +19 -0
- package/esm/pkg/commands/mod.js +5 -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/smismember.js +9 -0
- package/esm/pkg/commands/zdiffstore.js +9 -0
- package/esm/pkg/commands/zmscore.js +10 -0
- package/esm/pkg/commands/zrange.js +6 -0
- package/esm/pkg/http.js +133 -8
- package/esm/pkg/pipeline.js +80 -6
- package/esm/pkg/redis.js +125 -2
- package/esm/pkg/script.js +77 -0
- package/esm/platforms/cloudflare.js +14 -26
- package/esm/platforms/fastly.js +5 -25
- package/esm/platforms/node_with_fetch.js +31 -26
- package/esm/platforms/nodejs.js +26 -26
- package/esm/version.js +1 -0
- 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/getdel.js +13 -0
- package/script/pkg/commands/hgetall.js +0 -4
- package/script/pkg/commands/hrandfield.js +43 -0
- package/script/pkg/commands/lmove.js +13 -0
- package/script/pkg/commands/lpos.js +23 -0
- package/script/pkg/commands/mod.js +5 -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/smismember.js +13 -0
- package/script/pkg/commands/zdiffstore.js +13 -0
- package/script/pkg/commands/zmscore.js +14 -0
- package/script/pkg/commands/zrange.js +6 -0
- package/script/pkg/http.js +133 -8
- package/script/pkg/pipeline.js +79 -5
- package/script/pkg/redis.js +124 -1
- package/script/pkg/script.js +81 -0
- package/script/platforms/cloudflare.js +14 -26
- package/script/platforms/fastly.js +5 -25
- package/script/platforms/node_with_fetch.js +31 -26
- package/script/platforms/nodejs.js +26 -26
- package/script/version.js +4 -0
- 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/getdel.d.ts +7 -0
- package/types/pkg/commands/hrandfield.d.ts +9 -0
- package/types/pkg/commands/lmove.d.ts +12 -0
- 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 +5 -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/smembers.d.ts +2 -2
- package/types/pkg/commands/smismember.d.ts +7 -0
- package/types/pkg/commands/spop.d.ts +2 -2
- package/types/pkg/commands/zadd.d.ts +1 -1
- package/types/pkg/commands/zdiffstore.d.ts +7 -0
- package/types/pkg/commands/zmscore.d.ts +7 -0
- package/types/pkg/commands/zrange.d.ts +7 -0
- package/types/pkg/http.d.ts +63 -5
- package/types/pkg/pipeline.d.ts +46 -9
- package/types/pkg/redis.d.ts +65 -9
- package/types/pkg/script.d.ts +42 -0
- package/types/pkg/types.d.ts +17 -0
- package/types/platforms/cloudflare.d.ts +8 -3
- package/types/platforms/fastly.d.ts +2 -2
- package/types/platforms/node_with_fetch.d.ts +2 -2
- package/types/platforms/nodejs.d.ts +18 -2
- package/types/version.d.ts +1 -0
|
@@ -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,12 @@ 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 },
|
|
61
|
+
responseEncoding: config.responseEncoding,
|
|
60
62
|
});
|
|
61
63
|
super(client, {
|
|
62
64
|
automaticDeserialization: config.automaticDeserialization,
|
|
@@ -64,25 +66,3 @@ class Redis extends core.Redis {
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
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,8 +26,22 @@ 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
|
+
const version_js_1 = require("../version.js");
|
|
30
31
|
require("isomorphic-fetch");
|
|
32
|
+
// @ts-ignore Deno can't compile
|
|
33
|
+
// import https from "https";
|
|
34
|
+
// @ts-ignore Deno can't compile
|
|
35
|
+
// import http from "http";
|
|
36
|
+
// import "isomorphic-fetch";
|
|
37
|
+
/**
|
|
38
|
+
* Workaround for nodejs 14, where atob is not included in the standardlib
|
|
39
|
+
*/
|
|
40
|
+
if (typeof atob === "undefined") {
|
|
41
|
+
global.atob = function (b64) {
|
|
42
|
+
return Buffer.from(b64, "base64").toString("utf-8");
|
|
43
|
+
};
|
|
44
|
+
}
|
|
31
45
|
/**
|
|
32
46
|
* Serverless redis client for upstash.
|
|
33
47
|
*/
|
|
@@ -47,10 +61,23 @@ class Redis extends core.Redis {
|
|
|
47
61
|
/\r|\n/.test(configOrRequester.token)) {
|
|
48
62
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
49
63
|
}
|
|
50
|
-
const
|
|
64
|
+
const telemetry = {};
|
|
65
|
+
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
66
|
+
telemetry.runtime = `node@${process.version}`;
|
|
67
|
+
telemetry.platform = process.env.VERCEL
|
|
68
|
+
? "vercel"
|
|
69
|
+
: process.env.AWS_REGION
|
|
70
|
+
? "aws"
|
|
71
|
+
: "unknown";
|
|
72
|
+
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
73
|
+
}
|
|
74
|
+
const client = new http_js_1.HttpClient({
|
|
51
75
|
baseUrl: configOrRequester.url,
|
|
76
|
+
retry: configOrRequester.retry,
|
|
52
77
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
53
|
-
//
|
|
78
|
+
// agent: configOrRequester.agent,
|
|
79
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
80
|
+
telemetry,
|
|
54
81
|
});
|
|
55
82
|
super(client, {
|
|
56
83
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
@@ -80,29 +107,7 @@ class Redis extends core.Redis {
|
|
|
80
107
|
if (!token) {
|
|
81
108
|
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
|
|
82
109
|
}
|
|
83
|
-
return new Redis({ url, token
|
|
110
|
+
return new Redis({ ...config, url, token });
|
|
84
111
|
}
|
|
85
112
|
}
|
|
86
113
|
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,16 @@ 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
|
+
const version_js_1 = require("../version.js");
|
|
31
|
+
/**
|
|
32
|
+
* Workaround for nodejs 14, where atob is not included in the standardlib
|
|
33
|
+
*/
|
|
34
|
+
if (typeof atob === "undefined") {
|
|
35
|
+
global.atob = function (b64) {
|
|
36
|
+
return Buffer.from(b64, "base64").toString("utf-8");
|
|
37
|
+
};
|
|
38
|
+
}
|
|
30
39
|
/**
|
|
31
40
|
* Serverless redis client for upstash.
|
|
32
41
|
*/
|
|
@@ -46,10 +55,23 @@ class Redis extends core.Redis {
|
|
|
46
55
|
/\r|\n/.test(configOrRequester.token)) {
|
|
47
56
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
48
57
|
}
|
|
49
|
-
const
|
|
58
|
+
const telemetry = {};
|
|
59
|
+
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
60
|
+
telemetry.runtime = `node@${process.version}`;
|
|
61
|
+
telemetry.platform = process.env.VERCEL
|
|
62
|
+
? "vercel"
|
|
63
|
+
: process.env.AWS_REGION
|
|
64
|
+
? "aws"
|
|
65
|
+
: "unknown";
|
|
66
|
+
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
67
|
+
}
|
|
68
|
+
const client = new http_js_1.HttpClient({
|
|
50
69
|
baseUrl: configOrRequester.url,
|
|
70
|
+
retry: configOrRequester.retry,
|
|
51
71
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
52
|
-
|
|
72
|
+
agent: configOrRequester.agent,
|
|
73
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
74
|
+
telemetry,
|
|
53
75
|
});
|
|
54
76
|
super(client, {
|
|
55
77
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
@@ -79,29 +101,7 @@ class Redis extends core.Redis {
|
|
|
79
101
|
if (!token) {
|
|
80
102
|
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
|
|
81
103
|
}
|
|
82
|
-
return new Redis({ url, token
|
|
104
|
+
return new Redis({ ...config, url, token });
|
|
83
105
|
}
|
|
84
106
|
}
|
|
85
107
|
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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/hrandfield
|
|
4
|
+
*/
|
|
5
|
+
export declare class HRandFieldCommand<TData extends string | string[] | Record<string, unknown>> extends Command<string | string[], TData> {
|
|
6
|
+
constructor(cmd: [key: string], opts?: CommandOptions<string, string>);
|
|
7
|
+
constructor(cmd: [key: string, count: number], opts?: CommandOptions<string[], string[]>);
|
|
8
|
+
constructor(cmd: [key: string, count: number, withValues: boolean], opts?: CommandOptions<string[], Partial<TData>>);
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/lmove
|
|
4
|
+
*/
|
|
5
|
+
export declare class LMoveCommand<TData = string> extends Command<TData, TData> {
|
|
6
|
+
constructor(cmd: [
|
|
7
|
+
source: string,
|
|
8
|
+
destination: string,
|
|
9
|
+
whereFrom: "left" | "right",
|
|
10
|
+
whereTo: "left" | "right"
|
|
11
|
+
], opts?: CommandOptions<TData, TData>);
|
|
12
|
+
}
|
|
@@ -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
|
}
|
|
@@ -17,11 +17,13 @@ export * from "./flushall.js";
|
|
|
17
17
|
export * from "./flushdb.js";
|
|
18
18
|
export * from "./get.js";
|
|
19
19
|
export * from "./getbit.js";
|
|
20
|
+
export * from "./getdel.js";
|
|
20
21
|
export * from "./getrange.js";
|
|
21
22
|
export * from "./getset.js";
|
|
22
23
|
export * from "./hdel.js";
|
|
23
24
|
export * from "./hexists.js";
|
|
24
25
|
export * from "./hget.js";
|
|
26
|
+
export * from "./smismember.js";
|
|
25
27
|
export * from "./hgetall.js";
|
|
26
28
|
export * from "./hincrby.js";
|
|
27
29
|
export * from "./hincrbyfloat.js";
|
|
@@ -29,6 +31,7 @@ export * from "./hkeys.js";
|
|
|
29
31
|
export * from "./hlen.js";
|
|
30
32
|
export * from "./hmget.js";
|
|
31
33
|
export * from "./hmset.js";
|
|
34
|
+
export * from "./hrandfield.js";
|
|
32
35
|
export * from "./hscan.js";
|
|
33
36
|
export * from "./hset.js";
|
|
34
37
|
export * from "./hsetnx.js";
|
|
@@ -41,7 +44,9 @@ export * from "./keys.js";
|
|
|
41
44
|
export * from "./lindex.js";
|
|
42
45
|
export * from "./linsert.js";
|
|
43
46
|
export * from "./llen.js";
|
|
47
|
+
export * from "./lmove.js";
|
|
44
48
|
export * from "./lpop.js";
|
|
49
|
+
export * from "./lpos.js";
|
|
45
50
|
export * from "./lpush.js";
|
|
46
51
|
export * from "./lpushx.js";
|
|
47
52
|
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,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/smembers
|
|
4
4
|
*/
|
|
5
|
-
export declare class SMembersCommand<TData = string> extends Command<unknown[], TData
|
|
6
|
-
constructor(cmd: [key: string], opts?: CommandOptions<unknown[], TData
|
|
5
|
+
export declare class SMembersCommand<TData extends unknown[] = string[]> extends Command<unknown[], TData> {
|
|
6
|
+
constructor(cmd: [key: string], opts?: CommandOptions<unknown[], TData>);
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/smismember
|
|
4
|
+
*/
|
|
5
|
+
export declare class SMIsMemberCommand<TMembers extends unknown[]> extends Command<("0" | "1")[], (0 | 1)[]> {
|
|
6
|
+
constructor(cmd: [key: string, members: TMembers], opts?: CommandOptions<("0" | "1")[], (0 | 1)[]>);
|
|
7
|
+
}
|
|
@@ -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/zdiffstore
|
|
4
|
+
*/
|
|
5
|
+
export declare class ZDiffStoreCommand extends Command<number, number> {
|
|
6
|
+
constructor(cmd: [destination: string, numkeys: number, ...keys: string[]], opts?: CommandOptions<number, number>);
|
|
7
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Telemetry } from "./types.js";
|
|
1
2
|
export declare type UpstashRequest = {
|
|
2
3
|
path?: string[];
|
|
3
4
|
/**
|
|
@@ -12,19 +13,76 @@ export declare type UpstashResponse<TResult> = {
|
|
|
12
13
|
export interface Requester {
|
|
13
14
|
request: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>;
|
|
14
15
|
}
|
|
16
|
+
export declare type RetryConfig = false | {
|
|
17
|
+
/**
|
|
18
|
+
* The number of retries to attempt before giving up.
|
|
19
|
+
*
|
|
20
|
+
* @default 5
|
|
21
|
+
*/
|
|
22
|
+
retries?: number;
|
|
23
|
+
/**
|
|
24
|
+
* A backoff function receives the current retry cound and returns a number in milliseconds to wait before retrying.
|
|
25
|
+
*
|
|
26
|
+
* @default
|
|
27
|
+
* ```ts
|
|
28
|
+
* Math.exp(retryCount) * 50
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
backoff?: (retryCount: number) => number;
|
|
32
|
+
};
|
|
33
|
+
export declare type Options = {
|
|
34
|
+
backend?: string;
|
|
35
|
+
};
|
|
36
|
+
export declare type RequesterConfig = {
|
|
37
|
+
/**
|
|
38
|
+
* Configure the retry behaviour in case of network errors
|
|
39
|
+
*/
|
|
40
|
+
retry?: RetryConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Due to the nature of dynamic and custom data, it is possible to write data to redis that is not
|
|
43
|
+
* valid json and will therefore cause errors when deserializing. This used to happen very
|
|
44
|
+
* frequently with non-utf8 data, such as emojis.
|
|
45
|
+
*
|
|
46
|
+
* By default we will therefore encode the data as base64 on the server, before sending it to the
|
|
47
|
+
* client. The client will then decode the base64 data and parse it as utf8.
|
|
48
|
+
*
|
|
49
|
+
* For very large entries, this can add a few milliseconds, so if you are sure that your data is
|
|
50
|
+
* valid utf8, you can disable this behaviour by setting this option to false.
|
|
51
|
+
*
|
|
52
|
+
* Here's what the response body looks like:
|
|
53
|
+
*
|
|
54
|
+
* ```json
|
|
55
|
+
* {
|
|
56
|
+
* result?: "base64-encoded",
|
|
57
|
+
* error?: string
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @default "base64"
|
|
62
|
+
*/
|
|
63
|
+
responseEncoding?: false | "base64";
|
|
64
|
+
};
|
|
15
65
|
export declare type HttpClientConfig = {
|
|
16
66
|
headers?: Record<string, string>;
|
|
17
67
|
baseUrl: string;
|
|
18
|
-
options?:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
68
|
+
options?: Options;
|
|
69
|
+
retry?: RetryConfig;
|
|
70
|
+
agent?: any;
|
|
71
|
+
telemetry?: Telemetry;
|
|
72
|
+
} & RequesterConfig;
|
|
22
73
|
export declare class HttpClient implements Requester {
|
|
23
74
|
baseUrl: string;
|
|
24
75
|
headers: Record<string, string>;
|
|
25
|
-
readonly options
|
|
76
|
+
readonly options: {
|
|
26
77
|
backend?: string;
|
|
78
|
+
agent: any;
|
|
79
|
+
responseEncoding?: false | "base64";
|
|
80
|
+
};
|
|
81
|
+
readonly retry: {
|
|
82
|
+
attempts: number;
|
|
83
|
+
backoff: (retryCount: number) => number;
|
|
27
84
|
};
|
|
28
85
|
constructor(config: HttpClientConfig);
|
|
86
|
+
mergeTelemetry(telemetry: Telemetry): void;
|
|
29
87
|
request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
|
|
30
88
|
}
|