@itwin/presentation-backend 3.5.0-dev.5 → 3.5.0-dev.51

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 (65) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  3. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +761 -761
  4. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  5. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  7. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  8. package/lib/cjs/presentation-backend/Constants.d.ts +13 -13
  9. package/lib/cjs/presentation-backend/Constants.js +43 -43
  10. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  11. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +274 -274
  13. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  14. package/lib/cjs/presentation-backend/NativePlatform.d.ts +84 -83
  15. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  16. package/lib/cjs/presentation-backend/NativePlatform.js +140 -140
  17. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  18. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  19. package/lib/cjs/presentation-backend/Presentation.js +150 -150
  20. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  21. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
  23. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  24. package/lib/cjs/presentation-backend/PresentationManager.d.ts +441 -401
  25. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  26. package/lib/cjs/presentation-backend/PresentationManager.js +291 -291
  27. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  28. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +60 -60
  29. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +423 -422
  30. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  31. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +61 -59
  32. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  33. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +365 -364
  34. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  35. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +104 -104
  36. package/lib/cjs/presentation-backend/RulesetEmbedder.js +282 -282
  37. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  39. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  40. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  41. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  42. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  43. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  44. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +35 -35
  45. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +229 -229
  46. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  47. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  48. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  49. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  50. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  51. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  52. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  53. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  54. package/lib/cjs/presentation-backend/Utils.js +106 -106
  55. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  56. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  57. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +51 -51
  58. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  59. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  60. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  61. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  62. package/lib/cjs/presentation-backend.d.ts +19 -19
  63. package/lib/cjs/presentation-backend.js +35 -35
  64. package/lib/cjs/presentation-backend.js.map +1 -1
  65. package/package.json +14 -14
