import { IThing, Thing } from '../../models/Thing.js';
import { DataNamespace } from './DataNamespace.js';
import { DataProperty } from './DataProperty.js';
import { type DataPropertyType } from '../DataFormat.js';
import { DataAssociation } from './DataAssociation.js';
import { FileBreadcrumb } from '../../models/store/File.js';
import { DataEntityKind } from '../../models/kinds.js';
import { DataModel } from './DataModel.js';
import { IApiNodeShape, IShapeUnion } from '../../amf/definitions/Shapes.js';
import { IShapeRenderOptions } from '../../amf/shape/ShapeBase.js';
import type { DataDomainRemoveOptions } from '../types.js';
/**
 * @deprecated
 */
interface OrderedItem {
    /**
     * The type of the ordered item.
     */
    type: 'property' | 'association';
    /**
     * The key of the ordered item.
     */
    key: string;
}
/**
 * Data entity is the smallest description of a data in the system
 * It contains properties and associations. At least one entity describe a data model.
 * @deprecated
 */
export interface IDataEntity {
    kind: typeof DataEntityKind;
    /**
     * The key of the namespace.
     */
    key: string;
    /**
     * The data entity description.
     */
    info: IThing;
    /**
     * Optional general purpose tags for the UI.
     */
    tags?: string[];
    /**
     * For future use.
     *
     * The keys of the taxonomy items associated with the entity.
     */
    taxonomy?: string[];
    /**
     * The list of keys of properties that belong to this entity.
     */
    properties?: string[];
    /**
     * The list of keys of associations that belong to this entity.
     */
    associations?: string[];
    /**
     * The ordered list of fields (properties and associations) in the schema.
     * These only keep references to the properties and associations.
     * The order of the fields is important as it defines the order of the
     * properties in the schema.
     */
    fields?: OrderedItem[];
    /**
     * The list of keys of entities that are parents to this entity.
     *
     * This potentially may cause a conflict when two parents declare the same
     * property. In such situation this entity should define own property
     * with the same name to shadow parent property. When the property is
     * not shadowed this may cause unexpected results as the processing could result
     * with inconsistent definition of a schema because the last read property wins.
     *
     * @todo(jarrodek): This should also hold a reference to a namespace to support
     * foreign entities as parents.
     */
    parents?: string[];
    /**
     * Whether this entity is deprecated.
     */
    deprecated?: boolean;
    /**
     * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)
     */
    schema?: IApiNodeShape;
}
/**
 * Data entity is the smallest description of a data in the system
 * It contains properties and associations. At least one entity describe a data model.
 * @deprecated
 */
