@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.
Files changed (252) hide show
  1. package/Testing.md +1 -1
  2. package/bin/plugins/events/EventPlugin.ts +61 -0
  3. package/bin/plugins/events/assert.ts +193 -0
  4. package/bin/plugins/events/types.ts +6 -0
  5. package/bin/test.ts +8 -1
  6. package/build/src/amf/AmfShapeGenerator.d.ts +6 -3
  7. package/build/src/amf/AmfShapeGenerator.d.ts.map +1 -1
  8. package/build/src/amf/AmfShapeGenerator.js +4 -1
  9. package/build/src/amf/AmfShapeGenerator.js.map +1 -1
  10. package/build/src/amf/AmfTypes.d.ts +2 -2
  11. package/build/src/amf/AmfTypes.d.ts.map +1 -1
  12. package/build/src/amf/AmfTypes.js.map +1 -1
  13. package/build/src/amf/DataValueGenerator.d.ts +15 -15
  14. package/build/src/amf/DataValueGenerator.d.ts.map +1 -1
  15. package/build/src/amf/DataValueGenerator.js +14 -14
  16. package/build/src/amf/DataValueGenerator.js.map +1 -1
  17. package/build/src/browser.d.ts +12 -9
  18. package/build/src/browser.d.ts.map +1 -1
  19. package/build/src/browser.js +11 -8
  20. package/build/src/browser.js.map +1 -1
  21. package/build/src/exceptions/attach_exception.d.ts +11 -0
  22. package/build/src/exceptions/attach_exception.d.ts.map +1 -0
  23. package/build/src/exceptions/attach_exception.js +11 -0
  24. package/build/src/exceptions/attach_exception.js.map +1 -0
  25. package/build/src/exceptions/detach_exception.d.ts +11 -0
  26. package/build/src/exceptions/detach_exception.d.ts.map +1 -0
  27. package/build/src/exceptions/detach_exception.js +11 -0
  28. package/build/src/exceptions/detach_exception.js.map +1 -0
  29. package/build/src/exceptions/remove_model_exception.d.ts +8 -0
  30. package/build/src/exceptions/remove_model_exception.d.ts.map +1 -0
  31. package/build/src/exceptions/remove_model_exception.js +8 -0
  32. package/build/src/exceptions/remove_model_exception.js.map +1 -0
  33. package/build/src/exceptions/remove_namespace_exception.d.ts +8 -0
  34. package/build/src/exceptions/remove_namespace_exception.d.ts.map +1 -0
  35. package/build/src/exceptions/remove_namespace_exception.js +8 -0
  36. package/build/src/exceptions/remove_namespace_exception.js.map +1 -0
  37. package/build/src/index.d.ts +12 -9
  38. package/build/src/index.d.ts.map +1 -1
  39. package/build/src/index.js +11 -8
  40. package/build/src/index.js.map +1 -1
  41. package/build/src/legacy.d.ts +8 -0
  42. package/build/src/legacy.d.ts.map +1 -1
  43. package/build/src/legacy.js +9 -0
  44. package/build/src/legacy.js.map +1 -1
  45. package/build/src/modeling/Bindings.d.ts +2 -2
  46. package/build/src/modeling/Bindings.d.ts.map +1 -1
  47. package/build/src/modeling/Bindings.js.map +1 -1
  48. package/build/src/modeling/DataDomain.d.ts +601 -0
  49. package/build/src/modeling/DataDomain.d.ts.map +1 -0
  50. package/build/src/modeling/DataDomain.js +1142 -0
  51. package/build/src/modeling/DataDomain.js.map +1 -0
  52. package/build/src/modeling/DataFormat.d.ts +42 -41
  53. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  54. package/build/src/modeling/DataFormat.js +30 -131
  55. package/build/src/modeling/DataFormat.js.map +1 -1
  56. package/build/src/modeling/DomainAssociation.d.ts +281 -0
  57. package/build/src/modeling/DomainAssociation.d.ts.map +1 -0
  58. package/build/src/modeling/DomainAssociation.js +440 -0
  59. package/build/src/modeling/DomainAssociation.js.map +1 -0
  60. package/build/src/modeling/DomainElement.d.ts +33 -0
  61. package/build/src/modeling/DomainElement.d.ts.map +1 -0
  62. package/build/src/modeling/DomainElement.js +32 -0
  63. package/build/src/modeling/DomainElement.js.map +1 -0
  64. package/build/src/modeling/DomainEntity.d.ts +383 -0
  65. package/build/src/modeling/DomainEntity.d.ts.map +1 -0
  66. package/build/src/modeling/DomainEntity.js +718 -0
  67. package/build/src/modeling/DomainEntity.js.map +1 -0
  68. package/build/src/modeling/DomainFile.d.ts +25 -0
  69. package/build/src/modeling/DomainFile.d.ts.map +1 -0
  70. package/build/src/modeling/DomainFile.js +86 -0
  71. package/build/src/modeling/DomainFile.js.map +1 -0
  72. package/build/src/modeling/DomainImpactAnalysis.d.ts +60 -47
  73. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  74. package/build/src/modeling/DomainImpactAnalysis.js +201 -132
  75. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  76. package/build/src/modeling/DomainModel.d.ts +226 -0
  77. package/build/src/modeling/DomainModel.d.ts.map +1 -0
  78. package/build/src/modeling/DomainModel.js +401 -0
  79. package/build/src/modeling/DomainModel.js.map +1 -0
  80. package/build/src/modeling/DomainNamespace.d.ts +268 -0
  81. package/build/src/modeling/DomainNamespace.d.ts.map +1 -0
  82. package/build/src/modeling/DomainNamespace.js +512 -0
  83. package/build/src/modeling/DomainNamespace.js.map +1 -0
  84. package/build/src/modeling/DomainProperty.d.ts +281 -0
  85. package/build/src/modeling/DomainProperty.d.ts.map +1 -0
  86. package/build/src/modeling/DomainProperty.js +560 -0
  87. package/build/src/modeling/DomainProperty.js.map +1 -0
  88. package/build/src/modeling/DomainSerialization.d.ts +40 -0
  89. package/build/src/modeling/DomainSerialization.d.ts.map +1 -0
  90. package/build/src/modeling/DomainSerialization.js +288 -0
  91. package/build/src/modeling/DomainSerialization.js.map +1 -0
  92. package/build/src/modeling/DomainVersioning.d.ts +17 -0
  93. package/build/src/modeling/DomainVersioning.d.ts.map +1 -0
  94. package/build/src/modeling/DomainVersioning.js +124 -0
  95. package/build/src/modeling/DomainVersioning.js.map +1 -0
  96. package/build/src/modeling/GraphUtils.d.ts +8 -0
  97. package/build/src/modeling/GraphUtils.d.ts.map +1 -0
  98. package/build/src/modeling/GraphUtils.js +26 -0
  99. package/build/src/modeling/GraphUtils.js.map +1 -0
  100. package/build/src/modeling/amf/ShapeGenerator.d.ts +164 -0
  101. package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -0
  102. package/build/src/modeling/amf/ShapeGenerator.js +492 -0
  103. package/build/src/modeling/amf/ShapeGenerator.js.map +1 -0
  104. package/build/src/modeling/{DataAssociation.d.ts → legacy/DataAssociation.d.ts} +10 -5
  105. package/build/src/modeling/legacy/DataAssociation.d.ts.map +1 -0
  106. package/build/src/modeling/{DataAssociation.js → legacy/DataAssociation.js} +9 -6
  107. package/build/src/modeling/legacy/DataAssociation.js.map +1 -0
  108. package/build/src/modeling/{DataEntity.d.ts → legacy/DataEntity.d.ts} +12 -7
  109. package/build/src/modeling/legacy/DataEntity.d.ts.map +1 -0
  110. package/build/src/modeling/{DataEntity.js → legacy/DataEntity.js} +19 -18
  111. package/build/src/modeling/legacy/DataEntity.js.map +1 -0
  112. package/build/src/modeling/{DataEntityBuilder.d.ts → legacy/DataEntityBuilder.d.ts} +3 -2
  113. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +1 -0
  114. package/build/src/modeling/{DataEntityBuilder.js → legacy/DataEntityBuilder.js} +3 -2
  115. package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -0
  116. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +298 -0
  117. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +1 -0
  118. package/build/src/modeling/legacy/DataImpactAnalysis.js +441 -0
  119. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +1 -0
  120. package/build/src/modeling/{DataModel.d.ts → legacy/DataModel.d.ts} +6 -4
  121. package/build/src/modeling/legacy/DataModel.d.ts.map +1 -0
  122. package/build/src/modeling/{DataModel.js → legacy/DataModel.js} +7 -6
  123. package/build/src/modeling/legacy/DataModel.js.map +1 -0
  124. package/build/src/modeling/{DataNamespace.d.ts → legacy/DataNamespace.d.ts} +22 -3
  125. package/build/src/modeling/legacy/DataNamespace.d.ts.map +1 -0
  126. package/build/src/modeling/{DataNamespace.js → legacy/DataNamespace.js} +7 -3
  127. package/build/src/modeling/legacy/DataNamespace.js.map +1 -0
  128. package/build/src/modeling/{DataProperty.d.ts → legacy/DataProperty.d.ts} +13 -5
  129. package/build/src/modeling/legacy/DataProperty.d.ts.map +1 -0
  130. package/build/src/modeling/{DataProperty.js → legacy/DataProperty.js} +8 -5
  131. package/build/src/modeling/legacy/DataProperty.js.map +1 -0
  132. package/build/src/modeling/observed.d.ts +67 -0
  133. package/build/src/modeling/observed.d.ts.map +1 -0
  134. package/build/src/modeling/observed.js +230 -0
  135. package/build/src/modeling/observed.js.map +1 -0
  136. package/build/src/modeling/types.d.ts +165 -1
  137. package/build/src/modeling/types.d.ts.map +1 -1
  138. package/build/src/modeling/types.js.map +1 -1
  139. package/build/src/models/Thing.d.ts +26 -5
  140. package/build/src/models/Thing.d.ts.map +1 -1
  141. package/build/src/models/Thing.js +193 -91
  142. package/build/src/models/Thing.js.map +1 -1
  143. package/build/src/models/kinds.d.ts +31 -6
  144. package/build/src/models/kinds.d.ts.map +1 -1
  145. package/build/src/models/kinds.js +31 -6
  146. package/build/src/models/kinds.js.map +1 -1
  147. package/build/src/models/store/DataFile.d.ts +3 -1
  148. package/build/src/models/store/DataFile.d.ts.map +1 -1
  149. package/build/src/models/store/DataFile.js +2 -0
  150. package/build/src/models/store/DataFile.js.map +1 -1
  151. package/build/src/models/types.d.ts +12 -0
  152. package/build/src/models/types.d.ts.map +1 -0
  153. package/build/src/models/types.js +2 -0
  154. package/build/src/models/types.js.map +1 -0
  155. package/build/src/runtime/store/FilesSdk.d.ts +2 -2
  156. package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
  157. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  158. package/data/models/example-generator-api.json +16 -16
  159. package/package.json +20 -6
  160. package/readme.md +1 -1
  161. package/src/amf/AmfShapeGenerator.ts +7 -4
  162. package/src/amf/AmfTypes.ts +2 -2
  163. package/src/amf/DataValueGenerator.ts +21 -21
  164. package/src/exceptions/attach_exception.ts +11 -0
  165. package/src/exceptions/detach_exception.ts +11 -0
  166. package/src/exceptions/remove_model_exception.ts +8 -0
  167. package/src/exceptions/remove_namespace_exception.ts +8 -0
  168. package/src/modeling/Bindings.ts +2 -2
  169. package/src/modeling/DataDomain.ts +1221 -0
  170. package/src/modeling/DataFormat.ts +54 -163
  171. package/src/modeling/DomainAssociation.ts +476 -0
  172. package/src/modeling/DomainElement.ts +50 -0
  173. package/src/modeling/DomainEntity.ts +769 -0
  174. package/src/modeling/DomainFile.ts +94 -0
  175. package/src/modeling/DomainImpactAnalysis.ts +218 -144
  176. package/src/modeling/DomainModel.ts +421 -0
  177. package/src/modeling/DomainNamespace.ts +537 -0
  178. package/src/modeling/DomainProperty.ts +548 -0
  179. package/src/modeling/DomainSerialization.ts +312 -0
  180. package/src/modeling/DomainVersioning.ts +144 -0
  181. package/src/modeling/GraphUtils.ts +28 -0
  182. package/src/modeling/amf/ShapeGenerator.ts +552 -0
  183. package/src/modeling/graph.md +115 -0
  184. package/src/modeling/{DataAssociation.ts → legacy/DataAssociation.ts} +13 -8
  185. package/src/modeling/{DataEntity.ts → legacy/DataEntity.ts} +28 -23
  186. package/src/modeling/{DataEntityBuilder.ts → legacy/DataEntityBuilder.ts} +4 -3
  187. package/src/modeling/legacy/DataImpactAnalysis.ts +530 -0
  188. package/src/modeling/{DataModel.ts → legacy/DataModel.ts} +10 -8
  189. package/src/modeling/{DataNamespace.ts → legacy/DataNamespace.ts} +23 -5
  190. package/src/modeling/{DataProperty.ts → legacy/DataProperty.ts} +15 -7
  191. package/src/modeling/observed.ts +267 -0
  192. package/src/modeling/types.ts +174 -1
  193. package/src/models/Thing.ts +70 -5
  194. package/src/models/kinds.ts +32 -6
  195. package/src/models/store/DataFile.ts +3 -1
  196. package/src/models/types.ts +11 -0
  197. package/src/runtime/store/FilesSdk.ts +2 -2
  198. package/tests/unit/amf/data_value_generator.spec.ts +15 -15
  199. package/tests/unit/legacy-transformers/ARC-legacy-import.spec.ts +1 -1
  200. package/tests/unit/modeling/amf/shape_generator.spec.ts +1174 -0
  201. package/tests/unit/modeling/data_domain.spec.ts +444 -0
  202. package/tests/unit/modeling/data_domain_associations.spec.ts +279 -0
  203. package/tests/unit/modeling/data_domain_change_observers.spec.ts +681 -0
  204. package/tests/unit/modeling/data_domain_entities.spec.ts +449 -0
  205. package/tests/unit/modeling/data_domain_foreign.spec.ts +355 -0
  206. package/tests/unit/modeling/data_domain_models.spec.ts +658 -0
  207. package/tests/unit/modeling/data_domain_namespaces.spec.ts +668 -0
  208. package/tests/unit/modeling/data_domain_property.spec.ts +264 -0
  209. package/tests/unit/modeling/data_domain_serialization.spec.ts +294 -0
  210. package/tests/unit/modeling/domain.property.spec.ts +822 -0
  211. package/tests/unit/modeling/domain_asociation.spec.ts +643 -0
  212. package/tests/unit/modeling/domain_asociation_targets.spec.ts +350 -0
  213. package/tests/unit/modeling/domain_entity.spec.ts +730 -0
  214. package/tests/unit/modeling/domain_entity_associations.spec.ts +330 -0
  215. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +988 -0
  216. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1451 -0
  217. package/tests/unit/modeling/domain_entity_fields.spec.ts +113 -0
  218. package/tests/unit/modeling/domain_entity_generators.spec.ts +20 -0
  219. package/tests/unit/modeling/domain_entity_parents.spec.ts +291 -0
  220. package/tests/unit/modeling/domain_entity_properties.spec.ts +305 -0
  221. package/tests/unit/modeling/{data_file.spec.ts → domain_file.spec.ts} +29 -85
  222. package/tests/unit/modeling/domain_impact_analysis.spec.ts +452 -0
  223. package/tests/unit/modeling/domain_model.spec.ts +568 -0
  224. package/tests/unit/modeling/domain_model_entities.spec.ts +408 -0
  225. package/tests/unit/modeling/domain_namespace.spec.ts +514 -0
  226. package/tests/unit/modeling/domain_namespace_models.spec.ts +324 -0
  227. package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +404 -0
  228. package/tests/unit/modeling/domain_versioning.spec.ts +140 -0
  229. package/tests/unit/{amf → modeling/legacy}/amf_shape_generator.spec.ts +11 -11
  230. package/tests/unit/modeling/{data_association.spec.ts → legacy/data_association.spec.ts} +3 -11
  231. package/tests/unit/modeling/{data_entity.spec.ts → legacy/data_entity.spec.ts} +10 -8
  232. package/tests/unit/modeling/{data_entity_generator_json.spec.ts → legacy/data_entity_generator_json.spec.ts} +1 -1
  233. package/tests/unit/modeling/{data_entity_generator_xml.spec.ts → legacy/data_entity_generator_xml.spec.ts} +1 -1
  234. package/tests/unit/modeling/{data_model.spec.ts → legacy/data_model.spec.ts} +3 -3
  235. package/tests/unit/modeling/{data_namespace.spec.ts → legacy/data_namespace.spec.ts} +3 -10
  236. package/tests/unit/modeling/{data_property.spec.ts → legacy/data_property.spec.ts} +3 -6
  237. package/tests/unit/modeling/{impact_analysis.spec.ts → legacy/impact_analysis.spec.ts} +9 -9
  238. package/tests/unit/models/File/new.spec.ts +1 -1
  239. package/tests/unit/models/HttpProject.spec.ts +3 -3
  240. package/tsconfig.node.json +35 -0
  241. package/build/src/modeling/DataAssociation.d.ts.map +0 -1
  242. package/build/src/modeling/DataAssociation.js.map +0 -1
  243. package/build/src/modeling/DataEntity.d.ts.map +0 -1
  244. package/build/src/modeling/DataEntity.js.map +0 -1
  245. package/build/src/modeling/DataEntityBuilder.d.ts.map +0 -1
  246. package/build/src/modeling/DataEntityBuilder.js.map +0 -1
  247. package/build/src/modeling/DataModel.d.ts.map +0 -1
  248. package/build/src/modeling/DataModel.js.map +0 -1
  249. package/build/src/modeling/DataNamespace.d.ts.map +0 -1
  250. package/build/src/modeling/DataNamespace.js.map +0 -1
  251. package/build/src/modeling/DataProperty.d.ts.map +0 -1
  252. package/build/src/modeling/DataProperty.js.map +0 -1
