@valbuild/core 0.82.0 → 0.84.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 (27) hide show
  1. package/dist/declarations/src/index.d.ts +3 -1
  2. package/dist/declarations/src/{preview.d.ts → render.d.ts} +5 -5
  3. package/dist/declarations/src/router.d.ts +24 -0
  4. package/dist/declarations/src/schema/array.d.ts +6 -6
  5. package/dist/declarations/src/schema/boolean.d.ts +2 -2
  6. package/dist/declarations/src/schema/date.d.ts +2 -2
  7. package/dist/declarations/src/schema/file.d.ts +2 -2
  8. package/dist/declarations/src/schema/image.d.ts +2 -2
  9. package/dist/declarations/src/schema/index.d.ts +8 -4
  10. package/dist/declarations/src/schema/keyOf.d.ts +12 -4
  11. package/dist/declarations/src/schema/literal.d.ts +2 -2
  12. package/dist/declarations/src/schema/number.d.ts +2 -2
  13. package/dist/declarations/src/schema/object.d.ts +2 -2
  14. package/dist/declarations/src/schema/record.d.ts +13 -8
  15. package/dist/declarations/src/schema/richtext.d.ts +2 -2
  16. package/dist/declarations/src/schema/string.d.ts +2 -2
  17. package/dist/declarations/src/schema/union.d.ts +2 -2
  18. package/dist/{index-bcc230b2.esm.js → index-396ad310.esm.js} +523 -234
  19. package/dist/{index-74fe6f44.cjs.prod.js → index-a820d34c.cjs.prod.js} +523 -234
  20. package/dist/{index-5a7e1014.cjs.dev.js → index-f6af10b1.cjs.dev.js} +523 -234
  21. package/dist/valbuild-core.cjs.dev.js +1 -1
  22. package/dist/valbuild-core.cjs.prod.js +1 -1
  23. package/dist/valbuild-core.esm.js +1 -1
  24. package/package.json +1 -1
  25. package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
  26. package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
  27. package/patch/dist/valbuild-core-patch.esm.js +2 -2
@@ -191,7 +191,7 @@ var Schema = /*#__PURE__*/function () {
191
191
  }
