@api-client/core 0.11.8 → 0.11.10

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 (30) hide show
  1. package/build/src/browser.d.ts +1 -1
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +1 -1
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/index.d.ts +1 -1
  6. package/build/src/index.d.ts.map +1 -1
  7. package/build/src/index.js +1 -1
  8. package/build/src/index.js.map +1 -1
  9. package/build/src/modeling/DataEntity.d.ts +1 -1
  10. package/build/src/modeling/DataEntity.js +1 -1
  11. package/build/src/modeling/DataEntity.js.map +1 -1
  12. package/build/src/modeling/DataNamespace.d.ts +10 -2
  13. package/build/src/modeling/DataNamespace.d.ts.map +1 -1
  14. package/build/src/modeling/DataNamespace.js +34 -6
  15. package/build/src/modeling/DataNamespace.js.map +1 -1
  16. package/build/src/modeling/{ImpactAnalysis.d.ts → DomainImpactAnalysis.d.ts} +29 -30
  17. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -0
  18. package/build/src/modeling/{ImpactAnalysis.js → DomainImpactAnalysis.js} +20 -18
  19. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -0
  20. package/build/src/modeling/types.d.ts +1 -1
  21. package/build/src/modeling/types.js.map +1 -1
  22. package/data/models/example-generator-api.json +15 -15
  23. package/package.json +1 -1
  24. package/src/modeling/DataEntity.ts +1 -1
  25. package/src/modeling/DataNamespace.ts +41 -6
  26. package/src/modeling/{ImpactAnalysis.ts → DomainImpactAnalysis.ts} +38 -36
  27. package/src/modeling/types.ts +1 -1
  28. package/tests/unit/modeling/impact_analysis.spec.ts +16 -16
  29. package/build/src/modeling/ImpactAnalysis.d.ts.map +0 -1
  30. package/build/src/modeling/ImpactAnalysis.js.map +0 -1
@@ -41722,6 +41722,9 @@
41722
41722
  "@id": "#209"
41723
41723
  },
41724
41724
  {
41725
+ "@id": "#206"
41726
+ },
41727
+ {
41725
41728
  "@id": "#191"
41726
41729
  },
41727
41730
  {
@@ -41737,9 +41740,6 @@
41737
41740
  "@id": "#203"
41738
41741
  },
41739
41742
  {
41740
- "@id": "#206"
41741
- },
41742
- {
41743
41743
  "@id": "#209"
41744
41744
  }
41745
41745
  ],
@@ -43096,7 +43096,7 @@
43096
43096
  "doc:ExternalDomainElement",
43097
43097
  "doc:DomainElement"
43098
43098
  ],
43099
- "doc:raw": "countryCode: \"BE\"\ngraydonEnterpriseId: 1057155523\nregistrationId: \"0422319093\"\nvatNumber: \"BE0422319093\"\ngraydonCompanyId: \"0422319093\"\nisBranchOffice: false\n",
43099
+ "doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
43100
43100
  "core:mediaType": "application/yaml",
