@api-client/core 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/build/src/amf/AmfTypes.d.ts +1 -1
  2. package/build/src/amf/AmfTypes.js +1 -1
  3. package/build/src/amf/AmfTypes.js.map +1 -1
  4. package/build/src/amf/Utils.d.ts +0 -6
  5. package/build/src/amf/Utils.d.ts.map +1 -1
  6. package/build/src/amf/Utils.js +0 -14
  7. package/build/src/amf/Utils.js.map +1 -1
  8. package/build/src/browser.d.ts +2 -1
  9. package/build/src/browser.d.ts.map +1 -1
  10. package/build/src/browser.js +1 -0
  11. package/build/src/browser.js.map +1 -1
  12. package/build/src/index.d.ts +2 -1
  13. package/build/src/index.d.ts.map +1 -1
  14. package/build/src/index.js +1 -0
  15. package/build/src/index.js.map +1 -1
  16. package/build/src/legacy.d.ts +0 -8
  17. package/build/src/legacy.d.ts.map +1 -1
  18. package/build/src/legacy.js +0 -9
  19. package/build/src/legacy.js.map +1 -1
  20. package/build/src/modeling/Bindings.d.ts +1 -1
  21. package/build/src/modeling/Bindings.js.map +1 -1
  22. package/build/src/modeling/DataDomain.js +2 -2
  23. package/build/src/modeling/DataDomain.js.map +1 -1
  24. package/build/src/modeling/DataFormat.d.ts +0 -40
  25. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  26. package/build/src/modeling/DataFormat.js +0 -27
  27. package/build/src/modeling/DataFormat.js.map +1 -1
  28. package/build/src/modeling/DomainAssociation.d.ts +63 -0
  29. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  30. package/build/src/modeling/DomainAssociation.js +110 -4
  31. package/build/src/modeling/DomainAssociation.js.map +1 -1
  32. package/build/src/modeling/DomainEntity.d.ts +25 -9
  33. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  34. package/build/src/modeling/DomainEntity.js +65 -21
  35. package/build/src/modeling/DomainEntity.js.map +1 -1
  36. package/build/src/modeling/DomainFile.d.ts +1 -1
  37. package/build/src/modeling/DomainFile.js +1 -1
  38. package/build/src/modeling/DomainFile.js.map +1 -1
  39. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  42. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  43. package/build/src/modeling/DomainModel.d.ts +2 -2
  44. package/build/src/modeling/DomainModel.js +2 -2
  45. package/build/src/modeling/DomainModel.js.map +1 -1
  46. package/build/src/modeling/DomainProperty.d.ts +28 -12
  47. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  48. package/build/src/modeling/DomainProperty.js +61 -26
  49. package/build/src/modeling/DomainProperty.js.map +1 -1
  50. package/build/src/modeling/Semantics.d.ts +117 -0
  51. package/build/src/modeling/Semantics.d.ts.map +1 -0
  52. package/build/src/modeling/Semantics.js +112 -0
  53. package/build/src/modeling/Semantics.js.map +1 -0
  54. package/build/src/models/kinds.d.ts +0 -24
  55. package/build/src/models/kinds.d.ts.map +1 -1
  56. package/build/src/models/kinds.js +0 -24
  57. package/build/src/models/kinds.js.map +1 -1
  58. package/build/src/models/store/data_catalog.d.ts +1 -1
  59. package/build/src/models/store/data_catalog.js.map +1 -1
  60. package/build/tsconfig.tsbuildinfo +1 -1
  61. package/data/models/APIC-187.json +3 -3
  62. package/data/models/APIC-188.json +3 -3
  63. package/data/models/APIC-233.json +1 -1
  64. package/data/models/APIC-391.json +2 -2
  65. package/data/models/APIC-483.json +1 -1
  66. package/data/models/APIC-487.json +1 -1
  67. package/data/models/APIC-655.json +1 -1
  68. package/data/models/APIC-689.json +1 -1
  69. package/data/models/APIC-690.json +5 -5
  70. package/data/models/SE-10469.json +1 -1
  71. package/data/models/SE-13092.json +5 -5
  72. package/data/models/SE-22063.json +12 -2
  73. package/data/models/amf-helper-api.json +154 -14
  74. package/data/models/arc-demo-api.json +95 -15
  75. package/data/models/async-api.json +1 -1
  76. package/data/models/example-generator-api.json +369 -29
  77. package/data/models/expanded-api.json +1 -1
  78. package/data/models/flattened-api.json +1 -1
  79. package/data/models/multiple-servers.json +1 -1
  80. package/data/models/oas-3-api.json +1 -1
  81. package/data/models/oas-date.json +1 -1
  82. package/data/models/oas-types.json +1 -1
  83. package/data/models/oas-unions.json +1 -1
  84. package/data/models/petstore.json +1 -1
  85. package/data/models/raml-date.json +1 -1
  86. package/data/models/recursive.json +1 -1
  87. package/data/models/schema-api.json +62 -2
  88. package/data/models/secured-api.json +16 -16
  89. package/data/models/tracked-to-linked.json +4 -4
  90. package/package.json +2 -2
  91. package/src/amf/AmfTypes.ts +1 -1
  92. package/src/amf/Utils.ts +0 -15
  93. package/src/modeling/Bindings.ts +1 -1
  94. package/src/modeling/DataDomain.ts +2 -2
  95. package/src/modeling/DataFormat.ts +0 -48
  96. package/src/modeling/DomainAssociation.ts +122 -3
  97. package/src/modeling/DomainEntity.ts +56 -17
  98. package/src/modeling/DomainFile.ts +1 -1
  99. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  100. package/src/modeling/DomainModel.ts +2 -2
  101. package/src/modeling/DomainProperty.ts +60 -21
  102. package/src/modeling/Semantics.ts +195 -0
  103. package/src/modeling/graph.md +14 -14
  104. package/src/modeling/readme.md +29 -29
  105. package/src/models/kinds.ts +0 -25
  106. package/src/models/store/data_catalog.ts +1 -1
  107. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  108. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  109. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  110. package/tests/unit/modeling/domain_asociation.spec.ts +267 -0
  111. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  112. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  113. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  114. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  115. package/tests/unit/modeling/semantics.spec.ts +149 -0
  116. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  117. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  118. package/build/src/amf/AmfShapeGenerator.js +0 -416
  119. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  120. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  121. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  122. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  123. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  124. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  125. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  126. package/build/src/modeling/legacy/DataEntity.js +0 -855
  127. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  128. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  129. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  130. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  131. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  132. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  133. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  134. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  135. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  136. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  137. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  138. package/build/src/modeling/legacy/DataModel.js +0 -237
  139. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  140. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  141. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  142. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  143. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  144. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  145. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  146. package/build/src/modeling/legacy/DataProperty.js +0 -415
  147. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  148. package/build/src/models/store/DataFile.d.ts +0 -29
  149. package/build/src/models/store/DataFile.d.ts.map +0 -1
  150. package/build/src/models/store/DataFile.js +0 -87
  151. package/build/src/models/store/DataFile.js.map +0 -1
  152. package/src/amf/AmfShapeGenerator.ts +0 -477
  153. package/src/modeling/legacy/DataAssociation.ts +0 -554
  154. package/src/modeling/legacy/DataEntity.ts +0 -1019
  155. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  156. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  157. package/src/modeling/legacy/DataModel.ts +0 -276
  158. package/src/modeling/legacy/DataNamespace.ts +0 -929
  159. package/src/modeling/legacy/DataProperty.ts +0 -630
  160. package/src/models/store/DataFile.ts +0 -95
  161. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  162. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  163. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  164. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  165. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  166. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  167. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  168. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  169. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -7,6 +7,8 @@ import {
7
7
  AssociationBinding,
8
8
  DataDomain,
9
9
  DataFormat,
10
+ SemanticType,
11
+ type OnDeleteRule,
10
12
  } from '../../../src/index.js'
