@api-client/core 0.17.0 → 0.17.2

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 (29) hide show
  1. package/bin/test.ts +0 -4
  2. package/build/src/index.d.ts +72 -72
  3. package/build/src/index.d.ts.map +1 -1
  4. package/build/src/index.js +3 -3
  5. package/build/src/index.js.map +1 -1
  6. package/build/src/modeling/GraphUtils.d.ts.map +1 -1
  7. package/build/src/modeling/GraphUtils.js +16 -4
  8. package/build/src/modeling/GraphUtils.js.map +1 -1
  9. package/build/src/modeling/Semantics.d.ts +3 -1
  10. package/build/src/modeling/Semantics.d.ts.map +1 -1
  11. package/build/src/modeling/Semantics.js +7 -1
  12. package/build/src/modeling/Semantics.js.map +1 -1
  13. package/build/tsconfig.tsbuildinfo +1 -1
  14. package/data/models/example-generator-api.json +11 -11
  15. package/package.json +1 -1
  16. package/src/modeling/GraphUtils.ts +15 -4
  17. package/src/modeling/Semantics.ts +7 -1
  18. package/tests/unit/modeling/api_model.spec.ts +25 -6
  19. package/tests/unit/modeling/data_domain.spec.ts +47 -47
  20. package/tests/unit/modeling/data_domain_associations.spec.ts +41 -30
  21. package/tests/unit/modeling/data_domain_change_observers.spec.ts +30 -6
  22. package/tests/unit/modeling/data_domain_entities.spec.ts +62 -62
  23. package/tests/unit/modeling/data_domain_foreign.spec.ts +59 -59
  24. package/tests/unit/modeling/data_domain_models.spec.ts +80 -82
  25. package/tests/unit/modeling/data_domain_namespaces.spec.ts +76 -76
  26. package/tests/unit/modeling/data_domain_property.spec.ts +29 -29
  27. package/tests/unit/modeling/data_domain_serialization.spec.ts +9 -9
  28. package/tests/unit/modeling/domain_asociation_targets.spec.ts +26 -26
  29. package/tests/unit/modeling/semantics.spec.ts +77 -0
@@ -10,7 +10,7 @@ test.group('DataDomain.addProperty()', () => {
10
10
  const property = dataDomain.addProperty(entity.key, { key: 'test-property' })
11
11
  assert.instanceOf(property, DomainProperty)
12
12
  assert.isTrue(dataDomain.graph.hasNode(property.key))
13
- })
13
+ }).tags(['@modeling', '@property', '@add'])
14
14
 
15
15
  test('addProperty adds a property with default values', ({ assert }) => {
16
16
  const dataDomain = new DataDomain()
@@ -21,14 +21,14 @@ test.group('DataDomain.addProperty()', () => {
21
21
  assert.isTrue(dataDomain.graph.hasNode(property.key))
22
22
  assert.equal(property.info.name, 'new_property')
23
23
  assert.equal(property.type, 'string')
24
- })
24
+ }).tags(['@modeling', '@property', '@add'])
25
25
 
26
26
  test('addProperty throws an error if parent entity does not exist', ({ assert }) => {
27
27
  const dataDomain = new DataDomain()
28
28
  assert.throws(() => {
29
29
  dataDomain.addProperty('non-existent-entity', { key: 'test-property' })
30
30
  }, 'Parent entity non-existent-entity does not exist')
31
- })
31
+ }).tags(['@modeling', '@property', '@add'])
32
32
 
33
33
  test('addProperty throws an error if parent is not an entity', ({ assert }) => {
34
34
  const dataDomain = new DataDomain()
@@ -36,7 +36,7 @@ test.group('DataDomain.addProperty()', () => {
36
36
  assert.throws(() => {
37
37
  dataDomain.addProperty(model.key)
38
38
  }, `Parent entity ${model.key} not found`)
39
- })
39
+ }).tags(['@modeling', '@property', '@add'])
40
40
 
41
41
  test('addProperty notifies change', async ({ assert }) => {
42
42
  const dataDomain = new DataDomain()
@@ -44,7 +44,7 @@ test.group('DataDomain.addProperty()', () => {
44
44
  const entity = dataDomain.addEntity(model.key)
45
45
  dataDomain.addProperty(entity.key)
46
46
  await assert.dispatches(dataDomain, 'change', { timeout: 20 })
47
- })
47
+ }).tags(['@modeling', '@property', '@add'])
48
48
 
49
49
  test('addProperty adds a property to a parent entity - checks parent-child relationship', ({ assert }) => {
50
50
  const dataDomain = new DataDomain()
@@ -52,7 +52,7 @@ test.group('DataDomain.addProperty()', () => {
52
52
  const entity = dataDomain.addEntity(model.key)
53
53
  const property = dataDomain.addProperty(entity.key)
54
54
  assert.isTrue(dataDomain.graph.hasEdge(entity.key, property.key))
55
- })
55
+ }).tags(['@modeling', '@property', '@add'])
56
56
 
