@revisium/schema-toolkit 0.21.0 → 0.21.1

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-MK3IKVZO.js → chunk-HFMZITNE.js} +168 -17
  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-IPL2CGVA.cjs → chunk-RQBW7ATZ.cjs} +0 -2
  25. package/dist/{chunk-F4POD7AE.cjs → chunk-S5SRXND6.cjs} +235 -84
  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 +15 -2
  47. package/dist/model/index.d.ts +15 -2
  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-BinPIf3R.d.ts → typed-BRZhUqGG.d.ts} +48 -1
  52. package/dist/{typed-LSaUJayS.d.cts → typed-Cri0IYAn.d.cts} +48 -1
  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
@@ -107,5 +107,3 @@ exports.obj = obj;
107
107
  exports.ref = ref;
108
108
  exports.str = str;
109
109
  exports.strFormula = strFormula;
110
- //# sourceMappingURL=chunk-SBO2UMI3.cjs.map
111
- //# sourceMappingURL=chunk-SBO2UMI3.cjs.map
@@ -0,0 +1 @@
1
+
@@ -144,5 +144,3 @@ var ajvFileSchema = {
144
144
  };
145
145
 
146
146
  export { ajvFileSchema, ajvRowCreatedAtSchema, ajvRowCreatedIdSchema, ajvRowHashSchema, ajvRowIdSchema, ajvRowPublishedAtSchema, ajvRowSchemaHashSchema, ajvRowUpdatedAtSchema, ajvRowVersionIdSchema, fileSchema, rowCreatedAtSchema, rowCreatedIdSchema, rowHashSchema, rowIdSchema, rowPublishedAtSchema, rowSchemaHashSchema, rowUpdatedAtSchema, rowVersionIdSchema };
147
- //# sourceMappingURL=chunk-62A5JJJ3.js.map
148
- //# sourceMappingURL=chunk-62A5JJJ3.js.map
@@ -13,5 +13,3 @@ var SystemSchemaIds = /* @__PURE__ */ ((SystemSchemaIds2) => {
13
13
  })(SystemSchemaIds || {});
14
14
 
15
15
  export { SystemSchemaIds };
16
- //# sourceMappingURL=chunk-Q2UOTIMG.js.map
17
- //# sourceMappingURL=chunk-Q2UOTIMG.js.map
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk3DDUT57J_cjs = require('./chunk-3DDUT57J.cjs');
4
- var chunkHH2LDPVV_cjs = require('./chunk-HH2LDPVV.cjs');
3
+ var chunkITYABUR5_cjs = require('./chunk-ITYABUR5.cjs');
4
+ var chunkONW2OVNQ_cjs = require('./chunk-ONW2OVNQ.cjs');
5
5
 
6
6
  // src/lib/createJsonSchemaStore.ts
