@lionweb/validation 0.6.13-beta.7 → 0.7.0-alpha.10

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 (221) 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 +4 -4
  16. package/dist/issues/ValidationIssue.d.ts.map +1 -1
  17. package/dist/issues/ValidationIssue.js +1 -1
  18. package/dist/issues/ValidationIssue.js.map +1 -1
  19. package/dist/issues/index.d.ts +0 -1
  20. package/dist/issues/index.d.ts.map +1 -1
  21. package/dist/issues/index.js +0 -1
  22. package/dist/issues/index.js.map +1 -1
  23. package/dist/languages/CompositeLionWebLanguageWrapper.d.ts +1 -1
  24. package/dist/languages/CompositeLionWebLanguageWrapper.d.ts.map +1 -1
  25. package/dist/languages/LanguageRegistry.d.ts +1 -1
  26. package/dist/languages/LanguageRegistry.d.ts.map +1 -1
  27. package/dist/languages/LanguageUtils.d.ts +1 -1
  28. package/dist/languages/LanguageUtils.d.ts.map +1 -1
  29. package/dist/languages/LanguageUtils.js +5 -5
  30. package/dist/languages/LanguageUtils.js.map +1 -1
  31. package/dist/languages/LionWebLanguageWrapper.d.ts +3 -3
  32. package/dist/languages/LionWebLanguageWrapper.d.ts.map +1 -1
  33. package/dist/languages/LionWebLanguageWrapper.js +2 -2
  34. package/dist/languages/LionWebLanguageWrapper.js.map +1 -1
  35. package/dist/languages/MetaPointerMap.d.ts +2 -2
  36. package/dist/languages/MetaPointerMap.d.ts.map +1 -1
  37. package/dist/languages/MetaPointerMap.js +1 -1
  38. package/dist/languages/MetaPointerMap.js.map +1 -1
  39. package/dist/runners/FileUtils.d.ts.map +1 -1
  40. package/dist/runners/FileUtils.js +1 -1
  41. package/dist/runners/FileUtils.js.map +1 -1
  42. package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
  43. package/dist/runners/RunLioncoreDiff.js +1 -1
  44. package/dist/runners/RunLioncoreDiff.js.map +1 -1
  45. package/dist/runners/Utils.js +2 -2
  46. package/dist/runners/Utils.js.map +1 -1
  47. package/dist/validators/LionWebChunkDefinitions.d.ts +4 -4
  48. package/dist/validators/LionWebChunkDefinitions.d.ts.map +1 -1
  49. package/dist/validators/LionWebChunkDefinitions.js +82 -79
  50. package/dist/validators/LionWebChunkDefinitions.js.map +1 -1
  51. package/dist/validators/LionWebLanguageReferenceValidator.d.ts +2 -4
  52. package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
  53. package/dist/validators/LionWebLanguageReferenceValidator.js +2 -6
  54. package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
  55. package/dist/validators/LionWebLanguageValidator.d.ts +2 -3
  56. package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
  57. package/dist/validators/LionWebLanguageValidator.js +2 -4
  58. package/dist/validators/LionWebLanguageValidator.js.map +1 -1
  59. package/dist/validators/LionWebReferenceValidator.d.ts +3 -4
  60. package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
  61. package/dist/validators/LionWebReferenceValidator.js +2 -3
  62. package/dist/validators/LionWebReferenceValidator.js.map +1 -1
  63. package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
  64. package/dist/validators/LionWebSyntaxValidator.js +2 -2
  65. package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
  66. package/dist/validators/LionWebValidator.d.ts +1 -1
  67. package/dist/validators/LionWebValidator.d.ts.map +1 -1
  68. package/dist/validators/LionWebValidator.js +3 -3
  69. package/dist/validators/LionWebValidator.js.map +1 -1
  70. package/dist/validators/ValidationFunctions.d.ts +6 -2
  71. package/dist/validators/ValidationFunctions.d.ts.map +1 -1
  72. package/dist/validators/ValidationFunctions.js +4 -8
  73. package/dist/validators/ValidationFunctions.js.map +1 -1
  74. package/dist/validators/generic/SyntaxValidator.d.ts +11 -11
  75. package/dist/validators/generic/SyntaxValidator.d.ts.map +1 -1
  76. package/dist/validators/generic/SyntaxValidator.js +62 -64
  77. package/dist/validators/generic/SyntaxValidator.js.map +1 -1
  78. package/dist/validators/generic/index.d.ts +1 -2
  79. package/dist/validators/generic/index.d.ts.map +1 -1
  80. package/dist/validators/generic/index.js +1 -2
  81. package/dist/validators/generic/index.js.map +1 -1
  82. package/dist/validators/generic/schema/DefinitionSchema.d.ts +23 -0
  83. package/dist/validators/generic/schema/DefinitionSchema.d.ts.map +1 -0
  84. package/dist/validators/generic/schema/DefinitionSchema.js +43 -0
  85. package/dist/validators/generic/schema/DefinitionSchema.js.map +1 -0
  86. package/dist/validators/generic/schema/ValidationTypes.d.ts +101 -0
  87. package/dist/validators/generic/schema/ValidationTypes.d.ts.map +1 -0
  88. package/dist/validators/generic/schema/ValidationTypes.js +43 -0
  89. package/dist/validators/generic/schema/ValidationTypes.js.map +1 -0
  90. package/dist/validators/generic/schema/index.d.ts +3 -0
  91. package/dist/validators/generic/schema/index.d.ts.map +1 -0
  92. package/dist/validators/generic/schema/index.js +3 -0
  93. package/dist/validators/generic/schema/index.js.map +1 -0
  94. package/dist/validators/index.d.ts +0 -1
  95. package/dist/validators/index.d.ts.map +1 -1
  96. package/dist/validators/index.js +0 -1
  97. package/dist/validators/index.js.map +1 -1
  98. package/package.json +10 -4
  99. package/src/index.ts +0 -3
  100. package/src/issues/LanguageIssues.ts +12 -14
  101. package/src/issues/ReferenceIssues.ts +9 -9
  102. package/src/issues/SyntaxIssues.ts +5 -5
  103. package/src/issues/ValidationIssue.ts +10 -7
  104. package/src/issues/index.ts +0 -1
  105. package/src/languages/CompositeLionWebLanguageWrapper.ts +1 -1
  106. package/src/languages/LanguageRegistry.ts +1 -1
  107. package/src/languages/LanguageUtils.ts +6 -6
  108. package/src/languages/LionWebLanguageWrapper.ts +5 -9
  109. package/src/languages/MetaPointerMap.ts +7 -6
  110. package/src/runners/FileUtils.ts +1 -1
  111. package/src/runners/RunCheckFolderWithLanguage.ts +1 -1
  112. package/src/runners/RunLioncoreDiff.ts +2 -2
  113. package/src/runners/Utils.ts +2 -2
  114. package/src/validators/LionWebChunkDefinitions.ts +83 -85
  115. package/src/validators/LionWebLanguageReferenceValidator.ts +18 -20
  116. package/src/validators/LionWebLanguageValidator.ts +2 -4
  117. package/src/validators/LionWebReferenceValidator.ts +6 -14
  118. package/src/validators/LionWebSyntaxValidator.ts +2 -2
  119. package/src/validators/LionWebValidator.ts +4 -4
  120. package/src/validators/ValidationFunctions.ts +6 -6
  121. package/src/validators/generic/SyntaxValidator.ts +70 -69
  122. package/src/validators/generic/index.ts +1 -2
  123. package/src/validators/generic/schema/DefinitionSchema.ts +52 -0
  124. package/src/validators/generic/schema/ValidationTypes.ts +134 -0
  125. package/src/validators/generic/schema/index.ts +2 -0
  126. package/src/validators/index.ts +0 -1
  127. package/dist/diff/DiffResult.d.ts +0 -9
  128. package/dist/diff/DiffResult.d.ts.map +0 -1
  129. package/dist/diff/DiffResult.js +0 -18
  130. package/dist/diff/DiffResult.js.map +0 -1
  131. package/dist/diff/LionWebJsonDiff.d.ts +0 -25
  132. package/dist/diff/LionWebJsonDiff.d.ts.map +0 -1
  133. package/dist/diff/LionWebJsonDiff.js +0 -249
  134. package/dist/diff/LionWebJsonDiff.js.map +0 -1
  135. package/dist/diff/changes/Change.d.ts +0 -34
  136. package/dist/diff/changes/Change.d.ts.map +0 -1
  137. package/dist/diff/changes/Change.js +0 -38
  138. package/dist/diff/changes/Change.js.map +0 -1
  139. package/dist/diff/changes/ChunkChange.d.ts +0 -43
  140. package/dist/diff/changes/ChunkChange.d.ts.map +0 -1
  141. package/dist/diff/changes/ChunkChange.js +0 -57
  142. package/dist/diff/changes/ChunkChange.js.map +0 -1
  143. package/dist/diff/changes/ContainmentChange.d.ts +0 -25
  144. package/dist/diff/changes/ContainmentChange.d.ts.map +0 -1
  145. package/dist/diff/changes/ContainmentChange.js +0 -34
  146. package/dist/diff/changes/ContainmentChange.js.map +0 -1
  147. package/dist/diff/changes/NodeChange.d.ts +0 -41
  148. package/dist/diff/changes/NodeChange.d.ts.map +0 -1
  149. package/dist/diff/changes/NodeChange.js +0 -54
  150. package/dist/diff/changes/NodeChange.js.map +0 -1
  151. package/dist/diff/changes/PropertyChange.d.ts +0 -24
  152. package/dist/diff/changes/PropertyChange.d.ts.map +0 -1
  153. package/dist/diff/changes/PropertyChange.js +0 -29
  154. package/dist/diff/changes/PropertyChange.js.map +0 -1
  155. package/dist/diff/changes/ReferenceChange.d.ts +0 -25
  156. package/dist/diff/changes/ReferenceChange.d.ts.map +0 -1
  157. package/dist/diff/changes/ReferenceChange.js +0 -34
  158. package/dist/diff/changes/ReferenceChange.js.map +0 -1
  159. package/dist/diff/changes/index.d.ts +0 -7
  160. package/dist/diff/changes/index.d.ts.map +0 -1
  161. package/dist/diff/changes/index.js +0 -7
  162. package/dist/diff/changes/index.js.map +0 -1
  163. package/dist/diff/index.d.ts +0 -4
  164. package/dist/diff/index.d.ts.map +0 -1
  165. package/dist/diff/index.js +0 -4
  166. package/dist/diff/index.js.map +0 -1
  167. package/dist/json/ChunkUtils.d.ts +0 -26
  168. package/dist/json/ChunkUtils.d.ts.map +0 -1
  169. package/dist/json/ChunkUtils.js +0 -46
  170. package/dist/json/ChunkUtils.js.map +0 -1
  171. package/dist/json/JsonContext.d.ts +0 -11
  172. package/dist/json/JsonContext.d.ts.map +0 -1
  173. package/dist/json/JsonContext.js +0 -25
  174. package/dist/json/JsonContext.js.map +0 -1
  175. package/dist/json/LionWebJson.d.ts +0 -50
  176. package/dist/json/LionWebJson.d.ts.map +0 -1
  177. package/dist/json/LionWebJson.js +0 -27
  178. package/dist/json/LionWebJson.js.map +0 -1
  179. package/dist/json/LionWebJsonChunkWrapper.d.ts +0 -39
  180. package/dist/json/LionWebJsonChunkWrapper.d.ts.map +0 -1
  181. package/dist/json/LionWebJsonChunkWrapper.js +0 -119
  182. package/dist/json/LionWebJsonChunkWrapper.js.map +0 -1
  183. package/dist/json/M3definitions.d.ts +0 -176
  184. package/dist/json/M3definitions.d.ts.map +0 -1
  185. package/dist/json/M3definitions.js +0 -174
  186. package/dist/json/M3definitions.js.map +0 -1
  187. package/dist/json/NodeUtils.d.ts +0 -23
  188. package/dist/json/NodeUtils.d.ts.map +0 -1
  189. package/dist/json/NodeUtils.js +0 -57
  190. package/dist/json/NodeUtils.js.map +0 -1
  191. package/dist/json/index.d.ts +0 -7
  192. package/dist/json/index.d.ts.map +0 -1
  193. package/dist/json/index.js +0 -7
  194. package/dist/json/index.js.map +0 -1
  195. package/dist/util/graphs.d.ts +0 -18
  196. package/dist/util/graphs.d.ts.map +0 -1
  197. package/dist/util/graphs.js +0 -27
  198. package/dist/util/graphs.js.map +0 -1
  199. package/dist/validators/generic/ValidationTypes.d.ts +0 -44
  200. package/dist/validators/generic/ValidationTypes.d.ts.map +0 -1
  201. package/dist/validators/generic/ValidationTypes.js +0 -27
  202. package/dist/validators/generic/ValidationTypes.js.map +0 -1
  203. package/src/diff/DiffResult.ts +0 -21
  204. package/src/diff/LionWebJsonDiff.ts +0 -309
  205. package/src/diff/changes/Change.ts +0 -76
  206. package/src/diff/changes/ChunkChange.ts +0 -68
  207. package/src/diff/changes/ContainmentChange.ts +0 -32
  208. package/src/diff/changes/NodeChange.ts +0 -63
  209. package/src/diff/changes/PropertyChange.ts +0 -31
  210. package/src/diff/changes/ReferenceChange.ts +0 -34
  211. package/src/diff/changes/index.ts +0 -6
  212. package/src/diff/index.ts +0 -3
  213. package/src/json/ChunkUtils.ts +0 -49
  214. package/src/json/JsonContext.ts +0 -31
  215. package/src/json/LionWebJson.ts +0 -80
  216. package/src/json/LionWebJsonChunkWrapper.ts +0 -136
  217. package/src/json/M3definitions.ts +0 -177
  218. package/src/json/NodeUtils.ts +0 -75
  219. package/src/json/index.ts +0 -6
  220. package/src/util/graphs.ts +0 -36
  221. package/src/validators/generic/ValidationTypes.ts +0 -67
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lionweb/validation",
3
- "version": "0.6.13-beta.7",
3
+ "version": "0.7.0-alpha.10",
4
4
  "license": "Apache 2.0",