57
57
  test('addProperty adds a property to a parent entity - checks items list', ({ assert }) => {
58
58
  const dataDomain = new DataDomain()
@@ -60,7 +60,7 @@ test.group('DataDomain.addProperty()', () => {
60
60
  const entity = dataDomain.addEntity(model.key)
61
61
  const property = dataDomain.addProperty(entity.key)
62
62
  assert.deepInclude([...entity.listProperties()], property)
63
- })
63
+ }).tags(['@modeling', '@property', '@add'])
64
64
 
65
65
  test('addProperty throws an error if no parent is provided', ({ assert }) => {
66
66
  const dataDomain = new DataDomain()
@@ -68,7 +68,7 @@ test.group('DataDomain.addProperty()', () => {
68
68
  // @ts-expect-error For testing purposes, we are passing undefined
69
69
  dataDomain.addProperty(undefined)
70
70
  }, 'A property expects a DomainEntity parent')
71
- })
71
+ }).tags(['@modeling', '@property', '@add'])
72
72
 
73
73
  test('addProperty throws when adding property to a foreign entity', ({ assert }) => {
74
74
  const domain1 = new DataDomain()
@@ -85,7 +85,7 @@ test.group('DataDomain.addProperty()', () => {
85
85
  assert.throws(() => {
86
86
  domain1.addProperty(`${domain2.key}:${e2.key}`)
87
87
  }, 'Cannot add a property to a foreign domain')
88
- })
88
+ }).tags(['@modeling', '@property', '@add'])
89
89
  })
90
90
 
91
91
  test.group('DataDomain.removeProperty()', () => {
@@ -96,14 +96,14 @@ test.group('DataDomain.removeProperty()', () => {
96
96
  const property = dataDomain.addProperty(entity.key)
97
97
  dataDomain.removeProperty(property.key)
98
98
  assert.isFalse(dataDomain.graph.hasNode(property.key))
99
- })
99
+ }).tags(['@modeling', '@property', '@remove'])
100
100
 
101
101
  test('throws an error if the property does not exist', ({ assert }) => {
102
102
  const dataDomain = new DataDomain()
103
103
  assert.throws(() => {
104
104
  dataDomain.removeProperty('non-existent-property')
105
105
  }, 'Property non-existent-property does not exist')
106
- })
106
+ }).tags(['@modeling', '@property', '@remove'])
107
107
 
108
108
  test('removes the property from the parent entity', ({ assert }) => {
109
109
  const dataDomain = new DataDomain()
@@ -112,7 +112,7 @@ test.group('DataDomain.removeProperty()', () => {
112
112
  const property = dataDomain.addProperty(entity.key)
113
113
  dataDomain.removeProperty(property.key)
114
114
  assert.isUndefined(entity.listProperties().next().value)
115
- })
115
+ }).tags(['@modeling', '@property', '@remove'])
116
116
 
117
117
  test('throws an error when the parent entity is not found', ({ assert }) => {
118
118
  const dataDomain = new DataDomain()
@@ -121,7 +121,7 @@ test.group('DataDomain.removeProperty()', () => {
121
121
  assert.throws(() => {
122
122
  dataDomain.removeProperty(property.key)
123
123
  }, `Parent entity not found for property ${property.key}`)
124
- })
124
+ }).tags(['@modeling', '@property', '@remove'])
125
125
 
126
126
  test('notifies change', async ({ assert }) => {
127
127
  const dataDomain = new DataDomain()
@@ -130,7 +130,7 @@ test.group('DataDomain.removeProperty()', () => {
130
130
  const property = dataDomain.addProperty(entity.key)
131
131
  dataDomain.removeProperty(property.key)
132
132
  await assert.dispatches(dataDomain, 'change', { timeout: 20 })
133
- })
133
+ }).tags(['@modeling', '@property', '@remove'])
134
134
 
135
135
  test('throws an error if the property is not of type DomainProperty', ({ assert }) => {
136
136
  const dataDomain = new DataDomain()
@@ -139,7 +139,7 @@ test.group('DataDomain.removeProperty()', () => {
139
139
  assert.throws(() => {
140
140
  dataDomain.removeProperty(model.key)
141
141
  }, `Property ${model.key} not found`)
142
- })
142
+ }).tags(['@modeling', '@property', '@remove'])
143
143
 