@@ -1,21 +1,21 @@
1
- import { DataNamespaceKind, DataEntityKind, DataModelKind, DataPropertyKind, DataAssociationKind, } from '../models/kinds.js';
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 powerful tool for analyzing the consequences of deleting data domain objects
6
- * within a `DataNamespace`.
7
- * It helps developers understand the ripple effects of removing a namespace, data model, entity, property,
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 `ImpactItem` objects, each describing a specific consequence.
14
+ * - A list of `DomainImpactItem` objects, each describing a specific consequence.
16
15
  * - Whether the deletion can proceed safely (`canProceed`).
17
16
  *
18
- * - **ImpactItem:** Each `ImpactItem` describes a specific consequence of the deletion. Key properties include:
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 `DataNamespace` as an argument.
36
+ * 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataDomain` as an argument.
37
37
  *
38
38
  * ```typescript
39
- * import { DataNamespace } from './DataNamespace';
39
+ * import { DataDomain } from './DataDomain';
40
40
  * import { DomainImpactAnalysis } from './DomainImpactAnalysis';
41
41
  *
42
- * const rootNamespace = new DataNamespace();
43
- * // ... add some data to the namespace
44
- * const analyzer = new DomainImpactAnalysis(rootNamespace);
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 `ImpactReport` for a specific deletion.
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 { DataEntityKind } from '../models/kinds.js';
52
+ * import { DomainEntityKind } from '../models/kinds.js';
52
53
  * // ...
