@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
@@ -20,28 +20,3 @@ export const DataCatalogKind = 'Core#DataCatalog'
20
20
  export const DataCatalogVersionKind = 'Core#DataCatalogVersion'
21
21
  export const OrganizationKind = 'Core#Organization'
22
22
  export const InvitationKind = 'Core#Invitation'
23
-
24
- /**
25
- * @deprecated Not used anymore.
26
- */
27
- export const DataFileKind = 'Core#DataFile'
28
- /**
29
- * @deprecated Not used anymore.
30
- */
31
- export const DataNamespaceKind = 'Data#DataNamespace'
32
- /**
33
- * @deprecated Not used anymore.
34
- */
35
- export const DataModelKind = 'Data#DataModel'
36
- /**
37
- * @deprecated Not used anymore.
38
- */
39
- export const DataEntityKind = 'Data#DataEntity'
40
- /**
41
- * @deprecated Not used anymore.
42
- */
43
- export const DataAssociationKind = 'Data#DataAssociation'
44
- /**
45
- * @deprecated Not used anymore.
46
- */
47
- export const DataPropertyKind = 'Data#DataProperty'
@@ -51,19 +51,10 @@ export interface IStoredFile {
51
51
  * The identifier of the entity
52
52
  */
53
53
  key: string
54
- /**
55
- * The parent organization of the file.
56
- */
57
- organization: string
58
54
  /**
59
55
  * The file's meta info.
60
56
  */
61
57
  info: IThing
62
- /**
63
- * The owner of this object. The id of the User object.
64
- * Once the File is persistent by the API this is always populated.
65
- */
66
- owner?: string
67
58
  /**
68
59
  * The color of the icon to render for this file in the file explorer.
69
60
  * This should be a hex format, e.g.: #c00 for red.
@@ -144,7 +135,6 @@ export interface IFile extends IStoredFile {
144
135
  const parentsSymbol = Symbol('parents')
145
136
  const deletedSymbol = Symbol('deleted')
146
137
  const deletedInfoSymbol = Symbol('deletedInfo')
147
- const ownerSymbol = Symbol('owner')
148
138
  const lastModifiedSymbol = Symbol('lastModified')
149
139
  const capabilitiesSymbol = Symbol('capabilities')
150
140
  const permissionsSymbol = Symbol('permissions')
@@ -160,24 +150,10 @@ export class StoredFile {
160
150
  * The identifier of the entity
161
151
  */
162
152
  key = ''
163
- /**
164
- * The parent organization of the file.
165
- */
166
- organization = ''
167
153
  /**
168
154
  * The name of the environment.
169
155
  */
170
- info: Thing = Thing.fromName('');
171
-
172
- [ownerSymbol]?: string
173
-
174
- /**
175
- * The owner of this file. This is the id of the User object.
176
- * Set to `default` when there are no users in the system (no authentication).
177
- */
178
- get owner(): string | undefined {
179
- return this[ownerSymbol]
180
- }
156
+ info: Thing = Thing.fromName('')
181
157
 
182
158
  /**
183
159
  * The color of the icon to render for this file in the file explorer.
@@ -206,11 +182,9 @@ export class StoredFile {
206
182
  }
207
183
 
208
184
  new(init: IStoredFile): this {
209
- const { key = nanoid(), info, kind, owner, iconColor, organization, shortcutTarget } = init
185
+ const { key = nanoid(), info, kind, iconColor, shortcutTarget } = init
210
186
  this.key = key
211
- this.organization = organization
212
187
  this.kind = kind
213
- this[ownerSymbol] = owner
214
188
  if (info) {
215
189
  this.info = new Thing(info)
216
190
  } else {
@@ -230,13 +204,10 @@ export class StoredFile {
230
204
  }
231
205
 
232
206
  toJSON(): IStoredFile {
233
- const { owner } = this
234
207
  const result: IStoredFile = {
235
208
  key: this.key,
236
- organization: this.organization,
237
209
  kind: this.kind,
238
210
  info: this.info.toJSON(),
239
- owner,
240
211
  }
241
212
  if (this.iconColor) {
242
213
  result.iconColor = this.iconColor
@@ -484,19 +455,17 @@ export class File extends StoredFile {
484
455
  * @param name The name to set.
485
456
  * @param owner The user id that is the owner of the file.
486
457
  */
487
- static fromName(name: string, organization: string, owner?: string, kind = ''): File {
458
+ static fromName(name: string, kind = ''): File {
488
459
  const key = nanoid()
489
460
  const definition = new File()
490
461
  definition.new({
491
462
  key,
492
463
  kind,
493
- organization,
494
464
  info: Thing.fromName(name).toJSON(),
495
- owner,
496
465
  parents: [],
497
466
  permissionIds: [],
498
467
  permissions: [],
499
- lastModified: { user: owner || '', time: 0, byMe: false },
468
+ lastModified: { user: '', time: 0, byMe: false },
500
469
  })
501
470
  return definition
502
471
  }
@@ -23,7 +23,7 @@ export interface PublishedDataDomain {
23
23
  */
24
24
  version: string
25
25
  /**
26
- * Key of the referenced `DataNamespace` document.
26
+ * Key of the referenced `DomainNamespace` document.
27
27
  * Essentially this is a document id.
28
28
  */
29
29
  fid: string
@@ -200,7 +200,7 @@ export class FilesSdk extends SdkBase {
200
200
  opts: IMetaCreateOptions = {},
201
201
  request: SdkOptions = {}
202
202
  ): Promise<IFolder> {
203
- const file = Folder.fromName(name, organization)
203
+ const file = Folder.fromName(name)
204
204
  const { token } = request
205
205
  const url = this.sdk.getUrl(RouteBuilder.files(organization))
206
206
  if (opts.parent) {
@@ -1,5 +1,6 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { DataDomain, DataFormat } from '../../../src/index.js'
3
+ import { SemanticType } from '../../../src/modeling/Semantics.js'
3
4
 
4
5
  test.group('DataDomain change observers', () => {
5
6
  test('does not notifies a change when initializing a domain', async ({ assert }) => {
@@ -276,24 +277,24 @@ test.group('DomainEntity change observers', () => {
276
277
  await assert.dispatchCount(domain, 'change', 1, { timeout: 1 })
277
278
  })
278
279
 
279
- test('notifies a change when adding a taxonomy', async ({ assert, sleep }) => {
280
+ test('notifies a change when adding a semantics', async ({ assert, sleep }) => {
280
281
  const domain = new DataDomain()
281
282
  const n1 = domain.addNamespace()
282
283
  const m1 = n1.addModel()
283
284
  const e1 = m1.addEntity()
284
285
  await sleep(1)
285
- e1.taxonomy.push('test')
286
+ e1.semantics.push({ id: SemanticType.User })
286
287
  await assert.dispatchCount(domain, 'change', 1, { timeout: 1 })
287
288
  })
288
289
 
289
- test('notifies a change when removing a taxonomy', async ({ assert, sleep }) => {
290
+ test('notifies a change when removing a semantics', async ({ assert, sleep }) => {
290
291
  const domain = new DataDomain()
291
292
  const n1 = domain.addNamespace()
292
293
  const m1 = n1.addModel()
293
294
  const e1 = m1.addEntity()
294
- e1.taxonomy.push('test')
295
+ e1.semantics.push({ id: SemanticType.User })
295
296
  await sleep(1)
296
- e1.taxonomy.pop()
297
+ e1.semantics.pop()
297
298
  await assert.dispatchCount(domain, 'change', 1, { timeout: 1 })
298
299
  })
299
300
 
@@ -508,26 +509,26 @@ test.group('DomainProperty change observers', () => {
508
509
  await assert.dispatchCount(domain, 'change', 1, { timeout: 1 })
509
510
  })
510
511
 
511
- test('notifies a change when adding a taxonomy', async ({ assert, sleep }) => {
512
+ test('notifies a change when adding a semantics', async ({ assert, sleep }) => {
512
513
  const domain = new DataDomain()
513
514
  const n1 = domain.addNamespace()
514
515
  const m1 = n1.addModel()
515
516
  const e1 = m1.addEntity()
516
517
  const p1 = e1.addProperty()
517
518
  await sleep(1)
518
- p1.taxonomy.push('test')
519
+ p1.semantics.push({ id: SemanticType.CreatedTimestamp })
519
520
  await assert.dispatchCount(domain, 'change', 1, { timeout: 1 })
520
521
  })
521
522
 
522
- test('notifies a change when removing a taxonomy', async ({ assert, sleep }) => {
523
+ test('notifies a change when removing a semantics', async ({ assert, sleep }) => {
523
524
  const domain = new DataDomain()
524
525
  const n1 = domain.addNamespace()
525
526
  const m1 = n1.addModel()
526
527
  const e1 = m1.addEntity()
527
528
  const p1 = e1.addProperty()
528
- p1.taxonomy.push('test')
529
+ p1.semantics.push({ id: SemanticType.CreatedTimestamp })
529
530
  await sleep(1)
530
- p1.taxonomy.pop()
531
+ p1.semantics.pop()
531
532
  await assert.dispatchCount(domain, 'change', 1, { timeout: 1 })
532
533
  })
533
534
 
@@ -1,6 +1,7 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { DataDomain } from '../../../src/modeling/DataDomain.js'
3
3
  import { DomainEntity } from '../../../src/modeling/DomainEntity.js'
4
+ import { SemanticType } from '../../../src/modeling/Semantics.js'
4
5
 
5
6
  test.group('DataDomain.addEntity()', () => {
6
7
  test('addEntity adds an entity to the graph', ({ assert }) => {
@@ -70,7 +71,7 @@ test.group('DataDomain.addEntity()', () => {
70
71
  assert.throws(() => {
71
72
  // @ts-expect-error For testing purposes, we are passing undefined
72
73
  dataDomain.addEntity(undefined, { key: 'test-entity' })
73
- }, `An entity expects a DataModel parent`)
74
+ }, `An entity expects a DomainModel parent`)
74
75
  })
75
76
 
76
77
  test('addEntity throws when adding the same entity twice', ({ assert }) => {
@@ -328,6 +329,133 @@ test.group('DataDomain.findEntity()', () => {
328
329
  })
329
330
  })
330
331
 
332
+ test.group('DomainEntity.addSemantic()', () => {
333
+ test('adds a new semantic to the entity', ({ assert }) => {
334
+ const dataDomain = new DataDomain()
335
+ const model = dataDomain.addModel({ key: 'test-model' })
336
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
337
+ const semantic = { id: SemanticType.User }
338
+ entity.addSemantic(semantic)
339
+ assert.deepInclude(entity.semantics, semantic)
340
+ })
341
+
342
+ test('updates an existing semantic', ({ assert }) => {
343
+ const dataDomain = new DataDomain()
344
+ const model = dataDomain.addModel({ key: 'test-model' })
345
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
346
+ const semantic1 = { id: SemanticType.User, config: { value: 'old' } }
347
+ const semantic2 = { id: SemanticType.User, config: { value: 'new' } }
348
+ entity.addSemantic(semantic1)
349
+ entity.addSemantic(semantic2)
350
+ assert.lengthOf(entity.semantics, 1)
351
+ assert.deepInclude(entity.semantics, semantic2)
352
+ })
353
+
354
+ test('throws an error if the semantic is not an entity semantic', ({ assert }) => {
355
+ const dataDomain = new DataDomain()
356
+ const model = dataDomain.addModel({ key: 'test-model' })
357
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
358
+ const semantic = { id: SemanticType.CreatedTimestamp } // CreatedTimestamp is a Property semantic
359
+ assert.throws(() => {
360
+ entity.addSemantic(semantic)
361
+ }, `Invalid semantic type: ${SemanticType.CreatedTimestamp}. Expected an entity semantic.`)
362
+ })
363
+
364
+ test('notifies change when adding a new semantic', async ({ assert }) => {
365
+ const dataDomain = new DataDomain()
366
+ const model = dataDomain.addModel({ key: 'test-model' })
367
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
368
+ const semantic = { id: SemanticType.User }
369
+ entity.addSemantic(semantic)
370
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
371
+ })
372
+
373
+ test('notifies change when updating an existing semantic', async ({ assert }) => {
374
+ const dataDomain = new DataDomain()
375
+ const model = dataDomain.addModel({ key: 'test-model' })
376
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
377
+ const semantic1 = { id: SemanticType.User, config: { value: 'old' } }
378
+ const semantic2 = { id: SemanticType.User, config: { value: 'new' } }
379
+ entity.addSemantic(semantic1)
380
+ // Clear the event queue before the second add
381
+ await new Promise((resolve) => setTimeout(resolve, 0))
382
+ entity.addSemantic(semantic2)
383
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
384
+ })
385
+ })
386
+
387
+ test.group('DomainEntity.removeSemantic()', () => {
388
+ test('removes an existing semantic from the entity', ({ assert }) => {
389
+ const dataDomain = new DataDomain()
390
+ const model = dataDomain.addModel({ key: 'test-model' })
391
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
392
+ const semantic = { id: SemanticType.User }
393
+ entity.addSemantic(semantic)
394
+ assert.deepInclude(entity.semantics, semantic)
395
+ entity.removeSemantic(SemanticType.User)
396
+ assert.notDeepInclude(entity.semantics, semantic)
397
+ assert.lengthOf(entity.semantics, 0)
398
+ })
399
+
400
+ test('does nothing if the semantic to remove does not exist', ({ assert }) => {
401
+ const dataDomain = new DataDomain()
402
+ const model = dataDomain.addModel({ key: 'test-model' })
403
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
404
+ const semantic = { id: SemanticType.User }
405
+ entity.addSemantic(semantic)
406
+ const initialSemantics = [...entity.semantics]
407
+ entity.removeSemantic('non-existent-semantic-id' as SemanticType)
408
+ assert.deepEqual(entity.semantics, initialSemantics)
409
+ })
410
+
411
+ test('notifies change when a semantic is removed', async ({ assert }) => {
412
+ const dataDomain = new DataDomain()
413
+ const model = dataDomain.addModel({ key: 'test-model' })
414
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
415
+ const semantic = { id: SemanticType.User }
416
+ entity.addSemantic(semantic)
417
+ // Clear the event queue before removal
418
+ await new Promise((resolve) => setTimeout(resolve, 0))
419
+ entity.removeSemantic(SemanticType.User)
420
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
421
+ })
422
+
423
+ test('does not notify change if the semantic to remove does not exist', async ({ assert }) => {
424
+ const dataDomain = new DataDomain()
425
+ const model = dataDomain.addModel({ key: 'test-model' })
426
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
427
+ // Clear the event queue before removal
428
+ await new Promise((resolve) => setTimeout(resolve, 0))
429
+ entity.removeSemantic('non-existent-semantic-id' as SemanticType)
430
+ await assert.notDispatches(dataDomain, 'change', { timeout: 20 })
431
+ })
432
+ })
433
+
434
+ test.group('DomainEntity.hasSemantic()', () => {
435
+ test('returns true if the entity has the specified semantic', ({ assert }) => {
436
+ const dataDomain = new DataDomain()
437
+ const model = dataDomain.addModel({ key: 'test-model' })
438
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
439
+ const semantic = { id: SemanticType.User }
440
+ entity.addSemantic(semantic)
441
+ assert.isTrue(entity.hasSemantic(SemanticType.User))
442
+ })
443
+
444
+ test('returns false if the entity does not have the specified semantic', ({ assert }) => {
445
+ const dataDomain = new DataDomain()
446
+ const model = dataDomain.addModel({ key: 'test-model' })
447
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
448
+ assert.isFalse(entity.hasSemantic(SemanticType.User))
449
+ })
450
+
451
+ test('returns false for an empty semantics array', ({ assert }) => {
452
+ const dataDomain = new DataDomain()
453
+ const model = dataDomain.addModel({ key: 'test-model' })
454
+ const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
455
+ assert.isFalse(entity.hasSemantic(SemanticType.User))
456
+ })
457
+ })
458
+
331
459
  test.group('DataDomain.moveEntity()', () => {
332
460
  test('moves an entity from one model to another', ({ assert }) => {
333
461
  const dataDomain = new DataDomain()
@@ -67,7 +67,7 @@ test.group('DataDomain.addProperty()', () => {
67
67
  assert.throws(() => {
68
68
  // @ts-expect-error For testing purposes, we are passing undefined
69
69
  dataDomain.addProperty(undefined)
70
- }, 'A property expects a DataEntity parent')
70
+ }, 'A property expects a DomainEntity parent')
71
71
  })
72
72
 
73
73
  test('addProperty throws when adding property to a foreign entity', ({ assert }) => {