@@ -1,402 +1,442 @@
1
- /** @packageDocumentation
2
- * @module Core
3
- */
4
- import { IModelDb } from "@itwin/core-backend";
5
- import { Id64String } from "@itwin/core-bentley";
6
- import { FormatProps, UnitSystemKey } from "@itwin/core-quantity";
7
- import { ComputeSelectionRequestOptions, Content, ContentDescriptorRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, HierarchyCompareInfo, HierarchyCompareOptions, HierarchyRequestOptions, InstanceKey, KeySet, LabelDefinition, MultiElementPropertiesRequestOptions, Node, NodeKey, NodePathElement, Paged, PagedResponse, Prioritized, Ruleset, RulesetVariable, SelectClassInfo, SelectionScope, SelectionScopeRequestOptions, SingleElementPropertiesRequestOptions, WithCancelEvent } from "@itwin/presentation-common";
8
- import { NativePlatformDefinition } from "./NativePlatform";
9
- import { PresentationManagerDetail } from "./PresentationManagerDetail";
10
- import { RulesetManager } from "./RulesetManager";
11
- import { RulesetVariablesManager } from "./RulesetVariablesManager";
12
- import { BackendDiagnosticsAttribute, BackendDiagnosticsOptions } from "./Utils";
13
- /**
14
- * Presentation manager working mode.
15
- * @public
16
- */
17
- export declare enum PresentationManagerMode {
18
- /**
19
- * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
20
- * related to reacting to changes in iModels.
21
- */
22
- ReadOnly = 0,
23
- /**
24
- * Presentation manager assumes iModels are opened in read-write mode and it may need to
25
- * react to changes. This involves some additional work and gives slightly worse performance.
26
- */
27
- ReadWrite = 1
28
- }
29
- /**
30
- * Presentation hierarchy cache mode.
31
- * @beta
32
- */
33
- export declare enum HierarchyCacheMode {
34
- /**
35
- * Hierarchy cache is created in memory.
36
- */
37
- Memory = "memory",
38
- /**
39
- * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel
40
- * openings.
41
- */
42
- Disk = "disk",
43
- /**
44
- * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level
45
- * and persisted in disk cache when whole hierarchy level is created.
46
- */
47
- Hybrid = "hybrid"
48
- }
49
- /**
50
- * Configuration for hierarchy cache.
51
- * @beta
52
- */
53
- export declare type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;
54
- /**
55
- * Base interface for all [[HierarchyCacheConfig]] implementations.
56
- * @beta
57
- */
58
- export interface HierarchyCacheConfigBase {
59
- mode: HierarchyCacheMode;
60
- }
61
- /**
62
- * Configuration for in-memory hierarchy cache.
63
- * @beta
64
- */
65
- export interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {
66
- mode: HierarchyCacheMode.Memory;
67
- }
68
- /**
69
- * Configuration for persistent disk hierarchy cache.
70
- * @beta
71
- */
72
- export interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {
73
- mode: HierarchyCacheMode.Disk;
74
- /**
75
- * A directory for Presentation hierarchy cache. If set, the directory must exist.
76
- *
77
- * The default directory depends on the iModel and the way it's opened.
78
- */
79
- directory?: string;
80
- }
81
- /**
82
- * Configuration for the experimental hybrid hierarchy cache.
83
- *
84
- * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better
85
- * alternative for cases when there are lots of simultaneous requests.
86
- *
87
- * @beta
88
- */
89
- export interface HybridCacheConfig extends HierarchyCacheConfigBase {
90
- mode: HierarchyCacheMode.Hybrid;
91
- /** Configuration for disk cache used to persist hierarchies. */
92
- disk?: DiskHierarchyCacheConfig;
93
- }
94
- /**
95
- * Configuration for content cache.
96
- * @public
97
- */
98
- export interface ContentCacheConfig {
99
- /**
100
- * Maximum number of content descriptors cached in memory for quicker paged content requests.
101
- *
102
- * Defaults to `100`.
103
- *
104
- * @alpha
105
- */
106
- size?: number;
107
- }
108
- /**
109
- * A data structure that associates unit systems with a format. The associations are used for
110
- * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).
111
- *
112
- * @public
113
- */
114
- export interface UnitSystemFormat {
115
- unitSystems: UnitSystemKey[];
116
- format: FormatProps;
117
- }
118
- /**
119
- * Data structure for multiple element properties request response.
120
- * @alpha
121
- */
122
- export interface MultiElementPropertiesResponse {
123
- total: number;
124
- iterator: () => AsyncGenerator<ElementProperties[]>;
125
- }
126
- /**
127
- * Properties that can be used to configure [[PresentationManager]]
128
- * @public
129
- */
130
- export interface PresentationManagerProps {
131
- /**
132
- * Path overrides for presentation assets. Need to be overriden by application if it puts these assets someplace else than the default.
133
- *
134
- * By default paths to asset directories are determined during the call of [[Presentation.initialize]] using this algorithm:
135
- *
136
- * - for `presentation-backend` assets:
137
- *
138
- * - if path of `.js` file that contains [[PresentationManager]] definition contains "presentation-backend", assume the package is in `node_modules` and the directory structure is:
139
- * - `assets/*\*\/*`
140
- * - `presentation-backend/{presentation-backend source files}`
141
- *
142
- * which means the assets can be found through a relative path `../assets/` from the JS file being executed.
143
- *
144
- * - for `presentation-common` assets:
145
- *
146
- * - if path of `.js` files of `presentation-common` package contain "presentation-common", assume the package is in `node_modules` and the directory structure is:
147
- * - `assets/*\*\/*`
148
- * - `presentation-common/{presentation-common source files}`
149
- *
150
- * which means the assets can be found through a relative path `../assets/` from the package's source files.
151
- *
152
- * - in both cases, if we determine that source files are not in `node_modules`, assume the backend is webpacked into a single file with assets next to it:
153
- * - `assets/*\*\/*`
154
- * - `{source file being executed}.js`
155
- *
156
- * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.
157
- *
158
- * The overrides can be specified as a single path (when assets of both `presentation-backend` and `presentation-common` packages are merged into a single directory) or as an object with two separate paths for each package.
159
- */
160
- presentationAssetsRoot?: string | {
161
- /** Path to `presentation-backend` assets */
162
- backend: string;
163
- /** Path to `presentation-common` assets */
164
- common: string;
165
- };
166
- /**
167
- * A list of directories containing application's presentation rulesets.
168
- */
169
- rulesetDirectories?: string[];
170
- /**
171
- * A list of directories containing application's supplemental presentation rulesets.
172
- */
173
- supplementalRulesetDirectories?: string[];
174
- /**
175
- * A list of directories containing application's locale-specific localized
176
- * string files (in simplified i18next v3 format)
177
- *
178
- * @deprecated Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
179
- */
180
- localeDirectories?: string[];
181
- /**
182
- * Sets the active locale to use when localizing presentation-related
183
- * strings. It can later be changed through [[PresentationManager.activeLocale]].
184
- *
185
- * @deprecated Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
186
- */
187
- defaultLocale?: string;
188
- /**
189
- * Sets the active unit system to use for formatting property values with
190
- * units. Default presentation units are used if this is not specified. The active unit
191
- * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request
192
- * through request options.
193
- */
194
- defaultUnitSystem?: UnitSystemKey;
195
- /**
196
- * A map of default unit formats to use for formatting properties that don't have a presentation format
197
- * in requested unit system.
198
- */
199
- defaultFormats?: {
200
- [phenomenon: string]: UnitSystemFormat;
201
- };
202
- /**
203
- * Should schemas preloading be enabled. If true, presentation manager listens
204
- * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.
205
- *
206
- * @deprecated Use [[PresentationPropsBase.enableSchemasPreload]] instead.
207
- */
208
- enableSchemasPreload?: boolean;
209
- /**
210
- * A number of worker threads to use for handling presentation requests. Defaults to `2`.
211
- */
212
- workerThreadsCount?: number;
213
- /**
214
- * Presentation manager working mode. Backends that use iModels in read-write mode should
215
- * use `ReadWrite`, others might want to set to `ReadOnly` for better performance.
216
- *
217
- * Defaults to [[PresentationManagerMode.ReadWrite]].
218
- */
219
- mode?: PresentationManagerMode;
220
- /**
221
- * The interval (in milliseconds) used to poll for presentation data changes. Only has
222
- * effect in read-write mode (see [[mode]]).
223
- *
224
- * @alpha
225
- */
226
- updatesPollInterval?: number;
227
- /** Options for caching. */
228
- caching?: {
229
- /**
230
- * Hierarchies-related caching options.
231
- * @beta
232
- */
233
- hierarchies?: HierarchyCacheConfig;
234
- /** Content-related caching options. */
235
- content?: ContentCacheConfig;
236
- };
237
- /**
238
- * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling
239
- * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.
240
- *
241
- * 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.
242
- *
243
- * @alpha
244
- */
245
- useMmap?: boolean | number;
246
- /**
247
- * An identifier which helps separate multiple presentation managers. It's
248
- * mostly useful in tests where multiple presentation managers can co-exist
249
- * and try to share the same resources, which we don't want. With this identifier
250
- * set, managers put their resources into id-named subdirectories.
251
- *
252
- * @internal
253
- */
254
- id?: string;
255
- /** @internal */
256
- addon?: NativePlatformDefinition;
257
- /**
258
- * Localization function when only backend is used.
259
- * @beta
260
- */
261
- getLocalizedString?: (key: string) => string;
262
- /**
263
- * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request
264
- * made through the manager.
265
- *
266
- * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)
267
- * @beta
268
- */
269
- diagnostics?: BackendDiagnosticsOptions;
270
- }
271
- /**
272
- * Backend Presentation manager which pulls the presentation data from
273
- * an iModel using native platform.
274
- *
275
- * @public
276
- */
277
- export declare class PresentationManager {
278
- private _props;
279
- private _detail;
280
- private _localizationHelper;
281
- /**
282
- * Get / set active locale used for localizing presentation data
283
- * @deprecated Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
284
- */
285
- activeLocale: string | undefined;
286
- /**
287
- * Creates an instance of PresentationManager.
288
- * @param props Optional configuration properties.
289
- */
290
- constructor(props?: PresentationManagerProps);
291
- /** Get / set active unit system used to format property values with units */
292
- get activeUnitSystem(): UnitSystemKey | undefined;
293
- set activeUnitSystem(value: UnitSystemKey | undefined);
294
- /** Dispose the presentation manager. Must be called to clean up native resources. */
295
- dispose(): void;
296
- /** @internal */
297
- setOnManagerUsedHandler(handler: () => void): void;
298
- /** Properties used to initialize the manager */
299
- get props(): PresentationManagerProps;
300
- /** Get rulesets manager */
301
- rulesets(): RulesetManager;
302
- /**
303
- * Get ruleset variables manager for specific ruleset
304
- * @param rulesetId Id of the ruleset to get variables manager for
305
- */
306
- vars(rulesetId: string): RulesetVariablesManager;
307
- /** @internal */
308
- getNativePlatform: () => NativePlatformDefinition;
309
- /** @internal */
310
- getDetail(): PresentationManagerDetail;
311
- /** @internal */
312
- getRulesetId(rulesetOrId: Ruleset | string): string;
313
- /**
314
- * Retrieves nodes
315
- * @public
316
- */
317
- getNodes(requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute): Promise<Node[]>;
318
- /**
319
- * Retrieves nodes count
320
- * @public
321
- */
322
- getNodesCount(requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<number>;
323
- /**
324
- * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
325
- * TODO: Return results in pages
326
- * @public
327
- */
328
- getNodePaths(requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<NodePathElement[]>;
329
- /**
330
- * Retrieves paths from root nodes to nodes containing filter text in their label.
331
- * TODO: Return results in pages
332
- * @public
333
- */
334
- getFilteredNodePaths(requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<NodePathElement[]>;
335
- /** @beta */
336
- getContentSources(requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute): Promise<SelectClassInfo[]>;
337
- /**
338
- * Retrieves the content descriptor which can be used to get content
339
- * @public
340
- */
341
- getContentDescriptor(requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<Descriptor | undefined>;
342
- /**
343
- * Retrieves the content set size based on the supplied content descriptor override
344
- * @public
345
- */
346
- getContentSetSize(requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<number>;
347
- /**
348
- * Retrieves the content based on the supplied content descriptor override.
349
- * @public
350
- */
351
- getContent(requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute): Promise<Content | undefined>;
352
- /**
353
- * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
354
- * @param requestOptions Options for the request
355
- * @return A promise object that returns either distinct values on success or an error string on error.
356
- * @public
357
- */
358
- getPagedDistinctValues(requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<PagedResponse<DisplayValueGroup>>;
359
- /**
360
- * Retrieves property data in a simplified format for a single element specified by ID.
361
- * @beta
362
- */
363
- getElementProperties(requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute): Promise<ElementProperties | undefined>;
364
- /**
365
- * Retrieves property data in simplified format for multiple elements specified by class or all element.
366
- * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.
367
- * @alpha
368
- */
369
- getElementProperties(requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute): Promise<MultiElementPropertiesResponse>;
370
- private getMultipleElementProperties;
371
- /**
372
- * Retrieves display label definition of specific item
373
- * @public
374
- */
375
- getDisplayLabelDefinition(requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute): Promise<LabelDefinition>;
376
- /**
377
- * Retrieves display label definitions of specific items
378
- * @public
379
- */
380
- getDisplayLabelDefinitions(requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute): Promise<LabelDefinition[]>;
381
- /**
382
- * Retrieves available selection scopes.
383
- * @public
384
- */
385
- getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]>;
386
- /**
387
- * Computes selection set based on provided selection scope.
388
- * @public
389
- */
390
- computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb> & {
391
- ids: Id64String[];
392
- scopeId: string;
393
- } & BackendDiagnosticsAttribute): Promise<KeySet>;
394
- /** @alpha */
395
- computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet>;
396
- /**
397
- * Compares two hierarchies specified in the request options
398
- * @public
399
- */
400
- compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo>;
401
- }
1
+ /** @packageDocumentation
2
+ * @module Core
3
+ */
4
+ import { IModelDb } from "@itwin/core-backend";
5
+ import { Id64String } from "@itwin/core-bentley";
6
+ import { FormatProps, UnitSystemKey } from "@itwin/core-quantity";
7
+ import { ComputeSelectionRequestOptions, Content, ContentDescriptorRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, HierarchyCompareInfo, HierarchyCompareOptions, HierarchyRequestOptions, InstanceKey, KeySet, LabelDefinition, MultiElementPropertiesRequestOptions, Node, NodeKey, NodePathElement, Paged, PagedResponse, Prioritized, Ruleset, RulesetVariable, SelectClassInfo, SelectionScope, SelectionScopeRequestOptions, SingleElementPropertiesRequestOptions, WithCancelEvent } from "@itwin/presentation-common";
8
+ import { NativePlatformDefinition } from "./NativePlatform";
9
+ import { PresentationManagerDetail } from "./PresentationManagerDetail";
10
+ import { RulesetManager } from "./RulesetManager";
11
+ import { RulesetVariablesManager } from "./RulesetVariablesManager";
12
+ import { BackendDiagnosticsAttribute, BackendDiagnosticsOptions } from "./Utils";
13
+ /**
14
+ * Presentation manager working mode.
15
+ * @public
16
+ */
17
+ export declare enum PresentationManagerMode {
18
+ /**
19
+ * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
20
+ * related to reacting to changes in iModels.
21
+ */
22
+ ReadOnly = 0,
23
+ /**
24
+ * Presentation manager assumes iModels are opened in read-write mode and it may need to
25
+ * react to changes. This involves some additional work and gives slightly worse performance.
26
+ */
27
+ ReadWrite = 1
28
+ }
29
+ /**
30
+ * Presentation hierarchy cache mode.
31
+ * @beta
32
+ */
33
+ export declare enum HierarchyCacheMode {
34
+ /**
35
+ * Hierarchy cache is created in memory.
36
+ */
37
+ Memory = "memory",
38
+ /**
39
+ * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel
40
+ * openings.
41
+ */
42
+ Disk = "disk",
43
+ /**
44
+ * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level
45
+ * and persisted in disk cache when whole hierarchy level is created.
46
+ */
47
+ Hybrid = "hybrid"
48
+ }
49
+ /**
50
+ * Configuration for hierarchy cache.
51
+ * @beta
52
+ */
53
+ export declare type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;
54
+ /**
55
+ * Base interface for all [[HierarchyCacheConfig]] implementations.
56
+ * @beta
57
+ */
58
+ export interface HierarchyCacheConfigBase {
59
+ mode: HierarchyCacheMode;
60
+ }
61
+ /**
62
+ * Configuration for in-memory hierarchy cache.
63
+ *
64
+ * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)
65
+ * @beta
66
+ */
67
+ export interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {
68
+ mode: HierarchyCacheMode.Memory;
69
+ }
70
+ /**
71
+ * Configuration for persistent disk hierarchy cache.
72
+ *
73
+ * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)
74
+ * @beta
75
+ */
76
+ export interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {
77
+ mode: HierarchyCacheMode.Disk;
78
+ /**
79
+ * A directory for Presentation hierarchy cache. If set, the directory must exist.
80
+ *
81
+ * The default directory depends on the iModel and the way it's opened.
82
+ */
83
+ directory?: string;
84
+ /**
85
+ * While the cache itself is stored on a disk, there's still a required small in-memory cache.
86
+ * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).
87
+ *
88
+ * @beta
89
+ */
90
+ memoryCacheSize?: number;
91
+ }
92
+ /**
93
+ * Configuration for the experimental hybrid hierarchy cache.
94
+ *
95
+ * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better
96
+ * alternative for cases when there are lots of simultaneous requests.
97
+ *
98
+ * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)
99
+ * @beta
100
+ */
101
+ export interface HybridCacheConfig extends HierarchyCacheConfigBase {
102
+ mode: HierarchyCacheMode.Hybrid;
103
+ /** Configuration for disk cache used to persist hierarchies. */
104
+ disk?: DiskHierarchyCacheConfig;
105
+ }
106
+ /**
107
+ * Configuration for content cache.
108
+ *
109
+ * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)
110
+ * @public
111
+ */
112
+ export interface ContentCacheConfig {
113
+ /**
114
+ * Maximum number of content descriptors cached in memory for quicker paged content requests.
115
+ *
116
+ * Defaults to `100`.
117
+ *
118
+ * @beta
119
+ */
120
+ size?: number;
121
+ }
122
+ /**
123
+ * Caching configuration options for [[PresentationManager]].
124
+ * @public
125
+ */
126
+ export interface PresentationManagerCachingConfig {
127
+ /**
128
+ * Hierarchies-related caching options.
129
+ *
130
+ * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)
131
+ * @beta
132
+ */
133
+ hierarchies?: HierarchyCacheConfig;
134
+ /**
135
+ * Content-related caching options.
136
+ *
137
+ * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)
138
+ */
139
+ content?: ContentCacheConfig;
140
+ /**
141
+ * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This
142
+ * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection
143
+ * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that
144
+ * cache. Defaults to `32768000` bytes (32 MB).
145
+ *
146
+ * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)
147
+ * @beta
148
+ */
149
+ workerConnectionCacheSize?: number;
150
+ }
151
+ /**
152
+ * A data structure that associates unit systems with a format. The associations are used for
153
+ * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).
154
+ *
155
+ * @public
156
+ */
157
+ export interface UnitSystemFormat {
158
+ unitSystems: UnitSystemKey[];
159
+ format: FormatProps;
160
+ }
161
+ /**
162
+ * Data structure for multiple element properties request response.
163
+ * @alpha
164
+ */
165
+ export interface MultiElementPropertiesResponse {
166
+ total: number;
167
+ iterator: () => AsyncGenerator<ElementProperties[]>;
168
+ }
169
+ /**
170
+ * Configuration options for supplying asset directly paths to [[PresentationManager]].
171
+ * @public
172
+ */
173
+ export interface PresentationAssetsRootConfig {
174
+ /** Path to `presentation-backend` assets */
175
+ backend: string;
176
+ /** Path to `presentation-common` assets */
177
+ common: string;
178
+ }
179
+ /**
180
+ * Properties that can be used to configure [[PresentationManager]]
181
+ * @public
182
+ */
183
+ export interface PresentationManagerProps {
184
+ /**
185
+ * Path overrides for presentation assets. Need to be overriden by application if it puts these assets someplace else than the default.
186
+ *
187
+ * By default paths to asset directories are determined during the call of [[Presentation.initialize]] using this algorithm:
188
+ *
189
+ * - for `presentation-backend` assets:
190
+ *
191
+ * - if path of `.js` file that contains [[PresentationManager]] definition contains "presentation-backend", assume the package is in `node_modules` and the directory structure is:
192
+ * - `assets/*\*\/*`
193
+ * - `presentation-backend/{presentation-backend source files}`
194
+ *
195
+ * which means the assets can be found through a relative path `../assets/` from the JS file being executed.
196
+ *
197
+ * - for `presentation-common` assets:
198
+ *
199
+ * - if path of `.js` files of `presentation-common` package contain "presentation-common", assume the package is in `node_modules` and the directory structure is:
200
+ * - `assets/*\*\/*`
201
+ * - `presentation-common/{presentation-common source files}`
202
+ *
203
+ * which means the assets can be found through a relative path `../assets/` from the package's source files.
204
+ *
205
+ * - in both cases, if we determine that source files are not in `node_modules`, assume the backend is webpacked into a single file with assets next to it:
206
+ * - `assets/*\*\/*`
207
+ * - `{source file being executed}.js`
208
+ *
209
+ * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.
210
+ *
211
+ * The overrides can be specified as a single path (when assets of both `presentation-backend` and `presentation-common` packages are merged into a single directory) or as an object with two separate paths for each package.
212
+ */
213
+ presentationAssetsRoot?: string | PresentationAssetsRootConfig;
214
+ /**
215
+ * A list of directories containing application's presentation rulesets.
216
+ */
217
+ rulesetDirectories?: string[];
218
+ /**
219
+ * A list of directories containing application's supplemental presentation rulesets.
220
+ */
221
+ supplementalRulesetDirectories?: string[];
222
+ /**
223
+ * A list of directories containing application's locale-specific localized
224
+ * string files (in simplified i18next v3 format)
225
+ *
226
+ * @deprecated Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
227
+ */
228
+ localeDirectories?: string[];
229
+ /**
230
+ * Sets the active locale to use when localizing presentation-related
231
+ * strings. It can later be changed through [[PresentationManager.activeLocale]].
232
+ *
233
+ * @deprecated Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
234
+ */
235
+ defaultLocale?: string;
236
+ /**
237
+ * Sets the active unit system to use for formatting property values with
238
+ * units. Default presentation units are used if this is not specified. The active unit
239
+ * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request
240
+ * through request options.
241
+ */
242
+ defaultUnitSystem?: UnitSystemKey;
243
+ /**
244
+ * A map of default unit formats to use for formatting properties that don't have a presentation format
245
+ * in requested unit system.
246
+ */
247
+ defaultFormats?: {
248
+ [phenomenon: string]: UnitSystemFormat;
249
+ };
250
+ /**
251
+ * Should schemas preloading be enabled. If true, presentation manager listens
252
+ * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.
253
+ *
254
+ * @deprecated Use [[PresentationPropsBase.enableSchemasPreload]] instead.
255
+ */
256
+ enableSchemasPreload?: boolean;
257
+ /**
258
+ * A number of worker threads to use for handling presentation requests. Defaults to `2`.
259
+ */
260
+ workerThreadsCount?: number;
261
+ /**
262
+ * Presentation manager working mode. Backends that use iModels in read-write mode should
263
+ * use `ReadWrite`, others might want to set to `ReadOnly` for better performance.
264
+ *
265
+ * Defaults to [[PresentationManagerMode.ReadWrite]].
266
+ */
267
+ mode?: PresentationManagerMode;
268
+ /**
269
+ * The interval (in milliseconds) used to poll for presentation data changes. Only has
270
+ * effect in read-write mode (see [[mode]]).
271
+ *
272
+ * @alpha
273
+ */
274
+ updatesPollInterval?: number;
275
+ /** Options for caching. */
276
+ caching?: PresentationManagerCachingConfig;
277
+ /**
278
+ * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling
279
+ * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.
280
+ *
281
+ * 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.
282
+ *
283
+ * @alpha
284
+ */
285
+ useMmap?: boolean | number;
286
+ /**
287
+ * An identifier which helps separate multiple presentation managers. It's
288
+ * mostly useful in tests where multiple presentation managers can co-exist
289
+ * and try to share the same resources, which we don't want. With this identifier
290
+ * set, managers put their resources into id-named subdirectories.
291
+ *
292
+ * @internal
293
+ */
294
+ id?: string;
295
+ /** @internal */
296
+ addon?: NativePlatformDefinition;
297
+ /**
298
+ * Localization function when only backend is used.
299
+ * @beta
300
+ */
301
+ getLocalizedString?: (key: string) => string;
302
+ /**
303
+ * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request
304
+ * made through the manager.
305
+ *
306
+ * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)
307
+ * @beta
308
+ */
309
+ diagnostics?: BackendDiagnosticsOptions;
310
+ }
311
+ /**
312
+ * Backend Presentation manager which pulls the presentation data from
313
+ * an iModel using native platform.
314
+ *
315
+ * @public
316
+ */
317
+ export declare class PresentationManager {
318
+ private _props;
319
+ private _detail;
320
+ private _localizationHelper;
321
+ /**
322
+ * Get / set active locale used for localizing presentation data
323
+ * @deprecated Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
324
+ */
325
+ activeLocale: string | undefined;
326
+ /**
327
+ * Creates an instance of PresentationManager.
328
+ * @param props Optional configuration properties.
329
+ */
330
+ constructor(props?: PresentationManagerProps);
331
+ /** Get / set active unit system used to format property values with units */
332
+ get activeUnitSystem(): UnitSystemKey | undefined;
333
+ set activeUnitSystem(value: UnitSystemKey | undefined);
334
+ /** Dispose the presentation manager. Must be called to clean up native resources. */
335
+ dispose(): void;
336
+ /** @internal */
337
+ setOnManagerUsedHandler(handler: () => void): void;
338
+ /** Properties used to initialize the manager */
339
+ get props(): PresentationManagerProps;
340
+ /** Get rulesets manager */
341
+ rulesets(): RulesetManager;
342
+ /**
343
+ * Get ruleset variables manager for specific ruleset
344
+ * @param rulesetId Id of the ruleset to get variables manager for
345
+ */
346
+ vars(rulesetId: string): RulesetVariablesManager;
347
+ /** @internal */
348
+ getNativePlatform: () => NativePlatformDefinition;
349
+ /** @internal */
350
+ getDetail(): PresentationManagerDetail;
351
+ /** @internal */
352
+ getRulesetId(rulesetOrId: Ruleset | string): string;
353
+ /**
354
+ * Retrieves nodes
355
+ * @public
356
+ */
357
+ getNodes(requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute): Promise<Node[]>;
358
+ /**
359
+ * Retrieves nodes count
360
+ * @public
361
+ */
362
+ getNodesCount(requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<number>;
363
+ /**
364
+ * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
365
+ * TODO: Return results in pages
366
+ * @public
367
+ */
368
+ getNodePaths(requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<NodePathElement[]>;
369
+ /**
370
+ * Retrieves paths from root nodes to nodes containing filter text in their label.
371
+ * TODO: Return results in pages
372
+ * @public
373
+ */
374
+ getFilteredNodePaths(requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<NodePathElement[]>;
375
+ /** @beta */
376
+ getContentSources(requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute): Promise<SelectClassInfo[]>;
377
+ /**
378
+ * Retrieves the content descriptor which can be used to get content
379
+ * @public
380
+ */
381
+ getContentDescriptor(requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<Descriptor | undefined>;
382
+ /**
383
+ * Retrieves the content set size based on the supplied content descriptor override
384
+ * @public
385
+ */
386
+ getContentSetSize(requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<number>;
387
+ /**
388
+ * Retrieves the content based on the supplied content descriptor override.
389
+ * @public
390
+ */
391
+ getContent(requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute): Promise<Content | undefined>;
392
+ /**
393
+ * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
394
+ * @param requestOptions Options for the request
395
+ * @return A promise object that returns either distinct values on success or an error string on error.
396
+ * @public
397
+ */
398
+ getPagedDistinctValues(requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<PagedResponse<DisplayValueGroup>>;
399
+ /**
400
+ * Retrieves property data in a simplified format for a single element specified by ID.
401
+ * @beta
402
+ */
403
+ getElementProperties(requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute): Promise<ElementProperties | undefined>;
404
+ /**
405
+ * Retrieves property data in simplified format for multiple elements specified by class or all element.
406
+ * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.
407
+ * @alpha
408
+ */
409
+ getElementProperties(requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute): Promise<MultiElementPropertiesResponse>;
410
+ private getMultipleElementProperties;
411
+ /**
412
+ * Retrieves display label definition of specific item
413
+ * @public
414
+ */
415
+ getDisplayLabelDefinition(requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute): Promise<LabelDefinition>;
416
+ /**
417
+ * Retrieves display label definitions of specific items
418
+ * @public
419
+ */
420
+ getDisplayLabelDefinitions(requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute): Promise<LabelDefinition[]>;
421
+ /**
422
+ * Retrieves available selection scopes.
423
+ * @public
424
+ */
425
+ getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]>;
426
+ /**
427
+ * Computes selection set based on provided selection scope.
428
+ * @public
429
+ */
430
+ computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb> & {
431
+ ids: Id64String[];
432
+ scopeId: string;
433
+ } & BackendDiagnosticsAttribute): Promise<KeySet>;
434
+ /** @alpha */
435
+ computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet>;
436
+ /**
437
+ * Compares two hierarchies specified in the request options
438
+ * @public
439
+ */
440
+ compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo>;
441
+ }
402
442
  //# sourceMappingURL=PresentationManager.d.ts.map