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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  4. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +761 -761
  5. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  7. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  8. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  9. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  10. package/lib/cjs/presentation-backend/Constants.js +36 -36
  11. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  13. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +274 -274
  14. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  15. package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -82
  16. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  17. package/lib/cjs/presentation-backend/NativePlatform.js +140 -139
  18. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  19. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  20. package/lib/cjs/presentation-backend/Presentation.js +150 -150
  21. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
  23. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
  24. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
  25. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  26. package/lib/cjs/presentation-backend/PresentationManager.d.ts +445 -436
  27. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  28. package/lib/cjs/presentation-backend/PresentationManager.js +311 -292
  29. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  30. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -60
  31. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
  32. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +430 -420
  33. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  34. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -61
  35. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  36. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -365
  37. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -104
  39. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
  40. package/lib/cjs/presentation-backend/RulesetEmbedder.js +282 -282
  41. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  42. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  43. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  44. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  45. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  46. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  47. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  48. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -35
  49. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
  50. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +229 -229
  51. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  52. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  53. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  54. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  55. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  56. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  57. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  58. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  59. package/lib/cjs/presentation-backend/Utils.js +106 -106
  60. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  61. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  62. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +51 -51
  63. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  64. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  65. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  66. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  67. package/lib/cjs/presentation-backend.d.ts +19 -19
  68. package/lib/cjs/presentation-backend.js +35 -35
  69. package/lib/cjs/presentation-backend.js.map +1 -1
  70. package/package.json +13 -13
@@ -1,293 +1,312 @@
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 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
+ }
293
312
  //# sourceMappingURL=PresentationManager.js.map