53
54
  * const entityKey = 'some-entity-key';
54
- * const report = analyzer.deleteAnalysis(entityKey, DataEntityKind);
55
+ * const report = analyzer.deleteAnalysis(entityKey, DomainEntityKind);
55
56
  * ```
56
57
  *
57
- * 3. **Interpreting the Report:** Examine the `ImpactReport` to understand the consequences of the deletion.
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 object types:
83
+ * The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain element types:
83
84
  *
84
- * - **Namespaces (`DataNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,
85
- * data models, entities, properties, and associations.
86
- * - **Data Models (`DataModelKind`):** Deleting a data model impacts all its entities, properties, and associations.
87
- * - **Entities (`DataEntityKind`):** Deleting an entity impacts its properties, associations, and any other
88
- * entities that have it as a parent or target in an association.
89
- * - **Properties (`DataPropertyKind`):** Deleting a property impacts the entity it belongs to.
90
- * - **Associations (`DataAssociationKind`):** Deleting an association impacts the entity it belongs to.
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
- * - Namespace: `MyNamespace`
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": "DataEntityKind",
115
+ * "kind": "DomainEntityKind",
111
116
  * "impact": [
112
117
  * {
113
118
  * "key": "Product",
114
- * "kind": "DataEntityKind",
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": "DataEntityKind",
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": "DataAssociationKind",
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": "DataPropertyKind",
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
- * ### `ImpactKinds`
163
+ * ### `DomainImpactKinds`
159
164
  *
160
- * - **Description:** A type alias for the kinds of data domain objects that can be analyzed.
165
+ * - **Description:** A type alias for the kinds of data domain elements that can be analyzed.
161
166
  * - **Values:**
162
- * - `DataNamespaceKind`
163
- * - `DataEntityKind`
164
- * - `DataModelKind`
165
- * - `DataPropertyKind`
166
- * - `DataAssociationKind`
167
+ * - `DomainNamespaceKind`
168
+ * - `DomainEntityKind`
169
+ * - `DomainModelKind`
170
+ * - `DomainPropertyKind`
171
+ * - `DomainAssociationKind`
172
+ * - `DataDomainKind`
167
173
  *
168
- * ### `ImpactReport`
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` (`ImpactKinds`): The kind of the object being deleted.
174
- * - `impact` (`ImpactItem[]`): The list of impacts.
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
- * ### `ImpactItem`
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 `ImpactReport` to communicate
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 object, always use `DomainImpactAnalysis`
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: DataNamespaceKind,
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
- // this.report.impact.unshift({
238
- // key,
239
- // kind,
240
- // type: 'delete',
241
- // impact: `The ${this.kindToLabel(kind)} with key ${key} will be deleted.`,
242
- // blocking: false,
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 DataNamespaceKind:
262
+ case DomainNamespaceKind:
249
263
  return this.deleteNamespaceAnalysis(key, rootKey);
250
- case DataModelKind:
264
+ case DomainModelKind:
251
265
  return this.deleteDataModelAnalysis(key, rootKey);
252
- case DataEntityKind:
266
+ case DomainEntityKind:
253
267
  return this.deleteEntityAnalysis(key, rootKey);
254
- case DataPropertyKind:
268
+ case DomainPropertyKind:
255
269
  return this.deletePropertyAnalysis(key);
256
- case DataAssociationKind:
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.renderLabel} ${this.kindToLabel(DataNamespaceKind)} will be deleted.`,
286
+ impact: `The ${ns.info.getLabel()} ${this.kindToLabel(DomainNamespaceKind)} will be deleted.`,
273
287
  blocking: false,
274
288
  });
