@itwin/presentation-hierarchies 2.0.0-alpha.5 → 2.0.0-alpha.7
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 +62 -0
- package/README.md +3 -3
- package/lib/cjs/hierarchies/HierarchyMerge.d.ts +19 -0
- package/lib/cjs/hierarchies/HierarchyMerge.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyMerge.js +43 -0
- package/lib/cjs/hierarchies/HierarchyMerge.js.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +14 -24
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js +1 -21
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js +8 -8
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +11 -29
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js +0 -37
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchySearch.d.ts +167 -0
- package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchySearch.js +261 -0
- package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -0
- package/lib/cjs/hierarchies/imodel/HierarchyCache.js +3 -3
- package/lib/cjs/hierarchies/imodel/HierarchyCache.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +46 -11
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +155 -64
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/{FilteringHierarchyDefinition.d.ts → SearchHierarchyDefinition.d.ts} +12 -10
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
- package/lib/cjs/hierarchies/imodel/{FilteringHierarchyDefinition.js → SearchHierarchyDefinition.js} +88 -73
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +8 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.d.ts +3 -0
- package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.js +12 -1
- package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +2 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +4 -3
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js +7 -7
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyMerge.d.ts +19 -0
- package/lib/esm/hierarchies/HierarchyMerge.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyMerge.js +40 -0
- package/lib/esm/hierarchies/HierarchyMerge.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyNode.d.ts +14 -24
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js +0 -20
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js +9 -9
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +11 -29
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js +1 -36
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.d.ts +167 -0
- package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchySearch.js +256 -0
- package/lib/esm/hierarchies/HierarchySearch.js.map +1 -0
- package/lib/esm/hierarchies/imodel/HierarchyCache.js +3 -3
- package/lib/esm/hierarchies/imodel/HierarchyCache.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +46 -11
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +157 -67
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/{FilteringHierarchyDefinition.d.ts → SearchHierarchyDefinition.d.ts} +12 -10
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
- package/lib/esm/hierarchies/imodel/{FilteringHierarchyDefinition.js → SearchHierarchyDefinition.js} +86 -71
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js +8 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/esm/hierarchies/internal/Common.d.ts +3 -0
- package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/Common.js +11 -1
- package/lib/esm/hierarchies/internal/Common.js.map +1 -1
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +3 -2
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +4 -3
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +3 -3
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +7 -7
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +0 -136
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +0 -1
- package/lib/cjs/hierarchies/HierarchyFiltering.js +0 -249
- package/lib/cjs/hierarchies/HierarchyFiltering.js.map +0 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts +0 -136
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +0 -1
- package/lib/esm/hierarchies/HierarchyFiltering.js +0 -244
- package/lib/esm/hierarchies/HierarchyFiltering.js.map +0 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
package/lib/esm/hierarchies/imodel/{FilteringHierarchyDefinition.js → SearchHierarchyDefinition.js}
RENAMED
|
@@ -2,32 +2,35 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { defer, filter,
|
|
6
|
-
import { createHierarchyFilteringHelper } from "../HierarchyFiltering.js";
|
|
5
|
+
import { defaultIfEmpty, defer, filter, firstValueFrom, map, merge, mergeAll, mergeMap, of, take, toArray } from "rxjs";
|
|
7
6
|
import { HierarchyNodeIdentifier } from "../HierarchyNodeIdentifier.js";
|
|
8
7
|
import { HierarchyNodeKey } from "../HierarchyNodeKey.js";
|
|
8
|
+
import { createHierarchySearchHelper, HierarchySearchPath, shouldAutoExpandBasedOnReveal } from "../HierarchySearch.js";
|
|
9
9
|
import { HierarchyNodesDefinition, } from "../imodel/IModelHierarchyDefinition.js";
|
|
10
10
|
import { ProcessedHierarchyNode } from "../imodel/IModelHierarchyNode.js";
|
|
11
11
|
import { NodeSelectClauseColumnNames } from "../imodel/NodeSelectQueryFactory.js";
|
|
12
12
|
import { defaultNodesParser } from "../imodel/TreeNodesReader.js";
|
|
13
|
+
import { fromPossiblyPromise } from "../internal/Common.js";
|
|
13
14
|
import { partition } from "../internal/operators/Partition.js";
|
|
14
15
|
/** @internal */
|
|
15
|
-
export class
|
|
16
|
+
export class SearchHierarchyDefinition {
|
|
16
17
|
_imodelAccess;
|
|
17
18
|
_source;
|
|
18
|
-
|
|
19
|
+
_targetPaths;
|
|
19
20
|
_nodesParser;
|
|
21
|
+
#sourceName;
|
|
20
22
|
constructor(props) {
|
|
21
23
|
this._imodelAccess = props.imodelAccess;
|
|
22
24
|
this._source = props.source;
|
|
23
|
-
this
|
|
25
|
+
this.#sourceName = props.sourceName;
|
|
26
|
+
this._targetPaths = props.targetPaths;
|
|
24
27
|
this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => of(defaultNodesParser(row)));
|
|
25
28
|
}
|
|
26
29
|
get preProcessNode() {
|
|
27
30
|
return (node) => {
|
|
28
31
|
return (this._source.preProcessNode ? this._source.preProcessNode(node) : of(node)).pipe(filter((processedNode) => {
|
|
29
|
-
if (processedNode.processingParams?.hideInHierarchy && processedNode.
|
|
30
|
-
// we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another
|
|
32
|
+
if (processedNode.processingParams?.hideInHierarchy && processedNode.search?.isSearchTarget && !processedNode.search.hasSearchTargetAncestor) {
|
|
33
|
+
// we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another search target
|
|
31
34
|
return false;
|
|
32
35
|
}
|
|
33
36
|
return true;
|
|
@@ -37,8 +40,21 @@ export class FilteringHierarchyDefinition {
|
|
|
37
40
|
get postProcessNode() {
|
|
38
41
|
return (node) => {
|
|
39
42
|
return (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(map((processedNode) => {
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
const parentKeysWithoutGroupingNodesLength = processedNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;
|
|
44
|
+
const parentKeysLength = processedNode.parentKeys.length;
|
|
45
|
+
const shouldAutoExpand = ProcessedHierarchyNode.isGroupingNode(processedNode)
|
|
46
|
+
? shouldAutoExpandGroupingNodeBasedOnNestedChildren({
|
|
47
|
+
directOrIndirectChildren: processedNode.children,
|
|
48
|
+
parentKeysWithoutGroupingNodesLength,
|
|
49
|
+
parentKeysLength,
|
|
50
|
+
})
|
|
51
|
+
: (processedNode.search?.isSearchTarget && !!processedNode.search.searchTargetOptions?.autoExpand) ||
|
|
52
|
+
processedNode.search?.childrenTargetPaths?.some((path) => shouldAutoExpandBasedOnReveal({
|
|
53
|
+
reveal: HierarchySearchPath.normalize(path).options?.reveal,
|
|
54
|
+
nodePositionInPath: parentKeysWithoutGroupingNodesLength,
|
|
55
|
+
nodePositionInHierarchy: parentKeysLength,
|
|
56
|
+
}));
|
|
57
|
+
if (shouldAutoExpand) {
|
|
42
58
|
Object.assign(processedNode, { autoExpand: true });
|
|
43
59
|
}
|
|
44
60
|
return processedNode;
|
|
@@ -48,13 +64,13 @@ export class FilteringHierarchyDefinition {
|
|
|
48
64
|
get parseNode() {
|
|
49
65
|
return (row, parentNode) => {
|
|
50
66
|
return this._nodesParser(row).pipe(mergeMap((parsedNode) => {
|
|
51
|
-
if (!row[
|
|
67
|
+
if (!row[ECSQL_COLUMN_NAME_SearchECInstanceId] || !row[ECSQL_COLUMN_NAME_SearchClassName]) {
|
|
52
68
|
return of(parsedNode);
|
|
53
69
|
}
|
|
54
|
-
const rowInstanceKey = { className: row[
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
70
|
+
const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_SearchClassName], id: row[ECSQL_COLUMN_NAME_SearchECInstanceId] };
|
|
71
|
+
const searchHelper = createHierarchySearchHelper(this._targetPaths, parentNode);
|
|
72
|
+
const nodeSearchPropPossiblyPromise = searchHelper.createChildNodeProps({
|
|
73
|
+
asyncPathMatcher: (identifier) => {
|
|
58
74
|
if (identifier.id !== rowInstanceKey.id) {
|
|
59
75
|
return false;
|
|
60
76
|
}
|
|
@@ -67,18 +83,12 @@ export class FilteringHierarchyDefinition {
|
|
|
67
83
|
if (identifier.className === rowInstanceKey.className) {
|
|
68
84
|
return true;
|
|
69
85
|
}
|
|
70
|
-
return
|
|
71
|
-
this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className),
|
|
72
|
-
this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className),
|
|
73
|
-
]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo);
|
|
86
|
+
return firstValueFrom(merge(fromPossiblyPromise(this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className)), fromPossiblyPromise(this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className))).pipe(filter((classDerives) => classDerives), defaultIfEmpty(false), take(1)));
|
|
74
87
|
},
|
|
75
88
|
});
|
|
76
|
-
return (
|
|
77
|
-
if (nodeExtraProps?.
|
|
78
|
-
parsedNode.
|
|
79
|
-
}
|
|
80
|
-
if (nodeExtraProps?.filtering) {
|
|
81
|
-
parsedNode.filtering = nodeExtraProps.filtering;
|
|
89
|
+
return fromPossiblyPromise(nodeSearchPropPossiblyPromise).pipe(map((nodeExtraProps) => {
|
|
90
|
+
if (nodeExtraProps?.search) {
|
|
91
|
+
parsedNode.search = nodeExtraProps.search;
|
|
82
92
|
}
|
|
83
93
|
return parsedNode;
|
|
84
94
|
}));
|
|
@@ -87,29 +97,29 @@ export class FilteringHierarchyDefinition {
|
|
|
87
97
|
}
|
|
88
98
|
defineHierarchyLevel(props) {
|
|
89
99
|
const sourceDefinitions = this._source.defineHierarchyLevel(props);
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
100
|
+
const searchHelper = createHierarchySearchHelper(this._targetPaths, props.parentNode);
|
|
101
|
+
const childNodeSearchIdentifiers = searchHelper.getChildNodeSearchIdentifiers();
|
|
102
|
+
if (!childNodeSearchIdentifiers) {
|
|
93
103
|
return sourceDefinitions;
|
|
94
104
|
}
|
|
95
105
|
const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions.pipe(mergeAll()), HierarchyNodesDefinition.isGenericNode);
|
|
96
106
|
return merge(genericNodeDefinitions.pipe(map((definition) => {
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
(!identifier.source || identifier.source === this
|
|
107
|
+
if (searchHelper.hasSearchTargetAncestor ||
|
|
108
|
+
childNodeSearchIdentifiers.some((identifier) => HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&
|
|
109
|
+
(!identifier.source || identifier.source === this.#sourceName) &&
|
|
100
110
|
identifier.id === definition.node.key)) {
|
|
101
111
|
return {
|
|
102
112
|
...definition,
|
|
103
113
|
node: {
|
|
104
114
|
...definition.node,
|
|
105
|
-
...
|
|
115
|
+
...searchHelper.createChildNodeProps({ pathMatcher: ({ id }) => id === definition.node.key }),
|
|
106
116
|
},
|
|
107
117
|
};
|
|
108
118
|
}
|
|
109
119
|
return undefined;
|
|
110
120
|
}), filter((def) => !!def)), instanceNodeDefinitions.pipe(mergeMap((definition) => {
|
|
111
|
-
if (
|
|
112
|
-
// if we have a
|
|
121
|
+
if (searchHelper.hasSearchTargetAncestor) {
|
|
122
|
+
// if we have a search target ancestor, we don't need to search the definitions - we use all of them
|
|
113
123
|
return of(applyECInstanceIdsSelector(definition));
|
|
114
124
|
}
|
|
115
125
|
return defer(async () => {
|
|
@@ -135,7 +145,7 @@ export class FilteringHierarchyDefinition {
|
|
|
135
145
|
}
|
|
136
146
|
return entries;
|
|
137
147
|
}
|
|
138
|
-
for (const id of
|
|
148
|
+
for (const id of childNodeSearchIdentifiers) {
|
|
139
149
|
// take only identifiers that match the definition by type, source and class
|
|
140
150
|
if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {
|
|
141
151
|
continue;
|
|
@@ -159,20 +169,20 @@ export class FilteringHierarchyDefinition {
|
|
|
159
169
|
}).pipe(
|
|
160
170
|
// only take definitions that have matching path identifiers
|
|
161
171
|
filter((pathIdentifiers) => pathIdentifiers.length > 0),
|
|
162
|
-
// for each definition that we're going to use, apply query-level
|
|
163
|
-
map((pathIdentifiers) =>
|
|
172
|
+
// for each definition that we're going to use, apply query-level search
|
|
173
|
+
map((pathIdentifiers) => applyECInstanceIdsSearch(definition, pathIdentifiers)));
|
|
164
174
|
}))).pipe(toArray());
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
177
|
/** @internal */
|
|
168
178
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
169
|
-
export const
|
|
179
|
+
export const ECSQL_COLUMN_NAME_SearchECInstanceId = "SearchECInstanceId";
|
|
170
180
|
/** @internal */
|
|
171
181
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
172
|
-
export const
|
|
173
|
-
function getClassECInstanceIds(
|
|
182
|
+
export const ECSQL_COLUMN_NAME_SearchClassName = "SearchClassName";
|
|
183
|
+
function getClassECInstanceIds(targetInstanceKeys) {
|
|
174
184
|
const classNameECInstanceIds = new Map();
|
|
175
|
-
for (const key of
|
|
185
|
+
for (const key of targetInstanceKeys) {
|
|
176
186
|
const entry = classNameECInstanceIds.get(key.className);
|
|
177
187
|
if (entry === undefined) {
|
|
178
188
|
classNameECInstanceIds.set(key.className, [key.id]);
|
|
@@ -183,18 +193,18 @@ function getClassECInstanceIds(filteredInstanceKeys) {
|
|
|
183
193
|
return classNameECInstanceIds;
|
|
184
194
|
}
|
|
185
195
|
/** @internal */
|
|
186
|
-
export function
|
|
187
|
-
const instanceIdsByClass = getClassECInstanceIds(
|
|
196
|
+
export function applyECInstanceIdsSearch(def, targetInstanceKeys) {
|
|
197
|
+
const instanceIdsByClass = getClassECInstanceIds(targetInstanceKeys);
|
|
188
198
|
return {
|
|
189
199
|
...def,
|
|
190
200
|
query: {
|
|
191
201
|
...def.query,
|
|
192
202
|
ctes: [
|
|
193
203
|
...(def.query.ctes ?? []),
|
|
194
|
-
`
|
|
204
|
+
`SearchInfo(ECInstanceId, SearchClassName) AS (
|
|
195
205
|
${Array.from(instanceIdsByClass)
|
|
196
206
|
.map(([className, ecInstanceIds]) => `
|
|
197
|
-
SELECT ECInstanceId, '${className}' AS
|
|
207
|
+
SELECT ECInstanceId, '${className}' AS SearchClassName
|
|
198
208
|
FROM ${className}
|
|
199
209
|
WHERE ECInstanceId IN (${ecInstanceIds.join(", ")})
|
|
200
210
|
`)
|
|
@@ -204,12 +214,12 @@ export function applyECInstanceIdsFilter(def, filteredInstanceKeys) {
|
|
|
204
214
|
ecsql: `
|
|
205
215
|
SELECT
|
|
206
216
|
[q].*,
|
|
207
|
-
IdToHex([f].[ECInstanceId]) AS [${
|
|
208
|
-
[f].[
|
|
217
|
+
IdToHex([f].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_SearchECInstanceId}],
|
|
218
|
+
[f].[SearchClassName] AS [${ECSQL_COLUMN_NAME_SearchClassName}]
|
|
209
219
|
FROM (
|
|
210
220
|
${def.query.ecsql}
|
|
211
221
|
) [q]
|
|
212
|
-
JOIN
|
|
222
|
+
JOIN SearchInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]
|
|
213
223
|
`,
|
|
214
224
|
},
|
|
215
225
|
};
|
|
@@ -223,46 +233,51 @@ export function applyECInstanceIdsSelector(def) {
|
|
|
223
233
|
ecsql: `
|
|
224
234
|
SELECT
|
|
225
235
|
[q].*,
|
|
226
|
-
IdToHex([q].[ECInstanceId]) AS [${
|
|
227
|
-
[q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${
|
|
236
|
+
IdToHex([q].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_SearchECInstanceId}],
|
|
237
|
+
[q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${ECSQL_COLUMN_NAME_SearchClassName}]
|
|
228
238
|
FROM (${def.query.ecsql}) [q]
|
|
229
239
|
`,
|
|
230
240
|
},
|
|
231
241
|
};
|
|
232
242
|
}
|
|
233
|
-
function
|
|
234
|
-
const
|
|
235
|
-
|
|
243
|
+
function shouldAutoExpandGroupingNodeBasedOnNestedChildren({ directOrIndirectChildren, parentKeysLength, parentKeysWithoutGroupingNodesLength, }) {
|
|
244
|
+
for (const child of directOrIndirectChildren) {
|
|
245
|
+
if (ProcessedHierarchyNode.isGroupingNode(child)) {
|
|
246
|
+
// Need to check if the same grouping node needs to be expanded, but check the indirect children instead
|
|
247
|
+
if (shouldAutoExpandGroupingNodeBasedOnNestedChildren({ directOrIndirectChildren: child.children, parentKeysLength, parentKeysWithoutGroupingNodesLength })) {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
236
252
|
/* c8 ignore next 3 */
|
|
237
|
-
if (!child.
|
|
253
|
+
if (!child.search) {
|
|
238
254
|
continue;
|
|
239
255
|
}
|
|
240
|
-
if (child.
|
|
241
|
-
|
|
256
|
+
if (child.search.isSearchTarget &&
|
|
257
|
+
shouldAutoExpandBasedOnReveal({
|
|
258
|
+
reveal: child.search.searchTargetOptions?.reveal,
|
|
259
|
+
nodePositionInHierarchy: parentKeysLength,
|
|
260
|
+
// Grouping node is not in search path, but we can assume that it is at the position of 1 less than `parentKeysWithoutGroupingNodesLength`
|
|
261
|
+
nodePositionInPath: parentKeysWithoutGroupingNodesLength - 1,
|
|
262
|
+
})) {
|
|
242
263
|
return true;
|
|
243
264
|
}
|
|
244
|
-
if (!child.
|
|
265
|
+
if (!child.search.childrenTargetPaths) {
|
|
245
266
|
/* c8 ignore next */
|
|
246
267
|
continue;
|
|
247
268
|
}
|
|
248
|
-
for (const path of child.
|
|
249
|
-
if ("path" in path &&
|
|
269
|
+
for (const path of child.search.childrenTargetPaths) {
|
|
270
|
+
if ("path" in path &&
|
|
271
|
+
shouldAutoExpandBasedOnReveal({
|
|
272
|
+
reveal: path.options?.reveal,
|
|
273
|
+
nodePositionInHierarchy: parentKeysLength,
|
|
274
|
+
// Grouping node is not in search path, but we can assume that it is at the position of 1 less than `parentKeysWithoutGroupingNodesLength`
|
|
275
|
+
nodePositionInPath: parentKeysWithoutGroupingNodesLength - 1,
|
|
276
|
+
})) {
|
|
250
277
|
return true;
|
|
251
278
|
}
|
|
252
279
|
}
|
|
253
280
|
}
|
|
254
281
|
return false;
|
|
255
282
|
}
|
|
256
|
-
|
|
257
|
-
if (!autoExpand) {
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
if (autoExpand === true) {
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
// auto-expand should be set to true only if parentKeys length is smaller than depth.
|
|
264
|
-
const nodeDepth = "depthInHierarchy" in autoExpand ? numberOfParentNodes : numberOfNonGroupingParentNodes;
|
|
265
|
-
const filterTargetDepth = "depthInPath" in autoExpand ? autoExpand.depthInPath : autoExpand.depthInHierarchy;
|
|
266
|
-
return nodeDepth < filterTargetDepth;
|
|
267
|
-
}
|
|
268
|
-
//# sourceMappingURL=FilteringHierarchyDefinition.js.map
|
|
283
|
+
//# sourceMappingURL=SearchHierarchyDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/SearchHierarchyDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAc,EAAE,EAAE,IAAI,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AM;oBAC5B,uBAAuB,EAAE,gBAAgB;oBACzC,0IAA0I;oBAC1I,kBAAkB,EAAE,oCAAoC,GAAG,CAAC;iBAC7D,CAAC,EACF,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 { defaultIfEmpty, defer, filter, firstValueFrom, map, merge, mergeAll, mergeMap, Observable, of, take, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey, IModelInstanceKey } from \"../HierarchyNodeKey.js\";\nimport { createHierarchySearchHelper, HierarchySearchPath, shouldAutoExpandBasedOnReveal } from \"../HierarchySearch.js\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n} from \"../imodel/IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode } from \"../imodel/IModelHierarchyNode.js\";\nimport { NodeSelectClauseColumnNames } from \"../imodel/NodeSelectQueryFactory.js\";\nimport { defaultNodesParser } from \"../imodel/TreeNodesReader.js\";\nimport { fromPossiblyPromise } from \"../internal/Common.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport { RxjsHierarchyDefinition, RxjsNodeParser, RxjsNodePostProcessor, RxjsNodePreProcessor } from \"../internal/RxjsHierarchyDefinition.js\";\n\ninterface SearchHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n source: RxjsHierarchyDefinition;\n sourceName: string;\n targetPaths: HierarchySearchPath[];\n nodesParser?: RxjsNodeParser;\n}\n\n/** @internal */\nexport class SearchHierarchyDefinition implements RxjsHierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n private _source: RxjsHierarchyDefinition;\n private _targetPaths: HierarchySearchPath[];\n private _nodesParser: RxjsNodeParser;\n #sourceName: string;\n\n public constructor(props: SearchHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this.#sourceName = props.sourceName;\n this._targetPaths = props.targetPaths;\n this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => of(defaultNodesParser(row)));\n }\n\n public get preProcessNode(): RxjsNodePreProcessor {\n return (node) => {\n return (this._source.preProcessNode ? this._source.preProcessNode(node) : of(node)).pipe(\n filter((processedNode) => {\n if (processedNode.processingParams?.hideInHierarchy && processedNode.search?.isSearchTarget && !processedNode.search.hasSearchTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another search target\n return false;\n }\n return true;\n }),\n );\n };\n }\n\n public get postProcessNode(): RxjsNodePostProcessor {\n return (node) => {\n return (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(\n map((processedNode) => {\n const parentKeysWithoutGroupingNodesLength = processedNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n const parentKeysLength = processedNode.parentKeys.length;\n const shouldAutoExpand = ProcessedHierarchyNode.isGroupingNode(processedNode)\n ? shouldAutoExpandGroupingNodeBasedOnNestedChildren({\n directOrIndirectChildren: processedNode.children,\n parentKeysWithoutGroupingNodesLength,\n parentKeysLength,\n })\n : (processedNode.search?.isSearchTarget && !!processedNode.search.searchTargetOptions?.autoExpand) ||\n processedNode.search?.childrenTargetPaths?.some((path) =>\n shouldAutoExpandBasedOnReveal({\n reveal: HierarchySearchPath.normalize(path).options?.reveal,\n nodePositionInPath: parentKeysWithoutGroupingNodesLength,\n nodePositionInHierarchy: parentKeysLength,\n }),\n );\n if (shouldAutoExpand) {\n Object.assign(processedNode, { autoExpand: true });\n }\n\n return processedNode;\n }),\n );\n };\n }\n\n public get parseNode(): RxjsNodeParser {\n return (row, parentNode) => {\n return this._nodesParser(row).pipe(\n mergeMap((parsedNode) => {\n if (!row[ECSQL_COLUMN_NAME_SearchECInstanceId] || !row[ECSQL_COLUMN_NAME_SearchClassName]) {\n return of(parsedNode);\n }\n const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_SearchClassName], id: row[ECSQL_COLUMN_NAME_SearchECInstanceId] };\n const searchHelper = createHierarchySearchHelper(this._targetPaths, parentNode);\n const nodeSearchPropPossiblyPromise = searchHelper.createChildNodeProps({\n asyncPathMatcher: (identifier): boolean | Promise<boolean> => {\n if (identifier.id !== rowInstanceKey.id) {\n return false;\n }\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {\n return false;\n }\n if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {\n return false;\n }\n if (identifier.className === rowInstanceKey.className) {\n return true;\n }\n return firstValueFrom(\n merge(\n fromPossiblyPromise(this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className)),\n fromPossiblyPromise(this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className)),\n ).pipe(\n filter((classDerives) => classDerives),\n defaultIfEmpty(false),\n take(1),\n ),\n );\n },\n });\n return fromPossiblyPromise(nodeSearchPropPossiblyPromise).pipe(\n map((nodeExtraProps) => {\n if (nodeExtraProps?.search) {\n parsedNode.search = nodeExtraProps.search;\n }\n return parsedNode;\n }),\n );\n }),\n );\n };\n }\n\n public defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition> {\n const sourceDefinitions = this._source.defineHierarchyLevel(props);\n\n const searchHelper = createHierarchySearchHelper(this._targetPaths, props.parentNode);\n const childNodeSearchIdentifiers = searchHelper.getChildNodeSearchIdentifiers();\n if (!childNodeSearchIdentifiers) {\n return sourceDefinitions;\n }\n\n const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions.pipe(mergeAll()), HierarchyNodesDefinition.isGenericNode);\n return merge(\n genericNodeDefinitions.pipe(\n map((definition) => {\n if (\n searchHelper.hasSearchTargetAncestor ||\n childNodeSearchIdentifiers.some(\n (identifier) =>\n HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&\n (!identifier.source || identifier.source === this.#sourceName) &&\n identifier.id === definition.node.key,\n )\n ) {\n return {\n ...definition,\n node: {\n ...definition.node,\n ...searchHelper.createChildNodeProps({ pathMatcher: ({ id }) => id === definition.node.key }),\n },\n };\n }\n return undefined;\n }),\n filter((def): def is GenericHierarchyNodeDefinition => !!def),\n ),\n\n instanceNodeDefinitions.pipe(\n mergeMap((definition) => {\n if (searchHelper.hasSearchTargetAncestor) {\n // if we have a search target ancestor, we don't need to search the definitions - we use all of them\n return of(applyECInstanceIdsSelector(definition));\n }\n return defer(async () => {\n const imodelAccess = this._imodelAccess;\n const matches = new Map<Id64String, IModelInstanceKey[]>();\n async function getEntries(x: IModelInstanceKey) {\n let entries = matches.get(x.id);\n if (!entries) {\n entries = [];\n matches.set(x.id, entries);\n }\n // make sure that we don't have path identifiers that only differ by class name, where\n // class names are in the same class hierarchy, e.g.:\n // [{ className: \"bis.Element\", id: \"0x1\" }, { className: \"bis.Subject\", id: \"0x1\" }]\n // are actually the same instance, so we only need to keep one of them, or otherwise the query will\n // duplicate it\n for (const entry of entries) {\n if (\n entry.className === x.className ||\n (await imodelAccess.classDerivesFrom(entry.className, x.className)) ||\n (await imodelAccess.classDerivesFrom(x.className, entry.className))\n ) {\n return undefined;\n }\n }\n return entries;\n }\n for (const id of childNodeSearchIdentifiers) {\n // take only identifiers that match the definition by type, source and class\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n continue;\n }\n if (id.imodelKey && id.imodelKey !== imodelAccess.imodelKey) {\n continue;\n }\n if (\n id.className !== definition.fullClassName &&\n !(await Promise.all([\n imodelAccess.classDerivesFrom(id.className, definition.fullClassName),\n imodelAccess.classDerivesFrom(definition.fullClassName, id.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo))\n ) {\n continue;\n }\n const entriesTargetForPathIdentifier = await getEntries(id);\n if (entriesTargetForPathIdentifier) {\n entriesTargetForPathIdentifier.push(id);\n }\n }\n return Array.from(matches.values()).flat();\n }).pipe(\n // only take definitions that have matching path identifiers\n filter((pathIdentifiers) => pathIdentifiers.length > 0),\n\n // for each definition that we're going to use, apply query-level search\n map((pathIdentifiers) => applyECInstanceIdsSearch(definition, pathIdentifiers)),\n );\n }),\n ),\n ).pipe(toArray());\n }\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_SearchECInstanceId = \"SearchECInstanceId\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_SearchClassName = \"SearchClassName\";\n\nfunction getClassECInstanceIds(targetInstanceKeys: InstanceKey[]) {\n const classNameECInstanceIds = new Map<string, Id64String[]>();\n for (const key of targetInstanceKeys) {\n const entry = classNameECInstanceIds.get(key.className);\n if (entry === undefined) {\n classNameECInstanceIds.set(key.className, [key.id]);\n continue;\n }\n entry.push(key.id);\n }\n return classNameECInstanceIds;\n}\n\n/** @internal */\nexport function applyECInstanceIdsSearch(def: InstanceNodesQueryDefinition, targetInstanceKeys: InstanceKey[]): InstanceNodesQueryDefinition {\n const instanceIdsByClass = getClassECInstanceIds(targetInstanceKeys);\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n `SearchInfo(ECInstanceId, SearchClassName) AS (\n ${Array.from(instanceIdsByClass)\n .map(\n ([className, ecInstanceIds]) => `\n SELECT ECInstanceId, '${className}' AS SearchClassName\n FROM ${className}\n WHERE ECInstanceId IN (${ecInstanceIds.join(\", \")})\n `,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n IdToHex([f].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_SearchECInstanceId}],\n [f].[SearchClassName] AS [${ECSQL_COLUMN_NAME_SearchClassName}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n JOIN SearchInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n\n/** @internal */\nexport function applyECInstanceIdsSelector(def: InstanceNodesQueryDefinition): InstanceNodesQueryDefinition {\n return {\n ...def,\n query: {\n ...def.query,\n ecsql: `\n SELECT\n [q].*,\n IdToHex([q].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_SearchECInstanceId}],\n [q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${ECSQL_COLUMN_NAME_SearchClassName}]\n FROM (${def.query.ecsql}) [q]\n `,\n },\n };\n}\n\nfunction shouldAutoExpandGroupingNodeBasedOnNestedChildren({\n directOrIndirectChildren,\n parentKeysLength,\n parentKeysWithoutGroupingNodesLength,\n}: {\n directOrIndirectChildren: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n parentKeysLength: number;\n parentKeysWithoutGroupingNodesLength: number;\n}) {\n for (const child of directOrIndirectChildren) {\n if (ProcessedHierarchyNode.isGroupingNode(child)) {\n // Need to check if the same grouping node needs to be expanded, but check the indirect children instead\n if (\n shouldAutoExpandGroupingNodeBasedOnNestedChildren({ directOrIndirectChildren: child.children, parentKeysLength, parentKeysWithoutGroupingNodesLength })\n ) {\n return true;\n }\n continue;\n }\n\n /* c8 ignore next 3 */\n if (!child.search) {\n continue;\n }\n\n if (\n child.search.isSearchTarget &&\n shouldAutoExpandBasedOnReveal({\n reveal: child.search.searchTargetOptions?.reveal,\n nodePositionInHierarchy: parentKeysLength,\n // Grouping node is not in search path, but we can assume that it is at the position of 1 less than `parentKeysWithoutGroupingNodesLength`\n nodePositionInPath: parentKeysWithoutGroupingNodesLength - 1,\n })\n ) {\n return true;\n }\n\n if (!child.search.childrenTargetPaths) {\n /* c8 ignore next */\n continue;\n }\n\n for (const path of child.search.childrenTargetPaths) {\n if (\n \"path\" in path &&\n shouldAutoExpandBasedOnReveal({\n reveal: path.options?.reveal,\n nodePositionInHierarchy: parentKeysLength,\n // Grouping node is not in search path, but we can assume that it is at the position of 1 less than `parentKeysWithoutGroupingNodesLength`\n nodePositionInPath: parentKeysWithoutGroupingNodesLength - 1,\n })\n ) {\n return true;\n }\n }\n }\n return false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodesReader.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/TreeNodesReader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,UAAU,EAAM,MAAM,MAAM,CAAC;AACtD,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAsB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeNodesReader.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/TreeNodesReader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,UAAU,EAAM,MAAM,MAAM,CAAC;AACtD,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAsB,MAAM,4BAA4B,CAAC;AAG/E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAyC,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAI1E,UAAU,cAAc;IACtB,aAAa,EAAE,0BAA0B,CAAC;IAC1C,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC7B,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,gBAAgB;AAChB,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAAC,2BAA2B,CAAC,CAiBxF;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,CAAC,2BAA2B,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IACpD,CAAC,2BAA2B,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC;IACvD,CAAC,2BAA2B,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACnD,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC;IACpD,CAAC,2BAA2B,CAAC,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC;IACzD,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,CAAC,EAAE,OAAO,CAAC;IAC5D,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAChD,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC;IACpD,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC;IACnD,CAAC,2BAA2B,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC;CAC3D;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,GAAG,EAAE;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,2BAA2B,CAoBlG"}
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
import { from, mergeMap, of } from "rxjs";
|
|
6
6
|
import { Guid } from "@itwin/core-bentley";
|
|
7
7
|
import { parseInstanceLabel } from "@itwin/presentation-shared";
|
|
8
|
+
import { LOGGING_NAMESPACE_INTERNAL as BASE_LOGGING_NAMESPACE } from "../internal/Common.js";
|
|
9
|
+
import { log } from "../internal/LoggingUtils.js";
|
|
8
10
|
import { NodeSelectClauseColumnNames } from "./NodeSelectQueryFactory.js";
|
|
11
|
+
const LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.QueryRows`;
|
|
9
12
|
/** @internal */
|
|
10
13
|
export function readNodes(props) {
|
|
11
14
|
const { queryExecutor, query, limit } = props;
|
|
@@ -15,7 +18,11 @@ export function readNodes(props) {
|
|
|
15
18
|
restartToken: `readNodes/${Guid.createValue()}`,
|
|
16
19
|
...(limit !== undefined ? { limit } : undefined),
|
|
17
20
|
};
|
|
18
|
-
return from(queryExecutor.createQueryReader(query, config)).pipe(
|
|
21
|
+
return from(queryExecutor.createQueryReader(query, config)).pipe(log({
|
|
22
|
+
category: LOGGING_NAMESPACE,
|
|
23
|
+
severity: "trace",
|
|
24
|
+
message: /* c8 ignore next */ (row) => JSON.stringify(row),
|
|
25
|
+
}), mergeMap((row) => parser(row)));
|
|
19
26
|
}
|
|
20
27
|
/** @internal */
|
|
21
28
|
export function defaultNodesParser(row) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodesReader.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/TreeNodesReader.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAc,EAAE,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeNodesReader.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/TreeNodesReader.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAc,EAAE,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,0BAA0B,IAAI,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,E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AC,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, mergeMap, Observable, of } from \"rxjs\";\nimport { Guid, Id64String } from \"@itwin/core-bentley\";\nimport { ECSqlQueryDef, parseInstanceLabel } from \"@itwin/presentation-shared\";\nimport { LOGGING_NAMESPACE_INTERNAL as BASE_LOGGING_NAMESPACE } from \"../internal/Common.js\";\nimport { log } from \"../internal/LoggingUtils.js\";\nimport { RxjsNodeParser } from \"../internal/RxjsHierarchyDefinition.js\";\nimport { InstanceHierarchyNodeProcessingParams, SourceInstanceHierarchyNode } from \"./IModelHierarchyNode.js\";\nimport { LimitingECSqlQueryExecutor } from \"./LimitingECSqlQueryExecutor.js\";\nimport { NodeSelectClauseColumnNames } from \"./NodeSelectQueryFactory.js\";\n\nconst LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.QueryRows`;\n\ninterface ReadNodesProps {\n queryExecutor: LimitingECSqlQueryExecutor;\n query: ECSqlQueryDef;\n limit?: number | \"unbounded\";\n parser?: RxjsNodeParser;\n}\n\n/** @internal */\nexport function readNodes(props: ReadNodesProps): Observable<SourceInstanceHierarchyNode> {\n const { queryExecutor, query, limit } = props;\n const parser: RxjsNodeParser = props?.parser ?? ((row) => of(defaultNodesParser(row)));\n const config: Parameters<LimitingECSqlQueryExecutor[\"createQueryReader\"]>[1] = {\n rowFormat: \"ECSqlPropertyNames\",\n restartToken: `readNodes/${Guid.createValue()}`,\n ...(limit !== undefined ? { limit } : undefined),\n };\n\n return from(queryExecutor.createQueryReader(query, config)).pipe(\n log({\n category: LOGGING_NAMESPACE,\n severity: \"trace\",\n message: /* c8 ignore next */ (row) => JSON.stringify(row),\n }),\n mergeMap((row) => parser(row)),\n );\n}\n\n/**\n * The interface should contain a member for each `NodeSelectClauseColumnNames` value.\n * @internal\n */\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\n/** @internal */\nexport function defaultNodesParser(row: { [columnName: string]: any }): SourceInstanceHierarchyNode {\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 generic 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,4 +1,5 @@
|
|
|
1
1
|
import "./DisposePolyfill.js";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
2
3
|
import { ConcatenatedValue } from "@itwin/presentation-shared";
|
|
3
4
|
import { HierarchyNodeKey } from "../HierarchyNodeKey.js";
|
|
4
5
|
/**
|
|
@@ -55,4 +56,6 @@ export declare function safeDispose(disposable: {} | {
|
|
|
55
56
|
} | {
|
|
56
57
|
dispose: () => void;
|
|
57
58
|
}): void;
|
|
59
|
+
/** @internal */
|
|
60
|
+
export declare function fromPossiblyPromise<T>(possiblyPromise: T | Promise<T>): Observable<T>;
|
|
58
61
|
//# sourceMappingURL=Common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/Common.ts"],"names":[],"mappings":"AAKA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,6BAA6B,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,6BAA6B,yCAAqC,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,qCAAqC,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,iDAA8C,CAAC;AAElG,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC5C,YAAY,EAAE,MAAM,EACpB,YAAY,EACR,OAAO,iBAAiB,GACxB,OAAO,6BAA6B,GACpC,OAAO,0BAA0B,GACjC,OAAO,sCAAsC,UAGlD;AAED,gBAAgB;AAEhB,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAAC,GAAG,EAAE,gBAAgB,CAAC;IAAC,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAAE,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"Common.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/Common.ts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;IAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,QAMtG;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAErF"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import "./DisposePolyfill.js";
|
|
6
6
|
import naturalCompare from "natural-compare-lite";
|
|
7
|
+
import { from, of } from "rxjs";
|
|
7
8
|
/**
|
|
8
9
|
* This is a logging namespace for public log messages that may be interesting to consumers.
|
|
9
10
|
* @internal
|
|
@@ -38,7 +39,12 @@ export function createNodeIdentifierForLogging(node) {
|
|
|
38
39
|
}
|
|
39
40
|
const { label, key } = node;
|
|
40
41
|
const parentKeys = "parentKeys" in node ? node.parentKeys : "<unknown>";
|
|
41
|
-
|
|
42
|
+
const groupedInstanceKeys = "groupedInstanceKeys" in node && Array.isArray(node.groupedInstanceKeys)
|
|
43
|
+
? node.groupedInstanceKeys.length <= 3
|
|
44
|
+
? node.groupedInstanceKeys
|
|
45
|
+
: `<${node.groupedInstanceKeys.length} keys>`
|
|
46
|
+
: undefined;
|
|
47
|
+
return JSON.stringify({ label, key, parentKeys, groupedInstanceKeys });
|
|
42
48
|
}
|
|
43
49
|
/* c8 ignore end */
|
|
44
50
|
/** @internal */
|
|
@@ -66,4 +72,8 @@ export function safeDispose(disposable) {
|
|
|
66
72
|
disposable[Symbol.dispose]();
|
|
67
73
|
}
|
|
68
74
|
}
|
|
75
|
+
/** @internal */
|
|
76
|
+
export function fromPossiblyPromise(possiblyPromise) {
|
|
77
|
+
return possiblyPromise instanceof Promise ? from(possiblyPromise) : of(possiblyPromise);
|
|
78
|
+
}
|
|
69
79
|
//# sourceMappingURL=Common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/Common.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,sBAAsB,CAAC;AAE9B,OAAO,cAAc,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/Common.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,sBAAsB,CAAC;AAE9B,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAc,EAAE,EAAE,MAAM,MAAM,CAAC;AAI5C;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,iBAAiB,cAAc,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,kCAAkC,CAAC;AAE7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,0BAA0B,cAAc,CAAC;AAElG,gBAAgB;AAChB,MAAM,UAAU,8BAA8B,CAC5C,YAAoB,EACpB,YAIiD;IAEjD,OAAO,GAAG,YAAY,cAAc,YAAY,EAAE,CAAC;AACrD,CAAC;AAED,gBAAgB;AAChB,qBAAqB;AACrB,MAAM,UAAU,8BAA8B,CAC5C,IAA+G;IAE/G,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5B,MAAM,UAAU,GAAG,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;IACxE,MAAM,mBAAmB,GACvB,qBAAqB,IAAI,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IA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;AAC1F,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 \"./DisposePolyfill.js\";\n\nimport naturalCompare from \"natural-compare-lite\";\nimport { from, Observable, of } from \"rxjs\";\nimport { ConcatenatedValue } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeKey } from \"../HierarchyNodeKey.js\";\n\n/**\n * This is a logging namespace for public log messages that may be interesting to consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE = \"Presentation.Hierarchies\";\n\n/**\n * This is a logging namespace for public performance-related log messages that may be interesting to consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE_PERFORMANCE = `${LOGGING_NAMESPACE}.Performance`;\n\n/**\n * This is a logging namespace for internal log messages that are only interesting to package contributors,\n * but not the consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE_INTERNAL = \"Presentation.HierarchiesInternal\";\n\n/**\n * This is a logging namespace for internal performance-related log messages that are only interesting\n * to package contributors, but not the consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE_PERFORMANCE_INTERNAL = `${LOGGING_NAMESPACE_INTERNAL}.Performance`;\n\n/** @internal */\nexport function createOperatorLoggingNamespace(\n operatorName: string,\n baseCategory:\n | typeof LOGGING_NAMESPACE\n | typeof LOGGING_NAMESPACE_PERFORMANCE\n | typeof LOGGING_NAMESPACE_INTERNAL\n | typeof LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n) {\n return `${baseCategory}.Operators.${operatorName}`;\n}\n\n/** @internal */\n/* c8 ignore start */\nexport function createNodeIdentifierForLogging(\n node: { label: string | ConcatenatedValue; key: HierarchyNodeKey; parentKeys?: HierarchyNodeKey[] } | undefined,\n) {\n if (!node) {\n return \"<root>\";\n }\n const { label, key } = node;\n const parentKeys = \"parentKeys\" in node ? node.parentKeys : \"<unknown>\";\n const groupedInstanceKeys =\n \"groupedInstanceKeys\" in node && Array.isArray(node.groupedInstanceKeys)\n ? node.groupedInstanceKeys.length <= 3\n ? node.groupedInstanceKeys\n : `<${node.groupedInstanceKeys.length} keys>`\n : undefined;\n return JSON.stringify({ label, key, parentKeys, groupedInstanceKeys });\n}\n/* c8 ignore end */\n\n/** @internal */\nexport function hasChildren<TNode extends { children?: boolean | Array<unknown> }>(node: TNode) {\n return node.children === true || (Array.isArray(node.children) && node.children.length > 0);\n}\n\n/** @internal */\nexport function compareNodesByLabel<TLhsNode extends { label: string }, TRhsNode extends { label: string }>(lhs: TLhsNode, rhs: TRhsNode): number {\n return naturalCompare(lhs.label.toLocaleLowerCase(), rhs.label.toLocaleLowerCase());\n}\n\n/**\n * A helper that disposes the given object, if it's disposable.\n *\n * The first option is to dispose using the deprecated `dispose` method if it exists on the object.\n * If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is\n * considered as non-disposable and nothing is done with it.\n *\n * @internal\n */\nexport function safeDispose(disposable: {} | { [Symbol.dispose]: () => void } | { dispose: () => void }) {\n if (\"dispose\" in disposable) {\n disposable.dispose();\n } else if (Symbol.dispose in disposable) {\n disposable[Symbol.dispose]();\n }\n}\n\n/** @internal */\nexport function fromPossiblyPromise<T>(possiblyPromise: T | Promise<T>): Observable<T> {\n return possiblyPromise instanceof Promise ? from(possiblyPromise) : of(possiblyPromise);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RxjsHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/RxjsHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"RxjsHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/RxjsHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,UAAU,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAG1C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,UAAU,CAAC,EAAE,6BAA6B,KAAK,UAAU,CAAC,2BAA2B,CAAC,CAAC;AAEzJ;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,SAAS,6BAA6B,GAAG,8BAA8B,EAAE,IAAI,EAAE,KAAK,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC;AAEpJ;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,sBAAsB,KAAK,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAEzG;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAEtC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;IAExC,+EAA+E;IAC/E,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAC;CAC9F;AAED,gBAAgB;AAChB,wBAAgB,0BAA0B,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,uBAAuB,CAc5G"}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { filter, from
|
|
5
|
+
import { filter, from } from "rxjs";
|
|
6
|
+
import { fromPossiblyPromise } from "./Common.js";
|
|
6
7
|
/** @internal */
|
|
7
8
|
export function getRxjsHierarchyDefinition(hierarchyDefinition) {
|
|
8
9
|
return {
|
|
9
10
|
parseNode: hierarchyDefinition.parseNode
|
|
10
11
|
? (row, parentNode) => {
|
|
11
12
|
const parsedNode = hierarchyDefinition.parseNode(row, parentNode);
|
|
12
|
-
return
|
|
13
|
+
return fromPossiblyPromise(parsedNode);
|
|
13
14
|
}
|
|
14
15
|
: undefined,
|
|
15
16
|
preProcessNode: hierarchyDefinition.preProcessNode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RxjsHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/RxjsHierarchyDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"RxjsHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/RxjsHierarchyDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,MAAM,MAAM,CAAC;AAahD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAiElD,gBAAgB;AAChB,MAAM,UAAU,0BAA0B,CAAC,mBAAwC;IACjF,OAAO;QACL,SAAS,EAAE,mBAAmB,CAAC,SAAS;YACtC,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;gBAClB,MAAM,UAAU,GAAG,mBAAmB,CAAC,SAAU,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBACnE,OAAO,mBAAmB,CAAC,UAAU,CAAC,CAAC;YACzC,CAAC;YACH,CAAC,CAAC,SAAS;QACb,cAAc,EAAE,mBAAmB,CAAC,cAAc;YAChD,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,cAAe,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;YAClH,CAAC,CAAC,SAAS;QACb,eAAe,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,eAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7H,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;KACvF,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 { filter, from, Observable } from \"rxjs\";\nimport {\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyDefinitionParentNode,\n HierarchyLevelDefinition,\n} from \"../imodel/IModelHierarchyDefinition.js\";\nimport {\n ProcessedGenericHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n SourceInstanceHierarchyNode,\n} from \"../imodel/IModelHierarchyNode.js\";\nimport { fromPossiblyPromise } from \"./Common.js\";\n\n/**\n * A type for a function that parses a `SourceInstanceHierarchyNode` from provided ECSQL `row` object.\n * @internal\n */\nexport type RxjsNodeParser = (row: { [columnName: string]: any }, parentNode?: HierarchyDefinitionParentNode) => Observable<SourceInstanceHierarchyNode>;\n\n/**\n * A type for a function that pre-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one. Returning `undefined` omits the node\n * from the hierarchy.\n *\n * @internal\n */\nexport type RxjsNodePreProcessor = <TNode extends ProcessedGenericHierarchyNode | ProcessedInstanceHierarchyNode>(node: TNode) => Observable<TNode>;\n\n/**\n * A type for a function that post-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one.\n *\n * @internal\n */\nexport type RxjsNodePostProcessor = (node: ProcessedHierarchyNode) => Observable<ProcessedHierarchyNode>;\n\n/**\n * An interface for a factory that knows how define a hierarchy based on a given parent node.\n * @internal\n */\nexport interface RxjsHierarchyDefinition {\n /**\n * An optional function for parsing ECInstance node from ECSQL row.\n *\n * Should be used in situations when the `HierarchyDefinition` implementation\n * introduces additional ECSQL columns into the select clause and wants to assign additional\n * data to the nodes it produces.\n *\n * Defaults to a function that parses all `HierarchyNode` attributes from a query, whose SELECT\n * clause is created using `NodeSelectQueryFactory.createSelectClause`.\n */\n parseNode?: RxjsNodeParser;\n\n /**\n * An optional function for pre-processing nodes.\n *\n * Pre-processing happens immediately after the nodes are loaded based on `HierarchyLevelDefinition`\n * returned by this `HierarchyDefinition` and before their processing (hiding, grouping, sorting, etc.) starts.\n * The step allows assigning nodes additional data or excluding them from the hierarchy based on some attributes.\n */\n preProcessNode?: RxjsNodePreProcessor;\n\n /**\n * An optional function for post-processing nodes.\n *\n * Post-processing happens after the loaded nodes go through all the merging, hiding and grouping\n * steps, but before sorting them. This step allows `HierarchyDefinition` implementations to assign additional data\n * to nodes after they're processed. This is especially true for grouping nodes as they're only created during\n * processing.\n */\n postProcessNode?: RxjsNodePostProcessor;\n\n /** A function to create a hierarchy level definition for given parent node. */\n defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition>;\n}\n\n/** @internal */\nexport function getRxjsHierarchyDefinition(hierarchyDefinition: HierarchyDefinition): RxjsHierarchyDefinition {\n return {\n parseNode: hierarchyDefinition.parseNode\n ? (row, parentNode) => {\n const parsedNode = hierarchyDefinition.parseNode!(row, parentNode);\n return fromPossiblyPromise(parsedNode);\n }\n : undefined,\n preProcessNode: hierarchyDefinition.preProcessNode\n ? (node) => from(hierarchyDefinition.preProcessNode!(node)).pipe(filter((preprocessedNode) => !!preprocessedNode))\n : undefined,\n postProcessNode: hierarchyDefinition.postProcessNode ? (node) => from(hierarchyDefinition.postProcessNode!(node)) : undefined,\n defineHierarchyLevel: (props) => from(hierarchyDefinition.defineHierarchyLevel(props)),\n };\n}\n"]}
|
|
@@ -3,13 +3,14 @@ export { DefineHierarchyLevelProps, HierarchyLevelDefinition, HierarchyDefinitio
|
|
|
3
3
|
export { DefineGenericNodeChildHierarchyLevelProps, DefineInstanceNodeChildHierarchyLevelProps, DefineRootHierarchyLevelProps, createPredicateBasedHierarchyDefinition, } from "./hierarchies/imodel/PredicateBasedHierarchyDefinition.js";
|
|
4
4
|
export { LimitingECSqlQueryExecutor, createLimitingECSqlQueryExecutor } from "./hierarchies/imodel/LimitingECSqlQueryExecutor.js";
|
|
5
5
|
export { NodeSelectClauseColumnNames, NodesQueryClauseFactory, createNodesQueryClauseFactory } from "./hierarchies/imodel/NodeSelectQueryFactory.js";
|
|
6
|
-
export { createIModelHierarchyProvider } from "./hierarchies/imodel/IModelHierarchyProvider.js";
|
|
6
|
+
export { createIModelHierarchyProvider, createMergedIModelHierarchyProvider } from "./hierarchies/imodel/IModelHierarchyProvider.js";
|
|
7
7
|
export { SourceHierarchyNode, ProcessedHierarchyNode } from "./hierarchies/imodel/IModelHierarchyNode.js";
|
|
8
8
|
export { RowsLimitExceededError } from "./hierarchies/HierarchyErrors.js";
|
|
9
9
|
export { GroupingHierarchyNode, HierarchyNode, NonGroupingHierarchyNode } from "./hierarchies/HierarchyNode.js";
|
|
10
10
|
export { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from "./hierarchies/HierarchyNodeIdentifier.js";
|
|
11
11
|
export { GenericNodeKey, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey, ClassGroupingNodeKey, LabelGroupingNodeKey, PropertyGroupingNodeKey, PropertyOtherValuesGroupingNodeKey, PropertyValueGroupingNodeKey, PropertyValueRangeGroupingNodeKey, IModelHierarchyNodeKey, } from "./hierarchies/HierarchyNodeKey.js";
|
|
12
|
-
export { GetHierarchyNodesProps, HierarchyProvider
|
|
13
|
-
export {
|
|
12
|
+
export { GetHierarchyNodesProps, HierarchyProvider } from "./hierarchies/HierarchyProvider.js";
|
|
13
|
+
export { mergeProviders } from "./hierarchies/HierarchyMerge.js";
|
|
14
|
+
export { createHierarchySearchHelper, HierarchySearchPath, HierarchySearchPathOptions } from "./hierarchies/HierarchySearch.js";
|
|
14
15
|
export { getLogger, setLogger } from "./hierarchies/Logging.js";
|
|
15
16
|
//# sourceMappingURL=presentation-hierarchies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-hierarchies.d.ts","sourceRoot":"","sources":["../../src/presentation-hierarchies.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,yCAAyC,EACzC,0CAA0C,EAC1C,6BAA6B,EAC7B,uCAAuC,GACxC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,oDAAoD,CAAC;AAClI,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AACrJ,OAAO,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;
|
|
1
|
+
{"version":3,"file":"presentation-hierarchies.d.ts","sourceRoot":"","sources":["../../src/presentation-hierarchies.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,yCAAyC,E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