@itwin/presentation-hierarchies 0.1.0 → 0.1.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 +12 -0
- package/lib/cjs/hierarchies/HierarchyDefinition.d.ts +2 -8
- package/lib/cjs/hierarchies/HierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +11 -48
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts +6 -26
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts +4 -1
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js +26 -15
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyDefinition.d.ts +2 -8
- package/lib/esm/hierarchies/HierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.d.ts +11 -48
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts +6 -26
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts +4 -1
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js +26 -15
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.applyECInstanceIdsFilter = exports.ECSQL_COLUMN_NAME_IsFilterTarget = exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths = exports.FilteringHierarchyDefinition = void 0;
|
|
7
|
+
exports.applyECInstanceIdsFilter = exports.ECSQL_COLUMN_NAME_HasFilterTargetAncestor = exports.ECSQL_COLUMN_NAME_IsFilterTarget = exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths = exports.FilteringHierarchyDefinition = void 0;
|
|
8
8
|
const HierarchyDefinition_1 = require("../HierarchyDefinition");
|
|
9
9
|
const HierarchyNode_1 = require("../HierarchyNode");
|
|
10
10
|
const HierarchyNodeIdentifier_1 = require("../HierarchyNodeIdentifier");
|
|
@@ -22,8 +22,9 @@ class FilteringHierarchyDefinition {
|
|
|
22
22
|
get preProcessNode() {
|
|
23
23
|
return async (node) => {
|
|
24
24
|
const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const filteredNode = processedNode;
|
|
26
|
+
if (filteredNode?.processingParams?.hideInHierarchy && filteredNode.isFilterTarget && !filteredNode.hasFilterTargetAncestor) {
|
|
27
|
+
// we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target
|
|
27
28
|
return undefined;
|
|
28
29
|
}
|
|
29
30
|
return processedNode;
|
|
@@ -44,16 +45,17 @@ class FilteringHierarchyDefinition {
|
|
|
44
45
|
get parseNode() {
|
|
45
46
|
return (row) => {
|
|
46
47
|
const isFilterTarget = !!row[exports.ECSQL_COLUMN_NAME_IsFilterTarget];
|
|
48
|
+
const hasFilterTargetAncestor = !!row[exports.ECSQL_COLUMN_NAME_HasFilterTargetAncestor];
|
|
47
49
|
const parsedFilteredChildrenIdentifierPaths = row[exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths]
|
|
48
50
|
? JSON.parse(row[exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths])
|
|
49
51
|
: undefined;
|
|
50
52
|
const defaultNode = (this._source.parseNode ?? TreeNodesReader_1.defaultNodesParser)(row);
|
|
51
|
-
return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget);
|
|
53
|
+
return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor);
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
async defineHierarchyLevel(props) {
|
|
55
57
|
const sourceDefinitions = await this._source.defineHierarchyLevel(props);
|
|
56
|
-
const { filteredNodePaths,
|
|
58
|
+
const { filteredNodePaths, isDirectParentFilterTarget, hasFilterTargetAncestor } = this.getFilteringProps(props.parentNode);
|
|
57
59
|
if (!filteredNodePaths) {
|
|
58
60
|
return sourceDefinitions;
|
|
59
61
|
}
|
|
@@ -61,7 +63,7 @@ class FilteringHierarchyDefinition {
|
|
|
61
63
|
await Promise.all(sourceDefinitions.map(async (definition) => {
|
|
62
64
|
let matchedDefinition;
|
|
63
65
|
if (HierarchyDefinition_1.HierarchyNodesDefinition.isCustomNode(definition)) {
|
|
64
|
-
matchedDefinition = await matchFilters(definition, { filteredNodePaths,
|
|
66
|
+
matchedDefinition = await matchFilters(definition, { filteredNodePaths, isDirectParentFilterTarget }, async (id) => {
|
|
65
67
|
if (!HierarchyNodeIdentifier_1.HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {
|
|
66
68
|
return false;
|
|
67
69
|
}
|
|
@@ -70,17 +72,17 @@ class FilteringHierarchyDefinition {
|
|
|
70
72
|
const filteredChildrenIdentifierPaths = matchingFilters.reduce((r, c) => [...r, ...c.childrenIdentifierPaths], new Array());
|
|
71
73
|
return {
|
|
72
74
|
...def,
|
|
73
|
-
node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget),
|
|
75
|
+
node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget, !!hasFilterTargetAncestor),
|
|
74
76
|
};
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
79
|
else {
|
|
78
|
-
matchedDefinition = await matchFilters(definition, { filteredNodePaths,
|
|
80
|
+
matchedDefinition = await matchFilters(definition, { filteredNodePaths, isDirectParentFilterTarget }, async (id) => {
|
|
79
81
|
if (!HierarchyNodeIdentifier_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {
|
|
80
82
|
return false;
|
|
81
83
|
}
|
|
82
84
|
return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);
|
|
83
|
-
}, (def, matchingFilters, isFilterTarget) => applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!
|
|
85
|
+
}, (def, matchingFilters, isFilterTarget) => applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor));
|
|
84
86
|
}
|
|
85
87
|
if (matchedDefinition) {
|
|
86
88
|
filteredDefinitions.push(matchedDefinition);
|
|
@@ -90,14 +92,18 @@ class FilteringHierarchyDefinition {
|
|
|
90
92
|
}
|
|
91
93
|
getFilteringProps(parentNode) {
|
|
92
94
|
if (!parentNode) {
|
|
93
|
-
return { filteredNodePaths: this._nodeIdentifierPaths,
|
|
95
|
+
return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };
|
|
94
96
|
}
|
|
95
|
-
return {
|
|
97
|
+
return {
|
|
98
|
+
filteredNodePaths: parentNode.filteredChildrenIdentifierPaths,
|
|
99
|
+
isDirectParentFilterTarget: parentNode.isFilterTarget,
|
|
100
|
+
hasFilterTargetAncestor: !!parentNode.hasFilterTargetAncestor,
|
|
101
|
+
};
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
exports.FilteringHierarchyDefinition = FilteringHierarchyDefinition;
|
|
99
105
|
async function matchFilters(definition, filteringProps, predicate, matchedDefinitionProcessor) {
|
|
100
|
-
const { filteredNodePaths,
|
|
106
|
+
const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;
|
|
101
107
|
let isFilterTarget = false;
|
|
102
108
|
const matchingFilters = [];
|
|
103
109
|
for (const path of filteredNodePaths) {
|
|
@@ -125,16 +131,17 @@ async function matchFilters(definition, filteringProps, predicate, matchedDefini
|
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
|
-
if (
|
|
134
|
+
if (isDirectParentFilterTarget || matchingFilters.length > 0) {
|
|
129
135
|
return matchedDefinitionProcessor(definition, matchingFilters, isFilterTarget);
|
|
130
136
|
}
|
|
131
137
|
return undefined;
|
|
132
138
|
}
|
|
133
|
-
function applyFilterAttributes(node, filteredChildrenIdentifierPaths, isFilterTarget) {
|
|
139
|
+
function applyFilterAttributes(node, filteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor) {
|
|
134
140
|
const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);
|
|
135
141
|
return {
|
|
136
142
|
...node,
|
|
137
143
|
...(isFilterTarget ? { isFilterTarget } : undefined),
|
|
144
|
+
...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),
|
|
138
145
|
...(shouldAutoExpand ? { autoExpand: true } : undefined),
|
|
139
146
|
...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),
|
|
140
147
|
};
|
|
@@ -146,7 +153,10 @@ exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths = "FilteredChildrenPaths";
|
|
|
146
153
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
147
154
|
exports.ECSQL_COLUMN_NAME_IsFilterTarget = "IsFilterTarget";
|
|
148
155
|
/** @internal */
|
|
149
|
-
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
157
|
+
exports.ECSQL_COLUMN_NAME_HasFilterTargetAncestor = "HasFilterTargetAncestor";
|
|
158
|
+
/** @internal */
|
|
159
|
+
function applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, isParentFilterTarget, hasFilterTargetAncestor) {
|
|
150
160
|
if (matchingFilters.length === 0) {
|
|
151
161
|
return def;
|
|
152
162
|
}
|
|
@@ -168,6 +178,7 @@ function applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, isParent
|
|
|
168
178
|
SELECT
|
|
169
179
|
[q].*,
|
|
170
180
|
${isFilterTarget ? "1" : "0"} AS [${exports.ECSQL_COLUMN_NAME_IsFilterTarget}],
|
|
181
|
+
${hasFilterTargetAncestor || isParentFilterTarget ? "1" : "0"} AS [${exports.ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],
|
|
171
182
|
[f].[FilteredChildrenPaths] AS [${exports.ECSQL_COLUMN_NAME_FilteredChildrenPaths}]
|
|
172
183
|
FROM (
|
|
173
184
|
${def.query.ecsql}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAGhG,gEAUgC;AAChC,oDAA2H;AAC3H,wEAAmG;AACnG,uDAAuD;AAevD,gBAAgB;AAChB,MAAa,4BAA4B;IAC/B,eAAe,CAA4B;IAC3C,OAAO,CAAsB;IAC7B,oBAAoB,CAAiC;IAE7D,YAAmB,KAAiC;QAClD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,mBAAmB,CAAC;IACxD,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,KAAK,EAAE,IAA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C,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,IAAI,CAAC;qBACjH,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;YAGD,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,wCAAgC;4CAClC,+CAAuC;;YAEvE,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACtC;SACF;KACF,CAAC;AACJ,CAAC;AAnCD,4DAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport {\n CustomHierarchyNodeDefinition,\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"../HierarchyDefinition\";\nimport { HierarchyNode, ParsedHierarchyNode, ParsedInstanceHierarchyNode, ProcessedHierarchyNode } from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"../HierarchyNodeIdentifier\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n}\n\n/** @internal */\nexport type FilteredHierarchyNode<TNode = ProcessedHierarchyNode> = TNode & {\n isFilterTarget?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];\n};\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n\n public constructor(props: FilteringQueryBuilderProps) {\n this._classHierarchy = props.classHierarchy;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n if (processedNode?.processingParams?.hideInHierarchy && (node as FilteredHierarchyNode).isFilterTarget) {\n // we want to hide target nodes if they have `hideInHierarchy` param\n return undefined;\n }\n return processedNode;\n };\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n if (\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n HierarchyNode.isClassGroupingNode(node) &&\n node.children.some((child: FilteredHierarchyNode) => child.isFilterTarget || child.filteredChildrenIdentifierPaths)\n ) {\n return Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): FilteredHierarchyNode<ParsedInstanceHierarchyNode> => {\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const parsedFilteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget);\n };\n }\n\n public async defineHierarchyLevel(\n props: DefineHierarchyLevelProps & { parentNode: FilteredHierarchyNode<DefineHierarchyLevelProps[\"parentNode\"]> | undefined },\n ): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { filteredNodePaths, isParentFilterTarget } = this.getFilteringProps(props.parentNode);\n if (!filteredNodePaths) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isCustomNode(definition)) {\n matchedDefinition = await matchFilters<{ key: string }>(\n definition,\n { filteredNodePaths, isParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {\n return false;\n }\n return id.key === definition.node.key;\n },\n (def, matchingFilters, isFilterTarget) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyNodeIdentifiersPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n { filteredNodePaths, isParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n return false;\n }\n return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);\n },\n (def, matchingFilters, isFilterTarget) => applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!isParentFilterTarget),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n\n private getFilteringProps(parentNode: FilteredHierarchyNode<unknown> | undefined) {\n if (!parentNode) {\n return { filteredNodePaths: this._nodeIdentifierPaths, isParentFilterTarget: false };\n }\n return { filteredNodePaths: parentNode.filteredChildrenIdentifierPaths, isParentFilterTarget: parentNode.isFilterTarget };\n }\n}\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyNodeIdentifiersPath[]; isParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n matchedDefinitionProcessor: (\n def: TDefinition,\n matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n ) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isParentFilterTarget } = filteringProps;\n let isFilterTarget = false;\n const matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }> = [];\n for (const path of filteredNodePaths) {\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let childrenIdentifierPaths = matchingFilters.find(({ id }) => HierarchyNodeIdentifier.equal(id, nodeId))?.childrenIdentifierPaths;\n if (!childrenIdentifierPaths) {\n childrenIdentifierPaths = [];\n matchingFilters.push({\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths,\n });\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n childrenIdentifierPaths.push(remainingPath);\n } else {\n isFilterTarget = true;\n }\n }\n }\n if (isParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters, isFilterTarget);\n }\n return undefined;\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>(\n node: TNode,\n filteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined,\n isFilterTarget: boolean,\n): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);\n return {\n ...node,\n ...(isFilterTarget ? { isFilterTarget } : undefined),\n ...(shouldAutoExpand ? { autoExpand: true } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilteredChildrenPaths = \"FilteredChildrenPaths\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_IsFilterTarget = \"IsFilterTarget\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<{ id: InstanceKey; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n isParentFilterTarget: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map(({ id: key, childrenIdentifierPaths }) => `VALUES (${key.id}, '${JSON.stringify(childrenIdentifierPaths)}')`)\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n ${isFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${isParentFilterTarget ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAGhG,gEAUgC;AAChC,oDAO0B;AAC1B,wEAAmG;AACnG,uDAAuD;AAgBvD,gBAAgB;AAChB,MAAa,4BAA4B;IAC/B,eAAe,CAA4B;IAC3C,OAAO,CAAsB;IA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C","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport {\n CustomHierarchyNodeDefinition,\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"../HierarchyDefinition\";\nimport {\n HierarchyNode,\n ParsedHierarchyNode,\n ParsedInstanceHierarchyNode,\n ProcessedCustomHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n} from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"../HierarchyNodeIdentifier\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n}\n\n/** @internal */\nexport type FilteredHierarchyNode<TNode = ProcessedHierarchyNode> = TNode & {\n isFilterTarget?: boolean;\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];\n};\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n\n public constructor(props: FilteringQueryBuilderProps) {\n this._classHierarchy = props.classHierarchy;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n const filteredNode = processedNode as FilteredHierarchyNode<ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode> | undefined;\n if (filteredNode?.processingParams?.hideInHierarchy && filteredNode.isFilterTarget && !filteredNode.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return undefined;\n }\n return processedNode;\n };\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n if (\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n HierarchyNode.isClassGroupingNode(node) &&\n node.children.some((child: FilteredHierarchyNode) => child.isFilterTarget || child.filteredChildrenIdentifierPaths)\n ) {\n return Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): FilteredHierarchyNode<ParsedInstanceHierarchyNode> => {\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const parsedFilteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor);\n };\n }\n\n public async defineHierarchyLevel(\n props: DefineHierarchyLevelProps & { parentNode: FilteredHierarchyNode<DefineHierarchyLevelProps[\"parentNode\"]> | undefined },\n ): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { filteredNodePaths, isDirectParentFilterTarget, hasFilterTargetAncestor } = this.getFilteringProps(props.parentNode);\n if (!filteredNodePaths) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isCustomNode(definition)) {\n matchedDefinition = await matchFilters<{ key: string }>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {\n return false;\n }\n return id.key === definition.node.key;\n },\n (def, matchingFilters, isFilterTarget) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyNodeIdentifiersPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget, !!hasFilterTargetAncestor),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n return false;\n }\n return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);\n },\n (def, matchingFilters, isFilterTarget) =>\n applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n\n private getFilteringProps(parentNode: FilteredHierarchyNode<unknown> | undefined) {\n if (!parentNode) {\n return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };\n }\n return {\n filteredNodePaths: parentNode.filteredChildrenIdentifierPaths,\n isDirectParentFilterTarget: parentNode.isFilterTarget,\n hasFilterTargetAncestor: !!parentNode.hasFilterTargetAncestor,\n };\n }\n}\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyNodeIdentifiersPath[]; isDirectParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n matchedDefinitionProcessor: (\n def: TDefinition,\n matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n ) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;\n let isFilterTarget = false;\n const matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }> = [];\n for (const path of filteredNodePaths) {\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let childrenIdentifierPaths = matchingFilters.find(({ id }) => HierarchyNodeIdentifier.equal(id, nodeId))?.childrenIdentifierPaths;\n if (!childrenIdentifierPaths) {\n childrenIdentifierPaths = [];\n matchingFilters.push({\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths,\n });\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n childrenIdentifierPaths.push(remainingPath);\n } else {\n isFilterTarget = true;\n }\n }\n }\n if (isDirectParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters, isFilterTarget);\n }\n return undefined;\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>(\n node: TNode,\n filteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined,\n isFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);\n return {\n ...node,\n ...(isFilterTarget ? { isFilterTarget } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(shouldAutoExpand ? { autoExpand: true } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilteredChildrenPaths = \"FilteredChildrenPaths\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_IsFilterTarget = \"IsFilterTarget\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<{ id: InstanceKey; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n isParentFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map(({ id: key, childrenIdentifierPaths }) => `VALUES (${key.id}, '${JSON.stringify(childrenIdentifierPaths)}')`)\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n ${isFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n ${hasFilterTargetAncestor || isParentFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${isParentFilterTarget ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
|
|
@@ -3,18 +3,12 @@ import { GenericInstanceFilter } from "@itwin/core-common";
|
|
|
3
3
|
import { ECClassHierarchyInspector, ECSqlQueryDef } from "@itwin/presentation-shared";
|
|
4
4
|
import { NonGroupingHierarchyNode, ParsedCustomHierarchyNode, ParsedInstanceHierarchyNode, ProcessedCustomHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode } from "./HierarchyNode";
|
|
5
5
|
import { InstancesNodeKey } from "./HierarchyNodeKey";
|
|
6
|
-
/**
|
|
7
|
-
* A nodes definition that returns a single custom defined node.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
6
|
+
/** A nodes definition that returns a single custom defined node. */
|
|
10
7
|
export interface CustomHierarchyNodeDefinition {
|
|
11
8
|
/** The node to be created in the hierarchy level */
|
|
12
9
|
node: ParsedCustomHierarchyNode;
|
|
13
10
|
}
|
|
14
|
-
/**
|
|
15
|
-
* A nodes definition that returns an ECSQL query for selecting nodes from an iModel.
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
11
|
+
/** A nodes definition that returns an ECSQL query for selecting nodes from an iModel. */
|
|
18
12
|
export interface InstanceNodesQueryDefinition {
|
|
19
13
|
/**
|
|
20
14
|
* Full name of the class whose instances are going to be returned. It's okay if the attribute
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAe,MAAM,4BAA4B,CAAC;AACnG,OAAO,EAEL,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,sBAAsB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,CAAC;AACX,CAAC;AAED,SAAS,uBAAuB,CAAC,YAA2B;IAC1D,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3D,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC3B,IAAI,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,WAAW,GAAG,EAAE,CAAC;YACjB,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACrD,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,SAAS,yCAAyC,CAAC,GAAuC;IACxF,OAAO,CAAC,CAAE,GAA+C,CAAC,mBAAmB,CAAC;AAChF,CAAC;AAED,SAAS,4CAA4C,CAAC,GAAuC;IAC3F,OAAO,CAAC,CAAE,GAAkD,CAAC,mBAAmB,CAAC;AACnF,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 { Id64String } from \"@itwin/core-bentley\";\nimport { GenericInstanceFilter } from \"@itwin/core-common\";\nimport { ECClassHierarchyInspector, ECSqlQueryDef, InstanceKey } from \"@itwin/presentation-shared\";\nimport {\n HierarchyNode,\n NonGroupingHierarchyNode,\n ParsedCustomHierarchyNode,\n ParsedInstanceHierarchyNode,\n ProcessedCustomHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n} from \"./HierarchyNode\";\nimport { InstancesNodeKey } from \"./HierarchyNodeKey\";\n\n/**\n * A nodes definition that returns a single custom defined node.\n * @internal\n */\nexport interface CustomHierarchyNodeDefinition {\n /** The node to be created in the hierarchy level */\n node: ParsedCustomHierarchyNode;\n}\n\n/**\n * A nodes definition that returns an ECSQL query for selecting nodes from an iModel.\n * @internal\n */\nexport interface InstanceNodesQueryDefinition {\n /**\n * Full name of the class whose instances are going to be returned. It's okay if the attribute\n * points to a base class of multiple different classes of instances returned by the query, however\n * the more specific this class is, the more efficient hierarchy building process is.\n */\n fullClassName: string;\n /**\n * An ECSQL query that selects nodes from an iModel. `SELECT` clause of the query is expected\n * to be built using `NodeSelectQueryFactory.createSelectClause`.\n */\n query: ECSqlQueryDef;\n}\n\n/**\n * A definition of nodes included in a hierarchy level.\n * @beta\n */\nexport type HierarchyNodesDefinition = CustomHierarchyNodeDefinition | InstanceNodesQueryDefinition;\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodesDefinition {\n export function isCustomNode(def: HierarchyNodesDefinition): def is CustomHierarchyNodeDefinition {\n return !!(def as CustomHierarchyNodeDefinition).node;\n }\n export function isInstanceNodesQuery(def: HierarchyNodesDefinition): def is InstanceNodesQueryDefinition {\n return !!(def as InstanceNodesQueryDefinition).query;\n }\n}\n\n/**\n * A definition of a hierarchy level, which may consist of multiple node definitions.\n * @beta\n */\nexport type HierarchyLevelDefinition = HierarchyNodesDefinition[];\n\n/**\n * A type for a function that parses a `ParsedInstanceHierarchyNode` from provided ECSQL `row` object.\n * @beta\n */\nexport type NodeParser = (row: { [columnName: string]: any }) => ParsedInstanceHierarchyNode;\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 * @beta\n */\nexport type NodePreProcessor = <TNode extends ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode>(node: TNode) => Promise<TNode | undefined>;\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 * @beta\n */\nexport type NodePostProcessor = (node: ProcessedHierarchyNode) => Promise<ProcessedHierarchyNode>;\n\n/**\n * A type of node that can be passed to `HierarchyDefinition.defineHierarchyLevel`. This basically means\n * a `HierarchyNode` that:\n * - knows nothing about its children,\n * - is either an instances node (key is of `InstancesNodeKey` type) or a custom node (key is of `string` type).\n */\ntype HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, \"children\">;\n\n/**\n * Props for `HierarchyDefinition.defineHierarchyLevel`.\n * @beta\n */\nexport interface DefineHierarchyLevelProps {\n /** Parent node to get children for. Pass `undefined` to get root nodes. */\n parentNode: HierarchyDefinitionParentNode | undefined;\n\n /** Optional hierarchy level filter. */\n instanceFilter?: GenericInstanceFilter;\n}\n\n/**\n * An interface for a factory that knows how define a hierarchy based on a given parent node.\n * @beta\n */\nexport interface HierarchyDefinition {\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?: NodeParser;\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?: NodePreProcessor;\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?: NodePostProcessor;\n\n /** A function to create a hierarchy level definition for given parent node. */\n defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;\n}\n\n/**\n * Props for defining child hierarchy level for specific parent instance node.\n * @see `createClassBasedHierarchyDefinition`\n * @beta\n */\nexport type DefineInstanceNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\"> & {\n /** The parent instance node. */\n parentNode: Omit<HierarchyDefinitionParentNode, \"key\"> & { key: InstancesNodeKey };\n\n /**\n * Full name of the parent instance node class.\n *\n * The `parentNode.key` also contains information about the instances the parent node is based on. However,\n * an instance node may be based on instances of multiple classes. In case that happens, parent node's instance\n * keys are grouped by class and a hierarchy level definition is requested for each combination of class and\n * instance IDs (with the same `parentNode`).\n */\n parentNodeClassName: string;\n\n /**\n * ECInstanceIds of the parent instance node.\n *\n * The `parentNode.key` also contains information about the instances the parent node is based on. However,\n * an instance node may be based on instances of multiple classes. In case that happens, parent node's instance\n * keys are grouped by class and a hierarchy level definition is requested for each combination of class and\n * instance IDs (with the same `parentNode`).\n */\n parentNodeInstanceIds: Id64String[];\n};\n\n/**\n * A definition of a hierarchy level that should be used for specific class of parent instance nodes.\n */\ninterface InstancesNodeChildHierarchyLevelDefinition {\n /**\n * Full name of the parent instance node's class to match against when checking if this hierarchy\n * level should be used for specific parent instance node.\n *\n * The check is polymorphic, so `BisCore.Element` class would match `BisCore.GeometricElement`, `BisCore.Category` and\n * all other element classes.\n */\n parentNodeClassName: string;\n\n /**\n * Called to create a hierarchy level definition when the class check passes (see `parentNodeClassName`).\n */\n definitions: (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n}\n\n/**\n * Props for defining child hierarchy level for specific parent custom node.\n * @see `createClassBasedHierarchyDefinition`\n * @beta\n */\nexport type DefineCustomNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\"> & {\n /** The parent custom node. */\n parentNode: Omit<HierarchyDefinitionParentNode, \"key\"> & { key: string };\n};\n\n/**\n * A definition of a hierarchy level for that should be used for specific custom parent nodes.\n */\ninterface CustomNodeChildHierarchyLevelDefinition {\n /**\n * `HierarchyNode.key` of the custom node that this child hierarchy level definition should be used for.\n */\n customParentNodeKey: string;\n\n /**\n * Called to create a hierarchy level definition when the node key check passes (see `customParentNodeKey`).\n */\n definitions: (requestProps: DefineCustomNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n}\n\n/**\n * A hierarchy level definition associated with either parent instance node's class or custom\n * node's key.\n */\ntype ClassBasedHierarchyLevelDefinition = InstancesNodeChildHierarchyLevelDefinition | CustomNodeChildHierarchyLevelDefinition;\n\n/**\n * Props for defining root hierarchy level.\n * @see `createClassBasedHierarchyDefinition`\n * @beta\n */\nexport type DefineRootHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\">;\n\n/**\n * Props for `createClassBasedHierarchyDefinition`.\n */\ninterface ClassBasedHierarchyDefinitionProps {\n /** Access to ECClass hierarchy in the iModel */\n classHierarchyInspector: ECClassHierarchyInspector;\n\n /** Hierarchy level definitions based on parent instance node's class or custom node's key. */\n hierarchy: {\n /** Called to create the root hierarchy level definition. */\n rootNodes: (props: DefineRootHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n\n /**\n * Called to get child hierarchy level definitions based on parent instance node's class\n * or custom node's key.\n */\n childNodes: ClassBasedHierarchyLevelDefinition[];\n };\n}\n\n/**\n * Creates an instance of `HierarchyDefinition` that uses a somewhat declarative approach to define the\n * hierarchy - each hierarchy level is assigned either an instance node's class or custom node's\n * key and they're used to assign hierarchy level definitions based on parent node.\n *\n * @beta\n */\nexport function createClassBasedHierarchyDefinition(props: ClassBasedHierarchyDefinitionProps): HierarchyDefinition {\n return new ClassBasedHierarchyDefinition(props);\n}\n\nclass ClassBasedHierarchyDefinition implements HierarchyDefinition {\n public constructor(private _props: ClassBasedHierarchyDefinitionProps) {}\n\n /**\n * Create hierarchy level definitions for specific hierarchy level.\n * @param parentNode Parent node to create children definitions for.\n */\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const { parentNode } = props;\n if (!parentNode) {\n return this._props.hierarchy.rootNodes(props);\n }\n\n if (HierarchyNode.isCustom(parentNode)) {\n const defs = this._props.hierarchy.childNodes\n .filter(isCustomNodeChildHierarchyLevelDefinition)\n .filter((def) => def.customParentNodeKey === parentNode.key);\n return (await Promise.all(defs.map(async (def) => def.definitions({ ...props, parentNode })))).flat();\n }\n\n // istanbul ignore else\n if (HierarchyNode.isInstancesNode(parentNode)) {\n const instanceIdsByClass = groupInstanceIdsByClass(parentNode.key.instanceKeys);\n const instancesParentNodeDefs = this._props.hierarchy.childNodes.filter(isInstancesNodeChildHierarchyLevelDefinition);\n return (\n await Promise.all(\n [...instanceIdsByClass.entries()].map(async ([parentNodeClassName, parentNodeInstanceIds]) =>\n createHierarchyLevelDefinitions(this._props.classHierarchyInspector, instancesParentNodeDefs, {\n ...props,\n parentNodeClassName,\n parentNodeInstanceIds,\n parentNode,\n }),\n ),\n )\n ).flat();\n }\n\n // istanbul ignore next\n return [];\n }\n}\n\nasync function createHierarchyLevelDefinitions(\n classHierarchy: ECClassHierarchyInspector,\n defs: InstancesNodeChildHierarchyLevelDefinition[],\n requestProps: DefineInstanceNodeChildHierarchyLevelProps,\n) {\n return (\n await Promise.all(\n defs.map(async (def) => {\n if (await classHierarchy.classDerivesFrom(requestProps.parentNodeClassName, def.parentNodeClassName)) {\n return def.definitions(requestProps);\n }\n return [];\n }),\n )\n ).flat();\n}\n\nfunction groupInstanceIdsByClass(instanceKeys: InstanceKey[]) {\n const instanceIdsByClass = new Map<string, Id64String[]>();\n instanceKeys.forEach((key) => {\n let instanceIds = instanceIdsByClass.get(key.className);\n if (!instanceIds) {\n instanceIds = [];\n instanceIdsByClass.set(key.className, instanceIds);\n }\n instanceIds.push(key.id);\n });\n return instanceIdsByClass;\n}\n\nfunction isCustomNodeChildHierarchyLevelDefinition(def: ClassBasedHierarchyLevelDefinition): def is CustomNodeChildHierarchyLevelDefinition {\n return !!(def as CustomNodeChildHierarchyLevelDefinition).customParentNodeKey;\n}\n\nfunction isInstancesNodeChildHierarchyLevelDefinition(def: ClassBasedHierarchyLevelDefinition): def is InstancesNodeChildHierarchyLevelDefinition {\n return !!(def as InstancesNodeChildHierarchyLevelDefinition).parentNodeClassName;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HierarchyDefinition.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAKhG,OAAO,EACL,aAAa,GAOd,MAAM,iBAAiB,CAAC;AA6BzB,YAAY;AACZ,2DAA2D;AAC3D,MAAM,KAAW,wBAAwB,CAOxC;AAPD,WAAiB,wBAAwB;IACvC,SAAgB,YAAY,CAAC,GAA6B;QACxD,OAAO,CAAC,CAAE,GAAqC,CAAC,IAAI,CAAC;IACvD,CAAC;IAFe,qCAAY,eAE3B,CAAA;IACD,SAAgB,oBAAoB,CAAC,GAA6B;QAChE,OAAO,CAAC,CAAE,GAAoC,CAAC,KAAK,CAAC;IACvD,CAAC;IAFe,6CAAoB,uBAEnC,CAAA;AACH,CAAC,EAPgB,wBAAwB,KAAxB,wBAAwB,QAOxC;AAsMD;;;;;;GAMG;AACH,MAAM,UAAU,mCAAmC,CAAC,KAAyC;IAC3F,OAAO,IAAI,6BAA6B,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,6BAA6B;IACN;IAA3B,YAA2B,MAA0C;QAA1C,WAAM,GAAN,MAAM,CAAoC;IAAG,CAAC;IAEzE;;;OAGG;IACI,KAAK,CAAC,oBAAoB,CAAC,KAAgC;QAChE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU;iBAC1C,M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Ac,CAAC,gBAAgB,CAAC,YAAY,CAAC,mBAAmB,EAAE,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACrG,OAAO,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CACH,CACF,CAAC,IAAI,EAAE,CAAC;AACX,CAAC;AAED,SAAS,uBAAuB,CAAC,YAA2B;IAC1D,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3D,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC3B,IAAI,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,WAAW,GAAG,EAAE,CAAC;YACjB,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACrD,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,SAAS,yCAAyC,CAAC,GAAuC;IACxF,OAAO,CAAC,CAAE,GAA+C,CAAC,mBAAmB,CAAC;AAChF,CAAC;AAED,SAAS,4CAA4C,CAAC,GAAuC;IAC3F,OAAO,CAAC,CAAE,GAAkD,CAAC,mBAAmB,CAAC;AACnF,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 { Id64String } from \"@itwin/core-bentley\";\nimport { GenericInstanceFilter } from \"@itwin/core-common\";\nimport { ECClassHierarchyInspector, ECSqlQueryDef, InstanceKey } from \"@itwin/presentation-shared\";\nimport {\n HierarchyNode,\n NonGroupingHierarchyNode,\n ParsedCustomHierarchyNode,\n ParsedInstanceHierarchyNode,\n ProcessedCustomHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n} from \"./HierarchyNode\";\nimport { InstancesNodeKey } from \"./HierarchyNodeKey\";\n\n/** A nodes definition that returns a single custom defined node. */\nexport interface CustomHierarchyNodeDefinition {\n /** The node to be created in the hierarchy level */\n node: ParsedCustomHierarchyNode;\n}\n\n/** A nodes definition that returns an ECSQL query for selecting nodes from an iModel. */\nexport interface InstanceNodesQueryDefinition {\n /**\n * Full name of the class whose instances are going to be returned. It's okay if the attribute\n * points to a base class of multiple different classes of instances returned by the query, however\n * the more specific this class is, the more efficient hierarchy building process is.\n */\n fullClassName: string;\n /**\n * An ECSQL query that selects nodes from an iModel. `SELECT` clause of the query is expected\n * to be built using `NodeSelectQueryFactory.createSelectClause`.\n */\n query: ECSqlQueryDef;\n}\n\n/**\n * A definition of nodes included in a hierarchy level.\n * @beta\n */\nexport type HierarchyNodesDefinition = CustomHierarchyNodeDefinition | InstanceNodesQueryDefinition;\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodesDefinition {\n export function isCustomNode(def: HierarchyNodesDefinition): def is CustomHierarchyNodeDefinition {\n return !!(def as CustomHierarchyNodeDefinition).node;\n }\n export function isInstanceNodesQuery(def: HierarchyNodesDefinition): def is InstanceNodesQueryDefinition {\n return !!(def as InstanceNodesQueryDefinition).query;\n }\n}\n\n/**\n * A definition of a hierarchy level, which may consist of multiple node definitions.\n * @beta\n */\nexport type HierarchyLevelDefinition = HierarchyNodesDefinition[];\n\n/**\n * A type for a function that parses a `ParsedInstanceHierarchyNode` from provided ECSQL `row` object.\n * @beta\n */\nexport type NodeParser = (row: { [columnName: string]: any }) => ParsedInstanceHierarchyNode;\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 * @beta\n */\nexport type NodePreProcessor = <TNode extends ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode>(node: TNode) => Promise<TNode | undefined>;\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 * @beta\n */\nexport type NodePostProcessor = (node: ProcessedHierarchyNode) => Promise<ProcessedHierarchyNode>;\n\n/**\n * A type of node that can be passed to `HierarchyDefinition.defineHierarchyLevel`. This basically means\n * a `HierarchyNode` that:\n * - knows nothing about its children,\n * - is either an instances node (key is of `InstancesNodeKey` type) or a custom node (key is of `string` type).\n */\ntype HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, \"children\">;\n\n/**\n * Props for `HierarchyDefinition.defineHierarchyLevel`.\n * @beta\n */\nexport interface DefineHierarchyLevelProps {\n /** Parent node to get children for. Pass `undefined` to get root nodes. */\n parentNode: HierarchyDefinitionParentNode | undefined;\n\n /** Optional hierarchy level filter. */\n instanceFilter?: GenericInstanceFilter;\n}\n\n/**\n * An interface for a factory that knows how define a hierarchy based on a given parent node.\n * @beta\n */\nexport interface HierarchyDefinition {\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?: NodeParser;\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?: NodePreProcessor;\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?: NodePostProcessor;\n\n /** A function to create a hierarchy level definition for given parent node. */\n defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;\n}\n\n/**\n * Props for defining child hierarchy level for specific parent instance node.\n * @see `createClassBasedHierarchyDefinition`\n * @beta\n */\nexport type DefineInstanceNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\"> & {\n /** The parent instance node. */\n parentNode: Omit<HierarchyDefinitionParentNode, \"key\"> & { key: InstancesNodeKey };\n\n /**\n * Full name of the parent instance node class.\n *\n * The `parentNode.key` also contains information about the instances the parent node is based on. However,\n * an instance node may be based on instances of multiple classes. In case that happens, parent node's instance\n * keys are grouped by class and a hierarchy level definition is requested for each combination of class and\n * instance IDs (with the same `parentNode`).\n */\n parentNodeClassName: string;\n\n /**\n * ECInstanceIds of the parent instance node.\n *\n * The `parentNode.key` also contains information about the instances the parent node is based on. However,\n * an instance node may be based on instances of multiple classes. In case that happens, parent node's instance\n * keys are grouped by class and a hierarchy level definition is requested for each combination of class and\n * instance IDs (with the same `parentNode`).\n */\n parentNodeInstanceIds: Id64String[];\n};\n\n/**\n * A definition of a hierarchy level that should be used for specific class of parent instance nodes.\n */\ninterface InstancesNodeChildHierarchyLevelDefinition {\n /**\n * Full name of the parent instance node's class to match against when checking if this hierarchy\n * level should be used for specific parent instance node.\n *\n * The check is polymorphic, so `BisCore.Element` class would match `BisCore.GeometricElement`, `BisCore.Category` and\n * all other element classes.\n */\n parentNodeClassName: string;\n\n /**\n * Called to create a hierarchy level definition when the class check passes (see `parentNodeClassName`).\n */\n definitions: (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n}\n\n/**\n * Props for defining child hierarchy level for specific parent custom node.\n * @see `createClassBasedHierarchyDefinition`\n * @beta\n */\nexport type DefineCustomNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\"> & {\n /** The parent custom node. */\n parentNode: Omit<HierarchyDefinitionParentNode, \"key\"> & { key: string };\n};\n\n/**\n * A definition of a hierarchy level for that should be used for specific custom parent nodes.\n */\ninterface CustomNodeChildHierarchyLevelDefinition {\n /**\n * `HierarchyNode.key` of the custom node that this child hierarchy level definition should be used for.\n */\n customParentNodeKey: string;\n\n /**\n * Called to create a hierarchy level definition when the node key check passes (see `customParentNodeKey`).\n */\n definitions: (requestProps: DefineCustomNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n}\n\n/**\n * A hierarchy level definition associated with either parent instance node's class or custom\n * node's key.\n */\ntype ClassBasedHierarchyLevelDefinition = InstancesNodeChildHierarchyLevelDefinition | CustomNodeChildHierarchyLevelDefinition;\n\n/**\n * Props for defining root hierarchy level.\n * @see `createClassBasedHierarchyDefinition`\n * @beta\n */\nexport type DefineRootHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\">;\n\n/**\n * Props for `createClassBasedHierarchyDefinition`.\n */\ninterface ClassBasedHierarchyDefinitionProps {\n /** Access to ECClass hierarchy in the iModel */\n classHierarchyInspector: ECClassHierarchyInspector;\n\n /** Hierarchy level definitions based on parent instance node's class or custom node's key. */\n hierarchy: {\n /** Called to create the root hierarchy level definition. */\n rootNodes: (props: DefineRootHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n\n /**\n * Called to get child hierarchy level definitions based on parent instance node's class\n * or custom node's key.\n */\n childNodes: ClassBasedHierarchyLevelDefinition[];\n };\n}\n\n/**\n * Creates an instance of `HierarchyDefinition` that uses a somewhat declarative approach to define the\n * hierarchy - each hierarchy level is assigned either an instance node's class or custom node's\n * key and they're used to assign hierarchy level definitions based on parent node.\n *\n * @beta\n */\nexport function createClassBasedHierarchyDefinition(props: ClassBasedHierarchyDefinitionProps): HierarchyDefinition {\n return new ClassBasedHierarchyDefinition(props);\n}\n\nclass ClassBasedHierarchyDefinition implements HierarchyDefinition {\n public constructor(private _props: ClassBasedHierarchyDefinitionProps) {}\n\n /**\n * Create hierarchy level definitions for specific hierarchy level.\n * @param parentNode Parent node to create children definitions for.\n */\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const { parentNode } = props;\n if (!parentNode) {\n return this._props.hierarchy.rootNodes(props);\n }\n\n if (HierarchyNode.isCustom(parentNode)) {\n const defs = this._props.hierarchy.childNodes\n .filter(isCustomNodeChildHierarchyLevelDefinition)\n .filter((def) => def.customParentNodeKey === parentNode.key);\n return (await Promise.all(defs.map(async (def) => def.definitions({ ...props, parentNode })))).flat();\n }\n\n // istanbul ignore else\n if (HierarchyNode.isInstancesNode(parentNode)) {\n const instanceIdsByClass = groupInstanceIdsByClass(parentNode.key.instanceKeys);\n const instancesParentNodeDefs = this._props.hierarchy.childNodes.filter(isInstancesNodeChildHierarchyLevelDefinition);\n return (\n await Promise.all(\n [...instanceIdsByClass.entries()].map(async ([parentNodeClassName, parentNodeInstanceIds]) =>\n createHierarchyLevelDefinitions(this._props.classHierarchyInspector, instancesParentNodeDefs, {\n ...props,\n parentNodeClassName,\n parentNodeInstanceIds,\n parentNode,\n }),\n ),\n )\n ).flat();\n }\n\n // istanbul ignore next\n return [];\n }\n}\n\nasync function createHierarchyLevelDefinitions(\n classHierarchy: ECClassHierarchyInspector,\n defs: InstancesNodeChildHierarchyLevelDefinition[],\n requestProps: DefineInstanceNodeChildHierarchyLevelProps,\n) {\n return (\n await Promise.all(\n defs.map(async (def) => {\n if (await classHierarchy.classDerivesFrom(requestProps.parentNodeClassName, def.parentNodeClassName)) {\n return def.definitions(requestProps);\n }\n return [];\n }),\n )\n ).flat();\n}\n\nfunction groupInstanceIdsByClass(instanceKeys: InstanceKey[]) {\n const instanceIdsByClass = new Map<string, Id64String[]>();\n instanceKeys.forEach((key) => {\n let instanceIds = instanceIdsByClass.get(key.className);\n if (!instanceIds) {\n instanceIds = [];\n instanceIdsByClass.set(key.className, instanceIds);\n }\n instanceIds.push(key.id);\n });\n return instanceIdsByClass;\n}\n\nfunction isCustomNodeChildHierarchyLevelDefinition(def: ClassBasedHierarchyLevelDefinition): def is CustomNodeChildHierarchyLevelDefinition {\n return !!(def as CustomNodeChildHierarchyLevelDefinition).customParentNodeKey;\n}\n\nfunction isInstancesNodeChildHierarchyLevelDefinition(def: ClassBasedHierarchyLevelDefinition): def is InstancesNodeChildHierarchyLevelDefinition {\n return !!(def as InstancesNodeChildHierarchyLevelDefinition).parentNodeClassName;\n}\n"]}
|
|
@@ -120,8 +120,6 @@ export declare namespace HierarchyNode {
|
|
|
120
120
|
/**
|
|
121
121
|
* A type of `HierarchyNode` that doesn't know about its children and is an input when requesting
|
|
122
122
|
* them using `HierarchyProvider.getNodes`.
|
|
123
|
-
*
|
|
124
|
-
* @internal
|
|
125
123
|
*/
|
|
126
124
|
export type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, "children">;
|
|
127
125
|
/**
|
|
@@ -163,15 +161,9 @@ interface HierarchyNodeLabelGroupingMergeParams extends HierarchyNodeLabelGroupi
|
|
|
163
161
|
interface HierarchyNodeLabelGroupingGroupParams extends HierarchyNodeLabelGroupingBaseParams, HierarchyNodeGroupingParamsBase {
|
|
164
162
|
action?: "group";
|
|
165
163
|
}
|
|
166
|
-
/**
|
|
167
|
-
* A data structure for defining possible label grouping types.
|
|
168
|
-
* @internal
|
|
169
|
-
*/
|
|
164
|
+
/** A data structure for defining possible label grouping types. */
|
|
170
165
|
export type HierarchyNodeLabelGroupingParams = boolean | HierarchyNodeLabelGroupingMergeParams | HierarchyNodeLabelGroupingGroupParams;
|
|
171
|
-
/**
|
|
172
|
-
* Grouping parameters that are shared across all types of groupings.
|
|
173
|
-
* @internal
|
|
174
|
-
*/
|
|
166
|
+
/** Grouping parameters that are shared across all types of groupings. */
|
|
175
167
|
export interface HierarchyNodeGroupingParamsBase {
|
|
176
168
|
/** Hiding option that determines whether to hide group nodes which have no siblings at the same hierarchy level. */
|
|
177
169
|
hideIfNoSiblings?: boolean;
|
|
@@ -184,8 +176,6 @@ export interface HierarchyNodeGroupingParamsBase {
|
|
|
184
176
|
* Defines possible values for `BaseGroupingParams.autoExpand` attribute:
|
|
185
177
|
* - `single-child` - set the grouping node to auto-expand if it groups a single node.
|
|
186
178
|
* - `always` - always set the grouping node to auto-expand.
|
|
187
|
-
*
|
|
188
|
-
* @internal
|
|
189
179
|
*/
|
|
190
180
|
export type HierarchyNodeAutoExpandProp = "single-child" | "always";
|
|
191
181
|
/**
|
|
@@ -200,10 +190,7 @@ interface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingPara
|
|
|
200
190
|
*/
|
|
201
191
|
fullClassNames: string[];
|
|
202
192
|
}
|
|
203
|
-
/**
|
|
204
|
-
* A data structure that represents properties grouping.
|
|
205
|
-
* @internal
|
|
206
|
-
*/
|
|
193
|
+
/** A data structure that represents properties grouping. */
|
|
207
194
|
export interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGroupingParamsBase {
|
|
208
195
|
/**
|
|
209
196
|
* Full name of a class whose properties are used to group the node. Only has effect if the node
|
|
@@ -249,10 +236,7 @@ export interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGrou
|
|
|
249
236
|
*/
|
|
250
237
|
propertyGroups: HierarchyNodePropertyGroup[];
|
|
251
238
|
}
|
|
252
|
-
/**
|
|
253
|
-
* A data structure that represents specific properties' grouping params.
|
|
254
|
-
* @internal
|
|
255
|
-
*/
|
|
239
|
+
/** A data structure that represents specific properties' grouping params. */
|
|
256
240
|
export interface HierarchyNodePropertyGroup {
|
|
257
241
|
/** A string indicating the name of the property to group by. */
|
|
258
242
|
propertyName: string;
|
|
@@ -261,10 +245,7 @@ export interface HierarchyNodePropertyGroup {
|
|
|
261
245
|
/** Ranges are used to group nodes by numeric properties which are within specified bounds. */
|
|
262
246
|
ranges?: HierarchyNodePropertyValueRange[];
|
|
263
247
|
}
|
|
264
|
-
/**
|
|
265
|
-
* A data structure that represents boundaries for a value.
|
|
266
|
-
* @internal
|
|
267
|
-
*/
|
|
248
|
+
/** A data structure that represents boundaries for a value. */
|
|
268
249
|
export interface HierarchyNodePropertyValueRange {
|
|
269
250
|
/** Defines the lower bound of the range. */
|
|
270
251
|
fromValue: number;
|
|
@@ -273,35 +254,23 @@ export interface HierarchyNodePropertyValueRange {
|
|
|
273
254
|
/** Defines the range label. Will be used as `PropertyValueRangeGroupingNode` node's display label. */
|
|
274
255
|
rangeLabel?: string;
|
|
275
256
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Processing parameters that apply to instance nodes.
|
|
278
|
-
* @internal
|
|
279
|
-
*/
|
|
257
|
+
/** Processing parameters that apply to instance nodes. */
|
|
280
258
|
export interface InstanceHierarchyNodeProcessingParams extends HierarchyNodeProcessingParamsBase {
|
|
281
259
|
grouping?: HierarchyNodeGroupingParams;
|
|
282
260
|
}
|
|
283
|
-
/**
|
|
284
|
-
* A custom (not based on data in an iModel) node that has processing parameters.
|
|
285
|
-
* @internal
|
|
286
|
-
*/
|
|
261
|
+
/** A custom (not based on data in an iModel) node that has processing parameters. */
|
|
287
262
|
export type ProcessedCustomHierarchyNode = Omit<NonGroupingHierarchyNode, "key" | "children"> & {
|
|
288
263
|
key: string;
|
|
289
264
|
children?: boolean;
|
|
290
265
|
processingParams?: HierarchyNodeProcessingParamsBase;
|
|
291
266
|
};
|
|
292
|
-
/**
|
|
293
|
-
* An instances' (based on data in an iModel) node that has processing parameters.
|
|
294
|
-
* @internal
|
|
295
|
-
*/
|
|
267
|
+
/** An instances' (based on data in an iModel) node that has processing parameters. */
|
|
296
268
|
export type ProcessedInstanceHierarchyNode = Omit<NonGroupingHierarchyNode, "key" | "children"> & {
|
|
297
269
|
key: InstancesNodeKey;
|
|
298
270
|
children?: boolean;
|
|
299
271
|
processingParams?: InstanceHierarchyNodeProcessingParams;
|
|
300
272
|
};
|
|
301
|
-
/**
|
|
302
|
-
* A grouping node that groups either instance nodes or other grouping nodes.
|
|
303
|
-
* @internal
|
|
304
|
-
*/
|
|
273
|
+
/** A grouping node that groups either instance nodes or other grouping nodes. */
|
|
305
274
|
export type ProcessedGroupingHierarchyNode = Omit<GroupingHierarchyNode, "children"> & {
|
|
306
275
|
children: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;
|
|
307
276
|
};
|
|
@@ -323,15 +292,9 @@ export type ProcessedHierarchyNode = ProcessedCustomHierarchyNode | ProcessedIns
|
|
|
323
292
|
export type ParsedHierarchyNode<TBase = ParsedCustomHierarchyNode | ParsedInstanceHierarchyNode> = OmitOverUnion<TBase, "label" | "parentKeys"> & {
|
|
324
293
|
label: string | ConcatenatedValue;
|
|
325
294
|
};
|
|
326
|
-
/**
|
|
327
|
-
* A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors.
|
|
328
|
-
* @internal
|
|
329
|
-
*/
|
|
295
|
+
/** A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors. */
|
|
330
296
|
export type ParsedCustomHierarchyNode = ParsedHierarchyNode<ProcessedCustomHierarchyNode>;
|
|
331
|
-
/**
|
|
332
|
-
* A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors.
|
|
333
|
-
* @internal
|
|
334
|
-
*/
|
|
297
|
+
/** A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors. */
|
|
335
298
|
export type ParsedInstanceHierarchyNode = ParsedHierarchyNode<ProcessedInstanceHierarchyNode>;
|
|
336
299
|
export {};
|
|
337
300
|
//# sourceMappingURL=HierarchyNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyNode.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC3G,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,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E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAIX,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IANe,8CAAgC,mCAM/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAIX,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IANe,oCAAsB,yBAMrC,CAAA;AACH,CAAC,EAvEgB,aAAa,KAAb,aAAa,QAuE7B","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 { ConcatenatedValue, InstanceKey, OmitOverUnion, PrimitiveValue } from \"@itwin/presentation-shared\";\nimport {\n ClassGroupingNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n StandardHierarchyNodeKey,\n} from \"./HierarchyNodeKey\";\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @beta\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: string | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @beta\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: InstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @beta\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a custom node */\n export function isCustom<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedCustomHierarchyNode : NonGroupingHierarchyNode) & { key: string } {\n return HierarchyNodeKey.isCustom(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isStandard<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: StandardHierarchyNodeKey } {\n return HierarchyNodeKey.isStandard(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedInstanceHierarchyNode : NonGroupingHierarchyNode) & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedGroupingHierarchyNode : GroupingHierarchyNode) {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n *\n * @internal\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n\n/**\n * Base processing parameters that apply to every node.\n */\ninterface HierarchyNodeProcessingParamsBase {\n /** Indicates if this node should be hidden if it has no child nodes. */\n hideIfNoChildren?: boolean;\n /** Indicates that this node should always be hidden and its children should be loaded in its place. */\n hideInHierarchy?: boolean;\n}\n\n/**\n * A data structure for defining nodes' grouping requirements.\n */\ninterface HierarchyNodeGroupingParams {\n byLabel?: HierarchyNodeLabelGroupingParams;\n byClass?: boolean | HierarchyNodeGroupingParamsBase;\n byBaseClasses?: HierarchyNodeBaseClassGroupingParams;\n byProperties?: HierarchyNodePropertiesGroupingParams;\n}\n\n/**\n * A data structure for defining params specifically used for label grouping.\n */\ninterface HierarchyNodeLabelGroupingBaseParams {\n /** Label grouping option that determines whether to group nodes or to merge them. Defaults to \"group\".*/\n action?: \"group\" | \"merge\";\n /** Value that needs to match in order for nodes to be grouped or merged.*/\n groupId?: string;\n}\n\n/**\n * A data structure for defining label merging.\n */\ninterface HierarchyNodeLabelGroupingMergeParams extends HierarchyNodeLabelGroupingBaseParams {\n action: \"merge\";\n}\n\n/**\n * A data structure for defining label grouping with additional parameters.\n */\ninterface HierarchyNodeLabelGroupingGroupParams extends HierarchyNodeLabelGroupingBaseParams, HierarchyNodeGroupingParamsBase {\n action?: \"group\";\n}\n\n/**\n * A data structure for defining possible label grouping types.\n * @internal\n */\nexport type HierarchyNodeLabelGroupingParams = boolean | HierarchyNodeLabelGroupingMergeParams | HierarchyNodeLabelGroupingGroupParams;\n\n/**\n * Grouping parameters that are shared across all types of groupings.\n * @internal\n */\nexport interface HierarchyNodeGroupingParamsBase {\n /** Hiding option that determines whether to hide group nodes which have no siblings at the same hierarchy level. */\n hideIfNoSiblings?: boolean;\n /** Hiding option that determines whether to hide group nodes which have only one node as its children. */\n hideIfOneGroupedNode?: boolean;\n /** Option which auto expands grouping nodes' children when it has single child or always. */\n autoExpand?: HierarchyNodeAutoExpandProp;\n}\n\n/**\n * Defines possible values for `BaseGroupingParams.autoExpand` attribute:\n * - `single-child` - set the grouping node to auto-expand if it groups a single node.\n * - `always` - always set the grouping node to auto-expand.\n *\n * @internal\n */\nexport type HierarchyNodeAutoExpandProp = \"single-child\" | \"always\";\n\n/**\n * A data structure that represents base class grouping.\n */\ninterface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full names of classes, which should be used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n fullClassNames: string[];\n}\n\n/**\n * A data structure that represents properties grouping.\n * @internal\n */\nexport interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full name of a class whose properties are used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n propertiesClassName: string;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value is not set or is set to an empty string.\n *\n * Label of the created grouping node will be `Not Specified`.\n */\n createGroupForUnspecifiedValues?: boolean;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value doesn't fit within any of the provided\n * ranges, or is not a numeric value.\n *\n * Label of the created grouping node will be `Other`.\n */\n createGroupForOutOfRangeValues?: boolean;\n /**\n * Properties of the specified class, by which the nodes should be grouped. Each provided group definition results in a\n * grouping hierarchy level.\n *\n * Example usage:\n * ```ts\n * propertyGroups: [\n * {\n * propertyName: \"type\",\n * propertyValue: \"Wall\"\n * },\n * {\n * propertyName: \"length\",\n * propertyValue: 15,\n * ranges: [\n * { fromValue: 1, toValue: 10, rangeLabel: \"Small\" },\n * { fromValue: 11, toValue: 20, rangeLabel: \"Medium\" }\n * ]\n * },\n * ]\n * ```\n */\n propertyGroups: HierarchyNodePropertyGroup[];\n}\n\n/**\n * A data structure that represents specific properties' grouping params.\n * @internal\n */\nexport interface HierarchyNodePropertyGroup {\n /** A string indicating the name of the property to group by. */\n propertyName: string;\n /** Value of the property, which will be used to group the node. */\n propertyValue?: PrimitiveValue;\n /** Ranges are used to group nodes by numeric properties which are within specified bounds. */\n ranges?: HierarchyNodePropertyValueRange[];\n}\n\n/**\n * A data structure that represents boundaries for a value.\n * @internal\n */\nexport interface HierarchyNodePropertyValueRange {\n /** Defines the lower bound of the range. */\n fromValue: number;\n /** Defines the upper bound of the range. */\n toValue: number;\n /** Defines the range label. Will be used as `PropertyValueRangeGroupingNode` node's display label. */\n rangeLabel?: string;\n}\n\n/**\n * Processing parameters that apply to instance nodes.\n * @internal\n */\nexport interface InstanceHierarchyNodeProcessingParams extends HierarchyNodeProcessingParamsBase {\n grouping?: HierarchyNodeGroupingParams;\n}\n\n/**\n * A custom (not based on data in an iModel) node that has processing parameters.\n * @internal\n */\nexport type ProcessedCustomHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: string;\n children?: boolean;\n processingParams?: HierarchyNodeProcessingParamsBase;\n};\n/**\n * An instances' (based on data in an iModel) node that has processing parameters.\n * @internal\n */\nexport type ProcessedInstanceHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: InstancesNodeKey;\n children?: boolean;\n processingParams?: InstanceHierarchyNodeProcessingParams;\n};\n/**\n * A grouping node that groups either instance nodes or other grouping nodes.\n * @internal\n */\nexport type ProcessedGroupingHierarchyNode = Omit<GroupingHierarchyNode, \"children\"> & {\n children: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n};\n/**\n * A `HierarchyNode` that may have processing parameters defining whether it should be hidden under some conditions,\n * how it should be grouped, sorted, etc.\n *\n * Type guards under `HierarchyNode` namespace can be used to differentiate between different sub-types of\n * `ProcessedHierarchyNode`.\n *\n * @beta\n */\nexport type ProcessedHierarchyNode = ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode | ProcessedGroupingHierarchyNode;\n\n/**\n * A `ProcessedHierarchyNode` that has an unformatted label in a form of `ConcatenatedValue`. Generally this is\n * returned when the node is just parsed from query results.\n * @beta\n */\nexport type ParsedHierarchyNode<TBase = ParsedCustomHierarchyNode | ParsedInstanceHierarchyNode> = OmitOverUnion<TBase, \"label\" | \"parentKeys\"> & {\n label: string | ConcatenatedValue;\n};\n/**\n * A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors.\n * @internal\n */\nexport type ParsedCustomHierarchyNode = ParsedHierarchyNode<ProcessedCustomHierarchyNode>;\n/**\n * A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors.\n * @internal\n */\nexport type ParsedInstanceHierarchyNode = ParsedHierarchyNode<ProcessedInstanceHierarchyNode>;\n"]}
|
|
1
|
+
{"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAGL,gBAAgB,GAQjB,MAAM,oBAAoB,CAAC;AAwD5B,YAAY;AACZ,2DAA2D;AAC3D,MAAM,KAAW,aAAa,CAuE7B;AAvED,WAAiB,aAAa;IAC5B,qDAAqD;IACrD,SAAgB,QAAQ,CACtB,IAAW;QAEX,OAAO,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAJe,sBAAQ,WAIvB,CAAA;IACD,8EAA8E;IAC9E,SAAgB,UAAU,CAA0C,IAAW;QAC7E,OAAO,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAFe,wBAAU,aAEzB,CAAA;IACD,iEAAiE;IACjE,SAAgB,eAAe,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AC,EAvEgB,aAAa,KAAb,aAAa,QAuE7B","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 { ConcatenatedValue, InstanceKey, OmitOverUnion, PrimitiveValue } from \"@itwin/presentation-shared\";\nimport {\n ClassGroupingNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n StandardHierarchyNodeKey,\n} from \"./HierarchyNodeKey\";\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @beta\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: string | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @beta\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: InstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @beta\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a custom node */\n export function isCustom<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedCustomHierarchyNode : NonGroupingHierarchyNode) & { key: string } {\n return HierarchyNodeKey.isCustom(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isStandard<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: StandardHierarchyNodeKey } {\n return HierarchyNodeKey.isStandard(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedInstanceHierarchyNode : NonGroupingHierarchyNode) & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedGroupingHierarchyNode : GroupingHierarchyNode) {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n\n/**\n * Base processing parameters that apply to every node.\n */\ninterface HierarchyNodeProcessingParamsBase {\n /** Indicates if this node should be hidden if it has no child nodes. */\n hideIfNoChildren?: boolean;\n /** Indicates that this node should always be hidden and its children should be loaded in its place. */\n hideInHierarchy?: boolean;\n}\n\n/**\n * A data structure for defining nodes' grouping requirements.\n */\ninterface HierarchyNodeGroupingParams {\n byLabel?: HierarchyNodeLabelGroupingParams;\n byClass?: boolean | HierarchyNodeGroupingParamsBase;\n byBaseClasses?: HierarchyNodeBaseClassGroupingParams;\n byProperties?: HierarchyNodePropertiesGroupingParams;\n}\n\n/**\n * A data structure for defining params specifically used for label grouping.\n */\ninterface HierarchyNodeLabelGroupingBaseParams {\n /** Label grouping option that determines whether to group nodes or to merge them. Defaults to \"group\".*/\n action?: \"group\" | \"merge\";\n /** Value that needs to match in order for nodes to be grouped or merged.*/\n groupId?: string;\n}\n\n/**\n * A data structure for defining label merging.\n */\ninterface HierarchyNodeLabelGroupingMergeParams extends HierarchyNodeLabelGroupingBaseParams {\n action: \"merge\";\n}\n\n/**\n * A data structure for defining label grouping with additional parameters.\n */\ninterface HierarchyNodeLabelGroupingGroupParams extends HierarchyNodeLabelGroupingBaseParams, HierarchyNodeGroupingParamsBase {\n action?: \"group\";\n}\n\n/** A data structure for defining possible label grouping types. */\nexport type HierarchyNodeLabelGroupingParams = boolean | HierarchyNodeLabelGroupingMergeParams | HierarchyNodeLabelGroupingGroupParams;\n\n/** Grouping parameters that are shared across all types of groupings. */\nexport interface HierarchyNodeGroupingParamsBase {\n /** Hiding option that determines whether to hide group nodes which have no siblings at the same hierarchy level. */\n hideIfNoSiblings?: boolean;\n /** Hiding option that determines whether to hide group nodes which have only one node as its children. */\n hideIfOneGroupedNode?: boolean;\n /** Option which auto expands grouping nodes' children when it has single child or always. */\n autoExpand?: HierarchyNodeAutoExpandProp;\n}\n\n/**\n * Defines possible values for `BaseGroupingParams.autoExpand` attribute:\n * - `single-child` - set the grouping node to auto-expand if it groups a single node.\n * - `always` - always set the grouping node to auto-expand.\n */\nexport type HierarchyNodeAutoExpandProp = \"single-child\" | \"always\";\n\n/**\n * A data structure that represents base class grouping.\n */\ninterface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full names of classes, which should be used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n fullClassNames: string[];\n}\n\n/** A data structure that represents properties grouping. */\nexport interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full name of a class whose properties are used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n propertiesClassName: string;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value is not set or is set to an empty string.\n *\n * Label of the created grouping node will be `Not Specified`.\n */\n createGroupForUnspecifiedValues?: boolean;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value doesn't fit within any of the provided\n * ranges, or is not a numeric value.\n *\n * Label of the created grouping node will be `Other`.\n */\n createGroupForOutOfRangeValues?: boolean;\n /**\n * Properties of the specified class, by which the nodes should be grouped. Each provided group definition results in a\n * grouping hierarchy level.\n *\n * Example usage:\n * ```ts\n * propertyGroups: [\n * {\n * propertyName: \"type\",\n * propertyValue: \"Wall\"\n * },\n * {\n * propertyName: \"length\",\n * propertyValue: 15,\n * ranges: [\n * { fromValue: 1, toValue: 10, rangeLabel: \"Small\" },\n * { fromValue: 11, toValue: 20, rangeLabel: \"Medium\" }\n * ]\n * },\n * ]\n * ```\n */\n propertyGroups: HierarchyNodePropertyGroup[];\n}\n\n/** A data structure that represents specific properties' grouping params. */\nexport interface HierarchyNodePropertyGroup {\n /** A string indicating the name of the property to group by. */\n propertyName: string;\n /** Value of the property, which will be used to group the node. */\n propertyValue?: PrimitiveValue;\n /** Ranges are used to group nodes by numeric properties which are within specified bounds. */\n ranges?: HierarchyNodePropertyValueRange[];\n}\n\n/** A data structure that represents boundaries for a value. */\nexport interface HierarchyNodePropertyValueRange {\n /** Defines the lower bound of the range. */\n fromValue: number;\n /** Defines the upper bound of the range. */\n toValue: number;\n /** Defines the range label. Will be used as `PropertyValueRangeGroupingNode` node's display label. */\n rangeLabel?: string;\n}\n\n/** Processing parameters that apply to instance nodes. */\nexport interface InstanceHierarchyNodeProcessingParams extends HierarchyNodeProcessingParamsBase {\n grouping?: HierarchyNodeGroupingParams;\n}\n\n/** A custom (not based on data in an iModel) node that has processing parameters. */\nexport type ProcessedCustomHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: string;\n children?: boolean;\n processingParams?: HierarchyNodeProcessingParamsBase;\n};\n/** An instances' (based on data in an iModel) node that has processing parameters. */\nexport type ProcessedInstanceHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: InstancesNodeKey;\n children?: boolean;\n processingParams?: InstanceHierarchyNodeProcessingParams;\n};\n/** A grouping node that groups either instance nodes or other grouping nodes. */\nexport type ProcessedGroupingHierarchyNode = Omit<GroupingHierarchyNode, \"children\"> & {\n children: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n};\n/**\n * A `HierarchyNode` that may have processing parameters defining whether it should be hidden under some conditions,\n * how it should be grouped, sorted, etc.\n *\n * Type guards under `HierarchyNode` namespace can be used to differentiate between different sub-types of\n * `ProcessedHierarchyNode`.\n *\n * @beta\n */\nexport type ProcessedHierarchyNode = ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode | ProcessedGroupingHierarchyNode;\n\n/**\n * A `ProcessedHierarchyNode` that has an unformatted label in a form of `ConcatenatedValue`. Generally this is\n * returned when the node is just parsed from query results.\n * @beta\n */\nexport type ParsedHierarchyNode<TBase = ParsedCustomHierarchyNode | ParsedInstanceHierarchyNode> = OmitOverUnion<TBase, \"label\" | \"parentKeys\"> & {\n label: string | ConcatenatedValue;\n};\n/** A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedCustomHierarchyNode = ParsedHierarchyNode<ProcessedCustomHierarchyNode>;\n/** A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedInstanceHierarchyNode = ParsedHierarchyNode<ProcessedInstanceHierarchyNode>;\n"]}
|