@lionweb/validation 0.7.2-beta.6 → 0.8.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 (92) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/validators/LionWebReferenceValidator.d.ts +19 -1
  3. package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
  4. package/dist/validators/LionWebReferenceValidator.js +20 -2
  5. package/dist/validators/LionWebReferenceValidator.js.map +1 -1
  6. package/dist/validators/LionWebSyntaxValidator.d.ts +0 -3
  7. package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
  8. package/dist/validators/LionWebSyntaxValidator.js +10 -3
  9. package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
  10. package/dist/validators/ValidationFunctions.d.ts +1 -1
  11. package/dist/validators/ValidationFunctions.d.ts.map +1 -1
  12. package/dist/validators/definitions/ChunksDefinitions.d.ts +3 -0
  13. package/dist/validators/definitions/ChunksDefinitions.d.ts.map +1 -0
  14. package/dist/validators/definitions/ChunksDefinitions.js +251 -0
  15. package/dist/validators/definitions/ChunksDefinitions.js.map +1 -0
  16. package/dist/validators/definitions/CommandDefinitions.d.ts +3 -0
  17. package/dist/validators/definitions/CommandDefinitions.d.ts.map +1 -0
  18. package/dist/validators/definitions/CommandDefinitions.js +2138 -0
  19. package/dist/validators/definitions/CommandDefinitions.js.map +1 -0
  20. package/dist/validators/definitions/DeltaTypesDefinitions.d.ts +3 -0
  21. package/dist/validators/definitions/DeltaTypesDefinitions.d.ts.map +1 -0
  22. package/dist/validators/definitions/DeltaTypesDefinitions.js +116 -0
  23. package/dist/validators/definitions/DeltaTypesDefinitions.js.map +1 -0
  24. package/dist/validators/definitions/EventDefinitions.d.ts +3 -0
  25. package/dist/validators/definitions/EventDefinitions.d.ts.map +1 -0
  26. package/dist/validators/definitions/EventDefinitions.js +2806 -0
  27. package/dist/validators/definitions/EventDefinitions.js.map +1 -0
  28. package/dist/validators/definitions/QueryDefinitions.d.ts +3 -0
  29. package/dist/validators/definitions/QueryDefinitions.d.ts.map +1 -0
  30. package/dist/validators/definitions/QueryDefinitions.js +145 -0
  31. package/dist/validators/definitions/QueryDefinitions.js.map +1 -0
  32. package/dist/validators/definitions/RequestDefinitions.d.ts +3 -0
  33. package/dist/validators/definitions/RequestDefinitions.d.ts.map +1 -0
  34. package/dist/validators/definitions/RequestDefinitions.js +315 -0
  35. package/dist/validators/definitions/RequestDefinitions.js.map +1 -0
  36. package/dist/validators/definitions/ResponseDefinitions.d.ts +3 -0
  37. package/dist/validators/definitions/ResponseDefinitions.d.ts.map +1 -0
  38. package/dist/validators/definitions/ResponseDefinitions.js +273 -0
  39. package/dist/validators/definitions/ResponseDefinitions.js.map +1 -0
  40. package/dist/validators/definitions/index.d.ts +8 -0
  41. package/dist/validators/definitions/index.d.ts.map +1 -0
  42. package/dist/validators/definitions/index.js +8 -0
  43. package/dist/validators/definitions/index.js.map +1 -0
  44. package/dist/validators/generic/SyntaxValidator.d.ts +7 -6
  45. package/dist/validators/generic/SyntaxValidator.d.ts.map +1 -1
  46. package/dist/validators/generic/SyntaxValidator.js +53 -21
  47. package/dist/validators/generic/SyntaxValidator.js.map +1 -1
  48. package/dist/validators/generic/schema/SyntaxDefinition.d.ts +45 -0
  49. package/dist/validators/generic/schema/SyntaxDefinition.d.ts.map +1 -0
  50. package/dist/validators/generic/schema/SyntaxDefinition.js +39 -0
  51. package/dist/validators/generic/schema/SyntaxDefinition.js.map +1 -0
  52. package/dist/validators/generic/schema/index.d.ts +1 -2
  53. package/dist/validators/generic/schema/index.d.ts.map +1 -1
  54. package/dist/validators/generic/schema/index.js +1 -2
  55. package/dist/validators/generic/schema/index.js.map +1 -1
  56. package/dist/validators/index.d.ts +1 -1
  57. package/dist/validators/index.d.ts.map +1 -1
  58. package/dist/validators/index.js +1 -1
  59. package/dist/validators/index.js.map +1 -1
  60. package/package.json +4 -4
  61. package/src/validators/LionWebReferenceValidator.ts +20 -2
  62. package/src/validators/LionWebSyntaxValidator.ts +10 -3
  63. package/src/validators/ValidationFunctions.ts +1 -1
  64. package/src/validators/definitions/ChunksDefinitions.ts +252 -0
  65. package/src/validators/definitions/CommandDefinitions.ts +2139 -0
  66. package/src/validators/definitions/DeltaTypesDefinitions.ts +117 -0
  67. package/src/validators/definitions/EventDefinitions.ts +2807 -0
  68. package/src/validators/definitions/QueryDefinitions.ts +146 -0
  69. package/src/validators/definitions/README.md +17 -0
  70. package/src/validators/definitions/RequestDefinitions.ts +316 -0
  71. package/src/validators/definitions/ResponseDefinitions.ts +274 -0
  72. package/src/validators/definitions/index.ts +7 -0
  73. package/src/validators/generic/SyntaxValidator.ts +60 -29
  74. package/src/validators/generic/index.ts +1 -0
  75. package/src/validators/generic/schema/SyntaxDefinition.ts +83 -0
  76. package/src/validators/generic/schema/index.ts +1 -2
  77. package/src/validators/index.ts +1 -1
  78. package/dist/validators/LionWebChunkDefinitions.d.ts +0 -9
  79. package/dist/validators/LionWebChunkDefinitions.d.ts.map +0 -1
  80. package/dist/validators/LionWebChunkDefinitions.js +0 -100
  81. package/dist/validators/LionWebChunkDefinitions.js.map +0 -1
  82. package/dist/validators/generic/schema/DefinitionSchema.d.ts +0 -23
  83. package/dist/validators/generic/schema/DefinitionSchema.d.ts.map +0 -1
  84. package/dist/validators/generic/schema/DefinitionSchema.js +0 -43
  85. package/dist/validators/generic/schema/DefinitionSchema.js.map +0 -1
  86. package/dist/validators/generic/schema/ValidationTypes.d.ts +0 -101
  87. package/dist/validators/generic/schema/ValidationTypes.d.ts.map +0 -1
  88. package/dist/validators/generic/schema/ValidationTypes.js +0 -43
  89. package/dist/validators/generic/schema/ValidationTypes.js.map +0 -1
  90. package/src/validators/LionWebChunkDefinitions.ts +0 -104
  91. package/src/validators/generic/schema/DefinitionSchema.ts +0 -52
  92. package/src/validators/generic/schema/ValidationTypes.ts +0 -134
