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

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 +47 -1
  2. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  3. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +726 -762
  4. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  5. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  7. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  8. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  9. package/lib/cjs/presentation-backend/Constants.js +40 -36
  10. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  11. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +272 -274
  13. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  14. package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
  15. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  16. package/lib/cjs/presentation-backend/NativePlatform.js +147 -140
  17. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  18. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  19. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
  20. package/lib/cjs/presentation-backend/Presentation.js +148 -150
  21. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +11 -12
  23. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
  24. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +30 -41
  25. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  26. package/lib/cjs/presentation-backend/PresentationManager.d.ts +463 -445
  27. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  28. package/lib/cjs/presentation-backend/PresentationManager.js +317 -311
  29. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  30. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
  31. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
  32. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +442 -430
  33. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  34. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
  35. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  36. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
  37. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
  39. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
  40. package/lib/cjs/presentation-backend/RulesetEmbedder.js +287 -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 -28
  49. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +226 -229
  50. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  51. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  52. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  53. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  54. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  55. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  56. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  57. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  58. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  59. package/lib/cjs/presentation-backend/Utils.js +107 -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 +55 -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 +39 -35
  69. package/lib/cjs/presentation-backend.js.map +1 -1
  70. package/package.json +20 -18
@@ -1,312 +1,318 @@
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({
185
+ ...requestOptions,
186
+ ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),
187
+ });
188
+ if (!content)
189
+ return undefined;
190
+ if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {
191
+ const koqPropertyFormatter = new presentation_common_1.KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel));
192
+ const formatter = new presentation_common_1.ContentFormatter(new presentation_common_1.ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem);
193
+ await formatter.formatContent(content);
194
+ }
195
+ return this._localizationHelper.getLocalizedContent(content);
196
+ }
197
+ /**
198
+ * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
199
+ * @param requestOptions Options for the request
200
+ * @return A promise object that returns either distinct values on success or an error string on error.
201
+ * @public
202
+ */
203
+ async getPagedDistinctValues(requestOptions) {
204
+ return this._detail.getPagedDistinctValues(requestOptions);
205
+ }
206
+ async getElementProperties(requestOptions) {
207
+ if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
208
+ const elementProperties = await this._detail.getElementProperties(requestOptions);
209
+ // istanbul ignore if
210
+ if (!elementProperties)
211
+ return undefined;
212
+ return this._localizationHelper.getLocalizedElementProperties(elementProperties);
213
+ }
214
+ return this.getMultipleElementProperties(requestOptions);
215
+ }
216
+ async getMultipleElementProperties(requestOptions) {
217
+ const { elementClasses, ...optionsNoElementClasses } = requestOptions;
218
+ const elementsCount = (0, ElementPropertiesHelper_1.getElementsCount)(requestOptions.imodel, requestOptions.elementClasses);
219
+ const propertiesGetter = async (className, ids) => buildElementsPropertiesInPages(className, ids, async (keys) => {
220
+ const content = await this.getContent({
221
+ ...optionsNoElementClasses,
222
+ descriptor: {
223
+ displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
224
+ contentFlags: presentation_common_1.ContentFlags.ShowLabels,
225
+ },
226
+ rulesetOrId: "ElementProperties",
227
+ keys,
228
+ });
229
+ return (0, ElementPropertiesHelper_1.buildElementsProperties)(content);
230
+ });
231
+ const ELEMENT_IDS_BATCH_SIZE = 1000;
232
+ return {
233
+ total: elementsCount,
234
+ async *iterator() {
235
+ for (const idsByClass of (0, ElementPropertiesHelper_1.iterateElementIds)(requestOptions.imodel, elementClasses, ELEMENT_IDS_BATCH_SIZE)) {
236
+ const propertiesPage = [];
237
+ for (const entry of idsByClass) {
238
+ propertiesPage.push(...(await propertiesGetter(entry[0], entry[1])));
239
+ }
240
+ yield propertiesPage;
241
+ }
242
+ },
243
+ };
244
+ }
245
+ /**
246
+ * Retrieves display label definition of specific item
247
+ * @public
248
+ */
249
+ async getDisplayLabelDefinition(requestOptions) {
250
+ const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);
251
+ return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);
252
+ }
253
+ /**
254
+ * Retrieves display label definitions of specific items
255
+ * @public
256
+ */
257
+ async getDisplayLabelDefinitions(requestOptions) {
258
+ const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);
259
+ return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);
260
+ }
261
+ /**
262
+ * Retrieves available selection scopes.
263
+ * @public
264
+ */
265
+ async getSelectionScopes(_requestOptions) {
266
+ return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
267
+ }
268
+ async computeSelection(requestOptions) {
269
+ return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection((0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)
270
+ ? requestOptions
271
+ : (function () {
272
+ const { ids, scopeId, ...rest } = requestOptions;
273
+ return { ...rest, elementIds: ids, scope: { id: scopeId } };
274
+ })());
275
+ }
276
+ /**
277
+ * Compares two hierarchies specified in the request options
278
+ * @public
279
+ */
280
+ async compareHierarchies(requestOptions) {
281
+ if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {
282
+ return { changes: [] };
283
+ }
284
+ const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;
285
+ this._detail.registerRuleset(rulesetOrId);
286
+ const currRulesetId = (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId);
287
+ const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
288
+ if (prevRulesetId.parts.id !== currRulesetId.parts.id)
289
+ throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "Can't compare rulesets with different IDs");
290
+ const currRulesetVariables = rulesetVariables ?? [];
291
+ const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;
292
+ const params = {
293
+ requestId: NativePlatform_1.NativePlatformRequestTypes.CompareHierarchies,
294
+ ...options,
295
+ prevRulesetId: prevRulesetId.uniqueId,
296
+ currRulesetId: currRulesetId.uniqueId,
297
+ prevRulesetVariables: JSON.stringify(prevRulesetVariables),
298
+ currRulesetVariables: JSON.stringify(currRulesetVariables),
299
+ expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),
300
+ };
301
+ // eslint-disable-next-line deprecation/deprecation
302
+ const reviver = (key, value) => (key === "") ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value;
303
+ return JSON.parse(await this._detail.request(params), reviver);
304
+ }
305
+ }
306
+ exports.PresentationManager = PresentationManager;
307
+ const ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE = 100;
308
+ async function buildElementsPropertiesInPages(className, ids, getter) {
309
+ const elementProperties = [];
310
+ const elementIds = [...ids];
311
+ while (elementIds.length > 0) {
312
+ const idsPage = elementIds.splice(0, ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE);
313
+ const keys = new presentation_common_1.KeySet(idsPage.map((id) => ({ id, className })));
314
+ elementProperties.push(...(await getter(keys)));
315
+ }
316
+ return elementProperties;
317
+ }
312
318
  //# sourceMappingURL=PresentationManager.js.map