@upstash/redis 0.0.0-ci.b1e842dc-20220903 → 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 +19 -17
- 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/mod.js +4 -0
- package/esm/pkg/commands/smismember.js +9 -0
- package/esm/pkg/commands/zdiffstore.js +9 -0
- package/esm/pkg/commands/zmscore.js +1 -1
- package/esm/pkg/http.js +99 -2
- package/esm/pkg/pipeline.js +61 -6
- package/esm/pkg/redis.js +90 -2
- package/esm/platforms/cloudflare.js +10 -2
- package/esm/platforms/fastly.js +1 -0
- package/esm/platforms/node_with_fetch.js +27 -1
- package/esm/platforms/nodejs.js +22 -1
- package/esm/version.js +1 -0
- package/package.json +1 -1
- 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/mod.js +4 -0
- package/script/pkg/commands/smismember.js +13 -0
- package/script/pkg/commands/zdiffstore.js +13 -0
- package/script/pkg/commands/zmscore.js +1 -1
- package/script/pkg/http.js +99 -2
- package/script/pkg/pipeline.js +60 -5
- package/script/pkg/redis.js +89 -1
- package/script/platforms/cloudflare.js +10 -2
- package/script/platforms/fastly.js +1 -0
- package/script/platforms/node_with_fetch.js +27 -1
- package/script/platforms/nodejs.js +22 -1
- package/script/version.js +4 -0
- 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/mod.d.ts +4 -0
- package/types/pkg/commands/smembers.d.ts +2 -2
- package/types/pkg/commands/smismember.d.ts +7 -0
- package/types/pkg/commands/zdiffstore.d.ts +7 -0
- package/types/pkg/commands/zmscore.d.ts +1 -1
- package/types/pkg/http.d.ts +38 -4
- package/types/pkg/pipeline.d.ts +28 -3
- package/types/pkg/redis.d.ts +39 -1
- package/types/pkg/types.d.ts +17 -0
- package/types/platforms/cloudflare.d.ts +8 -7
- package/types/platforms/fastly.d.ts +2 -6
- package/types/platforms/node_with_fetch.d.ts +2 -21
- package/types/platforms/nodejs.d.ts +3 -6
- package/types/version.d.ts +1 -0
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.Redis = void 0;
|
|
27
27
|
const core = __importStar(require("../pkg/redis.js"));
|
|
28
28
|
const http_js_1 = require("../pkg/http.js");
|
|
29
|
+
const version_js_1 = require("../version.js");
|
|
29
30
|
/**
|
|
30
31
|
* Serverless redis client for upstash.
|
|
31
32
|
*/
|
|
@@ -41,7 +42,7 @@ class Redis extends core.Redis {
|
|
|
41
42
|
* });
|
|
42
43
|
* ```
|
|
43
44
|
*/
|
|
44
|
-
constructor(config) {
|
|
45
|
+
constructor(config, env) {
|
|
45
46
|
if (config.url.startsWith(" ") ||
|
|
46
47
|
config.url.endsWith(" ") ||
|
|
47
48
|
/\r|\n/.test(config.url)) {
|
|
@@ -52,10 +53,17 @@ class Redis extends core.Redis {
|
|
|
52
53
|
/\r|\n/.test(config.token)) {
|
|
53
54
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
54
55
|
}
|
|
56
|
+
const telemetry = {};
|
|
57
|
+
if (!env?.UPSTASH_DISABLE_TELEMETRY) {
|
|
58
|
+
telemetry.platform = "cloudflare";
|
|
59
|
+
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
60
|
+
}
|
|
55
61
|
const client = new http_js_1.HttpClient({
|
|
56
62
|
retry: config.retry,
|
|
57
63
|
baseUrl: config.url,
|
|
58
64
|
headers: { authorization: `Bearer ${config.token}` },
|
|
65
|
+
responseEncoding: config.responseEncoding,
|
|
66
|
+
telemetry,
|
|
59
67
|
});
|
|
60
68
|
super(client, {
|
|
61
69
|
automaticDeserialization: config.automaticDeserialization,
|
|
@@ -83,7 +91,7 @@ class Redis extends core.Redis {
|
|
|
83
91
|
if (!token) {
|
|
84
92
|
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`");
|
|
85
93
|
}
|
|
86
|
-
return new Redis({ ...opts, url, token });
|
|
94
|
+
return new Redis({ ...opts, url, token }, env);
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
97
|
exports.Redis = Redis;
|
|
@@ -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,
|
|
@@ -27,7 +27,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
exports.Redis = void 0;
|
|
28
28
|
const core = __importStar(require("../pkg/redis.js"));
|
|
29
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,11 +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
|
}
|
|
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
|
+
}
|
|
50
74
|
const client = new http_js_1.HttpClient({
|
|
51
75
|
baseUrl: configOrRequester.url,
|
|
52
76
|
retry: configOrRequester.retry,
|
|
53
77
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
54
|
-
//
|
|
78
|
+
// agent: configOrRequester.agent,
|
|
79
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
80
|
+
telemetry,
|
|
55
81
|
});
|
|
56
82
|
super(client, {
|
|
57
83
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
@@ -27,6 +27,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
exports.Redis = void 0;
|
|
28
28
|
const core = __importStar(require("../pkg/redis.js"));
|
|
29
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,11 +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
|
}
|
|
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
|
+
}
|
|
49
68
|
const client = new http_js_1.HttpClient({
|
|
50
69
|
baseUrl: configOrRequester.url,
|
|
51
70
|
retry: configOrRequester.retry,
|
|
52
71
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
53
|
-
|
|
72
|
+
agent: configOrRequester.agent,
|
|
73
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
74
|
+
telemetry,
|
|
54
75
|
});
|
|
55
76
|
super(client, {
|
|
56
77
|
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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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,6 +44,7 @@ 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";
|
|
45
49
|
export * from "./lpos.js";
|
|
46
50
|
export * from "./lpush.js";
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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/zmscore
|
|
4
4
|
*/
|
|
5
5
|
export declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] | null> {
|
|
6
6
|
constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
|
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
|
/**
|
|
@@ -29,26 +30,59 @@ export declare type RetryConfig = false | {
|
|
|
29
30
|
*/
|
|
30
31
|
backoff?: (retryCount: number) => number;
|
|
31
32
|
};
|
|
32
|
-
declare type Options = {
|
|
33
|
+
export declare type Options = {
|
|
33
34
|
backend?: string;
|
|
34
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
|
+
};
|
|
35
65
|
export declare type HttpClientConfig = {
|
|
36
66
|
headers?: Record<string, string>;
|
|
37
67
|
baseUrl: string;
|
|
38
68
|
options?: Options;
|
|
39
69
|
retry?: RetryConfig;
|
|
40
|
-
|
|
70
|
+
agent?: any;
|
|
71
|
+
telemetry?: Telemetry;
|
|
72
|
+
} & RequesterConfig;
|
|
41
73
|
export declare class HttpClient implements Requester {
|
|
42
74
|
baseUrl: string;
|
|
43
75
|
headers: Record<string, string>;
|
|
44
|
-
readonly options
|
|
76
|
+
readonly options: {
|
|
45
77
|
backend?: string;
|
|
78
|
+
agent: any;
|
|
79
|
+
responseEncoding?: false | "base64";
|
|
46
80
|
};
|
|
47
81
|
readonly retry: {
|
|
48
82
|
attempts: number;
|
|
49
83
|
backoff: (retryCount: number) => number;
|
|
50
84
|
};
|
|
51
85
|
constructor(config: HttpClientConfig);
|
|
86
|
+
mergeTelemetry(telemetry: Telemetry): void;
|
|
52
87
|
request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
|
|
53
88
|
}
|
|
54
|
-
export {};
|
package/types/pkg/pipeline.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { CommandArgs } from "./types.js";
|
|
|
18
18
|
* **Examples:**
|
|
19
19
|
*
|
|
20
20
|
* ```ts
|
|
21
|
-
* const p = redis.pipeline()
|
|
21
|
+
* const p = redis.pipeline() // or redis.multi()
|
|
22
22
|
* p.set("key","value")
|
|
23
23
|
* p.get("key")
|
|
24
24
|
* const res = await p.exec()
|
|
@@ -44,7 +44,12 @@ export declare class Pipeline {
|
|
|
44
44
|
private client;
|
|
45
45
|
private commands;
|
|
46
46
|
private commandOptions?;
|
|
47
|
-
|
|
47
|
+
private multiExec;
|
|
48
|
+
constructor(opts: {
|
|
49
|
+
client: Requester;
|
|
50
|
+
commandOptions?: CommandOptions<any, any>;
|
|
51
|
+
multiExec?: boolean;
|
|
52
|
+
});
|
|
48
53
|
/**
|
|
49
54
|
* Send the pipeline request to upstash.
|
|
50
55
|
*
|
|
@@ -80,6 +85,10 @@ export declare class Pipeline {
|
|
|
80
85
|
* @see https://redis.io/commands/bitpos
|
|
81
86
|
*/
|
|
82
87
|
bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => this;
|
|
88
|
+
/**
|
|
89
|
+
* @see https://redis.io/commands/zdiffstore
|
|
90
|
+
*/
|
|
91
|
+
zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => this;
|
|
83
92
|
/**
|
|
84
93
|
* @see https://redis.io/commands/dbsize
|
|
85
94
|
*/
|
|
@@ -138,6 +147,10 @@ export declare class Pipeline {
|
|
|
138
147
|
* @see https://redis.io/commands/getbit
|
|
139
148
|
*/
|
|
140
149
|
getbit: (key: string, offset: number) => this;
|
|
150
|
+
/**
|
|
151
|
+
* @see https://redis.io/commands/getdel
|
|
152
|
+
*/
|
|
153
|
+
getdel: <TData>(key: string) => this;
|
|
141
154
|
/**
|
|
142
155
|
* @see https://redis.io/commands/getrange
|
|
143
156
|
*/
|
|
@@ -188,6 +201,10 @@ export declare class Pipeline {
|
|
|
188
201
|
hmset: <TData>(key: string, kv: {
|
|
189
202
|
[field: string]: TData;
|
|
190
203
|
}) => this;
|
|
204
|
+
/**
|
|
205
|
+
* @see https://redis.io/commands/hrandfield
|
|
206
|
+
*/
|
|
207
|
+
hrandfield: <TData extends string | string[] | Record<string, unknown>>(key: string, count?: number, withValues?: boolean) => this;
|
|
191
208
|
/**
|
|
192
209
|
* @see https://redis.io/commands/hscan
|
|
193
210
|
*/
|
|
@@ -238,6 +255,10 @@ export declare class Pipeline {
|
|
|
238
255
|
* @see https://redis.io/commands/llen
|
|
239
256
|
*/
|
|
240
257
|
llen: (key: string) => this;
|
|
258
|
+
/**
|
|
259
|
+
* @see https://redis.io/commands/lmove
|
|
260
|
+
*/
|
|
261
|
+
lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => this;
|
|
241
262
|
/**
|
|
242
263
|
* @see https://redis.io/commands/lpop
|
|
243
264
|
*/
|
|
@@ -406,7 +427,11 @@ export declare class Pipeline {
|
|
|
406
427
|
/**
|
|
407
428
|
* @see https://redis.io/commands/smembers
|
|
408
429
|
*/
|
|
409
|
-
smembers: (key: string) => this;
|
|
430
|
+
smembers: <TData extends unknown[] = string[]>(key: string) => this;
|
|
431
|
+
/**
|
|
432
|
+
* @see https://redis.io/commands/smismember
|
|
433
|
+
*/
|
|
434
|
+
smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => this;
|
|
410
435
|
/**
|
|
411
436
|
* @see https://redis.io/commands/smove
|
|
412
437
|
*/
|
package/types/pkg/redis.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ export declare class Redis {
|
|
|
33
33
|
* Wrap a new middleware around the HTTP client.
|
|
34
34
|
*/
|
|
35
35
|
use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult_1 = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult_1>>) => Promise<UpstashResponse<TResult>>) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Technically this is not private, we can hide it from intellisense by doing this
|
|
38
|
+
*/
|
|
39
|
+
private addTelemetry;
|
|
36
40
|
createScript(script: string): Script;
|
|
37
41
|
/**
|
|
38
42
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
@@ -40,6 +44,16 @@ export declare class Redis {
|
|
|
40
44
|
* @see {@link Pipeline}
|
|
41
45
|
*/
|
|
42
46
|
pipeline: () => Pipeline;
|
|
47
|
+
/**
|
|
48
|
+
* Create a new transaction to allow executing multiple steps atomically.
|
|
49
|
+
*
|
|
50
|
+
* All the commands in a transaction are serialized and executed sequentially. A request sent by
|
|
51
|
+
* another client will never be served in the middle of the execution of a Redis Transaction. This
|
|
52
|
+
* guarantees that the commands are executed as a single isolated operation.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link Pipeline}
|
|
55
|
+
*/
|
|
56
|
+
multi: () => Pipeline;
|
|
43
57
|
/**
|
|
44
58
|
* @see https://redis.io/commands/append
|
|
45
59
|
*/
|
|
@@ -117,6 +131,10 @@ export declare class Redis {
|
|
|
117
131
|
* @see https://redis.io/commands/getbit
|
|
118
132
|
*/
|
|
119
133
|
getbit: (key: string, offset: number) => Promise<0 | 1>;
|
|
134
|
+
/**
|
|
135
|
+
* @see https://redis.io/commands/getdel
|
|
136
|
+
*/
|
|
137
|
+
getdel: <TData>(key: string) => Promise<TData | null>;
|
|
120
138
|
/**
|
|
121
139
|
* @see https://redis.io/commands/getrange
|
|
122
140
|
*/
|
|
@@ -167,6 +185,14 @@ export declare class Redis {
|
|
|
167
185
|
hmset: <TData>(key: string, kv: {
|
|
168
186
|
[field: string]: TData;
|
|
169
187
|
}) => Promise<"OK">;
|
|
188
|
+
/**
|
|
189
|
+
* @see https://redis.io/commands/hrandfield
|
|
190
|
+
*/
|
|
191
|
+
hrandfield: {
|
|
192
|
+
(key: string): Promise<string>;
|
|
193
|
+
(key: string, count: number): Promise<string[]>;
|
|
194
|
+
<TData extends Record<string, unknown>>(key: string, count: number, withValues: boolean): Promise<Partial<TData>>;
|
|
195
|
+
};
|
|
170
196
|
/**
|
|
171
197
|
* @see https://redis.io/commands/hscan
|
|
172
198
|
*/
|
|
@@ -217,6 +243,10 @@ export declare class Redis {
|
|
|
217
243
|
* @see https://redis.io/commands/llen
|
|
218
244
|
*/
|
|
219
245
|
llen: (key: string) => Promise<number>;
|
|
246
|
+
/**
|
|
247
|
+
* @see https://redis.io/commands/lmove
|
|
248
|
+
*/
|
|
249
|
+
lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => Promise<TData>;
|
|
220
250
|
/**
|
|
221
251
|
* @see https://redis.io/commands/lpop
|
|
222
252
|
*/
|
|
@@ -385,10 +415,14 @@ export declare class Redis {
|
|
|
385
415
|
* @see https://redis.io/commands/sismember
|
|
386
416
|
*/
|
|
387
417
|
sismember: <TData>(key: string, member: TData) => Promise<0 | 1>;
|
|
418
|
+
/**
|
|
419
|
+
* @see https://redis.io/commands/smismember
|
|
420
|
+
*/
|
|
421
|
+
smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => Promise<(0 | 1)[]>;
|
|
388
422
|
/**
|
|
389
423
|
* @see https://redis.io/commands/smembers
|
|
390
424
|
*/
|
|
391
|
-
smembers: (key: string) => Promise<
|
|
425
|
+
smembers: <TData extends unknown[] = string[]>(key: string) => Promise<TData>;
|
|
392
426
|
/**
|
|
393
427
|
* @see https://redis.io/commands/smove
|
|
394
428
|
*/
|
|
@@ -453,6 +487,10 @@ export declare class Redis {
|
|
|
453
487
|
* @see https://redis.io/commands/zcount
|
|
454
488
|
*/
|
|
455
489
|
zcount: (key: string, min: string | number, max: string | number) => Promise<number>;
|
|
490
|
+
/**
|
|
491
|
+
* @see https://redis.io/commands/zdiffstore
|
|
492
|
+
*/
|
|
493
|
+
zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => Promise<number>;
|
|
456
494
|
/**
|
|
457
495
|
* @see https://redis.io/commands/zincrby
|
|
458
496
|
*/
|
package/types/pkg/types.d.ts
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
1
|
export declare type CommandArgs<TCommand extends new (...args: any) => any> = ConstructorParameters<TCommand>[0];
|
|
2
|
+
export declare type Telemetry = {
|
|
3
|
+
/**
|
|
4
|
+
* Upstash-Telemetry-Sdk
|
|
5
|
+
* @example @upstash/redis@v1.1.1
|
|
6
|
+
*/
|
|
7
|
+
sdk?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Upstash-Telemetry-Platform
|
|
10
|
+
* @example cloudflare
|
|
11
|
+
*/
|
|
12
|
+
platform?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Upstash-Telemetry-Runtime
|
|
15
|
+
* @example node@v18
|
|
16
|
+
*/
|
|
17
|
+
runtime?: string;
|
|
18
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as core from "../pkg/redis.js";
|
|
2
|
-
import type { Requester,
|
|
2
|
+
import type { Requester, UpstashRequest, UpstashResponse } from "../pkg/http.js";
|
|
3
|
+
import { RequesterConfig } from "../pkg/http.js";
|
|
4
|
+
declare type Env = {
|
|
5
|
+
UPSTASH_DISABLE_TELEMETRY?: string;
|
|
6
|
+
};
|
|
3
7
|
export type { Requester, UpstashRequest, UpstashResponse };
|
|
4
8
|
/**
|
|
5
9
|
* Connection credentials for upstash redis.
|
|
@@ -14,11 +18,7 @@ export declare type RedisConfigCloudflare = {
|
|
|
14
18
|
* UPSTASH_REDIS_REST_TOKEN
|
|
15
19
|
*/
|
|
16
20
|
token: string;
|
|
17
|
-
|
|
18
|
-
* Configure the retry behaviour in case of network errors
|
|
19
|
-
*/
|
|
20
|
-
retry?: RetryConfig;
|
|
21
|
-
} & core.RedisOptions;
|
|
21
|
+
} & core.RedisOptions & RequesterConfig & Env;
|
|
22
22
|
/**
|
|
23
23
|
* Serverless redis client for upstash.
|
|
24
24
|
*/
|
|
@@ -34,9 +34,10 @@ export declare class Redis extends core.Redis {
|
|
|
34
34
|
* });
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
constructor(config: RedisConfigCloudflare);
|
|
37
|
+
constructor(config: RedisConfigCloudflare, env?: Env);
|
|
38
38
|
static fromEnv(env?: {
|
|
39
39
|
UPSTASH_REDIS_REST_URL: string;
|
|
40
40
|
UPSTASH_REDIS_REST_TOKEN: string;
|
|
41
|
+
UPSTASH_DISABLE_TELEMETRY?: string;
|
|
41
42
|
}, opts?: Omit<RedisConfigCloudflare, "url" | "token">): Redis;
|
|
42
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as core from "../pkg/redis.js";
|
|
2
|
-
import type { Requester,
|
|
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,
|
|
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,
|
|
2
|
+
import { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
|
|
3
3
|
export type { Requester, UpstashRequest, UpstashResponse };
|
|
4
4
|
/**
|
|
5
5
|
* Connection credentials for upstash redis.
|
|
@@ -29,11 +29,8 @@ export declare type RedisConfigNodejs = {
|
|
|
29
29
|
* }
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
retry?: RetryConfig;
|
|
36
|
-
} & core.RedisOptions;
|
|
32
|
+
agent?: any;
|
|
33
|
+
} & core.RedisOptions & RequesterConfig;
|
|
37
34
|
/**
|
|
38
35
|
* Serverless redis client for upstash.
|
|
39
36
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "v0.0.0-ci.b8efaf97-20230119";
|