@windrun-huaiin/backend-core 13.0.0 → 14.1.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.
Files changed (110) hide show
  1. package/dist/_virtual/index.js +7 -3
  2. package/dist/_virtual/index.mjs +5 -3
  3. package/dist/_virtual/index2.js +2 -6
  4. package/dist/_virtual/index2.mjs +2 -6
  5. package/dist/index.js +3 -1
  6. package/dist/index.mjs +2 -2
  7. package/dist/lib/index.js +3 -1
  8. package/dist/lib/index.mjs +2 -2
  9. package/dist/lib/stripe-config.d.ts +1 -1
  10. package/dist/lib/stripe-config.d.ts.map +1 -1
  11. package/dist/lib/stripe-config.js +25 -16
  12. package/dist/lib/stripe-config.mjs +25 -16
  13. package/dist/lib/upstash/qstash.d.ts.map +1 -1
  14. package/dist/lib/upstash/qstash.js +66 -62
  15. package/dist/lib/upstash/qstash.mjs +67 -63
  16. package/dist/lib/upstash/redis-counter.d.ts.map +1 -1
  17. package/dist/lib/upstash/redis-counter.js +9 -24
  18. package/dist/lib/upstash/redis-counter.mjs +10 -25
  19. package/dist/lib/upstash/redis-favorite.d.ts.map +1 -1
  20. package/dist/lib/upstash/redis-favorite.js +22 -36
  21. package/dist/lib/upstash/redis-favorite.mjs +23 -37
  22. package/dist/lib/upstash/redis-like.d.ts.map +1 -1
  23. package/dist/lib/upstash/redis-like.js +22 -36
  24. package/dist/lib/upstash/redis-like.mjs +23 -37
  25. package/dist/lib/upstash/redis-lock.d.ts.map +1 -1
  26. package/dist/lib/upstash/redis-lock.js +22 -38
  27. package/dist/lib/upstash/redis-lock.mjs +23 -39
  28. package/dist/lib/upstash/redis-structures.d.ts.map +1 -1
  29. package/dist/lib/upstash/redis-structures.js +77 -113
  30. package/dist/lib/upstash/redis-structures.mjs +78 -114
  31. package/dist/lib/upstash-config.d.ts +9 -1
  32. package/dist/lib/upstash-config.d.ts.map +1 -1
  33. package/dist/lib/upstash-config.js +221 -27
  34. package/dist/lib/upstash-config.mjs +220 -28
  35. package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.js → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js} +897 -468
  36. package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.mjs → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs} +895 -468
  37. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.js → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.js} +657 -40
  38. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.mjs → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.mjs} +657 -41
  39. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.js +6 -5
  40. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.mjs +2 -2
  41. package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js +1 -1
  42. package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs +1 -1
  43. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js +6 -6
  44. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js +1 -1
  45. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js +2 -2
  46. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js +3 -1
  47. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js +3 -1
  48. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js +1 -1
  49. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js +3 -1
  50. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js +7 -5
  51. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js +3 -1
  52. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js +3 -1
  53. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js +3 -1
  54. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js +3 -1
  55. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js +3 -1
  56. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js +4 -2
  57. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js +3 -1
  58. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js +3 -1
  59. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js +1 -1
  60. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js +3 -1
  61. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js +3 -1
  62. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js +6 -4
  63. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js +6 -4
  64. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js +7 -5
  65. package/dist/services/stripe/webhook-handler.js +4 -2
  66. package/dist/services/stripe/webhook-handler.mjs +3 -1
  67. package/package.json +5 -5
  68. package/src/lib/stripe-config.ts +27 -15
  69. package/src/lib/upstash/qstash.ts +64 -62
  70. package/src/lib/upstash/redis-counter.ts +10 -26
  71. package/src/lib/upstash/redis-favorite.ts +23 -42
  72. package/src/lib/upstash/redis-like.ts +23 -42
  73. package/src/lib/upstash/redis-lock.ts +23 -49
  74. package/src/lib/upstash/redis-structures.ts +82 -131
  75. package/src/lib/upstash-config.ts +231 -24
  76. package/src/services/stripe/webhook-handler.ts +3 -1
  77. package/dist/_virtual/index3.js +0 -5
  78. package/dist/_virtual/index3.mjs +0 -3
  79. package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.js +0 -191
  80. package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.mjs +0 -189
  81. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js +0 -54
  82. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.mjs +0 -51
  83. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js +0 -44
  84. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.mjs +0 -35
  85. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js +0 -31
  86. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.mjs +0 -18
  87. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js +0 -587
  88. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.mjs +0 -527
  89. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js +0 -447
  90. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.mjs +0 -399
  91. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js +0 -245
  92. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.mjs +0 -232
  93. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js +0 -68
  94. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.mjs +0 -62
  95. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js +0 -39
  96. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.mjs +0 -37
  97. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js +0 -80
  98. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.mjs +0 -75
  99. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js +0 -101
  100. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.mjs +0 -86
  101. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js +0 -102
  102. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.mjs +0 -76
  103. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js +0 -56
  104. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.mjs +0 -52
  105. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js +0 -1205
  106. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.mjs +0 -1157
  107. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js +0 -407
  108. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.mjs +0 -374
  109. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js +0 -9
  110. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.mjs +0 -7
