@itwin/presentation-hierarchies 0.1.2 → 0.1.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @itwin/presentation-hierarchies
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#620](https://github.com/iTwin/presentation/pull/620): Expose filtering information to the type of a fully processed node.
8
+
3
9
  ## 0.1.2
4
10
 
5
11
  ### Patch Changes
@@ -1,4 +1,5 @@
1
1
  import { ConcatenatedValue, InstanceKey, OmitOverUnion, PrimitiveValue } from "@itwin/presentation-shared";
2
+ import { HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier";
2
3
  import { ClassGroupingNodeKey, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey, LabelGroupingNodeKey, PropertyGroupingNodeKey, PropertyOtherValuesGroupingNodeKey, PropertyValueGroupingNodeKey, PropertyValueRangeGroupingNodeKey, StandardHierarchyNodeKey } from "./HierarchyNodeKey";
3
4
  /**
4
5
  * A data structure that represents a single non-grouping hierarchy node.
@@ -16,6 +17,12 @@ interface BaseHierarchyNode {
16
17
  extendedData?: {
17
18
  [key: string]: any;
18
19
  };
20
+ /** Data that may be assigned to the node if filtering is enabled */
21
+ filtering?: {
22
+ isFilterTarget?: boolean;
23
+ hasFilterTargetAncestor?: boolean;
24
+ filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];
25
+ };
19
26
  }
