@itwin/presentation-backend 4.0.0-dev.8 → 4.0.0-dev.80
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 +47 -1
- package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +5 -3
- package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
- package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
- package/lib/cjs/presentation-backend/Constants.js +40 -36
- package/lib/cjs/presentation-backend/Constants.js.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +260 -262
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +140 -140
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
- package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +148 -150
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +456 -445
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +309 -311
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +430 -430
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +284 -279
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
- package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +210 -213
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
- package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
- package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
- package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
- package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +107 -106
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
- package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
- package/lib/cjs/presentation-backend.d.ts +19 -19
- package/lib/cjs/presentation-backend.js +39 -35
- package/lib/cjs/presentation-backend.js.map +1 -1
- package/package.json +18 -18
|
@@ -1,312 +1,310 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Core
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.PresentationManager = exports.HierarchyCacheMode = exports.PresentationManagerMode = void 0;
|
|
11
|
-
const presentation_common_1 = require("@itwin/presentation-common");
|
|
12
|
-
const ElementPropertiesHelper_1 = require("./ElementPropertiesHelper");
|
|
13
|
-
const NativePlatform_1 = require("./NativePlatform");
|
|
14
|
-
const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
|
|
15
|
-
const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
|
|
16
|
-
const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
|
|
17
|
-
const Utils_1 = require("./Utils");
|
|
18
|
-
/**
|
|
19
|
-
* Presentation manager working mode.
|
|
20
|
-
* @public
|
|
21
|
-
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
22
|
-
*/
|
|
23
|
-
var PresentationManagerMode;
|
|
24
|
-
(function (PresentationManagerMode) {
|
|
25
|
-
/**
|
|
26
|
-
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
27
|
-
* related to reacting to changes in iModels.
|
|
28
|
-
*/
|
|
29
|
-
PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
|
|
30
|
-
/**
|
|
31
|
-
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
32
|
-
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
33
|
-
*/
|
|
34
|
-
PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
|
|
35
|
-
})(PresentationManagerMode = exports.PresentationManagerMode || (exports.PresentationManagerMode = {}));
|
|
36
|
-
/**
|
|
37
|
-
* Presentation hierarchy cache mode.
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
var HierarchyCacheMode;
|
|
41
|
-
(function (HierarchyCacheMode) {
|
|
42
|
-
/**
|
|
43
|
-
* Hierarchy cache is created in memory.
|
|
44
|
-
*/
|
|
45
|
-
HierarchyCacheMode["Memory"] = "memory";
|
|
46
|
-
/**
|
|
47
|
-
* Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel
|
|
48
|
-
* openings.
|
|
49
|
-
*/
|
|
50
|
-
HierarchyCacheMode["Disk"] = "disk";
|
|
51
|
-
/**
|
|
52
|
-
* Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level
|
|
53
|
-
* and persisted in disk cache when whole hierarchy level is created.
|
|
54
|
-
*
|
|
55
|
-
* **Note:** This mode is still experimental.
|
|
56
|
-
*/
|
|
57
|
-
HierarchyCacheMode["Hybrid"] = "hybrid";
|
|
58
|
-
})(HierarchyCacheMode = exports.HierarchyCacheMode || (exports.HierarchyCacheMode = {}));
|
|
59
|
-
/**
|
|
60
|
-
* Backend Presentation manager which pulls the presentation data from
|
|
61
|
-
* an iModel using native platform.
|
|
62
|
-
*
|
|
63
|
-
* @public
|
|
64
|
-
*/
|
|
65
|
-
class PresentationManager {
|
|
66
|
-
/**
|
|
67
|
-
* Creates an instance of PresentationManager.
|
|
68
|
-
* @param props Optional configuration properties.
|
|
69
|
-
*/
|
|
70
|
-
constructor(props) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
*
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
*
|
|
192
|
-
* @
|
|
193
|
-
* @
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
*
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
*
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
*
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
*
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return elementProperties;
|
|
311
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Core
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PresentationManager = exports.HierarchyCacheMode = exports.PresentationManagerMode = void 0;
|
|
11
|
+
const presentation_common_1 = require("@itwin/presentation-common");
|
|
12
|
+
const ElementPropertiesHelper_1 = require("./ElementPropertiesHelper");
|
|
13
|
+
const NativePlatform_1 = require("./NativePlatform");
|
|
14
|
+
const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
|
|
15
|
+
const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
|
|
16
|
+
const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
|
|
17
|
+
const Utils_1 = require("./Utils");
|
|
18
|
+
/**
|
|
19
|
+
* Presentation manager working mode.
|
|
20
|
+
* @public
|
|
21
|
+
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
22
|
+
*/
|
|
23
|
+
var PresentationManagerMode;
|
|
24
|
+
(function (PresentationManagerMode) {
|
|
25
|
+
/**
|
|
26
|
+
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
27
|
+
* related to reacting to changes in iModels.
|
|
28
|
+
*/
|
|
29
|
+
PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
|
|
30
|
+
/**
|
|
31
|
+
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
32
|
+
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
33
|
+
*/
|
|
34
|
+
PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
|
|
35
|
+
})(PresentationManagerMode = exports.PresentationManagerMode || (exports.PresentationManagerMode = {}));
|
|
36
|
+
/**
|
|
37
|
+
* Presentation hierarchy cache mode.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
var HierarchyCacheMode;
|
|
41
|
+
(function (HierarchyCacheMode) {
|
|
42
|
+
/**
|
|
43
|
+
* Hierarchy cache is created in memory.
|
|
44
|
+
*/
|
|
45
|
+
HierarchyCacheMode["Memory"] = "memory";
|
|
46
|
+
/**
|
|
47
|
+
* Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel
|
|
48
|
+
* openings.
|
|
49
|
+
*/
|
|
50
|
+
HierarchyCacheMode["Disk"] = "disk";
|
|
51
|
+
/**
|
|
52
|
+
* Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level
|
|
53
|
+
* and persisted in disk cache when whole hierarchy level is created.
|
|
54
|
+
*
|
|
55
|
+
* **Note:** This mode is still experimental.
|
|
56
|
+
*/
|
|
57
|
+
HierarchyCacheMode["Hybrid"] = "hybrid";
|
|
58
|
+
})(HierarchyCacheMode = exports.HierarchyCacheMode || (exports.HierarchyCacheMode = {}));
|
|
59
|
+
/**
|
|
60
|
+
* Backend Presentation manager which pulls the presentation data from
|
|
61
|
+
* an iModel using native platform.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
class PresentationManager {
|
|
66
|
+
/**
|
|
67
|
+
* Creates an instance of PresentationManager.
|
|
68
|
+
* @param props Optional configuration properties.
|
|
69
|
+
*/
|
|
70
|
+
constructor(props) {
|
|
71
|
+
/** @internal */
|
|
72
|
+
this.getNativePlatform = () => {
|
|
73
|
+
return this._detail.getNativePlatform();
|
|
74
|
+
};
|
|
75
|
+
this._props = props ?? {};
|
|
76
|
+
this._detail = new PresentationManagerDetail_1.PresentationManagerDetail(this._props);
|
|
77
|
+
this.activeLocale = this._props.defaultLocale; // eslint-disable-line deprecation/deprecation
|
|
78
|
+
this._localizationHelper = new presentation_common_1.LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? Utils_1.getLocalizedStringEN });
|
|
79
|
+
}
|
|
80
|
+
/** Get / set active unit system used to format property values with units */
|
|
81
|
+
get activeUnitSystem() { return this._detail.activeUnitSystem; }
|
|
82
|
+
// istanbul ignore next
|
|
83
|
+
set activeUnitSystem(value) { this._detail.activeUnitSystem = value; }
|
|
84
|
+
/** Dispose the presentation manager. Must be called to clean up native resources. */
|
|
85
|
+
dispose() {
|
|
86
|
+
this._detail.dispose();
|
|
87
|
+
}
|
|
88
|
+
/** @internal */
|
|
89
|
+
setOnManagerUsedHandler(handler) {
|
|
90
|
+
this._detail.setOnManagerUsedHandler(handler);
|
|
91
|
+
}
|
|
92
|
+
/** Properties used to initialize the manager */
|
|
93
|
+
get props() { return this._props; }
|
|
94
|
+
/** Get rulesets manager */
|
|
95
|
+
rulesets() { return this._detail.rulesets; }
|
|
96
|
+
/**
|
|
97
|
+
* Get ruleset variables manager for specific ruleset
|
|
98
|
+
* @param rulesetId Id of the ruleset to get variables manager for
|
|
99
|
+
*/
|
|
100
|
+
vars(rulesetId) {
|
|
101
|
+
return new RulesetVariablesManager_1.RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);
|
|
102
|
+
}
|
|
103
|
+
/** @internal */
|
|
104
|
+
// istanbul ignore next
|
|
105
|
+
getDetail() {
|
|
106
|
+
return this._detail;
|
|
107
|
+
}
|
|
108
|
+
/** @internal */
|
|
109
|
+
getRulesetId(rulesetOrId) {
|
|
110
|
+
return this._detail.getRulesetId(rulesetOrId);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves nodes
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
async getNodes(requestOptions) {
|
|
117
|
+
const serializedNodesJson = await this._detail.getNodes(requestOptions);
|
|
118
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
119
|
+
const nodesJson = JSON.parse(serializedNodesJson);
|
|
120
|
+
const nodes = presentation_common_1.Node.listFromJSON(nodesJson.nodes);
|
|
121
|
+
return this._localizationHelper.getLocalizedNodes(nodes);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Retrieves nodes count
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
async getNodesCount(requestOptions) {
|
|
128
|
+
return this._detail.getNodesCount(requestOptions);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Retrieves hierarchy level descriptor
|
|
132
|
+
* @beta
|
|
133
|
+
*/
|
|
134
|
+
async getNodesDescriptor(requestOptions) {
|
|
135
|
+
const response = await this._detail.getNodesDescriptor(requestOptions);
|
|
136
|
+
const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
|
|
137
|
+
return JSON.parse(response, reviver);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.
|
|
141
|
+
* TODO: Return results in pages
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
async getNodePaths(requestOptions) {
|
|
145
|
+
return this._detail.getNodePaths(requestOptions);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Retrieves paths from root nodes to nodes containing filter text in their label.
|
|
149
|
+
* TODO: Return results in pages
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
async getFilteredNodePaths(requestOptions) {
|
|
153
|
+
return this._detail.getFilteredNodePaths(requestOptions);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,
|
|
157
|
+
* its related instances for loading related and navigation properties.
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
async getContentSources(requestOptions) {
|
|
161
|
+
return this._detail.getContentSources(requestOptions);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Retrieves the content descriptor which can be used to get content
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
async getContentDescriptor(requestOptions) {
|
|
168
|
+
const response = await this._detail.getContentDescriptor(requestOptions);
|
|
169
|
+
const reviver = (key, value) => key === "" ? presentation_common_1.Descriptor.fromJSON(value) : value;
|
|
170
|
+
return JSON.parse(response, reviver);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Retrieves the content set size based on the supplied content descriptor override
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
async getContentSetSize(requestOptions) {
|
|
177
|
+
return this._detail.getContentSetSize(requestOptions);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Retrieves the content based on the supplied content descriptor override.
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
async getContent(requestOptions) {
|
|
184
|
+
const content = await this._detail.getContent(requestOptions);
|
|
185
|
+
if (!content)
|
|
186
|
+
return undefined;
|
|
187
|
+
return this._localizationHelper.getLocalizedContent(content);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Retrieves distinct values of specific field from the content based on the supplied content descriptor override.
|
|
191
|
+
* @param requestOptions Options for the request
|
|
192
|
+
* @return A promise object that returns either distinct values on success or an error string on error.
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
async getPagedDistinctValues(requestOptions) {
|
|
196
|
+
return this._detail.getPagedDistinctValues(requestOptions);
|
|
197
|
+
}
|
|
198
|
+
async getElementProperties(requestOptions) {
|
|
199
|
+
if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
|
|
200
|
+
const elementProperties = await this._detail.getElementProperties(requestOptions);
|
|
201
|
+
// istanbul ignore if
|
|
202
|
+
if (!elementProperties)
|
|
203
|
+
return undefined;
|
|
204
|
+
return this._localizationHelper.getLocalizedElementProperties(elementProperties);
|
|
205
|
+
}
|
|
206
|
+
return this.getMultipleElementProperties(requestOptions);
|
|
207
|
+
}
|
|
208
|
+
async getMultipleElementProperties(requestOptions) {
|
|
209
|
+
const { elementClasses, ...optionsNoElementClasses } = requestOptions;
|
|
210
|
+
const elementsCount = (0, ElementPropertiesHelper_1.getElementsCount)(requestOptions.imodel, requestOptions.elementClasses);
|
|
211
|
+
const propertiesGetter = async (className, ids) => buildElementsPropertiesInPages(className, ids, async (keys) => {
|
|
212
|
+
const content = await this.getContent({
|
|
213
|
+
...optionsNoElementClasses,
|
|
214
|
+
descriptor: {
|
|
215
|
+
displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
|
|
216
|
+
contentFlags: presentation_common_1.ContentFlags.ShowLabels,
|
|
217
|
+
},
|
|
218
|
+
rulesetOrId: "ElementProperties",
|
|
219
|
+
keys,
|
|
220
|
+
});
|
|
221
|
+
return (0, ElementPropertiesHelper_1.buildElementsProperties)(content);
|
|
222
|
+
});
|
|
223
|
+
const ELEMENT_IDS_BATCH_SIZE = 1000;
|
|
224
|
+
return {
|
|
225
|
+
total: elementsCount,
|
|
226
|
+
async *iterator() {
|
|
227
|
+
for (const idsByClass of (0, ElementPropertiesHelper_1.iterateElementIds)(requestOptions.imodel, elementClasses, ELEMENT_IDS_BATCH_SIZE)) {
|
|
228
|
+
const propertiesPage = [];
|
|
229
|
+
for (const entry of idsByClass) {
|
|
230
|
+
propertiesPage.push(...(await propertiesGetter(entry[0], entry[1])));
|
|
231
|
+
}
|
|
232
|
+
yield propertiesPage;
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Retrieves display label definition of specific item
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
async getDisplayLabelDefinition(requestOptions) {
|
|
242
|
+
const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);
|
|
243
|
+
return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Retrieves display label definitions of specific items
|
|
247
|
+
* @public
|
|
248
|
+
*/
|
|
249
|
+
async getDisplayLabelDefinitions(requestOptions) {
|
|
250
|
+
const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);
|
|
251
|
+
return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Retrieves available selection scopes.
|
|
255
|
+
* @public
|
|
256
|
+
*/
|
|
257
|
+
async getSelectionScopes(_requestOptions) {
|
|
258
|
+
return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
|
|
259
|
+
}
|
|
260
|
+
async computeSelection(requestOptions) {
|
|
261
|
+
return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection((0, presentation_common_1.isComputeSelectionRequestOptions)(requestOptions)
|
|
262
|
+
? requestOptions
|
|
263
|
+
: (function () {
|
|
264
|
+
const { ids, scopeId, ...rest } = requestOptions;
|
|
265
|
+
return { ...rest, elementIds: ids, scope: { id: scopeId } };
|
|
266
|
+
})());
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Compares two hierarchies specified in the request options
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
async compareHierarchies(requestOptions) {
|
|
273
|
+
if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {
|
|
274
|
+
return { changes: [] };
|
|
275
|
+
}
|
|
276
|
+
const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;
|
|
277
|
+
this._detail.registerRuleset(rulesetOrId);
|
|
278
|
+
const currRulesetId = (0, PresentationManagerDetail_1.getRulesetIdObject)(requestOptions.rulesetOrId);
|
|
279
|
+
const prevRulesetId = prev.rulesetOrId ? (0, PresentationManagerDetail_1.getRulesetIdObject)(prev.rulesetOrId) : currRulesetId;
|
|
280
|
+
if (prevRulesetId.parts.id !== currRulesetId.parts.id)
|
|
281
|
+
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, "Can't compare rulesets with different IDs");
|
|
282
|
+
const currRulesetVariables = rulesetVariables ?? [];
|
|
283
|
+
const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;
|
|
284
|
+
const params = {
|
|
285
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.CompareHierarchies,
|
|
286
|
+
...options,
|
|
287
|
+
prevRulesetId: prevRulesetId.uniqueId,
|
|
288
|
+
currRulesetId: currRulesetId.uniqueId,
|
|
289
|
+
prevRulesetVariables: JSON.stringify(prevRulesetVariables),
|
|
290
|
+
currRulesetVariables: JSON.stringify(currRulesetVariables),
|
|
291
|
+
expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),
|
|
292
|
+
};
|
|
293
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
294
|
+
const reviver = (key, value) => (key === "") ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value;
|
|
295
|
+
return JSON.parse(await this._detail.request(params), reviver);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
exports.PresentationManager = PresentationManager;
|
|
299
|
+
const ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE = 100;
|
|
300
|
+
async function buildElementsPropertiesInPages(className, ids, getter) {
|
|
301
|
+
const elementProperties = [];
|
|
302
|
+
const elementIds = [...ids];
|
|
303
|
+
while (elementIds.length > 0) {
|
|
304
|
+
const idsPage = elementIds.splice(0, ELEMENT_PROPERTIES_CONTENT_BATCH_SIZE);
|
|
305
|
+
const keys = new presentation_common_1.KeySet(idsPage.map((id) => ({ id, className })));
|
|
306
|
+
elementProperties.push(...(await getter(keys)));
|
|
307
|
+
}
|
|
308
|
+
return elementProperties;
|
|
309
|
+
}
|
|
312
310
|
//# sourceMappingURL=PresentationManager.js.map
|