5
5
  "description": "LionWeb Serialization validation",
6
6
  "author": "jos.warmer@openmodeling.nl",
@@ -14,14 +14,15 @@
14
14
  "testing"
15
15
  ],
16
16
  "scripts": {
17
- "clean": "rm -rf dist/ lionweb-validation-*.tgz",
17
+ "clean": "npx rimraf dist node_modules -g lionweb-validation-*.tgz",
18
18
  "build": "tsc && npm run copyM3 && npm run copyBuiltins",
19
19
  "copyM3": "node -e \"const fs = require('fs'); fs.copyFileSync('./src/languages/LionCore-M3.json', './dist/languages/LionCore-M3.json');\"",
20
20
  "copyBuiltins": "node -e \"const fs = require('fs'); fs.copyFileSync('./src/languages/LionCore-builtins.json', './dist/languages/LionCore-builtins.json');\"",
21
21
  "lint": "eslint src",
22
22
  "test-here": "cd ../test && find dist/validation -type d | sed '1!G;h;$!d' | xargs npx mocha",
23
- "release": "npm publish",
24
- "release-beta": "npm publish --tag beta",
23
+ "release-alpha": "npm publish --registry https://registry.npmjs.org --tag alpha",
24
+ "release-beta": "npm publish --registry https://registry.npmjs.org --tag beta",
25
+ "release": "npm publish --registry https://registry.npmjs.org",
25
26
  "testValid": "node dist/runners/RunCheckFolder.js ../test/testset/valid",
26
27
  "testInvalid": "node dist/runners/RunCheckFolder.js ../test/testset/invalid",
27
28
  "testInvalidWithLanguage": "node dist/runners/RunCheckFolderWithLanguage.js ../test/testset/withLanguage/invalid/ ../test/testset/withLanguage/myLang.language.json",
@@ -29,5 +30,10 @@
29
30
  "publish-local": "npm publish --registry http://localhost:4873",
30
31
  "unpublish-local": "npm unpublish --force --registry http://localhost:4873",
31
32
  "republish-local": "yarn unpublish-local && yarn publish-local"
33
+ },
34
+ "dependencies": {
35
+ "@lionweb/json": "0.7.0-alpha.10",
36
+ "@lionweb/ts-utils": "0.7.0-alpha.10",
37
+ "@lionweb/json-utils": "0.7.0-alpha.10"
32
38
  }
