@itwin/presentation-hierarchies 0.1.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/README.md +13 -9
- package/lib/cjs/hierarchies/HierarchyDefinition.d.ts +31 -2
- package/lib/cjs/hierarchies/HierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyDefinition.js +6 -4
- package/lib/cjs/hierarchies/HierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +53 -11
- 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 +25 -6
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +2 -0
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts +14 -2
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.js +2 -2
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyDefinition.d.ts +31 -2
- package/lib/esm/hierarchies/HierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyDefinition.js +6 -4
- package/lib/esm/hierarchies/HierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.d.ts +53 -11
- 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 +25 -6
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +2 -0
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts +14 -2
- package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/NodeSelectQueryFactory.js +2 -2
- package/lib/esm/hierarchies/NodeSelectQueryFactory.js.map +1 -1
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#665](https://github.com/iTwin/presentation/pull/665): Remove the option to specify `ecClassId` and `ecInstanceId` in `NodesQueryClauseFactory.createSelectClause` as `Id64String`. Now they can only be specified as a selector object, e.g. `{ selector: "this.ECClassId" }`. In case a static string is needed, the selector can return one.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies:
|
|
12
|
+
- @itwin/presentation-shared@0.3.2
|
|
13
|
+
|
|
14
|
+
## 0.2.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [#642](https://github.com/iTwin/presentation/pull/642): Added `onlyIfNotHandled` flag to hierarchy level definitions that are passed to `createClassBasedHierarchyDefinition`.
|
|
19
|
+
This flag allows to skip instance node hierarchy level definitions if previous ones have defined hierarchy levels for a more specific class.
|
|
20
|
+
This can help to reduce repetition having to check if class doesn't match those of the more specific definitions.
|
|
21
|
+
|
|
22
|
+
Before:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
createClassBasedHierarchyDefinition({
|
|
26
|
+
classHierarchyInspector: inspector,
|
|
27
|
+
hierarchy: {
|
|
28
|
+
childNodes: [
|
|
29
|
+
{
|
|
30
|
+
parentNodeClassName: "BisCore.PhysicalElement",
|
|
31
|
+
definitions: async ({ parentNode }) => getPhysicalElementChildren(parentNode),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
parentNodeClassName: "BisCore.SpatialElement",
|
|
35
|
+
definitions: async ({ parentNode, parentNodeClassName }) => {
|
|
36
|
+
if (await inspector.classDerivesFrom(parentNodeClassName, "BisCore.PhysicalElement")) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return getSpatialElementChildren(parentNode);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
parentNodeClassName: "BisCore.GeometricElement3d",
|
|
45
|
+
definitions: async ({ parentNode, parentNodeClassName }) => {
|
|
46
|
+
if (await inspector.classDerivesFrom(parentNodeClassName, "BisCore.PhysicalElement")) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (await inspector.classDerivesFrom(parentNodeClassName, "BisCore.SpatialElement")) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return getGeometricElement3dChildren(parentNode);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
After:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
createClassBasedHierarchyDefinition({
|
|
66
|
+
classHierarchyInspector,
|
|
67
|
+
hierarchy: {
|
|
68
|
+
childNodes: [
|
|
69
|
+
{
|
|
70
|
+
parentNodeClassName: "BisCore.PhysicalElement",
|
|
71
|
+
definitions: async ({ parentNode }) => getPhysicalElementChildren(parentNode),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
parentNodeClassName: "BisCore.SpatialElement",
|
|
75
|
+
onlyIfNotHandled: true,
|
|
76
|
+
definitions: async ({ parentNode }) => getSpatialElementChildren(parentNode),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
parentNodeClassName: "BisCore.GeometricElement3d",
|
|
80
|
+
onlyIfNotHandled: true,
|
|
81
|
+
definitions: async ({ parentNode }) => getGeometricElement3dChildren(parentNode),
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
3
88
|
## 0.1.6
|
|
4
89
|
|
|
5
90
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -57,6 +57,9 @@ In iTwin.js, the most common way to create hierarchies is based on EC data (sche
|
|
|
57
57
|
|
|
58
58
|
Here's a simple example of how to create a hierarchy provider and build a hierarchy of Models and their Elements, with the latter grouped by class:
|
|
59
59
|
|
|
60
|
+
<!-- [[include: Presentation.Hierarchies.Readme.BasicExample, ts]] -->
|
|
61
|
+
<!-- BEGIN EXTRACTION -->
|
|
62
|
+
|
|
60
63
|
```ts
|
|
61
64
|
import { IModelConnection } from "@itwin/core-frontend";
|
|
62
65
|
import { SchemaContext } from "@itwin/ecschema-metadata";
|
|
@@ -109,10 +112,10 @@ function createProvider(imodel: IModelConnection): HierarchyProvider {
|
|
|
109
112
|
const hierarchyDefinition = createClassBasedHierarchyDefinition({
|
|
110
113
|
classHierarchyInspector: imodelAccess,
|
|
111
114
|
hierarchy: {
|
|
112
|
-
// for root nodes, select all
|
|
115
|
+
// for root nodes, select all BisCore.GeometricModel3d instances
|
|
113
116
|
rootNodes: async () => [
|
|
114
117
|
{
|
|
115
|
-
fullClassName: "BisCore.
|
|
118
|
+
fullClassName: "BisCore.GeometricModel3d",
|
|
116
119
|
query: {
|
|
117
120
|
ecsql: `
|
|
118
121
|
SELECT
|
|
@@ -120,18 +123,17 @@ function createProvider(imodel: IModelConnection): HierarchyProvider {
|
|
|
120
123
|
ecClassId: { selector: "this.ECClassId" },
|
|
121
124
|
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
122
125
|
nodeLabel: {
|
|
123
|
-
selector: await labelsQueryFactory.createSelectClause({ classAlias: "this", className: "BisCore.
|
|
126
|
+
selector: await labelsQueryFactory.createSelectClause({ classAlias: "this", className: "BisCore.GeometricModel3d" }),
|
|
124
127
|
},
|
|
125
128
|
})}
|
|
126
|
-
FROM BisCore.
|
|
127
|
-
WHERE this.ParentModel IS NULL
|
|
129
|
+
FROM BisCore.GeometricModel3d this
|
|
128
130
|
`,
|
|
129
131
|
},
|
|
130
132
|
},
|
|
131
133
|
],
|
|
132
134
|
childNodes: [
|
|
133
135
|
{
|
|
134
|
-
// for
|
|
136
|
+
// for BisCore.Model parent nodes, select all BisCore.Element instances contained in corresponding model
|
|
135
137
|
parentNodeClassName: "BisCore.Model",
|
|
136
138
|
definitions: async ({ parentNodeInstanceIds }: DefineInstanceNodeChildHierarchyLevelProps) => [
|
|
137
139
|
{
|
|
@@ -166,13 +168,15 @@ function createProvider(imodel: IModelConnection): HierarchyProvider {
|
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
async function main() {
|
|
169
|
-
const provider = createProvider(
|
|
171
|
+
const provider = createProvider(await getIModelConnection());
|
|
170
172
|
async function loadBranch(parentNode: HierarchyNode | undefined, indent: number = 0) {
|
|
171
173
|
for await (const node of provider.getNodes({ parentNode })) {
|
|
172
|
-
console.log(`${new Array(indent + 1).join(" ")}
|
|
173
|
-
await loadBranch(node);
|
|
174
|
+
console.log(`${new Array(indent * 2 + 1).join(" ")}${node.label}`);
|
|
175
|
+
await loadBranch(node, indent + 1);
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
await loadBranch(undefined);
|
|
177
179
|
}
|
|
178
180
|
```
|
|
181
|
+
|
|
182
|
+
<!-- END EXTRACTION -->
|
|
@@ -3,12 +3,18 @@ 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
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* A nodes definition that returns a single custom defined node.
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
7
10
|
export interface CustomHierarchyNodeDefinition {
|
|
8
11
|
/** The node to be created in the hierarchy level */
|
|
9
12
|
node: ParsedCustomHierarchyNode;
|
|
10
13
|
}
|
|
11
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* A nodes definition that returns an ECSQL query for selecting nodes from an iModel.
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
12
18
|
export interface InstanceNodesQueryDefinition {
|
|
13
19
|
/**
|
|
14
20
|
* Full name of the class whose instances are going to be returned. It's okay if the attribute
|
|
@@ -64,6 +70,7 @@ export type NodePostProcessor = (node: ProcessedHierarchyNode) => Promise<Proces
|
|
|
64
70
|
* a `HierarchyNode` that:
|
|
65
71
|
* - knows nothing about its children,
|
|
66
72
|
* - is either an instances node (key is of `InstancesNodeKey` type) or a custom node (key is of `string` type).
|
|
73
|
+
* @beta
|
|
67
74
|
*/
|
|
68
75
|
type HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, "children">;
|
|
69
76
|
/**
|
|
@@ -143,6 +150,7 @@ export type DefineInstanceNodeChildHierarchyLevelProps = Omit<DefineHierarchyLev
|
|
|
143
150
|
};
|
|
144
151
|
/**
|
|
145
152
|
* A definition of a hierarchy level that should be used for specific class of parent instance nodes.
|
|
153
|
+
* @beta
|
|
146
154
|
*/
|
|
147
155
|
interface InstancesNodeChildHierarchyLevelDefinition {
|
|
148
156
|
/**
|
|
@@ -157,6 +165,24 @@ interface InstancesNodeChildHierarchyLevelDefinition {
|
|
|
157
165
|
* Called to create a hierarchy level definition when the class check passes (see `parentNodeClassName`).
|
|
158
166
|
*/
|
|
159
167
|
definitions: (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;
|
|
168
|
+
/**
|
|
169
|
+
* If set to true, and node matches at least one of the previous definitions, this definition will not be applied.
|
|
170
|
+
*
|
|
171
|
+
* For example:
|
|
172
|
+
* ```ts
|
|
173
|
+
* {
|
|
174
|
+
* parentNodeClassName: "BisCore.GeometricElement3d",
|
|
175
|
+
* definitions: () => ...,
|
|
176
|
+
* },
|
|
177
|
+
* // This will apply to all elements, that are not BisCore.GeometricElement3d
|
|
178
|
+
* {
|
|
179
|
+
* parentNodeClassName: "BisCore.Element",
|
|
180
|
+
* onlyIfNotHandled: true,
|
|
181
|
+
* definitions: () => ...,
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
onlyIfNotHandled?: boolean;
|
|
160
186
|
}
|
|
161
187
|
/**
|
|
162
188
|
* Props for defining child hierarchy level for specific parent custom node.
|
|
@@ -171,6 +197,7 @@ export type DefineCustomNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevel
|
|
|
171
197
|
};
|
|
172
198
|
/**
|
|
173
199
|
* A definition of a hierarchy level for that should be used for specific custom parent nodes.
|
|
200
|
+
* @beta
|
|
174
201
|
*/
|
|
175
202
|
interface CustomNodeChildHierarchyLevelDefinition {
|
|
176
203
|
/**
|
|
@@ -185,6 +212,7 @@ interface CustomNodeChildHierarchyLevelDefinition {
|
|
|
185
212
|
/**
|
|
186
213
|
* A hierarchy level definition associated with either parent instance node's class or custom
|
|
187
214
|
* node's key.
|
|
215
|
+
* @beta
|
|
188
216
|
*/
|
|
189
217
|
type ClassBasedHierarchyLevelDefinition = InstancesNodeChildHierarchyLevelDefinition | CustomNodeChildHierarchyLevelDefinition;
|
|
190
218
|
/**
|
|
@@ -195,6 +223,7 @@ type ClassBasedHierarchyLevelDefinition = InstancesNodeChildHierarchyLevelDefini
|
|
|
195
223
|
export type DefineRootHierarchyLevelProps = Omit<DefineHierarchyLevelProps, "parentNode">;
|
|
196
224
|
/**
|
|
197
225
|
* Props for `createClassBasedHierarchyDefinition`.
|
|
226
|
+
* @beta
|
|
198
227
|
*/
|
|
199
228
|
interface ClassBasedHierarchyDefinitionProps {
|
|
200
229
|
/** Access to ECClass hierarchy in the iModel */
|
|
@@ -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,EACtB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
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,EACtB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,oDAAoD;IACpD,IAAI,EAAE,yBAAyB,CAAC;CACj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;AACH,KAAK,kCAAkC,GAAG,0CAA0C,GAAG,uCAAuC,CAAC;AAE/H;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC;AAE1F;;;GAGG;AACH,UAAU,kCAAkC;IAC1C,gDAAgD;IAChD,uBAAuB,EAAE,yBAAyB,CAAC;IAEnD,8FAA8F;IAC9F,SAAS,EAAE;QACT,4DAA4D;QAC5D,SAAS,EAAE,CAAC,KAAK,EAAE,6BAA6B,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC;QAEvF;;;WAGG;QACH,UAAU,EAAE,kCAAkC,EAAE,CAAC;KAClD,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,kCAAkC,GAAG,mBAAmB,CAElH"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createClassBasedHierarchyDefinition = exports.HierarchyNodesDefinition = void 0;
|
|
8
8
|
const HierarchyNode_1 = require("./HierarchyNode");
|
|
9
|
+
const rxjs_1 = require("rxjs");
|
|
9
10
|
/** @beta */
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
11
12
|
var HierarchyNodesDefinition;
|
|
@@ -66,12 +67,13 @@ class ClassBasedHierarchyDefinition {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
async function createHierarchyLevelDefinitions(classHierarchy, defs, requestProps) {
|
|
69
|
-
|
|
70
|
+
const obs = (0, rxjs_1.from)(defs).pipe((0, rxjs_1.mergeMap)(async (def, idx) => {
|
|
70
71
|
if (await classHierarchy.classDerivesFrom(requestProps.parentNodeClassName, def.parentNodeClassName)) {
|
|
71
|
-
return def
|
|
72
|
+
return { def, idx };
|
|
72
73
|
}
|
|
73
|
-
return
|
|
74
|
-
}))).
|
|
74
|
+
return undefined;
|
|
75
|
+
}), (0, rxjs_1.filter)((x) => !!x), (0, rxjs_1.toArray)(), (0, rxjs_1.concatMap)((x) => x.sort((a, b) => a.idx - b.idx).map(({ def }) => def)), (0, rxjs_1.filter)((def, idx) => !def.onlyIfNotHandled || idx === 0), (0, rxjs_1.mergeMap)(async (def) => def.definitions(requestProps)), (0, rxjs_1.mergeAll)());
|
|
76
|
+
return (0, rxjs_1.firstValueFrom)(obs.pipe((0, rxjs_1.toArray)()));
|
|
75
77
|
}
|
|
76
78
|
function groupInstanceIdsByClass(instanceKeys) {
|
|
77
79
|
const instanceIdsByClass = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyDefinition.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAKhG,mDAQyB;AA6BzB,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,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,wCAAxB,wBAAwB,QAOxC;AAsMD;;;;;;GAMG;AACH,SAAgB,mCAAmC,CAAC,KAAyC;IAC3F,OAAO,IAAI,6BAA6B,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAFD,kFAEC;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,EAA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,uBAAuB;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,KAAK,UAAU,+BAA+B,CAC5C,cAAyC,EACzC,IAAkD,EAClD,YAAwD;IAExD,OAAO,CACL,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACrB,IAAI,MAAM,cAAc,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"]}
|
|
1
|
+
{"version":3,"file":"HierarchyDefinition.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAKhG,mDAQyB;AAEzB,+BAA4F;AAkC5F,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,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,wCAAxB,wBAAwB,QAOxC;AA8ND;;;;;;GAMG;AACH,SAAgB,mCAAmC,CAAC,KAAyC;IAC3F,OAAO,IAAI,6BAA6B,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAFD,kFAEC;AAED,MAAM,6BAA6B;IACN;IAA3B,YAA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AA,eAAQ,GAAE,CACX,CAAC;IACF,OAAO,IAAA,qBAAc,EAAC,GAAG,CAAC,IAAI,CAAC,IAAA,cAAO,GAAE,CAAC,CAAC,CAAC;AAC7C,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\";\nimport { concatMap, filter, firstValueFrom, from, mergeAll, mergeMap, toArray } from \"rxjs\";\n\n/**\n * A nodes definition that returns a single custom defined node.\n * @beta\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 * @beta\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 * @beta\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 * @beta\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 * If set to true, and node matches at least one of the previous definitions, this definition will not be applied.\n *\n * For example:\n * ```ts\n * {\n * parentNodeClassName: \"BisCore.GeometricElement3d\",\n * definitions: () => ...,\n * },\n * // This will apply to all elements, that are not BisCore.GeometricElement3d\n * {\n * parentNodeClassName: \"BisCore.Element\",\n * onlyIfNotHandled: true,\n * definitions: () => ...,\n * }\n * ```\n */\n onlyIfNotHandled?: boolean;\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 * @beta\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 * @beta\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 * @beta\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 const obs = from(defs).pipe(\n mergeMap(async (def, idx) => {\n if (await classHierarchy.classDerivesFrom(requestProps.parentNodeClassName, def.parentNodeClassName)) {\n return { def, idx };\n }\n return undefined;\n }),\n filter((x): x is Exclude<typeof x, undefined> => !!x),\n toArray(),\n concatMap((x) => x.sort((a, b) => a.idx - b.idx).map(({ def }) => def)),\n filter((def, idx) => !def.onlyIfNotHandled || idx === 0),\n mergeMap(async (def) => def.definitions(requestProps)),\n mergeAll(),\n );\n return firstValueFrom(obs.pipe(toArray()));\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"]}
|
|
@@ -3,6 +3,7 @@ import { HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier";
|
|
|
3
3
|
import { ClassGroupingNodeKey, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey, LabelGroupingNodeKey, PropertyGroupingNodeKey, PropertyOtherValuesGroupingNodeKey, PropertyValueGroupingNodeKey, PropertyValueRangeGroupingNodeKey, StandardHierarchyNodeKey } from "./HierarchyNodeKey";
|
|
4
4
|
/**
|
|
5
5
|
* A data structure that represents a single non-grouping hierarchy node.
|
|
6
|
+
* @beta
|
|
6
7
|
*/
|
|
7
8
|
interface BaseHierarchyNode {
|
|
8
9
|
/** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */
|
|
@@ -127,10 +128,12 @@ export declare namespace HierarchyNode {
|
|
|
127
128
|
/**
|
|
128
129
|
* A type of `HierarchyNode` that doesn't know about its children and is an input when requesting
|
|
129
130
|
* them using `HierarchyProvider.getNodes`.
|
|
131
|
+
* @beta
|
|
130
132
|
*/
|
|
131
133
|
export type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, "children">;
|
|
132
134
|
/**
|
|
133
135
|
* Base processing parameters that apply to every node.
|
|
136
|
+
* @beta
|
|
134
137
|
*/
|
|
135
138
|
interface HierarchyNodeProcessingParamsBase {
|
|
136
139
|
/** Indicates if this node should be hidden if it has no child nodes. */
|
|
@@ -140,6 +143,7 @@ interface HierarchyNodeProcessingParamsBase {
|
|
|
140
143
|
}
|
|
141
144
|
/**
|
|
142
145
|
* A data structure for defining nodes' grouping requirements.
|
|
146
|
+
* @beta
|
|
143
147
|
*/
|
|
144
148
|
interface HierarchyNodeGroupingParams {
|
|
145
149
|
byLabel?: HierarchyNodeLabelGroupingParams;
|
|
@@ -149,6 +153,7 @@ interface HierarchyNodeGroupingParams {
|
|
|
149
153
|
}
|
|
150
154
|
/**
|
|
151
155
|
* A data structure for defining params specifically used for label grouping.
|
|
156
|
+
* @beta
|
|
152
157
|
*/
|
|
153
158
|
interface HierarchyNodeLabelGroupingBaseParams {
|
|
154
159
|
/** Label grouping option that determines whether to group nodes or to merge them. Defaults to "group".*/
|
|
@@ -158,19 +163,27 @@ interface HierarchyNodeLabelGroupingBaseParams {
|
|
|
158
163
|
}
|
|
159
164
|
/**
|
|
160
165
|
* A data structure for defining label merging.
|
|
166
|
+
* @beta
|
|
161
167
|
*/
|
|
162
168
|
interface HierarchyNodeLabelGroupingMergeParams extends HierarchyNodeLabelGroupingBaseParams {
|
|
163
169
|
action: "merge";
|
|
164
170
|
}
|
|
165
171
|
/**
|
|
166
172
|
* A data structure for defining label grouping with additional parameters.
|
|
173
|
+
* @beta
|
|
167
174
|
*/
|
|
168
175
|
interface HierarchyNodeLabelGroupingGroupParams extends HierarchyNodeLabelGroupingBaseParams, HierarchyNodeGroupingParamsBase {
|
|
169
176
|
action?: "group";
|
|
170
177
|
}
|
|
171
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* A data structure for defining possible label grouping types.
|
|
180
|
+
* @beta
|
|
181
|
+
*/
|
|
172
182
|
export type HierarchyNodeLabelGroupingParams = boolean | HierarchyNodeLabelGroupingMergeParams | HierarchyNodeLabelGroupingGroupParams;
|
|
173
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Grouping parameters that are shared across all types of groupings.
|
|
185
|
+
* @beta
|
|
186
|
+
*/
|
|
174
187
|
export interface HierarchyNodeGroupingParamsBase {
|
|
175
188
|
/** Hiding option that determines whether to hide group nodes which have no siblings at the same hierarchy level. */
|
|
176
189
|
hideIfNoSiblings?: boolean;
|
|
@@ -183,10 +196,12 @@ export interface HierarchyNodeGroupingParamsBase {
|
|
|
183
196
|
* Defines possible values for `BaseGroupingParams.autoExpand` attribute:
|
|
184
197
|
* - `single-child` - set the grouping node to auto-expand if it groups a single node.
|
|
185
198
|
* - `always` - always set the grouping node to auto-expand.
|
|
199
|
+
* @beta
|
|
186
200
|
*/
|
|
187
201
|
export type HierarchyNodeAutoExpandProp = "single-child" | "always";
|
|
188
202
|
/**
|
|
189
203
|
* A data structure that represents base class grouping.
|
|
204
|
+
* @beta
|
|
190
205
|
*/
|
|
191
206
|
interface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingParamsBase {
|
|
192
207
|
/**
|
|
@@ -197,7 +212,10 @@ interface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingPara
|
|
|
197
212
|
*/
|
|
198
213
|
fullClassNames: string[];
|
|
199
214
|
}
|
|
200
|
-
/**
|
|
215
|
+
/**
|
|
216
|
+
* A data structure that represents properties grouping.
|
|
217
|
+
* @beta
|
|
218
|
+
*/
|
|
201
219
|
export interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGroupingParamsBase {
|
|
202
220
|
/**
|
|
203
221
|
* Full name of a class whose properties are used to group the node. Only has effect if the node
|
|
@@ -243,7 +261,10 @@ export interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGrou
|
|
|
243
261
|
*/
|
|
244
262
|
propertyGroups: HierarchyNodePropertyGroup[];
|
|
245
263
|
}
|
|
246
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* A data structure that represents specific properties' grouping params.
|
|
266
|
+
* @beta
|
|
267
|
+
*/
|
|
247
268
|
export interface HierarchyNodePropertyGroup {
|
|
248
269
|
/** A string indicating the name of the property to group by. */
|
|
249
270
|
propertyName: string;
|
|
@@ -252,7 +273,10 @@ export interface HierarchyNodePropertyGroup {
|
|
|
252
273
|
/** Ranges are used to group nodes by numeric properties which are within specified bounds. */
|
|
253
274
|
ranges?: HierarchyNodePropertyValueRange[];
|
|
254
275
|
}
|
|
255
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* A data structure that represents boundaries for a value.
|
|
278
|
+
* @beta
|
|
279
|
+
*/
|
|
256
280
|
export interface HierarchyNodePropertyValueRange {
|
|
257
281
|
/** Defines the lower bound of the range. */
|
|
258
282
|
fromValue: number;
|
|
@@ -261,23 +285,35 @@ export interface HierarchyNodePropertyValueRange {
|
|
|
261
285
|
/** Defines the range label. Will be used as `PropertyValueRangeGroupingNode` node's display label. */
|
|
262
286
|
rangeLabel?: string;
|
|
263
287
|
}
|
|
264
|
-
/**
|
|
288
|
+
/**
|
|
289
|
+
* Processing parameters that apply to instance nodes.
|
|
290
|
+
* @beta
|
|
291
|
+
*/
|
|
265
292
|
export interface InstanceHierarchyNodeProcessingParams extends HierarchyNodeProcessingParamsBase {
|
|
266
293
|
grouping?: HierarchyNodeGroupingParams;
|
|
267
294
|
}
|
|
268
|
-
/**
|
|
295
|
+
/**
|
|
296
|
+
* A custom (not based on data in an iModel) node that has processing parameters.
|
|
297
|
+
* @beta
|
|
298
|
+
*/
|
|
269
299
|
export type ProcessedCustomHierarchyNode = Omit<NonGroupingHierarchyNode, "key" | "children"> & {
|
|
270
300
|
key: string;
|
|
271
301
|
children?: boolean;
|
|
272
302
|
processingParams?: HierarchyNodeProcessingParamsBase;
|
|
273
303
|
};
|
|
274
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* An instances' (based on data in an iModel) node that has processing parameters.
|
|
306
|
+
* @beta
|
|
307
|
+
*/
|
|
275
308
|
export type ProcessedInstanceHierarchyNode = Omit<NonGroupingHierarchyNode, "key" | "children"> & {
|
|
276
309
|
key: InstancesNodeKey;
|
|
277
310
|
children?: boolean;
|
|
278
311
|
processingParams?: InstanceHierarchyNodeProcessingParams;
|
|
279
312
|
};
|
|
280
|
-
/**
|
|
313
|
+
/**
|
|
314
|
+
* A grouping node that groups either instance nodes or other grouping nodes.
|
|
315
|
+
* @beta
|
|
316
|
+
*/
|
|
281
317
|
export type ProcessedGroupingHierarchyNode = Omit<GroupingHierarchyNode, "children"> & {
|
|
282
318
|
children: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;
|
|
283
319
|
};
|
|
@@ -299,9 +335,15 @@ export type ProcessedHierarchyNode = ProcessedCustomHierarchyNode | ProcessedIns
|
|
|
299
335
|
export type ParsedHierarchyNode<TBase = ParsedCustomHierarchyNode | ParsedInstanceHierarchyNode> = OmitOverUnion<TBase, "label" | "parentKeys"> & {
|
|
300
336
|
label: string | ConcatenatedValue;
|
|
301
337
|
};
|
|
302
|
-
/**
|
|
338
|
+
/**
|
|
339
|
+
* A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors.
|
|
340
|
+
* @beta
|
|
341
|
+
*/
|
|
303
342
|
export type ParsedCustomHierarchyNode = ParsedHierarchyNode<ProcessedCustomHierarchyNode>;
|
|
304
|
-
/**
|
|
343
|
+
/**
|
|
344
|
+
* A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors.
|
|
345
|
+
* @beta
|
|
346
|
+
*/
|
|
305
347
|
export type ParsedInstanceHierarchyNode = ParsedHierarchyNode<ProcessedInstanceHierarchyNode>;
|
|
306
348
|
export {};
|
|
307
349
|
//# 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,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,wBAAwB,EACzB,MAAM,oBAAoB,CAAC;AAE5B
|
|
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,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,wBAAwB,EACzB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,UAAU,iBAAiB;IACzB,0FAA0F;IAC1F,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yDAAyD;IACzD,YAAY,CAAC,EAAE;QAAE,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