@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.
@@ -1,8 +1,8 @@
1
- import { a as array, o as object, u as union, r as richtext$1, i as image$1, l as literal, b as record, d as define, P as PatchError, n as newSelectorProxy, c as createValPathOfItem, e as isSelector, g as getSource, f as resolvePath, s as splitModuleIdAndModulePath } from './ops-a042c33f.esm.js';
2
- export { A as ArraySchema, I as ImageSchema, L as LiteralSchema, O as ObjectSchema, R as RecordSchema, h as RichTextSchema, U as UnionSchema } from './ops-a042c33f.esm.js';
3
- import { _ as _inherits, a as _classCallCheck, b as _callSuper, c as _createClass, d as _defineProperty, e as _typeof, S as Schema, G as GetSchema, g as getValPath, f as file, V as VAL_EXTENSION, F as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, i as file$1, j as _slicedToArray, k as isFile, P as Path, l as GetSource, m as isSerializedVal, n as convertFileSource, o as getSchema, p as isVal } from './index-b88673ad.esm.js';
4
- export { F as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, r as FileSchema, q as GenericSelector, S as Schema, V as VAL_EXTENSION } from './index-b88673ad.esm.js';
5
- export { i as expr } from './index-cdc3515c.esm.js';
1
+ import { a as array, o as object, u as union, r as richtext$1, i as image$1, l as literal, b as record, d as define, P as PatchError, n as newSelectorProxy, c as createValPathOfItem, e as isSelector, I as ImageSchema, R as RecordSchema, f as RichTextSchema, U as UnionSchema, A as ArraySchema, O as ObjectSchema, L as LiteralSchema, g as getSource, h as resolvePath, s as splitModuleIdAndModulePath, p as parsePath } from './ops-25e75394.esm.js';
2
+ export { A as ArraySchema, I as ImageSchema, L as LiteralSchema, O as ObjectSchema, R as RecordSchema, f as RichTextSchema, U as UnionSchema } from './ops-25e75394.esm.js';
3
+ import { _ as _inherits, a as _classCallCheck, b as _callSuper, c as _createClass, d as _defineProperty, e as _typeof, S as Schema, G as GetSchema, g as getValPath, f as file, V as VAL_EXTENSION, F as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, i as file$1, j as _slicedToArray, k as isFile, P as Path, l as GetSource, m as isSerializedVal, n as FileSchema, o as _objectSpread2, p as convertFileSource, q as getSchema, r as isVal } from './index-c6d9700a.esm.js';
4
+ export { F as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, n as FileSchema, s as GenericSelector, S as Schema, V as VAL_EXTENSION } from './index-c6d9700a.esm.js';
5
+ export { i as expr } from './index-0c827e64.esm.js';
6
6
  import { _ as _createForOfIteratorHelper, i as isErr, a as isOk, e as err, o as ok, r as result } from './result-b96df128.esm.js';
7
7
 
