@api-client/core 0.14.0 → 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 +1 -1
- package/build/src/modeling/DomainFile.js +1 -1
- 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/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/data_catalog.d.ts +1 -1
- package/build/src/models/store/data_catalog.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +11 -11
- package/package.json +1 -1
- 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 +1 -1
- 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/kinds.ts +0 -25
- package/src/models/store/data_catalog.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.property.spec.ts → domain_property.spec.ts} +139 -23
- 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 -29
- package/build/src/models/store/DataFile.d.ts.map +0 -1
- package/build/src/models/store/DataFile.js +0 -87
- 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 -95
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainAssociation.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainAssociation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAA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
import { observed, retargetChange, toRaw } from './observed.js';
|
|
7
7
|
import { DomainAttributeAttributes } from './DataFormat.js';
|
|
8
8
|
import { ShapeGenerator } from './amf/ShapeGenerator.js';
|
|
9
|
+
import { DataSemantics, isAssociationSemantic } from './Semantics.js';
|
|
9
10
|
/**
|
|
10
11
|
* Represents an association between entities in a data domain.
|
|
11
12
|
*
|
|
@@ -70,6 +71,9 @@ let DomainAssociation = (() => {
|
|
|
70
71
|
let _targets_decorators;
|
|
71
72
|
let _targets_initializers = [];
|
|
72
73
|
let _targets_extraInitializers = [];
|
|
74
|
+
let _semantics_decorators;
|
|
75
|
+
let _semantics_initializers = [];
|
|
76
|
+
let _semantics_extraInitializers = [];
|
|
73
77
|
return class DomainAssociation extends _classSuper {
|
|
74
78
|
static {
|
|
75
79
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
@@ -79,12 +83,14 @@ let DomainAssociation = (() => {
|
|
|
79
83
|
_schema_decorators = [observed({ deep: true })];
|
|
80
84
|
_bindings_decorators = [observed({ deep: true })];
|
|
81
85
|
_targets_decorators = [observed({ deep: true })];
|
|
86
|
+
_semantics_decorators = [observed({ deep: true })];
|
|
82
87
|
__esDecorate(this, null, _info_decorators, { kind: "accessor", name: "info", static: false, private: false, access: { has: obj => "info" in obj, get: obj => obj.info, set: (obj, value) => { obj.info = value; } }, metadata: _metadata }, _info_initializers, _info_extraInitializers);
|
|
83
88
|
__esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
|
|
84
89
|
__esDecorate(this, null, _multiple_decorators, { kind: "accessor", name: "multiple", static: false, private: false, access: { has: obj => "multiple" in obj, get: obj => obj.multiple, set: (obj, value) => { obj.multiple = value; } }, metadata: _metadata }, _multiple_initializers, _multiple_extraInitializers);
|
|
85
90
|
__esDecorate(this, null, _schema_decorators, { kind: "accessor", name: "schema", static: false, private: false, access: { has: obj => "schema" in obj, get: obj => obj.schema, set: (obj, value) => { obj.schema = value; } }, metadata: _metadata }, _schema_initializers, _schema_extraInitializers);
|
|
86
91
|
__esDecorate(this, null, _bindings_decorators, { kind: "accessor", name: "bindings", static: false, private: false, access: { has: obj => "bindings" in obj, get: obj => obj.bindings, set: (obj, value) => { obj.bindings = value; } }, metadata: _metadata }, _bindings_initializers, _bindings_extraInitializers);
|
|
87
92
|
__esDecorate(this, null, _targets_decorators, { kind: "accessor", name: "targets", static: false, private: false, access: { has: obj => "targets" in obj, get: obj => obj.targets, set: (obj, value) => { obj.targets = value; } }, metadata: _metadata }, _targets_initializers, _targets_extraInitializers);
|
|
93
|
+
__esDecorate(this, null, _semantics_decorators, { kind: "accessor", name: "semantics", static: false, private: false, access: { has: obj => "semantics" in obj, get: obj => obj.semantics, set: (obj, value) => { obj.semantics = value; } }, metadata: _metadata }, _semantics_initializers, _semantics_extraInitializers);
|
|
88
94
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
89
95
|
}
|
|
90
96
|
/**
|
|
@@ -138,6 +144,19 @@ let DomainAssociation = (() => {
|
|
|
138
144
|
*/
|
|
139
145
|
get targets() { return this.#targets_accessor_storage; }
|
|
140
146
|
set targets(value) { this.#targets_accessor_storage = value; }
|
|
147
|
+
#semantics_accessor_storage = (__runInitializers(this, _targets_extraInitializers), __runInitializers(this, _semantics_initializers, []
|
|
148
|
+
/**
|
|
149
|
+
* Creates a full data association schema with defaults.
|
|
150
|
+
*
|
|
151
|
+
* @param input The partial data association schema.
|
|
152
|
+
* @returns The data association schema.
|
|
153
|
+
*/
|
|
154
|
+
));
|
|
155
|
+
/**
|
|
156
|
+
* Semantics applied to this association.
|
|
157
|
+
*/
|
|
158
|
+
get semantics() { return this.#semantics_accessor_storage; }
|
|
159
|
+
set semantics(value) { this.#semantics_accessor_storage = value; }
|
|
141
160
|
/**
|
|
142
161
|
* Creates a full data association schema with defaults.
|
|
143
162
|
*
|
|
@@ -145,13 +164,16 @@ let DomainAssociation = (() => {
|
|
|
145
164
|
* @returns The data association schema.
|
|
146
165
|
*/
|
|
147
166
|
static createSchema(input = {}) {
|
|
148
|
-
const { key = nanoid() } = input;
|
|
167
|
+
const { key = nanoid(), semantics = [] } = input;
|
|
149
168
|
const info = Thing.fromJSON(input.info, { name: 'new_association' }).toJSON();
|
|
150
169
|
const result = {
|
|
151
170
|
kind: DomainAssociationKind,
|
|
152
171
|
key,
|
|
153
172
|
info,
|
|
154
173
|
};
|
|
174
|
+
if (Array.isArray(semantics)) {
|
|
175
|
+
result.semantics = [...semantics];
|
|
176
|
+
}
|
|
155
177
|
if (input.schema) {
|
|
156
178
|
result.schema = structuredClone(input.schema);
|
|
157
179
|
}
|
|
@@ -181,7 +203,7 @@ let DomainAssociation = (() => {
|
|
|
181
203
|
constructor(root, parent, input) {
|
|
182
204
|
const init = DomainAssociation.createSchema(input);
|
|
183
205
|
super(root, init.key);
|
|
184
|
-
__runInitializers(this,
|
|
206
|
+
__runInitializers(this, _semantics_extraInitializers);
|
|
185
207
|
this.parent = parent;
|
|
186
208
|
this.kind = DomainAssociationKind;
|
|
187
209
|
this.info = new Thing(init.info);
|
|
@@ -206,6 +228,12 @@ let DomainAssociation = (() => {
|
|
|
206
228
|
else {
|
|
207
229
|
this.targets = [];
|
|
208
230
|
}
|
|
231
|
+
if (Array.isArray(init.semantics)) {
|
|
232
|
+
this.semantics = init.semantics.map((item) => structuredClone(item));
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
this.semantics = [];
|
|
236
|
+
}
|
|
209
237
|
}
|
|
210
238
|
/**
|
|
211
239
|
* Generates a JSON representation of the association.
|
|
@@ -228,10 +256,13 @@ let DomainAssociation = (() => {
|
|
|
228
256
|
result.required = this.required;
|
|
229
257
|
}
|
|
230
258
|
if (Array.isArray(this.bindings) && this.bindings.length) {
|
|
231
|
-
result.bindings = toRaw(this, this.bindings)
|
|
259
|
+
result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i));
|
|
232
260
|
}
|
|
233
261
|
if (Array.isArray(this.targets) && this.targets.length) {
|
|
234
|
-
result.targets = toRaw(this, this.targets)
|
|
262
|
+
result.targets = toRaw(this, this.targets)?.map((i) => ({ ...i }));
|
|
263
|
+
}
|
|
264
|
+
if (Array.isArray(this.semantics) && this.semantics.length) {
|
|
265
|
+
result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i));
|
|
235
266
|
}
|
|
236
267
|
return result;
|
|
237
268
|
}
|
|
@@ -433,6 +464,44 @@ let DomainAssociation = (() => {
|
|
|
433
464
|
const serializer = new ShapeGenerator();
|
|
434
465
|
return serializer.associationProperty(this);
|
|
435
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* Adds or updates a semantic to the association.
|
|
469
|
+
* @param semantic The semantic to add to the association.
|
|
470
|
+
* @throws Error if the semantic is not an association semantic.
|
|
471
|
+
*/
|
|
472
|
+
addSemantic(semantic) {
|
|
473
|
+
const sem = DataSemantics[semantic.id];
|
|
474
|
+
if (!isAssociationSemantic(sem)) {
|
|
475
|
+
throw new Error(`Invalid semantic type: ${semantic.id}. Expected an association semantic.`);
|
|
476
|
+
}
|
|
477
|
+
const index = this.semantics.findIndex((s) => s.id === semantic.id);
|
|
478
|
+
if (index >= 0) {
|
|
479
|
+
this.semantics[index] = semantic;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
this.semantics.push(semantic);
|
|
483
|
+
}
|
|
484
|
+
this.domain.notifyChange();
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Removes a semantic from the association.
|
|
488
|
+
* @param semanticId The ID of the semantic to remove.
|
|
489
|
+
*/
|
|
490
|
+
removeSemantic(semanticId) {
|
|
491
|
+
const index = this.semantics.findIndex((s) => s.id === semanticId);
|
|
492
|
+
if (index >= 0) {
|
|
493
|
+
this.semantics.splice(index, 1);
|
|
494
|
+
this.domain.notifyChange();
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Checks if the association has a specific semantic.
|
|
499
|
+
* @param semanticId The ID of the semantic to check.
|
|
500
|
+
* @returns True if the semantic is present, false otherwise.
|
|
501
|
+
*/
|
|
502
|
+
hasSemantic(semanticId) {
|
|
503
|
+
return this.semantics.some((s) => s.id === semanticId);
|
|
504
|
+
}
|
|
436
505
|
};
|
|
437
506
|
})();
|
|
438
507
|
export { DomainAssociation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainAssociation.js","sourceRoot":"","sources":["../../../src/modeling/DomainAssociation.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAA4B,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAI/D,OAAO,EAA4B,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAErF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAwCxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;IACU,iBAAiB;sBAAS,aAAa;;;;;;;;;;;;;;;;;;;iBAAvC,iBAAkB,SAAQ,WAAa;;;gCASjD,cAAc,EAAE;oCAKhB,QAAQ,EAAE;oCAKV,QAAQ,EAAE;kCAMV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;oCASxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;mCAYxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YArCP,iKAAS,IAAI,6BAAJ,IA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R,MAAM,UAAU,GAAG,IAAI,cAAc,EAAE,CAAA;YACvC,OAAO,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAA;QAC7C,CAAC;;;SA1XU,iBAAiB","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainAssociationKind } from '../models/kinds.js'\nimport { DomainElement, type DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange, toRaw } from './observed.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { DomainAttributeAttribute, DomainAttributeAttributes } from './DataFormat.js'\nimport type { AssociationTarget, DomainGraphEdge } from './types.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\n\nexport interface DomainAssociationSchema extends DomainElementSchema {\n kind: typeof DomainAssociationKind\n /**\n * The data association description.\n */\n info: IThing\n /**\n * Wether the data association is required.\n */\n required?: boolean\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: AssociationBinding[]\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets?: AssociationTarget[]\n}\n\n/**\n * Represents an association between entities in a data domain.\n *\n * A `DomainAssociation` defines a relationship between a\n * `DomainEntity` and one or more other entities. It specifies\n * how entities are connected and can represent various types\n * of relationships, such as one-to-one, one-to-many, or\n * many-to-many.\n *\n * **Key Features:**\n *\n * - **Target Entities:** Specifies the entities that are\n * the target of the association.\n * - **Cardinality:** Defines whether the association is\n * single-valued or multi-valued (e.g., one-to-one vs.\n * one-to-many).\n * - **Required Status:** Indicates whether the association\n * is mandatory or optional.\n * - **Schema Customization:** Allows defining a custom\n * schema for the association, overriding the default\n * schema derived from the target entities.\n * - **Bindings:** Supports defining how the association is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Foreign Namespaces:** Can target entities in other\n * namespaces, enabling cross-namespace relationships.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainAssociation` is\n * through the `DomainEntity.addAssociation()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userModel = dataDomain.addModel({ key: 'userModel' });\n * const userEntity = userModel.addEntity({ key: 'user' });\n * const addressEntity = userModel.addEntity({ key: 'address' });\n * // Add an association from User to Address\n * const addressAssociation = userEntity.addAssociation();\n * addressAssociation.addTarget(addressEntity);\n * ```\n */\nexport class DomainAssociation extends DomainElement {\n /**\n * The kind of the domain element.\n */\n override kind: typeof DomainAssociationKind\n\n /**\n * The description of the association namespace.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data association is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data association allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * The schema allowing to translate the model into a\n * specific format (like JSON, RAML, XML, etc.)\n */\n @observed({ deep: true }) accessor schema: IApiAssociationShape | undefined\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n @observed({ deep: true }) accessor bindings: AssociationBinding[]\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n @observed({ deep: true }) accessor targets: AssociationTarget[]\n\n /**\n * Creates a full data association schema with defaults.\n *\n * @param input The partial data association schema.\n * @returns The data association schema.\n */\n static createSchema(input: Partial<DomainAssociationSchema> = {}): DomainAssociationSchema {\n const { key = nanoid() } = input\n const info = Thing.fromJSON(input.info, { name: 'new_association' }).toJSON()\n const result: DomainAssociationSchema = {\n kind: DomainAssociationKind,\n key,\n info,\n }\n if (input.schema) {\n result.schema = structuredClone(input.schema)\n }\n if (typeof input.multiple === 'boolean') {\n result.multiple = input.multiple\n }\n if (typeof input.required === 'boolean') {\n result.required = input.required\n }\n if (Array.isArray(input.bindings)) {\n result.bindings = input.bindings.map((i) => structuredClone(i))\n }\n if (Array.isArray(input.targets)) {\n result.targets = input.targets.map((i) => ({ ...i }))\n }\n return result\n }\n\n /**\n * Creates a new data association instance.\n *\n * You probably want to use the `DomainEntity.addAssociation()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param parent The key of the parent entity.\n * @param input The partial data association schema.\n */\n constructor(root: DataDomain, parent: string, input?: Partial<DomainAssociationSchema>) {\n const init = DomainAssociation.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainAssociationKind\n this.info = new Thing(init.info)\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n }\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n if (Array.isArray(init.targets)) {\n this.targets = init.targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n }\n\n /**\n * Generates a JSON representation of the association.\n *\n * @returns A plain object representation of the `DomainAssociation`.\n */\n toJSON(): DomainAssociationSchema {\n const result: DomainAssociationSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = (toRaw(this, this.bindings) as AssociationBinding[]).map((i) => structuredClone(i))\n }\n if (Array.isArray(this.targets) && this.targets.length) {\n result.targets = (toRaw(this, this.targets) as AssociationTarget[]).map((i) => ({ ...i }))\n }\n return result\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n *\n * @returns The parent `DomainEntity` or undefined if not found.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Removes this property from the parent entity.\n *\n * This method removes the association from the parent\n * entity's list of associations.\n *\n * @example\n * ```typescript\n * association.remove();\n * ```\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeAssociation(this.key)\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n *\n * @returns The schema object.\n * @example\n * ```typescript\n * const schema = association.ensureSchema();\n * ```\n */\n ensureSchema(): IApiAssociationShape {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Checks whether the passed value is one of the supported\n * data property attributes.\n *\n * @param value The value to test\n * @returns True when the passed value is one of the\n * supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainAttributeAttributes.includes(value as DomainAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings\n * definition.\n *\n * @returns The web binding definition\n * @example\n * ```typescript\n * const webBindings = association.getWebBinding();\n * webBindings.hidden = true;\n * ```\n */\n getWebBinding(): AssociationWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as AssociationBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as AssociationBinding\n this.bindings.push(object)\n this.domain.notifyChange()\n }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was\n * created.\n *\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n * @example\n * ```typescript\n * const webBindings = association.readBinding('web');\n * if (webBindings) {\n * // ...\n * }\n * ```\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema || undefined\n }\n\n /**\n * Adds a target entity to the association.\n *\n * If the entity comes from another namespace then it is\n * set as a foreign entity.\n *\n * @param entity - The `DomainEntity` instance to add.\n * @example\n * ```typescript\n * association.addTarget(addressEntity);\n * ```\n */\n addTarget(entity: DomainEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `DomainEntity` definition or just\n * its key.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local\n * entities.\n * @example\n * ```typescript\n * association.addTarget('address', 'foreignNamespace');\n * ```\n */\n addTarget(entity: string, namespace?: string): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local entities.\n */\n addTarget(init: string | DomainEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n if (init.domain.key !== this.root.key) {\n namespace = init.domain.key\n }\n }\n if (this.targets.some((i) => i.key === key && i.domain === namespace)) {\n const message = `Target ${key} already exists.`\n throw new Error(message)\n }\n if (namespace && !this.root.dependencies.has(namespace)) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.domain = namespace\n }\n this.targets.push(info)\n const targetKey = namespace ? `${namespace}:${key}` : key\n const label: DomainGraphEdge = {\n type: 'association',\n }\n if (namespace) {\n label.domain = namespace\n label.foreign = true\n }\n // We need to associate the target with the association\n // in the graph. This way, when looking for associations\n // on a target entities we can easily locate the\n // association.\n this.root.graph.setEdge(this.key, targetKey, label)\n // this.root.notifyChange()\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or\n * schema.\n * @example\n * ```typescript\n * association.removeTarget(addressEntity);\n * ```\n */\n removeTarget(init: string | DomainEntity): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n }\n const index = this.targets.findIndex((i) => i.key === key)\n if (index >= 0) {\n this.targets.splice(index, 1)\n // this.root.notifyChange()\n }\n this.root.graph.removeEdge(this.key, key)\n }\n\n /**\n * Lists all target entities of this association.\n *\n * @returns A generator that yields each target\n * `DomainEntity`.\n * @example\n * ```typescript\n * for (const target of association.listTargets()) {\n * console.log(target.key);\n * }\n * ```\n */\n *listTargets(): Generator<DomainEntity> {\n for (const target of this.targets) {\n const { key, domain } = target\n const targetKey = domain ? `${domain}:${key}` : key\n const entity = this.root.graph.node(targetKey) as DomainEntity | undefined\n if (entity) {\n yield entity\n }\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.associationProperty(this)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainAssociation.js","sourceRoot":"","sources":["../../../src/modeling/DomainAssociation.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAA4B,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAI/D,OAAO,EAA4B,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAErF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAA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AA;gBAC/B,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;YAC5B,CAAC;QACH,CAAC;QAED;;;;WAIG;QACH,WAAW,CAAC,UAAwB;YAClC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAA;QACxD,CAAC;;;SAlbU,iBAAiB","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainAssociationKind } from '../models/kinds.js'\nimport { DomainElement, type DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange, toRaw } from './observed.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { DomainAttributeAttribute, DomainAttributeAttributes } from './DataFormat.js'\nimport type { AssociationTarget, DomainGraphEdge } from './types.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport { DataSemantics, isAssociationSemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'\n\nexport interface DomainAssociationSchema extends DomainElementSchema {\n kind: typeof DomainAssociationKind\n /**\n * The data association description.\n */\n info: IThing\n /**\n * Wether the data association is required.\n */\n required?: boolean\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: AssociationBinding[]\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets?: AssociationTarget[]\n /**\n * The semantics applied to this association.\n * This is a list of applied semantics that can be used to\n * describe the association in more detail.\n */\n semantics?: AppliedDataSemantic[]\n}\n\n/**\n * Represents an association between entities in a data domain.\n *\n * A `DomainAssociation` defines a relationship between a\n * `DomainEntity` and one or more other entities. It specifies\n * how entities are connected and can represent various types\n * of relationships, such as one-to-one, one-to-many, or\n * many-to-many.\n *\n * **Key Features:**\n *\n * - **Target Entities:** Specifies the entities that are\n * the target of the association.\n * - **Cardinality:** Defines whether the association is\n * single-valued or multi-valued (e.g., one-to-one vs.\n * one-to-many).\n * - **Required Status:** Indicates whether the association\n * is mandatory or optional.\n * - **Schema Customization:** Allows defining a custom\n * schema for the association, overriding the default\n * schema derived from the target entities.\n * - **Bindings:** Supports defining how the association is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Foreign Namespaces:** Can target entities in other\n * namespaces, enabling cross-namespace relationships.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainAssociation` is\n * through the `DomainEntity.addAssociation()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userModel = dataDomain.addModel({ key: 'userModel' });\n * const userEntity = userModel.addEntity({ key: 'user' });\n * const addressEntity = userModel.addEntity({ key: 'address' });\n * // Add an association from User to Address\n * const addressAssociation = userEntity.addAssociation();\n * addressAssociation.addTarget(addressEntity);\n * ```\n */\nexport class DomainAssociation extends DomainElement {\n /**\n * The kind of the domain element.\n */\n override kind: typeof DomainAssociationKind\n\n /**\n * The description of the association namespace.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data association is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data association allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * The schema allowing to translate the model into a\n * specific format (like JSON, RAML, XML, etc.)\n */\n @observed({ deep: true }) accessor schema: IApiAssociationShape | undefined\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n @observed({ deep: true }) accessor bindings: AssociationBinding[]\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n @observed({ deep: true }) accessor targets: AssociationTarget[]\n\n /**\n * Semantics applied to this association.\n */\n @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []\n\n /**\n * Creates a full data association schema with defaults.\n *\n * @param input The partial data association schema.\n * @returns The data association schema.\n */\n static createSchema(input: Partial<DomainAssociationSchema> = {}): DomainAssociationSchema {\n const { key = nanoid(), semantics = [] } = input\n const info = Thing.fromJSON(input.info, { name: 'new_association' }).toJSON()\n const result: DomainAssociationSchema = {\n kind: DomainAssociationKind,\n key,\n info,\n }\n if (Array.isArray(semantics)) {\n result.semantics = [...semantics]\n }\n if (input.schema) {\n result.schema = structuredClone(input.schema)\n }\n if (typeof input.multiple === 'boolean') {\n result.multiple = input.multiple\n }\n if (typeof input.required === 'boolean') {\n result.required = input.required\n }\n if (Array.isArray(input.bindings)) {\n result.bindings = input.bindings.map((i) => structuredClone(i))\n }\n if (Array.isArray(input.targets)) {\n result.targets = input.targets.map((i) => ({ ...i }))\n }\n return result\n }\n\n /**\n * Creates a new data association instance.\n *\n * You probably want to use the `DomainEntity.addAssociation()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param parent The key of the parent entity.\n * @param input The partial data association schema.\n */\n constructor(root: DataDomain, parent: string, input?: Partial<DomainAssociationSchema>) {\n const init = DomainAssociation.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainAssociationKind\n this.info = new Thing(init.info)\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n }\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n if (Array.isArray(init.targets)) {\n this.targets = init.targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n if (Array.isArray(init.semantics)) {\n this.semantics = init.semantics.map((item) => structuredClone(item))\n } else {\n this.semantics = []\n }\n }\n\n /**\n * Generates a JSON representation of the association.\n *\n * @returns A plain object representation of the `DomainAssociation`.\n */\n toJSON(): DomainAssociationSchema {\n const result: DomainAssociationSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))\n }\n if (Array.isArray(this.targets) && this.targets.length) {\n result.targets = toRaw(this, this.targets)?.map((i) => ({ ...i }))\n }\n if (Array.isArray(this.semantics) && this.semantics.length) {\n result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n *\n * @returns The parent `DomainEntity` or undefined if not found.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Removes this property from the parent entity.\n *\n * This method removes the association from the parent\n * entity's list of associations.\n *\n * @example\n * ```typescript\n * association.remove();\n * ```\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeAssociation(this.key)\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n *\n * @returns The schema object.\n * @example\n * ```typescript\n * const schema = association.ensureSchema();\n * ```\n */\n ensureSchema(): IApiAssociationShape {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Checks whether the passed value is one of the supported\n * data property attributes.\n *\n * @param value The value to test\n * @returns True when the passed value is one of the\n * supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainAttributeAttributes.includes(value as DomainAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings\n * definition.\n *\n * @returns The web binding definition\n * @example\n * ```typescript\n * const webBindings = association.getWebBinding();\n * webBindings.hidden = true;\n * ```\n */\n getWebBinding(): AssociationWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as AssociationBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as AssociationBinding\n this.bindings.push(object)\n this.domain.notifyChange()\n }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was\n * created.\n *\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n * @example\n * ```typescript\n * const webBindings = association.readBinding('web');\n * if (webBindings) {\n * // ...\n * }\n * ```\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema || undefined\n }\n\n /**\n * Adds a target entity to the association.\n *\n * If the entity comes from another namespace then it is\n * set as a foreign entity.\n *\n * @param entity - The `DomainEntity` instance to add.\n * @example\n * ```typescript\n * association.addTarget(addressEntity);\n * ```\n */\n addTarget(entity: DomainEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `DomainEntity` definition or just\n * its key.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local\n * entities.\n * @example\n * ```typescript\n * association.addTarget('address', 'foreignNamespace');\n * ```\n */\n addTarget(entity: string, namespace?: string): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local entities.\n */\n addTarget(init: string | DomainEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n if (init.domain.key !== this.root.key) {\n namespace = init.domain.key\n }\n }\n if (this.targets.some((i) => i.key === key && i.domain === namespace)) {\n const message = `Target ${key} already exists.`\n throw new Error(message)\n }\n if (namespace && !this.root.dependencies.has(namespace)) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.domain = namespace\n }\n this.targets.push(info)\n const targetKey = namespace ? `${namespace}:${key}` : key\n const label: DomainGraphEdge = {\n type: 'association',\n }\n if (namespace) {\n label.domain = namespace\n label.foreign = true\n }\n // We need to associate the target with the association\n // in the graph. This way, when looking for associations\n // on a target entities we can easily locate the\n // association.\n this.root.graph.setEdge(this.key, targetKey, label)\n // this.root.notifyChange()\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or\n * schema.\n * @example\n * ```typescript\n * association.removeTarget(addressEntity);\n * ```\n */\n removeTarget(init: string | DomainEntity): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n }\n const index = this.targets.findIndex((i) => i.key === key)\n if (index >= 0) {\n this.targets.splice(index, 1)\n // this.root.notifyChange()\n }\n this.root.graph.removeEdge(this.key, key)\n }\n\n /**\n * Lists all target entities of this association.\n *\n * @returns A generator that yields each target\n * `DomainEntity`.\n * @example\n * ```typescript\n * for (const target of association.listTargets()) {\n * console.log(target.key);\n * }\n * ```\n */\n *listTargets(): Generator<DomainEntity> {\n for (const target of this.targets) {\n const { key, domain } = target\n const targetKey = domain ? `${domain}:${key}` : key\n const entity = this.root.graph.node(targetKey) as DomainEntity | undefined\n if (entity) {\n yield entity\n }\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.associationProperty(this)\n }\n\n /**\n * Adds or updates a semantic to the association.\n * @param semantic The semantic to add to the association.\n * @throws Error if the semantic is not an association semantic.\n */\n addSemantic(semantic: AppliedDataSemantic): void {\n const sem = DataSemantics[semantic.id]\n if (!isAssociationSemantic(sem)) {\n throw new Error(`Invalid semantic type: ${semantic.id}. Expected an association semantic.`)\n }\n const index = this.semantics.findIndex((s) => s.id === semantic.id)\n if (index >= 0) {\n this.semantics[index] = semantic\n } else {\n this.semantics.push(semantic)\n }\n this.domain.notifyChange()\n }\n\n /**\n * Removes a semantic from the association.\n * @param semanticId The ID of the semantic to remove.\n */\n removeSemantic(semanticId: SemanticType): void {\n const index = this.semantics.findIndex((s) => s.id === semanticId)\n if (index >= 0) {\n this.semantics.splice(index, 1)\n this.domain.notifyChange()\n }\n }\n\n /**\n * Checks if the association has a specific semantic.\n * @param semanticId The ID of the semantic to check.\n * @returns True if the semantic is present, false otherwise.\n */\n hasSemantic(semanticId: SemanticType): boolean {\n return this.semantics.some((s) => s.id === semanticId)\n }\n}\n"]}
|
|
@@ -9,6 +9,7 @@ import type { AssociationAddOptions } from './types.js';
|
|
|
9
9
|
import type { FileBreadcrumb } from '../models/store/File.js';
|
|
10
10
|
import type { DomainModel } from './DomainModel.js';
|
|
11
11
|
import type { IShapeRenderOptions } from '../amf/shape/ShapeBase.js';
|
|
12
|
+
import { type SemanticType, type AppliedDataSemantic } from './Semantics.js';
|
|
12
13
|
export interface EntityOrderedItem {
|
|
13
14
|
/**
|
|
14
15
|
* The type of the ordered item.
|
|
@@ -30,11 +31,11 @@ export interface DomainEntitySchema extends DomainElementSchema {
|
|
|
30
31
|
*/
|
|
31
32
|
tags?: string[];
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* The semantics applied to this entity.
|
|
35
|
+
* This is a list of applied semantics that can be used to
|
|
36
|
+
* describe the entity in more detail.
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
semantics?: AppliedDataSemantic[];
|
|
38
39
|
/**
|
|
39
40
|
* The ordered list of fields (properties and associations) in the schema.
|
|
40
41
|
* These only keep references to the properties and associations.
|
|
@@ -60,7 +61,7 @@ export interface DomainEntitySchema extends DomainElementSchema {
|
|
|
60
61
|
* - **Properties:** Defines the data elements (fields) within the entity.
|
|
61
62
|
* - **Associations:** Defines relationships to other entities.
|
|
62
63
|
* - **Inheritance:** Supports inheriting properties and associations from parent entities.
|
|
63
|
-
* - **Metadata:** Supports tags,
|
|
64
|
+
* - **Metadata:** Supports tags, semantics, and deprecation status.
|
|
64
65
|
* - **AMF Shape Generation:** Can be serialized to an AMF (API Modeling Framework) shape.
|
|
65
66
|
* - **Example Generation:** Can generate example databased on its schema.
|
|
66
67
|
*
|
|
@@ -120,11 +121,9 @@ export declare class DomainEntity extends DomainElement {
|
|
|
120
121
|
*/
|
|
121
122
|
accessor tags: string[];
|
|
122
123
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* The keys of the taxonomy items associated with the entity.
|
|
124
|
+
* Semantics applied to this property.
|
|
126
125
|
*/
|
|
127
|
-
accessor
|
|
126
|
+
accessor semantics: AppliedDataSemantic[];
|
|
128
127
|
/**
|
|
129
128
|
* The ordered list of fields (properties and associations) in the schema.
|
|
130
129
|
* These only keep references to the properties and associations.
|
|
@@ -425,5 +424,22 @@ export declare class DomainEntity extends DomainElement {
|
|
|
425
424
|
* @returns The primary key property of this entity or undefined if not found.
|
|
426
425
|
*/
|
|
427
426
|
primaryKey(): DomainProperty | undefined;
|
|
427
|
+
/**
|
|
428
|
+
* Adds or updates a semantic to the entity.
|
|
429
|
+
* @param semantic The semantic to add to the entity.
|
|
430
|
+
* @throws Error if the semantic is not an entity semantic.
|
|
431
|
+
*/
|
|
432
|
+
addSemantic(semantic: AppliedDataSemantic): void;
|
|
433
|
+
/**
|
|
434
|
+
* Removes a semantic from the entity.
|
|
435
|
+
* @param semanticId The ID of the semantic to remove.
|
|
436
|
+
*/
|
|
437
|
+
removeSemantic(semanticId: SemanticType): void;
|
|
438
|
+
/**
|
|
439
|
+
* Checks if the entity has a specific semantic.
|
|
440
|
+
* @param semanticId The ID of the semantic to check.
|
|
441
|
+
* @returns True if the semantic is present, false otherwise.
|
|
442
|
+
*/
|
|
443
|
+
hasSemantic(semanticId: SemanticType): boolean;
|
|
428
444
|
}
|
|
429
445
|
//# sourceMappingURL=DomainEntity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainEntity.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainEntity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAyB,gBAAgB,EAAsB,MAAM,oBAAoB,CAAA;AAChG,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"DomainEntity.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainEntity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,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AE,mBAAmB,GAAG,IAAI;IAchD;;;OAGG;IACH,cAAc,CAAC,UAAU,EAAE,YAAY,GAAG,IAAI;IAQ9C;;;;OAIG;IACH,WAAW,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO;CAG/C"}
|
|
@@ -11,6 +11,7 @@ import { ValidationError } from '../exceptions/validation_error.js';
|
|
|
11
11
|
import { ShapeGenerator } from './amf/ShapeGenerator.js';
|
|
12
12
|
import { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js';
|
|
13
13
|
import { removeGraphNode } from './GraphUtils.js';
|
|
14
|
+
import { DataSemantics, isEntitySemantic } from './Semantics.js';
|
|
14
15
|
/**
|
|
15
16
|
* Represents an entity within a data domain model.
|
|
16
17
|
*
|
|
@@ -24,7 +25,7 @@ import { removeGraphNode } from './GraphUtils.js';
|
|
|
24
25
|
* - **Properties:** Defines the data elements (fields) within the entity.
|
|
25
26
|
* - **Associations:** Defines relationships to other entities.
|
|
26
27
|
* - **Inheritance:** Supports inheriting properties and associations from parent entities.
|
|
27
|
-
* - **Metadata:** Supports tags,
|
|
28
|
+
* - **Metadata:** Supports tags, semantics, and deprecation status.
|
|
28
29
|
* - **AMF Shape Generation:** Can be serialized to an AMF (API Modeling Framework) shape.
|
|
29
30
|
* - **Example Generation:** Can generate example databased on its schema.
|
|
30
31
|
*
|
|
@@ -78,9 +79,9 @@ let DomainEntity = (() => {
|
|
|
78
79
|
let _tags_decorators;
|
|
79
80
|
let _tags_initializers = [];
|
|
80
81
|
let _tags_extraInitializers = [];
|
|
81
|
-
let
|
|
82
|
-
let
|
|
83
|
-
let
|
|
82
|
+
let _semantics_decorators;
|
|
83
|
+
let _semantics_initializers = [];
|
|
84
|
+
let _semantics_extraInitializers = [];
|
|
84
85
|
let _deprecated_decorators;
|
|
85
86
|
let _deprecated_initializers = [];
|
|
86
87
|
let _deprecated_extraInitializers = [];
|
|
@@ -89,11 +90,11 @@ let DomainEntity = (() => {
|
|
|
89
90
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
90
91
|
_info_decorators = [retargetChange()];
|
|
91
92
|
_tags_decorators = [observed({ deep: true })];
|
|
92
|
-
|
|
93
|
+
_semantics_decorators = [observed({ deep: true })];
|
|
93
94
|
_deprecated_decorators = [observed()];
|
|
94
95
|
__esDecorate(this, null, _info_decorators, { kind: "accessor", name: "info", static: false, private: false, access: { has: obj => "info" in obj, get: obj => obj.info, set: (obj, value) => { obj.info = value; } }, metadata: _metadata }, _info_initializers, _info_extraInitializers);
|
|
95
96
|
__esDecorate(this, null, _tags_decorators, { kind: "accessor", name: "tags", static: false, private: false, access: { has: obj => "tags" in obj, get: obj => obj.tags, set: (obj, value) => { obj.tags = value; } }, metadata: _metadata }, _tags_initializers, _tags_extraInitializers);
|
|
96
|
-
__esDecorate(this, null,
|
|
97
|
+
__esDecorate(this, null, _semantics_decorators, { kind: "accessor", name: "semantics", static: false, private: false, access: { has: obj => "semantics" in obj, get: obj => obj.semantics, set: (obj, value) => { obj.semantics = value; } }, metadata: _metadata }, _semantics_initializers, _semantics_extraInitializers);
|
|
97
98
|
__esDecorate(this, null, _deprecated_decorators, { kind: "accessor", name: "deprecated", static: false, private: false, access: { has: obj => "deprecated" in obj, get: obj => obj.deprecated, set: (obj, value) => { obj.deprecated = value; } }, metadata: _metadata }, _deprecated_initializers, _deprecated_extraInitializers);
|
|
98
99
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
99
100
|
}
|
|
@@ -113,15 +114,20 @@ let DomainEntity = (() => {
|
|
|
113
114
|
*/
|
|
114
115
|
get tags() { return this.#tags_accessor_storage; }
|
|
115
116
|
set tags(value) { this.#tags_accessor_storage = value; }
|
|
116
|
-
#
|
|
117
|
+
#semantics_accessor_storage = (__runInitializers(this, _tags_extraInitializers), __runInitializers(this, _semantics_initializers, []
|
|
117
118
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* The
|
|
119
|
+
* The ordered list of fields (properties and associations) in the schema.
|
|
120
|
+
* These only keep references to the properties and associations.
|
|
121
|
+
* The order of the fields is important as it defines the order of the
|
|
122
|
+
* properties in the schema.
|
|
121
123
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
));
|
|
125
|
+
/**
|
|
126
|
+
* Semantics applied to this property.
|
|
127
|
+
*/
|
|
128
|
+
get semantics() { return this.#semantics_accessor_storage; }
|
|
129
|
+
set semantics(value) { this.#semantics_accessor_storage = value; }
|
|
130
|
+
#fields_accessor_storage = __runInitializers(this, _semantics_extraInitializers);
|
|
125
131
|
/**
|
|
126
132
|
* The ordered list of fields (properties and associations) in the schema.
|
|
127
133
|
* These only keep references to the properties and associations.
|
|
@@ -143,7 +149,7 @@ let DomainEntity = (() => {
|
|
|
143
149
|
* @returns The data entity schema.
|
|
144
150
|
*/
|
|
145
151
|
static createSchema(input = {}) {
|
|
146
|
-
const { key = nanoid(), tags,
|
|
152
|
+
const { key = nanoid(), tags, semantics, fields, deprecated } = input;
|
|
147
153
|
const info = Thing.fromJSON(input.info, { name: 'New entity' }).toJSON();
|
|
148
154
|
const result = {
|
|
149
155
|
kind: DomainEntityKind,
|
|
@@ -153,8 +159,8 @@ let DomainEntity = (() => {
|
|
|
153
159
|
if (Array.isArray(tags)) {
|
|
154
160
|
result.tags = [...tags];
|
|
155
161
|
}
|
|
156
|
-
if (Array.isArray(
|
|
157
|
-
result.
|
|
162
|
+
if (Array.isArray(semantics)) {
|
|
163
|
+
result.semantics = [...semantics];
|
|
158
164
|
}
|
|
159
165
|
if (Array.isArray(fields)) {
|
|
160
166
|
result.fields = [...fields];
|
|
@@ -185,11 +191,11 @@ let DomainEntity = (() => {
|
|
|
185
191
|
else {
|
|
186
192
|
this.tags = [];
|
|
187
193
|
}
|
|
188
|
-
if (Array.isArray(init.
|
|
189
|
-
this.
|
|
194
|
+
if (Array.isArray(init.semantics)) {
|
|
195
|
+
this.semantics = init.semantics.map((item) => structuredClone(item));
|
|
190
196
|
}
|
|
191
197
|
else {
|
|
192
|
-
this.
|
|
198
|
+
this.semantics = [];
|
|
193
199
|
}
|
|
194
200
|
if (Array.isArray(init.fields)) {
|
|
195
201
|
this.fields = [...init.fields];
|
|
@@ -215,8 +221,8 @@ let DomainEntity = (() => {
|
|
|
215
221
|
if (Array.isArray(this.fields) && this.fields.length) {
|
|
216
222
|
result.fields = [...this.fields];
|
|
217
223
|
}
|
|
218
|
-
if (Array.isArray(this.
|
|
219
|
-
result.
|
|
224
|
+
if (Array.isArray(this.semantics) && this.semantics.length) {
|
|
225
|
+
result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i));
|
|
220
226
|
}
|
|
221
227
|
if (Array.isArray(this.tags) && this.tags.length) {
|
|
222
228
|
result.tags = [...toRaw(this, this.tags)];
|
|
@@ -783,6 +789,44 @@ let DomainEntity = (() => {
|
|
|
783
789
|
}
|
|
784
790
|
return property;
|
|
785
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* Adds or updates a semantic to the entity.
|
|
794
|
+
* @param semantic The semantic to add to the entity.
|
|
795
|
+
* @throws Error if the semantic is not an entity semantic.
|
|
796
|
+
*/
|
|
797
|
+
addSemantic(semantic) {
|
|
798
|
+
const sem = DataSemantics[semantic.id];
|
|
799
|
+
if (!isEntitySemantic(sem)) {
|
|
800
|
+
throw new Error(`Invalid semantic type: ${semantic.id}. Expected an entity semantic.`);
|
|
801
|
+
}
|
|
802
|
+
const index = this.semantics.findIndex((s) => s.id === semantic.id);
|
|
803
|
+
if (index >= 0) {
|
|
804
|
+
this.semantics[index] = semantic;
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
this.semantics.push(semantic);
|
|
808
|
+
}
|
|
809
|
+
this.domain.notifyChange();
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Removes a semantic from the entity.
|
|
813
|
+
* @param semanticId The ID of the semantic to remove.
|
|
814
|
+
*/
|
|
815
|
+
removeSemantic(semanticId) {
|
|
816
|
+
const index = this.semantics.findIndex((s) => s.id === semanticId);
|
|
817
|
+
if (index >= 0) {
|
|
818
|
+
this.semantics.splice(index, 1);
|
|
819
|
+
this.domain.notifyChange();
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Checks if the entity has a specific semantic.
|
|
824
|
+
* @param semanticId The ID of the semantic to check.
|
|
825
|
+
* @returns True if the semantic is present, false otherwise.
|
|
826
|
+
*/
|
|
827
|
+
hasSemantic(semanticId) {
|
|
828
|
+
return this.semantics.some((s) => s.id === semanticId);
|
|
829
|
+
}
|
|
786
830
|
};
|
|
787
831
|
})();
|
|
788
832
|
export { DomainEntity };
|