@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,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
DomainNamespaceKind,
|
|
3
|
+
DomainEntityKind,
|
|
4
|
+
DomainModelKind,
|
|
5
|
+
DomainPropertyKind,
|
|
6
|
+
DomainAssociationKind,
|
|
7
|
+
DataDomainKind,
|
|
7
8
|
} from '../models/kinds.js'
|
|
8
|
-
import type {
|
|
9
|
+
import type { DataDomain } from './DataDomain.js'
|
|
9
10
|
|
|
10
11
|
export type DomainImpactKinds =
|
|
11
|
-
| typeof
|
|
12
|
-
| typeof
|
|
13
|
-
| typeof
|
|
14
|
-
| typeof
|
|
15
|
-
| typeof
|
|
12
|
+
| typeof DomainNamespaceKind
|
|
13
|
+
| typeof DomainEntityKind
|
|
14
|
+
| typeof DomainModelKind
|
|
15
|
+
| typeof DomainPropertyKind
|
|
16
|
+
| typeof DomainAssociationKind
|
|
17
|
+
| typeof DataDomainKind
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* The impact analysis report
|
|
@@ -76,20 +78,20 @@ export interface DomainImpactItem {
|
|
|
76
78
|
/**
|
|
77
79
|
* # DomainImpactAnalysis
|
|
78
80
|
*
|
|
79
|
-
* The `DomainImpactAnalysis` class is a
|
|
80
|
-
* within a `
|
|
81
|
-
*
|
|
82
|
-
* or association, ensuring data integrity and preventing unintended side effects.
|
|
81
|
+
* The `DomainImpactAnalysis` class is a tool for analyzing the consequences of deleting data domain elements
|
|
82
|
+
* within a `DataDomain`. It helps developers understand the ripple effects of removing a namespace, data model,
|
|
83
|
+
* entity, property, or association, ensuring data integrity and preventing unintended side effects.
|
|
83
84
|
*
|
|
84
85
|
* ## Core Concepts
|
|
85
86
|
*
|
|
86
87
|
* - **Impact Report:** The central output of the `DomainImpactAnalysis` class is an `DomainImpactReport`.
|
|
87
88
|
* This report details the potential consequences of a deletion operation, including:
|
|
88
89
|
* - The object being deleted (`key`, `kind`).
|
|
89
|
-
* - A list of `
|
|
90
|
+
* - A list of `DomainImpactItem` objects, each describing a specific consequence.
|
|
90
91
|
* - Whether the deletion can proceed safely (`canProceed`).
|
|
91
92
|
*
|
|
92
|
-
* - **
|
|
93
|
+
* - **DomainImpactItem:** Each `DomainImpactItem` describes a specific consequence of the deletion.
|
|
94
|
+
* Key properties include:
|
|
93
95
|
* - `key`: The key of the impacted object.
|
|
94
96
|
* - `kind`: The kind of the impacted object.
|
|
95
97
|
* - `type`: The type of impact (currently only `delete`).
|
|
@@ -107,28 +109,29 @@ export interface DomainImpactItem {
|
|
|
107
109
|
*
|
|
108
110
|
* ## Usage
|
|
109
111
|
*
|
|
110
|
-
* 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `
|
|
112
|
+
* 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataDomain` as an argument.
|
|
111
113
|
*
|
|
112
114
|
* ```typescript
|
|
113
|
-
* import {
|
|
115
|
+
* import { DataDomain } from './DataDomain';
|
|
114
116
|
* import { DomainImpactAnalysis } from './DomainImpactAnalysis';
|
|
115
117
|
*
|
|
116
|
-
* const
|
|
117
|
-
* // ... add some data to the
|
|
118
|
-
* const analyzer = new DomainImpactAnalysis(
|
|
118
|
+
* const dataDomain = new DataDomain();
|
|
119
|
+
* // ... add some data to the domain
|
|
120
|
+
* const analyzer = new DomainImpactAnalysis(dataDomain);
|
|
119
121
|
* ```
|
|
120
122
|
*
|
|
121
|
-
* 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `
|
|
123
|
+
* 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `DomainImpactReport` for
|
|
124
|
+
* a specific deletion.
|
|
122
125
|
* Provide the `key` and `kind` of the object to be deleted.
|
|
123
126
|
*
|
|
124
127
|
* ```typescript
|
|
125
|
-
* import {
|
|
128
|
+
* import { DomainEntityKind } from '../models/kinds.js';
|
|
126
129
|
* // ...
|
|
127
130
|
* const entityKey = 'some-entity-key';
|
|
128
|
-
* const report = analyzer.deleteAnalysis(entityKey,
|
|
131
|
+
* const report = analyzer.deleteAnalysis(entityKey, DomainEntityKind);
|
|
129
132
|
* ```
|
|
130
133
|
*
|
|
131
|
-
* 3. **Interpreting the Report:** Examine the `
|
|
134
|
+
* 3. **Interpreting the Report:** Examine the `DomainImpactReport` to understand the consequences of the deletion.
|
|
132
135
|
* - Check `report.canProceed` to see if the deletion is safe.
|
|
133
136
|
* - Iterate through `report.impact` to understand each consequence.
|
|
134
137
|
* - Pay special attention to `impact.blocking` to identify impacts that require manual resolution.
|
|
@@ -153,21 +156,24 @@ export interface DomainImpactItem {
|
|
|
153
156
|
*
|
|
154
157
|
* ## Supported Deletion Scenarios
|
|
155
158
|
*
|
|
156
|
-
* The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain
|
|
159
|
+
* The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain element types:
|
|
157
160
|
*
|
|
158
|
-
* -
|
|
159
|
-
*
|
|
160
|
-
* -
|
|
161
|
-
* -
|
|
162
|
-
*
|
|
163
|
-
* -
|
|
164
|
-
* -
|
|
161
|
+
* - **Namespaces (`DomainNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,
|
|
162
|
+
* data models, entities, properties, and associations.
|
|
163
|
+
* - **Data Models (`DomainModelKind`):** Deleting a data model impacts all its entities, properties, and associations.
|
|
164
|
+
* - **Entities (`DomainEntityKind`):** Deleting an entity impacts its properties, associations, and any other
|
|
165
|
+
* entities that have it as a parent or target in an association.
|
|
166
|
+
* - **Properties (`DomainPropertyKind`):** Deleting a property impacts the entity it belongs to.
|
|
167
|
+
* - **Associations (`DomainAssociationKind`):** Deleting an association impacts the entity it belongs to.
|
|
168
|
+
* - **Data Domain (`DataDomainKind`):** Deleting a data domain is not supported.
|
|
165
169
|
*
|
|
166
170
|
* ## Example: Deleting an Entity
|
|
167
171
|
*
|
|
168
172
|
* Consider the following scenario:
|
|
169
173
|
*
|
|
170
|
-
*
|
|
174
|
+
* ```
|
|
175
|
+
* DataDomain
|
|
176
|
+
* - Namespace: `MyNamespace`
|
|
171
177
|
* - Data Model: `ProductModel`
|
|
172
178
|
* - Entity: `Product`
|
|
173
179
|
* - Property: `name`
|
|
@@ -175,33 +181,34 @@ export interface DomainImpactItem {
|
|
|
175
181
|
* - Entity: `Category`
|
|
176
182
|
* - Property: `name`
|
|
177
183
|
* - Entity: `SpecialProduct` (parent: `Product`)
|
|
184
|
+
* ```
|
|
178
185
|
*
|
|
179
186
|
* If you attempt to delete the `Product` entity, the `DomainImpactAnalysis` will generate a report similar to this:
|
|
180
187
|
*
|
|
181
188
|
* ```json
|
|
182
189
|
* {
|
|
183
190
|
* "key": "Product",
|
|
184
|
-
* "kind": "
|
|
191
|
+
* "kind": "DomainEntityKind",
|
|
185
192
|
* "impact": [
|
|
186
193
|
* {
|
|
187
194
|
* "key": "Product",
|
|
188
|
-
* "kind": "
|
|
195
|
+
* "kind": "DomainEntityKind",
|
|
189
196
|
* "type": "delete",
|
|
190
197
|
* "impact": "The entity with key Product will be deleted.",
|
|
191
198
|
* "blocking": false
|
|
192
199
|
* },
|
|
193
200
|
* {
|
|
194
201
|
* "key": "SpecialProduct",
|
|
195
|
-
* "kind": "
|
|
202
|
+
* "kind": "DomainEntityKind",
|
|
196
203
|
* "type": "delete",
|
|
197
204
|
* "impact": "The SpecialProduct entity will become an orphan because it is a child of Product.",
|
|
198
|
-
* "resolution": "The "Product" entity will be removed as the parent of the "SpecialProduct" entity.",
|
|
205
|
+
* "resolution": "The \"Product\" entity will be removed as the parent of the \"SpecialProduct\" entity.",
|
|
199
206
|
* "blocking": true,
|
|
200
207
|
* "relationship": "child"
|
|
201
208
|
* },
|
|
202
209
|
* {
|
|
203
210
|
* "key": "category",
|
|
204
|
-
* "kind": "
|
|
211
|
+
* "kind": "DomainAssociationKind",
|
|
205
212
|
* "type": "delete",
|
|
206
213
|
* "impact": "The association with key category will be broken because it has a target to Product.",
|
|
207
214
|
* "resolution": "The association with key category will be removed from Product.",
|
|
@@ -209,7 +216,7 @@ export interface DomainImpactItem {
|
|
|
209
216
|
* },
|
|
210
217
|
* {
|
|
211
218
|
* "key": "name",
|
|
212
|
-
* "kind": "
|
|
219
|
+
* "kind": "DomainPropertyKind",
|
|
213
220
|
* "type": "delete",
|
|
214
221
|
* "impact": "The property with key name will be deleted.",
|
|
215
222
|
* "blocking": false
|
|
@@ -229,26 +236,27 @@ export interface DomainImpactItem {
|
|
|
229
236
|
*
|
|
230
237
|
* ## Types
|
|
231
238
|
*
|
|
232
|
-
* ### `
|
|
239
|
+
* ### `DomainImpactKinds`
|
|
233
240
|
*
|
|
234
|
-
* - **Description:** A type alias for the kinds of data domain
|
|
241
|
+
* - **Description:** A type alias for the kinds of data domain elements that can be analyzed.
|
|
235
242
|
* - **Values:**
|
|
236
|
-
* -
|
|
237
|
-
* -
|
|
238
|
-
* -
|
|
239
|
-
* -
|
|
240
|
-
* -
|
|
243
|
+
* - `DomainNamespaceKind`
|
|
244
|
+
* - `DomainEntityKind`
|
|
245
|
+
* - `DomainModelKind`
|
|
246
|
+
* - `DomainPropertyKind`
|
|
247
|
+
* - `DomainAssociationKind`
|
|
248
|
+
* - `DataDomainKind`
|
|
241
249
|
*
|
|
242
|
-
* ### `
|
|
250
|
+
* ### `DomainImpactReport`
|
|
243
251
|
*
|
|
244
252
|
* - **Description:** The structure of the impact analysis report.
|
|
245
253
|
* - **Properties:**
|
|
246
254
|
* - `key` (`string`): The key of the object being deleted.
|
|
247
|
-
* - `kind` (`
|
|
248
|
-
* - `impact` (`
|
|
255
|
+
* - `kind` (`DomainImpactKinds`): The kind of the object being deleted.
|
|
256
|
+
* - `impact` (`DomainImpactItem[]`): The list of impacts.
|
|
249
257
|
* - `canProceed` (`boolean`): Whether the deletion can proceed.
|
|
250
258
|
*
|
|
251
|
-
* ### `
|
|
259
|
+
* ### `DomainImpactItem`
|
|
252
260
|
*
|
|
253
261
|
* - **Description:** The structure of an individual impact item.
|
|
254
262
|
* - **Properties:**
|
|
@@ -262,12 +270,12 @@ export interface DomainImpactItem {
|
|
|
262
270
|
*
|
|
263
271
|
* ## Error Handling
|
|
264
272
|
*
|
|
265
|
-
* The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `
|
|
273
|
+
* The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `DomainImpactReport` to communicate
|
|
266
274
|
* the results of the analysis, including any blocking impacts.
|
|
267
275
|
*
|
|
268
276
|
* ## Best Practices
|
|
269
277
|
*
|
|
270
|
-
* - **Always Analyze Before Deleting:** Before deleting any data domain
|
|
278
|
+
* - **Always Analyze Before Deleting:** Before deleting any data domain element, always use `DomainImpactAnalysis`
|
|
271
279
|
* to understand the consequences.
|
|
272
280
|
* - **Handle Blocking Impacts:** Pay close attention to `blocking` impacts and implement appropriate
|
|
273
281
|
* logic to handle them.
|
|
@@ -284,13 +292,13 @@ export interface DomainImpactItem {
|
|
|
284
292
|
*/
|
|
285
293
|
export class DomainImpactAnalysis {
|
|
286
294
|
private report: DomainImpactReport
|
|
287
|
-
private root:
|
|
295
|
+
private root: DataDomain
|
|
288
296
|
|
|
289
|
-
constructor(root:
|
|
297
|
+
constructor(root: DataDomain) {
|
|
290
298
|
this.root = root
|
|
291
299
|
this.report = {
|
|
292
300
|
key: '',
|
|
293
|
-
kind:
|
|
301
|
+
kind: DataDomainKind,
|
|
294
302
|
impact: [],
|
|
295
303
|
canProceed: false,
|
|
296
304
|
}
|
|
@@ -310,27 +318,36 @@ export class DomainImpactAnalysis {
|
|
|
310
318
|
canProceed: true,
|
|
311
319
|
}
|
|
312
320
|
this.report.impact = this.createDeleteImpact(key, kind, key)
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
321
|
+
return this.report
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Generates a report of how the data domain will be impacted by the removal of a foreign namespace.
|
|
326
|
+
* @param key The key of the foreign namespace.
|
|
327
|
+
* @returns The delete impact analysis report.
|
|
328
|
+
*/
|
|
329
|
+
removeForeignNamespaceAnalysis(key: string): DomainImpactReport {
|
|
330
|
+
this.report = {
|
|
331
|
+
key,
|
|
332
|
+
kind: DomainNamespaceKind,
|
|
333
|
+
impact: [],
|
|
334
|
+
canProceed: true,
|
|
335
|
+
}
|
|
336
|
+
this.report.impact = this.createRemoveForeignNamespaceImpact(key)
|
|
320
337
|
return this.report
|
|
321
338
|
}
|
|
322
339
|
|
|
323
340
|
protected createDeleteImpact(key: string, kind: DomainImpactKinds, rootKey: string): DomainImpactItem[] {
|
|
324
341
|
switch (kind) {
|
|
325
|
-
case
|
|
342
|
+
case DomainNamespaceKind:
|
|
326
343
|
return this.deleteNamespaceAnalysis(key, rootKey)
|
|
327
|
-
case
|
|
344
|
+
case DomainModelKind:
|
|
328
345
|
return this.deleteDataModelAnalysis(key, rootKey)
|
|
329
|
-
case
|
|
346
|
+
case DomainEntityKind:
|
|
330
347
|
return this.deleteEntityAnalysis(key, rootKey)
|
|
331
|
-
case
|
|
348
|
+
case DomainPropertyKind:
|
|
332
349
|
return this.deletePropertyAnalysis(key)
|
|
333
|
-
case
|
|
350
|
+
case DomainAssociationKind:
|
|
334
351
|
return this.deleteAssociationAnalysis(key)
|
|
335
352
|
default:
|
|
336
353
|
return []
|
|
@@ -347,25 +364,23 @@ export class DomainImpactAnalysis {
|
|
|
347
364
|
key: ns.key,
|
|
348
365
|
kind: ns.kind,
|
|
349
366
|
type: 'delete',
|
|
350
|
-
impact: `The ${ns.info.
|
|
367
|
+
impact: `The ${ns.info.getLabel()} ${this.kindToLabel(DomainNamespaceKind)} will be deleted.`,
|
|
351
368
|
blocking: false,
|
|
352
369
|
})
|
|
353
|
-
const
|
|
354
|
-
namespaces.forEach((child) => {
|
|
370
|
+
for (const child of ns.listNamespaces()) {
|
|
355
371
|
const items = this.deleteNamespaceAnalysis(child.key, rootKey)
|
|
356
372
|
result.push(...items)
|
|
357
|
-
}
|
|
358
|
-
const
|
|
359
|
-
models.forEach((child) => {
|
|
373
|
+
}
|
|
374
|
+
for (const child of ns.listModels()) {
|
|
360
375
|
const items = this.deleteDataModelAnalysis(child.key, rootKey)
|
|
361
376
|
result.push(...items)
|
|
362
|
-
}
|
|
377
|
+
}
|
|
363
378
|
return result
|
|
364
379
|
}
|
|
365
380
|
|
|
366
381
|
protected deleteDataModelAnalysis(key: string, rootKey: string): DomainImpactItem[] {
|
|
367
382
|
const result: DomainImpactItem[] = []
|
|
368
|
-
const model = this.root.
|
|
383
|
+
const model = this.root.findModel(key)
|
|
369
384
|
if (!model) {
|
|
370
385
|
return result
|
|
371
386
|
}
|
|
@@ -373,13 +388,13 @@ export class DomainImpactAnalysis {
|
|
|
373
388
|
key: model.key,
|
|
374
389
|
kind: model.kind,
|
|
375
390
|
type: 'delete',
|
|
376
|
-
impact: `The ${model.info.
|
|
391
|
+
impact: `The ${model.info.getLabel()} ${this.kindToLabel(DomainModelKind)} will be deleted.`,
|
|
377
392
|
blocking: false,
|
|
378
393
|
})
|
|
379
|
-
model.
|
|
394
|
+
for (const child of model.listEntities()) {
|
|
380
395
|
const items = this.deleteEntityAnalysis(child.key, rootKey)
|
|
381
396
|
result.push(...items)
|
|
382
|
-
}
|
|
397
|
+
}
|
|
383
398
|
return result
|
|
384
399
|
}
|
|
385
400
|
|
|
@@ -393,80 +408,76 @@ export class DomainImpactAnalysis {
|
|
|
393
408
|
key: entity.key,
|
|
394
409
|
kind: entity.kind,
|
|
395
410
|
type: 'delete',
|
|
396
|
-
impact: `The ${entity.info.
|
|
411
|
+
impact: `The ${entity.info.getLabel()} ${this.kindToLabel(DomainEntityKind)} will be deleted.`,
|
|
397
412
|
blocking: false,
|
|
398
413
|
})
|
|
414
|
+
|
|
399
415
|
// We need to know whether the entity is a parent of another entity
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
416
|
+
for (const info of this.root.graph.inEdges(key)) {
|
|
417
|
+
const edge = this.root.graph.edge(info)
|
|
418
|
+
if (!edge || edge.type !== 'parent') {
|
|
419
|
+
continue
|
|
404
420
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
421
|
+
const childEntity = this.root.findEntity(info.v)
|
|
422
|
+
if (!childEntity) {
|
|
423
|
+
continue
|
|
408
424
|
}
|
|
409
|
-
if (
|
|
410
|
-
// No need to include this
|
|
411
|
-
|
|
425
|
+
if (childEntity.isChildOf(rootKey)) {
|
|
426
|
+
// No need to include this child as it itself is being deleted
|
|
427
|
+
continue
|
|
412
428
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
type: 'delete',
|
|
424
|
-
impact: `The "${cLabel}" ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
|
|
425
|
-
resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
|
|
426
|
-
blocking: true,
|
|
427
|
-
relationship: 'child',
|
|
428
|
-
})
|
|
429
|
+
const pLabel = entity.info.getLabel()
|
|
430
|
+
const cLabel = childEntity.info.getLabel()
|
|
431
|
+
result.push({
|
|
432
|
+
key: childEntity.key,
|
|
433
|
+
kind: childEntity.kind,
|
|
434
|
+
type: 'delete',
|
|
435
|
+
impact: `The "${cLabel}" ${this.kindToLabel(DomainEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
|
|
436
|
+
resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
|
|
437
|
+
blocking: true,
|
|
438
|
+
relationship: 'child',
|
|
429
439
|
})
|
|
430
440
|
this.report.canProceed = false
|
|
431
441
|
}
|
|
432
442
|
// We need to know whether there's another entity that has an association to this entity.
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
})
|
|
443
|
+
for (const edgeInfo of this.root.graph.inEdges(entity.key)) {
|
|
444
|
+
const edge = this.root.graph.edge(edgeInfo)
|
|
445
|
+
if (!edge || edge.type !== 'association') {
|
|
446
|
+
continue
|
|
447
|
+
}
|
|
448
|
+
const association = this.root.findAssociation(edgeInfo.v)
|
|
449
|
+
if (!association) {
|
|
450
|
+
continue
|
|
451
|
+
}
|
|
452
|
+
const targetEntity = association.getParentInstance()
|
|
453
|
+
if (!targetEntity) {
|
|
454
|
+
continue
|
|
455
|
+
}
|
|
456
|
+
if (targetEntity.isChildOf(rootKey)) {
|
|
457
|
+
// No need to include this association as the target entity itself is being deleted
|
|
458
|
+
continue
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const aLabel = association.info.getLabel()
|
|
462
|
+
const eLabel = entity.info.getLabel()
|
|
463
|
+
result.push({
|
|
464
|
+
key: association.key,
|
|
465
|
+
kind: association.kind,
|
|
466
|
+
type: 'delete',
|
|
467
|
+
impact: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be broken because it has a target to ${eLabel}.`,
|
|
468
|
+
resolution: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be removed from ${eLabel}.`,
|
|
469
|
+
blocking: true,
|
|
459
470
|
})
|
|
460
471
|
this.report.canProceed = false
|
|
461
472
|
}
|
|
462
|
-
entity.
|
|
473
|
+
for (const child of entity.listProperties()) {
|
|
463
474
|
const items = this.deletePropertyAnalysis(child.key)
|
|
464
475
|
result.push(...items)
|
|
465
|
-
}
|
|
466
|
-
entity.
|
|
476
|
+
}
|
|
477
|
+
for (const child of entity.listAssociations()) {
|
|
467
478
|
const items = this.deleteAssociationAnalysis(child.key)
|
|
468
479
|
result.push(...items)
|
|
469
|
-
}
|
|
480
|
+
}
|
|
470
481
|
return result
|
|
471
482
|
}
|
|
472
483
|
|
|
@@ -480,7 +491,7 @@ export class DomainImpactAnalysis {
|
|
|
480
491
|
key: property.key,
|
|
481
492
|
kind: property.kind,
|
|
482
493
|
type: 'delete',
|
|
483
|
-
impact: `The ${property.info.
|
|
494
|
+
impact: `The ${property.info.getLabel()} ${this.kindToLabel(DomainPropertyKind)} will be deleted.`,
|
|
484
495
|
blocking: false,
|
|
485
496
|
})
|
|
486
497
|
return result
|
|
@@ -496,7 +507,7 @@ export class DomainImpactAnalysis {
|
|
|
496
507
|
key: association.key,
|
|
497
508
|
kind: association.kind,
|
|
498
509
|
type: 'delete',
|
|
499
|
-
impact: `The ${association.info.
|
|
510
|
+
impact: `The ${association.info.getLabel()} ${this.kindToLabel(DomainAssociationKind)} will be deleted.`,
|
|
500
511
|
blocking: false,
|
|
501
512
|
})
|
|
502
513
|
return result
|
|
@@ -504,18 +515,81 @@ export class DomainImpactAnalysis {
|
|
|
504
515
|
|
|
505
516
|
protected kindToLabel(kind: DomainImpactKinds): string {
|
|
506
517
|
switch (kind) {
|
|
507
|
-
case
|
|
518
|
+
case DomainNamespaceKind:
|
|
508
519
|
return 'namespace'
|
|
509
|
-
case
|
|
520
|
+
case DomainEntityKind:
|
|
510
521
|
return 'entity'
|
|
511
|
-
case
|
|
522
|
+
case DomainModelKind:
|
|
512
523
|
return 'data model'
|
|
513
|
-
case
|
|
524
|
+
case DomainPropertyKind:
|
|
514
525
|
return 'property'
|
|
515
|
-
case
|
|
526
|
+
case DomainAssociationKind:
|
|
516
527
|
return 'association'
|
|
517
528
|
default:
|
|
518
529
|
return 'unknown'
|
|
519
530
|
}
|
|
520
531
|
}
|
|
532
|
+
|
|
533
|
+
protected createRemoveForeignNamespaceImpact(key: string): DomainImpactItem[] {
|
|
534
|
+
const result: DomainImpactItem[] = []
|
|
535
|
+
const foreignNamespace = this.root.dependencies.get(key)
|
|
536
|
+
if (!foreignNamespace) {
|
|
537
|
+
return result
|
|
538
|
+
}
|
|
539
|
+
// Check for parent relationships to foreign entities
|
|
540
|
+
for (const entity of this.root.listEntities()) {
|
|
541
|
+
for (const info of this.root.graph.outEdges(entity.key)) {
|
|
542
|
+
const edge = this.root.graph.edge(info)
|
|
543
|
+
if (!edge) {
|
|
544
|
+
continue
|
|
545
|
+
}
|
|
546
|
+
if (edge.type === 'parent' && edge.domain === key) {
|
|
547
|
+
// the parent is in the foreign namespace
|
|
548
|
+
const parentEntity = this.root.findEntity(info.w)
|
|
549
|
+
if (!parentEntity) {
|
|
550
|
+
continue
|
|
551
|
+
}
|
|
552
|
+
const eLabel = entity.info.getLabel()
|
|
553
|
+
const pLabel = parentEntity.info.getLabel()
|
|
554
|
+
result.push({
|
|
555
|
+
key: entity.key,
|
|
556
|
+
kind: entity.kind,
|
|
557
|
+
type: 'delete',
|
|
558
|
+
impact: `The "${eLabel}" ${this.kindToLabel(DomainEntityKind)} will become an orphan because its parent "${pLabel}" is in the foreign namespace "${foreignNamespace.key}".`,
|
|
559
|
+
resolution: `The "${pLabel}" entity will be removed as the parent of the "${eLabel}" entity.`,
|
|
560
|
+
blocking: true,
|
|
561
|
+
relationship: 'child',
|
|
562
|
+
})
|
|
563
|
+
this.report.canProceed = false
|
|
564
|
+
} else if (edge.type === 'association') {
|
|
565
|
+
const association = this.root.findAssociation(info.w)
|
|
566
|
+
if (!association) {
|
|
567
|
+
continue
|
|
568
|
+
}
|
|
569
|
+
const targets = association.targets.filter((t) => t.domain === key)
|
|
570
|
+
if (targets.length) {
|
|
571
|
+
for (const info of targets) {
|
|
572
|
+
const targetEntity = this.root.findForeignEntity(info.key, info.domain as string)
|
|
573
|
+
if (!targetEntity) {
|
|
574
|
+
continue
|
|
575
|
+
}
|
|
576
|
+
const aLabel = association.info.getLabel()
|
|
577
|
+
const eLabel = entity.info.getLabel()
|
|
578
|
+
const tLabel = targetEntity.info.getLabel()
|
|
579
|
+
result.push({
|
|
580
|
+
key: association.key,
|
|
581
|
+
kind: association.kind,
|
|
582
|
+
type: 'delete',
|
|
583
|
+
impact: `The "${aLabel}" ${this.kindToLabel(DomainAssociationKind)} from "${eLabel}" will be broken because it targets "${tLabel}" in the foreign namespace "${foreignNamespace.key}".`,
|
|
584
|
+
resolution: `The "${aLabel}" ${this.kindToLabel(DomainAssociationKind)} will be removed from "${eLabel}".`,
|
|
585
|
+
blocking: true,
|
|
586
|
+
})
|
|
587
|
+
this.report.canProceed = false
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return result
|
|
594
|
+
}
|
|
521
595
|
}
|