192
192
  return _createClass(Schema, [{
193
193
  key: "executeCustomValidateFunctions",
194
- value: function executeCustomValidateFunctions(src, customValidateFunctions) {
194
+ value: function executeCustomValidateFunctions(src, customValidateFunctions, ctx) {
195
195
  var errors = [];
196
196
  var _iterator = result._createForOfIteratorHelper(customValidateFunctions),
197
197
  _step;
@@ -199,7 +199,7 @@ var Schema = /*#__PURE__*/function () {
199
199
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
200
200
  var customValidateFunction = _step.value;
201
201
  try {
202
- var result$1 = customValidateFunction(src);
202
+ var result$1 = customValidateFunction(src, ctx);
203
203
  if (result$1) {
204
204
  errors.push({
205
205
  message: result$1,
@@ -405,7 +405,9 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
405
405
  }, {
406
406
  key: "executeValidate",
407
407
  value: function executeValidate(path, src) {
408
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
408
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
409
+ path: path
410
+ });
409
411
  if (this.opt && (src === null || src === undefined)) {
410
412
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
411
413
  }
@@ -579,8 +581,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
579
581
  };
580
582
  }
581
583
  }, {
582
- key: "executePreview",
583
- value: function executePreview() {
584
+ key: "executeRender",
585
+ value: function executeRender() {
584
586
  return {};
585
587
  }
586
588
  }]);
@@ -668,6 +670,170 @@ function unsafeCreateSourcePath(path, itemKey) {
668
670
  return "".concat(path).concat(Internal.ModuleFilePathSep).concat(JSON.stringify(itemKey));
669
671
  }
670
672
 
673
+ var StringSchema = /*#__PURE__*/function (_Schema) {
674
+ function StringSchema(options) {
675
+ var _this;
676
+ var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
677
+ var isRaw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
678
+ var customValidateFunctions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
679
+ _classCallCheck(this, StringSchema);
680
+ _this = _callSuper(this, StringSchema);
681
+ _this.options = options;
682
+ _this.opt = opt;
683
+ _this.isRaw = isRaw;
684
+ _this.customValidateFunctions = customValidateFunctions;
685
+ return _this;
686
+ }
687
+
688
+ /**
689
+ * @deprecated Use `minLength` instead
690
+ */
691
+ _inherits(StringSchema, _Schema);
692
+ return _createClass(StringSchema, [{
693
+ key: "min",
694
+ value: function min(minLength) {
695
+ return this.minLength(minLength);
696
+ }
697
+ }, {
698
+ key: "minLength",
699
+ value: function minLength(_minLength) {
700
+ return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
701
+ minLength: _minLength
702
+ }), this.opt, this.isRaw);
703
+ }
704
+
705
+ /**
706
+ * @deprecated Use `maxLength` instead
707
+ */
708
+ }, {
709
+ key: "max",
710
+ value: function max(maxLength) {
711
+ return this.maxLength(maxLength);
712
+ }
713
+ }, {
714
+ key: "maxLength",
715
+ value: function maxLength(_maxLength) {
716
+ return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
717
+ maxLength: _maxLength
718
+ }), this.opt, this.isRaw);
719
+ }
720
+ }, {
721
+ key: "regexp",
722
+ value: function regexp(_regexp, message) {
723
+ return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
724
+ regexp: _regexp,
725
+ regExpMessage: message
726
+ }), this.opt, this.isRaw);
727
+ }
728
+ }, {
729
+ key: "validate",
730
+ value: function validate(validationFunction) {
731
+ return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions.concat(validationFunction));
732
+ }
733
+ }, {
734
+ key: "executeValidate",
735
+ value: function executeValidate(path, src) {
736
+ var _this$options, _this$options2, _this$options3;
737
+ var errors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
738
+ path: path
739
+ });
740
+ if (this.opt && (src === null || src === undefined)) {
741
+ return errors.length > 0 ? _defineProperty({}, path, errors) : false;
742
+ }
743
+ if (typeof src !== "string") {
744
+ return _defineProperty({}, path, [{
745
+ message: "Expected 'string', got '".concat(_typeof(src), "'"),
746
+ value: src
747
+ }]);
748
+ }
749
+ if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.maxLength && src.length > this.options.maxLength) {
750
+ errors.push({
751
+ message: "Expected string to be at most ".concat(this.options.maxLength, " characters long, got ").concat(src.length),
752
+ value: src
753
+ });
754
+ }
755
+ if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.minLength && src.length < this.options.minLength) {
756
+ errors.push({
757
+ message: "Expected string to be at least ".concat(this.options.minLength, " characters long, got ").concat(src.length),
758
+ value: src
759
+ });
760
+ }
761
+ if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.regexp && !this.options.regexp.test(src)) {
762
+ errors.push({
763
+ message: this.options.regExpMessage || "Expected string to match reg exp: ".concat(this.options.regexp.toString(), ", got '").concat(src, "'"),
764
+ value: src
765
+ });
766
+ }
767
+ if (errors.length > 0) {
768
+ return _defineProperty({}, path, errors);
769
+ }
770
+ return false;
771
+ }
772
+ }, {
773
+ key: "executeAssert",
774
+ value: function executeAssert(path, src) {
775
+ if (this.opt && src === null) {
776
+ return {
777
+ success: true,
778
+ data: src
779
+ };
780
+ }
781
+ if (typeof src === "string") {
782
+ return {
783
+ success: true,
784
+ data: src
785
+ };
786
+ }
787
+ return {
788
+ success: false,
789
+ errors: _defineProperty({}, path, [{
790
+ message: "Expected 'string', got '".concat(_typeof(src), "'"),
791
+ typeError: true
792
+ }])
793
+ };
794
+ }
795
+ }, {
796
+ key: "nullable",
797
+ value: function nullable() {
798
+ return new StringSchema(this.options, true, this.isRaw);
799
+ }
800
+ }, {
801
+ key: "raw",
802
+ value: function raw() {
803
+ return new StringSchema(this.options, this.opt, true);
804
+ }
805
+ }, {
806
+ key: "executeSerialize",
807
+ value: function executeSerialize() {
808
+ var _this$options4, _this$options5, _this$options6, _this$customValidateF, _this$customValidateF2;
809
+ return {
810
+ type: "string",
811
+ options: {
812
+ maxLength: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.maxLength,
813
+ minLength: (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.minLength,
814
+ regexp: ((_this$options6 = this.options) === null || _this$options6 === void 0 ? void 0 : _this$options6.regexp) && {
815
+ message: this.options.regExpMessage,
816
+ source: this.options.regexp.source,
817
+ flags: this.options.regexp.flags
818
+ },
819
+ customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
820
+ },
821
+ opt: this.opt,
822
+ raw: this.isRaw,
823
+ customValidate: this.customValidateFunctions && ((_this$customValidateF2 = this.customValidateFunctions) === null || _this$customValidateF2 === void 0 ? void 0 : _this$customValidateF2.length) > 0
824
+ };
825
+ }
826
+ }, {
827
+ key: "executeRender",
828
+ value: function executeRender() {
829
+ return {};
830
+ }
831
+ }]);
832
+ }(Schema);
833
+ var string = function string(options) {
834
+ return new StringSchema(options);
835
+ };
836
+
671
837
  var ObjectSchema = /*#__PURE__*/function (_Schema) {
672
838
  function ObjectSchema(items) {
673
839
  var _this;
@@ -690,7 +856,9 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
690
856
  key: "executeValidate",
691
857
  value: function executeValidate(path, src) {
692
858
  var error = false;
693
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
859
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
860
+ path: path
861
+ });
694
862
  if (this.opt && (src === null || src === undefined)) {
695
863
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
696
864
  }
@@ -825,8 +993,8 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
825
993
  };
826
994
  }