20
27
  /**
21
28
  * A data structure that represents a single non-grouping hierarchy node.
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNode.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC3G,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,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------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ConcatenatedValue, InstanceKey, OmitOverUnion, PrimitiveValue } from \"@itwin/presentation-shared\";\nimport {\n ClassGroupingNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n StandardHierarchyNodeKey,\n} from \"./HierarchyNodeKey\";\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @beta\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: string | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @beta\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: InstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @beta\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a custom node */\n export function isCustom<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedCustomHierarchyNode : NonGroupingHierarchyNode) & { key: string } {\n return HierarchyNodeKey.isCustom(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isStandard<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: StandardHierarchyNodeKey } {\n return HierarchyNodeKey.isStandard(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedInstanceHierarchyNode : NonGroupingHierarchyNode) & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedGroupingHierarchyNode : GroupingHierarchyNode) {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n\n/**\n * Base processing parameters that apply to every node.\n */\ninterface HierarchyNodeProcessingParamsBase {\n /** Indicates if this node should be hidden if it has no child nodes. */\n hideIfNoChildren?: boolean;\n /** Indicates that this node should always be hidden and its children should be loaded in its place. */\n hideInHierarchy?: boolean;\n}\n\n/**\n * A data structure for defining nodes' grouping requirements.\n */\ninterface HierarchyNodeGroupingParams {\n byLabel?: HierarchyNodeLabelGroupingParams;\n byClass?: boolean | HierarchyNodeGroupingParamsBase;\n byBaseClasses?: HierarchyNodeBaseClassGroupingParams;\n byProperties?: HierarchyNodePropertiesGroupingParams;\n}\n\n/**\n * A data structure for defining params specifically used for label grouping.\n */\ninterface HierarchyNodeLabelGroupingBaseParams {\n /** Label grouping option that determines whether to group nodes or to merge them. Defaults to \"group\".*/\n action?: \"group\" | \"merge\";\n /** Value that needs to match in order for nodes to be grouped or merged.*/\n groupId?: string;\n}\n\n/**\n * A data structure for defining label merging.\n */\ninterface HierarchyNodeLabelGroupingMergeParams extends HierarchyNodeLabelGroupingBaseParams {\n action: \"merge\";\n}\n\n/**\n * A data structure for defining label grouping with additional parameters.\n */\ninterface HierarchyNodeLabelGroupingGroupParams extends HierarchyNodeLabelGroupingBaseParams, HierarchyNodeGroupingParamsBase {\n action?: \"group\";\n}\n\n/** A data structure for defining possible label grouping types. */\nexport type HierarchyNodeLabelGroupingParams = boolean | HierarchyNodeLabelGroupingMergeParams | HierarchyNodeLabelGroupingGroupParams;\n\n/** Grouping parameters that are shared across all types of groupings. */\nexport interface HierarchyNodeGroupingParamsBase {\n /** Hiding option that determines whether to hide group nodes which have no siblings at the same hierarchy level. */\n hideIfNoSiblings?: boolean;\n /** Hiding option that determines whether to hide group nodes which have only one node as its children. */\n hideIfOneGroupedNode?: boolean;\n /** Option which auto expands grouping nodes' children when it has single child or always. */\n autoExpand?: HierarchyNodeAutoExpandProp;\n}\n\n/**\n * Defines possible values for `BaseGroupingParams.autoExpand` attribute:\n * - `single-child` - set the grouping node to auto-expand if it groups a single node.\n * - `always` - always set the grouping node to auto-expand.\n */\nexport type HierarchyNodeAutoExpandProp = \"single-child\" | \"always\";\n\n/**\n * A data structure that represents base class grouping.\n */\ninterface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full names of classes, which should be used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n fullClassNames: string[];\n}\n\n/** A data structure that represents properties grouping. */\nexport interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full name of a class whose properties are used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n propertiesClassName: string;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value is not set or is set to an empty string.\n *\n * Label of the created grouping node will be `Not Specified`.\n */\n createGroupForUnspecifiedValues?: boolean;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value doesn't fit within any of the provided\n * ranges, or is not a numeric value.\n *\n * Label of the created grouping node will be `Other`.\n */\n createGroupForOutOfRangeValues?: boolean;\n /**\n * Properties of the specified class, by which the nodes should be grouped. Each provided group definition results in a\n * grouping hierarchy level.\n *\n * Example usage:\n * ```ts\n * propertyGroups: [\n * {\n * propertyName: \"type\",\n * propertyValue: \"Wall\"\n * },\n * {\n * propertyName: \"length\",\n * propertyValue: 15,\n * ranges: [\n * { fromValue: 1, toValue: 10, rangeLabel: \"Small\" },\n * { fromValue: 11, toValue: 20, rangeLabel: \"Medium\" }\n * ]\n * },\n * ]\n * ```\n */\n propertyGroups: HierarchyNodePropertyGroup[];\n}\n\n/** A data structure that represents specific properties' grouping params. */\nexport interface HierarchyNodePropertyGroup {\n /** A string indicating the name of the property to group by. */\n propertyName: string;\n /** Value of the property, which will be used to group the node. */\n propertyValue?: PrimitiveValue;\n /** Ranges are used to group nodes by numeric properties which are within specified bounds. */\n ranges?: HierarchyNodePropertyValueRange[];\n}\n\n/** A data structure that represents boundaries for a value. */\nexport interface HierarchyNodePropertyValueRange {\n /** Defines the lower bound of the range. */\n fromValue: number;\n /** Defines the upper bound of the range. */\n toValue: number;\n /** Defines the range label. Will be used as `PropertyValueRangeGroupingNode` node's display label. */\n rangeLabel?: string;\n}\n\n/** Processing parameters that apply to instance nodes. */\nexport interface InstanceHierarchyNodeProcessingParams extends HierarchyNodeProcessingParamsBase {\n grouping?: HierarchyNodeGroupingParams;\n}\n\n/** A custom (not based on data in an iModel) node that has processing parameters. */\nexport type ProcessedCustomHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: string;\n children?: boolean;\n processingParams?: HierarchyNodeProcessingParamsBase;\n};\n/** An instances' (based on data in an iModel) node that has processing parameters. */\nexport type ProcessedInstanceHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: InstancesNodeKey;\n children?: boolean;\n processingParams?: InstanceHierarchyNodeProcessingParams;\n};\n/** A grouping node that groups either instance nodes or other grouping nodes. */\nexport type ProcessedGroupingHierarchyNode = Omit<GroupingHierarchyNode, \"children\"> & {\n children: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n};\n/**\n * A `HierarchyNode` that may have processing parameters defining whether it should be hidden under some conditions,\n * how it should be grouped, sorted, etc.\n *\n * Type guards under `HierarchyNode` namespace can be used to differentiate between different sub-types of\n * `ProcessedHierarchyNode`.\n *\n * @beta\n */\nexport type ProcessedHierarchyNode = ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode | ProcessedGroupingHierarchyNode;\n\n/**\n * A `ProcessedHierarchyNode` that has an unformatted label in a form of `ConcatenatedValue`. Generally this is\n * returned when the node is just parsed from query results.\n * @beta\n */\nexport type ParsedHierarchyNode<TBase = ParsedCustomHierarchyNode | ParsedInstanceHierarchyNode> = OmitOverUnion<TBase, \"label\" | \"parentKeys\"> & {\n label: string | ConcatenatedValue;\n};\n/** A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedCustomHierarchyNode = ParsedHierarchyNode<ProcessedCustomHierarchyNode>;\n/** A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedInstanceHierarchyNode = ParsedHierarchyNode<ProcessedInstanceHierarchyNode>;\n"]}
1
+ {"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAIhG,yDAW4B;AA8D5B,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,aAAa,CAuE7B;AAvED,WAAiB,aAAa;IAC5B,qDAAqD;IACrD,SAAgB,QAAQ,CACtB,IAAW;QAEX,OAAO,mCAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAJe,sBAAQ,WAIvB,CAAA;IACD,8EAA8E;IAC9E,SAAgB,UAAU,CAA0C,IAAW;QAC7E,OAAO,mCAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAFe,wBAAU,aAEzB,CAAA;IACD,iEAAiE;IACjE,SAAgB,eAAe,CAC7B,IAAW;QAEX,OAAO,mCAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IAJe,6BAAe,kBAI9B,CAAA;IACD,uDAAuD;IACvD,SAAgB,cAAc,CAC5B,IAAW;QAEX,OAAO,mCAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAJe,4BAAc,iBAI7B,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAIX,OAAO,mCAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IANe,iCAAmB,sBAMlC,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAIX,OAAO,mCAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IANe,iCAAmB,sBAMlC,CAAA;IACD,gFAAgF;IAChF,SAAgB,iCAAiC,CAC/C,IAAW;QAIX,OAAO,mCAAgB,CAAC,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IANe,+CAAiC,oCAMhD,CAAA;IACD,sEAAsE;IACtE,SAAgB,2BAA2B,CACzC,IAAW;QAIX,OAAO,mCAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IANe,yCAA2B,8BAM1C,CAAA;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAIX,OAAO,mCAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IANe,8CAAgC,mCAM/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAIX,OAAO,mCAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IANe,oCAAsB,yBAMrC,CAAA;AACH,CAAC,EAvEgB,aAAa,6BAAb,aAAa,QAuE7B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ConcatenatedValue, InstanceKey, OmitOverUnion, PrimitiveValue } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier\";\nimport {\n ClassGroupingNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n StandardHierarchyNodeKey,\n} from \"./HierarchyNodeKey\";\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n /** Data that may be assigned to the node if filtering is enabled */\n filtering?: {\n isFilterTarget?: boolean;\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];\n };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @beta\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: string | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @beta\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: InstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @beta\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a custom node */\n export function isCustom<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedCustomHierarchyNode : NonGroupingHierarchyNode) & { key: string } {\n return HierarchyNodeKey.isCustom(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isStandard<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: StandardHierarchyNodeKey } {\n return HierarchyNodeKey.isStandard(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedInstanceHierarchyNode : NonGroupingHierarchyNode) & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedGroupingHierarchyNode : GroupingHierarchyNode) {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n\n/**\n * Base processing parameters that apply to every node.\n */\ninterface HierarchyNodeProcessingParamsBase {\n /** Indicates if this node should be hidden if it has no child nodes. */\n hideIfNoChildren?: boolean;\n /** Indicates that this node should always be hidden and its children should be loaded in its place. */\n hideInHierarchy?: boolean;\n}\n\n/**\n * A data structure for defining nodes' grouping requirements.\n */\ninterface HierarchyNodeGroupingParams {\n byLabel?: HierarchyNodeLabelGroupingParams;\n byClass?: boolean | HierarchyNodeGroupingParamsBase;\n byBaseClasses?: HierarchyNodeBaseClassGroupingParams;\n byProperties?: HierarchyNodePropertiesGroupingParams;\n}\n\n/**\n * A data structure for defining params specifically used for label grouping.\n */\ninterface HierarchyNodeLabelGroupingBaseParams {\n /** Label grouping option that determines whether to group nodes or to merge them. Defaults to \"group\".*/\n action?: \"group\" | \"merge\";\n /** Value that needs to match in order for nodes to be grouped or merged.*/\n groupId?: string;\n}\n\n/**\n * A data structure for defining label merging.\n */\ninterface HierarchyNodeLabelGroupingMergeParams extends HierarchyNodeLabelGroupingBaseParams {\n action: \"merge\";\n}\n\n/**\n * A data structure for defining label grouping with additional parameters.\n */\ninterface HierarchyNodeLabelGroupingGroupParams extends HierarchyNodeLabelGroupingBaseParams, HierarchyNodeGroupingParamsBase {\n action?: \"group\";\n}\n\n/** A data structure for defining possible label grouping types. */\nexport type HierarchyNodeLabelGroupingParams = boolean | HierarchyNodeLabelGroupingMergeParams | HierarchyNodeLabelGroupingGroupParams;\n\n/** Grouping parameters that are shared across all types of groupings. */\nexport interface HierarchyNodeGroupingParamsBase {\n /** Hiding option that determines whether to hide group nodes which have no siblings at the same hierarchy level. */\n hideIfNoSiblings?: boolean;\n /** Hiding option that determines whether to hide group nodes which have only one node as its children. */\n hideIfOneGroupedNode?: boolean;\n /** Option which auto expands grouping nodes' children when it has single child or always. */\n autoExpand?: HierarchyNodeAutoExpandProp;\n}\n\n/**\n * Defines possible values for `BaseGroupingParams.autoExpand` attribute:\n * - `single-child` - set the grouping node to auto-expand if it groups a single node.\n * - `always` - always set the grouping node to auto-expand.\n */\nexport type HierarchyNodeAutoExpandProp = \"single-child\" | \"always\";\n\n/**\n * A data structure that represents base class grouping.\n */\ninterface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full names of classes, which should be used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n fullClassNames: string[];\n}\n\n/** A data structure that represents properties grouping. */\nexport interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full name of a class whose properties are used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n propertiesClassName: string;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value is not set or is set to an empty string.\n *\n * Label of the created grouping node will be `Not Specified`.\n */\n createGroupForUnspecifiedValues?: boolean;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value doesn't fit within any of the provided\n * ranges, or is not a numeric value.\n *\n * Label of the created grouping node will be `Other`.\n */\n createGroupForOutOfRangeValues?: boolean;\n /**\n * Properties of the specified class, by which the nodes should be grouped. Each provided group definition results in a\n * grouping hierarchy level.\n *\n * Example usage:\n * ```ts\n * propertyGroups: [\n * {\n * propertyName: \"type\",\n * propertyValue: \"Wall\"\n * },\n * {\n * propertyName: \"length\",\n * propertyValue: 15,\n * ranges: [\n * { fromValue: 1, toValue: 10, rangeLabel: \"Small\" },\n * { fromValue: 11, toValue: 20, rangeLabel: \"Medium\" }\n * ]\n * },\n * ]\n * ```\n */\n propertyGroups: HierarchyNodePropertyGroup[];\n}\n\n/** A data structure that represents specific properties' grouping params. */\nexport interface HierarchyNodePropertyGroup {\n /** A string indicating the name of the property to group by. */\n propertyName: string;\n /** Value of the property, which will be used to group the node. */\n propertyValue?: PrimitiveValue;\n /** Ranges are used to group nodes by numeric properties which are within specified bounds. */\n ranges?: HierarchyNodePropertyValueRange[];\n}\n\n/** A data structure that represents boundaries for a value. */\nexport interface HierarchyNodePropertyValueRange {\n /** Defines the lower bound of the range. */\n fromValue: number;\n /** Defines the upper bound of the range. */\n toValue: number;\n /** Defines the range label. Will be used as `PropertyValueRangeGroupingNode` node's display label. */\n rangeLabel?: string;\n}\n\n/** Processing parameters that apply to instance nodes. */\nexport interface InstanceHierarchyNodeProcessingParams extends HierarchyNodeProcessingParamsBase {\n grouping?: HierarchyNodeGroupingParams;\n}\n\n/** A custom (not based on data in an iModel) node that has processing parameters. */\nexport type ProcessedCustomHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: string;\n children?: boolean;\n processingParams?: HierarchyNodeProcessingParamsBase;\n};\n/** An instances' (based on data in an iModel) node that has processing parameters. */\nexport type ProcessedInstanceHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: InstancesNodeKey;\n children?: boolean;\n processingParams?: InstanceHierarchyNodeProcessingParams;\n};\n/** A grouping node that groups either instance nodes or other grouping nodes. */\nexport type ProcessedGroupingHierarchyNode = Omit<GroupingHierarchyNode, \"children\"> & {\n children: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n};\n\n/**\n * A `HierarchyNode` that may have processing parameters defining whether it should be hidden under some conditions,\n * how it should be grouped, sorted, etc.\n *\n * Type guards under `HierarchyNode` namespace can be used to differentiate between different sub-types of\n * `ProcessedHierarchyNode`.\n *\n * @beta\n */\nexport type ProcessedHierarchyNode = ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode | ProcessedGroupingHierarchyNode;\n\n/**\n * A `ProcessedHierarchyNode` that has an unformatted label in a form of `ConcatenatedValue`. Generally this is\n * returned when the node is just parsed from query results.\n * @beta\n */\nexport type ParsedHierarchyNode<TBase = ParsedCustomHierarchyNode | ParsedInstanceHierarchyNode> = OmitOverUnion<TBase, \"label\" | \"parentKeys\"> & {\n label: string | ConcatenatedValue;\n};\n/** A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedCustomHierarchyNode = ParsedHierarchyNode<ProcessedCustomHierarchyNode>;\n/** A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedInstanceHierarchyNode = ParsedHierarchyNode<ProcessedInstanceHierarchyNode>;\n"]}
@@ -1,6 +1,5 @@
1
1
  import { ECClassHierarchyInspector, InstanceKey } from "@itwin/presentation-shared";
