@upstash/redis 1.19.2 → 1.19.3
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/esm/pkg/http.js +0 -9
- package/esm/pkg/redis.js +10 -0
- package/esm/platforms/cloudflare.js +6 -6
- package/esm/platforms/fastly.js +5 -0
- package/esm/platforms/node_with_fetch.js +10 -11
- package/esm/platforms/nodejs.js +10 -11
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/script/pkg/http.js +0 -9
- package/script/pkg/redis.js +10 -0
- package/script/platforms/cloudflare.js +6 -6
- package/script/platforms/fastly.js +5 -0
- package/script/platforms/node_with_fetch.js +10 -11
- package/script/platforms/nodejs.js +10 -11
- package/script/version.js +1 -1
- package/types/pkg/http.d.ts +0 -1
- package/types/pkg/redis.d.ts +4 -1
- package/types/version.d.ts +1 -1
package/esm/pkg/http.js
CHANGED
|
@@ -35,15 +35,6 @@ export class HttpClient {
|
|
|
35
35
|
"Content-Type": "application/json",
|
|
36
36
|
...config.headers,
|
|
37
37
|
};
|
|
38
|
-
if (config.telemetry?.runtime) {
|
|
39
|
-
this.headers["Upstash-Telemetry-Runtime"] = config.telemetry.runtime;
|
|
40
|
-
}
|
|
41
|
-
if (config.telemetry?.platform) {
|
|
42
|
-
this.headers["Upstash-Telemetry-Platform"] = config.telemetry.platform;
|
|
43
|
-
}
|
|
44
|
-
if (config.telemetry?.sdk) {
|
|
45
|
-
this.headers["Upstash-Telemetry-Sdk"] = config.telemetry.sdk;
|
|
46
|
-
}
|
|
47
38
|
if (this.options.responseEncoding === "base64") {
|
|
48
39
|
this.headers["Upstash-Encoding"] = "base64";
|
|
49
40
|
}
|
package/esm/pkg/redis.js
CHANGED
|
@@ -31,6 +31,12 @@ export class Redis {
|
|
|
31
31
|
writable: true,
|
|
32
32
|
value: void 0
|
|
33
33
|
});
|
|
34
|
+
Object.defineProperty(this, "enableTelemetry", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: void 0
|
|
39
|
+
});
|
|
34
40
|
/**
|
|
35
41
|
* Wrap a new middleware around the HTTP client.
|
|
36
42
|
*/
|
|
@@ -51,6 +57,9 @@ export class Redis {
|
|
|
51
57
|
configurable: true,
|
|
52
58
|
writable: true,
|
|
53
59
|
value: (telemetry) => {
|
|
60
|
+
if (!this.enableTelemetry) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
54
63
|
try {
|
|
55
64
|
// @ts-ignore - The `Requester` interface does not know about this method but it will be there
|
|
56
65
|
// as long as the user uses the standard HttpClient
|
|
@@ -1183,6 +1192,7 @@ export class Redis {
|
|
|
1183
1192
|
});
|
|
1184
1193
|
this.client = client;
|
|
1185
1194
|
this.opts = opts;
|
|
1195
|
+
this.enableTelemetry = opts?.enableTelemetry ?? true;
|
|
1186
1196
|
}
|
|
1187
1197
|
createScript(script) {
|
|
1188
1198
|
return new Script(this, script);
|
|
@@ -27,21 +27,21 @@ export class Redis extends core.Redis {
|
|
|
27
27
|
/\r|\n/.test(config.token)) {
|
|
28
28
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
29
29
|
}
|
|
30
|
-
const telemetry = {};
|
|
31
|
-
if (!env?.UPSTASH_DISABLE_TELEMETRY) {
|
|
32
|
-
telemetry.platform = "cloudflare";
|
|
33
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
34
|
-
}
|
|
35
30
|
const client = new HttpClient({
|
|
36
31
|
retry: config.retry,
|
|
37
32
|
baseUrl: config.url,
|
|
38
33
|
headers: { authorization: `Bearer ${config.token}` },
|
|
39
34
|
responseEncoding: config.responseEncoding,
|
|
40
|
-
telemetry,
|
|
41
35
|
});
|
|
42
36
|
super(client, {
|
|
37
|
+
enableTelemetry: !env?.UPSTASH_DISABLE_TELEMETRY,
|
|
43
38
|
automaticDeserialization: config.automaticDeserialization,
|
|
44
39
|
});
|
|
40
|
+
// This is only added of the user has not disabled telemetry
|
|
41
|
+
this.addTelemetry({
|
|
42
|
+
platform: "cloudflare",
|
|
43
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
44
|
+
});
|
|
45
45
|
}
|
|
46
46
|
/*
|
|
47
47
|
* Create a new Upstash Redis instance from environment variables on cloudflare.
|
package/esm/platforms/fastly.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as core from "../pkg/redis.js";
|
|
2
2
|
import { HttpClient } from "../pkg/http.js";
|
|
3
|
+
import { VERSION } from "../version.js";
|
|
3
4
|
/**
|
|
4
5
|
* Serverless redis client for upstash.
|
|
5
6
|
*/
|
|
@@ -37,5 +38,9 @@ export class Redis extends core.Redis {
|
|
|
37
38
|
super(client, {
|
|
38
39
|
automaticDeserialization: config.automaticDeserialization,
|
|
39
40
|
});
|
|
41
|
+
this.addTelemetry({
|
|
42
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
43
|
+
platform: "fastly",
|
|
44
|
+
});
|
|
40
45
|
}
|
|
41
46
|
}
|
|
@@ -35,26 +35,25 @@ export class Redis extends core.Redis {
|
|
|
35
35
|
/\r|\n/.test(configOrRequester.token)) {
|
|
36
36
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
37
37
|
}
|
|
38
|
-
const telemetry = {};
|
|
39
|
-
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
40
|
-
telemetry.runtime = `node@${process.version}`;
|
|
41
|
-
telemetry.platform = process.env.VERCEL
|
|
42
|
-
? "vercel"
|
|
43
|
-
: process.env.AWS_REGION
|
|
44
|
-
? "aws"
|
|
45
|
-
: "unknown";
|
|
46
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
47
|
-
}
|
|
48
38
|
const client = new HttpClient({
|
|
49
39
|
baseUrl: configOrRequester.url,
|
|
50
40
|
retry: configOrRequester.retry,
|
|
51
41
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
52
42
|
// agent: configOrRequester.agent,
|
|
53
43
|
responseEncoding: configOrRequester.responseEncoding,
|
|
54
|
-
telemetry,
|
|
55
44
|
});
|
|
56
45
|
super(client, {
|
|
57
46
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
47
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
48
|
+
});
|
|
49
|
+
this.addTelemetry({
|
|
50
|
+
runtime: `node@${process.version}`,
|
|
51
|
+
platform: process.env.VERCEL
|
|
52
|
+
? "vercel"
|
|
53
|
+
: process.env.AWS_REGION
|
|
54
|
+
? "aws"
|
|
55
|
+
: "unknown",
|
|
56
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
59
|
/**
|
package/esm/platforms/nodejs.js
CHANGED
|
@@ -29,26 +29,25 @@ export class Redis extends core.Redis {
|
|
|
29
29
|
/\r|\n/.test(configOrRequester.token)) {
|
|
30
30
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
31
31
|
}
|
|
32
|
-
const telemetry = {};
|
|
33
|
-
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
34
|
-
telemetry.runtime = `node@${process.version}`;
|
|
35
|
-
telemetry.platform = process.env.VERCEL
|
|
36
|
-
? "vercel"
|
|
37
|
-
: process.env.AWS_REGION
|
|
38
|
-
? "aws"
|
|
39
|
-
: "unknown";
|
|
40
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
41
|
-
}
|
|
42
32
|
const client = new HttpClient({
|
|
43
33
|
baseUrl: configOrRequester.url,
|
|
44
34
|
retry: configOrRequester.retry,
|
|
45
35
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
46
36
|
agent: configOrRequester.agent,
|
|
47
37
|
responseEncoding: configOrRequester.responseEncoding,
|
|
48
|
-
telemetry,
|
|
49
38
|
});
|
|
50
39
|
super(client, {
|
|
51
40
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
41
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
42
|
+
});
|
|
43
|
+
this.addTelemetry({
|
|
44
|
+
runtime: `node@${process.version}`,
|
|
45
|
+
platform: process.env.VERCEL
|
|
46
|
+
? "vercel"
|
|
47
|
+
: process.env.AWS_REGION
|
|
48
|
+
? "aws"
|
|
49
|
+
: "unknown",
|
|
50
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
/**
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "v1.19.
|
|
1
|
+
export const VERSION = "v1.19.3";
|
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": "v1.19.
|
|
6
|
+
"version": "v1.19.3",
|
|
7
7
|
"description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
package/script/pkg/http.js
CHANGED
|
@@ -38,15 +38,6 @@ class HttpClient {
|
|
|
38
38
|
"Content-Type": "application/json",
|
|
39
39
|
...config.headers,
|
|
40
40
|
};
|
|
41
|
-
if (config.telemetry?.runtime) {
|
|
42
|
-
this.headers["Upstash-Telemetry-Runtime"] = config.telemetry.runtime;
|
|
43
|
-
}
|
|
44
|
-
if (config.telemetry?.platform) {
|
|
45
|
-
this.headers["Upstash-Telemetry-Platform"] = config.telemetry.platform;
|
|
46
|
-
}
|
|
47
|
-
if (config.telemetry?.sdk) {
|
|
48
|
-
this.headers["Upstash-Telemetry-Sdk"] = config.telemetry.sdk;
|
|
49
|
-
}
|
|
50
41
|
if (this.options.responseEncoding === "base64") {
|
|
51
42
|
this.headers["Upstash-Encoding"] = "base64";
|
|
52
43
|
}
|
package/script/pkg/redis.js
CHANGED
|
@@ -34,6 +34,12 @@ class Redis {
|
|
|
34
34
|
writable: true,
|
|
35
35
|
value: void 0
|
|
36
36
|
});
|
|
37
|
+
Object.defineProperty(this, "enableTelemetry", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
37
43
|
/**
|
|
38
44
|
* Wrap a new middleware around the HTTP client.
|
|
39
45
|
*/
|
|
@@ -54,6 +60,9 @@ class Redis {
|
|
|
54
60
|
configurable: true,
|
|
55
61
|
writable: true,
|
|
56
62
|
value: (telemetry) => {
|
|
63
|
+
if (!this.enableTelemetry) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
57
66
|
try {
|
|
58
67
|
// @ts-ignore - The `Requester` interface does not know about this method but it will be there
|
|
59
68
|
// as long as the user uses the standard HttpClient
|
|
@@ -1186,6 +1195,7 @@ class Redis {
|
|
|
1186
1195
|
});
|
|
1187
1196
|
this.client = client;
|
|
1188
1197
|
this.opts = opts;
|
|
1198
|
+
this.enableTelemetry = opts?.enableTelemetry ?? true;
|
|
1189
1199
|
}
|
|
1190
1200
|
createScript(script) {
|
|
1191
1201
|
return new script_js_1.Script(this, script);
|
|
@@ -53,21 +53,21 @@ 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 telemetry = {};
|
|
57
|
-
if (!env?.UPSTASH_DISABLE_TELEMETRY) {
|
|
58
|
-
telemetry.platform = "cloudflare";
|
|
59
|
-
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
60
|
-
}
|
|
61
56
|
const client = new http_js_1.HttpClient({
|
|
62
57
|
retry: config.retry,
|
|
63
58
|
baseUrl: config.url,
|
|
64
59
|
headers: { authorization: `Bearer ${config.token}` },
|
|
65
60
|
responseEncoding: config.responseEncoding,
|
|
66
|
-
telemetry,
|
|
67
61
|
});
|
|
68
62
|
super(client, {
|
|
63
|
+
enableTelemetry: !env?.UPSTASH_DISABLE_TELEMETRY,
|
|
69
64
|
automaticDeserialization: config.automaticDeserialization,
|
|
70
65
|
});
|
|
66
|
+
// This is only added of the user has not disabled telemetry
|
|
67
|
+
this.addTelemetry({
|
|
68
|
+
platform: "cloudflare",
|
|
69
|
+
sdk: `@upstash/redis@${version_js_1.VERSION}`,
|
|
70
|
+
});
|
|
71
71
|
}
|
|
72
72
|
/*
|
|
73
73
|
* Create a new Upstash Redis instance from environment variables on cloudflare.
|
|
@@ -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
|
*/
|
|
@@ -63,6 +64,10 @@ class Redis extends core.Redis {
|
|
|
63
64
|
super(client, {
|
|
64
65
|
automaticDeserialization: config.automaticDeserialization,
|
|
65
66
|
});
|
|
67
|
+
this.addTelemetry({
|
|
68
|
+
sdk: `@upstash/redis@${version_js_1.VERSION}`,
|
|
69
|
+
platform: "fastly",
|
|
70
|
+
});
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
73
|
exports.Redis = Redis;
|
|
@@ -61,26 +61,25 @@ class Redis extends core.Redis {
|
|
|
61
61
|
/\r|\n/.test(configOrRequester.token)) {
|
|
62
62
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
63
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
|
-
}
|
|
74
64
|
const client = new http_js_1.HttpClient({
|
|
75
65
|
baseUrl: configOrRequester.url,
|
|
76
66
|
retry: configOrRequester.retry,
|
|
77
67
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
78
68
|
// agent: configOrRequester.agent,
|
|
79
69
|
responseEncoding: configOrRequester.responseEncoding,
|
|
80
|
-
telemetry,
|
|
81
70
|
});
|
|
82
71
|
super(client, {
|
|
83
72
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
73
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
74
|
+
});
|
|
75
|
+
this.addTelemetry({
|
|
76
|
+
runtime: `node@${process.version}`,
|
|
77
|
+
platform: process.env.VERCEL
|
|
78
|
+
? "vercel"
|
|
79
|
+
: process.env.AWS_REGION
|
|
80
|
+
? "aws"
|
|
81
|
+
: "unknown",
|
|
82
|
+
sdk: `@upstash/redis@${version_js_1.VERSION}`,
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
@@ -55,26 +55,25 @@ class Redis extends core.Redis {
|
|
|
55
55
|
/\r|\n/.test(configOrRequester.token)) {
|
|
56
56
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
57
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
|
-
}
|
|
68
58
|
const client = new http_js_1.HttpClient({
|
|
69
59
|
baseUrl: configOrRequester.url,
|
|
70
60
|
retry: configOrRequester.retry,
|
|
71
61
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
72
62
|
agent: configOrRequester.agent,
|
|
73
63
|
responseEncoding: configOrRequester.responseEncoding,
|
|
74
|
-
telemetry,
|
|
75
64
|
});
|
|
76
65
|
super(client, {
|
|
77
66
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
67
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
68
|
+
});
|
|
69
|
+
this.addTelemetry({
|
|
70
|
+
runtime: `node@${process.version}`,
|
|
71
|
+
platform: process.env.VERCEL
|
|
72
|
+
? "vercel"
|
|
73
|
+
: process.env.AWS_REGION
|
|
74
|
+
? "aws"
|
|
75
|
+
: "unknown",
|
|
76
|
+
sdk: `@upstash/redis@${version_js_1.VERSION}`,
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
79
|
/**
|
package/script/version.js
CHANGED
package/types/pkg/http.d.ts
CHANGED
package/types/pkg/redis.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Requester, UpstashRequest, UpstashResponse } from "./http.js";
|
|
|
3
3
|
import { Pipeline } from "./pipeline.js";
|
|
4
4
|
import type { CommandArgs } from "./types.js";
|
|
5
5
|
import { Script } from "./script.js";
|
|
6
|
+
import { Telemetry } from "./types.js";
|
|
6
7
|
export declare type RedisOptions = {
|
|
7
8
|
/**
|
|
8
9
|
* Automatically try to deserialize the returned data from upstash using `JSON.deserialize`
|
|
@@ -10,6 +11,7 @@ export declare type RedisOptions = {
|
|
|
10
11
|
* @default true
|
|
11
12
|
*/
|
|
12
13
|
automaticDeserialization?: boolean;
|
|
14
|
+
enableTelemetry?: boolean;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* Serverless redis client for upstash.
|
|
@@ -17,6 +19,7 @@ export declare type RedisOptions = {
|
|
|
17
19
|
export declare class Redis {
|
|
18
20
|
protected client: Requester;
|
|
19
21
|
protected opts?: CommandOptions<any, any>;
|
|
22
|
+
protected enableTelemetry: boolean;
|
|
20
23
|
/**
|
|
21
24
|
* Create a new redis client
|
|
22
25
|
*
|
|
@@ -36,7 +39,7 @@ export declare class Redis {
|
|
|
36
39
|
/**
|
|
37
40
|
* Technically this is not private, we can hide it from intellisense by doing this
|
|
38
41
|
*/
|
|
39
|
-
|
|
42
|
+
protected addTelemetry: (telemetry: Telemetry) => void;
|
|
40
43
|
createScript(script: string): Script;
|
|
41
44
|
/**
|
|
42
45
|
* Create a new pipeline that allows you to send requests in bulk.
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "v1.19.
|
|
1
|
+
export declare const VERSION = "v1.19.3";
|