@itwin/presentation-hierarchies 2.0.0-alpha.11 → 2.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +284 -16
  2. package/README.md +2 -2
  3. package/lib/cjs/hierarchies/HierarchyNode.d.ts +13 -11
  4. package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
  5. package/lib/cjs/hierarchies/HierarchyNode.js +18 -0
  6. package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
  7. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts +2 -0
  8. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
  9. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js +23 -6
  10. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
  11. package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts +5 -4
  12. package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  13. package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
  14. package/lib/cjs/hierarchies/HierarchyProvider.d.ts +3 -3
  15. package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
  16. package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
  17. package/lib/cjs/hierarchies/HierarchySearch.d.ts +184 -78
  18. package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -1
  19. package/lib/cjs/hierarchies/HierarchySearch.js +305 -113
  20. package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -1
  21. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -2
  22. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
  23. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
  24. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts +3 -3
  25. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
  26. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
  27. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +9 -4
  28. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  29. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +25 -16
  30. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  31. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -4
  32. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  33. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +12 -9
  34. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  35. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +3 -3
  36. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
  37. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
  38. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts +2 -2
  39. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
  40. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js +31 -55
  41. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
  42. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
  43. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  44. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +1 -1
  45. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  46. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
  47. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
  48. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -1
  49. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
  50. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +1 -1
  51. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
  52. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
  53. package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts +2 -2
  54. package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
  55. package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
  56. package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
  57. package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
  58. package/lib/cjs/presentation-hierarchies.d.ts +1 -1
  59. package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
  60. package/lib/cjs/presentation-hierarchies.js +2 -1
  61. package/lib/cjs/presentation-hierarchies.js.map +1 -1
  62. package/lib/esm/hierarchies/HierarchyNode.d.ts +13 -11
  63. package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
  64. package/lib/esm/hierarchies/HierarchyNode.js +18 -0
  65. package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
  66. package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts +2 -0
  67. package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
  68. package/lib/esm/hierarchies/HierarchyNodeIdentifier.js +23 -6
  69. package/lib/esm/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
  70. package/lib/esm/hierarchies/HierarchyNodeKey.d.ts +5 -4
  71. package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  72. package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
  73. package/lib/esm/hierarchies/HierarchyProvider.d.ts +3 -3
  74. package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
  75. package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
  76. package/lib/esm/hierarchies/HierarchySearch.d.ts +184 -78
  77. package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -1
  78. package/lib/esm/hierarchies/HierarchySearch.js +304 -111
  79. package/lib/esm/hierarchies/HierarchySearch.js.map +1 -1
  80. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -2
  81. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
  82. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
  83. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts +3 -3
  84. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
  85. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
  86. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +9 -4
  87. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  88. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +26 -17
  89. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  90. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -4
  91. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  92. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +13 -10
  93. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  94. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +3 -3
  95. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
  96. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
  97. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts +2 -2
  98. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
  99. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js +32 -56
  100. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
  101. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
  102. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  103. package/lib/esm/hierarchies/imodel/TreeNodesReader.js +2 -2
  104. package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  105. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
  106. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
  107. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -1
  108. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
  109. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +1 -1
  110. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
  111. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
  112. package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts +2 -2
  113. package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
  114. package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
  115. package/lib/esm/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
  116. package/lib/esm/hierarchies/internal/operators/Sorting.js.map +1 -1
  117. package/lib/esm/presentation-hierarchies.d.ts +1 -1
  118. package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
  119. package/lib/esm/presentation-hierarchies.js +1 -1
  120. package/lib/esm/presentation-hierarchies.js.map +1 -1
  121. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,201 @@
1
1
  # @itwin/presentation-hierarchies
2
2
 