827
995
  }, {
828
- key: "executePreview",
829
- value: function executePreview(sourcePath, src) {
996
+ key: "executeRender",
997
+ value: function executeRender(sourcePath, src) {
830
998
  var res = {};
831
999
  if (src === null) {
832
1000
  return res;
@@ -837,7 +1005,7 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
837
1005
  continue;
838
1006
  }
839
1007
  var subPath = unsafeCreateSourcePath(sourcePath, _key3);
840
- var itemResult = this.items[_key3]["executePreview"](subPath, itemSrc);
1008
+ var itemResult = this.items[_key3]["executeRender"](subPath, itemSrc);
841
1009
  for (var keyS in itemResult) {
842
1010
  var _key4 = keyS;
843
1011
  res[_key4] = itemResult[_key4];
@@ -850,6 +1018,11 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
850
1018
  var object = function object(schema) {
851
1019
  return new ObjectSchema(schema);
852
1020
  };
1021
+ object({
1022
+ get test() {
1023
+ return string();
1024
+ }
1025
+ });
853
1026
 
854
1027
  var ArraySchema = /*#__PURE__*/function (_Schema) {
855
1028
  function ArraySchema(item) {
@@ -858,7 +1031,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
858
1031
  var customValidateFunctions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
859
1032
  _classCallCheck(this, ArraySchema);
860
1033
  _this = _callSuper(this, ArraySchema);
861
- _defineProperty(_this, "previewInput", null);
1034
+ _defineProperty(_this, "renderInput", null);
862
1035
  _this.item = item;
863
1036
  _this.opt = opt;
864
1037
  _this.customValidateFunctions = customValidateFunctions;
@@ -954,8 +1127,8 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
954
1127
  };
955
1128
  }
956
1129
  }, {
957
- key: "executePreview",
958
- value: function executePreview(sourcePath, src) {
1130
+ key: "executeRender",
1131
+ value: function executeRender(sourcePath, src) {
959
1132
  var res = {};
960
1133
  if (src === null) {
961
1134
  return res;
@@ -967,16 +1140,16 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
967
1140
  continue;
968
1141
  }
969
1142
  var subPath = unsafeCreateSourcePath(sourcePath, key);
970
- var itemResult = this.item["executePreview"](subPath, itemSrc);
1143
+ var itemResult = this.item["executeRender"](subPath, itemSrc);
971
1144
  for (var keyS in itemResult) {
972
1145
  var _key = keyS;
973
1146
  res[_key] = itemResult[_key];
974
1147
  }
975
1148
  }
976
- if (this.previewInput) {
977
- var _this$previewInput = this.previewInput,
978
- prepare = _this$previewInput.prepare,
979
- layout = _this$previewInput.layout;
1149
+ if (this.renderInput) {
1150
+ var _this$renderInput = this.renderInput,
1151
+ select = _this$renderInput.select,
1152
+ layout = _this$renderInput.layout;
980
1153
  if (layout !== "list") {
981
1154
  res[sourcePath] = {
982
1155
  status: "error",
@@ -991,12 +1164,12 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
991
1164
  parent: "array",
992
1165
  items: src.map(function (val) {
993
1166
  // NB NB: display is actually defined by the user
994
- var _prepare = prepare({
1167
+ var _select = select({
995
1168
  val: val
996
1169
  }),
997
- title = _prepare.title,
998
- subtitle = _prepare.subtitle,
999
- image = _prepare.image;
1170
+ title = _select.title,
1171
+ subtitle = _select.subtitle,
1172
+ image = _select.image;
1000
1173
  return {
1001
1174
  title: title,
1002
1175
  subtitle: subtitle,
@@ -1015,9 +1188,9 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1015
1188
  return res;
1016
1189
  }
1017
1190
  }, {
1018
- key: "preview",
1019
- value: function preview(input) {
1020
- this.previewInput = input;
1191
+ key: "render",
1192
+ value: function render(input) {
1193
+ this.renderInput = input;
1021
1194
  return this;
1022
1195
  }
1023
1196
  }]);
@@ -1047,7 +1220,9 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
1047
1220
  }, {
1048
1221
  key: "executeValidate",
1049
1222
  value: function executeValidate(path, src) {
1050
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
1223
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
1224
+ path: path
1225
+ });
1051
1226
  if (this.opt && (src === null || src === undefined)) {
1052
1227
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
1053
1228
  }
@@ -1117,8 +1292,8 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
1117
1292
  };
1118
1293
  }
1119
1294
  }, {
1120
- key: "executePreview",
1121
- value: function executePreview() {
1295
+ key: "executeRender",
1296
+ value: function executeRender() {
1122
1297
  return {};
1123
1298
  }
1124
1299
  }]);
@@ -1149,7 +1324,9 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1149
1324
  }, {
1150
1325
  key: "executeValidate",
1151
1326
  value: function executeValidate(path, src) {
1152
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
1327
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
1328
+ path: path
1329
+ });
1153
1330
  var unknownSrc = src;
1154
1331
  if (this.opt && unknownSrc === null) {
1155
1332
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
@@ -1464,8 +1641,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1464
1641
  };
1465
1642
  }
1466
1643
  }, {
1467
- key: "executePreview",
1468
- value: function executePreview(sourcePath, src) {
1644
+ key: "executeRender",
1645
+ value: function executeRender(sourcePath, src) {
1469
1646
  var res = {};
1470
1647
  if (src === null) {
1471
1648
  return res;
@@ -1487,7 +1664,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1487
1664
  return false;
1488
1665
  });
1489
1666
  if (thisSchema) {
1490
- var itemResult = thisSchema["executePreview"](sourcePath, src);
1667
+ var itemResult = thisSchema["executeRender"](sourcePath, src);
1491
1668
  for (var keyS in itemResult) {
1492
1669
  var _key3 = keyS;
1493
1670
  res[_key3] = itemResult[_key3];
@@ -1542,7 +1719,9 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1542
1719
  }, {
1543
1720
  key: "executeValidate",
1544
1721
  value: function executeValidate(path, src) {
1545
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
1722
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
1723
+ path: path
1724
+ });
1546
1725
  if (this.opt && (src === null || src === undefined)) {
1547
1726
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
1548
1727
  }
@@ -1724,8 +1903,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1724
1903
  };
1725
1904
  }
1726
1905
  }, {
1727
- key: "executePreview",
1728
- value: function executePreview() {
1906
+ key: "executeRender",
1907
+ value: function executeRender() {
1729
1908
  return {};
1730
1909
  }
1731
1910
  }]);
@@ -1769,7 +1948,9 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
1769
1948
  }, {
1770
1949
  key: "executeValidate",
1771
1950
  value: function executeValidate(path, src) {
1772
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
1951
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
1952
+ path: path
1953
+ });
1773
1954
  var assertRes = this.executeAssert(path, src);
1774
1955
  if (!assertRes.success) {
1775
1956
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : assertRes.errors;
@@ -2182,8 +2363,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2182
2363
  };
2183
2364
  }
2184
2365
  }, {
2185
- key: "executePreview",
2186
- value: function executePreview() {
2366
+ key: "executeRender",
2367
+ value: function executeRender() {
2187
2368
  return {};
2188
2369
  }
2189
2370
  }]);