8
8
  var NumberSchema = /*#__PURE__*/function (_Schema) {
@@ -206,12 +206,13 @@ var _boolean = function _boolean() {
206
206
 
207
207
  var KeyOfSchema = /*#__PURE__*/function (_Schema) {
208
208
  _inherits(KeyOfSchema, _Schema);
209
- function KeyOfSchema(selector) {
209
+ function KeyOfSchema(schema, sourcePath) {
210
210
  var _this;
211
- var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
211
+ var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
212
212
  _classCallCheck(this, KeyOfSchema);
213
213
  _this = _callSuper(this, KeyOfSchema);
214
- _this.selector = selector;
214
+ _this.schema = schema;
215
+ _this.sourcePath = sourcePath;
215
216
  _this.opt = opt;
216
217
  return _this;
217
218
  }
@@ -221,13 +222,12 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
221
222
  if (this.opt && (src === null || src === undefined)) {
222
223
  return false;
223
224
  }
224
- var schema = this.selector[GetSchema];
225
- if (!schema) {
225
+ if (!this.schema) {
226
226
  return _defineProperty({}, path, [{
227
227
  message: "Schema not found for module. keyOf must be used with a Val Module"
228
228
  }]);
229
229
  }
230
- var serializedSchema = schema.serialize();
230
+ var serializedSchema = this.schema;
231
231
  if (!(serializedSchema.type === "array" || serializedSchema.type === "object" || serializedSchema.type === "record")) {
232
232
  return _defineProperty({}, path, [{
233
233
  message: "Schema in keyOf must be an 'array', 'object' or 'record'. Found '".concat(serializedSchema.type, "'")
@@ -262,11 +262,11 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
262
262
  if (this.opt && (src === null || src === undefined)) {
263
263
  return true;
264
264
  }
265
- var schema = this.selector[GetSchema];
265
+ var schema = this.schema;
266
266
  if (!schema) {
267
267
  return false;
268
268
  }
269
- var serializedSchema = schema.serialize();
269
+ var serializedSchema = schema;
270
270
  if (!(serializedSchema.type === "array" || serializedSchema.type === "object" || serializedSchema.type === "record")) {
271
271
  return false;
272
272
  }
@@ -290,22 +290,21 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
290
290
  }, {
291
291
  key: "optional",
292
292
  value: function optional() {
293
- return new KeyOfSchema(this.selector, true);
293
+ return new KeyOfSchema(this.schema, undefined, true);
294
294
  }
295
295
  }, {
296
296
  key: "serialize",
297
297
  value: function serialize() {
298
- var _this$selector$GetSch;
299
- var path = getValPath(this.selector);
298
+ var path = this.sourcePath;
300
299
  if (!path) {
301
300
  throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module.");
302
301
  }
303
- var serializedSubSchema = (_this$selector$GetSch = this.selector[GetSchema]) === null || _this$selector$GetSch === void 0 ? void 0 : _this$selector$GetSch.serialize();
304
- if (!serializedSubSchema) {
302
+ var serializedSchema = this.schema;
303
+ if (!serializedSchema) {
305
304
  throw new Error("Cannot serialize oneOf schema with empty selector.");
306
305
  }
307
306
  var values;
308
- switch (serializedSubSchema.type) {
307
+ switch (serializedSchema.type) {
309
308
  case "array":
310
309
  values = "number";
311
310
  break;
@@ -313,14 +312,15 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
313
312
  values = "string";
314
313
  break;
315
314
  case "object":
316
- values = Object.keys(serializedSubSchema.items);
315
+ values = Object.keys(serializedSchema.items);
317
316
  break;
318
317
  default:
319
- throw new Error("Cannot serialize oneOf schema with selector of type '".concat(serializedSubSchema.type, "'. keyOf must be used with a Val Module."));
318
+ throw new Error("Cannot serialize oneOf schema with selector of type '".concat(serializedSchema.type, "'. keyOf must be used with a Val Module."));
320
319
  }
321
320
  return {
322
321
  type: "keyOf",
323
- selector: path,
322
+ path: path,
323
+ schema: serializedSchema,
324
324
  opt: this.opt,
325
325
  values: values
326
326
  };
@@ -329,7 +329,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
329
329
  return KeyOfSchema;
330
330
  }(Schema);
331
331
  var keyOf = function keyOf(valModule) {
332
- return new KeyOfSchema(valModule);
332
+ var _valModule$GetSchema;
333
+ return new KeyOfSchema(valModule === null || valModule === void 0 || (_valModule$GetSchema = valModule[GetSchema]) === null || _valModule$GetSchema === void 0 ? void 0 : _valModule$GetSchema.serialize(), getValPath(valModule));
333
334
  };
334
335
 
335
336
  // import type { F } from "ts-toolbelt";
@@ -416,7 +417,7 @@ function link(text, _ref) {
416
417
  // };
417
418
 
418
419
  // TODO: Rename to createValSystem (only to be used by internal things), we can then export * from '@valbuild/core' in the next package then.
419
- var initVal = function initVal() {
420
+ var initVal = function initVal(config) {
420
421
  // const locales = options?.locales;
421
422
  var s = initSchema();
422
423
  // if (locales?.required) {
@@ -450,7 +451,7 @@ var initVal = function initVal() {
450
451
  }
451
452
  },
452
453
  s: s,
453
- config: {}
454
+ config: config
454
455
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
455
456
  };
456
457
  };
@@ -1039,6 +1040,53 @@ var getSHA256Hash = function getSHA256Hash(bits) {
1039
1040
  return createHash().update(bits).digest("hex");
1040
1041
  };
1041
1042
 
1043
+ function deserializeSchema(serialized) {
1044
+ var _serialized$options;
1045
+ switch (serialized.type) {
1046
+ case "string":
1047
+ return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
1048
+ 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)
1049
+ }), serialized.opt);
1050
+ case "literal":
1051
+ return new LiteralSchema(serialized.value, serialized.opt);
1052
+ case "boolean":
1053
+ return new BooleanSchema(serialized.opt);
1054
+ case "number":
1055
+ return new NumberSchema(serialized.options, serialized.opt);
1056
+ case "object":
1057
+ return new ObjectSchema(Object.fromEntries(Object.entries(serialized.items).map(function (_ref) {
1058
+ var _ref2 = _slicedToArray(_ref, 2),
1059
+ key = _ref2[0],
1060
+ item = _ref2[1];
1061
+ return [key, deserializeSchema(item)];
1062
+ })), serialized.opt);
1063
+ case "array":
1064
+ return new ArraySchema(deserializeSchema(serialized.item), serialized.opt);
1065
+ case "union":
1066
+ return new UnionSchema(typeof serialized.key === "string" ? serialized.key : deserializeSchema(serialized.key), serialized.items.map(deserializeSchema), serialized.opt);
1067
+ case "richtext":
1068
+ return new RichTextSchema(serialized.options, serialized.opt);
1069
+ case "record":
1070
+ return new RecordSchema(deserializeSchema(serialized.item), serialized.opt);
1071
+ case "keyOf":
1072
+ return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt);
1073
+ case "file":
1074
+ return new FileSchema(serialized.options, serialized.opt);
1075
+ case "image":
1076
+ return new ImageSchema(serialized.options, serialized.opt);
1077
+ default:
1078
+ {
1079
+ var exhaustiveCheck = serialized;
1080
+ var unknownSerialized = exhaustiveCheck;
1081
+ if (unknownSerialized && _typeof(unknownSerialized) === "object" && "type" in unknownSerialized) {
1082
+ throw new Error("Unknown schema type: ".concat(unknownSerialized.type));
1083
+ } else {
1084
+ throw new Error("Unknown schema: ".concat(JSON.stringify(unknownSerialized, null, 2)));
1085
+ }
1086
+ }
1087
+ }
1088
+ }
1089
+
1042
1090
  function _regeneratorRuntime() {
1043
1091
  _regeneratorRuntime = function () {
1044
1092
  return e;
@@ -1423,6 +1471,37 @@ var ValApi = /*#__PURE__*/function () {
1423
1471
  }
1424
1472
  return getPatches;
1425
1473
  }()
1474
+ }, {
1475
+ key: "deletePatches",
1476
+ value: function () {
1477
+ var _deletePatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ids, headers) {
1478
+ var params;
1479
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1480
+ while (1) switch (_context2.prev = _context2.next) {
1481
+ case 0:
1482
+ params = new URLSearchParams();
1483
+ ids.forEach(function (id) {
1484
+ return params.append("id", id);
1485
+ });
1486
+ return _context2.abrupt("return", fetch("".concat(this.host, "/patches/~?").concat(params), {
1487
+ method: "DELETE",
1488
+ headers: headers || {
1489
+ "Content-Type": "application/json"
1490
+ }
1491
+ }).then(function (res) {
1492
+ return parse(res);
1493
+ })["catch"](createError));
1494
+ case 3:
1495
+ case "end":
1496
+ return _context2.stop();
1497
+ }
1498
+ }, _callee2, this);
1499
+ }));
1500
+ function deletePatches(_x2, _x3) {
1501
+ return _deletePatches.apply(this, arguments);
1502
+ }
1503
+ return deletePatches;
1504
+ }()
1426
1505
  }, {
1427
1506
  key: "getEditUrl",
1428
1507
  value: function getEditUrl() {
@@ -1437,9 +1516,22 @@ var ValApi = /*#__PURE__*/function () {
1437
1516
  },
1438
1517
  method: "POST",
1439
1518
  body: JSON.stringify(_defineProperty({}, moduleId, patches))
1440
- }).then(function (res) {
1441
- return parse(res);
1442
- })["catch"](createError);
1519
+ }).then( /*#__PURE__*/function () {
1520
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(res) {
1521
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1522
+ while (1) switch (_context3.prev = _context3.next) {
1523
+ case 0:
1524
+ return _context3.abrupt("return", parse(res));
1525
+ case 1:
1526
+ case "end":
1527
+ return _context3.stop();
1528
+ }
1529
+ }, _callee3);
1530
+ }));
1531
+ return function (_x4) {
1532
+ return _ref2.apply(this, arguments);
1533
+ };
1534
+ }())["catch"](createError);
1443
1535
  }
