@itwin/presentation-backend 5.14.0-dev.8 → 5.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ const Utils_js_1 = require("./Utils.js");
24
24
  /**
25
25
  * Presentation hierarchy cache mode.
26
26
  * @public
27
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
27
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
28
28
  * package for creating hierarchies.
29
29
  */
30
30
  var HierarchyCacheMode;
@@ -116,7 +116,7 @@ class PresentationManager {
116
116
  /**
117
117
  * Retrieves nodes
118
118
  * @public
119
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
119
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
120
120
  * package for creating hierarchies.
121
121
  */
122
122
  async getNodes(requestOptions) {
@@ -127,7 +127,7 @@ class PresentationManager {
127
127
  /**
128
128
  * Retrieves nodes count
129
129
  * @public
130
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
130
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
131
131
  * package for creating hierarchies.
132
132
  */
133
133
  async getNodesCount(requestOptions) {
@@ -136,7 +136,7 @@ class PresentationManager {
136
136
  /**
137
137
  * Retrieves hierarchy level descriptor
138
138
  * @public
139
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
139
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
140
140
  * package for creating hierarchies.
141
141
  */
142
142
  async getNodesDescriptor(requestOptions) {
@@ -148,7 +148,7 @@ class PresentationManager {
148
148
  * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
149
149
  * TODO: Return results in pages
150
150
  * @public
151
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
151
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
152
152
  * package for creating hierarchies.
153
153
  */
154
154
  async getNodePaths(requestOptions) {
@@ -159,7 +159,7 @@ class PresentationManager {
159
159
  * Retrieves paths from root nodes to nodes containing filter text in their label.
160
160
  * TODO: Return results in pages
161
161
  * @public
162
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
162
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
163
163
  * package for creating hierarchies.
164
164
  */
165
165
  async getFilteredNodePaths(requestOptions) {
@@ -361,7 +361,7 @@ class PresentationManager {
361
361
  /**
362
362
  * Compares two hierarchies specified in the request options
363
363
  * @public
364
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
364
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
365
365
  * package for creating hierarchies.
366
366
  */
367
367
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -1 +1 @@
1
- {"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAsC;AACtC,mDAA+C;AAI/C,gEAAgF;AAChF,oEA8CoC;AACpC,kEAK6C;AAC7C,6EAAgI;AAChI,6DAAoE;AACpE,2DAAiE;AACjE,iFAA+F;AAE/F,6EAAoG;AACpG,yEAAmE;AACnE,yCAA0G;AAE1G,qDAAqD;AACrD;;;;;GAKG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,uCAAiB,CAAA;IACjB;;;OAGG;IACH,mCAAa,CAAA;IACb;;;;;OAKG;IACH,uCAAiB,CAAA;AACnB,CAAC,EAjBW,kBAAkB,kCAAlB,kBAAkB,QAiB7B;AA6QD;;;;;GAKG;AACH,MAAa,mBAAmB;IACtB,MAAM,CAA2B;IACjC,OAAO,CAA4B;IACnC,mBAAmB,CAAqB;IACxC,sBAAsB,CAAsC;IAEpE;;;OAGG;IACH,YAAY,KAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,wDAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,mBAAmB,GAAG,IAAI,6BAAkB,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,IAAI,+BAAoB,EAAE,CAAC,CAAC;QAC7H,4DAA4D;QAC5D,IAAI,CAAC,sBAAsB,GAAG,KAAK,EAAE,qBAAqB,IAAI,CAAC,CAAC,MAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7G,CAAC;IAED,6EAA6E;IAC7E,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC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,CAAC,WAAW,CAAC,CAAC;QACrE,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,iDAAkB,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;QAC9F,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,KAAK,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACtD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,2CAA2C,CAAC,CAAC;QAC/G,CAAC;QAED,MAAM,oBAAoB,GAAG,gBAAgB,IAAI,EAAE,CAAC;QACpD,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,IAAI,oBAAoB,CAAC;QAE3E,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,8CAA0B,CAAC,kBAAkB;YACxD,GAAG,OAAO;YACV,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;SACjE,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAzcD,kDAycC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { firstValueFrom } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { IModelDb } from \"@itwin/core-backend\";\r\nimport { BeEvent, Id64Array } from \"@itwin/core-bentley\";\r\nimport { FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext, SchemaFormatsProvider } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n UnitSystemFormat as CommonUnitSystemFormat,\r\n ComputeSelectionRequestOptions,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n createContentFormatter,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyCompareInfo,\r\n HierarchyCompareOptions,\r\n HierarchyLevel,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyRequestOptions,\r\n InstanceKey,\r\n Item,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n MultiElementPropertiesRequestOptions,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PresentationError,\r\n PresentationStatus,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SelectionScope,\r\n SelectionScopeRequestOptions,\r\n SingleElementPropertiesRequestOptions,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport {\r\n createElementPropertiesBuilder,\r\n deepReplaceNullsToUndefined,\r\n isSingleElementPropertiesRequestOptions,\r\n LocalizationHelper,\r\n} from \"@itwin/presentation-common/internal\";\r\nimport { getContentItemsObservableFromClassNames, getContentItemsObservableFromElementIds } from \"./ElementPropertiesHelper.js\";\r\nimport { _presentation_manager_detail } from \"./InternalSymbols.js\";\r\nimport { NativePlatformRequestTypes } from \"./NativePlatform.js\";\r\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail.js\";\r\nimport { RulesetManager } from \"./RulesetManager.js\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager.js\";\r\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper.js\";\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils.js\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n/**\r\n * Presentation hierarchy cache mode.\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport enum HierarchyCacheMode {\r\n /**\r\n * Hierarchy cache is created in memory.\r\n */\r\n Memory = \"memory\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\r\n * openings.\r\n */\r\n Disk = \"disk\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\r\n * and persisted in disk cache when whole hierarchy level is created.\r\n *\r\n * **Note:** This mode is still experimental.\r\n */\r\n Hybrid = \"hybrid\",\r\n}\r\n\r\n/**\r\n * Configuration for hierarchy cache.\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\r\n\r\n/**\r\n * Base interface for all [[HierarchyCacheConfig]] implementations.\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode;\r\n}\r\n\r\n/**\r\n * Configuration for in-memory hierarchy cache.\r\n *\r\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Memory;\r\n}\r\n\r\n/**\r\n * Configuration for persistent disk hierarchy cache.\r\n *\r\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Disk;\r\n\r\n /**\r\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\r\n *\r\n * The default directory depends on the iModel and the way it's opened.\r\n */\r\n directory?: string;\r\n\r\n /**\r\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\r\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\r\n */\r\n memoryCacheSize?: number;\r\n}\r\n\r\n/**\r\n * Configuration for the experimental hybrid hierarchy cache.\r\n *\r\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\r\n * alternative for cases when there are lots of simultaneous requests.\r\n *\r\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Hybrid;\r\n\r\n /** Configuration for disk cache used to persist hierarchies. */\r\n disk?: DiskHierarchyCacheConfig;\r\n}\r\n/* eslint-enable @typescript-eslint/no-deprecated */\r\n\r\n/**\r\n * Configuration for content cache.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n * @public\r\n */\r\nexport interface ContentCacheConfig {\r\n /**\r\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\r\n *\r\n * Defaults to `100`.\r\n */\r\n size?: number;\r\n}\r\n\r\n/**\r\n * Caching configuration options for [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationManagerCachingConfig {\r\n /**\r\n * Hierarchies-related caching options.\r\n *\r\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n hierarchies?: HierarchyCacheConfig;\r\n\r\n /**\r\n * Content-related caching options.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n */\r\n content?: ContentCacheConfig;\r\n\r\n /**\r\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\r\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\r\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\r\n * cache. Defaults to `32768000` bytes (32 MB).\r\n *\r\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\r\n */\r\n workerConnectionCacheSize?: number;\r\n}\r\n\r\n/**\r\n * A data structure that associates unit systems with a format. The associations are used for\r\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\r\n *\r\n * @public\r\n * @deprecated in 4.3 - might be removed in next major version. The type has been moved to `@itwin/presentation-common` package.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-deprecated\r\nexport type UnitSystemFormat = CommonUnitSystemFormat;\r\n\r\n/**\r\n * Data structure for multiple element properties request response.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\r\n total: number;\r\n iterator: () => AsyncGenerator<TParsedContent[]>;\r\n}\r\n\r\n/**\r\n * Configuration options for supplying asset paths to [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationAssetsRootConfig {\r\n /**\r\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\r\n */\r\n backend: string;\r\n}\r\n\r\n/**\r\n * Properties that can be used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\r\n *\r\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\r\n *\r\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\r\n * - `assets/*\\*\\/*`\r\n * - `presentation-backend/{presentation-backend source files}`\r\n *\r\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\r\n *\r\n * - else, assume the backend is webpacked into a single file with assets next to it:\r\n * - `assets/*\\*\\/*`\r\n * - `{source file being executed}.js`\r\n *\r\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\r\n *\r\n * @deprecated in 4.2 - might be removed in next major version. This attribute is not used anymore - the package is not using private assets anymore.\r\n */\r\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\r\n\r\n /**\r\n * A list of directories containing application's presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n rulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's supplemental presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n supplementalRulesetDirectories?: string[];\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. Default presentation units are used if this is not specified. The active unit\r\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\r\n * through request options.\r\n */\r\n defaultUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * A map of default unit formats to use for formatting properties that don't have a presentation format\r\n * in requested unit system.\r\n *\r\n * @deprecated in 5.1 - might be removed in next major version. Use `formatsProvider` instead. Still used as a fallback if `formatsProvider` is not supplied.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n defaultFormats?: FormatsMap;\r\n\r\n /**\r\n * A custom formats provider to use for formatting property values with units. Defaults to [SchemaFormatsProvider]($ecschema-metadata) if\r\n * not supplied.\r\n */\r\n formatsProvider?: FormatsProvider;\r\n\r\n /**\r\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\r\n */\r\n workerThreadsCount?: number;\r\n\r\n /**\r\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\r\n * data changes are not tracked at all.\r\n *\r\n * @beta\r\n * @deprecated in 4.4 - might be removed in next major version. The manager now always tracks for iModel data changes without polling.\r\n */\r\n updatesPollInterval?: number;\r\n\r\n /** Options for caching. */\r\n caching?: PresentationManagerCachingConfig;\r\n\r\n /**\r\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\r\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\r\n *\r\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\r\n */\r\n useMmap?: boolean | number;\r\n\r\n /**\r\n * Localization function to localize data returned by presentation manager when it's used directly on the backend (as opposed to when used through RPC, where\r\n * data is localized on the frontend). Defaults to English localization.\r\n *\r\n * @see [Localization]($docs/presentation/advanced/Localization)\r\n */\r\n getLocalizedString?: (key: string) => string;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n *\r\n * @deprecated in 5.1 - might be removed in next major version. By default [IModelDb.schemaContext]($core-backend) is now used instead.\r\n */\r\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\r\n\r\n /**\r\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\r\n * made through the manager.\r\n *\r\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\r\n */\r\n diagnostics?: BackendDiagnosticsOptions;\r\n}\r\n\r\n/**\r\n * Backend Presentation manager which pulls the presentation data from\r\n * an iModel using native platform.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager {\r\n private _props: PresentationManagerProps;\r\n private _detail: PresentationManagerDetail;\r\n private _localizationHelper: LocalizationHelper;\r\n private _schemaContextProvider: (imodel: IModelDb) => SchemaContext;\r\n\r\n /**\r\n * Creates an instance of PresentationManager.\r\n * @param props Optional configuration properties.\r\n */\r\n constructor(props?: PresentationManagerProps) {\r\n this._props = props ?? {};\r\n this._detail = new PresentationManagerDetail(this._props);\r\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this._schemaContextProvider = props?.schemaContextProvider ?? ((imodel: IModelDb) => imodel.schemaContext);\r\n }\r\n\r\n /** Get / set active unit system used to format property values with units */\r\n public get activeUnitSystem(): UnitSystemKey | undefined {\r\n return this._detail.activeUnitSystem;\r\n }\r\n /* c8 ignore next 3 */\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._detail.activeUnitSystem = value;\r\n }\r\n\r\n /** Dispose the presentation manager. Must be called to clean up native resources. */\r\n public [Symbol.dispose]() {\r\n this._detail[Symbol.dispose]();\r\n }\r\n\r\n /** @deprecated in 5.0 - might be removed in next major version. Use [Symbol.dispose] instead. */\r\n /* c8 ignore next 3 */\r\n public dispose() {\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** An event, that this manager raises whenever any request is made on it. */\r\n public get onUsed(): BeEvent<() => void> {\r\n return this._detail.onUsed;\r\n }\r\n\r\n /** Properties used to initialize the manager */\r\n public get props() {\r\n return this._props;\r\n }\r\n\r\n /** Get rulesets manager */\r\n public rulesets(): RulesetManager {\r\n return this._detail.rulesets;\r\n }\r\n\r\n /**\r\n * Get ruleset variables manager for specific ruleset\r\n * @param rulesetId Id of the ruleset to get variables manager for\r\n */\r\n public vars(rulesetId: string): RulesetVariablesManager {\r\n return new RulesetVariablesManagerImpl(() => this._detail.getNativePlatform(), rulesetId);\r\n }\r\n\r\n /** @internal */\r\n /* c8 ignore next 3 */\r\n public get [_presentation_manager_detail](): PresentationManagerDetail {\r\n return this._detail;\r\n }\r\n\r\n public getRulesetId(rulesetOrId: Ruleset | string) {\r\n return this._detail.getRulesetId(rulesetOrId);\r\n }\r\n\r\n /* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\n /**\r\n * Retrieves nodes\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getNodes(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Node[]> {\r\n const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);\r\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\r\n return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);\r\n }\r\n\r\n /**\r\n * Retrieves nodes count\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getNodesCount(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getNodesCount(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getNodesDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\r\n * TODO: Return results in pages\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to nodes containing filter text in their label.\r\n * TODO: Return results in pages\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getFilteredNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getFilteredNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /* eslint-enable @typescript-eslint/no-deprecated */\r\n\r\n /**\r\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\r\n * its related instances for loading related and navigation properties.\r\n * @public\r\n */\r\n public async getContentSources(\r\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<SelectClassInfo[]> {\r\n return this._detail.getContentSources(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content descriptor which can be used to get content\r\n * @public\r\n */\r\n public async getContentDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getContentDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the content set size based on the supplied content descriptor override\r\n * @public\r\n */\r\n public async getContentSetSize(\r\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getContentSetSize(requestOptions);\r\n }\r\n\r\n private createContentFormatter({ imodel, unitSystem }: { imodel: IModelDb; unitSystem?: UnitSystemKey }) {\r\n if (!unitSystem) {\r\n unitSystem = this.props.defaultUnitSystem ?? \"metric\";\r\n }\r\n const schemaContext = this._schemaContextProvider(imodel);\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter({\r\n schemaContext,\r\n formatsProvider: this.props.formatsProvider ?? new SchemaFormatsProvider(schemaContext, unitSystem),\r\n });\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n koqPropertyFormatter.defaultFormats = this.props.defaultFormats;\r\n return createContentFormatter({ propertyValueFormatter: koqPropertyFormatter, unitSystem });\r\n }\r\n\r\n /**\r\n * Retrieves the content set based on the supplied content descriptor.\r\n * @public\r\n */\r\n public async getContentSet(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Item[]> {\r\n let items = await this._detail.getContentSet({ ...requestOptions, omitFormattedValues: true });\r\n\r\n if (!requestOptions.omitFormattedValues) {\r\n const formatter = this.createContentFormatter(requestOptions);\r\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContentItems(items);\r\n }\r\n\r\n /**\r\n * Retrieves the content based on the supplied content descriptor override.\r\n * @public\r\n */\r\n public async getContent(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<Content | undefined> {\r\n const content = await this._detail.getContent({ ...requestOptions, omitFormattedValues: true });\r\n if (!content) {\r\n return undefined;\r\n }\r\n\r\n if (!requestOptions.omitFormattedValues) {\r\n const formatter = this.createContentFormatter(requestOptions);\r\n await formatter.formatContent(content);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContent(content);\r\n }\r\n\r\n /**\r\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\r\n * @param requestOptions Options for the request\r\n * @return A promise object that returns either distinct values on success or an error string on error.\r\n * @public\r\n */\r\n public async getPagedDistinctValues(\r\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<PagedResponse<DisplayValueGroup>> {\r\n const result = await this._detail.getPagedDistinctValues(requestOptions);\r\n return {\r\n ...result,\r\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves property data in a simplified format for a single element specified by ID.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined>;\r\n /**\r\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\r\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<\r\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\r\n > &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\r\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\r\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n\r\n private async getSingleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\r\n const parser: TParser = contentParser ?? (createElementPropertiesBuilder() as TParser);\r\n const content = await this.getContent({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!content || content.contentSet.length === 0) {\r\n return undefined;\r\n }\r\n return parser(content.descriptor, content.contentSet[0]);\r\n }\r\n\r\n private async getMultipleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { contentParser, fieldsSelector: fieldsSelectorOption, batchSize: batchSizeOption, ...contentOptions } = requestOptions;\r\n\r\n const parser: TParser = contentParser ?? (createElementPropertiesBuilder() as TParser);\r\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\r\n\r\n // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory\r\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\r\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\r\n // most `workerThreadsCount / 2` classes in parallel.\r\n /* c8 ignore next */\r\n const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;\r\n\r\n // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,\r\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\r\n // To avoid that, we keep twice as much requests active.\r\n /* c8 ignore next */\r\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;\r\n\r\n /* c8 ignore next */\r\n const batchSize = batchSizeOption ?? 100;\r\n\r\n const elementsIdentifier = ((): { elementIds: Id64Array } | { elementClasses: string[] } => {\r\n if (\"elementIds\" in contentOptions && contentOptions.elementIds !== undefined) {\r\n const elementIds = contentOptions.elementIds;\r\n delete contentOptions.elementIds;\r\n return { elementIds };\r\n }\r\n if (\"elementClasses\" in contentOptions && contentOptions.elementClasses !== undefined) {\r\n const elementClasses = contentOptions.elementClasses;\r\n delete contentOptions.elementClasses;\r\n return { elementClasses };\r\n }\r\n /* c8 ignore next */\r\n return { elementClasses: [\"BisCore:Element\"] };\r\n })();\r\n\r\n const descriptorGetter = async (partialProps: Pick<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\">) => {\r\n const descr = await this.getContentDescriptor({\r\n ...contentOptions,\r\n displayType: DefaultContentDisplayTypes.Grid,\r\n contentFlags: ContentFlags.ShowLabels,\r\n ...partialProps,\r\n });\r\n if (descr) {\r\n descr.fieldsSelector = fieldsSelectorOption?.(descr);\r\n }\r\n return descr;\r\n };\r\n const contentSetGetter = async (\r\n partialProps: Pick<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\" | \"descriptor\">,\r\n ) => this.getContentSet({ ...contentOptions, ...partialProps });\r\n const { itemBatches, count } =\r\n \"elementIds\" in elementsIdentifier\r\n ? getContentItemsObservableFromElementIds(\r\n requestOptions.imodel,\r\n descriptorGetter,\r\n contentSetGetter,\r\n elementsIdentifier.elementIds,\r\n classParallelism,\r\n batchesParallelism,\r\n batchSize,\r\n )\r\n : getContentItemsObservableFromClassNames(\r\n requestOptions.imodel,\r\n descriptorGetter,\r\n contentSetGetter,\r\n elementsIdentifier.elementClasses,\r\n classParallelism,\r\n batchesParallelism,\r\n batchSize,\r\n );\r\n return {\r\n total: await firstValueFrom(count),\r\n async *iterator() {\r\n for await (const itemsBatch of eachValueFrom(itemBatches)) {\r\n const { descriptor, items } = itemsBatch;\r\n yield items.map((item): TParsedContent => parser(descriptor, item));\r\n }\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves display label definition of specific item\r\n * @public\r\n */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\r\n }\r\n\r\n /**\r\n * Retrieves display label definitions of specific items\r\n * @public\r\n */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition[]> {\r\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\r\n }\r\n\r\n /**\r\n * Retrieves available selection scopes.\r\n * @public\r\n * @deprecated in 5.0 - might be removed in next major version. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\r\n return SelectionScopesHelper.getSelectionScopes();\r\n }\r\n\r\n /**\r\n * Computes selection based on provided element IDs and selection scope.\r\n * @public\r\n * @deprecated in 5.0 - might be removed in next major version. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet> {\r\n return SelectionScopesHelper.computeSelection(requestOptions);\r\n }\r\n\r\n /**\r\n * Compares two hierarchies specified in the request options\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\r\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\r\n return { changes: [] };\r\n }\r\n\r\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\r\n this._detail.registerRuleset(rulesetOrId);\r\n\r\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\r\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\r\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\r\n }\r\n\r\n const currRulesetVariables = rulesetVariables ?? [];\r\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\r\n\r\n const params = {\r\n requestId: NativePlatformRequestTypes.CompareHierarchies,\r\n ...options,\r\n prevRulesetId: prevRulesetId.uniqueId,\r\n currRulesetId: currRulesetId.uniqueId,\r\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\r\n currRulesetVariables: JSON.stringify(currRulesetVariables),\r\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\r\n };\r\n return JSON.parse(await this._detail.request(params));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAsC;AACtC,mDAA+C;AAI/C,gEAAgF;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a,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACtD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,2CAA2C,CAAC,CAAC;QAC/G,CAAC;QAED,MAAM,oBAAoB,GAAG,gBAAgB,IAAI,EAAE,CAAC;QACpD,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,IAAI,oBAAoB,CAAC;QAE3E,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,8CAA0B,CAAC,kBAAkB;YACxD,GAAG,OAAO;YACV,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;SACjE,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAzcD,kDAycC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { firstValueFrom } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { IModelDb } from \"@itwin/core-backend\";\r\nimport { BeEvent, Id64Array } from \"@itwin/core-bentley\";\r\nimport { FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext, SchemaFormatsProvider } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n UnitSystemFormat as CommonUnitSystemFormat,\r\n ComputeSelectionRequestOptions,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n createContentFormatter,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyCompareInfo,\r\n HierarchyCompareOptions,\r\n HierarchyLevel,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyRequestOptions,\r\n InstanceKey,\r\n Item,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n MultiElementPropertiesRequestOptions,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PresentationError,\r\n PresentationStatus,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SelectionScope,\r\n SelectionScopeRequestOptions,\r\n SingleElementPropertiesRequestOptions,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport {\r\n createElementPropertiesBuilder,\r\n deepReplaceNullsToUndefined,\r\n isSingleElementPropertiesRequestOptions,\r\n LocalizationHelper,\r\n} from \"@itwin/presentation-common/internal\";\r\nimport { getContentItemsObservableFromClassNames, getContentItemsObservableFromElementIds } from \"./ElementPropertiesHelper.js\";\r\nimport { _presentation_manager_detail } from \"./InternalSymbols.js\";\r\nimport { NativePlatformRequestTypes } from \"./NativePlatform.js\";\r\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail.js\";\r\nimport { RulesetManager } from \"./RulesetManager.js\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager.js\";\r\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper.js\";\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils.js\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n/**\r\n * Presentation hierarchy cache mode.\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport enum HierarchyCacheMode {\r\n /**\r\n * Hierarchy cache is created in memory.\r\n */\r\n Memory = \"memory\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\r\n * openings.\r\n */\r\n Disk = \"disk\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\r\n * and persisted in disk cache when whole hierarchy level is created.\r\n *\r\n * **Note:** This mode is still experimental.\r\n */\r\n Hybrid = \"hybrid\",\r\n}\r\n\r\n/**\r\n * Configuration for hierarchy cache.\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\r\n\r\n/**\r\n * Base interface for all [[HierarchyCacheConfig]] implementations.\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode;\r\n}\r\n\r\n/**\r\n * Configuration for in-memory hierarchy cache.\r\n *\r\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Memory;\r\n}\r\n\r\n/**\r\n * Configuration for persistent disk hierarchy cache.\r\n *\r\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Disk;\r\n\r\n /**\r\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\r\n *\r\n * The default directory depends on the iModel and the way it's opened.\r\n */\r\n directory?: string;\r\n\r\n /**\r\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\r\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\r\n */\r\n memoryCacheSize?: number;\r\n}\r\n\r\n/**\r\n * Configuration for the experimental hybrid hierarchy cache.\r\n *\r\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\r\n * alternative for cases when there are lots of simultaneous requests.\r\n *\r\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Hybrid;\r\n\r\n /** Configuration for disk cache used to persist hierarchies. */\r\n disk?: DiskHierarchyCacheConfig;\r\n}\r\n/* eslint-enable @typescript-eslint/no-deprecated */\r\n\r\n/**\r\n * Configuration for content cache.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n * @public\r\n */\r\nexport interface ContentCacheConfig {\r\n /**\r\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\r\n *\r\n * Defaults to `100`.\r\n */\r\n size?: number;\r\n}\r\n\r\n/**\r\n * Caching configuration options for [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationManagerCachingConfig {\r\n /**\r\n * Hierarchies-related caching options.\r\n *\r\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n hierarchies?: HierarchyCacheConfig;\r\n\r\n /**\r\n * Content-related caching options.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n */\r\n content?: ContentCacheConfig;\r\n\r\n /**\r\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\r\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\r\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\r\n * cache. Defaults to `32768000` bytes (32 MB).\r\n *\r\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\r\n */\r\n workerConnectionCacheSize?: number;\r\n}\r\n\r\n/**\r\n * A data structure that associates unit systems with a format. The associations are used for\r\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\r\n *\r\n * @public\r\n * @deprecated in 4.3 - might be removed in next major version. The type has been moved to `@itwin/presentation-common` package.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-deprecated\r\nexport type UnitSystemFormat = CommonUnitSystemFormat;\r\n\r\n/**\r\n * Data structure for multiple element properties request response.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\r\n total: number;\r\n iterator: () => AsyncGenerator<TParsedContent[]>;\r\n}\r\n\r\n/**\r\n * Configuration options for supplying asset paths to [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationAssetsRootConfig {\r\n /**\r\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\r\n */\r\n backend: string;\r\n}\r\n\r\n/**\r\n * Properties that can be used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\r\n *\r\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\r\n *\r\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\r\n * - `assets/*\\*\\/*`\r\n * - `presentation-backend/{presentation-backend source files}`\r\n *\r\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\r\n *\r\n * - else, assume the backend is webpacked into a single file with assets next to it:\r\n * - `assets/*\\*\\/*`\r\n * - `{source file being executed}.js`\r\n *\r\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\r\n *\r\n * @deprecated in 4.2 - might be removed in next major version. This attribute is not used anymore - the package is not using private assets anymore.\r\n */\r\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\r\n\r\n /**\r\n * A list of directories containing application's presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n rulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's supplemental presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n supplementalRulesetDirectories?: string[];\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. Default presentation units are used if this is not specified. The active unit\r\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\r\n * through request options.\r\n */\r\n defaultUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * A map of default unit formats to use for formatting properties that don't have a presentation format\r\n * in requested unit system.\r\n *\r\n * @deprecated in 5.1 - might be removed in next major version. Use `formatsProvider` instead. Still used as a fallback if `formatsProvider` is not supplied.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n defaultFormats?: FormatsMap;\r\n\r\n /**\r\n * A custom formats provider to use for formatting property values with units. Defaults to [SchemaFormatsProvider]($ecschema-metadata) if\r\n * not supplied.\r\n */\r\n formatsProvider?: FormatsProvider;\r\n\r\n /**\r\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\r\n */\r\n workerThreadsCount?: number;\r\n\r\n /**\r\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\r\n * data changes are not tracked at all.\r\n *\r\n * @beta\r\n * @deprecated in 4.4 - might be removed in next major version. The manager now always tracks for iModel data changes without polling.\r\n */\r\n updatesPollInterval?: number;\r\n\r\n /** Options for caching. */\r\n caching?: PresentationManagerCachingConfig;\r\n\r\n /**\r\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\r\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\r\n *\r\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\r\n */\r\n useMmap?: boolean | number;\r\n\r\n /**\r\n * Localization function to localize data returned by presentation manager when it's used directly on the backend (as opposed to when used through RPC, where\r\n * data is localized on the frontend). Defaults to English localization.\r\n *\r\n * @see [Localization]($docs/presentation/advanced/Localization)\r\n */\r\n getLocalizedString?: (key: string) => string;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n *\r\n * @deprecated in 5.1 - might be removed in next major version. By default [IModelDb.schemaContext]($core-backend) is now used instead.\r\n */\r\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\r\n\r\n /**\r\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\r\n * made through the manager.\r\n *\r\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\r\n */\r\n diagnostics?: BackendDiagnosticsOptions;\r\n}\r\n\r\n/**\r\n * Backend Presentation manager which pulls the presentation data from\r\n * an iModel using native platform.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager {\r\n private _props: PresentationManagerProps;\r\n private _detail: PresentationManagerDetail;\r\n private _localizationHelper: LocalizationHelper;\r\n private _schemaContextProvider: (imodel: IModelDb) => SchemaContext;\r\n\r\n /**\r\n * Creates an instance of PresentationManager.\r\n * @param props Optional configuration properties.\r\n */\r\n constructor(props?: PresentationManagerProps) {\r\n this._props = props ?? {};\r\n this._detail = new PresentationManagerDetail(this._props);\r\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this._schemaContextProvider = props?.schemaContextProvider ?? ((imodel: IModelDb) => imodel.schemaContext);\r\n }\r\n\r\n /** Get / set active unit system used to format property values with units */\r\n public get activeUnitSystem(): UnitSystemKey | undefined {\r\n return this._detail.activeUnitSystem;\r\n }\r\n /* c8 ignore next 3 */\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._detail.activeUnitSystem = value;\r\n }\r\n\r\n /** Dispose the presentation manager. Must be called to clean up native resources. */\r\n public [Symbol.dispose]() {\r\n this._detail[Symbol.dispose]();\r\n }\r\n\r\n /** @deprecated in 5.0 - might be removed in next major version. Use [Symbol.dispose] instead. */\r\n /* c8 ignore next 3 */\r\n public dispose() {\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** An event, that this manager raises whenever any request is made on it. */\r\n public get onUsed(): BeEvent<() => void> {\r\n return this._detail.onUsed;\r\n }\r\n\r\n /** Properties used to initialize the manager */\r\n public get props() {\r\n return this._props;\r\n }\r\n\r\n /** Get rulesets manager */\r\n public rulesets(): RulesetManager {\r\n return this._detail.rulesets;\r\n }\r\n\r\n /**\r\n * Get ruleset variables manager for specific ruleset\r\n * @param rulesetId Id of the ruleset to get variables manager for\r\n */\r\n public vars(rulesetId: string): RulesetVariablesManager {\r\n return new RulesetVariablesManagerImpl(() => this._detail.getNativePlatform(), rulesetId);\r\n }\r\n\r\n /** @internal */\r\n /* c8 ignore next 3 */\r\n public get [_presentation_manager_detail](): PresentationManagerDetail {\r\n return this._detail;\r\n }\r\n\r\n public getRulesetId(rulesetOrId: Ruleset | string) {\r\n return this._detail.getRulesetId(rulesetOrId);\r\n }\r\n\r\n /* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\n /**\r\n * Retrieves nodes\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getNodes(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Node[]> {\r\n const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);\r\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\r\n return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);\r\n }\r\n\r\n /**\r\n * Retrieves nodes count\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getNodesCount(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getNodesCount(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getNodesDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\r\n * TODO: Return results in pages\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to nodes containing filter text in their label.\r\n * TODO: Return results in pages\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n public async getFilteredNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getFilteredNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /* eslint-enable @typescript-eslint/no-deprecated */\r\n\r\n /**\r\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\r\n * its related instances for loading related and navigation properties.\r\n * @public\r\n */\r\n public async getContentSources(\r\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<SelectClassInfo[]> {\r\n return this._detail.getContentSources(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content descriptor which can be used to get content\r\n * @public\r\n */\r\n public async getContentDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getContentDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the content set size based on the supplied content descriptor override\r\n * @public\r\n */\r\n public async getContentSetSize(\r\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getContentSetSize(requestOptions);\r\n }\r\n\r\n private createContentFormatter({ imodel, unitSystem }: { imodel: IModelDb; unitSystem?: UnitSystemKey }) {\r\n if (!unitSystem) {\r\n unitSystem = this.props.defaultUnitSystem ?? \"metric\";\r\n }\r\n const schemaContext = this._schemaContextProvider(imodel);\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter({\r\n schemaContext,\r\n formatsProvider: this.props.formatsProvider ?? new SchemaFormatsProvider(schemaContext, unitSystem),\r\n });\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n koqPropertyFormatter.defaultFormats = this.props.defaultFormats;\r\n return createContentFormatter({ propertyValueFormatter: koqPropertyFormatter, unitSystem });\r\n }\r\n\r\n /**\r\n * Retrieves the content set based on the supplied content descriptor.\r\n * @public\r\n */\r\n public async getContentSet(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Item[]> {\r\n let items = await this._detail.getContentSet({ ...requestOptions, omitFormattedValues: true });\r\n\r\n if (!requestOptions.omitFormattedValues) {\r\n const formatter = this.createContentFormatter(requestOptions);\r\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContentItems(items);\r\n }\r\n\r\n /**\r\n * Retrieves the content based on the supplied content descriptor override.\r\n * @public\r\n */\r\n public async getContent(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<Content | undefined> {\r\n const content = await this._detail.getContent({ ...requestOptions, omitFormattedValues: true });\r\n if (!content) {\r\n return undefined;\r\n }\r\n\r\n if (!requestOptions.omitFormattedValues) {\r\n const formatter = this.createContentFormatter(requestOptions);\r\n await formatter.formatContent(content);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContent(content);\r\n }\r\n\r\n /**\r\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\r\n * @param requestOptions Options for the request\r\n * @return A promise object that returns either distinct values on success or an error string on error.\r\n * @public\r\n */\r\n public async getPagedDistinctValues(\r\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<PagedResponse<DisplayValueGroup>> {\r\n const result = await this._detail.getPagedDistinctValues(requestOptions);\r\n return {\r\n ...result,\r\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves property data in a simplified format for a single element specified by ID.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined>;\r\n /**\r\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\r\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<\r\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\r\n > &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\r\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\r\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n\r\n private async getSingleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\r\n const parser: TParser = contentParser ?? (createElementPropertiesBuilder() as TParser);\r\n const content = await this.getContent({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!content || content.contentSet.length === 0) {\r\n return undefined;\r\n }\r\n return parser(content.descriptor, content.contentSet[0]);\r\n }\r\n\r\n private async getMultipleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { contentParser, fieldsSelector: fieldsSelectorOption, batchSize: batchSizeOption, ...contentOptions } = requestOptions;\r\n\r\n const parser: TParser = contentParser ?? (createElementPropertiesBuilder() as TParser);\r\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\r\n\r\n // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory\r\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\r\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\r\n // most `workerThreadsCount / 2` classes in parallel.\r\n /* c8 ignore next */\r\n const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;\r\n\r\n // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,\r\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\r\n // To avoid that, we keep twice as much requests active.\r\n /* c8 ignore next */\r\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;\r\n\r\n /* c8 ignore next */\r\n const batchSize = batchSizeOption ?? 100;\r\n\r\n const elementsIdentifier = ((): { elementIds: Id64Array } | { elementClasses: string[] } => {\r\n if (\"elementIds\" in contentOptions && contentOptions.elementIds !== undefined) {\r\n const elementIds = contentOptions.elementIds;\r\n delete contentOptions.elementIds;\r\n return { elementIds };\r\n }\r\n if (\"elementClasses\" in contentOptions && contentOptions.elementClasses !== undefined) {\r\n const elementClasses = contentOptions.elementClasses;\r\n delete contentOptions.elementClasses;\r\n return { elementClasses };\r\n }\r\n /* c8 ignore next */\r\n return { elementClasses: [\"BisCore:Element\"] };\r\n })();\r\n\r\n const descriptorGetter = async (partialProps: Pick<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\">) => {\r\n const descr = await this.getContentDescriptor({\r\n ...contentOptions,\r\n displayType: DefaultContentDisplayTypes.Grid,\r\n contentFlags: ContentFlags.ShowLabels,\r\n ...partialProps,\r\n });\r\n if (descr) {\r\n descr.fieldsSelector = fieldsSelectorOption?.(descr);\r\n }\r\n return descr;\r\n };\r\n const contentSetGetter = async (\r\n partialProps: Pick<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\" | \"descriptor\">,\r\n ) => this.getContentSet({ ...contentOptions, ...partialProps });\r\n const { itemBatches, count } =\r\n \"elementIds\" in elementsIdentifier\r\n ? getContentItemsObservableFromElementIds(\r\n requestOptions.imodel,\r\n descriptorGetter,\r\n contentSetGetter,\r\n elementsIdentifier.elementIds,\r\n classParallelism,\r\n batchesParallelism,\r\n batchSize,\r\n )\r\n : getContentItemsObservableFromClassNames(\r\n requestOptions.imodel,\r\n descriptorGetter,\r\n contentSetGetter,\r\n elementsIdentifier.elementClasses,\r\n classParallelism,\r\n batchesParallelism,\r\n batchSize,\r\n );\r\n return {\r\n total: await firstValueFrom(count),\r\n async *iterator() {\r\n for await (const itemsBatch of eachValueFrom(itemBatches)) {\r\n const { descriptor, items } = itemsBatch;\r\n yield items.map((item): TParsedContent => parser(descriptor, item));\r\n }\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves display label definition of specific item\r\n * @public\r\n */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\r\n }\r\n\r\n /**\r\n * Retrieves display label definitions of specific items\r\n * @public\r\n */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition[]> {\r\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\r\n }\r\n\r\n /**\r\n * Retrieves available selection scopes.\r\n * @public\r\n * @deprecated in 5.0 - might be removed in next major version. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\r\n return SelectionScopesHelper.getSelectionScopes();\r\n }\r\n\r\n /**\r\n * Computes selection based on provided element IDs and selection scope.\r\n * @public\r\n * @deprecated in 5.0 - might be removed in next major version. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet> {\r\n return SelectionScopesHelper.computeSelection(requestOptions);\r\n }\r\n\r\n /**\r\n * Compares two hierarchies specified in the request options\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\r\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\r\n return { changes: [] };\r\n }\r\n\r\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\r\n this._detail.registerRuleset(rulesetOrId);\r\n\r\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\r\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\r\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\r\n }\r\n\r\n const currRulesetVariables = rulesetVariables ?? [];\r\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\r\n\r\n const params = {\r\n requestId: NativePlatformRequestTypes.CompareHierarchies,\r\n ...options,\r\n prevRulesetId: prevRulesetId.uniqueId,\r\n currRulesetId: currRulesetId.uniqueId,\r\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\r\n currRulesetVariables: JSON.stringify(currRulesetVariables),\r\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\r\n };\r\n return JSON.parse(await this._detail.request(params));\r\n }\r\n}\r\n"]}
@@ -21,23 +21,6 @@ export declare function getContentItemsObservableFromClassNames(imodel: IModelDb
21
21
  }>;
22
22
  count: Observable<number>;
23
23
  };
24
- /**
25
- * Given a sorted list of ECInstanceIds and a batch size, create a stream of batches. Because the IDs won't necessarily
26
- * be sequential, a batch is defined a list of from-to pairs.
27
- * @internal
28
- */
29
- export declare function createIdBatches(sortedIds: Id64String[], batchSize: number): Observable<Array<{
30
- from: Id64String;
31
- to: Id64String;
32
- }>>;
33
- /**
34
- * Query all ECInstanceIds from given class and stream from-to pairs that batch the items into batches of `batchSize` size.
35
- * @internal
36
- */
37
- export declare function getBatchedClassElementIds(imodel: IModelDb, fullClassName: string, batchSize: number): Observable<Array<{
38
- from: Id64String;
39
- to: Id64String;
40
- }>>;
41
24
  /** @internal */
42
25
  export declare function getElementsCount(db: IModelDb, classNames: string[]): Promise<any>;
43
26
  //# sourceMappingURL=ElementPropertiesHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElementPropertiesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAoD,UAAU,EAAsC,MAAM,MAAM,CAAC;AACxH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAmB,UAAU,EAAuB,MAAM,qBAAqB,CAAC;AAEvF,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,UAAU,EACV,IAAI,EACJ,MAAM,EAIN,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAQpC,gBAAgB;AAChB,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,QAAQ,EAChB,uBAAuB,EAAE,CACvB,YAAY,EAAE,IAAI,CAAC,+BAA+B,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC,KAC3G,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,EACpC,gBAAgB,EAAE,CAChB,YAAY,EAAE,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,YAAY,CAAC,KAC5H,OAAO,CAAC,IAAI,EAAE,CAAC,EACpB,UAAU,EAAE,UAAU,EAAE,EACxB,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,GAChB;IAAE,WAAW,EAAE,UAAU,CAAC;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,IAAI,EAAE,CAAA;KAAE,CAAC,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;CAAE,CAiBnG;AAED,g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,CAAC,+BAA+B,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC,KAC3G,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,EACpC,gBAAgB,EAAE,CAChB,YAAY,EAAE,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,YAAY,CAAC,KAC5H,OAAO,CAAC,IAAI,EAAE,CAAC,EACpB,cAAc,EAAE,MAAM,EAAE,EACxB,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,GAChB;IAAE,WAAW,EAAE,UAAU,CAAC;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,IAAI,EAAE,CAAA;KAAE,CAAC,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;CAAE,CAkBnG;AAsQD,gBAAgB;AAChB,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,gBA0BxE"}
@@ -6,7 +6,8 @@
6
6
  * @module Core
7
7
  */
8
8
  import { bufferCount, defer, from, groupBy, map, mergeMap, of, range, reduce } from "rxjs";
9
- import { Id64, OrderedId64Iterable } from "@itwin/core-bentley";
9
+ import { OrderedId64Iterable } from "@itwin/core-bentley";
10
+ import { QueryBinder } from "@itwin/core-common";
10
11
  import { Descriptor, KeySet, PresentationError, PresentationStatus, } from "@itwin/presentation-common";
11
12
  import { parseFullClassName } from "@itwin/presentation-shared";
12
13
  function getECSqlName(fullClassName) {
@@ -16,18 +17,18 @@ function getECSqlName(fullClassName) {
16
17
  /** @internal */
17
18
  export function getContentItemsObservableFromElementIds(imodel, contentDescriptorGetter, contentSetGetter, elementIds, classParallelism, batchesParallelism, batchSize) {
18
19
  return {
19
- itemBatches: getElementClassesFromIds(imodel, elementIds).pipe(mergeMap(({ classFullName, ids }) => getBatchedClassContentItems(classFullName, contentDescriptorGetter, contentSetGetter, () => createIdBatches(OrderedId64Iterable.sortArray(ids), batchSize), batchesParallelism), classParallelism)),
20
+ itemBatches: getElementClassesFromIds(imodel, elementIds).pipe(mergeMap(({ classFullName, ids }) => getBatchedClassContentItems(imodel, classFullName, contentDescriptorGetter, contentSetGetter, () => createIdBatches(ids, batchSize), batchesParallelism), classParallelism)),
20
21
  count: of(elementIds.length),
21
22
  };
22
23
  }
23
24
  /** @internal */
24
25
  export function getContentItemsObservableFromClassNames(imodel, contentDescriptorGetter, contentSetGetter, elementClasses, classParallelism, batchesParallelism, batchSize) {
25
26
  return {
26
- itemBatches: getClassesWithInstances(imodel, elementClasses).pipe(mergeMap((classFullName) => getBatchedClassContentItems(classFullName, contentDescriptorGetter, contentSetGetter, () => getBatchedClassElementIds(imodel, classFullName, batchSize), batchesParallelism), classParallelism)),
27
+ itemBatches: getClassesWithInstances(imodel, elementClasses).pipe(mergeMap((classFullName) => getBatchedClassContentItems(imodel, classFullName, contentDescriptorGetter, contentSetGetter, () => getBatchedClassElementIds(imodel, classFullName, batchSize), batchesParallelism), classParallelism)),
27
28
  count: from(getElementsCount(imodel, elementClasses)),
28
29
  };
29
30
  }
30
- function getBatchedClassContentItems(classFullName, contentDescriptorGetter, contentSetGetter, batcher, batchesParallelism) {
31
+ function getBatchedClassContentItems(imodel, classFullName, contentDescriptorGetter, contentSetGetter, batcher, batchesParallelism) {
31
32
  return defer(async () => {
32
33
  const ruleset = createClassContentRuleset(classFullName);
33
34
  const keys = new KeySet();
@@ -35,41 +36,70 @@ function getBatchedClassContentItems(classFullName, contentDescriptorGetter, con
35
36
  if (!descriptor) {
36
37
  throw new PresentationError(PresentationStatus.Error, `Failed to get descriptor for class ${classFullName}`);
37
38
  }
38
- return { descriptor, keys, ruleset };
39
- }).pipe(
40
- // create elements' id batches
41
- mergeMap((x) => batcher().pipe(map((batch) => ({ ...x, batch })))),
42
- // request content for each batch, filter by IDs for performance
43
- mergeMap(({ descriptor, keys, ruleset, batch }) => defer(async () => {
44
- const filteringDescriptor = new Descriptor(descriptor);
45
- filteringDescriptor.instanceFilter = {
39
+ const aspectFields = getPrunableAspectFields(descriptor, classFullName);
40
+ return { descriptor, keys, ruleset, aspectFields };
41
+ }).pipe(mergeMap((x) => batcher().pipe(map((batch) => ({ ...x, batch })))), mergeMap(({ descriptor, keys, ruleset, batch, aspectFields }) => defer(async () => {
42
+ const batchDescriptor = new Descriptor(descriptor);
43
+ batchDescriptor.instanceFilter = {
46
44
  selectClassName: classFullName,
47
- expression: createElementIdsECExpressionFilter(batch),
45
+ expression: batch.ranges
46
+ .map(({ from: fromId, to }) => fromId === to ? `this.ECInstanceId = ${fromId}` : `this.ECInstanceId >= ${fromId} AND this.ECInstanceId <= ${to}`)
47
+ .join(" OR "),
48
48
  };
49
- return contentSetGetter({
49
+ if (aspectFields.length) {
50
+ await selectBatchAspectFields(imodel, batchDescriptor, aspectFields, batch.ids);
51
+ }
52
+ const items = await contentSetGetter({
50
53
  rulesetOrId: ruleset,
51
54
  keys,
52
- descriptor: filteringDescriptor,
55
+ descriptor: batchDescriptor,
53
56
  });
54
- }).pipe(map((items) => ({ descriptor, items }))), batchesParallelism));
57
+ return { descriptor: batchDescriptor, items };
58
+ }), batchesParallelism));
55
59
  }
56
- function createElementIdsECExpressionFilter(batch) {
57
- let filter = "";
58
- function appendCondition(cond) {
59
- if (filter.length > 0) {
60
- filter += " OR ";
61
- }
62
- filter += cond;
60
+ function getPrunableAspectFields(descriptor, classFullName) {
61
+ // Caller selections take precedence; don't replace an include/exclude selector with our own.
62
+ if (descriptor.fieldsSelector || countFields(descriptor.fields) <= 1000) {
63
+ return [];
63
64
  }
64
- for (const item of batch) {
65
- if (item.from === item.to) {
66
- appendCondition(`this.ECInstanceId = ${item.from}`);
67
- }
68
- else {
69
- appendCondition(`this.ECInstanceId >= ${item.from} AND this.ECInstanceId <= ${item.to}`);
65
+ const { schemaName, className } = parseFullClassName(classFullName);
66
+ return descriptor.fields.filter((field) => {
67
+ if (!field.isNestedContentField() || field.pathToPrimaryClass.length !== 1) {
68
+ return false;
70
69
  }
70
+ const step = field.pathToPrimaryClass[0];
71
+ return (!step.isForwardRelationship &&
72
+ (step.relationshipInfo.name === "BisCore:ElementOwnsMultiAspects" || step.relationshipInfo.name === "BisCore:ElementOwnsUniqueAspect") &&
73
+ step.sourceClassInfo.id === field.contentClassInfo.id &&
74
+ step.targetClassInfo.name === `${schemaName}:${className}`);
75
+ });
76
+ }
77
+ function countFields(fields) {
78
+ return fields.reduce((count, field) => count + 1 + (field.isNestedContentField() ? countFields(field.nestedFields) : 0), 0);
79
+ }
80
+ async function selectBatchAspectFields(imodel, descriptor, aspectFields, batch) {
81
+ const query = `
82
+ WITH aspectClasses(ClassId) AS (
83
+ SELECT DISTINCT a.ECClassId
84
+ FROM bis.ElementMultiAspect a
85
+ JOIN IdSet(:elementIds) e ON e.id = a.Element.Id
86
+ UNION ALL
87
+ SELECT DISTINCT a.ECClassId
88
+ FROM bis.ElementUniqueAspect a
89
+ JOIN IdSet(:elementIds) e ON e.id = a.Element.Id
90
+ )
91
+ SELECT IdToHex(b.TargetECInstanceId) classId
92
+ FROM meta.ClassHasAllBaseClasses b
93
+ JOIN aspectClasses a ON a.ClassId = b.SourceECInstanceId
94
+ `;
95
+ const aspectClasses = new Set();
96
+ for await (const row of imodel.createQueryReader(query, QueryBinder.from({ elementIds: batch }))) {
97
+ aspectClasses.add(row.classId);
98
+ }
99
+ const excludedFields = aspectFields.filter((field) => !aspectClasses.has(field.contentClassInfo.id));
100
+ if (excludedFields.length > 0) {
101
+ descriptor.fieldsSelector = { type: "exclude", fields: excludedFields.map((field) => field.getFieldDescriptor()) };
71
102
  }
72
- return filter;
73
103
  }
74
104
  function createClassContentRuleset(fullClassName) {
75
105
  const { schemaName, className } = parseFullClassName(fullClassName);
@@ -93,27 +123,59 @@ function createClassContentRuleset(fullClassName) {
93
123
  ],
94
124
  };
95
125
  }
96
- /** Given a list of element ids, group them by class name. */
126
+ /**
127
+ * Given a list of element ids, group them by class name. In addition, for every element, get ID of the previous
128
+ * element of the same class, which lets us put requested IDs into ranges without other instances of the same class.
129
+ *
130
+ * The query reader re-executes the query for every page, so querying all IDs at once is much slower than querying
131
+ * them in chunks. Chunks are made of the sorted IDs list and run in parallel. `GROUP_CONCAT` order isn't guaranteed
132
+ * by SQLite, so each chunk's IDs are sorted individually (usually a no-op check), then stored at the chunk's index.
133
+ * Concatenating them gives each class its IDs sorted.
134
+ */
97
135
  function getElementClassesFromIds(imodel, elementIds) {
98
136
  const elementIdsBatchSize = 5000;
99
- return range(0, elementIds.length / elementIdsBatchSize).pipe(mergeMap((batchIndex) => {
100
- const idsFrom = batchIndex * elementIdsBatchSize;
101
- const idsTo = Math.min(idsFrom + elementIdsBatchSize, elementIds.length);
137
+ const sortedElementIds = OrderedId64Iterable.sortArray([...elementIds]);
138
+ return range(0, sortedElementIds.length / elementIdsBatchSize).pipe(mergeMap((_, chunkIndex) => {
139
+ const idsFrom = chunkIndex * elementIdsBatchSize;
140
+ const idsTo = Math.min(idsFrom + elementIdsBatchSize, sortedElementIds.length);
102
141
  return from(imodel.createQueryReader(`
103
- SELECT ec_classname(e.ECClassId) className, GROUP_CONCAT(IdToHex(e.ECInstanceId)) ids
142
+ SELECT
143
+ ec_classname(e.ECClassId) className,
144
+ GROUP_CONCAT(
145
+ IdToHex(e.ECInstanceId) || ':' || IFNULL((
146
+ SELECT IdToHex(MAX(p.ECInstanceId))
147
+ FROM bis.Element p
148
+ WHERE p.ECClassId = e.ECClassId AND p.ECInstanceId < e.ECInstanceId
149
+ ), '')
150
+ ) ids
104
151
  FROM bis.Element e
105
- WHERE e.ECInstanceId IN (${elementIds.slice(idsFrom, idsTo).join(",")})
152
+ JOIN IdSet(:elementIds) elementIds ON elementIds.id = e.ECInstanceId
106
153
  GROUP BY e.ECClassId
107
- `));
108
- }), map((row) => ({ className: row.className, ids: row.ids.split(",") })), groupBy(({ className }) => className), mergeMap((groups) => groups.pipe(reduce((acc, g) => {
109
- g.ids.forEach((id) => acc.ids.push(id));
110
- return {
111
- classFullName: g.className,
112
- ids: acc.ids,
113
- };
114
- }, { classFullName: "", ids: [] }))));
154
+ `, new QueryBinder().bindIdSet("elementIds", sortedElementIds.slice(idsFrom, idsTo)))).pipe(map((row) => ({
155
+ chunkIndex,
156
+ className: row.className,
157
+ ids: ensureSortedById(row.ids.split(",").map((pair) => {
158
+ const [id, prevClassInstanceId] = pair.split(":");
159
+ return { id, ...(prevClassInstanceId ? { prevClassInstanceId } : undefined) };
160
+ })),
161
+ })));
162
+ }), groupBy(({ className }) => className), mergeMap((groups) => groups.pipe(reduce((acc, g) => {
163
+ acc.chunks[g.chunkIndex] = g.ids;
164
+ return { classFullName: g.className, chunks: acc.chunks };
165
+ }, { classFullName: "", chunks: [] }))),
166
+ // chunks cover consecutive ID ranges and are sorted individually, so their concatenation is sorted as well;
167
+ // `flat` skips holes left by chunks that had no elements of the class
168
+ map(({ classFullName, chunks }) => ({ classFullName, ids: chunks.flat() })));
169
+ }
170
+ function ensureSortedById(ids) {
171
+ for (let i = 1; i < ids.length; ++i) {
172
+ if (OrderedId64Iterable.compare(ids[i - 1].id, ids[i].id) > 0) {
173
+ return ids.sort((a, b) => OrderedId64Iterable.compare(a.id, b.id));
174
+ }
175
+ }
176
+ return ids;
115
177
  }
116
- /** Given a list of full class names, get a stream of actual class names that have instances. */
178
+ /** Given a list of full class names, get concrete class names with instances. */
117
179
  function getClassesWithInstances(imodel, fullClassNames) {
118
180
  return from(fullClassNames).pipe(mergeMap((fullClassName) => from(imodel.createQueryReader(`
119
181
  SELECT ec_classname(e.ECClassId, 's.c') className
@@ -122,38 +184,28 @@ function getClassesWithInstances(imodel, fullClassNames) {
122
184
  `))), map((row) => row.className));
123
185
  }
124
186
  /**
125
- * Given a sorted list of ECInstanceIds and a batch size, create a stream of batches. Because the IDs won't necessarily
126
- * be sequential, a batch is defined a list of from-to pairs.
127
- * @internal
187
+ * Given a list of same-class ECInstanceIds, sorted by ID, and a batch size, create a stream of batches. Because the IDs won't
188
+ * necessarily be sequential, a batch is defined as a list of from-to pairs. An ID extends the current range if there are no other
189
+ * instances of the same class between it and the previous requested ID.
128
190
  */
129
- export function createIdBatches(sortedIds, batchSize) {
191
+ function createIdBatches(sortedIds, batchSize) {
130
192
  return range(0, sortedIds.length / batchSize).pipe(map((batchIndex) => {
131
- const sequences = new Array();
193
+ const ranges = new Array();
132
194
  const startIndex = batchIndex * batchSize;
133
195
  const endIndex = Math.min((batchIndex + 1) * batchSize, sortedIds.length) - 1;
134
- let fromId = sortedIds[startIndex];
135
- let to = {
136
- id: sortedIds[startIndex],
137
- localId: Id64.getLocalId(sortedIds[startIndex]),
138
- };
196
+ let fromId = sortedIds[startIndex].id;
139
197
  for (let i = startIndex + 1; i <= endIndex; ++i) {
140
- const currLocalId = Id64.getLocalId(sortedIds[i]);
141
- if (currLocalId !== to.localId + 1) {
142
- sequences.push({ from: fromId, to: sortedIds[i - 1] });
143
- fromId = sortedIds[i];
198
+ if (sortedIds[i].prevClassInstanceId !== sortedIds[i - 1].id) {
199
+ ranges.push({ from: fromId, to: sortedIds[i - 1].id });
200
+ fromId = sortedIds[i].id;
144
201
  }
145
- to = { id: sortedIds[i], localId: currLocalId };
146
202
  }
147
- sequences.push({ from: fromId, to: sortedIds[endIndex] });
148
- return sequences;
203
+ ranges.push({ from: fromId, to: sortedIds[endIndex].id });
204
+ return { ids: sortedIds.slice(startIndex, endIndex + 1).map(({ id }) => id), ranges };
149
205
  }));
150
206
  }
151
- /**
152
- * Query all ECInstanceIds from given class and stream from-to pairs that batch the items into batches of `batchSize` size.
153
- * @internal
154
- */
155
- export function getBatchedClassElementIds(imodel, fullClassName, batchSize) {
156
- return from(imodel.createQueryReader(`SELECT IdToHex(ECInstanceId) id FROM ${getECSqlName(fullClassName)} ORDER BY ECInstanceId`)).pipe(map((row) => row.id), bufferCount(batchSize), map((batch) => [{ from: batch[0], to: batch[batch.length - 1] }]));
207
+ function getBatchedClassElementIds(imodel, fullClassName, batchSize) {
208
+ return from(imodel.createQueryReader(`SELECT IdToHex(ECInstanceId) id FROM ONLY ${getECSqlName(fullClassName)} ORDER BY ECInstanceId`)).pipe(map((row) => row.id), bufferCount(batchSize), map((ids) => ({ ids, ranges: [{ from: ids[0], to: ids[ids.length - 1] }] })));
157
209
  }
158
210
  /** @internal */
159
211
  export async function getElementsCount(db, classNames) {