@revisium/schema-toolkit 0.17.0 → 0.19.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/dist/{chunk-RTBMPBPC.js → chunk-EPFW6FVB.js} +104 -177
- package/dist/chunk-EPFW6FVB.js.map +1 -0
- package/dist/{chunk-YRKXZTRZ.cjs → chunk-HLHODANT.cjs} +71 -59
- package/dist/chunk-HLHODANT.cjs.map +1 -0
- package/dist/{chunk-6EAIJMZV.js → chunk-OZ4ZCJXY.js} +15 -3
- package/dist/chunk-OZ4ZCJXY.js.map +1 -0
- package/dist/{chunk-ZG7QX4I3.cjs → chunk-WJXVLFZN.cjs} +104 -177
- package/dist/chunk-WJXVLFZN.cjs.map +1 -0
- package/dist/core/index.cjs +57 -57
- package/dist/core/index.d.cts +6 -11
- package/dist/core/index.d.ts +6 -11
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +102 -102
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/model/index.cjs +46 -46
- package/dist/model/index.d.cts +3 -2
- package/dist/model/index.d.ts +3 -2
- package/dist/model/index.js +2 -2
- package/dist/{types-6S07rMdY.d.ts → types-Dw9ba_YE.d.ts} +10 -29
- package/dist/{types-DHlnrQKG.d.cts → types-EHdxfQpd.d.cts} +10 -29
- package/package.json +1 -1
- package/dist/chunk-6EAIJMZV.js.map +0 -1
- package/dist/chunk-RTBMPBPC.js.map +0 -1
- package/dist/chunk-YRKXZTRZ.cjs.map +0 -1
- package/dist/chunk-ZG7QX4I3.cjs.map +0 -1
|
@@ -68,6 +68,8 @@ var NullNodeImpl = class {
|
|
|
68
68
|
}
|
|
69
69
|
addChild(_node) {
|
|
70
70
|
}
|
|
71
|
+
insertChild(_index, _node) {
|
|
72
|
+
}
|
|
71
73
|
removeChild(_name) {
|
|
72
74
|
return false;
|
|
73
75
|
}
|
|
@@ -258,6 +260,8 @@ var BaseNode = class {
|
|
|
258
260
|
}
|
|
259
261
|
addChild(_node) {
|
|
260
262
|
}
|
|
263
|
+
insertChild(_index, _node) {
|
|
264
|
+
}
|
|
261
265
|
removeChild(_name) {
|
|
262
266
|
return false;
|
|
263
267
|
}
|
|
@@ -301,6 +305,7 @@ var ObjectNode = class _ObjectNode extends BaseNode {
|
|
|
301
305
|
makeObservable(this, {
|
|
302
306
|
_children: "observable.shallow",
|
|
303
307
|
addChild: "action",
|
|
308
|
+
insertChild: "action",
|
|
304
309
|
removeChild: "action",
|
|
305
310
|
replaceChild: "action"
|
|
306
311
|
});
|
|
@@ -336,6 +341,12 @@ var ObjectNode = class _ObjectNode extends BaseNode {
|
|
|
336
341
|
addChild(node) {
|
|
337
342
|
this._children.push(node);
|
|
338
343
|
}
|
|
344
|
+
insertChild(index, node) {
|
|
345
|
+
if (index < 0 || index > this._children.length) {
|
|
346
|
+
throw new Error(`Index out of bounds: ${index}`);
|
|
347
|
+
}
|
|
348
|
+
this._children.splice(index, 0, node);
|
|
349
|
+
}
|
|
339
350
|
removeChild(name) {
|
|
340
351
|
const index = this._children.findIndex((child) => child.name() === name);
|
|
341
352
|
if (index === -1) {
|
|
@@ -851,6 +862,17 @@ var SchemaTreeImpl = class _SchemaTreeImpl {
|
|
|
851
862
|
parent.addChild(node);
|
|
852
863
|
this.rebuildIndex();
|
|
853
864
|
}
|
|
865
|
+
insertChildAt(parentId, index, node) {
|
|
866
|
+
const parent = this.nodeById(parentId);
|
|
867
|
+
if (parent.isNull()) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
if (parent.isArray()) {
|
|
871
|
+
throw new Error("Cannot add child to array node. Use setItems instead.");
|
|
872
|
+
}
|
|
873
|
+
parent.insertChild(index, node);
|
|
874
|
+
this.rebuildIndex();
|
|
875
|
+
}
|
|
854
876
|
removeNodeAt(path) {
|
|
855
877
|
if (path.isEmpty()) {
|
|
856
878
|
return false;
|
|
@@ -2218,7 +2240,9 @@ var PatchEnricher = class {
|
|
|
2218
2240
|
constructor(currentTree, baseTree) {
|
|
2219
2241
|
this.currentTree = currentTree;
|
|
2220
2242
|
this.baseTree = baseTree;
|
|
2243
|
+
this.extractors = this.buildExtractors();
|
|
2221
2244
|
}
|
|
2245
|
+
extractors;
|
|
2222
2246
|
enrich(patch) {
|
|
2223
2247
|
const fieldName = this.getFieldNameFromPath(patch.path);
|
|
2224
2248
|
if (patch.op === "add") {
|
|
@@ -2235,18 +2259,13 @@ var PatchEnricher = class {
|
|
|
2235
2259
|
enrichAddPatch(patch, fieldName) {
|
|
2236
2260
|
const currentNode = this.getNodeAtPath(this.currentTree, patch.path);
|
|
2237
2261
|
if (!currentNode) {
|
|
2238
|
-
return { patch, fieldName,
|
|
2262
|
+
return { patch, fieldName, propertyChanges: [] };
|
|
2239
2263
|
}
|
|
2240
|
-
const
|
|
2241
|
-
return {
|
|
2242
|
-
patch,
|
|
2243
|
-
fieldName,
|
|
2244
|
-
metadataChanges: this.computeMetadataChanges(metadata),
|
|
2245
|
-
...metadata
|
|
2246
|
-
};
|
|
2264
|
+
const propertyChanges = this.computeAddPropertyChanges(currentNode);
|
|
2265
|
+
return { patch, fieldName, propertyChanges };
|
|
2247
2266
|
}
|
|
2248
2267
|
enrichRemovePatch(patch, fieldName) {
|
|
2249
|
-
return { patch, fieldName,
|
|
2268
|
+
return { patch, fieldName, propertyChanges: [] };
|
|
2250
2269
|
}
|
|
2251
2270
|
enrichMovePatch(patch, fieldName) {
|
|
2252
2271
|
const fromPath = patch.from;
|
|
@@ -2254,98 +2273,98 @@ var PatchEnricher = class {
|
|
|
2254
2273
|
const movesIntoArray = this.movesIntoArrayBoundary(fromPath, patch.path);
|
|
2255
2274
|
const baseNode = this.getNodeAtPath(this.baseTree, fromPath);
|
|
2256
2275
|
const currentNode = this.getNodeAtPath(this.currentTree, patch.path);
|
|
2257
|
-
const
|
|
2258
|
-
const metadataChanges = [];
|
|
2259
|
-
if (formulaChange) {
|
|
2260
|
-
metadataChanges.push("formula");
|
|
2261
|
-
}
|
|
2276
|
+
const propertyChanges = this.computePropertyChanges(baseNode, currentNode);
|
|
2262
2277
|
return {
|
|
2263
2278
|
patch,
|
|
2264
2279
|
fieldName,
|
|
2265
|
-
|
|
2280
|
+
propertyChanges,
|
|
2266
2281
|
isRename: isRename || void 0,
|
|
2267
|
-
movesIntoArray: movesIntoArray || void 0
|
|
2268
|
-
formulaChange
|
|
2282
|
+
movesIntoArray: movesIntoArray || void 0
|
|
2269
2283
|
};
|
|
2270
2284
|
}
|
|
2271
2285
|
enrichReplacePatch(patch, fieldName) {
|
|
2272
2286
|
const baseNode = this.getNodeAtPath(this.baseTree, patch.path);
|
|
2273
2287
|
const currentNode = this.getNodeAtPath(this.currentTree, patch.path);
|
|
2274
2288
|
const isArrayMetadataPatch = baseNode?.isArray() && currentNode?.isArray();
|
|
2275
|
-
const
|
|
2276
|
-
const
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
const metadataChanges = this.computeMetadataChanges({
|
|
2282
|
-
formulaChange,
|
|
2283
|
-
defaultChange,
|
|
2284
|
-
descriptionChange,
|
|
2285
|
-
deprecatedChange,
|
|
2286
|
-
foreignKeyChange,
|
|
2287
|
-
contentMediaTypeChange
|
|
2288
|
-
});
|
|
2289
|
+
const skipProperties = isArrayMetadataPatch ? ["default"] : [];
|
|
2290
|
+
const propertyChanges = this.computePropertyChanges(
|
|
2291
|
+
baseNode,
|
|
2292
|
+
currentNode,
|
|
2293
|
+
{ skipProperties }
|
|
2294
|
+
);
|
|
2289
2295
|
return {
|
|
2290
2296
|
patch,
|
|
2291
2297
|
fieldName,
|
|
2292
|
-
|
|
2293
|
-
typeChange: this.computeTypeChange(baseNode, currentNode, isArrayMetadataPatch)
|
|
2294
|
-
formulaChange,
|
|
2295
|
-
defaultChange,
|
|
2296
|
-
descriptionChange,
|
|
2297
|
-
deprecatedChange,
|
|
2298
|
-
foreignKeyChange,
|
|
2299
|
-
contentMediaTypeChange
|
|
2298
|
+
propertyChanges,
|
|
2299
|
+
typeChange: this.computeTypeChange(baseNode, currentNode, isArrayMetadataPatch)
|
|
2300
2300
|
};
|
|
2301
2301
|
}
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
}
|
|
2302
|
+
buildExtractors() {
|
|
2303
|
+
return [
|
|
2304
|
+
{
|
|
2305
|
+
property: "formula",
|
|
2306
|
+
extract: (node, tree) => {
|
|
2307
|
+
const formula = node?.formula();
|
|
2308
|
+
if (!formula || !node) {
|
|
2309
|
+
return void 0;
|
|
2310
|
+
}
|
|
2311
|
+
return FormulaSerializer.serializeExpression(tree, node.id(), formula, { strict: false });
|
|
2312
|
+
},
|
|
2313
|
+
compare: (from, to) => from === to
|
|
2314
|
+
},
|
|
2315
|
+
{
|
|
2316
|
+
property: "default",
|
|
2317
|
+
extract: (node) => {
|
|
2318
|
+
const value = node?.defaultValue();
|
|
2319
|
+
return isPrimitiveDefault(value) ? value : void 0;
|
|
2320
|
+
}
|
|
2321
|
+
},
|
|
2322
|
+
{
|
|
2323
|
+
property: "description",
|
|
2324
|
+
extract: (node) => node?.metadata().description
|
|
2325
|
+
},
|
|
2326
|
+
{
|
|
2327
|
+
property: "deprecated",
|
|
2328
|
+
extract: (node) => node?.metadata().deprecated
|
|
2329
|
+
},
|
|
2330
|
+
{
|
|
2331
|
+
property: "foreignKey",
|
|
2332
|
+
extract: (node) => node?.foreignKey()
|
|
2333
|
+
},
|
|
2334
|
+
{
|
|
2335
|
+
property: "contentMediaType",
|
|
2336
|
+
extract: (node) => node?.contentMediaType()
|
|
2337
|
+
},
|
|
2338
|
+
{
|
|
2339
|
+
property: "ref",
|
|
2340
|
+
extract: (node) => node?.ref()
|
|
2341
|
+
},
|
|
2342
|
+
{
|
|
2343
|
+
property: "title",
|
|
2344
|
+
extract: (node) => node?.metadata().title
|
|
2345
|
+
}
|
|
2346
|
+
];
|
|
2347
|
+
}
|
|
2348
|
+
computePropertyChanges(baseNode, currentNode, options) {
|
|
2349
|
+
const skipSet = options?.skipProperties;
|
|
2350
|
+
const result = [];
|
|
2351
|
+
for (const extractor of this.extractors) {
|
|
2352
|
+
if (skipSet?.includes(extractor.property)) {
|
|
2353
|
+
continue;
|
|
2354
|
+
}
|
|
2355
|
+
const from = extractor.extract(baseNode, this.baseTree);
|
|
2356
|
+
const to = extractor.extract(currentNode, this.currentTree);
|
|
2357
|
+
const areEqual = extractor.compare ? extractor.compare(from, to) : from === to;
|
|
2358
|
+
if (!areEqual) {
|
|
2359
|
+
result.push({ property: extractor.property, from, to });
|
|
2360
|
+
}
|
|
2346
2361
|
}
|
|
2347
2362
|
return result;
|
|
2348
2363
|
}
|
|
2364
|
+
computeAddPropertyChanges(node) {
|
|
2365
|
+
const allChanges = this.computePropertyChanges(null, node);
|
|
2366
|
+
return allChanges.filter((change) => change.to !== void 0);
|
|
2367
|
+
}
|
|
2349
2368
|
computeTypeChange(baseNode, currentNode, ignoreItems) {
|
|
2350
2369
|
if (!baseNode || !currentNode) {
|
|
2351
2370
|
return void 0;
|
|
@@ -2364,98 +2383,6 @@ var PatchEnricher = class {
|
|
|
2364
2383
|
}
|
|
2365
2384
|
return void 0;
|
|
2366
2385
|
}
|
|
2367
|
-
computeFormulaChange(baseNode, currentNode) {
|
|
2368
|
-
const baseFormula = baseNode?.formula();
|
|
2369
|
-
const currentFormula = currentNode?.formula();
|
|
2370
|
-
const baseExpr = baseFormula && baseNode ? this.getFormulaExpression(baseFormula, this.baseTree, baseNode.id()) : void 0;
|
|
2371
|
-
const currentExpr = currentFormula && currentNode ? this.getFormulaExpression(currentFormula, this.currentTree, currentNode.id()) : void 0;
|
|
2372
|
-
const baseVersion = baseFormula?.version();
|
|
2373
|
-
const currentVersion = currentFormula?.version();
|
|
2374
|
-
if (baseExpr !== currentExpr || baseVersion !== currentVersion) {
|
|
2375
|
-
return {
|
|
2376
|
-
fromFormula: baseExpr,
|
|
2377
|
-
toFormula: currentExpr,
|
|
2378
|
-
fromVersion: baseVersion,
|
|
2379
|
-
toVersion: currentVersion
|
|
2380
|
-
};
|
|
2381
|
-
}
|
|
2382
|
-
return void 0;
|
|
2383
|
-
}
|
|
2384
|
-
getFormulaExpression(formula, tree, nodeId) {
|
|
2385
|
-
return FormulaSerializer.serializeExpression(tree, nodeId, formula, { strict: false });
|
|
2386
|
-
}
|
|
2387
|
-
computeDefaultChange(baseNode, currentNode) {
|
|
2388
|
-
const baseDefault = baseNode?.defaultValue();
|
|
2389
|
-
const currentDefault = currentNode?.defaultValue();
|
|
2390
|
-
const safeBaseDefault = isPrimitiveDefault(baseDefault) ? baseDefault : void 0;
|
|
2391
|
-
const safeCurrentDefault = isPrimitiveDefault(
|
|
2392
|
-
currentDefault
|
|
2393
|
-
) ? currentDefault : void 0;
|
|
2394
|
-
if (safeBaseDefault !== safeCurrentDefault) {
|
|
2395
|
-
return {
|
|
2396
|
-
fromDefault: safeBaseDefault,
|
|
2397
|
-
toDefault: safeCurrentDefault
|
|
2398
|
-
};
|
|
2399
|
-
}
|
|
2400
|
-
return void 0;
|
|
2401
|
-
}
|
|
2402
|
-
computeDescriptionChange(baseNode, currentNode) {
|
|
2403
|
-
const baseDesc = baseNode?.metadata().description;
|
|
2404
|
-
const currentDesc = currentNode?.metadata().description;
|
|
2405
|
-
if (baseDesc !== currentDesc) {
|
|
2406
|
-
return { fromDescription: baseDesc, toDescription: currentDesc };
|
|
2407
|
-
}
|
|
2408
|
-
return void 0;
|
|
2409
|
-
}
|
|
2410
|
-
computeDeprecatedChange(baseNode, currentNode) {
|
|
2411
|
-
const baseDeprecated = baseNode?.metadata().deprecated;
|
|
2412
|
-
const currentDeprecated = currentNode?.metadata().deprecated;
|
|
2413
|
-
if (baseDeprecated !== currentDeprecated) {
|
|
2414
|
-
return { fromDeprecated: baseDeprecated, toDeprecated: currentDeprecated };
|
|
2415
|
-
}
|
|
2416
|
-
return void 0;
|
|
2417
|
-
}
|
|
2418
|
-
computeForeignKeyChange(baseNode, currentNode) {
|
|
2419
|
-
const baseFk = baseNode?.foreignKey();
|
|
2420
|
-
const currentFk = currentNode?.foreignKey();
|
|
2421
|
-
if (baseFk !== currentFk) {
|
|
2422
|
-
return { fromForeignKey: baseFk, toForeignKey: currentFk };
|
|
2423
|
-
}
|
|
2424
|
-
return void 0;
|
|
2425
|
-
}
|
|
2426
|
-
computeContentMediaTypeChange(baseNode, currentNode) {
|
|
2427
|
-
const baseMediaType = baseNode?.contentMediaType();
|
|
2428
|
-
const currentMediaType = currentNode?.contentMediaType();
|
|
2429
|
-
if (baseMediaType !== currentMediaType) {
|
|
2430
|
-
return {
|
|
2431
|
-
fromContentMediaType: baseMediaType,
|
|
2432
|
-
toContentMediaType: currentMediaType
|
|
2433
|
-
};
|
|
2434
|
-
}
|
|
2435
|
-
return void 0;
|
|
2436
|
-
}
|
|
2437
|
-
computeMetadataChanges(changes) {
|
|
2438
|
-
const result = [];
|
|
2439
|
-
if (changes.formulaChange) {
|
|
2440
|
-
result.push("formula");
|
|
2441
|
-
}
|
|
2442
|
-
if (changes.defaultChange) {
|
|
2443
|
-
result.push("default");
|
|
2444
|
-
}
|
|
2445
|
-
if (changes.descriptionChange) {
|
|
2446
|
-
result.push("description");
|
|
2447
|
-
}
|
|
2448
|
-
if (changes.deprecatedChange) {
|
|
2449
|
-
result.push("deprecated");
|
|
2450
|
-
}
|
|
2451
|
-
if (changes.foreignKeyChange) {
|
|
2452
|
-
result.push("foreignKey");
|
|
2453
|
-
}
|
|
2454
|
-
if (changes.contentMediaTypeChange) {
|
|
2455
|
-
result.push("contentMediaType");
|
|
2456
|
-
}
|
|
2457
|
-
return result;
|
|
2458
|
-
}
|
|
2459
2386
|
getNodeType(node) {
|
|
2460
2387
|
if (node.isArray()) {
|
|
2461
2388
|
const items = node.items();
|
|
@@ -2933,5 +2860,5 @@ function buildArrayItemsPath(parentPath) {
|
|
|
2933
2860
|
}
|
|
2934
2861
|
|
|
2935
2862
|
export { AbstractBasePath, ChangeCoalescer, ChangeCollector, CompositeRule, EMPTY_METADATA, EMPTY_PATH, EnumValidator, FIELD_NAME_ERROR_MESSAGE, ForeignKeyValidator, FormulaChangeDetector, FormulaDependencyIndex, FormulaPath, FormulaPathBuilder, FormulaSerializer, ItemsSegment, MaxLengthValidator, MaximumValidator, MinLengthValidator, MinimumValidator, NULL_NODE, NodePathIndex, ParsedFormula, PatchBuilder, PatchEnricher, PatchGenerator, PatternValidator, PropertySegment, RequiredValidator, ResolvedDependency, SchemaDiff, SchemaPropertyRule, SchemaSerializer, SchemaTruthyRule, ValidationEngine, ValidatorRegistry, ValidatorResolver, areNodesContentEqual, areNodesEqual, coalesceChanges, collectChanges, createArrayNode, createBooleanNode, createDefaultValidatorRegistry, createMobxProvider, createNumberNode, createObjectNode, createPath, createRefNode, createSchemaTree, createStringNode, createValidationEngine, isValidFieldName, jsonPointerToPath, jsonPointerToSegments, jsonPointerToSimplePath, makeAutoObservable, makeObservable, observable, reaction, resetReactivityProvider, runInAction, setReactivityProvider, validateFormulas, validateSchema };
|
|
2936
|
-
//# sourceMappingURL=chunk-
|
|
2937
|
-
//# sourceMappingURL=chunk-
|
|
2863
|
+
//# sourceMappingURL=chunk-EPFW6FVB.js.map
|
|
2864
|
+
//# sourceMappingURL=chunk-EPFW6FVB.js.map
|