1444
1536
  }, {
1445
1537
  key: "getSession",
@@ -1450,16 +1542,16 @@ var ValApi = /*#__PURE__*/function () {
1450
1542
  }
1451
1543
  }, {
1452
1544
  key: "getTree",
1453
- value: function getTree(_ref2) {
1454
- var _ref2$patch = _ref2.patch,
1455
- patch = _ref2$patch === void 0 ? false : _ref2$patch,
1456
- _ref2$includeSchema = _ref2.includeSchema,
1457
- includeSchema = _ref2$includeSchema === void 0 ? false : _ref2$includeSchema,
1458
- _ref2$includeSource = _ref2.includeSource,
1459
- includeSource = _ref2$includeSource === void 0 ? false : _ref2$includeSource,
1460
- _ref2$treePath = _ref2.treePath,
1461
- treePath = _ref2$treePath === void 0 ? "/" : _ref2$treePath,
1462
- headers = _ref2.headers;
1545
+ value: function getTree(_ref3) {
1546
+ var _ref3$patch = _ref3.patch,
1547
+ patch = _ref3$patch === void 0 ? false : _ref3$patch,
1548
+ _ref3$includeSchema = _ref3.includeSchema,
1549
+ includeSchema = _ref3$includeSchema === void 0 ? false : _ref3$includeSchema,
1550
+ _ref3$includeSource = _ref3.includeSource,
1551
+ includeSource = _ref3$includeSource === void 0 ? false : _ref3$includeSource,
1552
+ _ref3$treePath = _ref3.treePath,
1553
+ treePath = _ref3$treePath === void 0 ? "/" : _ref3$treePath,
1554
+ headers = _ref3.headers;
1463
1555
  var params = new URLSearchParams();
1464
1556
  params.set("patch", patch.toString());
1465
1557
  params.set("schema", includeSchema.toString());
@@ -1472,9 +1564,9 @@ var ValApi = /*#__PURE__*/function () {
1472
1564
  }
1473
1565
  }, {
1474
1566
  key: "postCommit",
1475
- value: function postCommit(_ref3) {
1476
- var patches = _ref3.patches,
1477
- headers = _ref3.headers;
1567
+ value: function postCommit(_ref4) {
1568
+ var patches = _ref4.patches,
1569
+ headers = _ref4.headers;
1478
1570
  return fetch("".concat(this.host, "/commit"), {
1479
1571
  method: "POST",
1480
1572
  body: JSON.stringify({
@@ -1483,9 +1575,75 @@ var ValApi = /*#__PURE__*/function () {
1483
1575
  headers: headers || {
1484
1576
  "Content-Type": "application/json"
1485
1577
  }
1486
- }).then(function (res) {
1487
- return parse(res);
1488
- })["catch"](createError);
1578
+ }).then( /*#__PURE__*/function () {
1579
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(res) {
1580
+ var jsonRes;
1581
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1582
+ while (1) switch (_context4.prev = _context4.next) {
1583
+ case 0:
1584
+ if (!res.ok) {
1585
+ _context4.next = 4;
1586
+ break;
1587
+ }
1588
+ return _context4.abrupt("return", parse(res));
1589
+ case 4:
1590
+ if (!(res.status === 400 && res.headers.get("content-type") === "application/json")) {
1591
+ _context4.next = 13;
1592
+ break;
1593
+ }
1594
+ _context4.next = 7;
1595
+ return res.json();
1596
+ case 7:
1597
+ jsonRes = _context4.sent;
1598
+ if (!("validationErrors" in jsonRes)) {
1599
+ _context4.next = 12;
1600
+ break;
1601
+ }
1602
+ return _context4.abrupt("return", err(jsonRes));
1603
+ case 12:
1604
+ return _context4.abrupt("return", formatError(res.status, jsonRes, res.statusText));
1605
+ case 13:
1606
+ return _context4.abrupt("return", parse(res));
1607
+ case 14:
1608
+ case "end":
1609
+ return _context4.stop();
1610
+ }
1611
+ }, _callee4);
1612
+ }));
1613
+ return function (_x5) {
1614
+ return _ref5.apply(this, arguments);
1615
+ };
1616
+ }())["catch"](createError);
1617
+ }
1618
+ }, {
1619
+ key: "postValidate",
1620
+ value: function postValidate(_ref6) {
1621
+ var patches = _ref6.patches,
1622
+ headers = _ref6.headers;
1623
+ return fetch("".concat(this.host, "/validate"), {
1624
+ method: "POST",
1625
+ body: JSON.stringify({
1626
+ patches: patches
1627
+ }),
1628
+ headers: headers || {
1629
+ "Content-Type": "application/json"
1630
+ }
1631
+ }).then( /*#__PURE__*/function () {
1632
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(res) {
1633
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1634
+ while (1) switch (_context5.prev = _context5.next) {
1635
+ case 0:
1636
+ return _context5.abrupt("return", parse(res));
1637
+ case 1:
1638
+ case "end":
1639
+ return _context5.stop();
1640
+ }
1641
+ }, _callee5);
1642
+ }));
1643
+ return function (_x6) {
1644
+ return _ref7.apply(this, arguments);
1645
+ };
1646
+ }())["catch"](createError);
1489
1647
  }