2
2
  import { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, InstanceNodesQueryDefinition, NodeParser, NodePostProcessor, NodePreProcessor } from "../HierarchyDefinition";
3
- import { ProcessedHierarchyNode } from "../HierarchyNode";
4
3
  import { HierarchyNodeIdentifiersPath } from "../HierarchyNodeIdentifier";
5
4
  /** @internal */
6
5
  export interface FilteringQueryBuilderProps {
@@ -9,12 +8,6 @@ export interface FilteringQueryBuilderProps {
9
8
  nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];
10
9
  }
11
10
  /** @internal */
12
- export type FilteredHierarchyNode<TNode = ProcessedHierarchyNode> = TNode & {
13
- isFilterTarget?: boolean;
14
- hasFilterTargetAncestor?: boolean;
15
- filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];
16
- };
17
- /** @internal */
18
11
  export declare class FilteringHierarchyDefinition implements HierarchyDefinition {
19
12
  private _classHierarchy;
20
13
  private _source;
@@ -23,9 +16,7 @@ export declare class FilteringHierarchyDefinition implements HierarchyDefinition
23
16
  get preProcessNode(): NodePreProcessor;
24
17
  get postProcessNode(): NodePostProcessor;
25
18
  get parseNode(): NodeParser;
26
- defineHierarchyLevel(props: DefineHierarchyLevelProps & {
27
- parentNode: FilteredHierarchyNode<DefineHierarchyLevelProps["parentNode"]> | undefined;
28
- }): Promise<HierarchyLevelDefinition>;
19
+ defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
29
20
  private getFilteringProps;
30
21
  }
31
22
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAEL,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EAExB,4BAA4B,EAC5B,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAKL,sBAAsB,EAEvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA2B,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAGnG,gBAAgB;AAChB,MAAM,WAAW,0BAA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AO,EAC7B,uBAAuB,EAAE,OAAO,GAC/B,4BAA4B,CA+B9B"}
1
+ {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAEL,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EAExB,4BAA4B,EAC5B,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA2B,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAGnG,gBAAgB;AAChB,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,yBAAyB,CAAC;IAC1C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,mBAAmB,EAAE,4BAA4B,EAAE,CAAC;CACrD;AAED,gBAAgB;AAChB,qBAAa,4BAA6B,YAAW,mBAAmB;IACtE,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,oBAAoB,CAAiC;gBAE1C,KAAK,EAAE,0BAA0B;IAMpD,IAAW,cAAc,IAAI,gBAAgB,CAS5C;IAED,IAAW,eAAe,IAAI,iBAAiB,CAc9C;IAED,IAAW,SAAS,IAAI,UAAU,CAUjC;IAEY,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAsDtG,OAAO,CAAC,iBAAiB;CAU1B;AAqED,gBAAgB;AAEhB,eAAO,MAAM,uCAAuC,0BAA0B,CAAC;AAE/E,gBAAgB;AAEhB,eAAO,MAAM,gCAAgC,mBAAmB,CAAC;AAEjE,gBAAgB;AAEhB,eAAO,MAAM,yCAAyC,4BAA4B,CAAC;AAEnF,gBAAgB;AAChB,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,4BAA4B,EACjC,eAAe,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,WAAW,CAAC;IAAC,uBAAuB,EAAE,4BAA4B,EAAE,CAAA;CAAE,CAAC,EACpG,cAAc,EAAE,OAAO,EACvB,oBAAoB,EAAE,OAAO,EAC7B,uBAAuB,EAAE,OAAO,GAC/B,4BAA4B,CA+B9B"}
@@ -22,8 +22,7 @@ class FilteringHierarchyDefinition {
22
22
  get preProcessNode() {
23
23
  return async (node) => {
24
24
  const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;
25
- const filteredNode = processedNode;
26
- if (filteredNode?.processingParams?.hideInHierarchy && filteredNode.isFilterTarget && !filteredNode.hasFilterTargetAncestor) {
25
+ if (processedNode?.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {
27
26
  // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target
28
27
  return undefined;
29
28
  }
@@ -36,7 +35,7 @@ class FilteringHierarchyDefinition {
36
35
  if (
37
36
  // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing
38
37
  HierarchyNode_1.HierarchyNode.isClassGroupingNode(node) &&
39
- node.children.some((child) => child.isFilterTarget || child.filteredChildrenIdentifierPaths)) {
38
+ node.children.some((child) => child.filtering && (child.filtering.isFilterTarget || child.filtering.filteredChildrenIdentifierPaths))) {
40
39
  return Object.assign(processedNode, { autoExpand: true });
41
40
  }
42
41
  return processedNode;
@@ -95,9 +94,9 @@ class FilteringHierarchyDefinition {
95
94
  return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };
96
95
  }
97
96
  return {
98
- filteredNodePaths: parentNode.filteredChildrenIdentifierPaths,
99
- isDirectParentFilterTarget: parentNode.isFilterTarget,
100
- hasFilterTargetAncestor: !!parentNode.hasFilterTargetAncestor,
97
+ filteredNodePaths: parentNode.filtering?.filteredChildrenIdentifierPaths,
98
+ isDirectParentFilterTarget: parentNode.filtering?.isFilterTarget,
99
+ hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor,
101
100
  };
102
101
  }
103
102
  }
@@ -138,13 +137,18 @@ async function matchFilters(definition, filteringProps, predicate, matchedDefini
138
137
  }
139
138
  function applyFilterAttributes(node, filteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor) {
140
139
  const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);
141
- return {
142
- ...node,
143
- ...(isFilterTarget ? { isFilterTarget } : undefined),
144
- ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),
145
- ...(shouldAutoExpand ? { autoExpand: true } : undefined),
146
- ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),
147
- };
140
+ const result = { ...node };
141
+ if (shouldAutoExpand) {
142
+ result.autoExpand = true;
143
+ }
144
+ if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {
145
+ result.filtering = {
146
+ ...(isFilterTarget ? { isFilterTarget } : undefined),
147
+ ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),
148
+ ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),
149
+ };
150
+ }
151
+ return result;
148
152
  }
149
153
  /** @internal */
