@itwin/presentation-hierarchies 1.0.0 → 1.2.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 +35 -0
- package/lib/cjs/hierarchies/HierarchyErrors.d.ts +1 -1
- package/lib/cjs/hierarchies/HierarchyErrors.js +1 -1
- package/lib/cjs/hierarchies/HierarchyErrors.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +12 -11
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyFiltering.js +16 -21
- package/lib/cjs/hierarchies/HierarchyFiltering.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +10 -10
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js +13 -13
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts +4 -4
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts +13 -13
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +6 -6
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js +6 -6
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/Logging.d.ts +2 -2
- package/lib/cjs/hierarchies/Logging.js +3 -3
- package/lib/cjs/hierarchies/Logging.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +9 -18
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +104 -50
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/HierarchyCache.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/HierarchyCache.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/HierarchyCache.js +2 -2
- package/lib/cjs/hierarchies/imodel/HierarchyCache.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +14 -14
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts +23 -23
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.js +5 -5
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +8 -8
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +95 -87
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.js +17 -14
- package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts +16 -16
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +2 -2
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +10 -10
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js +5 -10
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +4 -4
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +5 -3
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/Utils.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/Utils.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/Utils.js +2 -2
- package/lib/cjs/hierarchies/imodel/Utils.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.js +8 -8
- package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/Grouping.d.ts +3 -3
- package/lib/cjs/hierarchies/imodel/operators/Grouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/Grouping.js +42 -42
- package/lib/cjs/hierarchies/imodel/operators/Grouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js +16 -16
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.js +25 -25
- package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/AutoExpand.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/AutoExpand.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/AutoExpand.js +2 -2
- package/lib/cjs/hierarchies/imodel/operators/grouping/AutoExpand.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts +3 -3
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +3 -3
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts +3 -3
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +2 -2
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/GroupHiding.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/GroupHiding.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/GroupHiding.js +2 -2
- package/lib/cjs/hierarchies/imodel/operators/grouping/GroupHiding.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/LabelGrouping.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/operators/grouping/LabelGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/LabelGrouping.js +2 -2
- package/lib/cjs/hierarchies/imodel/operators/grouping/LabelGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +3 -3
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +13 -18
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/Shared.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/operators/grouping/Shared.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/Shared.js.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.d.ts +1 -1
- package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.js +2 -1
- package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
- package/lib/cjs/hierarchies/internal/EachValueFrom.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/EachValueFrom.js +3 -0
- package/lib/cjs/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/cjs/hierarchies/internal/LoggingUtils.js +2 -2
- package/lib/cjs/hierarchies/internal/LoggingUtils.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.js +2 -2
- package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +13 -13
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js +29 -29
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyErrors.d.ts +1 -1
- package/lib/esm/hierarchies/HierarchyErrors.js +1 -1
- package/lib/esm/hierarchies/HierarchyErrors.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts +12 -11
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyFiltering.js +16 -21
- package/lib/esm/hierarchies/HierarchyFiltering.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.d.ts +10 -10
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js +3 -3
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts +4 -4
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.js +1 -1
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts +13 -13
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +6 -6
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js +3 -3
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/Logging.d.ts +2 -2
- package/lib/esm/hierarchies/Logging.js +3 -3
- package/lib/esm/hierarchies/Logging.js.map +1 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +9 -18
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +92 -38
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/HierarchyCache.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/HierarchyCache.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/HierarchyCache.js +1 -1
- package/lib/esm/hierarchies/imodel/HierarchyCache.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +14 -14
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts +23 -23
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.js +2 -2
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +8 -8
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +49 -41
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.js +11 -8
- package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts +16 -16
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +2 -2
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +10 -10
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js +5 -10
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +4 -4
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js +6 -4
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/esm/hierarchies/imodel/Utils.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/Utils.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/Utils.js +1 -1
- package/lib/esm/hierarchies/imodel/Utils.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/DetermineChildren.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/DetermineChildren.js +6 -6
- package/lib/esm/hierarchies/imodel/operators/DetermineChildren.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/Grouping.d.ts +3 -3
- package/lib/esm/hierarchies/imodel/operators/Grouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/Grouping.js +22 -22
- package/lib/esm/hierarchies/imodel/operators/Grouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js +10 -10
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.js +14 -14
- package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/AutoExpand.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/AutoExpand.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/AutoExpand.js +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/AutoExpand.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts +3 -3
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +2 -2
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts +3 -3
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/GroupHiding.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/GroupHiding.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/GroupHiding.js +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/GroupHiding.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/LabelGrouping.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/operators/grouping/LabelGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/LabelGrouping.js +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/LabelGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +3 -3
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +9 -14
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/Shared.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/operators/grouping/Shared.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/Shared.js.map +1 -1
- package/lib/esm/hierarchies/internal/Common.d.ts +1 -1
- package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/Common.js +2 -1
- package/lib/esm/hierarchies/internal/Common.js.map +1 -1
- package/lib/esm/hierarchies/internal/EachValueFrom.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/EachValueFrom.js +3 -0
- package/lib/esm/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/esm/hierarchies/internal/LoggingUtils.js +1 -1
- package/lib/esm/hierarchies/internal/LoggingUtils.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Sorting.js +1 -1
- package/lib/esm/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +13 -13
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +13 -13
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +24 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyProvider.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAK7D,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"HierarchyProvider.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,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,EAAE,WAAW,EAAE,CAAC,CAAC,CAC3D,CAAC;QACJ,CAAC,CAAC,CACH,CACF,EACD,wBAAwB,CAEzB,CACF;QACH,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClH,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAChF,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACpF,OAAO,EAAE,GAAG,EAAE;YACZ,gBAAgB,CAAC,KAAK,EAAE,CAAC;YACzB,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACtB,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YAClC,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { filter, first, from, map, mergeMap, of } from \"rxjs\";\nimport { BeEvent, isIDisposable } from \"@itwin/core-bentley\";\nimport { GenericInstanceFilter } from \"@itwin/core-common\";\nimport { Event, InstanceKey, IPrimitiveValueFormatter } from \"@itwin/presentation-shared\";\nimport { HierarchyFilteringPath } from \"./HierarchyFiltering.js\";\nimport { HierarchyNode, ParentHierarchyNode } from \"./HierarchyNode.js\";\nimport { eachValueFrom } from \"./internal/EachValueFrom.js\";\nimport { sortNodesByLabelOperator } from \"./internal/operators/Sorting.js\";\n\n/**\n * Props for the `HierarchyProvider.getNodes` call.\n * @public\n */\nexport interface GetHierarchyNodesProps {\n /** Parent node to get children for. Pass `undefined` to get root nodes. */\n parentNode: ParentHierarchyNode | undefined;\n\n /** Optional hierarchy level filter. Has no effect if `parentNode` is a `GroupingNode`. */\n instanceFilter?: GenericInstanceFilter;\n\n /**\n * Optional hierarchy level size limit override. This value is passed to `LimitingECSqlQueryExecutor` used\n * by this provider to override query rows limit per hierarchy level. If not provided, defaults to whatever\n * is used by the limiting query executor.\n *\n * Has no effect if `parentNode` is a `GroupingNode`.\n */\n hierarchyLevelSizeLimit?: number | \"unbounded\";\n\n /** When set to true ignores the cache and fetches the nodes again. */\n ignoreCache?: boolean;\n}\n\n/**\n * An interface for a hierarchy provider that knows how to create child nodes for a given parent node.\n * @public\n */\nexport interface HierarchyProvider {\n /**\n * An event that provider raises when the internal data source changes, resulting in a\n * hierarchy change.\n *\n * Consumers are expected to subscribe to this event and reload the hierarchy when it's raised.\n */\n readonly hierarchyChanged: Event<() => void>;\n\n /** Gets nodes for the specified parent node. */\n getNodes(props: GetHierarchyNodesProps): AsyncIterableIterator<HierarchyNode>;\n\n /** Gets instance keys for the specified parent node. */\n getNodeInstanceKeys(props: Omit<GetHierarchyNodesProps, \"ignoreCache\">): AsyncIterableIterator<InstanceKey>;\n\n /**\n * Overrides the property value formatter used by the hierarchy provider. Setting to `undefined`\n * resets the formatter to the result of `createDefaultValueFormatter` called with default parameters.\n */\n setFormatter(formatter: IPrimitiveValueFormatter | undefined): void;\n\n /**\n * Sets the hierarchy filter used by this hierarchy provider. Setting to `undefined`\n * removes the filter.\n */\n setHierarchyFilter(\n props:\n | {\n /** A list of node identifiers from root to target node. */\n paths: HierarchyFilteringPath[];\n }\n | undefined,\n ): void;\n}\n\n/**\n * Props for `mergeProviders` function.\n * @public\n */\ninterface MergeHierarchyProvidersProps {\n /** List of providers to merge. */\n providers: HierarchyProvider[];\n}\n\n/**\n * Creates a single, merged, hierarchy provider from multiple given providers.\n * @public\n */\nexport function mergeProviders({ providers }: MergeHierarchyProvidersProps): HierarchyProvider & { dispose: () => void } {\n const hierarchyChanged = new BeEvent<() => void>();\n providers.forEach((p) => {\n p.hierarchyChanged.addListener(() => hierarchyChanged.raiseEvent());\n });\n\n return {\n hierarchyChanged,\n getNodes: (props) =>\n eachValueFrom(\n from(providers).pipe(\n mergeMap((provider) =>\n from(provider.getNodes(props)).pipe(\n mergeMap((node) => {\n if (node.children) {\n return of(node);\n }\n // each provider only considers its own data when determining node's children - in case it says\n // the node has no children, we have to check against the other providers too\n return from(providers).pipe(\n filter((p) => p !== provider),\n mergeMap((p) => p.getNodes({ parentNode: node })),\n map(() => true),\n first(undefined, false),\n map((hasChildren) => ({ ...node, children: hasChildren })),\n );\n }),\n ),\n ),\n sortNodesByLabelOperator,\n // TODO: consider merging similar nodes\n ),\n ),\n getNodeInstanceKeys: (props) => eachValueFrom(from(providers).pipe(mergeMap((p) => p.getNodeInstanceKeys(props)))),\n setFormatter: (formatter) => providers.forEach((p) => p.setFormatter(formatter)),\n setHierarchyFilter: (props) => providers.forEach((p) => p.setHierarchyFilter(props)),\n dispose: () => {\n hierarchyChanged.clear();\n providers.forEach((p) => {\n isIDisposable(p) && p.dispose();\n });\n },\n };\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ILogger } from "@itwin/presentation-shared";
|
|
2
2
|
/**
|
|
3
3
|
* Set logger to use by this package. By default the package uses a no-op logger.
|
|
4
|
-
* @
|
|
4
|
+
* @public
|
|
5
5
|
*/
|
|
6
6
|
export declare function setLogger(logger: ILogger | undefined): void;
|
|
7
7
|
/**
|
|
8
8
|
* Get logger used by this package.
|
|
9
9
|
* @see `setLogger`
|
|
10
|
-
* @
|
|
10
|
+
* @public
|
|
11
11
|
*/
|
|
12
12
|
export declare function getLogger(): ILogger;
|
|
13
13
|
//# sourceMappingURL=Logging.d.ts.map
|
|
@@ -7,15 +7,15 @@ import { NOOP_LOGGER } from "@itwin/presentation-shared";
|
|
|
7
7
|
let g_logger = NOOP_LOGGER;
|
|
8
8
|
/**
|
|
9
9
|
* Set logger to use by this package. By default the package uses a no-op logger.
|
|
10
|
-
* @
|
|
10
|
+
* @public
|
|
11
11
|
*/
|
|
12
12
|
export function setLogger(logger) {
|
|
13
|
-
g_logger = logger ?? /*
|
|
13
|
+
g_logger = logger ?? /* c8 ignore next */ NOOP_LOGGER;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Get logger used by this package.
|
|
17
17
|
* @see `setLogger`
|
|
18
|
-
* @
|
|
18
|
+
* @public
|
|
19
19
|
*/
|
|
20
20
|
export function getLogger() {
|
|
21
21
|
return g_logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../src/hierarchies/Logging.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAW,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAElE,gEAAgE;AAChE,IAAI,QAAQ,GAAY,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAA2B;IACnD,QAAQ,GAAG,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../src/hierarchies/Logging.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAW,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAElE,gEAAgE;AAChE,IAAI,QAAQ,GAAY,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAA2B;IACnD,QAAQ,GAAG,MAAM,IAAI,oBAAoB,CAAC,WAAW,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,QAAQ,CAAC;AAClB,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 { ILogger, NOOP_LOGGER } from \"@itwin/presentation-shared\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nlet g_logger: ILogger = NOOP_LOGGER;\n\n/**\n * Set logger to use by this package. By default the package uses a no-op logger.\n * @public\n */\nexport function setLogger(logger: ILogger | undefined) {\n g_logger = logger ?? /* c8 ignore next */ NOOP_LOGGER;\n}\n\n/**\n * Get logger used by this package.\n * @see `setLogger`\n * @public\n */\nexport function getLogger(): ILogger {\n return g_logger;\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ECClassHierarchyInspector, InstanceKey } from "@itwin/presentation-shared";
|
|
2
|
-
import { HierarchyFilteringPath
|
|
3
|
-
import {
|
|
4
|
-
import { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, InstanceNodesQueryDefinition, NodeParser, NodePostProcessor, NodePreProcessor } from "./IModelHierarchyDefinition";
|
|
2
|
+
import { HierarchyFilteringPath } from "../HierarchyFiltering.js";
|
|
3
|
+
import { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, InstanceNodesQueryDefinition, NodeParser, NodePostProcessor, NodePreProcessor } from "./IModelHierarchyDefinition.js";
|
|
5
4
|
interface FilteringHierarchyDefinitionProps {
|
|
6
5
|
imodelAccess: ECClassHierarchyInspector & {
|
|
7
6
|
imodelKey: string;
|
|
@@ -19,26 +18,18 @@ export declare class FilteringHierarchyDefinition implements HierarchyDefinition
|
|
|
19
18
|
private shouldExpandGroupingNode;
|
|
20
19
|
get postProcessNode(): NodePostProcessor;
|
|
21
20
|
get parseNode(): NodeParser;
|
|
21
|
+
private getChildrenIdentifierPaths;
|
|
22
22
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
23
23
|
}
|
|
24
|
-
type MatchedFilter<TIdentifier extends HierarchyNodeIdentifier> = {
|
|
25
|
-
id: TIdentifier;
|
|
26
|
-
childrenIdentifierPaths: HierarchyFilteringPath[];
|
|
27
|
-
} & ({
|
|
28
|
-
isFilterTarget: false;
|
|
29
|
-
} | {
|
|
30
|
-
isFilterTarget: true;
|
|
31
|
-
filterTargetOptions?: HierarchyFilteringPathOptions;
|
|
32
|
-
});
|
|
33
24
|
/** @internal */
|
|
34
|
-
export declare const
|
|
35
|
-
/** @internal */
|
|
36
|
-
export declare const ECSQL_COLUMN_NAME_IsFilterTarget = "IsFilterTarget";
|
|
25
|
+
export declare const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = "HasFilterTargetAncestor";
|
|
37
26
|
/** @internal */
|
|
38
|
-
export declare const
|
|
27
|
+
export declare const ECSQL_COLUMN_NAME_FilterECInstanceId = "FilterECInstanceId";
|
|
39
28
|
/** @internal */
|
|
40
|
-
export declare const
|
|
29
|
+
export declare const ECSQL_COLUMN_NAME_FilterClassName = "FilterClassName";
|
|
41
30
|
/** @internal */
|
|
42
|
-
export declare function applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, matchingFilters: Array<
|
|
31
|
+
export declare function applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, matchingFilters: Array<{
|
|
32
|
+
id: InstanceKey;
|
|
33
|
+
}>, hasFilterTargetAncestor: boolean): InstanceNodesQueryDefinition;
|
|
43
34
|
export {};
|
|
44
35
|
//# sourceMappingURL=FilteringHierarchyDefinition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,WAAW,E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ley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { extractFilteringProps, HierarchyFilteringPath } from "../HierarchyFiltering";
|
|
6
|
-
import { HierarchyNodeFilteringProps } from "../HierarchyNode";
|
|
7
|
-
import { HierarchyNodeIdentifier } from "../HierarchyNodeIdentifier";
|
|
8
|
-
import { HierarchyNodesDefinition, } from "./IModelHierarchyDefinition";
|
|
9
|
-
import { ProcessedHierarchyNode } from "./IModelHierarchyNode";
|
|
10
|
-
import { defaultNodesParser } from "./TreeNodesReader";
|
|
5
|
+
import { extractFilteringProps, HierarchyFilteringPath } from "../HierarchyFiltering.js";
|
|
6
|
+
import { HierarchyNodeFilteringProps } from "../HierarchyNode.js";
|
|
7
|
+
import { HierarchyNodeIdentifier } from "../HierarchyNodeIdentifier.js";
|
|
8
|
+
import { HierarchyNodesDefinition, } from "./IModelHierarchyDefinition.js";
|
|
9
|
+
import { ProcessedHierarchyNode } from "./IModelHierarchyNode.js";
|
|
10
|
+
import { defaultNodesParser } from "./TreeNodesReader.js";
|
|
11
11
|
/** @internal */
|
|
12
12
|
export class FilteringHierarchyDefinition {
|
|
13
13
|
_imodelAccess;
|
|
@@ -30,7 +30,7 @@ export class FilteringHierarchyDefinition {
|
|
|
30
30
|
}
|
|
31
31
|
shouldExpandGroupingNode(node) {
|
|
32
32
|
for (const child of node.children) {
|
|
33
|
-
|
|
33
|
+
/* c8 ignore next 3 */
|
|
34
34
|
if (!child.filtering) {
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
@@ -53,7 +53,7 @@ export class FilteringHierarchyDefinition {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
if (!child.filtering.filteredChildrenIdentifierPaths) {
|
|
56
|
-
|
|
56
|
+
/* c8 ignore next */
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
59
|
for (const path of child.filtering.filteredChildrenIdentifierPaths) {
|
|
@@ -75,16 +75,15 @@ export class FilteringHierarchyDefinition {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
get parseNode() {
|
|
78
|
-
return (row) => {
|
|
78
|
+
return async (row, parentNode) => {
|
|
79
79
|
const hasFilterTargetAncestor = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];
|
|
80
|
-
const isFilterTarget =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);
|
|
80
|
+
const { filteredChildrenIdentifierPaths, filterTargetOptions, isFilterTarget } = row[ECSQL_COLUMN_NAME_FilterECInstanceId] && row[ECSQL_COLUMN_NAME_FilterClassName]
|
|
81
|
+
? await this.getChildrenIdentifierPaths(parentNode?.filtering?.filteredChildrenIdentifierPaths ?? this._nodeIdentifierPaths, {
|
|
82
|
+
className: row[ECSQL_COLUMN_NAME_FilterClassName],
|
|
83
|
+
id: row[ECSQL_COLUMN_NAME_FilterECInstanceId],
|
|
84
|
+
})
|
|
85
|
+
: { filteredChildrenIdentifierPaths: [], filterTargetOptions: undefined, isFilterTarget: false };
|
|
86
|
+
const defaultNode = await (this._source.parseNode ?? defaultNodesParser)(row);
|
|
88
87
|
return applyFilterAttributes({
|
|
89
88
|
node: defaultNode,
|
|
90
89
|
filteredChildrenIdentifierPaths,
|
|
@@ -94,6 +93,49 @@ export class FilteringHierarchyDefinition {
|
|
|
94
93
|
});
|
|
95
94
|
};
|
|
96
95
|
}
|
|
96
|
+
async getChildrenIdentifierPaths(filteredChildrenNodeIdentifierPaths, providedIdentifier) {
|
|
97
|
+
const { id, className } = providedIdentifier;
|
|
98
|
+
let filteredChildrenIdentifierPaths;
|
|
99
|
+
let isFilterTarget = false;
|
|
100
|
+
let filterTargetOptions;
|
|
101
|
+
for (const filteredChildrenNodeIdentifierPath of filteredChildrenNodeIdentifierPaths) {
|
|
102
|
+
const { path, options } = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
|
|
103
|
+
/* c8 ignore next 3 */
|
|
104
|
+
if (path.length === 0) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
// We need to check if identifiers have the same id and imodelKey and are
|
|
108
|
+
// of the same class / derived class / is derived from class
|
|
109
|
+
const identifier = path[0];
|
|
110
|
+
if (identifier.id !== id) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {
|
|
114
|
+
if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (identifier.className !== className &&
|
|
118
|
+
!(await this._imodelAccess.classDerivesFrom(identifier.className, className)) &&
|
|
119
|
+
!(await this._imodelAccess.classDerivesFrom(className, identifier.className))) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (!filteredChildrenIdentifierPaths) {
|
|
124
|
+
filteredChildrenIdentifierPaths = [];
|
|
125
|
+
}
|
|
126
|
+
if (path.length > 1) {
|
|
127
|
+
filteredChildrenIdentifierPaths.push(options ? { path: path.slice(1), options } : path.slice(1));
|
|
128
|
+
}
|
|
129
|
+
else if (isFilterTarget) {
|
|
130
|
+
filterTargetOptions = HierarchyFilteringPath.mergeOptions(filterTargetOptions, options);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
isFilterTarget = true;
|
|
134
|
+
filterTargetOptions = options;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { filteredChildrenIdentifierPaths, filterTargetOptions, isFilterTarget };
|
|
138
|
+
}
|
|
97
139
|
async defineHierarchyLevel(props) {
|
|
98
140
|
const sourceDefinitions = await this._source.defineHierarchyLevel(props);
|
|
99
141
|
const filteringProps = extractFilteringProps(this._nodeIdentifierPaths, props.parentNode);
|
|
@@ -116,6 +158,7 @@ export class FilteringHierarchyDefinition {
|
|
|
116
158
|
node: def.node,
|
|
117
159
|
filteredChildrenIdentifierPaths,
|
|
118
160
|
isFilterTarget: matchingFilters.some((mc) => mc.isFilterTarget),
|
|
161
|
+
filterTargetOptions: matchingFilters.find((mc) => mc.isFilterTarget)?.filterTargetOptions,
|
|
119
162
|
hasFilterTargetAncestor: filteringProps.hasFilterTargetAncestor,
|
|
120
163
|
}),
|
|
121
164
|
};
|
|
@@ -126,7 +169,7 @@ export class FilteringHierarchyDefinition {
|
|
|
126
169
|
return (HierarchyNodeIdentifier.isInstanceNodeIdentifier(id) &&
|
|
127
170
|
(!id.imodelKey || id.imodelKey === this._imodelAccess.imodelKey) &&
|
|
128
171
|
(await this._imodelAccess.classDerivesFrom(id.className, definition.fullClassName)));
|
|
129
|
-
}, this._imodelAccess, (def, matchingFilters) => applyECInstanceIdsFilter(def, matchingFilters, !!filteringProps.hasFilterTargetAncestor));
|
|
172
|
+
}, this._imodelAccess, (def, matchingFilters) => applyECInstanceIdsFilter(def, matchingFilters, !!filteringProps.hasFilterTargetAncestor), false);
|
|
130
173
|
}
|
|
131
174
|
if (matchedDefinition) {
|
|
132
175
|
filteredDefinitions.push(matchedDefinition);
|
|
@@ -135,7 +178,7 @@ export class FilteringHierarchyDefinition {
|
|
|
135
178
|
return filteredDefinitions;
|
|
136
179
|
}
|
|
137
180
|
}
|
|
138
|
-
async function matchFilters(definition, filteringProps, predicate, classHierarchy, matchedDefinitionProcessor) {
|
|
181
|
+
async function matchFilters(definition, filteringProps, predicate, classHierarchy, matchedDefinitionProcessor, extractPathsAndOptions = true) {
|
|
139
182
|
const { filteredNodePaths, hasFilterTargetAncestor } = filteringProps;
|
|
140
183
|
const matchingFilters = [];
|
|
141
184
|
for (const filteredNodePath of filteredNodePaths) {
|
|
@@ -156,9 +199,11 @@ async function matchFilters(definition, filteringProps, predicate, classHierarch
|
|
|
156
199
|
};
|
|
157
200
|
matchingFilters.push(entry);
|
|
158
201
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
202
|
+
if (!extractPathsAndOptions) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (path.length > 1) {
|
|
206
|
+
entry.childrenIdentifierPaths.push(options ? { path: path.slice(1), options } : path.slice(1));
|
|
162
207
|
}
|
|
163
208
|
else if (entry.isFilterTarget) {
|
|
164
209
|
entry.filterTargetOptions = HierarchyFilteringPath.mergeOptions(entry.filterTargetOptions, options);
|
|
@@ -207,44 +252,53 @@ function applyFilterAttributes(props) {
|
|
|
207
252
|
}
|
|
208
253
|
/** @internal */
|
|
209
254
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
210
|
-
export const
|
|
211
|
-
/** @internal */
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
213
|
-
export const ECSQL_COLUMN_NAME_IsFilterTarget = "IsFilterTarget";
|
|
255
|
+
export const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = "HasFilterTargetAncestor";
|
|
214
256
|
/** @internal */
|
|
215
257
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
216
|
-
export const
|
|
258
|
+
export const ECSQL_COLUMN_NAME_FilterECInstanceId = "FilterECInstanceId";
|
|
217
259
|
/** @internal */
|
|
218
260
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
219
|
-
export const
|
|
261
|
+
export const ECSQL_COLUMN_NAME_FilterClassName = "FilterClassName";
|
|
262
|
+
function getClassECInstanceIds(matchingFilters) {
|
|
263
|
+
const classNameECInstanceIds = new Map();
|
|
264
|
+
for (const matchingFilter of matchingFilters) {
|
|
265
|
+
const entry = classNameECInstanceIds.get(matchingFilter.id.className);
|
|
266
|
+
if (entry === undefined) {
|
|
267
|
+
classNameECInstanceIds.set(matchingFilter.id.className, [matchingFilter.id.id]);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
entry.push(matchingFilter.id.id);
|
|
271
|
+
}
|
|
272
|
+
return classNameECInstanceIds;
|
|
273
|
+
}
|
|
220
274
|
/** @internal */
|
|
221
275
|
export function applyECInstanceIdsFilter(def, matchingFilters, hasFilterTargetAncestor) {
|
|
222
276
|
if (matchingFilters.length === 0) {
|
|
223
277
|
return def;
|
|
224
278
|
}
|
|
279
|
+
const matchingFiltersToUse = getClassECInstanceIds(matchingFilters);
|
|
225
280
|
return {
|
|
226
281
|
...def,
|
|
227
282
|
query: {
|
|
228
283
|
...def.query,
|
|
229
284
|
ctes: [
|
|
230
285
|
...(def.query.ctes ?? []),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
286
|
+
`FilteringInfo(ECInstanceId, FilterClassName) AS (
|
|
287
|
+
${Array.from(matchingFiltersToUse)
|
|
288
|
+
.map(([className, ecInstanceIds]) => `
|
|
289
|
+
SELECT ECInstanceId, '${className}' AS FilterClassName
|
|
290
|
+
FROM ${className}
|
|
291
|
+
WHERE ECInstanceId IN (${ecInstanceIds.join(", ")})
|
|
292
|
+
`)
|
|
238
293
|
.join(" UNION ALL ")}
|
|
239
294
|
)`,
|
|
240
295
|
],
|
|
241
296
|
ecsql: `
|
|
242
297
|
SELECT
|
|
243
298
|
[q].*,
|
|
244
|
-
[f].[IsFilterTarget] AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],
|
|
245
|
-
[f].[FilterTargetOptions] AS [${ECSQL_COLUMN_NAME_FilterTargetOptions}],
|
|
246
299
|
${hasFilterTargetAncestor ? "1" : "0"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],
|
|
247
|
-
[f].[
|
|
300
|
+
IdToHex([f].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_FilterECInstanceId}],
|
|
301
|
+
[f].[FilterClassName] AS [${ECSQL_COLUMN_NAME_FilterClassName}]
|
|
248
302
|
FROM (
|
|
249
303
|
${def.query.ecsql}
|
|
250
304
|
) [q]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAiC,MAAM,uBAAuB,CAAC;AACrH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAKL,wBAAwB,GAKzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAkC,sBAAsB,EAAoD,MAAM,uBAAuB,CAAC;AACjJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAQvD,gBAAgB;AAChB,MAAM,OAAO,4BAA4B;IAC/B,aAAa,CAAoD;IACjE,OAAO,CAAsB;IAC7B,oBAAoB,CAA2B;IAEvD,YAAmB,KAAwC;QACzD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,mBAAmB,CAAC;IACxD,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;YACpB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACnG,IAAI,aAAa,EAAE,gBAAgB,EAAE,eAAe,IAAI,aAAa,CAAC,SAAS,EAAE,cAAc,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,uBAAuB,EAAE,CAAC;gBACpJ,yHAAyH;gBACzH,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,aAAa,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC;IAEO,wBA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CAAC,CAAC,oBAAoB,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,uBAAuB,CAAC,IAAI;oBAC9K,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,6BAA6B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,uBAAuB,CAAC,IAAI,CACnG;qBACA,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;qCAGwB,gCAAgC;0CAC3B,qCAAqC;YACnE,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,yCAAyC;4CACpD,uCAAuC;;YAEvE,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACzC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { extractFilteringProps, HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"../HierarchyFiltering\";\nimport { HierarchyNodeFilteringProps } from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier\";\nimport { GenericNodeKey } from \"../HierarchyNodeKey\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"./IModelHierarchyDefinition\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, SourceHierarchyNode, SourceInstanceHierarchyNode } from \"./IModelHierarchyNode\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\ninterface FilteringHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyFilteringPath[];\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyFilteringPath[];\n\n public constructor(props: FilteringHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n if (processedNode?.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return undefined;\n }\n return processedNode;\n };\n }\n\n private shouldExpandGroupingNode(node: ProcessedGroupingHierarchyNode) {\n for (const child of node.children) {\n // istanbul ignore next\n if (!child.filtering) {\n continue;\n }\n\n if (child.filtering.isFilterTarget) {\n const childAutoExpand = child.filtering.filterTargetOptions?.autoExpand;\n\n // If child is a filter target and is has no `autoExpand` flag, then it's always to be expanded.\n if (childAutoExpand === true) {\n return true;\n }\n\n // If it's not an object and not `true`, then it's falsy - continue looking\n if (typeof childAutoExpand !== \"object\") {\n continue;\n }\n\n // If grouping node's child has `autoExpandUntil` flag,\n // auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.\n const nodeDepth = node.parentKeys.length;\n const filterTargetDepth = childAutoExpand.depth;\n if (nodeDepth < filterTargetDepth) {\n return true;\n }\n }\n\n if (!child.filtering.filteredChildrenIdentifierPaths) {\n // istanbul ignore next\n continue;\n }\n\n for (const path of child.filtering.filteredChildrenIdentifierPaths) {\n if (\"path\" in path && path.options?.autoExpand) {\n return true;\n }\n }\n }\n return false;\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n if (ProcessedHierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {\n Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): SourceInstanceHierarchyNode => {\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const filterTargetOptions: HierarchyFilteringPathOptions | undefined = row[ECSQL_COLUMN_NAME_FilterTargetOptions]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilterTargetOptions])\n : undefined;\n const filteredChildrenIdentifierPaths: HierarchyFilteringPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes({\n node: defaultNode,\n filteredChildrenIdentifierPaths,\n isFilterTarget,\n filterTargetOptions,\n hasFilterTargetAncestor,\n });\n };\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const filteringProps = extractFilteringProps(this._nodeIdentifierPaths, props.parentNode);\n if (!filteringProps) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isGenericNode(definition)) {\n matchedDefinition = await matchFilters<GenericNodeKey>(\n definition,\n filteringProps,\n async (id) => {\n return (\n HierarchyNodeIdentifier.isGenericNodeIdentifier(id) &&\n (!id.source || id.source === this._imodelAccess.imodelKey) &&\n id.id === definition.node.key\n );\n },\n this._imodelAccess,\n (def, matchingFilters) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyFilteringPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes({\n node: def.node,\n filteredChildrenIdentifierPaths,\n isFilterTarget: matchingFilters.some((mc) => mc.isFilterTarget),\n hasFilterTargetAncestor: filteringProps.hasFilterTargetAncestor,\n }),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n filteringProps,\n async (id) => {\n return (\n HierarchyNodeIdentifier.isInstanceNodeIdentifier(id) &&\n (!id.imodelKey || id.imodelKey === this._imodelAccess.imodelKey) &&\n (await this._imodelAccess.classDerivesFrom(id.className, definition.fullClassName))\n );\n },\n this._imodelAccess,\n (def, matchingFilters) => applyECInstanceIdsFilter(def, matchingFilters, !!filteringProps.hasFilterTargetAncestor),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n}\n\ntype MatchedFilter<TIdentifier extends HierarchyNodeIdentifier> = {\n id: TIdentifier;\n childrenIdentifierPaths: HierarchyFilteringPath[];\n} & ({ isFilterTarget: false } | { isFilterTarget: true; filterTargetOptions?: HierarchyFilteringPathOptions });\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : GenericHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyFilteringPath[]; hasFilterTargetAncestor?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n classHierarchy: ECClassHierarchyInspector,\n matchedDefinitionProcessor: (def: TDefinition, matchingFilters: Array<MatchedFilter<TIdentifier>>) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, hasFilterTargetAncestor } = filteringProps;\n const matchingFilters: Array<MatchedFilter<TIdentifier>> = [];\n for (const filteredNodePath of filteredNodePaths) {\n const { path, options } = HierarchyFilteringPath.normalize(filteredNodePath);\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let entry = await findMatchingFilterEntry(matchingFilters, nodeId, classHierarchy);\n if (!entry) {\n entry = {\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths: [],\n isFilterTarget: false,\n };\n matchingFilters.push(entry);\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n entry.childrenIdentifierPaths.push(options ? { path: remainingPath, options } : remainingPath);\n } else if (entry.isFilterTarget) {\n entry.filterTargetOptions = HierarchyFilteringPath.mergeOptions(entry.filterTargetOptions, options);\n } else {\n Object.assign(entry, { isFilterTarget: true, filterTargetOptions: options });\n }\n }\n }\n if (hasFilterTargetAncestor || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters);\n }\n return undefined;\n}\n\nasync function findMatchingFilterEntry<TEntry extends { id: TIdentifier }, TIdentifier extends HierarchyNodeIdentifier>(\n filters: TEntry[],\n nodeId: TIdentifier,\n classHierarchy: ECClassHierarchyInspector,\n): Promise<TEntry | undefined> {\n for (const filter of filters) {\n if (await identifiersEqual(filter.id, nodeId, classHierarchy)) {\n return filter;\n }\n }\n return undefined;\n}\n\nasync function identifiersEqual<TIdentifier extends HierarchyNodeIdentifier>(lhs: TIdentifier, rhs: TIdentifier, classHierarchy: ECClassHierarchyInspector) {\n if (HierarchyNodeIdentifier.isInstanceNodeIdentifier(lhs) && HierarchyNodeIdentifier.isInstanceNodeIdentifier(rhs)) {\n return (\n lhs.id === rhs.id &&\n (lhs.className === rhs.className ||\n (await classHierarchy.classDerivesFrom(lhs.className, rhs.className)) ||\n (await classHierarchy.classDerivesFrom(rhs.className, lhs.className)))\n );\n }\n return HierarchyNodeIdentifier.equal(lhs, rhs);\n}\n\nfunction applyFilterAttributes<TNode extends SourceHierarchyNode>(props: {\n node: TNode;\n filteredChildrenIdentifierPaths: HierarchyFilteringPath[] | undefined;\n isFilterTarget?: boolean;\n filterTargetOptions?: HierarchyFilteringPathOptions;\n hasFilterTargetAncestor: boolean;\n}): TNode {\n const { node, filteredChildrenIdentifierPaths } = props;\n const result = { ...node };\n\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((childPath) => {\n return !!HierarchyFilteringPath.normalize(childPath).options?.autoExpand;\n });\n if (shouldAutoExpand) {\n result.autoExpand = true;\n }\n\n const filteringProps = HierarchyNodeFilteringProps.create(props);\n if (filteringProps) {\n result.filtering = filteringProps;\n }\n\n return result;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilteredChildrenPaths = \"FilteredChildrenPaths\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_IsFilterTarget = \"IsFilterTarget\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterTargetOptions = \"FilterTargetOptions\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<MatchedFilter<InstanceKey>>,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, IsFilterTarget, FilterTargetOptions, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map((mc) =>\n mc.isFilterTarget\n ? `VALUES (${mc.id.id}, 1, ${mc.filterTargetOptions ? `'${JSON.stringify(mc.filterTargetOptions)}'` : \"CAST(NULL AS TEXT)\"}, '${JSON.stringify(mc.childrenIdentifierPaths)}')`\n : `VALUES (${mc.id.id}, 0, CAST(NULL AS TEXT), '${JSON.stringify(mc.childrenIdentifierPaths)}')`,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n [f].[IsFilterTarget] AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n [f].[FilterTargetOptions] AS [${ECSQL_COLUMN_NAME_FilterTargetOptions}],\n ${hasFilterTargetAncestor ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${hasFilterTargetAncestor ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAiC,MAAM,0BAA0B,CAAC;AACxH,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAML,wBAAwB,GAKzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAkC,sBAAsB,EAAoD,MAAM,0BAA0B,CAAC;AACpJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAQ1D,gBAAgB;AAChB,MAAM,OAAO,4B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E,CAAC,CAAC,CAAC;YAChF,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CACtC,GAAiC,EACjC,eAA2C,EAC3C,uBAAgC;IAEhC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,eAAe,CAAC,CAAC;IACpE,OAAO;QACL,GAAG,GAAG;QACN,KAAK,EAAE;YACL,GAAG,GAAG,CAAC,KAAK;YACZ,IAAI,EAAE;gBACJ,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;gBACzB;YACI,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC;qBAC/B,GAAG,CACF,CAAC,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC;wCACN,SAAS;uBAC1B,SAAS;yCACS,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;eAClD,CACF;qBACA,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;YAGD,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,yCAAyC;4CACpD,oCAAoC;sCAC1C,iCAAiC;;YAE3D,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACzC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { extractFilteringProps, HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"../HierarchyFiltering.js\";\nimport { HierarchyNodeFilteringProps } from \"../HierarchyNode.js\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey } from \"../HierarchyNodeKey.js\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyDefinition,\n HierarchyDefinitionParentNode,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"./IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, SourceHierarchyNode, SourceInstanceHierarchyNode } from \"./IModelHierarchyNode.js\";\nimport { defaultNodesParser } from \"./TreeNodesReader.js\";\n\ninterface FilteringHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyFilteringPath[];\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyFilteringPath[];\n\n public constructor(props: FilteringHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n if (processedNode?.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return undefined;\n }\n return processedNode;\n };\n }\n\n private shouldExpandGroupingNode(node: ProcessedGroupingHierarchyNode) {\n for (const child of node.children) {\n /* c8 ignore next 3 */\n if (!child.filtering) {\n continue;\n }\n\n if (child.filtering.isFilterTarget) {\n const childAutoExpand = child.filtering.filterTargetOptions?.autoExpand;\n\n // If child is a filter target and is has no `autoExpand` flag, then it's always to be expanded.\n if (childAutoExpand === true) {\n return true;\n }\n\n // If it's not an object and not `true`, then it's falsy - continue looking\n if (typeof childAutoExpand !== \"object\") {\n continue;\n }\n\n // If grouping node's child has `autoExpandUntil` flag,\n // auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.\n const nodeDepth = node.parentKeys.length;\n const filterTargetDepth = childAutoExpand.depth;\n if (nodeDepth < filterTargetDepth) {\n return true;\n }\n }\n\n if (!child.filtering.filteredChildrenIdentifierPaths) {\n /* c8 ignore next */\n continue;\n }\n\n for (const path of child.filtering.filteredChildrenIdentifierPaths) {\n if (\"path\" in path && path.options?.autoExpand) {\n return true;\n }\n }\n }\n return false;\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n if (ProcessedHierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {\n Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return async (row: { [columnName: string]: any }, parentNode?: HierarchyDefinitionParentNode): Promise<SourceInstanceHierarchyNode> => {\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n\n const { filteredChildrenIdentifierPaths, filterTargetOptions, isFilterTarget } =\n row[ECSQL_COLUMN_NAME_FilterECInstanceId] && row[ECSQL_COLUMN_NAME_FilterClassName]\n ? await this.getChildrenIdentifierPaths(parentNode?.filtering?.filteredChildrenIdentifierPaths ?? this._nodeIdentifierPaths, {\n className: row[ECSQL_COLUMN_NAME_FilterClassName],\n id: row[ECSQL_COLUMN_NAME_FilterECInstanceId],\n })\n : { filteredChildrenIdentifierPaths: [], filterTargetOptions: undefined, isFilterTarget: false };\n\n const defaultNode = await (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes({\n node: defaultNode,\n filteredChildrenIdentifierPaths,\n isFilterTarget,\n filterTargetOptions,\n hasFilterTargetAncestor,\n });\n };\n }\n\n private async getChildrenIdentifierPaths(filteredChildrenNodeIdentifierPaths: HierarchyFilteringPath[], providedIdentifier: InstanceKey) {\n const { id, className } = providedIdentifier;\n\n let filteredChildrenIdentifierPaths: HierarchyFilteringPath[] | undefined;\n let isFilterTarget = false;\n let filterTargetOptions: HierarchyFilteringPathOptions | undefined;\n for (const filteredChildrenNodeIdentifierPath of filteredChildrenNodeIdentifierPaths) {\n const { path, options } = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);\n /* c8 ignore next 3 */\n if (path.length === 0) {\n continue;\n }\n\n // We need to check if identifiers have the same id and imodelKey and are\n // of the same class / derived class / is derived from class\n const identifier = path[0];\n if (identifier.id !== id) {\n continue;\n }\n if (HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {\n if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {\n continue;\n }\n if (\n identifier.className !== className &&\n !(await this._imodelAccess.classDerivesFrom(identifier.className, className)) &&\n !(await this._imodelAccess.classDerivesFrom(className, identifier.className))\n ) {\n continue;\n }\n }\n if (!filteredChildrenIdentifierPaths) {\n filteredChildrenIdentifierPaths = [];\n }\n if (path.length > 1) {\n filteredChildrenIdentifierPaths.push(options ? { path: path.slice(1), options } : path.slice(1));\n } else if (isFilterTarget) {\n filterTargetOptions = HierarchyFilteringPath.mergeOptions(filterTargetOptions, options);\n } else {\n isFilterTarget = true;\n filterTargetOptions = options;\n }\n }\n return { filteredChildrenIdentifierPaths, filterTargetOptions, isFilterTarget };\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const filteringProps = extractFilteringProps(this._nodeIdentifierPaths, props.parentNode);\n if (!filteringProps) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isGenericNode(definition)) {\n matchedDefinition = await matchFilters<GenericNodeKey>(\n definition,\n filteringProps,\n async (id) => {\n return (\n HierarchyNodeIdentifier.isGenericNodeIdentifier(id) &&\n (!id.source || id.source === this._imodelAccess.imodelKey) &&\n id.id === definition.node.key\n );\n },\n this._imodelAccess,\n (def, matchingFilters) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyFilteringPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes({\n node: def.node,\n filteredChildrenIdentifierPaths,\n isFilterTarget: matchingFilters.some((mc) => mc.isFilterTarget),\n filterTargetOptions: matchingFilters.find((mc) => mc.isFilterTarget)?.filterTargetOptions,\n hasFilterTargetAncestor: filteringProps.hasFilterTargetAncestor,\n }),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n filteringProps,\n async (id) => {\n return (\n HierarchyNodeIdentifier.isInstanceNodeIdentifier(id) &&\n (!id.imodelKey || id.imodelKey === this._imodelAccess.imodelKey) &&\n (await this._imodelAccess.classDerivesFrom(id.className, definition.fullClassName))\n );\n },\n this._imodelAccess,\n (def, matchingFilters) => applyECInstanceIdsFilter(def, matchingFilters, !!filteringProps.hasFilterTargetAncestor),\n false,\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n}\n\ntype MatchedFilter<TIdentifier extends HierarchyNodeIdentifier> = {\n id: TIdentifier;\n childrenIdentifierPaths: HierarchyFilteringPath[];\n} & ({ isFilterTarget: false } | { isFilterTarget: true; filterTargetOptions?: HierarchyFilteringPathOptions });\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : GenericHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyFilteringPath[]; hasFilterTargetAncestor?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n classHierarchy: ECClassHierarchyInspector,\n matchedDefinitionProcessor: (def: TDefinition, matchingFilters: Array<MatchedFilter<TIdentifier>>) => TDefinition,\n extractPathsAndOptions: boolean = true,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, hasFilterTargetAncestor } = filteringProps;\n const matchingFilters: Array<MatchedFilter<TIdentifier>> = [];\n for (const filteredNodePath of filteredNodePaths) {\n const { path, options } = HierarchyFilteringPath.normalize(filteredNodePath);\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let entry = await findMatchingFilterEntry(matchingFilters, nodeId, classHierarchy);\n if (!entry) {\n entry = {\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths: [],\n isFilterTarget: false,\n };\n matchingFilters.push(entry);\n }\n\n if (!extractPathsAndOptions) {\n continue;\n }\n\n if (path.length > 1) {\n entry.childrenIdentifierPaths.push(options ? { path: path.slice(1), options } : path.slice(1));\n } else if (entry.isFilterTarget) {\n entry.filterTargetOptions = HierarchyFilteringPath.mergeOptions(entry.filterTargetOptions, options);\n } else {\n Object.assign(entry, { isFilterTarget: true, filterTargetOptions: options });\n }\n }\n }\n if (hasFilterTargetAncestor || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters);\n }\n return undefined;\n}\n\nasync function findMatchingFilterEntry<TEntry extends { id: TIdentifier }, TIdentifier extends HierarchyNodeIdentifier>(\n filters: TEntry[],\n nodeId: TIdentifier,\n classHierarchy: ECClassHierarchyInspector,\n): Promise<TEntry | undefined> {\n for (const filter of filters) {\n if (await identifiersEqual(filter.id, nodeId, classHierarchy)) {\n return filter;\n }\n }\n return undefined;\n}\n\nasync function identifiersEqual<TIdentifier extends HierarchyNodeIdentifier>(lhs: TIdentifier, rhs: TIdentifier, classHierarchy: ECClassHierarchyInspector) {\n if (HierarchyNodeIdentifier.isInstanceNodeIdentifier(lhs) && HierarchyNodeIdentifier.isInstanceNodeIdentifier(rhs)) {\n return (\n lhs.id === rhs.id &&\n (lhs.className === rhs.className ||\n (await classHierarchy.classDerivesFrom(lhs.className, rhs.className)) ||\n (await classHierarchy.classDerivesFrom(rhs.className, lhs.className)))\n );\n }\n return HierarchyNodeIdentifier.equal(lhs, rhs);\n}\n\nfunction applyFilterAttributes<TNode extends SourceHierarchyNode>(props: {\n node: TNode;\n filteredChildrenIdentifierPaths: HierarchyFilteringPath[] | undefined;\n isFilterTarget?: boolean;\n filterTargetOptions?: HierarchyFilteringPathOptions;\n hasFilterTargetAncestor: boolean;\n}): TNode {\n const { node, filteredChildrenIdentifierPaths } = props;\n const result = { ...node };\n\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((childPath) => {\n return !!HierarchyFilteringPath.normalize(childPath).options?.autoExpand;\n });\n if (shouldAutoExpand) {\n result.autoExpand = true;\n }\n\n const filteringProps = HierarchyNodeFilteringProps.create(props);\n if (filteringProps) {\n result.filtering = filteringProps;\n }\n\n return result;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterECInstanceId = \"FilterECInstanceId\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterClassName = \"FilterClassName\";\n\nfunction getClassECInstanceIds(matchingFilters: Array<{ id: InstanceKey }>) {\n const classNameECInstanceIds = new Map<string, Id64String[]>();\n for (const matchingFilter of matchingFilters) {\n const entry = classNameECInstanceIds.get(matchingFilter.id.className);\n if (entry === undefined) {\n classNameECInstanceIds.set(matchingFilter.id.className, [matchingFilter.id.id]);\n continue;\n }\n entry.push(matchingFilter.id.id);\n }\n return classNameECInstanceIds;\n}\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<{ id: InstanceKey }>,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n const matchingFiltersToUse = getClassECInstanceIds(matchingFilters);\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n `FilteringInfo(ECInstanceId, FilterClassName) AS (\n ${Array.from(matchingFiltersToUse)\n .map(\n ([className, ecInstanceIds]) => `\n SELECT ECInstanceId, '${className}' AS FilterClassName\n FROM ${className}\n WHERE ECInstanceId IN (${ecInstanceIds.join(\", \")})\n `,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n ${hasFilterTargetAncestor ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n IdToHex([f].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_FilterECInstanceId}],\n [f].[FilterClassName] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${hasFilterTargetAncestor ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyCache.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/HierarchyCache.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"HierarchyCache.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/HierarchyCache.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AASjE,UAAU,8BAA8B;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,gBAAgB;AAChB,qBAAa,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAA4D;IACxE,OAAO,CAAC,MAAM,CAAiC;gBAE5B,KAAK,EAAE,8BAA8B;IAKxD,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,iBAAiB;IAyBlB,GAAG,CAAC,YAAY,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC;IAKlD,GAAG,CAAC,YAAY,EAAE,sBAAsB,GAAG,CAAC,GAAG,SAAS;IAKxD,KAAK;CAGb"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { LRUDictionary, LRUMap } from "@itwin/core-bentley";
|
|
6
|
-
import { HierarchyNodeKey } from "../HierarchyNodeKey";
|
|
6
|
+
import { HierarchyNodeKey } from "../HierarchyNodeKey.js";
|
|
7
7
|
/** @internal */
|
|
8
8
|
export class HierarchyCache {
|
|
9
9
|
_map;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyCache.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/HierarchyCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAY,aAAa,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"HierarchyCache.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/HierarchyCache.ts"],"names":[],"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QACxE,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC;IAChE,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACF;AAED,SAAS,wBAAwB,CAAC,GAAuB,EAAE,GAAuB;IAChF,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACpC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,IAAI,iBAAiB,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,iBAAiB,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,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 { LRUCache, LRUDictionary, LRUMap } from \"@itwin/core-bentley\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeKey } from \"../HierarchyNodeKey.js\";\nimport { GetHierarchyNodesProps } from \"../HierarchyProvider.js\";\n\ninterface HierarchyCacheEntry<T> {\n /** Stores observables for the default case - no instance filter or custom limit for the hierarchy level. */\n primary: T | undefined;\n /** Stores a limited number of variations with custom instance filter and/or custom limit for the hierarchy level. */\n variations: LRUCache<string, T>;\n}\n\ninterface ChildNodeObservablesCacheProps {\n size: number;\n variationsCount?: number;\n}\n\n/** @internal */\nexport class HierarchyCache<T> {\n private _map: LRUDictionary<HierarchyNodeKey[], HierarchyCacheEntry<T>>;\n private _props: ChildNodeObservablesCacheProps;\n\n public constructor(props: ChildNodeObservablesCacheProps) {\n this._props = props;\n this._map = new LRUDictionary<HierarchyNodeKey[], HierarchyCacheEntry<T>>(props.size, compareHierarchyNodeKeys);\n }\n\n private createCacheKeys(\n props: Omit<GetHierarchyNodesProps, \"parentNode\"> & {\n parentNode: { key: HierarchyNodeKey; parentKeys: HierarchyNodeKey[] } | undefined;\n filteredInstanceKeys?: InstanceKey[];\n },\n ) {\n function createVariationKey() {\n const { instanceFilter, hierarchyLevelSizeLimit, filteredInstanceKeys } = props;\n if (instanceFilter === undefined && hierarchyLevelSizeLimit === undefined && filteredInstanceKeys === undefined) {\n return undefined;\n }\n return JSON.stringify({ instanceFilter, hierarchyLevelSizeLimit, filteredInstanceKeys });\n }\n\n if (!props.parentNode) {\n return { primaryKey: [], variationKey: createVariationKey() };\n }\n\n const parentKeys = props.parentNode.parentKeys;\n\n return {\n primaryKey: [...parentKeys, props.parentNode.key],\n variationKey: createVariationKey(),\n };\n }\n\n private getCacheAccessors(primaryKey: HierarchyNodeKey[], variationKey?: string) {\n const getMapEntry = (create: boolean) => {\n let entry = this._map.get(primaryKey);\n if (!entry && create) {\n entry = { primary: undefined, variations: new LRUMap(this._props.variationsCount ?? 1) };\n this._map.set(primaryKey, entry);\n }\n return entry;\n };\n if (variationKey) {\n return {\n get: () => getMapEntry(false)?.variations.get(variationKey),\n set: (value: T) => {\n getMapEntry(true)!.variations.set(variationKey, value);\n },\n };\n }\n return {\n get: () => getMapEntry(false)?.primary,\n set: (value: T) => {\n getMapEntry(true)!.primary = value;\n },\n };\n }\n\n public set(requestProps: GetHierarchyNodesProps, value: T) {\n const { primaryKey, variationKey } = this.createCacheKeys(requestProps);\n this.getCacheAccessors(primaryKey, variationKey).set(value);\n }\n\n public get(requestProps: GetHierarchyNodesProps): T | undefined {\n const { primaryKey, variationKey } = this.createCacheKeys(requestProps);\n return this.getCacheAccessors(primaryKey, variationKey).get();\n }\n\n public clear() {\n this._map.clear();\n }\n}\n\nfunction compareHierarchyNodeKeys(lhs: HierarchyNodeKey[], rhs: HierarchyNodeKey[]) {\n if (lhs.length !== rhs.length) {\n return lhs.length - rhs.length;\n }\n for (let i = 0; i < lhs.length; ++i) {\n const keysCompareResult = HierarchyNodeKey.compare(lhs[i], rhs[i]);\n if (keysCompareResult !== 0) {\n return keysCompareResult;\n }\n }\n return 0;\n}\n"]}
|