@api-client/core 0.11.11 → 0.12.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/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 +7 -4
- 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 +17 -16
- package/build/src/amf/DataValueGenerator.js.map +1 -1
- package/build/src/amf/models/AmfDataNode.d.ts.map +1 -1
- package/build/src/amf/models/AmfDataNode.js +2 -2
- package/build/src/amf/models/AmfDataNode.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/lib/uuid.d.ts +1 -1
- package/build/src/lib/uuid.js +1 -1
- package/build/src/lib/uuid.js.map +1 -1
- package/build/src/mocking/lib/History.js +8 -8
- package/build/src/mocking/lib/History.js.map +1 -1
- package/build/src/mocking/lib/HostRules.js +1 -1
- package/build/src/mocking/lib/HostRules.js.map +1 -1
- package/build/src/mocking/lib/User.js +2 -2
- package/build/src/mocking/lib/User.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 +1141 -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} +11 -8
- 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} +21 -20
- 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} +4 -3
- 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} +9 -8
- 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} +9 -5
- 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} +10 -7
- 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/AuthorizationData.js +3 -3
- package/build/src/models/AuthorizationData.js.map +1 -1
- package/build/src/models/CertificateFile.js +2 -2
- package/build/src/models/CertificateFile.js.map +1 -1
- package/build/src/models/ClientCertificate.js +5 -5
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/Environment.js +6 -6
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/Folder.js +2 -2
- package/build/src/models/Folder.js.map +1 -1
- package/build/src/models/HostRule.js +4 -4
- package/build/src/models/HostRule.js.map +1 -1
- package/build/src/models/HttpProject.js +12 -12
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/Project.d.ts.map +1 -1
- package/build/src/models/Project.js +2 -2
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts.map +1 -1
- package/build/src/models/ProjectFolder.js +6 -6
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectRequest.d.ts.map +1 -1
- package/build/src/models/ProjectRequest.js +8 -8
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/ProjectSchema.js +6 -6
- package/build/src/models/ProjectSchema.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 +4 -2
- package/build/src/models/store/DataFile.js.map +1 -1
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +3 -3
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/Organization.js +3 -3
- package/build/src/models/store/Organization.js.map +1 -1
- package/build/src/models/store/Permission.js +7 -7
- package/build/src/models/store/Permission.js.map +1 -1
- package/build/src/models/store/UserIdentity.js +3 -3
- package/build/src/models/store/UserIdentity.js.map +1 -1
- package/build/src/models/transformers/ArcDexieTransformer.js +4 -4
- package/build/src/models/transformers/ArcDexieTransformer.js.map +1 -1
- package/build/src/models/transformers/ArcLegacyTransformer.js +3 -3
- package/build/src/models/transformers/ArcLegacyTransformer.js.map +1 -1
- package/build/src/models/transformers/ArcPouchTransformer.js +2 -2
- package/build/src/models/transformers/ArcPouchTransformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV21Transformer.js +2 -2
- package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV2Transformer.js +2 -2
- package/build/src/models/transformers/PostmanV2Transformer.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/patch/PatchClient.js +2 -2
- package/build/src/patch/PatchClient.js.map +1 -1
- 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 +3 -3
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/data/models/example-generator-api.json +8 -8
- package/package.json +20 -6
- package/readme.md +1 -1
- package/src/amf/AmfShapeGenerator.ts +10 -7
- package/src/amf/AmfTypes.ts +2 -2
- package/src/amf/DataValueGenerator.ts +24 -23
- package/src/amf/models/AmfDataNode.ts +2 -2
- 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/lib/uuid.ts +1 -1
- package/src/mocking/lib/History.ts +8 -8
- package/src/mocking/lib/HostRules.ts +1 -1
- package/src/mocking/lib/User.ts +2 -2
- package/src/modeling/Bindings.ts +2 -2
- package/src/modeling/DataDomain.ts +1220 -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} +15 -10
- package/src/modeling/{DataEntity.ts → legacy/DataEntity.ts} +30 -25
- package/src/modeling/{DataEntityBuilder.ts → legacy/DataEntityBuilder.ts} +5 -4
- package/src/modeling/legacy/DataImpactAnalysis.ts +530 -0
- package/src/modeling/{DataModel.ts → legacy/DataModel.ts} +12 -10
- package/src/modeling/{DataNamespace.ts → legacy/DataNamespace.ts} +25 -7
- package/src/modeling/{DataProperty.ts → legacy/DataProperty.ts} +17 -9
- package/src/modeling/observed.ts +267 -0
- package/src/modeling/types.ts +174 -1
- package/src/models/AuthorizationData.ts +3 -3
- package/src/models/CertificateFile.ts +2 -2
- package/src/models/ClientCertificate.ts +5 -5
- package/src/models/Environment.ts +6 -6
- package/src/models/Folder.ts +2 -2
- package/src/models/HostRule.ts +4 -4
- package/src/models/HttpProject.ts +12 -12
- package/src/models/Project.ts +2 -2
- package/src/models/ProjectFolder.ts +6 -6
- package/src/models/ProjectRequest.ts +8 -8
- package/src/models/ProjectSchema.ts +6 -6
- package/src/models/Thing.ts +70 -5
- package/src/models/kinds.ts +32 -6
- package/src/models/store/DataFile.ts +5 -3
- package/src/models/store/File.ts +3 -3
- package/src/models/store/Organization.ts +3 -3
- package/src/models/store/Permission.ts +7 -7
- package/src/models/store/UserIdentity.ts +3 -3
- package/src/models/transformers/ArcDexieTransformer.ts +4 -4
- package/src/models/transformers/ArcLegacyTransformer.ts +3 -3
- package/src/models/transformers/ArcPouchTransformer.ts +2 -2
- package/src/models/transformers/PostmanV21Transformer.ts +2 -2
- package/src/models/transformers/PostmanV2Transformer.ts +2 -2
- package/src/models/types.ts +11 -0
- package/src/patch/PatchClient.ts +2 -2
- package/src/runtime/store/FilesSdk.ts +5 -5
- 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/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +8 -8
- 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,658 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import { DataDomain } from '../../../src/modeling/DataDomain.js'
|
|
3
|
+
import { DomainModel } from '../../../src/modeling/DomainModel.js'
|
|
4
|
+
|
|
5
|
+
test.group('DataDomain.addModel()', () => {
|
|
6
|
+
test('addModel adds a model to the graph', ({ assert }) => {
|
|
7
|
+
const dataDomain = new DataDomain()
|
|
8
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
9
|
+
assert.instanceOf(model, DomainModel)
|
|
10
|
+
assert.isTrue(dataDomain.graph.hasNode(model.key))
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('addModel adds a model to the graph with a parent', ({ assert }) => {
|
|
14
|
+
const dataDomain = new DataDomain()
|
|
15
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
16
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
17
|
+
assert.instanceOf(model, DomainModel)
|
|
18
|
+
assert.isTrue(dataDomain.graph.hasNode(model.key))
|
|
19
|
+
assert.equal(dataDomain.graph.parent(model.key), parentNamespace.key)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('addModel throws an error if parent namespace does not exist', ({ assert }) => {
|
|
23
|
+
const dataDomain = new DataDomain()
|
|
24
|
+
assert.throws(() => {
|
|
25
|
+
dataDomain.addModel({ key: 'test-model' }, 'non-existent-parent')
|
|
26
|
+
}, 'Parent non-existent-parent does not exist')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('addModel adds a model with default values', ({ assert }) => {
|
|
30
|
+
const dataDomain = new DataDomain()
|
|
31
|
+
const model = dataDomain.addModel()
|
|
32
|
+
assert.instanceOf(model, DomainModel)
|
|
33
|
+
assert.isTrue(dataDomain.graph.hasNode(model.key))
|
|
34
|
+
assert.isUndefined(dataDomain.graph.parent(model.key))
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('addModel adds a model to a parent namespace', ({ assert }) => {
|
|
38
|
+
const dataDomain = new DataDomain()
|
|
39
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
40
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
41
|
+
assert.instanceOf(model, DomainModel)
|
|
42
|
+
assert.isTrue(dataDomain.graph.hasNode(model.key))
|
|
43
|
+
assert.equal(dataDomain.graph.parent(model.key), parentNamespace.key)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('addModel notifies change', async ({ assert }) => {
|
|
47
|
+
const dataDomain = new DataDomain()
|
|
48
|
+
dataDomain.addModel({ key: 'test-model' })
|
|
49
|
+
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('addModel adds a model to the root of the graph', ({ assert }) => {
|
|
53
|
+
const dataDomain = new DataDomain()
|
|
54
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
55
|
+
assert.instanceOf(model, DomainModel)
|
|
56
|
+
assert.isTrue(dataDomain.graph.hasNode(model.key))
|
|
57
|
+
assert.isUndefined(dataDomain.graph.parent(model.key))
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('addModel adds a model to a parent namespace - checks parent-child relationship', ({ assert }) => {
|
|
61
|
+
const dataDomain = new DataDomain()
|
|
62
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
63
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
64
|
+
assert.isTrue(dataDomain.graph.hasParent(model.key, parentNamespace.key))
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('addModel adds a model to the root of the graph - checks parent-child relationship', ({ assert }) => {
|
|
68
|
+
const dataDomain = new DataDomain()
|
|
69
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
70
|
+
assert.isFalse(dataDomain.graph.hasParent(model.key, dataDomain.key))
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('addModel adds a model to a parent namespace - checks items list', ({ assert }) => {
|
|
74
|
+
const dataDomain = new DataDomain()
|
|
75
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
76
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
77
|
+
const parentNs = dataDomain.findNamespace(parentNamespace.key)
|
|
78
|
+
assert.deepInclude([...parentNs!.listModels()], model)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('addModel adds a model to the root of the graph - checks items list', ({ assert }) => {
|
|
82
|
+
const dataDomain = new DataDomain()
|
|
83
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
84
|
+
assert.deepInclude([...dataDomain.listGraphModels()], model)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('addModel throws an error if parent is not a namespace', ({ assert }) => {
|
|
88
|
+
const dataDomain = new DataDomain()
|
|
89
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
90
|
+
assert.throws(() => {
|
|
91
|
+
dataDomain.addModel({ key: 'child-model' }, model.key)
|
|
92
|
+
}, `Parent namespace ${model.key} is not a valid namespace`)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('addModel adds to the fields list', ({ assert }) => {
|
|
96
|
+
const root = new DataDomain()
|
|
97
|
+
const m1 = root.addModel({})
|
|
98
|
+
assert.lengthOf(root.fields, 1)
|
|
99
|
+
const [field] = root.fields
|
|
100
|
+
assert.equal(field.key, m1.key)
|
|
101
|
+
assert.equal(field.type, 'model')
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test.group('DataDomain.removeModel()', () => {
|
|
106
|
+
test('removeModel removes a model from the graph', ({ assert }) => {
|
|
107
|
+
const dataDomain = new DataDomain()
|
|
108
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
109
|
+
dataDomain.removeModel(model.key)
|
|
110
|
+
assert.isFalse(dataDomain.graph.hasNode(model.key))
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test('removeModel throws an error if model does not exist', ({ assert }) => {
|
|
114
|
+
const dataDomain = new DataDomain()
|
|
115
|
+
assert.throws(() => {
|
|
116
|
+
dataDomain.removeModel('non-existent-model')
|
|
117
|
+
}, 'Data model non-existent-model does not exist')
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('removeModel notifies change', async ({ assert }) => {
|
|
121
|
+
const dataDomain = new DataDomain()
|
|
122
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
123
|
+
dataDomain.removeModel(model.key)
|
|
124
|
+
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test('removeModel removes a model from the root of the graph', ({ assert }) => {
|
|
128
|
+
const dataDomain = new DataDomain()
|
|
129
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
130
|
+
dataDomain.removeModel(model.key)
|
|
131
|
+
assert.isFalse(dataDomain.graph.hasNode(model.key))
|
|
132
|
+
assert.isUndefined(dataDomain.graph.parent(model.key))
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('removeModel removes a model from a parent namespace', ({ assert }) => {
|
|
136
|
+
const dataDomain = new DataDomain()
|
|
137
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
138
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
139
|
+
dataDomain.removeModel(model.key)
|
|
140
|
+
assert.isFalse(dataDomain.graph.hasNode(model.key))
|
|
141
|
+
assert.equal(dataDomain.graph.parent(model.key), undefined)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
test('removeModel removes a model with entities', ({ assert }) => {
|
|
145
|
+
const dataDomain = new DataDomain()
|
|
146
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
147
|
+
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
148
|
+
dataDomain.removeModel(model.key)
|
|
149
|
+
assert.isFalse(dataDomain.graph.hasNode(model.key))
|
|
150
|
+
assert.isFalse(dataDomain.graph.hasNode(entity.key))
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
test('removeModel removes a model from a parent namespace - checks parent-child relationship', ({ assert }) => {
|
|
154
|
+
const dataDomain = new DataDomain()
|
|
155
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
156
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
157
|
+
dataDomain.removeModel(model.key)
|
|
158
|
+
assert.isFalse(dataDomain.graph.hasParent(model.key, parentNamespace.key))
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
test('removeModel removes a model from the root of the graph - checks parent-child relationship', ({ assert }) => {
|
|
162
|
+
const dataDomain = new DataDomain()
|
|
163
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
164
|
+
dataDomain.removeModel(model.key)
|
|
165
|
+
assert.isFalse(dataDomain.graph.hasParent(model.key, dataDomain.key))
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
test('removeModel removes a model from a parent namespace - checks items list', ({ assert }) => {
|
|
169
|
+
const dataDomain = new DataDomain()
|
|
170
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
171
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
172
|
+
dataDomain.removeModel(model.key)
|
|
173
|
+
const parentNs = dataDomain.findNamespace(parentNamespace.key)
|
|
174
|
+
assert.notDeepInclude([...parentNs!.listModels()], model)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
test('removeModel removes a model from the root of the graph - checks items list', ({ assert }) => {
|
|
178
|
+
const dataDomain = new DataDomain()
|
|
179
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
180
|
+
dataDomain.removeModel(model.key)
|
|
181
|
+
assert.notDeepInclude([...dataDomain.listGraphModels()], model)
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
test('removeModel throws an error if key is not a model', ({ assert }) => {
|
|
185
|
+
const dataDomain = new DataDomain()
|
|
186
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
187
|
+
assert.throws(() => {
|
|
188
|
+
dataDomain.removeModel(namespace.key)
|
|
189
|
+
}, `Data model ${namespace.key} not found`)
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
test('removeModel removes from fields', ({ assert }) => {
|
|
193
|
+
const root = new DataDomain()
|
|
194
|
+
const m1 = root.addModel()
|
|
195
|
+
root.removeModel(m1.key)
|
|
196
|
+
assert.deepEqual(root.fields, [])
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
test.group('DataDomain.listModels()', () => {
|
|
201
|
+
test('lists all models in the data domain', ({ assert }) => {
|
|
202
|
+
const dataDomain = new DataDomain()
|
|
203
|
+
const model1 = dataDomain.addModel()
|
|
204
|
+
const model2 = dataDomain.addModel()
|
|
205
|
+
const models = [...dataDomain.listModels()]
|
|
206
|
+
assert.lengthOf(models, 2)
|
|
207
|
+
assert.deepInclude(models, model1)
|
|
208
|
+
assert.deepInclude(models, model2)
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
test('returns an empty array if there are no models', ({ assert }) => {
|
|
212
|
+
const dataDomain = new DataDomain()
|
|
213
|
+
const models = [...dataDomain.listModels()]
|
|
214
|
+
assert.lengthOf(models, 0)
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
test('returns only models', ({ assert }) => {
|
|
218
|
+
const dataDomain = new DataDomain()
|
|
219
|
+
const model1 = dataDomain.addModel()
|
|
220
|
+
dataDomain.addNamespace()
|
|
221
|
+
const models = [...dataDomain.listModels()]
|
|
222
|
+
assert.lengthOf(models, 1)
|
|
223
|
+
assert.deepInclude(models, model1)
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
test('models in the list are of type DomainModel', ({ assert }) => {
|
|
227
|
+
const dataDomain = new DataDomain()
|
|
228
|
+
dataDomain.addModel()
|
|
229
|
+
const models = [...dataDomain.listModels()]
|
|
230
|
+
assert.instanceOf(models[0], DomainModel)
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
test('lists models in the order they were added', ({ assert }) => {
|
|
234
|
+
const dataDomain = new DataDomain()
|
|
235
|
+
const model1 = dataDomain.addModel()
|
|
236
|
+
const model2 = dataDomain.addModel()
|
|
237
|
+
const models = [...dataDomain.listModels()]
|
|
238
|
+
assert.deepEqual(models, [model1, model2])
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
test('lists models when there are no models', ({ assert }) => {
|
|
242
|
+
const dataDomain = new DataDomain()
|
|
243
|
+
const models = [...dataDomain.listModels()]
|
|
244
|
+
assert.deepEqual(models, [])
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
test('lists models when there are other domain elements', ({ assert }) => {
|
|
248
|
+
const dataDomain = new DataDomain()
|
|
249
|
+
const model1 = dataDomain.addModel()
|
|
250
|
+
dataDomain.addNamespace()
|
|
251
|
+
const models = [...dataDomain.listModels()]
|
|
252
|
+
assert.deepEqual(models, [model1])
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
test.group('DataDomain.hasModels()', () => {
|
|
257
|
+
test('returns true if there are child models', ({ assert }) => {
|
|
258
|
+
const dataDomain = new DataDomain()
|
|
259
|
+
dataDomain.addModel()
|
|
260
|
+
assert.isTrue(dataDomain.hasModels())
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
test('returns false if there are no child models', ({ assert }) => {
|
|
264
|
+
const dataDomain = new DataDomain()
|
|
265
|
+
assert.isFalse(dataDomain.hasModels())
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
test('returns false if there are only namespaces', ({ assert }) => {
|
|
269
|
+
const dataDomain = new DataDomain()
|
|
270
|
+
dataDomain.addNamespace()
|
|
271
|
+
assert.isFalse(dataDomain.hasModels())
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
test('returns true if there are both models and namespaces', ({ assert }) => {
|
|
275
|
+
const dataDomain = new DataDomain()
|
|
276
|
+
dataDomain.addModel()
|
|
277
|
+
dataDomain.addNamespace()
|
|
278
|
+
assert.isTrue(dataDomain.hasModels())
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
test('returns false if the data domain has no fields', ({ assert }) => {
|
|
282
|
+
const dataDomain = new DataDomain()
|
|
283
|
+
dataDomain.fields = []
|
|
284
|
+
assert.isFalse(dataDomain.hasModels())
|
|
285
|
+
})
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
test.group('DataDomain.listGraphModels()', () => {
|
|
289
|
+
test('lists all models in the graph', ({ assert }) => {
|
|
290
|
+
const dataDomain = new DataDomain()
|
|
291
|
+
const model1 = dataDomain.addModel({ key: 'model1' })
|
|
292
|
+
const model2 = dataDomain.addModel({ key: 'model2' })
|
|
293
|
+
const models = [...dataDomain.listGraphModels()]
|
|
294
|
+
assert.lengthOf(models, 2)
|
|
295
|
+
assert.deepInclude(models, model1)
|
|
296
|
+
assert.deepInclude(models, model2)
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
test('lists all models in the graph with a parent', ({ assert }) => {
|
|
300
|
+
const dataDomain = new DataDomain()
|
|
301
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
302
|
+
const model1 = dataDomain.addModel({ key: 'model1' }, parentNamespace.key)
|
|
303
|
+
dataDomain.addModel({ key: 'model2' })
|
|
304
|
+
const models = [...dataDomain.listGraphModels(parentNamespace.key)]
|
|
305
|
+
assert.lengthOf(models, 1)
|
|
306
|
+
assert.deepInclude(models, model1)
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
test('returns an empty array if there are no models', ({ assert }) => {
|
|
310
|
+
const dataDomain = new DataDomain()
|
|
311
|
+
const models = [...dataDomain.listGraphModels()]
|
|
312
|
+
assert.lengthOf(models, 0)
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
test('returns an empty array if the parent does not exist', ({ assert }) => {
|
|
316
|
+
const dataDomain = new DataDomain()
|
|
317
|
+
const models = [...dataDomain.listGraphModels('non-existent-parent')]
|
|
318
|
+
assert.lengthOf(models, 0)
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
test('returns only models', ({ assert }) => {
|
|
322
|
+
const dataDomain = new DataDomain()
|
|
323
|
+
const model1 = dataDomain.addModel({ key: 'model1' })
|
|
324
|
+
dataDomain.addNamespace({ key: 'ns1' })
|
|
325
|
+
const models = [...dataDomain.listGraphModels()]
|
|
326
|
+
assert.lengthOf(models, 1)
|
|
327
|
+
assert.deepInclude(models, model1)
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
test('returns only models for the given parent', ({ assert }) => {
|
|
331
|
+
const dataDomain = new DataDomain()
|
|
332
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
333
|
+
const model1 = dataDomain.addModel({ key: 'model1' }, parentNamespace.key)
|
|
334
|
+
dataDomain.addModel({ key: 'model2' })
|
|
335
|
+
dataDomain.addNamespace({ key: 'ns1' }, parentNamespace.key)
|
|
336
|
+
dataDomain.addNamespace({ key: 'ns2' })
|
|
337
|
+
const models = [...dataDomain.listGraphModels(parentNamespace.key)]
|
|
338
|
+
assert.lengthOf(models, 1)
|
|
339
|
+
assert.deepInclude(models, model1)
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
test('models in the list are of type DomainModel', ({ assert }) => {
|
|
343
|
+
const dataDomain = new DataDomain()
|
|
344
|
+
dataDomain.addModel({ key: 'model1' })
|
|
345
|
+
const models = [...dataDomain.listGraphModels()]
|
|
346
|
+
assert.instanceOf(models[0], DomainModel)
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
test('lists models from the root when no parent is provided', ({ assert }) => {
|
|
350
|
+
const dataDomain = new DataDomain()
|
|
351
|
+
const model1 = dataDomain.addModel({ key: 'model1' })
|
|
352
|
+
const model2 = dataDomain.addModel({ key: 'model2' })
|
|
353
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
354
|
+
dataDomain.addModel({ key: 'model3' }, parentNamespace.key)
|
|
355
|
+
|
|
356
|
+
const models = [...dataDomain.listGraphModels()]
|
|
357
|
+
assert.lengthOf(models, 2)
|
|
358
|
+
assert.deepInclude(models, model1)
|
|
359
|
+
assert.deepInclude(models, model2)
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
test('lists models from a parent namespace', ({ assert }) => {
|
|
363
|
+
const dataDomain = new DataDomain()
|
|
364
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
365
|
+
const model1 = dataDomain.addModel({ key: 'model1' }, parentNamespace.key)
|
|
366
|
+
dataDomain.addModel({ key: 'model2' })
|
|
367
|
+
|
|
368
|
+
const models = [...dataDomain.listGraphModels(parentNamespace.key)]
|
|
369
|
+
assert.lengthOf(models, 1)
|
|
370
|
+
assert.deepInclude(models, model1)
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
test('lists models from a parent namespace and the parent has no models', ({ assert }) => {
|
|
374
|
+
const dataDomain = new DataDomain()
|
|
375
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
376
|
+
|
|
377
|
+
const models = [...dataDomain.listGraphModels(parentNamespace.key)]
|
|
378
|
+
assert.lengthOf(models, 0)
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
test('lists models from a parent namespace and the parent is not a namespace', ({ assert }) => {
|
|
382
|
+
const dataDomain = new DataDomain()
|
|
383
|
+
const model = dataDomain.addModel({ key: 'model-1' })
|
|
384
|
+
|
|
385
|
+
const models = [...dataDomain.listGraphModels(model.key)]
|
|
386
|
+
assert.lengthOf(models, 0)
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
test('lists models from a parent namespace and the parent is not in the graph', ({ assert }) => {
|
|
390
|
+
const dataDomain = new DataDomain()
|
|
391
|
+
|
|
392
|
+
const models = [...dataDomain.listGraphModels('non-existent-parent')]
|
|
393
|
+
assert.lengthOf(models, 0)
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
test('lists all children for the root, excluding foreign models', ({ assert }) => {
|
|
397
|
+
const domain1 = new DataDomain()
|
|
398
|
+
const m1 = domain1.addModel({ key: 'model1' })
|
|
399
|
+
|
|
400
|
+
const domain2 = new DataDomain()
|
|
401
|
+
domain2.addModel({ key: 'model2' })
|
|
402
|
+
domain2.info.version = '1.0.0'
|
|
403
|
+
domain1.registerForeignDomain(domain2)
|
|
404
|
+
|
|
405
|
+
const children = [...domain1.listGraphModels()]
|
|
406
|
+
assert.lengthOf(children, 1)
|
|
407
|
+
assert.deepInclude(children, m1)
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
test('lists all children for a namespace, excluding foreign models', ({ assert }) => {
|
|
411
|
+
const domain1 = new DataDomain()
|
|
412
|
+
const ns1 = domain1.addNamespace({ key: 'ns1' })
|
|
413
|
+
const m1 = domain1.addModel({ key: 'model1' }, ns1.key)
|
|
414
|
+
|
|
415
|
+
const domain2 = new DataDomain()
|
|
416
|
+
domain2.addModel({ key: 'model2' })
|
|
417
|
+
domain2.info.version = '1.0.0'
|
|
418
|
+
domain1.registerForeignDomain(domain2)
|
|
419
|
+
|
|
420
|
+
const children = [...domain1.listGraphModels(ns1.key)]
|
|
421
|
+
assert.lengthOf(children, 1)
|
|
422
|
+
assert.deepInclude(children, m1)
|
|
423
|
+
})
|
|
424
|
+
})
|
|
425
|
+
|
|
426
|
+
test.group('DataDomain.findModel()', () => {
|
|
427
|
+
test('finds a model by its key', ({ assert }) => {
|
|
428
|
+
const dataDomain = new DataDomain()
|
|
429
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
430
|
+
const foundModel = dataDomain.findModel('test-model')
|
|
431
|
+
assert.deepEqual(foundModel, model)
|
|
432
|
+
})
|
|
433
|
+
|
|
434
|
+
test('returns undefined if model does not exist', ({ assert }) => {
|
|
435
|
+
const dataDomain = new DataDomain()
|
|
436
|
+
const foundModel = dataDomain.findModel('non-existent-model')
|
|
437
|
+
assert.isUndefined(foundModel)
|
|
438
|
+
})
|
|
439
|
+
|
|
440
|
+
test('returns undefined if key is not a model', ({ assert }) => {
|
|
441
|
+
const dataDomain = new DataDomain()
|
|
442
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
443
|
+
const foundModel = dataDomain.findModel(namespace.key)
|
|
444
|
+
assert.isUndefined(foundModel)
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
test('returns undefined if key is undefined', ({ assert }) => {
|
|
448
|
+
const dataDomain = new DataDomain()
|
|
449
|
+
// @ts-expect-error For testing purposes
|
|
450
|
+
const foundModel = dataDomain.findModel(undefined)
|
|
451
|
+
assert.isUndefined(foundModel)
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
test('returns undefined if key is null', ({ assert }) => {
|
|
455
|
+
const dataDomain = new DataDomain()
|
|
456
|
+
// @ts-expect-error For testing purposes
|
|
457
|
+
const foundModel = dataDomain.findModel(null)
|
|
458
|
+
assert.isUndefined(foundModel)
|
|
459
|
+
})
|
|
460
|
+
|
|
461
|
+
test('returns undefined if key is an empty string', ({ assert }) => {
|
|
462
|
+
const dataDomain = new DataDomain()
|
|
463
|
+
const foundModel = dataDomain.findModel('')
|
|
464
|
+
assert.isUndefined(foundModel)
|
|
465
|
+
})
|
|
466
|
+
|
|
467
|
+
test('returns undefined if key is a number', ({ assert }) => {
|
|
468
|
+
const dataDomain = new DataDomain()
|
|
469
|
+
// @ts-expect-error For testing purposes
|
|
470
|
+
const foundModel = dataDomain.findModel(123)
|
|
471
|
+
assert.isUndefined(foundModel)
|
|
472
|
+
})
|
|
473
|
+
|
|
474
|
+
test('returns undefined if key is a boolean', ({ assert }) => {
|
|
475
|
+
const dataDomain = new DataDomain()
|
|
476
|
+
// @ts-expect-error For testing purposes
|
|
477
|
+
const foundModel = dataDomain.findModel(true)
|
|
478
|
+
assert.isUndefined(foundModel)
|
|
479
|
+
})
|
|
480
|
+
|
|
481
|
+
test('returns undefined if key is an object', ({ assert }) => {
|
|
482
|
+
const dataDomain = new DataDomain()
|
|
483
|
+
// @ts-expect-error For testing purposes
|
|
484
|
+
const foundModel = dataDomain.findModel({})
|
|
485
|
+
assert.isUndefined(foundModel)
|
|
486
|
+
})
|
|
487
|
+
|
|
488
|
+
test('returns undefined if key is an array', ({ assert }) => {
|
|
489
|
+
const dataDomain = new DataDomain()
|
|
490
|
+
// @ts-expect-error For testing purposes
|
|
491
|
+
const foundModel = dataDomain.findModel([])
|
|
492
|
+
assert.isUndefined(foundModel)
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
test('returns undefined if key is a function', ({ assert }) => {
|
|
496
|
+
const dataDomain = new DataDomain()
|
|
497
|
+
// @ts-expect-error For testing purposes
|
|
498
|
+
const foundModel = dataDomain.findModel(() => {})
|
|
499
|
+
assert.isUndefined(foundModel)
|
|
500
|
+
})
|
|
501
|
+
})
|
|
502
|
+
|
|
503
|
+
test.group('DataDomain.moveModel()', () => {
|
|
504
|
+
test('moves a model from the root to a parent namespace', ({ assert }) => {
|
|
505
|
+
const dataDomain = new DataDomain()
|
|
506
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
507
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
508
|
+
dataDomain.moveModel(model.key, parentNamespace.key)
|
|
509
|
+
assert.equal(dataDomain.graph.parent(model.key), parentNamespace.key)
|
|
510
|
+
})
|
|
511
|
+
|
|
512
|
+
test('moves a model from a parent namespace to the root', ({ assert }) => {
|
|
513
|
+
const dataDomain = new DataDomain()
|
|
514
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
515
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
516
|
+
dataDomain.moveModel(model.key)
|
|
517
|
+
assert.equal(dataDomain.graph.parent(model.key), undefined)
|
|
518
|
+
})
|
|
519
|
+
|
|
520
|
+
test('moves a model from one parent namespace to another', ({ assert }) => {
|
|
521
|
+
const dataDomain = new DataDomain()
|
|
522
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
523
|
+
const parentNamespace2 = dataDomain.addNamespace({ key: 'parent-ns2' })
|
|
524
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace1.key)
|
|
525
|
+
dataDomain.moveModel(model.key, parentNamespace2.key)
|
|
526
|
+
assert.equal(dataDomain.graph.parent(model.key), parentNamespace2.key)
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
test('throws an error if model does not exist', ({ assert }) => {
|
|
530
|
+
const dataDomain = new DataDomain()
|
|
531
|
+
assert.throws(() => {
|
|
532
|
+
dataDomain.moveModel('non-existent-model', 'parent-ns')
|
|
533
|
+
}, 'Data model non-existent-model does not exist')
|
|
534
|
+
})
|
|
535
|
+
|
|
536
|
+
test('throws an error if parent namespace does not exist', ({ assert }) => {
|
|
537
|
+
const dataDomain = new DataDomain()
|
|
538
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
539
|
+
assert.throws(() => {
|
|
540
|
+
dataDomain.moveModel(model.key, 'non-existent-parent')
|
|
541
|
+
}, 'Parent namespace non-existent-parent does not exist')
|
|
542
|
+
})
|
|
543
|
+
|
|
544
|
+
test('throws an error if model is moved to itself', ({ assert }) => {
|
|
545
|
+
const dataDomain = new DataDomain()
|
|
546
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
547
|
+
assert.throws(() => {
|
|
548
|
+
dataDomain.moveModel(model.key, model.key)
|
|
549
|
+
}, 'Parent namespace test-model does not exist')
|
|
550
|
+
})
|
|
551
|
+
|
|
552
|
+
test('moveModel notifies change', async ({ assert }) => {
|
|
553
|
+
const dataDomain = new DataDomain()
|
|
554
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
555
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
556
|
+
dataDomain.moveModel(model.key, parentNamespace.key)
|
|
557
|
+
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
test('moves a model from the root to a parent namespace - checks parent-child relationship', ({ assert }) => {
|
|
561
|
+
const dataDomain = new DataDomain()
|
|
562
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
563
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
564
|
+
dataDomain.moveModel(model.key, parentNamespace.key)
|
|
565
|
+
assert.isTrue(dataDomain.graph.hasParent(model.key, parentNamespace.key))
|
|
566
|
+
})
|
|
567
|
+
|
|
568
|
+
test('moves a model from a parent namespace to the root - checks parent-child relationship', ({ assert }) => {
|
|
569
|
+
const dataDomain = new DataDomain()
|
|
570
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
571
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
572
|
+
dataDomain.moveModel(model.key)
|
|
573
|
+
assert.isFalse(dataDomain.graph.hasParent(model.key, parentNamespace.key))
|
|
574
|
+
})
|
|
575
|
+
|
|
576
|
+
test('moves a model from one parent namespace to another - checks parent-child relationship', ({ assert }) => {
|
|
577
|
+
const dataDomain = new DataDomain()
|
|
578
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
579
|
+
const parentNamespace2 = dataDomain.addNamespace({ key: 'parent-ns2' })
|
|
580
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace1.key)
|
|
581
|
+
dataDomain.moveModel(model.key, parentNamespace2.key)
|
|
582
|
+
assert.isFalse(dataDomain.graph.hasParent(model.key, parentNamespace1.key))
|
|
583
|
+
assert.isTrue(dataDomain.graph.hasParent(model.key, parentNamespace2.key))
|
|
584
|
+
})
|
|
585
|
+
|
|
586
|
+
test('moves a model from the root to a parent namespace - checks items list', ({ assert }) => {
|
|
587
|
+
const dataDomain = new DataDomain()
|
|
588
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
589
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
590
|
+
dataDomain.moveModel(model.key, parentNamespace.key)
|
|
591
|
+
const parentNs = dataDomain.findNamespace(parentNamespace.key)
|
|
592
|
+
assert.deepInclude([...parentNs!.listModels()], model)
|
|
593
|
+
})
|
|
594
|
+
|
|
595
|
+
test('moves a model from a parent namespace to the root - checks items list', ({ assert }) => {
|
|
596
|
+
const dataDomain = new DataDomain()
|
|
597
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
598
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
599
|
+
dataDomain.moveModel(model.key)
|
|
600
|
+
assert.deepInclude([...dataDomain.listGraphModels()], model)
|
|
601
|
+
})
|
|
602
|
+
|
|
603
|
+
test('moves a model from one parent namespace to another - checks items list', ({ assert }) => {
|
|
604
|
+
const dataDomain = new DataDomain()
|
|
605
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
606
|
+
const parentNamespace2 = dataDomain.addNamespace({ key: 'parent-ns2' })
|
|
607
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace1.key)
|
|
608
|
+
dataDomain.moveModel(model.key, parentNamespace2.key)
|
|
609
|
+
const parentNs1 = dataDomain.findNamespace(parentNamespace1.key)
|
|
610
|
+
const parentNs2 = dataDomain.findNamespace(parentNamespace2.key)
|
|
611
|
+
assert.notDeepInclude([...parentNs1!.listModels()], model)
|
|
612
|
+
assert.deepInclude([...parentNs2!.listModels()], model)
|
|
613
|
+
})
|
|
614
|
+
|
|
615
|
+
test('throws an error if the target is not a namespace', ({ assert }) => {
|
|
616
|
+
const dataDomain = new DataDomain()
|
|
617
|
+
const model1 = dataDomain.addModel({ key: 'test-model' })
|
|
618
|
+
const model2 = dataDomain.addModel({ key: 'other-model' })
|
|
619
|
+
assert.throws(() => {
|
|
620
|
+
dataDomain.moveModel(model1.key, model2.key)
|
|
621
|
+
}, 'Parent namespace other-model does not exist')
|
|
622
|
+
})
|
|
623
|
+
|
|
624
|
+
test('moves a model from the root to a parent namespace - updates fields array', ({ assert }) => {
|
|
625
|
+
const dataDomain = new DataDomain()
|
|
626
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
627
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
628
|
+
dataDomain.moveModel(model.key, parentNamespace.key)
|
|
629
|
+
assert.notDeepInclude(dataDomain.fields, { key: model.key, type: 'model' })
|
|
630
|
+
})
|
|
631
|
+
|
|
632
|
+
test('moves a model from a parent namespace to the root - updates fields array', ({ assert }) => {
|
|
633
|
+
const dataDomain = new DataDomain()
|
|
634
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
635
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
636
|
+
dataDomain.moveModel(model.key)
|
|
637
|
+
assert.deepInclude(dataDomain.fields, { key: model.key, type: 'model' })
|
|
638
|
+
})
|
|
639
|
+
|
|
640
|
+
test('moves a model from one parent namespace to another - updates fields array', ({ assert }) => {
|
|
641
|
+
const dataDomain = new DataDomain()
|
|
642
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
643
|
+
const parentNamespace2 = dataDomain.addNamespace({ key: 'parent-ns2' })
|
|
644
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace1.key)
|
|
645
|
+
dataDomain.moveModel(model.key, parentNamespace2.key)
|
|
646
|
+
assert.notDeepInclude(dataDomain.fields, { key: model.key, type: 'model' })
|
|
647
|
+
})
|
|
648
|
+
|
|
649
|
+
test('moves a model from one parent namespace to another - updates fields array when moving to root', ({
|
|
650
|
+
assert,
|
|
651
|
+
}) => {
|
|
652
|
+
const dataDomain = new DataDomain()
|
|
653
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
654
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace1.key)
|
|
655
|
+
dataDomain.moveModel(model.key)
|
|
656
|
+
assert.deepInclude(dataDomain.fields, { key: model.key, type: 'model' })
|
|
657
|
+
})
|
|
658
|
+
})
|