150
154
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -1 +1 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAGhG,gEAUgC;AAChC,oDAO0B;AAC1B,wEAAmG;AACnG,uDAAuD;AAgBvD,gBAAgB;AAChB,MAAa,4BAA4B;IAC/B,eAAe,CAA4B;IAC3C,OAAO,CAAsB;IAC7B,oBAAoB,CAAiC;IAE7D,YAAmB,KAAiC;QAClD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC;QAC5C,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AG,uBAAuB,CAAC;AAE/E,gBAAgB;AAChB,gEAAgE;AACnD,QAAA,gCAAgC,GAAG,gBAAgB,CAAC;AAEjE,gBAAgB;AAChB,gEAAgE;AACnD,QAAA,yCAAyC,GAAG,yBAAyB,CAAC;AAEnF,gBAAgB;AAChB,SAAgB,wBAAwB,CACtC,GAAiC,EACjC,eAAoG,EACpG,cAAuB,EACvB,oBAA6B,EAC7B,uBAAgC;IAEhC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC;IACD,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,uIAAuI;gBACvI,iCAAiC;gBACjC;YACI,eAAe;qBACd,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,uBAAuB,EAAE,EAAE,EAAE,CAAC,WAAW,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,IAAI,CAAC;qBACjH,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;YAGD,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,wCAAgC;YAClE,uBAAuB,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,iDAAyC;4CAC5E,+CAAuC;;YAEvE,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACtC;SACF;KACF,CAAC;AACJ,CAAC;AArCD,4DAqCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport {\n CustomHierarchyNodeDefinition,\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"../HierarchyDefinition\";\nimport {\n HierarchyNode,\n ParsedHierarchyNode,\n ParsedInstanceHierarchyNode,\n ProcessedCustomHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n} from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"../HierarchyNodeIdentifier\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n}\n\n/** @internal */\nexport type FilteredHierarchyNode<TNode = ProcessedHierarchyNode> = TNode & {\n isFilterTarget?: boolean;\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];\n};\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n\n public constructor(props: FilteringQueryBuilderProps) {\n this._classHierarchy = props.classHierarchy;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n const filteredNode = processedNode as FilteredHierarchyNode<ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode> | undefined;\n if (filteredNode?.processingParams?.hideInHierarchy && filteredNode.isFilterTarget && !filteredNode.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return undefined;\n }\n return processedNode;\n };\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n if (\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n HierarchyNode.isClassGroupingNode(node) &&\n node.children.some((child: FilteredHierarchyNode) => child.isFilterTarget || child.filteredChildrenIdentifierPaths)\n ) {\n return Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): FilteredHierarchyNode<ParsedInstanceHierarchyNode> => {\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const parsedFilteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor);\n };\n }\n\n public async defineHierarchyLevel(\n props: DefineHierarchyLevelProps & { parentNode: FilteredHierarchyNode<DefineHierarchyLevelProps[\"parentNode\"]> | undefined },\n ): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { filteredNodePaths, isDirectParentFilterTarget, hasFilterTargetAncestor } = this.getFilteringProps(props.parentNode);\n if (!filteredNodePaths) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isCustomNode(definition)) {\n matchedDefinition = await matchFilters<{ key: string }>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {\n return false;\n }\n return id.key === definition.node.key;\n },\n (def, matchingFilters, isFilterTarget) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyNodeIdentifiersPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget, !!hasFilterTargetAncestor),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n return false;\n }\n return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);\n },\n (def, matchingFilters, isFilterTarget) =>\n applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n\n private getFilteringProps(parentNode: FilteredHierarchyNode<unknown> | undefined) {\n if (!parentNode) {\n return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };\n }\n return {\n filteredNodePaths: parentNode.filteredChildrenIdentifierPaths,\n isDirectParentFilterTarget: parentNode.isFilterTarget,\n hasFilterTargetAncestor: !!parentNode.hasFilterTargetAncestor,\n };\n }\n}\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyNodeIdentifiersPath[]; isDirectParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n matchedDefinitionProcessor: (\n def: TDefinition,\n matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n ) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;\n let isFilterTarget = false;\n const matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }> = [];\n for (const path of filteredNodePaths) {\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let childrenIdentifierPaths = matchingFilters.find(({ id }) => HierarchyNodeIdentifier.equal(id, nodeId))?.childrenIdentifierPaths;\n if (!childrenIdentifierPaths) {\n childrenIdentifierPaths = [];\n matchingFilters.push({\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths,\n });\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n childrenIdentifierPaths.push(remainingPath);\n } else {\n isFilterTarget = true;\n }\n }\n }\n if (isDirectParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters, isFilterTarget);\n }\n return undefined;\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>(\n node: TNode,\n filteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined,\n isFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);\n return {\n ...node,\n ...(isFilterTarget ? { isFilterTarget } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(shouldAutoExpand ? { autoExpand: true } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilteredChildrenPaths = \"FilteredChildrenPaths\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_IsFilterTarget = \"IsFilterTarget\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<{ id: InstanceKey; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n isParentFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map(({ id: key, childrenIdentifierPaths }) => `VALUES (${key.id}, '${JSON.stringify(childrenIdentifierPaths)}')`)\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n ${isFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n ${hasFilterTargetAncestor || isParentFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${isParentFilterTarget ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"FilteringHierarchyDefinition.js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AM,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,IAAI,CAAC;qBACjH,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;YAGD,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,wCAAgC;YAClE,uBAAuB,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,iDAAyC;4CAC5E,+CAAuC;;YAEvE,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACtC;SACF;KACF,CAAC;AACJ,CAAC;AArCD,4DAqCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport {\n CustomHierarchyNodeDefinition,\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"../HierarchyDefinition\";\nimport { HierarchyNode, ParsedHierarchyNode, ParsedInstanceHierarchyNode, ProcessedHierarchyNode } from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"../HierarchyNodeIdentifier\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n\n public constructor(props: FilteringQueryBuilderProps) {\n this._classHierarchy = props.classHierarchy;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n if (processedNode?.processingParams?.hideInHierarchy && 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 public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n if (\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n HierarchyNode.isClassGroupingNode(node) &&\n node.children.some(\n (child: ProcessedHierarchyNode) => child.filtering && (child.filtering.isFilterTarget || child.filtering.filteredChildrenIdentifierPaths),\n )\n ) {\n return Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): ParsedInstanceHierarchyNode => {\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const parsedFilteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor);\n };\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { filteredNodePaths, isDirectParentFilterTarget, hasFilterTargetAncestor } = this.getFilteringProps(props.parentNode);\n if (!filteredNodePaths) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isCustomNode(definition)) {\n matchedDefinition = await matchFilters<{ key: string }>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {\n return false;\n }\n return id.key === definition.node.key;\n },\n (def, matchingFilters, isFilterTarget) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyNodeIdentifiersPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget, !!hasFilterTargetAncestor),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n return false;\n }\n return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);\n },\n (def, matchingFilters, isFilterTarget) =>\n applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n\n private getFilteringProps(parentNode: Pick<HierarchyNode, \"filtering\"> | undefined) {\n if (!parentNode) {\n return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };\n }\n return {\n filteredNodePaths: parentNode.filtering?.filteredChildrenIdentifierPaths,\n isDirectParentFilterTarget: parentNode.filtering?.isFilterTarget,\n hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor,\n };\n }\n}\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyNodeIdentifiersPath[]; isDirectParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n matchedDefinitionProcessor: (\n def: TDefinition,\n matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n ) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;\n let isFilterTarget = false;\n const matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }> = [];\n for (const path of filteredNodePaths) {\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let childrenIdentifierPaths = matchingFilters.find(({ id }) => HierarchyNodeIdentifier.equal(id, nodeId))?.childrenIdentifierPaths;\n if (!childrenIdentifierPaths) {\n childrenIdentifierPaths = [];\n matchingFilters.push({\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths,\n });\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n childrenIdentifierPaths.push(remainingPath);\n } else {\n isFilterTarget = true;\n }\n }\n }\n if (isDirectParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters, isFilterTarget);\n }\n return undefined;\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>(\n node: TNode,\n filteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined,\n isFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);\n const result = { ...node };\n if (shouldAutoExpand) {\n result.autoExpand = true;\n }\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n result.filtering = {\n ...(isFilterTarget ? { isFilterTarget } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\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_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<{ id: InstanceKey; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n isParentFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map(({ id: key, childrenIdentifierPaths }) => `VALUES (${key.id}, '${JSON.stringify(childrenIdentifierPaths)}')`)\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n ${isFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n ${hasFilterTargetAncestor || isParentFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${isParentFilterTarget ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { ConcatenatedValue, InstanceKey, OmitOverUnion, PrimitiveValue } from "@itwin/presentation-shared";
2
+ import { HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier";
2
3
  import { ClassGroupingNodeKey, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey, LabelGroupingNodeKey, PropertyGroupingNodeKey, PropertyOtherValuesGroupingNodeKey, PropertyValueGroupingNodeKey, PropertyValueRangeGroupingNodeKey, StandardHierarchyNodeKey } from "./HierarchyNodeKey";
3
4
  /**
4
5
  * A data structure that represents a single non-grouping hierarchy node.
@@ -16,6 +17,12 @@ interface BaseHierarchyNode {
16
17
  extendedData?: {
17
18
  [key: string]: any;
18
19
  };
20
+ /** Data that may be assigned to the node if filtering is enabled */
21
+ filtering?: {
22
+ isFilterTarget?: boolean;
23
+ hasFilterTargetAncestor?: boolean;
24
+ filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];
25
+ };
19
26
  }
