@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.
@@ -46,7 +46,7 @@ var HttpClient = class {
46
46
  };
47
47
  this.upstashSyncToken = "";
48
48
  this.readYourWrites = config.readYourWrites ?? true;
49
- this.baseUrl = config.baseUrl.replace(/\/$/, "");
49
+ this.baseUrl = (config.baseUrl || "").replace(/\/$/, "");
50
50
  const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
51
51
  if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
52
52
  throw new UrlError(this.baseUrl);
@@ -88,7 +88,7 @@ var HttpClient = class {
88
88
  backend: this.options.backend
89
89
  };
90
90
  if (!this.hasCredentials) {
91
- throw new Error(
91
+ console.warn(
92
92
  "[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
93
93
  );
94
94
  }
@@ -115,7 +115,9 @@ var HttpClient = class {
115
115
  break;
116
116
  }
117
117
  error = error_;
118
- await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
118
+ if (i < this.retry.attempts) {
119
+ await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
120
+ }
119
121
  }
120
122
  }
121
123
  if (!res) {
@@ -446,6 +448,14 @@ var EvalshaCommand = class extends Command {
446
448
  }
447
449
  };
448
450
 
451
+ // pkg/commands/exec.ts
452
+ var ExecCommand = class extends Command {
453
+ constructor(cmd, opts) {
454
+ const normalizedCmd = cmd.map((arg) => typeof arg === "string" ? arg : String(arg));
455
+ super(normalizedCmd, opts);
456
+ }
457
+ };
458
+
449
459
  // pkg/commands/exists.ts