144
144
  test('throws an error if trying to remove a property from a foreign domain', ({ assert }) => {
145
145
  const domain1 = new DataDomain()
@@ -156,7 +156,7 @@ test.group('DataDomain.removeProperty()', () => {
156
156
  assert.throws(() => {
157
157
  domain1.removeProperty(`${domain2.key}:${property.key}`)
158
158
  }, 'Cannot remove a property from a foreign domain')
159
- })
159
+ }).tags(['@modeling', '@property', '@remove'])
160
160
 
161
161
  test('removes the property from the fields list', ({ assert }) => {
162
162
  const dataDomain = new DataDomain()
@@ -165,7 +165,7 @@ test.group('DataDomain.removeProperty()', () => {
165
165
  const property = dataDomain.addProperty(entity.key)
166
166
  dataDomain.removeProperty(property.key)
167
167
  assert.deepEqual([...entity.listFields()], [])
168
- })
168
+ }).tags(['@modeling', '@property', '@remove'])
169
169
  })
170
170
 
171
171
  test.group('DataDomain.findProperty()', () => {
@@ -176,75 +176,75 @@ test.group('DataDomain.findProperty()', () => {
176
176
  const property = dataDomain.addProperty(entity.key)
177
177
  const foundProperty = dataDomain.findProperty(property.key)
178
178
  assert.deepEqual(foundProperty, property)
179
- })
179
+ }).tags(['@modeling', '@property', '@find'])
180
180
 
181
181
  test('returns undefined if property does not exist', ({ assert }) => {
182
182
  const dataDomain = new DataDomain()
183
183
  const foundProperty = dataDomain.findProperty('non-existent-property')
184
184
  assert.isUndefined(foundProperty)
185
- })
185
+ }).tags(['@modeling', '@property', '@find'])
186
186
 
187
187
  test('returns undefined if key is not a property', ({ assert }) => {
188
188
  const dataDomain = new DataDomain()
189
189
  const model = dataDomain.addModel()
190
190
  const foundProperty = dataDomain.findProperty(model.key)
191
191
  assert.isUndefined(foundProperty)
192
- })
192
+ }).tags(['@modeling', '@property', '@find'])
193
193
 
194
194
  test('returns undefined if key is undefined', ({ assert }) => {
195
195
  const dataDomain = new DataDomain()
196
196
  // @ts-expect-error For testing purposes
197
197
  const foundProperty = dataDomain.findProperty(undefined)
198
198
  assert.isUndefined(foundProperty)
199
- })
199
+ }).tags(['@modeling', '@property', '@find'])
200
200
 
201
201
  test('returns undefined if key is null', ({ assert }) => {
202
202
  const dataDomain = new DataDomain()
203
203
  // @ts-expect-error For testing purposes
204
204
  const foundProperty = dataDomain.findProperty(null)
205
205
  assert.isUndefined(foundProperty)
206
- })
206
+ }).tags(['@modeling', '@property', '@find'])
207
207
 
208
208
  test('returns undefined if key is an empty string', ({ assert }) => {
209
209
  const dataDomain = new DataDomain()
210
210
  const foundProperty = dataDomain.findProperty('')
211
211
  assert.isUndefined(foundProperty)
212
- })
212
+ }).tags(['@modeling', '@property', '@find'])
213
213
 
214
214
  test('returns undefined if key is a number', ({ assert }) => {
215
215
  const dataDomain = new DataDomain()
216
216
  // @ts-expect-error For testing purposes
217
217
  const foundProperty = dataDomain.findProperty(123)
218
218
  assert.isUndefined(foundProperty)
219
- })
219
+ }).tags(['@modeling', '@property', '@find'])
220
220
 
221
221
  test('returns undefined if key is a boolean', ({ assert }) => {
222
222
  const dataDomain = new DataDomain()
223
223
  // @ts-expect-error For testing purposes
224
224
  const foundProperty = dataDomain.findProperty(true)
225
225
  assert.isUndefined(foundProperty)
226
- })
226
+ }).tags(['@modeling', '@property', '@find'])
227
227
 
228
228
  test('returns undefined if key is an object', ({ assert }) => {
229
229
  const dataDomain = new DataDomain()
230
230
  // @ts-expect-error For testing purposes
231
231
  const foundProperty = dataDomain.findProperty({})
232
232
  assert.isUndefined(foundProperty)
233
- })
233
+ }).tags(['@modeling', '@property', '@find'])
234
234
 
235
235
  test('returns undefined if key is an array', ({ assert }) => {
236
236
  const dataDomain = new DataDomain()
237
237
  // @ts-expect-error For testing purposes
238
238
  const foundProperty = dataDomain.findProperty([])
239
239
  assert.isUndefined(foundProperty)
240
- })
240
+ }).tags(['@modeling', '@property', '@find'])
241
241
 
