@itwin/presentation-hierarchies 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +1 -1
  3. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +1 -1
  4. package/lib/cjs/hierarchies/HierarchyFiltering.js +10 -5
  5. package/lib/cjs/hierarchies/HierarchyFiltering.js.map +1 -1
  6. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +11 -7
  7. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
  8. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +64 -58
  9. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
  10. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  11. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +32 -39
  12. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  13. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
  14. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  15. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +2 -5
  16. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  17. package/lib/cjs/hierarchies/imodel/operators/Grouping.d.ts +1 -3
  18. package/lib/cjs/hierarchies/imodel/operators/Grouping.d.ts.map +1 -1
  19. package/lib/cjs/hierarchies/imodel/operators/Grouping.js +5 -5
  20. package/lib/cjs/hierarchies/imodel/operators/Grouping.js.map +1 -1
  21. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts +64 -0
  22. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -0
  23. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +25 -0
  24. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -0
  25. package/lib/esm/hierarchies/HierarchyFiltering.d.ts +1 -1
  26. package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +1 -1
  27. package/lib/esm/hierarchies/HierarchyFiltering.js +10 -5
  28. package/lib/esm/hierarchies/HierarchyFiltering.js.map +1 -1
  29. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +11 -7
  30. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
  31. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +65 -59
  32. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
  33. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  34. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +33 -40
  35. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  36. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
  37. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  38. package/lib/esm/hierarchies/imodel/TreeNodesReader.js +2 -5
  39. package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  40. package/lib/esm/hierarchies/imodel/operators/Grouping.d.ts +1 -3
  41. package/lib/esm/hierarchies/imodel/operators/Grouping.d.ts.map +1 -1
  42. package/lib/esm/hierarchies/imodel/operators/Grouping.js +6 -5
  43. package/lib/esm/hierarchies/imodel/operators/Grouping.js.map +1 -1
  44. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts +64 -0
  45. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -0
  46. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +22 -0
  47. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -0
  48. package/package.json +22 -26
