@itwin/presentation-hierarchies 0.1.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 +12 -0
- package/LICENSE.md +9 -0
- package/README.md +178 -0
- package/lib/cjs/hierarchies/HierarchyDefinition.d.ts +228 -0
- package/lib/cjs/hierarchies/HierarchyDefinition.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyDefinition.js +94 -0
- package/lib/cjs/hierarchies/HierarchyDefinition.js.map +1 -0
- package/lib/cjs/hierarchies/HierarchyErrors.d.ts +9 -0
- package/lib/cjs/hierarchies/HierarchyErrors.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyErrors.js +20 -0
- package/lib/cjs/hierarchies/HierarchyErrors.js.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +337 -0
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNode.js +64 -0
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts +33 -0
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js +34 -0
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts +137 -0
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNodeKey.js +163 -0
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -0
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +104 -0
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyProvider.js +384 -0
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -0
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.d.ts +21 -0
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.d.ts.map +1 -0
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.js +100 -0
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.js.map +1 -0
- package/lib/cjs/hierarchies/Logging.d.ts +13 -0
- package/lib/cjs/hierarchies/Logging.d.ts.map +1 -0
- package/lib/cjs/hierarchies/Logging.js +28 -0
- package/lib/cjs/hierarchies/Logging.js.map +1 -0
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts +205 -0
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts.map +1 -0
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.js +467 -0
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.js.map +1 -0
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.d.ts +40 -0
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.js +84 -0
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.js.map +1 -0
- package/lib/cjs/hierarchies/internal/Common.d.ts +20 -0
- package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/Common.js +106 -0
- package/lib/cjs/hierarchies/internal/Common.js.map +1 -0
- package/lib/cjs/hierarchies/internal/EachValueFrom.d.ts +12 -0
- package/lib/cjs/hierarchies/internal/EachValueFrom.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/EachValueFrom.js +108 -0
- package/lib/cjs/hierarchies/internal/EachValueFrom.js.map +1 -0
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts +39 -0
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js +181 -0
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js.map +1 -0
- package/lib/cjs/hierarchies/internal/LoggingUtils.d.ts +14 -0
- package/lib/cjs/hierarchies/internal/LoggingUtils.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/LoggingUtils.js +56 -0
- package/lib/cjs/hierarchies/internal/LoggingUtils.js.map +1 -0
- package/lib/cjs/hierarchies/internal/SubscriptionScheduler.d.ts +17 -0
- package/lib/cjs/hierarchies/internal/SubscriptionScheduler.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/SubscriptionScheduler.js +57 -0
- package/lib/cjs/hierarchies/internal/SubscriptionScheduler.js.map +1 -0
- package/lib/cjs/hierarchies/internal/TreeNodesReader.d.ts +37 -0
- package/lib/cjs/hierarchies/internal/TreeNodesReader.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/TreeNodesReader.js +46 -0
- package/lib/cjs/hierarchies/internal/TreeNodesReader.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.d.ts +11 -0
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.js +34 -0
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/Grouping.d.ts +27 -0
- package/lib/cjs/hierarchies/internal/operators/Grouping.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/Grouping.js +161 -0
- package/lib/cjs/hierarchies/internal/operators/Grouping.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.d.ts +11 -0
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.js +52 -0
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.d.ts +11 -0
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.js +55 -0
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/Partition.d.ts +6 -0
- package/lib/cjs/hierarchies/internal/operators/Partition.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/Partition.js +61 -0
- package/lib/cjs/hierarchies/internal/operators/Partition.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts +22 -0
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js +51 -0
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.d.ts +7 -0
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.js +25 -0
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/ShareReplayWithErrors.d.ts +9 -0
- package/lib/cjs/hierarchies/internal/operators/ShareReplayWithErrors.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/ShareReplayWithErrors.js +24 -0
- package/lib/cjs/hierarchies/internal/operators/ShareReplayWithErrors.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts +12 -0
- package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/Sorting.js +26 -0
- package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/TapOnce.d.ts +4 -0
- package/lib/cjs/hierarchies/internal/operators/TapOnce.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/TapOnce.js +20 -0
- package/lib/cjs/hierarchies/internal/operators/TapOnce.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.d.ts +4 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.js +27 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.d.ts +10 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.js +115 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.d.ts +6 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.js +56 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.d.ts +4 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.js +54 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.d.ts +5 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.js +61 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.d.ts +31 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.js +310 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.js.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/Shared.d.ts +5 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/Shared.d.ts.map +1 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/Shared.js +30 -0
- package/lib/cjs/hierarchies/internal/operators/grouping/Shared.js.map +1 -0
- package/lib/cjs/presentation-hierarchies.d.ts +11 -0
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -0
- package/lib/cjs/presentation-hierarchies.js +31 -0
- package/lib/cjs/presentation-hierarchies.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyDefinition.d.ts +228 -0
- package/lib/esm/hierarchies/HierarchyDefinition.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyDefinition.js +90 -0
- package/lib/esm/hierarchies/HierarchyDefinition.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyErrors.d.ts +9 -0
- package/lib/esm/hierarchies/HierarchyErrors.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyErrors.js +16 -0
- package/lib/esm/hierarchies/HierarchyErrors.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyNode.d.ts +337 -0
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyNode.js +61 -0
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts +33 -0
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.js +31 -0
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts +137 -0
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyNodeKey.js +160 -0
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +104 -0
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyProvider.js +380 -0
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -0
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.d.ts +21 -0
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.d.ts.map +1 -0
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.js +96 -0
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.js.map +1 -0
- package/lib/esm/hierarchies/Logging.d.ts +13 -0
- package/lib/esm/hierarchies/Logging.d.ts.map +1 -0
- package/lib/esm/hierarchies/Logging.js +23 -0
- package/lib/esm/hierarchies/Logging.js.map +1 -0
- package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts +205 -0
- package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts.map +1 -0
- package/lib/esm/hierarchies/NodeSelectQueryFactory.js +463 -0
- package/lib/esm/hierarchies/NodeSelectQueryFactory.js.map +1 -0
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.d.ts +40 -0
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.js +80 -0
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.js.map +1 -0
- package/lib/esm/hierarchies/internal/Common.d.ts +20 -0
- package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/Common.js +95 -0
- package/lib/esm/hierarchies/internal/Common.js.map +1 -0
- package/lib/esm/hierarchies/internal/EachValueFrom.d.ts +12 -0
- package/lib/esm/hierarchies/internal/EachValueFrom.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/EachValueFrom.js +104 -0
- package/lib/esm/hierarchies/internal/EachValueFrom.js.map +1 -0
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts +39 -0
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js +176 -0
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js.map +1 -0
- package/lib/esm/hierarchies/internal/LoggingUtils.d.ts +14 -0
- package/lib/esm/hierarchies/internal/LoggingUtils.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/LoggingUtils.js +50 -0
- package/lib/esm/hierarchies/internal/LoggingUtils.js.map +1 -0
- package/lib/esm/hierarchies/internal/SubscriptionScheduler.d.ts +17 -0
- package/lib/esm/hierarchies/internal/SubscriptionScheduler.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/SubscriptionScheduler.js +53 -0
- package/lib/esm/hierarchies/internal/SubscriptionScheduler.js.map +1 -0
- package/lib/esm/hierarchies/internal/TreeNodesReader.d.ts +37 -0
- package/lib/esm/hierarchies/internal/TreeNodesReader.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/TreeNodesReader.js +41 -0
- package/lib/esm/hierarchies/internal/TreeNodesReader.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.d.ts +11 -0
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.js +30 -0
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/Grouping.d.ts +27 -0
- package/lib/esm/hierarchies/internal/operators/Grouping.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/Grouping.js +156 -0
- package/lib/esm/hierarchies/internal/operators/Grouping.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.d.ts +11 -0
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.js +48 -0
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.d.ts +11 -0
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.js +51 -0
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/Partition.d.ts +6 -0
- package/lib/esm/hierarchies/internal/operators/Partition.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/Partition.js +57 -0
- package/lib/esm/hierarchies/internal/operators/Partition.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts +22 -0
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.js +46 -0
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/ReleaseMainThread.d.ts +7 -0
- package/lib/esm/hierarchies/internal/operators/ReleaseMainThread.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/ReleaseMainThread.js +21 -0
- package/lib/esm/hierarchies/internal/operators/ReleaseMainThread.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/ShareReplayWithErrors.d.ts +9 -0
- package/lib/esm/hierarchies/internal/operators/ShareReplayWithErrors.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/ShareReplayWithErrors.js +20 -0
- package/lib/esm/hierarchies/internal/operators/ShareReplayWithErrors.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/Sorting.d.ts +12 -0
- package/lib/esm/hierarchies/internal/operators/Sorting.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/Sorting.js +22 -0
- package/lib/esm/hierarchies/internal/operators/Sorting.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/TapOnce.d.ts +4 -0
- package/lib/esm/hierarchies/internal/operators/TapOnce.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/TapOnce.js +16 -0
- package/lib/esm/hierarchies/internal/operators/TapOnce.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/AutoExpand.d.ts +4 -0
- package/lib/esm/hierarchies/internal/operators/grouping/AutoExpand.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/AutoExpand.js +23 -0
- package/lib/esm/hierarchies/internal/operators/grouping/AutoExpand.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/BaseClassGrouping.d.ts +10 -0
- package/lib/esm/hierarchies/internal/operators/grouping/BaseClassGrouping.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/BaseClassGrouping.js +109 -0
- package/lib/esm/hierarchies/internal/operators/grouping/BaseClassGrouping.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/ClassGrouping.d.ts +6 -0
- package/lib/esm/hierarchies/internal/operators/grouping/ClassGrouping.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/ClassGrouping.js +52 -0
- package/lib/esm/hierarchies/internal/operators/grouping/ClassGrouping.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/GroupHiding.d.ts +4 -0
- package/lib/esm/hierarchies/internal/operators/grouping/GroupHiding.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/GroupHiding.js +50 -0
- package/lib/esm/hierarchies/internal/operators/grouping/GroupHiding.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/LabelGrouping.d.ts +5 -0
- package/lib/esm/hierarchies/internal/operators/grouping/LabelGrouping.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/LabelGrouping.js +57 -0
- package/lib/esm/hierarchies/internal/operators/grouping/LabelGrouping.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.d.ts +31 -0
- package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.js +302 -0
- package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.js.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/Shared.d.ts +5 -0
- package/lib/esm/hierarchies/internal/operators/grouping/Shared.d.ts.map +1 -0
- package/lib/esm/hierarchies/internal/operators/grouping/Shared.js +26 -0
- package/lib/esm/hierarchies/internal/operators/grouping/Shared.js.map +1 -0
- package/lib/esm/presentation-hierarchies.d.ts +11 -0
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies.js +15 -0
- package/lib/esm/presentation-hierarchies.js.map +1 -0
- package/media/sample-hierarchy.png +0 -0
- package/package.json +71 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2017-2024 Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# @itwin/presentation-hierarchies
|
|
2
|
+
|
|
3
|
+
Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.
|
|
4
|
+
|
|
5
|
+
The `@itwin/presentation-hierarchies` package provides APIs for creating hierarchical data structures based on data in an [iTwin.js iModel](https://www.itwinjs.org/learning/imodels/#imodel-overview).
|
|
6
|
+
|
|
7
|
+
## Basic concepts
|
|
8
|
+
|
|
9
|
+
A hierarchy is an arrangement of items, called hierarchy nodes, which are represented as being "above", "below", or "at the same level as" one another:
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
Here are definitions of some basic hierarchy-related concepts based on the above example:
|
|
14
|
+
|
|
15
|
+
- A hierarchy node is an item in the hierarchy, e.g. `Node 0`, `Node 1`, `Node 1-0` etc.
|
|
16
|
+
- A hierarchy level is a group of hierarchy nodes that are at the same level in the hierarchy. In the above example the root level contains `Node 0`, `Node 1` and `Node 2`. Child level of `Node 2` contains `Node 2-0`, `Node 2-1`.
|
|
17
|
+
- A hierarchy branch is a sub-hierarchy under specific parent node, including the parent itself. In the above example, the branch of `Node 2` contains `Node 2`, `Node 2-0`, `Node 2-1` and `Node 2-1-0`.
|
|
18
|
+
|
|
19
|
+
In the context of `@itwin/presentation-hierarchies` package, a hierarchy is built by requesting hierarchy levels from a [hierarchy provider](#hierarchy-provider). The provider knows how to create hierarchy levels based on the data in an iModel and a [hierarchy definition](#hierarchy-definition).
|
|
20
|
+
|
|
21
|
+
### Hierarchy nodes
|
|
22
|
+
|
|
23
|
+
A `HierarchyNode` interface in the package represents a single node in a hierarchy. It contains information about what the node represents in the iModel (through it's `key` property), label and other properties. There are multiple types of nodes:
|
|
24
|
+
|
|
25
|
+
- A custom node is not based on any iModel data and is created by the application. Its `key` is a string.
|
|
26
|
+
- An instances node is based on one or more ECInstance(s) in the iModel. Its `key` is an `InstancesNodeKey` and contains identifiers of those ECInstances.
|
|
27
|
+
- A grouping node groups one or more instances nodes. Its `key` is a `GroupingNodeKey` and contains the grouping criteria, which depends on the type of grouping:
|
|
28
|
+
- Label grouping node keys have a label.
|
|
29
|
+
- Class grouping nodes have a full class name.
|
|
30
|
+
- Property grouping nodes have a full class name containing the property and property name. Also, depending on whether the grouping is based on value or a range of values, that information is also included.
|
|
31
|
+
|
|
32
|
+
`HierarchyNode` and `HierarchyNodeKey` namespaces contain type guards and utility functions for working with hierarchy nodes and their keys.
|
|
33
|
+
|
|
34
|
+
A `HierarchyNode` goes through several stages throughout its lifetime:
|
|
35
|
+
|
|
36
|
+
1. A node starts its life as a `ParsedHierarchyNode` when it's initially parsed from ECSQL query results or returned by a [hierarchy definition](#hierarchy-definition) as a custom node. This variation has no information about its ancestors (position in the hierarchy) and may have unformatted label. Parsed nodes may only be custom or instances nodes.
|
|
37
|
+
|
|
38
|
+
2. A node becomes a `ProcessedHierarchyNode` as soon as it starts being processed by a [hierarchy provider](#hierarchy-provider). During the processing, provider assigns a formatted label, handles node hiding, grouping, sorting and other operations. A [hierarchy definition](#hierarchy-definition) gets a chance to step into the process as well. In case of grouping, new grouping nodes may be created.
|
|
39
|
+
|
|
40
|
+
3. Finally, all the processing-related information is cleaned up from `ProcessedHierarchyNode` and it becomes a `HierarchyNode`, which is what consumers get from a [hierarchy provider](#hierarchy-provider).
|
|
41
|
+
|
|
42
|
+
### Hierarchy definition
|
|
43
|
+
|
|
44
|
+
A hierarchy definition is what describes the hierarchy by defining what child nodes to return for a given parent node. In this package that is achieved though the `HierarchyDefinition` interface, which has one required method - `defineHierarchyLevel`. The method's responsibility is to create a `HierarchyLevelDefinition` for a given parent node. A `HierarchyLevelDefinition` is actually just a set of `HierarchyNodesDefinition` objects, which either describe a single custom node, or an ECSQL query that returns a number of ECInstance nodes. When `HierarchyLevelDefinition` consists of more than 1 `HierarchyNodesDefinition`, the hierarchy level is combined from multiple sets of nodes.
|
|
45
|
+
|
|
46
|
+
In case of ECSQL queries for creating the hierarchy level, the definition may want to select some extra information and assign it to the nodes. For that purpose, there's an optional `HierarchyDefinition.parseNode` method, which lets the definition parse the query results handle those extra columns.
|
|
47
|
+
|
|
48
|
+
Finally, the library also allows hierarchy definitions to step into nodes processing chain through the optional `preProcessNode` and `postProcessNode` methods. These methods are called before and after the node is processed by a [hierarchy provider](#hierarchy-provider) respectively and allow hiding and customizing nodes.
|
|
49
|
+
|
|
50
|
+
In iTwin.js, the most common way to create hierarchies is based on EC data (schemas, classes, relationships) in iModels. To make consumers' life easier, the package provides an utility called `createClassBasedHierarchyDefinition`, which lets consumers define hierarchy levels based on parent nodes' class.
|
|
51
|
+
|
|
52
|
+
### Hierarchy provider
|
|
53
|
+
|
|
54
|
+
`HierarchyProvider` the core concept of the library - it's responsibility is to glue everything together, including evaluating hierarchy definition, running the queries, processing nodes and, finally, returning them to consumers. The package delivers the `createHierarchyProvider` function to create an instance of `HierarchyProvider`.
|
|
55
|
+
|
|
56
|
+
## Basic usage
|
|
57
|
+
|
|
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
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { IModelConnection } from "@itwin/core-frontend";
|
|
62
|
+
import { SchemaContext } from "@itwin/ecschema-metadata";
|
|
63
|
+
import { ECSchemaRpcLocater } from "@itwin/ecschema-rpcinterface-common";
|
|
64
|
+
import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
|
|
65
|
+
import {
|
|
66
|
+
createClassBasedHierarchyDefinition,
|
|
67
|
+
createHierarchyProvider,
|
|
68
|
+
createLimitingECSqlQueryExecutor,
|
|
69
|
+
createNodesQueryClauseFactory,
|
|
70
|
+
DefineInstanceNodeChildHierarchyLevelProps,
|
|
71
|
+
HierarchyNode,
|
|
72
|
+
HierarchyProvider,
|
|
73
|
+
} from "@itwin/presentation-hierarchies";
|
|
74
|
+
import { createBisInstanceLabelSelectClauseFactory, createCachingECClassHierarchyInspector, ECSqlBinding } from "@itwin/presentation-shared";
|
|
75
|
+
|
|
76
|
+
// Not really part of the package, but we need SchemaContext to create a hierarchy provider. It's
|
|
77
|
+
// recommended to cache the schema context and reuse it across different application's components to
|
|
78
|
+
// avoid loading and storing same schemas multiple times.
|
|
79
|
+
const imodelSchemaContextsCache = new Map<string, SchemaContext>();
|
|
80
|
+
function getIModelSchemaContext(imodel: IModelConnection) {
|
|
81
|
+
let context = imodelSchemaContextsCache.get(imodel.key);
|
|
82
|
+
if (!context) {
|
|
83
|
+
context = new SchemaContext();
|
|
84
|
+
context.addLocater(new ECSchemaRpcLocater(imodel.getRpcProps()));
|
|
85
|
+
imodelSchemaContextsCache.set(imodel.key, context);
|
|
86
|
+
imodel.onClose.addListener(() => imodelSchemaContextsCache.delete(imodel.key));
|
|
87
|
+
}
|
|
88
|
+
return context;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function createProvider(imodel: IModelConnection): HierarchyProvider {
|
|
92
|
+
// First, set up access to the iModel
|
|
93
|
+
const schemaProvider = createECSchemaProvider(getIModelSchemaContext(imodel));
|
|
94
|
+
const imodelAccess = {
|
|
95
|
+
...schemaProvider,
|
|
96
|
+
// while caching for hierarchy inspector is not mandatory, it's recommended to use it to improve performance
|
|
97
|
+
...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),
|
|
98
|
+
// the second argument is the maximum number of rows the executor will return - this allows us to
|
|
99
|
+
// avoid creating hierarchy levels of insane size (expensive to us and useless to users)
|
|
100
|
+
...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), 1000),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// Create a factory for building nodes SELECT query clauses in a format understood by the provider
|
|
104
|
+
const nodesQueryFactory = createNodesQueryClauseFactory({ imodelAccess });
|
|
105
|
+
// Create a factory for building labels SELECT query clauses according to BIS conventions
|
|
106
|
+
const labelsQueryFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: imodelAccess });
|
|
107
|
+
|
|
108
|
+
// Then, define the hierarchy
|
|
109
|
+
const hierarchyDefinition = createClassBasedHierarchyDefinition({
|
|
110
|
+
classHierarchyInspector: imodelAccess,
|
|
111
|
+
hierarchy: {
|
|
112
|
+
// for root nodes, select all root level bis.Model instances
|
|
113
|
+
rootNodes: async () => [
|
|
114
|
+
{
|
|
115
|
+
fullClassName: "BisCore.Model",
|
|
116
|
+
query: {
|
|
117
|
+
ecsql: `
|
|
118
|
+
SELECT
|
|
119
|
+
${await nodesQueryFactory.createSelectClause({
|
|
120
|
+
ecClassId: { selector: "this.ECClassId" },
|
|
121
|
+
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
122
|
+
nodeLabel: {
|
|
123
|
+
selector: await labelsQueryFactory.createSelectClause({ classAlias: "this", className: "BisCore.Model" }),
|
|
124
|
+
},
|
|
125
|
+
})}
|
|
126
|
+
FROM BisCore.Model this
|
|
127
|
+
WHERE this.ParentModel IS NULL
|
|
128
|
+
`,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
childNodes: [
|
|
133
|
+
{
|
|
134
|
+
// for bis.Model parent nodes, select all bis.Element instances contained in corresponding model
|
|
135
|
+
parentNodeClassName: "BisCore.Model",
|
|
136
|
+
definitions: async ({ parentNodeInstanceIds }: DefineInstanceNodeChildHierarchyLevelProps) => [
|
|
137
|
+
{
|
|
138
|
+
fullClassName: "BisCore.Element",
|
|
139
|
+
query: {
|
|
140
|
+
ecsql: `
|
|
141
|
+
SELECT
|
|
142
|
+
${await nodesQueryFactory.createSelectClause({
|
|
143
|
+
ecClassId: { selector: "this.ECClassId" },
|
|
144
|
+
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
145
|
+
nodeLabel: {
|
|
146
|
+
selector: await labelsQueryFactory.createSelectClause({ classAlias: "this", className: "BisCore.Element" }),
|
|
147
|
+
},
|
|
148
|
+
grouping: {
|
|
149
|
+
byClass: true,
|
|
150
|
+
},
|
|
151
|
+
})}
|
|
152
|
+
FROM BisCore.Element this
|
|
153
|
+
WHERE this.Model.Id IN (${parentNodeInstanceIds.map(() => "?").join(",")})
|
|
154
|
+
`,
|
|
155
|
+
bindings: [...parentNodeInstanceIds.map((id): ECSqlBinding => ({ type: "id", value: id }))],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Finally, create the provider
|
|
165
|
+
return createHierarchyProvider({ imodelAccess, hierarchyDefinition });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function main() {
|
|
169
|
+
const provider = createProvider(/* pass your IModelConnection here */);
|
|
170
|
+
async function loadBranch(parentNode: HierarchyNode | undefined, indent: number = 0) {
|
|
171
|
+
for await (const node of provider.getNodes({ parentNode })) {
|
|
172
|
+
console.log(`${new Array(indent + 1).join(" ")} ${node.label}`);
|
|
173
|
+
await loadBranch(node);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
await loadBranch(undefined);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
2
|
+
import { GenericInstanceFilter } from "@itwin/core-common";
|
|
3
|
+
import { ECClassHierarchyInspector, ECSqlQueryDef } from "@itwin/presentation-shared";
|
|
4
|
+
import { NonGroupingHierarchyNode, ParsedCustomHierarchyNode, ParsedInstanceHierarchyNode, ProcessedCustomHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode } from "./HierarchyNode";
|
|
5
|
+
import { InstancesNodeKey } from "./HierarchyNodeKey";
|
|
6
|
+
/**
|
|
7
|
+
* A nodes definition that returns a single custom defined node.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export interface CustomHierarchyNodeDefinition {
|
|
11
|
+
/** The node to be created in the hierarchy level */
|
|
12
|
+
node: ParsedCustomHierarchyNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A nodes definition that returns an ECSQL query for selecting nodes from an iModel.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export interface InstanceNodesQueryDefinition {
|
|
19
|
+
/**
|
|
20
|
+
* Full name of the class whose instances are going to be returned. It's okay if the attribute
|
|
21
|
+
* points to a base class of multiple different classes of instances returned by the query, however
|
|
22
|
+
* the more specific this class is, the more efficient hierarchy building process is.
|
|
23
|
+
*/
|
|
24
|
+
fullClassName: string;
|
|
25
|
+
/**
|
|
26
|
+
* An ECSQL query that selects nodes from an iModel. `SELECT` clause of the query is expected
|
|
27
|
+
* to be built using `NodeSelectQueryFactory.createSelectClause`.
|
|
28
|
+
*/
|
|
29
|
+
query: ECSqlQueryDef;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A definition of nodes included in a hierarchy level.
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export type HierarchyNodesDefinition = CustomHierarchyNodeDefinition | InstanceNodesQueryDefinition;
|
|
36
|
+
/** @beta */
|
|
37
|
+
export declare namespace HierarchyNodesDefinition {
|
|
38
|
+
function isCustomNode(def: HierarchyNodesDefinition): def is CustomHierarchyNodeDefinition;
|
|
39
|
+
function isInstanceNodesQuery(def: HierarchyNodesDefinition): def is InstanceNodesQueryDefinition;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A definition of a hierarchy level, which may consist of multiple node definitions.
|
|
43
|
+
* @beta
|
|
44
|
+
*/
|
|
45
|
+
export type HierarchyLevelDefinition = HierarchyNodesDefinition[];
|
|
46
|
+
/**
|
|
47
|
+
* A type for a function that parses a `ParsedInstanceHierarchyNode` from provided ECSQL `row` object.
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
export type NodeParser = (row: {
|
|
51
|
+
[columnName: string]: any;
|
|
52
|
+
}) => ParsedInstanceHierarchyNode;
|
|
53
|
+
/**
|
|
54
|
+
* A type for a function that pre-processes given node. Unless the function decides not to make any modifications,
|
|
55
|
+
* it should return a new - modified - node, rather than modifying the given one. Returning `undefined` omits the node
|
|
56
|
+
* from the hierarchy.
|
|
57
|
+
*
|
|
58
|
+
* @beta
|
|
59
|
+
*/
|
|
60
|
+
export type NodePreProcessor = <TNode extends ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode>(node: TNode) => Promise<TNode | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* A type for a function that post-processes given node. Unless the function decides not to make any modifications,
|
|
63
|
+
* it should return a new - modified - node, rather than modifying the given one.
|
|
64
|
+
*
|
|
65
|
+
* @beta
|
|
66
|
+
*/
|
|
67
|
+
export type NodePostProcessor = (node: ProcessedHierarchyNode) => Promise<ProcessedHierarchyNode>;
|
|
68
|
+
/**
|
|
69
|
+
* A type of node that can be passed to `HierarchyDefinition.defineHierarchyLevel`. This basically means
|
|
70
|
+
* a `HierarchyNode` that:
|
|
71
|
+
* - knows nothing about its children,
|
|
72
|
+
* - is either an instances node (key is of `InstancesNodeKey` type) or a custom node (key is of `string` type).
|
|
73
|
+
*/
|
|
74
|
+
type HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, "children">;
|
|
75
|
+
/**
|
|
76
|
+
* Props for `HierarchyDefinition.defineHierarchyLevel`.
|
|
77
|
+
* @beta
|
|
78
|
+
*/
|
|
79
|
+
export interface DefineHierarchyLevelProps {
|
|
80
|
+
/** Parent node to get children for. Pass `undefined` to get root nodes. */
|
|
81
|
+
parentNode: HierarchyDefinitionParentNode | undefined;
|
|
82
|
+
/** Optional hierarchy level filter. */
|
|
83
|
+
instanceFilter?: GenericInstanceFilter;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* An interface for a factory that knows how define a hierarchy based on a given parent node.
|
|
87
|
+
* @beta
|
|
88
|
+
*/
|
|
89
|
+
export interface HierarchyDefinition {
|
|
90
|
+
/**
|
|
91
|
+
* An optional function for parsing ECInstance node from ECSQL row.
|
|
92
|
+
*
|
|
93
|
+
* Should be used in situations when the `HierarchyDefinition` implementation
|
|
94
|
+
* introduces additional ECSQL columns into the select clause and wants to assign additional
|
|
95
|
+
* data to the nodes it produces.
|
|
96
|
+
*
|
|
97
|
+
* Defaults to a function that parses all `HierarchyNode` attributes from a query, whose SELECT
|
|
98
|
+
* clause is created using `NodeSelectQueryFactory.createSelectClause`.
|
|
99
|
+
*/
|
|
100
|
+
parseNode?: NodeParser;
|
|
101
|
+
/**
|
|
102
|
+
* An optional function for pre-processing nodes.
|
|
103
|
+
*
|
|
104
|
+
* Pre-processing happens immediately after the nodes are loaded based on `HierarchyLevelDefinition`
|
|
105
|
+
* returned by this `HierarchyDefinition` and before their processing (hiding, grouping, sorting, etc.) starts.
|
|
106
|
+
* The step allows assigning nodes additional data or excluding them from the hierarchy based on some attributes.
|
|
107
|
+
*/
|
|
108
|
+
preProcessNode?: NodePreProcessor;
|
|
109
|
+
/**
|
|
110
|
+
* An optional function for post-processing nodes.
|
|
111
|
+
*
|
|
112
|
+
* Post-processing happens after the loaded nodes go through all the merging, hiding and grouping
|
|
113
|
+
* steps, but before sorting them. This step allows `HierarchyDefinition` implementations to assign additional data
|
|
114
|
+
* to nodes after they're processed. This is especially true for grouping nodes as they're only created during
|
|
115
|
+
* processing.
|
|
116
|
+
*/
|
|
117
|
+
postProcessNode?: NodePostProcessor;
|
|
118
|
+
/** A function to create a hierarchy level definition for given parent node. */
|
|
119
|
+
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Props for defining child hierarchy level for specific parent instance node.
|
|
123
|
+
* @see `createClassBasedHierarchyDefinition`
|
|
124
|
+
* @beta
|
|
125
|
+
*/
|
|
126
|
+
export type DefineInstanceNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, "parentNode"> & {
|
|
127
|
+
/** The parent instance node. */
|
|
128
|
+
parentNode: Omit<HierarchyDefinitionParentNode, "key"> & {
|
|
129
|
+
key: InstancesNodeKey;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Full name of the parent instance node class.
|
|
133
|
+
*
|
|
134
|
+
* The `parentNode.key` also contains information about the instances the parent node is based on. However,
|
|
135
|
+
* an instance node may be based on instances of multiple classes. In case that happens, parent node's instance
|
|
136
|
+
* keys are grouped by class and a hierarchy level definition is requested for each combination of class and
|
|
137
|
+
* instance IDs (with the same `parentNode`).
|
|
138
|
+
*/
|
|
139
|
+
parentNodeClassName: string;
|
|
140
|
+
/**
|
|
141
|
+
* ECInstanceIds of the parent instance node.
|
|
142
|
+
*
|
|
143
|
+
* The `parentNode.key` also contains information about the instances the parent node is based on. However,
|
|
144
|
+
* an instance node may be based on instances of multiple classes. In case that happens, parent node's instance
|
|
145
|
+
* keys are grouped by class and a hierarchy level definition is requested for each combination of class and
|
|
146
|
+
* instance IDs (with the same `parentNode`).
|
|
147
|
+
*/
|
|
148
|
+
parentNodeInstanceIds: Id64String[];
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* A definition of a hierarchy level that should be used for specific class of parent instance nodes.
|
|
152
|
+
*/
|
|
153
|
+
interface InstancesNodeChildHierarchyLevelDefinition {
|
|
154
|
+
/**
|
|
155
|
+
* Full name of the parent instance node's class to match against when checking if this hierarchy
|
|
156
|
+
* level should be used for specific parent instance node.
|
|
157
|
+
*
|
|
158
|
+
* The check is polymorphic, so `BisCore.Element` class would match `BisCore.GeometricElement`, `BisCore.Category` and
|
|
159
|
+
* all other element classes.
|
|
160
|
+
*/
|
|
161
|
+
parentNodeClassName: string;
|
|
162
|
+
/**
|
|
163
|
+
* Called to create a hierarchy level definition when the class check passes (see `parentNodeClassName`).
|
|
164
|
+
*/
|
|
165
|
+
definitions: (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Props for defining child hierarchy level for specific parent custom node.
|
|
169
|
+
* @see `createClassBasedHierarchyDefinition`
|
|
170
|
+
* @beta
|
|
171
|
+
*/
|
|
172
|
+
export type DefineCustomNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, "parentNode"> & {
|
|
173
|
+
/** The parent custom node. */
|
|
174
|
+
parentNode: Omit<HierarchyDefinitionParentNode, "key"> & {
|
|
175
|
+
key: string;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* A definition of a hierarchy level for that should be used for specific custom parent nodes.
|
|
180
|
+
*/
|
|
181
|
+
interface CustomNodeChildHierarchyLevelDefinition {
|
|
182
|
+
/**
|
|
183
|
+
* `HierarchyNode.key` of the custom node that this child hierarchy level definition should be used for.
|
|
184
|
+
*/
|
|
185
|
+
customParentNodeKey: string;
|
|
186
|
+
/**
|
|
187
|
+
* Called to create a hierarchy level definition when the node key check passes (see `customParentNodeKey`).
|
|
188
|
+
*/
|
|
189
|
+
definitions: (requestProps: DefineCustomNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* A hierarchy level definition associated with either parent instance node's class or custom
|
|
193
|
+
* node's key.
|
|
194
|
+
*/
|
|
195
|
+
type ClassBasedHierarchyLevelDefinition = InstancesNodeChildHierarchyLevelDefinition | CustomNodeChildHierarchyLevelDefinition;
|
|
196
|
+
/**
|
|
197
|
+
* Props for defining root hierarchy level.
|
|
198
|
+
* @see `createClassBasedHierarchyDefinition`
|
|
199
|
+
* @beta
|
|
200
|
+
*/
|
|
201
|
+
export type DefineRootHierarchyLevelProps = Omit<DefineHierarchyLevelProps, "parentNode">;
|
|
202
|
+
/**
|
|
203
|
+
* Props for `createClassBasedHierarchyDefinition`.
|
|
204
|
+
*/
|
|
205
|
+
interface ClassBasedHierarchyDefinitionProps {
|
|
206
|
+
/** Access to ECClass hierarchy in the iModel */
|
|
207
|
+
classHierarchyInspector: ECClassHierarchyInspector;
|
|
208
|
+
/** Hierarchy level definitions based on parent instance node's class or custom node's key. */
|
|
209
|
+
hierarchy: {
|
|
210
|
+
/** Called to create the root hierarchy level definition. */
|
|
211
|
+
rootNodes: (props: DefineRootHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;
|
|
212
|
+
/**
|
|
213
|
+
* Called to get child hierarchy level definitions based on parent instance node's class
|
|
214
|
+
* or custom node's key.
|
|
215
|
+
*/
|
|
216
|
+
childNodes: ClassBasedHierarchyLevelDefinition[];
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Creates an instance of `HierarchyDefinition` that uses a somewhat declarative approach to define the
|
|
221
|
+
* hierarchy - each hierarchy level is assigned either an instance node's class or custom node's
|
|
222
|
+
* key and they're used to assign hierarchy level definitions based on parent node.
|
|
223
|
+
*
|
|
224
|
+
* @beta
|
|
225
|
+
*/
|
|
226
|
+
export declare function createClassBasedHierarchyDefinition(props: ClassBasedHierarchyDefinitionProps): HierarchyDefinition;
|
|
227
|
+
export {};
|
|
228
|
+
//# sourceMappingURL=HierarchyDefinition.d.ts.map
|
|
@@ -0,0 +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;AAEtD;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,oDAAoD;IACpD,IAAI,EAAE,yBAAyB,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WA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IAAI,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC;AAE1F;;GAEG;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"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createClassBasedHierarchyDefinition = exports.HierarchyNodesDefinition = void 0;
|
|
8
|
+
const HierarchyNode_1 = require("./HierarchyNode");
|
|
9
|
+
/** @beta */
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
11
|
+
var HierarchyNodesDefinition;
|
|
12
|
+
(function (HierarchyNodesDefinition) {
|
|
13
|
+
function isCustomNode(def) {
|
|
14
|
+
return !!def.node;
|
|
15
|
+
}
|
|
16
|
+
HierarchyNodesDefinition.isCustomNode = isCustomNode;
|
|
17
|
+
function isInstanceNodesQuery(def) {
|
|
18
|
+
return !!def.query;
|
|
19
|
+
}
|
|
20
|
+
HierarchyNodesDefinition.isInstanceNodesQuery = isInstanceNodesQuery;
|
|
21
|
+
})(HierarchyNodesDefinition || (exports.HierarchyNodesDefinition = HierarchyNodesDefinition = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of `HierarchyDefinition` that uses a somewhat declarative approach to define the
|
|
24
|
+
* hierarchy - each hierarchy level is assigned either an instance node's class or custom node's
|
|
25
|
+
* key and they're used to assign hierarchy level definitions based on parent node.
|
|
26
|
+
*
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
function createClassBasedHierarchyDefinition(props) {
|
|
30
|
+
return new ClassBasedHierarchyDefinition(props);
|
|
31
|
+
}
|
|
32
|
+
exports.createClassBasedHierarchyDefinition = createClassBasedHierarchyDefinition;
|
|
33
|
+
class ClassBasedHierarchyDefinition {
|
|
34
|
+
_props;
|
|
35
|
+
constructor(_props) {
|
|
36
|
+
this._props = _props;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create hierarchy level definitions for specific hierarchy level.
|
|
40
|
+
* @param parentNode Parent node to create children definitions for.
|
|
41
|
+
*/
|
|
42
|
+
async defineHierarchyLevel(props) {
|
|
43
|
+
const { parentNode } = props;
|
|
44
|
+
if (!parentNode) {
|
|
45
|
+
return this._props.hierarchy.rootNodes(props);
|
|
46
|
+
}
|
|
47
|
+
if (HierarchyNode_1.HierarchyNode.isCustom(parentNode)) {
|
|
48
|
+
const defs = this._props.hierarchy.childNodes
|
|
49
|
+
.filter(isCustomNodeChildHierarchyLevelDefinition)
|
|
50
|
+
.filter((def) => def.customParentNodeKey === parentNode.key);
|
|
51
|
+
return (await Promise.all(defs.map(async (def) => def.definitions({ ...props, parentNode })))).flat();
|
|
52
|
+
}
|
|
53
|
+
// istanbul ignore else
|
|
54
|
+
if (HierarchyNode_1.HierarchyNode.isInstancesNode(parentNode)) {
|
|
55
|
+
const instanceIdsByClass = groupInstanceIdsByClass(parentNode.key.instanceKeys);
|
|
56
|
+
const instancesParentNodeDefs = this._props.hierarchy.childNodes.filter(isInstancesNodeChildHierarchyLevelDefinition);
|
|
57
|
+
return (await Promise.all([...instanceIdsByClass.entries()].map(async ([parentNodeClassName, parentNodeInstanceIds]) => createHierarchyLevelDefinitions(this._props.classHierarchyInspector, instancesParentNodeDefs, {
|
|
58
|
+
...props,
|
|
59
|
+
parentNodeClassName,
|
|
60
|
+
parentNodeInstanceIds,
|
|
61
|
+
parentNode,
|
|
62
|
+
})))).flat();
|
|
63
|
+
}
|
|
64
|
+
// istanbul ignore next
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function createHierarchyLevelDefinitions(classHierarchy, defs, requestProps) {
|
|
69
|
+
return (await Promise.all(defs.map(async (def) => {
|
|
70
|
+
if (await classHierarchy.classDerivesFrom(requestProps.parentNodeClassName, def.parentNodeClassName)) {
|
|
71
|
+
return def.definitions(requestProps);
|
|
72
|
+
}
|
|
73
|
+
return [];
|
|
74
|
+
}))).flat();
|
|
75
|
+
}
|
|
76
|
+
function groupInstanceIdsByClass(instanceKeys) {
|
|
77
|
+
const instanceIdsByClass = new Map();
|
|
78
|
+
instanceKeys.forEach((key) => {
|
|
79
|
+
let instanceIds = instanceIdsByClass.get(key.className);
|
|
80
|
+
if (!instanceIds) {
|
|
81
|
+
instanceIds = [];
|
|
82
|
+
instanceIdsByClass.set(key.className, instanceIds);
|
|
83
|
+
}
|
|
84
|
+
instanceIds.push(key.id);
|
|
85
|
+
});
|
|
86
|
+
return instanceIdsByClass;
|
|
87
|
+
}
|
|
88
|
+
function isCustomNodeChildHierarchyLevelDefinition(def) {
|
|
89
|
+
return !!def.customParentNodeKey;
|
|
90
|
+
}
|
|
91
|
+
function isInstancesNodeChildHierarchyLevelDefinition(def) {
|
|
92
|
+
return !!def.parentNodeClassName;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=HierarchyDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HierarchyDefinition.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAKhG,mDAQyB;AAmCzB,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,wB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AAwB,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HierarchyErrors.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyErrors.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;aACZ,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAGjD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RowsLimitExceededError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Error that is thrown when rows amount exceed hierarchy level limit.
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
class RowsLimitExceededError extends Error {
|
|
13
|
+
limit;
|
|
14
|
+
constructor(limit) {
|
|
15
|
+
super(`Query rows limit of ${limit} exceeded`);
|
|
16
|
+
this.limit = limit;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.RowsLimitExceededError = RowsLimitExceededError;
|
|
20
|
+
//# sourceMappingURL=HierarchyErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HierarchyErrors.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyErrors.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IACZ;IAAnC,YAAmC,KAAa;QAC9C,KAAK,CAAC,uBAAuB,KAAK,WAAW,CAAC,CAAC;QADd,UAAK,GAAL,KAAK,CAAQ;IAEhD,CAAC;CACF;AAJD,wDAIC","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\n/**\n * Error that is thrown when rows amount exceed hierarchy level limit.\n * @beta\n */\nexport class RowsLimitExceededError extends Error {\n public constructor(public readonly limit: number) {\n super(`Query rows limit of ${limit} exceeded`);\n }\n}\n"]}
|