@revisium/schema-toolkit 0.21.0 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/{chunk-SBO2UMI3.cjs → chunk-2PIMJSWJ.cjs} +0 -2
  2. package/dist/chunk-3MJP73IJ.js +1 -0
  3. package/dist/{chunk-62A5JJJ3.js → chunk-4U2RZHMX.js} +0 -2
  4. package/dist/{chunk-Q2UOTIMG.js → chunk-5DUMJHCA.js} +0 -2
  5. package/dist/{chunk-Z7M4ZGC6.cjs → chunk-7JWCZZPJ.cjs} +21 -23
  6. package/dist/{chunk-YFWOURZL.js → chunk-7PEC6ZYY.js} +0 -2
  7. package/dist/chunk-AV5EZUMZ.cjs +2 -0
  8. package/dist/{chunk-TMCRV6V5.js → chunk-AWFMSOHM.js} +0 -2
  9. package/dist/{chunk-X2VRR7V7.cjs → chunk-ERW5XVED.cjs} +0 -2
  10. package/dist/{chunk-XNFSFT7T.cjs → chunk-EVD5ZI55.cjs} +0 -2
  11. package/dist/{chunk-ZRNFSUOV.cjs → chunk-FL6PWPVJ.cjs} +0 -2
  12. package/dist/{chunk-TKMR6CQW.js → chunk-FTBRJODD.js} +0 -2
  13. package/dist/{chunk-R3MS2N4A.js → chunk-GJM63Q4K.js} +0 -2
  14. package/dist/{chunk-F4POD7AE.cjs → chunk-HJFM6E5M.cjs} +243 -90
  15. package/dist/{chunk-3DDUT57J.cjs → chunk-ITYABUR5.cjs} +0 -2
  16. package/dist/{chunk-BIBFHULN.js → chunk-IZMBM36H.js} +0 -2
  17. package/dist/chunk-J4RVO37K.cjs +2 -0
  18. package/dist/{chunk-UTSL45Q4.js → chunk-JLXX3SGF.js} +2 -4
  19. package/dist/{chunk-DRPNJ4YP.js → chunk-NO655UI5.js} +0 -2
  20. package/dist/chunk-OAUVP6CU.js +1 -0
  21. package/dist/{chunk-HH2LDPVV.cjs → chunk-ONW2OVNQ.cjs} +0 -2
  22. package/dist/{chunk-32FZHFIO.cjs → chunk-QKA7DJDN.cjs} +0 -2
  23. package/dist/{chunk-JWYYVKRT.cjs → chunk-RCCBUOGY.cjs} +0 -2
  24. package/dist/{chunk-MK3IKVZO.js → chunk-REVQG2NY.js} +176 -23
  25. package/dist/{chunk-IPL2CGVA.cjs → chunk-RQBW7ATZ.cjs} +0 -2
  26. package/dist/{chunk-WSPFHUHU.cjs → chunk-T3QQSHAC.cjs} +0 -2
  27. package/dist/{chunk-CGVYS7EK.cjs → chunk-VMELKZXD.cjs} +0 -2
  28. package/dist/{chunk-5VDDLW7U.js → chunk-WE4OLW5U.js} +0 -2
  29. package/dist/{chunk-JUOGJFTL.js → chunk-XKWWCXGB.js} +0 -2
  30. package/dist/{chunk-ZBPUTF3Q.js → chunk-ZPRBA4AQ.js} +0 -2
  31. package/dist/consts/index.cjs +4 -6
  32. package/dist/consts/index.js +2 -4
  33. package/dist/core/index.cjs +65 -67
  34. package/dist/core/index.js +4 -6
  35. package/dist/formula/index.cjs +7 -9
  36. package/dist/formula/index.js +1 -3
  37. package/dist/index.cjs +245 -247
  38. package/dist/index.d.cts +1 -1
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +15 -17
  41. package/dist/lib/index.cjs +51 -53
  42. package/dist/lib/index.js +7 -9
  43. package/dist/mocks/index.cjs +21 -23
  44. package/dist/mocks/index.js +2 -4
  45. package/dist/model/index.cjs +76 -78
  46. package/dist/model/index.d.cts +17 -4
  47. package/dist/model/index.d.ts +17 -4
  48. package/dist/model/index.js +4 -6
  49. package/dist/plugins/index.cjs +20 -22
  50. package/dist/plugins/index.js +2 -4
  51. package/dist/{typed-LSaUJayS.d.cts → typed-DjSH_5Vh.d.cts} +50 -3
  52. package/dist/{typed-BinPIf3R.d.ts → typed-KUia-LYN.d.ts} +50 -3
  53. package/dist/types/index.cjs +4 -6
  54. package/dist/types/index.d.cts +1 -1
  55. package/dist/types/index.d.ts +1 -1
  56. package/dist/types/index.js +2 -4
  57. package/dist/validation-schemas/index.cjs +18 -20
  58. package/dist/validation-schemas/index.js +1 -3
  59. package/package.json +1 -1
  60. package/dist/chunk-2NARA22J.js +0 -3
  61. package/dist/chunk-2NARA22J.js.map +0 -1
  62. package/dist/chunk-32FZHFIO.cjs.map +0 -1
  63. package/dist/chunk-3DDUT57J.cjs.map +0 -1
  64. package/dist/chunk-3FJZMVWA.js +0 -3
  65. package/dist/chunk-3FJZMVWA.js.map +0 -1
  66. package/dist/chunk-5VDDLW7U.js.map +0 -1
  67. package/dist/chunk-62A5JJJ3.js.map +0 -1
  68. package/dist/chunk-BIBFHULN.js.map +0 -1
  69. package/dist/chunk-BZWL424W.cjs +0 -4
  70. package/dist/chunk-BZWL424W.cjs.map +0 -1
  71. package/dist/chunk-CGVYS7EK.cjs.map +0 -1
  72. package/dist/chunk-DRPNJ4YP.js.map +0 -1
  73. package/dist/chunk-F4POD7AE.cjs.map +0 -1
  74. package/dist/chunk-HH2LDPVV.cjs.map +0 -1
  75. package/dist/chunk-IPL2CGVA.cjs.map +0 -1
  76. package/dist/chunk-JUOGJFTL.js.map +0 -1
  77. package/dist/chunk-JWYYVKRT.cjs.map +0 -1
  78. package/dist/chunk-L6HE7QPU.cjs +0 -4
  79. package/dist/chunk-L6HE7QPU.cjs.map +0 -1
  80. package/dist/chunk-MK3IKVZO.js.map +0 -1
  81. package/dist/chunk-Q2UOTIMG.js.map +0 -1
  82. package/dist/chunk-R3MS2N4A.js.map +0 -1
  83. package/dist/chunk-SBO2UMI3.cjs.map +0 -1
  84. package/dist/chunk-TKMR6CQW.js.map +0 -1
  85. package/dist/chunk-TMCRV6V5.js.map +0 -1
  86. package/dist/chunk-UTSL45Q4.js.map +0 -1
  87. package/dist/chunk-WSPFHUHU.cjs.map +0 -1
  88. package/dist/chunk-X2VRR7V7.cjs.map +0 -1
  89. package/dist/chunk-XNFSFT7T.cjs.map +0 -1
  90. package/dist/chunk-YFWOURZL.js.map +0 -1
  91. package/dist/chunk-Z7M4ZGC6.cjs.map +0 -1
  92. package/dist/chunk-ZBPUTF3Q.js.map +0 -1
  93. package/dist/chunk-ZRNFSUOV.cjs.map +0 -1
  94. package/dist/consts/index.cjs.map +0 -1
  95. package/dist/consts/index.js.map +0 -1
  96. package/dist/core/index.cjs.map +0 -1
  97. package/dist/core/index.js.map +0 -1
  98. package/dist/formula/index.cjs.map +0 -1
  99. package/dist/formula/index.js.map +0 -1
  100. package/dist/index.cjs.map +0 -1
  101. package/dist/index.js.map +0 -1
  102. package/dist/lib/index.cjs.map +0 -1
  103. package/dist/lib/index.js.map +0 -1
  104. package/dist/mocks/index.cjs.map +0 -1
  105. package/dist/mocks/index.js.map +0 -1
  106. package/dist/model/index.cjs.map +0 -1
  107. package/dist/model/index.js.map +0 -1
  108. package/dist/plugins/index.cjs.map +0 -1
  109. package/dist/plugins/index.js.map +0 -1
  110. package/dist/types/index.cjs.map +0 -1
  111. package/dist/types/index.js.map +0 -1
  112. package/dist/validation-schemas/index.cjs.map +0 -1
  113. package/dist/validation-schemas/index.js.map +0 -1
