@api-client/core 0.11.10 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/Testing.md +1 -1
  2. package/bin/plugins/events/EventPlugin.ts +61 -0
  3. package/bin/plugins/events/assert.ts +193 -0
  4. package/bin/plugins/events/types.ts +6 -0
  5. package/bin/test.ts +8 -1
  6. package/build/src/amf/AmfShapeGenerator.d.ts +6 -3
  7. package/build/src/amf/AmfShapeGenerator.d.ts.map +1 -1
  8. package/build/src/amf/AmfShapeGenerator.js +4 -1
  9. package/build/src/amf/AmfShapeGenerator.js.map +1 -1
  10. package/build/src/amf/AmfTypes.d.ts +2 -2
  11. package/build/src/amf/AmfTypes.d.ts.map +1 -1
  12. package/build/src/amf/AmfTypes.js.map +1 -1
  13. package/build/src/amf/DataValueGenerator.d.ts +15 -15
  14. package/build/src/amf/DataValueGenerator.d.ts.map +1 -1
  15. package/build/src/amf/DataValueGenerator.js +14 -14
  16. package/build/src/amf/DataValueGenerator.js.map +1 -1
  17. package/build/src/browser.d.ts +12 -9
  18. package/build/src/browser.d.ts.map +1 -1
  19. package/build/src/browser.js +11 -8
  20. package/build/src/browser.js.map +1 -1
  21. package/build/src/exceptions/attach_exception.d.ts +11 -0
  22. package/build/src/exceptions/attach_exception.d.ts.map +1 -0
  23. package/build/src/exceptions/attach_exception.js +11 -0
  24. package/build/src/exceptions/attach_exception.js.map +1 -0
  25. package/build/src/exceptions/detach_exception.d.ts +11 -0
  26. package/build/src/exceptions/detach_exception.d.ts.map +1 -0
  27. package/build/src/exceptions/detach_exception.js +11 -0
  28. package/build/src/exceptions/detach_exception.js.map +1 -0
  29. package/build/src/exceptions/remove_model_exception.d.ts +8 -0
  30. package/build/src/exceptions/remove_model_exception.d.ts.map +1 -0
  31. package/build/src/exceptions/remove_model_exception.js +8 -0
  32. package/build/src/exceptions/remove_model_exception.js.map +1 -0
  33. package/build/src/exceptions/remove_namespace_exception.d.ts +8 -0
  34. package/build/src/exceptions/remove_namespace_exception.d.ts.map +1 -0
  35. package/build/src/exceptions/remove_namespace_exception.js +8 -0
  36. package/build/src/exceptions/remove_namespace_exception.js.map +1 -0
  37. package/build/src/index.d.ts +12 -9
  38. package/build/src/index.d.ts.map +1 -1
  39. package/build/src/index.js +11 -8
  40. package/build/src/index.js.map +1 -1
  41. package/build/src/legacy.d.ts +8 -0
  42. package/build/src/legacy.d.ts.map +1 -1
  43. package/build/src/legacy.js +9 -0
  44. package/build/src/legacy.js.map +1 -1
  45. package/build/src/modeling/Bindings.d.ts +2 -2
  46. package/build/src/modeling/Bindings.d.ts.map +1 -1
  47. package/build/src/modeling/Bindings.js.map +1 -1
  48. package/build/src/modeling/DataDomain.d.ts +601 -0
  49. package/build/src/modeling/DataDomain.d.ts.map +1 -0
  50. package/build/src/modeling/DataDomain.js +1142 -0
  51. package/build/src/modeling/DataDomain.js.map +1 -0
  52. package/build/src/modeling/DataFormat.d.ts +42 -41
  53. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  54. package/build/src/modeling/DataFormat.js +30 -131
  55. package/build/src/modeling/DataFormat.js.map +1 -1
  56. package/build/src/modeling/DomainAssociation.d.ts +281 -0
  57. package/build/src/modeling/DomainAssociation.d.ts.map +1 -0
  58. package/build/src/modeling/DomainAssociation.js +440 -0
  59. package/build/src/modeling/DomainAssociation.js.map +1 -0
  60. package/build/src/modeling/DomainElement.d.ts +33 -0
  61. package/build/src/modeling/DomainElement.d.ts.map +1 -0
  62. package/build/src/modeling/DomainElement.js +32 -0
  63. package/build/src/modeling/DomainElement.js.map +1 -0
  64. package/build/src/modeling/DomainEntity.d.ts +383 -0
  65. package/build/src/modeling/DomainEntity.d.ts.map +1 -0
  66. package/build/src/modeling/DomainEntity.js +718 -0
  67. package/build/src/modeling/DomainEntity.js.map +1 -0
  68. package/build/src/modeling/DomainFile.d.ts +25 -0
  69. package/build/src/modeling/DomainFile.d.ts.map +1 -0
  70. package/build/src/modeling/DomainFile.js +86 -0
  71. package/build/src/modeling/DomainFile.js.map +1 -0
  72. package/build/src/modeling/DomainImpactAnalysis.d.ts +60 -47
  73. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  74. package/build/src/modeling/DomainImpactAnalysis.js +201 -132
  75. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  76. package/build/src/modeling/DomainModel.d.ts +226 -0
  77. package/build/src/modeling/DomainModel.d.ts.map +1 -0
  78. package/build/src/modeling/DomainModel.js +401 -0
  79. package/build/src/modeling/DomainModel.js.map +1 -0
  80. package/build/src/modeling/DomainNamespace.d.ts +268 -0
  81. package/build/src/modeling/DomainNamespace.d.ts.map +1 -0
  82. package/build/src/modeling/DomainNamespace.js +512 -0
  83. package/build/src/modeling/DomainNamespace.js.map +1 -0
  84. package/build/src/modeling/DomainProperty.d.ts +281 -0
  85. package/build/src/modeling/DomainProperty.d.ts.map +1 -0
  86. package/build/src/modeling/DomainProperty.js +560 -0
  87. package/build/src/modeling/DomainProperty.js.map +1 -0
  88. package/build/src/modeling/DomainSerialization.d.ts +40 -0
  89. package/build/src/modeling/DomainSerialization.d.ts.map +1 -0
  90. package/build/src/modeling/DomainSerialization.js +288 -0
  91. package/build/src/modeling/DomainSerialization.js.map +1 -0
  92. package/build/src/modeling/DomainVersioning.d.ts +17 -0
  93. package/build/src/modeling/DomainVersioning.d.ts.map +1 -0
  94. package/build/src/modeling/DomainVersioning.js +124 -0
  95. package/build/src/modeling/DomainVersioning.js.map +1 -0
  96. package/build/src/modeling/GraphUtils.d.ts +8 -0
  97. package/build/src/modeling/GraphUtils.d.ts.map +1 -0
  98. package/build/src/modeling/GraphUtils.js +26 -0
  99. package/build/src/modeling/GraphUtils.js.map +1 -0
  100. package/build/src/modeling/amf/ShapeGenerator.d.ts +164 -0
  101. package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -0
  102. package/build/src/modeling/amf/ShapeGenerator.js +492 -0
  103. package/build/src/modeling/amf/ShapeGenerator.js.map +1 -0
  104. package/build/src/modeling/{DataAssociation.d.ts → legacy/DataAssociation.d.ts} +10 -5
  105. package/build/src/modeling/legacy/DataAssociation.d.ts.map +1 -0
  106. package/build/src/modeling/{DataAssociation.js → legacy/DataAssociation.js} +9 -6
  107. package/build/src/modeling/legacy/DataAssociation.js.map +1 -0
  108. package/build/src/modeling/{DataEntity.d.ts → legacy/DataEntity.d.ts} +12 -7
  109. package/build/src/modeling/legacy/DataEntity.d.ts.map +1 -0
  110. package/build/src/modeling/{DataEntity.js → legacy/DataEntity.js} +19 -18
  111. package/build/src/modeling/legacy/DataEntity.js.map +1 -0
  112. package/build/src/modeling/{DataEntityBuilder.d.ts → legacy/DataEntityBuilder.d.ts} +3 -2
  113. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +1 -0
  114. package/build/src/modeling/{DataEntityBuilder.js → legacy/DataEntityBuilder.js} +3 -2
  115. package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -0
  116. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +298 -0
  117. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +1 -0
  118. package/build/src/modeling/legacy/DataImpactAnalysis.js +441 -0
  119. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +1 -0
  120. package/build/src/modeling/{DataModel.d.ts → legacy/DataModel.d.ts} +6 -4
  121. package/build/src/modeling/legacy/DataModel.d.ts.map +1 -0
  122. package/build/src/modeling/{DataModel.js → legacy/DataModel.js} +7 -6
  123. package/build/src/modeling/legacy/DataModel.js.map +1 -0
  124. package/build/src/modeling/{DataNamespace.d.ts → legacy/DataNamespace.d.ts} +22 -3
  125. package/build/src/modeling/legacy/DataNamespace.d.ts.map +1 -0
  126. package/build/src/modeling/{DataNamespace.js → legacy/DataNamespace.js} +7 -3
  127. package/build/src/modeling/legacy/DataNamespace.js.map +1 -0
  128. package/build/src/modeling/{DataProperty.d.ts → legacy/DataProperty.d.ts} +13 -5
  129. package/build/src/modeling/legacy/DataProperty.d.ts.map +1 -0
  130. package/build/src/modeling/{DataProperty.js → legacy/DataProperty.js} +8 -5
  131. package/build/src/modeling/legacy/DataProperty.js.map +1 -0
  132. package/build/src/modeling/observed.d.ts +67 -0
  133. package/build/src/modeling/observed.d.ts.map +1 -0
  134. package/build/src/modeling/observed.js +230 -0
  135. package/build/src/modeling/observed.js.map +1 -0
  136. package/build/src/modeling/types.d.ts +165 -1
  137. package/build/src/modeling/types.d.ts.map +1 -1
  138. package/build/src/modeling/types.js.map +1 -1
  139. package/build/src/models/Thing.d.ts +26 -5
  140. package/build/src/models/Thing.d.ts.map +1 -1
  141. package/build/src/models/Thing.js +193 -91
  142. package/build/src/models/Thing.js.map +1 -1
  143. package/build/src/models/kinds.d.ts +31 -6
  144. package/build/src/models/kinds.d.ts.map +1 -1
  145. package/build/src/models/kinds.js +31 -6
  146. package/build/src/models/kinds.js.map +1 -1
  147. package/build/src/models/store/DataFile.d.ts +3 -1
  148. package/build/src/models/store/DataFile.d.ts.map +1 -1
  149. package/build/src/models/store/DataFile.js +2 -0
  150. package/build/src/models/store/DataFile.js.map +1 -1
  151. package/build/src/models/types.d.ts +12 -0
  152. package/build/src/models/types.d.ts.map +1 -0
  153. package/build/src/models/types.js +2 -0
  154. package/build/src/models/types.js.map +1 -0
  155. package/build/src/runtime/store/FilesSdk.d.ts +2 -2
  156. package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
  157. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  158. package/data/models/example-generator-api.json +26 -26
  159. package/package.json +20 -6
  160. package/readme.md +1 -1
  161. package/src/amf/AmfShapeGenerator.ts +7 -4
  162. package/src/amf/AmfTypes.ts +2 -2
  163. package/src/amf/DataValueGenerator.ts +21 -21
  164. package/src/exceptions/attach_exception.ts +11 -0
  165. package/src/exceptions/detach_exception.ts +11 -0
  166. package/src/exceptions/remove_model_exception.ts +8 -0
  167. package/src/exceptions/remove_namespace_exception.ts +8 -0
  168. package/src/modeling/Bindings.ts +2 -2
  169. package/src/modeling/DataDomain.ts +1221 -0
  170. package/src/modeling/DataFormat.ts +54 -163
  171. package/src/modeling/DomainAssociation.ts +476 -0
  172. package/src/modeling/DomainElement.ts +50 -0
  173. package/src/modeling/DomainEntity.ts +769 -0
  174. package/src/modeling/DomainFile.ts +94 -0
  175. package/src/modeling/DomainImpactAnalysis.ts +218 -144
  176. package/src/modeling/DomainModel.ts +421 -0
  177. package/src/modeling/DomainNamespace.ts +537 -0
  178. package/src/modeling/DomainProperty.ts +548 -0
  179. package/src/modeling/DomainSerialization.ts +312 -0
  180. package/src/modeling/DomainVersioning.ts +144 -0
  181. package/src/modeling/GraphUtils.ts +28 -0
  182. package/src/modeling/amf/ShapeGenerator.ts +552 -0
  183. package/src/modeling/graph.md +115 -0
  184. package/src/modeling/{DataAssociation.ts → legacy/DataAssociation.ts} +13 -8
  185. package/src/modeling/{DataEntity.ts → legacy/DataEntity.ts} +28 -23
  186. package/src/modeling/{DataEntityBuilder.ts → legacy/DataEntityBuilder.ts} +4 -3
  187. package/src/modeling/legacy/DataImpactAnalysis.ts +530 -0
  188. package/src/modeling/{DataModel.ts → legacy/DataModel.ts} +10 -8
  189. package/src/modeling/{DataNamespace.ts → legacy/DataNamespace.ts} +23 -5
  190. package/src/modeling/{DataProperty.ts → legacy/DataProperty.ts} +15 -7
  191. package/src/modeling/observed.ts +267 -0
  192. package/src/modeling/types.ts +174 -1
  193. package/src/models/Thing.ts +70 -5
  194. package/src/models/kinds.ts +32 -6
  195. package/src/models/store/DataFile.ts +3 -1
  196. package/src/models/types.ts +11 -0
  197. package/src/runtime/store/FilesSdk.ts +2 -6
  198. package/tests/unit/amf/data_value_generator.spec.ts +15 -15
  199. package/tests/unit/legacy-transformers/ARC-legacy-import.spec.ts +1 -1
  200. package/tests/unit/modeling/amf/shape_generator.spec.ts +1174 -0
  201. package/tests/unit/modeling/data_domain.spec.ts +444 -0
  202. package/tests/unit/modeling/data_domain_associations.spec.ts +279 -0
  203. package/tests/unit/modeling/data_domain_change_observers.spec.ts +681 -0
  204. package/tests/unit/modeling/data_domain_entities.spec.ts +449 -0
  205. package/tests/unit/modeling/data_domain_foreign.spec.ts +355 -0
  206. package/tests/unit/modeling/data_domain_models.spec.ts +658 -0
  207. package/tests/unit/modeling/data_domain_namespaces.spec.ts +668 -0
  208. package/tests/unit/modeling/data_domain_property.spec.ts +264 -0
  209. package/tests/unit/modeling/data_domain_serialization.spec.ts +294 -0
  210. package/tests/unit/modeling/domain.property.spec.ts +822 -0
  211. package/tests/unit/modeling/domain_asociation.spec.ts +643 -0
  212. package/tests/unit/modeling/domain_asociation_targets.spec.ts +350 -0
  213. package/tests/unit/modeling/domain_entity.spec.ts +730 -0
  214. package/tests/unit/modeling/domain_entity_associations.spec.ts +330 -0
  215. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +988 -0
  216. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1451 -0
  217. package/tests/unit/modeling/domain_entity_fields.spec.ts +113 -0
  218. package/tests/unit/modeling/domain_entity_generators.spec.ts +20 -0
  219. package/tests/unit/modeling/domain_entity_parents.spec.ts +291 -0
  220. package/tests/unit/modeling/domain_entity_properties.spec.ts +305 -0
  221. package/tests/unit/modeling/{data_file.spec.ts → domain_file.spec.ts} +29 -85
  222. package/tests/unit/modeling/domain_impact_analysis.spec.ts +452 -0
  223. package/tests/unit/modeling/domain_model.spec.ts +568 -0
  224. package/tests/unit/modeling/domain_model_entities.spec.ts +408 -0
  225. package/tests/unit/modeling/domain_namespace.spec.ts +514 -0
  226. package/tests/unit/modeling/domain_namespace_models.spec.ts +324 -0
  227. package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +404 -0
  228. package/tests/unit/modeling/domain_versioning.spec.ts +140 -0
  229. package/tests/unit/{amf → modeling/legacy}/amf_shape_generator.spec.ts +11 -11
  230. package/tests/unit/modeling/{data_association.spec.ts → legacy/data_association.spec.ts} +3 -11
  231. package/tests/unit/modeling/{data_entity.spec.ts → legacy/data_entity.spec.ts} +10 -8
  232. package/tests/unit/modeling/{data_entity_generator_json.spec.ts → legacy/data_entity_generator_json.spec.ts} +1 -1
  233. package/tests/unit/modeling/{data_entity_generator_xml.spec.ts → legacy/data_entity_generator_xml.spec.ts} +1 -1
  234. package/tests/unit/modeling/{data_model.spec.ts → legacy/data_model.spec.ts} +3 -3
  235. package/tests/unit/modeling/{data_namespace.spec.ts → legacy/data_namespace.spec.ts} +3 -10
  236. package/tests/unit/modeling/{data_property.spec.ts → legacy/data_property.spec.ts} +3 -6
  237. package/tests/unit/modeling/{impact_analysis.spec.ts → legacy/impact_analysis.spec.ts} +9 -9
  238. package/tests/unit/models/File/new.spec.ts +1 -1
  239. package/tests/unit/models/HttpProject.spec.ts +3 -3
  240. package/tsconfig.node.json +35 -0
  241. package/build/src/modeling/DataAssociation.d.ts.map +0 -1
  242. package/build/src/modeling/DataAssociation.js.map +0 -1
  243. package/build/src/modeling/DataEntity.d.ts.map +0 -1
  244. package/build/src/modeling/DataEntity.js.map +0 -1
  245. package/build/src/modeling/DataEntityBuilder.d.ts.map +0 -1
  246. package/build/src/modeling/DataEntityBuilder.js.map +0 -1
  247. package/build/src/modeling/DataModel.d.ts.map +0 -1
  248. package/build/src/modeling/DataModel.js.map +0 -1
  249. package/build/src/modeling/DataNamespace.d.ts.map +0 -1
  250. package/build/src/modeling/DataNamespace.js.map +0 -1
  251. package/build/src/modeling/DataProperty.d.ts.map +0 -1
  252. package/build/src/modeling/DataProperty.js.map +0 -1
