@itwin/presentation-backend 5.0.0-dev.61 → 5.0.0-dev.62
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.
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +0 -68
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +6 -31
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +1 -2
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +1 -8
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +2 -4
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +10 -17
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/package.json +14 -14
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
4
|
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
6
5
|
import { UnitSystemKey } from "@itwin/core-quantity";
|
|
7
6
|
import { SchemaContext } from "@itwin/ecschema-metadata";
|
|
8
7
|
import { UnitSystemFormat as CommonUnitSystemFormat, ComputeSelectionRequestOptions, Content, ContentDescriptorRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, FormatsMap, HierarchyCompareInfo, HierarchyCompareOptions, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions, InstanceKey, Item, KeySet, LabelDefinition, MultiElementPropertiesRequestOptions, Node, NodeKey, NodePathElement, Paged, PagedResponse, Prioritized, Ruleset, RulesetVariable, SelectClassInfo, SelectionScope, SelectionScopeRequestOptions, SingleElementPropertiesRequestOptions, WithCancelEvent } from "@itwin/presentation-common";
|
|
@@ -11,23 +10,6 @@ import { PresentationManagerDetail } from "./PresentationManagerDetail";
|
|
|
11
10
|
import { RulesetManager } from "./RulesetManager";
|
|
12
11
|
import { RulesetVariablesManager } from "./RulesetVariablesManager";
|
|
13
12
|
import { BackendDiagnosticsAttribute, BackendDiagnosticsOptions } from "./Utils";
|
|
14
|
-
/**
|
|
15
|
-
* Presentation manager working mode.
|
|
16
|
-
* @public
|
|
17
|
-
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
18
|
-
*/
|
|
19
|
-
export declare enum PresentationManagerMode {
|
|
20
|
-
/**
|
|
21
|
-
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
22
|
-
* related to reacting to changes in iModels.
|
|
23
|
-
*/
|
|
24
|
-
ReadOnly = 0,
|
|
25
|
-
/**
|
|
26
|
-
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
27
|
-
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
28
|
-
*/
|
|
29
|
-
ReadWrite = 1
|
|
30
|
-
}
|
|
31
13
|
/**
|
|
32
14
|
* Presentation hierarchy cache mode.
|
|
33
15
|
* @public
|
|
@@ -171,12 +153,6 @@ export interface PresentationAssetsRootConfig {
|
|
|
171
153
|
* Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.
|
|
172
154
|
*/
|
|
173
155
|
backend: string;
|
|
174
|
-
/**
|
|
175
|
-
* Path to `presentation-common` assets.
|
|
176
|
-
*
|
|
177
|
-
* @deprecated in 3.x. This path is not used anymore
|
|
178
|
-
*/
|
|
179
|
-
common: string;
|
|
180
156
|
}
|
|
181
157
|
/**
|
|
182
158
|
* Properties that can be used to configure [[PresentationManager]]
|
|
@@ -217,20 +193,6 @@ export interface PresentationManagerProps {
|
|
|
217
193
|
* @note Only files with `.PresentationRuleSet.json` are read.
|
|
218
194
|
*/
|
|
219
195
|
supplementalRulesetDirectories?: string[];
|
|
220
|
-
/**
|
|
221
|
-
* A list of directories containing application's locale-specific localized
|
|
222
|
-
* string files (in simplified i18next v3 format)
|
|
223
|
-
*
|
|
224
|
-
* @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
|
|
225
|
-
*/
|
|
226
|
-
localeDirectories?: string[];
|
|
227
|
-
/**
|
|
228
|
-
* Sets the active locale to use when localizing presentation-related
|
|
229
|
-
* strings. It can later be changed through [[PresentationManager.activeLocale]].
|
|
230
|
-
*
|
|
231
|
-
* @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
|
|
232
|
-
*/
|
|
233
|
-
defaultLocale?: string;
|
|
234
196
|
/**
|
|
235
197
|
* Sets the active unit system to use for formatting property values with
|
|
236
198
|
* units. Default presentation units are used if this is not specified. The active unit
|
|
@@ -243,26 +205,10 @@ export interface PresentationManagerProps {
|
|
|
243
205
|
* in requested unit system.
|
|
244
206
|
*/
|
|
245
207
|
defaultFormats?: FormatsMap;
|
|
246
|
-
/**
|
|
247
|
-
* Should schemas preloading be enabled. If true, presentation manager listens
|
|
248
|
-
* for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.
|
|
249
|
-
*
|
|
250
|
-
* @deprecated in 3.x. Use [[PresentationProps.enableSchemasPreload]] instead.
|
|
251
|
-
*/
|
|
252
|
-
enableSchemasPreload?: boolean;
|
|
253
208
|
/**
|
|
254
209
|
* A number of worker threads to use for handling presentation requests. Defaults to `2`.
|
|
255
210
|
*/
|
|
256
211
|
workerThreadsCount?: number;
|
|
257
|
-
/**
|
|
258
|
-
* Presentation manager working mode. Backends that use iModels in read-write mode should
|
|
259
|
-
* use `ReadWrite`, others might want to set to `ReadOnly` for better performance.
|
|
260
|
-
*
|
|
261
|
-
* Defaults to [[PresentationManagerMode.ReadWrite]].
|
|
262
|
-
*
|
|
263
|
-
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
264
|
-
*/
|
|
265
|
-
mode?: PresentationManagerMode;
|
|
266
212
|
/**
|
|
267
213
|
* The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation
|
|
268
214
|
* data changes are not tracked at all.
|
|
@@ -321,11 +267,6 @@ export declare class PresentationManager {
|
|
|
321
267
|
private _props;
|
|
322
268
|
private _detail;
|
|
323
269
|
private _localizationHelper;
|
|
324
|
-
/**
|
|
325
|
-
* Get / set active locale used for localizing presentation data
|
|
326
|
-
* @deprecated in 3.x. Use [[PresentationManagerProps.getLocalizedString]] to localize data returned by [[PresentationManager]].
|
|
327
|
-
*/
|
|
328
|
-
activeLocale: string | undefined;
|
|
329
270
|
/**
|
|
330
271
|
* Creates an instance of PresentationManager.
|
|
331
272
|
* @param props Optional configuration properties.
|
|
@@ -443,15 +384,6 @@ export declare class PresentationManager {
|
|
|
443
384
|
* @public
|
|
444
385
|
*/
|
|
445
386
|
getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]>;
|
|
446
|
-
/**
|
|
447
|
-
* Computes selection set based on provided selection scope.
|
|
448
|
-
* @public
|
|
449
|
-
* @deprecated in 3.x. Use overload with `ComputeSelectionRequestOptions` parameter.
|
|
450
|
-
*/
|
|
451
|
-
computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb> & {
|
|
452
|
-
ids: Id64String[];
|
|
453
|
-
scopeId: string;
|
|
454
|
-
} & BackendDiagnosticsAttribute): Promise<KeySet>;
|
|
455
387
|
/**
|
|
456
388
|
* Computes selection based on provided element IDs and selection scope.
|
|
457
389
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAEL,gBAAgB,IAAI,sBAAsB,EAC1C,8BAA8B,EAC9B,OAAO,EACP,+BAA+B,EAI/B,qBAAqB,EACrB,4BAA4B,EAG5B,UAAU,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,4BAA4B,EAC5B,iBAAiB,EACjB,4CAA4C,EAC5C,mCAAmC,EACnC,UAAU,EACV,oBAAoB,EACpB,uBAAuB,EAEvB,sCAAsC,EACtC,uBAAuB,EACvB,WAAW,EAEX,IAAI,EACJ,MAAM,EAEN,eAAe,EAEf,oCAAoC,EACpC,IAAI,EACJ,OAAO,EACP,eAAe,EACf,KAAK,EACL,aAAa,EAGb,WAAW,EACX,OAAO,EACP,eAAe,EACf,eAAe,EACf,cAAc,EACd,4BAA4B,EAC5B,qCAAqC,EACrC,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,wBAAwB,EAA8B,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAsB,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAA+B,MAAM,2BAA2B,CAAC;AAEjG,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAwB,MAAM,SAAS,CAAC;AAEvG;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B;;OAEG;IACH,MAAM,WAAW;IACjB;;;OAGG;IACH,IAAI,S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AQ,CAAC,GAAG,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAItI;;;OAGG;IACU,kBAAkB,CAAC,cAAc,EAAE,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;CA4B3H"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.PresentationManager = exports.HierarchyCacheMode =
|
|
10
|
+
exports.PresentationManager = exports.HierarchyCacheMode = void 0;
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const rxjs_for_await_1 = require("rxjs-for-await");
|
|
13
13
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
@@ -17,24 +17,6 @@ const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
|
|
|
17
17
|
const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
|
|
18
18
|
const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
|
|
19
19
|
const Utils_1 = require("./Utils");
|
|
20
|
-
/**
|
|
21
|
-
* Presentation manager working mode.
|
|
22
|
-
* @public
|
|
23
|
-
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
24
|
-
*/
|
|
25
|
-
var PresentationManagerMode;
|
|
26
|
-
(function (PresentationManagerMode) {
|
|
27
|
-
/**
|
|
28
|
-
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
29
|
-
* related to reacting to changes in iModels.
|
|
30
|
-
*/
|
|
31
|
-
PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
|
|
32
|
-
/**
|
|
33
|
-
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
34
|
-
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
35
|
-
*/
|
|
36
|
-
PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
|
|
37
|
-
})(PresentationManagerMode || (exports.PresentationManagerMode = PresentationManagerMode = {}));
|
|
38
20
|
/**
|
|
39
21
|
* Presentation hierarchy cache mode.
|
|
40
22
|
* @public
|
|
@@ -68,11 +50,6 @@ class PresentationManager {
|
|
|
68
50
|
_props;
|
|
69
51
|
_detail;
|
|
70
52
|
_localizationHelper;
|
|
71
|
-
/**
|
|
72
|
-
* Get / set active locale used for localizing presentation data
|
|
73
|
-
* @deprecated in 3.x. Use [[PresentationManagerProps.getLocalizedString]] to localize data returned by [[PresentationManager]].
|
|
74
|
-
*/
|
|
75
|
-
activeLocale;
|
|
76
53
|
/**
|
|
77
54
|
* Creates an instance of PresentationManager.
|
|
78
55
|
* @param props Optional configuration properties.
|
|
@@ -80,7 +57,6 @@ class PresentationManager {
|
|
|
80
57
|
constructor(props) {
|
|
81
58
|
this._props = props ?? {};
|
|
82
59
|
this._detail = new PresentationManagerDetail_1.PresentationManagerDetail(this._props);
|
|
83
|
-
this.activeLocale = this._props.defaultLocale; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
84
60
|
this._localizationHelper = new presentation_common_1.LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? Utils_1.getLocalizedStringEN });
|
|
85
61
|
}
|
|
86
62
|
/** Get / set active unit system used to format property values with units */
|
|
@@ -340,13 +316,12 @@ class PresentationManager {
|
|
|
340
316
|
async getSelectionScopes(_requestOptions) {
|
|
341
317
|
return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
|
|
342
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Computes selection based on provided element IDs and selection scope.
|
|
321
|
+
* @public
|
|
322
|
+
*/
|
|
343
323
|
async computeSelection(requestOptions) {
|
|
344
|
-
return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection(
|
|
345
|
-
? requestOptions
|
|
346
|
-
: (function () {
|
|
347
|
-
const { ids, scopeId, ...rest } = requestOptions;
|
|
348
|
-
return { ...rest, elementIds: ids, scope: { id: scopeId } };
|
|
349
|
-
})());
|
|
324
|
+
return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection(requestOptions);
|
|
350
325
|
}
|
|
351
326
|
/**
|
|
352
327
|
* Compares two hierarchies specified in the request options
|
|
@@ -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;AAK/C,oEAoDoC;AACpC,uEAA6H;AAC7H,qDAAwF;AACxF,2EAA4F;AAE5F,uEAAiG;AACjG,mEAAgE;AAChE,mCAAuG;AAEvG;;;;GAIG;AACH,IAAY,uBAYX;AAZD,WAAY,uBAAuB;IACjC;;;OAGG;IACH,6EAAQ,CAAA;IAER;;;OAGG;IACH,+EAAS,CAAA;AACX,CAAC,EAZW,uBAAuB,uCAAvB,uBAAuB,QAYlC;AAED;;;GAGG;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;AAySD;;;;;GAKG;AACH,MAAa,mBAAmB;IACtB,MAAM,CAA2B;IACjC,OAAO,CAA4B;IACnC,mBAAmB,CAAqB;IAEhD;;;OAGG;IACI,YAAY,CAAqB;IAExC;;;OAGG;IACH,YAAY,KAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,qDAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,uDAAuD;QAEtG,IAAI,CAAC,mBAAmB,GAAG,IAAI,wCAAkB,CAAC,EAAE,kBAAkB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I,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;AA3cD,kDA2cC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { firstValueFrom } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport {\n buildElementProperties,\n UnitSystemFormat as CommonUnitSystemFormat,\n ComputeSelectionRequestOptions,\n Content,\n ContentDescriptorRequestOptions,\n ContentFlags,\n ContentFormatter,\n ContentPropertyValueFormatter,\n ContentRequestOptions,\n ContentSourcesRequestOptions,\n deepReplaceNullsToUndefined,\n DefaultContentDisplayTypes,\n Descriptor,\n DescriptorOverrides,\n DisplayLabelRequestOptions,\n DisplayLabelsRequestOptions,\n DisplayValueGroup,\n DistinctValuesRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRequestOptions,\n FilterByTextHierarchyRequestOptions,\n FormatsMap,\n HierarchyCompareInfo,\n HierarchyCompareOptions,\n HierarchyLevel,\n HierarchyLevelDescriptorRequestOptions,\n HierarchyRequestOptions,\n InstanceKey,\n isComputeSelectionRequestOptions,\n isSingleElementPropertiesRequestOptions,\n Item,\n KeySet,\n KoqPropertyValueFormatter,\n LabelDefinition,\n LocalizationHelper,\n MultiElementPropertiesRequestOptions,\n Node,\n NodeKey,\n NodePathElement,\n Paged,\n PagedResponse,\n PresentationError,\n PresentationStatus,\n Prioritized,\n Ruleset,\n RulesetVariable,\n SelectClassInfo,\n SelectionScope,\n SelectionScopeRequestOptions,\n SingleElementPropertiesRequestOptions,\n WithCancelEvent,\n} from \"@itwin/presentation-common\";\nimport { getContentItemsObservableFromClassNames, getContentItemsObservableFromElementIds } from \"./ElementPropertiesHelper\";\nimport { NativePlatformDefinition, NativePlatformRequestTypes } from \"./NativePlatform\";\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail\";\nimport { RulesetManager } from \"./RulesetManager\";\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper\";\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils\";\n\n/**\n * Presentation manager working mode.\n * @public\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\n */\nexport enum PresentationManagerMode {\n /**\n * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work\n * related to reacting to changes in iModels.\n */\n ReadOnly,\n\n /**\n * Presentation manager assumes iModels are opened in read-write mode and it may need to\n * react to changes. This involves some additional work and gives slightly worse performance.\n */\n ReadWrite,\n}\n\n/**\n * Presentation hierarchy cache mode.\n * @public\n */\nexport enum HierarchyCacheMode {\n /**\n * Hierarchy cache is created in memory.\n */\n Memory = \"memory\",\n /**\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\n * openings.\n */\n Disk = \"disk\",\n /**\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\n * and persisted in disk cache when whole hierarchy level is created.\n *\n * **Note:** This mode is still experimental.\n */\n Hybrid = \"hybrid\",\n}\n\n/**\n * Configuration for hierarchy cache.\n * @public\n */\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\n\n/**\n * Base interface for all [[HierarchyCacheConfig]] implementations.\n * @public\n */\nexport interface HierarchyCacheConfigBase {\n mode: HierarchyCacheMode;\n}\n\n/**\n * Configuration for in-memory hierarchy cache.\n *\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\n * @public\n */\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Memory;\n}\n\n/**\n * Configuration for persistent disk hierarchy cache.\n *\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\n * @public\n */\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Disk;\n\n /**\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\n *\n * The default directory depends on the iModel and the way it's opened.\n */\n directory?: string;\n\n /**\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\n */\n memoryCacheSize?: number;\n}\n\n/**\n * Configuration for the experimental hybrid hierarchy cache.\n *\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\n * alternative for cases when there are lots of simultaneous requests.\n *\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\n * @public\n */\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Hybrid;\n\n /** Configuration for disk cache used to persist hierarchies. */\n disk?: DiskHierarchyCacheConfig;\n}\n\n/**\n * Configuration for content cache.\n *\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\n * @public\n */\nexport interface ContentCacheConfig {\n /**\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\n *\n * Defaults to `100`.\n */\n size?: number;\n}\n\n/**\n * Caching configuration options for [[PresentationManager]].\n * @public\n */\nexport interface PresentationManagerCachingConfig {\n /**\n * Hierarchies-related caching options.\n *\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\n */\n hierarchies?: HierarchyCacheConfig;\n\n /**\n * Content-related caching options.\n *\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\n */\n content?: ContentCacheConfig;\n\n /**\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\n * cache. Defaults to `32768000` bytes (32 MB).\n *\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\n */\n workerConnectionCacheSize?: number;\n}\n\n/**\n * A data structure that associates unit systems with a format. The associations are used for\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\n *\n * @public\n * @deprecated in 4.3. The type has been moved to `@itwin/presentation-common` package.\n */\nexport type UnitSystemFormat = CommonUnitSystemFormat;\n\n/**\n * Data structure for multiple element properties request response.\n * @public\n */\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\n total: number;\n iterator: () => AsyncGenerator<TParsedContent[]>;\n}\n\n/**\n * Configuration options for supplying asset paths to [[PresentationManager]].\n * @public\n */\nexport interface PresentationAssetsRootConfig {\n /**\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\n */\n backend: string;\n\n /**\n * Path to `presentation-common` assets.\n *\n * @deprecated in 3.x. This path is not used anymore\n */\n common: string;\n}\n\n/**\n * Properties that can be used to configure [[PresentationManager]]\n * @public\n */\nexport interface PresentationManagerProps {\n /**\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\n *\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\n *\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:\n * - `assets/*\\*\\/*`\n * - `presentation-backend/{presentation-backend source files}`\n *\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\n *\n * - else, assume the backend is webpacked into a single file with assets next to it:\n * - `assets/*\\*\\/*`\n * - `{source file being executed}.js`\n *\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\n *\n * @deprecated in 4.2. This attribute is not used anymore - the package is not using private assets anymore.\n */\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\n\n /**\n * A list of directories containing application's presentation rulesets. Relative\n * paths start from `process.cwd()`. The directories are traversed recursively.\n *\n * @note Only files with `.PresentationRuleSet.json` are read.\n */\n rulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's supplemental presentation rulesets. Relative\n * paths start from `process.cwd()`. The directories are traversed recursively.\n *\n * @note Only files with `.PresentationRuleSet.json` are read.\n */\n supplementalRulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's locale-specific localized\n * string files (in simplified i18next v3 format)\n *\n * @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].\n */\n localeDirectories?: string[];\n\n /**\n * Sets the active locale to use when localizing presentation-related\n * strings. It can later be changed through [[PresentationManager.activeLocale]].\n *\n * @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].\n */\n defaultLocale?: string;\n\n /**\n * Sets the active unit system to use for formatting property values with\n * units. Default presentation units are used if this is not specified. The active unit\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\n * through request options.\n */\n defaultUnitSystem?: UnitSystemKey;\n\n /**\n * A map of default unit formats to use for formatting properties that don't have a presentation format\n * in requested unit system.\n */\n defaultFormats?: FormatsMap;\n\n /**\n * Should schemas preloading be enabled. If true, presentation manager listens\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\n *\n * @deprecated in 3.x. Use [[PresentationProps.enableSchemasPreload]] instead.\n */\n enableSchemasPreload?: boolean;\n\n /**\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\n */\n workerThreadsCount?: number;\n\n /**\n * Presentation manager working mode. Backends that use iModels in read-write mode should\n * use `ReadWrite`, others might want to set to `ReadOnly` for better performance.\n *\n * Defaults to [[PresentationManagerMode.ReadWrite]].\n *\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\n */\n mode?: PresentationManagerMode; // eslint-disable-line @typescript-eslint/no-deprecated\n\n /**\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\n * data changes are not tracked at all.\n *\n * @beta\n * @deprecated in 4.4. The manager now always tracks for iModel data changes without polling.\n */\n updatesPollInterval?: number;\n\n /** Options for caching. */\n caching?: PresentationManagerCachingConfig;\n\n /**\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\n *\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.\n */\n useMmap?: boolean | number;\n\n /**\n * An identifier which helps separate multiple presentation managers. It's\n * mostly useful in tests where multiple presentation managers can co-exist\n * and try to share the same resources, which we don't want. With this identifier\n * set, managers put their resources into id-named subdirectories.\n *\n * @internal\n */\n id?: string;\n\n /** @internal */\n addon?: NativePlatformDefinition;\n\n /**\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\n * data is localized on the frontend). Defaults to English localization.\n *\n * @see [Localization]($docs/presentation/advanced/Localization)\n */\n getLocalizedString?: (key: string) => string;\n\n /**\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\n */\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\n\n /**\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\n * made through the manager.\n *\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\n */\n diagnostics?: BackendDiagnosticsOptions;\n}\n\n/**\n * Backend Presentation manager which pulls the presentation data from\n * an iModel using native platform.\n *\n * @public\n */\nexport class PresentationManager {\n private _props: PresentationManagerProps;\n private _detail: PresentationManagerDetail;\n private _localizationHelper: LocalizationHelper;\n\n /**\n * Get / set active locale used for localizing presentation data\n * @deprecated in 3.x. Use [[PresentationManagerProps.getLocalizedString]] to localize data returned by [[PresentationManager]].\n */\n public activeLocale: string | undefined;\n\n /**\n * Creates an instance of PresentationManager.\n * @param props Optional configuration properties.\n */\n constructor(props?: PresentationManagerProps) {\n this._props = props ?? {};\n this._detail = new PresentationManagerDetail(this._props);\n this.activeLocale = this._props.defaultLocale; // eslint-disable-line @typescript-eslint/no-deprecated\n\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\n }\n\n /** Get / set active unit system used to format property values with units */\n public get activeUnitSystem(): UnitSystemKey | undefined {\n return this._detail.activeUnitSystem;\n }\n // istanbul ignore next\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\n this._detail.activeUnitSystem = value;\n }\n\n /** Dispose the presentation manager. Must be called to clean up native resources. */\n public [Symbol.dispose]() {\n this._detail[Symbol.dispose]();\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n // istanbul ignore next\n public dispose() {\n this[Symbol.dispose]();\n }\n\n /** @internal */\n public setOnManagerUsedHandler(handler: () => void) {\n this._detail.setOnManagerUsedHandler(handler);\n }\n\n /** Properties used to initialize the manager */\n public get props() {\n return this._props;\n }\n\n /** Get rulesets manager */\n public rulesets(): RulesetManager {\n return this._detail.rulesets;\n }\n\n /**\n * Get ruleset variables manager for specific ruleset\n * @param rulesetId Id of the ruleset to get variables manager for\n */\n public vars(rulesetId: string): RulesetVariablesManager {\n return new RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);\n }\n\n /** @internal */\n public getNativePlatform = (): NativePlatformDefinition => {\n return this._detail.getNativePlatform();\n };\n\n /** @internal */\n // istanbul ignore next\n public getDetail(): PresentationManagerDetail {\n return this._detail;\n }\n\n /** @internal */\n public getRulesetId(rulesetOrId: Ruleset | string) {\n return this._detail.getRulesetId(rulesetOrId);\n }\n\n /**\n * Retrieves nodes\n * @public\n */\n public async getNodes(\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\n ): Promise<Node[]> {\n const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\n return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);\n }\n\n /**\n * Retrieves nodes count\n * @public\n */\n public async getNodesCount(\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<number> {\n return this._detail.getNodesCount(requestOptions);\n }\n\n /**\n * Retrieves hierarchy level descriptor\n * @public\n */\n public async getNodesDescriptor(\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n const response = await this._detail.getNodesDescriptor(requestOptions);\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n }\n\n /**\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\n * TODO: Return results in pages\n * @public\n */\n public async getNodePaths(\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n const result = await this._detail.getNodePaths(requestOptions);\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Retrieves paths from root nodes to nodes containing filter text in their label.\n * TODO: Return results in pages\n * @public\n */\n public async getFilteredNodePaths(\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n const result = await this._detail.getFilteredNodePaths(requestOptions);\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\n * its related instances for loading related and navigation properties.\n * @public\n */\n public async getContentSources(\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\n ): Promise<SelectClassInfo[]> {\n return this._detail.getContentSources(requestOptions);\n }\n\n /**\n * Retrieves the content descriptor which can be used to get content\n * @public\n */\n public async getContentDescriptor(\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n const response = await this._detail.getContentDescriptor(requestOptions);\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n }\n\n /**\n * Retrieves the content set size based on the supplied content descriptor override\n * @public\n */\n public async getContentSetSize(\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\n BackendDiagnosticsAttribute,\n ): Promise<number> {\n return this._detail.getContentSetSize(requestOptions);\n }\n\n /**\n * Retrieves the content set based on the supplied content descriptor.\n * @public\n */\n public async getContentSet(\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\n ): Promise<Item[]> {\n let items = await this._detail.getContentSet({\n ...requestOptions,\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\n });\n\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\n const formatter = new ContentFormatter(\n new ContentPropertyValueFormatter(koqPropertyFormatter),\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\n );\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\n }\n\n return this._localizationHelper.getLocalizedContentItems(items);\n }\n\n /**\n * Retrieves the content based on the supplied content descriptor override.\n * @public\n */\n public async getContent(\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\n BackendDiagnosticsAttribute,\n ): Promise<Content | undefined> {\n const content = await this._detail.getContent({\n ...requestOptions,\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\n });\n\n if (!content) {\n return undefined;\n }\n\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\n const formatter = new ContentFormatter(\n new ContentPropertyValueFormatter(koqPropertyFormatter),\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\n );\n await formatter.formatContent(content);\n }\n\n return this._localizationHelper.getLocalizedContent(content);\n }\n\n /**\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\n * @param requestOptions Options for the request\n * @return A promise object that returns either distinct values on success or an error string on error.\n * @public\n */\n public async getPagedDistinctValues(\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\n BackendDiagnosticsAttribute,\n ): Promise<PagedResponse<DisplayValueGroup>> {\n const result = await this._detail.getPagedDistinctValues(requestOptions);\n return {\n ...result,\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\n };\n }\n\n /**\n * Retrieves property data in a simplified format for a single element specified by ID.\n * @public\n */\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined>;\n /**\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\n * @public\n */\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\n > &\n BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\n }\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\n }\n\n private async getSingleElementProperties<TParsedContent>(\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined> {\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\n const content = await this.getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n if (!content || content.contentSet.length === 0) {\n return undefined;\n }\n return parser(content.descriptor, content.contentSet[0]);\n }\n\n private async getMultipleElementProperties<TParsedContent>(\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\n const { contentParser, batchSize: batchSizeOption, ...contentOptions } = requestOptions;\n\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\n\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\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\n // most `workerThreadsCount / 2` classes in parallel.\n // istanbul ignore next\n const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;\n\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,\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\n // To avoid that, we keep twice as much requests active.\n // istanbul ignore next\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;\n\n // istanbul ignore next\n const batchSize = batchSizeOption ?? 100;\n\n const elementsIdentifier = ((): { elementIds: Id64Array } | { elementClasses: string[] } => {\n if (\"elementIds\" in contentOptions && contentOptions.elementIds !== undefined) {\n const elementIds = contentOptions.elementIds;\n delete contentOptions.elementIds;\n return { elementIds };\n }\n // istanbul ignore else\n if (\"elementClasses\" in contentOptions && contentOptions.elementClasses !== undefined) {\n const elementClasses = contentOptions.elementClasses;\n delete contentOptions.elementClasses;\n return { elementClasses };\n }\n // istanbul ignore next\n return { elementClasses: [\"BisCore:Element\"] };\n })();\n\n const descriptorGetter = async (partialProps: Pick<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\">) =>\n this.getContentDescriptor({ ...contentOptions, displayType: DefaultContentDisplayTypes.Grid, contentFlags: ContentFlags.ShowLabels, ...partialProps });\n const contentSetGetter = async (\n partialProps: Pick<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\" | \"descriptor\">,\n ) => this.getContentSet({ ...contentOptions, ...partialProps });\n const { itemBatches, count } =\n \"elementIds\" in elementsIdentifier\n ? getContentItemsObservableFromElementIds(\n requestOptions.imodel,\n descriptorGetter,\n contentSetGetter,\n elementsIdentifier.elementIds,\n classParallelism,\n batchesParallelism,\n batchSize,\n )\n : getContentItemsObservableFromClassNames(\n requestOptions.imodel,\n descriptorGetter,\n contentSetGetter,\n elementsIdentifier.elementClasses,\n classParallelism,\n batchesParallelism,\n batchSize,\n );\n return {\n total: await firstValueFrom(count),\n async *iterator() {\n for await (const itemsBatch of eachValueFrom(itemBatches)) {\n const { descriptor, items } = itemsBatch;\n yield items.map((item) => parser(descriptor, item));\n }\n },\n };\n }\n\n /**\n * Retrieves display label definition of specific item\n * @public\n */\n public async getDisplayLabelDefinition(\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\n ): Promise<LabelDefinition> {\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\n }\n\n /**\n * Retrieves display label definitions of specific items\n * @public\n */\n public async getDisplayLabelDefinitions(\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\n ): Promise<LabelDefinition[]> {\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\n }\n\n /**\n * Retrieves available selection scopes.\n * @public\n */\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\n return SelectionScopesHelper.getSelectionScopes();\n }\n\n /**\n * Computes selection set based on provided selection scope.\n * @public\n * @deprecated in 3.x. Use overload with `ComputeSelectionRequestOptions` parameter.\n */\n public async computeSelection(\n requestOptions: SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[]; scopeId: string } & BackendDiagnosticsAttribute,\n ): Promise<KeySet>;\n /**\n * Computes selection based on provided element IDs and selection scope.\n * @public\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet>;\n public async computeSelection(\n requestOptions: ((SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[]; scopeId: string }) | ComputeSelectionRequestOptions<IModelDb>) &\n BackendDiagnosticsAttribute,\n ): Promise<KeySet> {\n return SelectionScopesHelper.computeSelection(\n isComputeSelectionRequestOptions(requestOptions)\n ? requestOptions\n : (function () {\n const { ids, scopeId, ...rest } = requestOptions;\n return { ...rest, elementIds: ids, scope: { id: scopeId } };\n })(),\n );\n }\n\n /**\n * Compares two hierarchies specified in the request options\n * @public\n */\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\n return { changes: [] };\n }\n\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\n this._detail.registerRuleset(rulesetOrId);\n\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\n }\n\n const currRulesetVariables = rulesetVariables ?? [];\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\n\n const params = {\n requestId: NativePlatformRequestTypes.CompareHierarchies,\n ...options,\n prevRulesetId: prevRulesetId.uniqueId,\n currRulesetId: currRulesetId.uniqueId,\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\n currRulesetVariables: JSON.stringify(currRulesetVariables),\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\n };\n return JSON.parse(await this._detail.request(params));\n }\n}\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;AAK/C,oEAmDoC;AACpC,uEAA6H;AAC7H,qDAAwF;AACxF,2EAA4F;AAE5F,uEAAiG;AACjG,mEAAgE;AAChE,mCAAuG;AAEvG;;;GAGG;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;AAgQD;;;;;GAKG;AACH,MAAa,mBAAmB;IACtB,MAAM,CAA2B;IACjC,OAAO,CAA4B;IACnC,mBAAmB,CAAqB;IAEhD;;;OAGG;IACH,YAAY,KAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,qDAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,mBAAmB,GAAG,IAAI,wCAAkB,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,IAAI,4BAAoB,EAAE,CAAC,CAAC;IAC/H,CAAC;IAED,6EAA6E;IAC7E,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACvC,CAAC;IACD,uBAAuB;IACvB,IAAW,gBAAgB,CAAC,KAAgC;QAC1D,IAAI,CAAC,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC;IACxC,CAAC;IAED,qFAAqF;IAC9E,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI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AAI,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,2CAA0B,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;AAhbD,kDAgbC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { firstValueFrom } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { Id64Array } from \"@itwin/core-bentley\";\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport {\n buildElementProperties,\n UnitSystemFormat as CommonUnitSystemFormat,\n ComputeSelectionRequestOptions,\n Content,\n ContentDescriptorRequestOptions,\n ContentFlags,\n ContentFormatter,\n ContentPropertyValueFormatter,\n ContentRequestOptions,\n ContentSourcesRequestOptions,\n deepReplaceNullsToUndefined,\n DefaultContentDisplayTypes,\n Descriptor,\n DescriptorOverrides,\n DisplayLabelRequestOptions,\n DisplayLabelsRequestOptions,\n DisplayValueGroup,\n DistinctValuesRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRequestOptions,\n FilterByTextHierarchyRequestOptions,\n FormatsMap,\n HierarchyCompareInfo,\n HierarchyCompareOptions,\n HierarchyLevel,\n HierarchyLevelDescriptorRequestOptions,\n HierarchyRequestOptions,\n InstanceKey,\n isSingleElementPropertiesRequestOptions,\n Item,\n KeySet,\n KoqPropertyValueFormatter,\n LabelDefinition,\n LocalizationHelper,\n MultiElementPropertiesRequestOptions,\n Node,\n NodeKey,\n NodePathElement,\n Paged,\n PagedResponse,\n PresentationError,\n PresentationStatus,\n Prioritized,\n Ruleset,\n RulesetVariable,\n SelectClassInfo,\n SelectionScope,\n SelectionScopeRequestOptions,\n SingleElementPropertiesRequestOptions,\n WithCancelEvent,\n} from \"@itwin/presentation-common\";\nimport { getContentItemsObservableFromClassNames, getContentItemsObservableFromElementIds } from \"./ElementPropertiesHelper\";\nimport { NativePlatformDefinition, NativePlatformRequestTypes } from \"./NativePlatform\";\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail\";\nimport { RulesetManager } from \"./RulesetManager\";\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper\";\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils\";\n\n/**\n * Presentation hierarchy cache mode.\n * @public\n */\nexport enum HierarchyCacheMode {\n /**\n * Hierarchy cache is created in memory.\n */\n Memory = \"memory\",\n /**\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\n * openings.\n */\n Disk = \"disk\",\n /**\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\n * and persisted in disk cache when whole hierarchy level is created.\n *\n * **Note:** This mode is still experimental.\n */\n Hybrid = \"hybrid\",\n}\n\n/**\n * Configuration for hierarchy cache.\n * @public\n */\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\n\n/**\n * Base interface for all [[HierarchyCacheConfig]] implementations.\n * @public\n */\nexport interface HierarchyCacheConfigBase {\n mode: HierarchyCacheMode;\n}\n\n/**\n * Configuration for in-memory hierarchy cache.\n *\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\n * @public\n */\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Memory;\n}\n\n/**\n * Configuration for persistent disk hierarchy cache.\n *\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\n * @public\n */\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Disk;\n\n /**\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\n *\n * The default directory depends on the iModel and the way it's opened.\n */\n directory?: string;\n\n /**\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\n */\n memoryCacheSize?: number;\n}\n\n/**\n * Configuration for the experimental hybrid hierarchy cache.\n *\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\n * alternative for cases when there are lots of simultaneous requests.\n *\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\n * @public\n */\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Hybrid;\n\n /** Configuration for disk cache used to persist hierarchies. */\n disk?: DiskHierarchyCacheConfig;\n}\n\n/**\n * Configuration for content cache.\n *\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\n * @public\n */\nexport interface ContentCacheConfig {\n /**\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\n *\n * Defaults to `100`.\n */\n size?: number;\n}\n\n/**\n * Caching configuration options for [[PresentationManager]].\n * @public\n */\nexport interface PresentationManagerCachingConfig {\n /**\n * Hierarchies-related caching options.\n *\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\n */\n hierarchies?: HierarchyCacheConfig;\n\n /**\n * Content-related caching options.\n *\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\n */\n content?: ContentCacheConfig;\n\n /**\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\n * cache. Defaults to `32768000` bytes (32 MB).\n *\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\n */\n workerConnectionCacheSize?: number;\n}\n\n/**\n * A data structure that associates unit systems with a format. The associations are used for\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\n *\n * @public\n * @deprecated in 4.3. The type has been moved to `@itwin/presentation-common` package.\n */\nexport type UnitSystemFormat = CommonUnitSystemFormat;\n\n/**\n * Data structure for multiple element properties request response.\n * @public\n */\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\n total: number;\n iterator: () => AsyncGenerator<TParsedContent[]>;\n}\n\n/**\n * Configuration options for supplying asset paths to [[PresentationManager]].\n * @public\n */\nexport interface PresentationAssetsRootConfig {\n /**\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\n */\n backend: string;\n}\n\n/**\n * Properties that can be used to configure [[PresentationManager]]\n * @public\n */\nexport interface PresentationManagerProps {\n /**\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\n *\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\n *\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:\n * - `assets/*\\*\\/*`\n * - `presentation-backend/{presentation-backend source files}`\n *\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\n *\n * - else, assume the backend is webpacked into a single file with assets next to it:\n * - `assets/*\\*\\/*`\n * - `{source file being executed}.js`\n *\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\n *\n * @deprecated in 4.2. This attribute is not used anymore - the package is not using private assets anymore.\n */\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\n\n /**\n * A list of directories containing application's presentation rulesets. Relative\n * paths start from `process.cwd()`. The directories are traversed recursively.\n *\n * @note Only files with `.PresentationRuleSet.json` are read.\n */\n rulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's supplemental presentation rulesets. Relative\n * paths start from `process.cwd()`. The directories are traversed recursively.\n *\n * @note Only files with `.PresentationRuleSet.json` are read.\n */\n supplementalRulesetDirectories?: string[];\n\n /**\n * Sets the active unit system to use for formatting property values with\n * units. Default presentation units are used if this is not specified. The active unit\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\n * through request options.\n */\n defaultUnitSystem?: UnitSystemKey;\n\n /**\n * A map of default unit formats to use for formatting properties that don't have a presentation format\n * in requested unit system.\n */\n defaultFormats?: FormatsMap;\n\n /**\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\n */\n workerThreadsCount?: number;\n\n /**\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\n * data changes are not tracked at all.\n *\n * @beta\n * @deprecated in 4.4. The manager now always tracks for iModel data changes without polling.\n */\n updatesPollInterval?: number;\n\n /** Options for caching. */\n caching?: PresentationManagerCachingConfig;\n\n /**\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\n *\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.\n */\n useMmap?: boolean | number;\n\n /**\n * An identifier which helps separate multiple presentation managers. It's\n * mostly useful in tests where multiple presentation managers can co-exist\n * and try to share the same resources, which we don't want. With this identifier\n * set, managers put their resources into id-named subdirectories.\n *\n * @internal\n */\n id?: string;\n\n /** @internal */\n addon?: NativePlatformDefinition;\n\n /**\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\n * data is localized on the frontend). Defaults to English localization.\n *\n * @see [Localization]($docs/presentation/advanced/Localization)\n */\n getLocalizedString?: (key: string) => string;\n\n /**\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\n */\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\n\n /**\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\n * made through the manager.\n *\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\n */\n diagnostics?: BackendDiagnosticsOptions;\n}\n\n/**\n * Backend Presentation manager which pulls the presentation data from\n * an iModel using native platform.\n *\n * @public\n */\nexport class PresentationManager {\n private _props: PresentationManagerProps;\n private _detail: PresentationManagerDetail;\n private _localizationHelper: LocalizationHelper;\n\n /**\n * Creates an instance of PresentationManager.\n * @param props Optional configuration properties.\n */\n constructor(props?: PresentationManagerProps) {\n this._props = props ?? {};\n this._detail = new PresentationManagerDetail(this._props);\n\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\n }\n\n /** Get / set active unit system used to format property values with units */\n public get activeUnitSystem(): UnitSystemKey | undefined {\n return this._detail.activeUnitSystem;\n }\n // istanbul ignore next\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\n this._detail.activeUnitSystem = value;\n }\n\n /** Dispose the presentation manager. Must be called to clean up native resources. */\n public [Symbol.dispose]() {\n this._detail[Symbol.dispose]();\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n // istanbul ignore next\n public dispose() {\n this[Symbol.dispose]();\n }\n\n /** @internal */\n public setOnManagerUsedHandler(handler: () => void) {\n this._detail.setOnManagerUsedHandler(handler);\n }\n\n /** Properties used to initialize the manager */\n public get props() {\n return this._props;\n }\n\n /** Get rulesets manager */\n public rulesets(): RulesetManager {\n return this._detail.rulesets;\n }\n\n /**\n * Get ruleset variables manager for specific ruleset\n * @param rulesetId Id of the ruleset to get variables manager for\n */\n public vars(rulesetId: string): RulesetVariablesManager {\n return new RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);\n }\n\n /** @internal */\n public getNativePlatform = (): NativePlatformDefinition => {\n return this._detail.getNativePlatform();\n };\n\n /** @internal */\n // istanbul ignore next\n public getDetail(): PresentationManagerDetail {\n return this._detail;\n }\n\n /** @internal */\n public getRulesetId(rulesetOrId: Ruleset | string) {\n return this._detail.getRulesetId(rulesetOrId);\n }\n\n /**\n * Retrieves nodes\n * @public\n */\n public async getNodes(\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\n ): Promise<Node[]> {\n const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\n return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);\n }\n\n /**\n * Retrieves nodes count\n * @public\n */\n public async getNodesCount(\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<number> {\n return this._detail.getNodesCount(requestOptions);\n }\n\n /**\n * Retrieves hierarchy level descriptor\n * @public\n */\n public async getNodesDescriptor(\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n const response = await this._detail.getNodesDescriptor(requestOptions);\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n }\n\n /**\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\n * TODO: Return results in pages\n * @public\n */\n public async getNodePaths(\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n const result = await this._detail.getNodePaths(requestOptions);\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Retrieves paths from root nodes to nodes containing filter text in their label.\n * TODO: Return results in pages\n * @public\n */\n public async getFilteredNodePaths(\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n const result = await this._detail.getFilteredNodePaths(requestOptions);\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\n * its related instances for loading related and navigation properties.\n * @public\n */\n public async getContentSources(\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\n ): Promise<SelectClassInfo[]> {\n return this._detail.getContentSources(requestOptions);\n }\n\n /**\n * Retrieves the content descriptor which can be used to get content\n * @public\n */\n public async getContentDescriptor(\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n const response = await this._detail.getContentDescriptor(requestOptions);\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n }\n\n /**\n * Retrieves the content set size based on the supplied content descriptor override\n * @public\n */\n public async getContentSetSize(\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\n BackendDiagnosticsAttribute,\n ): Promise<number> {\n return this._detail.getContentSetSize(requestOptions);\n }\n\n /**\n * Retrieves the content set based on the supplied content descriptor.\n * @public\n */\n public async getContentSet(\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\n ): Promise<Item[]> {\n let items = await this._detail.getContentSet({\n ...requestOptions,\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\n });\n\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\n const formatter = new ContentFormatter(\n new ContentPropertyValueFormatter(koqPropertyFormatter),\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\n );\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\n }\n\n return this._localizationHelper.getLocalizedContentItems(items);\n }\n\n /**\n * Retrieves the content based on the supplied content descriptor override.\n * @public\n */\n public async getContent(\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\n BackendDiagnosticsAttribute,\n ): Promise<Content | undefined> {\n const content = await this._detail.getContent({\n ...requestOptions,\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\n });\n\n if (!content) {\n return undefined;\n }\n\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\n const formatter = new ContentFormatter(\n new ContentPropertyValueFormatter(koqPropertyFormatter),\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\n );\n await formatter.formatContent(content);\n }\n\n return this._localizationHelper.getLocalizedContent(content);\n }\n\n /**\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\n * @param requestOptions Options for the request\n * @return A promise object that returns either distinct values on success or an error string on error.\n * @public\n */\n public async getPagedDistinctValues(\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\n BackendDiagnosticsAttribute,\n ): Promise<PagedResponse<DisplayValueGroup>> {\n const result = await this._detail.getPagedDistinctValues(requestOptions);\n return {\n ...result,\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\n };\n }\n\n /**\n * Retrieves property data in a simplified format for a single element specified by ID.\n * @public\n */\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined>;\n /**\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\n * @public\n */\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\n > &\n BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\n }\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\n }\n\n private async getSingleElementProperties<TParsedContent>(\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined> {\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\n const content = await this.getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n if (!content || content.contentSet.length === 0) {\n return undefined;\n }\n return parser(content.descriptor, content.contentSet[0]);\n }\n\n private async getMultipleElementProperties<TParsedContent>(\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\n const { contentParser, batchSize: batchSizeOption, ...contentOptions } = requestOptions;\n\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\n\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\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\n // most `workerThreadsCount / 2` classes in parallel.\n // istanbul ignore next\n const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;\n\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,\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\n // To avoid that, we keep twice as much requests active.\n // istanbul ignore next\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;\n\n // istanbul ignore next\n const batchSize = batchSizeOption ?? 100;\n\n const elementsIdentifier = ((): { elementIds: Id64Array } | { elementClasses: string[] } => {\n if (\"elementIds\" in contentOptions && contentOptions.elementIds !== undefined) {\n const elementIds = contentOptions.elementIds;\n delete contentOptions.elementIds;\n return { elementIds };\n }\n // istanbul ignore else\n if (\"elementClasses\" in contentOptions && contentOptions.elementClasses !== undefined) {\n const elementClasses = contentOptions.elementClasses;\n delete contentOptions.elementClasses;\n return { elementClasses };\n }\n // istanbul ignore next\n return { elementClasses: [\"BisCore:Element\"] };\n })();\n\n const descriptorGetter = async (partialProps: Pick<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\">) =>\n this.getContentDescriptor({ ...contentOptions, displayType: DefaultContentDisplayTypes.Grid, contentFlags: ContentFlags.ShowLabels, ...partialProps });\n const contentSetGetter = async (\n partialProps: Pick<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\" | \"descriptor\">,\n ) => this.getContentSet({ ...contentOptions, ...partialProps });\n const { itemBatches, count } =\n \"elementIds\" in elementsIdentifier\n ? getContentItemsObservableFromElementIds(\n requestOptions.imodel,\n descriptorGetter,\n contentSetGetter,\n elementsIdentifier.elementIds,\n classParallelism,\n batchesParallelism,\n batchSize,\n )\n : getContentItemsObservableFromClassNames(\n requestOptions.imodel,\n descriptorGetter,\n contentSetGetter,\n elementsIdentifier.elementClasses,\n classParallelism,\n batchesParallelism,\n batchSize,\n );\n return {\n total: await firstValueFrom(count),\n async *iterator() {\n for await (const itemsBatch of eachValueFrom(itemBatches)) {\n const { descriptor, items } = itemsBatch;\n yield items.map((item) => parser(descriptor, item));\n }\n },\n };\n }\n\n /**\n * Retrieves display label definition of specific item\n * @public\n */\n public async getDisplayLabelDefinition(\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\n ): Promise<LabelDefinition> {\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\n }\n\n /**\n * Retrieves display label definitions of specific items\n * @public\n */\n public async getDisplayLabelDefinitions(\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\n ): Promise<LabelDefinition[]> {\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\n }\n\n /**\n * Retrieves available selection scopes.\n * @public\n */\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\n return SelectionScopesHelper.getSelectionScopes();\n }\n\n /**\n * Computes selection based on provided element IDs and selection scope.\n * @public\n */\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet> {\n return SelectionScopesHelper.computeSelection(requestOptions);\n }\n\n /**\n * Compares two hierarchies specified in the request options\n * @public\n */\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\n return { changes: [] };\n }\n\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\n this._detail.registerRuleset(rulesetOrId);\n\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\n }\n\n const currRulesetVariables = rulesetVariables ?? [];\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\n\n const params = {\n requestId: NativePlatformRequestTypes.CompareHierarchies,\n ...options,\n prevRulesetId: prevRulesetId.uniqueId,\n currRulesetId: currRulesetId.uniqueId,\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\n currRulesetVariables: JSON.stringify(currRulesetVariables),\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\n };\n return JSON.parse(await this._detail.request(params));\n }\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module RPC
|
|
3
3
|
*/
|
|
4
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
5
4
|
import { IModelRpcProps } from "@itwin/core-common";
|
|
6
5
|
import { ComputeSelectionRpcRequestOptions, ContentDescriptorRpcRequestOptions, ContentInstanceKeysRpcRequestOptions, ContentRpcRequestOptions, ContentSourcesRpcRequestOptions, ContentSourcesRpcResult, DescriptorJSON, DisplayLabelRpcRequestOptions, DisplayLabelsRpcRequestOptions, DisplayValueGroup, DistinctValuesRpcRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRpcRequestOptions, FilterByTextHierarchyRpcRequestOptions, HierarchyLevelDescriptorRpcRequestOptions, HierarchyRpcRequestOptions, ItemJSON, KeySetJSON, LabelDefinition, Node, NodePathElement, Paged, PagedResponse, PresentationRpcInterface, PresentationRpcResponse, SelectionScope, SelectionScopeRpcRequestOptions, SingleElementPropertiesRpcRequestOptions } from "@itwin/presentation-common";
|
|
7
6
|
import { PresentationManager } from "./PresentationManager";
|
|
@@ -58,6 +57,6 @@ export declare class PresentationRpcImpl extends PresentationRpcInterface implem
|
|
|
58
57
|
getDisplayLabelDefinition(token: IModelRpcProps, requestOptions: DisplayLabelRpcRequestOptions): PresentationRpcResponse<LabelDefinition>;
|
|
59
58
|
getPagedDisplayLabelDefinitions(token: IModelRpcProps, requestOptions: DisplayLabelsRpcRequestOptions): PresentationRpcResponse<PagedResponse<LabelDefinition>>;
|
|
60
59
|
getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]>;
|
|
61
|
-
computeSelection(token: IModelRpcProps, requestOptions: ComputeSelectionRpcRequestOptions
|
|
60
|
+
computeSelection(token: IModelRpcProps, requestOptions: ComputeSelectionRpcRequestOptions): PresentationRpcResponse<KeySetJSON>;
|
|
62
61
|
}
|
|
63
62
|
//# sourceMappingURL=PresentationRpcImpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"PresentationRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAGL,iCAAiC,EACjC,kCAAkC,EAElC,oCAAoC,EACpC,wBAAwB,EACxB,+BAA+B,EAC/B,uBAAuB,EAGvB,cAAc,EAEd,6BAA6B,EAC7B,8BAA8B,EAC9B,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,+CAA+C,EAC/C,sCAAsC,EAEtC,yCAAyC,EACzC,0BAA0B,EAC1B,QAAQ,EAER,UAAU,EACV,eAAe,EACf,IAAI,EACJ,eAAe,EACf,KAAK,EACL,aAAa,EAGb,wBAAwB,EACxB,uBAAuB,EAQvB,cAAc,EACd,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAOtD,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,gBAAgB;AAChB,eAAO,MAAM,0BAA0B,QAAQ,CAAC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AAc,EAAE,cAAc,EAAE,iCAAiC,GAAG,uBAAuB,CAAC,UAAU,CAAC;CAMtJ"}
|
|
@@ -368,15 +368,8 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
368
368
|
async getSelectionScopes(token, requestOptions) {
|
|
369
369
|
return this.makeRequest(token, "getSelectionScopes", requestOptions, async (options) => this.getManager(requestOptions.clientId).getSelectionScopes(options));
|
|
370
370
|
}
|
|
371
|
-
async computeSelection(token, requestOptions
|
|
371
|
+
async computeSelection(token, requestOptions) {
|
|
372
372
|
return this.makeRequest(token, "computeSelection", requestOptions, async (options) => {
|
|
373
|
-
if (!(0, presentation_common_1.isComputeSelectionRequestOptions)(options)) {
|
|
374
|
-
options = {
|
|
375
|
-
...options,
|
|
376
|
-
elementIds: ids,
|
|
377
|
-
scope: { id: scopeId },
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
373
|
const keys = await this.getManager(requestOptions.clientId).computeSelection(options);
|
|
381
374
|
return keys.toJSON();
|
|
382
375
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationRpcImpl.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAyD;AACzD,sDAAkE;AAElE,oEAgDoC;AACpC,mEAA4E;AAC5E,iDAA8C;AAE9C,yDAAsD;AAEtD,iEAAiE;AACjE,MAAM,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC;AAIpE,gBAAgB;AACH,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAC1C,gBAAgB;AACH,QAAA,0BAA0B,GAAG,KAAK,CAAC;AAEhD,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,8CAAwB;IACvD,eAAe,CAAS;IACxB,gBAAgB,CAAiD;IACjE,aAAa,CAAmC;IAExD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AE,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC;IAC1F,CAAC;IACD,OAAO,cAAoD,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAwB,EAAE,WAAmB,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,CAAC;IAChC,OAAO,aAAa,KAAK,CAAC,IAAI,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;AAC1F,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RPC\n */\n\nimport { IModelDb, RpcTrace } from \"@itwin/core-backend\";\nimport { BeEvent, Id64String, Logger } from \"@itwin/core-bentley\";\nimport { IModelRpcProps } from \"@itwin/core-common\";\nimport {\n buildElementProperties,\n ClientDiagnostics,\n ComputeSelectionRequestOptions,\n ComputeSelectionRpcRequestOptions,\n ContentDescriptorRpcRequestOptions,\n ContentFlags,\n ContentInstanceKeysRpcRequestOptions,\n ContentRpcRequestOptions,\n ContentSourcesRpcRequestOptions,\n ContentSourcesRpcResult,\n deepReplaceNullsToUndefined,\n DefaultContentDisplayTypes,\n DescriptorJSON,\n Diagnostics,\n DisplayLabelRpcRequestOptions,\n DisplayLabelsRpcRequestOptions,\n DisplayValueGroup,\n DistinctValuesRpcRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRpcRequestOptions,\n FilterByTextHierarchyRpcRequestOptions,\n HierarchyLevel,\n HierarchyLevelDescriptorRpcRequestOptions,\n HierarchyRpcRequestOptions,\n isComputeSelectionRequestOptions,\n ItemJSON,\n KeySet,\n KeySetJSON,\n LabelDefinition,\n Node,\n NodePathElement,\n Paged,\n PagedResponse,\n PageOptions,\n PresentationError,\n PresentationRpcInterface,\n PresentationRpcResponse,\n PresentationRpcResponseData,\n PresentationStatus,\n RpcDiagnosticsOptions,\n Ruleset,\n RulesetVariable,\n RulesetVariableJSON,\n SelectClassInfo,\n SelectionScope,\n SelectionScopeRpcRequestOptions,\n SingleElementPropertiesRpcRequestOptions,\n} from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { Presentation } from \"./Presentation\";\nimport { PresentationManager } from \"./PresentationManager\";\nimport { TemporaryStorage } from \"./TemporaryStorage\";\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst packageJsonVersion = require(\"../../../package.json\").version;\n\ntype ContentGetter<TResult = any, TOptions = any> = (requestOptions: TOptions) => TResult;\n\n/** @internal */\nexport const MAX_ALLOWED_PAGE_SIZE = 1000;\n/** @internal */\nexport const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;\n\nconst DEFAULT_REQUEST_TIMEOUT = 5000;\n\n/**\n * The backend implementation of PresentationRpcInterface. All it's basically\n * responsible for is forwarding calls to [[Presentation.manager]].\n *\n * @internal\n */\nexport class PresentationRpcImpl extends PresentationRpcInterface implements Disposable {\n private _requestTimeout: number;\n private _pendingRequests: TemporaryStorage<PresentationRpcResponse<any>>;\n private _cancelEvents: Map<string, BeEvent<() => void>>;\n\n public constructor(props?: { requestTimeout?: number }) {\n super();\n this._requestTimeout = props?.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;\n this._pendingRequests = new TemporaryStorage({\n // remove the pending request after request timeout + 10 seconds - this gives\n // frontend 10 seconds to re-send the request until it's removed from requests' cache\n unusedValueLifetime: this._requestTimeout > 0 ? this._requestTimeout + 10 * 1000 : undefined,\n\n // attempt to clean up every second\n cleanupInterval: 1000,\n\n cleanupHandler: (id, _, reason) => {\n if (reason !== \"request\") {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);\n // istanbul ignore next\n this._cancelEvents.get(id)?.raiseEvent();\n }\n this._cancelEvents.delete(id);\n },\n });\n this._cancelEvents = new Map<string, BeEvent<() => void>>();\n }\n\n public [Symbol.dispose]() {\n this._pendingRequests[Symbol.dispose]();\n }\n\n public get requestTimeout() {\n return this._requestTimeout;\n }\n\n public get pendingRequests() {\n return this._pendingRequests;\n }\n\n /** Returns an ok response with result inside */\n private successResponse<TResult>(result: TResult, diagnostics?: ClientDiagnostics) {\n return {\n statusCode: PresentationStatus.Success,\n result,\n diagnostics,\n };\n }\n\n /** Returns a bad request response with empty result and an error code */\n private errorResponse(errorCode: PresentationStatus, errorMessage?: string, diagnostics?: ClientDiagnostics) {\n return {\n statusCode: errorCode,\n result: undefined,\n errorMessage,\n diagnostics,\n };\n }\n\n /**\n * Get the [[PresentationManager]] used by this RPC impl.\n */\n public getManager(clientId?: string): PresentationManager {\n return Presentation.getManager(clientId);\n }\n\n private async getIModel(token: IModelRpcProps): Promise<IModelDb> {\n const imodel = IModelDb.findByKey(token.key);\n // call refreshContainer, just in case this is a V2 checkpoint whose sasToken is about to expire, or its default transaction is about to be restarted.\n await imodel.refreshContainerForRpc(RpcTrace.expectCurrentActivity.accessToken);\n return imodel;\n }\n\n private async makeRequest<\n TRpcOptions extends { rulesetOrId?: Ruleset | string; clientId?: string; diagnostics?: RpcDiagnosticsOptions; rulesetVariables?: RulesetVariableJSON[] },\n TResult,\n >(token: IModelRpcProps, requestId: string, requestOptions: TRpcOptions, request: ContentGetter<Promise<TResult>>): PresentationRpcResponse<TResult> {\n const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });\n\n Logger.logInfo(PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);\n\n const imodel = await this.getIModel(token);\n\n let resultPromise = this._pendingRequests.getValue(requestKey);\n if (resultPromise) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request already pending`);\n } else {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request not found, creating a new one`);\n const { clientId: _, diagnostics: diagnosticsOptions, rulesetVariables, ...options } = requestOptions;\n const managerRequestOptions: any = {\n ...options,\n imodel,\n cancelEvent: new BeEvent<() => void>(),\n };\n\n // set up ruleset variables\n if (rulesetVariables) {\n managerRequestOptions.rulesetVariables = rulesetVariables.map(RulesetVariable.fromJSON);\n }\n\n // set up diagnostics listener\n let diagnostics: ClientDiagnostics | undefined;\n const getDiagnostics = (): ClientDiagnostics => {\n if (!diagnostics) {\n diagnostics = {};\n }\n return diagnostics;\n };\n if (diagnosticsOptions) {\n if (diagnosticsOptions.backendVersion) {\n getDiagnostics().backendVersion = packageJsonVersion;\n }\n managerRequestOptions.diagnostics = {\n ...diagnosticsOptions,\n handler: (d: Diagnostics) => {\n if (d.logs) {\n const target = getDiagnostics();\n if (target.logs) {\n target.logs.push(...d.logs);\n } else {\n target.logs = [...d.logs];\n }\n }\n },\n };\n }\n\n // initiate request\n resultPromise = request(managerRequestOptions)\n .then((result) => this.successResponse(result, diagnostics))\n .catch((e: unknown) => {\n if (e instanceof PresentationError) {\n return this.errorResponse(e.errorNumber, e.message, diagnostics);\n }\n throw e;\n });\n\n // store the request promise\n this._pendingRequests.addValue(requestKey, resultPromise);\n this._cancelEvents.set(requestKey, managerRequestOptions.cancelEvent);\n }\n\n if (this._requestTimeout === 0) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout not configured, returning promise without a timeout.`);\n void resultPromise.finally(() => {\n this._pendingRequests.deleteValue(requestKey);\n });\n return resultPromise;\n }\n\n let timeout: NodeJS.Timeout;\n const timeoutPromise = new Promise<any>((_resolve, reject) => {\n timeout = setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(\"timeout\");\n }, this._requestTimeout);\n });\n\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);\n return Promise.race([resultPromise, timeoutPromise])\n .catch<PresentationRpcResponseData>((e: unknown) => {\n if (e === \"timeout\") {\n // note: error responses from the manager get handled when creating `resultPromise`, so we can only get here due\n // to a timeout exception\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout, returning \"BackendTimeout\" status.`);\n return this.errorResponse(PresentationStatus.BackendTimeout);\n }\n // ...or an error that we don't want to reveal - let RPC system handle it.\n throw e;\n })\n .then((response: PresentationRpcResponseData<TResult>) => {\n if (response.statusCode !== PresentationStatus.BackendTimeout) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);\n this._pendingRequests.deleteValue(requestKey);\n }\n return response;\n })\n .finally(() => {\n clearTimeout(timeout);\n });\n }\n\n public override async getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {\n return this.makeRequest(token, \"getNodesCount\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getNodesCount(options);\n });\n }\n\n public override async getPagedNodes(token: IModelRpcProps, requestOptions: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<Node>> {\n return this.makeRequest(token, \"getPagedNodes\", requestOptions, async (options) => {\n options = enforceValidPageSize(options);\n const [serializedHierarchyLevel, count] = await Promise.all([\n this.getManager(requestOptions.clientId).getDetail().getNodes(options),\n this.getManager(requestOptions.clientId).getNodesCount(options),\n ]);\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\n return {\n total: count,\n items: hierarchyLevel.nodes,\n };\n });\n }\n\n public override async getNodesDescriptor(\n token: IModelRpcProps,\n requestOptions: HierarchyLevelDescriptorRpcRequestOptions,\n ): PresentationRpcResponse<string | DescriptorJSON | undefined> {\n return this.makeRequest(token, \"getNodesDescriptor\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getNodesDescriptor(options);\n });\n }\n\n public override async getNodePaths(\n token: IModelRpcProps,\n requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions,\n ): PresentationRpcResponse<NodePathElement[]> {\n return this.makeRequest(token, \"getNodePaths\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getNodePaths(options);\n });\n }\n\n public override async getFilteredNodePaths(\n token: IModelRpcProps,\n requestOptions: FilterByTextHierarchyRpcRequestOptions,\n ): PresentationRpcResponse<NodePathElement[]> {\n return this.makeRequest(token, \"getFilteredNodePaths\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getFilteredNodePaths(options);\n });\n }\n\n public override async getContentSources(\n token: IModelRpcProps,\n requestOptions: ContentSourcesRpcRequestOptions,\n ): PresentationRpcResponse<ContentSourcesRpcResult> {\n return this.makeRequest(token, \"getContentSources\", requestOptions, async (options) => {\n const result = await this.getManager(requestOptions.clientId).getContentSources(options);\n const classesMap = {};\n const selectClasses = result.map((sci) => SelectClassInfo.toCompressedJSON(sci, classesMap));\n return { sources: selectClasses, classesMap };\n });\n }\n\n public override async getContentDescriptor(\n token: IModelRpcProps,\n requestOptions: ContentDescriptorRpcRequestOptions,\n ): PresentationRpcResponse<DescriptorJSON | undefined> {\n return this.makeRequest(token, \"getContentDescriptor\", requestOptions, async (options) => {\n options = {\n ...options,\n contentFlags: (options.contentFlags ?? 0) | ContentFlags.DescriptorOnly, // always append the \"descriptor only\" flag when handling request from the frontend\n keys: KeySet.fromJSON(options.keys),\n };\n if (options.transport === \"unparsed-json\") {\n // Here we send a plain JSON string but we will parse it to DescriptorJSON on the frontend. This way we are\n // bypassing unnecessary deserialization and serialization.\n return Presentation.getManager(requestOptions.clientId).getDetail().getContentDescriptor(options) as unknown as DescriptorJSON | undefined;\n } else {\n // Support for older frontends that still expect a parsed descriptor\n const descriptor = await Presentation.getManager(requestOptions.clientId).getContentDescriptor(options);\n return descriptor?.toJSON();\n }\n });\n }\n\n public override async getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number> {\n return this.makeRequest(token, \"getContentSetSize\", requestOptions, async (options) => {\n options = {\n ...options,\n keys: KeySet.fromJSON(options.keys),\n };\n return this.getManager(requestOptions.clientId).getContentSetSize(options);\n });\n }\n\n public override async getPagedContent(\n token: IModelRpcProps,\n requestOptions: Paged<ContentRpcRequestOptions>,\n ): PresentationRpcResponse<{ descriptor: DescriptorJSON; contentSet: PagedResponse<ItemJSON> } | undefined> {\n return this.makeRequest(token, \"getPagedContent\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n keys: KeySet.fromJSON(options.keys),\n });\n\n const [size, content] = await Promise.all([\n this.getManager(requestOptions.clientId).getContentSetSize(options),\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\n ]);\n\n if (!content) {\n return undefined;\n }\n\n return {\n descriptor: content.descriptor.toJSON(),\n contentSet: {\n total: size,\n items: content.contentSet.map((i) => i.toJSON()),\n },\n };\n });\n }\n\n public override async getPagedContentSet(\n token: IModelRpcProps,\n requestOptions: Paged<ContentRpcRequestOptions>,\n ): PresentationRpcResponse<PagedResponse<ItemJSON>> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const response = await this.getPagedContent(token, requestOptions);\n if (response.statusCode !== PresentationStatus.Success) {\n return this.errorResponse(response.statusCode, response.errorMessage, response.diagnostics);\n }\n if (!response.result) {\n return this.errorResponse(PresentationStatus.Error, `Failed to get content set (received a success response with empty result)`, response.diagnostics);\n }\n return {\n ...response,\n result: response.result.contentSet,\n };\n }\n\n public override async getElementProperties(\n token: IModelRpcProps,\n requestOptions: SingleElementPropertiesRpcRequestOptions,\n ): PresentationRpcResponse<ElementProperties | undefined> {\n return this.makeRequest(token, \"getElementProperties\", { ...requestOptions }, async (options) => {\n const manager = this.getManager(requestOptions.clientId);\n const { elementId, ...optionsNoElementId } = options;\n const content = await manager.getDetail().getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n if (!content || content.contentSet.length === 0) {\n return undefined;\n }\n return buildElementProperties(content.descriptor, content.contentSet[0]);\n });\n }\n\n public override async getPagedDistinctValues(\n token: IModelRpcProps,\n requestOptions: DistinctValuesRpcRequestOptions,\n ): PresentationRpcResponse<PagedResponse<DisplayValueGroup>> {\n return this.makeRequest(token, \"getPagedDistinctValues\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n keys: KeySet.fromJSON(options.keys),\n });\n return this.getManager(requestOptions.clientId).getDetail().getPagedDistinctValues(options);\n });\n }\n\n public override async getContentInstanceKeys(\n token: IModelRpcProps,\n requestOptions: ContentInstanceKeysRpcRequestOptions,\n ): PresentationRpcResponse<{ total: number; items: KeySetJSON }> {\n return this.makeRequest(token, \"getContentInstanceKeys\", requestOptions, async (options) => {\n const { displayType, ...optionsNoDisplayType } = options;\n options = enforceValidPageSize(\n {\n ...optionsNoDisplayType,\n keys: KeySet.fromJSON(optionsNoDisplayType.keys),\n descriptor: {\n displayType,\n contentFlags: ContentFlags.KeysOnly,\n },\n },\n MAX_ALLOWED_KEYS_PAGE_SIZE,\n );\n\n const [size, content] = await Promise.all([\n this.getManager(requestOptions.clientId).getContentSetSize(options),\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\n ]);\n\n if (size === 0 || !content) {\n return { total: 0, items: new KeySet().toJSON() };\n }\n\n return {\n total: size,\n items: content.contentSet.reduce((keys, item) => keys.add(item.primaryKeys), new KeySet()).toJSON(),\n };\n });\n }\n\n public override async getDisplayLabelDefinition(\n token: IModelRpcProps,\n requestOptions: DisplayLabelRpcRequestOptions,\n ): PresentationRpcResponse<LabelDefinition> {\n return this.makeRequest(token, \"getDisplayLabelDefinition\", requestOptions, async (options) => {\n const label = await this.getManager(requestOptions.clientId).getDetail().getDisplayLabelDefinition(options);\n return label;\n });\n }\n\n public override async getPagedDisplayLabelDefinitions(\n token: IModelRpcProps,\n requestOptions: DisplayLabelsRpcRequestOptions,\n ): PresentationRpcResponse<PagedResponse<LabelDefinition>> {\n const pageOpts = enforceValidPageSize({ paging: { start: 0, size: requestOptions.keys.length } });\n if (pageOpts.paging.size < requestOptions.keys.length) {\n requestOptions.keys.splice(pageOpts.paging.size);\n }\n return this.makeRequest(token, \"getPagedDisplayLabelDefinitions\", requestOptions, async (options) => {\n const labels = await this.getManager(requestOptions.clientId)\n .getDetail()\n .getDisplayLabelDefinitions({ ...options, keys: options.keys });\n return {\n total: options.keys.length,\n items: labels,\n };\n });\n }\n\n public override async getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {\n return this.makeRequest(token, \"getSelectionScopes\", requestOptions, async (options) =>\n this.getManager(requestOptions.clientId).getSelectionScopes(options),\n );\n }\n\n public override async computeSelection(\n token: IModelRpcProps,\n requestOptions: ComputeSelectionRpcRequestOptions | SelectionScopeRpcRequestOptions,\n ids?: Id64String[],\n scopeId?: string,\n ): PresentationRpcResponse<KeySetJSON> {\n return this.makeRequest(token, \"computeSelection\", requestOptions, async (options) => {\n if (!isComputeSelectionRequestOptions(options)) {\n options = {\n ...options,\n elementIds: ids!,\n scope: { id: scopeId! },\n };\n }\n const keys = await this.getManager(requestOptions.clientId).computeSelection(options as ComputeSelectionRequestOptions<IModelDb>);\n return keys.toJSON();\n });\n }\n}\n\nconst enforceValidPageSize = <TOptions extends Paged<object>>(\n requestOptions: TOptions,\n maxPageSize = MAX_ALLOWED_PAGE_SIZE,\n): TOptions & { paging: PageOptions } => {\n const validPageSize = getValidPageSize(requestOptions.paging?.size, maxPageSize);\n if (!requestOptions.paging || requestOptions.paging.size !== validPageSize) {\n return { ...requestOptions, paging: { ...requestOptions.paging, size: validPageSize } };\n }\n return requestOptions as TOptions & { paging: PageOptions };\n};\n\nconst getValidPageSize = (size: number | undefined, maxPageSize: number) => {\n const requestedSize = size ?? 0;\n return requestedSize === 0 || requestedSize > maxPageSize ? maxPageSize : requestedSize;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationRpcImpl.js","sourceR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oBAAoB,GAAG,CAC3B,cAAwB,EACxB,WAAW,GAAG,6BAAqB,EACC,EAAE;IACtC,MAAM,aAAa,GAAG,gBAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IACjF,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC3E,OAAO,EAAE,GAAG,cAAc,EAAE,MAAM,EAAE,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC;IAC1F,CAAC;IACD,OAAO,cAAoD,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAwB,EAAE,WAAmB,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,CAAC;IAChC,OAAO,aAAa,KAAK,CAAC,IAAI,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;AAC1F,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RPC\n */\n\nimport { IModelDb, RpcTrace } from \"@itwin/core-backend\";\nimport { BeEvent, Logger } from \"@itwin/core-bentley\";\nimport { IModelRpcProps } from \"@itwin/core-common\";\nimport {\n buildElementProperties,\n ClientDiagnostics,\n ComputeSelectionRpcRequestOptions,\n ContentDescriptorRpcRequestOptions,\n ContentFlags,\n ContentInstanceKeysRpcRequestOptions,\n ContentRpcRequestOptions,\n ContentSourcesRpcRequestOptions,\n ContentSourcesRpcResult,\n deepReplaceNullsToUndefined,\n DefaultContentDisplayTypes,\n DescriptorJSON,\n Diagnostics,\n DisplayLabelRpcRequestOptions,\n DisplayLabelsRpcRequestOptions,\n DisplayValueGroup,\n DistinctValuesRpcRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRpcRequestOptions,\n FilterByTextHierarchyRpcRequestOptions,\n HierarchyLevel,\n HierarchyLevelDescriptorRpcRequestOptions,\n HierarchyRpcRequestOptions,\n ItemJSON,\n KeySet,\n KeySetJSON,\n LabelDefinition,\n Node,\n NodePathElement,\n Paged,\n PagedResponse,\n PageOptions,\n PresentationError,\n PresentationRpcInterface,\n PresentationRpcResponse,\n PresentationRpcResponseData,\n PresentationStatus,\n RpcDiagnosticsOptions,\n Ruleset,\n RulesetVariable,\n RulesetVariableJSON,\n SelectClassInfo,\n SelectionScope,\n SelectionScopeRpcRequestOptions,\n SingleElementPropertiesRpcRequestOptions,\n} from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { Presentation } from \"./Presentation\";\nimport { PresentationManager } from \"./PresentationManager\";\nimport { TemporaryStorage } from \"./TemporaryStorage\";\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst packageJsonVersion = require(\"../../../package.json\").version;\n\ntype ContentGetter<TResult = any, TOptions = any> = (requestOptions: TOptions) => TResult;\n\n/** @internal */\nexport const MAX_ALLOWED_PAGE_SIZE = 1000;\n/** @internal */\nexport const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;\n\nconst DEFAULT_REQUEST_TIMEOUT = 5000;\n\n/**\n * The backend implementation of PresentationRpcInterface. All it's basically\n * responsible for is forwarding calls to [[Presentation.manager]].\n *\n * @internal\n */\nexport class PresentationRpcImpl extends PresentationRpcInterface implements Disposable {\n private _requestTimeout: number;\n private _pendingRequests: TemporaryStorage<PresentationRpcResponse<any>>;\n private _cancelEvents: Map<string, BeEvent<() => void>>;\n\n public constructor(props?: { requestTimeout?: number }) {\n super();\n this._requestTimeout = props?.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;\n this._pendingRequests = new TemporaryStorage({\n // remove the pending request after request timeout + 10 seconds - this gives\n // frontend 10 seconds to re-send the request until it's removed from requests' cache\n unusedValueLifetime: this._requestTimeout > 0 ? this._requestTimeout + 10 * 1000 : undefined,\n\n // attempt to clean up every second\n cleanupInterval: 1000,\n\n cleanupHandler: (id, _, reason) => {\n if (reason !== \"request\") {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);\n // istanbul ignore next\n this._cancelEvents.get(id)?.raiseEvent();\n }\n this._cancelEvents.delete(id);\n },\n });\n this._cancelEvents = new Map<string, BeEvent<() => void>>();\n }\n\n public [Symbol.dispose]() {\n this._pendingRequests[Symbol.dispose]();\n }\n\n public get requestTimeout() {\n return this._requestTimeout;\n }\n\n public get pendingRequests() {\n return this._pendingRequests;\n }\n\n /** Returns an ok response with result inside */\n private successResponse<TResult>(result: TResult, diagnostics?: ClientDiagnostics) {\n return {\n statusCode: PresentationStatus.Success,\n result,\n diagnostics,\n };\n }\n\n /** Returns a bad request response with empty result and an error code */\n private errorResponse(errorCode: PresentationStatus, errorMessage?: string, diagnostics?: ClientDiagnostics) {\n return {\n statusCode: errorCode,\n result: undefined,\n errorMessage,\n diagnostics,\n };\n }\n\n /**\n * Get the [[PresentationManager]] used by this RPC impl.\n */\n public getManager(clientId?: string): PresentationManager {\n return Presentation.getManager(clientId);\n }\n\n private async getIModel(token: IModelRpcProps): Promise<IModelDb> {\n const imodel = IModelDb.findByKey(token.key);\n // call refreshContainer, just in case this is a V2 checkpoint whose sasToken is about to expire, or its default transaction is about to be restarted.\n await imodel.refreshContainerForRpc(RpcTrace.expectCurrentActivity.accessToken);\n return imodel;\n }\n\n private async makeRequest<\n TRpcOptions extends { rulesetOrId?: Ruleset | string; clientId?: string; diagnostics?: RpcDiagnosticsOptions; rulesetVariables?: RulesetVariableJSON[] },\n TResult,\n >(token: IModelRpcProps, requestId: string, requestOptions: TRpcOptions, request: ContentGetter<Promise<TResult>>): PresentationRpcResponse<TResult> {\n const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });\n\n Logger.logInfo(PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);\n\n const imodel = await this.getIModel(token);\n\n let resultPromise = this._pendingRequests.getValue(requestKey);\n if (resultPromise) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request already pending`);\n } else {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request not found, creating a new one`);\n const { clientId: _, diagnostics: diagnosticsOptions, rulesetVariables, ...options } = requestOptions;\n const managerRequestOptions: any = {\n ...options,\n imodel,\n cancelEvent: new BeEvent<() => void>(),\n };\n\n // set up ruleset variables\n if (rulesetVariables) {\n managerRequestOptions.rulesetVariables = rulesetVariables.map(RulesetVariable.fromJSON);\n }\n\n // set up diagnostics listener\n let diagnostics: ClientDiagnostics | undefined;\n const getDiagnostics = (): ClientDiagnostics => {\n if (!diagnostics) {\n diagnostics = {};\n }\n return diagnostics;\n };\n if (diagnosticsOptions) {\n if (diagnosticsOptions.backendVersion) {\n getDiagnostics().backendVersion = packageJsonVersion;\n }\n managerRequestOptions.diagnostics = {\n ...diagnosticsOptions,\n handler: (d: Diagnostics) => {\n if (d.logs) {\n const target = getDiagnostics();\n if (target.logs) {\n target.logs.push(...d.logs);\n } else {\n target.logs = [...d.logs];\n }\n }\n },\n };\n }\n\n // initiate request\n resultPromise = request(managerRequestOptions)\n .then((result) => this.successResponse(result, diagnostics))\n .catch((e: unknown) => {\n if (e instanceof PresentationError) {\n return this.errorResponse(e.errorNumber, e.message, diagnostics);\n }\n throw e;\n });\n\n // store the request promise\n this._pendingRequests.addValue(requestKey, resultPromise);\n this._cancelEvents.set(requestKey, managerRequestOptions.cancelEvent);\n }\n\n if (this._requestTimeout === 0) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout not configured, returning promise without a timeout.`);\n void resultPromise.finally(() => {\n this._pendingRequests.deleteValue(requestKey);\n });\n return resultPromise;\n }\n\n let timeout: NodeJS.Timeout;\n const timeoutPromise = new Promise<any>((_resolve, reject) => {\n timeout = setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(\"timeout\");\n }, this._requestTimeout);\n });\n\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);\n return Promise.race([resultPromise, timeoutPromise])\n .catch<PresentationRpcResponseData>((e: unknown) => {\n if (e === \"timeout\") {\n // note: error responses from the manager get handled when creating `resultPromise`, so we can only get here due\n // to a timeout exception\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout, returning \"BackendTimeout\" status.`);\n return this.errorResponse(PresentationStatus.BackendTimeout);\n }\n // ...or an error that we don't want to reveal - let RPC system handle it.\n throw e;\n })\n .then((response: PresentationRpcResponseData<TResult>) => {\n if (response.statusCode !== PresentationStatus.BackendTimeout) {\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);\n this._pendingRequests.deleteValue(requestKey);\n }\n return response;\n })\n .finally(() => {\n clearTimeout(timeout);\n });\n }\n\n public override async getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {\n return this.makeRequest(token, \"getNodesCount\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getNodesCount(options);\n });\n }\n\n public override async getPagedNodes(token: IModelRpcProps, requestOptions: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<Node>> {\n return this.makeRequest(token, \"getPagedNodes\", requestOptions, async (options) => {\n options = enforceValidPageSize(options);\n const [serializedHierarchyLevel, count] = await Promise.all([\n this.getManager(requestOptions.clientId).getDetail().getNodes(options),\n this.getManager(requestOptions.clientId).getNodesCount(options),\n ]);\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\n return {\n total: count,\n items: hierarchyLevel.nodes,\n };\n });\n }\n\n public override async getNodesDescriptor(\n token: IModelRpcProps,\n requestOptions: HierarchyLevelDescriptorRpcRequestOptions,\n ): PresentationRpcResponse<string | DescriptorJSON | undefined> {\n return this.makeRequest(token, \"getNodesDescriptor\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getNodesDescriptor(options);\n });\n }\n\n public override async getNodePaths(\n token: IModelRpcProps,\n requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions,\n ): PresentationRpcResponse<NodePathElement[]> {\n return this.makeRequest(token, \"getNodePaths\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getNodePaths(options);\n });\n }\n\n public override async getFilteredNodePaths(\n token: IModelRpcProps,\n requestOptions: FilterByTextHierarchyRpcRequestOptions,\n ): PresentationRpcResponse<NodePathElement[]> {\n return this.makeRequest(token, \"getFilteredNodePaths\", requestOptions, async (options) => {\n return this.getManager(requestOptions.clientId).getDetail().getFilteredNodePaths(options);\n });\n }\n\n public override async getContentSources(\n token: IModelRpcProps,\n requestOptions: ContentSourcesRpcRequestOptions,\n ): PresentationRpcResponse<ContentSourcesRpcResult> {\n return this.makeRequest(token, \"getContentSources\", requestOptions, async (options) => {\n const result = await this.getManager(requestOptions.clientId).getContentSources(options);\n const classesMap = {};\n const selectClasses = result.map((sci) => SelectClassInfo.toCompressedJSON(sci, classesMap));\n return { sources: selectClasses, classesMap };\n });\n }\n\n public override async getContentDescriptor(\n token: IModelRpcProps,\n requestOptions: ContentDescriptorRpcRequestOptions,\n ): PresentationRpcResponse<DescriptorJSON | undefined> {\n return this.makeRequest(token, \"getContentDescriptor\", requestOptions, async (options) => {\n options = {\n ...options,\n contentFlags: (options.contentFlags ?? 0) | ContentFlags.DescriptorOnly, // always append the \"descriptor only\" flag when handling request from the frontend\n keys: KeySet.fromJSON(options.keys),\n };\n if (options.transport === \"unparsed-json\") {\n // Here we send a plain JSON string but we will parse it to DescriptorJSON on the frontend. This way we are\n // bypassing unnecessary deserialization and serialization.\n return Presentation.getManager(requestOptions.clientId).getDetail().getContentDescriptor(options) as unknown as DescriptorJSON | undefined;\n } else {\n // Support for older frontends that still expect a parsed descriptor\n const descriptor = await Presentation.getManager(requestOptions.clientId).getContentDescriptor(options);\n return descriptor?.toJSON();\n }\n });\n }\n\n public override async getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number> {\n return this.makeRequest(token, \"getContentSetSize\", requestOptions, async (options) => {\n options = {\n ...options,\n keys: KeySet.fromJSON(options.keys),\n };\n return this.getManager(requestOptions.clientId).getContentSetSize(options);\n });\n }\n\n public override async getPagedContent(\n token: IModelRpcProps,\n requestOptions: Paged<ContentRpcRequestOptions>,\n ): PresentationRpcResponse<{ descriptor: DescriptorJSON; contentSet: PagedResponse<ItemJSON> } | undefined> {\n return this.makeRequest(token, \"getPagedContent\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n keys: KeySet.fromJSON(options.keys),\n });\n\n const [size, content] = await Promise.all([\n this.getManager(requestOptions.clientId).getContentSetSize(options),\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\n ]);\n\n if (!content) {\n return undefined;\n }\n\n return {\n descriptor: content.descriptor.toJSON(),\n contentSet: {\n total: size,\n items: content.contentSet.map((i) => i.toJSON()),\n },\n };\n });\n }\n\n public override async getPagedContentSet(\n token: IModelRpcProps,\n requestOptions: Paged<ContentRpcRequestOptions>,\n ): PresentationRpcResponse<PagedResponse<ItemJSON>> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const response = await this.getPagedContent(token, requestOptions);\n if (response.statusCode !== PresentationStatus.Success) {\n return this.errorResponse(response.statusCode, response.errorMessage, response.diagnostics);\n }\n if (!response.result) {\n return this.errorResponse(PresentationStatus.Error, `Failed to get content set (received a success response with empty result)`, response.diagnostics);\n }\n return {\n ...response,\n result: response.result.contentSet,\n };\n }\n\n public override async getElementProperties(\n token: IModelRpcProps,\n requestOptions: SingleElementPropertiesRpcRequestOptions,\n ): PresentationRpcResponse<ElementProperties | undefined> {\n return this.makeRequest(token, \"getElementProperties\", { ...requestOptions }, async (options) => {\n const manager = this.getManager(requestOptions.clientId);\n const { elementId, ...optionsNoElementId } = options;\n const content = await manager.getDetail().getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n if (!content || content.contentSet.length === 0) {\n return undefined;\n }\n return buildElementProperties(content.descriptor, content.contentSet[0]);\n });\n }\n\n public override async getPagedDistinctValues(\n token: IModelRpcProps,\n requestOptions: DistinctValuesRpcRequestOptions,\n ): PresentationRpcResponse<PagedResponse<DisplayValueGroup>> {\n return this.makeRequest(token, \"getPagedDistinctValues\", requestOptions, async (options) => {\n options = enforceValidPageSize({\n ...options,\n keys: KeySet.fromJSON(options.keys),\n });\n return this.getManager(requestOptions.clientId).getDetail().getPagedDistinctValues(options);\n });\n }\n\n public override async getContentInstanceKeys(\n token: IModelRpcProps,\n requestOptions: ContentInstanceKeysRpcRequestOptions,\n ): PresentationRpcResponse<{ total: number; items: KeySetJSON }> {\n return this.makeRequest(token, \"getContentInstanceKeys\", requestOptions, async (options) => {\n const { displayType, ...optionsNoDisplayType } = options;\n options = enforceValidPageSize(\n {\n ...optionsNoDisplayType,\n keys: KeySet.fromJSON(optionsNoDisplayType.keys),\n descriptor: {\n displayType,\n contentFlags: ContentFlags.KeysOnly,\n },\n },\n MAX_ALLOWED_KEYS_PAGE_SIZE,\n );\n\n const [size, content] = await Promise.all([\n this.getManager(requestOptions.clientId).getContentSetSize(options),\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\n ]);\n\n if (size === 0 || !content) {\n return { total: 0, items: new KeySet().toJSON() };\n }\n\n return {\n total: size,\n items: content.contentSet.reduce((keys, item) => keys.add(item.primaryKeys), new KeySet()).toJSON(),\n };\n });\n }\n\n public override async getDisplayLabelDefinition(\n token: IModelRpcProps,\n requestOptions: DisplayLabelRpcRequestOptions,\n ): PresentationRpcResponse<LabelDefinition> {\n return this.makeRequest(token, \"getDisplayLabelDefinition\", requestOptions, async (options) => {\n const label = await this.getManager(requestOptions.clientId).getDetail().getDisplayLabelDefinition(options);\n return label;\n });\n }\n\n public override async getPagedDisplayLabelDefinitions(\n token: IModelRpcProps,\n requestOptions: DisplayLabelsRpcRequestOptions,\n ): PresentationRpcResponse<PagedResponse<LabelDefinition>> {\n const pageOpts = enforceValidPageSize({ paging: { start: 0, size: requestOptions.keys.length } });\n if (pageOpts.paging.size < requestOptions.keys.length) {\n requestOptions.keys.splice(pageOpts.paging.size);\n }\n return this.makeRequest(token, \"getPagedDisplayLabelDefinitions\", requestOptions, async (options) => {\n const labels = await this.getManager(requestOptions.clientId)\n .getDetail()\n .getDisplayLabelDefinitions({ ...options, keys: options.keys });\n return {\n total: options.keys.length,\n items: labels,\n };\n });\n }\n\n public override async getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {\n return this.makeRequest(token, \"getSelectionScopes\", requestOptions, async (options) =>\n this.getManager(requestOptions.clientId).getSelectionScopes(options),\n );\n }\n\n public override async computeSelection(token: IModelRpcProps, requestOptions: ComputeSelectionRpcRequestOptions): PresentationRpcResponse<KeySetJSON> {\n return this.makeRequest(token, \"computeSelection\", requestOptions, async (options) => {\n const keys = await this.getManager(requestOptions.clientId).computeSelection(options);\n return keys.toJSON();\n });\n }\n}\n\nconst enforceValidPageSize = <TOptions extends Paged<object>>(\n requestOptions: TOptions,\n maxPageSize = MAX_ALLOWED_PAGE_SIZE,\n): TOptions & { paging: PageOptions } => {\n const validPageSize = getValidPageSize(requestOptions.paging?.size, maxPageSize);\n if (!requestOptions.paging || requestOptions.paging.size !== validPageSize) {\n return { ...requestOptions, paging: { ...requestOptions.paging, size: validPageSize } };\n }\n return requestOptions as TOptions & { paging: PageOptions };\n};\n\nconst getValidPageSize = (size: number | undefined, maxPageSize: number) => {\n const requestedSize = size ?? 0;\n return requestedSize === 0 || requestedSize > maxPageSize ? maxPageSize : requestedSize;\n};\n"]}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
4
|
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
-
import {
|
|
6
|
-
import { ComputeSelectionRequestOptions, KeySet, SelectionScope, SelectionScopeRequestOptions } from "@itwin/presentation-common";
|
|
5
|
+
import { ComputeSelectionRequestOptions, KeySet, SelectionScope } from "@itwin/presentation-common";
|
|
7
6
|
/**
|
|
8
7
|
* Contains helper methods for computing selection scopes. Will get removed
|
|
9
8
|
* once rules-driven scopes are implemented.
|
|
@@ -23,7 +22,6 @@ export declare class SelectionScopesHelper {
|
|
|
23
22
|
private static computeFunctionalElementSelection;
|
|
24
23
|
private static computeFunctionalAssemblySelection;
|
|
25
24
|
private static computeFunctionalTopAssemblySelection;
|
|
26
|
-
static computeSelection(
|
|
27
|
-
static computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet>;
|
|
25
|
+
static computeSelection({ imodel, scope, elementIds }: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet>;
|
|
28
26
|
}
|
|
29
27
|
//# sourceMappingURL=SelectionScopesHelper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionScopesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAoB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectionScopesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAoB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EACL,8BAA8B,EAG9B,MAAM,EAGN,cAAc,EACf,MAAM,4BAA4B,CAAC;AAGpC;;;;;GAKG;AACH,qBAAa,qBAAqB;IAEhC,OAAO;WAEO,kBAAkB,IAAI,cAAc,EAAE;IAgBpD,OAAO,CAAC,MAAM,CAAC,aAAa;IAW5B,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAWtC,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAcvC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAcpC,OAAO,CAAC,MAAM,CAAC,8BAA8B;IAwB7C,OAAO,CAAC,MAAM,CAAC,oCAAoC;IAYnD,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAgBtC,OAAO,CAAC,MAAM,CAAC,iCAAiC;IA2BhD,OAAO,CAAC,MAAM,CAAC,kCAAkC;IA6BjD,OAAO,CAAC,MAAM,CAAC,qCAAqC;WA6BhC,gBAAgB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAsB/H"}
|
|
@@ -200,32 +200,25 @@ class SelectionScopesHelper {
|
|
|
200
200
|
}));
|
|
201
201
|
return keys;
|
|
202
202
|
}
|
|
203
|
-
static async computeSelection(
|
|
204
|
-
|
|
205
|
-
return this.computeSelection({
|
|
206
|
-
...requestOptions,
|
|
207
|
-
elementIds: elementIds,
|
|
208
|
-
scope: { id: scopeId },
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
switch (requestOptions.scope.id) {
|
|
203
|
+
static async computeSelection({ imodel, scope, elementIds }) {
|
|
204
|
+
switch (scope.id) {
|
|
212
205
|
case "element":
|
|
213
|
-
return this.computeElementSelection(
|
|
206
|
+
return this.computeElementSelection(imodel, elementIds, scope.ancestorLevel ?? 0);
|
|
214
207
|
case "assembly":
|
|
215
|
-
return this.computeElementSelection(
|
|
208
|
+
return this.computeElementSelection(imodel, elementIds, 1);
|
|
216
209
|
case "top-assembly":
|
|
217
|
-
return this.computeElementSelection(
|
|
210
|
+
return this.computeElementSelection(imodel, elementIds, Number.MAX_SAFE_INTEGER);
|
|
218
211
|
case "category":
|
|
219
|
-
return this.computeCategorySelection(
|
|
212
|
+
return this.computeCategorySelection(imodel, elementIds);
|
|
220
213
|
case "model":
|
|
221
|
-
return this.computeModelSelection(
|
|
214
|
+
return this.computeModelSelection(imodel, elementIds);
|
|
222
215
|
case "functional":
|
|
223
216
|
case "functional-element":
|
|
224
|
-
return this.computeFunctionalElementSelection(
|
|
217
|
+
return this.computeFunctionalElementSelection(imodel, elementIds);
|
|
225
218
|
case "functional-assembly":
|
|
226
|
-
return this.computeFunctionalAssemblySelection(
|
|
219
|
+
return this.computeFunctionalAssemblySelection(imodel, elementIds);
|
|
227
220
|
case "functional-top-assembly":
|
|
228
|
-
return this.computeFunctionalTopAssemblySelection(
|
|
221
|
+
return this.computeFunctionalTopAssemblySelection(imodel, elementIds);
|
|
229
222
|
}
|
|
230
223
|
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "scopeId");
|
|
231
224
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionScopesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAGH,sDAAiE;AACjE,oEAUoC;AACpC,mCAAwC;AAExC;;;;;GAKG;AACH,MAAa,qBAAqB;IAChC,uBAAuB;IACvB,gBAAuB,CAAC;IAEjB,MAAM,CAAC,kBAAkB;QAC9B,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAAE,KAAa,EAAE,WAAmB,EAAkB,EAAE,CAAC,CAAC;YACrG,EAAE,EAAE,OAAO;YACX,KAAK;YACL,WAAW;SACZ,CAAC,CAAC;QACH,OAAO;YACL,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,2BAA2B,CAAC;YACvE,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,qCAAqC,CAAC;YACnF,oBAAoB,CAAC,cAAc,EAAE,cAAc,EAA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uBAAuB,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;YAC3F,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACjH,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC,wBAAwB,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;YACzF,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;YACtF,KAAK,YAAY,CAAC;YAClB,KAAK,oBAAoB;gBACvB,OAAO,IAAI,CAAC,iCAAiC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;YAClG,KAAK,qBAAqB;gBACxB,OAAO,IAAI,CAAC,kCAAkC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;YACnG,KAAK,yBAAyB;gBAC5B,OAAO,IAAI,CAAC,qCAAqC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;QACxG,CAAC;QACD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC;CACF;AAvPD,sDAuPC;AAED,MAAM,cAAc,GAAG,CAAC,QAAkC,EAAE,EAAE;IAC5D,OAAO,CAAC,EAAc,EAAE,EAAE;QACxB,IAAI,CAAC,mBAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;YAC1B,QAAQ,CAAC,EAAE,CAAC,CAAC;QACf,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { GeometricElement, IModelDb } from \"@itwin/core-backend\";\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport {\n ComputeSelectionRequestOptions,\n ElementSelectionScopeProps,\n InstanceKey,\n isComputeSelectionRequestOptions,\n KeySet,\n PresentationError,\n PresentationStatus,\n SelectionScope,\n SelectionScopeRequestOptions,\n} from \"@itwin/presentation-common\";\nimport { getElementKey } from \"./Utils\";\n\n/**\n * Contains helper methods for computing selection scopes. Will get removed\n * once rules-driven scopes are implemented.\n *\n * @internal\n */\nexport class SelectionScopesHelper {\n // istanbul ignore next\n private constructor() {}\n\n public static getSelectionScopes(): SelectionScope[] {\n const createSelectionScope = (scopeId: string, label: string, description: string): SelectionScope => ({\n id: scopeId,\n label,\n description,\n });\n return [\n createSelectionScope(\"element\", \"Element\", \"Select the picked element\"),\n createSelectionScope(\"assembly\", \"Assembly\", \"Select parent of the picked element\"),\n createSelectionScope(\"top-assembly\", \"Top Assembly\", \"Select the topmost parent of the picked element\"),\n // WIP: temporarily comment-out \"category\" and \"model\" scopes since we can't hilite contents of them fast enough\n // createSelectionScope(\"category\", \"Category\", \"Select all elements in the picked element's category\"),\n // createSelectionScope(\"model\", \"Model\", \"Select all elements in the picked element's model\"),\n ];\n }\n\n private static getElementKey(iModel: IModelDb, elementId: Id64String, ancestorLevel: number) {\n let currId = elementId;\n let parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\n while (parentId && ancestorLevel !== 0) {\n currId = parentId;\n parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\n --ancestorLevel;\n }\n return getElementKey(iModel, currId);\n }\n\n private static computeElementSelection(iModel: IModelDb, elementIds: Id64String[], ancestorLevel: number) {\n const parentKeys = new KeySet();\n elementIds.forEach(\n skipTransients((id) => {\n const key = this.getElementKey(iModel, id, ancestorLevel);\n key && parentKeys.add(key);\n }),\n );\n return parentKeys;\n }\n\n private static computeCategorySelection(iModel: IModelDb, ids: Id64String[]) {\n const categoryKeys = new KeySet();\n ids.forEach(\n skipTransients((id) => {\n const el = iModel.elements.tryGetElement<GeometricElement>(id);\n const category = el?.category ? iModel.elements.tryGetElementProps(el.category) : undefined;\n if (category) {\n categoryKeys.add({ className: category.classFullName, id: category.id! });\n }\n }),\n );\n return categoryKeys;\n }\n\n private static computeModelSelection(iModel: IModelDb, ids: Id64String[]) {\n const modelKeys = new KeySet();\n ids.forEach(\n skipTransients((id) => {\n const el = iModel.elements.tryGetElementProps(id);\n const model = el ? iModel.models.tryGetModelProps(el.model) : undefined;\n if (model) {\n modelKeys.add({ className: model.classFullName, id: model.id! });\n }\n }),\n );\n return modelKeys;\n }\n\n private static getRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): InstanceKey | undefined {\n const query = `\n SELECT funcSchemaDef.Name || '.' || funcClassDef.Name funcElClassName, fe.ECInstanceId funcElId\n FROM bis.Element e\n LEFT JOIN func.PhysicalElementFulfillsFunction rel1 ON rel1.SourceECInstanceId = e.ECInstanceId\n LEFT JOIN func.DrawingGraphicRepresentsFunctionalElement rel2 ON rel2.SourceECInstanceId = e.ECInstanceId\n LEFT JOIN func.FunctionalElement fe ON fe.ECInstanceId IN (rel1.TargetECInstanceId, rel2.TargetECInstanceId)\n INNER JOIN meta.ECClassDef funcClassDef ON funcClassDef.ECInstanceId = fe.ECClassId\n INNER JOIN meta.ECSchemaDef funcSchemaDef ON funcSchemaDef.ECInstanceId = funcClassDef.Schema.Id\n WHERE e.ECInstanceId = ?\n `;\n return imodel.withPreparedStatement(query, (stmt): InstanceKey | undefined => {\n stmt.bindId(1, graphicalElementId);\n // istanbul ignore else\n if (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const row = stmt.getRow();\n if (row.funcElClassName && row.funcElId) {\n return { className: row.funcElClassName.replace(\".\", \":\"), id: row.funcElId };\n }\n }\n return undefined;\n });\n }\n\n private static findFirstRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): InstanceKey | undefined {\n let currId: Id64String | undefined = graphicalElementId;\n while (currId) {\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(imodel, currId);\n if (relatedFunctionalKey) {\n return relatedFunctionalKey;\n }\n currId = imodel.elements.tryGetElementProps(currId)?.parent?.id;\n }\n return undefined;\n }\n\n private static elementClassDerivesFrom(imodel: IModelDb, elementId: Id64String, baseClassFullName: string): boolean {\n const query = `\n SELECT 1\n FROM bis.Element e\n INNER JOIN meta.ClassHasAllBaseClasses baseClassRels ON baseClassRels.SourceECInstanceId = e.ECClassId\n INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId\n INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id\n WHERE e.ECInstanceId = ? AND (baseSchema.Name || ':' || baseClass.Name) = ?\n `;\n return imodel.withPreparedStatement(query, (stmt): boolean => {\n stmt.bindId(1, elementId);\n stmt.bindString(2, baseClassFullName);\n return DbResult.BE_SQLITE_ROW === stmt.step();\n });\n }\n\n private static computeFunctionalElementSelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n ids.forEach(\n skipTransients((id): void => {\n const is3d = this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n keys.add(firstFunctionalKey);\n return;\n }\n }\n let keyToAdd: InstanceKey | undefined;\n if (is3d) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n keyToAdd = this.getRelatedFunctionalElementKey(iModel, id);\n }\n if (!keyToAdd) {\n keyToAdd = getElementKey(iModel, id);\n }\n keyToAdd && keys.add(keyToAdd);\n }),\n );\n return keys;\n }\n\n private static computeFunctionalAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n ids.forEach(\n skipTransients((id): void => {\n let idToGetAssemblyFor = id;\n const is3d = this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n idToGetAssemblyFor = firstFunctionalKey.id;\n }\n }\n // find the assembly of either the given element or the functional element\n const assemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, 1);\n let keyToAdd = assemblyKey;\n if (is3d && keyToAdd) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\n if (relatedFunctionalKey) {\n keyToAdd = relatedFunctionalKey;\n }\n }\n keyToAdd && keys.add(keyToAdd);\n }),\n );\n return keys;\n }\n\n private static computeFunctionalTopAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n ids.forEach(\n skipTransients((id): void => {\n let idToGetAssemblyFor = id;\n const is3d = this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n idToGetAssemblyFor = firstFunctionalKey.id;\n }\n }\n // find the top assembly of either the given element or the functional element\n const topAssemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, Number.MAX_SAFE_INTEGER);\n let keyToAdd = topAssemblyKey;\n if (is3d && keyToAdd) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\n if (relatedFunctionalKey) {\n keyToAdd = relatedFunctionalKey;\n }\n }\n keyToAdd && keys.add(keyToAdd);\n }),\n );\n return keys;\n }\n\n public static async computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb>, ids: Id64String[], scopeId: string): Promise<KeySet>;\n public static async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet>;\n public static async computeSelection(\n requestOptions: ComputeSelectionRequestOptions<IModelDb> | SelectionScopeRequestOptions<IModelDb>,\n elementIds?: Id64String[],\n scopeId?: string,\n ): Promise<KeySet> {\n if (!isComputeSelectionRequestOptions(requestOptions)) {\n return this.computeSelection({\n ...requestOptions,\n elementIds: elementIds!,\n scope: { id: scopeId! },\n });\n }\n\n switch (requestOptions.scope.id) {\n case \"element\":\n return this.computeElementSelection(\n requestOptions.imodel,\n requestOptions.elementIds,\n (requestOptions.scope as ElementSelectionScopeProps).ancestorLevel ?? 0,\n );\n case \"assembly\":\n return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, 1);\n case \"top-assembly\":\n return this.computeElementSelection(requestOptions.imodel, requestOptions.elementIds, Number.MAX_SAFE_INTEGER);\n case \"category\":\n return this.computeCategorySelection(requestOptions.imodel, requestOptions.elementIds);\n case \"model\":\n return this.computeModelSelection(requestOptions.imodel, requestOptions.elementIds);\n case \"functional\":\n case \"functional-element\":\n return this.computeFunctionalElementSelection(requestOptions.imodel, requestOptions.elementIds);\n case \"functional-assembly\":\n return this.computeFunctionalAssemblySelection(requestOptions.imodel, requestOptions.elementIds);\n case \"functional-top-assembly\":\n return this.computeFunctionalTopAssemblySelection(requestOptions.imodel, requestOptions.elementIds);\n }\n throw new PresentationError(PresentationStatus.InvalidArgument, \"scopeId\");\n }\n}\n\nconst skipTransients = (callback: (id: Id64String) => void) => {\n return (id: Id64String) => {\n if (!Id64.isTransient(id)) {\n callback(id);\n }\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"SelectionScopesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAGH,sDAAiE;AACjE,oEAQoC;AACpC,mCAAwC;AAExC;;;;;GAKG;AACH,MAAa,qBAAqB;IA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AuB,CAAC,MAAM,EAAE,UAAU,EAAG,KAAoC,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;YACpH,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;YAC7D,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACnF,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC,wBAAwB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YAC3D,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACxD,KAAK,YAAY,CAAC;YAClB,KAAK,oBAAoB;gBACvB,OAAO,IAAI,CAAC,iCAAiC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACpE,KAAK,qBAAqB;gBACxB,OAAO,IAAI,CAAC,kCAAkC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACrE,KAAK,yBAAyB;gBAC5B,OAAO,IAAI,CAAC,qCAAqC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC;CACF;AArOD,sDAqOC;AAED,MAAM,cAAc,GAAG,CAAC,QAAkC,EAAE,EAAE;IAC5D,OAAO,CAAC,EAAc,EAAE,EAAE;QACxB,IAAI,CAAC,mBAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;YAC1B,QAAQ,CAAC,EAAE,CAAC,CAAC;QACf,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { GeometricElement, IModelDb } from \"@itwin/core-backend\";\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport {\n ComputeSelectionRequestOptions,\n ElementSelectionScopeProps,\n InstanceKey,\n KeySet,\n PresentationError,\n PresentationStatus,\n SelectionScope,\n} from \"@itwin/presentation-common\";\nimport { getElementKey } from \"./Utils\";\n\n/**\n * Contains helper methods for computing selection scopes. Will get removed\n * once rules-driven scopes are implemented.\n *\n * @internal\n */\nexport class SelectionScopesHelper {\n // istanbul ignore next\n private constructor() {}\n\n public static getSelectionScopes(): SelectionScope[] {\n const createSelectionScope = (scopeId: string, label: string, description: string): SelectionScope => ({\n id: scopeId,\n label,\n description,\n });\n return [\n createSelectionScope(\"element\", \"Element\", \"Select the picked element\"),\n createSelectionScope(\"assembly\", \"Assembly\", \"Select parent of the picked element\"),\n createSelectionScope(\"top-assembly\", \"Top Assembly\", \"Select the topmost parent of the picked element\"),\n // WIP: temporarily comment-out \"category\" and \"model\" scopes since we can't hilite contents of them fast enough\n // createSelectionScope(\"category\", \"Category\", \"Select all elements in the picked element's category\"),\n // createSelectionScope(\"model\", \"Model\", \"Select all elements in the picked element's model\"),\n ];\n }\n\n private static getElementKey(iModel: IModelDb, elementId: Id64String, ancestorLevel: number) {\n let currId = elementId;\n let parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\n while (parentId && ancestorLevel !== 0) {\n currId = parentId;\n parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\n --ancestorLevel;\n }\n return getElementKey(iModel, currId);\n }\n\n private static computeElementSelection(iModel: IModelDb, elementIds: Id64String[], ancestorLevel: number) {\n const parentKeys = new KeySet();\n elementIds.forEach(\n skipTransients((id) => {\n const key = this.getElementKey(iModel, id, ancestorLevel);\n key && parentKeys.add(key);\n }),\n );\n return parentKeys;\n }\n\n private static computeCategorySelection(iModel: IModelDb, ids: Id64String[]) {\n const categoryKeys = new KeySet();\n ids.forEach(\n skipTransients((id) => {\n const el = iModel.elements.tryGetElement<GeometricElement>(id);\n const category = el?.category ? iModel.elements.tryGetElementProps(el.category) : undefined;\n if (category) {\n categoryKeys.add({ className: category.classFullName, id: category.id! });\n }\n }),\n );\n return categoryKeys;\n }\n\n private static computeModelSelection(iModel: IModelDb, ids: Id64String[]) {\n const modelKeys = new KeySet();\n ids.forEach(\n skipTransients((id) => {\n const el = iModel.elements.tryGetElementProps(id);\n const model = el ? iModel.models.tryGetModelProps(el.model) : undefined;\n if (model) {\n modelKeys.add({ className: model.classFullName, id: model.id! });\n }\n }),\n );\n return modelKeys;\n }\n\n private static getRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): InstanceKey | undefined {\n const query = `\n SELECT funcSchemaDef.Name || '.' || funcClassDef.Name funcElClassName, fe.ECInstanceId funcElId\n FROM bis.Element e\n LEFT JOIN func.PhysicalElementFulfillsFunction rel1 ON rel1.SourceECInstanceId = e.ECInstanceId\n LEFT JOIN func.DrawingGraphicRepresentsFunctionalElement rel2 ON rel2.SourceECInstanceId = e.ECInstanceId\n LEFT JOIN func.FunctionalElement fe ON fe.ECInstanceId IN (rel1.TargetECInstanceId, rel2.TargetECInstanceId)\n INNER JOIN meta.ECClassDef funcClassDef ON funcClassDef.ECInstanceId = fe.ECClassId\n INNER JOIN meta.ECSchemaDef funcSchemaDef ON funcSchemaDef.ECInstanceId = funcClassDef.Schema.Id\n WHERE e.ECInstanceId = ?\n `;\n return imodel.withPreparedStatement(query, (stmt): InstanceKey | undefined => {\n stmt.bindId(1, graphicalElementId);\n // istanbul ignore else\n if (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const row = stmt.getRow();\n if (row.funcElClassName && row.funcElId) {\n return { className: row.funcElClassName.replace(\".\", \":\"), id: row.funcElId };\n }\n }\n return undefined;\n });\n }\n\n private static findFirstRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): InstanceKey | undefined {\n let currId: Id64String | undefined = graphicalElementId;\n while (currId) {\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(imodel, currId);\n if (relatedFunctionalKey) {\n return relatedFunctionalKey;\n }\n currId = imodel.elements.tryGetElementProps(currId)?.parent?.id;\n }\n return undefined;\n }\n\n private static elementClassDerivesFrom(imodel: IModelDb, elementId: Id64String, baseClassFullName: string): boolean {\n const query = `\n SELECT 1\n FROM bis.Element e\n INNER JOIN meta.ClassHasAllBaseClasses baseClassRels ON baseClassRels.SourceECInstanceId = e.ECClassId\n INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId\n INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id\n WHERE e.ECInstanceId = ? AND (baseSchema.Name || ':' || baseClass.Name) = ?\n `;\n return imodel.withPreparedStatement(query, (stmt): boolean => {\n stmt.bindId(1, elementId);\n stmt.bindString(2, baseClassFullName);\n return DbResult.BE_SQLITE_ROW === stmt.step();\n });\n }\n\n private static computeFunctionalElementSelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n ids.forEach(\n skipTransients((id): void => {\n const is3d = this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n keys.add(firstFunctionalKey);\n return;\n }\n }\n let keyToAdd: InstanceKey | undefined;\n if (is3d) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n keyToAdd = this.getRelatedFunctionalElementKey(iModel, id);\n }\n if (!keyToAdd) {\n keyToAdd = getElementKey(iModel, id);\n }\n keyToAdd && keys.add(keyToAdd);\n }),\n );\n return keys;\n }\n\n private static computeFunctionalAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n ids.forEach(\n skipTransients((id): void => {\n let idToGetAssemblyFor = id;\n const is3d = this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n idToGetAssemblyFor = firstFunctionalKey.id;\n }\n }\n // find the assembly of either the given element or the functional element\n const assemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, 1);\n let keyToAdd = assemblyKey;\n if (is3d && keyToAdd) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\n if (relatedFunctionalKey) {\n keyToAdd = relatedFunctionalKey;\n }\n }\n keyToAdd && keys.add(keyToAdd);\n }),\n );\n return keys;\n }\n\n private static computeFunctionalTopAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n ids.forEach(\n skipTransients((id): void => {\n let idToGetAssemblyFor = id;\n const is3d = this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n idToGetAssemblyFor = firstFunctionalKey.id;\n }\n }\n // find the top assembly of either the given element or the functional element\n const topAssemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, Number.MAX_SAFE_INTEGER);\n let keyToAdd = topAssemblyKey;\n if (is3d && keyToAdd) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n const relatedFunctionalKey = this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\n if (relatedFunctionalKey) {\n keyToAdd = relatedFunctionalKey;\n }\n }\n keyToAdd && keys.add(keyToAdd);\n }),\n );\n return keys;\n }\n\n public static async computeSelection({ imodel, scope, elementIds }: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet> {\n switch (scope.id) {\n case \"element\":\n return this.computeElementSelection(imodel, elementIds, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n case \"assembly\":\n return this.computeElementSelection(imodel, elementIds, 1);\n case \"top-assembly\":\n return this.computeElementSelection(imodel, elementIds, Number.MAX_SAFE_INTEGER);\n case \"category\":\n return this.computeCategorySelection(imodel, elementIds);\n case \"model\":\n return this.computeModelSelection(imodel, elementIds);\n case \"functional\":\n case \"functional-element\":\n return this.computeFunctionalElementSelection(imodel, elementIds);\n case \"functional-assembly\":\n return this.computeFunctionalAssemblySelection(imodel, elementIds);\n case \"functional-top-assembly\":\n return this.computeFunctionalTopAssemblySelection(imodel, elementIds);\n }\n throw new PresentationError(PresentationStatus.InvalidArgument, \"scopeId\");\n }\n}\n\nconst skipTransients = (callback: (id: Id64String) => void) => {\n return (id: Id64String) => {\n if (!Id64.isTransient(id)) {\n callback(id);\n }\n };\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-backend",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.62",
|
|
4
4
|
"description": "Backend of iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"main": "lib/cjs/presentation-backend.js",
|
|
24
24
|
"typings": "lib/cjs/presentation-backend",
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@itwin/core-backend": "5.0.0-dev.
|
|
27
|
-
"@itwin/core-bentley": "5.0.0-dev.
|
|
28
|
-
"@itwin/
|
|
29
|
-
"@itwin/
|
|
30
|
-
"@itwin/presentation-common": "5.0.0-dev.
|
|
31
|
-
"@itwin/core-
|
|
26
|
+
"@itwin/core-backend": "5.0.0-dev.62",
|
|
27
|
+
"@itwin/core-bentley": "5.0.0-dev.62",
|
|
28
|
+
"@itwin/core-quantity": "5.0.0-dev.62",
|
|
29
|
+
"@itwin/ecschema-metadata": "5.0.0-dev.62",
|
|
30
|
+
"@itwin/presentation-common": "5.0.0-dev.62",
|
|
31
|
+
"@itwin/core-common": "5.0.0-dev.62"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@itwin/eslint-plugin": "5.0.0-dev.1",
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"source-map-support": "^0.5.6",
|
|
68
68
|
"typemoq": "^2.1.0",
|
|
69
69
|
"typescript": "~5.6.2",
|
|
70
|
-
"@itwin/build-tools": "5.0.0-dev.
|
|
71
|
-
"@itwin/core-bentley": "5.0.0-dev.
|
|
72
|
-
"@itwin/core-
|
|
73
|
-
"@itwin/
|
|
74
|
-
"@itwin/
|
|
75
|
-
"@itwin/core-
|
|
76
|
-
"@itwin/
|
|
70
|
+
"@itwin/build-tools": "5.0.0-dev.62",
|
|
71
|
+
"@itwin/core-bentley": "5.0.0-dev.62",
|
|
72
|
+
"@itwin/core-quantity": "5.0.0-dev.62",
|
|
73
|
+
"@itwin/core-backend": "5.0.0-dev.62",
|
|
74
|
+
"@itwin/ecschema-metadata": "5.0.0-dev.62",
|
|
75
|
+
"@itwin/core-common": "5.0.0-dev.62",
|
|
76
|
+
"@itwin/presentation-common": "5.0.0-dev.62"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"object-hash": "^1.3.1",
|