UNPKG

@itwin/core-backend

Version:
164 lines • 8.44 kB
/** @packageDocumentation * @module ElementAspects */ import { ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement } from "@itwin/core-common"; import { Entity } from "./Entity"; import { IModelDb } from "./IModelDb"; import { Id64String } from "@itwin/core-bentley"; /** Argument for the `ElementAspect.onXxx` static methods * @beta */ export interface OnAspectArg { /** The iModel for the aspect affected by this event. */ iModel: IModelDb; /** The model for the aspect affected by this event */ model: Id64String; } /** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated. * @beta */ export interface OnAspectPropsArg extends OnAspectArg { /** The new properties of the aspect affected by this event. */ props: Readonly<ElementAspectProps>; } /** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect. * @beta */ export interface OnAspectIdArg extends OnAspectArg { /** The Id of the aspect affected by this event */ aspectId: Id64String; } /** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element. * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted. * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly. * @public @preview */ export declare class ElementAspect extends Entity { static get className(): string; element: RelatedElement; /** Construct an aspect from its JSON representation and its containing iModel. */ constructor(props: ElementAspectProps, iModel: IModelDb); toJSON(): ElementAspectProps; /** Called before a new ElementAspect is inserted. * @note throw an exception to disallow the insert * @note If you override this method, you must call super. * @beta */ protected static onInsert(arg: OnAspectPropsArg): void; /** Called after a new ElementAspect was inserted. * @note If you override this method, you must call super. * @beta */ protected static onInserted(_arg: OnAspectPropsArg): void; /** Called before an ElementAspect is updated. * @note throw an exception to disallow the update * @note If you override this method, you must call super. * @beta */ protected static onUpdate(arg: OnAspectPropsArg): void; /** Called after an ElementAspect was updated. * @note If you override this method, you must call super. * @beta */ protected static onUpdated(_arg: OnAspectPropsArg): void; /** Called before an ElementAspect is deleted. * @note throw an exception to disallow the delete * @note If you override this method, you must call super. * @beta */ protected static onDelete(arg: OnAspectIdArg): void; /** Called after an ElementAspect was deleted. * @note If you override this method, you must call super. * @beta */ protected static onDeleted(_arg: OnAspectIdArg): void; } /** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element. * @public @preview */ export declare class ElementUniqueAspect extends ElementAspect { static get className(): string; } /** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element. * @public @preview */ export declare class ElementMultiAspect extends ElementAspect { static get className(): string; } /** * @public @preview */ export declare class ChannelRootAspect extends ElementUniqueAspect { static get className(): string; /** Insert a ChannelRootAspect on the specified element. * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use [[ChannelControl.makeChannelRoot]]. This method does not enforce the rule that channels may not nest and is therefore dangerous. */ static insert(iModel: IModelDb, ownerId: Id64String, channelName: string): void; } /** An ElementMultiAspect that stores synchronization information for an Element originating from an external source. * @note The associated ECClass was added to the BisCore schema in version 1.0.2 * @public @preview */ export declare class ExternalSourceAspect extends ElementMultiAspect { static get className(): string; /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source. * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid. * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change. */ scope: RelatedElement; /** The identifier of the object in the source repository. */ identifier: string; /** The kind of object within the source repository. */ kind: string; /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */ checksum?: string; /** An optional value that is typically a version number or a pseudo version number like last modified time. * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided. * If present, this value must be guaranteed to change when any of the source object's content changes. */ version?: string; /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process. * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel. * This will be a breaking change, since application code will have to change from supplying a string to supplying an object. */ jsonProperties?: string; /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */ source?: RelatedElement; /** Construct an aspect from its JSON representation and its containing iModel. */ constructor(props: ExternalSourceAspectProps, iModel: IModelDb); /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier. * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element. * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier. * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier. * Therefore, the result array could have more than one entry with the same elementId. * Aspects are never shared. Each aspect has its own unique ECInstanceId. * @param iModelDb The iModel to query * @param scope The scope of the ExternalSourceAspects to find * @param kind The kind of the ExternalSourceAspects to find * @param identifier The identifier of the ExternalSourceAspects to find * @returns the query results */ static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String; aspectId: Id64String; }>; toJSON(): ExternalSourceAspectProps; protected collectReferenceIds(referenceIds: EntityReferenceSet): void; } /** @public @preview */ export declare namespace ExternalSourceAspect { /** Standard values for the `Kind` property of `ExternalSourceAspect`. * @public @preview */ enum Kind { /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */ Element = "Element", /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */ Relationship = "Relationship", /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance * @see [[ExternalSourceAspect.scope]] */ Scope = "Scope" } } //# sourceMappingURL=ElementAspect.d.ts.map