@api-client/core 0.17.0 → 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/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +15 -15
- package/package.json +1 -1
- package/src/modeling/GraphUtils.ts +15 -4
- 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
|
@@ -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
|
})
|
|
@@ -2,7 +2,11 @@ import { test } from '@japa/runner'
|
|
|
2
2
|
import { DataDomain, DataFormat } from '../../../src/index.js'
|
|
3
3
|
import { SemanticType } from '../../../src/modeling/Semantics.js'
|
|
4
4
|
|
|
5
|
-
test.group('DataDomain change observers', () => {
|
|
5
|
+
test.group('DataDomain change observers', (g) => {
|
|
6
|
+
g.tests.forEach((test) => {
|
|
7
|
+
test.tags(['@modeling', '@domain', '@change_observers'])
|
|
8
|
+
})
|
|
9
|
+
|
|
6
10
|
test('does not notifies a change when initializing a domain', async ({ assert }) => {
|
|
7
11
|
const domain = new DataDomain()
|
|
8
12
|
await assert.notDispatches(domain, 'change', { timeout: 1 })
|
|
@@ -33,7 +37,11 @@ test.group('DataDomain change observers', () => {
|
|
|
33
37
|
})
|
|
34
38
|
})
|
|
35
39
|
|
|
36
|
-
test.group('DomainNamespace change observers', () => {
|
|
40
|
+
test.group('DomainNamespace change observers', (g) => {
|
|
41
|
+
g.tests.forEach((test) => {
|
|
42
|
+
test.tags(['@modeling', '@namespace', '@change_observers'])
|
|
43
|
+
})
|
|
44
|
+
|
|
37
45
|
test('notifies a change when changing info.name', async ({ assert, sleep }) => {
|
|
38
46
|
const domain = new DataDomain()
|
|
39
47
|
const n1 = domain.addNamespace()
|
|
@@ -128,7 +136,11 @@ test.group('DomainNamespace change observers', () => {
|
|
|
128
136
|
})
|
|
129
137
|
})
|
|
130
138
|
|
|
131
|
-
test.group('DomainModel change observers', () => {
|
|
139
|
+
test.group('DomainModel change observers', (g) => {
|
|
140
|
+
g.tests.forEach((test) => {
|
|
141
|
+
test.tags(['@modeling', '@model', '@change_observers'])
|
|
142
|
+
})
|
|
143
|
+
|
|
132
144
|
test('notifies a change when changing info.name', async ({ assert, sleep }) => {
|
|
133
145
|
const domain = new DataDomain()
|
|
134
146
|
const n1 = domain.addNamespace()
|
|
@@ -205,7 +217,11 @@ test.group('DomainModel change observers', () => {
|
|
|
205
217
|
})
|
|
206
218
|
})
|
|
207
219
|
|
|
208
|
-
test.group('DomainEntity change observers', () => {
|
|
220
|
+
test.group('DomainEntity change observers', (g) => {
|
|
221
|
+
g.tests.forEach((test) => {
|
|
222
|
+
test.tags(['@modeling', '@entity', '@change_observers'])
|
|
223
|
+
})
|
|
224
|
+
|
|
209
225
|
test('notifies a change when changing info.name', async ({ assert, sleep }) => {
|
|
210
226
|
const domain = new DataDomain()
|
|
211
227
|
const n1 = domain.addNamespace()
|
|
@@ -364,7 +380,11 @@ test.group('DomainEntity change observers', () => {
|
|
|
364
380
|
})
|
|
365
381
|
})
|
|
366
382
|
|
|
367
|
-
test.group('DomainProperty change observers', () => {
|
|
383
|
+
test.group('DomainProperty change observers', (g) => {
|
|
384
|
+
g.tests.forEach((test) => {
|
|
385
|
+
test.tags(['@modeling', '@property', '@change_observers'])
|
|
386
|
+
})
|
|
387
|
+
|
|
368
388
|
test('notifies a change when changing info.name', async ({ assert, sleep }) => {
|
|
369
389
|
const domain = new DataDomain()
|
|
370
390
|
const n1 = domain.addNamespace()
|
|
@@ -566,7 +586,11 @@ test.group('DomainProperty change observers', () => {
|
|
|
566
586
|
})
|
|
567
587
|
})
|
|
568
588
|
|
|
569
|
-
test.group('DomainAssociation change observers', () => {
|
|
589
|
+
test.group('DomainAssociation change observers', (g) => {
|
|
590
|
+
g.tests.forEach((test) => {
|
|
591
|
+
test.tags(['@modeling', '@association', '@change_observers'])
|
|
592
|
+
})
|
|
593
|
+
|
|
570
594
|
test('notifies a change when changing info.name', async ({ assert, sleep }) => {
|
|
571
595
|
const domain = new DataDomain()
|
|
572
596
|
const n1 = domain.addNamespace()
|