@lionweb/validation 0.5.0-beta.8 → 0.5.0-beta.9
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 +17 -17
- package/dist/diff/LionwebDiff.d.ts +40 -0
- package/dist/diff/LionwebDiff.d.ts.map +1 -0
- package/dist/diff/LionwebDiff.js +158 -0
- package/dist/diff/LionwebDiff.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/issues/JsonContext.d.ts +11 -0
- package/dist/issues/JsonContext.d.ts.map +1 -0
- package/dist/issues/JsonContext.js +25 -0
- package/dist/issues/JsonContext.js.map +1 -0
- package/dist/issues/LanguageIssues.d.ts +75 -0
- package/dist/issues/LanguageIssues.d.ts.map +1 -0
- package/dist/issues/LanguageIssues.js +110 -0
- package/dist/issues/LanguageIssues.js.map +1 -0
- package/dist/issues/ReferenceIssues.d.ts +43 -0
- package/dist/issues/ReferenceIssues.d.ts.map +1 -0
- package/dist/issues/ReferenceIssues.js +53 -0
- package/dist/issues/ReferenceIssues.js.map +1 -0
- package/dist/issues/SyntaxIssues.d.ts +53 -0
- package/dist/issues/SyntaxIssues.d.ts.map +1 -0
- package/dist/issues/SyntaxIssues.js +81 -0
- package/dist/issues/SyntaxIssues.js.map +1 -0
- package/dist/issues/ValidationIssue.d.ts +9 -0
- package/dist/issues/ValidationIssue.d.ts.map +1 -0
- package/dist/issues/ValidationIssue.js +9 -0
- package/dist/issues/ValidationIssue.js.map +1 -0
- package/dist/issues/index.d.ts +6 -0
- package/dist/issues/index.d.ts.map +1 -0
- package/dist/issues/index.js +6 -0
- package/dist/issues/index.js.map +1 -0
- 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/LanguageUtils.d.ts +9 -0
- package/dist/json/LanguageUtils.d.ts.map +1 -0
- package/dist/json/LanguageUtils.js +30 -0
- package/dist/json/LanguageUtils.js.map +1 -0
- package/dist/json/LionWebJson.d.ts +56 -0
- package/dist/json/LionWebJson.d.ts.map +1 -0
- package/dist/json/LionWebJson.js +28 -0
- package/dist/json/LionWebJson.js.map +1 -0
- package/dist/json/LionWebJsonChunkWrapper.d.ts +25 -0
- package/dist/json/LionWebJsonChunkWrapper.d.ts.map +1 -0
- package/dist/json/LionWebJsonChunkWrapper.js +53 -0
- package/dist/json/LionWebJsonChunkWrapper.js.map +1 -0
- package/dist/json/LionWebLanguageDefinition.d.ts +48 -0
- package/dist/json/LionWebLanguageDefinition.d.ts.map +1 -0
- package/dist/json/LionWebLanguageDefinition.js +126 -0
- package/dist/json/LionWebLanguageDefinition.js.map +1 -0
- package/dist/json/NodeUtils.d.ts +26 -0
- package/dist/json/NodeUtils.d.ts.map +1 -0
- package/dist/json/NodeUtils.js +60 -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/runners/FileUtils.d.ts +6 -0
- package/dist/runners/FileUtils.d.ts.map +1 -0
- package/dist/runners/FileUtils.js +77 -0
- package/dist/runners/FileUtils.js.map +1 -0
- package/dist/runners/RunCheckFolder.d.ts +2 -0
- package/dist/runners/RunCheckFolder.d.ts.map +1 -0
- package/dist/runners/RunCheckFolder.js +4 -0
- package/dist/runners/RunCheckFolder.js.map +1 -0
- package/dist/runners/RunCheckFolderWithLanguage.d.ts +2 -0
- package/dist/runners/RunCheckFolderWithLanguage.d.ts.map +1 -0
- package/dist/runners/RunCheckFolderWithLanguage.js +36 -0
- package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -0
- package/dist/runners/RunCheckOneFile.d.ts +2 -0
- package/dist/runners/RunCheckOneFile.d.ts.map +1 -0
- package/dist/runners/RunCheckOneFile.js +4 -0
- package/dist/runners/RunCheckOneFile.js.map +1 -0
- package/dist/runners/RunCheckOneFileWithLanguage.d.ts +2 -0
- package/dist/runners/RunCheckOneFileWithLanguage.d.ts.map +1 -0
- package/dist/runners/RunCheckOneFileWithLanguage.js +22 -0
- package/dist/runners/RunCheckOneFileWithLanguage.js.map +1 -0
- package/dist/runners/RunLioncoreDiff.d.ts +2 -0
- package/dist/runners/RunLioncoreDiff.d.ts.map +1 -0
- package/dist/runners/RunLioncoreDiff.js +22 -0
- package/dist/runners/RunLioncoreDiff.js.map +1 -0
- package/dist/runners/Utils.d.ts +7 -0
- package/dist/runners/Utils.d.ts.map +1 -0
- package/dist/runners/Utils.js +49 -0
- package/dist/runners/Utils.js.map +1 -0
- package/dist/runners/index.d.ts +3 -0
- package/dist/runners/index.d.ts.map +1 -0
- package/dist/runners/index.js +3 -0
- package/dist/runners/index.js.map +1 -0
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts +24 -0
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -0
- package/dist/validators/LionWebLanguageReferenceValidator.js +109 -0
- package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -0
- package/dist/validators/LionWebLanguageValidator.d.ts +12 -0
- package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -0
- package/dist/validators/LionWebLanguageValidator.js +35 -0
- package/dist/validators/LionWebLanguageValidator.js.map +1 -0
- package/dist/validators/LionWebReferenceValidator.d.ts +45 -0
- package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -0
- package/dist/validators/LionWebReferenceValidator.js +210 -0
- package/dist/validators/LionWebReferenceValidator.js.map +1 -0
- package/dist/validators/LionWebSyntaxValidator.d.ts +88 -0
- package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -0
- package/dist/validators/LionWebSyntaxValidator.js +244 -0
- package/dist/validators/LionWebSyntaxValidator.js.map +1 -0
- package/dist/validators/LionWebValidator.d.ts +24 -0
- package/dist/validators/LionWebValidator.d.ts.map +1 -0
- package/dist/validators/LionWebValidator.js +59 -0
- package/dist/validators/LionWebValidator.js.map +1 -0
- package/dist/validators/SimpleFieldValidator.d.ts +27 -0
- package/dist/validators/SimpleFieldValidator.d.ts.map +1 -0
- package/dist/validators/SimpleFieldValidator.js +77 -0
- package/dist/validators/SimpleFieldValidator.js.map +1 -0
- package/dist/validators/ValidationResult.d.ts +8 -0
- package/dist/validators/ValidationResult.d.ts.map +1 -0
- package/dist/validators/ValidationResult.js +15 -0
- package/dist/validators/ValidationResult.js.map +1 -0
- package/dist/validators/index.d.ts +8 -0
- package/dist/validators/index.d.ts.map +1 -0
- package/dist/validators/index.js +8 -0
- package/dist/validators/index.js.map +1 -0
- package/package.json +10 -8
- package/src/diff/LionwebDiff.ts +5 -5
- package/src/index.ts +4 -0
- package/src/issues/JsonContext.ts +31 -0
- package/src/issues/LanguageIssues.ts +3 -2
- package/src/issues/ReferenceIssues.ts +3 -2
- package/src/issues/SyntaxIssues.ts +2 -1
- package/src/issues/ValidationIssue.ts +1 -31
- package/src/issues/index.ts +5 -0
- package/src/json/ChunkUtils.ts +1 -1
- package/src/json/LanguageUtils.ts +43 -2
- package/src/json/LionWebJson.ts +2 -0
- package/src/json/LionWebJsonChunkWrapper.ts +4 -11
- package/src/json/LionWebLanguageDefinition.ts +24 -17
- package/src/json/NodeUtils.ts +1 -1
- package/src/json/index.ts +6 -0
- package/src/runners/FileUtils.ts +87 -0
- package/src/runners/RunCheckFolder.ts +2 -33
- package/src/runners/RunCheckFolderWithLanguage.ts +5 -5
- package/src/runners/RunCheckOneFile.ts +2 -13
- package/src/runners/RunCheckOneFileWithLanguage.ts +4 -4
- package/src/runners/RunLioncoreDiff.ts +2 -2
- package/src/runners/Utils.ts +37 -3
- package/src/runners/index.ts +2 -0
- package/src/validators/LionWebLanguageReferenceValidator.ts +7 -7
- package/src/validators/LionWebLanguageValidator.ts +7 -7
- package/src/validators/LionWebReferenceValidator.ts +20 -7
- package/src/validators/LionWebSyntaxValidator.ts +8 -6
- package/src/validators/LionWebValidator.ts +8 -8
- package/src/validators/SimpleFieldValidator.ts +5 -5
- package/src/validators/ValidationResult.ts +1 -1
- package/src/validators/index.ts +7 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Language_IncorrectContainmentMetaPointer_Issue, Language_IncorrectPropertyMetaPointer_Issue, Language_IncorrectReferenceMetaPointer_Issue, Language_UnknownConcept_Issue, Language_UnknownContainment_Issue, Language_UnknownProperty_Issue, Language_UnknownReference_Issue } from "../issues/LanguageIssues.js";
|
|
2
|
+
import { JsonContext } from "./../issues/JsonContext.js";
|
|
3
|
+
import { LION_CORE_BUILTINS_INAMED_NAME, LIONWEB_BOOLEAN_TYPE, LIONWEB_INTEGER_TYPE, LIONWEB_JSON_TYPE, LIONWEB_STRING_TYPE } from "../json/LionWebJson.js";
|
|
4
|
+
import { LIONWEB_M3_CONCEPT_KEY, LIONWEB_M3_PROPERTY_KEY, LIONWEB_M3_PROPERTY_TYPE_KEY } from "../json/LionWebLanguageDefinition.js";
|
|
5
|
+
import { SimpleFieldValidator } from "./SimpleFieldValidator.js";
|
|
6
|
+
/**
|
|
7
|
+
* Check against the language definition
|
|
8
|
+
*/
|
|
9
|
+
export class LionWebLanguageReferenceValidator {
|
|
10
|
+
constructor(validationResult, lang) {
|
|
11
|
+
this.validationResult = validationResult;
|
|
12
|
+
this.language = lang;
|
|
13
|
+
this.simpleFieldValidator = new SimpleFieldValidator(this.validationResult);
|
|
14
|
+
}
|
|
15
|
+
// reset() {
|
|
16
|
+
// this.validationResult.reset();
|
|
17
|
+
// }
|
|
18
|
+
// TODO test reference and children implementation
|
|
19
|
+
validate(obj) {
|
|
20
|
+
if (this.language === undefined || this.language === null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
obj.jsonChunk.nodes.forEach((node, nodeIndex) => {
|
|
24
|
+
const nodeContext = new JsonContext(null, ["node", nodeIndex]);
|
|
25
|
+
const jsonConcept = this.language.getNodeByMetaPointer(node.classifier);
|
|
26
|
+
if (jsonConcept === null || jsonConcept === undefined) {
|
|
27
|
+
this.validationResult.issue(new Language_UnknownConcept_Issue(nodeContext, node.classifier));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
node.properties.forEach((property, propIndex) => {
|
|
31
|
+
this.validateProperty(property, nodeContext.concat("properties", propIndex));
|
|
32
|
+
});
|
|
33
|
+
node.containments.forEach((containment, childIndex) => {
|
|
34
|
+
this.validateContainment(containment, nodeContext.concat("containments", childIndex));
|
|
35
|
+
});
|
|
36
|
+
node.references.forEach((reference, refIndex) => {
|
|
37
|
+
this.validateReference(reference, nodeContext.concat("references", refIndex));
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
validateContainment(child, context) {
|
|
42
|
+
const type = this.language.getNodeByMetaPointer(child.containment);
|
|
43
|
+
if (type === null || type === undefined) {
|
|
44
|
+
this.validationResult.issue(new Language_UnknownContainment_Issue(context, child.containment));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (type.classifier.key !== LIONWEB_M3_CONCEPT_KEY) {
|
|
48
|
+
this.validationResult.issue(new Language_IncorrectContainmentMetaPointer_Issue(context, child.containment, type.classifier.key));
|
|
49
|
+
}
|
|
50
|
+
// TODO check type of children
|
|
51
|
+
}
|
|
52
|
+
validateReference(ref, context) {
|
|
53
|
+
const type = this.language.getNodeByMetaPointer(ref.reference);
|
|
54
|
+
if (type === null || type === undefined) {
|
|
55
|
+
this.validationResult.issue(new Language_UnknownReference_Issue(context, ref.reference));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (type.classifier.key !== LIONWEB_M3_CONCEPT_KEY) {
|
|
59
|
+
this.validationResult.issue(new Language_IncorrectReferenceMetaPointer_Issue(context, ref.reference, type.classifier.key));
|
|
60
|
+
}
|
|
61
|
+
// TODO Check type of reference (if possible)
|
|
62
|
+
// TODO Check for duplicate targets?
|
|
63
|
+
// If so, what to check because there can be either or both a `resolveInfo` and a `reference`
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks wwhether the value of `prop1` is correct in relation with its property definition in the referred language.
|
|
67
|
+
* @param prop
|
|
68
|
+
*/
|
|
69
|
+
validateProperty(prop, context) {
|
|
70
|
+
if (prop.value === null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const type = this.language.getNodeByMetaPointer(prop.property);
|
|
74
|
+
if (type === null || type === undefined) {
|
|
75
|
+
this.validationResult.issue(new Language_UnknownProperty_Issue(context, prop.property));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (type.classifier.key !== LIONWEB_M3_PROPERTY_KEY) {
|
|
79
|
+
this.validationResult.issue(new Language_IncorrectPropertyMetaPointer_Issue(context, prop.property, type.classifier.key));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// TODO check for property to exist inside the concept in the language
|
|
83
|
+
// Need to find inherited and implemented properties as well: complex!
|
|
84
|
+
const refType = type.references.find((ref) => (ref.reference.key === LIONWEB_M3_PROPERTY_TYPE_KEY));
|
|
85
|
+
const propertyName = type.properties.find(p => p.property.key === LION_CORE_BUILTINS_INAMED_NAME)?.value;
|
|
86
|
+
// console.log("Fount type should be " + refType.targets[0].reference);
|
|
87
|
+
if (propertyName !== undefined) {
|
|
88
|
+
if (refType !== null && refType !== undefined) {
|
|
89
|
+
switch (refType.targets[0].reference) {
|
|
90
|
+
case LIONWEB_BOOLEAN_TYPE:
|
|
91
|
+
this.simpleFieldValidator.validateBoolean(prop, propertyName, context);
|
|
92
|
+
break;
|
|
93
|
+
case LIONWEB_INTEGER_TYPE:
|
|
94
|
+
this.simpleFieldValidator.validateInteger(prop, propertyName, context);
|
|
95
|
+
break;
|
|
96
|
+
case LIONWEB_STRING_TYPE:
|
|
97
|
+
break;
|
|
98
|
+
case LIONWEB_JSON_TYPE:
|
|
99
|
+
this.simpleFieldValidator.validateJSON(prop, propertyName, context);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// TODO refType not found, but
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=LionWebLanguageReferenceValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LionWebLanguageReferenceValidator.js","sourceRoot":"","sources":["../../src/validators/LionWebLanguageReferenceValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,8CAA8C,EAC9C,2CAA2C,EAAE,4CAA4C,EACzF,6BAA6B,EAC7B,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACH,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EAEtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,4BAA4B,EAA6B,MAAM,sCAAsC,CAAC;AAChK,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE;;GAEG;AACH,MAAM,OAAO,iCAAiC;IAK1C,YAAY,gBAAkC,EAAE,IAA+B;QAC3E,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChF,CAAC;IAED,YAAY;IACZ,qCAAqC;IACrC,IAAI;IAEJ,kDAAkD;IAClD,QAAQ,CAAC,GAA4B;QACjC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE;YACvD,OAAO;SACV;QACD,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAA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,KAAK,iBAAiB;wBAClB,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;wBACpE,MAAM;iBACb;aACJ;iBAAM;gBACH,+BAA+B;aAClC;SACJ;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LionWebJsonChunk } from "../json/LionWebJson.js";
|
|
2
|
+
import { ValidationResult } from "./ValidationResult.js";
|
|
3
|
+
export declare class LionWebLanguageValidator {
|
|
4
|
+
validationResult: ValidationResult;
|
|
5
|
+
constructor();
|
|
6
|
+
/**
|
|
7
|
+
* check JSON as in `check`, but also check whether the metamoddel is a Language.
|
|
8
|
+
* @param obj
|
|
9
|
+
*/
|
|
10
|
+
checkLanguage(chunk: LionWebJsonChunk): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=LionWebLanguageValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LionWebLanguageValidator.d.ts","sourceRoot":"","sources":["../../src/validators/LionWebLanguageValidator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,qBAAa,wBAAwB;IACjC,gBAAgB,EAAE,gBAAgB,CAAC;;IAMnC;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,gBAAgB;CAsBxC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IncorrectLionCoreVersion_Issue, NotLionCoreLanguageKey_Issue, NumberOfLanguagesUsed_Issue } from "../issues/LanguageIssues.js";
|
|
2
|
+
import { JsonContext } from "./../issues/JsonContext.js";
|
|
3
|
+
import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js";
|
|
4
|
+
import { ValidationResult } from "./ValidationResult.js";
|
|
5
|
+
export class LionWebLanguageValidator {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.validationResult = new ValidationResult();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* check JSON as in `check`, but also check whether the metamoddel is a Language.
|
|
11
|
+
* @param obj
|
|
12
|
+
*/
|
|
13
|
+
checkLanguage(chunk) {
|
|
14
|
+
// TODO Vaalidate syntax first via LionWebSyntaxValidator !!!
|
|
15
|
+
if (chunk.languages.length !== 1) {
|
|
16
|
+
// Check whether the LionCore M3 is the only used language, then this is a language model.
|
|
17
|
+
this.validationResult.issue(new NumberOfLanguagesUsed_Issue(new JsonContext(null, ["languages"]), chunk.languages.length));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const usedLanguage = chunk.languages[0];
|
|
21
|
+
if (usedLanguage.key !== "LionCore-M3") {
|
|
22
|
+
this.validationResult.issue(new NotLionCoreLanguageKey_Issue(new JsonContext(null, ["languages", 0]), usedLanguage.key));
|
|
23
|
+
}
|
|
24
|
+
if (usedLanguage.version !== "1") {
|
|
25
|
+
this.validationResult.issue(new IncorrectLionCoreVersion_Issue(new JsonContext(null, ["languages", 0]), usedLanguage.version));
|
|
26
|
+
}
|
|
27
|
+
const chunkWrapper = new LionWebJsonChunkWrapper(chunk);
|
|
28
|
+
const languageNodes = chunkWrapper.findNodesOfConcept("Language");
|
|
29
|
+
if (languageNodes.length !== 1) {
|
|
30
|
+
// TODO Better error handling.
|
|
31
|
+
console.error("Expected exactly one Language node, found " + languageNodes.length + " => " + JSON.stringify(languageNodes));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=LionWebLanguageValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LionWebLanguageValidator.js","sourceRoot":"","sources":["../../src/validators/LionWebLanguageValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AACxI,OAAO,E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I,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,8BAA8B;YAC9B,OAAO,CAAC,KAAK,CAAC,4CAA4C,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;SAE/H;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { JsonContext } from "./../issues/JsonContext.js";
|
|
2
|
+
import { LionWebJsonChunk, LionWebJsonMetaPointer, LionWebJsonNode, LwJsonUsedLanguage } from "../json/LionWebJson.js";
|
|
3
|
+
import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js";
|
|
4
|
+
import { SimpleFieldValidator } from "./SimpleFieldValidator.js";
|
|
5
|
+
import { ValidationResult } from "./ValidationResult.js";
|
|
6
|
+
/**
|
|
7
|
+
* Assuming that the syntax is correct, check whether all LionWeb references are correct,
|
|
8
|
+
* as far as they do not need the used language definition.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LionWebReferenceValidator {
|
|
11
|
+
validationResult: ValidationResult;
|
|
12
|
+
nodesIdMap: Map<string, LionWebJsonNode>;
|
|
13
|
+
simpleFieldValidator: SimpleFieldValidator;
|
|
14
|
+
constructor(validationResult: ValidationResult);
|
|
15
|
+
validateNodeIds(obj: LionWebJsonChunk, ctx: JsonContext): void;
|
|
16
|
+
validate(obj: LionWebJsonChunkWrapper): void;
|
|
17
|
+
/**
|
|
18
|
+
* Check whether the metapointer refers to a language defined in the usedLanguages of chunk.
|
|
19
|
+
* @param chunk
|
|
20
|
+
* @param metaPointer
|
|
21
|
+
* @param context
|
|
22
|
+
*/
|
|
23
|
+
validateLanguageReference(chunk: LionWebJsonChunkWrapper, metaPointer: LionWebJsonMetaPointer, context: JsonContext): void;
|
|
24
|
+
/**
|
|
25
|
+
* Check whether there are duplicate values in `strings`.
|
|
26
|
+
* @param strings
|
|
27
|
+
* @param context
|
|
28
|
+
*/
|
|
29
|
+
checkDuplicate(strings: string[], context: JsonContext): void;
|
|
30
|
+
/**
|
|
31
|
+
* Checks whether there are duplicate usedLanguages in `usedLanguages`.
|
|
32
|
+
* usedLanguages are considered equal when bith their `key` and `version` are identical.
|
|
33
|
+
* @param usedLanguages
|
|
34
|
+
* @param context
|
|
35
|
+
*/
|
|
36
|
+
checkDuplicateUsedLanguage(usedLanguages: LwJsonUsedLanguage[], context: JsonContext): void;
|
|
37
|
+
/**
|
|
38
|
+
* Checks whether the parent of node recursively points to `node` itself.
|
|
39
|
+
* @param node
|
|
40
|
+
*/
|
|
41
|
+
checkParentCircular(node: LionWebJsonNode, context: JsonContext): void;
|
|
42
|
+
validateExistsAsChild(context: JsonContext, parent: LionWebJsonNode | undefined, child: LionWebJsonNode): void;
|
|
43
|
+
validateChildrenHaveCorrectParent(node: LionWebJsonNode, context: JsonContext): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=LionWebReferenceValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LionWebReferenceValidator.d.ts","sourceRoot":"","sources":["../../src/validators/LionWebReferenceValidator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAA4C,gBAAgB,EAAE,sBAAsB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjK,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;GAGG;AACH,qBAAa,yBAAyB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAsC;IAC9E,oBAAoB,EAAE,oBAAoB,CAAC;gBAE/B,gBAAgB,EAAE,gBAAgB;IAK9C,eAAe,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI;IAW9D,QAAQ,CAAC,GAAG,EAAE,uBAAuB,GAAG,IAAI;IAqD5C;;;;;OAKG;IACH,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW;IAenH;;;;OAIG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW;IActD;;;;;OAKG;IACH,0BAA0B,CAAC,aAAa,EAAE,kBAAkB,EAAE,EAAE,OAAO,EAAE,WAAW;IAiBpF;;;OAGG;IACH,mBAAmB,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW;IAoB/D,qBAAqB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,SAAS,EAAE,KAAK,EAAE,eAAe;IAevG,iCAAiC,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW;CA+BhF"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { Duplicates_Issue, Reference_ChildMissingInParent_Issue, Reference_CirculairParent_Issue, Reference_DuplicateNodeId_Issue, Reference_LanguageUnknown_Issue, Reference_ParentMissingInChild_Issue } from "../issues/ReferenceIssues.js";
|
|
2
|
+
import { JsonContext } from "./../issues/JsonContext.js";
|
|
3
|
+
import { ChunkUtils } from "../json/ChunkUtils.js";
|
|
4
|
+
import { LION_CORE_BUILTINS_KEY } from "../json/LionWebJson.js";
|
|
5
|
+
import { SimpleFieldValidator } from "./SimpleFieldValidator.js";
|
|
6
|
+
/**
|
|
7
|
+
* Assuming that the syntax is correct, check whether all LionWeb references are correct,
|
|
8
|
+
* as far as they do not need the used language definition.
|
|
9
|
+
*/
|
|
10
|
+
export class LionWebReferenceValidator {
|
|
11
|
+
constructor(validationResult) {
|
|
12
|
+
this.nodesIdMap = new Map();
|
|
13
|
+
this.validationResult = validationResult;
|
|
14
|
+
this.simpleFieldValidator = new SimpleFieldValidator(this.validationResult);
|
|
15
|
+
}
|
|
16
|
+
validateNodeIds(obj, ctx) {
|
|
17
|
+
// put all nodes in a map, validate that there are no two nodes with the same id.
|
|
18
|
+
obj.nodes.forEach((node, index) => {
|
|
19
|
+
// this.validationResult.check(this.nodesIdMap.get(node.id) === undefined, `Node number ${index} has duplicate id "${node.id}"`);
|
|
20
|
+
if (!(this.nodesIdMap.get(node.id) === undefined)) {
|
|
21
|
+
this.validationResult.issue(new Reference_DuplicateNodeId_Issue(ctx.concat("nodes", index), node.id));
|
|
22
|
+
}
|
|
23
|
+
this.nodesIdMap.set(node.id, node);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
validate(obj) {
|
|
27
|
+
const rootCtx = new JsonContext(null, ["$"]);
|
|
28
|
+
this.checkDuplicateUsedLanguage(obj.jsonChunk.languages, rootCtx);
|
|
29
|
+
this.validateNodeIds(obj.jsonChunk, rootCtx);
|
|
30
|
+
obj.jsonChunk.nodes.forEach((node, nodeIndex) => {
|
|
31
|
+
const context = rootCtx.concat(`node`, nodeIndex);
|
|
32
|
+
const parentNode = node.parent;
|
|
33
|
+
if (parentNode !== null) {
|
|
34
|
+
this.validateExistsAsChild(context, this.nodesIdMap.get(parentNode), node);
|
|
35
|
+
}
|
|
36
|
+
this.validateLanguageReference(obj, node.classifier, context);
|
|
37
|
+
this.checkParentCircular(node, context);
|
|
38
|
+
this.checkDuplicate(node.annotations, rootCtx.concat("node", nodeIndex, "annotations"));
|
|
39
|
+
this.validateChildrenHaveCorrectParent(node, rootCtx.concat("node", nodeIndex));
|
|
40
|
+
node.properties.forEach((prop, propertyIndex) => {
|
|
41
|
+
this.validateLanguageReference(obj, prop.property, rootCtx.concat("node", nodeIndex, "property", propertyIndex));
|
|
42
|
+
});
|
|
43
|
+
node.containments.forEach((containment, childIndex) => {
|
|
44
|
+
this.validateLanguageReference(obj, containment.containment, rootCtx.concat("node", nodeIndex, "containments", childIndex));
|
|
45
|
+
this.checkDuplicate(containment.children, rootCtx.concat("node", nodeIndex, "containments", childIndex));
|
|
46
|
+
containment.children.forEach((childId) => {
|
|
47
|
+
const childNode = this.nodesIdMap.get(childId);
|
|
48
|
+
if (childNode !== undefined) {
|
|
49
|
+
if (childNode.parent !== null && childNode.parent !== undefined && childNode.parent !== node.id) {
|
|
50
|
+
this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, childNode, node));
|
|
51
|
+
// TODO this.validationResult.error(`Child "${childId}" with parent "${childNode.parent}" is defined as child in node "${node.id}"`);
|
|
52
|
+
}
|
|
53
|
+
if (childNode.parent === null || childNode.parent === undefined) {
|
|
54
|
+
// TODO this.validationResult.error(`Child "${childId}" of node "${node.id}" has different parent "${childNode.parent}"`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
node.annotations.forEach((annotationId) => {
|
|
60
|
+
const annotation = this.nodesIdMap.get(annotationId);
|
|
61
|
+
if (annotation !== undefined) {
|
|
62
|
+
if (annotation.parent !== null && annotation.parent !== undefined && annotation.parent !== node.id) {
|
|
63
|
+
this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, annotation, node));
|
|
64
|
+
// TODO this.validationResult.error(`Child "${annotationId}" with parent "${childNode.parent}" is defined as child in node "${node.id}"`);
|
|
65
|
+
}
|
|
66
|
+
if (annotation.parent === null || annotation.parent === undefined) {
|
|
67
|
+
// TODO this.validationResult.error(`Child "${annotationId}" of node "${node.id}" has different parent "${childNode.parent}"`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
node.references.forEach((ref, refIndex) => {
|
|
72
|
+
this.validateLanguageReference(obj, ref.reference, rootCtx.concat("node", nodeIndex, "references", refIndex));
|
|
73
|
+
// TODO Check for duplicate targets?
|
|
74
|
+
// If so, what to check because there can be either or both a `resolveInfo` and a `reference`
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check whether the metapointer refers to a language defined in the usedLanguages of chunk.
|
|
80
|
+
* @param chunk
|
|
81
|
+
* @param metaPointer
|
|
82
|
+
* @param context
|
|
83
|
+
*/
|
|
84
|
+
validateLanguageReference(chunk, metaPointer, context) {
|
|
85
|
+
const lang = ChunkUtils.findLwUsedLanguageWithVersion(chunk.jsonChunk, metaPointer.language, metaPointer.version);
|
|
86
|
+
if (metaPointer.language === LION_CORE_BUILTINS_KEY) {
|
|
87
|
+
// Ok, builtin
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (lang === undefined || lang === null) {
|
|
91
|
+
this.validationResult.issue(new Reference_LanguageUnknown_Issue(context, metaPointer));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (lang.version !== metaPointer.version) {
|
|
95
|
+
this.validationResult.issue(new Reference_LanguageUnknown_Issue(context, metaPointer));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Check whether there are duplicate values in `strings`.
|
|
101
|
+
* @param strings
|
|
102
|
+
* @param context
|
|
103
|
+
*/
|
|
104
|
+
checkDuplicate(strings, context) {
|
|
105
|
+
if (strings === null || strings === undefined) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const alreadySeen = {};
|
|
109
|
+
strings.forEach((str) => {
|
|
110
|
+
if (alreadySeen[str]) {
|
|
111
|
+
this.validationResult.issue(new Duplicates_Issue(context, str));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
alreadySeen[str] = true;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Checks whether there are duplicate usedLanguages in `usedLanguages`.
|
|
120
|
+
* usedLanguages are considered equal when bith their `key` and `version` are identical.
|
|
121
|
+
* @param usedLanguages
|
|
122
|
+
* @param context
|
|
123
|
+
*/
|
|
124
|
+
checkDuplicateUsedLanguage(usedLanguages, context) {
|
|
125
|
+
if (usedLanguages === null || usedLanguages === undefined) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const alreadySeen = new Map();
|
|
129
|
+
usedLanguages.forEach((usedLanguage, index) => {
|
|
130
|
+
const seenKeys = alreadySeen.get(usedLanguage.key);
|
|
131
|
+
if (seenKeys !== null && seenKeys !== undefined) {
|
|
132
|
+
if (seenKeys.includes(usedLanguage.version)) {
|
|
133
|
+
this.validationResult.issue(new Duplicates_Issue(context.concat("language", index, "version"), usedLanguage.version));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
alreadySeen.set(usedLanguage.key, [usedLanguage.version]);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Checks whether the parent of node recursively points to `node` itself.
|
|
143
|
+
* @param node
|
|
144
|
+
*/
|
|
145
|
+
checkParentCircular(node, context) {
|
|
146
|
+
if (node === null || node === undefined) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (node.parent === null || node.parent === undefined) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
let current = node;
|
|
153
|
+
const seenParents = [node.id];
|
|
154
|
+
while (current !== null && current !== undefined && current.parent !== null && current.parent !== undefined) {
|
|
155
|
+
const nextParent = current.parent;
|
|
156
|
+
if (nextParent !== null && nextParent !== undefined && seenParents.includes(nextParent)) {
|
|
157
|
+
this.validationResult.issue(new Reference_CirculairParent_Issue(context.concat("???"), this.nodesIdMap.get(nextParent), seenParents));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
seenParents.push(nextParent);
|
|
161
|
+
current = this.nodesIdMap.get(nextParent);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
validateExistsAsChild(context, parent, child) {
|
|
165
|
+
if (parent === undefined || parent === null) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
for (const containment of parent.containments) {
|
|
169
|
+
if (containment.children.includes(child.id)) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (parent.annotations.includes(child.id)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, child, parent));
|
|
177
|
+
}
|
|
178
|
+
validateChildrenHaveCorrectParent(node, context) {
|
|
179
|
+
node.containments.forEach((child) => {
|
|
180
|
+
child.children.forEach((childId, index) => {
|
|
181
|
+
const childNode = this.nodesIdMap.get(childId);
|
|
182
|
+
if (childNode !== undefined) {
|
|
183
|
+
if (childNode.parent !== node.id) {
|
|
184
|
+
// TODO Check that this is already tested from the child in vaidateExistsAsChild().
|
|
185
|
+
}
|
|
186
|
+
if (childNode.parent === null || childNode.parent === undefined) {
|
|
187
|
+
this.validationResult.issue(new Reference_ParentMissingInChild_Issue(context.concat("child", "containment", "key", index), node, childNode));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
node.annotations.forEach((annotationId, annotationIndex) => {
|
|
193
|
+
const childNode = this.nodesIdMap.get(annotationId);
|
|
194
|
+
if (childNode !== undefined) {
|
|
195
|
+
if (childNode.parent === null || childNode.parent === undefined) {
|
|
196
|
+
this.validationResult.issue(new Reference_ParentMissingInChild_Issue(context.concat("annotations", annotationIndex), node, childNode));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
// for (const childId of NodeUtils.allChildren(node)) {
|
|
201
|
+
// const childNode = this.nodesIdMap.get(childId);
|
|
202
|
+
// if (childNode !== undefined) {
|
|
203
|
+
// if (childNode.parent !== node.id) {
|
|
204
|
+
// this.validationResult.error(`QQ Parent of child "${childId}" is "${childNode.parent}", but should be "${node.id}" in ${context}`);
|
|
205
|
+
// }
|
|
206
|
+
// }
|
|
207
|
+
// }
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=LionWebReferenceValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LionWebReferenceValidator.js","sourceRoot":"","sources":["../../src/validators/LionWebReferenceValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,oCAAoC,EACpC,+BAA+B,EAC/B,+BAA+B,EAAE,+BAA+B,EAChE,oCAAoC,EACvC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAmG,MAAM,wBAAwB,CAAC;AAEjK,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAKlC,YAAY,gBAAkC;QAH9C,eAAU,GAAiC,IAAI,GAAG,EAA2B,CAAC;QAI1E,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChF,CAAC;IAED,eAAe,CAAC,GAAqB,EAAE,GAAgB;QACnD,iFAAiF;QACjF,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC9B,iIAAiI;YACjI,IAAI,CAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC,EAAE;gBAChD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,+BAA+B,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;aACzG;YACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC,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GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACpD,IAAI,SAAS,KAAK,SAAS,EAAE;gBACzB,IAAI,SAAS,CAAC,MAAM,KAAK,IAAI,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE;oBAC7D,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,oCAAoC,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;iBAC1I;aACJ;QACL,CAAC,CAAC,CAAC;QACH,uDAAuD;QACvD,sDAAsD;QACtD,qCAAqC;QACrC,8CAA8C;QAC9C,iJAAiJ;QACjJ,YAAY;QACZ,QAAQ;QACR,IAAI;IACR,CAAC;CACJ"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { SimpleFieldValidator, ValidatorFunction } from "./SimpleFieldValidator.js";
|
|
2
|
+
import { JsonContext } from "./../issues/JsonContext.js";
|
|
3
|
+
import { ValidationResult } from "./ValidationResult.js";
|
|
4
|
+
export type UnknownObjectType = {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export type PropertyType = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "array";
|
|
8
|
+
export type PropertyDefinition = {
|
|
9
|
+
/**
|
|
10
|
+
* The property name
|
|
11
|
+
*/
|
|
12
|
+
property: string;
|
|
13
|
+
/**
|
|
14
|
+
* The expected type of the property value
|
|
15
|
+
*/
|
|
16
|
+
expectedType: PropertyType;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the property value is allowed to be null
|
|
19
|
+
*/
|
|
20
|
+
mayBeNull: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* If the property type is correct, check its value further with this function.
|
|
23
|
+
* Will, only be called if `this.recursive === true`.
|
|
24
|
+
* If the property value is an Array, the `checkValue` will be called on each element in the array.
|
|
25
|
+
* @param obj
|
|
26
|
+
* @param ctx
|
|
27
|
+
*/
|
|
28
|
+
validateValue?: ValidatorFunction;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* LionWebCheck can chack whether objects are LionWeb JSON objects.
|
|
32
|
+
* The check can be on a single object, or recursively on an object and its children.
|
|
33
|
+
*/
|
|
34
|
+
export declare class LionWebSyntaxValidator {
|
|
35
|
+
validationResult: ValidationResult;
|
|
36
|
+
simpleFieldValidator: SimpleFieldValidator;
|
|
37
|
+
/**
|
|
38
|
+
* When true, each function will work recursively on the given object.
|
|
39
|
+
* When false, will only check the given object.
|
|
40
|
+
* Metapointers are always checked as part of the object, disregarding the va;lue of `recursive`.
|
|
41
|
+
*/
|
|
42
|
+
recursive: boolean;
|
|
43
|
+
constructor(validationResult: ValidationResult);
|
|
44
|
+
/**
|
|
45
|
+
* Check whether `obj` is a JSON object that conforms to the serialization syntax of LionCore.
|
|
46
|
+
* All errors found will be pushed into the `errors` array, if its length is not 0, the check has failed.
|
|
47
|
+
* @param obj
|
|
48
|
+
*/
|
|
49
|
+
validate(obj: unknown): void;
|
|
50
|
+
validateLwChunk: (obj: unknown, ctx: JsonContext) => void;
|
|
51
|
+
validateLwUsedLanguage: (obj: unknown, ctx: JsonContext) => void;
|
|
52
|
+
validateLwNode: (obj: unknown, ctx: JsonContext) => void;
|
|
53
|
+
validateLwAnnotation: (obj: unknown, context: JsonContext) => void;
|
|
54
|
+
validateLwProperty: (obj: unknown, ctx: JsonContext) => void;
|
|
55
|
+
validateLwMetaPointer: (obj: unknown, ctx: JsonContext) => void;
|
|
56
|
+
validateLwChild: (obj: unknown, ctx: JsonContext) => void;
|
|
57
|
+
private checkChild;
|
|
58
|
+
/** Checks whether `obj` is not null or defined and has the correct type.
|
|
59
|
+
*/
|
|
60
|
+
private checkType;
|
|
61
|
+
validateLwReference: (obj: unknown, ctx: JsonContext) => void;
|
|
62
|
+
validateLwReferenceTarget: (obj: unknown, ctx: JsonContext) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Check whether all property definitions in `propDef` are correct and check that there are
|
|
65
|
+
* no iother properties in `obj`.
|
|
66
|
+
* @param obj
|
|
67
|
+
* @param propDefs
|
|
68
|
+
* @param context
|
|
69
|
+
*/
|
|
70
|
+
propertyChecks(obj: unknown, propDefs: PropertyDefinition[], context: JsonContext): void;
|
|
71
|
+
/**
|
|
72
|
+
* Check whether there are extra properties that should not be there.
|
|
73
|
+
* @param obj
|
|
74
|
+
* @param properties
|
|
75
|
+
* @param context
|
|
76
|
+
*/
|
|
77
|
+
checkStrayProperties(obj: UnknownObjectType, properties: string[], context: JsonContext): void;
|
|
78
|
+
/**
|
|
79
|
+
* Check whether the value of property `prop` of `obj` has type `expectedType`.
|
|
80
|
+
* @param obj
|
|
81
|
+
* @param prop
|
|
82
|
+
* @param expectedType
|
|
83
|
+
* @param context
|
|
84
|
+
*/
|
|
85
|
+
checkPropertyType: (obj: UnknownObjectType, prop: string, expectedType: PropertyType, mayBeNull: boolean, context: JsonContext) => boolean;
|
|
86
|
+
}
|
|
87
|
+
export declare function SyntaxValidator(jsonChunk: unknown): ValidationResult;
|
|
88
|
+
//# sourceMappingURL=LionWebSyntaxValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LionWebSyntaxValidator.d.ts","sourceRoot":"","sources":["../../src/validators/LionWebSyntaxValidator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE3D,MAAM,MAAM,YAAY,GACpB,QAAQ,GACN,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,WAAW,GACX,QA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