@api-client/core 0.14.0 → 0.14.2

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 (169) hide show
  1. package/build/src/amf/AmfTypes.d.ts +1 -1
  2. package/build/src/amf/AmfTypes.js +1 -1
  3. package/build/src/amf/AmfTypes.js.map +1 -1
  4. package/build/src/amf/Utils.d.ts +0 -6
  5. package/build/src/amf/Utils.d.ts.map +1 -1
  6. package/build/src/amf/Utils.js +0 -14
  7. package/build/src/amf/Utils.js.map +1 -1
  8. package/build/src/browser.d.ts +2 -1
  9. package/build/src/browser.d.ts.map +1 -1
  10. package/build/src/browser.js +1 -0
  11. package/build/src/browser.js.map +1 -1
  12. package/build/src/index.d.ts +2 -1
  13. package/build/src/index.d.ts.map +1 -1
  14. package/build/src/index.js +1 -0
  15. package/build/src/index.js.map +1 -1
  16. package/build/src/legacy.d.ts +0 -8
  17. package/build/src/legacy.d.ts.map +1 -1
  18. package/build/src/legacy.js +0 -9
  19. package/build/src/legacy.js.map +1 -1
  20. package/build/src/modeling/Bindings.d.ts +1 -1
  21. package/build/src/modeling/Bindings.js.map +1 -1
  22. package/build/src/modeling/DataDomain.js +2 -2
  23. package/build/src/modeling/DataDomain.js.map +1 -1
  24. package/build/src/modeling/DataFormat.d.ts +0 -40
  25. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  26. package/build/src/modeling/DataFormat.js +0 -27
  27. package/build/src/modeling/DataFormat.js.map +1 -1
  28. package/build/src/modeling/DomainAssociation.d.ts +63 -0
  29. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  30. package/build/src/modeling/DomainAssociation.js +110 -4
  31. package/build/src/modeling/DomainAssociation.js.map +1 -1
  32. package/build/src/modeling/DomainEntity.d.ts +25 -9
  33. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  34. package/build/src/modeling/DomainEntity.js +65 -21
  35. package/build/src/modeling/DomainEntity.js.map +1 -1
  36. package/build/src/modeling/DomainFile.d.ts +1 -1
  37. package/build/src/modeling/DomainFile.js +1 -1
  38. package/build/src/modeling/DomainFile.js.map +1 -1
  39. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  42. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  43. package/build/src/modeling/DomainModel.d.ts +2 -2
  44. package/build/src/modeling/DomainModel.js +2 -2
  45. package/build/src/modeling/DomainModel.js.map +1 -1
  46. package/build/src/modeling/DomainProperty.d.ts +28 -12
  47. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  48. package/build/src/modeling/DomainProperty.js +61 -26
  49. package/build/src/modeling/DomainProperty.js.map +1 -1
  50. package/build/src/modeling/Semantics.d.ts +117 -0
  51. package/build/src/modeling/Semantics.d.ts.map +1 -0
  52. package/build/src/modeling/Semantics.js +112 -0
  53. package/build/src/modeling/Semantics.js.map +1 -0
  54. package/build/src/models/kinds.d.ts +0 -24
  55. package/build/src/models/kinds.d.ts.map +1 -1
  56. package/build/src/models/kinds.js +0 -24
  57. package/build/src/models/kinds.js.map +1 -1
  58. package/build/src/models/store/data_catalog.d.ts +1 -1
  59. package/build/src/models/store/data_catalog.js.map +1 -1
  60. package/build/tsconfig.tsbuildinfo +1 -1
  61. package/data/models/APIC-187.json +3 -3
  62. package/data/models/APIC-188.json +3 -3
  63. package/data/models/APIC-233.json +1 -1
  64. package/data/models/APIC-391.json +2 -2
  65. package/data/models/APIC-483.json +1 -1
  66. package/data/models/APIC-487.json +1 -1
  67. package/data/models/APIC-655.json +1 -1
  68. package/data/models/APIC-689.json +1 -1
  69. package/data/models/APIC-690.json +5 -5
  70. package/data/models/SE-10469.json +1 -1
  71. package/data/models/SE-13092.json +5 -5
  72. package/data/models/SE-22063.json +12 -2
  73. package/data/models/amf-helper-api.json +154 -14
  74. package/data/models/arc-demo-api.json +95 -15
  75. package/data/models/async-api.json +1 -1
  76. package/data/models/example-generator-api.json +369 -29
  77. package/data/models/expanded-api.json +1 -1
  78. package/data/models/flattened-api.json +1 -1
  79. package/data/models/multiple-servers.json +1 -1
  80. package/data/models/oas-3-api.json +1 -1
  81. package/data/models/oas-date.json +1 -1
  82. package/data/models/oas-types.json +1 -1
  83. package/data/models/oas-unions.json +1 -1
  84. package/data/models/petstore.json +1 -1
  85. package/data/models/raml-date.json +1 -1
  86. package/data/models/recursive.json +1 -1
  87. package/data/models/schema-api.json +62 -2
  88. package/data/models/secured-api.json +16 -16
  89. package/data/models/tracked-to-linked.json +4 -4
  90. package/package.json +2 -2
  91. package/src/amf/AmfTypes.ts +1 -1
  92. package/src/amf/Utils.ts +0 -15
  93. package/src/modeling/Bindings.ts +1 -1
  94. package/src/modeling/DataDomain.ts +2 -2
  95. package/src/modeling/DataFormat.ts +0 -48
  96. package/src/modeling/DomainAssociation.ts +122 -3
  97. package/src/modeling/DomainEntity.ts +56 -17
  98. package/src/modeling/DomainFile.ts +1 -1
  99. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  100. package/src/modeling/DomainModel.ts +2 -2
  101. package/src/modeling/DomainProperty.ts +60 -21
  102. package/src/modeling/Semantics.ts +195 -0
  103. package/src/modeling/graph.md +14 -14
  104. package/src/modeling/readme.md +29 -29
  105. package/src/models/kinds.ts +0 -25
  106. package/src/models/store/data_catalog.ts +1 -1
  107. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  108. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  109. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  110. package/tests/unit/modeling/domain_asociation.spec.ts +267 -0
  111. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  112. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  113. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  114. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  115. package/tests/unit/modeling/semantics.spec.ts +149 -0
  116. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  117. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  118. package/build/src/amf/AmfShapeGenerator.js +0 -416
  119. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  120. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  121. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  122. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  123. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  124. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  125. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  126. package/build/src/modeling/legacy/DataEntity.js +0 -855
  127. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  128. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  129. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  130. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  131. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  132. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  133. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  134. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  135. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  136. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  137. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  138. package/build/src/modeling/legacy/DataModel.js +0 -237
  139. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  140. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  141. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  142. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  143. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  144. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  145. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  146. package/build/src/modeling/legacy/DataProperty.js +0 -415
  147. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  148. package/build/src/models/store/DataFile.d.ts +0 -29
  149. package/build/src/models/store/DataFile.d.ts.map +0 -1
  150. package/build/src/models/store/DataFile.js +0 -87
  151. package/build/src/models/store/DataFile.js.map +0 -1
  152. package/src/amf/AmfShapeGenerator.ts +0 -477
  153. package/src/modeling/legacy/DataAssociation.ts +0 -554
  154. package/src/modeling/legacy/DataEntity.ts +0 -1019
  155. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  156. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  157. package/src/modeling/legacy/DataModel.ts +0 -276
  158. package/src/modeling/legacy/DataNamespace.ts +0 -929
  159. package/src/modeling/legacy/DataProperty.ts +0 -630
  160. package/src/models/store/DataFile.ts +0 -95
  161. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  162. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  163. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  164. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  165. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  166. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  167. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  168. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  169. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -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,EA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AC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAA;oBACnE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;wBACnB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;4BAC3B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAgB,CAAC,CAAA;4BACjF,IAAI,CAAC,YAAY,EAAE,CAAC;gCAClB,SAAQ;4BACV,CAAC;4BACD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;4BAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;4BACrC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;4BAC3C,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.deleteDataModelAnalysis(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.deleteDataModelAnalysis(child.key, rootKey)\n }\n }\n\n protected deleteDataModelAnalysis(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,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C;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"]}
@@ -53,10 +53,10 @@ export interface DomainModelSchema extends DomainElementSchema {
53
53
  *
54
54
  * ```typescript
55
55
  * const dataDomain = new DataDomain();
56
- * const dataNamespace = dataDomain.addNamespace({
56
+ * const ns = dataDomain.addNamespace({
57
57
  * key: 'myNamespace',
58
58
  * });
59
- * const userModel = dataNamespace.addModel({
59
+ * const userModel = ns.addModel({
60
60
  * key: 'userModel',
61
61
  * info: { name: 'User Model' },
62
62
  * });
@@ -32,10 +32,10 @@ import { DetachException } from '../exceptions/detach_exception.js';
32
32
  *
33
33
  * ```typescript
34
34
  * const dataDomain = new DataDomain();
35
- * const dataNamespace = dataDomain.addNamespace({
35
+ * const ns = dataDomain.addNamespace({
36
36
  * key: 'myNamespace',
37
37
  * });
38
- * const userModel = dataNamespace.addModel({
38
+ * const userModel = ns.addModel({
39
39
  * key: 'userModel',
40
40
  * info: { name: 'User Model' },
41
41
  * });
@@ -1 +1 @@
1
- {"version":3,"file":"DomainModel.js","sourceRoot":"","sources":["../../../src/modeling/DomainModel.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGxD,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AA+BnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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{ DomainEntityKind, DomainModelKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from './observed.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport { DomainEntity, type DomainEntitySchema } from './DomainEntity.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\n\nexport interface ModelOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'entity'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainModelSchema extends DomainElementSchema {\n kind: typeof DomainModelKind\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The ordered list of entities in the schema.\n */\n fields?: ModelOrderedItem[]\n\n /**\n * Whether this model is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents a data model within a data domain.\n *\n * A `DomainModel` groups related `DomainEntity` instances, providing a logical structure for organizing\n * data. It acts as a container for entities that share a common purpose or context.\n *\n * **Key Features:**\n *\n * - **Entity Container:** Holds a collection of `DomainEntity` instances.\n * - **Logical Grouping:** Organizes entities into meaningful groups.\n * - **Metadata:** Supports a description for the data model.\n * - **Namespace Integration:** Belongs to a `DomainNamespace`, creating a hierarchical structure.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainModel` is through\n * the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const dataNamespace = dataDomain.addNamespace({\n * key: 'myNamespace',\n * });\n * const userModel = dataNamespace.addModel({\n * key: 'userModel',\n * info: { name: 'User Model' },\n * });\n * ```\n */\nexport class DomainModel extends DomainElement {\n override kind: typeof DomainModelKind\n\n /**\n * The description of the domain model.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of entities in the schema.\n */\n accessor fields: ModelOrderedItem[]\n /**\n * Whether this model is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data model schema with defaults.\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainModelSchema> = {}): DomainModelSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New model' }).toJSON()\n const result: DomainModelSchema = {\n kind: DomainModelKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new model instance.\n *\n * You should use the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial model schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainModelSchema>) {\n const init = DomainModel.createSchema(input)\n super(root, init.key)\n this.kind = DomainModelKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n /**\n * Generates a JSON representation of the data model.\n *\n * @returns A plain object representation of the\n * `DomainModel`.\n * @example\n * ```typescript\n * const json = userModel.toJSON();\n * console.log(json);\n * ```\n */\n toJSON(): DomainModelSchema {\n const result: DomainModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns the parent namespace where this data model\n * exists.\n *\n * @returns The parent `DomainNamespace`.\n * @throws Error When no parent is found.\n * @example\n * ```typescript\n * const parent = userModel.getParentInstance();\n * console.log(parent.key);\n * ```\n */\n getParentInstance(): DomainNamespace | DataDomain {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Adds a child entity to the current model.\n *\n * @param value The partial entity schema.\n * @returns The created entity instance.\n * @example\n * ```typescript\n * const entity = model.addEntity({\n * key: 'address',\n * info: { name: 'Address' },\n * })\n * ```\n */\n addEntity(input?: Partial<DomainEntitySchema>): DomainEntity {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Entity with key ${input?.key} already exists`)\n }\n const item = new DomainEntity(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n key: item.key,\n type: 'entity',\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an entity from the current model.\n *\n * @param key The key of the model to remove.\n * @throws {RemoveEntityException} If the model does not exist.\n * @example\n * ```typescript\n * model.removeEntity('address')\n * ```\n */\n removeEntity(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not a child of this model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * Attaches an entity to the current model. It changes the parent of the entity\n * to the current model in the graph.\n *\n * The attached entity must be already a child of another model. It detaches the entity\n * from the previous model.\n *\n * @param key The key of the entity to attach.\n * @throws {AttachException} If the entity does not exist.\n * @throws {AttachException} If passed key doesn't belong to an entity.\n * @throws {AttachException} When the entity is already a child of the current model.\n * @throws {AttachException} If the entity is not in the same domain.\n * @example\n * ```typescript\n * model.attachEntity('address')\n * ```\n */\n attachEntity(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a entity`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not in the same domain`)\n }\n const parent = node.getParentInstance() as DomainModel\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n parent.detachEntity(key)\n this.fields.push({\n type: 'entity',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches an entity from the current model. It changes the parent of the entity\n * to the root graph.\n * Unlike remove, it doesn't remove the entity from the graph nor notifies the change.\n * @param key The key of the entity to detach.\n * @throws {DetachException} If the entity does not exist.\n * @throws {DetachException} If passed key doesn't belong to an entity.\n * @throws {DetachException} When the entity is not a child of the current model.\n */\n detachEntity(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not a child of this model`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all entities.\n *\n * Note, it accounts for the order of the entities as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of model.listEntities()) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(): Generator<DomainEntity> {\n for (const { key, type } of this.fields) {\n if (type !== 'entity') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this model has any entities.\n *\n * @returns True if the model has entities.\n * @example\n * ```typescript\n * if (model.hasEntities()) {\n * // ...\n * }\n * ```\n */\n hasEntities(): boolean {\n return this.fields.some((item) => item.type === 'entity')\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed model'),\n kind: DomainModelKind,\n })\n let parent: DomainNamespace | DataDomain = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n const typed = parent as DomainNamespace\n parent = typed.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks if this model has any fields (entities).\n *\n * @returns True if the model has fields.\n * @example\n * ```typescript\n * if (model.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
1
+ {"version":3,"file":"DomainModel.js","sourceRoot":"","sources":["../../../src/modeling/DomainModel.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,E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iB,EAAE,CAAA;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAA;YACd,CAAC;YACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAQ,MAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;;;SAxVU,WAAW","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainEntityKind, DomainModelKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from './observed.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport { DomainEntity, type DomainEntitySchema } from './DomainEntity.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\n\nexport interface ModelOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'entity'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainModelSchema extends DomainElementSchema {\n kind: typeof DomainModelKind\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The ordered list of entities in the schema.\n */\n fields?: ModelOrderedItem[]\n\n /**\n * Whether this model is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents a data model within a data domain.\n *\n * A `DomainModel` groups related `DomainEntity` instances, providing a logical structure for organizing\n * data. It acts as a container for entities that share a common purpose or context.\n *\n * **Key Features:**\n *\n * - **Entity Container:** Holds a collection of `DomainEntity` instances.\n * - **Logical Grouping:** Organizes entities into meaningful groups.\n * - **Metadata:** Supports a description for the data model.\n * - **Namespace Integration:** Belongs to a `DomainNamespace`, creating a hierarchical structure.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainModel` is through\n * the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const ns = dataDomain.addNamespace({\n * key: 'myNamespace',\n * });\n * const userModel = ns.addModel({\n * key: 'userModel',\n * info: { name: 'User Model' },\n * });\n * ```\n */\nexport class DomainModel extends DomainElement {\n override kind: typeof DomainModelKind\n\n /**\n * The description of the domain model.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of entities in the schema.\n */\n accessor fields: ModelOrderedItem[]\n /**\n * Whether this model is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data model schema with defaults.\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainModelSchema> = {}): DomainModelSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New model' }).toJSON()\n const result: DomainModelSchema = {\n kind: DomainModelKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new model instance.\n *\n * You should use the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial model schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainModelSchema>) {\n const init = DomainModel.createSchema(input)\n super(root, init.key)\n this.kind = DomainModelKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n /**\n * Generates a JSON representation of the data model.\n *\n * @returns A plain object representation of the\n * `DomainModel`.\n * @example\n * ```typescript\n * const json = userModel.toJSON();\n * console.log(json);\n * ```\n */\n toJSON(): DomainModelSchema {\n const result: DomainModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns the parent namespace where this data model\n * exists.\n *\n * @returns The parent `DomainNamespace`.\n * @throws Error When no parent is found.\n * @example\n * ```typescript\n * const parent = userModel.getParentInstance();\n * console.log(parent.key);\n * ```\n */\n getParentInstance(): DomainNamespace | DataDomain {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Adds a child entity to the current model.\n *\n * @param value The partial entity schema.\n * @returns The created entity instance.\n * @example\n * ```typescript\n * const entity = model.addEntity({\n * key: 'address',\n * info: { name: 'Address' },\n * })\n * ```\n */\n addEntity(input?: Partial<DomainEntitySchema>): DomainEntity {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Entity with key ${input?.key} already exists`)\n }\n const item = new DomainEntity(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n key: item.key,\n type: 'entity',\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an entity from the current model.\n *\n * @param key The key of the model to remove.\n * @throws {RemoveEntityException} If the model does not exist.\n * @example\n * ```typescript\n * model.removeEntity('address')\n * ```\n */\n removeEntity(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not a child of this model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * Attaches an entity to the current model. It changes the parent of the entity\n * to the current model in the graph.\n *\n * The attached entity must be already a child of another model. It detaches the entity\n * from the previous model.\n *\n * @param key The key of the entity to attach.\n * @throws {AttachException} If the entity does not exist.\n * @throws {AttachException} If passed key doesn't belong to an entity.\n * @throws {AttachException} When the entity is already a child of the current model.\n * @throws {AttachException} If the entity is not in the same domain.\n * @example\n * ```typescript\n * model.attachEntity('address')\n * ```\n */\n attachEntity(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a entity`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not in the same domain`)\n }\n const parent = node.getParentInstance() as DomainModel\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n parent.detachEntity(key)\n this.fields.push({\n type: 'entity',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches an entity from the current model. It changes the parent of the entity\n * to the root graph.\n * Unlike remove, it doesn't remove the entity from the graph nor notifies the change.\n * @param key The key of the entity to detach.\n * @throws {DetachException} If the entity does not exist.\n * @throws {DetachException} If passed key doesn't belong to an entity.\n * @throws {DetachException} When the entity is not a child of the current model.\n */\n detachEntity(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not a child of this model`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all entities.\n *\n * Note, it accounts for the order of the entities as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of model.listEntities()) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(): Generator<DomainEntity> {\n for (const { key, type } of this.fields) {\n if (type !== 'entity') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this model has any entities.\n *\n * @returns True if the model has entities.\n * @example\n * ```typescript\n * if (model.hasEntities()) {\n * // ...\n * }\n * ```\n */\n hasEntities(): boolean {\n return this.fields.some((item) => item.type === 'entity')\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed model'),\n kind: DomainModelKind,\n })\n let parent: DomainNamespace | DataDomain = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n const typed = parent as DomainNamespace\n parent = typed.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks if this model has any fields (entities).\n *\n * @returns True if the model has fields.\n * @example\n * ```typescript\n * if (model.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
@@ -7,7 +7,8 @@ import type { PropertyBinding, PropertyBindings, PropertyWebBindings } from './B
7
7
  import type { ModelValidationOptions } from '../models/types.js';
8
8
  import type { DomainEntity } from './DomainEntity.js';
9
9
  import type { IApiPropertyShape } from '../amf/definitions/Shapes.js';
10
- import { PropertySchema } from './types.js';
10
+ import type { PropertySchema } from './types.js';
11
+ import { type SemanticType, type AppliedDataSemantic } from './Semantics.js';
11
12
  export interface DomainPropertySchema extends DomainElementSchema {
12
13
  kind: typeof DomainPropertyKind;
13
14
  /**
@@ -47,11 +48,11 @@ export interface DomainPropertySchema extends DomainElementSchema {
47
48
  */
48
49
  tags?: string[];
49
50
  /**
50
- * For future use.
51
- *
52
- * The keys of the taxonomy items associated with the property.
51
+ * The semantics applied to this property.
52
+ * This is a list of applied semantics that can be used to
53
+ * describe the property in more detail.
53
54
  */
54
- taxonomy?: string[];
55
+ semantics?: AppliedDataSemantic[];
55
56
  /**
56
57
  * The data type for this property.
57
58
  * Note, not all schemas support the same type. For example, defining `sint32`
@@ -90,21 +91,21 @@ export interface DomainPropertySchema extends DomainElementSchema {
90
91
  * - **Bindings:** Allows defining how the property is
91
92
  * represented in different formats (e.g., web APIs,
92
93
  * protocol buffers).
93
- * - **Metadata:** Supports metadata such as tags, taxonomy,
94
+ * - **Metadata:** Supports metadata such as tags, semantics,
94
95
  * read-only/write-only status, and deprecation.
95
96
  * - **Schema:** Allows defining a general schema for the
96
97
  * property, which is propagated to all bindings.
97
98
  *
98
99
  * **Usage:**
99
100
  *
100
- * Use the `DataEntity.addProperty` method to add a new property to an
101
+ * Use the `DomainEntity.addProperty` method to add a new property to an
101
102
  * entity. The property can be created using the constructor, but it
102
103
  * won't be added to the graph until you call the `addProperty` method.
103
104
  *
104
105
  * **Example:**
105
106
  *
106
107
  * ```typescript
107
- * const entity = dataModel.addEntity({ key: 'user' });
108
+ * const entity = domainModel.addEntity({ key: 'user' });
108
109
  * const property = entity.addProperty({
109
110
  * key: 'name',
110
111
  * type: 'string',
@@ -159,11 +160,9 @@ export declare class DomainProperty extends DomainElement {
159
160
  */
160
161
  accessor tags: string[];
161
162
  /**
162
- * Reserved for future use.
163
- *
164
- * The keys of the taxonomy items associated with the property.
163
+ * Semantics applied to this property.
165
164
  */
166
- accessor taxonomy: string[];
165
+ accessor semantics: AppliedDataSemantic[];
167
166
  /**
168
167
  * The data type for this property.
169
168
  * Note, not all schemas support the same type. For example, defining `sint32`
@@ -277,5 +276,22 @@ export declare class DomainProperty extends DomainElement {
277
276
  * @returns AMF property shape definition.
278
277
  */
279
278
  toApiShape(): IApiPropertyShape;
279
+ /**
280
+ * Adds or updates a semantic to the property.
281
+ * @param semantic The semantic to add to the property.
282
+ * @throws Error if the semantic is not an property semantic.
283
+ */
284
+ addSemantic(semantic: AppliedDataSemantic): void;
285
+ /**
286
+ * Removes a semantic from the property.
287
+ * @param semanticId The ID of the semantic to remove.
288
+ */
289
+ removeSemantic(semanticId: SemanticType): void;
290
+ /**
291
+ * Checks if the property has a specific semantic.
292
+ * @param semanticId The ID of the semantic to check.
293
+ * @returns True if the semantic is present, false otherwise.
294
+ */
295
+ hasSemantic(semanticId: SemanticType): boolean;
280
296
  }
281
297
  //# sourceMappingURL=DomainProperty.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomainProperty.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,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IAAI,IAAI;IAKd;;OAEG;IACH,iBAAiB,IAAI,YAAY,GAAG,SAAS;IAI7C;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB;IAO/D;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB;IAOzE;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB;IAiBnE;;;OAGG;IACH,YAAY,IAAI,cAAc;IAO9B;;;OAGG;IACH,aAAa,IAAI,mBAAmB;IASpC;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS;IAKnE;;;;;;;;;;;;OAYG;IACH,UAAU,IAAI,iBAAiB;IAK/B;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAchD;;;OAGG;IACH,cAAc,CAAC,UAAU,EAAE,YAAY,GAAG,IAAI;IAQ9C;;;;OAIG;IACH,WAAW,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO;CAG/C"}
@@ -6,6 +6,7 @@ import { Thing } from '../models/Thing.js';
6
6
  import { observed, retargetChange, toRaw } from './observed.js';
7
7
  import { BinaryFormats, DomainPropertyAttributes, DomainPropertyList, DomainPropertyTypes, NumberFormats, } from './DataFormat.js';
8
8
  import { ShapeGenerator } from './amf/ShapeGenerator.js';
9
+ import { DataSemantics, isPropertySemantic } from './Semantics.js';
9
10
  /**
10
11
  * Represents a property within a data domain entity.
11
12
  *
@@ -22,21 +23,21 @@ import { ShapeGenerator } from './amf/ShapeGenerator.js';
22
23
  * - **Bindings:** Allows defining how the property is
23
24
  * represented in different formats (e.g., web APIs,
24
25
  * protocol buffers).
25
- * - **Metadata:** Supports metadata such as tags, taxonomy,
26
+ * - **Metadata:** Supports metadata such as tags, semantics,
26
27
  * read-only/write-only status, and deprecation.
27
28
  * - **Schema:** Allows defining a general schema for the
28
29
  * property, which is propagated to all bindings.
29
30
  *
30
31
  * **Usage:**
31
32
  *
32
- * Use the `DataEntity.addProperty` method to add a new property to an
33
+ * Use the `DomainEntity.addProperty` method to add a new property to an
33
34
  * entity. The property can be created using the constructor, but it
34
35
  * won't be added to the graph until you call the `addProperty` method.
35
36
  *
36
37
  * **Example:**
37
38
  *
38
39
  * ```typescript
39
- * const entity = dataModel.addEntity({ key: 'user' });
40
+ * const entity = domainModel.addEntity({ key: 'user' });
40
41
  * const property = entity.addProperty({
41
42
  * key: 'name',
42
43
  * type: 'string',
@@ -77,9 +78,9 @@ let DomainProperty = (() => {
77
78
  let _tags_decorators;
78
79
  let _tags_initializers = [];
79
80
  let _tags_extraInitializers = [];
80
- let _taxonomy_decorators;
81
- let _taxonomy_initializers = [];
82
- let _taxonomy_extraInitializers = [];
81
+ let _semantics_decorators;
82
+ let _semantics_initializers = [];
83
+ let _semantics_extraInitializers = [];
83
84
  let _type_decorators;
84
85
  let _type_initializers = [];
85
86
  let _type_extraInitializers = [];
@@ -101,7 +102,7 @@ let DomainProperty = (() => {
101
102
  _writeOnly_decorators = [observed()];
102
103
  _deprecated_decorators = [observed()];
103
104
  _tags_decorators = [observed({ deep: true })];
104
- _taxonomy_decorators = [observed({ deep: true })];
105
+ _semantics_decorators = [observed({ deep: true })];
105
106
  _type_decorators = [observed()];
106
107
  _schema_decorators = [observed({ deep: true })];
107
108
  _bindings_decorators = [observed({ deep: true })];
@@ -114,7 +115,7 @@ let DomainProperty = (() => {
114
115
  __esDecorate(this, null, _writeOnly_decorators, { kind: "accessor", name: "writeOnly", static: false, private: false, access: { has: obj => "writeOnly" in obj, get: obj => obj.writeOnly, set: (obj, value) => { obj.writeOnly = value; } }, metadata: _metadata }, _writeOnly_initializers, _writeOnly_extraInitializers);
115
116
  __esDecorate(this, null, _deprecated_decorators, { kind: "accessor", name: "deprecated", static: false, private: false, access: { has: obj => "deprecated" in obj, get: obj => obj.deprecated, set: (obj, value) => { obj.deprecated = value; } }, metadata: _metadata }, _deprecated_initializers, _deprecated_extraInitializers);
116
117
  __esDecorate(this, null, _tags_decorators, { kind: "accessor", name: "tags", static: false, private: false, access: { has: obj => "tags" in obj, get: obj => obj.tags, set: (obj, value) => { obj.tags = value; } }, metadata: _metadata }, _tags_initializers, _tags_extraInitializers);
117
- __esDecorate(this, null, _taxonomy_decorators, { kind: "accessor", name: "taxonomy", static: false, private: false, access: { has: obj => "taxonomy" in obj, get: obj => obj.taxonomy, set: (obj, value) => { obj.taxonomy = value; } }, metadata: _metadata }, _taxonomy_initializers, _taxonomy_extraInitializers);
118
+ __esDecorate(this, null, _semantics_decorators, { kind: "accessor", name: "semantics", static: false, private: false, access: { has: obj => "semantics" in obj, get: obj => obj.semantics, set: (obj, value) => { obj.semantics = value; } }, metadata: _metadata }, _semantics_initializers, _semantics_extraInitializers);
118
119
  __esDecorate(this, null, _type_decorators, { kind: "accessor", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
119
120
  __esDecorate(this, null, _schema_decorators, { kind: "accessor", name: "schema", static: false, private: false, access: { has: obj => "schema" in obj, get: obj => obj.schema, set: (obj, value) => { obj.schema = value; } }, metadata: _metadata }, _schema_initializers, _schema_extraInitializers);
120
121
  __esDecorate(this, null, _bindings_decorators, { kind: "accessor", name: "bindings", static: false, private: false, access: { has: obj => "bindings" in obj, get: obj => obj.bindings, set: (obj, value) => { obj.bindings = value; } }, metadata: _metadata }, _bindings_initializers, _bindings_extraInitializers);
@@ -171,9 +172,7 @@ let DomainProperty = (() => {
171
172
  set deprecated(value) { this.#deprecated_accessor_storage = value; }
172
173
  #tags_accessor_storage = (__runInitializers(this, _deprecated_extraInitializers), __runInitializers(this, _tags_initializers, []
173
174
  /**
174
- * Reserved for future use.
175
- *
176
- * The keys of the taxonomy items associated with the property.
175
+ * Semantics applied to this property.
177
176
  */
178
177
  ));
179
178
  /**
@@ -185,7 +184,7 @@ let DomainProperty = (() => {
185
184
  */
186
185
  get tags() { return this.#tags_accessor_storage; }
187
186
  set tags(value) { this.#tags_accessor_storage = value; }
188
- #taxonomy_accessor_storage = (__runInitializers(this, _tags_extraInitializers), __runInitializers(this, _taxonomy_initializers, []
187
+ #semantics_accessor_storage = (__runInitializers(this, _tags_extraInitializers), __runInitializers(this, _semantics_initializers, []
189
188
  /**
190
189
  * The data type for this property.
191
190
  * Note, not all schemas support the same type. For example, defining `sint32`
@@ -195,13 +194,11 @@ let DomainProperty = (() => {
195
194
  */
196
195
  ));
197
196
  /**
198
- * Reserved for future use.
199
- *
200
- * The keys of the taxonomy items associated with the property.
197
+ * Semantics applied to this property.
201
198
  */
202
- get taxonomy() { return this.#taxonomy_accessor_storage; }
203
- set taxonomy(value) { this.#taxonomy_accessor_storage = value; }
204
- #type_accessor_storage = (__runInitializers(this, _taxonomy_extraInitializers), __runInitializers(this, _type_initializers, 'string'
199
+ get semantics() { return this.#semantics_accessor_storage; }
200
+ set semantics(value) { this.#semantics_accessor_storage = value; }
201
+ #type_accessor_storage = (__runInitializers(this, _semantics_extraInitializers), __runInitializers(this, _type_initializers, 'string'
205
202
  /**
206
203
  * The general schema definition of this property.
207
204
  * This is propagated to all bindings (when they support these properties).
@@ -247,7 +244,7 @@ let DomainProperty = (() => {
247
244
  * @returns The data model schema.
248
245
  */
249
246
  static createSchema(input = {}) {
250
- const { key = nanoid(), multiple, required, type = DomainPropertyList.string, index, primary, readOnly, writeOnly, tags, taxonomy, deprecated, schema, bindings, } = input;
247
+ const { key = nanoid(), multiple, required, type = DomainPropertyList.string, index, primary, readOnly, writeOnly, tags, semantics, deprecated, schema, bindings, } = input;
251
248
  if (typeof type === 'string') {
252
249
  if (!DomainPropertyTypes.includes(type)) {
253
250
  throw new Error(`Invalid data property type ${type}`);
@@ -284,8 +281,8 @@ let DomainProperty = (() => {
284
281
  if (Array.isArray(tags)) {
285
282
  result.tags = [...tags];
286
283
  }
287
- if (Array.isArray(taxonomy)) {
288
- result.taxonomy = [...taxonomy];
284
+ if (Array.isArray(semantics)) {
285
+ result.semantics = [...semantics];
289
286
  }
290
287
  if (schema) {
291
288
  result.schema = structuredClone(schema);
@@ -370,11 +367,11 @@ let DomainProperty = (() => {
370
367
  else {
371
368
  this.tags = [];
372
369
  }
373
- if (Array.isArray(init.taxonomy)) {
374
- this.taxonomy = [...init.taxonomy];
370
+ if (Array.isArray(init.semantics)) {
371
+ this.semantics = [...init.semantics];
375
372
  }
376
373
  else {
377
- this.taxonomy = [];
374
+ this.semantics = [];
378
375
  }
379
376
  if (init.schema) {
380
377
  this.schema = structuredClone(init.schema);
@@ -437,8 +434,8 @@ let DomainProperty = (() => {
437
434
  if (Array.isArray(this.tags) && this.tags.length) {
438
435
  result.tags = [...this.tags];
439
436
  }
440
- if (Array.isArray(this.taxonomy) && this.taxonomy.length) {
441
- result.taxonomy = [...this.taxonomy];
437
+ if (Array.isArray(this.semantics) && this.semantics.length) {
438
+ result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i));
442
439
  }
443
440
  if (this.schema) {
444
441
  result.schema = structuredClone(toRaw(this, this.schema));
@@ -554,6 +551,44 @@ let DomainProperty = (() => {
554
551
  const serializer = new ShapeGenerator();
555
552
  return serializer.property(this);
556
553
  }
554
+ /**
555
+ * Adds or updates a semantic to the property.
556
+ * @param semantic The semantic to add to the property.
557
+ * @throws Error if the semantic is not an property semantic.
558
+ */
559
+ addSemantic(semantic) {
560
+ const sem = DataSemantics[semantic.id];
561
+ if (!isPropertySemantic(sem)) {
562
+ throw new Error(`Invalid semantic type: ${semantic.id}. Expected a property semantic.`);
563
+ }
564
+ const index = this.semantics.findIndex((s) => s.id === semantic.id);
565
+ if (index >= 0) {
566
+ this.semantics[index] = semantic;
567
+ }
568
+ else {
569
+ this.semantics.push(semantic);
570
+ }
571
+ this.domain.notifyChange();
572
+ }
573
+ /**
574
+ * Removes a semantic from the property.
575
+ * @param semanticId The ID of the semantic to remove.
576
+ */
577
+ removeSemantic(semanticId) {
578
+ const index = this.semantics.findIndex((s) => s.id === semanticId);
579
+ if (index >= 0) {
580
+ this.semantics.splice(index, 1);
581
+ this.domain.notifyChange();
582
+ }
583
+ }
584
+ /**
585
+ * Checks if the property has a specific semantic.
586
+ * @param semanticId The ID of the semantic to check.
587
+ * @returns True if the semantic is present, false otherwise.
588
+ */
589
+ hasSemantic(semanticId) {
590
+ return this.semantics.some((s) => s.id === semanticId);
591
+ }
557
592
  };
558
593
  })();
559
594
  export { DomainProperty };