@valbuild/core 0.63.5 → 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.
- package/dist/declarations/src/index.d.ts +12 -89
- package/dist/declarations/src/initSchema.d.ts +4 -1
- package/dist/declarations/src/mimeType/all.d.ts +4 -0
- package/dist/declarations/src/mimeType/convertMimeType.d.ts +3 -0
- package/dist/declarations/src/mimeType/index.d.ts +2 -0
- package/dist/declarations/src/schema/array.d.ts +5 -5
- package/dist/declarations/src/schema/boolean.d.ts +2 -2
- package/dist/declarations/src/schema/date.d.ts +38 -0
- package/dist/declarations/src/schema/file.d.ts +5 -3
- package/dist/declarations/src/schema/image.d.ts +4 -3
- package/dist/declarations/src/schema/index.d.ts +46 -4
- package/dist/declarations/src/schema/keyOf.d.ts +5 -5
- package/dist/declarations/src/schema/literal.d.ts +3 -3
- package/dist/declarations/src/schema/number.d.ts +3 -3
- package/dist/declarations/src/schema/object.d.ts +5 -5
- package/dist/declarations/src/schema/record.d.ts +5 -5
- package/dist/declarations/src/schema/richtext.d.ts +5 -4
- package/dist/declarations/src/schema/string.d.ts +2 -2
- package/dist/declarations/src/schema/union.d.ts +5 -5
- package/dist/declarations/src/schema/validation/ValidationError.d.ts +2 -1
- package/dist/declarations/src/selector/SelectorProxy.d.ts +1 -0
- package/dist/declarations/src/source/richtext.d.ts +7 -0
- package/dist/declarations/src/val/index.d.ts +1 -1
- package/dist/{index-7c62e0da.cjs.prod.js → index-41223963.cjs.prod.js} +1697 -818
- package/dist/{index-3c8b4776.esm.js → index-4240c6a6.esm.js} +1696 -818
- package/dist/{index-3388fb33.cjs.dev.js → index-d384ec25.cjs.dev.js} +1697 -818
- package/dist/valbuild-core.cjs.dev.js +3 -2
- package/dist/valbuild-core.cjs.prod.js +3 -2
- package/dist/valbuild-core.esm.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.dev.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.prod.js +1 -1
- package/expr/dist/valbuild-core-expr.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
- package/dist/declarations/src/ValApi.d.ts +0 -54
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as _arrayLikeToArray, a as _unsupportedIterableToArray, i as isErr, e as err, o as ok, b as isOk, c as _createForOfIteratorHelper
|
1
|
+
import { _ as _arrayLikeToArray, a as _unsupportedIterableToArray, i as isErr, e as err, o as ok, b as isOk, c as _createForOfIteratorHelper } from './result-a8316efa.esm.js';
|
2
2
|
import * as marked from 'marked';
|
3
3
|
import { VAL_EXTENSION as VAL_EXTENSION$1, FILE_REF_SUBTYPE_TAG as FILE_REF_SUBTYPE_TAG$1 } from '@valbuild/core';
|
4
4
|
|
@@ -448,6 +448,50 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
448
448
|
value: src
|
449
449
|
}]);
|
450
450
|
}
|
451
|
+
var _ref4 = this.options || {},
|
452
|
+
accept = _ref4.accept;
|
453
|
+
var _ref5 = src.metadata || {},
|
454
|
+
mimeType = _ref5.mimeType;
|
455
|
+
if (accept && mimeType && !mimeType.includes("/")) {
|
456
|
+
return _defineProperty({}, path, [{
|
457
|
+
message: "Invalid mime type format. Got: ".concat(mimeType),
|
458
|
+
value: src
|
459
|
+
}]);
|
460
|
+
}
|
461
|
+
if (accept && mimeType && mimeType.includes("/")) {
|
462
|
+
var acceptedTypes = accept.split(",").map(function (type) {
|
463
|
+
return type.trim();
|
464
|
+
});
|
465
|
+
var isValidMimeType = acceptedTypes.some(function (acceptedType) {
|
466
|
+
if (acceptedType === "*/*") {
|
467
|
+
return true;
|
468
|
+
}
|
469
|
+
if (acceptedType.endsWith("/*")) {
|
470
|
+
var baseType = acceptedType.slice(0, -2);
|
471
|
+
return mimeType.startsWith(baseType);
|
472
|
+
}
|
473
|
+
return acceptedType === mimeType;
|
474
|
+
});
|
475
|
+
if (!isValidMimeType) {
|
476
|
+
return _defineProperty({}, path, [{
|
477
|
+
message: "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'"),
|
478
|
+
value: src
|
479
|
+
}]);
|
480
|
+
}
|
481
|
+
}
|
482
|
+
var fileMimeType = Internal.filenameToMimeType(src[FILE_REF_PROP]);
|
483
|
+
if (!fileMimeType) {
|
484
|
+
return _defineProperty({}, path, [{
|
485
|
+
message: "Could not determine mime type from file extension. Got: ".concat(src[FILE_REF_PROP]),
|
486
|
+
value: src
|
487
|
+
}]);
|
488
|
+
}
|
489
|
+
if (fileMimeType !== mimeType) {
|
490
|
+
return _defineProperty({}, path, [{
|
491
|
+
message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
|
492
|
+
value: src
|
493
|
+
}]);
|
494
|
+
}
|
451
495
|
if (src.metadata) {
|
452
496
|
return _defineProperty({}, path, [{
|
453
497
|
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).",
|
@@ -464,11 +508,53 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
464
508
|
}
|
465
509
|
}, {
|
466
510
|
key: "assert",
|
467
|
-
value: function assert(src) {
|
468
|
-
if (this.opt &&
|
469
|
-
return
|
511
|
+
value: function assert(path, src) {
|
512
|
+
if (this.opt && src === null) {
|
513
|
+
return {
|
514
|
+
success: true,
|
515
|
+
data: src
|
516
|
+
};
|
517
|
+
}
|
518
|
+
if (src === null) {
|
519
|
+
return {
|
520
|
+
success: false,
|
521
|
+
errors: _defineProperty({}, path, [{
|
522
|
+
message: "Expected 'object', got 'null'",
|
523
|
+
typeError: true
|
524
|
+
}])
|
525
|
+
};
|
526
|
+
}
|
527
|
+
if (_typeof(src) !== "object") {
|
528
|
+
return {
|
529
|
+
success: false,
|
530
|
+
errors: _defineProperty({}, path, [{
|
531
|
+
message: "Expected object, got '".concat(_typeof(src), "'"),
|
532
|
+
typeError: true
|
533
|
+
}])
|
534
|
+
};
|
535
|
+
}
|
536
|
+
if (!(FILE_REF_PROP in src)) {
|
537
|
+
return {
|
538
|
+
success: false,
|
539
|
+
errors: _defineProperty({}, path, [{
|
540
|
+
message: "Value of this schema must use: 'c.file' (error type: missing_ref_prop)",
|
541
|
+
typeError: true
|
542
|
+
}])
|
543
|
+
};
|
544
|
+
}
|
545
|
+
if (!(VAL_EXTENSION in src && src[VAL_EXTENSION] === "file")) {
|
546
|
+
return {
|
547
|
+
success: false,
|
548
|
+
errors: _defineProperty({}, path, [{
|
549
|
+
message: "Value of this schema must use: 'c.file' (error type: missing_file_extension)",
|
550
|
+
typeError: true
|
551
|
+
}])
|
552
|
+
};
|
470
553
|
}
|
471
|
-
return
|
554
|
+
return {
|
555
|
+
success: true,
|
556
|
+
data: src
|
557
|
+
};
|
472
558
|
}
|
473
559
|
}, {
|
474
560
|
key: "nullable",
|
@@ -613,7 +699,7 @@ function newSelectorProxy$1(source, path, moduleSchema) {
|
|
613
699
|
return newSelectorProxy$1(a, createValPathOfItem(path, i), moduleSchema === null || moduleSchema === void 0 ? void 0 : moduleSchema.item);
|
614
700
|
}).filter(function (a) {
|
615
701
|
if (f && f instanceof Schema) {
|
616
|
-
return f.assert(unValify$1(a));
|
702
|
+
return f.assert(path || "", unValify$1(a)).success;
|
617
703
|
} else {
|
618
704
|
return unValify$1(f(a));
|
619
705
|
}
|
@@ -680,6 +766,20 @@ function createValPathOfItem(arrayPath, prop) {
|
|
680
766
|
return "".concat(arrayPath).concat(Internal.ModuleFilePathSep).concat(JSON.stringify(prop));
|
681
767
|
}
|
682
768
|
|
769
|
+
// TODO: replace createValPathOfItem everywhere with this newer implementation (that does not return undefined but throws)
|
770
|
+
function unsafeCreateSourcePath(path, itemKey) {
|
771
|
+
if (_typeof(itemKey) === "symbol") {
|
772
|
+
throw Error("Cannot create val path of array item with symbol prop: ".concat(itemKey.toString()));
|
773
|
+
}
|
774
|
+
if (!path) {
|
775
|
+
throw Error("Cannot create val path of array item of empty or missing path: ".concat(path, ". Item: ").concat(itemKey));
|
776
|
+
}
|
777
|
+
if (path.includes(Internal.ModuleFilePathSep)) {
|
778
|
+
return "".concat(path, ".").concat(JSON.stringify(itemKey));
|
779
|
+
}
|
780
|
+
return "".concat(path).concat(Internal.ModuleFilePathSep).concat(JSON.stringify(itemKey));
|
781
|
+
}
|
782
|
+
|
683
783
|
// TODO: could we do .val on the objects instead?
|
684
784
|
function unValify$1(valueOrSelector) {
|
685
785
|
if (_typeof(valueOrSelector) === "object" && (GetSource in valueOrSelector || Path$1 in valueOrSelector)) {
|
@@ -710,6 +810,11 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
710
810
|
if (this.opt && (src === null || src === undefined)) {
|
711
811
|
return false;
|
712
812
|
}
|
813
|
+
if (src === null) {
|
814
|
+
return _defineProperty({}, path, [{
|
815
|
+
message: "Expected 'object', got 'null'"
|
816
|
+
}]);
|
817
|
+
}
|
713
818
|
if (_typeof(src) !== "object") {
|
714
819
|
return _defineProperty({}, path, [{
|
715
820
|
message: "Expected 'object', got '".concat(_typeof(src), "'")
|
@@ -719,10 +824,10 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
719
824
|
message: "Expected 'object', got 'array'"
|
720
825
|
}]);
|
721
826
|
}
|
722
|
-
Object.entries(this.items).forEach(function (
|
723
|
-
var
|
724
|
-
key =
|
725
|
-
schema =
|
827
|
+
Object.entries(this.items).forEach(function (_ref4) {
|
828
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
829
|
+
key = _ref5[0],
|
830
|
+
schema = _ref5[1];
|
726
831
|
var subPath = createValPathOfItem(path, key);
|
727
832
|
if (!subPath) {
|
728
833
|
error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(key),
|
@@ -741,22 +846,66 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
741
846
|
}
|
742
847
|
}, {
|
743
848
|
key: "assert",
|
744
|
-
value: function assert(src) {
|
745
|
-
if (this.opt &&
|
746
|
-
return
|
849
|
+
value: function assert(path, src) {
|
850
|
+
if (this.opt && src === null) {
|
851
|
+
return {
|
852
|
+
success: true,
|
853
|
+
data: src
|
854
|
+
};
|
747
855
|
}
|
748
|
-
if (
|
749
|
-
return
|
856
|
+
if (src === null) {
|
857
|
+
return {
|
858
|
+
success: false,
|
859
|
+
errors: _defineProperty({}, path, [{
|
860
|
+
message: "Expected 'object', got 'null'",
|
861
|
+
typeError: true
|
862
|
+
}])
|
863
|
+
};
|
750
864
|
}
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
865
|
+
if (_typeof(src) !== "object") {
|
866
|
+
return {
|
867
|
+
success: false,
|
868
|
+
errors: _defineProperty({}, path, [{
|
869
|
+
message: "Expected 'object', got '".concat(_typeof(src), "'"),
|
870
|
+
typeError: true
|
871
|
+
}])
|
872
|
+
};
|
873
|
+
} else if (Array.isArray(src)) {
|
874
|
+
return {
|
875
|
+
success: false,
|
876
|
+
errors: _defineProperty({}, path, [{
|
877
|
+
message: "Expected 'object', got 'array'",
|
878
|
+
typeError: true
|
879
|
+
}])
|
880
|
+
};
|
881
|
+
}
|
882
|
+
var errorsAtPath = [];
|
883
|
+
for (var _i = 0, _Object$keys = Object.keys(this.items); _i < _Object$keys.length; _i++) {
|
884
|
+
var _key = _Object$keys[_i];
|
885
|
+
var subPath = createValPathOfItem(path, _key);
|
886
|
+
if (!subPath) {
|
887
|
+
errorsAtPath.push({
|
888
|
+
message: "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(_key),
|
889
|
+
// Should! never happen
|
890
|
+
internalError: true
|
891
|
+
});
|
892
|
+
} else if (!(_key in src)) {
|
893
|
+
errorsAtPath.push({
|
894
|
+
message: "Expected key '".concat(_key, "' not found in object"),
|
895
|
+
typeError: true
|
896
|
+
});
|
757
897
|
}
|
758
898
|
}
|
759
|
-
|
899
|
+
if (errorsAtPath.length > 0) {
|
900
|
+
return {
|
901
|
+
success: false,
|
902
|
+
errors: _defineProperty({}, path, errorsAtPath)
|
903
|
+
};
|
904
|
+
}
|
905
|
+
return {
|
906
|
+
success: true,
|
907
|
+
data: src
|
908
|
+
};
|
760
909
|
}
|
761
910
|
}, {
|
762
911
|
key: "nullable",
|
@@ -768,10 +917,10 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
768
917
|
value: function serialize() {
|
769
918
|
return {
|
770
919
|
type: "object",
|
771
|
-
items: Object.fromEntries(Object.entries(this.items).map(function (
|
772
|
-
var
|
773
|
-
key =
|
774
|
-
schema =
|
920
|
+
items: Object.fromEntries(Object.entries(this.items).map(function (_ref6) {
|
921
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
922
|
+
key = _ref7[0],
|
923
|
+
schema = _ref7[1];
|
775
924
|
return [key, schema.serialize()];
|
776
925
|
})),
|
777
926
|
opt: this.opt
|
@@ -1034,7 +1183,7 @@ function parseTokens$1(inputTokens) {
|
|
1034
1183
|
}
|
1035
1184
|
return res;
|
1036
1185
|
}
|
1037
|
-
function parse
|
1186
|
+
function parse(input) {
|
1038
1187
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1039
1188
|
var _tokenize = tokenize(input),
|
1040
1189
|
_tokenize2 = _slicedToArray(_tokenize, 2),
|
@@ -1160,7 +1309,7 @@ function newSelectorProxy(source, path, moduleSchema) {
|
|
1160
1309
|
return newSelectorProxy(a, createValPathOfItem(path, i), moduleSchema === null || moduleSchema === void 0 ? void 0 : moduleSchema.item);
|
1161
1310
|
}).filter(function (a) {
|
1162
1311
|
if (f && f instanceof Schema) {
|
1163
|
-
return f.assert(unValify(a));
|
1312
|
+
return f.assert(path || "", unValify(a)).success;
|
1164
1313
|
} else {
|
1165
1314
|
return unValify(f(a));
|
1166
1315
|
}
|
@@ -1403,7 +1552,7 @@ function evaluate(expr, source, stack) {
|
|
1403
1552
|
|
1404
1553
|
var index = /*#__PURE__*/Object.freeze({
|
1405
1554
|
__proto__: null,
|
1406
|
-
parse: parse
|
1555
|
+
parse: parse,
|
1407
1556
|
Call: Call,
|
1408
1557
|
Expr: Expr,
|
1409
1558
|
NilSym: NilSym,
|
@@ -1427,57 +1576,69 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
1427
1576
|
_createClass(ArraySchema, [{
|
1428
1577
|
key: "validate",
|
1429
1578
|
value: function validate(path, src) {
|
1430
|
-
var
|
1431
|
-
|
1432
|
-
|
1433
|
-
return false;
|
1579
|
+
var assertRes = this.assert(path, src);
|
1580
|
+
if (!assertRes.success) {
|
1581
|
+
return assertRes.errors;
|
1434
1582
|
}
|
1435
|
-
if (
|
1436
|
-
return
|
1437
|
-
message: "Expected 'array', got '".concat(_typeof(src), "'")
|
1438
|
-
}]);
|
1583
|
+
if (assertRes.data === null) {
|
1584
|
+
return false;
|
1439
1585
|
}
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
} else if (subError) {
|
1451
|
-
error = subError;
|
1452
|
-
}
|
1586
|
+
var error = {};
|
1587
|
+
for (var _i = 0, _Object$entries = Object.entries(assertRes.data); _i < _Object$entries.length; _i++) {
|
1588
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
1589
|
+
idx = _Object$entries$_i[0],
|
1590
|
+
i = _Object$entries$_i[1];
|
1591
|
+
var subPath = unsafeCreateSourcePath(path, Number(idx));
|
1592
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1593
|
+
var subError = this.item.validate(subPath, i);
|
1594
|
+
if (subError) {
|
1595
|
+
error = _objectSpread2(_objectSpread2({}, subError), error);
|
1453
1596
|
}
|
1454
|
-
}
|
1597
|
+
}
|
1598
|
+
if (Object.keys(error).length === 0) {
|
1599
|
+
return false;
|
1600
|
+
}
|
1455
1601
|
return error;
|
1456
1602
|
}
|
1457
1603
|
}, {
|
1458
1604
|
key: "assert",
|
1459
|
-
value: function assert(src) {
|
1460
|
-
if (
|
1461
|
-
return
|
1605
|
+
value: function assert(path, src) {
|
1606
|
+
if (src === null && this.opt) {
|
1607
|
+
return {
|
1608
|
+
success: true,
|
1609
|
+
data: src
|
1610
|
+
};
|
1462
1611
|
}
|
1463
|
-
if (
|
1464
|
-
return
|
1612
|
+
if (src === null) {
|
1613
|
+
return {
|
1614
|
+
success: false,
|
1615
|
+
errors: _defineProperty({}, path, [{
|
1616
|
+
message: "Expected 'array', got 'null'",
|
1617
|
+
typeError: true
|
1618
|
+
}])
|
1619
|
+
};
|
1465
1620
|
}
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1621
|
+
if (_typeof(src) !== "object") {
|
1622
|
+
return {
|
1623
|
+
success: false,
|
1624
|
+
errors: _defineProperty({}, path, [{
|
1625
|
+
message: "Expected 'object', got '".concat(_typeof(src), "'"),
|
1626
|
+
typeError: true
|
1627
|
+
}])
|
1628
|
+
};
|
1629
|
+
} else if (!Array.isArray(src)) {
|
1630
|
+
return {
|
1631
|
+
success: false,
|
1632
|
+
errors: _defineProperty({}, path, [{
|
1633
|
+
message: "Expected object of type 'array'",
|
1634
|
+
typeError: true
|
1635
|
+
}])
|
1636
|
+
};
|
1479
1637
|
}
|
1480
|
-
return
|
1638
|
+
return {
|
1639
|
+
success: true,
|
1640
|
+
data: src
|
1641
|
+
};
|
1481
1642
|
}
|
1482
1643
|
}, {
|
1483
1644
|
key: "nullable",
|
@@ -1533,11 +1694,35 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
1533
1694
|
}
|
1534
1695
|
}, {
|
1535
1696
|
key: "assert",
|
1536
|
-
value: function assert(src) {
|
1537
|
-
if (this.opt &&
|
1538
|
-
return
|
1697
|
+
value: function assert(path, src) {
|
1698
|
+
if (this.opt && src === null) {
|
1699
|
+
return {
|
1700
|
+
success: true,
|
1701
|
+
data: src
|
1702
|
+
};
|
1703
|
+
}
|
1704
|
+
if (src === null) {
|
1705
|
+
return {
|
1706
|
+
success: false,
|
1707
|
+
errors: _defineProperty({}, path, [{
|
1708
|
+
message: "Expected 'string', got 'null'",
|
1709
|
+
typeError: true
|
1710
|
+
}])
|
1711
|
+
};
|
1712
|
+
}
|
1713
|
+
if (typeof src === "string" && src === this.value) {
|
1714
|
+
return {
|
1715
|
+
success: true,
|
1716
|
+
data: src
|
1717
|
+
};
|
1539
1718
|
}
|
1540
|
-
return
|
1719
|
+
return {
|
1720
|
+
success: false,
|
1721
|
+
errors: _defineProperty({}, path, [{
|
1722
|
+
message: "Expected literal '".concat(this.value, "', got '").concat(src, "'"),
|
1723
|
+
typeError: true
|
1724
|
+
}])
|
1725
|
+
};
|
1541
1726
|
}
|
1542
1727
|
}, {
|
1543
1728
|
key: "nullable",
|
@@ -1577,20 +1762,20 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1577
1762
|
value: function validate(path, src) {
|
1578
1763
|
var unknownSrc = src;
|
1579
1764
|
var errors = false;
|
1580
|
-
if (this.opt &&
|
1581
|
-
// TODO: src should never be undefined
|
1765
|
+
if (this.opt && unknownSrc === null) {
|
1582
1766
|
return false;
|
1583
1767
|
}
|
1584
1768
|
if (!this.key) {
|
1585
1769
|
return _defineProperty({}, path, [{
|
1586
|
-
message: "Missing required first argument in union"
|
1770
|
+
message: "Missing required first argument in union",
|
1771
|
+
schemaError: true
|
1587
1772
|
}]);
|
1588
1773
|
}
|
1589
1774
|
var key = this.key;
|
1590
1775
|
if (!Array.isArray(this.items)) {
|
1591
1776
|
return _defineProperty({}, path, [{
|
1592
1777
|
message: "A union schema must take more than 1 schema arguments",
|
1593
|
-
|
1778
|
+
schemaError: true
|
1594
1779
|
}]);
|
1595
1780
|
}
|
1596
1781
|
if (typeof key === "string") {
|
@@ -1600,7 +1785,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1600
1785
|
})) {
|
1601
1786
|
return _defineProperty({}, path, [{
|
1602
1787
|
message: "Key is a string, so all schema items must be objects",
|
1603
|
-
|
1788
|
+
schemaError: true
|
1604
1789
|
}]);
|
1605
1790
|
}
|
1606
1791
|
var objectSchemas = this.items;
|
@@ -1613,7 +1798,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1613
1798
|
if (illegalSchemas.length > 0) {
|
1614
1799
|
return _defineProperty({}, path, [{
|
1615
1800
|
message: "All schema items must be objects with a key: ".concat(key, " that is a literal schema. Found: ").concat(JSON.stringify(illegalSchemas, null, 2)),
|
1616
|
-
|
1801
|
+
schemaError: true
|
1617
1802
|
}]);
|
1618
1803
|
}
|
1619
1804
|
var serializedObjectSchemas = serializedSchemas;
|
@@ -1623,18 +1808,20 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1623
1808
|
if (optionalLiterals.length > 1) {
|
1624
1809
|
return _defineProperty({}, path, [{
|
1625
1810
|
message: "Schema cannot have an optional keys: ".concat(key),
|
1626
|
-
|
1811
|
+
schemaError: true
|
1627
1812
|
}]);
|
1628
1813
|
}
|
1629
1814
|
if (_typeof(unknownSrc) !== "object") {
|
1630
1815
|
return _defineProperty({}, path, [{
|
1631
|
-
message: "Expected an object"
|
1816
|
+
message: "Expected an object",
|
1817
|
+
typeError: true
|
1632
1818
|
}]);
|
1633
1819
|
}
|
1634
1820
|
var objectSrc = unknownSrc;
|
1635
1821
|
if (objectSrc[key] === undefined) {
|
1636
1822
|
return _defineProperty({}, path, [{
|
1637
|
-
message: "Missing required key: ".concat(key)
|
1823
|
+
message: "Missing required key: ".concat(key),
|
1824
|
+
typeError: true
|
1638
1825
|
}]);
|
1639
1826
|
}
|
1640
1827
|
var foundSchemaLiterals = [];
|
@@ -1650,7 +1837,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1650
1837
|
} else {
|
1651
1838
|
return _defineProperty({}, path, [{
|
1652
1839
|
message: "Found duplicate key in schema: ".concat(schemaKey.value),
|
1653
|
-
|
1840
|
+
schemaError: true
|
1654
1841
|
}]);
|
1655
1842
|
}
|
1656
1843
|
}
|
@@ -1690,7 +1877,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1690
1877
|
})) {
|
1691
1878
|
return _defineProperty({}, path, [{
|
1692
1879
|
message: "Key is a literal schema, so all schema items must be literals",
|
1693
|
-
|
1880
|
+
typeError: true
|
1694
1881
|
}]);
|
1695
1882
|
}
|
1696
1883
|
var literalItems = [key].concat(_toConsumableArray(this.items));
|
@@ -1715,8 +1902,146 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1715
1902
|
}
|
1716
1903
|
}, {
|
1717
1904
|
key: "assert",
|
1718
|
-
value: function assert(src) {
|
1719
|
-
|
1905
|
+
value: function assert(path, src) {
|
1906
|
+
if (this.opt && src === null) {
|
1907
|
+
return {
|
1908
|
+
success: true,
|
1909
|
+
data: src
|
1910
|
+
};
|
1911
|
+
}
|
1912
|
+
if (src === null) {
|
1913
|
+
return {
|
1914
|
+
success: false,
|
1915
|
+
errors: _defineProperty({}, path, [{
|
1916
|
+
message: "Expected 'object', got 'null'",
|
1917
|
+
typeError: true
|
1918
|
+
}])
|
1919
|
+
};
|
1920
|
+
}
|
1921
|
+
if (!this.key) {
|
1922
|
+
return {
|
1923
|
+
success: false,
|
1924
|
+
errors: _defineProperty({}, path, [{
|
1925
|
+
message: "Missing required first argument in union schema",
|
1926
|
+
schemaError: true
|
1927
|
+
}])
|
1928
|
+
};
|
1929
|
+
}
|
1930
|
+
if (!Array.isArray(this.items)) {
|
1931
|
+
return {
|
1932
|
+
success: false,
|
1933
|
+
errors: _defineProperty({}, path, [{
|
1934
|
+
message: "The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)",
|
1935
|
+
schemaError: true
|
1936
|
+
}])
|
1937
|
+
};
|
1938
|
+
}
|
1939
|
+
if (this.key instanceof LiteralSchema) {
|
1940
|
+
var _ref13;
|
1941
|
+
var success = false;
|
1942
|
+
var errors = {};
|
1943
|
+
var _iterator2 = _createForOfIteratorHelper((_ref13 = [this.key]).concat.apply(_ref13, _toConsumableArray(this.items))),
|
1944
|
+
_step2;
|
1945
|
+
try {
|
1946
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
1947
|
+
var itemSchema = _step2.value;
|
1948
|
+
if (!(itemSchema instanceof LiteralSchema)) {
|
1949
|
+
return {
|
1950
|
+
success: false,
|
1951
|
+
errors: _defineProperty({}, path, [{
|
1952
|
+
message: "Schema of value is a union of string, so all schema items must be literals",
|
1953
|
+
schemaError: true
|
1954
|
+
}])
|
1955
|
+
};
|
1956
|
+
}
|
1957
|
+
if (typeof src !== "string") {
|
1958
|
+
errors[path] = [{
|
1959
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
1960
|
+
typeError: true
|
1961
|
+
}];
|
1962
|
+
continue;
|
1963
|
+
}
|
1964
|
+
var res = itemSchema.assert(path, src);
|
1965
|
+
if (res.success) {
|
1966
|
+
success = true;
|
1967
|
+
break;
|
1968
|
+
} else {
|
1969
|
+
for (var _i = 0, _Object$entries = Object.entries(res.errors); _i < _Object$entries.length; _i++) {
|
1970
|
+
var _errors5;
|
1971
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
1972
|
+
_key = _Object$entries$_i[0],
|
1973
|
+
value = _Object$entries$_i[1];
|
1974
|
+
if (!errors[_key]) {
|
1975
|
+
errors[_key] = [];
|
1976
|
+
}
|
1977
|
+
(_errors5 = errors[_key]).push.apply(_errors5, _toConsumableArray(value));
|
1978
|
+
}
|
1979
|
+
}
|
1980
|
+
}
|
1981
|
+
} catch (err) {
|
1982
|
+
_iterator2.e(err);
|
1983
|
+
} finally {
|
1984
|
+
_iterator2.f();
|
1985
|
+
}
|
1986
|
+
if (!success) {
|
1987
|
+
return {
|
1988
|
+
success: false,
|
1989
|
+
errors: errors
|
1990
|
+
};
|
1991
|
+
}
|
1992
|
+
return {
|
1993
|
+
success: true,
|
1994
|
+
data: src
|
1995
|
+
};
|
1996
|
+
} else if (typeof this.key === "string") {
|
1997
|
+
var _success = false;
|
1998
|
+
var _errors6 = {};
|
1999
|
+
var _iterator3 = _createForOfIteratorHelper(this.items),
|
2000
|
+
_step3;
|
2001
|
+
try {
|
2002
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
2003
|
+
var _itemSchema = _step3.value;
|
2004
|
+
var _res = _itemSchema.assert(path, src);
|
2005
|
+
if (_res.success) {
|
2006
|
+
_success = true;
|
2007
|
+
break;
|
2008
|
+
} else {
|
2009
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(_res.errors); _i2 < _Object$entries2.length; _i2++) {
|
2010
|
+
var _errors7;
|
2011
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
2012
|
+
_key2 = _Object$entries2$_i[0],
|
2013
|
+
_value = _Object$entries2$_i[1];
|
2014
|
+
if (!_errors6[_key2]) {
|
2015
|
+
_errors6[_key2] = [];
|
2016
|
+
}
|
2017
|
+
(_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
|
2018
|
+
}
|
2019
|
+
}
|
2020
|
+
}
|
2021
|
+
} catch (err) {
|
2022
|
+
_iterator3.e(err);
|
2023
|
+
} finally {
|
2024
|
+
_iterator3.f();
|
2025
|
+
}
|
2026
|
+
if (!_success) {
|
2027
|
+
return {
|
2028
|
+
success: false,
|
2029
|
+
errors: _errors6
|
2030
|
+
};
|
2031
|
+
}
|
2032
|
+
return {
|
2033
|
+
success: true,
|
2034
|
+
data: src
|
2035
|
+
};
|
2036
|
+
} else {
|
2037
|
+
return {
|
2038
|
+
success: false,
|
2039
|
+
errors: _defineProperty({}, path, [{
|
2040
|
+
message: "The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)",
|
2041
|
+
schemaError: true
|
2042
|
+
}])
|
2043
|
+
};
|
2044
|
+
}
|
1720
2045
|
}
|
1721
2046
|
}, {
|
1722
2047
|
key: "nullable",
|
@@ -1749,8 +2074,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1749
2074
|
return UnionSchema;
|
1750
2075
|
}(Schema);
|
1751
2076
|
var union = function union(key) {
|
1752
|
-
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0),
|
1753
|
-
objects[
|
2077
|
+
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
|
2078
|
+
objects[_key3 - 1] = arguments[_key3];
|
1754
2079
|
}
|
1755
2080
|
return new UnionSchema(key, objects);
|
1756
2081
|
};
|
@@ -1777,12 +2102,147 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
1777
2102
|
fixes: ["fix:deprecated-richtext"]
|
1778
2103
|
}]);
|
1779
2104
|
}
|
1780
|
-
|
2105
|
+
var assertRes = this.assert(path, src);
|
2106
|
+
if (!assertRes.success) {
|
2107
|
+
return _defineProperty({}, path, assertRes.errors[path]);
|
2108
|
+
}
|
2109
|
+
// TODO validate options
|
2110
|
+
return false;
|
1781
2111
|
}
|
1782
2112
|
}, {
|
1783
2113
|
key: "assert",
|
1784
|
-
value: function assert(src) {
|
1785
|
-
|
2114
|
+
value: function assert(path, src) {
|
2115
|
+
if (this.opt && src === null) {
|
2116
|
+
return {
|
2117
|
+
success: true,
|
2118
|
+
data: src
|
2119
|
+
};
|
2120
|
+
}
|
2121
|
+
if (!Array.isArray(src)) {
|
2122
|
+
return {
|
2123
|
+
success: false,
|
2124
|
+
errors: _defineProperty({}, path, [{
|
2125
|
+
message: "Expected 'array', got '".concat(_typeof(src), "'"),
|
2126
|
+
typeError: true
|
2127
|
+
}])
|
2128
|
+
};
|
2129
|
+
}
|
2130
|
+
var errors = {};
|
2131
|
+
for (var i = 0; i < src.length; i++) {
|
2132
|
+
this.recursiveAssert(unsafeCreateSourcePath(path, i), src[i], errors);
|
2133
|
+
}
|
2134
|
+
if (Object.keys(errors).length > 0) {
|
2135
|
+
return {
|
2136
|
+
success: false,
|
2137
|
+
errors: errors
|
2138
|
+
};
|
2139
|
+
}
|
2140
|
+
// TODO: validate options
|
2141
|
+
return {
|
2142
|
+
success: true,
|
2143
|
+
data: src
|
2144
|
+
};
|
2145
|
+
}
|
2146
|
+
}, {
|
2147
|
+
key: "recursiveAssert",
|
2148
|
+
value: function recursiveAssert(path, node, errors) {
|
2149
|
+
if (_typeof(node) !== "object") {
|
2150
|
+
if (!errors[path]) {
|
2151
|
+
errors[path] = [];
|
2152
|
+
}
|
2153
|
+
errors[path].push({
|
2154
|
+
message: "Expected 'object', got '".concat(_typeof(node), "'"),
|
2155
|
+
typeError: true
|
2156
|
+
});
|
2157
|
+
return;
|
2158
|
+
}
|
2159
|
+
if (Array.isArray(node)) {
|
2160
|
+
if (!errors[path]) {
|
2161
|
+
errors[path] = [];
|
2162
|
+
}
|
2163
|
+
errors[path].push({
|
2164
|
+
message: "Expected 'object', got 'array'",
|
2165
|
+
typeError: true
|
2166
|
+
});
|
2167
|
+
return;
|
2168
|
+
}
|
2169
|
+
if (node === null) {
|
2170
|
+
if (!errors[path]) {
|
2171
|
+
errors[path] = [];
|
2172
|
+
}
|
2173
|
+
errors[path].push({
|
2174
|
+
message: "Expected 'object', got 'null'",
|
2175
|
+
typeError: true
|
2176
|
+
});
|
2177
|
+
return;
|
2178
|
+
}
|
2179
|
+
if ("tag" in node) {
|
2180
|
+
if (typeof node.tag !== "string") {
|
2181
|
+
if (!errors[path]) {
|
2182
|
+
errors[path] = [];
|
2183
|
+
}
|
2184
|
+
errors[path].push({
|
2185
|
+
message: "Expected 'string', got '".concat(_typeof(node.tag), "'"),
|
2186
|
+
typeError: true
|
2187
|
+
});
|
2188
|
+
return;
|
2189
|
+
}
|
2190
|
+
}
|
2191
|
+
if ("children" in node) {
|
2192
|
+
if (!Array.isArray(node.children)) {
|
2193
|
+
if (!errors[path]) {
|
2194
|
+
errors[path] = [];
|
2195
|
+
}
|
2196
|
+
errors[path].push({
|
2197
|
+
message: "Expected 'array', got '".concat(_typeof(node.children), "'"),
|
2198
|
+
typeError: true
|
2199
|
+
});
|
2200
|
+
return;
|
2201
|
+
} else {
|
2202
|
+
for (var i = 0; i < node.children.length; i++) {
|
2203
|
+
var child = node.children[i];
|
2204
|
+
var pathAtError = unsafeCreateSourcePath(unsafeCreateSourcePath(path, "children"), i);
|
2205
|
+
if (_typeof(child) === "object") {
|
2206
|
+
this.recursiveAssert(pathAtError, child, errors);
|
2207
|
+
} else if (typeof child === "string") {
|
2208
|
+
continue;
|
2209
|
+
} else {
|
2210
|
+
if (!errors[pathAtError]) {
|
2211
|
+
errors[pathAtError] = [];
|
2212
|
+
}
|
2213
|
+
errors[pathAtError].push({
|
2214
|
+
message: "Expected 'object' or 'string', got '".concat(_typeof(child), "'"),
|
2215
|
+
typeError: true
|
2216
|
+
});
|
2217
|
+
}
|
2218
|
+
}
|
2219
|
+
}
|
2220
|
+
}
|
2221
|
+
if ("styles" in node) {
|
2222
|
+
if (!Array.isArray(node.styles)) {
|
2223
|
+
if (!errors[path]) {
|
2224
|
+
errors[path] = [];
|
2225
|
+
}
|
2226
|
+
errors[path].push({
|
2227
|
+
message: "Expected 'array', got '".concat(_typeof(node.styles), "'"),
|
2228
|
+
typeError: true
|
2229
|
+
});
|
2230
|
+
} else {
|
2231
|
+
for (var _i = 0; _i < node.styles.length; _i++) {
|
2232
|
+
var style = node.styles[_i];
|
2233
|
+
if (typeof style !== "string") {
|
2234
|
+
var _pathAtError = unsafeCreateSourcePath(path, _i);
|
2235
|
+
if (!errors[_pathAtError]) {
|
2236
|
+
errors[_pathAtError] = [];
|
2237
|
+
}
|
2238
|
+
errors[_pathAtError].push({
|
2239
|
+
message: "Expected 'string', got '".concat(_typeof(style), "'"),
|
2240
|
+
typeError: true
|
2241
|
+
});
|
2242
|
+
}
|
2243
|
+
}
|
2244
|
+
}
|
2245
|
+
}
|
1786
2246
|
}
|
1787
2247
|
}, {
|
1788
2248
|
key: "nullable",
|
@@ -1840,6 +2300,50 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1840
2300
|
value: src
|
1841
2301
|
}]);
|
1842
2302
|
}
|
2303
|
+
var _ref4 = this.options || {},
|
2304
|
+
accept = _ref4.accept;
|
2305
|
+
var _ref5 = src.metadata || {},
|
2306
|
+
mimeType = _ref5.mimeType;
|
2307
|
+
if (accept && mimeType && !mimeType.includes("/")) {
|
2308
|
+
return _defineProperty({}, path, [{
|
2309
|
+
message: "Invalid mime type format. Got: '".concat(mimeType, "'"),
|
2310
|
+
value: src
|
2311
|
+
}]);
|
2312
|
+
}
|
2313
|
+
if (accept && mimeType && mimeType.includes("/")) {
|
2314
|
+
var acceptedTypes = accept.split(",").map(function (type) {
|
2315
|
+
return type.trim();
|
2316
|
+
});
|
2317
|
+
var isValidMimeType = acceptedTypes.some(function (acceptedType) {
|
2318
|
+
if (acceptedType === "*/*") {
|
2319
|
+
return true;
|
2320
|
+
}
|
2321
|
+
if (acceptedType.endsWith("/*")) {
|
2322
|
+
var baseType = acceptedType.slice(0, -2);
|
2323
|
+
return mimeType.startsWith(baseType);
|
2324
|
+
}
|
2325
|
+
return acceptedType === mimeType;
|
2326
|
+
});
|
2327
|
+
if (!isValidMimeType) {
|
2328
|
+
return _defineProperty({}, path, [{
|
2329
|
+
message: "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'"),
|
2330
|
+
value: src
|
2331
|
+
}]);
|
2332
|
+
}
|
2333
|
+
}
|
2334
|
+
var fileMimeType = Internal.filenameToMimeType(src[FILE_REF_PROP]);
|
2335
|
+
if (!fileMimeType) {
|
2336
|
+
return _defineProperty({}, path, [{
|
2337
|
+
message: "Could not determine mime type from file extension. Got: ".concat(src[FILE_REF_PROP]),
|
2338
|
+
value: src
|
2339
|
+
}]);
|
2340
|
+
}
|
2341
|
+
if (fileMimeType && mimeType && fileMimeType !== mimeType) {
|
2342
|
+
return _defineProperty({}, path, [{
|
2343
|
+
message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
|
2344
|
+
value: src
|
2345
|
+
}]);
|
2346
|
+
}
|
1843
2347
|
if (src.metadata) {
|
1844
2348
|
return _defineProperty({}, path, [{
|
1845
2349
|
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).",
|
@@ -1856,23 +2360,65 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1856
2360
|
}
|
1857
2361
|
}, {
|
1858
2362
|
key: "assert",
|
1859
|
-
value: function assert(src) {
|
1860
|
-
if (this.opt &&
|
1861
|
-
return
|
2363
|
+
value: function assert(path, src) {
|
2364
|
+
if (this.opt && src === null) {
|
2365
|
+
return {
|
2366
|
+
success: true,
|
2367
|
+
data: src
|
2368
|
+
};
|
1862
2369
|
}
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
2370
|
+
if (src === null) {
|
2371
|
+
return {
|
2372
|
+
success: false,
|
2373
|
+
errors: _defineProperty({}, path, [{
|
2374
|
+
message: "Expected 'object', got 'null'",
|
2375
|
+
typeError: true
|
2376
|
+
}])
|
2377
|
+
};
|
2378
|
+
}
|
2379
|
+
if (_typeof(src) !== "object") {
|
2380
|
+
return {
|
2381
|
+
success: false,
|
2382
|
+
errors: _defineProperty({}, path, [{
|
2383
|
+
message: "Expected 'object', got '".concat(_typeof(src), "'"),
|
2384
|
+
typeError: true
|
2385
|
+
}])
|
2386
|
+
};
|
2387
|
+
}
|
2388
|
+
if (!(FILE_REF_PROP in src)) {
|
2389
|
+
return {
|
2390
|
+
success: false,
|
2391
|
+
errors: _defineProperty({}, path, [{
|
2392
|
+
message: "Value of this schema must use: 'c.image' (error type: missing_ref_prop)",
|
2393
|
+
typeError: true
|
2394
|
+
}])
|
2395
|
+
};
|
2396
|
+
}
|
2397
|
+
if (!(VAL_EXTENSION in src && src[VAL_EXTENSION] === "file")) {
|
2398
|
+
return {
|
2399
|
+
success: false,
|
2400
|
+
errors: _defineProperty({}, path, [{
|
2401
|
+
message: "Value of this schema must use: 'c.image' (error type: missing_file_extension)",
|
2402
|
+
typeError: true
|
2403
|
+
}])
|
2404
|
+
};
|
2405
|
+
}
|
2406
|
+
return {
|
2407
|
+
success: true,
|
2408
|
+
data: src
|
2409
|
+
};
|
2410
|
+
}
|
2411
|
+
}, {
|
2412
|
+
key: "nullable",
|
2413
|
+
value: function nullable() {
|
2414
|
+
return new ImageSchema(this.options, true);
|
2415
|
+
}
|
2416
|
+
}, {
|
2417
|
+
key: "serialize",
|
2418
|
+
value: function serialize() {
|
2419
|
+
return {
|
2420
|
+
type: "image",
|
2421
|
+
options: this.options,
|
1876
2422
|
opt: this.opt
|
1877
2423
|
};
|
1878
2424
|
}
|
@@ -1902,6 +2448,11 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1902
2448
|
if (this.opt && (src === null || src === undefined)) {
|
1903
2449
|
return false;
|
1904
2450
|
}
|
2451
|
+
if (src === null) {
|
2452
|
+
return _defineProperty({}, path, [{
|
2453
|
+
message: "Expected 'object', got 'null'"
|
2454
|
+
}]);
|
2455
|
+
}
|
1905
2456
|
if (_typeof(src) !== "object") {
|
1906
2457
|
return _defineProperty({}, path, [{
|
1907
2458
|
message: "Expected 'object', got '".concat(_typeof(src), "'")
|
@@ -1912,10 +2463,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1912
2463
|
message: "Expected 'object', got 'array'"
|
1913
2464
|
}]);
|
1914
2465
|
}
|
1915
|
-
Object.entries(src).forEach(function (
|
1916
|
-
var
|
1917
|
-
key =
|
1918
|
-
elem =
|
2466
|
+
Object.entries(src).forEach(function (_ref4) {
|
2467
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
2468
|
+
key = _ref5[0],
|
2469
|
+
elem = _ref5[1];
|
1919
2470
|
var subPath = createValPathOfItem(path, key);
|
1920
2471
|
if (!subPath) {
|
1921
2472
|
error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(elem),
|
@@ -1934,21 +2485,35 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1934
2485
|
}
|
1935
2486
|
}, {
|
1936
2487
|
key: "assert",
|
1937
|
-
value: function assert(src) {
|
1938
|
-
if (this.opt &&
|
1939
|
-
return
|
2488
|
+
value: function assert(path, src) {
|
2489
|
+
if (this.opt && src === null) {
|
2490
|
+
return {
|
2491
|
+
success: true,
|
2492
|
+
data: src
|
2493
|
+
};
|
1940
2494
|
}
|
1941
|
-
if (
|
1942
|
-
return
|
2495
|
+
if (_typeof(src) !== "object") {
|
2496
|
+
return {
|
2497
|
+
success: false,
|
2498
|
+
errors: _defineProperty({}, path, [{
|
2499
|
+
message: "Expected 'object', got '".concat(_typeof(src), "'"),
|
2500
|
+
typeError: true
|
2501
|
+
}])
|
2502
|
+
};
|
1943
2503
|
}
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
2504
|
+
if (Array.isArray(src)) {
|
2505
|
+
return {
|
2506
|
+
success: false,
|
2507
|
+
errors: _defineProperty({}, path, [{
|
2508
|
+
message: "Expected 'object', got 'array'",
|
2509
|
+
typeError: true
|
2510
|
+
}])
|
2511
|
+
};
|
1950
2512
|
}
|
1951
|
-
return
|
2513
|
+
return {
|
2514
|
+
success: true,
|
2515
|
+
data: src
|
2516
|
+
};
|
1952
2517
|
}
|
1953
2518
|
}, {
|
1954
2519
|
key: "nullable",
|
@@ -2016,7 +2581,9 @@ function isArraySchema(schema) {
|
|
2016
2581
|
// );
|
2017
2582
|
// }
|
2018
2583
|
|
2019
|
-
function isUnionSchema(schema
|
2584
|
+
function isUnionSchema(schema
|
2585
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2586
|
+
) {
|
2020
2587
|
return schema instanceof UnionSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "union";
|
2021
2588
|
}
|
2022
2589
|
|
@@ -2038,6 +2605,7 @@ function isImageSchema(schema) {
|
|
2038
2605
|
// }
|
2039
2606
|
|
2040
2607
|
function resolvePath(path, valModule, schema) {
|
2608
|
+
// TODO: use schema assert while resolving (and emit errors if any)
|
2041
2609
|
var parts = parsePath(path);
|
2042
2610
|
var origParts = _toConsumableArray(parts);
|
2043
2611
|
var resolvedSchema = schema;
|
@@ -2132,6 +2700,7 @@ function resolvePath(path, valModule, schema) {
|
|
2132
2700
|
if (!keyValue) {
|
2133
2701
|
throw Error("Invalid path: union source ".concat(resolvedSchema, " did not have required key ").concat(_key, " in path: ").concat(path));
|
2134
2702
|
}
|
2703
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2135
2704
|
var schemaOfUnionKey = resolvedSchema.items.find(
|
2136
2705
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2137
2706
|
function (child) {
|
@@ -2243,11 +2812,35 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
2243
2812
|
}
|
2244
2813
|
}, {
|
2245
2814
|
key: "assert",
|
2246
|
-
value: function assert(src) {
|
2247
|
-
if (this.opt &&
|
2248
|
-
return
|
2815
|
+
value: function assert(path, src) {
|
2816
|
+
if (this.opt && src === null) {
|
2817
|
+
return {
|
2818
|
+
success: true,
|
2819
|
+
data: src
|
2820
|
+
};
|
2249
2821
|
}
|
2250
|
-
|
2822
|
+
if (src === null) {
|
2823
|
+
return {
|
2824
|
+
success: false,
|
2825
|
+
errors: _defineProperty({}, path, [{
|
2826
|
+
message: "Expected 'number', got 'null'",
|
2827
|
+
typeError: true
|
2828
|
+
}])
|
2829
|
+
};
|
2830
|
+
}
|
2831
|
+
if (typeof src === "number") {
|
2832
|
+
return {
|
2833
|
+
success: true,
|
2834
|
+
data: src
|
2835
|
+
};
|
2836
|
+
}
|
2837
|
+
return {
|
2838
|
+
success: false,
|
2839
|
+
errors: _defineProperty({}, path, [{
|
2840
|
+
message: "Expected 'number', got '".concat(_typeof(src), "'"),
|
2841
|
+
typeError: true
|
2842
|
+
}])
|
2843
|
+
};
|
2251
2844
|
}
|
2252
2845
|
}, {
|
2253
2846
|
key: "nullable",
|
@@ -2343,11 +2936,26 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
2343
2936
|
}
|
2344
2937
|
}, {
|
2345
2938
|
key: "assert",
|
2346
|
-
value: function assert(src) {
|
2347
|
-
if (this.opt &&
|
2348
|
-
return
|
2939
|
+
value: function assert(path, src) {
|
2940
|
+
if (this.opt && src === null) {
|
2941
|
+
return {
|
2942
|
+
success: true,
|
2943
|
+
data: src
|
2944
|
+
};
|
2349
2945
|
}
|
2350
|
-
|
2946
|
+
if (typeof src === "string") {
|
2947
|
+
return {
|
2948
|
+
success: true,
|
2949
|
+
data: src
|
2950
|
+
};
|
2951
|
+
}
|
2952
|
+
return {
|
2953
|
+
success: false,
|
2954
|
+
errors: _defineProperty({}, path, [{
|
2955
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
2956
|
+
typeError: true
|
2957
|
+
}])
|
2958
|
+
};
|
2351
2959
|
}
|
2352
2960
|
}, {
|
2353
2961
|
key: "nullable",
|
@@ -2410,11 +3018,35 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
2410
3018
|
}
|
2411
3019
|
}, {
|
2412
3020
|
key: "assert",
|
2413
|
-
value: function assert(src) {
|
2414
|
-
if (this.opt &&
|
2415
|
-
return
|
3021
|
+
value: function assert(path, src) {
|
3022
|
+
if (this.opt && src === null) {
|
3023
|
+
return {
|
3024
|
+
success: true,
|
3025
|
+
data: src
|
3026
|
+
};
|
3027
|
+
}
|
3028
|
+
if (src === null) {
|
3029
|
+
return {
|
3030
|
+
success: false,
|
3031
|
+
errors: _defineProperty({}, path, [{
|
3032
|
+
message: "Expected 'boolean', got 'null'",
|
3033
|
+
typeError: true
|
3034
|
+
}])
|
3035
|
+
};
|
2416
3036
|
}
|
2417
|
-
|
3037
|
+
if (typeof src !== "boolean") {
|
3038
|
+
return {
|
3039
|
+
success: false,
|
3040
|
+
errors: _defineProperty({}, path, [{
|
3041
|
+
message: "Expected 'boolean', got '".concat(_typeof(src), "'"),
|
3042
|
+
typeError: true
|
3043
|
+
}])
|
3044
|
+
};
|
3045
|
+
}
|
3046
|
+
return {
|
3047
|
+
success: true,
|
3048
|
+
data: src
|
3049
|
+
};
|
2418
3050
|
}
|
2419
3051
|
}, {
|
2420
3052
|
key: "nullable",
|
@@ -2490,34 +3122,79 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2490
3122
|
}
|
2491
3123
|
}, {
|
2492
3124
|
key: "assert",
|
2493
|
-
value: function assert(src) {
|
2494
|
-
if (this.opt &&
|
2495
|
-
return
|
3125
|
+
value: function assert(path, src) {
|
3126
|
+
if (this.opt && src === null) {
|
3127
|
+
return {
|
3128
|
+
success: true,
|
3129
|
+
data: src
|
3130
|
+
};
|
3131
|
+
}
|
3132
|
+
if (src === null) {
|
3133
|
+
return {
|
3134
|
+
success: false,
|
3135
|
+
errors: _defineProperty({}, path, [{
|
3136
|
+
message: "Expected 'string', got 'null'",
|
3137
|
+
typeError: true
|
3138
|
+
}])
|
3139
|
+
};
|
2496
3140
|
}
|
2497
3141
|
var schema = this.schema;
|
2498
3142
|
if (!schema) {
|
2499
|
-
return
|
3143
|
+
return {
|
3144
|
+
success: false,
|
3145
|
+
errors: _defineProperty({}, path, [{
|
3146
|
+
message: "Neither key nor schema was found. keyOf is missing an argument.",
|
3147
|
+
typeError: true
|
3148
|
+
}])
|
3149
|
+
};
|
2500
3150
|
}
|
2501
3151
|
var serializedSchema = schema;
|
2502
3152
|
if (!(serializedSchema.type === "array" || serializedSchema.type === "object" || serializedSchema.type === "record")) {
|
2503
|
-
return
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
3153
|
+
return {
|
3154
|
+
success: false,
|
3155
|
+
errors: _defineProperty({}, path, [{
|
3156
|
+
message: "Schema of first argument must be either: 'array', 'object' or 'record'. Found '".concat(serializedSchema.type, "'"),
|
3157
|
+
typeError: true
|
3158
|
+
}])
|
3159
|
+
};
|
2507
3160
|
}
|
2508
3161
|
if (serializedSchema.type === "array" && typeof src !== "number") {
|
2509
|
-
return
|
3162
|
+
return {
|
3163
|
+
success: false,
|
3164
|
+
errors: _defineProperty({}, path, [{
|
3165
|
+
message: "Value of keyOf (array) must be 'number', got '".concat(_typeof(src), "'"),
|
3166
|
+
typeError: true
|
3167
|
+
}])
|
3168
|
+
};
|
2510
3169
|
}
|
2511
3170
|
if (serializedSchema.type === "record" && typeof src !== "string") {
|
2512
|
-
return
|
3171
|
+
return {
|
3172
|
+
success: false,
|
3173
|
+
errors: _defineProperty({}, path, [{
|
3174
|
+
message: "Value of keyOf (record) must be 'string', got '".concat(_typeof(src), "'"),
|
3175
|
+
typeError: true
|
3176
|
+
}])
|
3177
|
+
};
|
2513
3178
|
}
|
3179
|
+
// We check actual value here, since TypeScript also does this. Literals are used in other types (unions),
|
3180
|
+
// and there it also makes sense to check the actual string values (i.e. that it is not just a string) since
|
3181
|
+
// missing one would lead to a runtime error. At least this is what we are thinking currently.
|
2514
3182
|
if (serializedSchema.type === "object") {
|
2515
3183
|
var keys = Object.keys(serializedSchema.items);
|
2516
3184
|
if (!keys.includes(src)) {
|
2517
|
-
return
|
3185
|
+
return {
|
3186
|
+
success: false,
|
3187
|
+
errors: _defineProperty({}, path, [{
|
3188
|
+
message: "Value of keyOf (object) must be: ".concat(keys.join(", "), ". Found: ").concat(src),
|
3189
|
+
typeError: true
|
3190
|
+
}])
|
3191
|
+
};
|
2518
3192
|
}
|
2519
3193
|
}
|
2520
|
-
return
|
3194
|
+
return {
|
3195
|
+
success: true,
|
3196
|
+
data: src
|
3197
|
+
};
|
2521
3198
|
}
|
2522
3199
|
}, {
|
2523
3200
|
key: "nullable",
|
@@ -2565,6 +3242,135 @@ var keyOf = function keyOf(valModule) {
|
|
2565
3242
|
return new KeyOfSchema(valModule === null || valModule === void 0 || (_valModule$GetSchema = valModule[GetSchema$1]) === null || _valModule$GetSchema === void 0 ? void 0 : _valModule$GetSchema.serialize(), getValPath(valModule));
|
2566
3243
|
};
|
2567
3244
|
|
3245
|
+
var DateSchema = /*#__PURE__*/function (_Schema) {
|
3246
|
+
_inherits(DateSchema, _Schema);
|
3247
|
+
function DateSchema(options) {
|
3248
|
+
var _this;
|
3249
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
3250
|
+
_classCallCheck(this, DateSchema);
|
3251
|
+
_this = _callSuper(this, DateSchema);
|
3252
|
+
_this.options = options;
|
3253
|
+
_this.opt = opt;
|
3254
|
+
return _this;
|
3255
|
+
}
|
3256
|
+
_createClass(DateSchema, [{
|
3257
|
+
key: "validate",
|
3258
|
+
value: function validate(path, src) {
|
3259
|
+
var _this$options, _this$options2, _this$options3, _this$options4;
|
3260
|
+
if (this.opt && (src === null || src === undefined)) {
|
3261
|
+
return false;
|
3262
|
+
}
|
3263
|
+
if (typeof src !== "string") {
|
3264
|
+
return _defineProperty({}, path, [{
|
3265
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
3266
|
+
value: src
|
3267
|
+
}]);
|
3268
|
+
}
|
3269
|
+
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.from && (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.to) {
|
3270
|
+
if (this.options.from > this.options.to) {
|
3271
|
+
return _defineProperty({}, path, [{
|
3272
|
+
message: "From date ".concat(this.options.from, " is after to date ").concat(this.options.to),
|
3273
|
+
value: src,
|
3274
|
+
typeError: true
|
3275
|
+
}]);
|
3276
|
+
}
|
3277
|
+
if (src < this.options.from || src > this.options.to) {
|
3278
|
+
return _defineProperty({}, path, [{
|
3279
|
+
message: "Date is not between ".concat(this.options.from, " and ").concat(this.options.to),
|
3280
|
+
value: src
|
3281
|
+
}]);
|
3282
|
+
}
|
3283
|
+
} else if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.from) {
|
3284
|
+
if (src < this.options.from) {
|
3285
|
+
return _defineProperty({}, path, [{
|
3286
|
+
message: "Date is before the minimum date ".concat(this.options.from),
|
3287
|
+
value: src
|
3288
|
+
}]);
|
3289
|
+
}
|
3290
|
+
} else if ((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.to) {
|
3291
|
+
if (src > this.options.to) {
|
3292
|
+
return _defineProperty({}, path, [{
|
3293
|
+
message: "Date is after the maximum date ".concat(this.options.to),
|
3294
|
+
value: src
|
3295
|
+
}]);
|
3296
|
+
}
|
3297
|
+
}
|
3298
|
+
// const errors = [];
|
3299
|
+
|
3300
|
+
// if (errors.length > 0) {
|
3301
|
+
// return {
|
3302
|
+
// [path]: errors,
|
3303
|
+
// } as ValidationErrors;
|
3304
|
+
// }
|
3305
|
+
return false;
|
3306
|
+
}
|
3307
|
+
}, {
|
3308
|
+
key: "assert",
|
3309
|
+
value: function assert(path, src) {
|
3310
|
+
if (this.opt && src === null) {
|
3311
|
+
return {
|
3312
|
+
success: true,
|
3313
|
+
data: src
|
3314
|
+
};
|
3315
|
+
}
|
3316
|
+
if (src === null) {
|
3317
|
+
return {
|
3318
|
+
success: false,
|
3319
|
+
errors: _defineProperty({}, path, [{
|
3320
|
+
message: "Expected 'string', got 'null'",
|
3321
|
+
typeError: true
|
3322
|
+
}])
|
3323
|
+
};
|
3324
|
+
}
|
3325
|
+
if (typeof src !== "string") {
|
3326
|
+
return {
|
3327
|
+
success: false,
|
3328
|
+
errors: _defineProperty({}, path, [{
|
3329
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
3330
|
+
typeError: true
|
3331
|
+
}])
|
3332
|
+
};
|
3333
|
+
}
|
3334
|
+
return {
|
3335
|
+
success: true,
|
3336
|
+
data: src
|
3337
|
+
};
|
3338
|
+
}
|
3339
|
+
}, {
|
3340
|
+
key: "from",
|
3341
|
+
value: function from(_from) {
|
3342
|
+
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
3343
|
+
from: _from
|
3344
|
+
}), this.opt);
|
3345
|
+
}
|
3346
|
+
}, {
|
3347
|
+
key: "to",
|
3348
|
+
value: function to(_to) {
|
3349
|
+
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
3350
|
+
to: _to
|
3351
|
+
}), this.opt);
|
3352
|
+
}
|
3353
|
+
}, {
|
3354
|
+
key: "nullable",
|
3355
|
+
value: function nullable() {
|
3356
|
+
return new DateSchema(this.options, true);
|
3357
|
+
}
|
3358
|
+
}, {
|
3359
|
+
key: "serialize",
|
3360
|
+
value: function serialize() {
|
3361
|
+
return {
|
3362
|
+
type: "date",
|
3363
|
+
opt: this.opt,
|
3364
|
+
options: this.options
|
3365
|
+
};
|
3366
|
+
}
|
3367
|
+
}]);
|
3368
|
+
return DateSchema;
|
3369
|
+
}(Schema);
|
3370
|
+
var date = function date(options) {
|
3371
|
+
return new DateSchema(options);
|
3372
|
+
};
|
3373
|
+
|
2568
3374
|
// import type { F } from "ts-toolbelt";
|
2569
3375
|
// import { i18n, I18n } from "./schema/future/i18n";
|
2570
3376
|
// import { oneOf } from "./schema/future/oneOf";
|
@@ -2587,7 +3393,8 @@ function initSchema() {
|
|
2587
3393
|
literal: literal,
|
2588
3394
|
keyOf: keyOf,
|
2589
3395
|
record: record,
|
2590
|
-
file: file
|
3396
|
+
file: file,
|
3397
|
+
date: date
|
2591
3398
|
// i18n: i18n(locales),
|
2592
3399
|
};
|
2593
3400
|
}
|
@@ -3507,6 +4314,728 @@ var getSHA256Hash = function getSHA256Hash(bits) {
|
|
3507
4314
|
return createHash().update(bits).digest("hex");
|
3508
4315
|
};
|
3509
4316
|
|
4317
|
+
var EXT_TO_MIME_TYPES = {
|
4318
|
+
x3d: "application/vnd.hzn-3d-crossword",
|
4319
|
+
"3gp": "video/3gpp",
|
4320
|
+
"3g2": "video/3gpp2",
|
4321
|
+
mseq: "application/vnd.mseq",
|
4322
|
+
pwn: "application/vnd.3m.post-it-notes",
|
4323
|
+
plb: "application/vnd.3gpp.pic-bw-large",
|
4324
|
+
psb: "application/vnd.3gpp.pic-bw-small",
|
4325
|
+
pvb: "application/vnd.3gpp.pic-bw-var",
|
4326
|
+
tcap: "application/vnd.3gpp2.tcap",
|
4327
|
+
"7z": "application/x-7z-compressed",
|
4328
|
+
abw: "application/x-abiword",
|
4329
|
+
ace: "application/x-ace-compressed",
|
4330
|
+
acc: "application/vnd.americandynamics.acc",
|
4331
|
+
acu: "application/vnd.acucobol",
|
4332
|
+
atc: "application/vnd.acucorp",
|
4333
|
+
adp: "audio/adpcm",
|
4334
|
+
aab: "application/x-authorware-bin",
|
4335
|
+
aam: "application/x-authorware-map",
|
4336
|
+
aas: "application/x-authorware-seg",
|
4337
|
+
air: "application/vnd.adobe.air-application-installer-package+zip",
|
4338
|
+
swf: "application/x-shockwave-flash",
|
4339
|
+
fxp: "application/vnd.adobe.fxp",
|
4340
|
+
pdf: "application/pdf",
|
4341
|
+
ppd: "application/vnd.cups-ppd",
|
4342
|
+
dir: "application/x-director",
|
4343
|
+
xdp: "application/vnd.adobe.xdp+xml",
|
4344
|
+
xfdf: "application/vnd.adobe.xfdf",
|
4345
|
+
aac: "audio/x-aac",
|
4346
|
+
ahead: "application/vnd.ahead.space",
|
4347
|
+
azf: "application/vnd.airzip.filesecure.azf",
|
4348
|
+
azs: "application/vnd.airzip.filesecure.azs",
|
4349
|
+
azw: "application/vnd.amazon.ebook",
|
4350
|
+
ami: "application/vnd.amiga.ami",
|
4351
|
+
"N/A": "application/andrew-inset",
|
4352
|
+
apk: "application/vnd.android.package-archive",
|
4353
|
+
cii: "application/vnd.anser-web-certificate-issue-initiation",
|
4354
|
+
fti: "application/vnd.anser-web-funds-transfer-initiation",
|
4355
|
+
atx: "application/vnd.antix.game-component",
|
4356
|
+
dmg: "application/x-apple-diskimage",
|
4357
|
+
mpkg: "application/vnd.apple.installer+xml",
|
4358
|
+
aw: "application/applixware",
|
4359
|
+
mp3: "audio/mpeg",
|
4360
|
+
les: "application/vnd.hhe.lesson-player",
|
4361
|
+
swi: "application/vnd.aristanetworks.swi",
|
4362
|
+
s: "text/x-asm",
|
4363
|
+
atomcat: "application/atomcat+xml",
|
4364
|
+
atomsvc: "application/atomsvc+xml",
|
4365
|
+
atom: "application/atom+xml",
|
4366
|
+
ac: "application/pkix-attr-cert",
|
4367
|
+
aif: "audio/x-aiff",
|
4368
|
+
avi: "video/x-msvideo",
|
4369
|
+
aep: "application/vnd.audiograph",
|
4370
|
+
dxf: "image/vnd.dxf",
|
4371
|
+
dwf: "model/vnd.dwf",
|
4372
|
+
par: "text/plain-bas",
|
4373
|
+
bcpio: "application/x-bcpio",
|
4374
|
+
bin: "application/octet-stream",
|
4375
|
+
bmp: "image/bmp",
|
4376
|
+
torrent: "application/x-bittorrent",
|
4377
|
+
cod: "application/vnd.rim.cod",
|
4378
|
+
mpm: "application/vnd.blueice.multipass",
|
4379
|
+
bmi: "application/vnd.bmi",
|
4380
|
+
sh: "application/x-sh",
|
4381
|
+
btif: "image/prs.btif",
|
4382
|
+
rep: "application/vnd.businessobjects",
|
4383
|
+
bz: "application/x-bzip",
|
4384
|
+
bz2: "application/x-bzip2",
|
4385
|
+
csh: "application/x-csh",
|
4386
|
+
c: "text/x-c",
|
4387
|
+
cdxml: "application/vnd.chemdraw+xml",
|
4388
|
+
css: "text/css",
|
4389
|
+
cdx: "chemical/x-cdx",
|
4390
|
+
cml: "chemical/x-cml",
|
4391
|
+
csml: "chemical/x-csml",
|
4392
|
+
cdbcmsg: "application/vnd.contact.cmsg",
|
4393
|
+
cla: "application/vnd.claymore",
|
4394
|
+
c4g: "application/vnd.clonk.c4group",
|
4395
|
+
sub: "image/vnd.dvb.subtitle",
|
4396
|
+
cdmia: "application/cdmi-capability",
|
4397
|
+
cdmic: "application/cdmi-container",
|
4398
|
+
cdmid: "application/cdmi-domain",
|
4399
|
+
cdmio: "application/cdmi-object",
|
4400
|
+
cdmiq: "application/cdmi-queue",
|
4401
|
+
c11amc: "application/vnd.cluetrust.cartomobile-config",
|
4402
|
+
c11amz: "application/vnd.cluetrust.cartomobile-config-pkg",
|
4403
|
+
ras: "image/x-cmu-raster",
|
4404
|
+
dae: "model/vnd.collada+xml",
|
4405
|
+
csv: "text/csv",
|
4406
|
+
cpt: "application/mac-compactpro",
|
4407
|
+
wmlc: "application/vnd.wap.wmlc",
|
4408
|
+
cgm: "image/cgm",
|
4409
|
+
ice: "x-conference/x-cooltalk",
|
4410
|
+
cmx: "image/x-cmx",
|
4411
|
+
xar: "application/vnd.xara",
|
4412
|
+
cmc: "application/vnd.cosmocaller",
|
4413
|
+
cpio: "application/x-cpio",
|
4414
|
+
clkx: "application/vnd.crick.clicker",
|
4415
|
+
clkk: "application/vnd.crick.clicker.keyboard",
|
4416
|
+
clkp: "application/vnd.crick.clicker.palette",
|
4417
|
+
clkt: "application/vnd.crick.clicker.template",
|
4418
|
+
clkw: "application/vnd.crick.clicker.wordbank",
|
4419
|
+
wbs: "application/vnd.criticaltools.wbs+xml",
|
4420
|
+
cryptonote: "application/vnd.rig.cryptonote",
|
4421
|
+
cif: "chemical/x-cif",
|
4422
|
+
cmdf: "chemical/x-cmdf",
|
4423
|
+
cu: "application/cu-seeme",
|
4424
|
+
cww: "application/prs.cww",
|
4425
|
+
curl: "text/vnd.curl",
|
4426
|
+
dcurl: "text/vnd.curl.dcurl",
|
4427
|
+
mcurl: "text/vnd.curl.mcurl",
|
4428
|
+
scurl: "text/vnd.curl.scurl",
|
4429
|
+
car: "application/vnd.curl.car",
|
4430
|
+
pcurl: "application/vnd.curl.pcurl",
|
4431
|
+
cmp: "application/vnd.yellowriver-custom-menu",
|
4432
|
+
dssc: "application/dssc+der",
|
4433
|
+
xdssc: "application/dssc+xml",
|
4434
|
+
deb: "application/x-debian-package",
|
4435
|
+
uva: "audio/vnd.dece.audio",
|
4436
|
+
uvi: "image/vnd.dece.graphic",
|
4437
|
+
uvh: "video/vnd.dece.hd",
|
4438
|
+
uvm: "video/vnd.dece.mobile",
|
4439
|
+
uvu: "video/vnd.uvvu.mp4",
|
4440
|
+
uvp: "video/vnd.dece.pd",
|
4441
|
+
uvs: "video/vnd.dece.sd",
|
4442
|
+
uvv: "video/vnd.dece.video",
|
4443
|
+
dvi: "application/x-dvi",
|
4444
|
+
seed: "application/vnd.fdsn.seed",
|
4445
|
+
dtb: "application/x-dtbook+xml",
|
4446
|
+
res: "application/x-dtbresource+xml",
|
4447
|
+
ait: "application/vnd.dvb.ait",
|
4448
|
+
svc: "application/vnd.dvb.service",
|
4449
|
+
eol: "audio/vnd.digital-winds",
|
4450
|
+
djvu: "image/vnd.djvu",
|
4451
|
+
dtd: "application/xml-dtd",
|
4452
|
+
mlp: "application/vnd.dolby.mlp",
|
4453
|
+
wad: "application/x-doom",
|
4454
|
+
dpg: "application/vnd.dpgraph",
|
4455
|
+
dra: "audio/vnd.dra",
|
4456
|
+
dfac: "application/vnd.dreamfactory",
|
4457
|
+
dts: "audio/vnd.dts",
|
4458
|
+
dtshd: "audio/vnd.dts.hd",
|
4459
|
+
dwg: "image/vnd.dwg",
|
4460
|
+
geo: "application/vnd.dynageo",
|
4461
|
+
es: "application/ecmascript",
|
4462
|
+
mag: "application/vnd.ecowin.chart",
|
4463
|
+
mmr: "image/vnd.fujixerox.edmics-mmr",
|
4464
|
+
rlc: "image/vnd.fujixerox.edmics-rlc",
|
4465
|
+
exi: "application/exi",
|
4466
|
+
mgz: "application/vnd.proteus.magazine",
|
4467
|
+
epub: "application/epub+zip",
|
4468
|
+
eml: "message/rfc822",
|
4469
|
+
nml: "application/vnd.enliven",
|
4470
|
+
xpr: "application/vnd.is-xpr",
|
4471
|
+
xif: "image/vnd.xiff",
|
4472
|
+
xfdl: "application/vnd.xfdl",
|
4473
|
+
emma: "application/emma+xml",
|
4474
|
+
ez2: "application/vnd.ezpix-album",
|
4475
|
+
ez3: "application/vnd.ezpix-package",
|
4476
|
+
fst: "image/vnd.fst",
|
4477
|
+
fvt: "video/vnd.fvt",
|
4478
|
+
fbs: "image/vnd.fastbidsheet",
|
4479
|
+
fe_launch: "application/vnd.denovo.fcselayout-link",
|
4480
|
+
f4v: "video/x-f4v",
|
4481
|
+
flv: "video/x-flv",
|
4482
|
+
fpx: "image/vnd.fpx",
|
4483
|
+
npx: "image/vnd.net-fpx",
|
4484
|
+
flx: "text/vnd.fmi.flexstor",
|
4485
|
+
fli: "video/x-fli",
|
4486
|
+
ftc: "application/vnd.fluxtime.clip",
|
4487
|
+
fdf: "application/vnd.fdf",
|
4488
|
+
f: "text/x-fortran",
|
4489
|
+
mif: "application/vnd.mif",
|
4490
|
+
fm: "application/vnd.framemaker",
|
4491
|
+
fh: "image/x-freehand",
|
4492
|
+
fsc: "application/vnd.fsc.weblaunch",
|
4493
|
+
fnc: "application/vnd.frogans.fnc",
|
4494
|
+
ltf: "application/vnd.frogans.ltf",
|
4495
|
+
ddd: "application/vnd.fujixerox.ddd",
|
4496
|
+
xdw: "application/vnd.fujixerox.docuworks",
|
4497
|
+
xbd: "application/vnd.fujixerox.docuworks.binder",
|
4498
|
+
oas: "application/vnd.fujitsu.oasys",
|
4499
|
+
oa2: "application/vnd.fujitsu.oasys2",
|
4500
|
+
oa3: "application/vnd.fujitsu.oasys3",
|
4501
|
+
fg5: "application/vnd.fujitsu.oasysgp",
|
4502
|
+
bh2: "application/vnd.fujitsu.oasysprs",
|
4503
|
+
spl: "application/x-futuresplash",
|
4504
|
+
fzs: "application/vnd.fuzzysheet",
|
4505
|
+
g3: "image/g3fax",
|
4506
|
+
gmx: "application/vnd.gmx",
|
4507
|
+
gtw: "model/vnd.gtw",
|
4508
|
+
txd: "application/vnd.genomatix.tuxedo",
|
4509
|
+
ggb: "application/vnd.geogebra.file",
|
4510
|
+
ggt: "application/vnd.geogebra.tool",
|
4511
|
+
gdl: "model/vnd.gdl",
|
4512
|
+
gex: "application/vnd.geometry-explorer",
|
4513
|
+
gxt: "application/vnd.geonext",
|
4514
|
+
g2w: "application/vnd.geoplan",
|
4515
|
+
g3w: "application/vnd.geospace",
|
4516
|
+
gsf: "application/x-font-ghostscript",
|
4517
|
+
bdf: "application/x-font-bdf",
|
4518
|
+
gtar: "application/x-gtar",
|
4519
|
+
texinfo: "application/x-texinfo",
|
4520
|
+
gnumeric: "application/x-gnumeric",
|
4521
|
+
kml: "application/vnd.google-earth.kml+xml",
|
4522
|
+
kmz: "application/vnd.google-earth.kmz",
|
4523
|
+
gqf: "application/vnd.grafeq",
|
4524
|
+
gif: "image/gif",
|
4525
|
+
gv: "text/vnd.graphviz",
|
4526
|
+
gac: "application/vnd.groove-account",
|
4527
|
+
ghf: "application/vnd.groove-help",
|
4528
|
+
gim: "application/vnd.groove-identity-message",
|
4529
|
+
grv: "application/vnd.groove-injector",
|
4530
|
+
gtm: "application/vnd.groove-tool-message",
|
4531
|
+
tpl: "application/vnd.groove-tool-template",
|
4532
|
+
vcg: "application/vnd.groove-vcard",
|
4533
|
+
h261: "video/h261",
|
4534
|
+
h263: "video/h263",
|
4535
|
+
h264: "video/h264",
|
4536
|
+
hpid: "application/vnd.hp-hpid",
|
4537
|
+
hps: "application/vnd.hp-hps",
|
4538
|
+
hdf: "application/x-hdf",
|
4539
|
+
rip: "audio/vnd.rip",
|
4540
|
+
hbci: "application/vnd.hbci",
|
4541
|
+
jlt: "application/vnd.hp-jlyt",
|
4542
|
+
pcl: "application/vnd.hp-pcl",
|
4543
|
+
hpgl: "application/vnd.hp-hpgl",
|
4544
|
+
hvs: "application/vnd.yamaha.hv-script",
|
4545
|
+
hvd: "application/vnd.yamaha.hv-dic",
|
4546
|
+
hvp: "application/vnd.yamaha.hv-voice",
|
4547
|
+
"sfd-hdstx": "application/vnd.hydrostatix.sof-data",
|
4548
|
+
stk: "application/hyperstudio",
|
4549
|
+
hal: "application/vnd.hal+xml",
|
4550
|
+
html: "text/html",
|
4551
|
+
irm: "application/vnd.ibm.rights-management",
|
4552
|
+
sc: "application/vnd.ibm.secure-container",
|
4553
|
+
ics: "text/calendar",
|
4554
|
+
icc: "application/vnd.iccprofile",
|
4555
|
+
ico: "image/x-icon",
|
4556
|
+
igl: "application/vnd.igloader",
|
4557
|
+
ief: "image/ief",
|
4558
|
+
ivp: "application/vnd.immervision-ivp",
|
4559
|
+
ivu: "application/vnd.immervision-ivu",
|
4560
|
+
rif: "application/reginfo+xml",
|
4561
|
+
"3dml": "text/vnd.in3d.3dml",
|
4562
|
+
spot: "text/vnd.in3d.spot",
|
4563
|
+
igs: "model/iges",
|
4564
|
+
i2g: "application/vnd.intergeo",
|
4565
|
+
cdy: "application/vnd.cinderella",
|
4566
|
+
xpw: "application/vnd.intercon.formnet",
|
4567
|
+
fcs: "application/vnd.isac.fcs",
|
4568
|
+
ipfix: "application/ipfix",
|
4569
|
+
cer: "application/pkix-cert",
|
4570
|
+
pki: "application/pkixcmp",
|
4571
|
+
crl: "application/pkix-crl",
|
4572
|
+
pkipath: "application/pkix-pkipath",
|
4573
|
+
igm: "application/vnd.insors.igm",
|
4574
|
+
rcprofile: "application/vnd.ipunplugged.rcprofile",
|
4575
|
+
irp: "application/vnd.irepository.package+xml",
|
4576
|
+
jad: "text/vnd.sun.j2me.app-descriptor",
|
4577
|
+
jar: "application/java-archive",
|
4578
|
+
"class": "application/java-vm",
|
4579
|
+
jnlp: "application/x-java-jnlp-file",
|
4580
|
+
ser: "application/java-serialized-object",
|
4581
|
+
java: "text/x-java-source,java",
|
4582
|
+
js: "application/javascript",
|
4583
|
+
json: "application/json",
|
4584
|
+
joda: "application/vnd.joost.joda-archive",
|
4585
|
+
jpm: "video/jpm",
|
4586
|
+
jpeg: "image/jpeg",
|
4587
|
+
jpg: "image/jpeg",
|
4588
|
+
pjpeg: "image/pjpeg",
|
4589
|
+
jpgv: "video/jpeg",
|
4590
|
+
ktz: "application/vnd.kahootz",
|
4591
|
+
mmd: "application/vnd.chipnuts.karaoke-mmd",
|
4592
|
+
karbon: "application/vnd.kde.karbon",
|
4593
|
+
chrt: "application/vnd.kde.kchart",
|
4594
|
+
kfo: "application/vnd.kde.kformula",
|
4595
|
+
flw: "application/vnd.kde.kivio",
|
4596
|
+
kon: "application/vnd.kde.kontour",
|
4597
|
+
kpr: "application/vnd.kde.kpresenter",
|
4598
|
+
ksp: "application/vnd.kde.kspread",
|
4599
|
+
kwd: "application/vnd.kde.kword",
|
4600
|
+
htke: "application/vnd.kenameaapp",
|
4601
|
+
kia: "application/vnd.kidspiration",
|
4602
|
+
kne: "application/vnd.kinar",
|
4603
|
+
sse: "application/vnd.kodak-descriptor",
|
4604
|
+
lasxml: "application/vnd.las.las+xml",
|
4605
|
+
latex: "application/x-latex",
|
4606
|
+
lbd: "application/vnd.llamagraphics.life-balance.desktop",
|
4607
|
+
lbe: "application/vnd.llamagraphics.life-balance.exchange+xml",
|
4608
|
+
jam: "application/vnd.jam",
|
4609
|
+
"123": "application/vnd.lotus-1-2-3",
|
4610
|
+
apr: "application/vnd.lotus-approach",
|
4611
|
+
pre: "application/vnd.lotus-freelance",
|
4612
|
+
nsf: "application/vnd.lotus-notes",
|
4613
|
+
org: "application/vnd.lotus-organizer",
|
4614
|
+
scm: "application/vnd.lotus-screencam",
|
4615
|
+
lwp: "application/vnd.lotus-wordpro",
|
4616
|
+
lvp: "audio/vnd.lucent.voice",
|
4617
|
+
m3u: "audio/x-mpegurl",
|
4618
|
+
m4v: "video/x-m4v",
|
4619
|
+
hqx: "application/mac-binhex40",
|
4620
|
+
portpkg: "application/vnd.macports.portpkg",
|
4621
|
+
mgp: "application/vnd.osgeo.mapguide.package",
|
4622
|
+
mrc: "application/marc",
|
4623
|
+
mrcx: "application/marcxml+xml",
|
4624
|
+
mxf: "application/mxf",
|
4625
|
+
nbp: "application/vnd.wolfram.player",
|
4626
|
+
ma: "application/mathematica",
|
4627
|
+
mathml: "application/mathml+xml",
|
4628
|
+
mbox: "application/mbox",
|
4629
|
+
mc1: "application/vnd.medcalcdata",
|
4630
|
+
mscml: "application/mediaservercontrol+xml",
|
4631
|
+
cdkey: "application/vnd.mediastation.cdkey",
|
4632
|
+
mwf: "application/vnd.mfer",
|
4633
|
+
mfm: "application/vnd.mfmp",
|
4634
|
+
msh: "model/mesh",
|
4635
|
+
mads: "application/mads+xml",
|
4636
|
+
mets: "application/mets+xml",
|
4637
|
+
mods: "application/mods+xml",
|
4638
|
+
meta4: "application/metalink4+xml",
|
4639
|
+
mcd: "application/vnd.mcd",
|
4640
|
+
flo: "application/vnd.micrografx.flo",
|
4641
|
+
igx: "application/vnd.micrografx.igx",
|
4642
|
+
es3: "application/vnd.eszigno3+xml",
|
4643
|
+
mdb: "application/x-msaccess",
|
4644
|
+
asf: "video/x-ms-asf",
|
4645
|
+
exe: "application/x-msdownload",
|
4646
|
+
cil: "application/vnd.ms-artgalry",
|
4647
|
+
cab: "application/vnd.ms-cab-compressed",
|
4648
|
+
ims: "application/vnd.ms-ims",
|
4649
|
+
application: "application/x-ms-application",
|
4650
|
+
clp: "application/x-msclip",
|
4651
|
+
mdi: "image/vnd.ms-modi",
|
4652
|
+
eot: "application/vnd.ms-fontobject",
|
4653
|
+
xls: "application/vnd.ms-excel",
|
4654
|
+
xlam: "application/vnd.ms-excel.addin.macroenabled.12",
|
4655
|
+
xlsb: "application/vnd.ms-excel.sheet.binary.macroenabled.12",
|
4656
|
+
xltm: "application/vnd.ms-excel.template.macroenabled.12",
|
4657
|
+
xlsm: "application/vnd.ms-excel.sheet.macroenabled.12",
|
4658
|
+
chm: "application/vnd.ms-htmlhelp",
|
4659
|
+
crd: "application/x-mscardfile",
|
4660
|
+
lrm: "application/vnd.ms-lrm",
|
4661
|
+
mvb: "application/x-msmediaview",
|
4662
|
+
mny: "application/x-msmoney",
|
4663
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
4664
|
+
sldx: "application/vnd.openxmlformats-officedocument.presentationml.slide",
|
4665
|
+
ppsx: "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
4666
|
+
potx: "application/vnd.openxmlformats-officedocument.presentationml.template",
|
4667
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
4668
|
+
xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
4669
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
4670
|
+
dotx: "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
4671
|
+
obd: "application/x-msbinder",
|
4672
|
+
thmx: "application/vnd.ms-officetheme",
|
4673
|
+
onetoc: "application/onenote",
|
4674
|
+
pya: "audio/vnd.ms-playready.media.pya",
|
4675
|
+
pyv: "video/vnd.ms-playready.media.pyv",
|
4676
|
+
ppt: "application/vnd.ms-powerpoint",
|
4677
|
+
ppam: "application/vnd.ms-powerpoint.addin.macroenabled.12",
|
4678
|
+
sldm: "application/vnd.ms-powerpoint.slide.macroenabled.12",
|
4679
|
+
pptm: "application/vnd.ms-powerpoint.presentation.macroenabled.12",
|
4680
|
+
ppsm: "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
|
4681
|
+
potm: "application/vnd.ms-powerpoint.template.macroenabled.12",
|
4682
|
+
mpp: "application/vnd.ms-project",
|
4683
|
+
pub: "application/x-mspublisher",
|
4684
|
+
scd: "application/x-msschedule",
|
4685
|
+
xap: "application/x-silverlight-app",
|
4686
|
+
stl: "application/vnd.ms-pki.stl",
|
4687
|
+
cat: "application/vnd.ms-pki.seccat",
|
4688
|
+
vsd: "application/vnd.visio",
|
4689
|
+
vsdx: "application/vnd.visio2013",
|
4690
|
+
wm: "video/x-ms-wm",
|
4691
|
+
wma: "audio/x-ms-wma",
|
4692
|
+
wax: "audio/x-ms-wax",
|
4693
|
+
wmx: "video/x-ms-wmx",
|
4694
|
+
wmd: "application/x-ms-wmd",
|
4695
|
+
wpl: "application/vnd.ms-wpl",
|
4696
|
+
wmz: "application/x-ms-wmz",
|
4697
|
+
wmv: "video/x-ms-wmv",
|
4698
|
+
wvx: "video/x-ms-wvx",
|
4699
|
+
wmf: "application/x-msmetafile",
|
4700
|
+
trm: "application/x-msterminal",
|
4701
|
+
doc: "application/msword",
|
4702
|
+
docm: "application/vnd.ms-word.document.macroenabled.12",
|
4703
|
+
dotm: "application/vnd.ms-word.template.macroenabled.12",
|
4704
|
+
wri: "application/x-mswrite",
|
4705
|
+
wps: "application/vnd.ms-works",
|
4706
|
+
xbap: "application/x-ms-xbap",
|
4707
|
+
xps: "application/vnd.ms-xpsdocument",
|
4708
|
+
mid: "audio/midi",
|
4709
|
+
mpy: "application/vnd.ibm.minipay",
|
4710
|
+
afp: "application/vnd.ibm.modcap",
|
4711
|
+
rms: "application/vnd.jcp.javame.midlet-rms",
|
4712
|
+
tmo: "application/vnd.tmobile-livetv",
|
4713
|
+
prc: "application/x-mobipocket-ebook",
|
4714
|
+
mbk: "application/vnd.mobius.mbk",
|
4715
|
+
dis: "application/vnd.mobius.dis",
|
4716
|
+
plc: "application/vnd.mobius.plc",
|
4717
|
+
mqy: "application/vnd.mobius.mqy",
|
4718
|
+
msl: "application/vnd.mobius.msl",
|
4719
|
+
txf: "application/vnd.mobius.txf",
|
4720
|
+
daf: "application/vnd.mobius.daf",
|
4721
|
+
fly: "text/vnd.fly",
|
4722
|
+
mpc: "application/vnd.mophun.certificate",
|
4723
|
+
mpn: "application/vnd.mophun.application",
|
4724
|
+
mj2: "video/mj2",
|
4725
|
+
mpga: "audio/mpeg",
|
4726
|
+
mxu: "video/vnd.mpegurl",
|
4727
|
+
mpeg: "video/mpeg",
|
4728
|
+
m21: "application/mp21",
|
4729
|
+
mp4a: "audio/mp4",
|
4730
|
+
mp4: "video/mp4",
|
4731
|
+
m3u8: "application/vnd.apple.mpegurl",
|
4732
|
+
mus: "application/vnd.musician",
|
4733
|
+
msty: "application/vnd.muvee.style",
|
4734
|
+
mxml: "application/xv+xml",
|
4735
|
+
ngdat: "application/vnd.nokia.n-gage.data",
|
4736
|
+
"n-gage": "application/vnd.nokia.n-gage.symbian.install",
|
4737
|
+
ncx: "application/x-dtbncx+xml",
|
4738
|
+
nc: "application/x-netcdf",
|
4739
|
+
nlu: "application/vnd.neurolanguage.nlu",
|
4740
|
+
dna: "application/vnd.dna",
|
4741
|
+
nnd: "application/vnd.noblenet-directory",
|
4742
|
+
nns: "application/vnd.noblenet-sealer",
|
4743
|
+
nnw: "application/vnd.noblenet-web",
|
4744
|
+
rpst: "application/vnd.nokia.radio-preset",
|
4745
|
+
rpss: "application/vnd.nokia.radio-presets",
|
4746
|
+
n3: "text/n3",
|
4747
|
+
edm: "application/vnd.novadigm.edm",
|
4748
|
+
edx: "application/vnd.novadigm.edx",
|
4749
|
+
ext: "application/vnd.novadigm.ext",
|
4750
|
+
gph: "application/vnd.flographit",
|
4751
|
+
ecelp4800: "audio/vnd.nuera.ecelp4800",
|
4752
|
+
ecelp7470: "audio/vnd.nuera.ecelp7470",
|
4753
|
+
ecelp9600: "audio/vnd.nuera.ecelp9600",
|
4754
|
+
oda: "application/oda",
|
4755
|
+
ogx: "application/ogg",
|
4756
|
+
oga: "audio/ogg",
|
4757
|
+
ogv: "video/ogg",
|
4758
|
+
dd2: "application/vnd.oma.dd2+xml",
|
4759
|
+
oth: "application/vnd.oasis.opendocument.text-web",
|
4760
|
+
opf: "application/oebps-package+xml",
|
4761
|
+
qbo: "application/vnd.intu.qbo",
|
4762
|
+
oxt: "application/vnd.openofficeorg.extension",
|
4763
|
+
osf: "application/vnd.yamaha.openscoreformat",
|
4764
|
+
weba: "audio/webm",
|
4765
|
+
webm: "video/webm",
|
4766
|
+
odc: "application/vnd.oasis.opendocument.chart",
|
4767
|
+
otc: "application/vnd.oasis.opendocument.chart-template",
|
4768
|
+
odb: "application/vnd.oasis.opendocument.database",
|
4769
|
+
odf: "application/vnd.oasis.opendocument.formula",
|
4770
|
+
odft: "application/vnd.oasis.opendocument.formula-template",
|
4771
|
+
odg: "application/vnd.oasis.opendocument.graphics",
|
4772
|
+
otg: "application/vnd.oasis.opendocument.graphics-template",
|
4773
|
+
odi: "application/vnd.oasis.opendocument.image",
|
4774
|
+
oti: "application/vnd.oasis.opendocument.image-template",
|
4775
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
4776
|
+
otp: "application/vnd.oasis.opendocument.presentation-template",
|
4777
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
4778
|
+
ots: "application/vnd.oasis.opendocument.spreadsheet-template",
|
4779
|
+
odt: "application/vnd.oasis.opendocument.text",
|
4780
|
+
odm: "application/vnd.oasis.opendocument.text-master",
|
4781
|
+
ott: "application/vnd.oasis.opendocument.text-template",
|
4782
|
+
ktx: "image/ktx",
|
4783
|
+
sxc: "application/vnd.sun.xml.calc",
|
4784
|
+
stc: "application/vnd.sun.xml.calc.template",
|
4785
|
+
sxd: "application/vnd.sun.xml.draw",
|
4786
|
+
std: "application/vnd.sun.xml.draw.template",
|
4787
|
+
sxi: "application/vnd.sun.xml.impress",
|
4788
|
+
sti: "application/vnd.sun.xml.impress.template",
|
4789
|
+
sxm: "application/vnd.sun.xml.math",
|
4790
|
+
sxw: "application/vnd.sun.xml.writer",
|
4791
|
+
sxg: "application/vnd.sun.xml.writer.global",
|
4792
|
+
stw: "application/vnd.sun.xml.writer.template",
|
4793
|
+
otf: "application/x-font-otf",
|
4794
|
+
osfpvg: "application/vnd.yamaha.openscoreformat.osfpvg+xml",
|
4795
|
+
dp: "application/vnd.osgi.dp",
|
4796
|
+
pdb: "application/vnd.palm",
|
4797
|
+
p: "text/x-pascal",
|
4798
|
+
paw: "application/vnd.pawaafile",
|
4799
|
+
pclxl: "application/vnd.hp-pclxl",
|
4800
|
+
efif: "application/vnd.picsel",
|
4801
|
+
pcx: "image/x-pcx",
|
4802
|
+
psd: "image/vnd.adobe.photoshop",
|
4803
|
+
prf: "application/pics-rules",
|
4804
|
+
pic: "image/x-pict",
|
4805
|
+
chat: "application/x-chat",
|
4806
|
+
p10: "application/pkcs10",
|
4807
|
+
p12: "application/x-pkcs12",
|
4808
|
+
p7m: "application/pkcs7-mime",
|
4809
|
+
p7s: "application/pkcs7-signature",
|
4810
|
+
p7r: "application/x-pkcs7-certreqresp",
|
4811
|
+
p7b: "application/x-pkcs7-certificates",
|
4812
|
+
p8: "application/pkcs8",
|
4813
|
+
plf: "application/vnd.pocketlearn",
|
4814
|
+
pnm: "image/x-portable-anymap",
|
4815
|
+
pbm: "image/x-portable-bitmap",
|
4816
|
+
pcf: "application/x-font-pcf",
|
4817
|
+
pfr: "application/font-tdpfr",
|
4818
|
+
pgn: "application/x-chess-pgn",
|
4819
|
+
pgm: "image/x-portable-graymap",
|
4820
|
+
png: "image/png",
|
4821
|
+
ppm: "image/x-portable-pixmap",
|
4822
|
+
pskcxml: "application/pskc+xml",
|
4823
|
+
pml: "application/vnd.ctc-posml",
|
4824
|
+
ai: "application/postscript",
|
4825
|
+
pfa: "application/x-font-type1",
|
4826
|
+
pbd: "application/vnd.powerbuilder6",
|
4827
|
+
pgp: "application/pgp-signature",
|
4828
|
+
box: "application/vnd.previewsystems.box",
|
4829
|
+
ptid: "application/vnd.pvi.ptid1",
|
4830
|
+
pls: "application/pls+xml",
|
4831
|
+
str: "application/vnd.pg.format",
|
4832
|
+
ei6: "application/vnd.pg.osasli",
|
4833
|
+
dsc: "text/prs.lines.tag",
|
4834
|
+
psf: "application/x-font-linux-psf",
|
4835
|
+
qps: "application/vnd.publishare-delta-tree",
|
4836
|
+
wg: "application/vnd.pmi.widget",
|
4837
|
+
qxd: "application/vnd.quark.quarkxpress",
|
4838
|
+
esf: "application/vnd.epson.esf",
|
4839
|
+
msf: "application/vnd.epson.msf",
|
4840
|
+
ssf: "application/vnd.epson.ssf",
|
4841
|
+
qam: "application/vnd.epson.quickanime",
|
4842
|
+
qfx: "application/vnd.intu.qfx",
|
4843
|
+
qt: "video/quicktime",
|
4844
|
+
rar: "application/x-rar-compressed",
|
4845
|
+
ram: "audio/x-pn-realaudio",
|
4846
|
+
rmp: "audio/x-pn-realaudio-plugin",
|
4847
|
+
rsd: "application/rsd+xml",
|
4848
|
+
rm: "application/vnd.rn-realmedia",
|
4849
|
+
bed: "application/vnd.realvnc.bed",
|
4850
|
+
mxl: "application/vnd.recordare.musicxml",
|
4851
|
+
musicxml: "application/vnd.recordare.musicxml+xml",
|
4852
|
+
rnc: "application/relax-ng-compact-syntax",
|
4853
|
+
rdz: "application/vnd.data-vision.rdz",
|
4854
|
+
rdf: "application/rdf+xml",
|
4855
|
+
rp9: "application/vnd.cloanto.rp9",
|
4856
|
+
jisp: "application/vnd.jisp",
|
4857
|
+
rtf: "application/rtf",
|
4858
|
+
rtx: "text/richtext",
|
4859
|
+
link66: "application/vnd.route66.link66+xml",
|
4860
|
+
rss: "application/rss+xml",
|
4861
|
+
shf: "application/shf+xml",
|
4862
|
+
st: "application/vnd.sailingtracker.track",
|
4863
|
+
svg: "image/svg+xml",
|
4864
|
+
sus: "application/vnd.sus-calendar",
|
4865
|
+
sru: "application/sru+xml",
|
4866
|
+
setpay: "application/set-payment-initiation",
|
4867
|
+
setreg: "application/set-registration-initiation",
|
4868
|
+
sema: "application/vnd.sema",
|
4869
|
+
semd: "application/vnd.semd",
|
4870
|
+
semf: "application/vnd.semf",
|
4871
|
+
see: "application/vnd.seemail",
|
4872
|
+
snf: "application/x-font-snf",
|
4873
|
+
spq: "application/scvp-vp-request",
|
4874
|
+
spp: "application/scvp-vp-response",
|
4875
|
+
scq: "application/scvp-cv-request",
|
4876
|
+
scs: "application/scvp-cv-response",
|
4877
|
+
sdp: "application/sdp",
|
4878
|
+
etx: "text/x-setext",
|
4879
|
+
movie: "video/x-sgi-movie",
|
4880
|
+
ifm: "application/vnd.shana.informed.formdata",
|
4881
|
+
itp: "application/vnd.shana.informed.formtemplate",
|
4882
|
+
iif: "application/vnd.shana.informed.interchange",
|
4883
|
+
ipk: "application/vnd.shana.informed.package",
|
4884
|
+
tfi: "application/thraud+xml",
|
4885
|
+
shar: "application/x-shar",
|
4886
|
+
rgb: "image/x-rgb",
|
4887
|
+
slt: "application/vnd.epson.salt",
|
4888
|
+
aso: "application/vnd.accpac.simply.aso",
|
4889
|
+
imp: "application/vnd.accpac.simply.imp",
|
4890
|
+
twd: "application/vnd.simtech-mindmapper",
|
4891
|
+
csp: "application/vnd.commonspace",
|
4892
|
+
saf: "application/vnd.yamaha.smaf-audio",
|
4893
|
+
mmf: "application/vnd.smaf",
|
4894
|
+
spf: "application/vnd.yamaha.smaf-phrase",
|
4895
|
+
teacher: "application/vnd.smart.teacher",
|
4896
|
+
svd: "application/vnd.svd",
|
4897
|
+
rq: "application/sparql-query",
|
4898
|
+
srx: "application/sparql-results+xml",
|
4899
|
+
gram: "application/srgs",
|
4900
|
+
grxml: "application/srgs+xml",
|
4901
|
+
ssml: "application/ssml+xml",
|
4902
|
+
skp: "application/vnd.koan",
|
4903
|
+
sgml: "text/sgml",
|
4904
|
+
sdc: "application/vnd.stardivision.calc",
|
4905
|
+
sda: "application/vnd.stardivision.draw",
|
4906
|
+
sdd: "application/vnd.stardivision.impress",
|
4907
|
+
smf: "application/vnd.stardivision.math",
|
4908
|
+
sdw: "application/vnd.stardivision.writer",
|
4909
|
+
sgl: "application/vnd.stardivision.writer-global",
|
4910
|
+
sm: "application/vnd.stepmania.stepchart",
|
4911
|
+
sit: "application/x-stuffit",
|
4912
|
+
sitx: "application/x-stuffitx",
|
4913
|
+
sdkm: "application/vnd.solent.sdkm+xml",
|
4914
|
+
xo: "application/vnd.olpc-sugar",
|
4915
|
+
au: "audio/basic",
|
4916
|
+
wqd: "application/vnd.wqd",
|
4917
|
+
sis: "application/vnd.symbian.install",
|
4918
|
+
smi: "application/smil+xml",
|
4919
|
+
xsm: "application/vnd.syncml+xml",
|
4920
|
+
bdm: "application/vnd.syncml.dm+wbxml",
|
4921
|
+
xdm: "application/vnd.syncml.dm+xml",
|
4922
|
+
sv4cpio: "application/x-sv4cpio",
|
4923
|
+
sv4crc: "application/x-sv4crc",
|
4924
|
+
sbml: "application/sbml+xml",
|
4925
|
+
tsv: "text/tab-separated-values",
|
4926
|
+
tiff: "image/tiff",
|
4927
|
+
tao: "application/vnd.tao.intent-module-archive",
|
4928
|
+
tar: "application/x-tar",
|
4929
|
+
tcl: "application/x-tcl",
|
4930
|
+
tex: "application/x-tex",
|
4931
|
+
tfm: "application/x-tex-tfm",
|
4932
|
+
tei: "application/tei+xml",
|
4933
|
+
txt: "text/plain",
|
4934
|
+
dxp: "application/vnd.spotfire.dxp",
|
4935
|
+
sfs: "application/vnd.spotfire.sfs",
|
4936
|
+
tsd: "application/timestamped-data",
|
4937
|
+
tpt: "application/vnd.trid.tpt",
|
4938
|
+
mxs: "application/vnd.triscape.mxs",
|
4939
|
+
t: "text/troff",
|
4940
|
+
tra: "application/vnd.trueapp",
|
4941
|
+
ttf: "application/x-font-ttf",
|
4942
|
+
ttl: "text/turtle",
|
4943
|
+
umj: "application/vnd.umajin",
|
4944
|
+
uoml: "application/vnd.uoml+xml",
|
4945
|
+
unityweb: "application/vnd.unity",
|
4946
|
+
ufd: "application/vnd.ufdl",
|
4947
|
+
uri: "text/uri-list",
|
4948
|
+
utz: "application/vnd.uiq.theme",
|
4949
|
+
ustar: "application/x-ustar",
|
4950
|
+
uu: "text/x-uuencode",
|
4951
|
+
vcs: "text/x-vcalendar",
|
4952
|
+
vcf: "text/x-vcard",
|
4953
|
+
vcd: "application/x-cdlink",
|
4954
|
+
vsf: "application/vnd.vsf",
|
4955
|
+
wrl: "model/vrml",
|
4956
|
+
vcx: "application/vnd.vcx",
|
4957
|
+
mts: "model/vnd.mts",
|
4958
|
+
vtu: "model/vnd.vtu",
|
4959
|
+
vis: "application/vnd.visionary",
|
4960
|
+
viv: "video/vnd.vivo",
|
4961
|
+
ccxml: "application/ccxml+xml,",
|
4962
|
+
vxml: "application/voicexml+xml",
|
4963
|
+
src: "application/x-wais-source",
|
4964
|
+
wbxml: "application/vnd.wap.wbxml",
|
4965
|
+
wbmp: "image/vnd.wap.wbmp",
|
4966
|
+
wav: "audio/x-wav",
|
4967
|
+
davmount: "application/davmount+xml",
|
4968
|
+
woff: "application/x-font-woff",
|
4969
|
+
wspolicy: "application/wspolicy+xml",
|
4970
|
+
webp: "image/webp",
|
4971
|
+
wtb: "application/vnd.webturbo",
|
4972
|
+
wgt: "application/widget",
|
4973
|
+
hlp: "application/winhlp",
|
4974
|
+
wml: "text/vnd.wap.wml",
|
4975
|
+
wmls: "text/vnd.wap.wmlscript",
|
4976
|
+
wmlsc: "application/vnd.wap.wmlscriptc",
|
4977
|
+
wpd: "application/vnd.wordperfect",
|
4978
|
+
stf: "application/vnd.wt.stf",
|
4979
|
+
wsdl: "application/wsdl+xml",
|
4980
|
+
xbm: "image/x-xbitmap",
|
4981
|
+
xpm: "image/x-xpixmap",
|
4982
|
+
xwd: "image/x-xwindowdump",
|
4983
|
+
der: "application/x-x509-ca-cert",
|
4984
|
+
fig: "application/x-xfig",
|
4985
|
+
xhtml: "application/xhtml+xml",
|
4986
|
+
xml: "application/xml",
|
4987
|
+
xdf: "application/xcap-diff+xml",
|
4988
|
+
xenc: "application/xenc+xml",
|
4989
|
+
xer: "application/patch-ops-error+xml",
|
4990
|
+
rl: "application/resource-lists+xml",
|
4991
|
+
rs: "application/rls-services+xml",
|
4992
|
+
rld: "application/resource-lists-diff+xml",
|
4993
|
+
xslt: "application/xslt+xml",
|
4994
|
+
xop: "application/xop+xml",
|
4995
|
+
xpi: "application/x-xpinstall",
|
4996
|
+
xspf: "application/xspf+xml",
|
4997
|
+
xul: "application/vnd.mozilla.xul+xml",
|
4998
|
+
xyz: "chemical/x-xyz",
|
4999
|
+
yaml: "text/yaml",
|
5000
|
+
yang: "application/yang",
|
5001
|
+
yin: "application/yin+xml",
|
5002
|
+
zir: "application/vnd.zul",
|
5003
|
+
zip: "application/zip",
|
5004
|
+
zmm: "application/vnd.handheld-entertainment+xml",
|
5005
|
+
zaz: "application/vnd.zzazz.deck+xml"
|
5006
|
+
};
|
5007
|
+
|
5008
|
+
// TODO: write this out to avoid compute
|
5009
|
+
var MIME_TYPES_TO_EXT = Object.fromEntries(Object.entries(EXT_TO_MIME_TYPES).map(function (_ref) {
|
5010
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
5011
|
+
k = _ref2[0],
|
5012
|
+
v = _ref2[1];
|
5013
|
+
return [v, k];
|
5014
|
+
}));
|
5015
|
+
|
5016
|
+
var MIME_TYPE_REGEX = /^data:(.*?);base64,/;
|
5017
|
+
function getMimeType(base64Url) {
|
5018
|
+
var match = MIME_TYPE_REGEX.exec(base64Url);
|
5019
|
+
if (match && match[1]) {
|
5020
|
+
return match[1];
|
5021
|
+
}
|
5022
|
+
return;
|
5023
|
+
}
|
5024
|
+
function mimeTypeToFileExt(mimeType) {
|
5025
|
+
var recognizedMimeType = MIME_TYPES_TO_EXT[mimeType];
|
5026
|
+
if (recognizedMimeType) {
|
5027
|
+
return recognizedMimeType;
|
5028
|
+
}
|
5029
|
+
return mimeType.split("/")[1];
|
5030
|
+
}
|
5031
|
+
function filenameToMimeType(filename) {
|
5032
|
+
var ext = filename.split(".").pop();
|
5033
|
+
var recognizedExt = ext && EXT_TO_MIME_TYPES[ext];
|
5034
|
+
if (recognizedExt) {
|
5035
|
+
return recognizedExt;
|
5036
|
+
}
|
5037
|
+
}
|
5038
|
+
|
3510
5039
|
function deserializeSchema(serialized) {
|
3511
5040
|
var _serialized$options;
|
3512
5041
|
switch (serialized.type) {
|
@@ -3530,9 +5059,16 @@ function deserializeSchema(serialized) {
|
|
3530
5059
|
case "array":
|
3531
5060
|
return new ArraySchema(deserializeSchema(serialized.item), serialized.opt);
|
3532
5061
|
case "union":
|
3533
|
-
return new UnionSchema(typeof serialized.key === "string" ? serialized.key :
|
5062
|
+
return new UnionSchema(typeof serialized.key === "string" ? serialized.key :
|
5063
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5064
|
+
deserializeSchema(serialized.key),
|
5065
|
+
// TODO: we do not really need any here - right?
|
5066
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5067
|
+
serialized.items.map(deserializeSchema),
|
5068
|
+
// TODO: we do not really need any here - right?
|
5069
|
+
serialized.opt);
|
3534
5070
|
case "richtext":
|
3535
|
-
return new RichTextSchema(serialized.options, serialized.opt);
|
5071
|
+
return new RichTextSchema(serialized.options || {}, serialized.opt);
|
3536
5072
|
case "record":
|
3537
5073
|
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt);
|
3538
5074
|
case "keyOf":
|
@@ -3541,6 +5077,8 @@ function deserializeSchema(serialized) {
|
|
3541
5077
|
return new FileSchema(serialized.options, serialized.opt);
|
3542
5078
|
case "image":
|
3543
5079
|
return new ImageSchema(serialized.options, serialized.opt);
|
5080
|
+
case "date":
|
5081
|
+
return new DateSchema(serialized.options);
|
3544
5082
|
default:
|
3545
5083
|
{
|
3546
5084
|
var exhaustiveCheck = serialized;
|
@@ -3554,671 +5092,6 @@ function deserializeSchema(serialized) {
|
|
3554
5092
|
}
|
3555
5093
|
}
|
3556
5094
|
|
3557
|
-
function _regeneratorRuntime() {
|
3558
|
-
_regeneratorRuntime = function () {
|
3559
|
-
return e;
|
3560
|
-
};
|
3561
|
-
var t,
|
3562
|
-
e = {},
|
3563
|
-
r = Object.prototype,
|
3564
|
-
n = r.hasOwnProperty,
|
3565
|
-
o = Object.defineProperty || function (t, e, r) {
|
3566
|
-
t[e] = r.value;
|
3567
|
-
},
|
3568
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
3569
|
-
a = i.iterator || "@@iterator",
|
3570
|
-
c = i.asyncIterator || "@@asyncIterator",
|
3571
|
-
u = i.toStringTag || "@@toStringTag";
|
3572
|
-
function define(t, e, r) {
|
3573
|
-
return Object.defineProperty(t, e, {
|
3574
|
-
value: r,
|
3575
|
-
enumerable: !0,
|
3576
|
-
configurable: !0,
|
3577
|
-
writable: !0
|
3578
|
-
}), t[e];
|
3579
|
-
}
|
3580
|
-
try {
|
3581
|
-
define({}, "");
|
3582
|
-
} catch (t) {
|
3583
|
-
define = function (t, e, r) {
|
3584
|
-
return t[e] = r;
|
3585
|
-
};
|
3586
|
-
}
|
3587
|
-
function wrap(t, e, r, n) {
|
3588
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
3589
|
-
a = Object.create(i.prototype),
|
3590
|
-
c = new Context(n || []);
|
3591
|
-
return o(a, "_invoke", {
|
3592
|
-
value: makeInvokeMethod(t, r, c)
|
3593
|
-
}), a;
|
3594
|
-
}
|
3595
|
-
function tryCatch(t, e, r) {
|
3596
|
-
try {
|
3597
|
-
return {
|
3598
|
-
type: "normal",
|
3599
|
-
arg: t.call(e, r)
|
3600
|
-
};
|
3601
|
-
} catch (t) {
|
3602
|
-
return {
|
3603
|
-
type: "throw",
|
3604
|
-
arg: t
|
3605
|
-
};
|
3606
|
-
}
|
3607
|
-
}
|
3608
|
-
e.wrap = wrap;
|
3609
|
-
var h = "suspendedStart",
|
3610
|
-
l = "suspendedYield",
|
3611
|
-
f = "executing",
|
3612
|
-
s = "completed",
|
3613
|
-
y = {};
|
3614
|
-
function Generator() {}
|
3615
|
-
function GeneratorFunction() {}
|
3616
|
-
function GeneratorFunctionPrototype() {}
|
3617
|
-
var p = {};
|
3618
|
-
define(p, a, function () {
|
3619
|
-
return this;
|
3620
|
-
});
|
3621
|
-
var d = Object.getPrototypeOf,
|
3622
|
-
v = d && d(d(values([])));
|
3623
|
-
v && v !== r && n.call(v, a) && (p = v);
|
3624
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
3625
|
-
function defineIteratorMethods(t) {
|
3626
|
-
["next", "throw", "return"].forEach(function (e) {
|
3627
|
-
define(t, e, function (t) {
|
3628
|
-
return this._invoke(e, t);
|
3629
|
-
});
|
3630
|
-
});
|
3631
|
-
}
|
3632
|
-
function AsyncIterator(t, e) {
|
3633
|
-
function invoke(r, o, i, a) {
|
3634
|
-
var c = tryCatch(t[r], t, o);
|
3635
|
-
if ("throw" !== c.type) {
|
3636
|
-
var u = c.arg,
|
3637
|
-
h = u.value;
|
3638
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
3639
|
-
invoke("next", t, i, a);
|
3640
|
-
}, function (t) {
|
3641
|
-
invoke("throw", t, i, a);
|
3642
|
-
}) : e.resolve(h).then(function (t) {
|
3643
|
-
u.value = t, i(u);
|
3644
|
-
}, function (t) {
|
3645
|
-
return invoke("throw", t, i, a);
|
3646
|
-
});
|
3647
|
-
}
|
3648
|
-
a(c.arg);
|
3649
|
-
}
|
3650
|
-
var r;
|
3651
|
-
o(this, "_invoke", {
|
3652
|
-
value: function (t, n) {
|
3653
|
-
function callInvokeWithMethodAndArg() {
|
3654
|
-
return new e(function (e, r) {
|
3655
|
-
invoke(t, n, e, r);
|
3656
|
-
});
|
3657
|
-
}
|
3658
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
3659
|
-
}
|
3660
|
-
});
|
3661
|
-
}
|
3662
|
-
function makeInvokeMethod(e, r, n) {
|
3663
|
-
var o = h;
|
3664
|
-
return function (i, a) {
|
3665
|
-
if (o === f) throw new Error("Generator is already running");
|
3666
|
-
if (o === s) {
|
3667
|
-
if ("throw" === i) throw a;
|
3668
|
-
return {
|
3669
|
-
value: t,
|
3670
|
-
done: !0
|
3671
|
-
};
|
3672
|
-
}
|
3673
|
-
for (n.method = i, n.arg = a;;) {
|
3674
|
-
var c = n.delegate;
|
3675
|
-
if (c) {
|
3676
|
-
var u = maybeInvokeDelegate(c, n);
|
3677
|
-
if (u) {
|
3678
|
-
if (u === y) continue;
|
3679
|
-
return u;
|
3680
|
-
}
|
3681
|
-
}
|
3682
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
3683
|
-
if (o === h) throw o = s, n.arg;
|
3684
|
-
n.dispatchException(n.arg);
|
3685
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
3686
|
-
o = f;
|
3687
|
-
var p = tryCatch(e, r, n);
|
3688
|
-
if ("normal" === p.type) {
|
3689
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
3690
|
-
return {
|
3691
|
-
value: p.arg,
|
3692
|
-
done: n.done
|
3693
|
-
};
|
3694
|
-
}
|
3695
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
3696
|
-
}
|
3697
|
-
};
|
3698
|
-
}
|
3699
|
-
function maybeInvokeDelegate(e, r) {
|
3700
|
-
var n = r.method,
|
3701
|
-
o = e.iterator[n];
|
3702
|
-
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;
|
3703
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
3704
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
3705
|
-
var a = i.arg;
|
3706
|
-
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);
|
3707
|
-
}
|
3708
|
-
function pushTryEntry(t) {
|
3709
|
-
var e = {
|
3710
|
-
tryLoc: t[0]
|
3711
|
-
};
|
3712
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
3713
|
-
}
|
3714
|
-
function resetTryEntry(t) {
|
3715
|
-
var e = t.completion || {};
|
3716
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
3717
|
-
}
|
3718
|
-
function Context(t) {
|
3719
|
-
this.tryEntries = [{
|
3720
|
-
tryLoc: "root"
|
3721
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
3722
|
-
}
|
3723
|
-
function values(e) {
|
3724
|
-
if (e || "" === e) {
|
3725
|
-
var r = e[a];
|
3726
|
-
if (r) return r.call(e);
|
3727
|
-
if ("function" == typeof e.next) return e;
|
3728
|
-
if (!isNaN(e.length)) {
|
3729
|
-
var o = -1,
|
3730
|
-
i = function next() {
|
3731
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
3732
|
-
return next.value = t, next.done = !0, next;
|
3733
|
-
};
|
3734
|
-
return i.next = i;
|
3735
|
-
}
|
3736
|
-
}
|
3737
|
-
throw new TypeError(typeof e + " is not iterable");
|
3738
|
-
}
|
3739
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
3740
|
-
value: GeneratorFunctionPrototype,
|
3741
|
-
configurable: !0
|
3742
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
3743
|
-
value: GeneratorFunction,
|
3744
|
-
configurable: !0
|
3745
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
3746
|
-
var e = "function" == typeof t && t.constructor;
|
3747
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
3748
|
-
}, e.mark = function (t) {
|
3749
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
3750
|
-
}, e.awrap = function (t) {
|
3751
|
-
return {
|
3752
|
-
__await: t
|
3753
|
-
};
|
3754
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
3755
|
-
return this;
|
3756
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
3757
|
-
void 0 === i && (i = Promise);
|
3758
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
3759
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
3760
|
-
return t.done ? t.value : a.next();
|
3761
|
-
});
|
3762
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
3763
|
-
return this;
|
3764
|
-
}), define(g, "toString", function () {
|
3765
|
-
return "[object Generator]";
|
3766
|
-
}), e.keys = function (t) {
|
3767
|
-
var e = Object(t),
|
3768
|
-
r = [];
|
3769
|
-
for (var n in e) r.push(n);
|
3770
|
-
return r.reverse(), function next() {
|
3771
|
-
for (; r.length;) {
|
3772
|
-
var t = r.pop();
|
3773
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
3774
|
-
}
|
3775
|
-
return next.done = !0, next;
|
3776
|
-
};
|
3777
|
-
}, e.values = values, Context.prototype = {
|
3778
|
-
constructor: Context,
|
3779
|
-
reset: function (e) {
|
3780
|
-
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);
|
3781
|
-
},
|
3782
|
-
stop: function () {
|
3783
|
-
this.done = !0;
|
3784
|
-
var t = this.tryEntries[0].completion;
|
3785
|
-
if ("throw" === t.type) throw t.arg;
|
3786
|
-
return this.rval;
|
3787
|
-
},
|
3788
|
-
dispatchException: function (e) {
|
3789
|
-
if (this.done) throw e;
|
3790
|
-
var r = this;
|
3791
|
-
function handle(n, o) {
|
3792
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
3793
|
-
}
|
3794
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
3795
|
-
var i = this.tryEntries[o],
|
3796
|
-
a = i.completion;
|
3797
|
-
if ("root" === i.tryLoc) return handle("end");
|
3798
|
-
if (i.tryLoc <= this.prev) {
|
3799
|
-
var c = n.call(i, "catchLoc"),
|
3800
|
-
u = n.call(i, "finallyLoc");
|
3801
|
-
if (c && u) {
|
3802
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
3803
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
3804
|
-
} else if (c) {
|
3805
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
3806
|
-
} else {
|
3807
|
-
if (!u) throw new Error("try statement without catch or finally");
|
3808
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
3809
|
-
}
|
3810
|
-
}
|
3811
|
-
}
|
3812
|
-
},
|
3813
|
-
abrupt: function (t, e) {
|
3814
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
3815
|
-
var o = this.tryEntries[r];
|
3816
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
3817
|
-
var i = o;
|
3818
|
-
break;
|
3819
|
-
}
|
3820
|
-
}
|
3821
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
3822
|
-
var a = i ? i.completion : {};
|
3823
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
3824
|
-
},
|
3825
|
-
complete: function (t, e) {
|
3826
|
-
if ("throw" === t.type) throw t.arg;
|
3827
|
-
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;
|
3828
|
-
},
|
3829
|
-
finish: function (t) {
|
3830
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
3831
|
-
var r = this.tryEntries[e];
|
3832
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
3833
|
-
}
|
3834
|
-
},
|
3835
|
-
catch: function (t) {
|
3836
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
3837
|
-
var r = this.tryEntries[e];
|
3838
|
-
if (r.tryLoc === t) {
|
3839
|
-
var n = r.completion;
|
3840
|
-
if ("throw" === n.type) {
|
3841
|
-
var o = n.arg;
|
3842
|
-
resetTryEntry(r);
|
3843
|
-
}
|
3844
|
-
return o;
|
3845
|
-
}
|
3846
|
-
}
|
3847
|
-
throw new Error("illegal catch attempt");
|
3848
|
-
},
|
3849
|
-
delegateYield: function (e, r, n) {
|
3850
|
-
return this.delegate = {
|
3851
|
-
iterator: values(e),
|
3852
|
-
resultName: r,
|
3853
|
-
nextLoc: n
|
3854
|
-
}, "next" === this.method && (this.arg = t), y;
|
3855
|
-
}
|
3856
|
-
}, e;
|
3857
|
-
}
|
3858
|
-
|
3859
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
3860
|
-
try {
|
3861
|
-
var info = gen[key](arg);
|
3862
|
-
var value = info.value;
|
3863
|
-
} catch (error) {
|
3864
|
-
reject(error);
|
3865
|
-
return;
|
3866
|
-
}
|
3867
|
-
if (info.done) {
|
3868
|
-
resolve(value);
|
3869
|
-
} else {
|
3870
|
-
Promise.resolve(value).then(_next, _throw);
|
3871
|
-
}
|
3872
|
-
}
|
3873
|
-
function _asyncToGenerator(fn) {
|
3874
|
-
return function () {
|
3875
|
-
var self = this,
|
3876
|
-
args = arguments;
|
3877
|
-
return new Promise(function (resolve, reject) {
|
3878
|
-
var gen = fn.apply(self, args);
|
3879
|
-
function _next(value) {
|
3880
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
3881
|
-
}
|
3882
|
-
function _throw(err) {
|
3883
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
3884
|
-
}
|
3885
|
-
_next(undefined);
|
3886
|
-
});
|
3887
|
-
};
|
3888
|
-
}
|
3889
|
-
|
3890
|
-
// TODO: move this to internal, only reason this is here is that react, ui and server all depend on it
|
3891
|
-
var ValApi = /*#__PURE__*/function () {
|
3892
|
-
function ValApi(host) {
|
3893
|
-
_classCallCheck(this, ValApi);
|
3894
|
-
this.host = host;
|
3895
|
-
}
|
3896
|
-
_createClass(ValApi, [{
|
3897
|
-
key: "getDisableUrl",
|
3898
|
-
value: function getDisableUrl(redirectTo) {
|
3899
|
-
return "".concat(this.host, "/disable?redirect_to=").concat(encodeURIComponent(redirectTo));
|
3900
|
-
}
|
3901
|
-
}, {
|
3902
|
-
key: "getLoginUrl",
|
3903
|
-
value: function getLoginUrl(redirectTo) {
|
3904
|
-
return "".concat(this.host, "/authorize?redirect_to=").concat(encodeURIComponent(redirectTo));
|
3905
|
-
}
|
3906
|
-
}, {
|
3907
|
-
key: "getEnableUrl",
|
3908
|
-
value: function getEnableUrl(redirectTo) {
|
3909
|
-
return "".concat(this.host, "/enable?redirect_to=").concat(encodeURIComponent(redirectTo));
|
3910
|
-
}
|
3911
|
-
}, {
|
3912
|
-
key: "getPatches",
|
3913
|
-
value: function () {
|
3914
|
-
var _getPatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(filters) {
|
3915
|
-
var params, _iterator, _step, patchId, _iterator2, _step2, author, _iterator3, _step3, moduleFilePath, searchParams;
|
3916
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
3917
|
-
while (1) switch (_context.prev = _context.next) {
|
3918
|
-
case 0:
|
3919
|
-
params = [];
|
3920
|
-
if (filters) {
|
3921
|
-
if (filters.patchIds) {
|
3922
|
-
_iterator = _createForOfIteratorHelper(filters.patchIds);
|
3923
|
-
try {
|
3924
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
3925
|
-
patchId = _step.value;
|
3926
|
-
params.push(["patch_id", patchId]);
|
3927
|
-
}
|
3928
|
-
} catch (err) {
|
3929
|
-
_iterator.e(err);
|
3930
|
-
} finally {
|
3931
|
-
_iterator.f();
|
3932
|
-
}
|
3933
|
-
}
|
3934
|
-
if (filters.authors) {
|
3935
|
-
_iterator2 = _createForOfIteratorHelper(filters.authors);
|
3936
|
-
try {
|
3937
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
3938
|
-
author = _step2.value;
|
3939
|
-
params.push(["author", author]);
|
3940
|
-
}
|
3941
|
-
} catch (err) {
|
3942
|
-
_iterator2.e(err);
|
3943
|
-
} finally {
|
3944
|
-
_iterator2.f();
|
3945
|
-
}
|
3946
|
-
}
|
3947
|
-
if (filters.moduleFilePaths) {
|
3948
|
-
_iterator3 = _createForOfIteratorHelper(filters.moduleFilePaths);
|
3949
|
-
try {
|
3950
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
3951
|
-
moduleFilePath = _step3.value;
|
3952
|
-
params.push(["module_file_path", moduleFilePath]);
|
3953
|
-
}
|
3954
|
-
} catch (err) {
|
3955
|
-
_iterator3.e(err);
|
3956
|
-
} finally {
|
3957
|
-
_iterator3.f();
|
3958
|
-
}
|
3959
|
-
}
|
3960
|
-
if (filters.omitPatches) {
|
3961
|
-
params.push(["omit_patches", "true"]);
|
3962
|
-
}
|
3963
|
-
}
|
3964
|
-
searchParams = new URLSearchParams(params);
|
3965
|
-
return _context.abrupt("return", fetch("".concat(this.host, "/patches/~").concat(searchParams.size > 0 ? "?".concat(searchParams.toString()) : ""), {
|
3966
|
-
headers: {
|
3967
|
-
"Content-Type": "application/json"
|
3968
|
-
}
|
3969
|
-
}).then(function (res) {
|
3970
|
-
return parse(res);
|
3971
|
-
})["catch"](createError));
|
3972
|
-
case 4:
|
3973
|
-
case "end":
|
3974
|
-
return _context.stop();
|
3975
|
-
}
|
3976
|
-
}, _callee, this);
|
3977
|
-
}));
|
3978
|
-
function getPatches(_x) {
|
3979
|
-
return _getPatches.apply(this, arguments);
|
3980
|
-
}
|
3981
|
-
return getPatches;
|
3982
|
-
}()
|
3983
|
-
}, {
|
3984
|
-
key: "deletePatches",
|
3985
|
-
value: function () {
|
3986
|
-
var _deletePatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ids, headers) {
|
3987
|
-
var params;
|
3988
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
3989
|
-
while (1) switch (_context2.prev = _context2.next) {
|
3990
|
-
case 0:
|
3991
|
-
params = new URLSearchParams();
|
3992
|
-
ids.forEach(function (id) {
|
3993
|
-
return params.append("id", id);
|
3994
|
-
});
|
3995
|
-
return _context2.abrupt("return", fetch("".concat(this.host, "/patches/~?").concat(params), {
|
3996
|
-
method: "DELETE",
|
3997
|
-
headers: headers || {
|
3998
|
-
"Content-Type": "application/json"
|
3999
|
-
}
|
4000
|
-
}).then(function (res) {
|
4001
|
-
return parse(res);
|
4002
|
-
})["catch"](createError));
|
4003
|
-
case 3:
|
4004
|
-
case "end":
|
4005
|
-
return _context2.stop();
|
4006
|
-
}
|
4007
|
-
}, _callee2, this);
|
4008
|
-
}));
|
4009
|
-
function deletePatches(_x2, _x3) {
|
4010
|
-
return _deletePatches.apply(this, arguments);
|
4011
|
-
}
|
4012
|
-
return deletePatches;
|
4013
|
-
}()
|
4014
|
-
}, {
|
4015
|
-
key: "getEditUrl",
|
4016
|
-
value: function getEditUrl() {
|
4017
|
-
// TODO: make route configurable
|
4018
|
-
return "/val/~";
|
4019
|
-
}
|
4020
|
-
}, {
|
4021
|
-
key: "getSession",
|
4022
|
-
value: function getSession() {
|
4023
|
-
return fetch("".concat(this.host, "/session")).then(function (res) {
|
4024
|
-
return parse(res)["catch"](createError);
|
4025
|
-
});
|
4026
|
-
}
|
4027
|
-
}, {
|
4028
|
-
key: "getSchema",
|
4029
|
-
value: function getSchema(_ref) {
|
4030
|
-
var headers = _ref.headers;
|
4031
|
-
return fetch("".concat(this.host, "/schema"), {
|
4032
|
-
method: "GET",
|
4033
|
-
headers: headers
|
4034
|
-
}).then(function (res) {
|
4035
|
-
return parse(res);
|
4036
|
-
})["catch"](createError);
|
4037
|
-
}
|
4038
|
-
}, {
|
4039
|
-
key: "putTree",
|
4040
|
-
value: function putTree(_ref2) {
|
4041
|
-
var _ref2$treePath = _ref2.treePath,
|
4042
|
-
treePath = _ref2$treePath === void 0 ? "/" : _ref2$treePath,
|
4043
|
-
patchIds = _ref2.patchIds,
|
4044
|
-
addPatch = _ref2.addPatch,
|
4045
|
-
validateAll = _ref2.validateAll,
|
4046
|
-
validateSource = _ref2.validateSource,
|
4047
|
-
validateBinaryFiles = _ref2.validateBinaryFiles,
|
4048
|
-
headers = _ref2.headers;
|
4049
|
-
var params = new URLSearchParams();
|
4050
|
-
var textEncoder = new TextEncoder();
|
4051
|
-
var patchesSha = getSHA256Hash(textEncoder.encode((patchIds || []).concat(JSON.stringify(addPatch || {})).join(";")));
|
4052
|
-
params.set("patches_sha", patchesSha);
|
4053
|
-
params.set("validate_all", (validateAll || false).toString());
|
4054
|
-
params.set("validate_source", (validateSource || false).toString());
|
4055
|
-
params.set("validate_binary_files", (validateBinaryFiles || false).toString());
|
4056
|
-
return fetch("".concat(this.host, "/tree/~").concat(treePath, "?").concat(params.toString()), {
|
4057
|
-
method: "PUT",
|
4058
|
-
body: JSON.stringify({
|
4059
|
-
patchIds: patchIds,
|
4060
|
-
addPatch: addPatch
|
4061
|
-
}),
|
4062
|
-
headers: headers
|
4063
|
-
}).then(function (res) {
|
4064
|
-
return parse(res);
|
4065
|
-
})["catch"](createError);
|
4066
|
-
}
|
4067
|
-
}, {
|
4068
|
-
key: "postSave",
|
4069
|
-
value: function postSave(_ref3) {
|
4070
|
-
var patchIds = _ref3.patchIds;
|
4071
|
-
return fetch("".concat(this.host, "/save"), {
|
4072
|
-
method: "POST",
|
4073
|
-
body: JSON.stringify({
|
4074
|
-
patchIds: patchIds
|
4075
|
-
}),
|
4076
|
-
headers: {
|
4077
|
-
"Content-Type": "application/json"
|
4078
|
-
}
|
4079
|
-
}).then( /*#__PURE__*/function () {
|
4080
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(res) {
|
4081
|
-
var jsonRes;
|
4082
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
4083
|
-
while (1) switch (_context3.prev = _context3.next) {
|
4084
|
-
case 0:
|
4085
|
-
if (!res.ok) {
|
4086
|
-
_context3.next = 4;
|
4087
|
-
break;
|
4088
|
-
}
|
4089
|
-
return _context3.abrupt("return", parse(res));
|
4090
|
-
case 4:
|
4091
|
-
if (!(res.status === 400 && res.headers.get("content-type") === "application/json")) {
|
4092
|
-
_context3.next = 9;
|
4093
|
-
break;
|
4094
|
-
}
|
4095
|
-
_context3.next = 7;
|
4096
|
-
return res.json();
|
4097
|
-
case 7:
|
4098
|
-
jsonRes = _context3.sent;
|
4099
|
-
alert(JSON.stringify(jsonRes));
|
4100
|
-
case 9:
|
4101
|
-
return _context3.abrupt("return", parse(res));
|
4102
|
-
case 10:
|
4103
|
-
case "end":
|
4104
|
-
return _context3.stop();
|
4105
|
-
}
|
4106
|
-
}, _callee3);
|
4107
|
-
}));
|
4108
|
-
return function (_x4) {
|
4109
|
-
return _ref4.apply(this, arguments);
|
4110
|
-
};
|
4111
|
-
}())["catch"](createError);
|
4112
|
-
}
|
4113
|
-
}, {
|
4114
|
-
key: "postValidate",
|
4115
|
-
value: function postValidate(_ref5) {
|
4116
|
-
var patches = _ref5.patches,
|
4117
|
-
headers = _ref5.headers;
|
4118
|
-
return fetch("".concat(this.host, "/validate"), {
|
4119
|
-
method: "POST",
|
4120
|
-
body: JSON.stringify({
|
4121
|
-
patches: patches
|
4122
|
-
}),
|
4123
|
-
headers: headers || {
|
4124
|
-
"Content-Type": "application/json"
|
4125
|
-
}
|
4126
|
-
}).then( /*#__PURE__*/function () {
|
4127
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(res) {
|
4128
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
4129
|
-
while (1) switch (_context4.prev = _context4.next) {
|
4130
|
-
case 0:
|
4131
|
-
return _context4.abrupt("return", parse(res));
|
4132
|
-
case 1:
|
4133
|
-
case "end":
|
4134
|
-
return _context4.stop();
|
4135
|
-
}
|
4136
|
-
}, _callee4);
|
4137
|
-
}));
|
4138
|
-
return function (_x5) {
|
4139
|
-
return _ref6.apply(this, arguments);
|
4140
|
-
};
|
4141
|
-
}())["catch"](createError);
|
4142
|
-
}
|
4143
|
-
}]);
|
4144
|
-
return ValApi;
|
4145
|
-
}();
|
4146
|
-
function createError(err$1) {
|
4147
|
-
return err({
|
4148
|
-
statusCode: 500,
|
4149
|
-
message: err$1 instanceof Error ? err$1.message : _typeof(err$1) === "object" && err$1 && "message" in err$1 && typeof err$1.message === "string" ? err$1.message : "Unknown error",
|
4150
|
-
details: _typeof(err$1) === "object" && err$1 && "details" in err$1 ? err$1.details : undefined
|
4151
|
-
});
|
4152
|
-
}
|
4153
|
-
|
4154
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
4155
|
-
function formatError(status, json, statusText) {
|
4156
|
-
return err({
|
4157
|
-
statusCode: status,
|
4158
|
-
message: json.message || statusText,
|
4159
|
-
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref7) {
|
4160
|
-
var _ref8 = _slicedToArray(_ref7, 1),
|
4161
|
-
key = _ref8[0];
|
4162
|
-
return key !== "message";
|
4163
|
-
}))
|
4164
|
-
});
|
4165
|
-
}
|
4166
|
-
|
4167
|
-
// TODO: validate
|
4168
|
-
function parse(_x6) {
|
4169
|
-
return _parse.apply(this, arguments);
|
4170
|
-
}
|
4171
|
-
function _parse() {
|
4172
|
-
_parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(res) {
|
4173
|
-
var json;
|
4174
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
4175
|
-
while (1) switch (_context5.prev = _context5.next) {
|
4176
|
-
case 0:
|
4177
|
-
_context5.prev = 0;
|
4178
|
-
if (!res.ok) {
|
4179
|
-
_context5.next = 9;
|
4180
|
-
break;
|
4181
|
-
}
|
4182
|
-
_context5.t0 = result;
|
4183
|
-
_context5.next = 5;
|
4184
|
-
return res.json();
|
4185
|
-
case 5:
|
4186
|
-
_context5.t1 = _context5.sent;
|
4187
|
-
return _context5.abrupt("return", _context5.t0.ok.call(_context5.t0, _context5.t1));
|
4188
|
-
case 9:
|
4189
|
-
_context5.prev = 9;
|
4190
|
-
_context5.next = 12;
|
4191
|
-
return res.json();
|
4192
|
-
case 12:
|
4193
|
-
json = _context5.sent;
|
4194
|
-
return _context5.abrupt("return", formatError(res.status, json, res.statusText));
|
4195
|
-
case 16:
|
4196
|
-
_context5.prev = 16;
|
4197
|
-
_context5.t2 = _context5["catch"](9);
|
4198
|
-
return _context5.abrupt("return", err({
|
4199
|
-
statusCode: res.status,
|
4200
|
-
message: res.statusText
|
4201
|
-
}));
|
4202
|
-
case 19:
|
4203
|
-
_context5.next = 24;
|
4204
|
-
break;
|
4205
|
-
case 21:
|
4206
|
-
_context5.prev = 21;
|
4207
|
-
_context5.t3 = _context5["catch"](0);
|
4208
|
-
return _context5.abrupt("return", err({
|
4209
|
-
message: _context5.t3 instanceof Error ? _context5.t3.message : "Unknown error"
|
4210
|
-
}));
|
4211
|
-
case 24:
|
4212
|
-
case "end":
|
4213
|
-
return _context5.stop();
|
4214
|
-
}
|
4215
|
-
}, _callee5, null, [[0, 21], [9, 16]]);
|
4216
|
-
}));
|
4217
|
-
return _parse.apply(this, arguments);
|
4218
|
-
}
|
4219
|
-
|
4220
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
4221
|
-
|
4222
5095
|
var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
4223
5096
|
var Internal = {
|
4224
5097
|
VERSION: {
|
@@ -4242,6 +5115,11 @@ var Internal = {
|
|
4242
5115
|
createValPathOfItem: createValPathOfItem,
|
4243
5116
|
getSHA256Hash: getSHA256Hash,
|
4244
5117
|
initSchema: initSchema,
|
5118
|
+
getMimeType: getMimeType,
|
5119
|
+
mimeTypeToFileExt: mimeTypeToFileExt,
|
5120
|
+
filenameToMimeType: filenameToMimeType,
|
5121
|
+
EXT_TO_MIME_TYPES: EXT_TO_MIME_TYPES,
|
5122
|
+
MIME_TYPES_TO_EXT: MIME_TYPES_TO_EXT,
|
4245
5123
|
ModuleFilePathSep: ModuleFilePathSep,
|
4246
5124
|
notFileOp: function notFileOp(op) {
|
4247
5125
|
return op.op !== "file";
|
@@ -4278,4 +5156,4 @@ function tryJsonParse(str) {
|
|
4278
5156
|
}
|
4279
5157
|
}
|
4280
5158
|
|
4281
|
-
export { ArraySchema as A, BooleanSchema as B, Call as C, Expr as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, LiteralSchema as L, NilSym as N, ObjectSchema as O, PatchError as P, RT_IMAGE_TAG as R, StringLiteral as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, StringTemplate as e, Sym as f, evaluate as g, initVal as h, index as i, Schema as j, FILE_REF_PROP as k, FILE_REF_SUBTYPE_TAG as l, modules as m, derefPatch as n, RecordSchema as o, parse
|
5159
|
+
export { ArraySchema as A, BooleanSchema as B, Call as C, DateSchema as D, Expr as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, NilSym as N, ObjectSchema as O, PatchError as P, RT_IMAGE_TAG as R, StringLiteral as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, StringTemplate as e, Sym as f, evaluate as g, initVal as h, index as i, Schema as j, FILE_REF_PROP as k, FILE_REF_SUBTYPE_TAG as l, modules as m, derefPatch as n, RecordSchema as o, parse as p, StringSchema as q, NumberSchema as r, splitModuleFilePathAndModulePath as s, ImageSchema as t, FileSchema as u, RichTextSchema as v, deserializeSchema as w };
|