@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
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DomainNamespaceKind, DomainEntityKind, DomainModelKind, DomainPropertyKind, DomainAssociationKind, DataDomainKind, } from '../models/kinds.js';
|
|
2
2
|
/**
|
|
3
3
|
* # DomainImpactAnalysis
|
|
4
4
|
*
|
|
5
|
-
* The `DomainImpactAnalysis` class is a
|
|
6
|
-
* within a `
|
|
7
|
-
*
|
|
8
|
-
* or association, ensuring data integrity and preventing unintended side effects.
|
|
5
|
+
* The `DomainImpactAnalysis` class is a tool for analyzing the consequences of deleting data domain elements
|
|
6
|
+
* within a `DataDomain`. It helps developers understand the ripple effects of removing a namespace, data model,
|
|
7
|
+
* entity, property, or association, ensuring data integrity and preventing unintended side effects.
|
|
9
8
|
*
|
|
10
9
|
* ## Core Concepts
|
|
11
10
|
*
|
|
12
11
|
* - **Impact Report:** The central output of the `DomainImpactAnalysis` class is an `DomainImpactReport`.
|
|
13
12
|
* This report details the potential consequences of a deletion operation, including:
|
|
14
13
|
* - The object being deleted (`key`, `kind`).
|
|
15
|
-
* - A list of `
|
|
14
|
+
* - A list of `DomainImpactItem` objects, each describing a specific consequence.
|
|
16
15
|
* - Whether the deletion can proceed safely (`canProceed`).
|
|
17
16
|
*
|
|
18
|
-
* - **
|
|
17
|
+
* - **DomainImpactItem:** Each `DomainImpactItem` describes a specific consequence of the deletion.
|
|
18
|
+
* Key properties include:
|
|
19
19
|
* - `key`: The key of the impacted object.
|
|
20
20
|
* - `kind`: The kind of the impacted object.
|
|
21
21
|
* - `type`: The type of impact (currently only `delete`).
|
|
@@ -33,28 +33,29 @@ import { DataNamespaceKind, DataEntityKind, DataModelKind, DataPropertyKind, Dat
|
|
|
33
33
|
*
|
|
34
34
|
* ## Usage
|
|
35
35
|
*
|
|
36
|
-
* 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `
|
|
36
|
+
* 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataDomain` as an argument.
|
|
37
37
|
*
|
|
38
38
|
* ```typescript
|
|
39
|
-
* import {
|
|
39
|
+
* import { DataDomain } from './DataDomain';
|
|
40
40
|
* import { DomainImpactAnalysis } from './DomainImpactAnalysis';
|
|
41
41
|
*
|
|
42
|
-
* const
|
|
43
|
-
* // ... add some data to the
|
|
44
|
-
* const analyzer = new DomainImpactAnalysis(
|
|
42
|
+
* const dataDomain = new DataDomain();
|
|
43
|
+
* // ... add some data to the domain
|
|
44
|
+
* const analyzer = new DomainImpactAnalysis(dataDomain);
|
|
45
45
|
* ```
|
|
46
46
|
*
|
|
47
|
-
* 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `
|
|
47
|
+
* 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `DomainImpactReport` for
|
|
48
|
+
* a specific deletion.
|
|
48
49
|
* Provide the `key` and `kind` of the object to be deleted.
|
|
49
50
|
*
|
|
50
51
|
* ```typescript
|
|
51
|
-
* import {
|
|
52
|
+
* import { DomainEntityKind } from '../models/kinds.js';
|
|
52
53
|
* // ...
|
|
53
54
|
* const entityKey = 'some-entity-key';
|
|
54
|
-
* const report = analyzer.deleteAnalysis(entityKey,
|
|
55
|
+
* const report = analyzer.deleteAnalysis(entityKey, DomainEntityKind);
|
|
55
56
|
* ```
|
|
56
57
|
*
|
|
57
|
-
* 3. **Interpreting the Report:** Examine the `
|
|
58
|
+
* 3. **Interpreting the Report:** Examine the `DomainImpactReport` to understand the consequences of the deletion.
|
|
58
59
|
* - Check `report.canProceed` to see if the deletion is safe.
|
|
59
60
|
* - Iterate through `report.impact` to understand each consequence.
|
|
60
61
|
* - Pay special attention to `impact.blocking` to identify impacts that require manual resolution.
|
|
@@ -79,21 +80,24 @@ import { DataNamespaceKind, DataEntityKind, DataModelKind, DataPropertyKind, Dat
|
|
|
79
80
|
*
|
|
80
81
|
* ## Supported Deletion Scenarios
|
|
81
82
|
*
|
|
82
|
-
* The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain
|
|
83
|
+
* The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain element types:
|
|
83
84
|
*
|
|
84
|
-
* -
|
|
85
|
-
*
|
|
86
|
-
* -
|
|
87
|
-
* -
|
|
88
|
-
*
|
|
89
|
-
* -
|
|
90
|
-
* -
|
|
85
|
+
* - **Namespaces (`DomainNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,
|
|
86
|
+
* data models, entities, properties, and associations.
|
|
87
|
+
* - **Data Models (`DomainModelKind`):** Deleting a data model impacts all its entities, properties, and associations.
|
|
88
|
+
* - **Entities (`DomainEntityKind`):** Deleting an entity impacts its properties, associations, and any other
|
|
89
|
+
* entities that have it as a parent or target in an association.
|
|
90
|
+
* - **Properties (`DomainPropertyKind`):** Deleting a property impacts the entity it belongs to.
|
|
91
|
+
* - **Associations (`DomainAssociationKind`):** Deleting an association impacts the entity it belongs to.
|
|
92
|
+
* - **Data Domain (`DataDomainKind`):** Deleting a data domain is not supported.
|
|
91
93
|
*
|
|
92
94
|
* ## Example: Deleting an Entity
|
|
93
95
|
*
|
|
94
96
|
* Consider the following scenario:
|
|
95
97
|
*
|
|
96
|
-
*
|
|
98
|
+
* ```
|
|
99
|
+
* DataDomain
|
|
100
|
+
* - Namespace: `MyNamespace`
|
|
97
101
|
* - Data Model: `ProductModel`
|
|
98
102
|
* - Entity: `Product`
|
|
99
103
|
* - Property: `name`
|
|
@@ -101,33 +105,34 @@ import { DataNamespaceKind, DataEntityKind, DataModelKind, DataPropertyKind, Dat
|
|
|
101
105
|
* - Entity: `Category`
|
|
102
106
|
* - Property: `name`
|
|
103
107
|
* - Entity: `SpecialProduct` (parent: `Product`)
|
|
108
|
+
* ```
|
|
104
109
|
*
|
|
105
110
|
* If you attempt to delete the `Product` entity, the `DomainImpactAnalysis` will generate a report similar to this:
|
|
106
111
|
*
|
|
107
112
|
* ```json
|
|
108
113
|
* {
|
|
109
114
|
* "key": "Product",
|
|
110
|
-
* "kind": "
|
|
115
|
+
* "kind": "DomainEntityKind",
|
|
111
116
|
* "impact": [
|
|
112
117
|
* {
|
|
113
118
|
* "key": "Product",
|
|
114
|
-
* "kind": "
|
|
119
|
+
* "kind": "DomainEntityKind",
|
|
115
120
|
* "type": "delete",
|
|
116
121
|
* "impact": "The entity with key Product will be deleted.",
|
|
117
122
|
* "blocking": false
|
|
118
123
|
* },
|
|
119
124
|
* {
|
|
120
125
|
* "key": "SpecialProduct",
|
|
121
|
-
* "kind": "
|
|
126
|
+
* "kind": "DomainEntityKind",
|
|
122
127
|
* "type": "delete",
|
|
123
128
|
* "impact": "The SpecialProduct entity will become an orphan because it is a child of Product.",
|
|
124
|
-
* "resolution": "The "Product" entity will be removed as the parent of the "SpecialProduct" entity.",
|
|
129
|
+
* "resolution": "The \"Product\" entity will be removed as the parent of the \"SpecialProduct\" entity.",
|
|
125
130
|
* "blocking": true,
|
|
126
131
|
* "relationship": "child"
|
|
127
132
|
* },
|
|
128
133
|
* {
|
|
129
134
|
* "key": "category",
|
|
130
|
-
* "kind": "
|
|
135
|
+
* "kind": "DomainAssociationKind",
|
|
131
136
|
* "type": "delete",
|
|
132
137
|
* "impact": "The association with key category will be broken because it has a target to Product.",
|
|
133
138
|
* "resolution": "The association with key category will be removed from Product.",
|
|
@@ -135,7 +140,7 @@ import { DataNamespaceKind, DataEntityKind, DataModelKind, DataPropertyKind, Dat
|
|
|
135
140
|
* },
|
|
136
141
|
* {
|
|
137
142
|
* "key": "name",
|
|
138
|
-
* "kind": "
|
|
143
|
+
* "kind": "DomainPropertyKind",
|
|
139
144
|
* "type": "delete",
|
|
140
145
|
* "impact": "The property with key name will be deleted.",
|
|
141
146
|
* "blocking": false
|
|
@@ -155,26 +160,27 @@ import { DataNamespaceKind, DataEntityKind, DataModelKind, DataPropertyKind, Dat
|
|
|
155
160
|
*
|
|
156
161
|
* ## Types
|
|
157
162
|
*
|
|
158
|
-
* ### `
|
|
163
|
+
* ### `DomainImpactKinds`
|
|
159
164
|
*
|
|
160
|
-
* - **Description:** A type alias for the kinds of data domain
|
|
165
|
+
* - **Description:** A type alias for the kinds of data domain elements that can be analyzed.
|
|
161
166
|
* - **Values:**
|
|
162
|
-
* -
|
|
163
|
-
* -
|
|
164
|
-
* -
|
|
165
|
-
* -
|
|
166
|
-
* -
|
|
167
|
+
* - `DomainNamespaceKind`
|
|
168
|
+
* - `DomainEntityKind`
|
|
169
|
+
* - `DomainModelKind`
|
|
170
|
+
* - `DomainPropertyKind`
|
|
171
|
+
* - `DomainAssociationKind`
|
|
172
|
+
* - `DataDomainKind`
|
|
167
173
|
*
|
|
168
|
-
* ### `
|
|
174
|
+
* ### `DomainImpactReport`
|
|
169
175
|
*
|
|
170
176
|
* - **Description:** The structure of the impact analysis report.
|
|
171
177
|
* - **Properties:**
|
|
172
178
|
* - `key` (`string`): The key of the object being deleted.
|
|
173
|
-
* - `kind` (`
|
|
174
|
-
* - `impact` (`
|
|
179
|
+
* - `kind` (`DomainImpactKinds`): The kind of the object being deleted.
|
|
180
|
+
* - `impact` (`DomainImpactItem[]`): The list of impacts.
|
|
175
181
|
* - `canProceed` (`boolean`): Whether the deletion can proceed.
|
|
176
182
|
*
|
|
177
|
-
* ### `
|
|
183
|
+
* ### `DomainImpactItem`
|
|
178
184
|
*
|
|
179
185
|
* - **Description:** The structure of an individual impact item.
|
|
180
186
|
* - **Properties:**
|
|
@@ -188,12 +194,12 @@ import { DataNamespaceKind, DataEntityKind, DataModelKind, DataPropertyKind, Dat
|
|
|
188
194
|
*
|
|
189
195
|
* ## Error Handling
|
|
190
196
|
*
|
|
191
|
-
* The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `
|
|
197
|
+
* The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `DomainImpactReport` to communicate
|
|
192
198
|
* the results of the analysis, including any blocking impacts.
|
|
193
199
|
*
|
|
194
200
|
* ## Best Practices
|
|
195
201
|
*
|
|
196
|
-
* - **Always Analyze Before Deleting:** Before deleting any data domain
|
|
202
|
+
* - **Always Analyze Before Deleting:** Before deleting any data domain element, always use `DomainImpactAnalysis`
|
|
197
203
|
* to understand the consequences.
|
|
198
204
|
* - **Handle Blocking Impacts:** Pay close attention to `blocking` impacts and implement appropriate
|
|
199
205
|
* logic to handle them.
|
|
@@ -215,7 +221,7 @@ export class DomainImpactAnalysis {
|
|
|
215
221
|
this.root = root;
|
|
216
222
|
this.report = {
|
|
217
223
|
key: '',
|
|
218
|
-
kind:
|
|
224
|
+
kind: DataDomainKind,
|
|
219
225
|
impact: [],
|
|
220
226
|
canProceed: false,
|
|
221
227
|
};
|
|
@@ -234,26 +240,34 @@ export class DomainImpactAnalysis {
|
|
|
234
240
|
canProceed: true,
|
|
235
241
|
};
|
|
236
242
|
this.report.impact = this.createDeleteImpact(key, kind, key);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
243
|
+
return this.report;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Generates a report of how the data domain will be impacted by the removal of a foreign namespace.
|
|
247
|
+
* @param key The key of the foreign namespace.
|
|
248
|
+
* @returns The delete impact analysis report.
|
|
249
|
+
*/
|
|
250
|
+
removeForeignNamespaceAnalysis(key) {
|
|
251
|
+
this.report = {
|
|
252
|
+
key,
|
|
253
|
+
kind: DomainNamespaceKind,
|
|
254
|
+
impact: [],
|
|
255
|
+
canProceed: true,
|
|
256
|
+
};
|
|
257
|
+
this.report.impact = this.createRemoveForeignNamespaceImpact(key);
|
|
244
258
|
return this.report;
|
|
245
259
|
}
|
|
246
260
|
createDeleteImpact(key, kind, rootKey) {
|
|
247
261
|
switch (kind) {
|
|
248
|
-
case
|
|
262
|
+
case DomainNamespaceKind:
|
|
249
263
|
return this.deleteNamespaceAnalysis(key, rootKey);
|
|
250
|
-
case
|
|
264
|
+
case DomainModelKind:
|
|
251
265
|
return this.deleteDataModelAnalysis(key, rootKey);
|
|
252
|
-
case
|
|
266
|
+
case DomainEntityKind:
|
|
253
267
|
return this.deleteEntityAnalysis(key, rootKey);
|
|
254
|
-
case
|
|
268
|
+
case DomainPropertyKind:
|
|
255
269
|
return this.deletePropertyAnalysis(key);
|
|
256
|
-
case
|
|
270
|
+
case DomainAssociationKind:
|
|
257
271
|
return this.deleteAssociationAnalysis(key);
|
|
258
272
|
default:
|
|
259
273
|
return [];
|
|
@@ -269,24 +283,22 @@ export class DomainImpactAnalysis {
|
|
|
269
283
|
key: ns.key,
|
|
270
284
|
kind: ns.kind,
|
|
271
285
|
type: 'delete',
|
|
272
|
-
impact: `The ${ns.info.
|
|
286
|
+
impact: `The ${ns.info.getLabel()} ${this.kindToLabel(DomainNamespaceKind)} will be deleted.`,
|
|
273
287
|
blocking: false,
|
|
274
288
|
});
|
|
275
|
-
const
|
|
276
|
-
namespaces.forEach((child) => {
|
|
289
|
+
for (const child of ns.listNamespaces()) {
|
|
277
290
|
const items = this.deleteNamespaceAnalysis(child.key, rootKey);
|
|
278
291
|
result.push(...items);
|
|
279
|
-
}
|
|
280
|
-
const
|
|
281
|
-
models.forEach((child) => {
|
|
292
|
+
}
|
|
293
|
+
for (const child of ns.listModels()) {
|
|
282
294
|
const items = this.deleteDataModelAnalysis(child.key, rootKey);
|
|
283
295
|
result.push(...items);
|
|
284
|
-
}
|
|
296
|
+
}
|
|
285
297
|
return result;
|
|
286
298
|
}
|
|
287
299
|
deleteDataModelAnalysis(key, rootKey) {
|
|
288
300
|
const result = [];
|
|
289
|
-
const model = this.root.
|
|
301
|
+
const model = this.root.findModel(key);
|
|
290
302
|
if (!model) {
|
|
291
303
|
return result;
|
|
292
304
|
}
|
|
@@ -294,13 +306,13 @@ export class DomainImpactAnalysis {
|
|
|
294
306
|
key: model.key,
|
|
295
307
|
kind: model.kind,
|
|
296
308
|
type: 'delete',
|
|
297
|
-
impact: `The ${model.info.
|
|
309
|
+
impact: `The ${model.info.getLabel()} ${this.kindToLabel(DomainModelKind)} will be deleted.`,
|
|
298
310
|
blocking: false,
|
|
299
311
|
});
|
|
300
|
-
model.
|
|
312
|
+
for (const child of model.listEntities()) {
|
|
301
313
|
const items = this.deleteEntityAnalysis(child.key, rootKey);
|
|
302
314
|
result.push(...items);
|
|
303
|
-
}
|
|
315
|
+
}
|
|
304
316
|
return result;
|
|
305
317
|
}
|
|
306
318
|
deleteEntityAnalysis(key, rootKey) {
|
|
@@ -313,80 +325,74 @@ export class DomainImpactAnalysis {
|
|
|
313
325
|
key: entity.key,
|
|
314
326
|
kind: entity.kind,
|
|
315
327
|
type: 'delete',
|
|
316
|
-
impact: `The ${entity.info.
|
|
328
|
+
impact: `The ${entity.info.getLabel()} ${this.kindToLabel(DomainEntityKind)} will be deleted.`,
|
|
317
329
|
blocking: false,
|
|
318
330
|
});
|
|
319
331
|
// We need to know whether the entity is a parent of another entity
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
332
|
+
for (const info of this.root.graph.inEdges(key)) {
|
|
333
|
+
const edge = this.root.graph.edge(info);
|
|
334
|
+
if (!edge || edge.type !== 'parent') {
|
|
335
|
+
continue;
|
|
324
336
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
337
|
+
const childEntity = this.root.findEntity(info.v);
|
|
338
|
+
if (!childEntity) {
|
|
339
|
+
continue;
|
|
328
340
|
}
|
|
329
|
-
if (
|
|
330
|
-
// No need to include this
|
|
331
|
-
|
|
341
|
+
if (childEntity.isChildOf(rootKey)) {
|
|
342
|
+
// No need to include this child as it itself is being deleted
|
|
343
|
+
continue;
|
|
332
344
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
type: 'delete',
|
|
344
|
-
impact: `The "${cLabel}" ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
|
|
345
|
-
resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
|
|
346
|
-
blocking: true,
|
|
347
|
-
relationship: 'child',
|
|
348
|
-
});
|
|
345
|
+
const pLabel = entity.info.getLabel();
|
|
346
|
+
const cLabel = childEntity.info.getLabel();
|
|
347
|
+
result.push({
|
|
348
|
+
key: childEntity.key,
|
|
349
|
+
kind: childEntity.kind,
|
|
350
|
+
type: 'delete',
|
|
351
|
+
impact: `The "${cLabel}" ${this.kindToLabel(DomainEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
|
|
352
|
+
resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
|
|
353
|
+
blocking: true,
|
|
354
|
+
relationship: 'child',
|
|
349
355
|
});
|
|
350
356
|
this.report.canProceed = false;
|
|
351
357
|
}
|
|
352
358
|
// We need to know whether there's another entity that has an association to this entity.
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
359
|
+
for (const edgeInfo of this.root.graph.inEdges(entity.key)) {
|
|
360
|
+
const edge = this.root.graph.edge(edgeInfo);
|
|
361
|
+
if (!edge || edge.type !== 'association') {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
const association = this.root.findAssociation(edgeInfo.v);
|
|
365
|
+
if (!association) {
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
const targetEntity = association.getParentInstance();
|
|
369
|
+
if (!targetEntity) {
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (targetEntity.isChildOf(rootKey)) {
|
|
373
|
+
// No need to include this association as the target entity itself is being deleted
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
const aLabel = association.info.getLabel();
|
|
377
|
+
const eLabel = entity.info.getLabel();
|
|
378
|
+
result.push({
|
|
379
|
+
key: association.key,
|
|
380
|
+
kind: association.kind,
|
|
381
|
+
type: 'delete',
|
|
382
|
+
impact: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be broken because it has a target to ${eLabel}.`,
|
|
383
|
+
resolution: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be removed from ${eLabel}.`,
|
|
384
|
+
blocking: true,
|
|
379
385
|
});
|
|
380
386
|
this.report.canProceed = false;
|
|
381
387
|
}
|
|
382
|
-
entity.
|
|
388
|
+
for (const child of entity.listProperties()) {
|
|
383
389
|
const items = this.deletePropertyAnalysis(child.key);
|
|
384
390
|
result.push(...items);
|
|
385
|
-
}
|
|
386
|
-
entity.
|
|
391
|
+
}
|
|
392
|
+
for (const child of entity.listAssociations()) {
|
|
387
393
|
const items = this.deleteAssociationAnalysis(child.key);
|
|
388
394
|
result.push(...items);
|
|
389
|
-
}
|
|
395
|
+
}
|
|
390
396
|
return result;
|
|
391
397
|
}
|
|
392
398
|
deletePropertyAnalysis(key) {
|
|
@@ -399,7 +405,7 @@ export class DomainImpactAnalysis {
|
|
|
399
405
|
key: property.key,
|
|
400
406
|
kind: property.kind,
|
|
401
407
|
type: 'delete',
|
|
402
|
-
impact: `The ${property.info.
|
|
408
|
+
impact: `The ${property.info.getLabel()} ${this.kindToLabel(DomainPropertyKind)} will be deleted.`,
|
|
403
409
|
blocking: false,
|
|
404
410
|
});
|
|
405
411
|
return result;
|
|
@@ -414,26 +420,89 @@ export class DomainImpactAnalysis {
|
|
|
414
420
|
key: association.key,
|
|
415
421
|
kind: association.kind,
|
|
416
422
|
type: 'delete',
|
|
417
|
-
impact: `The ${association.info.
|
|
423
|
+
impact: `The ${association.info.getLabel()} ${this.kindToLabel(DomainAssociationKind)} will be deleted.`,
|
|
418
424
|
blocking: false,
|
|
419
425
|
});
|
|
420
426
|
return result;
|
|
421
427
|
}
|
|
422
428
|
kindToLabel(kind) {
|
|
423
429
|
switch (kind) {
|
|
424
|
-
case
|
|
430
|
+
case DomainNamespaceKind:
|
|
425
431
|
return 'namespace';
|
|
426
|
-
case
|
|
432
|
+
case DomainEntityKind:
|
|
427
433
|
return 'entity';
|
|
428
|
-
case
|
|
434
|
+
case DomainModelKind:
|
|
429
435
|
return 'data model';
|
|
430
|
-
case
|
|
436
|
+
case DomainPropertyKind:
|
|
431
437
|
return 'property';
|
|
432
|
-
case
|
|
438
|
+
case DomainAssociationKind:
|
|
433
439
|
return 'association';
|
|
434
440
|
default:
|
|
435
441
|
return 'unknown';
|
|
436
442
|
}
|
|
437
443
|
}
|
|
444
|
+
createRemoveForeignNamespaceImpact(key) {
|
|
445
|
+
const result = [];
|
|
446
|
+
const foreignNamespace = this.root.dependencies.get(key);
|
|
447
|
+
if (!foreignNamespace) {
|
|
448
|
+
return result;
|
|
449
|
+
}
|
|
450
|
+
// Check for parent relationships to foreign entities
|
|
451
|
+
for (const entity of this.root.listEntities()) {
|
|
452
|
+
for (const info of this.root.graph.outEdges(entity.key)) {
|
|
453
|
+
const edge = this.root.graph.edge(info);
|
|
454
|
+
if (!edge) {
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (edge.type === 'parent' && edge.domain === key) {
|
|
458
|
+
// the parent is in the foreign namespace
|
|
459
|
+
const parentEntity = this.root.findEntity(info.w);
|
|
460
|
+
if (!parentEntity) {
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
const eLabel = entity.info.getLabel();
|
|
464
|
+
const pLabel = parentEntity.info.getLabel();
|
|
465
|
+
result.push({
|
|
466
|
+
key: entity.key,
|
|
467
|
+
kind: entity.kind,
|
|
468
|
+
type: 'delete',
|
|
469
|
+
impact: `The "${eLabel}" ${this.kindToLabel(DomainEntityKind)} will become an orphan because its parent "${pLabel}" is in the foreign namespace "${foreignNamespace.key}".`,
|
|
470
|
+
resolution: `The "${pLabel}" entity will be removed as the parent of the "${eLabel}" entity.`,
|
|
471
|
+
blocking: true,
|
|
472
|
+
relationship: 'child',
|
|
473
|
+
});
|
|
474
|
+
this.report.canProceed = false;
|
|
475
|
+
}
|
|
476
|
+
else if (edge.type === 'association') {
|
|
477
|
+
const association = this.root.findAssociation(info.w);
|
|
478
|
+
if (!association) {
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
const targets = association.targets.filter((t) => t.domain === key);
|
|
482
|
+
if (targets.length) {
|
|
483
|
+
for (const info of targets) {
|
|
484
|
+
const targetEntity = this.root.findForeignEntity(info.key, info.domain);
|
|
485
|
+
if (!targetEntity) {
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
const aLabel = association.info.getLabel();
|
|
489
|
+
const eLabel = entity.info.getLabel();
|
|
490
|
+
const tLabel = targetEntity.info.getLabel();
|
|
491
|
+
result.push({
|
|
492
|
+
key: association.key,
|
|
493
|
+
kind: association.kind,
|
|
494
|
+
type: 'delete',
|
|
495
|
+
impact: `The "${aLabel}" ${this.kindToLabel(DomainAssociationKind)} from "${eLabel}" will be broken because it targets "${tLabel}" in the foreign namespace "${foreignNamespace.key}".`,
|
|
496
|
+
resolution: `The "${aLabel}" ${this.kindToLabel(DomainAssociationKind)} will be removed from "${eLabel}".`,
|
|
497
|
+
blocking: true,
|
|
498
|
+
});
|
|
499
|
+
this.report.canProceed = false;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return result;
|
|
506
|
+
}
|
|
438
507
|
}
|
|
439
508
|
//# sourceMappingURL=DomainImpactAnalysis.js.map
|