@valbuild/core 0.92.0 → 0.94.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 +1 -1
  2. package/dist/declarations/src/initSchema.d.ts +59 -2
  3. package/dist/declarations/src/module.d.ts +2 -1
  4. package/dist/declarations/src/router.d.ts +1 -1
  5. package/dist/declarations/src/schema/file.d.ts +7 -4
  6. package/dist/declarations/src/schema/files.d.ts +56 -0
  7. package/dist/declarations/src/schema/image.d.ts +11 -7
  8. package/dist/declarations/src/schema/images.d.ts +85 -0
  9. package/dist/declarations/src/schema/object.d.ts +2 -0
  10. package/dist/declarations/src/schema/record.d.ts +20 -1
  11. package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
  12. package/dist/declarations/src/selector/index.d.ts +1 -1
  13. package/dist/declarations/src/source/index.d.ts +3 -2
  14. package/dist/declarations/src/source/remote.d.ts +1 -1
  15. package/dist/declarations/src/source/richtext.d.ts +2 -2
  16. package/dist/{index-0688e9f7.esm.js → index-bfe08f16.esm.js} +571 -179
  17. package/dist/{index-89cd4eb4.cjs.dev.js → index-c9252d4a.cjs.dev.js} +570 -178
  18. package/dist/{index-ad8961ed.cjs.prod.js → index-f8101689.cjs.prod.js} +570 -178
  19. package/dist/{result-daff1cae.esm.js → result-4bd63123.esm.js} +1 -1
  20. package/dist/valbuild-core.cjs.dev.js +1 -1
  21. package/dist/valbuild-core.cjs.prod.js +1 -1
  22. package/dist/valbuild-core.esm.js +2 -2
  23. package/fp/dist/valbuild-core-fp.esm.js +1 -1
  24. package/package.json +1 -1
  25. package/patch/dist/valbuild-core-patch.cjs.dev.js +2 -1
  26. package/patch/dist/valbuild-core-patch.cjs.prod.js +2 -1
  27. package/patch/dist/valbuild-core-patch.esm.js +4 -3
@@ -1,44 +1,4 @@
1
- import { _ as _unsupportedIterableToArray, a as _arrayLikeToArray, b as _createForOfIteratorHelper, i as isErr, c as isOk, e as err, o as ok } from './result-daff1cae.esm.js';
2
-
3
- function _arrayWithHoles(r) {
4
- if (Array.isArray(r)) return r;
5
- }
6
-
7
- function _iterableToArrayLimit(r, l) {
8
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
9
- if (null != t) {
10
- var e,
11
- n,
12
- i,
13
- u,
14
- a = [],
15
- f = !0,
16
- o = !1;
17
- try {
18
- if (i = (t = t.call(r)).next, 0 === l) {
19
- if (Object(t) !== t) return;
20
- f = !1;
21
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
22
- } catch (r) {
23
- o = !0, n = r;
24
- } finally {
25
- try {
26
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
27
- } finally {
28
- if (o) throw n;
29
- }
30
- }
31
- return a;
32
- }
33
- }
34
-
35
- function _nonIterableRest() {
36
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
37
- }
38
-
39
- function _slicedToArray(r, e) {
40
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
41
- }
1
+ import { _ as _arrayLikeToArray, a as _unsupportedIterableToArray, b as _createForOfIteratorHelper, i as isErr, c as isOk, e as err, o as ok } from './result-4bd63123.esm.js';
42
2
 
43
3
  function _arrayWithoutHoles(r) {
44
4
  if (Array.isArray(r)) return _arrayLikeToArray(r);
@@ -113,6 +73,46 @@ function _objectSpread2(e) {
113
73
  return e;
114
74
  }
115
75
 
76
+ function _arrayWithHoles(r) {
77
+ if (Array.isArray(r)) return r;
78
+ }
79
+
80
+ function _iterableToArrayLimit(r, l) {
81
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
82
+ if (null != t) {
83
+ var e,
84
+ n,
85
+ i,
86
+ u,
87
+ a = [],
88
+ f = !0,
89
+ o = !1;
90
+ try {
91
+ if (i = (t = t.call(r)).next, 0 === l) {
92
+ if (Object(t) !== t) return;
93
+ f = !1;
94
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
95
+ } catch (r) {
96
+ o = !0, n = r;
97
+ } finally {
98
+ try {
99
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
100
+ } finally {
101
+ if (o) throw n;
102
+ }
103
+ }
104
+ return a;
105
+ }
106
+ }
107
+
108
+ function _nonIterableRest() {
109
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
110
+ }
111
+
112
+ function _slicedToArray(r, e) {
113
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
114
+ }
115
+
116
116
  function _classCallCheck(a, n) {
117
117
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
118
118
  }
@@ -129,55 +129,6 @@ function _createClass(e, r, t) {
129
129
  }), e;
130
130
  }
131
131
 
132
- function _getPrototypeOf(t) {
133
- return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
134
- return t.__proto__ || Object.getPrototypeOf(t);
135
- }, _getPrototypeOf(t);
136
- }
137
-
138
- function _isNativeReflectConstruct() {
139
- try {
140
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
141
- } catch (t) {}
142
- return (_isNativeReflectConstruct = function () {
143
- return !!t;
144
- })();
145
- }
146
-
147
- function _assertThisInitialized(e) {
148
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
149
- return e;
150
- }
151
-
152
- function _possibleConstructorReturn(t, e) {
153
- if (e && ("object" == typeof e || "function" == typeof e)) return e;
154
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
155
- return _assertThisInitialized(t);
156
- }
157
-
158
- function _callSuper(t, o, e) {
159
- return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
160
- }
161
-
162
- function _setPrototypeOf(t, e) {
163
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
164
- return t.__proto__ = e, t;
165
- }, _setPrototypeOf(t, e);
166
- }
167
-
168
- function _inherits(t, e) {
169
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
170
- t.prototype = Object.create(e && e.prototype, {
171
- constructor: {
172
- value: t,
173
- writable: !0,
174
- configurable: !0
175
- }
176
- }), Object.defineProperty(t, "prototype", {
177
- writable: !1
178
- }), e && _setPrototypeOf(t, e);
179
- }
180
-
181
132
  // import { RemoteCompatibleSource, RemoteSource } from "../source/remote";
