@itwin/presentation-frontend 4.5.0-dev.16 → 4.5.0-dev.17
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.
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +2 -2
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +7 -4
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +79 -71
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +33 -4
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +76 -16
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteRules.json +172 -172
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +2 -2
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +7 -4
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +79 -71
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +33 -4
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +76 -16
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteRules.json +172 -172
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +15 -15
|
@@ -58,7 +58,6 @@ export class PresentationManager {
|
|
|
58
58
|
this._rulesetVars = new Map();
|
|
59
59
|
this._rulesets = RulesetManagerImpl.create();
|
|
60
60
|
this._localizationHelper = new FrontendLocalizationHelper(props?.activeLocale);
|
|
61
|
-
this._connections = new Map();
|
|
62
61
|
this._schemaContextProvider = props?.schemaContextProvider;
|
|
63
62
|
this._defaultFormats = props?.defaultFormats;
|
|
64
63
|
if (IpcApp.isValid) {
|
|
@@ -80,18 +79,6 @@ export class PresentationManager {
|
|
|
80
79
|
this._clearEventListener = undefined;
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
|
-
async onConnection(imodel) {
|
|
84
|
-
if (!this._connections.has(imodel)) {
|
|
85
|
-
this._connections.set(imodel, this.initializeIModel(imodel));
|
|
86
|
-
}
|
|
87
|
-
await this._connections.get(imodel);
|
|
88
|
-
}
|
|
89
|
-
async initializeIModel(imodel) {
|
|
90
|
-
imodel.onClose.addOnce(() => {
|
|
91
|
-
this._connections.delete(imodel);
|
|
92
|
-
});
|
|
93
|
-
await this.onNewiModelConnection(imodel);
|
|
94
|
-
}
|
|
95
82
|
/** @note This is only called in native apps after changes in iModels */
|
|
96
83
|
async handleUpdateAsync(report) {
|
|
97
84
|
for (const imodelKey in report) {
|
|
@@ -119,7 +106,13 @@ export class PresentationManager {
|
|
|
119
106
|
* Function that is called when a new IModelConnection is used to retrieve data.
|
|
120
107
|
* @internal
|
|
121
108
|
*/
|
|
122
|
-
|
|
109
|
+
startIModelInitialization(_) { }
|
|
110
|
+
/**
|
|
111
|
+
* Function that should be called to finish initialization that was started at [[PresentationManager.startIModelInitialization]].
|
|
112
|
+
* Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed.
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
async ensureIModelInitialized(_) { }
|
|
123
116
|
/**
|
|
124
117
|
* Create a new PresentationManager instance
|
|
125
118
|
* @param props Optional properties used to configure the manager
|
|
@@ -198,7 +191,7 @@ export class PresentationManager {
|
|
|
198
191
|
}
|
|
199
192
|
/** Retrieves nodes */
|
|
200
193
|
async getNodes(requestOptions) {
|
|
201
|
-
|
|
194
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
202
195
|
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
203
196
|
const rpcOptions = this.toRpcTokenOptions({ ...options });
|
|
204
197
|
const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));
|
|
@@ -207,14 +200,14 @@ export class PresentationManager {
|
|
|
207
200
|
}
|
|
208
201
|
/** Retrieves nodes count. */
|
|
209
202
|
async getNodesCount(requestOptions) {
|
|
210
|
-
|
|
203
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
211
204
|
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
212
205
|
const rpcOptions = this.toRpcTokenOptions({ ...options });
|
|
213
206
|
return this._requestsHandler.getNodesCount(rpcOptions);
|
|
214
207
|
}
|
|
215
208
|
/** Retrieves total nodes count and a single page of nodes. */
|
|
216
209
|
async getNodesAndCount(requestOptions) {
|
|
217
|
-
|
|
210
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
218
211
|
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
219
212
|
const rpcOptions = this.toRpcTokenOptions({ ...options });
|
|
220
213
|
const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));
|
|
@@ -229,16 +222,21 @@ export class PresentationManager {
|
|
|
229
222
|
* @beta
|
|
230
223
|
*/
|
|
231
224
|
async getNodesDescriptor(requestOptions) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
225
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
226
|
+
try {
|
|
227
|
+
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
228
|
+
const rpcOptions = this.toRpcTokenOptions({ ...options });
|
|
229
|
+
const result = await this._requestsHandler.getNodesDescriptor(rpcOptions);
|
|
230
|
+
const descriptor = Descriptor.fromJSON(result);
|
|
231
|
+
return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;
|
|
232
|
+
}
|
|
233
|
+
finally {
|
|
234
|
+
await this.ensureIModelInitialized(requestOptions.imodel);
|
|
235
|
+
}
|
|
238
236
|
}
|
|
239
237
|
/** Retrieves paths from root nodes to children nodes according to specified keys. Intersecting paths will be merged. */
|
|
240
238
|
async getNodePaths(requestOptions) {
|
|
241
|
-
|
|
239
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
242
240
|
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
243
241
|
const rpcOptions = this.toRpcTokenOptions({ ...options });
|
|
244
242
|
const result = await this._requestsHandler.getNodePaths(rpcOptions);
|
|
@@ -247,7 +245,7 @@ export class PresentationManager {
|
|
|
247
245
|
}
|
|
248
246
|
/** Retrieves paths from root nodes to nodes containing filter text in their label. */
|
|
249
247
|
async getFilteredNodePaths(requestOptions) {
|
|
250
|
-
|
|
248
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
251
249
|
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
252
250
|
const result = await this._requestsHandler.getFilteredNodePaths(this.toRpcTokenOptions(options));
|
|
253
251
|
// eslint-disable-next-line deprecation/deprecation
|
|
@@ -259,26 +257,31 @@ export class PresentationManager {
|
|
|
259
257
|
* @public
|
|
260
258
|
*/
|
|
261
259
|
async getContentSources(requestOptions) {
|
|
262
|
-
|
|
260
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
263
261
|
const rpcOptions = this.toRpcTokenOptions(requestOptions);
|
|
264
262
|
const result = await this._requestsHandler.getContentSources(rpcOptions);
|
|
265
263
|
return SelectClassInfo.listFromCompressedJSON(result.sources, result.classesMap);
|
|
266
264
|
}
|
|
267
265
|
/** Retrieves the content descriptor which describes the content and can be used to customize it. */
|
|
268
266
|
async getContentDescriptor(requestOptions) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
267
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
268
|
+
try {
|
|
269
|
+
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
270
|
+
const rpcOptions = this.toRpcTokenOptions({
|
|
271
|
+
...options,
|
|
272
|
+
keys: stripTransientElementKeys(options.keys).toJSON(),
|
|
273
|
+
});
|
|
274
|
+
const result = await this._requestsHandler.getContentDescriptor(rpcOptions);
|
|
275
|
+
const descriptor = Descriptor.fromJSON(result);
|
|
276
|
+
return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;
|
|
277
|
+
}
|
|
278
|
+
finally {
|
|
279
|
+
await this.ensureIModelInitialized(requestOptions.imodel);
|
|
280
|
+
}
|
|
278
281
|
}
|
|
279
282
|
/** Retrieves overall content set size. */
|
|
280
283
|
async getContentSetSize(requestOptions) {
|
|
281
|
-
|
|
284
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
282
285
|
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
283
286
|
const rpcOptions = this.toRpcTokenOptions({
|
|
284
287
|
...options,
|
|
@@ -293,44 +296,49 @@ export class PresentationManager {
|
|
|
293
296
|
}
|
|
294
297
|
/** Retrieves content set size and content which consists of a content descriptor and a page of records. */
|
|
295
298
|
async getContentAndSize(requestOptions) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
299
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
300
|
+
try {
|
|
301
|
+
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
302
|
+
const rpcOptions = this.toRpcTokenOptions({
|
|
303
|
+
...options,
|
|
304
|
+
descriptor: getDescriptorOverrides(requestOptions.descriptor),
|
|
305
|
+
keys: stripTransientElementKeys(requestOptions.keys).toJSON(),
|
|
306
|
+
...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),
|
|
307
|
+
});
|
|
308
|
+
let descriptor = requestOptions.descriptor instanceof Descriptor ? requestOptions.descriptor : undefined;
|
|
309
|
+
const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions, requestIndex) => {
|
|
310
|
+
if (0 === requestIndex && !descriptor) {
|
|
311
|
+
const content = await this._requestsHandler.getPagedContent({ ...rpcOptions, paging: partialPageOptions });
|
|
312
|
+
if (content) {
|
|
313
|
+
descriptor = Descriptor.fromJSON(content.descriptor);
|
|
314
|
+
return content.contentSet;
|
|
315
|
+
}
|
|
316
|
+
return { total: 0, items: [] };
|
|
311
317
|
}
|
|
312
|
-
return {
|
|
318
|
+
return this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging: partialPageOptions });
|
|
319
|
+
});
|
|
320
|
+
if (!descriptor) {
|
|
321
|
+
return undefined;
|
|
313
322
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
323
|
+
const items = result.items.map((itemJson) => Item.fromJSON(itemJson)).filter((item) => item !== undefined);
|
|
324
|
+
const resultContent = new Content(descriptor, items);
|
|
325
|
+
if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {
|
|
326
|
+
const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);
|
|
327
|
+
const contentFormatter = new ContentFormatter(new ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem);
|
|
328
|
+
await contentFormatter.formatContent(resultContent);
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
size: result.total,
|
|
332
|
+
content: this._localizationHelper.getLocalizedContent(resultContent),
|
|
333
|
+
};
|
|
318
334
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {
|
|
322
|
-
const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);
|
|
323
|
-
const contentFormatter = new ContentFormatter(new ContentPropertyValueFormatter(koqPropertyFormatter), requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem);
|
|
324
|
-
await contentFormatter.formatContent(resultContent);
|
|
335
|
+
finally {
|
|
336
|
+
await this.ensureIModelInitialized(requestOptions.imodel);
|
|
325
337
|
}
|
|
326
|
-
return {
|
|
327
|
-
size: result.total,
|
|
328
|
-
content: this._localizationHelper.getLocalizedContent(resultContent),
|
|
329
|
-
};
|
|
330
338
|
}
|
|
331
339
|
/** Retrieves distinct values of specific field from the content. */
|
|
332
340
|
async getPagedDistinctValues(requestOptions) {
|
|
333
|
-
|
|
341
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
334
342
|
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
335
343
|
const rpcOptions = {
|
|
336
344
|
...this.toRpcTokenOptions(options),
|
|
@@ -349,7 +357,7 @@ export class PresentationManager {
|
|
|
349
357
|
* @public
|
|
350
358
|
*/
|
|
351
359
|
async getElementProperties(requestOptions) {
|
|
352
|
-
|
|
360
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
353
361
|
const results = await this._requestsHandler.getElementProperties(this.toRpcTokenOptions(requestOptions));
|
|
354
362
|
// istanbul ignore if
|
|
355
363
|
if (!results) {
|
|
@@ -362,7 +370,7 @@ export class PresentationManager {
|
|
|
362
370
|
* @public
|
|
363
371
|
*/
|
|
364
372
|
async getContentInstanceKeys(requestOptions) {
|
|
365
|
-
|
|
373
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
366
374
|
const options = await this.addRulesetAndVariablesToOptions(requestOptions);
|
|
367
375
|
const rpcOptions = {
|
|
368
376
|
...this.toRpcTokenOptions(options),
|
|
@@ -387,14 +395,14 @@ export class PresentationManager {
|
|
|
387
395
|
}
|
|
388
396
|
/** Retrieves display label definition of specific item. */
|
|
389
397
|
async getDisplayLabelDefinition(requestOptions) {
|
|
390
|
-
|
|
398
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
391
399
|
const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });
|
|
392
400
|
const result = await this._requestsHandler.getDisplayLabelDefinition(rpcOptions);
|
|
393
401
|
return this._localizationHelper.getLocalizedLabelDefinition(result);
|
|
394
402
|
}
|
|
395
403
|
/** Retrieves display label definition of specific items. */
|
|
396
404
|
async getDisplayLabelDefinitions(requestOptions) {
|
|
397
|
-
|
|
405
|
+
this.startIModelInitialization(requestOptions.imodel);
|
|
398
406
|
const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });
|
|
399
407
|
const result = await buildPagedArrayResponse(undefined, async (partialPageOptions) => {
|
|
400
408
|
const partialKeys = !partialPageOptions.start ? rpcOptions.keys : rpcOptions.keys.slice(partialPageOptions.start);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/PresentationManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAe,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,SA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ClF,4EAA4E;QAC5E,uBAAuB;QACvB,MAAM,WAAW,GACf,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,2BAA2B,CAAC;YACzE,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,aAAa,KAAK,2BAA2B,CAAC,CAAC;QAChF,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","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 { BeEvent, CompressedId64Set, IDisposable, OrderedId64Iterable } from \"@itwin/core-bentley\";\r\nimport { IModelApp, IModelConnection, IpcApp } from \"@itwin/core-frontend\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n ClientDiagnosticsAttribute,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFormatter,\r\n ContentInstanceKeysRequestOptions,\r\n ContentPropertyValueFormatter,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n ContentUpdateInfo,\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 HierarchyLevelDescriptorRequestOptions,\r\n HierarchyRequestOptions,\r\n HierarchyUpdateInfo,\r\n InstanceKey,\r\n Item,\r\n Key,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PageOptions,\r\n PresentationIpcEvents,\r\n RpcRequestsHandler,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SingleElementPropertiesRequestOptions,\r\n UpdateInfo,\r\n VariableValueTypes,\r\n} from \"@itwin/presentation-common\";\r\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\r\nimport { FrontendLocalizationHelper } from \"./LocalizationHelper\";\r\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\r\nimport { TRANSIENT_ELEMENT_CLASSNAME } from \"./selection/SelectionManager\";\r\n\r\n/**\r\n * Data structure that describes IModel hierarchy change event arguments.\r\n * @alpha\r\n */\r\nexport interface IModelHierarchyChangeEventArgs {\r\n /** Id of ruleset that was used to create hierarchy. */\r\n rulesetId: string;\r\n /** Hierarchy changes info. */\r\n updateInfo: HierarchyUpdateInfo;\r\n /** Key of iModel that was used to create hierarchy. It matches [[IModelConnection.key]] property. */\r\n imodelKey: string;\r\n}\r\n\r\n/**\r\n * Data structure that describes iModel content change event arguments.\r\n * @alpha\r\n */\r\nexport interface IModelContentChangeEventArgs {\r\n /** Id of ruleset that was used to create content. */\r\n rulesetId: string;\r\n /** Content changes info. */\r\n updateInfo: ContentUpdateInfo;\r\n /** Key of iModel that was used to create content. It matches [[IModelConnection.key]] property. */\r\n imodelKey: string;\r\n}\r\n\r\n/**\r\n * Properties used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Sets the active locale to use when localizing presentation-related\r\n * strings. It can later be changed through [[PresentationManager]].\r\n */\r\n activeLocale?: string;\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. The value can later be changed through [[PresentationManager.activeUnitSystem]] setter or\r\n * overriden for each request through request parameters. If not set, `IModelApp.quantityFormatter.activeUnitSystem`\r\n * is used by default.\r\n *\r\n * @deprecated in 4.0. Use [IModelApp.quantityFormatter]($core-frontend) to set the active unit system.\r\n */\r\n activeUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * ID used to identify client that requests data. Generally, clients should\r\n * store this ID in their local storage so the ID can be reused across\r\n * sessions - this allows reusing some caches.\r\n *\r\n * Defaults to a unique GUID as a client id.\r\n */\r\n clientId?: string;\r\n\r\n /**\r\n * Timeout (in milliseconds) for how long we're going to wait for RPC request to be fulfilled before throwing\r\n * a timeout error.\r\n *\r\n * Defaults to 10 minutes.\r\n */\r\n requestTimeout?: number;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelConnection]($core-frontend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n * @alpha\r\n */\r\n schemaContextProvider?: (imodel: IModelConnection) => SchemaContext;\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 * @note Only has effect when frontend value formatting is enabled by supplying the `schemaContextProvider` prop.\r\n * @alpha\r\n */\r\n defaultFormats?: FormatsMap;\r\n\r\n /** @internal */\r\n rpcRequestsHandler?: RpcRequestsHandler;\r\n\r\n /** @internal */\r\n ipcRequestsHandler?: IpcRequestsHandler;\r\n}\r\n\r\n/**\r\n * Frontend Presentation manager which basically just forwards all calls to\r\n * the backend implementation.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager implements IDisposable {\r\n private _requestsHandler: RpcRequestsHandler;\r\n private _rulesets: RulesetManager;\r\n private _localizationHelper: FrontendLocalizationHelper;\r\n private _explicitActiveUnitSystem: UnitSystemKey | undefined;\r\n private _rulesetVars: Map<string, RulesetVariablesManager>;\r\n private _clearEventListener?: () => void;\r\n private _connections: Map<IModelConnection, Promise<void>>;\r\n private _schemaContextProvider?: (imodel: IModelConnection) => SchemaContext;\r\n private _defaultFormats?: FormatsMap;\r\n private _ipcRequestsHandler?: IpcRequestsHandler;\r\n\r\n /**\r\n * An event raised when hierarchies created using specific ruleset change\r\n * @alpha\r\n */\r\n public onIModelHierarchyChanged = new BeEvent<(args: IModelHierarchyChangeEventArgs) => void>();\r\n\r\n /**\r\n * An event raised when content created using specific ruleset changes\r\n * @alpha\r\n */\r\n public onIModelContentChanged = new BeEvent<(args: IModelContentChangeEventArgs) => void>();\r\n\r\n /**\r\n * Get / set active unit system used to format property values with units.\r\n *\r\n * @deprecated in 4.0. `IModelApp.quantityFormatter` should be used to get/set the active unit system. At the moment\r\n * [[PresentationManager]] allows overriding it, but returns `IModelApp.quantityFormatter.activeUnitSystem` if override\r\n * is not set.\r\n */\r\n public get activeUnitSystem(): UnitSystemKey {\r\n return this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem;\r\n }\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._explicitActiveUnitSystem = value;\r\n }\r\n\r\n private constructor(props?: PresentationManagerProps) {\r\n if (props) {\r\n // eslint-disable-next-line deprecation/deprecation\r\n this._explicitActiveUnitSystem = props.activeUnitSystem;\r\n }\r\n\r\n this._requestsHandler =\r\n props?.rpcRequestsHandler ?? new RpcRequestsHandler(props ? { clientId: props.clientId, timeout: props.requestTimeout } : undefined);\r\n this._rulesetVars = new Map<string, RulesetVariablesManager>();\r\n this._rulesets = RulesetManagerImpl.create();\r\n this._localizationHelper = new FrontendLocalizationHelper(props?.activeLocale);\r\n this._connections = new Map<IModelConnection, Promise<void>>();\r\n this._schemaContextProvider = props?.schemaContextProvider;\r\n this._defaultFormats = props?.defaultFormats;\r\n\r\n if (IpcApp.isValid) {\r\n // Ipc only works in ipc apps, so the `onUpdate` callback will only be called there.\r\n this._clearEventListener = IpcApp.addListener(PresentationIpcEvents.Update, this.onUpdate);\r\n this._ipcRequestsHandler = props?.ipcRequestsHandler ?? new IpcRequestsHandler(this._requestsHandler.clientId);\r\n }\r\n }\r\n\r\n /** Get / set active locale used for localizing presentation data */\r\n public get activeLocale(): string | undefined {\r\n return this._localizationHelper.locale;\r\n }\r\n public set activeLocale(locale: string | undefined) {\r\n this._localizationHelper.locale = locale;\r\n }\r\n\r\n public dispose() {\r\n if (this._clearEventListener) {\r\n this._clearEventListener();\r\n this._clearEventListener = undefined;\r\n }\r\n }\r\n\r\n private async onConnection(imodel: IModelConnection) {\r\n if (!this._connections.has(imodel)) {\r\n this._connections.set(imodel, this.initializeIModel(imodel));\r\n }\r\n await this._connections.get(imodel);\r\n }\r\n\r\n private async initializeIModel(imodel: IModelConnection) {\r\n imodel.onClose.addOnce(() => {\r\n this._connections.delete(imodel);\r\n });\r\n await this.onNewiModelConnection(imodel);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onUpdate = (_evt: Event, report: UpdateInfo) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.handleUpdateAsync(report);\r\n };\r\n\r\n /** @note This is only called in native apps after changes in iModels */\r\n private async handleUpdateAsync(report: UpdateInfo) {\r\n for (const imodelKey in report) {\r\n // istanbul ignore if\r\n if (!report.hasOwnProperty(imodelKey)) {\r\n continue;\r\n }\r\n\r\n const imodelReport = report[imodelKey];\r\n for (const rulesetId in imodelReport) {\r\n // istanbul ignore if\r\n if (!imodelReport.hasOwnProperty(rulesetId)) {\r\n continue;\r\n }\r\n\r\n const updateInfo = imodelReport[rulesetId];\r\n if (updateInfo.content) {\r\n this.onIModelContentChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.content, imodelKey });\r\n }\r\n if (updateInfo.hierarchy) {\r\n this.onIModelHierarchyChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.hierarchy, imodelKey });\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Function that is called when a new IModelConnection is used to retrieve data.\r\n * @internal\r\n */\r\n public async onNewiModelConnection(_: IModelConnection) {}\r\n\r\n /**\r\n * Create a new PresentationManager instance\r\n * @param props Optional properties used to configure the manager\r\n */\r\n public static create(props?: PresentationManagerProps) {\r\n return new PresentationManager(props);\r\n }\r\n\r\n /** @internal */\r\n public get rpcRequestsHandler() {\r\n return this._requestsHandler;\r\n }\r\n\r\n /** @internal */\r\n public get ipcRequestsHandler() {\r\n return this._ipcRequestsHandler;\r\n }\r\n\r\n /**\r\n * Get rulesets manager\r\n */\r\n public rulesets() {\r\n return this._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 the vars manager for\r\n */\r\n public vars(rulesetId: string) {\r\n if (!this._rulesetVars.has(rulesetId)) {\r\n const varsManager = new RulesetVariablesManagerImpl(rulesetId, this._ipcRequestsHandler);\r\n this._rulesetVars.set(rulesetId, varsManager);\r\n }\r\n return this._rulesetVars.get(rulesetId)!;\r\n }\r\n\r\n private toRpcTokenOptions<TOptions extends { imodel: IModelConnection; locale?: string; unitSystem?: UnitSystemKey; rulesetVariables?: RulesetVariable[] }>(\r\n requestOptions: TOptions,\r\n ) {\r\n // 1. put default `locale` and `unitSystem`\r\n // 2. put all `requestOptions` members (if `locale` or `unitSystem` are set, they'll override the defaults put at #1)\r\n // 3. put `imodel` of type `IModelRpcProps` which overwrites the `imodel` from `requestOptions` put at #2\r\n const defaultOptions: Pick<TOptions, \"locale\" | \"unitSystem\"> = {};\r\n if (this.activeLocale) {\r\n defaultOptions.locale = this.activeLocale;\r\n }\r\n defaultOptions.unitSystem = this.activeUnitSystem; // eslint-disable-line deprecation/deprecation\r\n\r\n const { imodel, rulesetVariables, ...rpcRequestOptions } = requestOptions;\r\n return {\r\n ...defaultOptions,\r\n ...rpcRequestOptions,\r\n ...(rulesetVariables ? { rulesetVariables: rulesetVariables.map(RulesetVariable.toJSON) } : {}),\r\n imodel: imodel.getRpcProps(),\r\n };\r\n }\r\n\r\n private async addRulesetAndVariablesToOptions<TOptions extends { rulesetOrId: Ruleset | string; rulesetVariables?: RulesetVariable[] }>(options: TOptions) {\r\n const { rulesetOrId, rulesetVariables } = options;\r\n let foundRulesetOrId: Ruleset | string;\r\n if (typeof rulesetOrId === \"object\") {\r\n foundRulesetOrId = rulesetOrId;\r\n } else {\r\n const foundRuleset = await this._rulesets.get(rulesetOrId);\r\n foundRulesetOrId = foundRuleset ? foundRuleset.toJSON() : rulesetOrId;\r\n }\r\n const rulesetId = typeof foundRulesetOrId === \"object\" ? foundRulesetOrId.id : foundRulesetOrId;\r\n\r\n // All Id64Array variable values must be sorted for serialization to JSON to work. RulesetVariablesManager\r\n // sorts them before storing, so that part is taken care of, but we need to ensure that variables coming from\r\n // request options are also sorted.\r\n const variables = (rulesetVariables ?? []).map((variable) => {\r\n if (variable.type === VariableValueTypes.Id64Array) {\r\n return { ...variable, value: OrderedId64Iterable.sortArray(variable.value) };\r\n }\r\n return variable;\r\n });\r\n if (!this._ipcRequestsHandler) {\r\n // only need to add variables from variables manager if there's no IPC\r\n // handler - if there is one, the variables are already known by the backend\r\n variables.push(...this.vars(rulesetId).getAllVariables());\r\n }\r\n\r\n return { ...options, rulesetOrId: foundRulesetOrId, rulesetVariables: variables };\r\n }\r\n\r\n /** Retrieves nodes */\r\n public async getNodes(\r\n requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute,\r\n ): Promise<Node[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) =>\r\n this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }),\r\n );\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON));\r\n }\r\n\r\n /** Retrieves nodes count. */\r\n public async getNodesCount(\r\n requestOptions: HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<number> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n return this._requestsHandler.getNodesCount(rpcOptions);\r\n }\r\n\r\n /** Retrieves total nodes count and a single page of nodes. */\r\n public async getNodesAndCount(\r\n requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute,\r\n ): Promise<{ count: number; nodes: Node[] }> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) =>\r\n this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }),\r\n );\r\n return {\r\n count: result.total,\r\n // eslint-disable-next-line deprecation/deprecation\r\n nodes: this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON)),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor.\r\n * @beta\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: HierarchyLevelDescriptorRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await this._requestsHandler.getNodesDescriptor(rpcOptions);\r\n const descriptor = Descriptor.fromJSON(result);\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /** Retrieves paths from root nodes to children nodes according to specified keys. Intersecting paths will be merged. */\r\n public async getNodePaths(\r\n requestOptions: FilterByInstancePathsHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await this._requestsHandler.getNodePaths(rpcOptions);\r\n // eslint-disable-next-line deprecation/deprecation\r\n return result.map(NodePathElement.fromJSON).map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /** Retrieves paths from root nodes to nodes containing filter text in their label. */\r\n public async getFilteredNodePaths(\r\n requestOptions: FilterByTextHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const result = await this._requestsHandler.getFilteredNodePaths(this.toRpcTokenOptions(options));\r\n // eslint-disable-next-line deprecation/deprecation\r\n return result.map(NodePathElement.fromJSON).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(requestOptions: ContentSourcesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute): Promise<SelectClassInfo[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions(requestOptions);\r\n const result = await this._requestsHandler.getContentSources(rpcOptions);\r\n return SelectClassInfo.listFromCompressedJSON(result.sources, result.classesMap);\r\n }\r\n\r\n /** Retrieves the content descriptor which describes the content and can be used to customize it. */\r\n public async getContentDescriptor(\r\n requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n });\r\n const result = await this._requestsHandler.getContentDescriptor(rpcOptions);\r\n const descriptor = Descriptor.fromJSON(result);\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /** Retrieves overall content set size. */\r\n public async getContentSetSize(\r\n requestOptions: ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<number> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n descriptor: getDescriptorOverrides(requestOptions.descriptor),\r\n keys: stripTransientElementKeys(requestOptions.keys).toJSON(),\r\n });\r\n return this._requestsHandler.getContentSetSize(rpcOptions);\r\n }\r\n\r\n /** Retrieves content which consists of a content descriptor and a page of records. */\r\n public async getContent(\r\n requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute,\r\n ): Promise<Content | undefined> {\r\n return (await this.getContentAndSize(requestOptions))?.content;\r\n }\r\n\r\n /** Retrieves content set size and content which consists of a content descriptor and a page of records. */\r\n public async getContentAndSize(\r\n requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute,\r\n ): Promise<{ content: Content; size: number } | undefined> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n descriptor: getDescriptorOverrides(requestOptions.descriptor),\r\n keys: stripTransientElementKeys(requestOptions.keys).toJSON(),\r\n ...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n let descriptor = requestOptions.descriptor instanceof Descriptor ? requestOptions.descriptor : undefined;\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions, requestIndex) => {\r\n if (0 === requestIndex && !descriptor) {\r\n const content = await this._requestsHandler.getPagedContent({ ...rpcOptions, paging: partialPageOptions });\r\n if (content) {\r\n descriptor = Descriptor.fromJSON(content.descriptor);\r\n return content.contentSet;\r\n }\r\n return { total: 0, items: [] };\r\n }\r\n return this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging: partialPageOptions });\r\n });\r\n if (!descriptor) {\r\n return undefined;\r\n }\r\n\r\n const items = result.items.map((itemJson) => Item.fromJSON(itemJson)).filter<Item>((item): item is Item => item !== undefined);\r\n const resultContent = new Content(descriptor, items);\r\n if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);\r\n const contentFormatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem,\r\n );\r\n await contentFormatter.formatContent(resultContent);\r\n }\r\n\r\n return {\r\n size: result.total,\r\n content: this._localizationHelper.getLocalizedContent(resultContent),\r\n };\r\n }\r\n\r\n /** Retrieves distinct values of specific field from the content. */\r\n public async getPagedDistinctValues(\r\n requestOptions: DistinctValuesRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<PagedResponse<DisplayValueGroup>> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = {\r\n ...this.toRpcTokenOptions(options),\r\n descriptor: getDescriptorOverrides(options.descriptor),\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n };\r\n const result = await buildPagedArrayResponse(requestOptions.paging, async (partialPageOptions) =>\r\n this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging: partialPageOptions }),\r\n );\r\n return {\r\n ...result,\r\n // eslint-disable-next-line deprecation/deprecation\r\n items: result.items.map(DisplayValueGroup.fromJSON).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(\r\n requestOptions: SingleElementPropertiesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute,\r\n ): Promise<ElementProperties | undefined> {\r\n await this.onConnection(requestOptions.imodel);\r\n const results = await this._requestsHandler.getElementProperties(this.toRpcTokenOptions(requestOptions));\r\n // istanbul ignore if\r\n if (!results) {\r\n return undefined;\r\n }\r\n return this._localizationHelper.getLocalizedElementProperties(results);\r\n }\r\n\r\n /**\r\n * Retrieves content item instance keys.\r\n * @public\r\n */\r\n public async getContentInstanceKeys(\r\n requestOptions: ContentInstanceKeysRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<{ total: number; items: () => AsyncGenerator<InstanceKey> }> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = {\r\n ...this.toRpcTokenOptions(options),\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n };\r\n\r\n const props = {\r\n page: requestOptions.paging,\r\n get: async (page: Required<PageOptions>) => {\r\n const keys = await this._requestsHandler.getContentInstanceKeys({ ...rpcOptions, paging: page });\r\n return {\r\n total: keys.total,\r\n items: keys.items.instanceKeys.reduce((instanceKeys, entry) => {\r\n for (const id of CompressedId64Set.iterable(entry[1])) {\r\n instanceKeys.push({ className: entry[0], id });\r\n }\r\n return instanceKeys;\r\n }, new Array<InstanceKey>()),\r\n };\r\n },\r\n };\r\n return createPagedGeneratorResponse(props);\r\n }\r\n\r\n /** Retrieves display label definition of specific item. */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: DisplayLabelRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n await this.onConnection(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\r\n const result = await this._requestsHandler.getDisplayLabelDefinition(rpcOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(result);\r\n }\r\n\r\n /** Retrieves display label definition of specific items. */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute,\r\n ): Promise<LabelDefinition[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\r\n const result = await buildPagedArrayResponse(undefined, async (partialPageOptions) => {\r\n const partialKeys = !partialPageOptions.start ? rpcOptions.keys : rpcOptions.keys.slice(partialPageOptions.start);\r\n return this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });\r\n });\r\n return this._localizationHelper.getLocalizedLabelDefinitions(result.items);\r\n }\r\n}\r\n\r\nconst getDescriptorOverrides = (descriptorOrOverrides: Descriptor | DescriptorOverrides): DescriptorOverrides => {\r\n if (descriptorOrOverrides instanceof Descriptor) {\r\n return descriptorOrOverrides.createDescriptorOverrides();\r\n }\r\n return descriptorOrOverrides;\r\n};\r\n\r\ninterface PagedGeneratorCreateProps<TPagedResponseItem> {\r\n page: PageOptions | undefined;\r\n get: (pageStart: Required<PageOptions>, requestIndex: number) => Promise<{ total: number; items: TPagedResponseItem[] }>;\r\n}\r\nasync function createPagedGeneratorResponse<TPagedResponseItem>(props: PagedGeneratorCreateProps<TPagedResponseItem>) {\r\n let pageStart = props.page?.start ?? 0;\r\n let pageSize = props.page?.size ?? 0;\r\n let requestIndex = 0;\r\n\r\n const firstPage = await props.get({ start: pageStart, size: pageSize }, requestIndex++);\r\n return {\r\n total: firstPage.total,\r\n async *items() {\r\n let partialResult = firstPage;\r\n while (true) {\r\n for (const item of partialResult.items) {\r\n yield item;\r\n }\r\n\r\n const receivedItemsCount = partialResult.items.length;\r\n if (partialResult.total !== 0 && receivedItemsCount === 0) {\r\n if (pageStart >= partialResult.total) {\r\n throw new Error(`Requested page with start index ${pageStart} is out of bounds. Total number of items: ${partialResult.total}`);\r\n }\r\n throw new Error(\"Paged request returned non zero total count but no items\");\r\n }\r\n\r\n if ((pageSize !== 0 && receivedItemsCount >= pageSize) || receivedItemsCount >= partialResult.total - pageStart) {\r\n break;\r\n }\r\n\r\n if (pageSize !== 0) {\r\n pageSize -= receivedItemsCount;\r\n }\r\n pageStart += receivedItemsCount;\r\n\r\n partialResult = await props.get({ start: pageStart, size: pageSize }, requestIndex++);\r\n }\r\n },\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport const buildPagedArrayResponse = async <TItem>(\r\n requestedPage: PageOptions | undefined,\r\n getter: (page: Required<PageOptions>, requestIndex: number) => Promise<PagedResponse<TItem>>,\r\n): Promise<PagedResponse<TItem>> => {\r\n const items = new Array<TItem>();\r\n const gen = await createPagedGeneratorResponse({ page: requestedPage, get: getter });\r\n for await (const item of gen.items()) {\r\n items.push(item);\r\n }\r\n return { total: gen.total, items };\r\n};\r\n\r\nconst stripTransientElementKeys = (keys: KeySet) => {\r\n if (!keys.some((key) => Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME)) {\r\n return keys;\r\n }\r\n\r\n const copy = new KeySet();\r\n copy.add(keys, (key) => {\r\n // the callback is not going to be called with EntityProps as KeySet converts them\r\n // to InstanceKeys, but we want to keep the EntityProps case for correctness\r\n // istanbul ignore next\r\n const isTransient =\r\n (Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME) ||\r\n (Key.isEntityProps(key) && key.classFullName === TRANSIENT_ELEMENT_CLASSNAME);\r\n return !isTransient;\r\n });\r\n return copy;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/PresentationManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAe,mBAAmB,EAAE,MAAM,qBAAqB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CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { BeEvent, CompressedId64Set, IDisposable, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { IModelApp, IModelConnection, IpcApp } from \"@itwin/core-frontend\";\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport {\n ClientDiagnosticsAttribute,\n Content,\n ContentDescriptorRequestOptions,\n ContentFormatter,\n ContentInstanceKeysRequestOptions,\n ContentPropertyValueFormatter,\n ContentRequestOptions,\n ContentSourcesRequestOptions,\n ContentUpdateInfo,\n Descriptor,\n DescriptorOverrides,\n DisplayLabelRequestOptions,\n DisplayLabelsRequestOptions,\n DisplayValueGroup,\n DistinctValuesRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRequestOptions,\n FilterByTextHierarchyRequestOptions,\n FormatsMap,\n HierarchyLevelDescriptorRequestOptions,\n HierarchyRequestOptions,\n HierarchyUpdateInfo,\n InstanceKey,\n Item,\n Key,\n KeySet,\n KoqPropertyValueFormatter,\n LabelDefinition,\n Node,\n NodeKey,\n NodePathElement,\n Paged,\n PagedResponse,\n PageOptions,\n PresentationIpcEvents,\n RpcRequestsHandler,\n Ruleset,\n RulesetVariable,\n SelectClassInfo,\n SingleElementPropertiesRequestOptions,\n UpdateInfo,\n VariableValueTypes,\n} from \"@itwin/presentation-common\";\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\nimport { FrontendLocalizationHelper } from \"./LocalizationHelper\";\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager\";\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\nimport { TRANSIENT_ELEMENT_CLASSNAME } from \"./selection/SelectionManager\";\n\n/**\n * Data structure that describes IModel hierarchy change event arguments.\n * @alpha\n */\nexport interface IModelHierarchyChangeEventArgs {\n /** Id of ruleset that was used to create hierarchy. */\n rulesetId: string;\n /** Hierarchy changes info. */\n updateInfo: HierarchyUpdateInfo;\n /** Key of iModel that was used to create hierarchy. It matches [[IModelConnection.key]] property. */\n imodelKey: string;\n}\n\n/**\n * Data structure that describes iModel content change event arguments.\n * @alpha\n */\nexport interface IModelContentChangeEventArgs {\n /** Id of ruleset that was used to create content. */\n rulesetId: string;\n /** Content changes info. */\n updateInfo: ContentUpdateInfo;\n /** Key of iModel that was used to create content. It matches [[IModelConnection.key]] property. */\n imodelKey: string;\n}\n\n/**\n * Properties used to configure [[PresentationManager]]\n * @public\n */\nexport interface PresentationManagerProps {\n /**\n * Sets the active locale to use when localizing presentation-related\n * strings. It can later be changed through [[PresentationManager]].\n */\n activeLocale?: string;\n\n /**\n * Sets the active unit system to use for formatting property values with\n * units. The value can later be changed through [[PresentationManager.activeUnitSystem]] setter or\n * overriden for each request through request parameters. If not set, `IModelApp.quantityFormatter.activeUnitSystem`\n * is used by default.\n *\n * @deprecated in 4.0. Use [IModelApp.quantityFormatter]($core-frontend) to set the active unit system.\n */\n activeUnitSystem?: UnitSystemKey;\n\n /**\n * ID used to identify client that requests data. Generally, clients should\n * store this ID in their local storage so the ID can be reused across\n * sessions - this allows reusing some caches.\n *\n * Defaults to a unique GUID as a client id.\n */\n clientId?: string;\n\n /**\n * Timeout (in milliseconds) for how long we're going to wait for RPC request to be fulfilled before throwing\n * a timeout error.\n *\n * Defaults to 10 minutes.\n */\n requestTimeout?: number;\n\n /**\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelConnection]($core-frontend).\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\n * @alpha\n */\n schemaContextProvider?: (imodel: IModelConnection) => SchemaContext;\n\n /**\n * A map of default unit formats to use for formatting properties that don't have a presentation format\n * in requested unit system.\n *\n * @note Only has effect when frontend value formatting is enabled by supplying the `schemaContextProvider` prop.\n * @alpha\n */\n defaultFormats?: FormatsMap;\n\n /** @internal */\n rpcRequestsHandler?: RpcRequestsHandler;\n\n /** @internal */\n ipcRequestsHandler?: IpcRequestsHandler;\n}\n\n/**\n * Frontend Presentation manager which basically just forwards all calls to\n * the backend implementation.\n *\n * @public\n */\nexport class PresentationManager implements IDisposable {\n private _requestsHandler: RpcRequestsHandler;\n private _rulesets: RulesetManager;\n private _localizationHelper: FrontendLocalizationHelper;\n private _explicitActiveUnitSystem: UnitSystemKey | undefined;\n private _rulesetVars: Map<string, RulesetVariablesManager>;\n private _clearEventListener?: () => void;\n private _schemaContextProvider?: (imodel: IModelConnection) => SchemaContext;\n private _defaultFormats?: FormatsMap;\n private _ipcRequestsHandler?: IpcRequestsHandler;\n\n /**\n * An event raised when hierarchies created using specific ruleset change\n * @alpha\n */\n public onIModelHierarchyChanged = new BeEvent<(args: IModelHierarchyChangeEventArgs) => void>();\n\n /**\n * An event raised when content created using specific ruleset changes\n * @alpha\n */\n public onIModelContentChanged = new BeEvent<(args: IModelContentChangeEventArgs) => void>();\n\n /**\n * Get / set active unit system used to format property values with units.\n *\n * @deprecated in 4.0. `IModelApp.quantityFormatter` should be used to get/set the active unit system. At the moment\n * [[PresentationManager]] allows overriding it, but returns `IModelApp.quantityFormatter.activeUnitSystem` if override\n * is not set.\n */\n public get activeUnitSystem(): UnitSystemKey {\n return this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem;\n }\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\n this._explicitActiveUnitSystem = value;\n }\n\n private constructor(props?: PresentationManagerProps) {\n if (props) {\n // eslint-disable-next-line deprecation/deprecation\n this._explicitActiveUnitSystem = props.activeUnitSystem;\n }\n\n this._requestsHandler =\n props?.rpcRequestsHandler ?? new RpcRequestsHandler(props ? { clientId: props.clientId, timeout: props.requestTimeout } : undefined);\n this._rulesetVars = new Map<string, RulesetVariablesManager>();\n this._rulesets = RulesetManagerImpl.create();\n this._localizationHelper = new FrontendLocalizationHelper(props?.activeLocale);\n this._schemaContextProvider = props?.schemaContextProvider;\n this._defaultFormats = props?.defaultFormats;\n\n if (IpcApp.isValid) {\n // Ipc only works in ipc apps, so the `onUpdate` callback will only be called there.\n this._clearEventListener = IpcApp.addListener(PresentationIpcEvents.Update, this.onUpdate);\n this._ipcRequestsHandler = props?.ipcRequestsHandler ?? new IpcRequestsHandler(this._requestsHandler.clientId);\n }\n }\n\n /** Get / set active locale used for localizing presentation data */\n public get activeLocale(): string | undefined {\n return this._localizationHelper.locale;\n }\n public set activeLocale(locale: string | undefined) {\n this._localizationHelper.locale = locale;\n }\n\n public dispose() {\n if (this._clearEventListener) {\n this._clearEventListener();\n this._clearEventListener = undefined;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onUpdate = (_evt: Event, report: UpdateInfo) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.handleUpdateAsync(report);\n };\n\n /** @note This is only called in native apps after changes in iModels */\n private async handleUpdateAsync(report: UpdateInfo) {\n for (const imodelKey in report) {\n // istanbul ignore if\n if (!report.hasOwnProperty(imodelKey)) {\n continue;\n }\n\n const imodelReport = report[imodelKey];\n for (const rulesetId in imodelReport) {\n // istanbul ignore if\n if (!imodelReport.hasOwnProperty(rulesetId)) {\n continue;\n }\n\n const updateInfo = imodelReport[rulesetId];\n if (updateInfo.content) {\n this.onIModelContentChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.content, imodelKey });\n }\n if (updateInfo.hierarchy) {\n this.onIModelHierarchyChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.hierarchy, imodelKey });\n }\n }\n }\n }\n\n /**\n * Function that is called when a new IModelConnection is used to retrieve data.\n * @internal\n */\n public startIModelInitialization(_: IModelConnection) {}\n\n /**\n * Function that should be called to finish initialization that was started at [[PresentationManager.startIModelInitialization]].\n * Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed.\n * @internal\n */\n public async ensureIModelInitialized(_: IModelConnection) {}\n\n /**\n * Create a new PresentationManager instance\n * @param props Optional properties used to configure the manager\n */\n public static create(props?: PresentationManagerProps) {\n return new PresentationManager(props);\n }\n\n /** @internal */\n public get rpcRequestsHandler() {\n return this._requestsHandler;\n }\n\n /** @internal */\n public get ipcRequestsHandler() {\n return this._ipcRequestsHandler;\n }\n\n /**\n * Get rulesets manager\n */\n public rulesets() {\n return this._rulesets;\n }\n\n /**\n * Get ruleset variables manager for specific ruleset\n * @param rulesetId Id of the ruleset to get the vars manager for\n */\n public vars(rulesetId: string) {\n if (!this._rulesetVars.has(rulesetId)) {\n const varsManager = new RulesetVariablesManagerImpl(rulesetId, this._ipcRequestsHandler);\n this._rulesetVars.set(rulesetId, varsManager);\n }\n return this._rulesetVars.get(rulesetId)!;\n }\n\n private toRpcTokenOptions<TOptions extends { imodel: IModelConnection; locale?: string; unitSystem?: UnitSystemKey; rulesetVariables?: RulesetVariable[] }>(\n requestOptions: TOptions,\n ) {\n // 1. put default `locale` and `unitSystem`\n // 2. put all `requestOptions` members (if `locale` or `unitSystem` are set, they'll override the defaults put at #1)\n // 3. put `imodel` of type `IModelRpcProps` which overwrites the `imodel` from `requestOptions` put at #2\n const defaultOptions: Pick<TOptions, \"locale\" | \"unitSystem\"> = {};\n if (this.activeLocale) {\n defaultOptions.locale = this.activeLocale;\n }\n defaultOptions.unitSystem = this.activeUnitSystem; // eslint-disable-line deprecation/deprecation\n\n const { imodel, rulesetVariables, ...rpcRequestOptions } = requestOptions;\n return {\n ...defaultOptions,\n ...rpcRequestOptions,\n ...(rulesetVariables ? { rulesetVariables: rulesetVariables.map(RulesetVariable.toJSON) } : {}),\n imodel: imodel.getRpcProps(),\n };\n }\n\n private async addRulesetAndVariablesToOptions<TOptions extends { rulesetOrId: Ruleset | string; rulesetVariables?: RulesetVariable[] }>(options: TOptions) {\n const { rulesetOrId, rulesetVariables } = options;\n let foundRulesetOrId: Ruleset | string;\n if (typeof rulesetOrId === \"object\") {\n foundRulesetOrId = rulesetOrId;\n } else {\n const foundRuleset = await this._rulesets.get(rulesetOrId);\n foundRulesetOrId = foundRuleset ? foundRuleset.toJSON() : rulesetOrId;\n }\n const rulesetId = typeof foundRulesetOrId === \"object\" ? foundRulesetOrId.id : foundRulesetOrId;\n\n // All Id64Array variable values must be sorted for serialization to JSON to work. RulesetVariablesManager\n // sorts them before storing, so that part is taken care of, but we need to ensure that variables coming from\n // request options are also sorted.\n const variables = (rulesetVariables ?? []).map((variable) => {\n if (variable.type === VariableValueTypes.Id64Array) {\n return { ...variable, value: OrderedId64Iterable.sortArray(variable.value) };\n }\n return variable;\n });\n if (!this._ipcRequestsHandler) {\n // only need to add variables from variables manager if there's no IPC\n // handler - if there is one, the variables are already known by the backend\n variables.push(...this.vars(rulesetId).getAllVariables());\n }\n\n return { ...options, rulesetOrId: foundRulesetOrId, rulesetVariables: variables };\n }\n\n /** Retrieves nodes */\n public async getNodes(\n requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute,\n ): Promise<Node[]> {\n this.startIModelInitialization(requestOptions.imodel);\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = this.toRpcTokenOptions({ ...options });\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) =>\n this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }),\n );\n // eslint-disable-next-line deprecation/deprecation\n return this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON));\n }\n\n /** Retrieves nodes count. */\n public async getNodesCount(\n requestOptions: HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute,\n ): Promise<number> {\n this.startIModelInitialization(requestOptions.imodel);\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = this.toRpcTokenOptions({ ...options });\n return this._requestsHandler.getNodesCount(rpcOptions);\n }\n\n /** Retrieves total nodes count and a single page of nodes. */\n public async getNodesAndCount(\n requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute,\n ): Promise<{ count: number; nodes: Node[] }> {\n this.startIModelInitialization(requestOptions.imodel);\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = this.toRpcTokenOptions({ ...options });\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) =>\n this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }),\n );\n return {\n count: result.total,\n // eslint-disable-next-line deprecation/deprecation\n nodes: this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON)),\n };\n }\n\n /**\n * Retrieves hierarchy level descriptor.\n * @beta\n */\n public async getNodesDescriptor(\n requestOptions: HierarchyLevelDescriptorRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n this.startIModelInitialization(requestOptions.imodel);\n try {\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = this.toRpcTokenOptions({ ...options });\n const result = await this._requestsHandler.getNodesDescriptor(rpcOptions);\n const descriptor = Descriptor.fromJSON(result);\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n } finally {\n await this.ensureIModelInitialized(requestOptions.imodel);\n }\n }\n\n /** Retrieves paths from root nodes to children nodes according to specified keys. Intersecting paths will be merged. */\n public async getNodePaths(\n requestOptions: FilterByInstancePathsHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n this.startIModelInitialization(requestOptions.imodel);\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = this.toRpcTokenOptions({ ...options });\n const result = await this._requestsHandler.getNodePaths(rpcOptions);\n // eslint-disable-next-line deprecation/deprecation\n return result.map(NodePathElement.fromJSON).map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /** Retrieves paths from root nodes to nodes containing filter text in their label. */\n public async getFilteredNodePaths(\n requestOptions: FilterByTextHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n this.startIModelInitialization(requestOptions.imodel);\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const result = await this._requestsHandler.getFilteredNodePaths(this.toRpcTokenOptions(options));\n // eslint-disable-next-line deprecation/deprecation\n return result.map(NodePathElement.fromJSON).map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\n * its related instances for loading related and navigation properties.\n * @public\n */\n public async getContentSources(requestOptions: ContentSourcesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute): Promise<SelectClassInfo[]> {\n this.startIModelInitialization(requestOptions.imodel);\n const rpcOptions = this.toRpcTokenOptions(requestOptions);\n const result = await this._requestsHandler.getContentSources(rpcOptions);\n return SelectClassInfo.listFromCompressedJSON(result.sources, result.classesMap);\n }\n\n /** Retrieves the content descriptor which describes the content and can be used to customize it. */\n public async getContentDescriptor(\n requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n this.startIModelInitialization(requestOptions.imodel);\n try {\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = this.toRpcTokenOptions({\n ...options,\n keys: stripTransientElementKeys(options.keys).toJSON(),\n });\n const result = await this._requestsHandler.getContentDescriptor(rpcOptions);\n const descriptor = Descriptor.fromJSON(result);\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n } finally {\n await this.ensureIModelInitialized(requestOptions.imodel);\n }\n }\n\n /** Retrieves overall content set size. */\n public async getContentSetSize(\n requestOptions: ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\n ): Promise<number> {\n this.startIModelInitialization(requestOptions.imodel);\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = this.toRpcTokenOptions({\n ...options,\n descriptor: getDescriptorOverrides(requestOptions.descriptor),\n keys: stripTransientElementKeys(requestOptions.keys).toJSON(),\n });\n return this._requestsHandler.getContentSetSize(rpcOptions);\n }\n\n /** Retrieves content which consists of a content descriptor and a page of records. */\n public async getContent(\n requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute,\n ): Promise<Content | undefined> {\n return (await this.getContentAndSize(requestOptions))?.content;\n }\n\n /** Retrieves content set size and content which consists of a content descriptor and a page of records. */\n public async getContentAndSize(\n requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute,\n ): Promise<{ content: Content; size: number } | undefined> {\n this.startIModelInitialization(requestOptions.imodel);\n try {\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = this.toRpcTokenOptions({\n ...options,\n descriptor: getDescriptorOverrides(requestOptions.descriptor),\n keys: stripTransientElementKeys(requestOptions.keys).toJSON(),\n ...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\n });\n let descriptor = requestOptions.descriptor instanceof Descriptor ? requestOptions.descriptor : undefined;\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions, requestIndex) => {\n if (0 === requestIndex && !descriptor) {\n const content = await this._requestsHandler.getPagedContent({ ...rpcOptions, paging: partialPageOptions });\n if (content) {\n descriptor = Descriptor.fromJSON(content.descriptor);\n return content.contentSet;\n }\n return { total: 0, items: [] };\n }\n return this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging: partialPageOptions });\n });\n if (!descriptor) {\n return undefined;\n }\n\n const items = result.items.map((itemJson) => Item.fromJSON(itemJson)).filter<Item>((item): item is Item => item !== undefined);\n const resultContent = new Content(descriptor, items);\n if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);\n const contentFormatter = new ContentFormatter(\n new ContentPropertyValueFormatter(koqPropertyFormatter),\n requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem,\n );\n await contentFormatter.formatContent(resultContent);\n }\n\n return {\n size: result.total,\n content: this._localizationHelper.getLocalizedContent(resultContent),\n };\n } finally {\n await this.ensureIModelInitialized(requestOptions.imodel);\n }\n }\n\n /** Retrieves distinct values of specific field from the content. */\n public async getPagedDistinctValues(\n requestOptions: DistinctValuesRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\n ): Promise<PagedResponse<DisplayValueGroup>> {\n this.startIModelInitialization(requestOptions.imodel);\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = {\n ...this.toRpcTokenOptions(options),\n descriptor: getDescriptorOverrides(options.descriptor),\n keys: stripTransientElementKeys(options.keys).toJSON(),\n };\n const result = await buildPagedArrayResponse(requestOptions.paging, async (partialPageOptions) =>\n this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging: partialPageOptions }),\n );\n return {\n ...result,\n // eslint-disable-next-line deprecation/deprecation\n items: result.items.map(DisplayValueGroup.fromJSON).map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\n };\n }\n\n /**\n * Retrieves property data in a simplified format for a single element specified by ID.\n * @public\n */\n public async getElementProperties(\n requestOptions: SingleElementPropertiesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute,\n ): Promise<ElementProperties | undefined> {\n this.startIModelInitialization(requestOptions.imodel);\n const results = await this._requestsHandler.getElementProperties(this.toRpcTokenOptions(requestOptions));\n // istanbul ignore if\n if (!results) {\n return undefined;\n }\n return this._localizationHelper.getLocalizedElementProperties(results);\n }\n\n /**\n * Retrieves content item instance keys.\n * @public\n */\n public async getContentInstanceKeys(\n requestOptions: ContentInstanceKeysRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\n ): Promise<{ total: number; items: () => AsyncGenerator<InstanceKey> }> {\n this.startIModelInitialization(requestOptions.imodel);\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\n const rpcOptions = {\n ...this.toRpcTokenOptions(options),\n keys: stripTransientElementKeys(options.keys).toJSON(),\n };\n\n const props = {\n page: requestOptions.paging,\n get: async (page: Required<PageOptions>) => {\n const keys = await this._requestsHandler.getContentInstanceKeys({ ...rpcOptions, paging: page });\n return {\n total: keys.total,\n items: keys.items.instanceKeys.reduce((instanceKeys, entry) => {\n for (const id of CompressedId64Set.iterable(entry[1])) {\n instanceKeys.push({ className: entry[0], id });\n }\n return instanceKeys;\n }, new Array<InstanceKey>()),\n };\n },\n };\n return createPagedGeneratorResponse(props);\n }\n\n /** Retrieves display label definition of specific item. */\n public async getDisplayLabelDefinition(\n requestOptions: DisplayLabelRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute,\n ): Promise<LabelDefinition> {\n this.startIModelInitialization(requestOptions.imodel);\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\n const result = await this._requestsHandler.getDisplayLabelDefinition(rpcOptions);\n return this._localizationHelper.getLocalizedLabelDefinition(result);\n }\n\n /** Retrieves display label definition of specific items. */\n public async getDisplayLabelDefinitions(\n requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute,\n ): Promise<LabelDefinition[]> {\n this.startIModelInitialization(requestOptions.imodel);\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\n const result = await buildPagedArrayResponse(undefined, async (partialPageOptions) => {\n const partialKeys = !partialPageOptions.start ? rpcOptions.keys : rpcOptions.keys.slice(partialPageOptions.start);\n return this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });\n });\n return this._localizationHelper.getLocalizedLabelDefinitions(result.items);\n }\n}\n\nconst getDescriptorOverrides = (descriptorOrOverrides: Descriptor | DescriptorOverrides): DescriptorOverrides => {\n if (descriptorOrOverrides instanceof Descriptor) {\n return descriptorOrOverrides.createDescriptorOverrides();\n }\n return descriptorOrOverrides;\n};\n\ninterface PagedGeneratorCreateProps<TPagedResponseItem> {\n page: PageOptions | undefined;\n get: (pageStart: Required<PageOptions>, requestIndex: number) => Promise<{ total: number; items: TPagedResponseItem[] }>;\n}\nasync function createPagedGeneratorResponse<TPagedResponseItem>(props: PagedGeneratorCreateProps<TPagedResponseItem>) {\n let pageStart = props.page?.start ?? 0;\n let pageSize = props.page?.size ?? 0;\n let requestIndex = 0;\n\n const firstPage = await props.get({ start: pageStart, size: pageSize }, requestIndex++);\n return {\n total: firstPage.total,\n async *items() {\n let partialResult = firstPage;\n while (true) {\n for (const item of partialResult.items) {\n yield item;\n }\n\n const receivedItemsCount = partialResult.items.length;\n if (partialResult.total !== 0 && receivedItemsCount === 0) {\n if (pageStart >= partialResult.total) {\n throw new Error(`Requested page with start index ${pageStart} is out of bounds. Total number of items: ${partialResult.total}`);\n }\n throw new Error(\"Paged request returned non zero total count but no items\");\n }\n\n if ((pageSize !== 0 && receivedItemsCount >= pageSize) || receivedItemsCount >= partialResult.total - pageStart) {\n break;\n }\n\n if (pageSize !== 0) {\n pageSize -= receivedItemsCount;\n }\n pageStart += receivedItemsCount;\n\n partialResult = await props.get({ start: pageStart, size: pageSize }, requestIndex++);\n }\n },\n };\n}\n\n/** @internal */\nexport const buildPagedArrayResponse = async <TItem>(\n requestedPage: PageOptions | undefined,\n getter: (page: Required<PageOptions>, requestIndex: number) => Promise<PagedResponse<TItem>>,\n): Promise<PagedResponse<TItem>> => {\n const items = new Array<TItem>();\n const gen = await createPagedGeneratorResponse({ page: requestedPage, get: getter });\n for await (const item of gen.items()) {\n items.push(item);\n }\n return { total: gen.total, items };\n};\n\nconst stripTransientElementKeys = (keys: KeySet) => {\n if (!keys.some((key) => Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME)) {\n return keys;\n }\n\n const copy = new KeySet();\n copy.add(keys, (key) => {\n // the callback is not going to be called with EntityProps as KeySet converts them\n // to InstanceKeys, but we want to keep the EntityProps case for correctness\n // istanbul ignore next\n const isTransient =\n (Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME) ||\n (Key.isEntityProps(key) && key.classFullName === TRANSIENT_ELEMENT_CLASSNAME);\n return !isTransient;\n });\n return copy;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RulesetManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/RulesetManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAW,MAAM,4BAA4B,CAAC;AAwCxE,gBAAgB;AAChB,MAAM,OAAO,kBAAkB;IAA/B;QACU,oBAAe,GAAG,IAAI,GAAG,EAA+B,CAAC;QAC1D,sBAAiB,GAAG,IAAI,OAAO,EAAoD,CAAC;IA+E7F,CAAC;IA7EQ,MAAM,CAAC,MAAM;QAClB,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,EAAU;QACzB,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC,EAAE;YACN,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,OAAgB;QAC/B,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CA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KAAK,CAAC;SACd;QAED,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACjC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,KAAK,gBAAgB,EAAE;gBAC9C,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACf,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;aACP;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE;YACnC,OAAO;SACR;QAED,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"RulesetManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/RulesetManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAW,MAAM,4BAA4B,CAAC;AAwCxE,gBAAgB;AAChB,MAAM,OAAO,kBAAkB;IAA/B;QACU,oBAAe,GAAG,IAAI,GAAG,EAA+B,CAAC;QAC1D,sBAAiB,GAAG,IAAI,OAAO,EAAoD,CAAC;IA+E7F,CAAC;IA7EQ,MAAM,CAAC,MAAM;QAClB,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,EAAU;QACzB,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC,EAAE;YACN,OAAO,SAAS,CAAC;SACl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,GAAG,OAAO,CAAC,EAAE,CAAC;YACvB,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;SAC7C;QAED,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,CAAC,EAAE;YACN,OAAO,KAAK,CAAC;SACd;QAED,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACjC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,KAAK,gBAAgB,EAAE;gBAC9C,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACf,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;aACP;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE;YACnC,OAAO;SACR;QAED,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { BeEvent, Guid } from \"@itwin/core-bentley\";\nimport { RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\n\n/**\n * Presentation ruleset registry.\n * @public\n */\nexport interface RulesetManager {\n /**\n * An event invoked one a ruleset is modified using [[modify]] function.\n * @beta\n */\n onRulesetModified: BeEvent<(curr: RegisteredRuleset, prev: Ruleset) => void>;\n\n /**\n * Get a ruleset with the specified id.\n */\n get(id: string): Promise<RegisteredRuleset | undefined>;\n\n /**\n * Register the supplied ruleset\n */\n add(ruleset: Ruleset): Promise<RegisteredRuleset>;\n\n /**\n * Modify the given pre-registered ruleset\n * @beta\n */\n modify(ruleset: RegisteredRuleset, newRules: Omit<Ruleset, \"id\">): Promise<RegisteredRuleset>;\n\n /**\n * Unregister the supplied ruleset\n */\n remove(ruleset: RegisteredRuleset | [string, string]): Promise<boolean>;\n\n /**\n * Remove all rulesets registered in this session.\n */\n clear(): Promise<void>;\n}\n\n/** @internal */\nexport class RulesetManagerImpl implements RulesetManager {\n private _clientRulesets = new Map<string, RegisteredRuleset[]>();\n public onRulesetModified = new BeEvent<(curr: RegisteredRuleset, prev: Ruleset) => void>();\n\n public static create() {\n return new RulesetManagerImpl();\n }\n\n /**\n * Get a ruleset with the specified id.\n */\n public async get(id: string): Promise<RegisteredRuleset | undefined> {\n const m = this._clientRulesets.get(id);\n if (!m) {\n return undefined;\n }\n return m[0];\n }\n\n /**\n * Register the supplied ruleset\n */\n public async add(ruleset: Ruleset): Promise<RegisteredRuleset> {\n const registered = new RegisteredRuleset(ruleset, Guid.createValue(), async (r: RegisteredRuleset) => this.remove(r));\n if (!this._clientRulesets.has(ruleset.id)) {\n this._clientRulesets.set(ruleset.id, []);\n }\n this._clientRulesets.get(ruleset.id)!.push(registered);\n return registered;\n }\n\n /**\n * Modifies the given pre-registered ruleset\n */\n public async modify(ruleset: RegisteredRuleset, newRules: Omit<Ruleset, \"id\">): Promise<RegisteredRuleset> {\n await this.remove(ruleset);\n const modified = await this.add({ ...newRules, id: ruleset.id });\n this.onRulesetModified.raiseEvent(modified, ruleset.toJSON());\n return modified;\n }\n\n /**\n * Unregister the supplied ruleset\n */\n public async remove(ruleset: RegisteredRuleset | [string, string]): Promise<boolean> {\n let rulesetId, uniqueIdentifier: string;\n if (Array.isArray(ruleset)) {\n rulesetId = ruleset[0];\n uniqueIdentifier = ruleset[1];\n } else {\n rulesetId = ruleset.id;\n uniqueIdentifier = ruleset.uniqueIdentifier;\n }\n\n const m = this._clientRulesets.get(rulesetId);\n if (!m) {\n return false;\n }\n\n let didRemove = false;\n for (let i = 0; i < m.length; ++i) {\n if (m[i].uniqueIdentifier === uniqueIdentifier) {\n m.splice(i, 1);\n didRemove = true;\n break;\n }\n }\n\n return didRemove;\n }\n\n /**\n * Remove all rulesets registered in this session.\n */\n public async clear(): Promise<void> {\n if (0 === this._clientRulesets.size) {\n return;\n }\n\n this._clientRulesets.clear();\n }\n}\n"]}
|