@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.
- package/build/src/amf/AmfTypes.d.ts +1 -1
- package/build/src/amf/AmfTypes.js +1 -1
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/Utils.d.ts +0 -6
- package/build/src/amf/Utils.d.ts.map +1 -1
- package/build/src/amf/Utils.js +0 -14
- package/build/src/amf/Utils.js.map +1 -1
- package/build/src/browser.d.ts +1 -0
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +1 -0
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +1 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/legacy.d.ts +0 -8
- package/build/src/legacy.d.ts.map +1 -1
- package/build/src/legacy.js +0 -9
- package/build/src/legacy.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DataDomain.js +2 -2
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DataFormat.d.ts +0 -40
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +0 -27
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +28 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js +73 -4
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +25 -9
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +65 -21
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.d.ts +3 -4
- package/build/src/modeling/DomainFile.d.ts.map +1 -1
- package/build/src/modeling/DomainFile.js +5 -9
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +3 -3
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +2 -2
- package/build/src/modeling/DomainModel.js +2 -2
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +28 -12
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +61 -26
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/Semantics.d.ts +109 -0
- package/build/src/modeling/Semantics.d.ts.map +1 -0
- package/build/src/modeling/Semantics.js +97 -0
- package/build/src/modeling/Semantics.js.map +1 -0
- package/build/src/models/CertificateFile.d.ts +2 -3
- package/build/src/models/CertificateFile.d.ts.map +1 -1
- package/build/src/models/CertificateFile.js +4 -8
- package/build/src/models/CertificateFile.js.map +1 -1
- package/build/src/models/Folder.d.ts +1 -2
- package/build/src/models/Folder.d.ts.map +1 -1
- package/build/src/models/Folder.js +2 -4
- package/build/src/models/Folder.js.map +1 -1
- package/build/src/models/Project.d.ts +2 -3
- package/build/src/models/Project.d.ts.map +1 -1
- package/build/src/models/Project.js +4 -8
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/kinds.d.ts +0 -24
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +0 -24
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/File.d.ts +1 -21
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +3 -23
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/data_catalog.d.ts +1 -1
- package/build/src/models/store/data_catalog.js.map +1 -1
- package/build/src/sdk/FilesSdk.js +1 -1
- package/build/src/sdk/FilesSdk.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +22 -22
- package/eslint.config.js +1 -0
- package/package.json +5 -5
- package/src/amf/AmfTypes.ts +1 -1
- package/src/amf/Utils.ts +0 -15
- package/src/modeling/Bindings.ts +1 -1
- package/src/modeling/DataDomain.ts +2 -2
- package/src/modeling/DataFormat.ts +0 -48
- package/src/modeling/DomainAssociation.ts +66 -3
- package/src/modeling/DomainEntity.ts +56 -17
- package/src/modeling/DomainFile.ts +5 -9
- package/src/modeling/DomainImpactAnalysis.ts +3 -3
- package/src/modeling/DomainModel.ts +2 -2
- package/src/modeling/DomainProperty.ts +60 -21
- package/src/modeling/Semantics.ts +178 -0
- package/src/modeling/graph.md +14 -14
- package/src/modeling/readme.md +29 -29
- package/src/models/CertificateFile.ts +4 -12
- package/src/models/Folder.ts +2 -4
- package/src/models/Project.ts +4 -8
- package/src/models/kinds.ts +0 -25
- package/src/models/store/File.ts +4 -35
- package/src/models/store/data_catalog.ts +1 -1
- package/src/sdk/FilesSdk.ts +1 -1
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
- package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
- package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
- package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
- package/tests/unit/modeling/domain_entity.spec.ts +27 -26
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
- package/tests/unit/modeling/domain_file.spec.ts +4 -27
- package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
- package/tests/unit/models/Certificate/from_name.spec.ts +3 -15
- package/tests/unit/models/File/constructor.spec.ts +0 -1
- package/tests/unit/models/File/new.spec.ts +0 -13
- package/tests/unit/models/File/shortcutTo.spec.ts +1 -2
- package/tests/unit/models/File/toJSON.spec.ts +0 -13
- package/tests/unit/models/File/updateByMeMeta.spec.ts +4 -6
- package/tests/unit/models/Folder/create.spec.ts +2 -23
- package/tests/unit/models/Project/create.spec.ts +6 -32
- package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
- package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
- package/build/src/amf/AmfShapeGenerator.js +0 -416
- package/build/src/amf/AmfShapeGenerator.js.map +0 -1
- package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
- package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataAssociation.js +0 -443
- package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
- package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
- package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataEntity.js +0 -855
- package/build/src/modeling/legacy/DataEntity.js.map +0 -1
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
- package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
- package/build/src/modeling/legacy/DataModel.d.ts +0 -99
- package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataModel.js +0 -237
- package/build/src/modeling/legacy/DataModel.js.map +0 -1
- package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
- package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataNamespace.js +0 -784
- package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
- package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
- package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataProperty.js +0 -415
- package/build/src/modeling/legacy/DataProperty.js.map +0 -1
- package/build/src/models/store/DataFile.d.ts +0 -31
- package/build/src/models/store/DataFile.d.ts.map +0 -1
- package/build/src/models/store/DataFile.js +0 -92
- package/build/src/models/store/DataFile.js.map +0 -1
- package/src/amf/AmfShapeGenerator.ts +0 -477
- package/src/modeling/legacy/DataAssociation.ts +0 -554
- package/src/modeling/legacy/DataEntity.ts +0 -1019
- package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
- package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
- package/src/modeling/legacy/DataModel.ts +0 -276
- package/src/modeling/legacy/DataNamespace.ts +0 -929
- package/src/modeling/legacy/DataProperty.ts +0 -630
- package/src/models/store/DataFile.ts +0 -100
- package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
- package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
- package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
- package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
- package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
- package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
- package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
- package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
- package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
package/src/models/kinds.ts
CHANGED
|
@@ -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'
|
package/src/models/store/File.ts
CHANGED
|
@@ -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,
|
|
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,
|
|
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:
|
|
468
|
+
lastModified: { user: '', time: 0, byMe: false },
|
|
500
469
|
})
|
|
501
470
|
return definition
|
|
502
471
|
}
|
package/src/sdk/FilesSdk.ts
CHANGED
|
@@ -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
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
295
|
+
e1.semantics.push({ id: SemanticType.User })
|
|
295
296
|
await sleep(1)
|
|
296
|
-
e1.
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
529
|
+
p1.semantics.push({ id: SemanticType.CreatedTimestamp })
|
|
529
530
|
await sleep(1)
|
|
530
|
-
p1.
|
|
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
|
|
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
|
|
70
|
+
}, 'A property expects a DomainEntity parent')
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
test('addProperty throws when adding property to a foreign entity', ({ assert }) => {
|