@@ -4,6 +4,6 @@ export * from "./LionWebReferenceValidator.js";
4
4
  export * from "./LionWebLanguageValidator.js";
5
5
  export * from "./LionWebLanguageReferenceValidator.js";
6
6
  export * from "./LionWebValidator.js";
7
+ export * from "./definitions/index.js";
7
8
  export * from "./ValidationFunctions.js";
8
- export * from "./LionWebChunkDefinitions.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -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,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wCAAwC,CAAA;AACtD,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA"}
@@ -4,6 +4,6 @@ export * from "./LionWebReferenceValidator.js";
4
4
  export * from "./LionWebLanguageValidator.js";
5
5
  export * from "./LionWebLanguageReferenceValidator.js";
6
6
  export * from "./LionWebValidator.js";
7
+ export * from "./definitions/index.js";
7
8
  export * from "./ValidationFunctions.js";
8
- export * from "./LionWebChunkDefinitions.js";
9
9
  //# sourceMappingURL=index.js.map
@@ -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,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wCAAwC,CAAA;AACtD,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lionweb/validation",
3
- "version": "0.7.2-beta.6",
3
+ "version": "0.8.0-beta.0",
4
4
  "license": "Apache 2.0",
5
5
  "description": "LionWeb Serialization validation",
6
6
  "author": "jos.warmer@openmodeling.nl",