182
133
 
183
134
  // import { SerializedI18nSchema } from "./future/i18n";
@@ -274,6 +225,55 @@ var Schema = /*#__PURE__*/function () {
274
225
 
275
226
  // TODO: SourceError<"Could not determine type of Schema">
276
227
 
228
+ function _getPrototypeOf(t) {
229
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
230
+ return t.__proto__ || Object.getPrototypeOf(t);
231
+ }, _getPrototypeOf(t);
232
+ }
233
+
234
+ function _isNativeReflectConstruct() {
235
+ try {
236
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
237
+ } catch (t) {}
238
+ return (_isNativeReflectConstruct = function () {
239
+ return !!t;
240
+ })();
241
+ }
242
+
243
+ function _assertThisInitialized(e) {
244
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
245
+ return e;
246
+ }
247
+
248
+ function _possibleConstructorReturn(t, e) {
249
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
250
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
251
+ return _assertThisInitialized(t);
252
+ }
253
+
254
+ function _callSuper(t, o, e) {
255
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
256
+ }
257
+
258
+ function _setPrototypeOf(t, e) {
259
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
260
+ return t.__proto__ = e, t;
261
+ }, _setPrototypeOf(t, e);
262
+ }
263
+
264
+ function _inherits(t, e) {
265
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
266
+ t.prototype = Object.create(e && e.prototype, {
267
+ constructor: {
268
+ value: t,
269
+ writable: !0,
270
+ configurable: !0
271
+ }
272
+ }), Object.defineProperty(t, "prototype", {
273
+ writable: !1
274
+ }), e && _setPrototypeOf(t, e);
275
+ }
276
+
277
277
  /**
278
278
  * @internal
279
279
  */
@@ -376,30 +376,65 @@ function isFile(obj) {
376
376
  return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
377
377
  }
378
378
 
379
+ function isVal(val) {
380
+ return _typeof(val) === "object" && val !== null && val !== undefined && Path in val && "val" in val;
381
+ }
382
+
383
+ /**
384
+ * The path of the source value.
385
+ *
386
+ * @example
387
+ * '/app/blogs.val.ts?p=0.text' // the text property of the first element of the /app/blogs module
388
+ */
389
+
390
+ /**
391
+ * The path inside the module.
392
+ *
393
+ * @example
394
+ * '0."text"' // the text property of the first element of the module
395
+ */
396
+
397
+ /**
398
+ * The path of the module.
399
+ *
400
+ * @example
401
+ * '/app/blogs.val.ts'
402
+ */
403
+
404
+ /**
405
+ * The patchId of the parent patch, or "head" if there is no parent patch.
406
+ */
407
+
408
+ function getValPath(valOrSelector) {
409
+ return valOrSelector[Path];
410
+ }
411
+
379
412
  var FileSchema = /*#__PURE__*/function (_Schema) {
380
413
  function FileSchema(options) {
381
414
  var _this;
382
415
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
383
416
  var isRemote = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
384
417
  var customValidateFunctions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
418
+ var moduleMetadata = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
385
419
  _classCallCheck(this, FileSchema);
386
420
  _this = _callSuper(this, FileSchema);
387
421
  _this.options = options;
388
422
  _this.opt = opt;
389
423
  _this.isRemote = isRemote;
390
424
  _this.customValidateFunctions = customValidateFunctions;
425
+ _this.moduleMetadata = moduleMetadata;
391
426
  return _this;
392
427
  }
393
428
  _inherits(FileSchema, _Schema);
394
429
  return _createClass(FileSchema, [{
395
430
  key: "remote",
396
431
  value: function remote() {
397
- return new FileSchema(this.options, this.opt, true);
432
+ return new FileSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata);
398
433
  }
399
434
  }, {
400
435
  key: "validate",
401
436
  value: function validate(validationFunction) {
402
- return new FileSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]));
437
+ return new FileSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata);
403
438
  }
404
439
  }, {
405
440
  key: "executeValidate",
@@ -560,18 +595,20 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
560
595
  }, {
561
596
  key: "nullable",
562
597
  value: function nullable() {
563
- return new FileSchema(this.options, true);
598
+ return new FileSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata);
564
599
  }
565
600
  }, {
566
601
  key: "executeSerialize",
567
602
  value: function executeSerialize() {
568
603
  var _this$customValidateF;
604
+ var modulePaths = this.moduleMetadata ? Object.keys(this.moduleMetadata) : [];
569
605
  return {
570
606
  type: "file",
571
607
  options: this.options,
572
608
  opt: this.opt,
573
609
  remote: this.isRemote,
574
- customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
610
+ customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
611
+ referencedModule: modulePaths.length > 0 ? modulePaths[0] : undefined
575
612
  };
576
613
  }
577
614
  }, {
@@ -582,6 +619,19 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
582
619
  }]);
583
620
  }(Schema);
584
621
  var file = function file(options) {
622
+ var isModule = !!options && !!Internal.getValPath(options);
623
+ if (isModule) {
624
+ var allModules = {};
625
+ for (var _i = 0, _arr = [options]; _i < _arr.length; _i++) {
626
+ var valModule = _arr[_i];
627
+ var modulePath = getValPath(valModule);
628
+ if (modulePath === undefined) {
629
+ throw new Error("Invalid argument passed to s.file(). Expected a ValModule constructed through c.define, but got an object without a valid module path.");
630
+ }
631
+ allModules[modulePath] = getSource(valModule);
632
+ }
633
+ return new FileSchema({}, false, false, [], allModules);
634
+ }
585
635
  return new FileSchema(options);
586
636
  };
