@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
@@ -15,32 +15,13 @@ export const MAY_BE_NULL = true;
15
15
  * @constructor
16
16
  */
17
17
  export function PropertyDef(propDef) {
18
- const { property, expectedType, mayBeNull = false, isList = false, isOptional = false, validate = emptyValidation } = propDef;
18
+ const { property, expectedType, mayBeNull = false, isList = false, validate = emptyValidation } = propDef;
19
19
  return {
20
20
  property: property,
21
21
  expectedType: expectedType,
22
22
  isList: isList,
23
23
  mayBeNull: mayBeNull,
24
- isOptional: isOptional,
25
24
  validate: validate
26
25
  };
27
26
  }
28
- /**
29
- * Easy way to create a PropertyDefinition typed object with default values.
30
- * @param propDef
31
- * @constructor
32
- */
33
- export function PrimitiveDef(propDef) {
34
- const { primitiveType, validate = emptyValidation } = propDef;
35
- return {
36
- primitiveType: primitiveType,
37
- validate: validate
38
- };
39
- }
40
- export function isObjectDefinition(def) {
41
- return Array.isArray(def);
42
- }
43
- export function isPrimitiveDefinition(def) {
44
- return def?.primitiveType !== undefined;
45
- }
46
27
  //# sourceMappingURL=ValidationTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationTypes.js","sourceRoot":"","sources":["../../../src/validators/generic/ValidationTypes.ts"],"names":[],"mappings":"AA0CA;;;;;;GAMG;AACH,6DAA6D;AAC7D,SAAS,eAAe,CAAI,MAAS,EAAE,MAAwB,EAAE,GAAgB,EAAE,IAAyB,IAAS,CAAC;AAEtH,uCAAuC;AACvC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAA;AAE/B;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACnD,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,QAAQ,GAAG,eAAe,EAAE,GAAG,OAAO,CAAA;IAC7H,OAAO;QACH,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,YAAY;QAC1B,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,SAAS;QACpB,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,QAAQ;KACrB,CAAA;AACL,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B;IACrD,MAAM,EAAE,aAAa,EAAE,QAAQ,GAAG,eAAe,EAAE,GAAG,OAAO,CAAA;IAC7D,OAAO;QACH,aAAa,EAAE,aAAa;QAC5B,QAAQ,EAAE,QAAQ;KACrB,CAAA;AACL,CAAC;AAID,MAAM,UAAU,kBAAkB,CAAC,GAAmB;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AAC7B,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAmB;IACrD,OAAQ,GAA2B,EAAE,aAAa,KAAK,SAAS,CAAA;AACpE,CAAC"}
