@api-client/core 0.11.4 → 0.11.7

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.
Files changed (35) hide show
  1. package/build/oauth-popup.html +33 -0
  2. package/build/src/amf/definitions/Shapes.d.ts +1 -1
  3. package/build/src/amf/definitions/Shapes.js.map +1 -1
  4. package/build/src/modeling/DataAssociation.d.ts +7 -3
  5. package/build/src/modeling/DataAssociation.d.ts.map +1 -1
  6. package/build/src/modeling/DataAssociation.js +22 -6
  7. package/build/src/modeling/DataAssociation.js.map +1 -1
  8. package/build/src/modeling/DataEntity.d.ts +14 -1
  9. package/build/src/modeling/DataEntity.d.ts.map +1 -1
  10. package/build/src/modeling/DataEntity.js +39 -9
  11. package/build/src/modeling/DataEntity.js.map +1 -1
  12. package/build/src/modeling/DataModel.d.ts +5 -1
  13. package/build/src/modeling/DataModel.d.ts.map +1 -1
  14. package/build/src/modeling/DataModel.js +15 -11
  15. package/build/src/modeling/DataModel.js.map +1 -1
  16. package/build/src/modeling/DataNamespace.d.ts +12 -1
  17. package/build/src/modeling/DataNamespace.d.ts.map +1 -1
  18. package/build/src/modeling/DataNamespace.js +45 -6
  19. package/build/src/modeling/DataNamespace.js.map +1 -1
  20. package/build/src/modeling/DataProperty.js +2 -2
  21. package/build/src/modeling/DataProperty.js.map +1 -1
  22. package/data/models/example-generator-api.json +27 -27
  23. package/package.json +6 -16
  24. package/src/amf/definitions/Shapes.ts +1 -1
  25. package/src/modeling/DataAssociation.ts +26 -6
  26. package/src/modeling/DataEntity.ts +44 -9
  27. package/src/modeling/DataModel.ts +16 -11
  28. package/src/modeling/DataNamespace.ts +46 -6
  29. package/src/modeling/DataProperty.ts +2 -2
  30. package/tests/unit/modeling/data_association.spec.ts +2 -2
  31. package/tests/unit/modeling/data_entity.spec.ts +3 -3
  32. package/tests/unit/modeling/data_model.spec.ts +3 -3
  33. package/tests/unit/modeling/data_namespace.spec.ts +72 -3
  34. package/tsconfig.browser.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AAC,CAAC,EAAE,CAAC;YACtE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;YACxE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,GAAa,EAAE,MAAgB,EAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;QAClG,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;YAC3B,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;gBAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;gBAC9B,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,MAAM,CAAA;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { DataProperty } from './DataProperty.js'\nimport { type DataPropertyType } from './DataFormat.js'\nimport { DataAssociation } from './DataAssociation.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataEntityKind } from '../models/kinds.js'\nimport { DataModel } from './DataModel.js'\nimport { IApiNodeShape, IShapeUnion } from '../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\nimport { RemovePropertyException } from '../exceptions/remove_property_exception.js'\nimport { RemoveAssociationException } from '../exceptions/remove_association_exception.js'\nimport { ValidationError, type FieldValidationMessage } from '../exceptions/validation_error.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { ForeignAssociationException } from '../exceptions/foreign_association_exception.js'\n\ninterface OrderedItem {\n type: 'property' | 'association'\n key: string\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport interface IDataEntity {\n kind: typeof DataEntityKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data entity description.\n */\n info: IThing\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy?: string[]\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties?: string[]\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations?: string[]\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields?: OrderedItem[]\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n *\n * @todo(jarrodek): This should also hold a reference to a namespace to support\n * foreign entities as parents.\n */\n parents?: string[]\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n */\n schema?: IApiNodeShape\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport class DataEntity {\n kind = DataEntityKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy: string[] = []\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties: DataProperty[] = []\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations: DataAssociation[] = []\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields: OrderedItem[] = []\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n */\n parents: string[] = []\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n static fromName(root: DataNamespace, name: string): DataEntity {\n const entity = new DataEntity(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param input The data entity definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataEntity\n ) {\n let init: IDataEntity\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataEntityKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataEntity): void {\n DataEntity.validate(init)\n const {\n info,\n key = v4(),\n kind = DataEntityKind,\n tags,\n taxonomy,\n parents,\n properties,\n associations,\n fields,\n deprecated,\n } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (Array.isArray(parents)) {\n this.parents = [...parents]\n } else {\n this.parents = []\n }\n this.properties = []\n if (Array.isArray(properties)) {\n properties.forEach((key) => {\n const value = this._readProperty(key)\n if (value) {\n this.properties.push(value)\n }\n })\n }\n this.associations = []\n if (Array.isArray(associations)) {\n associations.forEach((key) => {\n const value = this._readAssociation(key)\n if (value) {\n this.associations.push(value)\n }\n })\n }\n if (Array.isArray(fields)) {\n this.fields = [...fields]\n } else {\n this.fields = this.createOrderedFields()\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n private createOrderedFields(): OrderedItem[] {\n const result: OrderedItem[] = []\n this.properties.forEach((i) => {\n result.push({\n type: 'property',\n key: i.key,\n })\n })\n this.associations.forEach((i) => {\n result.push({\n type: 'association',\n key: i.key,\n })\n })\n return result\n }\n\n static validate(input: unknown): void {\n const typed = input as IDataEntity\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataEntityKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataEntityKind}`,\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages, { message: 'Invalid data entity definition.' })\n }\n }\n\n toJSON(): IDataEntity {\n const result: IDataEntity = {\n kind: DataEntityKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.parents) && this.parents.length) {\n result.parents = [...this.parents]\n }\n if (Array.isArray(this.properties) && this.properties.length) {\n result.properties = this.properties.map((i) => i.key)\n }\n if (Array.isArray(this.associations) && this.associations.length) {\n result.associations = this.associations.map((i) => i.key)\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n protected _readAssociation(key: string): DataAssociation | undefined {\n return this.root.definitions.associations.find((i) => i.key === key)\n }\n\n protected _readProperty(key: string): DataProperty | undefined {\n return this.root.definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Creates a property with a passed type.\n * @param type The type of the property\n * @returns The created property\n */\n addTypedProperty(type: DataPropertyType, name?: string): DataProperty {\n const property = DataProperty.fromType(this.root, type)\n if (name) {\n property.info.name = name\n }\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Creates a property with a passed type.\n * @param name The name of the property.\n * @returns The created property\n */\n addNamedProperty(name: string): DataProperty {\n const property = DataProperty.fromName(this.root, name)\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Removes the property from the entity and namespace definitions.\n * @param key The key of the property to remove.\n */\n removeProperty(key: string): void {\n const thisIndex = this.properties.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't exist.`)\n }\n const propertyToRemove = this.properties[thisIndex]\n this.properties.splice(thisIndex, 1)\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n this.removeField(key)\n propertyToRemove.remove()\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Lists all properties for this Entity.\n * @returns The list of properties that belong to this entity.\n */\n listProperties(): DataProperty[] {\n return [...this.properties]\n }\n\n /**\n * Lists all associations for this Entity.\n * @returns The list of associations that belong to this entity.\n */\n listAssociations(): DataAssociation[] {\n return [...this.associations]\n }\n\n /**\n * Generates an ordered list of fields (properties and associations) for this entity.\n *\n * @returns The list of fields (properties and associations) that belong to this entity.\n */\n listFields(): (DataAssociation | DataProperty)[] {\n const result: (DataAssociation | DataProperty)[] = []\n this.fields.forEach((i) => {\n if (i.type === 'property') {\n const property = this.properties.find((p) => p.key === i.key)\n if (property) {\n result.push(property)\n }\n } else if (i.type === 'association') {\n const association = this.associations.find((a) => a.key === i.key)\n if (association) {\n result.push(association)\n }\n }\n })\n return result\n }\n\n /**\n * Moves the field to a new index.\n * @param key The key of the field to move.\n * @param toIndex The new index to which move the field to.\n */\n moveField(key: string, toIndex: number): void {\n const fromIndex = this.fields.findIndex((i) => i.key === key)\n if (fromIndex < 0) {\n throw new ValidationError([{ field: 'fields', message: `Field ${key} not found.`, rule: 'not-found' }])\n }\n if (toIndex < 0 || toIndex >= this.fields.length) {\n throw new ValidationError([{ field: 'fields', message: `Invalid index ${toIndex}.`, rule: 'invalid' }])\n }\n const [item] = this.fields.splice(fromIndex, 1)\n this.fields.splice(toIndex, 0, item)\n }\n\n /**\n * Creates an association for a given name, adds it to definitions, and returns it.\n * @param name The name of the association\n * @returns The created association\n */\n addNamedAssociation(name: string): DataAssociation {\n const result = DataAssociation.fromName(this.root, name)\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target, adds it to definitions, and returns it.\n *\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addTargetAssociation(target: string | DataEntity, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n const result = DataAssociation.fromTarget(this.root, key)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target that is in another namespace\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addForeignAssociation(target: string | DataEntity, namespace: string, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n if (!this.root.hasForeignNamespace(namespace)) {\n throw new ForeignAssociationException(\n `Trying to add a foreign association but the foreign namespace is not defined.`\n )\n }\n const result = DataAssociation.fromTarget(this.root, key, namespace)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Removes an association from the entity and, namespace definitions.\n * @param key The key of the association to remove.\n */\n removeAssociation(key: string): void {\n const thisIndex = this.associations.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n // return\n throw new RemoveAssociationException(`Trying to remove the ${key} association, but it doesn't exist.`)\n }\n const associationToRemove = this.associations[thisIndex]\n this.associations.splice(thisIndex, 1)\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n this.removeField(key)\n associationToRemove.remove()\n }\n\n /**\n * Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all\n * parents in the inheritance chain in no particular order.\n * @param recursive Whether to include parent parents as well.\n */\n getComputedParents(recursive?: boolean): DataEntity[] {\n const { entities } = this.root.definitions\n let result: DataEntity[] = []\n this.parents.forEach((key) => {\n const parent = entities.find((i) => i.key === key)\n if (parent) {\n result.push(parent)\n if (recursive) {\n result = result.concat(parent.getComputedParents())\n }\n }\n })\n return result\n }\n\n /**\n * Computes list of all children, inside the root namespace, that extends this entity.\n * The children are not ordered.\n */\n getComputedChildren(): DataEntity[] {\n const { entities } = this.root.definitions\n return entities.filter((i) => i.parents.includes(this.key))\n }\n\n /**\n * Computes a list of entities that are associated with the current entity.\n */\n getComputedAssociations(): DataEntity[] {\n const { associations } = this\n const result: DataEntity[] = []\n associations.forEach((assoc) => {\n if (!assoc.targets.length) {\n return\n }\n const entities = this.root.findAssociatedEntities(assoc.targets)\n entities.forEach((entity) => {\n if (entity) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n /**\n * Removes self from the namespace with all properties and attributes.\n */\n remove(): void {\n const { key, properties, associations, root } = this\n // check if some entity has reference to this entity as a target\n const associationsToEntity = this.root.definitions.associations.filter((a) =>\n a.targets.some((t) => t.key === this.key)\n )\n if (associationsToEntity.length > 0) {\n const entitiesNames = associationsToEntity.reduce<string[]>((acc, association) => {\n const entity = root.definitions.entities.find((e) => e.associations.includes(association))\n if (entity) {\n acc.push(entity.info.name as string)\n }\n return acc\n }, [])\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.name} because it is used as a target in associations in entities: ${entitiesNames.join(', ')}.`\n )\n }\n\n // remove own stuff\n properties.forEach((p) => this.removeProperty(p.key))\n associations.forEach((a) => this.removeAssociation(a.key))\n // remove from the root\n const index = root.definitions.entities.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.entities.splice(index, 1)\n }\n // remove from the parent\n const model = this.getParent()\n if (model) {\n const entityIndex = model.entities.findIndex((e) => e === this)\n model.entities.splice(entityIndex, 1)\n }\n }\n\n /**\n * Returns a parent data model where this entity exist.\n */\n getParent(): DataModel | undefined {\n return this.root.definitions.models.find((m) => m.entities.some((e) => e === this))\n }\n\n /**\n * Adds a parent reference to this entity.\n * This will not add the parent to the namespace. It only adds a reference to the parent.\n * @param key The key of the parent entity to add.\n * @returns `this` for chaining.\n */\n addParent(key: string): this {\n // Prevent adding self as parent\n if (key === this.key) {\n const message = 'Entity cannot be a parent of itself.'\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n // check if parent exists\n const parent = this.root.definitions.entities.find((i) => i.key === key)\n if (!parent) {\n const message = `Entity with key \"${key}\" not found.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'not-exists',\n },\n ],\n { message }\n )\n }\n // Check for circular inheritance\n if (this.hasCircularParent(key)) {\n const message = `Circular inheritance detected. Cannot add ${key} as a parent.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n const has = this.parents.some((i) => i === key)\n if (has) {\n const message = `Parent ${key} already exists.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'exists',\n },\n ],\n { message }\n )\n }\n this.parents.push(key)\n return this\n }\n\n /**\n * Checks if the entity has a circular parent relationship when attempting to add a new parent.\n * @param key The key of the parent being added.\n * @returns true if adding this parent would create a circular relationship.\n */\n hasCircularParent(key: string): boolean {\n const { entities } = this.root.definitions\n // Check if new parent is one of the children.\n const children = this.getComputedChildren()\n if (children.some((c) => c.key === key)) {\n return true\n }\n // check if this entity is in parents chain.\n let current: DataEntity | undefined = entities.find((e) => e.key === key)\n while (current) {\n if (current.key === this.key) {\n return true\n }\n // for (const parentKey of current.parents) {\n // current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n // }\n const parentKey = current.parents[0] // Assuming single inheritance\n current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n }\n return false\n }\n\n /**\n * Tests whether one entity is associated with another.\n *\n * @param entity1 The source entity\n * @param entity2 The target entity\n * @returns true when there's any path from one entity to another.\n */\n static isAssociated(entity1: DataEntity, entity2: DataEntity): boolean {\n return entity1.isAssociated(entity2.key)\n }\n\n /**\n * Tests whether this entity is somehow associated with another entity.\n * @param target The key of the target entity to test for association with.\n * @returns true if this entity has any association to the `target` entity.\n */\n isAssociated(target: string): boolean {\n const it = this.associationPath(target)\n const path = it.next().value\n return !!path\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n * @param toEntity The key to the target entity\n * @yields The path containing keys of entities from this entity to the `toEntity`\n * (inclusive) and all entities in between.\n */\n *associationPath(toEntity: string): Generator<string[]> {\n const graph = this.root.associationGraph()\n for (const path of this.root.associationPath(this.key, toEntity, graph)) {\n yield path\n }\n }\n\n /**\n * Returns a list of entities that are associated with this entity as a target.\n *\n * This method identifies entities that have an association where this entity is a target.\n * In other words, it finds entities that \"point to\" this entity through an association.\n *\n * For example, consider the following relationships:\n *\n * ```plain\n * A -> B (A has an association that targets B)\n * C -> B (C has an association that targets B)\n * B -> D (B has an association that targets D)\n *\n * Calling `getRelatedEntities()` on B would return [A, C]\n * Calling `getRelatedEntities()` on D would return [B]\n * Calling `getRelatedEntities()` on A would return []\n * ```\n *\n * Note, this method only returns entities that are directly associated with this entity as a target.\n * It does not traverse the association graph to find indirectly related entities.\n *\n * @returns An array of `DataEntity` instances that have an association targeting this entity.\n */\n getRelatedEntities(): DataEntity[] {\n const { key, root } = this\n const result = DataEntity.getRelatedEntities(root, key)\n root.foreign.forEach((ns) => {\n const other = DataEntity.getRelatedEntities(ns, key)\n other.forEach((entity) => {\n if (!result.includes(entity)) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n static getRelatedEntities(namespace: DataNamespace, entityKey: string): DataEntity[] {\n const result: DataEntity[] = []\n const inverse = namespace.definitions.associations.filter((i) => i.targets.some((j) => j.key === entityKey))\n inverse.forEach((assoc) => {\n const entity = namespace.definitions.entities.find((e) => e.associations.includes(assoc))\n if (entity && !result.includes(entity)) {\n result.push(entity)\n }\n })\n return result\n }\n\n /**\n * Creates breadcrumbs from this entity to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.name || 'Unnamed entity',\n kind: DataEntityKind,\n })\n const model = this.getParent()\n if (model) {\n result.push({\n key: model.key,\n kind: model.kind,\n name: model.info.name || 'Unnamed data model',\n })\n let parent = model.getParent()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.name || 'Unnamed namespace',\n })\n parent = parent.getParent()\n }\n }\n result.push({\n key: this.root.key,\n name: this.root.info.name || 'Unnamed namespace',\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.\n *\n * Note, it does nothing when the tag is already defined.\n *\n * @param tag The tag to add.\n */\n addTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n if (tags.some((t) => t.toLowerCase() === lower)) {\n return\n }\n tags.push(tag)\n const { definitions } = this.root\n if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {\n definitions.tags.push(tag)\n }\n }\n\n /**\n * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.\n *\n * @param tag The tag to remove.\n */\n removeTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n const index = tags.findIndex((t) => t.toLowerCase() === lower)\n if (index >= 0) {\n tags.splice(index, 1)\n }\n }\n\n /**\n * Creates a Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IShapeUnion {\n const serializer = new AmfShapeGenerator()\n return serializer.entity(this)\n }\n\n /**\n * Reads the schema of the Entity and generates an example for it.\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n const shape = this.toApiShape()\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: typeof opts.renderExamples === 'boolean' ? opts.renderExamples : true,\n renderMocked: typeof opts.renderMocked === 'boolean' ? opts.renderMocked : true,\n renderOptional: typeof opts.renderOptional === 'boolean' ? opts.renderOptional : true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n hasClosedCycle(rootEntity: string, targetEntity: string): boolean {\n if (targetEntity === this.key) {\n // self association\n return true\n }\n const g = this.root.associationGraph()\n const selfPaths: string[][] = []\n const targetPaths: string[][] = []\n for (const path of this.root.associationPath(rootEntity, this.key, g)) {\n selfPaths.push(path)\n }\n for (const path of this.root.associationPath(targetEntity, this.key, g)) {\n targetPaths.push(path)\n }\n const checker = (arr: string[], target: string[]): boolean => target.every((v) => arr.includes(v))\n for (const sp of selfPaths) {\n for (const tp of targetPaths) {\n const result = checker(sp, tp)\n if (result) {\n return result\n }\n }\n }\n return false\n }\n}\n"]}
1
+ {"version":3,"file":"DataEntity.js","s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AAE,EAAE,EAAE,CAAC,CAAA;gBAC9B,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,MAAM,CAAA;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { DataProperty } from './DataProperty.js'\nimport { type DataPropertyType } from './DataFormat.js'\nimport { DataAssociation } from './DataAssociation.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataEntityKind } from '../models/kinds.js'\nimport { DataModel } from './DataModel.js'\nimport { IApiNodeShape, IShapeUnion } from '../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\nimport { RemovePropertyException } from '../exceptions/remove_property_exception.js'\nimport { RemoveAssociationException } from '../exceptions/remove_association_exception.js'\nimport { ValidationError, type FieldValidationMessage } from '../exceptions/validation_error.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { ForeignAssociationException } from '../exceptions/foreign_association_exception.js'\n\ninterface OrderedItem {\n type: 'property' | 'association'\n key: string\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport interface IDataEntity {\n kind: typeof DataEntityKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data entity description.\n */\n info: IThing\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy?: string[]\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties?: string[]\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations?: string[]\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields?: OrderedItem[]\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n *\n * @todo(jarrodek): This should also hold a reference to a namespace to support\n * foreign entities as parents.\n */\n parents?: string[]\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n */\n schema?: IApiNodeShape\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport class DataEntity {\n kind = DataEntityKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy: string[] = []\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties: DataProperty[] = []\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations: DataAssociation[] = []\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields: OrderedItem[] = []\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n */\n parents: string[] = []\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n static fromName(root: DataNamespace, name: string): DataEntity {\n const entity = new DataEntity(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param input The data entity definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataEntity\n ) {\n let init: IDataEntity\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataEntityKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataEntity): void {\n DataEntity.validate(init)\n const {\n info,\n key = v4(),\n kind = DataEntityKind,\n tags,\n taxonomy,\n parents,\n properties,\n associations,\n fields,\n deprecated,\n } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (Array.isArray(parents)) {\n this.parents = [...parents]\n } else {\n this.parents = []\n }\n this.properties = []\n if (Array.isArray(properties)) {\n properties.forEach((key) => {\n const value = this._readProperty(key)\n if (value) {\n this.properties.push(value)\n }\n })\n }\n this.associations = []\n if (Array.isArray(associations)) {\n associations.forEach((key) => {\n const value = this._readAssociation(key)\n if (value) {\n this.associations.push(value)\n }\n })\n }\n if (Array.isArray(fields)) {\n this.fields = [...fields]\n } else {\n this.fields = this.createOrderedFields()\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n private createOrderedFields(): OrderedItem[] {\n const result: OrderedItem[] = []\n this.properties.forEach((i) => {\n result.push({\n type: 'property',\n key: i.key,\n })\n })\n this.associations.forEach((i) => {\n result.push({\n type: 'association',\n key: i.key,\n })\n })\n return result\n }\n\n static validate(input: unknown): void {\n const typed = input as IDataEntity\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataEntityKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataEntityKind}`,\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages, { message: 'Invalid data entity definition.' })\n }\n }\n\n toJSON(): IDataEntity {\n const result: IDataEntity = {\n kind: DataEntityKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.parents) && this.parents.length) {\n result.parents = [...this.parents]\n }\n if (Array.isArray(this.properties) && this.properties.length) {\n result.properties = this.properties.map((i) => i.key)\n }\n if (Array.isArray(this.associations) && this.associations.length) {\n result.associations = this.associations.map((i) => i.key)\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n protected _readAssociation(key: string): DataAssociation | undefined {\n return this.root.definitions.associations.find((i) => i.key === key)\n }\n\n protected _readProperty(key: string): DataProperty | undefined {\n return this.root.definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Creates a property with a passed type.\n * @param type The type of the property\n * @returns The created property\n */\n addTypedProperty(type: DataPropertyType, name?: string): DataProperty {\n const property = DataProperty.fromType(this.root, type)\n if (name) {\n property.info.name = name\n }\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Creates a property with a passed type.\n * @param name The name of the property.\n * @returns The created property\n */\n addNamedProperty(name: string): DataProperty {\n const property = DataProperty.fromName(this.root, name)\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Removes the property from the entity and namespace definitions.\n * @param key The key of the property to remove.\n */\n removeProperty(key: string): void {\n const thisIndex = this.properties.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't exist.`)\n }\n const propertyToRemove = this.properties[thisIndex]\n this.properties.splice(thisIndex, 1)\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n this.removeField(key)\n propertyToRemove.remove()\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Lists all properties for this Entity.\n * @returns The list of properties that belong to this entity.\n */\n listProperties(): DataProperty[] {\n return [...this.properties]\n }\n\n /**\n * Lists all associations for this Entity.\n * @returns The list of associations that belong to this entity.\n */\n listAssociations(): DataAssociation[] {\n return [...this.associations]\n }\n\n /**\n * Generates an ordered list of fields (properties and associations) for this entity.\n *\n * @returns The list of fields (properties and associations) that belong to this entity.\n */\n listFields(): (DataAssociation | DataProperty)[] {\n const result: (DataAssociation | DataProperty)[] = []\n this.fields.forEach((i) => {\n if (i.type === 'property') {\n const property = this.properties.find((p) => p.key === i.key)\n if (property) {\n result.push(property)\n }\n } else if (i.type === 'association') {\n const association = this.associations.find((a) => a.key === i.key)\n if (association) {\n result.push(association)\n }\n }\n })\n return result\n }\n\n /**\n * Moves the field to a new index.\n * @param key The key of the field to move.\n * @param toIndex The new index to which move the field to.\n */\n moveField(key: string, toIndex: number): void {\n const fromIndex = this.fields.findIndex((i) => i.key === key)\n if (fromIndex < 0) {\n throw new ValidationError([{ field: 'fields', message: `Field ${key} not found.`, rule: 'not-found' }])\n }\n if (toIndex < 0 || toIndex >= this.fields.length) {\n throw new ValidationError([{ field: 'fields', message: `Invalid index ${toIndex}.`, rule: 'invalid' }])\n }\n const [item] = this.fields.splice(fromIndex, 1)\n this.fields.splice(toIndex, 0, item)\n }\n\n /**\n * Creates an association for a given name, adds it to definitions, and returns it.\n * @param name The name of the association\n * @returns The created association\n */\n addNamedAssociation(name: string): DataAssociation {\n const result = DataAssociation.fromName(this.root, name)\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target, adds it to definitions, and returns it.\n *\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addTargetAssociation(target: string | DataEntity, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n const result = DataAssociation.fromTarget(this.root, key)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target that is in another namespace\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addForeignAssociation(target: string | DataEntity, namespace: string, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n if (!this.root.hasForeignNamespace(namespace)) {\n throw new ForeignAssociationException(\n `Trying to add a foreign association but the foreign namespace is not defined.`\n )\n }\n const result = DataAssociation.fromTarget(this.root, key, namespace)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Removes an association from the entity and, namespace definitions.\n * @param key The key of the association to remove.\n */\n removeAssociation(key: string): void {\n const thisIndex = this.associations.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n // return\n throw new RemoveAssociationException(`Trying to remove the ${key} association, but it doesn't exist.`)\n }\n const associationToRemove = this.associations[thisIndex]\n this.associations.splice(thisIndex, 1)\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n this.removeField(key)\n associationToRemove.remove()\n }\n\n /**\n * Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all\n * parents in the inheritance chain in no particular order.\n * @param recursive Whether to include parent parents as well.\n */\n getComputedParents(recursive?: boolean): DataEntity[] {\n const { entities } = this.root.definitions\n let result: DataEntity[] = []\n this.parents.forEach((key) => {\n const parent = entities.find((i) => i.key === key)\n if (parent) {\n result.push(parent)\n if (recursive) {\n result = result.concat(parent.getComputedParents())\n }\n }\n })\n return result\n }\n\n /**\n * Computes list of all children, inside the root namespace, that extends this entity.\n * The children are not ordered.\n */\n getComputedChildren(): DataEntity[] {\n const { entities } = this.root.definitions\n return entities.filter((i) => i.parents.includes(this.key))\n }\n\n /**\n * Computes a list of entities that are associated with the current entity.\n */\n getComputedAssociations(): DataEntity[] {\n const { associations } = this\n const result: DataEntity[] = []\n associations.forEach((assoc) => {\n if (!assoc.targets.length) {\n return\n }\n const entities = this.root.findAssociatedEntities(assoc.targets)\n entities.forEach((entity) => {\n if (entity) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n /**\n * Removes self from the namespace with all properties and attributes.\n */\n remove(): void {\n const { key, properties, associations, root } = this\n // check if some entity has reference to this entity as a target\n const associationsToEntity = this.root.definitions.associations.filter((a) =>\n a.targets.some((t) => t.key === this.key)\n )\n if (associationsToEntity.length > 0) {\n const entitiesNames = associationsToEntity.reduce<string[]>((acc, association) => {\n const entity = root.definitions.entities.find((e) => e.associations.some((a) => a.key === association.key))\n if (entity) {\n acc.push(entity.info.name as string)\n }\n return acc\n }, [])\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.name} because it is used as a target in associations in entities: ${entitiesNames.join(', ')}.`\n )\n }\n\n // remove own stuff\n properties.forEach((p) => this.removeProperty(p.key))\n associations.forEach((a) => this.removeAssociation(a.key))\n // remove from the root\n const index = root.definitions.entities.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.entities.splice(index, 1)\n }\n // remove from the parent\n const model = this.getParentInstance()\n if (model) {\n const entityIndex = model.entities.findIndex((e) => e.key === this.key)\n model.entities.splice(entityIndex, 1)\n }\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n // This method name 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"]}
@@ -73,9 +73,13 @@ export declare class DataModel {
73
73
  */
74
74
  addEntity(init: string | DataEntity | IDataEntity): DataEntity;
75
75
  /**
76
- * Returns the parent namespace where this data model exist.
76
+ * @deprecated Use the `getParentInstance()` method instead.
77
77
  */
78
78
  getParent(): DataNamespace | undefined;
79
+ /**
80
+ * Returns the parent namespace where this data model exist.
81
+ */
82
+ getParentInstance(): DataNamespace | undefined;
79
83
  /**
80
84
  * Creates breadcrumbs from this data model to the root namespace.
81
85
  */
@@ -1 +1 @@
1
- {"version":3,"file":"DataModel.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,aAAa,CAAA;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IA0BX,IAAI,EAAE,aAAa;IAzB5B,IAAI,SAAgB;IAEpB,GAAG,SAAK;IAER;;OAEG;IACH,IAAI,EAAE,KAAK,CAAqB;IAEhC;;OAEG;IACH,QAAQ,EAAE,UAAU,EAAE,CAAK;IAE3B,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS;IAM7D;;;OAGG;gBAEM,IAAI,EAAE,aAAa,EAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU;IAkB7B,GAAG,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAwB3B,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQ3C,MAAM,IAAI,UAA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AE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS;IAM7D;;;OAGG;gBAEM,IAAI,EAAE,aAAa,EAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU;IAkB7B,GAAG,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAwB3B,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQ3C,MAAM,IAAI,UAAU;IAYpB,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI1D;;OAEG;IACH,MAAM,IAAI,IAAI;IAoBd;;;;;;;OAOG;IACH,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,GAAE,uBAA4B,GAAG,IAAI;IA6BzE;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU;IAc9D;;OAEG;IACH,SAAS,IAAI,aAAa,GAAG,SAAS;IAItC;;OAEG;IACH,iBAAiB,IAAI,aAAa,GAAG,SAAS;IAO9C;;OAEG;IACH,WAAW,IAAI,cAAc,EAAE;CAuBhC"}
@@ -100,7 +100,7 @@ export class DataModel {
100
100
  // remove children
101
101
  entities.forEach((e) => e.remove());
102
102
  // remove self from the parent
103
- const parent = this.getParent();
103
+ const parent = this.getParentInstance();
104
104
  if (parent) {
105
105
  const itemIndex = parent.items.findIndex((i) => i.key === key);
106
106
  if (itemIndex >= 0) {
@@ -133,17 +133,15 @@ export class DataModel {
133
133
  if (entity.root !== this.root) {
134
134
  throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`);
135
135
  }
136
- if (entity.getParent() === this) {
137
- throw new Error(`The entity ${entity.key} is already adapted by this data model.`);
138
- }
139
- const parent = entity.getParent();
136
+ const parent = entity.getParentInstance();
140
137
  if (!parent) {
141
138
  throw new Error(`The entity ${entity.key} has no parent.`);
142
139
  }
143
- const index = parent.entities.findIndex((i) => i.key === entity.key);
144
- if (index < 0) {
145
- throw new Error(`The entity ${entity.key} is not in the parent data model.`);
140
+ if (parent.key === this.key) {
141
+ throw new Error(`The entity ${entity.key} is already adapted by this data model.`);
146
142
  }
143
+ // it has a parent (above check) so it has the index.
144
+ const index = parent.entities.findIndex((i) => i.key === entity.key);
147
145
  parent.entities.splice(index, 1);
148
146
  if (opts.index !== undefined) {
149
147
  this.entities.splice(opts.index, 0, entity);
@@ -174,9 +172,15 @@ export class DataModel {
174
172
  return definition;
175
173
  }
176
174
  /**
177
- * Returns the parent namespace where this data model exist.
175
+ * @deprecated Use the `getParentInstance()` method instead.
178
176
  */
179
177
  getParent() {
178
+ return this.getParentInstance();
179
+ }
180
+ /**
181
+ * Returns the parent namespace where this data model exist.
182
+ */
183
+ getParentInstance() {
180
184
  if (this.root.items.some((e) => e.key === this.key)) {
181
185
  return this.root;
182
186
  }
@@ -192,14 +196,14 @@ export class DataModel {
192
196
  name: this.info.name || 'Unnamed data model',
193
197
  kind: DataModelKind,
194
198
  });
195
- let parent = this.getParent();
199
+ let parent = this.getParentInstance();
196
200
  while (parent && parent !== this.root) {
197
201
  result.push({
198
202
  key: parent.key,
199
203
  kind: parent.kind,
200
204
  name: parent.info.name || 'Unnamed namespace',
201
205
  });
202
- parent = parent.getParent();
206
+ parent = parent.getParentInstance();
203
207
  }
204
208
  result.push({
205
209
  key: this.root.key,
@@ -1 +1 @@
1
- {"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../../src/modeling/DataModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAA;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAwBlD;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IA0BX;IAzBT,IAAI,GAAG,aAAa,CAAA;IAEpB,GAAG,GAAG,EAAE,CA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ED;;OAEG;IACH,WAAW;QACT,MAAM,MAAM,GAAqB,EAAE,CAAA;QACnC,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,oBAAoB;YAC5C,IAAI,EAAE,aAAa;SACpB,CAAC,CAAA;QACF,IAAI,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC7B,OAAO,MAAM,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB;aAC9C,CAAC,CAAA;YACF,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;QAC7B,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB;YAChD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;SACrB,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport type { DataItemAdaptingOptions, DataNamespace } from './DataNamespace.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataModelKind } from '../models/kinds.js'\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n */\nexport interface IDataModel {\n kind: typeof DataModelKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The list of keys of entities that this data model contain.\n */\n entities?: string[]\n}\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n */\nexport class DataModel {\n kind = DataModelKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * The list of entities that this data model has.\n */\n entities: DataEntity[] = []\n\n static fromName(root: DataNamespace, name: string): DataModel {\n const entity = new DataModel(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param root the root namespace.\n * @param input The data model definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataModel\n ) {\n let init: IDataModel\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: DataModelKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n entities: [],\n }\n }\n this.new(init)\n }\n\n new(init: IDataModel): void {\n if (!DataModel.isDataModel(init)) {\n throw new Error(`Not a data model.`)\n }\n const { info, key = v4(), kind = DataModelKind, entities } = 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\n this.entities = []\n if (Array.isArray(entities)) {\n entities.forEach((key) => {\n const value = this._readEntity(key)\n if (value) {\n this.entities.push(value)\n }\n })\n }\n }\n\n static isDataModel(input: unknown): boolean {\n const typed = input as IDataModel\n if (!input || typed.kind !== DataModelKind) {\n return false\n }\n return true\n }\n\n toJSON(): IDataModel {\n const result: IDataModel = {\n kind: DataModelKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.entities) && this.entities.length) {\n result.entities = this.entities.map((i) => i.key)\n }\n return result\n }\n\n protected _readEntity(key: string): DataEntity | undefined {\n return this.root.definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Removes self from the namespace with all entities.\n */\n remove(): void {\n const { key, entities, root } = this\n // remove children\n entities.forEach((e) => e.remove())\n\n // remove self from the parent\n const parent = this.getParent()\n if (parent) {\n const itemIndex = parent.items.findIndex((i) => i.key === key)\n if (itemIndex >= 0) {\n parent.items.splice(itemIndex, 1)\n }\n }\n // remove self from definitions\n const index = root.definitions.models.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.models.splice(index, 1)\n }\n }\n\n /**\n * Adapts an entity to this data model.\n * The entity must already be added to another data model within this namespace for it to be\n * adapted to this data model.\n * This method is used to change the data model of an entity.\n * It will remove the entity from the previous data model and add it to this one.\n * @param entity The entity to adapt.\n */\n adaptEntity(entity: DataEntity, 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.entities.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (entity.root !== this.root) {\n throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`)\n }\n if (entity.getParent() === this) {\n throw new Error(`The entity ${entity.key} is already adapted by this data model.`)\n }\n const parent = entity.getParent()\n if (!parent) {\n throw new Error(`The entity ${entity.key} has no parent.`)\n }\n const index = parent.entities.findIndex((i) => i.key === entity.key)\n if (index < 0) {\n throw new Error(`The entity ${entity.key} is not in the parent data model.`)\n }\n parent.entities.splice(index, 1)\n if (opts.index !== undefined) {\n this.entities.splice(opts.index, 0, entity)\n } else {\n this.entities.push(entity)\n }\n }\n\n /**\n * Adds an entity to this data model.\n *\n * @param init The name of the entity to create, the instance of the entity or its schema\n * @returns A reference to the created entity.\n */\n addEntity(init: string | DataEntity | IDataEntity): DataEntity {\n let definition: DataEntity\n if (typeof init === 'string') {\n definition = DataEntity.fromName(this.root, init)\n } else if (init instanceof DataEntity) {\n definition = init\n } else {\n definition = new DataEntity(this.root, init)\n }\n this.root.definitions.entities.push(definition)\n this.entities.push(definition)\n return definition\n }\n\n /**\n * Returns the parent namespace where this data model exist.\n */\n getParent(): DataNamespace | undefined {\n if (this.root.items.some((e) => e.key === this.key)) {\n return this.root\n }\n return this.root.definitions.namespaces.find((n) => n.items.some((e) => e.key === this.key))\n }\n\n /**\n * Creates breadcrumbs from this data model 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 data model',\n kind: DataModelKind,\n })\n let parent = this.getParent()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.name || 'Unnamed namespace',\n })\n parent = parent.getParent()\n }\n 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"]}
1
+ {"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../../src/modeling/DataModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAA;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAwBlD;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IA0BX;IAzBT,IAAI,GAAG,aAAa,CAAA;IAEpB,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,GAAiB,EAAE,CAAA;IAE3B,MAAM,CAAC,QAAQ,CAAC,IAAmB,EAAE,IAAY;QAC/C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClC,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;OAGG;IACH,YACS,IAAmB,EAC1B,KAA2B;QADpB,SAAI,GAAJ,IAAI,CAAe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AAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB;aAC9C,CAAC,CAAA;YACF,MAAM,GAAG,MAAM,CAAC,iBAAiB,EAAE,CAAA;QACrC,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB;YAChD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;SACrB,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport type { DataItemAdaptingOptions, DataNamespace } from './DataNamespace.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataModelKind } from '../models/kinds.js'\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n */\nexport interface IDataModel {\n kind: typeof DataModelKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The list of keys of entities that this data model contain.\n */\n entities?: string[]\n}\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n */\nexport class DataModel {\n kind = DataModelKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * The list of entities that this data model has.\n */\n entities: DataEntity[] = []\n\n static fromName(root: DataNamespace, name: string): DataModel {\n const entity = new DataModel(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param root the root namespace.\n * @param input The data model definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataModel\n ) {\n let init: IDataModel\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: DataModelKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n entities: [],\n }\n }\n this.new(init)\n }\n\n new(init: IDataModel): void {\n if (!DataModel.isDataModel(init)) {\n throw new Error(`Not a data model.`)\n }\n const { info, key = v4(), kind = DataModelKind, entities } = 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\n this.entities = []\n if (Array.isArray(entities)) {\n entities.forEach((key) => {\n const value = this._readEntity(key)\n if (value) {\n this.entities.push(value)\n }\n })\n }\n }\n\n static isDataModel(input: unknown): boolean {\n const typed = input as IDataModel\n if (!input || typed.kind !== DataModelKind) {\n return false\n }\n return true\n }\n\n toJSON(): IDataModel {\n const result: IDataModel = {\n kind: DataModelKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.entities) && this.entities.length) {\n result.entities = this.entities.map((i) => i.key)\n }\n return result\n }\n\n protected _readEntity(key: string): DataEntity | undefined {\n return this.root.definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Removes self from the namespace with all entities.\n */\n remove(): void {\n const { key, entities, root } = this\n // remove children\n entities.forEach((e) => e.remove())\n\n // remove self from the parent\n const parent = this.getParentInstance()\n if (parent) {\n const itemIndex = parent.items.findIndex((i) => i.key === key)\n if (itemIndex >= 0) {\n parent.items.splice(itemIndex, 1)\n }\n }\n // remove self from definitions\n const index = root.definitions.models.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.models.splice(index, 1)\n }\n }\n\n /**\n * Adapts an entity to this data model.\n * The entity must already be added to another data model within this namespace for it to be\n * adapted to this data model.\n * This method is used to change the data model of an entity.\n * It will remove the entity from the previous data model and add it to this one.\n * @param entity The entity to adapt.\n */\n adaptEntity(entity: DataEntity, 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.entities.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (entity.root !== this.root) {\n throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`)\n }\n const parent = entity.getParentInstance()\n if (!parent) {\n throw new Error(`The entity ${entity.key} has no parent.`)\n }\n if (parent.key === this.key) {\n throw new Error(`The entity ${entity.key} is already adapted by this data model.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.entities.findIndex((i) => i.key === entity.key)\n parent.entities.splice(index, 1)\n if (opts.index !== undefined) {\n this.entities.splice(opts.index, 0, entity)\n } else {\n this.entities.push(entity)\n }\n }\n\n /**\n * Adds an entity to this data model.\n *\n * @param init The name of the entity to create, the instance of the entity or its schema\n * @returns A reference to the created entity.\n */\n addEntity(init: string | DataEntity | IDataEntity): DataEntity {\n let definition: DataEntity\n if (typeof init === 'string') {\n definition = DataEntity.fromName(this.root, init)\n } else if (init instanceof DataEntity) {\n definition = init\n } else {\n definition = new DataEntity(this.root, init)\n }\n this.root.definitions.entities.push(definition)\n this.entities.push(definition)\n return definition\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 where this data model exist.\n */\n getParentInstance(): DataNamespace | undefined {\n if (this.root.items.some((e) => e.key === this.key)) {\n return this.root\n }\n return this.root.definitions.namespaces.find((n) => n.items.some((e) => e.key === this.key))\n }\n\n /**\n * Creates breadcrumbs from this data model 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 data model',\n kind: DataModelKind,\n })\n let parent = this.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 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"]}
@@ -105,9 +105,13 @@ declare class DataNamespaceParent {
105
105
  root?: DataNamespace;
106
106
  constructor(root?: DataNamespace);
107
107
  /**
108
- * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
108
+ * @deprecated Use the `getParentInstance()` method instead.
109
109
  */
110
110
  getParent(): DataNamespace | undefined;
111
+ /**
112
+ * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
113
+ */
114
+ getParentInstance(): DataNamespace | undefined;
111
115
  /**
112
116
  * Adds a data namespace to the structure.
113
117
  * @param init The name of the namespace to add, namespace's schema, or instance.
@@ -198,6 +202,13 @@ export declare class DataNamespace extends DataNamespaceParent {
198
202
  * @param opts Adapting options.
199
203
  */
200
204
  adaptNamespace(ns: DataNamespace, opts?: DataItemAdaptingOptions): void;
205
+ /**
206
+ * Adapts an existing data model to this namespace.
207
+ * This will remove the data model from the parent namespace and add it to this one.
208
+ * @param model The data model to adapt.
209
+ * @param opts The adapting options.
210
+ */
211
+ adaptDataModel(model: DataModel, opts?: DataItemAdaptingOptions): void;
201
212
  /**
202
213
  * Finds a namespace in the definitions.
203
214
  * @param key The key of the namespace to find.
@@ -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,EAAE,iBAAiB,EA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AAE,MAAM,GAAG,SAAS;IA4B/E;;;;OAIG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAKjD;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQlC;;;OAGG;IACH,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAqB5C;;;;;;;;;OASG;IACF,eAAe,CACd,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAC3B,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,cAAoB,GAC1B,SAAS,CAAC,MAAM,EAAE,CAAC;IAsBtB;;;;;;;;;OASG;IACH,2BAA2B,IAAI,MAAM,EAAE;IAgBvC;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAK/C;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAKnD;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAKzD;;;;;;OAMG;IACH,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE;IAuBhF;;;;;;;;;OASG;IACH,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAa7E,UAAU,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAQnC,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAOtC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAG1C"}
@@ -26,9 +26,15 @@ class DataNamespaceParent {
26
26
  this.root = root;
27
27
  }
28
28
  /**
29
- * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
29
+ * @deprecated Use the `getParentInstance()` method instead.
30
30
  */
31
31
  getParent() {
32
+ return this.getParentInstance();
33
+ }
34
+ /**
35
+ * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
36
+ */
37
+ getParentInstance() {
32
38
  const { root, key } = this;
33
39
  if (root) {
34
40
  const result = root.findParent(key);
@@ -411,7 +417,7 @@ export class DataNamespace extends DataNamespaceParent {
411
417
  if (ns.root !== this.root) {
412
418
  throw new Error(`The namespace ${ns.key} is not in the same namespace as this data namespace.`);
413
419
  }
414
- if (ns.getParent() === this) {
420
+ if (ns.getParentInstance() === this) {
415
421
  throw new Error(`The namespace ${ns.key} is already adapted by this data namespace.`);
416
422
  }
417
423
  // Check for circular dependency
@@ -420,16 +426,49 @@ export class DataNamespace extends DataNamespaceParent {
420
426
  if (current === ns) {
421
427
  throw new Error(`Unable to adapt namespace ${ns.key} under itself or one of its children.`);
422
428
  }
423
- current = current.getParent();
429
+ current = current.getParentInstance();
424
430
  }
425
- const parent = ns.getParent() || this.root;
431
+ const parent = ns.getParentInstance() || this.root;
426
432
  if (!parent) {
427
433
  throw new Error(`The namespace ${ns.key} has no parent.`);
428
434
  }
435
+ // it has a parent (above check) so it has the index.
429
436
  const index = parent.items.findIndex((i) => i.key === ns.key);
430
- if (index < 0) {
431
- throw new Error(`The namespace ${ns.key} is not in the parent data namespace.`);
437
+ const [item] = parent.items.splice(index, 1);
438
+ if (opts.index !== undefined) {
439
+ this.items.splice(opts.index, 0, item);
440
+ }
441
+ else {
442
+ this.items.push(item);
443
+ }
444
+ }
445
+ /**
446
+ * Adapts an existing data model to this namespace.
447
+ * This will remove the data model from the parent namespace and add it to this one.
448
+ * @param model The data model to adapt.
449
+ * @param opts The adapting options.
450
+ */
451
+ adaptDataModel(model, opts = {}) {
452
+ if (opts.index !== undefined) {
453
+ if (opts.index < 0) {
454
+ throw new Error(`The index ${opts.index} cannot be below 0.`);
455
+ }
456
+ if (opts.index >= this.items.length) {
457
+ throw new Error(`The index ${opts.index} is not valid.`);
458
+ }
459
+ }
460
+ if (model.root !== this.root) {
461
+ throw new Error(`The data model ${model.key} is not in the same namespace as this data namespace.`);
462
+ }
463
+ const parent = model.getParentInstance();
464
+ if (!parent) {
465
+ throw new Error(`The data model ${model.key} has no parent.`);
466
+ }
467
+ if (parent === this) {
468
+ throw new Error(`The data model ${model.key} is already adapted by this data namespace.`);
432
469
  }
470
+ // it has a parent (above check) so it has the index.
471
+ const index = parent.items.findIndex((i) => i.key === model.key);
433
472
  const [item] = parent.items.splice(index, 1);
434
473
  if (opts.index !== undefined) {
435
474
  this.items.splice(opts.index, 0, item);