@itwin/presentation-backend 4.9.0-dev.23 → 4.9.0-dev.24
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/ElementPropertiesHelper.d.ts +0 -3
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +1 -185
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +2 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +19 -7
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +1 -2
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +1 -18
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +15 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/package.json +14 -14
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
import { Observable } from "rxjs";
|
|
5
5
|
import { IModelDb } from "@itwin/core-backend";
|
|
6
6
|
import { Id64String } from "@itwin/core-bentley";
|
|
7
|
-
import { Descriptor, ElementProperties, Item } from "@itwin/presentation-common";
|
|
8
|
-
/** @internal */
|
|
9
|
-
export declare const buildElementProperties: (descriptor: Descriptor, item: Item) => ElementProperties;
|
|
10
7
|
/** @internal */
|
|
11
8
|
export declare function getElementsCount(db: IModelDb, classNames?: string[]): number;
|
|
12
9
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementPropertiesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA4B,UAAU,EAAU,MAAM,MAAM,CAAC;AACpE,OAAO,EAAkB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"ElementPropertiesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA4B,UAAU,EAAU,MAAM,MAAM,CAAC;AACpE,OAAO,EAAkB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAY,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG3D,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAWnE;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAG1E;AAOD,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAmBtG;AAED,gBAAgB;AAChB,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,QAAQ,EAChB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC,CAqBtD"}
|
|
@@ -7,18 +7,11 @@
|
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.getBatchedClassElementIds = exports.getClassesWithInstances = exports.parseFullClassName = exports.getElementsCount =
|
|
10
|
+
exports.getBatchedClassElementIds = exports.getClassesWithInstances = exports.parseFullClassName = exports.getElementsCount = void 0;
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
13
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
14
14
|
/** @internal */
|
|
15
|
-
const buildElementProperties = (descriptor, item) => {
|
|
16
|
-
const builder = new ElementPropertiesBuilder();
|
|
17
|
-
(0, presentation_common_1.traverseContentItem)(builder, descriptor, item);
|
|
18
|
-
return builder.items[0];
|
|
19
|
-
};
|
|
20
|
-
exports.buildElementProperties = buildElementProperties;
|
|
21
|
-
/** @internal */
|
|
22
15
|
function getElementsCount(db, classNames) {
|
|
23
16
|
const filter = createElementsFilter("e", classNames);
|
|
24
17
|
const query = `
|
|
@@ -95,181 +88,4 @@ function createElementsFilter(elementAlias, classNames) {
|
|
|
95
88
|
}
|
|
96
89
|
return `${elementAlias}.ECClassId IS (${classNames.join(",")})`;
|
|
97
90
|
}
|
|
98
|
-
class ElementPropertiesAppender {
|
|
99
|
-
constructor(_item, _onItemFinished) {
|
|
100
|
-
this._item = _item;
|
|
101
|
-
this._onItemFinished = _onItemFinished;
|
|
102
|
-
this._propertyItems = {};
|
|
103
|
-
this._categoryItemAppenders = {};
|
|
104
|
-
}
|
|
105
|
-
append(label, item) {
|
|
106
|
-
this._propertyItems[label] = item;
|
|
107
|
-
}
|
|
108
|
-
finish() {
|
|
109
|
-
// eslint-disable-next-line guard-for-in
|
|
110
|
-
for (const categoryName in this._categoryItemAppenders) {
|
|
111
|
-
const appender = this._categoryItemAppenders[categoryName];
|
|
112
|
-
appender.finish();
|
|
113
|
-
}
|
|
114
|
-
this._onItemFinished({
|
|
115
|
-
class: this._item.classInfo?.label ?? "",
|
|
116
|
-
id: this._item.primaryKeys[0]?.id ?? core_bentley_1.Id64.invalid,
|
|
117
|
-
label: this._item.label.displayValue,
|
|
118
|
-
items: this._propertyItems,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
getCategoryAppender(parentAppender, category) {
|
|
122
|
-
let appender = this._categoryItemAppenders[category.name];
|
|
123
|
-
if (!appender) {
|
|
124
|
-
appender = new CategoryItemAppender(parentAppender, category);
|
|
125
|
-
this._categoryItemAppenders[category.name] = appender;
|
|
126
|
-
}
|
|
127
|
-
return appender;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
class CategoryItemAppender {
|
|
131
|
-
constructor(_parentAppender, _category) {
|
|
132
|
-
this._parentAppender = _parentAppender;
|
|
133
|
-
this._category = _category;
|
|
134
|
-
this._items = {};
|
|
135
|
-
}
|
|
136
|
-
append(label, item) {
|
|
137
|
-
this._items[label] = item;
|
|
138
|
-
}
|
|
139
|
-
finish() {
|
|
140
|
-
if (Object.keys(this._items).length === 0) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
this._parentAppender.append(this._category.label, {
|
|
144
|
-
type: "category",
|
|
145
|
-
items: this._items,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
class ArrayItemAppender {
|
|
150
|
-
constructor(_parentAppender, _props) {
|
|
151
|
-
this._parentAppender = _parentAppender;
|
|
152
|
-
this._props = _props;
|
|
153
|
-
this._items = [];
|
|
154
|
-
}
|
|
155
|
-
append(_label, item) {
|
|
156
|
-
(0, core_bentley_1.assert)(item.type !== "category");
|
|
157
|
-
this._items.push(item);
|
|
158
|
-
}
|
|
159
|
-
finish() {
|
|
160
|
-
(0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Array);
|
|
161
|
-
if (this._props.valueType.memberType.valueFormat === presentation_common_1.PropertyValueFormat.Primitive) {
|
|
162
|
-
this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
createPrimitivesArray() {
|
|
169
|
-
return {
|
|
170
|
-
type: "array",
|
|
171
|
-
valueType: "primitive",
|
|
172
|
-
values: this._items.map((item) => {
|
|
173
|
-
(0, core_bentley_1.assert)(item.type === "primitive");
|
|
174
|
-
return item.value;
|
|
175
|
-
}),
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
createStructsArray() {
|
|
179
|
-
return {
|
|
180
|
-
type: "array",
|
|
181
|
-
valueType: "struct",
|
|
182
|
-
values: this._items.map((item) => {
|
|
183
|
-
(0, core_bentley_1.assert)(item.type === "struct");
|
|
184
|
-
return item.members;
|
|
185
|
-
}),
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
class StructItemAppender {
|
|
190
|
-
constructor(_parentAppender, _props) {
|
|
191
|
-
this._parentAppender = _parentAppender;
|
|
192
|
-
this._props = _props;
|
|
193
|
-
this._members = {};
|
|
194
|
-
}
|
|
195
|
-
append(label, item) {
|
|
196
|
-
(0, core_bentley_1.assert)(item.type !== "category");
|
|
197
|
-
this._members[label] = item;
|
|
198
|
-
}
|
|
199
|
-
finish() {
|
|
200
|
-
(0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Struct);
|
|
201
|
-
this._parentAppender.append(this._props.hierarchy.field.label, {
|
|
202
|
-
type: "struct",
|
|
203
|
-
members: this._members,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
class ElementPropertiesBuilder {
|
|
208
|
-
constructor() {
|
|
209
|
-
this._appendersStack = [];
|
|
210
|
-
this._items = [];
|
|
211
|
-
}
|
|
212
|
-
get items() {
|
|
213
|
-
return this._items;
|
|
214
|
-
}
|
|
215
|
-
get _currentAppender() {
|
|
216
|
-
const appender = this._appendersStack[this._appendersStack.length - 1];
|
|
217
|
-
(0, core_bentley_1.assert)(appender !== undefined);
|
|
218
|
-
return appender;
|
|
219
|
-
}
|
|
220
|
-
startContent(_props) {
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
finishContent() { }
|
|
224
|
-
processFieldHierarchies(_props) { }
|
|
225
|
-
startItem(props) {
|
|
226
|
-
this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));
|
|
227
|
-
this._appendersStack.push(this._elementPropertiesAppender);
|
|
228
|
-
return true;
|
|
229
|
-
}
|
|
230
|
-
finishItem() {
|
|
231
|
-
this._appendersStack.pop();
|
|
232
|
-
(0, core_bentley_1.assert)(this._elementPropertiesAppender !== undefined);
|
|
233
|
-
this._elementPropertiesAppender.finish();
|
|
234
|
-
this._elementPropertiesAppender = undefined;
|
|
235
|
-
}
|
|
236
|
-
startCategory(props) {
|
|
237
|
-
(0, core_bentley_1.assert)(this._elementPropertiesAppender !== undefined);
|
|
238
|
-
this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));
|
|
239
|
-
return true;
|
|
240
|
-
}
|
|
241
|
-
finishCategory() {
|
|
242
|
-
this._appendersStack.pop();
|
|
243
|
-
}
|
|
244
|
-
startField(_props) {
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
finishField() { }
|
|
248
|
-
startStruct(props) {
|
|
249
|
-
this._appendersStack.push(new StructItemAppender(this._currentAppender, props));
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
finishStruct() {
|
|
253
|
-
this._appendersStack.pop().finish();
|
|
254
|
-
}
|
|
255
|
-
startArray(props) {
|
|
256
|
-
this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
259
|
-
finishArray() {
|
|
260
|
-
this._appendersStack.pop().finish();
|
|
261
|
-
}
|
|
262
|
-
processMergedValue(props) {
|
|
263
|
-
this._currentAppender.append(props.mergedField.label, {
|
|
264
|
-
type: "primitive",
|
|
265
|
-
value: "",
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
processPrimitiveValue(props) {
|
|
269
|
-
this._currentAppender.append(props.field.label, {
|
|
270
|
-
type: "primitive",
|
|
271
|
-
value: props.displayValue?.toString() ?? "",
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
91
|
//# sourceMappingURL=ElementPropertiesHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementPropertiesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAoE;AAEpE,sDAAyE;AACzE,oEAuBoC;AAEpC,gBAAgB;AACT,MAAM,sBAAsB,GAAG,CAAC,UAAsB,EAAE,IAAU,EAAqB,EAAE;IAC9F,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC/C,IAAA,yCAAmB,EAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC;AAEF,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,EAAY,EAAE,UAAqB;IAClE,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG;;;MAGV,MAAM,CAAC,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;GAClC,CAAC;IAEF,OAAO,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC,IAAoB,EAAE,EAAE;QAC9D,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,uBAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,4CAWC;AAED,gBAAgB;AAChB,SAAgB,kBAAkB,CAAC,aAAqB;I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AW,CAAC,KAAK,EAAE;YACpD,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IACM,qBAAqB,CAAC,KAAiC;QAC5D,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;YAC9C,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;CACF","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/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { from, mergeAll, mergeMap, Observable, reduce } from \"rxjs\";\r\nimport { ECSqlStatement, IModelDb } from \"@itwin/core-backend\";\r\nimport { assert, DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n CategoryDescription,\r\n Descriptor,\r\n ElementProperties,\r\n ElementPropertiesItem,\r\n ElementPropertiesPrimitiveArrayPropertyItem,\r\n ElementPropertiesPropertyItem,\r\n ElementPropertiesStructArrayPropertyItem,\r\n IContentVisitor,\r\n Item,\r\n PresentationError,\r\n PresentationStatus,\r\n ProcessFieldHierarchiesProps,\r\n ProcessMergedValueProps,\r\n ProcessPrimitiveValueProps,\r\n PropertyValueFormat,\r\n StartArrayProps,\r\n StartCategoryProps,\r\n StartContentProps,\r\n StartFieldProps,\r\n StartItemProps,\r\n StartStructProps,\r\n traverseContentItem,\r\n} from \"@itwin/presentation-common\";\r\n\r\n/** @internal */\r\nexport const buildElementProperties = (descriptor: Descriptor, item: Item): ElementProperties => {\r\n const builder = new ElementPropertiesBuilder();\r\n traverseContentItem(builder, descriptor, item);\r\n return builder.items[0];\r\n};\r\n\r\n/** @internal */\r\nexport function getElementsCount(db: IModelDb, classNames?: string[]) {\r\n const filter = createElementsFilter(\"e\", classNames);\r\n const query = `\r\n SELECT COUNT(e.ECInstanceId)\r\n FROM bis.Element e\r\n ${filter ? `WHERE ${filter}` : \"\"}\r\n `;\r\n\r\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\r\n return stmt.step() === DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;\r\n });\r\n}\r\n\r\n/** @internal */\r\nexport function parseFullClassName(fullClassName: string): [string, string] {\r\n const [schemaName, className] = fullClassName.split(/[:\\.]/);\r\n return [schemaName, className];\r\n}\r\n\r\nfunction getECSqlName(fullClassName: string) {\r\n const [schemaName, className] = parseFullClassName(fullClassName);\r\n return `[${schemaName}].[${className}]`;\r\n}\r\n\r\n/** @internal */\r\nexport function getClassesWithInstances(imodel: IModelDb, fullClassNames: string[]): Observable<string> {\r\n return from(fullClassNames).pipe(\r\n mergeMap((fullClassName) => {\r\n const reader = imodel.createQueryReader(`\r\n SELECT s.Name, c.Name\r\n FROM ${getECSqlName(fullClassName)} e\r\n JOIN meta.ECClassDef c ON c.ECInstanceId = e.ECClassId\r\n JOIN meta.ECSchemaDef s on s.ECInstanceId = c.Schema.Id\r\n GROUP BY c.ECInstanceId\r\n `);\r\n return from(reader.toArray() as Promise<[string, string][]>);\r\n }),\r\n mergeAll(),\r\n reduce<[string, string], Set<string>>((set, [schemaName, className]) => {\r\n set.add(`${schemaName}.${className}`);\r\n return set;\r\n }, new Set()),\r\n mergeMap((set) => [...set]),\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport async function getBatchedClassElementIds(\r\n imodel: IModelDb,\r\n fullClassName: string,\r\n batchSize: number,\r\n): Promise<Array<{ from: Id64String; to: Id64String }>> {\r\n const batches = [];\r\n const reader = imodel.createQueryReader(`SELECT ECInstanceId id FROM ${getECSqlName(fullClassName)} ORDER BY ECInstanceId`);\r\n let currId: Id64String | undefined;\r\n let fromId: Id64String | undefined;\r\n let count = 0;\r\n while (await reader.step()) {\r\n currId = reader.current.toRow().id as Id64String;\r\n if (!fromId) {\r\n fromId = currId;\r\n }\r\n if (++count >= batchSize) {\r\n batches.push({ from: fromId, to: currId });\r\n fromId = undefined;\r\n count = 0;\r\n }\r\n }\r\n if (fromId && currId) {\r\n batches.push({ from: fromId, to: currId });\r\n }\r\n return batches;\r\n}\r\n\r\nfunction createElementsFilter(elementAlias: string, classNames?: string[]) {\r\n if (classNames === undefined || classNames.length === 0) {\r\n return undefined;\r\n }\r\n\r\n // check if list contains only valid class names\r\n const classNameRegExp = new RegExp(/^[\\w]+[.:][\\w]+$/);\r\n const invalidName = classNames.find((name) => !name.match(classNameRegExp));\r\n if (invalidName) {\r\n throw new PresentationError(\r\n PresentationStatus.InvalidArgument,\r\n `Encountered invalid class name - ${invalidName}.\r\n Valid class name formats: \"<schema name or alias>.<class name>\", \"<schema name or alias>:<class name>\"`,\r\n );\r\n }\r\n\r\n return `${elementAlias}.ECClassId IS (${classNames.join(\",\")})`;\r\n}\r\n\r\ninterface IPropertiesAppender {\r\n append(label: string, item: ElementPropertiesItem): void;\r\n finish(): void;\r\n}\r\n\r\nclass ElementPropertiesAppender implements IPropertiesAppender {\r\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\r\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\r\n constructor(\r\n private _item: Item,\r\n private _onItemFinished: (item: ElementProperties) => void,\r\n ) {}\r\n\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._propertyItems[label] = item;\r\n }\r\n\r\n public finish(): void {\r\n // eslint-disable-next-line guard-for-in\r\n for (const categoryName in this._categoryItemAppenders) {\r\n const appender = this._categoryItemAppenders[categoryName];\r\n appender.finish();\r\n }\r\n\r\n this._onItemFinished({\r\n class: this._item.classInfo?.label ?? \"\",\r\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\r\n label: this._item.label.displayValue,\r\n items: this._propertyItems,\r\n });\r\n }\r\n\r\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\r\n let appender = this._categoryItemAppenders[category.name];\r\n if (!appender) {\r\n appender = new CategoryItemAppender(parentAppender, category);\r\n this._categoryItemAppenders[category.name] = appender;\r\n }\r\n return appender;\r\n }\r\n}\r\n\r\nclass CategoryItemAppender implements IPropertiesAppender {\r\n private _items: { [label: string]: ElementPropertiesItem } = {};\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _category: CategoryDescription,\r\n ) {}\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._items[label] = item;\r\n }\r\n public finish(): void {\r\n if (Object.keys(this._items).length === 0) {\r\n return;\r\n }\r\n\r\n this._parentAppender.append(this._category.label, {\r\n type: \"category\",\r\n items: this._items,\r\n });\r\n }\r\n}\r\n\r\nclass ArrayItemAppender implements IPropertiesAppender {\r\n private _items: ElementPropertiesPropertyItem[] = [];\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _props: StartArrayProps,\r\n ) {}\r\n public append(_label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._items.push(item);\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\r\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive) {\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\r\n } else {\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\r\n }\r\n }\r\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"primitive\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"primitive\");\r\n return item.value;\r\n }),\r\n };\r\n }\r\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"struct\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"struct\");\r\n return item.members;\r\n }),\r\n };\r\n }\r\n}\r\n\r\nclass StructItemAppender implements IPropertiesAppender {\r\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _props: StartStructProps,\r\n ) {}\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._members[label] = item;\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\r\n this._parentAppender.append(this._props.hierarchy.field.label, {\r\n type: \"struct\",\r\n members: this._members,\r\n });\r\n }\r\n}\r\n\r\nclass ElementPropertiesBuilder implements IContentVisitor {\r\n private _appendersStack: IPropertiesAppender[] = [];\r\n private _items: ElementProperties[] = [];\r\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\r\n\r\n public get items(): ElementProperties[] {\r\n return this._items;\r\n }\r\n\r\n private get _currentAppender(): IPropertiesAppender {\r\n const appender = this._appendersStack[this._appendersStack.length - 1];\r\n assert(appender !== undefined);\r\n return appender;\r\n }\r\n\r\n public startContent(_props: StartContentProps): boolean {\r\n return true;\r\n }\r\n public finishContent(): void {}\r\n\r\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void {}\r\n\r\n public startItem(props: StartItemProps): boolean {\r\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\r\n this._appendersStack.push(this._elementPropertiesAppender);\r\n return true;\r\n }\r\n public finishItem(): void {\r\n this._appendersStack.pop();\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._elementPropertiesAppender.finish();\r\n this._elementPropertiesAppender = undefined;\r\n }\r\n\r\n public startCategory(props: StartCategoryProps): boolean {\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\r\n return true;\r\n }\r\n public finishCategory(): void {\r\n this._appendersStack.pop();\r\n }\r\n\r\n public startField(_props: StartFieldProps): boolean {\r\n return true;\r\n }\r\n public finishField(): void {}\r\n\r\n public startStruct(props: StartStructProps): boolean {\r\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishStruct(): void {\r\n this._appendersStack.pop()!.finish();\r\n }\r\n\r\n public startArray(props: StartArrayProps): boolean {\r\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishArray(): void {\r\n this._appendersStack.pop()!.finish();\r\n }\r\n\r\n public processMergedValue(props: ProcessMergedValueProps): void {\r\n this._currentAppender.append(props.mergedField.label, {\r\n type: \"primitive\",\r\n value: \"\",\r\n });\r\n }\r\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\r\n this._currentAppender.append(props.field.label, {\r\n type: \"primitive\",\r\n value: props.displayValue?.toString() ?? \"\",\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ElementPropertiesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAoE;AAEpE,sDAA2D;AAC3D,oEAAmF;AAEnF,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,EAAY,EAAE,UAAqB;IAClE,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG;;;MAGV,MAAM,CAAC,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;GAClC,CAAC;IAEF,OAAO,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC,IAAoB,EAAE,EAAE;QAC9D,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,uBAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,4CAWC;AAED,gBAAgB;AAChB,SAAgB,kBAAk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AC,eAAe,EAClC,oCAAoC,WAAW;6GACwD,CACxG,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,YAAY,kBAAkB,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAClE,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/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { from, mergeAll, mergeMap, Observable, reduce } from \"rxjs\";\r\nimport { ECSqlStatement, IModelDb } from \"@itwin/core-backend\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\r\n\r\n/** @internal */\r\nexport function getElementsCount(db: IModelDb, classNames?: string[]) {\r\n const filter = createElementsFilter(\"e\", classNames);\r\n const query = `\r\n SELECT COUNT(e.ECInstanceId)\r\n FROM bis.Element e\r\n ${filter ? `WHERE ${filter}` : \"\"}\r\n `;\r\n\r\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\r\n return stmt.step() === DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;\r\n });\r\n}\r\n\r\n/** @internal */\r\nexport function parseFullClassName(fullClassName: string): [string, string] {\r\n const [schemaName, className] = fullClassName.split(/[:\\.]/);\r\n return [schemaName, className];\r\n}\r\n\r\nfunction getECSqlName(fullClassName: string) {\r\n const [schemaName, className] = parseFullClassName(fullClassName);\r\n return `[${schemaName}].[${className}]`;\r\n}\r\n\r\n/** @internal */\r\nexport function getClassesWithInstances(imodel: IModelDb, fullClassNames: string[]): Observable<string> {\r\n return from(fullClassNames).pipe(\r\n mergeMap((fullClassName) => {\r\n const reader = imodel.createQueryReader(`\r\n SELECT s.Name, c.Name\r\n FROM ${getECSqlName(fullClassName)} e\r\n JOIN meta.ECClassDef c ON c.ECInstanceId = e.ECClassId\r\n JOIN meta.ECSchemaDef s on s.ECInstanceId = c.Schema.Id\r\n GROUP BY c.ECInstanceId\r\n `);\r\n return from(reader.toArray() as Promise<[string, string][]>);\r\n }),\r\n mergeAll(),\r\n reduce<[string, string], Set<string>>((set, [schemaName, className]) => {\r\n set.add(`${schemaName}.${className}`);\r\n return set;\r\n }, new Set()),\r\n mergeMap((set) => [...set]),\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport async function getBatchedClassElementIds(\r\n imodel: IModelDb,\r\n fullClassName: string,\r\n batchSize: number,\r\n): Promise<Array<{ from: Id64String; to: Id64String }>> {\r\n const batches = [];\r\n const reader = imodel.createQueryReader(`SELECT ECInstanceId id FROM ${getECSqlName(fullClassName)} ORDER BY ECInstanceId`);\r\n let currId: Id64String | undefined;\r\n let fromId: Id64String | undefined;\r\n let count = 0;\r\n while (await reader.step()) {\r\n currId = reader.current.toRow().id as Id64String;\r\n if (!fromId) {\r\n fromId = currId;\r\n }\r\n if (++count >= batchSize) {\r\n batches.push({ from: fromId, to: currId });\r\n fromId = undefined;\r\n count = 0;\r\n }\r\n }\r\n if (fromId && currId) {\r\n batches.push({ from: fromId, to: currId });\r\n }\r\n return batches;\r\n}\r\n\r\nfunction createElementsFilter(elementAlias: string, classNames?: string[]) {\r\n if (classNames === undefined || classNames.length === 0) {\r\n return undefined;\r\n }\r\n\r\n // check if list contains only valid class names\r\n const classNameRegExp = new RegExp(/^[\\w]+[.:][\\w]+$/);\r\n const invalidName = classNames.find((name) => !name.match(classNameRegExp));\r\n if (invalidName) {\r\n throw new PresentationError(\r\n PresentationStatus.InvalidArgument,\r\n `Encountered invalid class name - ${invalidName}.\r\n Valid class name formats: \"<schema name or alias>.<class name>\", \"<schema name or alias>:<class name>\"`,\r\n );\r\n }\r\n\r\n return `${elementAlias}.ECClassId IS (${classNames.join(\",\")})`;\r\n}\r\n"]}
|
|
@@ -417,13 +417,14 @@ export declare class PresentationManager {
|
|
|
417
417
|
* Retrieves property data in a simplified format for a single element specified by ID.
|
|
418
418
|
* @public
|
|
419
419
|
*/
|
|
420
|
-
getElementProperties(requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute): Promise<
|
|
420
|
+
getElementProperties<TParsedContent = ElementProperties>(requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute): Promise<TParsedContent | undefined>;
|
|
421
421
|
/**
|
|
422
422
|
* Retrieves property data in simplified format for multiple elements specified by class or all element.
|
|
423
423
|
* @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.
|
|
424
424
|
* @public
|
|
425
425
|
*/
|
|
426
426
|
getElementProperties<TParsedContent = ElementProperties>(requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute): Promise<MultiElementPropertiesResponse<TParsedContent>>;
|
|
427
|
+
private getSingleElementProperties;
|
|
427
428
|
private getMultipleElementProperties;
|
|
428
429
|
/**
|
|
429
430
|
* Retrieves display label definition of specific item
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,M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AE,CAAC;IAK7B;;;OAGG;IACU,kBAAkB,CAAC,eAAe,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAAG,2BAA2B,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIjJ;;;;OAIG;IACU,gBAAgB,CAC3B,cAAc,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAAG;QAAE,GAAG,EAAE,UAAU,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,2BAA2B,GAC5H,OAAO,CAAC,MAAM,CAAC;IAClB;;;OAGG;IAEU,gBAAgB,CAAC,cAAc,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GAAG,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAetI;;;OAGG;IACU,kBAAkB,CAAC,cAAc,EAAE,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;CA+B3H"}
|
|
@@ -239,18 +239,30 @@ class PresentationManager {
|
|
|
239
239
|
}
|
|
240
240
|
async getElementProperties(requestOptions) {
|
|
241
241
|
if ((0, presentation_common_1.isSingleElementPropertiesRequestOptions)(requestOptions)) {
|
|
242
|
-
|
|
243
|
-
// istanbul ignore if
|
|
244
|
-
if (!elementProperties) {
|
|
245
|
-
return undefined;
|
|
246
|
-
}
|
|
247
|
-
return this._localizationHelper.getLocalizedElementProperties(elementProperties);
|
|
242
|
+
return this.getSingleElementProperties(requestOptions);
|
|
248
243
|
}
|
|
249
244
|
return this.getMultipleElementProperties(requestOptions);
|
|
250
245
|
}
|
|
246
|
+
async getSingleElementProperties(requestOptions) {
|
|
247
|
+
const { elementId, contentParser, ...optionsNoElementId } = requestOptions;
|
|
248
|
+
const parser = contentParser ?? presentation_common_1.buildElementProperties;
|
|
249
|
+
const content = await this.getContent({
|
|
250
|
+
...optionsNoElementId,
|
|
251
|
+
descriptor: {
|
|
252
|
+
displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
|
|
253
|
+
contentFlags: presentation_common_1.ContentFlags.ShowLabels,
|
|
254
|
+
},
|
|
255
|
+
rulesetOrId: "ElementProperties",
|
|
256
|
+
keys: new presentation_common_1.KeySet([{ className: "BisCore:Element", id: elementId }]),
|
|
257
|
+
});
|
|
258
|
+
if (!content || content.contentSet.length === 0) {
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
return parser(content.descriptor, content.contentSet[0]);
|
|
262
|
+
}
|
|
251
263
|
async getMultipleElementProperties(requestOptions) {
|
|
252
264
|
const { elementClasses, contentParser, batchSize, ...contentOptions } = requestOptions;
|
|
253
|
-
const parser = contentParser ??
|
|
265
|
+
const parser = contentParser ?? presentation_common_1.buildElementProperties;
|
|
254
266
|
const workerThreadsCount = this._props.workerThreadsCount ?? 2;
|
|
255
267
|
// We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory
|
|
256
268
|
// and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAyD;AACzD,mDAA+C;AAK/C,oEAkDoC;AACpC,uEAA6J;AAC7J,qDAAwF;AACxF,2EAA4F;AAE5F,uEAAiG;AACjG,mEAAgE;AAChE,mCAAuG;AAEvG;;;;GAIG;AACH,IAAY,uBAYX;AAZD,WAAY,uBAAuB;IACjC;;;OAGG;IACH,6EAAQ,CAAA;IAER;;;OAGG;IACH,+EAAS,CAAA;AACX,CAAC,EAZW,uBAAuB,uCAAvB,uBAAuB,QAYlC;AAED;;;GAGG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,uCAAiB,CAAA;IACjB;;;OAGG;IACH,mCAAa,CAAA;IACb;;;;;OAKG;IACH,uCAAiB,CAAA;AACnB,CAAC,EAjBW,kBA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,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;CACF;AApdD,kDAodC","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/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { forkJoin, from, map, mergeMap, of } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { IModelDb } from \"@itwin/core-backend\";\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n UnitSystemFormat as CommonUnitSystemFormat,\r\n ComputeSelectionRequestOptions,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentFormatter,\r\n ContentPropertyValueFormatter,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyCompareInfo,\r\n HierarchyCompareOptions,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyLevelJSON,\r\n HierarchyRequestOptions,\r\n InstanceKey,\r\n isComputeSelectionRequestOptions,\r\n isSingleElementPropertiesRequestOptions,\r\n Item,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n LocalizationHelper,\r\n MultiElementPropertiesRequestOptions,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PresentationError,\r\n PresentationStatus,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SelectionScope,\r\n SelectionScopeRequestOptions,\r\n SingleElementPropertiesRequestOptions,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport { buildElementProperties, getBatchedClassElementIds, getClassesWithInstances, getElementsCount, parseFullClassName } from \"./ElementPropertiesHelper\";\r\nimport { NativePlatformDefinition, NativePlatformRequestTypes } from \"./NativePlatform\";\r\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail\";\r\nimport { RulesetManager } from \"./RulesetManager\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\r\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper\";\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils\";\r\n\r\n/**\r\n * Presentation manager working mode.\r\n * @public\r\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\r\n */\r\nexport enum PresentationManagerMode {\r\n /**\r\n * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work\r\n * related to reacting to changes in iModels.\r\n */\r\n ReadOnly,\r\n\r\n /**\r\n * Presentation manager assumes iModels are opened in read-write mode and it may need to\r\n * react to changes. This involves some additional work and gives slightly worse performance.\r\n */\r\n ReadWrite,\r\n}\r\n\r\n/**\r\n * Presentation hierarchy cache mode.\r\n * @public\r\n */\r\nexport enum HierarchyCacheMode {\r\n /**\r\n * Hierarchy cache is created in memory.\r\n */\r\n Memory = \"memory\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\r\n * openings.\r\n */\r\n Disk = \"disk\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\r\n * and persisted in disk cache when whole hierarchy level is created.\r\n *\r\n * **Note:** This mode is still experimental.\r\n */\r\n Hybrid = \"hybrid\",\r\n}\r\n\r\n/**\r\n * Configuration for hierarchy cache.\r\n * @public\r\n */\r\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\r\n\r\n/**\r\n * Base interface for all [[HierarchyCacheConfig]] implementations.\r\n * @public\r\n */\r\nexport interface HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode;\r\n}\r\n\r\n/**\r\n * Configuration for in-memory hierarchy cache.\r\n *\r\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\r\n * @public\r\n */\r\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Memory;\r\n}\r\n\r\n/**\r\n * Configuration for persistent disk hierarchy cache.\r\n *\r\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\r\n * @public\r\n */\r\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Disk;\r\n\r\n /**\r\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\r\n *\r\n * The default directory depends on the iModel and the way it's opened.\r\n */\r\n directory?: string;\r\n\r\n /**\r\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\r\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\r\n */\r\n memoryCacheSize?: number;\r\n}\r\n\r\n/**\r\n * Configuration for the experimental hybrid hierarchy cache.\r\n *\r\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\r\n * alternative for cases when there are lots of simultaneous requests.\r\n *\r\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\r\n * @public\r\n */\r\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Hybrid;\r\n\r\n /** Configuration for disk cache used to persist hierarchies. */\r\n disk?: DiskHierarchyCacheConfig;\r\n}\r\n\r\n/**\r\n * Configuration for content cache.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n * @public\r\n */\r\nexport interface ContentCacheConfig {\r\n /**\r\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\r\n *\r\n * Defaults to `100`.\r\n */\r\n size?: number;\r\n}\r\n\r\n/**\r\n * Caching configuration options for [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationManagerCachingConfig {\r\n /**\r\n * Hierarchies-related caching options.\r\n *\r\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\r\n */\r\n hierarchies?: HierarchyCacheConfig;\r\n\r\n /**\r\n * Content-related caching options.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n */\r\n content?: ContentCacheConfig;\r\n\r\n /**\r\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\r\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\r\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\r\n * cache. Defaults to `32768000` bytes (32 MB).\r\n *\r\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\r\n */\r\n workerConnectionCacheSize?: number;\r\n}\r\n\r\n/**\r\n * A data structure that associates unit systems with a format. The associations are used for\r\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\r\n *\r\n * @public\r\n * @deprecated in 4.3. The type has been moved to `@itwin/presentation-common` package.\r\n */\r\nexport type UnitSystemFormat = CommonUnitSystemFormat;\r\n\r\n/**\r\n * Data structure for multiple element properties request response.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\r\n total: number;\r\n iterator: () => AsyncGenerator<TParsedContent[]>;\r\n}\r\n\r\n/**\r\n * Configuration options for supplying asset paths to [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationAssetsRootConfig {\r\n /**\r\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\r\n */\r\n backend: string;\r\n\r\n /**\r\n * Path to `presentation-common` assets.\r\n *\r\n * @deprecated in 3.x. This path is not used anymore\r\n */\r\n common: string;\r\n}\r\n\r\n/**\r\n * Properties that can be used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\r\n *\r\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\r\n *\r\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\r\n * - `assets/*\\*\\/*`\r\n * - `presentation-backend/{presentation-backend source files}`\r\n *\r\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\r\n *\r\n * - else, assume the backend is webpacked into a single file with assets next to it:\r\n * - `assets/*\\*\\/*`\r\n * - `{source file being executed}.js`\r\n *\r\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\r\n *\r\n * @deprecated in 4.2. This attribute is not used anymore - the package is not using private assets anymore.\r\n */\r\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\r\n\r\n /**\r\n * A list of directories containing application's presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n rulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's supplemental presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n supplementalRulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's locale-specific localized\r\n * string files (in simplified i18next v3 format)\r\n *\r\n * @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n localeDirectories?: string[];\r\n\r\n /**\r\n * Sets the active locale to use when localizing presentation-related\r\n * strings. It can later be changed through [[PresentationManager.activeLocale]].\r\n *\r\n * @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n defaultLocale?: string;\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. Default presentation units are used if this is not specified. The active unit\r\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\r\n * through request options.\r\n */\r\n defaultUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * A map of default unit formats to use for formatting properties that don't have a presentation format\r\n * in requested unit system.\r\n */\r\n defaultFormats?: FormatsMap;\r\n\r\n /**\r\n * Should schemas preloading be enabled. If true, presentation manager listens\r\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\r\n *\r\n * @deprecated in 3.x. Use [[PresentationPropsBase.enableSchemasPreload]] instead.\r\n */\r\n enableSchemasPreload?: boolean;\r\n\r\n /**\r\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\r\n */\r\n workerThreadsCount?: number;\r\n\r\n /**\r\n * Presentation manager working mode. Backends that use iModels in read-write mode should\r\n * use `ReadWrite`, others might want to set to `ReadOnly` for better performance.\r\n *\r\n * Defaults to [[PresentationManagerMode.ReadWrite]].\r\n *\r\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\r\n */\r\n mode?: PresentationManagerMode; // eslint-disable-line deprecation/deprecation\r\n\r\n /**\r\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\r\n * data changes are not tracked at all.\r\n *\r\n * @beta\r\n * @deprecated in 4.4. The manager now always tracks for iModel data changes without polling.\r\n */\r\n updatesPollInterval?: number;\r\n\r\n /** Options for caching. */\r\n caching?: PresentationManagerCachingConfig;\r\n\r\n /**\r\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\r\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\r\n *\r\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\r\n */\r\n useMmap?: boolean | number;\r\n\r\n /**\r\n * An identifier which helps separate multiple presentation managers. It's\r\n * mostly useful in tests where multiple presentation managers can co-exist\r\n * and try to share the same resources, which we don't want. With this identifier\r\n * set, managers put their resources into id-named subdirectories.\r\n *\r\n * @internal\r\n */\r\n id?: string;\r\n\r\n /** @internal */\r\n addon?: NativePlatformDefinition;\r\n\r\n /**\r\n * Localization function to localize data returned by presentation manager when it's used directly on the backend (as opposed to when used through RPC, where\r\n * data is localized on the frontend). Defaults to English localization.\r\n *\r\n * @see [Localization]($docs/presentation/advanced/Localization)\r\n */\r\n getLocalizedString?: (key: string) => string;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n */\r\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\r\n\r\n /**\r\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\r\n * made through the manager.\r\n *\r\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\r\n */\r\n diagnostics?: BackendDiagnosticsOptions;\r\n}\r\n\r\n/**\r\n * Backend Presentation manager which pulls the presentation data from\r\n * an iModel using native platform.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager {\r\n private _props: PresentationManagerProps;\r\n private _detail: PresentationManagerDetail;\r\n private _localizationHelper: LocalizationHelper;\r\n\r\n /**\r\n * Get / set active locale used for localizing presentation data\r\n * @deprecated in 3.x. Use [[PresentationManagerProps.getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n public activeLocale: string | undefined;\r\n\r\n /**\r\n * Creates an instance of PresentationManager.\r\n * @param props Optional configuration properties.\r\n */\r\n constructor(props?: PresentationManagerProps) {\r\n this._props = props ?? {};\r\n this._detail = new PresentationManagerDetail(this._props);\r\n this.activeLocale = this._props.defaultLocale; // eslint-disable-line deprecation/deprecation\r\n\r\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\r\n }\r\n\r\n /** Get / set active unit system used to format property values with units */\r\n public get activeUnitSystem(): UnitSystemKey | undefined {\r\n return this._detail.activeUnitSystem;\r\n }\r\n // istanbul ignore next\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._detail.activeUnitSystem = value;\r\n }\r\n\r\n /** Dispose the presentation manager. Must be called to clean up native resources. */\r\n public dispose() {\r\n this._detail.dispose();\r\n }\r\n\r\n /** @internal */\r\n public setOnManagerUsedHandler(handler: () => void) {\r\n this._detail.setOnManagerUsedHandler(handler);\r\n }\r\n\r\n /** Properties used to initialize the manager */\r\n public get props() {\r\n return this._props;\r\n }\r\n\r\n /** Get rulesets manager */\r\n public rulesets(): RulesetManager {\r\n return this._detail.rulesets;\r\n }\r\n\r\n /**\r\n * Get ruleset variables manager for specific ruleset\r\n * @param rulesetId Id of the ruleset to get variables manager for\r\n */\r\n public vars(rulesetId: string): RulesetVariablesManager {\r\n return new RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);\r\n }\r\n\r\n /** @internal */\r\n public getNativePlatform = (): NativePlatformDefinition => {\r\n return this._detail.getNativePlatform();\r\n };\r\n\r\n /** @internal */\r\n // istanbul ignore next\r\n public getDetail(): PresentationManagerDetail {\r\n return this._detail;\r\n }\r\n\r\n /** @internal */\r\n public getRulesetId(rulesetOrId: Ruleset | string) {\r\n return this._detail.getRulesetId(rulesetOrId);\r\n }\r\n\r\n /**\r\n * Retrieves nodes\r\n * @public\r\n */\r\n public async getNodes(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Node[]> {\r\n const serializedNodesJson = await this._detail.getNodes(requestOptions);\r\n // eslint-disable-next-line deprecation/deprecation\r\n const nodesJson = JSON.parse(serializedNodesJson) as HierarchyLevelJSON;\r\n const nodes = Node.listFromJSON(nodesJson.nodes);\r\n return this._localizationHelper.getLocalizedNodes(nodes);\r\n }\r\n\r\n /**\r\n * Retrieves nodes count\r\n * @public\r\n */\r\n public async getNodesCount(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getNodesCount(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor\r\n * @public\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getNodesDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\r\n * TODO: Return results in pages\r\n * @public\r\n */\r\n public async getNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to nodes containing filter text in their label.\r\n * TODO: Return results in pages\r\n * @public\r\n */\r\n public async getFilteredNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getFilteredNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\r\n * its related instances for loading related and navigation properties.\r\n * @public\r\n */\r\n public async getContentSources(\r\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<SelectClassInfo[]> {\r\n return this._detail.getContentSources(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content descriptor which can be used to get content\r\n * @public\r\n */\r\n public async getContentDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getContentDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the content set size based on the supplied content descriptor override\r\n * @public\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 return this._detail.getContentSetSize(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content set based on the supplied content descriptor.\r\n * @public\r\n */\r\n public async getContentSet(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Item[]> {\r\n let items = await this._detail.getContentSet({\r\n ...requestOptions,\r\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\r\n const formatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\r\n );\r\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContentItems(items);\r\n }\r\n\r\n /**\r\n * Retrieves the content based on the supplied content descriptor override.\r\n * @public\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 content = await this._detail.getContent({\r\n ...requestOptions,\r\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n if (!content) {\r\n return undefined;\r\n }\r\n\r\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\r\n const formatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\r\n );\r\n await formatter.formatContent(content);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContent(content);\r\n }\r\n\r\n /**\r\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\r\n * @param requestOptions Options for the request\r\n * @return A promise object that returns either distinct values on success or an error string on error.\r\n * @public\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 result = await this._detail.getPagedDistinctValues(requestOptions);\r\n return {\r\n ...result,\r\n // eslint-disable-next-line deprecation/deprecation\r\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves property data in a simplified format for a single element specified by ID.\r\n * @public\r\n */\r\n public async getElementProperties(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<ElementProperties | undefined>;\r\n /**\r\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\r\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<\r\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\r\n > &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<ElementProperties | undefined | MultiElementPropertiesResponse<TParsedContent>> {\r\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\r\n const elementProperties = await this._detail.getElementProperties(requestOptions);\r\n // istanbul ignore if\r\n if (!elementProperties) {\r\n return undefined;\r\n }\r\n return this._localizationHelper.getLocalizedElementProperties(elementProperties);\r\n }\r\n\r\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n\r\n private async getMultipleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\r\n type TParser = Required<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>[\"contentParser\"];\r\n const { elementClasses, contentParser, batchSize, ...contentOptions } = requestOptions;\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\r\n\r\n // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory\r\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\r\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\r\n // most `workerThreadsCount / 2` classes in parallel.\r\n // istanbul ignore next\r\n const classParallelism = workerThreadsCount > 1 ? workerThreadsCount / 2 : 1;\r\n\r\n // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,\r\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\r\n // To avoid that, we keep twice as much requests active.\r\n // istanbul ignore next\r\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount * 2 : 2;\r\n\r\n const createClassContentRuleset = (fullClassName: string): Ruleset => {\r\n const [schemaName, className] = parseFullClassName(fullClassName);\r\n return {\r\n id: `content/${fullClassName}`,\r\n rules: [\r\n {\r\n ruleType: \"Content\",\r\n specifications: [\r\n {\r\n specType: \"ContentInstancesOfSpecificClasses\",\r\n classes: {\r\n schemaName,\r\n classNames: [className],\r\n arePolymorphic: false,\r\n },\r\n handlePropertiesPolymorphically: true,\r\n },\r\n ],\r\n },\r\n ],\r\n };\r\n };\r\n const getContentDescriptor = async (ruleset: Ruleset): Promise<Descriptor> => {\r\n return (await this.getContentDescriptor({\r\n ...contentOptions,\r\n rulesetOrId: ruleset,\r\n displayType: DefaultContentDisplayTypes.Grid,\r\n contentFlags: ContentFlags.ShowLabels,\r\n keys: new KeySet(),\r\n }))!;\r\n };\r\n\r\n const obs = getClassesWithInstances(requestOptions.imodel, elementClasses ?? /* istanbul ignore next */ [\"BisCore.Element\"]).pipe(\r\n map((classFullName) => ({\r\n classFullName,\r\n ruleset: createClassContentRuleset(classFullName),\r\n })),\r\n mergeMap(\r\n ({ classFullName, ruleset }) =>\r\n // use forkJoin to query descriptor and element ids in parallel\r\n forkJoin({\r\n classFullName: of(classFullName),\r\n ruleset: of(ruleset),\r\n descriptor: from(getContentDescriptor(ruleset)),\r\n batches: from(getBatchedClassElementIds(requestOptions.imodel, classFullName, batchSize ?? /* istanbul ignore next */ 1000)),\r\n }).pipe(\r\n // split incoming stream into individual batch requests\r\n mergeMap(({ descriptor, batches }) => from(batches.map((batch) => ({ classFullName, descriptor, batch })))),\r\n // request content for each batch, filter by IDs for performance\r\n mergeMap(({ descriptor, batch }) => {\r\n const filteringDescriptor = new Descriptor(descriptor);\r\n filteringDescriptor.instanceFilter = {\r\n selectClassName: classFullName,\r\n expression: `this.ECInstanceId >= ${Number.parseInt(batch.from, 16)} AND this.ECInstanceId <= ${Number.parseInt(batch.to, 16)}`,\r\n };\r\n return from(\r\n this.getContentSet({\r\n ...contentOptions,\r\n keys: new KeySet(),\r\n descriptor: filteringDescriptor,\r\n rulesetOrId: ruleset,\r\n }),\r\n ).pipe(map((items) => ({ classFullName, descriptor, items })));\r\n }, batchesParallelism),\r\n ),\r\n classParallelism,\r\n ),\r\n map(({ descriptor, items }) => items.map((item) => parser(descriptor, item))),\r\n );\r\n\r\n return {\r\n total: getElementsCount(requestOptions.imodel, elementClasses),\r\n async *iterator() {\r\n for await (const batch of eachValueFrom(obs)) {\r\n yield batch;\r\n }\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves display label definition of specific item\r\n * @public\r\n */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\r\n }\r\n\r\n /**\r\n * Retrieves display label definitions of specific items\r\n * @public\r\n */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition[]> {\r\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\r\n }\r\n\r\n /**\r\n * Retrieves available selection scopes.\r\n * @public\r\n */\r\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\r\n return SelectionScopesHelper.getSelectionScopes();\r\n }\r\n\r\n /**\r\n * Computes selection set based on provided selection scope.\r\n * @public\r\n * @deprecated in 3.x. Use overload with `ComputeSelectionRequestOptions` parameter.\r\n */\r\n public async computeSelection(\r\n requestOptions: SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[]; scopeId: string } & BackendDiagnosticsAttribute,\r\n ): Promise<KeySet>;\r\n /**\r\n * Computes selection based on provided element IDs and selection scope.\r\n * @public\r\n */\r\n // eslint-disable-next-line @typescript-eslint/unified-signatures\r\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet>;\r\n public async computeSelection(\r\n requestOptions: ((SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[]; scopeId: string }) | ComputeSelectionRequestOptions<IModelDb>) &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<KeySet> {\r\n return SelectionScopesHelper.computeSelection(\r\n isComputeSelectionRequestOptions(requestOptions)\r\n ? requestOptions\r\n : (function () {\r\n const { ids, scopeId, ...rest } = requestOptions;\r\n return { ...rest, elementIds: ids, scope: { id: scopeId } };\r\n })(),\r\n );\r\n }\r\n\r\n /**\r\n * Compares two hierarchies specified in the request options\r\n * @public\r\n */\r\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\r\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\r\n return { changes: [] };\r\n }\r\n\r\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\r\n this._detail.registerRuleset(rulesetOrId);\r\n\r\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\r\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\r\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\r\n }\r\n\r\n const currRulesetVariables = rulesetVariables ?? [];\r\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\r\n\r\n const params = {\r\n requestId: NativePlatformRequestTypes.CompareHierarchies,\r\n ...options,\r\n prevRulesetId: prevRulesetId.uniqueId,\r\n currRulesetId: currRulesetId.uniqueId,\r\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\r\n currRulesetVariables: JSON.stringify(currRulesetVariables),\r\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\r\n };\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n const reviver = (key: string, value: any) => (key === \"\" ? HierarchyCompareInfo.fromJSON(value) : value);\r\n return JSON.parse(await this._detail.request(params), reviver);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAyD;AACzD,mDAA+C;AAK/C,oEAmDoC;AACpC,uEAAqI;AACrI,qDAAwF;AACxF,2EAA4F;AAE5F,uEAAiG;AACjG,mEAAgE;AAChE,mCAAuG;AAEvG;;;;GAIG;AACH,IAAY,uBAYX;AAZD,WAAY,uBAAuB;IACjC;;;OAGG;IACH,6EAAQ,CAAA;IAER;;;OAGG;IACH,+EAAS,CAAA;AACX,CAAC,EAZW,uBAAuB,uCAAvB,uBAAuB,QAYlC;AAED;;;GAGG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,uCAAiB,CAAA;IAC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AAG,IAAI,CAAC,gBAAgB,IAAI,oBAAoB,CAAC;QAE3E,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,2CAA0B,CAAC,kBAAkB;YACxD,GAAG,OAAO;YACV,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;SACjE,CAAC;QAEF,mDAAmD;QACnD,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,0CAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzG,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;CACF;AAneD,kDAmeC","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/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { forkJoin, from, map, mergeMap, of } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { IModelDb } from \"@itwin/core-backend\";\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n buildElementProperties,\r\n UnitSystemFormat as CommonUnitSystemFormat,\r\n ComputeSelectionRequestOptions,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentFormatter,\r\n ContentPropertyValueFormatter,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyCompareInfo,\r\n HierarchyCompareOptions,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyLevelJSON,\r\n HierarchyRequestOptions,\r\n InstanceKey,\r\n isComputeSelectionRequestOptions,\r\n isSingleElementPropertiesRequestOptions,\r\n Item,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n LocalizationHelper,\r\n MultiElementPropertiesRequestOptions,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PresentationError,\r\n PresentationStatus,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SelectionScope,\r\n SelectionScopeRequestOptions,\r\n SingleElementPropertiesRequestOptions,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport { getBatchedClassElementIds, getClassesWithInstances, getElementsCount, parseFullClassName } from \"./ElementPropertiesHelper\";\r\nimport { NativePlatformDefinition, NativePlatformRequestTypes } from \"./NativePlatform\";\r\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail\";\r\nimport { RulesetManager } from \"./RulesetManager\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\r\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper\";\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils\";\r\n\r\n/**\r\n * Presentation manager working mode.\r\n * @public\r\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\r\n */\r\nexport enum PresentationManagerMode {\r\n /**\r\n * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work\r\n * related to reacting to changes in iModels.\r\n */\r\n ReadOnly,\r\n\r\n /**\r\n * Presentation manager assumes iModels are opened in read-write mode and it may need to\r\n * react to changes. This involves some additional work and gives slightly worse performance.\r\n */\r\n ReadWrite,\r\n}\r\n\r\n/**\r\n * Presentation hierarchy cache mode.\r\n * @public\r\n */\r\nexport enum HierarchyCacheMode {\r\n /**\r\n * Hierarchy cache is created in memory.\r\n */\r\n Memory = \"memory\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\r\n * openings.\r\n */\r\n Disk = \"disk\",\r\n /**\r\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\r\n * and persisted in disk cache when whole hierarchy level is created.\r\n *\r\n * **Note:** This mode is still experimental.\r\n */\r\n Hybrid = \"hybrid\",\r\n}\r\n\r\n/**\r\n * Configuration for hierarchy cache.\r\n * @public\r\n */\r\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\r\n\r\n/**\r\n * Base interface for all [[HierarchyCacheConfig]] implementations.\r\n * @public\r\n */\r\nexport interface HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode;\r\n}\r\n\r\n/**\r\n * Configuration for in-memory hierarchy cache.\r\n *\r\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\r\n * @public\r\n */\r\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Memory;\r\n}\r\n\r\n/**\r\n * Configuration for persistent disk hierarchy cache.\r\n *\r\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\r\n * @public\r\n */\r\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Disk;\r\n\r\n /**\r\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\r\n *\r\n * The default directory depends on the iModel and the way it's opened.\r\n */\r\n directory?: string;\r\n\r\n /**\r\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\r\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\r\n */\r\n memoryCacheSize?: number;\r\n}\r\n\r\n/**\r\n * Configuration for the experimental hybrid hierarchy cache.\r\n *\r\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\r\n * alternative for cases when there are lots of simultaneous requests.\r\n *\r\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\r\n * @public\r\n */\r\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\r\n mode: HierarchyCacheMode.Hybrid;\r\n\r\n /** Configuration for disk cache used to persist hierarchies. */\r\n disk?: DiskHierarchyCacheConfig;\r\n}\r\n\r\n/**\r\n * Configuration for content cache.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n * @public\r\n */\r\nexport interface ContentCacheConfig {\r\n /**\r\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\r\n *\r\n * Defaults to `100`.\r\n */\r\n size?: number;\r\n}\r\n\r\n/**\r\n * Caching configuration options for [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationManagerCachingConfig {\r\n /**\r\n * Hierarchies-related caching options.\r\n *\r\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\r\n */\r\n hierarchies?: HierarchyCacheConfig;\r\n\r\n /**\r\n * Content-related caching options.\r\n *\r\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\r\n */\r\n content?: ContentCacheConfig;\r\n\r\n /**\r\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\r\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\r\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\r\n * cache. Defaults to `32768000` bytes (32 MB).\r\n *\r\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\r\n */\r\n workerConnectionCacheSize?: number;\r\n}\r\n\r\n/**\r\n * A data structure that associates unit systems with a format. The associations are used for\r\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\r\n *\r\n * @public\r\n * @deprecated in 4.3. The type has been moved to `@itwin/presentation-common` package.\r\n */\r\nexport type UnitSystemFormat = CommonUnitSystemFormat;\r\n\r\n/**\r\n * Data structure for multiple element properties request response.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\r\n total: number;\r\n iterator: () => AsyncGenerator<TParsedContent[]>;\r\n}\r\n\r\n/**\r\n * Configuration options for supplying asset paths to [[PresentationManager]].\r\n * @public\r\n */\r\nexport interface PresentationAssetsRootConfig {\r\n /**\r\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\r\n */\r\n backend: string;\r\n\r\n /**\r\n * Path to `presentation-common` assets.\r\n *\r\n * @deprecated in 3.x. This path is not used anymore\r\n */\r\n common: string;\r\n}\r\n\r\n/**\r\n * Properties that can be used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\r\n *\r\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\r\n *\r\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\r\n * - `assets/*\\*\\/*`\r\n * - `presentation-backend/{presentation-backend source files}`\r\n *\r\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\r\n *\r\n * - else, assume the backend is webpacked into a single file with assets next to it:\r\n * - `assets/*\\*\\/*`\r\n * - `{source file being executed}.js`\r\n *\r\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\r\n *\r\n * @deprecated in 4.2. This attribute is not used anymore - the package is not using private assets anymore.\r\n */\r\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\r\n\r\n /**\r\n * A list of directories containing application's presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n rulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's supplemental presentation rulesets. Relative\r\n * paths start from `process.cwd()`. The directories are traversed recursively.\r\n *\r\n * @note Only files with `.PresentationRuleSet.json` are read.\r\n */\r\n supplementalRulesetDirectories?: string[];\r\n\r\n /**\r\n * A list of directories containing application's locale-specific localized\r\n * string files (in simplified i18next v3 format)\r\n *\r\n * @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n localeDirectories?: string[];\r\n\r\n /**\r\n * Sets the active locale to use when localizing presentation-related\r\n * strings. It can later be changed through [[PresentationManager.activeLocale]].\r\n *\r\n * @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n defaultLocale?: string;\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. Default presentation units are used if this is not specified. The active unit\r\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\r\n * through request options.\r\n */\r\n defaultUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * A map of default unit formats to use for formatting properties that don't have a presentation format\r\n * in requested unit system.\r\n */\r\n defaultFormats?: FormatsMap;\r\n\r\n /**\r\n * Should schemas preloading be enabled. If true, presentation manager listens\r\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\r\n *\r\n * @deprecated in 3.x. Use [[PresentationPropsBase.enableSchemasPreload]] instead.\r\n */\r\n enableSchemasPreload?: boolean;\r\n\r\n /**\r\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\r\n */\r\n workerThreadsCount?: number;\r\n\r\n /**\r\n * Presentation manager working mode. Backends that use iModels in read-write mode should\r\n * use `ReadWrite`, others might want to set to `ReadOnly` for better performance.\r\n *\r\n * Defaults to [[PresentationManagerMode.ReadWrite]].\r\n *\r\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\r\n */\r\n mode?: PresentationManagerMode; // eslint-disable-line deprecation/deprecation\r\n\r\n /**\r\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\r\n * data changes are not tracked at all.\r\n *\r\n * @beta\r\n * @deprecated in 4.4. The manager now always tracks for iModel data changes without polling.\r\n */\r\n updatesPollInterval?: number;\r\n\r\n /** Options for caching. */\r\n caching?: PresentationManagerCachingConfig;\r\n\r\n /**\r\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\r\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\r\n *\r\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\r\n */\r\n useMmap?: boolean | number;\r\n\r\n /**\r\n * An identifier which helps separate multiple presentation managers. It's\r\n * mostly useful in tests where multiple presentation managers can co-exist\r\n * and try to share the same resources, which we don't want. With this identifier\r\n * set, managers put their resources into id-named subdirectories.\r\n *\r\n * @internal\r\n */\r\n id?: string;\r\n\r\n /** @internal */\r\n addon?: NativePlatformDefinition;\r\n\r\n /**\r\n * Localization function to localize data returned by presentation manager when it's used directly on the backend (as opposed to when used through RPC, where\r\n * data is localized on the frontend). Defaults to English localization.\r\n *\r\n * @see [Localization]($docs/presentation/advanced/Localization)\r\n */\r\n getLocalizedString?: (key: string) => string;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n */\r\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\r\n\r\n /**\r\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\r\n * made through the manager.\r\n *\r\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\r\n */\r\n diagnostics?: BackendDiagnosticsOptions;\r\n}\r\n\r\n/**\r\n * Backend Presentation manager which pulls the presentation data from\r\n * an iModel using native platform.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager {\r\n private _props: PresentationManagerProps;\r\n private _detail: PresentationManagerDetail;\r\n private _localizationHelper: LocalizationHelper;\r\n\r\n /**\r\n * Get / set active locale used for localizing presentation data\r\n * @deprecated in 3.x. Use [[PresentationManagerProps.getLocalizedString]] to localize data returned by [[PresentationManager]].\r\n */\r\n public activeLocale: string | undefined;\r\n\r\n /**\r\n * Creates an instance of PresentationManager.\r\n * @param props Optional configuration properties.\r\n */\r\n constructor(props?: PresentationManagerProps) {\r\n this._props = props ?? {};\r\n this._detail = new PresentationManagerDetail(this._props);\r\n this.activeLocale = this._props.defaultLocale; // eslint-disable-line deprecation/deprecation\r\n\r\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\r\n }\r\n\r\n /** Get / set active unit system used to format property values with units */\r\n public get activeUnitSystem(): UnitSystemKey | undefined {\r\n return this._detail.activeUnitSystem;\r\n }\r\n // istanbul ignore next\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._detail.activeUnitSystem = value;\r\n }\r\n\r\n /** Dispose the presentation manager. Must be called to clean up native resources. */\r\n public dispose() {\r\n this._detail.dispose();\r\n }\r\n\r\n /** @internal */\r\n public setOnManagerUsedHandler(handler: () => void) {\r\n this._detail.setOnManagerUsedHandler(handler);\r\n }\r\n\r\n /** Properties used to initialize the manager */\r\n public get props() {\r\n return this._props;\r\n }\r\n\r\n /** Get rulesets manager */\r\n public rulesets(): RulesetManager {\r\n return this._detail.rulesets;\r\n }\r\n\r\n /**\r\n * Get ruleset variables manager for specific ruleset\r\n * @param rulesetId Id of the ruleset to get variables manager for\r\n */\r\n public vars(rulesetId: string): RulesetVariablesManager {\r\n return new RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);\r\n }\r\n\r\n /** @internal */\r\n public getNativePlatform = (): NativePlatformDefinition => {\r\n return this._detail.getNativePlatform();\r\n };\r\n\r\n /** @internal */\r\n // istanbul ignore next\r\n public getDetail(): PresentationManagerDetail {\r\n return this._detail;\r\n }\r\n\r\n /** @internal */\r\n public getRulesetId(rulesetOrId: Ruleset | string) {\r\n return this._detail.getRulesetId(rulesetOrId);\r\n }\r\n\r\n /**\r\n * Retrieves nodes\r\n * @public\r\n */\r\n public async getNodes(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Node[]> {\r\n const serializedNodesJson = await this._detail.getNodes(requestOptions);\r\n // eslint-disable-next-line deprecation/deprecation\r\n const nodesJson = JSON.parse(serializedNodesJson) as HierarchyLevelJSON;\r\n const nodes = Node.listFromJSON(nodesJson.nodes);\r\n return this._localizationHelper.getLocalizedNodes(nodes);\r\n }\r\n\r\n /**\r\n * Retrieves nodes count\r\n * @public\r\n */\r\n public async getNodesCount(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<number> {\r\n return this._detail.getNodesCount(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor\r\n * @public\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getNodesDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\r\n * TODO: Return results in pages\r\n * @public\r\n */\r\n public async getNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Retrieves paths from root nodes to nodes containing filter text in their label.\r\n * TODO: Return results in pages\r\n * @public\r\n */\r\n public async getFilteredNodePaths(\r\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n const result = await this._detail.getFilteredNodePaths(requestOptions);\r\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\r\n * its related instances for loading related and navigation properties.\r\n * @public\r\n */\r\n public async getContentSources(\r\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<SelectClassInfo[]> {\r\n return this._detail.getContentSources(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content descriptor which can be used to get content\r\n * @public\r\n */\r\n public async getContentDescriptor(\r\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n const response = await this._detail.getContentDescriptor(requestOptions);\r\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the content set size based on the supplied content descriptor override\r\n * @public\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 return this._detail.getContentSetSize(requestOptions);\r\n }\r\n\r\n /**\r\n * Retrieves the content set based on the supplied content descriptor.\r\n * @public\r\n */\r\n public async getContentSet(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<Item[]> {\r\n let items = await this._detail.getContentSet({\r\n ...requestOptions,\r\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\r\n const formatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\r\n );\r\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContentItems(items);\r\n }\r\n\r\n /**\r\n * Retrieves the content based on the supplied content descriptor override.\r\n * @public\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 content = await this._detail.getContent({\r\n ...requestOptions,\r\n ...(!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n if (!content) {\r\n return undefined;\r\n }\r\n\r\n if (!requestOptions.omitFormattedValues && this.props.schemaContextProvider !== undefined) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this.props.schemaContextProvider(requestOptions.imodel), this.props.defaultFormats);\r\n const formatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this.props.defaultUnitSystem,\r\n );\r\n await formatter.formatContent(content);\r\n }\r\n\r\n return this._localizationHelper.getLocalizedContent(content);\r\n }\r\n\r\n /**\r\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\r\n * @param requestOptions Options for the request\r\n * @return A promise object that returns either distinct values on success or an error string on error.\r\n * @public\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 result = await this._detail.getPagedDistinctValues(requestOptions);\r\n return {\r\n ...result,\r\n // eslint-disable-next-line deprecation/deprecation\r\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves property data in a simplified format for a single element specified by ID.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined>;\r\n /**\r\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\r\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: WithCancelEvent<\r\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\r\n > &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\r\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\r\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\r\n }\r\n\r\n private async getSingleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const content = await this.getContent({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!content || content.contentSet.length === 0) {\r\n return undefined;\r\n }\r\n return parser(content.descriptor, content.contentSet[0]);\r\n }\r\n\r\n private async getMultipleElementProperties<TParsedContent>(\r\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\r\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementClasses, contentParser, batchSize, ...contentOptions } = requestOptions;\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\r\n\r\n // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory\r\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\r\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\r\n // most `workerThreadsCount / 2` classes in parallel.\r\n // istanbul ignore next\r\n const classParallelism = workerThreadsCount > 1 ? workerThreadsCount / 2 : 1;\r\n\r\n // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,\r\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\r\n // To avoid that, we keep twice as much requests active.\r\n // istanbul ignore next\r\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount * 2 : 2;\r\n\r\n const createClassContentRuleset = (fullClassName: string): Ruleset => {\r\n const [schemaName, className] = parseFullClassName(fullClassName);\r\n return {\r\n id: `content/${fullClassName}`,\r\n rules: [\r\n {\r\n ruleType: \"Content\",\r\n specifications: [\r\n {\r\n specType: \"ContentInstancesOfSpecificClasses\",\r\n classes: {\r\n schemaName,\r\n classNames: [className],\r\n arePolymorphic: false,\r\n },\r\n handlePropertiesPolymorphically: true,\r\n },\r\n ],\r\n },\r\n ],\r\n };\r\n };\r\n const getContentDescriptor = async (ruleset: Ruleset): Promise<Descriptor> => {\r\n return (await this.getContentDescriptor({\r\n ...contentOptions,\r\n rulesetOrId: ruleset,\r\n displayType: DefaultContentDisplayTypes.Grid,\r\n contentFlags: ContentFlags.ShowLabels,\r\n keys: new KeySet(),\r\n }))!;\r\n };\r\n\r\n const obs = getClassesWithInstances(requestOptions.imodel, elementClasses ?? /* istanbul ignore next */ [\"BisCore.Element\"]).pipe(\r\n map((classFullName) => ({\r\n classFullName,\r\n ruleset: createClassContentRuleset(classFullName),\r\n })),\r\n mergeMap(\r\n ({ classFullName, ruleset }) =>\r\n // use forkJoin to query descriptor and element ids in parallel\r\n forkJoin({\r\n classFullName: of(classFullName),\r\n ruleset: of(ruleset),\r\n descriptor: from(getContentDescriptor(ruleset)),\r\n batches: from(getBatchedClassElementIds(requestOptions.imodel, classFullName, batchSize ?? /* istanbul ignore next */ 1000)),\r\n }).pipe(\r\n // split incoming stream into individual batch requests\r\n mergeMap(({ descriptor, batches }) => from(batches.map((batch) => ({ classFullName, descriptor, batch })))),\r\n // request content for each batch, filter by IDs for performance\r\n mergeMap(({ descriptor, batch }) => {\r\n const filteringDescriptor = new Descriptor(descriptor);\r\n filteringDescriptor.instanceFilter = {\r\n selectClassName: classFullName,\r\n expression: `this.ECInstanceId >= ${Number.parseInt(batch.from, 16)} AND this.ECInstanceId <= ${Number.parseInt(batch.to, 16)}`,\r\n };\r\n return from(\r\n this.getContentSet({\r\n ...contentOptions,\r\n keys: new KeySet(),\r\n descriptor: filteringDescriptor,\r\n rulesetOrId: ruleset,\r\n }),\r\n ).pipe(map((items) => ({ classFullName, descriptor, items })));\r\n }, batchesParallelism),\r\n ),\r\n classParallelism,\r\n ),\r\n map(({ descriptor, items }) => items.map((item) => parser(descriptor, item))),\r\n );\r\n\r\n return {\r\n total: getElementsCount(requestOptions.imodel, elementClasses),\r\n async *iterator() {\r\n for await (const batch of eachValueFrom(obs)) {\r\n yield batch;\r\n }\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves display label definition of specific item\r\n * @public\r\n */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\r\n }\r\n\r\n /**\r\n * Retrieves display label definitions of specific items\r\n * @public\r\n */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\r\n ): Promise<LabelDefinition[]> {\r\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\r\n }\r\n\r\n /**\r\n * Retrieves available selection scopes.\r\n * @public\r\n */\r\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\r\n return SelectionScopesHelper.getSelectionScopes();\r\n }\r\n\r\n /**\r\n * Computes selection set based on provided selection scope.\r\n * @public\r\n * @deprecated in 3.x. Use overload with `ComputeSelectionRequestOptions` parameter.\r\n */\r\n public async computeSelection(\r\n requestOptions: SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[]; scopeId: string } & BackendDiagnosticsAttribute,\r\n ): Promise<KeySet>;\r\n /**\r\n * Computes selection based on provided element IDs and selection scope.\r\n * @public\r\n */\r\n // eslint-disable-next-line @typescript-eslint/unified-signatures\r\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet>;\r\n public async computeSelection(\r\n requestOptions: ((SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[]; scopeId: string }) | ComputeSelectionRequestOptions<IModelDb>) &\r\n BackendDiagnosticsAttribute,\r\n ): Promise<KeySet> {\r\n return SelectionScopesHelper.computeSelection(\r\n isComputeSelectionRequestOptions(requestOptions)\r\n ? requestOptions\r\n : (function () {\r\n const { ids, scopeId, ...rest } = requestOptions;\r\n return { ...rest, elementIds: ids, scope: { id: scopeId } };\r\n })(),\r\n );\r\n }\r\n\r\n /**\r\n * Compares two hierarchies specified in the request options\r\n * @public\r\n */\r\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\r\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\r\n return { changes: [] };\r\n }\r\n\r\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\r\n this._detail.registerRuleset(rulesetOrId);\r\n\r\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\r\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\r\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\r\n }\r\n\r\n const currRulesetVariables = rulesetVariables ?? [];\r\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\r\n\r\n const params = {\r\n requestId: NativePlatformRequestTypes.CompareHierarchies,\r\n ...options,\r\n prevRulesetId: prevRulesetId.uniqueId,\r\n currRulesetId: currRulesetId.uniqueId,\r\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\r\n currRulesetVariables: JSON.stringify(currRulesetVariables),\r\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\r\n };\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n const reviver = (key: string, value: any) => (key === \"\" ? HierarchyCompareInfo.fromJSON(value) : value);\r\n return JSON.parse(await this._detail.request(params), reviver);\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IModelDb } from "@itwin/core-backend";
|
|
2
2
|
import { BeEvent, IDisposable } from "@itwin/core-bentley";
|
|
3
3
|
import { UnitSystemKey } from "@itwin/core-quantity";
|
|
4
|
-
import { Content, ContentDescriptorRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions,
|
|
4
|
+
import { Content, ContentDescriptorRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions, InstanceKey, Item, KeySet, LabelDefinition, NodeKey, NodePathElement, Paged, PagedResponse, Prioritized, Ruleset, RulesetVariable, SelectClassInfo, UpdateInfo, WithCancelEvent } from "@itwin/presentation-common";
|
|
5
5
|
import { NativePlatformDefinition, NativePresentationKeySetJSON } from "./NativePlatform";
|
|
6
6
|
import { PresentationManagerProps } from "./PresentationManager";
|
|
7
7
|
import { RulesetManager } from "./RulesetManager";
|
|
@@ -31,7 +31,6 @@ export declare class PresentationManagerDetail implements IDisposable {
|
|
|
31
31
|
getPagedDistinctValues(requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute): Promise<PagedResponse<DisplayValueGroup>>;
|
|
32
32
|
getDisplayLabelDefinition(requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute): Promise<LabelDefinition>;
|
|
33
33
|
getDisplayLabelDefinitions(requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute): Promise<LabelDefinition[]>;
|
|
34
|
-
getElementProperties(requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute): Promise<ElementProperties | undefined>;
|
|
35
34
|
/** Registers given ruleset and replaces the ruleset with its ID in the resulting object */
|
|
36
35
|
registerRuleset(rulesetOrId: Ruleset | string): string;
|
|
37
36
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManagerDetail.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManagerDetail.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAA2B,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACL,OAAO,EACP,+BAA+B,EAE/B,qBAAqB,EACrB,4BAA4B,EAE5B,UAAU,EACV,mBAAmB,EAGnB,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,4BAA4B,EAC5B,
|
|
1
|
+
{"version":3,"file":"PresentationManagerDetail.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManagerDetail.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAA2B,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACL,OAAO,EACP,+BAA+B,EAE/B,qBAAqB,EACrB,4BAA4B,EAE5B,UAAU,EACV,mBAAmB,EAGnB,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,4BAA4B,EAC5B,4CAA4C,EAC5C,mCAAmC,EAEnC,sCAAsC,EACtC,uBAAuB,EACvB,WAAW,EACX,IAAI,EAEJ,MAAM,EACN,eAAe,EACf,OAAO,EACP,eAAe,EACf,KAAK,EACL,aAAa,EAIb,WAAW,EACX,OAAO,EACP,eAAe,EACf,eAAe,EACf,UAAU,EACV,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEL,wBAAwB,EAIxB,4BAA4B,EAG7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA4C,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,cAAc,EAAsB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAA+D,MAAM,SAAS,CAAC;AAE9I,gBAAgB;AAChB,qBAAa,yBAA0B,YAAW,WAAW;IAC3D,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,eAAe,CAAuC;IAC9D,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,mBAAmB,CAAwC;IAE5D,QAAQ,EAAE,cAAc,CAAC;IACzB,gBAAgB,EAAE,aAAa,GAAG,SAAS,CAAC;gBA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const core_backend_1 = require("@itwin/core-backend");
|
|
34
34
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
35
35
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
36
|
-
const
|
|
36
|
+
const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
37
37
|
const NativePlatform_1 = require("./NativePlatform");
|
|
38
38
|
const PresentationManager_1 = require("./PresentationManager");
|
|
39
39
|
const RulesetManager_1 = require("./RulesetManager");
|
|
40
40
|
const Utils_1 = require("./Utils");
|
|
41
|
-
const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
42
41
|
/** @internal */
|
|
43
42
|
class PresentationManagerDetail {
|
|
44
43
|
constructor(params) {
|
|
@@ -229,22 +228,6 @@ class PresentationManagerDetail {
|
|
|
229
228
|
return item.label;
|
|
230
229
|
});
|
|
231
230
|
}
|
|
232
|
-
async getElementProperties(requestOptions) {
|
|
233
|
-
const { elementId, ...optionsNoElementId } = requestOptions;
|
|
234
|
-
const content = await this.getContent({
|
|
235
|
-
...optionsNoElementId,
|
|
236
|
-
descriptor: {
|
|
237
|
-
displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
|
|
238
|
-
contentFlags: presentation_common_1.ContentFlags.ShowLabels,
|
|
239
|
-
},
|
|
240
|
-
rulesetOrId: "ElementProperties",
|
|
241
|
-
keys: new presentation_common_1.KeySet([{ className: "BisCore:Element", id: elementId }]),
|
|
242
|
-
});
|
|
243
|
-
if (!content || content.contentSet.length === 0) {
|
|
244
|
-
return undefined;
|
|
245
|
-
}
|
|
246
|
-
return (0, ElementPropertiesHelper_1.buildElementProperties)(content.descriptor, content.contentSet[0]);
|
|
247
|
-
}
|
|
248
231
|
/** Registers given ruleset and replaces the ruleset with its ID in the resulting object */
|
|
249
232
|
registerRuleset(rulesetOrId) {
|
|
250
233
|
if (typeof rulesetOrId === "object") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManagerDetail.js","sourceRoot":"","sources":["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AQ,GAAG,uBAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,qBAAM,CAAC,QAAQ,CAAC,yDAAiC,CAAC,mBAAmB,EAAE,+CAA+C,QAAQ,EAAE,CAAC,CAAC;YAClI,SAAS;QACX,CAAC;QAED,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC;AAED,gBAAgB;AAChB,SAAgB,iBAAiB,CAAC,IAA4B;IAC5D,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,MAAM,EAAE,CAAC;QACX,sBAAO,CAAC,IAAI,CAAC,2CAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AALD,8CAKC;AAED,gBAAgB;AAChB,uBAAuB;AACvB,SAAgB,kBAAkB,CAAC,KAA6B,IAAG,CAAC;AAApE,gDAAoE","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\nimport * as hash from \"object-hash\";\r\nimport * as path from \"path\";\r\nimport { IModelDb, IModelJsNative, IpcHost } from \"@itwin/core-backend\";\r\nimport { BeEvent, IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport {\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 ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyRequestOptions,\r\n InstanceKey,\r\n Item,\r\n Key,\r\n KeySet,\r\n LabelDefinition,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PresentationError,\r\n PresentationIpcEvents,\r\n PresentationStatus,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SingleElementPropertiesRequestOptions,\r\n UpdateInfo,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport { buildElementProperties } from \"./ElementPropertiesHelper\";\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\";\r\nimport { HierarchyCacheConfig, HierarchyCacheMode, PresentationManagerProps } from \"./PresentationManager\";\r\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager\";\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, combineDiagnosticsOptions, getElementKey, reportDiagnostics } from \"./Utils\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\n\r\n/** @internal */\r\nexport class PresentationManagerDetail implements IDisposable {\r\n private _disposed: boolean;\r\n private _nativePlatform: NativePlatformDefinition | undefined;\r\n private _onManagerUsed: (() => void) | undefined;\r\n private _diagnosticsOptions: BackendDiagnosticsOptions | undefined;\r\n\r\n public rulesets: RulesetManager;\r\n public activeUnitSystem: UnitSystemKey | undefined;\r\n\r\n constructor(params: PresentationManagerProps) {\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._onManagerUsed = undefined;\r\n this.rulesets = new RulesetManagerImpl(() => this.getNativePlatform());\r\n this._diagnosticsOptions = params.diagnostics;\r\n }\r\n\r\n public dispose(): void {\r\n if (this._disposed) {\r\n return;\r\n }\r\n\r\n this.getNativePlatform().dispose();\r\n this._nativePlatform = undefined;\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 PresentationError(PresentationStatus.NotInitialized, \"Attempting to use Presentation manager after disposal\");\r\n }\r\n\r\n return this._nativePlatform!;\r\n }\r\n\r\n public setOnManagerUsedHandler(handler: () => void) {\r\n this._onManagerUsed = handler;\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 return JSON.parse(await this.request(params), NodePathElement.listReviver);\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 return JSON.parse(await this.request(params), NodePathElement.listReviver);\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 ?? ContentFlags.DescriptorOnly, // 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 reviver = (key: string, value: any) => {\r\n return key === \"\" ? SelectClassInfo.listFromCompressedJSON(value.sources, value.classesMap) : value;\r\n };\r\n return JSON.parse(await this.request(params), reviver);\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 // eslint-disable-next-line @typescript-eslint/unbound-method\r\n return JSON.parse(await this.request(params), Item.listReviver);\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 JSON.parse(await this.request(params), (key, value) => Content.reviver(key, value));\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 const reviver = (key: string, value: any) => {\r\n return key === \"\"\r\n ? {\r\n total: value.total,\r\n // eslint-disable-next-line deprecation/deprecation\r\n items: value.items.map(DisplayValueGroup.fromJSON),\r\n }\r\n : value;\r\n };\r\n return JSON.parse(await this.request(params), reviver);\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 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 public async getElementProperties(\r\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\r\n ): Promise<ElementProperties | undefined> {\r\n const { elementId, ...optionsNoElementId } = requestOptions;\r\n const content = await this.getContent({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!content || content.contentSet.length === 0) {\r\n return undefined;\r\n }\r\n return buildElementProperties(content.descriptor, content.contentSet[0]);\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._onManagerUsed?.();\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 } 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 // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const elementPropertiesRuleset: Ruleset = require(\"./primary-presentation-rules/ElementProperties.PresentationRuleSet.json\");\r\n nativePlatform.addRuleset(JSON.stringify(elementPropertiesRuleset));\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const bisSupplementalRuleset: Ruleset = require(\"./supplemental-presentation-rules/BisCore.PresentationRuleSet.json\");\r\n nativePlatform.registerSupplementalRuleset(JSON.stringify(bisSupplementalRuleset));\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const funcSupplementalRuleset: Ruleset = require(\"./supplemental-presentation-rules/Functional.PresentationRuleSet.json\");\r\n nativePlatform.registerSupplementalRuleset(JSON.stringify(funcSupplementalRuleset));\r\n\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 // istanbul ignore else\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 // istanbul ignore if\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// istanbul ignore next\r\nexport function noopUpdatesHandler(_info: UpdateInfo | undefined) {}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationManagerDetail.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManagerDetail.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,kDAAoC;AACpC,2CAA6B;AAC7B,sDAAwE;AACxE,sDAAmE;AAEnE,oEAsCoC;AACpC,mEAA4E;AAC5E,qDAS0B;AAC1B,+DAA2G;AAC3G,qDAAsE;AACtE,mCAA8I;AAE9I,gBAAgB;AAChB,MAAa,yBAAyB;IASpC,YAAY,MAAgC;QAC1C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAEvB,IAAI,CAAC,eAAe;YAClB,MAAM,CAAC,KAAK;gBACZ,oBAAoB,CAClB,MAAM,CAAC,EAAE,IAAI,EAAE,EACf,MAAM,CAAC,kBAAkB,IAAI,CAAC,EAC9B,sBAAO,CAAC,OAAO,CAAC,C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QACX,CAAC;QAED,MAAM,QAAQ,GAAG,uBAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,qBAAM,CAAC,QAAQ,CAAC,yDAAiC,CAAC,mBAAmB,EAAE,+CAA+C,QAAQ,EAAE,CAAC,CAAC;YAClI,SAAS;QACX,CAAC;QAED,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC;AAED,gBAAgB;AAChB,SAAgB,iBAAiB,CAAC,IAA4B;IAC5D,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,MAAM,EAAE,CAAC;QACX,sBAAO,CAAC,IAAI,CAAC,2CAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AALD,8CAKC;AAED,gBAAgB;AAChB,uBAAuB;AACvB,SAAgB,kBAAkB,CAAC,KAA6B,IAAG,CAAC;AAApE,gDAAoE","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\nimport * as hash from \"object-hash\";\r\nimport * as path from \"path\";\r\nimport { IModelDb, IModelJsNative, IpcHost } from \"@itwin/core-backend\";\r\nimport { BeEvent, IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport {\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 Key,\r\n KeySet,\r\n LabelDefinition,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PresentationError,\r\n PresentationIpcEvents,\r\n PresentationStatus,\r\n Prioritized,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n UpdateInfo,\r\n WithCancelEvent,\r\n} from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\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\";\r\nimport { HierarchyCacheConfig, HierarchyCacheMode, PresentationManagerProps } from \"./PresentationManager\";\r\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager\";\r\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, combineDiagnosticsOptions, getElementKey, reportDiagnostics } from \"./Utils\";\r\n\r\n/** @internal */\r\nexport class PresentationManagerDetail implements IDisposable {\r\n private _disposed: boolean;\r\n private _nativePlatform: NativePlatformDefinition | undefined;\r\n private _onManagerUsed: (() => void) | undefined;\r\n private _diagnosticsOptions: BackendDiagnosticsOptions | undefined;\r\n\r\n public rulesets: RulesetManager;\r\n public activeUnitSystem: UnitSystemKey | undefined;\r\n\r\n constructor(params: PresentationManagerProps) {\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._onManagerUsed = undefined;\r\n this.rulesets = new RulesetManagerImpl(() => this.getNativePlatform());\r\n this._diagnosticsOptions = params.diagnostics;\r\n }\r\n\r\n public dispose(): void {\r\n if (this._disposed) {\r\n return;\r\n }\r\n\r\n this.getNativePlatform().dispose();\r\n this._nativePlatform = undefined;\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 PresentationError(PresentationStatus.NotInitialized, \"Attempting to use Presentation manager after disposal\");\r\n }\r\n\r\n return this._nativePlatform!;\r\n }\r\n\r\n public setOnManagerUsedHandler(handler: () => void) {\r\n this._onManagerUsed = handler;\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 return JSON.parse(await this.request(params), NodePathElement.listReviver);\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 return JSON.parse(await this.request(params), NodePathElement.listReviver);\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 ?? ContentFlags.DescriptorOnly, // 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 reviver = (key: string, value: any) => {\r\n return key === \"\" ? SelectClassInfo.listFromCompressedJSON(value.sources, value.classesMap) : value;\r\n };\r\n return JSON.parse(await this.request(params), reviver);\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 // eslint-disable-next-line @typescript-eslint/unbound-method\r\n return JSON.parse(await this.request(params), Item.listReviver);\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 JSON.parse(await this.request(params), (key, value) => Content.reviver(key, value));\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 const reviver = (key: string, value: any) => {\r\n return key === \"\"\r\n ? {\r\n total: value.total,\r\n // eslint-disable-next-line deprecation/deprecation\r\n items: value.items.map(DisplayValueGroup.fromJSON),\r\n }\r\n : value;\r\n };\r\n return JSON.parse(await this.request(params), reviver);\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 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._onManagerUsed?.();\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 } 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 // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const elementPropertiesRuleset: Ruleset = require(\"./primary-presentation-rules/ElementProperties.PresentationRuleSet.json\");\r\n nativePlatform.addRuleset(JSON.stringify(elementPropertiesRuleset));\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const bisSupplementalRuleset: Ruleset = require(\"./supplemental-presentation-rules/BisCore.PresentationRuleSet.json\");\r\n nativePlatform.registerSupplementalRuleset(JSON.stringify(bisSupplementalRuleset));\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const funcSupplementalRuleset: Ruleset = require(\"./supplemental-presentation-rules/Functional.PresentationRuleSet.json\");\r\n nativePlatform.registerSupplementalRuleset(JSON.stringify(funcSupplementalRuleset));\r\n\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 // istanbul ignore else\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 // istanbul ignore if\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// istanbul ignore next\r\nexport function noopUpdatesHandler(_info: UpdateInfo | undefined) {}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAmB,UAAU,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"PresentationRpcImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAmB,UAAU,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAIL,iCAAiC,EACjC,kCAAkC,EAElC,oCAAoC,EACpC,wBAAwB,EACxB,+BAA+B,EAC/B,uBAAuB,EAEvB,cAAc,EAEd,6BAA6B,EAC7B,8BAA8B,EAE9B,qBAAqB,EACrB,+BAA+B,EAC/B,iBAAiB,EACjB,+CAA+C,EAC/C,sCAAsC,EACtC,yCAAyC,EAEzC,0BAA0B,EAE1B,QAAQ,EAER,UAAU,EACV,eAAe,EACf,QAAQ,EAIR,mBAAmB,EACnB,KAAK,EACL,aAAa,EAGb,wBAAwB,EACxB,uBAAuB,EAQvB,cAAc,EACd,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAOtD,gBAAgB;AAChB,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AAG,uBAAuB,CAAC,cAAc,EAAE,CAAC;IAMrI,gBAAgB,CACpC,KAAK,EAAE,cAAc,EACrB,cAAc,EAAE,iCAAiC,GAAG,+BAA+B,EACnF,GAAG,CAAC,EAAE,UAAU,EAAE,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,uBAAuB,CAAC,UAAU,CAAC;CAavC"}
|
|
@@ -307,7 +307,21 @@ class PresentationRpcImpl extends presentation_common_1.PresentationRpcInterface
|
|
|
307
307
|
}
|
|
308
308
|
async getElementProperties(token, requestOptions) {
|
|
309
309
|
return this.makeRequest(token, "getElementProperties", { ...requestOptions }, async (options) => {
|
|
310
|
-
|
|
310
|
+
const manager = this.getManager(requestOptions.clientId);
|
|
311
|
+
const { elementId, ...optionsNoElementId } = options;
|
|
312
|
+
const content = await manager.getDetail().getContent({
|
|
313
|
+
...optionsNoElementId,
|
|
314
|
+
descriptor: {
|
|
315
|
+
displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
|
|
316
|
+
contentFlags: presentation_common_1.ContentFlags.ShowLabels,
|
|
317
|
+
},
|
|
318
|
+
rulesetOrId: "ElementProperties",
|
|
319
|
+
keys: new presentation_common_1.KeySet([{ className: "BisCore:Element", id: elementId }]),
|
|
320
|
+
});
|
|
321
|
+
if (!content || content.contentSet.length === 0) {
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
324
|
+
return (0, presentation_common_1.buildElementProperties)(content.descriptor, content.contentSet[0]);
|
|
311
325
|
});
|
|
312
326
|
}
|
|
313
327
|
async getPagedDistinctValues(token, requestOptions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationRpcImpl.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAyD;AACzD,sDAAuF;AAEvF,oEAiDoC;AACpC,mEAA4E;AAC5E,iDAA8C;AAE9C,yDAAsD;AAEtD,8DAA8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AAC;CACF;AAxcD,kDAwcC;AAED,MAAM,oBAAoB,GAAG,CAC3B,cAAwB,EACxB,WAAW,GAAG,6BAAqB,EACC,EAAE;IACtC,MAAM,aAAa,GAAG,gBAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IACjF,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC3E,OAAO,EAAE,GAAG,cAAc,EAAE,MAAM,EAAE,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC;IAC1F,CAAC;IACD,OAAO,cAAoD,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAwB,EAAE,WAAmB,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,CAAC;IAChC,OAAO,aAAa,KAAK,CAAC,IAAI,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;AAC1F,CAAC,CAAC;AAEF,mDAAmD;AACnD,MAAM,eAAe,GAAG,CAAC,IAA6B,EAAuB,EAAE;IAC7E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,mDAAmD;IACnD,OAAO,6BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC,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/** @packageDocumentation\r\n * @module RPC\r\n */\r\n\r\nimport { IModelDb, RpcTrace } from \"@itwin/core-backend\";\r\nimport { assert, BeEvent, Id64String, IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"@itwin/core-common\";\r\nimport {\r\n ClientDiagnostics,\r\n ComputeSelectionRequestOptions,\r\n ComputeSelectionRpcRequestOptions,\r\n ContentDescriptorRpcRequestOptions,\r\n ContentFlags,\r\n ContentInstanceKeysRpcRequestOptions,\r\n ContentRpcRequestOptions,\r\n ContentSourcesRpcRequestOptions,\r\n ContentSourcesRpcResult,\r\n DescriptorJSON,\r\n Diagnostics,\r\n DisplayLabelRpcRequestOptions,\r\n DisplayLabelsRpcRequestOptions,\r\n DisplayValueGroup,\r\n DisplayValueGroupJSON,\r\n DistinctValuesRpcRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRpcRequestOptions,\r\n FilterByTextHierarchyRpcRequestOptions,\r\n HierarchyLevelDescriptorRpcRequestOptions,\r\n HierarchyLevelJSON,\r\n HierarchyRpcRequestOptions,\r\n isComputeSelectionRequestOptions,\r\n ItemJSON,\r\n KeySet,\r\n KeySetJSON,\r\n LabelDefinition,\r\n NodeJSON,\r\n NodeKey,\r\n NodeKeyJSON,\r\n NodePathElement,\r\n NodePathElementJSON,\r\n Paged,\r\n PagedResponse,\r\n PageOptions,\r\n PresentationError,\r\n PresentationRpcInterface,\r\n PresentationRpcResponse,\r\n PresentationRpcResponseData,\r\n PresentationStatus,\r\n RpcDiagnosticsOptions,\r\n Ruleset,\r\n RulesetVariable,\r\n RulesetVariableJSON,\r\n SelectClassInfo,\r\n SelectionScope,\r\n SelectionScopeRpcRequestOptions,\r\n SingleElementPropertiesRpcRequestOptions,\r\n} from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { Presentation } from \"./Presentation\";\r\nimport { PresentationManager } from \"./PresentationManager\";\r\nimport { TemporaryStorage } from \"./TemporaryStorage\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nconst packageJsonVersion = require(\"../../../package.json\").version;\r\n\r\ntype ContentGetter<TResult = any, TOptions = any> = (requestOptions: TOptions) => TResult;\r\n\r\n/** @internal */\r\nexport const MAX_ALLOWED_PAGE_SIZE = 1000;\r\n/** @internal */\r\nexport const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;\r\n\r\nconst DEFAULT_REQUEST_TIMEOUT = 5000;\r\n\r\n/**\r\n * The backend implementation of PresentationRpcInterface. All it's basically\r\n * responsible for is forwarding calls to [[Presentation.manager]].\r\n *\r\n * @internal\r\n */\r\nexport class PresentationRpcImpl extends PresentationRpcInterface implements IDisposable {\r\n private _requestTimeout: number;\r\n private _pendingRequests: TemporaryStorage<PresentationRpcResponse<any>>;\r\n private _cancelEvents: Map<string, BeEvent<() => void>>;\r\n\r\n public constructor(props?: { requestTimeout?: number }) {\r\n super();\r\n this._requestTimeout = props?.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;\r\n this._pendingRequests = new TemporaryStorage({\r\n // remove the pending request after request timeout + 10 seconds - this gives\r\n // frontend 10 seconds to re-send the request until it's removed from requests' cache\r\n unusedValueLifetime: this._requestTimeout > 0 ? this._requestTimeout + 10 * 1000 : undefined,\r\n\r\n // attempt to clean up every second\r\n cleanupInterval: 1000,\r\n\r\n cleanupHandler: (id, _, reason) => {\r\n if (reason !== \"request\") {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);\r\n // istanbul ignore next\r\n this._cancelEvents.get(id)?.raiseEvent();\r\n }\r\n this._cancelEvents.delete(id);\r\n },\r\n });\r\n this._cancelEvents = new Map<string, BeEvent<() => void>>();\r\n }\r\n\r\n public dispose() {\r\n this._pendingRequests.dispose();\r\n }\r\n\r\n public get requestTimeout() {\r\n return this._requestTimeout;\r\n }\r\n\r\n public get pendingRequests() {\r\n return this._pendingRequests;\r\n }\r\n\r\n /** Returns an ok response with result inside */\r\n private successResponse<TResult>(result: TResult, diagnostics?: ClientDiagnostics) {\r\n return {\r\n statusCode: PresentationStatus.Success,\r\n result,\r\n diagnostics,\r\n };\r\n }\r\n\r\n /** Returns a bad request response with empty result and an error code */\r\n private errorResponse(errorCode: PresentationStatus, errorMessage?: string, diagnostics?: ClientDiagnostics) {\r\n return {\r\n statusCode: errorCode,\r\n result: undefined,\r\n errorMessage,\r\n diagnostics,\r\n };\r\n }\r\n\r\n /**\r\n * Get the [[PresentationManager]] used by this RPC impl.\r\n */\r\n public getManager(clientId?: string): PresentationManager {\r\n return Presentation.getManager(clientId);\r\n }\r\n\r\n private async getIModel(token: IModelRpcProps): Promise<IModelDb> {\r\n let imodel: IModelDb;\r\n try {\r\n imodel = IModelDb.findByKey(token.key);\r\n // call refreshContainer, just in case this is a V2 checkpoint whose sasToken is about to expire, or its default transaction is about to be restarted.\r\n await imodel.refreshContainerForRpc(RpcTrace.expectCurrentActivity.accessToken);\r\n } catch {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"IModelRpcProps doesn't point to a valid iModel\");\r\n }\r\n return imodel;\r\n }\r\n\r\n private async makeRequest<\r\n TRpcOptions extends { rulesetOrId?: Ruleset | string; clientId?: string; diagnostics?: RpcDiagnosticsOptions; rulesetVariables?: RulesetVariableJSON[] },\r\n TResult,\r\n >(token: IModelRpcProps, requestId: string, requestOptions: TRpcOptions, request: ContentGetter<Promise<TResult>>): PresentationRpcResponse<TResult> {\r\n const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });\r\n\r\n Logger.logInfo(PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);\r\n\r\n let imodel: IModelDb;\r\n try {\r\n imodel = await this.getIModel(token);\r\n } catch (e) {\r\n assert(e instanceof Error);\r\n return this.errorResponse(PresentationStatus.InvalidArgument, e.message);\r\n }\r\n\r\n let resultPromise = this._pendingRequests.getValue(requestKey);\r\n if (resultPromise) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request already pending`);\r\n } else {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request not found, creating a new one`);\r\n const { clientId: _, diagnostics: diagnosticsOptions, rulesetVariables, ...options } = requestOptions;\r\n const managerRequestOptions: any = {\r\n ...options,\r\n imodel,\r\n cancelEvent: new BeEvent<() => void>(),\r\n };\r\n\r\n // set up ruleset variables\r\n if (rulesetVariables) {\r\n managerRequestOptions.rulesetVariables = rulesetVariables.map(RulesetVariable.fromJSON);\r\n }\r\n\r\n // set up diagnostics listener\r\n let diagnostics: ClientDiagnostics | undefined;\r\n const getDiagnostics = (): ClientDiagnostics => {\r\n if (!diagnostics) {\r\n diagnostics = {};\r\n }\r\n return diagnostics;\r\n };\r\n if (diagnosticsOptions) {\r\n if (diagnosticsOptions.backendVersion) {\r\n getDiagnostics().backendVersion = packageJsonVersion;\r\n }\r\n managerRequestOptions.diagnostics = {\r\n ...diagnosticsOptions,\r\n handler: (d: Diagnostics) => {\r\n if (d.logs) {\r\n const target = getDiagnostics();\r\n if (target.logs) {\r\n target.logs.push(...d.logs);\r\n } else {\r\n target.logs = [...d.logs];\r\n }\r\n }\r\n },\r\n };\r\n }\r\n\r\n // initiate request\r\n resultPromise = request(managerRequestOptions)\r\n .then((result) => this.successResponse(result, diagnostics))\r\n .catch((e: PresentationError) => this.errorResponse(e.errorNumber, e.message, diagnostics));\r\n\r\n // store the request promise\r\n this._pendingRequests.addValue(requestKey, resultPromise);\r\n this._cancelEvents.set(requestKey, managerRequestOptions.cancelEvent);\r\n }\r\n\r\n if (this._requestTimeout === 0) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout not configured, returning promise without a timeout.`);\r\n void resultPromise.finally(() => {\r\n this._pendingRequests.deleteValue(requestKey);\r\n });\r\n return resultPromise;\r\n }\r\n\r\n let timeout: NodeJS.Timeout;\r\n const timeoutPromise = new Promise<any>((_resolve, reject) => {\r\n timeout = setTimeout(() => {\r\n reject();\r\n }, this._requestTimeout);\r\n });\r\n\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);\r\n return Promise.race([resultPromise, timeoutPromise])\r\n .catch<PresentationRpcResponseData>(() => {\r\n // note: error responses from the manager get handled when creating `resultPromise`, so we can only get here due\r\n // to a timeout exception\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout, returning \"BackendTimeout\" status.`);\r\n return this.errorResponse(PresentationStatus.BackendTimeout);\r\n })\r\n .then((response: PresentationRpcResponseData<TResult>) => {\r\n if (response.statusCode !== PresentationStatus.BackendTimeout) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);\r\n this._pendingRequests.deleteValue(requestKey);\r\n }\r\n clearTimeout(timeout);\r\n return response;\r\n });\r\n }\r\n\r\n public override async getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {\r\n return this.makeRequest(token, \"getNodesCount\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n };\r\n return this.getManager(requestOptions.clientId).getNodesCount(options);\r\n });\r\n }\r\n\r\n public override async getPagedNodes(\r\n token: IModelRpcProps,\r\n requestOptions: Paged<HierarchyRpcRequestOptions>,\r\n // eslint-disable-next-line deprecation/deprecation\r\n ): PresentationRpcResponse<PagedResponse<NodeJSON>> {\r\n return this.makeRequest(token, \"getPagedNodes\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n });\r\n const [serializedNodesJson, count] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getDetail().getNodes(options),\r\n this.getManager(requestOptions.clientId).getNodesCount(options),\r\n ]);\r\n // eslint-disable-next-line deprecation/deprecation\r\n const nodesJson = JSON.parse(serializedNodesJson) as HierarchyLevelJSON;\r\n return {\r\n total: count,\r\n items: nodesJson.nodes,\r\n };\r\n });\r\n }\r\n\r\n public override async getNodesDescriptor(\r\n token: IModelRpcProps,\r\n requestOptions: HierarchyLevelDescriptorRpcRequestOptions,\r\n ): PresentationRpcResponse<string | DescriptorJSON | undefined> {\r\n return this.makeRequest(token, \"getNodesDescriptor\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n };\r\n return this.getManager(requestOptions.clientId).getDetail().getNodesDescriptor(options);\r\n });\r\n }\r\n\r\n public override async getNodePaths(\r\n token: IModelRpcProps,\r\n requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions,\r\n // eslint-disable-next-line deprecation/deprecation\r\n ): PresentationRpcResponse<NodePathElementJSON[]> {\r\n return this.makeRequest(token, \"getNodePaths\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getDetail().getNodePaths(options);\r\n // eslint-disable-next-line deprecation/deprecation\r\n return result.map(NodePathElement.toJSON);\r\n });\r\n }\r\n\r\n public override async getFilteredNodePaths(\r\n token: IModelRpcProps,\r\n requestOptions: FilterByTextHierarchyRpcRequestOptions,\r\n // eslint-disable-next-line deprecation/deprecation\r\n ): PresentationRpcResponse<NodePathElementJSON[]> {\r\n return this.makeRequest(token, \"getFilteredNodePaths\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getDetail().getFilteredNodePaths(options);\r\n // eslint-disable-next-line deprecation/deprecation\r\n return result.map(NodePathElement.toJSON);\r\n });\r\n }\r\n\r\n public override async getContentSources(\r\n token: IModelRpcProps,\r\n requestOptions: ContentSourcesRpcRequestOptions,\r\n ): PresentationRpcResponse<ContentSourcesRpcResult> {\r\n return this.makeRequest(token, \"getContentSources\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getContentSources(options);\r\n const classesMap = {};\r\n const selectClasses = result.map((sci) => SelectClassInfo.toCompressedJSON(sci, classesMap));\r\n return { sources: selectClasses, classesMap };\r\n });\r\n }\r\n\r\n public override async getContentDescriptor(\r\n token: IModelRpcProps,\r\n requestOptions: ContentDescriptorRpcRequestOptions,\r\n ): PresentationRpcResponse<DescriptorJSON | undefined> {\r\n return this.makeRequest(token, \"getContentDescriptor\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n contentFlags: (options.contentFlags ?? 0) | ContentFlags.DescriptorOnly, // always append the \"descriptor only\" flag when handling request from the frontend\r\n keys: KeySet.fromJSON(options.keys),\r\n };\r\n if (options.transport === \"unparsed-json\") {\r\n // Here we send a plain JSON string but we will parse it to DescriptorJSON on the frontend. This way we are\r\n // bypassing unnecessary deserialization and serialization.\r\n return Presentation.getManager(requestOptions.clientId).getDetail().getContentDescriptor(options) as unknown as DescriptorJSON | undefined;\r\n } else {\r\n // Support for older frontends that still expect a parsed descriptor\r\n const descriptor = await Presentation.getManager(requestOptions.clientId).getContentDescriptor(options);\r\n return descriptor?.toJSON();\r\n }\r\n });\r\n }\r\n\r\n public override async getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number> {\r\n return this.makeRequest(token, \"getContentSetSize\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n };\r\n return this.getManager(requestOptions.clientId).getContentSetSize(options);\r\n });\r\n }\r\n\r\n public override async getPagedContent(\r\n token: IModelRpcProps,\r\n requestOptions: Paged<ContentRpcRequestOptions>,\r\n ): PresentationRpcResponse<{ descriptor: DescriptorJSON; contentSet: PagedResponse<ItemJSON> } | undefined> {\r\n return this.makeRequest(token, \"getPagedContent\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n });\r\n\r\n const [size, content] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getContentSetSize(options),\r\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\r\n ]);\r\n\r\n if (!content) {\r\n return undefined;\r\n }\r\n\r\n return {\r\n descriptor: content.descriptor.toJSON(),\r\n contentSet: {\r\n total: size,\r\n items: content.contentSet.map((i) => i.toJSON()),\r\n },\r\n };\r\n });\r\n }\r\n\r\n public override async getPagedContentSet(\r\n token: IModelRpcProps,\r\n requestOptions: Paged<ContentRpcRequestOptions>,\r\n ): PresentationRpcResponse<PagedResponse<ItemJSON>> {\r\n const response = await this.getPagedContent(token, requestOptions);\r\n if (response.statusCode !== PresentationStatus.Success) {\r\n return this.errorResponse(response.statusCode, response.errorMessage, response.diagnostics);\r\n }\r\n if (!response.result) {\r\n return this.errorResponse(PresentationStatus.Error, `Failed to get content set (received a success response with empty result)`, response.diagnostics);\r\n }\r\n return {\r\n ...response,\r\n result: response.result.contentSet,\r\n };\r\n }\r\n\r\n public override async getElementProperties(\r\n token: IModelRpcProps,\r\n requestOptions: SingleElementPropertiesRpcRequestOptions,\r\n ): PresentationRpcResponse<ElementProperties | undefined> {\r\n return this.makeRequest(token, \"getElementProperties\", { ...requestOptions }, async (options) => {\r\n return this.getManager(requestOptions.clientId).getDetail().getElementProperties(options);\r\n });\r\n }\r\n\r\n public override async getPagedDistinctValues(\r\n token: IModelRpcProps,\r\n requestOptions: DistinctValuesRpcRequestOptions,\r\n // eslint-disable-next-line deprecation/deprecation\r\n ): PresentationRpcResponse<PagedResponse<DisplayValueGroupJSON>> {\r\n return this.makeRequest(token, \"getPagedDistinctValues\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n });\r\n const response = await this.getManager(requestOptions.clientId).getDetail().getPagedDistinctValues(options);\r\n return {\r\n ...response,\r\n // eslint-disable-next-line deprecation/deprecation\r\n items: response.items.map(DisplayValueGroup.toJSON),\r\n };\r\n });\r\n }\r\n\r\n public override async getContentInstanceKeys(\r\n token: IModelRpcProps,\r\n requestOptions: ContentInstanceKeysRpcRequestOptions,\r\n ): PresentationRpcResponse<{ total: number; items: KeySetJSON }> {\r\n return this.makeRequest(token, \"getContentInstanceKeys\", requestOptions, async (options) => {\r\n const { displayType, ...optionsNoDisplayType } = options;\r\n options = enforceValidPageSize(\r\n {\r\n ...optionsNoDisplayType,\r\n keys: KeySet.fromJSON(optionsNoDisplayType.keys),\r\n descriptor: {\r\n displayType,\r\n contentFlags: ContentFlags.KeysOnly,\r\n },\r\n },\r\n MAX_ALLOWED_KEYS_PAGE_SIZE,\r\n );\r\n\r\n const [size, content] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getContentSetSize(options),\r\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\r\n ]);\r\n\r\n if (size === 0 || !content) {\r\n return { total: 0, items: new KeySet().toJSON() };\r\n }\r\n\r\n return {\r\n total: size,\r\n items: content.contentSet.reduce((keys, item) => keys.add(item.primaryKeys), new KeySet()).toJSON(),\r\n };\r\n });\r\n }\r\n\r\n public override async getDisplayLabelDefinition(\r\n token: IModelRpcProps,\r\n requestOptions: DisplayLabelRpcRequestOptions,\r\n ): PresentationRpcResponse<LabelDefinition> {\r\n return this.makeRequest(token, \"getDisplayLabelDefinition\", requestOptions, async (options) => {\r\n const label = await this.getManager(requestOptions.clientId).getDetail().getDisplayLabelDefinition(options);\r\n return label;\r\n });\r\n }\r\n\r\n public override async getPagedDisplayLabelDefinitions(\r\n token: IModelRpcProps,\r\n requestOptions: DisplayLabelsRpcRequestOptions,\r\n ): PresentationRpcResponse<PagedResponse<LabelDefinition>> {\r\n const pageOpts = enforceValidPageSize({ paging: { start: 0, size: requestOptions.keys.length } });\r\n if (pageOpts.paging.size < requestOptions.keys.length) {\r\n requestOptions.keys.splice(pageOpts.paging.size);\r\n }\r\n return this.makeRequest(token, \"getPagedDisplayLabelDefinitions\", requestOptions, async (options) => {\r\n const labels = await this.getManager(requestOptions.clientId)\r\n .getDetail()\r\n .getDisplayLabelDefinitions({ ...options, keys: options.keys });\r\n return {\r\n total: options.keys.length,\r\n items: labels,\r\n };\r\n });\r\n }\r\n\r\n public override async getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {\r\n return this.makeRequest(token, \"getSelectionScopes\", requestOptions, async (options) =>\r\n this.getManager(requestOptions.clientId).getSelectionScopes(options),\r\n );\r\n }\r\n\r\n public override async computeSelection(\r\n token: IModelRpcProps,\r\n requestOptions: ComputeSelectionRpcRequestOptions | SelectionScopeRpcRequestOptions,\r\n ids?: Id64String[],\r\n scopeId?: string,\r\n ): PresentationRpcResponse<KeySetJSON> {\r\n return this.makeRequest(token, \"computeSelection\", requestOptions, async (options) => {\r\n if (!isComputeSelectionRequestOptions(options)) {\r\n options = {\r\n ...options,\r\n elementIds: ids!,\r\n scope: { id: scopeId! },\r\n };\r\n }\r\n const keys = await this.getManager(requestOptions.clientId).computeSelection(options as ComputeSelectionRequestOptions<IModelDb>);\r\n return keys.toJSON();\r\n });\r\n }\r\n}\r\n\r\nconst enforceValidPageSize = <TOptions extends Paged<object>>(\r\n requestOptions: TOptions,\r\n maxPageSize = MAX_ALLOWED_PAGE_SIZE,\r\n): TOptions & { paging: PageOptions } => {\r\n const validPageSize = getValidPageSize(requestOptions.paging?.size, maxPageSize);\r\n if (!requestOptions.paging || requestOptions.paging.size !== validPageSize) {\r\n return { ...requestOptions, paging: { ...requestOptions.paging, size: validPageSize } };\r\n }\r\n return requestOptions as TOptions & { paging: PageOptions };\r\n};\r\n\r\nconst getValidPageSize = (size: number | undefined, maxPageSize: number) => {\r\n const requestedSize = size ?? 0;\r\n return requestedSize === 0 || requestedSize > maxPageSize ? maxPageSize : requestedSize;\r\n};\r\n\r\n// eslint-disable-next-line deprecation/deprecation\r\nconst nodeKeyFromJson = (json: NodeKeyJSON | undefined): NodeKey | undefined => {\r\n if (!json) {\r\n return undefined;\r\n }\r\n // eslint-disable-next-line deprecation/deprecation\r\n return NodeKey.fromJSON(json);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationRpcImpl.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationRpcImpl.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAyD;AACzD,sDAAuF;AAEvF,oEAmDoC;AACpC,mEAA4E;AAC5E,iDAA8C;AAE9C,yDAAsD;AAEtD,8DAA8D;AAC9D,MAAM,kBAAkB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C,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;AAC1F,CAAC,CAAC;AAEF,mDAAmD;AACnD,MAAM,eAAe,GAAG,CAAC,IAA6B,EAAuB,EAAE;IAC7E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,mDAAmD;IACnD,OAAO,6BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC,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/** @packageDocumentation\r\n * @module RPC\r\n */\r\n\r\nimport { IModelDb, RpcTrace } from \"@itwin/core-backend\";\r\nimport { assert, BeEvent, Id64String, IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"@itwin/core-common\";\r\nimport {\r\n buildElementProperties,\r\n ClientDiagnostics,\r\n ComputeSelectionRequestOptions,\r\n ComputeSelectionRpcRequestOptions,\r\n ContentDescriptorRpcRequestOptions,\r\n ContentFlags,\r\n ContentInstanceKeysRpcRequestOptions,\r\n ContentRpcRequestOptions,\r\n ContentSourcesRpcRequestOptions,\r\n ContentSourcesRpcResult,\r\n DefaultContentDisplayTypes,\r\n DescriptorJSON,\r\n Diagnostics,\r\n DisplayLabelRpcRequestOptions,\r\n DisplayLabelsRpcRequestOptions,\r\n DisplayValueGroup,\r\n DisplayValueGroupJSON,\r\n DistinctValuesRpcRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRpcRequestOptions,\r\n FilterByTextHierarchyRpcRequestOptions,\r\n HierarchyLevelDescriptorRpcRequestOptions,\r\n HierarchyLevelJSON,\r\n HierarchyRpcRequestOptions,\r\n isComputeSelectionRequestOptions,\r\n ItemJSON,\r\n KeySet,\r\n KeySetJSON,\r\n LabelDefinition,\r\n NodeJSON,\r\n NodeKey,\r\n NodeKeyJSON,\r\n NodePathElement,\r\n NodePathElementJSON,\r\n Paged,\r\n PagedResponse,\r\n PageOptions,\r\n PresentationError,\r\n PresentationRpcInterface,\r\n PresentationRpcResponse,\r\n PresentationRpcResponseData,\r\n PresentationStatus,\r\n RpcDiagnosticsOptions,\r\n Ruleset,\r\n RulesetVariable,\r\n RulesetVariableJSON,\r\n SelectClassInfo,\r\n SelectionScope,\r\n SelectionScopeRpcRequestOptions,\r\n SingleElementPropertiesRpcRequestOptions,\r\n} from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { Presentation } from \"./Presentation\";\r\nimport { PresentationManager } from \"./PresentationManager\";\r\nimport { TemporaryStorage } from \"./TemporaryStorage\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nconst packageJsonVersion = require(\"../../../package.json\").version;\r\n\r\ntype ContentGetter<TResult = any, TOptions = any> = (requestOptions: TOptions) => TResult;\r\n\r\n/** @internal */\r\nexport const MAX_ALLOWED_PAGE_SIZE = 1000;\r\n/** @internal */\r\nexport const MAX_ALLOWED_KEYS_PAGE_SIZE = 10000;\r\n\r\nconst DEFAULT_REQUEST_TIMEOUT = 5000;\r\n\r\n/**\r\n * The backend implementation of PresentationRpcInterface. All it's basically\r\n * responsible for is forwarding calls to [[Presentation.manager]].\r\n *\r\n * @internal\r\n */\r\nexport class PresentationRpcImpl extends PresentationRpcInterface implements IDisposable {\r\n private _requestTimeout: number;\r\n private _pendingRequests: TemporaryStorage<PresentationRpcResponse<any>>;\r\n private _cancelEvents: Map<string, BeEvent<() => void>>;\r\n\r\n public constructor(props?: { requestTimeout?: number }) {\r\n super();\r\n this._requestTimeout = props?.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;\r\n this._pendingRequests = new TemporaryStorage({\r\n // remove the pending request after request timeout + 10 seconds - this gives\r\n // frontend 10 seconds to re-send the request until it's removed from requests' cache\r\n unusedValueLifetime: this._requestTimeout > 0 ? this._requestTimeout + 10 * 1000 : undefined,\r\n\r\n // attempt to clean up every second\r\n cleanupInterval: 1000,\r\n\r\n cleanupHandler: (id, _, reason) => {\r\n if (reason !== \"request\") {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Cleaning up request without frontend retrieving it: ${id}.`);\r\n // istanbul ignore next\r\n this._cancelEvents.get(id)?.raiseEvent();\r\n }\r\n this._cancelEvents.delete(id);\r\n },\r\n });\r\n this._cancelEvents = new Map<string, BeEvent<() => void>>();\r\n }\r\n\r\n public dispose() {\r\n this._pendingRequests.dispose();\r\n }\r\n\r\n public get requestTimeout() {\r\n return this._requestTimeout;\r\n }\r\n\r\n public get pendingRequests() {\r\n return this._pendingRequests;\r\n }\r\n\r\n /** Returns an ok response with result inside */\r\n private successResponse<TResult>(result: TResult, diagnostics?: ClientDiagnostics) {\r\n return {\r\n statusCode: PresentationStatus.Success,\r\n result,\r\n diagnostics,\r\n };\r\n }\r\n\r\n /** Returns a bad request response with empty result and an error code */\r\n private errorResponse(errorCode: PresentationStatus, errorMessage?: string, diagnostics?: ClientDiagnostics) {\r\n return {\r\n statusCode: errorCode,\r\n result: undefined,\r\n errorMessage,\r\n diagnostics,\r\n };\r\n }\r\n\r\n /**\r\n * Get the [[PresentationManager]] used by this RPC impl.\r\n */\r\n public getManager(clientId?: string): PresentationManager {\r\n return Presentation.getManager(clientId);\r\n }\r\n\r\n private async getIModel(token: IModelRpcProps): Promise<IModelDb> {\r\n let imodel: IModelDb;\r\n try {\r\n imodel = IModelDb.findByKey(token.key);\r\n // call refreshContainer, just in case this is a V2 checkpoint whose sasToken is about to expire, or its default transaction is about to be restarted.\r\n await imodel.refreshContainerForRpc(RpcTrace.expectCurrentActivity.accessToken);\r\n } catch {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"IModelRpcProps doesn't point to a valid iModel\");\r\n }\r\n return imodel;\r\n }\r\n\r\n private async makeRequest<\r\n TRpcOptions extends { rulesetOrId?: Ruleset | string; clientId?: string; diagnostics?: RpcDiagnosticsOptions; rulesetVariables?: RulesetVariableJSON[] },\r\n TResult,\r\n >(token: IModelRpcProps, requestId: string, requestOptions: TRpcOptions, request: ContentGetter<Promise<TResult>>): PresentationRpcResponse<TResult> {\r\n const requestKey = JSON.stringify({ iModelKey: token.key, requestId, requestOptions });\r\n\r\n Logger.logInfo(PresentationBackendLoggerCategory.Rpc, `Received '${requestId}' request. Params: ${requestKey}`);\r\n\r\n let imodel: IModelDb;\r\n try {\r\n imodel = await this.getIModel(token);\r\n } catch (e) {\r\n assert(e instanceof Error);\r\n return this.errorResponse(PresentationStatus.InvalidArgument, e.message);\r\n }\r\n\r\n let resultPromise = this._pendingRequests.getValue(requestKey);\r\n if (resultPromise) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request already pending`);\r\n } else {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request not found, creating a new one`);\r\n const { clientId: _, diagnostics: diagnosticsOptions, rulesetVariables, ...options } = requestOptions;\r\n const managerRequestOptions: any = {\r\n ...options,\r\n imodel,\r\n cancelEvent: new BeEvent<() => void>(),\r\n };\r\n\r\n // set up ruleset variables\r\n if (rulesetVariables) {\r\n managerRequestOptions.rulesetVariables = rulesetVariables.map(RulesetVariable.fromJSON);\r\n }\r\n\r\n // set up diagnostics listener\r\n let diagnostics: ClientDiagnostics | undefined;\r\n const getDiagnostics = (): ClientDiagnostics => {\r\n if (!diagnostics) {\r\n diagnostics = {};\r\n }\r\n return diagnostics;\r\n };\r\n if (diagnosticsOptions) {\r\n if (diagnosticsOptions.backendVersion) {\r\n getDiagnostics().backendVersion = packageJsonVersion;\r\n }\r\n managerRequestOptions.diagnostics = {\r\n ...diagnosticsOptions,\r\n handler: (d: Diagnostics) => {\r\n if (d.logs) {\r\n const target = getDiagnostics();\r\n if (target.logs) {\r\n target.logs.push(...d.logs);\r\n } else {\r\n target.logs = [...d.logs];\r\n }\r\n }\r\n },\r\n };\r\n }\r\n\r\n // initiate request\r\n resultPromise = request(managerRequestOptions)\r\n .then((result) => this.successResponse(result, diagnostics))\r\n .catch((e: PresentationError) => this.errorResponse(e.errorNumber, e.message, diagnostics));\r\n\r\n // store the request promise\r\n this._pendingRequests.addValue(requestKey, resultPromise);\r\n this._cancelEvents.set(requestKey, managerRequestOptions.cancelEvent);\r\n }\r\n\r\n if (this._requestTimeout === 0) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout not configured, returning promise without a timeout.`);\r\n void resultPromise.finally(() => {\r\n this._pendingRequests.deleteValue(requestKey);\r\n });\r\n return resultPromise;\r\n }\r\n\r\n let timeout: NodeJS.Timeout;\r\n const timeoutPromise = new Promise<any>((_resolve, reject) => {\r\n timeout = setTimeout(() => {\r\n reject();\r\n }, this._requestTimeout);\r\n });\r\n\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Returning a promise with a timeout of ${this._requestTimeout}.`);\r\n return Promise.race([resultPromise, timeoutPromise])\r\n .catch<PresentationRpcResponseData>(() => {\r\n // note: error responses from the manager get handled when creating `resultPromise`, so we can only get here due\r\n // to a timeout exception\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request timeout, returning \"BackendTimeout\" status.`);\r\n return this.errorResponse(PresentationStatus.BackendTimeout);\r\n })\r\n .then((response: PresentationRpcResponseData<TResult>) => {\r\n if (response.statusCode !== PresentationStatus.BackendTimeout) {\r\n Logger.logTrace(PresentationBackendLoggerCategory.Rpc, `Request completed, returning result.`);\r\n this._pendingRequests.deleteValue(requestKey);\r\n }\r\n clearTimeout(timeout);\r\n return response;\r\n });\r\n }\r\n\r\n public override async getNodesCount(token: IModelRpcProps, requestOptions: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {\r\n return this.makeRequest(token, \"getNodesCount\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n };\r\n return this.getManager(requestOptions.clientId).getNodesCount(options);\r\n });\r\n }\r\n\r\n public override async getPagedNodes(\r\n token: IModelRpcProps,\r\n requestOptions: Paged<HierarchyRpcRequestOptions>,\r\n // eslint-disable-next-line deprecation/deprecation\r\n ): PresentationRpcResponse<PagedResponse<NodeJSON>> {\r\n return this.makeRequest(token, \"getPagedNodes\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n });\r\n const [serializedNodesJson, count] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getDetail().getNodes(options),\r\n this.getManager(requestOptions.clientId).getNodesCount(options),\r\n ]);\r\n // eslint-disable-next-line deprecation/deprecation\r\n const nodesJson = JSON.parse(serializedNodesJson) as HierarchyLevelJSON;\r\n return {\r\n total: count,\r\n items: nodesJson.nodes,\r\n };\r\n });\r\n }\r\n\r\n public override async getNodesDescriptor(\r\n token: IModelRpcProps,\r\n requestOptions: HierarchyLevelDescriptorRpcRequestOptions,\r\n ): PresentationRpcResponse<string | DescriptorJSON | undefined> {\r\n return this.makeRequest(token, \"getNodesDescriptor\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n parentKey: nodeKeyFromJson(options.parentKey),\r\n };\r\n return this.getManager(requestOptions.clientId).getDetail().getNodesDescriptor(options);\r\n });\r\n }\r\n\r\n public override async getNodePaths(\r\n token: IModelRpcProps,\r\n requestOptions: FilterByInstancePathsHierarchyRpcRequestOptions,\r\n // eslint-disable-next-line deprecation/deprecation\r\n ): PresentationRpcResponse<NodePathElementJSON[]> {\r\n return this.makeRequest(token, \"getNodePaths\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getDetail().getNodePaths(options);\r\n // eslint-disable-next-line deprecation/deprecation\r\n return result.map(NodePathElement.toJSON);\r\n });\r\n }\r\n\r\n public override async getFilteredNodePaths(\r\n token: IModelRpcProps,\r\n requestOptions: FilterByTextHierarchyRpcRequestOptions,\r\n // eslint-disable-next-line deprecation/deprecation\r\n ): PresentationRpcResponse<NodePathElementJSON[]> {\r\n return this.makeRequest(token, \"getFilteredNodePaths\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getDetail().getFilteredNodePaths(options);\r\n // eslint-disable-next-line deprecation/deprecation\r\n return result.map(NodePathElement.toJSON);\r\n });\r\n }\r\n\r\n public override async getContentSources(\r\n token: IModelRpcProps,\r\n requestOptions: ContentSourcesRpcRequestOptions,\r\n ): PresentationRpcResponse<ContentSourcesRpcResult> {\r\n return this.makeRequest(token, \"getContentSources\", requestOptions, async (options) => {\r\n const result = await this.getManager(requestOptions.clientId).getContentSources(options);\r\n const classesMap = {};\r\n const selectClasses = result.map((sci) => SelectClassInfo.toCompressedJSON(sci, classesMap));\r\n return { sources: selectClasses, classesMap };\r\n });\r\n }\r\n\r\n public override async getContentDescriptor(\r\n token: IModelRpcProps,\r\n requestOptions: ContentDescriptorRpcRequestOptions,\r\n ): PresentationRpcResponse<DescriptorJSON | undefined> {\r\n return this.makeRequest(token, \"getContentDescriptor\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n contentFlags: (options.contentFlags ?? 0) | ContentFlags.DescriptorOnly, // always append the \"descriptor only\" flag when handling request from the frontend\r\n keys: KeySet.fromJSON(options.keys),\r\n };\r\n if (options.transport === \"unparsed-json\") {\r\n // Here we send a plain JSON string but we will parse it to DescriptorJSON on the frontend. This way we are\r\n // bypassing unnecessary deserialization and serialization.\r\n return Presentation.getManager(requestOptions.clientId).getDetail().getContentDescriptor(options) as unknown as DescriptorJSON | undefined;\r\n } else {\r\n // Support for older frontends that still expect a parsed descriptor\r\n const descriptor = await Presentation.getManager(requestOptions.clientId).getContentDescriptor(options);\r\n return descriptor?.toJSON();\r\n }\r\n });\r\n }\r\n\r\n public override async getContentSetSize(token: IModelRpcProps, requestOptions: ContentRpcRequestOptions): PresentationRpcResponse<number> {\r\n return this.makeRequest(token, \"getContentSetSize\", requestOptions, async (options) => {\r\n options = {\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n };\r\n return this.getManager(requestOptions.clientId).getContentSetSize(options);\r\n });\r\n }\r\n\r\n public override async getPagedContent(\r\n token: IModelRpcProps,\r\n requestOptions: Paged<ContentRpcRequestOptions>,\r\n ): PresentationRpcResponse<{ descriptor: DescriptorJSON; contentSet: PagedResponse<ItemJSON> } | undefined> {\r\n return this.makeRequest(token, \"getPagedContent\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n });\r\n\r\n const [size, content] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getContentSetSize(options),\r\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\r\n ]);\r\n\r\n if (!content) {\r\n return undefined;\r\n }\r\n\r\n return {\r\n descriptor: content.descriptor.toJSON(),\r\n contentSet: {\r\n total: size,\r\n items: content.contentSet.map((i) => i.toJSON()),\r\n },\r\n };\r\n });\r\n }\r\n\r\n public override async getPagedContentSet(\r\n token: IModelRpcProps,\r\n requestOptions: Paged<ContentRpcRequestOptions>,\r\n ): PresentationRpcResponse<PagedResponse<ItemJSON>> {\r\n const response = await this.getPagedContent(token, requestOptions);\r\n if (response.statusCode !== PresentationStatus.Success) {\r\n return this.errorResponse(response.statusCode, response.errorMessage, response.diagnostics);\r\n }\r\n if (!response.result) {\r\n return this.errorResponse(PresentationStatus.Error, `Failed to get content set (received a success response with empty result)`, response.diagnostics);\r\n }\r\n return {\r\n ...response,\r\n result: response.result.contentSet,\r\n };\r\n }\r\n\r\n public override async getElementProperties(\r\n token: IModelRpcProps,\r\n requestOptions: SingleElementPropertiesRpcRequestOptions,\r\n ): PresentationRpcResponse<ElementProperties | undefined> {\r\n return this.makeRequest(token, \"getElementProperties\", { ...requestOptions }, async (options) => {\r\n const manager = this.getManager(requestOptions.clientId);\r\n const { elementId, ...optionsNoElementId } = options;\r\n const content = await manager.getDetail().getContent({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!content || content.contentSet.length === 0) {\r\n return undefined;\r\n }\r\n return buildElementProperties(content.descriptor, content.contentSet[0]);\r\n });\r\n }\r\n\r\n public override async getPagedDistinctValues(\r\n token: IModelRpcProps,\r\n requestOptions: DistinctValuesRpcRequestOptions,\r\n // eslint-disable-next-line deprecation/deprecation\r\n ): PresentationRpcResponse<PagedResponse<DisplayValueGroupJSON>> {\r\n return this.makeRequest(token, \"getPagedDistinctValues\", requestOptions, async (options) => {\r\n options = enforceValidPageSize({\r\n ...options,\r\n keys: KeySet.fromJSON(options.keys),\r\n });\r\n const response = await this.getManager(requestOptions.clientId).getDetail().getPagedDistinctValues(options);\r\n return {\r\n ...response,\r\n // eslint-disable-next-line deprecation/deprecation\r\n items: response.items.map(DisplayValueGroup.toJSON),\r\n };\r\n });\r\n }\r\n\r\n public override async getContentInstanceKeys(\r\n token: IModelRpcProps,\r\n requestOptions: ContentInstanceKeysRpcRequestOptions,\r\n ): PresentationRpcResponse<{ total: number; items: KeySetJSON }> {\r\n return this.makeRequest(token, \"getContentInstanceKeys\", requestOptions, async (options) => {\r\n const { displayType, ...optionsNoDisplayType } = options;\r\n options = enforceValidPageSize(\r\n {\r\n ...optionsNoDisplayType,\r\n keys: KeySet.fromJSON(optionsNoDisplayType.keys),\r\n descriptor: {\r\n displayType,\r\n contentFlags: ContentFlags.KeysOnly,\r\n },\r\n },\r\n MAX_ALLOWED_KEYS_PAGE_SIZE,\r\n );\r\n\r\n const [size, content] = await Promise.all([\r\n this.getManager(requestOptions.clientId).getContentSetSize(options),\r\n this.getManager(requestOptions.clientId).getDetail().getContent(options),\r\n ]);\r\n\r\n if (size === 0 || !content) {\r\n return { total: 0, items: new KeySet().toJSON() };\r\n }\r\n\r\n return {\r\n total: size,\r\n items: content.contentSet.reduce((keys, item) => keys.add(item.primaryKeys), new KeySet()).toJSON(),\r\n };\r\n });\r\n }\r\n\r\n public override async getDisplayLabelDefinition(\r\n token: IModelRpcProps,\r\n requestOptions: DisplayLabelRpcRequestOptions,\r\n ): PresentationRpcResponse<LabelDefinition> {\r\n return this.makeRequest(token, \"getDisplayLabelDefinition\", requestOptions, async (options) => {\r\n const label = await this.getManager(requestOptions.clientId).getDetail().getDisplayLabelDefinition(options);\r\n return label;\r\n });\r\n }\r\n\r\n public override async getPagedDisplayLabelDefinitions(\r\n token: IModelRpcProps,\r\n requestOptions: DisplayLabelsRpcRequestOptions,\r\n ): PresentationRpcResponse<PagedResponse<LabelDefinition>> {\r\n const pageOpts = enforceValidPageSize({ paging: { start: 0, size: requestOptions.keys.length } });\r\n if (pageOpts.paging.size < requestOptions.keys.length) {\r\n requestOptions.keys.splice(pageOpts.paging.size);\r\n }\r\n return this.makeRequest(token, \"getPagedDisplayLabelDefinitions\", requestOptions, async (options) => {\r\n const labels = await this.getManager(requestOptions.clientId)\r\n .getDetail()\r\n .getDisplayLabelDefinitions({ ...options, keys: options.keys });\r\n return {\r\n total: options.keys.length,\r\n items: labels,\r\n };\r\n });\r\n }\r\n\r\n public override async getSelectionScopes(token: IModelRpcProps, requestOptions: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {\r\n return this.makeRequest(token, \"getSelectionScopes\", requestOptions, async (options) =>\r\n this.getManager(requestOptions.clientId).getSelectionScopes(options),\r\n );\r\n }\r\n\r\n public override async computeSelection(\r\n token: IModelRpcProps,\r\n requestOptions: ComputeSelectionRpcRequestOptions | SelectionScopeRpcRequestOptions,\r\n ids?: Id64String[],\r\n scopeId?: string,\r\n ): PresentationRpcResponse<KeySetJSON> {\r\n return this.makeRequest(token, \"computeSelection\", requestOptions, async (options) => {\r\n if (!isComputeSelectionRequestOptions(options)) {\r\n options = {\r\n ...options,\r\n elementIds: ids!,\r\n scope: { id: scopeId! },\r\n };\r\n }\r\n const keys = await this.getManager(requestOptions.clientId).computeSelection(options as ComputeSelectionRequestOptions<IModelDb>);\r\n return keys.toJSON();\r\n });\r\n }\r\n}\r\n\r\nconst enforceValidPageSize = <TOptions extends Paged<object>>(\r\n requestOptions: TOptions,\r\n maxPageSize = MAX_ALLOWED_PAGE_SIZE,\r\n): TOptions & { paging: PageOptions } => {\r\n const validPageSize = getValidPageSize(requestOptions.paging?.size, maxPageSize);\r\n if (!requestOptions.paging || requestOptions.paging.size !== validPageSize) {\r\n return { ...requestOptions, paging: { ...requestOptions.paging, size: validPageSize } };\r\n }\r\n return requestOptions as TOptions & { paging: PageOptions };\r\n};\r\n\r\nconst getValidPageSize = (size: number | undefined, maxPageSize: number) => {\r\n const requestedSize = size ?? 0;\r\n return requestedSize === 0 || requestedSize > maxPageSize ? maxPageSize : requestedSize;\r\n};\r\n\r\n// eslint-disable-next-line deprecation/deprecation\r\nconst nodeKeyFromJson = (json: NodeKeyJSON | undefined): NodeKey | undefined => {\r\n if (!json) {\r\n return undefined;\r\n }\r\n // eslint-disable-next-line deprecation/deprecation\r\n return NodeKey.fromJSON(json);\r\n};\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-backend",
|
|
3
|
-
"version": "4.9.0-dev.
|
|
3
|
+
"version": "4.9.0-dev.24",
|
|
4
4
|
"description": "Backend of iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"main": "lib/cjs/presentation-backend.js",
|
|
24
24
|
"typings": "lib/cjs/presentation-backend",
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@itwin/core-backend": "^4.9.0-dev.
|
|
27
|
-
"@itwin/core-bentley": "^4.9.0-dev.
|
|
28
|
-
"@itwin/core-common": "^4.9.0-dev.
|
|
29
|
-
"@itwin/core-quantity": "^4.9.0-dev.
|
|
30
|
-
"@itwin/ecschema-metadata": "^4.9.0-dev.
|
|
31
|
-
"@itwin/presentation-common": "^4.9.0-dev.
|
|
26
|
+
"@itwin/core-backend": "^4.9.0-dev.24",
|
|
27
|
+
"@itwin/core-bentley": "^4.9.0-dev.24",
|
|
28
|
+
"@itwin/core-common": "^4.9.0-dev.24",
|
|
29
|
+
"@itwin/core-quantity": "^4.9.0-dev.24",
|
|
30
|
+
"@itwin/ecschema-metadata": "^4.9.0-dev.24",
|
|
31
|
+
"@itwin/presentation-common": "^4.9.0-dev.24"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@itwin/eslint-plugin": "^4.0.2",
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
"source-map-support": "^0.5.6",
|
|
67
67
|
"typemoq": "^2.1.0",
|
|
68
68
|
"typescript": "~5.3.3",
|
|
69
|
-
"@itwin/
|
|
70
|
-
"@itwin/core-backend": "4.9.0-dev.
|
|
71
|
-
"@itwin/core-
|
|
72
|
-
"@itwin/
|
|
73
|
-
"@itwin/
|
|
74
|
-
"@itwin/
|
|
75
|
-
"@itwin/presentation-common": "4.9.0-dev.
|
|
69
|
+
"@itwin/build-tools": "4.9.0-dev.24",
|
|
70
|
+
"@itwin/core-backend": "4.9.0-dev.24",
|
|
71
|
+
"@itwin/core-common": "4.9.0-dev.24",
|
|
72
|
+
"@itwin/core-bentley": "4.9.0-dev.24",
|
|
73
|
+
"@itwin/ecschema-metadata": "4.9.0-dev.24",
|
|
74
|
+
"@itwin/core-quantity": "4.9.0-dev.24",
|
|
75
|
+
"@itwin/presentation-common": "4.9.0-dev.24"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"object-hash": "^1.3.1",
|