export declare class DataEntity {
    root: DataNamespace;
    kind: string;
    key: string;
    /**
     * The description of the data namespace.
     */
    info: Thing;
    /**
     * Optional general purpose tags for the UI.
     */
    tags: string[];
    /**
     * Reserved for future use.
     *
     * The keys of the taxonomy items associated with the entity.
     */
    taxonomy: string[];
    /**
     * The list of keys of properties that belong to this entity.
     */
    properties: DataProperty[];
    /**
     * The list of keys of associations that belong to this entity.
     */
    associations: DataAssociation[];
    /**
     * The ordered list of fields (properties and associations) in the schema.
     * These only keep references to the properties and associations.
     * The order of the fields is important as it defines the order of the
     * properties in the schema.
     */
    fields: OrderedItem[];
    /**
     * The list of keys of entities that are parents to this entity.
     *
     * This potentially may cause a conflict when two parents declare the same
     * property. In such situation this entity should define own property
     * with the same name to shadow parent property. When the property is
     * not shadowed this may cause unexpected results as the processing could result
     * with inconsistent definition of a schema because the last read property wins.
     */
    parents: string[];
    /**
     * Whether this entity is deprecated.
     */
    deprecated?: boolean;
    static fromName(root: DataNamespace, name: string): DataEntity;
    /**
     * @param input The data entity definition to restore.
     */
    constructor(root: DataNamespace, input?: string | IDataEntity);
    new(init: IDataEntity): void;
    private createOrderedFields;
    static validate(input: unknown): void;
    toJSON(): IDataEntity;
    protected _readAssociation(key: string): DataAssociation | undefined;
    protected _readProperty(key: string): DataProperty | undefined;
    /**
     * Creates a property with a passed type.
     * @param type The type of the property
     * @returns The created property
     */
    addTypedProperty(type: DataPropertyType, name?: string): DataProperty;
    /**
     * Creates a property with a passed type.
     * @param name The name of the property.
     * @returns The created property
     */
    addNamedProperty(name: string): DataProperty;
    /**
     * Removes the property from the entity and namespace definitions.
     * @param key The key of the property to remove.
     */
    removeProperty(key: string): void;
    private removeField;
    /**
     * Lists all properties for this Entity.
     * @returns The list of properties that belong to this entity.
     */
    listProperties(): DataProperty[];
    /**
     * Lists all associations for this Entity.
     * @returns The list of associations that belong to this entity.
     */
    listAssociations(): DataAssociation[];
    /**
     * Generates an ordered list of fields (properties and associations) for this entity.
     *
     * @returns The list of fields (properties and associations) that belong to this entity.
     */
    listFields(): (DataAssociation | DataProperty)[];
    /**
     * Moves the field to a new index.
     * @param key The key of the field to move.
     * @param toIndex The new index to which move the field to.
     */
    moveField(key: string, toIndex: number): void;
    /**
     * Creates an association for a given name, adds it to definitions, and returns it.
     * @param name The name of the association
     * @returns The created association
     */
    addNamedAssociation(name: string): DataAssociation;
    /**
     * Creates an association for a given target, adds it to definitions, and returns it.
     *
     * @param target The target entity key of the association
     * @param namespace The target entity namespace when different to the current namespace.
     * @param name Optional name.
     * @returns The created association
     */
    addTargetAssociation(target: string | DataEntity, name?: string): DataAssociation;
    /**
     * Creates an association for a given target that is in another namespace
     * @param target The target entity key of the association
     * @param namespace The target entity namespace when different to the current namespace.
     * @param name Optional name.
     * @returns The created association
     */
    addForeignAssociation(target: string | DataEntity, namespace: string, name?: string): DataAssociation;
    /**
     * Removes an association from the entity and, namespace definitions.
     * @param key The key of the association to remove.
     */
    removeAssociation(key: string): void;
    /**
     * Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all
     * parents in the inheritance chain in no particular order.
     * @param recursive Whether to include parent's parents as well.
     */
    getComputedParents(recursive?: boolean): DataEntity[];
    /**
     * Computes list of all children, inside the root namespace, that extends this entity.
     * The children are not ordered.
     */
    getComputedChildren(): DataEntity[];
    /**
     * Computes a list of entities that are associated with the current entity.
     * This is the association-out (out-edge) direction.
     */
    getComputedAssociations(): DataEntity[];
    /**
     * Removes self from the namespace with all properties and attributes.
     */
    remove(opts?: DataDomainRemoveOptions): void;
    /**
     * @deprecated Use the `getParentInstance()` method instead.
     */
    getParent(): DataModel | undefined;
    /**
     * Returns a parent data model where this entity exist.
     */
    getParentInstance(): DataModel | undefined;
    /**
     * Adds a parent reference to this entity.
     * This will not add the parent to the namespace. It only adds a reference to the parent.
     * @param key The key of the parent entity to add.
     * @returns `this` for chaining.
     */
    addParent(key: string): this;
    /**
     * Removes a parent reference from this entity.
     * It keeps the parent as is.
     *
     * @param key The key of the parent entity to remove.
     * @throws ValidationError when the parent is not found.
     * @returns Self for chaining.
     */
    removeParent(key: string): this;
    /**
     * Checks if the entity has a circular parent relationship when attempting to add a new parent.
     * @param key The key of the parent being added.
     * @returns true if adding this parent would create a circular relationship.
     */
    hasCircularParent(key: string): boolean;
    /**
     * Tests whether one entity is associated with another.
     *
     * @param entity1 The source entity
     * @param entity2 The target entity
     * @returns true when there's any path from one entity to another.
     */
    static isAssociated(entity1: DataEntity, entity2: DataEntity): boolean;
    /**
     * Tests whether this entity is somehow associated with another entity.
     * @param target The key of the target entity to test for association with.
     * @returns true if this entity has any association to the `target` entity.
     */
    isAssociated(target: string): boolean;
    /**
     * Prints out all associations from one entity to another through all entities that may be in between.
     * @param toEntity The key to the target entity
     * @yields The path containing keys of entities from this entity to the `toEntity`
     * (inclusive) and all entities in between.
     */
    associationPath(toEntity: string): Generator<string[]>;
    /**
     * Returns a list of entities that are associated with this entity as a target.
     *
     * This method identifies entities that have an association where this entity is a target.
     * In other words, it finds entities that "point to" this entity through an association.
     *
     * For example, consider the following relationships:
     *
     * ```plain
     * A -> B  (A has an association that targets B)
     * C -> B  (C has an association that targets B)
     * B -> D  (B has an association that targets D)
     *
     * Calling `getRelatedEntities()` on B would return [A, C]
     * Calling `getRelatedEntities()` on D would return [B]
     * Calling `getRelatedEntities()` on A would return []
     * ```
     *
     * Note, this method only returns entities that are directly associated with this entity as a target.
     * It does not traverse the association graph to find indirectly related entities.
     *
     * @returns An array of `DataEntity` instances that have an association targeting this entity.
     */
    getRelatedEntities(): DataEntity[];
    static getRelatedEntities(namespace: DataNamespace, entityKey: string): DataEntity[];
    /**
     * Creates breadcrumbs from this entity to the root namespace.
     */
    breadcrumbs(): FileBreadcrumb[];
    /**
     * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.
     *
     * Note, it does nothing when the tag is already defined.
     *
     * @param tag The tag to add.
     */
    addTag(tag: string): void;
    /**
     * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.
     *
     * @param tag The tag to remove.
     */
    removeTag(tag: string): void;
    /**
     * Creates a Shape of AMF.
     * The property itself is auto-generated. If the `schema` is defined then it is used
     * as the `range` of the property. Otherwise basic shape is generated for the range.
     *
     * This is a preferred way of reading the AMF shape as this synchronizes changed
     * data properties with the shape definition.
     *
     * @returns AMF property shape definition.
     */
    toApiShape(): IShapeUnion;
    /**
     * Reads the schema of the Entity and generates an example for it.
     */
    toExample(mime: string, opts?: IShapeRenderOptions): string | number | boolean | null | undefined;
    hasClosedCycle(rootEntity: string, targetEntity: string): boolean;
    /**
     * Checks whether the entity is a child of the given namespace or data model.
     * The relationship doesn't have to be direct, as long as the entity is in the hierarchy it will return true.
     *
     * @param key The key of the parent to check.
     * @returns True if this entity is a child of the given namespace or data model.
     */
    isChildOf(key: string): boolean;
}
export {};
//# sourceMappingURL=DataEntity.d.ts.map