@itwin/presentation-hierarchies 2.0.0-alpha.0 → 2.0.0-alpha.2
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 +81 -0
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +37 -14
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyFiltering.js +46 -24
- package/lib/cjs/hierarchies/HierarchyFiltering.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +10 -8
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +73 -60
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +31 -38
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +2 -5
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts +64 -0
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +25 -0
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts +37 -14
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyFiltering.js +46 -24
- package/lib/esm/hierarchies/HierarchyFiltering.js.map +1 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +10 -8
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +74 -61
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +32 -39
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js +2 -5
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts +64 -0
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +22 -0
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -0
- package/package.json +8 -8
|
@@ -10,11 +10,12 @@ exports.applyECInstanceIdsSelector = applyECInstanceIdsSelector;
|
|
|
10
10
|
const rxjs_1 = require("rxjs");
|
|
11
11
|
const HierarchyFiltering_js_1 = require("../HierarchyFiltering.js");
|
|
12
12
|
const HierarchyNodeIdentifier_js_1 = require("../HierarchyNodeIdentifier.js");
|
|
13
|
+
const HierarchyNodeKey_js_1 = require("../HierarchyNodeKey.js");
|
|
14
|
+
const IModelHierarchyDefinition_js_1 = require("../imodel/IModelHierarchyDefinition.js");
|
|
15
|
+
const IModelHierarchyNode_js_1 = require("../imodel/IModelHierarchyNode.js");
|
|
16
|
+
const NodeSelectQueryFactory_js_1 = require("../imodel/NodeSelectQueryFactory.js");
|
|
17
|
+
const TreeNodesReader_js_1 = require("../imodel/TreeNodesReader.js");
|
|
13
18
|
const Partition_js_1 = require("../internal/operators/Partition.js");
|
|
14
|
-
const IModelHierarchyDefinition_js_1 = require("./IModelHierarchyDefinition.js");
|
|
15
|
-
const IModelHierarchyNode_js_1 = require("./IModelHierarchyNode.js");
|
|
16
|
-
const NodeSelectQueryFactory_js_1 = require("./NodeSelectQueryFactory.js");
|
|
17
|
-
const TreeNodesReader_js_1 = require("./TreeNodesReader.js");
|
|
18
19
|
/** @internal */
|
|
19
20
|
class FilteringHierarchyDefinition {
|
|
20
21
|
_imodelAccess;
|
|
@@ -25,16 +26,17 @@ class FilteringHierarchyDefinition {
|
|
|
25
26
|
this._imodelAccess = props.imodelAccess;
|
|
26
27
|
this._source = props.source;
|
|
27
28
|
this._nodeIdentifierPaths = props.nodeIdentifierPaths;
|
|
28
|
-
this._nodesParser = props.nodesParser ?? this._source.parseNode ?? TreeNodesReader_js_1.defaultNodesParser;
|
|
29
|
+
this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => (0, rxjs_1.of)((0, TreeNodesReader_js_1.defaultNodesParser)(row)));
|
|
29
30
|
}
|
|
30
31
|
get preProcessNode() {
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
return (node) => {
|
|
33
|
+
return (this._source.preProcessNode ? this._source.preProcessNode(node) : (0, rxjs_1.of)(node)).pipe((0, rxjs_1.filter)((processedNode) => {
|
|
34
|
+
if (processedNode.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {
|
|
35
|
+
// we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}));
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
shouldExpandGroupingNode(node) {
|
|
@@ -55,7 +57,9 @@ class FilteringHierarchyDefinition {
|
|
|
55
57
|
}
|
|
56
58
|
// If grouping node's child has `autoExpandUntil` flag,
|
|
57
59
|
// auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.
|
|
58
|
-
const nodeDepth =
|
|
60
|
+
const nodeDepth = childAutoExpand.includeGroupingNodes
|
|
61
|
+
? node.parentKeys.length
|
|
62
|
+
: node.parentKeys.filter((key) => !HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(key)).length;
|
|
59
63
|
const filterTargetDepth = childAutoExpand.depth;
|
|
60
64
|
if (nodeDepth < filterTargetDepth) {
|
|
61
65
|
return true;
|
|
@@ -74,62 +78,71 @@ class FilteringHierarchyDefinition {
|
|
|
74
78
|
return false;
|
|
75
79
|
}
|
|
76
80
|
get postProcessNode() {
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
return (node) => {
|
|
82
|
+
return (this._source.postProcessNode ? this._source.postProcessNode(node) : (0, rxjs_1.of)(node)).pipe((0, rxjs_1.map)((processedNode) => {
|
|
83
|
+
// instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing
|
|
84
|
+
if (IModelHierarchyNode_js_1.ProcessedHierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {
|
|
85
|
+
Object.assign(processedNode, { autoExpand: true });
|
|
86
|
+
}
|
|
87
|
+
return processedNode;
|
|
88
|
+
}));
|
|
84
89
|
};
|
|
85
90
|
}
|
|
86
91
|
get parseNode() {
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
92
|
+
return (row, parentNode) => {
|
|
93
|
+
return this._nodesParser(row).pipe((0, rxjs_1.mergeMap)((parsedNode) => {
|
|
94
|
+
if (!row[exports.ECSQL_COLUMN_NAME_FilterECInstanceId] || !row[exports.ECSQL_COLUMN_NAME_FilterClassName]) {
|
|
95
|
+
return (0, rxjs_1.of)(parsedNode);
|
|
96
|
+
}
|
|
97
|
+
const rowInstanceKey = { className: row[exports.ECSQL_COLUMN_NAME_FilterClassName], id: row[exports.ECSQL_COLUMN_NAME_FilterECInstanceId] };
|
|
98
|
+
const filteringHelper = (0, HierarchyFiltering_js_1.createHierarchyFilteringHelper)(this._nodeIdentifierPaths, parentNode);
|
|
99
|
+
const nodeExtraPropsPossiblyPromise = filteringHelper.createChildNodePropsAsync({
|
|
100
|
+
pathMatcher: (identifier) => {
|
|
101
|
+
if (identifier.id !== rowInstanceKey.id) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (!HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (identifier.className === rowInstanceKey.className) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return Promise.all([
|
|
114
|
+
this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className),
|
|
115
|
+
this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className),
|
|
116
|
+
]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo);
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
return (nodeExtraPropsPossiblyPromise instanceof Promise ? (0, rxjs_1.from)(nodeExtraPropsPossiblyPromise) : (0, rxjs_1.of)(nodeExtraPropsPossiblyPromise)).pipe((0, rxjs_1.map)((nodeExtraProps) => {
|
|
120
|
+
if (nodeExtraProps?.autoExpand) {
|
|
121
|
+
const parentLength = !parentNode
|
|
122
|
+
? 0
|
|
123
|
+
: nodeExtraProps.filtering?.includeGroupingNodes
|
|
124
|
+
? 1 + parentNode.parentKeys.length
|
|
125
|
+
: 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(key)).length;
|
|
126
|
+
parsedNode.autoExpand =
|
|
127
|
+
nodeExtraProps.filtering?.autoExpandDepth !== undefined && parentLength >= nodeExtraProps.filtering.autoExpandDepth ? undefined : true;
|
|
128
|
+
}
|
|
129
|
+
if (nodeExtraProps?.filtering) {
|
|
130
|
+
parsedNode.filtering = nodeExtraProps.filtering;
|
|
131
|
+
}
|
|
132
|
+
return parsedNode;
|
|
133
|
+
}));
|
|
134
|
+
}));
|
|
122
135
|
};
|
|
123
136
|
}
|
|
124
|
-
|
|
125
|
-
const sourceDefinitions =
|
|
137
|
+
defineHierarchyLevel(props) {
|
|
138
|
+
const sourceDefinitions = this._source.defineHierarchyLevel(props);
|
|
126
139
|
const filteringHelper = (0, HierarchyFiltering_js_1.createHierarchyFilteringHelper)(this._nodeIdentifierPaths, props.parentNode);
|
|
127
140
|
const childNodeFilteringIdentifiers = filteringHelper.getChildNodeFilteringIdentifiers();
|
|
128
141
|
if (!childNodeFilteringIdentifiers) {
|
|
129
142
|
return sourceDefinitions;
|
|
130
143
|
}
|
|
131
|
-
const [genericNodeDefinitions, instanceNodeDefinitions] = (0, Partition_js_1.partition)(sourceDefinitions, IModelHierarchyDefinition_js_1.HierarchyNodesDefinition.isGenericNode);
|
|
132
|
-
return (0, rxjs_1.
|
|
144
|
+
const [genericNodeDefinitions, instanceNodeDefinitions] = (0, Partition_js_1.partition)(sourceDefinitions.pipe((0, rxjs_1.mergeAll)()), IModelHierarchyDefinition_js_1.HierarchyNodesDefinition.isGenericNode);
|
|
145
|
+
return (0, rxjs_1.merge)(genericNodeDefinitions.pipe((0, rxjs_1.map)((definition) => {
|
|
133
146
|
if (filteringHelper.hasFilterTargetAncestor ||
|
|
134
147
|
childNodeFilteringIdentifiers.some((identifier) => HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&
|
|
135
148
|
(!identifier.source || identifier.source === this._imodelAccess.imodelKey) &&
|
|
@@ -197,7 +210,7 @@ class FilteringHierarchyDefinition {
|
|
|
197
210
|
(0, rxjs_1.filter)((pathIdentifiers) => pathIdentifiers.length > 0),
|
|
198
211
|
// for each definition that we're going to use, apply query-level filter
|
|
199
212
|
(0, rxjs_1.map)((pathIdentifiers) => applyECInstanceIdsFilter(definition, pathIdentifiers)));
|
|
200
|
-
}))).pipe((0, rxjs_1.toArray)())
|
|
213
|
+
}))).pipe((0, rxjs_1.toArray)());
|
|
201
214
|
}
|
|
202
215
|
}
|
|
203
216
|
exports.FilteringHierarchyDefinition = FilteringHierarchyDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAsRhG,4DAgCC;AAGD,gEAcC;AArUD,+BAAwF;AAGxF,oEAAkG;AAClG,8EAAwE;AAExE,qEAA+D;AAC/D,iFAWwC;AACxC,qEAA+H;AAC/H,2EAA0E;AAC1E,6DAA0D;AAS1D,gBAAgB;AAChB,MAAa,4BAA4B;IAC/B,aAAa,CAAoD;IACjE,OAAO,CAAsB;IAC7B,oBAAoB,CAA2B;IAC/C,YAAY,CAAa;IAEjC,YAAmB,KAAwC;QACzD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,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CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;gBACzB;YACI,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC;qBAC7B,GAAG,CACF,CAAC,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC;wCACN,SAAS;uBAC1B,SAAS;yCACS,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;eAClD,CACF;qBACA,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;4CAG+B,4CAAoC;sCAC1C,yCAAiC;;YAE3D,GAAG,CAAC,KAAK,CAAC,KAAK;;;OAGpB;SACF;KACF,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,SAAgB,0BAA0B,CAAC,GAAiC;IAC1E,OAAO;QACL,GAAG,GAAG;QACN,KAAK,EAAE;YACL,GAAG,GAAG,CAAC,KAAK;YACZ,KAAK,EAAE;;;4CAG+B,4CAAoC;iBAC/D,uDAA2B,CAAC,aAAa,SAAS,yCAAiC;gBACpF,GAAG,CAAC,KAAK,CAAC,KAAK;OACxB;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 { defer, filter, firstValueFrom, map, merge, mergeMap, of, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { createHierarchyFilteringHelper, HierarchyFilteringPath } from \"../HierarchyFiltering.js\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier.js\";\nimport { IModelInstanceKey } from \"../HierarchyNodeKey.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyDefinition,\n HierarchyDefinitionParentNode,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"./IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, SourceInstanceHierarchyNode } from \"./IModelHierarchyNode.js\";\nimport { NodeSelectClauseColumnNames } from \"./NodeSelectQueryFactory.js\";\nimport { defaultNodesParser } from \"./TreeNodesReader.js\";\n\ninterface FilteringHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyFilteringPath[];\n nodesParser?: NodeParser;\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyFilteringPath[];\n private _nodesParser: NodeParser;\n\n public constructor(props: FilteringHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n this._nodesParser = props.nodesParser ?? this._source.parseNode ?? defaultNodesParser;\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 /* c8 ignore next 3 */\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 /* c8 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 (ProcessedHierarchyNode.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 async (row: { [columnName: string]: any }, parentNode?: HierarchyDefinitionParentNode): Promise<SourceInstanceHierarchyNode> => {\n const parsedNode = await this._nodesParser(row);\n const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, parentNode);\n const nodeExtraProps =\n row[ECSQL_COLUMN_NAME_FilterECInstanceId] && row[ECSQL_COLUMN_NAME_FilterClassName]\n ? await (async () => {\n const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_FilterClassName], id: row[ECSQL_COLUMN_NAME_FilterECInstanceId] };\n return filteringHelper.createChildNodePropsAsync({\n pathMatcher: (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 Promise.all([\n this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className),\n this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo);\n },\n });\n })()\n : undefined;\n if (nodeExtraProps?.autoExpand) {\n parsedNode.autoExpand = true;\n }\n if (nodeExtraProps?.filtering) {\n parsedNode.filtering = nodeExtraProps.filtering;\n }\n\n return parsedNode;\n };\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n\n const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, props.parentNode);\n const childNodeFilteringIdentifiers = filteringHelper.getChildNodeFilteringIdentifiers();\n if (!childNodeFilteringIdentifiers) {\n return sourceDefinitions;\n }\n\n const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions, HierarchyNodesDefinition.isGenericNode);\n return firstValueFrom(\n merge(\n genericNodeDefinitions.pipe(\n map((definition) => {\n if (\n filteringHelper.hasFilterTargetAncestor ||\n childNodeFilteringIdentifiers.some(\n (identifier) =>\n HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&\n (!identifier.source || identifier.source === this._imodelAccess.imodelKey) &&\n identifier.id === definition.node.key,\n )\n ) {\n return {\n ...definition,\n node: {\n ...definition.node,\n ...filteringHelper.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 (filteringHelper.hasFilterTargetAncestor) {\n // if we have a filter target ancestor, we don't need to filter 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 childNodeFilteringIdentifiers) {\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 filter\n map((pathIdentifiers) => applyECInstanceIdsFilter(definition, pathIdentifiers)),\n );\n }),\n ),\n ).pipe(toArray()),\n );\n }\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterECInstanceId = \"FilterECInstanceId\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterClassName = \"FilterClassName\";\n\nfunction getClassECInstanceIds(filteredInstanceKeys: InstanceKey[]) {\n const classNameECInstanceIds = new Map<string, Id64String[]>();\n for (const key of filteredInstanceKeys) {\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 applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, filteredInstanceKeys: InstanceKey[]): InstanceNodesQueryDefinition {\n const instanceIdsByClass = getClassECInstanceIds(filteredInstanceKeys);\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n `FilteringInfo(ECInstanceId, FilterClassName) AS (\n ${Array.from(instanceIdsByClass)\n .map(\n ([className, ecInstanceIds]) => `\n SELECT ECInstanceId, '${className}' AS FilterClassName\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_FilterECInstanceId}],\n [f].[FilterClassName] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n JOIN FilteringInfo [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_FilterECInstanceId}],\n [q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (${def.query.ecsql}) [q]\n `,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAkShG,4DAgCC;AAG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C;QACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,gBAAgB;AAChB,SAAgB,wBAAwB,CAAC,GAAiC,EAAE,oBAAmC;IAC7G,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IACvE,OAAO;QACL,GAAG,GAAG;QACN,KAAK,EAAE;YACL,GAAG,GAAG,CAAC,KAAK;YACZ,IAAI,EAAE;gBACJ,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;gBACzB;YACI,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC;qBAC7B,GAAG,CACF,CAAC,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC;wCACN,SAAS;uBAC1B,SAAS;yCACS,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;eAClD,CACF;qBACA,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;4CAG+B,4CAAoC;sCAC1C,yCAAiC;;YAE3D,GAAG,CAAC,KAAK,CAAC,KAAK;;;OAGpB;SACF;KACF,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,SAAgB,0BAA0B,CAAC,GAAiC;IAC1E,OAAO;QACL,GAAG,GAAG;QACN,KAAK,EAAE;YACL,GAAG,GAAG,CAAC,KAAK;YACZ,KAAK,EAAE;;;4CAG+B,4CAAoC;iBAC/D,uDAA2B,CAAC,aAAa,SAAS,yCAAiC;gBACpF,GAAG,CAAC,KAAK,CAAC,KAAK;OACxB;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 { defer, filter, from, map, merge, mergeAll, mergeMap, Observable, of, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { createHierarchyFilteringHelper, HierarchyFilteringPath } from \"../HierarchyFiltering.js\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey, IModelInstanceKey } from \"../HierarchyNodeKey.js\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n} from \"../imodel/IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode } from \"../imodel/IModelHierarchyNode.js\";\nimport { NodeSelectClauseColumnNames } from \"../imodel/NodeSelectQueryFactory.js\";\nimport { defaultNodesParser } from \"../imodel/TreeNodesReader.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport { RxjsHierarchyDefinition, RxjsNodeParser, RxjsNodePostProcessor, RxjsNodePreProcessor } from \"../internal/RxjsHierarchyDefinition.js\";\n\ninterface FilteringHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n source: RxjsHierarchyDefinition;\n nodeIdentifierPaths: HierarchyFilteringPath[];\n nodesParser?: RxjsNodeParser;\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements RxjsHierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n private _source: RxjsHierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyFilteringPath[];\n private _nodesParser: RxjsNodeParser;\n\n public constructor(props: FilteringHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\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.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 false;\n }\n return true;\n }),\n );\n };\n }\n\n private shouldExpandGroupingNode(node: ProcessedGroupingHierarchyNode) {\n for (const child of node.children) {\n /* c8 ignore next 3 */\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 = childAutoExpand.includeGroupingNodes\n ? node.parentKeys.length\n : node.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n const filterTargetDepth = childAutoExpand.depth;\n if (nodeDepth < filterTargetDepth) {\n return true;\n }\n }\n\n if (!child.filtering.filteredChildrenIdentifierPaths) {\n /* c8 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(): RxjsNodePostProcessor {\n return (node) => {\n return (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(\n map((processedNode) => {\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n if (ProcessedHierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {\n Object.assign(processedNode, { autoExpand: true });\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_FilterECInstanceId] || !row[ECSQL_COLUMN_NAME_FilterClassName]) {\n return of(parsedNode);\n }\n const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_FilterClassName], id: row[ECSQL_COLUMN_NAME_FilterECInstanceId] };\n const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, parentNode);\n const nodeExtraPropsPossiblyPromise = filteringHelper.createChildNodePropsAsync({\n pathMatcher: (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 Promise.all([\n this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className),\n this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo);\n },\n });\n return (nodeExtraPropsPossiblyPromise instanceof Promise ? from(nodeExtraPropsPossiblyPromise) : of(nodeExtraPropsPossiblyPromise)).pipe(\n map((nodeExtraProps) => {\n if (nodeExtraProps?.autoExpand) {\n const parentLength = !parentNode\n ? 0\n : nodeExtraProps.filtering?.includeGroupingNodes\n ? 1 + parentNode.parentKeys.length\n : 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n parsedNode.autoExpand =\n nodeExtraProps.filtering?.autoExpandDepth !== undefined && parentLength >= nodeExtraProps.filtering.autoExpandDepth ? undefined : true;\n }\n if (nodeExtraProps?.filtering) {\n parsedNode.filtering = nodeExtraProps.filtering;\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 filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, props.parentNode);\n const childNodeFilteringIdentifiers = filteringHelper.getChildNodeFilteringIdentifiers();\n if (!childNodeFilteringIdentifiers) {\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 filteringHelper.hasFilterTargetAncestor ||\n childNodeFilteringIdentifiers.some(\n (identifier) =>\n HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&\n (!identifier.source || identifier.source === this._imodelAccess.imodelKey) &&\n identifier.id === definition.node.key,\n )\n ) {\n return {\n ...definition,\n node: {\n ...definition.node,\n ...filteringHelper.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 (filteringHelper.hasFilterTargetAncestor) {\n // if we have a filter target ancestor, we don't need to filter 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 childNodeFilteringIdentifiers) {\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 filter\n map((pathIdentifiers) => applyECInstanceIdsFilter(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_FilterECInstanceId = \"FilterECInstanceId\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterClassName = \"FilterClassName\";\n\nfunction getClassECInstanceIds(filteredInstanceKeys: InstanceKey[]) {\n const classNameECInstanceIds = new Map<string, Id64String[]>();\n for (const key of filteredInstanceKeys) {\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 applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, filteredInstanceKeys: InstanceKey[]): InstanceNodesQueryDefinition {\n const instanceIdsByClass = getClassECInstanceIds(filteredInstanceKeys);\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n `FilteringInfo(ECInstanceId, FilterClassName) AS (\n ${Array.from(instanceIdsByClass)\n .map(\n ([className, ecInstanceIds]) => `\n SELECT ECInstanceId, '${className}' AS FilterClassName\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_FilterECInstanceId}],\n [f].[FilterClassName] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n JOIN FilteringInfo [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_FilterECInstanceId}],\n [q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (${def.query.ecsql}) [q]\n `,\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHierarchyProvider.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAKA,OAAO,gCAAgC,CAAC;AAuBxC,OAAO,EAGL,yBAAyB,EACzB,gBAAgB,EAGhB,KAAK,EAIL,wBAAwB,EAEzB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAA0B,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelHierarchyProvider.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAKA,OAAO,gCAAgC,CAAC;AAuBxC,OAAO,EAGL,yBAAyB,EACzB,gBAA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C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B,CAEA"}
|
|
@@ -19,6 +19,7 @@ const Partition_js_1 = require("../internal/operators/Partition.js");
|
|
|
19
19
|
const ReduceToMergeMap_js_1 = require("../internal/operators/ReduceToMergeMap.js");
|
|
20
20
|
const ShareReplayWithErrors_js_1 = require("../internal/operators/ShareReplayWithErrors.js");
|
|
21
21
|
const Sorting_js_1 = require("../internal/operators/Sorting.js");
|
|
22
|
+
const RxjsHierarchyDefinition_js_1 = require("../internal/RxjsHierarchyDefinition.js");
|
|
22
23
|
const SubscriptionScheduler_js_1 = require("../internal/SubscriptionScheduler.js");
|
|
23
24
|
const FilteringHierarchyDefinition_js_1 = require("./FilteringHierarchyDefinition.js");
|
|
24
25
|
const HierarchyCache_js_1 = require("./HierarchyCache.js");
|
|
@@ -57,7 +58,7 @@ class IModelHierarchyProviderImpl {
|
|
|
57
58
|
constructor(props) {
|
|
58
59
|
this._imodelAccess = props.imodelAccess;
|
|
59
60
|
this._hierarchyChanged = new core_bentley_1.BeEvent();
|
|
60
|
-
this._activeHierarchyDefinition = this._sourceHierarchyDefinition = props.hierarchyDefinition;
|
|
61
|
+
this._activeHierarchyDefinition = this._sourceHierarchyDefinition = (0, RxjsHierarchyDefinition_js_1.getRxjsHierarchyDefinition)(props.hierarchyDefinition);
|
|
61
62
|
this._valuesFormatter = props?.formatter ?? (0, presentation_shared_1.createDefaultValueFormatter)();
|
|
62
63
|
this._localizedStrings = { other: "Other", unspecified: "Not specified", ...props?.localizedStrings };
|
|
63
64
|
this._queryScheduler = new SubscriptionScheduler_js_1.SubscriptionScheduler(props.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY);
|
|
@@ -129,26 +130,24 @@ class IModelHierarchyProviderImpl {
|
|
|
129
130
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
130
131
|
message: /* c8 ignore next */ () => `[${requestContext.requestId}] Requesting hierarchy level definitions for ${(0, Common_js_1.createNodeIdentifierForLogging)(props.parentNode)}`,
|
|
131
132
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
parentNode
|
|
139
|
-
|
|
140
|
-
key
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return [];
|
|
148
|
-
}
|
|
133
|
+
let parentNode = props.parentNode;
|
|
134
|
+
if (parentNode && HierarchyNode_js_1.HierarchyNode.isGeneric(parentNode) && parentNode.key.source && parentNode.key.source !== this._imodelAccess.imodelKey) {
|
|
135
|
+
return rxjs_1.EMPTY;
|
|
136
|
+
}
|
|
137
|
+
if (parentNode && HierarchyNode_js_1.HierarchyNode.isInstancesNode(parentNode)) {
|
|
138
|
+
parentNode = {
|
|
139
|
+
...parentNode,
|
|
140
|
+
key: {
|
|
141
|
+
...parentNode.key,
|
|
142
|
+
instanceKeys: parentNode.key.instanceKeys.filter((ik) => !ik.imodelKey || ik.imodelKey === this._imodelAccess.imodelKey),
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
(0, core_bentley_1.assert)(HierarchyNodeKey_js_1.HierarchyNodeKey.isInstances(parentNode.key));
|
|
146
|
+
if (parentNode.key.instanceKeys.length === 0) {
|
|
147
|
+
return rxjs_1.EMPTY;
|
|
149
148
|
}
|
|
150
|
-
|
|
151
|
-
})
|
|
149
|
+
}
|
|
150
|
+
return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode }).pipe((0, rxjs_1.mergeAll)(), (0, rxjs_1.finalize)(() => (0, LoggingUtils_js_1.doLog)({
|
|
152
151
|
category: LOGGING_NAMESPACE_PERFORMANCE,
|
|
153
152
|
message: /* c8 ignore next */ () => `[${requestContext.requestId}] Received all hierarchy level definitions for ${(0, Common_js_1.createNodeIdentifierForLogging)(props.parentNode)}`,
|
|
154
153
|
})));
|
|
@@ -163,9 +162,7 @@ class IModelHierarchyProviderImpl {
|
|
|
163
162
|
queryExecutor: this._imodelAccess,
|
|
164
163
|
query,
|
|
165
164
|
limit: props.hierarchyLevelSizeLimit,
|
|
166
|
-
parser: this._activeHierarchyDefinition.parseNode
|
|
167
|
-
? async (row) => this._activeHierarchyDefinition.parseNode(row, props.parentNode)
|
|
168
|
-
: undefined,
|
|
165
|
+
parser: this._activeHierarchyDefinition.parseNode ? (row) => this._activeHierarchyDefinition.parseNode(row, props.parentNode) : undefined,
|
|
169
166
|
})), (0, rxjs_1.map)((node) => ({
|
|
170
167
|
...node,
|
|
171
168
|
key: { ...node.key, instanceKeys: node.key.instanceKeys.map((key) => ({ ...key, imodelKey: this._imodelAccess.imodelKey })) },
|
|
@@ -182,7 +179,7 @@ class IModelHierarchyProviderImpl {
|
|
|
182
179
|
// set parent node keys on the source node
|
|
183
180
|
(0, rxjs_1.map)((node) => Object.assign(node, { parentKeys: createParentNodeKeysList(props.parentNode) })),
|
|
184
181
|
// format `ConcatenatedValue` labels into string labels
|
|
185
|
-
(0, rxjs_1.mergeMap)(
|
|
182
|
+
(0, rxjs_1.mergeMap)((node) => applyLabelsFormatting(node, this._valuesFormatter)),
|
|
186
183
|
// we have `ProcessedHierarchyNode` from here
|
|
187
184
|
preProcessNodes(this._activeHierarchyDefinition),
|
|
188
185
|
// process hiding
|
|
@@ -398,26 +395,22 @@ class IModelHierarchyProviderImpl {
|
|
|
398
395
|
}
|
|
399
396
|
}
|
|
400
397
|
function preProcessNodes(hierarchyFactory) {
|
|
401
|
-
return hierarchyFactory.preProcessNode
|
|
402
|
-
? processNodes(hierarchyFactory.preProcessNode.bind(hierarchyFactory))
|
|
403
|
-
: (o) => o;
|
|
398
|
+
return hierarchyFactory.preProcessNode ? processNodes(hierarchyFactory.preProcessNode) : rxjs_1.identity;
|
|
404
399
|
}
|
|
405
400
|
function postProcessNodes(hierarchyFactory) {
|
|
406
|
-
return hierarchyFactory.postProcessNode
|
|
407
|
-
? processNodes(hierarchyFactory.postProcessNode.bind(hierarchyFactory))
|
|
408
|
-
: (o) => o;
|
|
401
|
+
return hierarchyFactory.postProcessNode ? processNodes(hierarchyFactory.postProcessNode) : rxjs_1.identity;
|
|
409
402
|
}
|
|
410
403
|
function processNodes(processor) {
|
|
411
|
-
return (nodes) => nodes.pipe((0, rxjs_1.mergeMap)(processor)
|
|
404
|
+
return (nodes) => nodes.pipe((0, rxjs_1.mergeMap)(processor));
|
|
412
405
|
}
|
|
413
|
-
|
|
414
|
-
return {
|
|
406
|
+
function applyLabelsFormatting(node, valueFormatter) {
|
|
407
|
+
return (0, rxjs_1.from)((0, presentation_shared_1.formatConcatenatedValue)({
|
|
408
|
+
value: node.label,
|
|
409
|
+
valueFormatter,
|
|
410
|
+
})).pipe((0, rxjs_1.map)((label) => ({
|
|
415
411
|
...node,
|
|
416
|
-
label
|
|
417
|
-
|
|
418
|
-
valueFormatter,
|
|
419
|
-
}),
|
|
420
|
-
};
|
|
412
|
+
label,
|
|
413
|
+
})));
|
|
421
414
|
}
|
|
422
415
|
function createParentNodeKeysList(parentNode) {
|
|
423
416
|
if (!parentNode) {
|