@@ -163,5 +163,3 @@ exports.rowPublishedAtSchema = rowPublishedAtSchema;
163
163
  exports.rowSchemaHashSchema = rowSchemaHashSchema;
164
164
  exports.rowUpdatedAtSchema = rowUpdatedAtSchema;
165
165
  exports.rowVersionIdSchema = rowVersionIdSchema;
166
- //# sourceMappingURL=chunk-3DDUT57J.cjs.map
167
- //# sourceMappingURL=chunk-3DDUT57J.cjs.map
@@ -87,5 +87,3 @@ var arr = (items, options) => getArraySchema(items, options);
87
87
  var ref = ($ref, options) => getRefSchema($ref, options);
88
88
 
89
89
  export { arr, bool, boolFormula, getAddPatch, getArraySchema, getBooleanSchema, getMovePatch, getNumberSchema, getObjectSchema, getRefSchema, getRemovePatch, getReplacePatch, getStringSchema, num, numFormula, obj, ref, str, strFormula };
90
- //# sourceMappingURL=chunk-BIBFHULN.js.map
91
- //# sourceMappingURL=chunk-BIBFHULN.js.map
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -1,5 +1,5 @@
1
- import { fileSchema, rowSchemaHashSchema, rowHashSchema, rowUpdatedAtSchema, rowPublishedAtSchema, rowCreatedAtSchema, rowCreatedIdSchema, rowVersionIdSchema, rowIdSchema } from './chunk-62A5JJJ3.js';
2
- import { JsonArrayStore, JsonObjectStore, JsonStringStore, JsonNumberStore, JsonBooleanStore, JsonObjectValueStore, JsonArrayValueStore, createJsonValueStore, getTransformation } from './chunk-TKMR6CQW.js';
1
+ import { fileSchema, rowSchemaHashSchema, rowHashSchema, rowUpdatedAtSchema, rowPublishedAtSchema, rowCreatedAtSchema, rowCreatedIdSchema, rowVersionIdSchema, rowIdSchema } from './chunk-4U2RZHMX.js';
2
+ import { JsonArrayStore, JsonObjectStore, JsonStringStore, JsonNumberStore, JsonBooleanStore, JsonObjectValueStore, JsonArrayValueStore, createJsonValueStore, getTransformation } from './chunk-FTBRJODD.js';
3
3
 
