@api-client/core 0.14.10 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE.md +163 -0
- package/RELEASE_SETUP.md +235 -0
- package/build/src/events/authorization/AuthorizationEvents.d.ts +1 -1
- package/build/src/events/authorization/AuthorizationEvents.d.ts.map +1 -1
- package/build/src/events/authorization/AuthorizationEvents.js +1 -1
- package/build/src/events/authorization/AuthorizationEvents.js.map +1 -1
- package/build/src/events/cookies/CookieEvents.d.ts +1 -1
- package/build/src/events/cookies/CookieEvents.d.ts.map +1 -1
- package/build/src/events/cookies/CookieEvents.js +1 -1
- package/build/src/events/cookies/CookieEvents.js.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts +22 -119
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +49 -155
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainValidation.d.ts +8 -0
- package/build/src/modeling/DomainValidation.d.ts.map +1 -0
- package/build/src/modeling/DomainValidation.js +99 -0
- package/build/src/modeling/DomainValidation.js.map +1 -0
- package/build/src/modeling/types.d.ts +70 -0
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/modeling/validation/rules.d.ts +2 -3
- package/build/src/modeling/validation/rules.d.ts.map +1 -1
- package/build/src/modeling/validation/rules.js.map +1 -1
- package/build/src/modeling/validation/semantic_validation.d.ts +31 -0
- package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -0
- package/build/src/modeling/validation/semantic_validation.js +126 -0
- package/build/src/modeling/validation/semantic_validation.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +6 -6
- package/noop.ts +3 -0
- package/package.json +9 -4
- package/src/events/authorization/AuthorizationEvents.ts +1 -1
- package/src/events/cookies/CookieEvents.ts +1 -1
- package/src/modeling/DomainImpactAnalysis.ts +54 -239
- package/src/modeling/DomainValidation.ts +105 -0
- package/src/modeling/types.ts +86 -0
- package/src/modeling/validation/rules.ts +2 -4
- package/src/modeling/validation/semantic_validation.ts +145 -0
- package/tests/unit/events/EventsTestHelpers.ts +16 -0
- package/tests/unit/events/amf.spec.ts +151 -0
- package/tests/unit/events/authorization.spec.ts +150 -0
- package/tests/unit/events/cookie.spec.ts +274 -0
- package/tests/unit/events/encryption.spec.ts +108 -0
- package/tests/unit/events/events_polyfills.ts +77 -0
- package/tests/unit/events/process.spec.ts +120 -0
- package/tests/unit/events/reporting.spec.ts +82 -0
- package/tests/unit/events/telemetry.spec.ts +224 -0
- package/tests/unit/events/transport.spec.ts +139 -0
- package/tests/unit/modeling/domain_impact_analysis.spec.ts +0 -110
- package/tests/unit/modeling/domain_validation.spec.ts +94 -0
- package/tests/unit/modeling/validation/semantic_validation.spec.ts +91 -0
- package/tests/unit/models/environment.spec.ts +574 -0
- package/tests/unit/models/error_response.spec.ts +183 -0
- package/tests/unit/models/headers_array.spec.ts +86 -0
- package/tests/unit/models/http-actions/assertion/equal_assertion.spec.ts +103 -0
- package/tests/unit/models/http-actions/assertion/greater_than_assertion.spec.ts +91 -0
- package/tests/unit/models/http-actions/assertion/includes_assertion.spec.ts +71 -0
- package/tests/unit/models/http-actions/assertion/less_than_assertion.spec.ts +91 -0
- package/tests/unit/models/http-actions/assertion/matches_assertion.spec.ts +71 -0
- package/tests/unit/models/http-actions/assertion/matches_schema_assertion.spec.ts +117 -0
- package/tests/unit/models/http-actions/assertion/not_equal_assertion.spec.ts +103 -0
- package/tests/unit/models/http-actions/assertion/not_includes_assertion.spec.ts +71 -0
- package/tests/unit/models/http-actions/assertion/not_ok_assertion.spec.ts +47 -0
- package/tests/unit/models/http-actions/assertion/not_to_be_assertion.spec.ts +72 -0
- package/tests/unit/models/http-actions/assertion/ok_assertion.spec.ts +44 -0
- package/tests/unit/models/http-actions/assertion/to_be_assertion.spec.ts +71 -0
- package/tests/unit/models/http-actions/transformation/as_lower_case_step.spec.ts +47 -0
- package/tests/unit/models/http-actions/transformation/as_number_step.spec.ts +47 -0
- package/tests/unit/models/http-actions/transformation/as_upper_case_step.spec.ts +47 -0
- package/tests/unit/models/http-actions/transformation/round_step.spec.ts +69 -0
- package/tests/unit/models/http-actions/transformation/substring_step.spec.ts +85 -0
- package/tests/unit/models/http-actions/transformation/trim_step.spec.ts +44 -0
- package/tests/unit/models/http_cookie.spec.ts +516 -0
- package/tests/unit/models/http_history.spec.ts +443 -0
- package/tests/unit/models/project_folder.spec.ts +926 -0
- package/tests/unit/models/project_item.spec.ts +137 -0
- package/tests/unit/models/project_request.spec.ts +1047 -0
- package/tests/unit/models/project_schema.spec.ts +236 -0
- package/tests/unit/models/property.spec.ts +625 -0
- package/tests/unit/models/provider.spec.ts +102 -0
- package/tests/unit/models/request.spec.ts +1206 -0
- package/tests/unit/models/request_log.spec.ts +308 -0
- package/tests/unit/models/request_time.spec.ts +138 -0
- package/tests/unit/models/response_redirect.spec.ts +303 -0
- package/tests/unit/models/sent_request.spec.ts +206 -0
- package/tests/unit/models/server.spec.ts +195 -0
- package/tests/unit/models/thing.spec.ts +154 -0
- package/build/oauth-popup.html +0 -33
- /package/tests/unit/models/{Certificate.spec.ts → certificate.spec.ts} +0 -0
- /package/tests/unit/models/{HostRule.spec.ts → host_rule.spec.ts} +0 -0
- /package/tests/unit/models/{HttpProject.spec.ts → http_project.spec.ts} +0 -0
- /package/tests/unit/models/{HttpRequest.spec.ts → http_request.spec.ts} +0 -0
- /package/tests/unit/models/{HttpResponse.spec.ts → http_response.spec.ts} +0 -0
- /package/tests/unit/models/{License.spec.ts → license.spec.ts} +0 -0
- /package/tests/unit/models/{Response.spec.ts → response.spec.ts} +0 -0
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { DomainNamespaceKind, DomainEntityKind, DomainModelKind, DomainPropertyKind, DomainAssociationKind,
|
|
2
|
-
import { AssociationValidation } from './validation/association_validation.js';
|
|
3
|
-
import { EntityValidation } from './validation/entity_validation.js';
|
|
4
|
-
import { PropertyValidation } from './validation/property_validation.js';
|
|
1
|
+
import { DomainNamespaceKind, DomainEntityKind, DomainModelKind, DomainPropertyKind, DomainAssociationKind, } from '../models/kinds.js';
|
|
5
2
|
/**
|
|
6
3
|
* # DomainImpactAnalysis
|
|
7
4
|
*
|
|
@@ -23,13 +20,13 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
23
20
|
* - `kind`: The kind of the impacted object.
|
|
24
21
|
* - `type`: The type of impact (currently only `delete`).
|
|
25
22
|
* - `impact`: A human-readable description of the impact.
|
|
26
|
-
* - `blocking`: Whether this impact prevents the deletion from proceeding.
|
|
27
23
|
* - `relationship`: The type of relationship between the deleted object and the impacted object (e.g., `child`).
|
|
28
24
|
* - `resolution`: A description of how the impact will be resolved if the deletion is forced.
|
|
25
|
+
* - `severity`: The severity of the impact, which can be `info`, `warning`, or `error`.
|
|
29
26
|
*
|
|
30
27
|
* - **Blocking Impacts:** Some impacts are considered "blocking," meaning they prevent the deletion from proceeding
|
|
31
28
|
* without manual intervention. For example, deleting an entity that is a parent to other entities is
|
|
32
|
-
* a blocking impact.
|
|
29
|
+
* a blocking impact. Blocking impacts are indicated by the `severity` property set to `error`.
|
|
33
30
|
*
|
|
34
31
|
* - **Non-Blocking Impacts:** Some impacts are informational and do not prevent the deletion. For example, deleting a
|
|
35
32
|
* property is not a blocking impact.
|
|
@@ -61,7 +58,7 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
61
58
|
* 3. **Interpreting the Report:** Examine the `DomainImpactReport` to understand the consequences of the deletion.
|
|
62
59
|
* - Check `report.canProceed` to see if the deletion is safe.
|
|
63
60
|
* - Iterate through `report.impact` to understand each consequence.
|
|
64
|
-
* - Pay special attention to `impact.
|
|
61
|
+
* - Pay special attention to `impact.severity` to identify impacts that require manual resolution.
|
|
65
62
|
*
|
|
66
63
|
* ```typescript
|
|
67
64
|
* if (report.canProceed) {
|
|
@@ -70,7 +67,7 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
70
67
|
* console.warn('Deletion cannot proceed due to the following impacts:');
|
|
71
68
|
* report.impact.forEach((item) => {
|
|
72
69
|
* console.warn(`- ${item.impact}`);
|
|
73
|
-
* if (item.
|
|
70
|
+
* if (item.severity === 'error') {
|
|
74
71
|
* console.warn(` - This impact is blocking.`);
|
|
75
72
|
* if (item.resolution) {
|
|
76
73
|
* console.warn(` - Resolution: ${item.resolution}`);
|
|
@@ -122,7 +119,7 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
122
119
|
* "kind": "DomainEntityKind",
|
|
123
120
|
* "type": "delete",
|
|
124
121
|
* "impact": "The entity with key Product will be deleted.",
|
|
125
|
-
* "
|
|
122
|
+
* "severity": "warning"
|
|
126
123
|
* },
|
|
127
124
|
* {
|
|
128
125
|
* "key": "SpecialProduct",
|
|
@@ -130,7 +127,7 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
130
127
|
* "type": "delete",
|
|
131
128
|
* "impact": "The SpecialProduct entity will become an orphan because it is a child of Product.",
|
|
132
129
|
* "resolution": "The \"Product\" entity will be removed as the parent of the \"SpecialProduct\" entity.",
|
|
133
|
-
* "
|
|
130
|
+
* "severity": "error",
|
|
134
131
|
* "relationship": "child"
|
|
135
132
|
* },
|
|
136
133
|
* {
|
|
@@ -139,14 +136,14 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
139
136
|
* "type": "delete",
|
|
140
137
|
* "impact": "The association with key category will be broken because it has a target to Product.",
|
|
141
138
|
* "resolution": "The association with key category will be removed from Product.",
|
|
142
|
-
* "
|
|
139
|
+
* "severity": "error"
|
|
143
140
|
* },
|
|
144
141
|
* {
|
|
145
142
|
* "key": "name",
|
|
146
143
|
* "kind": "DomainPropertyKind",
|
|
147
144
|
* "type": "delete",
|
|
148
145
|
* "impact": "The property with key name will be deleted.",
|
|
149
|
-
* "
|
|
146
|
+
* "severity": "info"
|
|
150
147
|
* }
|
|
151
148
|
* ],
|
|
152
149
|
* "canProceed": false
|
|
@@ -174,27 +171,6 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
174
171
|
* - `DomainAssociationKind`
|
|
175
172
|
* - `DataDomainKind`
|
|
176
173
|
*
|
|
177
|
-
* ### `DomainImpactReport`
|
|
178
|
-
*
|
|
179
|
-
* - **Description:** The structure of the impact analysis report.
|
|
180
|
-
* - **Properties:**
|
|
181
|
-
* - `key` (`string`): The key of the object being deleted.
|
|
182
|
-
* - `kind` (`DomainImpactKinds`): The kind of the object being deleted.
|
|
183
|
-
* - `impact` (`DomainImpactItem[]`): The list of impacts.
|
|
184
|
-
* - `canProceed` (`boolean`): Whether the deletion can proceed.
|
|
185
|
-
*
|
|
186
|
-
* ### `DomainImpactItem`
|
|
187
|
-
*
|
|
188
|
-
* - **Description:** The structure of an individual impact item.
|
|
189
|
-
* - **Properties:**
|
|
190
|
-
* - `key` (`string`): The key of the impacted object.
|
|
191
|
-
* - `kind` (`string`): The kind of the impacted object.
|
|
192
|
-
* - `type` (`'delete'`): The type of impact.
|
|
193
|
-
* - `impact` (`string`): The impact description.
|
|
194
|
-
* - `blocking` (`boolean`): Whether the impact is blocking.
|
|
195
|
-
* - `relationship` (`'child'`, optional): The relationship type.
|
|
196
|
-
* - `resolution` (`string`, optional): The resolution description.
|
|
197
|
-
*
|
|
198
174
|
* ## Error Handling
|
|
199
175
|
*
|
|
200
176
|
* The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `DomainImpactReport` to communicate
|
|
@@ -204,7 +180,7 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
204
180
|
*
|
|
205
181
|
* - **Always Analyze Before Deleting:** Before deleting any data domain element, always use `DomainImpactAnalysis`
|
|
206
182
|
* to understand the consequences.
|
|
207
|
-
* - **Handle Blocking Impacts:** Pay close attention to `
|
|
183
|
+
* - **Handle Blocking Impacts:** Pay close attention to `severity = "error"` impacts and implement appropriate
|
|
208
184
|
* logic to handle them.
|
|
209
185
|
* - **Inform the User:** If a deletion cannot proceed, inform the user about the blocking impacts and provide
|
|
210
186
|
* guidance on how to resolve them.
|
|
@@ -218,16 +194,9 @@ import { PropertyValidation } from './validation/property_validation.js';
|
|
|
218
194
|
* about data deletion and prevent unintended consequences.
|
|
219
195
|
*/
|
|
220
196
|
export class DomainImpactAnalysis {
|
|
221
|
-
report;
|
|
222
197
|
root;
|
|
223
198
|
constructor(root) {
|
|
224
199
|
this.root = root;
|
|
225
|
-
this.report = {
|
|
226
|
-
key: '',
|
|
227
|
-
kind: DataDomainKind,
|
|
228
|
-
impact: [],
|
|
229
|
-
canProceed: false,
|
|
230
|
-
};
|
|
231
200
|
}
|
|
232
201
|
/**
|
|
233
202
|
* Generates a report of how the data domain will be impacted by the deletion of a data domain object.
|
|
@@ -236,14 +205,15 @@ export class DomainImpactAnalysis {
|
|
|
236
205
|
* @returns The delete impact analysis report.
|
|
237
206
|
*/
|
|
238
207
|
deleteAnalysis(key, kind) {
|
|
239
|
-
|
|
208
|
+
const report = {
|
|
240
209
|
key,
|
|
241
210
|
kind,
|
|
242
211
|
impact: [],
|
|
243
212
|
canProceed: true,
|
|
244
213
|
};
|
|
245
|
-
this.createDeleteImpact(key, kind, key);
|
|
246
|
-
|
|
214
|
+
this.createDeleteImpact(key, kind, key, report.impact);
|
|
215
|
+
report.canProceed = this.computeCanProceed(report.impact);
|
|
216
|
+
return report;
|
|
247
217
|
}
|
|
248
218
|
/**
|
|
249
219
|
* Generates a report of how the data domain will be impacted by the removal of a foreign namespace.
|
|
@@ -251,156 +221,90 @@ export class DomainImpactAnalysis {
|
|
|
251
221
|
* @returns The delete impact analysis report.
|
|
252
222
|
*/
|
|
253
223
|
removeForeignNamespaceAnalysis(key) {
|
|
254
|
-
|
|
224
|
+
const report = {
|
|
255
225
|
key,
|
|
256
226
|
kind: DomainNamespaceKind,
|
|
257
227
|
impact: [],
|
|
258
228
|
canProceed: true,
|
|
259
229
|
};
|
|
260
|
-
this.createRemoveForeignNamespaceImpact(key);
|
|
261
|
-
|
|
230
|
+
this.createRemoveForeignNamespaceImpact(key, report.impact);
|
|
231
|
+
report.canProceed = this.computeCanProceed(report.impact);
|
|
232
|
+
return report;
|
|
262
233
|
}
|
|
263
234
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* @returns
|
|
235
|
+
* Computes whether the deletion can proceed based on the impact report.
|
|
236
|
+
* @param impact The list of impacts from the analysis.
|
|
237
|
+
* @returns `true` if the deletion can proceed, `false` otherwise.
|
|
267
238
|
*/
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
key: '',
|
|
271
|
-
kind: DataDomainKind,
|
|
272
|
-
impact: [],
|
|
273
|
-
canProceed: true,
|
|
274
|
-
};
|
|
275
|
-
const entityValidator = new EntityValidation(this.root);
|
|
276
|
-
const propertyValidator = new PropertyValidation(this.root);
|
|
277
|
-
const associationValidator = new AssociationValidation(this.root);
|
|
278
|
-
for (const entity of this.root.listEntities()) {
|
|
279
|
-
if (entity.domain.key !== this.root.key) {
|
|
280
|
-
// we don't need to validate foreign entities
|
|
281
|
-
continue;
|
|
282
|
-
}
|
|
283
|
-
const report = entityValidator.validate(entity);
|
|
284
|
-
for (const item of report) {
|
|
285
|
-
const blocking = item.severity === 'error';
|
|
286
|
-
this.report.canProceed = this.report.canProceed && !blocking;
|
|
287
|
-
this.report.impact.push({
|
|
288
|
-
key: item.key,
|
|
289
|
-
kind: item.kind,
|
|
290
|
-
type: 'publish',
|
|
291
|
-
impact: item.message,
|
|
292
|
-
blocking,
|
|
293
|
-
resolution: item.help,
|
|
294
|
-
severity: item.severity,
|
|
295
|
-
parent: item.parent,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
for (const property of entity.properties) {
|
|
299
|
-
const report = propertyValidator.validate(property);
|
|
300
|
-
for (const item of report) {
|
|
301
|
-
const blocking = item.severity === 'error';
|
|
302
|
-
this.report.canProceed = this.report.canProceed && !blocking;
|
|
303
|
-
this.report.impact.push({
|
|
304
|
-
key: item.key,
|
|
305
|
-
kind: item.kind,
|
|
306
|
-
type: 'publish',
|
|
307
|
-
impact: item.message,
|
|
308
|
-
blocking,
|
|
309
|
-
resolution: item.help,
|
|
310
|
-
severity: item.severity,
|
|
311
|
-
parent: item.parent,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
for (const association of entity.associations) {
|
|
316
|
-
const report = associationValidator.validate(association);
|
|
317
|
-
for (const item of report) {
|
|
318
|
-
const blocking = item.severity === 'error';
|
|
319
|
-
this.report.canProceed = this.report.canProceed && !blocking;
|
|
320
|
-
this.report.impact.push({
|
|
321
|
-
key: item.key,
|
|
322
|
-
kind: item.kind,
|
|
323
|
-
type: 'publish',
|
|
324
|
-
impact: item.message,
|
|
325
|
-
blocking,
|
|
326
|
-
resolution: item.help,
|
|
327
|
-
severity: item.severity,
|
|
328
|
-
parent: item.parent,
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return this.report;
|
|
239
|
+
computeCanProceed(impact) {
|
|
240
|
+
return !impact.some((item) => item.severity === 'error');
|
|
334
241
|
}
|
|
335
|
-
createDeleteImpact(key, kind, rootKey) {
|
|
242
|
+
createDeleteImpact(key, kind, rootKey, impact) {
|
|
336
243
|
switch (kind) {
|
|
337
244
|
case DomainNamespaceKind:
|
|
338
|
-
this.deleteNamespaceAnalysis(key, rootKey);
|
|
245
|
+
this.deleteNamespaceAnalysis(key, rootKey, impact);
|
|
339
246
|
break;
|
|
340
247
|
case DomainModelKind:
|
|
341
|
-
this.deleteModelAnalysis(key, rootKey);
|
|
248
|
+
this.deleteModelAnalysis(key, rootKey, impact);
|
|
342
249
|
break;
|
|
343
250
|
case DomainEntityKind:
|
|
344
|
-
this.deleteEntityAnalysis(key, rootKey);
|
|
251
|
+
this.deleteEntityAnalysis(key, rootKey, impact);
|
|
345
252
|
break;
|
|
346
253
|
case DomainPropertyKind:
|
|
347
|
-
this.deletePropertyAnalysis(key);
|
|
254
|
+
this.deletePropertyAnalysis(key, impact);
|
|
348
255
|
break;
|
|
349
256
|
case DomainAssociationKind:
|
|
350
|
-
this.deleteAssociationAnalysis(key);
|
|
257
|
+
this.deleteAssociationAnalysis(key, impact);
|
|
351
258
|
break;
|
|
352
259
|
default:
|
|
353
260
|
// ignore unknown kinds
|
|
354
261
|
}
|
|
355
262
|
}
|
|
356
|
-
deleteNamespaceAnalysis(key, rootKey) {
|
|
263
|
+
deleteNamespaceAnalysis(key, rootKey, impact) {
|
|
357
264
|
const ns = this.root.findNamespace(key);
|
|
358
265
|
if (!ns) {
|
|
359
266
|
return;
|
|
360
267
|
}
|
|
361
|
-
|
|
268
|
+
impact.push({
|
|
362
269
|
key: ns.key,
|
|
363
270
|
kind: ns.kind,
|
|
364
271
|
type: 'delete',
|
|
365
272
|
impact: `The ${ns.info.getLabel()} ${this.kindToLabel(DomainNamespaceKind)} will be deleted.`,
|
|
366
|
-
blocking: false,
|
|
367
273
|
severity: 'info',
|
|
368
274
|
});
|
|
369
275
|
for (const child of ns.listNamespaces()) {
|
|
370
|
-
this.deleteNamespaceAnalysis(child.key, rootKey);
|
|
276
|
+
this.deleteNamespaceAnalysis(child.key, rootKey, impact);
|
|
371
277
|
}
|
|
372
278
|
for (const child of ns.listModels()) {
|
|
373
|
-
this.deleteModelAnalysis(child.key, rootKey);
|
|
279
|
+
this.deleteModelAnalysis(child.key, rootKey, impact);
|
|
374
280
|
}
|
|
375
281
|
}
|
|
376
|
-
deleteModelAnalysis(key, rootKey) {
|
|
282
|
+
deleteModelAnalysis(key, rootKey, impact) {
|
|
377
283
|
const model = this.root.findModel(key);
|
|
378
284
|
if (!model) {
|
|
379
285
|
return;
|
|
380
286
|
}
|
|
381
|
-
|
|
287
|
+
impact.push({
|
|
382
288
|
key: model.key,
|
|
383
289
|
kind: model.kind,
|
|
384
290
|
type: 'delete',
|
|
385
291
|
impact: `The ${model.info.getLabel()} ${this.kindToLabel(DomainModelKind)} will be deleted.`,
|
|
386
|
-
blocking: false,
|
|
387
292
|
severity: 'info',
|
|
388
293
|
});
|
|
389
294
|
for (const child of model.listEntities()) {
|
|
390
|
-
this.deleteEntityAnalysis(child.key, rootKey);
|
|
295
|
+
this.deleteEntityAnalysis(child.key, rootKey, impact);
|
|
391
296
|
}
|
|
392
297
|
}
|
|
393
|
-
deleteEntityAnalysis(key, rootKey) {
|
|
298
|
+
deleteEntityAnalysis(key, rootKey, impact) {
|
|
394
299
|
const entity = this.root.findEntity(key);
|
|
395
300
|
if (!entity) {
|
|
396
301
|
return;
|
|
397
302
|
}
|
|
398
|
-
|
|
303
|
+
impact.push({
|
|
399
304
|
key: entity.key,
|
|
400
305
|
kind: entity.kind,
|
|
401
306
|
type: 'delete',
|
|
402
307
|
impact: `The ${entity.info.getLabel()} ${this.kindToLabel(DomainEntityKind)} will be deleted.`,
|
|
403
|
-
blocking: false,
|
|
404
308
|
severity: 'info',
|
|
405
309
|
});
|
|
406
310
|
// We need to know whether the entity is a parent of another entity
|
|
@@ -419,17 +323,15 @@ export class DomainImpactAnalysis {
|
|
|
419
323
|
}
|
|
420
324
|
const pLabel = entity.info.getLabel();
|
|
421
325
|
const cLabel = childEntity.info.getLabel();
|
|
422
|
-
|
|
326
|
+
impact.push({
|
|
423
327
|
key: childEntity.key,
|
|
424
328
|
kind: childEntity.kind,
|
|
425
329
|
type: 'delete',
|
|
426
330
|
impact: `The "${cLabel}" ${this.kindToLabel(DomainEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
|
|
427
331
|
resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
|
|
428
|
-
blocking: false,
|
|
429
332
|
relationship: 'child',
|
|
430
333
|
severity: 'error',
|
|
431
334
|
});
|
|
432
|
-
this.report.canProceed = false;
|
|
433
335
|
}
|
|
434
336
|
// We need to know whether there's another entity that has an association to this entity.
|
|
435
337
|
for (const edgeInfo of this.root.graph.inEdges(entity.key)) {
|
|
@@ -451,49 +353,45 @@ export class DomainImpactAnalysis {
|
|
|
451
353
|
}
|
|
452
354
|
const aLabel = association.info.getLabel();
|
|
453
355
|
const eLabel = entity.info.getLabel();
|
|
454
|
-
|
|
356
|
+
impact.push({
|
|
455
357
|
key: association.key,
|
|
456
358
|
kind: association.kind,
|
|
457
359
|
type: 'delete',
|
|
458
360
|
impact: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be broken because it has a target to ${eLabel}.`,
|
|
459
361
|
resolution: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be removed from ${eLabel}.`,
|
|
460
|
-
blocking: true,
|
|
461
362
|
severity: 'error',
|
|
462
363
|
});
|
|
463
|
-
this.report.canProceed = false;
|
|
464
364
|
}
|
|
465
365
|
for (const child of entity.listProperties()) {
|
|
466
|
-
this.deletePropertyAnalysis(child.key);
|
|
366
|
+
this.deletePropertyAnalysis(child.key, impact);
|
|
467
367
|
}
|
|
468
368
|
for (const child of entity.listAssociations()) {
|
|
469
|
-
this.deleteAssociationAnalysis(child.key);
|
|
369
|
+
this.deleteAssociationAnalysis(child.key, impact);
|
|
470
370
|
}
|
|
471
371
|
}
|
|
472
|
-
deletePropertyAnalysis(key) {
|
|
372
|
+
deletePropertyAnalysis(key, impact) {
|
|
473
373
|
const property = this.root.findProperty(key);
|
|
474
374
|
if (!property) {
|
|
475
375
|
return;
|
|
476
376
|
}
|
|
477
|
-
|
|
377
|
+
impact.push({
|
|
478
378
|
key: property.key,
|
|
479
379
|
kind: property.kind,
|
|
480
380
|
type: 'delete',
|
|
481
381
|
impact: `The ${property.info.getLabel()} ${this.kindToLabel(DomainPropertyKind)} will be deleted.`,
|
|
482
|
-
blocking: false,
|
|
483
382
|
severity: 'info',
|
|
484
383
|
});
|
|
485
384
|
}
|
|
486
|
-
deleteAssociationAnalysis(key) {
|
|
385
|
+
deleteAssociationAnalysis(key, impact) {
|
|
487
386
|
const association = this.root.findAssociation(key);
|
|
488
387
|
if (!association) {
|
|
489
388
|
return;
|
|
490
389
|
}
|
|
491
|
-
|
|
390
|
+
impact.push({
|
|
492
391
|
key: association.key,
|
|
493
392
|
kind: association.kind,
|
|
494
393
|
type: 'delete',
|
|
495
394
|
impact: `The ${association.info.getLabel()} ${this.kindToLabel(DomainAssociationKind)} will be deleted.`,
|
|
496
|
-
blocking: false,
|
|
497
395
|
severity: 'info',
|
|
498
396
|
});
|
|
499
397
|
}
|
|
@@ -513,7 +411,7 @@ export class DomainImpactAnalysis {
|
|
|
513
411
|
return 'unknown';
|
|
514
412
|
}
|
|
515
413
|
}
|
|
516
|
-
createRemoveForeignNamespaceImpact(key) {
|
|
414
|
+
createRemoveForeignNamespaceImpact(key, impact) {
|
|
517
415
|
const foreignNamespace = this.root.dependencies.get(key);
|
|
518
416
|
if (!foreignNamespace) {
|
|
519
417
|
return;
|
|
@@ -533,17 +431,15 @@ export class DomainImpactAnalysis {
|
|
|
533
431
|
}
|
|
534
432
|
const eLabel = entity.info.getLabel();
|
|
535
433
|
const pLabel = parentEntity.info.getLabel();
|
|
536
|
-
|
|
434
|
+
impact.push({
|
|
537
435
|
key: entity.key,
|
|
538
436
|
kind: entity.kind,
|
|
539
437
|
type: 'delete',
|
|
540
438
|
impact: `The "${eLabel}" ${this.kindToLabel(DomainEntityKind)} will become an orphan because its parent "${pLabel}" is in the foreign namespace "${foreignNamespace.key}".`,
|
|
541
439
|
resolution: `The "${pLabel}" entity will be removed as the parent of the "${eLabel}" entity.`,
|
|
542
|
-
blocking: true,
|
|
543
440
|
relationship: 'child',
|
|
544
441
|
severity: 'error',
|
|
545
442
|
});
|
|
546
|
-
this.report.canProceed = false;
|
|
547
443
|
}
|
|
548
444
|
else if (edge.type === 'association') {
|
|
549
445
|
const association = this.root.findAssociation(info.w);
|
|
@@ -560,16 +456,14 @@ export class DomainImpactAnalysis {
|
|
|
560
456
|
const aLabel = association.info.getLabel();
|
|
561
457
|
const eLabel = entity.info.getLabel();
|
|
562
458
|
const tLabel = targetEntity.info.getLabel();
|
|
563
|
-
|
|
459
|
+
impact.push({
|
|
564
460
|
key: association.key,
|
|
565
461
|
kind: association.kind,
|
|
566
462
|
type: 'delete',
|
|
567
463
|
impact: `The "${aLabel}" ${this.kindToLabel(DomainAssociationKind)} from "${eLabel}" will be broken because it targets "${tLabel}" in the foreign namespace "${foreignNamespace.key}".`,
|
|
568
464
|
resolution: `The "${aLabel}" ${this.kindToLabel(DomainAssociationKind)} will be removed from "${eLabel}".`,
|
|
569
|
-
blocking: true,
|
|
570
465
|
severity: 'error',
|
|
571
466
|
});
|
|
572
|
-
this.report.canProceed = false;
|
|
573
467
|
}
|
|
574
468
|
}
|
|
575
469
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainImpactAnalysis.js","sourceRoot":"","sources":["../../../src/modeling/DomainImpactAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,GACf,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAsFxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsNG;AACH,MAAM,OAAO,oBAAoB;IACvB,MAAM,CAAoB;IAC1B,IAAI,CAAY;IAExB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG;YACZ,GAA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IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gCACtB,GAAG,EAAE,WAAW,CAAC,GAAG;gCACpB,IAAI,EAAE,WAAW,CAAC,IAAI;gCACtB,IAAI,EAAE,QAAQ;gCACd,MAAM,EAAE,QAAQ,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,UAAU,MAAM,wCAAwC,MAAM,+BAA+B,gBAAgB,CAAC,GAAG,IAAI;gCACvL,UAAU,EAAE,QAAQ,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,0BAA0B,MAAM,IAAI;gCAC1G,QAAQ,EAAE,IAAI;gCACd,QAAQ,EAAE,OAAO;6BAClB,CAAC,CAAA;4BACF,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,KAAK,CAAA;wBAChC,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n DomainNamespaceKind,\n DomainEntityKind,\n DomainModelKind,\n DomainPropertyKind,\n DomainAssociationKind,\n DataDomainKind,\n} from '../models/kinds.js'\nimport type { DataDomain } from './DataDomain.js'\nimport { AssociationValidation } from './validation/association_validation.js'\nimport { EntityValidation } from './validation/entity_validation.js'\nimport { PropertyValidation } from './validation/property_validation.js'\n\nexport type DomainImpactKinds =\n | typeof DomainNamespaceKind\n | typeof DomainEntityKind\n | typeof DomainModelKind\n | typeof DomainPropertyKind\n | typeof DomainAssociationKind\n | typeof DataDomainKind\n\n/**\n * The impact analysis report\n */\nexport interface DomainImpactReport {\n /**\n * The key of the impacted data object.\n * This is the key of the object that is being changed.\n */\n key: string\n /**\n * The kind of the impacted data object.\n * This is the kind of the object that is being changed.\n */\n kind: DomainImpactKinds\n /**\n * The list of impacted data objects.\n */\n impact: DomainImpactItem[]\n /**\n * Whether it is possible to proceed with the change.\n * If the change is not possible, the reason will be in the impact list.\n */\n canProceed: boolean\n}\n\nexport interface DomainImpactItem {\n /**\n * The key of the impacted data object.\n */\n key: string\n /**\n * The kind of the impacted data object.\n */\n kind: string\n /**\n * The type of the impact.\n *\n * - `delete` - The data object would be deleted.\n */\n type: 'delete' | 'publish'\n /**\n * The impact description.\n * Explains what will happen to the impacted data object.\n * This is a human-readable description of the impact.\n * It should be clear and concise.\n */\n impact: string\n /**\n * The severity of the impact.\n *\n * - `info` - The impact is informational.\n * - `warning` - The impact can potentially cause problems but is not a blocker.\n * - `error` - The impact is a blocker and needs to be resolved before proceeding.\n */\n severity: 'info' | 'warning' | 'error'\n /**\n * Whether the impact is blocking the operation.\n * If true, the operation cannot proceed.\n * @deprecated Use `severity` instead.\n */\n blocking: boolean\n /**\n * The type of the relationship between two impacted objects.\n */\n relationship?: 'child'\n /**\n * The resolution of the conflict if the change will be forced.\n */\n resolution?: string\n /**\n * The optional parent of the impacted data object.\n * For example, if the impacted item is a property, this will be the entity it belongs to.\n */\n parent?: string\n}\n\n/**\n * # DomainImpactAnalysis\n *\n * The `DomainImpactAnalysis` class is a tool for analyzing the consequences of deleting data domain elements\n * within a `DataDomain`. It helps developers understand the ripple effects of removing a namespace, data model,\n * entity, property, or association, ensuring data integrity and preventing unintended side effects.\n *\n * ## Core Concepts\n *\n * - **Impact Report:** The central output of the `DomainImpactAnalysis` class is an `DomainImpactReport`.\n * This report details the potential consequences of a deletion operation, including:\n * - The object being deleted (`key`, `kind`).\n * - A list of `DomainImpactItem` objects, each describing a specific consequence.\n * - Whether the deletion can proceed safely (`canProceed`).\n *\n * - **DomainImpactItem:** Each `DomainImpactItem` describes a specific consequence of the deletion.\n * Key properties include:\n * - `key`: The key of the impacted object.\n * - `kind`: The kind of the impacted object.\n * - `type`: The type of impact (currently only `delete`).\n * - `impact`: A human-readable description of the impact.\n * - `blocking`: Whether this impact prevents the deletion from proceeding.\n * - `relationship`: The type of relationship between the deleted object and the impacted object (e.g., `child`).\n * - `resolution`: A description of how the impact will be resolved if the deletion is forced.\n *\n * - **Blocking Impacts:** Some impacts are considered \"blocking,\" meaning they prevent the deletion from proceeding\n * without manual intervention. For example, deleting an entity that is a parent to other entities is\n * a blocking impact.\n *\n * - **Non-Blocking Impacts:** Some impacts are informational and do not prevent the deletion. For example, deleting a\n * property is not a blocking impact.\n *\n * ## Usage\n *\n * 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataDomain` as an argument.\n *\n * ```typescript\n * import { DataDomain } from './DataDomain';\n * import { DomainImpactAnalysis } from './DomainImpactAnalysis';\n *\n * const dataDomain = new DataDomain();\n * // ... add some data to the domain\n * const analyzer = new DomainImpactAnalysis(dataDomain);\n * ```\n *\n * 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `DomainImpactReport` for\n * a specific deletion.\n * Provide the `key` and `kind` of the object to be deleted.\n *\n * ```typescript\n * import { DomainEntityKind } from '../models/kinds.js';\n * // ...\n * const entityKey = 'some-entity-key';\n * const report = analyzer.deleteAnalysis(entityKey, DomainEntityKind);\n * ```\n *\n * 3. **Interpreting the Report:** Examine the `DomainImpactReport` to understand the consequences of the deletion.\n * - Check `report.canProceed` to see if the deletion is safe.\n * - Iterate through `report.impact` to understand each consequence.\n * - Pay special attention to `impact.blocking` to identify impacts that require manual resolution.\n *\n * ```typescript\n * if (report.canProceed) {\n * // Proceed with deletion\n * } else {\n * console.warn('Deletion cannot proceed due to the following impacts:');\n * report.impact.forEach((item) => {\n * console.warn(`- ${item.impact}`);\n * if (item.blocking) {\n * console.warn(` - This impact is blocking.`);\n * if (item.resolution) {\n * console.warn(` - Resolution: ${item.resolution}`);\n * }\n * }\n * });\n * // Handle blocking impacts (e.g., prompt the user, modify the data, etc.)\n * }\n * ```\n *\n * ## Supported Deletion Scenarios\n *\n * The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain element types:\n *\n * - **Namespaces (`DomainNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,\n * data models, entities, properties, and associations.\n * - **Data Models (`DomainModelKind`):** Deleting a data model impacts all its entities, properties, and associations.\n * - **Entities (`DomainEntityKind`):** Deleting an entity impacts its properties, associations, and any other\n * entities that have it as a parent or target in an association.\n * - **Properties (`DomainPropertyKind`):** Deleting a property impacts the entity it belongs to.\n * - **Associations (`DomainAssociationKind`):** Deleting an association impacts the entity it belongs to.\n * - **Data Domain (`DataDomainKind`):** Deleting a data domain is not supported.\n *\n * ## Example: Deleting an Entity\n *\n * Consider the following scenario:\n *\n * ```\n * DataDomain\n * - Namespace: `MyNamespace`\n * - Data Model: `ProductModel`\n * - Entity: `Product`\n * - Property: `name`\n * - Association: `category` (targets `Category` entity)\n * - Entity: `Category`\n * - Property: `name`\n * - Entity: `SpecialProduct` (parent: `Product`)\n * ```\n *\n * If you attempt to delete the `Product` entity, the `DomainImpactAnalysis` will generate a report similar to this:\n *\n * ```json\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DomainEntityKind\",\n * \"impact\": [\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DomainEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The entity with key Product will be deleted.\",\n * \"blocking\": false\n * },\n * {\n * \"key\": \"SpecialProduct\",\n * \"kind\": \"DomainEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The SpecialProduct entity will become an orphan because it is a child of Product.\",\n * \"resolution\": \"The \\\"Product\\\" entity will be removed as the parent of the \\\"SpecialProduct\\\" entity.\",\n * \"blocking\": true,\n * \"relationship\": \"child\"\n * },\n * {\n * \"key\": \"category\",\n * \"kind\": \"DomainAssociationKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The association with key category will be broken because it has a target to Product.\",\n * \"resolution\": \"The association with key category will be removed from Product.\",\n * \"blocking\": true\n * },\n * {\n * \"key\": \"name\",\n * \"kind\": \"DomainPropertyKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The property with key name will be deleted.\",\n * \"blocking\": false\n * }\n * ],\n * \"canProceed\": false\n * }\n * ```\n *\n * This report indicates that:\n *\n * - The `Product` entity will be deleted.\n * - The `SpecialProduct` entity will become an orphan (blocking).\n * - The `category` association will be broken (blocking).\n * - The `name` property will be deleted.\n * - The deletion cannot proceed without addressing the blocking impacts.\n *\n * ## Types\n *\n * ### `DomainImpactKinds`\n *\n * - **Description:** A type alias for the kinds of data domain elements that can be analyzed.\n * - **Values:**\n * - `DomainNamespaceKind`\n * - `DomainEntityKind`\n * - `DomainModelKind`\n * - `DomainPropertyKind`\n * - `DomainAssociationKind`\n * - `DataDomainKind`\n *\n * ### `DomainImpactReport`\n *\n * - **Description:** The structure of the impact analysis report.\n * - **Properties:**\n * - `key` (`string`): The key of the object being deleted.\n * - `kind` (`DomainImpactKinds`): The kind of the object being deleted.\n * - `impact` (`DomainImpactItem[]`): The list of impacts.\n * - `canProceed` (`boolean`): Whether the deletion can proceed.\n *\n * ### `DomainImpactItem`\n *\n * - **Description:** The structure of an individual impact item.\n * - **Properties:**\n * - `key` (`string`): The key of the impacted object.\n * - `kind` (`string`): The kind of the impacted object.\n * - `type` (`'delete'`): The type of impact.\n * - `impact` (`string`): The impact description.\n * - `blocking` (`boolean`): Whether the impact is blocking.\n * - `relationship` (`'child'`, optional): The relationship type.\n * - `resolution` (`string`, optional): The resolution description.\n *\n * ## Error Handling\n *\n * The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `DomainImpactReport` to communicate\n * the results of the analysis, including any blocking impacts.\n *\n * ## Best Practices\n *\n * - **Always Analyze Before Deleting:** Before deleting any data domain element, always use `DomainImpactAnalysis`\n * to understand the consequences.\n * - **Handle Blocking Impacts:** Pay close attention to `blocking` impacts and implement appropriate\n * logic to handle them.\n * - **Inform the User:** If a deletion cannot proceed, inform the user about the blocking impacts and provide\n * guidance on how to resolve them.\n * - **Consider Forced Deletion:** In some cases, you may want to allow users to force a deletion even if there are\n * blocking impacts. In such cases, you should clearly communicate the risks to the user.\n *\n * ## Conclusion\n *\n * The `DomainImpactAnalysis` class is an essential tool for maintaining data integrity when working with complex\n * data domain models. By providing detailed impact reports, it empowers developers to make informed decisions\n * about data deletion and prevent unintended consequences.\n */\nexport class DomainImpactAnalysis {\n private report: DomainImpactReport\n private root: DataDomain\n\n constructor(root: DataDomain) {\n this.root = root\n this.report = {\n key: '',\n kind: DataDomainKind,\n impact: [],\n canProceed: false,\n }\n }\n\n /**\n * Generates a report of how the data domain will be impacted by the deletion of a data domain object.\n * @param key The key of the impacted data domain object.\n * @param kind The kind of the impacted data object.\n * @returns The delete impact analysis report.\n */\n deleteAnalysis(key: string, kind: DomainImpactKinds): DomainImpactReport {\n this.report = {\n key,\n kind,\n impact: [],\n canProceed: true,\n }\n this.createDeleteImpact(key, kind, key)\n return this.report\n }\n\n /**\n * Generates a report of how the data domain will be impacted by the removal of a foreign namespace.\n * @param key The key of the foreign namespace.\n * @returns The delete impact analysis report.\n */\n removeForeignNamespaceAnalysis(key: string): DomainImpactReport {\n this.report = {\n key,\n kind: DomainNamespaceKind,\n impact: [],\n canProceed: true,\n }\n this.createRemoveForeignNamespaceImpact(key)\n return this.report\n }\n\n /**\n * Analyzes the data domain for publishing. Essentially, it performs a validation of the data domain\n * and returns a report of the impact.\n * @returns The publish impact analysis report.\n */\n publishAnalysis(): DomainImpactReport {\n this.report = {\n key: '',\n kind: DataDomainKind,\n impact: [],\n canProceed: true,\n }\n const entityValidator = new EntityValidation(this.root)\n const propertyValidator = new PropertyValidation(this.root)\n const associationValidator = new AssociationValidation(this.root)\n for (const entity of this.root.listEntities()) {\n if (entity.domain.key !== this.root.key) {\n // we don't need to validate foreign entities\n continue\n }\n const report = entityValidator.validate(entity)\n for (const item of report) {\n const blocking = item.severity === 'error'\n this.report.canProceed = this.report.canProceed && !blocking\n this.report.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n blocking,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n for (const property of entity.properties) {\n const report = propertyValidator.validate(property)\n for (const item of report) {\n const blocking = item.severity === 'error'\n this.report.canProceed = this.report.canProceed && !blocking\n this.report.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n blocking,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n }\n for (const association of entity.associations) {\n const report = associationValidator.validate(association)\n for (const item of report) {\n const blocking = item.severity === 'error'\n this.report.canProceed = this.report.canProceed && !blocking\n this.report.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n blocking,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n }\n }\n return this.report\n }\n\n protected createDeleteImpact(key: string, kind: DomainImpactKinds, rootKey: string): void {\n switch (kind) {\n case DomainNamespaceKind:\n this.deleteNamespaceAnalysis(key, rootKey)\n break\n case DomainModelKind:\n this.deleteModelAnalysis(key, rootKey)\n break\n case DomainEntityKind:\n this.deleteEntityAnalysis(key, rootKey)\n break\n case DomainPropertyKind:\n this.deletePropertyAnalysis(key)\n break\n case DomainAssociationKind:\n this.deleteAssociationAnalysis(key)\n break\n default:\n // ignore unknown kinds\n }\n }\n\n protected deleteNamespaceAnalysis(key: string, rootKey: string): void {\n const ns = this.root.findNamespace(key)\n if (!ns) {\n return\n }\n this.report.impact.push({\n key: ns.key,\n kind: ns.kind,\n type: 'delete',\n impact: `The ${ns.info.getLabel()} ${this.kindToLabel(DomainNamespaceKind)} will be deleted.`,\n blocking: false,\n severity: 'info',\n })\n for (const child of ns.listNamespaces()) {\n this.deleteNamespaceAnalysis(child.key, rootKey)\n }\n for (const child of ns.listModels()) {\n this.deleteModelAnalysis(child.key, rootKey)\n }\n }\n\n protected deleteModelAnalysis(key: string, rootKey: string): void {\n const model = this.root.findModel(key)\n if (!model) {\n return\n }\n this.report.impact.push({\n key: model.key,\n kind: model.kind,\n type: 'delete',\n impact: `The ${model.info.getLabel()} ${this.kindToLabel(DomainModelKind)} will be deleted.`,\n blocking: false,\n severity: 'info',\n })\n for (const child of model.listEntities()) {\n this.deleteEntityAnalysis(child.key, rootKey)\n }\n }\n\n protected deleteEntityAnalysis(key: string, rootKey: string): void {\n const entity = this.root.findEntity(key)\n if (!entity) {\n return\n }\n this.report.impact.push({\n key: entity.key,\n kind: entity.kind,\n type: 'delete',\n impact: `The ${entity.info.getLabel()} ${this.kindToLabel(DomainEntityKind)} will be deleted.`,\n blocking: false,\n severity: 'info',\n })\n\n // We need to know whether the entity is a parent of another entity\n for (const info of this.root.graph.inEdges(key)) {\n const edge = this.root.graph.edge(info)\n if (!edge || edge.type !== 'parent') {\n continue\n }\n const childEntity = this.root.findEntity(info.v)\n if (!childEntity) {\n continue\n }\n if (childEntity.isChildOf(rootKey)) {\n // No need to include this child as it itself is being deleted\n continue\n }\n const pLabel = entity.info.getLabel()\n const cLabel = childEntity.info.getLabel()\n this.report.impact.push({\n key: childEntity.key,\n kind: childEntity.kind,\n type: 'delete',\n impact: `The \"${cLabel}\" ${this.kindToLabel(DomainEntityKind)} will become an orphan because it is a child of the \"${pLabel}\" entity.`,\n resolution: `The \"${pLabel}\" entity will be removed as the parent of the \"${cLabel}\" entity.`,\n blocking: false,\n relationship: 'child',\n severity: 'error',\n })\n this.report.canProceed = false\n }\n // We need to know whether there's another entity that has an association to this entity.\n for (const edgeInfo of this.root.graph.inEdges(entity.key)) {\n const edge = this.root.graph.edge(edgeInfo)\n if (!edge || edge.type !== 'association') {\n continue\n }\n const association = this.root.findAssociation(edgeInfo.v)\n if (!association) {\n continue\n }\n const targetEntity = association.getParentInstance()\n if (!targetEntity) {\n continue\n }\n if (targetEntity.isChildOf(rootKey)) {\n // No need to include this association as the target entity itself is being deleted\n continue\n }\n\n const aLabel = association.info.getLabel()\n const eLabel = entity.info.getLabel()\n this.report.impact.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be broken because it has a target to ${eLabel}.`,\n resolution: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be removed from ${eLabel}.`,\n blocking: true,\n severity: 'error',\n })\n this.report.canProceed = false\n }\n for (const child of entity.listProperties()) {\n this.deletePropertyAnalysis(child.key)\n }\n for (const child of entity.listAssociations()) {\n this.deleteAssociationAnalysis(child.key)\n }\n }\n\n protected deletePropertyAnalysis(key: string): void {\n const property = this.root.findProperty(key)\n if (!property) {\n return\n }\n this.report.impact.push({\n key: property.key,\n kind: property.kind,\n type: 'delete',\n impact: `The ${property.info.getLabel()} ${this.kindToLabel(DomainPropertyKind)} will be deleted.`,\n blocking: false,\n severity: 'info',\n })\n }\n\n protected deleteAssociationAnalysis(key: string): void {\n const association = this.root.findAssociation(key)\n if (!association) {\n return\n }\n this.report.impact.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${association.info.getLabel()} ${this.kindToLabel(DomainAssociationKind)} will be deleted.`,\n blocking: false,\n severity: 'info',\n })\n }\n\n protected kindToLabel(kind: DomainImpactKinds): string {\n switch (kind) {\n case DomainNamespaceKind:\n return 'namespace'\n case DomainEntityKind:\n return 'entity'\n case DomainModelKind:\n return 'data model'\n case DomainPropertyKind:\n return 'property'\n case DomainAssociationKind:\n return 'association'\n default:\n return 'unknown'\n }\n }\n\n protected createRemoveForeignNamespaceImpact(key: string): void {\n const foreignNamespace = this.root.dependencies.get(key)\n if (!foreignNamespace) {\n return\n }\n // Check for parent relationships to foreign entities\n for (const entity of this.root.listEntities()) {\n for (const info of this.root.graph.outEdges(entity.key)) {\n const edge = this.root.graph.edge(info)\n if (!edge) {\n continue\n }\n if (edge.type === 'parent' && edge.domain === key) {\n // the parent is in the foreign namespace\n const parentEntity = this.root.findEntity(info.w)\n if (!parentEntity) {\n continue\n }\n const eLabel = entity.info.getLabel()\n const pLabel = parentEntity.info.getLabel()\n this.report.impact.push({\n key: entity.key,\n kind: entity.kind,\n type: 'delete',\n impact: `The \"${eLabel}\" ${this.kindToLabel(DomainEntityKind)} will become an orphan because its parent \"${pLabel}\" is in the foreign namespace \"${foreignNamespace.key}\".`,\n resolution: `The \"${pLabel}\" entity will be removed as the parent of the \"${eLabel}\" entity.`,\n blocking: true,\n relationship: 'child',\n severity: 'error',\n })\n this.report.canProceed = false\n } else if (edge.type === 'association') {\n const association = this.root.findAssociation(info.w)\n if (!association) {\n continue\n }\n const targets = association.targets.filter((t) => t.domain === key)\n if (targets.length) {\n for (const info of targets) {\n const targetEntity = this.root.findForeignEntity(info.key, info.domain as string)\n if (!targetEntity) {\n continue\n }\n const aLabel = association.info.getLabel()\n const eLabel = entity.info.getLabel()\n const tLabel = targetEntity.info.getLabel()\n this.report.impact.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The \"${aLabel}\" ${this.kindToLabel(DomainAssociationKind)} from \"${eLabel}\" will be broken because it targets \"${tLabel}\" in the foreign namespace \"${foreignNamespace.key}\".`,\n resolution: `The \"${aLabel}\" ${this.kindToLabel(DomainAssociationKind)} will be removed from \"${eLabel}\".`,\n blocking: true,\n severity: 'error',\n })\n this.report.canProceed = false\n }\n }\n }\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainImpactAnalysis.js","sourceRoot":"","sources":["../../../src/modeling/DomainImpactAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,oBAAoB,CAAA;AAI3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiMG;AACH,MAAM,OAAO,oBAAoB;IACvB,IAAI,CAAY;IAExB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,GAAW,EAAE,IAAuB;QACjD,MAAM,MAAM,GAAuB;YACjC,GAAG;YACH,IAAI;Y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AC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n DomainNamespaceKind,\n DomainEntityKind,\n DomainModelKind,\n DomainPropertyKind,\n DomainAssociationKind,\n} from '../models/kinds.js'\nimport type { DataDomain } from './DataDomain.js'\nimport { DomainImpactItem, DomainImpactKinds, DomainImpactReport } from './types.js'\n\n/**\n * # DomainImpactAnalysis\n *\n * The `DomainImpactAnalysis` class is a tool for analyzing the consequences of deleting data domain elements\n * within a `DataDomain`. It helps developers understand the ripple effects of removing a namespace, data model,\n * entity, property, or association, ensuring data integrity and preventing unintended side effects.\n *\n * ## Core Concepts\n *\n * - **Impact Report:** The central output of the `DomainImpactAnalysis` class is an `DomainImpactReport`.\n * This report details the potential consequences of a deletion operation, including:\n * - The object being deleted (`key`, `kind`).\n * - A list of `DomainImpactItem` objects, each describing a specific consequence.\n * - Whether the deletion can proceed safely (`canProceed`).\n *\n * - **DomainImpactItem:** Each `DomainImpactItem` describes a specific consequence of the deletion.\n * Key properties include:\n * - `key`: The key of the impacted object.\n * - `kind`: The kind of the impacted object.\n * - `type`: The type of impact (currently only `delete`).\n * - `impact`: A human-readable description of the impact.\n * - `relationship`: The type of relationship between the deleted object and the impacted object (e.g., `child`).\n * - `resolution`: A description of how the impact will be resolved if the deletion is forced.\n * - `severity`: The severity of the impact, which can be `info`, `warning`, or `error`.\n *\n * - **Blocking Impacts:** Some impacts are considered \"blocking,\" meaning they prevent the deletion from proceeding\n * without manual intervention. For example, deleting an entity that is a parent to other entities is\n * a blocking impact. Blocking impacts are indicated by the `severity` property set to `error`.\n *\n * - **Non-Blocking Impacts:** Some impacts are informational and do not prevent the deletion. For example, deleting a\n * property is not a blocking impact.\n *\n * ## Usage\n *\n * 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataDomain` as an argument.\n *\n * ```typescript\n * import { DataDomain } from './DataDomain';\n * import { DomainImpactAnalysis } from './DomainImpactAnalysis';\n *\n * const dataDomain = new DataDomain();\n * // ... add some data to the domain\n * const analyzer = new DomainImpactAnalysis(dataDomain);\n * ```\n *\n * 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `DomainImpactReport` for\n * a specific deletion.\n * Provide the `key` and `kind` of the object to be deleted.\n *\n * ```typescript\n * import { DomainEntityKind } from '../models/kinds.js';\n * // ...\n * const entityKey = 'some-entity-key';\n * const report = analyzer.deleteAnalysis(entityKey, DomainEntityKind);\n * ```\n *\n * 3. **Interpreting the Report:** Examine the `DomainImpactReport` to understand the consequences of the deletion.\n * - Check `report.canProceed` to see if the deletion is safe.\n * - Iterate through `report.impact` to understand each consequence.\n * - Pay special attention to `impact.severity` to identify impacts that require manual resolution.\n *\n * ```typescript\n * if (report.canProceed) {\n * // Proceed with deletion\n * } else {\n * console.warn('Deletion cannot proceed due to the following impacts:');\n * report.impact.forEach((item) => {\n * console.warn(`- ${item.impact}`);\n * if (item.severity === 'error') {\n * console.warn(` - This impact is blocking.`);\n * if (item.resolution) {\n * console.warn(` - Resolution: ${item.resolution}`);\n * }\n * }\n * });\n * // Handle blocking impacts (e.g., prompt the user, modify the data, etc.)\n * }\n * ```\n *\n * ## Supported Deletion Scenarios\n *\n * The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain element types:\n *\n * - **Namespaces (`DomainNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,\n * data models, entities, properties, and associations.\n * - **Data Models (`DomainModelKind`):** Deleting a data model impacts all its entities, properties, and associations.\n * - **Entities (`DomainEntityKind`):** Deleting an entity impacts its properties, associations, and any other\n * entities that have it as a parent or target in an association.\n * - **Properties (`DomainPropertyKind`):** Deleting a property impacts the entity it belongs to.\n * - **Associations (`DomainAssociationKind`):** Deleting an association impacts the entity it belongs to.\n * - **Data Domain (`DataDomainKind`):** Deleting a data domain is not supported.\n *\n * ## Example: Deleting an Entity\n *\n * Consider the following scenario:\n *\n * ```\n * DataDomain\n * - Namespace: `MyNamespace`\n * - Data Model: `ProductModel`\n * - Entity: `Product`\n * - Property: `name`\n * - Association: `category` (targets `Category` entity)\n * - Entity: `Category`\n * - Property: `name`\n * - Entity: `SpecialProduct` (parent: `Product`)\n * ```\n *\n * If you attempt to delete the `Product` entity, the `DomainImpactAnalysis` will generate a report similar to this:\n *\n * ```json\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DomainEntityKind\",\n * \"impact\": [\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DomainEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The entity with key Product will be deleted.\",\n * \"severity\": \"warning\"\n * },\n * {\n * \"key\": \"SpecialProduct\",\n * \"kind\": \"DomainEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The SpecialProduct entity will become an orphan because it is a child of Product.\",\n * \"resolution\": \"The \\\"Product\\\" entity will be removed as the parent of the \\\"SpecialProduct\\\" entity.\",\n * \"severity\": \"error\",\n * \"relationship\": \"child\"\n * },\n * {\n * \"key\": \"category\",\n * \"kind\": \"DomainAssociationKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The association with key category will be broken because it has a target to Product.\",\n * \"resolution\": \"The association with key category will be removed from Product.\",\n * \"severity\": \"error\"\n * },\n * {\n * \"key\": \"name\",\n * \"kind\": \"DomainPropertyKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The property with key name will be deleted.\",\n * \"severity\": \"info\"\n * }\n * ],\n * \"canProceed\": false\n * }\n * ```\n *\n * This report indicates that:\n *\n * - The `Product` entity will be deleted.\n * - The `SpecialProduct` entity will become an orphan (blocking).\n * - The `category` association will be broken (blocking).\n * - The `name` property will be deleted.\n * - The deletion cannot proceed without addressing the blocking impacts.\n *\n * ## Types\n *\n * ### `DomainImpactKinds`\n *\n * - **Description:** A type alias for the kinds of data domain elements that can be analyzed.\n * - **Values:**\n * - `DomainNamespaceKind`\n * - `DomainEntityKind`\n * - `DomainModelKind`\n * - `DomainPropertyKind`\n * - `DomainAssociationKind`\n * - `DataDomainKind`\n *\n * ## Error Handling\n *\n * The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `DomainImpactReport` to communicate\n * the results of the analysis, including any blocking impacts.\n *\n * ## Best Practices\n *\n * - **Always Analyze Before Deleting:** Before deleting any data domain element, always use `DomainImpactAnalysis`\n * to understand the consequences.\n * - **Handle Blocking Impacts:** Pay close attention to `severity = \"error\"` impacts and implement appropriate\n * logic to handle them.\n * - **Inform the User:** If a deletion cannot proceed, inform the user about the blocking impacts and provide\n * guidance on how to resolve them.\n * - **Consider Forced Deletion:** In some cases, you may want to allow users to force a deletion even if there are\n * blocking impacts. In such cases, you should clearly communicate the risks to the user.\n *\n * ## Conclusion\n *\n * The `DomainImpactAnalysis` class is an essential tool for maintaining data integrity when working with complex\n * data domain models. By providing detailed impact reports, it empowers developers to make informed decisions\n * about data deletion and prevent unintended consequences.\n */\nexport class DomainImpactAnalysis {\n private root: DataDomain\n\n constructor(root: DataDomain) {\n this.root = root\n }\n\n /**\n * Generates a report of how the data domain will be impacted by the deletion of a data domain object.\n * @param key The key of the impacted data domain object.\n * @param kind The kind of the impacted data object.\n * @returns The delete impact analysis report.\n */\n deleteAnalysis(key: string, kind: DomainImpactKinds): DomainImpactReport {\n const report: DomainImpactReport = {\n key,\n kind,\n impact: [],\n canProceed: true,\n }\n this.createDeleteImpact(key, kind, key, report.impact)\n report.canProceed = this.computeCanProceed(report.impact)\n return report\n }\n\n /**\n * Generates a report of how the data domain will be impacted by the removal of a foreign namespace.\n * @param key The key of the foreign namespace.\n * @returns The delete impact analysis report.\n */\n removeForeignNamespaceAnalysis(key: string): DomainImpactReport {\n const report: DomainImpactReport = {\n key,\n kind: DomainNamespaceKind,\n impact: [],\n canProceed: true,\n }\n this.createRemoveForeignNamespaceImpact(key, report.impact)\n report.canProceed = this.computeCanProceed(report.impact)\n return report\n }\n\n /**\n * Computes whether the deletion can proceed based on the impact report.\n * @param impact The list of impacts from the analysis.\n * @returns `true` if the deletion can proceed, `false` otherwise.\n */\n protected computeCanProceed(impact: DomainImpactItem[]): boolean {\n return !impact.some((item) => item.severity === 'error')\n }\n\n protected createDeleteImpact(\n key: string,\n kind: DomainImpactKinds,\n rootKey: string,\n impact: DomainImpactItem[]\n ): void {\n switch (kind) {\n case DomainNamespaceKind:\n this.deleteNamespaceAnalysis(key, rootKey, impact)\n break\n case DomainModelKind:\n this.deleteModelAnalysis(key, rootKey, impact)\n break\n case DomainEntityKind:\n this.deleteEntityAnalysis(key, rootKey, impact)\n break\n case DomainPropertyKind:\n this.deletePropertyAnalysis(key, impact)\n break\n case DomainAssociationKind:\n this.deleteAssociationAnalysis(key, impact)\n break\n default:\n // ignore unknown kinds\n }\n }\n\n protected deleteNamespaceAnalysis(key: string, rootKey: string, impact: DomainImpactItem[]): void {\n const ns = this.root.findNamespace(key)\n if (!ns) {\n return\n }\n impact.push({\n key: ns.key,\n kind: ns.kind,\n type: 'delete',\n impact: `The ${ns.info.getLabel()} ${this.kindToLabel(DomainNamespaceKind)} will be deleted.`,\n severity: 'info',\n })\n for (const child of ns.listNamespaces()) {\n this.deleteNamespaceAnalysis(child.key, rootKey, impact)\n }\n for (const child of ns.listModels()) {\n this.deleteModelAnalysis(child.key, rootKey, impact)\n }\n }\n\n protected deleteModelAnalysis(key: string, rootKey: string, impact: DomainImpactItem[]): void {\n const model = this.root.findModel(key)\n if (!model) {\n return\n }\n impact.push({\n key: model.key,\n kind: model.kind,\n type: 'delete',\n impact: `The ${model.info.getLabel()} ${this.kindToLabel(DomainModelKind)} will be deleted.`,\n severity: 'info',\n })\n for (const child of model.listEntities()) {\n this.deleteEntityAnalysis(child.key, rootKey, impact)\n }\n }\n\n protected deleteEntityAnalysis(key: string, rootKey: string, impact: DomainImpactItem[]): void {\n const entity = this.root.findEntity(key)\n if (!entity) {\n return\n }\n impact.push({\n key: entity.key,\n kind: entity.kind,\n type: 'delete',\n impact: `The ${entity.info.getLabel()} ${this.kindToLabel(DomainEntityKind)} will be deleted.`,\n severity: 'info',\n })\n\n // We need to know whether the entity is a parent of another entity\n for (const info of this.root.graph.inEdges(key)) {\n const edge = this.root.graph.edge(info)\n if (!edge || edge.type !== 'parent') {\n continue\n }\n const childEntity = this.root.findEntity(info.v)\n if (!childEntity) {\n continue\n }\n if (childEntity.isChildOf(rootKey)) {\n // No need to include this child as it itself is being deleted\n continue\n }\n const pLabel = entity.info.getLabel()\n const cLabel = childEntity.info.getLabel()\n impact.push({\n key: childEntity.key,\n kind: childEntity.kind,\n type: 'delete',\n impact: `The \"${cLabel}\" ${this.kindToLabel(DomainEntityKind)} will become an orphan because it is a child of the \"${pLabel}\" entity.`,\n resolution: `The \"${pLabel}\" entity will be removed as the parent of the \"${cLabel}\" entity.`,\n relationship: 'child',\n severity: 'error',\n })\n }\n // We need to know whether there's another entity that has an association to this entity.\n for (const edgeInfo of this.root.graph.inEdges(entity.key)) {\n const edge = this.root.graph.edge(edgeInfo)\n if (!edge || edge.type !== 'association') {\n continue\n }\n const association = this.root.findAssociation(edgeInfo.v)\n if (!association) {\n continue\n }\n const targetEntity = association.getParentInstance()\n if (!targetEntity) {\n continue\n }\n if (targetEntity.isChildOf(rootKey)) {\n // No need to include this association as the target entity itself is being deleted\n continue\n }\n\n const aLabel = association.info.getLabel()\n const eLabel = entity.info.getLabel()\n impact.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be broken because it has a target to ${eLabel}.`,\n resolution: `The ${aLabel} ${this.kindToLabel(DomainAssociationKind)} will be removed from ${eLabel}.`,\n severity: 'error',\n })\n }\n for (const child of entity.listProperties()) {\n this.deletePropertyAnalysis(child.key, impact)\n }\n for (const child of entity.listAssociations()) {\n this.deleteAssociationAnalysis(child.key, impact)\n }\n }\n\n protected deletePropertyAnalysis(key: string, impact: DomainImpactItem[]): void {\n const property = this.root.findProperty(key)\n if (!property) {\n return\n }\n impact.push({\n key: property.key,\n kind: property.kind,\n type: 'delete',\n impact: `The ${property.info.getLabel()} ${this.kindToLabel(DomainPropertyKind)} will be deleted.`,\n severity: 'info',\n })\n }\n\n protected deleteAssociationAnalysis(key: string, impact: DomainImpactItem[]): void {\n const association = this.root.findAssociation(key)\n if (!association) {\n return\n }\n impact.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${association.info.getLabel()} ${this.kindToLabel(DomainAssociationKind)} will be deleted.`,\n severity: 'info',\n })\n }\n\n protected kindToLabel(kind: DomainImpactKinds): string {\n switch (kind) {\n case DomainNamespaceKind:\n return 'namespace'\n case DomainEntityKind:\n return 'entity'\n case DomainModelKind:\n return 'data model'\n case DomainPropertyKind:\n return 'property'\n case DomainAssociationKind:\n return 'association'\n default:\n return 'unknown'\n }\n }\n\n protected createRemoveForeignNamespaceImpact(key: string, impact: DomainImpactItem[]): void {\n const foreignNamespace = this.root.dependencies.get(key)\n if (!foreignNamespace) {\n return\n }\n // Check for parent relationships to foreign entities\n for (const entity of this.root.listEntities()) {\n for (const info of this.root.graph.outEdges(entity.key)) {\n const edge = this.root.graph.edge(info)\n if (!edge) {\n continue\n }\n if (edge.type === 'parent' && edge.domain === key) {\n // the parent is in the foreign namespace\n const parentEntity = this.root.findEntity(info.w)\n if (!parentEntity) {\n continue\n }\n const eLabel = entity.info.getLabel()\n const pLabel = parentEntity.info.getLabel()\n impact.push({\n key: entity.key,\n kind: entity.kind,\n type: 'delete',\n impact: `The \"${eLabel}\" ${this.kindToLabel(DomainEntityKind)} will become an orphan because its parent \"${pLabel}\" is in the foreign namespace \"${foreignNamespace.key}\".`,\n resolution: `The \"${pLabel}\" entity will be removed as the parent of the \"${eLabel}\" entity.`,\n relationship: 'child',\n severity: 'error',\n })\n } else if (edge.type === 'association') {\n const association = this.root.findAssociation(info.w)\n if (!association) {\n continue\n }\n const targets = association.targets.filter((t) => t.domain === key)\n if (targets.length) {\n for (const info of targets) {\n const targetEntity = this.root.findForeignEntity(info.key, info.domain as string)\n if (!targetEntity) {\n continue\n }\n const aLabel = association.info.getLabel()\n const eLabel = entity.info.getLabel()\n const tLabel = targetEntity.info.getLabel()\n impact.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The \"${aLabel}\" ${this.kindToLabel(DomainAssociationKind)} from \"${eLabel}\" will be broken because it targets \"${tLabel}\" in the foreign namespace \"${foreignNamespace.key}\".`,\n resolution: `The \"${aLabel}\" ${this.kindToLabel(DomainAssociationKind)} will be removed from \"${eLabel}\".`,\n severity: 'error',\n })\n }\n }\n }\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataDomain } from './DataDomain.js';
|
|
2
|
+
import { DomainImpactReport } from './types.js';
|
|
3
|
+
export declare class DomainValidation {
|
|
4
|
+
private root;
|
|
5
|
+
constructor(root: DataDomain);
|
|
6
|
+
validate(): DomainImpactReport;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=DomainValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainValidation.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAM/C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAY;gBAEZ,IAAI,EAAE,UAAU;IAI5B,QAAQ,IAAI,kBAAkB;CAyF/B"}
|