UNPKG

@itwin/core-frontend

Version:
594 lines • 39.4 kB
/** @packageDocumentation * @module IModelConnection */ import { BeEvent, CompressedId64Set, GuidString, Id64Arg, Id64Set, Id64String, PickAsyncMethods, TransientIdSequence } from "@itwin/core-bentley"; import { Cartographic, CodeProps, CodeSpec, EcefLocationProps, ECSqlReader, ElementLoadOptions, ElementMeshRequestProps, ElementProps, EntityQueryParams, FontMap, GeographicCRSProps, GeometryContainmentRequestProps, GeometryContainmentResponseProps, GeometrySummaryRequestProps, IModel, IModelConnectionProps, MassPropertiesPerCandidateRequestProps, MassPropertiesPerCandidateResponseProps, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelExtentsProps, ModelProps, ModelQueryParams, Placement, QueryBinder, QueryOptions, SnapRequestProps, SnapResponseProps, SubCategoryAppearance, SubCategoryResultRow, TextureData, TextureLoadProps, ViewDefinitionProps, ViewIdString, ViewQueryParams, ViewStateProps, ViewStoreRpc } from "@itwin/core-common"; import { Point3d, Range3dProps, Transform, XYAndZ, XYZProps } from "@itwin/core-geometry"; import { BriefcaseConnection } from "./BriefcaseConnection"; import { CheckpointConnection } from "./CheckpointConnection"; import { EntityState } from "./EntityState"; import { GeoServices } from "./GeoServices"; import { IModelRoutingContext } from "./IModelRoutingContext"; import { ModelState } from "./ModelState"; import { HiliteSet, SelectionSet } from "./SelectionSet"; import { SubCategoriesCache } from "./SubCategoriesCache"; import { Tiles } from "./Tiles"; import { ViewState } from "./ViewState"; import { _requestSnap } from "./common/internal/Symbols"; import { SchemaContext } from "@itwin/ecschema-metadata"; /** The properties for creating a [Blank IModelConnection]($docs/learning/frontend/BlankConnection) * @public */ export interface BlankConnectionProps { /** A name for this blank connection. */ name: string; /** The spatial location for the blank connection. */ location: Cartographic | EcefLocationProps; /** The volume of interest, in meters, centered around `location` */ extents: Range3dProps; /** An offset to be applied to all spatial coordinates. */ globalOrigin?: XYZProps; /** The optional Guid that identifies the iTwin associated with the [[BlankConnection]]. */ iTwinId?: GuidString; } /** A connection to a [IModelDb]($backend) hosted on the backend. * @public * @extensions */ export declare abstract class IModelConnection extends IModel { /** The [[ModelState]]s in this IModelConnection. */ readonly models: IModelConnection.Models; /** The [[ElementState]]s in this IModelConnection. */ readonly elements: IModelConnection.Elements; /** The [[CodeSpec]]s in this IModelConnection. */ readonly codeSpecs: IModelConnection.CodeSpecs; /** The [[ViewState]]s in this IModelConnection. */ readonly views: IModelConnection.Views; /** The set of currently hilited elements for this IModelConnection. */ readonly hilited: HiliteSet; /** The set of currently selected elements for this IModelConnection. */ readonly selectionSet: SelectionSet; /** The set of Tiles for this IModelConnection. */ readonly tiles: Tiles; /** The set of [Category]($backend)'s in this IModelConnection. */ readonly categories: IModelConnection.Categories; /** A cache of information about SubCategories chiefly used for rendering. * @internal */ get subcategories(): SubCategoriesCache; /** Generator for unique Ids of transient graphics for this IModelConnection. */ readonly transientIds: TransientIdSequence; /** The Geographic location services available for this iModelConnection. */ readonly geoServices: GeoServices; /** @internal Whether GCS has been disabled for this iModelConnection. */ protected _gcsDisabled: boolean; /** @internal Return true if a GCS is not defined for this iModelConnection; also returns true if GCS is defined but disabled. */ get noGcsDefined(): boolean; /** @internal */ disableGCS(disable: boolean): void; /** The maximum time (in milliseconds) to wait before timing out the request to open a connection to a new iModel */ static connectionTimeout: number; /** The RPC routing for this connection. */ routingContext: IModelRoutingContext; /** Type guard for instanceof [[BriefcaseConnection]] */ isBriefcaseConnection(): this is BriefcaseConnection; /** Type guard for instanceof [[CheckpointConnection]] * @beta */ isCheckpointConnection(): this is CheckpointConnection; /** Type guard for instanceof [[SnapshotConnection]] */ isSnapshotConnection(): this is SnapshotConnection; /** Type guard for instanceof [[BlankConnection]] */ isBlankConnection(): this is BlankConnection; /** Returns `true` if this is a briefcase copy of an iModel that is synchronized with iModelHub. */ get isBriefcase(): boolean; /** Returns `true` if this is a *snapshot* iModel. * @see [[SnapshotConnection.openSnapshot]] */ get isSnapshot(): boolean; /** True if this is a [Blank Connection]($docs/learning/frontend/BlankConnection). */ get isBlank(): boolean; /** Check the [[openMode]] of this IModelConnection to see if it was opened read-only. */ get isReadonly(): boolean; /** Check if the IModelConnection is open (i.e. it has a *connection* to a backend server). * Returns false for [[BlankConnection]] instances and after [[IModelConnection.close]] has been called. * @note no RPC operations are valid on this IModelConnection if this method returns false. */ get isOpen(): boolean; /** Check if the IModelConnection is closed (i.e. it has no *connection* to a backend server). * Returns true for [[BlankConnection]] instances and after [[IModelConnection.close]] has been called. * @note no RPC operations are valid on this IModelConnection if this method returns true. */ abstract get isClosed(): boolean; /** Event raised immediately before *any* IModelConnection is [[close]]d. * @note This static event is raised when *any* IModelConnection is closed, and the specific IModelConnection is passed as its argument. To * monitor closing a specific IModelConnection, listen for the `onClose` instance event instead. * @note Be careful not to perform any asynchronous operations on the IModelConnection because it will close before they are processed. */ static readonly onClose: BeEvent<(_imodel: IModelConnection) => void>; /** Event called immediately after *any* IModelConnection is opened. */ static readonly onOpen: BeEvent<(_imodel: IModelConnection) => void>; /** Event raised immediately before this IModelConnection is [[close]]d. * @note This event is raised only for this specific IModelConnection. To monitor *all* IModelConnections, listen for the static `onClose` event instead. * @note Be careful not to perform any asynchronous operations on the IModelConnection because it will close before they are processed. */ readonly onClose: BeEvent<(_imodel: IModelConnection) => void>; /** The font map for this IModelConnection. Only valid after calling #loadFontMap and waiting for the returned promise to be fulfilled. * @deprecated in 5.0.0 - will not be removed until after 2026-06-13. If you need font Ids on the front-end for some reason, write an Ipc method that queries [IModelDb.fonts]($backend). */ fontMap?: FontMap; private _schemaContext?; /** Load the FontMap for this IModelConnection. * @returns Returns a Promise<FontMap> that is fulfilled when the FontMap member of this IModelConnection is valid. * @deprecated in 5.0.0 - will not be removed until after 2026-06-13. If you need font Ids on the front-end for some reason, write an Ipc method that queries [IModelDb.fonts]($backend). */ loadFontMap(): Promise<FontMap>; /** Find the first registered base class of the given EntityState className. This class will "handle" the State for the supplied className. * @param className The full name of the class of interest. * @param defaultClass If no base class of the className is registered, return this value. * @note this method is async since it may have to query the server to get the class hierarchy. */ findClassFor<T extends typeof EntityState>(className: string, defaultClass: T | undefined): Promise<T | undefined>; /** @internal */ protected constructor(iModelProps: IModelConnectionProps); /** Called prior to connection closing. Raises close events and calls tiles.dispose. * @internal */ protected beforeClose(): void; /** Close this IModelConnection. */ abstract close(): Promise<void>; /** Allow to execute query and read results along with meta data. The result are streamed. * * See also: * - [ECSQL Overview]($docs/learning/frontend/ExecutingECSQL) * - [Code Examples]($docs/learning/frontend/ECSQLCodeExamples) * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat) * * @param params The values to bind to the parameters (if the ECSQL has any). * @param config Allow to specify certain flags which control how query is executed. * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata. * @public * */ createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader; /** * queries the BisCore.SubCategory table for the entries that are children of the passed categoryIds * @param compressedCategoryIds compressed category Ids * @returns array of SubCategoryResultRow * @internal */ querySubCategories(compressedCategoryIds: CompressedId64Set): Promise<SubCategoryResultRow[]>; /** * queries the BisCore.SubCategory table for entries that are children of used spatial categories and 3D elements. * @returns array of SubCategoryResultRow * @internal */ queryAllUsedSpatialSubCategories(): Promise<SubCategoryResultRow[]>; /** Query for a set of element ids that satisfy the supplied query params * @param params The query parameters. The `limit` and `offset` members should be used to page results. * @throws [IModelError]($common) If the generated statement is invalid or would return too many rows. */ queryEntityIds(params: EntityQueryParams): Promise<Id64Set>; private _snapRpc; /** Request a snap from the backend. * @note callers must gracefully handle Promise rejected with AbandonedError * @internal */ [_requestSnap](props: SnapRequestProps): Promise<SnapResponseProps>; /** @internal * @deprecated in 4.8 - will not be removed until after 2026-06-13. Use AccuSnap.doSnapRequest. */ requestSnap(props: SnapRequestProps): Promise<SnapResponseProps>; private _toolTipRpc; /** Request a tooltip from the backend. * @note If another call to this method occurs before preceding call(s) return, all preceding calls will be abandoned - only the most recent will resolve. Therefore callers must gracefully handle Promise rejected with AbandonedError. */ getToolTipMessage(id: Id64String): Promise<string[]>; /** Request element clip containment status from the backend. */ getGeometryContainment(requestProps: GeometryContainmentRequestProps): Promise<GeometryContainmentResponseProps>; /** Obtain a summary of the geometry belonging to one or more [GeometricElement]($backend)s suitable for debugging and diagnostics. * @param requestProps Specifies the elements to query and options for how to format the output. * @returns A string containing the summary, typically consisting of multiple lines. * @note Trying to parse the output to programmatically inspect an element's geometry is not recommended. * @see [GeometryStreamIterator]($common) to more directly inspect a geometry stream. */ getGeometrySummary(requestProps: GeometrySummaryRequestProps): Promise<string>; /** Request a named texture image from the backend. * @param textureLoadProps The texture load properties which must contain a name property (a valid 64-bit integer identifier). It optionally can contain the maximum texture size supported by the client. * @see [[Id64]] * @public */ queryTextureData(textureLoadProps: TextureLoadProps): Promise<TextureData | undefined>; /** Request element mass properties from the backend. */ getMassProperties(requestProps: MassPropertiesRequestProps): Promise<MassPropertiesResponseProps>; /** Request mass properties for multiple elements from the backend. * @deprecated in 4.11 - will not be removed until after 2026-06-13. Use [[IModelConnection.getMassProperties]]. */ getMassPropertiesPerCandidate(requestProps: MassPropertiesPerCandidateRequestProps): Promise<MassPropertiesPerCandidateResponseProps[]>; /** Produce encoded [Polyface]($core-geometry)s from the geometry stream of a [GeometricElement]($backend). * A polyface is produced for each geometric entry in the element's geometry stream, excluding geometry like open curves that can't be converted into polyfaces. * The polyfaces can be decoded using [readElementMeshes]($common). * Symbology, UV parameters, and normal vectors are not included in the result. * @param requestProps A description of how to produce the polyfaces and from which element to obtain them. * @returns an encoded list of polyfaces that can be decoded by [readElementMeshes]($common). * @throws Error if [ElementMeshRequestProps.source]($common) does not refer to a [GeometricElement]($backend). * @note This function is intended to support limited analysis of an element's geometry as a mesh. It is not intended for producing graphics. * @see [[TileAdmin.requestElementGraphics]] to obtain meshes appropriate for display. * @beta */ generateElementMeshes(requestProps: ElementMeshRequestProps): Promise<Uint8Array>; /** Convert a point in this iModel's Spatial coordinates to a [[Cartographic]] using the Geographic location services for this IModelConnection. * @param spatial A point in the iModel's spatial coordinates * @param result If defined, use this for output * @returns A Cartographic location (Horizontal datum depends on iModel's GCS) * @throws IModelError if [[isGeoLocated]] is false or point could not be converted. * @see [[cartographicFromSpatial]] if you have more than one point to convert, or you don't know whether the iModel has a GCS. */ spatialToCartographicFromGcs(spatial: XYAndZ, result?: Cartographic): Promise<Cartographic>; /** Convert a point in this iModel's Spatial coordinates to a [[Cartographic]] using the Geographic location services for this IModelConnection or [[IModel.ecefLocation]]. * @param spatial A point in the iModel's spatial coordinates * @param result If defined, use this for output * @returns A Cartographic location (Horizontal datum depends on iModel's GCS) * @throws IModelError if [[isGeoLocated]] is false or point could not be converted. * @see [[cartographicFromSpatial]] to convert multiple points at once. * @see [[spatialToCartographicFromEcef]] to synchronously convert points using the iModel's ECEF transform. */ spatialToCartographic(spatial: XYAndZ, result?: Cartographic): Promise<Cartographic>; /** Convert points in this iModel's spatial coordinate system to [Cartographic]($common) coordinates using either a [[GeoConverter]] or the iModel's [EcefLocation]($common). * @param spatial Coordinates to be converted from the iModel's spatial coordinate system * @returns The `spatial` coordinates converted to cartographic coordinates, of the same length and order as the `spatial`. * @throws IModelError if [[isGeoLocated]] is false or any point could not be converted. * @see [[spatialFromCartographic]] to perform the inverse conversion. * @see [[spatialToCartographicFromEcef]] to synchronously convert points using the iModel's ECEF transform. */ cartographicFromSpatial(spatial: XYAndZ[]): Promise<Cartographic[]>; /** Convert points in this iModel's spatial coordinate system to [Cartographic]($common) coordinates using either a [[GeoConverter]] or the iModel's [EcefLocation]($common). * @param spatial Coordinates to be converted from the iModel's spatial coordinate system * @returns The `spatial` coordinates converted to cartographic coordinates (WGS84 horizontal datum), of the same length and order as the `spatial`. * @throws IModelError if [[isGeoLocated]] is false or any point could not be converted. * @see [[cartographicFromSpatial]] to perform conversion using iModel's GCS horizontal datum * @beta */ wgs84CartographicFromSpatial(spatial: XYAndZ[]): Promise<Cartographic[]>; /** @internal */ cartographicFromSpatialWithGcs(spatial: XYAndZ[], datumOrGCRS?: string | GeographicCRSProps): Promise<Cartographic[]>; /** Convert a [Cartographic]($common) to a point in this iModel's spatial coordinate system using a [[GeoConverter]]. * @param cartographic A cartographic location * @param result If defined, use this for output * @returns A point in this iModel's spatial coordinates * @throws IModelError if [[isGeoLocated]] is false or cartographic location could not be converted. * @see [[spatialFromCartographic]] to convert multiple points at once, or you don't know whether the iModel has a GCS. */ cartographicToSpatialFromGcs(cartographic: Cartographic, result?: Point3d): Promise<Point3d>; /** Convert a [Cartographic]($common) to a point in this iModel's Spatial coordinates using a [[GeoConverter]] or[[IModel.ecefLocation]($common). * @param cartographic A cartographic location * @param result If defined, use this for output * @returns A point in this iModel's spatial coordinates * @throws IModelError if [[isGeoLocated]] is false or cartographic location could not be converted. * @see [[spatialFromCartographic]] to convert multiple points at once. * @see [[cartographicToSpatialFromEcef]] to synchronously convert points using the iModel's ECEF transform. */ cartographicToSpatial(cartographic: Cartographic, result?: Point3d): Promise<Point3d>; /** Convert [Cartographic]($common) coordinates into points in this iModel's spatial coordinate system using a [[GeoConverter]] or the iModel's [EcefLocation]($common). * @param cartographic Coordinates to be converted to the iModel's spatial coordinate system. * @returns The `cartographic` coordinates converted to spatial coordinates, of the same length and order as `cartographic`. * @throws IModelError if [[isGeoLocated]] is false or any point could not be converted. * @see [[cartographicFromSpatial]] to perform the inverse conversion. */ spatialFromCartographic(cartographic: Cartographic[]): Promise<Point3d[]>; /** Convert geographic coordinates into points in this iModel's spatial coordinate system using a [[GeoConverter]] or the iModel's [EcefLocation]($common). * @param geoCoords Coordinates to be converted are in the coordinate system described by the `datumOrGCRS` parameter. Defaults iModel's spatial coordinate system otherwise. * @param datumOrGCRS Datum name or Geographic CRS object definition to use for the conversion. * @returns The `geographics` coordinates converted to spatial coordinates, of the same length and order as `geographics`. * @throws IModelError if [[isGeoLocated]] is false or any point could not be converted. * @beta */ toSpatialFromGcs(geoCoords: XYAndZ[], datumOrGCRS?: string | GeographicCRSProps): Promise<Point3d[]>; /** @internal */ getMapEcefToDb(bimElevationBias: number): Transform; private _geodeticToSeaLevel?; private _projectCenterAltitude?; /** Event called immediately after map elevation request is completed. This occurs only in the case where background map terrain is displayed * with either geoid or ground offset. These require a query to BingElevation and therefore synching the view may be required * when the request is completed. * @internal */ readonly onMapElevationLoaded: BeEvent<(_imodel: IModelConnection) => void>; /** The offset between sea level and the geodetic ellipsoid. This will return undefined only if the request for the offset to Bing Elevation * is required, and in this case the [[onMapElevationLoaded]] event is raised when the request is completed. * @internal */ get geodeticToSeaLevel(): number | undefined; /** The altitude (geodetic) at the project center. This will return undefined only if the request for the offset to Bing Elevation * is required, and in this case the [[onMapElevationLoaded]] event is raised when the request is completed. * @internal */ get projectCenterAltitude(): number | undefined; /** * Gets the context that allows accessing the metadata (see `@itwin/ecschema-metadata` package) of this iModel. * The context is created lazily when this property is accessed for the first time, with an `ECSchemaRpcLocater` registered as a fallback locater, enabling users to register their own locater that'd take more priority. * This means to correctly access schema context, client-side applications must register `ECSchemaRpcInterface` following instructions for [RPC configuration]($docs/learning/rpcinterface/#client-side-configuration). * Server-side applications would also [configure RPC]($docs/learning/rpcinterface/#server-side-configuration) as needed. * * @note While a `BlankConnection` returns a valid `schemaContext`, it has an invalid locater registered by default, and will throw an error when trying to call it's methods. * @beta */ get schemaContext(): SchemaContext; } /** A connection that exists without an iModel. Useful for connecting to Reality Data services. * @note This class exists because our display system requires an IModelConnection type even if only reality data is drawn. * @public */ export declare class BlankConnection extends IModelConnection { isBlankConnection(): this is BlankConnection; /** The Guid that identifies the iTwin for this BlankConnection. * @note This can also be set via the [[create]] method using [[BlankConnectionProps.iTwinId]]. */ get iTwinId(): GuidString | undefined; set iTwinId(iTwinId: GuidString | undefined); /** A BlankConnection does not have an associated iModel, so its `iModelId` is alway `undefined`. */ get iModelId(): undefined; /** A BlankConnection is always considered closed because it does not have a specific backend nor associated iModel. * @returns `true` is always returned since RPC operations and iModel queries are not valid. * @note Even though true is always returned, it is still valid to call [[close]] to dispose frontend resources. */ get isClosed(): boolean; /** Create a new [Blank IModelConnection]($docs/learning/frontend/BlankConnection). * @param props The properties to use for the new BlankConnection. */ static create(props: BlankConnectionProps): BlankConnection; /** There are no connections to the backend to close in the case of a BlankConnection. * However, there are frontend resources (like the tile cache) that can be disposed. * @note A BlankConnection should not be used after calling `close`. */ close(): Promise<void>; /** @internal */ closeSync(): void; } /** A connection to a [SnapshotDb]($backend) hosted on a backend. * @public */ export declare class SnapshotConnection extends IModelConnection { /** Type guard for instanceof [[SnapshotConnection]] */ isSnapshotConnection(): this is SnapshotConnection; /** The Guid that identifies this iModel. */ get iModelId(): GuidString; /** Returns `true` if [[close]] has already been called. */ get isClosed(): boolean; private _isClosed?; /** Returns `true` if this is a connection to a remote snapshot iModel resolved by the backend. * @see [[openRemote]] */ get isRemote(): boolean; private _isRemote?; /** Open an IModelConnection to a read-only snapshot iModel from a file name. * @note This method is intended for desktop or mobile applications and is not available for web applications. */ static openFile(filePath: string): Promise<SnapshotConnection>; /** Open an IModelConnection to a remote read-only snapshot iModel from a key that will be resolved by the backend. * @note This method is intended for web applications. * @deprecated in 4.10 - will not be removed until after 2026-06-13. Use [[CheckpointConnection.openRemote]]. */ static openRemote(fileKey: string): Promise<SnapshotConnection>; /** Close this SnapshotConnection. * @note For local snapshot files, `close` closes the connection and the underlying [SnapshotDb]($backend) database file. * For remote snapshots, `close` only closes the connection and frees any frontend resources allocated to the connection. * @see [[openFile]], [[openRemote]] */ close(): Promise<void>; } /** @public */ export declare namespace IModelConnection { /** The id/name/class of a ViewDefinition. Returned by [[IModelConnection.Views.getViewList]] */ interface ViewSpec { /** The element id of the ViewDefinition. This string may be passed to [[IModelConnection.Views.load]]. */ id: string; /** The name of the view. This string may be used to create a list with the possible view names. */ name: string; /** The fullClassName of the ViewDefinition. Useful for sorting the list of views. */ class: string; } /** The collection of loaded ModelState objects for an [[IModelConnection]]. */ class Models implements Iterable<ModelState> { private _iModel; private _loaded; /** @internal */ get loaded(): Map<string, ModelState>; /** An iterator over all currently-loaded models. */ [Symbol.iterator](): Iterator<ModelState>; /** @internal */ constructor(_iModel: IModelConnection); /** The Id of the [RepositoryModel]($backend). */ get repositoryModelId(): string; /** @internal */ getDictionaryModel(): Promise<Id64String>; /** Get a batch of [[ModelProps]] given a list of Model ids. */ getProps(modelIds: Id64Arg): Promise<ModelProps[]>; /** Find a ModelState in the set of loaded Models by ModelId. */ getLoaded(id: string): ModelState | undefined; /** Given a set of modelIds, return the subset of corresponding models that are not currently loaded. * @param modelIds The set of model Ids * @returns The subset of the supplied Ids corresponding to models that are not currently loaded, or undefined if all of the specified models are loaded. */ filterLoaded(modelIds: Id64Arg): Id64Set | undefined; /** load a set of Models by Ids. After the returned Promise resolves, you may get the ModelState objects by calling getLoadedModel. */ load(modelIds: Id64Arg): Promise<void>; /** Given an array of modelProps, find the class for each model and construct it. save it in the iModelConnection's loaded set. */ updateLoadedWithModelProps(modelProps: ModelProps[]): Promise<void>; /** Remove a model from the set of loaded models. Used internally by BriefcaseConnection in response to txn events. * @internal */ unload(modelId: Id64String): void; /** Query for a set of model ranges by ModelIds. * @param modelIds the Id or Ids of the [GeometricModel]($backend)s for which to query the ranges. * @returns An array containing the range of each model of each unique model Id, omitting the range for any Id which did no identify a GeometricModel. * @note The contents of the returned array do not follow a deterministic order. * @throws [IModelError]($common) if exactly one model Id is specified and that Id does not identify a GeometricModel. * @see [[queryExtents]] for a similar function that does not throw and produces a deterministically-ordered result. */ queryModelRanges(modelIds: Id64Arg): Promise<Range3dProps[]>; /** For each [GeometricModel]($backend) specified by Id, attempts to obtain the union of the volumes of all geometric elements within that model. * @param modelIds The Id or Ids of the geometric models for which to obtain the extents. * @returns An array of results, one per supplied Id, in the order in which the Ids were supplied. If the extents could not be obtained, the * corresponding results entry's `extents` will be a "null" range (@see [Range3d.isNull]($geometry) and its `status` will indicate * why the extents could not be obtained (e.g., because the Id did not identify a [GeometricModel]($backend)). */ queryExtents(modelIds: Id64String | Id64String[]): Promise<ModelExtentsProps[]>; /** Query for a set of ModelProps of the specified ModelQueryParams. * @param queryParams The query parameters. The `limit` and `offset` members should be used to page results. * @throws [IModelError]($common) If the generated statement is invalid or would return too many props. */ queryProps(queryParams: ModelQueryParams): Promise<ModelProps[]>; /** Asynchronously stream ModelProps using the specified ModelQueryParams. */ query(queryParams: ModelQueryParams): AsyncIterableIterator<ModelProps>; } /** Options controlling the results produced by [[IModelConnection.Elements.getPlacements]]. * @public */ interface GetPlacementsOptions { /** The types of elements for which to query [Placement]($common)s: * - "2d": Include only [GeometricElement2d]($backend)s. * - "3d": Include only [GeometricElement3d]($backend)s. * - `undefined`: Include both 2d and 3d [GeometricElement]($backend)s. */ type?: "3d" | "2d"; } /** The collection of Elements for an [[IModelConnection]]. */ class Elements { private _iModel; /** @internal */ constructor(_iModel: IModelConnection); /** The Id of the [root subject element]($docs/bis/guide/references/glossary.md#subject-root) for this iModel. */ get rootSubjectId(): Id64String; /** Get a set of element ids that satisfy a query */ queryIds(params: EntityQueryParams): Promise<Id64Set>; /** Get an array of [[ElementProps]] given one or more element ids. * @note This method returns **all** of the properties of the element (excluding GeometryStream), which may be a very large amount of data - consider using * [[IModelConnection.query]] to select only those properties of interest to limit the amount of data returned. */ getProps(arg: Id64Arg): Promise<ElementProps[]>; /** Obtain the properties of a single element, optionally specifying specific properties to include or exclude. * For example, [[getProps]] and [[queryProps]] omit the [GeometryStreamProps]($common) property of [GeometricElementProps]($common) and [GeometryPartProps]($common) * because it can be quite large and is generally not useful to frontend code. The following code requests that the geometry stream be included: * ```ts * const props = await iModel.elements.loadProps(elementId, { wantGeometry: true }); * ``` * @param identifier Identifies the element by its Id, federation Guid, or [Code]($common). * @param options Optionally includes or excludes specific properties. * @returns The properties of the requested element; or `undefined` if no element exists with the specified identifier or the iModel is not open. * @throws [IModelError]($common) if the element exists but could not be loaded. */ loadProps(identifier: Id64String | GuidString | CodeProps, options?: ElementLoadOptions): Promise<ElementProps | undefined>; /** Get an array of [[ElementProps]] that satisfy a query * @param params The query parameters. The `limit` and `offset` members should be used to page results. * @throws [IModelError]($common) If the generated statement is invalid or would return too many props. */ queryProps(params: EntityQueryParams): Promise<ElementProps[]>; /** Obtain the [Placement]($common)s of a set of [GeometricElement]($backend)s. * @param elementIds The Ids of the elements whose placements are to be queried. * @param options Options customizing how the placements are queried. * @returns an array of placements, each having an additional `elementId` property identifying the element from which the placement was obtained. * @note Any Id that does not identify a geometric element with a valid bounding box and origin is omitted from the returned array. */ getPlacements(elementIds: Iterable<Id64String>, options?: Readonly<GetPlacementsOptions>): Promise<Array<Placement & { elementId: Id64String; }>>; } /** The collection of [[CodeSpec]] entities for an [[IModelConnection]]. */ class CodeSpecs { private _iModel; /** @internal */ constructor(_iModel: IModelConnection); private _isCodeSpecProperties; private _loadCodeSpec; /** Look up a CodeSpec by Id. * @param codeSpecId The Id of the CodeSpec to load * @returns The CodeSpec with the specified Id * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found. */ getById(codeSpecId: Id64String): Promise<CodeSpec>; /** Look up a CodeSpec by name. * @param name The name of the CodeSpec to load * @returns The CodeSpec with the specified name * @throws [[IModelError]] if no CodeSpec with the specified name could be found. */ getByName(name: string): Promise<CodeSpec>; } /** The collection of views for an [[IModelConnection]]. */ class Views { private _iModel; /** @internal */ constructor(_iModel: IModelConnection); private _writeViewStoreProxy?; private _readViewStoreProxy?; get viewStoreWriter(): PickAsyncMethods<ViewStoreRpc.Writer>; get viewsStoreReader(): PickAsyncMethods<ViewStoreRpc.Reader>; /** Query for an array of ViewDefinitionProps * @param queryParams Query parameters specifying the views to return. The `limit` and `offset` members should be used to page results. * @throws [IModelError]($common) If the generated statement is invalid or would return too many props. */ queryProps(queryParams: ViewQueryParams): Promise<ViewDefinitionProps[]>; /** Get an array of the ViewSpecs for all views in this IModel that satisfy a ViewQueryParams. * * This is typically used to create a list for UI. * * For example: * ```ts * [[include:IModelConnection.Views.getSpatialViewList]] * ``` * @param queryParams The parameters for the views to find. The `limit` and `offset` members should be used to page results. * @throws [IModelError]($common) If the generated statement is invalid or would return too many props. */ getViewList(queryParams: ViewQueryParams): Promise<ViewSpec[]>; /** Query the Id of the default [ViewDefinition]($backend), if any, stored in this iModel's property table. * The default view is typically chosen by the application (such as a connector) that created the iModel. * There is no guarantee that this view will be suitable for the purposes of any other applications. * Most applications should ignore the default view and instead create a [[ViewState]] that fits their own requirements using APIs like [[ViewCreator3d]]. * @returns the Id of the default view as defined in the iModel's property table, or an invalid ID if no default view is defined. * @deprecated in 4.2 - will not be removed until after 2026-06-13. Create a ViewState to your own specifications. */ queryDefaultViewId(): Promise<Id64String>; /** Load a [[ViewState]] object from the specified [[ViewDefinition]] id. */ load(viewDefinitionId: ViewIdString): Promise<ViewState>; /** Return the [[ViewState]] object associated with the [[ViewStateProps]] passed in. */ convertViewStatePropsToViewState(viewProps: ViewStateProps): Promise<ViewState>; } /** @public */ namespace Categories { /** A subset of the information describing a [SubCategory]($backend), supplied by [[IModelConnection.Categories.getCategoryInfo]] * or [[IModelConnection.Categories.getSubCategoryInfo]]. */ interface SubCategoryInfo { /** The [SubCategory]($backend)'s element Id. */ readonly id: Id64String; /** The Id of the [Category]($backend) to which this [SubCategory]($backend) belongs. */ readonly categoryId: Id64String; /** Visual parameters applied to geometry belonging to this [SubCategory]($backend). */ readonly appearance: Readonly<SubCategoryAppearance>; } /** A subset of the information describing a [Category]($backend), supplied by [[IModelConnection.Categories.getCategoryInfo]]. */ interface CategoryInfo { /** The category's element Id. */ readonly id: Id64String; /** For each [SubCategory]($backend) belonging to this [Category]($backend), a mapping from the SubCategory's element Id to its properties. */ readonly subCategories: Map<Id64String, SubCategoryInfo>; } } /** Provides access to information about the [Category]($backend)'s stored in an [[IModelConnection]]. * This information is cached internally so that repeated requests need not query the backend. * @see [[IModelConnection.categories]] for the categories associated with a specific iModel. */ class Categories { /** @internal */ readonly cache: SubCategoriesCache; /** @internal */ constructor(iModel: IModelConnection); /** Obtain information about one or more [Category]($backend)'s. */ getCategoryInfo(categoryIds: Iterable<Id64String>): Promise<Map<Id64String, Categories.CategoryInfo>>; /** Obtain information about one or more [SubCategory]($backend)'s belonging to the specified [Category]($backend). */ getSubCategoryInfo(args: { category: Id64String; subCategories: Iterable<Id64String>; }): Promise<Map<Id64String, Categories.SubCategoryInfo>>; } } //# sourceMappingURL=IModelConnection.d.ts.map