@lionweb/validation 0.5.0 → 0.6.0-beta.2
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 +2 -0
- package/dist/diff/DiffResult.d.ts +9 -0
- package/dist/diff/DiffResult.d.ts.map +1 -0
- package/dist/diff/DiffResult.js +18 -0
- package/dist/diff/DiffResult.js.map +1 -0
- package/dist/diff/LionWebJsonDiff.d.ts +25 -0
- package/dist/diff/LionWebJsonDiff.d.ts.map +1 -0
- package/dist/diff/LionWebJsonDiff.js +205 -0
- package/dist/diff/LionWebJsonDiff.js.map +1 -0
- package/dist/diff/changes/Change.d.ts +16 -0
- package/dist/diff/changes/Change.d.ts.map +1 -0
- package/dist/diff/changes/Change.js +19 -0
- package/dist/diff/changes/Change.js.map +1 -0
- package/dist/diff/changes/ChunkChange.d.ts +43 -0
- package/dist/diff/changes/ChunkChange.d.ts.map +1 -0
- package/dist/diff/changes/ChunkChange.js +57 -0
- package/dist/diff/changes/ChunkChange.js.map +1 -0
- package/dist/diff/changes/ContainmentChange.d.ts +26 -0
- package/dist/diff/changes/ContainmentChange.d.ts.map +1 -0
- package/dist/diff/changes/ContainmentChange.js +34 -0
- package/dist/diff/changes/ContainmentChange.js.map +1 -0
- package/dist/diff/changes/NodeChange.d.ts +22 -0
- package/dist/diff/changes/NodeChange.d.ts.map +1 -0
- package/dist/diff/changes/NodeChange.js +24 -0
- package/dist/diff/changes/NodeChange.js.map +1 -0
- package/dist/diff/changes/PropertyChange.d.ts +23 -0
- package/dist/diff/changes/PropertyChange.d.ts.map +1 -0
- package/dist/diff/changes/PropertyChange.js +28 -0
- package/dist/diff/changes/PropertyChange.js.map +1 -0
- package/dist/diff/changes/ReferenceChange.d.ts +19 -0
- package/dist/diff/changes/ReferenceChange.d.ts.map +1 -0
- package/dist/diff/changes/ReferenceChange.js +25 -0
- package/dist/diff/changes/ReferenceChange.js.map +1 -0
- package/dist/diff/changes/index.d.ts +7 -0
- package/dist/diff/changes/index.d.ts.map +1 -0
- package/dist/diff/changes/index.js +7 -0
- package/dist/diff/changes/index.js.map +1 -0
- package/dist/diff/index.d.ts +4 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +4 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/issues/LanguageIssues.d.ts +1 -1
- package/dist/issues/LanguageIssues.d.ts.map +1 -1
- package/dist/issues/LanguageIssues.js.map +1 -1
- package/dist/issues/ReferenceIssues.d.ts +1 -1
- package/dist/issues/ReferenceIssues.d.ts.map +1 -1
- package/dist/issues/ReferenceIssues.js.map +1 -1
- package/dist/issues/SyntaxIssues.d.ts +1 -1
- package/dist/issues/SyntaxIssues.d.ts.map +1 -1
- package/dist/issues/SyntaxIssues.js +4 -4
- package/dist/issues/SyntaxIssues.js.map +1 -1
- package/dist/issues/ValidationIssue.d.ts +1 -1
- package/dist/issues/ValidationIssue.d.ts.map +1 -1
- package/dist/issues/ValidationIssue.js.map +1 -1
- package/dist/issues/index.d.ts +1 -1
- package/dist/issues/index.d.ts.map +1 -1
- package/dist/issues/index.js +1 -1
- package/dist/issues/index.js.map +1 -1
- package/dist/json/ChunkUtils.d.ts.map +1 -1
- package/dist/json/ChunkUtils.js.map +1 -1
- package/dist/json/JsonContext.d.ts.map +1 -0
- package/dist/json/JsonContext.js.map +1 -0
- package/dist/json/LanguageUtils.d.ts.map +1 -1
- package/dist/json/LanguageUtils.js.map +1 -1
- package/dist/json/LionWebJson.d.ts +10 -9
- package/dist/json/LionWebJson.d.ts.map +1 -1
- package/dist/json/LionWebJson.js +1 -0
- package/dist/json/LionWebJson.js.map +1 -1
- package/dist/json/LionWebJsonChunkWrapper.d.ts +7 -4
- package/dist/json/LionWebJsonChunkWrapper.d.ts.map +1 -1
- package/dist/json/LionWebJsonChunkWrapper.js +48 -10
- package/dist/json/LionWebJsonChunkWrapper.js.map +1 -1
- package/dist/json/LionWebLanguageDefinition.d.ts.map +1 -1
- package/dist/json/LionWebLanguageDefinition.js +3 -3
- package/dist/json/LionWebLanguageDefinition.js.map +1 -1
- package/dist/json/NodeUtils.d.ts +5 -4
- package/dist/json/NodeUtils.d.ts.map +1 -1
- package/dist/json/NodeUtils.js +5 -2
- package/dist/json/NodeUtils.js.map +1 -1
- package/dist/json/index.d.ts +1 -0
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +1 -0
- package/dist/json/index.js.map +1 -1
- package/dist/runners/FileUtils.d.ts.map +1 -1
- package/dist/runners/FileUtils.js.map +1 -1
- package/dist/runners/RunCheckFolder.js.map +1 -1
- package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
- package/dist/runners/RunCheckOneFile.js.map +1 -1
- package/dist/runners/RunCheckOneFileWithLanguage.js.map +1 -1
- package/dist/runners/RunLioncoreDiff.js +5 -5
- package/dist/runners/RunLioncoreDiff.js.map +1 -1
- package/dist/runners/Utils.d.ts.map +1 -1
- package/dist/runners/Utils.js +1 -1
- package/dist/runners/Utils.js.map +1 -1
- package/dist/runners/index.d.ts.map +1 -1
- package/dist/runners/index.js.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.js +6 -6
- package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageValidator.js +1 -1
- package/dist/validators/LionWebLanguageValidator.js.map +1 -1
- package/dist/validators/LionWebReferenceValidator.d.ts +1 -1
- package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebReferenceValidator.js +6 -6
- package/dist/validators/LionWebReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.d.ts +1 -1
- package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.js +21 -11
- package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
- package/dist/validators/LionWebValidator.d.ts.map +1 -1
- package/dist/validators/LionWebValidator.js.map +1 -1
- package/dist/validators/SimpleFieldValidator.d.ts +1 -1
- package/dist/validators/SimpleFieldValidator.d.ts.map +1 -1
- package/dist/validators/SimpleFieldValidator.js +1 -1
- package/dist/validators/SimpleFieldValidator.js.map +1 -1
- package/dist/validators/ValidationResult.d.ts.map +1 -1
- package/dist/validators/ValidationResult.js.map +1 -1
- package/dist/validators/index.d.ts.map +1 -1
- package/dist/validators/index.js.map +1 -1
- package/package.json +5 -2
- package/src/diff/DiffResult.ts +21 -0
- package/src/diff/LionWebJsonDiff.ts +259 -0
- package/src/diff/changes/Change.ts +52 -0
- package/src/diff/changes/ChunkChange.ts +68 -0
- package/src/diff/changes/ContainmentChange.ts +34 -0
- package/src/diff/changes/NodeChange.ts +32 -0
- package/src/diff/changes/PropertyChange.ts +29 -0
- package/src/diff/changes/ReferenceChange.ts +24 -0
- package/src/diff/changes/index.ts +6 -0
- package/src/diff/index.ts +3 -0
- package/src/index.ts +5 -4
- package/src/issues/LanguageIssues.ts +61 -39
- package/src/issues/ReferenceIssues.ts +51 -29
- package/src/issues/SyntaxIssues.ts +38 -23
- package/src/issues/ValidationIssue.ts +7 -7
- package/src/issues/index.ts +5 -5
- package/src/json/ChunkUtils.ts +7 -11
- package/src/json/JsonContext.ts +31 -0
- package/src/json/LanguageUtils.ts +5 -6
- package/src/json/LionWebJson.ts +44 -43
- package/src/json/LionWebJsonChunkWrapper.ts +76 -29
- package/src/json/LionWebLanguageDefinition.ts +44 -49
- package/src/json/NodeUtils.ts +25 -19
- package/src/json/index.ts +7 -6
- package/src/json/std-builtins-copy.json +347 -349
- package/src/runners/FileUtils.ts +48 -49
- package/src/runners/RunCheckFolder.ts +3 -3
- package/src/runners/RunCheckFolderWithLanguage.ts +31 -30
- package/src/runners/RunCheckOneFile.ts +3 -3
- package/src/runners/RunCheckOneFileWithLanguage.ts +21 -19
- package/src/runners/RunLioncoreDiff.ts +15 -15
- package/src/runners/Utils.ts +24 -24
- package/src/runners/index.ts +2 -2
- package/src/validators/LionWebLanguageReferenceValidator.ts +63 -55
- package/src/validators/LionWebLanguageValidator.ts +11 -12
- package/src/validators/LionWebReferenceValidator.ts +90 -76
- package/src/validators/LionWebSyntaxValidator.ts +108 -99
- package/src/validators/LionWebValidator.ts +33 -33
- package/src/validators/SimpleFieldValidator.ts +33 -28
- package/src/validators/ValidationResult.ts +5 -6
- package/src/validators/index.ts +7 -7
- package/dist/diff/LionwebDiff.d.ts +0 -40
- package/dist/diff/LionwebDiff.d.ts.map +0 -1
- package/dist/diff/LionwebDiff.js +0 -158
- package/dist/diff/LionwebDiff.js.map +0 -1
- package/dist/issues/JsonContext.d.ts.map +0 -1
- package/dist/issues/JsonContext.js.map +0 -1
- package/src/diff/LionwebDiff.ts +0 -193
- package/src/issues/JsonContext.ts +0 -31
- /package/dist/{issues → json}/JsonContext.d.ts +0 -0
- /package/dist/{issues → json}/JsonContext.js +0 -0
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { LionWebSyntaxValidator } from "../validators/LionWebSyntaxValidator.js";
|
|
2
|
-
import { LionWebJsonChild, LionWebJsonChunk, LionWebJsonNode, LionWebJsonReference } from "../json/LionWebJson.js";
|
|
3
|
-
export type ChangedType = {
|
|
4
|
-
path: string;
|
|
5
|
-
oldValue: unknown;
|
|
6
|
-
newValue: unknown;
|
|
7
|
-
};
|
|
8
|
-
export type AddedOrDeletedType = {
|
|
9
|
-
path: string;
|
|
10
|
-
value: unknown;
|
|
11
|
-
};
|
|
12
|
-
export type MatchedType = {
|
|
13
|
-
path: string;
|
|
14
|
-
value: unknown;
|
|
15
|
-
};
|
|
16
|
-
export type ResultType = {
|
|
17
|
-
matched: MatchedType[];
|
|
18
|
-
changed: ChangedType[];
|
|
19
|
-
added: AddedOrDeletedType[];
|
|
20
|
-
deleted: AddedOrDeletedType[];
|
|
21
|
-
};
|
|
22
|
-
export declare class LwDiff {
|
|
23
|
-
errors: string[];
|
|
24
|
-
lwChecker: LionWebSyntaxValidator;
|
|
25
|
-
constructor();
|
|
26
|
-
error(msg: string): void;
|
|
27
|
-
check(b: boolean, message: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* Compare two LwNode objects and return their difference
|
|
30
|
-
* @param obj1
|
|
31
|
-
* @param obj2
|
|
32
|
-
*/
|
|
33
|
-
diffLwNode(obj1: LionWebJsonNode, obj2: LionWebJsonNode): void;
|
|
34
|
-
diffLwChunk(chunk1: LionWebJsonChunk, chunk2: LionWebJsonChunk): void;
|
|
35
|
-
diffLwChild(obj1: LionWebJsonChild, obj2: LionWebJsonChild): void;
|
|
36
|
-
diffLwReference(ref1: LionWebJsonReference, ref2: LionWebJsonReference): void;
|
|
37
|
-
private diffLwUsedLanguage;
|
|
38
|
-
private diffLwProperty;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=LionwebDiff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionwebDiff.d.ts","sourceRoot":"","sources":["../../src/diff/LionwebDiff.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAEH,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACvB,MAAM,wBAAwB,CAAC;AAKhC,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG;IACrB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,OAAO,EAAE,kBAAkB,EAAE,CAAC;CACjC,CAAC;AAEF,qBAAa,MAAM;IACf,MAAM,EAAE,MAAM,EAAE,CAAM;IACtB,SAAS,yBAAsD;;IAM/D,KAAK,CAAC,GAAG,EAAE,MAAM;IAIjB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAMxC;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,GAAG,IAAI;IAuC9D,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI;IA0CrE,WAAW,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAkBjE,eAAe,CAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAsB7E,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,cAAc;CAQzB"}
|
package/dist/diff/LionwebDiff.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
// TODO The diff is outdated and need work to become fully functional again.
|
|
2
|
-
import { LionWebSyntaxValidator } from "../validators/LionWebSyntaxValidator.js";
|
|
3
|
-
import { isEqualMetaPointer, } from "../json/LionWebJson.js";
|
|
4
|
-
import { NodeUtils } from "../json/NodeUtils.js";
|
|
5
|
-
import { ChunkUtils } from "../json/ChunkUtils.js";
|
|
6
|
-
import { ValidationResult } from "../validators/ValidationResult.js";
|
|
7
|
-
export class LwDiff {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.errors = [];
|
|
10
|
-
this.lwChecker = new LionWebSyntaxValidator(new ValidationResult());
|
|
11
|
-
this.lwChecker.recursive = false;
|
|
12
|
-
}
|
|
13
|
-
error(msg) {
|
|
14
|
-
this.errors.push(msg + "\n");
|
|
15
|
-
}
|
|
16
|
-
check(b, message) {
|
|
17
|
-
if (!b) {
|
|
18
|
-
this.error("Check error: " + message);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Compare two LwNode objects and return their difference
|
|
23
|
-
* @param obj1
|
|
24
|
-
* @param obj2
|
|
25
|
-
*/
|
|
26
|
-
diffLwNode(obj1, obj2) {
|
|
27
|
-
// console.log("Comparing nodes")
|
|
28
|
-
if (!isEqualMetaPointer(obj1.classifier, obj2.classifier)) {
|
|
29
|
-
this.error(`Object ${obj1.id} has classifier ${JSON.stringify(obj1.classifier)} vs. ${JSON.stringify(obj2.classifier)}`);
|
|
30
|
-
}
|
|
31
|
-
if (obj1.parent !== obj2.parent) {
|
|
32
|
-
this.error(`Object ${obj1.id} has parent ${obj1.parent} vs. ${obj2.parent}`);
|
|
33
|
-
}
|
|
34
|
-
for (const property of obj1.properties) {
|
|
35
|
-
const key = property.property.key;
|
|
36
|
-
// console.log(` property ${key} of node ${obj1.id}`)
|
|
37
|
-
const otherProp = NodeUtils.findLwProperty(obj2, key);
|
|
38
|
-
if (otherProp === null) {
|
|
39
|
-
this.error(`Property with concept key ${key} does not exist in second object`);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
// const tmp = this.diffLwProperty(prop, otherProp);
|
|
43
|
-
}
|
|
44
|
-
for (const containment of obj1.containments) {
|
|
45
|
-
const key = containment.containment.key;
|
|
46
|
-
// console.log(` property ${key} of node ${obj1.id}`)
|
|
47
|
-
const otherChild = NodeUtils.findLwChild(obj2, key);
|
|
48
|
-
if (otherChild === null) {
|
|
49
|
-
this.error(`Child with containment key ${key} does not exist in second object`);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
// const tmp = this.diffLwChild(child, otherChild);
|
|
53
|
-
}
|
|
54
|
-
for (const reference of obj1.references) {
|
|
55
|
-
const key = reference.reference.key;
|
|
56
|
-
const otherref = NodeUtils.findLwReference(obj2, key);
|
|
57
|
-
if (otherref === null) {
|
|
58
|
-
this.error(`Child with containment key ${key} does not exist in second object`);
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
// const tmp = this.diffLwReference(ref, otherref);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
diffLwChunk(chunk1, chunk2) {
|
|
65
|
-
console.log("Comparing chuncks");
|
|
66
|
-
if (chunk1.serializationFormatVersion !== chunk2.serializationFormatVersion) {
|
|
67
|
-
this.error(`Serialization versions do not match: ${chunk1.serializationFormatVersion} vs ${chunk2.serializationFormatVersion}`);
|
|
68
|
-
}
|
|
69
|
-
for (const language of chunk1.languages) {
|
|
70
|
-
const otherLanguage = ChunkUtils.findLwUsedLanguage(chunk2, language.key);
|
|
71
|
-
if (otherLanguage === null) {
|
|
72
|
-
// return { isEqual: false, diffMessage: `Node with concept key ${id} does not exist in second object`};
|
|
73
|
-
this.error(`Language with key ${language.key} does not exist in second object`);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
// const tmp = this.diffLwUsedLanguage(language, otherLanguage);
|
|
77
|
-
}
|
|
78
|
-
for (const language of chunk2.languages) {
|
|
79
|
-
console.log("Comparing languages");
|
|
80
|
-
const otherLanguage = ChunkUtils.findLwUsedLanguage(chunk1, language.key);
|
|
81
|
-
if (otherLanguage === null) {
|
|
82
|
-
// return { isEqual: false, diffMessage: `Node with concept key ${id} does not exist in second object`};
|
|
83
|
-
this.error(`Language with key ${language.key} does not exist in first object`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
for (const node of chunk1.nodes) {
|
|
87
|
-
const id = node.id;
|
|
88
|
-
const otherNode = ChunkUtils.findNode(chunk2, id);
|
|
89
|
-
if (otherNode === null) {
|
|
90
|
-
// return { isEqual: false, diffMessage: `Node with concept key ${id} does not exist in second object`};
|
|
91
|
-
this.error(`Node with concept key ${id} does not exist in second object`);
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
// const tmp = this.diffLwNode(node, otherNode);
|
|
95
|
-
}
|
|
96
|
-
for (const node of chunk2.nodes) {
|
|
97
|
-
const id = node.id;
|
|
98
|
-
const otherNode = ChunkUtils.findNode(chunk1, id);
|
|
99
|
-
if (otherNode === null) {
|
|
100
|
-
// return { isEqual: false, diffMessage: `Node with concept key ${id} does not exist in second object`};
|
|
101
|
-
this.error(`Node with concept key ${id} does not exist in first object`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
diffLwChild(obj1, obj2) {
|
|
106
|
-
if (!isEqualMetaPointer(obj1.containment, obj2.containment)) {
|
|
107
|
-
// return { isEqual: false, diffMessage: `Property Object has concept ${JSON.stringify(obj1.property)} vs ${JSON.stringify(obj2.property)}`}
|
|
108
|
-
this.error(`Child Object has concept ${JSON.stringify(obj1.containment)} vs ${JSON.stringify(obj2.containment)}`);
|
|
109
|
-
}
|
|
110
|
-
// Check whether children exist in both objects (two for loops)
|
|
111
|
-
for (const childId1 of obj1.children) {
|
|
112
|
-
if (!obj2.children.includes(childId1)) {
|
|
113
|
-
this.error(`Child ${childId1} is missing in other object`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
for (const childId2 of obj2.children) {
|
|
117
|
-
if (!obj1.children.includes(childId2)) {
|
|
118
|
-
console.error(`Child ${childId2} is missing in first object`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
diffLwReference(ref1, ref2) {
|
|
123
|
-
if (!isEqualMetaPointer(ref1.reference, ref2.reference)) {
|
|
124
|
-
// return { isEqual: false, diffMessage: `Property Object has concept ${JSON.stringify(obj1.property)} vs ${JSON.stringify(obj2.property)}`}
|
|
125
|
-
this.error(`Reference has concept ${JSON.stringify(ref1.reference)} vs ${JSON.stringify(ref2.reference)}`);
|
|
126
|
-
}
|
|
127
|
-
for (const target of ref1.targets) {
|
|
128
|
-
const otherTarget = NodeUtils.findLwReferenceTarget(ref2.targets, target);
|
|
129
|
-
if (otherTarget === null) {
|
|
130
|
-
console.error(`REFERENCE Target ${JSON.stringify(target)} missing in second `);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
if (target.reference !== otherTarget.reference || target.resolveInfo !== otherTarget.resolveInfo) {
|
|
134
|
-
this.error(`REFERENCE target ${JSON.stringify(target)} vs ${JSON.stringify(otherTarget)}`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
for (const target of ref2.targets) {
|
|
139
|
-
if (NodeUtils.findLwReferenceTarget(ref1.targets, target) === null) {
|
|
140
|
-
this.error(`REFERENCE Target ${JSON.stringify(target)} missing in first `);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
diffLwUsedLanguage(obj1, obj2) {
|
|
145
|
-
if (obj1.key !== obj2.key || obj1.version !== obj2.version) {
|
|
146
|
-
this.error(`Different used languages ${JSON.stringify(obj1)} vs ${JSON.stringify(obj2)}`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
diffLwProperty(obj1, obj2) {
|
|
150
|
-
if (!isEqualMetaPointer(obj1.property, obj2.property)) {
|
|
151
|
-
this.error(`Property Object has concept ${JSON.stringify(obj1.property)} vs ${JSON.stringify(obj2.property)}`);
|
|
152
|
-
}
|
|
153
|
-
if (obj1.value !== obj2.value) {
|
|
154
|
-
this.error(`Property ${obj1.property.key} has value ${obj1.value} vs ${obj2.value}`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=LionwebDiff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LionwebDiff.js","sourceRoot":"","sources":["../../src/diff/LionwebDiff.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACj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Context.js","sourceRoot":"","sources":["../../src/issues/JsonContext.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,WAAW;IAIpB,MAAM,CAAC,GAAI,KAAe;QACtB,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,IAAI;QACA,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/F,CAAC;IAED,YAAY,MAA0B,EAAE,IAAc;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,QAAQ;QACJ,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAChC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC3B,MAAM,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;YAC9C,CAAC;iBAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAClC,MAAM,IAAI,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;YAC/B,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
package/src/diff/LionwebDiff.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
// TODO The diff is outdated and need work to become fully functional again.
|
|
2
|
-
|
|
3
|
-
import { LionWebSyntaxValidator } from "../validators/LionWebSyntaxValidator.js";
|
|
4
|
-
import {
|
|
5
|
-
isEqualMetaPointer,
|
|
6
|
-
LionWebJsonChild,
|
|
7
|
-
LionWebJsonChunk,
|
|
8
|
-
LionWebJsonNode, LionWebJsonProperty,
|
|
9
|
-
LionWebJsonReference, LwJsonUsedLanguage,
|
|
10
|
-
} from "../json/LionWebJson.js";
|
|
11
|
-
import { NodeUtils } from "../json/NodeUtils.js";
|
|
12
|
-
import { ChunkUtils } from "../json/ChunkUtils.js";
|
|
13
|
-
import { ValidationResult } from "../validators/ValidationResult.js";
|
|
14
|
-
|
|
15
|
-
export type ChangedType = {
|
|
16
|
-
path: string;
|
|
17
|
-
oldValue: unknown;
|
|
18
|
-
newValue: unknown;
|
|
19
|
-
};
|
|
20
|
-
export type AddedOrDeletedType = {
|
|
21
|
-
path: string;
|
|
22
|
-
value: unknown;
|
|
23
|
-
};
|
|
24
|
-
export type MatchedType = {
|
|
25
|
-
path: string;
|
|
26
|
-
value: unknown;
|
|
27
|
-
};
|
|
28
|
-
export type ResultType = {
|
|
29
|
-
matched: MatchedType[];
|
|
30
|
-
changed: ChangedType[];
|
|
31
|
-
added: AddedOrDeletedType[];
|
|
32
|
-
deleted: AddedOrDeletedType[];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export class LwDiff {
|
|
36
|
-
errors: string[] = [];
|
|
37
|
-
lwChecker = new LionWebSyntaxValidator(new ValidationResult());
|
|
38
|
-
|
|
39
|
-
constructor() {
|
|
40
|
-
this.lwChecker.recursive = false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
error(msg: string) {
|
|
44
|
-
this.errors.push(msg + "\n");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
check(b: boolean, message: string): void {
|
|
48
|
-
if (!b) {
|
|
49
|
-
this.error("Check error: " + message);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Compare two LwNode objects and return their difference
|
|
55
|
-
* @param obj1
|
|
56
|
-
* @param obj2
|
|
57
|
-
*/
|
|
58
|
-
diffLwNode(obj1: LionWebJsonNode, obj2: LionWebJsonNode): void {
|
|
59
|
-
// console.log("Comparing nodes")
|
|
60
|
-
if (!isEqualMetaPointer(obj1.classifier, obj2.classifier)) {
|
|
61
|
-
this.error(`Object ${obj1.id} has classifier ${JSON.stringify(obj1.classifier)} vs. ${JSON.stringify(obj2.classifier)}`);
|
|
62
|
-
}
|
|
63
|
-
if (obj1.parent !== obj2.parent) {
|
|
64
|
-
this.error(`Object ${obj1.id} has parent ${obj1.parent} vs. ${obj2.parent}`);
|
|
65
|
-
}
|
|
66
|
-
for (const property of obj1.properties) {
|
|
67
|
-
const key = property.property.key;
|
|
68
|
-
// console.log(` property ${key} of node ${obj1.id}`)
|
|
69
|
-
const otherProp = NodeUtils.findLwProperty(obj2, key);
|
|
70
|
-
if (otherProp === null) {
|
|
71
|
-
this.error(`Property with concept key ${key} does not exist in second object`);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
// const tmp = this.diffLwProperty(prop, otherProp);
|
|
75
|
-
}
|
|
76
|
-
for (const containment of obj1.containments) {
|
|
77
|
-
const key = containment.containment.key;
|
|
78
|
-
// console.log(` property ${key} of node ${obj1.id}`)
|
|
79
|
-
const otherChild = NodeUtils.findLwChild(obj2, key);
|
|
80
|
-
if (otherChild === null) {
|
|
81
|
-
this.error(`Child with containment key ${key} does not exist in second object`);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
// const tmp = this.diffLwChild(child, otherChild);
|
|
85
|
-
}
|
|
86
|
-
for (const reference of obj1.references) {
|
|
87
|
-
const key = reference.reference.key;
|
|
88
|
-
const otherref = NodeUtils.findLwReference(obj2, key);
|
|
89
|
-
if (otherref === null) {
|
|
90
|
-
this.error(`Child with containment key ${key} does not exist in second object`);
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
// const tmp = this.diffLwReference(ref, otherref);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
diffLwChunk(chunk1: LionWebJsonChunk, chunk2: LionWebJsonChunk): void {
|
|
98
|
-
console.log("Comparing chuncks");
|
|
99
|
-
if (chunk1.serializationFormatVersion !== chunk2.serializationFormatVersion) {
|
|
100
|
-
this.error(`Serialization versions do not match: ${chunk1.serializationFormatVersion} vs ${chunk2.serializationFormatVersion}`);
|
|
101
|
-
}
|
|
102
|
-
for (const language of chunk1.languages) {
|
|
103
|
-
const otherLanguage = ChunkUtils.findLwUsedLanguage(chunk2, language.key);
|
|
104
|
-
if (otherLanguage === null) {
|
|
105
|
-
// return { isEqual: false, diffMessage: `Node with concept key ${id} does not exist in second object`};
|
|
106
|
-
this.error(`Language with key ${language.key} does not exist in second object`);
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
// const tmp = this.diffLwUsedLanguage(language, otherLanguage);
|
|
110
|
-
}
|
|
111
|
-
for (const language of chunk2.languages) {
|
|
112
|
-
console.log("Comparing languages");
|
|
113
|
-
const otherLanguage = ChunkUtils.findLwUsedLanguage(chunk1, language.key);
|
|
114
|
-
if (otherLanguage === null) {
|
|
115
|
-
// return { isEqual: false, diffMessage: `Node with concept key ${id} does not exist in second object`};
|
|
116
|
-
this.error(`Language with key ${language.key} does not exist in first object`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
for (const node of chunk1.nodes) {
|
|
120
|
-
const id = node.id;
|
|
121
|
-
const otherNode = ChunkUtils.findNode(chunk2, id);
|
|
122
|
-
if (otherNode === null) {
|
|
123
|
-
// return { isEqual: false, diffMessage: `Node with concept key ${id} does not exist in second object`};
|
|
124
|
-
this.error(`Node with concept key ${id} does not exist in second object`);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
// const tmp = this.diffLwNode(node, otherNode);
|
|
128
|
-
}
|
|
129
|
-
for (const node of chunk2.nodes) {
|
|
130
|
-
const id = node.id;
|
|
131
|
-
const otherNode = ChunkUtils.findNode(chunk1, id);
|
|
132
|
-
if (otherNode === null) {
|
|
133
|
-
// return { isEqual: false, diffMessage: `Node with concept key ${id} does not exist in second object`};
|
|
134
|
-
this.error(`Node with concept key ${id} does not exist in first object`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
diffLwChild(obj1: LionWebJsonChild, obj2: LionWebJsonChild): void {
|
|
140
|
-
if (!isEqualMetaPointer(obj1.containment, obj2.containment)) {
|
|
141
|
-
// return { isEqual: false, diffMessage: `Property Object has concept ${JSON.stringify(obj1.property)} vs ${JSON.stringify(obj2.property)}`}
|
|
142
|
-
this.error(`Child Object has concept ${JSON.stringify(obj1.containment)} vs ${JSON.stringify(obj2.containment)}`);
|
|
143
|
-
}
|
|
144
|
-
// Check whether children exist in both objects (two for loops)
|
|
145
|
-
for (const childId1 of obj1.children) {
|
|
146
|
-
if (!obj2.children.includes(childId1)) {
|
|
147
|
-
this.error(`Child ${childId1} is missing in other object`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
for (const childId2 of obj2.children) {
|
|
151
|
-
if (!obj1.children.includes(childId2)) {
|
|
152
|
-
console.error(`Child ${childId2} is missing in first object`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
diffLwReference(ref1: LionWebJsonReference, ref2: LionWebJsonReference): void {
|
|
158
|
-
if (!isEqualMetaPointer(ref1.reference, ref2.reference)) {
|
|
159
|
-
// return { isEqual: false, diffMessage: `Property Object has concept ${JSON.stringify(obj1.property)} vs ${JSON.stringify(obj2.property)}`}
|
|
160
|
-
this.error(`Reference has concept ${JSON.stringify(ref1.reference)} vs ${JSON.stringify(ref2.reference)}`);
|
|
161
|
-
}
|
|
162
|
-
for (const target of ref1.targets) {
|
|
163
|
-
const otherTarget = NodeUtils.findLwReferenceTarget(ref2.targets, target);
|
|
164
|
-
if (otherTarget === null) {
|
|
165
|
-
console.error(`REFERENCE Target ${JSON.stringify(target)} missing in second `);
|
|
166
|
-
} else {
|
|
167
|
-
if (target.reference !== otherTarget.reference || target.resolveInfo !== otherTarget.resolveInfo) {
|
|
168
|
-
this.error(`REFERENCE target ${JSON.stringify(target)} vs ${JSON.stringify(otherTarget)}`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
for (const target of ref2.targets) {
|
|
173
|
-
if (NodeUtils.findLwReferenceTarget(ref1.targets, target) === null) {
|
|
174
|
-
this.error(`REFERENCE Target ${JSON.stringify(target)} missing in first `);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private diffLwUsedLanguage(obj1: LwJsonUsedLanguage, obj2: LwJsonUsedLanguage) {
|
|
180
|
-
if (obj1.key !== obj2.key || obj1.version !== obj2.version) {
|
|
181
|
-
this.error(`Different used languages ${JSON.stringify(obj1)} vs ${JSON.stringify(obj2)}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
private diffLwProperty(obj1: LionWebJsonProperty, obj2: LionWebJsonProperty) {
|
|
186
|
-
if (!isEqualMetaPointer(obj1.property, obj2.property)) {
|
|
187
|
-
this.error(`Property Object has concept ${JSON.stringify(obj1.property)} vs ${JSON.stringify(obj2.property)}`);
|
|
188
|
-
}
|
|
189
|
-
if (obj1.value !== obj2.value) {
|
|
190
|
-
this.error(`Property ${obj1.property.key} has value ${obj1.value} vs ${obj2.value}`);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
type JsonPath = (string | number)[];
|
|
2
|
-
|
|
3
|
-
export class JsonContext {
|
|
4
|
-
private parent: JsonContext | null;
|
|
5
|
-
private local_path: JsonPath;
|
|
6
|
-
|
|
7
|
-
concat(... items: JsonPath) : JsonContext {
|
|
8
|
-
return new JsonContext(this, items);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
path(): JsonPath {
|
|
12
|
-
return this.parent === null ? this.local_path : this.parent.path().concat(this.local_path);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
constructor(parent: JsonContext | null, path: JsonPath) {
|
|
16
|
-
this.parent = parent;
|
|
17
|
-
this.local_path = path;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
toString(): string {
|
|
21
|
-
let result = "";
|
|
22
|
-
this.path().forEach((part, index) => {
|
|
23
|
-
if (typeof part === "string") {
|
|
24
|
-
result += (index === 0 ? "" : ".") + part;
|
|
25
|
-
} else if (typeof part === "number") {
|
|
26
|
-
result += "[" + part + "]";
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
File without changes
|
|
File without changes
|