@@ -36,8 +36,8 @@
36
36
  "republish-local": "yarn unpublish-local && yarn publish-local"
37
37
  },
38
38
  "dependencies": {
39
- "@lionweb/json": "0.7.2-beta.6",
40
- "@lionweb/ts-utils": "0.7.2-beta.6",
41
- "@lionweb/json-utils": "0.7.2-beta.6"
39
+ "@lionweb/json": "0.8.0-beta.0",
40
+ "@lionweb/ts-utils": "0.8.0-beta.0",
41
+ "@lionweb/json-utils": "0.8.0-beta.0"
42
42
  }
43
43
  }
@@ -22,9 +22,14 @@ export class LionWebReferenceValidator {
22
22
  this.validationResult = validationResult
23
23
  }
24
24
 
25
- validateNodeIds(obj: LionWebJsonChunk, ctx: JsonContext): void {
25
+ /**
26
+ * Checks for duplicate node id's.
27
+ * As a side-effect creates a map from `id` to `node` for all nodes in `chunk` to make further validation faster.
28
+ * @param ctx
29
+ */
30
+ validateNodeIds(chunk: LionWebJsonChunk, ctx: JsonContext): void {
26
31
  // put all nodes in a map, validate that there are no two nodes with the same id.
27
- obj.nodes.forEach((node, index) => {
32
+ chunk.nodes.forEach((node, index) => {
28
33
  // this.validationResult.check(this.nodesIdMap.get(node.id) === undefined, `Node number ${index} has duplicate id "${node.id}"`);
29
34
  if (!(this.nodesIdMap.get(node.id) === undefined)) {
30
35
  this.validationResult.issue(new Reference_DuplicateNodeId_Issue(ctx.concat("nodes", index), node.id))
@@ -172,6 +177,13 @@ export class LionWebReferenceValidator {
172
177
  }
173
178
  }
174
179
 
180
+ /**
181
+ * Checks whether `child` appears in a `containment` of `parent`.
182
+ * Only applicable when both `parent` and `child` are in the same LionWebJsonChunk being validated.
183
+ * @param context
184
+ * @param parent
185
+ * @param child
186
+ */
175
187
  validateExistsAsChild(context: JsonContext, parent: LionWebJsonNode | undefined, child: LionWebJsonNode) {
176
188
  if (parent === undefined || parent === null) {
177
189
  return
@@ -187,6 +199,12 @@ export class LionWebReferenceValidator {
187
199
  this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, child, parent))
188
200
  }
189
201
 
202
+ /**
203
+ * Checks whether the `children` in the `containments` of `parent` have `parent` as their parent node.
204
+ * Only applicable when both `parent` and `child` are in the same LionWebJsonChunk being validated.
205
+ * @param node
206
+ * @param context
207
+ */
190
208
  validateChildrenHaveCorrectParent(node: LionWebJsonNode, context: JsonContext) {
191
209
  node.containments.forEach((child: LionWebJsonContainment) => {
192
210
  child.children.forEach((childId: LionWebId, index: number) => {
@@ -1,14 +1,21 @@
1
+ import { ChunksDefinitions, DeltaTypesDefinitions } from "./definitions/index.js"
2
+ import { SyntaxDefinition } from "./generic/index.js"
1
3
  import { SyntaxValidator } from "./generic/SyntaxValidator.js"
2
4
  import { ValidationResult } from "./generic/ValidationResult.js"
3
- import { LionWebSchema } from "./LionWebChunkDefinitions.js"
5
+ import { validateId, validateKey, validateSerializationFormatVersion, validateVersion } from "./ValidationFunctions.js"
4
6
 
5
- /**
7
+ const schema = new SyntaxDefinition([], [ChunksDefinitions, DeltaTypesDefinitions] )
8
+ schema.addValidator("LionWebId", validateId ),
9
+ schema.addValidator("LionWebKey", validateKey ),
10
+ schema.addValidator("LionWebVersion",validateVersion),
11
+ schema.addValidator("LionWebSerializationFormatVersion", validateSerializationFormatVersion)
12
+ /*
6
13
  * LionWebSyntaxValidator can check whether objects are structurally LionWeb objects.
7
14
  */
8
15
  export class LionWebSyntaxValidator extends SyntaxValidator {
9
16
 
10
17
  constructor(validationResult: ValidationResult) {
11
- super(validationResult, LionWebSchema)
18
+ super(validationResult, schema)
12
19
  }
13
20
  }
14
21
 
@@ -12,8 +12,8 @@ import {
12
12
  Syntax_SerializationFormatVersion_Issue,
13
13
  Syntax_VersionFormat_Issue
14
14
  } from "../issues/SyntaxIssues.js"
15
+ import { PropertyDefinition } from "./generic/index.js"
15
16
  import { ValidationResult } from "./generic/ValidationResult.js"
16
- import { PropertyDefinition } from "./generic/schema/ValidationTypes.js"
17
17
 
18
18
  /**
19
19
  * Check whether `id` is a valid LionWeb id.
@@ -0,0 +1,252 @@
1
+ import { TypeGroup } from "../generic/schema/SyntaxDefinition.js";
2
+
3
+ export const ChunksDefinitions: TypeGroup = {
4
+ name: "Chunks",
5
+ primitiveTypes: [
6
+ {
7
+ name: "LionWebId",
8
+ primitiveType: "string",
9
+ },
10
+ {
11
+ name: "LionWebKey",
12
+ primitiveType: "string",
13
+ },
14
+ {
15
+ name: "LionWebVersion",
16
+ primitiveType: "string",
17
+ },
18
+ {
19
+ name: "LionWebSerializationFormatVersion",
20
+ primitiveType: "string",
21
+ },
22
+ ],
23
+ structuredTypes: [
24
+ {
25
+ name: "LionWebJsonMetaPointer",
26
+ properties: [
27
+ {
28
+ name: "key",
29
+ type: "LionWebKey",
30
+ isList: false,
31
+ isOptional: false,
32
+ mayBeNull: false,
33
+ },
34
+ {
35
+ name: "version",
36
+ type: "LionWebVersion",
37
+ isList: false,
38
+ isOptional: false,
39
+ mayBeNull: false,
40
+ },
41
+ {
42
+ name: "language",
43
+ type: "LionWebKey",
44
+ isList: false,
45
+ isOptional: false,
46
+ mayBeNull: false,
47
+ },
48
+ ],
49
+ },
50
+ {
51
+ name: "ResponseMessage",
52
+ properties: [
53
+ {
54
+ name: "kind",
55
+ type: "String",
56
+ isList: false,
57
+ isOptional: false,
58
+ mayBeNull: false,
59
+ },
60
+ {
61
+ name: "message",
62
+ type: "String",
63
+ isList: false,
64
+ isOptional: false,
65
+ mayBeNull: false,
66
+ },
67
+ {
68
+ name: "data",
69
+ type: "KeyValuePair",
70
+ isList: false,
71
+ isOptional: true,
72
+ mayBeNull: true,
73
+ },
74
+ ],
75
+ },
76
+ {
77
+ name: "LionWebJsonChunk",
78
+ properties: [
79
+ {
80
+ name: "serializationFormatVersion",
81
+ type: "LionWebSerializationFormatVersion",
82
+ isList: false,
83
+ isOptional: false,
84
+ mayBeNull: false,
85
+ },
86
+ {
87
+ name: "languages",
88
+ type: "LionWebJsonUsedLanguage",
89
+ isList: true,
90
+ isOptional: false,
91
+ mayBeNull: false,
92
+ },
93
+ {
94
+ name: "nodes",
95
+ type: "LionWebJsonNode",
96
+ isList: true,
97
+ isOptional: false,
98
+ mayBeNull: false,
99
+ },
100
+ ],
101
+ },
102
+ {
103
+ name: "LionWebJsonUsedLanguage",
104
+ properties: [
105
+ {
106
+ name: "key",
107
+ type: "LionWebKey",
108
+ isList: false,
109
+ isOptional: false,
110
+ mayBeNull: false,
111
+ },
112
+ {
113
+ name: "version",
114
+ type: "LionWebVersion",
115
+ isList: false,
116
+ isOptional: false,
117
+ mayBeNull: false,
118
+ },
119
+ ],
120
+ },
121
+ {
122
+ name: "LionWebJsonNode",
123
+ properties: [
124
+ {
125
+ name: "id",
126
+ type: "LionWebId",
127
+ isList: false,
128
+ isOptional: false,
129
+ mayBeNull: false,
130
+ },
131
+ {
132
+ name: "classifier",
133
+ type: "LionWebJsonMetaPointer",
134
+ isList: false,
135
+ isOptional: false,
136
+ mayBeNull: false,
137
+ },
138
+ {
139
+ name: "properties",
140
+ type: "LionWebJsonProperty",
141
+ isList: true,
142
+ isOptional: false,
143
+ mayBeNull: false,
144
+ },
145
+ {
146
+ name: "containments",
147
+ type: "LionWebJsonContainment",
148
+ isList: true,
149
+ isOptional: false,
150
+ mayBeNull: false,
151
+ },
152
+ {
153
+ name: "references",
154
+ type: "LionWebJsonReference",
155
+ isList: true,
156
+ isOptional: false,
157
+ mayBeNull: false,
158
+ },
159
+ {
160
+ name: "annotations",
161
+ type: "LionWebId",
162
+ isList: true,
163
+ isOptional: false,
164
+ mayBeNull: false,
165
+ },
166
+ {
167
+ name: "parent",
168
+ type: "LionWebId",
169
+ isList: false,
170
+ isOptional: false,
171
+ mayBeNull: true,
172
+ },
173
+ ],
174
+ },
175
+ {
176
+ name: "LionWebJsonProperty",
177
+ properties: [
178
+ {
179
+ name: "property",
180
+ type: "LionWebJsonMetaPointer",
181
+ isList: false,
182
+ isOptional: false,
183
+ mayBeNull: false,
184
+ },
185
+ {
186
+ name: "value",
187
+ type: "String",
188
+ isList: false,
189
+ isOptional: false,
190
+ mayBeNull: true,
191
+ },
192
+ ],
193
+ },
194
+ {
195
+ name: "LionWebJsonContainment",
196
+ properties: [
197
+ {
198
+ name: "containment",
199
+ type: "LionWebJsonMetaPointer",
200
+ isList: false,
201
+ isOptional: false,
202
+ mayBeNull: false,
203
+ },
204
+ {
205
+ name: "children",
206
+ type: "LionWebId",
207
+ isList: true,
208
+ isOptional: false,
209
+ mayBeNull: false,
210
+ },
211
+ ],
212
+ },
213
+ {
214
+ name: "LionWebJsonReference",
215
+ properties: [
216
+ {
217
+ name: "reference",
218
+ type: "LionWebJsonMetaPointer",
219
+ isList: false,
220
+ isOptional: false,
221
+ mayBeNull: false,
222
+ },
223
+ {
224
+ name: "targets",
225
+ type: "LionWebJsonReferenceTarget",
226
+ isList: true,
227
+ isOptional: false,
228
+ mayBeNull: false,
229
+ },
230
+ ],
231
+ },
232
+ {
233
+ name: "LionWebJsonReferenceTarget",
234
+ properties: [
235
+ {
236
+ name: "resolveInfo",
237
+ type: "String",
238
+ isList: false,
239
+ isOptional: false,
240
+ mayBeNull: true,
241
+ },
242
+ {
243
+ name: "reference",
244
+ type: "LionWebId",
245
+ isList: false,
246
+ isOptional: false,
247
+ mayBeNull: true,
248
+ },
249
+ ],
250
+ },
251
+ ],
252
+ };