@@ -2197,12 +2378,14 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2197
2378
  var _this;
2198
2379
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2199
2380
  var customValidateFunctions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
2381
+ var currentRouter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
2200
2382
  _classCallCheck(this, RecordSchema);
2201
2383
  _this = _callSuper(this, RecordSchema);
2202
- _defineProperty(_this, "previewInput", null);
2384
+ _defineProperty(_this, "renderInput", null);
2203
2385
  _this.item = item;
2204
2386
  _this.opt = opt;
2205
2387
  _this.customValidateFunctions = customValidateFunctions;
2388
+ _this.currentRouter = currentRouter;
2206
2389
  return _this;
2207
2390
  }
2208
2391
  _inherits(RecordSchema, _Schema);
@@ -2216,7 +2399,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2216
2399
  value: function executeValidate(path, src) {
2217
2400
  var _this2 = this;
2218
2401
  var error = false;
2219
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
2402
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
2403
+ path: path
2404
+ });
2220
2405
  if (this.opt && (src === null || src === undefined)) {
2221
2406
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
2222
2407
  }
@@ -2235,6 +2420,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2235
2420
  message: "Expected 'object', got 'array'"
2236
2421
  }]));
2237
2422
  }
2423
+ var routerValidations = this.getRouterValidations(path, src);
2424
+ if (routerValidations) {
2425
+ return routerValidations;
2426
+ }
2238
2427
  var _iterator = result._createForOfIteratorHelper(customValidationErrors),
2239
2428
  _step;