242
242
  test('returns undefined if key is a function', ({ assert }) => {
243
243
  const dataDomain = new DataDomain()
244
244
  // @ts-expect-error For testing purposes
245
245
  const foundProperty = dataDomain.findProperty(() => {})
246
246
  assert.isUndefined(foundProperty)
247
- })
247
+ }).tags(['@modeling', '@property', '@find'])
248
248
 
249
249
  test('finds a property in a foreign domain', ({ assert }) => {
250
250
  const domain1 = new DataDomain()
@@ -260,5 +260,5 @@ test.group('DataDomain.findProperty()', () => {
260
260
 
261
261
  const foundProperty = domain1.findProperty(`${domain2.key}:${property.key}`)
262
262
  assert.deepEqual(foundProperty, property)
263
- })
263
+ }).tags(['@modeling', '@property', '@find'])
264
264
  })
@@ -19,7 +19,7 @@ test.group('DataDomain Serialization and Deserialization', () => {
19
19
  assert.deepEqual(restored.info.toJSON(), domain.info.toJSON())
20
20
  assert.equal([...restored.graph.nodes()].length, 0)
21
21
  assert.equal([...restored.graph.edges()].length, 0)
22
- })
22
+ }).tags(['@modeling', '@serialization'])
23
23
 
24
24
  test('should serialize and deserialize a DataDomain with namespaces', ({ assert }) => {
25
25
  const domain = new DataDomain()
@@ -45,7 +45,7 @@ test.group('DataDomain Serialization and Deserialization', () => {
45
45
  assert.equal(rn2!.key, ns2.key)
46
46
  assert.equal(rn2!.kind, DomainNamespaceKind)
47
47
  assert.equal(restored.graph.parent(ns2.key), ns1.key)
48
- })
48
+ }).tags(['@modeling', '@serialization'])
49
49
 
50
50
  test('should serialize and deserialize a DataDomain with models', ({ assert }) => {
51
51
  const domain = new DataDomain()
@@ -70,7 +70,7 @@ test.group('DataDomain Serialization and Deserialization', () => {
70
70
  assert.isDefined(rm2)
71
71
  assert.equal(rm2!.key, m2.key)
72
72
  assert.equal(rm2!.kind, DomainModelKind)
73
- })
73
+ }).tags(['@modeling', '@serialization'])
74
74
 
75
75
  test('should serialize and deserialize a DataDomain with entities', ({ assert }) => {
76
76
  const domain = new DataDomain()
@@ -98,7 +98,7 @@ test.group('DataDomain Serialization and Deserialization', () => {
98
98
  assert.equal(re2!.key, e2.key)
99
99
  assert.equal(re2!.kind, DomainEntityKind)
100
100
  assert.equal([...re2!.listParents()][0].key, e1.key)
101
- })
101
+ }).tags(['@modeling', '@serialization'])
102
102
 
103
103
  test('should serialize and deserialize a DataDomain with properties', ({ assert }) => {
104
104
  const domain = new DataDomain()
@@ -132,7 +132,7 @@ test.group('DataDomain Serialization and Deserialization', () => {
132
132
  assert.equal(props.length, 2)
133
133
  assert.equal(props[0].key, p1.key)
134
134
  assert.equal(props[1].key, p2.key)
135
- })
135
+ }).tags(['@modeling', '@serialization'])
136
136
 
137
137
  test('should serialize and deserialize a DataDomain with associations', ({ assert }) => {
138
138
  const domain = new DataDomain()
@@ -155,7 +155,7 @@ test.group('DataDomain Serialization and Deserialization', () => {
155
155
  assert.equal(ra1!.key, a1.key)
156
156
  assert.equal(ra1!.kind, DomainAssociationKind)
157
157
  assert.equal([...ra1!.listTargets()][0].key, e2.key)
158
- })
158
+ }).tags(['@modeling', '@serialization'])
159
159
 
160
160
  test('should serialize and deserialize a complex DataDomain', ({ assert }) => {
161
161
  const domain = new DataDomain()
@@ -236,7 +236,7 @@ test.group('DataDomain Serialization and Deserialization', () => {
236
236
  assert.equal(ra1!.key, a1.key)
237
237
  assert.equal(ra1!.kind, DomainAssociationKind)
238
238
  assert.equal([...ra1!.listTargets()][0].key, e2.key)
239
- })
239
+ }).tags(['@modeling', '@serialization'])
240
240
 
241
241
  test('should serialize and deserialize a DataDomain with foreign dependencies', ({ assert }) => {
242
242
  const fd = new DataDomain()
@@ -265,7 +265,7 @@ test.group('DataDomain Serialization and Deserialization', () => {
265
265
  // Associations look like: Entity -> (edge) -> Association -> (edge) -> ForeignEntity
266
266
  assert.isTrue(restored.graph.hasEdge(e1.key, a1.key), 'has edge from e1 to a1')
267
267
  assert.isTrue(restored.graph.hasEdge(a1.key, `${fd.key}:${fe1.key}`), 'has edge from a1 to fe1')
268
- })
268
+ }).tags(['@modeling', '@serialization'])
269
269
 
