@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
@@ -0,0 +1,530 @@
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
+ }
@@ -1,16 +1,17 @@
1
- import { IThing, Thing } from '../models/Thing.js'
2
- import v4 from '../lib/uuid.js'
1
+ import { IThing, Thing } from '../../models/Thing.js'
2
+ import v4 from '../../lib/uuid.js'
3
3
  import { DataEntity, IDataEntity } from './DataEntity.js'
4
4
  import type { DataItemAdaptingOptions, DataNamespace } from './DataNamespace.js'
5
- import { FileBreadcrumb } from '../models/store/File.js'
6
- import { DataModelKind } from '../models/kinds.js'
7
- import type { DataDomainRemoveOptions } from './types.js'
5
+ import { FileBreadcrumb } from '../../models/store/File.js'
6
+ import { DataModelKind } from '../../models/kinds.js'
7
+ import type { DataDomainRemoveOptions } from '../types.js'
8
8
 
9
9
  /**
10
10
  * Data model creates a logical structure around data entities.
11
11
  * It groups entities that represents a whole schema, like a Product data model
12
12
  * can have entities that describe: the product entity, price history entity,
13
13
  * product location, etc.
14
+ * @deprecated
14
15
  */
15
16
  export interface IDataModel {
16
17
  kind: typeof DataModelKind
@@ -33,6 +34,7 @@ export interface IDataModel {
33
34
  * It groups entities that represents a whole schema, like a Product data model
34
35
  * can have entities that describe: the product entity, price history entity,
35
36
  * product location, etc.
37
+ * @deprecated
36
38
  */
37
39
  export class DataModel {
38
40
  kind = DataModelKind
@@ -231,7 +233,7 @@ export class DataModel {
231
233
  const result: FileBreadcrumb[] = []
232
234
  result.push({
233
235
  key: this.key,
234
- name: this.info.name || 'Unnamed data model',
236
+ name: this.info.getLabel('Unnamed data model'),
235
237
  kind: DataModelKind,
236
238
  })
237
239
  let parent = this.getParentInstance()
@@ -239,13 +241,13 @@ export class DataModel {
239
241
  result.push({
240
242
  key: parent.key,
241
243
  kind: parent.kind,
242
- name: parent.info.name || 'Unnamed namespace',
244
+ name: parent.info.getLabel('Unnamed namespace'),
243
245
  })
244
246
  parent = parent.getParentInstance()
245
247
  }
246
248
  result.push({
247
249
  key: this.root.key,
248
- name: this.root.info.name || 'Unnamed namespace',
250
+ name: this.root.info.getLabel('Unnamed data domain'),
249
251
  kind: this.root.kind,
250
252
  })
251
253
  return result.reverse()
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-this-alias */
2
- import { IThing, Thing } from '../models/Thing.js'
2
+ import { IThing, Thing } from '../../models/Thing.js'
3
3
  import { IDataAssociation, DataAssociation, AssociationTarget } from './DataAssociation.js'
4
4
  import { IDataEntity, DataEntity } from './DataEntity.js'
5
5
  import { IDataModel, DataModel } from './DataModel.js'
@@ -10,19 +10,27 @@ import {
10
10
  DataEntityKind,
11
11
  DataPropertyKind,
12
12
  DataAssociationKind,
13
- } from '../models/kinds.js'
14
- import v4 from '../lib/uuid.js'
15
- import type { DataDomainRemoveOptions } from './types.js'
13
+ } from '../../models/kinds.js'
14
+ import v4 from '../../lib/uuid.js'
15
+ import type { DataDomainRemoveOptions } from '../types.js'
16
16
 
17
+ /**
18
+ * @deprecated
19
+ */
17
20
  type ItemKind = typeof DataNamespaceKind | typeof DataModelKind
18
21
 
22
+ /**
23
+ * @deprecated
24
+ */
19
25
  export interface DataItemAdaptingOptions {
20
26
  /**
21
27
  * The index at which to adapt the item.
22
28
  */
23
29
  index?: number
24
30
  }
25
-
31
+ /**
32
+ * @deprecated
33
+ */
26
34
  interface IDataDefinitions {
27
35
  models?: IDataModel[]
28
36
  entities?: IDataEntity[]
@@ -36,6 +44,9 @@ interface IDataDefinitions {
36
44
  foreign?: ForeignNamespace[]
37
45
  }
38
46
 
47
+ /**
48
+ * @deprecated
49
+ */
39
50
  interface DataDefinitions {
40
51
  models: DataModel[]
41
52
  // @todo: This should be a map of entities with a key of the entity key.
@@ -61,6 +72,7 @@ interface DataDefinitions {
61
72
  * Each foreign namespace is resolved to a specific version.
62
73
  * This makes sure that the local data are always referencing an existing
63
74
  * entity as breaking changes should be resolved when upgrading a version.
75
+ * @deprecated
64
76
  */
65
77
  interface ForeignNamespace {
66
78
  key: string
@@ -69,6 +81,7 @@ interface ForeignNamespace {
69
81
 
70
82
  /**
71
83
  * Data namespace is a logical description of the hierarchy in the data.
84
+ * @deprecated
72
85
  */
73
86
  export interface IDataNamespace {
74
87
  kind: typeof DataNamespaceKind
@@ -93,6 +106,7 @@ export interface IDataNamespace {
93
106
  /**
94
107
  * Data item is a reference to an object in the top namespace definitions
95
108
  * to the namespace items.
109
+ * @deprecated
96
110
  */
97
111
  export interface IDataItem {
98
112
  /**
@@ -105,6 +119,9 @@ export interface IDataItem {
105
119
  key: string
106
120
  }
107
121
 
122
+ /**
123
+ * @deprecated
124
+ */
108
125
  export class DataItem implements IDataItem {
109
126
  kind: ItemKind = DataModelKind
110
127
 
@@ -187,6 +204,7 @@ export class DataItem implements IDataItem {
187
204
 
188
205
  /**
189
206
  * Data namespace is a logical description of the hierarchy in the data.
207
+ * @deprecated
190
208
  */
191
209
  export class DataNamespace {
192
210
  kind = DataNamespaceKind