@itwin/presentation-backend 3.5.4 → 3.5.5

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  3. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +761 -761
  4. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  5. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  7. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  8. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  9. package/lib/cjs/presentation-backend/Constants.js +36 -36
  10. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  11. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +274 -274
  13. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  14. package/lib/cjs/presentation-backend/NativePlatform.d.ts +82 -82
  15. package/lib/cjs/presentation-backend/NativePlatform.js +139 -139
  16. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  17. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  18. package/lib/cjs/presentation-backend/Presentation.js +150 -150
  19. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  20. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
  21. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  23. package/lib/cjs/presentation-backend/PresentationManager.d.ts +436 -436
  24. package/lib/cjs/presentation-backend/PresentationManager.js +292 -292
  25. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  26. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +60 -60
  27. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +420 -420
  28. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  29. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +61 -61
  30. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +365 -365
  31. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  32. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +104 -104
  33. package/lib/cjs/presentation-backend/RulesetEmbedder.js +282 -282
  34. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  35. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  36. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  37. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  39. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  40. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  41. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +35 -35
  42. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +229 -229
  43. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  44. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  45. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  46. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  47. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  48. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  49. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  50. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  51. package/lib/cjs/presentation-backend/Utils.js +106 -106
  52. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  53. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  54. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +51 -51
  55. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  56. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  57. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  58. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  59. package/lib/cjs/presentation-backend.d.ts +19 -19
  60. package/lib/cjs/presentation-backend.js +35 -35
  61. package/lib/cjs/presentation-backend.js.map +1 -1
  62. package/package.json +13 -13