270
270
  test('should serialize and deserialize a DataDomain with missing foreign dependencies', ({ assert }) => {
271
271
  const fd = new DataDomain()
@@ -290,5 +290,5 @@ test.group('DataDomain Serialization and Deserialization', () => {
290
290
  assert.equal([...restored.graph.edges()].length, 1)
291
291
  assert.isTrue(restored.graph.hasEdge(e1.key, a1.key), 'has edge from e1 to a1')
292
292
  assert.isFalse(restored.graph.hasEdge(a1.key, `${fd.key}:${fe1.key}`), 'has no edge from a1 to fe1')
293
- })
293
+ }).tags(['@modeling', '@serialization'])
294
294
  })
@@ -11,7 +11,7 @@ test.group('DomainAssociation.addTarget()', () => {
11
11
  association.addTarget(entity2)
12
12
  assert.deepEqual(association.targets, [{ key: entity2.key }])
13
13
  assert.isTrue(dataDomain.graph.hasEdge(association.key, entity2.key))
14
- })
14
+ }).tags(['@modeling', '@association', '@target', '@add'])
15
15
 
16
16
  test('adds a target entity by key to the association', ({ assert }) => {
17
17
  const dataDomain = new DataDomain()
@@ -22,7 +22,7 @@ test.group('DomainAssociation.addTarget()', () => {
22
22
  association.addTarget(entity2.key)
23
23
  assert.deepEqual(association.targets, [{ key: entity2.key }])
24
24
  assert.isTrue(dataDomain.graph.hasEdge(association.key, entity2.key))
25
- })
25
+ }).tags(['@modeling', '@association', '@target', '@add'])
26
26
 
27
27
  test('adds a target entity with a foreign namespace', ({ assert }) => {
28
28
  const dataDomain = new DataDomain()
@@ -37,7 +37,7 @@ test.group('DomainAssociation.addTarget()', () => {
37
37
  association.addTarget(entity2.key, foreignDomain.key)
38
38
  assert.deepEqual(association.targets, [{ key: entity2.key, domain: foreignDomain.key }])
39
39
  assert.isTrue(dataDomain.graph.hasEdge(association.key, `${foreignDomain.key}:${entity2.key}`))
40
- })
40
+ }).tags(['@modeling', '@association', '@target', '@add'])
41
41
 
42
42
  test('throws an error if the target entity already exists', ({ assert }) => {
43
43
  const dataDomain = new DataDomain()
@@ -49,7 +49,7 @@ test.group('DomainAssociation.addTarget()', () => {
49
49
  assert.throws(() => {
50
50
  association.addTarget(entity2)
51
51
  }, `Target ${entity2.key} already exists.`)
52
- })
52
+ }).tags(['@modeling', '@association', '@target', '@add'])
53
53
 
54
54
  test('throws an error if the foreign namespace does not exist', ({ assert }) => {
55
55
  const dataDomain = new DataDomain()
@@ -60,7 +60,7 @@ test.group('DomainAssociation.addTarget()', () => {
60
60
  assert.throws(() => {
61
61
  association.addTarget(entity2.key, 'non-existent-namespace')
62
62
  }, 'Foreign namespace "non-existent-namespace" does not exist.')
63
- })
63
+ }).tags(['@modeling', '@association', '@target', '@add'])
64
64
 
65
65
  test('notifies change', async ({ assert }) => {
66
66
  const dataDomain = new DataDomain()
@@ -70,7 +70,7 @@ test.group('DomainAssociation.addTarget()', () => {
70
70
  const association = new DomainAssociation(dataDomain, entity1.key)
71
71
  association.addTarget(entity2)
72
72
  await assert.dispatches(dataDomain, 'change', { timeout: 20 })
73
- })
73
+ }).tags(['@modeling', '@association', '@target', '@add'])
74
74
 
75
75
  test('creates a graph edge', ({ assert }) => {
76
76
  const dataDomain = new DataDomain()
@@ -81,7 +81,7 @@ test.group('DomainAssociation.addTarget()', () => {
81
81
  association.addTarget(entity2)
82
82
  assert.isTrue(dataDomain.graph.hasEdge(association.key, entity2.key))
83
83
  assert.deepEqual(dataDomain.graph.edge(association.key, entity2.key), { type: 'association' })
84
- })
84
+ }).tags(['@modeling', '@association', '@target', '@add'])
85
85
 