587
637
  function convertFileSource(src) {
@@ -604,39 +654,6 @@ function convertFileSource(src) {
604
654
  };
605
655
  }
606
656
 
607
- function isVal(val) {
608
- return _typeof(val) === "object" && val !== null && val !== undefined && Path in val && "val" in val;
609
- }
610
-
611
- /**
612
- * The path of the source value.
613
- *
614
- * @example
615
- * '/app/blogs.val.ts?p=0.text' // the text property of the first element of the /app/blogs module
616
- */
617
-
618
- /**
619
- * The path inside the module.
620
- *
621
- * @example
622
- * '0."text"' // the text property of the first element of the module
623
- */
624
-
625
- /**
626
- * The path of the module.
627
- *
628
- * @example
629
- * '/app/blogs.val.ts'
630
- */
631
-
632
- /**
633
- * The patchId of the parent patch, or "head" if there is no parent patch.
634
- */
635
-
636
- function getValPath(valOrSelector) {
637
- return valOrSelector[Path];
638
- }
639
-
640
657
  function createValPathOfItem(arrayPath, prop) {
641
658
  if (_typeof(prop) === "symbol") {
642
659
  throw Error("Cannot create val path of array item with symbol prop: ".concat(prop.toString()));
@@ -736,6 +753,12 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
736
753
  if (this.opt && (src === null || src === undefined)) {
737
754
  return errors.length > 0 ? _defineProperty({}, path, errors) : false;
738
755
  }
756
+ if (!this.opt && (src === null || src === undefined)) {
757
+ return _defineProperty({}, path, [{
758
+ message: "Expected 'string', got '".concat(src === null ? "null" : "undefined", "'"),
759
+ value: src
760
+ }]);
761
+ }
739
762
  if (typeof src !== "string") {
740
763
  return _defineProperty({}, path, [{
741
764
  message: "Expected 'string', got '".concat(_typeof(src), "'"),
@@ -1715,28 +1738,31 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1715
1738
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1716
1739
  var isRemote = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1717
1740
  var customValidateFunctions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1741
+ var moduleMetadata = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1718
1742
  _classCallCheck(this, ImageSchema);
1719
1743
  _this = _callSuper(this, ImageSchema);
1720
1744
  _this.options = options;
1721
1745
  _this.opt = opt;
1722
1746
  _this.isRemote = isRemote;
1723
1747
  _this.customValidateFunctions = customValidateFunctions;
1748
+ _this.moduleMetadata = moduleMetadata;
1724
1749
  return _this;
1725
1750
  }
1726
1751
  _inherits(ImageSchema, _Schema);
1727
1752
  return _createClass(ImageSchema, [{
1728
1753
  key: "remote",
1729
1754
  value: function remote() {
1730
- return new ImageSchema(this.options, this.opt, true);
1755
+ return new ImageSchema(this.options, this.opt, true, this.customValidateFunctions, this.moduleMetadata);
1731
1756
  }
1732
1757
  }, {
1733
1758
  key: "validate",
1734
1759
  value: function validate(validationFunction) {
1735
- return new ImageSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]));
1760
+ return new ImageSchema(this.options, this.opt, this.isRemote, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.moduleMetadata);
1736
1761
  }
1737
1762
  }, {
1738
1763
  key: "executeValidate",
1739
1764
  value: function executeValidate(path, src) {
1765
+ var _src$metadata$mimeTyp, _src$metadata;
1740
1766
  var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
1741
1767
  path: path
1742
1768
  });
@@ -1784,8 +1810,7 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1784
1810
  }
1785
1811
  var _ref8 = this.options || {},
1786
1812
  accept = _ref8.accept;
1787
- var _ref9 = src.metadata || {},
1788
- mimeType = _ref9.mimeType;
1813
+ var mimeType = (_src$metadata$mimeTyp = (_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.mimeType) !== null && _src$metadata$mimeTyp !== void 0 ? _src$metadata$mimeTyp : "";
1789
1814
  if (accept && mimeType && !mimeType.includes("/")) {
1790
1815
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
1791
1816
  message: "Invalid mime type format. Got: '".concat(mimeType, "'"),
@@ -1846,6 +1871,13 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1846
1871
  fixes: ["image:check-metadata"]
1847
1872
  }]));
1848
1873
  }
1874
+ var isReferencedModule = Object.keys(this.moduleMetadata).length > 0;
1875
+ if (src.metadata === undefined && isReferencedModule) {
1876
+ if (customValidationErrors.length === 0) {
1877
+ return false;
1878
+ }
1879
+ return _defineProperty({}, path, _toConsumableArray(customValidationErrors));
1880
+ }
1849
1881
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
1850
1882
  message: "Could not validate Image metadata.",
1851
1883
  value: src,
@@ -1905,18 +1937,20 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1905
1937
  }, {
1906
1938
  key: "nullable",
1907
1939
  value: function nullable() {
1908
- return new ImageSchema(this.options, true, this.isRemote);
1940
+ return new ImageSchema(this.options, true, this.isRemote, this.customValidateFunctions, this.moduleMetadata);
1909
1941
  }
1910
1942
  }, {
1911
1943
  key: "executeSerialize",
1912
1944
  value: function executeSerialize() {
1913
1945
  var _this$customValidateF;
1946
+ var modulePaths = this.moduleMetadata ? Object.keys(this.moduleMetadata) : [];
1914
1947
  return {
1915
1948
  type: "image",
1916
1949
  options: this.options,
1917
1950
  opt: this.opt,
1918
1951
  remote: this.isRemote,
1919
- customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
1952
+ customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
1953
+ referencedModule: modulePaths.length > 0 ? modulePaths[0] : undefined
1920
1954
  };
1921
1955
  }
1922
1956
  }, {
@@ -1927,6 +1961,19 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1927
1961
  }]);
