@itwin/presentation-backend 5.0.0-dev.11 → 5.0.0-dev.110

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 (148) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/lib/cjs/package.json +1 -0
  3. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +31 -4
  4. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -1
  5. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +161 -56
  6. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  7. package/lib/cjs/presentation-backend/InternalSymbols.d.ts +5 -0
  8. package/lib/cjs/presentation-backend/InternalSymbols.d.ts.map +1 -0
  9. package/lib/cjs/presentation-backend/InternalSymbols.js +16 -0
  10. package/lib/cjs/presentation-backend/InternalSymbols.js.map +1 -0
  11. package/lib/cjs/presentation-backend/NativePlatform.d.ts +2 -2
  12. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  13. package/lib/cjs/presentation-backend/NativePlatform.js +5 -3
  14. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  15. package/lib/cjs/presentation-backend/Presentation.d.ts +2 -7
  16. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
  17. package/lib/cjs/presentation-backend/Presentation.js +40 -29
  18. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  19. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +3 -3
  20. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
  21. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +5 -7
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  23. package/lib/cjs/presentation-backend/PresentationManager.d.ts +13 -90
  24. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  25. package/lib/cjs/presentation-backend/PresentationManager.js +79 -130
  26. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  27. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +19 -10
  28. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
  29. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +83 -76
  30. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  31. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +11 -11
  32. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  33. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +110 -118
  34. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  35. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
  36. package/lib/cjs/presentation-backend/RulesetEmbedder.js +23 -24
  37. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetManager.d.ts +1 -1
  39. package/lib/cjs/presentation-backend/RulesetManager.d.ts.map +1 -1
  40. package/lib/cjs/presentation-backend/RulesetManager.js +2 -1
  41. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  42. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +1 -1
  43. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts.map +1 -1
  44. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +2 -0
  45. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  46. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +2 -4
  47. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
  48. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +70 -83
  49. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  50. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +2 -3
  51. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -1
  52. package/lib/cjs/presentation-backend/TemporaryStorage.js +30 -28
  53. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  54. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  55. package/lib/cjs/presentation-backend/Utils.js +15 -21
  56. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  57. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +2 -2
  58. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  59. package/lib/cjs/presentation-backend/domain/RulesetElements.js +4 -4
  60. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  61. package/lib/cjs/presentation-backend-internal.d.ts +2 -0
  62. package/lib/cjs/presentation-backend-internal.d.ts.map +1 -0
  63. package/lib/cjs/presentation-backend-internal.js +12 -0
  64. package/lib/cjs/presentation-backend-internal.js.map +1 -0
  65. package/lib/cjs/presentation-backend.d.ts +7 -7
  66. package/lib/cjs/presentation-backend.d.ts.map +1 -1
  67. package/lib/cjs/presentation-backend.js +11 -21
  68. package/lib/cjs/presentation-backend.js.map +1 -1
  69. package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts +62 -0
  70. package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts.map +1 -0
  71. package/lib/esm/presentation-backend/BackendLoggerCategory.js +69 -0
  72. package/lib/esm/presentation-backend/BackendLoggerCategory.js.map +1 -0
  73. package/lib/esm/presentation-backend/ElementPropertiesHelper.d.ts +45 -0
  74. package/lib/esm/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -0
  75. package/lib/esm/presentation-backend/ElementPropertiesHelper.js +187 -0
  76. package/lib/esm/presentation-backend/ElementPropertiesHelper.js.map +1 -0
  77. package/lib/esm/presentation-backend/InternalSymbols.d.ts +5 -0
  78. package/lib/esm/presentation-backend/InternalSymbols.d.ts.map +1 -0
  79. package/lib/esm/presentation-backend/InternalSymbols.js +13 -0
  80. package/lib/esm/presentation-backend/InternalSymbols.js.map +1 -0
  81. package/lib/esm/presentation-backend/NativePlatform.d.ts +89 -0
  82. package/lib/esm/presentation-backend/NativePlatform.d.ts.map +1 -0
  83. package/lib/esm/presentation-backend/NativePlatform.js +156 -0
  84. package/lib/esm/presentation-backend/NativePlatform.js.map +1 -0
  85. package/lib/esm/presentation-backend/Presentation.d.ts +97 -0
  86. package/lib/esm/presentation-backend/Presentation.d.ts.map +1 -0
  87. package/lib/esm/presentation-backend/Presentation.js +147 -0
  88. package/lib/esm/presentation-backend/Presentation.js.map +1 -0
  89. package/lib/esm/presentation-backend/PresentationIpcHandler.d.ts +12 -0
  90. package/lib/esm/presentation-backend/PresentationIpcHandler.d.ts.map +1 -0
  91. package/lib/esm/presentation-backend/PresentationIpcHandler.js +25 -0
  92. package/lib/esm/presentation-backend/PresentationIpcHandler.js.map +1 -0
  93. package/lib/esm/presentation-backend/PresentationManager.d.ts +387 -0
  94. package/lib/esm/presentation-backend/PresentationManager.d.ts.map +1 -0
  95. package/lib/esm/presentation-backend/PresentationManager.js +352 -0
  96. package/lib/esm/presentation-backend/PresentationManager.js.map +1 -0
  97. package/lib/esm/presentation-backend/PresentationManagerDetail.d.ts +74 -0
  98. package/lib/esm/presentation-backend/PresentationManagerDetail.d.ts.map +1 -0
  99. package/lib/esm/presentation-backend/PresentationManagerDetail.js +446 -0
  100. package/lib/esm/presentation-backend/PresentationManagerDetail.js.map +1 -0
  101. package/lib/esm/presentation-backend/PresentationRpcImpl.d.ts +63 -0
  102. package/lib/esm/presentation-backend/PresentationRpcImpl.d.ts.map +1 -0
  103. package/lib/esm/presentation-backend/PresentationRpcImpl.js +409 -0
  104. package/lib/esm/presentation-backend/PresentationRpcImpl.js.map +1 -0
  105. package/lib/esm/presentation-backend/RulesetEmbedder.d.ts +109 -0
  106. package/lib/esm/presentation-backend/RulesetEmbedder.d.ts.map +1 -0
  107. package/lib/esm/presentation-backend/RulesetEmbedder.js +269 -0
  108. package/lib/esm/presentation-backend/RulesetEmbedder.js.map +1 -0
  109. package/lib/esm/presentation-backend/RulesetManager.d.ts +54 -0
  110. package/lib/esm/presentation-backend/RulesetManager.d.ts.map +1 -0
  111. package/lib/esm/presentation-backend/RulesetManager.js +74 -0
  112. package/lib/esm/presentation-backend/RulesetManager.js.map +1 -0
  113. package/lib/esm/presentation-backend/RulesetVariablesManager.d.ts +141 -0
  114. package/lib/esm/presentation-backend/RulesetVariablesManager.d.ts.map +1 -0
  115. package/lib/esm/presentation-backend/RulesetVariablesManager.js +140 -0
  116. package/lib/esm/presentation-backend/RulesetVariablesManager.js.map +1 -0
  117. package/lib/esm/presentation-backend/SelectionScopesHelper.d.ts +27 -0
  118. package/lib/esm/presentation-backend/SelectionScopesHelper.d.ts.map +1 -0
  119. package/lib/esm/presentation-backend/SelectionScopesHelper.js +227 -0
  120. package/lib/esm/presentation-backend/SelectionScopesHelper.js.map +1 -0
  121. package/lib/esm/presentation-backend/TemporaryStorage.d.ts +123 -0
  122. package/lib/esm/presentation-backend/TemporaryStorage.d.ts.map +1 -0
  123. package/lib/esm/presentation-backend/TemporaryStorage.js +157 -0
  124. package/lib/esm/presentation-backend/TemporaryStorage.js.map +1 -0
  125. package/lib/esm/presentation-backend/Utils.d.ts +50 -0
  126. package/lib/esm/presentation-backend/Utils.d.ts.map +1 -0
  127. package/lib/esm/presentation-backend/Utils.js +101 -0
  128. package/lib/esm/presentation-backend/Utils.js.map +1 -0
  129. package/lib/esm/presentation-backend/domain/PresentationRulesDomain.d.ts +17 -0
  130. package/lib/esm/presentation-backend/domain/PresentationRulesDomain.d.ts.map +1 -0
  131. package/lib/esm/presentation-backend/domain/PresentationRulesDomain.js +31 -0
  132. package/lib/esm/presentation-backend/domain/PresentationRulesDomain.js.map +1 -0
  133. package/lib/esm/presentation-backend/domain/RulesetElements.d.ts +22 -0
  134. package/lib/esm/presentation-backend/domain/RulesetElements.d.ts.map +1 -0
  135. package/lib/esm/presentation-backend/domain/RulesetElements.js +38 -0
  136. package/lib/esm/presentation-backend/domain/RulesetElements.js.map +1 -0
  137. package/lib/esm/presentation-backend/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -0
  138. package/lib/esm/presentation-backend/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +701 -0
  139. package/lib/esm/presentation-backend/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -0
  140. package/lib/esm/presentation-backend-internal.d.ts +2 -0
  141. package/lib/esm/presentation-backend-internal.d.ts.map +1 -0
  142. package/lib/esm/presentation-backend-internal.js +8 -0
  143. package/lib/esm/presentation-backend-internal.js.map +1 -0
  144. package/lib/esm/presentation-backend.d.ts +20 -0
  145. package/lib/esm/presentation-backend.d.ts.map +1 -0
  146. package/lib/esm/presentation-backend.js +21 -0
  147. package/lib/esm/presentation-backend.js.map +1 -0
  148. package/package.json +42 -35