11
13
 
12
14
  test.group('DomainAssociation.createSchema()', () => {
@@ -21,6 +23,9 @@ test.group('DomainAssociation.createSchema()', () => {
21
23
  assert.isUndefined(schema.required)
22
24
  assert.isUndefined(schema.bindings)
23
25
  assert.isUndefined(schema.targets)
26
+ assert.deepEqual(schema.semantics, [])
27
+ assert.isUndefined(schema.onDelete)
28
+ assert.isUndefined(schema.readOnly)
24
29
  })
25
30
 
26
31
  test('creates a schema with provided key', ({ assert }) => {
@@ -35,6 +40,23 @@ test.group('DomainAssociation.createSchema()', () => {
35
40
  assert.deepEqual(schema.info, Thing.fromJSON(info).toJSON())
36
41
  })
37
42
 
43
+ test('creates a schema with provided semantics', ({ assert }) => {
44
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
45
+ const schema = DomainAssociation.createSchema({ semantics })
46
+ assert.deepEqual(schema.semantics, semantics)
47
+ })
48
+
49
+ test('creates a schema with provided onDelete rule', ({ assert }) => {
50
+ const onDelete: OnDeleteRule = 'cascade'
51
+ const schema = DomainAssociation.createSchema({ onDelete })
52
+ assert.equal(schema.onDelete, onDelete)
53
+ })
54
+
55
+ test('creates a schema with provided readOnly rule', ({ assert }) => {
56
+ const schema = DomainAssociation.createSchema({ readOnly: true })
57
+ assert.isTrue(schema.readOnly)
58
+ })
59
+
38
60
  test('creates a schema with provided schema', ({ assert }) => {
39
61
  const schemaDefinition: AmfShapes.IApiAssociationShape = { linked: false }
40
62
  const schema = DomainAssociation.createSchema({ schema: schemaDefinition })
@@ -71,6 +93,9 @@ test.group('DomainAssociation.createSchema()', () => {
71
93
  const required = true
72
94
  const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
73
95
  const targets = [{ key: 'target1', domain: 'domain1' }, { key: 'target2' }]
96
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
97
+ const readOnly = true
98
+ const onDelete: OnDeleteRule = 'restrict'
74
99
 
75
100
  const schema = DomainAssociation.createSchema({
76
101
  key,
@@ -80,6 +105,9 @@ test.group('DomainAssociation.createSchema()', () => {
80
105
  required,
81
106
  bindings,
82
107
  targets,
108
+ semantics,
109
+ onDelete,
110
+ readOnly,
83
111
  })
84
112
 
85
113
  assert.equal(schema.key, key)
@@ -89,6 +117,9 @@ test.group('DomainAssociation.createSchema()', () => {
89
117
  assert.equal(schema.required, required)
90
118
  assert.deepEqual(schema.bindings, bindings)
91
119
  assert.deepEqual(schema.targets, targets)
120
+ assert.deepEqual(schema.semantics, semantics)
121
+ assert.equal(schema.onDelete, onDelete)
122
+ assert.isTrue(schema.readOnly)
92
123
  })
93
124
 
94
125
  test('creates a schema with cloned bindings', ({ assert }) => {
@@ -98,6 +129,13 @@ test.group('DomainAssociation.createSchema()', () => {
98
129
  assert.notStrictEqual(schema.bindings, bindings)
99
130
  })
100
131
 
132
+ test('creates a schema with cloned semantics', ({ assert }) => {
133
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
134
+ const schema = DomainAssociation.createSchema({ semantics })
135
+ assert.deepEqual(schema.semantics, semantics)
136
+ assert.notStrictEqual(schema.semantics, semantics)
137
+ })
138
+
101
139
  test('creates a schema with cloned targets', ({ assert }) => {
102
140
  const targets = [{ key: 'target1', domain: 'domain1' }, { key: 'target2' }]
103
141
  const schema = DomainAssociation.createSchema({ targets })
@@ -126,6 +164,9 @@ test.group('DomainAssociation.constructor()', () => {
126
164
  assert.isUndefined(association.required)
127
165
  assert.deepEqual(association.bindings, [])
128
166
  assert.deepEqual(association.targets, [])
167
+ assert.deepEqual(association.semantics, [])
168
+ assert.isUndefined(association.onDelete)
169
+ assert.isUndefined(association.readOnly)
129
170
  })
130
171
 
131
172
  test('creates an instance with provided key', ({ assert }) => {
@@ -136,6 +177,30 @@ test.group('DomainAssociation.constructor()', () => {
136
177
  assert.equal(association.key, key)
137
178
  })
138
179
 
180
+ test('creates an instance with provided semantics', ({ assert }) => {
181
+ const dataDomain = new DataDomain()
182
+ const parentKey = 'test-parent'
183
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
184
+ const association = new DomainAssociation(dataDomain, parentKey, { semantics })
185
+ assert.deepEqual(association.semantics, semantics)
186
+ })
187
+
188
+ test('creates an instance with provided onDelete rule', ({ assert }) => {
189
+ const dataDomain = new DataDomain()
190
+ const parentKey = 'test-parent'
191
+ const onDelete: OnDeleteRule = 'setNull'
192
+ const association = new DomainAssociation(dataDomain, parentKey, { onDelete })
193
+ assert.equal(association.onDelete, onDelete)
194
+ })
195
+
196
+ test('creates an instance with provided readOnly rule', ({ assert }) => {
197
+ const dataDomain = new DataDomain()
198
+ const parentKey = 'test-parent'
199
+ const readOnly = true
200
+ const association = new DomainAssociation(dataDomain, parentKey, { readOnly })
201
+ assert.isTrue(association.readOnly)
202
+ })
203
+
139
204
  test('creates an instance with provided info', ({ assert }) => {
140
205
  const dataDomain = new DataDomain()
141
206
  const parentKey = 'test-parent'
@@ -192,6 +257,9 @@ test.group('DomainAssociation.constructor()', () => {
192
257
  const required = true
193
258
  const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
194
259
  const targets = [{ key: 'target1', domain: 'domain1' }, { key: 'target2' }]
260
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
261
+ const readOnly = false
262
+ const onDelete: OnDeleteRule = 'cascade'
195
263
 
196
264
  const association = new DomainAssociation(dataDomain, parentKey, {
197
265
  key,
@@ -201,6 +269,9 @@ test.group('DomainAssociation.constructor()', () => {
201
269
  required,
202
270
  bindings,
203
271
  targets,
272
+ semantics,
273
+ onDelete,
274
+ readOnly,
204
275
  })
205
276
 
206
277
  assert.equal(association.key, key)
@@ -210,6 +281,9 @@ test.group('DomainAssociation.constructor()', () => {
210
281
  assert.equal(association.required, required)
211
282
  assert.deepEqual(association.bindings, bindings)
212
283
  assert.deepEqual(association.targets, targets)
284
+ assert.deepEqual(association.semantics, semantics)
285
+ assert.equal(association.onDelete, onDelete)
286
+ assert.isFalse(association.readOnly)
213
287
  })
214
288
 
215
289
  test('creates an instance with cloned bindings', ({ assert }) => {
@@ -221,6 +295,15 @@ test.group('DomainAssociation.constructor()', () => {
221
295
  assert.notStrictEqual(association.bindings, bindings)
222
296
  })
223
297
 
298
+ test('creates an instance with cloned semantics', ({ assert }) => {
299
+ const dataDomain = new DataDomain()
300
+ const parentKey = 'test-parent'
301
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
302
+ const association = new DomainAssociation(dataDomain, parentKey, { semantics })
303
+ assert.deepEqual(association.semantics, semantics)
304
+ assert.notStrictEqual(association.semantics, semantics)
305
+ })
306
+
224
307
  test('creates an instance with cloned targets', ({ assert }) => {
225
308
  const dataDomain = new DataDomain()
226
309
  const parentKey = 'test-parent'
@@ -254,6 +337,9 @@ test.group('DomainAssociation.toJSON()', () => {
254
337
  assert.isUndefined(json.required)
255
338
  assert.isUndefined(json.bindings)
256
339
  assert.isUndefined(json.targets)
340
+ assert.isUndefined(json.semantics)
341
+ assert.isUndefined(json.onDelete)
342
+ assert.isUndefined(json.readOnly)
257
343
  })
258
344
 
259
345
  test('returns a JSON representation with provided key', ({ assert }) => {
@@ -265,6 +351,33 @@ test.group('DomainAssociation.toJSON()', () => {
265
351
  assert.equal(json.key, key)
266
352
  })
267
353
 
354
+ test('returns a JSON representation with provided semantics', ({ assert }) => {
355
+ const dataDomain = new DataDomain()
356
+ const parentKey = 'test-parent'
357
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
358
+ const association = new DomainAssociation(dataDomain, parentKey, { semantics })
359
+ const json = association.toJSON()
360
+ assert.deepEqual(json.semantics, semantics, 'Semantics are serialized')
361
+ })
362
+
363
+ test('returns a JSON representation with provided onDelete rule', ({ assert }) => {
364
+ const dataDomain = new DataDomain()
365
+ const parentKey = 'test-parent'
366
+ const onDelete: OnDeleteRule = 'cascade'
367
+ const association = new DomainAssociation(dataDomain, parentKey, { onDelete })
368
+ const json = association.toJSON()
369
+ assert.equal(json.onDelete, onDelete, 'onDelete is serialized')
370
+ })
371
+
372
+ test('returns a JSON representation with provided readOnly rule', ({ assert }) => {
373
+ const dataDomain = new DataDomain()
374
+ const parentKey = 'test-parent'
375
+ const readOnly = true
376
+ const association = new DomainAssociation(dataDomain, parentKey, { readOnly })
377
+ const json = association.toJSON()
378
+ assert.isTrue(json.readOnly, 'readOnly is serialized when true')
379
+ })
380
+
268
381
  test('returns a JSON representation with provided info', ({ assert }) => {
269
382
  const dataDomain = new DataDomain()
270
383
  const parentKey = 'test-parent'
@@ -330,6 +443,9 @@ test.group('DomainAssociation.toJSON()', () => {
330
443
  const required = true
331
444
  const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
332
445
  const targets = [{ key: 'target1', domain: 'domain1' }, { key: 'target2' }]
446
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
447
+ const readOnly = true
448
+ const onDelete: OnDeleteRule = 'restrict'
333
449
 
334
450
  const association = new DomainAssociation(dataDomain, parentKey, {
335
451
  key,
@@ -339,6 +455,9 @@ test.group('DomainAssociation.toJSON()', () => {
339
455
  required,
340
456
  bindings,
341
457
  targets,
458
+ semantics,
459
+ onDelete,
460
+ readOnly,
342
461
  })
343
462
 
344
463
  const json = association.toJSON()
@@ -350,6 +469,9 @@ test.group('DomainAssociation.toJSON()', () => {
350
469
  assert.equal(json.required, required)
351
470
  assert.deepEqual(json.bindings, bindings)
352
471
  assert.deepEqual(json.targets, targets)
472
+ assert.deepEqual(json.semantics, semantics)
473
+ assert.equal(json.onDelete, onDelete)
474
+ assert.isTrue(json.readOnly)
353
475
  })
354
476
 
355
477
  test('returns a JSON representation with cloned bindings', ({ assert }) => {
@@ -362,6 +484,36 @@ test.group('DomainAssociation.toJSON()', () => {
362
484
  assert.notStrictEqual(json.bindings, bindings)
363
485
  })
364
486
 
487
+ test('returns a JSON representation with cloned semantics when it is set after creation', ({ assert }) => {
488
+ const dataDomain = new DataDomain()
489
+ const parentKey = 'test-parent'
490
+ const association = new DomainAssociation(dataDomain, parentKey)
491
+ const semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
492
+ association.semantics = semantics
493
+ const json = association.toJSON()
494
+ assert.deepEqual(json.semantics, semantics, 'Semantics are serialized after creation')
495
+ })
496
+
497
+ test('returns a JSON representation with onDelete rule when it is set after creation', ({ assert }) => {
498
+ const dataDomain = new DataDomain()
499
+ const parentKey = 'test-parent'
500
+ const association = new DomainAssociation(dataDomain, parentKey)
501
+ const onDelete: OnDeleteRule = 'setNull'
502
+ association.onDelete = onDelete
503
+ const json = association.toJSON()
504
+ assert.equal(json.onDelete, onDelete, 'onDelete is serialized after creation')
505
+ })
506
+
507
+ test('returns a JSON representation with readOnly rule when it is set after creation', ({ assert }) => {
508
+ const dataDomain = new DataDomain()
509
+ const parentKey = 'test-parent'
510
+ const association = new DomainAssociation(dataDomain, parentKey)
511
+ const readOnly = true
512
+ association.readOnly = readOnly
513
+ const json = association.toJSON()
514
+ assert.isTrue(json.readOnly, 'readOnly is serialized after creation when true')
515
+ })
516
+
365
517
  test('returns a JSON representation with cloned targets', ({ assert }) => {
366
518
  const dataDomain = new DataDomain()
367
519
  const parentKey = 'test-parent'
@@ -641,3 +793,118 @@ test.group('DomainAssociation.readBinding()', () => {
641
793
  assert.isUndefined(webBindings)
642
794
  })
643
795
  })
796
+
797
+ test.group('DomainAssociation.addSemantic()', () => {
798
+ test('adds a new semantic to the association', ({ assert }) => {
799
+ const dataDomain = new DataDomain()
800
+ const association = new DomainAssociation(dataDomain, 'test-parent')
801
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
802
+ association.addSemantic(semantic)
803
+ assert.deepInclude(association.semantics, semantic)
804
+ })
805
+
806
+ test('updates an existing semantic', ({ assert }) => {
807
+ const dataDomain = new DataDomain()
808
+ const association = new DomainAssociation(dataDomain, 'test-parent')
809
+ const semantic1 = { id: SemanticType.ResourceOwnerIdentifier, config: { value: 'old' } }
810
+ const semantic2 = { id: SemanticType.ResourceOwnerIdentifier, config: { value: 'new' } }
811
+ association.addSemantic(semantic1)
812
+ association.addSemantic(semantic2)
813
+ assert.lengthOf(association.semantics, 1)
814
+ assert.deepInclude(association.semantics, semantic2)
815
+ })
816
+
817
+ test('throws an error if the semantic is not an association semantic', ({ assert }) => {
818
+ const dataDomain = new DataDomain()
819
+ const association = new DomainAssociation(dataDomain, 'test-parent')
820
+ const semantic = { id: SemanticType.User } // User is an Entity semantic
821
+ assert.throws(() => {
822
+ association.addSemantic(semantic)
823
+ }, `Invalid semantic type: ${SemanticType.User}. Expected an association semantic.`)
824
+ })
825
+
826
+ test('notifies change when adding a new semantic', async ({ assert }) => {
827
+ const dataDomain = new DataDomain()
828
+ const association = new DomainAssociation(dataDomain, 'test-parent')
829
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
830
+ association.addSemantic(semantic)
831
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
832
+ })
833
+
834
+ test('notifies change when updating an existing semantic', async ({ assert }) => {
835
+ const dataDomain = new DataDomain()
836
+ const association = new DomainAssociation(dataDomain, 'test-parent')
837
+ const semantic1 = { id: SemanticType.ResourceOwnerIdentifier, config: { value: 'old' } }
838
+ const semantic2 = { id: SemanticType.ResourceOwnerIdentifier, config: { value: 'new' } }
839
+ association.addSemantic(semantic1)
840
+ // Clear the event queue before the second add
841
+ await new Promise((resolve) => setTimeout(resolve, 0))
842
+ association.addSemantic(semantic2)
843
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
844
+ })
845
+ })
846
+
847
+ test.group('DomainAssociation.removeSemantic()', () => {
848
+ test('removes an existing semantic from the association', ({ assert }) => {
849
+ const dataDomain = new DataDomain()
850
+ const association = new DomainAssociation(dataDomain, 'test-parent')
851
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
852
+ association.addSemantic(semantic)
853
+ assert.deepInclude(association.semantics, semantic)
854
+ association.removeSemantic(SemanticType.ResourceOwnerIdentifier)
855
+ assert.notDeepInclude(association.semantics, semantic)
856
+ assert.lengthOf(association.semantics, 0)
857
+ })
858
+
859
+ test('does nothing if the semantic to remove does not exist', ({ assert }) => {
860
+ const dataDomain = new DataDomain()
861
+ const association = new DomainAssociation(dataDomain, 'test-parent')
862
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
863
+ association.addSemantic(semantic)
864
+ const initialSemantics = [...association.semantics]
865
+ association.removeSemantic('non-existent-semantic-id' as SemanticType)
866
+ assert.deepEqual(association.semantics, initialSemantics)
867
+ })
868
+
869
+ test('notifies change when a semantic is removed', async ({ assert }) => {
870
+ const dataDomain = new DataDomain()
871
+ const association = new DomainAssociation(dataDomain, 'test-parent')
872
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
873
+ association.addSemantic(semantic)
874
+ // Clear the event queue before removal
875
+ await new Promise((resolve) => setTimeout(resolve, 0))
876
+ association.removeSemantic(SemanticType.ResourceOwnerIdentifier)
877
+ await assert.dispatches(dataDomain, 'change', { timeout: 20 })
878
+ })
879
+
880
+ test('does not notify change if the semantic to remove does not exist', async ({ assert }) => {
881
+ const dataDomain = new DataDomain()
882
+ const association = new DomainAssociation(dataDomain, 'test-parent')
883
+ // Clear the event queue before removal
884
+ await new Promise((resolve) => setTimeout(resolve, 0))
885
+ association.removeSemantic('non-existent-semantic-id' as SemanticType)
886
+ await assert.notDispatches(dataDomain, 'change', { timeout: 20 })
887
+ })
888
+ })
889
+
890
+ test.group('DomainAssociation.hasSemantic()', () => {
891
+ test('returns true if the association has the specified semantic', ({ assert }) => {
892
+ const dataDomain = new DataDomain()
893
+ const association = new DomainAssociation(dataDomain, 'test-parent')
894
+ const semantic = { id: SemanticType.ResourceOwnerIdentifier }
895
+ association.addSemantic(semantic)
896
+ assert.isTrue(association.hasSemantic(SemanticType.ResourceOwnerIdentifier))
897
+ })
898
+
899
+ test('returns false if the association does not have the specified semantic', ({ assert }) => {
900
+ const dataDomain = new DataDomain()
901
+ const association = new DomainAssociation(dataDomain, 'test-parent')
902
+ assert.isFalse(association.hasSemantic(SemanticType.ResourceOwnerIdentifier))
903
+ })
904
+
905
+ test('returns false for an empty semantics array', ({ assert }) => {
906
+ const dataDomain = new DataDomain()
907
+ const association = new DomainAssociation(dataDomain, 'test-parent')
908
+ assert.isFalse(association.hasSemantic(SemanticType.ResourceOwnerIdentifier))
909
+ })
910
+ })
@@ -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