@@ -1,293 +1,293 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Core
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.PresentationManager = exports.HierarchyCacheMode = exports.PresentationManagerMode = void 0;
11
- const presentation_common_1 = require("@itwin/presentation-common");
12
- const ElementPropertiesHelper_1 = require("./ElementPropertiesHelper");
13
- const NativePlatform_1 = require("./NativePlatform");
14
- const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
15
- const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
16
- const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
17
- const Utils_1 = require("./Utils");
18
- /**
19
- * Presentation manager working mode.
20
- * @public
21
- * @deprecated The attribute is not used by [[PresentationManager]] anymore
22
- */
23
- var PresentationManagerMode;
24
- (function (PresentationManagerMode) {
25
- /**
26
- * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
27
- * related to reacting to changes in iModels.
28
- */
29
- PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
30
- /**
31
- * Presentation manager assumes iModels are opened in read-write mode and it may need to
32
- * react to changes. This involves some additional work and gives slightly worse performance.
33
- */
34
- PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
35
- })(PresentationManagerMode = exports.PresentationManagerMode || (exports.PresentationManagerMode = {}));
36
- /**
37
- * Presentation hierarchy cache mode.
38
- * @beta
39
- */
40
- var HierarchyCacheMode;
41
- (function (HierarchyCacheMode) {
42
- /**
43
- * Hierarchy cache is created in memory.
44
- */
45
- HierarchyCacheMode["Memory"] = "memory";
46
- /**
47
- * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel
48
- * openings.
49
- */
50
- HierarchyCacheMode["Disk"] = "disk";
51
- /**
52
- * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level
53
- * and persisted in disk cache when whole hierarchy level is created.
54
- */
55
- HierarchyCacheMode["Hybrid"] = "hybrid";
56
- })(HierarchyCacheMode = exports.HierarchyCacheMode || (exports.HierarchyCacheMode = {}));
57
- /**
58
- * Backend Presentation manager which pulls the presentation data from
59
- * an iModel using native platform.
60
- *
61
- * @public
62
- */
63
- class PresentationManager {
64
- /**
65
- * Creates an instance of PresentationManager.
66
- * @param props Optional configuration properties.
67
- */
68
- constructor(props) {
69
- var _a;
70
- /** @internal */
71
- this.getNativePlatform = () => {
72
- return this._detail.getNativePlatform();
73
- };
74
- this._props = props !== null && props !== void 0 ? props : {};
75
- this._detail = new PresentationManagerDetail_1.PresentationManagerDetail(this._props);
76
- this.activeLocale = this._props.defaultLocale; // eslint-disable-line deprecation/deprecation
77
- this._localizationHelper = new presentation_common_1.LocalizationHelper({ getLocalizedString: (_a = props === null || props === void 0 ? void 0 : props.getLocalizedString) !== null && _a !== void 0 ? _a : Utils_1.getLocalizedStringEN });
78
- }
79
- /** Get / set active unit system used to format property values with units */
80
- get activeUnitSystem() { return this._detail.activeUnitSystem; }
81
- // istanbul ignore next
82
- set activeUnitSystem(value) { this._detail.activeUnitSystem = value; }
83
- /** Dispose the presentation manager. Must be called to clean up native resources. */
84
- dispose() {
85
- this._detail.dispose();
86
- }
87
- /** @internal */
88
- setOnManagerUsedHandler(handler) {
89
- this._detail.setOnManagerUsedHandler(handler);
90
- }
91
- /** Properties used to initialize the manager */
92
- get props() { return this._props; }
93
- /** Get rulesets manager */
94
- rulesets() { return this._detail.rulesets; }
95
- /**
96
- * Get ruleset variables manager for specific ruleset
97
- * @param rulesetId Id of the ruleset to get variables manager for
98
- */
99
- vars(rulesetId) {
100
- return new RulesetVariablesManager_1.RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);
101
- }
102
- /** @internal */
103
- // istanbul ignore next
104
- getDetail() {
105
- return this._detail;
106
- }
107
- /** @internal */
108
- getRulesetId(rulesetOrId) {
109
- return this._detail.getRulesetId(rulesetOrId);
110
- }
111
- /**
112
- * Retrieves nodes
113
- * @public
114
- */
115
- async getNodes(requestOptions) {
116
- const nodes = await this._detail.getNodes(requestOptions);
117
- return this._localizationHelper.getLocalizedNodes(nodes);
118
- }
119
- /**
120
- * Retrieves nodes count
121
- * @public
122
- */
123
- async getNodesCount(requestOptions) {
124
- return this._detail.getNodesCount(requestOptions);
125
- }
126
- /**
127
- * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
128
- * TODO: Return results in pages
129
- * @public
130
- */
131
- async getNodePaths(requestOptions) {
132
- return this._detail.getNodePaths(requestOptions);
133
- }
134
- /**
135
- * Retrieves paths from root nodes to nodes containing filter text in their label.
136
- * TODO: Return results in pages
137
- * @public
138
- */
139
- async getFilteredNodePaths(requestOptions) {
140
- return this._detail.getFilteredNodePaths(requestOptions);
141
- }
142
- /** @beta */
143
- async getContentSources(requestOptions) {
144
- return this._detail.getContentSources(requestOptions);
145
- }
146
- /**
147
- * Retrieves the content descriptor which can be used to get content
148
- * @public
149
- */
150
- async getContentDescriptor(requestOptions) {
151
- const response = await this._detail.getContentDescriptor(requestOptions);
152
- const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
153
- return JSON.parse(response, reviver);
154
- }
155
- /**
156
- * Retrieves the content set size based on the supplied content descriptor override
157
- * @public
158
- */
159
- async getContentSetSize(requestOptions) {
160
- return this._detail.getContentSetSize(requestOptions);
161
- }
162
- /**
163
- * Retrieves the content based on the supplied content descriptor override.
164
- * @public
165
- */
166
- async getContent(requestOptions) {
167
- const content = await this._detail.getContent(requestOptions);
168
- if (!content)
169
- return undefined;
170
- return this._localizationHelper.getLocalizedContent(content);
171
- }
172
- /**
173
- * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
174
- * @param requestOptions Options for the request
175
- * @return A promise object that returns either distinct values on success or an error string on error.
176
- * @public
177
- */
178
- async getPagedDistinctValues(requestOptions) {
179
- return this._detail.getPagedDistinctValues(requestOptions);
180
- }
181
- async getElementProperties(requestOptions) {
182
- if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
183
- const elementProperties = await this._detail.getElementProperties(requestOptions);
184
- // istanbul ignore if
185
- if (!elementProperties)
186
- return undefined;
187
- return this._localizationHelper.getLocalizedElementProperties(elementProperties);
188
- }
189
- return this.getMultipleElementProperties(requestOptions);
190
- }
191
- async getMultipleElementProperties(requestOptions) {
192
- const { elementClasses, ...optionsNoElementClasses } = requestOptions;
193
- const elementsCount = (0, ElementPropertiesHelper_1.getElementsCount)(requestOptions.imodel, requestOptions.elementClasses);
194
- const propertiesGetter = async (className, ids) => buildElementsPropertiesInPages(className, ids, async (keys) => {
195
- const content = await this.getContent({
196
- ...optionsNoElementClasses,
197
- descriptor: {
198
- displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
199
- contentFlags: presentation_common_1.ContentFlags.ShowLabels,
200
- },
201
- rulesetOrId: "ElementProperties",
202
- keys,
203
- });
204
- return (0, ElementPropertiesHelper_1.buildElementsProperties)(content);
205
- });
206
- const ELEMENT_IDS_BATCH_SIZE = 1000;
207
- return {
208
- total: elementsCount,
209
- async *iterator() {
210
- for (const idsByClass of (0, ElementPropertiesHelper_1.iterateElementIds)(requestOptions.imodel, elementClasses, ELEMENT_IDS_BATCH_SIZE)) {
211
- const propertiesPage = [];
212
- for (const entry of idsByClass) {
213
- propertiesPage.push(...(await propertiesGetter(entry[0], entry[1])));
214
- }
215
- yield propertiesPage;
216
- }
217
- },
218
- };
219
- }
220
- /**
221
- * Retrieves display label definition of specific item
222
- * @public
223
- */
224
- async getDisplayLabelDefinition(requestOptions) {
225
- const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);
226
- return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);
227
- }
228
- /**
229
- * Retrieves display label definitions of specific items
230
- * @public
231
- */
232
- async getDisplayLabelDefinitions(requestOptions) {
233
- const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);
234
- return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);
235
- }
236
- /**
237
- * Retrieves available selection scopes.
238
- * @public
239
- */
240
- async getSelectionScopes(_requestOptions) {
241
- return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
242
- }
243
- async computeSelection(requestOptions) {
244
- return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection((0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)
245
- ? requestOptions
246
- : (function () {
247
- const { ids, scopeId, ...rest } = requestOptions;
248
- return { ...rest, elementIds: ids, scope: { id: scopeId } };
249
- })());
250
- }
251
- /**
252
- * Compares two hierarchies specified in the request options
253
- * @public
254
- */
255
- async compareHierarchies(requestOptions) {
256
- var _a, _b;
257
- if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {
258
- return { changes: [] };
259
- }
260
- const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;
261
- this._detail.registerRuleset(rulesetOrId);
262
- const currRulesetId = (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId);
263
- const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
264
- if (prevRulesetId.parts.id !== currRulesetId.parts.id)
265
- throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "Can't compare rulesets with different IDs");
266
- const currRulesetVariables = rulesetVariables !== null && rulesetVariables !== void 0 ? rulesetVariables : [];
267
- const prevRulesetVariables = (_a = prev.rulesetVariables) !== null && _a !== void 0 ? _a : currRulesetVariables;
268
- const params = {
269
- requestId: NativePlatform_1.NativePlatformRequestTypes.CompareHierarchies,
270
- ...options,
271
- prevRulesetId: prevRulesetId.uniqueId,
272
- currRulesetId: currRulesetId.uniqueId,
273
- prevRulesetVariables: JSON.stringify(prevRulesetVariables),
274
- currRulesetVariables: JSON.stringify(currRulesetVariables),
275
- expandedNodeKeys: JSON.stringify((_b = options.expandedNodeKeys) !== null && _b !== void 0 ? _b : []),
276
- };
277
- const reviver = (key, value) => (key === "") ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value;
278
- return JSON.parse(await this._detail.request(params), reviver);
279
- }
280
- }
281
- exports.PresentationManager = PresentationManager;
282
- const ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE = 100;
283
- async function buildElementsPropertiesInPages(className, ids, getter) {
284
- const elementProperties = [];
285
- const elementIds = [...ids];
286
- while (elementIds.length > 0) {
287
- const idsPage = elementIds.splice(0, ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE);
288
- const keys = new presentation_common_1.KeySet(idsPage.map((id) => ({ id, className })));
289
- elementProperties.push(...(await getter(keys)));
290
- }
291
- return elementProperties;
292
- }
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Core
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.PresentationManager = exports.HierarchyCacheMode = exports.PresentationManagerMode = void 0;
11
+ const presentation_common_1 = require("@itwin/presentation-common");
12
+ const ElementPropertiesHelper_1 = require("./ElementPropertiesHelper");
13
+ const NativePlatform_1 = require("./NativePlatform");
14
+ const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
15
+ const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
16
+ const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
17
+ const Utils_1 = require("./Utils");
18
+ /**
19
+ * Presentation manager working mode.
20
+ * @public
21
+ * @deprecated The attribute is not used by [[PresentationManager]] anymore
22
+ */
23
+ var PresentationManagerMode;
24
+ (function (PresentationManagerMode) {
25
+ /**
26
+ * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
27
+ * related to reacting to changes in iModels.
28
+ */
29
+ PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
30
+ /**
31
+ * Presentation manager assumes iModels are opened in read-write mode and it may need to
32
+ * react to changes. This involves some additional work and gives slightly worse performance.
33
+ */
34
+ PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
35
+ })(PresentationManagerMode = exports.PresentationManagerMode || (exports.PresentationManagerMode = {}));
36
+ /**
37
+ * Presentation hierarchy cache mode.
38
+ * @beta
39
+ */
40
+ var HierarchyCacheMode;
41
+ (function (HierarchyCacheMode) {
42
+ /**
43
+ * Hierarchy cache is created in memory.
44
+ */
45
+ HierarchyCacheMode["Memory"] = "memory";
46
+ /**
47
+ * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel
48
+ * openings.
49
+ */
50
+ HierarchyCacheMode["Disk"] = "disk";
51
+ /**
52
+ * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level
53
+ * and persisted in disk cache when whole hierarchy level is created.
54
+ */
55
+ HierarchyCacheMode["Hybrid"] = "hybrid";
56
+ })(HierarchyCacheMode = exports.HierarchyCacheMode || (exports.HierarchyCacheMode = {}));
57
+ /**
58
+ * Backend Presentation manager which pulls the presentation data from
59
+ * an iModel using native platform.
60
+ *
61
+ * @public
62
+ */
63
+ class PresentationManager {
64
+ /**
65
+ * Creates an instance of PresentationManager.
66
+ * @param props Optional configuration properties.
67
+ */
68
+ constructor(props) {
69
+ var _a;
70
+ /** @internal */
71
+ this.getNativePlatform = () => {
72
+ return this._detail.getNativePlatform();
73
+ };
74
+ this._props = props !== null && props !== void 0 ? props : {};
75
+ this._detail = new PresentationManagerDetail_1.PresentationManagerDetail(this._props);
76
+ this.activeLocale = this._props.defaultLocale; // eslint-disable-line deprecation/deprecation
77
+ this._localizationHelper = new presentation_common_1.LocalizationHelper({ getLocalizedString: (_a = props === null || props === void 0 ? void 0 : props.getLocalizedString) !== null && _a !== void 0 ? _a : Utils_1.getLocalizedStringEN });
78
+ }
79
+ /** Get / set active unit system used to format property values with units */
80
+ get activeUnitSystem() { return this._detail.activeUnitSystem; }
81
+ // istanbul ignore next
82
+ set activeUnitSystem(value) { this._detail.activeUnitSystem = value; }
83
+ /** Dispose the presentation manager. Must be called to clean up native resources. */
84
+ dispose() {
85
+ this._detail.dispose();
86
+ }
87
+ /** @internal */
88
+ setOnManagerUsedHandler(handler) {
89
+ this._detail.setOnManagerUsedHandler(handler);
90
+ }
91
+ /** Properties used to initialize the manager */
92
+ get props() { return this._props; }
93
+ /** Get rulesets manager */
94
+ rulesets() { return this._detail.rulesets; }
95
+ /**
96
+ * Get ruleset variables manager for specific ruleset
97
+ * @param rulesetId Id of the ruleset to get variables manager for
98
+ */
99
+ vars(rulesetId) {
100
+ return new RulesetVariablesManager_1.RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);
101
+ }
102
+ /** @internal */
103
+ // istanbul ignore next
104
+ getDetail() {
105
+ return this._detail;
106
+ }
107
+ /** @internal */
108
+ getRulesetId(rulesetOrId) {
109
+ return this._detail.getRulesetId(rulesetOrId);
110
+ }
111
+ /**
112
+ * Retrieves nodes
113
+ * @public
114
+ */
115
+ async getNodes(requestOptions) {
116
+ const nodes = await this._detail.getNodes(requestOptions);
117
+ return this._localizationHelper.getLocalizedNodes(nodes);
118
+ }
119
+ /**
120
+ * Retrieves nodes count
121
+ * @public
122
+ */
123
+ async getNodesCount(requestOptions) {
124
+ return this._detail.getNodesCount(requestOptions);
125
+ }
126
+ /**
127
+ * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
128
+ * TODO: Return results in pages
129
+ * @public
130
+ */
131
+ async getNodePaths(requestOptions) {
132
+ return this._detail.getNodePaths(requestOptions);
133
+ }
134
+ /**
135
+ * Retrieves paths from root nodes to nodes containing filter text in their label.
136
+ * TODO: Return results in pages
137
+ * @public
138
+ */
139
+ async getFilteredNodePaths(requestOptions) {
140
+ return this._detail.getFilteredNodePaths(requestOptions);
141
+ }
142
+ /** @beta */
143
+ async getContentSources(requestOptions) {
144
+ return this._detail.getContentSources(requestOptions);
145
+ }
146
+ /**
147
+ * Retrieves the content descriptor which can be used to get content
148
+ * @public
149
+ */
150
+ async getContentDescriptor(requestOptions) {
151
+ const response = await this._detail.getContentDescriptor(requestOptions);
152
+ const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
153
+ return JSON.parse(response, reviver);
154
+ }
155
+ /**
156
+ * Retrieves the content set size based on the supplied content descriptor override
157
+ * @public
158
+ */
159
+ async getContentSetSize(requestOptions) {
160
+ return this._detail.getContentSetSize(requestOptions);
161
+ }
162
+ /**
163
+ * Retrieves the content based on the supplied content descriptor override.
164
+ * @public
165
+ */
166
+ async getContent(requestOptions) {
167
+ const content = await this._detail.getContent(requestOptions);
168
+ if (!content)
169
+ return undefined;
170
+ return this._localizationHelper.getLocalizedContent(content);
171
+ }
172
+ /**
173
+ * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
174
+ * @param requestOptions Options for the request
175
+ * @return A promise object that returns either distinct values on success or an error string on error.
176
+ * @public
177
+ */
178
+ async getPagedDistinctValues(requestOptions) {
179
+ return this._detail.getPagedDistinctValues(requestOptions);
180
+ }
181
+ async getElementProperties(requestOptions) {
182
+ if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
183
+ const elementProperties = await this._detail.getElementProperties(requestOptions);
184
+ // istanbul ignore if
185
+ if (!elementProperties)
186
+ return undefined;
187
+ return this._localizationHelper.getLocalizedElementProperties(elementProperties);
188
+ }
189
+ return this.getMultipleElementProperties(requestOptions);
190
+ }
191
+ async getMultipleElementProperties(requestOptions) {
192
+ const { elementClasses, ...optionsNoElementClasses } = requestOptions;
193
+ const elementsCount = (0, ElementPropertiesHelper_1.getElementsCount)(requestOptions.imodel, requestOptions.elementClasses);
194
+ const propertiesGetter = async (className, ids) => buildElementsPropertiesInPages(className, ids, async (keys) => {
195
+ const content = await this.getContent({
196
+ ...optionsNoElementClasses,
197
+ descriptor: {
198
+ displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
199
+ contentFlags: presentation_common_1.ContentFlags.ShowLabels,
200
+ },
201
+ rulesetOrId: "ElementProperties",
202
+ keys,
203
+ });
204
+ return (0, ElementPropertiesHelper_1.buildElementsProperties)(content);
205
+ });
206
+ const ELEMENT_IDS_BATCH_SIZE = 1000;
207
+ return {
208
+ total: elementsCount,
209
+ async *iterator() {
210
+ for (const idsByClass of (0, ElementPropertiesHelper_1.iterateElementIds)(requestOptions.imodel, elementClasses, ELEMENT_IDS_BATCH_SIZE)) {
211
+ const propertiesPage = [];
212
+ for (const entry of idsByClass) {
213
+ propertiesPage.push(...(await propertiesGetter(entry[0], entry[1])));
214
+ }
215
+ yield propertiesPage;
216
+ }
217
+ },
218
+ };
219
+ }
220
+ /**
221
+ * Retrieves display label definition of specific item
222
+ * @public
223
+ */
224
+ async getDisplayLabelDefinition(requestOptions) {
225
+ const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);
226
+ return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);
227
+ }
228
+ /**
229
+ * Retrieves display label definitions of specific items
230
+ * @public
231
+ */
232
+ async getDisplayLabelDefinitions(requestOptions) {
233
+ const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);
234
+ return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);
235
+ }
236
+ /**
237
+ * Retrieves available selection scopes.
238
+ * @public
239
+ */
240
+ async getSelectionScopes(_requestOptions) {
241
+ return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
242
+ }
243
+ async computeSelection(requestOptions) {
244
+ return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection((0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)
245
+ ? requestOptions
246
+ : (function () {
247
+ const { ids, scopeId, ...rest } = requestOptions;
248
+ return { ...rest, elementIds: ids, scope: { id: scopeId } };
249
+ })());
250
+ }
251
+ /**
252
+ * Compares two hierarchies specified in the request options
253
+ * @public
254
+ */
255
+ async compareHierarchies(requestOptions) {
256
+ var _a, _b;
257
+ if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {
258
+ return { changes: [] };
259
+ }
260
+ const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;
261
+ this._detail.registerRuleset(rulesetOrId);
262
+ const currRulesetId = (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId);
263
+ const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
264
+ if (prevRulesetId.parts.id !== currRulesetId.parts.id)
265
+ throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "Can't compare rulesets with different IDs");
266
+ const currRulesetVariables = rulesetVariables !== null && rulesetVariables !== void 0 ? rulesetVariables : [];
267
+ const prevRulesetVariables = (_a = prev.rulesetVariables) !== null && _a !== void 0 ? _a : currRulesetVariables;
268
+ const params = {
269
+ requestId: NativePlatform_1.NativePlatformRequestTypes.CompareHierarchies,
270
+ ...options,
271
+ prevRulesetId: prevRulesetId.uniqueId,
272
+ currRulesetId: currRulesetId.uniqueId,
273
+ prevRulesetVariables: JSON.stringify(prevRulesetVariables),
274
+ currRulesetVariables: JSON.stringify(currRulesetVariables),
275
+ expandedNodeKeys: JSON.stringify((_b = options.expandedNodeKeys) !== null && _b !== void 0 ? _b : []),
276
+ };
277
+ const reviver = (key, value) => (key === "") ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value;
278
+ return JSON.parse(await this._detail.request(params), reviver);
279
+ }
280
+ }
281
+ exports.PresentationManager = PresentationManager;
282
+ const ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE = 100;
283
+ async function buildElementsPropertiesInPages(className, ids, getter) {
284
+ const elementProperties = [];
285
+ const elementIds = [...ids];
286
+ while (elementIds.length > 0) {
287
+ const idsPage = elementIds.splice(0, ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE);
288
+ const keys = new presentation_common_1.KeySet(idsPage.map((id) => ({ id, className })));
289
+ elementProperties.push(...(await getter(keys)));
290
+ }
291
+ return elementProperties;
292
+ }
293
293
  //# sourceMappingURL=PresentationManager.js.map