@itwin/presentation-backend 5.0.0-dev.11 → 5.0.0-dev.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -1
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +31 -4
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +161 -56
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/InternalSymbols.d.ts +5 -0
- package/lib/cjs/presentation-backend/InternalSymbols.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/InternalSymbols.js +16 -0
- package/lib/cjs/presentation-backend/InternalSymbols.js.map +1 -0
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +2 -2
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +5 -3
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.d.ts +2 -7
- package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +40 -29
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +3 -3
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +5 -7
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +13 -90
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +79 -130
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +19 -10
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +83 -76
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +11 -11
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +110 -118
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +23 -24
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.d.ts +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.js +2 -1
- package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +2 -0
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +2 -4
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +70 -83
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +2 -3
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.js +30 -28
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +15 -21
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +2 -2
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/RulesetElements.js +4 -4
- package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
- package/lib/cjs/presentation-backend-internal.d.ts +2 -0
- package/lib/cjs/presentation-backend-internal.d.ts.map +1 -0
- package/lib/cjs/presentation-backend-internal.js +12 -0
- package/lib/cjs/presentation-backend-internal.js.map +1 -0
- package/lib/cjs/presentation-backend.d.ts +7 -7
- package/lib/cjs/presentation-backend.d.ts.map +1 -1
- package/lib/cjs/presentation-backend.js +11 -21
- package/lib/cjs/presentation-backend.js.map +1 -1
- package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts +62 -0
- package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts.map +1 -0
- package/lib/esm/presentation-backend/BackendLoggerCategory.js +69 -0
- package/lib/esm/presentation-backend/BackendLoggerCategory.js.map +1 -0
- package/lib/esm/presentation-backend/ElementPropertiesHelper.d.ts +45 -0
- package/lib/esm/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -0
- package/lib/esm/presentation-backend/ElementPropertiesHelper.js +187 -0
- package/lib/esm/presentation-backend/ElementPropertiesHelper.js.map +1 -0
- package/lib/esm/presentation-backend/InternalSymbols.d.ts +5 -0
- package/lib/esm/presentation-backend/InternalSymbols.d.ts.map +1 -0
- package/lib/esm/presentation-backend/InternalSymbols.js +13 -0
- package/lib/esm/presentation-backend/InternalSymbols.js.map +1 -0
- package/lib/esm/presentation-backend/NativePlatform.d.ts +89 -0
- package/lib/esm/presentation-backend/NativePlatform.d.ts.map +1 -0
- package/lib/esm/presentation-backend/NativePlatform.js +156 -0
- package/lib/esm/presentation-backend/NativePlatform.js.map +1 -0
- package/lib/esm/presentation-backend/Presentation.d.ts +97 -0
- package/lib/esm/presentation-backend/Presentation.d.ts.map +1 -0
- package/lib/esm/presentation-backend/Presentation.js +147 -0
- package/lib/esm/presentation-backend/Presentation.js.map +1 -0
- package/lib/esm/presentation-backend/PresentationIpcHandler.d.ts +12 -0
- package/lib/esm/presentation-backend/PresentationIpcHandler.d.ts.map +1 -0
- package/lib/esm/presentation-backend/PresentationIpcHandler.js +25 -0
- package/lib/esm/presentation-backend/PresentationIpcHandler.js.map +1 -0
- package/lib/esm/presentation-backend/PresentationManager.d.ts +387 -0
- package/lib/esm/presentation-backend/PresentationManager.d.ts.map +1 -0
- package/lib/esm/presentation-backend/PresentationManager.js +352 -0
- package/lib/esm/presentation-backend/PresentationManager.js.map +1 -0
- package/lib/esm/presentation-backend/PresentationManagerDetail.d.ts +74 -0
- package/lib/esm/presentation-backend/PresentationManagerDetail.d.ts.map +1 -0
- package/lib/esm/presentation-backend/PresentationManagerDetail.js +446 -0
- package/lib/esm/presentation-backend/PresentationManagerDetail.js.map +1 -0
- package/lib/esm/presentation-backend/PresentationRpcImpl.d.ts +63 -0
- package/lib/esm/presentation-backend/PresentationRpcImpl.d.ts.map +1 -0
- package/lib/esm/presentation-backend/PresentationRpcImpl.js +409 -0
- package/lib/esm/presentation-backend/PresentationRpcImpl.js.map +1 -0
- package/lib/esm/presentation-backend/RulesetEmbedder.d.ts +109 -0
- package/lib/esm/presentation-backend/RulesetEmbedder.d.ts.map +1 -0
- package/lib/esm/presentation-backend/RulesetEmbedder.js +269 -0
- package/lib/esm/presentation-backend/RulesetEmbedder.js.map +1 -0
- package/lib/esm/presentation-backend/RulesetManager.d.ts +54 -0
- package/lib/esm/presentation-backend/RulesetManager.d.ts.map +1 -0
- package/lib/esm/presentation-backend/RulesetManager.js +74 -0
- package/lib/esm/presentation-backend/RulesetManager.js.map +1 -0
- package/lib/esm/presentation-backend/RulesetVariablesManager.d.ts +141 -0
- package/lib/esm/presentation-backend/RulesetVariablesManager.d.ts.map +1 -0
- package/lib/esm/presentation-backend/RulesetVariablesManager.js +140 -0
- package/lib/esm/presentation-backend/RulesetVariablesManager.js.map +1 -0
- package/lib/esm/presentation-backend/SelectionScopesHelper.d.ts +27 -0
- package/lib/esm/presentation-backend/SelectionScopesHelper.d.ts.map +1 -0
- package/lib/esm/presentation-backend/SelectionScopesHelper.js +227 -0
- package/lib/esm/presentation-backend/SelectionScopesHelper.js.map +1 -0
- package/lib/esm/presentation-backend/TemporaryStorage.d.ts +123 -0
- package/lib/esm/presentation-backend/TemporaryStorage.d.ts.map +1 -0
- package/lib/esm/presentation-backend/TemporaryStorage.js +157 -0
- package/lib/esm/presentation-backend/TemporaryStorage.js.map +1 -0
- package/lib/esm/presentation-backend/Utils.d.ts +50 -0
- package/lib/esm/presentation-backend/Utils.d.ts.map +1 -0
- package/lib/esm/presentation-backend/Utils.js +101 -0
- package/lib/esm/presentation-backend/Utils.js.map +1 -0
- package/lib/esm/presentation-backend/domain/PresentationRulesDomain.d.ts +17 -0
- package/lib/esm/presentation-backend/domain/PresentationRulesDomain.d.ts.map +1 -0
- package/lib/esm/presentation-backend/domain/PresentationRulesDomain.js +31 -0
- package/lib/esm/presentation-backend/domain/PresentationRulesDomain.js.map +1 -0
- package/lib/esm/presentation-backend/domain/RulesetElements.d.ts +22 -0
- package/lib/esm/presentation-backend/domain/RulesetElements.d.ts.map +1 -0
- package/lib/esm/presentation-backend/domain/RulesetElements.js +38 -0
- package/lib/esm/presentation-backend/domain/RulesetElements.js.map +1 -0
- package/lib/esm/presentation-backend/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -0
- package/lib/esm/presentation-backend/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +701 -0
- package/lib/esm/presentation-backend/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -0
- package/lib/esm/presentation-backend-internal.d.ts +2 -0
- package/lib/esm/presentation-backend-internal.d.ts.map +1 -0
- package/lib/esm/presentation-backend-internal.js +8 -0
- package/lib/esm/presentation-backend-internal.js.map +1 -0
- package/lib/esm/presentation-backend.d.ts +20 -0
- package/lib/esm/presentation-backend.d.ts.map +1 -0
- package/lib/esm/presentation-backend.js +21 -0
- package/lib/esm/presentation-backend.js.map +1 -0
- package/package.json +42 -35
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
6
|
+
import * as hash from "object-hash";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import { IModelDb, IpcHost } from "@itwin/core-backend";
|
|
9
|
+
import { BeEvent, Logger } from "@itwin/core-bentley";
|
|
10
|
+
import { Content, ContentFlags, DefaultContentDisplayTypes, Descriptor, InstanceKey, Item, Key, KeySet, SelectClassInfo, } from "@itwin/presentation-common";
|
|
11
|
+
import { deepReplaceNullsToUndefined, PresentationIpcEvents } from "@itwin/presentation-common/internal";
|
|
12
|
+
import { PresentationBackendLoggerCategory } from "./BackendLoggerCategory.js";
|
|
13
|
+
import { createDefaultNativePlatform, NativePlatformRequestTypes, NativePresentationUnitSystem, PresentationNativePlatformResponseError, } from "./NativePlatform.js";
|
|
14
|
+
import { HierarchyCacheMode } from "./PresentationManager.js";
|
|
15
|
+
// @ts-ignore TS complains about `with` in CJS builds, but not ESM
|
|
16
|
+
import elementPropertiesRuleset from "./primary-presentation-rules/ElementProperties.PresentationRuleSet.json" with { type: "json" };
|
|
17
|
+
import { RulesetManagerImpl } from "./RulesetManager.js";
|
|
18
|
+
// @ts-ignore TS complains about `with` in CJS builds, but not ESM
|
|
19
|
+
import bisSupplementalRuleset from "./supplemental-presentation-rules/BisCore.PresentationRuleSet.json" with { type: "json" };
|
|
20
|
+
// @ts-ignore TS complains about `with` in CJS builds, but not ESM
|
|
21
|
+
import funcSupplementalRuleset from "./supplemental-presentation-rules/Functional.PresentationRuleSet.json" with { type: "json" };
|
|
22
|
+
import { combineDiagnosticsOptions, getElementKey, reportDiagnostics } from "./Utils.js";
|
|
23
|
+
/**
|
|
24
|
+
* Produce content descriptor that is not intended for querying content. Allows the implementation to omit certain
|
|
25
|
+
* operations to make obtaining content descriptor faster.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export const DESCRIPTOR_ONLY_CONTENT_FLAG = 1 << 9;
|
|
29
|
+
/** @internal */
|
|
30
|
+
export class PresentationManagerDetail {
|
|
31
|
+
_disposed;
|
|
32
|
+
_nativePlatform;
|
|
33
|
+
_diagnosticsOptions;
|
|
34
|
+
rulesets;
|
|
35
|
+
activeUnitSystem;
|
|
36
|
+
onUsed;
|
|
37
|
+
constructor(params) {
|
|
38
|
+
this._disposed = false;
|
|
39
|
+
this._nativePlatform =
|
|
40
|
+
params.addon ??
|
|
41
|
+
createNativePlatform(params.id ?? "", params.workerThreadsCount ?? 2, IpcHost.isValid ? ipcUpdatesHandler : noopUpdatesHandler, params.caching, params.defaultFormats, params.useMmap);
|
|
42
|
+
setupRulesets(this._nativePlatform, params.supplementalRulesetDirectories ?? [], params.rulesetDirectories ?? []);
|
|
43
|
+
this.activeUnitSystem = params.defaultUnitSystem;
|
|
44
|
+
this.onUsed = new BeEvent();
|
|
45
|
+
this.rulesets = new RulesetManagerImpl(() => this.getNativePlatform());
|
|
46
|
+
this._diagnosticsOptions = params.diagnostics;
|
|
47
|
+
}
|
|
48
|
+
[Symbol.dispose]() {
|
|
49
|
+
if (this._disposed) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.getNativePlatform()[Symbol.dispose]();
|
|
53
|
+
this._nativePlatform = undefined;
|
|
54
|
+
this.onUsed.clear();
|
|
55
|
+
this._disposed = true;
|
|
56
|
+
}
|
|
57
|
+
getNativePlatform() {
|
|
58
|
+
if (this._disposed) {
|
|
59
|
+
throw new Error("Attempting to use Presentation manager after disposal");
|
|
60
|
+
}
|
|
61
|
+
return this._nativePlatform;
|
|
62
|
+
}
|
|
63
|
+
async getNodes(requestOptions) {
|
|
64
|
+
const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;
|
|
65
|
+
const params = {
|
|
66
|
+
requestId: parentKey ? NativePlatformRequestTypes.GetChildren : NativePlatformRequestTypes.GetRootNodes,
|
|
67
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
68
|
+
...strippedOptions,
|
|
69
|
+
nodeKey: parentKey,
|
|
70
|
+
};
|
|
71
|
+
return this.request(params);
|
|
72
|
+
}
|
|
73
|
+
async getNodesCount(requestOptions) {
|
|
74
|
+
const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;
|
|
75
|
+
const params = {
|
|
76
|
+
requestId: parentKey ? NativePlatformRequestTypes.GetChildrenCount : NativePlatformRequestTypes.GetRootNodesCount,
|
|
77
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
78
|
+
...strippedOptions,
|
|
79
|
+
nodeKey: parentKey,
|
|
80
|
+
};
|
|
81
|
+
return JSON.parse(await this.request(params));
|
|
82
|
+
}
|
|
83
|
+
async getNodesDescriptor(requestOptions) {
|
|
84
|
+
const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;
|
|
85
|
+
const params = {
|
|
86
|
+
requestId: NativePlatformRequestTypes.GetNodesDescriptor,
|
|
87
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
88
|
+
...strippedOptions,
|
|
89
|
+
nodeKey: parentKey,
|
|
90
|
+
};
|
|
91
|
+
return this.request(params);
|
|
92
|
+
}
|
|
93
|
+
async getNodePaths(requestOptions) {
|
|
94
|
+
const { rulesetOrId, instancePaths, ...strippedOptions } = requestOptions;
|
|
95
|
+
const params = {
|
|
96
|
+
requestId: NativePlatformRequestTypes.GetNodePaths,
|
|
97
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
98
|
+
...strippedOptions,
|
|
99
|
+
paths: instancePaths,
|
|
100
|
+
};
|
|
101
|
+
const paths = deepReplaceNullsToUndefined(JSON.parse(await this.request(params)));
|
|
102
|
+
return paths;
|
|
103
|
+
}
|
|
104
|
+
async getFilteredNodePaths(requestOptions) {
|
|
105
|
+
const { rulesetOrId, ...strippedOptions } = requestOptions;
|
|
106
|
+
const params = {
|
|
107
|
+
requestId: NativePlatformRequestTypes.GetFilteredNodePaths,
|
|
108
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
109
|
+
...strippedOptions,
|
|
110
|
+
};
|
|
111
|
+
const paths = deepReplaceNullsToUndefined(JSON.parse(await this.request(params)));
|
|
112
|
+
return paths;
|
|
113
|
+
}
|
|
114
|
+
async getContentDescriptor(requestOptions) {
|
|
115
|
+
const { rulesetOrId, contentFlags, ...strippedOptions } = requestOptions;
|
|
116
|
+
const params = {
|
|
117
|
+
requestId: NativePlatformRequestTypes.GetContentDescriptor,
|
|
118
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
119
|
+
...strippedOptions,
|
|
120
|
+
contentFlags: contentFlags ?? DESCRIPTOR_ONLY_CONTENT_FLAG, // only set "descriptor only" flag if there are no flags provided
|
|
121
|
+
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
122
|
+
};
|
|
123
|
+
return this.request(params);
|
|
124
|
+
}
|
|
125
|
+
async getContentSources(requestOptions) {
|
|
126
|
+
const params = {
|
|
127
|
+
requestId: NativePlatformRequestTypes.GetContentSources,
|
|
128
|
+
rulesetId: "ElementProperties",
|
|
129
|
+
...requestOptions,
|
|
130
|
+
};
|
|
131
|
+
const json = JSON.parse(await this.request(params));
|
|
132
|
+
return deepReplaceNullsToUndefined(json.sources.map((sourceJson) => SelectClassInfo.fromCompressedJSON(sourceJson, json.classesMap)));
|
|
133
|
+
}
|
|
134
|
+
async getContentSetSize(requestOptions) {
|
|
135
|
+
const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;
|
|
136
|
+
const params = {
|
|
137
|
+
requestId: NativePlatformRequestTypes.GetContentSetSize,
|
|
138
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
139
|
+
...strippedOptions,
|
|
140
|
+
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
141
|
+
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
142
|
+
};
|
|
143
|
+
return JSON.parse(await this.request(params));
|
|
144
|
+
}
|
|
145
|
+
async getContentSet(requestOptions) {
|
|
146
|
+
const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;
|
|
147
|
+
const params = {
|
|
148
|
+
requestId: NativePlatformRequestTypes.GetContentSet,
|
|
149
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
150
|
+
...strippedOptions,
|
|
151
|
+
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
152
|
+
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
153
|
+
};
|
|
154
|
+
return JSON.parse(await this.request(params))
|
|
155
|
+
.map((json) => Item.fromJSON(deepReplaceNullsToUndefined(json)))
|
|
156
|
+
.filter((item) => !!item);
|
|
157
|
+
}
|
|
158
|
+
async getContent(requestOptions) {
|
|
159
|
+
const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;
|
|
160
|
+
const params = {
|
|
161
|
+
requestId: NativePlatformRequestTypes.GetContent,
|
|
162
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
163
|
+
...strippedOptions,
|
|
164
|
+
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
165
|
+
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
166
|
+
};
|
|
167
|
+
return Content.fromJSON(deepReplaceNullsToUndefined(JSON.parse(await this.request(params))));
|
|
168
|
+
}
|
|
169
|
+
async getPagedDistinctValues(requestOptions) {
|
|
170
|
+
const { rulesetOrId, ...strippedOptions } = requestOptions;
|
|
171
|
+
const { descriptor, keys, ...strippedOptionsNoDescriptorAndKeys } = strippedOptions;
|
|
172
|
+
const params = {
|
|
173
|
+
requestId: NativePlatformRequestTypes.GetPagedDistinctValues,
|
|
174
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
175
|
+
...strippedOptionsNoDescriptorAndKeys,
|
|
176
|
+
keys: getKeysForContentRequest(keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
177
|
+
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
178
|
+
};
|
|
179
|
+
return deepReplaceNullsToUndefined(JSON.parse(await this.request(params)));
|
|
180
|
+
}
|
|
181
|
+
async getDisplayLabelDefinition(requestOptions) {
|
|
182
|
+
const params = {
|
|
183
|
+
requestId: NativePlatformRequestTypes.GetDisplayLabel,
|
|
184
|
+
...requestOptions,
|
|
185
|
+
};
|
|
186
|
+
return deepReplaceNullsToUndefined(JSON.parse(await this.request(params)));
|
|
187
|
+
}
|
|
188
|
+
async getDisplayLabelDefinitions(requestOptions) {
|
|
189
|
+
const concreteKeys = requestOptions.keys
|
|
190
|
+
.map((k) => {
|
|
191
|
+
if (k.className === "BisCore:Element") {
|
|
192
|
+
return getElementKey(requestOptions.imodel, k.id);
|
|
193
|
+
}
|
|
194
|
+
return k;
|
|
195
|
+
})
|
|
196
|
+
.filter((k) => !!k);
|
|
197
|
+
const contentRequestOptions = {
|
|
198
|
+
...requestOptions,
|
|
199
|
+
rulesetOrId: "RulesDrivenECPresentationManager_RulesetId_DisplayLabel",
|
|
200
|
+
descriptor: {
|
|
201
|
+
displayType: DefaultContentDisplayTypes.List,
|
|
202
|
+
contentFlags: ContentFlags.ShowLabels | ContentFlags.NoFields,
|
|
203
|
+
},
|
|
204
|
+
keys: new KeySet(concreteKeys),
|
|
205
|
+
};
|
|
206
|
+
const content = await this.getContent(contentRequestOptions);
|
|
207
|
+
return concreteKeys.map((key) => {
|
|
208
|
+
const item = content ? content.contentSet.find((it) => it.primaryKeys.length > 0 && InstanceKey.compare(it.primaryKeys[0], key) === 0) : undefined;
|
|
209
|
+
if (!item) {
|
|
210
|
+
return { displayValue: "", rawValue: "", typeName: "" };
|
|
211
|
+
}
|
|
212
|
+
return item.label;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/** Registers given ruleset and replaces the ruleset with its ID in the resulting object */
|
|
216
|
+
registerRuleset(rulesetOrId) {
|
|
217
|
+
if (typeof rulesetOrId === "object") {
|
|
218
|
+
const rulesetWithNativeId = { ...rulesetOrId, id: this.getRulesetId(rulesetOrId) };
|
|
219
|
+
return this.rulesets.add(rulesetWithNativeId).id;
|
|
220
|
+
}
|
|
221
|
+
return rulesetOrId;
|
|
222
|
+
}
|
|
223
|
+
/** @internal */
|
|
224
|
+
getRulesetId(rulesetOrId) {
|
|
225
|
+
return getRulesetIdObject(rulesetOrId).uniqueId;
|
|
226
|
+
}
|
|
227
|
+
async request(params) {
|
|
228
|
+
this.onUsed.raiseEvent();
|
|
229
|
+
const { requestId, imodel, unitSystem, diagnostics: requestDiagnostics, cancelEvent, ...strippedParams } = params;
|
|
230
|
+
const imodelAddon = this.getNativePlatform().getImodelAddon(imodel);
|
|
231
|
+
const response = await withOptionalDiagnostics([this._diagnosticsOptions, requestDiagnostics], async (diagnosticsOptions) => {
|
|
232
|
+
const nativeRequestParams = {
|
|
233
|
+
requestId,
|
|
234
|
+
params: {
|
|
235
|
+
unitSystem: toOptionalNativeUnitSystem(unitSystem ?? this.activeUnitSystem),
|
|
236
|
+
...strippedParams,
|
|
237
|
+
...(diagnosticsOptions ? { diagnostics: diagnosticsOptions } : undefined),
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
return this.getNativePlatform().handleRequest(imodelAddon, JSON.stringify(nativeRequestParams), cancelEvent);
|
|
241
|
+
});
|
|
242
|
+
return response.result;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async function withOptionalDiagnostics(diagnosticsOptions, nativePlatformRequestHandler) {
|
|
246
|
+
const contexts = diagnosticsOptions.map((d) => d?.requestContextSupplier?.());
|
|
247
|
+
const combinedOptions = combineDiagnosticsOptions(...diagnosticsOptions);
|
|
248
|
+
let responseDiagnostics;
|
|
249
|
+
try {
|
|
250
|
+
const response = await nativePlatformRequestHandler(combinedOptions);
|
|
251
|
+
responseDiagnostics = response.diagnostics;
|
|
252
|
+
return response;
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
if (e instanceof PresentationNativePlatformResponseError) {
|
|
256
|
+
responseDiagnostics = e.diagnostics;
|
|
257
|
+
}
|
|
258
|
+
throw e;
|
|
259
|
+
/* c8 ignore next */
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
if (responseDiagnostics) {
|
|
263
|
+
const diagnostics = { logs: [responseDiagnostics] };
|
|
264
|
+
diagnosticsOptions.forEach((options, i) => {
|
|
265
|
+
options && reportDiagnostics(diagnostics, options, contexts[i]);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function setupRulesets(nativePlatform, supplementalRulesetDirectories, primaryRulesetDirectories) {
|
|
271
|
+
nativePlatform.addRuleset(JSON.stringify(elementPropertiesRuleset));
|
|
272
|
+
nativePlatform.registerSupplementalRuleset(JSON.stringify(bisSupplementalRuleset));
|
|
273
|
+
nativePlatform.registerSupplementalRuleset(JSON.stringify(funcSupplementalRuleset));
|
|
274
|
+
nativePlatform.setupSupplementalRulesetDirectories(collateAssetDirectories(supplementalRulesetDirectories));
|
|
275
|
+
nativePlatform.setupRulesetDirectories(collateAssetDirectories(primaryRulesetDirectories));
|
|
276
|
+
}
|
|
277
|
+
/** @internal */
|
|
278
|
+
export function getRulesetIdObject(rulesetOrId) {
|
|
279
|
+
if (typeof rulesetOrId === "object") {
|
|
280
|
+
if (IpcHost.isValid) {
|
|
281
|
+
// in case of native apps we don't want to enforce ruleset id uniqueness as ruleset variables
|
|
282
|
+
// are stored on a backend and creating new id will lose those variables
|
|
283
|
+
return {
|
|
284
|
+
uniqueId: rulesetOrId.id,
|
|
285
|
+
parts: { id: rulesetOrId.id },
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const hashedId = hash.MD5(rulesetOrId);
|
|
289
|
+
return {
|
|
290
|
+
uniqueId: `${rulesetOrId.id}-${hashedId}`,
|
|
291
|
+
parts: {
|
|
292
|
+
id: rulesetOrId.id,
|
|
293
|
+
hash: hashedId,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
return { uniqueId: rulesetOrId, parts: { id: rulesetOrId } };
|
|
298
|
+
}
|
|
299
|
+
/** @internal */
|
|
300
|
+
export function getKeysForContentRequest(keys, classInstanceKeysProcessor) {
|
|
301
|
+
const result = {
|
|
302
|
+
instanceKeys: [],
|
|
303
|
+
nodeKeys: [],
|
|
304
|
+
};
|
|
305
|
+
const classInstancesMap = new Map();
|
|
306
|
+
keys.forEach((key) => {
|
|
307
|
+
if (Key.isNodeKey(key)) {
|
|
308
|
+
result.nodeKeys.push(key);
|
|
309
|
+
}
|
|
310
|
+
if (Key.isInstanceKey(key)) {
|
|
311
|
+
addInstanceKey(classInstancesMap, key);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
if (classInstanceKeysProcessor) {
|
|
315
|
+
classInstanceKeysProcessor(classInstancesMap);
|
|
316
|
+
}
|
|
317
|
+
for (const entry of classInstancesMap) {
|
|
318
|
+
if (entry[1].size > 0) {
|
|
319
|
+
result.instanceKeys.push([entry["0"], [...entry[1]]]);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
/** @internal */
|
|
325
|
+
export function bisElementInstanceKeysProcessor(imodel, classInstancesMap) {
|
|
326
|
+
const elementClassName = "BisCore:Element";
|
|
327
|
+
const elementIds = classInstancesMap.get(elementClassName);
|
|
328
|
+
if (elementIds) {
|
|
329
|
+
const deleteElementIds = new Array();
|
|
330
|
+
elementIds.forEach((elementId) => {
|
|
331
|
+
const concreteKey = getElementKey(imodel, elementId);
|
|
332
|
+
if (concreteKey && concreteKey.className !== elementClassName) {
|
|
333
|
+
deleteElementIds.push(elementId);
|
|
334
|
+
addInstanceKey(classInstancesMap, { className: concreteKey.className, id: elementId });
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
for (const id of deleteElementIds) {
|
|
338
|
+
elementIds.delete(id);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function addInstanceKey(classInstancesMap, key) {
|
|
343
|
+
let set = classInstancesMap.get(key.className);
|
|
344
|
+
if (!set) {
|
|
345
|
+
set = new Set();
|
|
346
|
+
classInstancesMap.set(key.className, set);
|
|
347
|
+
}
|
|
348
|
+
set.add(key.id);
|
|
349
|
+
}
|
|
350
|
+
function createNativePlatform(id, workerThreadsCount, updateCallback, caching, defaultFormats, useMmap) {
|
|
351
|
+
return new (createDefaultNativePlatform({
|
|
352
|
+
id,
|
|
353
|
+
taskAllocationsMap: { [Number.MAX_SAFE_INTEGER]: workerThreadsCount },
|
|
354
|
+
updateCallback,
|
|
355
|
+
cacheConfig: createCacheConfig(caching?.hierarchies),
|
|
356
|
+
contentCacheSize: caching?.content?.size,
|
|
357
|
+
workerConnectionCacheSize: caching?.workerConnectionCacheSize,
|
|
358
|
+
defaultFormats: toNativeUnitFormatsMap(defaultFormats),
|
|
359
|
+
useMmap,
|
|
360
|
+
}))();
|
|
361
|
+
function createCacheConfig(config) {
|
|
362
|
+
switch (config?.mode) {
|
|
363
|
+
case HierarchyCacheMode.Disk:
|
|
364
|
+
return { ...config, directory: normalizeDirectory(config.directory) };
|
|
365
|
+
case HierarchyCacheMode.Hybrid:
|
|
366
|
+
return {
|
|
367
|
+
...config,
|
|
368
|
+
disk: config.disk ? { ...config.disk, directory: normalizeDirectory(config.disk.directory) } : undefined,
|
|
369
|
+
};
|
|
370
|
+
case HierarchyCacheMode.Memory:
|
|
371
|
+
return config;
|
|
372
|
+
default:
|
|
373
|
+
return { mode: HierarchyCacheMode.Disk, directory: "" };
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function normalizeDirectory(directory) {
|
|
377
|
+
return directory ? path.resolve(directory) : "";
|
|
378
|
+
}
|
|
379
|
+
function toNativeUnitFormatsMap(map) {
|
|
380
|
+
if (!map) {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
const nativeFormatsMap = {};
|
|
384
|
+
Object.entries(map).forEach(([phenomenon, formats]) => {
|
|
385
|
+
nativeFormatsMap[phenomenon] = (Array.isArray(formats) ? formats : [formats]).map((unitSystemsFormat) => ({
|
|
386
|
+
unitSystems: unitSystemsFormat.unitSystems.map(toNativeUnitSystem),
|
|
387
|
+
format: unitSystemsFormat.format,
|
|
388
|
+
}));
|
|
389
|
+
});
|
|
390
|
+
return nativeFormatsMap;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function toOptionalNativeUnitSystem(unitSystem) {
|
|
394
|
+
return unitSystem ? toNativeUnitSystem(unitSystem) : undefined;
|
|
395
|
+
}
|
|
396
|
+
function toNativeUnitSystem(unitSystem) {
|
|
397
|
+
switch (unitSystem) {
|
|
398
|
+
case "imperial":
|
|
399
|
+
return NativePresentationUnitSystem.BritishImperial;
|
|
400
|
+
case "metric":
|
|
401
|
+
return NativePresentationUnitSystem.Metric;
|
|
402
|
+
case "usCustomary":
|
|
403
|
+
return NativePresentationUnitSystem.UsCustomary;
|
|
404
|
+
case "usSurvey":
|
|
405
|
+
return NativePresentationUnitSystem.UsSurvey;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function collateAssetDirectories(dirs) {
|
|
409
|
+
return [...new Set(dirs)];
|
|
410
|
+
}
|
|
411
|
+
const createContentDescriptorOverrides = (descriptorOrOverrides) => {
|
|
412
|
+
if (descriptorOrOverrides instanceof Descriptor) {
|
|
413
|
+
return descriptorOrOverrides.createDescriptorOverrides();
|
|
414
|
+
}
|
|
415
|
+
return descriptorOrOverrides;
|
|
416
|
+
};
|
|
417
|
+
function parseUpdateInfo(info) {
|
|
418
|
+
if (info === undefined) {
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
const parsedInfo = {};
|
|
422
|
+
for (const fileName in info) {
|
|
423
|
+
/* c8 ignore next 3 */
|
|
424
|
+
if (!info.hasOwnProperty(fileName)) {
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
const imodelDb = IModelDb.findByFilename(fileName);
|
|
428
|
+
if (!imodelDb) {
|
|
429
|
+
Logger.logError(PresentationBackendLoggerCategory.PresentationManager, `Update records IModelDb not found with path ${fileName}`);
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
parsedInfo[imodelDb.getRpcProps().key] = info[fileName];
|
|
433
|
+
}
|
|
434
|
+
return Object.keys(parsedInfo).length > 0 ? parsedInfo : undefined;
|
|
435
|
+
}
|
|
436
|
+
/** @internal */
|
|
437
|
+
export function ipcUpdatesHandler(info) {
|
|
438
|
+
const parsed = parseUpdateInfo(info);
|
|
439
|
+
if (parsed) {
|
|
440
|
+
IpcHost.send(PresentationIpcEvents.Update, parsed);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/** @internal */
|
|
444
|
+
/* c8 ignore next */
|
|
445
|
+
export function noopUpdatesHandler(_info) { }
|
|
446
|
+
//# sourceMappingURL=PresentationManagerDetail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationManagerDetail.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManagerDetail.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,sDAAsD;AACtD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAkB,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAEL,OAAO,EAEP,YAAY,EAGZ,0BAA0B,EAC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;AACrE,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,iBAAiB,CAAC,IAA4B;IAC5D,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,gBAAgB;AAChB,oBAAoB;AACpB,MAAM,UAAU,kBAAkB,CAAC,KAA6B,IAAG,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/* eslint-disable @typescript-eslint/ban-ts-comment */\r\nimport * as hash from \"object-hash\";\r\nimport * as path from \"path\";\r\nimport { IModelDb, IModelJsNative, IpcHost } from \"@itwin/core-backend\";\r\nimport { BeEvent, Logger } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport {\r\n CompressedClassInfoJSON,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DiagnosticsOptions,\r\n DiagnosticsScopeLogs,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyRequestOptions,\r\n InstanceKey,\r\n Item,\r\n ItemJSON,\r\n Key,\r\n KeySet,\r\n LabelDefinition,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SelectClassInfoJSON,\r\n UpdateInfo,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport { deepReplaceNullsToUndefined, PresentationIpcEvents } from \"@itwin/presentation-common/internal\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory.js\";\r\nimport {\r\n createDefaultNativePlatform,\r\n NativePlatformDefinition,\r\n NativePlatformRequestTypes,\r\n NativePlatformResponse,\r\n NativePresentationDefaultUnitFormats,\r\n NativePresentationKeySetJSON,\r\n NativePresentationUnitSystem,\r\n PresentationNativePlatformResponseError,\r\n} from \"./NativePlatform.js\";\r\nimport { HierarchyCacheConfig, HierarchyCacheMode, PresentationManagerProps } from \"./PresentationManager.js\";\r\n// @ts-ignore TS complains about `with` in CJS builds, but not ESM\r\nimport elementPropertiesRuleset from \"./primary-presentation-rules/ElementProperties.PresentationRuleSet.json\" with { type: \"json\" };\r\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager.js\";\r\n// @ts-ignore TS complains about `with` in CJS builds, but not ESM\r\nimport bisSupplementalRuleset from \"./supplemental-presentation-rules/BisCore.PresentationRuleSet.json\" with { type: \"json\" };\r\n// @ts-ignore TS complains about `with` in CJS builds, but not ESM\r\nimport funcSupplementalRuleset from \"./supplemental-presentation-rules/Functional.PresentationRuleSet.json\" with { type: \"json\" };\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, combineDiagnosticsOptions, getElementKey, reportDiagnostics } from \"./Utils.js\";\r\n\r\n/**\r\n * Produce content descriptor that is not intended for querying content. Allows the implementation to omit certain\r\n * operations to make obtaining content descriptor faster.\r\n * @internal\r\n */\r\nexport const DESCRIPTOR_ONLY_CONTENT_FLAG = 1 << 9;\r\n\r\ninterface PresentationManagerDetailProps extends PresentationManagerProps {\r\n id?: string;\r\n addon?: NativePlatformDefinition;\r\n}\r\n\r\n/** @internal */\r\nexport class PresentationManagerDetail implements Disposable {\r\n private _disposed: boolean;\r\n private _nativePlatform: NativePlatformDefinition | undefined;\r\n private _diagnosticsOptions: BackendDiagnosticsOptions | undefined;\r\n\r\n public rulesets: RulesetManager;\r\n public activeUnitSystem: UnitSystemKey | undefined;\r\n public readonly onUsed: BeEvent<() => void>;\r\n\r\n constructor(params: PresentationManagerDetailProps) {\r\n this._disposed = false;\r\n\r\n this._nativePlatform =\r\n params.addon ??\r\n createNativePlatform(\r\n params.id ?? \"\",\r\n params.workerThreadsCount ?? 2,\r\n IpcHost.isValid ? ipcUpdatesHandler : noopUpdatesHandler,\r\n params.caching,\r\n params.defaultFormats,\r\n params.useMmap,\r\n );\r\n\r\n setupRulesets(this._nativePlatform, params.supplementalRulesetDirectories ?? [], params.rulesetDirectories ?? []);\r\n this.activeUnitSystem = params.defaultUnitSystem;\r\n\r\n this.onUsed = new BeEvent();\r\n this.rulesets = new RulesetManagerImpl(() => this.getNativePlatform());\r\n this._diagnosticsOptions = params.diagnostics;\r\n }\r\n\r\n public [Symbol.dispose](): void {\r\n if (this._disposed) {\r\n return;\r\n }\r\n\r\n this.getNativePlatform()[Symbol.dispose]();\r\n this._nativePlatform = undefined;\r\n this.onUsed.clear();\r\n\r\n this._disposed = true;\r\n }\r\n\r\n public getNativePlatform(): NativePlatformDefinition {\r\n if (this._disposed) {\r\n throw new Error(\"Attempting to use Presentation manager after disposal\");\r\n }\r\n return this._nativePlatform!;\r\n }\r\n\r\n public async getNodes(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<string> {\r\n const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: parentKey ? NativePlatformRequestTypes.GetChildren : NativePlatformRequestTypes.GetRootNodes,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n nodeKey: parentKey,\r\n };\r\n return this.request(params);\r\n }\r\n\r\n public async getNodesCount(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: parentKey ? NativePlatformRequestTypes.GetChildrenCount : NativePlatformRequestTypes.GetRootNodesCount,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n nodeKey: parentKey,\r\n };\r\n return JSON.parse(await this.request(params));\r\n }\r\n\r\n public async getNodesDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<string> {\r\n const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetNodesDescriptor,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n nodeKey: parentKey,\r\n };\r\n return this.request(params);\r\n }\r\n\r\n public async getNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const { rulesetOrId, instancePaths, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetNodePaths,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n paths: instancePaths,\r\n };\r\n const paths: NodePathElement[] = deepReplaceNullsToUndefined(JSON.parse(await this.request(params)));\r\n return paths;\r\n }\r\n\r\n public async getFilteredNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const { rulesetOrId, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetFilteredNodePaths,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n };\r\n const paths: NodePathElement[] = deepReplaceNullsToUndefined(JSON.parse(await this.request(params)));\r\n return paths;\r\n }\r\n\r\n public async getContentDescriptor(requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet>>>): Promise<string> {\r\n const { rulesetOrId, contentFlags, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetContentDescriptor,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n contentFlags: contentFlags ?? DESCRIPTOR_ONLY_CONTENT_FLAG, // only set \"descriptor only\" flag if there are no flags provided\r\n keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),\r\n };\r\n return this.request(params);\r\n }\r\n\r\n public async getContentSources(\r\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<SelectClassInfo[]> {\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetContentSources,\r\n rulesetId: \"ElementProperties\",\r\n ...requestOptions,\r\n };\r\n const json: {\r\n sources: SelectClassInfoJSON<string>[];\r\n classesMap: { [id: string]: CompressedClassInfoJSON };\r\n } = JSON.parse(await this.request(params));\r\n return deepReplaceNullsToUndefined(json.sources.map((sourceJson) => SelectClassInfo.fromCompressedJSON(sourceJson, json.classesMap)));\r\n }\r\n\r\n public async getContentSetSize(\r\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetContentSetSize,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),\r\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\r\n };\r\n return JSON.parse(await this.request(params));\r\n }\r\n\r\n public async getContentSet(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<Item[]> {\r\n const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetContentSet,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),\r\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\r\n };\r\n return JSON.parse(await this.request(params))\r\n .map((json: ItemJSON) => Item.fromJSON(deepReplaceNullsToUndefined(json)))\r\n .filter((item: Item | undefined): item is Item => !!item);\r\n }\r\n\r\n public async getContent(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<Content | undefined> {\r\n const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetContent,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptions,\r\n keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),\r\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\r\n };\r\n return Content.fromJSON(deepReplaceNullsToUndefined(JSON.parse(await this.request(params))));\r\n }\r\n\r\n public async getPagedDistinctValues(\r\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<PagedResponse<DisplayValueGroup>> {\r\n const { rulesetOrId, ...strippedOptions } = requestOptions;\r\n const { descriptor, keys, ...strippedOptionsNoDescriptorAndKeys } = strippedOptions;\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetPagedDistinctValues,\r\n rulesetId: this.registerRuleset(rulesetOrId),\r\n ...strippedOptionsNoDescriptorAndKeys,\r\n keys: getKeysForContentRequest(keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),\r\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\r\n };\r\n return deepReplaceNullsToUndefined(JSON.parse(await this.request(params)));\r\n }\r\n\r\n public async getDisplayLabelDefinition(\r\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n const params = {\r\n requestId: NativePlatformRequestTypes.GetDisplayLabel,\r\n ...requestOptions,\r\n };\r\n return deepReplaceNullsToUndefined(JSON.parse(await this.request(params)));\r\n }\r\n\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition[]> {\r\n const concreteKeys = requestOptions.keys\r\n .map((k) => {\r\n if (k.className === \"BisCore:Element\") {\r\n return getElementKey(requestOptions.imodel, k.id);\r\n }\r\n return k;\r\n })\r\n .filter<InstanceKey>((k): k is InstanceKey => !!k);\r\n const contentRequestOptions: ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet> = {\r\n ...requestOptions,\r\n rulesetOrId: \"RulesDrivenECPresentationManager_RulesetId_DisplayLabel\",\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.List,\r\n contentFlags: ContentFlags.ShowLabels | ContentFlags.NoFields,\r\n },\r\n keys: new KeySet(concreteKeys),\r\n };\r\n const content = await this.getContent(contentRequestOptions);\r\n return concreteKeys.map((key) => {\r\n const item = content ? content.contentSet.find((it) => it.primaryKeys.length > 0 && InstanceKey.compare(it.primaryKeys[0], key) === 0) : undefined;\r\n if (!item) {\r\n return { displayValue: \"\", rawValue: \"\", typeName: \"\" };\r\n }\r\n return item.label;\r\n });\r\n }\r\n\r\n /** Registers given ruleset and replaces the ruleset with its ID in the resulting object */\r\n public registerRuleset(rulesetOrId: Ruleset | string): string {\r\n if (typeof rulesetOrId === \"object\") {\r\n const rulesetWithNativeId = { ...rulesetOrId, id: this.getRulesetId(rulesetOrId) };\r\n return this.rulesets.add(rulesetWithNativeId).id;\r\n }\r\n\r\n return rulesetOrId;\r\n }\r\n\r\n /** @internal */\r\n public getRulesetId(rulesetOrId: Ruleset | string): string {\r\n return getRulesetIdObject(rulesetOrId).uniqueId;\r\n }\r\n\r\n public async request(params: RequestParams): Promise<string> {\r\n this.onUsed.raiseEvent();\r\n const { requestId, imodel, unitSystem, diagnostics: requestDiagnostics, cancelEvent, ...strippedParams } = params;\r\n const imodelAddon = this.getNativePlatform().getImodelAddon(imodel);\r\n const response = await withOptionalDiagnostics([this._diagnosticsOptions, requestDiagnostics], async (diagnosticsOptions) => {\r\n const nativeRequestParams: any = {\r\n requestId,\r\n params: {\r\n unitSystem: toOptionalNativeUnitSystem(unitSystem ?? this.activeUnitSystem),\r\n ...strippedParams,\r\n ...(diagnosticsOptions ? { diagnostics: diagnosticsOptions } : undefined),\r\n },\r\n };\r\n return this.getNativePlatform().handleRequest(imodelAddon, JSON.stringify(nativeRequestParams), cancelEvent);\r\n });\r\n return response.result;\r\n }\r\n}\r\n\r\nasync function withOptionalDiagnostics(\r\n diagnosticsOptions: Array<BackendDiagnosticsOptions | undefined>,\r\n nativePlatformRequestHandler: (combinedDiagnosticsOptions: DiagnosticsOptions | undefined) => Promise<NativePlatformResponse<string>>,\r\n): Promise<NativePlatformResponse<string>> {\r\n const contexts = diagnosticsOptions.map((d) => d?.requestContextSupplier?.());\r\n const combinedOptions = combineDiagnosticsOptions(...diagnosticsOptions);\r\n let responseDiagnostics: DiagnosticsScopeLogs | undefined;\r\n try {\r\n const response = await nativePlatformRequestHandler(combinedOptions);\r\n responseDiagnostics = response.diagnostics;\r\n return response;\r\n } catch (e) {\r\n if (e instanceof PresentationNativePlatformResponseError) {\r\n responseDiagnostics = e.diagnostics;\r\n }\r\n throw e;\r\n /* c8 ignore next */\r\n } finally {\r\n if (responseDiagnostics) {\r\n const diagnostics = { logs: [responseDiagnostics] };\r\n diagnosticsOptions.forEach((options, i) => {\r\n options && reportDiagnostics(diagnostics, options, contexts[i]);\r\n });\r\n }\r\n }\r\n}\r\n\r\ninterface RequestParams {\r\n diagnostics?: BackendDiagnosticsOptions;\r\n requestId: string;\r\n imodel: IModelDb;\r\n unitSystem?: UnitSystemKey;\r\n cancelEvent?: BeEvent<() => void>;\r\n}\r\n\r\nfunction setupRulesets(nativePlatform: NativePlatformDefinition, supplementalRulesetDirectories: string[], primaryRulesetDirectories: string[]): void {\r\n nativePlatform.addRuleset(JSON.stringify(elementPropertiesRuleset));\r\n nativePlatform.registerSupplementalRuleset(JSON.stringify(bisSupplementalRuleset));\r\n nativePlatform.registerSupplementalRuleset(JSON.stringify(funcSupplementalRuleset));\r\n nativePlatform.setupSupplementalRulesetDirectories(collateAssetDirectories(supplementalRulesetDirectories));\r\n nativePlatform.setupRulesetDirectories(collateAssetDirectories(primaryRulesetDirectories));\r\n}\r\n\r\ninterface RulesetIdObject {\r\n uniqueId: string;\r\n parts: {\r\n id: string;\r\n hash?: string;\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getRulesetIdObject(rulesetOrId: Ruleset | string): RulesetIdObject {\r\n if (typeof rulesetOrId === \"object\") {\r\n if (IpcHost.isValid) {\r\n // in case of native apps we don't want to enforce ruleset id uniqueness as ruleset variables\r\n // are stored on a backend and creating new id will lose those variables\r\n return {\r\n uniqueId: rulesetOrId.id,\r\n parts: { id: rulesetOrId.id },\r\n };\r\n }\r\n\r\n const hashedId = hash.MD5(rulesetOrId);\r\n return {\r\n uniqueId: `${rulesetOrId.id}-${hashedId}`,\r\n parts: {\r\n id: rulesetOrId.id,\r\n hash: hashedId,\r\n },\r\n };\r\n }\r\n\r\n return { uniqueId: rulesetOrId, parts: { id: rulesetOrId } };\r\n}\r\n\r\n/** @internal */\r\nexport function getKeysForContentRequest(\r\n keys: Readonly<KeySet>,\r\n classInstanceKeysProcessor?: (keys: Map<string, Set<string>>) => void,\r\n): NativePresentationKeySetJSON {\r\n const result: NativePresentationKeySetJSON = {\r\n instanceKeys: [],\r\n nodeKeys: [],\r\n };\r\n const classInstancesMap = new Map<string, Set<string>>();\r\n keys.forEach((key) => {\r\n if (Key.isNodeKey(key)) {\r\n result.nodeKeys.push(key);\r\n }\r\n\r\n if (Key.isInstanceKey(key)) {\r\n addInstanceKey(classInstancesMap, key);\r\n }\r\n });\r\n\r\n if (classInstanceKeysProcessor) {\r\n classInstanceKeysProcessor(classInstancesMap);\r\n }\r\n\r\n for (const entry of classInstancesMap) {\r\n if (entry[1].size > 0) {\r\n result.instanceKeys.push([entry[\"0\"], [...entry[1]]]);\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/** @internal */\r\nexport function bisElementInstanceKeysProcessor(imodel: IModelDb, classInstancesMap: Map<string, Set<string>>) {\r\n const elementClassName = \"BisCore:Element\";\r\n const elementIds = classInstancesMap.get(elementClassName);\r\n if (elementIds) {\r\n const deleteElementIds = new Array<string>();\r\n elementIds.forEach((elementId) => {\r\n const concreteKey = getElementKey(imodel, elementId);\r\n if (concreteKey && concreteKey.className !== elementClassName) {\r\n deleteElementIds.push(elementId);\r\n addInstanceKey(classInstancesMap, { className: concreteKey.className, id: elementId });\r\n }\r\n });\r\n for (const id of deleteElementIds) {\r\n elementIds.delete(id);\r\n }\r\n }\r\n}\r\n\r\nfunction addInstanceKey(classInstancesMap: Map<string, Set<string>>, key: InstanceKey): void {\r\n let set = classInstancesMap.get(key.className);\r\n if (!set) {\r\n set = new Set();\r\n classInstancesMap.set(key.className, set);\r\n }\r\n set.add(key.id);\r\n}\r\n\r\nfunction createNativePlatform(\r\n id: string,\r\n workerThreadsCount: number,\r\n updateCallback: (updateInfo: UpdateInfo | undefined) => void,\r\n caching: PresentationManagerProps[\"caching\"],\r\n defaultFormats: FormatsMap | undefined,\r\n useMmap: boolean | number | undefined,\r\n): NativePlatformDefinition {\r\n return new (createDefaultNativePlatform({\r\n id,\r\n taskAllocationsMap: { [Number.MAX_SAFE_INTEGER]: workerThreadsCount },\r\n updateCallback,\r\n cacheConfig: createCacheConfig(caching?.hierarchies),\r\n contentCacheSize: caching?.content?.size,\r\n workerConnectionCacheSize: caching?.workerConnectionCacheSize,\r\n defaultFormats: toNativeUnitFormatsMap(defaultFormats),\r\n useMmap,\r\n }))();\r\n\r\n function createCacheConfig(config?: HierarchyCacheConfig): IModelJsNative.ECPresentationHierarchyCacheConfig {\r\n switch (config?.mode) {\r\n case HierarchyCacheMode.Disk:\r\n return { ...config, directory: normalizeDirectory(config.directory) };\r\n\r\n case HierarchyCacheMode.Hybrid:\r\n return {\r\n ...config,\r\n disk: config.disk ? { ...config.disk, directory: normalizeDirectory(config.disk.directory) } : undefined,\r\n };\r\n\r\n case HierarchyCacheMode.Memory:\r\n return config;\r\n\r\n default:\r\n return { mode: HierarchyCacheMode.Disk, directory: \"\" };\r\n }\r\n }\r\n\r\n function normalizeDirectory(directory?: string): string {\r\n return directory ? path.resolve(directory) : \"\";\r\n }\r\n\r\n function toNativeUnitFormatsMap(map: FormatsMap | undefined): NativePresentationDefaultUnitFormats | undefined {\r\n if (!map) {\r\n return undefined;\r\n }\r\n\r\n const nativeFormatsMap: NativePresentationDefaultUnitFormats = {};\r\n Object.entries(map).forEach(([phenomenon, formats]) => {\r\n nativeFormatsMap[phenomenon] = (Array.isArray(formats) ? formats : [formats]).map((unitSystemsFormat) => ({\r\n unitSystems: unitSystemsFormat.unitSystems.map(toNativeUnitSystem),\r\n format: unitSystemsFormat.format,\r\n }));\r\n });\r\n return nativeFormatsMap;\r\n }\r\n}\r\n\r\nfunction toOptionalNativeUnitSystem(unitSystem: UnitSystemKey | undefined): NativePresentationUnitSystem | undefined {\r\n return unitSystem ? toNativeUnitSystem(unitSystem) : undefined;\r\n}\r\n\r\nfunction toNativeUnitSystem(unitSystem: UnitSystemKey): NativePresentationUnitSystem {\r\n switch (unitSystem) {\r\n case \"imperial\":\r\n return NativePresentationUnitSystem.BritishImperial;\r\n case \"metric\":\r\n return NativePresentationUnitSystem.Metric;\r\n case \"usCustomary\":\r\n return NativePresentationUnitSystem.UsCustomary;\r\n case \"usSurvey\":\r\n return NativePresentationUnitSystem.UsSurvey;\r\n }\r\n}\r\n\r\nfunction collateAssetDirectories(dirs: string[]): string[] {\r\n return [...new Set(dirs)];\r\n}\r\nconst createContentDescriptorOverrides = (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\nfunction parseUpdateInfo(info: UpdateInfo | undefined) {\r\n if (info === undefined) {\r\n return undefined;\r\n }\r\n\r\n const parsedInfo: UpdateInfo = {};\r\n for (const fileName in info) {\r\n /* c8 ignore next 3 */\r\n if (!info.hasOwnProperty(fileName)) {\r\n continue;\r\n }\r\n\r\n const imodelDb = IModelDb.findByFilename(fileName);\r\n if (!imodelDb) {\r\n Logger.logError(PresentationBackendLoggerCategory.PresentationManager, `Update records IModelDb not found with path ${fileName}`);\r\n continue;\r\n }\r\n\r\n parsedInfo[imodelDb.getRpcProps().key] = info[fileName];\r\n }\r\n return Object.keys(parsedInfo).length > 0 ? parsedInfo : undefined;\r\n}\r\n\r\n/** @internal */\r\nexport function ipcUpdatesHandler(info: UpdateInfo | undefined) {\r\n const parsed = parseUpdateInfo(info);\r\n if (parsed) {\r\n IpcHost.send(PresentationIpcEvents.Update, parsed);\r\n }\r\n}\r\n\r\n/** @internal */\r\n/* c8 ignore next */\r\nexport function noopUpdatesHandler(_info: UpdateInfo | undefined) {}\r\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module RPC
|
|
3
|
+
*/
|
|
4
|
+
import { IModelRpcProps } from "@itwin/core-common";
|
|
5
|
+
import { ComputeSelectionRpcRequestOptions, ContentDescriptorRpcRequestOptions, ContentInstanceKeysRpcRequestOptions, ContentRpcRequestOptions, ContentSourcesRpcRequestOptions, ContentSourcesRpcResult, DescriptorJSON, DisplayLabelRpcRequestOptions, DisplayLabelsRpcRequestOptions, DisplayValueGroup, DistinctValuesRpcRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRpcRequestOptions, FilterByTextHierarchyRpcRequestOptions, HierarchyLevelDescriptorRpcRequestOptions, HierarchyRpcRequestOptions, ItemJSON, KeySetJSON, LabelDefinition, Node, NodePathElement, Paged, PagedResponse, PresentationRpcInterface, PresentationRpcResponse, SelectionScope, SelectionScopeRpcRequestOptions, SingleElementPropertiesRpcRequestOptions } from "@itwin/presentation-common";
|
|
6
|
+
import { PresentationManager } from "./PresentationManager.js";
|
|
7
|
+
import { TemporaryStorage } from "./TemporaryStorage.js";
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare const MAX_ALLOWED_PAGE_SIZE = 1000;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;
|
|
12
|
+
/**
|
|
13
|
+
* The backend implementation of PresentationRpcInterface. All it's basically
|
|
14
|
+
* responsible for is forwarding calls to [[Presentation.manager]].
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare class PresentationRpcImpl extends PresentationRpcInterface implements Disposable {
|
|
19
|
+
private _requestTimeout;
|
|
20
|
+
private _pendingRequests;
|
|
21
|
+
private _cancelEvents;
|
|
22
|
+
private _statusHandler;
|
|
23
|
+
constructor(props?: {
|
|
24
|
+
requestTimeout?: number;
|
|
25
|
+
});
|
|
26
|
+
[Symbol.dispose](): void;
|
|
27
|
+
get requestTimeout(): number;
|
|
28
|
+
get pendingRequests(): TemporaryStorage<PresentationRpcResponse<any>>;
|
|
29
|
+
/** Returns an ok response with result inside */
|
|
30
|
+
private successResponse;
|
|
31
|
+
/** Returns a bad request response with empty result and an error code */
|
|
32
|
+
private errorResponse;
|
|
33
|
+
/**
|
|
34
|
+
* Get the [[PresentationManager]] used by this RPC impl.
|
|
35
|
+
*/
|
|
36
|
+
getManager(clientId?: string): PresentationManager;
|
|
37
|
+
private getIModel;
|
|
38
|
+
private makeRequest;
|
|
39
|
+
getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number>;
|
|
40
|
+
getPagedNodes(token: IModelRpcProps, requestOptions: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<Node>>;
|
|
41
|
+
getNodesDescriptor(token: IModelRpcProps, requestOptions: HierarchyLevelDescriptorRpcRequestOptions): PresentationRpcResponse<string | DescriptorJSON | undefined>;
|
|
42
|
+
getNodePaths(token: IModelRpcProps, requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElement[]>;
|
|
43
|
+
getFilteredNodePaths(token: IModelRpcProps, requestOptions: FilterByTextHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElement[]>;
|
|
44
|
+
getContentSources(token: IModelRpcProps, requestOptions: ContentSourcesRpcRequestOptions): PresentationRpcResponse<ContentSourcesRpcResult>;
|
|
45
|
+
getContentDescriptor(token: IModelRpcProps, requestOptions: ContentDescriptorRpcRequestOptions): PresentationRpcResponse<DescriptorJSON | undefined>;
|
|
46
|
+
getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number>;
|
|
47
|
+
getPagedContent(token: IModelRpcProps, requestOptions: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<{
|
|
48
|
+
descriptor: DescriptorJSON;
|
|
49
|
+
contentSet: PagedResponse<ItemJSON>;
|
|
50
|
+
} | undefined>;
|
|
51
|
+
getPagedContentSet(token: IModelRpcProps, requestOptions: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<PagedResponse<ItemJSON>>;
|
|
52
|
+
getElementProperties(token: IModelRpcProps, requestOptions: SingleElementPropertiesRpcRequestOptions): PresentationRpcResponse<ElementProperties | undefined>;
|
|
53
|
+
getPagedDistinctValues(token: IModelRpcProps, requestOptions: DistinctValuesRpcRequestOptions): PresentationRpcResponse<PagedResponse<DisplayValueGroup>>;
|
|
54
|
+
getContentInstanceKeys(token: IModelRpcProps, requestOptions: ContentInstanceKeysRpcRequestOptions): PresentationRpcResponse<{
|
|
55
|
+
total: number;
|
|
56
|
+
items: KeySetJSON;
|
|
57
|
+
}>;
|
|
58
|
+
getDisplayLabelDefinition(token: IModelRpcProps, requestOptions: DisplayLabelRpcRequestOptions): PresentationRpcResponse<LabelDefinition>;
|
|
59
|
+
getPagedDisplayLabelDefinitions(token: IModelRpcProps, requestOptions: DisplayLabelsRpcRequestOptions): PresentationRpcResponse<PagedResponse<LabelDefinition>>;
|
|
60
|
+
getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]>;
|
|
61
|
+
computeSelection(token: IModelRpcProps, requestOptions: ComputeSelectionRpcRequestOptions): PresentationRpcResponse<KeySetJSON>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=PresentationRpcImpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAEL,iCAAiC,EACjC,kCAAkC,EAElC,oCAAoC,EACpC,wBAAwB,EACxB,+BAA+B,EAC/B,uBAAuB,EAEvB,cA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