@upstash/redis 0.0.0-ci.ec86feafac6d95eed4e9c9d8a5ff13b74ed84a74-20240709145745 → 0.0.0-ci.ed4e6de160b6a8d6f2caedfb5836805e0ffd2cdd-20241008135327
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 +1 -2
- package/chunk-BG6GZAGZ.mjs +3810 -0
- package/cloudflare.d.mts +7 -3
- package/cloudflare.d.ts +7 -3
- package/cloudflare.js +3922 -1
- package/cloudflare.mjs +93 -1
- package/fastly.d.mts +7 -3
- package/fastly.d.ts +7 -3
- package/fastly.js +3895 -1
- package/fastly.mjs +66 -1
- package/nodejs.d.mts +8 -22
- package/nodejs.d.ts +8 -22
- package/nodejs.js +3942 -1
- package/nodejs.mjs +113 -1
- package/package.json +1 -1
- package/{zmscore-09122379.d.ts → zmscore-BLgYk16R.d.mts} +157 -191
- package/zmscore-BLgYk16R.d.ts +3488 -0
- package/chunk-PXDAFHKP.js +0 -1
- package/chunk-SGK6FTNU.mjs +0 -1
package/nodejs.mjs
CHANGED
|
@@ -1 +1,113 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
HttpClient,
|
|
3
|
+
Redis,
|
|
4
|
+
VERSION,
|
|
5
|
+
error_exports
|
|
6
|
+
} from "./chunk-BG6GZAGZ.mjs";
|
|
7
|
+
|
|
8
|
+
// platforms/nodejs.ts
|
|
9
|
+
if (typeof atob === "undefined") {
|
|
10
|
+
global.atob = (b64) => Buffer.from(b64, "base64").toString("utf8");
|
|
11
|
+
}
|
|
12
|
+
var Redis2 = class _Redis extends Redis {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new redis client by providing a custom `Requester` implementation
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
*
|
|
19
|
+
* import { UpstashRequest, Requester, UpstashResponse, Redis } from "@upstash/redis"
|
|
20
|
+
*
|
|
21
|
+
* const requester: Requester = {
|
|
22
|
+
* request: <TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>> => {
|
|
23
|
+
* // ...
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* const redis = new Redis(requester)
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
constructor(configOrRequester) {
|
|
31
|
+
if ("request" in configOrRequester) {
|
|
32
|
+
super(configOrRequester);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!configOrRequester.url) {
|
|
36
|
+
console.warn(
|
|
37
|
+
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
|
|
38
|
+
);
|
|
39
|
+
} else if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
|
|
40
|
+
console.warn(
|
|
41
|
+
"[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (!configOrRequester.token) {
|
|
45
|
+
console.warn(
|
|
46
|
+
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
|
|
47
|
+
);
|
|
48
|
+
} else if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
|
|
49
|
+
console.warn(
|
|
50
|
+
"[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const client = new HttpClient({
|
|
54
|
+
baseUrl: configOrRequester.url,
|
|
55
|
+
retry: configOrRequester.retry,
|
|
56
|
+
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
57
|
+
agent: configOrRequester.agent,
|
|
58
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
59
|
+
cache: configOrRequester.cache ?? "no-store",
|
|
60
|
+
signal: configOrRequester.signal,
|
|
61
|
+
keepAlive: configOrRequester.keepAlive,
|
|
62
|
+
readYourWrites: configOrRequester.readYourWrites
|
|
63
|
+
});
|
|
64
|
+
super(client, {
|
|
65
|
+
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
66
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
67
|
+
latencyLogging: configOrRequester.latencyLogging,
|
|
68
|
+
enableAutoPipelining: configOrRequester.enableAutoPipelining
|
|
69
|
+
});
|
|
70
|
+
this.addTelemetry({
|
|
71
|
+
runtime: (
|
|
72
|
+
// @ts-expect-error to silence compiler
|
|
73
|
+
typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
|
|
74
|
+
),
|
|
75
|
+
platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
|
|
76
|
+
sdk: `@upstash/redis@${VERSION}`
|
|
77
|
+
});
|
|
78
|
+
if (this.enableAutoPipelining) {
|
|
79
|
+
return this.autoPipeline();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a new Upstash Redis instance from environment variables.
|
|
84
|
+
*
|
|
85
|
+
* Use this to automatically load connection secrets from your environment
|
|
86
|
+
* variables. For instance when using the Vercel integration.
|
|
87
|
+
*
|
|
88
|
+
* This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
|
|
89
|
+
* your environment using `process.env`.
|
|
90
|
+
*/
|
|
91
|
+
static fromEnv(config) {
|
|
92
|
+
if (process.env === void 0) {
|
|
93
|
+
throw new TypeError(
|
|
94
|
+
'[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
const url = process.env.UPSTASH_REDIS_REST_URL;
|
|
98
|
+
if (!url) {
|
|
99
|
+
console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
|
|
100
|
+
}
|
|
101
|
+
const token = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
102
|
+
if (!token) {
|
|
103
|
+
console.warn(
|
|
104
|
+
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return new _Redis({ ...config, url, token });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
export {
|
|
111
|
+
Redis2 as Redis,
|
|
112
|
+
error_exports as errors
|
|
113
|
+
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/redis","version":"v0.0.0-ci.
|
|
1
|
+
{"name":"@upstash/redis","version":"v0.0.0-ci.ed4e6de160b6a8d6f2caedfb5836805e0ffd2cdd-20241008135327","main":"./nodejs.js","module":"./nodejs.mjs","types":"./nodejs.d.ts","exports":{".":{"import":"./nodejs.mjs","require":"./nodejs.js"},"./node":{"import":"./nodejs.mjs","require":"./nodejs.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./cloudflare.js":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./cloudflare.mjs":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./fastly":{"import":"./fastly.mjs","require":"./fastly.js"},"./fastly.js":{"import":"./fastly.mjs","require":"./fastly.js"},"./fastly.mjs":{"import":"./fastly.mjs","require":"./fastly.js"}},"description":"An HTTP/REST based Redis client built on top of Upstash REST API.","repository":{"type":"git","url":"git+https://github.com/upstash/upstash-redis.git"},"keywords":["redis","database","serverless","edge","upstash"],"files":["./*"],"scripts":{"build":"tsup && cp package.json README.md LICENSE dist/","test":"bun test pkg","fmt":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","lint":"eslint \"**/*.{js,ts,tsx}\" --quiet --fix","format":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","format:check":"prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"","lint:fix":"eslint . -c .ts,.tsx,.js,.jsx --fix","commit":"cz","lint:format":"bun run lint:fix && bun run format","check-exports":"bun run build && cd dist && attw -P"},"author":"Andreas Thomas <dev@chronark.com>","license":"MIT","bugs":{"url":"https://github.com/upstash/upstash-redis/issues"},"homepage":"https://github.com/upstash/upstash-redis#readme","devDependencies":{"@biomejs/biome":"latest","@commitlint/cli":"^19.3.0","@commitlint/config-conventional":"^19.2.2","@types/crypto-js":"^4.1.3","@typescript-eslint/eslint-plugin":"8.4.0","@typescript-eslint/parser":"8.4.0","bun-types":"1.0.33","eslint":"9.10.0","eslint-plugin-unicorn":"55.0.0","husky":"^9.1.1","prettier":"^3.3.3","tsup":"^8.2.3","typescript":"latest"},"dependencies":{"crypto-js":"^4.2.0"}}
|