20
27
  /**
21
28
  * A data structure that represents a single non-grouping hierarchy node.
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNode.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC3G,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,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AAC,CAAC;IAChD,CAAC;IAJe,6BAAe,kBAI9B,CAAA;IACD,uDAAuD;IACvD,SAAgB,cAAc,CAC5B,IAAW;QAEX,OAAO,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAJe,4BAAc,iBAI7B,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAIX,OAAO,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IANe,iCAAmB,sBAMlC,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAIX,OAAO,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IANe,iCAAmB,sBAMlC,CAAA;IACD,gFAAgF;IAChF,SAAgB,iCAAiC,CAC/C,IAAW;QAIX,OAAO,gBAAgB,CAAC,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IANe,+CAAiC,oCAMhD,CAAA;IACD,sEAAsE;IACtE,SAAgB,2BAA2B,CACzC,IAAW;QAIX,OAAO,gBAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IANe,yCAA2B,8BAM1C,CAAA;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAIX,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IANe,8CAAgC,mCAM/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAIX,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IANe,oCAAsB,yBAMrC,CAAA;AACH,CAAC,EAvEgB,aAAa,KAAb,aAAa,QAuE7B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ConcatenatedValue, InstanceKey, OmitOverUnion, PrimitiveValue } from \"@itwin/presentation-shared\";\nimport {\n ClassGroupingNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n StandardHierarchyNodeKey,\n} from \"./HierarchyNodeKey\";\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @beta\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: string | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @beta\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: InstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @beta\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a custom node */\n export function isCustom<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedCustomHierarchyNode : NonGroupingHierarchyNode) & { key: string } {\n return HierarchyNodeKey.isCustom(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isStandard<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: StandardHierarchyNodeKey } {\n return HierarchyNodeKey.isStandard(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedInstanceHierarchyNode : NonGroupingHierarchyNode) & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedGroupingHierarchyNode : GroupingHierarchyNode) {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n\n/**\n * Base processing parameters that apply to every node.\n */\ninterface HierarchyNodeProcessingParamsBase {\n /** Indicates if this node should be hidden if it has no child nodes. */\n hideIfNoChildren?: boolean;\n /** Indicates that this node should always be hidden and its children should be loaded in its place. */\n hideInHierarchy?: boolean;\n}\n\n/**\n * A data structure for defining nodes' grouping requirements.\n */\ninterface HierarchyNodeGroupingParams {\n byLabel?: HierarchyNodeLabelGroupingParams;\n byClass?: boolean | HierarchyNodeGroupingParamsBase;\n byBaseClasses?: HierarchyNodeBaseClassGroupingParams;\n byProperties?: HierarchyNodePropertiesGroupingParams;\n}\n\n/**\n * A data structure for defining params specifically used for label grouping.\n */\ninterface HierarchyNodeLabelGroupingBaseParams {\n /** Label grouping option that determines whether to group nodes or to merge them. Defaults to \"group\".*/\n action?: \"group\" | \"merge\";\n /** Value that needs to match in order for nodes to be grouped or merged.*/\n groupId?: string;\n}\n\n/**\n * A data structure for defining label merging.\n */\ninterface HierarchyNodeLabelGroupingMergeParams extends HierarchyNodeLabelGroupingBaseParams {\n action: \"merge\";\n}\n\n/**\n * A data structure for defining label grouping with additional parameters.\n */\ninterface HierarchyNodeLabelGroupingGroupParams extends HierarchyNodeLabelGroupingBaseParams, HierarchyNodeGroupingParamsBase {\n action?: \"group\";\n}\n\n/** A data structure for defining possible label grouping types. */\nexport type HierarchyNodeLabelGroupingParams = boolean | HierarchyNodeLabelGroupingMergeParams | HierarchyNodeLabelGroupingGroupParams;\n\n/** Grouping parameters that are shared across all types of groupings. */\nexport interface HierarchyNodeGroupingParamsBase {\n /** Hiding option that determines whether to hide group nodes which have no siblings at the same hierarchy level. */\n hideIfNoSiblings?: boolean;\n /** Hiding option that determines whether to hide group nodes which have only one node as its children. */\n hideIfOneGroupedNode?: boolean;\n /** Option which auto expands grouping nodes' children when it has single child or always. */\n autoExpand?: HierarchyNodeAutoExpandProp;\n}\n\n/**\n * Defines possible values for `BaseGroupingParams.autoExpand` attribute:\n * - `single-child` - set the grouping node to auto-expand if it groups a single node.\n * - `always` - always set the grouping node to auto-expand.\n */\nexport type HierarchyNodeAutoExpandProp = \"single-child\" | \"always\";\n\n/**\n * A data structure that represents base class grouping.\n */\ninterface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full names of classes, which should be used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n fullClassNames: string[];\n}\n\n/** A data structure that represents properties grouping. */\nexport interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full name of a class whose properties are used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n propertiesClassName: string;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value is not set or is set to an empty string.\n *\n * Label of the created grouping node will be `Not Specified`.\n */\n createGroupForUnspecifiedValues?: boolean;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value doesn't fit within any of the provided\n * ranges, or is not a numeric value.\n *\n * Label of the created grouping node will be `Other`.\n */\n createGroupForOutOfRangeValues?: boolean;\n /**\n * Properties of the specified class, by which the nodes should be grouped. Each provided group definition results in a\n * grouping hierarchy level.\n *\n * Example usage:\n * ```ts\n * propertyGroups: [\n * {\n * propertyName: \"type\",\n * propertyValue: \"Wall\"\n * },\n * {\n * propertyName: \"length\",\n * propertyValue: 15,\n * ranges: [\n * { fromValue: 1, toValue: 10, rangeLabel: \"Small\" },\n * { fromValue: 11, toValue: 20, rangeLabel: \"Medium\" }\n * ]\n * },\n * ]\n * ```\n */\n propertyGroups: HierarchyNodePropertyGroup[];\n}\n\n/** A data structure that represents specific properties' grouping params. */\nexport interface HierarchyNodePropertyGroup {\n /** A string indicating the name of the property to group by. */\n propertyName: string;\n /** Value of the property, which will be used to group the node. */\n propertyValue?: PrimitiveValue;\n /** Ranges are used to group nodes by numeric properties which are within specified bounds. */\n ranges?: HierarchyNodePropertyValueRange[];\n}\n\n/** A data structure that represents boundaries for a value. */\nexport interface HierarchyNodePropertyValueRange {\n /** Defines the lower bound of the range. */\n fromValue: number;\n /** Defines the upper bound of the range. */\n toValue: number;\n /** Defines the range label. Will be used as `PropertyValueRangeGroupingNode` node's display label. */\n rangeLabel?: string;\n}\n\n/** Processing parameters that apply to instance nodes. */\nexport interface InstanceHierarchyNodeProcessingParams extends HierarchyNodeProcessingParamsBase {\n grouping?: HierarchyNodeGroupingParams;\n}\n\n/** A custom (not based on data in an iModel) node that has processing parameters. */\nexport type ProcessedCustomHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: string;\n children?: boolean;\n processingParams?: HierarchyNodeProcessingParamsBase;\n};\n/** An instances' (based on data in an iModel) node that has processing parameters. */\nexport type ProcessedInstanceHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: InstancesNodeKey;\n children?: boolean;\n processingParams?: InstanceHierarchyNodeProcessingParams;\n};\n/** A grouping node that groups either instance nodes or other grouping nodes. */\nexport type ProcessedGroupingHierarchyNode = Omit<GroupingHierarchyNode, \"children\"> & {\n children: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n};\n/**\n * A `HierarchyNode` that may have processing parameters defining whether it should be hidden under some conditions,\n * how it should be grouped, sorted, etc.\n *\n * Type guards under `HierarchyNode` namespace can be used to differentiate between different sub-types of\n * `ProcessedHierarchyNode`.\n *\n * @beta\n */\nexport type ProcessedHierarchyNode = ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode | ProcessedGroupingHierarchyNode;\n\n/**\n * A `ProcessedHierarchyNode` that has an unformatted label in a form of `ConcatenatedValue`. Generally this is\n * returned when the node is just parsed from query results.\n * @beta\n */\nexport type ParsedHierarchyNode<TBase = ParsedCustomHierarchyNode | ParsedInstanceHierarchyNode> = OmitOverUnion<TBase, \"label\" | \"parentKeys\"> & {\n label: string | ConcatenatedValue;\n};\n/** A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedCustomHierarchyNode = ParsedHierarchyNode<ProcessedCustomHierarchyNode>;\n/** A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedInstanceHierarchyNode = ParsedHierarchyNode<ProcessedInstanceHierarchyNode>;\n"]}
1
+ {"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,OAAO,EAGL,gBAAgB,GAQjB,MAAM,oBAAoB,CAAC;AA8D5B,YAAY;AACZ,2DAA2D;AAC3D,MAAM,KAAW,aAAa,CAuE7B;AAvED,WAAiB,aAAa;IAC5B,qDAAqD;IACrD,SAAgB,QAAQ,CACtB,IAAW;QAEX,OAAO,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAJe,sBAAQ,WAIvB,CAAA;IACD,8EAA8E;IAC9E,SAAgB,UAAU,CAA0C,IAAW;QAC7E,OAAO,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAFe,wBAAU,aAEzB,CAAA;IACD,iEAAiE;IACjE,SAAgB,eAAe,CAC7B,IAAW;QAEX,OAAO,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IAJe,6BAAe,kBAI9B,CAAA;IACD,uDAAuD;IACvD,SAAgB,cAAc,CAC5B,IAAW;QAEX,OAAO,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAJe,4BAAc,iBAI7B,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAIX,OAAO,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IANe,iCAAmB,sBAMlC,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAIX,OAAO,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IANe,iCAAmB,sBAMlC,CAAA;IACD,gFAAgF;IAChF,SAAgB,iCAAiC,CAC/C,IAAW;QAIX,OAAO,gBAAgB,CAAC,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IANe,+CAAiC,oCAMhD,CAAA;IACD,sEAAsE;IACtE,SAAgB,2BAA2B,CACzC,IAAW;QAIX,OAAO,gBAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IANe,yCAA2B,8BAM1C,CAAA;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAIX,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IANe,8CAAgC,mCAM/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAIX,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IANe,oCAAsB,yBAMrC,CAAA;AACH,CAAC,EAvEgB,aAAa,KAAb,aAAa,QAuE7B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ConcatenatedValue, InstanceKey, OmitOverUnion, PrimitiveValue } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier\";\nimport {\n ClassGroupingNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n StandardHierarchyNodeKey,\n} from \"./HierarchyNodeKey\";\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n /** Data that may be assigned to the node if filtering is enabled */\n filtering?: {\n isFilterTarget?: boolean;\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];\n };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @beta\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: string | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @beta\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: InstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @beta\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a custom node */\n export function isCustom<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedCustomHierarchyNode : NonGroupingHierarchyNode) & { key: string } {\n return HierarchyNodeKey.isCustom(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isStandard<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: StandardHierarchyNodeKey } {\n return HierarchyNodeKey.isStandard(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedInstanceHierarchyNode : NonGroupingHierarchyNode) & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & (TNode extends ProcessedHierarchyNode ? ProcessedGroupingHierarchyNode : GroupingHierarchyNode) {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & (TNode extends ProcessedHierarchyNode\n ? ProcessedGroupingHierarchyNode\n : GroupingHierarchyNode) {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n\n/**\n * Base processing parameters that apply to every node.\n */\ninterface HierarchyNodeProcessingParamsBase {\n /** Indicates if this node should be hidden if it has no child nodes. */\n hideIfNoChildren?: boolean;\n /** Indicates that this node should always be hidden and its children should be loaded in its place. */\n hideInHierarchy?: boolean;\n}\n\n/**\n * A data structure for defining nodes' grouping requirements.\n */\ninterface HierarchyNodeGroupingParams {\n byLabel?: HierarchyNodeLabelGroupingParams;\n byClass?: boolean | HierarchyNodeGroupingParamsBase;\n byBaseClasses?: HierarchyNodeBaseClassGroupingParams;\n byProperties?: HierarchyNodePropertiesGroupingParams;\n}\n\n/**\n * A data structure for defining params specifically used for label grouping.\n */\ninterface HierarchyNodeLabelGroupingBaseParams {\n /** Label grouping option that determines whether to group nodes or to merge them. Defaults to \"group\".*/\n action?: \"group\" | \"merge\";\n /** Value that needs to match in order for nodes to be grouped or merged.*/\n groupId?: string;\n}\n\n/**\n * A data structure for defining label merging.\n */\ninterface HierarchyNodeLabelGroupingMergeParams extends HierarchyNodeLabelGroupingBaseParams {\n action: \"merge\";\n}\n\n/**\n * A data structure for defining label grouping with additional parameters.\n */\ninterface HierarchyNodeLabelGroupingGroupParams extends HierarchyNodeLabelGroupingBaseParams, HierarchyNodeGroupingParamsBase {\n action?: \"group\";\n}\n\n/** A data structure for defining possible label grouping types. */\nexport type HierarchyNodeLabelGroupingParams = boolean | HierarchyNodeLabelGroupingMergeParams | HierarchyNodeLabelGroupingGroupParams;\n\n/** Grouping parameters that are shared across all types of groupings. */\nexport interface HierarchyNodeGroupingParamsBase {\n /** Hiding option that determines whether to hide group nodes which have no siblings at the same hierarchy level. */\n hideIfNoSiblings?: boolean;\n /** Hiding option that determines whether to hide group nodes which have only one node as its children. */\n hideIfOneGroupedNode?: boolean;\n /** Option which auto expands grouping nodes' children when it has single child or always. */\n autoExpand?: HierarchyNodeAutoExpandProp;\n}\n\n/**\n * Defines possible values for `BaseGroupingParams.autoExpand` attribute:\n * - `single-child` - set the grouping node to auto-expand if it groups a single node.\n * - `always` - always set the grouping node to auto-expand.\n */\nexport type HierarchyNodeAutoExpandProp = \"single-child\" | \"always\";\n\n/**\n * A data structure that represents base class grouping.\n */\ninterface HierarchyNodeBaseClassGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full names of classes, which should be used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n fullClassNames: string[];\n}\n\n/** A data structure that represents properties grouping. */\nexport interface HierarchyNodePropertiesGroupingParams extends HierarchyNodeGroupingParamsBase {\n /**\n * Full name of a class whose properties are used to group the node. Only has effect if the node\n * represents an instance of that class.\n *\n * Full class name format: `SchemaName.ClassName`.\n */\n propertiesClassName: string;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value is not set or is set to an empty string.\n *\n * Label of the created grouping node will be `Not Specified`.\n */\n createGroupForUnspecifiedValues?: boolean;\n /**\n * Property grouping option that determines whether to group nodes whose grouping value doesn't fit within any of the provided\n * ranges, or is not a numeric value.\n *\n * Label of the created grouping node will be `Other`.\n */\n createGroupForOutOfRangeValues?: boolean;\n /**\n * Properties of the specified class, by which the nodes should be grouped. Each provided group definition results in a\n * grouping hierarchy level.\n *\n * Example usage:\n * ```ts\n * propertyGroups: [\n * {\n * propertyName: \"type\",\n * propertyValue: \"Wall\"\n * },\n * {\n * propertyName: \"length\",\n * propertyValue: 15,\n * ranges: [\n * { fromValue: 1, toValue: 10, rangeLabel: \"Small\" },\n * { fromValue: 11, toValue: 20, rangeLabel: \"Medium\" }\n * ]\n * },\n * ]\n * ```\n */\n propertyGroups: HierarchyNodePropertyGroup[];\n}\n\n/** A data structure that represents specific properties' grouping params. */\nexport interface HierarchyNodePropertyGroup {\n /** A string indicating the name of the property to group by. */\n propertyName: string;\n /** Value of the property, which will be used to group the node. */\n propertyValue?: PrimitiveValue;\n /** Ranges are used to group nodes by numeric properties which are within specified bounds. */\n ranges?: HierarchyNodePropertyValueRange[];\n}\n\n/** A data structure that represents boundaries for a value. */\nexport interface HierarchyNodePropertyValueRange {\n /** Defines the lower bound of the range. */\n fromValue: number;\n /** Defines the upper bound of the range. */\n toValue: number;\n /** Defines the range label. Will be used as `PropertyValueRangeGroupingNode` node's display label. */\n rangeLabel?: string;\n}\n\n/** Processing parameters that apply to instance nodes. */\nexport interface InstanceHierarchyNodeProcessingParams extends HierarchyNodeProcessingParamsBase {\n grouping?: HierarchyNodeGroupingParams;\n}\n\n/** A custom (not based on data in an iModel) node that has processing parameters. */\nexport type ProcessedCustomHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: string;\n children?: boolean;\n processingParams?: HierarchyNodeProcessingParamsBase;\n};\n/** An instances' (based on data in an iModel) node that has processing parameters. */\nexport type ProcessedInstanceHierarchyNode = Omit<NonGroupingHierarchyNode, \"key\" | \"children\"> & {\n key: InstancesNodeKey;\n children?: boolean;\n processingParams?: InstanceHierarchyNodeProcessingParams;\n};\n/** A grouping node that groups either instance nodes or other grouping nodes. */\nexport type ProcessedGroupingHierarchyNode = Omit<GroupingHierarchyNode, \"children\"> & {\n children: Array<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>;\n};\n\n/**\n * A `HierarchyNode` that may have processing parameters defining whether it should be hidden under some conditions,\n * how it should be grouped, sorted, etc.\n *\n * Type guards under `HierarchyNode` namespace can be used to differentiate between different sub-types of\n * `ProcessedHierarchyNode`.\n *\n * @beta\n */\nexport type ProcessedHierarchyNode = ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode | ProcessedGroupingHierarchyNode;\n\n/**\n * A `ProcessedHierarchyNode` that has an unformatted label in a form of `ConcatenatedValue`. Generally this is\n * returned when the node is just parsed from query results.\n * @beta\n */\nexport type ParsedHierarchyNode<TBase = ParsedCustomHierarchyNode | ParsedInstanceHierarchyNode> = OmitOverUnion<TBase, \"label\" | \"parentKeys\"> & {\n label: string | ConcatenatedValue;\n};\n/** A kind of `ProcessedCustomHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedCustomHierarchyNode = ParsedHierarchyNode<ProcessedCustomHierarchyNode>;\n/** A kind of `ProcessedInstanceHierarchyNode` that has unformatted label and doesn't know about its ancestors. */\nexport type ParsedInstanceHierarchyNode = ParsedHierarchyNode<ProcessedInstanceHierarchyNode>;\n"]}
@@ -1,6 +1,5 @@
1
1
  import { ECClassHierarchyInspector, InstanceKey } from "@itwin/presentation-shared";
