@valbuild/core 0.58.0 → 0.60.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/ValApi.d.ts +11 -6
- package/dist/declarations/src/index.d.ts +56 -12
- package/dist/declarations/src/initVal.d.ts +3 -3
- package/dist/declarations/src/schema/deserialize.d.ts +3 -0
- package/dist/declarations/src/schema/keyOf.d.ts +5 -3
- package/dist/declarations/src/schema/union.d.ts +1 -1
- package/dist/declarations/src/source/index.d.ts +1 -1
- package/dist/declarations/src/val/index.d.ts +3 -0
- package/dist/{index-cdc3515c.esm.js → index-0c827e64.esm.js} +1 -1
- package/dist/{index-b88673ad.esm.js → index-c6d9700a.esm.js} +1 -1
- package/dist/{ops-a042c33f.esm.js → ops-25e75394.esm.js} +5 -4
- package/dist/{ops-cdc83cb6.cjs.prod.js → ops-8fd18dcf.cjs.prod.js} +4 -2
- package/dist/{ops-36bf1f3c.cjs.dev.js → ops-9e41e1f9.cjs.dev.js} +4 -2
- package/dist/valbuild-core.cjs.dev.js +256 -72
- package/dist/valbuild-core.cjs.prod.js +256 -72
- package/dist/valbuild-core.esm.js +259 -77
- package/expr/dist/valbuild-core-expr.esm.js +2 -2
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +4 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +4 -1
- package/patch/dist/valbuild-core-patch.esm.js +6 -3
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var ops = require('./ops-
|
5
|
+
var ops = require('./ops-8fd18dcf.cjs.prod.js');
|
6
6
|
var index = require('./index-0c2d9420.cjs.prod.js');
|
7
7
|
var expr_dist_valbuildCoreExpr = require('./index-5afcc749.cjs.prod.js');
|
8
8
|
var result = require('./result-26f67b40.cjs.prod.js');
|
@@ -208,12 +208,13 @@ var _boolean = function _boolean() {
|
|
208
208
|
|
209
209
|
var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
210
210
|
index._inherits(KeyOfSchema, _Schema);
|
211
|
-
function KeyOfSchema(
|
211
|
+
function KeyOfSchema(schema, sourcePath) {
|
212
212
|
var _this;
|
213
|
-
var opt = arguments.length >
|
213
|
+
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
214
214
|
index._classCallCheck(this, KeyOfSchema);
|
215
215
|
_this = index._callSuper(this, KeyOfSchema);
|
216
|
-
_this.
|
216
|
+
_this.schema = schema;
|
217
|
+
_this.sourcePath = sourcePath;
|
217
218
|
_this.opt = opt;
|
218
219
|
return _this;
|
219
220
|
}
|
@@ -223,13 +224,12 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
223
224
|
if (this.opt && (src === null || src === undefined)) {
|
224
225
|
return false;
|
225
226
|
}
|
226
|
-
|
227
|
-
if (!schema) {
|
227
|
+
if (!this.schema) {
|
228
228
|
return index._defineProperty({}, path, [{
|
229
229
|
message: "Schema not found for module. keyOf must be used with a Val Module"
|
230
230
|
}]);
|
231
231
|
}
|
232
|
-
var serializedSchema = schema
|
232
|
+
var serializedSchema = this.schema;
|
233
233
|
if (!(serializedSchema.type === "array" || serializedSchema.type === "object" || serializedSchema.type === "record")) {
|
234
234
|
return index._defineProperty({}, path, [{
|
235
235
|
message: "Schema in keyOf must be an 'array', 'object' or 'record'. Found '".concat(serializedSchema.type, "'")
|
@@ -264,11 +264,11 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
264
264
|
if (this.opt && (src === null || src === undefined)) {
|
265
265
|
return true;
|
266
266
|
}
|
267
|
-
var schema = this.
|
267
|
+
var schema = this.schema;
|
268
268
|
if (!schema) {
|
269
269
|
return false;
|
270
270
|
}
|
271
|
-
var serializedSchema = schema
|
271
|
+
var serializedSchema = schema;
|
272
272
|
if (!(serializedSchema.type === "array" || serializedSchema.type === "object" || serializedSchema.type === "record")) {
|
273
273
|
return false;
|
274
274
|
}
|
@@ -292,22 +292,21 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
292
292
|
}, {
|
293
293
|
key: "optional",
|
294
294
|
value: function optional() {
|
295
|
-
return new KeyOfSchema(this.
|
295
|
+
return new KeyOfSchema(this.schema, undefined, true);
|
296
296
|
}
|
297
297
|
}, {
|
298
298
|
key: "serialize",
|
299
299
|
value: function serialize() {
|
300
|
-
var
|
301
|
-
var path = index.getValPath(this.selector);
|
300
|
+
var path = this.sourcePath;
|
302
301
|
if (!path) {
|
303
302
|
throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module.");
|
304
303
|
}
|
305
|
-
var
|
306
|
-
if (!
|
304
|
+
var serializedSchema = this.schema;
|
305
|
+
if (!serializedSchema) {
|
307
306
|
throw new Error("Cannot serialize oneOf schema with empty selector.");
|
308
307
|
}
|
309
308
|
var values;
|
310
|
-
switch (
|
309
|
+
switch (serializedSchema.type) {
|
311
310
|
case "array":
|
312
311
|
values = "number";
|
313
312
|
break;
|
@@ -315,14 +314,15 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
315
314
|
values = "string";
|
316
315
|
break;
|
317
316
|
case "object":
|
318
|
-
values = Object.keys(
|
317
|
+
values = Object.keys(serializedSchema.items);
|
319
318
|
break;
|
320
319
|
default:
|
321
|
-
throw new Error("Cannot serialize oneOf schema with selector of type '".concat(
|
320
|
+
throw new Error("Cannot serialize oneOf schema with selector of type '".concat(serializedSchema.type, "'. keyOf must be used with a Val Module."));
|
322
321
|
}
|
323
322
|
return {
|
324
323
|
type: "keyOf",
|
325
|
-
|
324
|
+
path: path,
|
325
|
+
schema: serializedSchema,
|
326
326
|
opt: this.opt,
|
327
327
|
values: values
|
328
328
|
};
|
@@ -331,7 +331,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
331
331
|
return KeyOfSchema;
|
332
332
|
}(index.Schema);
|
333
333
|
var keyOf = function keyOf(valModule) {
|
334
|
-
|
334
|
+
var _valModule$GetSchema;
|
335
|
+
return new KeyOfSchema(valModule === null || valModule === void 0 || (_valModule$GetSchema = valModule[index.GetSchema]) === null || _valModule$GetSchema === void 0 ? void 0 : _valModule$GetSchema.serialize(), index.getValPath(valModule));
|
335
336
|
};
|
336
337
|
|
337
338
|
// import type { F } from "ts-toolbelt";
|
@@ -418,7 +419,7 @@ function link(text, _ref) {
|
|
418
419
|
// };
|
419
420
|
|
420
421
|
// TODO: Rename to createValSystem (only to be used by internal things), we can then export * from '@valbuild/core' in the next package then.
|
421
|
-
var initVal = function initVal() {
|
422
|
+
var initVal = function initVal(config) {
|
422
423
|
// const locales = options?.locales;
|
423
424
|
var s = initSchema();
|
424
425
|
// if (locales?.required) {
|
@@ -452,7 +453,7 @@ var initVal = function initVal() {
|
|
452
453
|
}
|
453
454
|
},
|
454
455
|
s: s,
|
455
|
-
config:
|
456
|
+
config: config
|
456
457
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
457
458
|
};
|
458
459
|
};
|
@@ -1041,6 +1042,53 @@ var getSHA256Hash = function getSHA256Hash(bits) {
|
|
1041
1042
|
return createHash().update(bits).digest("hex");
|
1042
1043
|
};
|
1043
1044
|
|
1045
|
+
function deserializeSchema(serialized) {
|
1046
|
+
var _serialized$options;
|
1047
|
+
switch (serialized.type) {
|
1048
|
+
case "string":
|
1049
|
+
return new StringSchema(index._objectSpread2(index._objectSpread2({}, serialized.options), {}, {
|
1050
|
+
regexp: ((_serialized$options = serialized.options) === null || _serialized$options === void 0 ? void 0 : _serialized$options.regexp) && new RegExp(serialized.options.regexp.source, serialized.options.regexp.flags)
|
1051
|
+
}), serialized.opt);
|
1052
|
+
case "literal":
|
1053
|
+
return new ops.LiteralSchema(serialized.value, serialized.opt);
|
1054
|
+
case "boolean":
|
1055
|
+
return new BooleanSchema(serialized.opt);
|
1056
|
+
case "number":
|
1057
|
+
return new NumberSchema(serialized.options, serialized.opt);
|
1058
|
+
case "object":
|
1059
|
+
return new ops.ObjectSchema(Object.fromEntries(Object.entries(serialized.items).map(function (_ref) {
|
1060
|
+
var _ref2 = index._slicedToArray(_ref, 2),
|
1061
|
+
key = _ref2[0],
|
1062
|
+
item = _ref2[1];
|
1063
|
+
return [key, deserializeSchema(item)];
|
1064
|
+
})), serialized.opt);
|
1065
|
+
case "array":
|
1066
|
+
return new ops.ArraySchema(deserializeSchema(serialized.item), serialized.opt);
|
1067
|
+
case "union":
|
1068
|
+
return new ops.UnionSchema(typeof serialized.key === "string" ? serialized.key : deserializeSchema(serialized.key), serialized.items.map(deserializeSchema), serialized.opt);
|
1069
|
+
case "richtext":
|
1070
|
+
return new ops.RichTextSchema(serialized.options, serialized.opt);
|
1071
|
+
case "record":
|
1072
|
+
return new ops.RecordSchema(deserializeSchema(serialized.item), serialized.opt);
|
1073
|
+
case "keyOf":
|
1074
|
+
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt);
|
1075
|
+
case "file":
|
1076
|
+
return new index.FileSchema(serialized.options, serialized.opt);
|
1077
|
+
case "image":
|
1078
|
+
return new ops.ImageSchema(serialized.options, serialized.opt);
|
1079
|
+
default:
|
1080
|
+
{
|
1081
|
+
var exhaustiveCheck = serialized;
|
1082
|
+
var unknownSerialized = exhaustiveCheck;
|
1083
|
+
if (unknownSerialized && index._typeof(unknownSerialized) === "object" && "type" in unknownSerialized) {
|
1084
|
+
throw new Error("Unknown schema type: ".concat(unknownSerialized.type));
|
1085
|
+
} else {
|
1086
|
+
throw new Error("Unknown schema: ".concat(JSON.stringify(unknownSerialized, null, 2)));
|
1087
|
+
}
|
1088
|
+
}
|
1089
|
+
}
|
1090
|
+
}
|
1091
|
+
|
1044
1092
|
function _regeneratorRuntime() {
|
1045
1093
|
_regeneratorRuntime = function () {
|
1046
1094
|
return e;
|
@@ -1425,6 +1473,37 @@ var ValApi = /*#__PURE__*/function () {
|
|
1425
1473
|
}
|
1426
1474
|
return getPatches;
|
1427
1475
|
}()
|
1476
|
+
}, {
|
1477
|
+
key: "deletePatches",
|
1478
|
+
value: function () {
|
1479
|
+
var _deletePatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ids, headers) {
|
1480
|
+
var params;
|
1481
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1482
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1483
|
+
case 0:
|
1484
|
+
params = new URLSearchParams();
|
1485
|
+
ids.forEach(function (id) {
|
1486
|
+
return params.append("id", id);
|
1487
|
+
});
|
1488
|
+
return _context2.abrupt("return", fetch("".concat(this.host, "/patches/~?").concat(params), {
|
1489
|
+
method: "DELETE",
|
1490
|
+
headers: headers || {
|
1491
|
+
"Content-Type": "application/json"
|
1492
|
+
}
|
1493
|
+
}).then(function (res) {
|
1494
|
+
return parse(res);
|
1495
|
+
})["catch"](createError));
|
1496
|
+
case 3:
|
1497
|
+
case "end":
|
1498
|
+
return _context2.stop();
|
1499
|
+
}
|
1500
|
+
}, _callee2, this);
|
1501
|
+
}));
|
1502
|
+
function deletePatches(_x2, _x3) {
|
1503
|
+
return _deletePatches.apply(this, arguments);
|
1504
|
+
}
|
1505
|
+
return deletePatches;
|
1506
|
+
}()
|
1428
1507
|
}, {
|
1429
1508
|
key: "getEditUrl",
|
1430
1509
|
value: function getEditUrl() {
|
@@ -1439,9 +1518,22 @@ var ValApi = /*#__PURE__*/function () {
|
|
1439
1518
|
},
|
1440
1519
|
method: "POST",
|
1441
1520
|
body: JSON.stringify(index._defineProperty({}, moduleId, patches))
|
1442
|
-
}).then(function (
|
1443
|
-
|
1444
|
-
|
1521
|
+
}).then( /*#__PURE__*/function () {
|
1522
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(res) {
|
1523
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1524
|
+
while (1) switch (_context3.prev = _context3.next) {
|
1525
|
+
case 0:
|
1526
|
+
return _context3.abrupt("return", parse(res));
|
1527
|
+
case 1:
|
1528
|
+
case "end":
|
1529
|
+
return _context3.stop();
|
1530
|
+
}
|
1531
|
+
}, _callee3);
|
1532
|
+
}));
|
1533
|
+
return function (_x4) {
|
1534
|
+
return _ref2.apply(this, arguments);
|
1535
|
+
};
|
1536
|
+
}())["catch"](createError);
|
1445
1537
|
}
|
1446
1538
|
}, {
|
1447
1539
|
key: "getSession",
|
@@ -1452,16 +1544,16 @@ var ValApi = /*#__PURE__*/function () {
|
|
1452
1544
|
}
|
1453
1545
|
}, {
|
1454
1546
|
key: "getTree",
|
1455
|
-
value: function getTree(
|
1456
|
-
var
|
1457
|
-
patch =
|
1458
|
-
|
1459
|
-
includeSchema =
|
1460
|
-
|
1461
|
-
includeSource =
|
1462
|
-
|
1463
|
-
treePath =
|
1464
|
-
headers =
|
1547
|
+
value: function getTree(_ref3) {
|
1548
|
+
var _ref3$patch = _ref3.patch,
|
1549
|
+
patch = _ref3$patch === void 0 ? false : _ref3$patch,
|
1550
|
+
_ref3$includeSchema = _ref3.includeSchema,
|
1551
|
+
includeSchema = _ref3$includeSchema === void 0 ? false : _ref3$includeSchema,
|
1552
|
+
_ref3$includeSource = _ref3.includeSource,
|
1553
|
+
includeSource = _ref3$includeSource === void 0 ? false : _ref3$includeSource,
|
1554
|
+
_ref3$treePath = _ref3.treePath,
|
1555
|
+
treePath = _ref3$treePath === void 0 ? "/" : _ref3$treePath,
|
1556
|
+
headers = _ref3.headers;
|
1465
1557
|
var params = new URLSearchParams();
|
1466
1558
|
params.set("patch", patch.toString());
|
1467
1559
|
params.set("schema", includeSchema.toString());
|
@@ -1474,9 +1566,9 @@ var ValApi = /*#__PURE__*/function () {
|
|
1474
1566
|
}
|
1475
1567
|
}, {
|
1476
1568
|
key: "postCommit",
|
1477
|
-
value: function postCommit(
|
1478
|
-
var patches =
|
1479
|
-
headers =
|
1569
|
+
value: function postCommit(_ref4) {
|
1570
|
+
var patches = _ref4.patches,
|
1571
|
+
headers = _ref4.headers;
|
1480
1572
|
return fetch("".concat(this.host, "/commit"), {
|
1481
1573
|
method: "POST",
|
1482
1574
|
body: JSON.stringify({
|
@@ -1485,9 +1577,75 @@ var ValApi = /*#__PURE__*/function () {
|
|
1485
1577
|
headers: headers || {
|
1486
1578
|
"Content-Type": "application/json"
|
1487
1579
|
}
|
1488
|
-
}).then(function (
|
1489
|
-
|
1490
|
-
|
1580
|
+
}).then( /*#__PURE__*/function () {
|
1581
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(res) {
|
1582
|
+
var jsonRes;
|
1583
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
1584
|
+
while (1) switch (_context4.prev = _context4.next) {
|
1585
|
+
case 0:
|
1586
|
+
if (!res.ok) {
|
1587
|
+
_context4.next = 4;
|
1588
|
+
break;
|
1589
|
+
}
|
1590
|
+
return _context4.abrupt("return", parse(res));
|
1591
|
+
case 4:
|
1592
|
+
if (!(res.status === 400 && res.headers.get("content-type") === "application/json")) {
|
1593
|
+
_context4.next = 13;
|
1594
|
+
break;
|
1595
|
+
}
|
1596
|
+
_context4.next = 7;
|
1597
|
+
return res.json();
|
1598
|
+
case 7:
|
1599
|
+
jsonRes = _context4.sent;
|
1600
|
+
if (!("validationErrors" in jsonRes)) {
|
1601
|
+
_context4.next = 12;
|
1602
|
+
break;
|
1603
|
+
}
|
1604
|
+
return _context4.abrupt("return", result.err(jsonRes));
|
1605
|
+
case 12:
|
1606
|
+
return _context4.abrupt("return", formatError(res.status, jsonRes, res.statusText));
|
1607
|
+
case 13:
|
1608
|
+
return _context4.abrupt("return", parse(res));
|
1609
|
+
case 14:
|
1610
|
+
case "end":
|
1611
|
+
return _context4.stop();
|
1612
|
+
}
|
1613
|
+
}, _callee4);
|
1614
|
+
}));
|
1615
|
+
return function (_x5) {
|
1616
|
+
return _ref5.apply(this, arguments);
|
1617
|
+
};
|
1618
|
+
}())["catch"](createError);
|
1619
|
+
}
|
1620
|
+
}, {
|
1621
|
+
key: "postValidate",
|
1622
|
+
value: function postValidate(_ref6) {
|
1623
|
+
var patches = _ref6.patches,
|
1624
|
+
headers = _ref6.headers;
|
1625
|
+
return fetch("".concat(this.host, "/validate"), {
|
1626
|
+
method: "POST",
|
1627
|
+
body: JSON.stringify({
|
1628
|
+
patches: patches
|
1629
|
+
}),
|
1630
|
+
headers: headers || {
|
1631
|
+
"Content-Type": "application/json"
|
1632
|
+
}
|
1633
|
+
}).then( /*#__PURE__*/function () {
|
1634
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(res) {
|
1635
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
1636
|
+
while (1) switch (_context5.prev = _context5.next) {
|
1637
|
+
case 0:
|
1638
|
+
return _context5.abrupt("return", parse(res));
|
1639
|
+
case 1:
|
1640
|
+
case "end":
|
1641
|
+
return _context5.stop();
|
1642
|
+
}
|
1643
|
+
}, _callee5);
|
1644
|
+
}));
|
1645
|
+
return function (_x6) {
|
1646
|
+
return _ref7.apply(this, arguments);
|
1647
|
+
};
|
1648
|
+
}())["catch"](createError);
|
1491
1649
|
}
|
1492
1650
|
}]);
|
1493
1651
|
return ValApi;
|
@@ -1499,67 +1657,73 @@ function createError(err) {
|
|
1499
1657
|
});
|
1500
1658
|
}
|
1501
1659
|
|
1660
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1661
|
+
function formatError(status, json, statusText) {
|
1662
|
+
return result.err({
|
1663
|
+
statusCode: status,
|
1664
|
+
message: json.message || statusText,
|
1665
|
+
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref8) {
|
1666
|
+
var _ref9 = index._slicedToArray(_ref8, 1),
|
1667
|
+
key = _ref9[0];
|
1668
|
+
return key !== "message";
|
1669
|
+
}))
|
1670
|
+
});
|
1671
|
+
}
|
1672
|
+
|
1502
1673
|
// TODO: validate
|
1503
|
-
function parse(
|
1674
|
+
function parse(_x7) {
|
1504
1675
|
return _parse.apply(this, arguments);
|
1505
1676
|
}
|
1506
1677
|
function _parse() {
|
1507
|
-
_parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
1678
|
+
_parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(res) {
|
1508
1679
|
var json;
|
1509
|
-
return _regeneratorRuntime().wrap(function
|
1510
|
-
while (1) switch (
|
1680
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
1681
|
+
while (1) switch (_context6.prev = _context6.next) {
|
1511
1682
|
case 0:
|
1512
|
-
|
1683
|
+
_context6.prev = 0;
|
1513
1684
|
if (!res.ok) {
|
1514
|
-
|
1685
|
+
_context6.next = 9;
|
1515
1686
|
break;
|
1516
1687
|
}
|
1517
|
-
|
1518
|
-
|
1688
|
+
_context6.t0 = result.result;
|
1689
|
+
_context6.next = 5;
|
1519
1690
|
return res.json();
|
1520
1691
|
case 5:
|
1521
|
-
|
1522
|
-
return
|
1692
|
+
_context6.t1 = _context6.sent;
|
1693
|
+
return _context6.abrupt("return", _context6.t0.ok.call(_context6.t0, _context6.t1));
|
1523
1694
|
case 9:
|
1524
|
-
|
1525
|
-
|
1695
|
+
_context6.prev = 9;
|
1696
|
+
_context6.next = 12;
|
1526
1697
|
return res.json();
|
1527
1698
|
case 12:
|
1528
|
-
json =
|
1529
|
-
return
|
1530
|
-
statusCode: res.status,
|
1531
|
-
message: json.message || res.statusText,
|
1532
|
-
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref4) {
|
1533
|
-
var _ref5 = index._slicedToArray(_ref4, 1),
|
1534
|
-
key = _ref5[0];
|
1535
|
-
return key !== "message";
|
1536
|
-
}))
|
1537
|
-
}));
|
1699
|
+
json = _context6.sent;
|
1700
|
+
return _context6.abrupt("return", formatError(res.status, json, res.statusText));
|
1538
1701
|
case 16:
|
1539
|
-
|
1540
|
-
|
1541
|
-
return
|
1702
|
+
_context6.prev = 16;
|
1703
|
+
_context6.t2 = _context6["catch"](9);
|
1704
|
+
return _context6.abrupt("return", result.err({
|
1542
1705
|
statusCode: res.status,
|
1543
1706
|
message: res.statusText
|
1544
1707
|
}));
|
1545
1708
|
case 19:
|
1546
|
-
|
1709
|
+
_context6.next = 24;
|
1547
1710
|
break;
|
1548
1711
|
case 21:
|
1549
|
-
|
1550
|
-
|
1551
|
-
return
|
1552
|
-
message:
|
1712
|
+
_context6.prev = 21;
|
1713
|
+
_context6.t3 = _context6["catch"](0);
|
1714
|
+
return _context6.abrupt("return", result.err({
|
1715
|
+
message: _context6.t3 instanceof Error ? _context6.t3.message : "Unknown error"
|
1553
1716
|
}));
|
1554
1717
|
case 24:
|
1555
1718
|
case "end":
|
1556
|
-
return
|
1719
|
+
return _context6.stop();
|
1557
1720
|
}
|
1558
|
-
},
|
1721
|
+
}, _callee6, null, [[0, 21], [9, 16]]);
|
1559
1722
|
}));
|
1560
1723
|
return _parse.apply(this, arguments);
|
1561
1724
|
}
|
1562
1725
|
|
1726
|
+
var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
1563
1727
|
var Internal = {
|
1564
1728
|
convertFileSource: index.convertFileSource,
|
1565
1729
|
getSchema: index.getSchema,
|
@@ -1572,11 +1736,29 @@ var Internal = {
|
|
1572
1736
|
createValPathOfItem: ops.createValPathOfItem,
|
1573
1737
|
getSHA256Hash: getSHA256Hash,
|
1574
1738
|
initSchema: initSchema,
|
1739
|
+
notFileOp: function notFileOp(op) {
|
1740
|
+
return op.op !== "file";
|
1741
|
+
},
|
1742
|
+
isFileOp: function isFileOp(op) {
|
1743
|
+
return op.op === "file" && typeof op.filePath === "string";
|
1744
|
+
},
|
1575
1745
|
createPatchJSONPath: function createPatchJSONPath(modulePath) {
|
1576
1746
|
return "/".concat(modulePath.split(".").map(function (segment) {
|
1577
1747
|
return segment && tryJsonParse(segment);
|
1578
1748
|
}).join("/"));
|
1579
1749
|
},
|
1750
|
+
createPatchPath: function createPatchPath(modulePath) {
|
1751
|
+
return ops.parsePath(modulePath);
|
1752
|
+
},
|
1753
|
+
patchPathToModulePath: function patchPathToModulePath(patchPath) {
|
1754
|
+
return patchPath.map(function (segment) {
|
1755
|
+
// TODO: I am worried that something is lost here: what if the segment is a string that happens to be a parsable as a number? We could make those keys illegal?
|
1756
|
+
if (Number.isInteger(Number(segment))) {
|
1757
|
+
return segment;
|
1758
|
+
}
|
1759
|
+
return JSON.stringify(segment);
|
1760
|
+
}).join(".");
|
1761
|
+
},
|
1580
1762
|
VAL_ENABLE_COOKIE_NAME: "val_enable",
|
1581
1763
|
VAL_STATE_COOKIE: "val_state",
|
1582
1764
|
VAL_SESSION_COOKIE: "val_session"
|
@@ -1604,10 +1786,12 @@ exports.Schema = index.Schema;
|
|
1604
1786
|
exports.VAL_EXTENSION = index.VAL_EXTENSION;
|
1605
1787
|
exports.expr = expr_dist_valbuildCoreExpr.index;
|
1606
1788
|
exports.BooleanSchema = BooleanSchema;
|
1789
|
+
exports.FATAL_ERROR_TYPES = FATAL_ERROR_TYPES;
|
1607
1790
|
exports.Internal = Internal;
|
1608
1791
|
exports.NumberSchema = NumberSchema;
|
1609
1792
|
exports.RT_IMAGE_TAG = RT_IMAGE_TAG;
|
1610
1793
|
exports.StringSchema = StringSchema;
|
1611
1794
|
exports.ValApi = ValApi;
|
1612
1795
|
exports.derefPatch = derefPatch;
|
1796
|
+
exports.deserializeSchema = deserializeSchema;
|
1613
1797
|
exports.initVal = initVal;
|