@upstash/redis 1.34.3-canary-2 → 1.34.4
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-2YMDVZBQ.mjs → chunk-T6D4KAGH.mjs} +62 -22
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +62 -22
- package/cloudflare.mjs +1 -1
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +62 -22
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +2 -2
- package/nodejs.d.ts +2 -2
- package/nodejs.js +64 -24
- package/nodejs.mjs +3 -3
- package/package.json +1 -1
- package/{zmscore-BLgYk16R.d.mts → zmscore-C3G81zLz.d.mts} +163 -14
- package/{zmscore-BLgYk16R.d.ts → zmscore-C3G81zLz.d.ts} +163 -14
package/fastly.mjs
CHANGED
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
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-C3G81zLz.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 GetExCommand, I as GetRangeCommand, J as GetSetCommand, K as HDelCommand, L as HExistsCommand, N as HGetAllCommand, M as HGetCommand, O as HIncrByCommand, Q as HIncrByFloatCommand, S as HKeysCommand, T as HLenCommand, V as HMGetCommand, W as HMSetCommand, X as HRandFieldCommand, Y as HScanCommand, Z as HSetCommand, _ as HSetNXCommand, $ as HStrLenCommand, a0 as HValsCommand, a2 as IncrByCommand, a3 as IncrByFloatCommand, a1 as IncrCommand, a4 as JsonArrAppendCommand, a5 as JsonArrIndexCommand, a6 as JsonArrInsertCommand, a7 as JsonArrLenCommand, a8 as JsonArrPopCommand, a9 as JsonArrTrimCommand, aa as JsonClearCommand, ab as JsonDelCommand, ac as JsonForgetCommand, ad as JsonGetCommand, ae as JsonMGetCommand, af as JsonNumIncrByCommand, ag as JsonNumMultByCommand, ah as JsonObjKeysCommand, ai as JsonObjLenCommand, aj as JsonRespCommand, ak as JsonSetCommand, al as JsonStrAppendCommand, am as JsonStrLenCommand, an as JsonToggleCommand, ao as JsonTypeCommand, ap as KeysCommand, aq as LIndexCommand, ar as LInsertCommand, as as LLenCommand, at as LMoveCommand, au as LPopCommand, av as LPushCommand, aw as LPushXCommand, ax as LRangeCommand, ay as LRemCommand, az as LSetCommand, aA as LTrimCommand, aB as MGetCommand, aC as MSetCommand, aD as MSetNXCommand, aG as PExpireAtCommand, aF as PExpireCommand, aI as PSetEXCommand, aJ as PTtlCommand, aE as PersistCommand, aH as PingCommand, P as Pipeline, aK as PublishCommand, aO as RPopCommand, aP as RPushCommand, aQ as RPushXCommand, aL as RandomKeyCommand, aM as RenameCommand, aN as RenameNXCommand, d as Requester, aR as SAddCommand, aU as SCardCommand, aY as SDiffCommand, aZ as SDiffStoreCommand, b4 as SInterCommand, b5 as SInterStoreCommand, b6 as SIsMemberCommand, b8 as SMIsMemberCommand, b7 as SMembersCommand, b9 as SMoveCommand, ba as SPopCommand, bb as SRandMemberCommand, bc as SRemCommand, bd as SScanCommand, bf as SUnionCommand, bg as SUnionStoreCommand, aS as ScanCommand, aT as ScanCommandOptions, bp as ScoreMember, aV as ScriptExistsCommand, aW as ScriptFlushCommand, aX as ScriptLoadCommand, b0 as SetBitCommand, a_ as SetCommand, a$ as SetCommandOptions, b1 as SetExCommand, b2 as SetNxCommand, b3 as SetRangeCommand, be as StrLenCommand, bh as TimeCommand, bi as TouchCommand, bj as TtlCommand, bk as Type, bl as TypeCommand, bm as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bn as XAddCommand, bo as XRangeCommand, br as ZAddCommand, bq as ZAddCommandOptions, bs as ZCardCommand, bt as ZCountCommand, bu as ZDiffStoreCommand, bv as ZIncrByCommand, bw as ZInterStoreCommand, bx as ZInterStoreCommandOptions, by as ZLexCountCommand, bz as ZMScoreCommand, bA as ZPopMaxCommand, bB as ZPopMinCommand, bC as ZRangeCommand, bD as ZRangeCommandOptions, bE as ZRankCommand, bF as ZRemCommand, bG as ZRemRangeByLexCommand, bH as ZRemRangeByRankCommand, bI as ZRemRangeByScoreCommand, bJ as ZRevRankCommand, bK as ZScanCommand, bL as ZScoreCommand, bM as ZUnionCommand, bN as ZUnionCommandOptions, bO as ZUnionStoreCommand, bP as ZUnionStoreCommandOptions, e as errors } from './zmscore-C3G81zLz.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
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-C3G81zLz.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 GetExCommand, I as GetRangeCommand, J as GetSetCommand, K as HDelCommand, L as HExistsCommand, N as HGetAllCommand, M as HGetCommand, O as HIncrByCommand, Q as HIncrByFloatCommand, S as HKeysCommand, T as HLenCommand, V as HMGetCommand, W as HMSetCommand, X as HRandFieldCommand, Y as HScanCommand, Z as HSetCommand, _ as HSetNXCommand, $ as HStrLenCommand, a0 as HValsCommand, a2 as IncrByCommand, a3 as IncrByFloatCommand, a1 as IncrCommand, a4 as JsonArrAppendCommand, a5 as JsonArrIndexCommand, a6 as JsonArrInsertCommand, a7 as JsonArrLenCommand, a8 as JsonArrPopCommand, a9 as JsonArrTrimCommand, aa as JsonClearCommand, ab as JsonDelCommand, ac as JsonForgetCommand, ad as JsonGetCommand, ae as JsonMGetCommand, af as JsonNumIncrByCommand, ag as JsonNumMultByCommand, ah as JsonObjKeysCommand, ai as JsonObjLenCommand, aj as JsonRespCommand, ak as JsonSetCommand, al as JsonStrAppendCommand, am as JsonStrLenCommand, an as JsonToggleCommand, ao as JsonTypeCommand, ap as KeysCommand, aq as LIndexCommand, ar as LInsertCommand, as as LLenCommand, at as LMoveCommand, au as LPopCommand, av as LPushCommand, aw as LPushXCommand, ax as LRangeCommand, ay as LRemCommand, az as LSetCommand, aA as LTrimCommand, aB as MGetCommand, aC as MSetCommand, aD as MSetNXCommand, aG as PExpireAtCommand, aF as PExpireCommand, aI as PSetEXCommand, aJ as PTtlCommand, aE as PersistCommand, aH as PingCommand, P as Pipeline, aK as PublishCommand, aO as RPopCommand, aP as RPushCommand, aQ as RPushXCommand, aL as RandomKeyCommand, aM as RenameCommand, aN as RenameNXCommand, d as Requester, aR as SAddCommand, aU as SCardCommand, aY as SDiffCommand, aZ as SDiffStoreCommand, b4 as SInterCommand, b5 as SInterStoreCommand, b6 as SIsMemberCommand, b8 as SMIsMemberCommand, b7 as SMembersCommand, b9 as SMoveCommand, ba as SPopCommand, bb as SRandMemberCommand, bc as SRemCommand, bd as SScanCommand, bf as SUnionCommand, bg as SUnionStoreCommand, aS as ScanCommand, aT as ScanCommandOptions, bp as ScoreMember, aV as ScriptExistsCommand, aW as ScriptFlushCommand, aX as ScriptLoadCommand, b0 as SetBitCommand, a_ as SetCommand, a$ as SetCommandOptions, b1 as SetExCommand, b2 as SetNxCommand, b3 as SetRangeCommand, be as StrLenCommand, bh as TimeCommand, bi as TouchCommand, bj as TtlCommand, bk as Type, bl as TypeCommand, bm as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bn as XAddCommand, bo as XRangeCommand, br as ZAddCommand, bq as ZAddCommandOptions, bs as ZCardCommand, bt as ZCountCommand, bu as ZDiffStoreCommand, bv as ZIncrByCommand, bw as ZInterStoreCommand, bx as ZInterStoreCommandOptions, by as ZLexCountCommand, bz as ZMScoreCommand, bA as ZPopMaxCommand, bB as ZPopMinCommand, bC as ZRangeCommand, bD as ZRangeCommandOptions, bE as ZRankCommand, bF as ZRemCommand, bG as ZRemRangeByLexCommand, bH as ZRemRangeByRankCommand, bI as ZRemRangeByScoreCommand, bJ as ZRevRankCommand, bK as ZScanCommand, bL as ZScoreCommand, bM as ZUnionCommand, bN as ZUnionCommandOptions, bO as ZUnionStoreCommand, bP as ZUnionStoreCommandOptions, e as errors } from './zmscore-C3G81zLz.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Connection credentials for upstash redis.
|
package/nodejs.js
CHANGED
|
@@ -77,7 +77,7 @@ var HttpClient = class {
|
|
|
77
77
|
};
|
|
78
78
|
this.upstashSyncToken = "";
|
|
79
79
|
this.readYourWrites = config.readYourWrites ?? true;
|
|
80
|
-
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
80
|
+
this.baseUrl = (config.baseUrl || "").replace(/\/$/, "");
|
|
81
81
|
const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
|
|
82
82
|
if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
|
|
83
83
|
throw new UrlError(this.baseUrl);
|
|
@@ -119,7 +119,7 @@ var HttpClient = class {
|
|
|
119
119
|
backend: this.options.backend
|
|
120
120
|
};
|
|
121
121
|
if (!this.hasCredentials) {
|
|
122
|
-
|
|
122
|
+
console.warn(
|
|
123
123
|
"[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
|
|
124
124
|
);
|
|
125
125
|
}
|
|
@@ -146,7 +146,9 @@ var HttpClient = class {
|
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
error = error_;
|
|
149
|
-
|
|
149
|
+
if (i < this.retry.attempts) {
|
|
150
|
+
await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
|
|
151
|
+
}
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
if (!res) {
|
|
@@ -289,7 +291,7 @@ var AutoPipelineExecutor = class {
|
|
|
289
291
|
executeWithPipeline(pipeline);
|
|
290
292
|
const pipelineDone = this.deferExecution().then(() => {
|
|
291
293
|
if (!this.pipelinePromises.has(pipeline)) {
|
|
292
|
-
const pipelinePromise = pipeline.exec();
|
|
294
|
+
const pipelinePromise = pipeline.exec({ keepErrors: true });
|
|
293
295
|
this.pipelineCounter += 1;
|
|
294
296
|
this.pipelinePromises.set(pipeline, pipelinePromise);
|
|
295
297
|
this.activePipeline = null;
|
|
@@ -297,7 +299,11 @@ var AutoPipelineExecutor = class {
|
|
|
297
299
|
return this.pipelinePromises.get(pipeline);
|
|
298
300
|
});
|
|
299
301
|
const results = await pipelineDone;
|
|
300
|
-
|
|
302
|
+
const commandResult = results[index];
|
|
303
|
+
if (commandResult.error) {
|
|
304
|
+
throw new UpstashError(`Command failed: ${commandResult.error}`);
|
|
305
|
+
}
|
|
306
|
+
return commandResult.result;
|
|
301
307
|
}
|
|
302
308
|
async deferExecution() {
|
|
303
309
|
await Promise.resolve();
|
|
@@ -518,6 +524,14 @@ var EvalshaCommand = class extends Command {
|
|
|
518
524
|
}
|
|
519
525
|
};
|
|
520
526
|
|
|
527
|
+
// pkg/commands/exec.ts
|
|
528
|
+
var ExecCommand = class extends Command {
|
|
529
|
+
constructor(cmd, opts) {
|
|
530
|
+
const normalizedCmd = cmd.map((arg) => typeof arg === "string" ? arg : String(arg));
|
|
531
|
+
super(normalizedCmd, opts);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
521
535
|
// pkg/commands/exists.ts
|
|
522
536
|
var ExistsCommand = class extends Command {
|
|
523
537
|
constructor(cmd, opts) {
|
|
@@ -734,6 +748,27 @@ var GetDelCommand = class extends Command {
|
|
|
734
748
|
}
|
|
735
749
|
};
|
|
736
750
|
|
|
751
|
+
// pkg/commands/getex.ts
|
|
752
|
+
var GetExCommand = class extends Command {
|
|
753
|
+
constructor([key, opts], cmdOpts) {
|
|
754
|
+
const command = ["getex", key];
|
|
755
|
+
if (opts) {
|
|
756
|
+
if ("ex" in opts && typeof opts.ex === "number") {
|
|
757
|
+
command.push("ex", opts.ex);
|
|
758
|
+
} else if ("px" in opts && typeof opts.px === "number") {
|
|
759
|
+
command.push("px", opts.px);
|
|
760
|
+
} else if ("exat" in opts && typeof opts.exat === "number") {
|
|
761
|
+
command.push("exat", opts.exat);
|
|
762
|
+
} else if ("pxat" in opts && typeof opts.pxat === "number") {
|
|
763
|
+
command.push("pxat", opts.pxat);
|
|
764
|
+
} else if ("persist" in opts && opts.persist) {
|
|
765
|
+
command.push("persist");
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
super(command, cmdOpts);
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
|
|
737
772
|
// pkg/commands/getrange.ts
|
|
738
773
|
var GetRangeCommand = class extends Command {
|
|
739
774
|
constructor(cmd, opts) {
|
|
@@ -2228,9 +2263,9 @@ var Pipeline = class {
|
|
|
2228
2263
|
this.multiExec = opts.multiExec ?? false;
|
|
2229
2264
|
if (this.commandOptions?.latencyLogging) {
|
|
2230
2265
|
const originalExec = this.exec.bind(this);
|
|
2231
|
-
this.exec = async () => {
|
|
2266
|
+
this.exec = async (options) => {
|
|
2232
2267
|
const start = performance.now();
|
|
2233
|
-
const result = await originalExec();
|
|
2268
|
+
const result = await (options ? originalExec(options) : originalExec());
|
|
2234
2269
|
const end = performance.now();
|
|
2235
2270
|
const loggerResult = (end - start).toFixed(2);
|
|
2236
2271
|
console.log(
|
|
@@ -2240,19 +2275,7 @@ var Pipeline = class {
|
|
|
2240
2275
|
};
|
|
2241
2276
|
}
|
|
2242
2277
|
}
|
|
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 () => {
|
|
2278
|
+
exec = async (options) => {
|
|
2256
2279
|
if (this.commands.length === 0) {
|
|
2257
2280
|
throw new Error("Pipeline is empty");
|
|
2258
2281
|
}
|
|
@@ -2261,7 +2284,12 @@ var Pipeline = class {
|
|
|
2261
2284
|
path,
|
|
2262
2285
|
body: Object.values(this.commands).map((c) => c.command)
|
|
2263
2286
|
});
|
|
2264
|
-
return res.map(({ error, result }, i) => {
|
|
2287
|
+
return options?.keepErrors ? res.map(({ error, result }, i) => {
|
|
2288
|
+
return {
|
|
2289
|
+
error,
|
|
2290
|
+
result: this.commands[i].deserialize(result)
|
|
2291
|
+
};
|
|
2292
|
+
}) : res.map(({ error, result }, i) => {
|
|
2265
2293
|
if (error) {
|
|
2266
2294
|
throw new UpstashError(
|
|
2267
2295
|
`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
|
|
@@ -2411,6 +2439,10 @@ var Pipeline = class {
|
|
|
2411
2439
|
* @see https://redis.io/commands/getdel
|
|
2412
2440
|
*/
|
|
2413
2441
|
getdel = (...args) => this.chain(new GetDelCommand(args, this.commandOptions));
|
|
2442
|
+
/**
|
|
2443
|
+
* @see https://redis.io/commands/getex
|
|
2444
|
+
*/
|
|
2445
|
+
getex = (...args) => this.chain(new GetExCommand(args, this.commandOptions));
|
|
2414
2446
|
/**
|
|
2415
2447
|
* @see https://redis.io/commands/getrange
|
|
2416
2448
|
*/
|
|
@@ -3282,6 +3314,10 @@ var Redis = class {
|
|
|
3282
3314
|
* @see https://redis.io/commands/evalsha
|
|
3283
3315
|
*/
|
|
3284
3316
|
evalsha = (...args) => new EvalshaCommand(args, this.opts).exec(this.client);
|
|
3317
|
+
/**
|
|
3318
|
+
* Generic method to execute any Redis command.
|
|
3319
|
+
*/
|
|
3320
|
+
exec = (args) => new ExecCommand(args, this.opts).exec(this.client);
|
|
3285
3321
|
/**
|
|
3286
3322
|
* @see https://redis.io/commands/exists
|
|
3287
3323
|
*/
|
|
@@ -3338,6 +3374,10 @@ var Redis = class {
|
|
|
3338
3374
|
* @see https://redis.io/commands/getdel
|
|
3339
3375
|
*/
|
|
3340
3376
|
getdel = (...args) => new GetDelCommand(args, this.opts).exec(this.client);
|
|
3377
|
+
/**
|
|
3378
|
+
* @see https://redis.io/commands/getex
|
|
3379
|
+
*/
|
|
3380
|
+
getex = (...args) => new GetExCommand(args, this.opts).exec(this.client);
|
|
3341
3381
|
/**
|
|
3342
3382
|
* @see https://redis.io/commands/getrange
|
|
3343
3383
|
*/
|
|
@@ -3831,7 +3871,7 @@ var Redis = class {
|
|
|
3831
3871
|
};
|
|
3832
3872
|
|
|
3833
3873
|
// version.ts
|
|
3834
|
-
var VERSION = "
|
|
3874
|
+
var VERSION = "v1.34.4";
|
|
3835
3875
|
|
|
3836
3876
|
// platforms/nodejs.ts
|
|
3837
3877
|
if (typeof atob === "undefined") {
|
|
@@ -3922,11 +3962,11 @@ var Redis2 = class _Redis extends Redis {
|
|
|
3922
3962
|
'[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
|
|
3923
3963
|
);
|
|
3924
3964
|
}
|
|
3925
|
-
const url = process.env.UPSTASH_REDIS_REST_URL;
|
|
3965
|
+
const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
|
|
3926
3966
|
if (!url) {
|
|
3927
3967
|
console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
|
|
3928
3968
|
}
|
|
3929
|
-
const token = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
3969
|
+
const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
|
|
3930
3970
|
if (!token) {
|
|
3931
3971
|
console.warn(
|
|
3932
3972
|
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
|
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-T6D4KAGH.mjs";
|
|
7
7
|
|
|
8
8
|
// platforms/nodejs.ts
|
|
9
9
|
if (typeof atob === "undefined") {
|
|
@@ -94,11 +94,11 @@ var Redis2 = class _Redis extends Redis {
|
|
|
94
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
95
|
);
|
|
96
96
|
}
|
|
97
|
-
const url = process.env.UPSTASH_REDIS_REST_URL;
|
|
97
|
+
const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
|
|
98
98
|
if (!url) {
|
|
99
99
|
console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
|
|
100
100
|
}
|
|
101
|
-
const token = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
101
|
+
const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
|
|
102
102
|
if (!token) {
|
|
103
103
|
console.warn(
|
|
104
104
|
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/redis","version":"
|
|
1
|
+
{"name":"@upstash/redis","version":"v1.34.4","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"}}
|
|
@@ -563,6 +563,50 @@ declare class GetDelCommand<TData = string> extends Command<unknown | null, TDat
|
|
|
563
563
|
constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
|
|
564
564
|
}
|
|
565
565
|
|
|
566
|
+
type GetExCommandOptions = {
|
|
567
|
+
ex: number;
|
|
568
|
+
px?: never;
|
|
569
|
+
exat?: never;
|
|
570
|
+
pxat?: never;
|
|
571
|
+
persist?: never;
|
|
572
|
+
} | {
|
|
573
|
+
ex?: never;
|
|
574
|
+
px: number;
|
|
575
|
+
exat?: never;
|
|
576
|
+
pxat?: never;
|
|
577
|
+
persist?: never;
|
|
578
|
+
} | {
|
|
579
|
+
ex?: never;
|
|
580
|
+
px?: never;
|
|
581
|
+
exat: number;
|
|
582
|
+
pxat?: never;
|
|
583
|
+
persist?: never;
|
|
584
|
+
} | {
|
|
585
|
+
ex?: never;
|
|
586
|
+
px?: never;
|
|
587
|
+
exat?: never;
|
|
588
|
+
pxat: number;
|
|
589
|
+
persist?: never;
|
|
590
|
+
} | {
|
|
591
|
+
ex?: never;
|
|
592
|
+
px?: never;
|
|
593
|
+
exat?: never;
|
|
594
|
+
pxat?: never;
|
|
595
|
+
persist: true;
|
|
596
|
+
} | {
|
|
597
|
+
ex?: never;
|
|
598
|
+
px?: never;
|
|
599
|
+
exat?: never;
|
|
600
|
+
pxat?: never;
|
|
601
|
+
persist?: never;
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* @see https://redis.io/commands/getex
|
|
605
|
+
*/
|
|
606
|
+
declare class GetExCommand<TData = string> extends Command<unknown | null, TData | null> {
|
|
607
|
+
constructor([key, opts]: [key: string, opts?: GetExCommandOptions], cmdOpts?: CommandOptions<unknown | null, TData | null>);
|
|
608
|
+
}
|
|
609
|
+
|
|
566
610
|
/**
|
|
567
611
|
* @see https://redis.io/commands/getrange
|
|
568
612
|
*/
|
|
@@ -1602,6 +1646,39 @@ declare class ZScoreCommand<TData> extends Command<string | null, number | null>
|
|
|
1602
1646
|
type InferResponseData<T extends unknown[]> = {
|
|
1603
1647
|
[K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
|
|
1604
1648
|
};
|
|
1649
|
+
interface ExecMethod<TCommands extends Command<any, any>[]> {
|
|
1650
|
+
/**
|
|
1651
|
+
* Send the pipeline request to upstash.
|
|
1652
|
+
*
|
|
1653
|
+
* Returns an array with the results of all pipelined commands.
|
|
1654
|
+
*
|
|
1655
|
+
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
1656
|
+
* ```ts
|
|
1657
|
+
* const p = redis.pipeline()
|
|
1658
|
+
* p.get("key")
|
|
1659
|
+
* const result = p.exec<[{ greeting: string }]>()
|
|
1660
|
+
* ```
|
|
1661
|
+
*
|
|
1662
|
+
* 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.
|
|
1663
|
+
*
|
|
1664
|
+
* 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 }`.
|
|
1665
|
+
*
|
|
1666
|
+
* ```ts
|
|
1667
|
+
* const p = redis.pipeline()
|
|
1668
|
+
* p.get("key")
|
|
1669
|
+
*
|
|
1670
|
+
* const result = await p.exec({ keepErrors: true });
|
|
1671
|
+
* const getResult = result[0].result
|
|
1672
|
+
* const getError = result[0].error
|
|
1673
|
+
* ```
|
|
1674
|
+
*/
|
|
1675
|
+
<TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(): Promise<TCommandResults>;
|
|
1676
|
+
<TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(options: {
|
|
1677
|
+
keepErrors: true;
|
|
1678
|
+
}): Promise<{
|
|
1679
|
+
[K in keyof TCommandResults]: UpstashResponse<TCommandResults[K]>;
|
|
1680
|
+
}>;
|
|
1681
|
+
}
|
|
1605
1682
|
/**
|
|
1606
1683
|
* Upstash REST API supports command pipelining to send multiple commands in
|
|
1607
1684
|
* batch, instead of sending each command one by one and waiting for a response.
|
|
@@ -1650,19 +1727,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1650
1727
|
commandOptions?: CommandOptions<any, any>;
|
|
1651
1728
|
multiExec?: boolean;
|
|
1652
1729
|
});
|
|
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>;
|
|
1730
|
+
exec: ExecMethod<TCommands>;
|
|
1666
1731
|
/**
|
|
1667
1732
|
* Returns the length of pipeline before the execution
|
|
1668
1733
|
*/
|
|
@@ -1870,6 +1935,46 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1870
1935
|
* @see https://redis.io/commands/getdel
|
|
1871
1936
|
*/
|
|
1872
1937
|
getdel: <TData>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
|
|
1938
|
+
/**
|
|
1939
|
+
* @see https://redis.io/commands/getex
|
|
1940
|
+
*/
|
|
1941
|
+
getex: <TData>(key: string, opts?: ({
|
|
1942
|
+
ex: number;
|
|
1943
|
+
px?: never;
|
|
1944
|
+
exat?: never;
|
|
1945
|
+
pxat?: never;
|
|
1946
|
+
persist?: never;
|
|
1947
|
+
} | {
|
|
1948
|
+
ex?: never;
|
|
1949
|
+
px: number;
|
|
1950
|
+
exat?: never;
|
|
1951
|
+
pxat?: never;
|
|
1952
|
+
persist?: never;
|
|
1953
|
+
} | {
|
|
1954
|
+
ex?: never;
|
|
1955
|
+
px?: never;
|
|
1956
|
+
exat: number;
|
|
1957
|
+
pxat?: never;
|
|
1958
|
+
persist?: never;
|
|
1959
|
+
} | {
|
|
1960
|
+
ex?: never;
|
|
1961
|
+
px?: never;
|
|
1962
|
+
exat?: never;
|
|
1963
|
+
pxat: number;
|
|
1964
|
+
persist?: never;
|
|
1965
|
+
} | {
|
|
1966
|
+
ex?: never;
|
|
1967
|
+
px?: never;
|
|
1968
|
+
exat?: never;
|
|
1969
|
+
pxat?: never;
|
|
1970
|
+
persist: true;
|
|
1971
|
+
} | {
|
|
1972
|
+
ex?: never;
|
|
1973
|
+
px?: never;
|
|
1974
|
+
exat?: never;
|
|
1975
|
+
pxat?: never;
|
|
1976
|
+
persist?: never;
|
|
1977
|
+
}) | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
|
|
1873
1978
|
/**
|
|
1874
1979
|
* @see https://redis.io/commands/getrange
|
|
1875
1980
|
*/
|
|
@@ -2771,6 +2876,10 @@ declare class Redis {
|
|
|
2771
2876
|
* @see https://redis.io/commands/evalsha
|
|
2772
2877
|
*/
|
|
2773
2878
|
evalsha: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Promise<TData>;
|
|
2879
|
+
/**
|
|
2880
|
+
* Generic method to execute any Redis command.
|
|
2881
|
+
*/
|
|
2882
|
+
exec: <TResult>(args: [command: string, ...args: (string | number | boolean)[]]) => Promise<TResult>;
|
|
2774
2883
|
/**
|
|
2775
2884
|
* @see https://redis.io/commands/exists
|
|
2776
2885
|
*/
|
|
@@ -2895,6 +3004,46 @@ declare class Redis {
|
|
|
2895
3004
|
* @see https://redis.io/commands/getdel
|
|
2896
3005
|
*/
|
|
2897
3006
|
getdel: <TData>(key: string) => Promise<TData | null>;
|
|
3007
|
+
/**
|
|
3008
|
+
* @see https://redis.io/commands/getex
|
|
3009
|
+
*/
|
|
3010
|
+
getex: <TData>(key: string, opts?: ({
|
|
3011
|
+
ex: number;
|
|
3012
|
+
px?: never;
|
|
3013
|
+
exat?: never;
|
|
3014
|
+
pxat?: never;
|
|
3015
|
+
persist?: never;
|
|
3016
|
+
} | {
|
|
3017
|
+
ex?: never;
|
|
3018
|
+
px: number;
|
|
3019
|
+
exat?: never;
|
|
3020
|
+
pxat?: never;
|
|
3021
|
+
persist?: never;
|
|
3022
|
+
} | {
|
|
3023
|
+
ex?: never;
|
|
3024
|
+
px?: never;
|
|
3025
|
+
exat: number;
|
|
3026
|
+
pxat?: never;
|
|
3027
|
+
persist?: never;
|
|
3028
|
+
} | {
|
|
3029
|
+
ex?: never;
|
|
3030
|
+
px?: never;
|
|
3031
|
+
exat?: never;
|
|
3032
|
+
pxat: number;
|
|
3033
|
+
persist?: never;
|
|
3034
|
+
} | {
|
|
3035
|
+
ex?: never;
|
|
3036
|
+
px?: never;
|
|
3037
|
+
exat?: never;
|
|
3038
|
+
pxat?: never;
|
|
3039
|
+
persist: true;
|
|
3040
|
+
} | {
|
|
3041
|
+
ex?: never;
|
|
3042
|
+
px?: never;
|
|
3043
|
+
exat?: never;
|
|
3044
|
+
pxat?: never;
|
|
3045
|
+
persist?: never;
|
|
3046
|
+
}) | undefined) => Promise<TData | null>;
|
|
2898
3047
|
/**
|
|
2899
3048
|
* @see https://redis.io/commands/getrange
|
|
2900
3049
|
*/
|
|
@@ -3485,4 +3634,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
|
|
|
3485
3634
|
constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
|
|
3486
3635
|
}
|
|
3487
3636
|
|
|
3488
|
-
export {
|
|
3637
|
+
export { HStrLenCommand as $, AppendCommand as A, BitCountCommand as B, CopyCommand as C, DBSizeCommand as D, EchoCommand as E, FlushAllCommand as F, GeoAddCommand as G, GetExCommand as H, GetRangeCommand as I, GetSetCommand as J, HDelCommand as K, HExistsCommand as L, HGetCommand as M, HGetAllCommand as N, HIncrByCommand as O, Pipeline as P, HIncrByFloatCommand as Q, type RedisOptions as R, HKeysCommand as S, HLenCommand as T, type UpstashRequest as U, HMGetCommand as V, HMSetCommand as W, HRandFieldCommand as X, HScanCommand as Y, HSetCommand as Z, HSetNXCommand as _, type RequesterConfig as a, type SetCommandOptions as a$, HValsCommand as a0, IncrCommand as a1, IncrByCommand as a2, IncrByFloatCommand as a3, JsonArrAppendCommand as a4, JsonArrIndexCommand as a5, JsonArrInsertCommand as a6, JsonArrLenCommand as a7, JsonArrPopCommand as a8, JsonArrTrimCommand as a9, LTrimCommand as aA, MGetCommand as aB, MSetCommand as aC, MSetNXCommand as aD, PersistCommand as aE, PExpireCommand as aF, PExpireAtCommand as aG, PingCommand as aH, PSetEXCommand as aI, PTtlCommand as aJ, PublishCommand as aK, RandomKeyCommand as aL, RenameCommand as aM, RenameNXCommand as aN, RPopCommand as aO, RPushCommand as aP, RPushXCommand as aQ, SAddCommand as aR, ScanCommand as aS, type ScanCommandOptions as aT, SCardCommand as aU, ScriptExistsCommand as aV, ScriptFlushCommand as aW, ScriptLoadCommand as aX, SDiffCommand as aY, SDiffStoreCommand as aZ, SetCommand as a_, JsonClearCommand as aa, JsonDelCommand as ab, JsonForgetCommand as ac, JsonGetCommand as ad, JsonMGetCommand as ae, JsonNumIncrByCommand as af, JsonNumMultByCommand as ag, JsonObjKeysCommand as ah, JsonObjLenCommand as ai, JsonRespCommand as aj, JsonSetCommand as ak, JsonStrAppendCommand as al, JsonStrLenCommand as am, JsonToggleCommand as an, JsonTypeCommand as ao, KeysCommand as ap, LIndexCommand as aq, LInsertCommand as ar, LLenCommand as as, LMoveCommand as at, LPopCommand as au, LPushCommand as av, LPushXCommand as aw, LRangeCommand as ax, LRemCommand as ay, LSetCommand as az, Redis as b, SetBitCommand as b0, SetExCommand as b1, SetNxCommand as b2, SetRangeCommand as b3, SInterCommand as b4, SInterStoreCommand as b5, SIsMemberCommand as b6, SMembersCommand as b7, SMIsMemberCommand as b8, SMoveCommand as b9, ZPopMaxCommand as bA, ZPopMinCommand as bB, ZRangeCommand as bC, type ZRangeCommandOptions as bD, ZRankCommand as bE, ZRemCommand as bF, ZRemRangeByLexCommand as bG, ZRemRangeByRankCommand as bH, ZRemRangeByScoreCommand as bI, ZRevRankCommand as bJ, ZScanCommand as bK, ZScoreCommand as bL, ZUnionCommand as bM, type ZUnionCommandOptions as bN, ZUnionStoreCommand as bO, type ZUnionStoreCommandOptions as bP, SPopCommand as ba, SRandMemberCommand as bb, SRemCommand as bc, SScanCommand as bd, StrLenCommand as be, SUnionCommand as bf, SUnionStoreCommand as bg, TimeCommand as bh, TouchCommand as bi, TtlCommand as bj, type Type as bk, TypeCommand as bl, UnlinkCommand as bm, XAddCommand as bn, XRangeCommand as bo, type ScoreMember as bp, type ZAddCommandOptions as bq, ZAddCommand as br, ZCardCommand as bs, ZCountCommand as bt, ZDiffStoreCommand as bu, ZIncrByCommand as bv, ZInterStoreCommand as bw, type ZInterStoreCommandOptions as bx, ZLexCountCommand as by, ZMScoreCommand as bz, type UpstashResponse as c, type Requester as d, error as e, BitOpCommand as f, BitPosCommand as g, DecrCommand as h, DecrByCommand as i, DelCommand as j, EvalCommand as k, EvalshaCommand as l, ExistsCommand as m, ExpireCommand as n, ExpireAtCommand as o, FlushDBCommand as p, type GeoAddCommandOptions as q, type GeoMember as r, GeoDistCommand as s, GeoHashCommand as t, GeoPosCommand as u, GeoSearchCommand as v, GeoSearchStoreCommand as w, GetCommand as x, GetBitCommand as y, GetDelCommand as z };
|