86
86
  test('adds a target entity to the association with a foreign domain', ({ assert }) => {
87
87
  const dataDomain = new DataDomain()
@@ -96,7 +96,7 @@ test.group('DomainAssociation.addTarget()', () => {
96
96
  association.addTarget(entity2)
97
97
  assert.deepEqual(association.targets, [{ key: entity2.key, domain: foreignDomain.key }])
98
98
  assert.isTrue(dataDomain.graph.hasEdge(association.key, `${foreignDomain.key}:${entity2.key}`))
99
- })
99
+ }).tags(['@modeling', '@association', '@target', '@add'])
100
100
 
101
101
  test('adds a target entity to the association with a foreign domain - entity instance', ({ assert }) => {
102
102
  const dataDomain = new DataDomain()
@@ -111,7 +111,7 @@ test.group('DomainAssociation.addTarget()', () => {
111
111
  association.addTarget(entity2)
112
112
  assert.deepEqual(association.targets, [{ key: entity2.key, domain: foreignDomain.key }])
113
113
  assert.isTrue(dataDomain.graph.hasEdge(association.key, `${foreignDomain.key}:${entity2.key}`))
114
- })
114
+ }).tags(['@modeling', '@association', '@target', '@add'])
115
115
 
116
116
  test('throws an error if the foreign namespace does not exist when adding a target entity with a foreign domain', ({
117
117
  assert,
@@ -123,7 +123,7 @@ test.group('DomainAssociation.addTarget()', () => {
123
123
  assert.throws(() => {
124
124
  association.addTarget('test-entity', 'non-existent-domain')
125
125
  }, 'Foreign namespace "non-existent-domain" does not exist.')
126
- })
126
+ }).tags(['@modeling', '@association', '@target', '@add'])
127
127
 
128
128
  test('throws an error if the target entity already exists with the same foreign namespace', ({ assert }) => {
129
129
  const dataDomain = new DataDomain()
@@ -139,7 +139,7 @@ test.group('DomainAssociation.addTarget()', () => {
139
139
  assert.throws(() => {
140
140
  association.addTarget(entity2)
141
141
  }, `Target ${entity2.key} already exists.`)
142
- })
142
+ }).tags(['@modeling', '@association', '@target', '@add'])
143
143
  })
144
144
 
145
145
  test.group('DomainAssociation.removeTarget()', () => {
@@ -153,7 +153,7 @@ test.group('DomainAssociation.removeTarget()', () => {
153
153
  association.removeTarget(entity2)
154
154
  assert.deepEqual(association.targets, [])
155
155
  assert.isFalse(dataDomain.graph.hasEdge(association.key, entity2.key))
156
- })
156
+ }).tags(['@modeling', '@association', '@target', '@remove'])
157
157
 
158
158
  test('removes a target entity by key from the targets list', ({ assert }) => {
159
159
  const dataDomain = new DataDomain()
@@ -165,7 +165,7 @@ test.group('DomainAssociation.removeTarget()', () => {
165
165
  association.removeTarget(entity2.key)
166
166
  assert.deepEqual(association.targets, [])
167
167
  assert.isFalse(dataDomain.graph.hasEdge(association.key, entity2.key))
168
- })
168
+ }).tags(['@modeling', '@association', '@target', '@remove'])
169
169
 
170
170
  test('does not throw an error if the target entity does not exist', ({ assert }) => {
171
171
  const dataDomain = new DataDomain()
@@ -174,7 +174,7 @@ test.group('DomainAssociation.removeTarget()', () => {
174
174
  const association = new DomainAssociation(dataDomain, entity1.key)
175
175
  association.removeTarget('non-existent-entity')
176
176
  assert.deepEqual(association.targets, [])
177
- })
177
+ }).tags(['@modeling', '@association', '@target', '@remove'])
178
178
 
179
179
  test('notifies change', async ({ assert }) => {
180
180
  const dataDomain = new DataDomain()
@@ -185,7 +185,7 @@ test.group('DomainAssociation.removeTarget()', () => {
185
185
  association.addTarget(entity2)
186
186
  association.removeTarget(entity2)
187
187
  await assert.dispatches(dataDomain, 'change', { timeout: 20 })
188
- })
188
+ }).tags(['@modeling', '@association', '@target', '@remove'])
189
189
 
190
190
  test('removes the graph edge', ({ assert }) => {
191
191
  const dataDomain = new DataDomain()
@@ -196,7 +196,7 @@ test.group('DomainAssociation.removeTarget()', () => {
196
196
  association.addTarget(entity2)
197
197
  association.removeTarget(entity2)
198
198
  assert.isFalse(dataDomain.graph.hasEdge(association.key, entity2.key))
199
- })
199
+ }).tags(['@modeling', '@association', '@target', '@remove'])
200
200
 
