import { TypeAnnotation } from "typedb-protocol/proto/concept"; import { Stream } from "../../../common/util/Stream"; import { TypeDBTransaction } from "../../connection/TypeDBTransaction"; import { Concept } from "../Concept"; import { Thing } from "../thing/Thing"; import { AttributeType } from "./AttributeType"; import { RoleType } from "./RoleType"; import { Type } from "./Type"; import Transitivity = Concept.Transitivity; import Annotation = ThingType.Annotation; export interface ThingType extends Type { /** * Retrieves the most immediate supertype of the ThingType. * * ### Examples * * ```ts * thingType.getSupertype(transaction) * ``` * * @param transaction - The current transaction */ getSupertype(transaction: TypeDBTransaction): Promise; /** * Retrieves all supertypes of the ThingType. * * ### Examples * * ```ts * thingType.getSupertypes(transaction) * ``` * * @param transaction - The current transaction */ getSupertypes(transaction: TypeDBTransaction): Stream; /** * Retrieves all direct and indirect subtypes of the ThingType. * Equivalent to getSubtypes(transaction, Transitivity.TRANSITIVE) * * ### Examples * * ```ts * thingType.getSubtypes(transaction) * ``` * * @param transaction - The current transaction */ getSubtypes(transaction: TypeDBTransaction): Stream; /** * Retrieves all direct and indirect (or direct only) subtypes of the ThingType. * * ### Examples * * ```ts * thingType.getSubtypes(transaction, Transitivity.EXPLICIT) * ``` * * @param transaction - The current transaction * @param transitivity - Transitivity.TRANSITIVE for direct and indirect subtypes, Transitivity.EXPLICIT for direct subtypes only */ getSubtypes(transaction: TypeDBTransaction, transitivity: Transitivity): Stream; /** * Retrieves all direct and indirect Thing objects that are instances of this ThingType. * Equivalent to getInstances(transaction, Transitivity.TRANSITIVE) * * ### Examples * * ```ts * thingType.getInstances(transaction) * ``` * * @param transaction - The current transaction */ getInstances(transaction: TypeDBTransaction): Stream; /** * Retrieves all direct and indirect (or direct only) Thing objects that are instances of this ThingType. * * ### Examples * * ```ts * thingType.getInstances(transaction, Transitivity.EXPLICIT) * ``` * * @param transaction - The current transaction * @param transitivity - Transitivity.TRANSITIVE for direct and indirect instances, Transitivity.EXPLICIT for direct instances only */ getInstances(transaction: TypeDBTransaction, transitivity: Transitivity): Stream; /** * Set a ThingType to be abstract, meaning it cannot have instances. * * ### Examples * * ```ts * thingType.setAbstract(transaction) * ``` * * @param transaction - The current transaction */ setAbstract(transaction: TypeDBTransaction): Promise; /** * Set a ThingType to be non-abstract, meaning it can have instances. * * ### Examples * * ```ts * thingType.unsetAbstract(transaction) * ``` * * @param transaction - The current transaction */ unsetAbstract(transaction: TypeDBTransaction): Promise; /** {@inheritDoc ThingType#getOwns:(7)} */ getOwns(transaction: TypeDBTransaction): Stream; /** {@inheritDoc ThingType#getOwns:(7)} */ getOwns(transaction: TypeDBTransaction, valueType: Concept.ValueType): Stream; /** {@inheritDoc ThingType#getOwns:(7)} */ getOwns(transaction: TypeDBTransaction, annotations: Annotation[]): Stream; /** {@inheritDoc ThingType#getOwns:(7)} */ getOwns(transaction: TypeDBTransaction, valueType: Concept.ValueType, annotations: Annotation[]): Stream; /** {@inheritDoc ThingType#getOwns:(7)} */ getOwns(transaction: TypeDBTransaction, transitivity: Transitivity): Stream; /** {@inheritDoc ThingType#getOwns:(7)} */ getOwns(transaction: TypeDBTransaction, valueType: Concept.ValueType, transitivity: Transitivity): Stream; /** {@inheritDoc ThingType#getOwns:(7)} */ getOwns(transaction: TypeDBTransaction, annotations: Annotation[], transitivity: Transitivity): Stream; /** * Retrieves AttributeType that the instances of this ThingType are allowed to own directly or via inheritance. * * ### Examples * * ```ts * thingType.getOwns(transaction) * thingType.getOwns(transaction, valueType, Transitivity.EXPLICIT,[Annotation.KEY]) * ``` * * @param transaction - The current transaction * @param valueType - If specified, only attribute types of this ValueType will be retrieved. * @param transitivity - Transitivity.TRANSITIVE for direct and inherited ownership, Transitivity.EXPLICIT for direct ownership only * @param annotations - Only retrieve attribute types owned with annotations. */ getOwns(transaction: TypeDBTransaction, valueType: Concept.ValueType, annotations: Annotation[], transitivity: Transitivity): Stream; /** * Retrieves an AttributeType, ownership of which is overridden for this ThingType by a given attribute_type. * * ### Examples * * ```ts * thingType.getOwnsOverridden(transaction, attributeType) * ``` * * @param transaction - The current transaction * @param attributeType - The AttributeType that overrides requested AttributeType */ getOwnsOverridden(transaction: TypeDBTransaction, attributeType: AttributeType): Promise; /** {@inheritDoc ThingType#setOwns:(3)} */ setOwns(transaction: TypeDBTransaction, attributeType: AttributeType): Promise; /** {@inheritDoc ThingType#setOwns:(3)} */ setOwns(transaction: TypeDBTransaction, attributeType: AttributeType, annotations: Annotation[]): Promise; /** {@inheritDoc ThingType#setOwns:(3)} */ setOwns(transaction: TypeDBTransaction, attributeType: AttributeType, overriddenType: AttributeType): Promise; /** * Allows the instances of this ThingType to own the given AttributeType. * * ### Examples * * ```ts * thingType.setOwns(transaction, attributeType) * thingType.setOwns(transaction, attributeType, overriddenType,[Annotation.KEY]) * ``` * * @param transaction - The current transaction * @param attributeType - The AttributeType to be owned by the instances of this type. * @param overriddenType - The AttributeType that this attribute ownership overrides, if applicable. * @param annotations - Adds annotations to the ownership. */ setOwns(transaction: TypeDBTransaction, attributeType: AttributeType, overriddenType: AttributeType, annotations: Annotation[]): Promise; /** * Disallows the instances of this ThingType from owning the given AttributeType. * * ### Examples * * ```ts * thingType.unsetOwns(transaction, attributeType) * ``` * * @param transaction - The current transaction * @param attributeType - The AttributeType to not be owned by the type. */ unsetOwns(transaction: TypeDBTransaction, attributeType: AttributeType): Promise; /** {@inheritDoc ThingType#getPlays:(1)} */ getPlays(transaction: TypeDBTransaction): Stream; /** * Retrieves all direct and inherited (or direct only) roles that are allowed to be played by the instances of this ThingType. * * ### Examples * * ```ts * thingType.getPlays(transaction) * thingType.getPlays(transaction, Transitivity.EXPLICIT) * ``` * * @param transaction - The current transaction * @param transitivity - Transitivity.TRANSITIVE for direct and indirect playing, Transitivity.EXPLICIT for direct playing only */ getPlays(transaction: TypeDBTransaction, transitivity: Transitivity): Stream; /** * Retrieves a RoleType that is overridden by the given role_type for this ThingType. * * ### Examples * * ```ts * thingType.getPlaysOverridden(transaction, role) * ``` * * @param transaction - The current transaction * @param role - The RoleType that overrides an inherited role */ getPlaysOverridden(transaction: TypeDBTransaction, role: RoleType): Promise; /** {@inheritDoc ThingType#setPlays:(1)} */ setPlays(transaction: TypeDBTransaction, role: RoleType): Promise; /** * Allows the instances of this ThingType to play the given role. * * ### Examples * * ```ts * thingType.setPlays(transaction, role) * thingType.setPlays(transaction, role, overriddenType) * ``` * * @param transaction - The current transaction * @param role - The role to be played by the instances of this type * @param overriddenType - The role type that this role overrides, if applicable */ setPlays(transaction: TypeDBTransaction, role: RoleType, overriddenType: RoleType): Promise; /** * Disallows the instances of this ThingType from playing the given role. * * ### Examples * * ```ts * thingType.unsetPlays(transaction, role) * ``` * * @param transaction - The current transaction * @param role - The role to not be played by the instances of this type. */ unsetPlays(transaction: TypeDBTransaction, role: RoleType): Promise; /** * Produces a pattern for creating this ThingType in a define query. * * ### Examples * * ```ts * thingType.getSyntax(transaction) * ``` * * @param transaction - The current transaction */ getSyntax(transaction: TypeDBTransaction): Promise; } export declare namespace ThingType { const NAME = "thing"; function proto(thing_type: ThingType): import("typedb-protocol/proto/concept").ThingType; /** Annotations for ownership declarations. */ class Annotation { /** Annotation to specify the attribute owned is a KEY */ static KEY: Annotation; /** Annotation to specify the owned is UNIQUE */ static UNIQUE: Annotation; private readonly name; /** @ignore */ private constructor(); /** * Returns the relevant Annotation given the name as a string * @param string - name of the attribute as a string. e.g.: "key", "unique" */ static parse(string: string): Annotation; /** Printable string */ toString(): string; } namespace Annotation { function proto(annotation: Annotation): TypeAnnotation; } }