3
+ ## 2.0.0-alpha.13
4
+
5
+ ### Major Changes
6
+
7
+ - [#1250](https://github.com/iTwin/presentation/pull/1250): Use type-safe full class names.
8
+
9
+ The full class names used in this package were defined as `string`, although we always expect them to be in specific format - either `Schema:Class` or `Schema.Class`. In many cases we rely on this format when parsing the name for compare or other purposes, so type safety for the format is highly beneficial. This change makes full class names type-safe(ier) through [TypeScript's template literal types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html), so that we can be sure that they are always in correct format.
10
+
11
+ ## Breaking changes
12
+
13
+ - `ClassGroupingNodeKey.className` is now of type `EC.FullClassName` instead of `string`.
14
+ - `NodesQueryClauseFactory.createSelectClause` prop `grouping.byBaseClasses.fullClassNames` is now of type `EC.FullClassName[]` instead of `string[]`.
15
+ - `NodesQueryClauseFactory.createSelectClause` prop `grouping.byProperties.propertiesClassName` is now of type `EC.FullClassName` instead of `string`.
16
+ - `HierarchyNodesDefinition.fullClassName` is now of type `EC.FullClassName` instead of `string`.
17
+ - `createPredicateBasedHierarchyDefinition` prop `hierarchies.childNodes[number].parentInstancesNodePredicate` now accepts `EC.FullClassName` instead of `string`.
18
+ - `NodesQueryClauseFactory.createFilterClauses` prop `contentClass.fullName` is now of type `EC.FullClassName` instead of `string`.
19
+ - `PropertyOtherValuesGroupingNodeKey.properties[number].className` is now of type `EC.FullClassName` instead of `string`.
20
+ - `PropertyValueGroupingNodeKey.propertyClassName` is now of type `EC.FullClassName` instead of `string`.
21
+ - `PropertyValueRangeGroupingNodeKey.propertyClassName` is now of type `EC.FullClassName` instead of `string`.
22
+
23
+ In many cases migration will be seamless, as long as the input string matches the expected format. In some cases (e.g. when assigning a string variable to one of the affected properties), you may need to use `normalizeFullClassName` from `@itwin/presentation-shared` to ensure the value is of the correct type:
24
+
25
+ ```ts
26
+ const myClassName: string = "MySchema.MyClass";
27
+
28
+ // before
29
+ const myClassGroupingNodeKey: ClassGroupingNodeKey = {
30
+ type: "class-grouping",
31
+ className: myClassName,
32
+ };
33
+
34
+ // after
35
+ const myClassGroupingNodeKey: ClassGroupingNodeKey = {
36
+ type: "class-grouping",
37
+ // assigning `MySchema.MyClass` directly wouldn't require using `normalizeFullClassName` as the type would be correctly inferred, but if the class name is stored in a variable of type `string`, you need to use `normalizeFullClassName` to ensure it's of the correct type
38
+ className: normalizeFullClassName(myClassName),
39
+ };
40
+ ```
41
+
42
+ - [#1236](https://github.com/iTwin/presentation/pull/1236): Start using tree structure for defining hierarchy search paths.
43
+
44
+ **Additions:**
45
+
46
+ - `HierarchySearchTree` type that represents a tree structure of hierarchy search paths and is now used for hierarchy search implementation in `HierarchyProvider`.
47
+
48
+ In addition to the type, there's also a namespace with the same name, providing utility functions for working with the tree structure:
49
+
50
+ - `HierarchySearchTree.createBuilder` function to create a builder for hierarchy search trees, which can be used to create a tree from individual paths or to merge multiple trees together:
51
+
52
+ ```ts
53
+ const builder = HierarchySearchTree.createBuilder();
54
+ builder.accept({ path: searchPath1 });
55
+ builder.accept({ path: searchPath2 });
56
+ builder.accept({ tree: partialSearchTree });
57
+ const tree: HierarchySearchTree = builder.getTree();
58
+ ```
59
+
60
+ 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.
61
+
62
+ - `HierarchySearchTree.createFromPathsList` function to create a hierarchy search tree from a list of hierarchy search paths. This is a quick & easy way to migrate from the old `HierarchySearchPath[]` structure to `HierarchySearchTree[]`, but it's' less efficient than using the builder if you need to create a tree from a large number of paths, as it needs to create an intermediate array.
63
+
64
+ The recommended way to handle multiple search paths is to use the builder and call `accept` for each path, as it allows to create a tree without having to create an array first:
65
+
66
+ ```ts
67
+ // Instead of doing this:
68
+ const searchPaths: HierarchySearchPath[] = [];
69
+ for (const item of items) {
70
+ searchPaths.push(createSearchPathForItem(item));
71
+ }
72
+ const tree: HierarchySearchTree =
73
+ HierarchySearchTree.createFromPathsList(searchPaths);
74
+
75
+ // Do this:
76
+ const builder = HierarchySearchTree.createBuilder();
77
+ for (const item of items) {
78
+ builder.accept({ path: createSearchPathForItem(item) });
79
+ }
80
+ const tree: HierarchySearchTree = builder.getTree();
81
+ ```
82
+
83
+ - `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.
84
+
85
+ - `HierarchyNode.getGroupingNodeLevel` utility function to get the level of a grouping node in the hierarchy. Convenient for specifying the `groupingLevel` prop in `HierarchySearchPath.options.reveal` and `HierarchySearchTree.options.autoExpand`.
86
+
87
+ - `HierarchyNodeIdentifier.compare` static function to compare two `HierarchyNodeIdentifier` objects. Useful when using `HierarchyNodeIdentifier` as a key in a dictionary sorted set.
88
+
89
+ **Breaking changes:**
90
+
91
+ - `HierarchySearchPathOptions.reveal` type `{ depthInHierarchy: number }` was replaced with `{ groupingLevel: number }`.
92
+
93
+ The `depthInHierarchy` option was only useful when revealing grouping nodes, the rename makes the intent more explicit. In addition, the `groupingLevel` option is only handled in the scope of one specific `InstancesNode` node that the options are supplied for, so handling this option is more efficient - we only need to handle it for grouping nodes, and look only as deep as the next grouped `InstancesNode` node.
94
+
95
+ Migration:
96
+
97
+ ```ts
98
+ const groupingNode = getMyGroupingNode();
99
+ const searchPath: HierarchySearchPath = {
100
+ // ...
101
+ options: {
102
+ // before
103
+ reveal: { depthInHierarchy: groupingNode.parentKeys.length },
104
+
105
+ // after
106
+ reveal: {
107
+ groupingLevel: HierarchyNode.getGroupingNodeLevel(groupingNode),
108
+ },
109
+ },
110
+ };
111
+ ```
112
+
113
+ - `HierarchyProvider.setHierarchySearch` now takes `{ paths: HierarchySearchTree[] }` instead of `{ paths: HierarchySearchPath[] }`.
114
+
115
+ Migration:
116
+
117
+ ```ts
118
+ const provider: HierarchyProvider = getMyHierarchyProvider();
119
+ const searchPaths: HierarchySearchPath[] = getMySearchPaths();
120
+ provider.setHierarchySearch({
121
+ // before
122
+ paths: searchPaths,
123
+
124
+ // after
125
+ // - see `HierarchySearchTree.createFromPathsList` description above for more efficient way to do this
126
+ // - quick migration:
127
+ paths: await HierarchySearchTree.createFromPathsList(searchPaths),
128
+ });
129
+ ```
130
+
131
+ - `createIModelHierarchyProvider` and `createMergedIModelHierarchyProvider` functions' `search` prop now takes `{ paths: HierarchySearchTree[] }` instead of `{ paths: HierarchySearchPath[] }`. Use `HierarchySearchTree.createFromPathsList` to do the conversion.
132
+
133
+ Migration:
134
+
135
+ ```ts
136
+ const searchPaths: HierarchySearchPath[] = getMySearchPaths();
137
+ const provider = createIModelHierarchyProvider({
138
+ // ...
139
+ search: {
140
+ // before
141
+ paths: searchPaths,
142
+
143
+ // after
144
+ // - see `HierarchySearchTree.createFromPathsList` description above for more efficient way to do this
145
+ // - quick migration:
146
+ paths: await HierarchySearchTree.createFromPathsList(searchPaths),
147
+ },
148
+ });
149
+ ```
150
+
151
+ - `HierarchyNode.search` changes:
152
+
153
+ - Type of `childrenTargetPaths` has been changed from `HierarchySearchPath[]` to `HierarchySearchTree[]`.
154
+ - `searchTargetOptions` was replaced with `options`, which is available not only for nodes with `isSearchTarget: true`, but all of them.
155
+
156
+ The changes of this attribute are taken care of by the `createHierarchySearchHelper` changes described below.
157
+
158
+ - `createHierarchySearchHelper` changes:
159
+
160
+ - The first argument is now `HierarchySearchTree[]` instead of `HierarchySearchPath[]`.
161
+ - The `createChildNodeProps` function of returned result no longer requires the `parentKeys` prop, but instead always requires the `nodeKey` prop.
162
+
163
+ Migration:
164
+
165
+ ```ts
166
+ // Somewhere in `HierarchyProvider.getNodes` implementation...
167
+
168
+ // Type of the first argument has changed, but it also changed on `HierarchyProvider`, so likely no changes are needed here. If the
169
+ // type of `rootSearch.paths` is still `HierarchySearchPath[]` - use `HierarchySearchTree.createFromPathsList` to do the conversion.
170
+ const helper = createHierarchySearchHelper(rootSearch?.paths, parentNode);
171
+ for (const book of books) {
172
+ const nodeKey: GenericNodeKey = { type: "generic", id: `book:${book.key}` };
173
+ yield {
174
+ key: nodeKey,
175
+ label: book.title,
176
+ children: false,
177
+ parentKeys: [...parentNode.parentKeys, parentNode.key],
178
+ // before
179
+ ...searchHelper?.createChildNodeProps({ nodeKey, parentKeys }),
180
+ // after
181
+ ...searchHelper?.createChildNodeProps({ nodeKey }),
182
+ };
183
+ }
184
+ ```
185
+
186
+ ### Patch Changes
187
+
188
+ - Updated dependencies:
189
+ - @itwin/presentation-shared@2.0.0-alpha.9
190
+
191
+ ## 2.0.0-alpha.12
192
+
193
+ ### Patch Changes
194
+
195
+ - [#1229](https://github.com/iTwin/presentation/pull/1229): Version bump
196
+ - Updated dependencies:
197
+ - @itwin/presentation-shared@2.0.0-alpha.8
198
+
3
199
  ## 2.0.0-alpha.11
4
200
 
5
201
  ### Major Changes
@@ -83,15 +279,21 @@
83
279
  // or, provide implementation as a class instance:
84
280
  const afterAsClassObject = createHierarchyProvider(
85
281
  ({ hierarchyChanged }) =>
86
- new (class implements Pick<HierarchyProvider, "getNodes" | "setFormatter"> {
87
- public async *getNodes({ parentNode }): ReturnType<HierarchyProvider["getNodes"]> {
282
+ new (class
283
+ implements Pick<HierarchyProvider, "getNodes" | "setFormatter">
284
+ {
285
+ public async *getNodes({
286
+ parentNode,
287
+ }): ReturnType<HierarchyProvider["getNodes"]> {
88
288
  // yield nodes...
89
289
  }
90
290
  public setFormatter(formatter: IPrimitiveValueFormatter | undefined) {
91
291
  // set formatter...
92
- hierarchyChanged.raiseEvent({ formatterChange: { newFormatter: formatter } });
292
+ hierarchyChanged.raiseEvent({
293
+ formatterChange: { newFormatter: formatter },
294
+ });
93
295
  }
94
- })(),
296
+ })()
95
297
  );
96
298
  ```
97
299
 
@@ -118,6 +320,7 @@
118
320
  the `createNodesQueryClauseFactory` function should be called with `imodelAccess` that is passed to `HierarchyDefinition.defineHierarchyLevel`.
119
321
 
120
322
  **Breaking changes:**
323
+
121
324
  - `DefineHierarchyLevelProps.imodelKey` was replaced with `imodelAccess`. If needed, the key can be accessed using `imodelAccess.imodelKey`. This affects the following APIs:
122
325
  - `HierarchyDefinition.defineHierarchyLevel` (function that uses these props),
123
326
  - `DefineRootHierarchyLevelProps` (extends the props type),
@@ -130,6 +333,7 @@
130
333
  - [#1137](https://github.com/iTwin/presentation/pull/1137): Fix hierarchy search only handling a single (latest) iModel results when searching multi-iModel hierarchies.
131
334
 
132
335
  Notable API changes:
336
+
133
337
  - **BREAKING:** `NodeParser` (type of `HierarchyDefinition.parseNode` function) now gets a single props argument instead of multiple arguments. In addition, the props object now also contains an imodel key argument.
134
338
 
135
339
  ```ts
@@ -164,6 +368,7 @@
164
368
  Properties and APIs were renamed accordingly to clarify the distinction and avoid confusion between hierarchy‑wide search and per-hierarchy‑level filtering.
165
369
 
166
370
  **Breaking changes:**
371
+
167
372
  - Removed deprecated `extractFilteringProps`.
168
373
  - Removed deprecated `HierarchyNodeFilteringProps.create`.
169
374
  - Renamed `createHierarchyFilteringHelper` to `createHierarchySearchHelper`. It's return type was also adjusted for the rename:
@@ -188,6 +393,7 @@
188
393
  - 6a00754233e6d1b8956a5fc7680829562156d659: Fixed a bug causing `HierarchyNode.autoExpand` flag to be set on non-grouping nodes, when `HierarchyFilteringPathOptions.autoExpand.depthInHierarchy` points to a grouping node whose child non-grouping node is not a filter target.
189
394
 
190
395
  **Breaking changes:**
396
+
191
397
  - `GroupingHierarchyNode` no longer contains `filtering` attribute. This was always the case, but now the types have been updated to match it.
192
398
  - Changed return type of `createHierarchyFilteringHelper`:
193
399
  - Removed `createChildNodePropsAsync` - it became an overload of `createChildNodeProps`, whose path matching is done through `asyncPathMatcher` callback.
@@ -250,6 +456,7 @@
250
456
  ### Major Changes
251
457
 
252
458
  - [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
459
+
253
460
  - `EC.Schema`, `EC.Class` and `EC.Property` now all have an async `getCustomAttributes()` method that returns an `EC.CustomAttributeSet`, allowing consumers to access custom attributes of these schema items.
254
461
  - `EC.Class` now additionally has these members:
255
462
  - `baseClass: Promise<Class | undefined>`
@@ -268,6 +475,22 @@
268
475
  - Updated dependencies:
269
476
  - @itwin/presentation-shared@2.0.0-alpha.0
270
477
 
478
+ ## 1.7.11
479
+
480
+ ### Patch Changes
481
+
482
+ - [#1242](https://github.com/iTwin/presentation/pull/1242): Bump dependencies.
483
+ - Updated dependencies:
484
+ - @itwin/presentation-shared@1.2.10
485
+
486
+ ## 1.7.10
487
+
488
+ ### Patch Changes
489
+
490
+ - [#1215](https://github.com/iTwin/presentation/pull/1215): Update dependencies.
491
+ - Updated dependencies:
492
+ - @itwin/presentation-shared@1.2.9
493
+
271
494
  ## 1.7.9
272
495
 
273
496
  ### Patch Changes
@@ -340,6 +563,7 @@
340
563
  ### Minor Changes
341
564
 
342
565
  - 8f7d200926b93e862276e1f978f6c891691e0dae: Refactored specifying the depth / level to which filtering path should be auto-expanded.
566
+
343
567
  - Deprecated `FilteringPathAutoExpandOption` and `FilterTargetGroupingNodeInfo`.
344
568
  - Added `FilteringPathAutoExpandDepthInPath` and `FilteringPathAutoExpandDepthInHierarchy` which should be used instead.
345
569
 
@@ -404,7 +628,10 @@
404
628
  **Before:**
405
629
 
406
630
  ```ts
407
- const childNodeProps = await createHierarchyFilteringHelper(undefined, undefined).createChildNodePropsAsync({
631
+ const childNodeProps = await createHierarchyFilteringHelper(
632
+ undefined,
633
+ undefined
634
+ ).createChildNodePropsAsync({
408
635
  pathMatcher: (identifier): boolean | Promise<boolean> => {
409
636
  return false;
410
637
  },
@@ -412,6 +639,7 @@
412
639
  ```
413
640
 
414
641
  **After:**
642
+
415
643
  - **Option A:** check if it's a Promise before awaiting:
416
644
 
417
645
  Use this when you want to get slightly better performance by avoiding unnecessary `await`.
@@ -430,7 +658,10 @@
430
658
  Use this if pathMatcher always returns a Promise or you prefer a simpler pattern.
431
659
 
432
660
  ```ts
433
- const childNodeProps = await createHierarchyFilteringHelper(undefined, undefined).createChildNodePropsAsync({
661
+ const childNodeProps = await createHierarchyFilteringHelper(
662
+ undefined,
663
+ undefined
664
+ ).createChildNodePropsAsync({
434
665
  pathMatcher: async (identifier): Promise<boolean> => {
435
666
  return false;
436
667
  },
@@ -496,6 +727,7 @@
496
727
  - [#783](https://github.com/iTwin/presentation/pull/783): Added hierarchy filtering helper to make hierarchy filtering easier to implement.
497
728
 
498
729
  The helper can be created using the `createHierarchyFilteringHelper` function and supplying it the root level filtering paths and parent node. From there, filtering information for specific hierarchy level is determined and an object with the following attributes is returned:
730
+
499
731
  - `hasFilter` tells if the hierarchy level has a filter applied.
500
732
  - `hasFilterTargetAncestor` tells if there's a filter target ancestor node up in the hierarchy.
501
733
  - `getChildNodeFilteringIdentifiers()` returns an array of hierarchy node identifiers that apply specifically for this hierarchy level.
@@ -504,6 +736,7 @@
504
736
  See the [Implementing hierarchy filtering support](./learning/CustomHierarchyProviders.md#implementing-hierarchy-filtering-support) learning page for a usage example.
505
737
 
506
738
  In addition, deprecated a few APIs that are replaced by filtering helper:
739
+
507
740
  - `extractFilteringProps` function,
508
741
  - `HierarchyNodeFilteringProps.create` function.
509
742
 
@@ -549,6 +782,7 @@
549
782
  | 50k | not tested | 13.45 s |
550
783
 
551
784
  In addition, changed `NodeParser` (return type of `HierarchyDefinition.parseNode`):
785
+
552
786
  - It now can return a promise, so instead of just `SourceInstanceHierarchyNode` it can now also return `Promise<SourceInstanceHierarchyNode>`.
553
787
  - Additionally, it now accepts an optional `parentNode` argument of `HierarchyDefinitionParentNode` type.
554
788
 
@@ -580,6 +814,7 @@
580
814
  ### Minor Changes
581
815
 
582
816
  - [#708](https://github.com/iTwin/presentation/pull/708): **BREAKING:** Added support for creating hierarchies from multiple data sources.
817
+
583
818
  - `InstancesNodeKey.instanceKeys` array items now have an optional `imodelKey` attribute to allow for the identification of the iModel that the instance belongs to. This is useful when working with sets of instance keys representing instances from different iModels. In addition, the same `imodelKey` attribute is also available on `HierarchyNodeIdentifier` to allow for filtering nodes based on the iModel they belong to.
584
819
  - `HierarchyNode` terminology and related changes:
585
820
  - "Standard" nodes were renamed to "IModel" nodes to signify the fact that they're based on iModel data:
@@ -607,6 +842,7 @@
607
842
  - The returned provider now has a `dispose` method to clean up resources - make sure to call it when the provider is no longer needed.
608
843
  - Added `mergeProviders` function, which, given a number of hierarchy providers, creates a new provider that merges the hierarchies of the input providers. The returned provider has a `dispose` method that needs to be called when the provider is no longer needed.
609
844
  - Renamed `createClassBasedHierarchyDefinition` to `createPredicateBasedHierarchyDefinition` to signify its props changes:
845
+
610
846
  - When specifying `childNodes` definition for instances parent node, the `parentNodeClassName` attribute was changed to `parentInstancesNodePredicate`. In addition to accepting a full class name, identifying the class of parent instances to return children for, it now also accepts an async function predicate.
611
847
  - When specifying `childNodes` definition for generic parent node, the `customParentNodeKey` attribute was changed to `parentGenericNodePredicate`. The type changed from `string`, identifying the key of the parent node, to an async function predicate.
612
848
 
@@ -659,6 +895,7 @@
659
895
  ```
660
896
 
661
897
  - [#708](https://github.com/iTwin/presentation/pull/708): Added utilities for custom hierarchy filtering handling:
898
+
662
899
  - `extractFilteringProps` function, given root level hierarchy filtering paths and a parent node, returns props required to filter particular hierarchy level.
663
900
  - `HierarchyFilteringPath` interface is now public and there's also a similarly-named namespace with the following utilities:
664
901
  - `mergeOptions` merges filtering options of two paths. This is useful for cases when there are multiple paths targeting the same node, but with different options.
@@ -687,7 +924,9 @@
687
924
  ```ts
688
925
  const selectQueryFactory = createNodesQueryClauseFactory({
689
926
  imodelAccess,
690
- instanceLabelSelectClauseFactory: createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: imodelAccess }),
927
+ instanceLabelSelectClauseFactory: createBisInstanceLabelSelectClauseFactory(
928
+ { classHierarchyInspector: imodelAccess }
929
+ ),
691
930
  });
692
931
  ```
693
932
 
@@ -710,7 +949,12 @@
710
949
  // Path to the element "C"
711
950
  path: [elementKeys.a, elementKeys.b, elementKeys.c],
712
951
  // Supply grouping node attributes with the path to the "C" element.
713
- options: { autoExpand: { key: groupingNode.key, depth: groupingNode.parentKeys.length } },
952
+ options: {
953
+ autoExpand: {
954
+ key: groupingNode.key,
955
+ depth: groupingNode.parentKeys.length,
956
+ },
957
+ },
714
958
  },
715
959
  ],
716
960
  },
@@ -749,7 +993,12 @@
749
993
  const hierarchyProvider = createHierarchyProvider({
750
994
  imodelAccess,
751
995
  hierarchyDefinition: createHierarchyDefinition(imodelAccess),
752
- filtering: { paths: filterPaths.map((path) => ({ path, options: { autoExpand: true } })) },
996
+ filtering: {
997
+ paths: filterPaths.map((path) => ({
998
+ path,
999
+ options: { autoExpand: true },
1000
+ })),
1001
+ },
753
1002
  });
754
1003
  ```
755
1004
 
@@ -791,12 +1040,18 @@
791
1040
  childNodes: [
792
1041
  {
793
1042
  parentNodeClassName: "BisCore.PhysicalElement",
794
- definitions: async ({ parentNode }) => getPhysicalElementChildren(parentNode),
1043
+ definitions: async ({ parentNode }) =>
1044
+ getPhysicalElementChildren(parentNode),
795
1045
  },
796
1046
  {
797
1047
  parentNodeClassName: "BisCore.SpatialElement",
798
1048
  definitions: async ({ parentNode, parentNodeClassName }) => {
799
- if (await inspector.classDerivesFrom(parentNodeClassName, "BisCore.PhysicalElement")) {
1049
+ if (
1050
+ await inspector.classDerivesFrom(
1051
+ parentNodeClassName,
1052
+ "BisCore.PhysicalElement"
1053
+ )
1054
+ ) {
800
1055
  return [];
801
1056
  }
802
1057
 
@@ -806,11 +1061,21 @@
806
1061
  {
807
1062
  parentNodeClassName: "BisCore.GeometricElement3d",
808
1063
  definitions: async ({ parentNode, parentNodeClassName }) => {
809
- if (await inspector.classDerivesFrom(parentNodeClassName, "BisCore.PhysicalElement")) {
1064
+ if (
1065
+ await inspector.classDerivesFrom(
1066
+ parentNodeClassName,
1067
+ "BisCore.PhysicalElement"
1068
+ )
1069
+ ) {
810
1070
  return [];
811
1071
  }
812
1072
 
813
- if (await inspector.classDerivesFrom(parentNodeClassName, "BisCore.SpatialElement")) {
1073
+ if (
1074
+ await inspector.classDerivesFrom(
1075
+ parentNodeClassName,
1076
+ "BisCore.SpatialElement"
1077
+ )
1078
+ ) {
814
1079
  return [];
815
1080
  }
816
1081
 
@@ -831,17 +1096,20 @@
831
1096
  childNodes: [
832
1097
  {
833
1098
  parentNodeClassName: "BisCore.PhysicalElement",
834
- definitions: async ({ parentNode }) => getPhysicalElementChildren(parentNode),
1099
+ definitions: async ({ parentNode }) =>
1100
+ getPhysicalElementChildren(parentNode),
835
1101
  },
836
1102
  {
837
1103
  parentNodeClassName: "BisCore.SpatialElement",
838
1104
  onlyIfNotHandled: true,
839
- definitions: async ({ parentNode }) => getSpatialElementChildren(parentNode),
1105
+ definitions: async ({ parentNode }) =>
1106
+ getSpatialElementChildren(parentNode),
840
1107
  },
841
1108
  {
842
1109
  parentNodeClassName: "BisCore.GeometricElement3d",
843
1110
  onlyIfNotHandled: true,
844
- definitions: async ({ parentNode }) => getGeometricElement3dChildren(parentNode),
1111
+ definitions: async ({ parentNode }) =>
1112
+ getGeometricElement3dChildren(parentNode),
845
1113
  },
846
1114
  ],
847
1115
  },
package/README.md CHANGED
@@ -76,7 +76,7 @@ Here's a simple example of how to create a hierarchy provider and build a hierar
76
76
  ```ts
77
77
  import { IModelConnection } from "@itwin/core-frontend";
78
78
  import { createECSchemaProvider, createECSqlQueryExecutor, createIModelKey } from "@itwin/presentation-core-interop";
79
- import { createLimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
79
+ import { createLimitingECSqlQueryExecutor, HierarchyLevelDefinition } from "@itwin/presentation-hierarchies";
80
80
  import { createCachingECClassHierarchyInspector, Props } from "@itwin/presentation-shared";
81
81
 
82
82
  import {
@@ -138,7 +138,7 @@ function createProvider(imodelAccess: Props<typeof createIModelHierarchyProvider
138
138
  {
139
139
  // For BisCore.Model parent nodes, select all BisCore.Element instances contained in corresponding model
140
140
  parentInstancesNodePredicate: "BisCore.Model",
141
- definitions: async ({ parentNodeInstanceIds }: DefineInstanceNodeChildHierarchyLevelProps) => [
141
+ definitions: async ({ parentNodeInstanceIds }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> => [
142
142
  {
143
143
  fullClassName: "BisCore.Element",
144
144
  query: {
@@ -1,22 +1,18 @@
1
1
  import { HierarchyNodeKey } from "./HierarchyNodeKey.js";
2
2
  import type { OmitOverUnion } from "@itwin/presentation-shared";
3
3
  import type { ClassGroupingNodeKey, GenericNodeKey, GroupingNodeKey, IModelHierarchyNodeKey, IModelInstanceKey, InstancesNodeKey, LabelGroupingNodeKey, PropertyGroupingNodeKey, PropertyOtherValuesGroupingNodeKey, PropertyValueGroupingNodeKey, PropertyValueRangeGroupingNodeKey } from "./HierarchyNodeKey.js";
4
- import type { HierarchySearchPath, HierarchySearchPathOptions } from "./HierarchySearch.js";
4
+ import type { HierarchySearchTree } from "./HierarchySearch.js";
5
5
  /** @public */
6
- export type HierarchyNodeSearchProps = {
6
+ export interface HierarchyNodeSearchProps {
7
7
  /** If set to true, then one of the ancestor nodes in the hierarchy is the search target. */
8
8
  hasSearchTargetAncestor?: boolean;
9
9
  /** Paths to node's children that are search targets. */
10
- childrenTargetPaths?: HierarchySearchPath[];
11
- } & ({
10
+ childrenTargetPaths?: HierarchySearchTree[];
12
11
  /** Whether or not this node is a search target. */
13
- isSearchTarget?: false;
14
- } | {
15
- /** Whether or not this node is a search target. */
16
- isSearchTarget: true;
17
- /** Options that were used to search the node. */
18
- searchTargetOptions?: HierarchySearchPathOptions;
19
- });
12
+ isSearchTarget?: boolean;
13
+ /** Options assigned to this node through search. */
14
+ options?: HierarchySearchTree["options"];
15
+ }
20
16
  /**
21
17
  * A data structure that defines attributes that are common to all types of hierarchy nodes.
22
18
  * @public
@@ -136,6 +132,12 @@ export declare namespace HierarchyNode {
136
132
  key: PropertyGroupingNodeKey;
137
133
  supportsFiltering?: undefined;
138
134
  } & GroupingHierarchyNode;
135
+ /**
136
+ * Gets the grouping level of the given grouping node.
137
+ *
138
+ * May be useful when setting `groupingLevel` for `HierarchySearchTree.options.autoExpand` or `HierarchySearchPathOptions.reveal`.
139
+ */
140
+ function getGroupingNodeLevel(groupingNode: Pick<GroupingHierarchyNode, "key" | "parentKeys">): number;
139
141
  }
140
142
  /**
141
143
  * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNode.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EAClC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAE5F,cAAc;AACd,MAAM,MAAM,wBAAwB,GAAG;IACrC,4FAA4F;IAC5F,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C,GAAG,CACA;IACE,mDAAmD;IACnD,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB,GACD;IACE,mDAAmD;IACnD,cAAc,EAAE,IAAI,CAAC;IACrB,iDAAiD;IACjD,mBAAmB,CAAC,EAAE,0BAA0B,CAAC;CAClD,CACJ,CAAC;AAEF;;;GAGG;AACH,UAAU,iBAAiB;IACzB,0FAA0F;IAC1F,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yDAAyD;IACzD,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CA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,EAAE,KAAK,GACV,IAAI,IAAI,KAAK,GAAG;QAAE,GAAG,EAAE,4BAA4B,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAE9G;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAAC,KAAK,SAAS;QAAE,GAAG,EAAE,gBAAgB,CAAA;KAAE,EACtF,IAAI,EAAE,KAAK,GACV,IAAI,IAAI,KAAK,GAAG;QAAE,GAAG,EAAE,iCAAiC,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAEnH;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CAAC,KAAK,SAAS;QAAE,GAAG,EAAE,gBAAgB,CAAA;KAAE,EAC5E,IAAI,EAAE,KAAK,GACV,IAAI,IAAI,KAAK,GAAG;QAAE,GAAG,EAAE,uBAAuB,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAEzG;IAED;;;;OAIG;IACH,SAAgB,oBAAoB,CAAC,YAAY,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,GAAG,YAAY,CAAC,GAAG,MAAM,CAU5G;CACF;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,KAAK,GAAG,aAAa,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC"}
@@ -60,5 +60,23 @@ var HierarchyNode;
60
60
  return HierarchyNodeKey_js_1.HierarchyNodeKey.isPropertyGrouping(node.key);
61
61
  }
62
62
  HierarchyNode.isPropertyGroupingNode = isPropertyGroupingNode;
63
+ /**
64
+ * Gets the grouping level of the given grouping node.
65
+ *
66
+ * May be useful when setting `groupingLevel` for `HierarchySearchTree.options.autoExpand` or `HierarchySearchPathOptions.reveal`.
67
+ */
68
+ function getGroupingNodeLevel(groupingNode) {
69
+ let level = 1;
70
+ for (let i = groupingNode.parentKeys.length - 1; i >= 0; i--) {
71
+ if (HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(groupingNode.parentKeys[i])) {
72
+ level++;
73
+ }
74
+ else {
75
+ break;
76
+ }
77
+ }
78
+ return level;
79
+ }
80
+ HierarchyNode.getGroupingNodeLevel = getGroupingNodeLevel;
63
81
  })(HierarchyNode || (exports.HierarchyNode = HierarchyNode = {}));
64
82
  //# sourceMappingURL=HierarchyNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+DAAyD;AA8FzD,cAAc;AACd,2DAA2D;AAC3D,IAAiB,aAAa,CAqD7B;AArDD,WAAiB,aAAa;IAC5B,sDAAsD;IACtD,SAAgB,SAAS,CAA0C,IAAW;QAC5E,OAAO,sCAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAFe,uBAAS,YAExB,CAAA;IACD,8EAA8E;IAC9E,SAAgB,YAAY,CAA0C,IAAW;QAC/E,OAAO,sCAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAFe,0BAAY,eAE3B,CAAA;IACD,iEAAiE;IACjE,SAAgB,eAAe,CAA0C,IAAW;QAClF,OAAO,sCAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IAFe,6BAAe,kBAE9B,CAAA;IACD,uDAAuD;IACvD,SAAgB,cAAc,CAA0C,IAAW;QACjF,OAAO,sCAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAFe,4BAAc,iBAE7B,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAEX,OAAO,sCAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAJe,iCAAmB,sBAIlC,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAEX,OAAO,sCAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAJe,iCAAmB,sBAIlC,CAAA;IACD,gFAAgF;IAChF,SAAgB,iCAAiC,CAC/C,IAAW;QAEX,OAAO,sCAAgB,CAAC,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IAJe,+CAAiC,oCAIhD,CAAA;IACD,sEAAsE;IACtE,SAAgB,2BAA2B,CACzC,IAAW;QAEX,OAAO,sCAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAJe,yCAA2B,8BAI1C,CAAA;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAEX,OAAO,sCAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IAJe,8CAAgC,mCAI/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAEX,OAAO,sCAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IAJe,oCAAsB,yBAIrC,CAAA;AACH,CAAC,EArDgB,aAAa,6BAAb,aAAa,QAqD7B","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 { HierarchyNodeKey } from \"./HierarchyNodeKey.js\";\n\nimport type { OmitOverUnion } from \"@itwin/presentation-shared\";\nimport type {\n ClassGroupingNodeKey,\n GenericNodeKey,\n GroupingNodeKey,\n IModelHierarchyNodeKey,\n IModelInstanceKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n} from \"./HierarchyNodeKey.js\";\nimport type { HierarchySearchPath, HierarchySearchPathOptions } from \"./HierarchySearch.js\";\n\n/** @public */\nexport type HierarchyNodeSearchProps = {\n /** If set to true, then one of the ancestor nodes in the hierarchy is the search target. */\n hasSearchTargetAncestor?: boolean;\n /** Paths to node's children that are search targets. */\n childrenTargetPaths?: HierarchySearchPath[];\n} & (\n | {\n /** Whether or not this node is a search target. */\n isSearchTarget?: false;\n }\n | {\n /** Whether or not this node is a search target. */\n isSearchTarget: true;\n /** Options that were used to search the node. */\n searchTargetOptions?: HierarchySearchPathOptions;\n }\n);\n\n/**\n * A data structure that defines attributes that are common to all types of hierarchy nodes.\n * @public\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @public\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: GenericNodeKey | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n /** Data that is assigned to the node if hierarchy search is enabled */\n search?: HierarchyNodeSearchProps;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @public\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: IModelInstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @public\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a generic node */\n export function isGeneric<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: GenericNodeKey } {\n return HierarchyNodeKey.isGeneric(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isIModelNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: IModelHierarchyNodeKey } {\n return HierarchyNodeKey.isIModelNodeKey(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & GroupingHierarchyNode {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n * @public\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n"]}
1
+ {"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+DAAyD;AAuFzD,cAAc;AACd,2DAA2D;AAC3D,IAAiB,aAAa,CAsE7B;AAtED,WAAiB,aAAa;IAC5B,sDAAsD;IACtD,SAAgB,SAAS,CAA0C,IAAW;QAC5E,OAAO,sCAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAFe,uBAAS,YAExB,CAAA;IACD,8EAA8E;IAC9E,SAAgB,YAAY,CAA0C,IAAW;QAC/E,OAAO,sCAAgB,C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IAAW;QAEX,OAAO,sCAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IAJe,oCAAsB,yBAIrC,CAAA;IAED;;;;OAIG;IACH,SAAgB,oBAAoB,CAAC,YAA+D;QAClG,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7D,IAAI,sCAAgB,CAAC,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5D,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAVe,kCAAoB,uBAUnC,CAAA;AACH,CAAC,EAtEgB,aAAa,6BAAb,aAAa,QAsE7B","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 { HierarchyNodeKey } from \"./HierarchyNodeKey.js\";\n\nimport type { OmitOverUnion } from \"@itwin/presentation-shared\";\nimport type {\n ClassGroupingNodeKey,\n GenericNodeKey,\n GroupingNodeKey,\n IModelHierarchyNodeKey,\n IModelInstanceKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n} from \"./HierarchyNodeKey.js\";\nimport type { HierarchySearchTree } from \"./HierarchySearch.js\";\n\n/** @public */\nexport interface HierarchyNodeSearchProps {\n /** If set to true, then one of the ancestor nodes in the hierarchy is the search target. */\n hasSearchTargetAncestor?: boolean;\n /** Paths to node's children that are search targets. */\n childrenTargetPaths?: HierarchySearchTree[];\n /** Whether or not this node is a search target. */\n isSearchTarget?: boolean;\n /** Options assigned to this node through search. */\n options?: HierarchySearchTree[\"options\"];\n}\n\n/**\n * A data structure that defines attributes that are common to all types of hierarchy nodes.\n * @public\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @public\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: GenericNodeKey | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n /** Data that is assigned to the node if hierarchy search is enabled */\n search?: HierarchyNodeSearchProps;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @public\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: IModelInstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @public\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a generic node */\n export function isGeneric<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: GenericNodeKey } {\n return HierarchyNodeKey.isGeneric(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isIModelNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: IModelHierarchyNodeKey } {\n return HierarchyNodeKey.isIModelNodeKey(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & GroupingHierarchyNode {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n\n /**\n * Gets the grouping level of the given grouping node.\n *\n * May be useful when setting `groupingLevel` for `HierarchySearchTree.options.autoExpand` or `HierarchySearchPathOptions.reveal`.\n */\n export function getGroupingNodeLevel(groupingNode: Pick<GroupingHierarchyNode, \"key\" | \"parentKeys\">): number {\n let level = 1;\n for (let i = groupingNode.parentKeys.length - 1; i >= 0; i--) {\n if (HierarchyNodeKey.isGrouping(groupingNode.parentKeys[i])) {\n level++;\n } else {\n break;\n }\n }\n return level;\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n * @public\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n"]}
@@ -18,6 +18,8 @@ export declare namespace HierarchyNodeIdentifier {
18
18
  function isGenericNodeIdentifier(id: HierarchyNodeIdentifier): id is GenericNodeKey;
19
19
  /** Checks two identifiers for equality */
20
20
  function equal(lhs: HierarchyNodeIdentifier, rhs: HierarchyNodeIdentifier): boolean;
21
+ /** Compares two identifiers */
22
+ function compare(lhs: HierarchyNodeIdentifier, rhs: HierarchyNodeIdentifier): number;
21
23
  }
22
24
  /**
23
25
  * A path of hierarchy node identifiers, typically used to describe a path from root down
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNodeIdentifier.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNodeIdentifier.ts"],"names":[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