@api-client/core 0.11.4 → 0.11.6
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/oauth-popup.html +33 -0
- package/build/src/modeling/DataAssociation.d.ts +5 -1
- package/build/src/modeling/DataAssociation.d.ts.map +1 -1
- package/build/src/modeling/DataAssociation.js +10 -4
- package/build/src/modeling/DataAssociation.js.map +1 -1
- package/build/src/modeling/DataEntity.d.ts +5 -1
- package/build/src/modeling/DataEntity.d.ts.map +1 -1
- package/build/src/modeling/DataEntity.js +15 -8
- package/build/src/modeling/DataEntity.js.map +1 -1
- package/build/src/modeling/DataModel.d.ts +5 -1
- package/build/src/modeling/DataModel.d.ts.map +1 -1
- package/build/src/modeling/DataModel.js +15 -11
- package/build/src/modeling/DataModel.js.map +1 -1
- package/build/src/modeling/DataNamespace.d.ts +12 -1
- package/build/src/modeling/DataNamespace.d.ts.map +1 -1
- package/build/src/modeling/DataNamespace.js +45 -6
- package/build/src/modeling/DataNamespace.js.map +1 -1
- package/build/src/modeling/DataProperty.js +2 -2
- package/build/src/modeling/DataProperty.js.map +1 -1
- package/data/models/example-generator-api.json +18 -18
- package/package.json +1 -1
- package/src/modeling/DataAssociation.ts +11 -4
- package/src/modeling/DataEntity.ts +16 -8
- package/src/modeling/DataModel.ts +16 -11
- package/src/modeling/DataNamespace.ts +46 -6
- package/src/modeling/DataProperty.ts +2 -2
- package/tests/unit/modeling/data_association.spec.ts +2 -2
- package/tests/unit/modeling/data_entity.spec.ts +3 -3
- package/tests/unit/modeling/data_model.spec.ts +3 -3
- package/tests/unit/modeling/data_namespace.spec.ts +72 -3
- package/Local.session.sql +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>Oauth2 callback window</title>
|
|
6
|
+
<style>
|
|
7
|
+
*[hidden] {
|
|
8
|
+
display: none;
|
|
9
|
+
}
|
|
10
|
+
</style>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<h1>Sending the authorization data to the application</h1>
|
|
14
|
+
<p id="general-error" hidden>
|
|
15
|
+
The window wasn't opened as a popup and therefore it can't pass the authorization information.<br />
|
|
16
|
+
This is an error.
|
|
17
|
+
</p>
|
|
18
|
+
<script>
|
|
19
|
+
const messageTarget = window.opener || window.parent || window.top
|
|
20
|
+
if (!messageTarget || messageTarget === window || !messageTarget.postMessage) {
|
|
21
|
+
const elm = document.getElementById('general-error')
|
|
22
|
+
elm.removeAttribute('hidden')
|
|
23
|
+
} else {
|
|
24
|
+
const search = window.location.search.substr(1)
|
|
25
|
+
if (search) {
|
|
26
|
+
messageTarget.postMessage(search, '*')
|
|
27
|
+
} else {
|
|
28
|
+
messageTarget.postMessage(window.location.hash.substr(1), '*')
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
@@ -235,12 +235,16 @@ export declare class DataAssociation {
|
|
|
235
235
|
* @returns AMF property shape definition.
|
|
236
236
|
*/
|
|
237
237
|
toApiShape(): IApiPropertyShape;
|
|
238
|
+
/**
|
|
239
|
+
* @deprecated Use the `getParentInstance()` method instead.
|
|
240
|
+
*/
|
|
241
|
+
getParent(): DataEntity;
|
|
238
242
|
/**
|
|
239
243
|
* Retrieves the parent entity of this association.
|
|
240
244
|
*
|
|
241
245
|
* @returns The `DataEntity` instance that contains this association.
|
|
242
246
|
*/
|
|
243
|
-
|
|
247
|
+
getParentInstance(): DataEntity;
|
|
244
248
|
/**
|
|
245
249
|
* Creates the `schema` object if missing and returns it.
|
|
246
250
|
* @returns The schema object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataAssociation.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataAssociation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,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AI,iBAAiB;IAK/B;;OAEG;IACH,SAAS,IAAI,UAAU;IAIvB;;;;OAIG;IACH,iBAAiB,IAAI,UAAU;IAM/B;;;OAGG;IACH,YAAY,IAAI,oBAAoB;IAOpC;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB;IAOxE;;;OAGG;IACH,aAAa,IAAI,sBAAsB;IASvC;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,mBAAmB,GAAG,SAAS;CAIvE"}
|
|
@@ -276,9 +276,9 @@ export class DataAssociation {
|
|
|
276
276
|
*/
|
|
277
277
|
remove() {
|
|
278
278
|
const { root } = this;
|
|
279
|
-
const entity = root.definitions.entities.find((i) => i.associations.some((j) => j === this));
|
|
279
|
+
const entity = root.definitions.entities.find((i) => i.associations.some((j) => j.key === this.key));
|
|
280
280
|
if (entity) {
|
|
281
|
-
const assocIndex = entity.associations.findIndex((i) => i === this);
|
|
281
|
+
const assocIndex = entity.associations.findIndex((i) => i.key === this.key);
|
|
282
282
|
entity.associations.splice(assocIndex, 1);
|
|
283
283
|
}
|
|
284
284
|
const defIndex = this.root.definitions.associations.findIndex((i) => i.key === this.key);
|
|
@@ -349,15 +349,21 @@ export class DataAssociation {
|
|
|
349
349
|
const serializer = new AmfShapeGenerator();
|
|
350
350
|
return serializer.associationProperty(this);
|
|
351
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* @deprecated Use the `getParentInstance()` method instead.
|
|
354
|
+
*/
|
|
355
|
+
getParent() {
|
|
356
|
+
return this.getParentInstance();
|
|
357
|
+
}
|
|
352
358
|
/**
|
|
353
359
|
* Retrieves the parent entity of this association.
|
|
354
360
|
*
|
|
355
361
|
* @returns The `DataEntity` instance that contains this association.
|
|
356
362
|
*/
|
|
357
|
-
|
|
363
|
+
getParentInstance() {
|
|
358
364
|
// this is forced as an association is only created when an entity is created
|
|
359
365
|
// so it has to be defined.
|
|
360
|
-
return this.root.definitions.entities.find((i) => i.associations.
|
|
366
|
+
return this.root.definitions.entities.find((i) => i.associations.some((a) => a.key === this.key));
|
|
361
367
|
}
|
|
362
368
|
/**
|
|
363
369
|
* Creates the `schema` object if missing and returns it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataAssociation.js","sourceRoot":"","sources":["../../../src/modeling/DataAssociation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAE/D,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAA+B,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAE,uBAAuB,EAA+B,MAAM,iBAAiB,CAAA;AAuEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,OAAO,eAAe;IA0FjB;IAzFT,IAAI,GAAG,mBAAmB,CAAA;IAE1B,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;;;OAIG;IACH,OAAO,GAAwB,EAAE,CAAA;IAEjC;;;;;;OAMG;IACH,MAAM,CAAuB;IAE7B;;;;;;OAMG;IACH,QAAQ,GAAyB,EAAE,CAAA;IAEnC;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,UAAU,CAAC,IAAmB,EAAE,MAAc,EAAE,SAAkB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AAC,MAAM,CAAC,CAAA;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,MAAgC,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAwB;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAuB,CAAA;QAC7E,OAAO,IAAI,EAAE,MAAM,CAAA;IACrB,CAAC;CACF","sourcesContent":["import { Json } from '@api-client/json'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport v4 from '../lib/uuid.js'\nimport { IThing, Thing } from '../models/Thing.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { type FieldValidationMessage, ValidationError } from '../exceptions/validation_error.js'\nimport { DataAssociationKind } from '../models/kinds.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { DataAttributeAttributes, type DataAttributeAttribute } from './DataFormat.js'\n\n/**\n * Describes association target of an entity\n */\nexport interface AssociationTarget {\n /**\n * The key of the associated entity.\n */\n key: string\n /**\n * The key of the namespace to look for entities.\n * By default it is the current (root) namespace. When this is set the program\n * will look into `foreign` of the root namespace for the definition\n * of the entity.\n */\n namespace?: string\n}\n\n/**\n * Describes an association between entities. An association is another property of an entity.\n * The `name` is the name of the property and the value is the associated target or targets.\n *\n * An association can have multiple targets to allow describing the model as `allOf`, `anyOf` and `oneOf` schemas.\n * When the association has only one target, then generated schema cannot have union types.\n *\n * Depending on the schema translation an association can be embedded as a sub-object in the generated schema\n * or can be references via a primary key.\n */\nexport interface IDataAssociation {\n kind: typeof DataAssociationKind\n /**\n * The key of the association.\n */\n key: string\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 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 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\n/**\n * Describes an association between entities. An association is a relationship defined on an entity\n * that links it to one or more other entities. The association has a `name` which is used as the\n * property name in the context of the parent entity, and it connects to a set of `targets`\n * representing the associated entities.\n *\n * An association can have multiple targets to allow describing the model as `allOf`, `anyOf`, or `oneOf`\n * schemas. When the association has only one target, then the generated schema cannot have union types.\n *\n * Depending on the schema translation, an association can be embedded as a sub-object in the generated\n * schema, or it can be referenced via a primary key.\n *\n * ## Key Concepts\n *\n * - **Targets**: An association's `targets` specify the entities that this association points to.\n * Each target is defined by:\n * - `key`: The key of the target entity.\n * - `namespace` (optional): The key of the namespace where the target entity is defined.\n * If not specified, it defaults to the current namespace.\n *\n * - **Cardinality**:\n * - `multiple` (boolean): Indicates whether the association allows multiple target entities.\n * If `true`, it's a to-many relationship; otherwise, it's a to-one relationship.\n *\n * - **Schema**:\n * - `schema` (optional): A custom schema for the association, allowing manual definition of the\n * association's structure in specific formats (e.g., JSON, RAML, XML).\n * When provided, this schema overrides the automatically generated schema based on the\n * target entities.\n * - **Important**: If a custom schema is defined and changes are made to the referenced\n * entities, those changes **will not** be automatically propagated to the custom schema.\n * This means the custom schema may become outdated and no longer accurately reflect the\n * structure of the target entities.\n *\n * - **Hidden**:\n * - `hidden`: (boolean) Defines if this association is a part of the schema or not.\n */\nexport class DataAssociation {\n kind = DataAssociationKind\n\n key = ''\n\n /**\n * The description of the data association.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Wether the data association is required.\n */\n required?: boolean\n\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\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 targets: AssociationTarget[] = []\n\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 /**\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 /**\n * Returns true when the association has 0 or 1 targets.\n */\n get isSingle(): boolean {\n return this.targets.length < 2\n }\n\n /**\n * Creates an instance of DataAssociation from a target entity key.\n * Note, this entity will have no name. The default name is used instead.\n *\n * @param root The namespace root.\n * @param target The target entity key.\n * @param namespace The optional key of the target association when different to the current one.\n * @returns A new `DataAssociation` instance.\n */\n static fromTarget(root: DataNamespace, target: string, namespace?: string): DataAssociation {\n const assoc = new DataAssociation(root)\n const info: AssociationTarget = {\n key: target,\n }\n if (namespace) {\n info.namespace = namespace\n }\n assoc.targets = [info]\n return assoc\n }\n\n /**\n * Creates an instance of DataAssociation from a name, without defining a target.\n *\n * @param root The namespace root.\n * @param name The name of the association.\n * @returns A new `DataAssociation` instance.\n */\n static fromName(root: DataNamespace, name: string): DataAssociation {\n const assoc = new DataAssociation(root)\n assoc.info = Thing.fromName(name)\n return assoc\n }\n\n /**\n * @param input The data association definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataAssociation\n ) {\n let init: IDataAssociation\n if (typeof input === 'string') {\n try {\n init = JSON.parse(input)\n } catch {\n throw new ValidationError([\n {\n field: '',\n message: 'Unable to parse the data association input as JSON.',\n rule: 'object_required',\n },\n ])\n }\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataAssociationKind,\n key: v4(),\n info: Thing.fromName('Unnamed association').toJSON(),\n }\n }\n this.new(init)\n }\n\n /**\n * Initializes the association using provided data.\n *\n * @param init - The data association definition to restore.\n */\n new(init: IDataAssociation): this {\n DataAssociation.validate(init)\n const { info, key = v4(), kind = DataAssociationKind, schema, multiple, required, targets, bindings } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (schema) {\n this.schema = Json.clone(schema)\n } else {\n this.schema = undefined\n }\n if (typeof multiple === 'boolean') {\n this.multiple = multiple\n } else {\n this.multiple = undefined\n }\n if (typeof required === 'boolean') {\n this.required = required\n } else {\n this.required = undefined\n }\n if (Array.isArray(targets)) {\n this.targets = targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n if (Array.isArray(bindings)) {\n this.bindings = bindings.map((i) => Json.clone(i))\n } else {\n this.bindings = []\n }\n return this\n }\n\n /**\n * Validates if the input object is a valid `DataAssociation` definition.\n * Throws a `ValidationError` if the input is invalid.\n *\n * @param input The object to validate.\n * @throws {ValidationError} When the validation fails.\n */\n static validate(input: unknown): void {\n const typed = input as IDataAssociation\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataAssociationKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataAssociationKind}`,\n rule: 'invalid',\n })\n }\n if (typed.info && typeof typed.info !== 'object') {\n messages.push({\n field: 'info',\n message: 'The info property must be an object',\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages)\n }\n }\n\n /**\n * Generates an object representing the association, suitable for serialization.\n *\n * @returns A plain object representation of the `DataAssociation`.\n */\n toJSON(): IDataAssociation {\n const result: IDataAssociation = {\n kind: DataAssociationKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = Json.clone(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.targets) && this.targets.length) {\n result.targets = this.targets.map((i) => ({ ...i }))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = this.bindings.map((i) => Json.clone(i))\n }\n return result\n }\n\n /**\n * Retrieves the list of target entities.\n *\n * @returns An array of `DataEntity` instances representing the targets of this association.\n */\n getTargets(): DataEntity[] {\n const { targets } = this\n return this.root.findAssociatedEntities(targets).filter((i) => !!i) as DataEntity[]\n }\n\n /**\n * Removes self from the parent entity and the namespace definition.\n */\n remove(): void {\n const { root } = this\n const entity = root.definitions.entities.find((i) => i.associations.some((j) => j === this))\n if (entity) {\n const assocIndex = entity.associations.findIndex((i) => i === this)\n entity.associations.splice(assocIndex, 1)\n }\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === this.key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n }\n\n /**\n * Adds a target entity to the association.\n * If the entity comes from another namespace then it is set as a foreign entity.\n *\n * @param entity - The `DataEntity` instance to add.\n */\n addTarget(entity: DataEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `IDataEntity` definition or just its key.\n * @param namespace - The key of the foreign namespace this entity belongs to.\n * Do not set this value for local entities.\n */\n addTarget(entity: IDataEntity | string, namespace?: string): void\n\n /**\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this entity belongs to.\n * Do not set this value for local entities.\n */\n addTarget(init: string | DataEntity | IDataEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n const typed = init as IDataEntity & { root?: DataNamespace }\n if (!namespace && typed.root && typed.root !== this.root) {\n namespace = typed.root.key\n }\n }\n if (namespace && namespace !== this.root.key) {\n const foreignNamespace = this.root.foreign.find((ns) => ns.key === namespace)\n if (!foreignNamespace) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.namespace = namespace\n }\n this.targets.push(info)\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or schema.\n */\n removeTarget(init: string | DataEntity | IDataEntity): 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 }\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 AmfShapeGenerator()\n return serializer.associationProperty(this)\n }\n\n /**\n * Retrieves the parent entity of this association.\n *\n * @returns The `DataEntity` instance that contains this association.\n */\n getParent(): DataEntity {\n // this is forced as an association is only created when an entity is created\n // so it has to be defined.\n return this.root.definitions.entities.find((i) => i.associations.includes(this)) as DataEntity\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\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 data proprty attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data proprty attributes.\n */\n static isValidAttribute(value: unknown): value is DataAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DataAttributeAttributes.includes(value as DataAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\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 }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataAssociation.js","sourceRoot":"","sources":["../../../src/modeling/DataAssociation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAE/D,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAA+B,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAE,uBAAuB,EAA+B,MAAM,iBAAiB,CAAA;AAuEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,OAAO,eAAe;IA0FjB;IAzFT,IAAI,GAAG,mBAAmB,CAAA;IAE1B,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;;;OAIG;IACH,OAAO,GAAwB,EAAE,CAAA;IAEjC;;;;;;OAMG;IACH,MAAM,CAAuB;IAE7B;;;;;;OAMG;IACH,QAAQ,GAAyB,EAAE,CAAA;IAEnC;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;;;OAQG;I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AQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAmC,CAAA;QAC1F,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAwB,CAAA;YAC1D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,MAAgC,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAwB;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAuB,CAAA;QAC7E,OAAO,IAAI,EAAE,MAAM,CAAA;IACrB,CAAC;CACF","sourcesContent":["import { Json } from '@api-client/json'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport v4 from '../lib/uuid.js'\nimport { IThing, Thing } from '../models/Thing.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { type FieldValidationMessage, ValidationError } from '../exceptions/validation_error.js'\nimport { DataAssociationKind } from '../models/kinds.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { DataAttributeAttributes, type DataAttributeAttribute } from './DataFormat.js'\n\n/**\n * Describes association target of an entity\n */\nexport interface AssociationTarget {\n /**\n * The key of the associated entity.\n */\n key: string\n /**\n * The key of the namespace to look for entities.\n * By default it is the current (root) namespace. When this is set the program\n * will look into `foreign` of the root namespace for the definition\n * of the entity.\n */\n namespace?: string\n}\n\n/**\n * Describes an association between entities. An association is another property of an entity.\n * The `name` is the name of the property and the value is the associated target or targets.\n *\n * An association can have multiple targets to allow describing the model as `allOf`, `anyOf` and `oneOf` schemas.\n * When the association has only one target, then generated schema cannot have union types.\n *\n * Depending on the schema translation an association can be embedded as a sub-object in the generated schema\n * or can be references via a primary key.\n */\nexport interface IDataAssociation {\n kind: typeof DataAssociationKind\n /**\n * The key of the association.\n */\n key: string\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 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 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\n/**\n * Describes an association between entities. An association is a relationship defined on an entity\n * that links it to one or more other entities. The association has a `name` which is used as the\n * property name in the context of the parent entity, and it connects to a set of `targets`\n * representing the associated entities.\n *\n * An association can have multiple targets to allow describing the model as `allOf`, `anyOf`, or `oneOf`\n * schemas. When the association has only one target, then the generated schema cannot have union types.\n *\n * Depending on the schema translation, an association can be embedded as a sub-object in the generated\n * schema, or it can be referenced via a primary key.\n *\n * ## Key Concepts\n *\n * - **Targets**: An association's `targets` specify the entities that this association points to.\n * Each target is defined by:\n * - `key`: The key of the target entity.\n * - `namespace` (optional): The key of the namespace where the target entity is defined.\n * If not specified, it defaults to the current namespace.\n *\n * - **Cardinality**:\n * - `multiple` (boolean): Indicates whether the association allows multiple target entities.\n * If `true`, it's a to-many relationship; otherwise, it's a to-one relationship.\n *\n * - **Schema**:\n * - `schema` (optional): A custom schema for the association, allowing manual definition of the\n * association's structure in specific formats (e.g., JSON, RAML, XML).\n * When provided, this schema overrides the automatically generated schema based on the\n * target entities.\n * - **Important**: If a custom schema is defined and changes are made to the referenced\n * entities, those changes **will not** be automatically propagated to the custom schema.\n * This means the custom schema may become outdated and no longer accurately reflect the\n * structure of the target entities.\n *\n * - **Hidden**:\n * - `hidden`: (boolean) Defines if this association is a part of the schema or not.\n */\nexport class DataAssociation {\n kind = DataAssociationKind\n\n key = ''\n\n /**\n * The description of the data association.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Wether the data association is required.\n */\n required?: boolean\n\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\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 targets: AssociationTarget[] = []\n\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 /**\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 /**\n * Returns true when the association has 0 or 1 targets.\n */\n get isSingle(): boolean {\n return this.targets.length < 2\n }\n\n /**\n * Creates an instance of DataAssociation from a target entity key.\n * Note, this entity will have no name. The default name is used instead.\n *\n * @param root The namespace root.\n * @param target The target entity key.\n * @param namespace The optional key of the target association when different to the current one.\n * @returns A new `DataAssociation` instance.\n */\n static fromTarget(root: DataNamespace, target: string, namespace?: string): DataAssociation {\n const assoc = new DataAssociation(root)\n const info: AssociationTarget = {\n key: target,\n }\n if (namespace) {\n info.namespace = namespace\n }\n assoc.targets = [info]\n return assoc\n }\n\n /**\n * Creates an instance of DataAssociation from a name, without defining a target.\n *\n * @param root The namespace root.\n * @param name The name of the association.\n * @returns A new `DataAssociation` instance.\n */\n static fromName(root: DataNamespace, name: string): DataAssociation {\n const assoc = new DataAssociation(root)\n assoc.info = Thing.fromName(name)\n return assoc\n }\n\n /**\n * @param input The data association definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataAssociation\n ) {\n let init: IDataAssociation\n if (typeof input === 'string') {\n try {\n init = JSON.parse(input)\n } catch {\n throw new ValidationError([\n {\n field: '',\n message: 'Unable to parse the data association input as JSON.',\n rule: 'object_required',\n },\n ])\n }\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataAssociationKind,\n key: v4(),\n info: Thing.fromName('Unnamed association').toJSON(),\n }\n }\n this.new(init)\n }\n\n /**\n * Initializes the association using provided data.\n *\n * @param init - The data association definition to restore.\n */\n new(init: IDataAssociation): this {\n DataAssociation.validate(init)\n const { info, key = v4(), kind = DataAssociationKind, schema, multiple, required, targets, bindings } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (schema) {\n this.schema = Json.clone(schema)\n } else {\n this.schema = undefined\n }\n if (typeof multiple === 'boolean') {\n this.multiple = multiple\n } else {\n this.multiple = undefined\n }\n if (typeof required === 'boolean') {\n this.required = required\n } else {\n this.required = undefined\n }\n if (Array.isArray(targets)) {\n this.targets = targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n if (Array.isArray(bindings)) {\n this.bindings = bindings.map((i) => Json.clone(i))\n } else {\n this.bindings = []\n }\n return this\n }\n\n /**\n * Validates if the input object is a valid `DataAssociation` definition.\n * Throws a `ValidationError` if the input is invalid.\n *\n * @param input The object to validate.\n * @throws {ValidationError} When the validation fails.\n */\n static validate(input: unknown): void {\n const typed = input as IDataAssociation\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataAssociationKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataAssociationKind}`,\n rule: 'invalid',\n })\n }\n if (typed.info && typeof typed.info !== 'object') {\n messages.push({\n field: 'info',\n message: 'The info property must be an object',\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages)\n }\n }\n\n /**\n * Generates an object representing the association, suitable for serialization.\n *\n * @returns A plain object representation of the `DataAssociation`.\n */\n toJSON(): IDataAssociation {\n const result: IDataAssociation = {\n kind: DataAssociationKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = Json.clone(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.targets) && this.targets.length) {\n result.targets = this.targets.map((i) => ({ ...i }))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = this.bindings.map((i) => Json.clone(i))\n }\n return result\n }\n\n /**\n * Retrieves the list of target entities.\n *\n * @returns An array of `DataEntity` instances representing the targets of this association.\n */\n getTargets(): DataEntity[] {\n const { targets } = this\n return this.root.findAssociatedEntities(targets).filter((i) => !!i) as DataEntity[]\n }\n\n /**\n * Removes self from the parent entity and the namespace definition.\n */\n remove(): void {\n const { root } = this\n const entity = root.definitions.entities.find((i) => i.associations.some((j) => j.key === this.key))\n if (entity) {\n const assocIndex = entity.associations.findIndex((i) => i.key === this.key)\n entity.associations.splice(assocIndex, 1)\n }\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === this.key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n }\n\n /**\n * Adds a target entity to the association.\n * If the entity comes from another namespace then it is set as a foreign entity.\n *\n * @param entity - The `DataEntity` instance to add.\n */\n addTarget(entity: DataEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `IDataEntity` definition or just its key.\n * @param namespace - The key of the foreign namespace this entity belongs to.\n * Do not set this value for local entities.\n */\n addTarget(entity: IDataEntity | string, namespace?: string): void\n\n /**\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this entity belongs to.\n * Do not set this value for local entities.\n */\n addTarget(init: string | DataEntity | IDataEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n const typed = init as IDataEntity & { root?: DataNamespace }\n if (!namespace && typed.root && typed.root !== this.root) {\n namespace = typed.root.key\n }\n }\n if (namespace && namespace !== this.root.key) {\n const foreignNamespace = this.root.foreign.find((ns) => ns.key === namespace)\n if (!foreignNamespace) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.namespace = namespace\n }\n this.targets.push(info)\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or schema.\n */\n removeTarget(init: string | DataEntity | IDataEntity): 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 }\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 AmfShapeGenerator()\n return serializer.associationProperty(this)\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n getParent(): DataEntity {\n return this.getParentInstance()\n }\n\n /**\n * Retrieves the parent entity of this association.\n *\n * @returns The `DataEntity` instance that contains this association.\n */\n getParentInstance(): DataEntity {\n // this is forced as an association is only created when an entity is created\n // so it has to be defined.\n return this.root.definitions.entities.find((i) => i.associations.some((a) => a.key === this.key)) as DataEntity\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\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 data proprty attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data proprty attributes.\n */\n static isValidAttribute(value: unknown): value is DataAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DataAttributeAttributes.includes(value as DataAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\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 }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema\n }\n}\n"]}
|
|
@@ -223,9 +223,13 @@ export declare class DataEntity {
|
|
|
223
223
|
*/
|
|
224
224
|
remove(): void;
|
|
225
225
|
/**
|
|
226
|
-
*
|
|
226
|
+
* @deprecated Use the `getParentInstance()` method instead.
|
|
227
227
|
*/
|
|
228
228
|
getParent(): DataModel | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Returns a parent data model where this entity exist.
|
|
231
|
+
*/
|
|
232
|
+
getParentInstance(): DataModel | undefined;
|
|
229
233
|
/**
|
|
230
234
|
* Adds a parent reference to this entity.
|
|
231
235
|
* This will not add the parent to the namespace. It only adds a reference to the parent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataEntity.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mB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G;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAY5B;;;;;;;;;OASG;IACH,UAAU,IAAI,WAAW;IAKzB;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,mBAAwB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;IAWrG,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;CAyBlE"}
|
|
@@ -465,7 +465,7 @@ export class DataEntity {
|
|
|
465
465
|
const associationsToEntity = this.root.definitions.associations.filter((a) => a.targets.some((t) => t.key === this.key));
|
|
466
466
|
if (associationsToEntity.length > 0) {
|
|
467
467
|
const entitiesNames = associationsToEntity.reduce((acc, association) => {
|
|
468
|
-
const entity = root.definitions.entities.find((e) => e.associations.
|
|
468
|
+
const entity = root.definitions.entities.find((e) => e.associations.some((a) => a.key === association.key));
|
|
469
469
|
if (entity) {
|
|
470
470
|
acc.push(entity.info.name);
|
|
471
471
|
}
|
|
@@ -482,17 +482,24 @@ export class DataEntity {
|
|
|
482
482
|
root.definitions.entities.splice(index, 1);
|
|
483
483
|
}
|
|
484
484
|
// remove from the parent
|
|
485
|
-
const model = this.
|
|
485
|
+
const model = this.getParentInstance();
|
|
486
486
|
if (model) {
|
|
487
|
-
const entityIndex = model.entities.findIndex((e) => e === this);
|
|
487
|
+
const entityIndex = model.entities.findIndex((e) => e.key === this.key);
|
|
488
488
|
model.entities.splice(entityIndex, 1);
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
/**
|
|
492
|
-
*
|
|
492
|
+
* @deprecated Use the `getParentInstance()` method instead.
|
|
493
493
|
*/
|
|
494
|
+
// This method name colides with the `getParents()` method.
|
|
494
495
|
getParent() {
|
|
495
|
-
return this.
|
|
496
|
+
return this.getParentInstance();
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Returns a parent data model where this entity exist.
|
|
500
|
+
*/
|
|
501
|
+
getParentInstance() {
|
|
502
|
+
return this.root.definitions.models.find((m) => m.entities.some((e) => e.key === this.key));
|
|
496
503
|
}
|
|
497
504
|
/**
|
|
498
505
|
* Adds a parent reference to this entity.
|
|
@@ -664,21 +671,21 @@ export class DataEntity {
|
|
|
664
671
|
name: this.info.name || 'Unnamed entity',
|
|
665
672
|
kind: DataEntityKind,
|
|
666
673
|
});
|
|
667
|
-
const model = this.
|
|
674
|
+
const model = this.getParentInstance();
|
|
668
675
|
if (model) {
|
|
669
676
|
result.push({
|
|
670
677
|
key: model.key,
|
|
671
678
|
kind: model.kind,
|
|
672
679
|
name: model.info.name || 'Unnamed data model',
|
|
673
680
|
});
|
|
674
|
-
let parent = model.
|
|
681
|
+
let parent = model.getParentInstance();
|
|
675
682
|
while (parent && parent !== this.root) {
|
|
676
683
|
result.push({
|
|
677
684
|
key: parent.key,
|
|
678
685
|
kind: parent.kind,
|
|
679
686
|
name: parent.info.name || 'Unnamed namespace',
|
|
680
687
|
});
|
|
681
|
-
parent = parent.
|
|
688
|
+
parent = parent.getParentInstance();
|
|
682
689
|
}
|
|
683
690
|
}
|
|
684
691
|
result.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataEntity.js","sourceRoot":"","sources":["../../../src/modeling/DataEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,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,EAAE,CAAC;gBAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;gBAC9B,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,MAAM,CAAA;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { DataProperty } from './DataProperty.js'\nimport { type DataPropertyType } from './DataFormat.js'\nimport { DataAssociation } from './DataAssociation.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataEntityKind } from '../models/kinds.js'\nimport { DataModel } from './DataModel.js'\nimport { IApiNodeShape, IShapeUnion } from '../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\nimport { RemovePropertyException } from '../exceptions/remove_property_exception.js'\nimport { RemoveAssociationException } from '../exceptions/remove_association_exception.js'\nimport { ValidationError, type FieldValidationMessage } from '../exceptions/validation_error.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { ForeignAssociationException } from '../exceptions/foreign_association_exception.js'\n\ninterface OrderedItem {\n type: 'property' | 'association'\n key: string\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport interface IDataEntity {\n kind: typeof DataEntityKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data entity description.\n */\n info: IThing\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy?: string[]\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties?: string[]\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations?: string[]\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields?: OrderedItem[]\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n *\n * @todo(jarrodek): This should also hold a reference to a namespace to support\n * foreign entities as parents.\n */\n parents?: string[]\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n */\n schema?: IApiNodeShape\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport class DataEntity {\n kind = DataEntityKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy: string[] = []\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties: DataProperty[] = []\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations: DataAssociation[] = []\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields: OrderedItem[] = []\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n */\n parents: string[] = []\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n static fromName(root: DataNamespace, name: string): DataEntity {\n const entity = new DataEntity(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param input The data entity definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataEntity\n ) {\n let init: IDataEntity\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataEntityKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataEntity): void {\n DataEntity.validate(init)\n const {\n info,\n key = v4(),\n kind = DataEntityKind,\n tags,\n taxonomy,\n parents,\n properties,\n associations,\n fields,\n deprecated,\n } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (Array.isArray(parents)) {\n this.parents = [...parents]\n } else {\n this.parents = []\n }\n this.properties = []\n if (Array.isArray(properties)) {\n properties.forEach((key) => {\n const value = this._readProperty(key)\n if (value) {\n this.properties.push(value)\n }\n })\n }\n this.associations = []\n if (Array.isArray(associations)) {\n associations.forEach((key) => {\n const value = this._readAssociation(key)\n if (value) {\n this.associations.push(value)\n }\n })\n }\n if (Array.isArray(fields)) {\n this.fields = [...fields]\n } else {\n this.fields = this.createOrderedFields()\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n private createOrderedFields(): OrderedItem[] {\n const result: OrderedItem[] = []\n this.properties.forEach((i) => {\n result.push({\n type: 'property',\n key: i.key,\n })\n })\n this.associations.forEach((i) => {\n result.push({\n type: 'association',\n key: i.key,\n })\n })\n return result\n }\n\n static validate(input: unknown): void {\n const typed = input as IDataEntity\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataEntityKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataEntityKind}`,\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages, { message: 'Invalid data entity definition.' })\n }\n }\n\n toJSON(): IDataEntity {\n const result: IDataEntity = {\n kind: DataEntityKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.parents) && this.parents.length) {\n result.parents = [...this.parents]\n }\n if (Array.isArray(this.properties) && this.properties.length) {\n result.properties = this.properties.map((i) => i.key)\n }\n if (Array.isArray(this.associations) && this.associations.length) {\n result.associations = this.associations.map((i) => i.key)\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n protected _readAssociation(key: string): DataAssociation | undefined {\n return this.root.definitions.associations.find((i) => i.key === key)\n }\n\n protected _readProperty(key: string): DataProperty | undefined {\n return this.root.definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Creates a property with a passed type.\n * @param type The type of the property\n * @returns The created property\n */\n addTypedProperty(type: DataPropertyType, name?: string): DataProperty {\n const property = DataProperty.fromType(this.root, type)\n if (name) {\n property.info.name = name\n }\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Creates a property with a passed type.\n * @param name The name of the property.\n * @returns The created property\n */\n addNamedProperty(name: string): DataProperty {\n const property = DataProperty.fromName(this.root, name)\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Removes the property from the entity and namespace definitions.\n * @param key The key of the property to remove.\n */\n removeProperty(key: string): void {\n const thisIndex = this.properties.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't exist.`)\n }\n const propertyToRemove = this.properties[thisIndex]\n this.properties.splice(thisIndex, 1)\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n this.removeField(key)\n propertyToRemove.remove()\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Lists all properties for this Entity.\n * @returns The list of properties that belong to this entity.\n */\n listProperties(): DataProperty[] {\n return [...this.properties]\n }\n\n /**\n * Lists all associations for this Entity.\n * @returns The list of associations that belong to this entity.\n */\n listAssociations(): DataAssociation[] {\n return [...this.associations]\n }\n\n /**\n * Generates an ordered list of fields (properties and associations) for this entity.\n *\n * @returns The list of fields (properties and associations) that belong to this entity.\n */\n listFields(): (DataAssociation | DataProperty)[] {\n const result: (DataAssociation | DataProperty)[] = []\n this.fields.forEach((i) => {\n if (i.type === 'property') {\n const property = this.properties.find((p) => p.key === i.key)\n if (property) {\n result.push(property)\n }\n } else if (i.type === 'association') {\n const association = this.associations.find((a) => a.key === i.key)\n if (association) {\n result.push(association)\n }\n }\n })\n return result\n }\n\n /**\n * Moves the field to a new index.\n * @param key The key of the field to move.\n * @param toIndex The new index to which move the field to.\n */\n moveField(key: string, toIndex: number): void {\n const fromIndex = this.fields.findIndex((i) => i.key === key)\n if (fromIndex < 0) {\n throw new ValidationError([{ field: 'fields', message: `Field ${key} not found.`, rule: 'not-found' }])\n }\n if (toIndex < 0 || toIndex >= this.fields.length) {\n throw new ValidationError([{ field: 'fields', message: `Invalid index ${toIndex}.`, rule: 'invalid' }])\n }\n const [item] = this.fields.splice(fromIndex, 1)\n this.fields.splice(toIndex, 0, item)\n }\n\n /**\n * Creates an association for a given name, adds it to definitions, and returns it.\n * @param name The name of the association\n * @returns The created association\n */\n addNamedAssociation(name: string): DataAssociation {\n const result = DataAssociation.fromName(this.root, name)\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target, adds it to definitions, and returns it.\n *\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addTargetAssociation(target: string | DataEntity, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n const result = DataAssociation.fromTarget(this.root, key)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target that is in another namespace\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addForeignAssociation(target: string | DataEntity, namespace: string, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n if (!this.root.hasForeignNamespace(namespace)) {\n throw new ForeignAssociationException(\n `Trying to add a foreign association but the foreign namespace is not defined.`\n )\n }\n const result = DataAssociation.fromTarget(this.root, key, namespace)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Removes an association from the entity and, namespace definitions.\n * @param key The key of the association to remove.\n */\n removeAssociation(key: string): void {\n const thisIndex = this.associations.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n // return\n throw new RemoveAssociationException(`Trying to remove the ${key} association, but it doesn't exist.`)\n }\n const associationToRemove = this.associations[thisIndex]\n this.associations.splice(thisIndex, 1)\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n this.removeField(key)\n associationToRemove.remove()\n }\n\n /**\n * Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all\n * parents in the inheritance chain in no particular order.\n * @param recursive Whether to include parent parents as well.\n */\n getComputedParents(recursive?: boolean): DataEntity[] {\n const { entities } = this.root.definitions\n let result: DataEntity[] = []\n this.parents.forEach((key) => {\n const parent = entities.find((i) => i.key === key)\n if (parent) {\n result.push(parent)\n if (recursive) {\n result = result.concat(parent.getComputedParents())\n }\n }\n })\n return result\n }\n\n /**\n * Computes list of all children, inside the root namespace, that extends this entity.\n * The children are not ordered.\n */\n getComputedChildren(): DataEntity[] {\n const { entities } = this.root.definitions\n return entities.filter((i) => i.parents.includes(this.key))\n }\n\n /**\n * Computes a list of entities that are associated with the current entity.\n */\n getComputedAssociations(): DataEntity[] {\n const { associations } = this\n const result: DataEntity[] = []\n associations.forEach((assoc) => {\n if (!assoc.targets.length) {\n return\n }\n const entities = this.root.findAssociatedEntities(assoc.targets)\n entities.forEach((entity) => {\n if (entity) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n /**\n * Removes self from the namespace with all properties and attributes.\n */\n remove(): void {\n const { key, properties, associations, root } = this\n // check if some entity has reference to this entity as a target\n const associationsToEntity = this.root.definitions.associations.filter((a) =>\n a.targets.some((t) => t.key === this.key)\n )\n if (associationsToEntity.length > 0) {\n const entitiesNames = associationsToEntity.reduce<string[]>((acc, association) => {\n const entity = root.definitions.entities.find((e) => e.associations.includes(association))\n if (entity) {\n acc.push(entity.info.name as string)\n }\n return acc\n }, [])\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.name} because it is used as a target in associations in entities: ${entitiesNames.join(', ')}.`\n )\n }\n\n // remove own stuff\n properties.forEach((p) => this.removeProperty(p.key))\n associations.forEach((a) => this.removeAssociation(a.key))\n // remove from the root\n const index = root.definitions.entities.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.entities.splice(index, 1)\n }\n // remove from the parent\n const model = this.getParent()\n if (model) {\n const entityIndex = model.entities.findIndex((e) => e === this)\n model.entities.splice(entityIndex, 1)\n }\n }\n\n /**\n * Returns a parent data model where this entity exist.\n */\n getParent(): DataModel | undefined {\n return this.root.definitions.models.find((m) => m.entities.some((e) => e === this))\n }\n\n /**\n * Adds a parent reference to this entity.\n * This will not add the parent to the namespace. It only adds a reference to the parent.\n * @param key The key of the parent entity to add.\n * @returns `this` for chaining.\n */\n addParent(key: string): this {\n // Prevent adding self as parent\n if (key === this.key) {\n const message = 'Entity cannot be a parent of itself.'\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n // check if parent exists\n const parent = this.root.definitions.entities.find((i) => i.key === key)\n if (!parent) {\n const message = `Entity with key \"${key}\" not found.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'not-exists',\n },\n ],\n { message }\n )\n }\n // Check for circular inheritance\n if (this.hasCircularParent(key)) {\n const message = `Circular inheritance detected. Cannot add ${key} as a parent.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n const has = this.parents.some((i) => i === key)\n if (has) {\n const message = `Parent ${key} already exists.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'exists',\n },\n ],\n { message }\n )\n }\n this.parents.push(key)\n return this\n }\n\n /**\n * Checks if the entity has a circular parent relationship when attempting to add a new parent.\n * @param key The key of the parent being added.\n * @returns true if adding this parent would create a circular relationship.\n */\n hasCircularParent(key: string): boolean {\n const { entities } = this.root.definitions\n // Check if new parent is one of the children.\n const children = this.getComputedChildren()\n if (children.some((c) => c.key === key)) {\n return true\n }\n // check if this entity is in parents chain.\n let current: DataEntity | undefined = entities.find((e) => e.key === key)\n while (current) {\n if (current.key === this.key) {\n return true\n }\n // for (const parentKey of current.parents) {\n // current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n // }\n const parentKey = current.parents[0] // Assuming single inheritance\n current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n }\n return false\n }\n\n /**\n * Tests whether one entity is associated with another.\n *\n * @param entity1 The source entity\n * @param entity2 The target entity\n * @returns true when there's any path from one entity to another.\n */\n static isAssociated(entity1: DataEntity, entity2: DataEntity): boolean {\n return entity1.isAssociated(entity2.key)\n }\n\n /**\n * Tests whether this entity is somehow associated with another entity.\n * @param target The key of the target entity to test for association with.\n * @returns true if this entity has any association to the `target` entity.\n */\n isAssociated(target: string): boolean {\n const it = this.associationPath(target)\n const path = it.next().value\n return !!path\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n * @param toEntity The key to the target entity\n * @yields The path containing keys of entities from this entity to the `toEntity`\n * (inclusive) and all entities in between.\n */\n *associationPath(toEntity: string): Generator<string[]> {\n const graph = this.root.associationGraph()\n for (const path of this.root.associationPath(this.key, toEntity, graph)) {\n yield path\n }\n }\n\n /**\n * Returns a list of entities that are associated with this entity as a target.\n *\n * This method identifies entities that have an association where this entity is a target.\n * In other words, it finds entities that \"point to\" this entity through an association.\n *\n * For example, consider the following relationships:\n *\n * ```plain\n * A -> B (A has an association that targets B)\n * C -> B (C has an association that targets B)\n * B -> D (B has an association that targets D)\n *\n * Calling `getRelatedEntities()` on B would return [A, C]\n * Calling `getRelatedEntities()` on D would return [B]\n * Calling `getRelatedEntities()` on A would return []\n * ```\n *\n * Note, this method only returns entities that are directly associated with this entity as a target.\n * It does not traverse the association graph to find indirectly related entities.\n *\n * @returns An array of `DataEntity` instances that have an association targeting this entity.\n */\n getRelatedEntities(): DataEntity[] {\n const { key, root } = this\n const result = DataEntity.getRelatedEntities(root, key)\n root.foreign.forEach((ns) => {\n const other = DataEntity.getRelatedEntities(ns, key)\n other.forEach((entity) => {\n if (!result.includes(entity)) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n static getRelatedEntities(namespace: DataNamespace, entityKey: string): DataEntity[] {\n const result: DataEntity[] = []\n const inverse = namespace.definitions.associations.filter((i) => i.targets.some((j) => j.key === entityKey))\n inverse.forEach((assoc) => {\n const entity = namespace.definitions.entities.find((e) => e.associations.includes(assoc))\n if (entity && !result.includes(entity)) {\n result.push(entity)\n }\n })\n return result\n }\n\n /**\n * Creates breadcrumbs from this entity to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.name || 'Unnamed entity',\n kind: DataEntityKind,\n })\n const model = this.getParent()\n if (model) {\n result.push({\n key: model.key,\n kind: model.kind,\n name: model.info.name || 'Unnamed data model',\n })\n let parent = model.getParent()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.name || 'Unnamed namespace',\n })\n parent = parent.getParent()\n }\n }\n result.push({\n key: this.root.key,\n name: this.root.info.name || 'Unnamed namespace',\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.\n *\n * Note, it does nothing when the tag is already defined.\n *\n * @param tag The tag to add.\n */\n addTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n if (tags.some((t) => t.toLowerCase() === lower)) {\n return\n }\n tags.push(tag)\n const { definitions } = this.root\n if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {\n definitions.tags.push(tag)\n }\n }\n\n /**\n * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.\n *\n * @param tag The tag to remove.\n */\n removeTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n const index = tags.findIndex((t) => t.toLowerCase() === lower)\n if (index >= 0) {\n tags.splice(index, 1)\n }\n }\n\n /**\n * Creates a 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(): IShapeUnion {\n const serializer = new AmfShapeGenerator()\n return serializer.entity(this)\n }\n\n /**\n * Reads the schema of the Entity and generates an example for it.\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n const shape = this.toApiShape()\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: typeof opts.renderExamples === 'boolean' ? opts.renderExamples : true,\n renderMocked: typeof opts.renderMocked === 'boolean' ? opts.renderMocked : true,\n renderOptional: typeof opts.renderOptional === 'boolean' ? opts.renderOptional : true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n hasClosedCycle(rootEntity: string, targetEntity: string): boolean {\n if (targetEntity === this.key) {\n // self association\n return true\n }\n const g = this.root.associationGraph()\n const selfPaths: string[][] = []\n const targetPaths: string[][] = []\n for (const path of this.root.associationPath(rootEntity, this.key, g)) {\n selfPaths.push(path)\n }\n for (const path of this.root.associationPath(targetEntity, this.key, g)) {\n targetPaths.push(path)\n }\n const checker = (arr: string[], target: string[]): boolean => target.every((v) => arr.includes(v))\n for (const sp of selfPaths) {\n for (const tp of targetPaths) {\n const result = checker(sp, tp)\n if (result) {\n return result\n }\n }\n }\n return false\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataEntity.js","sourceRoot":"","sources":["../../../src/modeling/DataEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAA;AAC1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AAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;QAClG,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;YAC3B,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;gBAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;gBAC9B,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,MAAM,CAAA;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { DataProperty } from './DataProperty.js'\nimport { type DataPropertyType } from './DataFormat.js'\nimport { DataAssociation } from './DataAssociation.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataEntityKind } from '../models/kinds.js'\nimport { DataModel } from './DataModel.js'\nimport { IApiNodeShape, IShapeUnion } from '../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\nimport { RemovePropertyException } from '../exceptions/remove_property_exception.js'\nimport { RemoveAssociationException } from '../exceptions/remove_association_exception.js'\nimport { ValidationError, type FieldValidationMessage } from '../exceptions/validation_error.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { ForeignAssociationException } from '../exceptions/foreign_association_exception.js'\n\ninterface OrderedItem {\n type: 'property' | 'association'\n key: string\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport interface IDataEntity {\n kind: typeof DataEntityKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data entity description.\n */\n info: IThing\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy?: string[]\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties?: string[]\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations?: string[]\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields?: OrderedItem[]\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n *\n * @todo(jarrodek): This should also hold a reference to a namespace to support\n * foreign entities as parents.\n */\n parents?: string[]\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n */\n schema?: IApiNodeShape\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport class DataEntity {\n kind = DataEntityKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy: string[] = []\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties: DataProperty[] = []\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations: DataAssociation[] = []\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields: OrderedItem[] = []\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n */\n parents: string[] = []\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n static fromName(root: DataNamespace, name: string): DataEntity {\n const entity = new DataEntity(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param input The data entity definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataEntity\n ) {\n let init: IDataEntity\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataEntityKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataEntity): void {\n DataEntity.validate(init)\n const {\n info,\n key = v4(),\n kind = DataEntityKind,\n tags,\n taxonomy,\n parents,\n properties,\n associations,\n fields,\n deprecated,\n } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (Array.isArray(parents)) {\n this.parents = [...parents]\n } else {\n this.parents = []\n }\n this.properties = []\n if (Array.isArray(properties)) {\n properties.forEach((key) => {\n const value = this._readProperty(key)\n if (value) {\n this.properties.push(value)\n }\n })\n }\n this.associations = []\n if (Array.isArray(associations)) {\n associations.forEach((key) => {\n const value = this._readAssociation(key)\n if (value) {\n this.associations.push(value)\n }\n })\n }\n if (Array.isArray(fields)) {\n this.fields = [...fields]\n } else {\n this.fields = this.createOrderedFields()\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n private createOrderedFields(): OrderedItem[] {\n const result: OrderedItem[] = []\n this.properties.forEach((i) => {\n result.push({\n type: 'property',\n key: i.key,\n })\n })\n this.associations.forEach((i) => {\n result.push({\n type: 'association',\n key: i.key,\n })\n })\n return result\n }\n\n static validate(input: unknown): void {\n const typed = input as IDataEntity\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataEntityKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataEntityKind}`,\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages, { message: 'Invalid data entity definition.' })\n }\n }\n\n toJSON(): IDataEntity {\n const result: IDataEntity = {\n kind: DataEntityKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.parents) && this.parents.length) {\n result.parents = [...this.parents]\n }\n if (Array.isArray(this.properties) && this.properties.length) {\n result.properties = this.properties.map((i) => i.key)\n }\n if (Array.isArray(this.associations) && this.associations.length) {\n result.associations = this.associations.map((i) => i.key)\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n protected _readAssociation(key: string): DataAssociation | undefined {\n return this.root.definitions.associations.find((i) => i.key === key)\n }\n\n protected _readProperty(key: string): DataProperty | undefined {\n return this.root.definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Creates a property with a passed type.\n * @param type The type of the property\n * @returns The created property\n */\n addTypedProperty(type: DataPropertyType, name?: string): DataProperty {\n const property = DataProperty.fromType(this.root, type)\n if (name) {\n property.info.name = name\n }\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Creates a property with a passed type.\n * @param name The name of the property.\n * @returns The created property\n */\n addNamedProperty(name: string): DataProperty {\n const property = DataProperty.fromName(this.root, name)\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Removes the property from the entity and namespace definitions.\n * @param key The key of the property to remove.\n */\n removeProperty(key: string): void {\n const thisIndex = this.properties.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't exist.`)\n }\n const propertyToRemove = this.properties[thisIndex]\n this.properties.splice(thisIndex, 1)\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n this.removeField(key)\n propertyToRemove.remove()\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Lists all properties for this Entity.\n * @returns The list of properties that belong to this entity.\n */\n listProperties(): DataProperty[] {\n return [...this.properties]\n }\n\n /**\n * Lists all associations for this Entity.\n * @returns The list of associations that belong to this entity.\n */\n listAssociations(): DataAssociation[] {\n return [...this.associations]\n }\n\n /**\n * Generates an ordered list of fields (properties and associations) for this entity.\n *\n * @returns The list of fields (properties and associations) that belong to this entity.\n */\n listFields(): (DataAssociation | DataProperty)[] {\n const result: (DataAssociation | DataProperty)[] = []\n this.fields.forEach((i) => {\n if (i.type === 'property') {\n const property = this.properties.find((p) => p.key === i.key)\n if (property) {\n result.push(property)\n }\n } else if (i.type === 'association') {\n const association = this.associations.find((a) => a.key === i.key)\n if (association) {\n result.push(association)\n }\n }\n })\n return result\n }\n\n /**\n * Moves the field to a new index.\n * @param key The key of the field to move.\n * @param toIndex The new index to which move the field to.\n */\n moveField(key: string, toIndex: number): void {\n const fromIndex = this.fields.findIndex((i) => i.key === key)\n if (fromIndex < 0) {\n throw new ValidationError([{ field: 'fields', message: `Field ${key} not found.`, rule: 'not-found' }])\n }\n if (toIndex < 0 || toIndex >= this.fields.length) {\n throw new ValidationError([{ field: 'fields', message: `Invalid index ${toIndex}.`, rule: 'invalid' }])\n }\n const [item] = this.fields.splice(fromIndex, 1)\n this.fields.splice(toIndex, 0, item)\n }\n\n /**\n * Creates an association for a given name, adds it to definitions, and returns it.\n * @param name The name of the association\n * @returns The created association\n */\n addNamedAssociation(name: string): DataAssociation {\n const result = DataAssociation.fromName(this.root, name)\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target, adds it to definitions, and returns it.\n *\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addTargetAssociation(target: string | DataEntity, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n const result = DataAssociation.fromTarget(this.root, key)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target that is in another namespace\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addForeignAssociation(target: string | DataEntity, namespace: string, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n if (!this.root.hasForeignNamespace(namespace)) {\n throw new ForeignAssociationException(\n `Trying to add a foreign association but the foreign namespace is not defined.`\n )\n }\n const result = DataAssociation.fromTarget(this.root, key, namespace)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Removes an association from the entity and, namespace definitions.\n * @param key The key of the association to remove.\n */\n removeAssociation(key: string): void {\n const thisIndex = this.associations.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n // return\n throw new RemoveAssociationException(`Trying to remove the ${key} association, but it doesn't exist.`)\n }\n const associationToRemove = this.associations[thisIndex]\n this.associations.splice(thisIndex, 1)\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n this.removeField(key)\n associationToRemove.remove()\n }\n\n /**\n * Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all\n * parents in the inheritance chain in no particular order.\n * @param recursive Whether to include parent parents as well.\n */\n getComputedParents(recursive?: boolean): DataEntity[] {\n const { entities } = this.root.definitions\n let result: DataEntity[] = []\n this.parents.forEach((key) => {\n const parent = entities.find((i) => i.key === key)\n if (parent) {\n result.push(parent)\n if (recursive) {\n result = result.concat(parent.getComputedParents())\n }\n }\n })\n return result\n }\n\n /**\n * Computes list of all children, inside the root namespace, that extends this entity.\n * The children are not ordered.\n */\n getComputedChildren(): DataEntity[] {\n const { entities } = this.root.definitions\n return entities.filter((i) => i.parents.includes(this.key))\n }\n\n /**\n * Computes a list of entities that are associated with the current entity.\n */\n getComputedAssociations(): DataEntity[] {\n const { associations } = this\n const result: DataEntity[] = []\n associations.forEach((assoc) => {\n if (!assoc.targets.length) {\n return\n }\n const entities = this.root.findAssociatedEntities(assoc.targets)\n entities.forEach((entity) => {\n if (entity) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n /**\n * Removes self from the namespace with all properties and attributes.\n */\n remove(): void {\n const { key, properties, associations, root } = this\n // check if some entity has reference to this entity as a target\n const associationsToEntity = this.root.definitions.associations.filter((a) =>\n a.targets.some((t) => t.key === this.key)\n )\n if (associationsToEntity.length > 0) {\n const entitiesNames = associationsToEntity.reduce<string[]>((acc, association) => {\n const entity = root.definitions.entities.find((e) => e.associations.some((a) => a.key === association.key))\n if (entity) {\n acc.push(entity.info.name as string)\n }\n return acc\n }, [])\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.name} because it is used as a target in associations in entities: ${entitiesNames.join(', ')}.`\n )\n }\n\n // remove own stuff\n properties.forEach((p) => this.removeProperty(p.key))\n associations.forEach((a) => this.removeAssociation(a.key))\n // remove from the root\n const index = root.definitions.entities.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.entities.splice(index, 1)\n }\n // remove from the parent\n const model = this.getParentInstance()\n if (model) {\n const entityIndex = model.entities.findIndex((e) => e.key === this.key)\n model.entities.splice(entityIndex, 1)\n }\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n // This method name colides with the `getParents()` method.\n getParent(): DataModel | undefined {\n return this.getParentInstance()\n }\n\n /**\n * Returns a parent data model where this entity exist.\n */\n getParentInstance(): DataModel | undefined {\n return this.root.definitions.models.find((m) => m.entities.some((e) => e.key === this.key))\n }\n\n /**\n * Adds a parent reference to this entity.\n * This will not add the parent to the namespace. It only adds a reference to the parent.\n * @param key The key of the parent entity to add.\n * @returns `this` for chaining.\n */\n addParent(key: string): this {\n // Prevent adding self as parent\n if (key === this.key) {\n const message = 'Entity cannot be a parent of itself.'\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n // check if parent exists\n const parent = this.root.definitions.entities.find((i) => i.key === key)\n if (!parent) {\n const message = `Entity with key \"${key}\" not found.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'not-exists',\n },\n ],\n { message }\n )\n }\n // Check for circular inheritance\n if (this.hasCircularParent(key)) {\n const message = `Circular inheritance detected. Cannot add ${key} as a parent.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n const has = this.parents.some((i) => i === key)\n if (has) {\n const message = `Parent ${key} already exists.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'exists',\n },\n ],\n { message }\n )\n }\n this.parents.push(key)\n return this\n }\n\n /**\n * Checks if the entity has a circular parent relationship when attempting to add a new parent.\n * @param key The key of the parent being added.\n * @returns true if adding this parent would create a circular relationship.\n */\n hasCircularParent(key: string): boolean {\n const { entities } = this.root.definitions\n // Check if new parent is one of the children.\n const children = this.getComputedChildren()\n if (children.some((c) => c.key === key)) {\n return true\n }\n // check if this entity is in parents chain.\n let current: DataEntity | undefined = entities.find((e) => e.key === key)\n while (current) {\n if (current.key === this.key) {\n return true\n }\n // for (const parentKey of current.parents) {\n // current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n // }\n const parentKey = current.parents[0] // Assuming single inheritance\n current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n }\n return false\n }\n\n /**\n * Tests whether one entity is associated with another.\n *\n * @param entity1 The source entity\n * @param entity2 The target entity\n * @returns true when there's any path from one entity to another.\n */\n static isAssociated(entity1: DataEntity, entity2: DataEntity): boolean {\n return entity1.isAssociated(entity2.key)\n }\n\n /**\n * Tests whether this entity is somehow associated with another entity.\n * @param target The key of the target entity to test for association with.\n * @returns true if this entity has any association to the `target` entity.\n */\n isAssociated(target: string): boolean {\n const it = this.associationPath(target)\n const path = it.next().value\n return !!path\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n * @param toEntity The key to the target entity\n * @yields The path containing keys of entities from this entity to the `toEntity`\n * (inclusive) and all entities in between.\n */\n *associationPath(toEntity: string): Generator<string[]> {\n const graph = this.root.associationGraph()\n for (const path of this.root.associationPath(this.key, toEntity, graph)) {\n yield path\n }\n }\n\n /**\n * Returns a list of entities that are associated with this entity as a target.\n *\n * This method identifies entities that have an association where this entity is a target.\n * In other words, it finds entities that \"point to\" this entity through an association.\n *\n * For example, consider the following relationships:\n *\n * ```plain\n * A -> B (A has an association that targets B)\n * C -> B (C has an association that targets B)\n * B -> D (B has an association that targets D)\n *\n * Calling `getRelatedEntities()` on B would return [A, C]\n * Calling `getRelatedEntities()` on D would return [B]\n * Calling `getRelatedEntities()` on A would return []\n * ```\n *\n * Note, this method only returns entities that are directly associated with this entity as a target.\n * It does not traverse the association graph to find indirectly related entities.\n *\n * @returns An array of `DataEntity` instances that have an association targeting this entity.\n */\n getRelatedEntities(): DataEntity[] {\n const { key, root } = this\n const result = DataEntity.getRelatedEntities(root, key)\n root.foreign.forEach((ns) => {\n const other = DataEntity.getRelatedEntities(ns, key)\n other.forEach((entity) => {\n if (!result.includes(entity)) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n static getRelatedEntities(namespace: DataNamespace, entityKey: string): DataEntity[] {\n const result: DataEntity[] = []\n const inverse = namespace.definitions.associations.filter((i) => i.targets.some((j) => j.key === entityKey))\n inverse.forEach((assoc) => {\n const entity = namespace.definitions.entities.find((e) => e.associations.includes(assoc))\n if (entity && !result.includes(entity)) {\n result.push(entity)\n }\n })\n return result\n }\n\n /**\n * Creates breadcrumbs from this entity to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.name || 'Unnamed entity',\n kind: DataEntityKind,\n })\n const model = this.getParentInstance()\n if (model) {\n result.push({\n key: model.key,\n kind: model.kind,\n name: model.info.name || 'Unnamed data model',\n })\n let parent = model.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.name || 'Unnamed namespace',\n })\n parent = parent.getParentInstance()\n }\n }\n result.push({\n key: this.root.key,\n name: this.root.info.name || 'Unnamed namespace',\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.\n *\n * Note, it does nothing when the tag is already defined.\n *\n * @param tag The tag to add.\n */\n addTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n if (tags.some((t) => t.toLowerCase() === lower)) {\n return\n }\n tags.push(tag)\n const { definitions } = this.root\n if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {\n definitions.tags.push(tag)\n }\n }\n\n /**\n * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.\n *\n * @param tag The tag to remove.\n */\n removeTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n const index = tags.findIndex((t) => t.toLowerCase() === lower)\n if (index >= 0) {\n tags.splice(index, 1)\n }\n }\n\n /**\n * Creates a 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(): IShapeUnion {\n const serializer = new AmfShapeGenerator()\n return serializer.entity(this)\n }\n\n /**\n * Reads the schema of the Entity and generates an example for it.\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n const shape = this.toApiShape()\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: typeof opts.renderExamples === 'boolean' ? opts.renderExamples : true,\n renderMocked: typeof opts.renderMocked === 'boolean' ? opts.renderMocked : true,\n renderOptional: typeof opts.renderOptional === 'boolean' ? opts.renderOptional : true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n hasClosedCycle(rootEntity: string, targetEntity: string): boolean {\n if (targetEntity === this.key) {\n // self association\n return true\n }\n const g = this.root.associationGraph()\n const selfPaths: string[][] = []\n const targetPaths: string[][] = []\n for (const path of this.root.associationPath(rootEntity, this.key, g)) {\n selfPaths.push(path)\n }\n for (const path of this.root.associationPath(targetEntity, this.key, g)) {\n targetPaths.push(path)\n }\n const checker = (arr: string[], target: string[]): boolean => target.every((v) => arr.includes(v))\n for (const sp of selfPaths) {\n for (const tp of targetPaths) {\n const result = checker(sp, tp)\n if (result) {\n return result\n }\n }\n }\n return false\n }\n}\n"]}
|
|
@@ -73,9 +73,13 @@ export declare class DataModel {
|
|
|
73
73
|
*/
|
|
74
74
|
addEntity(init: string | DataEntity | IDataEntity): DataEntity;
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* @deprecated Use the `getParentInstance()` method instead.
|
|
77
77
|
*/
|
|
78
78
|
getParent(): DataNamespace | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the parent namespace where this data model exist.
|
|
81
|
+
*/
|
|
82
|
+
getParentInstance(): DataNamespace | undefined;
|
|
79
83
|
/**
|
|
80
84
|
* Creates breadcrumbs from this data model to the root namespace.
|
|
81
85
|
*/
|