@@ -1 +1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AAC;AAED,IAAK,aAKJ;AALD,WAAK,aAAa;IAChB,iDAAQ,CAAA;IACR,mDAAS,CAAA;IACT,yDAAY,CAAA;IACZ,mDAAS,CAAA;AACX,CAAC,EALI,aAAa,KAAb,aAAa,QAKjB","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 { concat, concatAll, delay, EMPTY, expand, finalize, from, last, map, merge, mergeMap, Observable, of, reduce, tap, toArray } from \"rxjs\";\nimport { assert, StopWatch } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, ECSchemaProvider, IPrimitiveValueFormatter } from \"@itwin/presentation-shared\";\nimport { HierarchyNode, ParentHierarchyNode } from \"../../HierarchyNode.js\";\nimport {\n LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE,\n LOGGING_NAMESPACE_PERFORMANCE_INTERNAL as BASE_LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n createNodeIdentifierForLogging,\n createOperatorLoggingNamespace,\n LOGGING_NAMESPACE_INTERNAL,\n} from \"../../internal/Common.js\";\nimport { doLog, log } from \"../../internal/LoggingUtils.js\";\nimport { releaseMainThreadOnItemsCount } from \"../../internal/operators/ReleaseMainThread.js\";\nimport { tapOnce } from \"../../internal/operators/TapOnce.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode } from \"../IModelHierarchyNode.js\";\nimport { assignAutoExpand } from \"./grouping/AutoExpand.js\";\nimport { createBaseClassGroupingHandlers } from \"./grouping/BaseClassGrouping.js\";\nimport { createClassGroups } from \"./grouping/ClassGrouping.js\";\nimport { applyGroupHidingParams } from \"./grouping/GroupHiding.js\";\nimport { createLabelGroups } from \"./grouping/LabelGrouping.js\";\nimport { createPropertiesGroupingHandlers, PropertiesGroupingLocalizedStrings } from \"./grouping/PropertiesGrouping.js\";\n\nconst OPERATOR_NAME = \"Grouping\";\n/** @internal */\nexport const LOGGING_NAMESPACE = createOperatorLoggingNamespace(OPERATOR_NAME, LOGGING_NAMESPACE_INTERNAL);\nconst LOGGING_NAMESPACE_PERFORMANCE = createOperatorLoggingNamespace(OPERATOR_NAME, BASE_LOGGING_NAMESPACE_PERFORMANCE);\nconst LOGGING_NAMESPACE_PERFORMANCE_INTERNAL = createOperatorLoggingNamespace(OPERATOR_NAME, BASE_LOGGING_NAMESPACE_PERFORMANCE_INTERNAL);\n\n/** @internal */\nexport function createGroupingOperator(\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector,\n parentNode: ParentHierarchyNode | undefined,\n valueFormatter: IPrimitiveValueFormatter,\n localizedStrings: PropertiesGroupingLocalizedStrings,\n onGroupingNodeCreated?: (groupingNode: ProcessedGroupingHierarchyNode) => void,\n groupingHandlers?: GroupingHandler[],\n) {\n return function (nodes: Observable<ProcessedHierarchyNode>): Observable<ProcessedHierarchyNode> {\n return nodes.pipe(\n log({ category: LOGGING_NAMESPACE, message: /* c8 ignore next */ (n) => `in: ${createNodeIdentifierForLogging(n)}` }),\n tapOnce(() => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () => `Starting grouping (parent: ${createNodeIdentifierForLogging(parentNode)})`,\n });\n }),\n reduce<ProcessedHierarchyNode, { instanceNodes: ProcessedInstanceHierarchyNode[]; restNodes: ProcessedHierarchyNode[] }>(\n (resolvedNodes, node) => {\n if (HierarchyNode.isInstancesNode(node)) {\n resolvedNodes.instanceNodes.push(node);\n } else {\n resolvedNodes.restNodes.push(node);\n }\n return resolvedNodes;\n },\n { instanceNodes: [], restNodes: [] },\n ),\n tap(({ instanceNodes, restNodes }) => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Nodes partitioned. Got ${instanceNodes.length} instance nodes and ${restNodes.length} rest nodes.`,\n });\n }),\n mergeMap((res) => {\n const out = of(res);\n const totalNodes = res.instanceNodes.length + res.restNodes.length;\n /* c8 ignore next */\n return totalNodes <= 1000 ? out : out.pipe(delay(0));\n }),\n mergeMap(({ instanceNodes, restNodes }): Observable<ProcessedHierarchyNode> => {\n const timer = new StopWatch(undefined, true);\n const groupingHandlersObs: Observable<GroupingHandler> = groupingHandlers\n ? from(groupingHandlers)\n : createGroupingHandlers(imodelAccess, parentNode, instanceNodes, valueFormatter, localizedStrings);\n return merge(\n groupingHandlersObs.pipe(\n toArray(),\n mergeMap((createdGroupingHandlers) =>\n groupInstanceNodes(instanceNodes, restNodes.length, createdGroupingHandlers, parentNode, onGroupingNodeCreated),\n ),\n finalize(() => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () => `Grouping ${instanceNodes.length} nodes took ${timer.elapsedSeconds.toFixed(3)} s`,\n });\n }),\n ),\n from(restNodes),\n );\n }),\n releaseMainThreadOnItemsCount(500),\n log({ category: LOGGING_NAMESPACE, message: /* c8 ignore next */ (n) => `out: ${createNodeIdentifierForLogging(n)}` }),\n );\n };\n}\n\n/** @internal */\nexport type ProcessedInstancesGroupingHierarchyNode = Omit<ProcessedGroupingHierarchyNode, \"children\"> & { children: ProcessedInstanceHierarchyNode[] };\n\n/** @internal */\nexport interface GroupingHandlerResult {\n /** Expected to be sorted by label. */\n grouped: Array<ProcessedInstancesGroupingHierarchyNode>;\n /** Expected to be sorted by label. */\n ungrouped: ProcessedInstanceHierarchyNode[];\n groupingType: GroupingType;\n}\n\n/** @internal */\nexport type GroupingType = \"label\" | \"class\" | \"base-class\" | \"property\";\n\n/** @internal */\nexport type GroupingHandler = (\n nodesToGroup: ProcessedInstanceHierarchyNode[],\n nodesAlreadyGrouped: ProcessedInstancesGroupingHierarchyNode[],\n) => Promise<GroupingHandlerResult>;\n\nfunction groupInstanceNodes(\n nodes: ProcessedInstanceHierarchyNode[],\n extraSiblings: number,\n groupingHandlers: GroupingHandler[],\n parentNode: ParentHierarchyNode | undefined,\n onGroupingNodeCreated?: (groupingNode: ProcessedGroupingHierarchyNode) => void,\n): Observable<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode> {\n if (groupingHandlers.length === 0) {\n return from(nodes);\n }\n return of<{ handlerIndex: number; result?: GroupingHandlerResult | undefined }>({ handlerIndex: 0 }).pipe(\n expand(({ handlerIndex, result: curr }) => {\n if (handlerIndex >= groupingHandlers.length) {\n return EMPTY;\n }\n const timer = new StopWatch(undefined, true);\n const currentHandler = groupingHandlers[handlerIndex];\n return from(currentHandler(curr?.ungrouped ?? nodes, curr?.grouped ?? [])).pipe(\n log({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Grouping handler ${handlerIndex} exclusively took ${timer.elapsedSeconds.toFixed(3)} s.`,\n }),\n mergeMap((result) => {\n if (result.grouped.length === 0) {\n return of({ handlerIndex: handlerIndex + 1, result: { ...result, grouped: curr?.grouped ?? [] } });\n }\n const groupingPostProcessingTimer = new StopWatch(undefined, true);\n return of(result).pipe(\n map((r) => applyGroupHidingParams(r, extraSiblings)),\n map((r) => assignAutoExpand(r)),\n map((r) => ({ handlerIndex: handlerIndex + 1, result: { ...r, grouped: mergeInPlace(curr?.grouped, r.grouped) } })),\n log({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () =>\n `Post-processing grouping handler ${handlerIndex} exclusively took ${groupingPostProcessingTimer.elapsedSeconds.toFixed(3)} s.`,\n }),\n delay(0),\n );\n }),\n log({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Total time for grouping handler ${handlerIndex}: ${timer.elapsedSeconds.toFixed(3)} s.`,\n }),\n );\n }),\n last(),\n mergeMap(({ result }) => {\n result.grouped.forEach((groupingNode) => {\n onGroupingNodeCreated?.(groupingNode);\n if (!parentNode) {\n return;\n }\n if (HierarchyNode.isGroupingNode(parentNode)) {\n groupingNode.nonGroupingAncestor = parentNode.nonGroupingAncestor;\n return;\n }\n // not sure why type checker doesn't pick this up\n assert(HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));\n groupingNode.nonGroupingAncestor = parentNode;\n });\n return mergeInPlace<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>(result.grouped, result.ungrouped);\n }),\n );\n}\n\nfunction mergeInPlace<T>(target: T[] | undefined, source: T[]) {\n if (!target || target.length === 0) {\n return source;\n }\n for (const item of source) {\n target.push(item);\n }\n return target;\n}\n\n/** @internal */\nexport function createGroupingHandlers(\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector,\n parentNode: ParentHierarchyNode | undefined,\n processedInstanceNodes: ProcessedInstanceHierarchyNode[],\n valueFormatter: IPrimitiveValueFormatter,\n localizedStrings: PropertiesGroupingLocalizedStrings,\n): Observable<GroupingHandler> {\n const timer = new StopWatch();\n const groupingLevel = getNodeGroupingLevel(parentNode);\n return concat(\n groupingLevel <= GroupingLevel.Class\n ? concat(\n from(createBaseClassGroupingHandlers(imodelAccess, parentNode, processedInstanceNodes)).pipe(concatAll()),\n of<GroupingHandler>(async (allNodes) => createClassGroups(imodelAccess, parentNode, allNodes)),\n )\n : EMPTY,\n groupingLevel <= GroupingLevel.Property\n ? from(createPropertiesGroupingHandlers(imodelAccess, parentNode, processedInstanceNodes, valueFormatter, localizedStrings)).pipe(concatAll())\n : EMPTY,\n groupingLevel < GroupingLevel.Label ? of<GroupingHandler>(async (allNodes) => createLabelGroups(allNodes)) : EMPTY,\n ).pipe(\n tap({\n subscribe: () => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Start creating grouping handlers`,\n });\n timer.start();\n },\n }),\n finalize(() => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Creating grouping handlers took ${timer.elapsedSeconds.toFixed(3)} s`,\n });\n }),\n );\n}\n\nfunction getNodeGroupingLevel(node: ParentHierarchyNode | undefined): GroupingLevel {\n if (node && HierarchyNode.isClassGroupingNode(node)) {\n return GroupingLevel.Class;\n }\n if (node && HierarchyNode.isPropertyGroupingNode(node)) {\n return GroupingLevel.Property;\n }\n if (node && HierarchyNode.isLabelGroupingNode(node)) {\n return GroupingLevel.Label;\n }\n return GroupingLevel.None;\n}\n\nenum GroupingLevel {\n None = 0,\n Class = 2,\n Property = 3,\n Label = 4,\n}\n"]}
1
+ {"version":3,"file":"Grouping.js","sourceRoot":"","sources":["../../../../../src/hierarchies/imodel/operators/Grouping.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA+BhG,wDAkEC;AA/FD,+BAAiJ;AACjJ,sDAAwD;AAExD,6DAA4E;AAC5E,wDAMkC;AAClC,oEAA4D;AAC5D,wFAA8F;AAC9F,oEAA8D;AAE9D,4DAA4D;AAC5D,0EAAkF;AAClF,kEAAgE;AAChE,8DAAmE;AACnE,kEAAgE;AAChE,4EAAwH;AAExH,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,gBAAgB;AACH,QAAA,iBAAiB,GAAG,IAAA,0CAA8B,EAAC,aAAa,EAAE,sCAA0B,CAAC,CAAC;AAC3G,MAAM,6BAA6B,GAAG,IAAA,0CAA8B,EAAC,aAAa,EAAE,yCAAkC,CAAC,CAAC;AACxH,MAAM,sCAAsC,GAAG,IAAA,0CAA8B,EAAC,aAAa,EAAE,kDAA2C,CAAC,CAAC;AAE1I,gBAAgB;AAChB,SAAgB,sBAAsB,CACpC,YAA0D,EAC1D,UAA2C,EAC3C,cAAwC,EACxC,gBAAoD,EACpD,cAAsG,EACtG,qBAA8E,EAC9E,gBAAoC;IAEpC,OAAO,UAAU,KAAyC;QACxD,OAAO,KAAK,CAAC,IAAI,CACf,IAAA,qBAAG,EAAC,EAAE,QAAQ,EAAE,yBAAiB,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,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,CAAC,IAAqC;IACjE,IAAI,IAAI,IAAI,gCAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,OAAO,aAAa,CAAC,KAAK,CAAC;IAC7B,CAAC;IACD,IAAI,IAAI,IAAI,gCAAa,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,OAAO,aAAa,CAAC,QAAQ,CAAC;IAChC,CAAC;IACD,IAAI,IAAI,IAAI,gCAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,OAAO,aAAa,CAAC,KAAK,CAAC;IAC7B,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC;AAC5B,CAAC;AAED,IAAK,aAKJ;AALD,WAAK,aAAa;IAChB,iDAAQ,CAAA;IACR,mDAAS,CAAA;IACT,yDAAY,CAAA;IACZ,mDAAS,CAAA;AACX,CAAC,EALI,aAAa,KAAb,aAAa,QAKjB","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 { concat, concatAll, delay, EMPTY, expand, finalize, from, last, map, merge, mergeMap, Observable, of, reduce, tap, toArray } from \"rxjs\";\nimport { assert, StopWatch } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, ECSchemaProvider, IPrimitiveValueFormatter } from \"@itwin/presentation-shared\";\nimport { HierarchyNode, ParentHierarchyNode } from \"../../HierarchyNode.js\";\nimport {\n LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE,\n LOGGING_NAMESPACE_PERFORMANCE_INTERNAL as BASE_LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n createNodeIdentifierForLogging,\n createOperatorLoggingNamespace,\n LOGGING_NAMESPACE_INTERNAL,\n} from \"../../internal/Common.js\";\nimport { doLog, log } from \"../../internal/LoggingUtils.js\";\nimport { releaseMainThreadOnItemsCount } from \"../../internal/operators/ReleaseMainThread.js\";\nimport { tapOnce } from \"../../internal/operators/TapOnce.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode } from \"../IModelHierarchyNode.js\";\nimport { assignAutoExpand } from \"./grouping/AutoExpand.js\";\nimport { createBaseClassGroupingHandlers } from \"./grouping/BaseClassGrouping.js\";\nimport { createClassGroups } from \"./grouping/ClassGrouping.js\";\nimport { applyGroupHidingParams } from \"./grouping/GroupHiding.js\";\nimport { createLabelGroups } from \"./grouping/LabelGrouping.js\";\nimport { createPropertiesGroupingHandlers, PropertiesGroupingLocalizedStrings } from \"./grouping/PropertiesGrouping.js\";\n\nconst OPERATOR_NAME = \"Grouping\";\n/** @internal */\nexport const LOGGING_NAMESPACE = createOperatorLoggingNamespace(OPERATOR_NAME, LOGGING_NAMESPACE_INTERNAL);\nconst LOGGING_NAMESPACE_PERFORMANCE = createOperatorLoggingNamespace(OPERATOR_NAME, BASE_LOGGING_NAMESPACE_PERFORMANCE);\nconst LOGGING_NAMESPACE_PERFORMANCE_INTERNAL = createOperatorLoggingNamespace(OPERATOR_NAME, BASE_LOGGING_NAMESPACE_PERFORMANCE_INTERNAL);\n\n/** @internal */\nexport function createGroupingOperator(\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector,\n parentNode: ParentHierarchyNode | undefined,\n valueFormatter: IPrimitiveValueFormatter,\n localizedStrings: PropertiesGroupingLocalizedStrings,\n onNodesGrouped?: (groupingResult: GroupingHandlerResult | undefined, handler: GroupingHandler) => void,\n onGroupingNodeCreated?: (groupingNode: ProcessedGroupingHierarchyNode) => void,\n groupingHandlers?: GroupingHandler[],\n) {\n return function (nodes: Observable<ProcessedHierarchyNode>): Observable<ProcessedHierarchyNode> {\n return nodes.pipe(\n log({ category: LOGGING_NAMESPACE, message: /* c8 ignore next */ (n) => `in: ${createNodeIdentifierForLogging(n)}` }),\n tapOnce(() => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () => `Starting grouping (parent: ${createNodeIdentifierForLogging(parentNode)})`,\n });\n }),\n reduce<ProcessedHierarchyNode, { instanceNodes: ProcessedInstanceHierarchyNode[]; restNodes: ProcessedHierarchyNode[] }>(\n (resolvedNodes, node) => {\n if (HierarchyNode.isInstancesNode(node)) {\n resolvedNodes.instanceNodes.push(node);\n } else {\n resolvedNodes.restNodes.push(node);\n }\n return resolvedNodes;\n },\n { instanceNodes: [], restNodes: [] },\n ),\n tap(({ instanceNodes, restNodes }) => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Nodes partitioned. Got ${instanceNodes.length} instance nodes and ${restNodes.length} rest nodes.`,\n });\n }),\n mergeMap((res) => {\n const out = of(res);\n const totalNodes = res.instanceNodes.length + res.restNodes.length;\n /* c8 ignore next */\n return totalNodes <= 1000 ? out : out.pipe(delay(0));\n }),\n mergeMap(({ instanceNodes, restNodes }): Observable<ProcessedHierarchyNode> => {\n const timer = new StopWatch(undefined, true);\n const groupingHandlersObs: Observable<GroupingHandler> = groupingHandlers\n ? from(groupingHandlers)\n : createGroupingHandlers(imodelAccess, parentNode, instanceNodes, valueFormatter, localizedStrings);\n return merge(\n groupingHandlersObs.pipe(\n toArray(),\n mergeMap((createdGroupingHandlers) =>\n groupInstanceNodes(instanceNodes, restNodes.length, createdGroupingHandlers, parentNode, onNodesGrouped, onGroupingNodeCreated),\n ),\n finalize(() => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* c8 ignore next */ () => `Grouping ${instanceNodes.length} nodes took ${timer.elapsedSeconds.toFixed(3)} s`,\n });\n }),\n ),\n from(restNodes),\n );\n }),\n releaseMainThreadOnItemsCount(500),\n log({ category: LOGGING_NAMESPACE, message: /* c8 ignore next */ (n) => `out: ${createNodeIdentifierForLogging(n)}` }),\n );\n };\n}\n\n/** @internal */\nexport type ProcessedInstancesGroupingHierarchyNode = Omit<ProcessedGroupingHierarchyNode, \"children\"> & { children: ProcessedInstanceHierarchyNode[] };\n\n/** @internal */\nexport interface GroupingHandlerResult {\n /** Expected to be sorted by label. */\n grouped: Array<ProcessedInstancesGroupingHierarchyNode>;\n /** Expected to be sorted by label. */\n ungrouped: ProcessedInstanceHierarchyNode[];\n groupingType: GroupingType;\n}\n\n/** @internal */\nexport type GroupingType = \"label\" | \"class\" | \"base-class\" | \"property\";\n\n/** @internal */\nexport type GroupingHandler = (\n nodesToGroup: ProcessedInstanceHierarchyNode[],\n nodesAlreadyGrouped: ProcessedInstancesGroupingHierarchyNode[],\n) => Promise<GroupingHandlerResult>;\n\nfunction groupInstanceNodes(\n nodes: ProcessedInstanceHierarchyNode[],\n extraSiblings: number,\n groupingHandlers: GroupingHandler[],\n parentNode: ParentHierarchyNode | undefined,\n onNodesGrouped?: (groupingResult: GroupingHandlerResult | undefined, handler: GroupingHandler) => void,\n onGroupingNodeCreated?: (groupingNode: ProcessedGroupingHierarchyNode) => void,\n): Observable<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode> {\n if (groupingHandlers.length === 0) {\n return from(nodes);\n }\n return of<{ handlerIndex: number; result?: GroupingHandlerResult | undefined }>({ handlerIndex: 0 }).pipe(\n expand(({ handlerIndex, result: curr }) => {\n if (handlerIndex >= groupingHandlers.length) {\n return EMPTY;\n }\n const timer = new StopWatch(undefined, true);\n const currentHandler = groupingHandlers[handlerIndex];\n return from(currentHandler(curr?.ungrouped ?? nodes, curr?.grouped ?? [])).pipe(\n log({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Grouping handler ${handlerIndex} exclusively took ${timer.elapsedSeconds.toFixed(3)} s.`,\n }),\n tap((result) => {\n onNodesGrouped?.(result, currentHandler);\n }),\n mergeMap((result) => {\n if (result.grouped.length === 0) {\n return of({ handlerIndex: handlerIndex + 1, result: { ...result, grouped: curr?.grouped ?? [] } });\n }\n const groupingPostProcessingTimer = new StopWatch(undefined, true);\n return of(result).pipe(\n map((r) => applyGroupHidingParams(r, extraSiblings)),\n map((r) => assignAutoExpand(r)),\n map((r) => ({ handlerIndex: handlerIndex + 1, result: { ...r, grouped: mergeInPlace(curr?.grouped, r.grouped) } })),\n log({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () =>\n `Post-processing grouping handler ${handlerIndex} exclusively took ${groupingPostProcessingTimer.elapsedSeconds.toFixed(3)} s.`,\n }),\n delay(0),\n );\n }),\n log({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Total time for grouping handler ${handlerIndex}: ${timer.elapsedSeconds.toFixed(3)} s.`,\n }),\n );\n }),\n last(),\n mergeMap(({ result }) => {\n result.grouped.forEach((groupingNode) => {\n onGroupingNodeCreated?.(groupingNode);\n if (!parentNode) {\n return;\n }\n if (HierarchyNode.isGroupingNode(parentNode)) {\n groupingNode.nonGroupingAncestor = parentNode.nonGroupingAncestor;\n return;\n }\n // not sure why type checker doesn't pick this up\n assert(HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));\n groupingNode.nonGroupingAncestor = parentNode;\n });\n return mergeInPlace<ProcessedGroupingHierarchyNode | ProcessedInstanceHierarchyNode>(result.grouped, result.ungrouped);\n }),\n );\n}\n\nfunction mergeInPlace<T>(target: T[] | undefined, source: T[]) {\n if (!target || target.length === 0) {\n return source;\n }\n for (const item of source) {\n target.push(item);\n }\n return target;\n}\n\nfunction createGroupingHandlers(\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector,\n parentNode: ParentHierarchyNode | undefined,\n processedInstanceNodes: ProcessedInstanceHierarchyNode[],\n valueFormatter: IPrimitiveValueFormatter,\n localizedStrings: PropertiesGroupingLocalizedStrings,\n): Observable<GroupingHandler> {\n const timer = new StopWatch();\n const groupingLevel = getNodeGroupingLevel(parentNode);\n return concat(\n groupingLevel <= GroupingLevel.Class\n ? concat(\n from(createBaseClassGroupingHandlers(imodelAccess, parentNode, processedInstanceNodes)).pipe(concatAll()),\n of<GroupingHandler>(async (allNodes) => createClassGroups(imodelAccess, parentNode, allNodes)),\n )\n : EMPTY,\n groupingLevel <= GroupingLevel.Property\n ? from(createPropertiesGroupingHandlers(imodelAccess, parentNode, processedInstanceNodes, valueFormatter, localizedStrings)).pipe(concatAll())\n : EMPTY,\n groupingLevel < GroupingLevel.Label ? of<GroupingHandler>(async (allNodes) => createLabelGroups(allNodes)) : EMPTY,\n ).pipe(\n tap({\n subscribe: () => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Start creating grouping handlers`,\n });\n timer.start();\n },\n }),\n finalize(() => {\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE_INTERNAL,\n message: /* c8 ignore next */ () => `Creating grouping handlers took ${timer.elapsedSeconds.toFixed(3)} s`,\n });\n }),\n );\n}\n\nfunction getNodeGroupingLevel(node: ParentHierarchyNode | undefined): GroupingLevel {\n if (node && HierarchyNode.isClassGroupingNode(node)) {\n return GroupingLevel.Class;\n }\n if (node && HierarchyNode.isPropertyGroupingNode(node)) {\n return GroupingLevel.Property;\n }\n if (node && HierarchyNode.isLabelGroupingNode(node)) {\n return GroupingLevel.Label;\n }\n return GroupingLevel.None;\n}\n\nenum GroupingLevel {\n None = 0,\n Class = 2,\n Property = 3,\n Label = 4,\n}\n"]}
@@ -0,0 +1,64 @@
1
+ import { Observable } from "rxjs";
2
+ import { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyDefinitionParentNode, HierarchyLevelDefinition } from "../imodel/IModelHierarchyDefinition.js";
3
+ import { ProcessedGenericHierarchyNode, ProcessedHierarchyNode, ProcessedInstanceHierarchyNode, SourceInstanceHierarchyNode } from "../imodel/IModelHierarchyNode.js";
4
+ /**
5
+ * A type for a function that parses a `SourceInstanceHierarchyNode` from provided ECSQL `row` object.
6
+ * @internal
7
+ */
8
+ export type RxjsNodeParser = (row: {
9
+ [columnName: string]: any;
10
+ }, parentNode?: HierarchyDefinitionParentNode) => Observable<SourceInstanceHierarchyNode>;
11
+ /**
12
+ * A type for a function that pre-processes given node. Unless the function decides not to make any modifications,
13
+ * it should return a new - modified - node, rather than modifying the given one. Returning `undefined` omits the node
14
+ * from the hierarchy.
15
+ *
16
+ * @internal
17
+ */
18
+ export type RxjsNodePreProcessor = <TNode extends ProcessedGenericHierarchyNode | ProcessedInstanceHierarchyNode>(node: TNode) => Observable<TNode>;
19
+ /**
20
+ * A type for a function that post-processes given node. Unless the function decides not to make any modifications,
21
+ * it should return a new - modified - node, rather than modifying the given one.
22
+ *
23
+ * @internal
24
+ */
25
+ export type RxjsNodePostProcessor = (node: ProcessedHierarchyNode) => Observable<ProcessedHierarchyNode>;
26
+ /**
27
+ * An interface for a factory that knows how define a hierarchy based on a given parent node.
28
+ * @internal
29
+ */
30
+ export interface RxjsHierarchyDefinition {
31
+ /**
32
+ * An optional function for parsing ECInstance node from ECSQL row.
33
+ *
34
+ * Should be used in situations when the `HierarchyDefinition` implementation
35
+ * introduces additional ECSQL columns into the select clause and wants to assign additional
36
+ * data to the nodes it produces.
37
+ *
38
+ * Defaults to a function that parses all `HierarchyNode` attributes from a query, whose SELECT
39
+ * clause is created using `NodeSelectQueryFactory.createSelectClause`.
40
+ */
41
+ parseNode?: RxjsNodeParser;
42
+ /**
43
+ * An optional function for pre-processing nodes.
44
+ *
45
+ * Pre-processing happens immediately after the nodes are loaded based on `HierarchyLevelDefinition`
46
+ * returned by this `HierarchyDefinition` and before their processing (hiding, grouping, sorting, etc.) starts.
47
+ * The step allows assigning nodes additional data or excluding them from the hierarchy based on some attributes.
48
+ */
49
+ preProcessNode?: RxjsNodePreProcessor;
50
+ /**
51
+ * An optional function for post-processing nodes.
52
+ *
53
+ * Post-processing happens after the loaded nodes go through all the merging, hiding and grouping
54
+ * steps, but before sorting them. This step allows `HierarchyDefinition` implementations to assign additional data
55
+ * to nodes after they're processed. This is especially true for grouping nodes as they're only created during
56
+ * processing.
57
+ */
58
+ postProcessNode?: RxjsNodePostProcessor;
59
+ /** A function to create a hierarchy level definition for given parent node. */
60
+ defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition>;
61
+ }
62
+ /** @internal */
63
+ export declare function getRxjsHierarchyDefinition(hierarchyDefinition: HierarchyDefinition): RxjsHierarchyDefinition;
64
+ //# sourceMappingURL=RxjsHierarchyDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RxjsHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/RxjsHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,UAAU,EAAM,MAAM,MAAM,CAAC;AACpD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,UAAU,CAAC,EAAE,6BAA6B,KAAK,UAAU,CAAC,2BAA2B,CAAC,CAAC;AAEzJ;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,SAAS,6BAA6B,GAAG,8BAA8B,EAAE,IAAI,EAAE,KAAK,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC;AAEpJ;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,sBAAsB,KAAK,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAEzG;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAEtC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;IAExC,+EAA+E;IAC/E,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAC;CAC9F;AAED,gBAAgB;AAChB,wBAAgB,0BAA0B,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,uBAAuB,CAc5G"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getRxjsHierarchyDefinition = getRxjsHierarchyDefinition;
8
+ const rxjs_1 = require("rxjs");
9
+ /** @internal */
10
+ function getRxjsHierarchyDefinition(hierarchyDefinition) {
11
+ return {
12
+ parseNode: hierarchyDefinition.parseNode
13
+ ? (row, parentNode) => {
14
+ const parsedNode = hierarchyDefinition.parseNode(row, parentNode);
15
+ return parsedNode instanceof Promise ? (0, rxjs_1.from)(parsedNode) : (0, rxjs_1.of)(parsedNode);
16
+ }
17
+ : undefined,
18
+ preProcessNode: hierarchyDefinition.preProcessNode
19
+ ? (node) => (0, rxjs_1.from)(hierarchyDefinition.preProcessNode(node)).pipe((0, rxjs_1.filter)((preprocessedNode) => !!preprocessedNode))
20
+ : undefined,
21
+ postProcessNode: hierarchyDefinition.postProcessNode ? (node) => (0, rxjs_1.from)(hierarchyDefinition.postProcessNode(node)) : undefined,
22
+ defineHierarchyLevel: (props) => (0, rxjs_1.from)(hierarchyDefinition.defineHierarchyLevel(props)),
23
+ };
24
+ }
25
+ //# sourceMappingURL=RxjsHierarchyDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RxjsHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/RxjsHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAgFhG,gEAcC;AA5FD,+BAAoD;AA6EpD,gBAAgB;AAChB,SAAgB,0BAA0B,CAAC,mBAAwC;IACjF,OAAO;QACL,SAAS,EAAE,mBAAmB,CAAC,SAAS;YACtC,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;gBAClB,MAAM,UAAU,GAAG,mBAAmB,CAAC,SAAU,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBACnE,OAAO,UAAU,YAAY,OAAO,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAA,SAAE,EAAC,UAAU,CAAC,CAAC;YAC3E,CAAC;YACH,CAAC,CAAC,SAAS;QACb,cAAc,EAAE,mBAAmB,CAAC,cAAc;YAChD,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,mBAAmB,CAAC,cAAe,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,aAAM,EAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;YAClH,CAAC,CAAC,SAAS;QACb,eAAe,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,mBAAmB,CAAC,eAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7H,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,mBAAmB,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;KACvF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { filter, from, Observable, of } from \"rxjs\";\nimport {\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyDefinitionParentNode,\n HierarchyLevelDefinition,\n} from \"../imodel/IModelHierarchyDefinition.js\";\nimport {\n ProcessedGenericHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n SourceInstanceHierarchyNode,\n} from \"../imodel/IModelHierarchyNode.js\";\n\n/**\n * A type for a function that parses a `SourceInstanceHierarchyNode` from provided ECSQL `row` object.\n * @internal\n */\nexport type RxjsNodeParser = (row: { [columnName: string]: any }, parentNode?: HierarchyDefinitionParentNode) => Observable<SourceInstanceHierarchyNode>;\n\n/**\n * A type for a function that pre-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one. Returning `undefined` omits the node\n * from the hierarchy.\n *\n * @internal\n */\nexport type RxjsNodePreProcessor = <TNode extends ProcessedGenericHierarchyNode | ProcessedInstanceHierarchyNode>(node: TNode) => Observable<TNode>;\n\n/**\n * A type for a function that post-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one.\n *\n * @internal\n */\nexport type RxjsNodePostProcessor = (node: ProcessedHierarchyNode) => Observable<ProcessedHierarchyNode>;\n\n/**\n * An interface for a factory that knows how define a hierarchy based on a given parent node.\n * @internal\n */\nexport interface RxjsHierarchyDefinition {\n /**\n * An optional function for parsing ECInstance node from ECSQL row.\n *\n * Should be used in situations when the `HierarchyDefinition` implementation\n * introduces additional ECSQL columns into the select clause and wants to assign additional\n * data to the nodes it produces.\n *\n * Defaults to a function that parses all `HierarchyNode` attributes from a query, whose SELECT\n * clause is created using `NodeSelectQueryFactory.createSelectClause`.\n */\n parseNode?: RxjsNodeParser;\n\n /**\n * An optional function for pre-processing nodes.\n *\n * Pre-processing happens immediately after the nodes are loaded based on `HierarchyLevelDefinition`\n * returned by this `HierarchyDefinition` and before their processing (hiding, grouping, sorting, etc.) starts.\n * The step allows assigning nodes additional data or excluding them from the hierarchy based on some attributes.\n */\n preProcessNode?: RxjsNodePreProcessor;\n\n /**\n * An optional function for post-processing nodes.\n *\n * Post-processing happens after the loaded nodes go through all the merging, hiding and grouping\n * steps, but before sorting them. This step allows `HierarchyDefinition` implementations to assign additional data\n * to nodes after they're processed. This is especially true for grouping nodes as they're only created during\n * processing.\n */\n postProcessNode?: RxjsNodePostProcessor;\n\n /** A function to create a hierarchy level definition for given parent node. */\n defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition>;\n}\n\n/** @internal */\nexport function getRxjsHierarchyDefinition(hierarchyDefinition: HierarchyDefinition): RxjsHierarchyDefinition {\n return {\n parseNode: hierarchyDefinition.parseNode\n ? (row, parentNode) => {\n const parsedNode = hierarchyDefinition.parseNode!(row, parentNode);\n return parsedNode instanceof Promise ? from(parsedNode) : of(parsedNode);\n }\n : undefined,\n preProcessNode: hierarchyDefinition.preProcessNode\n ? (node) => from(hierarchyDefinition.preProcessNode!(node)).pipe(filter((preprocessedNode) => !!preprocessedNode))\n : undefined,\n postProcessNode: hierarchyDefinition.postProcessNode ? (node) => from(hierarchyDefinition.postProcessNode!(node)) : undefined,\n defineHierarchyLevel: (props) => from(hierarchyDefinition.defineHierarchyLevel(props)),\n };\n}\n"]}
@@ -105,6 +105,6 @@ export declare function createHierarchyFilteringHelper(rootLevelFilteringProps:
105
105
  */
106
106
  createChildNodePropsAsync: (props: {
107
107
  pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
108
- }) => Promise<Pick<HierarchyNode, "filtering" | "autoExpand"> | undefined>;
108
+ }) => Promise<Pick<HierarchyNode, "filtering" | "autoExpand"> | undefined> | Pick<HierarchyNode, "filtering" | "autoExpand"> | undefined;
109
109
  };