2
2
  import { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, InstanceNodesQueryDefinition, NodeParser, NodePostProcessor, NodePreProcessor } from "../HierarchyDefinition";
3
- import { ProcessedHierarchyNode } from "../HierarchyNode";
4
3
  import { HierarchyNodeIdentifiersPath } from "../HierarchyNodeIdentifier";
5
4
  /** @internal */
6
5
  export interface FilteringQueryBuilderProps {
@@ -9,12 +8,6 @@ export interface FilteringQueryBuilderProps {
9
8
  nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];
10
9
  }
11
10
  /** @internal */
12
- export type FilteredHierarchyNode<TNode = ProcessedHierarchyNode> = TNode & {
13
- isFilterTarget?: boolean;
14
- hasFilterTargetAncestor?: boolean;
15
- filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];
16
- };
17
- /** @internal */
18
11
  export declare class FilteringHierarchyDefinition implements HierarchyDefinition {
19
12
  private _classHierarchy;
20
13
  private _source;
@@ -23,9 +16,7 @@ export declare class FilteringHierarchyDefinition implements HierarchyDefinition
23
16
  get preProcessNode(): NodePreProcessor;
24
17
  get postProcessNode(): NodePostProcessor;
25
18
  get parseNode(): NodeParser;
26
- defineHierarchyLevel(props: DefineHierarchyLevelProps & {
27
- parentNode: FilteredHierarchyNode<DefineHierarchyLevelProps["parentNode"]> | undefined;
28
- }): Promise<HierarchyLevelDefinition>;
19
+ defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
29
20
  private getFilteringProps;
30
21
  }
