@revisium/schema-toolkit 0.19.0 → 0.19.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-OZ4ZCJXY.js → chunk-45UZ3CJN.js} +21 -18
- package/dist/chunk-45UZ3CJN.js.map +1 -0
- package/dist/{chunk-HLHODANT.cjs → chunk-MKDGOOBV.cjs} +71 -68
- package/dist/chunk-MKDGOOBV.cjs.map +1 -0
- package/dist/{chunk-EPFW6FVB.js → chunk-R6VYCHY2.js} +89 -12
- package/dist/chunk-R6VYCHY2.js.map +1 -0
- package/dist/{chunk-WJXVLFZN.cjs → chunk-U7N3EEQX.cjs} +89 -12
- package/dist/chunk-U7N3EEQX.cjs.map +1 -0
- package/dist/core/index.cjs +57 -57
- package/dist/core/index.d.cts +6 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +102 -102
- package/dist/index.js +2 -2
- package/dist/model/index.cjs +46 -46
- package/dist/model/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-EPFW6FVB.js.map +0 -1
- package/dist/chunk-HLHODANT.cjs.map +0 -1
- package/dist/chunk-OZ4ZCJXY.js.map +0 -1
- package/dist/chunk-WJXVLFZN.cjs.map +0 -1
|
@@ -1414,12 +1414,7 @@ var ChangeCoalescer = class {
|
|
|
1414
1414
|
hasParentChange(change, allChanges, path) {
|
|
1415
1415
|
for (const other of allChanges) {
|
|
1416
1416
|
if (other === change) continue;
|
|
1417
|
-
if (
|
|
1418
|
-
if (!this.isTypeChangeReplacement(other)) {
|
|
1419
|
-
continue;
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
if (change.type === "moved" && other.type === "added") {
|
|
1417
|
+
if (this.shouldSkipParentCandidate(change, other)) {
|
|
1423
1418
|
continue;
|
|
1424
1419
|
}
|
|
1425
1420
|
const otherPath = this.getChangePath(other);
|
|
@@ -1429,9 +1424,24 @@ var ChangeCoalescer = class {
|
|
|
1429
1424
|
}
|
|
1430
1425
|
return false;
|
|
1431
1426
|
}
|
|
1427
|
+
shouldSkipParentCandidate(change, other) {
|
|
1428
|
+
if (other.type === "modified" && !this.isTypeChangeReplacement(other)) {
|
|
1429
|
+
return true;
|
|
1430
|
+
}
|
|
1431
|
+
if (change.type === "moved" && other.type === "added") {
|
|
1432
|
+
return true;
|
|
1433
|
+
}
|
|
1434
|
+
if (change.type === "moved" && other.type === "moved") {
|
|
1435
|
+
return this.hasIndependentRename(change);
|
|
1436
|
+
}
|
|
1437
|
+
return false;
|
|
1438
|
+
}
|
|
1432
1439
|
isTypeChangeReplacement(change) {
|
|
1433
1440
|
return change.baseNode.nodeType() !== change.currentNode.nodeType();
|
|
1434
1441
|
}
|
|
1442
|
+
hasIndependentRename(change) {
|
|
1443
|
+
return change.baseNode.name() !== change.currentNode.name();
|
|
1444
|
+
}
|
|
1435
1445
|
isAffectedByMove(change, movedPaths) {
|
|
1436
1446
|
if (change.type !== "modified") {
|
|
1437
1447
|
return false;
|
|
@@ -2021,19 +2031,31 @@ var PatchGenerator = class {
|
|
|
2021
2031
|
return { prerequisiteAdds, regularAdds };
|
|
2022
2032
|
}
|
|
2023
2033
|
generateMovePatches(moved) {
|
|
2034
|
+
const movedNodeIds = this.collectMovedNodeIds(moved);
|
|
2035
|
+
const sorted = this.sortMovesParentFirst(moved);
|
|
2024
2036
|
const patches = [];
|
|
2025
|
-
|
|
2037
|
+
const appliedMoves = [];
|
|
2038
|
+
for (const change of sorted) {
|
|
2026
2039
|
const basePath = this.baseTree.pathOf(change.baseNode.id());
|
|
2027
2040
|
const currentPath = this.currentTree.pathOf(change.currentNode.id());
|
|
2041
|
+
const adjustedFrom = this.adjustFromPath(
|
|
2042
|
+
basePath.asJsonPointer(),
|
|
2043
|
+
appliedMoves
|
|
2044
|
+
);
|
|
2028
2045
|
patches.push({
|
|
2029
2046
|
op: "move",
|
|
2030
|
-
from:
|
|
2047
|
+
from: adjustedFrom,
|
|
2031
2048
|
path: currentPath.asJsonPointer()
|
|
2032
2049
|
});
|
|
2050
|
+
appliedMoves.push({
|
|
2051
|
+
from: adjustedFrom,
|
|
2052
|
+
to: currentPath.asJsonPointer()
|
|
2053
|
+
});
|
|
2033
2054
|
const modifyPatch = this.generateModifyAfterMove(
|
|
2034
2055
|
change.baseNode,
|
|
2035
2056
|
change.currentNode,
|
|
2036
|
-
currentPath.asJsonPointer()
|
|
2057
|
+
currentPath.asJsonPointer(),
|
|
2058
|
+
movedNodeIds
|
|
2037
2059
|
);
|
|
2038
2060
|
if (modifyPatch) {
|
|
2039
2061
|
patches.push(modifyPatch);
|
|
@@ -2041,10 +2063,29 @@ var PatchGenerator = class {
|
|
|
2041
2063
|
}
|
|
2042
2064
|
return patches;
|
|
2043
2065
|
}
|
|
2044
|
-
|
|
2066
|
+
sortMovesParentFirst(moved) {
|
|
2067
|
+
return [...moved].sort((a, b) => {
|
|
2068
|
+
const pathA = this.baseTree.pathOf(a.baseNode.id()).asJsonPointer();
|
|
2069
|
+
const pathB = this.baseTree.pathOf(b.baseNode.id()).asJsonPointer();
|
|
2070
|
+
return pathA.length - pathB.length;
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
adjustFromPath(fromPath, appliedMoves) {
|
|
2074
|
+
let adjusted = fromPath;
|
|
2075
|
+
for (const move of appliedMoves) {
|
|
2076
|
+
if (adjusted.startsWith(move.from + "/")) {
|
|
2077
|
+
adjusted = move.to + adjusted.slice(move.from.length);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
return adjusted;
|
|
2081
|
+
}
|
|
2082
|
+
generateModifyAfterMove(baseNode, currentNode, currentPath, siblingMovedIds) {
|
|
2045
2083
|
if (areNodesContentEqual(currentNode, baseNode, this.context)) {
|
|
2046
2084
|
return null;
|
|
2047
2085
|
}
|
|
2086
|
+
if (this.isDifferenceExplainedByMoves(currentNode, baseNode, siblingMovedIds)) {
|
|
2087
|
+
return null;
|
|
2088
|
+
}
|
|
2048
2089
|
const currentSchema = this.serializer.serializeNode(
|
|
2049
2090
|
currentNode,
|
|
2050
2091
|
this.currentTree
|
|
@@ -2055,6 +2096,42 @@ var PatchGenerator = class {
|
|
|
2055
2096
|
value: currentSchema
|
|
2056
2097
|
};
|
|
2057
2098
|
}
|
|
2099
|
+
isDifferenceExplainedByMoves(currentNode, baseNode, movedIds) {
|
|
2100
|
+
if (!currentNode.isObject() || !baseNode.isObject()) {
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
const currentProps = currentNode.properties();
|
|
2104
|
+
const baseProps = baseNode.properties();
|
|
2105
|
+
if (currentProps.length !== baseProps.length) {
|
|
2106
|
+
return false;
|
|
2107
|
+
}
|
|
2108
|
+
for (const prop of currentProps) {
|
|
2109
|
+
const matchByName = baseProps.find((b) => b.name() === prop.name());
|
|
2110
|
+
if (matchByName) {
|
|
2111
|
+
if (!this.areNodesEqualAccountingMoves(prop, matchByName, movedIds)) {
|
|
2112
|
+
return false;
|
|
2113
|
+
}
|
|
2114
|
+
continue;
|
|
2115
|
+
}
|
|
2116
|
+
if (!movedIds.has(prop.id())) {
|
|
2117
|
+
return false;
|
|
2118
|
+
}
|
|
2119
|
+
const matchById = baseProps.find((b) => b.id() === prop.id());
|
|
2120
|
+
if (!matchById) {
|
|
2121
|
+
return false;
|
|
2122
|
+
}
|
|
2123
|
+
if (!this.areNodesEqualAccountingMoves(prop, matchById, movedIds)) {
|
|
2124
|
+
return false;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
return true;
|
|
2128
|
+
}
|
|
2129
|
+
areNodesEqualAccountingMoves(currentNode, baseNode, movedIds) {
|
|
2130
|
+
if (areNodesContentEqual(currentNode, baseNode, this.context)) {
|
|
2131
|
+
return true;
|
|
2132
|
+
}
|
|
2133
|
+
return this.isDifferenceExplainedByMoves(currentNode, baseNode, movedIds);
|
|
2134
|
+
}
|
|
2058
2135
|
generateAddPatches(added, movedNodeIds) {
|
|
2059
2136
|
const patches = [];
|
|
2060
2137
|
for (const change of added) {
|
|
@@ -2925,5 +3002,5 @@ exports.runInAction = runInAction;
|
|
|
2925
3002
|
exports.setReactivityProvider = setReactivityProvider;
|
|
2926
3003
|
exports.validateFormulas = validateFormulas;
|
|
2927
3004
|
exports.validateSchema = validateSchema;
|
|
2928
|
-
//# sourceMappingURL=chunk-
|
|
2929
|
-
//# sourceMappingURL=chunk-
|
|
3005
|
+
//# sourceMappingURL=chunk-U7N3EEQX.cjs.map
|
|
3006
|
+
//# sourceMappingURL=chunk-U7N3EEQX.cjs.map
|