@@ -0,0 +1,440 @@
1
+ import { __esDecorate, __runInitializers } from "tslib";
2
+ import { DomainAssociationKind } from '../models/kinds.js';
3
+ import { DomainElement } from './DomainElement.js';
4
+ import { nanoid } from 'nanoid';
5
+ import { Thing } from '../models/Thing.js';
6
+ import { observed, retargetChange, toRaw } from './observed.js';
7
+ import { Json } from '@api-client/json';
8
+ import { DomainAttributeAttributes } from './DataFormat.js';
9
+ import { ShapeGenerator } from './amf/ShapeGenerator.js';
10
+ /**
11
+ * Represents an association between entities in a data domain.
12
+ *
13
+ * A `DomainAssociation` defines a relationship between a
14
+ * `DomainEntity` and one or more other entities. It specifies
15
+ * how entities are connected and can represent various types
16
+ * of relationships, such as one-to-one, one-to-many, or
17
+ * many-to-many.
18
+ *
19
+ * **Key Features:**
20
+ *
21
+ * - **Target Entities:** Specifies the entities that are
22
+ * the target of the association.
23
+ * - **Cardinality:** Defines whether the association is
24
+ * single-valued or multi-valued (e.g., one-to-one vs.
25
+ * one-to-many).
26
+ * - **Required Status:** Indicates whether the association
27
+ * is mandatory or optional.
28
+ * - **Schema Customization:** Allows defining a custom
29
+ * schema for the association, overriding the default
30
+ * schema derived from the target entities.
31
+ * - **Bindings:** Supports defining how the association is
32
+ * represented in different formats (e.g., web APIs,
33
+ * protocol buffers).
34
+ * - **Foreign Namespaces:** Can target entities in other
35
+ * namespaces, enabling cross-namespace relationships.
36
+ *
37
+ * **Usage:**
38
+ *
39
+ * The preferred way to create a `DomainAssociation` is
40
+ * through the `DomainEntity.addAssociation()` method.
41
+ *
42
+ * **Example:**
43
+ *
44
+ * ```typescript
45
+ * const dataDomain = new DataDomain();
46
+ * const userModel = dataDomain.addModel({ key: 'userModel' });
47
+ * const userEntity = userModel.addEntity({ key: 'user' });
48
+ * const addressEntity = userModel.addEntity({ key: 'address' });
49
+ * // Add an association from User to Address
50
+ * const addressAssociation = userEntity.addAssociation();
51
+ * addressAssociation.addTarget(addressEntity);
52
+ * ```
53
+ */
54
+ let DomainAssociation = (() => {
55
+ let _classSuper = DomainElement;
56
+ let _info_decorators;
57
+ let _info_initializers = [];
58
+ let _info_extraInitializers = [];
59
+ let _required_decorators;
60
+ let _required_initializers = [];
61
+ let _required_extraInitializers = [];
62
+ let _multiple_decorators;
63
+ let _multiple_initializers = [];
64
+ let _multiple_extraInitializers = [];
65
+ let _schema_decorators;
66
+ let _schema_initializers = [];
67
+ let _schema_extraInitializers = [];
68
+ let _bindings_decorators;
69
+ let _bindings_initializers = [];
70
+ let _bindings_extraInitializers = [];
71
+ let _targets_decorators;
72
+ let _targets_initializers = [];
73
+ let _targets_extraInitializers = [];
74
+ return class DomainAssociation extends _classSuper {
75
+ static {
76
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
77
+ _info_decorators = [retargetChange()];
78
+ _required_decorators = [observed()];
79
+ _multiple_decorators = [observed()];
80
+ _schema_decorators = [observed({ deep: true })];
81
+ _bindings_decorators = [observed({ deep: true })];
82
+ _targets_decorators = [observed({ deep: true })];
83
+ __esDecorate(this, null, _info_decorators, { kind: "accessor", name: "info", static: false, private: false, access: { has: obj => "info" in obj, get: obj => obj.info, set: (obj, value) => { obj.info = value; } }, metadata: _metadata }, _info_initializers, _info_extraInitializers);
84
+ __esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
85
+ __esDecorate(this, null, _multiple_decorators, { kind: "accessor", name: "multiple", static: false, private: false, access: { has: obj => "multiple" in obj, get: obj => obj.multiple, set: (obj, value) => { obj.multiple = value; } }, metadata: _metadata }, _multiple_initializers, _multiple_extraInitializers);
86
+ __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);
87
+ __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);
88
+ __esDecorate(this, null, _targets_decorators, { kind: "accessor", name: "targets", static: false, private: false, access: { has: obj => "targets" in obj, get: obj => obj.targets, set: (obj, value) => { obj.targets = value; } }, metadata: _metadata }, _targets_initializers, _targets_extraInitializers);
89
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
90
+ }
91
+ /**
92
+ * The kind of the domain element.
93
+ */
94
+ kind;
95
+ #info_accessor_storage = __runInitializers(this, _info_initializers, void 0);
96
+ /**
97
+ * The description of the association namespace.
98
+ */
99
+ get info() { return this.#info_accessor_storage; }
100
+ set info(value) { this.#info_accessor_storage = value; }
101
+ #required_accessor_storage = (__runInitializers(this, _info_extraInitializers), __runInitializers(this, _required_initializers, void 0));
102
+ /**
103
+ * Wether the data association is required.
104
+ */
105
+ get required() { return this.#required_accessor_storage; }
106
+ set required(value) { this.#required_accessor_storage = value; }
107
+ #multiple_accessor_storage = (__runInitializers(this, _required_extraInitializers), __runInitializers(this, _multiple_initializers, void 0));
108
+ /**
109
+ * Whether the data association allows multiple items.
110
+ */
111
+ get multiple() { return this.#multiple_accessor_storage; }
112
+ set multiple(value) { this.#multiple_accessor_storage = value; }
113
+ #schema_accessor_storage = (__runInitializers(this, _multiple_extraInitializers), __runInitializers(this, _schema_initializers, void 0));
114
+ /**
115
+ * The schema allowing to translate the model into a
116
+ * specific format (like JSON, RAML, XML, etc.)
117
+ */
118
+ get schema() { return this.#schema_accessor_storage; }
119
+ set schema(value) { this.#schema_accessor_storage = value; }
120
+ #bindings_accessor_storage = (__runInitializers(this, _schema_extraInitializers), __runInitializers(this, _bindings_initializers, void 0));
121
+ /**
122
+ * The list of bindings for this property.
123
+ *
124
+ * A binding defines a translation from a data model to a specific format.
125
+ * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs
126
+ * or a protocol buffer schema.
127
+ */
128
+ get bindings() { return this.#bindings_accessor_storage; }
129
+ set bindings(value) { this.#bindings_accessor_storage = value; }
130
+ /**
131
+ * The key of the parent entity.
132
+ */
133
+ parent = __runInitializers(this, _bindings_extraInitializers);
134
+ #targets_accessor_storage = __runInitializers(this, _targets_initializers, void 0);
135
+ /**
136
+ * The list of keys associated with the entity through this association.
137
+ * An association without a target is considered invalid and discarded when processing the values.
138
+ * When multiple associations are set then we are dealing with an union.
139
+ */
140
+ get targets() { return this.#targets_accessor_storage; }
141
+ set targets(value) { this.#targets_accessor_storage = value; }
142
+ /**
143
+ * Creates a full data association schema with defaults.
144
+ *
145
+ * @param input The partial data association schema.
146
+ * @returns The data association schema.
147
+ */
148
+ static createSchema(input = {}) {
149
+ const { key = nanoid() } = input;
150
+ const info = Thing.fromJSON(input.info, { name: 'New association' }).toJSON();
151
+ const result = {
152
+ kind: DomainAssociationKind,
153
+ key,
154
+ info,
155
+ };
156
+ if (input.schema) {
157
+ result.schema = structuredClone(input.schema);
158
+ }
159
+ if (typeof input.multiple === 'boolean') {
160
+ result.multiple = input.multiple;
161
+ }
162
+ if (typeof input.required === 'boolean') {
163
+ result.required = input.required;
164
+ }
165
+ if (Array.isArray(input.bindings)) {
166
+ result.bindings = input.bindings.map((i) => structuredClone(i));
167
+ }
168
+ if (Array.isArray(input.targets)) {
169
+ result.targets = input.targets.map((i) => ({ ...i }));
170
+ }
171
+ return result;
172
+ }
173
+ /**
174
+ * Creates a new data association instance.
175
+ *
176
+ * You probably want to use the `DomainEntity.addAssociation()` method instead.
177
+ *
178
+ * @param root A reference to the root DataDomain instance.
179
+ * @param parent The key of the parent entity.
180
+ * @param input The partial data association schema.
181
+ */
182
+ constructor(root, parent, input) {
183
+ const init = DomainAssociation.createSchema(input);
184
+ super(root, init.key);
185
+ __runInitializers(this, _targets_extraInitializers);
186
+ this.parent = parent;
187
+ this.kind = DomainAssociationKind;
188
+ this.info = new Thing(init.info);
189
+ if (init.schema) {
190
+ this.schema = structuredClone(init.schema);
191
+ }
192
+ if (typeof init.multiple === 'boolean') {
193
+ this.multiple = init.multiple;
194
+ }
195
+ if (typeof init.required === 'boolean') {
196
+ this.required = init.required;
197
+ }
198
+ if (Array.isArray(init.bindings)) {
199
+ this.bindings = init.bindings.map((i) => structuredClone(i));
200
+ }
201
+ else {
202
+ this.bindings = [];
203
+ }
204
+ if (Array.isArray(init.targets)) {
205
+ this.targets = init.targets.map((i) => ({ ...i }));
206
+ }
207
+ else {
208
+ this.targets = [];
209
+ }
210
+ }
211
+ /**
212
+ * Generates a JSON representation of the association.
213
+ *
214
+ * @returns A plain object representation of the `DomainAssociation`.
215
+ */
216
+ toJSON() {
217
+ const result = {
218
+ kind: this.kind,
219
+ key: this.key,
220
+ info: this.info.toJSON(),
221
+ };
222
+ if (this.schema) {
223
+ result.schema = Json.clone(toRaw(this, this.schema));
224
+ }
225
+ if (typeof this.multiple === 'boolean') {
226
+ result.multiple = this.multiple;
227
+ }
228
+ if (typeof this.required === 'boolean') {
229
+ result.required = this.required;
230
+ }
231
+ if (Array.isArray(this.bindings) && this.bindings.length) {
232
+ result.bindings = toRaw(this, this.bindings).map((i) => Json.clone(i));
233
+ }
234
+ if (Array.isArray(this.targets) && this.targets.length) {
235
+ result.targets = toRaw(this, this.targets).map((i) => ({ ...i }));
236
+ }
237
+ return result;
238
+ }
239
+ /**
240
+ * Returns a parent data entity where this data property exist.
241
+ *
242
+ * @returns The parent `DomainEntity` or undefined if not found.
243
+ */
244
+ getParentInstance() {
245
+ return this.root.graph.node(this.parent);
246
+ }
247
+ /**
248
+ * Removes this property from the parent entity.
249
+ *
250
+ * This method removes the association from the parent
251
+ * entity's list of associations.
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * association.remove();
256
+ * ```
257
+ */
258
+ remove() {
259
+ const parent = this.getParentInstance();
260
+ parent?.removeAssociation(this.key);
261
+ }
262
+ /**
263
+ * Creates the `schema` object if missing and returns it.
264
+ *
265
+ * @returns The schema object.
266
+ * @example
267
+ * ```typescript
268
+ * const schema = association.ensureSchema();
269
+ * ```
270
+ */
271
+ ensureSchema() {
272
+ if (!this.schema) {
273
+ this.schema = {};
274
+ }
275
+ return this.schema;
276
+ }
277
+ /**
278
+ * Checks whether the passed value is one of the supported
279
+ * data property attributes.
280
+ *
281
+ * @param value The value to test
282
+ * @returns True when the passed value is one of the
283
+ * supported data property attributes.
284
+ */
285
+ static isValidAttribute(value) {
286
+ if (typeof value !== 'string') {
287
+ return false;
288
+ }
289
+ return DomainAttributeAttributes.includes(value);
290
+ }
291
+ /**
292
+ * Creates if not existing and returns web bindings
293
+ * definition.
294
+ *
295
+ * @returns The web binding definition
296
+ * @example
297
+ * ```typescript
298
+ * const webBindings = association.getWebBinding();
299
+ * webBindings.hidden = true;
300
+ * ```
301
+ */
302
+ getWebBinding() {
303
+ let object = this.bindings.find((i) => i.type === 'web');
304
+ if (!object) {
305
+ object = { type: 'web', schema: {} };
306
+ this.bindings.push(object);
307
+ this.domain.notifyChange();
308
+ }
309
+ return object.schema;
310
+ }
311
+ /**
312
+ * Returns the schema value of the binding, if any was
313
+ * created.
314
+ *
315
+ * @param type The type of the binding to read.
316
+ * @returns The binding schema, if any
317
+ * @example
318
+ * ```typescript
319
+ * const webBindings = association.readBinding('web');
320
+ * if (webBindings) {
321
+ * // ...
322
+ * }
323
+ * ```
324
+ */
325
+ readBinding(type) {
326
+ const item = this.bindings.find((i) => i.type === type);
327
+ return item?.schema || undefined;
328
+ }
329
+ /**
330
+ * Adds a target entity to the association.
331
+ *
332
+ * @param init The key of an entity, its instance, or schema.
333
+ * @param namespace - The key of the foreign namespace this
334
+ * entity belongs to. Do not set this value for local entities.
335
+ */
336
+ addTarget(init, namespace) {
337
+ let key;
338
+ if (typeof init === 'string') {
339
+ key = init;
340
+ }
341
+ else {
342
+ key = init.key;
343
+ if (init.domain.key !== this.root.key) {
344
+ namespace = init.domain.key;
345
+ }
346
+ }
347
+ if (this.targets.some((i) => i.key === key && i.domain === namespace)) {
348
+ const message = `Target ${key} already exists.`;
349
+ throw new Error(message);
350
+ }
351
+ if (namespace && !this.root.dependencies.has(namespace)) {
352
+ throw new Error(`Foreign namespace "${namespace}" does not exist.`);
353
+ }
354
+ const info = {
355
+ key,
356
+ };
357
+ if (namespace) {
358
+ info.domain = namespace;
359
+ }
360
+ this.targets.push(info);
361
+ const targetKey = namespace ? `${namespace}:${key}` : key;
362
+ const label = {
363
+ type: 'association',
364
+ };
365
+ if (namespace) {
366
+ label.domain = namespace;
367
+ label.foreign = true;
368
+ }
369
+ // We need to associate the target with the association
370
+ // in the graph. This way, when looking for associations
371
+ // on a target entities we can easily locate the
372
+ // association.
373
+ this.root.graph.setEdge(this.key, targetKey, label);
374
+ // this.root.notifyChange()
375
+ }
376
+ /**
377
+ * Removes a target entity from the targets list.
378
+ *
379
+ * @param init The key of an entity, its instance, or
380
+ * schema.
381
+ * @example
382
+ * ```typescript
383
+ * association.removeTarget(addressEntity);
384
+ * ```
385
+ */
386
+ removeTarget(init) {
387
+ let key;
388
+ if (typeof init === 'string') {
389
+ key = init;
390
+ }
391
+ else {
392
+ key = init.key;
393
+ }
394
+ const index = this.targets.findIndex((i) => i.key === key);
395
+ if (index >= 0) {
396
+ this.targets.splice(index, 1);
397
+ // this.root.notifyChange()
398
+ }
399
+ this.root.graph.removeEdge(this.key, key);
400
+ }
401
+ /**
402
+ * Lists all target entities of this association.
403
+ *
404
+ * @returns A generator that yields each target
405
+ * `DomainEntity`.
406
+ * @example
407
+ * ```typescript
408
+ * for (const target of association.listTargets()) {
409
+ * console.log(target.key);
410
+ * }
411
+ * ```
412
+ */
413
+ *listTargets() {
414
+ for (const target of this.targets) {
415
+ const { key, domain } = target;
416
+ const targetKey = domain ? `${domain}:${key}` : key;
417
+ const entity = this.root.graph.node(targetKey);
418
+ if (entity) {
419
+ yield entity;
420
+ }
421
+ }
422
+ }
423
+ /**
424
+ * Creates a Property Shape of AMF.
425
+ * The property itself is auto-generated. If the `schema` is defined then it is used
426
+ * as the `range` of the property. Otherwise basic shape is generated for the range.
427
+ *
428
+ * This is a preferred way of reading the AMF shape as this synchronizes changed
429
+ * data properties with the shape definition.
430
+ *
431
+ * @returns AMF property shape definition.
432
+ */
433
+ toApiShape() {
434
+ const serializer = new ShapeGenerator();
435
+ return serializer.associationProperty(this);
436
+ }
437
+ };
438
+ })();
439
+ export { DomainAssociation };
440
+ //# sourceMapp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AAC;gBAC7B,GAAG,GAAG,IAAI,CAAA;YACZ,CAAC;iBAAM,CAAC;gBACN,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;YAChB,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;YAC1D,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;gBAC7B,2BAA2B;YAC7B,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAC3C,CAAC;QAED;;;;;;;;;;;WAWG;QACH,CAAC,WAAW;YACV,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;gBAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;gBACnD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAA6B,CAAA;gBAC1E,IAAI,MAAM,EAAE,CAAC;oBACX,MAAM,MAAM,CAAA;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QAED;;;;;;;;;WASG;QACH,UAAU;YACR,MAAM,UAAU,GAAG,IAAI,cAAc,EAAE,CAAA;YACvC,OAAO,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAA;QAC7C,CAAC;;;SA1XU,iBAAiB","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainAssociationKind } from '../models/kinds.js'\nimport { DomainElement, type DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from 'nanoid'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange, toRaw } from './observed.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { Json } from '@api-client/json'\nimport { DomainAttributeAttribute, DomainAttributeAttributes } from './DataFormat.js'\nimport type { AssociationTarget, DomainGraphEdge } from './types.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\n\nexport interface DomainAssociationSchema extends DomainElementSchema {\n kind: typeof DomainAssociationKind\n /**\n * The data association description.\n */\n info: IThing\n /**\n * Wether the data association is required.\n */\n required?: boolean\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: AssociationBinding[]\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets?: AssociationTarget[]\n}\n\n/**\n * Represents an association between entities in a data domain.\n *\n * A `DomainAssociation` defines a relationship between a\n * `DomainEntity` and one or more other entities. It specifies\n * how entities are connected and can represent various types\n * of relationships, such as one-to-one, one-to-many, or\n * many-to-many.\n *\n * **Key Features:**\n *\n * - **Target Entities:** Specifies the entities that are\n * the target of the association.\n * - **Cardinality:** Defines whether the association is\n * single-valued or multi-valued (e.g., one-to-one vs.\n * one-to-many).\n * - **Required Status:** Indicates whether the association\n * is mandatory or optional.\n * - **Schema Customization:** Allows defining a custom\n * schema for the association, overriding the default\n * schema derived from the target entities.\n * - **Bindings:** Supports defining how the association is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Foreign Namespaces:** Can target entities in other\n * namespaces, enabling cross-namespace relationships.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainAssociation` is\n * through the `DomainEntity.addAssociation()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userModel = dataDomain.addModel({ key: 'userModel' });\n * const userEntity = userModel.addEntity({ key: 'user' });\n * const addressEntity = userModel.addEntity({ key: 'address' });\n * // Add an association from User to Address\n * const addressAssociation = userEntity.addAssociation();\n * addressAssociation.addTarget(addressEntity);\n * ```\n */\nexport class DomainAssociation extends DomainElement {\n /**\n * The kind of the domain element.\n */\n override kind: typeof DomainAssociationKind\n\n /**\n * The description of the association namespace.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data association is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data association allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * The schema allowing to translate the model into a\n * specific format (like JSON, RAML, XML, etc.)\n */\n @observed({ deep: true }) accessor schema: IApiAssociationShape | undefined\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n @observed({ deep: true }) accessor bindings: AssociationBinding[]\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n @observed({ deep: true }) accessor targets: AssociationTarget[]\n\n /**\n * Creates a full data association schema with defaults.\n *\n * @param input The partial data association schema.\n * @returns The data association schema.\n */\n static createSchema(input: Partial<DomainAssociationSchema> = {}): DomainAssociationSchema {\n const { key = nanoid() } = input\n const info = Thing.fromJSON(input.info, { name: 'New association' }).toJSON()\n const result: DomainAssociationSchema = {\n kind: DomainAssociationKind,\n key,\n info,\n }\n if (input.schema) {\n result.schema = structuredClone(input.schema)\n }\n if (typeof input.multiple === 'boolean') {\n result.multiple = input.multiple\n }\n if (typeof input.required === 'boolean') {\n result.required = input.required\n }\n if (Array.isArray(input.bindings)) {\n result.bindings = input.bindings.map((i) => structuredClone(i))\n }\n if (Array.isArray(input.targets)) {\n result.targets = input.targets.map((i) => ({ ...i }))\n }\n return result\n }\n\n /**\n * Creates a new data association instance.\n *\n * You probably want to use the `DomainEntity.addAssociation()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param parent The key of the parent entity.\n * @param input The partial data association schema.\n */\n constructor(root: DataDomain, parent: string, input?: Partial<DomainAssociationSchema>) {\n const init = DomainAssociation.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainAssociationKind\n this.info = new Thing(init.info)\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n }\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n if (Array.isArray(init.targets)) {\n this.targets = init.targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n }\n\n /**\n * Generates a JSON representation of the association.\n *\n * @returns A plain object representation of the `DomainAssociation`.\n */\n toJSON(): DomainAssociationSchema {\n const result: DomainAssociationSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = Json.clone(toRaw(this, this.schema))\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = (toRaw(this, this.bindings) as AssociationBinding[]).map((i) => Json.clone(i))\n }\n if (Array.isArray(this.targets) && this.targets.length) {\n result.targets = (toRaw(this, this.targets) as AssociationTarget[]).map((i) => ({ ...i }))\n }\n return result\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n *\n * @returns The parent `DomainEntity` or undefined if not found.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Removes this property from the parent entity.\n *\n * This method removes the association from the parent\n * entity's list of associations.\n *\n * @example\n * ```typescript\n * association.remove();\n * ```\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeAssociation(this.key)\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n *\n * @returns The schema object.\n * @example\n * ```typescript\n * const schema = association.ensureSchema();\n * ```\n */\n ensureSchema(): IApiAssociationShape {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Checks whether the passed value is one of the supported\n * data property attributes.\n *\n * @param value The value to test\n * @returns True when the passed value is one of the\n * supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainAttributeAttributes.includes(value as DomainAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings\n * definition.\n *\n * @returns The web binding definition\n * @example\n * ```typescript\n * const webBindings = association.getWebBinding();\n * webBindings.hidden = true;\n * ```\n */\n getWebBinding(): AssociationWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as AssociationBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as AssociationBinding\n this.bindings.push(object)\n this.domain.notifyChange()\n }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was\n * created.\n *\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n * @example\n * ```typescript\n * const webBindings = association.readBinding('web');\n * if (webBindings) {\n * // ...\n * }\n * ```\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema || undefined\n }\n\n /**\n * Adds a target entity to the association.\n *\n * If the entity comes from another namespace then it is\n * set as a foreign entity.\n *\n * @param entity - The `DomainEntity` instance to add.\n * @example\n * ```typescript\n * association.addTarget(addressEntity);\n * ```\n */\n addTarget(entity: DomainEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `DomainEntity` definition or just\n * its key.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local\n * entities.\n * @example\n * ```typescript\n * association.addTarget('address', 'foreignNamespace');\n * ```\n */\n addTarget(entity: string, namespace?: string): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local entities.\n */\n addTarget(init: string | DomainEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n if (init.domain.key !== this.root.key) {\n namespace = init.domain.key\n }\n }\n if (this.targets.some((i) => i.key === key && i.domain === namespace)) {\n const message = `Target ${key} already exists.`\n throw new Error(message)\n }\n if (namespace && !this.root.dependencies.has(namespace)) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.domain = namespace\n }\n this.targets.push(info)\n const targetKey = namespace ? `${namespace}:${key}` : key\n const label: DomainGraphEdge = {\n type: 'association',\n }\n if (namespace) {\n label.domain = namespace\n label.foreign = true\n }\n // We need to associate the target with the association\n // in the graph. This way, when looking for associations\n // on a target entities we can easily locate the\n // association.\n this.root.graph.setEdge(this.key, targetKey, label)\n // this.root.notifyChange()\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or\n * schema.\n * @example\n * ```typescript\n * association.removeTarget(addressEntity);\n * ```\n */\n removeTarget(init: string | DomainEntity): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n }\n const index = this.targets.findIndex((i) => i.key === key)\n if (index >= 0) {\n this.targets.splice(index, 1)\n // this.root.notifyChange()\n }\n this.root.graph.removeEdge(this.key, key)\n }\n\n /**\n * Lists all target entities of this association.\n *\n * @returns A generator that yields each target\n * `DomainEntity`.\n * @example\n * ```typescript\n * for (const target of association.listTargets()) {\n * console.log(target.key);\n * }\n * ```\n */\n *listTargets(): Generator<DomainEntity> {\n for (const target of this.targets) {\n const { key, domain } = target\n const targetKey = domain ? `${domain}:${key}` : key\n const entity = this.root.graph.node(targetKey) as DomainEntity | undefined\n if (entity) {\n yield entity\n }\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.associationProperty(this)\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import type { DataDomain } from './DataDomain.js';
2
+ export interface DomainElementSchema {
3
+ /**
4
+ * The kind of the domain element.
5
+ */
6
+ kind: string;
7
+ /**
8
+ * The unique key of the domain element.
9
+ */
10
+ key: string;
11
+ }
12
+ export declare abstract class DomainElement implements DomainElementSchema {
13
+ #private;
14
+ /**
15
+ * A reference to the root DataDomain instance.
16
+ */
17
+ protected root: DataDomain;
18
+ /**
19
+ * The root DataDomain instance.
20
+ */
21
+ get domain(): DataDomain;
22
+ abstract accessor kind: string;
23
+ /**
24
+ * The unique key of the domain element.
25
+ */
26
+ get key(): string;
27
+ /**
28
+ * @param root The root DataDomain instance.
29
+ * @param key The unique key of the domain element.
30
+ */
31
+ constructor(root: DataDomain, key: string);
32
+ }
33
+ //# sourceMappingURL=DomainElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomainElement.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,8BAAsB,aAAc,YAAW,mBAAmB;;IAChE;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,UAAU,CAAA;IAE1B;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAQ9B;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;;OAGG;gBACS,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM;CAI1C"}
@@ -0,0 +1,32 @@
1
+ export class DomainElement {
2
+ /**
3
+ * A reference to the root DataDomain instance.
4
+ */
5
+ root;
6
+ /**
7
+ * The root DataDomain instance.
8
+ */
9
+ get domain() {
10
+ return this.root;
11
+ }
12
+ /**
13
+ * The unique key of the domain element.
14
+ * Since keys are immutable, we use a private field to store the key.
15
+ */
16
+ #key;
17
+ /**
18
+ * The unique key of the domain element.
19
+ */
20
+ get key() {
21
+ return this.#key;
22
+ }
23
+ /**
24
+ * @param root The root DataDomain instance.
25
+ * @param key The unique key of the domain element.
26
+ */
27
+ constructor(root, key) {
28
+ this.root = root;
29
+ this.#key = key;
30
+ }
31
+ }
32
+ //# sourceMappingURL=DomainElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomainElement.js","sourceRoot":"","sources":["../../../src/modeling/DomainElement.ts"],"names":[],"mappings":"AAaA,MAAM,OAAgB,aAAa;IACjC;;OAEG;IACO,IAAI,CAAY;IAE1B;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAID;;;OAGG;IACH,IAAI,CAAQ;IAEZ;;OAEG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED;;;OAGG;IACH,YAAY,IAAgB,EAAE,GAAW;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;IACjB,CAAC;CACF","sourcesContent":["import type { DataDomain } from './DataDomain.js'\n\nexport interface DomainElementSchema {\n /**\n * The kind of the domain element.\n */\n kind: string\n /**\n * The unique key of the domain element.\n */\n key: string\n}\n\nexport abstract class DomainElement implements DomainElementSchema {\n /**\n * A reference to the root DataDomain instance.\n */\n protected root: DataDomain\n\n /**\n * The root DataDomain instance.\n */\n get domain(): DataDomain {\n return this.root\n }\n\n abstract accessor kind: string\n\n /**\n * The unique key of the domain element.\n * Since keys are immutable, we use a private field to store the key.\n */\n #key: string\n\n /**\n * The unique key of the domain element.\n */\n get key(): string {\n return this.#key\n }\n\n /**\n * @param root The root DataDomain instance.\n * @param key The unique key of the domain element.\n */\n constructor(root: DataDomain, key: string) {\n this.root = root\n this.#key = key\n }\n}\n"]}