4
4
  // src/lib/createJsonSchemaStore.ts
5
5
  var createJsonSchemaStore = (schema, refs = {}) => {
@@ -731,5 +731,3 @@ var SchemaTable = class {
731
731
  };
732
732
 
733
733
  export { SchemaTable, VALIDATE_JSON_FIELD_NAME_ERROR_MESSAGE, applyAddPatch, applyMovePatch, applyRemovePatch, applyReplacePatch, convertJsonPathToSchemaPath, convertSchemaPathToJsonPath, createJsonObjectSchemaStore, createJsonSchemaStore, createPrimitiveStoreBySchema, deepEqual, getDBJsonPathByJsonSchemaStore, getForeignKeyPatchesFromSchema, getForeignKeysFromSchema, getForeignKeysFromValue, getInvalidFieldNamesInSchema, getJsonSchemaStoreByPath, getJsonValueStoreByPath, getParentForPath, getPathByStore, getValueByPath, hasPath, parsePath, pluginRefs, replaceForeignKeyValue, resolveRefs, saveSharedFields, setValueByPath, traverseStore, traverseValue, validateJsonFieldName };
734
- //# sourceMappingURL=chunk-UTSL45Q4.js.map
735
- //# sourceMappingURL=chunk-UTSL45Q4.js.map
@@ -9,5 +9,3 @@ var JsonSchemaTypeName = /* @__PURE__ */ ((JsonSchemaTypeName2) => {
9
9
  })(JsonSchemaTypeName || {});
10
10
 
11
11
  export { JsonSchemaTypeName };
12
- //# sourceMappingURL=chunk-DRPNJ4YP.js.map
13
- //# sourceMappingURL=chunk-DRPNJ4YP.js.map
@@ -0,0 +1 @@
1
+
@@ -789,5 +789,3 @@ exports.fromStringToBoolean = fromStringToBoolean;
789
789
  exports.fromStringToNumber = fromStringToNumber;
790
790
  exports.getTransformation = getTransformation;
791
791
  exports.toArrayTransformation = toArrayTransformation;
792
- //# sourceMappingURL=chunk-HH2LDPVV.cjs.map
793
- //# sourceMappingURL=chunk-HH2LDPVV.cjs.map
@@ -414,5 +414,3 @@ exports.stringMetaSchema = stringMetaSchema;
414
414
  exports.tableMigrationsSchema = tableMigrationsSchema;
415
415
  exports.xFormulaRequiresReadOnly = xFormulaRequiresReadOnly;
416
416
  exports.xFormulaSchema = xFormulaSchema;
417
- //# sourceMappingURL=chunk-32FZHFIO.cjs.map
418
- //# sourceMappingURL=chunk-32FZHFIO.cjs.map
@@ -2741,5 +2741,3 @@ exports.runInAction = runInAction;
2741
2741
  exports.setReactivityProvider = setReactivityProvider;
2742
2742
  exports.validateFormulas = validateFormulas;
2743
2743
  exports.validateSchema = validateSchema;
2744
- //# sourceMappingURL=chunk-JWYYVKRT.cjs.map
2745
- //# sourceMappingURL=chunk-JWYYVKRT.cjs.map
@@ -1,7 +1,8 @@
1
- import { AbstractBasePath, EMPTY_PATH, FormulaError, ResolvedDependency, FormulaSerializer, createRefNode, createObjectNode, createArrayNode, createStringNode, createNumberNode, createBooleanNode, observable, makeObservable, makeAutoObservable, runInAction, PatchBuilder, SchemaSerializer, createSchemaTree, NULL_NODE, validateSchema, validateFormulas, reaction } from './chunk-TMCRV6V5.js';
2
- import { obj, ref } from './chunk-BIBFHULN.js';
1
+ import { AbstractBasePath, EMPTY_PATH, FormulaError, ResolvedDependency, FormulaSerializer, createRefNode, createObjectNode, createArrayNode, createStringNode, createNumberNode, createBooleanNode, observable, makeObservable, makeAutoObservable, runInAction, PatchBuilder, SchemaSerializer, createSchemaTree, NULL_NODE, validateSchema, validateFormulas, reaction } from './chunk-AWFMSOHM.js';
2
+ import { obj, ref } from './chunk-IZMBM36H.js';
3
3
  import { nanoid } from 'nanoid';
4
4
  import { parseFormula, parseExpression, evaluateWithContext } from '@revisium/formula';
5
+ import { EventEmitter } from 'eventemitter3';
5
6
 
6
7
  var ARRAY_NOTATION_REGEX = /^([^[]+)\[(?:\d+|\*)?\]$/;
7
8
  var FormulaPath = class {
@@ -1598,8 +1599,6 @@ var FormulaEngine = class {
1598
1599
  this.disposers = [];
1599
1600
  }
1600
1601
  };
1601
-
1602
- // src/model/value-node/BaseValueNode.ts
1603
1602
  var nodeIdCounter = 0;
1604
1603
  function generateNodeId() {
1605
1604
  return `node-${++nodeIdCounter}`;
@@ -1612,11 +1611,21 @@ var BaseValueNode = class {
1612
1611
  schema;
1613
1612
  _parent = null;
1614
1613
  _name;
1614
+ _emitter = new EventEmitter();
1615
1615
  constructor(id, name, schema) {
1616
1616
  this.id = id ?? generateNodeId();
1617
1617
  this._name = name;
1618
1618
  this.schema = schema;
1619
1619
  }
1620
+ on(event, listener) {
1621
+ this._emitter.on(event, listener);
1622
+ }
1623
+ off(event, listener) {
1624
+ this._emitter.off(event, listener);
1625
+ }
1626
+ emit(changeEvent) {
1627
+ this._emitter.emit("change", changeEvent);
1628
+ }
1620
1629
  get parent() {
1621
1630
  return this._parent;
1622
1631
  }
@@ -1722,6 +1731,7 @@ var ArrayValueNode = class extends BaseValueNode {
1722
1731
  push(node) {
1723
1732
  node.parent = this;
1724
1733
  this._items.push(node);
1734
+ this.emit({ type: "arrayPush", array: this, item: node });
1725
1735
  }
1726
1736
  insertAt(index, node) {
1727
1737
  if (index < 0 || index > this._items.length) {
@@ -1729,6 +1739,7 @@ var ArrayValueNode = class extends BaseValueNode {
1729
1739
  }
1730
1740
  node.parent = this;
1731
1741
  this._items.splice(index, 0, node);
1742
+ this.emit({ type: "arrayInsert", array: this, index, item: node });
1732
1743
  }
1733
1744
  removeAt(index) {
1734
1745
  if (index < 0 || index >= this._items.length) {
@@ -1738,6 +1749,7 @@ var ArrayValueNode = class extends BaseValueNode {
1738
1749
  if (removed) {
1739
1750
  removed.parent = null;
1740
1751
  }
1752
+ this.emit({ type: "arrayRemove", array: this, index, item: removed });
1741
1753
  }
1742
1754
  move(fromIndex, toIndex) {
1743
1755
  if (fromIndex < 0 || fromIndex >= this._items.length) {
@@ -1753,23 +1765,25 @@ var ArrayValueNode = class extends BaseValueNode {
1753
1765
  if (item) {
1754
1766
  this._items.splice(toIndex, 0, item);
1755
1767
  }
1768
+ this.emit({ type: "arrayMove", array: this, fromIndex, toIndex });
1756
1769
  }
1757
1770
  replaceAt(index, node) {
1758
1771
  if (index < 0 || index >= this._items.length) {
1759
1772
  throw new Error(`Index out of bounds: ${index}`);
1760
1773
  }
1761
1774
  const oldNode = this._items[index];
1762
- if (oldNode) {
1763
- oldNode.parent = null;
1764
- }
1775
+ oldNode.parent = null;
1765
1776
  node.parent = this;
1766
1777
  this._items[index] = node;
1778
+ this.emit({ type: "arrayReplace", array: this, index, item: node, oldItem: oldNode });
1767
1779
  }
1768
1780
  clear() {
1769
- for (const item of this._items) {
1781
+ const removed = [...this._items];
1782
+ for (const item of removed) {
1770
1783
  item.parent = null;
1771
1784
  }
1772
1785
  this._items.length = 0;
1786
+ this.emit({ type: "arrayClear", array: this, items: removed });
1773
1787
  }
1774
1788
  setNodeFactory(factory) {
1775
1789
  this._nodeFactory = factory;
@@ -1936,6 +1950,9 @@ var BasePrimitiveValueNode = class extends BaseValueNode {
1936
1950
  return this._baseValue;
1937
1951
  }
1938
1952
  get isDirty() {
1953
+ if (this.formula !== void 0) {
1954
+ return false;
1955
+ }
1939
1956
  return this._value !== this._baseValue;
1940
1957
  }
1941
1958
  get formula() {
@@ -1955,7 +1972,11 @@ var BasePrimitiveValueNode = class extends BaseValueNode {
1955
1972
  if (this.isReadOnly && !options?.internal) {
1956
1973
  throw new Error(`Cannot set value on read-only field: ${this.name}`);
1957
1974
  }
1975
+ const oldValue = this._value;
1958
1976
  this._value = this.coerceValue(value);
1977
+ if (!options?.internal) {
1978
+ this.emit({ type: "setValue", node: this, value: this._value, oldValue });
1979
+ }
1959
1980
  }
1960
1981
  setFormulaWarning(warning) {
1961
1982
  this._formulaWarning = warning;
@@ -2306,12 +2327,14 @@ var ObjectValueNode = class extends BaseValueNode {
2306
2327
  }
2307
2328
  node.parent = this;
2308
2329
  this._children.set(node.name, node);
2330
+ this.emit({ type: "addChild", parent: this, child: node });
2309
2331
  }
2310
2332
  removeChild(name) {
2311
2333
  const node = this._children.get(name);
2312
2334
  if (node) {
2313
2335
  node.parent = null;
2314
2336
  this._children.delete(name);
2337
+ this.emit({ type: "removeChild", parent: this, childName: name, child: node });
2315
2338
  }
2316
2339
  }
2317
2340
  setValue(value, options) {
@@ -2675,6 +2698,9 @@ function parseValuePath(path) {
2675
2698
  // src/model/value-tree/ChangeTracker.ts
2676
2699
  var ChangeTracker = class {
2677
2700
  _changes = [];
2701
+ constructor() {
2702
+ makeAutoObservable(this);
2703
+ }
2678
2704
  get changes() {
2679
2705
  return this._changes;
2680
2706
  }
@@ -2687,7 +2713,7 @@ var ChangeTracker = class {
2687
2713
  clear() {
2688
2714
  this._changes = [];
2689
2715
  }
2690
- toPatches() {
2716
+ get patches() {
2691
2717
  const patches = [];
2692
2718
  for (const change of this._changes) {
2693
2719
  const converted = this.changeToPatch(change);
@@ -2837,16 +2863,21 @@ var ValueTree = class {
2837
2863
  this._root = _root;
2838
2864
  this.index = new TreeIndex(_root);
2839
2865
  this.changeTracker = new ChangeTracker();
2866
+ this._nodeChangeListener = (event) => this.handleNodeChange(event);
2867
+ this.subscribe(this._root);
2840
2868
  makeAutoObservable(this, {
2841
2869
  _root: false,
2842
2870
  index: false,
2843
- changeTracker: false,
2844
- _formulaEngine: false
2871
+ _nodeChangeListener: false,
2872
+ _formulaEngine: false,
2873
+ _suppressEvents: false
2845
2874
  });
2846
2875
  }
2847
2876
  index;
2848
2877
  changeTracker;
2878
+ _nodeChangeListener;
2849
2879
  _formulaEngine = null;
2880
+ _suppressEvents = false;
2850
2881
  get root() {
2851
2882
  return this._root;
2852
2883
  }
@@ -2890,12 +2921,17 @@ var ValueTree = class {
2890
2921
  throw new Error(`Path not found: ${path}`);
2891
2922
  }
2892
2923
  const oldValue = node.getPlainValue();
2893
- if (node.isPrimitive()) {
2894
- node.setValue(value, options);
2895
- } else if (node.isObject()) {
2896
- node.setValue(value, options);
2897
- } else if (node.isArray()) {
2898
- node.setValue(value, options);
2924
+ this._suppressEvents = true;
2925
+ try {
2926
+ if (node.isPrimitive()) {
2927
+ node.setValue(value, options);
2928
+ } else if (node.isObject()) {
2929
+ node.setValue(value, options);
2930
+ } else if (node.isArray()) {
2931
+ node.setValue(value, options);
2932
+ }
2933
+ } finally {
2934
+ this._suppressEvents = false;
2899
2935
  }
2900
2936
  this.changeTracker.track({
2901
2937
  type: "setValue",
@@ -2920,8 +2956,8 @@ var ValueTree = class {
2920
2956
  get errors() {
2921
2957
  return this._root.errors;
2922
2958
  }
2923
- getPatches() {
2924
- return this.changeTracker.toPatches();
2959
+ get patches() {
2960
+ return this.changeTracker.patches;
2925
2961
  }
2926
2962
  trackChange(change) {
2927
2963
  this.changeTracker.track(change);
@@ -2934,11 +2970,13 @@ var ValueTree = class {
2934
2970
  this.changeTracker.clear();
2935
2971
  }
2936
2972
  revert() {
2973
+ this.unsubscribe(this._root);
2937
2974
  const root = this._root;
2938
2975
  if ("revert" in root && typeof root.revert === "function") {
2939
2976
  root.revert();
2940
2977
  }
2941
2978
  this.changeTracker.clear();
2979
+ this.subscribe(this._root);
2942
2980
  }
2943
2981
  rebuildIndex() {
2944
2982
  this.index.rebuild();
@@ -2956,9 +2994,126 @@ var ValueTree = class {
2956
2994
  return this._formulaEngine;
2957
2995
  }
2958
2996
  dispose() {
2997
+ this.unsubscribe(this._root);
2959
2998
  this._formulaEngine?.dispose();
2960
2999
  this._formulaEngine = null;
2961
3000
  }
3001
+ handleNodeChange(event) {
3002
+ if (this._suppressEvents) {
3003
+ return;
3004
+ }
3005
+ switch (event.type) {
3006
+ case "setValue": {
3007
+ this.changeTracker.track({
3008
+ type: "setValue",
3009
+ path: this.index.pathOf(event.node),
3010
+ value: event.value,
3011
+ oldValue: event.oldValue
3012
+ });
3013
+ break;
3014
+ }
3015
+ case "addChild": {
3016
+ this.adoptNode(event.child);
3017
+ this.changeTracker.track({
3018
+ type: "addProperty",
3019
+ path: this.index.pathOf(event.parent).child(event.child.name),
3020
+ value: event.child.getPlainValue()
3021
+ });
3022
+ break;
3023
+ }
3024
+ case "removeChild": {
3025
+ this.unsubscribe(event.child);
3026
+ this.changeTracker.track({
3027
+ type: "removeProperty",
3028
+ path: this.index.pathOf(event.parent).child(event.childName)
3029
+ });
3030
+ break;
3031
+ }
3032
+ case "arrayPush":
3033
+ case "arrayInsert": {
3034
+ this.adoptNode(event.item);
3035
+ this.index.invalidatePathsUnder(event.array);
3036
+ this.changeTracker.track(
3037
+ this.toArrayItemChange(event)
3038
+ );
3039
+ break;
3040
+ }
3041
+ case "arrayReplace": {
3042
+ this.unsubscribe(event.oldItem);
3043
+ this.adoptNode(event.item);
3044
+ this.index.invalidatePathsUnder(event.array);
3045
+ this.changeTracker.track({
3046
+ type: "arrayReplace",
3047
+ path: this.index.pathOf(event.array),
3048
+ index: event.index,
3049
+ value: event.item.getPlainValue()
3050
+ });
3051
+ break;
3052
+ }
3053
+ case "arrayRemove": {
3054
+ this.unsubscribe(event.item);
3055
+ this.index.invalidatePathsUnder(event.array);
3056
+ this.changeTracker.track(
3057
+ this.toArrayStructureChange(event)
3058
+ );
3059
+ break;
3060
+ }
3061
+ case "arrayMove": {
3062
+ this.index.invalidatePathsUnder(event.array);
3063
+ this.changeTracker.track(
3064
+ this.toArrayStructureChange(event)
3065
+ );
3066
+ break;
3067
+ }
3068
+ case "arrayClear": {
3069
+ for (const item of event.items) {
3070
+ this.unsubscribe(item);
3071
+ }
3072
+ this.changeTracker.track({
3073
+ type: "arrayClear",
3074
+ path: this.index.pathOf(event.array)
3075
+ });
3076
+ break;
3077
+ }
3078
+ }
3079
+ }
3080
+ toArrayItemChange(event) {
3081
+ const path = this.index.pathOf(event.array);
3082
+ const value = event.item.getPlainValue();
3083
+ if (event.type === "arrayPush") {
3084
+ return { type: "arrayPush", path, value };
3085
+ }
3086
+ return { type: "arrayInsert", path, index: event.index, value };
3087
+ }
3088
+ toArrayStructureChange(event) {
3089
+ const path = this.index.pathOf(event.array);
3090
+ if (event.type === "arrayRemove") {
3091
+ return { type: "arrayRemove", path, index: event.index };
3092
+ }
3093
+ return { type: "arrayMove", path, fromIndex: event.fromIndex, toIndex: event.toIndex };
3094
+ }
3095
+ adoptNode(node) {
3096
+ this.subscribe(node);
3097
+ this.index.registerNode(node);
3098
+ }
3099
+ walkTree(node, visit) {
3100
+ visit(node);
3101
+ if (node.isObject()) {
3102
+ for (const child of node.children) {
3103
+ this.walkTree(child, visit);
3104
+ }
3105
+ } else if (node.isArray()) {
3106
+ for (const item of node.value) {
3107
+ this.walkTree(item, visit);
3108
+ }
3109
+ }
3110
+ }
3111
+ subscribe(node) {
3112
+ this.walkTree(node, (n) => n.on("change", this._nodeChangeListener));
3113
+ }
3114
+ unsubscribe(node) {
3115
+ this.walkTree(node, (n) => n.off("change", this._nodeChangeListener));
3116
+ }
2962
3117
  };
2963
3118
 
2964
3119
  // src/model/table/row/RowModelImpl.ts
@@ -3033,8 +3188,8 @@ var RowModelImpl = class {
3033
3188
  get errors() {
3034
3189
  return this._tree.errors;
3035
3190
  }
3036
- getPatches() {
3037
- return this._tree.getPatches();
3191
+ get patches() {
3192
+ return this._tree.patches;
3038
3193
  }
3039
3194
  commit() {
3040
3195
  this._tree.commit();
@@ -3604,5 +3759,3 @@ function createTypedTree(schema, data, options) {
3604
3759
  }
3605
3760
 
3606
3761
  export { ArrayToItemsTypeTransformer, ArrayValueNode, BasePrimitiveValueNode, BaseValueNode, BooleanValueNode, DataModelImpl, DefaultTransformer, ForeignKeyNotFoundError, ForeignKeyResolverImpl, ForeignKeyResolverNotConfiguredError, ForeignKeyValueNodeImpl, FormulaChangeDetector, FormulaDependencyIndex, FormulaPath, NodeFactory, NodeFactory2, NodeFactoryRegistry, NumberValueNode, ObjectToArrayTransformer, ObjectValueNode, ParsedFormula, PrimitiveToArrayTransformer, RefTransformer, RowModelImpl, SchemaParser, StringValueNode, TableModelImpl, TypeTransformChain, ValueTree, ValueType, createDataModel, createDefaultRegistry, createForeignKeyResolver, createNodeFactory, createRowModel, createSchemaModel, createTableModel, createTypeTransformChain, createTypedTree, extractFormulaDefinition, generateDefaultValue, generateNodeId, isForeignKeyValueNode, resetNodeIdCounter, typedNode };
3607
- //# sourceMappingURL=chunk-MK3IKVZO.js.map
3608
- //# sourceMappingURL=chunk-MK3IKVZO.js.map
@@ -7,5 +7,3 @@ var CustomSchemeKeywords = /* @__PURE__ */ ((CustomSchemeKeywords2) => {
7
7
  })(CustomSchemeKeywords || {});
8
8
 
9
9
  exports.CustomSchemeKeywords = CustomSchemeKeywords;
10
- //# sourceMappingURL=chunk-IPL2CGVA.cjs.map
11
- //# sourceMappingURL=chunk-IPL2CGVA.cjs.map
@@ -126,5 +126,3 @@ function deepEqual(a, b) {
126
126
  }
127
127
 
128
128
  exports.computeValueDiff = computeValueDiff;
129
- //# sourceMappingURL=chunk-WSPFHUHU.cjs.map
130
- //# sourceMappingURL=chunk-WSPFHUHU.cjs.map
@@ -11,5 +11,3 @@ var JsonSchemaTypeName = /* @__PURE__ */ ((JsonSchemaTypeName2) => {
11
11
  })(JsonSchemaTypeName || {});
12
12
 
13
13
  exports.JsonSchemaTypeName = JsonSchemaTypeName;
14
- //# sourceMappingURL=chunk-CGVYS7EK.cjs.map
15
- //# sourceMappingURL=chunk-CGVYS7EK.cjs.map
@@ -5,5 +5,3 @@ var CustomSchemeKeywords = /* @__PURE__ */ ((CustomSchemeKeywords2) => {
5
5
  })(CustomSchemeKeywords || {});
6
6
 
7
7
  export { CustomSchemeKeywords };
8
- //# sourceMappingURL=chunk-5VDDLW7U.js.map
9
- //# sourceMappingURL=chunk-5VDDLW7U.js.map
@@ -396,5 +396,3 @@ var tableMigrationsSchema = {
396
396
  };
397
397
 
398
398
  export { arrayMetaSchema, baseStringFields, booleanMetaSchema, foreignKeyExcludesFormula, historyPatchesSchema, jsonPatchSchema, metaSchema, noForeignKeyStringMetaSchema, notForeignKeyMetaSchema, numberMetaSchema, objectMetaSchema, refMetaSchema, sharedFields, stringMetaSchema, tableMigrationsSchema, xFormulaRequiresReadOnly, xFormulaSchema };
399
- //# sourceMappingURL=chunk-JUOGJFTL.js.map
400
- //# sourceMappingURL=chunk-JUOGJFTL.js.map
@@ -7,5 +7,3 @@ var FieldChangeType = /* @__PURE__ */ ((FieldChangeType2) => {
7
7
  })(FieldChangeType || {});
8
8
 
9
9
  export { FieldChangeType };
10
- //# sourceMappingURL=chunk-ZBPUTF3Q.js.map
11
- //# sourceMappingURL=chunk-ZBPUTF3Q.js.map
@@ -1,17 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkIPL2CGVA_cjs = require('../chunk-IPL2CGVA.cjs');
4
- var chunkXNFSFT7T_cjs = require('../chunk-XNFSFT7T.cjs');
3
+ var chunkRQBW7ATZ_cjs = require('../chunk-RQBW7ATZ.cjs');
4
+ var chunkEVD5ZI55_cjs = require('../chunk-EVD5ZI55.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "CustomSchemeKeywords", {
9
9
  enumerable: true,
10
- get: function () { return chunkIPL2CGVA_cjs.CustomSchemeKeywords; }
10
+ get: function () { return chunkRQBW7ATZ_cjs.CustomSchemeKeywords; }
11
11
  });
12
12
  Object.defineProperty(exports, "SystemSchemaIds", {
13
13
  enumerable: true,
14
- get: function () { return chunkXNFSFT7T_cjs.SystemSchemaIds; }
14
+ get: function () { return chunkEVD5ZI55_cjs.SystemSchemaIds; }
15
15
  });
16
- //# sourceMappingURL=index.cjs.map
17
- //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,2 @@
1
- export { CustomSchemeKeywords } from '../chunk-5VDDLW7U.js';
2
- export { SystemSchemaIds } from '../chunk-Q2UOTIMG.js';
3
- //# sourceMappingURL=index.js.map
4
- //# sourceMappingURL=index.js.map
1
+ export { CustomSchemeKeywords } from '../chunk-WE4OLW5U.js';
2
+ export { SystemSchemaIds } from '../chunk-5DUMJHCA.js';