@valbuild/core 0.63.6 → 0.64.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 (37) hide show
  1. package/dist/declarations/src/index.d.ts +11 -89
  2. package/dist/declarations/src/initSchema.d.ts +2 -2
  3. package/dist/declarations/src/mimeType/all.d.ts +4 -0
  4. package/dist/declarations/src/mimeType/convertMimeType.d.ts +3 -0
  5. package/dist/declarations/src/mimeType/index.d.ts +2 -0
  6. package/dist/declarations/src/schema/array.d.ts +5 -5
  7. package/dist/declarations/src/schema/boolean.d.ts +2 -2
  8. package/dist/declarations/src/schema/date.d.ts +5 -5
  9. package/dist/declarations/src/schema/file.d.ts +5 -3
  10. package/dist/declarations/src/schema/image.d.ts +4 -3
  11. package/dist/declarations/src/schema/index.d.ts +44 -3
  12. package/dist/declarations/src/schema/keyOf.d.ts +5 -5
  13. package/dist/declarations/src/schema/literal.d.ts +3 -3
  14. package/dist/declarations/src/schema/number.d.ts +3 -3
  15. package/dist/declarations/src/schema/object.d.ts +5 -5
  16. package/dist/declarations/src/schema/record.d.ts +5 -5
  17. package/dist/declarations/src/schema/richtext.d.ts +5 -4
  18. package/dist/declarations/src/schema/string.d.ts +2 -2
  19. package/dist/declarations/src/schema/union.d.ts +5 -5
  20. package/dist/declarations/src/schema/validation/ValidationError.d.ts +2 -1
  21. package/dist/declarations/src/selector/SelectorProxy.d.ts +1 -0
  22. package/dist/declarations/src/source/richtext.d.ts +7 -0
  23. package/dist/declarations/src/val/index.d.ts +1 -1
  24. package/dist/{index-041f75bd.cjs.prod.js → index-41223963.cjs.prod.js} +1583 -815
  25. package/dist/{index-fccba617.esm.js → index-4240c6a6.esm.js} +1583 -815
  26. package/dist/{index-c67ed8f9.cjs.dev.js → index-d384ec25.cjs.dev.js} +1583 -815
  27. package/dist/valbuild-core.cjs.dev.js +2 -2
  28. package/dist/valbuild-core.cjs.prod.js +2 -2
  29. package/dist/valbuild-core.esm.js +1 -1
  30. package/expr/dist/valbuild-core-expr.cjs.dev.js +1 -1
  31. package/expr/dist/valbuild-core-expr.cjs.prod.js +1 -1
  32. package/expr/dist/valbuild-core-expr.esm.js +1 -1
  33. package/package.json +1 -1
  34. package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
  35. package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
  36. package/patch/dist/valbuild-core-patch.esm.js +2 -2
  37. package/dist/declarations/src/ValApi.d.ts +0 -54
@@ -470,6 +470,50 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
470
470
  value: src
471
471
  }]);
472
472
  }