2240
2429
  try {
@@ -2304,20 +2493,68 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2304
2493
  value: function nullable() {
2305
2494
  return new RecordSchema(this.item, true);
2306
2495
  }
2496
+ }, {
2497
+ key: "router",
2498
+ value: function router(_router) {
2499
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router);
2500
+ }
2501
+ }, {
2502
+ key: "getRouterValidations",
2503
+ value: function getRouterValidations(path, src) {
2504
+ if (!this.currentRouter) {
2505
+ return false;
2506
+ }
2507
+ if (src === null) {
2508
+ return false;
2509
+ }
2510
+ var _splitModuleFilePathA = splitModuleFilePathAndModulePath(path),
2511
+ _splitModuleFilePathA2 = _slicedToArray(_splitModuleFilePathA, 2),
2512
+ moduleFilePath = _splitModuleFilePathA2[0],
2513
+ modulePath = _splitModuleFilePathA2[1];
2514
+ if (modulePath) {
2515
+ return _defineProperty({}, path, [{
2516
+ message: "This field was configured as a router, but it is not defined at the root of the module",
2517
+ schemaError: true
2518
+ }]);
2519
+ }
2520
+ var routerValidations = this.currentRouter.validate(moduleFilePath, Object.keys(src));
2521
+ if (routerValidations.length > 0) {
2522
+ return Object.fromEntries(routerValidations.map(function (validation) {
2523
+ if (!validation.error.urlPath) {
2524
+ return [path, [{
2525
+ message: "Router validation error: ".concat(validation.error.message, " has no url path"),
2526
+ schemaError: true
2527
+ }]];
2528
+ }
2529
+ var subPath = createValPathOfItem(path, validation.error.urlPath);
2530
+ if (!subPath) {
2531
+ return [path, [{
2532
+ message: "Could not create path for router validation error",
2533
+ schemaError: true
2534
+ }]];
2535
+ }
2536
+ return [subPath, [{
2537
+ message: validation.error.message
2538
+ }]];
2539
+ }));
2540
+ }
2541
+ return false;
2542
+ }
2307
2543
  }, {
2308
2544
  key: "executeSerialize",
2309
2545
  value: function executeSerialize() {
2310
- var _this$customValidateF;
2546
+ var _this$currentRouter, _this$customValidateF;
2311
2547
  return {
2312
2548
  type: "record",
2313
2549
  item: this.item["executeSerialize"](),
2314
2550
  opt: this.opt,
2551
+ router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
2315
2552
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
2316
2553
  };
2317
2554
  }
2318
2555
  }, {
2319
- key: "executePreview",
2320
- value: function executePreview(sourcePath, src) {
2556
+ key: "executeRender",
2557
+ value: function executeRender(sourcePath, src) {
2321
2558
  var res = {};
2322
2559
  if (src === null) {
2323
2560
  return res;
@@ -2328,16 +2565,16 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2328
2565
  continue;
2329
2566
  }
2330
2567
  var subPath = unsafeCreateSourcePath(sourcePath, key);
2331
- var itemResult = this.item["executePreview"](subPath, itemSrc);
2568
+ var itemResult = this.item["executeRender"](subPath, itemSrc);
2332
2569
  for (var keyS in itemResult) {
2333
2570
  var _key = keyS;
2334
2571
  res[_key] = itemResult[_key];
2335
2572
  }
2336
2573
  }
2337
- if (this.previewInput) {
2338
- var _this$previewInput = this.previewInput,
2339
- prepare = _this$previewInput.prepare,
2340
- layout = _this$previewInput.layout;
2574
+ if (this.renderInput) {
2575
+ var _this$renderInput = this.renderInput,
2576
+ prepare = _this$renderInput.select,
2577
+ layout = _this$renderInput.layout;
2341
2578
  if (layout !== "list") {
2342
2579
  res[sourcePath] = {
2343
2580
  status: "error",
@@ -2350,10 +2587,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2350
2587
  data: {
2351
2588
  layout: "list",
2352
2589
  parent: "record",
2353
- items: Object.entries(src).map(function (_ref7) {
2354
- var _ref8 = _slicedToArray(_ref7, 2),
2355
- key = _ref8[0],
2356
- val = _ref8[1];
2590
+ items: Object.entries(src).map(function (_ref8) {
2591
+ var _ref9 = _slicedToArray(_ref8, 2),
2592
+ key = _ref9[0],
2593
+ val = _ref9[1];
2357
2594
  // NB NB: display is actually defined by the user
2358
2595
  var _prepare = prepare({
2359
2596
  key: key,
@@ -2380,9 +2617,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2380
2617
  return res;
2381
2618
  }
2382
2619
  }, {
2383
- key: "preview",
2384
- value: function preview(input) {
2385
- this.previewInput = input;
2620
+ key: "render",
2621
+ value: function render(input) {
2622
+ this.renderInput = input;
2386
2623
  return this;
2387
2624
  }
2388
2625
  }]);
@@ -2913,7 +3150,9 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
2913
3150
  key: "executeValidate",
2914
3151
  value: function executeValidate(path, src) {
2915
3152
  var _this$options, _this$options2;
2916
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
3153
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
3154
+ path: path
3155
+ });
2917
3156
  if (this.opt && (src === null || src === undefined)) {
2918
3157
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
2919
3158
  }
@@ -3003,8 +3242,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
3003
3242
  };
3004
3243
  }
3005
3244
  }, {
3006
- key: "executePreview",
3007
- value: function executePreview() {
3245
+ key: "executeRender",
3246
+ value: function executeRender() {
3008
3247
  return {};
3009
3248
  }
3010
3249
  }]);
@@ -3013,168 +3252,6 @@ var number = function number(options) {
3013
3252
  return new NumberSchema(options);
3014
3253
  };
3015
3254
 
3016
- var StringSchema = /*#__PURE__*/function (_Schema) {
3017
- function StringSchema(options) {
3018
- var _this;
3019
- var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3020
- var isRaw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3021
- var customValidateFunctions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
3022
- _classCallCheck(this, StringSchema);
3023
- _this = _callSuper(this, StringSchema);
3024
- _this.options = options;
3025
- _this.opt = opt;
3026
- _this.isRaw = isRaw;
3027
- _this.customValidateFunctions = customValidateFunctions;
3028
- return _this;
3029
- }
3030
-
3031
- /**
3032
- * @deprecated Use `minLength` instead
3033
- */
3034
- _inherits(StringSchema, _Schema);
3035
- return _createClass(StringSchema, [{
3036
- key: "min",
3037
- value: function min(minLength) {
3038
- return this.minLength(minLength);
3039
- }
3040
- }, {
3041
- key: "minLength",
3042
- value: function minLength(_minLength) {
3043
- return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
3044
- minLength: _minLength
3045
- }), this.opt, this.isRaw);
3046
- }
3047
-
3048
- /**
3049
- * @deprecated Use `maxLength` instead
3050
- */
3051
- }, {
3052
- key: "max",
3053
- value: function max(maxLength) {
3054
- return this.maxLength(maxLength);
3055
- }
3056
- }, {
3057
- key: "maxLength",
3058
- value: function maxLength(_maxLength) {
3059
- return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
3060
- maxLength: _maxLength
3061
- }), this.opt, this.isRaw);
3062
- }
3063
- }, {
3064
- key: "regexp",
3065
- value: function regexp(_regexp, message) {
3066
- return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
3067
- regexp: _regexp,
3068
- regExpMessage: message
3069
- }), this.opt, this.isRaw);
3070
- }
3071
- }, {
3072
- key: "validate",
3073
- value: function validate(validationFunction) {
3074
- return new StringSchema(this.options, this.opt, this.isRaw, this.customValidateFunctions.concat(validationFunction));
3075
- }
3076
- }, {
3077
- key: "executeValidate",
3078
- value: function executeValidate(path, src) {
3079
- var _this$options, _this$options2, _this$options3;
3080
- var errors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
3081
- if (this.opt && (src === null || src === undefined)) {
3082
- return errors.length > 0 ? _defineProperty({}, path, errors) : false;
3083
- }
3084
- if (typeof src !== "string") {
3085
- return _defineProperty({}, path, [{
3086
- message: "Expected 'string', got '".concat(_typeof(src), "'"),
3087
- value: src
3088
- }]);
3089
- }
3090
- if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.maxLength && src.length > this.options.maxLength) {
3091
- errors.push({
3092
- message: "Expected string to be at most ".concat(this.options.maxLength, " characters long, got ").concat(src.length),
3093
- value: src
3094
- });
3095
- }
3096
- if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.minLength && src.length < this.options.minLength) {
3097
- errors.push({
3098
- message: "Expected string to be at least ".concat(this.options.minLength, " characters long, got ").concat(src.length),
3099
- value: src
3100
- });
3101
- }
3102
- if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.regexp && !this.options.regexp.test(src)) {
3103
- errors.push({
3104
- message: this.options.regExpMessage || "Expected string to match reg exp: ".concat(this.options.regexp.toString(), ", got '").concat(src, "'"),
3105
- value: src
3106
- });
3107
- }
3108
- if (errors.length > 0) {
3109
- return _defineProperty({}, path, errors);
3110
- }
3111
- return false;
3112
- }
3113
- }, {
3114
- key: "executeAssert",
3115
- value: function executeAssert(path, src) {
3116
- if (this.opt && src === null) {
3117
- return {
3118
- success: true,
3119
- data: src
3120
- };
3121
- }
3122
- if (typeof src === "string") {
3123
- return {
3124
- success: true,
3125
- data: src
3126
- };
3127
- }
3128
- return {
3129
- success: false,
3130
- errors: _defineProperty({}, path, [{
3131
- message: "Expected 'string', got '".concat(_typeof(src), "'"),
3132
- typeError: true
3133
- }])
3134
- };
3135
- }
3136
- }, {
3137
- key: "nullable",
3138
- value: function nullable() {
3139
- return new StringSchema(this.options, true, this.isRaw);
3140
- }
3141
- }, {
3142
- key: "raw",
3143
- value: function raw() {
3144
- return new StringSchema(this.options, this.opt, true);
3145
- }
3146
- }, {
3147
- key: "executeSerialize",
3148
- value: function executeSerialize() {
3149
- var _this$options4, _this$options5, _this$options6, _this$customValidateF, _this$customValidateF2;
3150
- return {
3151
- type: "string",
3152
- options: {
3153
- maxLength: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.maxLength,
3154
- minLength: (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.minLength,
3155
- regexp: ((_this$options6 = this.options) === null || _this$options6 === void 0 ? void 0 : _this$options6.regexp) && {
3156
- message: this.options.regExpMessage,
3157
- source: this.options.regexp.source,
3158
- flags: this.options.regexp.flags
3159
- },
3160
- customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
3161
- },
3162
- opt: this.opt,
3163
- raw: this.isRaw,
3164
- customValidate: this.customValidateFunctions && ((_this$customValidateF2 = this.customValidateFunctions) === null || _this$customValidateF2 === void 0 ? void 0 : _this$customValidateF2.length) > 0
3165
- };
3166
- }
3167
- }, {
3168
- key: "executePreview",
3169
- value: function executePreview() {
3170
- return {};
3171
- }
3172
- }]);
3173
- }(Schema);
3174
- var string = function string(options) {
3175
- return new StringSchema(options);
3176
- };
3177
-
3178
3255
  var BooleanSchema = /*#__PURE__*/function (_Schema) {
3179
3256
  function BooleanSchema() {
3180
3257
  var _this;
@@ -3254,8 +3331,8 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
3254
3331
  };
3255
3332
  }