110
110
  //# sourceMappingURL=HierarchyFiltering.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyFiltering.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,a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AAE,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS;EAgCzI"}
@@ -140,11 +140,12 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
140
140
  /**
141
141
  * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
142
142
  */
143
- createChildNodePropsAsync: async (props) => {
143
+ createChildNodePropsAsync: (props) => {
144
144
  if (!hasFilter) {
145
145
  return undefined;
146
146
  }
147
147
  const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
148
+ const matchedPathPromises = new Array();
148
149
  for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
149
150
  const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
150
151
  /* c8 ignore next 3 */
@@ -153,16 +154,20 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
153
154
  }
154
155
  const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);
155
156
  if (matchesPossiblyPromise instanceof Promise) {
156
- if (!(await matchesPossiblyPromise)) {
157
- continue;
158
- }
157
+ matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));
158
+ continue;
159
159
  }
160
160
  if (!matchesPossiblyPromise) {
161
161
  continue;
162
162
  }
163
163
  reducer.accept(normalizedPath);
164
164
  }
165
- return reducer.getNodeProps();
165
+ if (matchedPathPromises.length === 0) {
166
+ return reducer.getNodeProps();
167
+ }
168
+ return Promise.all(matchedPathPromises)
169
+ .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))
170
+ .then(() => reducer.getNodeProps());
166
171
  },
