@revisium/schema-toolkit 0.20.2 → 0.21.0
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/README.md +216 -0
- package/dist/FormulaPathBuilder-BUJRR0Am.d.cts +48 -0
- package/dist/FormulaPathBuilder-QR0htn-e.d.ts +48 -0
- package/dist/chunk-2NARA22J.js +3 -0
- package/dist/{chunk-NY3H6C7K.js.map → chunk-2NARA22J.js.map} +1 -1
- package/dist/{chunk-EGC32GPY.cjs → chunk-3DDUT57J.cjs} +21 -21
- package/dist/chunk-3DDUT57J.cjs.map +1 -0
- package/dist/{chunk-LLHQWDAR.js → chunk-62A5JJJ3.js} +21 -21
- package/dist/chunk-62A5JJJ3.js.map +1 -0
- package/dist/{chunk-R4CFU33U.js → chunk-BIBFHULN.js} +12 -9
- package/dist/chunk-BIBFHULN.js.map +1 -0
- package/dist/chunk-BZWL424W.cjs +4 -0
- package/dist/{chunk-G6ZKEVVU.cjs.map → chunk-BZWL424W.cjs.map} +1 -1
- package/dist/{chunk-J6SCHJKG.cjs → chunk-CGVYS7EK.cjs} +2 -2
- package/dist/chunk-CGVYS7EK.cjs.map +1 -0
- package/dist/{chunk-MPF6VCB5.js → chunk-DRPNJ4YP.js} +2 -2
- package/dist/chunk-DRPNJ4YP.js.map +1 -0
- package/dist/{chunk-FZ2MS4Q5.cjs → chunk-F4POD7AE.cjs} +149 -90
- package/dist/chunk-F4POD7AE.cjs.map +1 -0
- package/dist/{chunk-B3T6YB2D.cjs → chunk-HH2LDPVV.cjs} +30 -30
- package/dist/chunk-HH2LDPVV.cjs.map +1 -0
- package/dist/{chunk-46ME2TAU.cjs → chunk-JWYYVKRT.cjs} +7 -7
- package/dist/{chunk-46ME2TAU.cjs.map → chunk-JWYYVKRT.cjs.map} +1 -1
- package/dist/{chunk-U5YDA3LA.js → chunk-MK3IKVZO.js} +80 -24
- package/dist/chunk-MK3IKVZO.js.map +1 -0
- package/dist/{chunk-VGADCIBG.cjs → chunk-SBO2UMI3.cjs} +14 -8
- package/dist/chunk-SBO2UMI3.cjs.map +1 -0
- package/dist/{chunk-55AMH44G.js → chunk-TKMR6CQW.js} +30 -30
- package/dist/chunk-TKMR6CQW.js.map +1 -0
- package/dist/{chunk-3JZKQWQH.js → chunk-TMCRV6V5.js} +7 -7
- package/dist/{chunk-3JZKQWQH.js.map → chunk-TMCRV6V5.js.map} +1 -1
- package/dist/{chunk-QEV4Q4TR.js → chunk-UTSL45Q4.js} +32 -32
- package/dist/chunk-UTSL45Q4.js.map +1 -0
- package/dist/{chunk-V6JTSET2.cjs → chunk-Z7M4ZGC6.cjs} +51 -51
- package/dist/chunk-Z7M4ZGC6.cjs.map +1 -0
- package/dist/core/index.cjs +60 -62
- package/dist/core/index.d.cts +6 -4
- package/dist/core/index.d.ts +6 -4
- package/dist/core/index.js +1 -3
- package/dist/formula/index.d.cts +1 -1
- package/dist/formula/index.d.ts +1 -1
- package/dist/index.cjs +237 -214
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +9 -10
- package/dist/{json-patch.types-DY7k9hxy.d.ts → json-patch.types-BpVnp08Z.d.ts} +1 -1
- package/dist/{json-patch.types-Cu0Medki.d.cts → json-patch.types-eM6pYC2P.d.cts} +1 -1
- package/dist/{json-string.store-C58zbl31.d.ts → json-string.store-DfdLcgnM.d.ts} +11 -11
- package/dist/{json-string.store-DuI--IL2.d.cts → json-string.store-cAOADo23.d.cts} +11 -11
- package/dist/lib/index.cjs +41 -42
- package/dist/lib/index.d.cts +3 -3
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +4 -5
- package/dist/mocks/index.cjs +30 -19
- package/dist/mocks/index.d.cts +22 -8
- package/dist/mocks/index.d.ts +22 -8
- package/dist/mocks/index.js +2 -3
- package/dist/model/index.cjs +85 -76
- package/dist/model/index.d.cts +158 -346
- package/dist/model/index.d.ts +158 -346
- package/dist/model/index.js +4 -7
- package/dist/plugins/index.cjs +19 -20
- package/dist/plugins/index.d.cts +10 -10
- package/dist/plugins/index.d.ts +10 -10
- package/dist/plugins/index.js +1 -2
- package/dist/{schema.types-B5OgKLpV.d.cts → schema.types-On_VGw2m.d.cts} +7 -6
- package/dist/{schema.types-B5OgKLpV.d.ts → schema.types-On_VGw2m.d.ts} +7 -6
- package/dist/typed-BinPIf3R.d.ts +455 -0
- package/dist/typed-LSaUJayS.d.cts +455 -0
- package/dist/types/index.cjs +5 -6
- package/dist/types/index.d.cts +7 -5
- package/dist/types/index.d.ts +7 -5
- package/dist/types/index.js +1 -2
- package/dist/{FormulaPathBuilder-DwlKOvVB.d.ts → types-BIvIURgy.d.cts} +37 -82
- package/dist/{FormulaPathBuilder-D9LkBcSv.d.cts → types-C_pTFtSY.d.ts} +37 -82
- package/package.json +1 -1
- package/dist/chunk-3IKI64T2.js +0 -3
- package/dist/chunk-3IKI64T2.js.map +0 -1
- package/dist/chunk-55AMH44G.js.map +0 -1
- package/dist/chunk-B3T6YB2D.cjs.map +0 -1
- package/dist/chunk-EGC32GPY.cjs.map +0 -1
- package/dist/chunk-FZ2MS4Q5.cjs.map +0 -1
- package/dist/chunk-G6ZKEVVU.cjs +0 -4
- package/dist/chunk-J6SCHJKG.cjs.map +0 -1
- package/dist/chunk-LLHQWDAR.js.map +0 -1
- package/dist/chunk-MPF6VCB5.js.map +0 -1
- package/dist/chunk-NY3H6C7K.js +0 -3
- package/dist/chunk-QEV4Q4TR.js.map +0 -1
- package/dist/chunk-R4CFU33U.js.map +0 -1
- package/dist/chunk-TBFTADML.cjs +0 -4
- package/dist/chunk-TBFTADML.cjs.map +0 -1
- package/dist/chunk-U5YDA3LA.js.map +0 -1
- package/dist/chunk-V6JTSET2.cjs.map +0 -1
- package/dist/chunk-VGADCIBG.cjs.map +0 -1
- package/dist/json-value-patch.types-CgiEpchp.d.ts +0 -24
- package/dist/json-value-patch.types-LEJxcIWR.d.cts +0 -24
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
2
|
-
import { obj, ref } from './chunk-
|
|
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';
|
|
3
3
|
import { nanoid } from 'nanoid';
|
|
4
4
|
import { parseFormula, parseExpression, evaluateWithContext } from '@revisium/formula';
|
|
5
5
|
|
|
@@ -343,15 +343,15 @@ var SchemaParser = class {
|
|
|
343
343
|
}
|
|
344
344
|
const schemaWithType = schema;
|
|
345
345
|
switch (schemaWithType.type) {
|
|
346
|
-
case "object"
|
|
346
|
+
case "object":
|
|
347
347
|
return this.parseObject(schemaWithType, name, parentRef);
|
|
348
|
-
case "array"
|
|
348
|
+
case "array":
|
|
349
349
|
return this.parseArray(schemaWithType, name, parentRef);
|
|
350
|
-
case "string"
|
|
350
|
+
case "string":
|
|
351
351
|
return this.parseString(schemaWithType, name, parentRef);
|
|
352
|
-
case "number"
|
|
352
|
+
case "number":
|
|
353
353
|
return this.parseNumber(schemaWithType, name, parentRef);
|
|
354
|
-
case "boolean"
|
|
354
|
+
case "boolean":
|
|
355
355
|
return this.parseBoolean(schemaWithType, name, parentRef);
|
|
356
356
|
default:
|
|
357
357
|
throw new Error(`Unknown schema type: ${schemaWithType.type}`);
|
|
@@ -462,10 +462,10 @@ function isRefSchema(schema) {
|
|
|
462
462
|
return "$ref" in schema;
|
|
463
463
|
}
|
|
464
464
|
function isObjectSchema(schema) {
|
|
465
|
-
return "type" in schema && schema.type === "object"
|
|
465
|
+
return "type" in schema && schema.type === "object";
|
|
466
466
|
}
|
|
467
467
|
function isArraySchema(schema) {
|
|
468
|
-
return "type" in schema && schema.type === "array"
|
|
468
|
+
return "type" in schema && schema.type === "array";
|
|
469
469
|
}
|
|
470
470
|
function hasDefaultValue(schema) {
|
|
471
471
|
return "default" in schema && schema.default !== void 0;
|
|
@@ -475,11 +475,11 @@ function generatePrimitiveDefault(schema) {
|
|
|
475
475
|
return void 0;
|
|
476
476
|
}
|
|
477
477
|
switch (schema.type) {
|
|
478
|
-
case "string"
|
|
478
|
+
case "string":
|
|
479
479
|
return DEFAULT_STRING;
|
|
480
|
-
case "number"
|
|
480
|
+
case "number":
|
|
481
481
|
return DEFAULT_NUMBER;
|
|
482
|
-
case "boolean"
|
|
482
|
+
case "boolean":
|
|
483
483
|
return DEFAULT_BOOLEAN;
|
|
484
484
|
default:
|
|
485
485
|
return void 0;
|
|
@@ -1700,7 +1700,8 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1700
1700
|
commit: "action",
|
|
1701
1701
|
revert: "action",
|
|
1702
1702
|
pushValue: "action",
|
|
1703
|
-
insertValueAt: "action"
|
|
1703
|
+
insertValueAt: "action",
|
|
1704
|
+
setValue: "action"
|
|
1704
1705
|
});
|
|
1705
1706
|
}
|
|
1706
1707
|
get value() {
|
|
@@ -1781,6 +1782,32 @@ var ArrayValueNode = class extends BaseValueNode {
|
|
|
1781
1782
|
const node = this.createItemNode(index, value);
|
|
1782
1783
|
this.insertAt(index, node);
|
|
1783
1784
|
}
|
|
1785
|
+
setValue(value, options) {
|
|
1786
|
+
const commonLength = Math.min(this._items.length, value.length);
|
|
1787
|
+
for (let i = 0; i < commonLength; i++) {
|
|
1788
|
+
const item = this._items[i];
|
|
1789
|
+
if (!item) {
|
|
1790
|
+
continue;
|
|
1791
|
+
}
|
|
1792
|
+
const itemValue = value[i];
|
|
1793
|
+
if (item.isObject()) {
|
|
1794
|
+
item.setValue(itemValue, options);
|
|
1795
|
+
} else if (item.isArray()) {
|
|
1796
|
+
item.setValue(itemValue, options);
|
|
1797
|
+
} else if (item.isPrimitive()) {
|
|
1798
|
+
item.setValue(itemValue, options);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
if (value.length > this._items.length) {
|
|
1802
|
+
for (let i = this._items.length; i < value.length; i++) {
|
|
1803
|
+
this.pushValue(value[i]);
|
|
1804
|
+
}
|
|
1805
|
+
} else if (value.length < this._items.length) {
|
|
1806
|
+
for (let i = this._items.length - 1; i >= value.length; i--) {
|
|
1807
|
+
this.removeAt(i);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1784
1811
|
createItemNode(index, value) {
|
|
1785
1812
|
if (!this._nodeFactory) {
|
|
1786
1813
|
throw new Error("NodeFactory not set");
|
|
@@ -2184,7 +2211,7 @@ var NumberValueNode = class extends BasePrimitiveValueNode {
|
|
|
2184
2211
|
}
|
|
2185
2212
|
computeErrors() {
|
|
2186
2213
|
const errors = [];
|
|
2187
|
-
if (!("type" in this.schema) || this.schema.type !== "number"
|
|
2214
|
+
if (!("type" in this.schema) || this.schema.type !== "number") {
|
|
2188
2215
|
return errors;
|
|
2189
2216
|
}
|
|
2190
2217
|
const numberSchema = this.schema;
|
|
@@ -2248,6 +2275,7 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
2248
2275
|
warnings: "computed",
|
|
2249
2276
|
addChild: "action",
|
|
2250
2277
|
removeChild: "action",
|
|
2278
|
+
setValue: "action",
|
|
2251
2279
|
commit: "action",
|
|
2252
2280
|
revert: "action"
|
|
2253
2281
|
});
|
|
@@ -2286,6 +2314,21 @@ var ObjectValueNode = class extends BaseValueNode {
|
|
|
2286
2314
|
this._children.delete(name);
|
|
2287
2315
|
}
|
|
2288
2316
|
}
|
|
2317
|
+
setValue(value, options) {
|
|
2318
|
+
for (const [key, child] of this._children) {
|
|
2319
|
+
if (!(key in value)) {
|
|
2320
|
+
continue;
|
|
2321
|
+
}
|
|
2322
|
+
const childValue = value[key];
|
|
2323
|
+
if (child.isObject()) {
|
|
2324
|
+
child.setValue(childValue, options);
|
|
2325
|
+
} else if (child.isArray()) {
|
|
2326
|
+
child.setValue(childValue, options);
|
|
2327
|
+
} else if (child.isPrimitive()) {
|
|
2328
|
+
child.setValue(childValue, options);
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2289
2332
|
get isDirty() {
|
|
2290
2333
|
if (this._children.size !== this._baseChildren.size) {
|
|
2291
2334
|
return true;
|
|
@@ -2841,20 +2884,23 @@ var ValueTree = class {
|
|
|
2841
2884
|
const node = this.get(path);
|
|
2842
2885
|
return node?.getPlainValue();
|
|
2843
2886
|
}
|
|
2844
|
-
setValue(path, value) {
|
|
2887
|
+
setValue(path, value, options) {
|
|
2845
2888
|
const node = this.get(path);
|
|
2846
2889
|
if (!node) {
|
|
2847
2890
|
throw new Error(`Path not found: ${path}`);
|
|
2848
2891
|
}
|
|
2849
|
-
|
|
2850
|
-
|
|
2892
|
+
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);
|
|
2851
2899
|
}
|
|
2852
|
-
const oldValue = node.value;
|
|
2853
|
-
node.setValue(value);
|
|
2854
2900
|
this.changeTracker.track({
|
|
2855
2901
|
type: "setValue",
|
|
2856
2902
|
path: this.index.pathOf(node),
|
|
2857
|
-
value,
|
|
2903
|
+
value: node.getPlainValue(),
|
|
2858
2904
|
oldValue
|
|
2859
2905
|
});
|
|
2860
2906
|
}
|
|
@@ -3443,7 +3489,7 @@ var ForeignKeyResolverImpl = class {
|
|
|
3443
3489
|
return foreignKeys;
|
|
3444
3490
|
}
|
|
3445
3491
|
getForeignKeyFromSchema(schema) {
|
|
3446
|
-
if ("type" in schema && schema.type === "string"
|
|
3492
|
+
if ("type" in schema && schema.type === "string") {
|
|
3447
3493
|
return schema.foreignKey;
|
|
3448
3494
|
}
|
|
3449
3495
|
return void 0;
|
|
@@ -3547,6 +3593,16 @@ function createDataModel(options) {
|
|
|
3547
3593
|
return new DataModelImpl(options);
|
|
3548
3594
|
}
|
|
3549
3595
|
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3596
|
+
// src/model/value-tree/typed.ts
|
|
3597
|
+
function typedNode(node) {
|
|
3598
|
+
return node;
|
|
3599
|
+
}
|
|
3600
|
+
function createTypedTree(schema, data, options) {
|
|
3601
|
+
const factory = createNodeFactory(options);
|
|
3602
|
+
const root = factory.createTree(schema, data);
|
|
3603
|
+
return new ValueTree(root);
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
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
|