@itwin/presentation-hierarchies 0.3.0 → 0.5.0
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 +69 -0
- package/README.md +27 -6
- package/lib/cjs/hierarchies/HierarchyDefinition.js +2 -2
- package/lib/cjs/hierarchies/HierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +17 -7
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +31 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js +33 -19
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.d.ts.map +1 -1
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.js +33 -13
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/cjs/hierarchies/Logging.js +2 -3
- package/lib/cjs/hierarchies/Logging.js.map +1 -1
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts +14 -2
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.js +7 -7
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.js +3 -3
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.js.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.d.ts +25 -5
- package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.js +41 -21
- package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
- package/lib/cjs/hierarchies/internal/EachValueFrom.js +1 -2
- package/lib/cjs/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts +17 -6
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js +118 -32
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/internal/LoggingUtils.d.ts +1 -3
- package/lib/cjs/hierarchies/internal/LoggingUtils.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/LoggingUtils.js +2 -21
- package/lib/cjs/hierarchies/internal/LoggingUtils.js.map +1 -1
- package/lib/cjs/hierarchies/internal/TreeNodesReader.js +2 -3
- package/lib/cjs/hierarchies/internal/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.js +3 -3
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Grouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Grouping.js +13 -12
- package/lib/cjs/hierarchies/internal/operators/Grouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.js +3 -3
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.js +3 -3
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Partition.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/Partition.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js +2 -3
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ShareReplayWithErrors.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/ShareReplayWithErrors.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/TapOnce.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/TapOnce.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.js +3 -4
- package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.js +7 -8
- package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/Shared.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/Shared.js.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.d.ts +17 -7
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +31 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js +34 -19
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.d.ts.map +1 -1
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.js +35 -14
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts +14 -2
- package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/NodeSelectQueryFactory.js +5 -5
- package/lib/esm/hierarchies/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.js +3 -3
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.js.map +1 -1
- package/lib/esm/hierarchies/internal/Common.d.ts +25 -5
- package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/Common.js +35 -15
- package/lib/esm/hierarchies/internal/Common.js.map +1 -1
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts +17 -6
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js +116 -30
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/internal/LoggingUtils.d.ts +1 -3
- package/lib/esm/hierarchies/internal/LoggingUtils.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/LoggingUtils.js +0 -17
- package/lib/esm/hierarchies/internal/LoggingUtils.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.js +2 -2
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Grouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Grouping.js +11 -10
- package/lib/esm/hierarchies/internal/operators/Grouping.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.js +2 -2
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.js +2 -2
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReleaseMainThread.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.js +2 -2
- package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +1 -1
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +1 -1
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +15 -15
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.ECSQL_COLUMN_NAME_HasFilterTargetAncestor = exports.ECSQL_COLUMN_NAME_FilterTargetOptions = exports.ECSQL_COLUMN_NAME_IsFilterTarget = exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths = exports.FilteringHierarchyDefinition = void 0;
|
|
8
|
+
exports.applyECInstanceIdsFilter = applyECInstanceIdsFilter;
|
|
8
9
|
const HierarchyDefinition_1 = require("../HierarchyDefinition");
|
|
9
10
|
const HierarchyNode_1 = require("../HierarchyNode");
|
|
10
11
|
const HierarchyNodeIdentifier_1 = require("../HierarchyNodeIdentifier");
|
|
@@ -29,27 +30,70 @@ class FilteringHierarchyDefinition {
|
|
|
29
30
|
return processedNode;
|
|
30
31
|
};
|
|
31
32
|
}
|
|
33
|
+
shouldExpandGroupingNode(node) {
|
|
34
|
+
for (const child of node.children) {
|
|
35
|
+
// istanbul ignore next
|
|
36
|
+
if (!child.filtering) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (child.filtering.isFilterTarget) {
|
|
40
|
+
const childAutoExpand = child.filtering.filterTargetOptions?.autoExpand;
|
|
41
|
+
// If child is a filter target and is has no `autoExpand` flag, then it's always to be expanded.
|
|
42
|
+
if (childAutoExpand === true) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
// If it's not an object and not `true`, then it's falsy - continue looking
|
|
46
|
+
if (typeof childAutoExpand !== "object") {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
// If grouping node's child has `autoExpandUntil` flag,
|
|
50
|
+
// auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.
|
|
51
|
+
const nodeDepth = node.parentKeys.length;
|
|
52
|
+
const filterTargetDepth = childAutoExpand.depth;
|
|
53
|
+
if (nodeDepth < filterTargetDepth) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!child.filtering.filteredChildrenIdentifierPaths) {
|
|
58
|
+
// istanbul ignore next
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
for (const path of child.filtering.filteredChildrenIdentifierPaths) {
|
|
62
|
+
if ("path" in path && path.options?.autoExpand) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
32
69
|
get postProcessNode() {
|
|
33
70
|
return async (node) => {
|
|
34
71
|
const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;
|
|
35
|
-
if (
|
|
36
72
|
// instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing
|
|
37
|
-
HierarchyNode_1.HierarchyNode.
|
|
38
|
-
|
|
39
|
-
return Object.assign(processedNode, { autoExpand: true });
|
|
73
|
+
if (HierarchyNode_1.HierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {
|
|
74
|
+
Object.assign(processedNode, { autoExpand: true });
|
|
40
75
|
}
|
|
41
76
|
return processedNode;
|
|
42
77
|
};
|
|
43
78
|
}
|
|
44
79
|
get parseNode() {
|
|
45
80
|
return (row) => {
|
|
46
|
-
const isFilterTarget = !!row[exports.ECSQL_COLUMN_NAME_IsFilterTarget];
|
|
47
81
|
const hasFilterTargetAncestor = !!row[exports.ECSQL_COLUMN_NAME_HasFilterTargetAncestor];
|
|
48
|
-
const
|
|
82
|
+
const isFilterTarget = !!row[exports.ECSQL_COLUMN_NAME_IsFilterTarget];
|
|
83
|
+
const filterTargetOptions = row[exports.ECSQL_COLUMN_NAME_FilterTargetOptions]
|
|
84
|
+
? JSON.parse(row[exports.ECSQL_COLUMN_NAME_FilterTargetOptions])
|
|
85
|
+
: undefined;
|
|
86
|
+
const filteredChildrenIdentifierPaths = row[exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths]
|
|
49
87
|
? JSON.parse(row[exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths])
|
|
50
88
|
: undefined;
|
|
51
89
|
const defaultNode = (this._source.parseNode ?? TreeNodesReader_1.defaultNodesParser)(row);
|
|
52
|
-
return applyFilterAttributes(
|
|
90
|
+
return applyFilterAttributes({
|
|
91
|
+
node: defaultNode,
|
|
92
|
+
filteredChildrenIdentifierPaths,
|
|
93
|
+
isFilterTarget,
|
|
94
|
+
filterTargetOptions,
|
|
95
|
+
hasFilterTargetAncestor,
|
|
96
|
+
});
|
|
53
97
|
};
|
|
54
98
|
}
|
|
55
99
|
async defineHierarchyLevel(props) {
|
|
@@ -67,11 +111,16 @@ class FilteringHierarchyDefinition {
|
|
|
67
111
|
return false;
|
|
68
112
|
}
|
|
69
113
|
return id.key === definition.node.key;
|
|
70
|
-
}, this._classHierarchy, (def, matchingFilters
|
|
114
|
+
}, this._classHierarchy, (def, matchingFilters) => {
|
|
71
115
|
const filteredChildrenIdentifierPaths = matchingFilters.reduce((r, c) => [...r, ...c.childrenIdentifierPaths], new Array());
|
|
72
116
|
return {
|
|
73
117
|
...def,
|
|
74
|
-
node: applyFilterAttributes(
|
|
118
|
+
node: applyFilterAttributes({
|
|
119
|
+
node: def.node,
|
|
120
|
+
filteredChildrenIdentifierPaths,
|
|
121
|
+
isFilterTarget: matchingFilters.some((mc) => mc.isFilterTarget),
|
|
122
|
+
hasFilterTargetAncestor,
|
|
123
|
+
}),
|
|
75
124
|
};
|
|
76
125
|
});
|
|
77
126
|
}
|
|
@@ -81,7 +130,7 @@ class FilteringHierarchyDefinition {
|
|
|
81
130
|
return false;
|
|
82
131
|
}
|
|
83
132
|
return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);
|
|
84
|
-
}, this._classHierarchy, (def, matchingFilters
|
|
133
|
+
}, this._classHierarchy, (def, matchingFilters) => applyECInstanceIdsFilter(def, matchingFilters, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor));
|
|
85
134
|
}
|
|
86
135
|
if (matchedDefinition) {
|
|
87
136
|
filteredDefinitions.push(matchedDefinition);
|
|
@@ -103,42 +152,72 @@ class FilteringHierarchyDefinition {
|
|
|
103
152
|
exports.FilteringHierarchyDefinition = FilteringHierarchyDefinition;
|
|
104
153
|
async function matchFilters(definition, filteringProps, predicate, classHierarchy, matchedDefinitionProcessor) {
|
|
105
154
|
const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;
|
|
106
|
-
let isFilterTarget = false;
|
|
107
155
|
const matchingFilters = [];
|
|
108
|
-
for (const
|
|
156
|
+
for (const filteredNodePath of filteredNodePaths) {
|
|
157
|
+
const { path, options } = "path" in filteredNodePath ? filteredNodePath : { path: filteredNodePath, options: undefined };
|
|
109
158
|
if (path.length === 0) {
|
|
110
159
|
continue;
|
|
111
160
|
}
|
|
112
161
|
const nodeId = path[0];
|
|
113
162
|
if (await predicate(nodeId)) {
|
|
114
|
-
let
|
|
115
|
-
if (!
|
|
116
|
-
|
|
117
|
-
matchingFilters.push({
|
|
163
|
+
let entry = await findMatchingFilterEntry(matchingFilters, nodeId, classHierarchy);
|
|
164
|
+
if (!entry) {
|
|
165
|
+
entry = {
|
|
118
166
|
// ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment
|
|
119
167
|
// async type guards aren't supported
|
|
120
168
|
id: nodeId,
|
|
121
|
-
childrenIdentifierPaths,
|
|
122
|
-
|
|
169
|
+
childrenIdentifierPaths: [],
|
|
170
|
+
isFilterTarget: false,
|
|
171
|
+
};
|
|
172
|
+
matchingFilters.push(entry);
|
|
123
173
|
}
|
|
124
174
|
const remainingPath = path.slice(1);
|
|
125
175
|
if (remainingPath.length > 0) {
|
|
126
|
-
|
|
176
|
+
const remainingPathWithOptions = options ? { path: remainingPath, options } : remainingPath;
|
|
177
|
+
entry.childrenIdentifierPaths.push(remainingPathWithOptions);
|
|
178
|
+
}
|
|
179
|
+
else if (entry.isFilterTarget) {
|
|
180
|
+
entry.filterTargetOptions = mergeFilterTargetOptions(entry.filterTargetOptions, options);
|
|
127
181
|
}
|
|
128
182
|
else {
|
|
129
|
-
isFilterTarget
|
|
183
|
+
Object.assign(entry, { isFilterTarget: true, filterTargetOptions: options });
|
|
130
184
|
}
|
|
131
185
|
}
|
|
132
186
|
}
|
|
133
187
|
if (isDirectParentFilterTarget || matchingFilters.length > 0) {
|
|
134
|
-
return matchedDefinitionProcessor(definition, matchingFilters
|
|
188
|
+
return matchedDefinitionProcessor(definition, matchingFilters);
|
|
135
189
|
}
|
|
136
190
|
return undefined;
|
|
137
191
|
}
|
|
138
|
-
|
|
192
|
+
function mergeFilterTargetOptions(target, source) {
|
|
193
|
+
// istanbul ignore next
|
|
194
|
+
if (!target && !source) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
// istanbul ignore next
|
|
198
|
+
if (!target) {
|
|
199
|
+
return source;
|
|
200
|
+
}
|
|
201
|
+
// istanbul ignore next
|
|
202
|
+
if (!source) {
|
|
203
|
+
return target;
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
autoExpand: (() => {
|
|
207
|
+
if (source.autoExpand === true) {
|
|
208
|
+
return source.autoExpand;
|
|
209
|
+
}
|
|
210
|
+
if (typeof target.autoExpand === "object" && typeof source.autoExpand === "object" && source.autoExpand.depth > target.autoExpand.depth) {
|
|
211
|
+
return source.autoExpand;
|
|
212
|
+
}
|
|
213
|
+
return target.autoExpand;
|
|
214
|
+
})(),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
async function findMatchingFilterEntry(filters, nodeId, classHierarchy) {
|
|
139
218
|
for (const filter of filters) {
|
|
140
219
|
if (await identifiersEqual(filter.id, nodeId, classHierarchy)) {
|
|
141
|
-
return filter
|
|
220
|
+
return filter;
|
|
142
221
|
}
|
|
143
222
|
}
|
|
144
223
|
return undefined;
|
|
@@ -152,15 +231,17 @@ async function identifiersEqual(lhs, rhs, classHierarchy) {
|
|
|
152
231
|
}
|
|
153
232
|
return HierarchyNodeIdentifier_1.HierarchyNodeIdentifier.equal(lhs, rhs);
|
|
154
233
|
}
|
|
155
|
-
function applyFilterAttributes(node, filteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor) {
|
|
156
|
-
const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((
|
|
234
|
+
function applyFilterAttributes({ node, filteredChildrenIdentifierPaths, isFilterTarget, filterTargetOptions, hasFilterTargetAncestor, }) {
|
|
235
|
+
const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((childPath) => {
|
|
236
|
+
return "path" in childPath && childPath.path.length && childPath.options?.autoExpand;
|
|
237
|
+
});
|
|
157
238
|
const result = { ...node };
|
|
158
239
|
if (shouldAutoExpand) {
|
|
159
240
|
result.autoExpand = true;
|
|
160
241
|
}
|
|
161
242
|
if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {
|
|
162
243
|
result.filtering = {
|
|
163
|
-
...(isFilterTarget ? { isFilterTarget } : undefined),
|
|
244
|
+
...(isFilterTarget ? { isFilterTarget, filterTargetOptions } : undefined),
|
|
164
245
|
...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),
|
|
165
246
|
...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),
|
|
166
247
|
};
|
|
@@ -175,9 +256,12 @@ exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths = "FilteredChildrenPaths";
|
|
|
175
256
|
exports.ECSQL_COLUMN_NAME_IsFilterTarget = "IsFilterTarget";
|
|
176
257
|
/** @internal */
|
|
177
258
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
259
|
+
exports.ECSQL_COLUMN_NAME_FilterTargetOptions = "FilterTargetOptions";
|
|
260
|
+
/** @internal */
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
178
262
|
exports.ECSQL_COLUMN_NAME_HasFilterTargetAncestor = "HasFilterTargetAncestor";
|
|
179
263
|
/** @internal */
|
|
180
|
-
function applyECInstanceIdsFilter(def, matchingFilters,
|
|
264
|
+
function applyECInstanceIdsFilter(def, matchingFilters, isParentFilterTarget, hasFilterTargetAncestor) {
|
|
181
265
|
if (matchingFilters.length === 0) {
|
|
182
266
|
return def;
|
|
183
267
|
}
|
|
@@ -189,16 +273,19 @@ function applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, isParent
|
|
|
189
273
|
...(def.query.ctes ?? []),
|
|
190
274
|
// note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),
|
|
191
275
|
// so using UNION as a workaround
|
|
192
|
-
`FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (
|
|
276
|
+
`FilteringInfo(ECInstanceId, IsFilterTarget, FilterTargetOptions, FilteredChildrenPaths) AS (
|
|
193
277
|
${matchingFilters
|
|
194
|
-
.map((
|
|
278
|
+
.map((mc) => mc.isFilterTarget
|
|
279
|
+
? `VALUES (${mc.id.id}, 1, ${mc.filterTargetOptions ? `'${JSON.stringify(mc.filterTargetOptions)}'` : "CAST(NULL AS TEXT)"}, '${JSON.stringify(mc.childrenIdentifierPaths)}')`
|
|
280
|
+
: `VALUES (${mc.id.id}, 0, CAST(NULL AS TEXT), '${JSON.stringify(mc.childrenIdentifierPaths)}')`)
|
|
195
281
|
.join(" UNION ALL ")}
|
|
196
282
|
)`,
|
|
197
283
|
],
|
|
198
284
|
ecsql: `
|
|
199
285
|
SELECT
|
|
200
286
|
[q].*,
|
|
201
|
-
|
|
287
|
+
[f].[IsFilterTarget] AS [${exports.ECSQL_COLUMN_NAME_IsFilterTarget}],
|
|
288
|
+
[f].[FilterTargetOptions] AS [${exports.ECSQL_COLUMN_NAME_FilterTargetOptions}],
|
|
202
289
|
${hasFilterTargetAncestor || isParentFilterTarget ? "1" : "0"} AS [${exports.ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],
|
|
203
290
|
[f].[FilteredChildrenPaths] AS [${exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths}]
|
|
204
291
|
FROM (
|
|
@@ -209,5 +296,4 @@ function applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, isParent
|
|
|
209
296
|
},
|
|
210
297
|
};
|
|
211
298
|
}
|
|
212
|
-
exports.applyECInstanceIdsFilter = applyECInstanceIdsFilter;
|
|
213
299
|
//# sourceMappingURL=FilteringHierarchyDefinition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAGhG,gEAUgC;AAChC,oDAA2H;AAC3H,wEAAmG;AACnG,uDAAuD;AASvD,gBAAgB;AAChB,MAAa,4BAA4B;IAC/B,eAAe,CAA4B;IAC3C,OAAO,CAAsB;IAC7B,oBAAoB,CAAiC;IAE7D,YAAmB,KAAiC;QAClD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,mBAAmB,CAAC;IACxD,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;YACpB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACnG,IAAI,aAAa,EAAE,gBAAgB,EAAE,eAAe,IAAI,aAAa,CAAC,SAAS,EAAE,cAAc,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,uBAAuB,EAAE,CAAC;gBACpJ,yHAAyH;gBACzH,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,aAAa,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,KAAK,EAAE,IAA4B,EAAE,EAAE;YAC5C,MAAM,aAAa,GAAG,IAAI,CAA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AGD,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,wCAAgC;YAClE,uBAAuB,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,iDAAyC;4CAC5E,+CAAuC;;YAEvE,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACtC;SACF;KACF,CAAC;AACJ,CAAC;AArCD,4DAqCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport {\n CustomHierarchyNodeDefinition,\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"../HierarchyDefinition\";\nimport { HierarchyNode, ParsedHierarchyNode, ParsedInstanceHierarchyNode, ProcessedHierarchyNode } from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"../HierarchyNodeIdentifier\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n\n public constructor(props: FilteringQueryBuilderProps) {\n this._classHierarchy = props.classHierarchy;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n if (processedNode?.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return undefined;\n }\n return processedNode;\n };\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n if (\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n HierarchyNode.isClassGroupingNode(node) &&\n node.children.some(\n (child: ProcessedHierarchyNode) => child.filtering && (child.filtering.isFilterTarget || child.filtering.filteredChildrenIdentifierPaths),\n )\n ) {\n return Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): ParsedInstanceHierarchyNode => {\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const parsedFilteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor);\n };\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { filteredNodePaths, isDirectParentFilterTarget, hasFilterTargetAncestor } = this.getFilteringProps(props.parentNode);\n if (!filteredNodePaths) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isCustomNode(definition)) {\n matchedDefinition = await matchFilters<{ key: string }>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {\n return false;\n }\n return id.key === definition.node.key;\n },\n this._classHierarchy,\n (def, matchingFilters, isFilterTarget) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyNodeIdentifiersPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget, !!hasFilterTargetAncestor),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n return false;\n }\n return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);\n },\n this._classHierarchy,\n (def, matchingFilters, isFilterTarget) =>\n applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n\n private getFilteringProps(parentNode: Pick<HierarchyNode, \"filtering\"> | undefined) {\n if (!parentNode) {\n return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };\n }\n return {\n filteredNodePaths: parentNode.filtering?.filteredChildrenIdentifierPaths,\n isDirectParentFilterTarget: parentNode.filtering?.isFilterTarget,\n hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor,\n };\n }\n}\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyNodeIdentifiersPath[]; isDirectParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n classHierarchy: ECClassHierarchyInspector,\n matchedDefinitionProcessor: (\n def: TDefinition,\n matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n ) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;\n let isFilterTarget = false;\n const matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }> = [];\n for (const path of filteredNodePaths) {\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let childrenIdentifierPaths = await findChildrenIdentifierPaths(matchingFilters, nodeId, classHierarchy);\n if (!childrenIdentifierPaths) {\n childrenIdentifierPaths = [];\n matchingFilters.push({\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths,\n });\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n childrenIdentifierPaths.push(remainingPath);\n } else {\n isFilterTarget = true;\n }\n }\n }\n if (isDirectParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters, isFilterTarget);\n }\n return undefined;\n}\n\nasync function findChildrenIdentifierPaths<TIdentifier extends HierarchyNodeIdentifier>(\n filters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n nodeId: TIdentifier,\n classHierarchy: ECClassHierarchyInspector,\n) {\n for (const filter of filters) {\n if (await identifiersEqual(filter.id, nodeId, classHierarchy)) {\n return filter.childrenIdentifierPaths;\n }\n }\n return undefined;\n}\n\nasync function identifiersEqual<TIdentifier extends HierarchyNodeIdentifier>(lhs: TIdentifier, rhs: TIdentifier, classHierarchy: ECClassHierarchyInspector) {\n if (HierarchyNodeIdentifier.isInstanceNodeIdentifier(lhs) && HierarchyNodeIdentifier.isInstanceNodeIdentifier(rhs)) {\n return (\n lhs.id === rhs.id &&\n (lhs.className === rhs.className ||\n (await classHierarchy.classDerivesFrom(lhs.className, rhs.className)) ||\n (await classHierarchy.classDerivesFrom(rhs.className, lhs.className)))\n );\n }\n return HierarchyNodeIdentifier.equal(lhs, rhs);\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>(\n node: TNode,\n filteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined,\n isFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);\n const result = { ...node };\n if (shouldAutoExpand) {\n result.autoExpand = true;\n }\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n result.filtering = {\n ...(isFilterTarget ? { isFilterTarget } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n }\n return result;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilteredChildrenPaths = \"FilteredChildrenPaths\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_IsFilterTarget = \"IsFilterTarget\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<{ id: InstanceKey; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n isParentFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map(({ id: key, childrenIdentifierPaths }) => `VALUES (${key.id}, '${JSON.stringify(childrenIdentifierPaths)}')`)\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n ${isFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n ${hasFilterTargetAncestor || isParentFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${isParentFilterTarget ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA0VhG,4DAyCC;AAhYD,gEAUgC;AAChC,oDAA2J;AAC3J,wEAAqE;AAErE,uDAAuD;AASvD,gBAAgB;AAChB,MAAa,4BAA4B;IAC/B,eAAe,CAA4B;IAC3C,OAAO,CAAsB;IAC7B,oBAAoB,CAA2B;IAEvD,YAAmB,KAAiC;QAClD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC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C,GAAG,QAAQ,iDAAyC;4CAC5E,+CAAuC;;YAEvE,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACtC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport {\n CustomHierarchyNodeDefinition,\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"../HierarchyDefinition\";\nimport { HierarchyNode, ParsedHierarchyNode, ParsedInstanceHierarchyNode, ProcessedGroupingHierarchyNode, ProcessedHierarchyNode } from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier\";\nimport { HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"../HierarchyProvider\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyFilteringPath[];\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyFilteringPath[];\n\n public constructor(props: FilteringQueryBuilderProps) {\n this._classHierarchy = props.classHierarchy;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n if (processedNode?.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return undefined;\n }\n return processedNode;\n };\n }\n\n private shouldExpandGroupingNode(node: ProcessedGroupingHierarchyNode) {\n for (const child of node.children) {\n // istanbul ignore next\n if (!child.filtering) {\n continue;\n }\n\n if (child.filtering.isFilterTarget) {\n const childAutoExpand = child.filtering.filterTargetOptions?.autoExpand;\n\n // If child is a filter target and is has no `autoExpand` flag, then it's always to be expanded.\n if (childAutoExpand === true) {\n return true;\n }\n\n // If it's not an object and not `true`, then it's falsy - continue looking\n if (typeof childAutoExpand !== \"object\") {\n continue;\n }\n\n // If grouping node's child has `autoExpandUntil` flag,\n // auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.\n const nodeDepth = node.parentKeys.length;\n const filterTargetDepth = childAutoExpand.depth;\n if (nodeDepth < filterTargetDepth) {\n return true;\n }\n }\n\n if (!child.filtering.filteredChildrenIdentifierPaths) {\n // istanbul ignore next\n continue;\n }\n\n for (const path of child.filtering.filteredChildrenIdentifierPaths) {\n if (\"path\" in path && path.options?.autoExpand) {\n return true;\n }\n }\n }\n return false;\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n if (HierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {\n Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): ParsedInstanceHierarchyNode => {\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const filterTargetOptions: HierarchyFilteringPathOptions | undefined = row[ECSQL_COLUMN_NAME_FilterTargetOptions]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilterTargetOptions])\n : undefined;\n const filteredChildrenIdentifierPaths: HierarchyFilteringPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes({\n node: defaultNode,\n filteredChildrenIdentifierPaths,\n isFilterTarget,\n filterTargetOptions,\n hasFilterTargetAncestor,\n });\n };\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { filteredNodePaths, isDirectParentFilterTarget, hasFilterTargetAncestor } = this.getFilteringProps(props.parentNode);\n if (!filteredNodePaths) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isCustomNode(definition)) {\n matchedDefinition = await matchFilters<{ key: string }>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {\n return false;\n }\n return id.key === definition.node.key;\n },\n this._classHierarchy,\n (def, matchingFilters) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyFilteringPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes({\n node: def.node,\n filteredChildrenIdentifierPaths,\n isFilterTarget: matchingFilters.some((mc) => mc.isFilterTarget),\n hasFilterTargetAncestor,\n }),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n return false;\n }\n return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);\n },\n this._classHierarchy,\n (def, matchingFilters) => applyECInstanceIdsFilter(def, matchingFilters, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n\n private getFilteringProps(parentNode: Pick<HierarchyNode, \"filtering\"> | undefined) {\n if (!parentNode) {\n return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };\n }\n return {\n filteredNodePaths: parentNode.filtering?.filteredChildrenIdentifierPaths,\n isDirectParentFilterTarget: parentNode.filtering?.isFilterTarget,\n hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor,\n };\n }\n}\n\ntype MatchedFilter<TIdentifier extends HierarchyNodeIdentifier> = {\n id: TIdentifier;\n childrenIdentifierPaths: HierarchyFilteringPath[];\n} & ({ isFilterTarget: false } | { isFilterTarget: true; filterTargetOptions?: HierarchyFilteringPathOptions });\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyFilteringPath[]; isDirectParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n classHierarchy: ECClassHierarchyInspector,\n matchedDefinitionProcessor: (def: TDefinition, matchingFilters: Array<MatchedFilter<TIdentifier>>) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;\n const matchingFilters: Array<MatchedFilter<TIdentifier>> = [];\n for (const filteredNodePath of filteredNodePaths) {\n const { path, options } = \"path\" in filteredNodePath ? filteredNodePath : { path: filteredNodePath, options: undefined };\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let entry = await findMatchingFilterEntry(matchingFilters, nodeId, classHierarchy);\n if (!entry) {\n entry = {\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths: [],\n isFilterTarget: false,\n };\n matchingFilters.push(entry);\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n const remainingPathWithOptions = options ? { path: remainingPath, options } : remainingPath;\n entry.childrenIdentifierPaths.push(remainingPathWithOptions);\n } else if (entry.isFilterTarget) {\n entry.filterTargetOptions = mergeFilterTargetOptions(entry.filterTargetOptions, options);\n } else {\n Object.assign(entry, { isFilterTarget: true, filterTargetOptions: options });\n }\n }\n }\n if (isDirectParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters);\n }\n return undefined;\n}\n\nfunction mergeFilterTargetOptions(target?: HierarchyFilteringPathOptions, source?: HierarchyFilteringPathOptions): HierarchyFilteringPathOptions | undefined {\n // istanbul ignore next\n if (!target && !source) {\n return undefined;\n }\n // istanbul ignore next\n if (!target) {\n return source;\n }\n // istanbul ignore next\n if (!source) {\n return target;\n }\n return {\n autoExpand: ((): HierarchyFilteringPathOptions[\"autoExpand\"] => {\n if (source.autoExpand === true) {\n return source.autoExpand;\n }\n if (typeof target.autoExpand === \"object\" && typeof source.autoExpand === \"object\" && source.autoExpand.depth > target.autoExpand.depth) {\n return source.autoExpand;\n }\n return target.autoExpand;\n })(),\n };\n}\n\nasync function findMatchingFilterEntry<TEntry extends { id: TIdentifier }, TIdentifier extends HierarchyNodeIdentifier>(\n filters: TEntry[],\n nodeId: TIdentifier,\n classHierarchy: ECClassHierarchyInspector,\n): Promise<TEntry | undefined> {\n for (const filter of filters) {\n if (await identifiersEqual(filter.id, nodeId, classHierarchy)) {\n return filter;\n }\n }\n return undefined;\n}\n\nasync function identifiersEqual<TIdentifier extends HierarchyNodeIdentifier>(lhs: TIdentifier, rhs: TIdentifier, classHierarchy: ECClassHierarchyInspector) {\n if (HierarchyNodeIdentifier.isInstanceNodeIdentifier(lhs) && HierarchyNodeIdentifier.isInstanceNodeIdentifier(rhs)) {\n return (\n lhs.id === rhs.id &&\n (lhs.className === rhs.className ||\n (await classHierarchy.classDerivesFrom(lhs.className, rhs.className)) ||\n (await classHierarchy.classDerivesFrom(rhs.className, lhs.className)))\n );\n }\n return HierarchyNodeIdentifier.equal(lhs, rhs);\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>({\n node,\n filteredChildrenIdentifierPaths,\n isFilterTarget,\n filterTargetOptions,\n hasFilterTargetAncestor,\n}: {\n node: TNode;\n filteredChildrenIdentifierPaths: HierarchyFilteringPath[] | undefined;\n isFilterTarget?: boolean;\n filterTargetOptions?: HierarchyFilteringPathOptions;\n hasFilterTargetAncestor: boolean;\n}): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((childPath) => {\n return \"path\" in childPath && childPath.path.length && childPath.options?.autoExpand;\n });\n const result = { ...node };\n if (shouldAutoExpand) {\n result.autoExpand = true;\n }\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n result.filtering = {\n ...(isFilterTarget ? { isFilterTarget, filterTargetOptions } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n }\n return result;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilteredChildrenPaths = \"FilteredChildrenPaths\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_IsFilterTarget = \"IsFilterTarget\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterTargetOptions = \"FilterTargetOptions\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<MatchedFilter<InstanceKey>>,\n isParentFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, IsFilterTarget, FilterTargetOptions, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map((mc) =>\n mc.isFilterTarget\n ? `VALUES (${mc.id.id}, 1, ${mc.filterTargetOptions ? `'${JSON.stringify(mc.filterTargetOptions)}'` : \"CAST(NULL AS TEXT)\"}, '${JSON.stringify(mc.childrenIdentifierPaths)}')`\n : `VALUES (${mc.id.id}, 0, CAST(NULL AS TEXT), '${JSON.stringify(mc.childrenIdentifierPaths)}')`,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n [f].[IsFilterTarget] AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n [f].[FilterTargetOptions] AS [${ECSQL_COLUMN_NAME_FilterTargetOptions}],\n ${hasFilterTargetAncestor || isParentFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${isParentFilterTarget ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogLevel } from "@itwin/presentation-shared";
|
|
2
2
|
/** @internal */
|
|
3
3
|
export interface LogMessageProps<TMessageArg = void> {
|
|
4
4
|
category: string;
|
|
@@ -9,6 +9,4 @@ export interface LogMessageProps<TMessageArg = void> {
|
|
|
9
9
|
export declare function doLog(props: LogMessageProps): void;
|
|
10
10
|
/** @internal */
|
|
11
11
|
export declare function log<TMessageArg>(props: LogMessageProps<TMessageArg>): import("rxjs").MonoTypeOperatorFunction<TMessageArg>;
|
|
12
|
-
/** @internal */
|
|
13
|
-
export declare function createQueryLogMessage(query: ECSqlQueryDef): string;
|
|
14
12
|
//# sourceMappingURL=LoggingUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggingUtils.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/LoggingUtils.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"LoggingUtils.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/LoggingUtils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG/D,gBAAgB;AAChB,MAAM,WAAW,eAAe,CAAC,WAAW,GAAG,IAAI;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,MAAM,CAAC;CACvC;AAED,gBAAgB;AAChB,wBAAgB,KAAK,CAAC,KAAK,EAAE,eAAe,QAQ3C;AAeD,gBAAgB;AAChB,wBAAgB,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,wDAEnE"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.doLog = doLog;
|
|
8
|
+
exports.log = log;
|
|
8
9
|
const rxjs_1 = require("rxjs");
|
|
9
|
-
const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
10
10
|
const Logging_1 = require("../Logging");
|
|
11
11
|
/** @internal */
|
|
12
12
|
function doLog(props) {
|
|
@@ -18,7 +18,6 @@ function doLog(props) {
|
|
|
18
18
|
const logFunc = getLogFunc(logger, severity);
|
|
19
19
|
logFunc(props.category, props.message());
|
|
20
20
|
}
|
|
21
|
-
exports.doLog = doLog;
|
|
22
21
|
function getLogFunc(logger, severity) {
|
|
23
22
|
switch (severity) {
|
|
24
23
|
case "error":
|
|
@@ -35,22 +34,4 @@ function getLogFunc(logger, severity) {
|
|
|
35
34
|
function log(props) {
|
|
36
35
|
return (0, rxjs_1.tap)((n) => doLog({ ...props, message: () => props.message(n) }));
|
|
37
36
|
}
|
|
38
|
-
exports.log = log;
|
|
39
|
-
/** @internal */
|
|
40
|
-
// istanbul ignore next
|
|
41
|
-
function createQueryLogMessage(query) {
|
|
42
|
-
const ctes = query.ctes?.map((cte) => ` ${(0, presentation_shared_1.trimWhitespace)(cte)}`).join(", \n");
|
|
43
|
-
const bindings = query.bindings?.map((b) => JSON.stringify(b.value)).join(", ");
|
|
44
|
-
let output = "{\n";
|
|
45
|
-
if (ctes) {
|
|
46
|
-
output += ` ctes: [ \n${ctes} \n], \n`;
|
|
47
|
-
}
|
|
48
|
-
output += ` ecsql: ${(0, presentation_shared_1.trimWhitespace)(query.ecsql)}, \n`;
|
|
49
|
-
if (bindings) {
|
|
50
|
-
output += ` bindings: [${bindings}], \n`;
|
|
51
|
-
}
|
|
52
|
-
output += "}";
|
|
53
|
-
return output;
|
|
54
|
-
}
|
|
55
|
-
exports.createQueryLogMessage = createQueryLogMessage;
|
|
56
37
|
//# sourceMappingURL=LoggingUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggingUtils.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/LoggingUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG
|
|
1
|
+
{"version":3,"file":"LoggingUtils.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/LoggingUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAchG,sBAQC;AAgBD,kBAEC;AAtCD,+BAA2B;AAE3B,wCAAuC;AASvC,gBAAgB;AAChB,SAAgB,KAAK,CAAC,KAAsB;IAC1C,MAAM,MAAM,GAAG,IAAA,mBAAS,GAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,OAAO,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;QAChD,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,UAAU,CAAC,MAAe,EAAE,QAAkB;IACrD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,KAAK,MAAM;YACT,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrC,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AAED,gBAAgB;AAChB,SAAgB,GAAG,CAAc,KAAmC;IAClE,OAAO,IAAA,UAAG,EAAc,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { tap } from \"rxjs\";\nimport { ILogger, LogLevel } from \"@itwin/presentation-shared\";\nimport { getLogger } from \"../Logging\";\n\n/** @internal */\nexport interface LogMessageProps<TMessageArg = void> {\n category: string;\n severity?: LogLevel;\n message: (arg: TMessageArg) => string;\n}\n\n/** @internal */\nexport function doLog(props: LogMessageProps) {\n const logger = getLogger();\n const severity = props.severity ?? \"trace\";\n if (!logger.isEnabled(props.category, severity)) {\n return;\n }\n const logFunc = getLogFunc(logger, severity);\n logFunc(props.category, props.message());\n}\n\nfunction getLogFunc(logger: ILogger, severity: LogLevel) {\n switch (severity) {\n case \"error\":\n return logger.logError.bind(logger);\n case \"warning\":\n return logger.logWarning.bind(logger);\n case \"info\":\n return logger.logInfo.bind(logger);\n case \"trace\":\n return logger.logTrace.bind(logger);\n }\n}\n\n/** @internal */\nexport function log<TMessageArg>(props: LogMessageProps<TMessageArg>) {\n return tap<TMessageArg>((n) => doLog({ ...props, message: () => props.message(n) }));\n}\n"]}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.readNodes = readNodes;
|
|
8
|
+
exports.defaultNodesParser = defaultNodesParser;
|
|
8
9
|
const rxjs_1 = require("rxjs");
|
|
9
10
|
const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
10
11
|
const NodeSelectQueryFactory_1 = require("../NodeSelectQueryFactory");
|
|
@@ -18,7 +19,6 @@ function readNodes(props) {
|
|
|
18
19
|
};
|
|
19
20
|
return (0, rxjs_1.from)(queryExecutor.createQueryReader(query, config)).pipe((0, rxjs_1.map)(parser));
|
|
20
21
|
}
|
|
21
|
-
exports.readNodes = readNodes;
|
|
22
22
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
23
23
|
/** @internal */
|
|
24
24
|
function defaultNodesParser(row) {
|
|
@@ -42,5 +42,4 @@ function defaultNodesParser(row) {
|
|
|
42
42
|
...(Object.keys(processingParams).length > 0 ? { processingParams } : undefined),
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
exports.defaultNodesParser = defaultNodesParser;
|
|
46
45
|
//# sourceMappingURL=TreeNodesReader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodesReader.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/TreeNodesReader.ts"],"names":[],"mappings":";AAAA;;;gGAGgG
|
|
1
|
+
{"version":3,"file":"TreeNodesReader.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/TreeNodesReader.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAkBhG,8BAQC;AAsBD,gDAoBC;AAlED,+BAA6C;AAE7C,oEAA+E;AAI/E,sEAAwE;AASxE,gBAAgB;AAChB,SAAgB,SAAS,CAAC,KAAqB;IAC7C,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAC9C,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,IAAI,kBAAkB,CAAC;IACnD,MAAM,MAAM,GAAmE;QAC7E,SAAS,EAAE,oBAAoB;QAC/B,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;KACjD,CAAC;IACF,OAAO,IAAA,WAAI,EAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAA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AAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACzE,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5F,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;KACjF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { from, map, Observable } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECSqlQueryDef, parseInstanceLabel } from \"@itwin/presentation-shared\";\nimport { NodeParser } from \"../HierarchyDefinition\";\nimport { InstanceHierarchyNodeProcessingParams, ParsedHierarchyNode, ParsedInstanceHierarchyNode } from \"../HierarchyNode\";\nimport { LimitingECSqlQueryExecutor } from \"../LimitingECSqlQueryExecutor\";\nimport { NodeSelectClauseColumnNames } from \"../NodeSelectQueryFactory\";\n\ninterface ReadNodesProps {\n queryExecutor: LimitingECSqlQueryExecutor;\n query: ECSqlQueryDef;\n limit?: number | \"unbounded\";\n parser?: NodeParser;\n}\n\n/** @internal */\nexport function readNodes(props: ReadNodesProps): Observable<ParsedHierarchyNode> {\n const { queryExecutor, query, limit } = props;\n const parser = props?.parser ?? defaultNodesParser;\n const config: Parameters<LimitingECSqlQueryExecutor[\"createQueryReader\"]>[1] = {\n rowFormat: \"ECSqlPropertyNames\",\n ...(limit !== undefined ? { limit } : undefined),\n };\n return from(queryExecutor.createQueryReader(query, config)).pipe(map(parser));\n}\n\n/**\n * The interface should contain a member for each `NodeSelectClauseColumnNames` value.\n * @internal\n */\n/* eslint-disable @typescript-eslint/naming-convention */\nexport interface RowDef {\n [NodeSelectClauseColumnNames.FullClassName]: string;\n [NodeSelectClauseColumnNames.ECInstanceId]: Id64String;\n [NodeSelectClauseColumnNames.DisplayLabel]: string;\n [NodeSelectClauseColumnNames.HasChildren]?: boolean;\n [NodeSelectClauseColumnNames.HideIfNoChildren]?: boolean;\n [NodeSelectClauseColumnNames.HideNodeInHierarchy]?: boolean;\n [NodeSelectClauseColumnNames.Grouping]?: string;\n [NodeSelectClauseColumnNames.ExtendedData]?: string;\n [NodeSelectClauseColumnNames.AutoExpand]?: boolean;\n [NodeSelectClauseColumnNames.SupportsFiltering]?: boolean;\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\n/** @internal */\nexport function defaultNodesParser(row: { [columnName: string]: any }): ParsedInstanceHierarchyNode {\n const typedRow = row as RowDef;\n const processingParams: InstanceHierarchyNodeProcessingParams = {\n ...(typedRow.HideIfNoChildren ? { hideIfNoChildren: true } : undefined),\n ...(typedRow.HideNodeInHierarchy ? { hideInHierarchy: true } : undefined),\n ...(typedRow.Grouping ? { grouping: JSON.parse(typedRow.Grouping) } : undefined),\n };\n return {\n // don't format the label here - we're going to do that at node pre-processing step to handle both - instance and custom nodes\n label: parseInstanceLabel(typedRow.DisplayLabel),\n key: {\n type: \"instances\",\n instanceKeys: [{ className: typedRow.FullClassName.replace(\":\", \".\"), id: typedRow.ECInstanceId }],\n },\n ...(typedRow.HasChildren !== undefined ? { children: !!typedRow.HasChildren } : undefined),\n ...(typedRow.AutoExpand ? { autoExpand: true } : undefined),\n ...(typedRow.SupportsFiltering ? { supportsFiltering: true } : undefined),\n ...(typedRow.ExtendedData ? { extendedData: JSON.parse(typedRow.ExtendedData) } : undefined),\n ...(Object.keys(processingParams).length > 0 ? { processingParams } : undefined),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetermineChildren.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/internal/operators/DetermineChildren.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,UAAU,EAAM,MAAM,MAAM,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAM7D,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"DetermineChildren.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/internal/operators/DetermineChildren.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,UAAU,EAAM,MAAM,MAAM,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAM7D,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,QAA4E,CAAC;AAE3G;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,UAAU,CAAC,OAAO,CAAC,WACrF,UAAU,CAAC,sBAAsB,CAAC,KAAG,UAAU,CAAC,sBAAsB,CAAC,CAmBhG"}
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.LOGGING_NAMESPACE = void 0;
|
|
8
|
+
exports.createDetermineChildrenOperator = createDetermineChildrenOperator;
|
|
8
9
|
const rxjs_1 = require("rxjs");
|
|
9
10
|
const Common_1 = require("../Common");
|
|
10
11
|
const LoggingUtils_1 = require("../LoggingUtils");
|
|
11
12
|
const ReleaseMainThread_1 = require("./ReleaseMainThread");
|
|
12
13
|
const OPERATOR_NAME = "DetermineChildren";
|
|
13
14
|
/** @internal */
|
|
14
|
-
exports.LOGGING_NAMESPACE = (0, Common_1.createOperatorLoggingNamespace)(OPERATOR_NAME);
|
|
15
|
+
exports.LOGGING_NAMESPACE = (0, Common_1.createOperatorLoggingNamespace)(OPERATOR_NAME, Common_1.LOGGING_NAMESPACE_INTERNAL);
|
|
15
16
|
/**
|
|
16
17
|
* Ensures all input nodes have their children determined.
|
|
17
18
|
*
|
|
@@ -30,5 +31,4 @@ function createDetermineChildrenOperator(hasNodes) {
|
|
|
30
31
|
}), (0, LoggingUtils_1.log)({ category: exports.LOGGING_NAMESPACE, message: /* istanbul ignore next */ (n) => `out: ${(0, Common_1.createNodeIdentifierForLogging)(n)}` }));
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
|
-
exports.createDetermineChildrenOperator = createDetermineChildrenOperator;
|
|
34
34
|
//# sourceMappingURL=DetermineChildren.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetermineChildren.js","sourceRoot":"","sources":["../../../../../src/hierarchies/internal/operators/DetermineChildren.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;
|
|
1
|
+
{"version":3,"file":"DetermineChildren.js","sourceRoot":"","sources":["../../../../../src/hierarchies/internal/operators/DetermineChildren.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAiBhG,0EAoBC;AAnCD,+BAAsD;AAEtD,sCAAuH;AACvH,kDAAsC;AACtC,2DAAoE;AAEpE,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAC1C,gBAAgB;AACH,QAAA,iBAAiB,GAAG,IAAA,uCAA8B,EAAC,aAAa,EAAE,mCAA0B,CAAC,CAAC;AAE3G;;;;GAIG;AACH,SAAgB,+BAA+B,CAAC,QAA+D;IAC7G,OAAO,UAAU,KAAyC;QACxD,OAAO,KAAK,CAAC,IAAI,CACf,IAAA,kBAAG,EAAC,EAAE,QAAQ,EAAE,yBAAiB,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,IAAA,uCAA8B,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAC3H,IAAA,iDAA6B,EAAC,GAAG,CAAC,EAClC,IAAA,gBAAS,EAAC,CAAC,CAAyB,EAAsC,EAAE;YAC1E,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC7B,OAAO,IAAA,SAAE,EAAC,CAAC,CAAC,CAAC;YACf,CAAC;YACD,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CACrB,IAAA,kBAAG,EAAC;gBACF,QAAQ,EAAE,yBAAiB;gBAC3B,OAAO,EAAE,0BAA0B,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,GAAG,IAAA,uCAA8B,EAAC,CAAC,CAAC,0BAA0B,eAAe,EAAE;aACzI,CAAC,EACF,IAAA,UAAG,EAAC,CAAC,eAAe,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC,CAC1E,CAAC;QACJ,CAAC,CAAC,EACF,IAAA,kBAAG,EAAC,EAAE,QAAQ,EAAE,yBAAiB,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,IAAA,uCAA8B,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAC7H,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { concatMap, map, Observable, of } from \"rxjs\";\nimport { ProcessedHierarchyNode } from \"../../HierarchyNode\";\nimport { createNodeIdentifierForLogging, createOperatorLoggingNamespace, LOGGING_NAMESPACE_INTERNAL } from \"../Common\";\nimport { log } from \"../LoggingUtils\";\nimport { releaseMainThreadOnItemsCount } from \"./ReleaseMainThread\";\n\nconst OPERATOR_NAME = \"DetermineChildren\";\n/** @internal */\nexport const LOGGING_NAMESPACE = createOperatorLoggingNamespace(OPERATOR_NAME, LOGGING_NAMESPACE_INTERNAL);\n\n/**\n * Ensures all input nodes have their children determined.\n *\n * @internal\n */\nexport function createDetermineChildrenOperator(hasNodes: (node: ProcessedHierarchyNode) => Observable<boolean>) {\n return function (nodes: Observable<ProcessedHierarchyNode>): Observable<ProcessedHierarchyNode> {\n return nodes.pipe(\n log({ category: LOGGING_NAMESPACE, message: /* istanbul ignore next */ (n) => `in: ${createNodeIdentifierForLogging(n)}` }),\n releaseMainThreadOnItemsCount(200),\n concatMap((n: ProcessedHierarchyNode): Observable<ProcessedHierarchyNode> => {\n if (n.children !== undefined) {\n return of(n);\n }\n return hasNodes(n).pipe(\n log({\n category: LOGGING_NAMESPACE,\n message: /* istanbul ignore next */ (hasChildrenFlag) => `${createNodeIdentifierForLogging(n)}: determined children: ${hasChildrenFlag}`,\n }),\n map((hasChildrenFlag) => Object.assign(n, { children: hasChildrenFlag })),\n );\n }),\n log({ category: LOGGING_NAMESPACE, message: /* istanbul ignore next */ (n) => `out: ${createNodeIdentifierForLogging(n)}` }),\n );\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grouping.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/internal/operators/Grouping.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuF,UAAU,EAA4B,MAAM,MAAM,CAAC;AAEjJ,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACnH,OAAO,EAEL,mBAAmB,EACnB,8BAA8B,EAC9B,sBAAsB,EACtB,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Grouping.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/internal/operators/Grouping.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuF,UAAU,EAA4B,MAAM,MAAM,CAAC;AAEjJ,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACnH,OAAO,EAEL,mBAAmB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