@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.
Files changed (177) hide show
  1. package/README.md +2 -0
  2. package/dist/diff/DiffResult.d.ts +9 -0
  3. package/dist/diff/DiffResult.d.ts.map +1 -0
  4. package/dist/diff/DiffResult.js +18 -0
  5. package/dist/diff/DiffResult.js.map +1 -0
  6. package/dist/diff/LionWebJsonDiff.d.ts +25 -0
  7. package/dist/diff/LionWebJsonDiff.d.ts.map +1 -0
  8. package/dist/diff/LionWebJsonDiff.js +205 -0
  9. package/dist/diff/LionWebJsonDiff.js.map +1 -0
  10. package/dist/diff/changes/Change.d.ts +16 -0
  11. package/dist/diff/changes/Change.d.ts.map +1 -0
  12. package/dist/diff/changes/Change.js +19 -0
  13. package/dist/diff/changes/Change.js.map +1 -0
  14. package/dist/diff/changes/ChunkChange.d.ts +43 -0
  15. package/dist/diff/changes/ChunkChange.d.ts.map +1 -0
  16. package/dist/diff/changes/ChunkChange.js +57 -0
  17. package/dist/diff/changes/ChunkChange.js.map +1 -0
  18. package/dist/diff/changes/ContainmentChange.d.ts +26 -0
  19. package/dist/diff/changes/ContainmentChange.d.ts.map +1 -0
  20. package/dist/diff/changes/ContainmentChange.js +34 -0
  21. package/dist/diff/changes/ContainmentChange.js.map +1 -0
  22. package/dist/diff/changes/NodeChange.d.ts +22 -0
  23. package/dist/diff/changes/NodeChange.d.ts.map +1 -0
  24. package/dist/diff/changes/NodeChange.js +24 -0
  25. package/dist/diff/changes/NodeChange.js.map +1 -0
  26. package/dist/diff/changes/PropertyChange.d.ts +23 -0
  27. package/dist/diff/changes/PropertyChange.d.ts.map +1 -0
  28. package/dist/diff/changes/PropertyChange.js +28 -0
  29. package/dist/diff/changes/PropertyChange.js.map +1 -0
  30. package/dist/diff/changes/ReferenceChange.d.ts +19 -0
  31. package/dist/diff/changes/ReferenceChange.d.ts.map +1 -0
  32. package/dist/diff/changes/ReferenceChange.js +25 -0
  33. package/dist/diff/changes/ReferenceChange.js.map +1 -0
  34. package/dist/diff/changes/index.d.ts +7 -0
  35. package/dist/diff/changes/index.d.ts.map +1 -0
  36. package/dist/diff/changes/index.js +7 -0
  37. package/dist/diff/changes/index.js.map +1 -0
  38. package/dist/diff/index.d.ts +4 -0
  39. package/dist/diff/index.d.ts.map +1 -0
  40. package/dist/diff/index.js +4 -0
  41. package/dist/diff/index.js.map +1 -0
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +1 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/issues/LanguageIssues.d.ts +1 -1
  47. package/dist/issues/LanguageIssues.d.ts.map +1 -1
  48. package/dist/issues/LanguageIssues.js.map +1 -1
  49. package/dist/issues/ReferenceIssues.d.ts +1 -1
  50. package/dist/issues/ReferenceIssues.d.ts.map +1 -1
  51. package/dist/issues/ReferenceIssues.js.map +1 -1
  52. package/dist/issues/SyntaxIssues.d.ts +1 -1
  53. package/dist/issues/SyntaxIssues.d.ts.map +1 -1
  54. package/dist/issues/SyntaxIssues.js +4 -4
  55. package/dist/issues/SyntaxIssues.js.map +1 -1
  56. package/dist/issues/ValidationIssue.d.ts +1 -1
  57. package/dist/issues/ValidationIssue.d.ts.map +1 -1
  58. package/dist/issues/ValidationIssue.js.map +1 -1
  59. package/dist/issues/index.d.ts +1 -1
  60. package/dist/issues/index.d.ts.map +1 -1
  61. package/dist/issues/index.js +1 -1
  62. package/dist/issues/index.js.map +1 -1
  63. package/dist/json/ChunkUtils.d.ts.map +1 -1
  64. package/dist/json/ChunkUtils.js.map +1 -1
  65. package/dist/json/JsonContext.d.ts.map +1 -0
  66. package/dist/json/JsonContext.js.map +1 -0
  67. package/dist/json/LanguageUtils.d.ts.map +1 -1
  68. package/dist/json/LanguageUtils.js.map +1 -1
  69. package/dist/json/LionWebJson.d.ts +10 -9
  70. package/dist/json/LionWebJson.d.ts.map +1 -1
  71. package/dist/json/LionWebJson.js +1 -0
  72. package/dist/json/LionWebJson.js.map +1 -1
  73. package/dist/json/LionWebJsonChunkWrapper.d.ts +7 -4
  74. package/dist/json/LionWebJsonChunkWrapper.d.ts.map +1 -1
  75. package/dist/json/LionWebJsonChunkWrapper.js +48 -10
  76. package/dist/json/LionWebJsonChunkWrapper.js.map +1 -1
  77. package/dist/json/LionWebLanguageDefinition.d.ts.map +1 -1
  78. package/dist/json/LionWebLanguageDefinition.js +3 -3
  79. package/dist/json/LionWebLanguageDefinition.js.map +1 -1
  80. package/dist/json/NodeUtils.d.ts +5 -4
  81. package/dist/json/NodeUtils.d.ts.map +1 -1
  82. package/dist/json/NodeUtils.js +5 -2
  83. package/dist/json/NodeUtils.js.map +1 -1
  84. package/dist/json/index.d.ts +1 -0
  85. package/dist/json/index.d.ts.map +1 -1
  86. package/dist/json/index.js +1 -0
  87. package/dist/json/index.js.map +1 -1
  88. package/dist/runners/FileUtils.d.ts.map +1 -1
  89. package/dist/runners/FileUtils.js.map +1 -1
  90. package/dist/runners/RunCheckFolder.js.map +1 -1
  91. package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
  92. package/dist/runners/RunCheckOneFile.js.map +1 -1
  93. package/dist/runners/RunCheckOneFileWithLanguage.js.map +1 -1
  94. package/dist/runners/RunLioncoreDiff.js +5 -5
  95. package/dist/runners/RunLioncoreDiff.js.map +1 -1
  96. package/dist/runners/Utils.d.ts.map +1 -1
  97. package/dist/runners/Utils.js +1 -1
  98. package/dist/runners/Utils.js.map +1 -1
  99. package/dist/runners/index.d.ts.map +1 -1
  100. package/dist/runners/index.js.map +1 -1
  101. package/dist/validators/LionWebLanguageReferenceValidator.d.ts +1 -1
  102. package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
  103. package/dist/validators/LionWebLanguageReferenceValidator.js +6 -6
  104. package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
  105. package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
  106. package/dist/validators/LionWebLanguageValidator.js +1 -1
  107. package/dist/validators/LionWebLanguageValidator.js.map +1 -1
  108. package/dist/validators/LionWebReferenceValidator.d.ts +1 -1
  109. package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
  110. package/dist/validators/LionWebReferenceValidator.js +6 -6
  111. package/dist/validators/LionWebReferenceValidator.js.map +1 -1
  112. package/dist/validators/LionWebSyntaxValidator.d.ts +1 -1
  113. package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
  114. package/dist/validators/LionWebSyntaxValidator.js +21 -11
  115. package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
  116. package/dist/validators/LionWebValidator.d.ts.map +1 -1
  117. package/dist/validators/LionWebValidator.js.map +1 -1
  118. package/dist/validators/SimpleFieldValidator.d.ts +1 -1
  119. package/dist/validators/SimpleFieldValidator.d.ts.map +1 -1
  120. package/dist/validators/SimpleFieldValidator.js +1 -1
  121. package/dist/validators/SimpleFieldValidator.js.map +1 -1
  122. package/dist/validators/ValidationResult.d.ts.map +1 -1
  123. package/dist/validators/ValidationResult.js.map +1 -1
  124. package/dist/validators/index.d.ts.map +1 -1
  125. package/dist/validators/index.js.map +1 -1
  126. package/package.json +5 -2
  127. package/src/diff/DiffResult.ts +21 -0
  128. package/src/diff/LionWebJsonDiff.ts +259 -0
  129. package/src/diff/changes/Change.ts +52 -0
  130. package/src/diff/changes/ChunkChange.ts +68 -0
  131. package/src/diff/changes/ContainmentChange.ts +34 -0
  132. package/src/diff/changes/NodeChange.ts +32 -0
  133. package/src/diff/changes/PropertyChange.ts +29 -0
  134. package/src/diff/changes/ReferenceChange.ts +24 -0
  135. package/src/diff/changes/index.ts +6 -0
  136. package/src/diff/index.ts +3 -0
  137. package/src/index.ts +5 -4
  138. package/src/issues/LanguageIssues.ts +61 -39
  139. package/src/issues/ReferenceIssues.ts +51 -29
  140. package/src/issues/SyntaxIssues.ts +38 -23
  141. package/src/issues/ValidationIssue.ts +7 -7
  142. package/src/issues/index.ts +5 -5
  143. package/src/json/ChunkUtils.ts +7 -11
  144. package/src/json/JsonContext.ts +31 -0
  145. package/src/json/LanguageUtils.ts +5 -6
  146. package/src/json/LionWebJson.ts +44 -43
  147. package/src/json/LionWebJsonChunkWrapper.ts +76 -29
  148. package/src/json/LionWebLanguageDefinition.ts +44 -49
  149. package/src/json/NodeUtils.ts +25 -19
  150. package/src/json/index.ts +7 -6
  151. package/src/json/std-builtins-copy.json +347 -349
  152. package/src/runners/FileUtils.ts +48 -49
  153. package/src/runners/RunCheckFolder.ts +3 -3
  154. package/src/runners/RunCheckFolderWithLanguage.ts +31 -30
  155. package/src/runners/RunCheckOneFile.ts +3 -3
  156. package/src/runners/RunCheckOneFileWithLanguage.ts +21 -19
  157. package/src/runners/RunLioncoreDiff.ts +15 -15
  158. package/src/runners/Utils.ts +24 -24
  159. package/src/runners/index.ts +2 -2
  160. package/src/validators/LionWebLanguageReferenceValidator.ts +63 -55
  161. package/src/validators/LionWebLanguageValidator.ts +11 -12
  162. package/src/validators/LionWebReferenceValidator.ts +90 -76
  163. package/src/validators/LionWebSyntaxValidator.ts +108 -99
  164. package/src/validators/LionWebValidator.ts +33 -33
  165. package/src/validators/SimpleFieldValidator.ts +33 -28
  166. package/src/validators/ValidationResult.ts +5 -6
  167. package/src/validators/index.ts +7 -7
  168. package/dist/diff/LionwebDiff.d.ts +0 -40
  169. package/dist/diff/LionwebDiff.d.ts.map +0 -1
  170. package/dist/diff/LionwebDiff.js +0 -158
  171. package/dist/diff/LionwebDiff.js.map +0 -1
  172. package/dist/issues/JsonContext.d.ts.map +0 -1
  173. package/dist/issues/JsonContext.js.map +0 -1
  174. package/src/diff/LionwebDiff.ts +0 -193
  175. package/src/issues/JsonContext.ts +0 -31
  176. /package/dist/{issues → json}/JsonContext.d.ts +0 -0
  177. /package/dist/{issues → json}/JsonContext.js +0 -0
