@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.
Files changed (202) hide show
  1. package/dist/diff/DiffResult.d.ts +9 -0
  2. package/dist/diff/DiffResult.d.ts.map +1 -0
  3. package/dist/diff/DiffResult.js +18 -0
  4. package/dist/diff/DiffResult.js.map +1 -0
  5. package/dist/diff/LionWebJsonDiff.d.ts +25 -0
  6. package/dist/diff/LionWebJsonDiff.d.ts.map +1 -0
  7. package/dist/diff/LionWebJsonDiff.js +249 -0
  8. package/dist/diff/LionWebJsonDiff.js.map +1 -0
  9. package/dist/diff/changes/Change.d.ts +34 -0
  10. package/dist/diff/changes/Change.d.ts.map +1 -0
  11. package/dist/diff/changes/Change.js +38 -0
  12. package/dist/diff/changes/Change.js.map +1 -0
  13. package/dist/diff/changes/ChunkChange.d.ts +43 -0
  14. package/dist/diff/changes/ChunkChange.d.ts.map +1 -0
  15. package/dist/diff/changes/ChunkChange.js +57 -0
  16. package/dist/diff/changes/ChunkChange.js.map +1 -0
  17. package/dist/diff/changes/ContainmentChange.d.ts +25 -0
  18. package/dist/diff/changes/ContainmentChange.d.ts.map +1 -0
  19. package/dist/diff/changes/ContainmentChange.js +34 -0
  20. package/dist/diff/changes/ContainmentChange.js.map +1 -0
  21. package/dist/diff/changes/NodeChange.d.ts +41 -0
  22. package/dist/diff/changes/NodeChange.d.ts.map +1 -0
  23. package/dist/diff/changes/NodeChange.js +54 -0
  24. package/dist/diff/changes/NodeChange.js.map +1 -0
  25. package/dist/diff/changes/PropertyChange.d.ts +24 -0
  26. package/dist/diff/changes/PropertyChange.d.ts.map +1 -0
  27. package/dist/diff/changes/PropertyChange.js +29 -0
  28. package/dist/diff/changes/PropertyChange.js.map +1 -0
  29. package/dist/diff/changes/ReferenceChange.d.ts +25 -0
  30. package/dist/diff/changes/ReferenceChange.d.ts.map +1 -0
  31. package/dist/diff/changes/ReferenceChange.js +34 -0
  32. package/dist/diff/changes/ReferenceChange.js.map +1 -0
  33. package/dist/diff/changes/index.d.ts +7 -0
  34. package/dist/diff/changes/index.d.ts.map +1 -0
  35. package/dist/diff/changes/index.js +7 -0
  36. package/dist/diff/changes/index.js.map +1 -0
  37. package/dist/diff/index.d.ts +4 -0
  38. package/dist/diff/index.d.ts.map +1 -0
  39. package/dist/diff/index.js +4 -0
  40. package/dist/diff/index.js.map +1 -0
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +3 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/issues/LanguageIssues.d.ts +4 -4
  46. package/dist/issues/LanguageIssues.d.ts.map +1 -1
  47. package/dist/issues/LanguageIssues.js +1 -1
  48. package/dist/issues/LanguageIssues.js.map +1 -1
  49. package/dist/issues/ReferenceIssues.d.ts +6 -6
  50. package/dist/issues/ReferenceIssues.d.ts.map +1 -1
  51. package/dist/issues/ReferenceIssues.js +3 -3
  52. package/dist/issues/ReferenceIssues.js.map +1 -1
  53. package/dist/issues/SyntaxIssues.d.ts +1 -1
  54. package/dist/issues/SyntaxIssues.d.ts.map +1 -1
  55. package/dist/issues/ValidationIssue.d.ts +1 -1
  56. package/dist/issues/ValidationIssue.d.ts.map +1 -1
  57. package/dist/issues/ValidationIssue.js.map +1 -1
  58. package/dist/issues/index.d.ts +1 -0
  59. package/dist/issues/index.d.ts.map +1 -1
  60. package/dist/issues/index.js +1 -0
  61. package/dist/issues/index.js.map +1 -1
  62. package/dist/json/ChunkUtils.d.ts +26 -0
  63. package/dist/json/ChunkUtils.d.ts.map +1 -0
  64. package/dist/json/ChunkUtils.js +46 -0
  65. package/dist/json/ChunkUtils.js.map +1 -0
  66. package/dist/json/JsonContext.d.ts +11 -0
  67. package/dist/json/JsonContext.d.ts.map +1 -0
  68. package/dist/json/JsonContext.js +25 -0
  69. package/dist/json/JsonContext.js.map +1 -0
  70. package/dist/json/LionWebJson.d.ts +50 -0
  71. package/dist/json/LionWebJson.d.ts.map +1 -0
  72. package/dist/json/LionWebJson.js +27 -0
  73. package/dist/json/LionWebJson.js.map +1 -0
  74. package/dist/json/LionWebJsonChunkWrapper.d.ts +39 -0
  75. package/dist/json/LionWebJsonChunkWrapper.d.ts.map +1 -0
  76. package/dist/json/LionWebJsonChunkWrapper.js +119 -0
  77. package/dist/json/LionWebJsonChunkWrapper.js.map +1 -0
  78. package/dist/json/M3definitions.d.ts +176 -0
  79. package/dist/json/M3definitions.d.ts.map +1 -0
  80. package/dist/json/M3definitions.js +174 -0
  81. package/dist/json/M3definitions.js.map +1 -0
  82. package/dist/json/NodeUtils.d.ts +23 -0
  83. package/dist/json/NodeUtils.d.ts.map +1 -0
  84. package/dist/json/NodeUtils.js +57 -0
  85. package/dist/json/NodeUtils.js.map +1 -0
  86. package/dist/json/index.d.ts +7 -0
  87. package/dist/json/index.d.ts.map +1 -0
  88. package/dist/json/index.js +7 -0
  89. package/dist/json/index.js.map +1 -0
  90. package/dist/languages/CompositeLionWebLanguageWrapper.d.ts +1 -1
  91. package/dist/languages/CompositeLionWebLanguageWrapper.d.ts.map +1 -1
  92. package/dist/languages/LanguageRegistry.d.ts +1 -1
  93. package/dist/languages/LanguageRegistry.d.ts.map +1 -1
  94. package/dist/languages/LanguageUtils.d.ts +1 -1
  95. package/dist/languages/LanguageUtils.d.ts.map +1 -1
  96. package/dist/languages/LanguageUtils.js +5 -5
  97. package/dist/languages/LanguageUtils.js.map +1 -1
  98. package/dist/languages/LionWebLanguageWrapper.d.ts +3 -3
  99. package/dist/languages/LionWebLanguageWrapper.d.ts.map +1 -1
  100. package/dist/languages/LionWebLanguageWrapper.js +2 -2
  101. package/dist/languages/LionWebLanguageWrapper.js.map +1 -1
  102. package/dist/languages/MetaPointerMap.d.ts +2 -2
  103. package/dist/languages/MetaPointerMap.d.ts.map +1 -1
  104. package/dist/languages/MetaPointerMap.js +1 -1
  105. package/dist/languages/MetaPointerMap.js.map +1 -1
  106. package/dist/runners/FileUtils.d.ts.map +1 -1
  107. package/dist/runners/FileUtils.js +1 -1
  108. package/dist/runners/FileUtils.js.map +1 -1
  109. package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
  110. package/dist/runners/RunLioncoreDiff.js +1 -1
  111. package/dist/runners/RunLioncoreDiff.js.map +1 -1
  112. package/dist/util/graphs.d.ts +18 -0
  113. package/dist/util/graphs.d.ts.map +1 -0
  114. package/dist/util/graphs.js +27 -0
  115. package/dist/util/graphs.js.map +1 -0
  116. package/dist/validators/LionWebChunkDefinitions.d.ts +2 -2
  117. package/dist/validators/LionWebChunkDefinitions.d.ts.map +1 -1
  118. package/dist/validators/LionWebChunkDefinitions.js +20 -33
  119. package/dist/validators/LionWebChunkDefinitions.js.map +1 -1
  120. package/dist/validators/LionWebLanguageReferenceValidator.d.ts +4 -2
  121. package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
  122. package/dist/validators/LionWebLanguageReferenceValidator.js +6 -2
  123. package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
  124. package/dist/validators/LionWebLanguageValidator.d.ts +3 -2
  125. package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
  126. package/dist/validators/LionWebLanguageValidator.js +4 -2
  127. package/dist/validators/LionWebLanguageValidator.js.map +1 -1
  128. package/dist/validators/LionWebReferenceValidator.d.ts +4 -3
  129. package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
  130. package/dist/validators/LionWebReferenceValidator.js +3 -2
  131. package/dist/validators/LionWebReferenceValidator.js.map +1 -1
  132. package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
  133. package/dist/validators/LionWebSyntaxValidator.js +1 -1
  134. package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
  135. package/dist/validators/LionWebValidator.d.ts +1 -1
  136. package/dist/validators/LionWebValidator.d.ts.map +1 -1
  137. package/dist/validators/LionWebValidator.js +2 -2
  138. package/dist/validators/LionWebValidator.js.map +1 -1
  139. package/dist/validators/ValidationFunctions.d.ts +1 -5
  140. package/dist/validators/ValidationFunctions.d.ts.map +1 -1
  141. package/dist/validators/ValidationFunctions.js +4 -0
  142. package/dist/validators/ValidationFunctions.js.map +1 -1
  143. package/dist/validators/generic/SyntaxValidator.d.ts +9 -9
  144. package/dist/validators/generic/SyntaxValidator.d.ts.map +1 -1
  145. package/dist/validators/generic/SyntaxValidator.js +58 -61
  146. package/dist/validators/generic/SyntaxValidator.js.map +1 -1
  147. package/dist/validators/generic/ValidationTypes.d.ts +1 -25
  148. package/dist/validators/generic/ValidationTypes.d.ts.map +1 -1
  149. package/dist/validators/generic/ValidationTypes.js +1 -20
  150. package/dist/validators/generic/ValidationTypes.js.map +1 -1
  151. package/dist/validators/generic/index.d.ts +1 -0
  152. package/dist/validators/generic/index.d.ts.map +1 -1
  153. package/dist/validators/generic/index.js +1 -0
  154. package/dist/validators/generic/index.js.map +1 -1
  155. package/dist/validators/index.d.ts +1 -0
  156. package/dist/validators/index.d.ts.map +1 -1
  157. package/dist/validators/index.js +1 -0
  158. package/dist/validators/index.js.map +1 -1
  159. package/package.json +3 -8
  160. package/src/diff/DiffResult.ts +21 -0
  161. package/src/diff/LionWebJsonDiff.ts +309 -0
  162. package/src/diff/changes/Change.ts +76 -0
  163. package/src/diff/changes/ChunkChange.ts +68 -0
  164. package/src/diff/changes/ContainmentChange.ts +32 -0
  165. package/src/diff/changes/NodeChange.ts +63 -0
  166. package/src/diff/changes/PropertyChange.ts +31 -0
  167. package/src/diff/changes/ReferenceChange.ts +34 -0
  168. package/src/diff/changes/index.ts +6 -0
  169. package/src/diff/index.ts +3 -0
  170. package/src/index.ts +3 -0
  171. package/src/issues/LanguageIssues.ts +14 -12
  172. package/src/issues/ReferenceIssues.ts +9 -9
  173. package/src/issues/SyntaxIssues.ts +5 -5
  174. package/src/issues/ValidationIssue.ts +4 -7
  175. package/src/issues/index.ts +1 -0
  176. package/src/json/ChunkUtils.ts +49 -0
  177. package/src/json/JsonContext.ts +31 -0
  178. package/src/json/LionWebJson.ts +80 -0
  179. package/src/json/LionWebJsonChunkWrapper.ts +136 -0
  180. package/src/json/M3definitions.ts +177 -0
  181. package/src/json/NodeUtils.ts +75 -0
  182. package/src/json/index.ts +6 -0
  183. package/src/languages/CompositeLionWebLanguageWrapper.ts +1 -1
  184. package/src/languages/LanguageRegistry.ts +1 -1
  185. package/src/languages/LanguageUtils.ts +6 -6
  186. package/src/languages/LionWebLanguageWrapper.ts +9 -5
  187. package/src/languages/MetaPointerMap.ts +6 -7
  188. package/src/runners/FileUtils.ts +1 -1
  189. package/src/runners/RunCheckFolderWithLanguage.ts +1 -1
  190. package/src/runners/RunLioncoreDiff.ts +2 -2
  191. package/src/util/graphs.ts +36 -0
  192. package/src/validators/LionWebChunkDefinitions.ts +27 -35
  193. package/src/validators/LionWebLanguageReferenceValidator.ts +20 -18
  194. package/src/validators/LionWebLanguageValidator.ts +4 -2
  195. package/src/validators/LionWebReferenceValidator.ts +14 -6
  196. package/src/validators/LionWebSyntaxValidator.ts +1 -1
  197. package/src/validators/LionWebValidator.ts +3 -3
  198. package/src/validators/ValidationFunctions.ts +1 -1
  199. package/src/validators/generic/SyntaxValidator.ts +91 -98
  200. package/src/validators/generic/ValidationTypes.ts +4 -41
  201. package/src/validators/generic/index.ts +1 -0
  202. package/src/validators/index.ts +1 -0
