@itwin/presentation-backend 3.6.0-dev.53 → 3.6.0-dev.55

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 (61) hide show
  1. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  2. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +761 -761
  3. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  4. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  5. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  7. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  8. package/lib/cjs/presentation-backend/Constants.js +36 -36
  9. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  10. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  11. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +274 -274
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  13. package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
  14. package/lib/cjs/presentation-backend/NativePlatform.js +140 -140
  15. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  16. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  17. package/lib/cjs/presentation-backend/Presentation.js +150 -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/PresentationIpcHandler.js.map +1 -1
  22. package/lib/cjs/presentation-backend/PresentationManager.d.ts +441 -441
  23. package/lib/cjs/presentation-backend/PresentationManager.js +303 -303
  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.js +378 -378
  30. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  31. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +104 -104
  32. package/lib/cjs/presentation-backend/RulesetEmbedder.js +282 -282
  33. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  34. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  35. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  36. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  37. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  38. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  39. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  40. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +35 -35
  41. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +229 -229
  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/TemporaryStorage.js.map +1 -1
  46. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  47. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  48. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  49. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  50. package/lib/cjs/presentation-backend/Utils.js +106 -106
  51. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  52. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  53. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +51 -51
  54. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  55. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  56. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  57. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  58. package/lib/cjs/presentation-backend.d.ts +19 -19
  59. package/lib/cjs/presentation-backend.js +35 -35
  60. package/lib/cjs/presentation-backend.js.map +1 -1
  61. package/package.json +13 -13