473
+ var _ref4 = this.options || {},
474
+ accept = _ref4.accept;
475
+ var _ref5 = src.metadata || {},
476
+ mimeType = _ref5.mimeType;
477
+ if (accept && mimeType && !mimeType.includes("/")) {
478
+ return _defineProperty({}, path, [{
479
+ message: "Invalid mime type format. Got: ".concat(mimeType),
480
+ value: src
481
+ }]);
482
+ }
483
+ if (accept && mimeType && mimeType.includes("/")) {
484
+ var acceptedTypes = accept.split(",").map(function (type) {
485
+ return type.trim();
486
+ });
487
+ var isValidMimeType = acceptedTypes.some(function (acceptedType) {
488
+ if (acceptedType === "*/*") {
489
+ return true;
490
+ }
491
+ if (acceptedType.endsWith("/*")) {
492
+ var baseType = acceptedType.slice(0, -2);
493
+ return mimeType.startsWith(baseType);
494
+ }
495
+ return acceptedType === mimeType;
496
+ });
497
+ if (!isValidMimeType) {
498
+ return _defineProperty({}, path, [{
499
+ message: "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'"),
500
+ value: src
501
+ }]);
502
+ }
503
+ }
504
+ var fileMimeType = Internal.filenameToMimeType(src[FILE_REF_PROP]);
505
+ if (!fileMimeType) {
506
+ return _defineProperty({}, path, [{
507
+ message: "Could not determine mime type from file extension. Got: ".concat(src[FILE_REF_PROP]),
508
+ value: src
509
+ }]);
510
+ }
511
+ if (fileMimeType !== mimeType) {
512
+ return _defineProperty({}, path, [{
513
+ message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
514
+ value: src
515
+ }]);
516
+ }
473
517
  if (src.metadata) {
474
518
  return _defineProperty({}, path, [{
475
519
  message: "Found metadata, but it could not be validated. File metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
@@ -486,11 +530,53 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
486
530
  }
487
531
  }, {
488
532
  key: "assert",
489
- value: function assert(src) {
490
- if (this.opt && (src === null || src === undefined)) {
491
- return true;
533
+ value: function assert(path, src) {
534
+ if (this.opt && src === null) {
535
+ return {
536
+ success: true,
537
+ data: src
538
+ };
539
+ }
540
+ if (src === null) {
541
+ return {
542
+ success: false,
543
+ errors: _defineProperty({}, path, [{
544
+ message: "Expected 'object', got 'null'",
545
+ typeError: true
546
+ }])
547
+ };
548
+ }
549
+ if (_typeof(src) !== "object") {
550
+ return {
551
+ success: false,
552
+ errors: _defineProperty({}, path, [{
553
+ message: "Expected object, got '".concat(_typeof(src), "'"),
554
+ typeError: true
555
+ }])
556
+ };
557
+ }
558
+ if (!(FILE_REF_PROP in src)) {
559
+ return {
560
+ success: false,
561
+ errors: _defineProperty({}, path, [{
562
+ message: "Value of this schema must use: 'c.file' (error type: missing_ref_prop)",
563
+ typeError: true
564
+ }])
565
+ };
566
+ }
567
+ if (!(VAL_EXTENSION in src && src[VAL_EXTENSION] === "file")) {
568
+ return {
569
+ success: false,
570
+ errors: _defineProperty({}, path, [{
571
+ message: "Value of this schema must use: 'c.file' (error type: missing_file_extension)",
572
+ typeError: true
573
+ }])
574
+ };
492
575
  }
493
- return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "file" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
576
+ return {
577
+ success: true,
578
+ data: src
579
+ };
494
580
  }
495
581
  }, {
496
582
  key: "nullable",
@@ -635,7 +721,7 @@ function newSelectorProxy$1(source, path, moduleSchema) {
635
721
  return newSelectorProxy$1(a, createValPathOfItem(path, i), moduleSchema === null || moduleSchema === void 0 ? void 0 : moduleSchema.item);
636
722
  }).filter(function (a) {
637
723
  if (f && f instanceof Schema) {
638
- return f.assert(unValify$1(a));
724
+ return f.assert(path || "", unValify$1(a)).success;
639
725
  } else {
640
726
  return unValify$1(f(a));
641
727
  }
@@ -702,6 +788,20 @@ function createValPathOfItem(arrayPath, prop) {
702
788
  return "".concat(arrayPath).concat(Internal.ModuleFilePathSep).concat(JSON.stringify(prop));
703
789
  }
704
790
 
791
+ // TODO: replace createValPathOfItem everywhere with this newer implementation (that does not return undefined but throws)
792
+ function unsafeCreateSourcePath(path, itemKey) {
793
+ if (_typeof(itemKey) === "symbol") {
794
+ throw Error("Cannot create val path of array item with symbol prop: ".concat(itemKey.toString()));
795
+ }
796
+ if (!path) {
797
+ throw Error("Cannot create val path of array item of empty or missing path: ".concat(path, ". Item: ").concat(itemKey));
798
+ }
799
+ if (path.includes(Internal.ModuleFilePathSep)) {
800
+ return "".concat(path, ".").concat(JSON.stringify(itemKey));
801
+ }
802
+ return "".concat(path).concat(Internal.ModuleFilePathSep).concat(JSON.stringify(itemKey));
803
+ }
804
+
705
805
  // TODO: could we do .val on the objects instead?
706
806
  function unValify$1(valueOrSelector) {
707
807
  if (_typeof(valueOrSelector) === "object" && (GetSource in valueOrSelector || Path$1 in valueOrSelector)) {
@@ -732,6 +832,11 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
732
832
  if (this.opt && (src === null || src === undefined)) {
733
833
  return false;
734
834
  }
835
+ if (src === null) {
836
+ return _defineProperty({}, path, [{
837
+ message: "Expected 'object', got 'null'"
838
+ }]);
839
+ }
735
840
  if (_typeof(src) !== "object") {
736
841
  return _defineProperty({}, path, [{
737
842
  message: "Expected 'object', got '".concat(_typeof(src), "'")
@@ -741,10 +846,10 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
741
846
  message: "Expected 'object', got 'array'"
742
847
  }]);
743
848
  }
744
- Object.entries(this.items).forEach(function (_ref3) {
745
- var _ref4 = _slicedToArray(_ref3, 2),
746
- key = _ref4[0],
747
- schema = _ref4[1];
849
+ Object.entries(this.items).forEach(function (_ref4) {
850
+ var _ref5 = _slicedToArray(_ref4, 2),
851
+ key = _ref5[0],
852
+ schema = _ref5[1];
748
853
  var subPath = createValPathOfItem(path, key);
749
854
  if (!subPath) {
750
855
  error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(key),
@@ -763,22 +868,66 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
763
868
  }
764
869
  }, {
765
870
  key: "assert",
766
- value: function assert(src) {
767
- if (this.opt && (src === null || src === undefined)) {
768
- return true;
871
+ value: function assert(path, src) {
872
+ if (this.opt && src === null) {
873
+ return {
874
+ success: true,
875
+ data: src
876
+ };
769
877
  }
770
- if (!src) {
771
- return false;
878
+ if (src === null) {
879
+ return {
880
+ success: false,
881
+ errors: _defineProperty({}, path, [{
882
+ message: "Expected 'object', got 'null'",
883
+ typeError: true
884
+ }])
885
+ };
772
886
  }
773
- for (var _i = 0, _Object$entries = Object.entries(this.items); _i < _Object$entries.length; _i++) {
774
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
775
- _key = _Object$entries$_i[0],
776
- schema = _Object$entries$_i[1];
777
- if (!schema.assert(src[_key])) {
778
- return false;
887
+ if (_typeof(src) !== "object") {
888
+ return {
889
+ success: false,
890
+ errors: _defineProperty({}, path, [{
891
+ message: "Expected 'object', got '".concat(_typeof(src), "'"),
892
+ typeError: true
893
+ }])
894
+ };
895
+ } else if (Array.isArray(src)) {
896
+ return {
897
+ success: false,
898
+ errors: _defineProperty({}, path, [{
899
+ message: "Expected 'object', got 'array'",
900
+ typeError: true
901
+ }])
902
+ };
903
+ }
904
+ var errorsAtPath = [];
905
+ for (var _i = 0, _Object$keys = Object.keys(this.items); _i < _Object$keys.length; _i++) {
906
+ var _key = _Object$keys[_i];
907
+ var subPath = createValPathOfItem(path, _key);
908
+ if (!subPath) {
909
+ errorsAtPath.push({
910
+ message: "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(_key),
911
+ // Should! never happen
912
+ internalError: true
913
+ });
914
+ } else if (!(_key in src)) {
915
+ errorsAtPath.push({
916
+ message: "Expected key '".concat(_key, "' not found in object"),
917
+ typeError: true
918
+ });
779
919
  }
780
920
  }
781
- return _typeof(src) === "object" && !Array.isArray(src);
921
+ if (errorsAtPath.length > 0) {
922
+ return {
923
+ success: false,
924
+ errors: _defineProperty({}, path, errorsAtPath)
925
+ };
926
+ }
927
+ return {
928
+ success: true,
929
+ data: src
930
+ };
782
931
  }
783
932
  }, {
784
933
  key: "nullable",
@@ -790,10 +939,10 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
790
939
  value: function serialize() {
791
940
  return {
792
941
  type: "object",
793
- items: Object.fromEntries(Object.entries(this.items).map(function (_ref5) {
794
- var _ref6 = _slicedToArray(_ref5, 2),
795
- key = _ref6[0],
796
- schema = _ref6[1];
942
+ items: Object.fromEntries(Object.entries(this.items).map(function (_ref6) {
943
+ var _ref7 = _slicedToArray(_ref6, 2),
944
+ key = _ref7[0],
945
+ schema = _ref7[1];
797
946
  return [key, schema.serialize()];
798
947
  })),
799
948
  opt: this.opt
@@ -1056,7 +1205,7 @@ function parseTokens$1(inputTokens) {
1056
1205
  }
1057
1206
  return res;
1058
1207
  }
1059
- function parse$1(input) {
1208
+ function parse(input) {
1060
1209
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1061
1210
  var _tokenize = tokenize(input),
1062
1211
  _tokenize2 = _slicedToArray(_tokenize, 2),
@@ -1182,7 +1331,7 @@ function newSelectorProxy(source, path, moduleSchema) {
1182
1331
  return newSelectorProxy(a, createValPathOfItem(path, i), moduleSchema === null || moduleSchema === void 0 ? void 0 : moduleSchema.item);
1183
1332
  }).filter(function (a) {
1184
1333
  if (f && f instanceof Schema) {
1185
- return f.assert(unValify(a));
1334
+ return f.assert(path || "", unValify(a)).success;
1186
1335
  } else {
1187
1336
  return unValify(f(a));
1188
1337
  }
@@ -1425,7 +1574,7 @@ function evaluate(expr, source, stack) {
1425
1574
 
1426
1575
  var index = /*#__PURE__*/Object.freeze({
1427
1576
  __proto__: null,
1428
- parse: parse$1,
1577
+ parse: parse,
1429
1578
  Call: Call,
1430
1579
  Expr: Expr,
1431
1580
  NilSym: NilSym,
@@ -1449,57 +1598,69 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
1449
1598
  _createClass(ArraySchema, [{
1450
1599
  key: "validate",
1451
1600
  value: function validate(path, src) {
1452
- var _this2 = this;
1453
- var error = false;
1454
- if (this.opt && (src === null || src === undefined)) {
1455
- return false;
1601
+ var assertRes = this.assert(path, src);
1602
+ if (!assertRes.success) {
1603
+ return assertRes.errors;
1456
1604
  }
1457
- if (_typeof(src) !== "object" || !Array.isArray(src)) {
1458
- return _defineProperty({}, path, [{
1459
- message: "Expected 'array', got '".concat(_typeof(src), "'")
1460
- }]);
1605
+ if (assertRes.data === null) {
1606
+ return false;
1461
1607
  }
1462
- src.forEach(function (i, idx) {
1463
- var subPath = createValPathOfItem(path, idx);
1464
- if (!subPath) {
1465
- error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at index ").concat(idx),
1466
- // Should! never happen
1467
- src);
1468
- } else {
1469
- var subError = _this2.item.validate(subPath, i);
1470
- if (subError && error) {
1471
- error = _objectSpread2(_objectSpread2({}, subError), error);
1472
- } else if (subError) {
1473
- error = subError;
1474
- }
1608
+ var error = {};
1609
+ for (var _i = 0, _Object$entries = Object.entries(assertRes.data); _i < _Object$entries.length; _i++) {
1610
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1611
+ idx = _Object$entries$_i[0],
1612
+ i = _Object$entries$_i[1];
1613
+ var subPath = unsafeCreateSourcePath(path, Number(idx));
1614
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1615
+ var subError = this.item.validate(subPath, i);
1616
+ if (subError) {
1617
+ error = _objectSpread2(_objectSpread2({}, subError), error);
1475
1618
  }
1476
- });
1619
+ }
1620
+ if (Object.keys(error).length === 0) {
1621
+ return false;
1622
+ }
1477
1623
  return error;
1478
1624
  }
1479
1625
  }, {
1480
1626
  key: "assert",
1481
- value: function assert(src) {
1482
- if (this.opt && (src === null || src === undefined)) {
1483
- return true;
1627
+ value: function assert(path, src) {
1628
+ if (src === null && this.opt) {
1629
+ return {
1630
+ success: true,
1631
+ data: src
1632
+ };
1484
1633
  }
1485
- if (!src) {
1486
- return false;
1634
+ if (src === null) {
1635
+ return {
1636
+ success: false,
1637
+ errors: _defineProperty({}, path, [{
1638
+ message: "Expected 'array', got 'null'",
1639
+ typeError: true
1640
+ }])
1641
+ };
1487
1642
  }
1488
- var _iterator = result._createForOfIteratorHelper(src),
1489
- _step;
1490
- try {
1491
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1492
- var _item = _step.value;
1493
- if (!this.item.assert(_item)) {
1494
- return false;
1495
- }
1496
- }
1497
- } catch (err) {
1498
- _iterator.e(err);
1499
- } finally {
1500
- _iterator.f();
1643
+ if (_typeof(src) !== "object") {
1644
+ return {
1645
+ success: false,
1646
+ errors: _defineProperty({}, path, [{
1647
+ message: "Expected 'object', got '".concat(_typeof(src), "'"),
1648
+ typeError: true
1649
+ }])
1650
+ };
1651
+ } else if (!Array.isArray(src)) {
1652
+ return {
1653
+ success: false,
1654
+ errors: _defineProperty({}, path, [{
1655
+ message: "Expected object of type 'array'",
1656
+ typeError: true
1657
+ }])
1658
+ };
1501
1659
  }
1502
- return _typeof(src) === "object" && Array.isArray(src);
1660
+ return {
1661
+ success: true,
1662
+ data: src
1663
+ };
1503
1664
  }
1504
1665
  }, {
1505
1666
  key: "nullable",
@@ -1555,11 +1716,35 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
1555
1716
  }
1556
1717
  }, {
1557
1718
  key: "assert",
1558
- value: function assert(src) {
1559
- if (this.opt && (src === null || src === undefined)) {
1560
- return true;
1719
+ value: function assert(path, src) {
1720
+ if (this.opt && src === null) {
1721
+ return {
1722
+ success: true,
1723
+ data: src
1724
+ };
1725
+ }
1726
+ if (src === null) {
1727
+ return {
1728
+ success: false,
1729
+ errors: _defineProperty({}, path, [{
1730
+ message: "Expected 'string', got 'null'",
1731
+ typeError: true
1732
+ }])
1733
+ };
1734
+ }
1735
+ if (typeof src === "string" && src === this.value) {
1736
+ return {
1737
+ success: true,
1738
+ data: src
1739
+ };
1561
1740
  }
1562
- return typeof src === "string";
1741
+ return {
1742
+ success: false,
1743
+ errors: _defineProperty({}, path, [{
1744
+ message: "Expected literal '".concat(this.value, "', got '").concat(src, "'"),
1745
+ typeError: true
1746
+ }])
1747
+ };
1563
1748
  }
1564
1749
  }, {
1565
1750
  key: "nullable",
@@ -1599,20 +1784,20 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1599
1784
  value: function validate(path, src) {
1600
1785
  var unknownSrc = src;
1601
1786
  var errors = false;
1602
- if (this.opt && (unknownSrc === null || unknownSrc === undefined)) {
1603
- // TODO: src should never be undefined
1787
+ if (this.opt && unknownSrc === null) {
1604
1788
  return false;
1605
1789
  }
1606
1790
  if (!this.key) {
1607
1791
  return _defineProperty({}, path, [{
1608
- message: "Missing required first argument in union"
1792
+ message: "Missing required first argument in union",
1793
+ schemaError: true
1609
1794
  }]);
1610
1795
  }
1611
1796
  var key = this.key;
1612
1797
  if (!Array.isArray(this.items)) {
1613
1798
  return _defineProperty({}, path, [{
1614
1799
  message: "A union schema must take more than 1 schema arguments",
1615
- fatal: true
1800
+ schemaError: true
1616
1801
  }]);
1617
1802
  }
1618
1803
  if (typeof key === "string") {
@@ -1622,7 +1807,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1622
1807
  })) {
1623
1808
  return _defineProperty({}, path, [{
1624
1809
  message: "Key is a string, so all schema items must be objects",
1625
- fatal: true
1810
+ schemaError: true
1626
1811
  }]);
1627
1812
  }
1628
1813
  var objectSchemas = this.items;
@@ -1635,7 +1820,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1635
1820
  if (illegalSchemas.length > 0) {
1636
1821
  return _defineProperty({}, path, [{
1637
1822
  message: "All schema items must be objects with a key: ".concat(key, " that is a literal schema. Found: ").concat(JSON.stringify(illegalSchemas, null, 2)),
1638
- fatal: true
1823
+ schemaError: true
1639
1824
  }]);
1640
1825
  }
1641
1826
  var serializedObjectSchemas = serializedSchemas;
@@ -1645,18 +1830,20 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1645
1830
  if (optionalLiterals.length > 1) {
1646
1831
  return _defineProperty({}, path, [{
1647
1832
  message: "Schema cannot have an optional keys: ".concat(key),
1648
- fatal: true
1833
+ schemaError: true
1649
1834
  }]);
1650
1835
  }
1651
1836
  if (_typeof(unknownSrc) !== "object") {
1652
1837
  return _defineProperty({}, path, [{
1653
- message: "Expected an object"
1838
+ message: "Expected an object",
1839
+ typeError: true
1654
1840
  }]);
1655
1841
  }
1656
1842
  var objectSrc = unknownSrc;
1657
1843
  if (objectSrc[key] === undefined) {
1658
1844
  return _defineProperty({}, path, [{
1659
- message: "Missing required key: ".concat(key)
1845
+ message: "Missing required key: ".concat(key),
1846
+ typeError: true
1660
1847
  }]);
1661
1848
  }
1662
1849
  var foundSchemaLiterals = [];
@@ -1672,7 +1859,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1672
1859
  } else {
1673
1860
  return _defineProperty({}, path, [{
1674
1861
  message: "Found duplicate key in schema: ".concat(schemaKey.value),
1675
- fatal: true
1862
+ schemaError: true
1676
1863
  }]);
1677
1864
  }
1678
1865
  }
@@ -1712,7 +1899,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1712
1899
  })) {
1713
1900
  return _defineProperty({}, path, [{
1714
1901
  message: "Key is a literal schema, so all schema items must be literals",
1715
- fatal: true
1902
+ typeError: true
1716
1903
  }]);
1717
1904
  }
1718
1905
  var literalItems = [key].concat(_toConsumableArray(this.items));
@@ -1737,8 +1924,146 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1737
1924
  }
1738
1925
  }, {
1739
1926
  key: "assert",
1740
- value: function assert(src) {
1741
- return true;
1927
+ value: function assert(path, src) {
1928
+ if (this.opt && src === null) {
1929
+ return {
1930
+ success: true,
1931
+ data: src
1932
+ };
1933
+ }
1934
+ if (src === null) {
1935
+ return {
1936
+ success: false,
1937
+ errors: _defineProperty({}, path, [{
1938
+ message: "Expected 'object', got 'null'",
1939
+ typeError: true
1940
+ }])
1941
+ };
1942
+ }
1943
+ if (!this.key) {
1944
+ return {
1945
+ success: false,
1946
+ errors: _defineProperty({}, path, [{
1947
+ message: "Missing required first argument in union schema",
1948
+ schemaError: true
1949
+ }])
1950
+ };
1951
+ }
1952
+ if (!Array.isArray(this.items)) {
1953
+ return {
1954
+ success: false,
1955
+ errors: _defineProperty({}, path, [{
1956
+ message: "The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)",
1957
+ schemaError: true
1958
+ }])
1959
+ };
1960
+ }
1961
+ if (this.key instanceof LiteralSchema) {
1962
+ var _ref13;
1963
+ var success = false;
1964
+ var errors = {};
1965
+ var _iterator2 = result._createForOfIteratorHelper((_ref13 = [this.key]).concat.apply(_ref13, _toConsumableArray(this.items))),
1966
+ _step2;
1967
+ try {
1968
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1969
+ var itemSchema = _step2.value;
1970
+ if (!(itemSchema instanceof LiteralSchema)) {
1971
+ return {
1972
+ success: false,
1973
+ errors: _defineProperty({}, path, [{
1974
+ message: "Schema of value is a union of string, so all schema items must be literals",
1975
+ schemaError: true
1976
+ }])
1977
+ };
1978
+ }
1979
+ if (typeof src !== "string") {
1980
+ errors[path] = [{
1981
+ message: "Expected 'string', got '".concat(_typeof(src), "'"),
1982
+ typeError: true
1983
+ }];
1984
+ continue;
1985
+ }
1986
+ var res = itemSchema.assert(path, src);
1987
+ if (res.success) {
1988
+ success = true;
1989
+ break;
1990
+ } else {
1991
+ for (var _i = 0, _Object$entries = Object.entries(res.errors); _i < _Object$entries.length; _i++) {
1992
+ var _errors5;
1993
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1994
+ _key = _Object$entries$_i[0],
1995
+ value = _Object$entries$_i[1];
1996
+ if (!errors[_key]) {
1997
+ errors[_key] = [];
1998
+ }
1999
+ (_errors5 = errors[_key]).push.apply(_errors5, _toConsumableArray(value));
2000
+ }
2001
+ }
2002
+ }
2003
+ } catch (err) {
2004
+ _iterator2.e(err);
2005
+ } finally {
2006
+ _iterator2.f();
2007
+ }
2008
+ if (!success) {
2009
+ return {
2010
+ success: false,
2011
+ errors: errors
2012
+ };
2013
+ }
2014
+ return {
2015
+ success: true,
2016
+ data: src
2017
+ };
2018
+ } else if (typeof this.key === "string") {
2019
+ var _success = false;
2020
+ var _errors6 = {};
2021
+ var _iterator3 = result._createForOfIteratorHelper(this.items),
2022
+ _step3;
2023
+ try {
2024
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2025
+ var _itemSchema = _step3.value;
2026
+ var _res = _itemSchema.assert(path, src);
2027
+ if (_res.success) {
2028
+ _success = true;
2029
+ break;
2030
+ } else {
2031
+ for (var _i2 = 0, _Object$entries2 = Object.entries(_res.errors); _i2 < _Object$entries2.length; _i2++) {
2032
+ var _errors7;
2033
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
2034
+ _key2 = _Object$entries2$_i[0],
2035
+ _value = _Object$entries2$_i[1];
2036
+ if (!_errors6[_key2]) {
2037
+ _errors6[_key2] = [];
2038
+ }
2039
+ (_errors7 = _errors6[_key2]).push.apply(_errors7, _toConsumableArray(_value)); // by appending all type errors, we most likely get a lot of duplicate errors. Currently we believe this is correct though, but should probably be handled in when showing the errors to users
2040
+ }
2041
+ }
2042
+ }
2043
+ } catch (err) {
2044
+ _iterator3.e(err);
2045
+ } finally {
2046
+ _iterator3.f();
2047
+ }
2048
+ if (!_success) {
2049
+ return {
2050
+ success: false,
2051
+ errors: _errors6
2052
+ };
2053
+ }
2054
+ return {
2055
+ success: true,
2056
+ data: src
2057
+ };
2058
+ } else {
2059
+ return {
2060
+ success: false,
2061
+ errors: _defineProperty({}, path, [{
2062
+ message: "The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)",
2063
+ schemaError: true
2064
+ }])
2065
+ };
2066
+ }
1742
2067
  }
1743
2068
  }, {
1744
2069
  key: "nullable",
@@ -1771,8 +2096,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1771
2096
  return UnionSchema;
1772
2097
  }(Schema);
1773
2098
  var union = function union(key) {
1774
- for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1775
- objects[_key - 1] = arguments[_key];
2099
+ for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
2100
+ objects[_key3 - 1] = arguments[_key3];
1776
2101
  }
1777
2102
  return new UnionSchema(key, objects);
1778
2103
  };
@@ -1799,12 +2124,147 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
1799
2124
  fixes: ["fix:deprecated-richtext"]
1800
2125
  }]);
1801
2126
  }
1802
- return false; //TODO
2127
+ var assertRes = this.assert(path, src);
2128
+ if (!assertRes.success) {
2129
+ return _defineProperty({}, path, assertRes.errors[path]);
2130
+ }
2131
+ // TODO validate options
2132
+ return false;
1803
2133
  }
1804
2134
  }, {
1805
2135
  key: "assert",
1806
- value: function assert(src) {
1807
- return true; // TODO
2136
+ value: function assert(path, src) {
2137
+ if (this.opt && src === null) {
2138
+ return {
2139
+ success: true,
2140
+ data: src
2141
+ };
2142
+ }
2143
+ if (!Array.isArray(src)) {
2144
+ return {
2145
+ success: false,
2146
+ errors: _defineProperty({}, path, [{
2147
+ message: "Expected 'array', got '".concat(_typeof(src), "'"),
2148
+ typeError: true
2149
+ }])
2150
+ };
2151
+ }
2152
+ var errors = {};
2153
+ for (var i = 0; i < src.length; i++) {
2154
+ this.recursiveAssert(unsafeCreateSourcePath(path, i), src[i], errors);
2155
+ }
2156
+ if (Object.keys(errors).length > 0) {
2157
+ return {
2158
+ success: false,
2159
+ errors: errors
2160
+ };
2161
+ }
2162
+ // TODO: validate options
2163
+ return {
2164
+ success: true,
2165
+ data: src
2166
+ };
2167
+ }
2168
+ }, {
2169
+ key: "recursiveAssert",
2170
+ value: function recursiveAssert(path, node, errors) {
2171
+ if (_typeof(node) !== "object") {
2172
+ if (!errors[path]) {
2173
+ errors[path] = [];
2174
+ }
2175
+ errors[path].push({
2176
+ message: "Expected 'object', got '".concat(_typeof(node), "'"),
2177
+ typeError: true
2178
+ });
2179
+ return;
2180
+ }
2181
+ if (Array.isArray(node)) {
2182
+ if (!errors[path]) {
2183
+ errors[path] = [];
2184
+ }
2185
+ errors[path].push({
2186
+ message: "Expected 'object', got 'array'",
2187
+ typeError: true
2188
+ });
2189
+ return;
2190
+ }
2191
+ if (node === null) {
2192
+ if (!errors[path]) {
2193
+ errors[path] = [];
2194
+ }
2195
+ errors[path].push({
2196
+ message: "Expected 'object', got 'null'",
2197
+ typeError: true
2198
+ });
2199
+ return;
2200
+ }
2201
+ if ("tag" in node) {
2202
+ if (typeof node.tag !== "string") {
2203
+ if (!errors[path]) {
2204
+ errors[path] = [];
2205
+ }
2206
+ errors[path].push({
2207
+ message: "Expected 'string', got '".concat(_typeof(node.tag), "'"),
2208
+ typeError: true
2209
+ });
2210
+ return;
2211
+ }
2212
+ }
2213
+ if ("children" in node) {
2214
+ if (!Array.isArray(node.children)) {
2215
+ if (!errors[path]) {
2216
+ errors[path] = [];
2217
+ }
2218
+ errors[path].push({
2219
+ message: "Expected 'array', got '".concat(_typeof(node.children), "'"),
2220
+ typeError: true
2221
+ });
2222
+ return;
2223
+ } else {
2224
+ for (var i = 0; i < node.children.length; i++) {
2225
+ var child = node.children[i];
2226
+ var pathAtError = unsafeCreateSourcePath(unsafeCreateSourcePath(path, "children"), i);
2227
+ if (_typeof(child) === "object") {
2228
+ this.recursiveAssert(pathAtError, child, errors);
2229
+ } else if (typeof child === "string") {
2230
+ continue;
2231
+ } else {
2232
+ if (!errors[pathAtError]) {
2233
+ errors[pathAtError] = [];
2234
+ }
2235
+ errors[pathAtError].push({
2236
+ message: "Expected 'object' or 'string', got '".concat(_typeof(child), "'"),
2237
+ typeError: true
2238
+ });
2239
+ }
2240
+ }
2241
+ }
2242
+ }
2243
+ if ("styles" in node) {
2244
+ if (!Array.isArray(node.styles)) {
2245
+ if (!errors[path]) {
2246
+ errors[path] = [];
2247
+ }
2248
+ errors[path].push({
2249
+ message: "Expected 'array', got '".concat(_typeof(node.styles), "'"),
2250
+ typeError: true
2251
+ });
2252
+ } else {
2253
+ for (var _i = 0; _i < node.styles.length; _i++) {
2254
+ var style = node.styles[_i];
2255
+ if (typeof style !== "string") {
2256
+ var _pathAtError = unsafeCreateSourcePath(path, _i);
2257
+ if (!errors[_pathAtError]) {
2258
+ errors[_pathAtError] = [];
2259
+ }
2260
+ errors[_pathAtError].push({
2261
+ message: "Expected 'string', got '".concat(_typeof(style), "'"),
2262
+ typeError: true
2263
+ });
2264
+ }
2265
+ }
2266
+ }
2267
+ }
1808
2268
  }
1809
2269
  }, {
1810
2270
  key: "nullable",
@@ -1862,6 +2322,50 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1862
2322
  value: src
1863
2323
  }]);
1864
2324
  }
2325
+ var _ref4 = this.options || {},
2326
+ accept = _ref4.accept;
2327
+ var _ref5 = src.metadata || {},
2328
+ mimeType = _ref5.mimeType;
2329
+ if (accept && mimeType && !mimeType.includes("/")) {
2330
+ return _defineProperty({}, path, [{
2331
+ message: "Invalid mime type format. Got: '".concat(mimeType, "'"),
2332
+ value: src
2333
+ }]);
2334
+ }
2335
+ if (accept && mimeType && mimeType.includes("/")) {
2336
+ var acceptedTypes = accept.split(",").map(function (type) {
2337
+ return type.trim();
2338
+ });
2339
+ var isValidMimeType = acceptedTypes.some(function (acceptedType) {
2340
+ if (acceptedType === "*/*") {
2341
+ return true;
2342
+ }
2343
+ if (acceptedType.endsWith("/*")) {
2344
+ var baseType = acceptedType.slice(0, -2);
2345
+ return mimeType.startsWith(baseType);
2346
+ }
2347
+ return acceptedType === mimeType;
2348
+ });
2349
+ if (!isValidMimeType) {
2350
+ return _defineProperty({}, path, [{
2351
+ message: "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'"),
2352
+ value: src
2353
+ }]);
2354
+ }
2355
+ }
2356
+ var fileMimeType = Internal.filenameToMimeType(src[FILE_REF_PROP]);
2357
+ if (!fileMimeType) {
2358
+ return _defineProperty({}, path, [{
2359
+ message: "Could not determine mime type from file extension. Got: ".concat(src[FILE_REF_PROP]),
2360
+ value: src
2361
+ }]);
2362
+ }
2363
+ if (fileMimeType && mimeType && fileMimeType !== mimeType) {
2364
+ return _defineProperty({}, path, [{
2365
+ message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
2366
+ value: src
2367
+ }]);
2368
+ }
1865
2369
  if (src.metadata) {
1866
2370
  return _defineProperty({}, path, [{
1867
2371
  message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
@@ -1878,11 +2382,53 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1878
2382
  }
1879
2383
  }, {
1880
2384
  key: "assert",
1881
- value: function assert(src) {
1882
- if (this.opt && (src === null || src === undefined)) {
1883
- return true;
2385
+ value: function assert(path, src) {
2386
+ if (this.opt && src === null) {
2387
+ return {
2388
+ success: true,
2389
+ data: src
2390
+ };
2391
+ }
2392
+ if (src === null) {
2393
+ return {
2394
+ success: false,
2395
+ errors: _defineProperty({}, path, [{
2396
+ message: "Expected 'object', got 'null'",
2397
+ typeError: true
2398
+ }])
2399
+ };
2400
+ }
2401
+ if (_typeof(src) !== "object") {
2402
+ return {
2403
+ success: false,
2404
+ errors: _defineProperty({}, path, [{
2405
+ message: "Expected 'object', got '".concat(_typeof(src), "'"),
2406
+ typeError: true
2407
+ }])
2408
+ };
2409
+ }
2410
+ if (!(FILE_REF_PROP in src)) {
2411
+ return {
2412
+ success: false,
2413
+ errors: _defineProperty({}, path, [{
2414
+ message: "Value of this schema must use: 'c.image' (error type: missing_ref_prop)",
2415
+ typeError: true
2416
+ }])
2417
+ };
1884
2418
  }
1885
- return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "image" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
2419
+ if (!(VAL_EXTENSION in src && src[VAL_EXTENSION] === "file")) {
2420
+ return {
2421
+ success: false,
2422
+ errors: _defineProperty({}, path, [{
2423
+ message: "Value of this schema must use: 'c.image' (error type: missing_file_extension)",
2424
+ typeError: true
2425
+ }])
2426
+ };
2427
+ }
2428
+ return {
2429
+ success: true,
2430
+ data: src
2431
+ };
1886
2432
  }
1887
2433
  }, {
1888
2434
  key: "nullable",
@@ -1924,6 +2470,11 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
1924
2470
  if (this.opt && (src === null || src === undefined)) {
1925
2471
  return false;
1926
2472
  }
2473
+ if (src === null) {
2474
+ return _defineProperty({}, path, [{
2475
+ message: "Expected 'object', got 'null'"
2476
+ }]);
2477
+ }
1927
2478
  if (_typeof(src) !== "object") {
1928
2479
  return _defineProperty({}, path, [{
1929
2480
  message: "Expected 'object', got '".concat(_typeof(src), "'")
@@ -1934,10 +2485,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
1934
2485
  message: "Expected 'object', got 'array'"
1935
2486
  }]);
1936
2487
  }
1937
- Object.entries(src).forEach(function (_ref3) {
1938
- var _ref4 = _slicedToArray(_ref3, 2),
1939
- key = _ref4[0],
1940
- elem = _ref4[1];
2488
+ Object.entries(src).forEach(function (_ref4) {
2489
+ var _ref5 = _slicedToArray(_ref4, 2),
2490
+ key = _ref5[0],
2491
+ elem = _ref5[1];
1941
2492
  var subPath = createValPathOfItem(path, key);
1942
2493
  if (!subPath) {
1943
2494
  error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(elem),
@@ -1956,21 +2507,35 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
1956
2507
  }
1957
2508
  }, {
1958
2509
  key: "assert",
1959
- value: function assert(src) {
1960
- if (this.opt && (src === null || src === undefined)) {
1961
- return true;
2510
+ value: function assert(path, src) {
2511
+ if (this.opt && src === null) {
2512
+ return {
2513
+ success: true,
2514
+ data: src
2515
+ };
1962
2516
  }
1963
- if (!src) {
1964
- return false;
2517
+ if (_typeof(src) !== "object") {
2518
+ return {
2519
+ success: false,
2520
+ errors: _defineProperty({}, path, [{
2521
+ message: "Expected 'object', got '".concat(_typeof(src), "'"),
2522
+ typeError: true
2523
+ }])
2524
+ };
1965
2525
  }
1966
- for (var _i = 0, _Object$entries = Object.entries(src); _i < _Object$entries.length; _i++) {
1967
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1968
- _item = _Object$entries$_i[1];
1969
- if (!this.item.assert(_item)) {
1970
- return false;
1971
- }
2526
+ if (Array.isArray(src)) {
2527
+ return {
2528
+ success: false,
2529
+ errors: _defineProperty({}, path, [{
2530
+ message: "Expected 'object', got 'array'",
2531
+ typeError: true
2532
+ }])
2533
+ };
1972
2534
  }
1973
- return _typeof(src) === "object" && !Array.isArray(src);
2535
+ return {
2536
+ success: true,
2537
+ data: src
2538
+ };
1974
2539
  }
1975
2540
  }, {
1976
2541
  key: "nullable",
@@ -2038,7 +2603,9 @@ function isArraySchema(schema) {
2038
2603
  // );
2039
2604
  // }
2040
2605
 
2041
- function isUnionSchema(schema) {
2606
+ function isUnionSchema(schema
2607
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2608
+ ) {
2042
2609
  return schema instanceof UnionSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "union";
2043
2610
  }
2044
2611
 
@@ -2060,6 +2627,7 @@ function isImageSchema(schema) {
2060
2627
  // }
2061
2628
 
2062
2629
  function resolvePath(path, valModule, schema) {
2630
+ // TODO: use schema assert while resolving (and emit errors if any)
2063
2631
  var parts = parsePath(path);
2064
2632
  var origParts = _toConsumableArray(parts);
2065
2633
  var resolvedSchema = schema;
@@ -2154,6 +2722,7 @@ function resolvePath(path, valModule, schema) {
2154
2722
  if (!keyValue) {
2155
2723
  throw Error("Invalid path: union source ".concat(resolvedSchema, " did not have required key ").concat(_key, " in path: ").concat(path));
2156
2724
  }
2725
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2157
2726
  var schemaOfUnionKey = resolvedSchema.items.find(
2158
2727
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2159
2728
  function (child) {
@@ -2265,11 +2834,35 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
2265
2834
  }
2266
2835
  }, {
2267
2836
  key: "assert",
2268
- value: function assert(src) {
2269
- if (this.opt && (src === null || src === undefined)) {
2270
- return true;
2837
+ value: function assert(path, src) {
2838
+ if (this.opt && src === null) {
2839
+ return {
2840
+ success: true,
2841
+ data: src
2842
+ };
2843
+ }
2844
+ if (src === null) {
2845
+ return {
2846
+ success: false,
2847
+ errors: _defineProperty({}, path, [{
2848
+ message: "Expected 'number', got 'null'",
2849
+ typeError: true
2850
+ }])
2851
+ };
2852
+ }
2853
+ if (typeof src === "number") {
2854
+ return {
2855
+ success: true,
2856
+ data: src
2857
+ };
2271
2858
  }
2272
- return typeof src === "number";
2859
+ return {
2860
+ success: false,
2861
+ errors: _defineProperty({}, path, [{
2862
+ message: "Expected 'number', got '".concat(_typeof(src), "'"),
2863
+ typeError: true
2864
+ }])
2865
+ };
2273
2866
  }
2274
2867
  }, {
2275
2868
  key: "nullable",
@@ -2365,11 +2958,26 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
2365
2958
  }
2366
2959
  }, {
2367
2960
  key: "assert",
2368
- value: function assert(src) {
2369
- if (this.opt && (src === null || src === undefined)) {
2370
- return true;
2961
+ value: function assert(path, src) {
2962
+ if (this.opt && src === null) {
2963
+ return {
2964
+ success: true,
2965
+ data: src
2966
+ };
2967
+ }
2968
+ if (typeof src === "string") {
2969
+ return {
2970
+ success: true,
2971
+ data: src
2972
+ };
2371
2973
  }
2372
- return typeof src === "string";
2974
+ return {
2975
+ success: false,
2976
+ errors: _defineProperty({}, path, [{
2977
+ message: "Expected 'string', got '".concat(_typeof(src), "'"),
2978
+ typeError: true
2979
+ }])
2980
+ };
2373
2981
  }
2374
2982
  }, {
2375
2983
  key: "nullable",
@@ -2432,11 +3040,35 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
2432
3040
  }
2433
3041
  }, {
2434
3042
  key: "assert",
2435
- value: function assert(src) {
2436
- if (this.opt && (src === null || src === undefined)) {
2437
- return true;
3043
+ value: function assert(path, src) {
3044
+ if (this.opt && src === null) {
3045
+ return {
3046
+ success: true,
3047
+ data: src
3048
+ };
2438
3049
  }
2439
- return typeof src === "boolean";
3050
+ if (src === null) {
3051
+ return {
3052
+ success: false,
3053
+ errors: _defineProperty({}, path, [{
3054
+ message: "Expected 'boolean', got 'null'",
3055
+ typeError: true
3056
+ }])
3057
+ };
3058
+ }
3059
+ if (typeof src !== "boolean") {
3060
+ return {
3061
+ success: false,
3062
+ errors: _defineProperty({}, path, [{
3063
+ message: "Expected 'boolean', got '".concat(_typeof(src), "'"),
3064
+ typeError: true
3065
+ }])
3066
+ };
3067
+ }
3068
+ return {
3069
+ success: true,
3070
+ data: src
3071
+ };
2440
3072
  }
2441
3073
  }, {
2442
3074
  key: "nullable",
@@ -2512,34 +3144,79 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
2512
3144
  }
2513
3145
  }, {
2514
3146
  key: "assert",
2515
- value: function assert(src) {
2516
- if (this.opt && (src === null || src === undefined)) {
2517
- return true;
3147
+ value: function assert(path, src) {
3148
+ if (this.opt && src === null) {
3149
+ return {
3150
+ success: true,
3151
+ data: src
3152
+ };
3153
+ }
3154
+ if (src === null) {
3155
+ return {
3156
+ success: false,
3157
+ errors: _defineProperty({}, path, [{
3158
+ message: "Expected 'string', got 'null'",
3159
+ typeError: true
3160
+ }])
3161
+ };
2518
3162
  }
2519
3163
  var schema = this.schema;
2520
3164
  if (!schema) {
2521
- return false;
3165
+ return {
3166
+ success: false,
3167
+ errors: _defineProperty({}, path, [{
3168
+ message: "Neither key nor schema was found. keyOf is missing an argument.",
3169
+ typeError: true
3170
+ }])
3171
+ };
2522
3172
  }
2523
3173
  var serializedSchema = schema;
2524
3174
  if (!(serializedSchema.type === "array" || serializedSchema.type === "object" || serializedSchema.type === "record")) {
2525
- return false;
2526
- }
2527
- if (serializedSchema.opt && (src === null || src === undefined)) {
2528
- return true;
3175
+ return {
3176
+ success: false,
3177
+ errors: _defineProperty({}, path, [{
3178
+ message: "Schema of first argument must be either: 'array', 'object' or 'record'. Found '".concat(serializedSchema.type, "'"),
3179
+ typeError: true
3180
+ }])
3181
+ };
2529
3182
  }
2530
3183
  if (serializedSchema.type === "array" && typeof src !== "number") {
2531
- return false;
3184
+ return {
3185
+ success: false,
3186
+ errors: _defineProperty({}, path, [{
3187
+ message: "Value of keyOf (array) must be 'number', got '".concat(_typeof(src), "'"),
3188
+ typeError: true
3189
+ }])
3190
+ };
2532
3191
  }
2533
3192
  if (serializedSchema.type === "record" && typeof src !== "string") {
2534
- return false;
3193
+ return {
3194
+ success: false,
3195
+ errors: _defineProperty({}, path, [{
3196
+ message: "Value of keyOf (record) must be 'string', got '".concat(_typeof(src), "'"),
3197
+ typeError: true
3198
+ }])
3199
+ };
2535
3200
  }
3201
+ // We check actual value here, since TypeScript also does this. Literals are used in other types (unions),
3202
+ // and there it also makes sense to check the actual string values (i.e. that it is not just a string) since
3203
+ // missing one would lead to a runtime error. At least this is what we are thinking currently.
2536
3204
  if (serializedSchema.type === "object") {
2537
3205
  var keys = Object.keys(serializedSchema.items);
2538
3206
  if (!keys.includes(src)) {
2539
- return false;
3207
+ return {
3208
+ success: false,
3209
+ errors: _defineProperty({}, path, [{
3210
+ message: "Value of keyOf (object) must be: ".concat(keys.join(", "), ". Found: ").concat(src),
3211
+ typeError: true
3212
+ }])
3213
+ };
2540
3214
  }
2541
3215
  }
2542
- return true;
3216
+ return {
3217
+ success: true,
3218
+ data: src
3219
+ };
2543
3220
  }
2544
3221
  }, {
2545
3222
  key: "nullable",
@@ -2592,12 +3269,10 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
2592
3269
  function DateSchema(options) {
2593
3270
  var _this;
2594
3271
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2595
- var isRaw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2596
3272
  _classCallCheck(this, DateSchema);
2597
3273
  _this = _callSuper(this, DateSchema);
2598
3274
  _this.options = options;
2599
3275
  _this.opt = opt;
2600
- _this.isRaw = isRaw;
2601
3276
  return _this;
2602
3277
  }
2603
3278
  _createClass(DateSchema, [{
@@ -2618,7 +3293,7 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
2618
3293
  return _defineProperty({}, path, [{
2619
3294
  message: "From date ".concat(this.options.from, " is after to date ").concat(this.options.to),
2620
3295
  value: src,
2621
- fatal: true
3296
+ typeError: true
2622
3297
  }]);
2623
3298
  }
2624
3299
  if (src < this.options.from || src > this.options.to) {
@@ -2653,30 +3328,54 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
2653
3328
  }
2654
3329
  }, {
2655
3330
  key: "assert",
2656
- value: function assert(src) {
2657
- if (this.opt && (src === null || src === undefined)) {
2658
- return true;
3331
+ value: function assert(path, src) {
3332
+ if (this.opt && src === null) {
3333
+ return {
3334
+ success: true,
3335
+ data: src
3336
+ };
3337
+ }
3338
+ if (src === null) {
3339
+ return {
3340
+ success: false,
3341
+ errors: _defineProperty({}, path, [{
3342
+ message: "Expected 'string', got 'null'",
3343
+ typeError: true
3344
+ }])
3345
+ };
3346
+ }
3347
+ if (typeof src !== "string") {
3348
+ return {
3349
+ success: false,
3350
+ errors: _defineProperty({}, path, [{
3351
+ message: "Expected 'string', got '".concat(_typeof(src), "'"),
3352
+ typeError: true
3353
+ }])
3354
+ };
2659
3355
  }
2660
- return typeof src === "string";
3356
+ return {
3357
+ success: true,
3358
+ data: src
3359
+ };
2661
3360
  }
2662
3361
  }, {
2663
3362
  key: "from",
2664
3363
  value: function from(_from) {
2665
3364
  return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
2666
3365
  from: _from
2667
- }), this.opt, this.isRaw);
3366
+ }), this.opt);
2668
3367
  }
2669
3368
  }, {
2670
3369
  key: "to",
2671
3370
  value: function to(_to) {
2672
3371
  return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
2673
3372
  to: _to
2674
- }), this.opt, this.isRaw);
3373
+ }), this.opt);
2675
3374
  }
2676
3375
  }, {
2677
3376
  key: "nullable",
2678
3377
  value: function nullable() {
2679
- return new DateSchema(this.options, true, this.isRaw);
3378
+ return new DateSchema(this.options, true);
2680
3379
  }
2681
3380
  }, {
2682
3381
  key: "serialize",
@@ -3637,6 +4336,728 @@ var getSHA256Hash = function getSHA256Hash(bits) {
3637
4336
  return createHash().update(bits).digest("hex");
3638
4337
  };
3639
4338
 
4339
+ var EXT_TO_MIME_TYPES = {
4340
+ x3d: "application/vnd.hzn-3d-crossword",
4341
+ "3gp": "video/3gpp",
4342
+ "3g2": "video/3gpp2",
4343
+ mseq: "application/vnd.mseq",
4344
+ pwn: "application/vnd.3m.post-it-notes",
4345
+ plb: "application/vnd.3gpp.pic-bw-large",
4346
+ psb: "application/vnd.3gpp.pic-bw-small",
4347
+ pvb: "application/vnd.3gpp.pic-bw-var",
4348
+ tcap: "application/vnd.3gpp2.tcap",
4349
+ "7z": "application/x-7z-compressed",
4350
+ abw: "application/x-abiword",
4351
+ ace: "application/x-ace-compressed",
4352
+ acc: "application/vnd.americandynamics.acc",
4353
+ acu: "application/vnd.acucobol",
4354
+ atc: "application/vnd.acucorp",
4355
+ adp: "audio/adpcm",
4356
+ aab: "application/x-authorware-bin",
4357
+ aam: "application/x-authorware-map",
4358
+ aas: "application/x-authorware-seg",
4359
+ air: "application/vnd.adobe.air-application-installer-package+zip",
4360
+ swf: "application/x-shockwave-flash",
4361
+ fxp: "application/vnd.adobe.fxp",
4362
+ pdf: "application/pdf",
4363
+ ppd: "application/vnd.cups-ppd",
4364
+ dir: "application/x-director",
4365
+ xdp: "application/vnd.adobe.xdp+xml",
4366
+ xfdf: "application/vnd.adobe.xfdf",
4367
+ aac: "audio/x-aac",
4368
+ ahead: "application/vnd.ahead.space",
4369
+ azf: "application/vnd.airzip.filesecure.azf",
4370
+ azs: "application/vnd.airzip.filesecure.azs",
4371
+ azw: "application/vnd.amazon.ebook",
4372
+ ami: "application/vnd.amiga.ami",
4373
+ "N/A": "application/andrew-inset",
4374
+ apk: "application/vnd.android.package-archive",
4375
+ cii: "application/vnd.anser-web-certificate-issue-initiation",
4376
+ fti: "application/vnd.anser-web-funds-transfer-initiation",
4377
+ atx: "application/vnd.antix.game-component",
4378
+ dmg: "application/x-apple-diskimage",
4379
+ mpkg: "application/vnd.apple.installer+xml",
4380
+ aw: "application/applixware",
4381
+ mp3: "audio/mpeg",
4382
+ les: "application/vnd.hhe.lesson-player",
4383
+ swi: "application/vnd.aristanetworks.swi",
4384
+ s: "text/x-asm",
4385
+ atomcat: "application/atomcat+xml",
4386
+ atomsvc: "application/atomsvc+xml",
4387
+ atom: "application/atom+xml",
4388
+ ac: "application/pkix-attr-cert",
4389
+ aif: "audio/x-aiff",
4390
+ avi: "video/x-msvideo",
4391
+ aep: "application/vnd.audiograph",
4392
+ dxf: "image/vnd.dxf",
4393
+ dwf: "model/vnd.dwf",
4394
+ par: "text/plain-bas",
4395
+ bcpio: "application/x-bcpio",
4396
+ bin: "application/octet-stream",
4397
+ bmp: "image/bmp",
4398
+ torrent: "application/x-bittorrent",
4399
+ cod: "application/vnd.rim.cod",
4400
+ mpm: "application/vnd.blueice.multipass",
4401
+ bmi: "application/vnd.bmi",
4402
+ sh: "application/x-sh",
4403
+ btif: "image/prs.btif",
4404
+ rep: "application/vnd.businessobjects",
4405
+ bz: "application/x-bzip",
4406
+ bz2: "application/x-bzip2",
4407
+ csh: "application/x-csh",
4408
+ c: "text/x-c",
4409
+ cdxml: "application/vnd.chemdraw+xml",
4410
+ css: "text/css",
4411
+ cdx: "chemical/x-cdx",
4412
+ cml: "chemical/x-cml",
4413
+ csml: "chemical/x-csml",
4414
+ cdbcmsg: "application/vnd.contact.cmsg",
4415
+ cla: "application/vnd.claymore",
4416
+ c4g: "application/vnd.clonk.c4group",
4417
+ sub: "image/vnd.dvb.subtitle",
4418
+ cdmia: "application/cdmi-capability",
4419
+ cdmic: "application/cdmi-container",
4420
+ cdmid: "application/cdmi-domain",
4421
+ cdmio: "application/cdmi-object",
4422
+ cdmiq: "application/cdmi-queue",
4423
+ c11amc: "application/vnd.cluetrust.cartomobile-config",
4424
+ c11amz: "application/vnd.cluetrust.cartomobile-config-pkg",
4425
+ ras: "image/x-cmu-raster",
4426
+ dae: "model/vnd.collada+xml",
4427
+ csv: "text/csv",
4428
+ cpt: "application/mac-compactpro",
4429
+ wmlc: "application/vnd.wap.wmlc",
4430
+ cgm: "image/cgm",
4431
+ ice: "x-conference/x-cooltalk",
4432
+ cmx: "image/x-cmx",
4433
+ xar: "application/vnd.xara",
4434
+ cmc: "application/vnd.cosmocaller",
4435
+ cpio: "application/x-cpio",
4436
+ clkx: "application/vnd.crick.clicker",
4437
+ clkk: "application/vnd.crick.clicker.keyboard",
4438
+ clkp: "application/vnd.crick.clicker.palette",
4439
+ clkt: "application/vnd.crick.clicker.template",
4440
+ clkw: "application/vnd.crick.clicker.wordbank",
4441
+ wbs: "application/vnd.criticaltools.wbs+xml",
4442
+ cryptonote: "application/vnd.rig.cryptonote",
4443
+ cif: "chemical/x-cif",
4444
+ cmdf: "chemical/x-cmdf",
4445
+ cu: "application/cu-seeme",
4446
+ cww: "application/prs.cww",
4447
+ curl: "text/vnd.curl",
4448
+ dcurl: "text/vnd.curl.dcurl",
4449
+ mcurl: "text/vnd.curl.mcurl",
4450
+ scurl: "text/vnd.curl.scurl",
4451
+ car: "application/vnd.curl.car",
4452
+ pcurl: "application/vnd.curl.pcurl",
4453
+ cmp: "application/vnd.yellowriver-custom-menu",
4454
+ dssc: "application/dssc+der",
4455
+ xdssc: "application/dssc+xml",
4456
+ deb: "application/x-debian-package",
4457
+ uva: "audio/vnd.dece.audio",
4458
+ uvi: "image/vnd.dece.graphic",
4459
+ uvh: "video/vnd.dece.hd",
4460
+ uvm: "video/vnd.dece.mobile",
4461
+ uvu: "video/vnd.uvvu.mp4",
4462
+ uvp: "video/vnd.dece.pd",
4463
+ uvs: "video/vnd.dece.sd",
4464
+ uvv: "video/vnd.dece.video",
4465
+ dvi: "application/x-dvi",
4466
+ seed: "application/vnd.fdsn.seed",
4467
+ dtb: "application/x-dtbook+xml",
4468
+ res: "application/x-dtbresource+xml",
4469
+ ait: "application/vnd.dvb.ait",
4470
+ svc: "application/vnd.dvb.service",
4471
+ eol: "audio/vnd.digital-winds",
4472
+ djvu: "image/vnd.djvu",
4473
+ dtd: "application/xml-dtd",
4474
+ mlp: "application/vnd.dolby.mlp",
4475
+ wad: "application/x-doom",
4476
+ dpg: "application/vnd.dpgraph",
4477
+ dra: "audio/vnd.dra",
4478
+ dfac: "application/vnd.dreamfactory",
4479
+ dts: "audio/vnd.dts",
4480
+ dtshd: "audio/vnd.dts.hd",
4481
+ dwg: "image/vnd.dwg",
4482
+ geo: "application/vnd.dynageo",
4483
+ es: "application/ecmascript",
4484
+ mag: "application/vnd.ecowin.chart",
4485
+ mmr: "image/vnd.fujixerox.edmics-mmr",
4486
+ rlc: "image/vnd.fujixerox.edmics-rlc",
4487
+ exi: "application/exi",
4488
+ mgz: "application/vnd.proteus.magazine",
4489
+ epub: "application/epub+zip",
4490
+ eml: "message/rfc822",
4491
+ nml: "application/vnd.enliven",
4492
+ xpr: "application/vnd.is-xpr",
4493
+ xif: "image/vnd.xiff",
4494
+ xfdl: "application/vnd.xfdl",
4495
+ emma: "application/emma+xml",
4496
+ ez2: "application/vnd.ezpix-album",
4497
+ ez3: "application/vnd.ezpix-package",
4498
+ fst: "image/vnd.fst",
4499
+ fvt: "video/vnd.fvt",
4500
+ fbs: "image/vnd.fastbidsheet",
4501
+ fe_launch: "application/vnd.denovo.fcselayout-link",
4502
+ f4v: "video/x-f4v",
4503
+ flv: "video/x-flv",
4504
+ fpx: "image/vnd.fpx",
4505
+ npx: "image/vnd.net-fpx",
4506
+ flx: "text/vnd.fmi.flexstor",
4507
+ fli: "video/x-fli",
4508
+ ftc: "application/vnd.fluxtime.clip",
4509
+ fdf: "application/vnd.fdf",
4510
+ f: "text/x-fortran",
4511
+ mif: "application/vnd.mif",
4512
+ fm: "application/vnd.framemaker",
4513
+ fh: "image/x-freehand",
4514
+ fsc: "application/vnd.fsc.weblaunch",
4515
+ fnc: "application/vnd.frogans.fnc",
4516
+ ltf: "application/vnd.frogans.ltf",
4517
+ ddd: "application/vnd.fujixerox.ddd",
4518
+ xdw: "application/vnd.fujixerox.docuworks",
4519
+ xbd: "application/vnd.fujixerox.docuworks.binder",
4520
+ oas: "application/vnd.fujitsu.oasys",
4521
+ oa2: "application/vnd.fujitsu.oasys2",
4522
+ oa3: "application/vnd.fujitsu.oasys3",
4523
+ fg5: "application/vnd.fujitsu.oasysgp",
4524
+ bh2: "application/vnd.fujitsu.oasysprs",
4525
+ spl: "application/x-futuresplash",
4526
+ fzs: "application/vnd.fuzzysheet",
4527
+ g3: "image/g3fax",
4528
+ gmx: "application/vnd.gmx",
4529
+ gtw: "model/vnd.gtw",
4530
+ txd: "application/vnd.genomatix.tuxedo",
4531
+ ggb: "application/vnd.geogebra.file",
4532
+ ggt: "application/vnd.geogebra.tool",
4533
+ gdl: "model/vnd.gdl",
4534
+ gex: "application/vnd.geometry-explorer",
4535
+ gxt: "application/vnd.geonext",
4536
+ g2w: "application/vnd.geoplan",
4537
+ g3w: "application/vnd.geospace",
4538
+ gsf: "application/x-font-ghostscript",
4539
+ bdf: "application/x-font-bdf",
4540
+ gtar: "application/x-gtar",
4541
+ texinfo: "application/x-texinfo",
4542
+ gnumeric: "application/x-gnumeric",
4543
+ kml: "application/vnd.google-earth.kml+xml",
4544
+ kmz: "application/vnd.google-earth.kmz",
4545
+ gqf: "application/vnd.grafeq",
4546
+ gif: "image/gif",
4547
+ gv: "text/vnd.graphviz",
4548
+ gac: "application/vnd.groove-account",
4549
+ ghf: "application/vnd.groove-help",
4550
+ gim: "application/vnd.groove-identity-message",
4551
+ grv: "application/vnd.groove-injector",
4552
+ gtm: "application/vnd.groove-tool-message",
4553
+ tpl: "application/vnd.groove-tool-template",
4554
+ vcg: "application/vnd.groove-vcard",
4555
+ h261: "video/h261",
4556
+ h263: "video/h263",
4557
+ h264: "video/h264",
4558
+ hpid: "application/vnd.hp-hpid",
4559
+ hps: "application/vnd.hp-hps",
4560
+ hdf: "application/x-hdf",
4561
+ rip: "audio/vnd.rip",
4562
+ hbci: "application/vnd.hbci",
4563
+ jlt: "application/vnd.hp-jlyt",
4564
+ pcl: "application/vnd.hp-pcl",
4565
+ hpgl: "application/vnd.hp-hpgl",
4566
+ hvs: "application/vnd.yamaha.hv-script",
4567
+ hvd: "application/vnd.yamaha.hv-dic",
4568
+ hvp: "application/vnd.yamaha.hv-voice",
4569
+ "sfd-hdstx": "application/vnd.hydrostatix.sof-data",
4570
+ stk: "application/hyperstudio",
4571
+ hal: "application/vnd.hal+xml",
4572
+ html: "text/html",
4573
+ irm: "application/vnd.ibm.rights-management",
4574
+ sc: "application/vnd.ibm.secure-container",
4575
+ ics: "text/calendar",
4576
+ icc: "application/vnd.iccprofile",
4577
+ ico: "image/x-icon",
4578
+ igl: "application/vnd.igloader",
4579
+ ief: "image/ief",
4580
+ ivp: "application/vnd.immervision-ivp",
4581
+ ivu: "application/vnd.immervision-ivu",
4582
+ rif: "application/reginfo+xml",
4583
+ "3dml": "text/vnd.in3d.3dml",
4584
+ spot: "text/vnd.in3d.spot",
4585
+ igs: "model/iges",
4586
+ i2g: "application/vnd.intergeo",
4587
+ cdy: "application/vnd.cinderella",
4588
+ xpw: "application/vnd.intercon.formnet",
4589
+ fcs: "application/vnd.isac.fcs",
4590
+ ipfix: "application/ipfix",
4591
+ cer: "application/pkix-cert",
4592
+ pki: "application/pkixcmp",
4593
+ crl: "application/pkix-crl",
4594
+ pkipath: "application/pkix-pkipath",
4595
+ igm: "application/vnd.insors.igm",
4596
+ rcprofile: "application/vnd.ipunplugged.rcprofile",
4597
+ irp: "application/vnd.irepository.package+xml",
4598
+ jad: "text/vnd.sun.j2me.app-descriptor",
4599
+ jar: "application/java-archive",
4600
+ "class": "application/java-vm",
4601
+ jnlp: "application/x-java-jnlp-file",
4602
+ ser: "application/java-serialized-object",
4603
+ java: "text/x-java-source,java",
4604
+ js: "application/javascript",
4605
+ json: "application/json",
4606
+ joda: "application/vnd.joost.joda-archive",
4607
+ jpm: "video/jpm",
4608
+ jpeg: "image/jpeg",
4609
+ jpg: "image/jpeg",
4610
+ pjpeg: "image/pjpeg",
4611
+ jpgv: "video/jpeg",
4612
+ ktz: "application/vnd.kahootz",
4613
+ mmd: "application/vnd.chipnuts.karaoke-mmd",
4614
+ karbon: "application/vnd.kde.karbon",
4615
+ chrt: "application/vnd.kde.kchart",
4616
+ kfo: "application/vnd.kde.kformula",
4617
+ flw: "application/vnd.kde.kivio",
4618
+ kon: "application/vnd.kde.kontour",
4619
+ kpr: "application/vnd.kde.kpresenter",
4620
+ ksp: "application/vnd.kde.kspread",
4621
+ kwd: "application/vnd.kde.kword",
4622
+ htke: "application/vnd.kenameaapp",
4623
+ kia: "application/vnd.kidspiration",
4624
+ kne: "application/vnd.kinar",
4625
+ sse: "application/vnd.kodak-descriptor",
4626
+ lasxml: "application/vnd.las.las+xml",
4627
+ latex: "application/x-latex",
4628
+ lbd: "application/vnd.llamagraphics.life-balance.desktop",
4629
+ lbe: "application/vnd.llamagraphics.life-balance.exchange+xml",
4630
+ jam: "application/vnd.jam",
4631
+ "123": "application/vnd.lotus-1-2-3",
4632
+ apr: "application/vnd.lotus-approach",
4633
+ pre: "application/vnd.lotus-freelance",
4634
+ nsf: "application/vnd.lotus-notes",
4635
+ org: "application/vnd.lotus-organizer",
4636
+ scm: "application/vnd.lotus-screencam",
4637
+ lwp: "application/vnd.lotus-wordpro",
4638
+ lvp: "audio/vnd.lucent.voice",
4639
+ m3u: "audio/x-mpegurl",
4640
+ m4v: "video/x-m4v",
4641
+ hqx: "application/mac-binhex40",
4642
+ portpkg: "application/vnd.macports.portpkg",
4643
+ mgp: "application/vnd.osgeo.mapguide.package",
4644
+ mrc: "application/marc",
4645
+ mrcx: "application/marcxml+xml",
4646
+ mxf: "application/mxf",
4647
+ nbp: "application/vnd.wolfram.player",
4648
+ ma: "application/mathematica",
4649
+ mathml: "application/mathml+xml",
4650
+ mbox: "application/mbox",
4651
+ mc1: "application/vnd.medcalcdata",
4652
+ mscml: "application/mediaservercontrol+xml",
4653
+ cdkey: "application/vnd.mediastation.cdkey",
4654
+ mwf: "application/vnd.mfer",
4655
+ mfm: "application/vnd.mfmp",
4656
+ msh: "model/mesh",
4657
+ mads: "application/mads+xml",
4658
+ mets: "application/mets+xml",
4659
+ mods: "application/mods+xml",
4660
+ meta4: "application/metalink4+xml",
4661
+ mcd: "application/vnd.mcd",
4662
+ flo: "application/vnd.micrografx.flo",
4663
+ igx: "application/vnd.micrografx.igx",
4664
+ es3: "application/vnd.eszigno3+xml",
4665
+ mdb: "application/x-msaccess",
4666
+ asf: "video/x-ms-asf",
4667
+ exe: "application/x-msdownload",
4668
+ cil: "application/vnd.ms-artgalry",
4669
+ cab: "application/vnd.ms-cab-compressed",
4670
+ ims: "application/vnd.ms-ims",
4671
+ application: "application/x-ms-application",
4672
+ clp: "application/x-msclip",
4673
+ mdi: "image/vnd.ms-modi",
4674
+ eot: "application/vnd.ms-fontobject",
4675
+ xls: "application/vnd.ms-excel",
4676
+ xlam: "application/vnd.ms-excel.addin.macroenabled.12",
4677
+ xlsb: "application/vnd.ms-excel.sheet.binary.macroenabled.12",
4678
+ xltm: "application/vnd.ms-excel.template.macroenabled.12",
4679
+ xlsm: "application/vnd.ms-excel.sheet.macroenabled.12",
4680
+ chm: "application/vnd.ms-htmlhelp",
4681
+ crd: "application/x-mscardfile",
4682
+ lrm: "application/vnd.ms-lrm",
4683
+ mvb: "application/x-msmediaview",
4684
+ mny: "application/x-msmoney",
4685
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
4686
+ sldx: "application/vnd.openxmlformats-officedocument.presentationml.slide",
4687
+ ppsx: "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
4688
+ potx: "application/vnd.openxmlformats-officedocument.presentationml.template",
4689
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
4690
+ xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
4691
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
4692
+ dotx: "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
4693
+ obd: "application/x-msbinder",
4694
+ thmx: "application/vnd.ms-officetheme",
4695
+ onetoc: "application/onenote",
4696
+ pya: "audio/vnd.ms-playready.media.pya",
4697
+ pyv: "video/vnd.ms-playready.media.pyv",
4698
+ ppt: "application/vnd.ms-powerpoint",
4699
+ ppam: "application/vnd.ms-powerpoint.addin.macroenabled.12",
4700
+ sldm: "application/vnd.ms-powerpoint.slide.macroenabled.12",
4701
+ pptm: "application/vnd.ms-powerpoint.presentation.macroenabled.12",
4702
+ ppsm: "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
4703
+ potm: "application/vnd.ms-powerpoint.template.macroenabled.12",
4704
+ mpp: "application/vnd.ms-project",
4705
+ pub: "application/x-mspublisher",
4706
+ scd: "application/x-msschedule",
4707
+ xap: "application/x-silverlight-app",
4708
+ stl: "application/vnd.ms-pki.stl",
4709
+ cat: "application/vnd.ms-pki.seccat",
4710
+ vsd: "application/vnd.visio",
4711
+ vsdx: "application/vnd.visio2013",
4712
+ wm: "video/x-ms-wm",
4713
+ wma: "audio/x-ms-wma",
4714
+ wax: "audio/x-ms-wax",
4715
+ wmx: "video/x-ms-wmx",
4716
+ wmd: "application/x-ms-wmd",
4717
+ wpl: "application/vnd.ms-wpl",
4718
+ wmz: "application/x-ms-wmz",
4719
+ wmv: "video/x-ms-wmv",
4720
+ wvx: "video/x-ms-wvx",
4721
+ wmf: "application/x-msmetafile",
4722
+ trm: "application/x-msterminal",
4723
+ doc: "application/msword",
4724
+ docm: "application/vnd.ms-word.document.macroenabled.12",
4725
+ dotm: "application/vnd.ms-word.template.macroenabled.12",
4726
+ wri: "application/x-mswrite",
4727
+ wps: "application/vnd.ms-works",
4728
+ xbap: "application/x-ms-xbap",
4729
+ xps: "application/vnd.ms-xpsdocument",
4730
+ mid: "audio/midi",
4731
+ mpy: "application/vnd.ibm.minipay",
4732
+ afp: "application/vnd.ibm.modcap",
4733
+ rms: "application/vnd.jcp.javame.midlet-rms",
4734
+ tmo: "application/vnd.tmobile-livetv",
4735
+ prc: "application/x-mobipocket-ebook",
4736
+ mbk: "application/vnd.mobius.mbk",
4737
+ dis: "application/vnd.mobius.dis",
4738
+ plc: "application/vnd.mobius.plc",
4739
+ mqy: "application/vnd.mobius.mqy",
4740
+ msl: "application/vnd.mobius.msl",
4741
+ txf: "application/vnd.mobius.txf",
4742
+ daf: "application/vnd.mobius.daf",
4743
+ fly: "text/vnd.fly",
4744
+ mpc: "application/vnd.mophun.certificate",
4745
+ mpn: "application/vnd.mophun.application",
4746
+ mj2: "video/mj2",
4747
+ mpga: "audio/mpeg",
4748
+ mxu: "video/vnd.mpegurl",
4749
+ mpeg: "video/mpeg",
4750
+ m21: "application/mp21",
4751
+ mp4a: "audio/mp4",
4752
+ mp4: "video/mp4",
4753
+ m3u8: "application/vnd.apple.mpegurl",
4754
+ mus: "application/vnd.musician",
4755
+ msty: "application/vnd.muvee.style",
4756
+ mxml: "application/xv+xml",
4757
+ ngdat: "application/vnd.nokia.n-gage.data",
4758
+ "n-gage": "application/vnd.nokia.n-gage.symbian.install",
4759
+ ncx: "application/x-dtbncx+xml",
4760
+ nc: "application/x-netcdf",
4761
+ nlu: "application/vnd.neurolanguage.nlu",
4762
+ dna: "application/vnd.dna",
4763
+ nnd: "application/vnd.noblenet-directory",
4764
+ nns: "application/vnd.noblenet-sealer",
4765
+ nnw: "application/vnd.noblenet-web",
4766
+ rpst: "application/vnd.nokia.radio-preset",
4767
+ rpss: "application/vnd.nokia.radio-presets",
4768
+ n3: "text/n3",
4769
+ edm: "application/vnd.novadigm.edm",
4770
+ edx: "application/vnd.novadigm.edx",
4771
+ ext: "application/vnd.novadigm.ext",
4772
+ gph: "application/vnd.flographit",
4773
+ ecelp4800: "audio/vnd.nuera.ecelp4800",
4774
+ ecelp7470: "audio/vnd.nuera.ecelp7470",
4775
+ ecelp9600: "audio/vnd.nuera.ecelp9600",
4776
+ oda: "application/oda",
4777
+ ogx: "application/ogg",
4778
+ oga: "audio/ogg",
4779
+ ogv: "video/ogg",
4780
+ dd2: "application/vnd.oma.dd2+xml",
4781
+ oth: "application/vnd.oasis.opendocument.text-web",
4782
+ opf: "application/oebps-package+xml",
4783
+ qbo: "application/vnd.intu.qbo",
4784
+ oxt: "application/vnd.openofficeorg.extension",
4785
+ osf: "application/vnd.yamaha.openscoreformat",
4786
+ weba: "audio/webm",
4787
+ webm: "video/webm",
4788
+ odc: "application/vnd.oasis.opendocument.chart",
4789
+ otc: "application/vnd.oasis.opendocument.chart-template",
4790
+ odb: "application/vnd.oasis.opendocument.database",
4791
+ odf: "application/vnd.oasis.opendocument.formula",
4792
+ odft: "application/vnd.oasis.opendocument.formula-template",
4793
+ odg: "application/vnd.oasis.opendocument.graphics",
4794
+ otg: "application/vnd.oasis.opendocument.graphics-template",
4795
+ odi: "application/vnd.oasis.opendocument.image",
4796
+ oti: "application/vnd.oasis.opendocument.image-template",
4797
+ odp: "application/vnd.oasis.opendocument.presentation",
4798
+ otp: "application/vnd.oasis.opendocument.presentation-template",
4799
+ ods: "application/vnd.oasis.opendocument.spreadsheet",
4800
+ ots: "application/vnd.oasis.opendocument.spreadsheet-template",
4801
+ odt: "application/vnd.oasis.opendocument.text",
4802
+ odm: "application/vnd.oasis.opendocument.text-master",
4803
+ ott: "application/vnd.oasis.opendocument.text-template",
4804
+ ktx: "image/ktx",
4805
+ sxc: "application/vnd.sun.xml.calc",
4806
+ stc: "application/vnd.sun.xml.calc.template",
4807
+ sxd: "application/vnd.sun.xml.draw",
4808
+ std: "application/vnd.sun.xml.draw.template",
4809
+ sxi: "application/vnd.sun.xml.impress",
4810
+ sti: "application/vnd.sun.xml.impress.template",
4811
+ sxm: "application/vnd.sun.xml.math",
4812
+ sxw: "application/vnd.sun.xml.writer",
4813
+ sxg: "application/vnd.sun.xml.writer.global",
4814
+ stw: "application/vnd.sun.xml.writer.template",
4815
+ otf: "application/x-font-otf",
4816
+ osfpvg: "application/vnd.yamaha.openscoreformat.osfpvg+xml",
4817
+ dp: "application/vnd.osgi.dp",
4818
+ pdb: "application/vnd.palm",
4819
+ p: "text/x-pascal",
4820
+ paw: "application/vnd.pawaafile",
4821
+ pclxl: "application/vnd.hp-pclxl",
4822
+ efif: "application/vnd.picsel",
4823
+ pcx: "image/x-pcx",
4824
+ psd: "image/vnd.adobe.photoshop",
4825
+ prf: "application/pics-rules",
4826
+ pic: "image/x-pict",
4827
+ chat: "application/x-chat",
4828
+ p10: "application/pkcs10",
4829
+ p12: "application/x-pkcs12",
4830
+ p7m: "application/pkcs7-mime",
4831
+ p7s: "application/pkcs7-signature",
4832
+ p7r: "application/x-pkcs7-certreqresp",
4833
+ p7b: "application/x-pkcs7-certificates",
4834
+ p8: "application/pkcs8",
4835
+ plf: "application/vnd.pocketlearn",
4836
+ pnm: "image/x-portable-anymap",
4837
+ pbm: "image/x-portable-bitmap",
4838
+ pcf: "application/x-font-pcf",
4839
+ pfr: "application/font-tdpfr",
4840
+ pgn: "application/x-chess-pgn",
4841
+ pgm: "image/x-portable-graymap",
4842
+ png: "image/png",
4843
+ ppm: "image/x-portable-pixmap",
4844
+ pskcxml: "application/pskc+xml",
4845
+ pml: "application/vnd.ctc-posml",
4846
+ ai: "application/postscript",
4847
+ pfa: "application/x-font-type1",
4848
+ pbd: "application/vnd.powerbuilder6",
4849
+ pgp: "application/pgp-signature",
4850
+ box: "application/vnd.previewsystems.box",
4851
+ ptid: "application/vnd.pvi.ptid1",
4852
+ pls: "application/pls+xml",
4853
+ str: "application/vnd.pg.format",
4854
+ ei6: "application/vnd.pg.osasli",
4855
+ dsc: "text/prs.lines.tag",
4856
+ psf: "application/x-font-linux-psf",
4857
+ qps: "application/vnd.publishare-delta-tree",
4858
+ wg: "application/vnd.pmi.widget",
4859
+ qxd: "application/vnd.quark.quarkxpress",
4860
+ esf: "application/vnd.epson.esf",
4861
+ msf: "application/vnd.epson.msf",
4862
+ ssf: "application/vnd.epson.ssf",
4863
+ qam: "application/vnd.epson.quickanime",
4864
+ qfx: "application/vnd.intu.qfx",
4865
+ qt: "video/quicktime",
4866
+ rar: "application/x-rar-compressed",
4867
+ ram: "audio/x-pn-realaudio",
4868
+ rmp: "audio/x-pn-realaudio-plugin",
4869
+ rsd: "application/rsd+xml",
4870
+ rm: "application/vnd.rn-realmedia",
4871
+ bed: "application/vnd.realvnc.bed",
4872
+ mxl: "application/vnd.recordare.musicxml",
4873
+ musicxml: "application/vnd.recordare.musicxml+xml",
4874
+ rnc: "application/relax-ng-compact-syntax",
4875
+ rdz: "application/vnd.data-vision.rdz",
4876
+ rdf: "application/rdf+xml",
4877
+ rp9: "application/vnd.cloanto.rp9",
4878
+ jisp: "application/vnd.jisp",
4879
+ rtf: "application/rtf",
4880
+ rtx: "text/richtext",
4881
+ link66: "application/vnd.route66.link66+xml",
4882
+ rss: "application/rss+xml",
4883
+ shf: "application/shf+xml",
4884
+ st: "application/vnd.sailingtracker.track",
4885
+ svg: "image/svg+xml",
4886
+ sus: "application/vnd.sus-calendar",
4887
+ sru: "application/sru+xml",
4888
+ setpay: "application/set-payment-initiation",
4889
+ setreg: "application/set-registration-initiation",
4890
+ sema: "application/vnd.sema",
4891
+ semd: "application/vnd.semd",
4892
+ semf: "application/vnd.semf",
4893
+ see: "application/vnd.seemail",
4894
+ snf: "application/x-font-snf",
4895
+ spq: "application/scvp-vp-request",
4896
+ spp: "application/scvp-vp-response",
4897
+ scq: "application/scvp-cv-request",
4898
+ scs: "application/scvp-cv-response",
4899
+ sdp: "application/sdp",
4900
+ etx: "text/x-setext",
4901
+ movie: "video/x-sgi-movie",
4902
+ ifm: "application/vnd.shana.informed.formdata",
4903
+ itp: "application/vnd.shana.informed.formtemplate",
4904
+ iif: "application/vnd.shana.informed.interchange",
4905
+ ipk: "application/vnd.shana.informed.package",
4906
+ tfi: "application/thraud+xml",
4907
+ shar: "application/x-shar",
4908
+ rgb: "image/x-rgb",
4909
+ slt: "application/vnd.epson.salt",
4910
+ aso: "application/vnd.accpac.simply.aso",
4911
+ imp: "application/vnd.accpac.simply.imp",
4912
+ twd: "application/vnd.simtech-mindmapper",
4913
+ csp: "application/vnd.commonspace",
4914
+ saf: "application/vnd.yamaha.smaf-audio",
4915
+ mmf: "application/vnd.smaf",
4916
+ spf: "application/vnd.yamaha.smaf-phrase",
4917
+ teacher: "application/vnd.smart.teacher",
4918
+ svd: "application/vnd.svd",
4919
+ rq: "application/sparql-query",
4920
+ srx: "application/sparql-results+xml",
4921
+ gram: "application/srgs",
4922
+ grxml: "application/srgs+xml",
4923
+ ssml: "application/ssml+xml",
4924
+ skp: "application/vnd.koan",
4925
+ sgml: "text/sgml",
4926
+ sdc: "application/vnd.stardivision.calc",
4927
+ sda: "application/vnd.stardivision.draw",
4928
+ sdd: "application/vnd.stardivision.impress",
4929
+ smf: "application/vnd.stardivision.math",
4930
+ sdw: "application/vnd.stardivision.writer",
4931
+ sgl: "application/vnd.stardivision.writer-global",
4932
+ sm: "application/vnd.stepmania.stepchart",
4933
+ sit: "application/x-stuffit",
4934
+ sitx: "application/x-stuffitx",
4935
+ sdkm: "application/vnd.solent.sdkm+xml",
4936
+ xo: "application/vnd.olpc-sugar",
4937
+ au: "audio/basic",
4938
+ wqd: "application/vnd.wqd",
4939
+ sis: "application/vnd.symbian.install",
4940
+ smi: "application/smil+xml",
4941
+ xsm: "application/vnd.syncml+xml",
4942
+ bdm: "application/vnd.syncml.dm+wbxml",
4943
+ xdm: "application/vnd.syncml.dm+xml",
4944
+ sv4cpio: "application/x-sv4cpio",
4945
+ sv4crc: "application/x-sv4crc",
4946
+ sbml: "application/sbml+xml",
4947
+ tsv: "text/tab-separated-values",
4948
+ tiff: "image/tiff",
4949
+ tao: "application/vnd.tao.intent-module-archive",
4950
+ tar: "application/x-tar",
4951
+ tcl: "application/x-tcl",
4952
+ tex: "application/x-tex",
4953
+ tfm: "application/x-tex-tfm",
4954
+ tei: "application/tei+xml",
4955
+ txt: "text/plain",
4956
+ dxp: "application/vnd.spotfire.dxp",
4957
+ sfs: "application/vnd.spotfire.sfs",
4958
+ tsd: "application/timestamped-data",
4959
+ tpt: "application/vnd.trid.tpt",
4960
+ mxs: "application/vnd.triscape.mxs",
4961
+ t: "text/troff",
4962
+ tra: "application/vnd.trueapp",
4963
+ ttf: "application/x-font-ttf",
4964
+ ttl: "text/turtle",
4965
+ umj: "application/vnd.umajin",
4966
+ uoml: "application/vnd.uoml+xml",
4967
+ unityweb: "application/vnd.unity",
4968
+ ufd: "application/vnd.ufdl",
4969
+ uri: "text/uri-list",
4970
+ utz: "application/vnd.uiq.theme",
4971
+ ustar: "application/x-ustar",
4972
+ uu: "text/x-uuencode",
4973
+ vcs: "text/x-vcalendar",
4974
+ vcf: "text/x-vcard",
4975
+ vcd: "application/x-cdlink",
4976
+ vsf: "application/vnd.vsf",
4977
+ wrl: "model/vrml",
4978
+ vcx: "application/vnd.vcx",
4979
+ mts: "model/vnd.mts",
4980
+ vtu: "model/vnd.vtu",
4981
+ vis: "application/vnd.visionary",
4982
+ viv: "video/vnd.vivo",
4983
+ ccxml: "application/ccxml+xml,",
4984
+ vxml: "application/voicexml+xml",
4985
+ src: "application/x-wais-source",
4986
+ wbxml: "application/vnd.wap.wbxml",
4987
+ wbmp: "image/vnd.wap.wbmp",
4988
+ wav: "audio/x-wav",
4989
+ davmount: "application/davmount+xml",
4990
+ woff: "application/x-font-woff",
4991
+ wspolicy: "application/wspolicy+xml",
4992
+ webp: "image/webp",
4993
+ wtb: "application/vnd.webturbo",
4994
+ wgt: "application/widget",
4995
+ hlp: "application/winhlp",
4996
+ wml: "text/vnd.wap.wml",
4997
+ wmls: "text/vnd.wap.wmlscript",
4998
+ wmlsc: "application/vnd.wap.wmlscriptc",
4999
+ wpd: "application/vnd.wordperfect",
5000
+ stf: "application/vnd.wt.stf",
5001
+ wsdl: "application/wsdl+xml",
5002
+ xbm: "image/x-xbitmap",
5003
+ xpm: "image/x-xpixmap",
5004
+ xwd: "image/x-xwindowdump",
5005
+ der: "application/x-x509-ca-cert",
5006
+ fig: "application/x-xfig",
5007
+ xhtml: "application/xhtml+xml",
5008
+ xml: "application/xml",
5009
+ xdf: "application/xcap-diff+xml",
5010
+ xenc: "application/xenc+xml",
5011
+ xer: "application/patch-ops-error+xml",
5012
+ rl: "application/resource-lists+xml",
5013
+ rs: "application/rls-services+xml",
5014
+ rld: "application/resource-lists-diff+xml",
5015
+ xslt: "application/xslt+xml",
5016
+ xop: "application/xop+xml",
5017
+ xpi: "application/x-xpinstall",
5018
+ xspf: "application/xspf+xml",
5019
+ xul: "application/vnd.mozilla.xul+xml",
5020
+ xyz: "chemical/x-xyz",
5021
+ yaml: "text/yaml",
5022
+ yang: "application/yang",
5023
+ yin: "application/yin+xml",
5024
+ zir: "application/vnd.zul",
5025
+ zip: "application/zip",
5026
+ zmm: "application/vnd.handheld-entertainment+xml",
5027
+ zaz: "application/vnd.zzazz.deck+xml"
5028
+ };
5029
+
5030
+ // TODO: write this out to avoid compute
5031
+ var MIME_TYPES_TO_EXT = Object.fromEntries(Object.entries(EXT_TO_MIME_TYPES).map(function (_ref) {
5032
+ var _ref2 = _slicedToArray(_ref, 2),
5033
+ k = _ref2[0],
5034
+ v = _ref2[1];
5035
+ return [v, k];
5036
+ }));
5037
+
5038
+ var MIME_TYPE_REGEX = /^data:(.*?);base64,/;
5039
+ function getMimeType(base64Url) {
5040
+ var match = MIME_TYPE_REGEX.exec(base64Url);
5041
+ if (match && match[1]) {
5042
+ return match[1];
5043
+ }
5044
+ return;
5045
+ }
5046
+ function mimeTypeToFileExt(mimeType) {
5047
+ var recognizedMimeType = MIME_TYPES_TO_EXT[mimeType];
5048
+ if (recognizedMimeType) {
5049
+ return recognizedMimeType;
5050
+ }
5051
+ return mimeType.split("/")[1];
5052
+ }
5053
+ function filenameToMimeType(filename) {
5054
+ var ext = filename.split(".").pop();
5055
+ var recognizedExt = ext && EXT_TO_MIME_TYPES[ext];
5056
+ if (recognizedExt) {
5057
+ return recognizedExt;
5058
+ }
5059
+ }
5060
+
3640
5061
  function deserializeSchema(serialized) {
3641
5062
  var _serialized$options;
3642
5063
  switch (serialized.type) {
@@ -3660,9 +5081,16 @@ function deserializeSchema(serialized) {
3660
5081
  case "array":
3661
5082
  return new ArraySchema(deserializeSchema(serialized.item), serialized.opt);
3662
5083
  case "union":
3663
- return new UnionSchema(typeof serialized.key === "string" ? serialized.key : deserializeSchema(serialized.key), serialized.items.map(deserializeSchema), serialized.opt);
5084
+ return new UnionSchema(typeof serialized.key === "string" ? serialized.key :
5085
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5086
+ deserializeSchema(serialized.key),
5087
+ // TODO: we do not really need any here - right?
5088
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5089
+ serialized.items.map(deserializeSchema),
5090
+ // TODO: we do not really need any here - right?
5091
+ serialized.opt);
3664
5092
  case "richtext":
3665
- return new RichTextSchema(serialized.options, serialized.opt);
5093
+ return new RichTextSchema(serialized.options || {}, serialized.opt);
3666
5094
  case "record":
3667
5095
  return new RecordSchema(deserializeSchema(serialized.item), serialized.opt);
3668
5096
  case "keyOf":
@@ -3686,671 +5114,6 @@ function deserializeSchema(serialized) {
3686
5114
  }
3687
5115
  }
3688
5116
 
3689
- function _regeneratorRuntime() {
3690
- _regeneratorRuntime = function () {
3691
- return e;
3692
- };
3693
- var t,
3694
- e = {},
3695
- r = Object.prototype,
3696
- n = r.hasOwnProperty,
3697
- o = Object.defineProperty || function (t, e, r) {
3698
- t[e] = r.value;
3699
- },
3700
- i = "function" == typeof Symbol ? Symbol : {},
3701
- a = i.iterator || "@@iterator",
3702
- c = i.asyncIterator || "@@asyncIterator",
3703
- u = i.toStringTag || "@@toStringTag";
3704
- function define(t, e, r) {
3705
- return Object.defineProperty(t, e, {
3706
- value: r,
3707
- enumerable: !0,
3708
- configurable: !0,
3709
- writable: !0
3710
- }), t[e];
3711
- }
3712
- try {
3713
- define({}, "");
3714
- } catch (t) {
3715
- define = function (t, e, r) {
3716
- return t[e] = r;
3717
- };
3718
- }
3719
- function wrap(t, e, r, n) {
3720
- var i = e && e.prototype instanceof Generator ? e : Generator,
3721
- a = Object.create(i.prototype),
3722
- c = new Context(n || []);
3723
- return o(a, "_invoke", {
3724
- value: makeInvokeMethod(t, r, c)
3725
- }), a;
3726
- }
3727
- function tryCatch(t, e, r) {
3728
- try {
3729
- return {
3730
- type: "normal",
3731
- arg: t.call(e, r)
3732
- };
3733
- } catch (t) {
3734
- return {
3735
- type: "throw",
3736
- arg: t
3737
- };
3738
- }
3739
- }
3740
- e.wrap = wrap;
3741
- var h = "suspendedStart",
3742
- l = "suspendedYield",
3743
- f = "executing",
3744
- s = "completed",
3745
- y = {};
3746
- function Generator() {}
3747
- function GeneratorFunction() {}
3748
- function GeneratorFunctionPrototype() {}
3749
- var p = {};
3750
- define(p, a, function () {
3751
- return this;
3752
- });
3753
- var d = Object.getPrototypeOf,
3754
- v = d && d(d(values([])));
3755
- v && v !== r && n.call(v, a) && (p = v);
3756
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
3757
- function defineIteratorMethods(t) {
3758
- ["next", "throw", "return"].forEach(function (e) {
3759
- define(t, e, function (t) {
3760
- return this._invoke(e, t);
3761
- });
3762
- });
3763
- }
3764
- function AsyncIterator(t, e) {
3765
- function invoke(r, o, i, a) {
3766
- var c = tryCatch(t[r], t, o);
3767
- if ("throw" !== c.type) {
3768
- var u = c.arg,
3769
- h = u.value;
3770
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
3771
- invoke("next", t, i, a);
3772
- }, function (t) {
3773
- invoke("throw", t, i, a);
3774
- }) : e.resolve(h).then(function (t) {
3775
- u.value = t, i(u);
3776
- }, function (t) {
3777
- return invoke("throw", t, i, a);
3778
- });
3779
- }
3780
- a(c.arg);
3781
- }
3782
- var r;
3783
- o(this, "_invoke", {
3784
- value: function (t, n) {
3785
- function callInvokeWithMethodAndArg() {
3786
- return new e(function (e, r) {
3787
- invoke(t, n, e, r);
3788
- });
3789
- }
3790
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
3791
- }
3792
- });
3793
- }
3794
- function makeInvokeMethod(e, r, n) {
3795
- var o = h;
3796
- return function (i, a) {
3797
- if (o === f) throw new Error("Generator is already running");
3798
- if (o === s) {
3799
- if ("throw" === i) throw a;
3800
- return {
3801
- value: t,
3802
- done: !0
3803
- };
3804
- }
3805
- for (n.method = i, n.arg = a;;) {
3806
- var c = n.delegate;
3807
- if (c) {
3808
- var u = maybeInvokeDelegate(c, n);
3809
- if (u) {
3810
- if (u === y) continue;
3811
- return u;
3812
- }
3813
- }
3814
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
3815
- if (o === h) throw o = s, n.arg;
3816
- n.dispatchException(n.arg);
3817
- } else "return" === n.method && n.abrupt("return", n.arg);
3818
- o = f;
3819
- var p = tryCatch(e, r, n);
3820
- if ("normal" === p.type) {
3821
- if (o = n.done ? s : l, p.arg === y) continue;
3822
- return {
3823
- value: p.arg,
3824
- done: n.done
3825
- };
3826
- }
3827
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
3828
- }
3829
- };
3830
- }
3831
- function maybeInvokeDelegate(e, r) {
3832
- var n = r.method,
3833
- o = e.iterator[n];
3834
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
3835
- var i = tryCatch(o, e.iterator, r.arg);
3836
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
3837
- var a = i.arg;
3838
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
3839
- }
3840
- function pushTryEntry(t) {
3841
- var e = {
3842
- tryLoc: t[0]
3843
- };
3844
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
3845
- }
3846
- function resetTryEntry(t) {
3847
- var e = t.completion || {};
3848
- e.type = "normal", delete e.arg, t.completion = e;
3849
- }
3850
- function Context(t) {
3851
- this.tryEntries = [{
3852
- tryLoc: "root"
3853
- }], t.forEach(pushTryEntry, this), this.reset(!0);
3854
- }
3855
- function values(e) {
3856
- if (e || "" === e) {
3857
- var r = e[a];
3858
- if (r) return r.call(e);
3859
- if ("function" == typeof e.next) return e;
3860
- if (!isNaN(e.length)) {
3861
- var o = -1,
3862
- i = function next() {
3863
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
3864
- return next.value = t, next.done = !0, next;
3865
- };
3866
- return i.next = i;
3867
- }
3868
- }
3869
- throw new TypeError(typeof e + " is not iterable");
3870
- }
3871
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
3872
- value: GeneratorFunctionPrototype,
3873
- configurable: !0
3874
- }), o(GeneratorFunctionPrototype, "constructor", {
3875
- value: GeneratorFunction,
3876
- configurable: !0
3877
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
3878
- var e = "function" == typeof t && t.constructor;
3879
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
3880
- }, e.mark = function (t) {
3881
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
3882
- }, e.awrap = function (t) {
3883
- return {
3884
- __await: t
3885
- };
3886
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
3887
- return this;
3888
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
3889
- void 0 === i && (i = Promise);
3890
- var a = new AsyncIterator(wrap(t, r, n, o), i);
3891
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
3892
- return t.done ? t.value : a.next();
3893
- });
3894
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
3895
- return this;
3896
- }), define(g, "toString", function () {
3897
- return "[object Generator]";
3898
- }), e.keys = function (t) {
3899
- var e = Object(t),
3900
- r = [];
3901
- for (var n in e) r.push(n);
3902
- return r.reverse(), function next() {
3903
- for (; r.length;) {
3904
- var t = r.pop();
3905
- if (t in e) return next.value = t, next.done = !1, next;
3906
- }
3907
- return next.done = !0, next;
3908
- };
3909
- }, e.values = values, Context.prototype = {
3910
- constructor: Context,
3911
- reset: function (e) {
3912
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
3913
- },
3914
- stop: function () {
3915
- this.done = !0;
3916
- var t = this.tryEntries[0].completion;
3917
- if ("throw" === t.type) throw t.arg;
3918
- return this.rval;
3919
- },
3920
- dispatchException: function (e) {
3921
- if (this.done) throw e;
3922
- var r = this;
3923
- function handle(n, o) {
3924
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
3925
- }
3926
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
3927
- var i = this.tryEntries[o],
3928
- a = i.completion;
3929
- if ("root" === i.tryLoc) return handle("end");
3930
- if (i.tryLoc <= this.prev) {
3931
- var c = n.call(i, "catchLoc"),
3932
- u = n.call(i, "finallyLoc");
3933
- if (c && u) {
3934
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
3935
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
3936
- } else if (c) {
3937
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
3938
- } else {
3939
- if (!u) throw new Error("try statement without catch or finally");
3940
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
3941
- }
3942
- }
3943
- }
3944
- },
3945
- abrupt: function (t, e) {
3946
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
3947
- var o = this.tryEntries[r];
3948
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
3949
- var i = o;
3950
- break;
3951
- }
3952
- }
3953
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
3954
- var a = i ? i.completion : {};
3955
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
3956
- },
3957
- complete: function (t, e) {
3958
- if ("throw" === t.type) throw t.arg;
3959
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
3960
- },
3961
- finish: function (t) {
3962
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
3963
- var r = this.tryEntries[e];
3964
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
3965
- }
3966
- },
3967
- catch: function (t) {
3968
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
3969
- var r = this.tryEntries[e];
3970
- if (r.tryLoc === t) {
3971
- var n = r.completion;
3972
- if ("throw" === n.type) {
3973
- var o = n.arg;
3974
- resetTryEntry(r);
3975
- }
3976
- return o;
3977
- }
3978
- }
3979
- throw new Error("illegal catch attempt");
3980
- },
3981
- delegateYield: function (e, r, n) {
3982
- return this.delegate = {
3983
- iterator: values(e),
3984
- resultName: r,
3985
- nextLoc: n
3986
- }, "next" === this.method && (this.arg = t), y;
3987
- }
3988
- }, e;
3989
- }
3990
-
3991
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
3992
- try {
3993
- var info = gen[key](arg);
3994
- var value = info.value;
3995
- } catch (error) {
3996
- reject(error);
3997
- return;
3998
- }
3999
- if (info.done) {
4000
- resolve(value);
4001
- } else {
4002
- Promise.resolve(value).then(_next, _throw);
4003
- }
4004
- }
4005
- function _asyncToGenerator(fn) {
4006
- return function () {
4007
- var self = this,
4008
- args = arguments;
4009
- return new Promise(function (resolve, reject) {
4010
- var gen = fn.apply(self, args);
4011
- function _next(value) {
4012
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
4013
- }
4014
- function _throw(err) {
4015
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
4016
- }
4017
- _next(undefined);
4018
- });
4019
- };
4020
- }
4021
-
4022
- // TODO: move this to internal, only reason this is here is that react, ui and server all depend on it
4023
- var ValApi = /*#__PURE__*/function () {
4024
- function ValApi(host) {
4025
- _classCallCheck(this, ValApi);
4026
- this.host = host;
4027
- }
4028
- _createClass(ValApi, [{
4029
- key: "getDisableUrl",
4030
- value: function getDisableUrl(redirectTo) {
4031
- return "".concat(this.host, "/disable?redirect_to=").concat(encodeURIComponent(redirectTo));
4032
- }
4033
- }, {
4034
- key: "getLoginUrl",
4035
- value: function getLoginUrl(redirectTo) {
4036
- return "".concat(this.host, "/authorize?redirect_to=").concat(encodeURIComponent(redirectTo));
4037
- }
4038
- }, {
4039
- key: "getEnableUrl",
4040
- value: function getEnableUrl(redirectTo) {
4041
- return "".concat(this.host, "/enable?redirect_to=").concat(encodeURIComponent(redirectTo));
4042
- }
4043
- }, {
4044
- key: "getPatches",
4045
- value: function () {
4046
- var _getPatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(filters) {
4047
- var params, _iterator, _step, patchId, _iterator2, _step2, author, _iterator3, _step3, moduleFilePath, searchParams;
4048
- return _regeneratorRuntime().wrap(function _callee$(_context) {
4049
- while (1) switch (_context.prev = _context.next) {
4050
- case 0:
4051
- params = [];
4052
- if (filters) {
4053
- if (filters.patchIds) {
4054
- _iterator = result._createForOfIteratorHelper(filters.patchIds);
4055
- try {
4056
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
4057
- patchId = _step.value;
4058
- params.push(["patch_id", patchId]);
4059
- }
4060
- } catch (err) {
4061
- _iterator.e(err);
4062
- } finally {
4063
- _iterator.f();
4064
- }
4065
- }
4066
- if (filters.authors) {
4067
- _iterator2 = result._createForOfIteratorHelper(filters.authors);
4068
- try {
4069
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4070
- author = _step2.value;
4071
- params.push(["author", author]);
4072
- }
4073
- } catch (err) {
4074
- _iterator2.e(err);
4075
- } finally {
4076
- _iterator2.f();
4077
- }
4078
- }
4079
- if (filters.moduleFilePaths) {
4080
- _iterator3 = result._createForOfIteratorHelper(filters.moduleFilePaths);
4081
- try {
4082
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
4083
- moduleFilePath = _step3.value;
4084
- params.push(["module_file_path", moduleFilePath]);
4085
- }
4086
- } catch (err) {
4087
- _iterator3.e(err);
4088
- } finally {
4089
- _iterator3.f();
4090
- }
4091
- }
4092
- if (filters.omitPatches) {
4093
- params.push(["omit_patches", "true"]);
4094
- }
4095
- }
4096
- searchParams = new URLSearchParams(params);
4097
- return _context.abrupt("return", fetch("".concat(this.host, "/patches/~").concat(searchParams.size > 0 ? "?".concat(searchParams.toString()) : ""), {
4098
- headers: {
4099
- "Content-Type": "application/json"
4100
- }
4101
- }).then(function (res) {
4102
- return parse(res);
4103
- })["catch"](createError));
4104
- case 4:
4105
- case "end":
4106
- return _context.stop();
4107
- }
4108
- }, _callee, this);
4109
- }));
4110
- function getPatches(_x) {
4111
- return _getPatches.apply(this, arguments);
4112
- }
4113
- return getPatches;
4114
- }()
4115
- }, {
4116
- key: "deletePatches",
4117
- value: function () {
4118
- var _deletePatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ids, headers) {
4119
- var params;
4120
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4121
- while (1) switch (_context2.prev = _context2.next) {
4122
- case 0:
4123
- params = new URLSearchParams();
4124
- ids.forEach(function (id) {
4125
- return params.append("id", id);
4126
- });
4127
- return _context2.abrupt("return", fetch("".concat(this.host, "/patches/~?").concat(params), {
4128
- method: "DELETE",
4129
- headers: headers || {
4130
- "Content-Type": "application/json"
4131
- }
4132
- }).then(function (res) {
4133
- return parse(res);
4134
- })["catch"](createError));
4135
- case 3:
4136
- case "end":
4137
- return _context2.stop();
4138
- }
4139
- }, _callee2, this);
4140
- }));
4141
- function deletePatches(_x2, _x3) {
4142
- return _deletePatches.apply(this, arguments);
4143
- }
4144
- return deletePatches;
4145
- }()
4146
- }, {
4147
- key: "getEditUrl",
4148
- value: function getEditUrl() {
4149
- // TODO: make route configurable
4150
- return "/val/~";
4151
- }
4152
- }, {
4153
- key: "getSession",
4154
- value: function getSession() {
4155
- return fetch("".concat(this.host, "/session")).then(function (res) {
4156
- return parse(res)["catch"](createError);
4157
- });
4158
- }
4159
- }, {
4160
- key: "getSchema",
4161
- value: function getSchema(_ref) {
4162
- var headers = _ref.headers;
4163
- return fetch("".concat(this.host, "/schema"), {
4164
- method: "GET",
4165
- headers: headers
4166
- }).then(function (res) {
4167
- return parse(res);
4168
- })["catch"](createError);
4169
- }
4170
- }, {
4171
- key: "putTree",
4172
- value: function putTree(_ref2) {
4173
- var _ref2$treePath = _ref2.treePath,
4174
- treePath = _ref2$treePath === void 0 ? "/" : _ref2$treePath,
4175
- patchIds = _ref2.patchIds,
4176
- addPatch = _ref2.addPatch,
4177
- validateAll = _ref2.validateAll,
4178
- validateSource = _ref2.validateSource,
4179
- validateBinaryFiles = _ref2.validateBinaryFiles,
4180
- headers = _ref2.headers;
4181
- var params = new URLSearchParams();
4182
- var textEncoder = new TextEncoder();
4183
- var patchesSha = getSHA256Hash(textEncoder.encode((patchIds || []).concat(JSON.stringify(addPatch || {})).join(";")));
4184
- params.set("patches_sha", patchesSha);
4185
- params.set("validate_all", (validateAll || false).toString());
4186
- params.set("validate_source", (validateSource || false).toString());
4187
- params.set("validate_binary_files", (validateBinaryFiles || false).toString());
4188
- return fetch("".concat(this.host, "/tree/~").concat(treePath, "?").concat(params.toString()), {
4189
- method: "PUT",
4190
- body: JSON.stringify({
4191
- patchIds: patchIds,
4192
- addPatch: addPatch
4193
- }),
4194
- headers: headers
4195
- }).then(function (res) {
4196
- return parse(res);
4197
- })["catch"](createError);
4198
- }
4199
- }, {
4200
- key: "postSave",
4201
- value: function postSave(_ref3) {
4202
- var patchIds = _ref3.patchIds;
4203
- return fetch("".concat(this.host, "/save"), {
4204
- method: "POST",
4205
- body: JSON.stringify({
4206
- patchIds: patchIds
4207
- }),
4208
- headers: {
4209
- "Content-Type": "application/json"
4210
- }
4211
- }).then( /*#__PURE__*/function () {
4212
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(res) {
4213
- var jsonRes;
4214
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4215
- while (1) switch (_context3.prev = _context3.next) {
4216
- case 0:
4217
- if (!res.ok) {
4218
- _context3.next = 4;
4219
- break;
4220
- }
4221
- return _context3.abrupt("return", parse(res));
4222
- case 4:
4223
- if (!(res.status === 400 && res.headers.get("content-type") === "application/json")) {
4224
- _context3.next = 9;
4225
- break;
4226
- }
4227
- _context3.next = 7;
4228
- return res.json();
4229
- case 7:
4230
- jsonRes = _context3.sent;
4231
- alert(JSON.stringify(jsonRes));
4232
- case 9:
4233
- return _context3.abrupt("return", parse(res));
4234
- case 10:
4235
- case "end":
4236
- return _context3.stop();
4237
- }
4238
- }, _callee3);
4239
- }));
4240
- return function (_x4) {
4241
- return _ref4.apply(this, arguments);
4242
- };
4243
- }())["catch"](createError);
4244
- }
4245
- }, {
4246
- key: "postValidate",
4247
- value: function postValidate(_ref5) {
4248
- var patches = _ref5.patches,
4249
- headers = _ref5.headers;
4250
- return fetch("".concat(this.host, "/validate"), {
4251
- method: "POST",
4252
- body: JSON.stringify({
4253
- patches: patches
4254
- }),
4255
- headers: headers || {
4256
- "Content-Type": "application/json"
4257
- }
4258
- }).then( /*#__PURE__*/function () {
4259
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(res) {
4260
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
4261
- while (1) switch (_context4.prev = _context4.next) {
4262
- case 0:
4263
- return _context4.abrupt("return", parse(res));
4264
- case 1:
4265
- case "end":
4266
- return _context4.stop();
4267
- }
4268
- }, _callee4);
4269
- }));
4270
- return function (_x5) {
4271
- return _ref6.apply(this, arguments);
4272
- };
4273
- }())["catch"](createError);
4274
- }
4275
- }]);
4276
- return ValApi;
4277
- }();
4278
- function createError(err) {
4279
- return result.err({
4280
- statusCode: 500,
4281
- message: err instanceof Error ? err.message : _typeof(err) === "object" && err && "message" in err && typeof err.message === "string" ? err.message : "Unknown error",
4282
- details: _typeof(err) === "object" && err && "details" in err ? err.details : undefined
4283
- });
4284
- }
4285
-
4286
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4287
- function formatError(status, json, statusText) {
4288
- return result.err({
4289
- statusCode: status,
4290
- message: json.message || statusText,
4291
- details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref7) {
4292
- var _ref8 = _slicedToArray(_ref7, 1),
4293
- key = _ref8[0];
4294
- return key !== "message";
4295
- }))
4296
- });
4297
- }
4298
-
4299
- // TODO: validate
4300
- function parse(_x6) {
4301
- return _parse.apply(this, arguments);
4302
- }
4303
- function _parse() {
4304
- _parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(res) {
4305
- var json;
4306
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
4307
- while (1) switch (_context5.prev = _context5.next) {
4308
- case 0:
4309
- _context5.prev = 0;
4310
- if (!res.ok) {
4311
- _context5.next = 9;
4312
- break;
4313
- }
4314
- _context5.t0 = result.result;
4315
- _context5.next = 5;
4316
- return res.json();
4317
- case 5:
4318
- _context5.t1 = _context5.sent;
4319
- return _context5.abrupt("return", _context5.t0.ok.call(_context5.t0, _context5.t1));
4320
- case 9:
4321
- _context5.prev = 9;
4322
- _context5.next = 12;
4323
- return res.json();
4324
- case 12:
4325
- json = _context5.sent;
4326
- return _context5.abrupt("return", formatError(res.status, json, res.statusText));
4327
- case 16:
4328
- _context5.prev = 16;
4329
- _context5.t2 = _context5["catch"](9);
4330
- return _context5.abrupt("return", result.err({
4331
- statusCode: res.status,
4332
- message: res.statusText
4333
- }));
4334
- case 19:
4335
- _context5.next = 24;
4336
- break;
4337
- case 21:
4338
- _context5.prev = 21;
4339
- _context5.t3 = _context5["catch"](0);
4340
- return _context5.abrupt("return", result.err({
4341
- message: _context5.t3 instanceof Error ? _context5.t3.message : "Unknown error"
4342
- }));
4343
- case 24:
4344
- case "end":
4345
- return _context5.stop();
4346
- }
4347
- }, _callee5, null, [[0, 21], [9, 16]]);
4348
- }));
4349
- return _parse.apply(this, arguments);
4350
- }
4351
-
4352
- // eslint-disable-next-line @typescript-eslint/ban-types
4353
-
4354
5117
  var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