3256
3333
  }, {
3257
- key: "executePreview",
3258
- value: function executePreview() {
3334
+ key: "executeRender",
3335
+ value: function executeRender() {
3259
3336
  return {};
3260
3337
  }
3261
3338
  }]);
@@ -3286,7 +3363,9 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
3286
3363
  }, {
3287
3364
  key: "executeValidate",
3288
3365
  value: function executeValidate(path, src) {
3289
- var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions);
3366
+ var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
3367
+ path: path
3368
+ });
3290
3369
  if (this.opt && (src === null || src === undefined)) {
3291
3370
  return customValidationErrors.length > 0 ? _defineProperty({}, path, customValidationErrors) : false;
3292
3371
  }
@@ -3298,7 +3377,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
3298
3377
  var serializedSchema = this.schema;
3299
3378
  if (!(serializedSchema.type === "object" || serializedSchema.type === "record")) {
3300
3379
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
3301
- message: "Schema in keyOf must be an 'object' or 'record'. Found '".concat(serializedSchema.type, "'")
3380
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3381
+ message: "Schema in keyOf must be an 'object' or 'record'. Found '".concat(serializedSchema.type || "unknown", "'")
3302
3382
  }]));
3303
3383
  }
3304
3384
  if (serializedSchema.opt && (src === null || src === undefined)) {
@@ -3310,7 +3390,7 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
3310
3390
  }]));
3311
3391
  }
3312
3392
  if (serializedSchema.type === "object") {
3313
- var keys = Object.keys(serializedSchema.items);
3393
+ var keys = serializedSchema.keys;
3314
3394
  if (!keys.includes(src)) {
3315
3395
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
3316
3396
  message: "Value of keyOf (object) must be: ".concat(keys.join(", "), ". Found: ").concat(src)
@@ -3370,7 +3450,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
3370
3450
  return {
3371
3451
  success: false,
3372
3452
  errors: _defineProperty({}, path, [{
3373
- message: "Schema of first argument must be either: 'array', 'object' or 'record'. Found '".concat(serializedSchema.type, "'"),
3453
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3454
+ message: "Schema of first argument must be either: 'array', 'object' or 'record'. Found '".concat(serializedSchema.type || "unknown", "'"),
3374
3455
  typeError: true
3375
3456
  }])
3376
3457
  };
@@ -3388,7 +3469,7 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
3388
3469
  // and there it also makes sense to check the actual string values (i.e. that it is not just a string) since
3389
3470
  // missing one would lead to a runtime error. At least this is what we are thinking currently.
3390
3471
  if (serializedSchema.type === "object") {
3391
- var keys = Object.keys(serializedSchema.items);
3472
+ var keys = serializedSchema.keys;
3392
3473
  if (!keys.includes(src)) {
3393
3474
  return {
3394
3475
  success: false,
@@ -3427,10 +3508,11 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
3427
3508
  values = "string";
3428
3509
  break;
3429
3510
  case "object":
3430
- values = Object.keys(serializedSchema.items);
3511
+ values = serializedSchema.keys;
3431
3512
  break;
3432
3513
  default:
3433
- throw new Error("Cannot serialize keyOf schema with selector of type '".concat(serializedSchema.type, "'. keyOf must be used with a Val Module."));
3514
+ throw new Error(// eslint-disable-next-line @typescript-eslint/no-explicit-any
3515
+ "Cannot serialize keyOf schema with selector of type '".concat(serializedSchema.type || "unknown", "'"));
3434
3516
  }
3435
3517
  return {
3436
3518
  type: "keyOf",
@@ -3442,15 +3524,34 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
3442
3524
  };
3443
3525
  }
3444
3526
  }, {
3445
- key: "executePreview",
3446
- value: function executePreview() {
3527
+ key: "executeRender",
3528
+ value: function executeRender() {
3447
3529
  return {};
3448
3530
  }
3449
3531
  }]);
3450
3532
  }(Schema);
