@itwin/presentation-backend 3.3.0-dev.46 → 3.3.0-dev.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +13 -24
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +59 -317
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +50 -0
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -0
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +277 -0
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -0
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +10 -4
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/package.json +13 -13
|
@@ -6,38 +6,14 @@
|
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
const hash = __importStar(require("object-hash"));
|
|
31
|
-
const path = __importStar(require("path"));
|
|
32
|
-
const core_backend_1 = require("@itwin/core-backend");
|
|
10
|
+
exports.PresentationManager = exports.HierarchyCacheMode = exports.PresentationManagerMode = void 0;
|
|
33
11
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
34
|
-
const Constants_1 = require("./Constants");
|
|
35
12
|
const ElementPropertiesHelper_1 = require("./ElementPropertiesHelper");
|
|
36
13
|
const NativePlatform_1 = require("./NativePlatform");
|
|
37
|
-
const
|
|
14
|
+
const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
|
|
38
15
|
const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
|
|
39
16
|
const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
|
|
40
|
-
const UpdatesTracker_1 = require("./UpdatesTracker");
|
|
41
17
|
const Utils_1 = require("./Utils");
|
|
42
18
|
/**
|
|
43
19
|
* Presentation manager working mode.
|
|
@@ -89,71 +65,32 @@ class PresentationManager {
|
|
|
89
65
|
* @param props Optional configuration properties.
|
|
90
66
|
*/
|
|
91
67
|
constructor(props) {
|
|
92
|
-
var _a, _b, _c, _d, _e;
|
|
93
68
|
/** @internal */
|
|
94
69
|
this.getNativePlatform = () => {
|
|
95
|
-
|
|
96
|
-
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.NotInitialized, "Attempting to use Presentation manager after disposal");
|
|
97
|
-
return this._nativePlatform;
|
|
70
|
+
return this._detail.getNativePlatform();
|
|
98
71
|
};
|
|
99
72
|
this._props = props !== null && props !== void 0 ? props : {};
|
|
100
|
-
this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
taskAllocationsMap: createTaskAllocationsMap(props),
|
|
111
|
-
mode,
|
|
112
|
-
isChangeTrackingEnabled,
|
|
113
|
-
cacheConfig: createCacheConfig((_c = this._props.caching) === null || _c === void 0 ? void 0 : _c.hierarchies),
|
|
114
|
-
contentCacheSize: (_e = (_d = this._props.caching) === null || _d === void 0 ? void 0 : _d.content) === null || _e === void 0 ? void 0 : _e.size,
|
|
115
|
-
defaultFormats: toNativeUnitFormatsMap(this._props.defaultFormats),
|
|
116
|
-
useMmap: this._props.useMmap,
|
|
117
|
-
});
|
|
118
|
-
this._nativePlatform = new nativePlatformImpl();
|
|
119
|
-
}
|
|
120
|
-
this.setupRulesetDirectories(props);
|
|
121
|
-
if (props) {
|
|
122
|
-
this.activeLocale = props.defaultLocale;
|
|
123
|
-
this.activeUnitSystem = props.defaultUnitSystem;
|
|
124
|
-
}
|
|
125
|
-
this._rulesets = new RulesetManager_1.RulesetManagerImpl(this.getNativePlatform);
|
|
126
|
-
if (core_backend_1.IpcHost.isValid && isChangeTrackingEnabled) {
|
|
127
|
-
this._updatesTracker = UpdatesTracker_1.UpdatesTracker.create({
|
|
128
|
-
nativePlatformGetter: this.getNativePlatform,
|
|
129
|
-
pollInterval: props.updatesPollInterval,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Dispose the presentation manager. Must be called to clean up native resources.
|
|
135
|
-
*/
|
|
73
|
+
this._detail = new PresentationManagerDetail_1.PresentationManagerDetail(this._props);
|
|
74
|
+
}
|
|
75
|
+
/** Get / set active locale used for localizing presentation data */
|
|
76
|
+
get activeLocale() { return this._detail.activeLocale; }
|
|
77
|
+
set activeLocale(value) { this._detail.activeLocale = value; }
|
|
78
|
+
/** Get / set active unit system used to format property values with units */
|
|
79
|
+
get activeUnitSystem() { return this._detail.activeUnitSystem; }
|
|
80
|
+
// istanbul ignore next
|
|
81
|
+
set activeUnitSystem(value) { this._detail.activeUnitSystem = value; }
|
|
82
|
+
/** Dispose the presentation manager. Must be called to clean up native resources. */
|
|
136
83
|
dispose() {
|
|
137
|
-
|
|
138
|
-
this.getNativePlatform().dispose();
|
|
139
|
-
this._nativePlatform = undefined;
|
|
140
|
-
}
|
|
141
|
-
if (this._updatesTracker) {
|
|
142
|
-
this._updatesTracker.dispose();
|
|
143
|
-
this._updatesTracker = undefined;
|
|
144
|
-
}
|
|
145
|
-
this._isDisposed = true;
|
|
84
|
+
this._detail.dispose();
|
|
146
85
|
}
|
|
147
86
|
/** @internal */
|
|
148
87
|
setOnManagerUsedHandler(handler) {
|
|
149
|
-
this.
|
|
88
|
+
this._detail.setOnManagerUsedHandler(handler);
|
|
150
89
|
}
|
|
151
90
|
/** Properties used to initialize the manager */
|
|
152
91
|
get props() { return this._props; }
|
|
153
|
-
/**
|
|
154
|
-
|
|
155
|
-
*/
|
|
156
|
-
rulesets() { return this._rulesets; }
|
|
92
|
+
/** Get rulesets manager */
|
|
93
|
+
rulesets() { return this._detail.rulesets; }
|
|
157
94
|
/**
|
|
158
95
|
* Get ruleset variables manager for specific ruleset
|
|
159
96
|
* @param rulesetId Id of the ruleset to get variables manager for
|
|
@@ -161,89 +98,42 @@ class PresentationManager {
|
|
|
161
98
|
vars(rulesetId) {
|
|
162
99
|
return new RulesetVariablesManager_1.RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);
|
|
163
100
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (-1 === supplementalRulesetDirectories.indexOf(dir))
|
|
169
|
-
supplementalRulesetDirectories.push(dir);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
this.getNativePlatform().setupSupplementalRulesetDirectories(supplementalRulesetDirectories);
|
|
173
|
-
const primaryRulesetDirectories = [path.join(getPresentationBackendAssetsRoot(props === null || props === void 0 ? void 0 : props.presentationAssetsRoot), "primary-presentation-rules")];
|
|
174
|
-
if (props && props.rulesetDirectories) {
|
|
175
|
-
props.rulesetDirectories.forEach((dir) => {
|
|
176
|
-
if (-1 === primaryRulesetDirectories.indexOf(dir))
|
|
177
|
-
primaryRulesetDirectories.push(dir);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
this.getNativePlatform().setupRulesetDirectories(primaryRulesetDirectories);
|
|
181
|
-
}
|
|
182
|
-
getRulesetIdObject(rulesetOrId) {
|
|
183
|
-
if (typeof rulesetOrId === "object") {
|
|
184
|
-
if (core_backend_1.IpcHost.isValid) {
|
|
185
|
-
// in case of native apps we don't want to enforce ruleset id uniqueness as ruleset variables
|
|
186
|
-
// are stored on a backend and creating new id will lose those variables
|
|
187
|
-
return {
|
|
188
|
-
uniqueId: rulesetOrId.id,
|
|
189
|
-
parts: { id: rulesetOrId.id },
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
const hashedId = hash.MD5(rulesetOrId);
|
|
193
|
-
return {
|
|
194
|
-
uniqueId: `${rulesetOrId.id}-${hashedId}`,
|
|
195
|
-
parts: {
|
|
196
|
-
id: rulesetOrId.id,
|
|
197
|
-
hash: hashedId,
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
return { uniqueId: rulesetOrId, parts: { id: rulesetOrId } };
|
|
101
|
+
/** @internal */
|
|
102
|
+
// istanbul ignore next
|
|
103
|
+
getDetail() {
|
|
104
|
+
return this._detail;
|
|
202
105
|
}
|
|
203
106
|
/** @internal */
|
|
204
107
|
getRulesetId(rulesetOrId) {
|
|
205
|
-
return this.
|
|
206
|
-
}
|
|
207
|
-
ensureRulesetRegistered(rulesetOrId) {
|
|
208
|
-
if (typeof rulesetOrId === "object") {
|
|
209
|
-
const rulesetWithNativeId = { ...rulesetOrId, id: this.getRulesetId(rulesetOrId) };
|
|
210
|
-
return this.rulesets().add(rulesetWithNativeId).id;
|
|
211
|
-
}
|
|
212
|
-
return rulesetOrId;
|
|
213
|
-
}
|
|
214
|
-
/** Registers given ruleset and replaces the ruleset with its ID in the resulting object */
|
|
215
|
-
registerRuleset(options) {
|
|
216
|
-
const { rulesetOrId, ...strippedOptions } = options;
|
|
217
|
-
const registeredRulesetId = this.ensureRulesetRegistered(rulesetOrId);
|
|
218
|
-
return { rulesetId: registeredRulesetId, strippedOptions };
|
|
108
|
+
return this._detail.getRulesetId(rulesetOrId);
|
|
219
109
|
}
|
|
220
110
|
/**
|
|
221
111
|
* Retrieves nodes
|
|
222
112
|
* @public
|
|
223
113
|
*/
|
|
224
114
|
async getNodes(requestOptions) {
|
|
225
|
-
const {
|
|
115
|
+
const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;
|
|
226
116
|
const params = {
|
|
227
117
|
requestId: parentKey ? NativePlatform_1.NativePlatformRequestTypes.GetChildren : NativePlatform_1.NativePlatformRequestTypes.GetRootNodes,
|
|
228
|
-
rulesetId,
|
|
118
|
+
rulesetId: this._detail.registerRuleset(rulesetOrId),
|
|
229
119
|
...strippedOptions,
|
|
230
120
|
nodeKey: parentKey,
|
|
231
121
|
};
|
|
232
|
-
return this.request(params, presentation_common_1.Node.listReviver);
|
|
122
|
+
return JSON.parse(await this._detail.request(params), presentation_common_1.Node.listReviver);
|
|
233
123
|
}
|
|
234
124
|
/**
|
|
235
125
|
* Retrieves nodes count
|
|
236
126
|
* @public
|
|
237
127
|
*/
|
|
238
128
|
async getNodesCount(requestOptions) {
|
|
239
|
-
const {
|
|
129
|
+
const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;
|
|
240
130
|
const params = {
|
|
241
131
|
requestId: parentKey ? NativePlatform_1.NativePlatformRequestTypes.GetChildrenCount : NativePlatform_1.NativePlatformRequestTypes.GetRootNodesCount,
|
|
242
|
-
rulesetId,
|
|
132
|
+
rulesetId: this._detail.registerRuleset(rulesetOrId),
|
|
243
133
|
...strippedOptions,
|
|
244
134
|
nodeKey: parentKey,
|
|
245
135
|
};
|
|
246
|
-
return this.request(params);
|
|
136
|
+
return JSON.parse(await this._detail.request(params));
|
|
247
137
|
}
|
|
248
138
|
/**
|
|
249
139
|
* Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
|
|
@@ -251,14 +141,14 @@ class PresentationManager {
|
|
|
251
141
|
* @public
|
|
252
142
|
*/
|
|
253
143
|
async getNodePaths(requestOptions) {
|
|
254
|
-
const {
|
|
144
|
+
const { rulesetOrId, instancePaths, ...strippedOptions } = requestOptions;
|
|
255
145
|
const params = {
|
|
256
146
|
requestId: NativePlatform_1.NativePlatformRequestTypes.GetNodePaths,
|
|
257
|
-
rulesetId,
|
|
147
|
+
rulesetId: this._detail.registerRuleset(rulesetOrId),
|
|
258
148
|
...strippedOptions,
|
|
259
149
|
paths: instancePaths.map((p) => p.map((s) => presentation_common_1.InstanceKey.toJSON(s))),
|
|
260
150
|
};
|
|
261
|
-
return this.request(params, presentation_common_1.NodePathElement.listReviver);
|
|
151
|
+
return JSON.parse(await this._detail.request(params), presentation_common_1.NodePathElement.listReviver);
|
|
262
152
|
}
|
|
263
153
|
/**
|
|
264
154
|
* Retrieves paths from root nodes to nodes containing filter text in their label.
|
|
@@ -266,13 +156,13 @@ class PresentationManager {
|
|
|
266
156
|
* @public
|
|
267
157
|
*/
|
|
268
158
|
async getFilteredNodePaths(requestOptions) {
|
|
269
|
-
const {
|
|
159
|
+
const { rulesetOrId, ...strippedOptions } = requestOptions;
|
|
270
160
|
const params = {
|
|
271
161
|
requestId: NativePlatform_1.NativePlatformRequestTypes.GetFilteredNodePaths,
|
|
272
|
-
rulesetId,
|
|
162
|
+
rulesetId: this._detail.registerRuleset(rulesetOrId),
|
|
273
163
|
...strippedOptions,
|
|
274
164
|
};
|
|
275
|
-
return this.request(params, presentation_common_1.NodePathElement.listReviver);
|
|
165
|
+
return JSON.parse(await this._detail.request(params), presentation_common_1.NodePathElement.listReviver);
|
|
276
166
|
}
|
|
277
167
|
/** @beta */
|
|
278
168
|
async getContentSources(requestOptions) {
|
|
@@ -284,55 +174,46 @@ class PresentationManager {
|
|
|
284
174
|
const reviver = (key, value) => {
|
|
285
175
|
return key === "" ? presentation_common_1.SelectClassInfo.listFromCompressedJSON(value.sources, value.classesMap) : value;
|
|
286
176
|
};
|
|
287
|
-
return this.request(params, reviver);
|
|
177
|
+
return JSON.parse(await this._detail.request(params), reviver);
|
|
288
178
|
}
|
|
289
179
|
/**
|
|
290
180
|
* Retrieves the content descriptor which can be used to get content
|
|
291
181
|
* @public
|
|
292
182
|
*/
|
|
293
183
|
async getContentDescriptor(requestOptions) {
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
rulesetId,
|
|
298
|
-
...strippedOptions,
|
|
299
|
-
contentFlags: presentation_common_1.ContentFlags.DescriptorOnly,
|
|
300
|
-
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
301
|
-
};
|
|
302
|
-
const reviver = (key, value) => {
|
|
303
|
-
return key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
|
|
304
|
-
};
|
|
305
|
-
return this.request(params, reviver);
|
|
184
|
+
const response = await this._detail.getContentDescriptor(requestOptions);
|
|
185
|
+
const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
|
|
186
|
+
return JSON.parse(response, reviver);
|
|
306
187
|
}
|
|
307
188
|
/**
|
|
308
189
|
* Retrieves the content set size based on the supplied content descriptor override
|
|
309
190
|
* @public
|
|
310
191
|
*/
|
|
311
192
|
async getContentSetSize(requestOptions) {
|
|
312
|
-
const {
|
|
193
|
+
const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;
|
|
313
194
|
const params = {
|
|
314
195
|
requestId: NativePlatform_1.NativePlatformRequestTypes.GetContentSetSize,
|
|
315
|
-
rulesetId,
|
|
196
|
+
rulesetId: this._detail.registerRuleset(rulesetOrId),
|
|
316
197
|
...strippedOptions,
|
|
317
|
-
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
198
|
+
keys: (0, PresentationManagerDetail_1.getKeysForContentRequest)(requestOptions.keys, (map) => (0, PresentationManagerDetail_1.bisElementInstanceKeysProcessor)(requestOptions.imodel, map)),
|
|
318
199
|
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
319
200
|
};
|
|
320
|
-
return this.request(params);
|
|
201
|
+
return JSON.parse(await this._detail.request(params));
|
|
321
202
|
}
|
|
322
203
|
/**
|
|
323
204
|
* Retrieves the content based on the supplied content descriptor override.
|
|
324
205
|
* @public
|
|
325
206
|
*/
|
|
326
207
|
async getContent(requestOptions) {
|
|
327
|
-
const {
|
|
208
|
+
const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;
|
|
328
209
|
const params = {
|
|
329
210
|
requestId: NativePlatform_1.NativePlatformRequestTypes.GetContent,
|
|
330
|
-
rulesetId,
|
|
211
|
+
rulesetId: this._detail.registerRuleset(rulesetOrId),
|
|
331
212
|
...strippedOptions,
|
|
332
|
-
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
213
|
+
keys: (0, PresentationManagerDetail_1.getKeysForContentRequest)(requestOptions.keys, (map) => (0, PresentationManagerDetail_1.bisElementInstanceKeysProcessor)(requestOptions.imodel, map)),
|
|
333
214
|
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
334
215
|
};
|
|
335
|
-
return this.request(params, presentation_common_1.Content.reviver);
|
|
216
|
+
return JSON.parse(await this._detail.request(params), presentation_common_1.Content.reviver);
|
|
336
217
|
}
|
|
337
218
|
/**
|
|
338
219
|
* Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
|
|
@@ -341,13 +222,13 @@ class PresentationManager {
|
|
|
341
222
|
* @public
|
|
342
223
|
*/
|
|
343
224
|
async getPagedDistinctValues(requestOptions) {
|
|
344
|
-
const {
|
|
225
|
+
const { rulesetOrId, ...strippedOptions } = requestOptions;
|
|
345
226
|
const { descriptor, keys, ...strippedOptionsNoDescriptorAndKeys } = strippedOptions;
|
|
346
227
|
const params = {
|
|
347
228
|
requestId: NativePlatform_1.NativePlatformRequestTypes.GetPagedDistinctValues,
|
|
348
|
-
rulesetId,
|
|
229
|
+
rulesetId: this._detail.registerRuleset(rulesetOrId),
|
|
349
230
|
...strippedOptionsNoDescriptorAndKeys,
|
|
350
|
-
keys: getKeysForContentRequest(keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
231
|
+
keys: (0, PresentationManagerDetail_1.getKeysForContentRequest)(keys, (map) => (0, PresentationManagerDetail_1.bisElementInstanceKeysProcessor)(requestOptions.imodel, map)),
|
|
351
232
|
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
352
233
|
};
|
|
353
234
|
const reviver = (key, value) => {
|
|
@@ -356,7 +237,7 @@ class PresentationManager {
|
|
|
356
237
|
items: value.items.map(presentation_common_1.DisplayValueGroup.fromJSON),
|
|
357
238
|
} : value;
|
|
358
239
|
};
|
|
359
|
-
return this.request(params, reviver);
|
|
240
|
+
return JSON.parse(await this._detail.request(params), reviver);
|
|
360
241
|
}
|
|
361
242
|
async getElementProperties(requestOptions) {
|
|
362
243
|
if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
|
|
@@ -414,7 +295,7 @@ class PresentationManager {
|
|
|
414
295
|
...requestOptions,
|
|
415
296
|
key: presentation_common_1.InstanceKey.toJSON(requestOptions.key),
|
|
416
297
|
};
|
|
417
|
-
return this.request(params, presentation_common_1.LabelDefinition.reviver);
|
|
298
|
+
return JSON.parse(await this._detail.request(params), presentation_common_1.LabelDefinition.reviver);
|
|
418
299
|
}
|
|
419
300
|
/**
|
|
420
301
|
* Retrieves display label definitions of specific items
|
|
@@ -458,40 +339,19 @@ class PresentationManager {
|
|
|
458
339
|
return { ...rest, elementIds: ids, scope: { id: scopeId } };
|
|
459
340
|
})());
|
|
460
341
|
}
|
|
461
|
-
async request(params, reviver) {
|
|
462
|
-
const { requestId, imodel, locale, unitSystem, diagnostics, ...strippedParams } = params;
|
|
463
|
-
if (this._onManagerUsed)
|
|
464
|
-
this._onManagerUsed();
|
|
465
|
-
const imodelAddon = this.getNativePlatform().getImodelAddon(imodel);
|
|
466
|
-
const nativeRequestParams = {
|
|
467
|
-
requestId,
|
|
468
|
-
params: {
|
|
469
|
-
locale: normalizeLocale(locale !== null && locale !== void 0 ? locale : this.activeLocale),
|
|
470
|
-
unitSystem: toOptionalNativeUnitSystem(unitSystem !== null && unitSystem !== void 0 ? unitSystem : this.activeUnitSystem),
|
|
471
|
-
...strippedParams,
|
|
472
|
-
},
|
|
473
|
-
};
|
|
474
|
-
let diagnosticsListener;
|
|
475
|
-
if (diagnostics) {
|
|
476
|
-
const { handler: tempDiagnosticsListener, ...diagnosticsOptions } = diagnostics;
|
|
477
|
-
diagnosticsListener = tempDiagnosticsListener;
|
|
478
|
-
nativeRequestParams.params.diagnostics = diagnosticsOptions;
|
|
479
|
-
}
|
|
480
|
-
const response = await this.getNativePlatform().handleRequest(imodelAddon, JSON.stringify(nativeRequestParams));
|
|
481
|
-
diagnosticsListener && response.diagnostics && diagnosticsListener({ logs: [response.diagnostics] });
|
|
482
|
-
return JSON.parse(response.result, reviver);
|
|
483
|
-
}
|
|
484
342
|
/**
|
|
485
343
|
* Compares two hierarchies specified in the request options
|
|
486
344
|
* @public
|
|
487
345
|
*/
|
|
488
346
|
async compareHierarchies(requestOptions) {
|
|
489
347
|
var _a, _b;
|
|
490
|
-
if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables)
|
|
348
|
+
if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {
|
|
491
349
|
return { changes: [] };
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
|
|
350
|
+
}
|
|
351
|
+
const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;
|
|
352
|
+
this._detail.registerRuleset(rulesetOrId);
|
|
353
|
+
const currRulesetId = (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId);
|
|
354
|
+
const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
|
|
495
355
|
if (prevRulesetId.parts.id !== currRulesetId.parts.id)
|
|
496
356
|
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "Can't compare rulesets with different IDs");
|
|
497
357
|
const currRulesetVariables = rulesetVariables !== null && rulesetVariables !== void 0 ? rulesetVariables : [];
|
|
@@ -505,134 +365,16 @@ class PresentationManager {
|
|
|
505
365
|
currRulesetVariables: JSON.stringify(currRulesetVariables),
|
|
506
366
|
expandedNodeKeys: JSON.stringify((_b = options.expandedNodeKeys) !== null && _b !== void 0 ? _b : []),
|
|
507
367
|
};
|
|
508
|
-
|
|
368
|
+
const reviver = (key, value) => (key === "") ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value;
|
|
369
|
+
return JSON.parse(await this._detail.request(params), reviver);
|
|
509
370
|
}
|
|
510
371
|
}
|
|
511
372
|
exports.PresentationManager = PresentationManager;
|
|
512
|
-
function addInstanceKey(classInstancesMap, key) {
|
|
513
|
-
let set = classInstancesMap.get(key.className);
|
|
514
|
-
// istanbul ignore else
|
|
515
|
-
if (!set) {
|
|
516
|
-
set = new Set();
|
|
517
|
-
classInstancesMap.set(key.className, set);
|
|
518
|
-
}
|
|
519
|
-
set.add(key.id);
|
|
520
|
-
}
|
|
521
|
-
function bisElementInstanceKeysProcessor(imodel, classInstancesMap) {
|
|
522
|
-
const elementClassName = "BisCore:Element";
|
|
523
|
-
const elementIds = classInstancesMap.get(elementClassName);
|
|
524
|
-
if (elementIds) {
|
|
525
|
-
const deleteElementIds = new Array();
|
|
526
|
-
elementIds.forEach((elementId) => {
|
|
527
|
-
const concreteKey = (0, Utils_1.getElementKey)(imodel, elementId);
|
|
528
|
-
if (concreteKey && concreteKey.className !== elementClassName) {
|
|
529
|
-
deleteElementIds.push(elementId);
|
|
530
|
-
addInstanceKey(classInstancesMap, { className: concreteKey.className, id: elementId });
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
for (const id of deleteElementIds)
|
|
534
|
-
elementIds.delete(id);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
/** @internal */
|
|
538
|
-
function getKeysForContentRequest(keys, classInstanceKeysProcessor) {
|
|
539
|
-
const result = {
|
|
540
|
-
instanceKeys: [],
|
|
541
|
-
nodeKeys: [],
|
|
542
|
-
};
|
|
543
|
-
const classInstancesMap = new Map();
|
|
544
|
-
keys.forEach((key) => {
|
|
545
|
-
if (presentation_common_1.Key.isNodeKey(key))
|
|
546
|
-
result.nodeKeys.push(key);
|
|
547
|
-
if (presentation_common_1.Key.isInstanceKey(key))
|
|
548
|
-
addInstanceKey(classInstancesMap, key);
|
|
549
|
-
});
|
|
550
|
-
if (classInstanceKeysProcessor)
|
|
551
|
-
classInstanceKeysProcessor(classInstancesMap);
|
|
552
|
-
for (const entry of classInstancesMap) {
|
|
553
|
-
if (entry[1].size > 0)
|
|
554
|
-
result.instanceKeys.push([entry["0"], [...entry[1]]]);
|
|
555
|
-
}
|
|
556
|
-
return result;
|
|
557
|
-
}
|
|
558
|
-
exports.getKeysForContentRequest = getKeysForContentRequest;
|
|
559
373
|
const createContentDescriptorOverrides = (descriptorOrOverrides) => {
|
|
560
374
|
if (descriptorOrOverrides instanceof presentation_common_1.Descriptor)
|
|
561
375
|
return descriptorOrOverrides.createDescriptorOverrides();
|
|
562
376
|
return descriptorOrOverrides;
|
|
563
377
|
};
|
|
564
|
-
const createLocaleDirectoryList = (props) => {
|
|
565
|
-
const localeDirectories = [(0, Utils_1.getLocalesDirectory)(getPresentationCommonAssetsRoot(props === null || props === void 0 ? void 0 : props.presentationAssetsRoot))];
|
|
566
|
-
if (props && props.localeDirectories) {
|
|
567
|
-
props.localeDirectories.forEach((dir) => {
|
|
568
|
-
if (-1 === localeDirectories.indexOf(dir))
|
|
569
|
-
localeDirectories.push(dir);
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
return localeDirectories;
|
|
573
|
-
};
|
|
574
|
-
const createTaskAllocationsMap = (props) => {
|
|
575
|
-
var _a;
|
|
576
|
-
const count = (_a = props === null || props === void 0 ? void 0 : props.workerThreadsCount) !== null && _a !== void 0 ? _a : 2;
|
|
577
|
-
return {
|
|
578
|
-
[Number.MAX_SAFE_INTEGER]: count,
|
|
579
|
-
};
|
|
580
|
-
};
|
|
581
|
-
const normalizeLocale = (locale) => {
|
|
582
|
-
if (!locale)
|
|
583
|
-
return undefined;
|
|
584
|
-
return locale.toLocaleLowerCase();
|
|
585
|
-
};
|
|
586
|
-
const normalizeDirectory = (directory) => {
|
|
587
|
-
return directory ? path.resolve(directory) : "";
|
|
588
|
-
};
|
|
589
|
-
const toNativeUnitSystem = (unitSystem) => {
|
|
590
|
-
switch (unitSystem) {
|
|
591
|
-
case "imperial": return NativePlatform_1.NativePresentationUnitSystem.BritishImperial;
|
|
592
|
-
case "metric": return NativePlatform_1.NativePresentationUnitSystem.Metric;
|
|
593
|
-
case "usCustomary": return NativePlatform_1.NativePresentationUnitSystem.UsCustomary;
|
|
594
|
-
case "usSurvey": return NativePlatform_1.NativePresentationUnitSystem.UsSurvey;
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
const toOptionalNativeUnitSystem = (unitSystem) => {
|
|
598
|
-
return unitSystem ? toNativeUnitSystem(unitSystem) : undefined;
|
|
599
|
-
};
|
|
600
|
-
const toNativeUnitFormatsMap = (map) => {
|
|
601
|
-
if (!map)
|
|
602
|
-
return undefined;
|
|
603
|
-
const nativeFormatsMap = {};
|
|
604
|
-
Object.keys(map).forEach((phenomenon) => {
|
|
605
|
-
const unitSystemsFormat = map[phenomenon];
|
|
606
|
-
nativeFormatsMap[phenomenon] = {
|
|
607
|
-
unitSystems: unitSystemsFormat.unitSystems.map(toNativeUnitSystem),
|
|
608
|
-
format: unitSystemsFormat.format,
|
|
609
|
-
};
|
|
610
|
-
});
|
|
611
|
-
return nativeFormatsMap;
|
|
612
|
-
};
|
|
613
|
-
const createCacheConfig = (config) => {
|
|
614
|
-
if ((config === null || config === void 0 ? void 0 : config.mode) === HierarchyCacheMode.Disk)
|
|
615
|
-
return { ...config, directory: normalizeDirectory(config.directory) };
|
|
616
|
-
if ((config === null || config === void 0 ? void 0 : config.mode) === HierarchyCacheMode.Hybrid)
|
|
617
|
-
return { ...config, disk: config.disk ? { ...config.disk, directory: normalizeDirectory(config.disk.directory) } : undefined };
|
|
618
|
-
if ((config === null || config === void 0 ? void 0 : config.mode) === HierarchyCacheMode.Memory)
|
|
619
|
-
return config;
|
|
620
|
-
return { mode: HierarchyCacheMode.Disk, directory: "" };
|
|
621
|
-
};
|
|
622
|
-
const getPresentationBackendAssetsRoot = (ovr) => {
|
|
623
|
-
if (typeof ovr === "string")
|
|
624
|
-
return ovr;
|
|
625
|
-
if (typeof ovr === "object")
|
|
626
|
-
return ovr.backend;
|
|
627
|
-
return Constants_1.PRESENTATION_BACKEND_ASSETS_ROOT;
|
|
628
|
-
};
|
|
629
|
-
const getPresentationCommonAssetsRoot = (ovr) => {
|
|
630
|
-
if (typeof ovr === "string")
|
|
631
|
-
return ovr;
|
|
632
|
-
if (typeof ovr === "object")
|
|
633
|
-
return ovr.common;
|
|
634
|
-
return Constants_1.PRESENTATION_COMMON_ASSETS_ROOT;
|
|
635
|
-
};
|
|
636
378
|
const ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE = 100;
|
|
637
379
|
async function buildElementsPropertiesInPages(className, ids, getter) {
|
|
638
380
|
const elementProperties = [];
|