@itwin/presentation-backend 3.5.0-dev.11 → 3.5.0-dev.13

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 (63) hide show
  1. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  2. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +761 -761
  3. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  4. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  5. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  7. package/lib/cjs/presentation-backend/Constants.d.ts +13 -13
  8. package/lib/cjs/presentation-backend/Constants.js +43 -43
  9. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  10. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  11. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +274 -274
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  13. package/lib/cjs/presentation-backend/NativePlatform.d.ts +84 -84
  14. package/lib/cjs/presentation-backend/NativePlatform.js +140 -140
  15. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  16. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  17. package/lib/cjs/presentation-backend/Presentation.js +150 -150
  18. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  19. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
  20. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
  21. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  22. package/lib/cjs/presentation-backend/PresentationManager.d.ts +441 -428
  23. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  24. package/lib/cjs/presentation-backend/PresentationManager.js +291 -291
  25. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  26. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +60 -60
  27. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +423 -423
  28. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  29. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +61 -59
  30. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  31. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +365 -364
  32. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  33. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +104 -104
  34. package/lib/cjs/presentation-backend/RulesetEmbedder.js +282 -282
  35. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  36. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  37. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  38. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  39. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  40. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  41. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  42. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +35 -35
  43. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +229 -229
  44. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  45. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  46. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  47. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  48. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  49. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  50. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  51. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  52. package/lib/cjs/presentation-backend/Utils.js +106 -106
  53. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  54. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  55. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +51 -51
  56. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  57. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  58. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  59. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  60. package/lib/cjs/presentation-backend.d.ts +19 -19
  61. package/lib/cjs/presentation-backend.js +35 -35
  62. package/lib/cjs/presentation-backend.js.map +1 -1
  63. package/package.json +13 -13
@@ -1,12 +1,12 @@
1
- /** @packageDocumentation
2
- * @module Core
3
- */
4
- import { IModelDb } from "@itwin/core-backend";
5
- import { Content, ElementProperties } from "@itwin/presentation-common";
6
- /** @internal */
7
- export declare const buildElementsProperties: (content: Content | undefined) => ElementProperties[];
8
- /** @internal */
9
- export declare function getElementsCount(db: IModelDb, classNames?: string[]): number;
10
- /** @internal */
11
- export declare function iterateElementIds(db: IModelDb, classNames?: string[], limit?: number): Generator<Map<string, string[]>, void, unknown>;
1
+ /** @packageDocumentation
2
+ * @module Core
3
+ */
4
+ import { IModelDb } from "@itwin/core-backend";
5
+ import { Content, ElementProperties } from "@itwin/presentation-common";
6
+ /** @internal */
7
+ export declare const buildElementsProperties: (content: Content | undefined) => ElementProperties[];
8
+ /** @internal */
9
+ export declare function getElementsCount(db: IModelDb, classNames?: string[]): number;
10
+ /** @internal */
11
+ export declare function iterateElementIds(db: IModelDb, classNames?: string[], limit?: number): Generator<Map<string, string[]>, void, unknown>;
12
12
  //# sourceMappingURL=ElementPropertiesHelper.d.ts.map
@@ -1,275 +1,275 @@
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 !== 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
+ }
275
275
  //# sourceMappingURL=ElementPropertiesHelper.js.map