31
22
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAEL,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EAExB,4BAA4B,EAC5B,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAKL,sBAAsB,EAEvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA2B,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAGnG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AE,OAAO,EACvB,oBAAoB,EAAE,OAAO,EAC7B,uBAAuB,EAAE,OAAO,GAC/B,4BAA4B,CA+B9B"}
1
+ {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAEL,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EAExB,4BAA4B,EAC5B,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA2B,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAGnG,gBAAgB;AAChB,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,yBAAyB,CAAC;IAC1C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,mBAAmB,EAAE,4BAA4B,EAAE,CAAC;CACrD;AAED,gBAAgB;AAChB,qBAAa,4BAA6B,YAAW,mBAAmB;IACtE,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,oBAAoB,CAAiC;gBAE1C,KAAK,EAAE,0BAA0B;IAMpD,IAAW,cAAc,IAAI,gBAAgB,CAS5C;IAED,IAAW,eAAe,IAAI,iBAAiB,CAc9C;IAED,IAAW,SAAS,IAAI,UAAU,CAUjC;IAEY,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAsDtG,OAAO,CAAC,iBAAiB;CAU1B;AAqED,gBAAgB;AAEhB,eAAO,MAAM,uCAAuC,0BAA0B,CAAC;AAE/E,gBAAgB;AAEhB,eAAO,MAAM,gCAAgC,mBAAmB,CAAC;AAEjE,gBAAgB;AAEhB,eAAO,MAAM,yCAAyC,4BAA4B,CAAC;AAEnF,gBAAgB;AAChB,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,4BAA4B,EACjC,eAAe,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,WAAW,CAAC;IAAC,uBAAuB,EAAE,4BAA4B,EAAE,CAAA;CAAE,CAAC,EACpG,cAAc,EAAE,OAAO,EACvB,oBAAoB,EAAE,OAAO,EAC7B,uBAAuB,EAAE,OAAO,GAC/B,4BAA4B,CA+B9B"}
@@ -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 { HierarchyNodesDefinition, } from "../HierarchyDefinition";
6
- import { HierarchyNode, } from "../HierarchyNode";
6
+ import { HierarchyNode } from "../HierarchyNode";
7
7
  import { HierarchyNodeIdentifier } from "../HierarchyNodeIdentifier";
8
8
  import { defaultNodesParser } from "./TreeNodesReader";
9
9
  /** @internal */
@@ -19,8 +19,7 @@ export class FilteringHierarchyDefinition {
19
19
  get preProcessNode() {
20
20
  return async (node) => {
21
21
  const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;
22
- const filteredNode = processedNode;
23
- if (filteredNode?.processingParams?.hideInHierarchy && filteredNode.isFilterTarget && !filteredNode.hasFilterTargetAncestor) {
22
+ if (processedNode?.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {
24
23
  // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target
25
24
  return undefined;
26
25
  }
@@ -33,7 +32,7 @@ export class FilteringHierarchyDefinition {
33
32
  if (
34
33
  // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing
35
34
  HierarchyNode.isClassGroupingNode(node) &&
36
- node.children.some((child) => child.isFilterTarget || child.filteredChildrenIdentifierPaths)) {
35
+ node.children.some((child) => child.filtering && (child.filtering.isFilterTarget || child.filtering.filteredChildrenIdentifierPaths))) {
37
36
  return Object.assign(processedNode, { autoExpand: true });
38
37
  }
39
38
  return processedNode;
@@ -92,9 +91,9 @@ export class FilteringHierarchyDefinition {
92
91
  return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };
93
92
  }
94
93
  return {
95
- filteredNodePaths: parentNode.filteredChildrenIdentifierPaths,
96
- isDirectParentFilterTarget: parentNode.isFilterTarget,
97
- hasFilterTargetAncestor: !!parentNode.hasFilterTargetAncestor,
94
+ filteredNodePaths: parentNode.filtering?.filteredChildrenIdentifierPaths,
95
+ isDirectParentFilterTarget: parentNode.filtering?.isFilterTarget,
96
+ hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor,
98
97
  };
99
98
  }
100
99
  }
@@ -134,13 +133,18 @@ async function matchFilters(definition, filteringProps, predicate, matchedDefini
134
133
  }
135
134
  function applyFilterAttributes(node, filteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor) {
136
135
  const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);
137
- return {
138
- ...node,
139
- ...(isFilterTarget ? { isFilterTarget } : undefined),
140
- ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),
141
- ...(shouldAutoExpand ? { autoExpand: true } : undefined),
142
- ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),
143
- };
136
+ const result = { ...node };
137
+ if (shouldAutoExpand) {
138
+ result.autoExpand = true;
139
+ }
140
+ if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {
141
+ result.filtering = {
142
+ ...(isFilterTarget ? { isFilterTarget } : undefined),
143
+ ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),
144
+ ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),
145
+ };
146
+ }
147
+ return result;
144
148
  }
145
149
  /** @internal */
