@api-client/core 0.16.1 → 0.17.1
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.
- package/bin/test.ts +0 -4
- package/build/src/index.d.ts +72 -72
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +3 -3
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/GraphUtils.d.ts.map +1 -1
- package/build/src/modeling/GraphUtils.js +16 -4
- package/build/src/modeling/GraphUtils.js.map +1 -1
- package/build/src/modeling/Semantics.d.ts +52 -0
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +206 -97
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +12 -12
- package/package.json +1 -1
- package/src/modeling/GraphUtils.ts +15 -4
- package/src/modeling/Semantics.ts +226 -101
- package/tests/unit/modeling/api_model.spec.ts +25 -6
- package/tests/unit/modeling/data_domain.spec.ts +47 -47
- package/tests/unit/modeling/data_domain_associations.spec.ts +41 -30
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +30 -6
- package/tests/unit/modeling/data_domain_entities.spec.ts +62 -62
- package/tests/unit/modeling/data_domain_foreign.spec.ts +59 -59
- package/tests/unit/modeling/data_domain_models.spec.ts +80 -82
- package/tests/unit/modeling/data_domain_namespaces.spec.ts +76 -76
- package/tests/unit/modeling/data_domain_property.spec.ts +29 -29
- package/tests/unit/modeling/data_domain_serialization.spec.ts +9 -9
- package/tests/unit/modeling/domain_asociation_targets.spec.ts +26 -26
- package/tests/unit/modeling/semantics.spec.ts +73 -1
|
@@ -17,13 +17,13 @@ test.group('DataDomain', () => {
|
|
|
17
17
|
assert.isNotEmpty(dataDomain.key)
|
|
18
18
|
assert.isDefined(dataDomain.graph)
|
|
19
19
|
assert.deepEqual(dataDomain.fields, [])
|
|
20
|
-
})
|
|
20
|
+
}).tags(['@modeling', '@datadomain', '@core', '@unit', '@fast'])
|
|
21
21
|
|
|
22
22
|
test('notifyChange dispatches a change event', async ({ assert }) => {
|
|
23
23
|
const dataDomain = new DataDomain()
|
|
24
24
|
dataDomain.notifyChange()
|
|
25
25
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
26
|
-
})
|
|
26
|
+
}).tags(['@modeling', '@datadomain', '@core', '@unit', '@events', '@async'])
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
test.group('DataDomain.removeDomainElement()', () => {
|
|
@@ -33,7 +33,7 @@ test.group('DataDomain.removeDomainElement()', () => {
|
|
|
33
33
|
dataDomain.removeDomainElement(namespace.key, DomainNamespaceKind)
|
|
34
34
|
assert.isUndefined(dataDomain.findNamespace(namespace.key))
|
|
35
35
|
assert.isFalse(dataDomain.graph.hasNode(namespace.key))
|
|
36
|
-
})
|
|
36
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
37
37
|
|
|
38
38
|
test('removes a data model', ({ assert }) => {
|
|
39
39
|
const dataDomain = new DataDomain()
|
|
@@ -41,7 +41,7 @@ test.group('DataDomain.removeDomainElement()', () => {
|
|
|
41
41
|
dataDomain.removeDomainElement(model.key, DomainModelKind)
|
|
42
42
|
assert.isUndefined(dataDomain.findModel(model.key))
|
|
43
43
|
assert.isFalse(dataDomain.graph.hasNode(model.key))
|
|
44
|
-
})
|
|
44
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
45
45
|
|
|
46
46
|
test('removes an entity', ({ assert }) => {
|
|
47
47
|
const dataDomain = new DataDomain()
|
|
@@ -50,7 +50,7 @@ test.group('DataDomain.removeDomainElement()', () => {
|
|
|
50
50
|
dataDomain.removeDomainElement(entity.key, DomainEntityKind)
|
|
51
51
|
assert.isUndefined(dataDomain.findEntity(entity.key))
|
|
52
52
|
assert.isFalse(dataDomain.graph.hasNode(entity.key))
|
|
53
|
-
})
|
|
53
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
54
54
|
|
|
55
55
|
test('removes a property', ({ assert }) => {
|
|
56
56
|
const dataDomain = new DataDomain()
|
|
@@ -60,7 +60,7 @@ test.group('DataDomain.removeDomainElement()', () => {
|
|
|
60
60
|
dataDomain.removeDomainElement(property.key, DomainPropertyKind)
|
|
61
61
|
assert.isUndefined(dataDomain.findProperty(property.key))
|
|
62
62
|
assert.isFalse(dataDomain.graph.hasNode(property.key))
|
|
63
|
-
})
|
|
63
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
64
64
|
|
|
65
65
|
test('removes an association', ({ assert }) => {
|
|
66
66
|
const dataDomain = new DataDomain()
|
|
@@ -70,49 +70,49 @@ test.group('DataDomain.removeDomainElement()', () => {
|
|
|
70
70
|
dataDomain.removeDomainElement(association.key, DomainAssociationKind)
|
|
71
71
|
assert.isUndefined(dataDomain.findAssociation(association.key))
|
|
72
72
|
assert.isFalse(dataDomain.graph.hasNode(association.key))
|
|
73
|
-
})
|
|
73
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
74
74
|
|
|
75
75
|
test('throws an error for an unknown kind', ({ assert }) => {
|
|
76
76
|
const dataDomain = new DataDomain()
|
|
77
77
|
assert.throws(() => {
|
|
78
78
|
dataDomain.removeDomainElement('test-unknown', 'unknown-kind')
|
|
79
79
|
}, 'Unknown kind unknown-kind for the object test-unknown')
|
|
80
|
-
})
|
|
80
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
81
81
|
|
|
82
82
|
test('throws an error when removing a non-existing namespace', ({ assert }) => {
|
|
83
83
|
const dataDomain = new DataDomain()
|
|
84
84
|
assert.throws(() => {
|
|
85
85
|
dataDomain.removeDomainElement('non-existent-namespace', DomainNamespaceKind)
|
|
86
86
|
}, `Namespace non-existent-namespace does not exist`)
|
|
87
|
-
})
|
|
87
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
88
88
|
|
|
89
89
|
test('throws an error when removing a non-existing model', ({ assert }) => {
|
|
90
90
|
const dataDomain = new DataDomain()
|
|
91
91
|
assert.throws(() => {
|
|
92
92
|
dataDomain.removeDomainElement('non-existent-model', DomainModelKind)
|
|
93
93
|
}, `Data model non-existent-model does not exist`)
|
|
94
|
-
})
|
|
94
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
95
95
|
|
|
96
96
|
test('throws an error when removing a non-existing entity', ({ assert }) => {
|
|
97
97
|
const dataDomain = new DataDomain()
|
|
98
98
|
assert.throws(() => {
|
|
99
99
|
dataDomain.removeDomainElement('non-existent-entity', DomainEntityKind)
|
|
100
100
|
}, `Entity non-existent-entity does not exist`)
|
|
101
|
-
})
|
|
101
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
102
102
|
|
|
103
103
|
test('throws an error when removing a non-existing property', ({ assert }) => {
|
|
104
104
|
const dataDomain = new DataDomain()
|
|
105
105
|
assert.throws(() => {
|
|
106
106
|
dataDomain.removeDomainElement('non-existent-property', DomainPropertyKind)
|
|
107
107
|
}, `Property non-existent-property does not exist`)
|
|
108
|
-
})
|
|
108
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
109
109
|
|
|
110
110
|
test('throws an error when removing a non-existing association', ({ assert }) => {
|
|
111
111
|
const dataDomain = new DataDomain()
|
|
112
112
|
assert.throws(() => {
|
|
113
113
|
dataDomain.removeDomainElement('non-existent-association', DomainAssociationKind)
|
|
114
114
|
}, `Association non-existent-association does not exist`)
|
|
115
|
-
})
|
|
115
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
116
116
|
|
|
117
117
|
test('removes a namespace with children', ({ assert }) => {
|
|
118
118
|
const dataDomain = new DataDomain()
|
|
@@ -138,7 +138,7 @@ test.group('DataDomain.removeDomainElement()', () => {
|
|
|
138
138
|
assert.isFalse(dataDomain.graph.hasNode(entity.key))
|
|
139
139
|
assert.isFalse(dataDomain.graph.hasNode(property.key))
|
|
140
140
|
assert.isFalse(dataDomain.graph.hasNode(association.key))
|
|
141
|
-
})
|
|
141
|
+
}).tags(['@modeling', '@datadomain', '@crud', '@removal'])
|
|
142
142
|
})
|
|
143
143
|
|
|
144
144
|
test.group('DataDomain.createSchema()', () => {
|
|
@@ -151,7 +151,7 @@ test.group('DataDomain.createSchema()', () => {
|
|
|
151
151
|
assert.isUndefined(schema.graph)
|
|
152
152
|
assert.isUndefined(schema.dependencyList)
|
|
153
153
|
assert.isUndefined(schema.fields)
|
|
154
|
-
})
|
|
154
|
+
}).tags(['@modeling', '@datadomain', '@schema', '@factory'])
|
|
155
155
|
|
|
156
156
|
test('creates a schema with provided values', ({ assert }) => {
|
|
157
157
|
const schema = DataDomain.createSchema({
|
|
@@ -167,7 +167,7 @@ test.group('DataDomain.createSchema()', () => {
|
|
|
167
167
|
assert.deepEqual(schema.graph, { nodes: [], edges: [], options: {} })
|
|
168
168
|
assert.deepEqual(schema.dependencyList, [{ key: 'dep1', version: '1.0.0' }])
|
|
169
169
|
assert.deepEqual(schema.fields, [{ key: 'field1', type: 'namespace' }])
|
|
170
|
-
})
|
|
170
|
+
}).tags(['@modeling', '@datadomain', '@schema', '@factory'])
|
|
171
171
|
|
|
172
172
|
test('creates a schema with partial info', ({ assert }) => {
|
|
173
173
|
const schema = DataDomain.createSchema({
|
|
@@ -177,7 +177,7 @@ test.group('DataDomain.createSchema()', () => {
|
|
|
177
177
|
assert.typeOf(schema.key, 'string')
|
|
178
178
|
assert.isNotEmpty(schema.key)
|
|
179
179
|
assert.deepInclude(schema.info, { name: 'Test Domain' })
|
|
180
|
-
})
|
|
180
|
+
}).tags(['@modeling', '@datadomain', '@schema', '@factory'])
|
|
181
181
|
|
|
182
182
|
test('creates a schema with empty info', ({ assert }) => {
|
|
183
183
|
const schema = DataDomain.createSchema({
|
|
@@ -187,7 +187,7 @@ test.group('DataDomain.createSchema()', () => {
|
|
|
187
187
|
assert.typeOf(schema.key, 'string')
|
|
188
188
|
assert.isNotEmpty(schema.key)
|
|
189
189
|
assert.deepInclude(schema.info, { name: 'Unnamed domain' })
|
|
190
|
-
})
|
|
190
|
+
}).tags(['@modeling', '@datadomain', '@schema', '@factory'])
|
|
191
191
|
|
|
192
192
|
test('creates a schema with dependencyList', ({ assert }) => {
|
|
193
193
|
const schema = DataDomain.createSchema({
|
|
@@ -198,7 +198,7 @@ test.group('DataDomain.createSchema()', () => {
|
|
|
198
198
|
assert.isNotEmpty(schema.key)
|
|
199
199
|
assert.deepInclude(schema.info, { name: 'Unnamed domain' })
|
|
200
200
|
assert.deepEqual(schema.dependencyList, [{ key: 'dep1', version: '1.0.0' }])
|
|
201
|
-
})
|
|
201
|
+
}).tags(['@modeling', '@datadomain', '@schema', '@factory'])
|
|
202
202
|
|
|
203
203
|
test('creates a schema with graph', ({ assert }) => {
|
|
204
204
|
const schema = DataDomain.createSchema({
|
|
@@ -209,7 +209,7 @@ test.group('DataDomain.createSchema()', () => {
|
|
|
209
209
|
assert.isNotEmpty(schema.key)
|
|
210
210
|
assert.deepInclude(schema.info, { name: 'Unnamed domain' })
|
|
211
211
|
assert.deepEqual(schema.graph, { nodes: [], edges: [], options: {} })
|
|
212
|
-
})
|
|
212
|
+
}).tags(['@modeling', '@datadomain', '@schema', '@factory'])
|
|
213
213
|
|
|
214
214
|
test('creates a schema with fields', ({ assert }) => {
|
|
215
215
|
const schema = DataDomain.createSchema({
|
|
@@ -220,7 +220,7 @@ test.group('DataDomain.createSchema()', () => {
|
|
|
220
220
|
assert.isNotEmpty(schema.key)
|
|
221
221
|
assert.deepInclude(schema.info, { name: 'Unnamed domain' })
|
|
222
222
|
assert.deepEqual(schema.fields, [{ key: 'field1', type: 'namespace' }])
|
|
223
|
-
})
|
|
223
|
+
}).tags(['@modeling', '@datadomain', '@schema', '@factory'])
|
|
224
224
|
})
|
|
225
225
|
|
|
226
226
|
test.group('DataDomain.constructor()', () => {
|
|
@@ -233,7 +233,7 @@ test.group('DataDomain.constructor()', () => {
|
|
|
233
233
|
assert.deepInclude(dataDomain.info.toJSON(), { name: 'Unnamed domain' })
|
|
234
234
|
assert.isDefined(dataDomain.graph)
|
|
235
235
|
assert.deepEqual(dataDomain.dependencyList, [])
|
|
236
|
-
})
|
|
236
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
237
237
|
|
|
238
238
|
test('creates a new DataDomain with provided values', ({ assert }) => {
|
|
239
239
|
const dataDomain = new DataDomain({
|
|
@@ -247,7 +247,7 @@ test.group('DataDomain.constructor()', () => {
|
|
|
247
247
|
assert.deepInclude(dataDomain.info.toJSON(), { name: 'Test Domain', description: 'A test domain' })
|
|
248
248
|
assert.isDefined(dataDomain.graph)
|
|
249
249
|
assert.deepEqual(dataDomain.dependencyList, [{ key: 'dep1', version: '1.0.0' }])
|
|
250
|
-
})
|
|
250
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
251
251
|
|
|
252
252
|
test('creates a new DataDomain with partial info', ({ assert }) => {
|
|
253
253
|
const dataDomain = new DataDomain({
|
|
@@ -258,7 +258,7 @@ test.group('DataDomain.constructor()', () => {
|
|
|
258
258
|
assert.isNotEmpty(dataDomain.key)
|
|
259
259
|
assert.instanceOf(dataDomain.info, Thing)
|
|
260
260
|
assert.deepInclude(dataDomain.info.toJSON(), { name: 'Test Domain' })
|
|
261
|
-
})
|
|
261
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
262
262
|
|
|
263
263
|
test('creates a new DataDomain with empty info', ({ assert }) => {
|
|
264
264
|
const dataDomain = new DataDomain({
|
|
@@ -269,7 +269,7 @@ test.group('DataDomain.constructor()', () => {
|
|
|
269
269
|
assert.isNotEmpty(dataDomain.key)
|
|
270
270
|
assert.instanceOf(dataDomain.info, Thing)
|
|
271
271
|
assert.deepInclude(dataDomain.info.toJSON(), { name: 'Unnamed domain' })
|
|
272
|
-
})
|
|
272
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
273
273
|
|
|
274
274
|
test('creates a new DataDomain with dependencyList', ({ assert }) => {
|
|
275
275
|
const dataDomain = new DataDomain({
|
|
@@ -281,40 +281,40 @@ test.group('DataDomain.constructor()', () => {
|
|
|
281
281
|
assert.instanceOf(dataDomain.info, Thing)
|
|
282
282
|
assert.deepInclude(dataDomain.info.toJSON(), { name: 'Unnamed domain' })
|
|
283
283
|
assert.deepEqual(dataDomain.dependencyList, [{ key: 'dep1', version: '1.0.0' }])
|
|
284
|
-
})
|
|
284
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
285
285
|
|
|
286
286
|
test('creates a new DataDomain with a custom key', ({ assert }) => {
|
|
287
287
|
const dataDomain = new DataDomain({ key: 'custom-key' })
|
|
288
288
|
assert.equal(dataDomain.key, 'custom-key')
|
|
289
|
-
})
|
|
289
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
290
290
|
|
|
291
291
|
test('creates a new DataDomain with custom info', ({ assert }) => {
|
|
292
292
|
const customInfo = { name: 'Custom Name', description: 'Custom Description' }
|
|
293
293
|
const dataDomain = new DataDomain({ info: customInfo })
|
|
294
294
|
assert.deepInclude(dataDomain.info.toJSON(), customInfo)
|
|
295
|
-
})
|
|
295
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
296
296
|
|
|
297
297
|
test('initializes the graph', ({ assert }) => {
|
|
298
298
|
const dataDomain = new DataDomain()
|
|
299
299
|
assert.isDefined(dataDomain.graph)
|
|
300
|
-
})
|
|
300
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
301
301
|
|
|
302
302
|
test('initializes the dependencies map', ({ assert }) => {
|
|
303
303
|
const dataDomain = new DataDomain()
|
|
304
304
|
assert.instanceOf(dataDomain.dependencies, Map)
|
|
305
305
|
assert.equal(dataDomain.dependencies.size, 0)
|
|
306
|
-
})
|
|
306
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
307
307
|
|
|
308
308
|
test('initializes the dependencyList array', ({ assert }) => {
|
|
309
309
|
const dataDomain = new DataDomain()
|
|
310
310
|
assert.isArray(dataDomain.dependencyList)
|
|
311
311
|
assert.equal(dataDomain.dependencyList.length, 0)
|
|
312
|
-
})
|
|
312
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
313
313
|
|
|
314
314
|
test('does not notify change during initialization', async ({ assert }) => {
|
|
315
315
|
const dataDomain = new DataDomain()
|
|
316
316
|
await assert.notDispatches(dataDomain, 'change', { timeout: 20 })
|
|
317
|
-
})
|
|
317
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
318
318
|
|
|
319
319
|
test('restores the graph from a serialized state', ({ assert }) => {
|
|
320
320
|
const dataDomain1 = new DataDomain()
|
|
@@ -326,7 +326,7 @@ test.group('DataDomain.constructor()', () => {
|
|
|
326
326
|
const restoredEntity = dataDomain2.findEntity(entity.key)
|
|
327
327
|
assert.isDefined(restoredEntity)
|
|
328
328
|
assert.equal(restoredEntity!.key, entity.key)
|
|
329
|
-
})
|
|
329
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
330
330
|
|
|
331
331
|
test('restores the graph with dependencies', ({ assert }) => {
|
|
332
332
|
const dataDomain1 = new DataDomain()
|
|
@@ -338,7 +338,7 @@ test.group('DataDomain.constructor()', () => {
|
|
|
338
338
|
const dataDomain2 = new DataDomain(serialized, [dataDomain1])
|
|
339
339
|
const restoredEntity = dataDomain2.findForeignEntity(entity.key, dataDomain1.key)
|
|
340
340
|
assert.ok(restoredEntity)
|
|
341
|
-
})
|
|
341
|
+
}).tags(['@modeling', '@datadomain', '@constructor', '@initialization'])
|
|
342
342
|
})
|
|
343
343
|
|
|
344
344
|
test.group('DataDomain.hasFields()', () => {
|
|
@@ -346,31 +346,31 @@ test.group('DataDomain.hasFields()', () => {
|
|
|
346
346
|
const dataDomain = new DataDomain()
|
|
347
347
|
dataDomain.addNamespace()
|
|
348
348
|
assert.isTrue(dataDomain.hasFields())
|
|
349
|
-
})
|
|
349
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@query'])
|
|
350
350
|
|
|
351
351
|
test('returns true if there are child models', ({ assert }) => {
|
|
352
352
|
const dataDomain = new DataDomain()
|
|
353
353
|
dataDomain.addModel()
|
|
354
354
|
assert.isTrue(dataDomain.hasFields())
|
|
355
|
-
})
|
|
355
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@query'])
|
|
356
356
|
|
|
357
357
|
test('returns true if there are both namespaces and models', ({ assert }) => {
|
|
358
358
|
const dataDomain = new DataDomain()
|
|
359
359
|
dataDomain.addNamespace()
|
|
360
360
|
dataDomain.addModel()
|
|
361
361
|
assert.isTrue(dataDomain.hasFields())
|
|
362
|
-
})
|
|
362
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@query'])
|
|
363
363
|
|
|
364
364
|
test('returns false if there are no child namespaces or models', ({ assert }) => {
|
|
365
365
|
const dataDomain = new DataDomain()
|
|
366
366
|
assert.isFalse(dataDomain.hasFields())
|
|
367
|
-
})
|
|
367
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@query'])
|
|
368
368
|
|
|
369
369
|
test('returns false if the data domain has no fields', ({ assert }) => {
|
|
370
370
|
const dataDomain = new DataDomain()
|
|
371
371
|
dataDomain.fields = []
|
|
372
372
|
assert.isFalse(dataDomain.hasFields())
|
|
373
|
-
})
|
|
373
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@query'])
|
|
374
374
|
|
|
375
375
|
test('returns true if there are only foreign namespaces or models', ({ assert }) => {
|
|
376
376
|
const dataDomain = new DataDomain()
|
|
@@ -379,7 +379,7 @@ test.group('DataDomain.hasFields()', () => {
|
|
|
379
379
|
dataDomain.registerForeignDomain(foreignDomain)
|
|
380
380
|
foreignDomain.addNamespace()
|
|
381
381
|
assert.isFalse(dataDomain.hasFields())
|
|
382
|
-
})
|
|
382
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@query'])
|
|
383
383
|
})
|
|
384
384
|
|
|
385
385
|
test.group('DataDomain.listFields()', () => {
|
|
@@ -391,13 +391,13 @@ test.group('DataDomain.listFields()', () => {
|
|
|
391
391
|
assert.lengthOf(fields, 2)
|
|
392
392
|
assert.deepInclude(fields, namespace)
|
|
393
393
|
assert.deepInclude(fields, model)
|
|
394
|
-
})
|
|
394
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@listing'])
|
|
395
395
|
|
|
396
396
|
test('returns an empty array if there are no child namespaces or models', ({ assert }) => {
|
|
397
397
|
const dataDomain = new DataDomain()
|
|
398
398
|
const fields = [...dataDomain.listFields()]
|
|
399
399
|
assert.lengthOf(fields, 0)
|
|
400
|
-
})
|
|
400
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@listing'])
|
|
401
401
|
|
|
402
402
|
test('returns only namespaces and models', ({ assert }) => {
|
|
403
403
|
const dataDomain = new DataDomain()
|
|
@@ -408,7 +408,7 @@ test.group('DataDomain.listFields()', () => {
|
|
|
408
408
|
assert.lengthOf(fields, 2)
|
|
409
409
|
assert.deepInclude(fields, namespace)
|
|
410
410
|
assert.deepInclude(fields, model)
|
|
411
|
-
})
|
|
411
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@listing'])
|
|
412
412
|
|
|
413
413
|
test('namespaces and models in the list are of type DomainNamespace and DomainModel', ({ assert }) => {
|
|
414
414
|
const dataDomain = new DataDomain()
|
|
@@ -417,7 +417,7 @@ test.group('DataDomain.listFields()', () => {
|
|
|
417
417
|
const fields = [...dataDomain.listFields()]
|
|
418
418
|
assert.instanceOf(fields[0], DomainNamespace)
|
|
419
419
|
assert.instanceOf(fields[1], DomainModel)
|
|
420
|
-
})
|
|
420
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@listing'])
|
|
421
421
|
|
|
422
422
|
test('lists namespaces and models in the order they were added', ({ assert }) => {
|
|
423
423
|
const dataDomain = new DataDomain()
|
|
@@ -425,13 +425,13 @@ test.group('DataDomain.listFields()', () => {
|
|
|
425
425
|
const model = dataDomain.addModel()
|
|
426
426
|
const fields = [...dataDomain.listFields()]
|
|
427
427
|
assert.deepEqual(fields, [namespace, model])
|
|
428
|
-
})
|
|
428
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@listing'])
|
|
429
429
|
|
|
430
430
|
test('lists namespaces and models when there are no namespaces or models', ({ assert }) => {
|
|
431
431
|
const dataDomain = new DataDomain()
|
|
432
432
|
const fields = [...dataDomain.listFields()]
|
|
433
433
|
assert.deepEqual(fields, [])
|
|
434
|
-
})
|
|
434
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@listing'])
|
|
435
435
|
|
|
436
436
|
test('lists namespaces and models when there are other domain elements', ({ assert }) => {
|
|
437
437
|
const dataDomain = new DataDomain()
|
|
@@ -440,5 +440,5 @@ test.group('DataDomain.listFields()', () => {
|
|
|
440
440
|
dataDomain.addEntity(model.key) // Add an entity to make sure it's not included
|
|
441
441
|
const fields = [...dataDomain.listFields()]
|
|
442
442
|
assert.deepEqual(fields, [namespace, model])
|
|
443
|
-
})
|
|
443
|
+
}).tags(['@modeling', '@datadomain', '@fields', '@listing'])
|
|
444
444
|
})
|
|
@@ -10,7 +10,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
10
10
|
const association = dataDomain.addAssociation(entity.key)
|
|
11
11
|
assert.instanceOf(association, DomainAssociation)
|
|
12
12
|
assert.isTrue(dataDomain.graph.hasNode(association.key))
|
|
13
|
-
})
|
|
13
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
14
14
|
|
|
15
15
|
test('addAssociation adds an association to an entity with a target', ({ assert }) => {
|
|
16
16
|
const dataDomain = new DataDomain()
|
|
@@ -20,14 +20,14 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
20
20
|
const association = dataDomain.addAssociation(entity1.key, { key: entity2.key })
|
|
21
21
|
assert.instanceOf(association, DomainAssociation)
|
|
22
22
|
assert.isTrue(dataDomain.graph.hasNode(association.key))
|
|
23
|
-
})
|
|
23
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
24
24
|
|
|
25
25
|
test('addAssociation throws an error if source entity does not exist', ({ assert }) => {
|
|
26
26
|
const dataDomain = new DataDomain()
|
|
27
27
|
assert.throws(() => {
|
|
28
28
|
dataDomain.addAssociation('non-existent-entity')
|
|
29
29
|
}, 'Source entity non-existent-entity not found')
|
|
30
|
-
})
|
|
30
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
31
31
|
|
|
32
32
|
test('addAssociation adds an association with default values', ({ assert }) => {
|
|
33
33
|
const dataDomain = new DataDomain()
|
|
@@ -38,7 +38,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
38
38
|
assert.isTrue(dataDomain.graph.hasNode(association.key))
|
|
39
39
|
assert.typeOf(association.key, 'string')
|
|
40
40
|
assert.equal(association.info.name, 'new_association')
|
|
41
|
-
})
|
|
41
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
42
42
|
|
|
43
43
|
test('addAssociation notifies change', async ({ assert }) => {
|
|
44
44
|
const dataDomain = new DataDomain()
|
|
@@ -46,7 +46,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
46
46
|
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
47
47
|
dataDomain.addAssociation(entity.key)
|
|
48
48
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
49
|
-
})
|
|
49
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
50
50
|
|
|
51
51
|
test('addAssociation adds an association to an entity - checks parent-child relationship', ({ assert }) => {
|
|
52
52
|
const dataDomain = new DataDomain()
|
|
@@ -54,7 +54,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
54
54
|
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
55
55
|
const association = dataDomain.addAssociation(entity.key)
|
|
56
56
|
assert.isTrue(dataDomain.graph.hasEdge(entity.key, association.key))
|
|
57
|
-
})
|
|
57
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
58
58
|
|
|
59
59
|
test('addAssociation adds an association to an entity - checks items list', ({ assert }) => {
|
|
60
60
|
const dataDomain = new DataDomain()
|
|
@@ -62,7 +62,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
62
62
|
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
63
63
|
const association = dataDomain.addAssociation(entity.key)
|
|
64
64
|
assert.deepInclude([...entity.listAssociations()], association)
|
|
65
|
-
})
|
|
65
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
66
66
|
|
|
67
67
|
test('addAssociation throws an error if no source is provided', ({ assert }) => {
|
|
68
68
|
const dataDomain = new DataDomain()
|
|
@@ -70,7 +70,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
70
70
|
// @ts-expect-error For testing purposes, we are passing undefined
|
|
71
71
|
dataDomain.addAssociation(undefined)
|
|
72
72
|
}, 'Source entity undefined not found')
|
|
73
|
-
})
|
|
73
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
74
74
|
|
|
75
75
|
test('addAssociation adds an association to a foreign entity', ({ assert }) => {
|
|
76
76
|
const domain1 = new DataDomain()
|
|
@@ -87,7 +87,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
87
87
|
const association = domain1.addAssociation(e1.key, { key: 'entity2', domain: domain2.key })
|
|
88
88
|
assert.instanceOf(association, DomainAssociation)
|
|
89
89
|
assert.isTrue(domain1.graph.hasNode(association.key))
|
|
90
|
-
})
|
|
90
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
91
91
|
|
|
92
92
|
test('addAssociation throws an error if foreign entity does not exist', ({ assert }) => {
|
|
93
93
|
const domain1 = new DataDomain()
|
|
@@ -101,7 +101,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
101
101
|
assert.throws(() => {
|
|
102
102
|
domain1.addAssociation(e1.key, { key: 'non-existent-entity', domain: 'domain2' })
|
|
103
103
|
}, 'Foreign entity domain2:non-existent-entity not found')
|
|
104
|
-
})
|
|
104
|
+
}).tags(['@modeling', '@associations', '@add'])
|
|
105
105
|
})
|
|
106
106
|
|
|
107
107
|
test.group('DataDomain.removeAssociation()', () => {
|
|
@@ -112,14 +112,14 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
112
112
|
const association = dataDomain.addAssociation(entity.key)
|
|
113
113
|
dataDomain.removeAssociation(association.key)
|
|
114
114
|
assert.isFalse(dataDomain.graph.hasNode(association.key))
|
|
115
|
-
})
|
|
115
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
116
116
|
|
|
117
117
|
test('throws an error if the association does not exist', ({ assert }) => {
|
|
118
118
|
const dataDomain = new DataDomain()
|
|
119
119
|
assert.throws(() => {
|
|
120
120
|
dataDomain.removeAssociation('non-existent-association')
|
|
121
121
|
}, 'Association non-existent-association does not exist')
|
|
122
|
-
})
|
|
122
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
123
123
|
|
|
124
124
|
test('removes the association from the parent entity', ({ assert }) => {
|
|
125
125
|
const dataDomain = new DataDomain()
|
|
@@ -128,7 +128,7 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
128
128
|
const association = dataDomain.addAssociation(entity.key)
|
|
129
129
|
dataDomain.removeAssociation(association.key)
|
|
130
130
|
assert.isFalse(entity.hasAssociations())
|
|
131
|
-
})
|
|
131
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
132
132
|
|
|
133
133
|
test('throws an error when the parent entity is not found', ({ assert }) => {
|
|
134
134
|
const dataDomain = new DataDomain()
|
|
@@ -137,7 +137,7 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
137
137
|
assert.throws(() => {
|
|
138
138
|
dataDomain.removeAssociation(association.key)
|
|
139
139
|
}, `Parent entity not found for association ${association.key}`)
|
|
140
|
-
})
|
|
140
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
141
141
|
|
|
142
142
|
test('notifies change', async ({ assert }) => {
|
|
143
143
|
const dataDomain = new DataDomain()
|
|
@@ -146,7 +146,7 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
146
146
|
const association = dataDomain.addAssociation(entity.key)
|
|
147
147
|
dataDomain.removeAssociation(association.key)
|
|
148
148
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
149
|
-
})
|
|
149
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
150
150
|
|
|
151
151
|
test('removes an association to a foreign entity', ({ assert }) => {
|
|
152
152
|
const domain1 = new DataDomain()
|
|
@@ -162,7 +162,7 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
162
162
|
const association = domain1.addAssociation(e1.key, { key: e2.key, domain: domain2.key })
|
|
163
163
|
domain1.removeAssociation(association.key)
|
|
164
164
|
assert.isFalse(domain1.graph.hasNode(association.key))
|
|
165
|
-
})
|
|
165
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
166
166
|
|
|
167
167
|
test('throws an error if the association is not of type DomainAssociation', ({ assert }) => {
|
|
168
168
|
const dataDomain = new DataDomain()
|
|
@@ -171,7 +171,7 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
171
171
|
assert.throws(() => {
|
|
172
172
|
dataDomain.removeAssociation(model.key)
|
|
173
173
|
}, 'Association test-model not found')
|
|
174
|
-
})
|
|
174
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
175
175
|
|
|
176
176
|
test('removes the association from the fields list', ({ assert }) => {
|
|
177
177
|
const dataDomain = new DataDomain()
|
|
@@ -180,7 +180,18 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
180
180
|
const association = dataDomain.addAssociation(entity.key)
|
|
181
181
|
dataDomain.removeAssociation(association.key)
|
|
182
182
|
assert.deepEqual([...entity.listFields()], [])
|
|
183
|
-
})
|
|
183
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
184
|
+
|
|
185
|
+
test('keeps both source and target entities in the graph after removing an association', ({ assert }) => {
|
|
186
|
+
const dataDomain = new DataDomain()
|
|
187
|
+
const model = dataDomain.addModel()
|
|
188
|
+
const entity1 = dataDomain.addEntity(model.key, { key: 'entity1' })
|
|
189
|
+
const entity2 = dataDomain.addEntity(model.key, { key: 'entity2' })
|
|
190
|
+
const association = dataDomain.addAssociation(entity1.key, { key: entity2.key })
|
|
191
|
+
dataDomain.removeAssociation(association.key)
|
|
192
|
+
assert.isTrue(dataDomain.graph.hasNode(entity1.key))
|
|
193
|
+
assert.isTrue(dataDomain.graph.hasNode(entity2.key))
|
|
194
|
+
}).tags(['@modeling', '@associations', '@remove'])
|
|
184
195
|
})
|
|
185
196
|
|
|
186
197
|
test.group('DataDomain.findAssociation()', () => {
|
|
@@ -191,75 +202,75 @@ test.group('DataDomain.findAssociation()', () => {
|
|
|
191
202
|
const association = dataDomain.addAssociation(entity.key)
|
|
192
203
|
const foundAssociation = dataDomain.findAssociation(association.key)
|
|
193
204
|
assert.deepEqual(foundAssociation, association)
|
|
194
|
-
})
|
|
205
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
195
206
|
|
|
196
207
|
test('returns undefined if association does not exist', ({ assert }) => {
|
|
197
208
|
const dataDomain = new DataDomain()
|
|
198
209
|
const foundAssociation = dataDomain.findAssociation('non-existent-association')
|
|
199
210
|
assert.isUndefined(foundAssociation)
|
|
200
|
-
})
|
|
211
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
201
212
|
|
|
202
213
|
test('returns undefined if key is not an association', ({ assert }) => {
|
|
203
214
|
const dataDomain = new DataDomain()
|
|
204
215
|
const model = dataDomain.addModel({ key: 'test-model' })
|
|
205
216
|
const foundAssociation = dataDomain.findAssociation(model.key)
|
|
206
217
|
assert.isUndefined(foundAssociation)
|
|
207
|
-
})
|
|
218
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
208
219
|
|
|
209
220
|
test('returns undefined if key is undefined', ({ assert }) => {
|
|
210
221
|
const dataDomain = new DataDomain()
|
|
211
222
|
// @ts-expect-error For testing purposes
|
|
212
223
|
const foundAssociation = dataDomain.findAssociation(undefined)
|
|
213
224
|
assert.isUndefined(foundAssociation)
|
|
214
|
-
})
|
|
225
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
215
226
|
|
|
216
227
|
test('returns undefined if key is null', ({ assert }) => {
|
|
217
228
|
const dataDomain = new DataDomain()
|
|
218
229
|
// @ts-expect-error For testing purposes
|
|
219
230
|
const foundAssociation = dataDomain.findAssociation(null)
|
|
220
231
|
assert.isUndefined(foundAssociation)
|
|
221
|
-
})
|
|
232
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
222
233
|
|
|
223
234
|
test('returns undefined if key is an empty string', ({ assert }) => {
|
|
224
235
|
const dataDomain = new DataDomain()
|
|
225
236
|
const foundAssociation = dataDomain.findAssociation('')
|
|
226
237
|
assert.isUndefined(foundAssociation)
|
|
227
|
-
})
|
|
238
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
228
239
|
|
|
229
240
|
test('returns undefined if key is a number', ({ assert }) => {
|
|
230
241
|
const dataDomain = new DataDomain()
|
|
231
242
|
// @ts-expect-error For testing purposes
|
|
232
243
|
const foundAssociation = dataDomain.findAssociation(123)
|
|
233
244
|
assert.isUndefined(foundAssociation)
|
|
234
|
-
})
|
|
245
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
235
246
|
|
|
236
247
|
test('returns undefined if key is a boolean', ({ assert }) => {
|
|
237
248
|
const dataDomain = new DataDomain()
|
|
238
249
|
// @ts-expect-error For testing purposes
|
|
239
250
|
const foundAssociation = dataDomain.findAssociation(true)
|
|
240
251
|
assert.isUndefined(foundAssociation)
|
|
241
|
-
})
|
|
252
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
242
253
|
|
|
243
254
|
test('returns undefined if key is an object', ({ assert }) => {
|
|
244
255
|
const dataDomain = new DataDomain()
|
|
245
256
|
// @ts-expect-error For testing purposes
|
|
246
257
|
const foundAssociation = dataDomain.findAssociation({})
|
|
247
258
|
assert.isUndefined(foundAssociation)
|
|
248
|
-
})
|
|
259
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
249
260
|
|
|
250
261
|
test('returns undefined if key is an array', ({ assert }) => {
|
|
251
262
|
const dataDomain = new DataDomain()
|
|
252
263
|
// @ts-expect-error For testing purposes
|
|
253
264
|
const foundAssociation = dataDomain.findAssociation([])
|
|
254
265
|
assert.isUndefined(foundAssociation)
|
|
255
|
-
})
|
|
266
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
256
267
|
|
|
257
268
|
test('returns undefined if key is a function', ({ assert }) => {
|
|
258
269
|
const dataDomain = new DataDomain()
|
|
259
270
|
// @ts-expect-error For testing purposes
|
|
260
271
|
const foundAssociation = dataDomain.findAssociation(() => {})
|
|
261
272
|
assert.isUndefined(foundAssociation)
|
|
262
|
-
})
|
|
273
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
263
274
|
|
|
264
275
|
test('finds an association to a foreign domain', ({ assert }) => {
|
|
265
276
|
const domain1 = new DataDomain()
|
|
@@ -275,5 +286,5 @@ test.group('DataDomain.findAssociation()', () => {
|
|
|
275
286
|
|
|
276
287
|
const foundAssociation = domain1.findAssociation(association.key)
|
|
277
288
|
assert.deepEqual(foundAssociation, association)
|
|
278
|
-
})
|
|
289
|
+
}).tags(['@modeling', '@associations', '@find'])
|
|
279
290
|
})
|