@@ -146,7 +146,6 @@ var HttpClient = class {
146
146
  const signal = req.signal ?? this.options.signal;
147
147
  const isSignalFunction = typeof signal === "function";
148
148
  const requestOptions = {
149
- //@ts-expect-error this should throw due to bun regression
150
149
  cache: this.options.cache,
151
150
  method: "POST",
152
151
  headers: requestHeaders,
@@ -393,6 +392,442 @@ var Command = class {
393
392
  }
394
393
  };
395
394
 
395
+ // pkg/commands/exec.ts
396
+ var ExecCommand = class extends Command {
397
+ constructor(cmd, opts) {
398
+ const normalizedCmd = cmd.map((arg) => typeof arg === "string" ? arg : String(arg));
399
+ super(normalizedCmd, opts);
400
+ }
401
+ };
402
+
403
+ // pkg/commands/search/types.ts
404
+ var FIELD_TYPES = [
405
+ "TEXT",
406
+ "U64",
407
+ "I64",
408
+ "F64",
409
+ "BOOL",
410
+ "DATE",
411
+ "KEYWORD",
412
+ "FACET"
413
+ ];
414
+
415
+ // pkg/commands/search/utils.ts
416
+ function isFieldType(value) {
417
+ return typeof value === "string" && FIELD_TYPES.includes(value);
418
+ }
419
+ function isDetailedField(value) {
420
+ return typeof value === "object" && value !== null && "type" in value && isFieldType(value.type);
421
+ }
422
+ function isNestedSchema(value) {
423
+ return typeof value === "object" && value !== null && !isDetailedField(value);
424
+ }
425
+ function flattenSchema(schema, pathPrefix = []) {
426
+ const fields = [];
427
+ for (const [key, value] of Object.entries(schema)) {
428
+ const currentPath = [...pathPrefix, key];
429
+ const pathString = currentPath.join(".");
430
+ if (isFieldType(value)) {
431
+ fields.push({
432
+ path: pathString,
433
+ type: value
434
+ });
435
+ } else if (isDetailedField(value)) {
436
+ fields.push({
437
+ path: pathString,
438
+ type: value.type,
439
+ fast: "fast" in value ? value.fast : void 0,
440
+ noTokenize: "noTokenize" in value ? value.noTokenize : void 0,
441
+ noStem: "noStem" in value ? value.noStem : void 0,
442
+ from: "from" in value ? value.from : void 0
443
+ });
444
+ } else if (isNestedSchema(value)) {
445
+ const nestedFields = flattenSchema(value, currentPath);
446
+ fields.push(...nestedFields);
447
+ }
448
+ }
449
+ return fields;
450
+ }
451
+ function deserializeQueryResponse(rawResponse) {
452
+ return rawResponse.map((itemRaw) => {
453
+ const raw = itemRaw;
454
+ const key = raw[0];
455
+ const score = Number(raw[1]);
456
+ const rawFields = raw[2];
457
+ if (rawFields === void 0) {
458
+ return { key, score };
459
+ }
460
+ if (!Array.isArray(rawFields) || rawFields.length === 0) {
461
+ return { key, score, data: {} };
462
+ }
463
+ let data = {};
464
+ for (const fieldRaw of rawFields) {
465
+ const key2 = fieldRaw[0];
466
+ const value = fieldRaw[1];
467
+ const pathParts = key2.split(".");
468
+ if (pathParts.length === 1) {
469
+ data[key2] = value;
470
+ } else {
471
+ let currentObj = data;
472
+ for (let i = 0; i < pathParts.length - 1; i++) {
473
+ const pathPart = pathParts[i];
474
+ if (!(pathPart in currentObj)) {
475
+ currentObj[pathPart] = {};
476
+ }
477
+ currentObj = currentObj[pathPart];
478
+ }
479
+ currentObj[pathParts.at(-1)] = value;
480
+ }
481
+ }
482
+ if ("$" in data) {
483
+ data = data["$"];
484
+ }
485
+ return { key, score, data };
486
+ });
487
+ }
488
+ function deserializeDescribeResponse(rawResponse) {
489
+ const description = {};
490
+ for (let i = 0; i < rawResponse.length; i += 2) {
491
+ const descriptor = rawResponse[i];
492
+ switch (descriptor) {
493
+ case "name": {
494
+ description["name"] = rawResponse[i + 1];
495
+ break;
496
+ }
497
+ case "type": {
498
+ description["dataType"] = rawResponse[i + 1].toLowerCase();
499
+ break;
500
+ }
501
+ case "prefixes": {
502
+ description["prefixes"] = rawResponse[i + 1];
503
+ break;
504
+ }
505
+ case "language": {
506
+ description["language"] = rawResponse[i + 1];
507
+ break;
508
+ }
509
+ case "schema": {
510
+ const schema = {};
511
+ for (const fieldDescription of rawResponse[i + 1]) {
512
+ const fieldName = fieldDescription[0];
513
+ const fieldInfo = { type: fieldDescription[1] };
514
+ if (fieldDescription.length > 2) {
515
+ for (let j = 2; j < fieldDescription.length; j++) {
516
+ const fieldOption = fieldDescription[j];
517
+ switch (fieldOption) {
518
+ case "NOSTEM": {
519
+ fieldInfo.noStem = true;
520
+ break;
521
+ }
522
+ case "NOTOKENIZE": {
523
+ fieldInfo.noTokenize = true;
524
+ break;
525
+ }
526
+ case "FAST": {
527
+ fieldInfo.fast = true;
528
+ break;
529
+ }
530
+ case "FROM": {
531
+ fieldInfo.from = fieldDescription[++j];
532
+ break;
533
+ }
534
+ }
535
+ }
536
+ }
537
+ schema[fieldName] = fieldInfo;
538
+ }
539
+ description["schema"] = schema;
540
+ break;
541
+ }
542
+ }
543
+ }
544
+ return description;
545
+ }
546
+ function parseCountResponse(rawResponse) {
547
+ return typeof rawResponse === "number" ? rawResponse : Number.parseInt(rawResponse, 10);
548
+ }
549
+ function deserializeAggregateResponse(rawResponse) {
550
+ return parseAggregationArray(rawResponse);
551
+ }
552
+ function parseAggregationArray(arr) {
553
+ const result = {};
554
+ for (let i = 0; i < arr.length; i += 2) {
555
+ const key = arr[i];
556
+ const value = arr[i + 1];
557
+ if (Array.isArray(value)) {
558
+ if (value.length > 0 && typeof value[0] === "string") {
559
+ result[key] = value[0] === "buckets" ? parseBucketsValue(value) : parseStatsValue(value);
560
+ } else {
561
+ result[key] = parseAggregationArray(value);
562
+ }
563
+ } else {
564
+ result[key] = value;
565
+ }
566
+ }
567
+ return result;
568
+ }
569
+ function coerceNumericString(value) {
570
+ if (typeof value === "string" && value !== "" && !Number.isNaN(Number(value))) {
571
+ return Number(value);
572
+ }
573
+ return value;
574
+ }
575
+ function parseStatsValue(arr) {
576
+ const result = {};
577
+ for (let i = 0; i < arr.length; i += 2) {
578
+ const key = arr[i];
579
+ const value = arr[i + 1];
580
+ if (Array.isArray(value) && value.length > 0) {
581
+ if (typeof value[0] === "string") {
582
+ result[key] = parseStatsValue(value);
583
+ } else if (Array.isArray(value[0]) && typeof value[0][0] === "string") {
584
+ result[key] = value.map((item) => parseStatsValue(item));
585
+ } else {
586
+ result[key] = value;
587
+ }
588
+ } else {
589
+ result[key] = coerceNumericString(value);
590
+ }
591
+ }
592
+ return result;
593
+ }
594
+ function parseBucketsValue(arr) {
595
+ if (arr[0] === "buckets" && Array.isArray(arr[1])) {
596
+ const result = {
597
+ buckets: arr[1].map((bucket) => {
598
+ const bucketObj = {};
599
+ for (let i = 0; i < bucket.length; i += 2) {
600
+ const key = bucket[i];
601
+ const value = bucket[i + 1];
602
+ bucketObj[key] = Array.isArray(value) && value.length > 0 && typeof value[0] === "string" ? parseStatsValue(value) : value;
603
+ }
604
+ return bucketObj;
605
+ })
606
+ };
607
+ for (let i = 2; i < arr.length; i += 2) {
608
+ result[arr[i]] = arr[i + 1];
609
+ }
610
+ return result;
611
+ }
612
+ return arr;
613
+ }
614
+
615
+ // pkg/commands/search/command-builder.ts
616
+ function buildQueryCommand(redisCommand, name, options) {
617
+ const query = JSON.stringify(options?.filter ?? {});
618
+ const command = [redisCommand, name, query];
619
+ if (options?.limit !== void 0) {
620
+ command.push("LIMIT", options.limit.toString());
621
+ }
622
+ if (options?.offset !== void 0) {
623
+ command.push("OFFSET", options.offset.toString());
624
+ }
625
+ if (options?.select && Object.keys(options.select).length === 0) {
626
+ command.push("NOCONTENT");
627
+ }
628
+ if (options) {
629
+ if ("orderBy" in options && options.orderBy) {
630
+ command.push("ORDERBY");
631
+ for (const [field, direction] of Object.entries(options.orderBy)) {
632
+ command.push(field, direction);
633
+ }
634
+ } else if ("scoreFunc" in options && options.scoreFunc) {
635
+ command.push("SCOREFUNC", ...buildScoreFunc(options.scoreFunc));
636
+ }
637
+ }
638
+ if (options?.highlight) {
639
+ command.push(
640
+ "HIGHLIGHT",
641
+ "FIELDS",
642
+ options.highlight.fields.length.toString(),
643
+ ...options.highlight.fields
644
+ );
645
+ if (options.highlight.preTag && options.highlight.postTag) {
646
+ command.push("TAGS", options.highlight.preTag, options.highlight.postTag);
647
+ }
648
+ }
649
+ if (options?.select && Object.keys(options.select).length > 0) {
650
+ command.push(
651
+ "SELECT",
652
+ Object.keys(options.select).length.toString(),
653
+ ...Object.keys(options.select)
654
+ );
655
+ }
656
+ return command;
657
+ }
658
+ function buildScoreFunc(scoreBy) {
659
+ const result = [];
660
+ if (typeof scoreBy === "string") {
661
+ result.push("FIELDVALUE", scoreBy);
662
+ } else if ("fields" in scoreBy) {
663
+ if (scoreBy.combineMode) {
664
+ result.push("COMBINEMODE", scoreBy.combineMode.toUpperCase());
665
+ }
666
+ if (scoreBy.scoreMode) {
667
+ result.push("SCOREMODE", scoreBy.scoreMode.toUpperCase());
668
+ }
669
+ for (const field of scoreBy.fields) {
670
+ result.push(...buildScoreFuncField(field));
671
+ }
672
+ } else {
673
+ result.push(...buildScoreFuncField(scoreBy));
674
+ }
675
+ return result;
676
+ }
677
+ function buildScoreFuncField(field) {
678
+ const result = [];
679
+ if (typeof field === "string") {
680
+ result.push("FIELDVALUE", field);
681
+ } else {
682
+ if (field.scoreMode) {
683
+ result.push("SCOREMODE", field.scoreMode.toUpperCase());
684
+ }
685
+ result.push("FIELDVALUE", field.field);
686
+ if (field.modifier) {
687
+ result.push("MODIFIER", field.modifier.toUpperCase());
688
+ }
689
+ if (field.factor !== void 0) {
690
+ result.push("FACTOR", field.factor.toString());
691
+ }
692
+ if (field.missing !== void 0) {
693
+ result.push("MISSING", field.missing.toString());
694
+ }
695
+ }
696
+ return result;
697
+ }
698
+ function buildCreateIndexCommand(params) {
699
+ const { name, schema, dataType, prefix, language, skipInitialScan, existsOk } = params;
700
+ const prefixArray = Array.isArray(prefix) ? prefix : [prefix];
701
+ const payload = [
702
+ name,
703
+ ...skipInitialScan ? ["SKIPINITIALSCAN"] : [],
704
+ ...existsOk ? ["EXISTSOK"] : [],
705
+ "ON",
706
+ dataType.toUpperCase(),
707
+ "PREFIX",
708
+ prefixArray.length.toString(),
709
+ ...prefixArray,
710
+ ...language ? ["LANGUAGE", language] : [],
711
+ "SCHEMA"
712
+ ];
713
+ const fields = flattenSchema(schema);
714
+ for (const field of fields) {
715
+ payload.push(field.path, field.type);
716
+ if (field.fast) {
717
+ payload.push("FAST");
718
+ }
719
+ if (field.noTokenize) {
720
+ payload.push("NOTOKENIZE");
721
+ }
722
+ if (field.noStem) {
723
+ payload.push("NOSTEM");
724
+ }
725
+ if (field.from) {
726
+ payload.push("FROM", field.from);
727
+ }
728
+ }
729
+ return ["SEARCH.CREATE", ...payload];
730
+ }
731
+ function buildAggregateCommand(name, options) {
732
+ const query = JSON.stringify(options?.filter ?? {});
733
+ const aggregations = JSON.stringify(options.aggregations);
734
+ return ["SEARCH.AGGREGATE", name, query, aggregations];
735
+ }
736
+
737
+ // pkg/commands/search/search.ts
738
+ var SearchIndex = class {
739
+ name;
740
+ schema;
741
+ client;
742
+ constructor({ name, schema, client }) {
743
+ this.name = name;
744
+ this.schema = schema;
745
+ this.client = client;
746
+ }
747
+ async waitIndexing() {
748
+ const command = ["SEARCH.WAITINDEXING", this.name];
749
+ return await new ExecCommand(command).exec(this.client);
750
+ }
751
+ async describe() {
752
+ const command = ["SEARCH.DESCRIBE", this.name];
753
+ const rawResult = await new ExecCommand(command).exec(
754
+ this.client
755
+ );
756
+ if (!rawResult) return null;
757
+ return deserializeDescribeResponse(rawResult);
758
+ }
759
+ async query(options) {
760
+ const command = buildQueryCommand("SEARCH.QUERY", this.name, options);
761
+ const rawResult = await new ExecCommand(command).exec(
762
+ this.client
763
+ );
764
+ if (!rawResult) return rawResult;
765
+ return deserializeQueryResponse(rawResult);
766
+ }
767
+ async aggregate(options) {
768
+ const command = buildAggregateCommand(this.name, options);
769
+ const rawResult = await new ExecCommand(
770
+ command
771
+ ).exec(this.client);
772
+ return deserializeAggregateResponse(rawResult);
773
+ }
774
+ async count({ filter }) {
775
+ const command = buildQueryCommand("SEARCH.COUNT", this.name, { filter });
776
+ const rawResult = await new ExecCommand(command).exec(
777
+ this.client
778
+ );
779
+ return { count: parseCountResponse(rawResult) };
780
+ }
781
+ async drop() {
782
+ const command = ["SEARCH.DROP", this.name];
783
+ const result = await new ExecCommand(command).exec(this.client);
784
+ return result;
785
+ }
786
+ async addAlias({ alias }) {
787
+ const command = ["SEARCH.ALIASADD", alias, this.name];
788
+ const result = await new ExecCommand(command).exec(this.client);
789
+ return result;
790
+ }
791
+ };
792
+ async function createIndex(client, params) {
793
+ const { name, schema } = params;
794
+ const createIndexCommand = buildCreateIndexCommand(params);
795
+ await new ExecCommand(createIndexCommand).exec(client);
796
+ return initIndex(client, { name, schema });
797
+ }
798
+ function initIndex(client, params) {
799
+ const { name, schema } = params;
800
+ return new SearchIndex({ name, schema, client });
801
+ }
802
+ async function listAliases(client) {
803
+ const command = ["SEARCH.LISTALIASES"];
804
+ const rawResult = await new ExecCommand(command).exec(client);
805
+ if (rawResult === 0 || Array.isArray(rawResult) && rawResult.length === 0) {
806
+ return {};
807
+ }
808
+ if (!Array.isArray(rawResult)) {
809
+ return {};
810
+ }
811
+ const aliases = {};
812
+ for (const pair of rawResult) {
813
+ if (Array.isArray(pair) && pair.length === 2) {
814
+ const [alias, index] = pair;
815
+ aliases[alias] = index;
816
+ }
817
+ }
818
+ return aliases;
819
+ }
820
+ async function addAlias(client, { indexName, alias }) {
821
+ const command = ["SEARCH.ALIASADD", alias, indexName];
822
+ const result = await new ExecCommand(command).exec(client);
823
+ return result;
824
+ }
825
+ async function delAlias(client, { alias }) {
826
+ const command = ["SEARCH.ALIASDEL", alias];
827
+ const result = await new ExecCommand(command).exec(client);
828
+ return result;
829
+ }
830
+
396
831
  // pkg/commands/hrandfield.ts
397
832
  function deserialize(result) {
398
833
  if (result.length === 0) {
@@ -493,6 +928,13 @@ var BitPosCommand = class extends Command {
493
928
  }
494
929
  };
495
930
 
931
+ // pkg/commands/client_setinfo.ts
932
+ var ClientSetInfoCommand = class extends Command {
933
+ constructor([attribute, value], opts) {
934
+ super(["CLIENT", "SETINFO", attribute.toUpperCase(), value], opts);
935
+ }
936
+ };
937
+
496
938
  // pkg/commands/copy.ts
497
939
  var CopyCommand = class extends Command {
498
940
  constructor([key, destinationKey, opts], commandOptions) {
@@ -571,14 +1013,6 @@ var EvalshaCommand = class extends Command {
571
1013
  }
572
1014
  };
573
1015
 
574
- // pkg/commands/exec.ts
575
- var ExecCommand = class extends Command {
576
- constructor(cmd, opts) {
577
- const normalizedCmd = cmd.map((arg) => typeof arg === "string" ? arg : String(arg));
578
- super(normalizedCmd, opts);
579
- }
580
- };
581
-
582
1016
  // pkg/commands/exists.ts
583
1017
  var ExistsCommand = class extends Command {
584
1018
  constructor(cmd, opts) {
@@ -1090,6 +1524,63 @@ var HGetAllCommand = class extends Command {
1090
1524
  }
1091
1525
  };
1092
1526
 
1527
+ // pkg/commands/hmget.ts
1528
+ function deserialize5(fields, result) {
1529
+ if (result.every((field) => field === null)) {
1530
+ return null;
1531
+ }
1532
+ const obj = {};
1533
+ for (const [i, field] of fields.entries()) {
1534
+ try {
1535
+ obj[field] = JSON.parse(result[i]);
1536
+ } catch {
1537
+ obj[field] = result[i];
1538
+ }
1539
+ }
1540
+ return obj;
1541
+ }
1542
+ var HMGetCommand = class extends Command {
1543
+ constructor([key, ...fields], opts) {
1544
+ super(["hmget", key, ...fields], {
1545
+ deserialize: (result) => deserialize5(fields, result),
1546
+ ...opts
1547
+ });
1548
+ }
1549
+ };
1550
+
1551
+ // pkg/commands/hgetdel.ts
1552
+ var HGetDelCommand = class extends Command {
1553
+ constructor([key, ...fields], opts) {
1554
+ super(["hgetdel", key, "FIELDS", fields.length, ...fields], {
1555
+ deserialize: (result) => deserialize5(fields.map(String), result),
1556
+ ...opts
1557
+ });
1558
+ }
1559
+ };
1560
+
1561
+ // pkg/commands/hgetex.ts
1562
+ var HGetExCommand = class extends Command {
1563
+ constructor([key, opts, ...fields], cmdOpts) {
1564
+ const command = ["hgetex", key];
1565
+ if ("ex" in opts && typeof opts.ex === "number") {
1566
+ command.push("EX", opts.ex);
1567
+ } else if ("px" in opts && typeof opts.px === "number") {
1568
+ command.push("PX", opts.px);
1569
+ } else if ("exat" in opts && typeof opts.exat === "number") {
1570
+ command.push("EXAT", opts.exat);
1571
+ } else if ("pxat" in opts && typeof opts.pxat === "number") {
1572
+ command.push("PXAT", opts.pxat);
1573
+ } else if ("persist" in opts && opts.persist) {
1574
+ command.push("PERSIST");
1575
+ }
1576
+ command.push("FIELDS", fields.length, ...fields);
1577
+ super(command, {
1578
+ deserialize: (result) => deserialize5(fields.map(String), result),
1579
+ ...cmdOpts
1580
+ });
1581
+ }
1582
+ };
1583
+
1093
1584
  // pkg/commands/hincrby.ts
1094
1585
  var HIncrByCommand = class extends Command {
1095
1586
  constructor(cmd, opts) {
@@ -1118,30 +1609,6 @@ var HLenCommand = class extends Command {
1118
1609
  }
1119
1610
  };
1120
1611
 
1121
- // pkg/commands/hmget.ts
1122
- function deserialize5(fields, result) {
1123
- if (result.every((field) => field === null)) {
1124
- return null;
1125
- }
1126
- const obj = {};
1127
- for (const [i, field] of fields.entries()) {
1128
- try {
1129
- obj[field] = JSON.parse(result[i]);
1130
- } catch {
1131
- obj[field] = result[i];
1132
- }
1133
- }
1134
- return obj;
1135
- }
1136
- var HMGetCommand = class extends Command {
1137
- constructor([key, ...fields], opts) {
1138
- super(["hmget", key, ...fields], {
1139
- deserialize: (result) => deserialize5(fields, result),
1140
- ...opts
1141
- });
1142
- }
1143
- };
1144
-
1145
1612
  // pkg/commands/hmset.ts
1146
1613
  var HMSetCommand = class extends Command {
1147
1614
  constructor([key, kv], opts) {
@@ -1173,6 +1640,35 @@ var HSetCommand = class extends Command {
1173
1640
  }
1174
1641
  };
1175
1642
 
1643
+ // pkg/commands/hsetex.ts
1644
+ var HSetExCommand = class extends Command {
1645
+ constructor([key, opts, kv], cmdOpts) {
1646
+ const command = ["hsetex", key];
1647
+ if (opts.conditional) {
1648
+ command.push(opts.conditional.toUpperCase());
1649
+ }
1650
+ if (opts.expiration) {
1651
+ if ("ex" in opts.expiration && typeof opts.expiration.ex === "number") {
1652
+ command.push("EX", opts.expiration.ex);
1653
+ } else if ("px" in opts.expiration && typeof opts.expiration.px === "number") {
1654
+ command.push("PX", opts.expiration.px);
1655
+ } else if ("exat" in opts.expiration && typeof opts.expiration.exat === "number") {
1656
+ command.push("EXAT", opts.expiration.exat);
1657
+ } else if ("pxat" in opts.expiration && typeof opts.expiration.pxat === "number") {
1658
+ command.push("PXAT", opts.expiration.pxat);
1659
+ } else if ("keepttl" in opts.expiration && opts.expiration.keepttl) {
1660
+ command.push("KEEPTTL");
1661
+ }
1662
+ }
1663
+ const entries = Object.entries(kv);
1664
+ command.push("FIELDS", entries.length);
1665
+ for (const [field, value] of entries) {
1666
+ command.push(field, value);
1667
+ }
1668
+ super(command, cmdOpts);
1669
+ }
1670
+ };
1671
+
1176
1672
  // pkg/commands/hsetnx.ts
1177
1673
  var HSetNXCommand = class extends Command {
1178
1674
  constructor(cmd, opts) {
@@ -1811,6 +2307,18 @@ var SInterCommand = class extends Command {
1811
2307
  }
1812
2308
  };
1813
2309
 
2310
+ // pkg/commands/sintercard.ts
2311
+ var SInterCardCommand = class extends Command {
2312
+ constructor(cmd, cmdOpts) {
2313
+ const [keys, opts] = cmd;
2314
+ const command = ["sintercard", keys.length, ...keys];
2315
+ if (opts?.limit !== void 0) {
2316
+ command.push("LIMIT", opts.limit);
2317
+ }
2318
+ super(command, cmdOpts);
2319
+ }
2320
+ };
2321
+
1814
2322
  // pkg/commands/sinterstore.ts
1815
2323
  var SInterStoreCommand = class extends Command {
1816
2324
  constructor(cmd, opts) {
@@ -1956,6 +2464,15 @@ var XAckCommand = class extends Command {
1956
2464
  }
1957
2465
  };
1958
2466
 
2467
+ // pkg/commands/xackdel.ts
2468
+ var XAckDelCommand = class extends Command {
2469
+ constructor([key, group, opts, ...ids], cmdOpts) {
2470
+ const command = ["XACKDEL", key, group];
2471
+ command.push(opts.toUpperCase(), "IDS", ids.length, ...ids);
2472
+ super(command, cmdOpts);
2473
+ }
2474
+ };
2475
+
1959
2476
  // pkg/commands/xadd.ts
1960
2477
  var XAddCommand = class extends Command {
1961
2478
  constructor([key, id, entries, opts], commandOptions) {
@@ -2028,6 +2545,18 @@ var XDelCommand = class extends Command {
2028
2545
  }
2029
2546
  };
2030
2547
 
2548
+ // pkg/commands/xdelex.ts
2549
+ var XDelExCommand = class extends Command {
2550
+ constructor([key, opts, ...ids], cmdOpts) {
2551
+ const command = ["XDELEX", key];
2552
+ if (opts) {
2553
+ command.push(opts.toUpperCase());
2554
+ }
2555
+ command.push("IDS", ids.length, ...ids);
2556
+ super(command, cmdOpts);
2557
+ }
2558
+ };
2559
+
2031
2560
  // pkg/commands/xgroup.ts
2032
2561
  var XGroupCommand = class extends Command {
2033
2562
  constructor([key, opts], commandOptions) {
@@ -2592,6 +3121,10 @@ var Pipeline = class {
2592
3121
  * @see https://redis.io/commands/bitpos
2593
3122
  */
2594
3123
  bitpos = (...args) => this.chain(new BitPosCommand(args, this.commandOptions));
3124
+ /**
3125
+ * @see https://redis.io/commands/client-setinfo
3126
+ */
3127
+ clientSetinfo = (...args) => this.chain(new ClientSetInfoCommand(args, this.commandOptions));
2595
3128
  /**
2596
3129
  * @see https://redis.io/commands/copy
2597
3130
  */
@@ -2756,6 +3289,14 @@ var Pipeline = class {
2756
3289
  * @see https://redis.io/commands/hgetall
2757
3290
  */
2758
3291
  hgetall = (...args) => this.chain(new HGetAllCommand(args, this.commandOptions));
3292
+ /**
3293
+ * @see https://redis.io/commands/hgetdel
3294
+ */
3295
+ hgetdel = (...args) => this.chain(new HGetDelCommand(args, this.commandOptions));
3296
+ /**
3297
+ * @see https://redis.io/commands/hgetex
3298
+ */
3299
+ hgetex = (...args) => this.chain(new HGetExCommand(args, this.commandOptions));
2759
3300
  /**
2760
3301
  * @see https://redis.io/commands/hincrby
2761
3302
  */
@@ -2792,6 +3333,10 @@ var Pipeline = class {
2792
3333
  * @see https://redis.io/commands/hset
2793
3334
  */
2794
3335
  hset = (key, kv) => this.chain(new HSetCommand([key, kv], this.commandOptions));
3336
+ /**
3337
+ * @see https://redis.io/commands/hsetex
3338
+ */
3339
+ hsetex = (...args) => this.chain(new HSetExCommand(args, this.commandOptions));
2795
3340
  /**
2796
3341
  * @see https://redis.io/commands/hsetnx
2797
3342
  */
@@ -3004,6 +3549,10 @@ var Pipeline = class {
3004
3549
  * @see https://redis.io/commands/sinter
3005
3550
  */
3006
3551
  sinter = (...args) => this.chain(new SInterCommand(args, this.commandOptions));
3552
+ /**
3553
+ * @see https://redis.io/commands/sintercard
3554
+ */
3555
+ sintercard = (...args) => this.chain(new SInterCardCommand(args, this.commandOptions));
3007
3556
  /**
3008
3557
  * @see https://redis.io/commands/sinterstore
3009
3558
  */
@@ -3096,10 +3645,18 @@ var Pipeline = class {
3096
3645
  * @see https://redis.io/commands/xack
3097
3646
  */
3098
3647
  xack = (...args) => this.chain(new XAckCommand(args, this.commandOptions));
3648
+ /**
3649
+ * @see https://redis.io/commands/xackdel
3650
+ */
3651
+ xackdel = (...args) => this.chain(new XAckDelCommand(args, this.commandOptions));
3099
3652
  /**
3100
3653
  * @see https://redis.io/commands/xdel
3101
3654
  */
3102
3655
  xdel = (...args) => this.chain(new XDelCommand(args, this.commandOptions));
3656
+ /**
3657
+ * @see https://redis.io/commands/xdelex
3658
+ */
3659
+ xdelex = (...args) => this.chain(new XDelExCommand(args, this.commandOptions));
3103
3660
  /**
3104
3661
  * @see https://redis.io/commands/xgroup
3105
3662
  */
@@ -3648,6 +4205,7 @@ var Script = class {
3648
4205
  * future major release.
3649
4206
  */
3650
4207
  sha1;
4208
+ initPromise;
3651
4209
  redis;
3652
4210
  constructor(redis, script) {
3653
4211
  this.redis = redis;
@@ -3658,9 +4216,13 @@ var Script = class {
3658
4216
  /**
3659
4217
  * Initialize the script by computing its SHA-1 hash.
3660
4218
  */
3661
- async init(script) {
3662
- if (this.sha1) return;
3663
- this.sha1 = await this.digest(script);
4219
+ init(script) {
4220
+ if (!this.initPromise) {
4221
+ this.initPromise = this.digest(script).then((sha1) => {
4222
+ this.sha1 = sha1;
4223
+ });
4224
+ }
4225
+ return this.initPromise;
3664
4226
  }
3665
4227
  /**
3666
4228
  * Send an `EVAL` command to redis.
@@ -3712,6 +4274,7 @@ var ScriptRO = class {
3712
4274
  * future major release.
3713
4275
  */
3714
4276
  sha1;
4277
+ initPromise;
3715
4278
  redis;
3716
4279
  constructor(redis, script) {
3717
4280
  this.redis = redis;
@@ -3719,9 +4282,13 @@ var ScriptRO = class {
3719
4282
  this.script = script;
3720
4283
  void this.init(script);
3721
4284
  }
3722
- async init(script) {
3723
- if (this.sha1) return;
3724
- this.sha1 = await this.digest(script);
4285
+ init(script) {
4286
+ if (!this.initPromise) {
4287
+ this.initPromise = this.digest(script).then((sha1) => {
4288
+ this.sha1 = sha1;
4289
+ });
4290
+ }
4291
+ return this.initPromise;
3725
4292
  }
3726
4293
  /**
3727
4294
  * Send an `EVAL_RO` command to redis.
@@ -3976,6 +4543,27 @@ var Redis = class {
3976
4543
  createScript(script, opts) {
3977
4544
  return opts?.readonly ? new ScriptRO(this, script) : new Script(this, script);
3978
4545
  }
4546
+ get search() {
4547
+ return {
4548
+ createIndex: (params) => {
4549
+ return createIndex(this.client, params);
4550
+ },
4551
+ index: (params) => {
4552
+ return initIndex(this.client, params);
4553
+ },
4554
+ alias: {
4555
+ list: () => {
4556
+ return listAliases(this.client);
4557
+ },
4558
+ add: ({ indexName, alias }) => {
4559
+ return addAlias(this.client, { indexName, alias });
4560
+ },
4561
+ delete: ({ alias }) => {
4562
+ return delAlias(this.client, { alias });
4563
+ }
4564
+ }
4565
+ };
4566
+ }
3979
4567
  /**
3980
4568
  * Create a new pipeline that allows you to send requests in bulk.
3981
4569
  *
@@ -4037,6 +4625,10 @@ var Redis = class {
4037
4625
  * @see https://redis.io/commands/bitpos
4038
4626
  */
4039
4627
  bitpos = (...args) => new BitPosCommand(args, this.opts).exec(this.client);
4628
+ /**
4629
+ * @see https://redis.io/commands/client-setinfo
4630
+ */
4631
+ clientSetinfo = (...args) => new ClientSetInfoCommand(args, this.opts).exec(this.client);
4040
4632
  /**
4041
4633
  * @see https://redis.io/commands/copy
4042
4634
  */
@@ -4201,6 +4793,14 @@ var Redis = class {
4201
4793
  * @see https://redis.io/commands/hgetall
4202
4794
  */
4203
4795
  hgetall = (...args) => new HGetAllCommand(args, this.opts).exec(this.client);
4796
+ /**
4797
+ * @see https://redis.io/commands/hgetdel
4798
+ */
4799
+ hgetdel = (...args) => new HGetDelCommand(args, this.opts).exec(this.client);
4800
+ /**
4801
+ * @see https://redis.io/commands/hgetex
4802
+ */
4803
+ hgetex = (...args) => new HGetExCommand(args, this.opts).exec(this.client);
4204
4804
  /**
4205
4805
  * @see https://redis.io/commands/hincrby
4206
4806
  */
@@ -4237,6 +4837,10 @@ var Redis = class {
4237
4837
  * @see https://redis.io/commands/hset
4238
4838
  */
4239
4839
  hset = (key, kv) => new HSetCommand([key, kv], this.opts).exec(this.client);
4840
+ /**
4841
+ * @see https://redis.io/commands/hsetex
4842
+ */
4843
+ hsetex = (...args) => new HSetExCommand(args, this.opts).exec(this.client);
4240
4844
  /**
4241
4845
  * @see https://redis.io/commands/hsetnx
4242
4846
  */
@@ -4455,6 +5059,10 @@ var Redis = class {
4455
5059
  * @see https://redis.io/commands/sinter
4456
5060
  */
4457
5061
  sinter = (...args) => new SInterCommand(args, this.opts).exec(this.client);
5062
+ /**
5063
+ * @see https://redis.io/commands/sintercard
5064
+ */
5065
+ sintercard = (...args) => new SInterCardCommand(args, this.opts).exec(this.client);
4458
5066
  /**
4459
5067
  * @see https://redis.io/commands/sinterstore
4460
5068
  */
@@ -4538,10 +5146,18 @@ var Redis = class {
4538
5146
  * @see https://redis.io/commands/xack
4539
5147
  */
4540
5148
  xack = (...args) => new XAckCommand(args, this.opts).exec(this.client);
5149
+ /**
5150
+ * @see https://redis.io/commands/xackdel
5151
+ */
5152
+ xackdel = (...args) => new XAckDelCommand(args, this.opts).exec(this.client);
4541
5153
  /**
4542
5154
  * @see https://redis.io/commands/xdel
4543
5155
  */
4544
5156
  xdel = (...args) => new XDelCommand(args, this.opts).exec(this.client);
5157
+ /**
5158
+ * @see https://redis.io/commands/xdelex
5159
+ */
5160
+ xdelex = (...args) => new XDelExCommand(args, this.opts).exec(this.client);
4545
5161
  /**
4546
5162
  * @see https://redis.io/commands/xgroup
4547
5163
  */
@@ -4683,9 +5299,10 @@ var Redis = class {
4683
5299
  };
4684
5300
 
4685
5301
  // version.ts
4686
- var VERSION = "v1.36.1";
5302
+ var VERSION = "v1.30.2";
4687
5303
 
4688
5304
  exports.HttpClient = HttpClient;
4689
5305
  exports.Redis = Redis;
5306
+ exports.SearchIndex = SearchIndex;
4690
5307
  exports.VERSION = VERSION;
4691
5308
  exports.error_exports = error_exports;