450
460
  var ExistsCommand = class extends Command {
451
461
  constructor(cmd, opts) {
@@ -662,6 +672,27 @@ var GetDelCommand = class extends Command {
662
672
  }
663
673
  };
664
674
 
675
+ // pkg/commands/getex.ts
676
+ var GetExCommand = class extends Command {
677
+ constructor([key, opts], cmdOpts) {
678
+ const command = ["getex", key];
679
+ if (opts) {
680
+ if ("ex" in opts && typeof opts.ex === "number") {
681
+ command.push("ex", opts.ex);
682
+ } else if ("px" in opts && typeof opts.px === "number") {
683
+ command.push("px", opts.px);
684
+ } else if ("exat" in opts && typeof opts.exat === "number") {
685
+ command.push("exat", opts.exat);
686
+ } else if ("pxat" in opts && typeof opts.pxat === "number") {
687
+ command.push("pxat", opts.pxat);
688
+ } else if ("persist" in opts && opts.persist) {
689
+ command.push("persist");
690
+ }
691
+ }
692
+ super(command, cmdOpts);
693
+ }
694
+ };
695
+
665
696
  // pkg/commands/getrange.ts
666
697
  var GetRangeCommand = class extends Command {
667
698
  constructor(cmd, opts) {
@@ -2122,9 +2153,9 @@ var Pipeline = class {
2122
2153
  this.multiExec = opts.multiExec ?? false;
2123
2154
  if (this.commandOptions?.latencyLogging) {
2124
2155
  const originalExec = this.exec.bind(this);
2125
- this.exec = async () => {
2156
+ this.exec = async (options) => {
2126
2157
  const start = performance.now();
2127
- const result = await originalExec();
2158
+ const result = await (options ? originalExec(options) : originalExec());
2128
2159
  const end = performance.now();
2129
2160
  const loggerResult = (end - start).toFixed(2);
2130
2161
  console.log(
@@ -2134,19 +2165,7 @@ var Pipeline = class {
2134
2165
  };
2135
2166
  }
2136
2167
  }
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 () => {
2168
+ exec = async (options) => {
2150
2169
  if (this.commands.length === 0) {
2151
2170
  throw new Error("Pipeline is empty");
2152
2171
  }
@@ -2155,7 +2174,12 @@ var Pipeline = class {
2155
2174
  path,
2156
2175
  body: Object.values(this.commands).map((c) => c.command)
2157
2176
  });
2158
- return res.map(({ error, result }, i) => {
2177
+ return options?.keepErrors ? res.map(({ error, result }, i) => {
2178
+ return {
2179
+ error,
2180
+ result: this.commands[i].deserialize(result)
2181
+ };
2182
+ }) : res.map(({ error, result }, i) => {
2159
2183
  if (error) {
2160
2184
  throw new UpstashError(
2161
2185
  `Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
@@ -2305,6 +2329,10 @@ var Pipeline = class {
2305
2329
  * @see https://redis.io/commands/getdel
2306
2330
  */
2307
2331
  getdel = (...args) => this.chain(new GetDelCommand(args, this.commandOptions));
2332
+ /**
2333
+ * @see https://redis.io/commands/getex
2334
+ */
2335
+ getex = (...args) => this.chain(new GetExCommand(args, this.commandOptions));
2308
2336
  /**
2309
2337
  * @see https://redis.io/commands/getrange
2310
2338
  */
@@ -2949,7 +2977,7 @@ var AutoPipelineExecutor = class {
2949
2977
  executeWithPipeline(pipeline);
2950
2978
  const pipelineDone = this.deferExecution().then(() => {
2951
2979
  if (!this.pipelinePromises.has(pipeline)) {
2952
- const pipelinePromise = pipeline.exec();
2980
+ const pipelinePromise = pipeline.exec({ keepErrors: true });
2953
2981
  this.pipelineCounter += 1;
2954
2982
  this.pipelinePromises.set(pipeline, pipelinePromise);
2955
2983
  this.activePipeline = null;
@@ -2957,7 +2985,11 @@ var AutoPipelineExecutor = class {
2957
2985
  return this.pipelinePromises.get(pipeline);
2958
2986
  });
2959
2987
  const results = await pipelineDone;
2960
- return results[index];
2988
+ const commandResult = results[index];
2989
+ if (commandResult.error) {
2990
+ throw new UpstashError(`Command failed: ${commandResult.error}`);
2991
+ }
2992
+ return commandResult.result;
2961
2993
  }
2962
2994
  async deferExecution() {
2963
2995
  await Promise.resolve();
@@ -3251,6 +3283,10 @@ var Redis = class {
3251
3283
  * @see https://redis.io/commands/evalsha
3252
3284
  */
3253
3285
  evalsha = (...args) => new EvalshaCommand(args, this.opts).exec(this.client);
3286
+ /**
3287
+ * Generic method to execute any Redis command.
3288
+ */
3289
+ exec = (args) => new ExecCommand(args, this.opts).exec(this.client);
3254
3290
  /**
3255
3291
  * @see https://redis.io/commands/exists
3256
3292
  */
@@ -3307,6 +3343,10 @@ var Redis = class {
3307
3343
  * @see https://redis.io/commands/getdel
3308
3344
  */
3309
3345
  getdel = (...args) => new GetDelCommand(args, this.opts).exec(this.client);
3346
+ /**
3347
+ * @see https://redis.io/commands/getex
3348
+ */
3349
+ getex = (...args) => new GetExCommand(args, this.opts).exec(this.client);
3310
3350
  /**
3311
3351
  * @see https://redis.io/commands/getrange
3312
3352
  */
@@ -3800,7 +3840,7 @@ var Redis = class {
3800
3840
  };
3801
3841
 
3802
3842
  // version.ts
3803
- var VERSION = "1.34.3-canary-2";
3843
+ var VERSION = "v1.34.4";
3804
3844
 
3805
3845
  export {
3806
3846
  error_exports,
package/cloudflare.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-BLgYk16R.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-BLgYk16R.mjs';
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
  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-BLgYk16R.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-BLgYk16R.js';
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
  type Env = {
5
5
  UPSTASH_DISABLE_TELEMETRY?: string;
package/cloudflare.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
- throw new Error(
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
- await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
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
- return results[index];
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 = "1.34.3-canary-2";
3874
+ var VERSION = "v1.34.4";
3835
3875
 
3836
3876
  // platforms/cloudflare.ts
3837
3877
  var Redis2 = class _Redis extends Redis {
package/cloudflare.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-2YMDVZBQ.mjs";
6
+ } from "./chunk-T6D4KAGH.mjs";
7
7
 
8
8
  // platforms/cloudflare.ts
9
9
  var Redis2 = class _Redis extends Redis {
package/fastly.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-BLgYk16R.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-BLgYk16R.mjs';
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/fastly.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-BLgYk16R.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-BLgYk16R.js';
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/fastly.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
- throw new Error(
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
- await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
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
- return results[index];
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 = "1.34.3-canary-2";
3874
+ var VERSION = "v1.34.4";
3835
3875
 
3836
3876
  // platforms/fastly.ts
3837
3877
  var Redis2 = class extends Redis {