1490
1648
  }]);
1491
1649
  return ValApi;
@@ -1497,67 +1655,73 @@ function createError(err$1) {
1497
1655
  });
1498
1656
  }
1499
1657
 
1658
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1659
+ function formatError(status, json, statusText) {
1660
+ return err({
1661
+ statusCode: status,
1662
+ message: json.message || statusText,
1663
+ details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref8) {
1664
+ var _ref9 = _slicedToArray(_ref8, 1),
1665
+ key = _ref9[0];
1666
+ return key !== "message";
1667
+ }))
1668
+ });
1669
+ }
1670
+
1500
1671
  // TODO: validate
1501
- function parse(_x2) {
1672
+ function parse(_x7) {
1502
1673
  return _parse.apply(this, arguments);
1503
1674
  }
1504
1675
  function _parse() {
1505
- _parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(res) {
1676
+ _parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(res) {
1506
1677
  var json;
1507
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1508
- while (1) switch (_context2.prev = _context2.next) {
1678
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1679
+ while (1) switch (_context6.prev = _context6.next) {
1509
1680
  case 0:
1510
- _context2.prev = 0;
1681
+ _context6.prev = 0;
1511
1682
  if (!res.ok) {
1512
- _context2.next = 9;
1683
+ _context6.next = 9;
1513
1684
  break;
1514
1685
  }
1515
- _context2.t0 = result;
1516
- _context2.next = 5;
1686
+ _context6.t0 = result;
1687
+ _context6.next = 5;
1517
1688
  return res.json();
1518
1689
  case 5:
1519
- _context2.t1 = _context2.sent;
1520
- return _context2.abrupt("return", _context2.t0.ok.call(_context2.t0, _context2.t1));
1690
+ _context6.t1 = _context6.sent;
1691
+ return _context6.abrupt("return", _context6.t0.ok.call(_context6.t0, _context6.t1));
1521
1692
  case 9:
1522
- _context2.prev = 9;
1523
- _context2.next = 12;
1693
+ _context6.prev = 9;
1694
+ _context6.next = 12;
1524
1695
  return res.json();
1525
1696
  case 12:
1526
- json = _context2.sent;
1527
- return _context2.abrupt("return", err({
1528
- statusCode: res.status,
1529
- message: json.message || res.statusText,
1530
- details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref4) {
1531
- var _ref5 = _slicedToArray(_ref4, 1),
1532
- key = _ref5[0];
1533
- return key !== "message";
1534
- }))
1535
- }));
1697
+ json = _context6.sent;
1698
+ return _context6.abrupt("return", formatError(res.status, json, res.statusText));
1536
1699
  case 16:
1537
- _context2.prev = 16;
1538
- _context2.t2 = _context2["catch"](9);
1539
- return _context2.abrupt("return", err({
1700
+ _context6.prev = 16;
1701
+ _context6.t2 = _context6["catch"](9);
1702
+ return _context6.abrupt("return", err({
1540
1703
  statusCode: res.status,
1541
1704
  message: res.statusText
1542
1705
  }));
1543
1706
  case 19:
1544
- _context2.next = 24;
1707
+ _context6.next = 24;
1545
1708
  break;
1546
1709
  case 21:
1547
- _context2.prev = 21;
1548
- _context2.t3 = _context2["catch"](0);
1549
- return _context2.abrupt("return", err({
1550
- message: _context2.t3 instanceof Error ? _context2.t3.message : "Unknown error"
1710
+ _context6.prev = 21;
1711
+ _context6.t3 = _context6["catch"](0);
1712
+ return _context6.abrupt("return", err({
1713
+ message: _context6.t3 instanceof Error ? _context6.t3.message : "Unknown error"
1551
1714
  }));
1552
1715
  case 24:
1553
1716
  case "end":
1554
- return _context2.stop();
1717
+ return _context6.stop();
1555
1718
  }
1556
- }, _callee2, null, [[0, 21], [9, 16]]);
1719
+ }, _callee6, null, [[0, 21], [9, 16]]);
1557
1720
  }));
1558
1721
  return _parse.apply(this, arguments);
1559
1722
  }