7
7
  var createJsonSchemaStore = (schema, refs = {}) => {
@@ -20,7 +20,7 @@ var createJsonSchemaStore = (schema, refs = {}) => {
20
20
  return objectStore;
21
21
  } else if (schema.type === "array") {
22
22
  const itemsStore = createJsonSchemaStore(schema.items, refs);
23
- const arrayStore = new chunkHH2LDPVV_cjs.JsonArrayStore(itemsStore);
23
+ const arrayStore = new chunkONW2OVNQ_cjs.JsonArrayStore(itemsStore);
24
24
  saveSharedFields(arrayStore, schema);
25
25
  return arrayStore;
26
26
  } else {
@@ -31,7 +31,7 @@ var createJsonSchemaStore = (schema, refs = {}) => {
31
31
  }
32
32
  };
33
33
  var createJsonObjectSchemaStore = (value, refs) => {
34
- const store = new chunkHH2LDPVV_cjs.JsonObjectStore();
34
+ const store = new chunkONW2OVNQ_cjs.JsonObjectStore();
35
35
  for (const requiredField of value.required) {
36
36
  if (!value.properties[requiredField]) {
37
37
  throw new Error(
@@ -46,7 +46,7 @@ var createJsonObjectSchemaStore = (value, refs) => {
46
46
  };
47
47
  var createPrimitiveStoreBySchema = (schema) => {
48
48
  if (schema.type === "string") {
49
- const stringStore = new chunkHH2LDPVV_cjs.JsonStringStore();
49
+ const stringStore = new chunkONW2OVNQ_cjs.JsonStringStore();
50
50
  stringStore.foreignKey = schema.foreignKey;
51
51
  stringStore.format = schema.format;
52
52
  stringStore.enum = schema.enum;
@@ -55,11 +55,11 @@ var createPrimitiveStoreBySchema = (schema) => {
55
55
  stringStore["x-formula"] = schema["x-formula"];
56
56
  return stringStore;
57
57
  } else if (schema.type === "number") {
58
- const numberStore = new chunkHH2LDPVV_cjs.JsonNumberStore();
58
+ const numberStore = new chunkONW2OVNQ_cjs.JsonNumberStore();
59
59
  numberStore["x-formula"] = schema["x-formula"];
60
60
  return numberStore;
61
61
  } else if (schema.type === "boolean") {
62
- const booleanStore = new chunkHH2LDPVV_cjs.JsonBooleanStore();
62
+ const booleanStore = new chunkONW2OVNQ_cjs.JsonBooleanStore();
63
63
  booleanStore["x-formula"] = schema["x-formula"];
64
64
  return booleanStore;
65
65
  } else {
@@ -610,13 +610,13 @@ var getJsonValueStoreByPath = (root, path) => {
610
610
  const segments = parsePath(path);
611
611
  let current = root;
612
612
  for (const seg of segments) {
613
- if (current instanceof chunkHH2LDPVV_cjs.JsonObjectValueStore) {
613
+ if (current instanceof chunkONW2OVNQ_cjs.JsonObjectValueStore) {
614
614
  const next = current.value[String(seg)];
615
615
  if (!next) {
616
616
  throw new Error(`Path not found at segment "${seg}"`);
617
617
  }
618
618
  current = next;
619
- } else if (current instanceof chunkHH2LDPVV_cjs.JsonArrayValueStore) {
619
+ } else if (current instanceof chunkONW2OVNQ_cjs.JsonArrayValueStore) {
620
620
  if (typeof seg !== "number") {
621
621
  throw new Error(`Invalid array index "${seg}"`);
622
622
  }
@@ -646,15 +646,15 @@ var replaceForeignKeyValue = (options) => {
646
646
 
647
647
  // src/lib/resolveRefs.ts
648
648
  var pluginRefs = {
649
- ["urn:jsonschema:io:revisium:row-id-schema:1.0.0" /* RowId */]: chunk3DDUT57J_cjs.rowIdSchema,
650
- ["urn:jsonschema:io:revisium:row-version-id-schema:1.0.0" /* RowVersionId */]: chunk3DDUT57J_cjs.rowVersionIdSchema,
651
- ["urn:jsonschema:io:revisium:row-created-id-schema:1.0.0" /* RowCreatedId */]: chunk3DDUT57J_cjs.rowCreatedIdSchema,
652
- ["urn:jsonschema:io:revisium:row-created-at-schema:1.0.0" /* RowCreatedAt */]: chunk3DDUT57J_cjs.rowCreatedAtSchema,
653
- ["urn:jsonschema:io:revisium:row-published-at-schema:1.0.0" /* RowPublishedAt */]: chunk3DDUT57J_cjs.rowPublishedAtSchema,
654
- ["urn:jsonschema:io:revisium:row-updated-at-schema:1.0.0" /* RowUpdatedAt */]: chunk3DDUT57J_cjs.rowUpdatedAtSchema,
655
- ["urn:jsonschema:io:revisium:row-hash-schema:1.0.0" /* RowHash */]: chunk3DDUT57J_cjs.rowHashSchema,
656
- ["urn:jsonschema:io:revisium:row-schema-hash-schema:1.0.0" /* RowSchemaHash */]: chunk3DDUT57J_cjs.rowSchemaHashSchema,
657
- ["urn:jsonschema:io:revisium:file-schema:1.0.0" /* File */]: chunk3DDUT57J_cjs.fileSchema
649
+ ["urn:jsonschema:io:revisium:row-id-schema:1.0.0" /* RowId */]: chunkITYABUR5_cjs.rowIdSchema,
650
+ ["urn:jsonschema:io:revisium:row-version-id-schema:1.0.0" /* RowVersionId */]: chunkITYABUR5_cjs.rowVersionIdSchema,
651
+ ["urn:jsonschema:io:revisium:row-created-id-schema:1.0.0" /* RowCreatedId */]: chunkITYABUR5_cjs.rowCreatedIdSchema,
652
+ ["urn:jsonschema:io:revisium:row-created-at-schema:1.0.0" /* RowCreatedAt */]: chunkITYABUR5_cjs.rowCreatedAtSchema,
653
+ ["urn:jsonschema:io:revisium:row-published-at-schema:1.0.0" /* RowPublishedAt */]: chunkITYABUR5_cjs.rowPublishedAtSchema,
654
+ ["urn:jsonschema:io:revisium:row-updated-at-schema:1.0.0" /* RowUpdatedAt */]: chunkITYABUR5_cjs.rowUpdatedAtSchema,
655
+ ["urn:jsonschema:io:revisium:row-hash-schema:1.0.0" /* RowHash */]: chunkITYABUR5_cjs.rowHashSchema,
656
+ ["urn:jsonschema:io:revisium:row-schema-hash-schema:1.0.0" /* RowSchemaHash */]: chunkITYABUR5_cjs.rowSchemaHashSchema,
657
+ ["urn:jsonschema:io:revisium:file-schema:1.0.0" /* File */]: chunkITYABUR5_cjs.fileSchema
658
658
  };
659
659
  var resolveRefs = (schema) => {
660
660
  const store = createJsonSchemaStore(schema, pluginRefs);
@@ -700,7 +700,7 @@ var SchemaTable = class {
700
700
  return this.store.getPlainSchema();
701
701
  }
702
702
  addRow(rowId, data) {
703
- const row = chunkHH2LDPVV_cjs.createJsonValueStore(this.store, rowId, data);
703
+ const row = chunkONW2OVNQ_cjs.createJsonValueStore(this.store, rowId, data);
704
704
  this.rows.set(rowId, row);
705
705
  }
706
706
  getRow(id) {
@@ -717,14 +717,14 @@ var SchemaTable = class {
717
717
  }));
718
718
  }
719
719
  migrateRows(nextStore) {
720
- const transformation = chunkHH2LDPVV_cjs.getTransformation(this.store, nextStore);
720
+ const transformation = chunkONW2OVNQ_cjs.getTransformation(this.store, nextStore);
721
721
  if (transformation) {
722
722
  for (const [rowId, row] of this.rows) {
723
723
  const rawNextValue = transformation(
724
724
  row.getPlainValue(),
725
725
  nextStore.default
726
726
  );
727
- const nextRow = chunkHH2LDPVV_cjs.createJsonValueStore(nextStore, rowId, rawNextValue);
727
+ const nextRow = chunkONW2OVNQ_cjs.createJsonValueStore(nextStore, rowId, rawNextValue);
728
728
  this.rows.set(rowId, nextRow);
729
729
  }
730
730
  }
@@ -764,5 +764,3 @@ exports.setValueByPath = setValueByPath;
764
764
  exports.traverseStore = traverseStore;
765
765
  exports.traverseValue = traverseValue;
766
766
  exports.validateJsonFieldName = validateJsonFieldName;
767
- //# sourceMappingURL=chunk-Z7M4ZGC6.cjs.map
768
- //# sourceMappingURL=chunk-Z7M4ZGC6.cjs.map
@@ -124,5 +124,3 @@ function deepEqual(a, b) {
124
124
  }
125
125
 
126
126
  export { computeValueDiff };
127
- //# sourceMappingURL=chunk-YFWOURZL.js.map
128
- //# sourceMappingURL=chunk-YFWOURZL.js.map
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -2679,5 +2679,3 @@ function buildArrayItemsPath(parentPath) {
2679
2679
  }
2680
2680
 
2681
2681
  export { AbstractBasePath, ChangeCoalescer, ChangeCollector, CompositeRule, EMPTY_METADATA, EMPTY_PATH, EnumValidator, FIELD_NAME_ERROR_MESSAGE, ForeignKeyValidator, FormulaError, FormulaPathBuilder, FormulaSerializer, ItemsSegment, MaxLengthValidator, MaximumValidator, MinLengthValidator, MinimumValidator, NULL_NODE, NodePathIndex, PatchBuilder, PatchEnricher, PatchGenerator, PatternValidator, PropertySegment, RequiredValidator, ResolvedDependency, SchemaDiff, SchemaPropertyRule, SchemaSerializer, SchemaTruthyRule, ValidationEngine, ValidatorRegistry, ValidatorResolver, areNodesContentEqual, areNodesEqual, coalesceChanges, collectChanges, createArrayNode, createBooleanNode, createDefaultValidatorRegistry, createMobxProvider, createNumberNode, createObjectNode, createPath, createRefNode, createSchemaTree, createStringNode, createValidationEngine, isValidFieldName, jsonPointerToPath, jsonPointerToSegments, jsonPointerToSimplePath, makeAutoObservable, makeObservable, observable, reaction, resetReactivityProvider, runInAction, setReactivityProvider, validateFormulas, validateSchema };
2682
- //# sourceMappingURL=chunk-TMCRV6V5.js.map
2683
- //# sourceMappingURL=chunk-TMCRV6V5.js.map
@@ -678,5 +678,3 @@ exports.evaluateFormulas = evaluateFormulas;
678
678
  exports.extractSchemaFormulas = extractSchemaFormulas;
679
679
  exports.validateFormulaAgainstSchema = validateFormulaAgainstSchema;
680
680
  exports.validateSchemaFormulas = validateSchemaFormulas;
681
- //# sourceMappingURL=chunk-X2VRR7V7.cjs.map
682
- //# sourceMappingURL=chunk-X2VRR7V7.cjs.map
@@ -15,5 +15,3 @@ var SystemSchemaIds = /* @__PURE__ */ ((SystemSchemaIds2) => {
15
15
  })(SystemSchemaIds || {});
16
16
 
17
17
  exports.SystemSchemaIds = SystemSchemaIds;
18
- //# sourceMappingURL=chunk-XNFSFT7T.cjs.map
19
- //# sourceMappingURL=chunk-XNFSFT7T.cjs.map
@@ -9,5 +9,3 @@ var FieldChangeType = /* @__PURE__ */ ((FieldChangeType2) => {
9
9
  })(FieldChangeType || {});
10
10
 
11
11
  exports.FieldChangeType = FieldChangeType;
12
- //# sourceMappingURL=chunk-ZRNFSUOV.cjs.map
13
- //# sourceMappingURL=chunk-ZRNFSUOV.cjs.map
@@ -759,5 +759,3 @@ var JsonArrayValueStore = class {
759
759
  };
760
760
 
761
761
  export { JsonArrayStore, JsonArrayValueStore, JsonBooleanStore, JsonBooleanValueStore, JsonNumberStore, JsonNumberValueStore, JsonObjectStore, JsonObjectValueStore, JsonStringStore, JsonStringValueStore, addSharedFieldsFromState, createJsonArrayValueStore, createJsonObjectValueStore, createJsonValueStore, createPrimitiveValueStore, equal, fromArrayToObject, fromArrayTransformation, fromBooleanToNumber, fromBooleanToString, fromNumberToBoolean, fromNumberToString, fromObjectToArray, fromObjectToPrimitive, fromPrimitiveToObject, fromStringToBoolean, fromStringToNumber, getTransformation, toArrayTransformation };
762
- //# sourceMappingURL=chunk-TKMR6CQW.js.map
763
- //# sourceMappingURL=chunk-TKMR6CQW.js.map
@@ -668,5 +668,3 @@ function setValueByPath(obj, path, value) {
668
668
  }
669
669
 
670
670
  export { collectFormulaNodes, evaluateFormulas, extractSchemaFormulas, validateFormulaAgainstSchema, validateSchemaFormulas };
671
- //# sourceMappingURL=chunk-R3MS2N4A.js.map
672
- //# sourceMappingURL=chunk-R3MS2N4A.js.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) {
@@ -2837,16 +2860,22 @@ var ValueTree = class {
2837
2860
  this._root = _root;
2838
2861
  this.index = new TreeIndex(_root);
2839
2862
  this.changeTracker = new ChangeTracker();
2863
+ this._nodeChangeListener = (event) => this.handleNodeChange(event);
2864
+ this.subscribe(this._root);
2840
2865
  makeAutoObservable(this, {
2841
2866
  _root: false,
2842
2867
  index: false,
2843
2868
  changeTracker: false,
2844
- _formulaEngine: false
2869
+ _nodeChangeListener: false,
2870
+ _formulaEngine: false,
2871
+ _suppressEvents: false
2845
2872
  });
2846
2873
  }
2847
2874
  index;
2848
2875
  changeTracker;
2876
+ _nodeChangeListener;
2849
2877
  _formulaEngine = null;
2878
+ _suppressEvents = false;
2850
2879
  get root() {
2851
2880
  return this._root;
2852
2881
  }
@@ -2890,12 +2919,17 @@ var ValueTree = class {
2890
2919
  throw new Error(`Path not found: ${path}`);
2891
2920
  }
2892
2921
  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);
2922
+ this._suppressEvents = true;
2923
+ try {
2924
+ if (node.isPrimitive()) {
2925
+ node.setValue(value, options);
2926
+ } else if (node.isObject()) {
2927
+ node.setValue(value, options);
2928
+ } else if (node.isArray()) {
2929
+ node.setValue(value, options);
2930
+ }
2931
+ } finally {
2932
+ this._suppressEvents = false;
2899
2933
  }
2900
2934
  this.changeTracker.track({
2901
2935
  type: "setValue",
@@ -2934,11 +2968,13 @@ var ValueTree = class {
2934
2968
  this.changeTracker.clear();
2935
2969
  }
2936
2970
  revert() {
2971
+ this.unsubscribe(this._root);
2937
2972
  const root = this._root;
2938
2973
  if ("revert" in root && typeof root.revert === "function") {
2939
2974
  root.revert();
2940
2975
  }
2941
2976
  this.changeTracker.clear();
2977
+ this.subscribe(this._root);
2942
2978
  }
2943
2979
  rebuildIndex() {
2944
2980
  this.index.rebuild();
@@ -2956,9 +2992,126 @@ var ValueTree = class {
2956
2992
  return this._formulaEngine;
2957
2993
  }
2958
2994
  dispose() {
2995
+ this.unsubscribe(this._root);
2959
2996
  this._formulaEngine?.dispose();
2960
2997
  this._formulaEngine = null;
2961
2998
  }
2999
+ handleNodeChange(event) {
3000
+ if (this._suppressEvents) {
3001
+ return;
3002
+ }
3003
+ switch (event.type) {
3004
+ case "setValue": {
3005
+ this.changeTracker.track({
3006
+ type: "setValue",
3007
+ path: this.index.pathOf(event.node),
3008
+ value: event.value,
3009
+ oldValue: event.oldValue
3010
+ });
3011
+ break;
3012
+ }
3013
+ case "addChild": {
3014
+ this.adoptNode(event.child);
3015
+ this.changeTracker.track({
3016
+ type: "addProperty",
3017
+ path: this.index.pathOf(event.parent).child(event.child.name),
3018
+ value: event.child.getPlainValue()
3019
+ });
3020
+ break;
3021
+ }
3022
+ case "removeChild": {
3023
+ this.unsubscribe(event.child);
3024
+ this.changeTracker.track({
3025
+ type: "removeProperty",
3026
+ path: this.index.pathOf(event.parent).child(event.childName)
3027
+ });
3028
+ break;
3029
+ }
3030
+ case "arrayPush":
3031
+ case "arrayInsert": {
3032
+ this.adoptNode(event.item);
3033
+ this.index.invalidatePathsUnder(event.array);
3034
+ this.changeTracker.track(
3035
+ this.toArrayItemChange(event)
3036
+ );
3037
+ break;
3038
+ }
3039
+ case "arrayReplace": {
3040
+ this.unsubscribe(event.oldItem);
3041
+ this.adoptNode(event.item);
3042
+ this.index.invalidatePathsUnder(event.array);
3043
+ this.changeTracker.track({
3044
+ type: "arrayReplace",
3045
+ path: this.index.pathOf(event.array),
3046
+ index: event.index,
3047
+ value: event.item.getPlainValue()
3048
+ });
3049
+ break;
3050
+ }
3051
+ case "arrayRemove": {
3052
+ this.unsubscribe(event.item);
3053
+ this.index.invalidatePathsUnder(event.array);
3054
+ this.changeTracker.track(
3055
+ this.toArrayStructureChange(event)
3056
+ );
3057
+ break;
3058
+ }
3059
+ case "arrayMove": {
3060
+ this.index.invalidatePathsUnder(event.array);
3061
+ this.changeTracker.track(
3062
+ this.toArrayStructureChange(event)
3063
+ );
3064
+ break;
3065
+ }
3066
+ case "arrayClear": {
3067
+ for (const item of event.items) {
3068
+ this.unsubscribe(item);
3069
+ }
3070
+ this.changeTracker.track({
3071
+ type: "arrayClear",
3072
+ path: this.index.pathOf(event.array)
3073
+ });
3074
+ break;
3075
+ }
3076
+ }
3077
+ }
3078
+ toArrayItemChange(event) {
3079
+ const path = this.index.pathOf(event.array);
3080
+ const value = event.item.getPlainValue();
3081
+ if (event.type === "arrayPush") {
3082
+ return { type: "arrayPush", path, value };
3083
+ }
3084
+ return { type: "arrayInsert", path, index: event.index, value };
3085
+ }
3086
+ toArrayStructureChange(event) {
3087
+ const path = this.index.pathOf(event.array);
3088
+ if (event.type === "arrayRemove") {
3089
+ return { type: "arrayRemove", path, index: event.index };
3090
+ }
3091
+ return { type: "arrayMove", path, fromIndex: event.fromIndex, toIndex: event.toIndex };
3092
+ }
3093
+ adoptNode(node) {
3094
+ this.subscribe(node);
3095
+ this.index.registerNode(node);
3096
+ }
3097
+ walkTree(node, visit) {
3098
+ visit(node);
3099
+ if (node.isObject()) {
3100
+ for (const child of node.children) {
3101
+ this.walkTree(child, visit);
3102
+ }
3103
+ } else if (node.isArray()) {
3104
+ for (const item of node.value) {
3105
+ this.walkTree(item, visit);
3106
+ }
3107
+ }
3108
+ }
3109
+ subscribe(node) {
3110
+ this.walkTree(node, (n) => n.on("change", this._nodeChangeListener));
3111
+ }
3112
+ unsubscribe(node) {
3113
+ this.walkTree(node, (n) => n.off("change", this._nodeChangeListener));
3114
+ }
2962
3115
  };
2963
3116
 
2964
3117
  // src/model/table/row/RowModelImpl.ts
@@ -3604,5 +3757,3 @@ function createTypedTree(schema, data, options) {
3604
3757
  }
3605
3758
 
3606
3759
  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
@@ -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
@@ -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