33
39
  }
package/src/index.ts CHANGED
@@ -1,7 +1,4 @@
1
1
  export * from "./issues/index.js"
2
- export * from "./json/index.js"
3
2
  export * from "./validators/index.js"
4
- export * from "./diff/index.js"
5
3
  export * from "./runners/index.js"
6
4
  export * from "./languages/index.js"
7
- export * from "./util/graphs.js"
@@ -1,5 +1,5 @@
1
- import { LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js"
2
- import { JsonContext } from "../json/JsonContext.js"
1
+ import { LionWebJsonMetaPointer, LionWebJsonNode } from "@lionweb/json"
2
+ import { JsonContext } from "@lionweb/json-utils"
3
3
  import { ValidationIssue } from "./ValidationIssue.js"
4
4
 
5
5
  export class Language_PropertyValue_Issue extends ValidationIssue {
@@ -8,13 +8,13 @@ export class Language_PropertyValue_Issue extends ValidationIssue {
8
8
  constructor(
9
9
  context: JsonContext,
10
10
  public property: string,
11
- public value: (string | null),
12
- public expectedType: string,
11
+ public value: string | null,
12
+ public expectedType: string
13
13
  ) {
14
14
  super(context)
15
15
  }
16
16
 
17
- msg = (): string => `Property "${this.property}" with value "${this.value}" is not of type "${this.expectedType}"`
17
+ msg = (): string => `Property "${this.property}" with value "${this.value}" is not of type "${this.expectedType}"`
18
18
  }
19
19
 
20
20
  // Incorrect Meta Pointers
@@ -24,7 +24,7 @@ export abstract class Language_IncorrectMetaPointerType_Issue extends Validation
24
24
  constructor(
25
25
  context: JsonContext,
26
26
  public metaPointer: LionWebJsonMetaPointer,
27
- public incorrectType: string,
27
+ public incorrectType: string
28
28
  ) {
29
29
  super(context)
30
30
  }
@@ -43,7 +43,7 @@ export abstract class Language_FeatureMetaPointerNotInClassifier_Issue extends V
43
43
  constructor(
44
44
  context: JsonContext,
45
45
  public featureMetaPointer: LionWebJsonMetaPointer,
46
- public classifierPointer: LionWebJsonNode,
46
+ public classifierPointer: LionWebJsonNode
47
47
  ) {
48
48
  super(context)
49
49
  }
@@ -82,7 +82,7 @@ export abstract class Language_UnknownMetaPointer_Issue extends ValidationIssue
82
82
 
83
83
  constructor(
84
84
  context: JsonContext,
85
- public metaPointer: LionWebJsonMetaPointer,
85
+ public metaPointer: LionWebJsonMetaPointer
86
86
  ) {
87
87
  super(context)
88
88
  }
@@ -112,7 +112,7 @@ export class NumberOfLanguagesUsed_Issue extends ValidationIssue {
112
112
  readonly issueType = "NumberOfLanguagesUsed"
113
113
  constructor(
114
114
  context: JsonContext,
115
- public nrOfLanguages: number,
115
+ public nrOfLanguages: number
116
116
  ) {
117
117
  super(context)
118
118
  }
@@ -120,9 +120,7 @@ export class NumberOfLanguagesUsed_Issue extends ValidationIssue {
120
120
  }
121
121
  export class MissingM3Language_Issue extends ValidationIssue {
122
122
  readonly issueType = "MissingM3Language"
123
- constructor(
124
- context: JsonContext
125
- ) {
123
+ constructor(context: JsonContext) {
126
124
  super(context)
127
125
  }
128
126
  msg = () => `Missing used language LionCore-M3`
@@ -131,7 +129,7 @@ export class NotLionCoreLanguageKey_Issue extends ValidationIssue {
131
129
  readonly issueType = "NotLionCoreLanguageKey"
132
130
  constructor(
133
131
  context: JsonContext,
134
- public incorrectKey: string,
132
+ public incorrectKey: string
135
133
  ) {
136
134
  super(context)
137
135
  }
@@ -141,7 +139,7 @@ export class IncorrectLionCoreVersion_Issue extends ValidationIssue {
141
139
  readonly issueType = "IncorrectLionCoreVersion"
142
140
  constructor(
143
141
  context: JsonContext,
144
- public incorrectVersion: string,
142
+ public incorrectVersion: string
145
143
  ) {
146
144
  super(context)
147
145
  }
@@ -1,5 +1,5 @@
1
- import { LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js"
2
- import { JsonContext } from "../json/JsonContext.js"
1
+ import { LionWebId, LionWebJsonMetaPointer, LionWebJsonNode } from "@lionweb/json"
2
+ import { JsonContext } from "@lionweb/json-utils"
3
3
  import { ValidationIssue } from "./ValidationIssue.js"
4
4
 
5
5
  export class Reference_DuplicateNodeId_Issue extends ValidationIssue {
@@ -7,7 +7,7 @@ export class Reference_DuplicateNodeId_Issue extends ValidationIssue {
7
7
 
8
8
  constructor(
9
9
  context: JsonContext,
10
- public nodeId: string,
10
+ public nodeId: LionWebId
11
11
  ) {
12
12
  super(context)
13
13
  }
@@ -21,7 +21,7 @@ export class Reference_ChildMissingInParent_Issue extends ValidationIssue {
21
21
  constructor(
22
22
  context: JsonContext,
23
23
  public child: LionWebJsonNode,
24
- public parent: LionWebJsonNode,
24
+ public parent: LionWebJsonNode
25
25
  ) {
26
26
  super(context)
27
27
  }
@@ -35,7 +35,7 @@ export class Reference_ParentMissingInChild_Issue extends ValidationIssue {
35
35
  constructor(
36
36
  context: JsonContext,
37
37
  public parent: LionWebJsonNode,
38
- public child: LionWebJsonNode,
38
+ public child: LionWebJsonNode
39
39
  ) {
40
40
  super(context)
41
41
  }
@@ -49,7 +49,7 @@ export class Reference_CirculairParent_Issue extends ValidationIssue {
49
49
  constructor(
50
50
  context: JsonContext,
51
51
  public node: LionWebJsonNode | undefined,
52
- public parentPath: string[],
52
+ public parentPath: string[]
53
53
  ) {
54
54
  super(context)
55
55
  }
@@ -62,7 +62,7 @@ export class Reference_LanguageUnknown_Issue extends ValidationIssue {
62
62
 
63
63
  constructor(
64
64
  context: JsonContext,
65
- public languageRef: LionWebJsonMetaPointer,
65
+ public languageRef: LionWebJsonMetaPointer
66
66
  ) {
67
67
  super(context)
68
68
  }
@@ -75,9 +75,9 @@ export class Duplicates_Issue extends ValidationIssue {
75
75
 
76
76
  constructor(
77
77
  context: JsonContext,
78
- public nodeid: string,
78
+ public nodeId: LionWebId
79
79
  ) {
80
80
  super(context)
81
81
  }
82
- msg = () => `Duplicate value "${this.nodeid}"`
82
+ msg = () => `Duplicate value "${this.nodeId}"`
83
83
  }
@@ -1,10 +1,10 @@
1
- import { JsonContext } from "../json/JsonContext.js"
1
+ import { JsonContext } from "@lionweb/json-utils"
2
2
  import { ValidationIssue } from "./ValidationIssue.js"
3
3
 
4
4
  export abstract class Syntax_PropertyIssue extends ValidationIssue {
5
5
  constructor(
6
6
  public context: JsonContext,
7
- protected property: string,
7
+ protected property: string
8
8
  ) {
9
9
  super(context)
10
10
  }
@@ -32,7 +32,7 @@ export class Syntax_PropertyTypeIssue extends Syntax_PropertyIssue {
32
32
  context: JsonContext,
33
33
  property: string,
34
34
  protected expectedType: string,
35
- protected actualType: string,
35
+ protected actualType: string
36
36
  ) {
37
37
  super(context, property)
38
38
  }
@@ -46,7 +46,7 @@ export class Syntax_ArrayContainsNull_Issue extends Syntax_PropertyIssue {
46
46
  constructor(
47
47
  context: JsonContext,
48
48
  property: string,
49
- public index: number,
49
+ public index: number
50
50
  ) {
51
51
  super(context, property)
52
52
  }
@@ -57,7 +57,7 @@ export class Syntax_ArrayContainsNull_Issue extends Syntax_PropertyIssue {
57
57
  export abstract class Syntax_IncorrectFormat_Issue extends ValidationIssue {
58
58
  constructor(
59
59
  context: JsonContext,
60
- public value: string,
60
+ public value: string
61
61
  ) {
62
62
  super(context)
63
63
  }
@@ -1,26 +1,29 @@
1
- import { JsonContext } from "../json/JsonContext.js"
1
+ import { JsonContext } from "@lionweb/json-utils"
2
2
 
3
3
  export abstract class ValidationIssue {
4
4
  abstract readonly issueType: string
5
- context: JsonContext
5
+ context: JsonContext | null
6
6
 
7
- constructor(context: JsonContext) {
7
+ constructor(context: JsonContext | null) {
8
8
  this.context = context
9
9
  }
10
10
 
11
11
  protected abstract msg(): string
12
12
 
13
13
  public errorMsg(): string {
14
- return `${this.issueType}: ${this.msg()} at ${this.context.toString()} `
14
+ return `${this.issueType}: ${this.msg()} at ${this.context?.toString()} `
15
15
  }
16
16
  }
17
17
 
18
18
  export class GenericIssue extends ValidationIssue {
19
19
  readonly issueType = "GenericIssue"
20
-
21
- constructor(context: JsonContext, public text: string) {
20
+
21
+ constructor(
22
+ context: JsonContext | null,
23
+ public text: string
24
+ ) {
22
25
  super(context)
23
26
  }
24
-
27
+
25
28
  protected msg = () => this.text
26
29
  }
@@ -1,4 +1,3 @@
1
- export * from "../json/JsonContext.js"
2
1
  export * from "./ValidationIssue.js"
3
2
  export * from "./SyntaxIssues.js"
4
3
  export * from "./ReferenceIssues.js"
@@ -1,4 +1,4 @@
1
- import { LionWebId, LionWebJsonMetaPointer, LionWebJsonNode } from "../json/LionWebJson.js"
1
+ import { LionWebId, LionWebJsonMetaPointer, LionWebJsonNode } from "@lionweb/json"
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 "../json/LionWebJson.js"
1
+ import { LionWebId, LionWebJsonMetaPointer, LionWebJsonNode } from "@lionweb/json"
2
2
  import { CompositeLionWebLanguageWrapper } from "./CompositeLionWebLanguageWrapper.js"
3
3
  import { LionWebLanguageWrapper } from "./LionWebLanguageWrapper.js"
4
4
 
@@ -1,11 +1,11 @@
1
- import { isEqualMetaPointer, LionWebJsonNode, LionWebJsonChunk } from "../json/LionWebJson.js"
2
- import { LION_CORE_M3_KEY, MetaPointers } from "../json/M3definitions.js"
1
+ import { isEqualMetaPointer, LionWebJsonChunk, LionWebJsonNode } from "@lionweb/json"
2
+ import { LION_CORE_M3_KEY, MetaPointers } from "@lionweb/json-utils"
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,10 +1,6 @@
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"
1
+ import { LionWebJsonChunk, LionWebJsonNode, LionWebKey } from "@lionweb/json"
2
+ import { LionWebJsonChunkWrapper, MetaPointers, NodeUtils } from "@lionweb/json-utils"
3
+ import { visitAndMap } from "@lionweb/ts-utils"
8
4
  import { isAnnotation, isConcept, isContainment, isInterface, isProperty, isReference } from "./LanguageUtils.js"
9
5
 
10
6
  interface LionWebLanguageWrapperInterface {
@@ -24,8 +20,8 @@ interface LionWebLanguageWrapperInterface {
24
20
  export class LionWebLanguageWrapper extends LionWebJsonChunkWrapper implements LionWebLanguageWrapperInterface {
25
21
  name: string
26
22
  version: string
27
- key: string
28
-
23
+ key: LionWebKey
24
+
29
25
  constructor(chunk: LionWebJsonChunk) {
30
26
  super(chunk)
31
27
  const languageNode: LionWebJsonNode = this.findNodesOfClassifier(MetaPointers.Language)[0]
@@ -1,12 +1,13 @@
1
- import { LionWebJsonMetaPointer, LionWebJsonNode, MetaPointers, NodeUtils } from "../json/index.js"
1
+ import { LionWebJsonMetaPointer, LionWebJsonNode, LionWebKey } from "@lionweb/json"
2
+ import { MetaPointers, NodeUtils } from "@lionweb/json-utils"
2
3
 
3
4
  export class MetaPointerMap {
4
5
  /**
5
6
  * Map from languageKey => languageVersion => key => LionWebJsonNode
6
7
  */
7
8
  map: Map<string, Map<string, Map<string, LionWebJsonNode>>> = new Map<string, Map<string, Map<string, LionWebJsonNode>>>()
8
-
9
- add(languageKey: string, languageVersion: string, node: LionWebJsonNode): void {
9
+
10
+ add(languageKey: LionWebKey, languageVersion: string, node: LionWebJsonNode): void {
10
11
  const keyProperty = NodeUtils.findProperty(node, MetaPointers.IKeyedKey)
11
12
  if (keyProperty === undefined) {
12
13
  console.log("MetaPointerMap.add: trying to add node without key property.")
@@ -17,9 +18,9 @@ export class MetaPointerMap {
17
18
  console.log("MetaPointerMap.add: trying to add node without key property being empty or null.")
18
19
  return
19
20
  }
20
- this.set({language: languageKey, version: languageVersion, key: key}, node)
21
+ this.set({ language: languageKey, version: languageVersion, key: key }, node)
21
22
  }
22
-
23
+
23
24
  set(mp: LionWebJsonMetaPointer, node: LionWebJsonNode): void {
24
25
  let language = this.map.get(mp.language)
25
26
  if (language === undefined) {
@@ -33,7 +34,7 @@ export class MetaPointerMap {
33
34
  }
34
35
  version.set(mp.key, node)
35
36
  }
36
-
37
+
37
38
  get(mp: LionWebJsonMetaPointer): LionWebJsonNode | undefined {
38
39
  return this.map.get(mp.language)?.get(mp.version)?.get(mp.key)
39
40
  }
@@ -1,7 +1,7 @@
1
1
  import fs from "fs"
2
2
  import { LanguageRegistry } from "../languages/index.js"
3
- import { LionWebValidator } from "../validators/LionWebValidator.js"
4
3
  import { ValidationResult } from "../validators/generic/ValidationResult.js"
4
+ import { LionWebValidator } from "../validators/LionWebValidator.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"
1
3
  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]
@@ -48,7 +48,7 @@ export function printIssues(result: ValidationResult, file?: string): void {
48
48
  }
49
49
 
50
50
  export function issuestoString(vresult: ValidationResult, file?: string): string {
51
- let result = ""
52
- vresult.issues.forEach(issue => (result += (file == undefined ? "" : `File ${file}: `) + issue.errorMsg() + "\n"))
51
+ let result = "ISSUES: "
52
+ vresult.issues.forEach(issue => (result += (file === undefined ? "NOFILE" : `File ${file}: `) + issue.errorMsg() + "\n"))
53
53
  return result
54
54
  }
@@ -1,104 +1,102 @@
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"
1
+ import { DefinitionSchema, MAY_BE_NULL, PropertyDef, PrimitiveDef } from "./generic/index.js"
2
+ import { validateId, validateKey, validateSerializationFormatVersion, validateVersion } from "./ValidationFunctions.js"
8
3
 
9
4
  /**
10
5
  * The structure below defines the structure of a LionWeb Chunk by defining all the properties.
11
6
  * It can
12
- * - be fed to the SyntaxValidator to validate an object sat runtime.
13
- * - used to generate all the types for a LionWebChunk.
7
+ * - be used by the SyntaxValidator to validate an object sat runtime.
8
+ * - used to generate all the TypeScript types for a LionWebChunk.
14
9
  */
15
- export const expectedTypes: Map<string, PropertyDefinition[]> = new Map([
16
- [
17
- "LionWebMetaPointer",
18
- [
19
- PropertyDef({ property: "key", expectedType: "string", validate: validateKey }),
20
- PropertyDef({ property: "version", expectedType: "string", validate: validateVersion }),
21
- PropertyDef({ property: "language", expectedType: "string", validate: validateKey })
10
+ export const LionWebSchema: DefinitionSchema = new DefinitionSchema([
11
+ {
12
+ name: "LionWebJsonMetaPointer",
13
+ properties: [
14
+ PropertyDef({ name: "key", type: "LionWebKey" }),
15
+ PropertyDef({ name: "version", type: "LionWebVersion" }),
16
+ PropertyDef({ name: "language", type: "LionWebKey" })
22
17
  ]
23
- ],
24
- [
25
- "ResponseMessage",
26
- [
27
- PropertyDef({ property: "kind", expectedType: "string" }),
28
- PropertyDef({ property: "message", expectedType: "string" }),
29
- PropertyDef({ property: "data", expectedType: "object", mayBeNull: true })
18
+ },
19
+ {
20
+ name: "LionWebJsonMetaPointer",
21
+ properties: [
22
+ PropertyDef({ name: "key", type: "LionWebKey" }),
23
+ PropertyDef({ name: "version", type: "LionWebVersion" }),
24
+ PropertyDef({ name: "language", type: "LionWebKey" }),
30
25
  ]
31
- ],
32
- [
33
- "LionWebChunk",
34
- [
35
- PropertyDef({ property: "serializationFormatVersion", expectedType: "string", validate: validateSerializationFormatVersion }),
36
- PropertyDef({ property: "languages", expectedType: "LionWebUsedLanguage", isList: true }),
37
- PropertyDef({ property: "nodes", expectedType: "LionWebNode", isList: true })
26
+ },
27
+ {
28
+ name: "ResponseMessage",
29
+ properties: [
30
+ PropertyDef({ name: "kind", type: "JSstring" }),
31
+ PropertyDef({ name: "message", type: "JSstring" }),
32
+ PropertyDef({ name: "data", type: "JSobject", mayBeNull: true, isOptional: true })
38
33
  ]
39
- ],
40
- [
41
- "LionWebUsedLanguage",
42
- [
43
- PropertyDef({ property: "key", expectedType: "string", validate: validateKey }),
44
- PropertyDef({ property: "version", expectedType: "string", validate: validateVersion })
34
+ },
35
+ {
36
+ name: "LionWebJsonChunk",
37
+ properties: [
38
+ PropertyDef({ name: "serializationFormatVersion", type: "LionWebSerializationFormatVersion" }),
39
+ PropertyDef({ name: "languages", type: "LionWebJsonUsedLanguage", isList: true }),
40
+ PropertyDef({ name: "nodes", type: "LionWebJsonNode", isList: true })
45
41
  ]
46
- ],
47
- [
48
- "LionWebNode",
49
- [
50
- PropertyDef({ property: "id", expectedType: "string", validate: validateId }),
51
- PropertyDef({ property: "classifier", expectedType: "LionWebMetaPointer" }),
52
- PropertyDef({ property: "properties", expectedType: "LionWebProperty", isList: true }),
53
- PropertyDef({ property: "containments", expectedType: "LionWebContainment", isList: true }),
54
- PropertyDef({ property: "references", expectedType: "LionWebReference", isList: true }),
55
- PropertyDef({ property: "annotations", expectedType: "string", isList: true, validate: validateId }),
56
- PropertyDef({ property: "parent", expectedType: "string", mayBeNull: MAY_BE_NULL, validate: validateId }),
42
+ },
43
+ {
44
+ name: "LionWebJsonUsedLanguage",
45
+ properties: [
46
+ PropertyDef({ name: "key", type: "LionWebKey" }),
47
+ PropertyDef({ name: "version", type: "LionWebVersion" })
57
48
  ]
58
- ],
59
- [
60
- "LionWebProperty",
61
- [
62
- PropertyDef({ property: "property", expectedType: "LionWebMetaPointer" }),
63
- PropertyDef({ property: "value", expectedType: "string", mayBeNull: MAY_BE_NULL }),
49
+ },
50
+ {
51
+ name: "LionWebJsonNode",
52
+ properties: [
53
+ PropertyDef({ name: "id", type: "LionWebId" }),
54
+ PropertyDef({ name: "classifier", type: "LionWebJsonMetaPointer" }),
55
+ PropertyDef({ name: "properties", type: "LionWebJsonProperty", isList: true }),
56
+ PropertyDef({ name: "containments", type: "LionWebJsonContainment", isList: true }),
57
+ PropertyDef({ name: "references", type: "LionWebJsonReference", isList: true }),
58
+ PropertyDef({ name: "annotations", type: "LionWebId", isList: true }),
59
+ PropertyDef({ name: "parent", type: "LionWebId", mayBeNull: MAY_BE_NULL }),
64
60
  ]
65
- ],
66
- [
67
- "LionWebContainment",
68
- [
69
- PropertyDef({ property: "containment", expectedType: "LionWebMetaPointer" }),
70
- PropertyDef({ property: "children", expectedType: "string", isList: true, validate: validateId }),
61
+ },
62
+ {
63
+ name: "LionWebJsonProperty",
64
+ properties: [
65
+ PropertyDef({ name: "property", type: "LionWebJsonMetaPointer" }),
66
+ PropertyDef({ name: "value", type: "JSstring", mayBeNull: MAY_BE_NULL }),
71
67
  ]
72
- ],
73
- [
74
- "LionWebReference",
75
- [
76
- PropertyDef({ property: "reference", expectedType: "LionWebMetaPointer"}),
77
- PropertyDef({ property: "targets", expectedType: "LionWebReferenceTarget", isList: true}),
68
+ },
69
+ {
70
+ name: "LionWebJsonContainment",
71
+ properties: [
72
+ PropertyDef({ name: "containment", type: "LionWebJsonMetaPointer" }),
73
+ PropertyDef({ name: "children", type: "LionWebId", isList: true }),
78
74
  ]
79
- ],
80
- [
81
- "LionWebReferenceTarget",
82
- [
83
- PropertyDef({ property: "resolveInfo", expectedType: "string", mayBeNull: MAY_BE_NULL }),
84
- PropertyDef({ property: "reference", expectedType: "string", mayBeNull: MAY_BE_NULL, validate: validateId }),
75
+ },
76
+ {
77
+ name: "LionWebJsonReference",
78
+ properties: [
79
+ PropertyDef({ name: "reference", type: "LionWebJsonMetaPointer"}),
80
+ PropertyDef({ name: "targets", type: "LionWebJsonReferenceTarget", isList: true}),
85
81
  ]
86
- ],
82
+ },
83
+ {
84
+ name: "LionWebJsonReferenceTarget",
85
+ properties: [
86
+ PropertyDef({ name: "resolveInfo", type: "JSstring", mayBeNull: MAY_BE_NULL }),
87
+ PropertyDef({ name: "reference", type: "LionWebId", mayBeNull: MAY_BE_NULL }),
88
+ ]
89
+ },
87
90
  /**
88
- * Elements without properties are assumed to be JSON/JS primitive values, and tested using `typeof`.
91
+ * Elements without properties are assumed to be JSON/JS primitive values, and tested using `typeof`
92
+ * and the (optional) validate function.
89
93
  */
90
- [
91
- "string",
92
- []
93
- ],
94
- [
95
- "number",
96
- []
97
- ],
98
- [
99
- "boolean",
100
- []
101
- ],
94
+ PrimitiveDef({ name: "LionWebId", primitiveType: "string", validate: validateId }),
95
+ PrimitiveDef({ name: "LionWebKey", primitiveType: "string", validate: validateKey }),
96
+ PrimitiveDef({ name: "LionWebVersion",primitiveType: "string", validate: validateVersion }),
97
+ PrimitiveDef({ name: "LionWebSerializationFormatVersion",primitiveType: "string", validate: validateSerializationFormatVersion }),
98
+ PrimitiveDef({ name: "JSstring", primitiveType: "string" }),
99
+ PrimitiveDef({ name: "JSobject",primitiveType: "object" }),
102
100
  ])
103
101
 
104
102