3451
3533
  var keyOf = function keyOf(valModule) {
3452
- var _valModule$GetSchema;
3453
- return new KeyOfSchema(valModule === null || valModule === void 0 || (_valModule$GetSchema = valModule[GetSchema]) === null || _valModule$GetSchema === void 0 ? void 0 : _valModule$GetSchema["executeSerialize"](), getValPath(valModule));
3534
+ var refSchema = valModule === null || valModule === void 0 ? void 0 : valModule[GetSchema];
3535
+ var serializedRefSchema = undefined;
3536
+ if (refSchema instanceof ObjectSchema) {
3537
+ var keys = [];
3538
+ try {
3539
+ keys = Object.keys((refSchema === null || refSchema === void 0 ? void 0 : refSchema["items"]) || {});
3540
+ } catch (e) {
3541
+ // ignore this error here
3542
+ }
3543
+ serializedRefSchema = {
3544
+ type: "object",
3545
+ keys: keys,
3546
+ opt: refSchema === null || refSchema === void 0 ? void 0 : refSchema["opt"]
3547
+ };
3548
+ } else if (refSchema instanceof RecordSchema) {
3549
+ serializedRefSchema = {
3550
+ type: "record",
3551
+ opt: refSchema === null || refSchema === void 0 ? void 0 : refSchema["opt"]
3552
+ };
3553
+ }
3554
+ return new KeyOfSchema(serializedRefSchema, getValPath(valModule));
3454
3555
  };
3455
3556
 
3456
3557
  var DateSchema = /*#__PURE__*/function (_Schema) {
@@ -3585,8 +3686,8 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
3585
3686
  };
3586
3687
  }
3587
3688
  }, {
3588
- key: "executePreview",
3589
- value: function executePreview() {
3689
+ key: "executeRender",
3690
+ value: function executeRender() {
3590
3691
  return {};
3591
3692
  }
3592
3693
  }]);
@@ -5089,6 +5190,193 @@ function deserializeSchema(serialized) {
5089
5190
  }
5090
5191
  }
5091
5192
 
