@api-client/core 0.13.6 → 0.14.1

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 (174) hide show
  1. package/build/src/amf/AmfTypes.d.ts +1 -1
  2. package/build/src/amf/AmfTypes.js +1 -1
  3. package/build/src/amf/AmfTypes.js.map +1 -1
  4. package/build/src/amf/Utils.d.ts +0 -6
  5. package/build/src/amf/Utils.d.ts.map +1 -1
  6. package/build/src/amf/Utils.js +0 -14
  7. package/build/src/amf/Utils.js.map +1 -1
  8. package/build/src/browser.d.ts +1 -0
  9. package/build/src/browser.d.ts.map +1 -1
  10. package/build/src/browser.js +1 -0
  11. package/build/src/browser.js.map +1 -1
  12. package/build/src/index.d.ts +1 -0
  13. package/build/src/index.d.ts.map +1 -1
  14. package/build/src/index.js +1 -0
  15. package/build/src/index.js.map +1 -1
  16. package/build/src/legacy.d.ts +0 -8
  17. package/build/src/legacy.d.ts.map +1 -1
  18. package/build/src/legacy.js +0 -9
  19. package/build/src/legacy.js.map +1 -1
  20. package/build/src/modeling/Bindings.d.ts +1 -1
  21. package/build/src/modeling/Bindings.js.map +1 -1
  22. package/build/src/modeling/DataDomain.js +2 -2
  23. package/build/src/modeling/DataDomain.js.map +1 -1
  24. package/build/src/modeling/DataFormat.d.ts +0 -40
  25. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  26. package/build/src/modeling/DataFormat.js +0 -27
  27. package/build/src/modeling/DataFormat.js.map +1 -1
  28. package/build/src/modeling/DomainAssociation.d.ts +28 -0
  29. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  30. package/build/src/modeling/DomainAssociation.js +73 -4
  31. package/build/src/modeling/DomainAssociation.js.map +1 -1
  32. package/build/src/modeling/DomainEntity.d.ts +25 -9
  33. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  34. package/build/src/modeling/DomainEntity.js +65 -21
  35. package/build/src/modeling/DomainEntity.js.map +1 -1
  36. package/build/src/modeling/DomainFile.d.ts +3 -4
  37. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  38. package/build/src/modeling/DomainFile.js +5 -9
  39. package/build/src/modeling/DomainFile.js.map +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  42. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  43. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  44. package/build/src/modeling/DomainModel.d.ts +2 -2
  45. package/build/src/modeling/DomainModel.js +2 -2
  46. package/build/src/modeling/DomainModel.js.map +1 -1
  47. package/build/src/modeling/DomainProperty.d.ts +28 -12
  48. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  49. package/build/src/modeling/DomainProperty.js +61 -26
  50. package/build/src/modeling/DomainProperty.js.map +1 -1
  51. package/build/src/modeling/Semantics.d.ts +109 -0
  52. package/build/src/modeling/Semantics.d.ts.map +1 -0
  53. package/build/src/modeling/Semantics.js +97 -0
  54. package/build/src/modeling/Semantics.js.map +1 -0
  55. package/build/src/models/CertificateFile.d.ts +2 -3
  56. package/build/src/models/CertificateFile.d.ts.map +1 -1
  57. package/build/src/models/CertificateFile.js +4 -8
  58. package/build/src/models/CertificateFile.js.map +1 -1
  59. package/build/src/models/Folder.d.ts +1 -2
  60. package/build/src/models/Folder.d.ts.map +1 -1
  61. package/build/src/models/Folder.js +2 -4
  62. package/build/src/models/Folder.js.map +1 -1
  63. package/build/src/models/Project.d.ts +2 -3
  64. package/build/src/models/Project.d.ts.map +1 -1
  65. package/build/src/models/Project.js +4 -8
  66. package/build/src/models/Project.js.map +1 -1
  67. package/build/src/models/kinds.d.ts +0 -24
  68. package/build/src/models/kinds.d.ts.map +1 -1
  69. package/build/src/models/kinds.js +0 -24
  70. package/build/src/models/kinds.js.map +1 -1
  71. package/build/src/models/store/File.d.ts +1 -21
  72. package/build/src/models/store/File.d.ts.map +1 -1
  73. package/build/src/models/store/File.js +3 -23
  74. package/build/src/models/store/File.js.map +1 -1
  75. package/build/src/models/store/data_catalog.d.ts +1 -1
  76. package/build/src/models/store/data_catalog.js.map +1 -1
  77. package/build/src/sdk/FilesSdk.js +1 -1
  78. package/build/src/sdk/FilesSdk.js.map +1 -1
  79. package/build/tsconfig.tsbuildinfo +1 -1
  80. package/data/models/example-generator-api.json +22 -22
  81. package/eslint.config.js +1 -0
  82. package/package.json +5 -5
  83. package/src/amf/AmfTypes.ts +1 -1
  84. package/src/amf/Utils.ts +0 -15
  85. package/src/modeling/Bindings.ts +1 -1
  86. package/src/modeling/DataDomain.ts +2 -2
  87. package/src/modeling/DataFormat.ts +0 -48
  88. package/src/modeling/DomainAssociation.ts +66 -3
  89. package/src/modeling/DomainEntity.ts +56 -17
  90. package/src/modeling/DomainFile.ts +5 -9
  91. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  92. package/src/modeling/DomainModel.ts +2 -2
  93. package/src/modeling/DomainProperty.ts +60 -21
  94. package/src/modeling/Semantics.ts +178 -0
  95. package/src/modeling/graph.md +14 -14
  96. package/src/modeling/readme.md +29 -29
  97. package/src/models/CertificateFile.ts +4 -12
  98. package/src/models/Folder.ts +2 -4
  99. package/src/models/Project.ts +4 -8
  100. package/src/models/kinds.ts +0 -25
  101. package/src/models/store/File.ts +4 -35
  102. package/src/models/store/data_catalog.ts +1 -1
  103. package/src/sdk/FilesSdk.ts +1 -1
  104. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  105. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  106. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  107. package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
  108. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  109. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  110. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  111. package/tests/unit/modeling/domain_file.spec.ts +4 -27
  112. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  113. package/tests/unit/models/Certificate/from_name.spec.ts +3 -15
  114. package/tests/unit/models/File/constructor.spec.ts +0 -1
  115. package/tests/unit/models/File/new.spec.ts +0 -13
  116. package/tests/unit/models/File/shortcutTo.spec.ts +1 -2
  117. package/tests/unit/models/File/toJSON.spec.ts +0 -13
  118. package/tests/unit/models/File/updateByMeMeta.spec.ts +4 -6
  119. package/tests/unit/models/Folder/create.spec.ts +2 -23
  120. package/tests/unit/models/Project/create.spec.ts +6 -32
  121. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  122. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  123. package/build/src/amf/AmfShapeGenerator.js +0 -416
  124. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  125. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  126. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  127. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  128. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  129. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  130. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  131. package/build/src/modeling/legacy/DataEntity.js +0 -855
  132. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  133. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  134. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  135. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  136. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  137. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  138. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  139. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  140. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  141. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  142. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  143. package/build/src/modeling/legacy/DataModel.js +0 -237
  144. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  145. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  146. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  147. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  148. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  149. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  150. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  151. package/build/src/modeling/legacy/DataProperty.js +0 -415
  152. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  153. package/build/src/models/store/DataFile.d.ts +0 -31
  154. package/build/src/models/store/DataFile.d.ts.map +0 -1
  155. package/build/src/models/store/DataFile.js +0 -92
  156. package/build/src/models/store/DataFile.js.map +0 -1
  157. package/src/amf/AmfShapeGenerator.ts +0 -477
  158. package/src/modeling/legacy/DataAssociation.ts +0 -554
  159. package/src/modeling/legacy/DataEntity.ts +0 -1019
  160. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  161. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  162. package/src/modeling/legacy/DataModel.ts +0 -276
  163. package/src/modeling/legacy/DataNamespace.ts +0 -929
  164. package/src/modeling/legacy/DataProperty.ts +0 -630
  165. package/src/models/store/DataFile.ts +0 -100
  166. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  167. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  168. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  169. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  170. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  171. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  172. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  173. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  174. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -7,6 +7,7 @@ import {
7
7
  AssociationBinding,
8
8
  DataDomain,
9
9
  DataFormat,
10
+ SemanticType,
10
11
  } from '../../../src/index.js'
