@itwin/presentation-backend 3.5.0-dev.8 → 3.5.1

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