@revisium/schema-toolkit 0.21.3 → 0.21.4

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,4 +1,4 @@
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';
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-MXEQ5CBK.js';
2
2
  import { obj, ref } from './chunk-IZMBM36H.js';
3
3
  import { nanoid } from 'nanoid';
4
4
  import { parseFormula, parseExpression, evaluateWithContext } from '@revisium/formula';
@@ -306,10 +306,17 @@ var SchemaParser = class {
306
306
  pendingFormulas = [];
307
307
  _parseErrors = [];
308
308
  _refSchemas = {};
309
+ _resolvingRefs = /* @__PURE__ */ new Set();
309
310
  parse(schema, refSchemas) {
310
311
  this.pendingFormulas = [];
311
312
  this._parseErrors = [];
312
313
  this._refSchemas = refSchemas ?? {};
314
+ this._resolvingRefs = /* @__PURE__ */ new Set();
315
+ for (const [refKey, refSchema] of Object.entries(this._refSchemas)) {
316
+ if (refSchema === schema) {
317
+ this._resolvingRefs.add(refKey);
318
+ }
319
+ }
313
320
  return this.parseNode(schema, "root");
314
321
  }
315
322
  parseFormulas(tree) {
@@ -338,7 +345,13 @@ var SchemaParser = class {
338
345
  const refValue = schema.$ref;
339
346
  const resolvedSchema = this._refSchemas[refValue];
340
347
  if (resolvedSchema) {
341
- return this.parseNode(resolvedSchema, name, refValue);
348
+ if (this._resolvingRefs.has(refValue)) {
349
+ return createRefNode(nanoid(), name, refValue, this.extractMetadata(schema));
350
+ }
351
+ this._resolvingRefs.add(refValue);
352
+ const node = this.parseNode(resolvedSchema, name, refValue);
353
+ this._resolvingRefs.delete(refValue);
354
+ return node;
342
355
  }
343
356
  return createRefNode(nanoid(), name, refValue, this.extractMetadata(schema));
344
357
  }
@@ -1159,28 +1159,10 @@ var FormulaSerializer = class _FormulaSerializer {
1159
1159
 
1160
1160
  // src/core/schema-diff/SchemaComparator.ts
1161
1161
  function areNodesEqual(current, base, context) {
1162
- if (current.nodeType() !== base.nodeType()) {
1163
- return false;
1164
- }
1165
1162
  if (current.name() !== base.name()) {
1166
1163
  return false;
1167
1164
  }
1168
- if (!areMetadataEqual(current, base)) {
1169
- return false;
1170
- }
1171
- if (current.isPrimitive()) {
1172
- return arePrimitivesEqual(current, base, context);
1173
- }
1174
- if (current.isObject()) {
1175
- return areObjectsEqual(current, base, context);
1176
- }
1177
- if (current.isArray()) {
1178
- return areArraysEqual(current, base, context);
1179
- }
1180
- if (current.isRef()) {
1181
- return current.ref() === base.ref();
1182
- }
1183
- return current.isNull() && base.isNull();
1165
+ return areNodesContentEqual(current, base, context);
1184
1166
  }
1185
1167
  function areNodesContentEqual(current, base, context) {
1186
1168
  if (current.nodeType() !== base.nodeType()) {
@@ -1192,15 +1174,15 @@ function areNodesContentEqual(current, base, context) {
1192
1174
  if (current.isPrimitive()) {
1193
1175
  return arePrimitivesEqual(current, base, context);
1194
1176
  }
1177
+ if (current.isRef()) {
1178
+ return current.ref() === base.ref();
1179
+ }
1195
1180
  if (current.isObject()) {
1196
1181
  return areObjectsEqual(current, base, context);
1197
1182
  }
1198
1183
  if (current.isArray()) {
1199
1184
  return areArraysEqual(current, base, context);
1200
1185
  }
1201
- if (current.isRef()) {
1202
- return current.ref() === base.ref();
1203
- }
1204
1186
  return current.isNull() && base.isNull();
1205
1187
  }
1206
1188
  function areMetadataEqual(current, base) {
@@ -1161,28 +1161,10 @@ var FormulaSerializer = class _FormulaSerializer {
1161
1161
 
1162
1162
  // src/core/schema-diff/SchemaComparator.ts
1163
1163
  function areNodesEqual(current, base, context) {
1164
- if (current.nodeType() !== base.nodeType()) {
1165
- return false;
1166
- }
1167
1164
  if (current.name() !== base.name()) {
1168
1165
  return false;
1169
1166
  }
1170
- if (!areMetadataEqual(current, base)) {
1171
- return false;
1172
- }
1173
- if (current.isPrimitive()) {
1174
- return arePrimitivesEqual(current, base, context);
1175
- }
1176
- if (current.isObject()) {
1177
- return areObjectsEqual(current, base, context);
1178
- }
1179
- if (current.isArray()) {
1180
- return areArraysEqual(current, base, context);
1181
- }
1182
- if (current.isRef()) {
1183
- return current.ref() === base.ref();
1184
- }
1185
- return current.isNull() && base.isNull();
1167
+ return areNodesContentEqual(current, base, context);
1186
1168
  }
1187
1169
  function areNodesContentEqual(current, base, context) {
1188
1170
  if (current.nodeType() !== base.nodeType()) {
@@ -1194,15 +1176,15 @@ function areNodesContentEqual(current, base, context) {
1194
1176
  if (current.isPrimitive()) {
1195
1177
  return arePrimitivesEqual(current, base, context);
1196
1178
  }
1179
+ if (current.isRef()) {
1180
+ return current.ref() === base.ref();
1181
+ }
1197
1182
  if (current.isObject()) {
1198
1183
  return areObjectsEqual(current, base, context);
1199
1184
  }
1200
1185
  if (current.isArray()) {
1201
1186
  return areArraysEqual(current, base, context);
1202
1187
  }
1203
- if (current.isRef()) {
1204
- return current.ref() === base.ref();
1205
- }
1206
1188
  return current.isNull() && base.isNull();
1207
1189
  }
1208
1190
  function areMetadataEqual(current, base) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkRCCBUOGY_cjs = require('./chunk-RCCBUOGY.cjs');
3
+ var chunkT46TZYJL_cjs = require('./chunk-T46TZYJL.cjs');
4
4
  var chunk2PIMJSWJ_cjs = require('./chunk-2PIMJSWJ.cjs');
5
5
  var nanoid = require('nanoid');
6
6
  var formula = require('@revisium/formula');
@@ -69,7 +69,7 @@ var FormulaPath = class {
69
69
  resolveRootPath(rootPath) {
70
70
  const path = rootPath.startsWith("/") ? rootPath.slice(1) : rootPath;
71
71
  if (!path) {
72
- return chunkRCCBUOGY_cjs.EMPTY_PATH;
72
+ return chunkT46TZYJL_cjs.EMPTY_PATH;
73
73
  }
74
74
  try {
75
75
  return this.parseFormulaPath(path);
@@ -79,7 +79,7 @@ var FormulaPath = class {
79
79
  }
80
80
  parseFormulaPath(formulaPath) {
81
81
  const parts = formulaPath.split(".");
82
- let result = chunkRCCBUOGY_cjs.EMPTY_PATH;
82
+ let result = chunkT46TZYJL_cjs.EMPTY_PATH;
83
83
  for (const part of parts) {
84
84
  if (!part) {
85
85
  throw new Error(`Invalid path: empty segment`);
@@ -107,7 +107,7 @@ var ParsedFormula = class {
107
107
  this.astNode = parseResult.ast;
108
108
  const formulaPath = tree.pathOf(formulaNodeId);
109
109
  if (formulaPath.isEmpty() && tree.root().id() !== formulaNodeId) {
110
- throw new chunkRCCBUOGY_cjs.FormulaError("Formula node not found in tree", formulaNodeId);
110
+ throw new chunkT46TZYJL_cjs.FormulaError("Formula node not found in tree", formulaNodeId);
111
111
  }
112
112
  const deps = [];
113
113
  const astPathToNodeId = /* @__PURE__ */ new Map();
@@ -118,20 +118,20 @@ var ParsedFormula = class {
118
118
  depPath
119
119
  );
120
120
  if (!targetNodeId) {
121
- throw new chunkRCCBUOGY_cjs.FormulaError(
121
+ throw new chunkT46TZYJL_cjs.FormulaError(
122
122
  `Cannot resolve formula dependency: ${depPath}`,
123
123
  formulaNodeId,
124
124
  "Path not found in schema"
125
125
  );
126
126
  }
127
127
  if (targetNodeId === formulaNodeId) {
128
- throw new chunkRCCBUOGY_cjs.FormulaError(
128
+ throw new chunkT46TZYJL_cjs.FormulaError(
129
129
  "Formula cannot reference itself",
130
130
  formulaNodeId,
131
131
  "Self-reference detected"
132
132
  );
133
133
  }
134
- deps.push(new chunkRCCBUOGY_cjs.ResolvedDependency(targetNodeId));
134
+ deps.push(new chunkT46TZYJL_cjs.ResolvedDependency(targetNodeId));
135
135
  astPathToNodeId.set(depPath, targetNodeId);
136
136
  }
137
137
  this.deps = deps;
@@ -295,7 +295,7 @@ var FormulaChangeDetector = class {
295
295
  }
296
296
  getSerializedExpression(formula, tree, nodeId) {
297
297
  try {
298
- const xFormula = chunkRCCBUOGY_cjs.FormulaSerializer.toXFormula(tree, nodeId, formula);
298
+ const xFormula = chunkT46TZYJL_cjs.FormulaSerializer.toXFormula(tree, nodeId, formula);
299
299
  return xFormula.expression;
300
300
  } catch {
301
301
  return null;
@@ -308,10 +308,17 @@ var SchemaParser = class {
308
308
  pendingFormulas = [];
309
309
  _parseErrors = [];
310
310
  _refSchemas = {};
311
+ _resolvingRefs = /* @__PURE__ */ new Set();
311
312
  parse(schema, refSchemas) {
312
313
  this.pendingFormulas = [];
313
314
  this._parseErrors = [];
314
315
  this._refSchemas = refSchemas ?? {};
316
+ this._resolvingRefs = /* @__PURE__ */ new Set();
317
+ for (const [refKey, refSchema] of Object.entries(this._refSchemas)) {
318
+ if (refSchema === schema) {
319
+ this._resolvingRefs.add(refKey);
320
+ }
321
+ }
315
322
  return this.parseNode(schema, "root");
316
323
  }
317
324
  parseFormulas(tree) {
@@ -340,9 +347,15 @@ var SchemaParser = class {
340
347
  const refValue = schema.$ref;
341
348
  const resolvedSchema = this._refSchemas[refValue];
342
349
  if (resolvedSchema) {
343
- return this.parseNode(resolvedSchema, name, refValue);
350
+ if (this._resolvingRefs.has(refValue)) {
351
+ return chunkT46TZYJL_cjs.createRefNode(nanoid.nanoid(), name, refValue, this.extractMetadata(schema));
352
+ }
353
+ this._resolvingRefs.add(refValue);
354
+ const node = this.parseNode(resolvedSchema, name, refValue);
355
+ this._resolvingRefs.delete(refValue);
356
+ return node;
344
357
  }
345
- return chunkRCCBUOGY_cjs.createRefNode(nanoid.nanoid(), name, refValue, this.extractMetadata(schema));
358
+ return chunkT46TZYJL_cjs.createRefNode(nanoid.nanoid(), name, refValue, this.extractMetadata(schema));
346
359
  }
347
360
  const schemaWithType = schema;
348
361
  switch (schemaWithType.type) {
@@ -368,14 +381,14 @@ var SchemaParser = class {
368
381
  children.push(this.parseNode(propSchema, propName));
369
382
  }
370
383
  }
371
- return chunkRCCBUOGY_cjs.createObjectNode(nanoid.nanoid(), name, children, {
384
+ return chunkT46TZYJL_cjs.createObjectNode(nanoid.nanoid(), name, children, {
372
385
  metadata: this.extractMetadata(schema),
373
386
  ref: ref2
374
387
  });
375
388
  }
376
389
  parseArray(schema, name, ref2) {
377
390
  const items = this.parseNode(schema.items, "items");
378
- return chunkRCCBUOGY_cjs.createArrayNode(nanoid.nanoid(), name, items, {
391
+ return chunkT46TZYJL_cjs.createArrayNode(nanoid.nanoid(), name, items, {
379
392
  metadata: this.extractMetadata(schema),
380
393
  ref: ref2
381
394
  });
@@ -383,7 +396,7 @@ var SchemaParser = class {
383
396
  parseString(schema, name, ref2) {
384
397
  const nodeId = nanoid.nanoid();
385
398
  this.collectFormula(nodeId, schema["x-formula"]);
386
- return chunkRCCBUOGY_cjs.createStringNode(nodeId, name, {
399
+ return chunkT46TZYJL_cjs.createStringNode(nodeId, name, {
387
400
  defaultValue: schema.default,
388
401
  foreignKey: schema.foreignKey,
389
402
  metadata: this.extractMetadata(schema),
@@ -393,7 +406,7 @@ var SchemaParser = class {
393
406
  parseNumber(schema, name, ref2) {
394
407
  const nodeId = nanoid.nanoid();
395
408
  this.collectFormula(nodeId, schema["x-formula"]);
396
- return chunkRCCBUOGY_cjs.createNumberNode(nodeId, name, {
409
+ return chunkT46TZYJL_cjs.createNumberNode(nodeId, name, {
397
410
  defaultValue: schema.default,
398
411
  metadata: this.extractMetadata(schema),
399
412
  ref: ref2
@@ -402,7 +415,7 @@ var SchemaParser = class {
402
415
  parseBoolean(schema, name, ref2) {
403
416
  const nodeId = nanoid.nanoid();
404
417
  this.collectFormula(nodeId, schema["x-formula"]);
405
- return chunkRCCBUOGY_cjs.createBooleanNode(nodeId, name, {
418
+ return chunkT46TZYJL_cjs.createBooleanNode(nodeId, name, {
406
419
  defaultValue: schema.default,
407
420
  metadata: this.extractMetadata(schema),
408
421
  ref: ref2
@@ -435,13 +448,13 @@ var NodeFactory = class {
435
448
  createNode(name, type) {
436
449
  switch (type) {
437
450
  case "string":
438
- return chunkRCCBUOGY_cjs.createStringNode(nanoid.nanoid(), name, { defaultValue: "" });
451
+ return chunkT46TZYJL_cjs.createStringNode(nanoid.nanoid(), name, { defaultValue: "" });
439
452
  case "number":
440
- return chunkRCCBUOGY_cjs.createNumberNode(nanoid.nanoid(), name, { defaultValue: 0 });
453
+ return chunkT46TZYJL_cjs.createNumberNode(nanoid.nanoid(), name, { defaultValue: 0 });
441
454
  case "boolean":
442
- return chunkRCCBUOGY_cjs.createBooleanNode(nanoid.nanoid(), name, { defaultValue: false });
455
+ return chunkT46TZYJL_cjs.createBooleanNode(nanoid.nanoid(), name, { defaultValue: false });
443
456
  case "object":
444
- return chunkRCCBUOGY_cjs.createObjectNode(nanoid.nanoid(), name, []);
457
+ return chunkT46TZYJL_cjs.createObjectNode(nanoid.nanoid(), name, []);
445
458
  case "array":
446
459
  return this.createArrayNodeInternal(name);
447
460
  default:
@@ -449,11 +462,11 @@ var NodeFactory = class {
449
462
  }
450
463
  }
451
464
  createArrayNodeInternal(name) {
452
- const items = chunkRCCBUOGY_cjs.createStringNode(nanoid.nanoid(), "items", { defaultValue: "" });
453
- return chunkRCCBUOGY_cjs.createArrayNode(nanoid.nanoid(), name, items);
465
+ const items = chunkT46TZYJL_cjs.createStringNode(nanoid.nanoid(), "items", { defaultValue: "" });
466
+ return chunkT46TZYJL_cjs.createArrayNode(nanoid.nanoid(), name, items);
454
467
  }
455
468
  createArrayNodeWithItems(name, items) {
456
- return chunkRCCBUOGY_cjs.createArrayNode(nanoid.nanoid(), name, items);
469
+ return chunkT46TZYJL_cjs.createArrayNode(nanoid.nanoid(), name, items);
457
470
  }
458
471
  };
459
472
 
@@ -552,7 +565,7 @@ var PrimitiveToArrayTransformer = class {
552
565
  const { sourceNode } = ctx;
553
566
  const itemsNode = sourceNode.cloneWithId(nanoid.nanoid());
554
567
  itemsNode.setName("items");
555
- const arrayNode = chunkRCCBUOGY_cjs.createArrayNode(sourceNode.id(), sourceNode.name(), itemsNode);
568
+ const arrayNode = chunkT46TZYJL_cjs.createArrayNode(sourceNode.id(), sourceNode.name(), itemsNode);
556
569
  return { node: arrayNode };
557
570
  }
558
571
  };
@@ -565,7 +578,7 @@ var ObjectToArrayTransformer = class {
565
578
  const { sourceNode } = ctx;
566
579
  const itemsNode = sourceNode.cloneWithId(nanoid.nanoid());
567
580
  itemsNode.setName("items");
568
- const arrayNode = chunkRCCBUOGY_cjs.createArrayNode(sourceNode.id(), sourceNode.name(), itemsNode);
581
+ const arrayNode = chunkT46TZYJL_cjs.createArrayNode(sourceNode.id(), sourceNode.name(), itemsNode);
569
582
  return { node: arrayNode };
570
583
  }
571
584
  };
@@ -615,7 +628,7 @@ var RefTransformer = class {
615
628
  return { node: newNode };
616
629
  }
617
630
  const metadata = this.extractMetadata(targetSpec);
618
- const node = chunkRCCBUOGY_cjs.createRefNode(sourceNode.id(), sourceNode.name(), refUri, metadata);
631
+ const node = chunkT46TZYJL_cjs.createRefNode(sourceNode.id(), sourceNode.name(), refUri, metadata);
619
632
  return { node };
620
633
  }
621
634
  extractMetadata(spec) {
@@ -650,23 +663,23 @@ var DefaultTransformer = class {
650
663
  createNode(id, name, type, spec, metadata) {
651
664
  switch (type) {
652
665
  case "string":
653
- return chunkRCCBUOGY_cjs.createStringNode(id, name, {
666
+ return chunkT46TZYJL_cjs.createStringNode(id, name, {
654
667
  defaultValue: spec.default ?? "",
655
668
  foreignKey: spec.foreignKey,
656
669
  metadata
657
670
  });
658
671
  case "number":
659
- return chunkRCCBUOGY_cjs.createNumberNode(id, name, {
672
+ return chunkT46TZYJL_cjs.createNumberNode(id, name, {
660
673
  defaultValue: spec.default ?? 0,
661
674
  metadata
662
675
  });
663
676
  case "boolean":
664
- return chunkRCCBUOGY_cjs.createBooleanNode(id, name, {
677
+ return chunkT46TZYJL_cjs.createBooleanNode(id, name, {
665
678
  defaultValue: spec.default ?? false,
666
679
  metadata
667
680
  });
668
681
  case "object":
669
- return chunkRCCBUOGY_cjs.createObjectNode(id, name, [], { metadata });
682
+ return chunkT46TZYJL_cjs.createObjectNode(id, name, [], { metadata });
670
683
  case "array":
671
684
  return this.createArrayNode(id, name, metadata);
672
685
  default:
@@ -674,8 +687,8 @@ var DefaultTransformer = class {
674
687
  }
675
688
  }
676
689
  createArrayNode(id, name, metadata) {
677
- const items = chunkRCCBUOGY_cjs.createStringNode(nanoid.nanoid(), "items", { defaultValue: "" });
678
- return chunkRCCBUOGY_cjs.createArrayNode(id, name, items, { metadata });
690
+ const items = chunkT46TZYJL_cjs.createStringNode(nanoid.nanoid(), "items", { defaultValue: "" });
691
+ return chunkT46TZYJL_cjs.createArrayNode(id, name, items, { metadata });
679
692
  }
680
693
  extractMetadata(spec) {
681
694
  const meta = {};
@@ -739,8 +752,8 @@ function createTypeTransformChain(options) {
739
752
  var SchemaModelImpl = class {
740
753
  _baseTree;
741
754
  _currentTree;
742
- _patchBuilder = new chunkRCCBUOGY_cjs.PatchBuilder();
743
- _serializer = new chunkRCCBUOGY_cjs.SchemaSerializer();
755
+ _patchBuilder = new chunkT46TZYJL_cjs.PatchBuilder();
756
+ _serializer = new chunkT46TZYJL_cjs.SchemaSerializer();
744
757
  _nodeFactory = new NodeFactory();
745
758
  _formulaIndex = new FormulaDependencyIndex();
746
759
  _transformChain;
@@ -754,12 +767,12 @@ var SchemaModelImpl = class {
754
767
  });
755
768
  const parser = new SchemaParser();
756
769
  const rootNode = parser.parse(schema, this._refSchemas);
757
- this._currentTree = chunkRCCBUOGY_cjs.createSchemaTree(rootNode);
770
+ this._currentTree = chunkT46TZYJL_cjs.createSchemaTree(rootNode);
758
771
  parser.parseFormulas(this._currentTree);
759
772
  this._formulaParseErrors = parser.parseErrors;
760
773
  this._buildFormulaIndex();
761
774
  this._baseTree = this._currentTree.clone();
762
- chunkRCCBUOGY_cjs.makeAutoObservable(this, {
775
+ chunkT46TZYJL_cjs.makeAutoObservable(this, {
763
776
  _patchBuilder: false,
764
777
  _serializer: false,
765
778
  _nodeFactory: false,
@@ -788,10 +801,10 @@ var SchemaModelImpl = class {
788
801
  insertFieldAt(parentId, index, name, type) {
789
802
  const parent = this._currentTree.nodeById(parentId);
790
803
  if (parent.isNull() || !parent.isObject()) {
791
- return chunkRCCBUOGY_cjs.NULL_NODE;
804
+ return chunkT46TZYJL_cjs.NULL_NODE;
792
805
  }
793
806
  if (index < 0 || index > parent.properties().length) {
794
- return chunkRCCBUOGY_cjs.NULL_NODE;
807
+ return chunkT46TZYJL_cjs.NULL_NODE;
795
808
  }
796
809
  const node = this._nodeFactory.createNode(name, type);
797
810
  this._currentTree.insertChildAt(parentId, index, node);
@@ -1016,7 +1029,7 @@ var SchemaModelImpl = class {
1016
1029
  return "";
1017
1030
  }
1018
1031
  try {
1019
- return chunkRCCBUOGY_cjs.FormulaSerializer.serializeExpression(
1032
+ return chunkT46TZYJL_cjs.FormulaSerializer.serializeExpression(
1020
1033
  this._currentTree,
1021
1034
  nodeId,
1022
1035
  formula,
@@ -1027,10 +1040,10 @@ var SchemaModelImpl = class {
1027
1040
  }
1028
1041
  }
1029
1042
  get validationErrors() {
1030
- return chunkRCCBUOGY_cjs.validateSchema(this._currentTree.root());
1043
+ return chunkT46TZYJL_cjs.validateSchema(this._currentTree.root());
1031
1044
  }
1032
1045
  get formulaErrors() {
1033
- return [...this._formulaParseErrors, ...chunkRCCBUOGY_cjs.validateFormulas(this._currentTree)];
1046
+ return [...this._formulaParseErrors, ...chunkT46TZYJL_cjs.validateFormulas(this._currentTree)];
1034
1047
  }
1035
1048
  get isDirty() {
1036
1049
  return this.patches.length > 0;
@@ -1542,7 +1555,7 @@ var FormulaEngine = class {
1542
1555
  this.setupReactions();
1543
1556
  }
1544
1557
  evaluateAll() {
1545
- chunkRCCBUOGY_cjs.runInAction(() => {
1558
+ chunkT46TZYJL_cjs.runInAction(() => {
1546
1559
  for (const field of this.evaluationOrder) {
1547
1560
  this.evaluator.evaluate(field);
1548
1561
  }
@@ -1555,7 +1568,7 @@ var FormulaEngine = class {
1555
1568
  continue;
1556
1569
  }
1557
1570
  watchedNodes.add(depNode);
1558
- const disposer = chunkRCCBUOGY_cjs.reaction(
1571
+ const disposer = chunkT46TZYJL_cjs.reaction(
1559
1572
  () => depNode.value,
1560
1573
  () => this.handleDependencyChange(depNode)
1561
1574
  );
@@ -1565,7 +1578,7 @@ var FormulaEngine = class {
1565
1578
  }
1566
1579
  setupArrayReactions(node) {
1567
1580
  if (node.isArray()) {
1568
- const disposer = chunkRCCBUOGY_cjs.reaction(
1581
+ const disposer = chunkT46TZYJL_cjs.reaction(
1569
1582
  () => node.length,
1570
1583
  () => this.handleStructureChange()
1571
1584
  );
@@ -1585,7 +1598,7 @@ var FormulaEngine = class {
1585
1598
  this.dependencyMap,
1586
1599
  this.evaluationOrder
1587
1600
  );
1588
- chunkRCCBUOGY_cjs.runInAction(() => {
1601
+ chunkT46TZYJL_cjs.runInAction(() => {
1589
1602
  for (const field of affected) {
1590
1603
  this.evaluator.evaluate(field);
1591
1604
  }
@@ -1685,7 +1698,7 @@ var ArrayValueNode = class extends BaseValueNode {
1685
1698
  _nodeFactory = null;
1686
1699
  constructor(id, name, schema, items) {
1687
1700
  super(id, name, schema);
1688
- this._items = chunkRCCBUOGY_cjs.observable.array();
1701
+ this._items = chunkT46TZYJL_cjs.observable.array();
1689
1702
  this._baseItems = [];
1690
1703
  if (items) {
1691
1704
  for (const item of items) {
@@ -1694,7 +1707,7 @@ var ArrayValueNode = class extends BaseValueNode {
1694
1707
  }
1695
1708
  }
1696
1709
  this._baseItems = [...this._items];
1697
- chunkRCCBUOGY_cjs.makeObservable(this, {
1710
+ chunkT46TZYJL_cjs.makeObservable(this, {
1698
1711
  _items: "observable",
1699
1712
  _baseItems: "observable",
1700
1713
  value: "computed",
@@ -1881,7 +1894,7 @@ var ArrayValueNode = class extends BaseValueNode {
1881
1894
  for (const item of this._items) {
1882
1895
  item.parent = null;
1883
1896
  }
1884
- this._items = chunkRCCBUOGY_cjs.observable.array();
1897
+ this._items = chunkT46TZYJL_cjs.observable.array();
1885
1898
  for (const baseItem of this._baseItems) {
1886
1899
  this._items.push(baseItem);
1887
1900
  }
@@ -1924,7 +1937,7 @@ var BasePrimitiveValueNode = class extends BaseValueNode {
1924
1937
  this._baseValue = initialValue;
1925
1938
  }
1926
1939
  initObservable() {
1927
- chunkRCCBUOGY_cjs.makeObservable(this, {
1940
+ chunkT46TZYJL_cjs.makeObservable(this, {
1928
1941
  _value: "observable",
1929
1942
  _baseValue: "observable",
1930
1943
  _formulaWarning: "observable",
@@ -2283,7 +2296,7 @@ var ObjectValueNode = class extends BaseValueNode {
2283
2296
  _baseChildren;
2284
2297
  constructor(id, name, schema, children) {
2285
2298
  super(id, name, schema);
2286
- this._children = chunkRCCBUOGY_cjs.observable.map();
2299
+ this._children = chunkT46TZYJL_cjs.observable.map();
2287
2300
  this._baseChildren = /* @__PURE__ */ new Map();
2288
2301
  if (children) {
2289
2302
  for (const child of children) {
@@ -2292,7 +2305,7 @@ var ObjectValueNode = class extends BaseValueNode {
2292
2305
  }
2293
2306
  }
2294
2307
  this._baseChildren = new Map(this._children);
2295
- chunkRCCBUOGY_cjs.makeObservable(this, {
2308
+ chunkT46TZYJL_cjs.makeObservable(this, {
2296
2309
  _children: "observable",
2297
2310
  _baseChildren: "observable",
2298
2311
  value: "computed",
@@ -2386,7 +2399,7 @@ var ObjectValueNode = class extends BaseValueNode {
2386
2399
  for (const child of this._children.values()) {
2387
2400
  child.parent = null;
2388
2401
  }
2389
- this._children = chunkRCCBUOGY_cjs.observable.map();
2402
+ this._children = chunkT46TZYJL_cjs.observable.map();
2390
2403
  for (const [key, value] of this._baseChildren) {
2391
2404
  this._children.set(key, value);
2392
2405
  }
@@ -2600,7 +2613,7 @@ var IndexSegment = class {
2600
2613
  };
2601
2614
 
2602
2615
  // src/core/value-path/ValuePath.ts
2603
- var ValuePathImpl = class _ValuePathImpl extends chunkRCCBUOGY_cjs.AbstractBasePath {
2616
+ var ValuePathImpl = class _ValuePathImpl extends chunkT46TZYJL_cjs.AbstractBasePath {
2604
2617
  asString() {
2605
2618
  const parts = [];
2606
2619
  for (const seg of this.segs) {
@@ -2705,7 +2718,7 @@ function parseValuePath(path) {
2705
2718
  var ChangeTracker = class {
2706
2719
  _changes = [];
2707
2720
  constructor() {
2708
- chunkRCCBUOGY_cjs.makeAutoObservable(this);
2721
+ chunkT46TZYJL_cjs.makeAutoObservable(this);
2709
2722
  }
2710
2723
  get changes() {
2711
2724
  return this._changes;
@@ -2871,7 +2884,7 @@ var ValueTree = class {
2871
2884
  this.changeTracker = new ChangeTracker();
2872
2885
  this._nodeChangeListener = (event) => this.handleNodeChange(event);
2873
2886
  this.subscribe(this._root);
2874
- chunkRCCBUOGY_cjs.makeAutoObservable(this, {
2887
+ chunkT46TZYJL_cjs.makeAutoObservable(this, {
2875
2888
  _root: false,
2876
2889
  index: false,
2877
2890
  _nodeChangeListener: false,
@@ -3128,7 +3141,7 @@ var RowModelImpl = class {
3128
3141
  constructor(_rowId, _tree) {
3129
3142
  this._rowId = _rowId;
3130
3143
  this._tree = _tree;
3131
- chunkRCCBUOGY_cjs.makeAutoObservable(this, {
3144
+ chunkT46TZYJL_cjs.makeAutoObservable(this, {
3132
3145
  _rowId: false,
3133
3146
  _tree: false,
3134
3147
  _tableModel: "observable.ref"
@@ -3239,13 +3252,13 @@ var TableModelImpl = class {
3239
3252
  this._schema = createSchemaModel(options.schema, { refSchemas: options.refSchemas });
3240
3253
  this._fkResolver = options.fkResolver;
3241
3254
  this._refSchemas = options.refSchemas;
3242
- this._rows = chunkRCCBUOGY_cjs.observable.array();
3255
+ this._rows = chunkT46TZYJL_cjs.observable.array();
3243
3256
  if (options.rows) {
3244
3257
  for (const row of options.rows) {
3245
3258
  this._rows.push(this.createRow(row.rowId, row.data));
3246
3259
  }
3247
3260
  }
3248
- chunkRCCBUOGY_cjs.makeAutoObservable(this, {
3261
+ chunkT46TZYJL_cjs.makeAutoObservable(this, {
3249
3262
  _schema: false,
3250
3263
  _rows: false,
3251
3264
  _jsonSchema: false,
@@ -3376,13 +3389,13 @@ var ForeignKeyResolverImpl = class {
3376
3389
  constructor(options) {
3377
3390
  this.loader = options?.loader;
3378
3391
  this._prefetchEnabled = options?.prefetch ?? false;
3379
- this._schemaCache = chunkRCCBUOGY_cjs.observable.map();
3380
- this._tableCache = chunkRCCBUOGY_cjs.observable.map();
3392
+ this._schemaCache = chunkT46TZYJL_cjs.observable.map();
3393
+ this._tableCache = chunkT46TZYJL_cjs.observable.map();
3381
3394
  this._loadingTables = /* @__PURE__ */ new Set();
3382
3395
  this._loadingRows = /* @__PURE__ */ new Map();
3383
3396
  this._pendingTableLoads = /* @__PURE__ */ new Map();
3384
3397
  this._pendingRowLoads = /* @__PURE__ */ new Map();
3385
- chunkRCCBUOGY_cjs.makeAutoObservable(this, {
3398
+ chunkT46TZYJL_cjs.makeAutoObservable(this, {
3386
3399
  _schemaCache: false,
3387
3400
  _tableCache: false,
3388
3401
  _loadingTables: false,
@@ -3420,7 +3433,7 @@ var ForeignKeyResolverImpl = class {
3420
3433
  if (this._disposed) {
3421
3434
  return;
3422
3435
  }
3423
- chunkRCCBUOGY_cjs.runInAction(() => {
3436
+ chunkT46TZYJL_cjs.runInAction(() => {
3424
3437
  this._schemaCache.set(tableId, schema);
3425
3438
  });
3426
3439
  }
@@ -3428,12 +3441,12 @@ var ForeignKeyResolverImpl = class {
3428
3441
  if (this._disposed) {
3429
3442
  return;
3430
3443
  }
3431
- const rowMap = chunkRCCBUOGY_cjs.observable.map();
3444
+ const rowMap = chunkT46TZYJL_cjs.observable.map();
3432
3445
  for (const row of rows) {
3433
3446
  rowMap.set(row.rowId, row);
3434
3447
  }
3435
3448
  const cache = { schema, rows: rowMap };
3436
- chunkRCCBUOGY_cjs.runInAction(() => {
3449
+ chunkT46TZYJL_cjs.runInAction(() => {
3437
3450
  this._tableCache.set(tableId, cache);
3438
3451
  this._schemaCache.set(tableId, schema);
3439
3452
  });
@@ -3448,7 +3461,7 @@ var ForeignKeyResolverImpl = class {
3448
3461
  const table = this._tableCache.get(tableId);
3449
3462
  if (table) {
3450
3463
  const rowData = { rowId, data };
3451
- chunkRCCBUOGY_cjs.runInAction(() => {
3464
+ chunkT46TZYJL_cjs.runInAction(() => {
3452
3465
  table.rows.set(rowId, rowData);
3453
3466
  });
3454
3467
  if (this._prefetchEnabled) {
@@ -3462,7 +3475,7 @@ var ForeignKeyResolverImpl = class {
3462
3475
  }
3463
3476
  const schema = this._schemaCache.get(oldTableId);
3464
3477
  const tableCache = this._tableCache.get(oldTableId);
3465
- chunkRCCBUOGY_cjs.runInAction(() => {
3478
+ chunkT46TZYJL_cjs.runInAction(() => {
3466
3479
  if (schema) {
3467
3480
  this._schemaCache.delete(oldTableId);
3468
3481
  this._schemaCache.set(newTableId, schema);
@@ -3564,9 +3577,9 @@ var ForeignKeyResolverImpl = class {
3564
3577
  }
3565
3578
  ensureTableCache(tableId, schema) {
3566
3579
  if (!this._tableCache.has(tableId)) {
3567
- const rowMap = chunkRCCBUOGY_cjs.observable.map();
3580
+ const rowMap = chunkT46TZYJL_cjs.observable.map();
3568
3581
  const cache = { schema, rows: rowMap };
3569
- chunkRCCBUOGY_cjs.runInAction(() => {
3582
+ chunkT46TZYJL_cjs.runInAction(() => {
3570
3583
  this._tableCache.set(tableId, cache);
3571
3584
  });
3572
3585
  }
@@ -3666,7 +3679,7 @@ var DataModelImpl = class {
3666
3679
  _fk;
3667
3680
  _ownsFkResolver;
3668
3681
  constructor(options) {
3669
- this._tables = chunkRCCBUOGY_cjs.observable.map();
3682
+ this._tables = chunkT46TZYJL_cjs.observable.map();
3670
3683
  if (options?.fkResolver) {
3671
3684
  this._fk = options.fkResolver;
3672
3685
  this._ownsFkResolver = false;
@@ -3674,7 +3687,7 @@ var DataModelImpl = class {
3674
3687
  this._fk = createForeignKeyResolver();
3675
3688
  this._ownsFkResolver = true;
3676
3689
  }
3677
- chunkRCCBUOGY_cjs.makeAutoObservable(this, {
3690
+ chunkT46TZYJL_cjs.makeAutoObservable(this, {
3678
3691
  _tables: false,
3679
3692
  _fk: false,
3680
3693
  _ownsFkResolver: false