@api-client/core 0.13.6 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/build/src/amf/AmfTypes.d.ts +1 -1
  2. package/build/src/amf/AmfTypes.js +1 -1
  3. package/build/src/amf/AmfTypes.js.map +1 -1
  4. package/build/src/amf/Utils.d.ts +0 -6
  5. package/build/src/amf/Utils.d.ts.map +1 -1
  6. package/build/src/amf/Utils.js +0 -14
  7. package/build/src/amf/Utils.js.map +1 -1
  8. package/build/src/browser.d.ts +1 -0
  9. package/build/src/browser.d.ts.map +1 -1
  10. package/build/src/browser.js +1 -0
  11. package/build/src/browser.js.map +1 -1
  12. package/build/src/index.d.ts +1 -0
  13. package/build/src/index.d.ts.map +1 -1
  14. package/build/src/index.js +1 -0
  15. package/build/src/index.js.map +1 -1
  16. package/build/src/legacy.d.ts +0 -8
  17. package/build/src/legacy.d.ts.map +1 -1
  18. package/build/src/legacy.js +0 -9
  19. package/build/src/legacy.js.map +1 -1
  20. package/build/src/modeling/Bindings.d.ts +1 -1
  21. package/build/src/modeling/Bindings.js.map +1 -1
  22. package/build/src/modeling/DataDomain.js +2 -2
  23. package/build/src/modeling/DataDomain.js.map +1 -1
  24. package/build/src/modeling/DataFormat.d.ts +0 -40
  25. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  26. package/build/src/modeling/DataFormat.js +0 -27
  27. package/build/src/modeling/DataFormat.js.map +1 -1
  28. package/build/src/modeling/DomainAssociation.d.ts +28 -0
  29. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  30. package/build/src/modeling/DomainAssociation.js +73 -4
  31. package/build/src/modeling/DomainAssociation.js.map +1 -1
  32. package/build/src/modeling/DomainEntity.d.ts +25 -9
  33. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  34. package/build/src/modeling/DomainEntity.js +65 -21
  35. package/build/src/modeling/DomainEntity.js.map +1 -1
  36. package/build/src/modeling/DomainFile.d.ts +3 -4
  37. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  38. package/build/src/modeling/DomainFile.js +5 -9
  39. package/build/src/modeling/DomainFile.js.map +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  42. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  43. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  44. package/build/src/modeling/DomainModel.d.ts +2 -2
  45. package/build/src/modeling/DomainModel.js +2 -2
  46. package/build/src/modeling/DomainModel.js.map +1 -1
  47. package/build/src/modeling/DomainProperty.d.ts +28 -12
  48. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  49. package/build/src/modeling/DomainProperty.js +61 -26
  50. package/build/src/modeling/DomainProperty.js.map +1 -1
  51. package/build/src/modeling/Semantics.d.ts +109 -0
  52. package/build/src/modeling/Semantics.d.ts.map +1 -0
  53. package/build/src/modeling/Semantics.js +97 -0
  54. package/build/src/modeling/Semantics.js.map +1 -0
  55. package/build/src/models/CertificateFile.d.ts +2 -3
  56. package/build/src/models/CertificateFile.d.ts.map +1 -1
  57. package/build/src/models/CertificateFile.js +4 -8
  58. package/build/src/models/CertificateFile.js.map +1 -1
  59. package/build/src/models/Folder.d.ts +1 -2
  60. package/build/src/models/Folder.d.ts.map +1 -1
  61. package/build/src/models/Folder.js +2 -4
  62. package/build/src/models/Folder.js.map +1 -1
  63. package/build/src/models/Project.d.ts +2 -3
  64. package/build/src/models/Project.d.ts.map +1 -1
  65. package/build/src/models/Project.js +4 -8
  66. package/build/src/models/Project.js.map +1 -1
  67. package/build/src/models/kinds.d.ts +0 -24
  68. package/build/src/models/kinds.d.ts.map +1 -1
  69. package/build/src/models/kinds.js +0 -24
  70. package/build/src/models/kinds.js.map +1 -1
  71. package/build/src/models/store/File.d.ts +1 -21
  72. package/build/src/models/store/File.d.ts.map +1 -1
  73. package/build/src/models/store/File.js +3 -23
  74. package/build/src/models/store/File.js.map +1 -1
  75. package/build/src/models/store/data_catalog.d.ts +1 -1
  76. package/build/src/models/store/data_catalog.js.map +1 -1
  77. package/build/src/sdk/FilesSdk.js +1 -1
  78. package/build/src/sdk/FilesSdk.js.map +1 -1
  79. package/build/tsconfig.tsbuildinfo +1 -1
  80. package/data/models/example-generator-api.json +22 -22
  81. package/eslint.config.js +1 -0
  82. package/package.json +5 -5
  83. package/src/amf/AmfTypes.ts +1 -1
  84. package/src/amf/Utils.ts +0 -15
  85. package/src/modeling/Bindings.ts +1 -1
  86. package/src/modeling/DataDomain.ts +2 -2
  87. package/src/modeling/DataFormat.ts +0 -48
  88. package/src/modeling/DomainAssociation.ts +66 -3
  89. package/src/modeling/DomainEntity.ts +56 -17
  90. package/src/modeling/DomainFile.ts +5 -9
  91. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  92. package/src/modeling/DomainModel.ts +2 -2
  93. package/src/modeling/DomainProperty.ts +60 -21
  94. package/src/modeling/Semantics.ts +178 -0
  95. package/src/modeling/graph.md +14 -14
  96. package/src/modeling/readme.md +29 -29
  97. package/src/models/CertificateFile.ts +4 -12
  98. package/src/models/Folder.ts +2 -4
  99. package/src/models/Project.ts +4 -8
  100. package/src/models/kinds.ts +0 -25
  101. package/src/models/store/File.ts +4 -35
  102. package/src/models/store/data_catalog.ts +1 -1
  103. package/src/sdk/FilesSdk.ts +1 -1
  104. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  105. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  106. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  107. package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
  108. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  109. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  110. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  111. package/tests/unit/modeling/domain_file.spec.ts +4 -27
  112. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  113. package/tests/unit/models/Certificate/from_name.spec.ts +3 -15
  114. package/tests/unit/models/File/constructor.spec.ts +0 -1
  115. package/tests/unit/models/File/new.spec.ts +0 -13
  116. package/tests/unit/models/File/shortcutTo.spec.ts +1 -2
  117. package/tests/unit/models/File/toJSON.spec.ts +0 -13
  118. package/tests/unit/models/File/updateByMeMeta.spec.ts +4 -6
  119. package/tests/unit/models/Folder/create.spec.ts +2 -23
  120. package/tests/unit/models/Project/create.spec.ts +6 -32
  121. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  122. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  123. package/build/src/amf/AmfShapeGenerator.js +0 -416
  124. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  125. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  126. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  127. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  128. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  129. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  130. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  131. package/build/src/modeling/legacy/DataEntity.js +0 -855
  132. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  133. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  134. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  135. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  136. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  137. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  138. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  139. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  140. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  141. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  142. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  143. package/build/src/modeling/legacy/DataModel.js +0 -237
  144. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  145. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  146. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  147. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  148. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  149. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  150. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  151. package/build/src/modeling/legacy/DataProperty.js +0 -415
  152. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  153. package/build/src/models/store/DataFile.d.ts +0 -31
  154. package/build/src/models/store/DataFile.d.ts.map +0 -1
  155. package/build/src/models/store/DataFile.js +0 -92
  156. package/build/src/models/store/DataFile.js.map +0 -1
  157. package/src/amf/AmfShapeGenerator.ts +0 -477
  158. package/src/modeling/legacy/DataAssociation.ts +0 -554
  159. package/src/modeling/legacy/DataEntity.ts +0 -1019
  160. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  161. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  162. package/src/modeling/legacy/DataModel.ts +0 -276
  163. package/src/modeling/legacy/DataNamespace.ts +0 -929
  164. package/src/modeling/legacy/DataProperty.ts +0 -630
  165. package/src/models/store/DataFile.ts +0 -100
  166. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  167. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  168. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  169. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  170. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  171. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  172. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  173. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  174. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -1,530 +0,0 @@
