@lionweb/validation 0.6.13-beta.6 → 0.6.13-beta.7
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/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 +249 -0
- package/dist/diff/LionWebJsonDiff.js.map +1 -0
- package/dist/diff/changes/Change.d.ts +34 -0
- package/dist/diff/changes/Change.d.ts.map +1 -0
- package/dist/diff/changes/Change.js +38 -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 +25 -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 +41 -0
- package/dist/diff/changes/NodeChange.d.ts.map +1 -0
- package/dist/diff/changes/NodeChange.js +54 -0
- package/dist/diff/changes/NodeChange.js.map +1 -0
- package/dist/diff/changes/PropertyChange.d.ts +24 -0
- package/dist/diff/changes/PropertyChange.d.ts.map +1 -0
- package/dist/diff/changes/PropertyChange.js +29 -0
- package/dist/diff/changes/PropertyChange.js.map +1 -0
- package/dist/diff/changes/ReferenceChange.d.ts +25 -0
- package/dist/diff/changes/ReferenceChange.d.ts.map +1 -0
- package/dist/diff/changes/ReferenceChange.js +34 -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 +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/issues/LanguageIssues.d.ts +4 -4
- package/dist/issues/LanguageIssues.d.ts.map +1 -1
- package/dist/issues/LanguageIssues.js +1 -1
- package/dist/issues/LanguageIssues.js.map +1 -1
- package/dist/issues/ReferenceIssues.d.ts +6 -6
- package/dist/issues/ReferenceIssues.d.ts.map +1 -1
- package/dist/issues/ReferenceIssues.js +3 -3
- 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/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 -0
- package/dist/issues/index.d.ts.map +1 -1
- package/dist/issues/index.js +1 -0
- package/dist/issues/index.js.map +1 -1
- package/dist/json/ChunkUtils.d.ts +26 -0
- package/dist/json/ChunkUtils.d.ts.map +1 -0
- package/dist/json/ChunkUtils.js +46 -0
- package/dist/json/ChunkUtils.js.map +1 -0
- package/dist/json/JsonContext.d.ts +11 -0
- package/dist/json/JsonContext.d.ts.map +1 -0
- package/dist/json/JsonContext.js +25 -0
- package/dist/json/JsonContext.js.map +1 -0
- package/dist/json/LionWebJson.d.ts +50 -0
- package/dist/json/LionWebJson.d.ts.map +1 -0
- package/dist/json/LionWebJson.js +27 -0
- package/dist/json/LionWebJson.js.map +1 -0
- package/dist/json/LionWebJsonChunkWrapper.d.ts +39 -0
- package/dist/json/LionWebJsonChunkWrapper.d.ts.map +1 -0
- package/dist/json/LionWebJsonChunkWrapper.js +119 -0
- package/dist/json/LionWebJsonChunkWrapper.js.map +1 -0
- package/dist/json/M3definitions.d.ts +176 -0
- package/dist/json/M3definitions.d.ts.map +1 -0
- package/dist/json/M3definitions.js +174 -0
- package/dist/json/M3definitions.js.map +1 -0
- package/dist/json/NodeUtils.d.ts +23 -0
- package/dist/json/NodeUtils.d.ts.map +1 -0
- package/dist/json/NodeUtils.js +57 -0
- package/dist/json/NodeUtils.js.map +1 -0
- package/dist/json/index.d.ts +7 -0
- package/dist/json/index.d.ts.map +1 -0
- package/dist/json/index.js +7 -0
- package/dist/json/index.js.map +1 -0
- package/dist/languages/CompositeLionWebLanguageWrapper.d.ts +1 -1
- package/dist/languages/CompositeLionWebLanguageWrapper.d.ts.map +1 -1
- package/dist/languages/LanguageRegistry.d.ts +1 -1
- package/dist/languages/LanguageRegistry.d.ts.map +1 -1
- package/dist/languages/LanguageUtils.d.ts +1 -1
- package/dist/languages/LanguageUtils.d.ts.map +1 -1
- package/dist/languages/LanguageUtils.js +5 -5
- package/dist/languages/LanguageUtils.js.map +1 -1
- package/dist/languages/LionWebLanguageWrapper.d.ts +3 -3
- package/dist/languages/LionWebLanguageWrapper.d.ts.map +1 -1
- package/dist/languages/LionWebLanguageWrapper.js +2 -2
- package/dist/languages/LionWebLanguageWrapper.js.map +1 -1
- package/dist/languages/MetaPointerMap.d.ts +2 -2
- package/dist/languages/MetaPointerMap.d.ts.map +1 -1
- package/dist/languages/MetaPointerMap.js +1 -1
- package/dist/languages/MetaPointerMap.js.map +1 -1
- package/dist/runners/FileUtils.d.ts.map +1 -1
- package/dist/runners/FileUtils.js +1 -1
- package/dist/runners/FileUtils.js.map +1 -1
- package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
- package/dist/runners/RunLioncoreDiff.js +1 -1
- package/dist/runners/RunLioncoreDiff.js.map +1 -1
- package/dist/util/graphs.d.ts +18 -0
- package/dist/util/graphs.d.ts.map +1 -0
- package/dist/util/graphs.js +27 -0
- package/dist/util/graphs.js.map +1 -0
- package/dist/validators/LionWebChunkDefinitions.d.ts +2 -2
- package/dist/validators/LionWebChunkDefinitions.d.ts.map +1 -1
- package/dist/validators/LionWebChunkDefinitions.js +20 -33
- package/dist/validators/LionWebChunkDefinitions.js.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts +4 -2
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.js +6 -2
- package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebLanguageValidator.d.ts +3 -2
- package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageValidator.js +4 -2
- package/dist/validators/LionWebLanguageValidator.js.map +1 -1
- package/dist/validators/LionWebReferenceValidator.d.ts +4 -3
- package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebReferenceValidator.js +3 -2
- package/dist/validators/LionWebReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.js +1 -1
- package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
- package/dist/validators/LionWebValidator.d.ts +1 -1
- package/dist/validators/LionWebValidator.d.ts.map +1 -1
- package/dist/validators/LionWebValidator.js +2 -2
- package/dist/validators/LionWebValidator.js.map +1 -1
- package/dist/validators/ValidationFunctions.d.ts +1 -5
- package/dist/validators/ValidationFunctions.d.ts.map +1 -1
- package/dist/validators/ValidationFunctions.js +4 -0
- package/dist/validators/ValidationFunctions.js.map +1 -1
- package/dist/validators/generic/SyntaxValidator.d.ts +9 -9
- package/dist/validators/generic/SyntaxValidator.d.ts.map +1 -1
- package/dist/validators/generic/SyntaxValidator.js +58 -61
- package/dist/validators/generic/SyntaxValidator.js.map +1 -1
- package/dist/validators/generic/ValidationTypes.d.ts +1 -25
- package/dist/validators/generic/ValidationTypes.d.ts.map +1 -1
- package/dist/validators/generic/ValidationTypes.js +1 -20
- package/dist/validators/generic/ValidationTypes.js.map +1 -1
- package/dist/validators/generic/index.d.ts +1 -0
- package/dist/validators/generic/index.d.ts.map +1 -1
- package/dist/validators/generic/index.js +1 -0
- package/dist/validators/generic/index.js.map +1 -1
- package/dist/validators/index.d.ts +1 -0
- package/dist/validators/index.d.ts.map +1 -1
- package/dist/validators/index.js +1 -0
- package/dist/validators/index.js.map +1 -1
- package/package.json +3 -8
- package/src/diff/DiffResult.ts +21 -0
- package/src/diff/LionWebJsonDiff.ts +309 -0
- package/src/diff/changes/Change.ts +76 -0
- package/src/diff/changes/ChunkChange.ts +68 -0
- package/src/diff/changes/ContainmentChange.ts +32 -0
- package/src/diff/changes/NodeChange.ts +63 -0
- package/src/diff/changes/PropertyChange.ts +31 -0
- package/src/diff/changes/ReferenceChange.ts +34 -0
- package/src/diff/changes/index.ts +6 -0
- package/src/diff/index.ts +3 -0
- package/src/index.ts +3 -0
- package/src/issues/LanguageIssues.ts +14 -12
- package/src/issues/ReferenceIssues.ts +9 -9
- package/src/issues/SyntaxIssues.ts +5 -5
- package/src/issues/ValidationIssue.ts +4 -7
- package/src/issues/index.ts +1 -0
- package/src/json/ChunkUtils.ts +49 -0
- package/src/json/JsonContext.ts +31 -0
- package/src/json/LionWebJson.ts +80 -0
- package/src/json/LionWebJsonChunkWrapper.ts +136 -0
- package/src/json/M3definitions.ts +177 -0
- package/src/json/NodeUtils.ts +75 -0
- package/src/json/index.ts +6 -0
- package/src/languages/CompositeLionWebLanguageWrapper.ts +1 -1
- package/src/languages/LanguageRegistry.ts +1 -1
- package/src/languages/LanguageUtils.ts +6 -6
- package/src/languages/LionWebLanguageWrapper.ts +9 -5
- package/src/languages/MetaPointerMap.ts +6 -7
- package/src/runners/FileUtils.ts +1 -1
- package/src/runners/RunCheckFolderWithLanguage.ts +1 -1
- package/src/runners/RunLioncoreDiff.ts +2 -2
- package/src/util/graphs.ts +36 -0
- package/src/validators/LionWebChunkDefinitions.ts +27 -35
- package/src/validators/LionWebLanguageReferenceValidator.ts +20 -18
- package/src/validators/LionWebLanguageValidator.ts +4 -2
- package/src/validators/LionWebReferenceValidator.ts +14 -6
- package/src/validators/LionWebSyntaxValidator.ts +1 -1
- package/src/validators/LionWebValidator.ts +3 -3
- package/src/validators/ValidationFunctions.ts +1 -1
- package/src/validators/generic/SyntaxValidator.ts +91 -98
- package/src/validators/generic/ValidationTypes.ts +4 -41
- package/src/validators/generic/index.ts +1 -0
- package/src/validators/index.ts +1 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { JsonContext } from "../../issues/index.js"
|
|
2
|
+
import { LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
|
|
3
|
+
import { Change, ChangeType } from "./Change.js"
|
|
4
|
+
|
|
5
|
+
export class NodeClassifierChanged extends Change {
|
|
6
|
+
readonly changeType: ChangeType = "NodeClassifierChanged"
|
|
7
|
+
|
|
8
|
+
constructor(
|
|
9
|
+
public context: JsonContext,
|
|
10
|
+
public node: LionWebJsonNode,
|
|
11
|
+
public oldClassifier: LionWebJsonMetaPointer,
|
|
12
|
+
public newClassifier: LionWebJsonMetaPointer,
|
|
13
|
+
) {
|
|
14
|
+
super(context)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected msg = () => `Object ${this.node.id} has classifier changed from ${this.oldClassifier.key} to ${this.newClassifier.key}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class ParentChanged extends Change {
|
|
21
|
+
readonly changeType = "ParentChanged"
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
public context: JsonContext,
|
|
25
|
+
public node: LionWebJsonNode,
|
|
26
|
+
public beforeParentId: string | null,
|
|
27
|
+
public afterParentId: string | null,
|
|
28
|
+
) {
|
|
29
|
+
super(context)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected msg = () => `Node "${this.node.id}" changed parent from "${this.beforeParentId}" to "${this.afterParentId}`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export abstract class AnnotationChange extends Change {
|
|
36
|
+
constructor(
|
|
37
|
+
ctx: JsonContext,
|
|
38
|
+
public nodeBefore: LionWebJsonNode,
|
|
39
|
+
public nodeAfter: LionWebJsonNode,
|
|
40
|
+
public annotationId: string,
|
|
41
|
+
public index: number
|
|
42
|
+
) {
|
|
43
|
+
super(ctx)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class AnnotationRemoved extends AnnotationChange {
|
|
48
|
+
readonly changeType = "AnnotationRemoved"
|
|
49
|
+
|
|
50
|
+
protected msg = () => `Node "${this.nodeBefore.id}" removed annotation "${this.annotationId}"`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class AnnotationAdded extends AnnotationChange {
|
|
54
|
+
readonly changeType = "AnnotationAdded"
|
|
55
|
+
|
|
56
|
+
protected msg = () => `Node "${this.nodeAfter.id}" added annotation "${this.annotationId}"`
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export class AnnotationOrderChanged extends AnnotationChange {
|
|
61
|
+
readonly changeType = "AnnotationOrderChanged"
|
|
62
|
+
protected msg = () => `Node "${this.nodeAfter.id}" changed order of annotations`
|
|
63
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { JsonContext } from "../../issues/index.js"
|
|
2
|
+
import { LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
|
|
3
|
+
import { Change, Missing } from "./Change.js"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export abstract class PropertyChange extends Change {
|
|
7
|
+
constructor(
|
|
8
|
+
public context: JsonContext,
|
|
9
|
+
public nodeId: string,
|
|
10
|
+
public property: LionWebJsonMetaPointer,
|
|
11
|
+
public oldValue: string | null,
|
|
12
|
+
public newValue: string | null,
|
|
13
|
+
public missing: Missing = Missing.NotMissing
|
|
14
|
+
) {
|
|
15
|
+
super(context)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class PropertyValueChanged extends PropertyChange {
|
|
20
|
+
readonly changeType = "PropertyValueChanged"
|
|
21
|
+
protected msg = () => `Node "${this.nodeId} changed value of property "${this.property.key}" from "${this.oldValue}" to "${this.newValue}"`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class PropertyAdded extends Change {
|
|
25
|
+
readonly changeType = "PropertyAdded";
|
|
26
|
+
constructor(ctx: JsonContext, public node: LionWebJsonNode, public property: LionWebJsonMetaPointer) {
|
|
27
|
+
super(ctx)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected msg = () => `Node "${this.node.id}" containment added: "${JSON.stringify(this.property)}"`
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { JsonContext } from "../../issues/index.js"
|
|
2
|
+
import { LionWebJsonNode, LionWebJsonReference, LionWebJsonReferenceTarget } from "../../json/index.js"
|
|
3
|
+
import { Change, Missing } from "./Change.js"
|
|
4
|
+
|
|
5
|
+
export abstract class ReferenceChange extends Change {
|
|
6
|
+
constructor(
|
|
7
|
+
public context: JsonContext,
|
|
8
|
+
public node: LionWebJsonNode,
|
|
9
|
+
public beforeReference: LionWebJsonReference | undefined,
|
|
10
|
+
public afterReference: LionWebJsonReference | undefined,
|
|
11
|
+
public target: LionWebJsonReferenceTarget,
|
|
12
|
+
public missing = Missing.NotMissing
|
|
13
|
+
) {
|
|
14
|
+
super(context)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class TargetAdded extends ReferenceChange {
|
|
19
|
+
readonly changeType = "TargetAdded"
|
|
20
|
+
protected msg = () =>
|
|
21
|
+
`Node "${this.node.id}" added target "${this.target.reference}" to reference "${this?.afterReference?.reference?.key}"`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class TargetRemoved extends ReferenceChange {
|
|
25
|
+
readonly changeType = "TargetRemoved"
|
|
26
|
+
protected msg = () =>
|
|
27
|
+
`Node "${this.node.id}" removed target "${this.target.reference}" from reference "${this?.beforeReference?.reference?.key}"`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class TargetOrderChanged extends ReferenceChange {
|
|
31
|
+
readonly changeType = "TargetOrderChanged"
|
|
32
|
+
protected msg = () => `Node "${this.node.id}" changed order of targets in reference "${this.afterReference?.reference?.key}"`
|
|
33
|
+
}
|
|
34
|
+
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LionWebJsonMetaPointer, LionWebJsonNode } from "
|
|
2
|
-
import { JsonContext } from "
|
|
1
|
+
import { LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js"
|
|
2
|
+
import { JsonContext } from "../json/JsonContext.js"
|
|
3
3
|
import { ValidationIssue } from "./ValidationIssue.js"
|
|
4
4
|
|
|
5
5
|
export class Language_PropertyValue_Issue extends ValidationIssue {
|
|
@@ -8,13 +8,13 @@ export class Language_PropertyValue_Issue extends ValidationIssue {
|
|
|
8
8
|
constructor(
|
|
9
9
|
context: JsonContext,
|
|
10
10
|
public property: string,
|
|
11
|
-
public value: string | null,
|
|
12
|
-
public expectedType: string
|
|
11
|
+
public value: (string | null),
|
|
12
|
+
public expectedType: string,
|
|
13
13
|
) {
|
|
14
14
|
super(context)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
msg = (): string => `Property
|
|
17
|
+
msg = (): string => `Property "${this.property}" with value "${this.value}" is not of type "${this.expectedType}"`
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// Incorrect Meta Pointers
|
|
@@ -24,7 +24,7 @@ export abstract class Language_IncorrectMetaPointerType_Issue extends Validation
|
|
|
24
24
|
constructor(
|
|
25
25
|
context: JsonContext,
|
|
26
26
|
public metaPointer: LionWebJsonMetaPointer,
|
|
27
|
-
public incorrectType: string
|
|
27
|
+
public incorrectType: string,
|
|
28
28
|
) {
|
|
29
29
|
super(context)
|
|
30
30
|
}
|
|
@@ -43,7 +43,7 @@ export abstract class Language_FeatureMetaPointerNotInClassifier_Issue extends V
|
|
|
43
43
|
constructor(
|
|
44
44
|
context: JsonContext,
|
|
45
45
|
public featureMetaPointer: LionWebJsonMetaPointer,
|
|
46
|
-
public classifierPointer: LionWebJsonNode
|
|
46
|
+
public classifierPointer: LionWebJsonNode,
|
|
47
47
|
) {
|
|
48
48
|
super(context)
|
|
49
49
|
}
|
|
@@ -82,7 +82,7 @@ export abstract class Language_UnknownMetaPointer_Issue extends ValidationIssue
|
|
|
82
82
|
|
|
83
83
|
constructor(
|
|
84
84
|
context: JsonContext,
|
|
85
|
-
public metaPointer: LionWebJsonMetaPointer
|
|
85
|
+
public metaPointer: LionWebJsonMetaPointer,
|
|
86
86
|
) {
|
|
87
87
|
super(context)
|
|
88
88
|
}
|
|
@@ -112,7 +112,7 @@ export class NumberOfLanguagesUsed_Issue extends ValidationIssue {
|
|
|
112
112
|
readonly issueType = "NumberOfLanguagesUsed"
|
|
113
113
|
constructor(
|
|
114
114
|
context: JsonContext,
|
|
115
|
-
public nrOfLanguages: number
|
|
115
|
+
public nrOfLanguages: number,
|
|
116
116
|
) {
|
|
117
117
|
super(context)
|
|
118
118
|
}
|
|
@@ -120,7 +120,9 @@ export class NumberOfLanguagesUsed_Issue extends ValidationIssue {
|
|
|
120
120
|
}
|
|
121
121
|
export class MissingM3Language_Issue extends ValidationIssue {
|
|
122
122
|
readonly issueType = "MissingM3Language"
|
|
123
|
-
constructor(
|
|
123
|
+
constructor(
|
|
124
|
+
context: JsonContext
|
|
125
|
+
) {
|
|
124
126
|
super(context)
|
|
125
127
|
}
|
|
126
128
|
msg = () => `Missing used language LionCore-M3`
|
|
@@ -129,7 +131,7 @@ export class NotLionCoreLanguageKey_Issue extends ValidationIssue {
|
|
|
129
131
|
readonly issueType = "NotLionCoreLanguageKey"
|
|
130
132
|
constructor(
|
|
131
133
|
context: JsonContext,
|
|
132
|
-
public incorrectKey: string
|
|
134
|
+
public incorrectKey: string,
|
|
133
135
|
) {
|
|
134
136
|
super(context)
|
|
135
137
|
}
|
|
@@ -139,7 +141,7 @@ export class IncorrectLionCoreVersion_Issue extends ValidationIssue {
|
|
|
139
141
|
readonly issueType = "IncorrectLionCoreVersion"
|
|
140
142
|
constructor(
|
|
141
143
|
context: JsonContext,
|
|
142
|
-
public incorrectVersion: string
|
|
144
|
+
public incorrectVersion: string,
|
|
143
145
|
) {
|
|
144
146
|
super(context)
|
|
145
147
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JsonContext } from "
|
|
1
|
+
import { LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js"
|
|
2
|
+
import { JsonContext } from "../json/JsonContext.js"
|
|
3
3
|
import { ValidationIssue } from "./ValidationIssue.js"
|
|
4
4
|
|
|
5
5
|
export class Reference_DuplicateNodeId_Issue extends ValidationIssue {
|
|
@@ -7,7 +7,7 @@ export class Reference_DuplicateNodeId_Issue extends ValidationIssue {
|
|
|
7
7
|
|
|
8
8
|
constructor(
|
|
9
9
|
context: JsonContext,
|
|
10
|
-
public nodeId:
|
|
10
|
+
public nodeId: string,
|
|
11
11
|
) {
|
|
12
12
|
super(context)
|
|
13
13
|
}
|
|
@@ -21,7 +21,7 @@ export class Reference_ChildMissingInParent_Issue extends ValidationIssue {
|
|
|
21
21
|
constructor(
|
|
22
22
|
context: JsonContext,
|
|
23
23
|
public child: LionWebJsonNode,
|
|
24
|
-
public parent: LionWebJsonNode
|
|
24
|
+
public parent: LionWebJsonNode,
|
|
25
25
|
) {
|
|
26
26
|
super(context)
|
|
27
27
|
}
|
|
@@ -35,7 +35,7 @@ export class Reference_ParentMissingInChild_Issue extends ValidationIssue {
|
|
|
35
35
|
constructor(
|
|
36
36
|
context: JsonContext,
|
|
37
37
|
public parent: LionWebJsonNode,
|
|
38
|
-
public child: LionWebJsonNode
|
|
38
|
+
public child: LionWebJsonNode,
|
|
39
39
|
) {
|
|
40
40
|
super(context)
|
|
41
41
|
}
|
|
@@ -49,7 +49,7 @@ export class Reference_CirculairParent_Issue extends ValidationIssue {
|
|
|
49
49
|
constructor(
|
|
50
50
|
context: JsonContext,
|
|
51
51
|
public node: LionWebJsonNode | undefined,
|
|
52
|
-
public parentPath: string[]
|
|
52
|
+
public parentPath: string[],
|
|
53
53
|
) {
|
|
54
54
|
super(context)
|
|
55
55
|
}
|
|
@@ -62,7 +62,7 @@ export class Reference_LanguageUnknown_Issue extends ValidationIssue {
|
|
|
62
62
|
|
|
63
63
|
constructor(
|
|
64
64
|
context: JsonContext,
|
|
65
|
-
public languageRef: LionWebJsonMetaPointer
|
|
65
|
+
public languageRef: LionWebJsonMetaPointer,
|
|
66
66
|
) {
|
|
67
67
|
super(context)
|
|
68
68
|
}
|
|
@@ -75,9 +75,9 @@ export class Duplicates_Issue extends ValidationIssue {
|
|
|
75
75
|
|
|
76
76
|
constructor(
|
|
77
77
|
context: JsonContext,
|
|
78
|
-
public
|
|
78
|
+
public nodeid: string,
|
|
79
79
|
) {
|
|
80
80
|
super(context)
|
|
81
81
|
}
|
|
82
|
-
msg = () => `Duplicate value "${this.
|
|
82
|
+
msg = () => `Duplicate value "${this.nodeid}"`
|
|
83
83
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { JsonContext } from "
|
|
1
|
+
import { JsonContext } from "../json/JsonContext.js"
|
|
2
2
|
import { ValidationIssue } from "./ValidationIssue.js"
|
|
3
3
|
|
|
4
4
|
export abstract class Syntax_PropertyIssue extends ValidationIssue {
|
|
5
5
|
constructor(
|
|
6
6
|
public context: JsonContext,
|
|
7
|
-
protected property: string
|
|
7
|
+
protected property: string,
|
|
8
8
|
) {
|
|
9
9
|
super(context)
|
|
10
10
|
}
|
|
@@ -32,7 +32,7 @@ export class Syntax_PropertyTypeIssue extends Syntax_PropertyIssue {
|
|
|
32
32
|
context: JsonContext,
|
|
33
33
|
property: string,
|
|
34
34
|
protected expectedType: string,
|
|
35
|
-
protected actualType: string
|
|
35
|
+
protected actualType: string,
|
|
36
36
|
) {
|
|
37
37
|
super(context, property)
|
|
38
38
|
}
|
|
@@ -46,7 +46,7 @@ export class Syntax_ArrayContainsNull_Issue extends Syntax_PropertyIssue {
|
|
|
46
46
|
constructor(
|
|
47
47
|
context: JsonContext,
|
|
48
48
|
property: string,
|
|
49
|
-
public index: number
|
|
49
|
+
public index: number,
|
|
50
50
|
) {
|
|
51
51
|
super(context, property)
|
|
52
52
|
}
|
|
@@ -57,7 +57,7 @@ export class Syntax_ArrayContainsNull_Issue extends Syntax_PropertyIssue {
|
|
|
57
57
|
export abstract class Syntax_IncorrectFormat_Issue extends ValidationIssue {
|
|
58
58
|
constructor(
|
|
59
59
|
context: JsonContext,
|
|
60
|
-
public value: string
|
|
60
|
+
public value: string,
|
|
61
61
|
) {
|
|
62
62
|
super(context)
|
|
63
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonContext } from "
|
|
1
|
+
import { JsonContext } from "../json/JsonContext.js"
|
|
2
2
|
|
|
3
3
|
export abstract class ValidationIssue {
|
|
4
4
|
abstract readonly issueType: string
|
|
@@ -17,13 +17,10 @@ export abstract class ValidationIssue {
|
|
|
17
17
|
|
|
18
18
|
export class GenericIssue extends ValidationIssue {
|
|
19
19
|
readonly issueType = "GenericIssue"
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
context: JsonContext,
|
|
23
|
-
public text: string
|
|
24
|
-
) {
|
|
20
|
+
|
|
21
|
+
constructor(context: JsonContext, public text: string) {
|
|
25
22
|
super(context)
|
|
26
23
|
}
|
|
27
|
-
|
|
24
|
+
|
|
28
25
|
protected msg = () => this.text
|
|
29
26
|
}
|
package/src/issues/index.ts
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LionWebJsonChunk, LionWebJsonNode, LwJsonUsedLanguage } from "./LionWebJson.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility functions for LionWeb chunks
|
|
5
|
+
*/
|
|
6
|
+
export class ChunkUtils {
|
|
7
|
+
/**
|
|
8
|
+
* Find a used language in `chunk` with `key`.
|
|
9
|
+
* @param chunk
|
|
10
|
+
* @param key
|
|
11
|
+
*/
|
|
12
|
+
static findLwUsedLanguage(chunk: LionWebJsonChunk, key: string): LwJsonUsedLanguage | null {
|
|
13
|
+
for (const language of chunk.languages) {
|
|
14
|
+
if (language.key === key) {
|
|
15
|
+
return language
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Find a used language in `chunk` with `key` and 'version'.
|
|
23
|
+
* @param chunk
|
|
24
|
+
* @param key
|
|
25
|
+
* @param version
|
|
26
|
+
*/
|
|
27
|
+
static findLwUsedLanguageWithVersion(chunk: LionWebJsonChunk, key: string, version: string): LwJsonUsedLanguage | null {
|
|
28
|
+
for (const language of chunk.languages) {
|
|
29
|
+
if (language.key === key && language.version === version) {
|
|
30
|
+
return language
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Find node with id equals `id` in `chunk`.
|
|
38
|
+
* @param chunk
|
|
39
|
+
* @param id
|
|
40
|
+
*/
|
|
41
|
+
static findNode(chunk: LionWebJsonChunk, id: string): LionWebJsonNode | null {
|
|
42
|
+
for (const node of chunk.nodes) {
|
|
43
|
+
if (node.id === id) {
|
|
44
|
+
return node
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { LION_CORE_M3_KEY, LION_CORE_M3_VERSION } from "./M3definitions.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The types defining the structure of the LionWeb JSON format.
|
|
5
|
+
* @see https://lionweb-io.github.io/specification/serialization/serialization.html
|
|
6
|
+
* We use types instead of classes, because the purpose is to define the Lionweb JSON to be sent over the line.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export function isLionWebM3Language(language: LwJsonUsedLanguage): boolean {
|
|
11
|
+
return language.key === LION_CORE_M3_KEY && language.version === LION_CORE_M3_VERSION
|
|
12
|
+
}
|
|
13
|
+
export type LionWebId = string
|
|
14
|
+
|
|
15
|
+
export type LionWebJsonMetaPointer = {
|
|
16
|
+
language: string
|
|
17
|
+
version: string
|
|
18
|
+
key: string // key of concept, property, containment, referenve or property
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isEqualMetaPointer(p1: LionWebJsonMetaPointer, p2: LionWebJsonMetaPointer): boolean {
|
|
22
|
+
return p1.key === p2.key && p1.version === p2.version && p1.language === p2.language
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isEqualReferenceTarget(first: LionWebJsonReferenceTarget, second: LionWebJsonReferenceTarget): boolean {
|
|
26
|
+
return first.reference === second.reference && first.resolveInfo === second.resolveInfo
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type LionWebJsonChunk = {
|
|
30
|
+
serializationFormatVersion: string
|
|
31
|
+
languages: LwJsonUsedLanguage[]
|
|
32
|
+
nodes: LionWebJsonNode[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type LwJsonUsedLanguage = {
|
|
36
|
+
key: string
|
|
37
|
+
version: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type LionWebJsonNode = {
|
|
41
|
+
id: LionWebId
|
|
42
|
+
classifier: LionWebJsonMetaPointer
|
|
43
|
+
properties: LionWebJsonProperty[]
|
|
44
|
+
containments: LionWebJsonContainment[]
|
|
45
|
+
references: LionWebJsonReference[]
|
|
46
|
+
annotations: LionWebId[]
|
|
47
|
+
parent: (LionWebId | null)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function createLwNode(): LionWebJsonNode {
|
|
51
|
+
return {
|
|
52
|
+
id: "",
|
|
53
|
+
classifier: { language: "", version: "", key: "" },
|
|
54
|
+
properties: [],
|
|
55
|
+
containments: [],
|
|
56
|
+
references: [],
|
|
57
|
+
annotations: [],
|
|
58
|
+
parent: null,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type LionWebJsonProperty = {
|
|
63
|
+
property: LionWebJsonMetaPointer
|
|
64
|
+
value: (string | null)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type LionWebJsonContainment = {
|
|
68
|
+
containment: LionWebJsonMetaPointer
|
|
69
|
+
children: LionWebId[]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type LionWebJsonReference = {
|
|
73
|
+
reference: LionWebJsonMetaPointer
|
|
74
|
+
targets: LionWebJsonReferenceTarget[]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type LionWebJsonReferenceTarget = {
|
|
78
|
+
resolveInfo: (string | null)
|
|
79
|
+
reference: LionWebId
|
|
80
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isEqualMetaPointer,
|
|
3
|
+
LionWebId,
|
|
4
|
+
LionWebJsonChunk,
|
|
5
|
+
LionWebJsonContainment,
|
|
6
|
+
LionWebJsonMetaPointer,
|
|
7
|
+
LionWebJsonNode,
|
|
8
|
+
LionWebJsonReference
|
|
9
|
+
} from "./LionWebJson.js"
|
|
10
|
+
import { MetaPointers } from "./M3definitions.js"
|
|
11
|
+
import { NodeUtils } from "./NodeUtils.js"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Wraps around a LionWebJsonChunk, providing access to information inside, might be using caches to improve performance.
|
|
15
|
+
* NB Make sure that the contents of the chunk are not changed after creating the wrapper!
|
|
16
|
+
* NB BE aware that with `pushChunk(...)` the original chunk will be changed.
|
|
17
|
+
*/
|
|
18
|
+
export class LionWebJsonChunkWrapper {
|
|
19
|
+
jsonChunk: LionWebJsonChunk
|
|
20
|
+
/**
|
|
21
|
+
* Map to get quick access to nodes by id.
|
|
22
|
+
* @protected
|
|
23
|
+
*/
|
|
24
|
+
protected nodesIdMap: Map<LionWebId, LionWebJsonNode> = new Map<LionWebId, LionWebJsonNode>()
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Create a wrapper with `chunk` as its chunk
|
|
28
|
+
* @param chunk
|
|
29
|
+
*/
|
|
30
|
+
constructor(chunk: LionWebJsonChunk) {
|
|
31
|
+
this.jsonChunk = chunk
|
|
32
|
+
this.prepareNodeIds(chunk)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Put all nodes in a map, validate that there are no two nodes with the same id.
|
|
36
|
+
* The check should logically be in LionWebReferenceValidator, but the created map is needed here.
|
|
37
|
+
*/
|
|
38
|
+
prepareNodeIds(chunk: LionWebJsonChunk) {
|
|
39
|
+
chunk.nodes.forEach(node => {
|
|
40
|
+
this.nodesIdMap.set(node.id, node)
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getNode(id: string): LionWebJsonNode | undefined {
|
|
45
|
+
return this.nodesIdMap.get(id)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
findNodesOfClassifier(concept: LionWebJsonMetaPointer): LionWebJsonNode[] {
|
|
49
|
+
return this.jsonChunk.nodes.filter(node => isEqualMetaPointer(node.classifier, concept))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Return the target nodes inside `reference` as a list of actual nodes (LionWebJsonNode[])
|
|
54
|
+
* @param reference
|
|
55
|
+
*/
|
|
56
|
+
getReferredNodes(reference: LionWebJsonReference | undefined) {
|
|
57
|
+
if (reference === undefined) {
|
|
58
|
+
return []
|
|
59
|
+
}
|
|
60
|
+
const result = reference.targets.flatMap(target => {
|
|
61
|
+
if (target.reference === null) {
|
|
62
|
+
return []
|
|
63
|
+
} else {
|
|
64
|
+
const referredNode = this.getNode(target.reference)
|
|
65
|
+
return referredNode === undefined ? [] : [referredNode]
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
return result
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Return the target nodes inside `reference` as a list of actual nodes (LionWebJsonNode[])
|
|
73
|
+
* @param reference
|
|
74
|
+
*/
|
|
75
|
+
getChildrenAsNodes(containment: LionWebJsonContainment | undefined) {
|
|
76
|
+
if (containment === undefined) {
|
|
77
|
+
return []
|
|
78
|
+
}
|
|
79
|
+
const result: LionWebJsonNode[] = []
|
|
80
|
+
containment.children.forEach(ch => {
|
|
81
|
+
const childNode = this.getNode(ch)
|
|
82
|
+
if (childNode !== undefined) {
|
|
83
|
+
result.push(childNode)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
return result
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
asString(): string {
|
|
90
|
+
let result = ""
|
|
91
|
+
const partitions = this.jsonChunk.nodes.filter(n => n.parent === null)
|
|
92
|
+
partitions.forEach(partition => {
|
|
93
|
+
const pString = this.recursiveToString(partition, 1)
|
|
94
|
+
result += pString
|
|
95
|
+
})
|
|
96
|
+
return result
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private recursiveToString(node: LionWebJsonNode | undefined, depth: number): string {
|
|
100
|
+
if (node === undefined) {
|
|
101
|
+
return ""
|
|
102
|
+
}
|
|
103
|
+
let result: string = ""
|
|
104
|
+
const nameProperty = NodeUtils.findProperty(node, MetaPointers.INamedName)
|
|
105
|
+
const name = nameProperty === undefined ? "" : " " + nameProperty.value
|
|
106
|
+
result += this.indent(depth) + "(" + node.id + ")" + name + "\n"
|
|
107
|
+
if (node.annotations !== undefined && node.annotations.length !== 0) {
|
|
108
|
+
result += this.indent(depth + 1) + "*Annotations*" + "\n"
|
|
109
|
+
node.annotations.forEach(ann => {
|
|
110
|
+
result += this.recursiveToString(this.getNode(ann), depth + 1)
|
|
111
|
+
// result += this.indent(depth) + "[[" + JSON.stringify(ann) + "]]\n"
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
node.properties
|
|
115
|
+
.filter(p => p !== nameProperty)
|
|
116
|
+
.forEach(property => {
|
|
117
|
+
result += this.indent(depth + 1) + "*property* " + property.property.key + ": " + property.value + "\n"
|
|
118
|
+
})
|
|
119
|
+
node.references.forEach(ref => {
|
|
120
|
+
result += this.indent(depth + 1) + "*" + ref.reference.key + "*: " + JSON.stringify(ref.targets) + "\n"
|
|
121
|
+
})
|
|
122
|
+
node.containments.forEach(cont => {
|
|
123
|
+
if (cont.children.length !== 0) {
|
|
124
|
+
result += this.indent(depth + 1) + "*" + cont.containment.key + "*" + "\n"
|
|
125
|
+
cont.children.forEach(ch => {
|
|
126
|
+
result += this.recursiveToString(this.getNode(ch), depth + 1)
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
return result
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private indent(depth: number): string {
|
|
134
|
+
return Array(depth).join(" ")
|
|
135
|
+
}
|
|
136
|
+
}
|