201
201
  test('removes a target entity with a foreign namespace', ({ assert }) => {
202
202
  const dataDomain = new DataDomain()
@@ -212,7 +212,7 @@ test.group('DomainAssociation.removeTarget()', () => {
212
212
  association.removeTarget(entity2.key)
213
213
  assert.deepEqual(association.targets, [])
214
214
  assert.isFalse(dataDomain.graph.hasEdge(association.key, entity2.key))
215
- })
215
+ }).tags(['@modeling', '@association', '@target', '@remove'])
216
216
 
217
217
  test('removes a target entity with a foreign namespace - entity instance', ({ assert }) => {
218
218
  const dataDomain = new DataDomain()
@@ -228,7 +228,7 @@ test.group('DomainAssociation.removeTarget()', () => {
228
228
  association.removeTarget(entity2)
229
229
  assert.deepEqual(association.targets, [])
230
230
  assert.isFalse(dataDomain.graph.hasEdge(association.key, entity2.key))
231
- })
231
+ }).tags(['@modeling', '@association', '@target', '@remove'])
232
232
 
233
233
  test('removes only the specified target entity', ({ assert }) => {
234
234
  const dataDomain = new DataDomain()
@@ -243,7 +243,7 @@ test.group('DomainAssociation.removeTarget()', () => {
243
243
  assert.deepEqual(association.targets, [{ key: entity3.key }])
244
244
  assert.isFalse(dataDomain.graph.hasEdge(association.key, entity2.key))
245
245
  assert.isTrue(dataDomain.graph.hasEdge(association.key, entity3.key))
246
- })
246
+ }).tags(['@modeling', '@association', '@target', '@remove'])
247
247
  })
248
248
 
249
249
  test.group('DomainAssociation.listTargets()', () => {
@@ -260,7 +260,7 @@ test.group('DomainAssociation.listTargets()', () => {
260
260
  assert.lengthOf(targets, 2)
261
261
  assert.deepInclude(targets, entity2)
262
262
  assert.deepInclude(targets, entity3)
263
- })
263
+ }).tags(['@modeling', '@association', '@target', '@list'])
264
264
 
265
265
  test('returns an empty array if there are no target entities', ({ assert }) => {
266
266
  const dataDomain = new DataDomain()
@@ -269,7 +269,7 @@ test.group('DomainAssociation.listTargets()', () => {
269
269
  const association = new DomainAssociation(dataDomain, entity1.key)
270
270
  const targets = [...association.listTargets()]
271
271
  assert.lengthOf(targets, 0)
272
- })
272
+ }).tags(['@modeling', '@association', '@target', '@list'])
273
273
 
274
274
  test('returns only entities that exist in the graph', ({ assert }) => {
275
275
  const dataDomain = new DataDomain()
@@ -282,7 +282,7 @@ test.group('DomainAssociation.listTargets()', () => {
282
282
  const targets = [...association.listTargets()]
283
283
  assert.lengthOf(targets, 1)
284
284
  assert.deepInclude(targets, entity2)
285
- })
285
+ }).tags(['@modeling', '@association', '@target', '@list'])
286
286
 
287
287
  test('lists target entities with foreign namespaces', ({ assert }) => {
288
288
  const dataDomain = new DataDomain()
@@ -299,7 +299,7 @@ test.group('DomainAssociation.listTargets()', () => {
299
299
  const targets = [...association.listTargets()]
300
300
  assert.lengthOf(targets, 1)
301
301
  assert.deepInclude(targets, dataDomain.findForeignEntity(entity2.key, foreignDomain.key)!)
302
- })
302
+ }).tags(['@modeling', '@association', '@target', '@list'])
303
303
 
304
304
  test('lists target entities when some targets are from foreign namespaces and some are local', ({ assert }) => {
305
305
  const dataDomain = new DataDomain()
@@ -318,7 +318,7 @@ test.group('DomainAssociation.listTargets()', () => {
318
318
  assert.lengthOf(targets, 2)
319
319
  assert.deepInclude(targets, entity2)
320
320
  assert.deepInclude(targets, dataDomain.findForeignEntity(entity3.key, foreignDomain.key)!)
321
- })
321
+ }).tags(['@modeling', '@association', '@target', '@list'])
322
322
 
323
323
  test('lists target entities when the target entity is added as an instance', ({ assert }) => {
324
324
  const dataDomain = new DataDomain()
@@ -330,7 +330,7 @@ test.group('DomainAssociation.listTargets()', () => {
330
330
  const targets = [...association.listTargets()]
331
331
  assert.lengthOf(targets, 1)
332
332
  assert.deepInclude(targets, entity2)
333
- })
333
+ }).tags(['@modeling', '@association', '@target', '@list'])
334
334
 
