@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,730 @@
1
+ import { test } from '@japa/runner'
2
+ import {
3
+ DataDomain,
4
+ DataDomainKind,
5
+ DomainEntityKind,
6
+ DomainModelKind,
7
+ DomainNamespaceKind,
8
+ DomainEntity,
9
+ Thing,
10
+ } from '../../../src/index.js'
11
+ import type { EntityOrderedItem } from '../../../src/modeling/DomainEntity.js'
12
+
13
+ test.group('DomainEntity.createSchema()', () => {
14
+ test('creates a schema with default values', ({ assert }) => {
15
+ const schema = DomainEntity.createSchema()
16
+ assert.equal(schema.kind, DomainEntityKind)
17
+ assert.typeOf(schema.key, 'string')
18
+ assert.isNotEmpty(schema.key)
19
+ assert.deepInclude(schema.info, { name: 'New entity' })
20
+ assert.isUndefined(schema.tags)
21
+ assert.isUndefined(schema.taxonomy)
22
+ assert.isUndefined(schema.fields)
23
+ assert.isUndefined(schema.deprecated)
24
+ })
25
+
26
+ test('creates a schema with provided values', ({ assert }) => {
27
+ const schema = DomainEntity.createSchema({
28
+ key: 'test-entity',
29
+ info: { name: 'Test Entity', description: 'A test entity' },
30
+ tags: ['tag1', 'tag2'],
31
+ taxonomy: ['tax1', 'tax2'],
32
+ fields: [{ key: 'test-property', type: 'property' }],
33
+ deprecated: true,
34
+ })
35
+ assert.equal(schema.kind, DomainEntityKind)
36
+ assert.equal(schema.key, 'test-entity')
37
+ assert.deepInclude(schema.info, { name: 'Test Entity', description: 'A test entity' })
38
+ assert.deepEqual(schema.tags, ['tag1', 'tag2'])
39
+ assert.deepEqual(schema.taxonomy, ['tax1', 'tax2'])
40
+ assert.deepEqual(schema.fields, [{ key: 'test-property', type: 'property' }])
41
+ assert.isTrue(schema.deprecated)
42
+ })
43
+
44
+ test('creates a schema with partial info', ({ assert }) => {
45
+ const schema = DomainEntity.createSchema({
46
+ info: { name: 'Test Entity' },
47
+ })
48
+ assert.equal(schema.kind, DomainEntityKind)
49
+ assert.typeOf(schema.key, 'string')
50
+ assert.isNotEmpty(schema.key)
51
+ assert.deepInclude(schema.info, { name: 'Test Entity' })
52
+ })
53
+
54
+ test('creates a schema with empty info', ({ assert }) => {
55
+ const schema = DomainEntity.createSchema({
56
+ info: {},
57
+ })
58
+ assert.equal(schema.kind, DomainEntityKind)
59
+ assert.typeOf(schema.key, 'string')
60
+ assert.isNotEmpty(schema.key)
61
+ assert.deepInclude(schema.info, { name: 'New entity' })
62
+ })
63
+
64
+ test('creates a schema with tags', ({ assert }) => {
65
+ const schema = DomainEntity.createSchema({
66
+ tags: ['tag1', 'tag2'],
67
+ })
68
+ assert.equal(schema.kind, DomainEntityKind)
69
+ assert.typeOf(schema.key, 'string')
70
+ assert.isNotEmpty(schema.key)
71
+ assert.deepInclude(schema.info, { name: 'New entity' })
72
+ assert.deepEqual(schema.tags, ['tag1', 'tag2'])
73
+ })
74
+
75
+ test('creates a schema with taxonomy', ({ assert }) => {
76
+ const schema = DomainEntity.createSchema({
77
+ taxonomy: ['tax1', 'tax2'],
78
+ })
79
+ assert.equal(schema.kind, DomainEntityKind)
80
+ assert.typeOf(schema.key, 'string')
81
+ assert.isNotEmpty(schema.key)
82
+ assert.deepInclude(schema.info, { name: 'New entity' })
83
+ assert.deepEqual(schema.taxonomy, ['tax1', 'tax2'])
84
+ })
85
+
86
+ test('creates a schema with fields', ({ assert }) => {
87
+ const schema = DomainEntity.createSchema({
88
+ fields: [{ key: 'test-property', type: 'property' }],
89
+ })
90
+ assert.equal(schema.kind, DomainEntityKind)
91
+ assert.typeOf(schema.key, 'string')
92
+ assert.isNotEmpty(schema.key)
93
+ assert.deepInclude(schema.info, { name: 'New entity' })
94
+ assert.deepEqual(schema.fields, [{ key: 'test-property', type: 'property' }])
95
+ })
96
+
97
+ test('creates a schema with deprecated set to true', ({ assert }) => {
98
+ const schema = DomainEntity.createSchema({
99
+ deprecated: true,
100
+ })
101
+ assert.equal(schema.kind, DomainEntityKind)
102
+ assert.typeOf(schema.key, 'string')
103
+ assert.isNotEmpty(schema.key)
104
+ assert.deepInclude(schema.info, { name: 'New entity' })
105
+ assert.isTrue(schema.deprecated)
106
+ })
107
+
108
+ test('creates a schema with deprecated set to false', ({ assert }) => {
109
+ const schema = DomainEntity.createSchema({
110
+ deprecated: false,
111
+ })
112
+ assert.equal(schema.kind, DomainEntityKind)
113
+ assert.typeOf(schema.key, 'string')
114
+ assert.isNotEmpty(schema.key)
115
+ assert.deepInclude(schema.info, { name: 'New entity' })
116
+ assert.isFalse(schema.deprecated)
117
+ })
118
+
119
+ test('creates a schema with a custom key', ({ assert }) => {
120
+ const customKey = 'custom-key'
121
+ const schema = DomainEntity.createSchema({ key: customKey })
122
+ assert.equal(schema.key, customKey)
123
+ })
124
+
125
+ test('creates a schema with custom info', ({ assert }) => {
126
+ const customInfo = { name: 'Custom Name', description: 'Custom Description' }
127
+ const schema = DomainEntity.createSchema({ info: customInfo })
128
+ assert.deepInclude(schema.info, customInfo)
129
+ })
130
+
131
+ test('creates a schema with custom tags', ({ assert }) => {
132
+ const customTags = ['custom-tag1', 'custom-tag2']
133
+ const schema = DomainEntity.createSchema({ tags: customTags })
134
+ assert.deepEqual(schema.tags, customTags)
135
+ })
136
+
137
+ test('creates a schema with custom taxonomy', ({ assert }) => {
138
+ const customTaxonomy = ['custom-tax1', 'custom-tax2']
139
+ const schema = DomainEntity.createSchema({ taxonomy: customTaxonomy })
140
+ assert.deepEqual(schema.taxonomy, customTaxonomy)
141
+ })
142
+
143
+ test('creates a schema with custom fields', ({ assert }) => {
144
+ const customFields: EntityOrderedItem[] = [{ key: 'custom-property', type: 'property' }]
145
+ const schema = DomainEntity.createSchema({ fields: customFields })
146
+ assert.deepEqual(schema.fields, customFields)
147
+ })
148
+
149
+ test('creates a schema with custom deprecated value', ({ assert }) => {
150
+ const schemaTrue = DomainEntity.createSchema({ deprecated: true })
151
+ assert.isTrue(schemaTrue.deprecated)
152
+
153
+ const schemaFalse = DomainEntity.createSchema({ deprecated: false })
154
+ assert.isFalse(schemaFalse.deprecated)
155
+ })
156
+ })
157
+
158
+ test.group('DomainEntity.constructor()', () => {
159
+ test('creates a new DomainEntity with default values', ({ assert }) => {
160
+ const dataDomain = new DataDomain()
161
+ const entity = new DomainEntity(dataDomain)
162
+ assert.equal(entity.kind, DomainEntityKind)
163
+ assert.typeOf(entity.key, 'string')
164
+ assert.isNotEmpty(entity.key)
165
+ assert.instanceOf(entity.info, Thing)
166
+ assert.equal(entity.info.name, 'New entity')
167
+ assert.deepEqual(entity.tags, [])
168
+ assert.deepEqual(entity.taxonomy, [])
169
+ assert.deepEqual(entity.fields, [])
170
+ assert.isUndefined(entity.deprecated)
171
+ })
172
+
173
+ test('creates a new DomainEntity with provided values', ({ assert }) => {
174
+ const dataDomain = new DataDomain()
175
+ const entity = new DomainEntity(dataDomain, {
176
+ key: 'test-entity',
177
+ info: { name: 'Test Entity', description: 'A test entity' },
178
+ tags: ['tag1', 'tag2'],
179
+ taxonomy: ['tax1', 'tax2'],
180
+ fields: [{ key: 'test-property', type: 'property' }],
181
+ deprecated: true,
182
+ })
183
+ assert.equal(entity.kind, DomainEntityKind)
184
+ assert.equal(entity.key, 'test-entity')
185
+ assert.instanceOf(entity.info, Thing)
186
+ assert.equal(entity.info.name, 'Test Entity')
187
+ assert.equal(entity.info.description, 'A test entity')
188
+ assert.deepEqual(entity.tags, ['tag1', 'tag2'])
189
+ assert.deepEqual(entity.taxonomy, ['tax1', 'tax2'])
190
+ assert.deepEqual(entity.fields, [{ key: 'test-property', type: 'property' }])
191
+ assert.isTrue(entity.deprecated)
192
+ })
193
+
194
+ test('creates a new DomainEntity with partial info', ({ assert }) => {
195
+ const dataDomain = new DataDomain()
196
+ const entity = new DomainEntity(dataDomain, {
197
+ info: { name: 'Test Entity' },
198
+ })
199
+ assert.equal(entity.kind, DomainEntityKind)
200
+ assert.typeOf(entity.key, 'string')
201
+ assert.isNotEmpty(entity.key)
202
+ assert.instanceOf(entity.info, Thing)
203
+ assert.equal(entity.info.name, 'Test Entity')
204
+ })
205
+
206
+ test('creates a new DomainEntity with empty info', ({ assert }) => {
207
+ const dataDomain = new DataDomain()
208
+ const entity = new DomainEntity(dataDomain, {
209
+ info: {},
210
+ })
211
+ assert.equal(entity.kind, DomainEntityKind)
212
+ assert.typeOf(entity.key, 'string')
213
+ assert.isNotEmpty(entity.key)
214
+ assert.instanceOf(entity.info, Thing)
215
+ assert.equal(entity.info.name, 'New entity')
216
+ })
217
+
218
+ test('creates a new DomainEntity with tags', ({ assert }) => {
219
+ const dataDomain = new DataDomain()
220
+ const entity = new DomainEntity(dataDomain, {
221
+ tags: ['tag1', 'tag2'],
222
+ })
223
+ assert.equal(entity.kind, DomainEntityKind)
224
+ assert.typeOf(entity.key, 'string')
225
+ assert.isNotEmpty(entity.key)
226
+ assert.instanceOf(entity.info, Thing)
227
+ assert.equal(entity.info.name, 'New entity')
228
+ assert.deepEqual(entity.tags, ['tag1', 'tag2'])
229
+ })
230
+
231
+ test('creates a new DomainEntity with taxonomy', ({ assert }) => {
232
+ const dataDomain = new DataDomain()
233
+ const entity = new DomainEntity(dataDomain, {
234
+ taxonomy: ['tax1', 'tax2'],
235
+ })
236
+ assert.equal(entity.kind, DomainEntityKind)
237
+ assert.typeOf(entity.key, 'string')
238
+ assert.isNotEmpty(entity.key)
239
+ assert.instanceOf(entity.info, Thing)
240
+ assert.equal(entity.info.name, 'New entity')
241
+ assert.deepEqual(entity.taxonomy, ['tax1', 'tax2'])
242
+ })
243
+
244
+ test('creates a new DomainEntity with fields', ({ assert }) => {
245
+ const dataDomain = new DataDomain()
246
+ const entity = new DomainEntity(dataDomain, {
247
+ fields: [{ key: 'test-property', type: 'property' }],
248
+ })
249
+ assert.equal(entity.kind, DomainEntityKind)
250
+ assert.typeOf(entity.key, 'string')
251
+ assert.isNotEmpty(entity.key)
252
+ assert.instanceOf(entity.info, Thing)
253
+ assert.equal(entity.info.name, 'New entity')
254
+ assert.deepEqual(entity.fields, [{ key: 'test-property', type: 'property' }])
255
+ })
256
+
257
+ test('creates a new DomainEntity with deprecated set to true', ({ assert }) => {
258
+ const dataDomain = new DataDomain()
259
+ const entity = new DomainEntity(dataDomain, {
260
+ deprecated: true,
261
+ })
262
+ assert.equal(entity.kind, DomainEntityKind)
263
+ assert.typeOf(entity.key, 'string')
264
+ assert.isNotEmpty(entity.key)
265
+ assert.instanceOf(entity.info, Thing)
266
+ assert.equal(entity.info.name, 'New entity')
267
+ assert.isTrue(entity.deprecated)
268
+ })
269
+
270
+ test('creates a new DomainEntity with deprecated set to false', ({ assert }) => {
271
+ const dataDomain = new DataDomain()
272
+ const entity = new DomainEntity(dataDomain, {
273
+ deprecated: false,
274
+ })
275
+ assert.equal(entity.kind, DomainEntityKind)
276
+ assert.typeOf(entity.key, 'string')
277
+ assert.isNotEmpty(entity.key)
278
+ assert.instanceOf(entity.info, Thing)
279
+ assert.equal(entity.info.name, 'New entity')
280
+ assert.isFalse(entity.deprecated)
281
+ })
282
+
283
+ test('creates a new DomainEntity with a custom key', ({ assert }) => {
284
+ const dataDomain = new DataDomain()
285
+ const entity = new DomainEntity(dataDomain, { key: 'custom-key' })
286
+ assert.equal(entity.key, 'custom-key')
287
+ })
288
+
289
+ test('creates a new DomainEntity with custom info', ({ assert }) => {
290
+ const dataDomain = new DataDomain()
291
+ const customInfo = { name: 'Custom Name', description: 'Custom Description' }
292
+ const entity = new DomainEntity(dataDomain, { info: customInfo })
293
+ assert.deepInclude(entity.info, customInfo)
294
+ })
295
+
296
+ test('creates a new DomainEntity with custom tags', ({ assert }) => {
297
+ const dataDomain = new DataDomain()
298
+ const customTags = ['custom-tag1', 'custom-tag2']
299
+ const entity = new DomainEntity(dataDomain, { tags: customTags })
300
+ assert.deepEqual(entity.tags, customTags)
301
+ })
302
+
303
+ test('creates a new DomainEntity with custom taxonomy', ({ assert }) => {
304
+ const dataDomain = new DataDomain()
305
+ const customTaxonomy = ['custom-tax1', 'custom-tax2']
306
+ const entity = new DomainEntity(dataDomain, { taxonomy: customTaxonomy })
307
+ assert.deepEqual(entity.taxonomy, customTaxonomy)
308
+ })
309
+
310
+ test('creates a new DomainEntity with custom fields', ({ assert }) => {
311
+ const dataDomain = new DataDomain()
312
+ const customFields: EntityOrderedItem[] = [{ key: 'custom-property', type: 'property' }]
313
+ const entity = new DomainEntity(dataDomain, { fields: customFields })
314
+ assert.deepEqual(entity.fields, customFields)
315
+ })
316
+
317
+ test('creates a new DomainEntity with custom deprecated value', ({ assert }) => {
318
+ const dataDomain = new DataDomain()
319
+ const entityTrue = new DomainEntity(dataDomain, { deprecated: true })
320
+ assert.isTrue(entityTrue.deprecated)
321
+
322
+ const entityFalse = new DomainEntity(dataDomain, { deprecated: false })
323
+ assert.isFalse(entityFalse.deprecated)
324
+ })
325
+
326
+ test('sets deprecated to undefined when not provided', ({ assert }) => {
327
+ const dataDomain = new DataDomain()
328
+ const entity = new DomainEntity(dataDomain, {})
329
+ assert.isUndefined(entity.deprecated)
330
+ })
331
+
332
+ test('sets fields to empty array when not provided', ({ assert }) => {
333
+ const dataDomain = new DataDomain()
334
+ const entity = new DomainEntity(dataDomain, {})
335
+ assert.deepEqual(entity.fields, [])
336
+ })
337
+
338
+ test('sets fields to empty array when fields is undefined', ({ assert }) => {
339
+ const dataDomain = new DataDomain()
340
+ const entity = new DomainEntity(dataDomain, { fields: undefined })
341
+ assert.deepEqual(entity.fields, [])
342
+ })
343
+ })
344
+
345
+ test.group('DomainEntity.toJSON()', () => {
346
+ test('returns a valid schema with default values', ({ assert }) => {
347
+ const dataDomain = new DataDomain()
348
+ const entity = new DomainEntity(dataDomain)
349
+ const json = entity.toJSON()
350
+ assert.equal(json.kind, DomainEntityKind)
351
+ assert.equal(json.key, entity.key)
352
+ assert.deepInclude(json.info, { name: 'New entity' })
353
+ assert.isUndefined(json.tags)
354
+ assert.isUndefined(json.taxonomy)
355
+ assert.isUndefined(json.fields)
356
+ assert.isUndefined(json.deprecated)
357
+ })
358
+
359
+ test('returns a valid schema with provided values', ({ assert }) => {
360
+ const dataDomain = new DataDomain()
361
+ const entity = new DomainEntity(dataDomain, {
362
+ key: 'test-entity',
363
+ info: { name: 'Test Entity', description: 'A test entity' },
364
+ tags: ['tag1', 'tag2'],
365
+ taxonomy: ['tax1', 'tax2'],
366
+ fields: [{ key: 'test-property', type: 'property' }],
367
+ deprecated: true,
368
+ })
369
+ const json = entity.toJSON()
370
+ assert.equal(json.kind, DomainEntityKind)
371
+ assert.equal(json.key, 'test-entity')
372
+ assert.deepInclude(json.info, { name: 'Test Entity', description: 'A test entity' })
373
+ assert.deepEqual(json.tags, ['tag1', 'tag2'])
374
+ assert.deepEqual(json.taxonomy, ['tax1', 'tax2'])
375
+ assert.deepEqual(json.fields, [{ key: 'test-property', type: 'property' }])
376
+ assert.isTrue(json.deprecated)
377
+ })
378
+
379
+ test('includes child properties in the schema', ({ assert }) => {
380
+ const dataDomain = new DataDomain()
381
+ const model = dataDomain.addModel()
382
+ const entity = model.addEntity({ key: 'test-entity' })
383
+ const property = entity.addProperty({ type: 'string' })
384
+ const json = entity.toJSON()
385
+ assert.isArray(json.fields)
386
+ assert.lengthOf(json.fields!, 1)
387
+ assert.deepEqual(json.fields, [{ key: property.key, type: 'property' }])
388
+ })
389
+
390
+ test('includes child associations in the schema', ({ assert }) => {
391
+ const dataDomain = new DataDomain()
392
+ const model = dataDomain.addModel()
393
+ const entity = model.addEntity({ key: 'test-entity' })
394
+ const association = entity.addAssociation()
395
+ const json = entity.toJSON()
396
+ assert.isArray(json.fields)
397
+ assert.lengthOf(json.fields!, 1)
398
+ assert.deepEqual(json.fields, [{ key: association.key, type: 'association' }])
399
+ })
400
+
401
+ test('includes deprecated flag when true', ({ assert }) => {
402
+ const dataDomain = new DataDomain()
403
+ const model = dataDomain.addModel()
404
+ const entity = model.addEntity({ key: 'test-entity', deprecated: true })
405
+ const json = entity.toJSON()
406
+ assert.isTrue(json.deprecated)
407
+ })
408
+
409
+ test('includes deprecated flag when false', ({ assert }) => {
410
+ const dataDomain = new DataDomain()
411
+ const model = dataDomain.addModel()
412
+ const entity = model.addEntity({ key: 'test-entity', deprecated: false })
413
+ const json = entity.toJSON()
414
+ assert.isFalse(json.deprecated)
415
+ })
416
+
417
+ test('includes multiple fields in the correct order', ({ assert }) => {
418
+ const dataDomain = new DataDomain()
419
+ const model = dataDomain.addModel()
420
+ const entity = model.addEntity()
421
+ const property1 = entity.addProperty({ type: 'string' })
422
+ const association1 = entity.addAssociation()
423
+ const property2 = entity.addProperty({ type: 'string' })
424
+ const association2 = entity.addAssociation()
425
+ const json = entity.toJSON()
426
+ assert.isArray(json.fields)
427
+ assert.lengthOf(json.fields!, 4)
428
+ assert.deepEqual(json.fields, [
429
+ { key: property1.key, type: 'property' },
430
+ { key: association1.key, type: 'association' },
431
+ { key: property2.key, type: 'property' },
432
+ { key: association2.key, type: 'association' },
433
+ ])
434
+ })
435
+
436
+ test('serializes the "info" property', ({ assert }) => {
437
+ const dataDomain = new DataDomain()
438
+ const model = dataDomain.addModel()
439
+ const entity = model.addEntity({
440
+ key: 'test-entity',
441
+ info: { name: 'Test Name', description: 'Test Description' },
442
+ })
443
+ const json = entity.toJSON()
444
+ assert.deepInclude(json.info, { name: 'Test Name', description: 'Test Description' })
445
+ })
446
+
447
+ test('serializes the "tags" property', ({ assert }) => {
448
+ const dataDomain = new DataDomain()
449
+ const model = dataDomain.addModel()
450
+ const entity = model.addEntity({
451
+ key: 'test-entity',
452
+ tags: ['tag1', 'tag2'],
453
+ })
454
+ const json = entity.toJSON()
455
+ assert.deepEqual(json.tags, ['tag1', 'tag2'])
456
+ })
457
+
458
+ test('serializes the "taxonomy" property', ({ assert }) => {
459
+ const dataDomain = new DataDomain()
460
+ const model = dataDomain.addModel()
461
+ const entity = model.addEntity({
462
+ key: 'test-entity',
463
+ taxonomy: ['tax1', 'tax2'],
464
+ })
465
+ const json = entity.toJSON()
466
+ assert.deepEqual(json.taxonomy, ['tax1', 'tax2'])
467
+ })
468
+ })
469
+
470
+ test.group('DomainEntity.getParentInstance()', () => {
471
+ test('returns the parent model when the entity is a child', ({ assert }) => {
472
+ const dataDomain = new DataDomain()
473
+ const model = dataDomain.addModel()
474
+ const entity = model.addEntity()
475
+ const parent = entity.getParentInstance()
476
+ assert.deepEqual(parent, model)
477
+ })
478
+
479
+ test('returns undefined when the entity has no parent', ({ assert }) => {
480
+ const dataDomain = new DataDomain()
481
+ const model = dataDomain.addModel()
482
+ const entity = model.addEntity()
483
+ dataDomain.graph.removeParent(entity.key)
484
+ const parent = entity.getParentInstance()
485
+ assert.isUndefined(parent)
486
+ })
487
+
488
+ test('returns the correct parent when there are multiple levels of nesting', ({ assert }) => {
489
+ const dataDomain = new DataDomain()
490
+ const model = dataDomain.addModel()
491
+ const entity = model.addEntity()
492
+ entity.addProperty()
493
+ const parent = entity.getParentInstance()
494
+ assert.deepEqual(parent, model)
495
+ })
496
+
497
+ test('returns the correct parent when the entity is attached to a different model', ({ assert }) => {
498
+ const dataDomain = new DataDomain()
499
+ const model1 = dataDomain.addModel({ key: 'model1' })
500
+ const model2 = dataDomain.addModel({ key: 'model2' })
501
+ const entity = model1.addEntity({ key: 'entity1' })
502
+ model2.attachEntity(entity.key)
503
+ const parent = entity.getParentInstance()
504
+ assert.deepEqual(parent, model2)
505
+ })
506
+ })
507
+
508
+ test.group('DomainEntity.breadcrumbs()', () => {
509
+ test('creates breadcrumbs from entity to data domain', ({ assert }) => {
510
+ const dataDomain = new DataDomain()
511
+ const model = dataDomain.addModel()
512
+ const entity = model.addEntity({ info: { name: 'Test Entity' } })
513
+ const breadcrumbs = entity.breadcrumbs()
514
+ assert.lengthOf(breadcrumbs, 3)
515
+ assert.deepEqual(breadcrumbs[0], {
516
+ key: dataDomain.key,
517
+ name: 'Unnamed domain',
518
+ kind: DataDomainKind,
519
+ })
520
+ assert.deepEqual(breadcrumbs[1], {
521
+ key: model.key,
522
+ name: 'New model',
523
+ kind: DomainModelKind,
524
+ })
525
+ assert.deepEqual(breadcrumbs[2], {
526
+ key: entity.key,
527
+ name: 'Test Entity',
528
+ kind: DomainEntityKind,
529
+ })
530
+ })
531
+
532
+ test('creates breadcrumbs from entity to data domain with custom names', ({ assert }) => {
533
+ const dataDomain = new DataDomain()
534
+ dataDomain.info.name = 'Custom Data Domain'
535
+ const model = dataDomain.addModel({ info: { name: 'Test Model' } })
536
+ const entity = model.addEntity({ info: { name: 'Test Entity' } })
537
+ const breadcrumbs = entity.breadcrumbs()
538
+ assert.lengthOf(breadcrumbs, 3)
539
+ assert.deepEqual(breadcrumbs[0], {
540
+ key: dataDomain.key,
541
+ name: 'Custom Data Domain',
542
+ kind: DataDomainKind,
543
+ })
544
+ assert.deepEqual(breadcrumbs[1], {
545
+ key: model.key,
546
+ name: 'Test Model',
547
+ kind: DomainModelKind,
548
+ })
549
+ assert.deepEqual(breadcrumbs[2], {
550
+ key: entity.key,
551
+ name: 'Test Entity',
552
+ kind: DomainEntityKind,
553
+ })
554
+ })
555
+
556
+ test('creates breadcrumbs from entity to namespace to data domain', ({ assert }) => {
557
+ const dataDomain = new DataDomain()
558
+ const namespace = dataDomain.addNamespace({ info: { name: 'Test Namespace' } })
559
+ const model = namespace.addModel({ info: { name: 'Test Model' } })
560
+ const entity = model.addEntity({ info: { name: 'Test Entity' } })
561
+ const breadcrumbs = entity.breadcrumbs()
562
+ assert.lengthOf(breadcrumbs, 4)
563
+ assert.deepEqual(breadcrumbs[0], {
564
+ key: dataDomain.key,
565
+ name: 'Unnamed domain',
566
+ kind: DataDomainKind,
567
+ })
568
+ assert.deepEqual(breadcrumbs[1], {
569
+ key: namespace.key,
570
+ name: 'Test Namespace',
571
+ kind: DomainNamespaceKind,
572
+ })
573
+ assert.deepEqual(breadcrumbs[2], {
574
+ key: model.key,
575
+ name: 'Test Model',
576
+ kind: DomainModelKind,
577
+ })
578
+ assert.deepEqual(breadcrumbs[3], {
579
+ key: entity.key,
580
+ name: 'Test Entity',
581
+ kind: DomainEntityKind,
582
+ })
583
+ })
584
+
585
+ test('creates breadcrumbs from entity to nested namespaces to data domain', ({ assert }) => {
586
+ const dataDomain = new DataDomain()
587
+ const namespace1 = dataDomain.addNamespace({ info: { name: 'Test Namespace 1' } })
588
+ const namespace2 = namespace1.addNamespace({ info: { name: 'Test Namespace 2' } })
589
+ const model = namespace2.addModel({ info: { name: 'Test Model' } })
590
+ const entity = model.addEntity({ info: { name: 'Test Entity' } })
591
+ const breadcrumbs = entity.breadcrumbs()
592
+ assert.lengthOf(breadcrumbs, 5)
593
+ assert.deepEqual(breadcrumbs[0], {
594
+ key: dataDomain.key,
595
+ name: 'Unnamed domain',
596
+ kind: DataDomainKind,
597
+ })
598
+ assert.deepEqual(breadcrumbs[1], {
599
+ key: namespace1.key,
600
+ name: 'Test Namespace 1',
601
+ kind: DomainNamespaceKind,
602
+ })
603
+ assert.deepEqual(breadcrumbs[2], {
604
+ key: namespace2.key,
605
+ name: 'Test Namespace 2',
606
+ kind: DomainNamespaceKind,
607
+ })
608
+ assert.deepEqual(breadcrumbs[3], {
609
+ key: model.key,
610
+ name: 'Test Model',
611
+ kind: DomainModelKind,
612
+ })
613
+ assert.deepEqual(breadcrumbs[4], {
614
+ key: entity.key,
615
+ name: 'Test Entity',
616
+ kind: DomainEntityKind,
617
+ })
618
+ })
619
+
620
+ test('creates breadcrumbs with unnamed data domain, namespaces, and entity', ({ assert }) => {
621
+ const dataDomain = new DataDomain()
622
+ dataDomain.info.name = undefined
623
+ const namespace1 = dataDomain.addNamespace()
624
+ namespace1.info.name = undefined
625
+ const namespace2 = namespace1.addNamespace()
626
+ namespace2.info.name = undefined
627
+ const model = namespace2.addModel()
628
+ model.info.name = undefined
629
+ const entity = model.addEntity()
630
+ entity.info.name = undefined
631
+ const breadcrumbs = entity.breadcrumbs()
632
+ assert.lengthOf(breadcrumbs, 5)
633
+ assert.deepEqual(breadcrumbs[0], {
634
+ key: dataDomain.key,
635
+ name: 'Unnamed data domain',
636
+ kind: DataDomainKind,
637
+ })
638
+ assert.deepEqual(breadcrumbs[1], {
639
+ key: namespace1.key,
640
+ name: 'Unnamed namespace',
641
+ kind: DomainNamespaceKind,
642
+ })
643
+ assert.deepEqual(breadcrumbs[2], {
644
+ key: namespace2.key,
645
+ name: 'Unnamed namespace',
646
+ kind: DomainNamespaceKind,
647
+ })
648
+ assert.deepEqual(breadcrumbs[3], {
649
+ key: model.key,
650
+ name: 'Unnamed model',
651
+ kind: DomainModelKind,
652
+ })
653
+ assert.deepEqual(breadcrumbs[4], {
654
+ key: entity.key,
655
+ name: 'Unnamed entity',
656
+ kind: DomainEntityKind,
657
+ })
658
+ })
659
+ })
660
+
661
+ test.group('DomainEntity.isChildOf()', () => {
662
+ test('returns false when called on self', ({ assert }) => {
663
+ const dataDomain = new DataDomain()
664
+ const model = dataDomain.addModel()
665
+ const entity = model.addEntity()
666
+ assert.isFalse(entity.isChildOf(entity.key))
667
+ })
668
+
669
+ test('returns true when called on a direct parent (DomainModel)', ({ assert }) => {
670
+ const dataDomain = new DataDomain()
671
+ const model = dataDomain.addModel()
672
+ const entity = model.addEntity()
673
+ assert.isTrue(entity.isChildOf(model.key))
674
+ })
675
+
676
+ test('returns true when called on a grandparent (DomainNamespace)', ({ assert }) => {
677
+ const dataDomain = new DataDomain()
678
+ const namespace = dataDomain.addNamespace()
679
+ const model = namespace.addModel()
680
+ const entity = model.addEntity()
681
+ assert.isTrue(entity.isChildOf(namespace.key))
682
+ })
683
+
684
+ test('returns true when called on a great-grandparent (DataDomain)', ({ assert }) => {
685
+ const dataDomain = new DataDomain()
686
+ const namespace = dataDomain.addNamespace()
687
+ const model = namespace.addModel()
688
+ const entity = model.addEntity()
689
+ assert.isTrue(entity.isChildOf(dataDomain.key))
690
+ })
691
+
692
+ test('returns false when called on a sibling entity', ({ assert }) => {
693
+ const dataDomain = new DataDomain()
694
+ const model = dataDomain.addModel()
695
+ const entity1 = model.addEntity()
696
+ const entity2 = model.addEntity()
697
+ assert.isFalse(entity1.isChildOf(entity2.key))
698
+ })
699
+
700
+ test('returns false when called on a child property', ({ assert }) => {
701
+ const dataDomain = new DataDomain()
702
+ const model = dataDomain.addModel()
703
+ const entity = model.addEntity()
704
+ const property = entity.addProperty()
705
+ assert.isFalse(entity.isChildOf(property.key))
706
+ })
707
+
708
+ test('returns false when called on a non-existent key', ({ assert }) => {
709
+ const dataDomain = new DataDomain()
710
+ const model = dataDomain.addModel()
711
+ const entity = model.addEntity()
712
+ assert.isFalse(entity.isChildOf('non-existent-key'))
713
+ })
714
+
715
+ test('returns false when the entity has no parent', ({ assert }) => {
716
+ const dataDomain = new DataDomain()
717
+ const model = dataDomain.addModel()
718
+ const entity = model.addEntity()
719
+ dataDomain.graph.removeParent(entity.key)
720
+ assert.isFalse(entity.isChildOf(model.key))
721
+ })
722
+
723
+ test('returns true when there are multiple levels of nesting', ({ assert }) => {
724
+ const dataDomain = new DataDomain()
725
+ const namespace = dataDomain.addNamespace()
726
+ const model = namespace.addModel()
727
+ const entity = model.addEntity()
728
+ assert.isTrue(entity.isChildOf(dataDomain.key))
729
+ })
730
+ })