@lionweb/validation 0.6.13-beta.7 → 0.7.0-beta.0

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/index.d.ts +0 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/issues/LanguageIssues.d.ts +4 -4
  6. package/dist/issues/LanguageIssues.d.ts.map +1 -1
  7. package/dist/issues/LanguageIssues.js +1 -1
  8. package/dist/issues/LanguageIssues.js.map +1 -1
  9. package/dist/issues/ReferenceIssues.d.ts +6 -6
  10. package/dist/issues/ReferenceIssues.d.ts.map +1 -1
  11. package/dist/issues/ReferenceIssues.js +3 -3
  12. package/dist/issues/ReferenceIssues.js.map +1 -1
  13. package/dist/issues/SyntaxIssues.d.ts +1 -1
  14. package/dist/issues/SyntaxIssues.d.ts.map +1 -1
  15. package/dist/issues/ValidationIssue.d.ts +1 -1
  16. package/dist/issues/ValidationIssue.d.ts.map +1 -1
  17. package/dist/issues/ValidationIssue.js.map +1 -1
  18. package/dist/issues/index.d.ts +0 -1
  19. package/dist/issues/index.d.ts.map +1 -1
  20. package/dist/issues/index.js +0 -1
  21. package/dist/issues/index.js.map +1 -1
  22. package/dist/languages/CompositeLionWebLanguageWrapper.d.ts +1 -1
  23. package/dist/languages/CompositeLionWebLanguageWrapper.d.ts.map +1 -1
  24. package/dist/languages/LanguageRegistry.d.ts +1 -1
  25. package/dist/languages/LanguageRegistry.d.ts.map +1 -1
  26. package/dist/languages/LanguageUtils.d.ts +1 -1
  27. package/dist/languages/LanguageUtils.d.ts.map +1 -1
  28. package/dist/languages/LanguageUtils.js +5 -5
  29. package/dist/languages/LanguageUtils.js.map +1 -1
  30. package/dist/languages/LionWebLanguageWrapper.d.ts +3 -3
  31. package/dist/languages/LionWebLanguageWrapper.d.ts.map +1 -1
  32. package/dist/languages/LionWebLanguageWrapper.js +2 -2
  33. package/dist/languages/LionWebLanguageWrapper.js.map +1 -1
  34. package/dist/languages/MetaPointerMap.d.ts +2 -2
  35. package/dist/languages/MetaPointerMap.d.ts.map +1 -1
  36. package/dist/languages/MetaPointerMap.js +1 -1
  37. package/dist/languages/MetaPointerMap.js.map +1 -1
  38. package/dist/runners/FileUtils.d.ts.map +1 -1
  39. package/dist/runners/FileUtils.js +1 -1
  40. package/dist/runners/FileUtils.js.map +1 -1
  41. package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
  42. package/dist/runners/RunLioncoreDiff.js +1 -1
  43. package/dist/runners/RunLioncoreDiff.js.map +1 -1
  44. package/dist/validators/LionWebChunkDefinitions.d.ts +2 -2
  45. package/dist/validators/LionWebChunkDefinitions.d.ts.map +1 -1
  46. package/dist/validators/LionWebChunkDefinitions.js +33 -20
  47. package/dist/validators/LionWebChunkDefinitions.js.map +1 -1
  48. package/dist/validators/LionWebLanguageReferenceValidator.d.ts +2 -4
  49. package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
  50. package/dist/validators/LionWebLanguageReferenceValidator.js +2 -6
  51. package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
  52. package/dist/validators/LionWebLanguageValidator.d.ts +2 -3
  53. package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
  54. package/dist/validators/LionWebLanguageValidator.js +2 -4
  55. package/dist/validators/LionWebLanguageValidator.js.map +1 -1
  56. package/dist/validators/LionWebReferenceValidator.d.ts +3 -4
  57. package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
  58. package/dist/validators/LionWebReferenceValidator.js +2 -3
  59. package/dist/validators/LionWebReferenceValidator.js.map +1 -1
  60. package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
  61. package/dist/validators/LionWebSyntaxValidator.js +1 -1
  62. package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
  63. package/dist/validators/LionWebValidator.d.ts +1 -1
  64. package/dist/validators/LionWebValidator.d.ts.map +1 -1
  65. package/dist/validators/LionWebValidator.js +2 -2
  66. package/dist/validators/LionWebValidator.js.map +1 -1
  67. package/dist/validators/ValidationFunctions.d.ts +5 -1
  68. package/dist/validators/ValidationFunctions.d.ts.map +1 -1
  69. package/dist/validators/ValidationFunctions.js +0 -4
  70. package/dist/validators/ValidationFunctions.js.map +1 -1
  71. package/dist/validators/generic/SyntaxValidator.d.ts +9 -9
  72. package/dist/validators/generic/SyntaxValidator.d.ts.map +1 -1
  73. package/dist/validators/generic/SyntaxValidator.js +61 -58
  74. package/dist/validators/generic/SyntaxValidator.js.map +1 -1
  75. package/dist/validators/generic/ValidationTypes.d.ts +25 -1
  76. package/dist/validators/generic/ValidationTypes.d.ts.map +1 -1
  77. package/dist/validators/generic/ValidationTypes.js +20 -1
  78. package/dist/validators/generic/ValidationTypes.js.map +1 -1
  79. package/dist/validators/generic/index.d.ts +0 -1
  80. package/dist/validators/generic/index.d.ts.map +1 -1
  81. package/dist/validators/generic/index.js +0 -1
  82. package/dist/validators/generic/index.js.map +1 -1
  83. package/dist/validators/index.d.ts +0 -1
  84. package/dist/validators/index.d.ts.map +1 -1
  85. package/dist/validators/index.js +0 -1
  86. package/dist/validators/index.js.map +1 -1
  87. package/package.json +9 -4
  88. package/src/index.ts +0 -3
  89. package/src/issues/LanguageIssues.ts +12 -14
  90. package/src/issues/ReferenceIssues.ts +9 -9
  91. package/src/issues/SyntaxIssues.ts +5 -5
  92. package/src/issues/ValidationIssue.ts +7 -4
  93. package/src/issues/index.ts +0 -1
  94. package/src/languages/CompositeLionWebLanguageWrapper.ts +1 -1
  95. package/src/languages/LanguageRegistry.ts +1 -1
  96. package/src/languages/LanguageUtils.ts +6 -6
  97. package/src/languages/LionWebLanguageWrapper.ts +5 -9
  98. package/src/languages/MetaPointerMap.ts +7 -6
  99. package/src/runners/FileUtils.ts +1 -1
  100. package/src/runners/RunCheckFolderWithLanguage.ts +1 -1
  101. package/src/runners/RunLioncoreDiff.ts +2 -2
  102. package/src/validators/LionWebChunkDefinitions.ts +35 -27
  103. package/src/validators/LionWebLanguageReferenceValidator.ts +18 -20
  104. package/src/validators/LionWebLanguageValidator.ts +2 -4
  105. package/src/validators/LionWebReferenceValidator.ts +6 -14
  106. package/src/validators/LionWebSyntaxValidator.ts +1 -1
  107. package/src/validators/LionWebValidator.ts +3 -3
  108. package/src/validators/ValidationFunctions.ts +1 -1
  109. package/src/validators/generic/SyntaxValidator.ts +98 -91
  110. package/src/validators/generic/ValidationTypes.ts +41 -4
  111. package/src/validators/generic/index.ts +0 -1
  112. package/src/validators/index.ts +0 -1
  113. package/dist/diff/DiffResult.d.ts +0 -9
  114. package/dist/diff/DiffResult.d.ts.map +0 -1
  115. package/dist/diff/DiffResult.js +0 -18
  116. package/dist/diff/DiffResult.js.map +0 -1
  117. package/dist/diff/LionWebJsonDiff.d.ts +0 -25
  118. package/dist/diff/LionWebJsonDiff.d.ts.map +0 -1
  119. package/dist/diff/LionWebJsonDiff.js +0 -249
  120. package/dist/diff/LionWebJsonDiff.js.map +0 -1
  121. package/dist/diff/changes/Change.d.ts +0 -34
  122. package/dist/diff/changes/Change.d.ts.map +0 -1
  123. package/dist/diff/changes/Change.js +0 -38
  124. package/dist/diff/changes/Change.js.map +0 -1
  125. package/dist/diff/changes/ChunkChange.d.ts +0 -43
  126. package/dist/diff/changes/ChunkChange.d.ts.map +0 -1
  127. package/dist/diff/changes/ChunkChange.js +0 -57
  128. package/dist/diff/changes/ChunkChange.js.map +0 -1
  129. package/dist/diff/changes/ContainmentChange.d.ts +0 -25
  130. package/dist/diff/changes/ContainmentChange.d.ts.map +0 -1
  131. package/dist/diff/changes/ContainmentChange.js +0 -34
  132. package/dist/diff/changes/ContainmentChange.js.map +0 -1
  133. package/dist/diff/changes/NodeChange.d.ts +0 -41
  134. package/dist/diff/changes/NodeChange.d.ts.map +0 -1
  135. package/dist/diff/changes/NodeChange.js +0 -54
  136. package/dist/diff/changes/NodeChange.js.map +0 -1
  137. package/dist/diff/changes/PropertyChange.d.ts +0 -24
  138. package/dist/diff/changes/PropertyChange.d.ts.map +0 -1
  139. package/dist/diff/changes/PropertyChange.js +0 -29
  140. package/dist/diff/changes/PropertyChange.js.map +0 -1
  141. package/dist/diff/changes/ReferenceChange.d.ts +0 -25
  142. package/dist/diff/changes/ReferenceChange.d.ts.map +0 -1
  143. package/dist/diff/changes/ReferenceChange.js +0 -34
  144. package/dist/diff/changes/ReferenceChange.js.map +0 -1
  145. package/dist/diff/changes/index.d.ts +0 -7
  146. package/dist/diff/changes/index.d.ts.map +0 -1
  147. package/dist/diff/changes/index.js +0 -7
  148. package/dist/diff/changes/index.js.map +0 -1
  149. package/dist/diff/index.d.ts +0 -4
  150. package/dist/diff/index.d.ts.map +0 -1
  151. package/dist/diff/index.js +0 -4
  152. package/dist/diff/index.js.map +0 -1
  153. package/dist/json/ChunkUtils.d.ts +0 -26
  154. package/dist/json/ChunkUtils.d.ts.map +0 -1
  155. package/dist/json/ChunkUtils.js +0 -46
  156. package/dist/json/ChunkUtils.js.map +0 -1
  157. package/dist/json/JsonContext.d.ts +0 -11
  158. package/dist/json/JsonContext.d.ts.map +0 -1
  159. package/dist/json/JsonContext.js +0 -25
  160. package/dist/json/JsonContext.js.map +0 -1
  161. package/dist/json/LionWebJson.d.ts +0 -50
  162. package/dist/json/LionWebJson.d.ts.map +0 -1
  163. package/dist/json/LionWebJson.js +0 -27
  164. package/dist/json/LionWebJson.js.map +0 -1
  165. package/dist/json/LionWebJsonChunkWrapper.d.ts +0 -39
  166. package/dist/json/LionWebJsonChunkWrapper.d.ts.map +0 -1
  167. package/dist/json/LionWebJsonChunkWrapper.js +0 -119
  168. package/dist/json/LionWebJsonChunkWrapper.js.map +0 -1
  169. package/dist/json/M3definitions.d.ts +0 -176
  170. package/dist/json/M3definitions.d.ts.map +0 -1
  171. package/dist/json/M3definitions.js +0 -174
  172. package/dist/json/M3definitions.js.map +0 -1
  173. package/dist/json/NodeUtils.d.ts +0 -23
  174. package/dist/json/NodeUtils.d.ts.map +0 -1
  175. package/dist/json/NodeUtils.js +0 -57
  176. package/dist/json/NodeUtils.js.map +0 -1
  177. package/dist/json/index.d.ts +0 -7
  178. package/dist/json/index.d.ts.map +0 -1
  179. package/dist/json/index.js +0 -7
  180. package/dist/json/index.js.map +0 -1
  181. package/dist/util/graphs.d.ts +0 -18
  182. package/dist/util/graphs.d.ts.map +0 -1
  183. package/dist/util/graphs.js +0 -27
  184. package/dist/util/graphs.js.map +0 -1
  185. package/src/diff/DiffResult.ts +0 -21
  186. package/src/diff/LionWebJsonDiff.ts +0 -309
  187. package/src/diff/changes/Change.ts +0 -76
  188. package/src/diff/changes/ChunkChange.ts +0 -68
  189. package/src/diff/changes/ContainmentChange.ts +0 -32
  190. package/src/diff/changes/NodeChange.ts +0 -63
  191. package/src/diff/changes/PropertyChange.ts +0 -31
  192. package/src/diff/changes/ReferenceChange.ts +0 -34
  193. package/src/diff/changes/index.ts +0 -6
  194. package/src/diff/index.ts +0 -3
  195. package/src/json/ChunkUtils.ts +0 -49
  196. package/src/json/JsonContext.ts +0 -31
  197. package/src/json/LionWebJson.ts +0 -80
  198. package/src/json/LionWebJsonChunkWrapper.ts +0 -136
  199. package/src/json/M3definitions.ts +0 -177
  200. package/src/json/NodeUtils.ts +0 -75
  201. package/src/json/index.ts +0 -6
  202. package/src/util/graphs.ts +0 -36