@@ -7,34 +7,18 @@
7
7
  * @module Core
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.PresentationManager = exports.HierarchyCacheMode = exports.PresentationManagerMode = void 0;
10
+ exports.PresentationManager = exports.HierarchyCacheMode = void 0;
11
11
  const rxjs_1 = require("rxjs");
12
12
  const rxjs_for_await_1 = require("rxjs-for-await");
13
13
  const presentation_common_1 = require("@itwin/presentation-common");
14
- const ElementPropertiesHelper_1 = require("./ElementPropertiesHelper");
15
- const NativePlatform_1 = require("./NativePlatform");
16
- const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
17
- const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
18
- const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
19
- const Utils_1 = require("./Utils");
20
- /**
21
- * Presentation manager working mode.
22
- * @public
23
- * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
24
- */
25
- var PresentationManagerMode;
26
- (function (PresentationManagerMode) {
27
- /**
28
- * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
29
- * related to reacting to changes in iModels.
30
- */
31
- PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
32
- /**
33
- * Presentation manager assumes iModels are opened in read-write mode and it may need to
34
- * react to changes. This involves some additional work and gives slightly worse performance.
35
- */
36
- PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
37
- })(PresentationManagerMode || (exports.PresentationManagerMode = PresentationManagerMode = {}));
14
+ const internal_1 = require("@itwin/presentation-common/internal");
15
+ const ElementPropertiesHelper_js_1 = require("./ElementPropertiesHelper.js");
16
+ const NativePlatform_js_1 = require("./NativePlatform.js");
17
+ const PresentationManagerDetail_js_1 = require("./PresentationManagerDetail.js");
18
+ const RulesetVariablesManager_js_1 = require("./RulesetVariablesManager.js");
19
+ const SelectionScopesHelper_js_1 = require("./SelectionScopesHelper.js");
20
+ const Utils_js_1 = require("./Utils.js");
21
+ const InternalSymbols_js_1 = require("./InternalSymbols.js");
38
22
  /**
39
23
  * Presentation hierarchy cache mode.
40
24
  * @public
@@ -65,35 +49,38 @@ var HierarchyCacheMode;
65
49
  * @public
66
50
  */
67
51
  class PresentationManager {
52
+ _props;
53
+ _detail;
54
+ _localizationHelper;
68
55
  /**
69
56
  * Creates an instance of PresentationManager.
70
57
  * @param props Optional configuration properties.
71
58
  */
72
59
  constructor(props) {
73
- /** @internal */
74
- this.getNativePlatform = () => {
75
- return this._detail.getNativePlatform();
76
- };
77
60
  this._props = props ?? {};
78
- this._detail = new PresentationManagerDetail_1.PresentationManagerDetail(this._props);
79
- this.activeLocale = this._props.defaultLocale; // eslint-disable-line @typescript-eslint/no-deprecated
80
- this._localizationHelper = new presentation_common_1.LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? Utils_1.getLocalizedStringEN });
61
+ this._detail = new PresentationManagerDetail_js_1.PresentationManagerDetail(this._props);
62
+ this._localizationHelper = new internal_1.LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? Utils_js_1.getLocalizedStringEN });
81
63
  }
82
64
  /** Get / set active unit system used to format property values with units */
83
65
  get activeUnitSystem() {
84
66
  return this._detail.activeUnitSystem;
85
67
  }
86
- // istanbul ignore next
68
+ /* c8 ignore next 3 */
87
69
  set activeUnitSystem(value) {
88
70
  this._detail.activeUnitSystem = value;
89
71
  }
90
72
  /** Dispose the presentation manager. Must be called to clean up native resources. */
73
+ [Symbol.dispose]() {
74
+ this._detail[Symbol.dispose]();
75
+ }
76
+ /** @deprecated in 5.0 Use [Symbol.dispose] instead. */
77
+ /* c8 ignore next 3 */
91
78
  dispose() {
92
- this._detail.dispose();
79
+ this[Symbol.dispose]();
93
80
  }
