@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,18 +1,20 @@
1
1
  import {
2
- DataNamespaceKind,
3
- DataEntityKind,
4
- DataModelKind,
5
- DataPropertyKind,
6
- DataAssociationKind,
2
+ DomainNamespaceKind,
3
+ DomainEntityKind,
4
+ DomainModelKind,
5
+ DomainPropertyKind,
6
+ DomainAssociationKind,
7
+ DataDomainKind,
7
8
  } from '../models/kinds.js'
8
- import type { DataNamespace } from './DataNamespace.js'
9
+ import type { DataDomain } from './DataDomain.js'
9
10
 
10
11
  export type DomainImpactKinds =
11
- | typeof DataNamespaceKind
12
- | typeof DataEntityKind
13
- | typeof DataModelKind
14
- | typeof DataPropertyKind
15
- | typeof DataAssociationKind
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 powerful tool for analyzing the consequences of deleting data domain objects
80
- * within a `DataNamespace`.
81
- * It helps developers understand the ripple effects of removing a namespace, data model, entity, property,
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 `ImpactItem` objects, each describing a specific consequence.
90
+ * - A list of `DomainImpactItem` objects, each describing a specific consequence.
90
91
  * - Whether the deletion can proceed safely (`canProceed`).
91
92
  *
92
- * - **ImpactItem:** Each `ImpactItem` describes a specific consequence of the deletion. Key properties include:
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 `DataNamespace` as an argument.
112
+ * 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataDomain` as an argument.
111
113
  *
112
114
  * ```typescript
113
- * import { DataNamespace } from './DataNamespace';
115
+ * import { DataDomain } from './DataDomain';
114
116
  * import { DomainImpactAnalysis } from './DomainImpactAnalysis';
115
117
  *
116
- * const rootNamespace = new DataNamespace();
117
- * // ... add some data to the namespace
118
- * const analyzer = new DomainImpactAnalysis(rootNamespace);
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 `ImpactReport` for a specific deletion.
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 { DataEntityKind } from '../models/kinds.js';
128
+ * import { DomainEntityKind } from '../models/kinds.js';
126
129
  * // ...
127
130
  * const entityKey = 'some-entity-key';
128
- * const report = analyzer.deleteAnalysis(entityKey, DataEntityKind);
131
+ * const report = analyzer.deleteAnalysis(entityKey, DomainEntityKind);
129
132
  * ```
130
133
  *
131
- * 3. **Interpreting the Report:** Examine the `ImpactReport` to understand the consequences of the deletion.
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 object types:
159
+ * The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain element types:
157
160
  *
158
- * - **Namespaces (`DataNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,
159
- * data models, entities, properties, and associations.
160
- * - **Data Models (`DataModelKind`):** Deleting a data model impacts all its entities, properties, and associations.
161
- * - **Entities (`DataEntityKind`):** Deleting an entity impacts its properties, associations, and any other
162
- * entities that have it as a parent or target in an association.
163
- * - **Properties (`DataPropertyKind`):** Deleting a property impacts the entity it belongs to.
164
- * - **Associations (`DataAssociationKind`):** Deleting an association impacts the entity it belongs to.
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
- * - Namespace: `MyNamespace`
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": "DataEntityKind",
191
+ * "kind": "DomainEntityKind",
185
192
  * "impact": [
186
193
  * {
187
194
  * "key": "Product",
188
- * "kind": "DataEntityKind",
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": "DataEntityKind",
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": "DataAssociationKind",
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": "DataPropertyKind",
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
- * ### `ImpactKinds`
239
+ * ### `DomainImpactKinds`
233
240
  *
234
- * - **Description:** A type alias for the kinds of data domain objects that can be analyzed.
241
+ * - **Description:** A type alias for the kinds of data domain elements that can be analyzed.
235
242
  * - **Values:**
236
- * - `DataNamespaceKind`
237
- * - `DataEntityKind`
238
- * - `DataModelKind`
239
- * - `DataPropertyKind`
240
- * - `DataAssociationKind`
243
+ * - `DomainNamespaceKind`
244
+ * - `DomainEntityKind`
245
+ * - `DomainModelKind`
246
+ * - `DomainPropertyKind`
247
+ * - `DomainAssociationKind`
248
+ * - `DataDomainKind`
241
249
  *
242
- * ### `ImpactReport`
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` (`ImpactKinds`): The kind of the object being deleted.
248
- * - `impact` (`ImpactItem[]`): The list of impacts.
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
- * ### `ImpactItem`
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 `ImpactReport` to communicate
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 object, always use `DomainImpactAnalysis`
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: DataNamespace
295
+ private root: DataDomain
288
296
 
289
- constructor(root: DataNamespace) {
297
+ constructor(root: DataDomain) {
290
298
  this.root = root
291
299
  this.report = {
292
300
  key: '',
293
- kind: DataNamespaceKind,
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
- // this.report.impact.unshift({
314
- // key,
315
- // kind,
316
- // type: 'delete',
317
- // impact: `The ${this.kindToLabel(kind)} with key ${key} will be deleted.`,
318
- // blocking: false,
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 DataNamespaceKind:
342
+ case DomainNamespaceKind:
326
343
  return this.deleteNamespaceAnalysis(key, rootKey)
327
- case DataModelKind:
344
+ case DomainModelKind:
328
345
  return this.deleteDataModelAnalysis(key, rootKey)
329
- case DataEntityKind:
346
+ case DomainEntityKind:
330
347
  return this.deleteEntityAnalysis(key, rootKey)
331
- case DataPropertyKind:
348
+ case DomainPropertyKind:
332
349
  return this.deletePropertyAnalysis(key)
333
- case DataAssociationKind:
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.renderLabel} ${this.kindToLabel(DataNamespaceKind)} will be deleted.`,
367
+ impact: `The ${ns.info.getLabel()} ${this.kindToLabel(DomainNamespaceKind)} will be deleted.`,
351
368
  blocking: false,
352
369
  })