5193
+ // Helper function to validate a URL path against a route pattern
5194
+ function validateUrlAgainstPattern(urlPath, routePattern) {
5195
+ // Remove leading slash and split URL path
5196
+ var urlSegments = urlPath.startsWith("/") ? urlPath.slice(1).split("/") : urlPath.split("/");
5197
+
5198
+ // Handle empty patterns (root route)
5199
+ if (routePattern.length === 0) {
5200
+ return {
5201
+ isValid: urlSegments.length === 0 || urlSegments.length === 1 && urlSegments[0] === "",
5202
+ expectedPath: "/"
5203
+ };
5204
+ }
5205
+
5206
+ // Check if segment counts match (accounting for optional segments and catch-all)
5207
+ var minSegments = 0;
5208
+ var maxSegments = 0;
5209
+ var hasCatchAll = false;
5210
+ var catchAllIndex = -1;
5211
+ for (var i = 0; i < routePattern.length; i++) {
5212
+ var segment = routePattern[i];
5213
+ if (segment.startsWith("[[") && segment.endsWith("]]")) {
5214
+ // Optional catch-all segment
5215
+ hasCatchAll = true;
5216
+ catchAllIndex = i;
5217
+ maxSegments = Infinity;
5218
+ } else if (segment.startsWith("[...") && segment.endsWith("]")) {
5219
+ // Required catch-all segment
5220
+ hasCatchAll = true;
5221
+ catchAllIndex = i;
5222
+ minSegments++;
5223
+ maxSegments = Infinity;
5224
+ } else if (segment.startsWith("[[") && segment.endsWith("]")) {
5225
+ // Optional segment
5226
+ maxSegments++;
5227
+ } else if (segment.startsWith("[") && segment.endsWith("]")) {
5228
+ // Required segment
5229
+ minSegments++;
5230
+ maxSegments++;
5231
+ } else {
5232
+ // Static segment
5233
+ minSegments++;
5234
+ maxSegments++;
5235
+ }
5236
+ }
5237
+
5238
+ // Check segment count
5239
+ if (urlSegments.length < minSegments || !hasCatchAll && urlSegments.length > maxSegments) {
5240
+ var expectedSegments = routePattern.map(function (seg) {
5241
+ if (seg.startsWith("[[") && seg.endsWith("]]")) {
5242
+ return "[optional:".concat(seg.slice(2, -2), "]");
5243
+ } else if (seg.startsWith("[...") && seg.endsWith("]")) {
5244
+ return "[...".concat(seg.slice(4, -1), "]");
5245
+ } else if (seg.startsWith("[[") && seg.endsWith("]")) {
5246
+ return "[optional:".concat(seg.slice(2, -1), "]");
5247
+ } else if (seg.startsWith("[") && seg.endsWith("]")) {
5248
+ return "[".concat(seg.slice(1, -1), "]");
5249
+ }
5250
+ return seg;
5251
+ }).join("/");
5252
+ return {
5253
+ isValid: false,
5254
+ expectedPath: "/".concat(expectedSegments)
5255
+ };
5256
+ }
5257
+
5258
+ // Validate each segment up to the catch-all or the end of the pattern
5259
+ var segmentsToValidate = hasCatchAll ? catchAllIndex : routePattern.length;
5260
+ for (var _i = 0; _i < segmentsToValidate; _i++) {
5261
+ var patternSegment = routePattern[_i];
5262
+ var urlSegment = urlSegments[_i];
5263
+
5264
+ // Handle optional segments
5265
+ if (patternSegment.startsWith("[[") && patternSegment.endsWith("]]")) {
5266
+ // Optional segment - can be empty or match
5267
+ if (urlSegment !== "" && urlSegment !== undefined) {
5268
+ // If provided, validate it's not empty
5269
+ if (urlSegment === "") {
5270
+ return {
5271
+ isValid: false,
5272
+ expectedPath: "/".concat(routePattern.join("/"))
5273
+ };
5274
+ }
5275
+ }
5276
+ } else if (patternSegment.startsWith("[") && patternSegment.endsWith("]")) {
5277
+ // Required dynamic segment - just check it's not empty
5278
+ if (urlSegment === "" || urlSegment === undefined) {
5279
+ return {
5280
+ isValid: false,
5281
+ expectedPath: "/".concat(routePattern.join("/"))
5282
+ };
5283
+ }
5284
+ } else {
5285
+ // Static segment - must match exactly
5286
+ if (patternSegment !== urlSegment) {
5287
+ return {
5288
+ isValid: false,
5289
+ expectedPath: "/".concat(routePattern.join("/"))
5290
+ };
5291
+ }
5292
+ }
5293
+ }
5294
+ return {
5295
+ isValid: true
5296
+ };
5297
+ }
5298
+
5299
+ // This router should not be in core package
5300
+ var nextAppRouter = {
5301
+ getRouterId: function getRouterId() {
5302
+ return "next-app-router";
5303
+ },
5304
+ validate: function validate(moduleFilePath, urlPaths) {
5305
+ var routePattern = parseNextJsRoutePattern(moduleFilePath);
5306
+ var errors = [];
5307
+ var _iterator = result._createForOfIteratorHelper(urlPaths),
5308
+ _step;
5309
+ try {
5310
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
5311
+ var urlPath = _step.value;
5312
+ var validation = validateUrlAgainstPattern(urlPath, routePattern);
5313
+ if (!validation.isValid) {
5314
+ errors.push({
5315
+ error: {
5316
+ message: "URL path \"".concat(urlPath, "\" does not match the route pattern for \"").concat(moduleFilePath, "\""),
5317
+ urlPath: urlPath,
5318
+ expectedPath: validation.expectedPath || null
5319
+ }
5320
+ });
5321
+ }
5322
+ }
5323
+ } catch (err) {
5324
+ _iterator.e(err);
5325
+ } finally {
5326
+ _iterator.f();
5327
+ }
5328
+ return errors;
5329
+ }
5330
+ };
5331
+
5332
+ /**
5333
+ * Parse Next.js route pattern from file path
5334
+ * Support multiple Next.js app directory structures:
5335
+ * - /app/blogs/[blog]/page.val.ts -> ["blogs", "[blog]"]
5336
+ * - /src/app/blogs/[blog]/page.val.ts -> ["blogs", "[blog]"]
5337
+ * - /pages/blogs/[blog].tsx -> ["blogs", "[blog]"] (Pages Router)
5338
+ * - /app/(group)/blogs/[blog]/page.val.ts -> ["blogs", "[blog]"] (with groups)
5339
+ * - /app/(.)feed/page.val.ts -> ["feed"] (interception route)
5340
+ * - /app/(..)(dashboard)/feed/page.val.ts -> ["feed"] (interception route)
5341
+ */
5342
+ function parseNextJsRoutePattern(moduleFilePath) {
5343
+ if (!moduleFilePath || typeof moduleFilePath !== "string") {
5344
+ return [];
5345
+ }
5346
+
5347
+ // Try App Router patterns first
5348
+ var appRouterPatterns = [/\/app\/(.+)\/page\.val\.ts$/,
5349
+ // /app/...
5350
+ /\/src\/app\/(.+)\/page\.val\.ts$/,
5351
+ // /src/app/...
5352
+ /\/app\/(.+)\/page\.tsx?$/,
5353
+ // /app/... with .tsx
5354
+ /\/src\/app\/(.+)\/page\.tsx?$/ // /src/app/... with .tsx
5355
+ ];
5356
+ for (var _i2 = 0, _appRouterPatterns = appRouterPatterns; _i2 < _appRouterPatterns.length; _i2++) {
5357
+ var pattern = _appRouterPatterns[_i2];
5358
+ var match = moduleFilePath.match(pattern);
5359
+ if (match) {
5360
+ var routePath = match[1];
5361
+ // Remove group and interception segments
5362
+ // Group: (group), Interception: (.), (..), (..)(dashboard), etc.
5363
+ return routePath.split("/").flatMap(function (segment) {
5364
+ // Remove group segments (but not interception segments)
5365
+ if (segment.startsWith("(") && segment.endsWith(")") && !segment.includes(".")) return [];
5366
+ // Interception segments: (.)feed, (..)(dashboard)/feed, etc.
5367
+ // If segment starts with (.) or (..), strip the interception marker and keep the rest
5368
+ var interceptionMatch = segment.match(/^(\([.]+\)(\(.+\))?)(.*)$/);
5369
+ if (interceptionMatch) {
5370
+ var rest = interceptionMatch[3] || interceptionMatch[4];
5371
+ return rest ? [rest] : [];
5372
+ }
5373
+ return [segment];
5374
+ });
5375
+ }
5376
+ }
5377
+ return [];
5378
+ }
5379
+
5092
5380
  var ModuleFilePathSep = "?p=";
5093
5381
  var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
5094
5382
  var DEFAULT_CONTENT_HOST = "https://content.val.build";
@@ -5113,6 +5401,7 @@ var Internal = {
5113
5401
  safeResolvePath: safeResolvePath,
5114
5402
  splitModuleFilePathAndModulePath: splitModuleFilePathAndModulePath,
5115
5403
  joinModuleFilePathAndModulePath: joinModuleFilePathAndModulePath,
5404
+ nextAppRouter: nextAppRouter,
5116
5405
  remote: {
5117
5406
  createRemoteRef: createRemoteRef,
5118
5407
  getValidationBasis: getValidationBasis,