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