11
12
 
12
13
  test.group('DomainAssociation.createSchema()', () => {
@@ -21,6 +22,7 @@ test.group('DomainAssociation.createSchema()', () => {
21
22
  assert.isUndefined(schema.required)
22
23
  assert.isUndefined(schema.bindings)
23
24
  assert.isUndefined(schema.targets)
25
+ assert.deepEqual(schema.semantics, [])
24
26
  })
25
27
 
26
28
  test('creates a schema with provided key', ({ assert }) => {
@@ -35,6 +37,12 @@ test.group('DomainAssociation.createSchema()', () => {
35
37
  assert.deepEqual(schema.info, Thing.fromJSON(info).toJSON())
36
38
  })
37
39
 
40
+ test('creates a schema with provided semantics', ({ assert }) => {
41
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
42
+ const schema = DomainAssociation.createSchema({ semantics })
43
+ assert.deepEqual(schema.semantics, semantics)
44
+ })
45
+
38
46
  test('creates a schema with provided schema', ({ assert }) => {
39
47
  const schemaDefinition: AmfShapes.IApiAssociationShape = { linked: false }
40
48
  const schema = DomainAssociation.createSchema({ schema: schemaDefinition })
@@ -71,6 +79,7 @@ test.group('DomainAssociation.createSchema()', () => {
71
79
  const required = true
72
80
  const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
73
81
  const targets = [{ key: 'target1', domain: 'domain1' }, { key: 'target2' }]
82
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
74
83
 
75
84
  const schema = DomainAssociation.createSchema({
76
85
  key,
@@ -80,6 +89,7 @@ test.group('DomainAssociation.createSchema()', () => {
80
89
  required,
81
90
  bindings,
82
91
  targets,
92
+ semantics,
83
93
  })
84
94
 
85
95
  assert.equal(schema.key, key)
@@ -89,6 +99,7 @@ test.group('DomainAssociation.createSchema()', () => {
89
99
  assert.equal(schema.required, required)
90
100
  assert.deepEqual(schema.bindings, bindings)
91
101
  assert.deepEqual(schema.targets, targets)
102
+ assert.deepEqual(schema.semantics, semantics)
92
103
  })
93
104
 
94
105
  test('creates a schema with cloned bindings', ({ assert }) => {
@@ -98,6 +109,13 @@ test.group('DomainAssociation.createSchema()', () => {
98
109
  assert.notStrictEqual(schema.bindings, bindings)
99
110
  })
100
111
 
112
+ test('creates a schema with cloned semantics', ({ assert }) => {
113
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
114
+ const schema = DomainAssociation.createSchema({ semantics })
115
+ assert.deepEqual(schema.semantics, semantics)
116
+ assert.notStrictEqual(schema.semantics, semantics)
117
+ })
118
+
101
119
  test('creates a schema with cloned targets', ({ assert }) => {
102
120
  const targets = [{ key: 'target1', domain: 'domain1' }, { key: 'target2' }]
103
121
  const schema = DomainAssociation.createSchema({ targets })
@@ -126,6 +144,7 @@ test.group('DomainAssociation.constructor()', () => {
126
144
  assert.isUndefined(association.required)
127
145
  assert.deepEqual(association.bindings, [])
128
146
  assert.deepEqual(association.targets, [])
147
+ assert.deepEqual(association.semantics, [])
129
148
  })
130
149
 
131
150
  test('creates an instance with provided key', ({ assert }) => {
@@ -136,6 +155,14 @@ test.group('DomainAssociation.constructor()', () => {
136
155
  assert.equal(association.key, key)
137
156
  })
138
157
 
158
+ test('creates an instance with provided semantics', ({ assert }) => {
159
+ const dataDomain = new DataDomain()
160
+ const parentKey = 'test-parent'
161
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
162
+ const association = new DomainAssociation(dataDomain, parentKey, { semantics })
163
+ assert.deepEqual(association.semantics, semantics)
164
+ })
165
+
139
166
  test('creates an instance with provided info', ({ assert }) => {
140
167
  const dataDomain = new DataDomain()
141
168
  const parentKey = 'test-parent'
@@ -192,6 +219,7 @@ test.group('DomainAssociation.constructor()', () => {
192
219
  const required = true
193
220
  const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
194
221
  const targets = [{ key: 'target1', domain: 'domain1' }, { key: 'target2' }]
222
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
195
223
 
196
224
  const association = new DomainAssociation(dataDomain, parentKey, {
197
225
  key,
@@ -201,6 +229,7 @@ test.group('DomainAssociation.constructor()', () => {
201
229
  required,
202
230
  bindings,
203
231
  targets,
232
+ semantics,
204
233
  })
205
234
 
206
235
  assert.equal(association.key, key)
@@ -210,6 +239,7 @@ test.group('DomainAssociation.constructor()', () => {
210
239
  assert.equal(association.required, required)
211
240
  assert.deepEqual(association.bindings, bindings)
212
241
  assert.deepEqual(association.targets, targets)
242
+ assert.deepEqual(association.semantics, semantics)
213
243
  })
214
244
 
215
245
  test('creates an instance with cloned bindings', ({ assert }) => {
@@ -221,6 +251,15 @@ test.group('DomainAssociation.constructor()', () => {
221
251
  assert.notStrictEqual(association.bindings, bindings)
222
252
  })
223
253
 
254
+ test('creates an instance with cloned semantics', ({ assert }) => {
255
+ const dataDomain = new DataDomain()
256
+ const parentKey = 'test-parent'
257
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
258
+ const association = new DomainAssociation(dataDomain, parentKey, { semantics })
259
+ assert.deepEqual(association.semantics, semantics)
260
+ assert.notStrictEqual(association.semantics, semantics)
261
+ })
262
+
224
263
  test('creates an instance with cloned targets', ({ assert }) => {
225
264
  const dataDomain = new DataDomain()
226
265
  const parentKey = 'test-parent'
@@ -254,6 +293,7 @@ test.group('DomainAssociation.toJSON()', () => {
254
293
  assert.isUndefined(json.required)
255
294
  assert.isUndefined(json.bindings)
256
295
  assert.isUndefined(json.targets)
296
+ assert.isUndefined(json.semantics)
257
297
  })
258
298
 
259
299
  test('returns a JSON representation with provided key', ({ assert }) => {
@@ -265,6 +305,15 @@ test.group('DomainAssociation.toJSON()', () => {
265
305
  assert.equal(json.key, key)
266
306
  })
267
307
 
308
+ test('returns a JSON representation with provided semantics', ({ assert }) => {
309
+ const dataDomain = new DataDomain()
310
+ const parentKey = 'test-parent'
311
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
312
+ const association = new DomainAssociation(dataDomain, parentKey, { semantics })
313
+ const json = association.toJSON()
314
+ assert.deepEqual(json.semantics, semantics)
315
+ })
316
+
268
317
  test('returns a JSON representation with provided info', ({ assert }) => {
269
318
  const dataDomain = new DataDomain()
270
319
  const parentKey = 'test-parent'
@@ -330,6 +379,7 @@ test.group('DomainAssociation.toJSON()', () => {
330
379
  const required = true
331
380
  const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
332
381
  const targets = [{ key: 'target1', domain: 'domain1' }, { key: 'target2' }]
382
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
333
383
 
334
384
  const association = new DomainAssociation(dataDomain, parentKey, {
335
385
  key,
@@ -339,6 +389,7 @@ test.group('DomainAssociation.toJSON()', () => {
339
389
  required,
340
390
  bindings,
341
391
  targets,
392
+ semantics,
342
393
  })
343
394
 
344
395
  const json = association.toJSON()
@@ -350,6 +401,7 @@ test.group('DomainAssociation.toJSON()', () => {
350
401
  assert.equal(json.required, required)
351
402
  assert.deepEqual(json.bindings, bindings)
352
403
  assert.deepEqual(json.targets, targets)
404
+ assert.deepEqual(json.semantics, semantics)
353
405
  })
354
406
 
355
407
  test('returns a JSON representation with cloned bindings', ({ assert }) => {
@@ -362,6 +414,16 @@ test.group('DomainAssociation.toJSON()', () => {
362
414
  assert.notStrictEqual(json.bindings, bindings)
363
415
  })
364
416
 
417
+ test('returns a JSON representation with cloned semantics when it is set after creation', ({ assert }) => {
418
+ const dataDomain = new DataDomain()
419
+ const parentKey = 'test-parent'
420
+ const association = new DomainAssociation(dataDomain, parentKey)
421
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
422
+ association.semantics = semantics
423
+ const json = association.toJSON()
424
+ assert.deepEqual(json.semantics, semantics)
425
+ })
426
+
365
427
  test('returns a JSON representation with cloned targets', ({ assert }) => {
366
428
  const dataDomain = new DataDomain()
367
429
  const parentKey = 'test-parent'
@@ -641,3 +703,118 @@ test.group('DomainAssociation.readBinding()', () => {
641
703
  assert.isUndefined(webBindings)
642
704
  })
643
705
  })
706
+
707
+ test.group('DomainAssociation.addSemantic()', () => {
708
+ test('adds a new semantic to the association', ({ assert }) => {
709
+ const dataDomain = new DataDomain()
710
+ const association = new DomainAssociation(dataDomain, 'test-parent')
711
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
712
+ association.addSemantic(semantic)
713
+ assert.deepInclude(association.semantics, semantic)
714
+ })
715
+
716
+ test('updates an existing semantic', ({ assert }) => {
717
+ const dataDomain = new DataDomain()
718
+ const association = new DomainAssociation(dataDomain, 'test-parent')
719
+ const semantic1 = { id: SemanticType.ResourceOwnerIdentifier, config: { value: 'old' } }
720
+ const semantic2 = { id: SemanticType.ResourceOwnerIdentifier, config: { value: 'new' } }
721
+ association.addSemantic(semantic1)
722
+ association.addSemantic(semantic2)
723
+ assert.lengthOf(association.semantics, 1)
724
+ assert.deepInclude(association.semantics, semantic2)
725
+ })
726
+
727
+ test('throws an error if the semantic is not an association semantic', ({ assert }) => {
728
+ const dataDomain = new DataDomain()
729
+ const association = new DomainAssociation(dataDomain, 'test-parent')
730
+ const semantic = { id: SemanticType.User } // User is an Entity semantic
731
+ assert.throws(() => {
732
+ association.addSemantic(semantic)
733
+ }, `Invalid semantic type: ${SemanticType.User}. Expected an association semantic.`)
734
+ })
735
+
736
+ test('notifies change when adding a new semantic', async ({ assert }) => {
737
+ const dataDomain = new DataDomain()
738
+ const association = new DomainAssociation(dataDomain, 'test-parent')
739
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
740
+ association.addSemantic(semantic)
741
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
742
+ })
743
+
744
+ test('notifies change when updating an existing semantic', async ({ assert }) => {
745
+ const dataDomain = new DataDomain()
746
+ const association = new DomainAssociation(dataDomain, 'test-parent')
747
+ const semantic1 = { id: SemanticType.ResourceOwnerIdentifier, config: { value: 'old' } }
748
+ const semantic2 = { id: SemanticType.ResourceOwnerIdentifier, config: { value: 'new' } }
749
+ association.addSemantic(semantic1)
750
+ // Clear the event queue before the second add
751
+ await new Promise((resolve) => setTimeout(resolve, 0))
752
+ association.addSemantic(semantic2)
753
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
754
+ })
755
+ })
756
+
757
+ test.group('DomainAssociation.removeSemantic()', () => {
758
+ test('removes an existing semantic from the association', ({ assert }) => {
759
+ const dataDomain = new DataDomain()
760
+ const association = new DomainAssociation(dataDomain, 'test-parent')
761
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
762
+ association.addSemantic(semantic)
763
+ assert.deepInclude(association.semantics, semantic)
764
+ association.removeSemantic(SemanticType.ResourceOwnerIdentifier)
765
+ assert.notDeepInclude(association.semantics, semantic)
766
+ assert.lengthOf(association.semantics, 0)
767
+ })
768
+
769
+ test('does nothing if the semantic to remove does not exist', ({ assert }) => {
770
+ const dataDomain = new DataDomain()
771
+ const association = new DomainAssociation(dataDomain, 'test-parent')
772
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
773
+ association.addSemantic(semantic)
774
+ const initialSemantics = [...association.semantics]
775
+ association.removeSemantic('non-existent-semantic-id' as SemanticType)
776
+ assert.deepEqual(association.semantics, initialSemantics)
777
+ })
778
+
779
+ test('notifies change when a semantic is removed', async ({ assert }) => {
780
+ const dataDomain = new DataDomain()
781
+ const association = new DomainAssociation(dataDomain, 'test-parent')
782
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
783
+ association.addSemantic(semantic)
784
+ // Clear the event queue before removal
785
+ await new Promise((resolve) => setTimeout(resolve, 0))
786
+ association.removeSemantic(SemanticType.ResourceOwnerIdentifier)
787
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
788
+ })
789
+
790
+ test('does not notify change if the semantic to remove does not exist', async ({ assert }) => {
791
+ const dataDomain = new DataDomain()
792
+ const association = new DomainAssociation(dataDomain, 'test-parent')
793
+ // Clear the event queue before removal
794
+ await new Promise((resolve) => setTimeout(resolve, 0))
795
+ association.removeSemantic('non-existent-semantic-id' as SemanticType)
796
+ await assert.notDispatches(dataDomain, 'change', { timeout: 20 })
797
+ })
798
+ })
799
+
800
+ test.group('DomainAssociation.hasSemantic()', () => {
801
+ test('returns true if the association has the specified semantic', ({ assert }) => {
802
+ const dataDomain = new DataDomain()
803
+ const association = new DomainAssociation(dataDomain, 'test-parent')
804
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
805
+ association.addSemantic(semantic)
806
+ assert.isTrue(association.hasSemantic(SemanticType.ResourceOwnerIdentifier))
807
+ })
808
+
809
+ test('returns false if the association does not have the specified semantic', ({ assert }) => {
810
+ const dataDomain = new DataDomain()
811
+ const association = new DomainAssociation(dataDomain, 'test-parent')
812
+ assert.isFalse(association.hasSemantic(SemanticType.ResourceOwnerIdentifier))
813
+ })
814
+
815
+ test('returns false for an empty semantics array', ({ assert }) => {
816
+ const dataDomain = new DataDomain()
817
+ const association = new DomainAssociation(dataDomain, 'test-parent')
818
+ assert.isFalse(association.hasSemantic(SemanticType.ResourceOwnerIdentifier))
819
+ })
820
+ })
@@ -9,6 +9,7 @@ import {
9
9
  Thing,
10
10
  } from '../../../src/index.js'
11
11
  import type { EntityOrderedItem } from '../../../src/modeling/DomainEntity.js'
12
+ import { SemanticType } from '../../../src/modeling/Semantics.js'
12
13
 
13
14
  test.group('DomainEntity.createSchema()', () => {
14
15
  test('creates a schema with default values', ({ assert }) => {
@@ -18,7 +19,7 @@ test.group('DomainEntity.createSchema()', () => {
18
19
  assert.isNotEmpty(schema.key)
19
20
  assert.deepInclude(schema.info, { name: 'New entity' })
20
21
  assert.isUndefined(schema.tags)
21
- assert.isUndefined(schema.taxonomy)
22
+ assert.isUndefined(schema.semantics)
22
23
  assert.isUndefined(schema.fields)
23
24
  assert.isUndefined(schema.deprecated)
24
25
  })
@@ -28,7 +29,7 @@ test.group('DomainEntity.createSchema()', () => {
28
29
  key: 'test-entity',
29
30
  info: { name: 'Test Entity', description: 'A test entity' },
30
31
  tags: ['tag1', 'tag2'],
31
- taxonomy: ['tax1', 'tax2'],
32
+ semantics: [{ id: SemanticType.User }],
32
33
  fields: [{ key: 'test-property', type: 'property' }],
33
34
  deprecated: true,
34
35
  })
@@ -36,7 +37,7 @@ test.group('DomainEntity.createSchema()', () => {
36
37
  assert.equal(schema.key, 'test-entity')
37
38
  assert.deepInclude(schema.info, { name: 'Test Entity', description: 'A test entity' })
38
39
  assert.deepEqual(schema.tags, ['tag1', 'tag2'])
39
- assert.deepEqual(schema.taxonomy, ['tax1', 'tax2'])
40
+ assert.deepEqual(schema.semantics, [{ id: SemanticType.User }])
40
41
  assert.deepEqual(schema.fields, [{ key: 'test-property', type: 'property' }])
41
42
  assert.isTrue(schema.deprecated)
42
43
  })
@@ -72,15 +73,15 @@ test.group('DomainEntity.createSchema()', () => {
72
73
  assert.deepEqual(schema.tags, ['tag1', 'tag2'])
73
74
  })
74
75
 
75
- test('creates a schema with taxonomy', ({ assert }) => {
76
+ test('creates a schema with semantics', ({ assert }) => {
76
77
  const schema = DomainEntity.createSchema({
77
- taxonomy: ['tax1', 'tax2'],
78
+ semantics: [{ id: SemanticType.User }],
78
79
  })
79
80
  assert.equal(schema.kind, DomainEntityKind)
80
81
  assert.typeOf(schema.key, 'string')
81
82
  assert.isNotEmpty(schema.key)
82
83
  assert.deepInclude(schema.info, { name: 'New entity' })
83
- assert.deepEqual(schema.taxonomy, ['tax1', 'tax2'])
84
+ assert.deepEqual(schema.semantics, [{ id: SemanticType.User }])
84
85
  })
85
86
 
86
87
  test('creates a schema with fields', ({ assert }) => {
@@ -134,10 +135,10 @@ test.group('DomainEntity.createSchema()', () => {
134
135
  assert.deepEqual(schema.tags, customTags)
135
136
  })
136
137
 
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)
138
+ test('creates a schema with custom semantics', ({ assert }) => {
139
+ const customSemantics = [{ id: SemanticType.User }]
140
+ const schema = DomainEntity.createSchema({ semantics: customSemantics })
141
+ assert.deepEqual(schema.semantics, customSemantics)
141
142
  })
142
143
 
143
144
  test('creates a schema with custom fields', ({ assert }) => {
@@ -165,7 +166,7 @@ test.group('DomainEntity.constructor()', () => {
165
166
  assert.instanceOf(entity.info, Thing)
166
167
  assert.equal(entity.info.name, 'New entity')
167
168
  assert.deepEqual(entity.tags, [])
168
- assert.deepEqual(entity.taxonomy, [])
169
+ assert.deepEqual(entity.semantics, [])
169
170
  assert.deepEqual(entity.fields, [])
170
171
  assert.isUndefined(entity.deprecated)
171
172
  })
@@ -176,7 +177,7 @@ test.group('DomainEntity.constructor()', () => {
176
177
  key: 'test-entity',
177
178
  info: { name: 'Test Entity', description: 'A test entity' },
178
179
  tags: ['tag1', 'tag2'],
179
- taxonomy: ['tax1', 'tax2'],
180
+ semantics: [{ id: SemanticType.User }],
180
181
  fields: [{ key: 'test-property', type: 'property' }],
181
182
  deprecated: true,
182
183
  })
@@ -186,7 +187,7 @@ test.group('DomainEntity.constructor()', () => {
186
187
  assert.equal(entity.info.name, 'Test Entity')
187
188
  assert.equal(entity.info.description, 'A test entity')
188
189
  assert.deepEqual(entity.tags, ['tag1', 'tag2'])
189
- assert.deepEqual(entity.taxonomy, ['tax1', 'tax2'])
190
+ assert.deepEqual(entity.semantics, [{ id: SemanticType.User }])
190
191
  assert.deepEqual(entity.fields, [{ key: 'test-property', type: 'property' }])
191
192
  assert.isTrue(entity.deprecated)
192
193
  })
@@ -228,17 +229,17 @@ test.group('DomainEntity.constructor()', () => {
228
229
  assert.deepEqual(entity.tags, ['tag1', 'tag2'])
229
230
  })
230
231
 
231
- test('creates a new DomainEntity with taxonomy', ({ assert }) => {
232
+ test('creates a new DomainEntity with semantics', ({ assert }) => {
232
233
  const dataDomain = new DataDomain()
233
234
  const entity = new DomainEntity(dataDomain, {
234
- taxonomy: ['tax1', 'tax2'],
235
+ semantics: [{ id: SemanticType.User }],
235
236
  })
236
237
  assert.equal(entity.kind, DomainEntityKind)
237
238
  assert.typeOf(entity.key, 'string')
238
239
  assert.isNotEmpty(entity.key)
239
240
  assert.instanceOf(entity.info, Thing)
240
241
  assert.equal(entity.info.name, 'New entity')
241
- assert.deepEqual(entity.taxonomy, ['tax1', 'tax2'])
242
+ assert.deepEqual(entity.semantics, [{ id: SemanticType.User }])
242
243
  })
243
244
 
244
245
  test('creates a new DomainEntity with fields', ({ assert }) => {
@@ -300,11 +301,11 @@ test.group('DomainEntity.constructor()', () => {
300
301
  assert.deepEqual(entity.tags, customTags)
301
302
  })
302
303
 
303
- test('creates a new DomainEntity with custom taxonomy', ({ assert }) => {
304
+ test('creates a new DomainEntity with custom semantics', ({ assert }) => {
304
305
  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)
306
+ const customSemantics = [{ id: SemanticType.User }]
307
+ const entity = new DomainEntity(dataDomain, { semantics: customSemantics })
308
+ assert.deepEqual(entity.semantics, customSemantics)
308
309
  })
309
310
 
310
311
  test('creates a new DomainEntity with custom fields', ({ assert }) => {
@@ -351,7 +352,7 @@ test.group('DomainEntity.toJSON()', () => {
351
352
  assert.equal(json.key, entity.key)
352
353
  assert.deepInclude(json.info, { name: 'New entity' })
353
354
  assert.isUndefined(json.tags)
354
- assert.isUndefined(json.taxonomy)
355
+ assert.isUndefined(json.semantics)
355
356
  assert.isUndefined(json.fields)
356
357
  assert.isUndefined(json.deprecated)
357
358
  })
@@ -362,7 +363,7 @@ test.group('DomainEntity.toJSON()', () => {
362
363
  key: 'test-entity',
363
364
  info: { name: 'Test Entity', description: 'A test entity' },
364
365
  tags: ['tag1', 'tag2'],
365
- taxonomy: ['tax1', 'tax2'],
366
+ semantics: [{ id: SemanticType.User }],
366
367
  fields: [{ key: 'test-property', type: 'property' }],
367
368
  deprecated: true,
368
369
  })
@@ -371,7 +372,7 @@ test.group('DomainEntity.toJSON()', () => {
371
372
  assert.equal(json.key, 'test-entity')
372
373
  assert.deepInclude(json.info, { name: 'Test Entity', description: 'A test entity' })
373
374
  assert.deepEqual(json.tags, ['tag1', 'tag2'])
374
- assert.deepEqual(json.taxonomy, ['tax1', 'tax2'])
375
+ assert.deepEqual(json.semantics, [{ id: SemanticType.User }])
375
376
  assert.deepEqual(json.fields, [{ key: 'test-property', type: 'property' }])
376
377
  assert.isTrue(json.deprecated)
377
378
  })
@@ -455,15 +456,15 @@ test.group('DomainEntity.toJSON()', () => {
455
456
  assert.deepEqual(json.tags, ['tag1', 'tag2'])
456
457
  })
457
458
 
458
- test('serializes the "taxonomy" property', ({ assert }) => {
459
+ test('serializes the "semantics" property', ({ assert }) => {
459
460
  const dataDomain = new DataDomain()
460
461
  const model = dataDomain.addModel()
461
462
  const entity = model.addEntity({
462
463
  key: 'test-entity',
463
- taxonomy: ['tax1', 'tax2'],
464
+ semantics: [{ id: SemanticType.User }],
464
465
  })
465
466
  const json = entity.toJSON()
466
- assert.deepEqual(json.taxonomy, ['tax1', 'tax2'])
467
+ assert.deepEqual(json.semantics, [{ id: SemanticType.User }])
467
468
  })
468
469
  })
469
470
 
@@ -9,7 +9,7 @@ const dateRe = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
9
9
  const timeRe = /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/
10
10
  const mime = 'application/json'
11
11
 
12
- test.group('JSON DataEntity Generator: string', (group) => {
12
+ test.group('JSON DomainEntity Generator: string', (group) => {
13
13
  let e1: DomainEntity
14
14
 
15
15
  group.each.setup(() => {
@@ -140,7 +140,7 @@ test.group('JSON DataEntity Generator: string', (group) => {
140
140
  })
141
141
  })
142
142
 
143
- test.group('JSON DataEntity Generator: number', (group) => {
143
+ test.group('JSON DomainEntity Generator: number', (group) => {
144
144
  let e1: DomainEntity
145
145
 
146
146
  group.each.setup(() => {
@@ -289,7 +289,7 @@ test.group('JSON DataEntity Generator: number', (group) => {
289
289
  })
290
290
  })
291
291
 
292
- test.group('JSON DataEntity Generator: int64 format', (group) => {
292
+ test.group('JSON DomainEntity Generator: int64 format', (group) => {
293
293
  let e1: DomainEntity
294
294
  let p1: DomainProperty
295
295
 
@@ -416,7 +416,7 @@ test.group('JSON DataEntity Generator: int64 format', (group) => {
416
416
  })
417
417
  })
418
418
 
419
- test.group('JSON DataEntity Generator: date', (group) => {
419
+ test.group('JSON DomainEntity Generator: date', (group) => {
420
420
  let e1: DomainEntity
421
421
 
422
422
  group.each.setup(() => {
@@ -492,7 +492,7 @@ test.group('JSON DataEntity Generator: date', (group) => {
492
492
  })
493
493
  })
494
494
 
495
- test.group('JSON DataEntity Generator: datetime', (group) => {
495
+ test.group('JSON DomainEntity Generator: datetime', (group) => {
496
496
  let e1: DomainEntity
497
497
 
498
498
  group.each.setup(() => {
@@ -557,7 +557,7 @@ test.group('JSON DataEntity Generator: datetime', (group) => {
557
557
  })
558
558
  })
559
559
 
560
- test.group('JSON DataEntity Generator: time', (group) => {
560
+ test.group('JSON DomainEntity Generator: time', (group) => {
561
561
  let e1: DomainEntity
562
562
 
563
563
  group.each.setup(() => {
@@ -633,7 +633,7 @@ test.group('JSON DataEntity Generator: time', (group) => {
633
633
  })
634
634
  })
635
635
 
636
- test.group('JSON DataEntity Generator: boolean', (group) => {
636
+ test.group('JSON DomainEntity Generator: boolean', (group) => {
637
637
  let e1: DomainEntity
638
638
 
639
639
  group.each.setup(() => {
@@ -662,7 +662,7 @@ test.group('JSON DataEntity Generator: boolean', (group) => {
662
662
  })
663
663
  })
664
664
 
665
- // test.group('JSON DataEntity Generator: nil', (group) => {
665
+ // test.group('JSON DomainEntity Generator: nil', (group) => {
666
666
  // let e1: DomainEntity
667
667
 
668
668
  // group.each.setup(() => {
@@ -691,7 +691,7 @@ test.group('JSON DataEntity Generator: boolean', (group) => {
691
691
  // })
692
692
  // })
693
693
 
694
- test.group('JSON DataEntity Generator: binary', (group) => {
694
+ test.group('JSON DomainEntity Generator: binary', (group) => {
695
695
  let e1: DomainEntity
696
696
 
697
697
  group.each.setup(() => {
@@ -715,7 +715,7 @@ test.group('JSON DataEntity Generator: binary', (group) => {
715
715
  })
716
716
  })
717
717
 
718
- test.group('JSON DataEntity Generator: associations', (group) => {
718
+ test.group('JSON DomainEntity Generator: associations', (group) => {
719
719
  let n1: DataDomain
720
720
  let d1: DomainModel
721
721
  let e1: DomainEntity
@@ -906,7 +906,7 @@ test.group('JSON DataEntity Generator: associations', (group) => {
906
906
  })
907
907
  })
908
908
 
909
- test.group('JSON DataEntity Generator: parents', (group) => {
909
+ test.group('JSON DomainEntity Generator: parents', (group) => {
910
910
  let d1: DomainModel
911
911
  let e1: DomainEntity
912
912
  let e2: DomainEntity
@@ -7,7 +7,7 @@ const dateRe = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
7
7
  const timeRe = /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/
8
8
  const mime = 'application/xml'
9
9
 
10
- test.group('XML DataEntity Generator: string', (group) => {
10
+ test.group('XML DomainEntity Generator: string', (group) => {
11
11
  let e1: DomainEntity
12
12
 
13
13
  group.each.setup(() => {
@@ -177,7 +177,7 @@ test.group('XML DataEntity Generator: string', (group) => {
177
177
  })
178
178
  })
179
179
 
180
- test.group('XML DataEntity Generator: number', (group) => {
180
+ test.group('XML DomainEntity Generator: number', (group) => {
181
181
  let e1: DomainEntity
182
182
 
183
183
  group.each.setup(() => {
@@ -416,7 +416,7 @@ test.group('XML DataEntity Generator: number', (group) => {
416
416
  })
417
417
  })
418
418
 
419
- test.group('XML DataEntity Generator: int64 format', (group) => {
419
+ test.group('XML DomainEntity Generator: int64 format', (group) => {
420
420
  let e1: DomainEntity
421
421
  let p1: DomainProperty
422
422
 
@@ -641,7 +641,7 @@ test.group('XML DataEntity Generator: int64 format', (group) => {
641
641
  })
642
642
  })
643
643
 
644
- test.group('XML DataEntity Generator: date', (group) => {
644
+ test.group('XML DomainEntity Generator: date', (group) => {
645
645
  let e1: DomainEntity
646
646
 
647
647
  group.each.setup(() => {
@@ -768,7 +768,7 @@ test.group('XML DataEntity Generator: date', (group) => {
768
768
  })
769
769
  })
770
770
 
771
- test.group('XML DataEntity Generator: datetime', (group) => {
771
+ test.group('XML DomainEntity Generator: datetime', (group) => {
772
772
  let e1: DomainEntity
773
773
 
774
774
  group.each.setup(() => {
@@ -877,7 +877,7 @@ test.group('XML DataEntity Generator: datetime', (group) => {
877
877
  })
878
878
  })
879
879
 
880
- test.group('XML DataEntity Generator: time', (group) => {
880
+ test.group('XML DomainEntity Generator: time', (group) => {
881
881
  let e1: DomainEntity
882
882
 
883
883
  group.each.setup(() => {
@@ -1004,7 +1004,7 @@ test.group('XML DataEntity Generator: time', (group) => {
1004
1004
  })
1005
1005
  })
1006
1006
 
1007
- test.group('XML DataEntity Generator: boolean', (group) => {
1007
+ test.group('XML DomainEntity Generator: boolean', (group) => {
1008
1008
  let e1: DomainEntity
1009
1009
 
1010
1010
  group.each.setup(() => {
@@ -1049,7 +1049,7 @@ test.group('XML DataEntity Generator: boolean', (group) => {
1049
1049
  })
1050
1050
  })
1051
1051
 
1052
- // test.group('XML DataEntity Generator: nil', (group) => {
1052
+ // test.group('XML DomainEntity Generator: nil', (group) => {
1053
1053
  // let e1: DomainEntity
1054
1054
 
1055
1055
  // group.each.setup(() => {
@@ -1094,7 +1094,7 @@ test.group('XML DataEntity Generator: boolean', (group) => {
1094
1094
  // })
1095
1095
  // })
1096
1096
 
1097
- test.group('XML DataEntity Generator: associations', (group) => {
1097
+ test.group('XML DomainEntity Generator: associations', (group) => {
1098
1098
  let d1: DomainModel
1099
1099
  let e1: DomainEntity
1100
1100
  let e2: DomainEntity
@@ -1319,7 +1319,7 @@ test.group('XML DataEntity Generator: associations', (group) => {
1319
1319
  }).skip()
1320
1320
  })
1321
1321
 
1322
- test.group('XML DataEntity Generator: parents', (group) => {
1322
+ test.group('XML DomainEntity Generator: parents', (group) => {
1323
1323
  let d1: DomainModel
1324
1324
  let e1: DomainEntity
1325
1325
  let e2: DomainEntity