@upstash/redis 1.34.9 → 1.35.0

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.
@@ -49,6 +49,14 @@ function parseResponse(result) {
49
49
  function deserializeScanResponse(result) {
50
50
  return [result[0], ...parseResponse(result.slice(1))];
51
51
  }
52
+ function deserializeScanWithTypesResponse(result) {
53
+ const [cursor, keys] = result;
54
+ const parsedKeys = [];
55
+ for (let i = 0; i < keys.length; i += 2) {
56
+ parsedKeys.push({ key: keys[i], type: keys[i + 1] });
57
+ }
58
+ return [cursor, parsedKeys];
59
+ }
52
60
  function mergeHeaders(...headers) {
53
61
  const merged = {};
54
62
  for (const header of headers) {
@@ -1540,11 +1548,14 @@ var ScanCommand = class extends Command {
1540
1548
  if (typeof opts?.count === "number") {
1541
1549
  command.push("count", opts.count);
1542
1550
  }
1543
- if (opts?.type && opts.type.length > 0) {
1551
+ if (opts && "withType" in opts && opts.withType === true) {
1552
+ command.push("withtype");
1553
+ } else if (opts && "type" in opts && opts.type && opts.type.length > 0) {
1544
1554
  command.push("type", opts.type);
1545
1555
  }
1546
1556
  super(command, {
1547
- deserialize: deserializeScanResponse,
1557
+ // @ts-expect-error ignore types here
1558
+ deserialize: opts?.withType ? deserializeScanWithTypesResponse : deserializeScanResponse,
1548
1559
  ...cmdOpts
1549
1560
  });
1550
1561
  }
@@ -3450,27 +3461,43 @@ var SubscribeCommand = class extends Command {
3450
3461
  };
3451
3462
 
3452
3463
  // pkg/script.ts
3453
- import Hex from "crypto-js/enc-hex.js";
3454
- import sha1 from "crypto-js/sha1.js";
3464
+ import { subtle } from "uncrypto";
3455
3465
  var Script = class {
3456
3466
  script;
3467
+ /**
3468
+ * @deprecated This property is initialized to an empty string and will be set in the init method
3469
+ * asynchronously. Do not use this property immidiately after the constructor.
3470
+ *
3471
+ * This property is only exposed for backwards compatibility and will be removed in the
3472
+ * future major release.
3473
+ */
3457
3474
  sha1;
3458
3475
  redis;
3459
3476
  constructor(redis, script) {
3460
3477
  this.redis = redis;
3461
- this.sha1 = this.digest(script);
3462
3478
  this.script = script;
3479
+ this.sha1 = "";
3480
+ void this.init(script);
3481
+ }
3482
+ /**
3483
+ * Initialize the script by computing its SHA-1 hash.
3484
+ */
3485
+ async init(script) {
3486
+ if (this.sha1) return;
3487
+ this.sha1 = await this.digest(script);
3463
3488
  }
3464
3489
  /**
3465
3490
  * Send an `EVAL` command to redis.
3466
3491
  */
3467
3492
  async eval(keys, args) {
3493
+ await this.init(this.script);
3468
3494
  return await this.redis.eval(this.script, keys, args);
3469
3495
  }
3470
3496
  /**
3471
3497
  * Calculates the sha1 hash of the script and then calls `EVALSHA`.
3472
3498
  */
3473
3499
  async evalsha(keys, args) {
3500
+ await this.init(this.script);
3474
3501
  return await this.redis.evalsha(this.sha1, keys, args);
3475
3502
  }
3476
3503
  /**
@@ -3480,6 +3507,7 @@ var Script = class {
3480
3507
  * Following calls will be able to use the cached script
3481
3508
  */
3482
3509
  async exec(keys, args) {
3510
+ await this.init(this.script);
3483
3511
  const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
3484
3512
  if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3485
3513
  return await this.redis.eval(this.script, keys, args);
@@ -3491,33 +3519,49 @@ var Script = class {
3491
3519
  /**
3492
3520
  * Compute the sha1 hash of the script and return its hex representation.
3493
3521
  */
3494
- digest(s) {
3495
- return Hex.stringify(sha1(s));
3522
+ async digest(s) {
3523
+ const data = new TextEncoder().encode(s);
3524
+ const hashBuffer = await subtle.digest("SHA-1", data);
3525
+ const hashArray = [...new Uint8Array(hashBuffer)];
3526
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3496
3527
  }
3497
3528
  };
3498
3529
 
3499
3530
  // pkg/scriptRo.ts
3500
- import Hex2 from "crypto-js/enc-hex.js";
3501
- import sha12 from "crypto-js/sha1.js";
3531
+ import { subtle as subtle2 } from "uncrypto";
3502
3532
  var ScriptRO = class {
3503
3533
  script;
3534
+ /**
3535
+ * @deprecated This property is initialized to an empty string and will be set in the init method
3536
+ * asynchronously. Do not use this property immidiately after the constructor.
3537
+ *
3538
+ * This property is only exposed for backwards compatibility and will be removed in the
3539
+ * future major release.
3540
+ */
3504
3541
  sha1;
3505
3542
  redis;
3506
3543
  constructor(redis, script) {
3507
3544
  this.redis = redis;
3508
- this.sha1 = this.digest(script);
3545
+ this.sha1 = "";
3509
3546
  this.script = script;
3547
+ void this.init(script);
3548
+ }
3549
+ async init(script) {
3550
+ if (this.sha1) return;
3551
+ this.sha1 = await this.digest(script);
3510
3552
  }
3511
3553
  /**
3512
3554
  * Send an `EVAL_RO` command to redis.
3513
3555
  */
3514
3556
  async evalRo(keys, args) {
3557
+ await this.init(this.script);
3515
3558
  return await this.redis.evalRo(this.script, keys, args);
3516
3559
  }
3517
3560
  /**
3518
3561
  * Calculates the sha1 hash of the script and then calls `EVALSHA_RO`.
3519
3562
  */
3520
3563
  async evalshaRo(keys, args) {
3564
+ await this.init(this.script);
3521
3565
  return await this.redis.evalshaRo(this.sha1, keys, args);
3522
3566
  }
3523
3567
  /**
@@ -3527,6 +3571,7 @@ var ScriptRO = class {
3527
3571
  * Following calls will be able to use the cached script
3528
3572
  */
3529
3573
  async exec(keys, args) {
3574
+ await this.init(this.script);
3530
3575
  const res = await this.redis.evalshaRo(this.sha1, keys, args).catch(async (error) => {
3531
3576
  if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3532
3577
  return await this.redis.evalRo(this.script, keys, args);
@@ -3538,8 +3583,11 @@ var ScriptRO = class {
3538
3583
  /**
3539
3584
  * Compute the sha1 hash of the script and return its hex representation.
3540
3585
  */
3541
- digest(s) {
3542
- return Hex2.stringify(sha12(s));
3586
+ async digest(s) {
3587
+ const data = new TextEncoder().encode(s);
3588
+ const hashBuffer = await subtle2.digest("SHA-1", data);
3589
+ const hashArray = [...new Uint8Array(hashBuffer)];
3590
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3543
3591
  }
3544
3592
  };
3545
3593
 
@@ -4149,10 +4197,9 @@ var Redis = class {
4149
4197
  * @see https://redis.io/commands/sadd
4150
4198
  */
4151
4199
  sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
4152
- /**
4153
- * @see https://redis.io/commands/scan
4154
- */
4155
- scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
4200
+ scan(cursor, opts) {
4201
+ return new ScanCommand([cursor, opts], this.opts).exec(this.client);
4202
+ }
4156
4203
  /**
4157
4204
  * @see https://redis.io/commands/scard
4158
4205
  */
@@ -4429,7 +4476,7 @@ var Redis = class {
4429
4476
  };
4430
4477
 
4431
4478
  // version.ts
4432
- var VERSION = "v1.34.9";
4479
+ var VERSION = "v1.35.0";
4433
4480
 
4434
4481
  export {
4435
4482
  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-CjoCv9kz.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-CjoCv9kz.mjs';
1
+ import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-DzNHSWxc.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-DzNHSWxc.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-CjoCv9kz.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-CjoCv9kz.js';
1
+ import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-DzNHSWxc.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-DzNHSWxc.js';
3
3
 
4
4
  type Env = {
5
5
  UPSTASH_DISABLE_TELEMETRY?: string;
package/cloudflare.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // platforms/cloudflare.ts
@@ -80,6 +70,14 @@ function parseResponse(result) {
80
70
  function deserializeScanResponse(result) {
81
71
  return [result[0], ...parseResponse(result.slice(1))];
82
72
  }
73
+ function deserializeScanWithTypesResponse(result) {
74
+ const [cursor, keys] = result;
75
+ const parsedKeys = [];
76
+ for (let i = 0; i < keys.length; i += 2) {
77
+ parsedKeys.push({ key: keys[i], type: keys[i + 1] });
78
+ }
79
+ return [cursor, parsedKeys];
80
+ }
83
81
  function mergeHeaders(...headers) {
84
82
  const merged = {};
85
83
  for (const header of headers) {
@@ -1668,11 +1666,14 @@ var ScanCommand = class extends Command {
1668
1666
  if (typeof opts?.count === "number") {
1669
1667
  command.push("count", opts.count);
1670
1668
  }
1671
- if (opts?.type && opts.type.length > 0) {
1669
+ if (opts && "withType" in opts && opts.withType === true) {
1670
+ command.push("withtype");
1671
+ } else if (opts && "type" in opts && opts.type && opts.type.length > 0) {
1672
1672
  command.push("type", opts.type);
1673
1673
  }
1674
1674
  super(command, {
1675
- deserialize: deserializeScanResponse,
1675
+ // @ts-expect-error ignore types here
1676
+ deserialize: opts?.withType ? deserializeScanWithTypesResponse : deserializeScanResponse,
1676
1677
  ...cmdOpts
1677
1678
  });
1678
1679
  }
@@ -3481,27 +3482,43 @@ var Pipeline = class {
3481
3482
  };
3482
3483
 
3483
3484
  // pkg/script.ts
3484
- var import_enc_hex = __toESM(require("crypto-js/enc-hex.js"));
3485
- var import_sha1 = __toESM(require("crypto-js/sha1.js"));
3485
+ var import_uncrypto = require("uncrypto");
3486
3486
  var Script = class {
3487
3487
  script;
3488
+ /**
3489
+ * @deprecated This property is initialized to an empty string and will be set in the init method
3490
+ * asynchronously. Do not use this property immidiately after the constructor.
3491
+ *
3492
+ * This property is only exposed for backwards compatibility and will be removed in the
3493
+ * future major release.
3494
+ */
3488
3495
  sha1;
3489
3496
  redis;
3490
3497
  constructor(redis, script) {
3491
3498
  this.redis = redis;
3492
- this.sha1 = this.digest(script);
3493
3499
  this.script = script;
3500
+ this.sha1 = "";
3501
+ void this.init(script);
3502
+ }
3503
+ /**
3504
+ * Initialize the script by computing its SHA-1 hash.
3505
+ */
3506
+ async init(script) {
3507
+ if (this.sha1) return;
3508
+ this.sha1 = await this.digest(script);
3494
3509
  }
3495
3510
  /**
3496
3511
  * Send an `EVAL` command to redis.
3497
3512
  */
3498
3513
  async eval(keys, args) {
3514
+ await this.init(this.script);
3499
3515
  return await this.redis.eval(this.script, keys, args);
3500
3516
  }
3501
3517
  /**
3502
3518
  * Calculates the sha1 hash of the script and then calls `EVALSHA`.
3503
3519
  */
3504
3520
  async evalsha(keys, args) {
3521
+ await this.init(this.script);
3505
3522
  return await this.redis.evalsha(this.sha1, keys, args);
3506
3523
  }
3507
3524
  /**
@@ -3511,6 +3528,7 @@ var Script = class {
3511
3528
  * Following calls will be able to use the cached script
3512
3529
  */
3513
3530
  async exec(keys, args) {
3531
+ await this.init(this.script);
3514
3532
  const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
3515
3533
  if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3516
3534
  return await this.redis.eval(this.script, keys, args);
@@ -3522,33 +3540,49 @@ var Script = class {
3522
3540
  /**
3523
3541
  * Compute the sha1 hash of the script and return its hex representation.
3524
3542
  */
3525
- digest(s) {
3526
- return import_enc_hex.default.stringify((0, import_sha1.default)(s));
3543
+ async digest(s) {
3544
+ const data = new TextEncoder().encode(s);
3545
+ const hashBuffer = await import_uncrypto.subtle.digest("SHA-1", data);
3546
+ const hashArray = [...new Uint8Array(hashBuffer)];
3547
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3527
3548
  }
3528
3549
  };
3529
3550
 
3530
3551
  // pkg/scriptRo.ts
3531
- var import_enc_hex2 = __toESM(require("crypto-js/enc-hex.js"));
3532
- var import_sha12 = __toESM(require("crypto-js/sha1.js"));
3552
+ var import_uncrypto2 = require("uncrypto");
3533
3553
  var ScriptRO = class {
3534
3554
  script;
3555
+ /**
3556
+ * @deprecated This property is initialized to an empty string and will be set in the init method
3557
+ * asynchronously. Do not use this property immidiately after the constructor.
3558
+ *
3559
+ * This property is only exposed for backwards compatibility and will be removed in the
3560
+ * future major release.
3561
+ */
3535
3562
  sha1;
3536
3563
  redis;
3537
3564
  constructor(redis, script) {
3538
3565
  this.redis = redis;
3539
- this.sha1 = this.digest(script);
3566
+ this.sha1 = "";
3540
3567
  this.script = script;
3568
+ void this.init(script);
3569
+ }
3570
+ async init(script) {
3571
+ if (this.sha1) return;
3572
+ this.sha1 = await this.digest(script);
3541
3573
  }
3542
3574
  /**
3543
3575
  * Send an `EVAL_RO` command to redis.
3544
3576
  */
3545
3577
  async evalRo(keys, args) {
3578
+ await this.init(this.script);
3546
3579
  return await this.redis.evalRo(this.script, keys, args);
3547
3580
  }
3548
3581
  /**
3549
3582
  * Calculates the sha1 hash of the script and then calls `EVALSHA_RO`.
3550
3583
  */
3551
3584
  async evalshaRo(keys, args) {
3585
+ await this.init(this.script);
3552
3586
  return await this.redis.evalshaRo(this.sha1, keys, args);
3553
3587
  }
3554
3588
  /**
@@ -3558,6 +3592,7 @@ var ScriptRO = class {
3558
3592
  * Following calls will be able to use the cached script
3559
3593
  */
3560
3594
  async exec(keys, args) {
3595
+ await this.init(this.script);
3561
3596
  const res = await this.redis.evalshaRo(this.sha1, keys, args).catch(async (error) => {
3562
3597
  if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3563
3598
  return await this.redis.evalRo(this.script, keys, args);
@@ -3569,8 +3604,11 @@ var ScriptRO = class {
3569
3604
  /**
3570
3605
  * Compute the sha1 hash of the script and return its hex representation.
3571
3606
  */
3572
- digest(s) {
3573
- return import_enc_hex2.default.stringify((0, import_sha12.default)(s));
3607
+ async digest(s) {
3608
+ const data = new TextEncoder().encode(s);
3609
+ const hashBuffer = await import_uncrypto2.subtle.digest("SHA-1", data);
3610
+ const hashArray = [...new Uint8Array(hashBuffer)];
3611
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3574
3612
  }
3575
3613
  };
3576
3614
 
@@ -4180,10 +4218,9 @@ var Redis = class {
4180
4218
  * @see https://redis.io/commands/sadd
4181
4219
  */
4182
4220
  sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
4183
- /**
4184
- * @see https://redis.io/commands/scan
4185
- */
4186
- scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
4221
+ scan(cursor, opts) {
4222
+ return new ScanCommand([cursor, opts], this.opts).exec(this.client);
4223
+ }
4187
4224
  /**
4188
4225
  * @see https://redis.io/commands/scard
4189
4226
  */
@@ -4460,7 +4497,7 @@ var Redis = class {
4460
4497
  };
4461
4498
 
4462
4499
  // version.ts
4463
- var VERSION = "v1.34.9";
4500
+ var VERSION = "v1.35.0";
4464
4501
 
4465
4502
  // platforms/cloudflare.ts
4466
4503
  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-TZPYH7UX.mjs";
6
+ } from "./chunk-QZ3IMTW7.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-CjoCv9kz.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-CjoCv9kz.mjs';
1
+ import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-DzNHSWxc.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-DzNHSWxc.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-CjoCv9kz.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-CjoCv9kz.js';
1
+ import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-DzNHSWxc.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-DzNHSWxc.js';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash redis.
package/fastly.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // platforms/fastly.ts
@@ -80,6 +70,14 @@ function parseResponse(result) {
80
70
  function deserializeScanResponse(result) {
81
71
  return [result[0], ...parseResponse(result.slice(1))];
82
72
  }
73
+ function deserializeScanWithTypesResponse(result) {
74
+ const [cursor, keys] = result;
75
+ const parsedKeys = [];
76
+ for (let i = 0; i < keys.length; i += 2) {
77
+ parsedKeys.push({ key: keys[i], type: keys[i + 1] });
78
+ }
79
+ return [cursor, parsedKeys];
80
+ }
83
81
  function mergeHeaders(...headers) {
84
82
  const merged = {};
85
83
  for (const header of headers) {
@@ -1668,11 +1666,14 @@ var ScanCommand = class extends Command {
1668
1666
  if (typeof opts?.count === "number") {
1669
1667
  command.push("count", opts.count);
1670
1668
  }
1671
- if (opts?.type && opts.type.length > 0) {
1669
+ if (opts && "withType" in opts && opts.withType === true) {
1670
+ command.push("withtype");
1671
+ } else if (opts && "type" in opts && opts.type && opts.type.length > 0) {
1672
1672
  command.push("type", opts.type);
1673
1673
  }
1674
1674
  super(command, {
1675
- deserialize: deserializeScanResponse,
1675
+ // @ts-expect-error ignore types here
1676
+ deserialize: opts?.withType ? deserializeScanWithTypesResponse : deserializeScanResponse,
1676
1677
  ...cmdOpts
1677
1678
  });
1678
1679
  }
@@ -3481,27 +3482,43 @@ var Pipeline = class {
3481
3482
  };
3482
3483
 
3483
3484
  // pkg/script.ts
3484
- var import_enc_hex = __toESM(require("crypto-js/enc-hex.js"));
3485
- var import_sha1 = __toESM(require("crypto-js/sha1.js"));
3485
+ var import_uncrypto = require("uncrypto");
3486
3486
  var Script = class {
3487
3487
  script;
3488
+ /**
3489
+ * @deprecated This property is initialized to an empty string and will be set in the init method
3490
+ * asynchronously. Do not use this property immidiately after the constructor.
3491
+ *
3492
+ * This property is only exposed for backwards compatibility and will be removed in the
3493
+ * future major release.
3494
+ */
3488
3495
  sha1;
3489
3496
  redis;
3490
3497
  constructor(redis, script) {
3491
3498
  this.redis = redis;
3492
- this.sha1 = this.digest(script);
3493
3499
  this.script = script;
3500
+ this.sha1 = "";
3501
+ void this.init(script);
3502
+ }
3503
+ /**
3504
+ * Initialize the script by computing its SHA-1 hash.
3505
+ */
3506
+ async init(script) {
3507
+ if (this.sha1) return;
3508
+ this.sha1 = await this.digest(script);
3494
3509
  }
3495
3510
  /**
3496
3511
  * Send an `EVAL` command to redis.
3497
3512
  */
3498
3513
  async eval(keys, args) {
3514
+ await this.init(this.script);
3499
3515
  return await this.redis.eval(this.script, keys, args);
3500
3516
  }
3501
3517
  /**
3502
3518
  * Calculates the sha1 hash of the script and then calls `EVALSHA`.
3503
3519
  */
3504
3520
  async evalsha(keys, args) {
3521
+ await this.init(this.script);
3505
3522
  return await this.redis.evalsha(this.sha1, keys, args);
3506
3523
  }
3507
3524
  /**
@@ -3511,6 +3528,7 @@ var Script = class {
3511
3528
  * Following calls will be able to use the cached script
3512
3529
  */
3513
3530
  async exec(keys, args) {
3531
+ await this.init(this.script);
3514
3532
  const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
3515
3533
  if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3516
3534
  return await this.redis.eval(this.script, keys, args);
@@ -3522,33 +3540,49 @@ var Script = class {
3522
3540
  /**
3523
3541
  * Compute the sha1 hash of the script and return its hex representation.
3524
3542
  */
3525
- digest(s) {
3526
- return import_enc_hex.default.stringify((0, import_sha1.default)(s));
3543
+ async digest(s) {
3544
+ const data = new TextEncoder().encode(s);
3545
+ const hashBuffer = await import_uncrypto.subtle.digest("SHA-1", data);
3546
+ const hashArray = [...new Uint8Array(hashBuffer)];
3547
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3527
3548
  }
3528
3549
  };
3529
3550
 
3530
3551
  // pkg/scriptRo.ts
3531
- var import_enc_hex2 = __toESM(require("crypto-js/enc-hex.js"));
3532
- var import_sha12 = __toESM(require("crypto-js/sha1.js"));
3552
+ var import_uncrypto2 = require("uncrypto");
3533
3553
  var ScriptRO = class {
3534
3554
  script;
3555
+ /**
3556
+ * @deprecated This property is initialized to an empty string and will be set in the init method
3557
+ * asynchronously. Do not use this property immidiately after the constructor.
3558
+ *
3559
+ * This property is only exposed for backwards compatibility and will be removed in the
3560
+ * future major release.
3561
+ */
3535
3562
  sha1;
3536
3563
  redis;
3537
3564
  constructor(redis, script) {
3538
3565
  this.redis = redis;
3539
- this.sha1 = this.digest(script);
3566
+ this.sha1 = "";
3540
3567
  this.script = script;
3568
+ void this.init(script);
3569
+ }
3570
+ async init(script) {
3571
+ if (this.sha1) return;
3572
+ this.sha1 = await this.digest(script);
3541
3573
  }
3542
3574
  /**
3543
3575
  * Send an `EVAL_RO` command to redis.
3544
3576
  */
3545
3577
  async evalRo(keys, args) {
3578
+ await this.init(this.script);
3546
3579
  return await this.redis.evalRo(this.script, keys, args);
3547
3580
  }
3548
3581
  /**
3549
3582
  * Calculates the sha1 hash of the script and then calls `EVALSHA_RO`.
3550
3583
  */
3551
3584
  async evalshaRo(keys, args) {
3585
+ await this.init(this.script);
3552
3586
  return await this.redis.evalshaRo(this.sha1, keys, args);
3553
3587
  }
3554
3588
  /**
@@ -3558,6 +3592,7 @@ var ScriptRO = class {
3558
3592
  * Following calls will be able to use the cached script
3559
3593
  */
3560
3594
  async exec(keys, args) {
3595
+ await this.init(this.script);
3561
3596
  const res = await this.redis.evalshaRo(this.sha1, keys, args).catch(async (error) => {
3562
3597
  if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3563
3598
  return await this.redis.evalRo(this.script, keys, args);
@@ -3569,8 +3604,11 @@ var ScriptRO = class {
3569
3604
  /**
3570
3605
  * Compute the sha1 hash of the script and return its hex representation.
3571
3606
  */
3572
- digest(s) {
3573
- return import_enc_hex2.default.stringify((0, import_sha12.default)(s));
3607
+ async digest(s) {
3608
+ const data = new TextEncoder().encode(s);
3609
+ const hashBuffer = await import_uncrypto2.subtle.digest("SHA-1", data);
3610
+ const hashArray = [...new Uint8Array(hashBuffer)];
3611
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3574
3612
  }
3575
3613
  };
3576
3614
 
@@ -4180,10 +4218,9 @@ var Redis = class {
4180
4218
  * @see https://redis.io/commands/sadd
4181
4219
  */
4182
4220
  sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
4183
- /**
4184
- * @see https://redis.io/commands/scan
4185
- */
4186
- scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
4221
+ scan(cursor, opts) {
4222
+ return new ScanCommand([cursor, opts], this.opts).exec(this.client);
4223
+ }
4187
4224
  /**
4188
4225
  * @see https://redis.io/commands/scard
4189
4226
  */
@@ -4460,7 +4497,7 @@ var Redis = class {
4460
4497
  };
4461
4498
 
4462
4499
  // version.ts
4463
- var VERSION = "v1.34.9";
4500
+ var VERSION = "v1.35.0";
4464
4501
 
4465
4502
  // platforms/fastly.ts
4466
4503
  var Redis2 = class extends Redis {
package/fastly.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-TZPYH7UX.mjs";
6
+ } from "./chunk-QZ3IMTW7.mjs";
7
7
 
8
8
  // platforms/fastly.ts
9
9
  var Redis2 = class extends Redis {
package/nodejs.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-CjoCv9kz.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-CjoCv9kz.mjs';
1
+ import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-DzNHSWxc.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-DzNHSWxc.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-CjoCv9kz.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-CjoCv9kz.js';
1
+ import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './zmscore-DzNHSWxc.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, l as EvalCommand, k as EvalROCommand, n as EvalshaCommand, m as EvalshaROCommand, o as ExistsCommand, r as ExpireAtCommand, p as ExpireCommand, q as ExpireOption, F as FlushAllCommand, s as FlushDBCommand, G as GeoAddCommand, t as GeoAddCommandOptions, v as GeoDistCommand, w as GeoHashCommand, u as GeoMember, x as GeoPosCommand, y as GeoSearchCommand, z as GeoSearchStoreCommand, I as GetBitCommand, H as GetCommand, J as GetDelCommand, K as GetExCommand, L as GetRangeCommand, M as GetSetCommand, N as HDelCommand, O as HExistsCommand, S as HExpireAtCommand, Q as HExpireCommand, T as HExpireTimeCommand, a0 as HGetAllCommand, $ as HGetCommand, a1 as HIncrByCommand, a2 as HIncrByFloatCommand, a3 as HKeysCommand, a4 as HLenCommand, a5 as HMGetCommand, a6 as HMSetCommand, X as HPExpireAtCommand, W as HPExpireCommand, Y as HPExpireTimeCommand, Z as HPTtlCommand, _ as HPersistCommand, a7 as HRandFieldCommand, a8 as HScanCommand, a9 as HSetCommand, aa as HSetNXCommand, ab as HStrLenCommand, V as HTtlCommand, ac as HValsCommand, ae as IncrByCommand, af as IncrByFloatCommand, ad as IncrCommand, ag as JsonArrAppendCommand, ah as JsonArrIndexCommand, ai as JsonArrInsertCommand, aj as JsonArrLenCommand, ak as JsonArrPopCommand, al as JsonArrTrimCommand, am as JsonClearCommand, an as JsonDelCommand, ao as JsonForgetCommand, ap as JsonGetCommand, ar as JsonMGetCommand, aq as JsonMergeCommand, as as JsonNumIncrByCommand, at as JsonNumMultByCommand, au as JsonObjKeysCommand, av as JsonObjLenCommand, aw as JsonRespCommand, ax as JsonSetCommand, ay as JsonStrAppendCommand, az as JsonStrLenCommand, aA as JsonToggleCommand, aB as JsonTypeCommand, aC as KeysCommand, aD as LIndexCommand, aE as LInsertCommand, aF as LLenCommand, aG as LMoveCommand, aH as LPopCommand, aI as LPushCommand, aJ as LPushXCommand, aK as LRangeCommand, aL as LRemCommand, aM as LSetCommand, aN as LTrimCommand, aO as MGetCommand, aP as MSetCommand, aQ as MSetNXCommand, aT as PExpireAtCommand, aS as PExpireCommand, aV as PSetEXCommand, aW as PTtlCommand, aR as PersistCommand, aU as PingCommand, P as Pipeline, aX as PublishCommand, a$ as RPopCommand, b0 as RPushCommand, b1 as RPushXCommand, aY as RandomKeyCommand, aZ as RenameCommand, a_ as RenameNXCommand, d as Requester, b2 as SAddCommand, b5 as SCardCommand, b9 as SDiffCommand, ba as SDiffStoreCommand, bh as SInterCommand, bi as SInterStoreCommand, bj as SIsMemberCommand, bl as SMIsMemberCommand, bk as SMembersCommand, bm as SMoveCommand, bn as SPopCommand, bo as SRandMemberCommand, bp as SRemCommand, bq as SScanCommand, bs as SUnionCommand, bt as SUnionStoreCommand, b3 as ScanCommand, b4 as ScanCommandOptions, bC as ScoreMember, b6 as ScriptExistsCommand, b7 as ScriptFlushCommand, b8 as ScriptLoadCommand, bd as SetBitCommand, bb as SetCommand, bc as SetCommandOptions, be as SetExCommand, bf as SetNxCommand, bg as SetRangeCommand, br as StrLenCommand, bu as TimeCommand, bv as TouchCommand, bw as TtlCommand, bx as Type, by as TypeCommand, bz as UnlinkCommand, U as UpstashRequest, c as UpstashResponse, bA as XAddCommand, bB as XRangeCommand, bE as ZAddCommand, bD as ZAddCommandOptions, bF as ZCardCommand, bG as ZCountCommand, bH as ZDiffStoreCommand, bI as ZIncrByCommand, bJ as ZInterStoreCommand, bK as ZInterStoreCommandOptions, bL as ZLexCountCommand, bM as ZMScoreCommand, bN as ZPopMaxCommand, bO as ZPopMinCommand, bP as ZRangeCommand, bQ as ZRangeCommandOptions, bR as ZRankCommand, bS as ZRemCommand, bT as ZRemRangeByLexCommand, bU as ZRemRangeByRankCommand, bV as ZRemRangeByScoreCommand, bW as ZRevRankCommand, bX as ZScanCommand, bY as ZScoreCommand, bZ as ZUnionCommand, b_ as ZUnionCommandOptions, b$ as ZUnionStoreCommand, c0 as ZUnionStoreCommandOptions, e as errors } from './zmscore-DzNHSWxc.js';
3
3
 
4
4
  /**
5
5
  * Connection credentials for upstash redis.
package/nodejs.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // platforms/nodejs.ts
@@ -80,6 +70,14 @@ function parseResponse(result) {
80
70
  function deserializeScanResponse(result) {
81
71
  return [result[0], ...parseResponse(result.slice(1))];
82
72
  }
73
+ function deserializeScanWithTypesResponse(result) {
74
+ const [cursor, keys] = result;
75
+ const parsedKeys = [];
76
+ for (let i = 0; i < keys.length; i += 2) {
77
+ parsedKeys.push({ key: keys[i], type: keys[i + 1] });
78
+ }
79
+ return [cursor, parsedKeys];
80
+ }
83
81
  function mergeHeaders(...headers) {
84
82
  const merged = {};
85
83
  for (const header of headers) {
@@ -1668,11 +1666,14 @@ var ScanCommand = class extends Command {
1668
1666
  if (typeof opts?.count === "number") {
1669
1667
  command.push("count", opts.count);
1670
1668
  }
1671
- if (opts?.type && opts.type.length > 0) {
1669
+ if (opts && "withType" in opts && opts.withType === true) {
1670
+ command.push("withtype");
1671
+ } else if (opts && "type" in opts && opts.type && opts.type.length > 0) {
1672
1672
  command.push("type", opts.type);
1673
1673
  }
1674
1674
  super(command, {
1675
- deserialize: deserializeScanResponse,
1675
+ // @ts-expect-error ignore types here
1676
+ deserialize: opts?.withType ? deserializeScanWithTypesResponse : deserializeScanResponse,
1676
1677
  ...cmdOpts
1677
1678
  });
1678
1679
  }
@@ -3481,27 +3482,43 @@ var Pipeline = class {
3481
3482
  };
3482
3483
 
3483
3484
  // pkg/script.ts
3484
- var import_enc_hex = __toESM(require("crypto-js/enc-hex.js"));
3485
- var import_sha1 = __toESM(require("crypto-js/sha1.js"));
3485
+ var import_uncrypto = require("uncrypto");
3486
3486
  var Script = class {
3487
3487
  script;
3488
+ /**
3489
+ * @deprecated This property is initialized to an empty string and will be set in the init method
3490
+ * asynchronously. Do not use this property immidiately after the constructor.
3491
+ *
3492
+ * This property is only exposed for backwards compatibility and will be removed in the
3493
+ * future major release.
3494
+ */
3488
3495
  sha1;
3489
3496
  redis;
3490
3497
  constructor(redis, script) {
3491
3498
  this.redis = redis;
3492
- this.sha1 = this.digest(script);
3493
3499
  this.script = script;
3500
+ this.sha1 = "";
3501
+ void this.init(script);
3502
+ }
3503
+ /**
3504
+ * Initialize the script by computing its SHA-1 hash.
3505
+ */
3506
+ async init(script) {
3507
+ if (this.sha1) return;
3508
+ this.sha1 = await this.digest(script);
3494
3509
  }
3495
3510
  /**
3496
3511
  * Send an `EVAL` command to redis.
3497
3512
  */
3498
3513
  async eval(keys, args) {
3514
+ await this.init(this.script);
3499
3515
  return await this.redis.eval(this.script, keys, args);
3500
3516
  }
3501
3517
  /**
3502
3518
  * Calculates the sha1 hash of the script and then calls `EVALSHA`.
3503
3519
  */
3504
3520
  async evalsha(keys, args) {
3521
+ await this.init(this.script);
3505
3522
  return await this.redis.evalsha(this.sha1, keys, args);
3506
3523
  }
3507
3524
  /**
@@ -3511,6 +3528,7 @@ var Script = class {
3511
3528
  * Following calls will be able to use the cached script
3512
3529
  */
3513
3530
  async exec(keys, args) {
3531
+ await this.init(this.script);
3514
3532
  const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
3515
3533
  if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3516
3534
  return await this.redis.eval(this.script, keys, args);
@@ -3522,33 +3540,49 @@ var Script = class {
3522
3540
  /**
3523
3541
  * Compute the sha1 hash of the script and return its hex representation.
3524
3542
  */
3525
- digest(s) {
3526
- return import_enc_hex.default.stringify((0, import_sha1.default)(s));
3543
+ async digest(s) {
3544
+ const data = new TextEncoder().encode(s);
3545
+ const hashBuffer = await import_uncrypto.subtle.digest("SHA-1", data);
3546
+ const hashArray = [...new Uint8Array(hashBuffer)];
3547
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3527
3548
  }
3528
3549
  };
3529
3550
 
3530
3551
  // pkg/scriptRo.ts
3531
- var import_enc_hex2 = __toESM(require("crypto-js/enc-hex.js"));
3532
- var import_sha12 = __toESM(require("crypto-js/sha1.js"));
3552
+ var import_uncrypto2 = require("uncrypto");
3533
3553
  var ScriptRO = class {
3534
3554
  script;
3555
+ /**
3556
+ * @deprecated This property is initialized to an empty string and will be set in the init method
3557
+ * asynchronously. Do not use this property immidiately after the constructor.
3558
+ *
3559
+ * This property is only exposed for backwards compatibility and will be removed in the
3560
+ * future major release.
3561
+ */
3535
3562
  sha1;
3536
3563
  redis;
3537
3564
  constructor(redis, script) {
3538
3565
  this.redis = redis;
3539
- this.sha1 = this.digest(script);
3566
+ this.sha1 = "";
3540
3567
  this.script = script;
3568
+ void this.init(script);
3569
+ }
3570
+ async init(script) {
3571
+ if (this.sha1) return;
3572
+ this.sha1 = await this.digest(script);
3541
3573
  }
3542
3574
  /**
3543
3575
  * Send an `EVAL_RO` command to redis.
3544
3576
  */
3545
3577
  async evalRo(keys, args) {
3578
+ await this.init(this.script);
3546
3579
  return await this.redis.evalRo(this.script, keys, args);
3547
3580
  }
3548
3581
  /**
3549
3582
  * Calculates the sha1 hash of the script and then calls `EVALSHA_RO`.
3550
3583
  */
3551
3584
  async evalshaRo(keys, args) {
3585
+ await this.init(this.script);
3552
3586
  return await this.redis.evalshaRo(this.sha1, keys, args);
3553
3587
  }
3554
3588
  /**
@@ -3558,6 +3592,7 @@ var ScriptRO = class {
3558
3592
  * Following calls will be able to use the cached script
3559
3593
  */
3560
3594
  async exec(keys, args) {
3595
+ await this.init(this.script);
3561
3596
  const res = await this.redis.evalshaRo(this.sha1, keys, args).catch(async (error) => {
3562
3597
  if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3563
3598
  return await this.redis.evalRo(this.script, keys, args);
@@ -3569,8 +3604,11 @@ var ScriptRO = class {
3569
3604
  /**
3570
3605
  * Compute the sha1 hash of the script and return its hex representation.
3571
3606
  */
3572
- digest(s) {
3573
- return import_enc_hex2.default.stringify((0, import_sha12.default)(s));
3607
+ async digest(s) {
3608
+ const data = new TextEncoder().encode(s);
3609
+ const hashBuffer = await import_uncrypto2.subtle.digest("SHA-1", data);
3610
+ const hashArray = [...new Uint8Array(hashBuffer)];
3611
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3574
3612
  }
3575
3613
  };
3576
3614
 
@@ -4180,10 +4218,9 @@ var Redis = class {
4180
4218
  * @see https://redis.io/commands/sadd
4181
4219
  */
4182
4220
  sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
4183
- /**
4184
- * @see https://redis.io/commands/scan
4185
- */
4186
- scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
4221
+ scan(cursor, opts) {
4222
+ return new ScanCommand([cursor, opts], this.opts).exec(this.client);
4223
+ }
4187
4224
  /**
4188
4225
  * @see https://redis.io/commands/scard
4189
4226
  */
@@ -4460,7 +4497,7 @@ var Redis = class {
4460
4497
  };
4461
4498
 
4462
4499
  // version.ts
4463
- var VERSION = "v1.34.9";
4500
+ var VERSION = "v1.35.0";
4464
4501
 
4465
4502
  // platforms/nodejs.ts
4466
4503
  if (typeof atob === "undefined") {
package/nodejs.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-TZPYH7UX.mjs";
6
+ } from "./chunk-QZ3IMTW7.mjs";
7
7
 
8
8
  // platforms/nodejs.ts
9
9
  if (typeof atob === "undefined") {
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@upstash/redis","version":"v1.34.9","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"}}
1
+ {"name":"@upstash/redis","version":"v1.35.0","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","@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":{"uncrypto":"^0.1.3"}}
@@ -271,18 +271,6 @@ declare class ScriptFlushCommand extends Command<"OK", "OK"> {
271
271
  constructor([opts]: [opts?: ScriptFlushCommandOptions], cmdOpts?: CommandOptions<"OK", "OK">);
272
272
  }
273
273
 
274
- type ScanCommandOptions = {
275
- match?: string;
276
- count?: number;
277
- type?: string;
278
- };
279
- /**
280
- * @see https://redis.io/commands/scan
281
- */
282
- declare class ScanCommand extends Command<[string, string[]], [string, string[]]> {
283
- constructor([cursor, opts]: [cursor: string | number, opts?: ScanCommandOptions], cmdOpts?: CommandOptions<[string, string[]], [string, string[]]>);
284
- }
285
-
286
274
  type GeoAddCommandOptions = {
287
275
  nx?: boolean;
288
276
  xx?: never;
@@ -820,6 +808,39 @@ declare class HRandFieldCommand<TData extends string | string[] | Record<string,
820
808
  constructor(cmd: [key: string, count: number, withValues: boolean], opts?: CommandOptions<string[], Partial<TData>>);
821
809
  }
822
810
 
811
+ type ScanCommandOptionsStandard = {
812
+ match?: string;
813
+ count?: number;
814
+ type?: string;
815
+ withType?: false;
816
+ };
817
+ type ScanCommandOptionsWithType = {
818
+ match?: string;
819
+ count?: number;
820
+ /**
821
+ * Includes types of each key in the result
822
+ *
823
+ * @example
824
+ * ```typescript
825
+ * await redis.scan("0", { withType: true })
826
+ * // ["0", [{ key: "key1", type: "string" }, { key: "key2", type: "list" }]]
827
+ * ```
828
+ */
829
+ withType: true;
830
+ };
831
+ type ScanCommandOptions = ScanCommandOptionsStandard | ScanCommandOptionsWithType;
832
+ type ScanResultStandard = [string, string[]];
833
+ type ScanResultWithType = [string, {
834
+ key: string;
835
+ type: string;
836
+ }[]];
837
+ /**
838
+ * @see https://redis.io/commands/scan
839
+ */
840
+ declare class ScanCommand<TData = ScanResultStandard> extends Command<[string, string[]], TData> {
841
+ constructor([cursor, opts]: [cursor: string | number, opts?: ScanCommandOptions], cmdOpts?: CommandOptions<[string, string[]], TData>);
842
+ }
843
+
823
844
  /**
824
845
  * @see https://redis.io/commands/hscan
825
846
  */
@@ -2405,7 +2426,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2405
2426
  /**
2406
2427
  * @see https://redis.io/commands/scan
2407
2428
  */
2408
- scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, [string, string[]]>]>;
2429
+ scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, any>]>;
2409
2430
  /**
2410
2431
  * @see https://redis.io/commands/scard
2411
2432
  */
@@ -2846,9 +2867,20 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2846
2867
  */
2847
2868
  declare class Script<TResult = unknown> {
2848
2869
  readonly script: string;
2849
- readonly sha1: string;
2870
+ /**
2871
+ * @deprecated This property is initialized to an empty string and will be set in the init method
2872
+ * asynchronously. Do not use this property immidiately after the constructor.
2873
+ *
2874
+ * This property is only exposed for backwards compatibility and will be removed in the
2875
+ * future major release.
2876
+ */
2877
+ sha1: string;
2850
2878
  private readonly redis;
2851
2879
  constructor(redis: Redis, script: string);
2880
+ /**
2881
+ * Initialize the script by computing its SHA-1 hash.
2882
+ */
2883
+ private init;
2852
2884
  /**
2853
2885
  * Send an `EVAL` command to redis.
2854
2886
  */
@@ -2888,9 +2920,17 @@ declare class Script<TResult = unknown> {
2888
2920
  */
2889
2921
  declare class ScriptRO<TResult = unknown> {
2890
2922
  readonly script: string;
2891
- readonly sha1: string;
2923
+ /**
2924
+ * @deprecated This property is initialized to an empty string and will be set in the init method
2925
+ * asynchronously. Do not use this property immidiately after the constructor.
2926
+ *
2927
+ * This property is only exposed for backwards compatibility and will be removed in the
2928
+ * future major release.
2929
+ */
2930
+ sha1: string;
2892
2931
  private readonly redis;
2893
2932
  constructor(redis: Redis, script: string);
2933
+ private init;
2894
2934
  /**
2895
2935
  * Send an `EVAL_RO` command to redis.
2896
2936
  */
@@ -3606,7 +3646,10 @@ declare class Redis {
3606
3646
  /**
3607
3647
  * @see https://redis.io/commands/scan
3608
3648
  */
3609
- scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Promise<[string, string[]]>;
3649
+ scan(cursor: string | number): Promise<ScanResultStandard>;
3650
+ scan<TOptions extends ScanCommandOptions>(cursor: string | number, opts: TOptions): Promise<TOptions extends {
3651
+ withType: true;
3652
+ } ? ScanResultWithType : ScanResultStandard>;
3610
3653
  /**
3611
3654
  * @see https://redis.io/commands/scard
3612
3655
  */
@@ -271,18 +271,6 @@ declare class ScriptFlushCommand extends Command<"OK", "OK"> {
271
271
  constructor([opts]: [opts?: ScriptFlushCommandOptions], cmdOpts?: CommandOptions<"OK", "OK">);
272
272
  }
273
273
 
274
- type ScanCommandOptions = {
275
- match?: string;
276
- count?: number;
277
- type?: string;
278
- };
279
- /**
280
- * @see https://redis.io/commands/scan
281
- */
282
- declare class ScanCommand extends Command<[string, string[]], [string, string[]]> {
283
- constructor([cursor, opts]: [cursor: string | number, opts?: ScanCommandOptions], cmdOpts?: CommandOptions<[string, string[]], [string, string[]]>);
284
- }
285
-
286
274
  type GeoAddCommandOptions = {
287
275
  nx?: boolean;
288
276
  xx?: never;
@@ -820,6 +808,39 @@ declare class HRandFieldCommand<TData extends string | string[] | Record<string,
820
808
  constructor(cmd: [key: string, count: number, withValues: boolean], opts?: CommandOptions<string[], Partial<TData>>);
821
809
  }
822
810
 
811
+ type ScanCommandOptionsStandard = {
812
+ match?: string;
813
+ count?: number;
814
+ type?: string;
815
+ withType?: false;
816
+ };
817
+ type ScanCommandOptionsWithType = {
818
+ match?: string;
819
+ count?: number;
820
+ /**
821
+ * Includes types of each key in the result
822
+ *
823
+ * @example
824
+ * ```typescript
825
+ * await redis.scan("0", { withType: true })
826
+ * // ["0", [{ key: "key1", type: "string" }, { key: "key2", type: "list" }]]
827
+ * ```
828
+ */
829
+ withType: true;
830
+ };
831
+ type ScanCommandOptions = ScanCommandOptionsStandard | ScanCommandOptionsWithType;
832
+ type ScanResultStandard = [string, string[]];
833
+ type ScanResultWithType = [string, {
834
+ key: string;
835
+ type: string;
836
+ }[]];
837
+ /**
838
+ * @see https://redis.io/commands/scan
839
+ */
840
+ declare class ScanCommand<TData = ScanResultStandard> extends Command<[string, string[]], TData> {
841
+ constructor([cursor, opts]: [cursor: string | number, opts?: ScanCommandOptions], cmdOpts?: CommandOptions<[string, string[]], TData>);
842
+ }
843
+
823
844
  /**
824
845
  * @see https://redis.io/commands/hscan
825
846
  */
@@ -2405,7 +2426,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2405
2426
  /**
2406
2427
  * @see https://redis.io/commands/scan
2407
2428
  */
2408
- scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, [string, string[]]>]>;
2429
+ scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, any>]>;
2409
2430
  /**
2410
2431
  * @see https://redis.io/commands/scard
2411
2432
  */
@@ -2846,9 +2867,20 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2846
2867
  */
2847
2868
  declare class Script<TResult = unknown> {
2848
2869
  readonly script: string;
2849
- readonly sha1: string;
2870
+ /**
2871
+ * @deprecated This property is initialized to an empty string and will be set in the init method
2872
+ * asynchronously. Do not use this property immidiately after the constructor.
2873
+ *
2874
+ * This property is only exposed for backwards compatibility and will be removed in the
2875
+ * future major release.
2876
+ */
2877
+ sha1: string;
2850
2878
  private readonly redis;
2851
2879
  constructor(redis: Redis, script: string);
2880
+ /**
2881
+ * Initialize the script by computing its SHA-1 hash.
2882
+ */
2883
+ private init;
2852
2884
  /**
2853
2885
  * Send an `EVAL` command to redis.
2854
2886
  */
@@ -2888,9 +2920,17 @@ declare class Script<TResult = unknown> {
2888
2920
  */
2889
2921
  declare class ScriptRO<TResult = unknown> {
2890
2922
  readonly script: string;
2891
- readonly sha1: string;
2923
+ /**
2924
+ * @deprecated This property is initialized to an empty string and will be set in the init method
2925
+ * asynchronously. Do not use this property immidiately after the constructor.
2926
+ *
2927
+ * This property is only exposed for backwards compatibility and will be removed in the
2928
+ * future major release.
2929
+ */
2930
+ sha1: string;
2892
2931
  private readonly redis;
2893
2932
  constructor(redis: Redis, script: string);
2933
+ private init;
2894
2934
  /**
2895
2935
  * Send an `EVAL_RO` command to redis.
2896
2936
  */
@@ -3606,7 +3646,10 @@ declare class Redis {
3606
3646
  /**
3607
3647
  * @see https://redis.io/commands/scan
3608
3648
  */
3609
- scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Promise<[string, string[]]>;
3649
+ scan(cursor: string | number): Promise<ScanResultStandard>;
3650
+ scan<TOptions extends ScanCommandOptions>(cursor: string | number, opts: TOptions): Promise<TOptions extends {
3651
+ withType: true;
3652
+ } ? ScanResultWithType : ScanResultStandard>;
3610
3653
  /**
3611
3654
  * @see https://redis.io/commands/scard
3612
3655
  */