@@ -0,0 +1,52 @@
1
+ import { JsonContext } from "../../issues/index.js"
2
+
3
+ export type ChangeType =
4
+ | "GenericChange"
5
+ | "NodeRemoved"
6
+ | "NodeAdded"
7
+ | "ChildRemoved"
8
+ | "ChildAdded"
9
+ | "ParentChanged"
10
+ | "PropertyValueChanged"
11
+ | "SerializationFormatChange"
12
+ | "PropertyRemoved"
13
+ | "PropertyAdded"
14
+ | "NodeClassifierChanged"
15
+ | "ContainmentAdded"
16
+ | "ContainmentRemoved"
17
+ | "LanguageRemoved"
18
+ | "LanguageAdded"
19
+ | "TargetAdded"
20
+ | "TargetRemoved"
21
+ | "ReferenceRemoved"
22
+ | "ReferenceAdded"
23
+
24
+ export abstract class Change {
25
+ abstract readonly id: ChangeType
26
+ context: JsonContext
27
+
28
+ constructor(context: JsonContext) {
29
+ this.context = context
30
+ }
31
+
32
+ protected abstract msg(): string
33
+
34
+ public changeMsg(): string {
35
+ return `${this.id}: ${this.msg()} at ${this.context.toString()} `
36
+ }
37
+ }
38
+
39
+ export class GenericChange extends Change {
40
+ readonly id = "GenericChange"
41
+
42
+ constructor(
43
+ context: JsonContext,
44
+ protected message: string,
45
+ ) {
46
+ super(context)
47
+ }
48
+
49
+ protected msg(): string {
50
+ return this.message
51
+ }
52
+ }
@@ -0,0 +1,68 @@
1
+ import { JsonContext } from "../../issues/index.js"
2
+ import { LionWebJsonNode, LwJsonUsedLanguage } from "../../json/index.js"
3
+ import { Change } from "./Change.js"
4
+
5
+ export abstract class ChunkChange extends Change {
6
+ constructor(public context: JsonContext) {
7
+ super(context)
8
+ }
9
+ }
10
+
11
+ export class SerializationFormatChange extends ChunkChange {
12
+ readonly id = "SerializationFormatChange"
13
+
14
+ constructor(
15
+ public context: JsonContext,
16
+ protected original: string,
17
+ protected newValue: string,
18
+ ) {
19
+ super(context)
20
+ }
21
+
22
+ protected msg = () => `Serialization versions do not match: ${this.original} vs ${this.newValue}`
23
+ }
24
+
25
+ export class NodeRemoved extends ChunkChange {
26
+ readonly id = "NodeRemoved"
27
+
28
+ constructor(
29
+ public context: JsonContext,
30
+ public node: LionWebJsonNode,
31
+ ) {
32
+ super(context)
33
+ }
34
+
35
+ protected msg = () => `Node ${this.node.id} is removed`
36
+ }
37
+
38
+ export class NodeAdded extends ChunkChange {
39
+ readonly id = "NodeAdded"
40
+
41
+ constructor(
42
+ public context: JsonContext,
43
+ public node: LionWebJsonNode,
44
+ ) {
45
+ super(context)
46
+ }
47
+
48
+ protected msg = () => `Node ${this.node.id} is added`
49
+ }
50
+
51
+ export abstract class LanguageChange extends ChunkChange {
52
+ constructor(
53
+ public context: JsonContext,
54
+ public language: LwJsonUsedLanguage,
55
+ ) {
56
+ super(context)
57
+ }
58
+ }
59
+
60
+ export class LanguageRemoved extends LanguageChange {
61
+ readonly id = "LanguageRemoved"
62
+ protected msg = () => `Language with key ${this.language.key} and version ${this.language.version} is removed`
63
+ }
64
+
65
+ export class LanguageAdded extends LanguageChange {
66
+ readonly id = "LanguageAdded"
67
+ protected msg = () => `Language with key ${this.language.key} and version ${this.language.version} is added`
68
+ }
@@ -0,0 +1,34 @@
1
+ import { JsonContext } from "../../issues/index.js"
2
+ import { LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
3
+ import { Change } from "./Change.js"
4
+
5
+ export abstract class ContainmentChange extends Change {
6
+ constructor(
7
+ public context: JsonContext,
8
+ public parentNode: LionWebJsonNode,
9
+ public containment: LionWebJsonMetaPointer,
10
+ public childId: string,
11
+ ) {
12
+ super(context)
13
+ }
14
+ }
15
+
16
+ export class ChildAdded extends ContainmentChange {
17
+ readonly id = "ChildAdded"
18
+ protected msg = () => `Node "${this.parentNode.id}" added child "${this.childId}" to containment ${this.containment.key}`
19
+ }
20
+
21
+ export class ChildRemoved extends ContainmentChange {
22
+ readonly id = "ChildRemoved"
23
+ protected msg = () => `Node "${this.parentNode.id}" removed child "${this.childId}"`
24
+ }
25
+
26
+ export class ContainmentAdded extends Change {
27
+ readonly id = "ContainmentAdded";
28
+ constructor(ctx: JsonContext, public node: LionWebJsonNode, public containment: LionWebJsonMetaPointer) {
29
+ super(ctx)
30
+ }
31
+
32
+ protected msg = () => `Node "${this.node.id}" containment added: "${JSON.stringify(this.containment)}"`
33
+ }
34
+
@@ -0,0 +1,32 @@
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 id: 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
+ protected msg = () => `Object ${this.node.id} has classifier changed from ${this.oldClassifier.key} to ${this.newClassifier.key}`
17
+ }
18
+
19
+ export class ParentChanged extends Change {
20
+ readonly id = "ParentChanged"
21
+
22
+ constructor(
23
+ public context: JsonContext,
24
+ public node: LionWebJsonNode,
25
+ public beforeParentId: string | null,
26
+ public afterParentId: string | null,
27
+ ) {
28
+ super(context)
29
+ }
30
+
31
+ protected msg = () => `Node "${this.node.id}" changed parent from "${this.beforeParentId}" to "${this.afterParentId}`
32
+ }
@@ -0,0 +1,29 @@
1
+ import { JsonContext } from "../../issues/index.js"
2
+ import { LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
3
+ import { Change } from "./Change.js"
4
+
5
+ export abstract class PropertyChange extends Change {
6
+ constructor(
7
+ public context: JsonContext,
8
+ public nodeId: string,
9
+ public property: LionWebJsonMetaPointer,
10
+ public oldValue: string | undefined,
11
+ public newValue: string | undefined,
12
+ ) {
13
+ super(context)
14
+ }
15
+ }
16
+
17
+ export class PropertyValueChanged extends PropertyChange {
18
+ readonly id = "PropertyValueChanged"
19
+ protected msg = () => `Node "${this.nodeId} changed value of property "${this.property.key}" from "${this.oldValue}" to "${this.newValue}"`
20
+ }
21
+
22
+ export class PropertyAdded extends Change {
23
+ readonly id = "PropertyAdded";
24
+ constructor(ctx: JsonContext, public node: LionWebJsonNode, public property: LionWebJsonMetaPointer) {
25
+ super(ctx)
26
+ }
27
+
28
+ protected msg = () => `Node "${this.node.id}" containment added: "${JSON.stringify(this.property)}"`
29
+ }
@@ -0,0 +1,24 @@
1
+ import { JsonContext } from "../../issues/index.js"
2
+ import { LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
3
+ import { Change } from "./Change.js"
4
+
5
+ export abstract class ReferenceChange extends Change {
6
+ constructor(
7
+ public context: JsonContext,
8
+ public node: LionWebJsonNode,
9
+ public reference: LionWebJsonMetaPointer,
10
+ public targetId: string,
11
+ ) {
12
+ super(context)
13
+ }
14
+ }
15
+
16
+ export class TargetAdded extends ReferenceChange {
17
+ readonly id = "TargetAdded"
18
+ protected msg = () => `Node "${this.node.id}" added target "${this.targetId}" to reference "${this.reference.key}"`
19
+ }
20
+
21
+ export class TargetRemoved extends ReferenceChange {
22
+ readonly id = "TargetRemoved"
23
+ protected msg = () => `Node "${this.node.id}" removed target "${this.targetId}" from reference "${this.reference.key}"`
24
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./Change.js"
2
+ export * from "./ChunkChange.js"
3
+ export * from "./ContainmentChange.js"
4
+ export * from "./NodeChange.js"
5
+ export * from "./PropertyChange.js"
6
+ export * from "./ReferenceChange.js"
@@ -0,0 +1,3 @@
1
+ export * from "./changes/index.js"
2
+ export * from "./DiffResult.js"
3
+ export * from "./LionWebJsonDiff.js"
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- export * from "./issues/index.js";
2
- export * from "./json/index.js";
3
- export * from "./validators/index.js";
4
- export * from "./runners/index.js";
1
+ export * from "./issues/index.js"
2
+ export * from "./json/index.js"
3
+ export * from "./validators/index.js"
4
+ export * from "./diff/index.js"
5
+ export * from "./runners/index.js"
@@ -1,12 +1,17 @@
1
- import { LionWebJsonMetaPointer } from "../json/LionWebJson.js";
2
- import { JsonContext } from "./JsonContext.js";
3
- import { ValidationIssue } from "./ValidationIssue.js";
1
+ import { LionWebJsonMetaPointer } from "../json/LionWebJson.js"
2
+ import { JsonContext } from "../json/JsonContext.js"
3
+ import { ValidationIssue } from "./ValidationIssue.js"
4
4
 
5
5
  export class Language_PropertyValue_Issue extends ValidationIssue {
6
- readonly id = "PropertyValue";
6
+ readonly id = "PropertyValue"
7
7
 
8
- constructor(context: JsonContext, public property: string, public value: string,public expectedType: string ) {
9
- super(context);
8
+ constructor(
9
+ context: JsonContext,
10
+ public property: string,
11
+ public value: string,
12
+ public expectedType: string,
13
+ ) {
14
+ super(context)
10
15
  }
11
16
 
12
17
  msg = (): string => `Property "${this.property}" with value "${this.value}" is not of type "${this.expectedType}"`
@@ -14,79 +19,96 @@ export class Language_PropertyValue_Issue extends ValidationIssue {
14
19
 
15
20
  // Incorrect Meta Pointers
16
21
  export abstract class Language_IncorrectMetaPointerType_Issue extends ValidationIssue {
17
- abstract readonly metaType: string;
22
+ abstract readonly metaType: string
18
23
 
19
- constructor(context: JsonContext, public metaPointer: LionWebJsonMetaPointer, public incorrectType: string) {
20
- super(context);
24
+ constructor(
25
+ context: JsonContext,
26
+ public metaPointer: LionWebJsonMetaPointer,
27
+ public incorrectType: string,
28
+ ) {
29
+ super(context)
21
30
  }
22
31
 
23
- msg = (): string => `${this.metaType} with key "${this.metaPointer.key}" does not refer to a ${this.metaType}, but to a "${this.incorrectType}"`
32
+ msg = (): string =>
33
+ `${this.metaType} with key "${this.metaPointer.key}" does not refer to a ${this.metaType}, but to a "${this.incorrectType}"`
24
34
  }
25
35
 
26
36
  export class Language_IncorrectPropertyMetaPointer_Issue extends Language_IncorrectMetaPointerType_Issue {
27
- readonly id = "IncorrectPropertyMetaPointer";
28
- readonly metaType = "Property";
37
+ readonly id = "IncorrectPropertyMetaPointer"
38
+ readonly metaType = "Property"
29
39
  }
30
40
  export class Language_IncorrectConceptMetaPointer_Issue extends Language_IncorrectMetaPointerType_Issue {
31
- readonly id = "IncorrectConceptMetaPointer";
32
- readonly metaType = "Concept";
41
+ readonly id = "IncorrectConceptMetaPointer"
42
+ readonly metaType = "Concept"
33
43
  }
34
44
  export class Language_IncorrectReferenceMetaPointer_Issue extends Language_IncorrectMetaPointerType_Issue {
35
- readonly id = "IncorrectReferenceMetaPointer";
36
- readonly metaType = "Reference";
45
+ readonly id = "IncorrectReferenceMetaPointer"
46
+ readonly metaType = "Reference"
37
47
  }
38
48
  export class Language_IncorrectContainmentMetaPointer_Issue extends Language_IncorrectMetaPointerType_Issue {
39
- readonly id = "IncorrectContainmentMetaPointer";
40
- readonly metaType = "Containment";
49
+ readonly id = "IncorrectContainmentMetaPointer"
50
+ readonly metaType = "Containment"
41
51
  }
42
52
 
43
53
  // Unknown Meta Pointers
44
54
  export abstract class Language_UnknownMetaPointer_Issue extends ValidationIssue {
45
- abstract readonly metaType: string;
55
+ abstract readonly metaType: string
46
56
 
47
- constructor(context: JsonContext, public metaPointer: LionWebJsonMetaPointer) {
48
- super(context);
57
+ constructor(
58
+ context: JsonContext,
59
+ public metaPointer: LionWebJsonMetaPointer,
60
+ ) {
61
+ super(context)
49
62
  }
50
63
 
51
- msg = (): string => `${this.metaType} with key ${this.metaPointer.key} is unknown in the language`;
64
+ msg = (): string => `${this.metaType} with key ${this.metaPointer.key} is unknown in the language`
52
65
  }
53
66
 
54
67
  export class Language_UnknownReference_Issue extends Language_UnknownMetaPointer_Issue {
55
- readonly id = "UnknownReference";
56
- readonly metaType = "Reference";
68
+ readonly id = "UnknownReference"
69
+ readonly metaType = "Reference"
57
70
  }
58
71
  export class Language_UnknownContainment_Issue extends Language_UnknownMetaPointer_Issue {
59
- readonly id = "UnknownContainment";
60
- readonly metaType = "Containment";
72
+ readonly id = "UnknownContainment"
73
+ readonly metaType = "Containment"
61
74
  }
62
75
  export class Language_UnknownProperty_Issue extends Language_UnknownMetaPointer_Issue {
63
- readonly id = "UnknownProperty";
64
- readonly metaType = "Property";
76
+ readonly id = "UnknownProperty"
77
+ readonly metaType = "Property"
65
78
  }
66
79
  export class Language_UnknownConcept_Issue extends Language_UnknownMetaPointer_Issue {
67
- readonly id = "UnknownConcept";
68
- readonly metaType = "Concept";
80
+ readonly id = "UnknownConcept"
81
+ readonly metaType = "Concept"
69
82
  }
70
83
 
71
84
  // Actual Language checks on M2
72
85
  export class NumberOfLanguagesUsed_Issue extends ValidationIssue {
73
- readonly id = "NumberOfLanguagesUsed";
74
- constructor(context: JsonContext, public nrOfLanguages: number) {
75
- super(context);
86
+ readonly id = "NumberOfLanguagesUsed"
87
+ constructor(
88
+ context: JsonContext,
89
+ public nrOfLanguages: number,
90
+ ) {
91
+ super(context)
76
92
  }
77
93
  msg = () => `Is not a language: number of used languages should be 1, is ${this.nrOfLanguages}`
78
94
  }
79
95
  export class NotLionCoreLanguageKey_Issue extends ValidationIssue {
80
- readonly id = "NotLionCoreLanguageKey";
81
- constructor(context: JsonContext, public incorrectKey: string) {
82
- super(context);
96
+ readonly id = "NotLionCoreLanguageKey"
97
+ constructor(
98
+ context: JsonContext,
99
+ public incorrectKey: string,
100
+ ) {
101
+ super(context)
83
102
  }
84
103
  msg = () => `Is not a language: the used language key is not LionCore-M3, but ${this.incorrectKey}`
85
104
  }
86
105
  export class IncorrectLionCoreVersion_Issue extends ValidationIssue {
87
- readonly id = "IncorrectLionCoreVersion";
88
- constructor(context: JsonContext, public incorrectVersion: string) {
89
- super(context);
106
+ readonly id = "IncorrectLionCoreVersion"
107
+ constructor(
108
+ context: JsonContext,
109
+ public incorrectVersion: string,
110
+ ) {
111
+ super(context)
90
112
  }
91
113
  msg = () => `Is not a language: the used language version is not 1, but ${this.incorrectVersion}`
92
114
  }
@@ -1,61 +1,83 @@
1
- import { LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js";
2
- import { JsonContext } from "./JsonContext.js";
3
- import { ValidationIssue } from "./ValidationIssue.js";
1
+ import { LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js"
2
+ import { JsonContext } from "../json/JsonContext.js"
3
+ import { ValidationIssue } from "./ValidationIssue.js"
4
4
 
5
5
  export class Reference_DuplicateNodeId_Issue extends ValidationIssue {
6
- readonly id = "DuplicateNodeId";
7
-
8
- constructor(context: JsonContext, public nodeId: string) {
9
- super(context);
6
+ readonly id = "DuplicateNodeId"
7
+
8
+ constructor(
9
+ context: JsonContext,
10
+ public nodeId: string,
11
+ ) {
12
+ super(context)
10
13
  }
11
-
12
- msg = () : string => `Node has duplicate id "${this.nodeId}"`
14
+
15
+ msg = (): string => `Node has duplicate id "${this.nodeId}"`
13
16
  }
14
17
 
15
18
  export class Reference_ChildMissingInParent_Issue extends ValidationIssue {
16
- readonly id = "ChildMissingInParent";
19
+ readonly id = "ChildMissingInParent"
17
20
 
18
- constructor(context: JsonContext, public child: LionWebJsonNode, public parent: LionWebJsonNode) {
19
- super(context);
21
+ constructor(
22
+ context: JsonContext,
23
+ public child: LionWebJsonNode,
24
+ public parent: LionWebJsonNode,
25
+ ) {
26
+ super(context)
20
27
  }
21
28
 
22
- msg = () : string => `Node with id "${this.child.id}" has parent with id "${this.parent.id}" but parent does not contains it as a child.`
29
+ msg = (): string => `Node with id "${this.child.id}" has parent with id "${this.parent.id}" but parent does not contains it as a child.`
23
30
  }
24
31
 
25
32
  export class Reference_ParentMissingInChild_Issue extends ValidationIssue {
26
- readonly id = "ParentMissingInChild";
33
+ readonly id = "ParentMissingInChild"
27
34
 
28
- constructor(context: JsonContext, public parent: LionWebJsonNode, public child: LionWebJsonNode) {
29
- super(context);
35
+ constructor(
36
+ context: JsonContext,
37
+ public parent: LionWebJsonNode,
38
+ public child: LionWebJsonNode,
39
+ ) {
40
+ super(context)
30
41
  }
31
42
 
32
- msg = () : string => `Node with id "${this.parent.id}" has child with id "${this.child.id}" but child has empty parent.`
43
+ msg = (): string => `Node with id "${this.parent.id}" has child with id "${this.child.id}" but child has empty parent.`
33
44
  }
34
45
 
35
46
  export class Reference_CirculairParent_Issue extends ValidationIssue {
36
- readonly id = "CirculairParent";
47
+ readonly id = "CirculairParent"
37
48
 
38
- constructor(context: JsonContext, public node: LionWebJsonNode | undefined, public parentPath: string[]) {
39
- super(context);
49
+ constructor(
50
+ context: JsonContext,
51
+ public node: LionWebJsonNode | undefined,
52
+ public parentPath: string[],
53
+ ) {
54
+ super(context)
40
55
  }
41
56
 
42
- msg = () : string => `Node with id "${this.node?.id}" has circulair parent through "${this.parentPath}".`
57
+ msg = (): string => `Node with id "${this.node?.id}" has circulair parent through "${this.parentPath}".`
43
58
  }
44
59
 
45
60
  export class Reference_LanguageUnknown_Issue extends ValidationIssue {
46
- readonly id = "LanguageUnknown";
47
-
48
- constructor(context: JsonContext, public languageRef: LionWebJsonMetaPointer) {
49
- super(context);
61
+ readonly id = "LanguageUnknown"
62
+
63
+ constructor(
64
+ context: JsonContext,
65
+ public languageRef: LionWebJsonMetaPointer,
66
+ ) {
67
+ super(context)
50
68
  }
51
- msg = () => `Node uses language { language = ${this.languageRef.language}, version = ${this.languageRef.version} } which is not declared in used languages`
69
+ msg = () =>
70
+ `Node uses language { language = ${this.languageRef.language}, version = ${this.languageRef.version} } which is not declared in used languages`
52
71
  }
53
72
 
54
73
  export class Duplicates_Issue extends ValidationIssue {
55
- readonly id = "Duplicates";
74
+ readonly id = "Duplicates"
56
75
 
57
- constructor(context: JsonContext, public nodeid: string) {
58
- super(context);
76
+ constructor(
77
+ context: JsonContext,
78
+ public nodeid: string,
79
+ ) {
80
+ super(context)
59
81
  }
60
82
  msg = () => `Duplicate value "${this.nodeid}"`
61
83
  }
@@ -1,69 +1,84 @@
1
- import { JsonContext } from "./JsonContext.js";
2
- import { ValidationIssue } from "./ValidationIssue.js";
1
+ import { JsonContext } from "../json/JsonContext.js"
2
+ import { ValidationIssue } from "./ValidationIssue.js"
3
3
 
4
4
  export abstract class Syntax_PropertyIssue extends ValidationIssue {
5
- constructor(public context: JsonContext, protected property: string) {
6
- super(context);
5
+ constructor(
6
+ public context: JsonContext,
7
+ protected property: string,
8
+ ) {
9
+ super(context)
7
10
  }
8
11
  }
9
12
 
10
13
  export class Syntax_PropertyMissingIssue extends Syntax_PropertyIssue {
11
- readonly id = 'PropertyMissing';
12
- protected msg = () => `Property "${this.property}" is missing`;
14
+ readonly id = "PropertyMissing"
15
+ protected msg = () => `Property "${this.property}" is missing`
13
16
  }
14
17
 
15
18
  export class Syntax_PropertyUnknownIssue extends Syntax_PropertyIssue {
16
- readonly id = 'PropertyUnknown';
17
- protected msg = () => `Property "${this.property}" is not defined as a LionWeb property`;
19
+ readonly id = "PropertyUnknown"
20
+ protected msg = () => `Property "${this.property}" is not defined as a LionWeb property`
18
21
  }
19
22
 
20
23
  export class Syntax_PropertyNullIssue extends Syntax_PropertyIssue {
21
- readonly id = 'PropertyNull';
22
- protected msg = () => `Property "${this.property}" is null, but it should have a value`;
24
+ readonly id = "PropertyNull"
25
+ protected msg = () => `Property "${this.property}" is null, but it should have a value`
23
26
  }
24
27
 
25
28
  export class Syntax_PropertyTypeIssue extends Syntax_PropertyIssue {
26
- readonly id = 'PropertyTypeIncorrect';
29
+ readonly id = "PropertyTypeIncorrect"
27
30
 
28
- constructor(context: JsonContext, property: string, protected expectedType: string, protected actualType: string) {
29
- super(context, property);
31
+ constructor(
32
+ context: JsonContext,
33
+ property: string,
34
+ protected expectedType: string,
35
+ protected actualType: string,
36
+ ) {
37
+ super(context, property)
30
38
  }
31
39
 
32
- protected msg = () => `Property ${this.property} should have type "${this.expectedType}", but has type "${this.actualType}"`;
40
+ protected msg = () => `Property ${this.property} should have type "${this.expectedType}", but has type "${this.actualType}"`
33
41
  }
34
42
 
35
43
  export class Syntax_ArrayContainsNull_Issue extends Syntax_PropertyIssue {
36
- readonly id = "ArrayContainsNull";
44
+ readonly id = "ArrayContainsNull"
37
45
 
38
- constructor(context: JsonContext, property: string, public index: number) {
39
- super(context, property);
46
+ constructor(
47
+ context: JsonContext,
48
+ property: string,
49
+ public index: number,
50
+ ) {
51
+ super(context, property)
40
52
  }
41
53
 
42
54
  protected msg = () => `Property "${this.property}" of type array contains null at index "${"" + this.index}" `
43
55
  }
44
56
 
45
57
  export abstract class Syntax_IncorrectFormat_Issue extends ValidationIssue {
46
- constructor(context: JsonContext, public value: string) {
47
- super(context);
58
+ constructor(
59
+ context: JsonContext,
60
+ public value: string,
61
+ ) {
62
+ super(context)
48
63
  }
49
64
  }
50
65
 
51
66
  export class Syntax_SerializationFormatVersion_Issue extends Syntax_IncorrectFormat_Issue {
52
- readonly id = "SerializationFormatVersion";
67
+ readonly id = "SerializationFormatVersion"
53
68
  protected msg = () => `SerializationFormatVersion "${this.value}" is not a number`
54
69
  }
55
70
 
56
71
  export class Syntax_VersionFormat_Issue extends Syntax_IncorrectFormat_Issue {
57
- readonly id = "VersionFormat";
72
+ readonly id = "VersionFormat"
58
73
  protected msg = () => `Version "${this.value}" is an empty string.`
59
74
  }
60
75
 
61
76
  export class Syntax_KeyFormat_Issue extends Syntax_IncorrectFormat_Issue {
62
- readonly id = "KeyFormat";
77
+ readonly id = "KeyFormat"
63
78
  protected msg = () => `Key "${this.value}" has incorrect format.`
64
79
  }
65
80
 
66
81
  export class Syntax_IdFormat_Issue extends Syntax_IncorrectFormat_Issue {
67
- readonly id = "IdFormat";
82
+ readonly id = "IdFormat"
68
83
  protected msg = () => `Id "${this.value}" has incorrect format.`
69
84
  }
@@ -1,15 +1,15 @@
1
- import { JsonContext } from "./JsonContext.js";
1
+ import { JsonContext } from "../json/JsonContext.js"
2
2
 
3
3
  export abstract class ValidationIssue {
4
- abstract readonly id: string;
5
- context: JsonContext;
6
-
4
+ abstract readonly id: string
5
+ context: JsonContext
6
+
7
7
  constructor(context: JsonContext) {
8
- this.context = context;
8
+ this.context = context
9
9
  }
10
10
 
11
- protected abstract msg(): string;
12
-
11
+ protected abstract msg(): string
12
+
13
13
  public errorMsg(): string {
14
14
  return `${this.id}: ${this.msg()} at ${this.context.toString()} `
15
15
  }