167
172
  };
168
173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,uBAAuB,EAAgC,MAAM,8BAA8B,CAAC;AACrG,OAAO,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C9D,CAAC;IACJ,CAAC;CACF","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 { HierarchyNode, NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilterTargetGroupingNodeInfo {\n /** Key of the grouping node. */\n key: GroupingNodeKey;\n\n /**\n * Depth of the grouping node in the hierarchy.\n * Generally, it can be retrieved from `parentKeys.length`.\n */\n depth: number;\n}\n\n/** @public */\nexport interface HierarchyFilteringPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.\n * - If it's an instance of `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,\n * will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilterTargetGroupingNodeInfo;\n}\n\n/**\n * A path of hierarchy node identifiers for filtering the hierarchy with additional options.\n * @public\n */\nexport type HierarchyFilteringPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchyFilteringPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyFilteringPath {\n /**\n * Normalizes the hierarchy filtering path to the object form.\n * @public\n */\n export function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchyFilteringPathOptions` objects.\n * - if both inputs are `undefined`, `undefined` is returned,\n * - else if one of the inputs is `undefined`, the other one is returned.\n * - else, merge each option individually.\n *\n * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if both inputs are objects, return the one with the greater `depth` attribute.\n * - else if one input is an object, return it.\n * - else, return `false` or `undefined`.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchyFilteringPathOptions | undefined,\n rhs: HierarchyFilteringPathOptions | undefined,\n ): HierarchyFilteringPathOptions | undefined {\n if (!lhs || !rhs) {\n return lhs ?? rhs;\n }\n\n return {\n autoExpand: ((): HierarchyFilteringPathOptions[\"autoExpand\"] => {\n if (rhs.autoExpand === true || lhs.autoExpand === true) {\n return true;\n }\n if (typeof lhs.autoExpand === \"object\") {\n if (typeof rhs.autoExpand === \"object\" && rhs.autoExpand.depth > lhs.autoExpand.depth) {\n return rhs.autoExpand;\n }\n return lhs.autoExpand;\n }\n return rhs.autoExpand;\n })(),\n };\n }\n}\n\n/**\n * An utility that extracts filtering properties from given root level filtering props or\n * the parent node. Returns `undefined` if filtering props are not present.\n * @public\n * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.\n */\n/* c8 ignore start */\nexport function extractFilteringProps(\n rootLevelFilteringProps: HierarchyFilteringPath[],\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n}\n/* c8 ignore end */\n\nfunction extractFilteringPropsInternal(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;\n }\n return parentNode.filtering?.filteredChildrenIdentifierPaths\n ? {\n filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths,\n hasFilterTargetAncestor: !!parentNode.filtering.hasFilterTargetAncestor || !!parentNode.filtering.isFilterTarget,\n }\n : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to filter the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchyFilteringHelper(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n) {\n const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n const hasFilter = !!filteringProps;\n return {\n /**\n * Returns a flag indicating if the hierarchy level is filtered.\n */\n hasFilter,\n\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a filter target. That generally means that this and all downstream hierarchy\n * levels should be displayed without filter being applied to them, even if filter paths\n * say otherwise.\n */\n hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,\n\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if filtering is not applied to this level.\n */\n getChildNodeFilteringIdentifiers: () => {\n if (!hasFilter) {\n return undefined;\n }\n return filteringProps.filteredNodePaths\n .map(HierarchyFilteringPath.normalize)\n .filter(({ path }) => path.length > 0)\n .map(({ path }) => path[0]);\n },\n\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`\n * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies\n * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the\n * `nodeKey` prop can be used to check the whole identifier.\n */\n createChildNodeProps: (\n props:\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n },\n ): Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n filteringProps.filteredNodePaths.forEach((filteredPath) => {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);\n if (\n \"nodeKey\" in props &&\n ((HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||\n (HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))\n ) {\n reducer.accept(normalizedPath);\n } else if (\"pathMatcher\" in props && props.pathMatcher(normalizedPath.path[0])) {\n reducer.accept(normalizedPath);\n }\n });\n return reducer.getNodeProps();\n },\n\n /**\n * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.\n */\n createChildNodePropsAsync: async (props: {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | undefined> => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);\n /* c8 ignore next 3 */\n if (normalizedPath.path.length === 0) {\n continue;\n }\n\n const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);\n if (matchesPossiblyPromise instanceof Promise) {\n if (!(await matchesPossiblyPromise)) {\n continue;\n }\n }\n if (!matchesPossiblyPromise) {\n continue;\n }\n\n reducer.accept(normalizedPath);\n }\n return reducer.getNodeProps();\n },\n };\n}\n\ntype NormalizedFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\nclass MatchingFilteringPathsReducer {\n private _filteredChildrenIdentifierPaths = new Array<NormalizedFilteringPath>();\n private _isFilterTarget = false;\n private _filterTargetOptions = undefined as HierarchyFilteringPathOptions | undefined;\n private _needsAutoExpand = false;\n\n public constructor(private _hasFilterTargetAncestor: boolean) {}\n\n public accept({ path, options }: NormalizedFilteringPath) {\n if (path.length === 1) {\n this._isFilterTarget = true;\n this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);\n } else if (path.length > 1) {\n this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });\n if (options?.autoExpand) {\n this._needsAutoExpand = true;\n }\n }\n }\n public getNodeProps(): Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> {\n return {\n ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0\n ? {\n filtering: {\n ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),\n ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),\n ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),\n },\n }\n : undefined),\n ...(this._needsAutoExpand ? { autoExpand: true } : undefined),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,uBAAuB,EAAgC,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAmC,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AA+B5G,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,sBAAsB,CAiDtC;AAjDD,WAAiB,sBAAsB;IACrC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAA8B;QACtD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAL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S,CAAC;qBAC/I;iBACF;gBACH,CAAC,CAAC,SAAS,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC9D,CAAC;IACJ,CAAC;CACF","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 { HierarchyNode, NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilterTargetGroupingNodeInfo {\n /** Key of the grouping node. */\n key: GroupingNodeKey;\n\n /**\n * Depth of the grouping node in the hierarchy.\n * Generally, it can be retrieved from `parentKeys.length`.\n */\n depth: number;\n}\n\n/** @public */\nexport interface HierarchyFilteringPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.\n * - If it's an instance of `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,\n * will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilterTargetGroupingNodeInfo;\n}\n\n/**\n * A path of hierarchy node identifiers for filtering the hierarchy with additional options.\n * @public\n */\nexport type HierarchyFilteringPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchyFilteringPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyFilteringPath {\n /**\n * Normalizes the hierarchy filtering path to the object form.\n * @public\n */\n export function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchyFilteringPathOptions` objects.\n * - if both inputs are `undefined`, `undefined` is returned,\n * - else if one of the inputs is `undefined`, the other one is returned.\n * - else, merge each option individually.\n *\n * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if both inputs are objects, return the one with the greater `depth` attribute.\n * - else if one input is an object, return it.\n * - else, return `false` or `undefined`.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchyFilteringPathOptions | undefined,\n rhs: HierarchyFilteringPathOptions | undefined,\n ): HierarchyFilteringPathOptions | undefined {\n if (!lhs || !rhs) {\n return lhs ?? rhs;\n }\n\n return {\n autoExpand: ((): HierarchyFilteringPathOptions[\"autoExpand\"] => {\n if (rhs.autoExpand === true || lhs.autoExpand === true) {\n return true;\n }\n if (typeof lhs.autoExpand === \"object\") {\n if (typeof rhs.autoExpand === \"object\" && rhs.autoExpand.depth > lhs.autoExpand.depth) {\n return rhs.autoExpand;\n }\n return lhs.autoExpand;\n }\n return rhs.autoExpand;\n })(),\n };\n }\n}\n\n/**\n * An utility that extracts filtering properties from given root level filtering props or\n * the parent node. Returns `undefined` if filtering props are not present.\n * @public\n * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.\n */\n/* c8 ignore start */\nexport function extractFilteringProps(\n rootLevelFilteringProps: HierarchyFilteringPath[],\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n}\n/* c8 ignore end */\n\nfunction extractFilteringPropsInternal(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;\n }\n return parentNode.filtering?.filteredChildrenIdentifierPaths\n ? {\n filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths,\n hasFilterTargetAncestor: !!parentNode.filtering.hasFilterTargetAncestor || !!parentNode.filtering.isFilterTarget,\n }\n : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to filter the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchyFilteringHelper(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n) {\n const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n const hasFilter = !!filteringProps;\n return {\n /**\n * Returns a flag indicating if the hierarchy level is filtered.\n */\n hasFilter,\n\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a filter target. That generally means that this and all downstream hierarchy\n * levels should be displayed without filter being applied to them, even if filter paths\n * say otherwise.\n */\n hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,\n\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if filtering is not applied to this level.\n */\n getChildNodeFilteringIdentifiers: () => {\n if (!hasFilter) {\n return undefined;\n }\n return filteringProps.filteredNodePaths\n .map(HierarchyFilteringPath.normalize)\n .filter(({ path }) => path.length > 0)\n .map(({ path }) => path[0]);\n },\n\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`\n * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies\n * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the\n * `nodeKey` prop can be used to check the whole identifier.\n */\n createChildNodeProps: (\n props:\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n },\n ): Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n filteringProps.filteredNodePaths.forEach((filteredPath) => {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);\n if (\n \"nodeKey\" in props &&\n ((HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||\n (HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))\n ) {\n reducer.accept(normalizedPath);\n } else if (\"pathMatcher\" in props && props.pathMatcher(normalizedPath.path[0])) {\n reducer.accept(normalizedPath);\n }\n });\n return reducer.getNodeProps();\n },\n\n /**\n * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.\n */\n createChildNodePropsAsync: (props: {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | undefined> | Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n const matchedPathPromises = new Array<Promise<NormalizedFilteringPath | undefined>>();\n for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);\n /* c8 ignore next 3 */\n if (normalizedPath.path.length === 0) {\n continue;\n }\n\n const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));\n continue;\n }\n if (!matchesPossiblyPromise) {\n continue;\n }\n\n reducer.accept(normalizedPath);\n }\n if (matchedPathPromises.length === 0) {\n return reducer.getNodeProps();\n }\n return Promise.all(matchedPathPromises)\n .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))\n .then(() => reducer.getNodeProps());\n },\n };\n}\n\ntype NormalizedFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\n\nclass MatchingFilteringPathsReducer {\n private _filteredChildrenIdentifierPaths = new Array<NormalizedFilteringPath>();\n private _isFilterTarget = false;\n private _filterTargetOptions = undefined as HierarchyFilteringPathOptions | undefined;\n private _needsAutoExpand = false;\n\n public constructor(private _hasFilterTargetAncestor: boolean) {}\n\n public accept({ path, options }: NormalizedFilteringPath) {\n if (path.length === 1) {\n this._isFilterTarget = true;\n this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);\n } else if (path.length > 1) {\n this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });\n if (options?.autoExpand) {\n this._needsAutoExpand = true;\n }\n }\n }\n public getNodeProps(): Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> {\n return {\n ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0\n ? {\n filtering: {\n ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),\n ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),\n ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),\n },\n }\n : undefined),\n ...(this._needsAutoExpand ? { autoExpand: true } : undefined),\n };\n }\n}\n"]}
@@ -1,24 +1,28 @@
1
+ import { Observable } from "rxjs";
1
2
  import { ECClassHierarchyInspector, InstanceKey } from "@itwin/presentation-shared";
2
3
  import { HierarchyFilteringPath } from "../HierarchyFiltering.js";
3
- import { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, InstanceNodesQueryDefinition, NodeParser, NodePostProcessor, NodePreProcessor } from "./IModelHierarchyDefinition.js";
4
+ import { DefineHierarchyLevelProps, HierarchyLevelDefinition, InstanceNodesQueryDefinition } from "../imodel/IModelHierarchyDefinition.js";
5
+ import { RxjsHierarchyDefinition, RxjsNodeParser, RxjsNodePostProcessor, RxjsNodePreProcessor } from "../internal/RxjsHierarchyDefinition.js";
4
6
  interface FilteringHierarchyDefinitionProps {
5
7
  imodelAccess: ECClassHierarchyInspector & {
6
8
  imodelKey: string;
7
9
  };
8
- source: HierarchyDefinition;
10
+ source: RxjsHierarchyDefinition;
9
11
  nodeIdentifierPaths: HierarchyFilteringPath[];
12
+ nodesParser?: RxjsNodeParser;
10
13
  }
11
14
  /** @internal */
12
- export declare class FilteringHierarchyDefinition implements HierarchyDefinition {
15
+ export declare class FilteringHierarchyDefinition implements RxjsHierarchyDefinition {
13
16
  private _imodelAccess;
14
17
  private _source;
15
18
  private _nodeIdentifierPaths;
19
+ private _nodesParser;
16
20
  constructor(props: FilteringHierarchyDefinitionProps);
17
- get preProcessNode(): NodePreProcessor;
21
+ get preProcessNode(): RxjsNodePreProcessor;
18
22
  private shouldExpandGroupingNode;
19
- get postProcessNode(): NodePostProcessor;
20
- get parseNode(): NodeParser;
21
- defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
23
+ get postProcessNode(): RxjsNodePostProcessor;
24
+ get parseNode(): RxjsNodeParser;
25
+ defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition>;
22
26
  }
23
27
  /** @internal */
24
28
  export declare const ECSQL_COLUMN_NAME_FilterECInstanceId = "FilterECInstanceId";
@@ -1 +1 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/Fil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4BAA4B,EAAE,oBAAoB,EAAE,WAAW,EAAE,GAAG,4BAA4B,CAgC7I;AAED,gBAAgB;AAChB,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,4BAA4B,GAAG,4BAA4B,CAc1G"}
@@ -2,32 +2,35 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { defer, filter, firstValueFrom, map, merge, mergeMap, of, toArray } from "rxjs";
5
+ import { defer, filter, from, map, merge, mergeAll, mergeMap, of, toArray } from "rxjs";
6
6
  import { createHierarchyFilteringHelper } from "../HierarchyFiltering.js";
7
7
  import { HierarchyNodeIdentifier } from "../HierarchyNodeIdentifier.js";
8
+ import { HierarchyNodesDefinition, } from "../imodel/IModelHierarchyDefinition.js";
9
+ import { ProcessedHierarchyNode } from "../imodel/IModelHierarchyNode.js";
10
+ import { NodeSelectClauseColumnNames } from "../imodel/NodeSelectQueryFactory.js";
11
+ import { defaultNodesParser } from "../imodel/TreeNodesReader.js";
8
12
  import { partition } from "../internal/operators/Partition.js";
9
- import { HierarchyNodesDefinition, } from "./IModelHierarchyDefinition.js";
10
- import { ProcessedHierarchyNode } from "./IModelHierarchyNode.js";
11
- import { NodeSelectClauseColumnNames } from "./NodeSelectQueryFactory.js";
12
- import { defaultNodesParser } from "./TreeNodesReader.js";
13
13
  /** @internal */
14
14
  export class FilteringHierarchyDefinition {
15
15
  _imodelAccess;
16
16
  _source;
17
17
  _nodeIdentifierPaths;
18
+ _nodesParser;
18
19
  constructor(props) {
19
20
  this._imodelAccess = props.imodelAccess;
20
21
  this._source = props.source;
21
22
  this._nodeIdentifierPaths = props.nodeIdentifierPaths;
23
+ this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => of(defaultNodesParser(row)));
22
24
  }
23
25
  get preProcessNode() {
24
- return async (node) => {
25
- const processedNode = this._source.preProcessNode ? await this._source.preProcessNode(node) : node;
26
- if (processedNode?.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {
27
- // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target
28
- return undefined;
29
- }
30
- return processedNode;
26
+ return (node) => {
27
+ return (this._source.preProcessNode ? this._source.preProcessNode(node) : of(node)).pipe(filter((processedNode) => {
28
+ if (processedNode.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {
29
+ // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target
30
+ return false;
31
+ }
32
+ return true;
33
+ }));
31
34
  };
32
35
  }
33
36
  shouldExpandGroupingNode(node) {
@@ -67,62 +70,65 @@ export class FilteringHierarchyDefinition {
67
70
  return false;
68
71
  }
69
72
  get postProcessNode() {
70
- return async (node) => {
71
- const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;
72
- // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing
73
- if (ProcessedHierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {
74
- Object.assign(processedNode, { autoExpand: true });
75
- }
76
- return processedNode;
73
+ return (node) => {
74
+ return (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(map((processedNode) => {
75
+ // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing
76
+ if (ProcessedHierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {
77
+ Object.assign(processedNode, { autoExpand: true });
78
+ }
79
+ return processedNode;
80
+ }));
77
81
  };
78
82
  }
79
83
  get parseNode() {
80
- return async (row, parentNode) => {
81
- const parsedNode = await (this._source.parseNode ?? defaultNodesParser)(row);
82
- const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, parentNode);
83
- const nodeExtraProps = row[ECSQL_COLUMN_NAME_FilterECInstanceId] && row[ECSQL_COLUMN_NAME_FilterClassName]
84
- ? await (async () => {
85
- const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_FilterClassName], id: row[ECSQL_COLUMN_NAME_FilterECInstanceId] };
86
- return filteringHelper.createChildNodePropsAsync({
87
- pathMatcher: (identifier) => {
88
- if (identifier.id !== rowInstanceKey.id) {
89
- return false;
90
- }
91
- if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {
92
- return false;
93
- }
94
- if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {
95
- return false;
96
- }
97
- if (identifier.className === rowInstanceKey.className) {
98
- return true;
99
- }
100
- return Promise.all([
101
- this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className),
102
- this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className),
103
- ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo);
104
- },
105
- });
106
- })()
107
- : undefined;
108
- if (nodeExtraProps?.autoExpand) {
109
- parsedNode.autoExpand = true;
110
- }
111
- if (nodeExtraProps?.filtering) {
112
- parsedNode.filtering = nodeExtraProps.filtering;
113
- }
114
- return parsedNode;
84
+ return (row, parentNode) => {
85
+ return this._nodesParser(row).pipe(mergeMap((parsedNode) => {
86
+ if (!row[ECSQL_COLUMN_NAME_FilterECInstanceId] || !row[ECSQL_COLUMN_NAME_FilterClassName]) {
87
+ return of(parsedNode);
88
+ }
89
+ const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_FilterClassName], id: row[ECSQL_COLUMN_NAME_FilterECInstanceId] };
90
+ const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, parentNode);
91
+ const nodeExtraPropsPossiblyPromise = filteringHelper.createChildNodePropsAsync({
92
+ pathMatcher: (identifier) => {
93
+ if (identifier.id !== rowInstanceKey.id) {
94
+ return false;
95
+ }
96
+ if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {
97
+ return false;
98
+ }
99
+ if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {
100
+ return false;
101
+ }
102
+ if (identifier.className === rowInstanceKey.className) {
103
+ return true;
104
+ }
105
+ return Promise.all([
106
+ this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className),
107
+ this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className),
108
+ ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo);
109
+ },
110
+ });
111
+ return (nodeExtraPropsPossiblyPromise instanceof Promise ? from(nodeExtraPropsPossiblyPromise) : of(nodeExtraPropsPossiblyPromise)).pipe(map((nodeExtraProps) => {
112
+ if (nodeExtraProps?.autoExpand) {
113
+ parsedNode.autoExpand = true;
114
+ }
115
+ if (nodeExtraProps?.filtering) {
116
+ parsedNode.filtering = nodeExtraProps.filtering;
117
+ }
118
+ return parsedNode;
119
+ }));
120
+ }));
115
121
  };
116
122
  }
117
- async defineHierarchyLevel(props) {
118
- const sourceDefinitions = await this._source.defineHierarchyLevel(props);
123
+ defineHierarchyLevel(props) {
124
+ const sourceDefinitions = this._source.defineHierarchyLevel(props);
119
125
  const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, props.parentNode);
120
126
  const childNodeFilteringIdentifiers = filteringHelper.getChildNodeFilteringIdentifiers();
121
127
  if (!childNodeFilteringIdentifiers) {
122
128
  return sourceDefinitions;
123
129
  }
124
- const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions, HierarchyNodesDefinition.isGenericNode);
125
- return firstValueFrom(merge(genericNodeDefinitions.pipe(map((definition) => {
130
+ const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions.pipe(mergeAll()), HierarchyNodesDefinition.isGenericNode);
131
+ return merge(genericNodeDefinitions.pipe(map((definition) => {
126
132
  if (filteringHelper.hasFilterTargetAncestor ||
127
133
  childNodeFilteringIdentifiers.some((identifier) => HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&
128
134
  (!identifier.source || identifier.source === this._imodelAccess.imodelKey) &&
@@ -190,7 +196,7 @@ export class FilteringHierarchyDefinition {
190
196
  filter((pathIdentifiers) => pathIdentifiers.length > 0),
191
197
  // for each definition that we're going to use, apply query-level filter
192
198
  map((pathIdentifiers) => applyECInstanceIdsFilter(definition, pathIdentifiers)));
193
- }))).pipe(toArray()));
199
+ }))).pipe(toArray());
194
200
  }
195
201
  }
196
202
  /** @internal */