146
150
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -1 +1 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../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IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;YAGD,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,gCAAgC;YAClE,uBAAuB,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,yCAAyC;4CAC5E,uCAAuC;;YAEvE,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACtC;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 {\n CustomHierarchyNodeDefinition,\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"../HierarchyDefinition\";\nimport {\n HierarchyNode,\n ParsedHierarchyNode,\n ParsedInstanceHierarchyNode,\n ProcessedCustomHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n} from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"../HierarchyNodeIdentifier\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n}\n\n/** @internal */\nexport type FilteredHierarchyNode<TNode = ProcessedHierarchyNode> = TNode & {\n isFilterTarget?: boolean;\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyNodeIdentifiersPath[];\n};\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n\n public constructor(props: FilteringQueryBuilderProps) {\n this._classHierarchy = props.classHierarchy;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n const filteredNode = processedNode as FilteredHierarchyNode<ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode> | undefined;\n if (filteredNode?.processingParams?.hideInHierarchy && filteredNode.isFilterTarget && !filteredNode.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return undefined;\n }\n return processedNode;\n };\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n if (\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n HierarchyNode.isClassGroupingNode(node) &&\n node.children.some((child: FilteredHierarchyNode) => child.isFilterTarget || child.filteredChildrenIdentifierPaths)\n ) {\n return Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): FilteredHierarchyNode<ParsedInstanceHierarchyNode> => {\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const parsedFilteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor);\n };\n }\n\n public async defineHierarchyLevel(\n props: DefineHierarchyLevelProps & { parentNode: FilteredHierarchyNode<DefineHierarchyLevelProps[\"parentNode\"]> | undefined },\n ): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { filteredNodePaths, isDirectParentFilterTarget, hasFilterTargetAncestor } = this.getFilteringProps(props.parentNode);\n if (!filteredNodePaths) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isCustomNode(definition)) {\n matchedDefinition = await matchFilters<{ key: string }>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {\n return false;\n }\n return id.key === definition.node.key;\n },\n (def, matchingFilters, isFilterTarget) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyNodeIdentifiersPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget, !!hasFilterTargetAncestor),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n return false;\n }\n return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);\n },\n (def, matchingFilters, isFilterTarget) =>\n applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n\n private getFilteringProps(parentNode: FilteredHierarchyNode<unknown> | undefined) {\n if (!parentNode) {\n return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };\n }\n return {\n filteredNodePaths: parentNode.filteredChildrenIdentifierPaths,\n isDirectParentFilterTarget: parentNode.isFilterTarget,\n hasFilterTargetAncestor: !!parentNode.hasFilterTargetAncestor,\n };\n }\n}\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyNodeIdentifiersPath[]; isDirectParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n matchedDefinitionProcessor: (\n def: TDefinition,\n matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n ) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;\n let isFilterTarget = false;\n const matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }> = [];\n for (const path of filteredNodePaths) {\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let childrenIdentifierPaths = matchingFilters.find(({ id }) => HierarchyNodeIdentifier.equal(id, nodeId))?.childrenIdentifierPaths;\n if (!childrenIdentifierPaths) {\n childrenIdentifierPaths = [];\n matchingFilters.push({\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths,\n });\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n childrenIdentifierPaths.push(remainingPath);\n } else {\n isFilterTarget = true;\n }\n }\n }\n if (isDirectParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters, isFilterTarget);\n }\n return undefined;\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>(\n node: TNode,\n filteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined,\n isFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);\n return {\n ...node,\n ...(isFilterTarget ? { isFilterTarget } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(shouldAutoExpand ? { autoExpand: true } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilteredChildrenPaths = \"FilteredChildrenPaths\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_IsFilterTarget = \"IsFilterTarget\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<{ id: InstanceKey; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n isParentFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map(({ id: key, childrenIdentifierPaths }) => `VALUES (${key.id}, '${JSON.stringify(childrenIdentifierPaths)}')`)\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n ${isFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n ${hasFilterTargetAncestor || isParentFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${isParentFilterTarget ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAKL,wBAAwB,GAKzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAA4E,MAAM,kBAAkB,CAAC;AAC3H,OAAO,EAAE,uBAAuB,EAAgC,MAAM,4BAA4B,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AASvD,gBAAgB;AAChB,MAAM,OAAO,4BAA4B;IAC/B,eAAe,CAA4B;IAC3C,OAAO,CAAsB;IAC7B,oBAAoB,CAAiC;IAE7D,YAAmB,KAAiC;QAClD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,mBAAmB,CAAC;IACxD,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;YACpB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,IAAI,C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;AAChE,MAAM,CAAC,MAAM,gCAAgC,GAAG,gBAAgB,CAAC;AAEjE,gBAAgB;AAChB,gEAAgE;AAChE,MAAM,CAAC,MAAM,yCAAyC,GAAG,yBAAyB,CAAC;AAEnF,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CACtC,GAAiC,EACjC,eAAoG,EACpG,cAAuB,EACvB,oBAA6B,EAC7B,uBAAgC;IAEhC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC;IACD,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,uIAAuI;gBACvI,iCAAiC;gBACjC;YACI,eAAe;qBACd,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,uBAAuB,EAAE,EAAE,EAAE,CAAC,WAAW,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,IAAI,CAAC;qBACjH,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;YAGD,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,gCAAgC;YAClE,uBAAuB,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,yCAAyC;4CAC5E,uCAAuC;;YAEvE,GAAG,CAAC,KAAK,CAAC,KAAK;;UAEjB,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;OACtC;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 {\n CustomHierarchyNodeDefinition,\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"../HierarchyDefinition\";\nimport { HierarchyNode, ParsedHierarchyNode, ParsedInstanceHierarchyNode, ProcessedHierarchyNode } from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"../HierarchyNodeIdentifier\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyNodeIdentifiersPath[];\n\n public constructor(props: FilteringQueryBuilderProps) {\n this._classHierarchy = props.classHierarchy;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n }\n\n public get preProcessNode(): NodePreProcessor {\n return async (node) => {\n const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;\n if (processedNode?.processingParams?.hideInHierarchy && 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 public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n if (\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n HierarchyNode.isClassGroupingNode(node) &&\n node.children.some(\n (child: ProcessedHierarchyNode) => child.filtering && (child.filtering.isFilterTarget || child.filtering.filteredChildrenIdentifierPaths),\n )\n ) {\n return Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): ParsedInstanceHierarchyNode => {\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const parsedFilteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes(defaultNode, parsedFilteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor);\n };\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { filteredNodePaths, isDirectParentFilterTarget, hasFilterTargetAncestor } = this.getFilteringProps(props.parentNode);\n if (!filteredNodePaths) {\n return sourceDefinitions;\n }\n\n const filteredDefinitions: HierarchyLevelDefinition = [];\n await Promise.all(\n sourceDefinitions.map(async (definition) => {\n let matchedDefinition: HierarchyNodesDefinition | undefined;\n if (HierarchyNodesDefinition.isCustomNode(definition)) {\n matchedDefinition = await matchFilters<{ key: string }>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isCustomNodeIdentifier(id)) {\n return false;\n }\n return id.key === definition.node.key;\n },\n (def, matchingFilters, isFilterTarget) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyNodeIdentifiersPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes(def.node, filteredChildrenIdentifierPaths, isFilterTarget, !!hasFilterTargetAncestor),\n };\n },\n );\n } else {\n matchedDefinition = await matchFilters<InstanceKey>(\n definition,\n { filteredNodePaths, isDirectParentFilterTarget },\n async (id) => {\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n return false;\n }\n return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);\n },\n (def, matchingFilters, isFilterTarget) =>\n applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor),\n );\n }\n if (matchedDefinition) {\n filteredDefinitions.push(matchedDefinition);\n }\n }),\n );\n return filteredDefinitions;\n }\n\n private getFilteringProps(parentNode: Pick<HierarchyNode, \"filtering\"> | undefined) {\n if (!parentNode) {\n return { filteredNodePaths: this._nodeIdentifierPaths, isDirectParentFilterTarget: false, hasFilterTargetAncestor: false };\n }\n return {\n filteredNodePaths: parentNode.filtering?.filteredChildrenIdentifierPaths,\n isDirectParentFilterTarget: parentNode.filtering?.isFilterTarget,\n hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor,\n };\n }\n}\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyNodeIdentifiersPath[]; isDirectParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n matchedDefinitionProcessor: (\n def: TDefinition,\n matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n ) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;\n let isFilterTarget = false;\n const matchingFilters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }> = [];\n for (const path of filteredNodePaths) {\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let childrenIdentifierPaths = matchingFilters.find(({ id }) => HierarchyNodeIdentifier.equal(id, nodeId))?.childrenIdentifierPaths;\n if (!childrenIdentifierPaths) {\n childrenIdentifierPaths = [];\n matchingFilters.push({\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths,\n });\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n childrenIdentifierPaths.push(remainingPath);\n } else {\n isFilterTarget = true;\n }\n }\n }\n if (isDirectParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters, isFilterTarget);\n }\n return undefined;\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>(\n node: TNode,\n filteredChildrenIdentifierPaths: HierarchyNodeIdentifiersPath[] | undefined,\n isFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((path) => !!path.length);\n const result = { ...node };\n if (shouldAutoExpand) {\n result.autoExpand = true;\n }\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n result.filtering = {\n ...(isFilterTarget ? { isFilterTarget } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\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_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<{ id: InstanceKey; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n isFilterTarget: boolean,\n isParentFilterTarget: boolean,\n hasFilterTargetAncestor: boolean,\n): InstanceNodesQueryDefinition {\n if (matchingFilters.length === 0) {\n return def;\n }\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n // note: generally we'd use `VALUES (1,1),(2,2)`, but that doesn't work in ECSQL (https://github.com/iTwin/itwinjs-backlog/issues/865),\n // so using UNION as a workaround\n `FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map(({ id: key, childrenIdentifierPaths }) => `VALUES (${key.id}, '${JSON.stringify(childrenIdentifierPaths)}')`)\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n ${isFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n ${hasFilterTargetAncestor || isParentFilterTarget ? \"1\" : \"0\"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],\n [f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n ${isParentFilterTarget ? \"LEFT \" : \"\"} JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/presentation-hierarchies",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A package for creating hierarchies based on data in iTwin.js iModels.",
5
5
  "license": "MIT",
6
6
  "author": {