@api-client/core 0.11.11 → 0.12.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.
- package/Testing.md +1 -1
- package/bin/plugins/events/EventPlugin.ts +61 -0
- package/bin/plugins/events/assert.ts +193 -0
- package/bin/plugins/events/types.ts +6 -0
- package/bin/test.ts +8 -1
- package/build/src/amf/AmfShapeGenerator.d.ts +6 -3
- package/build/src/amf/AmfShapeGenerator.d.ts.map +1 -1
- package/build/src/amf/AmfShapeGenerator.js +4 -1
- package/build/src/amf/AmfShapeGenerator.js.map +1 -1
- package/build/src/amf/AmfTypes.d.ts +2 -2
- package/build/src/amf/AmfTypes.d.ts.map +1 -1
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/DataValueGenerator.d.ts +15 -15
- package/build/src/amf/DataValueGenerator.d.ts.map +1 -1
- package/build/src/amf/DataValueGenerator.js +14 -14
- package/build/src/amf/DataValueGenerator.js.map +1 -1
- package/build/src/browser.d.ts +12 -9
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +11 -8
- package/build/src/browser.js.map +1 -1
- package/build/src/exceptions/attach_exception.d.ts +11 -0
- package/build/src/exceptions/attach_exception.d.ts.map +1 -0
- package/build/src/exceptions/attach_exception.js +11 -0
- package/build/src/exceptions/attach_exception.js.map +1 -0
- package/build/src/exceptions/detach_exception.d.ts +11 -0
- package/build/src/exceptions/detach_exception.d.ts.map +1 -0
- package/build/src/exceptions/detach_exception.js +11 -0
- package/build/src/exceptions/detach_exception.js.map +1 -0
- package/build/src/exceptions/remove_model_exception.d.ts +8 -0
- package/build/src/exceptions/remove_model_exception.d.ts.map +1 -0
- package/build/src/exceptions/remove_model_exception.js +8 -0
- package/build/src/exceptions/remove_model_exception.js.map +1 -0
- package/build/src/exceptions/remove_namespace_exception.d.ts +8 -0
- package/build/src/exceptions/remove_namespace_exception.d.ts.map +1 -0
- package/build/src/exceptions/remove_namespace_exception.js +8 -0
- package/build/src/exceptions/remove_namespace_exception.js.map +1 -0
- package/build/src/index.d.ts +12 -9
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +11 -8
- package/build/src/index.js.map +1 -1
- package/build/src/legacy.d.ts +8 -0
- package/build/src/legacy.d.ts.map +1 -1
- package/build/src/legacy.js +9 -0
- package/build/src/legacy.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +2 -2
- package/build/src/modeling/Bindings.d.ts.map +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DataDomain.d.ts +601 -0
- package/build/src/modeling/DataDomain.d.ts.map +1 -0
- package/build/src/modeling/DataDomain.js +1142 -0
- package/build/src/modeling/DataDomain.js.map +1 -0
- package/build/src/modeling/DataFormat.d.ts +42 -41
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +30 -131
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +281 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -0
- package/build/src/modeling/DomainAssociation.js +440 -0
- package/build/src/modeling/DomainAssociation.js.map +1 -0
- package/build/src/modeling/DomainElement.d.ts +33 -0
- package/build/src/modeling/DomainElement.d.ts.map +1 -0
- package/build/src/modeling/DomainElement.js +32 -0
- package/build/src/modeling/DomainElement.js.map +1 -0
- package/build/src/modeling/DomainEntity.d.ts +383 -0
- package/build/src/modeling/DomainEntity.d.ts.map +1 -0
- package/build/src/modeling/DomainEntity.js +718 -0
- package/build/src/modeling/DomainEntity.js.map +1 -0
- package/build/src/modeling/DomainFile.d.ts +25 -0
- package/build/src/modeling/DomainFile.d.ts.map +1 -0
- package/build/src/modeling/DomainFile.js +86 -0
- package/build/src/modeling/DomainFile.js.map +1 -0
- package/build/src/modeling/DomainImpactAnalysis.d.ts +60 -47
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +201 -132
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +226 -0
- package/build/src/modeling/DomainModel.d.ts.map +1 -0
- package/build/src/modeling/DomainModel.js +401 -0
- package/build/src/modeling/DomainModel.js.map +1 -0
- package/build/src/modeling/DomainNamespace.d.ts +268 -0
- package/build/src/modeling/DomainNamespace.d.ts.map +1 -0
- package/build/src/modeling/DomainNamespace.js +512 -0
- package/build/src/modeling/DomainNamespace.js.map +1 -0
- package/build/src/modeling/DomainProperty.d.ts +281 -0
- package/build/src/modeling/DomainProperty.d.ts.map +1 -0
- package/build/src/modeling/DomainProperty.js +560 -0
- package/build/src/modeling/DomainProperty.js.map +1 -0
- package/build/src/modeling/DomainSerialization.d.ts +40 -0
- package/build/src/modeling/DomainSerialization.d.ts.map +1 -0
- package/build/src/modeling/DomainSerialization.js +288 -0
- package/build/src/modeling/DomainSerialization.js.map +1 -0
- package/build/src/modeling/DomainVersioning.d.ts +17 -0
- package/build/src/modeling/DomainVersioning.d.ts.map +1 -0
- package/build/src/modeling/DomainVersioning.js +124 -0
- package/build/src/modeling/DomainVersioning.js.map +1 -0
- package/build/src/modeling/GraphUtils.d.ts +8 -0
- package/build/src/modeling/GraphUtils.d.ts.map +1 -0
- package/build/src/modeling/GraphUtils.js +26 -0
- package/build/src/modeling/GraphUtils.js.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts +164 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.js +492 -0
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -0
- package/build/src/modeling/{DataAssociation.d.ts → legacy/DataAssociation.d.ts} +10 -5
- package/build/src/modeling/legacy/DataAssociation.d.ts.map +1 -0
- package/build/src/modeling/{DataAssociation.js → legacy/DataAssociation.js} +9 -6
- package/build/src/modeling/legacy/DataAssociation.js.map +1 -0
- package/build/src/modeling/{DataEntity.d.ts → legacy/DataEntity.d.ts} +12 -7
- package/build/src/modeling/legacy/DataEntity.d.ts.map +1 -0
- package/build/src/modeling/{DataEntity.js → legacy/DataEntity.js} +19 -18
- package/build/src/modeling/legacy/DataEntity.js.map +1 -0
- package/build/src/modeling/{DataEntityBuilder.d.ts → legacy/DataEntityBuilder.d.ts} +3 -2
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +1 -0
- package/build/src/modeling/{DataEntityBuilder.js → legacy/DataEntityBuilder.js} +3 -2
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +298 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +1 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.js +441 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.js.map +1 -0
- package/build/src/modeling/{DataModel.d.ts → legacy/DataModel.d.ts} +6 -4
- package/build/src/modeling/legacy/DataModel.d.ts.map +1 -0
- package/build/src/modeling/{DataModel.js → legacy/DataModel.js} +7 -6
- package/build/src/modeling/legacy/DataModel.js.map +1 -0
- package/build/src/modeling/{DataNamespace.d.ts → legacy/DataNamespace.d.ts} +22 -3
- package/build/src/modeling/legacy/DataNamespace.d.ts.map +1 -0
- package/build/src/modeling/{DataNamespace.js → legacy/DataNamespace.js} +7 -3
- package/build/src/modeling/legacy/DataNamespace.js.map +1 -0
- package/build/src/modeling/{DataProperty.d.ts → legacy/DataProperty.d.ts} +13 -5
- package/build/src/modeling/legacy/DataProperty.d.ts.map +1 -0
- package/build/src/modeling/{DataProperty.js → legacy/DataProperty.js} +8 -5
- package/build/src/modeling/legacy/DataProperty.js.map +1 -0
- package/build/src/modeling/observed.d.ts +67 -0
- package/build/src/modeling/observed.d.ts.map +1 -0
- package/build/src/modeling/observed.js +230 -0
- package/build/src/modeling/observed.js.map +1 -0
- package/build/src/modeling/types.d.ts +165 -1
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/models/Thing.d.ts +26 -5
- package/build/src/models/Thing.d.ts.map +1 -1
- package/build/src/models/Thing.js +193 -91
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/kinds.d.ts +31 -6
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +31 -6
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/DataFile.d.ts +3 -1
- package/build/src/models/store/DataFile.d.ts.map +1 -1
- package/build/src/models/store/DataFile.js +2 -0
- package/build/src/models/store/DataFile.js.map +1 -1
- package/build/src/models/types.d.ts +12 -0
- package/build/src/models/types.d.ts.map +1 -0
- package/build/src/models/types.js +2 -0
- package/build/src/models/types.js.map +1 -0
- package/build/src/runtime/store/FilesSdk.d.ts +2 -2
- package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/data/models/example-generator-api.json +16 -16
- package/package.json +20 -6
- package/readme.md +1 -1
- package/src/amf/AmfShapeGenerator.ts +7 -4
- package/src/amf/AmfTypes.ts +2 -2
- package/src/amf/DataValueGenerator.ts +21 -21
- package/src/exceptions/attach_exception.ts +11 -0
- package/src/exceptions/detach_exception.ts +11 -0
- package/src/exceptions/remove_model_exception.ts +8 -0
- package/src/exceptions/remove_namespace_exception.ts +8 -0
- package/src/modeling/Bindings.ts +2 -2
- package/src/modeling/DataDomain.ts +1221 -0
- package/src/modeling/DataFormat.ts +54 -163
- package/src/modeling/DomainAssociation.ts +476 -0
- package/src/modeling/DomainElement.ts +50 -0
- package/src/modeling/DomainEntity.ts +769 -0
- package/src/modeling/DomainFile.ts +94 -0
- package/src/modeling/DomainImpactAnalysis.ts +218 -144
- package/src/modeling/DomainModel.ts +421 -0
- package/src/modeling/DomainNamespace.ts +537 -0
- package/src/modeling/DomainProperty.ts +548 -0
- package/src/modeling/DomainSerialization.ts +312 -0
- package/src/modeling/DomainVersioning.ts +144 -0
- package/src/modeling/GraphUtils.ts +28 -0
- package/src/modeling/amf/ShapeGenerator.ts +552 -0
- package/src/modeling/graph.md +115 -0
- package/src/modeling/{DataAssociation.ts → legacy/DataAssociation.ts} +13 -8
- package/src/modeling/{DataEntity.ts → legacy/DataEntity.ts} +28 -23
- package/src/modeling/{DataEntityBuilder.ts → legacy/DataEntityBuilder.ts} +4 -3
- package/src/modeling/legacy/DataImpactAnalysis.ts +530 -0
- package/src/modeling/{DataModel.ts → legacy/DataModel.ts} +10 -8
- package/src/modeling/{DataNamespace.ts → legacy/DataNamespace.ts} +23 -5
- package/src/modeling/{DataProperty.ts → legacy/DataProperty.ts} +15 -7
- package/src/modeling/observed.ts +267 -0
- package/src/modeling/types.ts +174 -1
- package/src/models/Thing.ts +70 -5
- package/src/models/kinds.ts +32 -6
- package/src/models/store/DataFile.ts +3 -1
- package/src/models/types.ts +11 -0
- package/src/runtime/store/FilesSdk.ts +2 -2
- package/tests/unit/amf/data_value_generator.spec.ts +15 -15
- package/tests/unit/legacy-transformers/ARC-legacy-import.spec.ts +1 -1
- package/tests/unit/modeling/amf/shape_generator.spec.ts +1174 -0
- package/tests/unit/modeling/data_domain.spec.ts +444 -0
- package/tests/unit/modeling/data_domain_associations.spec.ts +279 -0
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +681 -0
- package/tests/unit/modeling/data_domain_entities.spec.ts +449 -0
- package/tests/unit/modeling/data_domain_foreign.spec.ts +355 -0
- package/tests/unit/modeling/data_domain_models.spec.ts +658 -0
- package/tests/unit/modeling/data_domain_namespaces.spec.ts +668 -0
- package/tests/unit/modeling/data_domain_property.spec.ts +264 -0
- package/tests/unit/modeling/data_domain_serialization.spec.ts +294 -0
- package/tests/unit/modeling/domain.property.spec.ts +822 -0
- package/tests/unit/modeling/domain_asociation.spec.ts +643 -0
- package/tests/unit/modeling/domain_asociation_targets.spec.ts +350 -0
- package/tests/unit/modeling/domain_entity.spec.ts +730 -0
- package/tests/unit/modeling/domain_entity_associations.spec.ts +330 -0
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +988 -0
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1451 -0
- package/tests/unit/modeling/domain_entity_fields.spec.ts +113 -0
- package/tests/unit/modeling/domain_entity_generators.spec.ts +20 -0
- package/tests/unit/modeling/domain_entity_parents.spec.ts +291 -0
- package/tests/unit/modeling/domain_entity_properties.spec.ts +305 -0
- package/tests/unit/modeling/{data_file.spec.ts → domain_file.spec.ts} +29 -85
- package/tests/unit/modeling/domain_impact_analysis.spec.ts +452 -0
- package/tests/unit/modeling/domain_model.spec.ts +568 -0
- package/tests/unit/modeling/domain_model_entities.spec.ts +408 -0
- package/tests/unit/modeling/domain_namespace.spec.ts +514 -0
- package/tests/unit/modeling/domain_namespace_models.spec.ts +324 -0
- package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +404 -0
- package/tests/unit/modeling/domain_versioning.spec.ts +140 -0
- package/tests/unit/{amf → modeling/legacy}/amf_shape_generator.spec.ts +11 -11
- package/tests/unit/modeling/{data_association.spec.ts → legacy/data_association.spec.ts} +3 -11
- package/tests/unit/modeling/{data_entity.spec.ts → legacy/data_entity.spec.ts} +10 -8
- package/tests/unit/modeling/{data_entity_generator_json.spec.ts → legacy/data_entity_generator_json.spec.ts} +1 -1
- package/tests/unit/modeling/{data_entity_generator_xml.spec.ts → legacy/data_entity_generator_xml.spec.ts} +1 -1
- package/tests/unit/modeling/{data_model.spec.ts → legacy/data_model.spec.ts} +3 -3
- package/tests/unit/modeling/{data_namespace.spec.ts → legacy/data_namespace.spec.ts} +3 -10
- package/tests/unit/modeling/{data_property.spec.ts → legacy/data_property.spec.ts} +3 -6
- package/tests/unit/modeling/{impact_analysis.spec.ts → legacy/impact_analysis.spec.ts} +9 -9
- package/tests/unit/models/File/new.spec.ts +1 -1
- package/tests/unit/models/HttpProject.spec.ts +3 -3
- package/tsconfig.node.json +35 -0
- package/build/src/modeling/DataAssociation.d.ts.map +0 -1
- package/build/src/modeling/DataAssociation.js.map +0 -1
- package/build/src/modeling/DataEntity.d.ts.map +0 -1
- package/build/src/modeling/DataEntity.js.map +0 -1
- package/build/src/modeling/DataEntityBuilder.d.ts.map +0 -1
- package/build/src/modeling/DataEntityBuilder.js.map +0 -1
- package/build/src/modeling/DataModel.d.ts.map +0 -1
- package/build/src/modeling/DataModel.js.map +0 -1
- package/build/src/modeling/DataNamespace.d.ts.map +0 -1
- package/build/src/modeling/DataNamespace.js.map +0 -1
- package/build/src/modeling/DataProperty.d.ts.map +0 -1
- package/build/src/modeling/DataProperty.js.map +0 -1
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import { DataDomain } from '../../../src/modeling/DataDomain.js'
|
|
3
|
+
|
|
4
|
+
test.group('DataDomain.registerForeignDomain()', () => {
|
|
5
|
+
test('registers a foreign domain', ({ assert }) => {
|
|
6
|
+
const dataDomain = new DataDomain()
|
|
7
|
+
const foreignDomain = new DataDomain()
|
|
8
|
+
foreignDomain.info.version = '1.0.0'
|
|
9
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
10
|
+
assert.equal(dataDomain.dependencies.size, 1)
|
|
11
|
+
assert.equal(dataDomain.dependencies.get(foreignDomain.key), foreignDomain)
|
|
12
|
+
assert.equal(dataDomain.dependencyList.length, 1)
|
|
13
|
+
assert.deepEqual(dataDomain.dependencyList[0], { key: foreignDomain.key, version: '1.0.0' })
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('throws an error when registering a domain with the same key', ({ assert }) => {
|
|
17
|
+
const dataDomain = new DataDomain()
|
|
18
|
+
const foreignDomain1 = new DataDomain()
|
|
19
|
+
foreignDomain1.info.version = '1.0.0'
|
|
20
|
+
dataDomain.registerForeignDomain(foreignDomain1)
|
|
21
|
+
assert.throws(
|
|
22
|
+
() => dataDomain.registerForeignDomain(foreignDomain1),
|
|
23
|
+
`Foreign domain with key ${foreignDomain1.key} already registered`
|
|
24
|
+
)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('throws an error when registering a domain without a version', ({ assert }) => {
|
|
28
|
+
const dataDomain = new DataDomain()
|
|
29
|
+
const foreignDomain = new DataDomain()
|
|
30
|
+
assert.throws(
|
|
31
|
+
() => dataDomain.registerForeignDomain(foreignDomain),
|
|
32
|
+
`Foreign domain ${foreignDomain.key} does not have a version set`
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test('copies nodes from the foreign domain to the local graph', ({ assert }) => {
|
|
37
|
+
const dataDomain = new DataDomain()
|
|
38
|
+
const foreignDomain = new DataDomain()
|
|
39
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
40
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
41
|
+
const property = foreignDomain.addProperty(entity.key, { key: 'test-property' })
|
|
42
|
+
foreignDomain.info.version = '1.0.0'
|
|
43
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
44
|
+
|
|
45
|
+
assert.isTrue(dataDomain.graph.hasNode(`${foreignDomain.key}:${model.key}`))
|
|
46
|
+
assert.isTrue(dataDomain.graph.hasNode(`${foreignDomain.key}:${entity.key}`))
|
|
47
|
+
assert.isTrue(dataDomain.graph.hasNode(`${foreignDomain.key}:${property.key}`))
|
|
48
|
+
assert.deepEqual(dataDomain.graph.node(`${foreignDomain.key}:${model.key}`), model)
|
|
49
|
+
assert.deepEqual(dataDomain.graph.node(`${foreignDomain.key}:${entity.key}`), entity)
|
|
50
|
+
assert.deepEqual(dataDomain.graph.node(`${foreignDomain.key}:${property.key}`), property)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('copies edges from the foreign domain to the local graph', ({ assert }) => {
|
|
54
|
+
const dataDomain = new DataDomain()
|
|
55
|
+
const foreignDomain = new DataDomain()
|
|
56
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
57
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
58
|
+
const property = foreignDomain.addProperty(entity.key, { key: 'test-property' })
|
|
59
|
+
foreignDomain.info.version = '1.0.0'
|
|
60
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
61
|
+
|
|
62
|
+
assert.isTrue(
|
|
63
|
+
dataDomain.graph.hasEdge(`${foreignDomain.key}:${entity.key}`, `${foreignDomain.key}:${property.key}`)
|
|
64
|
+
)
|
|
65
|
+
assert.deepEqual(
|
|
66
|
+
dataDomain.graph.edge(`${foreignDomain.key}:${entity.key}`, `${foreignDomain.key}:${property.key}`),
|
|
67
|
+
{ type: 'property', domain: foreignDomain.key, foreign: true }
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('copies parent-child relationships from the foreign domain to the local graph', ({ assert }) => {
|
|
72
|
+
const dataDomain = new DataDomain()
|
|
73
|
+
const foreignDomain = new DataDomain()
|
|
74
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
75
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
76
|
+
const childEntity = foreignDomain.addEntity(model.key, { key: 'child-entity' })
|
|
77
|
+
childEntity.addParent(entity.key)
|
|
78
|
+
foreignDomain.info.version = '1.0.0'
|
|
79
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
80
|
+
|
|
81
|
+
assert.isTrue(
|
|
82
|
+
dataDomain.graph.hasEdge(`${foreignDomain.key}:${childEntity.key}`, `${foreignDomain.key}:${entity.key}`)
|
|
83
|
+
)
|
|
84
|
+
assert.isTrue(dataDomain.graph.hasParent(`${foreignDomain.key}:${entity.key}`, `${foreignDomain.key}:${model.key}`))
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('copies multiple parent-child relationships from the foreign domain to the local graph', ({ assert }) => {
|
|
88
|
+
const dataDomain = new DataDomain()
|
|
89
|
+
const foreignDomain = new DataDomain()
|
|
90
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
91
|
+
const entity1 = foreignDomain.addEntity(model.key, { key: 'entity1' })
|
|
92
|
+
const entity2 = foreignDomain.addEntity(model.key, { key: 'entity2' })
|
|
93
|
+
const childEntity = foreignDomain.addEntity(model.key, { key: 'child-entity' })
|
|
94
|
+
childEntity.addParent(entity1.key)
|
|
95
|
+
childEntity.addParent(entity2.key)
|
|
96
|
+
foreignDomain.info.version = '1.0.0'
|
|
97
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
98
|
+
|
|
99
|
+
assert.isTrue(
|
|
100
|
+
dataDomain.graph.hasEdge(`${foreignDomain.key}:${childEntity.key}`, `${foreignDomain.key}:${entity1.key}`)
|
|
101
|
+
)
|
|
102
|
+
assert.isTrue(
|
|
103
|
+
dataDomain.graph.hasEdge(`${foreignDomain.key}:${childEntity.key}`, `${foreignDomain.key}:${entity2.key}`)
|
|
104
|
+
)
|
|
105
|
+
assert.isTrue(
|
|
106
|
+
dataDomain.graph.hasParent(`${foreignDomain.key}:${entity1.key}`, `${foreignDomain.key}:${model.key}`)
|
|
107
|
+
)
|
|
108
|
+
assert.isTrue(
|
|
109
|
+
dataDomain.graph.hasParent(`${foreignDomain.key}:${entity2.key}`, `${foreignDomain.key}:${model.key}`)
|
|
110
|
+
)
|
|
111
|
+
// assert.isTrue(dataDomain.graph.hasParent(`${foreignDomain.key}:${model.key}`))
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
test('copies association edges from the foreign domain to the local graph', ({ assert }) => {
|
|
115
|
+
const dataDomain = new DataDomain()
|
|
116
|
+
const foreignDomain = new DataDomain()
|
|
117
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
118
|
+
const entity1 = foreignDomain.addEntity(model.key, { key: 'entity1' })
|
|
119
|
+
const entity2 = foreignDomain.addEntity(model.key, { key: 'entity2' })
|
|
120
|
+
const association = entity1.addAssociation({ key: entity2.key })
|
|
121
|
+
foreignDomain.info.version = '1.0.0'
|
|
122
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
123
|
+
|
|
124
|
+
assert.isTrue(
|
|
125
|
+
dataDomain.graph.hasEdge(`${foreignDomain.key}:${entity1.key}`, `${foreignDomain.key}:${association.key}`)
|
|
126
|
+
)
|
|
127
|
+
assert.isTrue(
|
|
128
|
+
dataDomain.graph.hasEdge(`${foreignDomain.key}:${association.key}`, `${foreignDomain.key}:${entity2.key}`)
|
|
129
|
+
)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
test('copies foreign domain entities to the root of the graph', ({ assert }) => {
|
|
133
|
+
const dataDomain = new DataDomain()
|
|
134
|
+
const foreignDomain = new DataDomain()
|
|
135
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
136
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
137
|
+
foreignDomain.info.version = '1.0.0'
|
|
138
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
139
|
+
|
|
140
|
+
assert.isTrue(dataDomain.graph.hasNode(`${foreignDomain.key}:${entity.key}`))
|
|
141
|
+
assert.isTrue(dataDomain.graph.hasParent(`${foreignDomain.key}:${entity.key}`, `${foreignDomain.key}:${model.key}`))
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
test.group('DataDomain.findForeignEntity()', () => {
|
|
146
|
+
test('finds a foreign entity by its key and domain key', ({ assert }) => {
|
|
147
|
+
const dataDomain = new DataDomain()
|
|
148
|
+
const foreignDomain = new DataDomain()
|
|
149
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
150
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
151
|
+
foreignDomain.info.version = '1.0.0'
|
|
152
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
153
|
+
const foundEntity = dataDomain.findForeignEntity('test-entity', foreignDomain.key)
|
|
154
|
+
assert.deepEqual(foundEntity, entity)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test('returns undefined if the foreign domain does not exist', ({ assert }) => {
|
|
158
|
+
const dataDomain = new DataDomain()
|
|
159
|
+
const foundEntity = dataDomain.findForeignEntity('test-entity', 'non-existent-domain')
|
|
160
|
+
assert.isUndefined(foundEntity)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
test('returns undefined if the entity does not exist in the foreign domain', ({ assert }) => {
|
|
164
|
+
const dataDomain = new DataDomain()
|
|
165
|
+
const foreignDomain = new DataDomain()
|
|
166
|
+
foreignDomain.info.version = '1.0.0'
|
|
167
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
168
|
+
const foundEntity = dataDomain.findForeignEntity('non-existent-entity', foreignDomain.key)
|
|
169
|
+
assert.isUndefined(foundEntity)
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test('returns undefined if the key is not an entity', ({ assert }) => {
|
|
173
|
+
const dataDomain = new DataDomain()
|
|
174
|
+
const foreignDomain = new DataDomain()
|
|
175
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
176
|
+
foreignDomain.info.version = '1.0.0'
|
|
177
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
178
|
+
const foundEntity = dataDomain.findForeignEntity(model.key, foreignDomain.key)
|
|
179
|
+
assert.isUndefined(foundEntity)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
test('returns undefined if key is undefined', ({ assert }) => {
|
|
183
|
+
const dataDomain = new DataDomain()
|
|
184
|
+
const foreignDomain = new DataDomain()
|
|
185
|
+
foreignDomain.info.version = '1.0.0'
|
|
186
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
187
|
+
// @ts-expect-error For testing purposes
|
|
188
|
+
const foundEntity = dataDomain.findForeignEntity(undefined, foreignDomain.key)
|
|
189
|
+
assert.isUndefined(foundEntity)
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
test('returns undefined if key is null', ({ assert }) => {
|
|
193
|
+
const dataDomain = new DataDomain()
|
|
194
|
+
const foreignDomain = new DataDomain()
|
|
195
|
+
foreignDomain.info.version = '1.0.0'
|
|
196
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
197
|
+
// @ts-expect-error For testing purposes
|
|
198
|
+
const foundEntity = dataDomain.findForeignEntity(null, foreignDomain.key)
|
|
199
|
+
assert.isUndefined(foundEntity)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
test('returns undefined if key is an empty string', ({ assert }) => {
|
|
203
|
+
const dataDomain = new DataDomain()
|
|
204
|
+
const foreignDomain = new DataDomain()
|
|
205
|
+
foreignDomain.info.version = '1.0.0'
|
|
206
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
207
|
+
const foundEntity = dataDomain.findForeignEntity('', foreignDomain.key)
|
|
208
|
+
assert.isUndefined(foundEntity)
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
test('returns undefined if key is a number', ({ assert }) => {
|
|
212
|
+
const dataDomain = new DataDomain()
|
|
213
|
+
const foreignDomain = new DataDomain()
|
|
214
|
+
foreignDomain.info.version = '1.0.0'
|
|
215
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
216
|
+
// @ts-expect-error For testing purposes
|
|
217
|
+
const foundEntity = dataDomain.findForeignEntity(123, foreignDomain.key)
|
|
218
|
+
assert.isUndefined(foundEntity)
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
test('returns undefined if key is a boolean', ({ assert }) => {
|
|
222
|
+
const dataDomain = new DataDomain()
|
|
223
|
+
const foreignDomain = new DataDomain()
|
|
224
|
+
foreignDomain.info.version = '1.0.0'
|
|
225
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
226
|
+
// @ts-expect-error For testing purposes
|
|
227
|
+
const foundEntity = dataDomain.findForeignEntity(true, foreignDomain.key)
|
|
228
|
+
assert.isUndefined(foundEntity)
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
test('returns undefined if key is an object', ({ assert }) => {
|
|
232
|
+
const dataDomain = new DataDomain()
|
|
233
|
+
const foreignDomain = new DataDomain()
|
|
234
|
+
foreignDomain.info.version = '1.0.0'
|
|
235
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
236
|
+
// @ts-expect-error For testing purposes
|
|
237
|
+
const foundEntity = dataDomain.findForeignEntity({}, foreignDomain.key)
|
|
238
|
+
assert.isUndefined(foundEntity)
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
test('returns undefined if key is an array', ({ assert }) => {
|
|
242
|
+
const dataDomain = new DataDomain()
|
|
243
|
+
const foreignDomain = new DataDomain()
|
|
244
|
+
foreignDomain.info.version = '1.0.0'
|
|
245
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
246
|
+
// @ts-expect-error For testing purposes
|
|
247
|
+
const foundEntity = dataDomain.findForeignEntity([], foreignDomain.key)
|
|
248
|
+
assert.isUndefined(foundEntity)
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
test('returns undefined if key is a function', ({ assert }) => {
|
|
252
|
+
const dataDomain = new DataDomain()
|
|
253
|
+
const foreignDomain = new DataDomain()
|
|
254
|
+
foreignDomain.info.version = '1.0.0'
|
|
255
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
256
|
+
// @ts-expect-error For testing purposes
|
|
257
|
+
const foundEntity = dataDomain.findForeignEntity(() => {}, foreignDomain.key)
|
|
258
|
+
assert.isUndefined(foundEntity)
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
test('returns undefined if domainKey is undefined', ({ assert }) => {
|
|
262
|
+
const dataDomain = new DataDomain()
|
|
263
|
+
const foreignDomain = new DataDomain()
|
|
264
|
+
foreignDomain.info.version = '1.0.0'
|
|
265
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
266
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
267
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
268
|
+
// @ts-expect-error For testing purposes
|
|
269
|
+
const foundEntity = dataDomain.findForeignEntity(entity.key, undefined)
|
|
270
|
+
assert.isUndefined(foundEntity)
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
test('returns undefined if domainKey is null', ({ assert }) => {
|
|
274
|
+
const dataDomain = new DataDomain()
|
|
275
|
+
const foreignDomain = new DataDomain()
|
|
276
|
+
foreignDomain.info.version = '1.0.0'
|
|
277
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
278
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
279
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
280
|
+
// @ts-expect-error For testing purposes
|
|
281
|
+
const foundEntity = dataDomain.findForeignEntity(entity.key, null)
|
|
282
|
+
assert.isUndefined(foundEntity)
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
test('returns undefined if domainKey is an empty string', ({ assert }) => {
|
|
286
|
+
const dataDomain = new DataDomain()
|
|
287
|
+
const foreignDomain = new DataDomain()
|
|
288
|
+
foreignDomain.info.version = '1.0.0'
|
|
289
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
290
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
291
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
292
|
+
const foundEntity = dataDomain.findForeignEntity(entity.key, '')
|
|
293
|
+
assert.isUndefined(foundEntity)
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
test('returns undefined if domainKey is a number', ({ assert }) => {
|
|
297
|
+
const dataDomain = new DataDomain()
|
|
298
|
+
const foreignDomain = new DataDomain()
|
|
299
|
+
foreignDomain.info.version = '1.0.0'
|
|
300
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
301
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
302
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
303
|
+
// @ts-expect-error For testing purposes
|
|
304
|
+
const foundEntity = dataDomain.findForeignEntity(entity.key, 123)
|
|
305
|
+
assert.isUndefined(foundEntity)
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
test('returns undefined if domainKey is a boolean', ({ assert }) => {
|
|
309
|
+
const dataDomain = new DataDomain()
|
|
310
|
+
const foreignDomain = new DataDomain()
|
|
311
|
+
foreignDomain.info.version = '1.0.0'
|
|
312
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
313
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
314
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
315
|
+
// @ts-expect-error For testing purposes
|
|
316
|
+
const foundEntity = dataDomain.findForeignEntity(entity.key, true)
|
|
317
|
+
assert.isUndefined(foundEntity)
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
test('returns undefined if domainKey is an object', ({ assert }) => {
|
|
321
|
+
const dataDomain = new DataDomain()
|
|
322
|
+
const foreignDomain = new DataDomain()
|
|
323
|
+
foreignDomain.info.version = '1.0.0'
|
|
324
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
325
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
326
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
327
|
+
// @ts-expect-error For testing purposes
|
|
328
|
+
const foundEntity = dataDomain.findForeignEntity(entity.key, {})
|
|
329
|
+
assert.isUndefined(foundEntity)
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
test('returns undefined if domainKey is an array', ({ assert }) => {
|
|
333
|
+
const dataDomain = new DataDomain()
|
|
334
|
+
const foreignDomain = new DataDomain()
|
|
335
|
+
foreignDomain.info.version = '1.0.0'
|
|
336
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
337
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
338
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
339
|
+
// @ts-expect-error For testing purposes
|
|
340
|
+
const foundEntity = dataDomain.findForeignEntity(entity.key, [])
|
|
341
|
+
assert.isUndefined(foundEntity)
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
test('returns undefined if domainKey is a function', ({ assert }) => {
|
|
345
|
+
const dataDomain = new DataDomain()
|
|
346
|
+
const foreignDomain = new DataDomain()
|
|
347
|
+
foreignDomain.info.version = '1.0.0'
|
|
348
|
+
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
349
|
+
const entity = foreignDomain.addEntity(model.key, { key: 'test-entity' })
|
|
350
|
+
dataDomain.registerForeignDomain(foreignDomain)
|
|
351
|
+
// @ts-expect-error For testing purposes
|
|
352
|
+
const foundEntity = dataDomain.findForeignEntity(entity.key, () => {})
|
|
353
|
+
assert.isUndefined(foundEntity)
|
|
354
|
+
})
|
|
355
|
+
})
|