@@ -1,304 +1,304 @@
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
- * @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 serializedNodesJson = await this._detail.getNodes(requestOptions);
117
- const nodesJson = JSON.parse(serializedNodesJson);
118
- const nodes = presentation_common_1.Node.listFromJSON(nodesJson.nodes);
119
- return this._localizationHelper.getLocalizedNodes(nodes);
120
- }
121
- /**
122
- * Retrieves nodes count
123
- * @public
124
- */
125
- async getNodesCount(requestOptions) {
126
- return this._detail.getNodesCount(requestOptions);
127
- }
128
- /**
129
- * Retrieves hierarchy level descriptor
130
- * @alpha
131
- */
132
- async getNodesDescriptor(requestOptions) {
133
- const response = await this._detail.getNodesDescriptor(requestOptions);
134
- const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
135
- return JSON.parse(response, reviver);
136
- }
137
- /**
138
- * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
139
- * TODO: Return results in pages
140
- * @public
141
- */
142
- async getNodePaths(requestOptions) {
143
- return this._detail.getNodePaths(requestOptions);
144
- }
145
- /**
146
- * Retrieves paths from root nodes to nodes containing filter text in their label.
147
- * TODO: Return results in pages
148
- * @public
149
- */
150
- async getFilteredNodePaths(requestOptions) {
151
- return this._detail.getFilteredNodePaths(requestOptions);
152
- }
153
- /** @beta */
154
- async getContentSources(requestOptions) {
155
- return this._detail.getContentSources(requestOptions);
156
- }
157
- /**
158
- * Retrieves the content descriptor which can be used to get content
159
- * @public
160
- */
161
- async getContentDescriptor(requestOptions) {
162
- const response = await this._detail.getContentDescriptor(requestOptions);
163
- const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
164
- return JSON.parse(response, reviver);
165
- }
166
- /**
167
- * Retrieves the content set size based on the supplied content descriptor override
168
- * @public
169
- */
170
- async getContentSetSize(requestOptions) {
171
- return this._detail.getContentSetSize(requestOptions);
172
- }
173
- /**
174
- * Retrieves the content based on the supplied content descriptor override.
175
- * @public
176
- */
177
- async getContent(requestOptions) {
178
- const content = await this._detail.getContent(requestOptions);
179
- if (!content)
180
- return undefined;
181
- return this._localizationHelper.getLocalizedContent(content);
182
- }
183
- /**
184
- * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
185
- * @param requestOptions Options for the request
186
- * @return A promise object that returns either distinct values on success or an error string on error.
187
- * @public
188
- */
189
- async getPagedDistinctValues(requestOptions) {
190
- return this._detail.getPagedDistinctValues(requestOptions);
191
- }
192
- async getElementProperties(requestOptions) {
193
- if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
194
- const elementProperties = await this._detail.getElementProperties(requestOptions);
195
- // istanbul ignore if
196
- if (!elementProperties)
197
- return undefined;
198
- return this._localizationHelper.getLocalizedElementProperties(elementProperties);
199
- }
200
- return this.getMultipleElementProperties(requestOptions);
201
- }
202
- async getMultipleElementProperties(requestOptions) {
203
- const { elementClasses, ...optionsNoElementClasses } = requestOptions;
204
- const elementsCount = (0, ElementPropertiesHelper_1.getElementsCount)(requestOptions.imodel, requestOptions.elementClasses);
205
- const propertiesGetter = async (className, ids) => buildElementsPropertiesInPages(className, ids, async (keys) => {
206
- const content = await this.getContent({
207
- ...optionsNoElementClasses,
208
- descriptor: {
209
- displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
210
- contentFlags: presentation_common_1.ContentFlags.ShowLabels,
211
- },
212
- rulesetOrId: "ElementProperties",
213
- keys,
214
- });
215
- return (0, ElementPropertiesHelper_1.buildElementsProperties)(content);
216
- });
217
- const ELEMENT_IDS_BATCH_SIZE = 1000;
218
- return {
219
- total: elementsCount,
220
- async *iterator() {
221
- for (const idsByClass of (0, ElementPropertiesHelper_1.iterateElementIds)(requestOptions.imodel, elementClasses, ELEMENT_IDS_BATCH_SIZE)) {
222
- const propertiesPage = [];
223
- for (const entry of idsByClass) {
224
- propertiesPage.push(...(await propertiesGetter(entry[0], entry[1])));
225
- }
226
- yield propertiesPage;
227
- }
228
- },
229
- };
230
- }
231
- /**
232
- * Retrieves display label definition of specific item
233
- * @public
234
- */
235
- async getDisplayLabelDefinition(requestOptions) {
236
- const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);
237
- return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);
238
- }
239
- /**
240
- * Retrieves display label definitions of specific items
241
- * @public
242
- */
243
- async getDisplayLabelDefinitions(requestOptions) {
244
- const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);
245
- return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);
246
- }
247
- /**
248
- * Retrieves available selection scopes.
249
- * @public
250
- */
251
- async getSelectionScopes(_requestOptions) {
252
- return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
253
- }
254
- async computeSelection(requestOptions) {
255
- return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection((0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)
256
- ? requestOptions
257
- : (function () {
258
- const { ids, scopeId, ...rest } = requestOptions;
259
- return { ...rest, elementIds: ids, scope: { id: scopeId } };
260
- })());
261
- }
262
- /**
263
- * Compares two hierarchies specified in the request options
264
- * @public
265
- */
266
- async compareHierarchies(requestOptions) {
267
- var _a, _b;
268
- if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {
269
- return { changes: [] };
270
- }
271
- const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;
272
- this._detail.registerRuleset(rulesetOrId);
273
- const currRulesetId = (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId);
274
- const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
275
- if (prevRulesetId.parts.id !== currRulesetId.parts.id)
276
- throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "Can't compare rulesets with different IDs");
277
- const currRulesetVariables = rulesetVariables !== null && rulesetVariables !== void 0 ? rulesetVariables : [];
278
- const prevRulesetVariables = (_a = prev.rulesetVariables) !== null && _a !== void 0 ? _a : currRulesetVariables;
279
- const params = {
280
- requestId: NativePlatform_1.NativePlatformRequestTypes.CompareHierarchies,
281
- ...options,
282
- prevRulesetId: prevRulesetId.uniqueId,
283
- currRulesetId: currRulesetId.uniqueId,
284
- prevRulesetVariables: JSON.stringify(prevRulesetVariables),
285
- currRulesetVariables: JSON.stringify(currRulesetVariables),
286
- expandedNodeKeys: JSON.stringify((_b = options.expandedNodeKeys) !== null && _b !== void 0 ? _b : []),
287
- };
288
- const reviver = (key, value) => (key === "") ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value;
289
- return JSON.parse(await this._detail.request(params), reviver);
290
- }
291
- }
292
- exports.PresentationManager = PresentationManager;
293
- const ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE = 100;
294
- async function buildElementsPropertiesInPages(className, ids, getter) {
295
- const elementProperties = [];
296
- const elementIds = [...ids];
297
- while (elementIds.length > 0) {
298
- const idsPage = elementIds.splice(0, ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE);
299
- const keys = new presentation_common_1.KeySet(idsPage.map((id) => ({ id, className })));
300
- elementProperties.push(...(await getter(keys)));
301
- }
302
- return elementProperties;
303
- }
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
+ * @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 serializedNodesJson = await this._detail.getNodes(requestOptions);
117
+ const nodesJson = JSON.parse(serializedNodesJson);
118
+ const nodes = presentation_common_1.Node.listFromJSON(nodesJson.nodes);
119
+ return this._localizationHelper.getLocalizedNodes(nodes);
120
+ }
121
+ /**
122
+ * Retrieves nodes count
123
+ * @public
124
+ */
125
+ async getNodesCount(requestOptions) {
126
+ return this._detail.getNodesCount(requestOptions);
127
+ }
128
+ /**
129
+ * Retrieves hierarchy level descriptor
130
+ * @alpha
131
+ */
132
+ async getNodesDescriptor(requestOptions) {
133
+ const response = await this._detail.getNodesDescriptor(requestOptions);
134
+ const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
135
+ return JSON.parse(response, reviver);
136
+ }
137
+ /**
138
+ * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
139
+ * TODO: Return results in pages
140
+ * @public
141
+ */
142
+ async getNodePaths(requestOptions) {
143
+ return this._detail.getNodePaths(requestOptions);
144
+ }
145
+ /**
146
+ * Retrieves paths from root nodes to nodes containing filter text in their label.
147
+ * TODO: Return results in pages
148
+ * @public
149
+ */
150
+ async getFilteredNodePaths(requestOptions) {
151
+ return this._detail.getFilteredNodePaths(requestOptions);
152
+ }
153
+ /** @beta */
154
+ async getContentSources(requestOptions) {
155
+ return this._detail.getContentSources(requestOptions);
156
+ }
157
+ /**
158
+ * Retrieves the content descriptor which can be used to get content
159
+ * @public
160
+ */
161
+ async getContentDescriptor(requestOptions) {
162
+ const response = await this._detail.getContentDescriptor(requestOptions);
163
+ const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
164
+ return JSON.parse(response, reviver);
165
+ }
166
+ /**
167
+ * Retrieves the content set size based on the supplied content descriptor override
168
+ * @public
169
+ */
170
+ async getContentSetSize(requestOptions) {
171
+ return this._detail.getContentSetSize(requestOptions);
172
+ }
173
+ /**
174
+ * Retrieves the content based on the supplied content descriptor override.
175
+ * @public
176
+ */
177
+ async getContent(requestOptions) {
178
+ const content = await this._detail.getContent(requestOptions);
179
+ if (!content)
180
+ return undefined;
181
+ return this._localizationHelper.getLocalizedContent(content);
182
+ }
183
+ /**
184
+ * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
185
+ * @param requestOptions Options for the request
186
+ * @return A promise object that returns either distinct values on success or an error string on error.
187
+ * @public
188
+ */
189
+ async getPagedDistinctValues(requestOptions) {
190
+ return this._detail.getPagedDistinctValues(requestOptions);
191
+ }
192
+ async getElementProperties(requestOptions) {
193
+ if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
194
+ const elementProperties = await this._detail.getElementProperties(requestOptions);
195
+ // istanbul ignore if
196
+ if (!elementProperties)
197
+ return undefined;
198
+ return this._localizationHelper.getLocalizedElementProperties(elementProperties);
199
+ }
200
+ return this.getMultipleElementProperties(requestOptions);
201
+ }
202
+ async getMultipleElementProperties(requestOptions) {
203
+ const { elementClasses, ...optionsNoElementClasses } = requestOptions;
204
+ const elementsCount = (0, ElementPropertiesHelper_1.getElementsCount)(requestOptions.imodel, requestOptions.elementClasses);
205
+ const propertiesGetter = async (className, ids) => buildElementsPropertiesInPages(className, ids, async (keys) => {
206
+ const content = await this.getContent({
207
+ ...optionsNoElementClasses,
208
+ descriptor: {
209
+ displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
210
+ contentFlags: presentation_common_1.ContentFlags.ShowLabels,
211
+ },
212
+ rulesetOrId: "ElementProperties",
213
+ keys,
214
+ });
215
+ return (0, ElementPropertiesHelper_1.buildElementsProperties)(content);
216
+ });
217
+ const ELEMENT_IDS_BATCH_SIZE = 1000;
218
+ return {
219
+ total: elementsCount,
220
+ async *iterator() {
221
+ for (const idsByClass of (0, ElementPropertiesHelper_1.iterateElementIds)(requestOptions.imodel, elementClasses, ELEMENT_IDS_BATCH_SIZE)) {
222
+ const propertiesPage = [];
223
+ for (const entry of idsByClass) {
224
+ propertiesPage.push(...(await propertiesGetter(entry[0], entry[1])));
225
+ }
226
+ yield propertiesPage;
227
+ }
228
+ },
229
+ };
230
+ }
231
+ /**
232
+ * Retrieves display label definition of specific item
233
+ * @public
234
+ */
235
+ async getDisplayLabelDefinition(requestOptions) {
236
+ const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);
237
+ return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);
238
+ }
239
+ /**
240
+ * Retrieves display label definitions of specific items
241
+ * @public
242
+ */
243
+ async getDisplayLabelDefinitions(requestOptions) {
244
+ const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);
245
+ return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);
246
+ }
247
+ /**
248
+ * Retrieves available selection scopes.
249
+ * @public
250
+ */
251
+ async getSelectionScopes(_requestOptions) {
252
+ return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
253
+ }
254
+ async computeSelection(requestOptions) {
255
+ return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection((0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)
256
+ ? requestOptions
257
+ : (function () {
258
+ const { ids, scopeId, ...rest } = requestOptions;
259
+ return { ...rest, elementIds: ids, scope: { id: scopeId } };
260
+ })());
261
+ }
262
+ /**
263
+ * Compares two hierarchies specified in the request options
264
+ * @public
265
+ */
266
+ async compareHierarchies(requestOptions) {
267
+ var _a, _b;
268
+ if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {
269
+ return { changes: [] };
270
+ }
271
+ const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;
272
+ this._detail.registerRuleset(rulesetOrId);
273
+ const currRulesetId = (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId);
274
+ const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
275
+ if (prevRulesetId.parts.id !== currRulesetId.parts.id)
276
+ throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "Can't compare rulesets with different IDs");
277
+ const currRulesetVariables = rulesetVariables !== null && rulesetVariables !== void 0 ? rulesetVariables : [];
278
+ const prevRulesetVariables = (_a = prev.rulesetVariables) !== null && _a !== void 0 ? _a : currRulesetVariables;
279
+ const params = {
280
+ requestId: NativePlatform_1.NativePlatformRequestTypes.CompareHierarchies,
281
+ ...options,
282
+ prevRulesetId: prevRulesetId.uniqueId,
283
+ currRulesetId: currRulesetId.uniqueId,
284
+ prevRulesetVariables: JSON.stringify(prevRulesetVariables),
285
+ currRulesetVariables: JSON.stringify(currRulesetVariables),
286
+ expandedNodeKeys: JSON.stringify((_b = options.expandedNodeKeys) !== null && _b !== void 0 ? _b : []),
287
+ };
288
+ const reviver = (key, value) => (key === "") ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value;
289
+ return JSON.parse(await this._detail.request(params), reviver);
290
+ }
291
+ }
292
+ exports.PresentationManager = PresentationManager;
293
+ const ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE = 100;
294
+ async function buildElementsPropertiesInPages(className, ids, getter) {
295
+ const elementProperties = [];
296
+ const elementIds = [...ids];
297
+ while (elementIds.length > 0) {
298
+ const idsPage = elementIds.splice(0, ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE);
299
+ const keys = new presentation_common_1.KeySet(idsPage.map((id) => ({ id, className })));
300
+ elementProperties.push(...(await getter(keys)));
301
+ }
302
+ return elementProperties;
303
+ }
304
304
  //# sourceMappingURL=PresentationManager.js.map