@revisium/schema-toolkit 0.16.2 → 0.16.3
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-OY5NX5DZ.cjs → chunk-62TO7J76.cjs} +50 -50
- package/dist/{chunk-OY5NX5DZ.cjs.map → chunk-62TO7J76.cjs.map} +1 -1
- package/dist/{chunk-KLDN3IHB.js → chunk-PGR2S2BR.js} +5 -2
- package/dist/chunk-PGR2S2BR.js.map +1 -0
- package/dist/{chunk-VQZNN335.js → chunk-R66AFTGQ.js} +3 -3
- package/dist/{chunk-VQZNN335.js.map → chunk-R66AFTGQ.js.map} +1 -1
- package/dist/{chunk-44ZEZUWU.cjs → chunk-VGB4YCGF.cjs} +5 -2
- package/dist/chunk-VGB4YCGF.cjs.map +1 -0
- package/dist/core/index.cjs +57 -57
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +95 -95
- package/dist/index.js +2 -2
- package/dist/model/index.cjs +39 -39
- package/dist/model/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-44ZEZUWU.cjs.map +0 -1
- package/dist/chunk-KLDN3IHB.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVGB4YCGF_cjs = require('./chunk-VGB4YCGF.cjs');
|
|
4
4
|
var nanoid = require('nanoid');
|
|
5
5
|
|
|
6
6
|
var SchemaParser = class {
|
|
@@ -18,7 +18,7 @@ var SchemaParser = class {
|
|
|
18
18
|
continue;
|
|
19
19
|
}
|
|
20
20
|
try {
|
|
21
|
-
const formula = new
|
|
21
|
+
const formula = new chunkVGB4YCGF_cjs.ParsedFormula(tree, pending.nodeId, pending.expression);
|
|
22
22
|
node.setFormula(formula);
|
|
23
23
|
} catch (error) {
|
|
24
24
|
this._parseErrors.push({
|
|
@@ -34,7 +34,7 @@ var SchemaParser = class {
|
|
|
34
34
|
}
|
|
35
35
|
parseNode(schema, name) {
|
|
36
36
|
if ("$ref" in schema) {
|
|
37
|
-
return
|
|
37
|
+
return chunkVGB4YCGF_cjs.createRefNode(nanoid.nanoid(), name, schema.$ref, this.extractMetadata(schema));
|
|
38
38
|
}
|
|
39
39
|
const schemaWithType = schema;
|
|
40
40
|
switch (schemaWithType.type) {
|
|
@@ -60,16 +60,16 @@ var SchemaParser = class {
|
|
|
60
60
|
children.push(this.parseNode(propSchema, propName));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
return
|
|
63
|
+
return chunkVGB4YCGF_cjs.createObjectNode(nanoid.nanoid(), name, children, this.extractMetadata(schema));
|
|
64
64
|
}
|
|
65
65
|
parseArray(schema, name) {
|
|
66
66
|
const items = this.parseNode(schema.items, "items");
|
|
67
|
-
return
|
|
67
|
+
return chunkVGB4YCGF_cjs.createArrayNode(nanoid.nanoid(), name, items, this.extractMetadata(schema));
|
|
68
68
|
}
|
|
69
69
|
parseString(schema, name) {
|
|
70
70
|
const nodeId = nanoid.nanoid();
|
|
71
71
|
this.collectFormula(nodeId, schema["x-formula"]);
|
|
72
|
-
return
|
|
72
|
+
return chunkVGB4YCGF_cjs.createStringNode(nodeId, name, {
|
|
73
73
|
defaultValue: schema.default,
|
|
74
74
|
foreignKey: schema.foreignKey,
|
|
75
75
|
metadata: this.extractMetadata(schema)
|
|
@@ -78,7 +78,7 @@ var SchemaParser = class {
|
|
|
78
78
|
parseNumber(schema, name) {
|
|
79
79
|
const nodeId = nanoid.nanoid();
|
|
80
80
|
this.collectFormula(nodeId, schema["x-formula"]);
|
|
81
|
-
return
|
|
81
|
+
return chunkVGB4YCGF_cjs.createNumberNode(nodeId, name, {
|
|
82
82
|
defaultValue: schema.default,
|
|
83
83
|
metadata: this.extractMetadata(schema)
|
|
84
84
|
});
|
|
@@ -86,7 +86,7 @@ var SchemaParser = class {
|
|
|
86
86
|
parseBoolean(schema, name) {
|
|
87
87
|
const nodeId = nanoid.nanoid();
|
|
88
88
|
this.collectFormula(nodeId, schema["x-formula"]);
|
|
89
|
-
return
|
|
89
|
+
return chunkVGB4YCGF_cjs.createBooleanNode(nodeId, name, {
|
|
90
90
|
defaultValue: schema.default,
|
|
91
91
|
metadata: this.extractMetadata(schema)
|
|
92
92
|
});
|
|
@@ -118,13 +118,13 @@ var NodeFactory = class {
|
|
|
118
118
|
createNode(name, type) {
|
|
119
119
|
switch (type) {
|
|
120
120
|
case "string":
|
|
121
|
-
return
|
|
121
|
+
return chunkVGB4YCGF_cjs.createStringNode(nanoid.nanoid(), name, { defaultValue: "" });
|
|
122
122
|
case "number":
|
|
123
|
-
return
|
|
123
|
+
return chunkVGB4YCGF_cjs.createNumberNode(nanoid.nanoid(), name, { defaultValue: 0 });
|
|
124
124
|
case "boolean":
|
|
125
|
-
return
|
|
125
|
+
return chunkVGB4YCGF_cjs.createBooleanNode(nanoid.nanoid(), name, { defaultValue: false });
|
|
126
126
|
case "object":
|
|
127
|
-
return
|
|
127
|
+
return chunkVGB4YCGF_cjs.createObjectNode(nanoid.nanoid(), name, []);
|
|
128
128
|
case "array":
|
|
129
129
|
return this.createArrayNodeInternal(name);
|
|
130
130
|
default:
|
|
@@ -132,11 +132,11 @@ var NodeFactory = class {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
createArrayNodeInternal(name) {
|
|
135
|
-
const items =
|
|
136
|
-
return
|
|
135
|
+
const items = chunkVGB4YCGF_cjs.createStringNode(nanoid.nanoid(), "items", { defaultValue: "" });
|
|
136
|
+
return chunkVGB4YCGF_cjs.createArrayNode(nanoid.nanoid(), name, items);
|
|
137
137
|
}
|
|
138
138
|
createArrayNodeWithItems(name, items) {
|
|
139
|
-
return
|
|
139
|
+
return chunkVGB4YCGF_cjs.createArrayNode(nanoid.nanoid(), name, items);
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
|
|
@@ -231,20 +231,20 @@ function generateDefaultValue(schema, options = {}) {
|
|
|
231
231
|
var SchemaModelImpl = class {
|
|
232
232
|
_baseTree;
|
|
233
233
|
_currentTree;
|
|
234
|
-
_patchBuilder = new
|
|
235
|
-
_serializer = new
|
|
234
|
+
_patchBuilder = new chunkVGB4YCGF_cjs.PatchBuilder();
|
|
235
|
+
_serializer = new chunkVGB4YCGF_cjs.SchemaSerializer();
|
|
236
236
|
_nodeFactory = new NodeFactory();
|
|
237
|
-
_formulaIndex = new
|
|
237
|
+
_formulaIndex = new chunkVGB4YCGF_cjs.FormulaDependencyIndex();
|
|
238
238
|
_formulaParseErrors = [];
|
|
239
239
|
constructor(schema) {
|
|
240
240
|
const parser = new SchemaParser();
|
|
241
241
|
const rootNode = parser.parse(schema);
|
|
242
|
-
this._currentTree =
|
|
242
|
+
this._currentTree = chunkVGB4YCGF_cjs.createSchemaTree(rootNode);
|
|
243
243
|
parser.parseFormulas(this._currentTree);
|
|
244
244
|
this._formulaParseErrors = parser.parseErrors;
|
|
245
245
|
this._buildFormulaIndex();
|
|
246
246
|
this._baseTree = this._currentTree.clone();
|
|
247
|
-
|
|
247
|
+
chunkVGB4YCGF_cjs.makeAutoObservable(this, {
|
|
248
248
|
_patchBuilder: false,
|
|
249
249
|
_serializer: false,
|
|
250
250
|
_nodeFactory: false,
|
|
@@ -319,7 +319,7 @@ var SchemaModelImpl = class {
|
|
|
319
319
|
this._formulaIndex.unregisterFormula(nodeId);
|
|
320
320
|
} else {
|
|
321
321
|
try {
|
|
322
|
-
const formula = new
|
|
322
|
+
const formula = new chunkVGB4YCGF_cjs.ParsedFormula(this._currentTree, nodeId, expression);
|
|
323
323
|
node.setFormula(formula);
|
|
324
324
|
this._formulaIndex.registerFormula(nodeId, formula);
|
|
325
325
|
} catch (error) {
|
|
@@ -487,7 +487,7 @@ var SchemaModelImpl = class {
|
|
|
487
487
|
if (!formula) {
|
|
488
488
|
return "";
|
|
489
489
|
}
|
|
490
|
-
return
|
|
490
|
+
return chunkVGB4YCGF_cjs.FormulaSerializer.serializeExpression(
|
|
491
491
|
this._currentTree,
|
|
492
492
|
nodeId,
|
|
493
493
|
formula,
|
|
@@ -495,10 +495,10 @@ var SchemaModelImpl = class {
|
|
|
495
495
|
);
|
|
496
496
|
}
|
|
497
497
|
get validationErrors() {
|
|
498
|
-
return
|
|
498
|
+
return chunkVGB4YCGF_cjs.validateSchema(this._currentTree.root());
|
|
499
499
|
}
|
|
500
500
|
get formulaErrors() {
|
|
501
|
-
return [...this._formulaParseErrors, ...
|
|
501
|
+
return [...this._formulaParseErrors, ...chunkVGB4YCGF_cjs.validateFormulas(this._currentTree)];
|
|
502
502
|
}
|
|
503
503
|
get isDirty() {
|
|
504
504
|
return this.patches.length > 0;
|
|
@@ -548,7 +548,7 @@ var RowModelImpl = class {
|
|
|
548
548
|
constructor(_rowId, _tree) {
|
|
549
549
|
this._rowId = _rowId;
|
|
550
550
|
this._tree = _tree;
|
|
551
|
-
|
|
551
|
+
chunkVGB4YCGF_cjs.makeAutoObservable(this, {
|
|
552
552
|
_rowId: false,
|
|
553
553
|
_tree: false,
|
|
554
554
|
_tableModel: "observable.ref"
|
|
@@ -700,7 +700,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
700
700
|
_nodeFactory = null;
|
|
701
701
|
constructor(id, name, schema, items) {
|
|
702
702
|
super(id, name, schema);
|
|
703
|
-
this._items =
|
|
703
|
+
this._items = chunkVGB4YCGF_cjs.observable.array();
|
|
704
704
|
this._baseItems = [];
|
|
705
705
|
if (items) {
|
|
706
706
|
for (const item of items) {
|
|
@@ -709,7 +709,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
709
709
|
}
|
|
710
710
|
}
|
|
711
711
|
this._baseItems = [...this._items];
|
|
712
|
-
|
|
712
|
+
chunkVGB4YCGF_cjs.makeObservable(this, {
|
|
713
713
|
_items: "observable",
|
|
714
714
|
_baseItems: "observable",
|
|
715
715
|
value: "computed",
|
|
@@ -864,7 +864,7 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
864
864
|
for (const item of this._items) {
|
|
865
865
|
item.parent = null;
|
|
866
866
|
}
|
|
867
|
-
this._items =
|
|
867
|
+
this._items = chunkVGB4YCGF_cjs.observable.array();
|
|
868
868
|
for (const baseItem of this._baseItems) {
|
|
869
869
|
this._items.push(baseItem);
|
|
870
870
|
}
|
|
@@ -907,7 +907,7 @@ var BasePrimitiveValueNode = class extends BaseValueNode {
|
|
|
907
907
|
this._baseValue = initialValue;
|
|
908
908
|
}
|
|
909
909
|
initObservable() {
|
|
910
|
-
|
|
910
|
+
chunkVGB4YCGF_cjs.makeObservable(this, {
|
|
911
911
|
_value: "observable",
|
|
912
912
|
_baseValue: "observable",
|
|
913
913
|
_formulaWarning: "observable",
|
|
@@ -1255,7 +1255,7 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
1255
1255
|
_baseChildren;
|
|
1256
1256
|
constructor(id, name, schema, children) {
|
|
1257
1257
|
super(id, name, schema);
|
|
1258
|
-
this._children =
|
|
1258
|
+
this._children = chunkVGB4YCGF_cjs.observable.map();
|
|
1259
1259
|
this._baseChildren = /* @__PURE__ */ new Map();
|
|
1260
1260
|
if (children) {
|
|
1261
1261
|
for (const child of children) {
|
|
@@ -1264,7 +1264,7 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
1264
1264
|
}
|
|
1265
1265
|
}
|
|
1266
1266
|
this._baseChildren = new Map(this._children);
|
|
1267
|
-
|
|
1267
|
+
chunkVGB4YCGF_cjs.makeObservable(this, {
|
|
1268
1268
|
_children: "observable",
|
|
1269
1269
|
_baseChildren: "observable",
|
|
1270
1270
|
value: "computed",
|
|
@@ -1340,7 +1340,7 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
1340
1340
|
for (const child of this._children.values()) {
|
|
1341
1341
|
child.parent = null;
|
|
1342
1342
|
}
|
|
1343
|
-
this._children =
|
|
1343
|
+
this._children = chunkVGB4YCGF_cjs.observable.map();
|
|
1344
1344
|
for (const [key, value] of this._baseChildren) {
|
|
1345
1345
|
this._children.set(key, value);
|
|
1346
1346
|
}
|
|
@@ -1554,7 +1554,7 @@ var IndexSegment = class {
|
|
|
1554
1554
|
};
|
|
1555
1555
|
|
|
1556
1556
|
// src/core/value-path/ValuePath.ts
|
|
1557
|
-
var ValuePathImpl = class _ValuePathImpl extends
|
|
1557
|
+
var ValuePathImpl = class _ValuePathImpl extends chunkVGB4YCGF_cjs.AbstractBasePath {
|
|
1558
1558
|
asString() {
|
|
1559
1559
|
const parts = [];
|
|
1560
1560
|
for (const seg of this.segs) {
|
|
@@ -1642,7 +1642,7 @@ function parseValuePath(path) {
|
|
|
1642
1642
|
var ValueTree = class {
|
|
1643
1643
|
constructor(_root) {
|
|
1644
1644
|
this._root = _root;
|
|
1645
|
-
|
|
1645
|
+
chunkVGB4YCGF_cjs.makeAutoObservable(this, {
|
|
1646
1646
|
_root: false
|
|
1647
1647
|
});
|
|
1648
1648
|
}
|
|
@@ -1730,13 +1730,13 @@ var TableModelImpl = class {
|
|
|
1730
1730
|
this._jsonSchema = options.schema;
|
|
1731
1731
|
this._schema = createSchemaModel(options.schema);
|
|
1732
1732
|
this._fkResolver = options.fkResolver;
|
|
1733
|
-
this._rows =
|
|
1733
|
+
this._rows = chunkVGB4YCGF_cjs.observable.array();
|
|
1734
1734
|
if (options.rows) {
|
|
1735
1735
|
for (const row of options.rows) {
|
|
1736
1736
|
this._rows.push(this.createRowModel(row.rowId, row.data));
|
|
1737
1737
|
}
|
|
1738
1738
|
}
|
|
1739
|
-
|
|
1739
|
+
chunkVGB4YCGF_cjs.makeAutoObservable(this, {
|
|
1740
1740
|
_schema: false,
|
|
1741
1741
|
_rows: false,
|
|
1742
1742
|
_jsonSchema: false,
|
|
@@ -1852,13 +1852,13 @@ var ForeignKeyResolverImpl = class {
|
|
|
1852
1852
|
constructor(options) {
|
|
1853
1853
|
this.loader = options?.loader;
|
|
1854
1854
|
this._prefetchEnabled = options?.prefetch ?? false;
|
|
1855
|
-
this._schemaCache =
|
|
1856
|
-
this._tableCache =
|
|
1855
|
+
this._schemaCache = chunkVGB4YCGF_cjs.observable.map();
|
|
1856
|
+
this._tableCache = chunkVGB4YCGF_cjs.observable.map();
|
|
1857
1857
|
this._loadingTables = /* @__PURE__ */ new Set();
|
|
1858
1858
|
this._loadingRows = /* @__PURE__ */ new Map();
|
|
1859
1859
|
this._pendingTableLoads = /* @__PURE__ */ new Map();
|
|
1860
1860
|
this._pendingRowLoads = /* @__PURE__ */ new Map();
|
|
1861
|
-
|
|
1861
|
+
chunkVGB4YCGF_cjs.makeAutoObservable(this, {
|
|
1862
1862
|
_schemaCache: false,
|
|
1863
1863
|
_tableCache: false,
|
|
1864
1864
|
_loadingTables: false,
|
|
@@ -1896,7 +1896,7 @@ var ForeignKeyResolverImpl = class {
|
|
|
1896
1896
|
if (this._disposed) {
|
|
1897
1897
|
return;
|
|
1898
1898
|
}
|
|
1899
|
-
|
|
1899
|
+
chunkVGB4YCGF_cjs.runInAction(() => {
|
|
1900
1900
|
this._schemaCache.set(tableId, schema);
|
|
1901
1901
|
});
|
|
1902
1902
|
}
|
|
@@ -1904,12 +1904,12 @@ var ForeignKeyResolverImpl = class {
|
|
|
1904
1904
|
if (this._disposed) {
|
|
1905
1905
|
return;
|
|
1906
1906
|
}
|
|
1907
|
-
const rowMap =
|
|
1907
|
+
const rowMap = chunkVGB4YCGF_cjs.observable.map();
|
|
1908
1908
|
for (const row of rows) {
|
|
1909
1909
|
rowMap.set(row.rowId, row);
|
|
1910
1910
|
}
|
|
1911
1911
|
const cache = { schema, rows: rowMap };
|
|
1912
|
-
|
|
1912
|
+
chunkVGB4YCGF_cjs.runInAction(() => {
|
|
1913
1913
|
this._tableCache.set(tableId, cache);
|
|
1914
1914
|
this._schemaCache.set(tableId, schema);
|
|
1915
1915
|
});
|
|
@@ -1924,7 +1924,7 @@ var ForeignKeyResolverImpl = class {
|
|
|
1924
1924
|
const table = this._tableCache.get(tableId);
|
|
1925
1925
|
if (table) {
|
|
1926
1926
|
const rowData = { rowId, data };
|
|
1927
|
-
|
|
1927
|
+
chunkVGB4YCGF_cjs.runInAction(() => {
|
|
1928
1928
|
table.rows.set(rowId, rowData);
|
|
1929
1929
|
});
|
|
1930
1930
|
if (this._prefetchEnabled) {
|
|
@@ -1938,7 +1938,7 @@ var ForeignKeyResolverImpl = class {
|
|
|
1938
1938
|
}
|
|
1939
1939
|
const schema = this._schemaCache.get(oldTableId);
|
|
1940
1940
|
const tableCache = this._tableCache.get(oldTableId);
|
|
1941
|
-
|
|
1941
|
+
chunkVGB4YCGF_cjs.runInAction(() => {
|
|
1942
1942
|
if (schema) {
|
|
1943
1943
|
this._schemaCache.delete(oldTableId);
|
|
1944
1944
|
this._schemaCache.set(newTableId, schema);
|
|
@@ -2040,9 +2040,9 @@ var ForeignKeyResolverImpl = class {
|
|
|
2040
2040
|
}
|
|
2041
2041
|
ensureTableCache(tableId, schema) {
|
|
2042
2042
|
if (!this._tableCache.has(tableId)) {
|
|
2043
|
-
const rowMap =
|
|
2043
|
+
const rowMap = chunkVGB4YCGF_cjs.observable.map();
|
|
2044
2044
|
const cache = { schema, rows: rowMap };
|
|
2045
|
-
|
|
2045
|
+
chunkVGB4YCGF_cjs.runInAction(() => {
|
|
2046
2046
|
this._tableCache.set(tableId, cache);
|
|
2047
2047
|
});
|
|
2048
2048
|
}
|
|
@@ -2142,7 +2142,7 @@ var DataModelImpl = class {
|
|
|
2142
2142
|
_fk;
|
|
2143
2143
|
_ownsFkResolver;
|
|
2144
2144
|
constructor(options) {
|
|
2145
|
-
this._tables =
|
|
2145
|
+
this._tables = chunkVGB4YCGF_cjs.observable.map();
|
|
2146
2146
|
if (options?.fkResolver) {
|
|
2147
2147
|
this._fk = options.fkResolver;
|
|
2148
2148
|
this._ownsFkResolver = false;
|
|
@@ -2150,7 +2150,7 @@ var DataModelImpl = class {
|
|
|
2150
2150
|
this._fk = createForeignKeyResolver();
|
|
2151
2151
|
this._ownsFkResolver = true;
|
|
2152
2152
|
}
|
|
2153
|
-
|
|
2153
|
+
chunkVGB4YCGF_cjs.makeAutoObservable(this, {
|
|
2154
2154
|
_tables: false,
|
|
2155
2155
|
_fk: false,
|
|
2156
2156
|
_ownsFkResolver: false
|
|
@@ -2260,5 +2260,5 @@ exports.generateDefaultValue = generateDefaultValue;
|
|
|
2260
2260
|
exports.generateNodeId = generateNodeId;
|
|
2261
2261
|
exports.isForeignKeyValueNode = isForeignKeyValueNode;
|
|
2262
2262
|
exports.resetNodeIdCounter = resetNodeIdCounter;
|
|
2263
|
-
//# sourceMappingURL=chunk-
|
|
2264
|
-
//# sourceMappingURL=chunk-
|
|
2263
|
+
//# sourceMappingURL=chunk-62TO7J76.cjs.map
|
|
2264
|
+
//# sourceMappingURL=chunk-62TO7J76.cjs.map
|