1
+ {"version":3,"file":"ValidationTypes.js","sourceRoot":"","sources":["../../../src/validators/generic/ValidationTypes.ts"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,6DAA6D;AAC7D,SAAS,eAAe,CAAI,MAAS,EAAE,MAAwB,EAAE,GAAgB,EAAG,IAAyB,IAAS,CAAC;AAEvH,uCAAuC;AACvC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAA;AAE/B;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACnD,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,QAAQ,GAAG,eAAe,EAAE,GAAG,OAAO,CAAA;IACzG,OAAO;QACH,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,YAAY;QAC1B,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,SAAS;QACpB,QAAQ,EAAE,QAAQ;KACrB,CAAA;AACL,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./ValidationTypes.js";
2
2
  export * from "./ValidationResult.js";
3
+ export * from "../ValidationFunctions.js";
3
4
  export * from "./SyntaxValidator.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validators/generic/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validators/generic/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from "./ValidationTypes.js";
2
2
  export * from "./ValidationResult.js";
3
+ export * from "../ValidationFunctions.js";
3
4
  export * from "./SyntaxValidator.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validators/generic/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validators/generic/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from "./generic/index.js";
2
+ export * from "./generic/ValidationResult.js";
2
3
  export * from "./LionWebSyntaxValidator.js";
3
4
  export * from "./LionWebReferenceValidator.js";
4
5
  export * from "./LionWebLanguageValidator.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wCAAwC,CAAA;AACtD,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wCAAwC,CAAA;AACtD,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from "./generic/index.js";
2
+ export * from "./generic/ValidationResult.js";
2
3
  export * from "./LionWebSyntaxValidator.js";
3
4
  export * from "./LionWebReferenceValidator.js";
4
5
  export * from "./LionWebLanguageValidator.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wCAAwC,CAAA;AACtD,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wCAAwC,CAAA;AACtD,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lionweb/validation",
3
- "version": "0.6.13-beta.6",
3
+ "version": "0.6.13-beta.7",
4
4
  "license": "Apache 2.0",
5
5
  "description": "LionWeb Serialization validation",
6
6
  "author": "jos.warmer@openmodeling.nl",
@@ -20,8 +20,8 @@
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 --registry https://registry.npmjs.org",
24
- "release-beta": "npm publish --registry https://registry.npmjs.org --tag beta",
23
+ "release": "npm publish",
24
+ "release-beta": "npm publish --tag beta",
25
25
  "testValid": "node dist/runners/RunCheckFolder.js ../test/testset/valid",
26
26
  "testInvalid": "node dist/runners/RunCheckFolder.js ../test/testset/invalid",
27
27
  "testInvalidWithLanguage": "node dist/runners/RunCheckFolderWithLanguage.js ../test/testset/withLanguage/invalid/ ../test/testset/withLanguage/myLang.language.json",
@@ -29,10 +29,5 @@
29
29
  "publish-local": "npm publish --registry http://localhost:4873",
30
30
  "unpublish-local": "npm unpublish --force --registry http://localhost:4873",
31
31
  "republish-local": "yarn unpublish-local && yarn publish-local"
32
- },
33
- "dependencies": {
34
- "@lionweb/json": "0.6.13-beta.5",
35
- "@lionweb/ts-utils": "0.6.13-beta.5",
36
- "@lionweb/json-utils": "0.6.13-beta.5"
37
32
  }
38
33
  }
