@itwin/presentation-hierarchies 2.0.0-alpha.13 → 2.0.0-alpha.14
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 +37 -4
- package/lib/cjs/hierarchies/HierarchySearch.d.ts +24 -2
- package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchySearch.js +15 -5
- package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.d.ts +24 -2
- package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.js +15 -5
- package/lib/esm/hierarchies/HierarchySearch.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.14
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1264](https://github.com/iTwin/presentation/pull/1264): Enhance `HierarchySearchTree.createBuilder()` by allowing it to process resulting hierarchy.
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const builder = HierarchySearchTree.createBuilder<{ heat?: number }>();
|
|
13
|
+
builder.accept({
|
|
14
|
+
tree: subTree,
|
|
15
|
+
handler: {
|
|
16
|
+
onEntryHandled: ({ treeEntry, parentEntries }) => {
|
|
17
|
+
// Assign some extra information to the entry and its ancestors. This will allow us to test
|
|
18
|
+
// that we can use that information in `getTree` method to filter out entries.
|
|
19
|
+
[...parentEntries, treeEntry].forEach((entry) => {
|
|
20
|
+
entry.extras.heat ? entry.extras.heat++ : (entry.extras.heat = 1);
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const tree = builder.getTree({
|
|
26
|
+
// Only include branches with heat > 5
|
|
27
|
+
processEntry: ({ treeEntry }) =>
|
|
28
|
+
(treeEntry.extras.heat ?? 0) > 5 ? treeEntry : undefined,
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [#1256](https://github.com/iTwin/presentation/pull/1256): Fix `alpha` dependencies being specified with a range (`^`), allowing package manager to use higher versions, possibly with breaking changes.
|
|
35
|
+
|
|
3
36
|
## 2.0.0-alpha.13
|
|
4
37
|
|
|
5
38
|
### Major Changes
|
|
@@ -54,7 +87,7 @@
|
|
|
54
87
|
builder.accept({ path: searchPath1 });
|
|
55
88
|
builder.accept({ path: searchPath2 });
|
|
56
89
|
builder.accept({ tree: partialSearchTree });
|
|
57
|
-
const tree: HierarchySearchTree = builder.getTree();
|
|
90
|
+
const tree: HierarchySearchTree[] = builder.getTree();
|
|
58
91
|
```
|
|
59
92
|
|
|
60
93
|
This is the preferred way to create a `HierarchySearchTree`, as it allows to create a tree without having to create an array first, as opposed to `HierarchySearchTree.createFromPathsList` function described below.
|
|
@@ -69,15 +102,15 @@
|
|
|
69
102
|
for (const item of items) {
|
|
70
103
|
searchPaths.push(createSearchPathForItem(item));
|
|
71
104
|
}
|
|
72
|
-
const tree: HierarchySearchTree =
|
|
73
|
-
HierarchySearchTree.createFromPathsList(searchPaths);
|
|
105
|
+
const tree: HierarchySearchTree[] =
|
|
106
|
+
await HierarchySearchTree.createFromPathsList(searchPaths);
|
|
74
107
|
|
|
75
108
|
// Do this:
|
|
76
109
|
const builder = HierarchySearchTree.createBuilder();
|
|
77
110
|
for (const item of items) {
|
|
78
111
|
builder.accept({ path: createSearchPathForItem(item) });
|
|
79
112
|
}
|
|
80
|
-
const tree: HierarchySearchTree = builder.getTree();
|
|
113
|
+
const tree: HierarchySearchTree[] = builder.getTree();
|
|
81
114
|
```
|
|
82
115
|
|
|
83
116
|
- `HierarchySearchTree.mergeOptions` function to merge options of two hierarchy search trees. Used internally to merge options of the same nodes when creating a tree from a list of paths.
|
|
@@ -165,7 +165,11 @@ export declare namespace HierarchySearchTree {
|
|
|
165
165
|
inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;
|
|
166
166
|
}) => void;
|
|
167
167
|
}
|
|
168
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Props supplied to HierarchySearchTreeBuilder.accept() method for accepting a hierarchy search path or tree with an optional handler for customizing
|
|
170
|
+
* the behavior of the builder when accepting new entries.
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
169
173
|
type HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras extends Record<string, unknown>> = ({
|
|
170
174
|
path: HierarchySearchPath;
|
|
171
175
|
} | {
|
|
@@ -174,6 +178,24 @@ export declare namespace HierarchySearchTree {
|
|
|
174
178
|
/** An optional handler for customizing the behavior of the builder when accepting new entries. */
|
|
175
179
|
handler?: HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;
|
|
176
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Props supplied to HierarchySearchTreeBuilder.getTree() method for customizing the resulting tree entries, e.g. by omitting some of them or
|
|
183
|
+
* assigning extra information to them.
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
interface HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras extends Record<string, unknown>> {
|
|
187
|
+
/**
|
|
188
|
+
* A function that can be used to process each tree entry before it's added to the final tree.
|
|
189
|
+
*
|
|
190
|
+
* Return `undefined` to omit the entry and its entire branch from the resulting tree.
|
|
191
|
+
*/
|
|
192
|
+
processEntry?: (props: {
|
|
193
|
+
treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>;
|
|
194
|
+
parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>>;
|
|
195
|
+
}) => (Omit<HierarchySearchTree, "children"> & {
|
|
196
|
+
extras: TAcceptHandlerExtras;
|
|
197
|
+
}) | undefined;
|
|
198
|
+
}
|
|
177
199
|
/**
|
|
178
200
|
* An utility that accepts hierarchy search paths or search trees one by one and builds a `HierarchySearchTree` structure based on them.
|
|
179
201
|
* @public
|
|
@@ -187,7 +209,7 @@ export declare namespace HierarchySearchTree {
|
|
|
187
209
|
/**
|
|
188
210
|
* Create `HierarchySearchTree[]` from currently added search paths.
|
|
189
211
|
*/
|
|
190
|
-
getTree(): HierarchySearchTree[];
|
|
212
|
+
getTree(props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>): HierarchySearchTree[];
|
|
191
213
|
}
|
|
192
214
|
/**
|
|
193
215
|
* Create a `HierarchySearchTree` builder utility that accepts hierarchy search paths or search trees one by one and builds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchySearch.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAIvE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9E,cAAc;AACd,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,MAAM,CAAC,EACH,OAAO,GACP;QACE;;;;;;;;;;;;;;;;;WAiBG;QACH,WAAW,EAAE,MAAM,CAAC;KACrB,GACD;QACE;;;;;;WAMG;QACH,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACN;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,4BAA4B,GAAG;IAAE,IAAI,EAAE,4BAA4B,CAAC;IAAC,OAAO,CAAC,EAAE,0BAA0B,CAAA;CAA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nC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAAC;YAC3C,WAAW,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,CAAC;SAC/D,GAAG,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,SAAS;gBAClC;YACnC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAAC;YAC3C,gBAAgB,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;SACvF,GAAG,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,SAAS;;EA+DvJ"}
|
|
@@ -95,10 +95,20 @@ var HierarchySearchTree;
|
|
|
95
95
|
var _a;
|
|
96
96
|
return new (class Impl {
|
|
97
97
|
#rootsDictionary = new core_bentley_1.Dictionary(HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.compare);
|
|
98
|
-
static #mapDictionaryToTree(dictionary) {
|
|
98
|
+
static #mapDictionaryToTree(dictionary, parentEntries, props) {
|
|
99
99
|
const list = [];
|
|
100
|
-
for (const { children,
|
|
101
|
-
|
|
100
|
+
for (const { children, ...entry } of dictionary.values()) {
|
|
101
|
+
let processedEntry = entry;
|
|
102
|
+
if (props?.processEntry) {
|
|
103
|
+
processedEntry = props.processEntry({ treeEntry: entry, parentEntries });
|
|
104
|
+
}
|
|
105
|
+
if (!processedEntry) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const { extras: _, ...entryWithoutExtras } = processedEntry;
|
|
109
|
+
parentEntries.push(processedEntry);
|
|
110
|
+
list.push({ ...entryWithoutExtras, ...(children ? { children: Impl.#mapDictionaryToTree(children, parentEntries, props) } : undefined) });
|
|
111
|
+
parentEntries.pop();
|
|
102
112
|
}
|
|
103
113
|
return list;
|
|
104
114
|
}
|
|
@@ -250,8 +260,8 @@ var HierarchySearchTree;
|
|
|
250
260
|
}
|
|
251
261
|
return this;
|
|
252
262
|
}
|
|
253
|
-
getTree() {
|
|
254
|
-
return Impl.#mapDictionaryToTree(this.#rootsDictionary);
|
|
263
|
+
getTree(props) {
|
|
264
|
+
return Impl.#mapDictionaryToTree(this.#rootsDictionary, [], props);
|
|
255
265
|
}
|
|
256
266
|
})();
|
|
257
267
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchySearch.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA6iBhG,kEA0IC;AArrBD,+BAAyD;AACzD,sDAAiD;AACjD,6EAAuE;AACvE,+DAAyD;AACzD,oFAA0F;AA+D1F,cAAc;AACd,2DAA2D;AAC3D,IAAiB,mBAAmB,CAgEnC;AAhED,WAAiB,mBAAmB;IAClC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAA2B;QACnD,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;IALe,6BAAS,YAKxB,CAAA;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,YAAY,CAC1B,GAA2C,EAC3C,GAA2C;QAE3C,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,qBAAqB,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3E,OAAO,MAAM,IAAI,UAAU;YACzB,CAAC,CAAC;gBACE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBA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,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC;QACtD,OAAO;YACL,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YACpC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7C,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 { firstValueFrom, from, map, reduce } from \"rxjs\";\nimport { Dictionary } from \"@itwin/core-bentley\";\nimport { HierarchyNodeIdentifier } from \"./HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey } from \"./HierarchyNodeKey.js\";\nimport { releaseMainThreadOnItemsCount } from \"./internal/operators/ReleaseMainThread.js\";\n\nimport type { NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport type { HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport type { GenericNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface HierarchySearchPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the searched hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the search target will have `autoExpand` flag.\n * - If it's a object with `groupingLevel` then `groupingLevel` determines the number of grouping levels to expand for\n * the search target.\n */\n reveal?:\n | boolean\n | {\n /**\n * Index of the node in search path should be revealed in hierarchy by auto-expanding its ancestors.\n *\n * Use when you want to expand up to specific instance node and don't care about grouping nodes.\n *\n * **Use case example:**\n *\n * All nodes up to `Element1` should be expanded in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n *\n * Provide `{ path: [Node1, Element1], reveal: { depthInPath: 1 } }`\n *\n * **NOTE**: All nodes that are up to `depthInPath` will be expanded **except** search targets.\n */\n depthInPath: number;\n }\n | {\n /**\n * The number of grouping levels to expand for the search target. For example, if `groupingLevel` is set to `2`, then all grouping nodes up to the second level\n * will have the `autoExpand` flag.\n *\n * **Note:** if search target has less grouping levels than specified by this attribute, then all grouping nodes up to the search target will have\n * the `autoExpand` flag, but the search target itself won't have the `autoExpand` flag.\n */\n groupingLevel: number;\n };\n /**\n * This option specifies whether or not search target should be expanded.\n * - If it's `false` or `undefined`, search target won't have 'autoExpand' flag.\n * - If it's `true`, search target will have `autoExpand` flag.\n *\n * **Note:** this attribute does not set `autoExpand` flag on nodes up to the search target. For that use `reveal`.\n */\n autoExpand?: boolean;\n}\n\n/**\n * A path of hierarchy node identifiers for search the hierarchy with additional options.\n * @public\n */\nexport type HierarchySearchPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchySearchPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchySearchPath {\n /**\n * Normalizes the hierarchy search path to the object form.\n * @public\n */\n export function normalize(source: HierarchySearchPath): Exclude<HierarchySearchPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchySearchPathOptions` objects.\n *\n * For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if only one of the inputs is an object, return it,\n * - else if both inputs are falsy, return `false` or `undefined`,\n * - else:\n * - if only one of the inputs has `groupingLevel` set, return that one,\n * - else compare by matching reveal type (`groupingLevel` or `depthInPath`) and return the deeper one.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchPathOptions | undefined,\n rhs: HierarchySearchPathOptions | undefined,\n ): HierarchySearchPathOptions | undefined {\n const reveal = mergeRevealOptions(lhs?.reveal, rhs?.reveal);\n const autoExpand = mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);\n return reveal || autoExpand\n ? {\n ...(reveal !== undefined ? { reveal } : undefined),\n ...(autoExpand !== undefined ? { autoExpand } : undefined),\n }\n : undefined;\n }\n function mergeRevealOptions(lhs: HierarchySearchPathOptions[\"reveal\"], rhs: HierarchySearchPathOptions[\"reveal\"]): HierarchySearchPathOptions[\"reveal\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n if (\"groupingLevel\" in lhs) {\n if (\"groupingLevel\" in rhs) {\n return lhs.groupingLevel > rhs.groupingLevel ? lhs : rhs;\n }\n return lhs;\n } else if (\"groupingLevel\" in rhs) {\n return rhs;\n }\n\n return lhs.depthInPath > rhs.depthInPath ? lhs : rhs;\n }\n\n function mergeAutoExpandOption(\n lhs: HierarchySearchPathOptions[\"autoExpand\"],\n rhs: HierarchySearchPathOptions[\"autoExpand\"],\n ): HierarchySearchPathOptions[\"autoExpand\"] {\n return lhs || rhs ? true : undefined;\n }\n}\n\n/**\n * A tree structure representing hierarchy search paths. Each node in the tree corresponds\n * to a hierarchy node identifier and may have children that represent deeper levels in the\n * hierarchy.\n *\n * The `HierarchySearchTree.createBuilder` or `HierarchySearchTree.createFromPathsList` are\n * typically used create this tree from a flat list of search paths.\n *\n * @public\n */\nexport interface HierarchySearchTree {\n /** Identifier of the hierarchy node this tree entry represents. */\n identifier: HierarchyNodeIdentifier;\n\n /**\n * When `true`, indicates that this node is a search target.\n *\n * Note: A `HierarchySearchTree` node is considered a search target if it has no children, even if `isTarget` is not explicitly set to `true`. This\n * is because a node with no children represents the end of a search path.\n */\n isTarget?: boolean;\n\n /** Provides options for handling this search tree entry, such as auto-expansion behavior. */\n options?: {\n /**\n * - `true` to expand the node and its grouping nodes,\n * - `{ groupingLevel: number }` to expand ancestor grouping nodes, e.g. for the following hierarchy:\n * ```\n * - Grouping node A\n * - Instance node A\n * - Grouping node B1\n * - Grouping node B2\n * - ...\n * - Grouping node Bn\n * - Instance node B\n * ```\n *\n * For \"Instance node B\" search tree entry:\n * - `{ groupingLevel: 1 }` expands its first grouping node \"Grouping node B1\",\n * - `{ groupingLevel: 2 }` expands two levels to \"Grouping node B2\".\n * - `{ groupingLevel: Number.MAX_SAFE_INTEGER }` expands all grouping nodes of that instance node.\n *\n * Note that there's a slight difference between `HierarchySearchTree.options.autoExpand` and\n * `HierarchySearchPath.options.reveal`. The latter option reveals the search target node by expanding its ancestors,\n * while the `HierarchySearchTree.options.autoExpand` also expands the target node itself.\n */\n autoExpand?: boolean | { groupingLevel: number };\n };\n\n /** Child search tree entries representing the next level(s) in the hierarchy search paths. */\n children?: HierarchySearchTree[];\n}\n\n/** @public */\nexport namespace HierarchySearchTree {\n /** @public */\n type HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras extends Record<string, unknown>> = Readonly<\n Pick<HierarchySearchTree, \"identifier\" | \"options\"> & {\n extras: TExtras;\n }\n > &\n Pick<HierarchySearchTree, \"isTarget\">;\n /** @public */\n type HierarchySearchTreeBuilderAcceptHandlerTreeInput = Readonly<Pick<HierarchySearchTree, \"identifier\" | \"isTarget\" | \"options\"> & { hasChildren: boolean }>;\n /** @public */\n interface HierarchySearchTreeBuilderAcceptHandler<TExtras extends Record<string, unknown>> {\n /**\n * Called when a new entry is added to the tree. Return `true` to accept the entry, `false` to reject it and all its children, if any.\n */\n onNewEntry?: (props: {\n /** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;\n /** The new entry being added to the tree. */\n inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;\n }) => boolean;\n /**\n * Called when a new entry is added to the tree and accepted (either it's a new entry or it merges with an existing entry). This can be used to perform\n * side effects such as assigning extra information to the tree entry.\n */\n onEntryHandled?: (props: {\n /** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;\n /** The tree entry that has been handled. It's allowed to mutate this entry. */\n treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>;\n /** The input entry being added to the tree. */\n inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;\n }) => void;\n }\n /** @public */\n type HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras extends Record<string, unknown>> = (\n | { path: HierarchySearchPath }\n | { tree: HierarchySearchTree }\n ) & {\n /** An optional handler for customizing the behavior of the builder when accepting new entries. */\n handler?: HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;\n };\n /**\n * An utility that accepts hierarchy search paths or search trees one by one and builds a `HierarchySearchTree` structure based on them.\n * @public\n */\n interface HierarchySearchTreeBuilder<TAcceptHandlerExtras extends Record<string, unknown>> {\n /**\n * Accepts a hierarchy search path or paths' tree and adds it to the builder's internal tree structure. Use `getTree()` to create\n * a `HierarchySearchTree[]` from the added paths.\n */\n accept(props: HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras>): HierarchySearchTreeBuilder<TAcceptHandlerExtras>;\n /**\n * Create `HierarchySearchTree[]` from currently added search paths.\n */\n getTree(): HierarchySearchTree[];\n }\n\n /**\n * Create a `HierarchySearchTree` builder utility that accepts hierarchy search paths or search trees one by one and builds\n * a `HierarchySearchTree` structure based on them.\n *\n * Usage example:\n *\n * ```ts\n * const builder = HierarchySearchTree.createBuilder();\n * for (const path of searchPaths) {\n * builder.accept({ path });\n * }\n * const searchTree = builder.getTree();\n * ```\n *\n * @public\n */\n export function createBuilder<\n TAcceptHandlerExtras extends Record<string, unknown> = Record<string, unknown>,\n >(): HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n type HierarchySearchTreeDictionaryEntry = Omit<HierarchySearchTree, \"children\"> & {\n children?: HierarchySearchTreeDictionary;\n extras: TAcceptHandlerExtras;\n };\n type HierarchySearchTreeDictionary = Dictionary<HierarchyNodeIdentifier, HierarchySearchTreeDictionaryEntry>;\n type AcceptHandler = HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;\n return new (class Impl implements HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n #rootsDictionary: HierarchySearchTreeDictionary = new Dictionary(HierarchyNodeIdentifier.compare);\n\n static #mapDictionaryToTree(dictionary: HierarchySearchTreeDictionary): HierarchySearchTree[] {\n const list: HierarchySearchTree[] = [];\n for (const { children, extras: _, ...entry } of dictionary.values()) {\n list.push({ ...entry, ...(children ? { children: Impl.#mapDictionaryToTree(children) } : undefined) });\n }\n return list;\n }\n\n static #assignAutoExpandOptionsBasedOnReveal(\n treePath: Pick<HierarchySearchTree, \"options\">[],\n revealOption: HierarchySearchPathOptions[\"reveal\"] | undefined,\n ) {\n if (revealOption === true) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // auto-expand all grouping nodes of the revealed node\n return { autoExpand: { groupingLevel: Number.MAX_SAFE_INTEGER } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n } else if (revealOption && \"groupingLevel\" in revealOption) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // the last entry should have `autoExpand` with `groupingLevel` set to the value based on `reveal.groupingLevel`\n return { autoExpand: { groupingLevel: Math.max(revealOption.groupingLevel - 1, 0) } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n } else if (revealOption && \"depthInPath\" in revealOption) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: Math.min(revealOption.depthInPath, treePath.length - 1),\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // auto-expand all grouping nodes of the revealed node\n return { autoExpand: { groupingLevel: Number.MAX_SAFE_INTEGER } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n }\n }\n\n static #assignOptionsOnTreePath({\n treePath,\n targetEntryIndex,\n getEntryOptions,\n }: {\n treePath: Array<Pick<HierarchySearchTree, \"options\">>;\n targetEntryIndex: number;\n getEntryOptions: (index: number, targetEntryIndex: number) => HierarchySearchTree[\"options\"] | undefined;\n }) {\n // set all parent entries to auto-expand\n for (let i = 0; i <= targetEntryIndex; i++) {\n const options = mergeOptions(treePath[i].options, getEntryOptions(i, targetEntryIndex));\n if (options) {\n treePath[i].options = options;\n }\n }\n }\n\n #acceptNode({\n parentEntries,\n level,\n node,\n handler,\n }: {\n parentEntries: HierarchySearchTreeDictionaryEntry[];\n level: HierarchySearchTreeDictionary;\n node: Pick<HierarchySearchTree, \"identifier\" | \"isTarget\"> & { hasChildren: boolean };\n handler?: AcceptHandler;\n }): HierarchySearchTreeDictionaryEntry | undefined {\n let entry = level.get(node.identifier);\n if (!entry) {\n if (handler?.onNewEntry && !handler.onNewEntry({ parentEntries, inputEntry: node })) {\n return undefined;\n }\n entry = {\n identifier: node.identifier,\n children: node.hasChildren ? new Dictionary(HierarchyNodeIdentifier.compare) : undefined,\n extras: {} as TAcceptHandlerExtras,\n };\n level.set(node.identifier, entry);\n }\n\n const isNodeSearchTarget = node.isTarget || !node.hasChildren;\n if (isNodeSearchTarget && entry.children) {\n entry.isTarget = true;\n }\n if (!entry.children && node.hasChildren) {\n // Existing leaf nodes are implied targets. Preserve that status when adding children.\n entry.isTarget = true;\n entry.children = new Dictionary(HierarchyNodeIdentifier.compare);\n }\n handler?.onEntryHandled?.({ parentEntries, treeEntry: entry, inputEntry: node });\n return entry;\n }\n\n #acceptPath({ path, handler }: { path: HierarchySearchPath; handler?: AcceptHandler }) {\n const normalized = HierarchySearchPath.normalize(path);\n const treePath: Array<HierarchySearchTreeDictionaryEntry> = [];\n let currentLevel: HierarchySearchTreeDictionary = this.#rootsDictionary;\n for (let i = 0; i < normalized.path.length; i++) {\n const identifier = normalized.path[i];\n const acceptedNode = this.#acceptNode({\n parentEntries: treePath,\n node: { identifier, hasChildren: i < normalized.path.length - 1 },\n level: currentLevel,\n handler,\n });\n if (!acceptedNode) {\n break;\n }\n treePath.push(acceptedNode);\n if (!acceptedNode.children) {\n break;\n }\n currentLevel = acceptedNode.children;\n }\n\n if (treePath.length === 0) {\n return;\n }\n\n // handle auto-expand\n const lastNode = treePath[treePath.length - 1];\n if (normalized.options?.autoExpand) {\n (lastNode.options ??= {}).autoExpand = true;\n }\n\n // handle auto-reveal\n Impl.#assignAutoExpandOptionsBasedOnReveal(treePath, normalized.options?.reveal);\n }\n\n #acceptTree({ tree, handler }: { tree: HierarchySearchTree; handler?: AcceptHandler }) {\n const acceptTreeNode = (\n parentEntries: HierarchySearchTreeDictionaryEntry[],\n parentInputs: HierarchySearchTree[],\n level: HierarchySearchTreeDictionary,\n node: HierarchySearchTree,\n ) => {\n const acceptedNode = this.#acceptNode({\n parentEntries,\n node: { ...node, hasChildren: node.children !== undefined },\n level,\n handler,\n });\n if (!acceptedNode) {\n // It was decided to reject this node and its children, if any\n return;\n }\n const treePath = [...parentEntries, acceptedNode];\n const inputsPath = [...parentInputs, node];\n if (!node.children || node.isTarget) {\n // Found an effective search target - merge options from its path\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index) => inputsPath[index].options,\n });\n }\n const currentLevel = acceptedNode.children;\n if (currentLevel) {\n node.children?.forEach((child) => acceptTreeNode(treePath, inputsPath, currentLevel, child));\n }\n };\n acceptTreeNode([], [], this.#rootsDictionary, tree);\n }\n\n public accept(\n props: ({ path: HierarchySearchPath } | { tree: HierarchySearchTree }) & { handler?: AcceptHandler },\n ): HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n if (\"path\" in props) {\n this.#acceptPath(props);\n } else {\n this.#acceptTree(props);\n }\n return this;\n }\n\n public getTree() {\n return Impl.#mapDictionaryToTree(this.#rootsDictionary);\n }\n })();\n }\n\n /**\n * Builds a list of `HierarchySearchTree` nodes from an iterable of search paths. Shared\n * path prefixes are merged so that each unique hierarchy node identifier appears only once\n * per level. The resulting trees carry `isTarget`, `options`, and `children` attributes\n * derived from the paths and their options (`autoExpand`, `reveal`).\n *\n * @public\n */\n export async function createFromPathsList(paths: Iterable<HierarchySearchPath>): Promise<HierarchySearchTree[]> {\n return firstValueFrom(\n from(paths).pipe(\n releaseMainThreadOnItemsCount(1000),\n reduce((builder, path) => builder.accept({ path }), createBuilder()),\n map((builder) => builder.getTree()),\n ),\n );\n }\n\n /**\n * Merges two `HierarchySearchTree` option objects. For the `autoExpand` attribute,\n * `true` takes precedence over `{ groupingLevel }`, and when both sides are\n * `{ groupingLevel }` objects the larger value wins.\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchTree[\"options\"] | undefined,\n rhs: HierarchySearchTree[\"options\"] | undefined,\n ): HierarchySearchTree[\"options\"] | undefined {\n if (!lhs) {\n return rhs;\n }\n if (!rhs) {\n return lhs;\n }\n const autoExpand = mergeSearchTreeAutoExpandOption(lhs.autoExpand, rhs.autoExpand);\n const options: NonNullable<HierarchySearchTree[\"options\"]> = {\n ...(autoExpand ? { autoExpand } : undefined),\n };\n return Object.keys(options).length > 0 ? options : undefined;\n }\n\n function mergeSearchTreeAutoExpandOption(\n lhs: NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined,\n rhs: NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined,\n ): NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined {\n if (!lhs) {\n return rhs;\n }\n if (!rhs) {\n return lhs;\n }\n return lhs === true || rhs === true ? true : { groupingLevel: Math.max(lhs.groupingLevel, rhs.groupingLevel) };\n }\n}\n\nfunction extractSearchPropsInternal(\n rootLevelSearchProps: HierarchySearchTree[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n):\n | {\n childrenTargetPaths?: HierarchySearchTree[];\n hasSearchTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelSearchProps ? { childrenTargetPaths: rootLevelSearchProps, hasSearchTargetAncestor: false } : undefined;\n }\n const searchProps: {\n childrenTargetPaths?: HierarchySearchTree[];\n hasSearchTargetAncestor: boolean;\n } = {\n ...(parentNode.search?.childrenTargetPaths ? { childrenTargetPaths: parentNode.search.childrenTargetPaths } : undefined),\n hasSearchTargetAncestor: !!parentNode.search?.hasSearchTargetAncestor || !!parentNode.search?.isSearchTarget,\n };\n return searchProps.childrenTargetPaths || searchProps.hasSearchTargetAncestor ? searchProps : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to search the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchySearchHelper(\n rootLevelSearchProps: HierarchySearchTree[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n) {\n const searchProps = extractSearchPropsInternal(rootLevelSearchProps, parentNode);\n const hasSearch = !!searchProps;\n\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n } & (\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {}\n ),\n ): void;\n function saveSearchPropsFromPathsIntoReducer(extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): void | Promise<void>;\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n } & (\n | { pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean }\n | { asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean> }\n | {}\n ),\n ): void | Promise<void> {\n // Passes down matching hierarchy search trees to the reducer.\n // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` in the search tree item's identifier matches the node\n // and if it does, the path is passed down to the reducer.\n // This function returns a promise only if `asyncPathMatcher` returns a promise.\n if (!searchProps?.childrenTargetPaths) {\n return;\n }\n const matchedTreePromises = new Array<Promise<HierarchySearchTree | undefined>>();\n for (const childrenSearchTree of searchProps.childrenTargetPaths) {\n if (\"asyncPathMatcher\" in extractionProps) {\n const matchesPossiblyPromise = extractionProps.asyncPathMatcher(childrenSearchTree.identifier);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedTreePromises.push(matchesPossiblyPromise.then((matches) => (matches ? childrenSearchTree : undefined)));\n } else if (matchesPossiblyPromise) {\n extractionProps.pathsReducer.accept(childrenSearchTree);\n }\n } else {\n const matches =\n \"pathMatcher\" in extractionProps\n ? extractionProps.pathMatcher(childrenSearchTree.identifier)\n : nodeKeyMatchesIdentifier(extractionProps.nodeKey, childrenSearchTree.identifier);\n if (matches) {\n extractionProps.pathsReducer.accept(childrenSearchTree);\n }\n }\n }\n if (matchedTreePromises.length === 0) {\n return;\n }\n return Promise.all(matchedTreePromises).then((matchedTrees) =>\n matchedTrees.forEach((matchedTree) => matchedTree && extractionProps.pathsReducer.accept(matchedTree)),\n );\n }\n\n function createChildNodeProps(props: { nodeKey: InstancesNodeKey | GenericNodeKey }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(\n props: { nodeKey: InstancesNodeKey | GenericNodeKey } & (\n | {\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {}\n ),\n ): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined {\n if (!hasSearch) {\n return undefined;\n }\n\n const reducer = new MatchingSearchPathsReducer(searchProps.hasSearchTargetAncestor);\n if (\"asyncPathMatcher\" in props) {\n const extractResult = saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, nodeKey: props.nodeKey, asyncPathMatcher: props.asyncPathMatcher });\n if (extractResult instanceof Promise) {\n return extractResult.then(() => reducer.aggregatedOptions);\n }\n } else {\n saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, ...props });\n }\n return reducer.aggregatedOptions;\n }\n\n return {\n /** Returns a flag indicating if the hierarchy level is filtered. */\n hasSearch,\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a search target. That generally means that this and all downstream hierarchy\n * levels should be displayed without search being applied to them, even if search paths\n * say otherwise.\n */\n hasSearchTargetAncestor: searchProps?.hasSearchTargetAncestor ?? false,\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if search is not applied to this level.\n */\n getChildNodeSearchIdentifiers: () => {\n if (!searchProps?.childrenTargetPaths) {\n return undefined;\n }\n return searchProps.childrenTargetPaths.map(({ identifier }) => identifier);\n },\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `search`\n * and `autoExpand`) to be set based on the search paths and search options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` or `asyncPathMatcher` 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 * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:\n * - `asyncPathMatcher` is provided - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a `Promise`.\n * - `pathMatcher` or only `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;\n */\n createChildNodeProps,\n };\n}\n\nfunction nodeKeyMatchesIdentifier(nodeKey: InstancesNodeKey | GenericNodeKey, identifier: HierarchyNodeIdentifier): boolean {\n return (\n (HierarchyNodeKey.isGeneric(nodeKey) && HierarchyNodeIdentifier.equal(identifier, nodeKey)) ||\n (HierarchyNodeKey.isInstances(nodeKey) && nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(identifier, ik)))\n );\n}\n\n/**\n * Extracts information from search paths and later returns `search` and `autoExpand` values from `HierarchyNode`.\n *\n * Saved values can be applied to a single `HierarchyNode` - this means that a new reducer should be created every time these props are requested for a `HierarchyNode`.\n *\n * Extracts information using `accept` function:\n * - Determines if node is search target, and if it is saves the options as `searchTargetOptions`\n * - Saves `HierarchySearchPathOptions` and `childrenTargetPaths`\n */\nclass MatchingSearchPathsReducer {\n private _childrenTargetPaths = new Array<HierarchySearchTree>();\n private _isSearchTarget = false;\n private _options: HierarchySearchTree[\"options\"] | undefined = undefined;\n\n public constructor(private _hasSearchTargetAncestor: boolean) {}\n\n public accept(tree: HierarchySearchTree): void {\n if (tree.isTarget || tree.children === undefined) {\n this._isSearchTarget = true;\n }\n if (tree.children && tree.children.length > 0) {\n this._childrenTargetPaths.push(...tree.children);\n }\n this._options = HierarchySearchTree.mergeOptions(this._options, tree.options);\n }\n\n public get aggregatedOptions() {\n const search =\n this._hasSearchTargetAncestor || this._isSearchTarget || this._childrenTargetPaths.length > 0 || this._options\n ? {\n ...(this._hasSearchTargetAncestor ? { hasSearchTargetAncestor: true } : undefined),\n ...(this._isSearchTarget ? { isSearchTarget: true } : undefined),\n ...(this._childrenTargetPaths.length > 0 ? { childrenTargetPaths: this._childrenTargetPaths } : undefined),\n ...(this._options ? { options: this._options } : undefined),\n }\n : undefined;\n const autoExpand = this._options?.autoExpand === true;\n return {\n ...(search ? { search } : undefined),\n ...(autoExpand ? { autoExpand } : undefined),\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HierarchySearch.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA+kBhG,kEA0IC;AAvtBD,+BAAyD;AACzD,sDAAiD;AACjD,6EAAuE;AACvE,+DAAyD;AACzD,oFAA0F;AA+D1F,cAAc;AACd,2DAA2D;AAC3D,IAAiB,mBAAmB,CAgEnC;AAhED,WAAiB,mBAAmB;IAClC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAA2B;QACnD,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;IALe,6BAAS,YAKxB,CAAA;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,YAAY,CAC1B,GAA2C,EAC3C,GAA2C;QAE3C,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,qBAAqB,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3E,OAAO,MAAM,IAAI,UAAU;YACzB,CAAC,CAAC;gBACE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAClD,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;aAC3D;YACH,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAZe,gCAAY,eAY3B,CAAA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I,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC1G,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;aAC5D;YACH,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC;QACtD,OAAO;YACL,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YACpC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7C,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 { firstValueFrom, from, map, reduce } from \"rxjs\";\nimport { Dictionary } from \"@itwin/core-bentley\";\nimport { HierarchyNodeIdentifier } from \"./HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey } from \"./HierarchyNodeKey.js\";\nimport { releaseMainThreadOnItemsCount } from \"./internal/operators/ReleaseMainThread.js\";\n\nimport type { NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport type { HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport type { GenericNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface HierarchySearchPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the searched hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the search target will have `autoExpand` flag.\n * - If it's a object with `groupingLevel` then `groupingLevel` determines the number of grouping levels to expand for\n * the search target.\n */\n reveal?:\n | boolean\n | {\n /**\n * Index of the node in search path should be revealed in hierarchy by auto-expanding its ancestors.\n *\n * Use when you want to expand up to specific instance node and don't care about grouping nodes.\n *\n * **Use case example:**\n *\n * All nodes up to `Element1` should be expanded in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n *\n * Provide `{ path: [Node1, Element1], reveal: { depthInPath: 1 } }`\n *\n * **NOTE**: All nodes that are up to `depthInPath` will be expanded **except** search targets.\n */\n depthInPath: number;\n }\n | {\n /**\n * The number of grouping levels to expand for the search target. For example, if `groupingLevel` is set to `2`, then all grouping nodes up to the second level\n * will have the `autoExpand` flag.\n *\n * **Note:** if search target has less grouping levels than specified by this attribute, then all grouping nodes up to the search target will have\n * the `autoExpand` flag, but the search target itself won't have the `autoExpand` flag.\n */\n groupingLevel: number;\n };\n /**\n * This option specifies whether or not search target should be expanded.\n * - If it's `false` or `undefined`, search target won't have 'autoExpand' flag.\n * - If it's `true`, search target will have `autoExpand` flag.\n *\n * **Note:** this attribute does not set `autoExpand` flag on nodes up to the search target. For that use `reveal`.\n */\n autoExpand?: boolean;\n}\n\n/**\n * A path of hierarchy node identifiers for search the hierarchy with additional options.\n * @public\n */\nexport type HierarchySearchPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchySearchPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchySearchPath {\n /**\n * Normalizes the hierarchy search path to the object form.\n * @public\n */\n export function normalize(source: HierarchySearchPath): Exclude<HierarchySearchPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchySearchPathOptions` objects.\n *\n * For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if only one of the inputs is an object, return it,\n * - else if both inputs are falsy, return `false` or `undefined`,\n * - else:\n * - if only one of the inputs has `groupingLevel` set, return that one,\n * - else compare by matching reveal type (`groupingLevel` or `depthInPath`) and return the deeper one.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchPathOptions | undefined,\n rhs: HierarchySearchPathOptions | undefined,\n ): HierarchySearchPathOptions | undefined {\n const reveal = mergeRevealOptions(lhs?.reveal, rhs?.reveal);\n const autoExpand = mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);\n return reveal || autoExpand\n ? {\n ...(reveal !== undefined ? { reveal } : undefined),\n ...(autoExpand !== undefined ? { autoExpand } : undefined),\n }\n : undefined;\n }\n function mergeRevealOptions(lhs: HierarchySearchPathOptions[\"reveal\"], rhs: HierarchySearchPathOptions[\"reveal\"]): HierarchySearchPathOptions[\"reveal\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n if (\"groupingLevel\" in lhs) {\n if (\"groupingLevel\" in rhs) {\n return lhs.groupingLevel > rhs.groupingLevel ? lhs : rhs;\n }\n return lhs;\n } else if (\"groupingLevel\" in rhs) {\n return rhs;\n }\n\n return lhs.depthInPath > rhs.depthInPath ? lhs : rhs;\n }\n\n function mergeAutoExpandOption(\n lhs: HierarchySearchPathOptions[\"autoExpand\"],\n rhs: HierarchySearchPathOptions[\"autoExpand\"],\n ): HierarchySearchPathOptions[\"autoExpand\"] {\n return lhs || rhs ? true : undefined;\n }\n}\n\n/**\n * A tree structure representing hierarchy search paths. Each node in the tree corresponds\n * to a hierarchy node identifier and may have children that represent deeper levels in the\n * hierarchy.\n *\n * The `HierarchySearchTree.createBuilder` or `HierarchySearchTree.createFromPathsList` are\n * typically used create this tree from a flat list of search paths.\n *\n * @public\n */\nexport interface HierarchySearchTree {\n /** Identifier of the hierarchy node this tree entry represents. */\n identifier: HierarchyNodeIdentifier;\n\n /**\n * When `true`, indicates that this node is a search target.\n *\n * Note: A `HierarchySearchTree` node is considered a search target if it has no children, even if `isTarget` is not explicitly set to `true`. This\n * is because a node with no children represents the end of a search path.\n */\n isTarget?: boolean;\n\n /** Provides options for handling this search tree entry, such as auto-expansion behavior. */\n options?: {\n /**\n * - `true` to expand the node and its grouping nodes,\n * - `{ groupingLevel: number }` to expand ancestor grouping nodes, e.g. for the following hierarchy:\n * ```\n * - Grouping node A\n * - Instance node A\n * - Grouping node B1\n * - Grouping node B2\n * - ...\n * - Grouping node Bn\n * - Instance node B\n * ```\n *\n * For \"Instance node B\" search tree entry:\n * - `{ groupingLevel: 1 }` expands its first grouping node \"Grouping node B1\",\n * - `{ groupingLevel: 2 }` expands two levels to \"Grouping node B2\".\n * - `{ groupingLevel: Number.MAX_SAFE_INTEGER }` expands all grouping nodes of that instance node.\n *\n * Note that there's a slight difference between `HierarchySearchTree.options.autoExpand` and\n * `HierarchySearchPath.options.reveal`. The latter option reveals the search target node by expanding its ancestors,\n * while the `HierarchySearchTree.options.autoExpand` also expands the target node itself.\n */\n autoExpand?: boolean | { groupingLevel: number };\n };\n\n /** Child search tree entries representing the next level(s) in the hierarchy search paths. */\n children?: HierarchySearchTree[];\n}\n\n/** @public */\nexport namespace HierarchySearchTree {\n /** @public */\n type HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras extends Record<string, unknown>> = Readonly<\n Pick<HierarchySearchTree, \"identifier\" | \"options\"> & {\n extras: TExtras;\n }\n > &\n Pick<HierarchySearchTree, \"isTarget\">;\n /** @public */\n type HierarchySearchTreeBuilderAcceptHandlerTreeInput = Readonly<Pick<HierarchySearchTree, \"identifier\" | \"isTarget\" | \"options\"> & { hasChildren: boolean }>;\n /** @public */\n interface HierarchySearchTreeBuilderAcceptHandler<TExtras extends Record<string, unknown>> {\n /**\n * Called when a new entry is added to the tree. Return `true` to accept the entry, `false` to reject it and all its children, if any.\n */\n onNewEntry?: (props: {\n /** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;\n /** The new entry being added to the tree. */\n inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;\n }) => boolean;\n /**\n * Called when a new entry is added to the tree and accepted (either it's a new entry or it merges with an existing entry). This can be used to perform\n * side effects such as assigning extra information to the tree entry.\n */\n onEntryHandled?: (props: {\n /** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;\n /** The tree entry that has been handled. It's allowed to mutate this entry. */\n treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>;\n /** The input entry being added to the tree. */\n inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;\n }) => void;\n }\n /**\n * Props supplied to HierarchySearchTreeBuilder.accept() method for accepting a hierarchy search path or tree with an optional handler for customizing\n * the behavior of the builder when accepting new entries.\n * @public\n */\n type HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras extends Record<string, unknown>> = (\n | { path: HierarchySearchPath }\n | { tree: HierarchySearchTree }\n ) & {\n /** An optional handler for customizing the behavior of the builder when accepting new entries. */\n handler?: HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;\n };\n /**\n * Props supplied to HierarchySearchTreeBuilder.getTree() method for customizing the resulting tree entries, e.g. by omitting some of them or\n * assigning extra information to them.\n * @public\n */\n interface HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras extends Record<string, unknown>> {\n /**\n * A function that can be used to process each tree entry before it's added to the final tree.\n *\n * Return `undefined` to omit the entry and its entire branch from the resulting tree.\n */\n processEntry?: (props: {\n treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>;\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>>;\n }) => (Omit<HierarchySearchTree, \"children\"> & { extras: TAcceptHandlerExtras }) | undefined;\n }\n /**\n * An utility that accepts hierarchy search paths or search trees one by one and builds a `HierarchySearchTree` structure based on them.\n * @public\n */\n interface HierarchySearchTreeBuilder<TAcceptHandlerExtras extends Record<string, unknown>> {\n /**\n * Accepts a hierarchy search path or paths' tree and adds it to the builder's internal tree structure. Use `getTree()` to create\n * a `HierarchySearchTree[]` from the added paths.\n */\n accept(props: HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras>): HierarchySearchTreeBuilder<TAcceptHandlerExtras>;\n /**\n * Create `HierarchySearchTree[]` from currently added search paths.\n */\n getTree(props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>): HierarchySearchTree[];\n }\n\n /**\n * Create a `HierarchySearchTree` builder utility that accepts hierarchy search paths or search trees one by one and builds\n * a `HierarchySearchTree` structure based on them.\n *\n * Usage example:\n *\n * ```ts\n * const builder = HierarchySearchTree.createBuilder();\n * for (const path of searchPaths) {\n * builder.accept({ path });\n * }\n * const searchTree = builder.getTree();\n * ```\n *\n * @public\n */\n export function createBuilder<\n TAcceptHandlerExtras extends Record<string, unknown> = Record<string, unknown>,\n >(): HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n type HierarchySearchTreeDictionaryEntry = Omit<HierarchySearchTree, \"children\"> & {\n children?: HierarchySearchTreeDictionary;\n extras: TAcceptHandlerExtras;\n };\n type HierarchySearchTreeDictionary = Dictionary<HierarchyNodeIdentifier, HierarchySearchTreeDictionaryEntry>;\n type AcceptHandler = HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;\n return new (class Impl implements HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n #rootsDictionary: HierarchySearchTreeDictionary = new Dictionary(HierarchyNodeIdentifier.compare);\n\n static #mapDictionaryToTree(\n dictionary: HierarchySearchTreeDictionary,\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>>,\n props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>,\n ): HierarchySearchTree[] {\n const list: HierarchySearchTree[] = [];\n for (const { children, ...entry } of dictionary.values()) {\n let processedEntry: (Omit<HierarchySearchTree, \"children\"> & { extras: TAcceptHandlerExtras }) | undefined = entry;\n if (props?.processEntry) {\n processedEntry = props.processEntry({ treeEntry: entry, parentEntries });\n }\n if (!processedEntry) {\n continue;\n }\n const { extras: _, ...entryWithoutExtras } = processedEntry;\n parentEntries.push(processedEntry);\n list.push({ ...entryWithoutExtras, ...(children ? { children: Impl.#mapDictionaryToTree(children, parentEntries, props) } : undefined) });\n parentEntries.pop();\n }\n return list;\n }\n\n static #assignAutoExpandOptionsBasedOnReveal(\n treePath: Pick<HierarchySearchTree, \"options\">[],\n revealOption: HierarchySearchPathOptions[\"reveal\"] | undefined,\n ) {\n if (revealOption === true) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // auto-expand all grouping nodes of the revealed node\n return { autoExpand: { groupingLevel: Number.MAX_SAFE_INTEGER } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n } else if (revealOption && \"groupingLevel\" in revealOption) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // the last entry should have `autoExpand` with `groupingLevel` set to the value based on `reveal.groupingLevel`\n return { autoExpand: { groupingLevel: Math.max(revealOption.groupingLevel - 1, 0) } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n } else if (revealOption && \"depthInPath\" in revealOption) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: Math.min(revealOption.depthInPath, treePath.length - 1),\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // auto-expand all grouping nodes of the revealed node\n return { autoExpand: { groupingLevel: Number.MAX_SAFE_INTEGER } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n }\n }\n\n static #assignOptionsOnTreePath({\n treePath,\n targetEntryIndex,\n getEntryOptions,\n }: {\n treePath: Array<Pick<HierarchySearchTree, \"options\">>;\n targetEntryIndex: number;\n getEntryOptions: (index: number, targetEntryIndex: number) => HierarchySearchTree[\"options\"] | undefined;\n }) {\n // set all parent entries to auto-expand\n for (let i = 0; i <= targetEntryIndex; i++) {\n const options = mergeOptions(treePath[i].options, getEntryOptions(i, targetEntryIndex));\n if (options) {\n treePath[i].options = options;\n }\n }\n }\n\n #acceptNode({\n parentEntries,\n level,\n node,\n handler,\n }: {\n parentEntries: HierarchySearchTreeDictionaryEntry[];\n level: HierarchySearchTreeDictionary;\n node: Pick<HierarchySearchTree, \"identifier\" | \"isTarget\"> & { hasChildren: boolean };\n handler?: AcceptHandler;\n }): HierarchySearchTreeDictionaryEntry | undefined {\n let entry = level.get(node.identifier);\n if (!entry) {\n if (handler?.onNewEntry && !handler.onNewEntry({ parentEntries, inputEntry: node })) {\n return undefined;\n }\n entry = {\n identifier: node.identifier,\n children: node.hasChildren ? new Dictionary(HierarchyNodeIdentifier.compare) : undefined,\n extras: {} as TAcceptHandlerExtras,\n };\n level.set(node.identifier, entry);\n }\n\n const isNodeSearchTarget = node.isTarget || !node.hasChildren;\n if (isNodeSearchTarget && entry.children) {\n entry.isTarget = true;\n }\n if (!entry.children && node.hasChildren) {\n // Existing leaf nodes are implied targets. Preserve that status when adding children.\n entry.isTarget = true;\n entry.children = new Dictionary(HierarchyNodeIdentifier.compare);\n }\n handler?.onEntryHandled?.({ parentEntries, treeEntry: entry, inputEntry: node });\n return entry;\n }\n\n #acceptPath({ path, handler }: { path: HierarchySearchPath; handler?: AcceptHandler }) {\n const normalized = HierarchySearchPath.normalize(path);\n const treePath: Array<HierarchySearchTreeDictionaryEntry> = [];\n let currentLevel: HierarchySearchTreeDictionary = this.#rootsDictionary;\n for (let i = 0; i < normalized.path.length; i++) {\n const identifier = normalized.path[i];\n const acceptedNode = this.#acceptNode({\n parentEntries: treePath,\n node: { identifier, hasChildren: i < normalized.path.length - 1 },\n level: currentLevel,\n handler,\n });\n if (!acceptedNode) {\n break;\n }\n treePath.push(acceptedNode);\n if (!acceptedNode.children) {\n break;\n }\n currentLevel = acceptedNode.children;\n }\n\n if (treePath.length === 0) {\n return;\n }\n\n // handle auto-expand\n const lastNode = treePath[treePath.length - 1];\n if (normalized.options?.autoExpand) {\n (lastNode.options ??= {}).autoExpand = true;\n }\n\n // handle auto-reveal\n Impl.#assignAutoExpandOptionsBasedOnReveal(treePath, normalized.options?.reveal);\n }\n\n #acceptTree({ tree, handler }: { tree: HierarchySearchTree; handler?: AcceptHandler }) {\n const acceptTreeNode = (\n parentEntries: HierarchySearchTreeDictionaryEntry[],\n parentInputs: HierarchySearchTree[],\n level: HierarchySearchTreeDictionary,\n node: HierarchySearchTree,\n ) => {\n const acceptedNode = this.#acceptNode({\n parentEntries,\n node: { ...node, hasChildren: node.children !== undefined },\n level,\n handler,\n });\n if (!acceptedNode) {\n // It was decided to reject this node and its children, if any\n return;\n }\n const treePath = [...parentEntries, acceptedNode];\n const inputsPath = [...parentInputs, node];\n if (!node.children || node.isTarget) {\n // Found an effective search target - merge options from its path\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index) => inputsPath[index].options,\n });\n }\n const currentLevel = acceptedNode.children;\n if (currentLevel) {\n node.children?.forEach((child) => acceptTreeNode(treePath, inputsPath, currentLevel, child));\n }\n };\n acceptTreeNode([], [], this.#rootsDictionary, tree);\n }\n\n public accept(\n props: ({ path: HierarchySearchPath } | { tree: HierarchySearchTree }) & { handler?: AcceptHandler },\n ): HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n if (\"path\" in props) {\n this.#acceptPath(props);\n } else {\n this.#acceptTree(props);\n }\n return this;\n }\n\n public getTree(props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>) {\n return Impl.#mapDictionaryToTree(this.#rootsDictionary, [], props);\n }\n })();\n }\n\n /**\n * Builds a list of `HierarchySearchTree` nodes from an iterable of search paths. Shared\n * path prefixes are merged so that each unique hierarchy node identifier appears only once\n * per level. The resulting trees carry `isTarget`, `options`, and `children` attributes\n * derived from the paths and their options (`autoExpand`, `reveal`).\n *\n * @public\n */\n export async function createFromPathsList(paths: Iterable<HierarchySearchPath>): Promise<HierarchySearchTree[]> {\n return firstValueFrom(\n from(paths).pipe(\n releaseMainThreadOnItemsCount(1000),\n reduce((builder, path) => builder.accept({ path }), createBuilder()),\n map((builder) => builder.getTree()),\n ),\n );\n }\n\n /**\n * Merges two `HierarchySearchTree` option objects. For the `autoExpand` attribute,\n * `true` takes precedence over `{ groupingLevel }`, and when both sides are\n * `{ groupingLevel }` objects the larger value wins.\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchTree[\"options\"] | undefined,\n rhs: HierarchySearchTree[\"options\"] | undefined,\n ): HierarchySearchTree[\"options\"] | undefined {\n if (!lhs) {\n return rhs;\n }\n if (!rhs) {\n return lhs;\n }\n const autoExpand = mergeSearchTreeAutoExpandOption(lhs.autoExpand, rhs.autoExpand);\n const options: NonNullable<HierarchySearchTree[\"options\"]> = {\n ...(autoExpand ? { autoExpand } : undefined),\n };\n return Object.keys(options).length > 0 ? options : undefined;\n }\n\n function mergeSearchTreeAutoExpandOption(\n lhs: NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined,\n rhs: NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined,\n ): NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined {\n if (!lhs) {\n return rhs;\n }\n if (!rhs) {\n return lhs;\n }\n return lhs === true || rhs === true ? true : { groupingLevel: Math.max(lhs.groupingLevel, rhs.groupingLevel) };\n }\n}\n\nfunction extractSearchPropsInternal(\n rootLevelSearchProps: HierarchySearchTree[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n):\n | {\n childrenTargetPaths?: HierarchySearchTree[];\n hasSearchTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelSearchProps ? { childrenTargetPaths: rootLevelSearchProps, hasSearchTargetAncestor: false } : undefined;\n }\n const searchProps: {\n childrenTargetPaths?: HierarchySearchTree[];\n hasSearchTargetAncestor: boolean;\n } = {\n ...(parentNode.search?.childrenTargetPaths ? { childrenTargetPaths: parentNode.search.childrenTargetPaths } : undefined),\n hasSearchTargetAncestor: !!parentNode.search?.hasSearchTargetAncestor || !!parentNode.search?.isSearchTarget,\n };\n return searchProps.childrenTargetPaths || searchProps.hasSearchTargetAncestor ? searchProps : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to search the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchySearchHelper(\n rootLevelSearchProps: HierarchySearchTree[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n) {\n const searchProps = extractSearchPropsInternal(rootLevelSearchProps, parentNode);\n const hasSearch = !!searchProps;\n\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n } & (\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {}\n ),\n ): void;\n function saveSearchPropsFromPathsIntoReducer(extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): void | Promise<void>;\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n } & (\n | { pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean }\n | { asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean> }\n | {}\n ),\n ): void | Promise<void> {\n // Passes down matching hierarchy search trees to the reducer.\n // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` in the search tree item's identifier matches the node\n // and if it does, the path is passed down to the reducer.\n // This function returns a promise only if `asyncPathMatcher` returns a promise.\n if (!searchProps?.childrenTargetPaths) {\n return;\n }\n const matchedTreePromises = new Array<Promise<HierarchySearchTree | undefined>>();\n for (const childrenSearchTree of searchProps.childrenTargetPaths) {\n if (\"asyncPathMatcher\" in extractionProps) {\n const matchesPossiblyPromise = extractionProps.asyncPathMatcher(childrenSearchTree.identifier);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedTreePromises.push(matchesPossiblyPromise.then((matches) => (matches ? childrenSearchTree : undefined)));\n } else if (matchesPossiblyPromise) {\n extractionProps.pathsReducer.accept(childrenSearchTree);\n }\n } else {\n const matches =\n \"pathMatcher\" in extractionProps\n ? extractionProps.pathMatcher(childrenSearchTree.identifier)\n : nodeKeyMatchesIdentifier(extractionProps.nodeKey, childrenSearchTree.identifier);\n if (matches) {\n extractionProps.pathsReducer.accept(childrenSearchTree);\n }\n }\n }\n if (matchedTreePromises.length === 0) {\n return;\n }\n return Promise.all(matchedTreePromises).then((matchedTrees) =>\n matchedTrees.forEach((matchedTree) => matchedTree && extractionProps.pathsReducer.accept(matchedTree)),\n );\n }\n\n function createChildNodeProps(props: { nodeKey: InstancesNodeKey | GenericNodeKey }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(\n props: { nodeKey: InstancesNodeKey | GenericNodeKey } & (\n | {\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {}\n ),\n ): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined {\n if (!hasSearch) {\n return undefined;\n }\n\n const reducer = new MatchingSearchPathsReducer(searchProps.hasSearchTargetAncestor);\n if (\"asyncPathMatcher\" in props) {\n const extractResult = saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, nodeKey: props.nodeKey, asyncPathMatcher: props.asyncPathMatcher });\n if (extractResult instanceof Promise) {\n return extractResult.then(() => reducer.aggregatedOptions);\n }\n } else {\n saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, ...props });\n }\n return reducer.aggregatedOptions;\n }\n\n return {\n /** Returns a flag indicating if the hierarchy level is filtered. */\n hasSearch,\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a search target. That generally means that this and all downstream hierarchy\n * levels should be displayed without search being applied to them, even if search paths\n * say otherwise.\n */\n hasSearchTargetAncestor: searchProps?.hasSearchTargetAncestor ?? false,\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if search is not applied to this level.\n */\n getChildNodeSearchIdentifiers: () => {\n if (!searchProps?.childrenTargetPaths) {\n return undefined;\n }\n return searchProps.childrenTargetPaths.map(({ identifier }) => identifier);\n },\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `search`\n * and `autoExpand`) to be set based on the search paths and search options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` or `asyncPathMatcher` 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 * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:\n * - `asyncPathMatcher` is provided - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a `Promise`.\n * - `pathMatcher` or only `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;\n */\n createChildNodeProps,\n };\n}\n\nfunction nodeKeyMatchesIdentifier(nodeKey: InstancesNodeKey | GenericNodeKey, identifier: HierarchyNodeIdentifier): boolean {\n return (\n (HierarchyNodeKey.isGeneric(nodeKey) && HierarchyNodeIdentifier.equal(identifier, nodeKey)) ||\n (HierarchyNodeKey.isInstances(nodeKey) && nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(identifier, ik)))\n );\n}\n\n/**\n * Extracts information from search paths and later returns `search` and `autoExpand` values from `HierarchyNode`.\n *\n * Saved values can be applied to a single `HierarchyNode` - this means that a new reducer should be created every time these props are requested for a `HierarchyNode`.\n *\n * Extracts information using `accept` function:\n * - Determines if node is search target, and if it is saves the options as `searchTargetOptions`\n * - Saves `HierarchySearchPathOptions` and `childrenTargetPaths`\n */\nclass MatchingSearchPathsReducer {\n private _childrenTargetPaths = new Array<HierarchySearchTree>();\n private _isSearchTarget = false;\n private _options: HierarchySearchTree[\"options\"] | undefined = undefined;\n\n public constructor(private _hasSearchTargetAncestor: boolean) {}\n\n public accept(tree: HierarchySearchTree): void {\n if (tree.isTarget || tree.children === undefined) {\n this._isSearchTarget = true;\n }\n if (tree.children && tree.children.length > 0) {\n this._childrenTargetPaths.push(...tree.children);\n }\n this._options = HierarchySearchTree.mergeOptions(this._options, tree.options);\n }\n\n public get aggregatedOptions() {\n const search =\n this._hasSearchTargetAncestor || this._isSearchTarget || this._childrenTargetPaths.length > 0 || this._options\n ? {\n ...(this._hasSearchTargetAncestor ? { hasSearchTargetAncestor: true } : undefined),\n ...(this._isSearchTarget ? { isSearchTarget: true } : undefined),\n ...(this._childrenTargetPaths.length > 0 ? { childrenTargetPaths: this._childrenTargetPaths } : undefined),\n ...(this._options ? { options: this._options } : undefined),\n }\n : undefined;\n const autoExpand = this._options?.autoExpand === true;\n return {\n ...(search ? { search } : undefined),\n ...(autoExpand ? { autoExpand } : undefined),\n };\n }\n}\n"]}
|
|
@@ -165,7 +165,11 @@ export declare namespace HierarchySearchTree {
|
|
|
165
165
|
inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;
|
|
166
166
|
}) => void;
|
|
167
167
|
}
|
|
168
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Props supplied to HierarchySearchTreeBuilder.accept() method for accepting a hierarchy search path or tree with an optional handler for customizing
|
|
170
|
+
* the behavior of the builder when accepting new entries.
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
169
173
|
type HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras extends Record<string, unknown>> = ({
|
|
170
174
|
path: HierarchySearchPath;
|
|
171
175
|
} | {
|
|
@@ -174,6 +178,24 @@ export declare namespace HierarchySearchTree {
|
|
|
174
178
|
/** An optional handler for customizing the behavior of the builder when accepting new entries. */
|
|
175
179
|
handler?: HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;
|
|
176
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Props supplied to HierarchySearchTreeBuilder.getTree() method for customizing the resulting tree entries, e.g. by omitting some of them or
|
|
183
|
+
* assigning extra information to them.
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
interface HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras extends Record<string, unknown>> {
|
|
187
|
+
/**
|
|
188
|
+
* A function that can be used to process each tree entry before it's added to the final tree.
|
|
189
|
+
*
|
|
190
|
+
* Return `undefined` to omit the entry and its entire branch from the resulting tree.
|
|
191
|
+
*/
|
|
192
|
+
processEntry?: (props: {
|
|
193
|
+
treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>;
|
|
194
|
+
parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>>;
|
|
195
|
+
}) => (Omit<HierarchySearchTree, "children"> & {
|
|
196
|
+
extras: TAcceptHandlerExtras;
|
|
197
|
+
}) | undefined;
|
|
198
|
+
}
|
|
177
199
|
/**
|
|
178
200
|
* An utility that accepts hierarchy search paths or search trees one by one and builds a `HierarchySearchTree` structure based on them.
|
|
179
201
|
* @public
|
|
@@ -187,7 +209,7 @@ export declare namespace HierarchySearchTree {
|
|
|
187
209
|
/**
|
|
188
210
|
* Create `HierarchySearchTree[]` from currently added search paths.
|
|
189
211
|
*/
|
|
190
|
-
getTree(): HierarchySearchTree[];
|
|
212
|
+
getTree(props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>): HierarchySearchTree[];
|
|
191
213
|
}
|
|
192
214
|
/**
|
|
193
215
|
* Create a `HierarchySearchTree` builder utility that accepts hierarchy search paths or search trees one by one and builds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchySearch.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAIvE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9E,cAAc;AACd,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,MAAM,CAAC,EACH,OAAO,GACP;QACE;;;;;;;;;;;;;;;;;WAiBG;QACH,WAAW,EAAE,MAAM,CAAC;KACrB,GACD;QACE;;;;;;WAMG;QACH,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACN;;;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G;;IAEH;;;OAGG;;IAOH;;;;;;;;;;;;OAYG;;gBApEgC;YAAE,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAAA;SAAE,GAAG,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,SAAS;gBACpH;YACnC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAAC;YAC3C,WAAW,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,CAAC;SAC/D,GAAG,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,SAAS;gBAClC;YACnC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAAC;YAC3C,gBAAgB,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;SACvF,GAAG,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,SAAS;;EA+DvJ"}
|
|
@@ -91,10 +91,20 @@ export var HierarchySearchTree;
|
|
|
91
91
|
var _a;
|
|
92
92
|
return new (class Impl {
|
|
93
93
|
#rootsDictionary = new Dictionary(HierarchyNodeIdentifier.compare);
|
|
94
|
-
static #mapDictionaryToTree(dictionary) {
|
|
94
|
+
static #mapDictionaryToTree(dictionary, parentEntries, props) {
|
|
95
95
|
const list = [];
|
|
96
|
-
for (const { children,
|
|
97
|
-
|
|
96
|
+
for (const { children, ...entry } of dictionary.values()) {
|
|
97
|
+
let processedEntry = entry;
|
|
98
|
+
if (props?.processEntry) {
|
|
99
|
+
processedEntry = props.processEntry({ treeEntry: entry, parentEntries });
|
|
100
|
+
}
|
|
101
|
+
if (!processedEntry) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const { extras: _, ...entryWithoutExtras } = processedEntry;
|
|
105
|
+
parentEntries.push(processedEntry);
|
|
106
|
+
list.push({ ...entryWithoutExtras, ...(children ? { children: Impl.#mapDictionaryToTree(children, parentEntries, props) } : undefined) });
|
|
107
|
+
parentEntries.pop();
|
|
98
108
|
}
|
|
99
109
|
return list;
|
|
100
110
|
}
|
|
@@ -246,8 +256,8 @@ export var HierarchySearchTree;
|
|
|
246
256
|
}
|
|
247
257
|
return this;
|
|
248
258
|
}
|
|
249
|
-
getTree() {
|
|
250
|
-
return Impl.#mapDictionaryToTree(this.#rootsDictionary);
|
|
259
|
+
getTree(props) {
|
|
260
|
+
return Impl.#mapDictionaryToTree(this.#rootsDictionary, [], props);
|
|
251
261
|
}
|
|
252
262
|
})();
|
|
253
263
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchySearch.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AA+D1F,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,mBAAmB,CAgEnC;AAhED,WAAiB,mBAAmB;IAClC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAA2B;QACnD,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;IALe,6BAAS,YAKxB,CAAA;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,YAAY,CAC1B,GAA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AG,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC1G,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;aAC5D;YACH,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC;QACtD,OAAO;YACL,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YACpC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7C,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 { firstValueFrom, from, map, reduce } from \"rxjs\";\nimport { Dictionary } from \"@itwin/core-bentley\";\nimport { HierarchyNodeIdentifier } from \"./HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey } from \"./HierarchyNodeKey.js\";\nimport { releaseMainThreadOnItemsCount } from \"./internal/operators/ReleaseMainThread.js\";\n\nimport type { NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport type { HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport type { GenericNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface HierarchySearchPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the searched hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the search target will have `autoExpand` flag.\n * - If it's a object with `groupingLevel` then `groupingLevel` determines the number of grouping levels to expand for\n * the search target.\n */\n reveal?:\n | boolean\n | {\n /**\n * Index of the node in search path should be revealed in hierarchy by auto-expanding its ancestors.\n *\n * Use when you want to expand up to specific instance node and don't care about grouping nodes.\n *\n * **Use case example:**\n *\n * All nodes up to `Element1` should be expanded in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n *\n * Provide `{ path: [Node1, Element1], reveal: { depthInPath: 1 } }`\n *\n * **NOTE**: All nodes that are up to `depthInPath` will be expanded **except** search targets.\n */\n depthInPath: number;\n }\n | {\n /**\n * The number of grouping levels to expand for the search target. For example, if `groupingLevel` is set to `2`, then all grouping nodes up to the second level\n * will have the `autoExpand` flag.\n *\n * **Note:** if search target has less grouping levels than specified by this attribute, then all grouping nodes up to the search target will have\n * the `autoExpand` flag, but the search target itself won't have the `autoExpand` flag.\n */\n groupingLevel: number;\n };\n /**\n * This option specifies whether or not search target should be expanded.\n * - If it's `false` or `undefined`, search target won't have 'autoExpand' flag.\n * - If it's `true`, search target will have `autoExpand` flag.\n *\n * **Note:** this attribute does not set `autoExpand` flag on nodes up to the search target. For that use `reveal`.\n */\n autoExpand?: boolean;\n}\n\n/**\n * A path of hierarchy node identifiers for search the hierarchy with additional options.\n * @public\n */\nexport type HierarchySearchPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchySearchPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchySearchPath {\n /**\n * Normalizes the hierarchy search path to the object form.\n * @public\n */\n export function normalize(source: HierarchySearchPath): Exclude<HierarchySearchPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchySearchPathOptions` objects.\n *\n * For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if only one of the inputs is an object, return it,\n * - else if both inputs are falsy, return `false` or `undefined`,\n * - else:\n * - if only one of the inputs has `groupingLevel` set, return that one,\n * - else compare by matching reveal type (`groupingLevel` or `depthInPath`) and return the deeper one.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchPathOptions | undefined,\n rhs: HierarchySearchPathOptions | undefined,\n ): HierarchySearchPathOptions | undefined {\n const reveal = mergeRevealOptions(lhs?.reveal, rhs?.reveal);\n const autoExpand = mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);\n return reveal || autoExpand\n ? {\n ...(reveal !== undefined ? { reveal } : undefined),\n ...(autoExpand !== undefined ? { autoExpand } : undefined),\n }\n : undefined;\n }\n function mergeRevealOptions(lhs: HierarchySearchPathOptions[\"reveal\"], rhs: HierarchySearchPathOptions[\"reveal\"]): HierarchySearchPathOptions[\"reveal\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n if (\"groupingLevel\" in lhs) {\n if (\"groupingLevel\" in rhs) {\n return lhs.groupingLevel > rhs.groupingLevel ? lhs : rhs;\n }\n return lhs;\n } else if (\"groupingLevel\" in rhs) {\n return rhs;\n }\n\n return lhs.depthInPath > rhs.depthInPath ? lhs : rhs;\n }\n\n function mergeAutoExpandOption(\n lhs: HierarchySearchPathOptions[\"autoExpand\"],\n rhs: HierarchySearchPathOptions[\"autoExpand\"],\n ): HierarchySearchPathOptions[\"autoExpand\"] {\n return lhs || rhs ? true : undefined;\n }\n}\n\n/**\n * A tree structure representing hierarchy search paths. Each node in the tree corresponds\n * to a hierarchy node identifier and may have children that represent deeper levels in the\n * hierarchy.\n *\n * The `HierarchySearchTree.createBuilder` or `HierarchySearchTree.createFromPathsList` are\n * typically used create this tree from a flat list of search paths.\n *\n * @public\n */\nexport interface HierarchySearchTree {\n /** Identifier of the hierarchy node this tree entry represents. */\n identifier: HierarchyNodeIdentifier;\n\n /**\n * When `true`, indicates that this node is a search target.\n *\n * Note: A `HierarchySearchTree` node is considered a search target if it has no children, even if `isTarget` is not explicitly set to `true`. This\n * is because a node with no children represents the end of a search path.\n */\n isTarget?: boolean;\n\n /** Provides options for handling this search tree entry, such as auto-expansion behavior. */\n options?: {\n /**\n * - `true` to expand the node and its grouping nodes,\n * - `{ groupingLevel: number }` to expand ancestor grouping nodes, e.g. for the following hierarchy:\n * ```\n * - Grouping node A\n * - Instance node A\n * - Grouping node B1\n * - Grouping node B2\n * - ...\n * - Grouping node Bn\n * - Instance node B\n * ```\n *\n * For \"Instance node B\" search tree entry:\n * - `{ groupingLevel: 1 }` expands its first grouping node \"Grouping node B1\",\n * - `{ groupingLevel: 2 }` expands two levels to \"Grouping node B2\".\n * - `{ groupingLevel: Number.MAX_SAFE_INTEGER }` expands all grouping nodes of that instance node.\n *\n * Note that there's a slight difference between `HierarchySearchTree.options.autoExpand` and\n * `HierarchySearchPath.options.reveal`. The latter option reveals the search target node by expanding its ancestors,\n * while the `HierarchySearchTree.options.autoExpand` also expands the target node itself.\n */\n autoExpand?: boolean | { groupingLevel: number };\n };\n\n /** Child search tree entries representing the next level(s) in the hierarchy search paths. */\n children?: HierarchySearchTree[];\n}\n\n/** @public */\nexport namespace HierarchySearchTree {\n /** @public */\n type HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras extends Record<string, unknown>> = Readonly<\n Pick<HierarchySearchTree, \"identifier\" | \"options\"> & {\n extras: TExtras;\n }\n > &\n Pick<HierarchySearchTree, \"isTarget\">;\n /** @public */\n type HierarchySearchTreeBuilderAcceptHandlerTreeInput = Readonly<Pick<HierarchySearchTree, \"identifier\" | \"isTarget\" | \"options\"> & { hasChildren: boolean }>;\n /** @public */\n interface HierarchySearchTreeBuilderAcceptHandler<TExtras extends Record<string, unknown>> {\n /**\n * Called when a new entry is added to the tree. Return `true` to accept the entry, `false` to reject it and all its children, if any.\n */\n onNewEntry?: (props: {\n /** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;\n /** The new entry being added to the tree. */\n inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;\n }) => boolean;\n /**\n * Called when a new entry is added to the tree and accepted (either it's a new entry or it merges with an existing entry). This can be used to perform\n * side effects such as assigning extra information to the tree entry.\n */\n onEntryHandled?: (props: {\n /** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;\n /** The tree entry that has been handled. It's allowed to mutate this entry. */\n treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>;\n /** The input entry being added to the tree. */\n inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;\n }) => void;\n }\n /** @public */\n type HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras extends Record<string, unknown>> = (\n | { path: HierarchySearchPath }\n | { tree: HierarchySearchTree }\n ) & {\n /** An optional handler for customizing the behavior of the builder when accepting new entries. */\n handler?: HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;\n };\n /**\n * An utility that accepts hierarchy search paths or search trees one by one and builds a `HierarchySearchTree` structure based on them.\n * @public\n */\n interface HierarchySearchTreeBuilder<TAcceptHandlerExtras extends Record<string, unknown>> {\n /**\n * Accepts a hierarchy search path or paths' tree and adds it to the builder's internal tree structure. Use `getTree()` to create\n * a `HierarchySearchTree[]` from the added paths.\n */\n accept(props: HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras>): HierarchySearchTreeBuilder<TAcceptHandlerExtras>;\n /**\n * Create `HierarchySearchTree[]` from currently added search paths.\n */\n getTree(): HierarchySearchTree[];\n }\n\n /**\n * Create a `HierarchySearchTree` builder utility that accepts hierarchy search paths or search trees one by one and builds\n * a `HierarchySearchTree` structure based on them.\n *\n * Usage example:\n *\n * ```ts\n * const builder = HierarchySearchTree.createBuilder();\n * for (const path of searchPaths) {\n * builder.accept({ path });\n * }\n * const searchTree = builder.getTree();\n * ```\n *\n * @public\n */\n export function createBuilder<\n TAcceptHandlerExtras extends Record<string, unknown> = Record<string, unknown>,\n >(): HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n type HierarchySearchTreeDictionaryEntry = Omit<HierarchySearchTree, \"children\"> & {\n children?: HierarchySearchTreeDictionary;\n extras: TAcceptHandlerExtras;\n };\n type HierarchySearchTreeDictionary = Dictionary<HierarchyNodeIdentifier, HierarchySearchTreeDictionaryEntry>;\n type AcceptHandler = HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;\n return new (class Impl implements HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n #rootsDictionary: HierarchySearchTreeDictionary = new Dictionary(HierarchyNodeIdentifier.compare);\n\n static #mapDictionaryToTree(dictionary: HierarchySearchTreeDictionary): HierarchySearchTree[] {\n const list: HierarchySearchTree[] = [];\n for (const { children, extras: _, ...entry } of dictionary.values()) {\n list.push({ ...entry, ...(children ? { children: Impl.#mapDictionaryToTree(children) } : undefined) });\n }\n return list;\n }\n\n static #assignAutoExpandOptionsBasedOnReveal(\n treePath: Pick<HierarchySearchTree, \"options\">[],\n revealOption: HierarchySearchPathOptions[\"reveal\"] | undefined,\n ) {\n if (revealOption === true) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // auto-expand all grouping nodes of the revealed node\n return { autoExpand: { groupingLevel: Number.MAX_SAFE_INTEGER } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n } else if (revealOption && \"groupingLevel\" in revealOption) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // the last entry should have `autoExpand` with `groupingLevel` set to the value based on `reveal.groupingLevel`\n return { autoExpand: { groupingLevel: Math.max(revealOption.groupingLevel - 1, 0) } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n } else if (revealOption && \"depthInPath\" in revealOption) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: Math.min(revealOption.depthInPath, treePath.length - 1),\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // auto-expand all grouping nodes of the revealed node\n return { autoExpand: { groupingLevel: Number.MAX_SAFE_INTEGER } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n }\n }\n\n static #assignOptionsOnTreePath({\n treePath,\n targetEntryIndex,\n getEntryOptions,\n }: {\n treePath: Array<Pick<HierarchySearchTree, \"options\">>;\n targetEntryIndex: number;\n getEntryOptions: (index: number, targetEntryIndex: number) => HierarchySearchTree[\"options\"] | undefined;\n }) {\n // set all parent entries to auto-expand\n for (let i = 0; i <= targetEntryIndex; i++) {\n const options = mergeOptions(treePath[i].options, getEntryOptions(i, targetEntryIndex));\n if (options) {\n treePath[i].options = options;\n }\n }\n }\n\n #acceptNode({\n parentEntries,\n level,\n node,\n handler,\n }: {\n parentEntries: HierarchySearchTreeDictionaryEntry[];\n level: HierarchySearchTreeDictionary;\n node: Pick<HierarchySearchTree, \"identifier\" | \"isTarget\"> & { hasChildren: boolean };\n handler?: AcceptHandler;\n }): HierarchySearchTreeDictionaryEntry | undefined {\n let entry = level.get(node.identifier);\n if (!entry) {\n if (handler?.onNewEntry && !handler.onNewEntry({ parentEntries, inputEntry: node })) {\n return undefined;\n }\n entry = {\n identifier: node.identifier,\n children: node.hasChildren ? new Dictionary(HierarchyNodeIdentifier.compare) : undefined,\n extras: {} as TAcceptHandlerExtras,\n };\n level.set(node.identifier, entry);\n }\n\n const isNodeSearchTarget = node.isTarget || !node.hasChildren;\n if (isNodeSearchTarget && entry.children) {\n entry.isTarget = true;\n }\n if (!entry.children && node.hasChildren) {\n // Existing leaf nodes are implied targets. Preserve that status when adding children.\n entry.isTarget = true;\n entry.children = new Dictionary(HierarchyNodeIdentifier.compare);\n }\n handler?.onEntryHandled?.({ parentEntries, treeEntry: entry, inputEntry: node });\n return entry;\n }\n\n #acceptPath({ path, handler }: { path: HierarchySearchPath; handler?: AcceptHandler }) {\n const normalized = HierarchySearchPath.normalize(path);\n const treePath: Array<HierarchySearchTreeDictionaryEntry> = [];\n let currentLevel: HierarchySearchTreeDictionary = this.#rootsDictionary;\n for (let i = 0; i < normalized.path.length; i++) {\n const identifier = normalized.path[i];\n const acceptedNode = this.#acceptNode({\n parentEntries: treePath,\n node: { identifier, hasChildren: i < normalized.path.length - 1 },\n level: currentLevel,\n handler,\n });\n if (!acceptedNode) {\n break;\n }\n treePath.push(acceptedNode);\n if (!acceptedNode.children) {\n break;\n }\n currentLevel = acceptedNode.children;\n }\n\n if (treePath.length === 0) {\n return;\n }\n\n // handle auto-expand\n const lastNode = treePath[treePath.length - 1];\n if (normalized.options?.autoExpand) {\n (lastNode.options ??= {}).autoExpand = true;\n }\n\n // handle auto-reveal\n Impl.#assignAutoExpandOptionsBasedOnReveal(treePath, normalized.options?.reveal);\n }\n\n #acceptTree({ tree, handler }: { tree: HierarchySearchTree; handler?: AcceptHandler }) {\n const acceptTreeNode = (\n parentEntries: HierarchySearchTreeDictionaryEntry[],\n parentInputs: HierarchySearchTree[],\n level: HierarchySearchTreeDictionary,\n node: HierarchySearchTree,\n ) => {\n const acceptedNode = this.#acceptNode({\n parentEntries,\n node: { ...node, hasChildren: node.children !== undefined },\n level,\n handler,\n });\n if (!acceptedNode) {\n // It was decided to reject this node and its children, if any\n return;\n }\n const treePath = [...parentEntries, acceptedNode];\n const inputsPath = [...parentInputs, node];\n if (!node.children || node.isTarget) {\n // Found an effective search target - merge options from its path\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index) => inputsPath[index].options,\n });\n }\n const currentLevel = acceptedNode.children;\n if (currentLevel) {\n node.children?.forEach((child) => acceptTreeNode(treePath, inputsPath, currentLevel, child));\n }\n };\n acceptTreeNode([], [], this.#rootsDictionary, tree);\n }\n\n public accept(\n props: ({ path: HierarchySearchPath } | { tree: HierarchySearchTree }) & { handler?: AcceptHandler },\n ): HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n if (\"path\" in props) {\n this.#acceptPath(props);\n } else {\n this.#acceptTree(props);\n }\n return this;\n }\n\n public getTree() {\n return Impl.#mapDictionaryToTree(this.#rootsDictionary);\n }\n })();\n }\n\n /**\n * Builds a list of `HierarchySearchTree` nodes from an iterable of search paths. Shared\n * path prefixes are merged so that each unique hierarchy node identifier appears only once\n * per level. The resulting trees carry `isTarget`, `options`, and `children` attributes\n * derived from the paths and their options (`autoExpand`, `reveal`).\n *\n * @public\n */\n export async function createFromPathsList(paths: Iterable<HierarchySearchPath>): Promise<HierarchySearchTree[]> {\n return firstValueFrom(\n from(paths).pipe(\n releaseMainThreadOnItemsCount(1000),\n reduce((builder, path) => builder.accept({ path }), createBuilder()),\n map((builder) => builder.getTree()),\n ),\n );\n }\n\n /**\n * Merges two `HierarchySearchTree` option objects. For the `autoExpand` attribute,\n * `true` takes precedence over `{ groupingLevel }`, and when both sides are\n * `{ groupingLevel }` objects the larger value wins.\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchTree[\"options\"] | undefined,\n rhs: HierarchySearchTree[\"options\"] | undefined,\n ): HierarchySearchTree[\"options\"] | undefined {\n if (!lhs) {\n return rhs;\n }\n if (!rhs) {\n return lhs;\n }\n const autoExpand = mergeSearchTreeAutoExpandOption(lhs.autoExpand, rhs.autoExpand);\n const options: NonNullable<HierarchySearchTree[\"options\"]> = {\n ...(autoExpand ? { autoExpand } : undefined),\n };\n return Object.keys(options).length > 0 ? options : undefined;\n }\n\n function mergeSearchTreeAutoExpandOption(\n lhs: NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined,\n rhs: NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined,\n ): NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined {\n if (!lhs) {\n return rhs;\n }\n if (!rhs) {\n return lhs;\n }\n return lhs === true || rhs === true ? true : { groupingLevel: Math.max(lhs.groupingLevel, rhs.groupingLevel) };\n }\n}\n\nfunction extractSearchPropsInternal(\n rootLevelSearchProps: HierarchySearchTree[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n):\n | {\n childrenTargetPaths?: HierarchySearchTree[];\n hasSearchTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelSearchProps ? { childrenTargetPaths: rootLevelSearchProps, hasSearchTargetAncestor: false } : undefined;\n }\n const searchProps: {\n childrenTargetPaths?: HierarchySearchTree[];\n hasSearchTargetAncestor: boolean;\n } = {\n ...(parentNode.search?.childrenTargetPaths ? { childrenTargetPaths: parentNode.search.childrenTargetPaths } : undefined),\n hasSearchTargetAncestor: !!parentNode.search?.hasSearchTargetAncestor || !!parentNode.search?.isSearchTarget,\n };\n return searchProps.childrenTargetPaths || searchProps.hasSearchTargetAncestor ? searchProps : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to search the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchySearchHelper(\n rootLevelSearchProps: HierarchySearchTree[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n) {\n const searchProps = extractSearchPropsInternal(rootLevelSearchProps, parentNode);\n const hasSearch = !!searchProps;\n\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n } & (\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {}\n ),\n ): void;\n function saveSearchPropsFromPathsIntoReducer(extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): void | Promise<void>;\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n } & (\n | { pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean }\n | { asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean> }\n | {}\n ),\n ): void | Promise<void> {\n // Passes down matching hierarchy search trees to the reducer.\n // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` in the search tree item's identifier matches the node\n // and if it does, the path is passed down to the reducer.\n // This function returns a promise only if `asyncPathMatcher` returns a promise.\n if (!searchProps?.childrenTargetPaths) {\n return;\n }\n const matchedTreePromises = new Array<Promise<HierarchySearchTree | undefined>>();\n for (const childrenSearchTree of searchProps.childrenTargetPaths) {\n if (\"asyncPathMatcher\" in extractionProps) {\n const matchesPossiblyPromise = extractionProps.asyncPathMatcher(childrenSearchTree.identifier);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedTreePromises.push(matchesPossiblyPromise.then((matches) => (matches ? childrenSearchTree : undefined)));\n } else if (matchesPossiblyPromise) {\n extractionProps.pathsReducer.accept(childrenSearchTree);\n }\n } else {\n const matches =\n \"pathMatcher\" in extractionProps\n ? extractionProps.pathMatcher(childrenSearchTree.identifier)\n : nodeKeyMatchesIdentifier(extractionProps.nodeKey, childrenSearchTree.identifier);\n if (matches) {\n extractionProps.pathsReducer.accept(childrenSearchTree);\n }\n }\n }\n if (matchedTreePromises.length === 0) {\n return;\n }\n return Promise.all(matchedTreePromises).then((matchedTrees) =>\n matchedTrees.forEach((matchedTree) => matchedTree && extractionProps.pathsReducer.accept(matchedTree)),\n );\n }\n\n function createChildNodeProps(props: { nodeKey: InstancesNodeKey | GenericNodeKey }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(\n props: { nodeKey: InstancesNodeKey | GenericNodeKey } & (\n | {\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {}\n ),\n ): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined {\n if (!hasSearch) {\n return undefined;\n }\n\n const reducer = new MatchingSearchPathsReducer(searchProps.hasSearchTargetAncestor);\n if (\"asyncPathMatcher\" in props) {\n const extractResult = saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, nodeKey: props.nodeKey, asyncPathMatcher: props.asyncPathMatcher });\n if (extractResult instanceof Promise) {\n return extractResult.then(() => reducer.aggregatedOptions);\n }\n } else {\n saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, ...props });\n }\n return reducer.aggregatedOptions;\n }\n\n return {\n /** Returns a flag indicating if the hierarchy level is filtered. */\n hasSearch,\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a search target. That generally means that this and all downstream hierarchy\n * levels should be displayed without search being applied to them, even if search paths\n * say otherwise.\n */\n hasSearchTargetAncestor: searchProps?.hasSearchTargetAncestor ?? false,\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if search is not applied to this level.\n */\n getChildNodeSearchIdentifiers: () => {\n if (!searchProps?.childrenTargetPaths) {\n return undefined;\n }\n return searchProps.childrenTargetPaths.map(({ identifier }) => identifier);\n },\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `search`\n * and `autoExpand`) to be set based on the search paths and search options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` or `asyncPathMatcher` 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 * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:\n * - `asyncPathMatcher` is provided - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a `Promise`.\n * - `pathMatcher` or only `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;\n */\n createChildNodeProps,\n };\n}\n\nfunction nodeKeyMatchesIdentifier(nodeKey: InstancesNodeKey | GenericNodeKey, identifier: HierarchyNodeIdentifier): boolean {\n return (\n (HierarchyNodeKey.isGeneric(nodeKey) && HierarchyNodeIdentifier.equal(identifier, nodeKey)) ||\n (HierarchyNodeKey.isInstances(nodeKey) && nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(identifier, ik)))\n );\n}\n\n/**\n * Extracts information from search paths and later returns `search` and `autoExpand` values from `HierarchyNode`.\n *\n * Saved values can be applied to a single `HierarchyNode` - this means that a new reducer should be created every time these props are requested for a `HierarchyNode`.\n *\n * Extracts information using `accept` function:\n * - Determines if node is search target, and if it is saves the options as `searchTargetOptions`\n * - Saves `HierarchySearchPathOptions` and `childrenTargetPaths`\n */\nclass MatchingSearchPathsReducer {\n private _childrenTargetPaths = new Array<HierarchySearchTree>();\n private _isSearchTarget = false;\n private _options: HierarchySearchTree[\"options\"] | undefined = undefined;\n\n public constructor(private _hasSearchTargetAncestor: boolean) {}\n\n public accept(tree: HierarchySearchTree): void {\n if (tree.isTarget || tree.children === undefined) {\n this._isSearchTarget = true;\n }\n if (tree.children && tree.children.length > 0) {\n this._childrenTargetPaths.push(...tree.children);\n }\n this._options = HierarchySearchTree.mergeOptions(this._options, tree.options);\n }\n\n public get aggregatedOptions() {\n const search =\n this._hasSearchTargetAncestor || this._isSearchTarget || this._childrenTargetPaths.length > 0 || this._options\n ? {\n ...(this._hasSearchTargetAncestor ? { hasSearchTargetAncestor: true } : undefined),\n ...(this._isSearchTarget ? { isSearchTarget: true } : undefined),\n ...(this._childrenTargetPaths.length > 0 ? { childrenTargetPaths: this._childrenTargetPaths } : undefined),\n ...(this._options ? { options: this._options } : undefined),\n }\n : undefined;\n const autoExpand = this._options?.autoExpand === true;\n return {\n ...(search ? { search } : undefined),\n ...(autoExpand ? { autoExpand } : undefined),\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HierarchySearch.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AA+D1F,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,mBAAmB,CAgEnC;AAhED,WAAiB,mBAAmB;IAClC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAA2B;QACnD,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;IALe,6BAAS,YAKxB,CAAA;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,YAAY,CAC1B,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C,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAChF,CAAC;IAED,IAAW,iBAAiB;QAC1B,MAAM,MAAM,GACV,IAAI,CAAC,wBAAwB,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ;YAC5G,CAAC,CAAC;gBACE,GAAG,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAClF,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAChE,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC1G,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;aAC5D;YACH,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC;QACtD,OAAO;YACL,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YACpC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7C,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 { firstValueFrom, from, map, reduce } from \"rxjs\";\nimport { Dictionary } from \"@itwin/core-bentley\";\nimport { HierarchyNodeIdentifier } from \"./HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey } from \"./HierarchyNodeKey.js\";\nimport { releaseMainThreadOnItemsCount } from \"./internal/operators/ReleaseMainThread.js\";\n\nimport type { NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport type { HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport type { GenericNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface HierarchySearchPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the searched hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the search target will have `autoExpand` flag.\n * - If it's a object with `groupingLevel` then `groupingLevel` determines the number of grouping levels to expand for\n * the search target.\n */\n reveal?:\n | boolean\n | {\n /**\n * Index of the node in search path should be revealed in hierarchy by auto-expanding its ancestors.\n *\n * Use when you want to expand up to specific instance node and don't care about grouping nodes.\n *\n * **Use case example:**\n *\n * All nodes up to `Element1` should be expanded in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n *\n * Provide `{ path: [Node1, Element1], reveal: { depthInPath: 1 } }`\n *\n * **NOTE**: All nodes that are up to `depthInPath` will be expanded **except** search targets.\n */\n depthInPath: number;\n }\n | {\n /**\n * The number of grouping levels to expand for the search target. For example, if `groupingLevel` is set to `2`, then all grouping nodes up to the second level\n * will have the `autoExpand` flag.\n *\n * **Note:** if search target has less grouping levels than specified by this attribute, then all grouping nodes up to the search target will have\n * the `autoExpand` flag, but the search target itself won't have the `autoExpand` flag.\n */\n groupingLevel: number;\n };\n /**\n * This option specifies whether or not search target should be expanded.\n * - If it's `false` or `undefined`, search target won't have 'autoExpand' flag.\n * - If it's `true`, search target will have `autoExpand` flag.\n *\n * **Note:** this attribute does not set `autoExpand` flag on nodes up to the search target. For that use `reveal`.\n */\n autoExpand?: boolean;\n}\n\n/**\n * A path of hierarchy node identifiers for search the hierarchy with additional options.\n * @public\n */\nexport type HierarchySearchPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchySearchPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchySearchPath {\n /**\n * Normalizes the hierarchy search path to the object form.\n * @public\n */\n export function normalize(source: HierarchySearchPath): Exclude<HierarchySearchPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchySearchPathOptions` objects.\n *\n * For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if only one of the inputs is an object, return it,\n * - else if both inputs are falsy, return `false` or `undefined`,\n * - else:\n * - if only one of the inputs has `groupingLevel` set, return that one,\n * - else compare by matching reveal type (`groupingLevel` or `depthInPath`) and return the deeper one.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchPathOptions | undefined,\n rhs: HierarchySearchPathOptions | undefined,\n ): HierarchySearchPathOptions | undefined {\n const reveal = mergeRevealOptions(lhs?.reveal, rhs?.reveal);\n const autoExpand = mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);\n return reveal || autoExpand\n ? {\n ...(reveal !== undefined ? { reveal } : undefined),\n ...(autoExpand !== undefined ? { autoExpand } : undefined),\n }\n : undefined;\n }\n function mergeRevealOptions(lhs: HierarchySearchPathOptions[\"reveal\"], rhs: HierarchySearchPathOptions[\"reveal\"]): HierarchySearchPathOptions[\"reveal\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n if (\"groupingLevel\" in lhs) {\n if (\"groupingLevel\" in rhs) {\n return lhs.groupingLevel > rhs.groupingLevel ? lhs : rhs;\n }\n return lhs;\n } else if (\"groupingLevel\" in rhs) {\n return rhs;\n }\n\n return lhs.depthInPath > rhs.depthInPath ? lhs : rhs;\n }\n\n function mergeAutoExpandOption(\n lhs: HierarchySearchPathOptions[\"autoExpand\"],\n rhs: HierarchySearchPathOptions[\"autoExpand\"],\n ): HierarchySearchPathOptions[\"autoExpand\"] {\n return lhs || rhs ? true : undefined;\n }\n}\n\n/**\n * A tree structure representing hierarchy search paths. Each node in the tree corresponds\n * to a hierarchy node identifier and may have children that represent deeper levels in the\n * hierarchy.\n *\n * The `HierarchySearchTree.createBuilder` or `HierarchySearchTree.createFromPathsList` are\n * typically used create this tree from a flat list of search paths.\n *\n * @public\n */\nexport interface HierarchySearchTree {\n /** Identifier of the hierarchy node this tree entry represents. */\n identifier: HierarchyNodeIdentifier;\n\n /**\n * When `true`, indicates that this node is a search target.\n *\n * Note: A `HierarchySearchTree` node is considered a search target if it has no children, even if `isTarget` is not explicitly set to `true`. This\n * is because a node with no children represents the end of a search path.\n */\n isTarget?: boolean;\n\n /** Provides options for handling this search tree entry, such as auto-expansion behavior. */\n options?: {\n /**\n * - `true` to expand the node and its grouping nodes,\n * - `{ groupingLevel: number }` to expand ancestor grouping nodes, e.g. for the following hierarchy:\n * ```\n * - Grouping node A\n * - Instance node A\n * - Grouping node B1\n * - Grouping node B2\n * - ...\n * - Grouping node Bn\n * - Instance node B\n * ```\n *\n * For \"Instance node B\" search tree entry:\n * - `{ groupingLevel: 1 }` expands its first grouping node \"Grouping node B1\",\n * - `{ groupingLevel: 2 }` expands two levels to \"Grouping node B2\".\n * - `{ groupingLevel: Number.MAX_SAFE_INTEGER }` expands all grouping nodes of that instance node.\n *\n * Note that there's a slight difference between `HierarchySearchTree.options.autoExpand` and\n * `HierarchySearchPath.options.reveal`. The latter option reveals the search target node by expanding its ancestors,\n * while the `HierarchySearchTree.options.autoExpand` also expands the target node itself.\n */\n autoExpand?: boolean | { groupingLevel: number };\n };\n\n /** Child search tree entries representing the next level(s) in the hierarchy search paths. */\n children?: HierarchySearchTree[];\n}\n\n/** @public */\nexport namespace HierarchySearchTree {\n /** @public */\n type HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras extends Record<string, unknown>> = Readonly<\n Pick<HierarchySearchTree, \"identifier\" | \"options\"> & {\n extras: TExtras;\n }\n > &\n Pick<HierarchySearchTree, \"isTarget\">;\n /** @public */\n type HierarchySearchTreeBuilderAcceptHandlerTreeInput = Readonly<Pick<HierarchySearchTree, \"identifier\" | \"isTarget\" | \"options\"> & { hasChildren: boolean }>;\n /** @public */\n interface HierarchySearchTreeBuilderAcceptHandler<TExtras extends Record<string, unknown>> {\n /**\n * Called when a new entry is added to the tree. Return `true` to accept the entry, `false` to reject it and all its children, if any.\n */\n onNewEntry?: (props: {\n /** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;\n /** The new entry being added to the tree. */\n inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;\n }) => boolean;\n /**\n * Called when a new entry is added to the tree and accepted (either it's a new entry or it merges with an existing entry). This can be used to perform\n * side effects such as assigning extra information to the tree entry.\n */\n onEntryHandled?: (props: {\n /** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;\n /** The tree entry that has been handled. It's allowed to mutate this entry. */\n treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>;\n /** The input entry being added to the tree. */\n inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;\n }) => void;\n }\n /**\n * Props supplied to HierarchySearchTreeBuilder.accept() method for accepting a hierarchy search path or tree with an optional handler for customizing\n * the behavior of the builder when accepting new entries.\n * @public\n */\n type HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras extends Record<string, unknown>> = (\n | { path: HierarchySearchPath }\n | { tree: HierarchySearchTree }\n ) & {\n /** An optional handler for customizing the behavior of the builder when accepting new entries. */\n handler?: HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;\n };\n /**\n * Props supplied to HierarchySearchTreeBuilder.getTree() method for customizing the resulting tree entries, e.g. by omitting some of them or\n * assigning extra information to them.\n * @public\n */\n interface HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras extends Record<string, unknown>> {\n /**\n * A function that can be used to process each tree entry before it's added to the final tree.\n *\n * Return `undefined` to omit the entry and its entire branch from the resulting tree.\n */\n processEntry?: (props: {\n treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>;\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>>;\n }) => (Omit<HierarchySearchTree, \"children\"> & { extras: TAcceptHandlerExtras }) | undefined;\n }\n /**\n * An utility that accepts hierarchy search paths or search trees one by one and builds a `HierarchySearchTree` structure based on them.\n * @public\n */\n interface HierarchySearchTreeBuilder<TAcceptHandlerExtras extends Record<string, unknown>> {\n /**\n * Accepts a hierarchy search path or paths' tree and adds it to the builder's internal tree structure. Use `getTree()` to create\n * a `HierarchySearchTree[]` from the added paths.\n */\n accept(props: HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras>): HierarchySearchTreeBuilder<TAcceptHandlerExtras>;\n /**\n * Create `HierarchySearchTree[]` from currently added search paths.\n */\n getTree(props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>): HierarchySearchTree[];\n }\n\n /**\n * Create a `HierarchySearchTree` builder utility that accepts hierarchy search paths or search trees one by one and builds\n * a `HierarchySearchTree` structure based on them.\n *\n * Usage example:\n *\n * ```ts\n * const builder = HierarchySearchTree.createBuilder();\n * for (const path of searchPaths) {\n * builder.accept({ path });\n * }\n * const searchTree = builder.getTree();\n * ```\n *\n * @public\n */\n export function createBuilder<\n TAcceptHandlerExtras extends Record<string, unknown> = Record<string, unknown>,\n >(): HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n type HierarchySearchTreeDictionaryEntry = Omit<HierarchySearchTree, \"children\"> & {\n children?: HierarchySearchTreeDictionary;\n extras: TAcceptHandlerExtras;\n };\n type HierarchySearchTreeDictionary = Dictionary<HierarchyNodeIdentifier, HierarchySearchTreeDictionaryEntry>;\n type AcceptHandler = HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;\n return new (class Impl implements HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n #rootsDictionary: HierarchySearchTreeDictionary = new Dictionary(HierarchyNodeIdentifier.compare);\n\n static #mapDictionaryToTree(\n dictionary: HierarchySearchTreeDictionary,\n parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>>,\n props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>,\n ): HierarchySearchTree[] {\n const list: HierarchySearchTree[] = [];\n for (const { children, ...entry } of dictionary.values()) {\n let processedEntry: (Omit<HierarchySearchTree, \"children\"> & { extras: TAcceptHandlerExtras }) | undefined = entry;\n if (props?.processEntry) {\n processedEntry = props.processEntry({ treeEntry: entry, parentEntries });\n }\n if (!processedEntry) {\n continue;\n }\n const { extras: _, ...entryWithoutExtras } = processedEntry;\n parentEntries.push(processedEntry);\n list.push({ ...entryWithoutExtras, ...(children ? { children: Impl.#mapDictionaryToTree(children, parentEntries, props) } : undefined) });\n parentEntries.pop();\n }\n return list;\n }\n\n static #assignAutoExpandOptionsBasedOnReveal(\n treePath: Pick<HierarchySearchTree, \"options\">[],\n revealOption: HierarchySearchPathOptions[\"reveal\"] | undefined,\n ) {\n if (revealOption === true) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // auto-expand all grouping nodes of the revealed node\n return { autoExpand: { groupingLevel: Number.MAX_SAFE_INTEGER } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n } else if (revealOption && \"groupingLevel\" in revealOption) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // the last entry should have `autoExpand` with `groupingLevel` set to the value based on `reveal.groupingLevel`\n return { autoExpand: { groupingLevel: Math.max(revealOption.groupingLevel - 1, 0) } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n } else if (revealOption && \"depthInPath\" in revealOption) {\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: Math.min(revealOption.depthInPath, treePath.length - 1),\n getEntryOptions: (index, targetEntryIndex) => {\n if (index === targetEntryIndex) {\n // auto-expand all grouping nodes of the revealed node\n return { autoExpand: { groupingLevel: Number.MAX_SAFE_INTEGER } };\n }\n // auto-expand all parent nodes\n return { autoExpand: true };\n },\n });\n }\n }\n\n static #assignOptionsOnTreePath({\n treePath,\n targetEntryIndex,\n getEntryOptions,\n }: {\n treePath: Array<Pick<HierarchySearchTree, \"options\">>;\n targetEntryIndex: number;\n getEntryOptions: (index: number, targetEntryIndex: number) => HierarchySearchTree[\"options\"] | undefined;\n }) {\n // set all parent entries to auto-expand\n for (let i = 0; i <= targetEntryIndex; i++) {\n const options = mergeOptions(treePath[i].options, getEntryOptions(i, targetEntryIndex));\n if (options) {\n treePath[i].options = options;\n }\n }\n }\n\n #acceptNode({\n parentEntries,\n level,\n node,\n handler,\n }: {\n parentEntries: HierarchySearchTreeDictionaryEntry[];\n level: HierarchySearchTreeDictionary;\n node: Pick<HierarchySearchTree, \"identifier\" | \"isTarget\"> & { hasChildren: boolean };\n handler?: AcceptHandler;\n }): HierarchySearchTreeDictionaryEntry | undefined {\n let entry = level.get(node.identifier);\n if (!entry) {\n if (handler?.onNewEntry && !handler.onNewEntry({ parentEntries, inputEntry: node })) {\n return undefined;\n }\n entry = {\n identifier: node.identifier,\n children: node.hasChildren ? new Dictionary(HierarchyNodeIdentifier.compare) : undefined,\n extras: {} as TAcceptHandlerExtras,\n };\n level.set(node.identifier, entry);\n }\n\n const isNodeSearchTarget = node.isTarget || !node.hasChildren;\n if (isNodeSearchTarget && entry.children) {\n entry.isTarget = true;\n }\n if (!entry.children && node.hasChildren) {\n // Existing leaf nodes are implied targets. Preserve that status when adding children.\n entry.isTarget = true;\n entry.children = new Dictionary(HierarchyNodeIdentifier.compare);\n }\n handler?.onEntryHandled?.({ parentEntries, treeEntry: entry, inputEntry: node });\n return entry;\n }\n\n #acceptPath({ path, handler }: { path: HierarchySearchPath; handler?: AcceptHandler }) {\n const normalized = HierarchySearchPath.normalize(path);\n const treePath: Array<HierarchySearchTreeDictionaryEntry> = [];\n let currentLevel: HierarchySearchTreeDictionary = this.#rootsDictionary;\n for (let i = 0; i < normalized.path.length; i++) {\n const identifier = normalized.path[i];\n const acceptedNode = this.#acceptNode({\n parentEntries: treePath,\n node: { identifier, hasChildren: i < normalized.path.length - 1 },\n level: currentLevel,\n handler,\n });\n if (!acceptedNode) {\n break;\n }\n treePath.push(acceptedNode);\n if (!acceptedNode.children) {\n break;\n }\n currentLevel = acceptedNode.children;\n }\n\n if (treePath.length === 0) {\n return;\n }\n\n // handle auto-expand\n const lastNode = treePath[treePath.length - 1];\n if (normalized.options?.autoExpand) {\n (lastNode.options ??= {}).autoExpand = true;\n }\n\n // handle auto-reveal\n Impl.#assignAutoExpandOptionsBasedOnReveal(treePath, normalized.options?.reveal);\n }\n\n #acceptTree({ tree, handler }: { tree: HierarchySearchTree; handler?: AcceptHandler }) {\n const acceptTreeNode = (\n parentEntries: HierarchySearchTreeDictionaryEntry[],\n parentInputs: HierarchySearchTree[],\n level: HierarchySearchTreeDictionary,\n node: HierarchySearchTree,\n ) => {\n const acceptedNode = this.#acceptNode({\n parentEntries,\n node: { ...node, hasChildren: node.children !== undefined },\n level,\n handler,\n });\n if (!acceptedNode) {\n // It was decided to reject this node and its children, if any\n return;\n }\n const treePath = [...parentEntries, acceptedNode];\n const inputsPath = [...parentInputs, node];\n if (!node.children || node.isTarget) {\n // Found an effective search target - merge options from its path\n Impl.#assignOptionsOnTreePath({\n treePath,\n targetEntryIndex: treePath.length - 1,\n getEntryOptions: (index) => inputsPath[index].options,\n });\n }\n const currentLevel = acceptedNode.children;\n if (currentLevel) {\n node.children?.forEach((child) => acceptTreeNode(treePath, inputsPath, currentLevel, child));\n }\n };\n acceptTreeNode([], [], this.#rootsDictionary, tree);\n }\n\n public accept(\n props: ({ path: HierarchySearchPath } | { tree: HierarchySearchTree }) & { handler?: AcceptHandler },\n ): HierarchySearchTreeBuilder<TAcceptHandlerExtras> {\n if (\"path\" in props) {\n this.#acceptPath(props);\n } else {\n this.#acceptTree(props);\n }\n return this;\n }\n\n public getTree(props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>) {\n return Impl.#mapDictionaryToTree(this.#rootsDictionary, [], props);\n }\n })();\n }\n\n /**\n * Builds a list of `HierarchySearchTree` nodes from an iterable of search paths. Shared\n * path prefixes are merged so that each unique hierarchy node identifier appears only once\n * per level. The resulting trees carry `isTarget`, `options`, and `children` attributes\n * derived from the paths and their options (`autoExpand`, `reveal`).\n *\n * @public\n */\n export async function createFromPathsList(paths: Iterable<HierarchySearchPath>): Promise<HierarchySearchTree[]> {\n return firstValueFrom(\n from(paths).pipe(\n releaseMainThreadOnItemsCount(1000),\n reduce((builder, path) => builder.accept({ path }), createBuilder()),\n map((builder) => builder.getTree()),\n ),\n );\n }\n\n /**\n * Merges two `HierarchySearchTree` option objects. For the `autoExpand` attribute,\n * `true` takes precedence over `{ groupingLevel }`, and when both sides are\n * `{ groupingLevel }` objects the larger value wins.\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchTree[\"options\"] | undefined,\n rhs: HierarchySearchTree[\"options\"] | undefined,\n ): HierarchySearchTree[\"options\"] | undefined {\n if (!lhs) {\n return rhs;\n }\n if (!rhs) {\n return lhs;\n }\n const autoExpand = mergeSearchTreeAutoExpandOption(lhs.autoExpand, rhs.autoExpand);\n const options: NonNullable<HierarchySearchTree[\"options\"]> = {\n ...(autoExpand ? { autoExpand } : undefined),\n };\n return Object.keys(options).length > 0 ? options : undefined;\n }\n\n function mergeSearchTreeAutoExpandOption(\n lhs: NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined,\n rhs: NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined,\n ): NonNullable<HierarchySearchTree[\"options\"]>[\"autoExpand\"] | undefined {\n if (!lhs) {\n return rhs;\n }\n if (!rhs) {\n return lhs;\n }\n return lhs === true || rhs === true ? true : { groupingLevel: Math.max(lhs.groupingLevel, rhs.groupingLevel) };\n }\n}\n\nfunction extractSearchPropsInternal(\n rootLevelSearchProps: HierarchySearchTree[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n):\n | {\n childrenTargetPaths?: HierarchySearchTree[];\n hasSearchTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelSearchProps ? { childrenTargetPaths: rootLevelSearchProps, hasSearchTargetAncestor: false } : undefined;\n }\n const searchProps: {\n childrenTargetPaths?: HierarchySearchTree[];\n hasSearchTargetAncestor: boolean;\n } = {\n ...(parentNode.search?.childrenTargetPaths ? { childrenTargetPaths: parentNode.search.childrenTargetPaths } : undefined),\n hasSearchTargetAncestor: !!parentNode.search?.hasSearchTargetAncestor || !!parentNode.search?.isSearchTarget,\n };\n return searchProps.childrenTargetPaths || searchProps.hasSearchTargetAncestor ? searchProps : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to search the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchySearchHelper(\n rootLevelSearchProps: HierarchySearchTree[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n) {\n const searchProps = extractSearchPropsInternal(rootLevelSearchProps, parentNode);\n const hasSearch = !!searchProps;\n\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n } & (\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {}\n ),\n ): void;\n function saveSearchPropsFromPathsIntoReducer(extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): void | Promise<void>;\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n } & (\n | { pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean }\n | { asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean> }\n | {}\n ),\n ): void | Promise<void> {\n // Passes down matching hierarchy search trees to the reducer.\n // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` in the search tree item's identifier matches the node\n // and if it does, the path is passed down to the reducer.\n // This function returns a promise only if `asyncPathMatcher` returns a promise.\n if (!searchProps?.childrenTargetPaths) {\n return;\n }\n const matchedTreePromises = new Array<Promise<HierarchySearchTree | undefined>>();\n for (const childrenSearchTree of searchProps.childrenTargetPaths) {\n if (\"asyncPathMatcher\" in extractionProps) {\n const matchesPossiblyPromise = extractionProps.asyncPathMatcher(childrenSearchTree.identifier);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedTreePromises.push(matchesPossiblyPromise.then((matches) => (matches ? childrenSearchTree : undefined)));\n } else if (matchesPossiblyPromise) {\n extractionProps.pathsReducer.accept(childrenSearchTree);\n }\n } else {\n const matches =\n \"pathMatcher\" in extractionProps\n ? extractionProps.pathMatcher(childrenSearchTree.identifier)\n : nodeKeyMatchesIdentifier(extractionProps.nodeKey, childrenSearchTree.identifier);\n if (matches) {\n extractionProps.pathsReducer.accept(childrenSearchTree);\n }\n }\n }\n if (matchedTreePromises.length === 0) {\n return;\n }\n return Promise.all(matchedTreePromises).then((matchedTrees) =>\n matchedTrees.forEach((matchedTree) => matchedTree && extractionProps.pathsReducer.accept(matchedTree)),\n );\n }\n\n function createChildNodeProps(props: { nodeKey: InstancesNodeKey | GenericNodeKey }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(\n props: { nodeKey: InstancesNodeKey | GenericNodeKey } & (\n | {\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {}\n ),\n ): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined {\n if (!hasSearch) {\n return undefined;\n }\n\n const reducer = new MatchingSearchPathsReducer(searchProps.hasSearchTargetAncestor);\n if (\"asyncPathMatcher\" in props) {\n const extractResult = saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, nodeKey: props.nodeKey, asyncPathMatcher: props.asyncPathMatcher });\n if (extractResult instanceof Promise) {\n return extractResult.then(() => reducer.aggregatedOptions);\n }\n } else {\n saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, ...props });\n }\n return reducer.aggregatedOptions;\n }\n\n return {\n /** Returns a flag indicating if the hierarchy level is filtered. */\n hasSearch,\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a search target. That generally means that this and all downstream hierarchy\n * levels should be displayed without search being applied to them, even if search paths\n * say otherwise.\n */\n hasSearchTargetAncestor: searchProps?.hasSearchTargetAncestor ?? false,\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if search is not applied to this level.\n */\n getChildNodeSearchIdentifiers: () => {\n if (!searchProps?.childrenTargetPaths) {\n return undefined;\n }\n return searchProps.childrenTargetPaths.map(({ identifier }) => identifier);\n },\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `search`\n * and `autoExpand`) to be set based on the search paths and search options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` or `asyncPathMatcher` 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 * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:\n * - `asyncPathMatcher` is provided - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a `Promise`.\n * - `pathMatcher` or only `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;\n */\n createChildNodeProps,\n };\n}\n\nfunction nodeKeyMatchesIdentifier(nodeKey: InstancesNodeKey | GenericNodeKey, identifier: HierarchyNodeIdentifier): boolean {\n return (\n (HierarchyNodeKey.isGeneric(nodeKey) && HierarchyNodeIdentifier.equal(identifier, nodeKey)) ||\n (HierarchyNodeKey.isInstances(nodeKey) && nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(identifier, ik)))\n );\n}\n\n/**\n * Extracts information from search paths and later returns `search` and `autoExpand` values from `HierarchyNode`.\n *\n * Saved values can be applied to a single `HierarchyNode` - this means that a new reducer should be created every time these props are requested for a `HierarchyNode`.\n *\n * Extracts information using `accept` function:\n * - Determines if node is search target, and if it is saves the options as `searchTargetOptions`\n * - Saves `HierarchySearchPathOptions` and `childrenTargetPaths`\n */\nclass MatchingSearchPathsReducer {\n private _childrenTargetPaths = new Array<HierarchySearchTree>();\n private _isSearchTarget = false;\n private _options: HierarchySearchTree[\"options\"] | undefined = undefined;\n\n public constructor(private _hasSearchTargetAncestor: boolean) {}\n\n public accept(tree: HierarchySearchTree): void {\n if (tree.isTarget || tree.children === undefined) {\n this._isSearchTarget = true;\n }\n if (tree.children && tree.children.length > 0) {\n this._childrenTargetPaths.push(...tree.children);\n }\n this._options = HierarchySearchTree.mergeOptions(this._options, tree.options);\n }\n\n public get aggregatedOptions() {\n const search =\n this._hasSearchTargetAncestor || this._isSearchTarget || this._childrenTargetPaths.length > 0 || this._options\n ? {\n ...(this._hasSearchTargetAncestor ? { hasSearchTargetAncestor: true } : undefined),\n ...(this._isSearchTarget ? { isSearchTarget: true } : undefined),\n ...(this._childrenTargetPaths.length > 0 ? { childrenTargetPaths: this._childrenTargetPaths } : undefined),\n ...(this._options ? { options: this._options } : undefined),\n }\n : undefined;\n const autoExpand = this._options?.autoExpand === true;\n return {\n ...(search ? { search } : undefined),\n ...(autoExpand ? { autoExpand } : undefined),\n };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-hierarchies",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.14",
|
|
4
4
|
"description": "A package for creating hierarchies based on data in iTwin.js iModels.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@itwin/core-geometry": "^5.7.2",
|
|
39
39
|
"natural-compare-lite": "^1.4.0",
|
|
40
40
|
"rxjs": "^7.8.2",
|
|
41
|
-
"@itwin/presentation-shared": "
|
|
41
|
+
"@itwin/presentation-shared": "2.0.0-alpha.9"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@itwin/build-tools": "^5.7.2",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"sinon": "^19.0.5",
|
|
61
61
|
"sinon-chai": "^4.0.1",
|
|
62
62
|
"typescript": "~5.7.3",
|
|
63
|
-
"presentation-test-utilities": "
|
|
63
|
+
"presentation-test-utilities": "0.0.1"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"lint": "eslint \"./src/**/*.ts\"",
|
|
72
72
|
"test:dev": "mocha --enable-source-maps --config ./.mocharc.json",
|
|
73
73
|
"test": "npm run test:dev",
|
|
74
|
-
"extract-api": "betools extract-api --entry
|
|
74
|
+
"extract-api": "betools extract-api --entry=./lib/esm/presentation-hierarchies --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
75
75
|
"check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-hierarchies.api.md",
|
|
76
76
|
"update-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md,./learning",
|
|
77
77
|
"check-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md,./learning --check",
|