@upstash/redis 0.0.0-ci.ed4e6de160b6a8d6f2caedfb5836805e0ffd2cdd-20241008135327 → 0.0.0-ci.ef1ca9829e359ba31196db06ff1da80cd201974b-20241009150255
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/{chunk-BG6GZAGZ.mjs → chunk-YGIPCDY3.mjs} +18 -28
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +30 -42
- package/cloudflare.mjs +13 -15
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +26 -38
- package/fastly.mjs +9 -11
- package/nodejs.d.mts +2 -2
- package/nodejs.d.ts +2 -2
- package/nodejs.js +31 -45
- package/nodejs.mjs +14 -18
- package/package.json +1 -1
- package/{zmscore-BLgYk16R.d.mts → zmscore-Dc6Llqgr.d.mts} +34 -13
- package/{zmscore-BLgYk16R.d.ts → zmscore-Dc6Llqgr.d.ts} +34 -13
|
@@ -19,7 +19,7 @@ var UpstashError = class extends Error {
|
|
|
19
19
|
var UrlError = class extends Error {
|
|
20
20
|
constructor(url) {
|
|
21
21
|
super(
|
|
22
|
-
`Upstash Redis client was passed an invalid URL. You should pass
|
|
22
|
+
`Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
|
|
23
23
|
);
|
|
24
24
|
this.name = "UrlError";
|
|
25
25
|
}
|
|
@@ -32,7 +32,6 @@ var HttpClient = class {
|
|
|
32
32
|
options;
|
|
33
33
|
readYourWrites;
|
|
34
34
|
upstashSyncToken = "";
|
|
35
|
-
hasCredentials;
|
|
36
35
|
retry;
|
|
37
36
|
constructor(config) {
|
|
38
37
|
this.options = {
|
|
@@ -46,16 +45,15 @@ var HttpClient = class {
|
|
|
46
45
|
};
|
|
47
46
|
this.upstashSyncToken = "";
|
|
48
47
|
this.readYourWrites = config.readYourWrites ?? true;
|
|
49
|
-
this.baseUrl =
|
|
48
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
50
49
|
const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
|
|
51
|
-
if (
|
|
50
|
+
if (!urlRegex.test(this.baseUrl)) {
|
|
52
51
|
throw new UrlError(this.baseUrl);
|
|
53
52
|
}
|
|
54
53
|
this.headers = {
|
|
55
54
|
"Content-Type": "application/json",
|
|
56
55
|
...config.headers
|
|
57
56
|
};
|
|
58
|
-
this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
|
|
59
57
|
if (this.options.responseEncoding === "base64") {
|
|
60
58
|
this.headers["Upstash-Encoding"] = "base64";
|
|
61
59
|
}
|
|
@@ -87,11 +85,6 @@ var HttpClient = class {
|
|
|
87
85
|
*/
|
|
88
86
|
backend: this.options.backend
|
|
89
87
|
};
|
|
90
|
-
if (!this.hasCredentials) {
|
|
91
|
-
throw new Error(
|
|
92
|
-
"[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
88
|
if (this.readYourWrites) {
|
|
96
89
|
const newHeader = this.upstashSyncToken;
|
|
97
90
|
this.headers["upstash-sync-token"] = newHeader;
|
|
@@ -2122,9 +2115,9 @@ var Pipeline = class {
|
|
|
2122
2115
|
this.multiExec = opts.multiExec ?? false;
|
|
2123
2116
|
if (this.commandOptions?.latencyLogging) {
|
|
2124
2117
|
const originalExec = this.exec.bind(this);
|
|
2125
|
-
this.exec = async () => {
|
|
2118
|
+
this.exec = async (options) => {
|
|
2126
2119
|
const start = performance.now();
|
|
2127
|
-
const result = await originalExec();
|
|
2120
|
+
const result = await (options ? originalExec(options) : originalExec());
|
|
2128
2121
|
const end = performance.now();
|
|
2129
2122
|
const loggerResult = (end - start).toFixed(2);
|
|
2130
2123
|
console.log(
|
|
@@ -2134,19 +2127,7 @@ var Pipeline = class {
|
|
|
2134
2127
|
};
|
|
2135
2128
|
}
|
|
2136
2129
|
}
|
|
2137
|
-
|
|
2138
|
-
* Send the pipeline request to upstash.
|
|
2139
|
-
*
|
|
2140
|
-
* Returns an array with the results of all pipelined commands.
|
|
2141
|
-
*
|
|
2142
|
-
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
2143
|
-
* ```ts
|
|
2144
|
-
* const p = redis.pipeline()
|
|
2145
|
-
* p.get("key")
|
|
2146
|
-
* const result = p.exec<[{ greeting: string }]>()
|
|
2147
|
-
* ```
|
|
2148
|
-
*/
|
|
2149
|
-
exec = async () => {
|
|
2130
|
+
exec = async (options) => {
|
|
2150
2131
|
if (this.commands.length === 0) {
|
|
2151
2132
|
throw new Error("Pipeline is empty");
|
|
2152
2133
|
}
|
|
@@ -2155,7 +2136,12 @@ var Pipeline = class {
|
|
|
2155
2136
|
path,
|
|
2156
2137
|
body: Object.values(this.commands).map((c) => c.command)
|
|
2157
2138
|
});
|
|
2158
|
-
return res.map(({ error, result }, i) => {
|
|
2139
|
+
return options?.keepErrors ? res.map(({ error, result }, i) => {
|
|
2140
|
+
return {
|
|
2141
|
+
error,
|
|
2142
|
+
result: this.commands[i].deserialize(result)
|
|
2143
|
+
};
|
|
2144
|
+
}) : res.map(({ error, result }, i) => {
|
|
2159
2145
|
if (error) {
|
|
2160
2146
|
throw new UpstashError(
|
|
2161
2147
|
`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
|
|
@@ -2949,7 +2935,7 @@ var AutoPipelineExecutor = class {
|
|
|
2949
2935
|
executeWithPipeline(pipeline);
|
|
2950
2936
|
const pipelineDone = this.deferExecution().then(() => {
|
|
2951
2937
|
if (!this.pipelinePromises.has(pipeline)) {
|
|
2952
|
-
const pipelinePromise = pipeline.exec();
|
|
2938
|
+
const pipelinePromise = pipeline.exec({ keepErrors: true });
|
|
2953
2939
|
this.pipelineCounter += 1;
|
|
2954
2940
|
this.pipelinePromises.set(pipeline, pipelinePromise);
|
|
2955
2941
|
this.activePipeline = null;
|
|
@@ -2957,7 +2943,11 @@ var AutoPipelineExecutor = class {
|
|
|
2957
2943
|
return this.pipelinePromises.get(pipeline);
|
|
2958
2944
|
});
|
|
2959
2945
|
const results = await pipelineDone;
|
|
2960
|
-
|
|
2946
|
+
const commandResult = results[index];
|
|
2947
|
+
if (commandResult.error) {
|
|
2948
|
+
throw new UpstashError(`Command failed: ${commandResult.error}`);
|
|
2949
|
+
}
|
|
2950
|
+
return commandResult.result;
|
|
2961
2951
|
}
|
|
2962
2952
|
async deferExecution() {
|
|
2963
2953
|
await Promise.resolve();
|
package/cloudflare.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-
|
|
2
|
-
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-Dc6Llqgr.mjs';
|
|
2
|
+
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-Dc6Llqgr.mjs';
|
|
3
3
|
|
|
4
4
|
type Env = {
|
|
5
5
|
UPSTASH_DISABLE_TELEMETRY?: string;
|
package/cloudflare.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-
|
|
2
|
-
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-Dc6Llqgr.js';
|
|
2
|
+
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-Dc6Llqgr.js';
|
|
3
3
|
|
|
4
4
|
type Env = {
|
|
5
5
|
UPSTASH_DISABLE_TELEMETRY?: string;
|
package/cloudflare.js
CHANGED
|
@@ -50,7 +50,7 @@ var UpstashError = class extends Error {
|
|
|
50
50
|
var UrlError = class extends Error {
|
|
51
51
|
constructor(url) {
|
|
52
52
|
super(
|
|
53
|
-
`Upstash Redis client was passed an invalid URL. You should pass
|
|
53
|
+
`Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
|
|
54
54
|
);
|
|
55
55
|
this.name = "UrlError";
|
|
56
56
|
}
|
|
@@ -63,7 +63,6 @@ var HttpClient = class {
|
|
|
63
63
|
options;
|
|
64
64
|
readYourWrites;
|
|
65
65
|
upstashSyncToken = "";
|
|
66
|
-
hasCredentials;
|
|
67
66
|
retry;
|
|
68
67
|
constructor(config) {
|
|
69
68
|
this.options = {
|
|
@@ -77,16 +76,15 @@ var HttpClient = class {
|
|
|
77
76
|
};
|
|
78
77
|
this.upstashSyncToken = "";
|
|
79
78
|
this.readYourWrites = config.readYourWrites ?? true;
|
|
80
|
-
this.baseUrl =
|
|
79
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
81
80
|
const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
|
|
82
|
-
if (
|
|
81
|
+
if (!urlRegex.test(this.baseUrl)) {
|
|
83
82
|
throw new UrlError(this.baseUrl);
|
|
84
83
|
}
|
|
85
84
|
this.headers = {
|
|
86
85
|
"Content-Type": "application/json",
|
|
87
86
|
...config.headers
|
|
88
87
|
};
|
|
89
|
-
this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
|
|
90
88
|
if (this.options.responseEncoding === "base64") {
|
|
91
89
|
this.headers["Upstash-Encoding"] = "base64";
|
|
92
90
|
}
|
|
@@ -118,11 +116,6 @@ var HttpClient = class {
|
|
|
118
116
|
*/
|
|
119
117
|
backend: this.options.backend
|
|
120
118
|
};
|
|
121
|
-
if (!this.hasCredentials) {
|
|
122
|
-
throw new Error(
|
|
123
|
-
"[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
119
|
if (this.readYourWrites) {
|
|
127
120
|
const newHeader = this.upstashSyncToken;
|
|
128
121
|
this.headers["upstash-sync-token"] = newHeader;
|
|
@@ -289,7 +282,7 @@ var AutoPipelineExecutor = class {
|
|
|
289
282
|
executeWithPipeline(pipeline);
|
|
290
283
|
const pipelineDone = this.deferExecution().then(() => {
|
|
291
284
|
if (!this.pipelinePromises.has(pipeline)) {
|
|
292
|
-
const pipelinePromise = pipeline.exec();
|
|
285
|
+
const pipelinePromise = pipeline.exec({ keepErrors: true });
|
|
293
286
|
this.pipelineCounter += 1;
|
|
294
287
|
this.pipelinePromises.set(pipeline, pipelinePromise);
|
|
295
288
|
this.activePipeline = null;
|
|
@@ -297,7 +290,11 @@ var AutoPipelineExecutor = class {
|
|
|
297
290
|
return this.pipelinePromises.get(pipeline);
|
|
298
291
|
});
|
|
299
292
|
const results = await pipelineDone;
|
|
300
|
-
|
|
293
|
+
const commandResult = results[index];
|
|
294
|
+
if (commandResult.error) {
|
|
295
|
+
throw new UpstashError(`Command failed: ${commandResult.error}`);
|
|
296
|
+
}
|
|
297
|
+
return commandResult.result;
|
|
301
298
|
}
|
|
302
299
|
async deferExecution() {
|
|
303
300
|
await Promise.resolve();
|
|
@@ -2228,9 +2225,9 @@ var Pipeline = class {
|
|
|
2228
2225
|
this.multiExec = opts.multiExec ?? false;
|
|
2229
2226
|
if (this.commandOptions?.latencyLogging) {
|
|
2230
2227
|
const originalExec = this.exec.bind(this);
|
|
2231
|
-
this.exec = async () => {
|
|
2228
|
+
this.exec = async (options) => {
|
|
2232
2229
|
const start = performance.now();
|
|
2233
|
-
const result = await originalExec();
|
|
2230
|
+
const result = await (options ? originalExec(options) : originalExec());
|
|
2234
2231
|
const end = performance.now();
|
|
2235
2232
|
const loggerResult = (end - start).toFixed(2);
|
|
2236
2233
|
console.log(
|
|
@@ -2240,19 +2237,7 @@ var Pipeline = class {
|
|
|
2240
2237
|
};
|
|
2241
2238
|
}
|
|
2242
2239
|
}
|
|
2243
|
-
|
|
2244
|
-
* Send the pipeline request to upstash.
|
|
2245
|
-
*
|
|
2246
|
-
* Returns an array with the results of all pipelined commands.
|
|
2247
|
-
*
|
|
2248
|
-
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
2249
|
-
* ```ts
|
|
2250
|
-
* const p = redis.pipeline()
|
|
2251
|
-
* p.get("key")
|
|
2252
|
-
* const result = p.exec<[{ greeting: string }]>()
|
|
2253
|
-
* ```
|
|
2254
|
-
*/
|
|
2255
|
-
exec = async () => {
|
|
2240
|
+
exec = async (options) => {
|
|
2256
2241
|
if (this.commands.length === 0) {
|
|
2257
2242
|
throw new Error("Pipeline is empty");
|
|
2258
2243
|
}
|
|
@@ -2261,7 +2246,12 @@ var Pipeline = class {
|
|
|
2261
2246
|
path,
|
|
2262
2247
|
body: Object.values(this.commands).map((c) => c.command)
|
|
2263
2248
|
});
|
|
2264
|
-
return res.map(({ error, result }, i) => {
|
|
2249
|
+
return options?.keepErrors ? res.map(({ error, result }, i) => {
|
|
2250
|
+
return {
|
|
2251
|
+
error,
|
|
2252
|
+
result: this.commands[i].deserialize(result)
|
|
2253
|
+
};
|
|
2254
|
+
}) : res.map(({ error, result }, i) => {
|
|
2265
2255
|
if (error) {
|
|
2266
2256
|
throw new UpstashError(
|
|
2267
2257
|
`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
|
|
@@ -3848,22 +3838,20 @@ var Redis2 = class _Redis extends Redis {
|
|
|
3848
3838
|
*/
|
|
3849
3839
|
constructor(config, env) {
|
|
3850
3840
|
if (!config.url) {
|
|
3851
|
-
|
|
3841
|
+
throw new Error(
|
|
3852
3842
|
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
|
|
3853
3843
|
);
|
|
3854
|
-
} else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
|
|
3855
|
-
console.warn(
|
|
3856
|
-
"[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
|
|
3857
|
-
);
|
|
3858
3844
|
}
|
|
3859
3845
|
if (!config.token) {
|
|
3860
|
-
|
|
3846
|
+
throw new Error(
|
|
3861
3847
|
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
|
|
3862
3848
|
);
|
|
3863
|
-
}
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3849
|
+
}
|
|
3850
|
+
if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
|
|
3851
|
+
console.warn("The redis url contains whitespace or newline, which can cause errors!");
|
|
3852
|
+
}
|
|
3853
|
+
if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
|
|
3854
|
+
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
3867
3855
|
}
|
|
3868
3856
|
const client = new HttpClient({
|
|
3869
3857
|
retry: config.retry,
|
|
@@ -3903,13 +3891,13 @@ var Redis2 = class _Redis extends Redis {
|
|
|
3903
3891
|
const url = env?.UPSTASH_REDIS_REST_URL ?? UPSTASH_REDIS_REST_URL;
|
|
3904
3892
|
const token = env?.UPSTASH_REDIS_REST_TOKEN ?? UPSTASH_REDIS_REST_TOKEN;
|
|
3905
3893
|
if (!url) {
|
|
3906
|
-
|
|
3907
|
-
"
|
|
3894
|
+
throw new Error(
|
|
3895
|
+
"Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
|
|
3908
3896
|
);
|
|
3909
3897
|
}
|
|
3910
3898
|
if (!token) {
|
|
3911
|
-
|
|
3912
|
-
"
|
|
3899
|
+
throw new Error(
|
|
3900
|
+
"Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
|
|
3913
3901
|
);
|
|
3914
3902
|
}
|
|
3915
3903
|
return new _Redis({ ...opts, url, token }, env);
|
package/cloudflare.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Redis,
|
|
4
4
|
VERSION,
|
|
5
5
|
error_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YGIPCDY3.mjs";
|
|
7
7
|
|
|
8
8
|
// platforms/cloudflare.ts
|
|
9
9
|
var Redis2 = class _Redis extends Redis {
|
|
@@ -20,22 +20,20 @@ var Redis2 = class _Redis extends Redis {
|
|
|
20
20
|
*/
|
|
21
21
|
constructor(config, env) {
|
|
22
22
|
if (!config.url) {
|
|
23
|
-
|
|
23
|
+
throw new Error(
|
|
24
24
|
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
|
|
25
25
|
);
|
|
26
|
-
} else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
|
|
27
|
-
console.warn(
|
|
28
|
-
"[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
|
|
29
|
-
);
|
|
30
26
|
}
|
|
31
27
|
if (!config.token) {
|
|
32
|
-
|
|
28
|
+
throw new Error(
|
|
33
29
|
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
|
|
34
30
|
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
}
|
|
32
|
+
if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
|
|
33
|
+
console.warn("The redis url contains whitespace or newline, which can cause errors!");
|
|
34
|
+
}
|
|
35
|
+
if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
|
|
36
|
+
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
39
37
|
}
|
|
40
38
|
const client = new HttpClient({
|
|
41
39
|
retry: config.retry,
|
|
@@ -75,13 +73,13 @@ var Redis2 = class _Redis extends Redis {
|
|
|
75
73
|
const url = env?.UPSTASH_REDIS_REST_URL ?? UPSTASH_REDIS_REST_URL;
|
|
76
74
|
const token = env?.UPSTASH_REDIS_REST_TOKEN ?? UPSTASH_REDIS_REST_TOKEN;
|
|
77
75
|
if (!url) {
|
|
78
|
-
|
|
79
|
-
"
|
|
76
|
+
throw new Error(
|
|
77
|
+
"Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
|
|
80
78
|
);
|
|
81
79
|
}
|
|
82
80
|
if (!token) {
|
|
83
|
-
|
|
84
|
-
"
|
|
81
|
+
throw new Error(
|
|
82
|
+
"Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
|
|
85
83
|
);
|
|
86
84
|
}
|
|
87
85
|
return new _Redis({ ...opts, url, token }, env);
|
package/fastly.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-
|
|
2
|
-
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-Dc6Llqgr.mjs';
|
|
2
|
+
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-Dc6Llqgr.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Connection credentials for upstash redis.
|
package/fastly.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-
|
|
2
|
-
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-Dc6Llqgr.js';
|
|
2
|
+
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-Dc6Llqgr.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Connection credentials for upstash redis.
|
package/fastly.js
CHANGED
|
@@ -50,7 +50,7 @@ var UpstashError = class extends Error {
|
|
|
50
50
|
var UrlError = class extends Error {
|
|
51
51
|
constructor(url) {
|
|
52
52
|
super(
|
|
53
|
-
`Upstash Redis client was passed an invalid URL. You should pass
|
|
53
|
+
`Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
|
|
54
54
|
);
|
|
55
55
|
this.name = "UrlError";
|
|
56
56
|
}
|
|
@@ -63,7 +63,6 @@ var HttpClient = class {
|
|
|
63
63
|
options;
|
|
64
64
|
readYourWrites;
|
|
65
65
|
upstashSyncToken = "";
|
|
66
|
-
hasCredentials;
|
|
67
66
|
retry;
|
|
68
67
|
constructor(config) {
|
|
69
68
|
this.options = {
|
|
@@ -77,16 +76,15 @@ var HttpClient = class {
|
|
|
77
76
|
};
|
|
78
77
|
this.upstashSyncToken = "";
|
|
79
78
|
this.readYourWrites = config.readYourWrites ?? true;
|
|
80
|
-
this.baseUrl =
|
|
79
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
81
80
|
const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
|
|
82
|
-
if (
|
|
81
|
+
if (!urlRegex.test(this.baseUrl)) {
|
|
83
82
|
throw new UrlError(this.baseUrl);
|
|
84
83
|
}
|
|
85
84
|
this.headers = {
|
|
86
85
|
"Content-Type": "application/json",
|
|
87
86
|
...config.headers
|
|
88
87
|
};
|
|
89
|
-
this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
|
|
90
88
|
if (this.options.responseEncoding === "base64") {
|
|
91
89
|
this.headers["Upstash-Encoding"] = "base64";
|
|
92
90
|
}
|
|
@@ -118,11 +116,6 @@ var HttpClient = class {
|
|
|
118
116
|
*/
|
|
119
117
|
backend: this.options.backend
|
|
120
118
|
};
|
|
121
|
-
if (!this.hasCredentials) {
|
|
122
|
-
throw new Error(
|
|
123
|
-
"[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
119
|
if (this.readYourWrites) {
|
|
127
120
|
const newHeader = this.upstashSyncToken;
|
|
128
121
|
this.headers["upstash-sync-token"] = newHeader;
|
|
@@ -289,7 +282,7 @@ var AutoPipelineExecutor = class {
|
|
|
289
282
|
executeWithPipeline(pipeline);
|
|
290
283
|
const pipelineDone = this.deferExecution().then(() => {
|
|
291
284
|
if (!this.pipelinePromises.has(pipeline)) {
|
|
292
|
-
const pipelinePromise = pipeline.exec();
|
|
285
|
+
const pipelinePromise = pipeline.exec({ keepErrors: true });
|
|
293
286
|
this.pipelineCounter += 1;
|
|
294
287
|
this.pipelinePromises.set(pipeline, pipelinePromise);
|
|
295
288
|
this.activePipeline = null;
|
|
@@ -297,7 +290,11 @@ var AutoPipelineExecutor = class {
|
|
|
297
290
|
return this.pipelinePromises.get(pipeline);
|
|
298
291
|
});
|
|
299
292
|
const results = await pipelineDone;
|
|
300
|
-
|
|
293
|
+
const commandResult = results[index];
|
|
294
|
+
if (commandResult.error) {
|
|
295
|
+
throw new UpstashError(`Command failed: ${commandResult.error}`);
|
|
296
|
+
}
|
|
297
|
+
return commandResult.result;
|
|
301
298
|
}
|
|
302
299
|
async deferExecution() {
|
|
303
300
|
await Promise.resolve();
|
|
@@ -2228,9 +2225,9 @@ var Pipeline = class {
|
|
|
2228
2225
|
this.multiExec = opts.multiExec ?? false;
|
|
2229
2226
|
if (this.commandOptions?.latencyLogging) {
|
|
2230
2227
|
const originalExec = this.exec.bind(this);
|
|
2231
|
-
this.exec = async () => {
|
|
2228
|
+
this.exec = async (options) => {
|
|
2232
2229
|
const start = performance.now();
|
|
2233
|
-
const result = await originalExec();
|
|
2230
|
+
const result = await (options ? originalExec(options) : originalExec());
|
|
2234
2231
|
const end = performance.now();
|
|
2235
2232
|
const loggerResult = (end - start).toFixed(2);
|
|
2236
2233
|
console.log(
|
|
@@ -2240,19 +2237,7 @@ var Pipeline = class {
|
|
|
2240
2237
|
};
|
|
2241
2238
|
}
|
|
2242
2239
|
}
|
|
2243
|
-
|
|
2244
|
-
* Send the pipeline request to upstash.
|
|
2245
|
-
*
|
|
2246
|
-
* Returns an array with the results of all pipelined commands.
|
|
2247
|
-
*
|
|
2248
|
-
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
2249
|
-
* ```ts
|
|
2250
|
-
* const p = redis.pipeline()
|
|
2251
|
-
* p.get("key")
|
|
2252
|
-
* const result = p.exec<[{ greeting: string }]>()
|
|
2253
|
-
* ```
|
|
2254
|
-
*/
|
|
2255
|
-
exec = async () => {
|
|
2240
|
+
exec = async (options) => {
|
|
2256
2241
|
if (this.commands.length === 0) {
|
|
2257
2242
|
throw new Error("Pipeline is empty");
|
|
2258
2243
|
}
|
|
@@ -2261,7 +2246,12 @@ var Pipeline = class {
|
|
|
2261
2246
|
path,
|
|
2262
2247
|
body: Object.values(this.commands).map((c) => c.command)
|
|
2263
2248
|
});
|
|
2264
|
-
return res.map(({ error, result }, i) => {
|
|
2249
|
+
return options?.keepErrors ? res.map(({ error, result }, i) => {
|
|
2250
|
+
return {
|
|
2251
|
+
error,
|
|
2252
|
+
result: this.commands[i].deserialize(result)
|
|
2253
|
+
};
|
|
2254
|
+
}) : res.map(({ error, result }, i) => {
|
|
2265
2255
|
if (error) {
|
|
2266
2256
|
throw new UpstashError(
|
|
2267
2257
|
`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
|
|
@@ -3849,22 +3839,20 @@ var Redis2 = class extends Redis {
|
|
|
3849
3839
|
*/
|
|
3850
3840
|
constructor(config) {
|
|
3851
3841
|
if (!config.url) {
|
|
3852
|
-
|
|
3842
|
+
throw new Error(
|
|
3853
3843
|
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
|
|
3854
3844
|
);
|
|
3855
|
-
} else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
|
|
3856
|
-
console.warn(
|
|
3857
|
-
"[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
|
|
3858
|
-
);
|
|
3859
3845
|
}
|
|
3860
3846
|
if (!config.token) {
|
|
3861
|
-
|
|
3847
|
+
throw new Error(
|
|
3862
3848
|
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
|
|
3863
3849
|
);
|
|
3864
|
-
}
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3850
|
+
}
|
|
3851
|
+
if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
|
|
3852
|
+
console.warn("The redis url contains whitespace or newline, which can cause errors!");
|
|
3853
|
+
}
|
|
3854
|
+
if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
|
|
3855
|
+
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
3868
3856
|
}
|
|
3869
3857
|
const client = new HttpClient({
|
|
3870
3858
|
baseUrl: config.url,
|
package/fastly.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Redis,
|
|
4
4
|
VERSION,
|
|
5
5
|
error_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YGIPCDY3.mjs";
|
|
7
7
|
|
|
8
8
|
// platforms/fastly.ts
|
|
9
9
|
var Redis2 = class extends Redis {
|
|
@@ -21,22 +21,20 @@ var Redis2 = class extends Redis {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(config) {
|
|
23
23
|
if (!config.url) {
|
|
24
|
-
|
|
24
|
+
throw new Error(
|
|
25
25
|
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
|
|
26
26
|
);
|
|
27
|
-
} else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
|
|
28
|
-
console.warn(
|
|
29
|
-
"[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
|
|
30
|
-
);
|
|
31
27
|
}
|
|
32
28
|
if (!config.token) {
|
|
33
|
-
|
|
29
|
+
throw new Error(
|
|
34
30
|
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
|
|
35
31
|
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
}
|
|
33
|
+
if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
|
|
34
|
+
console.warn("The redis url contains whitespace or newline, which can cause errors!");
|
|
35
|
+
}
|
|
36
|
+
if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
|
|
37
|
+
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
40
38
|
}
|
|
41
39
|
const client = new HttpClient({
|
|
42
40
|
baseUrl: config.url,
|
package/nodejs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-
|
|
2
|
-
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-Dc6Llqgr.mjs';
|
|
2
|
+
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-Dc6Llqgr.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Connection credentials for upstash redis.
|
package/nodejs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-
|
|
2
|
-
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-Dc6Llqgr.js';
|
|
2
|
+
export { A as AppendCommand, B as BitCountCommand, f as BitOpCommand, g as BitPosCommand, C as CopyCommand, D as DBSizeCommand, i as DecrByCommand, h as DecrCommand, j as DelCommand, E as EchoCommand, k as EvalCommand, l as EvalshaCommand, m as ExistsCommand, o as ExpireAtCommand, n as ExpireCommand, F as FlushAllCommand, p as FlushDBCommand, G as GeoAddCommand, q as GeoAddCommandOptions, s as GeoDistCommand, t as GeoHashCommand, r as GeoMember, u as GeoPosCommand, v as GeoSearchCommand, w as GeoSearchStoreCommand, y as GetBitCommand, x as GetCommand, z as GetDelCommand, H as GetRangeCommand, I as GetSetCommand, J as HDelCommand, K as HExistsCommand, M as HGetAllCommand, L as HGetCommand, N as HIncrByCommand, O as HIncrByFloatCommand, Q as HKeysCommand, S as HLenCommand, T as HMGetCommand, V as HMSetCommand, W as HRandFieldCommand, X as HScanCommand, Y as HSetCommand, Z as HSetNXCommand, _ as HStrLenCommand, $ as HValsCommand, a1 as IncrByCommand, a2 as IncrByFloatCommand, a0 as IncrCommand, a3 as JsonArrAppendCommand, a4 as JsonArrIndexCommand, a5 as JsonArrInsertCommand, a6 as JsonArrLenCommand, a7 as JsonArrPopCommand, a8 as JsonArrTrimCommand, a9 as JsonClearCommand, aa as JsonDelCommand, ab as JsonForgetCommand, ac as JsonGetCommand, ad as JsonMGetCommand, ae as JsonNumIncrByCommand, af as JsonNumMultByCommand, ag as JsonObjKeysCommand, ah as JsonObjLenCommand, ai as JsonRespCommand, aj as JsonSetCommand, ak as JsonStrAppendCommand, al as JsonStrLenCommand, am as JsonToggleCommand, an as JsonTypeCommand, ao as KeysCommand, ap as LIndexCommand, aq as LInsertCommand, ar as LLenCommand, as as LMoveCommand, at as LPopCommand, au as LPushCommand, av as LPushXCommand, aw as LRangeCommand, ax as LRemCommand, ay as LSetCommand, az as LTrimCommand, aA as MGetCommand, aB as MSetCommand, aC as MSetNXCommand, aF as PExpireAtCommand, aE as PExpireCommand, aH as PSetEXCommand, aI as PTtlCommand, aD as PersistCommand, aG as PingCommand, P as Pipeline, aJ as PublishCommand, aN as RPopCommand, aO as RPushCommand, aP as RPushXCommand, aK as RandomKeyCommand, aL as RenameCommand, aM as RenameNXCommand, d as Requester, aQ as SAddCommand, aT as SCardCommand, aX as SDiffCommand, aY as SDiffStoreCommand, b3 as SInterCommand, b4 as SInterStoreCommand, b5 as SIsMemberCommand, b7 as SMIsMemberCommand, b6 as SMembersCommand, b8 as SMoveCommand, b9 as SPopCommand, ba as SRandMemberCommand, bb as SRemCommand, bc as SScanCommand, be as SUnionCommand, bf as SUnionStoreCommand, aR as ScanCommand, aS as ScanCommandOptions, bo as ScoreMember, aU as ScriptExistsCommand, aV as ScriptFlushCommand, aW as ScriptLoadCommand, a$ as SetBitCommand, aZ as SetCommand, a_ as SetCommandOptions, b0 as SetExCommand, b1 as SetNxCommand, b2 as SetRangeCommand, bd as StrLenCommand, bg as TimeCommand, bh as TouchCommand, bi as TtlCommand, bj as Type, bk as TypeCommand, bl as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bm as XAddCommand, bn as XRangeCommand, bq as ZAddCommand, bp as ZAddCommandOptions, br as ZCardCommand, bs as ZCountCommand, bt as ZDiffStoreCommand, bu as ZIncrByCommand, bv as ZInterStoreCommand, bw as ZInterStoreCommandOptions, bx as ZLexCountCommand, by as ZMScoreCommand, bz as ZPopMaxCommand, bA as ZPopMinCommand, bB as ZRangeCommand, bC as ZRangeCommandOptions, bD as ZRankCommand, bE as ZRemCommand, bF as ZRemRangeByLexCommand, bG as ZRemRangeByRankCommand, bH as ZRemRangeByScoreCommand, bI as ZRevRankCommand, bJ as ZScanCommand, bK as ZScoreCommand, bL as ZUnionCommand, bM as ZUnionCommandOptions, bN as ZUnionStoreCommand, bO as ZUnionStoreCommandOptions, e as errors } from './zmscore-Dc6Llqgr.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Connection credentials for upstash redis.
|
package/nodejs.js
CHANGED
|
@@ -50,7 +50,7 @@ var UpstashError = class extends Error {
|
|
|
50
50
|
var UrlError = class extends Error {
|
|
51
51
|
constructor(url) {
|
|
52
52
|
super(
|
|
53
|
-
`Upstash Redis client was passed an invalid URL. You should pass
|
|
53
|
+
`Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
|
|
54
54
|
);
|
|
55
55
|
this.name = "UrlError";
|
|
56
56
|
}
|
|
@@ -63,7 +63,6 @@ var HttpClient = class {
|
|
|
63
63
|
options;
|
|
64
64
|
readYourWrites;
|
|
65
65
|
upstashSyncToken = "";
|
|
66
|
-
hasCredentials;
|
|
67
66
|
retry;
|
|
68
67
|
constructor(config) {
|
|
69
68
|
this.options = {
|
|
@@ -77,16 +76,15 @@ var HttpClient = class {
|
|
|
77
76
|
};
|
|
78
77
|
this.upstashSyncToken = "";
|
|
79
78
|
this.readYourWrites = config.readYourWrites ?? true;
|
|
80
|
-
this.baseUrl =
|
|
79
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
81
80
|
const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
|
|
82
|
-
if (
|
|
81
|
+
if (!urlRegex.test(this.baseUrl)) {
|
|
83
82
|
throw new UrlError(this.baseUrl);
|
|
84
83
|
}
|
|
85
84
|
this.headers = {
|
|
86
85
|
"Content-Type": "application/json",
|
|
87
86
|
...config.headers
|
|
88
87
|
};
|
|
89
|
-
this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
|
|
90
88
|
if (this.options.responseEncoding === "base64") {
|
|
91
89
|
this.headers["Upstash-Encoding"] = "base64";
|
|
92
90
|
}
|
|
@@ -118,11 +116,6 @@ var HttpClient = class {
|
|
|
118
116
|
*/
|
|
119
117
|
backend: this.options.backend
|
|
120
118
|
};
|
|
121
|
-
if (!this.hasCredentials) {
|
|
122
|
-
throw new Error(
|
|
123
|
-
"[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
119
|
if (this.readYourWrites) {
|
|
127
120
|
const newHeader = this.upstashSyncToken;
|
|
128
121
|
this.headers["upstash-sync-token"] = newHeader;
|
|
@@ -289,7 +282,7 @@ var AutoPipelineExecutor = class {
|
|
|
289
282
|
executeWithPipeline(pipeline);
|
|
290
283
|
const pipelineDone = this.deferExecution().then(() => {
|
|
291
284
|
if (!this.pipelinePromises.has(pipeline)) {
|
|
292
|
-
const pipelinePromise = pipeline.exec();
|
|
285
|
+
const pipelinePromise = pipeline.exec({ keepErrors: true });
|
|
293
286
|
this.pipelineCounter += 1;
|
|
294
287
|
this.pipelinePromises.set(pipeline, pipelinePromise);
|
|
295
288
|
this.activePipeline = null;
|
|
@@ -297,7 +290,11 @@ var AutoPipelineExecutor = class {
|
|
|
297
290
|
return this.pipelinePromises.get(pipeline);
|
|
298
291
|
});
|
|
299
292
|
const results = await pipelineDone;
|
|
300
|
-
|
|
293
|
+
const commandResult = results[index];
|
|
294
|
+
if (commandResult.error) {
|
|
295
|
+
throw new UpstashError(`Command failed: ${commandResult.error}`);
|
|
296
|
+
}
|
|
297
|
+
return commandResult.result;
|
|
301
298
|
}
|
|
302
299
|
async deferExecution() {
|
|
303
300
|
await Promise.resolve();
|
|
@@ -2228,9 +2225,9 @@ var Pipeline = class {
|
|
|
2228
2225
|
this.multiExec = opts.multiExec ?? false;
|
|
2229
2226
|
if (this.commandOptions?.latencyLogging) {
|
|
2230
2227
|
const originalExec = this.exec.bind(this);
|
|
2231
|
-
this.exec = async () => {
|
|
2228
|
+
this.exec = async (options) => {
|
|
2232
2229
|
const start = performance.now();
|
|
2233
|
-
const result = await originalExec();
|
|
2230
|
+
const result = await (options ? originalExec(options) : originalExec());
|
|
2234
2231
|
const end = performance.now();
|
|
2235
2232
|
const loggerResult = (end - start).toFixed(2);
|
|
2236
2233
|
console.log(
|
|
@@ -2240,19 +2237,7 @@ var Pipeline = class {
|
|
|
2240
2237
|
};
|
|
2241
2238
|
}
|
|
2242
2239
|
}
|
|
2243
|
-
|
|
2244
|
-
* Send the pipeline request to upstash.
|
|
2245
|
-
*
|
|
2246
|
-
* Returns an array with the results of all pipelined commands.
|
|
2247
|
-
*
|
|
2248
|
-
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
2249
|
-
* ```ts
|
|
2250
|
-
* const p = redis.pipeline()
|
|
2251
|
-
* p.get("key")
|
|
2252
|
-
* const result = p.exec<[{ greeting: string }]>()
|
|
2253
|
-
* ```
|
|
2254
|
-
*/
|
|
2255
|
-
exec = async () => {
|
|
2240
|
+
exec = async (options) => {
|
|
2256
2241
|
if (this.commands.length === 0) {
|
|
2257
2242
|
throw new Error("Pipeline is empty");
|
|
2258
2243
|
}
|
|
@@ -2261,7 +2246,12 @@ var Pipeline = class {
|
|
|
2261
2246
|
path,
|
|
2262
2247
|
body: Object.values(this.commands).map((c) => c.command)
|
|
2263
2248
|
});
|
|
2264
|
-
return res.map(({ error, result }, i) => {
|
|
2249
|
+
return options?.keepErrors ? res.map(({ error, result }, i) => {
|
|
2250
|
+
return {
|
|
2251
|
+
error,
|
|
2252
|
+
result: this.commands[i].deserialize(result)
|
|
2253
|
+
};
|
|
2254
|
+
}) : res.map(({ error, result }, i) => {
|
|
2265
2255
|
if (error) {
|
|
2266
2256
|
throw new UpstashError(
|
|
2267
2257
|
`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
|
|
@@ -3861,22 +3851,20 @@ var Redis2 = class _Redis extends Redis {
|
|
|
3861
3851
|
return;
|
|
3862
3852
|
}
|
|
3863
3853
|
if (!configOrRequester.url) {
|
|
3864
|
-
|
|
3854
|
+
throw new Error(
|
|
3865
3855
|
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
|
|
3866
3856
|
);
|
|
3867
|
-
} else if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
|
|
3868
|
-
console.warn(
|
|
3869
|
-
"[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
|
|
3870
|
-
);
|
|
3871
3857
|
}
|
|
3872
3858
|
if (!configOrRequester.token) {
|
|
3873
|
-
|
|
3859
|
+
throw new Error(
|
|
3874
3860
|
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
|
|
3875
3861
|
);
|
|
3876
|
-
}
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3862
|
+
}
|
|
3863
|
+
if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
|
|
3864
|
+
console.warn("The redis url contains whitespace or newline, which can cause errors!");
|
|
3865
|
+
}
|
|
3866
|
+
if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
|
|
3867
|
+
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
3880
3868
|
}
|
|
3881
3869
|
const client = new HttpClient({
|
|
3882
3870
|
baseUrl: configOrRequester.url,
|
|
@@ -3919,18 +3907,16 @@ var Redis2 = class _Redis extends Redis {
|
|
|
3919
3907
|
static fromEnv(config) {
|
|
3920
3908
|
if (process.env === void 0) {
|
|
3921
3909
|
throw new TypeError(
|
|
3922
|
-
'
|
|
3910
|
+
'Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
|
|
3923
3911
|
);
|
|
3924
3912
|
}
|
|
3925
|
-
const url = process.env.UPSTASH_REDIS_REST_URL;
|
|
3913
|
+
const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
|
|
3926
3914
|
if (!url) {
|
|
3927
|
-
|
|
3915
|
+
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
|
|
3928
3916
|
}
|
|
3929
|
-
const token = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
3917
|
+
const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
|
|
3930
3918
|
if (!token) {
|
|
3931
|
-
|
|
3932
|
-
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
|
|
3933
|
-
);
|
|
3919
|
+
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
|
|
3934
3920
|
}
|
|
3935
3921
|
return new _Redis({ ...config, url, token });
|
|
3936
3922
|
}
|
package/nodejs.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Redis,
|
|
4
4
|
VERSION,
|
|
5
5
|
error_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YGIPCDY3.mjs";
|
|
7
7
|
|
|
8
8
|
// platforms/nodejs.ts
|
|
9
9
|
if (typeof atob === "undefined") {
|
|
@@ -33,22 +33,20 @@ var Redis2 = class _Redis extends Redis {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
if (!configOrRequester.url) {
|
|
36
|
-
|
|
36
|
+
throw new Error(
|
|
37
37
|
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
|
|
38
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
39
|
}
|
|
44
40
|
if (!configOrRequester.token) {
|
|
45
|
-
|
|
41
|
+
throw new Error(
|
|
46
42
|
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
|
|
47
43
|
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
}
|
|
45
|
+
if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
|
|
46
|
+
console.warn("The redis url contains whitespace or newline, which can cause errors!");
|
|
47
|
+
}
|
|
48
|
+
if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
|
|
49
|
+
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
52
50
|
}
|
|
53
51
|
const client = new HttpClient({
|
|
54
52
|
baseUrl: configOrRequester.url,
|
|
@@ -91,18 +89,16 @@ var Redis2 = class _Redis extends Redis {
|
|
|
91
89
|
static fromEnv(config) {
|
|
92
90
|
if (process.env === void 0) {
|
|
93
91
|
throw new TypeError(
|
|
94
|
-
'
|
|
92
|
+
'Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
|
|
95
93
|
);
|
|
96
94
|
}
|
|
97
|
-
const url = process.env.UPSTASH_REDIS_REST_URL;
|
|
95
|
+
const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
|
|
98
96
|
if (!url) {
|
|
99
|
-
|
|
97
|
+
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
|
|
100
98
|
}
|
|
101
|
-
const token = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
99
|
+
const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
|
|
102
100
|
if (!token) {
|
|
103
|
-
|
|
104
|
-
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
|
|
105
|
-
);
|
|
101
|
+
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
|
|
106
102
|
}
|
|
107
103
|
return new _Redis({ ...config, url, token });
|
|
108
104
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/redis","version":"v0.0.0-ci.
|
|
1
|
+
{"name":"@upstash/redis","version":"v0.0.0-ci.ef1ca9829e359ba31196db06ff1da80cd201974b-20241009150255","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"}}
|
|
@@ -1602,6 +1602,39 @@ declare class ZScoreCommand<TData> extends Command<string | null, number | null>
|
|
|
1602
1602
|
type InferResponseData<T extends unknown[]> = {
|
|
1603
1603
|
[K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
|
|
1604
1604
|
};
|
|
1605
|
+
interface ExecMethod<TCommands extends Command<any, any>[]> {
|
|
1606
|
+
/**
|
|
1607
|
+
* Send the pipeline request to upstash.
|
|
1608
|
+
*
|
|
1609
|
+
* Returns an array with the results of all pipelined commands.
|
|
1610
|
+
*
|
|
1611
|
+
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
1612
|
+
* ```ts
|
|
1613
|
+
* const p = redis.pipeline()
|
|
1614
|
+
* p.get("key")
|
|
1615
|
+
* const result = p.exec<[{ greeting: string }]>()
|
|
1616
|
+
* ```
|
|
1617
|
+
*
|
|
1618
|
+
* If one of the commands get an error, the whole pipeline fails. Alternatively, you can set the keepErrors option to true in order to get the errors individually.
|
|
1619
|
+
*
|
|
1620
|
+
* If keepErrors is set to true, a list of objects is returned where each object corresponds to a command and is of type: `{ result: unknown, error?: string }`.
|
|
1621
|
+
*
|
|
1622
|
+
* ```ts
|
|
1623
|
+
* const p = redis.pipeline()
|
|
1624
|
+
* p.get("key")
|
|
1625
|
+
*
|
|
1626
|
+
* const result = await p.exec({ keepErrors: true });
|
|
1627
|
+
* const getResult = result[0].result
|
|
1628
|
+
* const getError = result[0].error
|
|
1629
|
+
* ```
|
|
1630
|
+
*/
|
|
1631
|
+
<TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(): Promise<TCommandResults>;
|
|
1632
|
+
<TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(options: {
|
|
1633
|
+
keepErrors: true;
|
|
1634
|
+
}): Promise<{
|
|
1635
|
+
[K in keyof TCommandResults]: UpstashResponse<TCommandResults[K]>;
|
|
1636
|
+
}>;
|
|
1637
|
+
}
|
|
1605
1638
|
/**
|
|
1606
1639
|
* Upstash REST API supports command pipelining to send multiple commands in
|
|
1607
1640
|
* batch, instead of sending each command one by one and waiting for a response.
|
|
@@ -1650,19 +1683,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1650
1683
|
commandOptions?: CommandOptions<any, any>;
|
|
1651
1684
|
multiExec?: boolean;
|
|
1652
1685
|
});
|
|
1653
|
-
|
|
1654
|
-
* Send the pipeline request to upstash.
|
|
1655
|
-
*
|
|
1656
|
-
* Returns an array with the results of all pipelined commands.
|
|
1657
|
-
*
|
|
1658
|
-
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
1659
|
-
* ```ts
|
|
1660
|
-
* const p = redis.pipeline()
|
|
1661
|
-
* p.get("key")
|
|
1662
|
-
* const result = p.exec<[{ greeting: string }]>()
|
|
1663
|
-
* ```
|
|
1664
|
-
*/
|
|
1665
|
-
exec: <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>() => Promise<TCommandResults>;
|
|
1686
|
+
exec: ExecMethod<TCommands>;
|
|
1666
1687
|
/**
|
|
1667
1688
|
* Returns the length of pipeline before the execution
|
|
1668
1689
|
*/
|
|
@@ -1602,6 +1602,39 @@ declare class ZScoreCommand<TData> extends Command<string | null, number | null>
|
|
|
1602
1602
|
type InferResponseData<T extends unknown[]> = {
|
|
1603
1603
|
[K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
|
|
1604
1604
|
};
|
|
1605
|
+
interface ExecMethod<TCommands extends Command<any, any>[]> {
|
|
1606
|
+
/**
|
|
1607
|
+
* Send the pipeline request to upstash.
|
|
1608
|
+
*
|
|
1609
|
+
* Returns an array with the results of all pipelined commands.
|
|
1610
|
+
*
|
|
1611
|
+
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
1612
|
+
* ```ts
|
|
1613
|
+
* const p = redis.pipeline()
|
|
1614
|
+
* p.get("key")
|
|
1615
|
+
* const result = p.exec<[{ greeting: string }]>()
|
|
1616
|
+
* ```
|
|
1617
|
+
*
|
|
1618
|
+
* If one of the commands get an error, the whole pipeline fails. Alternatively, you can set the keepErrors option to true in order to get the errors individually.
|
|
1619
|
+
*
|
|
1620
|
+
* If keepErrors is set to true, a list of objects is returned where each object corresponds to a command and is of type: `{ result: unknown, error?: string }`.
|
|
1621
|
+
*
|
|
1622
|
+
* ```ts
|
|
1623
|
+
* const p = redis.pipeline()
|
|
1624
|
+
* p.get("key")
|
|
1625
|
+
*
|
|
1626
|
+
* const result = await p.exec({ keepErrors: true });
|
|
1627
|
+
* const getResult = result[0].result
|
|
1628
|
+
* const getError = result[0].error
|
|
1629
|
+
* ```
|
|
1630
|
+
*/
|
|
1631
|
+
<TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(): Promise<TCommandResults>;
|
|
1632
|
+
<TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(options: {
|
|
1633
|
+
keepErrors: true;
|
|
1634
|
+
}): Promise<{
|
|
1635
|
+
[K in keyof TCommandResults]: UpstashResponse<TCommandResults[K]>;
|
|
1636
|
+
}>;
|
|
1637
|
+
}
|
|
1605
1638
|
/**
|
|
1606
1639
|
* Upstash REST API supports command pipelining to send multiple commands in
|
|
1607
1640
|
* batch, instead of sending each command one by one and waiting for a response.
|
|
@@ -1650,19 +1683,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1650
1683
|
commandOptions?: CommandOptions<any, any>;
|
|
1651
1684
|
multiExec?: boolean;
|
|
1652
1685
|
});
|
|
1653
|
-
|
|
1654
|
-
* Send the pipeline request to upstash.
|
|
1655
|
-
*
|
|
1656
|
-
* Returns an array with the results of all pipelined commands.
|
|
1657
|
-
*
|
|
1658
|
-
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
1659
|
-
* ```ts
|
|
1660
|
-
* const p = redis.pipeline()
|
|
1661
|
-
* p.get("key")
|
|
1662
|
-
* const result = p.exec<[{ greeting: string }]>()
|
|
1663
|
-
* ```
|
|
1664
|
-
*/
|
|
1665
|
-
exec: <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>() => Promise<TCommandResults>;
|
|
1686
|
+
exec: ExecMethod<TCommands>;
|
|
1666
1687
|
/**
|
|
1667
1688
|
* Returns the length of pipeline before the execution
|
|
1668
1689
|
*/
|