275
- const namespaces = ns.listNamespaces();
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 models = ns.listDataModels();
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.findDataModel(key);
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.renderLabel} ${this.kindToLabel(DataModelKind)} will be deleted.`,
309
+ impact: `The ${model.info.getLabel()} ${this.kindToLabel(DomainModelKind)} will be deleted.`,
298
310
  blocking: false,
299
311
  });
300
- model.entities.forEach((child) => {
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.renderLabel} ${this.kindToLabel(DataEntityKind)} will be deleted.`,
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 children = this.root.definitions.entities.filter((domainEntity) => {
321
- if (domainEntity.key === entity.key) {
322
- // ignore self
323
- return false;
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
- if (!domainEntity.parents.includes(entity.key)) {
326
- // no relationship
327
- return false;
337
+ const childEntity = this.root.findEntity(info.v);
338
+ if (!childEntity) {
339
+ continue;
328
340
  }
329
- if (domainEntity.isChildOf(rootKey)) {
330
- // No need to include this parent as it itself is being deleted
331
- return false;
341
+ if (childEntity.isChildOf(rootKey)) {
342
+ // No need to include this child as it itself is being deleted
343
+ continue;
332
344
  }
333
- // the entity has a parent-child relationship to the deleted entity.
334
- return true;
335
- });
336
- if (children.length) {
337
- children.forEach((child) => {
338
- const pLabel = entity.info.renderLabel;
339
- const cLabel = child.info.renderLabel;
340
- result.push({
341
- key: child.key,
342
- kind: child.kind,
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 inAssociations = this.root.definitions.associations.filter((association) => {
354
- return association.targets.some((item) => {
355
- if (item.key === entity.key) {
356
- const related = association.getParentInstance();
357
- if (!related) {
358
- return false;
359
- }
360
- if (related.isChildOf(rootKey)) {
361
- // No need to include this association as the related entity itself is being deleted
362
- return false;
363
- }
364
- return true;
365
- }
366
- return false;
367
- });
368
- });
369
- if (inAssociations.length) {
370
- inAssociations.forEach((association) => {
371
- result.push({
372
- key: association.key,
373
- kind: association.kind,
374
- type: 'delete',
375
- impact: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be broken because it has a target to ${entity.info.renderLabel}.`,
376
- resolution: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be removed from ${entity.info.renderLabel}.`,
377
- blocking: true,
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.properties.forEach((child) => {
388
+ for (const child of entity.listProperties()) {
383
389
  const items = this.deletePropertyAnalysis(child.key);
384
390
  result.push(...items);
385
- });
386
- entity.associations.forEach((child) => {
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.renderLabel} ${this.kindToLabel(DataPropertyKind)} will be deleted.`,
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.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be deleted.`,
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 DataNamespaceKind:
430
+ case DomainNamespaceKind:
425
431
  return 'namespace';
426
- case DataEntityKind:
432
+ case DomainEntityKind:
427
433
  return 'entity';
428
- case DataModelKind:
434
+ case DomainModelKind:
429
435
  return 'data model';
430
- case DataPropertyKind:
436
+ case DomainPropertyKind:
431
437
  return 'property';
432
- case DataAssociationKind:
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