@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.
- package/dist/{chunk-SBO2UMI3.cjs → chunk-2PIMJSWJ.cjs} +0 -2
- package/dist/chunk-3MJP73IJ.js +1 -0
- package/dist/{chunk-62A5JJJ3.js → chunk-4U2RZHMX.js} +0 -2
- package/dist/{chunk-Q2UOTIMG.js → chunk-5DUMJHCA.js} +0 -2
- package/dist/{chunk-Z7M4ZGC6.cjs → chunk-7JWCZZPJ.cjs} +21 -23
- package/dist/{chunk-YFWOURZL.js → chunk-7PEC6ZYY.js} +0 -2
- package/dist/chunk-AV5EZUMZ.cjs +2 -0
- package/dist/{chunk-TMCRV6V5.js → chunk-AWFMSOHM.js} +0 -2
- package/dist/{chunk-X2VRR7V7.cjs → chunk-ERW5XVED.cjs} +0 -2
- package/dist/{chunk-XNFSFT7T.cjs → chunk-EVD5ZI55.cjs} +0 -2
- package/dist/{chunk-ZRNFSUOV.cjs → chunk-FL6PWPVJ.cjs} +0 -2
- package/dist/{chunk-TKMR6CQW.js → chunk-FTBRJODD.js} +0 -2
- package/dist/{chunk-R3MS2N4A.js → chunk-GJM63Q4K.js} +0 -2
- package/dist/{chunk-MK3IKVZO.js → chunk-HFMZITNE.js} +168 -17
- package/dist/{chunk-3DDUT57J.cjs → chunk-ITYABUR5.cjs} +0 -2
- package/dist/{chunk-BIBFHULN.js → chunk-IZMBM36H.js} +0 -2
- package/dist/chunk-J4RVO37K.cjs +2 -0
- package/dist/{chunk-UTSL45Q4.js → chunk-JLXX3SGF.js} +2 -4
- package/dist/{chunk-DRPNJ4YP.js → chunk-NO655UI5.js} +0 -2
- package/dist/chunk-OAUVP6CU.js +1 -0
- package/dist/{chunk-HH2LDPVV.cjs → chunk-ONW2OVNQ.cjs} +0 -2
- package/dist/{chunk-32FZHFIO.cjs → chunk-QKA7DJDN.cjs} +0 -2
- package/dist/{chunk-JWYYVKRT.cjs → chunk-RCCBUOGY.cjs} +0 -2
- package/dist/{chunk-IPL2CGVA.cjs → chunk-RQBW7ATZ.cjs} +0 -2
- package/dist/{chunk-F4POD7AE.cjs → chunk-S5SRXND6.cjs} +235 -84
- package/dist/{chunk-WSPFHUHU.cjs → chunk-T3QQSHAC.cjs} +0 -2
- package/dist/{chunk-CGVYS7EK.cjs → chunk-VMELKZXD.cjs} +0 -2
- package/dist/{chunk-5VDDLW7U.js → chunk-WE4OLW5U.js} +0 -2
- package/dist/{chunk-JUOGJFTL.js → chunk-XKWWCXGB.js} +0 -2
- package/dist/{chunk-ZBPUTF3Q.js → chunk-ZPRBA4AQ.js} +0 -2
- package/dist/consts/index.cjs +4 -6
- package/dist/consts/index.js +2 -4
- package/dist/core/index.cjs +65 -67
- package/dist/core/index.js +4 -6
- package/dist/formula/index.cjs +7 -9
- package/dist/formula/index.js +1 -3
- package/dist/index.cjs +245 -247
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -17
- package/dist/lib/index.cjs +51 -53
- package/dist/lib/index.js +7 -9
- package/dist/mocks/index.cjs +21 -23
- package/dist/mocks/index.js +2 -4
- package/dist/model/index.cjs +76 -78
- package/dist/model/index.d.cts +15 -2
- package/dist/model/index.d.ts +15 -2
- package/dist/model/index.js +4 -6
- package/dist/plugins/index.cjs +20 -22
- package/dist/plugins/index.js +2 -4
- package/dist/{typed-BinPIf3R.d.ts → typed-BRZhUqGG.d.ts} +48 -1
- package/dist/{typed-LSaUJayS.d.cts → typed-Cri0IYAn.d.cts} +48 -1
- package/dist/types/index.cjs +4 -6
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +2 -4
- package/dist/validation-schemas/index.cjs +18 -20
- package/dist/validation-schemas/index.js +1 -3
- package/package.json +1 -1
- package/dist/chunk-2NARA22J.js +0 -3
- package/dist/chunk-2NARA22J.js.map +0 -1
- package/dist/chunk-32FZHFIO.cjs.map +0 -1
- package/dist/chunk-3DDUT57J.cjs.map +0 -1
- package/dist/chunk-3FJZMVWA.js +0 -3
- package/dist/chunk-3FJZMVWA.js.map +0 -1
- package/dist/chunk-5VDDLW7U.js.map +0 -1
- package/dist/chunk-62A5JJJ3.js.map +0 -1
- package/dist/chunk-BIBFHULN.js.map +0 -1
- package/dist/chunk-BZWL424W.cjs +0 -4
- package/dist/chunk-BZWL424W.cjs.map +0 -1
- package/dist/chunk-CGVYS7EK.cjs.map +0 -1
- package/dist/chunk-DRPNJ4YP.js.map +0 -1
- package/dist/chunk-F4POD7AE.cjs.map +0 -1
- package/dist/chunk-HH2LDPVV.cjs.map +0 -1
- package/dist/chunk-IPL2CGVA.cjs.map +0 -1
- package/dist/chunk-JUOGJFTL.js.map +0 -1
- package/dist/chunk-JWYYVKRT.cjs.map +0 -1
- package/dist/chunk-L6HE7QPU.cjs +0 -4
- package/dist/chunk-L6HE7QPU.cjs.map +0 -1
- package/dist/chunk-MK3IKVZO.js.map +0 -1
- package/dist/chunk-Q2UOTIMG.js.map +0 -1
- package/dist/chunk-R3MS2N4A.js.map +0 -1
- package/dist/chunk-SBO2UMI3.cjs.map +0 -1
- package/dist/chunk-TKMR6CQW.js.map +0 -1
- package/dist/chunk-TMCRV6V5.js.map +0 -1
- package/dist/chunk-UTSL45Q4.js.map +0 -1
- package/dist/chunk-WSPFHUHU.cjs.map +0 -1
- package/dist/chunk-X2VRR7V7.cjs.map +0 -1
- package/dist/chunk-XNFSFT7T.cjs.map +0 -1
- package/dist/chunk-YFWOURZL.js.map +0 -1
- package/dist/chunk-Z7M4ZGC6.cjs.map +0 -1
- package/dist/chunk-ZBPUTF3Q.js.map +0 -1
- package/dist/chunk-ZRNFSUOV.cjs.map +0 -1
- package/dist/consts/index.cjs.map +0 -1
- package/dist/consts/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/formula/index.cjs.map +0 -1
- package/dist/formula/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/index.cjs.map +0 -1
- package/dist/lib/index.js.map +0 -1
- package/dist/mocks/index.cjs.map +0 -1
- package/dist/mocks/index.js.map +0 -1
- package/dist/model/index.cjs.map +0 -1
- package/dist/model/index.js.map +0 -1
- package/dist/plugins/index.cjs.map +0 -1
- package/dist/plugins/index.js.map +0 -1
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/validation-schemas/index.cjs.map +0 -1
- package/dist/validation-schemas/index.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkRCCBUOGY_cjs = require('./chunk-RCCBUOGY.cjs');
|
|
4
|
+
var chunk2PIMJSWJ_cjs = require('./chunk-2PIMJSWJ.cjs');
|
|
5
5
|
var nanoid = require('nanoid');
|
|
6
6
|
var formula = require('@revisium/formula');
|
|
7
|
+
var eventemitter3 = require('eventemitter3');
|
|
7
8
|
|
|
8
9
|
var ARRAY_NOTATION_REGEX = /^([^[]+)\[(?:\d+|\*)?\]$/;
|
|
9
10
|
var FormulaPath = class {
|
|
@@ -68,7 +69,7 @@ var FormulaPath = class {
|
|
|
68
69
|
resolveRootPath(rootPath) {
|
|
69
70
|
const path = rootPath.startsWith("/") ? rootPath.slice(1) : rootPath;
|
|
70
71
|
if (!path) {
|
|
71
|
-
return
|
|
72
|
+
return chunkRCCBUOGY_cjs.EMPTY_PATH;
|
|
72
73
|
}
|
|
73
74
|
try {
|
|
74
75
|
return this.parseFormulaPath(path);
|
|
@@ -78,7 +79,7 @@ var FormulaPath = class {
|
|
|
78
79
|
}
|
|
79
80
|
parseFormulaPath(formulaPath) {
|
|
80
81
|
const parts = formulaPath.split(".");
|
|
81
|
-
let result =
|
|
82
|
+
let result = chunkRCCBUOGY_cjs.EMPTY_PATH;
|
|
82
83
|
for (const part of parts) {
|
|
83
84
|
if (!part) {
|
|
84
85
|
throw new Error(`Invalid path: empty segment`);
|
|
@@ -106,7 +107,7 @@ var ParsedFormula = class {
|
|
|
106
107
|
this.astNode = parseResult.ast;
|
|
107
108
|
const formulaPath = tree.pathOf(formulaNodeId);
|
|
108
109
|
if (formulaPath.isEmpty() && tree.root().id() !== formulaNodeId) {
|
|
109
|
-
throw new
|
|
110
|
+
throw new chunkRCCBUOGY_cjs.FormulaError("Formula node not found in tree", formulaNodeId);
|
|
110
111
|
}
|
|
111
112
|
const deps = [];
|
|
112
113
|
const astPathToNodeId = /* @__PURE__ */ new Map();
|
|
@@ -117,20 +118,20 @@ var ParsedFormula = class {
|
|
|
117
118
|
depPath
|
|
118
119
|
);
|
|
119
120
|
if (!targetNodeId) {
|
|
120
|
-
throw new
|
|
121
|
+
throw new chunkRCCBUOGY_cjs.FormulaError(
|
|
121
122
|
`Cannot resolve formula dependency: ${depPath}`,
|
|
122
123
|
formulaNodeId,
|
|
123
124
|
"Path not found in schema"
|
|
124
125
|
);
|
|
125
126
|
}
|
|
126
127
|
if (targetNodeId === formulaNodeId) {
|
|
127
|
-
throw new
|
|
128
|
+
throw new chunkRCCBUOGY_cjs.FormulaError(
|
|
128
129
|
"Formula cannot reference itself",
|
|
129
130
|
formulaNodeId,
|
|
130
131
|
"Self-reference detected"
|
|
131
132
|
);
|
|
132
133
|
}
|
|
133
|
-
deps.push(new
|
|
134
|
+
deps.push(new chunkRCCBUOGY_cjs.ResolvedDependency(targetNodeId));
|
|
134
135
|
astPathToNodeId.set(depPath, targetNodeId);
|
|
135
136
|
}
|
|
136
137
|
this.deps = deps;
|
|
@@ -294,7 +295,7 @@ var FormulaChangeDetector = class {
|
|
|
294
295
|
}
|
|
295
296
|
getSerializedExpression(formula, tree, nodeId) {
|
|
296
297
|
try {
|
|
297
|
-
const xFormula =
|
|
298
|
+
const xFormula = chunkRCCBUOGY_cjs.FormulaSerializer.toXFormula(tree, nodeId, formula);
|
|
298
299
|
return xFormula.expression;
|
|
299
300
|
} catch {
|
|
300
301
|
return null;
|
|
@@ -341,7 +342,7 @@ var SchemaParser = class {
|
|
|
341
342
|
if (resolvedSchema) {
|
|
342
343
|
return this.parseNode(resolvedSchema, name, refValue);
|
|
343
344
|
}
|
|
344
|
-
return
|
|
345
|
+
return chunkRCCBUOGY_cjs.createRefNode(nanoid.nanoid(), name, refValue, this.extractMetadata(schema));
|
|
345
346
|
}
|
|
346
347
|
const schemaWithType = schema;
|
|
347
348
|
switch (schemaWithType.type) {
|
|
@@ -367,14 +368,14 @@ var SchemaParser = class {
|
|
|
367
368
|
children.push(this.parseNode(propSchema, propName));
|
|
368
369
|
}
|
|
369
370
|
}
|
|
370
|
-
return
|
|
371
|
+
return chunkRCCBUOGY_cjs.createObjectNode(nanoid.nanoid(), name, children, {
|
|
371
372
|
metadata: this.extractMetadata(schema),
|
|
372
373
|
ref: ref2
|
|
373
374
|
});
|
|
374
375
|
}
|
|
375
376
|
parseArray(schema, name, ref2) {
|
|
376
377
|
const items = this.parseNode(schema.items, "items");
|
|
377
|
-
return
|
|
378
|
+
return chunkRCCBUOGY_cjs.createArrayNode(nanoid.nanoid(), name, items, {
|
|
378
379
|
metadata: this.extractMetadata(schema),
|
|
379
380
|
ref: ref2
|
|
380
381
|
});
|
|
@@ -382,7 +383,7 @@ var SchemaParser = class {
|
|
|
382
383
|
parseString(schema, name, ref2) {
|
|
383
384
|
const nodeId = nanoid.nanoid();
|
|
384
385
|
this.collectFormula(nodeId, schema["x-formula"]);
|
|
385
|
-
return
|
|
386
|
+
return chunkRCCBUOGY_cjs.createStringNode(nodeId, name, {
|
|
386
387
|
defaultValue: schema.default,
|
|
387
388
|
foreignKey: schema.foreignKey,
|
|
388
389
|
metadata: this.extractMetadata(schema),
|
|
@@ -392,7 +393,7 @@ var SchemaParser = class {
|
|
|
392
393
|
parseNumber(schema, name, ref2) {
|
|
393
394
|
const nodeId = nanoid.nanoid();
|
|
394
395
|
this.collectFormula(nodeId, schema["x-formula"]);
|
|
395
|
-
return
|
|
396
|
+
return chunkRCCBUOGY_cjs.createNumberNode(nodeId, name, {
|
|
396
397
|
defaultValue: schema.default,
|
|
397
398
|
metadata: this.extractMetadata(schema),
|
|
398
399
|
ref: ref2
|
|
@@ -401,7 +402,7 @@ var SchemaParser = class {
|
|
|
401
402
|
parseBoolean(schema, name, ref2) {
|
|
402
403
|
const nodeId = nanoid.nanoid();
|
|
403
404
|
this.collectFormula(nodeId, schema["x-formula"]);
|
|
404
|
-
return
|
|
405
|
+
return chunkRCCBUOGY_cjs.createBooleanNode(nodeId, name, {
|
|
405
406
|
defaultValue: schema.default,
|
|
406
407
|
metadata: this.extractMetadata(schema),
|
|
407
408
|
ref: ref2
|
|
@@ -434,13 +435,13 @@ var NodeFactory = class {
|
|
|
434
435
|
createNode(name, type) {
|
|
435
436
|
switch (type) {
|
|
436
437
|
case "string":
|
|
437
|
-
return
|
|
438
|
+
return chunkRCCBUOGY_cjs.createStringNode(nanoid.nanoid(), name, { defaultValue: "" });
|
|
438
439
|
case "number":
|
|
439
|
-
return
|
|
440
|
+
return chunkRCCBUOGY_cjs.createNumberNode(nanoid.nanoid(), name, { defaultValue: 0 });
|
|
440
441
|
case "boolean":
|
|
441
|
-
return
|
|
442
|
+
return chunkRCCBUOGY_cjs.createBooleanNode(nanoid.nanoid(), name, { defaultValue: false });
|
|
442
443
|
case "object":
|
|
443
|
-
return
|
|
444
|
+
return chunkRCCBUOGY_cjs.createObjectNode(nanoid.nanoid(), name, []);
|
|
444
445
|
case "array":
|
|
445
446
|
return this.createArrayNodeInternal(name);
|
|
446
447
|
default:
|
|
@@ -448,11 +449,11 @@ var NodeFactory = class {
|
|
|
448
449
|
}
|
|
449
450
|
}
|
|
450
451
|
createArrayNodeInternal(name) {
|
|
451
|
-
const items =
|
|
452
|
-
return
|
|
452
|
+
const items = chunkRCCBUOGY_cjs.createStringNode(nanoid.nanoid(), "items", { defaultValue: "" });
|
|
453
|
+
return chunkRCCBUOGY_cjs.createArrayNode(nanoid.nanoid(), name, items);
|
|
453
454
|
}
|
|
454
455
|
createArrayNodeWithItems(name, items) {
|
|
455
|
-
return
|
|
456
|
+
return chunkRCCBUOGY_cjs.createArrayNode(nanoid.nanoid(), name, items);
|
|
456
457
|
}
|
|
457
458
|
};
|
|
458
459
|
|
|
@@ -551,7 +552,7 @@ var PrimitiveToArrayTransformer = class {
|
|
|
551
552
|
const { sourceNode } = ctx;
|
|
552
553
|
const itemsNode = sourceNode.cloneWithId(nanoid.nanoid());
|
|
553
554
|
itemsNode.setName("items");
|
|
554
|
-
const arrayNode =
|
|
555
|
+
const arrayNode = chunkRCCBUOGY_cjs.createArrayNode(sourceNode.id(), sourceNode.name(), itemsNode);
|
|
555
556
|
return { node: arrayNode };
|
|
556
557
|
}
|
|
557
558
|
};
|
|
@@ -564,7 +565,7 @@ var ObjectToArrayTransformer = class {
|
|
|
564
565
|
const { sourceNode } = ctx;
|
|
565
566
|
const itemsNode = sourceNode.cloneWithId(nanoid.nanoid());
|
|
566
567
|
itemsNode.setName("items");
|
|
567
|
-
const arrayNode =
|
|
568
|
+
const arrayNode = chunkRCCBUOGY_cjs.createArrayNode(sourceNode.id(), sourceNode.name(), itemsNode);
|
|
568
569
|
return { node: arrayNode };
|
|
569
570
|
}
|
|
570
571
|
};
|
|
@@ -606,7 +607,7 @@ var RefTransformer = class {
|
|
|
606
607
|
const resolvedSchema = refSchemas?.[refUri];
|
|
607
608
|
if (resolvedSchema) {
|
|
608
609
|
const parser = new SchemaParser();
|
|
609
|
-
const wrapperSchema =
|
|
610
|
+
const wrapperSchema = chunk2PIMJSWJ_cjs.obj({ temp: chunk2PIMJSWJ_cjs.ref(refUri) });
|
|
610
611
|
const resolvedNode = parser.parse(wrapperSchema, refSchemas);
|
|
611
612
|
const tempNode = resolvedNode.property("temp");
|
|
612
613
|
const newNode = tempNode.cloneWithId(sourceNode.id());
|
|
@@ -614,7 +615,7 @@ var RefTransformer = class {
|
|
|
614
615
|
return { node: newNode };
|
|
615
616
|
}
|
|
616
617
|
const metadata = this.extractMetadata(targetSpec);
|
|
617
|
-
const node =
|
|
618
|
+
const node = chunkRCCBUOGY_cjs.createRefNode(sourceNode.id(), sourceNode.name(), refUri, metadata);
|
|
618
619
|
return { node };
|
|
619
620
|
}
|
|
620
621
|
extractMetadata(spec) {
|
|
@@ -649,23 +650,23 @@ var DefaultTransformer = class {
|
|
|
649
650
|
createNode(id, name, type, spec, metadata) {
|
|
650
651
|
switch (type) {
|
|
651
652
|
case "string":
|
|
652
|
-
return
|
|
653
|
+
return chunkRCCBUOGY_cjs.createStringNode(id, name, {
|
|
653
654
|
defaultValue: spec.default ?? "",
|
|
654
655
|
foreignKey: spec.foreignKey,
|
|
655
656
|
metadata
|
|
656
657
|
});
|
|
657
658
|
case "number":
|
|
658
|
-
return
|
|
659
|
+
return chunkRCCBUOGY_cjs.createNumberNode(id, name, {
|
|
659
660
|
defaultValue: spec.default ?? 0,
|
|
660
661
|
metadata
|
|
661
662
|
});
|
|
662
663
|
case "boolean":
|
|
663
|
-
return
|
|
664
|
+
return chunkRCCBUOGY_cjs.createBooleanNode(id, name, {
|
|
664
665
|
defaultValue: spec.default ?? false,
|
|
665
666
|
metadata
|
|
666
667
|
});
|
|
667
668
|
case "object":
|
|
668
|
-
return
|
|
669
|
+
return chunkRCCBUOGY_cjs.createObjectNode(id, name, [], { metadata });
|
|
669
670
|
case "array":
|
|
670
671
|
return this.createArrayNode(id, name, metadata);
|
|
671
672
|
default:
|
|
@@ -673,8 +674,8 @@ var DefaultTransformer = class {
|
|
|
673
674
|
}
|
|
674
675
|
}
|
|
675
676
|
createArrayNode(id, name, metadata) {
|
|
676
|
-
const items =
|
|
677
|
-
return
|
|
677
|
+
const items = chunkRCCBUOGY_cjs.createStringNode(nanoid.nanoid(), "items", { defaultValue: "" });
|
|
678
|
+
return chunkRCCBUOGY_cjs.createArrayNode(id, name, items, { metadata });
|
|
678
679
|
}
|
|
679
680
|
extractMetadata(spec) {
|
|
680
681
|
const meta = {};
|
|
@@ -738,8 +739,8 @@ function createTypeTransformChain(options) {
|
|
|
738
739
|
var SchemaModelImpl = class {
|
|
739
740
|
_baseTree;
|
|
740
741
|
_currentTree;
|
|
741
|
-
_patchBuilder = new
|
|
742
|
-
_serializer = new
|
|
742
|
+
_patchBuilder = new chunkRCCBUOGY_cjs.PatchBuilder();
|
|
743
|
+
_serializer = new chunkRCCBUOGY_cjs.SchemaSerializer();
|
|
743
744
|
_nodeFactory = new NodeFactory();
|
|
744
745
|
_formulaIndex = new FormulaDependencyIndex();
|
|
745
746
|
_transformChain;
|
|
@@ -753,12 +754,12 @@ var SchemaModelImpl = class {
|
|
|
753
754
|
});
|
|
754
755
|
const parser = new SchemaParser();
|
|
755
756
|
const rootNode = parser.parse(schema, this._refSchemas);
|
|
756
|
-
this._currentTree =
|
|
757
|
+
this._currentTree = chunkRCCBUOGY_cjs.createSchemaTree(rootNode);
|
|
757
758
|
parser.parseFormulas(this._currentTree);
|
|
758
759
|
this._formulaParseErrors = parser.parseErrors;
|
|
759
760
|
this._buildFormulaIndex();
|
|
760
761
|
this._baseTree = this._currentTree.clone();
|
|
761
|
-
|
|
762
|
+
chunkRCCBUOGY_cjs.makeAutoObservable(this, {
|
|
762
763
|
_patchBuilder: false,
|
|
763
764
|
_serializer: false,
|
|
764
765
|
_nodeFactory: false,
|
|
@@ -787,10 +788,10 @@ var SchemaModelImpl = class {
|
|
|
787
788
|
insertFieldAt(parentId, index, name, type) {
|
|
788
789
|
const parent = this._currentTree.nodeById(parentId);
|
|
789
790
|
if (parent.isNull() || !parent.isObject()) {
|
|
790
|
-
return
|
|
791
|
+
return chunkRCCBUOGY_cjs.NULL_NODE;
|
|
791
792
|
}
|
|
792
793
|
if (index < 0 || index > parent.properties().length) {
|
|
793
|
-
return
|
|
794
|
+
return chunkRCCBUOGY_cjs.NULL_NODE;
|
|
794
795
|
}
|
|
795
796
|
const node = this._nodeFactory.createNode(name, type);
|
|
796
797
|
this._currentTree.insertChildAt(parentId, index, node);
|
|
@@ -1015,7 +1016,7 @@ var SchemaModelImpl = class {
|
|
|
1015
1016
|
return "";
|
|
1016
1017
|
}
|
|
1017
1018
|
try {
|
|
1018
|
-
return
|
|
1019
|
+
return chunkRCCBUOGY_cjs.FormulaSerializer.serializeExpression(
|
|
1019
1020
|
this._currentTree,
|
|
1020
1021
|
nodeId,
|
|
1021
1022
|
formula,
|
|
@@ -1026,10 +1027,10 @@ var SchemaModelImpl = class {
|
|
|
1026
1027
|
}
|
|
1027
1028
|
}
|
|
1028
1029
|
get validationErrors() {
|
|
1029
|
-
return
|
|
1030
|
+
return chunkRCCBUOGY_cjs.validateSchema(this._currentTree.root());
|
|
1030
1031
|
}
|
|
1031
1032
|
get formulaErrors() {
|
|
1032
|
-
return [...this._formulaParseErrors, ...
|
|
1033
|
+
return [...this._formulaParseErrors, ...chunkRCCBUOGY_cjs.validateFormulas(this._currentTree)];
|
|
1033
1034
|
}
|
|
1034
1035
|
get isDirty() {
|
|
1035
1036
|
return this.patches.length > 0;
|
|
@@ -1541,7 +1542,7 @@ var FormulaEngine = class {
|
|
|
1541
1542
|
this.setupReactions();
|
|
1542
1543
|
}
|
|
1543
1544
|
evaluateAll() {
|
|
1544
|
-
|
|
1545
|
+
chunkRCCBUOGY_cjs.runInAction(() => {
|
|
1545
1546
|
for (const field of this.evaluationOrder) {
|
|
1546
1547
|
this.evaluator.evaluate(field);
|
|
1547
1548
|
}
|
|
@@ -1554,7 +1555,7 @@ var FormulaEngine = class {
|
|
|
1554
1555
|
continue;
|
|
1555
1556
|
}
|
|
1556
1557
|
watchedNodes.add(depNode);
|
|
1557
|
-
const disposer =
|
|
1558
|
+
const disposer = chunkRCCBUOGY_cjs.reaction(
|
|
1558
1559
|
() => depNode.value,
|
|
1559
1560
|
() => this.handleDependencyChange(depNode)
|
|
1560
1561
|
);
|
|
@@ -1564,7 +1565,7 @@ var FormulaEngine = class {
|
|
|
1564
1565
|
}
|
|
1565
1566
|
setupArrayReactions(node) {
|
|
1566
1567
|
if (node.isArray()) {
|
|
1567
|
-
const disposer =
|
|
1568
|
+
const disposer = chunkRCCBUOGY_cjs.reaction(
|
|
1568
1569
|
() => node.length,
|
|
1569
1570
|
() => this.handleStructureChange()
|
|
1570
1571
|
);
|
|
@@ -1584,7 +1585,7 @@ var FormulaEngine = class {
|
|
|
1584
1585
|
this.dependencyMap,
|
|
1585
1586
|
this.evaluationOrder
|
|
1586
1587
|
);
|
|
1587
|
-
|
|
1588
|
+
chunkRCCBUOGY_cjs.runInAction(() => {
|
|
1588
1589
|
for (const field of affected) {
|
|
1589
1590
|
this.evaluator.evaluate(field);
|
|
1590
1591
|
}
|
|
@@ -1600,8 +1601,6 @@ var FormulaEngine = class {
|
|
|
1600
1601
|
this.disposers = [];
|
|
1601
1602
|
}
|
|
1602
1603
|
};
|
|
1603
|
-
|
|
1604
|
-
// src/model/value-node/BaseValueNode.ts
|
|
1605
1604
|
var nodeIdCounter = 0;
|
|
1606
1605
|
function generateNodeId() {
|
|
1607
1606
|
return `node-${++nodeIdCounter}`;
|
|
@@ -1614,11 +1613,21 @@ var BaseValueNode = class {
|
|
|
1614
1613
|
schema;
|
|
1615
1614
|
_parent = null;
|
|
1616
1615
|
_name;
|
|
1616
|
+
_emitter = new eventemitter3.EventEmitter();
|
|
1617
1617
|
constructor(id, name, schema) {
|
|
1618
1618
|
this.id = id ?? generateNodeId();
|
|
1619
1619
|
this._name = name;
|
|
1620
1620
|
this.schema = schema;
|
|
1621
1621
|
}
|
|
1622
|
+
on(event, listener) {
|
|
1623
|
+
this._emitter.on(event, listener);
|
|
1624
|
+
}
|
|
1625
|
+
off(event, listener) {
|
|
1626
|
+
this._emitter.off(event, listener);
|
|
1627
|
+
}
|
|
1628
|
+
emit(changeEvent) {
|
|
1629
|
+
this._emitter.emit("change", changeEvent);
|
|
1630
|
+
}
|
|
1622
1631
|
get parent() {
|
|
1623
1632
|
return this._parent;
|
|
1624
1633
|
}
|
|
@@ -1676,7 +1685,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1676
1685
|
_nodeFactory = null;
|
|
1677
1686
|
constructor(id, name, schema, items) {
|
|
1678
1687
|
super(id, name, schema);
|
|
1679
|
-
this._items =
|
|
1688
|
+
this._items = chunkRCCBUOGY_cjs.observable.array();
|
|
1680
1689
|
this._baseItems = [];
|
|
1681
1690
|
if (items) {
|
|
1682
1691
|
for (const item of items) {
|
|
@@ -1685,7 +1694,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1685
1694
|
}
|
|
1686
1695
|
}
|
|
1687
1696
|
this._baseItems = [...this._items];
|
|
1688
|
-
|
|
1697
|
+
chunkRCCBUOGY_cjs.makeObservable(this, {
|
|
1689
1698
|
_items: "observable",
|
|
1690
1699
|
_baseItems: "observable",
|
|
1691
1700
|
value: "computed",
|
|
@@ -1724,6 +1733,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1724
1733
|
push(node) {
|
|
1725
1734
|
node.parent = this;
|
|
1726
1735
|
this._items.push(node);
|
|
1736
|
+
this.emit({ type: "arrayPush", array: this, item: node });
|
|
1727
1737
|
}
|
|
1728
1738
|
insertAt(index, node) {
|
|
1729
1739
|
if (index < 0 || index > this._items.length) {
|
|
@@ -1731,6 +1741,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1731
1741
|
}
|
|
1732
1742
|
node.parent = this;
|
|
1733
1743
|
this._items.splice(index, 0, node);
|
|
1744
|
+
this.emit({ type: "arrayInsert", array: this, index, item: node });
|
|
1734
1745
|
}
|
|
1735
1746
|
removeAt(index) {
|
|
1736
1747
|
if (index < 0 || index >= this._items.length) {
|
|
@@ -1740,6 +1751,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1740
1751
|
if (removed) {
|
|
1741
1752
|
removed.parent = null;
|
|
1742
1753
|
}
|
|
1754
|
+
this.emit({ type: "arrayRemove", array: this, index, item: removed });
|
|
1743
1755
|
}
|
|
1744
1756
|
move(fromIndex, toIndex) {
|
|
1745
1757
|
if (fromIndex < 0 || fromIndex >= this._items.length) {
|
|
@@ -1755,23 +1767,25 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1755
1767
|
if (item) {
|
|
1756
1768
|
this._items.splice(toIndex, 0, item);
|
|
1757
1769
|
}
|
|
1770
|
+
this.emit({ type: "arrayMove", array: this, fromIndex, toIndex });
|
|
1758
1771
|
}
|
|
1759
1772
|
replaceAt(index, node) {
|
|
1760
1773
|
if (index < 0 || index >= this._items.length) {
|
|
1761
1774
|
throw new Error(`Index out of bounds: ${index}`);
|
|
1762
1775
|
}
|
|
1763
1776
|
const oldNode = this._items[index];
|
|
1764
|
-
|
|
1765
|
-
oldNode.parent = null;
|
|
1766
|
-
}
|
|
1777
|
+
oldNode.parent = null;
|
|
1767
1778
|
node.parent = this;
|
|
1768
1779
|
this._items[index] = node;
|
|
1780
|
+
this.emit({ type: "arrayReplace", array: this, index, item: node, oldItem: oldNode });
|
|
1769
1781
|
}
|
|
1770
1782
|
clear() {
|
|
1771
|
-
|
|
1783
|
+
const removed = [...this._items];
|
|
1784
|
+
for (const item of removed) {
|
|
1772
1785
|
item.parent = null;
|
|
1773
1786
|
}
|
|
1774
1787
|
this._items.length = 0;
|
|
1788
|
+
this.emit({ type: "arrayClear", array: this, items: removed });
|
|
1775
1789
|
}
|
|
1776
1790
|
setNodeFactory(factory) {
|
|
1777
1791
|
this._nodeFactory = factory;
|
|
@@ -1867,7 +1881,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1867
1881
|
for (const item of this._items) {
|
|
1868
1882
|
item.parent = null;
|
|
1869
1883
|
}
|
|
1870
|
-
this._items =
|
|
1884
|
+
this._items = chunkRCCBUOGY_cjs.observable.array();
|
|
1871
1885
|
for (const baseItem of this._baseItems) {
|
|
1872
1886
|
this._items.push(baseItem);
|
|
1873
1887
|
}
|
|
@@ -1910,7 +1924,7 @@ var BasePrimitiveValueNode = class extends BaseValueNode {
|
|
|
1910
1924
|
this._baseValue = initialValue;
|
|
1911
1925
|
}
|
|
1912
1926
|
initObservable() {
|
|
1913
|
-
|
|
1927
|
+
chunkRCCBUOGY_cjs.makeObservable(this, {
|
|
1914
1928
|
_value: "observable",
|
|
1915
1929
|
_baseValue: "observable",
|
|
1916
1930
|
_formulaWarning: "observable",
|
|
@@ -1938,6 +1952,9 @@ var BasePrimitiveValueNode = class extends BaseValueNode {
|
|
|
1938
1952
|
return this._baseValue;
|
|
1939
1953
|
}
|
|
1940
1954
|
get isDirty() {
|
|
1955
|
+
if (this.formula !== void 0) {
|
|
1956
|
+
return false;
|
|
1957
|
+
}
|
|
1941
1958
|
return this._value !== this._baseValue;
|
|
1942
1959
|
}
|
|
1943
1960
|
get formula() {
|
|
@@ -1957,7 +1974,11 @@ var BasePrimitiveValueNode = class extends BaseValueNode {
|
|
|
1957
1974
|
if (this.isReadOnly && !options?.internal) {
|
|
1958
1975
|
throw new Error(`Cannot set value on read-only field: ${this.name}`);
|
|
1959
1976
|
}
|
|
1977
|
+
const oldValue = this._value;
|
|
1960
1978
|
this._value = this.coerceValue(value);
|
|
1979
|
+
if (!options?.internal) {
|
|
1980
|
+
this.emit({ type: "setValue", node: this, value: this._value, oldValue });
|
|
1981
|
+
}
|
|
1961
1982
|
}
|
|
1962
1983
|
setFormulaWarning(warning) {
|
|
1963
1984
|
this._formulaWarning = warning;
|
|
@@ -2258,7 +2279,7 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
2258
2279
|
_baseChildren;
|
|
2259
2280
|
constructor(id, name, schema, children) {
|
|
2260
2281
|
super(id, name, schema);
|
|
2261
|
-
this._children =
|
|
2282
|
+
this._children = chunkRCCBUOGY_cjs.observable.map();
|
|
2262
2283
|
this._baseChildren = /* @__PURE__ */ new Map();
|
|
2263
2284
|
if (children) {
|
|
2264
2285
|
for (const child of children) {
|
|
@@ -2267,7 +2288,7 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
2267
2288
|
}
|
|
2268
2289
|
}
|
|
2269
2290
|
this._baseChildren = new Map(this._children);
|
|
2270
|
-
|
|
2291
|
+
chunkRCCBUOGY_cjs.makeObservable(this, {
|
|
2271
2292
|
_children: "observable",
|
|
2272
2293
|
_baseChildren: "observable",
|
|
2273
2294
|
value: "computed",
|
|
@@ -2308,12 +2329,14 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
2308
2329
|
}
|
|
2309
2330
|
node.parent = this;
|
|
2310
2331
|
this._children.set(node.name, node);
|
|
2332
|
+
this.emit({ type: "addChild", parent: this, child: node });
|
|
2311
2333
|
}
|
|
2312
2334
|
removeChild(name) {
|
|
2313
2335
|
const node = this._children.get(name);
|
|
2314
2336
|
if (node) {
|
|
2315
2337
|
node.parent = null;
|
|
2316
2338
|
this._children.delete(name);
|
|
2339
|
+
this.emit({ type: "removeChild", parent: this, childName: name, child: node });
|
|
2317
2340
|
}
|
|
2318
2341
|
}
|
|
2319
2342
|
setValue(value, options) {
|
|
@@ -2359,7 +2382,7 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
2359
2382
|
for (const child of this._children.values()) {
|
|
2360
2383
|
child.parent = null;
|
|
2361
2384
|
}
|
|
2362
|
-
this._children =
|
|
2385
|
+
this._children = chunkRCCBUOGY_cjs.observable.map();
|
|
2363
2386
|
for (const [key, value] of this._baseChildren) {
|
|
2364
2387
|
this._children.set(key, value);
|
|
2365
2388
|
}
|
|
@@ -2573,7 +2596,7 @@ var IndexSegment = class {
|
|
|
2573
2596
|
};
|
|
2574
2597
|
|
|
2575
2598
|
// src/core/value-path/ValuePath.ts
|
|
2576
|
-
var ValuePathImpl = class _ValuePathImpl extends
|
|
2599
|
+
var ValuePathImpl = class _ValuePathImpl extends chunkRCCBUOGY_cjs.AbstractBasePath {
|
|
2577
2600
|
asString() {
|
|
2578
2601
|
const parts = [];
|
|
2579
2602
|
for (const seg of this.segs) {
|
|
@@ -2839,16 +2862,22 @@ var ValueTree = class {
|
|
|
2839
2862
|
this._root = _root;
|
|
2840
2863
|
this.index = new TreeIndex(_root);
|
|
2841
2864
|
this.changeTracker = new ChangeTracker();
|
|
2842
|
-
|
|
2865
|
+
this._nodeChangeListener = (event) => this.handleNodeChange(event);
|
|
2866
|
+
this.subscribe(this._root);
|
|
2867
|
+
chunkRCCBUOGY_cjs.makeAutoObservable(this, {
|
|
2843
2868
|
_root: false,
|
|
2844
2869
|
index: false,
|
|
2845
2870
|
changeTracker: false,
|
|
2846
|
-
|
|
2871
|
+
_nodeChangeListener: false,
|
|
2872
|
+
_formulaEngine: false,
|
|
2873
|
+
_suppressEvents: false
|
|
2847
2874
|
});
|
|
2848
2875
|
}
|
|
2849
2876
|
index;
|
|
2850
2877
|
changeTracker;
|
|
2878
|
+
_nodeChangeListener;
|
|
2851
2879
|
_formulaEngine = null;
|
|
2880
|
+
_suppressEvents = false;
|
|
2852
2881
|
get root() {
|
|
2853
2882
|
return this._root;
|
|
2854
2883
|
}
|
|
@@ -2892,12 +2921,17 @@ var ValueTree = class {
|
|
|
2892
2921
|
throw new Error(`Path not found: ${path}`);
|
|
2893
2922
|
}
|
|
2894
2923
|
const oldValue = node.getPlainValue();
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
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;
|
|
2901
2935
|
}
|
|
2902
2936
|
this.changeTracker.track({
|
|
2903
2937
|
type: "setValue",
|
|
@@ -2936,11 +2970,13 @@ var ValueTree = class {
|
|
|
2936
2970
|
this.changeTracker.clear();
|
|
2937
2971
|
}
|
|
2938
2972
|
revert() {
|
|
2973
|
+
this.unsubscribe(this._root);
|
|
2939
2974
|
const root = this._root;
|
|
2940
2975
|
if ("revert" in root && typeof root.revert === "function") {
|
|
2941
2976
|
root.revert();
|
|
2942
2977
|
}
|
|
2943
2978
|
this.changeTracker.clear();
|
|
2979
|
+
this.subscribe(this._root);
|
|
2944
2980
|
}
|
|
2945
2981
|
rebuildIndex() {
|
|
2946
2982
|
this.index.rebuild();
|
|
@@ -2958,9 +2994,126 @@ var ValueTree = class {
|
|
|
2958
2994
|
return this._formulaEngine;
|
|
2959
2995
|
}
|
|
2960
2996
|
dispose() {
|
|
2997
|
+
this.unsubscribe(this._root);
|
|
2961
2998
|
this._formulaEngine?.dispose();
|
|
2962
2999
|
this._formulaEngine = null;
|
|
2963
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
|
+
}
|
|
2964
3117
|
};
|
|
2965
3118
|
|
|
2966
3119
|
// src/model/table/row/RowModelImpl.ts
|
|
@@ -2969,7 +3122,7 @@ var RowModelImpl = class {
|
|
|
2969
3122
|
constructor(_rowId, _tree) {
|
|
2970
3123
|
this._rowId = _rowId;
|
|
2971
3124
|
this._tree = _tree;
|
|
2972
|
-
|
|
3125
|
+
chunkRCCBUOGY_cjs.makeAutoObservable(this, {
|
|
2973
3126
|
_rowId: false,
|
|
2974
3127
|
_tree: false,
|
|
2975
3128
|
_tableModel: "observable.ref"
|
|
@@ -3080,13 +3233,13 @@ var TableModelImpl = class {
|
|
|
3080
3233
|
this._schema = createSchemaModel(options.schema, { refSchemas: options.refSchemas });
|
|
3081
3234
|
this._fkResolver = options.fkResolver;
|
|
3082
3235
|
this._refSchemas = options.refSchemas;
|
|
3083
|
-
this._rows =
|
|
3236
|
+
this._rows = chunkRCCBUOGY_cjs.observable.array();
|
|
3084
3237
|
if (options.rows) {
|
|
3085
3238
|
for (const row of options.rows) {
|
|
3086
3239
|
this._rows.push(this.createRow(row.rowId, row.data));
|
|
3087
3240
|
}
|
|
3088
3241
|
}
|
|
3089
|
-
|
|
3242
|
+
chunkRCCBUOGY_cjs.makeAutoObservable(this, {
|
|
3090
3243
|
_schema: false,
|
|
3091
3244
|
_rows: false,
|
|
3092
3245
|
_jsonSchema: false,
|
|
@@ -3217,13 +3370,13 @@ var ForeignKeyResolverImpl = class {
|
|
|
3217
3370
|
constructor(options) {
|
|
3218
3371
|
this.loader = options?.loader;
|
|
3219
3372
|
this._prefetchEnabled = options?.prefetch ?? false;
|
|
3220
|
-
this._schemaCache =
|
|
3221
|
-
this._tableCache =
|
|
3373
|
+
this._schemaCache = chunkRCCBUOGY_cjs.observable.map();
|
|
3374
|
+
this._tableCache = chunkRCCBUOGY_cjs.observable.map();
|
|
3222
3375
|
this._loadingTables = /* @__PURE__ */ new Set();
|
|
3223
3376
|
this._loadingRows = /* @__PURE__ */ new Map();
|
|
3224
3377
|
this._pendingTableLoads = /* @__PURE__ */ new Map();
|
|
3225
3378
|
this._pendingRowLoads = /* @__PURE__ */ new Map();
|
|
3226
|
-
|
|
3379
|
+
chunkRCCBUOGY_cjs.makeAutoObservable(this, {
|
|
3227
3380
|
_schemaCache: false,
|
|
3228
3381
|
_tableCache: false,
|
|
3229
3382
|
_loadingTables: false,
|
|
@@ -3261,7 +3414,7 @@ var ForeignKeyResolverImpl = class {
|
|
|
3261
3414
|
if (this._disposed) {
|
|
3262
3415
|
return;
|
|
3263
3416
|
}
|
|
3264
|
-
|
|
3417
|
+
chunkRCCBUOGY_cjs.runInAction(() => {
|
|
3265
3418
|
this._schemaCache.set(tableId, schema);
|
|
3266
3419
|
});
|
|
3267
3420
|
}
|
|
@@ -3269,12 +3422,12 @@ var ForeignKeyResolverImpl = class {
|
|
|
3269
3422
|
if (this._disposed) {
|
|
3270
3423
|
return;
|
|
3271
3424
|
}
|
|
3272
|
-
const rowMap =
|
|
3425
|
+
const rowMap = chunkRCCBUOGY_cjs.observable.map();
|
|
3273
3426
|
for (const row of rows) {
|
|
3274
3427
|
rowMap.set(row.rowId, row);
|
|
3275
3428
|
}
|
|
3276
3429
|
const cache = { schema, rows: rowMap };
|
|
3277
|
-
|
|
3430
|
+
chunkRCCBUOGY_cjs.runInAction(() => {
|
|
3278
3431
|
this._tableCache.set(tableId, cache);
|
|
3279
3432
|
this._schemaCache.set(tableId, schema);
|
|
3280
3433
|
});
|
|
@@ -3289,7 +3442,7 @@ var ForeignKeyResolverImpl = class {
|
|
|
3289
3442
|
const table = this._tableCache.get(tableId);
|
|
3290
3443
|
if (table) {
|
|
3291
3444
|
const rowData = { rowId, data };
|
|
3292
|
-
|
|
3445
|
+
chunkRCCBUOGY_cjs.runInAction(() => {
|
|
3293
3446
|
table.rows.set(rowId, rowData);
|
|
3294
3447
|
});
|
|
3295
3448
|
if (this._prefetchEnabled) {
|
|
@@ -3303,7 +3456,7 @@ var ForeignKeyResolverImpl = class {
|
|
|
3303
3456
|
}
|
|
3304
3457
|
const schema = this._schemaCache.get(oldTableId);
|
|
3305
3458
|
const tableCache = this._tableCache.get(oldTableId);
|
|
3306
|
-
|
|
3459
|
+
chunkRCCBUOGY_cjs.runInAction(() => {
|
|
3307
3460
|
if (schema) {
|
|
3308
3461
|
this._schemaCache.delete(oldTableId);
|
|
3309
3462
|
this._schemaCache.set(newTableId, schema);
|
|
@@ -3405,9 +3558,9 @@ var ForeignKeyResolverImpl = class {
|
|
|
3405
3558
|
}
|
|
3406
3559
|
ensureTableCache(tableId, schema) {
|
|
3407
3560
|
if (!this._tableCache.has(tableId)) {
|
|
3408
|
-
const rowMap =
|
|
3561
|
+
const rowMap = chunkRCCBUOGY_cjs.observable.map();
|
|
3409
3562
|
const cache = { schema, rows: rowMap };
|
|
3410
|
-
|
|
3563
|
+
chunkRCCBUOGY_cjs.runInAction(() => {
|
|
3411
3564
|
this._tableCache.set(tableId, cache);
|
|
3412
3565
|
});
|
|
3413
3566
|
}
|
|
@@ -3507,7 +3660,7 @@ var DataModelImpl = class {
|
|
|
3507
3660
|
_fk;
|
|
3508
3661
|
_ownsFkResolver;
|
|
3509
3662
|
constructor(options) {
|
|
3510
|
-
this._tables =
|
|
3663
|
+
this._tables = chunkRCCBUOGY_cjs.observable.map();
|
|
3511
3664
|
if (options?.fkResolver) {
|
|
3512
3665
|
this._fk = options.fkResolver;
|
|
3513
3666
|
this._ownsFkResolver = false;
|
|
@@ -3515,7 +3668,7 @@ var DataModelImpl = class {
|
|
|
3515
3668
|
this._fk = createForeignKeyResolver();
|
|
3516
3669
|
this._ownsFkResolver = true;
|
|
3517
3670
|
}
|
|
3518
|
-
|
|
3671
|
+
chunkRCCBUOGY_cjs.makeAutoObservable(this, {
|
|
3519
3672
|
_tables: false,
|
|
3520
3673
|
_fk: false,
|
|
3521
3674
|
_ownsFkResolver: false
|
|
@@ -3650,5 +3803,3 @@ exports.generateNodeId = generateNodeId;
|
|
|
3650
3803
|
exports.isForeignKeyValueNode = isForeignKeyValueNode;
|
|
3651
3804
|
exports.resetNodeIdCounter = resetNodeIdCounter;
|
|
3652
3805
|
exports.typedNode = typedNode;
|
|
3653
|
-
//# sourceMappingURL=chunk-F4POD7AE.cjs.map
|
|
3654
|
-
//# sourceMappingURL=chunk-F4POD7AE.cjs.map
|