@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.
Files changed (70) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  3. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +726 -762
  4. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  5. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  7. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  8. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  9. package/lib/cjs/presentation-backend/Constants.js +40 -36
  10. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  11. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +272 -274
  13. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  14. package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
  15. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  16. package/lib/cjs/presentation-backend/NativePlatform.js +147 -140
  17. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  18. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  19. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
  20. package/lib/cjs/presentation-backend/Presentation.js +148 -150
  21. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +11 -12
  23. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
  24. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +30 -41
  25. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  26. package/lib/cjs/presentation-backend/PresentationManager.d.ts +463 -445
  27. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  28. package/lib/cjs/presentation-backend/PresentationManager.js +317 -311
  29. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  30. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
  31. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
  32. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +442 -430
  33. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  34. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
  35. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  36. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
  37. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
  39. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
  40. package/lib/cjs/presentation-backend/RulesetEmbedder.js +287 -282
  41. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  42. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  43. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  44. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  45. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  46. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  47. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  48. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
  49. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +226 -229
  50. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  51. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  52. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  53. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  54. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  55. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  56. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  57. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  58. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  59. package/lib/cjs/presentation-backend/Utils.js +107 -106
  60. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  61. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  62. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
  63. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  64. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  65. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  66. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  67. package/lib/cjs/presentation-backend.d.ts +19 -19
  68. package/lib/cjs/presentation-backend.js +39 -35
  69. package/lib/cjs/presentation-backend.js.map +1 -1
  70. 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 !== null && classFilter !== void 0 ? classFilter : ""} ${elementFilter !== null && elementFilter !== void 0 ? 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
- var _a, _b, _c, _d;
119
- // eslint-disable-next-line guard-for-in
120
- for (const categoryName in this._categoryItemAppenders) {
121
- const appender = this._categoryItemAppenders[categoryName];
122
- appender.finish();
123
- }
124
- this._onItemFinished({
125
- class: (_b = (_a = this._item.classInfo) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : "",
126
- id: (_d = (_c = this._item.primaryKeys[0]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : core_bentley_1.Id64.invalid,
127
- label: this._item.label.displayValue,
128
- items: this._propertyItems,
129
- });
130
- }
131
- getCategoryAppender(parentAppender, category) {
132
- let appender = this._categoryItemAppenders[category.name];
133
- if (!appender) {
134
- appender = new CategoryItemAppender(parentAppender, category);
135
- this._categoryItemAppenders[category.name] = appender;
136
- }
137
- return appender;
138
- }
139
- }
140
- class CategoryItemAppender {
141
- constructor(_parentAppender, _category) {
142
- this._parentAppender = _parentAppender;
143
- this._category = _category;
144
- this._items = {};
145
- }
146
- append(label, item) {
147
- this._items[label] = item;
148
- }
149
- finish() {
150
- if (Object.keys(this._items).length === 0)
151
- return;
152
- this._parentAppender.append(this._category.label, {
153
- type: "category",
154
- items: this._items,
155
- });
156
- }
157
- }
158
- class ArrayItemAppender {
159
- constructor(_parentAppender, _props) {
160
- this._parentAppender = _parentAppender;
161
- this._props = _props;
162
- this._items = [];
163
- }
164
- append(_label, item) {
165
- (0, core_bentley_1.assert)(item.type !== "category");
166
- this._items.push(item);
167
- }
168
- finish() {
169
- (0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Array);
170
- if (this._props.valueType.memberType.valueFormat === presentation_common_1.PropertyValueFormat.Primitive)
171
- this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());
172
- else
173
- this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());
174
- }
175
- createPrimitivesArray() {
176
- return {
177
- type: "array",
178
- valueType: "primitive",
179
- values: this._items.map((item) => {
180
- (0, core_bentley_1.assert)(item.type === "primitive");
181
- return item.value;
182
- }),
183
- };
184
- }
185
- createStructsArray() {
186
- return {
187
- type: "array",
188
- valueType: "struct",
189
- values: this._items.map((item) => {
190
- (0, core_bentley_1.assert)(item.type === "struct");
191
- return item.members;
192
- }),
193
- };
194
- }
195
- }
196
- class StructItemAppender {
197
- constructor(_parentAppender, _props) {
198
- this._parentAppender = _parentAppender;
199
- this._props = _props;
200
- this._members = {};
201
- }
202
- append(label, item) {
203
- (0, core_bentley_1.assert)(item.type !== "category");
204
- this._members[label] = item;
205
- }
206
- finish() {
207
- (0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Struct);
208
- this._parentAppender.append(this._props.hierarchy.field.label, {
209
- type: "struct",
210
- members: this._members,
211
- });
212
- }
213
- }
214
- class ElementPropertiesBuilder {
215
- constructor() {
216
- this._appendersStack = [];
217
- this._items = [];
218
- }
219
- get items() {
220
- return this._items;
221
- }
222
- get _currentAppender() {
223
- const appender = this._appendersStack[this._appendersStack.length - 1];
224
- (0, core_bentley_1.assert)(appender !== undefined);
225
- return appender;
226
- }
227
- startContent(_props) { return true; }
228
- finishContent() { }
229
- processFieldHierarchies(_props) { }
230
- startItem(props) {
231
- this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));
232
- this._appendersStack.push(this._elementPropertiesAppender);
233
- return true;
234
- }
235
- finishItem() {
236
- this._appendersStack.pop();
237
- (0, core_bentley_1.assert)(this._elementPropertiesAppender !== undefined);
238
- this._elementPropertiesAppender.finish();
239
- this._elementPropertiesAppender = undefined;
240
- }
241
- startCategory(props) {
242
- (0, core_bentley_1.assert)(this._elementPropertiesAppender !== undefined);
243
- this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));
244
- return true;
245
- }
246
- finishCategory() {
247
- this._appendersStack.pop();
248
- }
249
- startField(_props) { return true; }
250
- finishField() { }
251
- startStruct(props) {
252
- this._appendersStack.push(new StructItemAppender(this._currentAppender, props));
253
- return true;
254
- }
255
- finishStruct() { this._appendersStack.pop().finish(); }
256
- startArray(props) {
257
- this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));
258
- return true;
259
- }
260
- finishArray() { this._appendersStack.pop().finish(); }
261
- processMergedValue(props) {
262
- this._currentAppender.append(props.mergedField.label, {
263
- type: "primitive",
264
- value: "",
265
- });
266
- }
267
- processPrimitiveValue(props) {
268
- var _a, _b;
269
- this._currentAppender.append(props.field.label, {
270
- type: "primitive",
271
- value: (_b = (_a = props.displayValue) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "",
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