4355
5118
  var Internal = {
4356
5119
  VERSION: {
@@ -4374,6 +5137,11 @@ var Internal = {
4374
5137
  createValPathOfItem: createValPathOfItem,
4375
5138
  getSHA256Hash: getSHA256Hash,
4376
5139
  initSchema: initSchema,
5140
+ getMimeType: getMimeType,
5141
+ mimeTypeToFileExt: mimeTypeToFileExt,
5142
+ filenameToMimeType: filenameToMimeType,
5143
+ EXT_TO_MIME_TYPES: EXT_TO_MIME_TYPES,
5144
+ MIME_TYPES_TO_EXT: MIME_TYPES_TO_EXT,
4377
5145
  ModuleFilePathSep: ModuleFilePathSep,
4378
5146
  notFileOp: function notFileOp(op) {
4379
5147
  return op.op !== "file";
@@ -4422,6 +5190,7 @@ exports.FileSchema = FileSchema;
4422
5190
  exports.GenericSelector = GenericSelector;
4423
5191
  exports.ImageSchema = ImageSchema;
4424
5192
  exports.Internal = Internal;
5193
+ exports.KeyOfSchema = KeyOfSchema;
4425
5194
  exports.LiteralSchema = LiteralSchema;
4426
5195
  exports.NilSym = NilSym;
4427
5196
  exports.NumberSchema = NumberSchema;
@@ -4437,7 +5206,6 @@ exports.StringTemplate = StringTemplate;
4437
5206
  exports.Sym = Sym;
4438
5207
  exports.UnionSchema = UnionSchema;
4439
5208
  exports.VAL_EXTENSION = VAL_EXTENSION;
4440
- exports.ValApi = ValApi;
4441
5209
  exports._classCallCheck = _classCallCheck;
4442
5210
  exports._createClass = _createClass;
4443
5211
  exports._slicedToArray = _slicedToArray;
@@ -4449,5 +5217,5 @@ exports.evaluate = evaluate;
4449
5217
  exports.index = index;
4450
5218
  exports.initVal = initVal;
4451
5219
  exports.modules = modules;
4452
- exports.parse = parse$1;
5220
+ exports.parse = parse;
4453
5221
  exports.splitModuleFilePathAndModulePath = splitModuleFilePathAndModulePath;