@itwin/presentation-hierarchies 0.3.0 → 0.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.
- package/CHANGELOG.md +69 -0
- package/README.md +27 -6
- package/lib/cjs/hierarchies/HierarchyDefinition.js +2 -2
- package/lib/cjs/hierarchies/HierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +17 -7
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +31 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js +33 -19
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.d.ts.map +1 -1
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.js +33 -13
- package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/cjs/hierarchies/Logging.js +2 -3
- package/lib/cjs/hierarchies/Logging.js.map +1 -1
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts +14 -2
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.js +7 -7
- package/lib/cjs/hierarchies/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.js +3 -3
- package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.js.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.d.ts +25 -5
- package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.js +41 -21
- package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
- package/lib/cjs/hierarchies/internal/EachValueFrom.js +1 -2
- package/lib/cjs/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts +17 -6
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js +118 -32
- package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/internal/LoggingUtils.d.ts +1 -3
- package/lib/cjs/hierarchies/internal/LoggingUtils.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/LoggingUtils.js +2 -21
- package/lib/cjs/hierarchies/internal/LoggingUtils.js.map +1 -1
- package/lib/cjs/hierarchies/internal/TreeNodesReader.js +2 -3
- package/lib/cjs/hierarchies/internal/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.js +3 -3
- package/lib/cjs/hierarchies/internal/operators/DetermineChildren.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Grouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Grouping.js +13 -12
- package/lib/cjs/hierarchies/internal/operators/Grouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.js +3 -3
- package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.js +3 -3
- package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Partition.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/Partition.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js +2 -3
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/ReleaseMainThread.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ShareReplayWithErrors.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/ShareReplayWithErrors.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/TapOnce.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/TapOnce.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.js +3 -4
- package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.js +7 -8
- package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/grouping/Shared.js +1 -2
- package/lib/cjs/hierarchies/internal/operators/grouping/Shared.js.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.d.ts +17 -7
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +31 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js +34 -19
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.d.ts.map +1 -1
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.js +35 -14
- package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.js.map +1 -1
- package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts +14 -2
- package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/NodeSelectQueryFactory.js +5 -5
- package/lib/esm/hierarchies/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.js +3 -3
- package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.js.map +1 -1
- package/lib/esm/hierarchies/internal/Common.d.ts +25 -5
- package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/Common.js +35 -15
- package/lib/esm/hierarchies/internal/Common.js.map +1 -1
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts +17 -6
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js +116 -30
- package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/internal/LoggingUtils.d.ts +1 -3
- package/lib/esm/hierarchies/internal/LoggingUtils.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/LoggingUtils.js +0 -17
- package/lib/esm/hierarchies/internal/LoggingUtils.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.js +2 -2
- package/lib/esm/hierarchies/internal/operators/DetermineChildren.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Grouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Grouping.js +11 -10
- package/lib/esm/hierarchies/internal/operators/Grouping.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.js +2 -2
- package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.js +2 -2
- package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReleaseMainThread.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.js +2 -2
- package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +1 -1
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +1 -1
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +15 -15
|
@@ -5,8 +5,42 @@
|
|
|
5
5
|
import naturalCompare from "natural-compare-lite";
|
|
6
6
|
import { assert } from "@itwin/core-bentley";
|
|
7
7
|
import { HierarchyNodeKey } from "../HierarchyNodeKey";
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* This is a logging namespace for public log messages that may be interesting to consumers.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
9
12
|
export const LOGGING_NAMESPACE = "Presentation.Hierarchies";
|
|
13
|
+
/**
|
|
14
|
+
* This is a logging namespace for public performance-related log messages that may be interesting to consumers.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export const LOGGING_NAMESPACE_PERFORMANCE = `${LOGGING_NAMESPACE}.Performance`;
|
|
18
|
+
/**
|
|
19
|
+
* This is a logging namespace for internal log messages that are only interesting to package contributors,
|
|
20
|
+
* but not the consumers.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export const LOGGING_NAMESPACE_INTERNAL = "Presentation.HierarchiesInternal";
|
|
24
|
+
/**
|
|
25
|
+
* This is a logging namespace for internal performance-related log messages that are only interesting
|
|
26
|
+
* to package contributors, but not the consumers.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export const LOGGING_NAMESPACE_PERFORMANCE_INTERNAL = `${LOGGING_NAMESPACE_INTERNAL}.Performance`;
|
|
30
|
+
/** @internal */
|
|
31
|
+
export function createOperatorLoggingNamespace(operatorName, baseCategory = LOGGING_NAMESPACE) {
|
|
32
|
+
return `${baseCategory}.Operators.${operatorName}`;
|
|
33
|
+
}
|
|
34
|
+
/** @internal */
|
|
35
|
+
// istanbul ignore next
|
|
36
|
+
export function createNodeIdentifierForLogging(node) {
|
|
37
|
+
if (!node) {
|
|
38
|
+
return "<root>";
|
|
39
|
+
}
|
|
40
|
+
const { label, key } = node;
|
|
41
|
+
const parentKeys = "parentKeys" in node ? node.parentKeys : "<unknown>";
|
|
42
|
+
return JSON.stringify({ label, key, parentKeys });
|
|
43
|
+
}
|
|
10
44
|
function mergeNodeHandlingParams(lhs, rhs) {
|
|
11
45
|
if (!lhs && !rhs) {
|
|
12
46
|
return undefined;
|
|
@@ -75,21 +109,7 @@ export function hasChildren(node) {
|
|
|
75
109
|
return node.children === true || (Array.isArray(node.children) && node.children.length > 0);
|
|
76
110
|
}
|
|
77
111
|
/** @internal */
|
|
78
|
-
export function createOperatorLoggingNamespace(operatorName) {
|
|
79
|
-
return `${LOGGING_NAMESPACE}.Operators.${operatorName}`;
|
|
80
|
-
}
|
|
81
|
-
/** @internal */
|
|
82
112
|
export function compareNodesByLabel(lhs, rhs) {
|
|
83
113
|
return naturalCompare(lhs.label.toLocaleLowerCase(), rhs.label.toLocaleLowerCase());
|
|
84
114
|
}
|
|
85
|
-
/** @internal */
|
|
86
|
-
// istanbul ignore next
|
|
87
|
-
export function createNodeIdentifierForLogging(node) {
|
|
88
|
-
if (!node) {
|
|
89
|
-
return "<root>";
|
|
90
|
-
}
|
|
91
|
-
const { label, key } = node;
|
|
92
|
-
const parentKeys = "parentKeys" in node ? node.parentKeys : "<unknown>";
|
|
93
|
-
return JSON.stringify({ label, key, parentKeys });
|
|
94
|
-
}
|
|
95
115
|
//# sourceMappingURL=Common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/Common.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,OAAO,EAAE,gBAAgB,EAAoB,MAAM,qBAAqB,CAAC;AAEzE,gBAAgB;AAChB,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAE5D,SAAS,uBAAuB,CAC9B,GAAsD,EACtD,GAAsD;IAEtD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG;QACb,GAAG,CAAC,GAAG,EAAE,gBAAgB,IAAI,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB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,CAAwD,IAAW;IAC5F,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,8BAA8B,CAAC,YAAoB;IACjE,OAAO,GAAG,iBAAiB,cAAc,YAAY,EAAE,CAAC;AAC1D,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,mBAAmB,CAAyE,GAAa,EAAE,GAAa;IACtI,OAAO,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACtF,CAAC;AAED,gBAAgB;AAChB,uBAAuB;AACvB,MAAM,UAAU,8BAA8B,CAAC,IAA2E;IACxH,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5B,MAAM,UAAU,GAAG,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;IACxE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;AACpD,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 naturalCompare from \"natural-compare-lite\";\nimport { assert } from \"@itwin/core-bentley\";\nimport {\n HierarchyNode,\n HierarchyNodeLabelGroupingParams,\n InstanceHierarchyNodeProcessingParams,\n ParentHierarchyNode,\n ParsedHierarchyNode,\n ProcessedCustomHierarchyNode,\n ProcessedInstanceHierarchyNode,\n} from \"../HierarchyNode\";\nimport { HierarchyNodeKey, InstancesNodeKey } from \"../HierarchyNodeKey\";\n\n/** @internal */\nexport const LOGGING_NAMESPACE = \"Presentation.Hierarchies\";\n\nfunction mergeNodeHandlingParams(\n lhs: InstanceHierarchyNodeProcessingParams | undefined,\n rhs: InstanceHierarchyNodeProcessingParams | undefined,\n): InstanceHierarchyNodeProcessingParams | undefined {\n if (!lhs && !rhs) {\n return undefined;\n }\n const params = {\n ...(lhs?.hideIfNoChildren || rhs?.hideIfNoChildren ? { hideIfNoChildren: true } : undefined),\n ...(lhs?.hideInHierarchy || rhs?.hideInHierarchy ? { hideInHierarchy: true } : undefined),\n ...mergeByLabelParams(lhs?.grouping?.byLabel, rhs?.grouping?.byLabel),\n };\n return Object.keys(params).length > 0 ? params : undefined;\n}\n\nfunction mergeByLabelParams(\n lhs: HierarchyNodeLabelGroupingParams | undefined,\n rhs: HierarchyNodeLabelGroupingParams | undefined,\n): InstanceHierarchyNodeProcessingParams | undefined {\n if (lhs && typeof lhs === \"object\" && lhs.action === \"merge\" && rhs && typeof rhs === \"object\" && rhs.action === \"merge\" && lhs.groupId === rhs.groupId) {\n return {\n grouping: { byLabel: lhs },\n };\n }\n return undefined;\n}\n\nfunction mergeNodeKeys<TKey extends string | InstancesNodeKey>(lhs: TKey, rhs: TKey): TKey {\n if (HierarchyNodeKey.isCustom(lhs)) {\n assert(HierarchyNodeKey.isCustom(rhs));\n return lhs === rhs ? lhs : (`${lhs}+${rhs}` as TKey);\n }\n // istanbul ignore else\n if (HierarchyNodeKey.isInstances(lhs)) {\n assert(HierarchyNodeKey.isInstances(rhs));\n return { type: \"instances\", instanceKeys: [...lhs.instanceKeys, ...rhs.instanceKeys] } as TKey;\n }\n // https://github.com/microsoft/TypeScript/issues/21985\n // istanbul ignore next\n return ((x: never) => x)(lhs);\n}\n\nfunction mergeParentNodeKeys(lhsKeys: HierarchyNodeKey[], rhsKeys: HierarchyNodeKey[]): HierarchyNodeKey[] {\n const res = new Array<HierarchyNodeKey>();\n for (let i = 0; i < lhsKeys.length && i < rhsKeys.length; ++i) {\n if (!HierarchyNodeKey.equals(lhsKeys[i], rhsKeys[i])) {\n break;\n }\n res.push(lhsKeys[i]);\n }\n return res;\n}\n\n/** @internal */\nexport function mergeNodes<TNode extends ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode>(lhs: TNode, rhs: TNode): TNode {\n assert(typeof lhs.key === typeof rhs.key);\n const mergedProcessingParams = mergeNodeHandlingParams(lhs.processingParams, rhs.processingParams);\n const mergedChildren = lhs.children === true || rhs.children === true ? true : lhs.children === false && rhs.children === false ? false : undefined;\n const mergedNode = {\n ...lhs,\n ...rhs,\n label: lhs.label,\n key: mergeNodeKeys(lhs.key, rhs.key),\n parentKeys: mergeParentNodeKeys(lhs.parentKeys, rhs.parentKeys),\n } as TNode;\n // Remove specific properties or change their values based on lhs and rhs nodes\n mergedChildren !== undefined ? (mergedNode.children = mergedChildren) : delete mergedNode.children;\n mergedProcessingParams ? (mergedNode.processingParams = mergedProcessingParams) : delete mergedNode.processingParams;\n lhs.autoExpand || rhs.autoExpand ? (mergedNode.autoExpand = true) : delete mergedNode.autoExpand;\n lhs.extendedData || rhs.extendedData ? (mergedNode.extendedData = { ...lhs.extendedData, ...rhs.extendedData }) : delete mergedNode.extendedData;\n lhs.supportsFiltering && rhs.supportsFiltering ? (mergedNode.supportsFiltering = true) : delete mergedNode.supportsFiltering;\n return mergedNode;\n}\n\n/** @internal */\nexport function hasChildren<TNode extends { children?: boolean | Array<unknown> }>(node: TNode) {\n return node.children === true || (Array.isArray(node.children) && node.children.length > 0);\n}\n\n/** @internal */\nexport function createOperatorLoggingNamespace(operatorName: string) {\n return `${LOGGING_NAMESPACE}.Operators.${operatorName}`;\n}\n\n/** @internal */\nexport function compareNodesByLabel<TLhsNode extends { label: string }, TRhsNode extends { label: string }>(lhs: TLhsNode, rhs: TRhsNode): number {\n return naturalCompare(lhs.label.toLocaleLowerCase(), rhs.label.toLocaleLowerCase());\n}\n\n/** @internal */\n// istanbul ignore next\nexport function createNodeIdentifierForLogging(node: ParentHierarchyNode | HierarchyNode | ParsedHierarchyNode | undefined) {\n if (!node) {\n return \"<root>\";\n }\n const { label, key } = node;\n const parentKeys = \"parentKeys\" in node ? node.parentKeys : \"<unknown>\";\n return JSON.stringify({ label, key, parentKeys });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/Common.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,OAAO,EAAE,gBAAgB,EAAoB,MAAM,qBAAqB,CAAC;AAEzE;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,iBAAiB,cAAc,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,kCAAkC,CAAC;AAE7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,0BAA0B,cAAc,CAAC;AAElG,gBAAgB;AAChB,MAAM,UAAU,8BAA8B,CAC5C,YAAoB,EACpB,eAIoD,iBAAiB;IAErE,OAAO,GAAG,YAAY,cAAc,YAAY,EAAE,CAAC;AACrD,CAAC;AAED,gBAAgB;AAChB,uBAAuB;AACvB,MAAM,UAAU,8BAA8B,CAAC,IAA2E;IACxH,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5B,MAAM,UAAU,GAAG,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;I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E,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,YAAY,CAAC;IACjJ,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,iBAAiB,CAAC;IAC7H,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,WAAW,CAAwD,IAAW;IAC5F,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,mBAAmB,CAAyE,GAAa,EAAE,GAAa;IACtI,OAAO,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACtF,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 naturalCompare from \"natural-compare-lite\";\nimport { assert } from \"@itwin/core-bentley\";\nimport {\n HierarchyNode,\n HierarchyNodeLabelGroupingParams,\n InstanceHierarchyNodeProcessingParams,\n ParentHierarchyNode,\n ParsedHierarchyNode,\n ProcessedCustomHierarchyNode,\n ProcessedInstanceHierarchyNode,\n} from \"../HierarchyNode\";\nimport { HierarchyNodeKey, InstancesNodeKey } from \"../HierarchyNodeKey\";\n\n/**\n * This is a logging namespace for public log messages that may be interesting to consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE = \"Presentation.Hierarchies\";\n\n/**\n * This is a logging namespace for public performance-related log messages that may be interesting to consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE_PERFORMANCE = `${LOGGING_NAMESPACE}.Performance`;\n\n/**\n * This is a logging namespace for internal log messages that are only interesting to package contributors,\n * but not the consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE_INTERNAL = \"Presentation.HierarchiesInternal\";\n\n/**\n * This is a logging namespace for internal performance-related log messages that are only interesting\n * to package contributors, but not the consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE_PERFORMANCE_INTERNAL = `${LOGGING_NAMESPACE_INTERNAL}.Performance`;\n\n/** @internal */\nexport function createOperatorLoggingNamespace(\n operatorName: string,\n baseCategory:\n | typeof LOGGING_NAMESPACE\n | typeof LOGGING_NAMESPACE_PERFORMANCE\n | typeof LOGGING_NAMESPACE_INTERNAL\n | typeof LOGGING_NAMESPACE_PERFORMANCE_INTERNAL = LOGGING_NAMESPACE,\n) {\n return `${baseCategory}.Operators.${operatorName}`;\n}\n\n/** @internal */\n// istanbul ignore next\nexport function createNodeIdentifierForLogging(node: ParentHierarchyNode | HierarchyNode | ParsedHierarchyNode | undefined) {\n if (!node) {\n return \"<root>\";\n }\n const { label, key } = node;\n const parentKeys = \"parentKeys\" in node ? node.parentKeys : \"<unknown>\";\n return JSON.stringify({ label, key, parentKeys });\n}\n\nfunction mergeNodeHandlingParams(\n lhs: InstanceHierarchyNodeProcessingParams | undefined,\n rhs: InstanceHierarchyNodeProcessingParams | undefined,\n): InstanceHierarchyNodeProcessingParams | undefined {\n if (!lhs && !rhs) {\n return undefined;\n }\n const params = {\n ...(lhs?.hideIfNoChildren || rhs?.hideIfNoChildren ? { hideIfNoChildren: true } : undefined),\n ...(lhs?.hideInHierarchy || rhs?.hideInHierarchy ? { hideInHierarchy: true } : undefined),\n ...mergeByLabelParams(lhs?.grouping?.byLabel, rhs?.grouping?.byLabel),\n };\n return Object.keys(params).length > 0 ? params : undefined;\n}\n\nfunction mergeByLabelParams(\n lhs: HierarchyNodeLabelGroupingParams | undefined,\n rhs: HierarchyNodeLabelGroupingParams | undefined,\n): InstanceHierarchyNodeProcessingParams | undefined {\n if (lhs && typeof lhs === \"object\" && lhs.action === \"merge\" && rhs && typeof rhs === \"object\" && rhs.action === \"merge\" && lhs.groupId === rhs.groupId) {\n return {\n grouping: { byLabel: lhs },\n };\n }\n return undefined;\n}\n\nfunction mergeNodeKeys<TKey extends string | InstancesNodeKey>(lhs: TKey, rhs: TKey): TKey {\n if (HierarchyNodeKey.isCustom(lhs)) {\n assert(HierarchyNodeKey.isCustom(rhs));\n return lhs === rhs ? lhs : (`${lhs}+${rhs}` as TKey);\n }\n // istanbul ignore else\n if (HierarchyNodeKey.isInstances(lhs)) {\n assert(HierarchyNodeKey.isInstances(rhs));\n return { type: \"instances\", instanceKeys: [...lhs.instanceKeys, ...rhs.instanceKeys] } as TKey;\n }\n // https://github.com/microsoft/TypeScript/issues/21985\n // istanbul ignore next\n return ((x: never) => x)(lhs);\n}\n\nfunction mergeParentNodeKeys(lhsKeys: HierarchyNodeKey[], rhsKeys: HierarchyNodeKey[]): HierarchyNodeKey[] {\n const res = new Array<HierarchyNodeKey>();\n for (let i = 0; i < lhsKeys.length && i < rhsKeys.length; ++i) {\n if (!HierarchyNodeKey.equals(lhsKeys[i], rhsKeys[i])) {\n break;\n }\n res.push(lhsKeys[i]);\n }\n return res;\n}\n\n/** @internal */\nexport function mergeNodes<TNode extends ProcessedCustomHierarchyNode | ProcessedInstanceHierarchyNode>(lhs: TNode, rhs: TNode): TNode {\n assert(typeof lhs.key === typeof rhs.key);\n const mergedProcessingParams = mergeNodeHandlingParams(lhs.processingParams, rhs.processingParams);\n const mergedChildren = lhs.children === true || rhs.children === true ? true : lhs.children === false && rhs.children === false ? false : undefined;\n const mergedNode = {\n ...lhs,\n ...rhs,\n label: lhs.label,\n key: mergeNodeKeys(lhs.key, rhs.key),\n parentKeys: mergeParentNodeKeys(lhs.parentKeys, rhs.parentKeys),\n } as TNode;\n // Remove specific properties or change their values based on lhs and rhs nodes\n mergedChildren !== undefined ? (mergedNode.children = mergedChildren) : delete mergedNode.children;\n mergedProcessingParams ? (mergedNode.processingParams = mergedProcessingParams) : delete mergedNode.processingParams;\n lhs.autoExpand || rhs.autoExpand ? (mergedNode.autoExpand = true) : delete mergedNode.autoExpand;\n lhs.extendedData || rhs.extendedData ? (mergedNode.extendedData = { ...lhs.extendedData, ...rhs.extendedData }) : delete mergedNode.extendedData;\n lhs.supportsFiltering && rhs.supportsFiltering ? (mergedNode.supportsFiltering = true) : delete mergedNode.supportsFiltering;\n return mergedNode;\n}\n\n/** @internal */\nexport function hasChildren<TNode extends { children?: boolean | Array<unknown> }>(node: TNode) {\n return node.children === true || (Array.isArray(node.children) && node.children.length > 0);\n}\n\n/** @internal */\nexport function compareNodesByLabel<TLhsNode extends { label: string }, TRhsNode extends { label: string }>(lhs: TLhsNode, rhs: TRhsNode): number {\n return naturalCompare(lhs.label.toLocaleLowerCase(), rhs.label.toLocaleLowerCase());\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ECClassHierarchyInspector, InstanceKey } from "@itwin/presentation-shared";
|
|
2
2
|
import { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, InstanceNodesQueryDefinition, NodeParser, NodePostProcessor, NodePreProcessor } from "../HierarchyDefinition";
|
|
3
|
-
import {
|
|
3
|
+
import { HierarchyNodeIdentifier } from "../HierarchyNodeIdentifier";
|
|
4
|
+
import { HierarchyFilteringPath, HierarchyFilteringPathOptions } from "../HierarchyProvider";
|
|
4
5
|
/** @internal */
|
|
5
6
|
export interface FilteringQueryBuilderProps {
|
|
6
7
|
classHierarchy: ECClassHierarchyInspector;
|
|
7
8
|
source: HierarchyDefinition;
|
|
8
|
-
nodeIdentifierPaths:
|
|
9
|
+
nodeIdentifierPaths: HierarchyFilteringPath[];
|
|
9
10
|
}
|
|
10
11
|
/** @internal */
|
|
11
12
|
export declare class FilteringHierarchyDefinition implements HierarchyDefinition {
|
|
@@ -14,20 +15,30 @@ export declare class FilteringHierarchyDefinition implements HierarchyDefinition
|
|
|
14
15
|
private _nodeIdentifierPaths;
|
|
15
16
|
constructor(props: FilteringQueryBuilderProps);
|
|
16
17
|
get preProcessNode(): NodePreProcessor;
|
|
18
|
+
private shouldExpandGroupingNode;
|
|
17
19
|
get postProcessNode(): NodePostProcessor;
|
|
18
20
|
get parseNode(): NodeParser;
|
|
19
21
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
20
22
|
private getFilteringProps;
|
|
21
23
|
}
|
|
24
|
+
type MatchedFilter<TIdentifier extends HierarchyNodeIdentifier> = {
|
|
25
|
+
id: TIdentifier;
|
|
26
|
+
childrenIdentifierPaths: HierarchyFilteringPath[];
|
|
27
|
+
} & ({
|
|
28
|
+
isFilterTarget: false;
|
|
29
|
+
} | {
|
|
30
|
+
isFilterTarget: true;
|
|
31
|
+
filterTargetOptions?: HierarchyFilteringPathOptions;
|
|
32
|
+
});
|
|
22
33
|
/** @internal */
|
|
23
34
|
export declare const ECSQL_COLUMN_NAME_FilteredChildrenPaths = "FilteredChildrenPaths";
|
|
24
35
|
/** @internal */
|
|
25
36
|
export declare const ECSQL_COLUMN_NAME_IsFilterTarget = "IsFilterTarget";
|
|
26
37
|
/** @internal */
|
|
38
|
+
export declare const ECSQL_COLUMN_NAME_FilterTargetOptions = "FilterTargetOptions";
|
|
39
|
+
/** @internal */
|
|
27
40
|
export declare const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = "HasFilterTargetAncestor";
|
|
28
41
|
/** @internal */
|
|
29
|
-
export declare function applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, matchingFilters: Array<
|
|
30
|
-
|
|
31
|
-
childrenIdentifierPaths: HierarchyNodeIdentifiersPath[];
|
|
32
|
-
}>, isFilterTarget: boolean, isParentFilterTarget: boolean, hasFilterTargetAncestor: boolean): InstanceNodesQueryDefinition;
|
|
42
|
+
export declare function applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, matchingFilters: Array<MatchedFilter<InstanceKey>>, isParentFilterTarget: boolean, hasFilterTargetAncestor: boolean): InstanceNodesQueryDefinition;
|
|
43
|
+
export {};
|
|
33
44
|
//# sourceMappingURL=FilteringHierarchyDefinition.d.ts.map
|
|
@@ -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;AAEhC,OAAO,
|
|
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,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAG7F,gBAAgB;AAChB,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,yBAAyB,CAAC;IAC1C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;CAC/C;AAED,gBAAgB;AAChB,qBAAa,4BAA6B,YAAW,mBAAmB;IACtE,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,oBAAoB,CAA2B;gBAEpC,KAAK,EAAE,0BAA0B;IAMpD,IAAW,cAAc,IAAI,gBAAgB,CAS5C;IAED,OAAO,CAAC,wBAAwB;IA2ChC,IAAW,eAAe,IAAI,iBAAiB,CAS9C;IAED,IAAW,SAAS,IAAI,UAAU,CAmBjC;IAEY,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA4DtG,OAAO,CAAC,iBAAiB;CAU1B;AAED,KAAK,aAAa,CAAC,WAAW,SAAS,uBAAuB,IAAI;IAChE,EAAE,EAAE,WAAW,CAAC;IAChB,uBAAuB,EAAE,sBAAsB,EAAE,CAAC;CACnD,GAAG,CAAC;IAAE,cAAc,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,cAAc,EAAE,IAAI,CAAC;IAAC,mBAAmB,CAAC,EAAE,6BAA6B,CAAA;CAAE,CAAC,CAAC;AAkIhH,gBAAgB;AAEhB,eAAO,MAAM,uCAAuC,0BAA0B,CAAC;AAE/E,gBAAgB;AAEhB,eAAO,MAAM,gCAAgC,mBAAmB,CAAC;AAEjE,gBAAgB;AAEhB,eAAO,MAAM,qCAAqC,wBAAwB,CAAC;AAE3E,gBAAgB;AAEhB,eAAO,MAAM,yCAAyC,4BAA4B,CAAC;AAEnF,gBAAgB;AAChB,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,4BAA4B,EACjC,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,EAClD,oBAAoB,EAAE,OAAO,EAC7B,uBAAuB,EAAE,OAAO,GAC/B,4BAA4B,CAoC9B"}
|
|
@@ -26,27 +26,70 @@ export class FilteringHierarchyDefinition {
|
|
|
26
26
|
return processedNode;
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
shouldExpandGroupingNode(node) {
|
|
30
|
+
for (const child of node.children) {
|
|
31
|
+
// istanbul ignore next
|
|
32
|
+
if (!child.filtering) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (child.filtering.isFilterTarget) {
|
|
36
|
+
const childAutoExpand = child.filtering.filterTargetOptions?.autoExpand;
|
|
37
|
+
// If child is a filter target and is has no `autoExpand` flag, then it's always to be expanded.
|
|
38
|
+
if (childAutoExpand === true) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
// If it's not an object and not `true`, then it's falsy - continue looking
|
|
42
|
+
if (typeof childAutoExpand !== "object") {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
// If grouping node's child has `autoExpandUntil` flag,
|
|
46
|
+
// auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.
|
|
47
|
+
const nodeDepth = node.parentKeys.length;
|
|
48
|
+
const filterTargetDepth = childAutoExpand.depth;
|
|
49
|
+
if (nodeDepth < filterTargetDepth) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!child.filtering.filteredChildrenIdentifierPaths) {
|
|
54
|
+
// istanbul ignore next
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
for (const path of child.filtering.filteredChildrenIdentifierPaths) {
|
|
58
|
+
if ("path" in path && path.options?.autoExpand) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
29
65
|
get postProcessNode() {
|
|
30
66
|
return async (node) => {
|
|
31
67
|
const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;
|
|
32
|
-
if (
|
|
33
68
|
// instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing
|
|
34
|
-
HierarchyNode.
|
|
35
|
-
|
|
36
|
-
return Object.assign(processedNode, { autoExpand: true });
|
|
69
|
+
if (HierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {
|
|
70
|
+
Object.assign(processedNode, { autoExpand: true });
|
|
37
71
|
}
|
|
38
72
|
return processedNode;
|
|
39
73
|
};
|
|
40
74
|
}
|
|
41
75
|
get parseNode() {
|
|
42
76
|
return (row) => {
|
|
43
|
-
const isFilterTarget = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];
|
|
44
77
|
const hasFilterTargetAncestor = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];
|
|
45
|
-
const
|
|
78
|
+
const isFilterTarget = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];
|
|
79
|
+
const filterTargetOptions = row[ECSQL_COLUMN_NAME_FilterTargetOptions]
|
|
80
|
+
? JSON.parse(row[ECSQL_COLUMN_NAME_FilterTargetOptions])
|
|
81
|
+
: undefined;
|
|
82
|
+
const filteredChildrenIdentifierPaths = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]
|
|
46
83
|
? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])
|
|
47
84
|
: undefined;
|
|
48
85
|
const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);
|
|
49
|
-
return applyFilterAttributes(
|
|
86
|
+
return applyFilterAttributes({
|
|
87
|
+
node: defaultNode,
|
|
88
|
+
filteredChildrenIdentifierPaths,
|
|
89
|
+
isFilterTarget,
|
|
90
|
+
filterTargetOptions,
|
|
91
|
+
hasFilterTargetAncestor,
|
|
92
|
+
});
|
|
50
93
|
};
|
|
51
94
|
}
|
|
52
95
|
async defineHierarchyLevel(props) {
|
|
@@ -64,11 +107,16 @@ export class FilteringHierarchyDefinition {
|
|
|
64
107
|
return false;
|
|
65
108
|
}
|
|
66
109
|
return id.key === definition.node.key;
|
|
67
|
-
}, this._classHierarchy, (def, matchingFilters
|
|
110
|
+
}, this._classHierarchy, (def, matchingFilters) => {
|
|
68
111
|
const filteredChildrenIdentifierPaths = matchingFilters.reduce((r, c) => [...r, ...c.childrenIdentifierPaths], new Array());
|
|
69
112
|
return {
|
|
70
113
|
...def,
|
|
71
|
-
node: applyFilterAttributes(
|
|
114
|
+
node: applyFilterAttributes({
|
|
115
|
+
node: def.node,
|
|
116
|
+
filteredChildrenIdentifierPaths,
|
|
117
|
+
isFilterTarget: matchingFilters.some((mc) => mc.isFilterTarget),
|
|
118
|
+
hasFilterTargetAncestor,
|
|
119
|
+
}),
|
|
72
120
|
};
|
|
73
121
|
});
|
|
74
122
|
}
|
|
@@ -78,7 +126,7 @@ export class FilteringHierarchyDefinition {
|
|
|
78
126
|
return false;
|
|
79
127
|
}
|
|
80
128
|
return this._classHierarchy.classDerivesFrom(id.className, definition.fullClassName);
|
|
81
|
-
}, this._classHierarchy, (def, matchingFilters
|
|
129
|
+
}, this._classHierarchy, (def, matchingFilters) => applyECInstanceIdsFilter(def, matchingFilters, !!isDirectParentFilterTarget, !!hasFilterTargetAncestor));
|
|
82
130
|
}
|
|
83
131
|
if (matchedDefinition) {
|
|
84
132
|
filteredDefinitions.push(matchedDefinition);
|
|
@@ -99,42 +147,72 @@ export class FilteringHierarchyDefinition {
|
|
|
99
147
|
}
|
|
100
148
|
async function matchFilters(definition, filteringProps, predicate, classHierarchy, matchedDefinitionProcessor) {
|
|
101
149
|
const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;
|
|
102
|
-
let isFilterTarget = false;
|
|
103
150
|
const matchingFilters = [];
|
|
104
|
-
for (const
|
|
151
|
+
for (const filteredNodePath of filteredNodePaths) {
|
|
152
|
+
const { path, options } = "path" in filteredNodePath ? filteredNodePath : { path: filteredNodePath, options: undefined };
|
|
105
153
|
if (path.length === 0) {
|
|
106
154
|
continue;
|
|
107
155
|
}
|
|
108
156
|
const nodeId = path[0];
|
|
109
157
|
if (await predicate(nodeId)) {
|
|
110
|
-
let
|
|
111
|
-
if (!
|
|
112
|
-
|
|
113
|
-
matchingFilters.push({
|
|
158
|
+
let entry = await findMatchingFilterEntry(matchingFilters, nodeId, classHierarchy);
|
|
159
|
+
if (!entry) {
|
|
160
|
+
entry = {
|
|
114
161
|
// ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment
|
|
115
162
|
// async type guards aren't supported
|
|
116
163
|
id: nodeId,
|
|
117
|
-
childrenIdentifierPaths,
|
|
118
|
-
|
|
164
|
+
childrenIdentifierPaths: [],
|
|
165
|
+
isFilterTarget: false,
|
|
166
|
+
};
|
|
167
|
+
matchingFilters.push(entry);
|
|
119
168
|
}
|
|
120
169
|
const remainingPath = path.slice(1);
|
|
121
170
|
if (remainingPath.length > 0) {
|
|
122
|
-
|
|
171
|
+
const remainingPathWithOptions = options ? { path: remainingPath, options } : remainingPath;
|
|
172
|
+
entry.childrenIdentifierPaths.push(remainingPathWithOptions);
|
|
173
|
+
}
|
|
174
|
+
else if (entry.isFilterTarget) {
|
|
175
|
+
entry.filterTargetOptions = mergeFilterTargetOptions(entry.filterTargetOptions, options);
|
|
123
176
|
}
|
|
124
177
|
else {
|
|
125
|
-
isFilterTarget
|
|
178
|
+
Object.assign(entry, { isFilterTarget: true, filterTargetOptions: options });
|
|
126
179
|
}
|
|
127
180
|
}
|
|
128
181
|
}
|
|
129
182
|
if (isDirectParentFilterTarget || matchingFilters.length > 0) {
|
|
130
|
-
return matchedDefinitionProcessor(definition, matchingFilters
|
|
183
|
+
return matchedDefinitionProcessor(definition, matchingFilters);
|
|
131
184
|
}
|
|
132
185
|
return undefined;
|
|
133
186
|
}
|
|
134
|
-
|
|
187
|
+
function mergeFilterTargetOptions(target, source) {
|
|
188
|
+
// istanbul ignore next
|
|
189
|
+
if (!target && !source) {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
// istanbul ignore next
|
|
193
|
+
if (!target) {
|
|
194
|
+
return source;
|
|
195
|
+
}
|
|
196
|
+
// istanbul ignore next
|
|
197
|
+
if (!source) {
|
|
198
|
+
return target;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
autoExpand: (() => {
|
|
202
|
+
if (source.autoExpand === true) {
|
|
203
|
+
return source.autoExpand;
|
|
204
|
+
}
|
|
205
|
+
if (typeof target.autoExpand === "object" && typeof source.autoExpand === "object" && source.autoExpand.depth > target.autoExpand.depth) {
|
|
206
|
+
return source.autoExpand;
|
|
207
|
+
}
|
|
208
|
+
return target.autoExpand;
|
|
209
|
+
})(),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
async function findMatchingFilterEntry(filters, nodeId, classHierarchy) {
|
|
135
213
|
for (const filter of filters) {
|
|
136
214
|
if (await identifiersEqual(filter.id, nodeId, classHierarchy)) {
|
|
137
|
-
return filter
|
|
215
|
+
return filter;
|
|
138
216
|
}
|
|
139
217
|
}
|
|
140
218
|
return undefined;
|
|
@@ -148,15 +226,17 @@ async function identifiersEqual(lhs, rhs, classHierarchy) {
|
|
|
148
226
|
}
|
|
149
227
|
return HierarchyNodeIdentifier.equal(lhs, rhs);
|
|
150
228
|
}
|
|
151
|
-
function applyFilterAttributes(node, filteredChildrenIdentifierPaths, isFilterTarget, hasFilterTargetAncestor) {
|
|
152
|
-
const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((
|
|
229
|
+
function applyFilterAttributes({ node, filteredChildrenIdentifierPaths, isFilterTarget, filterTargetOptions, hasFilterTargetAncestor, }) {
|
|
230
|
+
const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((childPath) => {
|
|
231
|
+
return "path" in childPath && childPath.path.length && childPath.options?.autoExpand;
|
|
232
|
+
});
|
|
153
233
|
const result = { ...node };
|
|
154
234
|
if (shouldAutoExpand) {
|
|
155
235
|
result.autoExpand = true;
|
|
156
236
|
}
|
|
157
237
|
if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {
|
|
158
238
|
result.filtering = {
|
|
159
|
-
...(isFilterTarget ? { isFilterTarget } : undefined),
|
|
239
|
+
...(isFilterTarget ? { isFilterTarget, filterTargetOptions } : undefined),
|
|
160
240
|
...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),
|
|
161
241
|
...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),
|
|
162
242
|
};
|
|
@@ -171,9 +251,12 @@ export const ECSQL_COLUMN_NAME_FilteredChildrenPaths = "FilteredChildrenPaths";
|
|
|
171
251
|
export const ECSQL_COLUMN_NAME_IsFilterTarget = "IsFilterTarget";
|
|
172
252
|
/** @internal */
|
|
173
253
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
254
|
+
export const ECSQL_COLUMN_NAME_FilterTargetOptions = "FilterTargetOptions";
|
|
255
|
+
/** @internal */
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
174
257
|
export const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = "HasFilterTargetAncestor";
|
|
175
258
|
/** @internal */
|
|
176
|
-
export function applyECInstanceIdsFilter(def, matchingFilters,
|
|
259
|
+
export function applyECInstanceIdsFilter(def, matchingFilters, isParentFilterTarget, hasFilterTargetAncestor) {
|
|
177
260
|
if (matchingFilters.length === 0) {
|
|
178
261
|
return def;
|
|
179
262
|
}
|
|
@@ -185,16 +268,19 @@ export function applyECInstanceIdsFilter(def, matchingFilters, isFilterTarget, i
|
|
|
185
268
|
...(def.query.ctes ?? []),
|
|
186
269
|
// 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),
|
|
187
270
|
// so using UNION as a workaround
|
|
188
|
-
`FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (
|
|
271
|
+
`FilteringInfo(ECInstanceId, IsFilterTarget, FilterTargetOptions, FilteredChildrenPaths) AS (
|
|
189
272
|
${matchingFilters
|
|
190
|
-
.map((
|
|
273
|
+
.map((mc) => mc.isFilterTarget
|
|
274
|
+
? `VALUES (${mc.id.id}, 1, ${mc.filterTargetOptions ? `'${JSON.stringify(mc.filterTargetOptions)}'` : "CAST(NULL AS TEXT)"}, '${JSON.stringify(mc.childrenIdentifierPaths)}')`
|
|
275
|
+
: `VALUES (${mc.id.id}, 0, CAST(NULL AS TEXT), '${JSON.stringify(mc.childrenIdentifierPaths)}')`)
|
|
191
276
|
.join(" UNION ALL ")}
|
|
192
277
|
)`,
|
|
193
278
|
],
|
|
194
279
|
ecsql: `
|
|
195
280
|
SELECT
|
|
196
281
|
[q].*,
|
|
197
|
-
|
|
282
|
+
[f].[IsFilterTarget] AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],
|
|
283
|
+
[f].[FilterTargetOptions] AS [${ECSQL_COLUMN_NAME_FilterTargetOptions}],
|
|
198
284
|
${hasFilterTargetAncestor || isParentFilterTarget ? "1" : "0"} AS [${ECSQL_COLUMN_NAME_HasFilterTargetAncestor}],
|
|
199
285
|
[f].[FilteredChildrenPaths] AS [${ECSQL_COLUMN_NAME_FilteredChildrenPaths}]
|
|
200
286
|
FROM (
|
|
@@ -1 +1 @@
|
|
|
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,aA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AC,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 this._classHierarchy,\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 this._classHierarchy,\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 classHierarchy: ECClassHierarchyInspector,\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 = await findChildrenIdentifierPaths(matchingFilters, nodeId, classHierarchy);\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\nasync function findChildrenIdentifierPaths<TIdentifier extends HierarchyNodeIdentifier>(\n filters: Array<{ id: TIdentifier; childrenIdentifierPaths: HierarchyNodeIdentifiersPath[] }>,\n nodeId: TIdentifier,\n classHierarchy: ECClassHierarchyInspector,\n) {\n for (const filter of filters) {\n if (await identifiersEqual(filter.id, nodeId, classHierarchy)) {\n return filter.childrenIdentifierPaths;\n }\n }\n return undefined;\n}\n\nasync function identifiersEqual<TIdentifier extends HierarchyNodeIdentifier>(lhs: TIdentifier, rhs: TIdentifier, classHierarchy: ECClassHierarchyInspector) {\n if (HierarchyNodeIdentifier.isInstanceNodeIdentifier(lhs) && HierarchyNodeIdentifier.isInstanceNodeIdentifier(rhs)) {\n return (\n lhs.id === rhs.id &&\n (lhs.className === rhs.className ||\n (await classHierarchy.classDerivesFrom(lhs.className, rhs.className)) ||\n (await classHierarchy.classDerivesFrom(rhs.className, lhs.className)))\n );\n }\n return HierarchyNodeIdentifier.equal(lhs, rhs);\n}\n\nfunction applyFilterAttributes<TNode extends 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
|
+
{"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,EAA4G,MAAM,kBAAkB,CAAC;AAC3J,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AASvD,gBAAgB;AAChB,MAAM,OAAO,4BAA4B;IAC/B,eAAe,CAA4B;IAC3C,OAAO,CAAsB;IAC7B,oBAAoB,CAA2B;IAEvD,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,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACnG,IAAI,aAAa,EAAE,gBAAgB,EAAE,eAAe,IAAI,aAAa,CAAC,SAAS,EAAE,cAAc,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,uBAAuB,EAAE,CAAC;gBACpJ,yHAAyH;gBACzH,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,aAAa,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC;IAEO,wBAAwB,CAAC,IAAoC;QACnE,KAAK,MAAM,KAAK,IA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,EAAE,CAAC;gBACzB,uIAAuI;gBACvI,iCAAiC;gBACjC;YACI,eAAe;qBACd,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACV,EAAE,CAAC,cAAc;oBACf,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,oBAAoB,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,uBAAuB,CAAC,IAAI;oBAC9K,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,6BAA6B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,uBAAuB,CAAC,IAAI,CACnG;qBACA,IAAI,CAAC,aAAa,CAAC;UACtB;aACH;YACD,KAAK,EAAE;;;qCAGwB,gCAAgC;0CAC3B,qCAAqC;YACnE,uBAAuB,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, ProcessedGroupingHierarchyNode, ProcessedHierarchyNode } from \"../HierarchyNode\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier\";\nimport { HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"../HierarchyProvider\";\nimport { defaultNodesParser } from \"./TreeNodesReader\";\n\n/** @internal */\nexport interface FilteringQueryBuilderProps {\n classHierarchy: ECClassHierarchyInspector;\n source: HierarchyDefinition;\n nodeIdentifierPaths: HierarchyFilteringPath[];\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements HierarchyDefinition {\n private _classHierarchy: ECClassHierarchyInspector;\n private _source: HierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyFilteringPath[];\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 private shouldExpandGroupingNode(node: ProcessedGroupingHierarchyNode) {\n for (const child of node.children) {\n // istanbul ignore next\n if (!child.filtering) {\n continue;\n }\n\n if (child.filtering.isFilterTarget) {\n const childAutoExpand = child.filtering.filterTargetOptions?.autoExpand;\n\n // If child is a filter target and is has no `autoExpand` flag, then it's always to be expanded.\n if (childAutoExpand === true) {\n return true;\n }\n\n // If it's not an object and not `true`, then it's falsy - continue looking\n if (typeof childAutoExpand !== \"object\") {\n continue;\n }\n\n // If grouping node's child has `autoExpandUntil` flag,\n // auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.\n const nodeDepth = node.parentKeys.length;\n const filterTargetDepth = childAutoExpand.depth;\n if (nodeDepth < filterTargetDepth) {\n return true;\n }\n }\n\n if (!child.filtering.filteredChildrenIdentifierPaths) {\n // istanbul ignore next\n continue;\n }\n\n for (const path of child.filtering.filteredChildrenIdentifierPaths) {\n if (\"path\" in path && path.options?.autoExpand) {\n return true;\n }\n }\n }\n return false;\n }\n\n public get postProcessNode(): NodePostProcessor {\n return async (node: ProcessedHierarchyNode) => {\n const processedNode = this._source.postProcessNode ? await this._source.postProcessNode(node) : node;\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n if (HierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {\n Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n };\n }\n\n public get parseNode(): NodeParser {\n return (row: { [columnName: string]: any }): ParsedInstanceHierarchyNode => {\n const hasFilterTargetAncestor: boolean = !!row[ECSQL_COLUMN_NAME_HasFilterTargetAncestor];\n const isFilterTarget: boolean = !!row[ECSQL_COLUMN_NAME_IsFilterTarget];\n const filterTargetOptions: HierarchyFilteringPathOptions | undefined = row[ECSQL_COLUMN_NAME_FilterTargetOptions]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilterTargetOptions])\n : undefined;\n const filteredChildrenIdentifierPaths: HierarchyFilteringPath[] | undefined = row[ECSQL_COLUMN_NAME_FilteredChildrenPaths]\n ? JSON.parse(row[ECSQL_COLUMN_NAME_FilteredChildrenPaths])\n : undefined;\n const defaultNode = (this._source.parseNode ?? defaultNodesParser)(row);\n return applyFilterAttributes({\n node: defaultNode,\n filteredChildrenIdentifierPaths,\n isFilterTarget,\n filterTargetOptions,\n hasFilterTargetAncestor,\n });\n };\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceDefinitions = await this._source.defineHierarchyLevel(props);\n const { 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 this._classHierarchy,\n (def, matchingFilters) => {\n const filteredChildrenIdentifierPaths = matchingFilters.reduce(\n (r, c) => [...r, ...c.childrenIdentifierPaths],\n new Array<HierarchyFilteringPath>(),\n );\n return {\n ...def,\n node: applyFilterAttributes({\n node: def.node,\n filteredChildrenIdentifierPaths,\n isFilterTarget: matchingFilters.some((mc) => mc.isFilterTarget),\n hasFilterTargetAncestor,\n }),\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 this._classHierarchy,\n (def, matchingFilters) => applyECInstanceIdsFilter(def, matchingFilters, !!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\ntype MatchedFilter<TIdentifier extends HierarchyNodeIdentifier> = {\n id: TIdentifier;\n childrenIdentifierPaths: HierarchyFilteringPath[];\n} & ({ isFilterTarget: false } | { isFilterTarget: true; filterTargetOptions?: HierarchyFilteringPathOptions });\n\nasync function matchFilters<\n TIdentifier extends HierarchyNodeIdentifier,\n TDefinition = TIdentifier extends InstanceKey ? InstanceNodesQueryDefinition : CustomHierarchyNodeDefinition,\n>(\n definition: TDefinition,\n filteringProps: { filteredNodePaths: HierarchyFilteringPath[]; isDirectParentFilterTarget?: boolean },\n predicate: (id: HierarchyNodeIdentifier) => Promise<boolean>,\n classHierarchy: ECClassHierarchyInspector,\n matchedDefinitionProcessor: (def: TDefinition, matchingFilters: Array<MatchedFilter<TIdentifier>>) => TDefinition,\n): Promise<TDefinition | undefined> {\n const { filteredNodePaths, isDirectParentFilterTarget } = filteringProps;\n const matchingFilters: Array<MatchedFilter<TIdentifier>> = [];\n for (const filteredNodePath of filteredNodePaths) {\n const { path, options } = \"path\" in filteredNodePath ? filteredNodePath : { path: filteredNodePath, options: undefined };\n if (path.length === 0) {\n continue;\n }\n const nodeId = path[0];\n if (await predicate(nodeId)) {\n let entry = await findMatchingFilterEntry(matchingFilters, nodeId, classHierarchy);\n if (!entry) {\n entry = {\n // ideally, `predicate` would act as a type guard to guarantee that `id` is `TIdentifier`, but at the moment\n // async type guards aren't supported\n id: nodeId as TIdentifier,\n childrenIdentifierPaths: [],\n isFilterTarget: false,\n };\n matchingFilters.push(entry);\n }\n const remainingPath = path.slice(1);\n if (remainingPath.length > 0) {\n const remainingPathWithOptions = options ? { path: remainingPath, options } : remainingPath;\n entry.childrenIdentifierPaths.push(remainingPathWithOptions);\n } else if (entry.isFilterTarget) {\n entry.filterTargetOptions = mergeFilterTargetOptions(entry.filterTargetOptions, options);\n } else {\n Object.assign(entry, { isFilterTarget: true, filterTargetOptions: options });\n }\n }\n }\n if (isDirectParentFilterTarget || matchingFilters.length > 0) {\n return matchedDefinitionProcessor(definition, matchingFilters);\n }\n return undefined;\n}\n\nfunction mergeFilterTargetOptions(target?: HierarchyFilteringPathOptions, source?: HierarchyFilteringPathOptions): HierarchyFilteringPathOptions | undefined {\n // istanbul ignore next\n if (!target && !source) {\n return undefined;\n }\n // istanbul ignore next\n if (!target) {\n return source;\n }\n // istanbul ignore next\n if (!source) {\n return target;\n }\n return {\n autoExpand: ((): HierarchyFilteringPathOptions[\"autoExpand\"] => {\n if (source.autoExpand === true) {\n return source.autoExpand;\n }\n if (typeof target.autoExpand === \"object\" && typeof source.autoExpand === \"object\" && source.autoExpand.depth > target.autoExpand.depth) {\n return source.autoExpand;\n }\n return target.autoExpand;\n })(),\n };\n}\n\nasync function findMatchingFilterEntry<TEntry extends { id: TIdentifier }, TIdentifier extends HierarchyNodeIdentifier>(\n filters: TEntry[],\n nodeId: TIdentifier,\n classHierarchy: ECClassHierarchyInspector,\n): Promise<TEntry | undefined> {\n for (const filter of filters) {\n if (await identifiersEqual(filter.id, nodeId, classHierarchy)) {\n return filter;\n }\n }\n return undefined;\n}\n\nasync function identifiersEqual<TIdentifier extends HierarchyNodeIdentifier>(lhs: TIdentifier, rhs: TIdentifier, classHierarchy: ECClassHierarchyInspector) {\n if (HierarchyNodeIdentifier.isInstanceNodeIdentifier(lhs) && HierarchyNodeIdentifier.isInstanceNodeIdentifier(rhs)) {\n return (\n lhs.id === rhs.id &&\n (lhs.className === rhs.className ||\n (await classHierarchy.classDerivesFrom(lhs.className, rhs.className)) ||\n (await classHierarchy.classDerivesFrom(rhs.className, lhs.className)))\n );\n }\n return HierarchyNodeIdentifier.equal(lhs, rhs);\n}\n\nfunction applyFilterAttributes<TNode extends ParsedHierarchyNode>({\n node,\n filteredChildrenIdentifierPaths,\n isFilterTarget,\n filterTargetOptions,\n hasFilterTargetAncestor,\n}: {\n node: TNode;\n filteredChildrenIdentifierPaths: HierarchyFilteringPath[] | undefined;\n isFilterTarget?: boolean;\n filterTargetOptions?: HierarchyFilteringPathOptions;\n hasFilterTargetAncestor: boolean;\n}): TNode {\n const shouldAutoExpand = !!filteredChildrenIdentifierPaths?.some((childPath) => {\n return \"path\" in childPath && childPath.path.length && childPath.options?.autoExpand;\n });\n const result = { ...node };\n if (shouldAutoExpand) {\n result.autoExpand = true;\n }\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n result.filtering = {\n ...(isFilterTarget ? { isFilterTarget, filterTargetOptions } : 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_FilterTargetOptions = \"FilterTargetOptions\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_HasFilterTargetAncestor = \"HasFilterTargetAncestor\";\n\n/** @internal */\nexport function applyECInstanceIdsFilter(\n def: InstanceNodesQueryDefinition,\n matchingFilters: Array<MatchedFilter<InstanceKey>>,\n 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, IsFilterTarget, FilterTargetOptions, FilteredChildrenPaths) AS (\n ${matchingFilters\n .map((mc) =>\n mc.isFilterTarget\n ? `VALUES (${mc.id.id}, 1, ${mc.filterTargetOptions ? `'${JSON.stringify(mc.filterTargetOptions)}'` : \"CAST(NULL AS TEXT)\"}, '${JSON.stringify(mc.childrenIdentifierPaths)}')`\n : `VALUES (${mc.id.id}, 0, CAST(NULL AS TEXT), '${JSON.stringify(mc.childrenIdentifierPaths)}')`,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n [f].[IsFilterTarget] AS [${ECSQL_COLUMN_NAME_IsFilterTarget}],\n [f].[FilterTargetOptions] AS [${ECSQL_COLUMN_NAME_FilterTargetOptions}],\n ${hasFilterTargetAncestor || 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,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogLevel } from "@itwin/presentation-shared";
|
|
2
2
|
/** @internal */
|
|
3
3
|
export interface LogMessageProps<TMessageArg = void> {
|
|
4
4
|
category: string;
|
|
@@ -9,6 +9,4 @@ export interface LogMessageProps<TMessageArg = void> {
|
|
|
9
9
|
export declare function doLog(props: LogMessageProps): void;
|
|
10
10
|
/** @internal */
|
|
11
11
|
export declare function log<TMessageArg>(props: LogMessageProps<TMessageArg>): import("rxjs").MonoTypeOperatorFunction<TMessageArg>;
|
|
12
|
-
/** @internal */
|
|
13
|
-
export declare function createQueryLogMessage(query: ECSqlQueryDef): string;
|
|
14
12
|
//# sourceMappingURL=LoggingUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggingUtils.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/LoggingUtils.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"LoggingUtils.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/internal/LoggingUtils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG/D,gBAAgB;AAChB,MAAM,WAAW,eAAe,CAAC,WAAW,GAAG,IAAI;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,MAAM,CAAC;CACvC;AAED,gBAAgB;AAChB,wBAAgB,KAAK,CAAC,KAAK,EAAE,eAAe,QAQ3C;AAeD,gBAAgB;AAChB,wBAAgB,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,wDAEnE"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { tap } from "rxjs";
|
|
6
|
-
import { trimWhitespace } from "@itwin/presentation-shared";
|
|
7
6
|
import { getLogger } from "../Logging";
|
|
8
7
|
/** @internal */
|
|
9
8
|
export function doLog(props) {
|
|
@@ -31,20 +30,4 @@ function getLogFunc(logger, severity) {
|
|
|
31
30
|
export function log(props) {
|
|
32
31
|
return tap((n) => doLog({ ...props, message: () => props.message(n) }));
|
|
33
32
|
}
|
|
34
|
-
/** @internal */
|
|
35
|
-
// istanbul ignore next
|
|
36
|
-
export function createQueryLogMessage(query) {
|
|
37
|
-
const ctes = query.ctes?.map((cte) => ` ${trimWhitespace(cte)}`).join(", \n");
|
|
38
|
-
const bindings = query.bindings?.map((b) => JSON.stringify(b.value)).join(", ");
|
|
39
|
-
let output = "{\n";
|
|
40
|
-
if (ctes) {
|
|
41
|
-
output += ` ctes: [ \n${ctes} \n], \n`;
|
|
42
|
-
}
|
|
43
|
-
output += ` ecsql: ${trimWhitespace(query.ecsql)}, \n`;
|
|
44
|
-
if (bindings) {
|
|
45
|
-
output += ` bindings: [${bindings}], \n`;
|
|
46
|
-
}
|
|
47
|
-
output += "}";
|
|
48
|
-
return output;
|
|
49
|
-
}
|
|
50
33
|
//# sourceMappingURL=LoggingUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggingUtils.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/LoggingUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"LoggingUtils.js","sourceRoot":"","sources":["../../../../src/hierarchies/internal/LoggingUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AASvC,gBAAgB;AAChB,MAAM,UAAU,KAAK,CAAC,KAAsB;IAC1C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,OAAO,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;QAChD,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,UAAU,CAAC,MAAe,EAAE,QAAkB;IACrD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,KAAK,MAAM;YACT,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrC,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,GAAG,CAAc,KAAmC;IAClE,OAAO,GAAG,CAAc,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvF,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 { tap } from \"rxjs\";\nimport { ILogger, LogLevel } from \"@itwin/presentation-shared\";\nimport { getLogger } from \"../Logging\";\n\n/** @internal */\nexport interface LogMessageProps<TMessageArg = void> {\n category: string;\n severity?: LogLevel;\n message: (arg: TMessageArg) => string;\n}\n\n/** @internal */\nexport function doLog(props: LogMessageProps) {\n const logger = getLogger();\n const severity = props.severity ?? \"trace\";\n if (!logger.isEnabled(props.category, severity)) {\n return;\n }\n const logFunc = getLogFunc(logger, severity);\n logFunc(props.category, props.message());\n}\n\nfunction getLogFunc(logger: ILogger, severity: LogLevel) {\n switch (severity) {\n case \"error\":\n return logger.logError.bind(logger);\n case \"warning\":\n return logger.logWarning.bind(logger);\n case \"info\":\n return logger.logInfo.bind(logger);\n case \"trace\":\n return logger.logTrace.bind(logger);\n }\n}\n\n/** @internal */\nexport function log<TMessageArg>(props: LogMessageProps<TMessageArg>) {\n return tap<TMessageArg>((n) => doLog({ ...props, message: () => props.message(n) }));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetermineChildren.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/internal/operators/DetermineChildren.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,UAAU,EAAM,MAAM,MAAM,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAM7D,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"DetermineChildren.d.ts","sourceRoot":"","sources":["../../../../../src/hierarchies/internal/operators/DetermineChildren.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,UAAU,EAAM,MAAM,MAAM,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAM7D,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,QAA4E,CAAC;AAE3G;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,UAAU,CAAC,OAAO,CAAC,WACrF,UAAU,CAAC,sBAAsB,CAAC,KAAG,UAAU,CAAC,sBAAsB,CAAC,CAmBhG"}
|