1928
1962
  }(Schema);
1929
1963
  var image = function image(options) {
1964
+ var isModule = !!options && !!Internal.getValPath(options);
1965
+ if (isModule) {
1966
+ var allModules = {};
1967
+ for (var _i = 0, _arr = [options]; _i < _arr.length; _i++) {
1968
+ var valModule = _arr[_i];
1969
+ var modulePath = getValPath(valModule);
1970
+ if (modulePath === undefined) {
1971
+ throw new Error("Invalid argument passed to s.image(). Expected a ValModule constructed through c.define, but got an object without a valid module path.");
1972
+ }
1973
+ allModules[modulePath] = getSource(valModule);
1974
+ }
1975
+ return new ImageSchema({}, false, false, [], allModules);
1976
+ }
1930
1977
  return new ImageSchema(options);
1931
1978
  };
1932
1979
 
@@ -2270,7 +2317,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2270
2317
  if (!((_this2$options$inline4 = _this2.options.inline) !== null && _this2$options$inline4 !== void 0 && _this2$options$inline4.img)) {
2271
2318
  addError(path, "'img' inline is not valid", false);
2272
2319
  } else if ((_this2$options$inline5 = _this2.options.inline) !== null && _this2$options$inline5 !== void 0 && _this2$options$inline5.img) {
2273
- var _this2$options$inline6, _this2$options$inline7;
2320
+ var _this2$options$inline6;
2274
2321
  if (!("src" in node)) {
2275
2322
  return {
2276
2323
  v: _defineProperty({}, path, [{
@@ -2280,7 +2327,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
2280
2327
  };
2281
2328
  }
2282
2329
  var srcPath = unsafeCreateSourcePath(path, "src");
2283
- var imageValidationErrors = _typeof((_this2$options$inline6 = _this2.options.inline) === null || _this2$options$inline6 === void 0 ? void 0 : _this2$options$inline6.img) === "object" ? (_this2$options$inline7 = _this2.options.inline) === null || _this2$options$inline7 === void 0 ? void 0 : _this2$options$inline7.img["executeValidate"](srcPath, node.src) : new ImageSchema({}, false, false)["executeValidate"](srcPath, node.src);
2330
+ var imgSchema = (_this2$options$inline6 = _this2.options.inline) === null || _this2$options$inline6 === void 0 ? void 0 : _this2$options$inline6.img;
2331
+ var imageValidationErrors = _typeof(imgSchema) === "object" ? imgSchema["executeValidate"](srcPath, node.src) : new ImageSchema({}, false, false)["executeValidate"](srcPath, node.src);
2284
2332
  if (imageValidationErrors) {
2285
2333
  for (var _validationErrorPathS in imageValidationErrors) {
2286
2334
  var _current$_validationE;
@@ -2614,6 +2662,39 @@ var richtext = function richtext(options) {
2614
2662
  return new RichTextSchema(options !== null && options !== void 0 ? options : {});
2615
2663
  };
2616
2664
 
2665
+ var RegEx = /^(https?:\/\/[^/]+)\/file\/p\/([^/]+)\/b\/([^/]+)\/v\/([^/]+)\/h\/([^/]+)\/f\/([^/]+)\/p\/(.+)$/;
2666
+ function splitRemoteRef(ref) {
2667
+ if (ref[0] === "/") {
2668
+ return {
2669
+ status: "error",
2670
+ error: "Not a remote ref: " + ref
2671
+ };
2672
+ }
2673
+ var match = ref.match(RegEx);
2674
+ if (!match) {
2675
+ return {
2676
+ status: "error",
2677
+ error: "Invalid remote ref: " + ref
2678
+ };
2679
+ }
2680
+ if (match[7].indexOf("public/val/") !== 0) {
2681
+ return {
2682
+ status: "error",
2683
+ error: "Invalid remote ref: " + ref
2684
+ };
2685
+ }
2686
+ return {
2687
+ status: "success",
2688
+ remoteHost: match[1],
2689
+ projectId: match[2],
2690
+ bucket: match[3],
2691
+ version: match[4],
2692
+ validationHash: match[5],
2693
+ fileHash: match[6],
2694
+ filePath: match[7]
2695
+ };
2696
+ }
2697
+
2617
2698
  var RecordSchema = /*#__PURE__*/function (_Schema) {
2618
2699
  function RecordSchema(item) {
2619
2700
  var _this;
@@ -2621,6 +2702,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2621
2702
  var customValidateFunctions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
2622
2703
  var currentRouter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
2623
2704
  var keySchema = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
2705
+ var mediaOptions = arguments.length > 5 ? arguments[5] : undefined;
2624
2706
  _classCallCheck(this, RecordSchema);
2625
2707
  _this = _callSuper(this, RecordSchema);
2626
2708
  _defineProperty(_this, "renderInput", null);
@@ -2629,13 +2711,14 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2629
2711
  _this.customValidateFunctions = customValidateFunctions;
2630
2712
  _this.currentRouter = currentRouter;
2631
2713
  _this.keySchema = keySchema;
2714
+ _this.mediaOptions = mediaOptions;
2632
2715
  return _this;
2633
2716
  }
2634
2717
  _inherits(RecordSchema, _Schema);
2635
2718
  return _createClass(RecordSchema, [{
2636
2719
  key: "validate",
2637
2720
  value: function validate(validationFunction) {
2638
- return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema);
2721
+ return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions);
2639
2722
  }
2640
2723
  }, {
2641
2724
  key: "executeValidate",
@@ -2679,6 +2762,40 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2679
2762
  } finally {
2680
2763
  _iterator.f();
2681
2764
  }
2765
+ if (this.mediaOptions) {
2766
+ var checkFix = this.mediaOptions.type === "images" ? "images:check-unique-folder" : "files:check-unique-folder";
2767
+ var uniqueCheckError = {
2768
+ message: "Gallery directory '".concat(this.mediaOptions.directory, "' must be unique across all galleries"),
2769
+ value: {
2770
+ directory: this.mediaOptions.directory,
2771
+ type: this.mediaOptions.type
2772
+ },
2773
+ fixes: [checkFix]
2774
+ };
2775
+ if (error) {
2776
+ if (error[path]) {
2777
+ error[path] = [].concat(_toConsumableArray(error[path]), [uniqueCheckError]);
2778
+ } else {
2779
+ error = _objectSpread2(_objectSpread2({}, error), {}, _defineProperty({}, path, [uniqueCheckError]));
2780
+ }
2781
+ } else {
2782
+ error = _defineProperty({}, path, [uniqueCheckError]);
2783
+ }
2784
+ var allFilesCheckFix = this.mediaOptions.type === "images" ? "images:check-all-files" : "files:check-all-files";
2785
+ var allFilesCheckError = {
2786
+ message: "Directory '".concat(this.mediaOptions.directory, "' may have files not tracked by this gallery"),
2787
+ value: {
2788
+ directory: this.mediaOptions.directory,
2789
+ type: this.mediaOptions.type
2790
+ },
2791
+ fixes: [allFilesCheckFix]
2792
+ };
2793
+ if (error[path]) {
2794
+ error[path] = [].concat(_toConsumableArray(error[path]), [allFilesCheckError]);
2795
+ } else {
2796
+ error = _objectSpread2(_objectSpread2({}, error), {}, _defineProperty({}, path, [allFilesCheckError]));
2797
+ }
2798
+ }
2682
2799
  Object.entries(src).forEach(function (_ref5) {
2683
2800
  var _ref6 = _slicedToArray(_ref5, 2),
2684
2801
  key = _ref6[0],
@@ -2712,6 +2829,16 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2712
2829
  error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(elem),
2713
2830
  // Should! never happen
2714
2831
  src);
2832
+ } else if (_this2.mediaOptions) {
2833
+ // Media collection: validate key (path/URL) and entry (metadata)
2834
+ var keyErr = _this2.validateMediaKey(subPath, key);
2835
+ if (keyErr) {
2836
+ error = error ? _objectSpread2(_objectSpread2({}, error), keyErr) : keyErr;
2837
+ }
2838
+ var entryErr = _this2.validateMediaEntry(subPath, elem);
2839
+ if (entryErr) {
2840
+ error = error ? _objectSpread2(_objectSpread2({}, error), entryErr) : entryErr;
2841
+ }
2715
2842
  } else {
2716
2843
  var subError = _this2.item["executeValidate"](subPath, elem);
2717
2844
  if (subError && error) {
@@ -2723,6 +2850,176 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2723
2850
  });
2724
2851
  return error;
2725
2852
  }
2853
+ }, {
2854
+ key: "isRemoteUrl",
2855
+ value: function isRemoteUrl(url) {
2856
+ return url.startsWith("https://") || url.startsWith("http://");
2857
+ }
2858
+ }, {
2859
+ key: "validateMediaKey",
2860
+ value: function validateMediaKey(path, key) {
2861
+ if (!this.mediaOptions) {
2862
+ return false;
2863
+ }
2864
+ var _this$mediaOptions = this.mediaOptions,
2865
+ directory = _this$mediaOptions.directory,
2866
+ isRemote = _this$mediaOptions.remote,
2867
+ type = _this$mediaOptions.type;
2868
+ var mediaLabel = type === "images" ? "images" : "files";
2869
+ var checkRemoteFix = type === "images" ? "images:check-remote" : "files:check-remote";
2870
+ var isRemoteUrl = this.isRemoteUrl(key);
2871
+ var isLocalPath = key === directory || key.startsWith(directory + "/");
2872
+ if (isRemote) {
2873
+ // When remote is enabled, accept either remote URLs or local paths
2874
+ if (isRemoteUrl) {
2875
+ // Validate remote URL format using splitRemoteRef
2876
+ var remoteResult = splitRemoteRef(key);
2877
+ if (remoteResult.status === "error") {
2878
+ return _defineProperty({}, path, [{
2879
+ message: "Invalid remote URL format. Use Val tooling (CLI, VS Code extension, or Val Studio) to upload ".concat(mediaLabel, ". Got: ").concat(key),
2880
+ value: key,
2881
+ fixes: [checkRemoteFix]
2882
+ }]);
2883
+ }
2884
+ // Check that the file path in the remote URL matches our directory constraint
2885
+ var remotePath = "/" + remoteResult.filePath;
2886
+ if (remotePath !== directory && !remotePath.startsWith(directory + "/")) {
2887
+ return _defineProperty({}, path, [{
2888
+ message: "Remote file path '".concat(remotePath, "' is not in expected directory '").concat(directory, "'. Use Val tooling to upload ").concat(mediaLabel, " to the correct directory."),
2889
+ value: key,
2890
+ fixes: [checkRemoteFix]
2891
+ }]);
2892
+ }
2893
+ return false;
2894
+ }
2895
+ if (!isLocalPath) {
2896
+ return _defineProperty({}, path, [{
2897
+ message: "Expected a remote URL (https://...) or a local path starting with ".concat(directory, "/. Got: ").concat(key),
2898
+ value: key
2899
+ }]);
2900
+ }
2901
+ } else {
2902
+ // When remote is disabled, only accept local paths
2903
+ if (isRemoteUrl) {
2904
+ return _defineProperty({}, path, [{
2905
+ message: "Remote URLs are not allowed. Use .remote() to enable remote ".concat(mediaLabel, ". Got: ").concat(key),
2906
+ value: key,
2907
+ fixes: [checkRemoteFix]
2908
+ }]);
2909
+ }
2910
+ if (!isLocalPath) {
2911
+ return _defineProperty({}, path, [{
2912
+ message: "File path must be within the ".concat(directory, "/ directory. Got: ").concat(key),
2913
+ value: key
2914
+ }]);
2915
+ }
2916
+ }
2917
+ return false;
2918
+ }
2919
+ }, {
2920
+ key: "validateMediaEntry",
2921
+ value: function validateMediaEntry(path, entry) {
2922
+ if (!this.mediaOptions) {
2923
+ return false;
2924
+ }
2925
+ var _this$mediaOptions2 = this.mediaOptions,
2926
+ type = _this$mediaOptions2.type,
2927
+ accept = _this$mediaOptions2.accept,
2928
+ altSchema = _this$mediaOptions2.altSchema;
2929
+ if (_typeof(entry) !== "object" || entry === null) {
2930
+ return _defineProperty({}, path, [{
2931
+ message: "Expected 'object', got '".concat(_typeof(entry), "'"),
2932
+ value: entry
2933
+ }]);
2934
+ }
2935
+ var entryObj = entry;
2936
+ var errors = [];
2937
+ if (type === "images") {
2938
+ // Validate width
2939
+ if (typeof entryObj.width !== "number" || entryObj.width <= 0) {
2940
+ errors.push({
2941
+ message: "Expected 'width' to be a positive number, got '".concat(entryObj.width, "'"),
2942
+ value: entry
2943
+ });
2944
+ }
2945
+
2946
+ // Validate height
2947
+ if (typeof entryObj.height !== "number" || entryObj.height <= 0) {
2948
+ errors.push({
2949
+ message: "Expected 'height' to be a positive number, got '".concat(entryObj.height, "'"),
2950
+ value: entry
2951
+ });
2952
+ }
2953
+ }
2954
+
2955
+ // Validate mimeType
2956
+ if (typeof entryObj.mimeType !== "string") {
2957
+ errors.push({
2958
+ message: "Expected 'mimeType' to be a string, got '".concat(_typeof(entryObj.mimeType), "'"),
2959
+ value: entry
2960
+ });
2961
+ } else {
2962
+ var mimeTypeError = this.validateMediaMimeType(entryObj.mimeType, accept);
2963
+ if (mimeTypeError) {
2964
+ errors.push({
2965
+ message: mimeTypeError,
2966
+ value: entry
2967
+ });
2968
+ }
2969
+ }
2970
+ if (type === "images") {
2971
+ // Validate hotspot if present
2972
+ if (entryObj.hotspot !== undefined) {
2973
+ var hs = entryObj.hotspot;
2974
+ if (_typeof(entryObj.hotspot) !== "object" || typeof hs.x !== "number" || typeof hs.y !== "number") {
2975
+ errors.push({
2976
+ message: "Hotspot must be an object with x and y as numbers.",
2977
+ value: entry
2978
+ });
2979
+ }
2980
+ }
2981
+
2982
+ // Validate alt using the alt schema
2983
+ var altPath = createValPathOfItem(path, "alt");
2984
+ if (altPath && altSchema) {
2985
+ var altError = altSchema["executeValidate"](altPath, entryObj.alt);
2986
+ if (altError) {
2987
+ return errors.length > 0 ? _objectSpread2(_objectSpread2({}, altError), {}, _defineProperty({}, path, errors)) : altError;
2988
+ }
2989
+ }
2990
+ }
2991
+ if (errors.length > 0) {
2992
+ return _defineProperty({}, path, errors);
2993
+ }
2994
+ return false;
2995
+ }
2996
+ }, {
2997
+ key: "validateMediaMimeType",
2998
+ value: function validateMediaMimeType(mimeType, accept) {
2999
+ if (!mimeType.includes("/")) {
3000
+ return "Invalid mime type format. Got: '".concat(mimeType, "'");
3001
+ }
3002
+ var acceptedTypes = accept.split(",").map(function (type) {
3003
+ return type.trim();
3004
+ });
3005
+ var isValidMimeType = acceptedTypes.some(function (acceptedType) {
3006
+ if (acceptedType === "*/*") {
3007
+ return true;
3008
+ }
3009
+ if (acceptedType === "image/*") {
3010
+ return mimeType.startsWith("image/");
3011
+ }
3012
+ if (acceptedType.endsWith("/*")) {
3013
+ var baseType = acceptedType.slice(0, -2);
3014
+ return mimeType.startsWith(baseType);
3015
+ }
3016
+ return acceptedType === mimeType;
3017
+ });
3018
+ if (!isValidMimeType) {
3019
+ return "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'");
3020
+ }
3021
+ return null;
3022
+ }
2726
3023
  }, {
2727
3024
  key: "executeAssert",
2728
3025
  value: function executeAssert(path, src) {
@@ -2732,6 +3029,15 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2732
3029
  data: src
2733
3030
  };
2734
3031
  }
3032
+ if (src === null) {
3033
+ return {
3034
+ success: false,
3035
+ errors: _defineProperty({}, path, [{
3036
+ message: "Expected 'object', got 'null'",
3037
+ typeError: true
3038
+ }])
3039
+ };
3040
+ }
2735
3041
  if (_typeof(src) !== "object") {
2736
3042
  return {
2737
3043
  success: false,
@@ -2758,12 +3064,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2758
3064
  }, {
2759
3065
  key: "nullable",
2760
3066
  value: function nullable() {
2761
- return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema);
3067
+ return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions);
2762
3068
  }
2763
3069
  }, {
2764
3070
  key: "router",
2765
3071
  value: function router(_router) {
2766
- return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema);
3072
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions);
3073
+ }
3074
+ }, {
3075
+ key: "remote",
3076
+ value: function remote() {
3077
+ return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions ? _objectSpread2(_objectSpread2({}, this.mediaOptions), {}, {
3078
+ remote: true
3079
+ }) : undefined);
2767
3080
  }
2768
3081
  }, {
2769
3082
  key: "getRouterValidations",
@@ -2811,7 +3124,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2811
3124
  key: "executeSerialize",
2812
3125
  value: function executeSerialize() {
2813
3126
  var _this$keySchema, _this$currentRouter, _this$customValidateF;
2814
- return {
3127
+ var result = {
2815
3128
  type: "record",
2816
3129
  item: this.item["executeSerialize"](),
2817
3130
  key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
@@ -2819,6 +3132,16 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2819
3132
  router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
2820
3133
  customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
2821
3134
  };
3135
+ if (this.mediaOptions) {
3136
+ result.mediaType = this.mediaOptions.type;
3137
+ result.accept = this.mediaOptions.accept;
3138
+ result.directory = this.mediaOptions.directory;
3139
+ result.remote = this.mediaOptions.remote;
3140
+ if (this.mediaOptions.altSchema) {
3141
+ result.alt = this.mediaOptions.altSchema["executeSerialize"]();
3142
+ }
3143
+ }
3144
+ return result;
2822
3145
  }
2823
3146
  }, {
2824
3147
  key: "executeRender",
@@ -2855,10 +3178,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2855
3178
  data: {
2856
3179
  layout: "list",
2857
3180
  parent: "record",
2858
- items: Object.entries(src).map(function (_ref8) {
2859
- var _ref9 = _slicedToArray(_ref8, 2),
2860
- key = _ref9[0],
2861
- val = _ref9[1];
3181
+ items: Object.entries(src).map(function (_ref13) {
3182
+ var _ref14 = _slicedToArray(_ref13, 2),
3183
+ key = _ref14[0],
3184
+ val = _ref14[1];
2862
3185
  // NB NB: display is actually defined by the user
2863
3186
  var _prepare = prepare({
2864
3187
  key: key,
@@ -2913,14 +3236,11 @@ function record(keyOrSchema, schema) {
2913
3236
 
2914
3237
  function define(id,
2915
3238
  // TODO: `/${string}`
2916
-
2917
3239
  schema, source) {
2918
3240
  return _defineProperty(_defineProperty(_defineProperty({}, GetSource, source), GetSchema, schema), Path, id);
2919
3241
  }
2920
3242
  function getSource(valModule) {
2921
- var sourceOrExpr = valModule[GetSource];
2922
- var source = sourceOrExpr;
2923
- return source;
3243
+ return valModule[GetSource];
2924
3244
  }
2925
3245
  function splitModuleFilePathAndModulePath(path) {
2926
3246
  var pathOfSep = path.indexOf(ModuleFilePathSep);
@@ -3851,6 +4171,44 @@ var keyOf = function keyOf(valModule) {
3851
4171
  return new KeyOfSchema(serializedRefSchema, getValPath(valModule));
3852
4172
  };
3853
4173
 
4174
+ /**
4175
+ * Options for s.files()
4176
+ */
4177
+
4178
+ /**
4179
+ * Metadata for a file entry in the files record
4180
+ */
4181
+
4182
+ /**
4183
+ * Define a collection of files.
4184
+ *
4185
+ * @example
4186
+ * ```typescript
4187
+ * const schema = s.files({
4188
+ * accept: "application/pdf",
4189
+ * directory: "/public/val/documents",
4190
+ * });
4191
+ * export default c.define("/content/documents.val.ts", schema, {
4192
+ * "/public/val/documents/report.pdf": {
4193
+ * mimeType: "application/pdf",
4194
+ * },
4195
+ * });
4196
+ * ```
4197
+ */
4198
+ var files = function files(options) {
4199
+ var _options$directory, _options$remote;
4200
+ var directory = (_options$directory = options.directory) !== null && _options$directory !== void 0 ? _options$directory : "/public/val";
4201
+ var itemSchema = new ObjectSchema({
4202
+ mimeType: new StringSchema({}, false)
4203
+ }, false);
4204
+ return new RecordSchema(itemSchema, false, [], null, null, {
4205
+ type: "files",
4206
+ accept: options.accept,
4207
+ directory: directory,
4208
+ remote: (_options$remote = options.remote) !== null && _options$remote !== void 0 ? _options$remote : false
4209
+ });
4210
+ };
4211
+
3854
4212
  var DateSchema = /*#__PURE__*/function (_Schema) {
3855
4213
  function DateSchema(options) {
3856
4214
  var _this;
@@ -3999,6 +4357,59 @@ function router(router, item) {
3999
4357
  return recordSchema;
4000
4358
  }
4001
4359
 
4360
+ /**
4361
+ * Alt schema type - can be a string, nullable string, or a record of locale to string
4362
+ */
4363
+
4364
+ /**
4365
+ * Options for s.images()
4366
+ */
4367
+
4368
+ /**
4369
+ * Metadata for an image entry in the images record
4370
+ */
4371
+
4372
+ // Item schema types for images (alt simplified to string | null for typing)
4373
+
4374
+ /**
4375
+ * Define a collection of images.
4376
+ *
4377
+ * @example
4378
+ * ```typescript
4379
+ * const schema = s.images({
4380
+ * accept: "image/webp",
4381
+ * directory: "/public/val/images",
4382
+ * alt: s.string().minLength(4),
4383
+ * });
4384
+ * export default c.define("/content/images.val.ts", schema, {
4385
+ * "/public/val/images/hero.webp": {
4386
+ * width: 1920,
4387
+ * height: 1080,
4388
+ * mimeType: "image/webp",
4389
+ * alt: "Hero image",
4390
+ * },
4391
+ * });
4392
+ * ```
4393
+ */
4394
+ var images = function images(options) {
4395
+ var _options$directory, _options$alt, _options$remote;
4396
+ var directory = (_options$directory = options.directory) !== null && _options$directory !== void 0 ? _options$directory : "/public/val";
4397
+ var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
4398
+ var itemSchema = new ObjectSchema({
4399
+ width: new NumberSchema(undefined, false),
4400
+ height: new NumberSchema(undefined, false),
4401
+ mimeType: new StringSchema({}, false),
4402
+ alt: altSchema
4403
+ }, false);
4404
+ return new RecordSchema(itemSchema, false, [], null, null, {
4405
+ type: "images",
4406
+ accept: options.accept,
4407
+ directory: directory,
4408
+ remote: (_options$remote = options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
4409
+ altSchema: altSchema
4410
+ });
4411
+ };
4412
+
4002
4413
  // import type { F } from "ts-toolbelt";
4003
4414
  // import { i18n, I18n } from "./schema/future/i18n";
4004
4415
  // import { oneOf } from "./schema/future/oneOf";
@@ -4022,9 +4433,11 @@ function initSchema() {
4022
4433
  keyOf: keyOf,
4023
4434
  record: record,
4024
4435
  file: file,
4436
+ files: files,
4025
4437
  date: date,
4026
4438
  route: route,
4027
- router: router
4439
+ router: router,
4440
+ images: images
4028
4441
  // i18n: i18n(locales),
4029
4442
  };
4030
4443
  }
@@ -4173,33 +4586,6 @@ function modules(config, modules) {
4173
4586
  };
4174
4587
  }
4175
4588
 
4176
- var RegEx = /^(https?:\/\/[^/]+)\/file\/p\/([^/]+)\/b\/([^/]+)\/v\/([^/]+)\/h\/([^/]+)\/f\/([^/]+)\/p\/(.+)$/;
4177
- function splitRemoteRef(ref) {
4178
- var match = ref.match(RegEx);
4179
- if (!match) {
4180
- return {
4181
- status: "error",
4182
- error: "Invalid remote ref: " + ref
4183
- };
4184
- }
4185
- if (match[7].indexOf("public/val/") !== 0) {
4186
- return {
4187
- status: "error",
4188
- error: "Invalid remote ref: " + ref
4189
- };
4190
- }
4191
- return {
4192
- status: "success",
4193
- remoteHost: match[1],
4194
- projectId: match[2],
4195
- bucket: match[3],
4196
- version: match[4],
4197
- validationHash: match[5],
4198
- fileHash: match[6],
4199
- filePath: match[7]
4200
- };
4201
- }
4202
-
4203
4589
  var DEFAULT_VAL_REMOTE_HOST = "https://remote.val.build";
4204
4590
  function convertRemoteSource(src) {
4205
4591
  if (src !== null && src !== void 0 && src.patch_id) {
@@ -5432,7 +5818,7 @@ function getFileHash(text) {
5432
5818
  }
5433
5819
 
5434
5820
  function deserializeSchema(serialized) {
5435
- var _serialized$options, _serialized$options2;
5821
+ var _serialized$options, _serialized$options2, _serialized$accept, _serialized$directory, _serialized$remote;
5436
5822
  switch (serialized.type) {
5437
5823
  case "string":
5438
5824
  return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
@@ -5475,7 +5861,13 @@ function deserializeSchema(serialized) {
5475
5861
  return new RichTextSchema(deserializedOptions, serialized.opt);
5476
5862
  }
5477
5863
  case "record":
5478
- return new RecordSchema(deserializeSchema(serialized.item), serialized.opt, [], null, serialized.key ? deserializeSchema(serialized.key) : null);
5864
+ return new RecordSchema(deserializeSchema(serialized.item), serialized.opt, [], null, serialized.key ? deserializeSchema(serialized.key) : null, serialized.mediaType ? {
5865
+ type: serialized.mediaType,
5866
+ accept: (_serialized$accept = serialized.accept) !== null && _serialized$accept !== void 0 ? _serialized$accept : "*/*",
5867
+ directory: (_serialized$directory = serialized.directory) !== null && _serialized$directory !== void 0 ? _serialized$directory : "/public/val",
5868
+ remote: (_serialized$remote = serialized.remote) !== null && _serialized$remote !== void 0 ? _serialized$remote : false,
5869
+ altSchema: serialized.alt ? deserializeSchema(serialized.alt) : undefined
5870
+ } : undefined);
5479
5871
  case "keyOf":
5480
5872
  return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt);
5481
5873
  case "route":
@@ -5505,7 +5897,7 @@ function deserializeSchema(serialized) {
5505
5897
  }
5506
5898
  }
5507
5899
 
5508
- var externalUrlPage = {
5900
+ var externalPageRouter = {
5509
5901
  getRouterId: function getRouterId() {
5510
5902
  return "external-url-router";
5511
5903
  },
@@ -5746,7 +6138,7 @@ var Internal = {
5746
6138
  splitModuleFilePathAndModulePath: splitModuleFilePathAndModulePath,
5747
6139
  joinModuleFilePathAndModulePath: joinModuleFilePathAndModulePath,
5748
6140
  nextAppRouter: nextAppRouter,
5749
- externalUrlPage: externalUrlPage,
6141
+ externalPageRouter: externalPageRouter,
5750
6142
  remote: {
5751
6143
  createRemoteRef: createRemoteRef,
5752
6144
  getValidationBasis: getValidationBasis,