@api-client/core 0.18.62 → 0.18.63
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/API_MODELING_EXPLAINER.md +57 -0
- package/DATA_MODELING_EXPLAINER.md +74 -0
- package/build/src/modeling/DataDomain.d.ts +6 -5
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js +5 -4
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainAssociation.js +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +9 -6
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +34 -18
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
- package/build/src/modeling/helpers/Intelisense.js +2 -2
- package/build/src/modeling/helpers/Intelisense.js.map +1 -1
- package/build/src/modeling/importers/JsonSchemaImporter.js +1 -1
- package/build/src/modeling/importers/JsonSchemaImporter.js.map +1 -1
- package/build/src/modeling/types.d.ts +0 -14
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +15 -15
- package/package.json +4 -4
- package/src/modeling/DataDomain.ts +6 -6
- package/src/modeling/DomainAssociation.ts +1 -1
- package/src/modeling/DomainEntity.ts +36 -18
- package/src/modeling/helpers/Intelisense.ts +8 -14
- package/src/modeling/importers/JsonSchemaImporter.ts +1 -1
- package/src/modeling/types.ts +0 -15
- package/tests/unit/modeling/amf/shape_generator.spec.ts +4 -4
- package/tests/unit/modeling/api_model_expose_entity.spec.ts +11 -11
- package/tests/unit/modeling/api_model_remove_entity.spec.ts +1 -1
- package/tests/unit/modeling/data_domain_associations.spec.ts +6 -6
- package/tests/unit/modeling/data_domain_foreign.spec.ts +2 -2
- package/tests/unit/modeling/data_domain_namespaces.spec.ts +1 -1
- package/tests/unit/modeling/data_domain_serialization.spec.ts +15 -15
- package/tests/unit/modeling/domain_asociation.spec.ts +15 -15
- package/tests/unit/modeling/domain_entity.spec.ts +3 -3
- package/tests/unit/modeling/domain_entity_associations.spec.ts +4 -4
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +16 -16
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +14 -14
- package/tests/unit/modeling/domain_property.spec.ts +1 -1
- package/tests/unit/modeling/domain_validation.spec.ts +3 -3
- package/tests/unit/modeling/domain_versioning.spec.ts +5 -5
- package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +1 -1
- package/tests/unit/modeling/validation/association_validation.spec.ts +40 -56
- package/tests/unit/modeling/validation/entity_validation.spec.ts +2 -2
|
@@ -42062,9 +42062,6 @@
|
|
|
42062
42062
|
"@id": "#209"
|
|
42063
42063
|
},
|
|
42064
42064
|
{
|
|
42065
|
-
"@id": "#206"
|
|
42066
|
-
},
|
|
42067
|
-
{
|
|
42068
42065
|
"@id": "#191"
|
|
42069
42066
|
},
|
|
42070
42067
|
{
|
|
@@ -42080,6 +42077,9 @@
|
|
|
42080
42077
|
"@id": "#203"
|
|
42081
42078
|
},
|
|
42082
42079
|
{
|
|
42080
|
+
"@id": "#206"
|
|
42081
|
+
},
|
|
42082
|
+
{
|
|
42083
42083
|
"@id": "#209"
|
|
42084
42084
|
}
|
|
42085
42085
|
],
|
|
@@ -43436,7 +43436,7 @@
|
|
|
43436
43436
|
"doc:ExternalDomainElement",
|
|
43437
43437
|
"doc:DomainElement"
|
|
43438
43438
|
],
|
|
43439
|
-
"doc:raw": "
|
|
43439
|
+
"doc:raw": "countryCode: \"BE\"\ngraydonEnterpriseId: 1057155523\nregistrationId: \"0422319093\"\nvatNumber: \"BE0422319093\"\ngraydonCompanyId: \"0422319093\"\nisBranchOffice: false\n",
|
|
43440
43440
|
"core:mediaType": "application/yaml",
|
|
43441
43441
|
"sourcemaps:sources": [
|
|
43442
43442
|
{
|
|
@@ -43457,7 +43457,7 @@
|
|
|
43457
43457
|
"doc:ExternalDomainElement",
|
|
43458
43458
|
"doc:DomainElement"
|
|
43459
43459
|
],
|
|
43460
|
-
"doc:raw": "
|
|
43460
|
+
"doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
|
|
43461
43461
|
"core:mediaType": "application/yaml",
|
|
43462
43462
|
"sourcemaps:sources": [
|
|
43463
43463
|
{
|
|
@@ -43478,7 +43478,7 @@
|
|
|
43478
43478
|
"doc:ExternalDomainElement",
|
|
43479
43479
|
"doc:DomainElement"
|
|
43480
43480
|
],
|
|
43481
|
-
"doc:raw": "
|
|
43481
|
+
"doc:raw": "code: '5'\ndescription: 'Limited company'\n",
|
|
43482
43482
|
"core:mediaType": "application/yaml",
|
|
43483
43483
|
"sourcemaps:sources": [
|
|
43484
43484
|
{
|
|
@@ -43499,7 +43499,7 @@
|
|
|
43499
43499
|
"doc:ExternalDomainElement",
|
|
43500
43500
|
"doc:DomainElement"
|
|
43501
43501
|
],
|
|
43502
|
-
"doc:raw": "
|
|
43502
|
+
"doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
|
|
43503
43503
|
"core:mediaType": "application/yaml",
|
|
43504
43504
|
"sourcemaps:sources": [
|
|
43505
43505
|
{
|
|
@@ -43520,7 +43520,7 @@
|
|
|
43520
43520
|
"doc:ExternalDomainElement",
|
|
43521
43521
|
"doc:DomainElement"
|
|
43522
43522
|
],
|
|
43523
|
-
"doc:raw": "code: '
|
|
43523
|
+
"doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
|
|
43524
43524
|
"core:mediaType": "application/yaml",
|
|
43525
43525
|
"sourcemaps:sources": [
|
|
43526
43526
|
{
|
|
@@ -43541,7 +43541,7 @@
|
|
|
43541
43541
|
"doc:ExternalDomainElement",
|
|
43542
43542
|
"doc:DomainElement"
|
|
43543
43543
|
],
|
|
43544
|
-
"doc:raw": "
|
|
43544
|
+
"doc:raw": "code: '7487'\ndescription: 'Financial and insurance activities'\ntype: \"PRIMARY\"\nclassificationCode: 'BE_NACEBEL2008'\nactivityGroupCode: 'ABCDE'\n",
|
|
43545
43545
|
"core:mediaType": "application/yaml",
|
|
43546
43546
|
"sourcemaps:sources": [
|
|
43547
43547
|
{
|
|
@@ -44756,32 +44756,32 @@
|
|
|
44756
44756
|
{
|
|
44757
44757
|
"@id": "#193/source-map/lexical/element_0",
|
|
44758
44758
|
"sourcemaps:element": "amf://id#193",
|
|
44759
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44759
|
+
"sourcemaps:value": "[(1,0)-(7,0)]"
|
|
44760
44760
|
},
|
|
44761
44761
|
{
|
|
44762
44762
|
"@id": "#196/source-map/lexical/element_0",
|
|
44763
44763
|
"sourcemaps:element": "amf://id#196",
|
|
44764
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44764
|
+
"sourcemaps:value": "[(1,0)-(10,0)]"
|
|
44765
44765
|
},
|
|
44766
44766
|
{
|
|
44767
44767
|
"@id": "#199/source-map/lexical/element_0",
|
|
44768
44768
|
"sourcemaps:element": "amf://id#199",
|
|
44769
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44769
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44770
44770
|
},
|
|
44771
44771
|
{
|
|
44772
44772
|
"@id": "#202/source-map/lexical/element_0",
|
|
44773
44773
|
"sourcemaps:element": "amf://id#202",
|
|
44774
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44774
|
+
"sourcemaps:value": "[(1,0)-(5,0)]"
|
|
44775
44775
|
},
|
|
44776
44776
|
{
|
|
44777
44777
|
"@id": "#205/source-map/lexical/element_0",
|
|
44778
44778
|
"sourcemaps:element": "amf://id#205",
|
|
44779
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44779
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44780
44780
|
},
|
|
44781
44781
|
{
|
|
44782
44782
|
"@id": "#208/source-map/lexical/element_0",
|
|
44783
44783
|
"sourcemaps:element": "amf://id#208",
|
|
44784
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44784
|
+
"sourcemaps:value": "[(1,0)-(6,0)]"
|
|
44785
44785
|
},
|
|
44786
44786
|
{
|
|
44787
44787
|
"@id": "#223/source-map/lexical/element_0",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/core",
|
|
3
3
|
"description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.63",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./browser.js": {
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@commitlint/cli": "^20.1.0",
|
|
110
110
|
"@commitlint/config-conventional": "^20.0.0",
|
|
111
|
-
"@eslint/js": "^
|
|
111
|
+
"@eslint/js": "^10.0.1",
|
|
112
112
|
"@japa/api-client": "^3.0.3",
|
|
113
113
|
"@japa/assert": "^4.0.1",
|
|
114
114
|
"@japa/browser-client": "^2.1.1",
|
|
@@ -128,13 +128,13 @@
|
|
|
128
128
|
"@web/dev-server-rollup": "^0.6.4",
|
|
129
129
|
"@web/test-runner": "^0.20.0",
|
|
130
130
|
"@web/test-runner-playwright": "^0.11.0",
|
|
131
|
-
"amf-client-js": "^5.
|
|
131
|
+
"amf-client-js": "^5.10.0-0",
|
|
132
132
|
"c8": "^10.1.3",
|
|
133
133
|
"chai-as-promised": "^8.0.2",
|
|
134
134
|
"conventional-changelog": "^7.1.0",
|
|
135
135
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
136
136
|
"cors": "^2.8.5",
|
|
137
|
-
"eslint": "^
|
|
137
|
+
"eslint": "^10.0.1",
|
|
138
138
|
"eslint-config-prettier": "^10.0.1",
|
|
139
139
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
140
140
|
"eslint-plugin-prettier": "^5.2.3",
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
DomainPropertyKind,
|
|
10
10
|
} from '../models/kinds.js'
|
|
11
11
|
import type {
|
|
12
|
-
AssociationAddOptions,
|
|
13
12
|
DeserializationIssue,
|
|
14
13
|
DeserializationMode,
|
|
15
14
|
DomainGraphEdge,
|
|
@@ -22,7 +21,7 @@ import type {
|
|
|
22
21
|
import { type DomainNamespaceSchema, DomainNamespace, type NamespaceOrderedItem } from './DomainNamespace.js'
|
|
23
22
|
import { type DomainModelSchema, DomainModel } from './DomainModel.js'
|
|
24
23
|
import { type DomainEntitySchema, DomainEntity } from './DomainEntity.js'
|
|
25
|
-
import { DomainAssociation } from './DomainAssociation.js'
|
|
24
|
+
import { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'
|
|
26
25
|
import { DomainProperty, DomainPropertySchema } from './DomainProperty.js'
|
|
27
26
|
import { type IThing, Thing } from '../models/Thing.js'
|
|
28
27
|
import { removeGraphNode } from './GraphUtils.js'
|
|
@@ -57,6 +56,7 @@ export interface DataDomainSchema extends DependentModelSchema {
|
|
|
57
56
|
* - **Root Container:** Holds all data elements within a domain.
|
|
58
57
|
* - **Graph-Based Structure:** Uses a graph to represent relationships between data elements.
|
|
59
58
|
* - **Namespace Management:** Supports creating and managing namespaces to organize data models.
|
|
59
|
+
* Namespaces are optional.
|
|
60
60
|
* - **Data Model Management:** Supports creating and managing data models to group entities.
|
|
61
61
|
* - **Entity Management:** Supports creating and managing entities, which define the structure of data.
|
|
62
62
|
* - **Property Management:** Supports creating and managing properties, which define the data elements
|
|
@@ -1084,17 +1084,17 @@ export class DataDomain extends DependentModel {
|
|
|
1084
1084
|
* calls the `addAssociation` method on it.
|
|
1085
1085
|
*
|
|
1086
1086
|
* @param source The key of the source entity.
|
|
1087
|
-
* @param
|
|
1087
|
+
* @param input The partial association schema.
|
|
1088
1088
|
* @returns The created association.
|
|
1089
1089
|
* @throws Error When the source entity does not exist.
|
|
1090
1090
|
* @example
|
|
1091
1091
|
* ```typescript
|
|
1092
1092
|
* const addressAssociation = dataDomain.addAssociation(
|
|
1093
|
-
* 'user', { key: 'address' }
|
|
1093
|
+
* 'user-key', { targets: [{ key: 'address-key' }] }
|
|
1094
1094
|
* );
|
|
1095
1095
|
* ```
|
|
1096
1096
|
*/
|
|
1097
|
-
addAssociation(source: string,
|
|
1097
|
+
addAssociation(source: string, input?: Partial<DomainAssociationSchema>): DomainAssociation {
|
|
1098
1098
|
if (!this.graph.hasNode(source)) {
|
|
1099
1099
|
throw new Error(`Source entity ${source} not found`)
|
|
1100
1100
|
}
|
|
@@ -1105,7 +1105,7 @@ export class DataDomain extends DependentModel {
|
|
|
1105
1105
|
if (entity.domain.key !== this.key) {
|
|
1106
1106
|
throw new Error(`Cannot add an association to a foreign domain`)
|
|
1107
1107
|
}
|
|
1108
|
-
return entity.addAssociation(
|
|
1108
|
+
return entity.addAssociation(input)
|
|
1109
1109
|
}
|
|
1110
1110
|
|
|
1111
1111
|
/**
|
|
@@ -625,7 +625,7 @@ export class DomainAssociation extends DomainElement {
|
|
|
625
625
|
copy.info = { name: newName }
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
-
const result = parent.addAssociation(
|
|
628
|
+
const result = parent.addAssociation(copy)
|
|
629
629
|
|
|
630
630
|
// Copy the target entities
|
|
631
631
|
for (const target of this.targets) {
|
|
@@ -8,7 +8,6 @@ import type { IShapeUnion } from '../amf/definitions/Shapes.js'
|
|
|
8
8
|
import { DomainProperty, type DomainPropertySchema } from './DomainProperty.js'
|
|
9
9
|
import { RemovePropertyException } from '../exceptions/remove_property_exception.js'
|
|
10
10
|
import { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'
|
|
11
|
-
import type { AssociationAddOptions } from './types.js'
|
|
12
11
|
import type { FileBreadcrumb } from '../models/store/File.js'
|
|
13
12
|
import type { DomainModel } from './DomainModel.js'
|
|
14
13
|
import type { DomainNamespace } from './DomainNamespace.js'
|
|
@@ -628,35 +627,54 @@ export class DomainEntity extends DomainElement {
|
|
|
628
627
|
/**
|
|
629
628
|
* Adds an association to this entity.
|
|
630
629
|
*
|
|
631
|
-
*
|
|
630
|
+
* Add rules:
|
|
631
|
+
* - If the target is specified, it has to exist in the graph.
|
|
632
|
+
* - The association targets can be local or foreign.
|
|
633
|
+
*
|
|
634
|
+
* Please note that you can't just add targets to the association schema.
|
|
635
|
+
* This function manipulates the graph to insert the required metadata.
|
|
636
|
+
*
|
|
632
637
|
* @param input The partial association schema.
|
|
633
638
|
* @returns The created `DomainAssociation` instance.
|
|
634
639
|
* @throws Error When the target entity does not exist.
|
|
635
640
|
* @example
|
|
636
641
|
* ```typescript
|
|
637
|
-
* const association = entity.addAssociation({
|
|
638
|
-
* key: 'address',
|
|
639
|
-
* });
|
|
642
|
+
* const association = entity.addAssociation({ info: { name: 'Address' }, targets: [{ key: 'address' }] });
|
|
640
643
|
* ```
|
|
641
644
|
*/
|
|
642
|
-
addAssociation(
|
|
645
|
+
addAssociation(input: Partial<DomainAssociationSchema> = {}): DomainAssociation {
|
|
643
646
|
const { graph } = this.root
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
647
|
+
|
|
648
|
+
// clean up any target information from the input
|
|
649
|
+
// so we won't break the graph and the app.
|
|
650
|
+
const inputCopy = { ...input }
|
|
651
|
+
const targets = inputCopy.targets
|
|
652
|
+
delete inputCopy.targets
|
|
653
|
+
|
|
654
|
+
const hasTargets = Array.isArray(targets) && targets.length
|
|
655
|
+
if (hasTargets) {
|
|
656
|
+
for (const target of targets) {
|
|
657
|
+
if (target.domain && target.key) {
|
|
658
|
+
// target is foreign
|
|
659
|
+
const foreignKey = `${target.domain}:${target.key}`
|
|
660
|
+
if (!graph.hasNode(foreignKey)) {
|
|
661
|
+
throw new Error(`Foreign entity ${foreignKey} not found`)
|
|
662
|
+
}
|
|
663
|
+
} else if (target.key) {
|
|
664
|
+
if (!graph.hasNode(target.key)) {
|
|
665
|
+
throw new Error(`Target entity ${target.key} not found`)
|
|
666
|
+
}
|
|
667
|
+
}
|
|
653
668
|
}
|
|
654
669
|
}
|
|
655
|
-
|
|
670
|
+
|
|
671
|
+
const item = new DomainAssociation(this.root, this.key, inputCopy)
|
|
656
672
|
graph.setNode(item.key, item)
|
|
657
673
|
graph.setEdge(this.key, item.key, { type: 'association' })
|
|
658
|
-
if (
|
|
659
|
-
|
|
674
|
+
if (hasTargets) {
|
|
675
|
+
for (const target of targets) {
|
|
676
|
+
item.addTarget(target.key, target.domain)
|
|
677
|
+
}
|
|
660
678
|
}
|
|
661
679
|
this.fields.push({ type: 'association', key: item.key })
|
|
662
680
|
this.root.notifyChange()
|
|
@@ -325,13 +325,10 @@ export function addOwnerField(entity: DomainEntity, info: Partial<IThing> = {}):
|
|
|
325
325
|
if (existing) {
|
|
326
326
|
return existing
|
|
327
327
|
}
|
|
328
|
-
const prop = entity.addAssociation(
|
|
329
|
-
{},
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
required: true,
|
|
333
|
-
}
|
|
334
|
-
)
|
|
328
|
+
const prop = entity.addAssociation({
|
|
329
|
+
info: { name: 'owner', displayName: 'Owner', ...info },
|
|
330
|
+
required: true,
|
|
331
|
+
})
|
|
335
332
|
prop.addSemantic({
|
|
336
333
|
id: SemanticType.ResourceOwnerIdentifier,
|
|
337
334
|
})
|
|
@@ -378,13 +375,10 @@ export function addUpdatedByField(entity: DomainEntity, info: Partial<IThing> =
|
|
|
378
375
|
if (existing) {
|
|
379
376
|
return existing
|
|
380
377
|
}
|
|
381
|
-
const prop = entity.addAssociation(
|
|
382
|
-
{},
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
required: true,
|
|
386
|
-
}
|
|
387
|
-
)
|
|
378
|
+
const prop = entity.addAssociation({
|
|
379
|
+
info: { name: 'updated_by', displayName: 'Updated By', ...info },
|
|
380
|
+
required: true,
|
|
381
|
+
})
|
|
388
382
|
prop.addSemantic({
|
|
389
383
|
id: SemanticType.ResourceOwnerIdentifier,
|
|
390
384
|
})
|
|
@@ -455,7 +455,7 @@ export class JsonSchemaImporter {
|
|
|
455
455
|
// Case 2: If any `$ref` was found, we treat it as an Association.
|
|
456
456
|
if (analysis.refs.size > 0) {
|
|
457
457
|
const sanitizedName = toDatabaseColumnName(propName, 'untitled_association')
|
|
458
|
-
const assoc = entity.addAssociation({
|
|
458
|
+
const assoc = entity.addAssociation({ info: { name: sanitizedName } })
|
|
459
459
|
if (sanitizedName !== propName) {
|
|
460
460
|
assoc.info.displayName = propName // Keep original name for display
|
|
461
461
|
}
|
package/src/modeling/types.ts
CHANGED
|
@@ -33,21 +33,6 @@ export interface DataDomainRemoveOptions {
|
|
|
33
33
|
force?: boolean
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export interface AssociationAddOptions {
|
|
37
|
-
/**
|
|
38
|
-
* When set, it is the the association target's origin data domain.
|
|
39
|
-
* The key of the target data domain where this target entity is defined.
|
|
40
|
-
* Only used when `key` is specified.
|
|
41
|
-
*/
|
|
42
|
-
domain?: string
|
|
43
|
-
/**
|
|
44
|
-
* The key of the association target, if known.
|
|
45
|
-
* If the target of the association is not specified, and the association has no other targets,
|
|
46
|
-
* the association is ignored in the namespace while processing.
|
|
47
|
-
*/
|
|
48
|
-
key?: string
|
|
49
|
-
}
|
|
50
|
-
|
|
51
36
|
export interface DomainGraphEdge {
|
|
52
37
|
/**
|
|
53
38
|
* Indicates that the edge is to or from a foreign domain.
|
|
@@ -95,7 +95,7 @@ test.group('entity()', (group) => {
|
|
|
95
95
|
|
|
96
96
|
test('adds associations to the properties', ({ assert }) => {
|
|
97
97
|
e1.addProperty({ key: 'test', info: { name: 'test' } })
|
|
98
|
-
e1.addAssociation({
|
|
98
|
+
e1.addAssociation({ info: { name: 'test association' } })
|
|
99
99
|
const result = e1.toApiShape() as IApiNodeShape
|
|
100
100
|
|
|
101
101
|
assert.lengthOf(result.properties, 2)
|
|
@@ -777,7 +777,7 @@ test.group('associationProperty()', (group) => {
|
|
|
777
777
|
m1 = root.addModel({ key: 'm1' })
|
|
778
778
|
e1 = m1.addEntity({ key: 'e1', info: { name: 'e1' } })
|
|
779
779
|
e2 = m1.addEntity({ key: 'e2', info: { name: 'e2' } })
|
|
780
|
-
a1 = e1.addAssociation({ key: e2.key },
|
|
780
|
+
a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
|
|
781
781
|
e1.addProperty({ key: 'p1', type: 'boolean', info: { name: 'p1' } })
|
|
782
782
|
p2 = e2.addProperty({ key: 'p2', type: 'number', info: { name: 'p2' } })
|
|
783
783
|
})
|
|
@@ -1048,7 +1048,7 @@ test.group('AI Generated tests', (group) => {
|
|
|
1048
1048
|
m1 = root.addModel({ key: 'm1' })
|
|
1049
1049
|
e1 = m1.addEntity({ key: 'e1', info: { name: 'e1' } })
|
|
1050
1050
|
e2 = m1.addEntity({ key: 'e2', info: { name: 'e2' } })
|
|
1051
|
-
a1 = e1.addAssociation({ key: e2.key },
|
|
1051
|
+
a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
|
|
1052
1052
|
p1 = e1.addProperty({ key: 'p1', info: { name: 'p1' } })
|
|
1053
1053
|
})
|
|
1054
1054
|
|
|
@@ -1067,7 +1067,7 @@ test.group('AI Generated tests', (group) => {
|
|
|
1067
1067
|
const e3 = m2.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
1068
1068
|
fd1.info.version = '1.0.0'
|
|
1069
1069
|
root.registerForeignDomain(fd1)
|
|
1070
|
-
const a2 = e1.addAssociation({ key: e3.key, domain: fd1.key },
|
|
1070
|
+
const a2 = e1.addAssociation({ targets: [{ key: e3.key, domain: fd1.key }], key: 'a2', info: { name: 'a2' } })
|
|
1071
1071
|
const result = e1.toApiShape() as IApiNodeShape
|
|
1072
1072
|
assert.lengthOf(result.properties, 3)
|
|
1073
1073
|
assert.isTrue(result.properties.some((prop) => prop.id === a2.key))
|
|
@@ -72,7 +72,7 @@ test.group('ApiModel.exposeEntity()', () => {
|
|
|
72
72
|
const eA = dm.addEntity({ info: { name: 'A' } })
|
|
73
73
|
const eB = dm.addEntity({ info: { name: 'B' } })
|
|
74
74
|
// Add association from A to B
|
|
75
|
-
eA.addAssociation({
|
|
75
|
+
eA.addAssociation({ info: { name: 'entityB' }, targets: [{ key: eB.key }] })
|
|
76
76
|
const model = new ApiModel()
|
|
77
77
|
model.attachDataDomain(domain)
|
|
78
78
|
const exposedA = model.exposeEntity({ key: eA.key }, { followAssociations: true })
|
|
@@ -90,8 +90,8 @@ test.group('ApiModel.exposeEntity()', () => {
|
|
|
90
90
|
const eA = dm.addEntity({ info: { name: 'A' } })
|
|
91
91
|
const eB = dm.addEntity({ info: { name: 'B' } })
|
|
92
92
|
// A -> B, B -> A
|
|
93
|
-
eA.addAssociation({
|
|
94
|
-
eB.addAssociation({
|
|
93
|
+
eA.addAssociation({ info: { name: 'assocAB' }, targets: [{ key: eB.key }] })
|
|
94
|
+
eB.addAssociation({ info: { name: 'assocBA' }, targets: [{ key: eA.key }] })
|
|
95
95
|
const model = new ApiModel()
|
|
96
96
|
model.attachDataDomain(domain)
|
|
97
97
|
model.exposeEntity({ key: eA.key }, { followAssociations: true, maxDepth: 4 })
|
|
@@ -114,7 +114,7 @@ test.group('ApiModel.exposeEntity()', () => {
|
|
|
114
114
|
const dm = domain.addModel()
|
|
115
115
|
const eA = dm.addEntity({ info: { name: 'A' } })
|
|
116
116
|
// A -> A (self-association)
|
|
117
|
-
eA.addAssociation({
|
|
117
|
+
eA.addAssociation({ info: { name: 'assocAA' }, targets: [{ key: eA.key }] })
|
|
118
118
|
const model = new ApiModel()
|
|
119
119
|
model.attachDataDomain(domain)
|
|
120
120
|
model.exposeEntity({ key: eA.key }, { followAssociations: true })
|
|
@@ -132,8 +132,8 @@ test.group('ApiModel.exposeEntity()', () => {
|
|
|
132
132
|
const eA = dm.addEntity({ info: { name: 'A' } })
|
|
133
133
|
const eB = dm.addEntity({ info: { name: 'B' } })
|
|
134
134
|
const eC = dm.addEntity({ info: { name: 'C' } })
|
|
135
|
-
eA.addAssociation({
|
|
136
|
-
eB.addAssociation({
|
|
135
|
+
eA.addAssociation({ info: { name: 'toB' }, targets: [{ key: eB.key }] })
|
|
136
|
+
eB.addAssociation({ info: { name: 'toC' }, targets: [{ key: eC.key }] })
|
|
137
137
|
const model = new ApiModel()
|
|
138
138
|
model.attachDataDomain(domain)
|
|
139
139
|
model.exposeEntity({ key: eA.key }, { followAssociations: true })
|
|
@@ -152,8 +152,8 @@ test.group('ApiModel.exposeEntity()', () => {
|
|
|
152
152
|
const eA = dm.addEntity({ info: { name: 'A' } })
|
|
153
153
|
const eB = dm.addEntity({ info: { name: 'B' } })
|
|
154
154
|
const eC = dm.addEntity({ info: { name: 'C' } })
|
|
155
|
-
eA.addAssociation({
|
|
156
|
-
eA.addAssociation({
|
|
155
|
+
eA.addAssociation({ info: { name: 'toB' }, targets: [{ key: eB.key }] })
|
|
156
|
+
eA.addAssociation({ info: { name: 'toC' }, targets: [{ key: eC.key }] })
|
|
157
157
|
const model = new ApiModel()
|
|
158
158
|
model.attachDataDomain(domain)
|
|
159
159
|
model.exposeEntity({ key: eA.key }, { followAssociations: true })
|
|
@@ -173,9 +173,9 @@ test.group('ApiModel.exposeEntity()', () => {
|
|
|
173
173
|
const eB = dm.addEntity({ info: { name: 'B' } })
|
|
174
174
|
const eC = dm.addEntity({ info: { name: 'C' } })
|
|
175
175
|
const eD = dm.addEntity({ info: { name: 'D' } })
|
|
176
|
-
eA.addAssociation({
|
|
177
|
-
eB.addAssociation({
|
|
178
|
-
eC.addAssociation({
|
|
176
|
+
eA.addAssociation({ info: { name: 'toB' }, targets: [{ key: eB.key }] })
|
|
177
|
+
eB.addAssociation({ info: { name: 'toC' }, targets: [{ key: eC.key }] })
|
|
178
|
+
eC.addAssociation({ info: { name: 'toD' }, targets: [{ key: eD.key }] })
|
|
179
179
|
const model = new ApiModel()
|
|
180
180
|
model.attachDataDomain(domain)
|
|
181
181
|
model.exposeEntity({ key: eA.key }, { followAssociations: true, maxDepth: 2 })
|
|
@@ -23,7 +23,7 @@ test.group('ApiModel.removeEntity()', () => {
|
|
|
23
23
|
const eA = dm.addEntity({ info: { name: 'A' } })
|
|
24
24
|
const eB = dm.addEntity({ info: { name: 'B' } })
|
|
25
25
|
// A -> B
|
|
26
|
-
eA.addAssociation({
|
|
26
|
+
eA.addAssociation({ info: { name: 'toB' }, targets: [{ key: eB.key }] })
|
|
27
27
|
const model = new ApiModel()
|
|
28
28
|
model.attachDataDomain(domain)
|
|
29
29
|
const rootExposure = model.exposeEntity({ key: eA.key }, { followAssociations: true })
|
|
@@ -17,7 +17,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
17
17
|
const model = dataDomain.addModel({ key: 'test-model' })
|
|
18
18
|
const entity1 = dataDomain.addEntity(model.key, { key: 'entity1' })
|
|
19
19
|
const entity2 = dataDomain.addEntity(model.key, { key: 'entity2' })
|
|
20
|
-
const association = dataDomain.addAssociation(entity1.key, { key: entity2.key })
|
|
20
|
+
const association = dataDomain.addAssociation(entity1.key, { targets: [{ key: entity2.key }] })
|
|
21
21
|
assert.instanceOf(association, DomainAssociation)
|
|
22
22
|
assert.isTrue(dataDomain.graph.hasNode(association.key))
|
|
23
23
|
}).tags(['@modeling', '@associations', '@add'])
|
|
@@ -84,7 +84,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
84
84
|
|
|
85
85
|
domain1.registerForeignDomain(domain2)
|
|
86
86
|
|
|
87
|
-
const association = domain1.addAssociation(e1.key, { key: 'entity2', domain: domain2.key })
|
|
87
|
+
const association = domain1.addAssociation(e1.key, { targets: [{ key: 'entity2', domain: domain2.key }] })
|
|
88
88
|
assert.instanceOf(association, DomainAssociation)
|
|
89
89
|
assert.isTrue(domain1.graph.hasNode(association.key))
|
|
90
90
|
}).tags(['@modeling', '@associations', '@add'])
|
|
@@ -99,7 +99,7 @@ test.group('DataDomain.addAssociation()', () => {
|
|
|
99
99
|
domain1.registerForeignDomain(domain2)
|
|
100
100
|
|
|
101
101
|
assert.throws(() => {
|
|
102
|
-
domain1.addAssociation(e1.key, { key: 'non-existent-entity', domain: 'domain2' })
|
|
102
|
+
domain1.addAssociation(e1.key, { targets: [{ key: 'non-existent-entity', domain: 'domain2' }] })
|
|
103
103
|
}, 'Foreign entity domain2:non-existent-entity not found')
|
|
104
104
|
}).tags(['@modeling', '@associations', '@add'])
|
|
105
105
|
})
|
|
@@ -159,7 +159,7 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
159
159
|
domain2.info.version = '1.0.0'
|
|
160
160
|
domain1.registerForeignDomain(domain2)
|
|
161
161
|
|
|
162
|
-
const association = domain1.addAssociation(e1.key, { key: e2.key, domain: domain2.key })
|
|
162
|
+
const association = domain1.addAssociation(e1.key, { targets: [{ key: e2.key, domain: domain2.key }] })
|
|
163
163
|
domain1.removeAssociation(association.key)
|
|
164
164
|
assert.isFalse(domain1.graph.hasNode(association.key))
|
|
165
165
|
}).tags(['@modeling', '@associations', '@remove'])
|
|
@@ -187,7 +187,7 @@ test.group('DataDomain.removeAssociation()', () => {
|
|
|
187
187
|
const model = dataDomain.addModel()
|
|
188
188
|
const entity1 = dataDomain.addEntity(model.key, { key: 'entity1' })
|
|
189
189
|
const entity2 = dataDomain.addEntity(model.key, { key: 'entity2' })
|
|
190
|
-
const association = dataDomain.addAssociation(entity1.key, { key: entity2.key })
|
|
190
|
+
const association = dataDomain.addAssociation(entity1.key, { targets: [{ key: entity2.key }] })
|
|
191
191
|
dataDomain.removeAssociation(association.key)
|
|
192
192
|
assert.isTrue(dataDomain.graph.hasNode(entity1.key))
|
|
193
193
|
assert.isTrue(dataDomain.graph.hasNode(entity2.key))
|
|
@@ -282,7 +282,7 @@ test.group('DataDomain.findAssociation()', () => {
|
|
|
282
282
|
const e2 = domain2.addEntity(m2.key, { key: 'entity2' })
|
|
283
283
|
domain2.info.version = '1.0.0'
|
|
284
284
|
domain1.registerForeignDomain(domain2)
|
|
285
|
-
const association = domain1.addAssociation(e1.key, { key: e2.key, domain: domain2.key })
|
|
285
|
+
const association = domain1.addAssociation(e1.key, { targets: [{ key: e2.key, domain: domain2.key }] })
|
|
286
286
|
|
|
287
287
|
const foundAssociation = domain1.findAssociation(association.key)
|
|
288
288
|
assert.deepEqual(foundAssociation, association)
|
|
@@ -118,7 +118,7 @@ test.group('DataDomain.registerForeignDomain()', () => {
|
|
|
118
118
|
const model = foreignDomain.addModel({ key: 'test-model' })
|
|
119
119
|
const entity1 = foreignDomain.addEntity(model.key, { key: 'entity1' })
|
|
120
120
|
const entity2 = foreignDomain.addEntity(model.key, { key: 'entity2' })
|
|
121
|
-
const association = entity1.addAssociation({ key: entity2.key })
|
|
121
|
+
const association = entity1.addAssociation({ targets: [{ key: entity2.key }] })
|
|
122
122
|
foreignDomain.info.version = '1.0.0'
|
|
123
123
|
dataDomain.registerForeignDomain(foreignDomain)
|
|
124
124
|
|
|
@@ -606,7 +606,7 @@ test.group('DataDomain.findAssociation()', () => {
|
|
|
606
606
|
const m1 = fd.addModel()
|
|
607
607
|
const e1 = m1.addEntity()
|
|
608
608
|
const e2 = m1.addEntity()
|
|
609
|
-
const a1 = e1.addAssociation({ key: e2.key })
|
|
609
|
+
const a1 = e1.addAssociation({ targets: [{ key: e2.key }] })
|
|
610
610
|
fd.info.version = '1.0.0'
|
|
611
611
|
domain.registerForeignDomain(fd)
|
|
612
612
|
const result = domain.findAssociation(a1.key, fd.key)
|
|
@@ -143,7 +143,7 @@ test.group('DataDomain.removeNamespace()', () => {
|
|
|
143
143
|
const e1 = m1.addEntity({ key: 'entity1' })
|
|
144
144
|
const e2 = m1.addEntity({ key: 'entity2' })
|
|
145
145
|
const p1 = e1.addProperty({ key: 'property1' })
|
|
146
|
-
const a1 = e1.addAssociation({ key: e2.key })
|
|
146
|
+
const a1 = e1.addAssociation({ targets: [{ key: e2.key }] })
|
|
147
147
|
d1.removeNamespace(ns1.key)
|
|
148
148
|
assert.isFalse(d1.graph.hasNode(ns1.key))
|
|
149
149
|
assert.isFalse(d1.graph.hasNode(ns2.key))
|