UNPKG

@itwin/ecschema-metadata

Version:

ECObjects core concepts in typescript

206 lines • 9.36 kB
/** @packageDocumentation * @module Metadata */ import { RelationshipClassProps, RelationshipConstraintProps } from "../Deserialization/JsonProps"; import { ECClassModifier, RelationshipEnd, SchemaItemType, StrengthDirection, StrengthType } from "../ECObjects"; import { LazyLoadedRelationshipConstraintClass } from "../Interfaces"; import { ECClass } from "./Class"; import { CustomAttribute, CustomAttributeContainerProps, CustomAttributeSet } from "./CustomAttribute"; import { NavigationProperty } from "./Property"; import { Schema } from "./Schema"; import { SchemaItem } from "./SchemaItem"; /** * A Typescript class representation of a ECRelationshipClass. * @public @preview */ export declare class RelationshipClass extends ECClass { readonly schemaItemType: SchemaItemType; /** @internal */ static get schemaItemType(): SchemaItemType; /** @internal */ protected _strength: StrengthType; /** @internal */ protected _strengthDirection: StrengthDirection; /** @internal */ protected _source: RelationshipConstraint; /** @internal */ protected _target: RelationshipConstraint; /** @internal */ constructor(schema: Schema, name: string, modifier?: ECClassModifier); get strength(): StrengthType; get strengthDirection(): StrengthDirection; get source(): RelationshipConstraint; get target(): RelationshipConstraint; /** * * @param name * @param relationship * @param direction * @internal */ protected createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>; /** @internal */ protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty; /** * @internal Used for schema editing. */ protected setStrength(strength: StrengthType): void; /** * @internal Used for schema editing. */ protected setStrengthDirection(direction: StrengthDirection): void; /** * @internal Used for schema editing. */ protected setSourceConstraint(source: RelationshipConstraint): void; /** * @internal Used for schema editing. */ protected setTargetConstraint(target: RelationshipConstraint): void; /** * Save this RelationshipClass's properties to an object for serializing to JSON. * @param standalone Serialization includes only this object (as opposed to the full schema). * @param includeSchemaVersion Include the Schema's version information in the serialized object. */ toJSON(standalone?: boolean, includeSchemaVersion?: boolean): RelationshipClassProps; /** @internal */ toXml(schemaXml: Document): Promise<Element>; fromJSONSync(relationshipClassProps: RelationshipClassProps): void; fromJSON(relationshipClassProps: RelationshipClassProps): Promise<void>; /** * Type guard to check if the SchemaItem is of type RelationshipClass. * @param item The SchemaItem to check. * @returns True if the item is a RelationshipClass, false otherwise. */ static isRelationshipClass(item?: SchemaItem): item is RelationshipClass; /** * Type assertion to check if the SchemaItem is of type RelationshipClass. * @param item The SchemaItem to check. * @returns The item cast to RelationshipClass if it is a RelationshipClass, undefined otherwise. * @internal */ static assertIsRelationshipClass(item?: SchemaItem): asserts item is RelationshipClass; } /** * A Typescript class representation of a ECRelationshipConstraint. * @public @preview */ export declare class RelationshipConstraint implements CustomAttributeContainerProps { private _abstractConstraint?; private _relationshipClass; private _relationshipEnd; private _multiplicity?; private _polymorphic?; private _roleLabel?; private _constraintClasses?; private _customAttributes?; /** @internal */ constructor(relClass: RelationshipClass, relEnd: RelationshipEnd, roleLabel?: string, polymorphic?: boolean); get multiplicity(): RelationshipMultiplicity; get polymorphic(): boolean; get roleLabel(): string | undefined; get constraintClasses(): ReadonlyArray<LazyLoadedRelationshipConstraintClass> | undefined; get relationshipClass(): RelationshipClass; get relationshipEnd(): RelationshipEnd; get customAttributes(): CustomAttributeSet | undefined; /** Returns the constraint name, ie. 'RelationshipName.Source/Target' */ get fullName(): string; /** Returns the schema of the RelationshipClass. */ get schema(): Schema; get abstractConstraint(): LazyLoadedRelationshipConstraintClass | undefined; /** * True if this RelationshipConstraint is the Source relationship end. */ get isSource(): boolean; /** * Adds the provided class as a constraint class to this constraint. * @param constraint The class to add as a constraint class. * @internal */ addClass(constraint: LazyLoadedRelationshipConstraintClass): void; /** * Removes the provided class as a constraint class from this constraint. * @param constraint The class to add as a constraint class. * * @internal */ protected removeClass(constraint: LazyLoadedRelationshipConstraintClass): void; /** * Save this RelationshipConstraint's properties to an object for serializing to JSON. */ toJSON(): RelationshipConstraintProps; /** @internal */ toXml(schemaXml: Document): Promise<Element>; fromJSONSync(relationshipConstraintProps: RelationshipConstraintProps): void; fromJSON(relationshipConstraintProps: RelationshipConstraintProps): Promise<void>; /** * Indicates if the provided [[ECClass]] is supported by this [[RelationshipConstraint]]. * @param ecClass The class to check. */ supportsClass(ecClass: ECClass): Promise<boolean>; /** * Indicates if an ECClass is of the type or applies to the type (if a mixin) of the ECClass specified by the constraintClass parameter. * @param constraintClass The ECClass that is a constraint class of a relationship. * @param testClass The ECClass to check against the constraint class. * @param isPolymorphic Indicates if the testClass should be checked polymorphically. */ static classCompatibleWithConstraint(constraintClass: ECClass, testClass: ECClass, isPolymorphic: boolean): Promise<boolean>; /** * @internal */ static isRelationshipConstraint(object: any): object is RelationshipConstraint; /** @internal */ protected addCustomAttribute(customAttribute: CustomAttribute): void; /** @internal */ protected setRoleLabel(roleLabel: string | undefined): void; /** @internal */ protected setRelationshipEnd(relationshipEnd: RelationshipEnd): void; /** @internal */ protected setPolymorphic(polymorphic: boolean): void; /** @internal */ protected setMultiplicity(multiplicity: RelationshipMultiplicity): void; /** @internal */ protected setAbstractConstraint(abstractConstraint: LazyLoadedRelationshipConstraintClass | undefined): void; } /** * Hackish approach that works like a "friend class" so we can access protected members without making them public. * @internal */ export declare abstract class MutableRelationshipConstraint extends RelationshipConstraint { abstract addCustomAttribute(customAttribute: CustomAttribute): void; abstract setRoleLabel(roleLabel: string | undefined): void; abstract setRelationshipEnd(relationshipEnd: RelationshipEnd): void; abstract setPolymorphic(polymorphic: boolean): void; abstract setMultiplicity(multiplicity: RelationshipMultiplicity): void; abstract setAbstractConstraint(abstractConstraint: LazyLoadedRelationshipConstraintClass | undefined): void; } /** * @public @preview */ export declare class RelationshipMultiplicity { static readonly zeroOne: RelationshipMultiplicity; static readonly zeroMany: RelationshipMultiplicity; static readonly oneOne: RelationshipMultiplicity; static readonly oneMany: RelationshipMultiplicity; readonly lowerLimit: number; readonly upperLimit: number; /** @internal */ constructor(lowerLimit: number, upperLimit: number); static fromString(str: string): RelationshipMultiplicity | undefined; equals(rhs: RelationshipMultiplicity): boolean; toString(): string; } /** * @internal * An abstract class used for schema editing. */ export declare abstract class MutableRelationshipClass extends RelationshipClass { get source(): MutableRelationshipConstraint; get target(): MutableRelationshipConstraint; abstract setStrength(strength: StrengthType): void; abstract setStrengthDirection(direction: StrengthDirection): void; abstract createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>; abstract createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty; abstract setDisplayLabel(displayLabel: string): void; } //# sourceMappingURL=RelationshipClass.d.ts.map