335
335
  test('lists target entities when the target entity is added as an instance from a foreign domain', ({ assert }) => {
336
336
  const dataDomain = new DataDomain()
@@ -346,5 +346,5 @@ test.group('DomainAssociation.listTargets()', () => {
346
346
  const targets = [...association.listTargets()]
347
347
  assert.lengthOf(targets, 1)
348
348
  assert.deepInclude(targets, dataDomain.findForeignEntity(entity2.key, foreignDomain.key)!)
349
- })
349
+ }).tags(['@modeling', '@association', '@target', '@list'])
350
350
  })
@@ -247,6 +247,83 @@ test.group('Semantics', () => {
247
247
  assert.equal(totalSemantics, allSemantics, 'All semantics should be categorized')
248
248
  })
249
249
 
250
+ test('getSemanticsByCategory should filter by Entity scope', ({ assert }) => {
251
+ const semanticsByCategory = getSemanticsByCategory(SemanticScope.Entity)
252
+ const allEntitySemantics = Object.values(DataSemantics).filter((s) => s.scope === SemanticScope.Entity)
253
+
254
+ // Ensure only Entity scope semantics are present
255
+ Object.values(semanticsByCategory).forEach((categorySemantics) => {
256
+ categorySemantics.forEach((semantic) => {
257
+ assert.equal(semantic.scope, SemanticScope.Entity, 'Only Entity semantics should be returned')
258
+ })
259
+ })
260
+
261
+ // Ensure all Entity scope semantics are returned
262
+ const returnedEntitySemantics = Object.values(semanticsByCategory).flat()
263
+ assert.equal(returnedEntitySemantics.length, allEntitySemantics.length, 'All Entity semantics should be returned')
264
+ allEntitySemantics.forEach((expectedSemantic) => {
265
+ assert.include(
266
+ returnedEntitySemantics,
267
+ expectedSemantic,
268
+ `Expected Entity semantic ${expectedSemantic.id} not found`
269
+ )
270
+ })
271
+ })
272
+
273
+ test('getSemanticsByCategory should filter by Property scope', ({ assert }) => {
274
+ const semanticsByCategory = getSemanticsByCategory(SemanticScope.Property)
275
+ const allPropertySemantics = Object.values(DataSemantics).filter((s) => s.scope === SemanticScope.Property)
276
+
277
+ // Ensure only Property scope semantics are present
278
+ Object.values(semanticsByCategory).forEach((categorySemantics) => {
279
+ categorySemantics.forEach((semantic) => {
280
+ assert.equal(semantic.scope, SemanticScope.Property, 'Only Property semantics should be returned')
281
+ })
282
+ })
283
+
284
+ // Ensure all Property scope semantics are returned
285
+ const returnedPropertySemantics = Object.values(semanticsByCategory).flat()
286
+ assert.equal(
287
+ returnedPropertySemantics.length,
288
+ allPropertySemantics.length,
289
+ 'All Property semantics should be returned'
290
+ )
291
+ allPropertySemantics.forEach((expectedSemantic) => {
292
+ assert.include(
293
+ returnedPropertySemantics,
294
+ expectedSemantic,
295
+ `Expected Property semantic ${expectedSemantic.id} not found`
296
+ )
297
+ })
298
+ })
299
+
300
+ test('getSemanticsByCategory should filter by Association scope', ({ assert }) => {
301
+ const semanticsByCategory = getSemanticsByCategory(SemanticScope.Association)
302
+ const allAssociationSemantics = Object.values(DataSemantics).filter((s) => s.scope === SemanticScope.Association)
303
+
304
+ // Ensure only Association scope semantics are present
305
+ Object.values(semanticsByCategory).forEach((categorySemantics) => {
306
+ categorySemantics.forEach((semantic) => {
307
+ assert.equal(semantic.scope, SemanticScope.Association, 'Only Association semantics should be returned')
308
+ })
309
+ })
310
+
311
+ // Ensure all Association scope semantics are returned
312
+ const returnedAssociationSemantics = Object.values(semanticsByCategory).flat()
313
+ assert.equal(
314
+ returnedAssociationSemantics.length,
315
+ allAssociationSemantics.length,
316
+ 'All Association semantics should be returned'
317
+ )
318
+ allAssociationSemantics.forEach((expectedSemantic) => {
319
+ assert.include(
320
+ returnedAssociationSemantics,
321
+ expectedSemantic,
322
+ `Expected Association semantic ${expectedSemantic.id} not found`
323
+ )
324
+ })
325
+ })
326
+
250
327
  test('getSemanticsByCategoryType should filter semantics by category', ({ assert }) => {
251
328
  const identitySemantics = getSemanticsByCategoryType(SemanticCategory.Identity)
252
329