@itwin/presentation-backend 4.0.0-dev.8 → 4.0.0-dev.80

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