353
- const namespaces = ns.listNamespaces()
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 models = ns.listDataModels()
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.findDataModel(key)
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.renderLabel} ${this.kindToLabel(DataModelKind)} will be deleted.`,
391
+ impact: `The ${model.info.getLabel()} ${this.kindToLabel(DomainModelKind)} will be deleted.`,
377
392
  blocking: false,
378
393
  })
379
- model.entities.forEach((child) => {
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.renderLabel} ${this.kindToLabel(DataEntityKind)} will be deleted.`,
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 children = this.root.definitions.entities.filter((domainEntity) => {
401
- if (domainEntity.key === entity.key) {
402
- // ignore self
403
- return false
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
- if (!domainEntity.parents.includes(entity.key)) {
406
- // no relationship
407
- return false
421
+ const childEntity = this.root.findEntity(info.v)
422
+ if (!childEntity) {
423
+ continue
408
424
  }
409
- if (domainEntity.isChildOf(rootKey)) {
410
- // No need to include this parent as it itself is being deleted
411
- return false
425
+ if (childEntity.isChildOf(rootKey)) {
426
+ // No need to include this child as it itself is being deleted
427
+ continue
412
428
  }
413
- // the entity has a parent-child relationship to the deleted entity.
414
- return true
415
- })
416
- if (children.length) {
417
- children.forEach((child) => {
418
- const pLabel = entity.info.renderLabel
419
- const cLabel = child.info.renderLabel
420
- result.push({
421
- key: child.key,
422
- kind: child.kind,
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 inAssociations = this.root.definitions.associations.filter((association) => {
434
- return association.targets.some((item) => {
435
- if (item.key === entity.key) {
436
- const related = association.getParentInstance()
437
- if (!related) {
438
- return false
439
- }
440
- if (related.isChildOf(rootKey)) {
441
- // No need to include this association as the related entity itself is being deleted
442
- return false
443
- }
444
- return true
445
- }
446
- return false
447
- })
448
- })
449
- if (inAssociations.length) {
450
- inAssociations.forEach((association) => {
451
- result.push({
452
- key: association.key,
453
- kind: association.kind,
454
- type: 'delete',
455
- impact: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be broken because it has a target to ${entity.info.renderLabel}.`,
456
- resolution: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be removed from ${entity.info.renderLabel}.`,
457
- blocking: true,
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.properties.forEach((child) => {
473
+ for (const child of entity.listProperties()) {
463
474
  const items = this.deletePropertyAnalysis(child.key)
464
475
  result.push(...items)
465
- })
466
- entity.associations.forEach((child) => {
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.renderLabel} ${this.kindToLabel(DataPropertyKind)} will be deleted.`,
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.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be deleted.`,
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 DataNamespaceKind:
518
+ case DomainNamespaceKind:
508
519
  return 'namespace'
509
- case DataEntityKind:
520
+ case DomainEntityKind:
510
521
  return 'entity'
511
- case DataModelKind:
522
+ case DomainModelKind:
512
523
  return 'data model'
513
- case DataPropertyKind:
524
+ case DomainPropertyKind:
514
525
  return 'property'
515
- case DataAssociationKind:
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
  }