@itwin/presentation-backend 4.0.0-dev.8 → 4.0.0-dev.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -1
- package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
- package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +726 -762
- package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
- package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
- package/lib/cjs/presentation-backend/Constants.js +40 -36
- package/lib/cjs/presentation-backend/Constants.js.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +272 -274
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +147 -140
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
- package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +148 -150
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +11 -12
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +30 -41
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +463 -445
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +317 -311
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +442 -430
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +287 -282
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
- package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
- package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +226 -229
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
- package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
- package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
- package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
- package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +107 -106
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
- package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
- package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
- package/lib/cjs/presentation-backend.d.ts +19 -19
- package/lib/cjs/presentation-backend.js +39 -35
- package/lib/cjs/presentation-backend.js.map +1 -1
- package/package.json +20 -18
|
@@ -1,275 +1,273 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Core
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.iterateElementIds = exports.getElementsCount = exports.buildElementsProperties = void 0;
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
-
const presentation_common_1 = require("@itwin/presentation-common");
|
|
13
|
-
/** @internal */
|
|
14
|
-
const buildElementsProperties = (content) => {
|
|
15
|
-
if (!content || content.contentSet.length === 0)
|
|
16
|
-
return [];
|
|
17
|
-
const builder = new ElementPropertiesBuilder();
|
|
18
|
-
(0, presentation_common_1.traverseContent)(builder, content);
|
|
19
|
-
return builder.items;
|
|
20
|
-
};
|
|
21
|
-
exports.buildElementsProperties = buildElementsProperties;
|
|
22
|
-
/** @internal */
|
|
23
|
-
function getElementsCount(db, classNames) {
|
|
24
|
-
const filter = createElementsFilter("e", classNames);
|
|
25
|
-
const query = `
|
|
26
|
-
SELECT COUNT(e.ECInstanceId)
|
|
27
|
-
FROM bis.Element e
|
|
28
|
-
${filter ? `WHERE ${filter}` : ""}
|
|
29
|
-
`;
|
|
30
|
-
return db.withPreparedStatement(query, (stmt) => {
|
|
31
|
-
return stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
exports.getElementsCount = getElementsCount;
|
|
35
|
-
/** @internal */
|
|
36
|
-
function* iterateElementIds(db, classNames, limit) {
|
|
37
|
-
let lastElementId;
|
|
38
|
-
while (true) {
|
|
39
|
-
const result = queryElementIds(db, classNames, limit, lastElementId);
|
|
40
|
-
yield result.ids;
|
|
41
|
-
lastElementId = result.lastElementId;
|
|
42
|
-
if (!lastElementId)
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.iterateElementIds = iterateElementIds;
|
|
47
|
-
function queryElementIds(db, classNames, limit, lastElementId) {
|
|
48
|
-
function createWhereClause() {
|
|
49
|
-
const classFilter = createElementsFilter("e", classNames);
|
|
50
|
-
const elementFilter = lastElementId ? `e.ECInstanceId > ?` : undefined;
|
|
51
|
-
if (!classFilter && !elementFilter)
|
|
52
|
-
return "";
|
|
53
|
-
if (classFilter && elementFilter)
|
|
54
|
-
return `WHERE ${classFilter} AND ${elementFilter}`;
|
|
55
|
-
return `WHERE ${classFilter
|
|
56
|
-
}
|
|
57
|
-
const query = `
|
|
58
|
-
SELECT e.ECInstanceId elId, eSchemaDef.Name || ':' || eClassDef.Name elClassName
|
|
59
|
-
FROM bis.Element e
|
|
60
|
-
LEFT JOIN meta.ECClassDef eClassDef ON eClassDef.ECInstanceId = e.ECClassId
|
|
61
|
-
LEFT JOIN meta.ECSchemaDef eSchemaDef ON eSchemaDef.ECInstanceId = eClassDef.Schema.Id
|
|
62
|
-
${createWhereClause()}
|
|
63
|
-
ORDER BY e.ECInstanceId ASC
|
|
64
|
-
`;
|
|
65
|
-
return db.withPreparedStatement(query, (stmt) => {
|
|
66
|
-
if (lastElementId)
|
|
67
|
-
stmt.bindId(1, lastElementId);
|
|
68
|
-
const ids = new Map();
|
|
69
|
-
let currentClassName = "";
|
|
70
|
-
let currentIds = [];
|
|
71
|
-
let loadedIds = 0;
|
|
72
|
-
while (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW) {
|
|
73
|
-
const row = stmt.getRow();
|
|
74
|
-
if (!row.elId || !row.elClassName)
|
|
75
|
-
continue;
|
|
76
|
-
if (currentClassName !== row.elClassName) {
|
|
77
|
-
currentClassName = row.elClassName;
|
|
78
|
-
const existingIds = ids.get(row.elClassName);
|
|
79
|
-
if (!existingIds) {
|
|
80
|
-
currentIds = [];
|
|
81
|
-
ids.set(row.elClassName, currentIds);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
currentIds = existingIds;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
currentIds.push(row.elId);
|
|
88
|
-
loadedIds++;
|
|
89
|
-
if (limit && loadedIds >= limit)
|
|
90
|
-
return { ids, lastElementId: row.elId };
|
|
91
|
-
}
|
|
92
|
-
return { ids, lastElementId: undefined };
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function createElementsFilter(elementAlias, classNames) {
|
|
96
|
-
if (classNames === undefined || classNames.length === 0)
|
|
97
|
-
return undefined;
|
|
98
|
-
// check if list contains only valid class names
|
|
99
|
-
const classNameRegExp = new RegExp(/^[\w]+[.:][\w]+$/);
|
|
100
|
-
const invalidName = classNames.find((name) => !name.match(classNameRegExp));
|
|
101
|
-
if (invalidName) {
|
|
102
|
-
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.
|
|
103
|
-
Valid class name formats: "<schema name or alias>.<class name>", "<schema name or alias>:<class name>"`);
|
|
104
|
-
}
|
|
105
|
-
return `${elementAlias}.ECClassId IS (${classNames.join(",")})`;
|
|
106
|
-
}
|
|
107
|
-
class ElementPropertiesAppender {
|
|
108
|
-
constructor(_item, _onItemFinished) {
|
|
109
|
-
this._item = _item;
|
|
110
|
-
this._onItemFinished = _onItemFinished;
|
|
111
|
-
this._propertyItems = {};
|
|
112
|
-
this._categoryItemAppenders = {};
|
|
113
|
-
}
|
|
114
|
-
append(label, item) {
|
|
115
|
-
this._propertyItems[label] = item;
|
|
116
|
-
}
|
|
117
|
-
finish() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.
|
|
161
|
-
this.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
this.
|
|
199
|
-
this.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
this.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
this.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
this.
|
|
237
|
-
|
|
238
|
-
this._elementPropertiesAppender
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Core
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.iterateElementIds = exports.getElementsCount = exports.buildElementsProperties = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const presentation_common_1 = require("@itwin/presentation-common");
|
|
13
|
+
/** @internal */
|
|
14
|
+
const buildElementsProperties = (content) => {
|
|
15
|
+
if (!content || content.contentSet.length === 0)
|
|
16
|
+
return [];
|
|
17
|
+
const builder = new ElementPropertiesBuilder();
|
|
18
|
+
(0, presentation_common_1.traverseContent)(builder, content);
|
|
19
|
+
return builder.items;
|
|
20
|
+
};
|
|
21
|
+
exports.buildElementsProperties = buildElementsProperties;
|
|
22
|
+
/** @internal */
|
|
23
|
+
function getElementsCount(db, classNames) {
|
|
24
|
+
const filter = createElementsFilter("e", classNames);
|
|
25
|
+
const query = `
|
|
26
|
+
SELECT COUNT(e.ECInstanceId)
|
|
27
|
+
FROM bis.Element e
|
|
28
|
+
${filter ? `WHERE ${filter}` : ""}
|
|
29
|
+
`;
|
|
30
|
+
return db.withPreparedStatement(query, (stmt) => {
|
|
31
|
+
return stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.getElementsCount = getElementsCount;
|
|
35
|
+
/** @internal */
|
|
36
|
+
function* iterateElementIds(db, classNames, limit) {
|
|
37
|
+
let lastElementId;
|
|
38
|
+
while (true) {
|
|
39
|
+
const result = queryElementIds(db, classNames, limit, lastElementId);
|
|
40
|
+
yield result.ids;
|
|
41
|
+
lastElementId = result.lastElementId;
|
|
42
|
+
if (!lastElementId)
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.iterateElementIds = iterateElementIds;
|
|
47
|
+
function queryElementIds(db, classNames, limit, lastElementId) {
|
|
48
|
+
function createWhereClause() {
|
|
49
|
+
const classFilter = createElementsFilter("e", classNames);
|
|
50
|
+
const elementFilter = lastElementId ? `e.ECInstanceId > ?` : undefined;
|
|
51
|
+
if (!classFilter && !elementFilter)
|
|
52
|
+
return "";
|
|
53
|
+
if (classFilter && elementFilter)
|
|
54
|
+
return `WHERE ${classFilter} AND ${elementFilter}`;
|
|
55
|
+
return `WHERE ${classFilter ?? ""} ${elementFilter ?? ""}`;
|
|
56
|
+
}
|
|
57
|
+
const query = `
|
|
58
|
+
SELECT e.ECInstanceId elId, eSchemaDef.Name || ':' || eClassDef.Name elClassName
|
|
59
|
+
FROM bis.Element e
|
|
60
|
+
LEFT JOIN meta.ECClassDef eClassDef ON eClassDef.ECInstanceId = e.ECClassId
|
|
61
|
+
LEFT JOIN meta.ECSchemaDef eSchemaDef ON eSchemaDef.ECInstanceId = eClassDef.Schema.Id
|
|
62
|
+
${createWhereClause()}
|
|
63
|
+
ORDER BY e.ECInstanceId ASC
|
|
64
|
+
`;
|
|
65
|
+
return db.withPreparedStatement(query, (stmt) => {
|
|
66
|
+
if (lastElementId)
|
|
67
|
+
stmt.bindId(1, lastElementId);
|
|
68
|
+
const ids = new Map();
|
|
69
|
+
let currentClassName = "";
|
|
70
|
+
let currentIds = [];
|
|
71
|
+
let loadedIds = 0;
|
|
72
|
+
while (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW) {
|
|
73
|
+
const row = stmt.getRow();
|
|
74
|
+
if (!row.elId || !row.elClassName)
|
|
75
|
+
continue;
|
|
76
|
+
if (currentClassName !== row.elClassName) {
|
|
77
|
+
currentClassName = row.elClassName;
|
|
78
|
+
const existingIds = ids.get(row.elClassName);
|
|
79
|
+
if (!existingIds) {
|
|
80
|
+
currentIds = [];
|
|
81
|
+
ids.set(row.elClassName, currentIds);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
currentIds = existingIds;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
currentIds.push(row.elId);
|
|
88
|
+
loadedIds++;
|
|
89
|
+
if (limit && loadedIds >= limit)
|
|
90
|
+
return { ids, lastElementId: row.elId };
|
|
91
|
+
}
|
|
92
|
+
return { ids, lastElementId: undefined };
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function createElementsFilter(elementAlias, classNames) {
|
|
96
|
+
if (classNames === undefined || classNames.length === 0)
|
|
97
|
+
return undefined;
|
|
98
|
+
// check if list contains only valid class names
|
|
99
|
+
const classNameRegExp = new RegExp(/^[\w]+[.:][\w]+$/);
|
|
100
|
+
const invalidName = classNames.find((name) => !name.match(classNameRegExp));
|
|
101
|
+
if (invalidName) {
|
|
102
|
+
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.
|
|
103
|
+
Valid class name formats: "<schema name or alias>.<class name>", "<schema name or alias>:<class name>"`);
|
|
104
|
+
}
|
|
105
|
+
return `${elementAlias}.ECClassId IS (${classNames.join(",")})`;
|
|
106
|
+
}
|
|
107
|
+
class ElementPropertiesAppender {
|
|
108
|
+
constructor(_item, _onItemFinished) {
|
|
109
|
+
this._item = _item;
|
|
110
|
+
this._onItemFinished = _onItemFinished;
|
|
111
|
+
this._propertyItems = {};
|
|
112
|
+
this._categoryItemAppenders = {};
|
|
113
|
+
}
|
|
114
|
+
append(label, item) {
|
|
115
|
+
this._propertyItems[label] = item;
|
|
116
|
+
}
|
|
117
|
+
finish() {
|
|
118
|
+
// eslint-disable-next-line guard-for-in
|
|
119
|
+
for (const categoryName in this._categoryItemAppenders) {
|
|
120
|
+
const appender = this._categoryItemAppenders[categoryName];
|
|
121
|
+
appender.finish();
|
|
122
|
+
}
|
|
123
|
+
this._onItemFinished({
|
|
124
|
+
class: this._item.classInfo?.label ?? "",
|
|
125
|
+
id: this._item.primaryKeys[0]?.id ?? core_bentley_1.Id64.invalid,
|
|
126
|
+
label: this._item.label.displayValue,
|
|
127
|
+
items: this._propertyItems,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
getCategoryAppender(parentAppender, category) {
|
|
131
|
+
let appender = this._categoryItemAppenders[category.name];
|
|
132
|
+
if (!appender) {
|
|
133
|
+
appender = new CategoryItemAppender(parentAppender, category);
|
|
134
|
+
this._categoryItemAppenders[category.name] = appender;
|
|
135
|
+
}
|
|
136
|
+
return appender;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
class CategoryItemAppender {
|
|
140
|
+
constructor(_parentAppender, _category) {
|
|
141
|
+
this._parentAppender = _parentAppender;
|
|
142
|
+
this._category = _category;
|
|
143
|
+
this._items = {};
|
|
144
|
+
}
|
|
145
|
+
append(label, item) {
|
|
146
|
+
this._items[label] = item;
|
|
147
|
+
}
|
|
148
|
+
finish() {
|
|
149
|
+
if (Object.keys(this._items).length === 0)
|
|
150
|
+
return;
|
|
151
|
+
this._parentAppender.append(this._category.label, {
|
|
152
|
+
type: "category",
|
|
153
|
+
items: this._items,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
class ArrayItemAppender {
|
|
158
|
+
constructor(_parentAppender, _props) {
|
|
159
|
+
this._parentAppender = _parentAppender;
|
|
160
|
+
this._props = _props;
|
|
161
|
+
this._items = [];
|
|
162
|
+
}
|
|
163
|
+
append(_label, item) {
|
|
164
|
+
(0, core_bentley_1.assert)(item.type !== "category");
|
|
165
|
+
this._items.push(item);
|
|
166
|
+
}
|
|
167
|
+
finish() {
|
|
168
|
+
(0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Array);
|
|
169
|
+
if (this._props.valueType.memberType.valueFormat === presentation_common_1.PropertyValueFormat.Primitive)
|
|
170
|
+
this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());
|
|
171
|
+
else
|
|
172
|
+
this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());
|
|
173
|
+
}
|
|
174
|
+
createPrimitivesArray() {
|
|
175
|
+
return {
|
|
176
|
+
type: "array",
|
|
177
|
+
valueType: "primitive",
|
|
178
|
+
values: this._items.map((item) => {
|
|
179
|
+
(0, core_bentley_1.assert)(item.type === "primitive");
|
|
180
|
+
return item.value;
|
|
181
|
+
}),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
createStructsArray() {
|
|
185
|
+
return {
|
|
186
|
+
type: "array",
|
|
187
|
+
valueType: "struct",
|
|
188
|
+
values: this._items.map((item) => {
|
|
189
|
+
(0, core_bentley_1.assert)(item.type === "struct");
|
|
190
|
+
return item.members;
|
|
191
|
+
}),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
class StructItemAppender {
|
|
196
|
+
constructor(_parentAppender, _props) {
|
|
197
|
+
this._parentAppender = _parentAppender;
|
|
198
|
+
this._props = _props;
|
|
199
|
+
this._members = {};
|
|
200
|
+
}
|
|
201
|
+
append(label, item) {
|
|
202
|
+
(0, core_bentley_1.assert)(item.type !== "category");
|
|
203
|
+
this._members[label] = item;
|
|
204
|
+
}
|
|
205
|
+
finish() {
|
|
206
|
+
(0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Struct);
|
|
207
|
+
this._parentAppender.append(this._props.hierarchy.field.label, {
|
|
208
|
+
type: "struct",
|
|
209
|
+
members: this._members,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
class ElementPropertiesBuilder {
|
|
214
|
+
constructor() {
|
|
215
|
+
this._appendersStack = [];
|
|
216
|
+
this._items = [];
|
|
217
|
+
}
|
|
218
|
+
get items() {
|
|
219
|
+
return this._items;
|
|
220
|
+
}
|
|
221
|
+
get _currentAppender() {
|
|
222
|
+
const appender = this._appendersStack[this._appendersStack.length - 1];
|
|
223
|
+
(0, core_bentley_1.assert)(appender !== undefined);
|
|
224
|
+
return appender;
|
|
225
|
+
}
|
|
226
|
+
startContent(_props) { return true; }
|
|
227
|
+
finishContent() { }
|
|
228
|
+
processFieldHierarchies(_props) { }
|
|
229
|
+
startItem(props) {
|
|
230
|
+
this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));
|
|
231
|
+
this._appendersStack.push(this._elementPropertiesAppender);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
finishItem() {
|
|
235
|
+
this._appendersStack.pop();
|
|
236
|
+
(0, core_bentley_1.assert)(this._elementPropertiesAppender !== undefined);
|
|
237
|
+
this._elementPropertiesAppender.finish();
|
|
238
|
+
this._elementPropertiesAppender = undefined;
|
|
239
|
+
}
|
|
240
|
+
startCategory(props) {
|
|
241
|
+
(0, core_bentley_1.assert)(this._elementPropertiesAppender !== undefined);
|
|
242
|
+
this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
finishCategory() {
|
|
246
|
+
this._appendersStack.pop();
|
|
247
|
+
}
|
|
248
|
+
startField(_props) { return true; }
|
|
249
|
+
finishField() { }
|
|
250
|
+
startStruct(props) {
|
|
251
|
+
this._appendersStack.push(new StructItemAppender(this._currentAppender, props));
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
finishStruct() { this._appendersStack.pop().finish(); }
|
|
255
|
+
startArray(props) {
|
|
256
|
+
this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
finishArray() { this._appendersStack.pop().finish(); }
|
|
260
|
+
processMergedValue(props) {
|
|
261
|
+
this._currentAppender.append(props.mergedField.label, {
|
|
262
|
+
type: "primitive",
|
|
263
|
+
value: "",
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
processPrimitiveValue(props) {
|
|
267
|
+
this._currentAppender.append(props.field.label, {
|
|
268
|
+
type: "primitive",
|
|
269
|
+
value: props.displayValue?.toString() ?? "",
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
275
273
|
//# sourceMappingURL=ElementPropertiesHelper.js.map
|