43101
43101
  "sourcemaps:sources": [
43102
43102
  {
@@ -43117,7 +43117,7 @@
43117
43117
  "doc:ExternalDomainElement",
43118
43118
  "doc:DomainElement"
43119
43119
  ],
43120
- "doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
43120
+ "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43121
43121
  "core:mediaType": "application/yaml",
43122
43122
  "sourcemaps:sources": [
43123
43123
  {
@@ -43138,7 +43138,7 @@
43138
43138
  "doc:ExternalDomainElement",
43139
43139
  "doc:DomainElement"
43140
43140
  ],
43141
- "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43141
+ "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43142
43142
  "core:mediaType": "application/yaml",
43143
43143
  "sourcemaps:sources": [
43144
43144
  {
@@ -43159,7 +43159,7 @@
43159
43159
  "doc:ExternalDomainElement",
43160
43160
  "doc:DomainElement"
43161
43161
  ],
43162
- "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43162
+ "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43163
43163
  "core:mediaType": "application/yaml",
43164
43164
  "sourcemaps:sources": [
43165
43165
  {
@@ -43180,7 +43180,7 @@
43180
43180
  "doc:ExternalDomainElement",
43181
43181
  "doc:DomainElement"
43182
43182
  ],
43183
- "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43183
+ "doc:raw": "code: '7487'\ndescription: 'Financial and insurance activities'\ntype: \"PRIMARY\"\nclassificationCode: 'BE_NACEBEL2008'\nactivityGroupCode: 'ABCDE'\n",
43184
43184
  "core:mediaType": "application/yaml",
43185
43185
  "sourcemaps:sources": [
43186
43186
  {
@@ -43201,7 +43201,7 @@
43201
43201
  "doc:ExternalDomainElement",
43202
43202
  "doc:DomainElement"
43203
43203
  ],
43204
- "doc:raw": "code: '7487'\ndescription: 'Financial and insurance activities'\ntype: \"PRIMARY\"\nclassificationCode: 'BE_NACEBEL2008'\nactivityGroupCode: 'ABCDE'\n",
43204
+ "doc:raw": "countryCode: \"BE\"\ngraydonEnterpriseId: 1057155523\nregistrationId: \"0422319093\"\nvatNumber: \"BE0422319093\"\ngraydonCompanyId: \"0422319093\"\nisBranchOffice: false\n",
43205
43205
  "core:mediaType": "application/yaml",
43206
43206
  "sourcemaps:sources": [
43207
43207
  {
@@ -44416,32 +44416,32 @@
44416
44416
  {
44417
44417
  "@id": "#193/source-map/lexical/element_0",
44418
44418
  "sourcemaps:element": "amf://id#193",
44419
- "sourcemaps:value": "[(1,0)-(7,0)]"
44419
+ "sourcemaps:value": "[(1,0)-(10,0)]"
44420
44420
  },
44421
44421
  {
44422
44422
  "@id": "#196/source-map/lexical/element_0",
44423
44423
  "sourcemaps:element": "amf://id#196",
44424
- "sourcemaps:value": "[(1,0)-(10,0)]"
44424
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44425
44425
  },
44426
44426
  {
44427
44427
  "@id": "#199/source-map/lexical/element_0",
44428
44428
  "sourcemaps:element": "amf://id#199",
44429
- "sourcemaps:value": "[(1,0)-(3,0)]"
44429
+ "sourcemaps:value": "[(1,0)-(5,0)]"
44430
44430
  },
44431
44431
  {
44432
44432
  "@id": "#202/source-map/lexical/element_0",
44433
44433
  "sourcemaps:element": "amf://id#202",
44434
- "sourcemaps:value": "[(1,0)-(5,0)]"
44434
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44435
44435
  },
44436
44436
  {
44437
44437
  "@id": "#205/source-map/lexical/element_0",
44438
44438
  "sourcemaps:element": "amf://id#205",
44439
- "sourcemaps:value": "[(1,0)-(3,0)]"
44439
+ "sourcemaps:value": "[(1,0)-(6,0)]"
44440
44440
  },
44441
44441
  {
44442
44442
  "@id": "#208/source-map/lexical/element_0",
44443
44443
  "sourcemaps:element": "amf://id#208",
44444
- "sourcemaps:value": "[(1,0)-(6,0)]"
44444
+ "sourcemaps:value": "[(1,0)-(7,0)]"
44445
44445
  },
44446
44446
  {
44447
44447
  "@id": "#223/source-map/lexical/element_0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.11.8",
4
+ "version": "0.11.10",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -535,7 +535,7 @@ export class DataEntity {
535
535
  /**
536
536
  * Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all
537
537
  * parents in the inheritance chain in no particular order.
538
- * @param recursive Whether to include parent parents as well.
538
+ * @param recursive Whether to include parent's parents as well.
539
539
  */
540
540
  getComputedParents(recursive?: boolean): DataEntity[] {
541
541
  const { entities } = this.root.definitions
@@ -4,7 +4,13 @@ import { IDataAssociation, DataAssociation, AssociationTarget } from './DataAsso
4
4
  import { IDataEntity, DataEntity } from './DataEntity.js'
5
5
  import { IDataModel, DataModel } from './DataModel.js'
6
6
  import { IDataProperty, DataProperty } from './DataProperty.js'
7
- import { DataNamespaceKind, DataModelKind } from '../models/kinds.js'
7
+ import {
8
+ DataNamespaceKind,
9
+ DataModelKind,
10
+ DataEntityKind,
11
+ DataPropertyKind,
12
+ DataAssociationKind,
13
+ } from '../models/kinds.js'
8
14
  import v4 from '../lib/uuid.js'
9
15
  import type { DataDomainRemoveOptions } from './types.js'
10
16
 
@@ -475,7 +481,7 @@ export class DataNamespace {
475
481
  addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {
476
482
  let root: DataNamespace
477
483
  if (parent) {
478
- const rootCandidate = this.findParent(parent)
484
+ const rootCandidate = this.findNamespace(parent)
479
485
  if (!rootCandidate) {
480
486
  throw new Error(`Unable to find the parent namespace ${parent}`)
481
487
  }
@@ -596,7 +602,7 @@ export class DataNamespace {
596
602
  * Finds a namespace and calls the `remove()` on it.
597
603
  * @param key The key of the namespace to find.
598
604
  */
599
- removeNamespace(key: string): void {
605
+ removeNamespace(key: string, opts?: DataDomainRemoveOptions): void {
600
606
  const root = this.root || this
601
607
  if (root.key === key) {
602
608
  throw new Error(`Unable to remove the root namespace this way.`)
@@ -604,7 +610,7 @@ export class DataNamespace {
604
610
  const { definitions } = root
605
611
  const ns = definitions.namespaces.find((i) => i.key === key)
606
612
  if (ns) {
607
- ns.remove()
613
+ ns.remove(opts)
608
614
  }
609
615
  }
610
616
 
@@ -651,15 +657,44 @@ export class DataNamespace {
651
657
  return definitions.models.find((i) => i.key === key)
652
658
  }
653
659
 
660
+ /**
661
+ * A convenience function to remove an object from the namespace.
662
+ * @param key The key of the object to remove.
663
+ * @param kind The kind of the object to remove.
664
+ * @param opts The options for the removal.
665
+ * @throws Error when the kind is not known.
666
+ */
667
+ removeObject(key: string, kind: string, opts?: DataDomainRemoveOptions): void {
668
+ switch (kind) {
669
+ case DataNamespaceKind:
670
+ this.findNamespace(key)?.remove(opts)
671
+ break
672
+ case DataModelKind:
673
+ this.findDataModel(key)?.remove(opts)
674
+ break
675
+ case DataEntityKind:
676
+ this.findEntity(key)?.remove(opts)
677
+ break
678
+ case DataPropertyKind:
679
+ this.findProperty(key)?.remove()
680
+ break
681
+ case DataAssociationKind:
682
+ this.findAssociation(key)?.remove()
683
+ break
684
+ default:
685
+ throw new Error(`Unknown kind ${kind} for the object ${key}.`)
686
+ }
687
+ }
688
+
654
689
  /**
655
690
  * Finds a data model and calls the `remove()` on it.
656
691
  * @param key The key of the data model to find.
657
692
  */
658
- removeDataModel(key: string): void {
693
+ removeDataModel(key: string, opts?: DataDomainRemoveOptions): void {
659
694
  const { definitions } = this.root || this
660
695
  const model = definitions.models.find((i) => i.key === key)
661
696
  if (model) {
662
- model.remove()
697
+ model.remove(opts)
663
698
  }
664
699
  }
665
700
 
@@ -7,7 +7,7 @@ import {
7
7
  } from '../models/kinds.js'
8
8
  import type { DataNamespace } from './DataNamespace.js'
9
9
 
10
- export type ImpactKinds =
10
+ export type DomainImpactKinds =
11
11
  | typeof DataNamespaceKind
12
12
  | typeof DataEntityKind
13
13
  | typeof DataModelKind
@@ -17,7 +17,7 @@ export type ImpactKinds =
17
17
  /**
18
18
  * The impact analysis report
19
19
  */
20
- interface ImpactReport {
20
+ export interface DomainImpactReport {
21
21
  /**
22
22
  * The key of the impacted data object.
23
23
  * This is the key of the object that is being changed.
@@ -27,11 +27,11 @@ interface ImpactReport {
27
27
  * The kind of the impacted data object.
28
28
  * This is the kind of the object that is being changed.
29
29
  */
30
- kind: ImpactKinds
30
+ kind: DomainImpactKinds
31
31
  /**
32
32
  * The list of impacted data objects.
33
33
  */
34
- impact: ImpactItem[]
34
+ impact: DomainImpactItem[]
35
35
  /**
36
36
  * Whether it is possible to proceed with the change.
37
37
  * If the change is not possible, the reason will be in the impact list.
@@ -39,7 +39,7 @@ interface ImpactReport {
39
39
  canProceed: boolean
40
40
  }
41
41
 
42
- interface ImpactItem {
42
+ export interface DomainImpactItem {
43
43
  /**
44
44
  * The key of the impacted data object.
45
45
  */
@@ -74,17 +74,17 @@ interface ImpactItem {
74
74
  }
75
75
 
76
76
  /**
77
- * # ImpactAnalysis
77
+ * # DomainImpactAnalysis
78
78
  *
79
- * The `ImpactAnalysis` class is a powerful tool for analyzing the consequences of deleting data domain objects
79
+ * The `DomainImpactAnalysis` class is a powerful tool for analyzing the consequences of deleting data domain objects
80
80
  * within a `DataNamespace`.
81
81
  * It helps developers understand the ripple effects of removing a namespace, data model, entity, property,
82
82
  * or association, ensuring data integrity and preventing unintended side effects.
83
83
  *
84
84
  * ## Core Concepts
85
85
  *
86
- * - **Impact Report:** The central output of the `ImpactAnalysis` class is an `ImpactReport`. This report details the
87
- * potential consequences of a deletion operation, including:
86
+ * - **Impact Report:** The central output of the `DomainImpactAnalysis` class is an `DomainImpactReport`.
87
+ * This report details the potential consequences of a deletion operation, including:
88
88
  * - The object being deleted (`key`, `kind`).
89
89
  * - A list of `ImpactItem` objects, each describing a specific consequence.
90
90
  * - Whether the deletion can proceed safely (`canProceed`).
@@ -107,15 +107,15 @@ interface ImpactItem {
107
107
  *
108
108
  * ## Usage
109
109
  *
110
- * 1. **Instantiation:** Create an instance of `ImpactAnalysis`, passing the root `DataNamespace` as an argument.
110
+ * 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataNamespace` as an argument.
111
111
  *
112
112
  * ```typescript
113
- * import { DataNamespace } from './DataNamespace'; // Assuming DataNamespace is in the same directory
114
- * import { ImpactAnalysis } from './ImpactAnalysis'; // Assuming ImpactAnalysis is in the same directory
113
+ * import { DataNamespace } from './DataNamespace';
114
+ * import { DomainImpactAnalysis } from './DomainImpactAnalysis';
115
115
  *
116
116
  * const rootNamespace = new DataNamespace();
117
117
  * // ... add some data to the namespace
118
- * const analyzer = new ImpactAnalysis(rootNamespace);
118
+ * const analyzer = new DomainImpactAnalysis(rootNamespace);
119
119
  * ```
120
120
  *
121
121
  * 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `ImpactReport` for a specific deletion.
@@ -153,7 +153,7 @@ interface ImpactItem {
153
153
  *
154
154
  * ## Supported Deletion Scenarios
155
155
  *
156
- * The `ImpactAnalysis` class supports analyzing the deletion of the following data domain object types:
156
+ * The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain object types:
157
157
  *
158
158
  * - **Namespaces (`DataNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,
159
159
  * data models, entities, properties, and associations.
@@ -176,7 +176,7 @@ interface ImpactItem {
176
176
  * - Property: `name`
177
177
  * - Entity: `SpecialProduct` (parent: `Product`)
178
178
  *
179
- * If you attempt to delete the `Product` entity, the `ImpactAnalysis` will generate a report similar to this:
179
+ * If you attempt to delete the `Product` entity, the `DomainImpactAnalysis` will generate a report similar to this:
180
180
  *
181
181
  * ```json
182
182
  * {
@@ -195,7 +195,7 @@ interface ImpactItem {
195
195
  * "kind": "DataEntityKind",
196
196
  * "type": "delete",
197
197
  * "impact": "The SpecialProduct entity will become an orphan because it is a child of Product.",
198
- * "resolution": "The Product will be removed as the parent parent of SpecialProduct.",
198
+ * "resolution": "The "Product" entity will be removed as the parent of the "SpecialProduct" entity.",
199
199
  * "blocking": true,
200
200
  * "relationship": "child"
201
201
  * },
@@ -262,12 +262,12 @@ interface ImpactItem {
262
262
  *
263
263
  * ## Error Handling
264
264
  *
265
- * The `ImpactAnalysis` class does not throw errors. Instead, it uses the `ImpactReport` to communicate
265
+ * The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `ImpactReport` to communicate
266
266
  * the results of the analysis, including any blocking impacts.
267
267
  *
268
268
  * ## Best Practices
269
269
  *
270
- * - **Always Analyze Before Deleting:** Before deleting any data domain object, always use `ImpactAnalysis`
270
+ * - **Always Analyze Before Deleting:** Before deleting any data domain object, always use `DomainImpactAnalysis`
271
271
  * to understand the consequences.
272
272
  * - **Handle Blocking Impacts:** Pay close attention to `blocking` impacts and implement appropriate
273
273
  * logic to handle them.
@@ -278,12 +278,12 @@ interface ImpactItem {
278
278
  *
279
279
  * ## Conclusion
280
280
  *
281
- * The `ImpactAnalysis` class is an essential tool for maintaining data integrity when working with complex
281
+ * The `DomainImpactAnalysis` class is an essential tool for maintaining data integrity when working with complex
282
282
  * data domain models. By providing detailed impact reports, it empowers developers to make informed decisions
283
283
  * about data deletion and prevent unintended consequences.
284
284
  */
285
- export class ImpactAnalysis {
286
- private report: ImpactReport
285
+ export class DomainImpactAnalysis {
286
+ private report: DomainImpactReport
287
287
  private root: DataNamespace
288
288
 
289
289
  constructor(root: DataNamespace) {
@@ -302,7 +302,7 @@ export class ImpactAnalysis {
302
302
  * @param kind The kind of the impacted data object.
303
303
  * @returns The delete impact analysis report.
304
304
  */
305
- deleteAnalysis(key: string, kind: ImpactKinds): ImpactReport {
305
+ deleteAnalysis(key: string, kind: DomainImpactKinds): DomainImpactReport {
306
306
  this.report = {
307
307
  key,
308
308
  kind,
@@ -320,7 +320,7 @@ export class ImpactAnalysis {
320
320
  return this.report
321
321
  }
322
322
 
323
- protected createDeleteImpact(key: string, kind: ImpactKinds, rootKey: string): ImpactItem[] {
323
+ protected createDeleteImpact(key: string, kind: DomainImpactKinds, rootKey: string): DomainImpactItem[] {
324
324
  switch (kind) {
325
325
  case DataNamespaceKind:
326
326
  return this.deleteNamespaceAnalysis(key, rootKey)
@@ -337,8 +337,8 @@ export class ImpactAnalysis {
337
337
  }
338
338
  }
339
339
 
340
- protected deleteNamespaceAnalysis(key: string, rootKey: string): ImpactItem[] {
341
- const result: ImpactItem[] = []
340
+ protected deleteNamespaceAnalysis(key: string, rootKey: string): DomainImpactItem[] {
341
+ const result: DomainImpactItem[] = []
342
342
  const ns = this.root.findNamespace(key)
343
343
  if (!ns) {
344
344
  return result
@@ -363,8 +363,8 @@ export class ImpactAnalysis {
363
363
  return result
364
364
  }
365
365
 
366
- protected deleteDataModelAnalysis(key: string, rootKey: string): ImpactItem[] {
367
- const result: ImpactItem[] = []
366
+ protected deleteDataModelAnalysis(key: string, rootKey: string): DomainImpactItem[] {
367
+ const result: DomainImpactItem[] = []
368
368
  const model = this.root.findDataModel(key)
369
369
  if (!model) {
370
370
  return result
@@ -383,8 +383,8 @@ export class ImpactAnalysis {
383
383
  return result
384
384
  }
385
385
 
386
- protected deleteEntityAnalysis(key: string, rootKey: string): ImpactItem[] {
387
- const result: ImpactItem[] = []
386
+ protected deleteEntityAnalysis(key: string, rootKey: string): DomainImpactItem[] {
387
+ const result: DomainImpactItem[] = []
388
388
  const entity = this.root.findEntity(key)
389
389
  if (!entity) {
390
390
  return result
@@ -415,12 +415,14 @@ export class ImpactAnalysis {
415
415
  })
416
416
  if (children.length) {
417
417
  children.forEach((child) => {
418
+ const pLabel = entity.info.renderLabel
419
+ const cLabel = child.info.renderLabel
418
420
  result.push({
419
421
  key: child.key,
420
422
  kind: child.kind,
421
423
  type: 'delete',
422
- impact: `The ${child.info.renderLabel} ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of ${entity.info.renderLabel}.`,
423
- resolution: `The ${entity.info.renderLabel} will be removed as the parent parent of ${child.info.renderLabel}.`,
424
+ impact: `The "${cLabel}" ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
425
+ resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
424
426
  blocking: true,
425
427
  relationship: 'child',
426
428
  })
@@ -468,8 +470,8 @@ export class ImpactAnalysis {
468
470
  return result
469
471
  }
470
472
 
471
- protected deletePropertyAnalysis(key: string): ImpactItem[] {
472
- const result: ImpactItem[] = []
473
+ protected deletePropertyAnalysis(key: string): DomainImpactItem[] {
474
+ const result: DomainImpactItem[] = []
473
475
  const property = this.root.findProperty(key)
474
476
  if (!property) {
475
477
  return result
@@ -484,8 +486,8 @@ export class ImpactAnalysis {
484
486
  return result
485
487
  }
486
488
 
487
- protected deleteAssociationAnalysis(key: string): ImpactItem[] {
488
- const result: ImpactItem[] = []
489
+ protected deleteAssociationAnalysis(key: string): DomainImpactItem[] {
490
+ const result: DomainImpactItem[] = []
489
491
  const association = this.root.findAssociation(key)
490
492
  if (!association) {
491
493
  return result
@@ -500,7 +502,7 @@ export class ImpactAnalysis {
500
502
  return result
501
503
  }
502
504
 
503
- protected kindToLabel(kind: ImpactKinds): string {
505
+ protected kindToLabel(kind: DomainImpactKinds): string {
504
506
  switch (kind) {
505
507
  case DataNamespaceKind:
506
508
  return 'namespace'
@@ -6,7 +6,7 @@ export interface DataDomainRemoveOptions {
6
6
  * For example, when removing an entity that is a parent to another entity, it will
7
7
  * removed itself as a parent from the child entity.
8
8
  *
9
- * Note, this option should only be used when the ImpactAnalysis has been performed
9
+ * Note, this option should only be used when the DomainImpactAnalysis has been performed
10
10
  * and the user was informed of the impact.
11
11
  */
12
12
  force?: boolean
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { ImpactAnalysis } from '../../../src/modeling/ImpactAnalysis.js'
2
+ import { DomainImpactAnalysis } from '../../../src/modeling/DomainImpactAnalysis.js'
3
3
  import {
4
4
  DataNamespaceKind,
5
5
  DataEntityKind,
@@ -13,9 +13,9 @@ import { DataModel } from '../../../src/modeling/DataModel.js'
13
13
  import { DataProperty } from '../../../src/modeling/DataProperty.js'
14
14
  import { DataAssociation } from '../../../src/modeling/DataAssociation.js'
15
15
 
16
- test.group('ImpactAnalysis', (group) => {
16
+ test.group('DomainImpactAnalysis', (group) => {
17
17
  let root: DataNamespace
18
- let analyzer: ImpactAnalysis
18
+ let analyzer: DomainImpactAnalysis
19
19
  let n1: DataNamespace
20
20
  let n2: DataNamespace
21
21
  let m1: DataModel
@@ -30,7 +30,7 @@ test.group('ImpactAnalysis', (group) => {
30
30
 
31
31
  group.each.setup(() => {
32
32
  root = new DataNamespace()
33
- analyzer = new ImpactAnalysis(root)
33
+ analyzer = new DomainImpactAnalysis(root)
34
34
  n1 = root.addNamespace('n1')
35
35
  m1 = root.addDataModel('m1')
36
36
  n2 = n1.addNamespace('n2')
@@ -114,8 +114,8 @@ test.group('ImpactAnalysis', (group) => {
114
114
  assert.equal(e4r.key, e4.key)
115
115
  assert.equal(e4r.kind, DataEntityKind)
116
116
  assert.equal(e4r.type, 'delete')
117
- assert.equal(e4r.impact, `The e4 entity will become an orphan because it is a child of e3.`)
118
- assert.equal(e4r.resolution, `The e3 will be removed as the parent parent of e4.`)
117
+ assert.equal(e4r.impact, `The "e4" entity will become an orphan because it is a child of the "e3" entity.`)
118
+ assert.equal(e4r.resolution, `The "e3" entity will be removed as the parent of the "e4" entity.`)
119
119
  assert.isTrue(e4r.blocking)
120
120
  assert.equal(e4r.relationship, 'child')
121
121
 
@@ -189,8 +189,8 @@ test.group('ImpactAnalysis', (group) => {
189
189
  assert.equal(e3r.key, e3.key)
190
190
  assert.equal(e3r.kind, DataEntityKind)
191
191
  assert.equal(e3r.type, 'delete')
192
- assert.equal(e3r.impact, `The e3 entity will become an orphan because it is a child of e1.`)
193
- assert.equal(e3r.resolution, `The e1 will be removed as the parent parent of e3.`)
192
+ assert.equal(e3r.impact, `The "e3" entity will become an orphan because it is a child of the "e1" entity.`)
193
+ assert.equal(e3r.resolution, `The "e1" entity will be removed as the parent of the "e3" entity.`)
194
194
  assert.isTrue(e3r.blocking)
195
195
  assert.equal(e3r.relationship, 'child')
196
196
  })
@@ -234,8 +234,8 @@ test.group('ImpactAnalysis', (group) => {
234
234
  assert.equal(e3r.key, e3.key)
235
235
  assert.equal(e3r.kind, DataEntityKind)
236
236
  assert.equal(e3r.type, 'delete')
237
- assert.equal(e3r.impact, `The e3 entity will become an orphan because it is a child of e1.`)
238
- assert.equal(e3r.resolution, `The e1 will be removed as the parent parent of e3.`)
237
+ assert.equal(e3r.impact, `The "e3" entity will become an orphan because it is a child of the "e1" entity.`)
238
+ assert.equal(e3r.resolution, `The "e1" entity will be removed as the parent of the "e3" entity.`)
239
239
  assert.isTrue(e3r.blocking)
240
240
  assert.equal(e3r.relationship, 'child')
241
241
  })
@@ -304,8 +304,8 @@ test.group('ImpactAnalysis', (group) => {
304
304
  assert.equal(e2r.key, e2.key)
305
305
  assert.equal(e2r.kind, DataEntityKind)
306
306
  assert.equal(e2r.type, 'delete')
307
- assert.equal(e2r.impact, `The e2 entity will become an orphan because it is a child of e3.`)
308
- assert.equal(e2r.resolution, `The e3 will be removed as the parent parent of e2.`)
307
+ assert.equal(e2r.impact, `The "e2" entity will become an orphan because it is a child of the "e3" entity.`)
308
+ assert.equal(e2r.resolution, `The "e3" entity will be removed as the parent of the "e2" entity.`)
309
309
  assert.isTrue(e2r.blocking)
310
310
  assert.equal(e2r.relationship, 'child')
311
311
 
@@ -313,8 +313,8 @@ test.group('ImpactAnalysis', (group) => {
313
313
  assert.equal(e4r.key, e4.key)
314
314
  assert.equal(e4r.kind, DataEntityKind)
315
315
  assert.equal(e4r.type, 'delete')
316
- assert.equal(e4r.impact, `The e4 entity will become an orphan because it is a child of e3.`)
317
- assert.equal(e4r.resolution, `The e3 will be removed as the parent parent of e4.`)
316
+ assert.equal(e4r.impact, `The "e4" entity will become an orphan because it is a child of the "e3" entity.`)
317
+ assert.equal(e4r.resolution, `The "e3" entity will be removed as the parent of the "e4" entity.`)
318
318
  assert.isTrue(e4r.blocking)
319
319
  assert.equal(e4r.relationship, 'child')
320
320
  })
@@ -365,8 +365,8 @@ test.group('ImpactAnalysis', (group) => {
365
365
  assert.equal(e3r.key, e3.key)
366
366
  assert.equal(e3r.kind, DataEntityKind)
367
367
  assert.equal(e3r.type, 'delete')
368
- assert.equal(e3r.impact, `The e3 entity will become an orphan because it is a child of e1.`)
369
- assert.equal(e3r.resolution, `The e1 will be removed as the parent parent of e3.`)
368
+ assert.equal(e3r.impact, `The "e3" entity will become an orphan because it is a child of the "e1" entity.`)
369
+ assert.equal(e3r.resolution, `The "e1" entity will be removed as the parent of the "e3" entity.`)
370
370
  assert.isTrue(e3r.blocking)
371
371
  assert.equal(e3r.relationship, 'child')
372
372
  })
@@ -1 +0,0 @@
1
- {"version":3,"file":"ImpactAnalysis.d.ts","sourceRoot":"","sources":["../../../src/modeling/ImpactAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,WAAW,GACnB,OAAO,iBAAiB,GACxB,OAAO,cAAc,GACrB,OAAO,aAAa,GACpB,OAAO,gBAAgB,GACvB,OAAO,mBAAmB,CAAA;AAE9B;;GAEG;AACH,UAAU,YAAY;IACpB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,IAAI,EAAE,WAAW,CAAA;IACjB;;OAEG;IACH,MAAM,EAAE,UAAU,EAAE,CAAA;IACpB;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,UAAU,UAAU;IAClB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,IAAI,EAAE,QAAQ,CAAA;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;QAClD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,MAAM,CAAA;QACf,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,WAAW,CAAC,GAAG;YACpB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,mBAAmB;YACvG,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IAES,WAAW,CAAC,IAAiB;QACrC,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,iBAAiB;gBACpB,OAAO,WAAW,CAAA;YACpB,KAAK,cAAc;gBACjB,OAAO,QAAQ,CAAA;YACjB,KAAK,aAAa;gBAChB,OAAO,YAAY,CAAA;YACrB,KAAK,gBAAgB;gBACnB,OAAO,UAAU,CAAA;YACnB,KAAK,mBAAmB;gBACtB,OAAO,aAAa,CAAA;YACtB;gBACE,OAAO,SAAS,CAAA;QACpB,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n DataNamespaceKind,\n DataEntityKind,\n DataModelKind,\n DataPropertyKind,\n DataAssociationKind,\n} from '../models/kinds.js'\nimport type { DataNamespace } from './DataNamespace.js'\n\nexport type ImpactKinds =\n | typeof DataNamespaceKind\n | typeof DataEntityKind\n | typeof DataModelKind\n | typeof DataPropertyKind\n | typeof DataAssociationKind\n\n/**\n * The impact analysis report\n */\ninterface ImpactReport {\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: ImpactKinds\n /**\n * The list of impacted data objects.\n */\n impact: ImpactItem[]\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\ninterface ImpactItem {\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'\n /**\n * The impact description.\n */\n impact: string\n /**\n * Whether the impact is blocking the operation.\n * If true, the operation cannot proceed.\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\n/**\n * # ImpactAnalysis\n *\n * The `ImpactAnalysis` class is a powerful tool for analyzing the consequences of deleting data domain objects\n * within a `DataNamespace`.\n * It helps developers understand the ripple effects of removing a namespace, data model, entity, property,\n * or association, ensuring data integrity and preventing unintended side effects.\n *\n * ## Core Concepts\n *\n * - **Impact Report:** The central output of the `ImpactAnalysis` class is an `ImpactReport`. This report details the\n * potential consequences of a deletion operation, including:\n * - The object being deleted (`key`, `kind`).\n * - A list of `ImpactItem` objects, each describing a specific consequence.\n * - Whether the deletion can proceed safely (`canProceed`).\n *\n * - **ImpactItem:** Each `ImpactItem` describes a specific consequence of the deletion. 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 `ImpactAnalysis`, passing the root `DataNamespace` as an argument.\n *\n * ```typescript\n * import { DataNamespace } from './DataNamespace'; // Assuming DataNamespace is in the same directory\n * import { ImpactAnalysis } from './ImpactAnalysis'; // Assuming ImpactAnalysis is in the same directory\n *\n * const rootNamespace = new DataNamespace();\n * // ... add some data to the namespace\n * const analyzer = new ImpactAnalysis(rootNamespace);\n * ```\n *\n * 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `ImpactReport` for a specific deletion.\n * Provide the `key` and `kind` of the object to be deleted.\n *\n * ```typescript\n * import { DataEntityKind } from '../models/kinds.js';\n * // ...\n * const entityKey = 'some-entity-key';\n * const report = analyzer.deleteAnalysis(entityKey, DataEntityKind);\n * ```\n *\n * 3. **Interpreting the Report:** Examine the `ImpactReport` 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 `ImpactAnalysis` class supports analyzing the deletion of the following data domain object types:\n *\n * - **Namespaces (`DataNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,\n * data models, entities, properties, and associations.\n * - **Data Models (`DataModelKind`):** Deleting a data model impacts all its entities, properties, and associations.\n * - **Entities (`DataEntityKind`):** 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 (`DataPropertyKind`):** Deleting a property impacts the entity it belongs to.\n * - **Associations (`DataAssociationKind`):** Deleting an association impacts the entity it belongs to.\n *\n * ## Example: Deleting an Entity\n *\n * Consider the following scenario:\n *\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 * If you attempt to delete the `Product` entity, the `ImpactAnalysis` will generate a report similar to this:\n *\n * ```json\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DataEntityKind\",\n * \"impact\": [\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DataEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The entity with key Product will be deleted.\",\n * \"blocking\": false\n * },\n * {\n * \"key\": \"SpecialProduct\",\n * \"kind\": \"DataEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The SpecialProduct entity will become an orphan because it is a child of Product.\",\n * \"resolution\": \"The Product will be removed as the parent parent of SpecialProduct.\",\n * \"blocking\": true,\n * \"relationship\": \"child\"\n * },\n * {\n * \"key\": \"category\",\n * \"kind\": \"DataAssociationKind\",\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\": \"DataPropertyKind\",\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 * ### `ImpactKinds`\n *\n * - **Description:** A type alias for the kinds of data domain objects that can be analyzed.\n * - **Values:**\n * - `DataNamespaceKind`\n * - `DataEntityKind`\n * - `DataModelKind`\n * - `DataPropertyKind`\n * - `DataAssociationKind`\n *\n * ### `ImpactReport`\n *\n * - **Description:** The structure of the impact analysis report.\n * - **Properties:**\n * - `key` (`string`): The key of the object being deleted.\n * - `kind` (`ImpactKinds`): The kind of the object being deleted.\n * - `impact` (`ImpactItem[]`): The list of impacts.\n * - `canProceed` (`boolean`): Whether the deletion can proceed.\n *\n * ### `ImpactItem`\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 `ImpactAnalysis` class does not throw errors. Instead, it uses the `ImpactReport` 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 object, always use `ImpactAnalysis`\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 `ImpactAnalysis` 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 ImpactAnalysis {\n private report: ImpactReport\n private root: DataNamespace\n\n constructor(root: DataNamespace) {\n this.root = root\n this.report = {\n key: '',\n kind: DataNamespaceKind,\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: ImpactKinds): ImpactReport {\n this.report = {\n key,\n kind,\n impact: [],\n canProceed: true,\n }\n this.report.impact = this.createDeleteImpact(key, kind, key)\n // this.report.impact.unshift({\n // key,\n // kind,\n // type: 'delete',\n // impact: `The ${this.kindToLabel(kind)} with key ${key} will be deleted.`,\n // blocking: false,\n // })\n return this.report\n }\n\n protected createDeleteImpact(key: string, kind: ImpactKinds, rootKey: string): ImpactItem[] {\n switch (kind) {\n case DataNamespaceKind:\n return this.deleteNamespaceAnalysis(key, rootKey)\n case DataModelKind:\n return this.deleteDataModelAnalysis(key, rootKey)\n case DataEntityKind:\n return this.deleteEntityAnalysis(key, rootKey)\n case DataPropertyKind:\n return this.deletePropertyAnalysis(key)\n case DataAssociationKind:\n return this.deleteAssociationAnalysis(key)\n default:\n return []\n }\n }\n\n protected deleteNamespaceAnalysis(key: string, rootKey: string): ImpactItem[] {\n const result: ImpactItem[] = []\n const ns = this.root.findNamespace(key)\n if (!ns) {\n return result\n }\n result.push({\n key: ns.key,\n kind: ns.kind,\n type: 'delete',\n impact: `The ${ns.info.renderLabel} ${this.kindToLabel(DataNamespaceKind)} will be deleted.`,\n blocking: false,\n })\n const namespaces = ns.listNamespaces()\n namespaces.forEach((child) => {\n const items = this.deleteNamespaceAnalysis(child.key, rootKey)\n result.push(...items)\n })\n const models = ns.listDataModels()\n models.forEach((child) => {\n const items = this.deleteDataModelAnalysis(child.key, rootKey)\n result.push(...items)\n })\n return result\n }\n\n protected deleteDataModelAnalysis(key: string, rootKey: string): ImpactItem[] {\n const result: ImpactItem[] = []\n const model = this.root.findDataModel(key)\n if (!model) {\n return result\n }\n result.push({\n key: model.key,\n kind: model.kind,\n type: 'delete',\n impact: `The ${model.info.renderLabel} ${this.kindToLabel(DataModelKind)} will be deleted.`,\n blocking: false,\n })\n model.entities.forEach((child) => {\n const items = this.deleteEntityAnalysis(child.key, rootKey)\n result.push(...items)\n })\n return result\n }\n\n protected deleteEntityAnalysis(key: string, rootKey: string): ImpactItem[] {\n const result: ImpactItem[] = []\n const entity = this.root.findEntity(key)\n if (!entity) {\n return result\n }\n result.push({\n key: entity.key,\n kind: entity.kind,\n type: 'delete',\n impact: `The ${entity.info.renderLabel} ${this.kindToLabel(DataEntityKind)} will be deleted.`,\n blocking: false,\n })\n // We need to know whether the entity is a parent of another entity\n const children = this.root.definitions.entities.filter((domainEntity) => {\n if (domainEntity.key === entity.key) {\n // ignore self\n return false\n }\n if (!domainEntity.parents.includes(entity.key)) {\n // no relationship\n return false\n }\n if (domainEntity.isChildOf(rootKey)) {\n // No need to include this parent as it itself is being deleted\n return false\n }\n // the entity has a parent-child relationship to the deleted entity.\n return true\n })\n if (children.length) {\n children.forEach((child) => {\n result.push({\n key: child.key,\n kind: child.kind,\n type: 'delete',\n impact: `The ${child.info.renderLabel} ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of ${entity.info.renderLabel}.`,\n resolution: `The ${entity.info.renderLabel} will be removed as the parent parent of ${child.info.renderLabel}.`,\n blocking: true,\n relationship: 'child',\n })\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 const inAssociations = this.root.definitions.associations.filter((association) => {\n return association.targets.some((item) => {\n if (item.key === entity.key) {\n const related = association.getParentInstance()\n if (!related) {\n return false\n }\n if (related.isChildOf(rootKey)) {\n // No need to include this association as the related entity itself is being deleted\n return false\n }\n return true\n }\n return false\n })\n })\n if (inAssociations.length) {\n inAssociations.forEach((association) => {\n result.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be broken because it has a target to ${entity.info.renderLabel}.`,\n resolution: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be removed from ${entity.info.renderLabel}.`,\n blocking: true,\n })\n })\n this.report.canProceed = false\n }\n entity.properties.forEach((child) => {\n const items = this.deletePropertyAnalysis(child.key)\n result.push(...items)\n })\n entity.associations.forEach((child) => {\n const items = this.deleteAssociationAnalysis(child.key)\n result.push(...items)\n })\n return result\n }\n\n protected deletePropertyAnalysis(key: string): ImpactItem[] {\n const result: ImpactItem[] = []\n const property = this.root.findProperty(key)\n if (!property) {\n return result\n }\n result.push({\n key: property.key,\n kind: property.kind,\n type: 'delete',\n impact: `The ${property.info.renderLabel} ${this.kindToLabel(DataPropertyKind)} will be deleted.`,\n blocking: false,\n })\n return result\n }\n\n protected deleteAssociationAnalysis(key: string): ImpactItem[] {\n const result: ImpactItem[] = []\n const association = this.root.findAssociation(key)\n if (!association) {\n return result\n }\n result.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be deleted.`,\n blocking: false,\n })\n return result\n }\n\n protected kindToLabel(kind: ImpactKinds): string {\n switch (kind) {\n case DataNamespaceKind:\n return 'namespace'\n case DataEntityKind:\n return 'entity'\n case DataModelKind:\n return 'data model'\n case DataPropertyKind:\n return 'property'\n case DataAssociationKind:\n return 'association'\n default:\n return 'unknown'\n }\n }\n}\n"]}