1
- import {
2
- DataNamespaceKind,
3
- DataEntityKind,
4
- DataModelKind,
5
- DataPropertyKind,
6
- DataAssociationKind,
7
- } from '../../models/kinds.js'
8
- import type { DataNamespace } from './DataNamespace.js'
9
-
10
- /**
11
- * @deprecated
12
- */
13
- export type DataImpactKinds =
14
- | typeof DataNamespaceKind
15
- | typeof DataEntityKind
16
- | typeof DataModelKind
17
- | typeof DataPropertyKind
18
- | typeof DataAssociationKind
19
-
20
- /**
21
- * The impact analysis report
22
- * @deprecated
23
- */
24
- export interface DataImpactReport {
25
- /**
26
- * The key of the impacted data object.
27
- * This is the key of the object that is being changed.
28
- */
29
- key: string
30
- /**
31
- * The kind of the impacted data object.
32
- * This is the kind of the object that is being changed.
33
- */
34
- kind: DataImpactKinds
35
- /**
36
- * The list of impacted data objects.
37
- */
38
- impact: DataImpactItem[]
39
- /**
40
- * Whether it is possible to proceed with the change.
41
- * If the change is not possible, the reason will be in the impact list.
42
- */
43
- canProceed: boolean
44
- }
45
-
46
- /**
47
- * @deprecated
48
- */
49
- export interface DataImpactItem {
50
- /**
51
- * The key of the impacted data object.
52
- */
53
- key: string
54
- /**
55
- * The kind of the impacted data object.
56
- */
57
- kind: string
58
- /**
59
- * The type of the impact.
60
- *
61
- * - `delete` - The data object would be deleted.
62
- */
63
- type: 'delete'
64
- /**
65
- * The impact description.
66
- */
67
- impact: string
68
- /**
69
- * Whether the impact is blocking the operation.
70
- * If true, the operation cannot proceed.
71
- */
72
- blocking: boolean
73
- /**
74
- * The type of the relationship between two impacted objects.
75
- */
76
- relationship?: 'child'
77
- /**
78
- * The resolution of the conflict if the change will be forced.
79
- */
80
- resolution?: string
81
- }
82
-
83
- /**
84
- * # DomainImpactAnalysis
85
- *
86
- * The `DomainImpactAnalysis` class is a powerful tool for analyzing the consequences of deleting data domain objects
87
- * within a `DataNamespace`.
88
- * It helps developers understand the ripple effects of removing a namespace, data model, entity, property,
89
- * or association, ensuring data integrity and preventing unintended side effects.
90
- *
91
- * ## Core Concepts
92
- *
93
- * - **Impact Report:** The central output of the `DomainImpactAnalysis` class is an `DataImpactReport`.
94
- * This report details the potential consequences of a deletion operation, including:
95
- * - The object being deleted (`key`, `kind`).
96
- * - A list of `ImpactItem` objects, each describing a specific consequence.
97
- * - Whether the deletion can proceed safely (`canProceed`).
98
- *
99
- * - **ImpactItem:** Each `ImpactItem` describes a specific consequence of the deletion. Key properties include:
100
- * - `key`: The key of the impacted object.
101
- * - `kind`: The kind of the impacted object.
102
- * - `type`: The type of impact (currently only `delete`).
103
- * - `impact`: A human-readable description of the impact.
104
- * - `blocking`: Whether this impact prevents the deletion from proceeding.
105
- * - `relationship`: The type of relationship between the deleted object and the impacted object (e.g., `child`).
106
- * - `resolution`: A description of how the impact will be resolved if the deletion is forced.
107
- *
108
- * - **Blocking Impacts:** Some impacts are considered "blocking," meaning they prevent the deletion from proceeding
109
- * without manual intervention. For example, deleting an entity that is a parent to other entities is
110
- * a blocking impact.
111
- *
112
- * - **Non-Blocking Impacts:** Some impacts are informational and do not prevent the deletion. For example, deleting a
113
- * property is not a blocking impact.
114
- *
115
- * ## Usage
116
- *
117
- * 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataNamespace` as an argument.
118
- *
119
- * ```typescript
120
- * import { DataNamespace } from './DataNamespace';
121
- * import { DomainImpactAnalysis } from './DomainImpactAnalysis';
122
- *
123
- * const rootNamespace = new DataNamespace();
124
- * // ... add some data to the namespace
125
- * const analyzer = new DomainImpactAnalysis(rootNamespace);
126
- * ```
127
- *
128
- * 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `ImpactReport` for a specific deletion.
129
- * Provide the `key` and `kind` of the object to be deleted.
130
- *
131
- * ```typescript
132
- * import { DataEntityKind } from '../models/kinds.js';
133
- * // ...
134
- * const entityKey = 'some-entity-key';
135
- * const report = analyzer.deleteAnalysis(entityKey, DataEntityKind);
136
- * ```
137
- *
138
- * 3. **Interpreting the Report:** Examine the `ImpactReport` to understand the consequences of the deletion.
139
- * - Check `report.canProceed` to see if the deletion is safe.
140
- * - Iterate through `report.impact` to understand each consequence.
141
- * - Pay special attention to `impact.blocking` to identify impacts that require manual resolution.
142
- *
143
- * ```typescript
144
- * if (report.canProceed) {
145
- * // Proceed with deletion
146
- * } else {
147
- * console.warn('Deletion cannot proceed due to the following impacts:');
148
- * report.impact.forEach((item) => {
149
- * console.warn(`- ${item.impact}`);
150
- * if (item.blocking) {
151
- * console.warn(` - This impact is blocking.`);
152
- * if (item.resolution) {
153
- * console.warn(` - Resolution: ${item.resolution}`);
154
- * }
155
- * }
156
- * });
157
- * // Handle blocking impacts (e.g., prompt the user, modify the data, etc.)
158
- * }
159
- * ```
160
- *
161
- * ## Supported Deletion Scenarios
162
- *
163
- * The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain object types:
164
- *
165
- * - **Namespaces (`DataNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,
166
- * data models, entities, properties, and associations.
167
- * - **Data Models (`DataModelKind`):** Deleting a data model impacts all its entities, properties, and associations.
168
- * - **Entities (`DataEntityKind`):** Deleting an entity impacts its properties, associations, and any other
169
- * entities that have it as a parent or target in an association.
170
- * - **Properties (`DataPropertyKind`):** Deleting a property impacts the entity it belongs to.
171
- * - **Associations (`DataAssociationKind`):** Deleting an association impacts the entity it belongs to.
172
- *
173
- * ## Example: Deleting an Entity
174
- *
175
- * Consider the following scenario:
176
- *
177
- * - Namespace: `MyNamespace`
178
- * - Data Model: `ProductModel`
179
- * - Entity: `Product`
180
- * - Property: `name`
181
- * - Association: `category` (targets `Category` entity)
182
- * - Entity: `Category`
183
- * - Property: `name`
184
- * - Entity: `SpecialProduct` (parent: `Product`)
185
- *
186
- * If you attempt to delete the `Product` entity, the `DomainImpactAnalysis` will generate a report similar to this:
187
- *
188
- * ```json
189
- * {
190
- * "key": "Product",
191
- * "kind": "DataEntityKind",
192
- * "impact": [
193
- * {
194
- * "key": "Product",
195
- * "kind": "DataEntityKind",
196
- * "type": "delete",
197
- * "impact": "The entity with key Product will be deleted.",
198
- * "blocking": false
199
- * },
200
- * {
201
- * "key": "SpecialProduct",
202
- * "kind": "DataEntityKind",
203
- * "type": "delete",
204
- * "impact": "The SpecialProduct entity will become an orphan because it is a child of Product.",
205
- * "resolution": "The "Product" entity will be removed as the parent of the "SpecialProduct" entity.",
206
- * "blocking": true,
207
- * "relationship": "child"
208
- * },
209
- * {
210
- * "key": "category",
211
- * "kind": "DataAssociationKind",
212
- * "type": "delete",
213
- * "impact": "The association with key category will be broken because it has a target to Product.",
214
- * "resolution": "The association with key category will be removed from Product.",
215
- * "blocking": true
216
- * },
217
- * {
218
- * "key": "name",
219
- * "kind": "DataPropertyKind",
220
- * "type": "delete",
221
- * "impact": "The property with key name will be deleted.",
222
- * "blocking": false
223
- * }
224
- * ],
225
- * "canProceed": false
226
- * }
227
- * ```
228
- *
229
- * This report indicates that:
230
- *
231
- * - The `Product` entity will be deleted.
232
- * - The `SpecialProduct` entity will become an orphan (blocking).
233
- * - The `category` association will be broken (blocking).
234
- * - The `name` property will be deleted.
235
- * - The deletion cannot proceed without addressing the blocking impacts.
236
- *
237
- * ## Types
238
- *
239
- * ### `ImpactKinds`
240
- *
241
- * - **Description:** A type alias for the kinds of data domain objects that can be analyzed.
242
- * - **Values:**
243
- * - `DataNamespaceKind`
244
- * - `DataEntityKind`
245
- * - `DataModelKind`
246
- * - `DataPropertyKind`
247
- * - `DataAssociationKind`
248
- *
249
- * ### `ImpactReport`
250
- *
251
- * - **Description:** The structure of the impact analysis report.
252
- * - **Properties:**
253
- * - `key` (`string`): The key of the object being deleted.
254
- * - `kind` (`ImpactKinds`): The kind of the object being deleted.
255
- * - `impact` (`ImpactItem[]`): The list of impacts.
256
- * - `canProceed` (`boolean`): Whether the deletion can proceed.
257
- *
258
- * ### `ImpactItem`
259
- *
260
- * - **Description:** The structure of an individual impact item.
261
- * - **Properties:**
262
- * - `key` (`string`): The key of the impacted object.
263
- * - `kind` (`string`): The kind of the impacted object.
264
- * - `type` (`'delete'`): The type of impact.
265
- * - `impact` (`string`): The impact description.
266
- * - `blocking` (`boolean`): Whether the impact is blocking.
267
- * - `relationship` (`'child'`, optional): The relationship type.
268
- * - `resolution` (`string`, optional): The resolution description.
269
- *
270
- * ## Error Handling
271
- *
272
- * The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `ImpactReport` to communicate
273
- * the results of the analysis, including any blocking impacts.
274
- *
275
- * ## Best Practices
276
- *
277
- * - **Always Analyze Before Deleting:** Before deleting any data domain object, always use `DomainImpactAnalysis`
278
- * to understand the consequences.
279
- * - **Handle Blocking Impacts:** Pay close attention to `blocking` impacts and implement appropriate
280
- * logic to handle them.
281
- * - **Inform the User:** If a deletion cannot proceed, inform the user about the blocking impacts and provide
282
- * guidance on how to resolve them.
283
- * - **Consider Forced Deletion:** In some cases, you may want to allow users to force a deletion even if there are
284
- * blocking impacts. In such cases, you should clearly communicate the risks to the user.
285
- *
286
- * ## Conclusion
287
- *
288
- * The `DomainImpactAnalysis` class is an essential tool for maintaining data integrity when working with complex
289
- * data domain models. By providing detailed impact reports, it empowers developers to make informed decisions
290
- * about data deletion and prevent unintended consequences.
291
- * @deprecated
292
- */
293
- export class DataImpactAnalysis {
294
- private report: DataImpactReport
295
- private root: DataNamespace
296
-
297
- constructor(root: DataNamespace) {
298
- this.root = root
299
- this.report = {
300
- key: '',
301
- kind: DataNamespaceKind,
302
- impact: [],
303
- canProceed: false,
304
- }
305
- }
306
-
307
- /**
308
- * Generates a report of how the data domain will be impacted by the deletion of a data domain object.
309
- * @param key The key of the impacted data domain object.
310
- * @param kind The kind of the impacted data object.
311
- * @returns The delete impact analysis report.
312
- * @deprecated
313
- */
314
- deleteAnalysis(key: string, kind: DataImpactKinds): DataImpactReport {
315
- this.report = {
316
- key,
317
- kind,
318
- impact: [],
319
- canProceed: true,
320
- }
321
- this.report.impact = this.createDeleteImpact(key, kind, key)
322
- // this.report.impact.unshift({
323
- // key,
324
- // kind,
325
- // type: 'delete',
326
- // impact: `The ${this.kindToLabel(kind)} with key ${key} will be deleted.`,
327
- // blocking: false,
328
- // })
329
- return this.report
330
- }
331
-
332
- protected createDeleteImpact(key: string, kind: DataImpactKinds, rootKey: string): DataImpactItem[] {
333
- switch (kind) {
334
- case DataNamespaceKind:
335
- return this.deleteNamespaceAnalysis(key, rootKey)
336
- case DataModelKind:
337
- return this.deleteDataModelAnalysis(key, rootKey)
338
- case DataEntityKind:
339
- return this.deleteEntityAnalysis(key, rootKey)
340
- case DataPropertyKind:
341
- return this.deletePropertyAnalysis(key)
342
- case DataAssociationKind:
343
- return this.deleteAssociationAnalysis(key)
344
- default:
345
- return []
346
- }
347
- }
348
-
349
- protected deleteNamespaceAnalysis(key: string, rootKey: string): DataImpactItem[] {
350
- const result: DataImpactItem[] = []
351
- const ns = this.root.findNamespace(key)
352
- if (!ns) {
353
- return result
354
- }
355
- result.push({
356
- key: ns.key,
357
- kind: ns.kind,
358
- type: 'delete',
359
- impact: `The ${ns.info.getLabel()} ${this.kindToLabel(DataNamespaceKind)} will be deleted.`,
360
- blocking: false,
361
- })
362
- const namespaces = ns.listNamespaces()
363
- namespaces.forEach((child) => {
364
- const items = this.deleteNamespaceAnalysis(child.key, rootKey)
365
- result.push(...items)
366
- })
367
- const models = ns.listDataModels()
368
- models.forEach((child) => {
369
- const items = this.deleteDataModelAnalysis(child.key, rootKey)
370
- result.push(...items)
371
- })
372
- return result
373
- }
374
-
375
- protected deleteDataModelAnalysis(key: string, rootKey: string): DataImpactItem[] {
376
- const result: DataImpactItem[] = []
377
- const model = this.root.findDataModel(key)
378
- if (!model) {
379
- return result
380
- }
381
- result.push({
382
- key: model.key,
383
- kind: model.kind,
384
- type: 'delete',
385
- impact: `The ${model.info.getLabel()} ${this.kindToLabel(DataModelKind)} will be deleted.`,
386
- blocking: false,
387
- })
388
- model.entities.forEach((child) => {
389
- const items = this.deleteEntityAnalysis(child.key, rootKey)
390
- result.push(...items)
391
- })
392
- return result
393
- }
394
-
395
- protected deleteEntityAnalysis(key: string, rootKey: string): DataImpactItem[] {
396
- const result: DataImpactItem[] = []
397
- const entity = this.root.findEntity(key)
398
- if (!entity) {
399
- return result
400
- }
401
- result.push({
402
- key: entity.key,
403
- kind: entity.kind,
404
- type: 'delete',
405
- impact: `The ${entity.info.getLabel()} ${this.kindToLabel(DataEntityKind)} will be deleted.`,
406
- blocking: false,
407
- })
408
- // We need to know whether the entity is a parent of another entity
409
- const children = this.root.definitions.entities.filter((domainEntity) => {
410
- if (domainEntity.key === entity.key) {
411
- // ignore self
412
- return false
413
- }
414
- if (!domainEntity.parents.includes(entity.key)) {
415
- // no relationship
416
- return false
417
- }
418
- if (domainEntity.isChildOf(rootKey)) {
419
- // No need to include this parent as it itself is being deleted
420
- return false
421
- }
422
- // the entity has a parent-child relationship to the deleted entity.
423
- return true
424
- })
425
- if (children.length) {
426
- children.forEach((child) => {
427
- const pLabel = entity.info.getLabel()
428
- const cLabel = child.info.getLabel()
429
- result.push({
430
- key: child.key,
431
- kind: child.kind,
432
- type: 'delete',
433
- impact: `The "${cLabel}" ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
434
- resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
435
- blocking: true,
436
- relationship: 'child',
437
- })
438
- })
439
- this.report.canProceed = false
440
- }
441
- // We need to know whether there's another entity that has an association to this entity.
442
- const inAssociations = this.root.definitions.associations.filter((association) => {
443
- return association.targets.some((item) => {
444
- if (item.key === entity.key) {
445
- const related = association.getParentInstance()
446
- if (!related) {
447
- return false
448
- }
449
- if (related.isChildOf(rootKey)) {
450
- // No need to include this association as the related entity itself is being deleted
451
- return false
452
- }
453
- return true
454
- }
455
- return false
456
- })
457
- })
458
- if (inAssociations.length) {
459
- inAssociations.forEach((association) => {
460
- result.push({
461
- key: association.key,
462
- kind: association.kind,
463
- type: 'delete',
464
- impact: `The ${association.info.getLabel()} ${this.kindToLabel(DataAssociationKind)} will be broken because it has a target to ${entity.info.getLabel()}.`,
465
- resolution: `The ${association.info.getLabel()} ${this.kindToLabel(DataAssociationKind)} will be removed from ${entity.info.getLabel()}.`,
466
- blocking: true,
467
- })
468
- })
469
- this.report.canProceed = false
470
- }
471
- entity.properties.forEach((child) => {
472
- const items = this.deletePropertyAnalysis(child.key)
473
- result.push(...items)
474
- })
475
- entity.associations.forEach((child) => {
476
- const items = this.deleteAssociationAnalysis(child.key)
477
- result.push(...items)
478
- })
479
- return result
480
- }
481
-
482
- protected deletePropertyAnalysis(key: string): DataImpactItem[] {
483
- const result: DataImpactItem[] = []
484
- const property = this.root.findProperty(key)
485
- if (!property) {
486
- return result
487
- }
488
- result.push({
489
- key: property.key,
490
- kind: property.kind,
491
- type: 'delete',
492
- impact: `The ${property.info.getLabel()} ${this.kindToLabel(DataPropertyKind)} will be deleted.`,
493
- blocking: false,
494
- })
495
- return result
496
- }
497
-
498
- protected deleteAssociationAnalysis(key: string): DataImpactItem[] {
499
- const result: DataImpactItem[] = []
500
- const association = this.root.findAssociation(key)
501
- if (!association) {
502
- return result
503
- }
504
- result.push({
505
- key: association.key,
506
- kind: association.kind,
507
- type: 'delete',
508
- impact: `The ${association.info.getLabel()} ${this.kindToLabel(DataAssociationKind)} will be deleted.`,
509
- blocking: false,
510
- })
511
- return result
512
- }
513
-
514
- protected kindToLabel(kind: DataImpactKinds): string {
515
- switch (kind) {
516
- case DataNamespaceKind:
517
- return 'namespace'
518
- case DataEntityKind:
519
- return 'entity'
520
- case DataModelKind:
521
- return 'data model'
522
- case DataPropertyKind:
523
- return 'property'
524
- case DataAssociationKind:
525
- return 'association'
526
- default:
527
- return 'unknown'
528
- }
529
- }
530
- }