@api-client/core 0.11.9 → 0.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/modeling/DataEntity.d.ts +1 -1
- package/build/src/modeling/DataEntity.js +1 -1
- package/build/src/modeling/DataEntity.js.map +1 -1
- package/build/src/modeling/DataNamespace.d.ts +10 -2
- package/build/src/modeling/DataNamespace.d.ts.map +1 -1
- package/build/src/modeling/DataNamespace.js +34 -6
- package/build/src/modeling/DataNamespace.js.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +5 -3
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/data/models/example-generator-api.json +9 -9
- package/package.json +1 -1
- package/src/modeling/DataEntity.ts +1 -1
- package/src/modeling/DataNamespace.ts +41 -6
- package/src/modeling/DomainImpactAnalysis.ts +5 -3
- package/tests/unit/modeling/impact_analysis.spec.ts +12 -12
|
@@ -213,7 +213,7 @@ export declare class DataEntity {
|
|
|
213
213
|
/**
|
|
214
214
|
* Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all
|
|
215
215
|
* parents in the inheritance chain in no particular order.
|
|
216
|
-
* @param recursive Whether to include parent parents as well.
|
|
216
|
+
* @param recursive Whether to include parent's parents as well.
|
|
217
217
|
*/
|
|
218
218
|
getComputedParents(recursive?: boolean): DataEntity[];
|
|
219
219
|
/**
|
|
@@ -413,7 +413,7 @@ export class DataEntity {
|
|
|
413
413
|
/**
|
|
414
414
|
* Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all
|
|
415
415
|
* parents in the inheritance chain in no particular order.
|
|
416
|
-
* @param recursive Whether to include parent parents as well.
|
|
416
|
+
* @param recursive Whether to include parent's parents as well.
|
|
417
417
|
*/
|
|
418
418
|
getComputedParents(recursive) {
|
|
419
419
|
const { entities } = this.root.definitions;
|
|
@@ -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B,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,MAAM,CAAA;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAW;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,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'\nimport type { DataDomainRemoveOptions } from './types.js'\n\ninterface OrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'property' | 'association'\n /**\n * The key of the ordered item.\n */\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 * This is the association-out (out-edge) direction.\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(opts: DataDomainRemoveOptions = {}): void {\n const { key, properties, associations, root } = this\n // check if some entity has reference to this entity as a target\n const toEdges = this.root.definitions.associations.filter((a) => a.targets.some((t) => t.key === this.key))\n if (toEdges.length > 0) {\n const result = toEdges.reduce<{ entity: DataEntity; association: DataAssociation }[]>((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, association })\n }\n return acc\n }, [])\n if (opts.force) {\n // remove the association from the entity\n result.forEach(({ entity: item, association }) => {\n item.removeAssociation(association.key)\n })\n } else {\n const entitiesNames = result.map(({ entity }) => entity.info.renderLabel || entity.key)\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.renderLabel} because it is used as a target in associations in entities: ${entitiesNames.join(', ')}.`\n )\n }\n }\n\n const children = this.getComputedChildren()\n if (children.length > 0) {\n if (opts.force) {\n children.forEach((child) => {\n child.parents = child.parents.filter((i) => i !== this.key)\n })\n } else {\n const childrenNames = children.map((i) => i.info.renderLabel || i.key)\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.renderLabel} because it is a parent for the following entities: ${childrenNames.join(', ')}.`\n )\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 collides 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: 'unique',\n },\n ],\n { message }\n )\n }\n this.parents.push(key)\n return this\n }\n\n /**\n * Removes a parent reference from this entity.\n * It keeps the parent as is.\n *\n * @param key The key of the parent entity to remove.\n * @throws ValidationError when the parent is not found.\n * @returns Self for chaining.\n */\n removeParent(key: string): this {\n const index = this.parents.findIndex((i) => i === key)\n if (index < 0) {\n const message = `Parent ${key} not found.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'not-found',\n },\n ],\n { message }\n )\n }\n this.parents.splice(index, 1)\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 /**\n * Checks whether the entity is a child of the given namespace or data model.\n * The relationship doesn't have to be direct, as long as the entity is in the hierarchy it will return true.\n *\n * @param key The key of the parent to check.\n * @returns True if this entity is a child of the given namespace or data model.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\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,oB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E,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,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'\nimport type { DataDomainRemoveOptions } from './types.js'\n\ninterface OrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'property' | 'association'\n /**\n * The key of the ordered item.\n */\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's 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 * This is the association-out (out-edge) direction.\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(opts: DataDomainRemoveOptions = {}): void {\n const { key, properties, associations, root } = this\n // check if some entity has reference to this entity as a target\n const toEdges = this.root.definitions.associations.filter((a) => a.targets.some((t) => t.key === this.key))\n if (toEdges.length > 0) {\n const result = toEdges.reduce<{ entity: DataEntity; association: DataAssociation }[]>((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, association })\n }\n return acc\n }, [])\n if (opts.force) {\n // remove the association from the entity\n result.forEach(({ entity: item, association }) => {\n item.removeAssociation(association.key)\n })\n } else {\n const entitiesNames = result.map(({ entity }) => entity.info.renderLabel || entity.key)\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.renderLabel} because it is used as a target in associations in entities: ${entitiesNames.join(', ')}.`\n )\n }\n }\n\n const children = this.getComputedChildren()\n if (children.length > 0) {\n if (opts.force) {\n children.forEach((child) => {\n child.parents = child.parents.filter((i) => i !== this.key)\n })\n } else {\n const childrenNames = children.map((i) => i.info.renderLabel || i.key)\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.renderLabel} because it is a parent for the following entities: ${childrenNames.join(', ')}.`\n )\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 collides 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: 'unique',\n },\n ],\n { message }\n )\n }\n this.parents.push(key)\n return this\n }\n\n /**\n * Removes a parent reference from this entity.\n * It keeps the parent as is.\n *\n * @param key The key of the parent entity to remove.\n * @throws ValidationError when the parent is not found.\n * @returns Self for chaining.\n */\n removeParent(key: string): this {\n const index = this.parents.findIndex((i) => i === key)\n if (index < 0) {\n const message = `Parent ${key} not found.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'not-found',\n },\n ],\n { message }\n )\n }\n this.parents.splice(index, 1)\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 /**\n * Checks whether the entity is a child of the given namespace or data model.\n * The relationship doesn't have to be direct, as long as the entity is in the hierarchy it will return true.\n *\n * @param key The key of the parent to check.\n * @returns True if this entity is a child of the given namespace or data model.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
|
|
@@ -216,7 +216,7 @@ export declare class DataNamespace {
|
|
|
216
216
|
* Finds a namespace and calls the `remove()` on it.
|
|
217
217
|
* @param key The key of the namespace to find.
|
|
218
218
|
*/
|
|
219
|
-
removeNamespace(key: string): void;
|
|
219
|
+
removeNamespace(key: string, opts?: DataDomainRemoveOptions): void;
|
|
220
220
|
/**
|
|
221
221
|
* Adds a data model to a namespace.
|
|
222
222
|
* @param init The name of the data model to add, data model's schema, or its instance.
|
|
@@ -229,11 +229,19 @@ export declare class DataNamespace {
|
|
|
229
229
|
* @returns The data model definition or undefined when not found.
|
|
230
230
|
*/
|
|
231
231
|
findDataModel(key: string): DataModel | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* A convenience function to remove an object from the namespace.
|
|
234
|
+
* @param key The key of the object to remove.
|
|
235
|
+
* @param kind The kind of the object to remove.
|
|
236
|
+
* @param opts The options for the removal.
|
|
237
|
+
* @throws Error when the kind is not known.
|
|
238
|
+
*/
|
|
239
|
+
removeObject(key: string, kind: string, opts?: DataDomainRemoveOptions): void;
|
|
232
240
|
/**
|
|
233
241
|
* Finds a data model and calls the `remove()` on it.
|
|
234
242
|
* @param key The key of the data model to find.
|
|
235
243
|
*/
|
|
236
|
-
removeDataModel(key: string): void;
|
|
244
|
+
removeDataModel(key: string, opts?: DataDomainRemoveOptions): void;
|
|
237
245
|
/**
|
|
238
246
|
* @returns The graph of associations where keys are the source
|
|
239
247
|
* entities and the value is the list of all target entities.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataNamespace.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataNamespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"DataNamespace.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataNamespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EACL,iBAAiB,EACjB,aAAa,EAId,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,uBAAu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import { DataModel } from './DataModel.js';
|
|
6
6
|
import { DataProperty } from './DataProperty.js';
|
|
7
|
-
import { DataNamespaceKind, DataModelKind } from '../models/kinds.js';
|
|
7
|
+
import { DataNamespaceKind, DataModelKind, DataEntityKind, DataPropertyKind, DataAssociationKind, } from '../models/kinds.js';
|
|
8
8
|
import v4 from '../lib/uuid.js';
|
|
9
9
|
export class DataItem {
|
|
10
10
|
kind = DataModelKind;
|
|
@@ -364,7 +364,7 @@ export class DataNamespace {
|
|
|
364
364
|
addNamespace(init, parent) {
|
|
365
365
|
let root;
|
|
366
366
|
if (parent) {
|
|
367
|
-
const rootCandidate = this.
|
|
367
|
+
const rootCandidate = this.findNamespace(parent);
|
|
368
368
|
if (!rootCandidate) {
|
|
369
369
|
throw new Error(`Unable to find the parent namespace ${parent}`);
|
|
370
370
|
}
|
|
@@ -487,7 +487,7 @@ export class DataNamespace {
|
|
|
487
487
|
* Finds a namespace and calls the `remove()` on it.
|
|
488
488
|
* @param key The key of the namespace to find.
|
|
489
489
|
*/
|
|
490
|
-
removeNamespace(key) {
|
|
490
|
+
removeNamespace(key, opts) {
|
|
491
491
|
const root = this.root || this;
|
|
492
492
|
if (root.key === key) {
|
|
493
493
|
throw new Error(`Unable to remove the root namespace this way.`);
|
|
@@ -495,7 +495,7 @@ export class DataNamespace {
|
|
|
495
495
|
const { definitions } = root;
|
|
496
496
|
const ns = definitions.namespaces.find((i) => i.key === key);
|
|
497
497
|
if (ns) {
|
|
498
|
-
ns.remove();
|
|
498
|
+
ns.remove(opts);
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
@@ -543,15 +543,43 @@ export class DataNamespace {
|
|
|
543
543
|
const { definitions } = this.root || this;
|
|
544
544
|
return definitions.models.find((i) => i.key === key);
|
|
545
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* A convenience function to remove an object from the namespace.
|
|
548
|
+
* @param key The key of the object to remove.
|
|
549
|
+
* @param kind The kind of the object to remove.
|
|
550
|
+
* @param opts The options for the removal.
|
|
551
|
+
* @throws Error when the kind is not known.
|
|
552
|
+
*/
|
|
553
|
+
removeObject(key, kind, opts) {
|
|
554
|
+
switch (kind) {
|
|
555
|
+
case DataNamespaceKind:
|
|
556
|
+
this.findNamespace(key)?.remove(opts);
|
|
557
|
+
break;
|
|
558
|
+
case DataModelKind:
|
|
559
|
+
this.findDataModel(key)?.remove(opts);
|
|
560
|
+
break;
|
|
561
|
+
case DataEntityKind:
|
|
562
|
+
this.findEntity(key)?.remove(opts);
|
|
563
|
+
break;
|
|
564
|
+
case DataPropertyKind:
|
|
565
|
+
this.findProperty(key)?.remove();
|
|
566
|
+
break;
|
|
567
|
+
case DataAssociationKind:
|
|
568
|
+
this.findAssociation(key)?.remove();
|
|
569
|
+
break;
|
|
570
|
+
default:
|
|
571
|
+
throw new Error(`Unknown kind ${kind} for the object ${key}.`);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
546
574
|
/**
|
|
547
575
|
* Finds a data model and calls the `remove()` on it.
|
|
548
576
|
* @param key The key of the data model to find.
|
|
549
577
|
*/
|
|
550
|
-
removeDataModel(key) {
|
|
578
|
+
removeDataModel(key, opts) {
|
|
551
579
|
const { definitions } = this.root || this;
|
|
552
580
|
const model = definitions.models.find((i) => i.key === key);
|
|
553
581
|
if (model) {
|
|
554
|
-
model.remove();
|
|
582
|
+
model.remove(opts);
|
|
555
583
|
}
|
|
556
584
|
}
|
|
557
585
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataNamespace.js","sourceRoot":"","sources":["../../../src/modeling/DataNamespace.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAoB,eAAe,EAAqB,MAAM,sBAAsB,CAAA;AAC3F,OAAO,EAAe,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAc,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OA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C,EAAE,CAAC,CAAA;IACvB,CAAC;IAED,aAAa,CAAC,EAAiB;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;QACrD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,GAAW;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;IAChD,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAW;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\nimport { IThing, Thing } from '../models/Thing.js'\nimport { IDataAssociation, DataAssociation, AssociationTarget } from './DataAssociation.js'\nimport { IDataEntity, DataEntity } from './DataEntity.js'\nimport { IDataModel, DataModel } from './DataModel.js'\nimport { IDataProperty, DataProperty } from './DataProperty.js'\nimport { DataNamespaceKind, DataModelKind } from '../models/kinds.js'\nimport v4 from '../lib/uuid.js'\nimport type { DataDomainRemoveOptions } from './types.js'\n\ntype ItemKind = typeof DataNamespaceKind | typeof DataModelKind\n\nexport interface DataItemAdaptingOptions {\n /**\n * The index at which to adapt the item.\n */\n index?: number\n}\n\ninterface IDataDefinitions {\n models?: IDataModel[]\n entities?: IDataEntity[]\n properties?: IDataProperty[]\n associations?: IDataAssociation[]\n namespaces?: IDataNamespace[]\n tags?: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\ninterface DataDefinitions {\n models: DataModel[]\n // @todo: This should be a map of entities with a key of the entity key.\n entities: DataEntity[]\n // @todo: This should be a map of properties with a key of the property key.\n properties: DataProperty[]\n // @todo: This should be a map of associations with a key of the association key.\n associations: DataAssociation[]\n namespaces: DataNamespace[]\n /**\n * Common for the entire root namespace tags.\n * These are kept separately so the UI can generate autocomplete for tags.\n */\n tags: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\n/**\n * Data definition for a foreign namespace.\n * Each foreign namespace is resolved to a specific version.\n * This makes sure that the local data are always referencing an existing\n * entity as breaking changes should be resolved when upgrading a version.\n */\ninterface ForeignNamespace {\n key: string\n version: string\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n */\nexport interface IDataNamespace {\n kind: typeof DataNamespaceKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The ordered list of items in this namespace.\n */\n items: IDataItem[]\n /**\n * The data namespace description.\n */\n info: IThing\n /**\n * The list of definitions used in the namespace.\n */\n definitions: IDataDefinitions\n}\n\n/**\n * Data item is a reference to an object in the top namespace definitions\n * to the namespace items.\n */\nexport interface IDataItem {\n /**\n * The kind of the item.\n */\n kind: ItemKind\n /**\n * The identifier in the `definitions` array of the namespace.\n */\n key: string\n}\n\nexport class DataItem implements IDataItem {\n kind: ItemKind = DataModelKind\n\n key = ''\n\n /**\n * A reference to the top level namespace.\n */\n private root: DataNamespace\n\n static isDataItem(input: unknown): boolean {\n const typed = input as IDataItem\n if (!input || ![DataModelKind, DataNamespaceKind].includes(typed.kind)) {\n return false\n }\n return true\n }\n\n static dataNamespace(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataNamespaceKind,\n key,\n })\n return item\n }\n\n static dataModel(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataModelKind,\n key,\n })\n return item\n }\n\n /**\n * @param root The top-most data namespace.\n * @param input The project item definition used to restore the state.\n */\n constructor(root: DataNamespace, input: string | IDataItem) {\n this.root = root\n let init: IDataItem\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n throw new Error('Specify the type of the item.')\n }\n this.new(init)\n }\n\n new(init: IDataItem): void {\n if (!DataItem.isDataItem(init)) {\n throw new Error(`Not a data item.`)\n }\n const { kind, key } = init\n this.kind = kind\n this.key = key\n }\n\n toJSON(): IDataItem {\n const result: IDataItem = {\n kind: this.kind,\n key: this.key,\n }\n return result\n }\n\n getItem(): DataNamespace | DataModel | undefined {\n const { root, key, kind } = this\n const { definitions } = root\n if (kind === DataModelKind) {\n return definitions.models.find((i) => i.key === key)\n }\n if (kind === kind) {\n return definitions.namespaces.find((i) => i.key === key)\n }\n }\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n */\nexport class DataNamespace {\n kind = DataNamespaceKind\n\n key = ''\n\n /**\n * The ordered list of items in this namespace.\n */\n items: DataItem[] = []\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * When a namespace is a sub-namespace this is the reference to the\n * root namespace with all definitions.\n */\n root?: DataNamespace\n /**\n * The list of definitions used in the namespace.\n */\n definitions: DataDefinitions\n\n /**\n * The list of foreign namespaces.\n * This is used to find entities from foreign namespaces.\n * Values here are treated as read only (objects can be frozen).\n *\n * This should be set by the application and the namespace will do\n * nothing to populate this value.\n */\n foreign: DataNamespace[] = []\n\n /**\n * Creates a new data namespace from a name.\n * @param name The name to set.\n */\n static fromName(name: string, root?: DataNamespace): DataNamespace {\n const ns = new DataNamespace(undefined, root)\n const info = Thing.fromName(name)\n ns.info = info\n return ns\n }\n\n /**\n * @deprecated\n */\n static definitions(): DataDefinitions {\n return {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n }\n\n constructor(input?: string | IDataNamespace, root?: DataNamespace) {\n this.root = root\n this.definitions = {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n\n let init: IDataNamespace\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n if (!init.kind) {\n init.kind = DataNamespaceKind\n }\n } else {\n init = {\n kind: DataNamespaceKind,\n key: v4(),\n definitions: {},\n items: [],\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataNamespace): void {\n if (!init || !init.definitions || !init.items) {\n throw new Error(`Not a data namespace.`)\n }\n const { key = v4(), definitions = {}, items, info } = init\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(items)) {\n this.items = items.map((i) => new DataItem(this, i))\n } else {\n this.items = []\n }\n if (Array.isArray(definitions.associations)) {\n this.definitions.associations = definitions.associations.map((i) => new DataAssociation(this, i))\n } else {\n this.definitions.associations = []\n }\n if (Array.isArray(definitions.properties)) {\n this.definitions.properties = definitions.properties.map((i) => new DataProperty(this, i))\n } else {\n this.definitions.properties = []\n }\n // note, entities must be restored after properties / associations\n if (Array.isArray(definitions.entities)) {\n this.definitions.entities = definitions.entities.map((i) => new DataEntity(this, i))\n } else {\n this.definitions.entities = []\n }\n // must be set after entities.\n if (Array.isArray(definitions.models)) {\n this.definitions.models = definitions.models.map((i) => new DataModel(this, i))\n } else {\n this.definitions.models = []\n }\n if (Array.isArray(definitions.namespaces)) {\n this.definitions.namespaces = definitions.namespaces.map((i) => new DataNamespace(i, this))\n } else {\n this.definitions.namespaces = []\n }\n if (Array.isArray(definitions.tags)) {\n this.definitions.tags = [...definitions.tags]\n } else {\n this.definitions.tags = []\n }\n }\n\n toJSON(): IDataNamespace {\n const result: IDataNamespace = {\n key: this.key,\n kind: DataNamespaceKind,\n info: this.info.toJSON(),\n items: this.items.map((i) => i.toJSON()),\n definitions: {},\n }\n const { associations, entities, models, namespaces, properties, tags } = this.definitions\n if (Array.isArray(associations) && associations.length) {\n result.definitions.associations = associations.map((i) => i.toJSON())\n }\n if (Array.isArray(entities) && entities.length) {\n result.definitions.entities = entities.map((i) => i.toJSON())\n }\n if (Array.isArray(models) && models.length) {\n result.definitions.models = models.map((i) => i.toJSON())\n }\n if (Array.isArray(namespaces) && namespaces.length) {\n result.definitions.namespaces = namespaces.map((i) => i.toJSON())\n }\n if (Array.isArray(properties) && properties.length) {\n result.definitions.properties = properties.map((i) => i.toJSON())\n }\n if (Array.isArray(tags) && tags.length) {\n result.definitions.tags = [...tags]\n }\n return result\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n getParent(): DataNamespace | undefined {\n return this.getParentInstance()\n }\n\n /**\n * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.\n */\n getParentInstance(): DataNamespace | undefined {\n const { root, key } = this\n if (root) {\n return root.findParent(key)\n }\n // we are the root namespace.\n return undefined\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listNamespaces(): DataNamespace[] {\n const result: DataNamespace[] = []\n const { items } = this\n const root = this.getRoot()\n const { namespaces } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataNamespaceKind) {\n return\n }\n const def = namespaces.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listDataModels(): DataModel[] {\n const result: DataModel[] = []\n const { items } = this\n const root = this.getRoot()\n const { models } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataModelKind) {\n return\n }\n const def = models.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * @returns The root of the namespaces tree. It might be the same object.\n */\n getRoot(): DataNamespace {\n if (this.root) {\n return this.root\n }\n return this as unknown as DataNamespace\n }\n\n /**\n * Removes self from the parent namespace with all data models.\n * This does noting for the root namespace.\n */\n remove(opts?: DataDomainRemoveOptions): void {\n const { root } = this\n if (!root) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const models = this.listDataModels()\n const children = this.listNamespaces()\n models.forEach((m) => m.remove(opts))\n children.forEach((c) => c.remove(opts))\n const index = root.definitions.namespaces.findIndex((i) => i.key === this.key)\n if (index >= 0) {\n root.definitions.namespaces.splice(index, 1)\n }\n }\n\n /**\n * Checks if this is the root namespace.\n * @returns True if this is the root namespace.\n */\n isRoot(): boolean {\n return this.root === undefined\n }\n\n /**\n * Finds a parent namespace for the given namespace.\n * @param key The namespace key to find the parent for.\n * @returns The parent namespace or undefined when the namespace does not exist. It may return the root namespace.\n */\n findParent(key: string): DataNamespace | undefined {\n const { definitions, items = [] } = this\n const rootIndex = items.findIndex((i) => i.key === key)\n if (rootIndex >= 0) {\n return this\n }\n const definition = definitions.namespaces.find((i) => i.items.some((item) => item.key === key))\n if (definition) {\n return definition\n }\n return undefined\n }\n\n /**\n * Adds a data namespace to the structure.\n * @param init The name of the namespace to add, namespace's schema, or instance.\n * @param parent The optional key of the parent namespace to add the new namespace to.\n */\n addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findParent(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataNamespace\n if (typeof init === 'string') {\n definition = DataNamespace.fromName(init, this.root || this)\n } else if (init instanceof DataNamespace) {\n definition = init\n } else {\n definition = new DataNamespace(init, this.root || this)\n }\n ;(this.root || this).definitions.namespaces.push(definition)\n const item = DataItem.dataNamespace(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Adapts an existing namespace to this namespace.\n * This will remove the namespace from the parent namespace and add it to this one.\n *\n * @param ns The namespace to adapt.\n * @param opts Adapting options.\n */\n adaptNamespace(ns: DataNamespace, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (ns === this) {\n throw new Error(`Unable to adapt a namespace that is self.`)\n }\n if (ns.root !== this.root) {\n throw new Error(`The namespace ${ns.key} is not in the same namespace as this data namespace.`)\n }\n if (ns.getParentInstance() === this) {\n throw new Error(`The namespace ${ns.key} is already adapted by this data namespace.`)\n }\n // Check for circular dependency\n let current: DataNamespace | undefined = this\n while (current) {\n if (current === ns) {\n throw new Error(`Unable to adapt namespace ${ns.key} under itself or one of its children.`)\n }\n current = current.getParentInstance()\n }\n const parent = ns.getParentInstance() || this.root\n if (!parent) {\n throw new Error(`The namespace ${ns.key} has no parent.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.items.findIndex((i) => i.key === ns.key)\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Adapts an existing data model to this namespace.\n * This will remove the data model from the parent namespace and add it to this one.\n * @param model The data model to adapt.\n * @param opts The adapting options.\n */\n adaptDataModel(model: DataModel, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (model.root !== this.root) {\n throw new Error(`The data model ${model.key} is not in the same namespace as this data namespace.`)\n }\n const parent = model.getParentInstance()\n if (!parent) {\n throw new Error(`The data model ${model.key} has no parent.`)\n }\n if (parent === this) {\n throw new Error(`The data model ${model.key} is already adapted by this data namespace.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.items.findIndex((i) => i.key === model.key)\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Finds a namespace in the definitions.\n * @param key The key of the namespace to find.\n * @returns The namespace definition or undefined when not found.\n */\n findNamespace(key: string): DataNamespace | undefined {\n const { definitions } = this.root || this\n return definitions.namespaces.find((i) => i.key === key)\n }\n\n /**\n * Finds a namespace and calls the `remove()` on it.\n * @param key The key of the namespace to find.\n */\n removeNamespace(key: string): void {\n const root = this.root || this\n if (root.key === key) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const { definitions } = root\n const ns = definitions.namespaces.find((i) => i.key === key)\n if (ns) {\n ns.remove()\n }\n }\n\n /**\n * Adds a data model to a namespace.\n * @param init The name of the data model to add, data model's schema, or its instance.\n * @param parent The optional key of the parent namespace to add the new data model to.\n */\n addDataModel(init: string | IDataModel | DataModel, parent?: string): DataModel {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataModel\n if (typeof init === 'string') {\n definition = DataModel.fromName(this.root || this, init)\n } else if (init instanceof DataModel) {\n definition = init\n } else {\n definition = new DataModel(this.root || this, init)\n }\n ;(this.root || this).definitions.models.push(definition)\n const item = DataItem.dataModel(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Finds a data model in the definitions.\n * @param key The key of the data model to find.\n * @returns The data model definition or undefined when not found.\n */\n findDataModel(key: string): DataModel | undefined {\n const { definitions } = this.root || this\n return definitions.models.find((i) => i.key === key)\n }\n\n /**\n * Finds a data model and calls the `remove()` on it.\n * @param key The key of the data model to find.\n */\n removeDataModel(key: string): void {\n const { definitions } = this.root || this\n const model = definitions.models.find((i) => i.key === key)\n if (model) {\n model.remove()\n }\n }\n\n /**\n * @returns The graph of associations where keys are the source\n * entities and the value is the list of all target entities.\n */\n associationGraph(): Record<string, string[]> {\n const graph: Record<string, string[]> = {}\n const { definitions } = this.root || this\n const { associations, entities } = definitions\n for (const assoc of associations) {\n if (!assoc.targets.length) {\n continue\n }\n const srcEntity = entities.find((i) => i.associations.some((a) => a === assoc))\n if (!srcEntity) {\n continue\n }\n if (!graph[srcEntity.key]) {\n graph[srcEntity.key] = []\n }\n const targetIds = assoc.targets.map((i) => i.key)\n graph[srcEntity.key].splice(0, 0, ...targetIds)\n }\n return graph\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n *\n * @param from The key of the from entity\n * @param to The key of the target entity\n * @param g The graph generated with `associationGraph()`\n * @param path The current list of entity ids. Do not set this, it is for the recursive processing of the graph.\n * @param visited The list of visited paths to avoid cycles.\n * Do not set this, it is for the recursive processing of the graph.\n */\n *associationPath(\n from: string,\n to: string,\n g: Record<string, string[]>,\n path: string[] = [],\n visited = new Set<string>()\n ): Generator<string[]> {\n if (from === to) {\n yield path.concat(to)\n return\n }\n if (visited.has(from)) {\n // it's a cycle\n return\n }\n if (g[from]) {\n visited.add(from)\n path.push(from)\n\n for (const neighbor of g[from]) {\n yield* this.associationPath(neighbor, to, g, path, visited)\n }\n\n visited.delete(from)\n path.pop()\n }\n }\n\n /**\n * Scans all associations for foreign namespaces and returns\n * the list of all namespaces used in the association graph.\n * This will never add this namespace's key.\n *\n * This function should be used to read keys for all related\n * namespaces through associations.\n *\n * @returns All keys of foreign namespaces.\n */\n computeForeignNamespaceKeys(): string[] {\n const result: string[] = []\n const { associations = [] } = this.definitions\n associations.forEach((association) => {\n const { targets = [] } = association\n targets.forEach((target) => {\n const { namespace } = target\n if (!namespace || namespace === this.key) {\n return\n }\n result.push(namespace)\n })\n })\n return result\n }\n\n /**\n * Finds an entity in this namespace.\n * @param key The key of the entity to find.\n */\n findEntity(key: string): DataEntity | undefined {\n const { definitions } = this.root || this\n return definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Finds a property by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findProperty(key: string): DataProperty | undefined {\n const { definitions } = this.root || this\n return definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Finds an association by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findAssociation(key: string): DataAssociation | undefined {\n const { definitions } = this.root || this\n return definitions.associations.find((i) => i.key === key)\n }\n\n /**\n * Searches for entities for association targets.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param targets The list of targets\n * @returns A list of entities. An `undefined` is put at the index where an entity cannot be found\n */\n findAssociatedEntities(targets: AssociationTarget[]): (DataEntity | undefined)[] {\n const result: (DataEntity | undefined)[] = []\n targets.forEach((target) => {\n let ns: DataNamespace | undefined\n if (target.namespace) {\n ns = this.foreign.find((i) => i.key === target.namespace)\n } else {\n ns = this\n }\n if (!ns) {\n result.push(undefined)\n return\n }\n const entity = ns.findEntity(target.key)\n if (entity) {\n result.push(entity)\n } else {\n result.push(undefined)\n }\n })\n return result\n }\n\n /**\n * Finds an associated entity in the current or foreign namespace.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param key The key of the entity to find.\n * @param namespace The optional namespace to search in.\n * If not set, the current namespace is used.\n * This is used to find entities in foreign namespaces.\n * @returns The entity or undefined if not found.\n */\n findAssociatedEntity(key: string, namespace?: string): DataEntity | undefined {\n let ns: DataNamespace | undefined\n if (namespace) {\n ns = this.foreign.find((i) => i.key === namespace)\n } else {\n ns = this\n }\n if (!ns) {\n return undefined\n }\n return ns.findEntity(key)\n }\n\n addForeign(ns: DataNamespace): void {\n const exists = this.foreign.some((i) => i.key === ns.key)\n if (exists) {\n return\n }\n this.foreign.push(ns)\n }\n\n removeForeign(ns: DataNamespace): void {\n const index = this.foreign.findIndex((i) => i === ns)\n if (index >= 0) {\n this.foreign.splice(index, 1)\n }\n }\n\n hasForeignNamespace(key: string): boolean {\n return this.foreign.some((i) => i.key === key)\n }\n\n /**\n * Checks whether the namespace is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this namespace is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataNamespace.js","sourceRoot":"","sources":["../../../src/modeling/DataNamespace.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAoB,eAAe,EAAqB,MAAM,sBAAsB,CAAA;AAC3F,OAAO,EAAe,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAc,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAiB,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,MAAM,gBAAgB,CAAA;AA8F/B,MAAM,OAAO,QAAQ;IACnB,IAAI,GAAa,aAAa,CAAA;IAE9B,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACK,IAAI,CAAe;IAE3B,MAAM,CAAC,UAAU,CAAC,KAAc;QAC9B,MAAM,KAAK,GAAG,KAAkB,CAAA;QAChC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACvE,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,IAAmB,EAAE,GAAW;QACnD,MAAM,IA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AAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;QACzD,IAAI,MAAM,EAAE,CAAC;YACX,OAAM;QACR,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACvB,CAAC;IAED,aAAa,CAAC,EAAiB;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;QACrD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,GAAW;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;IAChD,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAW;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\nimport { IThing, Thing } from '../models/Thing.js'\nimport { IDataAssociation, DataAssociation, AssociationTarget } from './DataAssociation.js'\nimport { IDataEntity, DataEntity } from './DataEntity.js'\nimport { IDataModel, DataModel } from './DataModel.js'\nimport { IDataProperty, DataProperty } from './DataProperty.js'\nimport {\n DataNamespaceKind,\n DataModelKind,\n DataEntityKind,\n DataPropertyKind,\n DataAssociationKind,\n} from '../models/kinds.js'\nimport v4 from '../lib/uuid.js'\nimport type { DataDomainRemoveOptions } from './types.js'\n\ntype ItemKind = typeof DataNamespaceKind | typeof DataModelKind\n\nexport interface DataItemAdaptingOptions {\n /**\n * The index at which to adapt the item.\n */\n index?: number\n}\n\ninterface IDataDefinitions {\n models?: IDataModel[]\n entities?: IDataEntity[]\n properties?: IDataProperty[]\n associations?: IDataAssociation[]\n namespaces?: IDataNamespace[]\n tags?: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\ninterface DataDefinitions {\n models: DataModel[]\n // @todo: This should be a map of entities with a key of the entity key.\n entities: DataEntity[]\n // @todo: This should be a map of properties with a key of the property key.\n properties: DataProperty[]\n // @todo: This should be a map of associations with a key of the association key.\n associations: DataAssociation[]\n namespaces: DataNamespace[]\n /**\n * Common for the entire root namespace tags.\n * These are kept separately so the UI can generate autocomplete for tags.\n */\n tags: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\n/**\n * Data definition for a foreign namespace.\n * Each foreign namespace is resolved to a specific version.\n * This makes sure that the local data are always referencing an existing\n * entity as breaking changes should be resolved when upgrading a version.\n */\ninterface ForeignNamespace {\n key: string\n version: string\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n */\nexport interface IDataNamespace {\n kind: typeof DataNamespaceKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The ordered list of items in this namespace.\n */\n items: IDataItem[]\n /**\n * The data namespace description.\n */\n info: IThing\n /**\n * The list of definitions used in the namespace.\n */\n definitions: IDataDefinitions\n}\n\n/**\n * Data item is a reference to an object in the top namespace definitions\n * to the namespace items.\n */\nexport interface IDataItem {\n /**\n * The kind of the item.\n */\n kind: ItemKind\n /**\n * The identifier in the `definitions` array of the namespace.\n */\n key: string\n}\n\nexport class DataItem implements IDataItem {\n kind: ItemKind = DataModelKind\n\n key = ''\n\n /**\n * A reference to the top level namespace.\n */\n private root: DataNamespace\n\n static isDataItem(input: unknown): boolean {\n const typed = input as IDataItem\n if (!input || ![DataModelKind, DataNamespaceKind].includes(typed.kind)) {\n return false\n }\n return true\n }\n\n static dataNamespace(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataNamespaceKind,\n key,\n })\n return item\n }\n\n static dataModel(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataModelKind,\n key,\n })\n return item\n }\n\n /**\n * @param root The top-most data namespace.\n * @param input The project item definition used to restore the state.\n */\n constructor(root: DataNamespace, input: string | IDataItem) {\n this.root = root\n let init: IDataItem\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n throw new Error('Specify the type of the item.')\n }\n this.new(init)\n }\n\n new(init: IDataItem): void {\n if (!DataItem.isDataItem(init)) {\n throw new Error(`Not a data item.`)\n }\n const { kind, key } = init\n this.kind = kind\n this.key = key\n }\n\n toJSON(): IDataItem {\n const result: IDataItem = {\n kind: this.kind,\n key: this.key,\n }\n return result\n }\n\n getItem(): DataNamespace | DataModel | undefined {\n const { root, key, kind } = this\n const { definitions } = root\n if (kind === DataModelKind) {\n return definitions.models.find((i) => i.key === key)\n }\n if (kind === kind) {\n return definitions.namespaces.find((i) => i.key === key)\n }\n }\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n */\nexport class DataNamespace {\n kind = DataNamespaceKind\n\n key = ''\n\n /**\n * The ordered list of items in this namespace.\n */\n items: DataItem[] = []\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * When a namespace is a sub-namespace this is the reference to the\n * root namespace with all definitions.\n */\n root?: DataNamespace\n /**\n * The list of definitions used in the namespace.\n */\n definitions: DataDefinitions\n\n /**\n * The list of foreign namespaces.\n * This is used to find entities from foreign namespaces.\n * Values here are treated as read only (objects can be frozen).\n *\n * This should be set by the application and the namespace will do\n * nothing to populate this value.\n */\n foreign: DataNamespace[] = []\n\n /**\n * Creates a new data namespace from a name.\n * @param name The name to set.\n */\n static fromName(name: string, root?: DataNamespace): DataNamespace {\n const ns = new DataNamespace(undefined, root)\n const info = Thing.fromName(name)\n ns.info = info\n return ns\n }\n\n /**\n * @deprecated\n */\n static definitions(): DataDefinitions {\n return {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n }\n\n constructor(input?: string | IDataNamespace, root?: DataNamespace) {\n this.root = root\n this.definitions = {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n\n let init: IDataNamespace\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n if (!init.kind) {\n init.kind = DataNamespaceKind\n }\n } else {\n init = {\n kind: DataNamespaceKind,\n key: v4(),\n definitions: {},\n items: [],\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataNamespace): void {\n if (!init || !init.definitions || !init.items) {\n throw new Error(`Not a data namespace.`)\n }\n const { key = v4(), definitions = {}, items, info } = init\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(items)) {\n this.items = items.map((i) => new DataItem(this, i))\n } else {\n this.items = []\n }\n if (Array.isArray(definitions.associations)) {\n this.definitions.associations = definitions.associations.map((i) => new DataAssociation(this, i))\n } else {\n this.definitions.associations = []\n }\n if (Array.isArray(definitions.properties)) {\n this.definitions.properties = definitions.properties.map((i) => new DataProperty(this, i))\n } else {\n this.definitions.properties = []\n }\n // note, entities must be restored after properties / associations\n if (Array.isArray(definitions.entities)) {\n this.definitions.entities = definitions.entities.map((i) => new DataEntity(this, i))\n } else {\n this.definitions.entities = []\n }\n // must be set after entities.\n if (Array.isArray(definitions.models)) {\n this.definitions.models = definitions.models.map((i) => new DataModel(this, i))\n } else {\n this.definitions.models = []\n }\n if (Array.isArray(definitions.namespaces)) {\n this.definitions.namespaces = definitions.namespaces.map((i) => new DataNamespace(i, this))\n } else {\n this.definitions.namespaces = []\n }\n if (Array.isArray(definitions.tags)) {\n this.definitions.tags = [...definitions.tags]\n } else {\n this.definitions.tags = []\n }\n }\n\n toJSON(): IDataNamespace {\n const result: IDataNamespace = {\n key: this.key,\n kind: DataNamespaceKind,\n info: this.info.toJSON(),\n items: this.items.map((i) => i.toJSON()),\n definitions: {},\n }\n const { associations, entities, models, namespaces, properties, tags } = this.definitions\n if (Array.isArray(associations) && associations.length) {\n result.definitions.associations = associations.map((i) => i.toJSON())\n }\n if (Array.isArray(entities) && entities.length) {\n result.definitions.entities = entities.map((i) => i.toJSON())\n }\n if (Array.isArray(models) && models.length) {\n result.definitions.models = models.map((i) => i.toJSON())\n }\n if (Array.isArray(namespaces) && namespaces.length) {\n result.definitions.namespaces = namespaces.map((i) => i.toJSON())\n }\n if (Array.isArray(properties) && properties.length) {\n result.definitions.properties = properties.map((i) => i.toJSON())\n }\n if (Array.isArray(tags) && tags.length) {\n result.definitions.tags = [...tags]\n }\n return result\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n getParent(): DataNamespace | undefined {\n return this.getParentInstance()\n }\n\n /**\n * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.\n */\n getParentInstance(): DataNamespace | undefined {\n const { root, key } = this\n if (root) {\n return root.findParent(key)\n }\n // we are the root namespace.\n return undefined\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listNamespaces(): DataNamespace[] {\n const result: DataNamespace[] = []\n const { items } = this\n const root = this.getRoot()\n const { namespaces } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataNamespaceKind) {\n return\n }\n const def = namespaces.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listDataModels(): DataModel[] {\n const result: DataModel[] = []\n const { items } = this\n const root = this.getRoot()\n const { models } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataModelKind) {\n return\n }\n const def = models.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * @returns The root of the namespaces tree. It might be the same object.\n */\n getRoot(): DataNamespace {\n if (this.root) {\n return this.root\n }\n return this as unknown as DataNamespace\n }\n\n /**\n * Removes self from the parent namespace with all data models.\n * This does noting for the root namespace.\n */\n remove(opts?: DataDomainRemoveOptions): void {\n const { root } = this\n if (!root) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const models = this.listDataModels()\n const children = this.listNamespaces()\n models.forEach((m) => m.remove(opts))\n children.forEach((c) => c.remove(opts))\n const index = root.definitions.namespaces.findIndex((i) => i.key === this.key)\n if (index >= 0) {\n root.definitions.namespaces.splice(index, 1)\n }\n }\n\n /**\n * Checks if this is the root namespace.\n * @returns True if this is the root namespace.\n */\n isRoot(): boolean {\n return this.root === undefined\n }\n\n /**\n * Finds a parent namespace for the given namespace.\n * @param key The namespace key to find the parent for.\n * @returns The parent namespace or undefined when the namespace does not exist. It may return the root namespace.\n */\n findParent(key: string): DataNamespace | undefined {\n const { definitions, items = [] } = this\n const rootIndex = items.findIndex((i) => i.key === key)\n if (rootIndex >= 0) {\n return this\n }\n const definition = definitions.namespaces.find((i) => i.items.some((item) => item.key === key))\n if (definition) {\n return definition\n }\n return undefined\n }\n\n /**\n * Adds a data namespace to the structure.\n * @param init The name of the namespace to add, namespace's schema, or instance.\n * @param parent The optional key of the parent namespace to add the new namespace to.\n */\n addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataNamespace\n if (typeof init === 'string') {\n definition = DataNamespace.fromName(init, this.root || this)\n } else if (init instanceof DataNamespace) {\n definition = init\n } else {\n definition = new DataNamespace(init, this.root || this)\n }\n ;(this.root || this).definitions.namespaces.push(definition)\n const item = DataItem.dataNamespace(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Adapts an existing namespace to this namespace.\n * This will remove the namespace from the parent namespace and add it to this one.\n *\n * @param ns The namespace to adapt.\n * @param opts Adapting options.\n */\n adaptNamespace(ns: DataNamespace, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (ns === this) {\n throw new Error(`Unable to adapt a namespace that is self.`)\n }\n if (ns.root !== this.root) {\n throw new Error(`The namespace ${ns.key} is not in the same namespace as this data namespace.`)\n }\n if (ns.getParentInstance() === this) {\n throw new Error(`The namespace ${ns.key} is already adapted by this data namespace.`)\n }\n // Check for circular dependency\n let current: DataNamespace | undefined = this\n while (current) {\n if (current === ns) {\n throw new Error(`Unable to adapt namespace ${ns.key} under itself or one of its children.`)\n }\n current = current.getParentInstance()\n }\n const parent = ns.getParentInstance() || this.root\n if (!parent) {\n throw new Error(`The namespace ${ns.key} has no parent.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.items.findIndex((i) => i.key === ns.key)\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Adapts an existing data model to this namespace.\n * This will remove the data model from the parent namespace and add it to this one.\n * @param model The data model to adapt.\n * @param opts The adapting options.\n */\n adaptDataModel(model: DataModel, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (model.root !== this.root) {\n throw new Error(`The data model ${model.key} is not in the same namespace as this data namespace.`)\n }\n const parent = model.getParentInstance()\n if (!parent) {\n throw new Error(`The data model ${model.key} has no parent.`)\n }\n if (parent === this) {\n throw new Error(`The data model ${model.key} is already adapted by this data namespace.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.items.findIndex((i) => i.key === model.key)\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Finds a namespace in the definitions.\n * @param key The key of the namespace to find.\n * @returns The namespace definition or undefined when not found.\n */\n findNamespace(key: string): DataNamespace | undefined {\n const { definitions } = this.root || this\n return definitions.namespaces.find((i) => i.key === key)\n }\n\n /**\n * Finds a namespace and calls the `remove()` on it.\n * @param key The key of the namespace to find.\n */\n removeNamespace(key: string, opts?: DataDomainRemoveOptions): void {\n const root = this.root || this\n if (root.key === key) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const { definitions } = root\n const ns = definitions.namespaces.find((i) => i.key === key)\n if (ns) {\n ns.remove(opts)\n }\n }\n\n /**\n * Adds a data model to a namespace.\n * @param init The name of the data model to add, data model's schema, or its instance.\n * @param parent The optional key of the parent namespace to add the new data model to.\n */\n addDataModel(init: string | IDataModel | DataModel, parent?: string): DataModel {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataModel\n if (typeof init === 'string') {\n definition = DataModel.fromName(this.root || this, init)\n } else if (init instanceof DataModel) {\n definition = init\n } else {\n definition = new DataModel(this.root || this, init)\n }\n ;(this.root || this).definitions.models.push(definition)\n const item = DataItem.dataModel(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Finds a data model in the definitions.\n * @param key The key of the data model to find.\n * @returns The data model definition or undefined when not found.\n */\n findDataModel(key: string): DataModel | undefined {\n const { definitions } = this.root || this\n return definitions.models.find((i) => i.key === key)\n }\n\n /**\n * A convenience function to remove an object from the namespace.\n * @param key The key of the object to remove.\n * @param kind The kind of the object to remove.\n * @param opts The options for the removal.\n * @throws Error when the kind is not known.\n */\n removeObject(key: string, kind: string, opts?: DataDomainRemoveOptions): void {\n switch (kind) {\n case DataNamespaceKind:\n this.findNamespace(key)?.remove(opts)\n break\n case DataModelKind:\n this.findDataModel(key)?.remove(opts)\n break\n case DataEntityKind:\n this.findEntity(key)?.remove(opts)\n break\n case DataPropertyKind:\n this.findProperty(key)?.remove()\n break\n case DataAssociationKind:\n this.findAssociation(key)?.remove()\n break\n default:\n throw new Error(`Unknown kind ${kind} for the object ${key}.`)\n }\n }\n\n /**\n * Finds a data model and calls the `remove()` on it.\n * @param key The key of the data model to find.\n */\n removeDataModel(key: string, opts?: DataDomainRemoveOptions): void {\n const { definitions } = this.root || this\n const model = definitions.models.find((i) => i.key === key)\n if (model) {\n model.remove(opts)\n }\n }\n\n /**\n * @returns The graph of associations where keys are the source\n * entities and the value is the list of all target entities.\n */\n associationGraph(): Record<string, string[]> {\n const graph: Record<string, string[]> = {}\n const { definitions } = this.root || this\n const { associations, entities } = definitions\n for (const assoc of associations) {\n if (!assoc.targets.length) {\n continue\n }\n const srcEntity = entities.find((i) => i.associations.some((a) => a === assoc))\n if (!srcEntity) {\n continue\n }\n if (!graph[srcEntity.key]) {\n graph[srcEntity.key] = []\n }\n const targetIds = assoc.targets.map((i) => i.key)\n graph[srcEntity.key].splice(0, 0, ...targetIds)\n }\n return graph\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n *\n * @param from The key of the from entity\n * @param to The key of the target entity\n * @param g The graph generated with `associationGraph()`\n * @param path The current list of entity ids. Do not set this, it is for the recursive processing of the graph.\n * @param visited The list of visited paths to avoid cycles.\n * Do not set this, it is for the recursive processing of the graph.\n */\n *associationPath(\n from: string,\n to: string,\n g: Record<string, string[]>,\n path: string[] = [],\n visited = new Set<string>()\n ): Generator<string[]> {\n if (from === to) {\n yield path.concat(to)\n return\n }\n if (visited.has(from)) {\n // it's a cycle\n return\n }\n if (g[from]) {\n visited.add(from)\n path.push(from)\n\n for (const neighbor of g[from]) {\n yield* this.associationPath(neighbor, to, g, path, visited)\n }\n\n visited.delete(from)\n path.pop()\n }\n }\n\n /**\n * Scans all associations for foreign namespaces and returns\n * the list of all namespaces used in the association graph.\n * This will never add this namespace's key.\n *\n * This function should be used to read keys for all related\n * namespaces through associations.\n *\n * @returns All keys of foreign namespaces.\n */\n computeForeignNamespaceKeys(): string[] {\n const result: string[] = []\n const { associations = [] } = this.definitions\n associations.forEach((association) => {\n const { targets = [] } = association\n targets.forEach((target) => {\n const { namespace } = target\n if (!namespace || namespace === this.key) {\n return\n }\n result.push(namespace)\n })\n })\n return result\n }\n\n /**\n * Finds an entity in this namespace.\n * @param key The key of the entity to find.\n */\n findEntity(key: string): DataEntity | undefined {\n const { definitions } = this.root || this\n return definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Finds a property by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findProperty(key: string): DataProperty | undefined {\n const { definitions } = this.root || this\n return definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Finds an association by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findAssociation(key: string): DataAssociation | undefined {\n const { definitions } = this.root || this\n return definitions.associations.find((i) => i.key === key)\n }\n\n /**\n * Searches for entities for association targets.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param targets The list of targets\n * @returns A list of entities. An `undefined` is put at the index where an entity cannot be found\n */\n findAssociatedEntities(targets: AssociationTarget[]): (DataEntity | undefined)[] {\n const result: (DataEntity | undefined)[] = []\n targets.forEach((target) => {\n let ns: DataNamespace | undefined\n if (target.namespace) {\n ns = this.foreign.find((i) => i.key === target.namespace)\n } else {\n ns = this\n }\n if (!ns) {\n result.push(undefined)\n return\n }\n const entity = ns.findEntity(target.key)\n if (entity) {\n result.push(entity)\n } else {\n result.push(undefined)\n }\n })\n return result\n }\n\n /**\n * Finds an associated entity in the current or foreign namespace.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param key The key of the entity to find.\n * @param namespace The optional namespace to search in.\n * If not set, the current namespace is used.\n * This is used to find entities in foreign namespaces.\n * @returns The entity or undefined if not found.\n */\n findAssociatedEntity(key: string, namespace?: string): DataEntity | undefined {\n let ns: DataNamespace | undefined\n if (namespace) {\n ns = this.foreign.find((i) => i.key === namespace)\n } else {\n ns = this\n }\n if (!ns) {\n return undefined\n }\n return ns.findEntity(key)\n }\n\n addForeign(ns: DataNamespace): void {\n const exists = this.foreign.some((i) => i.key === ns.key)\n if (exists) {\n return\n }\n this.foreign.push(ns)\n }\n\n removeForeign(ns: DataNamespace): void {\n const index = this.foreign.findIndex((i) => i === ns)\n if (index >= 0) {\n this.foreign.splice(index, 1)\n }\n }\n\n hasForeignNamespace(key: string): boolean {\n return this.foreign.some((i) => i.key === key)\n }\n\n /**\n * Checks whether the namespace is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this namespace is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
|
|
@@ -180,7 +180,7 @@ export interface DomainImpactItem {
|
|
|
180
180
|
* "kind": "DataEntityKind",
|
|
181
181
|
* "type": "delete",
|
|
182
182
|
* "impact": "The SpecialProduct entity will become an orphan because it is a child of Product.",
|
|
183
|
-
* "resolution": "The Product will be removed as the parent
|
|
183
|
+
* "resolution": "The "Product" entity will be removed as the parent of the "SpecialProduct" entity.",
|
|
184
184
|
* "blocking": true,
|
|
185
185
|
* "relationship": "child"
|
|
186
186
|
* },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainImpactAnalysis.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainImpactAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,iBAAiB,GACzB,OAAO,iBAAiB,GACxB,OAAO,cAAc,GACrB,OAAO,aAAa,GACpB,OAAO,gBAAgB,GACvB,OAAO,mBAAmB,CAAA;AAE9B;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,IAAI,EAAE,iBAAiB,CAAA;IACvB;;OAEG;IACH,MAAM,EAAE,gBAAgB,EAAE,CAAA;IAC1B;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,IAAI,EAAE,QAAQ,CAAA;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,EAAE;IAuFhF,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE;IAgBjE,SAAS,CAAC,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE;IAgBpE,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM;CAgBvD"}
|
|
@@ -121,7 +121,7 @@ import { DataNamespaceKind, DataEntityKind, DataModelKind, DataPropertyKind, Dat
|
|
|
121
121
|
* "kind": "DataEntityKind",
|
|
122
122
|
* "type": "delete",
|
|
123
123
|
* "impact": "The SpecialProduct entity will become an orphan because it is a child of Product.",
|
|
124
|
-
* "resolution": "The Product will be removed as the parent
|
|
124
|
+
* "resolution": "The "Product" entity will be removed as the parent of the "SpecialProduct" entity.",
|
|
125
125
|
* "blocking": true,
|
|
126
126
|
* "relationship": "child"
|
|
127
127
|
* },
|
|
@@ -335,12 +335,14 @@ export class DomainImpactAnalysis {
|
|
|
335
335
|
});
|
|
336
336
|
if (children.length) {
|
|
337
337
|
children.forEach((child) => {
|
|
338
|
+
const pLabel = entity.info.renderLabel;
|
|
339
|
+
const cLabel = child.info.renderLabel;
|
|
338
340
|
result.push({
|
|
339
341
|
key: child.key,
|
|
340
342
|
kind: child.kind,
|
|
341
343
|
type: 'delete',
|
|
342
|
-
impact: `The ${
|
|
343
|
-
resolution: `The ${
|
|
344
|
+
impact: `The "${cLabel}" ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
|
|
345
|
+
resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
|
|
344
346
|
blocking: true,
|
|
345
347
|
relationship: 'child',
|
|
346
348
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainImpactAnalysis.js","sourceRoot":"","sources":["../../../src/modeling/DomainImpactAnalysis.ts"],"names":[],"m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C,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IAES,yBAAyB,CAAC,GAAW;QAC7C,MAAM,MAAM,GAAuB,EAAE,CAAA;QACrC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;QAClD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,MAAM,CAAA;QACf,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,WAAW,CAAC,GAAG;YACpB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,mBAAmB;YACvG,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IAES,WAAW,CAAC,IAAuB;QAC3C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,iBAAiB;gBACpB,OAAO,WAAW,CAAA;YACpB,KAAK,cAAc;gBACjB,OAAO,QAAQ,CAAA;YACjB,KAAK,aAAa;gBAChB,OAAO,YAAY,CAAA;YACrB,KAAK,gBAAgB;gBACnB,OAAO,UAAU,CAAA;YACnB,KAAK,mBAAmB;gBACtB,OAAO,aAAa,CAAA;YACtB;gBACE,OAAO,SAAS,CAAA;QACpB,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n DataNamespaceKind,\n DataEntityKind,\n DataModelKind,\n DataPropertyKind,\n DataAssociationKind,\n} from '../models/kinds.js'\nimport type { DataNamespace } from './DataNamespace.js'\n\nexport type DomainImpactKinds =\n | typeof DataNamespaceKind\n | typeof DataEntityKind\n | typeof DataModelKind\n | typeof DataPropertyKind\n | typeof DataAssociationKind\n\n/**\n * The impact analysis report\n */\nexport interface DomainImpactReport {\n /**\n * The key of the impacted data object.\n * This is the key of the object that is being changed.\n */\n key: string\n /**\n * The kind of the impacted data object.\n * This is the kind of the object that is being changed.\n */\n kind: DomainImpactKinds\n /**\n * The list of impacted data objects.\n */\n impact: DomainImpactItem[]\n /**\n * Whether it is possible to proceed with the change.\n * If the change is not possible, the reason will be in the impact list.\n */\n canProceed: boolean\n}\n\nexport interface DomainImpactItem {\n /**\n * The key of the impacted data object.\n */\n key: string\n /**\n * The kind of the impacted data object.\n */\n kind: string\n /**\n * The type of the impact.\n *\n * - `delete` - The data object would be deleted.\n */\n type: 'delete'\n /**\n * The impact description.\n */\n impact: string\n /**\n * Whether the impact is blocking the operation.\n * If true, the operation cannot proceed.\n */\n blocking: boolean\n /**\n * The type of the relationship between two impacted objects.\n */\n relationship?: 'child'\n /**\n * The resolution of the conflict if the change will be forced.\n */\n resolution?: string\n}\n\n/**\n * # DomainImpactAnalysis\n *\n * The `DomainImpactAnalysis` class is a powerful tool for analyzing the consequences of deleting data domain objects\n * within a `DataNamespace`.\n * It helps developers understand the ripple effects of removing a namespace, data model, entity, property,\n * or association, ensuring data integrity and preventing unintended side effects.\n *\n * ## Core Concepts\n *\n * - **Impact Report:** The central output of the `DomainImpactAnalysis` class is an `DomainImpactReport`.\n * This report details the potential consequences of a deletion operation, including:\n * - The object being deleted (`key`, `kind`).\n * - A list of `ImpactItem` objects, each describing a specific consequence.\n * - Whether the deletion can proceed safely (`canProceed`).\n *\n * - **ImpactItem:** Each `ImpactItem` describes a specific consequence of the deletion. Key properties include:\n * - `key`: The key of the impacted object.\n * - `kind`: The kind of the impacted object.\n * - `type`: The type of impact (currently only `delete`).\n * - `impact`: A human-readable description of the impact.\n * - `blocking`: Whether this impact prevents the deletion from proceeding.\n * - `relationship`: The type of relationship between the deleted object and the impacted object (e.g., `child`).\n * - `resolution`: A description of how the impact will be resolved if the deletion is forced.\n *\n * - **Blocking Impacts:** Some impacts are considered \"blocking,\" meaning they prevent the deletion from proceeding\n * without manual intervention. For example, deleting an entity that is a parent to other entities is\n * a blocking impact.\n *\n * - **Non-Blocking Impacts:** Some impacts are informational and do not prevent the deletion. For example, deleting a\n * property is not a blocking impact.\n *\n * ## Usage\n *\n * 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataNamespace` as an argument.\n *\n * ```typescript\n * import { DataNamespace } from './DataNamespace';\n * import { DomainImpactAnalysis } from './DomainImpactAnalysis';\n *\n * const rootNamespace = new DataNamespace();\n * // ... add some data to the namespace\n * const analyzer = new DomainImpactAnalysis(rootNamespace);\n * ```\n *\n * 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `ImpactReport` for a specific deletion.\n * Provide the `key` and `kind` of the object to be deleted.\n *\n * ```typescript\n * import { DataEntityKind } from '../models/kinds.js';\n * // ...\n * const entityKey = 'some-entity-key';\n * const report = analyzer.deleteAnalysis(entityKey, DataEntityKind);\n * ```\n *\n * 3. **Interpreting the Report:** Examine the `ImpactReport` to understand the consequences of the deletion.\n * - Check `report.canProceed` to see if the deletion is safe.\n * - Iterate through `report.impact` to understand each consequence.\n * - Pay special attention to `impact.blocking` to identify impacts that require manual resolution.\n *\n * ```typescript\n * if (report.canProceed) {\n * // Proceed with deletion\n * } else {\n * console.warn('Deletion cannot proceed due to the following impacts:');\n * report.impact.forEach((item) => {\n * console.warn(`- ${item.impact}`);\n * if (item.blocking) {\n * console.warn(` - This impact is blocking.`);\n * if (item.resolution) {\n * console.warn(` - Resolution: ${item.resolution}`);\n * }\n * }\n * });\n * // Handle blocking impacts (e.g., prompt the user, modify the data, etc.)\n * }\n * ```\n *\n * ## Supported Deletion Scenarios\n *\n * The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain object types:\n *\n * - **Namespaces (`DataNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,\n * data models, entities, properties, and associations.\n * - **Data Models (`DataModelKind`):** Deleting a data model impacts all its entities, properties, and associations.\n * - **Entities (`DataEntityKind`):** Deleting an entity impacts its properties, associations, and any other\n * entities that have it as a parent or target in an association.\n * - **Properties (`DataPropertyKind`):** Deleting a property impacts the entity it belongs to.\n * - **Associations (`DataAssociationKind`):** Deleting an association impacts the entity it belongs to.\n *\n * ## Example: Deleting an Entity\n *\n * Consider the following scenario:\n *\n * - Namespace: `MyNamespace`\n * - Data Model: `ProductModel`\n * - Entity: `Product`\n * - Property: `name`\n * - Association: `category` (targets `Category` entity)\n * - Entity: `Category`\n * - Property: `name`\n * - Entity: `SpecialProduct` (parent: `Product`)\n *\n * If you attempt to delete the `Product` entity, the `DomainImpactAnalysis` will generate a report similar to this:\n *\n * ```json\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DataEntityKind\",\n * \"impact\": [\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DataEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The entity with key Product will be deleted.\",\n * \"blocking\": false\n * },\n * {\n * \"key\": \"SpecialProduct\",\n * \"kind\": \"DataEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The SpecialProduct entity will become an orphan because it is a child of Product.\",\n * \"resolution\": \"The Product will be removed as the parent parent of SpecialProduct.\",\n * \"blocking\": true,\n * \"relationship\": \"child\"\n * },\n * {\n * \"key\": \"category\",\n * \"kind\": \"DataAssociationKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The association with key category will be broken because it has a target to Product.\",\n * \"resolution\": \"The association with key category will be removed from Product.\",\n * \"blocking\": true\n * },\n * {\n * \"key\": \"name\",\n * \"kind\": \"DataPropertyKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The property with key name will be deleted.\",\n * \"blocking\": false\n * }\n * ],\n * \"canProceed\": false\n * }\n * ```\n *\n * This report indicates that:\n *\n * - The `Product` entity will be deleted.\n * - The `SpecialProduct` entity will become an orphan (blocking).\n * - The `category` association will be broken (blocking).\n * - The `name` property will be deleted.\n * - The deletion cannot proceed without addressing the blocking impacts.\n *\n * ## Types\n *\n * ### `ImpactKinds`\n *\n * - **Description:** A type alias for the kinds of data domain objects that can be analyzed.\n * - **Values:**\n * - `DataNamespaceKind`\n * - `DataEntityKind`\n * - `DataModelKind`\n * - `DataPropertyKind`\n * - `DataAssociationKind`\n *\n * ### `ImpactReport`\n *\n * - **Description:** The structure of the impact analysis report.\n * - **Properties:**\n * - `key` (`string`): The key of the object being deleted.\n * - `kind` (`ImpactKinds`): The kind of the object being deleted.\n * - `impact` (`ImpactItem[]`): The list of impacts.\n * - `canProceed` (`boolean`): Whether the deletion can proceed.\n *\n * ### `ImpactItem`\n *\n * - **Description:** The structure of an individual impact item.\n * - **Properties:**\n * - `key` (`string`): The key of the impacted object.\n * - `kind` (`string`): The kind of the impacted object.\n * - `type` (`'delete'`): The type of impact.\n * - `impact` (`string`): The impact description.\n * - `blocking` (`boolean`): Whether the impact is blocking.\n * - `relationship` (`'child'`, optional): The relationship type.\n * - `resolution` (`string`, optional): The resolution description.\n *\n * ## Error Handling\n *\n * The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `ImpactReport` to communicate\n * the results of the analysis, including any blocking impacts.\n *\n * ## Best Practices\n *\n * - **Always Analyze Before Deleting:** Before deleting any data domain object, always use `DomainImpactAnalysis`\n * to understand the consequences.\n * - **Handle Blocking Impacts:** Pay close attention to `blocking` impacts and implement appropriate\n * logic to handle them.\n * - **Inform the User:** If a deletion cannot proceed, inform the user about the blocking impacts and provide\n * guidance on how to resolve them.\n * - **Consider Forced Deletion:** In some cases, you may want to allow users to force a deletion even if there are\n * blocking impacts. In such cases, you should clearly communicate the risks to the user.\n *\n * ## Conclusion\n *\n * The `DomainImpactAnalysis` class is an essential tool for maintaining data integrity when working with complex\n * data domain models. By providing detailed impact reports, it empowers developers to make informed decisions\n * about data deletion and prevent unintended consequences.\n */\nexport class DomainImpactAnalysis {\n private report: DomainImpactReport\n private root: DataNamespace\n\n constructor(root: DataNamespace) {\n this.root = root\n this.report = {\n key: '',\n kind: DataNamespaceKind,\n impact: [],\n canProceed: false,\n }\n }\n\n /**\n * Generates a report of how the data domain will be impacted by the deletion of a data domain object.\n * @param key The key of the impacted data domain object.\n * @param kind The kind of the impacted data object.\n * @returns The delete impact analysis report.\n */\n deleteAnalysis(key: string, kind: DomainImpactKinds): DomainImpactReport {\n this.report = {\n key,\n kind,\n impact: [],\n canProceed: true,\n }\n this.report.impact = this.createDeleteImpact(key, kind, key)\n // this.report.impact.unshift({\n // key,\n // kind,\n // type: 'delete',\n // impact: `The ${this.kindToLabel(kind)} with key ${key} will be deleted.`,\n // blocking: false,\n // })\n return this.report\n }\n\n protected createDeleteImpact(key: string, kind: DomainImpactKinds, rootKey: string): DomainImpactItem[] {\n switch (kind) {\n case DataNamespaceKind:\n return this.deleteNamespaceAnalysis(key, rootKey)\n case DataModelKind:\n return this.deleteDataModelAnalysis(key, rootKey)\n case DataEntityKind:\n return this.deleteEntityAnalysis(key, rootKey)\n case DataPropertyKind:\n return this.deletePropertyAnalysis(key)\n case DataAssociationKind:\n return this.deleteAssociationAnalysis(key)\n default:\n return []\n }\n }\n\n protected deleteNamespaceAnalysis(key: string, rootKey: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const ns = this.root.findNamespace(key)\n if (!ns) {\n return result\n }\n result.push({\n key: ns.key,\n kind: ns.kind,\n type: 'delete',\n impact: `The ${ns.info.renderLabel} ${this.kindToLabel(DataNamespaceKind)} will be deleted.`,\n blocking: false,\n })\n const namespaces = ns.listNamespaces()\n namespaces.forEach((child) => {\n const items = this.deleteNamespaceAnalysis(child.key, rootKey)\n result.push(...items)\n })\n const models = ns.listDataModels()\n models.forEach((child) => {\n const items = this.deleteDataModelAnalysis(child.key, rootKey)\n result.push(...items)\n })\n return result\n }\n\n protected deleteDataModelAnalysis(key: string, rootKey: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const model = this.root.findDataModel(key)\n if (!model) {\n return result\n }\n result.push({\n key: model.key,\n kind: model.kind,\n type: 'delete',\n impact: `The ${model.info.renderLabel} ${this.kindToLabel(DataModelKind)} will be deleted.`,\n blocking: false,\n })\n model.entities.forEach((child) => {\n const items = this.deleteEntityAnalysis(child.key, rootKey)\n result.push(...items)\n })\n return result\n }\n\n protected deleteEntityAnalysis(key: string, rootKey: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const entity = this.root.findEntity(key)\n if (!entity) {\n return result\n }\n result.push({\n key: entity.key,\n kind: entity.kind,\n type: 'delete',\n impact: `The ${entity.info.renderLabel} ${this.kindToLabel(DataEntityKind)} will be deleted.`,\n blocking: false,\n })\n // We need to know whether the entity is a parent of another entity\n const children = this.root.definitions.entities.filter((domainEntity) => {\n if (domainEntity.key === entity.key) {\n // ignore self\n return false\n }\n if (!domainEntity.parents.includes(entity.key)) {\n // no relationship\n return false\n }\n if (domainEntity.isChildOf(rootKey)) {\n // No need to include this parent as it itself is being deleted\n return false\n }\n // the entity has a parent-child relationship to the deleted entity.\n return true\n })\n if (children.length) {\n children.forEach((child) => {\n result.push({\n key: child.key,\n kind: child.kind,\n type: 'delete',\n impact: `The ${child.info.renderLabel} ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of ${entity.info.renderLabel}.`,\n resolution: `The ${entity.info.renderLabel} will be removed as the parent parent of ${child.info.renderLabel}.`,\n blocking: true,\n relationship: 'child',\n })\n })\n this.report.canProceed = false\n }\n // We need to know whether there's another entity that has an association to this entity.\n const inAssociations = this.root.definitions.associations.filter((association) => {\n return association.targets.some((item) => {\n if (item.key === entity.key) {\n const related = association.getParentInstance()\n if (!related) {\n return false\n }\n if (related.isChildOf(rootKey)) {\n // No need to include this association as the related entity itself is being deleted\n return false\n }\n return true\n }\n return false\n })\n })\n if (inAssociations.length) {\n inAssociations.forEach((association) => {\n result.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be broken because it has a target to ${entity.info.renderLabel}.`,\n resolution: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be removed from ${entity.info.renderLabel}.`,\n blocking: true,\n })\n })\n this.report.canProceed = false\n }\n entity.properties.forEach((child) => {\n const items = this.deletePropertyAnalysis(child.key)\n result.push(...items)\n })\n entity.associations.forEach((child) => {\n const items = this.deleteAssociationAnalysis(child.key)\n result.push(...items)\n })\n return result\n }\n\n protected deletePropertyAnalysis(key: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const property = this.root.findProperty(key)\n if (!property) {\n return result\n }\n result.push({\n key: property.key,\n kind: property.kind,\n type: 'delete',\n impact: `The ${property.info.renderLabel} ${this.kindToLabel(DataPropertyKind)} will be deleted.`,\n blocking: false,\n })\n return result\n }\n\n protected deleteAssociationAnalysis(key: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const association = this.root.findAssociation(key)\n if (!association) {\n return result\n }\n result.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be deleted.`,\n blocking: false,\n })\n return result\n }\n\n protected kindToLabel(kind: DomainImpactKinds): string {\n switch (kind) {\n case DataNamespaceKind:\n return 'namespace'\n case DataEntityKind:\n return 'entity'\n case DataModelKind:\n return 'data model'\n case DataPropertyKind:\n return 'property'\n case DataAssociationKind:\n return 'association'\n default:\n return 'unknown'\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainImpactAnalysis.js","sourceRoot":"","sources":["../../../src/modeling/DomainImpactAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAqE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgNG;AACH,MAAM,OAAO,oBAAoB;IACvB,MAAM,CAAoB;IAC1B,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,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,mBAAmB;YACvG,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IAES,WAAW,CAAC,IAAuB;QAC3C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,iBAAiB;gBACpB,OAAO,WAAW,CAAA;YACpB,KAAK,cAAc;gBACjB,OAAO,QAAQ,CAAA;YACjB,KAAK,aAAa;gBAChB,OAAO,YAAY,CAAA;YACrB,KAAK,gBAAgB;gBACnB,OAAO,UAAU,CAAA;YACnB,KAAK,mBAAmB;gBACtB,OAAO,aAAa,CAAA;YACtB;gBACE,OAAO,SAAS,CAAA;QACpB,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n DataNamespaceKind,\n DataEntityKind,\n DataModelKind,\n DataPropertyKind,\n DataAssociationKind,\n} from '../models/kinds.js'\nimport type { DataNamespace } from './DataNamespace.js'\n\nexport type DomainImpactKinds =\n | typeof DataNamespaceKind\n | typeof DataEntityKind\n | typeof DataModelKind\n | typeof DataPropertyKind\n | typeof DataAssociationKind\n\n/**\n * The impact analysis report\n */\nexport interface DomainImpactReport {\n /**\n * The key of the impacted data object.\n * This is the key of the object that is being changed.\n */\n key: string\n /**\n * The kind of the impacted data object.\n * This is the kind of the object that is being changed.\n */\n kind: DomainImpactKinds\n /**\n * The list of impacted data objects.\n */\n impact: DomainImpactItem[]\n /**\n * Whether it is possible to proceed with the change.\n * If the change is not possible, the reason will be in the impact list.\n */\n canProceed: boolean\n}\n\nexport interface DomainImpactItem {\n /**\n * The key of the impacted data object.\n */\n key: string\n /**\n * The kind of the impacted data object.\n */\n kind: string\n /**\n * The type of the impact.\n *\n * - `delete` - The data object would be deleted.\n */\n type: 'delete'\n /**\n * The impact description.\n */\n impact: string\n /**\n * Whether the impact is blocking the operation.\n * If true, the operation cannot proceed.\n */\n blocking: boolean\n /**\n * The type of the relationship between two impacted objects.\n */\n relationship?: 'child'\n /**\n * The resolution of the conflict if the change will be forced.\n */\n resolution?: string\n}\n\n/**\n * # DomainImpactAnalysis\n *\n * The `DomainImpactAnalysis` class is a powerful tool for analyzing the consequences of deleting data domain objects\n * within a `DataNamespace`.\n * It helps developers understand the ripple effects of removing a namespace, data model, entity, property,\n * or association, ensuring data integrity and preventing unintended side effects.\n *\n * ## Core Concepts\n *\n * - **Impact Report:** The central output of the `DomainImpactAnalysis` class is an `DomainImpactReport`.\n * This report details the potential consequences of a deletion operation, including:\n * - The object being deleted (`key`, `kind`).\n * - A list of `ImpactItem` objects, each describing a specific consequence.\n * - Whether the deletion can proceed safely (`canProceed`).\n *\n * - **ImpactItem:** Each `ImpactItem` describes a specific consequence of the deletion. Key properties include:\n * - `key`: The key of the impacted object.\n * - `kind`: The kind of the impacted object.\n * - `type`: The type of impact (currently only `delete`).\n * - `impact`: A human-readable description of the impact.\n * - `blocking`: Whether this impact prevents the deletion from proceeding.\n * - `relationship`: The type of relationship between the deleted object and the impacted object (e.g., `child`).\n * - `resolution`: A description of how the impact will be resolved if the deletion is forced.\n *\n * - **Blocking Impacts:** Some impacts are considered \"blocking,\" meaning they prevent the deletion from proceeding\n * without manual intervention. For example, deleting an entity that is a parent to other entities is\n * a blocking impact.\n *\n * - **Non-Blocking Impacts:** Some impacts are informational and do not prevent the deletion. For example, deleting a\n * property is not a blocking impact.\n *\n * ## Usage\n *\n * 1. **Instantiation:** Create an instance of `DomainImpactAnalysis`, passing the root `DataNamespace` as an argument.\n *\n * ```typescript\n * import { DataNamespace } from './DataNamespace';\n * import { DomainImpactAnalysis } from './DomainImpactAnalysis';\n *\n * const rootNamespace = new DataNamespace();\n * // ... add some data to the namespace\n * const analyzer = new DomainImpactAnalysis(rootNamespace);\n * ```\n *\n * 2. **Performing Analysis:** Use the `deleteAnalysis()` method to generate an `ImpactReport` for a specific deletion.\n * Provide the `key` and `kind` of the object to be deleted.\n *\n * ```typescript\n * import { DataEntityKind } from '../models/kinds.js';\n * // ...\n * const entityKey = 'some-entity-key';\n * const report = analyzer.deleteAnalysis(entityKey, DataEntityKind);\n * ```\n *\n * 3. **Interpreting the Report:** Examine the `ImpactReport` to understand the consequences of the deletion.\n * - Check `report.canProceed` to see if the deletion is safe.\n * - Iterate through `report.impact` to understand each consequence.\n * - Pay special attention to `impact.blocking` to identify impacts that require manual resolution.\n *\n * ```typescript\n * if (report.canProceed) {\n * // Proceed with deletion\n * } else {\n * console.warn('Deletion cannot proceed due to the following impacts:');\n * report.impact.forEach((item) => {\n * console.warn(`- ${item.impact}`);\n * if (item.blocking) {\n * console.warn(` - This impact is blocking.`);\n * if (item.resolution) {\n * console.warn(` - Resolution: ${item.resolution}`);\n * }\n * }\n * });\n * // Handle blocking impacts (e.g., prompt the user, modify the data, etc.)\n * }\n * ```\n *\n * ## Supported Deletion Scenarios\n *\n * The `DomainImpactAnalysis` class supports analyzing the deletion of the following data domain object types:\n *\n * - **Namespaces (`DataNamespaceKind`):** Deleting a namespace also impacts all its child namespaces,\n * data models, entities, properties, and associations.\n * - **Data Models (`DataModelKind`):** Deleting a data model impacts all its entities, properties, and associations.\n * - **Entities (`DataEntityKind`):** Deleting an entity impacts its properties, associations, and any other\n * entities that have it as a parent or target in an association.\n * - **Properties (`DataPropertyKind`):** Deleting a property impacts the entity it belongs to.\n * - **Associations (`DataAssociationKind`):** Deleting an association impacts the entity it belongs to.\n *\n * ## Example: Deleting an Entity\n *\n * Consider the following scenario:\n *\n * - Namespace: `MyNamespace`\n * - Data Model: `ProductModel`\n * - Entity: `Product`\n * - Property: `name`\n * - Association: `category` (targets `Category` entity)\n * - Entity: `Category`\n * - Property: `name`\n * - Entity: `SpecialProduct` (parent: `Product`)\n *\n * If you attempt to delete the `Product` entity, the `DomainImpactAnalysis` will generate a report similar to this:\n *\n * ```json\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DataEntityKind\",\n * \"impact\": [\n * {\n * \"key\": \"Product\",\n * \"kind\": \"DataEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The entity with key Product will be deleted.\",\n * \"blocking\": false\n * },\n * {\n * \"key\": \"SpecialProduct\",\n * \"kind\": \"DataEntityKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The SpecialProduct entity will become an orphan because it is a child of Product.\",\n * \"resolution\": \"The \"Product\" entity will be removed as the parent of the \"SpecialProduct\" entity.\",\n * \"blocking\": true,\n * \"relationship\": \"child\"\n * },\n * {\n * \"key\": \"category\",\n * \"kind\": \"DataAssociationKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The association with key category will be broken because it has a target to Product.\",\n * \"resolution\": \"The association with key category will be removed from Product.\",\n * \"blocking\": true\n * },\n * {\n * \"key\": \"name\",\n * \"kind\": \"DataPropertyKind\",\n * \"type\": \"delete\",\n * \"impact\": \"The property with key name will be deleted.\",\n * \"blocking\": false\n * }\n * ],\n * \"canProceed\": false\n * }\n * ```\n *\n * This report indicates that:\n *\n * - The `Product` entity will be deleted.\n * - The `SpecialProduct` entity will become an orphan (blocking).\n * - The `category` association will be broken (blocking).\n * - The `name` property will be deleted.\n * - The deletion cannot proceed without addressing the blocking impacts.\n *\n * ## Types\n *\n * ### `ImpactKinds`\n *\n * - **Description:** A type alias for the kinds of data domain objects that can be analyzed.\n * - **Values:**\n * - `DataNamespaceKind`\n * - `DataEntityKind`\n * - `DataModelKind`\n * - `DataPropertyKind`\n * - `DataAssociationKind`\n *\n * ### `ImpactReport`\n *\n * - **Description:** The structure of the impact analysis report.\n * - **Properties:**\n * - `key` (`string`): The key of the object being deleted.\n * - `kind` (`ImpactKinds`): The kind of the object being deleted.\n * - `impact` (`ImpactItem[]`): The list of impacts.\n * - `canProceed` (`boolean`): Whether the deletion can proceed.\n *\n * ### `ImpactItem`\n *\n * - **Description:** The structure of an individual impact item.\n * - **Properties:**\n * - `key` (`string`): The key of the impacted object.\n * - `kind` (`string`): The kind of the impacted object.\n * - `type` (`'delete'`): The type of impact.\n * - `impact` (`string`): The impact description.\n * - `blocking` (`boolean`): Whether the impact is blocking.\n * - `relationship` (`'child'`, optional): The relationship type.\n * - `resolution` (`string`, optional): The resolution description.\n *\n * ## Error Handling\n *\n * The `DomainImpactAnalysis` class does not throw errors. Instead, it uses the `ImpactReport` to communicate\n * the results of the analysis, including any blocking impacts.\n *\n * ## Best Practices\n *\n * - **Always Analyze Before Deleting:** Before deleting any data domain object, always use `DomainImpactAnalysis`\n * to understand the consequences.\n * - **Handle Blocking Impacts:** Pay close attention to `blocking` impacts and implement appropriate\n * logic to handle them.\n * - **Inform the User:** If a deletion cannot proceed, inform the user about the blocking impacts and provide\n * guidance on how to resolve them.\n * - **Consider Forced Deletion:** In some cases, you may want to allow users to force a deletion even if there are\n * blocking impacts. In such cases, you should clearly communicate the risks to the user.\n *\n * ## Conclusion\n *\n * The `DomainImpactAnalysis` class is an essential tool for maintaining data integrity when working with complex\n * data domain models. By providing detailed impact reports, it empowers developers to make informed decisions\n * about data deletion and prevent unintended consequences.\n */\nexport class DomainImpactAnalysis {\n private report: DomainImpactReport\n private root: DataNamespace\n\n constructor(root: DataNamespace) {\n this.root = root\n this.report = {\n key: '',\n kind: DataNamespaceKind,\n impact: [],\n canProceed: false,\n }\n }\n\n /**\n * Generates a report of how the data domain will be impacted by the deletion of a data domain object.\n * @param key The key of the impacted data domain object.\n * @param kind The kind of the impacted data object.\n * @returns The delete impact analysis report.\n */\n deleteAnalysis(key: string, kind: DomainImpactKinds): DomainImpactReport {\n this.report = {\n key,\n kind,\n impact: [],\n canProceed: true,\n }\n this.report.impact = this.createDeleteImpact(key, kind, key)\n // this.report.impact.unshift({\n // key,\n // kind,\n // type: 'delete',\n // impact: `The ${this.kindToLabel(kind)} with key ${key} will be deleted.`,\n // blocking: false,\n // })\n return this.report\n }\n\n protected createDeleteImpact(key: string, kind: DomainImpactKinds, rootKey: string): DomainImpactItem[] {\n switch (kind) {\n case DataNamespaceKind:\n return this.deleteNamespaceAnalysis(key, rootKey)\n case DataModelKind:\n return this.deleteDataModelAnalysis(key, rootKey)\n case DataEntityKind:\n return this.deleteEntityAnalysis(key, rootKey)\n case DataPropertyKind:\n return this.deletePropertyAnalysis(key)\n case DataAssociationKind:\n return this.deleteAssociationAnalysis(key)\n default:\n return []\n }\n }\n\n protected deleteNamespaceAnalysis(key: string, rootKey: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const ns = this.root.findNamespace(key)\n if (!ns) {\n return result\n }\n result.push({\n key: ns.key,\n kind: ns.kind,\n type: 'delete',\n impact: `The ${ns.info.renderLabel} ${this.kindToLabel(DataNamespaceKind)} will be deleted.`,\n blocking: false,\n })\n const namespaces = ns.listNamespaces()\n namespaces.forEach((child) => {\n const items = this.deleteNamespaceAnalysis(child.key, rootKey)\n result.push(...items)\n })\n const models = ns.listDataModels()\n models.forEach((child) => {\n const items = this.deleteDataModelAnalysis(child.key, rootKey)\n result.push(...items)\n })\n return result\n }\n\n protected deleteDataModelAnalysis(key: string, rootKey: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const model = this.root.findDataModel(key)\n if (!model) {\n return result\n }\n result.push({\n key: model.key,\n kind: model.kind,\n type: 'delete',\n impact: `The ${model.info.renderLabel} ${this.kindToLabel(DataModelKind)} will be deleted.`,\n blocking: false,\n })\n model.entities.forEach((child) => {\n const items = this.deleteEntityAnalysis(child.key, rootKey)\n result.push(...items)\n })\n return result\n }\n\n protected deleteEntityAnalysis(key: string, rootKey: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const entity = this.root.findEntity(key)\n if (!entity) {\n return result\n }\n result.push({\n key: entity.key,\n kind: entity.kind,\n type: 'delete',\n impact: `The ${entity.info.renderLabel} ${this.kindToLabel(DataEntityKind)} will be deleted.`,\n blocking: false,\n })\n // We need to know whether the entity is a parent of another entity\n const children = this.root.definitions.entities.filter((domainEntity) => {\n if (domainEntity.key === entity.key) {\n // ignore self\n return false\n }\n if (!domainEntity.parents.includes(entity.key)) {\n // no relationship\n return false\n }\n if (domainEntity.isChildOf(rootKey)) {\n // No need to include this parent as it itself is being deleted\n return false\n }\n // the entity has a parent-child relationship to the deleted entity.\n return true\n })\n if (children.length) {\n children.forEach((child) => {\n const pLabel = entity.info.renderLabel\n const cLabel = child.info.renderLabel\n result.push({\n key: child.key,\n kind: child.kind,\n type: 'delete',\n impact: `The \"${cLabel}\" ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of the \"${pLabel}\" entity.`,\n resolution: `The \"${pLabel}\" entity will be removed as the parent of the \"${cLabel}\" entity.`,\n blocking: true,\n relationship: 'child',\n })\n })\n this.report.canProceed = false\n }\n // We need to know whether there's another entity that has an association to this entity.\n const inAssociations = this.root.definitions.associations.filter((association) => {\n return association.targets.some((item) => {\n if (item.key === entity.key) {\n const related = association.getParentInstance()\n if (!related) {\n return false\n }\n if (related.isChildOf(rootKey)) {\n // No need to include this association as the related entity itself is being deleted\n return false\n }\n return true\n }\n return false\n })\n })\n if (inAssociations.length) {\n inAssociations.forEach((association) => {\n result.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be broken because it has a target to ${entity.info.renderLabel}.`,\n resolution: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be removed from ${entity.info.renderLabel}.`,\n blocking: true,\n })\n })\n this.report.canProceed = false\n }\n entity.properties.forEach((child) => {\n const items = this.deletePropertyAnalysis(child.key)\n result.push(...items)\n })\n entity.associations.forEach((child) => {\n const items = this.deleteAssociationAnalysis(child.key)\n result.push(...items)\n })\n return result\n }\n\n protected deletePropertyAnalysis(key: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const property = this.root.findProperty(key)\n if (!property) {\n return result\n }\n result.push({\n key: property.key,\n kind: property.kind,\n type: 'delete',\n impact: `The ${property.info.renderLabel} ${this.kindToLabel(DataPropertyKind)} will be deleted.`,\n blocking: false,\n })\n return result\n }\n\n protected deleteAssociationAnalysis(key: string): DomainImpactItem[] {\n const result: DomainImpactItem[] = []\n const association = this.root.findAssociation(key)\n if (!association) {\n return result\n }\n result.push({\n key: association.key,\n kind: association.kind,\n type: 'delete',\n impact: `The ${association.info.renderLabel} ${this.kindToLabel(DataAssociationKind)} will be deleted.`,\n blocking: false,\n })\n return result\n }\n\n protected kindToLabel(kind: DomainImpactKinds): string {\n switch (kind) {\n case DataNamespaceKind:\n return 'namespace'\n case DataEntityKind:\n return 'entity'\n case DataModelKind:\n return 'data model'\n case DataPropertyKind:\n return 'property'\n case DataAssociationKind:\n return 'association'\n default:\n return 'unknown'\n }\n }\n}\n"]}
|
|
@@ -41722,10 +41722,10 @@
|
|
|
41722
41722
|
"@id": "#209"
|
|
41723
41723
|
},
|
|
41724
41724
|
{
|
|
41725
|
-
"@id": "#
|
|
41725
|
+
"@id": "#206"
|
|
41726
41726
|
},
|
|
41727
41727
|
{
|
|
41728
|
-
"@id": "#
|
|
41728
|
+
"@id": "#191"
|
|
41729
41729
|
},
|
|
41730
41730
|
{
|
|
41731
41731
|
"@id": "#194"
|
|
@@ -41734,7 +41734,7 @@
|
|
|
41734
41734
|
"@id": "#197"
|
|
41735
41735
|
},
|
|
41736
41736
|
{
|
|
41737
|
-
"@id": "#
|
|
41737
|
+
"@id": "#200"
|
|
41738
41738
|
},
|
|
41739
41739
|
{
|
|
41740
41740
|
"@id": "#203"
|
|
@@ -43096,7 +43096,7 @@
|
|
|
43096
43096
|
"doc:ExternalDomainElement",
|
|
43097
43097
|
"doc:DomainElement"
|
|
43098
43098
|
],
|
|
43099
|
-
"doc:raw": "
|
|
43099
|
+
"doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
|
|
43100
43100
|
"core:mediaType": "application/yaml",
|
|
43101
43101
|
"sourcemaps:sources": [
|
|
43102
43102
|
{
|
|
@@ -43159,7 +43159,7 @@
|
|
|
43159
43159
|
"doc:ExternalDomainElement",
|
|
43160
43160
|
"doc:DomainElement"
|
|
43161
43161
|
],
|
|
43162
|
-
"doc:raw": "
|
|
43162
|
+
"doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
|
|
43163
43163
|
"core:mediaType": "application/yaml",
|
|
43164
43164
|
"sourcemaps:sources": [
|
|
43165
43165
|
{
|
|
@@ -43201,7 +43201,7 @@
|
|
|
43201
43201
|
"doc:ExternalDomainElement",
|
|
43202
43202
|
"doc:DomainElement"
|
|
43203
43203
|
],
|
|
43204
|
-
"doc:raw": "
|
|
43204
|
+
"doc:raw": "countryCode: \"BE\"\ngraydonEnterpriseId: 1057155523\nregistrationId: \"0422319093\"\nvatNumber: \"BE0422319093\"\ngraydonCompanyId: \"0422319093\"\nisBranchOffice: false\n",
|
|
43205
43205
|
"core:mediaType": "application/yaml",
|
|
43206
43206
|
"sourcemaps:sources": [
|
|
43207
43207
|
{
|
|
@@ -44416,7 +44416,7 @@
|
|
|
44416
44416
|
{
|
|
44417
44417
|
"@id": "#193/source-map/lexical/element_0",
|
|
44418
44418
|
"sourcemaps:element": "amf://id#193",
|
|
44419
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44419
|
+
"sourcemaps:value": "[(1,0)-(10,0)]"
|
|
44420
44420
|
},
|
|
44421
44421
|
{
|
|
44422
44422
|
"@id": "#196/source-map/lexical/element_0",
|
|
@@ -44431,7 +44431,7 @@
|
|
|
44431
44431
|
{
|
|
44432
44432
|
"@id": "#202/source-map/lexical/element_0",
|
|
44433
44433
|
"sourcemaps:element": "amf://id#202",
|
|
44434
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44434
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44435
44435
|
},
|
|
44436
44436
|
{
|
|
44437
44437
|
"@id": "#205/source-map/lexical/element_0",
|
|
@@ -44441,7 +44441,7 @@
|
|
|
44441
44441
|
{
|
|
44442
44442
|
"@id": "#208/source-map/lexical/element_0",
|
|
44443
44443
|
"sourcemaps:element": "amf://id#208",
|
|
44444
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44444
|
+
"sourcemaps:value": "[(1,0)-(7,0)]"
|
|
44445
44445
|
},
|
|
44446
44446
|
{
|
|
44447
44447
|
"@id": "#223/source-map/lexical/element_0",
|
package/package.json
CHANGED
|
@@ -535,7 +535,7 @@ export class DataEntity {
|
|
|
535
535
|
/**
|
|
536
536
|
* Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all
|
|
537
537
|
* parents in the inheritance chain in no particular order.
|
|
538
|
-
* @param recursive Whether to include parent parents as well.
|
|
538
|
+
* @param recursive Whether to include parent's parents as well.
|
|
539
539
|
*/
|
|
540
540
|
getComputedParents(recursive?: boolean): DataEntity[] {
|
|
541
541
|
const { entities } = this.root.definitions
|
|
@@ -4,7 +4,13 @@ import { IDataAssociation, DataAssociation, AssociationTarget } from './DataAsso
|
|
|
4
4
|
import { IDataEntity, DataEntity } from './DataEntity.js'
|
|
5
5
|
import { IDataModel, DataModel } from './DataModel.js'
|
|
6
6
|
import { IDataProperty, DataProperty } from './DataProperty.js'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
DataNamespaceKind,
|
|
9
|
+
DataModelKind,
|
|
10
|
+
DataEntityKind,
|
|
11
|
+
DataPropertyKind,
|
|
12
|
+
DataAssociationKind,
|
|
13
|
+
} from '../models/kinds.js'
|
|
8
14
|
import v4 from '../lib/uuid.js'
|
|
9
15
|
import type { DataDomainRemoveOptions } from './types.js'
|
|
10
16
|
|
|
@@ -475,7 +481,7 @@ export class DataNamespace {
|
|
|
475
481
|
addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {
|
|
476
482
|
let root: DataNamespace
|
|
477
483
|
if (parent) {
|
|
478
|
-
const rootCandidate = this.
|
|
484
|
+
const rootCandidate = this.findNamespace(parent)
|
|
479
485
|
if (!rootCandidate) {
|
|
480
486
|
throw new Error(`Unable to find the parent namespace ${parent}`)
|
|
481
487
|
}
|
|
@@ -596,7 +602,7 @@ export class DataNamespace {
|
|
|
596
602
|
* Finds a namespace and calls the `remove()` on it.
|
|
597
603
|
* @param key The key of the namespace to find.
|
|
598
604
|
*/
|
|
599
|
-
removeNamespace(key: string): void {
|
|
605
|
+
removeNamespace(key: string, opts?: DataDomainRemoveOptions): void {
|
|
600
606
|
const root = this.root || this
|
|
601
607
|
if (root.key === key) {
|
|
602
608
|
throw new Error(`Unable to remove the root namespace this way.`)
|
|
@@ -604,7 +610,7 @@ export class DataNamespace {
|
|
|
604
610
|
const { definitions } = root
|
|
605
611
|
const ns = definitions.namespaces.find((i) => i.key === key)
|
|
606
612
|
if (ns) {
|
|
607
|
-
ns.remove()
|
|
613
|
+
ns.remove(opts)
|
|
608
614
|
}
|
|
609
615
|
}
|
|
610
616
|
|
|
@@ -651,15 +657,44 @@ export class DataNamespace {
|
|
|
651
657
|
return definitions.models.find((i) => i.key === key)
|
|
652
658
|
}
|
|
653
659
|
|
|
660
|
+
/**
|
|
661
|
+
* A convenience function to remove an object from the namespace.
|
|
662
|
+
* @param key The key of the object to remove.
|
|
663
|
+
* @param kind The kind of the object to remove.
|
|
664
|
+
* @param opts The options for the removal.
|
|
665
|
+
* @throws Error when the kind is not known.
|
|
666
|
+
*/
|
|
667
|
+
removeObject(key: string, kind: string, opts?: DataDomainRemoveOptions): void {
|
|
668
|
+
switch (kind) {
|
|
669
|
+
case DataNamespaceKind:
|
|
670
|
+
this.findNamespace(key)?.remove(opts)
|
|
671
|
+
break
|
|
672
|
+
case DataModelKind:
|
|
673
|
+
this.findDataModel(key)?.remove(opts)
|
|
674
|
+
break
|
|
675
|
+
case DataEntityKind:
|
|
676
|
+
this.findEntity(key)?.remove(opts)
|
|
677
|
+
break
|
|
678
|
+
case DataPropertyKind:
|
|
679
|
+
this.findProperty(key)?.remove()
|
|
680
|
+
break
|
|
681
|
+
case DataAssociationKind:
|
|
682
|
+
this.findAssociation(key)?.remove()
|
|
683
|
+
break
|
|
684
|
+
default:
|
|
685
|
+
throw new Error(`Unknown kind ${kind} for the object ${key}.`)
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
654
689
|
/**
|
|
655
690
|
* Finds a data model and calls the `remove()` on it.
|
|
656
691
|
* @param key The key of the data model to find.
|
|
657
692
|
*/
|
|
658
|
-
removeDataModel(key: string): void {
|
|
693
|
+
removeDataModel(key: string, opts?: DataDomainRemoveOptions): void {
|
|
659
694
|
const { definitions } = this.root || this
|
|
660
695
|
const model = definitions.models.find((i) => i.key === key)
|
|
661
696
|
if (model) {
|
|
662
|
-
model.remove()
|
|
697
|
+
model.remove(opts)
|
|
663
698
|
}
|
|
664
699
|
}
|
|
665
700
|
|
|
@@ -195,7 +195,7 @@ export interface DomainImpactItem {
|
|
|
195
195
|
* "kind": "DataEntityKind",
|
|
196
196
|
* "type": "delete",
|
|
197
197
|
* "impact": "The SpecialProduct entity will become an orphan because it is a child of Product.",
|
|
198
|
-
* "resolution": "The Product will be removed as the parent
|
|
198
|
+
* "resolution": "The "Product" entity will be removed as the parent of the "SpecialProduct" entity.",
|
|
199
199
|
* "blocking": true,
|
|
200
200
|
* "relationship": "child"
|
|
201
201
|
* },
|
|
@@ -415,12 +415,14 @@ export class DomainImpactAnalysis {
|
|
|
415
415
|
})
|
|
416
416
|
if (children.length) {
|
|
417
417
|
children.forEach((child) => {
|
|
418
|
+
const pLabel = entity.info.renderLabel
|
|
419
|
+
const cLabel = child.info.renderLabel
|
|
418
420
|
result.push({
|
|
419
421
|
key: child.key,
|
|
420
422
|
kind: child.kind,
|
|
421
423
|
type: 'delete',
|
|
422
|
-
impact: `The ${
|
|
423
|
-
resolution: `The ${
|
|
424
|
+
impact: `The "${cLabel}" ${this.kindToLabel(DataEntityKind)} will become an orphan because it is a child of the "${pLabel}" entity.`,
|
|
425
|
+
resolution: `The "${pLabel}" entity will be removed as the parent of the "${cLabel}" entity.`,
|
|
424
426
|
blocking: true,
|
|
425
427
|
relationship: 'child',
|
|
426
428
|
})
|
|
@@ -114,8 +114,8 @@ test.group('DomainImpactAnalysis', (group) => {
|
|
|
114
114
|
assert.equal(e4r.key, e4.key)
|
|
115
115
|
assert.equal(e4r.kind, DataEntityKind)
|
|
116
116
|
assert.equal(e4r.type, 'delete')
|
|
117
|
-
assert.equal(e4r.impact, `The e4 entity will become an orphan because it is a child of e3.`)
|
|
118
|
-
assert.equal(e4r.resolution, `The e3 will be removed as the parent
|
|
117
|
+
assert.equal(e4r.impact, `The "e4" entity will become an orphan because it is a child of the "e3" entity.`)
|
|
118
|
+
assert.equal(e4r.resolution, `The "e3" entity will be removed as the parent of the "e4" entity.`)
|
|
119
119
|
assert.isTrue(e4r.blocking)
|
|
120
120
|
assert.equal(e4r.relationship, 'child')
|
|
121
121
|
|
|
@@ -189,8 +189,8 @@ test.group('DomainImpactAnalysis', (group) => {
|
|
|
189
189
|
assert.equal(e3r.key, e3.key)
|
|
190
190
|
assert.equal(e3r.kind, DataEntityKind)
|
|
191
191
|
assert.equal(e3r.type, 'delete')
|
|
192
|
-
assert.equal(e3r.impact, `The e3 entity will become an orphan because it is a child of e1.`)
|
|
193
|
-
assert.equal(e3r.resolution, `The e1 will be removed as the parent
|
|
192
|
+
assert.equal(e3r.impact, `The "e3" entity will become an orphan because it is a child of the "e1" entity.`)
|
|
193
|
+
assert.equal(e3r.resolution, `The "e1" entity will be removed as the parent of the "e3" entity.`)
|
|
194
194
|
assert.isTrue(e3r.blocking)
|
|
195
195
|
assert.equal(e3r.relationship, 'child')
|
|
196
196
|
})
|
|
@@ -234,8 +234,8 @@ test.group('DomainImpactAnalysis', (group) => {
|
|
|
234
234
|
assert.equal(e3r.key, e3.key)
|
|
235
235
|
assert.equal(e3r.kind, DataEntityKind)
|
|
236
236
|
assert.equal(e3r.type, 'delete')
|
|
237
|
-
assert.equal(e3r.impact, `The e3 entity will become an orphan because it is a child of e1.`)
|
|
238
|
-
assert.equal(e3r.resolution, `The e1 will be removed as the parent
|
|
237
|
+
assert.equal(e3r.impact, `The "e3" entity will become an orphan because it is a child of the "e1" entity.`)
|
|
238
|
+
assert.equal(e3r.resolution, `The "e1" entity will be removed as the parent of the "e3" entity.`)
|
|
239
239
|
assert.isTrue(e3r.blocking)
|
|
240
240
|
assert.equal(e3r.relationship, 'child')
|
|
241
241
|
})
|
|
@@ -304,8 +304,8 @@ test.group('DomainImpactAnalysis', (group) => {
|
|
|
304
304
|
assert.equal(e2r.key, e2.key)
|
|
305
305
|
assert.equal(e2r.kind, DataEntityKind)
|
|
306
306
|
assert.equal(e2r.type, 'delete')
|
|
307
|
-
assert.equal(e2r.impact, `The e2 entity will become an orphan because it is a child of e3.`)
|
|
308
|
-
assert.equal(e2r.resolution, `The e3 will be removed as the parent
|
|
307
|
+
assert.equal(e2r.impact, `The "e2" entity will become an orphan because it is a child of the "e3" entity.`)
|
|
308
|
+
assert.equal(e2r.resolution, `The "e3" entity will be removed as the parent of the "e2" entity.`)
|
|
309
309
|
assert.isTrue(e2r.blocking)
|
|
310
310
|
assert.equal(e2r.relationship, 'child')
|
|
311
311
|
|
|
@@ -313,8 +313,8 @@ test.group('DomainImpactAnalysis', (group) => {
|
|
|
313
313
|
assert.equal(e4r.key, e4.key)
|
|
314
314
|
assert.equal(e4r.kind, DataEntityKind)
|
|
315
315
|
assert.equal(e4r.type, 'delete')
|
|
316
|
-
assert.equal(e4r.impact, `The e4 entity will become an orphan because it is a child of e3.`)
|
|
317
|
-
assert.equal(e4r.resolution, `The e3 will be removed as the parent
|
|
316
|
+
assert.equal(e4r.impact, `The "e4" entity will become an orphan because it is a child of the "e3" entity.`)
|
|
317
|
+
assert.equal(e4r.resolution, `The "e3" entity will be removed as the parent of the "e4" entity.`)
|
|
318
318
|
assert.isTrue(e4r.blocking)
|
|
319
319
|
assert.equal(e4r.relationship, 'child')
|
|
320
320
|
})
|
|
@@ -365,8 +365,8 @@ test.group('DomainImpactAnalysis', (group) => {
|
|
|
365
365
|
assert.equal(e3r.key, e3.key)
|
|
366
366
|
assert.equal(e3r.kind, DataEntityKind)
|
|
367
367
|
assert.equal(e3r.type, 'delete')
|
|
368
|
-
assert.equal(e3r.impact, `The e3 entity will become an orphan because it is a child of e1.`)
|
|
369
|
-
assert.equal(e3r.resolution, `The e1 will be removed as the parent
|
|
368
|
+
assert.equal(e3r.impact, `The "e3" entity will become an orphan because it is a child of the "e1" entity.`)
|
|
369
|
+
assert.equal(e3r.resolution, `The "e1" entity will be removed as the parent of the "e3" entity.`)
|
|
370
370
|
assert.isTrue(e3r.blocking)
|
|
371
371
|
assert.equal(e3r.relationship, 'child')
|
|
372
372
|
})
|