@@ -0,0 +1,21 @@
1
+ import { Change } from "./changes/Change.js"
2
+
3
+ export class DiffResult {
4
+ changes: Change[] = []
5
+
6
+ change(issue: Change) {
7
+ this.changes.push(issue)
8
+ }
9
+
10
+ reset() {
11
+ this.changes = []
12
+ }
13
+
14
+ hasChanges(): boolean {
15
+ return this.changes.length !== 0
16
+ }
17
+
18
+ asStringArray(): string[] {
19
+ return this.changes.map(ch => ch.changeMsg())
20
+ }
21
+ }
@@ -0,0 +1,309 @@
1
+ import { JsonContext } from "../issues/index.js"
2
+ import {
3
+ ChunkUtils,
4
+ isEqualMetaPointer, isEqualReferenceTarget,
5
+ LionWebJsonChunk,
6
+ LionWebJsonContainment,
7
+ LionWebJsonNode,
8
+ LionWebJsonProperty,
9
+ LionWebJsonReference,
10
+ LionWebJsonReferenceTarget,
11
+ LwJsonUsedLanguage,
12
+ NodeUtils
13
+ } from "../json/index.js"
14
+ import { Change, GenericChange, Missing } from "./changes/Change.js"
15
+ import { LanguageAdded, LanguageRemoved, NodeAdded, NodeRemoved, SerializationFormatChange } from "./changes/ChunkChange.js"
16
+ import { ChildAdded, ChildRemoved, ChildOrderChanged } from "./changes/ContainmentChange.js"
17
+ import { AnnotationAdded, AnnotationOrderChanged, AnnotationRemoved, TargetAdded, TargetOrderChanged, TargetRemoved } from "./changes/index.js"
18
+ import { NodeClassifierChanged, ParentChanged } from "./changes/NodeChange.js"
19
+ import { PropertyValueChanged } from "./changes/PropertyChange.js"
20
+ import { DiffResult } from "./DiffResult.js"
21
+
22
+ /**
23
+ * Comparing LionWeb JSON chunks and find all differences
24
+ */
25
+ export class LionWebJsonDiff {
26
+ diffResult = new DiffResult()
27
+
28
+ constructor() {}
29
+
30
+ change(change: Change): void {
31
+ this.diffResult.change(change)
32
+ }
33
+
34
+ diff(ctx: JsonContext, msg: string) {
35
+ const change = new GenericChange(ctx, msg)
36
+ this.diffResult.change(change)
37
+ }
38
+
39
+ /**
40
+ * Compare two LwNode objects and return their difference
41
+ * @param beforeNode
42
+ * @param afterNode
43
+ */
44
+ diffLwNode(ctx: JsonContext, beforeNode: LionWebJsonNode, afterNode: LionWebJsonNode): void {
45
+ if (!isEqualMetaPointer(beforeNode.classifier, afterNode.classifier)) {
46
+ this.change(new NodeClassifierChanged(ctx.concat("classifier"), beforeNode, beforeNode.classifier, afterNode.classifier))
47
+ }
48
+ if (beforeNode.parent !== afterNode.parent) {
49
+ this.change(new ParentChanged(ctx, beforeNode, beforeNode.parent, afterNode.parent))
50
+ }
51
+ // Find diff between previous and next properties
52
+ beforeNode.properties.forEach((beforeProperty: LionWebJsonProperty, index: number) => {
53
+ const afterProperty = NodeUtils.findProperty(afterNode, beforeProperty.property)
54
+ if (afterProperty === undefined) {
55
+ this.change(
56
+ new PropertyValueChanged(
57
+ ctx.concat("properties", index),
58
+ beforeNode.id,
59
+ beforeProperty.property,
60
+ beforeProperty.value,
61
+ null,
62
+ Missing.MissingAfter
63
+ ),
64
+ )
65
+ } else {
66
+ this.diffLwProperty(ctx.concat("properties", index), beforeNode, beforeProperty, afterProperty)
67
+ }
68
+ })
69
+ afterNode.properties.forEach((afterProperty: LionWebJsonProperty, index: number) => {
70
+ const beforeProperty = NodeUtils.findProperty(beforeNode, afterProperty.property)
71
+ if (beforeProperty === undefined) {
72
+ this.change(
73
+ new PropertyValueChanged(
74
+ ctx.concat("properties", index),
75
+ beforeNode.id,
76
+ afterProperty.property,
77
+ null,
78
+ afterProperty.value,
79
+ Missing.MissingBefore
80
+ ),
81
+ )
82
+ }
83
+ // no else, if the property exists in both nodes, the diff has been claculated in the loop before this one
84
+ })
85
+ beforeNode.containments.forEach((beforeContainment: LionWebJsonContainment, index: number) => {
86
+ const beforeKey = beforeContainment.containment.key
87
+ const afterContainment = NodeUtils.findChild(afterNode, beforeKey)
88
+ if (afterContainment === undefined) {
89
+ // NB No containment is considered equivalent to a containment with empty _children_
90
+ if (beforeContainment.children.length !== 0) {
91
+ beforeContainment.children.forEach(childId => {
92
+ this.change(new ChildRemoved(ctx.concat("containments", index), beforeNode, beforeContainment.containment, afterContainment, childId, Missing.MissingAfter))
93
+ })
94
+ }
95
+ } else {
96
+ this.diffContainment(ctx.concat("containments", index), beforeNode, beforeContainment, afterContainment)
97
+ }
98
+ })
99
+ afterNode.containments.forEach((afterContainment: LionWebJsonContainment, index: number) => {
100
+ const afterKey = afterContainment.containment.key
101
+ const beforeContainment = NodeUtils.findChild(beforeNode, afterKey)
102
+ if (beforeContainment === undefined) {
103
+ if (afterContainment.children.length !== 0) {
104
+ afterContainment.children.forEach(childId => {
105
+ this.change(new ChildAdded(ctx.concat("containments", index), afterNode, afterContainment.containment, afterContainment, childId, Missing.MissingBefore))
106
+ })
107
+ }
108
+ }
109
+ // No else, has already been done
110
+ })
111
+ beforeNode.references.forEach((beforeReference: LionWebJsonReference, index: number) => {
112
+ const afterReference = NodeUtils.findReference(afterNode, beforeReference.reference)
113
+ if (afterReference === undefined) {
114
+ if (beforeReference.targets.length !== 0) {
115
+ beforeReference.targets.forEach(target => {
116
+ this.change(new TargetRemoved(ctx.concat("references", index), afterNode, beforeReference, afterReference, target, Missing.MissingAfter))
117
+ })
118
+ }
119
+ } else {
120
+ this.diffLwReference(ctx.concat("references", index), beforeNode, beforeReference, afterReference)
121
+ }
122
+ })
123
+ afterNode.references.forEach((afterReference: LionWebJsonReference, index: number) => {
124
+ const beforeReference = NodeUtils.findReference(afterNode, afterReference.reference)
125
+ if (beforeReference === undefined) {
126
+ if (afterReference.targets.length !== 0) {
127
+ afterReference.targets.forEach(target => {
128
+ this.change(new TargetAdded(ctx.concat("references", index), afterNode, beforeReference, afterReference, target, Missing.MissingBefore))
129
+ })
130
+ }
131
+ }
132
+ })
133
+ if (beforeNode.annotations !== undefined && afterNode.annotations !== undefined) {
134
+ let annotationDiffFound = false
135
+ beforeNode.annotations.forEach((beforeAnn: string, index: number) => {
136
+ if (!afterNode.annotations.includes(beforeAnn)) {
137
+ annotationDiffFound = true
138
+ this.change(new AnnotationRemoved(ctx, beforeNode, afterNode, beforeAnn, index))
139
+ }
140
+ })
141
+ afterNode.annotations.forEach((afterAnn: string, index: number) => {
142
+ if (!beforeNode.annotations.includes(afterAnn)) {
143
+ annotationDiffFound = true
144
+ this.change(new AnnotationAdded(ctx, beforeNode, afterNode, afterAnn, index))
145
+ }
146
+ })
147
+ if (!annotationDiffFound) {
148
+ for (let i: number = 0; i < afterNode.annotations.length; i++) {
149
+ if (afterNode.annotations[i] !== beforeNode.annotations[i]) {
150
+ this.change(new AnnotationOrderChanged(ctx.concat("annotations"), beforeNode, afterNode, "", i))
151
+ break
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+
158
+ diffLwChunk(beforeChunk: LionWebJsonChunk, afterChunk: LionWebJsonChunk): void {
159
+ const ctx = new JsonContext(null, ["$"])
160
+ if (beforeChunk.serializationFormatVersion !== afterChunk.serializationFormatVersion) {
161
+ this.change(
162
+ new SerializationFormatChange(
163
+ ctx.concat("serializationFormatVersion"),
164
+ beforeChunk.serializationFormatVersion,
165
+ afterChunk.serializationFormatVersion,
166
+ ),
167
+ )
168
+ }
169
+ beforeChunk.languages.forEach((beforeLanguage: LwJsonUsedLanguage, index: number) => {
170
+ const afterLanguage = ChunkUtils.findLwUsedLanguage(afterChunk, beforeLanguage.key)
171
+ if (afterLanguage === null) {
172
+ this.change(new LanguageRemoved(ctx.concat("languages", index), beforeLanguage))
173
+ } else {
174
+ this.diffLwUsedLanguage(ctx.concat("languages", index), beforeLanguage, afterLanguage)
175
+ }
176
+ })
177
+ afterChunk.languages.forEach((afterLanguage: LwJsonUsedLanguage, index: number) => {
178
+ const beforeLanguage = ChunkUtils.findLwUsedLanguage(beforeChunk, afterLanguage.key)
179
+ if (beforeLanguage === null) {
180
+ this.change(new LanguageAdded(ctx.concat("languages", index), afterLanguage))
181
+ }
182
+ })
183
+ beforeChunk.nodes.forEach((beforeNode: LionWebJsonNode, index: number) => {
184
+ const beforeId = beforeNode.id
185
+ const afterNode = ChunkUtils.findNode(afterChunk, beforeId)
186
+ const newCtx = ctx.concat("nodes", index)
187
+ if (afterNode === null || afterNode === undefined) {
188
+ this.change(new NodeRemoved(ctx, beforeNode))
189
+ } else {
190
+ this.diffLwNode(newCtx, beforeNode, afterNode)
191
+ }
192
+ })
193
+ afterChunk.nodes.forEach((afterNode: LionWebJsonNode, index: number) => {
194
+ const afterId = afterNode.id
195
+ const beforeNode = ChunkUtils.findNode(beforeChunk, afterId)
196
+ if (beforeNode === null) {
197
+ this.change(new NodeAdded(ctx.concat("nodes", index), afterNode))
198
+ }
199
+ })
200
+ }
201
+
202
+ diffContainment(
203
+ ctx: JsonContext,
204
+ node: LionWebJsonNode,
205
+ beforeContainment: LionWebJsonContainment,
206
+ afterContainment: LionWebJsonContainment,
207
+ ): void {
208
+ if (!isEqualMetaPointer(beforeContainment.containment, afterContainment.containment)) {
209
+ console.error("diffContainment: MetaPointers of containments should be identical")
210
+ this.diff(
211
+ ctx,
212
+ `Containment Object has concept ${JSON.stringify(beforeContainment.containment)} vs ${JSON.stringify(
213
+ afterContainment.containment,
214
+ )}`,
215
+ )
216
+ }
217
+ // Check whether children exist in both objects (two for loops)
218
+ // TODO Also check for the order that can be changed!!!
219
+ let changeFound = false
220
+ for (const childId1 of beforeContainment.children) {
221
+ if (!afterContainment.children.includes(childId1)) {
222
+ changeFound = true
223
+ this.change(new ChildRemoved(ctx, node, beforeContainment.containment, afterContainment, childId1))
224
+ }
225
+ }
226
+ for (const childId2 of afterContainment.children) {
227
+ if (!beforeContainment.children.includes(childId2)) {
228
+ changeFound = true
229
+ this.change(new ChildAdded(ctx, node, beforeContainment.containment, afterContainment, childId2))
230
+ }
231
+ }
232
+ if (!changeFound) {
233
+ for (let i: number = 0; i < afterContainment.children.length; i++) {
234
+ if (afterContainment.children[i] !== beforeContainment.children[i]) {
235
+ this.change(new ChildOrderChanged(ctx.concat("children"), node, afterContainment.containment, afterContainment, ""))
236
+ break
237
+ }
238
+ }
239
+ }
240
+ }
241
+
242
+ diffLwReference(ctx: JsonContext, node: LionWebJsonNode, beforeRef: LionWebJsonReference, afterRef: LionWebJsonReference): void {
243
+ if (!isEqualMetaPointer(beforeRef.reference, afterRef.reference)) {
244
+ console.error("diffContainment: MetaPointers of references should be identical")
245
+ this.diff(ctx, `Reference has concept ${JSON.stringify(beforeRef.reference)} vs ${JSON.stringify(afterRef.reference)}`)
246
+ }
247
+ let diffFound = false;
248
+ beforeRef.targets.forEach((beforeTarget: LionWebJsonReferenceTarget, index: number) => {
249
+ const afterTarget = NodeUtils.findReferenceTarget(afterRef.targets, beforeTarget)
250
+ if (afterTarget === undefined) {
251
+ this.change(new TargetRemoved(ctx.concat("targets", index), node, beforeRef, afterRef, beforeTarget))
252
+ diffFound = true
253
+ } else {
254
+ if (!isEqualReferenceTarget(beforeTarget, afterTarget)) {
255
+ this.diff(
256
+ ctx.concat("targets", index),
257
+ `ERROR: reference target ${JSON.stringify(beforeTarget)} vs ${JSON.stringify(afterTarget)}`,
258
+ )
259
+ }
260
+ }
261
+ })
262
+ afterRef.targets.forEach((afterTarget: LionWebJsonReferenceTarget, index: number) => {
263
+ const beforeTarget = NodeUtils.findReferenceTarget(beforeRef.targets, afterTarget)
264
+ if (beforeTarget === undefined) {
265
+ this.change(new TargetAdded(ctx.concat("targets", index), node, beforeRef, afterRef, afterTarget))
266
+ diffFound = true
267
+ } else {
268
+ if (!isEqualReferenceTarget(beforeTarget, afterTarget)) {
269
+ this.diff(
270
+ ctx.concat("targets", index),
271
+ `ERROR: reference target ${JSON.stringify(beforeTarget)} vs ${JSON.stringify(afterTarget)}`,
272
+ )
273
+ }
274
+ }
275
+ })
276
+ if (!diffFound) {
277
+ for (let i: number = 0; i < beforeRef.targets.length; i++) {
278
+ if (!isEqualReferenceTarget(beforeRef.targets[i], afterRef.targets[i])) {
279
+ this.change(new TargetOrderChanged(ctx.concat("targets"), node, beforeRef, afterRef, beforeRef.targets[i]))
280
+ break
281
+ }
282
+ }
283
+ }
284
+ }
285
+
286
+ private diffLwUsedLanguage(ctx: JsonContext, obj1: LwJsonUsedLanguage, obj2: LwJsonUsedLanguage) {
287
+ if (obj1.key !== obj2.key || obj1.version !== obj2.version) {
288
+ this.diff(ctx, `Different used languages ${JSON.stringify(obj1)} vs ${JSON.stringify(obj2)}`)
289
+ }
290
+ }
291
+
292
+ private diffLwProperty(
293
+ ctx: JsonContext,
294
+ node: LionWebJsonNode,
295
+ beforeProperty: LionWebJsonProperty,
296
+ afterProperty: LionWebJsonProperty,
297
+ ) {
298
+ if (!isEqualMetaPointer(beforeProperty.property, afterProperty.property)) {
299
+ console.error("diffContainment: MetaPointers of properties should be identical")
300
+ this.diff(
301
+ ctx,
302
+ `Property Object has concept ${JSON.stringify(beforeProperty.property)} vs ${JSON.stringify(afterProperty.property)}`,
303
+ )
304
+ }
305
+ if (beforeProperty.value !== afterProperty.value) {
306
+ this.change(new PropertyValueChanged(ctx, node.id, beforeProperty.property, beforeProperty.value, afterProperty.value))
307
+ }
308
+ }
309
+ }
@@ -0,0 +1,76 @@
1
+ import { JsonContext } from "../../issues/index.js"
2
+
3
+ export type ChangeType =
4
+ | "GenericChange"
5
+ | "NodeRemoved"
6
+ | "NodeAdded"
7
+ | "ChildRemoved"
8
+ | "ChildAdded"
9
+ | "ParentChanged"
10
+ | "PropertyValueChanged"
11
+ | "SerializationFormatChange"
12
+ | "PropertyRemoved"
13
+ | "PropertyAdded"
14
+ | "NodeClassifierChanged"
15
+ | "ContainmentAdded"
16
+ | "ContainmentRemoved"
17
+ | "LanguageRemoved"
18
+ | "LanguageAdded"
19
+ | "TargetAdded"
20
+ | "TargetRemoved"
21
+ | "ReferenceRemoved"
22
+ | "ReferenceAdded"
23
+ | "AnnotationRemoved"
24
+ | "AnnotationAdded"
25
+ | "ChildOrderChanged"
26
+ | "AnnotationOrderChanged"
27
+ | "TargetOrderChanged"
28
+
29
+ /**
30
+ * Additionbal property in property, contauinment and reference changes to state
31
+ * that the whole property/ containment / reference definition is missing.
32
+ */
33
+ export enum Missing {
34
+ /**
35
+ * Both before and after have a definition for the property / containment / reference
36
+ */
37
+ NotMissing,
38
+ /**
39
+ * The definition is missing _before_ for the property / containment / reference
40
+ */
41
+ MissingBefore,
42
+ /**
43
+ * The definition is missing _after_ for the property / containment / reference
44
+ */
45
+ MissingAfter
46
+ }
47
+
48
+ export abstract class Change {
49
+ abstract readonly changeType: ChangeType
50
+ context: JsonContext
51
+
52
+ constructor(context: JsonContext) {
53
+ this.context = context
54
+ }
55
+
56
+ protected abstract msg(): string
57
+
58
+ public changeMsg(): string {
59
+ return `${this.changeType}: ${this.msg()} at ${this.context.toString()} `
60
+ }
61
+ }
62
+
63
+ export class GenericChange extends Change {
64
+ readonly changeType = "GenericChange"
65
+
66
+ constructor(
67
+ context: JsonContext,
68
+ protected message: string,
69
+ ) {
70
+ super(context)
71
+ }
72
+
73
+ protected msg(): string {
74
+ return this.message
75
+ }
76
+ }
@@ -0,0 +1,68 @@
1
+ import { JsonContext } from "../../issues/index.js"
2
+ import { LionWebJsonNode, LwJsonUsedLanguage } from "../../json/index.js"
3
+ import { Change } from "./Change.js"
4
+
5
+ export abstract class ChunkChange extends Change {
6
+ constructor(public context: JsonContext) {
7
+ super(context)
8
+ }
9
+ }
10
+
11
+ export class SerializationFormatChange extends ChunkChange {
12
+ readonly changeType = "SerializationFormatChange"
13
+
14
+ constructor(
15
+ public context: JsonContext,
16
+ protected original: string,
17
+ protected newValue: string,
18
+ ) {
19
+ super(context)
20
+ }
21
+
22
+ protected msg = () => `Serialization versions do not match: ${this.original} vs ${this.newValue}`
23
+ }
24
+
25
+ export class NodeRemoved extends ChunkChange {
26
+ readonly changeType = "NodeRemoved"
27
+
28
+ constructor(
29
+ public context: JsonContext,
30
+ public node: LionWebJsonNode,
31
+ ) {
32
+ super(context)
33
+ }
34
+
35
+ protected msg = () => `Node ${this.node.id} is removed`
36
+ }
37
+
38
+ export class NodeAdded extends ChunkChange {
39
+ readonly changeType = "NodeAdded"
40
+
41
+ constructor(
42
+ public context: JsonContext,
43
+ public node: LionWebJsonNode,
44
+ ) {
45
+ super(context)
46
+ }
47
+
48
+ protected msg = () => `Node ${this.node.id} is added`
49
+ }
50
+
51
+ export abstract class LanguageChange extends ChunkChange {
52
+ constructor(
53
+ public context: JsonContext,
54
+ public language: LwJsonUsedLanguage,
55
+ ) {
56
+ super(context)
57
+ }
58
+ }
59
+
60
+ export class LanguageRemoved extends LanguageChange {
61
+ readonly changeType = "LanguageRemoved"
62
+ protected msg = () => `Language with key ${this.language.key} and version ${this.language.version} is removed`
63
+ }
64
+
65
+ export class LanguageAdded extends LanguageChange {
66
+ readonly changeType = "LanguageAdded"
67
+ protected msg = () => `Language with key ${this.language.key} and version ${this.language.version} is added`
68
+ }
@@ -0,0 +1,32 @@
1
+ import { JsonContext } from "../../issues/index.js"
2
+ import { LionWebJsonContainment, LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
3
+ import { Change, Missing } from "./Change.js"
4
+
5
+ export abstract class ContainmentChange extends Change {
6
+ constructor(
7
+ public context: JsonContext,
8
+ public parentNode: LionWebJsonNode,
9
+ public containment: LionWebJsonMetaPointer,
10
+ public afterContainment: LionWebJsonContainment | undefined,
11
+ public childId: string,
12
+ public missing = Missing.NotMissing
13
+ ) {
14
+ super(context)
15
+ }
16
+ }
17
+
18
+ export class ChildAdded extends ContainmentChange {
19
+ readonly changeType = "ChildAdded"
20
+ protected msg = () => `Node "${this.parentNode.id}" added child "${this.childId}" to containment ${this.containment.key}`
21
+ }
22
+
23
+ export class ChildRemoved extends ContainmentChange {
24
+ readonly changeType = "ChildRemoved"
25
+ protected msg = () => `Node "${this.parentNode.id}" removed child "${this.childId}" from containment "${this.containment.key}"`
26
+ }
27
+
28
+ export class ChildOrderChanged extends ContainmentChange {
29
+ readonly changeType = "ChildOrderChanged"
30
+ protected msg = () => `Node "${this.parentNode.id}" changed order of children in containment "${this.containment.key}"`
31
+ }
32
+