94
- /** @internal */
95
- setOnManagerUsedHandler(handler) {
96
- this._detail.setOnManagerUsedHandler(handler);
81
+ /** An event, that this manager raises whenever any request is made on it. */
82
+ get onUsed() {
83
+ return this._detail.onUsed;
97
84
  }
98
85
  /** Properties used to initialize the manager */
99
86
  get props() {
@@ -108,14 +95,13 @@ class PresentationManager {
108
95
  * @param rulesetId Id of the ruleset to get variables manager for
109
96
  */
110
97
  vars(rulesetId) {
111
- return new RulesetVariablesManager_1.RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);
98
+ return new RulesetVariablesManager_js_1.RulesetVariablesManagerImpl(() => this._detail.getNativePlatform(), rulesetId);
112
99
  }
113
100
  /** @internal */
114
- // istanbul ignore next
115
- getDetail() {
101
+ /* c8 ignore next 3 */
102
+ get [InternalSymbols_js_1._presentation_manager_detail]() {
116
103
  return this._detail;
117
104
  }
118
- /** @internal */
119
105
  getRulesetId(rulesetOrId) {
120
106
  return this._detail.getRulesetId(rulesetOrId);
121
107
  }
@@ -124,11 +110,9 @@ class PresentationManager {
124
110
  * @public
125
111
  */
126
112
  async getNodes(requestOptions) {
127
- const serializedNodesJson = await this._detail.getNodes(requestOptions);
128
- // eslint-disable-next-line @typescript-eslint/no-deprecated
129
- const nodesJson = JSON.parse(serializedNodesJson);
130
- const nodes = presentation_common_1.Node.listFromJSON(nodesJson.nodes);
131
- return this._localizationHelper.getLocalizedNodes(nodes);
113
+ const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);
114
+ const hierarchyLevel = (0, internal_1.deepReplaceNullsToUndefined)(JSON.parse(serializedHierarchyLevel));
115
+ return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);
132
116
  }
133
117
  /**
134
118
  * Retrieves nodes count
@@ -199,7 +183,7 @@ class PresentationManager {
199
183
  });
200
184
  if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {
201
185
  const koqPropertyFormatter = new presentation_common_1.KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);
202
- const formatter = new presentation_common_1.ContentFormatter(new presentation_common_1.ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this.props.defaultUnitSystem);
186
+ const formatter = new internal_1.ContentFormatter(new internal_1.ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this.props.defaultUnitSystem);
203
187
  items = await formatter.formatContentItems(items, requestOptions.descriptor);
204
188
  }
205
189
  return this._localizationHelper.getLocalizedContentItems(items);
@@ -218,7 +202,7 @@ class PresentationManager {
218
202
  }
219
203
  if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {
220
204
  const koqPropertyFormatter = new presentation_common_1.KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);
221
- const formatter = new presentation_common_1.ContentFormatter(new presentation_common_1.ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this.props.defaultUnitSystem);
205
+ const formatter = new internal_1.ContentFormatter(new internal_1.ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this.props.defaultUnitSystem);
222
206
  await formatter.formatContent(content);
223
207
  }
224
208
  return this._localizationHelper.getLocalizedContent(content);
@@ -237,14 +221,14 @@ class PresentationManager {
237
221
  };
238
222
  }
239
223
  async getElementProperties(requestOptions) {
240
- if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
224
+ if ((0, internal_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
241
225
  return this.getSingleElementProperties(requestOptions);
242
226
  }
243
227
  return this.getMultipleElementProperties(requestOptions);
244
228
  }
245
229
  async getSingleElementProperties(requestOptions) {
246
230
  const { elementId, contentParser, ...optionsNoElementId } = requestOptions;
247
- const parser = contentParser ?? presentation_common_1.buildElementProperties;
231
+ const parser = contentParser ?? internal_1.buildElementProperties;
248
232
  const content = await this.getContent({
249
233
  ...optionsNoElementId,
250
234
  descriptor: {
@@ -260,83 +244,47 @@ class PresentationManager {
260
244
  return parser(content.descriptor, content.contentSet[0]);
261
245
  }
262
246
  async getMultipleElementProperties(requestOptions) {
263
- const { elementClasses, contentParser, batchSize, ...contentOptions } = requestOptions;
264
- const parser = contentParser ?? presentation_common_1.buildElementProperties;
247
+ const { contentParser, batchSize: batchSizeOption, ...contentOptions } = requestOptions;
248
+ const parser = contentParser ?? internal_1.buildElementProperties;
265
249
  const workerThreadsCount = this._props.workerThreadsCount ?? 2;
266
250
  // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory
267
251
  // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,
268
252
  // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at
269
253
  // most `workerThreadsCount / 2` classes in parallel.
270
- // istanbul ignore next
271
- const classParallelism = workerThreadsCount > 1 ? workerThreadsCount / 2 : 1;
254
+ /* c8 ignore next */
255
+ const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;
272
256
  // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,
273
257
  // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.
274
258
  // To avoid that, we keep twice as much requests active.
275
- // istanbul ignore next
276
- const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount * 2 : 2;
277
- const createClassContentRuleset = (fullClassName) => {
278
- const [schemaName, className] = (0, ElementPropertiesHelper_1.parseFullClassName)(fullClassName);
279
- return {
280
- id: `content/${fullClassName}`,
281
- rules: [
282
- {
283
- ruleType: "Content",
284
- specifications: [
285
- {
286
- specType: "ContentInstancesOfSpecificClasses",
287
- classes: {
288
- schemaName,
289
- classNames: [className],
290
- arePolymorphic: false,
291
- },
292
- handlePropertiesPolymorphically: true,
293
- },
294
- ],
295
- },
296
- ],
297
- };
298
- };
299
- const getContentDescriptor = async (ruleset) => {
300
- return (await this.getContentDescriptor({
301
- ...contentOptions,
302
- rulesetOrId: ruleset,
303
- displayType: presentation_common_1.DefaultContentDisplayTypes.Grid,
304
- contentFlags: presentation_common_1.ContentFlags.ShowLabels,
305
- keys: new presentation_common_1.KeySet(),
306
- }));
307
- };
308
- const obs = (0, ElementPropertiesHelper_1.getClassesWithInstances)(requestOptions.imodel, elementClasses ?? /* istanbul ignore next */ ["BisCore.Element"]).pipe((0, rxjs_1.map)((classFullName) => ({
309
- classFullName,
310
- ruleset: createClassContentRuleset(classFullName),
311
- })), (0, rxjs_1.mergeMap)(({ classFullName, ruleset }) =>
312
- // use forkJoin to query descriptor and element ids in parallel
313
- (0, rxjs_1.forkJoin)({
314
- classFullName: (0, rxjs_1.of)(classFullName),
315
- ruleset: (0, rxjs_1.of)(ruleset),
316
- descriptor: (0, rxjs_1.from)(getContentDescriptor(ruleset)),
317
- batches: (0, rxjs_1.from)((0, ElementPropertiesHelper_1.getBatchedClassElementIds)(requestOptions.imodel, classFullName, batchSize ?? /* istanbul ignore next */ 1000)),
318
- }).pipe(
319
- // split incoming stream into individual batch requests
320
- (0, rxjs_1.mergeMap)(({ descriptor, batches }) => (0, rxjs_1.from)(batches.map((batch) => ({ classFullName, descriptor, batch })))),
321
- // request content for each batch, filter by IDs for performance
322
- (0, rxjs_1.mergeMap)(({ descriptor, batch }) => {
323
- const filteringDescriptor = new presentation_common_1.Descriptor(descriptor);
324
- filteringDescriptor.instanceFilter = {
325
- selectClassName: classFullName,
326
- expression: `this.ECInstanceId >= ${Number.parseInt(batch.from, 16)} AND this.ECInstanceId <= ${Number.parseInt(batch.to, 16)}`,
327
- };
328
- return (0, rxjs_1.from)(this.getContentSet({
329
- ...contentOptions,
330
- keys: new presentation_common_1.KeySet(),
331
- descriptor: filteringDescriptor,
332
- rulesetOrId: ruleset,
333
- })).pipe((0, rxjs_1.map)((items) => ({ classFullName, descriptor, items })));
334
- }, batchesParallelism)), classParallelism), (0, rxjs_1.map)(({ descriptor, items }) => items.map((item) => parser(descriptor, item))));
259
+ /* c8 ignore next */
260
+ const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;
261
+ /* c8 ignore next */
262
+ const batchSize = batchSizeOption ?? 100;
263
+ const elementsIdentifier = (() => {
264
+ if ("elementIds" in contentOptions && contentOptions.elementIds !== undefined) {
265
+ const elementIds = contentOptions.elementIds;
266
+ delete contentOptions.elementIds;
267
+ return { elementIds };
268
+ }
269
+ if ("elementClasses" in contentOptions && contentOptions.elementClasses !== undefined) {
270
+ const elementClasses = contentOptions.elementClasses;
271
+ delete contentOptions.elementClasses;
272
+ return { elementClasses };
273
+ }
274
+ /* c8 ignore next */
275
+ return { elementClasses: ["BisCore:Element"] };
276
+ })();
277
+ const descriptorGetter = async (partialProps) => this.getContentDescriptor({ ...contentOptions, displayType: presentation_common_1.DefaultContentDisplayTypes.Grid, contentFlags: presentation_common_1.ContentFlags.ShowLabels, ...partialProps });
278
+ const contentSetGetter = async (partialProps) => this.getContentSet({ ...contentOptions, ...partialProps });
279
+ const { itemBatches, count } = "elementIds" in elementsIdentifier
280
+ ? (0, ElementPropertiesHelper_js_1.getContentItemsObservableFromElementIds)(requestOptions.imodel, descriptorGetter, contentSetGetter, elementsIdentifier.elementIds, classParallelism, batchesParallelism, batchSize)
281
+ : (0, ElementPropertiesHelper_js_1.getContentItemsObservableFromClassNames)(requestOptions.imodel, descriptorGetter, contentSetGetter, elementsIdentifier.elementClasses, classParallelism, batchesParallelism, batchSize);
335
282
  return {
336
- total: (0, ElementPropertiesHelper_1.getElementsCount)(requestOptions.imodel, elementClasses),
283
+ total: await (0, rxjs_1.firstValueFrom)(count),
337
284
  async *iterator() {
338
- for await (const batch of (0, rxjs_for_await_1.eachValueFrom)(obs)) {
339
- yield batch;
285
+ for await (const itemsBatch of (0, rxjs_for_await_1.eachValueFrom)(itemBatches)) {
286
+ const { descriptor, items } = itemsBatch;
287
+ yield items.map((item) => parser(descriptor, item));
340
288
  }
341
289
  },
342
290
  };
@@ -360,17 +308,20 @@ class PresentationManager {
360
308
  /**
361
309
  * Retrieves available selection scopes.
362
310
  * @public
311
+ * @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.
363
312
  */
313
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
364
314
  async getSelectionScopes(_requestOptions) {
365
- return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
315
+ return SelectionScopesHelper_js_1.SelectionScopesHelper.getSelectionScopes();
366
316
  }
317
+ /**
318
+ * Computes selection based on provided element IDs and selection scope.
319
+ * @public
320
+ * @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.
321
+ */
322
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
367
323
  async computeSelection(requestOptions) {
368
- return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection((0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)
369
- ? requestOptions
370
- : (function () {
371
- const { ids, scopeId, ...rest } = requestOptions;
372
- return { ...rest, elementIds: ids, scope: { id: scopeId } };
373
- })());
324
+ return SelectionScopesHelper_js_1.SelectionScopesHelper.computeSelection(requestOptions);
374
325
  }
375
326
  /**
376
327
  * Compares two hierarchies specified in the request options
@@ -382,15 +333,15 @@ class PresentationManager {
382
333
  }
383
334
  const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;
384
335
  this._detail.registerRuleset(rulesetOrId);
385
- const currRulesetId = (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId);
386
- const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
336
+ const currRulesetId = (0, PresentationManagerDetail_js_1.getRulesetIdObject)(requestOptions.rulesetOrId);
337
+ const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_js_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
387
338
  if (prevRulesetId.parts.id !== currRulesetId.parts.id) {
388
339
  throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "Can't compare rulesets with different IDs");
389
340
  }
390
341
  const currRulesetVariables = rulesetVariables ?? [];
391
342
  const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;
392
343
  const params = {
393
- requestId: NativePlatform_1.NativePlatformRequestTypes.CompareHierarchies,
344
+ requestId: NativePlatform_js_1.NativePlatformRequestTypes.CompareHierarchies,
394
345
  ...options,
395
346
  prevRulesetId: prevRulesetId.uniqueId,
396
347
  currRulesetId: currRulesetId.uniqueId,
@@ -398,9 +349,7 @@ class PresentationManager {
398
349
  currRulesetVariables: JSON.stringify(currRulesetVariables),
399
350
  expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),
400
351
  };
401
- // eslint-disable-next-line @typescript-eslint/no-deprecated
402
- const reviver = (key, value) => (key === "" ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value);
403
- return JSON.parse(await this._detail.request(params), reviver);
352
+ return JSON.parse(await this._detail.request(params));
404
353
  }
405
354
  }
406
355
  exports.PresentationManager = PresentationManager;
@@ -1 +1 @@
1
- {"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAyD;AACzD,mDAA+C;AAK/C,oEAmDoC;AACpC,uEAAqI;AACrI,qDAAwF;AACxF,2EAA4F;AAE5F,uEAAiG;AACjG,mEAAgE;AAChE,mCAAuG;AAEvG;;;;GAIG;AACH,IAAY,uBAYX;AA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,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACtD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,2CAA2C,CAAC,CAAC;QAC/G,CAAC;QAED,MAAM,oBAAoB,GAAG,gBAAgB,IAAI,EAAE,CAAC;QACpD,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,IAAI,oBAAoB,CAAC;QAE3E,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,2CAA0B,CAAC,kBAAkB;YACxD,GAAG,OAAO;YACV,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;SACjE,CAAC;QAEF,4DAA4D;QAC5D,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,0CAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzG,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;CACF;AAleD,kDAkeC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { forkJoin, from, map, mergeMap, of } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { IModelDb } from \"@itwin/core-backend\";\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n buildElementProperties,\r\n UnitSystemFormat as CommonUnitSystemFormat,\r\n ComputeSelectionRequestOptions,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentFormatter,\r\n ContentPropertyValueFormatter,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyCompareInfo,\r\n HierarchyCompareOptions,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyLevelJSON,\r\n HierarchyRequestOptions,\r\n InstanceKey,\r\n isComputeSelectionRequestOptions,\r\n isSingleElementPropertiesRequestOptions,\r\n Item,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n LocalizationHelper,\r\n MultiElementPropertiesRequestOptions,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PresentationError,\r\n PresentationStatus,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SelectionScope,\r\n SelectionScopeRequestOptions,\r\n SingleElementPropertiesRequestOptions,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport { getBatchedClassElementIds, getClassesWithInstances, getElementsCount, parseFullClassName } from \"./ElementPropertiesHelper\";\r\nimport { NativePlatformDefinition, NativePlatformRequestTypes } from \"./NativePlatform\";\r\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail\";\r\nimport { RulesetManager } from \"./RulesetManager\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\r\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper\";\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils\";\r\n\r\n/**\r\n * Presentation manager working mode.\r\n * @public\r\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\r\n */\r\nexport enum PresentationManagerMode {\r\n /**\r\n * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work\r\n * related to reacting to changes in iModels.\r\n */\r\n ReadOnly,\r\n\r\n /**\r\n * Presentation manager assumes iModels are opened in read-write mode and it may need to\r\n * react to changes. This involves some additional work and gives slightly worse performance.\r\n */\r\n ReadWrite,\r\n}\r\n\r\n/**\r\n * Presentation hierarchy cache mode.\r\n * @public\r\n */\r\nexport enum HierarchyCacheMode {\r\n /**\r\n * Hierarchy cache is created in memory.\r\n */\r\n Memory = \"memory\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\r\n * openings.\r\n */\r\n Disk = \"disk\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\r\n * and persisted in disk cache when whole hierarchy level is created.\r\n *\r\n * **Note:** This mode is still experimental.\r\n */\r\n Hybrid = \"hybrid\",\r\n}\r\n\r\n/**\r\n * Configuration for hierarchy cache.\r\n * @public\r\n */\r\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\r\n\r\n/**\r\n * Base interface for all [[HierarchyCacheConfig]] implementations.\r\n * @public\r\n */\r\nexport interface HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode;\r\n}\r\n\r\n/**\r\n * Configuration for in-memory hierarchy cache.\r\n *\r\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\r\n * @public\r\n */\r\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Memory;\r\n}\r\n\r\n/**\r\n * Configuration for persistent disk hierarchy cache.\r\n *\r\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\r\n * @public\r\n */\r\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Disk;\r\n\r\n /**\r\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\r\n *\r\n * The default directory depends on the iModel and the way it's opened.\r\n */\r\n directory?: string;\r\n\r\n /**\r\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\r\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\r\n */\r\n memoryCacheSize?: number;\r\n}\r\n\r\n/**\r\n * Configuration for the experimental hybrid hierarchy cache.\r\n *\r\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\r\n * alternative for cases when there are lots of simultaneous requests.\r\n *\r\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\r\n * @public\r\n */\r\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Hybrid;\r\n\r\n /** Configuration for disk cache used to persist hierarchies. */\r\n disk?: DiskHierarchyCacheConfig;\r\n}\r\n\r\n/**\r\n * Configuration for content cache.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n * @public\r\n */\r\nexport interface ContentCacheConfig {\r\n /**\r\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\r\n *\r\n * Defaults to `100`.\r\n */\r\n size?: number;\r\n}\r\n\r\n/**\r\n * Caching configuration options for [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationManagerCachingConfig {\r\n /**\r\n * Hierarchies-related caching options.\r\n *\r\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\r\n */\r\n hierarchies?: HierarchyCacheConfig;\r\n\r\n /**\r\n * Content-related caching options.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n */\r\n content?: ContentCacheConfig;\r\n\r\n /**\r\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\r\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\r\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\r\n * cache. Defaults to `32768000` bytes (32 MB).\r\n *\r\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\r\n */\r\n workerConnectionCacheSize?: number;\r\n}\r\n\r\n/**\r\n * A data structure that associates unit systems with a format. The associations are used for\r\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\r\n *\r\n * @public\r\n * @deprecated in 4.3. The type has been moved to `@itwin/presentation-common` package.\r\n */\r\nexport type UnitSystemFormat = CommonUnitSystemFormat;\r\n\r\n/**\r\n * Data structure for multiple element properties request response.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\r\n total: number;\r\n iterator: () => AsyncGenerator<TParsedContent[]>;\r\n}\r\n\r\n/**\r\n * Configuration options for supplying asset paths to [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationAssetsRootConfig {\r\n /**\r\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\r\n */\r\n backend: string;\r\n\r\n /**\r\n * Path to `presentation-common` assets.\r\n *\r\n * @deprecated in 3.x. This path is not used anymore\r\n */\r\n common: string;\r\n}\r\n\r\n/**\r\n * Properties that can be used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\r\n *\r\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\r\n *\r\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\r\n * - `assets/*\\*\\/*`\r\n * - `presentation-backend/{presentation-backend source files}`\r\n *\r\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\r\n *\r\n * - else, assume the backend is webpacked into a single file with assets next to it:\r\n * - `assets/*\\*\\/*`\r\n * - `{source file being executed}.js`\r\n *\r\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\r\n *\r\n * @deprecated in 4.2. This attribute is not used anymore - the package is not using private assets anymore.\r\n */\r\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\r\n\r\n /**\r\n * A list of directories containing application's presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n rulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's supplemental presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n supplementalRulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's locale-specific localized\r\n * string files (in simplified i18next v3 format)\r\n *\r\n * @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n localeDirectories?: string[];\r\n\r\n /**\r\n * Sets the active locale to use when localizing presentation-related\r\n * strings. It can later be changed through [[PresentationManager.activeLocale]].\r\n *\r\n * @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n defaultLocale?: string;\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. Default presentation units are used if this is not specified. The active unit\r\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\r\n * through request options.\r\n */\r\n defaultUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * A map of default unit formats to use for formatting properties that don't have a presentation format\r\n * in requested unit system.\r\n */\r\n defaultFormats?: FormatsMap;\r\n\r\n /**\r\n * Should schemas preloading be enabled. If true, presentation manager listens\r\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\r\n *\r\n * @deprecated in 3.x. Use [[PresentationProps.enableSchemasPreload]] instead.\r\n */\r\n enableSchemasPreload?: boolean;\r\n\r\n /**\r\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\r\n */\r\n workerThreadsCount?: number;\r\n\r\n /**\r\n * Presentation manager working mode. Backends that use iModels in read-write mode should\r\n * use `ReadWrite`, others might want to set to `ReadOnly` for better performance.\r\n *\r\n * Defaults to [[PresentationManagerMode.ReadWrite]].\r\n *\r\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\r\n */\r\n mode?: PresentationManagerMode; // eslint-disable-line @typescript-eslint/no-deprecated\r\n\r\n /**\r\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\r\n * data changes are not tracked at all.\r\n *\r\n * @beta\r\n * @deprecated in 4.4. The manager now always tracks for iModel data changes without polling.\r\n */\r\n updatesPollInterval?: number;\r\n\r\n /** Options for caching. */\r\n caching?: PresentationManagerCachingConfig;\r\n\r\n /**\r\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\r\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\r\n *\r\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\r\n */\r\n useMmap?: boolean | number;\r\n\r\n /**\r\n * An identifier which helps separate multiple presentation managers. It's\r\n * mostly useful in tests where multiple presentation managers can co-exist\r\n * and try to share the same resources, which we don't want. With this identifier\r\n * set, managers put their resources into id-named subdirectories.\r\n *\r\n * @internal\r\n */\r\n id?: string;\r\n\r\n /** @internal */\r\n addon?: NativePlatformDefinition;\r\n\r\n /**\r\n * Localization function to localize data returned by presentation manager when it's used directly on the backend (as opposed to when used through RPC, where\r\n * data is localized on the frontend). Defaults to English localization.\r\n *\r\n * @see [Localization]($docs/presentation/advanced/Localization)\r\n */\r\n getLocalizedString?: (key: string) => string;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n */\r\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\r\n\r\n /**\r\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\r\n * made through the manager.\r\n *\r\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\r\n */\r\n diagnostics?: BackendDiagnosticsOptions;\r\n}\r\n\r\n/**\r\n * Backend Presentation manager which pulls the presentation data from\r\n * an iModel using native platform.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager {\r\n private _props: PresentationManagerProps;\r\n private _detail: PresentationManagerDetail;\r\n private _localizationHelper: LocalizationHelper;\r\n\r\n /**\r\n * Get / set active locale used for localizing presentation data\r\n * @deprecated in 3.x. Use [[PresentationManagerProps.getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n public activeLocale: string | undefined;\r\n\r\n /**\r\n * Creates an instance of PresentationManager.\r\n * @param props Optional configuration properties.\r\n */\r\n constructor(props?: PresentationManagerProps) {\r\n this._props = props ?? {};\r\n this._detail = new PresentationManagerDetail(this._props);\r\n this.activeLocale = this._props.defaultLocale; // eslint-disable-line @typescript-eslint/no-deprecated\r\n\r\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\r\n }\r\n\r\n /** Get / set active unit system used to format property values with units */\r\n public get activeUnitSystem(): UnitSystemKey | undefined {\r\n return this._detail.activeUnitSystem;\r\n }\r\n // istanbul ignore next\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._detail.activeUnitSystem = value;\r\n }\r\n\r\n /** Dispose the presentation manager. Must be called to clean up native resources. */\r\n public dispose() {\r\n this._detail.dispose();\r\n }\r\n\r\n /** @internal */\r\n public setOnManagerUsedHandler(handler: () => void) {\r\n this._detail.setOnManagerUsedHandler(handler);\r\n }\r\n\r\n /** Properties used to initialize the manager */\r\n public get props() {\r\n return this._props;\r\n }\r\n\r\n /** Get rulesets manager */\r\n public rulesets(): RulesetManager {\r\n return this._detail.rulesets;\r\n }\r\n\r\n /**\r\n * Get ruleset variables manager for specific ruleset\r\n * @param rulesetId Id of the ruleset to get variables manager for\r\n */\r\n public vars(rulesetId: string): RulesetVariablesManager {\r\n return new RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);\r\n }\r\n\r\n /** @internal */\r\n public getNativePlatform = (): NativePlatformDefinition => {\r\n return this._detail.getNativePlatform();\r\n };\r\n\r\n /** @internal */\r\n // istanbul ignore next\r\n public getDetail(): PresentationManagerDetail {\r\n return this._detail;\r\n }\r\n\r\n /** @internal */\r\n public getRulesetId(rulesetOrId: Ruleset | string) {\r\n return this._detail.getRulesetId(rulesetOrId);\r\n }\r\n\r\n /**\r\n * Retrieves nodes\r\n * @public\r\n */\r\n public async getNodes(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Node[]> {\r\n const serializedNodesJson = await this._detail.getNodes(requestOptions);\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const nodesJson = JSON.parse(serializedNodesJson) as HierarchyLevelJSON;\r\n const nodes = Node.listFromJSON(nodesJson.nodes);\r\n return this._localizationHelper.getLocalizedNodes(nodes);\r\n }\r\n\r\n /**\r\n * Retrieves nodes count\r\n * @public\r\n */\r\n public async getNodesCount(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getNodesCount(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor\r\n * @public\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getNodesDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\r\n * TODO: Return results in pages\r\n * @public\r\n */\r\n public async getNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to nodes containing filter text in their label.\r\n * TODO: Return results in pages\r\n * @public\r\n */\r\n public async getFilteredNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getFilteredNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\r\n * its related instances for loading related and navigation properties.\r\n * @public\r\n */\r\n public async getContentSources(\r\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<SelectClassInfo[]> {\r\n return this._detail.getContentSources(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content descriptor which can be used to get content\r\n * @public\r\n */\r\n public async getContentDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getContentDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the content set size based on the supplied content descriptor override\r\n * @public\r\n */\r\n public async getContentSetSize(\r\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getContentSetSize(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content set based on the supplied content descriptor.\r\n * @public\r\n */\r\n public async getContentSet(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Item[]> {\r\n let items = await this._detail.getContentSet({\r\n ...requestOptions,\r\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\r\n const formatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\r\n );\r\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContentItems(items);\r\n }\r\n\r\n /**\r\n * Retrieves the content based on the supplied content descriptor override.\r\n * @public\r\n */\r\n public async getContent(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<Content | undefined> {\r\n const content = await this._detail.getContent({\r\n ...requestOptions,\r\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n if (!content) {\r\n return undefined;\r\n }\r\n\r\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\r\n const formatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\r\n );\r\n await formatter.formatContent(content);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContent(content);\r\n }\r\n\r\n /**\r\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\r\n * @param requestOptions Options for the request\r\n * @return A promise object that returns either distinct values on success or an error string on error.\r\n * @public\r\n */\r\n public async getPagedDistinctValues(\r\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<PagedResponse<DisplayValueGroup>> {\r\n const result = await this._detail.getPagedDistinctValues(requestOptions);\r\n return {\r\n ...result,\r\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves property data in a simplified format for a single element specified by ID.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined>;\r\n /**\r\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\r\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<\r\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\r\n > &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\r\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\r\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n\r\n private async getSingleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const content = await this.getContent({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!content || content.contentSet.length === 0) {\r\n return undefined;\r\n }\r\n return parser(content.descriptor, content.contentSet[0]);\r\n }\r\n\r\n private async getMultipleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementClasses, contentParser, batchSize, ...contentOptions } = requestOptions;\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\r\n\r\n // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory\r\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\r\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\r\n // most `workerThreadsCount / 2` classes in parallel.\r\n // istanbul ignore next\r\n const classParallelism = workerThreadsCount > 1 ? workerThreadsCount / 2 : 1;\r\n\r\n // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,\r\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\r\n // To avoid that, we keep twice as much requests active.\r\n // istanbul ignore next\r\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount * 2 : 2;\r\n\r\n const createClassContentRuleset = (fullClassName: string): Ruleset => {\r\n const [schemaName, className] = parseFullClassName(fullClassName);\r\n return {\r\n id: `content/${fullClassName}`,\r\n rules: [\r\n {\r\n ruleType: \"Content\",\r\n specifications: [\r\n {\r\n specType: \"ContentInstancesOfSpecificClasses\",\r\n classes: {\r\n schemaName,\r\n classNames: [className],\r\n arePolymorphic: false,\r\n },\r\n handlePropertiesPolymorphically: true,\r\n },\r\n ],\r\n },\r\n ],\r\n };\r\n };\r\n const getContentDescriptor = async (ruleset: Ruleset): Promise<Descriptor> => {\r\n return (await this.getContentDescriptor({\r\n ...contentOptions,\r\n rulesetOrId: ruleset,\r\n displayType: DefaultContentDisplayTypes.Grid,\r\n contentFlags: ContentFlags.ShowLabels,\r\n keys: new KeySet(),\r\n }))!;\r\n };\r\n\r\n const obs = getClassesWithInstances(requestOptions.imodel, elementClasses ?? /* istanbul ignore next */ [\"BisCore.Element\"]).pipe(\r\n map((classFullName) => ({\r\n classFullName,\r\n ruleset: createClassContentRuleset(classFullName),\r\n })),\r\n mergeMap(\r\n ({ classFullName, ruleset }) =>\r\n // use forkJoin to query descriptor and element ids in parallel\r\n forkJoin({\r\n classFullName: of(classFullName),\r\n ruleset: of(ruleset),\r\n descriptor: from(getContentDescriptor(ruleset)),\r\n batches: from(getBatchedClassElementIds(requestOptions.imodel, classFullName, batchSize ?? /* istanbul ignore next */ 1000)),\r\n }).pipe(\r\n // split incoming stream into individual batch requests\r\n mergeMap(({ descriptor, batches }) => from(batches.map((batch) => ({ classFullName, descriptor, batch })))),\r\n // request content for each batch, filter by IDs for performance\r\n mergeMap(({ descriptor, batch }) => {\r\n const filteringDescriptor = new Descriptor(descriptor);\r\n filteringDescriptor.instanceFilter = {\r\n selectClassName: classFullName,\r\n expression: `this.ECInstanceId >= ${Number.parseInt(batch.from, 16)} AND this.ECInstanceId <= ${Number.parseInt(batch.to, 16)}`,\r\n };\r\n return from(\r\n this.getContentSet({\r\n ...contentOptions,\r\n keys: new KeySet(),\r\n descriptor: filteringDescriptor,\r\n rulesetOrId: ruleset,\r\n }),\r\n ).pipe(map((items) => ({ classFullName, descriptor, items })));\r\n }, batchesParallelism),\r\n ),\r\n classParallelism,\r\n ),\r\n map(({ descriptor, items }) => items.map((item) => parser(descriptor, item))),\r\n );\r\n\r\n return {\r\n total: getElementsCount(requestOptions.imodel, elementClasses),\r\n async *iterator() {\r\n for await (const batch of eachValueFrom(obs)) {\r\n yield batch;\r\n }\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves display label definition of specific item\r\n * @public\r\n */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\r\n }\r\n\r\n /**\r\n * Retrieves display label definitions of specific items\r\n * @public\r\n */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition[]> {\r\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\r\n }\r\n\r\n /**\r\n * Retrieves available selection scopes.\r\n * @public\r\n */\r\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\r\n return SelectionScopesHelper.getSelectionScopes();\r\n }\r\n\r\n /**\r\n * Computes selection set based on provided selection scope.\r\n * @public\r\n * @deprecated in 3.x. Use overload with `ComputeSelectionRequestOptions` parameter.\r\n */\r\n public async computeSelection(\r\n requestOptions: SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[]; scopeId: string } & BackendDiagnosticsAttribute,\r\n ): Promise<KeySet>;\r\n /**\r\n * Computes selection based on provided element IDs and selection scope.\r\n * @public\r\n */\r\n // eslint-disable-next-line @typescript-eslint/unified-signatures\r\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet>;\r\n public async computeSelection(\r\n requestOptions: ((SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[]; scopeId: string }) | ComputeSelectionRequestOptions<IModelDb>) &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<KeySet> {\r\n return SelectionScopesHelper.computeSelection(\r\n isComputeSelectionRequestOptions(requestOptions)\r\n ? requestOptions\r\n : (function () {\r\n const { ids, scopeId, ...rest } = requestOptions;\r\n return { ...rest, elementIds: ids, scope: { id: scopeId } };\r\n })(),\r\n );\r\n }\r\n\r\n /**\r\n * Compares two hierarchies specified in the request options\r\n * @public\r\n */\r\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\r\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\r\n return { changes: [] };\r\n }\r\n\r\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\r\n this._detail.registerRuleset(rulesetOrId);\r\n\r\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\r\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\r\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\r\n }\r\n\r\n const currRulesetVariables = rulesetVariables ?? [];\r\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\r\n\r\n const params = {\r\n requestId: NativePlatformRequestTypes.CompareHierarchies,\r\n ...options,\r\n prevRulesetId: prevRulesetId.uniqueId,\r\n currRulesetId: currRulesetId.uniqueId,\r\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\r\n currRulesetVariables: JSON.stringify(currRulesetVariables),\r\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const reviver = (key: string, value: any) => (key === \"\" ? HierarchyCompareInfo.fromJSON(value) : value);\r\n return JSON.parse(await this._detail.request(params), reviver);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAsC;AACtC,mDAA+C;AAK/C,oEA6CoC;AACpC,kEAO6C;AAC7C,6EAAgI;AAChI,2DAAiE;AACjE,iFAA+F;AAE/F,6EAAoG;AACpG,yEAAmE;AACnE,yCAA0G;AAC1G,6DAAoE;AAEpE;;;GAGG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,uCAAiB,CAAA;IACjB;;;OAGG;IACH,mCAAa,CAAA;IACb;;;;;OAKG;IACH,uCAAiB,CAAA;AACnB,CAAC,EAjBW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AI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;SACjE,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AA5aD,kDA4aC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { firstValueFrom } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { IModelDb } from \"@itwin/core-backend\";\r\nimport { BeEvent, Id64Array } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n UnitSystemFormat as CommonUnitSystemFormat,\r\n ComputeSelectionRequestOptions,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyCompareInfo,\r\n HierarchyCompareOptions,\r\n HierarchyLevel,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyRequestOptions,\r\n InstanceKey,\r\n Item,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n MultiElementPropertiesRequestOptions,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PresentationError,\r\n PresentationStatus,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SelectionScope,\r\n SelectionScopeRequestOptions,\r\n SingleElementPropertiesRequestOptions,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport {\r\n buildElementProperties,\r\n ContentFormatter,\r\n ContentPropertyValueFormatter,\r\n deepReplaceNullsToUndefined,\r\n isSingleElementPropertiesRequestOptions,\r\n LocalizationHelper,\r\n} from \"@itwin/presentation-common/internal\";\r\nimport { getContentItemsObservableFromClassNames, getContentItemsObservableFromElementIds } from \"./ElementPropertiesHelper.js\";\r\nimport { NativePlatformRequestTypes } from \"./NativePlatform.js\";\r\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail.js\";\r\nimport { RulesetManager } from \"./RulesetManager.js\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager.js\";\r\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper.js\";\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils.js\";\r\nimport { _presentation_manager_detail } from \"./InternalSymbols.js\";\r\n\r\n/**\r\n * Presentation hierarchy cache mode.\r\n * @public\r\n */\r\nexport enum HierarchyCacheMode {\r\n /**\r\n * Hierarchy cache is created in memory.\r\n */\r\n Memory = \"memory\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\r\n * openings.\r\n */\r\n Disk = \"disk\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\r\n * and persisted in disk cache when whole hierarchy level is created.\r\n *\r\n * **Note:** This mode is still experimental.\r\n */\r\n Hybrid = \"hybrid\",\r\n}\r\n\r\n/**\r\n * Configuration for hierarchy cache.\r\n * @public\r\n */\r\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\r\n\r\n/**\r\n * Base interface for all [[HierarchyCacheConfig]] implementations.\r\n * @public\r\n */\r\nexport interface HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode;\r\n}\r\n\r\n/**\r\n * Configuration for in-memory hierarchy cache.\r\n *\r\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\r\n * @public\r\n */\r\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Memory;\r\n}\r\n\r\n/**\r\n * Configuration for persistent disk hierarchy cache.\r\n *\r\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\r\n * @public\r\n */\r\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Disk;\r\n\r\n /**\r\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\r\n *\r\n * The default directory depends on the iModel and the way it's opened.\r\n */\r\n directory?: string;\r\n\r\n /**\r\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\r\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\r\n */\r\n memoryCacheSize?: number;\r\n}\r\n\r\n/**\r\n * Configuration for the experimental hybrid hierarchy cache.\r\n *\r\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\r\n * alternative for cases when there are lots of simultaneous requests.\r\n *\r\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\r\n * @public\r\n */\r\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Hybrid;\r\n\r\n /** Configuration for disk cache used to persist hierarchies. */\r\n disk?: DiskHierarchyCacheConfig;\r\n}\r\n\r\n/**\r\n * Configuration for content cache.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n * @public\r\n */\r\nexport interface ContentCacheConfig {\r\n /**\r\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\r\n *\r\n * Defaults to `100`.\r\n */\r\n size?: number;\r\n}\r\n\r\n/**\r\n * Caching configuration options for [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationManagerCachingConfig {\r\n /**\r\n * Hierarchies-related caching options.\r\n *\r\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\r\n */\r\n hierarchies?: HierarchyCacheConfig;\r\n\r\n /**\r\n * Content-related caching options.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n */\r\n content?: ContentCacheConfig;\r\n\r\n /**\r\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\r\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\r\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\r\n * cache. Defaults to `32768000` bytes (32 MB).\r\n *\r\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\r\n */\r\n workerConnectionCacheSize?: number;\r\n}\r\n\r\n/**\r\n * A data structure that associates unit systems with a format. The associations are used for\r\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\r\n *\r\n * @public\r\n * @deprecated in 4.3. The type has been moved to `@itwin/presentation-common` package.\r\n */\r\nexport type UnitSystemFormat = CommonUnitSystemFormat;\r\n\r\n/**\r\n * Data structure for multiple element properties request response.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\r\n total: number;\r\n iterator: () => AsyncGenerator<TParsedContent[]>;\r\n}\r\n\r\n/**\r\n * Configuration options for supplying asset paths to [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationAssetsRootConfig {\r\n /**\r\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\r\n */\r\n backend: string;\r\n}\r\n\r\n/**\r\n * Properties that can be used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\r\n *\r\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\r\n *\r\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\r\n * - `assets/*\\*\\/*`\r\n * - `presentation-backend/{presentation-backend source files}`\r\n *\r\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\r\n *\r\n * - else, assume the backend is webpacked into a single file with assets next to it:\r\n * - `assets/*\\*\\/*`\r\n * - `{source file being executed}.js`\r\n *\r\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\r\n *\r\n * @deprecated in 4.2. This attribute is not used anymore - the package is not using private assets anymore.\r\n */\r\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\r\n\r\n /**\r\n * A list of directories containing application's presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n rulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's supplemental presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n supplementalRulesetDirectories?: string[];\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. Default presentation units are used if this is not specified. The active unit\r\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\r\n * through request options.\r\n */\r\n defaultUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * A map of default unit formats to use for formatting properties that don't have a presentation format\r\n * in requested unit system.\r\n */\r\n defaultFormats?: FormatsMap;\r\n\r\n /**\r\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\r\n */\r\n workerThreadsCount?: number;\r\n\r\n /**\r\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\r\n * data changes are not tracked at all.\r\n *\r\n * @beta\r\n * @deprecated in 4.4. The manager now always tracks for iModel data changes without polling.\r\n */\r\n updatesPollInterval?: number;\r\n\r\n /** Options for caching. */\r\n caching?: PresentationManagerCachingConfig;\r\n\r\n /**\r\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\r\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\r\n *\r\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\r\n */\r\n useMmap?: boolean | number;\r\n\r\n /**\r\n * Localization function to localize data returned by presentation manager when it's used directly on the backend (as opposed to when used through RPC, where\r\n * data is localized on the frontend). Defaults to English localization.\r\n *\r\n * @see [Localization]($docs/presentation/advanced/Localization)\r\n */\r\n getLocalizedString?: (key: string) => string;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n */\r\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\r\n\r\n /**\r\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\r\n * made through the manager.\r\n *\r\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\r\n */\r\n diagnostics?: BackendDiagnosticsOptions;\r\n}\r\n\r\n/**\r\n * Backend Presentation manager which pulls the presentation data from\r\n * an iModel using native platform.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager {\r\n private _props: PresentationManagerProps;\r\n private _detail: PresentationManagerDetail;\r\n private _localizationHelper: LocalizationHelper;\r\n\r\n /**\r\n * Creates an instance of PresentationManager.\r\n * @param props Optional configuration properties.\r\n */\r\n constructor(props?: PresentationManagerProps) {\r\n this._props = props ?? {};\r\n this._detail = new PresentationManagerDetail(this._props);\r\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\r\n }\r\n\r\n /** Get / set active unit system used to format property values with units */\r\n public get activeUnitSystem(): UnitSystemKey | undefined {\r\n return this._detail.activeUnitSystem;\r\n }\r\n /* c8 ignore next 3 */\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._detail.activeUnitSystem = value;\r\n }\r\n\r\n /** Dispose the presentation manager. Must be called to clean up native resources. */\r\n public [Symbol.dispose]() {\r\n this._detail[Symbol.dispose]();\r\n }\r\n\r\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\r\n /* c8 ignore next 3 */\r\n public dispose() {\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** An event, that this manager raises whenever any request is made on it. */\r\n public get onUsed(): BeEvent<() => void> {\r\n return this._detail.onUsed;\r\n }\r\n\r\n /** Properties used to initialize the manager */\r\n public get props() {\r\n return this._props;\r\n }\r\n\r\n /** Get rulesets manager */\r\n public rulesets(): RulesetManager {\r\n return this._detail.rulesets;\r\n }\r\n\r\n /**\r\n * Get ruleset variables manager for specific ruleset\r\n * @param rulesetId Id of the ruleset to get variables manager for\r\n */\r\n public vars(rulesetId: string): RulesetVariablesManager {\r\n return new RulesetVariablesManagerImpl(() => this._detail.getNativePlatform(), rulesetId);\r\n }\r\n\r\n /** @internal */\r\n /* c8 ignore next 3 */\r\n public get [_presentation_manager_detail](): PresentationManagerDetail {\r\n return this._detail;\r\n }\r\n\r\n public getRulesetId(rulesetOrId: Ruleset | string) {\r\n return this._detail.getRulesetId(rulesetOrId);\r\n }\r\n\r\n /**\r\n * Retrieves nodes\r\n * @public\r\n */\r\n public async getNodes(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Node[]> {\r\n const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);\r\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\r\n return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);\r\n }\r\n\r\n /**\r\n * Retrieves nodes count\r\n * @public\r\n */\r\n public async getNodesCount(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getNodesCount(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor\r\n * @public\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getNodesDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\r\n * TODO: Return results in pages\r\n * @public\r\n */\r\n public async getNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to nodes containing filter text in their label.\r\n * TODO: Return results in pages\r\n * @public\r\n */\r\n public async getFilteredNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getFilteredNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\r\n * its related instances for loading related and navigation properties.\r\n * @public\r\n */\r\n public async getContentSources(\r\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<SelectClassInfo[]> {\r\n return this._detail.getContentSources(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content descriptor which can be used to get content\r\n * @public\r\n */\r\n public async getContentDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getContentDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the content set size based on the supplied content descriptor override\r\n * @public\r\n */\r\n public async getContentSetSize(\r\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getContentSetSize(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content set based on the supplied content descriptor.\r\n * @public\r\n */\r\n public async getContentSet(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Item[]> {\r\n let items = await this._detail.getContentSet({\r\n ...requestOptions,\r\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\r\n const formatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\r\n );\r\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContentItems(items);\r\n }\r\n\r\n /**\r\n * Retrieves the content based on the supplied content descriptor override.\r\n * @public\r\n */\r\n public async getContent(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<Content | undefined> {\r\n const content = await this._detail.getContent({\r\n ...requestOptions,\r\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n if (!content) {\r\n return undefined;\r\n }\r\n\r\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\r\n const formatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\r\n );\r\n await formatter.formatContent(content);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContent(content);\r\n }\r\n\r\n /**\r\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\r\n * @param requestOptions Options for the request\r\n * @return A promise object that returns either distinct values on success or an error string on error.\r\n * @public\r\n */\r\n public async getPagedDistinctValues(\r\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<PagedResponse<DisplayValueGroup>> {\r\n const result = await this._detail.getPagedDistinctValues(requestOptions);\r\n return {\r\n ...result,\r\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves property data in a simplified format for a single element specified by ID.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined>;\r\n /**\r\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\r\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<\r\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\r\n > &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\r\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\r\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n\r\n private async getSingleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const content = await this.getContent({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!content || content.contentSet.length === 0) {\r\n return undefined;\r\n }\r\n return parser(content.descriptor, content.contentSet[0]);\r\n }\r\n\r\n private async getMultipleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { contentParser, batchSize: batchSizeOption, ...contentOptions } = requestOptions;\r\n\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\r\n\r\n // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory\r\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\r\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\r\n // most `workerThreadsCount / 2` classes in parallel.\r\n /* c8 ignore next */\r\n const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;\r\n\r\n // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,\r\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\r\n // To avoid that, we keep twice as much requests active.\r\n /* c8 ignore next */\r\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;\r\n\r\n /* c8 ignore next */\r\n const batchSize = batchSizeOption ?? 100;\r\n\r\n const elementsIdentifier = ((): { elementIds: Id64Array } | { elementClasses: string[] } => {\r\n if (\"elementIds\" in contentOptions && contentOptions.elementIds !== undefined) {\r\n const elementIds = contentOptions.elementIds;\r\n delete contentOptions.elementIds;\r\n return { elementIds };\r\n }\r\n if (\"elementClasses\" in contentOptions && contentOptions.elementClasses !== undefined) {\r\n const elementClasses = contentOptions.elementClasses;\r\n delete contentOptions.elementClasses;\r\n return { elementClasses };\r\n }\r\n /* c8 ignore next */\r\n return { elementClasses: [\"BisCore:Element\"] };\r\n })();\r\n\r\n const descriptorGetter = async (partialProps: Pick<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\">) =>\r\n this.getContentDescriptor({ ...contentOptions, displayType: DefaultContentDisplayTypes.Grid, contentFlags: ContentFlags.ShowLabels, ...partialProps });\r\n const contentSetGetter = async (\r\n partialProps: Pick<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\" | \"descriptor\">,\r\n ) => this.getContentSet({ ...contentOptions, ...partialProps });\r\n const { itemBatches, count } =\r\n \"elementIds\" in elementsIdentifier\r\n ? getContentItemsObservableFromElementIds(\r\n requestOptions.imodel,\r\n descriptorGetter,\r\n contentSetGetter,\r\n elementsIdentifier.elementIds,\r\n classParallelism,\r\n batchesParallelism,\r\n batchSize,\r\n )\r\n : getContentItemsObservableFromClassNames(\r\n requestOptions.imodel,\r\n descriptorGetter,\r\n contentSetGetter,\r\n elementsIdentifier.elementClasses,\r\n classParallelism,\r\n batchesParallelism,\r\n batchSize,\r\n );\r\n return {\r\n total: await firstValueFrom(count),\r\n async *iterator() {\r\n for await (const itemsBatch of eachValueFrom(itemBatches)) {\r\n const { descriptor, items } = itemsBatch;\r\n yield items.map((item) => parser(descriptor, item));\r\n }\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves display label definition of specific item\r\n * @public\r\n */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\r\n }\r\n\r\n /**\r\n * Retrieves display label definitions of specific items\r\n * @public\r\n */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition[]> {\r\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\r\n }\r\n\r\n /**\r\n * Retrieves available selection scopes.\r\n * @public\r\n * @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\r\n return SelectionScopesHelper.getSelectionScopes();\r\n }\r\n\r\n /**\r\n * Computes selection based on provided element IDs and selection scope.\r\n * @public\r\n * @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet> {\r\n return SelectionScopesHelper.computeSelection(requestOptions);\r\n }\r\n\r\n /**\r\n * Compares two hierarchies specified in the request options\r\n * @public\r\n */\r\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\r\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\r\n return { changes: [] };\r\n }\r\n\r\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\r\n this._detail.registerRuleset(rulesetOrId);\r\n\r\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\r\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\r\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\r\n }\r\n\r\n const currRulesetVariables = rulesetVariables ?? [];\r\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\r\n\r\n const params = {\r\n requestId: NativePlatformRequestTypes.CompareHierarchies,\r\n ...options,\r\n prevRulesetId: prevRulesetId.uniqueId,\r\n currRulesetId: currRulesetId.uniqueId,\r\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\r\n currRulesetVariables: JSON.stringify(currRulesetVariables),\r\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\r\n };\r\n return JSON.parse(await this._detail.request(params));\r\n }\r\n}\r\n"]}
@@ -1,23 +1,32 @@
1
1
  import { IModelDb } from "@itwin/core-backend";
2
- import { BeEvent, IDisposable } from "@itwin/core-bentley";
2
+ import { BeEvent } from "@itwin/core-bentley";
3
3
  import { UnitSystemKey } from "@itwin/core-quantity";
4
4
  import { Content, ContentDescriptorRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions, InstanceKey, Item, KeySet, LabelDefinition, NodeKey, NodePathElement, Paged, PagedResponse, Prioritized, Ruleset, RulesetVariable, SelectClassInfo, UpdateInfo, WithCancelEvent } from "@itwin/presentation-common";
5
- import { NativePlatformDefinition, NativePresentationKeySetJSON } from "./NativePlatform";
6
- import { PresentationManagerProps } from "./PresentationManager";
7
- import { RulesetManager } from "./RulesetManager";
8
- import { BackendDiagnosticsAttribute, BackendDiagnosticsOptions } from "./Utils";
5
+ import { NativePlatformDefinition, NativePresentationKeySetJSON } from "./NativePlatform.js";
6
+ import { PresentationManagerProps } from "./PresentationManager.js";
7
+ import { RulesetManager } from "./RulesetManager.js";
8
+ import { BackendDiagnosticsAttribute, BackendDiagnosticsOptions } from "./Utils.js";
9
+ /**
10
+ * Produce content descriptor that is not intended for querying content. Allows the implementation to omit certain
11
+ * operations to make obtaining content descriptor faster.
12
+ * @internal
13
+ */
14
+ export declare const DESCRIPTOR_ONLY_CONTENT_FLAG: number;
15
+ interface PresentationManagerDetailProps extends PresentationManagerProps {
16
+ id?: string;
17
+ addon?: NativePlatformDefinition;
18
+ }
9
19
  /** @internal */
10
- export declare class PresentationManagerDetail implements IDisposable {
20
+ export declare class PresentationManagerDetail implements Disposable {
11
21
  private _disposed;
12
22
  private _nativePlatform;
13
- private _onManagerUsed;
14
23
  private _diagnosticsOptions;
15
24
  rulesets: RulesetManager;
16
25
  activeUnitSystem: UnitSystemKey | undefined;
17
- constructor(params: PresentationManagerProps);
18
- dispose(): void;
26
+ readonly onUsed: BeEvent<() => void>;
27
+ constructor(params: PresentationManagerDetailProps);
28
+ [Symbol.dispose](): void;
19
29
  getNativePlatform(): NativePlatformDefinition;
20
- setOnManagerUsedHandler(handler: () => void): void;
21
30
  getNodes(requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute): Promise<string>;
22
31
  getNodesCount(requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<number>;
23
32
  getNodesDescriptor(requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<string>;