@@ -0,0 +1,177 @@
1
+ /**
2
+ * This file contains LionWeb defined M3 keys and identifications.
3
+ */
4
+ export const LION_CORE_BUILTINS_INAMED_NAME = "LionCore-builtins-INamed-name"
5
+ export const LION_CORE_BUILTINS_KEY = "LionCore-builtins"
6
+
7
+ export const LION_CORE_M3_KEY = "LionCore-M3"
8
+ export const LION_CORE_M3_NAME = "LionCore_M3"
9
+
10
+ export const LION_CORE_M3_VERSION = "2023.1"
11
+ // Builtin datatypes
12
+ export const LIONWEB_BOOLEAN_TYPE = "LionCore-builtins-Boolean"
13
+ export const LIONWEB_JSON_TYPE = "LionCore-builtins-JSON"
14
+ export const LIONWEB_INTEGER_TYPE = "LionCore-builtins-Integer"
15
+ export const LIONWEB_STRING_TYPE = "LionCore-builtins-String"
16
+
17
+ export const M3_Keys = {
18
+ Property: "Property",
19
+ Reference: "Reference",
20
+ Concept: "Concept",
21
+ conceptExtends: "Concept-extends",
22
+ conceptImplements: "Concept-implements",
23
+ concept2: {
24
+ key: "Concept",
25
+ extends: { key: "Concept-extends" },
26
+ implements: { key: "Concept-implements" }
27
+ },
28
+ conceptAbstract: "Concept-abstract",
29
+ conceptPartition: "Concept-partition",
30
+ classifierFeatures: "Classifier-features",
31
+ Interface: "Interface",
32
+ InterfaceExtends: "Interface-extends",
33
+ Containment: "Containment",
34
+ Language: "Language",
35
+ languageVersion: "Language-version",
36
+ IKeyedKey: "IKeyed-key",
37
+ PropertyType: "Property-type",
38
+ Enumeration: "Enumeration",
39
+ EnumerationLiterals: "Enumeration-literals",
40
+ EnumerationLiteral: "EnumerationLiteral",
41
+ INamed: "LionCore-builtins-INamed",
42
+ INamedName: "LionCore-builtins-INamed-name",
43
+ Annotation: "Annotation",
44
+ AnnotationAnnotates: "Annotation-annotates",
45
+ AnnotationExtends: "Annotation-extends",
46
+ AnnotationImplements: "Annotation-implements",
47
+ Node: "LionCore-builtins-Node"
48
+ }
49
+
50
+ export const MetaPointers = {
51
+ Language: {
52
+ version: LION_CORE_M3_VERSION,
53
+ language: LION_CORE_M3_KEY,
54
+ key: M3_Keys.Language
55
+ },
56
+ LanguageVersion: {
57
+ version: LION_CORE_M3_VERSION,
58
+ language: LION_CORE_M3_KEY,
59
+ key: M3_Keys.languageVersion
60
+ },
61
+ ClassifierFeatures: {
62
+ version: LION_CORE_M3_VERSION,
63
+ language: LION_CORE_M3_KEY,
64
+ key: M3_Keys.classifierFeatures
65
+ },
66
+ Concept: {
67
+ version: LION_CORE_M3_VERSION,
68
+ language: LION_CORE_M3_KEY,
69
+ key: M3_Keys.concept2.key
70
+ },
71
+ ConceptAbstract: {
72
+ version: LION_CORE_M3_VERSION,
73
+ language: LION_CORE_M3_KEY,
74
+ key: M3_Keys.conceptAbstract
75
+ },
76
+ ConceptPartition: {
77
+ version: LION_CORE_M3_VERSION,
78
+ language: LION_CORE_M3_KEY,
79
+ key: M3_Keys.conceptPartition
80
+ },
81
+ ConceptExtends: {
82
+ version: LION_CORE_M3_VERSION,
83
+ language: LION_CORE_M3_KEY,
84
+ key: M3_Keys.concept2.extends.key
85
+ },
86
+ ConceptImplements: {
87
+ version: LION_CORE_M3_VERSION,
88
+ language: LION_CORE_M3_KEY,
89
+ key: M3_Keys.concept2.implements.key
90
+ },
91
+ Annotation: {
92
+ version: LION_CORE_M3_VERSION,
93
+ language: LION_CORE_M3_KEY,
94
+ key: M3_Keys.Annotation
95
+ },
96
+ AnnotationAnnotates: {
97
+ version: LION_CORE_M3_VERSION,
98
+ language: LION_CORE_M3_KEY,
99
+ key: M3_Keys.AnnotationAnnotates
100
+ },
101
+ AnnotationExtends: {
102
+ version: LION_CORE_M3_VERSION,
103
+ language: LION_CORE_M3_KEY,
104
+ key: M3_Keys.AnnotationExtends
105
+ },
106
+ AnnotationImplements: {
107
+ version: LION_CORE_M3_VERSION,
108
+ language: LION_CORE_M3_KEY,
109
+ key: M3_Keys.AnnotationImplements
110
+ },
111
+ Interface: {
112
+ version: LION_CORE_M3_VERSION,
113
+ language: LION_CORE_M3_KEY,
114
+ key: M3_Keys.Interface
115
+ },
116
+ InterfaceExtends: {
117
+ version: LION_CORE_M3_VERSION,
118
+ language: LION_CORE_M3_KEY,
119
+ key: M3_Keys.InterfaceExtends
120
+ },
121
+ Enumeration: {
122
+ version: LION_CORE_M3_VERSION,
123
+ language: LION_CORE_M3_KEY,
124
+ key: M3_Keys.Enumeration
125
+ },
126
+ EnumerationLiteral: {
127
+ version: LION_CORE_M3_VERSION,
128
+ language: LION_CORE_M3_KEY,
129
+ key: M3_Keys.EnumerationLiteral
130
+ },
131
+ EnumerationLiterals: {
132
+ version: LION_CORE_M3_VERSION,
133
+ language: LION_CORE_M3_KEY,
134
+ key: M3_Keys.EnumerationLiterals
135
+ },
136
+ Containment: {
137
+ version: LION_CORE_M3_VERSION,
138
+ language: LION_CORE_M3_KEY,
139
+ key: M3_Keys.Containment
140
+ },
141
+ Property: {
142
+ version: LION_CORE_M3_VERSION,
143
+ language: LION_CORE_M3_KEY,
144
+ key: M3_Keys.Property
145
+ },
146
+ PropertyType: {
147
+ version: LION_CORE_M3_VERSION,
148
+ language: LION_CORE_M3_KEY,
149
+ key: M3_Keys.PropertyType
150
+ },
151
+ Reference: {
152
+ version: LION_CORE_M3_VERSION,
153
+ language: LION_CORE_M3_KEY,
154
+ key: M3_Keys.Reference
155
+ },
156
+ IKeyedKey: {
157
+ language: LION_CORE_M3_KEY,
158
+ version: LION_CORE_M3_VERSION,
159
+ key: M3_Keys.IKeyedKey
160
+ },
161
+ // Builtins:
162
+ Node: {
163
+ language: LION_CORE_BUILTINS_KEY,
164
+ version: LION_CORE_M3_VERSION,
165
+ key: M3_Keys.Node
166
+ },
167
+ INamed: {
168
+ language: LION_CORE_BUILTINS_KEY,
169
+ version: LION_CORE_M3_VERSION,
170
+ key: M3_Keys.INamed
171
+ },
172
+ INamedName: {
173
+ language: LION_CORE_BUILTINS_KEY,
174
+ version: LION_CORE_M3_VERSION,
175
+ key: M3_Keys.INamedName
176
+ }
177
+ }
@@ -0,0 +1,75 @@
1
+ import {
2
+ isEqualMetaPointer,
3
+ isEqualReferenceTarget,
4
+ LionWebJsonContainment, LionWebJsonMetaPointer,
5
+ LionWebJsonNode,
6
+ LionWebJsonProperty,
7
+ LionWebJsonReference,
8
+ LionWebJsonReferenceTarget
9
+ } from "./LionWebJson.js"
10
+
11
+ /**
12
+ * Utility functions for LionWebJsonNode's
13
+ */
14
+ export class NodeUtils {
15
+ /**
16
+ * Find property with key equals `key` in `node`.
17
+ * @param node
18
+ * @param key
19
+ */
20
+ static findProperty(node: LionWebJsonNode, property: LionWebJsonMetaPointer): LionWebJsonProperty | undefined {
21
+ if (node === undefined) {
22
+ return undefined
23
+ }
24
+ return node.properties.find(
25
+ prop => isEqualMetaPointer(prop.property, property)
26
+ )
27
+ }
28
+
29
+ /**
30
+ * Find containment child with key equals `key` in `node`.
31
+ * @param node
32
+ * @param key
33
+ */
34
+ static findChild(node: LionWebJsonNode, key: string): LionWebJsonContainment | undefined {
35
+ if (node === undefined) {
36
+ return undefined
37
+ }
38
+ for (const containment of node.containments) {
39
+ if (containment.containment.key === key) {
40
+ return containment
41
+ }
42
+ }
43
+ return undefined
44
+ }
45
+
46
+ static findContainment(node: LionWebJsonNode, containment: LionWebJsonMetaPointer): LionWebJsonContainment | undefined {
47
+ if (node === undefined) {
48
+ return undefined
49
+ }
50
+ return node.containments.find(cont => isEqualMetaPointer(cont.containment, containment))
51
+ }
52
+
53
+ static findReference(node: LionWebJsonNode, reference: LionWebJsonMetaPointer): LionWebJsonReference | undefined {
54
+ if (node === undefined) {
55
+ return undefined
56
+ }
57
+ return node.references.find(ref => isEqualMetaPointer(ref.reference, reference))
58
+ }
59
+
60
+ static findReferenceTarget(
61
+ referenceTargets: LionWebJsonReferenceTarget[],
62
+ target: LionWebJsonReferenceTarget,
63
+ ): LionWebJsonReferenceTarget | undefined {
64
+ for (const refTarget of referenceTargets) {
65
+ if (isEqualReferenceTarget(refTarget, target)) {
66
+ return refTarget
67
+ }
68
+ }
69
+ return undefined
70
+ }
71
+
72
+ static findContainmentContainingChild(containments: LionWebJsonContainment[], childId: string): LionWebJsonContainment | undefined {
73
+ return containments.find(cont => cont.children.includes(childId))
74
+ }
75
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./JsonContext.js"
2
+ export * from "./NodeUtils.js"
3
+ export * from "./ChunkUtils.js"
4
+ export * from "./LionWebJson.js"
5
+ export * from "./LionWebJsonChunkWrapper.js"
6
+ export * from "./M3definitions.js"
@@ -1,4 +1,4 @@
1
- import { LionWebId, LionWebJsonMetaPointer, LionWebJsonNode } from "@lionweb/json"
1
+ import { LionWebId, LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js"
2
2
  import { LionWebLanguageWrapper } from "./LionWebLanguageWrapper.js"
3
3
  import { MetaPointerMap } from "./MetaPointerMap.js"
4
4
 
@@ -1,4 +1,4 @@
1
- import { LionWebId, LionWebJsonMetaPointer, LionWebJsonNode } from "@lionweb/json"
1
+ import { LionWebId, LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js"
2
2
  import { CompositeLionWebLanguageWrapper } from "./CompositeLionWebLanguageWrapper.js"
3
3
  import { LionWebLanguageWrapper } from "./LionWebLanguageWrapper.js"
4
4
 
@@ -1,11 +1,11 @@
1
- import { isEqualMetaPointer, LionWebJsonChunk, LionWebJsonNode } from "@lionweb/json"
2
- import { LION_CORE_M3_KEY, MetaPointers } from "@lionweb/json-utils"
1
+ import { isEqualMetaPointer, LionWebJsonNode, LionWebJsonChunk } from "../json/LionWebJson.js"
2
+ import { LION_CORE_M3_KEY, MetaPointers } from "../json/M3definitions.js"
3
3
 
4
- import { createRequire } from "module"
4
+ import { createRequire } from 'module';
5
5
 
6
- const require = createRequire(import.meta.url)
7
- const LionCore_M3 = require("./LionCore-M3.json")
8
- const LionCore_builtins = require("./LionCore-builtins.json")
6
+ const require = createRequire(import.meta.url);
7
+ const LionCore_M3 = require('./LionCore-M3.json');
8
+ const LionCore_builtins = require('./LionCore-builtins.json');
9
9
 
10
10
  export const LionCore_M3_Json = LionCore_M3 as LionWebJsonChunk
11
11
  export const LionCore_builtins_Json = LionCore_builtins as LionWebJsonChunk
@@ -1,6 +1,10 @@
1
- import { LionWebJsonChunk, LionWebJsonNode, LionWebKey } from "@lionweb/json"
2
- import { LionWebJsonChunkWrapper, MetaPointers, NodeUtils } from "@lionweb/json-utils"
3
- import { visitAndMap } from "@lionweb/ts-utils"
1
+ import {
2
+ LionWebJsonChunkWrapper,
3
+ MetaPointers,
4
+ NodeUtils
5
+ } from "../json/index.js"
6
+ import { LionWebJsonChunk, LionWebJsonNode } from "../json/LionWebJson.js"
7
+ import { visitAndMap } from "../util/graphs.js"
4
8
  import { isAnnotation, isConcept, isContainment, isInterface, isProperty, isReference } from "./LanguageUtils.js"
5
9
 
6
10
  interface LionWebLanguageWrapperInterface {
@@ -20,8 +24,8 @@ interface LionWebLanguageWrapperInterface {
20
24
  export class LionWebLanguageWrapper extends LionWebJsonChunkWrapper implements LionWebLanguageWrapperInterface {
21
25
  name: string
22
26
  version: string
23
- key: LionWebKey
24
-
27
+ key: string
28
+
25
29
  constructor(chunk: LionWebJsonChunk) {
26
30
  super(chunk)
27
31
  const languageNode: LionWebJsonNode = this.findNodesOfClassifier(MetaPointers.Language)[0]
@@ -1,13 +1,12 @@
1
- import { LionWebJsonMetaPointer, LionWebJsonNode, LionWebKey } from "@lionweb/json"
2
- import { MetaPointers, NodeUtils } from "@lionweb/json-utils"
1
+ import { LionWebJsonMetaPointer, LionWebJsonNode, MetaPointers, NodeUtils } from "../json/index.js"
3
2
 
4
3
  export class MetaPointerMap {
5
4
  /**
6
5
  * Map from languageKey => languageVersion => key => LionWebJsonNode
7
6
  */
8
7
  map: Map<string, Map<string, Map<string, LionWebJsonNode>>> = new Map<string, Map<string, Map<string, LionWebJsonNode>>>()
9
-
10
- add(languageKey: LionWebKey, languageVersion: string, node: LionWebJsonNode): void {
8
+
9
+ add(languageKey: string, languageVersion: string, node: LionWebJsonNode): void {
11
10
  const keyProperty = NodeUtils.findProperty(node, MetaPointers.IKeyedKey)
12
11
  if (keyProperty === undefined) {
13
12
  console.log("MetaPointerMap.add: trying to add node without key property.")
@@ -18,9 +17,9 @@ export class MetaPointerMap {
18
17
  console.log("MetaPointerMap.add: trying to add node without key property being empty or null.")
19
18
  return
20
19
  }
21
- this.set({ language: languageKey, version: languageVersion, key: key }, node)
20
+ this.set({language: languageKey, version: languageVersion, key: key}, node)
22
21
  }
23
-
22
+
24
23
  set(mp: LionWebJsonMetaPointer, node: LionWebJsonNode): void {
25
24
  let language = this.map.get(mp.language)
26
25
  if (language === undefined) {
@@ -34,7 +33,7 @@ export class MetaPointerMap {
34
33
  }
35
34
  version.set(mp.key, node)
36
35
  }
37
-
36
+
38
37
  get(mp: LionWebJsonMetaPointer): LionWebJsonNode | undefined {
39
38
  return this.map.get(mp.language)?.get(mp.version)?.get(mp.key)
40
39
  }
@@ -1,7 +1,7 @@
1
1
  import fs from "fs"
2
2
  import { LanguageRegistry } from "../languages/index.js"
3
- import { ValidationResult } from "../validators/generic/ValidationResult.js"
4
3
  import { LionWebValidator } from "../validators/LionWebValidator.js"
4
+ import { ValidationResult } from "../validators/generic/ValidationResult.js"
5
5
  import { getFilesRecursive, printIssues } from "./Utils.js"
6
6
 
7
7
  export function validateFile(file: string, registry: LanguageRegistry): void {
@@ -28,7 +28,7 @@ if (languageValidator.validationResult.hasErrors()) {
28
28
  for (const modelFile of getFilesRecursive(folder, [])) {
29
29
  const jsonString1 = fs.readFileSync(modelFile, "utf-8")
30
30
  const jsonModel = JSON.parse(jsonString1)
31
- const modelValidator = new LionWebValidator(jsonModel, registry)
31
+ const modelValidator = new LionWebValidator(jsonModel, registry )
32
32
 
33
33
  modelValidator.validateAll()
34
34
  if (modelValidator.validationResult.hasErrors()) {
@@ -1,6 +1,6 @@
1
- import { LionWebJsonChunk } from "@lionweb/json"
2
- import { LionWebJsonDiff } from "@lionweb/json-diff"
3
1
  import fs from "fs"
2
+ import { LionWebJsonDiff } from "../diff/index.js"
3
+ import { LionWebJsonChunk } from "../json/LionWebJson.js"
4
4
 
5
5
  const file1 = process.argv[2]
6
6
  const file2 = process.argv[3]
@@ -0,0 +1,36 @@
1
+ // NB This is an almost identical copy of packages/core/utils/recursion.ts
2
+ // Copied to avoid package dependencies
3
+ /**
4
+ * Type def. of a generic "flatMap" function.
5
+ */
6
+ export type ResultMapper<T, R> = (t: T) => R[]
7
+
8
+ /**
9
+ * Returns a function that performs a "flatMap" on a graph that's specified as a start vertex. and a function that computes (outgoing) edges.
10
+ * The "flatMap" is performed depth-first, and doesn't loop on cycles.
11
+ *
12
+ * @param mapper The function that calculates the result values
13
+ * @param nextVertices The function that calculates the next edges to visit.
14
+ * @returns A function that takes a starting vertex and resursively calculates the result values for each vertex visited.
15
+ */
16
+ export const visitAndMap =
17
+ <T, R>(mapper: ResultMapper<T, R>, nextVertices: (t: T) => T[]): ResultMapper<T, R> =>
18
+ (startVertex: T): R[] => {
19
+ const visited: T[] = []
20
+ const rs: R[] = []
21
+ const recurse = (t: T) => {
22
+ if (visited.indexOf(t) > -1) {
23
+ return
24
+ }
25
+ visited.push(t)
26
+ rs.push(...mapper(t))
27
+ nextVertices(t).forEach(recurse)
28
+ }
29
+ recurse(startVertex)
30
+ return rs
31
+ }
32
+
33
+ /**
34
+ * A mapper function that returns the node itself as result
35
+ */
36
+ export const selfMapper = <T>(t: T) => [t]
@@ -1,5 +1,10 @@
1
- import { MAY_BE_NULL, PrimitiveDef, PropertyDef, TypeDefinition } from "./generic/ValidationTypes.js"
2
- import { validateId, validateKey, validateSerializationFormatVersion, validateVersion } from "./ValidationFunctions.js"
1
+ import {
2
+ validateId,
3
+ validateKey,
4
+ validateSerializationFormatVersion,
5
+ validateVersion
6
+ } from "./ValidationFunctions.js"
7
+ import { MAY_BE_NULL, PropertyDef, PropertyDefinition } from "./generic/ValidationTypes.js"
3
8
 
4
9
  /**
5
10
  * The structure below defines the structure of a LionWeb Chunk by defining all the properties.
@@ -7,13 +12,13 @@ import { validateId, validateKey, validateSerializationFormatVersion, validateVe
7
12
  * - be fed to the SyntaxValidator to validate an object sat runtime.
8
13
  * - used to generate all the types for a LionWebChunk.
9
14
  */
10
- export const expectedTypes: Map<string, TypeDefinition> = new Map<string, TypeDefinition>([
15
+ export const expectedTypes: Map<string, PropertyDefinition[]> = new Map([
11
16
  [
12
17
  "LionWebMetaPointer",
13
18
  [
14
- PropertyDef({ property: "key", expectedType: "LionWebKey" }),
15
- PropertyDef({ property: "version", expectedType: "LionWebVersion" }),
16
- PropertyDef({ property: "language", expectedType: "LionWebKey" })
19
+ PropertyDef({ property: "key", expectedType: "string", validate: validateKey }),
20
+ PropertyDef({ property: "version", expectedType: "string", validate: validateVersion }),
21
+ PropertyDef({ property: "language", expectedType: "string", validate: validateKey })
17
22
  ]
18
23
  ],
19
24
  [
@@ -21,13 +26,13 @@ export const expectedTypes: Map<string, TypeDefinition> = new Map<string, TypeDe
21
26
  [
22
27
  PropertyDef({ property: "kind", expectedType: "string" }),
23
28
  PropertyDef({ property: "message", expectedType: "string" }),
24
- PropertyDef({ property: "data", expectedType: "object", mayBeNull: true, isOptional: true })
29
+ PropertyDef({ property: "data", expectedType: "object", mayBeNull: true })
25
30
  ]
26
31
  ],
27
32
  [
28
33
  "LionWebChunk",
29
34
  [
30
- PropertyDef({ property: "serializationFormatVersion", expectedType: "LionWebSerializationFormatVersion" }),
35
+ PropertyDef({ property: "serializationFormatVersion", expectedType: "string", validate: validateSerializationFormatVersion }),
31
36
  PropertyDef({ property: "languages", expectedType: "LionWebUsedLanguage", isList: true }),
32
37
  PropertyDef({ property: "nodes", expectedType: "LionWebNode", isList: true })
33
38
  ]
@@ -35,20 +40,20 @@ export const expectedTypes: Map<string, TypeDefinition> = new Map<string, TypeDe
35
40
  [
36
41
  "LionWebUsedLanguage",
37
42
  [
38
- PropertyDef({ property: "key", expectedType: "LionWebKey" }),
39
- PropertyDef({ property: "version", expectedType: "LionWebVersion" })
43
+ PropertyDef({ property: "key", expectedType: "string", validate: validateKey }),
44
+ PropertyDef({ property: "version", expectedType: "string", validate: validateVersion })
40
45
  ]
41
46
  ],
42
47
  [
43
48
  "LionWebNode",
44
49
  [
45
- PropertyDef({ property: "id", expectedType: "LionWebId" }),
50
+ PropertyDef({ property: "id", expectedType: "string", validate: validateId }),
46
51
  PropertyDef({ property: "classifier", expectedType: "LionWebMetaPointer" }),
47
52
  PropertyDef({ property: "properties", expectedType: "LionWebProperty", isList: true }),
48
53
  PropertyDef({ property: "containments", expectedType: "LionWebContainment", isList: true }),
49
54
  PropertyDef({ property: "references", expectedType: "LionWebReference", isList: true }),
50
- PropertyDef({ property: "annotations", expectedType: "LionWebId", isList: true }),
51
- PropertyDef({ property: "parent", expectedType: "LionWebId", mayBeNull: MAY_BE_NULL }),
55
+ PropertyDef({ property: "annotations", expectedType: "string", isList: true, validate: validateId }),
56
+ PropertyDef({ property: "parent", expectedType: "string", mayBeNull: MAY_BE_NULL, validate: validateId }),
52
57
  ]
53
58
  ],
54
59
  [
@@ -62,7 +67,7 @@ export const expectedTypes: Map<string, TypeDefinition> = new Map<string, TypeDe
62
67
  "LionWebContainment",
63
68
  [
64
69
  PropertyDef({ property: "containment", expectedType: "LionWebMetaPointer" }),
65
- PropertyDef({ property: "children", expectedType: "LionWebId", isList: true }),
70
+ PropertyDef({ property: "children", expectedType: "string", isList: true, validate: validateId }),
66
71
  ]
67
72
  ],
68
73
  [
@@ -76,37 +81,24 @@ export const expectedTypes: Map<string, TypeDefinition> = new Map<string, TypeDe
76
81
  "LionWebReferenceTarget",
77
82
  [
78
83
  PropertyDef({ property: "resolveInfo", expectedType: "string", mayBeNull: MAY_BE_NULL }),
79
- PropertyDef({ property: "reference", expectedType: "LionWebId", mayBeNull: MAY_BE_NULL }),
84
+ PropertyDef({ property: "reference", expectedType: "string", mayBeNull: MAY_BE_NULL, validate: validateId }),
80
85
  ]
81
86
  ],
82
87
  /**
83
- * Elements without properties are assumed to be JSON/JS primitive values, and tested using `typeof`
84
- * and the (optional) validate function.
88
+ * Elements without properties are assumed to be JSON/JS primitive values, and tested using `typeof`.
85
89
  */
86
90
  [
87
- "LionWebId",
88
- PrimitiveDef({ primitiveType: "string", validate: validateId }),
89
- ],
90
- [
91
- "LionWebKey",
92
- PrimitiveDef({ primitiveType: "string", validate: validateKey }),
93
- ],
94
- [
95
- "LionWebVersion",
96
- PrimitiveDef({ primitiveType: "string", validate: validateVersion }),
91
+ "string",
92
+ []
97
93
  ],
98
94
  [
99
- "LionWebSerializationFormatVersion",
100
- PrimitiveDef({ primitiveType: "string", validate: validateSerializationFormatVersion }),
95
+ "number",
96
+ []
101
97
  ],
102
98
  [
103
- "string",
104
- PrimitiveDef({ primitiveType: "string" }),
99
+ "boolean",
100
+ []
105
101
  ],
106
- [
107
- "object",
108
- PrimitiveDef({ primitiveType: "object" }),
109
- ]
110
102
  ])
111
103
 
112
104
 
@@ -1,35 +1,37 @@
1
- import { isEqualMetaPointer, LionWebJsonContainment, LionWebJsonNode, LionWebJsonProperty, LionWebJsonReference } from "@lionweb/json"
2
- import {
3
- JsonContext,
4
- LION_CORE_BUILTINS_INAMED_NAME,
5
- LIONWEB_BOOLEAN_TYPE, LIONWEB_INTEGER_TYPE, LIONWEB_JSON_TYPE, LIONWEB_STRING_TYPE,
6
- LionWebJsonChunkWrapper,
7
- M3_Keys,
8
- MetaPointers,
9
- NodeUtils
10
- } from "@lionweb/json-utils"
11
1
  import {
12
2
  Language_ContainmentMetaPointerNotInClass_Issue,
13
- Language_IncorrectPropertyMetaPointer_Issue,
14
- Language_PropertyMetaPointerNotInClass_Issue,
15
- Language_PropertyValue_Issue,
16
- Language_ReferenceMetaPointerNotInClass_Issue,
3
+ Language_IncorrectPropertyMetaPointer_Issue, Language_PropertyMetaPointerNotInClass_Issue,
4
+ Language_PropertyValue_Issue, Language_ReferenceMetaPointerNotInClass_Issue,
17
5
  Language_UnknownConcept_Issue
18
6
  } from "../issues/index.js"
19
7
  import {
20
8
  Language_IncorrectContainmentMetaPointer_Issue,
21
9
  Language_IncorrectReferenceMetaPointer_Issue,
22
- Language_UnknownContainment_Issue,
23
- Language_UnknownProperty_Issue,
10
+ Language_UnknownContainment_Issue, Language_UnknownProperty_Issue,
24
11
  Language_UnknownReference_Issue
25
12
  } from "../issues/LanguageIssues.js"
13
+ import { isEqualMetaPointer, LionWebJsonNode, MetaPointers, NodeUtils } from "../json/index.js"
14
+ import { JsonContext } from "../json/JsonContext.js"
15
+ import {
16
+ LionWebJsonContainment,
17
+ LionWebJsonProperty,
18
+ LionWebJsonReference,
19
+ } from "../json/LionWebJson.js"
20
+ import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js"
26
21
  // import {
27
22
  // KnownLanguages, LanguageRegistry
28
23
  // } from "../languages/LanguageRegistry.js"
24
+ import {
25
+ LION_CORE_BUILTINS_INAMED_NAME,
26
+ LIONWEB_BOOLEAN_TYPE,
27
+ LIONWEB_INTEGER_TYPE,
28
+ LIONWEB_JSON_TYPE,
29
+ LIONWEB_STRING_TYPE,
30
+ M3_Keys
31
+ } from "../json/M3definitions.js"
29
32
  import { LanguageRegistry } from "../languages/index.js"
30
- import { ValidationResult } from "./generic/ValidationResult.js"
31
33
  import { validateBoolean, validateInteger, validateJSON } from "./ValidationFunctions.js"
32
-
34
+ import { ValidationResult } from "./generic/ValidationResult.js"
33
35
 
34
36
  /**
35
37
  * Check against the language definition
@@ -1,7 +1,9 @@
1
- import { isEqualMetaPointer, LionWebJsonChunk, LionWebJsonNode } from "@lionweb/json"
2
- import { isLionWebM3Language, JsonContext, LionWebJsonChunkWrapper, MetaPointers } from "@lionweb/json-utils"
3
1
  import { GenericIssue } from "../issues/index.js"
4
2
  import { MissingM3Language_Issue } from "../issues/LanguageIssues.js"
3
+ import { isEqualMetaPointer, LionWebJsonNode, MetaPointers } from "../json/index.js"
4
+ import { JsonContext } from "../json/JsonContext.js"
5
+ import { isLionWebM3Language, LionWebJsonChunk } from "../json/LionWebJson.js"
6
+ import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js"
5
7
  import { isConcept, LanguageRegistry } from "../languages/index.js"
6
8
  import { ValidationResult } from "./generic/ValidationResult.js"
7
9