1560
1723
 
1724
+ var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
1561
1725
  var Internal = {
1562
1726
  convertFileSource: convertFileSource,
1563
1727
  getSchema: getSchema,
@@ -1570,11 +1734,29 @@ var Internal = {
1570
1734
  createValPathOfItem: createValPathOfItem,
1571
1735
  getSHA256Hash: getSHA256Hash,
1572
1736
  initSchema: initSchema,
1737
+ notFileOp: function notFileOp(op) {
1738
+ return op.op !== "file";
1739
+ },
1740
+ isFileOp: function isFileOp(op) {
1741
+ return op.op === "file" && typeof op.filePath === "string";
1742
+ },
1573
1743
  createPatchJSONPath: function createPatchJSONPath(modulePath) {
1574
1744
  return "/".concat(modulePath.split(".").map(function (segment) {
1575
1745
  return segment && tryJsonParse(segment);
1576
1746
  }).join("/"));
1577
1747
  },
1748
+ createPatchPath: function createPatchPath(modulePath) {
1749
+ return parsePath(modulePath);
1750
+ },
1751
+ patchPathToModulePath: function patchPathToModulePath(patchPath) {
1752
+ return patchPath.map(function (segment) {
1753
+ // 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?
1754
+ if (Number.isInteger(Number(segment))) {
1755
+ return segment;
1756
+ }
1757
+ return JSON.stringify(segment);
1758
+ }).join(".");
1759
+ },
1578
1760
  VAL_ENABLE_COOKIE_NAME: "val_enable",
1579
1761
  VAL_STATE_COOKIE: "val_state",
1580
1762
  VAL_SESSION_COOKIE: "val_session"
@@ -1587,4 +1769,4 @@ function tryJsonParse(str) {
1587
1769
  }
1588
1770
  }
1589
1771
 
1590
- export { BooleanSchema, Internal, NumberSchema, RT_IMAGE_TAG, StringSchema, ValApi, derefPatch, initVal };
1772
+ export { BooleanSchema, FATAL_ERROR_TYPES, Internal, NumberSchema, RT_IMAGE_TAG, StringSchema, ValApi, derefPatch, deserializeSchema, initVal };
@@ -1,3 +1,3 @@
1
- export { e as evaluate, p as parse } from '../../dist/index-cdc3515c.esm.js';
2
- export { C as Call, E as Expr, N as NilSym, u as StringLiteral, v as StringTemplate, t as Sym } from '../../dist/index-b88673ad.esm.js';
1
+ export { e as evaluate, p as parse } from '../../dist/index-0c827e64.esm.js';
2
+ export { C as Call, E as Expr, N as NilSym, u as StringLiteral, v as StringTemplate, t as Sym } from '../../dist/index-c6d9700a.esm.js';
3
3
  import '../../dist/result-b96df128.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/core",
3
- "version": "0.58.0",
3
+ "version": "0.60.0",
4
4
  "private": false,
5
5
  "description": "Val - supercharged hard-coded content",
6
6
  "scripts": {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var index = require('../../dist/index-ae994fd0.cjs.dev.js');
6
6
  var result = require('../../dist/result-48320acd.cjs.dev.js');
7
7
  var util = require('../../dist/util-b213092b.cjs.dev.js');
8
- var ops = require('../../dist/ops-36bf1f3c.cjs.dev.js');
8
+ var ops = require('../../dist/ops-9e41e1f9.cjs.dev.js');
9
9
 
10
10
  function isNotRoot(path) {
11
11
  return result.isNonEmpty(path);
@@ -100,6 +100,9 @@ function replaceInNode(node, key, value) {
100
100
  node[key] = value;
101
101
  return result.ok(_replaced);
102
102
  } else {
103
+ console.log({
104
+ node: node
105
+ });
103
106
  return result.err(new ops.PatchError("Cannot replace object element which does not exist"));
104
107
  }
105
108
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var index = require('../../dist/index-0c2d9420.cjs.prod.js');
6
6
  var result = require('../../dist/result-26f67b40.cjs.prod.js');
7
7
  var util = require('../../dist/util-030d8a1f.cjs.prod.js');
8
- var ops = require('../../dist/ops-cdc83cb6.cjs.prod.js');
8
+ var ops = require('../../dist/ops-8fd18dcf.cjs.prod.js');
9
9
 
10
10
  function isNotRoot(path) {
11
11
  return result.isNonEmpty(path);
@@ -100,6 +100,9 @@ function replaceInNode(node, key, value) {
100
100
  node[key] = value;
101
101
  return result.ok(_replaced);
102
102
  } else {
103
+ console.log({
104
+ node: node
105
+ });
103
106
  return result.err(new ops.PatchError("Cannot replace object element which does not exist"));
104
107
  }
105
108
  }
@@ -1,8 +1,8 @@
1
- import { e as _typeof, j as _slicedToArray, c as _createClass, a as _classCallCheck, w as _toConsumableArray } from '../../dist/index-b88673ad.esm.js';
1
+ import { e as _typeof, j as _slicedToArray, c as _createClass, a as _classCallCheck, w as _toConsumableArray } from '../../dist/index-c6d9700a.esm.js';
2
2
  import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-b96df128.esm.js';
3
3
  import { p as pipe } from '../../dist/util-18613e99.esm.js';
4
- import { P as PatchError, s as splitModuleIdAndModulePath } from '../../dist/ops-a042c33f.esm.js';
5
- export { P as PatchError } from '../../dist/ops-a042c33f.esm.js';
4
+ import { P as PatchError, s as splitModuleIdAndModulePath } from '../../dist/ops-25e75394.esm.js';
5
+ export { P as PatchError } from '../../dist/ops-25e75394.esm.js';
6
6
 
7
7
  function isNotRoot(path) {
8
8
  return isNonEmpty(path);
@@ -97,6 +97,9 @@ function replaceInNode(node, key, value) {
97
97
  node[key] = value;
98
98
  return ok(_replaced);
99
99
  } else {
100
+ console.log({
101
+ node: node
102
+ });
100
103
  return err(new PatchError("Cannot replace object element which does not exist"));
101
104
  }
102
105
  }