@@ -1,49 +0,0 @@
1
- import { LionWebJsonChunk, LionWebJsonNode, LwJsonUsedLanguage } from "./LionWebJson.js"
2
-
3
- /**
4
- * Utility functions for LionWeb chunks
5
- */
6
- export class ChunkUtils {
7
- /**
8
- * Find a used language in `chunk` with `key`.
9
- * @param chunk
10
- * @param key
11
- */
12
- static findLwUsedLanguage(chunk: LionWebJsonChunk, key: string): LwJsonUsedLanguage | null {
13
- for (const language of chunk.languages) {
14
- if (language.key === key) {
15
- return language
16
- }
17
- }
18
- return null
19
- }
20
-
21
- /**
22
- * Find a used language in `chunk` with `key` and 'version'.
23
- * @param chunk
24
- * @param key
25
- * @param version
26
- */
27
- static findLwUsedLanguageWithVersion(chunk: LionWebJsonChunk, key: string, version: string): LwJsonUsedLanguage | null {
28
- for (const language of chunk.languages) {
29
- if (language.key === key && language.version === version) {
30
- return language
31
- }
32
- }
33
- return null
34
- }
35
-
36
- /**
37
- * Find node with id equals `id` in `chunk`.
38
- * @param chunk
39
- * @param id
40
- */
41
- static findNode(chunk: LionWebJsonChunk, id: string): LionWebJsonNode | null {
42
- for (const node of chunk.nodes) {
43
- if (node.id === id) {
44
- return node
45
- }
46
- }
47
- return null
48
- }
49
- }
@@ -1,31 +0,0 @@
1
- type JsonPath = (string | number)[]
2
-
3
- export class JsonContext {
4
- private parent: JsonContext | null
5
- private local_path: JsonPath
6
-
7
- concat(...items: JsonPath): JsonContext {
8
- return new JsonContext(this, items)
9
- }
10
-
11
- path(): JsonPath {
12
- return this.parent === null ? this.local_path : this.parent.path().concat(this.local_path)
13
- }
14
-
15
- constructor(parent: JsonContext | null, path: JsonPath) {
16
- this.parent = parent
17
- this.local_path = path
18
- }
19
-
20
- toString(): string {
21
- let result = ""
22
- this.path().forEach((part, index) => {
23
- if (typeof part === "string") {
24
- result += (index === 0 ? "" : ".") + part
25
- } else if (typeof part === "number") {
26
- result += "[" + part + "]"
27
- }
28
- })
29
- return result
30
- }
31
- }
@@ -1,80 +0,0 @@
1
- import { LION_CORE_M3_KEY, LION_CORE_M3_VERSION } from "./M3definitions.js"
2
-
3
- /**
4
- * The types defining the structure of the LionWeb JSON format.
5
- * @see https://lionweb-io.github.io/specification/serialization/serialization.html
6
- * We use types instead of classes, because the purpose is to define the Lionweb JSON to be sent over the line.
7
- */
8
-
9
-
10
- export function isLionWebM3Language(language: LwJsonUsedLanguage): boolean {
11
- return language.key === LION_CORE_M3_KEY && language.version === LION_CORE_M3_VERSION
12
- }
13
- export type LionWebId = string
14
-
15
- export type LionWebJsonMetaPointer = {
16
- language: string
17
- version: string
18
- key: string // key of concept, property, containment, referenve or property
19
- }
20
-
21
- export function isEqualMetaPointer(p1: LionWebJsonMetaPointer, p2: LionWebJsonMetaPointer): boolean {
22
- return p1.key === p2.key && p1.version === p2.version && p1.language === p2.language
23
- }
24
-
25
- export function isEqualReferenceTarget(first: LionWebJsonReferenceTarget, second: LionWebJsonReferenceTarget): boolean {
26
- return first.reference === second.reference && first.resolveInfo === second.resolveInfo
27
- }
28
-
29
- export type LionWebJsonChunk = {
30
- serializationFormatVersion: string
31
- languages: LwJsonUsedLanguage[]
32
- nodes: LionWebJsonNode[]
33
- }
34
-
35
- export type LwJsonUsedLanguage = {
36
- key: string
37
- version: string
38
- }
39
-
40
- export type LionWebJsonNode = {
41
- id: LionWebId
42
- classifier: LionWebJsonMetaPointer
43
- properties: LionWebJsonProperty[]
44
- containments: LionWebJsonContainment[]
45
- references: LionWebJsonReference[]
46
- annotations: LionWebId[]
47
- parent: (LionWebId | null)
48
- }
49
-
50
- export function createLwNode(): LionWebJsonNode {
51
- return {
52
- id: "",
53
- classifier: { language: "", version: "", key: "" },
54
- properties: [],
55
- containments: [],
56
- references: [],
57
- annotations: [],
58
- parent: null,
59
- }
60
- }
61
-
62
- export type LionWebJsonProperty = {
63
- property: LionWebJsonMetaPointer
64
- value: (string | null)
65
- }
66
-
67
- export type LionWebJsonContainment = {
68
- containment: LionWebJsonMetaPointer
69
- children: LionWebId[]
70
- }
71
-
72
- export type LionWebJsonReference = {
73
- reference: LionWebJsonMetaPointer
74
- targets: LionWebJsonReferenceTarget[]
75
- }
76
-
77
- export type LionWebJsonReferenceTarget = {
78
- resolveInfo: (string | null)
79
- reference: LionWebId
80
- }
@@ -1,136 +0,0 @@
1
- import {
2
- isEqualMetaPointer,
3
- LionWebId,
4
- LionWebJsonChunk,
5
- LionWebJsonContainment,
6
- LionWebJsonMetaPointer,
7
- LionWebJsonNode,
8
- LionWebJsonReference
9
- } from "./LionWebJson.js"
10
- import { MetaPointers } from "./M3definitions.js"
11
- import { NodeUtils } from "./NodeUtils.js"
12
-
13
- /**
14
- * Wraps around a LionWebJsonChunk, providing access to information inside, might be using caches to improve performance.
15
- * NB Make sure that the contents of the chunk are not changed after creating the wrapper!
16
- * NB BE aware that with `pushChunk(...)` the original chunk will be changed.
17
- */
18
- export class LionWebJsonChunkWrapper {
19
- jsonChunk: LionWebJsonChunk
20
- /**
21
- * Map to get quick access to nodes by id.
22
- * @protected
23
- */
24
- protected nodesIdMap: Map<LionWebId, LionWebJsonNode> = new Map<LionWebId, LionWebJsonNode>()
25
-
26
- /**
27
- * Create a wrapper with `chunk` as its chunk
28
- * @param chunk
29
- */
30
- constructor(chunk: LionWebJsonChunk) {
31
- this.jsonChunk = chunk
32
- this.prepareNodeIds(chunk)
33
- }
34
-
35
- /** Put all nodes in a map, validate that there are no two nodes with the same id.
36
- * The check should logically be in LionWebReferenceValidator, but the created map is needed here.
37
- */
38
- prepareNodeIds(chunk: LionWebJsonChunk) {
39
- chunk.nodes.forEach(node => {
40
- this.nodesIdMap.set(node.id, node)
41
- })
42
- }
43
-
44
- getNode(id: string): LionWebJsonNode | undefined {
45
- return this.nodesIdMap.get(id)
46
- }
47
-
48
- findNodesOfClassifier(concept: LionWebJsonMetaPointer): LionWebJsonNode[] {
49
- return this.jsonChunk.nodes.filter(node => isEqualMetaPointer(node.classifier, concept))
50
- }
51
-
52
- /**
53
- * Return the target nodes inside `reference` as a list of actual nodes (LionWebJsonNode[])
54
- * @param reference
55
- */
56
- getReferredNodes(reference: LionWebJsonReference | undefined) {
57
- if (reference === undefined) {
58
- return []
59
- }
60
- const result = reference.targets.flatMap(target => {
61
- if (target.reference === null) {
62
- return []
63
- } else {
64
- const referredNode = this.getNode(target.reference)
65
- return referredNode === undefined ? [] : [referredNode]
66
- }
67
- })
68
- return result
69
- }
70
-
71
- /**
72
- * Return the target nodes inside `reference` as a list of actual nodes (LionWebJsonNode[])
73
- * @param reference
74
- */
75
- getChildrenAsNodes(containment: LionWebJsonContainment | undefined) {
76
- if (containment === undefined) {
77
- return []
78
- }
79
- const result: LionWebJsonNode[] = []
80
- containment.children.forEach(ch => {
81
- const childNode = this.getNode(ch)
82
- if (childNode !== undefined) {
83
- result.push(childNode)
84
- }
85
- })
86
- return result
87
- }
88
-
89
- asString(): string {
90
- let result = ""
91
- const partitions = this.jsonChunk.nodes.filter(n => n.parent === null)
92
- partitions.forEach(partition => {
93
- const pString = this.recursiveToString(partition, 1)
94
- result += pString
95
- })
96
- return result
97
- }
98
-
99
- private recursiveToString(node: LionWebJsonNode | undefined, depth: number): string {
100
- if (node === undefined) {
101
- return ""
102
- }
103
- let result: string = ""
104
- const nameProperty = NodeUtils.findProperty(node, MetaPointers.INamedName)
105
- const name = nameProperty === undefined ? "" : " " + nameProperty.value
106
- result += this.indent(depth) + "(" + node.id + ")" + name + "\n"
107
- if (node.annotations !== undefined && node.annotations.length !== 0) {
108
- result += this.indent(depth + 1) + "*Annotations*" + "\n"
109
- node.annotations.forEach(ann => {
110
- result += this.recursiveToString(this.getNode(ann), depth + 1)
111
- // result += this.indent(depth) + "[[" + JSON.stringify(ann) + "]]\n"
112
- })
113
- }
114
- node.properties
115
- .filter(p => p !== nameProperty)
116
- .forEach(property => {
117
- result += this.indent(depth + 1) + "*property* " + property.property.key + ": " + property.value + "\n"
118
- })
119
- node.references.forEach(ref => {
120
- result += this.indent(depth + 1) + "*" + ref.reference.key + "*: " + JSON.stringify(ref.targets) + "\n"
121
- })
122
- node.containments.forEach(cont => {
123
- if (cont.children.length !== 0) {
124
- result += this.indent(depth + 1) + "*" + cont.containment.key + "*" + "\n"
125
- cont.children.forEach(ch => {
126
- result += this.recursiveToString(this.getNode(ch), depth + 1)
127
- })
128
- }
129
- })
130
- return result
131
- }
132
-
133
- private indent(depth: number): string {
134
- return Array(depth).join(" ")
135
- }
136
- }
@@ -1,177 +0,0 @@
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
- }
@@ -1,75 +0,0 @@
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
- }
package/src/json/index.ts DELETED
@@ -1,6 +0,0 @@
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,36 +0,0 @@
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]