@itwin/presentation-hierarchies 2.0.0-alpha.6 → 2.0.0-alpha.8

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 (111) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +3 -3
  3. package/lib/cjs/hierarchies/HierarchyMerge.js +1 -1
  4. package/lib/cjs/hierarchies/HierarchyMerge.js.map +1 -1
  5. package/lib/cjs/hierarchies/HierarchyNode.d.ts +14 -24
  6. package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
  7. package/lib/cjs/hierarchies/HierarchyNode.js +1 -21
  8. package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
  9. package/lib/cjs/hierarchies/HierarchyProvider.d.ts +11 -11
  10. package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
  11. package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
  12. package/lib/cjs/hierarchies/{HierarchyFiltering.d.ts → HierarchySearch.d.ts} +42 -52
  13. package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -0
  14. package/lib/cjs/hierarchies/{HierarchyFiltering.js → HierarchySearch.js} +69 -85
  15. package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -0
  16. package/lib/cjs/hierarchies/imodel/HierarchyCache.js +3 -3
  17. package/lib/cjs/hierarchies/imodel/HierarchyCache.js.map +1 -1
  18. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +12 -3
  19. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
  20. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
  21. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +4 -4
  22. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  23. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +52 -24
  24. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  25. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  26. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +1 -1
  27. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  28. package/lib/cjs/hierarchies/imodel/{FilteringHierarchyDefinition.d.ts → SearchHierarchyDefinition.d.ts} +11 -13
  29. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
  30. package/lib/cjs/hierarchies/imodel/{FilteringHierarchyDefinition.js → SearchHierarchyDefinition.js} +101 -105
  31. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
  32. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +4 -6
  33. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  34. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +6 -5
  35. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  36. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
  37. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +6 -5
  38. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
  39. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
  40. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -3
  41. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
  42. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
  43. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +21 -16
  44. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
  45. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts +7 -3
  46. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
  47. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +2 -2
  48. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
  49. package/lib/cjs/presentation-hierarchies.d.ts +2 -2
  50. package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
  51. package/lib/cjs/presentation-hierarchies.js +4 -5
  52. package/lib/cjs/presentation-hierarchies.js.map +1 -1
  53. package/lib/esm/hierarchies/HierarchyMerge.js +1 -1
  54. package/lib/esm/hierarchies/HierarchyMerge.js.map +1 -1
  55. package/lib/esm/hierarchies/HierarchyNode.d.ts +14 -24
  56. package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
  57. package/lib/esm/hierarchies/HierarchyNode.js +0 -20
  58. package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
  59. package/lib/esm/hierarchies/HierarchyProvider.d.ts +11 -11
  60. package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
  61. package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
  62. package/lib/esm/hierarchies/{HierarchyFiltering.d.ts → HierarchySearch.d.ts} +42 -52
  63. package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -0
  64. package/lib/esm/hierarchies/{HierarchyFiltering.js → HierarchySearch.js} +67 -82
  65. package/lib/esm/hierarchies/HierarchySearch.js.map +1 -0
  66. package/lib/esm/hierarchies/imodel/HierarchyCache.js +3 -3
  67. package/lib/esm/hierarchies/imodel/HierarchyCache.js.map +1 -1
  68. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +12 -3
  69. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
  70. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
  71. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +4 -4
  72. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  73. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +52 -24
  74. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  75. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  76. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +2 -2
  77. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  78. package/lib/esm/hierarchies/imodel/{FilteringHierarchyDefinition.d.ts → SearchHierarchyDefinition.d.ts} +11 -13
  79. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
  80. package/lib/esm/hierarchies/imodel/{FilteringHierarchyDefinition.js → SearchHierarchyDefinition.js} +96 -100
  81. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
  82. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +4 -6
  83. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  84. package/lib/esm/hierarchies/imodel/TreeNodesReader.js +3 -3
  85. package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  86. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
  87. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +7 -6
  88. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
  89. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
  90. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +5 -4
  91. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
  92. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
  93. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +22 -17
  94. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
  95. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts +7 -3
  96. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
  97. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +2 -2
  98. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
  99. package/lib/esm/presentation-hierarchies.d.ts +2 -2
  100. package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
  101. package/lib/esm/presentation-hierarchies.js +1 -1
  102. package/lib/esm/presentation-hierarchies.js.map +1 -1
  103. package/package.json +8 -8
  104. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +0 -1
  105. package/lib/cjs/hierarchies/HierarchyFiltering.js.map +0 -1
  106. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
  107. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
  108. package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +0 -1
  109. package/lib/esm/hierarchies/HierarchyFiltering.js.map +0 -1
  110. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
  111. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
@@ -4,14 +4,13 @@
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.HierarchyFilteringPath = void 0;
8
- exports.extractFilteringProps = extractFilteringProps;
9
- exports.createHierarchyFilteringHelper = createHierarchyFilteringHelper;
7
+ exports.HierarchySearchPath = void 0;
8
+ exports.createHierarchySearchHelper = createHierarchySearchHelper;
10
9
  exports.shouldAutoExpandBasedOnReveal = shouldAutoExpandBasedOnReveal;
11
10
  const HierarchyNodeIdentifier_js_1 = require("./HierarchyNodeIdentifier.js");
12
11
  const HierarchyNodeKey_js_1 = require("./HierarchyNodeKey.js");
13
- var HierarchyFilteringPathOptions;
14
- (function (HierarchyFilteringPathOptions) {
12
+ var HierarchySearchPathOptions;
13
+ (function (HierarchySearchPathOptions) {
15
14
  function mergeRevealOptions(lhs, rhs) {
16
15
  if (rhs === true || lhs === true) {
17
16
  return true;
@@ -34,18 +33,18 @@ var HierarchyFilteringPathOptions;
34
33
  }
35
34
  return lhsDepth > rhsDepth ? lhs : rhs;
36
35
  }
37
- HierarchyFilteringPathOptions.mergeRevealOptions = mergeRevealOptions;
36
+ HierarchySearchPathOptions.mergeRevealOptions = mergeRevealOptions;
38
37
  function mergeAutoExpandOption(lhs, rhs) {
39
38
  return lhs || rhs ? true : undefined;
40
39
  }
41
- HierarchyFilteringPathOptions.mergeAutoExpandOption = mergeAutoExpandOption;
42
- })(HierarchyFilteringPathOptions || (HierarchyFilteringPathOptions = {}));
40
+ HierarchySearchPathOptions.mergeAutoExpandOption = mergeAutoExpandOption;
41
+ })(HierarchySearchPathOptions || (HierarchySearchPathOptions = {}));
43
42
  /** @public */
44
43
  // eslint-disable-next-line @typescript-eslint/no-redeclare
45
- var HierarchyFilteringPath;
46
- (function (HierarchyFilteringPath) {
44
+ var HierarchySearchPath;
45
+ (function (HierarchySearchPath) {
47
46
  /**
48
- * Normalizes the hierarchy filtering path to the object form.
47
+ * Normalizes the hierarchy search path to the object form.
49
48
  * @public
50
49
  */
51
50
  function normalize(source) {
@@ -54,9 +53,9 @@ var HierarchyFilteringPath;
54
53
  }
55
54
  return source;
56
55
  }
57
- HierarchyFilteringPath.normalize = normalize;
56
+ HierarchySearchPath.normalize = normalize;
58
57
  /**
59
- * Merges two given `HierarchyFilteringPathOptions` objects.
58
+ * Merges two given `HierarchySearchPathOptions` objects.
60
59
  *
61
60
  * For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:
62
61
  * - if any one of the inputs is `true`, return `true`,
@@ -69,8 +68,8 @@ var HierarchyFilteringPath;
69
68
  * @public
70
69
  */
71
70
  function mergeOptions(lhs, rhs) {
72
- const reveal = HierarchyFilteringPathOptions.mergeRevealOptions(lhs?.reveal, rhs?.reveal);
73
- const autoExpand = HierarchyFilteringPathOptions.mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);
71
+ const reveal = HierarchySearchPathOptions.mergeRevealOptions(lhs?.reveal, rhs?.reveal);
72
+ const autoExpand = HierarchySearchPathOptions.mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);
74
73
  return reveal || autoExpand
75
74
  ? {
76
75
  ...(reveal !== undefined ? { reveal } : undefined),
@@ -78,55 +77,40 @@ var HierarchyFilteringPath;
78
77
  }
79
78
  : undefined;
80
79
  }
81
- HierarchyFilteringPath.mergeOptions = mergeOptions;
82
- })(HierarchyFilteringPath || (exports.HierarchyFilteringPath = HierarchyFilteringPath = {}));
83
- /**
84
- * An utility that extracts filtering properties from given root level filtering props or
85
- * the parent node. Returns `undefined` if filtering props are not present.
86
- * @public
87
- * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.
88
- */
80
+ HierarchySearchPath.mergeOptions = mergeOptions;
81
+ })(HierarchySearchPath || (exports.HierarchySearchPath = HierarchySearchPath = {}));
82
+ // TODO: remove c8 ignore start and add tests to cover the gaps
89
83
  /* c8 ignore start */
90
- function extractFilteringProps(rootLevelFilteringProps, parentNode) {
91
- const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
92
- return filteringProps?.filteredNodePaths !== undefined
93
- ? {
94
- filteredNodePaths: filteringProps.filteredNodePaths,
95
- hasFilterTargetAncestor: filteringProps.hasFilterTargetAncestor,
96
- }
97
- : undefined;
98
- }
99
- /* c8 ignore end */
100
- function extractFilteringPropsInternal(rootLevelFilteringProps, parentNode) {
84
+ function extractSearchPropsInternal(rootLevelSearchProps, parentNode) {
101
85
  if (!parentNode) {
102
- return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;
86
+ return rootLevelSearchProps ? { childrenTargetPaths: rootLevelSearchProps, hasSearchTargetAncestor: false } : undefined;
103
87
  }
104
- const filteringProps = {
105
- ...(parentNode.filtering?.filteredChildrenIdentifierPaths ? { filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths } : undefined),
106
- hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor || !!parentNode.filtering?.isFilterTarget,
88
+ const searchProps = {
89
+ ...(parentNode.search?.childrenTargetPaths ? { childrenTargetPaths: parentNode.search.childrenTargetPaths } : undefined),
90
+ hasSearchTargetAncestor: !!parentNode.search?.hasSearchTargetAncestor || !!parentNode.search?.isSearchTarget,
107
91
  };
108
- return filteringProps.filteredNodePaths || filteringProps.hasFilterTargetAncestor ? filteringProps : undefined;
92
+ return searchProps.childrenTargetPaths || searchProps.hasSearchTargetAncestor ? searchProps : undefined;
109
93
  }
110
94
  /**
111
- * Creates a set of utilities for making it easier to filter the given hierarchy
95
+ * Creates a set of utilities for making it easier to search the given hierarchy
112
96
  * level.
113
97
  *
114
98
  * @public
115
99
  */
116
- function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
117
- const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
118
- const hasFilter = !!filteringProps;
119
- function saveFilteringPropsFromPathsIntoReducer(extractionProps) {
100
+ function createHierarchySearchHelper(rootLevelSearchProps, parentNode) {
101
+ const searchProps = extractSearchPropsInternal(rootLevelSearchProps, parentNode);
102
+ const hasSearch = !!searchProps;
103
+ function saveSearchPropsFromPathsIntoReducer(extractionProps) {
120
104
  // Passes down matching normalized paths to the reducer.
121
- // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` at the first position in filtering path matches the node
105
+ // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` at the first position in search path matches the node
122
106
  // and if it does, the path is passed down to the reducer.
123
107
  // This function returns a promise only if asyncPathMatcher returns a promise.
124
- if (!filteringProps?.filteredNodePaths) {
108
+ if (!searchProps?.childrenTargetPaths) {
125
109
  return;
126
110
  }
127
111
  const matchedPathPromises = new Array();
128
- for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
129
- const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
112
+ for (const childrenTargetPaths of searchProps.childrenTargetPaths) {
113
+ const normalizedPath = HierarchySearchPath.normalize(childrenTargetPaths);
130
114
  /* c8 ignore next 3 */
131
115
  if (normalizedPath.path.length === 0) {
132
116
  continue;
@@ -154,47 +138,47 @@ function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
154
138
  return Promise.all(matchedPathPromises).then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && extractionProps.pathsReducer.accept(normalizedPath)));
155
139
  }
156
140
  function createChildNodeProps(props) {
157
- if (!hasFilter) {
141
+ if (!hasSearch) {
158
142
  return undefined;
159
143
  }
160
- const reducer = new MatchingFilteringPathsReducer(filteringProps.hasFilterTargetAncestor);
144
+ const reducer = new MatchingSearchPathsReducer(searchProps.hasSearchTargetAncestor);
161
145
  if ("asyncPathMatcher" in props) {
162
- const extractResult = saveFilteringPropsFromPathsIntoReducer({ pathsReducer: reducer, asyncPathMatcher: props.asyncPathMatcher });
146
+ const extractResult = saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, asyncPathMatcher: props.asyncPathMatcher });
163
147
  if (extractResult instanceof Promise) {
164
148
  return extractResult.then(() => reducer.getNodeProps(props.parentKeys));
165
149
  }
166
150
  }
167
151
  else {
168
- saveFilteringPropsFromPathsIntoReducer({ ...props, pathsReducer: reducer });
152
+ saveSearchPropsFromPathsIntoReducer({ ...props, pathsReducer: reducer });
169
153
  }
170
154
  return reducer.getNodeProps(props.parentKeys);
171
155
  }
172
156
  return {
173
157
  /** Returns a flag indicating if the hierarchy level is filtered. */
174
- hasFilter,
158
+ hasSearch,
175
159
  /**
176
160
  * Returns a flag indicating whether this hierarchy level has an ancestor node
177
- * that is a filter target. That generally means that this and all downstream hierarchy
178
- * levels should be displayed without filter being applied to them, even if filter paths
161
+ * that is a search target. That generally means that this and all downstream hierarchy
162
+ * levels should be displayed without search being applied to them, even if search paths
179
163
  * say otherwise.
180
164
  */
181
- hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,
165
+ hasSearchTargetAncestor: searchProps?.hasSearchTargetAncestor ?? false,
182
166
  /**
183
167
  * Returns a list of hierarchy node identifiers that apply specifically for this
184
- * hierarchy level. Returns `undefined` if filtering is not applied to this level.
168
+ * hierarchy level. Returns `undefined` if search is not applied to this level.
185
169
  */
186
- getChildNodeFilteringIdentifiers: () => {
187
- if (!filteringProps?.filteredNodePaths) {
170
+ getChildNodeSearchIdentifiers: () => {
171
+ if (!searchProps?.childrenTargetPaths) {
188
172
  return undefined;
189
173
  }
190
- return filteringProps.filteredNodePaths
191
- .map(HierarchyFilteringPath.normalize)
174
+ return searchProps.childrenTargetPaths
175
+ .map(HierarchySearchPath.normalize)
192
176
  .filter(({ path }) => path.length > 0)
193
177
  .map(({ path }) => path[0]);
194
178
  },
195
179
  /**
196
- * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`
197
- * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
180
+ * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `search`
181
+ * and `autoExpand`) to be set based on the search paths and search options. This function calculates
198
182
  * these props for a child node based on its key or path matcher.
199
183
  *
200
184
  * When using `pathMatcher` or `asyncPathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
@@ -202,7 +186,7 @@ function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
202
186
  * `nodeKey` prop can be used to check the whole identifier.
203
187
  *
204
188
  * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:
205
- * - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `filtering` and `autoExpand` prop from `HierarchyNode`;
189
+ * - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;
206
190
  * - `parentKeys` is undefined - does not return `HierarchyNode.autoExpand` option;
207
191
  * - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.
208
192
  */
@@ -210,42 +194,42 @@ function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
210
194
  };
211
195
  }
212
196
  /**
213
- * Extracts information from filtering paths and later returns `filtering` and `autoExpand` values from `HierarchyNode`.
197
+ * Extracts information from search paths and later returns `search` and `autoExpand` values from `HierarchyNode`.
214
198
  *
215
199
  * 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`.
216
200
  *
217
201
  * Extracts information using `accept` function:
218
- * - Determines if node is filter target, and if it is saves the options as `filterTargetOptions`
219
- * - Saves `HierarchyFilteringPathOptions` and `filteredChildrenIdentifierPaths`
202
+ * - Determines if node is search target, and if it is saves the options as `searchTargetOptions`
203
+ * - Saves `HierarchySearchPathOptions` and `childrenTargetPaths`
220
204
  */
221
- class MatchingFilteringPathsReducer {
222
- _hasFilterTargetAncestor;
223
- _filteredChildrenIdentifierPaths = new Array();
224
- _isFilterTarget = false;
225
- _filterTargetOptions = undefined;
205
+ class MatchingSearchPathsReducer {
206
+ _hasSearchTargetAncestor;
207
+ _childrenTargetPaths = new Array();
208
+ _isSearchTarget = false;
209
+ _searchTargetOptions = undefined;
226
210
  _revealOption = false;
227
- constructor(_hasFilterTargetAncestor) {
228
- this._hasFilterTargetAncestor = _hasFilterTargetAncestor;
211
+ constructor(_hasSearchTargetAncestor) {
212
+ this._hasSearchTargetAncestor = _hasSearchTargetAncestor;
229
213
  }
230
214
  accept(normalizedPath) {
231
215
  const { path, options } = normalizedPath;
232
216
  if (path.length === 1) {
233
- this._isFilterTarget = true;
234
- this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);
217
+ this._isSearchTarget = true;
218
+ this._searchTargetOptions = HierarchySearchPath.mergeOptions(this._searchTargetOptions, options);
235
219
  }
236
220
  else if (path.length > 1) {
237
- this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });
238
- this._revealOption = HierarchyFilteringPathOptions.mergeRevealOptions(options?.reveal, this._revealOption);
221
+ this._childrenTargetPaths.push({ path: path.slice(1), options });
222
+ this._revealOption = HierarchySearchPathOptions.mergeRevealOptions(options?.reveal, this._revealOption);
239
223
  }
240
224
  }
241
225
  getNodeProps(parentKeys) {
242
226
  return {
243
- ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0
227
+ ...(this._hasSearchTargetAncestor || this._isSearchTarget || this._childrenTargetPaths.length > 0
244
228
  ? {
245
- filtering: {
246
- ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),
247
- ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),
248
- ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),
229
+ search: {
230
+ ...(this._hasSearchTargetAncestor ? { hasSearchTargetAncestor: true } : undefined),
231
+ ...(this._isSearchTarget ? { isSearchTarget: true, searchTargetOptions: this._searchTargetOptions } : undefined),
232
+ ...(this._childrenTargetPaths.length > 0 ? { childrenTargetPaths: this._childrenTargetPaths } : undefined),
249
233
  },
250
234
  }
251
235
  : undefined),
@@ -255,7 +239,7 @@ class MatchingFilteringPathsReducer {
255
239
  nodePositionInHierarchy: parentKeys.length,
256
240
  nodePositionInPath: parentKeys.filter((key) => !HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(key)).length,
257
241
  }) ||
258
- !!this._filterTargetOptions?.autoExpand)
242
+ !!this._searchTargetOptions?.autoExpand)
259
243
  ? { autoExpand: true }
260
244
  : undefined),
261
245
  };
@@ -274,4 +258,4 @@ function shouldAutoExpandBasedOnReveal({ reveal, nodePositionInPath, nodePositio
274
258
  }
275
259
  return nodePositionInPath < reveal.depthInPath;
276
260
  }
277
- //# sourceMappingURL=HierarchyFiltering.js.map
261
+ //# sourceMappingURL=HierarchySearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HierarchySearch.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA6LhG,kEAyKC;AA2DD,sEAmBC;AAjbD,6EAAqG;AACrG,+DAA2F;AAsE3F,IAAU,0BAA0B,CAmCnC;AAnCD,WAAU,0BAA0B;IAClC,SAAgB,kBAAkB,CAChC,GAAyC,EACzC,GAAyC;QAEzC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC3B,CAAC;QAED,MAAM,QAAQ,GAAG,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC/E,MAAM,QAAQ,GAAG,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC/E,MAAM,qBAAqB,GAAG,aAAa,IAAI,GAAG,CAAC;QACnD,MAAM,qBAAqB,GAAG,aAAa,IAAI,GAAG,CAAC;QAEnD,IAAI,qBAAqB,EAAE,CAAC;YAC1B,IAAI,qBAAqB,EAAE,CAAC;gBAC1B,OAAO,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YACzC,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,IAAI,qBAAqB,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC;QACb,CAAC;QACD,OAAO,QAAQ,GAAG,QA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ACF;AAED,gBAAgB;AAChB,SAAgB,6BAA6B,CAAC,EAC5C,MAAM,EACN,kBAAkB,EAClB,uBAAuB,GAKxB;IACC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,kBAAkB,IAAI,MAAM,EAAE,CAAC;QACjC,OAAO,uBAAuB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC3D,CAAC;IACD,OAAO,kBAAkB,GAAG,MAAM,CAAC,WAAW,CAAC;AACjD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface SearchPathRevealDepthInPath {\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/** @public */\nexport interface SearchPathRevealDepthInHierarchy {\n /**\n * Considering the list of nodes from root to the target node, this is an index in that list, identifying the node that should be revealed in hierarchy by auto-expanding its ancestors.\n *\n * This should take into account the number of grouping nodes in hierarchy.\n *\n * **Use case example:**\n *\n * Only `Node1` and `GroupingNode1` should have `autoExpand` flag in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n *\n * Provide `{ path: [Node1, Element1], reveal: { depthInHierarchy: 2 } }`\n *\n * To get the correct depth use `HierarchyNode.parentKeys.length`.\n *\n * **NOTE**: All nodes that are up to `depthInHierarchy` will be expanded **except** search targets.\n */\n depthInHierarchy: number;\n}\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 an instance of `SearchPathRevealDepthInPath`, then all nodes up to `depthInPath` will have `autoExpand` flag.\n * - If it's an instance of `SearchPathRevealDepthInHierarchy`, then all nodes up to `depthInHierarchy` will have `autoExpand` flag.\n */\n reveal?: boolean | SearchPathRevealDepthInHierarchy | SearchPathRevealDepthInPath;\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\nnamespace HierarchySearchPathOptions {\n export function mergeRevealOptions(\n lhs: HierarchySearchPathOptions[\"reveal\"],\n rhs: HierarchySearchPathOptions[\"reveal\"],\n ): HierarchySearchPathOptions[\"reveal\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n const lhsDepth = \"depthInPath\" in lhs ? lhs.depthInPath : lhs.depthInHierarchy;\n const rhsDepth = \"depthInPath\" in rhs ? rhs.depthInPath : rhs.depthInHierarchy;\n const isLhsDepthBasedOnPath = \"depthInPath\" in lhs;\n const isRhsDepthBasedOnPath = \"depthInPath\" in rhs;\n\n if (isLhsDepthBasedOnPath) {\n if (isRhsDepthBasedOnPath) {\n return lhsDepth > rhsDepth ? lhs : rhs;\n }\n return lhs;\n }\n if (isRhsDepthBasedOnPath) {\n return rhs;\n }\n return lhsDepth > rhsDepth ? lhs : rhs;\n }\n\n export 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 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 `depthInHierarchy` set, return the other one,\n * - else return the one with greater `depthInPath` or `depthInHierarchy`.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchySearchPathOptions | undefined,\n rhs: HierarchySearchPathOptions | undefined,\n ): HierarchySearchPathOptions | undefined {\n const reveal = HierarchySearchPathOptions.mergeRevealOptions(lhs?.reveal, rhs?.reveal);\n const autoExpand = HierarchySearchPathOptions.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}\n\n// TODO: remove c8 ignore start and add tests to cover the gaps\n/* c8 ignore start */\n\nfunction extractSearchPropsInternal(\n rootLevelSearchProps: HierarchySearchPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"search\"> | undefined,\n):\n | {\n childrenTargetPaths?: HierarchySearchPath[];\n hasSearchTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelSearchProps ? { childrenTargetPaths: rootLevelSearchProps, hasSearchTargetAncestor: false } : undefined;\n }\n const searchProps: {\n childrenTargetPaths?: HierarchySearchPath[];\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: HierarchySearchPath[] | 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 } & (\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | { pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean }\n ),\n ): void;\n function saveSearchPropsFromPathsIntoReducer(extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): void | Promise<void>;\n function saveSearchPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingSearchPathsReducer;\n } & (\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | { pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean }\n | { asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean> }\n ),\n ): void | Promise<void> {\n // Passes down matching normalized paths to the reducer.\n // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` at the first position in search path 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 matchedPathPromises = new Array<Promise<NormalizedSearchPath | undefined>>();\n for (const childrenTargetPaths of searchProps.childrenTargetPaths) {\n const normalizedPath = HierarchySearchPath.normalize(childrenTargetPaths);\n /* c8 ignore next 3 */\n if (normalizedPath.path.length === 0) {\n continue;\n }\n if (\"nodeKey\" in extractionProps) {\n if (\n (HierarchyNodeKey.isGeneric(extractionProps.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], extractionProps.nodeKey)) ||\n (HierarchyNodeKey.isInstances(extractionProps.nodeKey) &&\n extractionProps.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik)))\n ) {\n extractionProps.pathsReducer.accept(normalizedPath);\n }\n continue;\n }\n\n const matchesPossiblyPromise =\n \"pathMatcher\" in extractionProps ? extractionProps.pathMatcher(normalizedPath.path[0]) : extractionProps.asyncPathMatcher(normalizedPath.path[0]);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));\n continue;\n }\n if (matchesPossiblyPromise) {\n extractionProps.pathsReducer.accept(normalizedPath);\n }\n }\n if (matchedPathPromises.length === 0) {\n return;\n }\n return Promise.all(matchedPathPromises).then((matchedPath) =>\n matchedPath.forEach((normalizedPath) => normalizedPath && extractionProps.pathsReducer.accept(normalizedPath)),\n );\n }\n\n function createChildNodeProps(props: {\n parentKeys?: undefined;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }): Pick<NonGroupingHierarchyNode, \"search\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys?: undefined;\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }): Pick<NonGroupingHierarchyNode, \"search\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys?: undefined;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<NonGroupingHierarchyNode, \"search\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys: HierarchyNodeKey[];\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys: HierarchyNodeKey[];\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }): Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys: HierarchyNodeKey[];\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(\n props: { parentKeys?: HierarchyNodeKey[] } & (\n | {\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n ),\n ):\n | Promise<Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> | Pick<NonGroupingHierarchyNode, \"search\"> | undefined>\n | Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\">\n | Pick<NonGroupingHierarchyNode, \"search\">\n | undefined {\n if (!hasSearch) {\n return undefined;\n }\n const reducer = new MatchingSearchPathsReducer(searchProps.hasSearchTargetAncestor);\n if (\"asyncPathMatcher\" in props) {\n const extractResult = saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, asyncPathMatcher: props.asyncPathMatcher });\n if (extractResult instanceof Promise) {\n return extractResult.then(() => reducer.getNodeProps(props.parentKeys));\n }\n } else {\n saveSearchPropsFromPathsIntoReducer({ ...props, pathsReducer: reducer });\n }\n return reducer.getNodeProps(props.parentKeys);\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\n .map(HierarchySearchPath.normalize)\n .filter(({ path }) => path.length > 0)\n .map(({ path }) => path[0]);\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 * - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;\n * - `parentKeys` is undefined - does not return `HierarchyNode.autoExpand` option;\n * - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.\n */\n createChildNodeProps,\n };\n}\n\ntype NormalizedSearchPath = ReturnType<(typeof HierarchySearchPath)[\"normalize\"]>;\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<NormalizedSearchPath>();\n private _isSearchTarget = false;\n private _searchTargetOptions: HierarchySearchPathOptions | undefined = undefined;\n private _revealOption: HierarchySearchPathOptions[\"reveal\"] = false;\n\n public constructor(private _hasSearchTargetAncestor: boolean) {}\n\n public accept(normalizedPath: NormalizedSearchPath): void {\n const { path, options } = normalizedPath;\n if (path.length === 1) {\n this._isSearchTarget = true;\n this._searchTargetOptions = HierarchySearchPath.mergeOptions(this._searchTargetOptions, options);\n } else if (path.length > 1) {\n this._childrenTargetPaths.push({ path: path.slice(1), options });\n this._revealOption = HierarchySearchPathOptions.mergeRevealOptions(options?.reveal, this._revealOption);\n }\n }\n\n public getNodeProps<T extends HierarchyNodeKey[] | undefined = undefined>(\n parentKeys?: T,\n ): T extends undefined ? Pick<NonGroupingHierarchyNode, \"search\"> : Pick<NonGroupingHierarchyNode, \"search\" | \"autoExpand\"> {\n return {\n ...(this._hasSearchTargetAncestor || this._isSearchTarget || this._childrenTargetPaths.length > 0\n ? {\n search: {\n ...(this._hasSearchTargetAncestor ? { hasSearchTargetAncestor: true } : undefined),\n ...(this._isSearchTarget ? { isSearchTarget: true, searchTargetOptions: this._searchTargetOptions } : undefined),\n ...(this._childrenTargetPaths.length > 0 ? { childrenTargetPaths: this._childrenTargetPaths } : undefined),\n },\n }\n : undefined),\n ...(parentKeys &&\n (shouldAutoExpandBasedOnReveal({\n reveal: this._revealOption,\n nodePositionInHierarchy: parentKeys.length,\n nodePositionInPath: parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length,\n }) ||\n !!this._searchTargetOptions?.autoExpand)\n ? { autoExpand: true }\n : undefined),\n };\n }\n}\n\n/** @internal */\nexport function shouldAutoExpandBasedOnReveal({\n reveal,\n nodePositionInPath,\n nodePositionInHierarchy,\n}: {\n reveal: HierarchySearchPathOptions[\"reveal\"];\n nodePositionInPath: number;\n nodePositionInHierarchy: number;\n}): boolean {\n if (!reveal) {\n return false;\n }\n if (reveal === true) {\n return true;\n }\n if (\"depthInHierarchy\" in reveal) {\n return nodePositionInHierarchy < reveal.depthInHierarchy;\n }\n return nodePositionInPath < reveal.depthInPath;\n}\n"]}
@@ -17,11 +17,11 @@ class HierarchyCache {
17
17
  }
18
18
  createCacheKeys(props) {
19
19
  function createVariationKey() {
20
- const { instanceFilter, hierarchyLevelSizeLimit, filteredInstanceKeys } = props;
21
- if (instanceFilter === undefined && hierarchyLevelSizeLimit === undefined && filteredInstanceKeys === undefined) {
20
+ const { instanceFilter, hierarchyLevelSizeLimit, targetInstanceKeys } = props;
21
+ if (instanceFilter === undefined && hierarchyLevelSizeLimit === undefined && targetInstanceKeys === undefined) {
22
22
  return undefined;
23
23
  }
24
- return JSON.stringify({ instanceFilter, hierarchyLevelSizeLimit, filteredInstanceKeys });
24
+ return JSON.stringify({ instanceFilter, hierarchyLevelSizeLimit, targetInstanceKeys });
25
25
  }
26
26
  if (!props.parentNode) {
27
27
  return { primaryKey: [], variationKey: createVariationKey() };
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyCache.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/HierarchyCache.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAAsE;AAEtE,gEAA0D;AAe1D,gBAAgB;AAChB,MAAa,cAAc;IACjB,IAAI,CAA4D;IAChE,MAAM,CAAiC;IAE/C,YAAmB,KAAqC;QACtD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,4BAAa,CAA6C,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;IAClH,CAAC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AAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACpC,MAAM,iBAAiB,GAAG,sCAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,IAAI,iBAAiB,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,iBAAiB,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { LRUCache, LRUDictionary, LRUMap } from \"@itwin/core-bentley\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeKey } from \"../HierarchyNodeKey.js\";\nimport { GetHierarchyNodesProps } from \"../HierarchyProvider.js\";\n\ninterface HierarchyCacheEntry<T> {\n /** Stores observables for the default case - no instance filter or custom limit for the hierarchy level. */\n primary: T | undefined;\n /** Stores a limited number of variations with custom instance filter and/or custom limit for the hierarchy level. */\n variations: LRUCache<string, T>;\n}\n\ninterface ChildNodeObservablesCacheProps {\n size: number;\n variationsCount?: number;\n}\n\n/** @internal */\nexport class HierarchyCache<T> {\n private _map: LRUDictionary<HierarchyNodeKey[], HierarchyCacheEntry<T>>;\n private _props: ChildNodeObservablesCacheProps;\n\n public constructor(props: ChildNodeObservablesCacheProps) {\n this._props = props;\n this._map = new LRUDictionary<HierarchyNodeKey[], HierarchyCacheEntry<T>>(props.size, compareHierarchyNodeKeys);\n }\n\n private createCacheKeys(\n props: Omit<GetHierarchyNodesProps, \"parentNode\"> & {\n parentNode: { key: HierarchyNodeKey; parentKeys: HierarchyNodeKey[] } | undefined;\n filteredInstanceKeys?: InstanceKey[];\n },\n ) {\n function createVariationKey() {\n const { instanceFilter, hierarchyLevelSizeLimit, filteredInstanceKeys } = props;\n if (instanceFilter === undefined && hierarchyLevelSizeLimit === undefined && filteredInstanceKeys === undefined) {\n return undefined;\n }\n return JSON.stringify({ instanceFilter, hierarchyLevelSizeLimit, filteredInstanceKeys });\n }\n\n if (!props.parentNode) {\n return { primaryKey: [], variationKey: createVariationKey() };\n }\n\n const parentKeys = props.parentNode.parentKeys;\n\n return {\n primaryKey: [...parentKeys, props.parentNode.key],\n variationKey: createVariationKey(),\n };\n }\n\n private getCacheAccessors(primaryKey: HierarchyNodeKey[], variationKey?: string) {\n const getMapEntry = (create: boolean) => {\n let entry = this._map.get(primaryKey);\n if (!entry && create) {\n entry = { primary: undefined, variations: new LRUMap(this._props.variationsCount ?? 1) };\n this._map.set(primaryKey, entry);\n }\n return entry;\n };\n if (variationKey) {\n return {\n get: () => getMapEntry(false)?.variations.get(variationKey),\n set: (value: T) => {\n getMapEntry(true)!.variations.set(variationKey, value);\n },\n };\n }\n return {\n get: () => getMapEntry(false)?.primary,\n set: (value: T) => {\n getMapEntry(true)!.primary = value;\n },\n };\n }\n\n public set(requestProps: GetHierarchyNodesProps, value: T) {\n const { primaryKey, variationKey } = this.createCacheKeys(requestProps);\n this.getCacheAccessors(primaryKey, variationKey).set(value);\n }\n\n public get(requestProps: GetHierarchyNodesProps): T | undefined {\n const { primaryKey, variationKey } = this.createCacheKeys(requestProps);\n return this.getCacheAccessors(primaryKey, variationKey).get();\n }\n\n public clear() {\n this._map.clear();\n }\n}\n\nfunction compareHierarchyNodeKeys(lhs: HierarchyNodeKey[], rhs: HierarchyNodeKey[]) {\n if (lhs.length !== rhs.length) {\n return lhs.length - rhs.length;\n }\n for (let i = 0; i < lhs.length; ++i) {\n const keysCompareResult = HierarchyNodeKey.compare(lhs[i], rhs[i]);\n if (keysCompareResult !== 0) {\n return keysCompareResult;\n }\n }\n return 0;\n}\n"]}
1
+ {"version":3,"file":"HierarchyCache.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/Hier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,GAAG,EAAE,CAAC;IAChE,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACF;AAzED,wCAyEC;AAED,SAAS,wBAAwB,CAAC,GAAuB,EAAE,GAAuB;IAChF,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACpC,MAAM,iBAAiB,GAAG,sCAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,IAAI,iBAAiB,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,iBAAiB,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { LRUCache, LRUDictionary, LRUMap } from \"@itwin/core-bentley\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { HierarchyNodeKey } from \"../HierarchyNodeKey.js\";\nimport { GetHierarchyNodesProps } from \"../HierarchyProvider.js\";\n\ninterface HierarchyCacheEntry<T> {\n /** Stores observables for the default case - no instance filter or custom limit for the hierarchy level. */\n primary: T | undefined;\n /** Stores a limited number of variations with custom instance filter and/or custom limit for the hierarchy level. */\n variations: LRUCache<string, T>;\n}\n\ninterface ChildNodeObservablesCacheProps {\n size: number;\n variationsCount?: number;\n}\n\n/** @internal */\nexport class HierarchyCache<T> {\n private _map: LRUDictionary<HierarchyNodeKey[], HierarchyCacheEntry<T>>;\n private _props: ChildNodeObservablesCacheProps;\n\n public constructor(props: ChildNodeObservablesCacheProps) {\n this._props = props;\n this._map = new LRUDictionary<HierarchyNodeKey[], HierarchyCacheEntry<T>>(props.size, compareHierarchyNodeKeys);\n }\n\n private createCacheKeys(\n props: Omit<GetHierarchyNodesProps, \"parentNode\"> & {\n parentNode: { key: HierarchyNodeKey; parentKeys: HierarchyNodeKey[] } | undefined;\n targetInstanceKeys?: InstanceKey[];\n },\n ) {\n function createVariationKey() {\n const { instanceFilter, hierarchyLevelSizeLimit, targetInstanceKeys } = props;\n if (instanceFilter === undefined && hierarchyLevelSizeLimit === undefined && targetInstanceKeys === undefined) {\n return undefined;\n }\n return JSON.stringify({ instanceFilter, hierarchyLevelSizeLimit, targetInstanceKeys });\n }\n\n if (!props.parentNode) {\n return { primaryKey: [], variationKey: createVariationKey() };\n }\n\n const parentKeys = props.parentNode.parentKeys;\n\n return {\n primaryKey: [...parentKeys, props.parentNode.key],\n variationKey: createVariationKey(),\n };\n }\n\n private getCacheAccessors(primaryKey: HierarchyNodeKey[], variationKey?: string) {\n const getMapEntry = (create: boolean) => {\n let entry = this._map.get(primaryKey);\n if (!entry && create) {\n entry = { primary: undefined, variations: new LRUMap(this._props.variationsCount ?? 1) };\n this._map.set(primaryKey, entry);\n }\n return entry;\n };\n if (variationKey) {\n return {\n get: () => getMapEntry(false)?.variations.get(variationKey),\n set: (value: T) => {\n getMapEntry(true)!.variations.set(variationKey, value);\n },\n };\n }\n return {\n get: () => getMapEntry(false)?.primary,\n set: (value: T) => {\n getMapEntry(true)!.primary = value;\n },\n };\n }\n\n public set(requestProps: GetHierarchyNodesProps, value: T) {\n const { primaryKey, variationKey } = this.createCacheKeys(requestProps);\n this.getCacheAccessors(primaryKey, variationKey).set(value);\n }\n\n public get(requestProps: GetHierarchyNodesProps): T | undefined {\n const { primaryKey, variationKey } = this.createCacheKeys(requestProps);\n return this.getCacheAccessors(primaryKey, variationKey).get();\n }\n\n public clear() {\n this._map.clear();\n }\n}\n\nfunction compareHierarchyNodeKeys(lhs: HierarchyNodeKey[], rhs: HierarchyNodeKey[]) {\n if (lhs.length !== rhs.length) {\n return lhs.length - rhs.length;\n }\n for (let i = 0; i < lhs.length; ++i) {\n const keysCompareResult = HierarchyNodeKey.compare(lhs[i], rhs[i]);\n if (keysCompareResult !== 0) {\n return keysCompareResult;\n }\n }\n return 0;\n}\n"]}
@@ -46,9 +46,16 @@ export type HierarchyLevelDefinition = HierarchyNodesDefinition[];
46
46
  * A type for a function that parses a `SourceInstanceHierarchyNode` from provided ECSQL `row` object.
47
47
  * @public
48
48
  */
49
- export type NodeParser = (row: {
50
- [columnName: string]: any;
51
- }, parentNode?: HierarchyDefinitionParentNode) => SourceInstanceHierarchyNode | Promise<SourceInstanceHierarchyNode>;
49
+ export type NodeParser = (props: {
50
+ /** The ECSQL row object to parse. Keys & value types depend on the executed query. */
51
+ row: {
52
+ [columnName: string]: any;
53
+ };
54
+ /** The parent node whose child node is being parsed. */
55
+ parentNode?: HierarchyDefinitionParentNode;
56
+ /** The key of iModel which is used to run the query. */
57
+ imodelKey: string;
58
+ }) => SourceInstanceHierarchyNode | Promise<SourceInstanceHierarchyNode>;
52
59
  /**
53
60
  * A type for a function that pre-processes given node. Unless the function decides not to make any modifications,
54
61
  * it should return a new - modified - node, rather than modifying the given one. Returning `undefined` omits the node
@@ -77,6 +84,8 @@ export type HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, "chil
77
84
  * @public
78
85
  */
79
86
  export interface DefineHierarchyLevelProps {
87
+ /** The key of iModel for which the hierarchy definition is being requested for. */
88
+ imodelKey: string;
80
89
  /** Parent node to get children for. Pass `undefined` to get root nodes. */
81
90
  parentNode: HierarchyDefinitionParentNode | undefined;
82
91
  /** Optional hierarchy level filter. */
@@ -1 +1 @@
1
- {"version":3,"file":"IModelHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OA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AM,iBAAiB,GAAG,CAAC,IAAI,EAAE,sBAAsB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAElG;;;;;;GAMG;AACH,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;AAEvF;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,2EAA2E;IAC3E,UAAU,EAAE,6BAA6B,GAAG,SAAS,CAAC;IAEtD,uCAAuC;IACvC,cAAc,CAAC,EAAE,qBAAqB,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IAEvB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAElC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;IAEpC,+EAA+E;IAC/E,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAC3F"}
1
+ {"version":3,"file":"IModelHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EAC9B,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,oDAAoD;IACpD,IAAI,EAAE,0BAA0B,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,KA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AAC,EAAE,qBAAqB,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IAEvB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAElC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;IAEpC,+EAA+E;IAC/E,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAC3F"}
@@ -1 +1 @@
1
- {"version":3,"file":"IModelHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA6ChG,cAAc;AACd,2DAA2D;AAC3D,IAAiB,wBAAwB,CAOxC;AAPD,WAAiB,wBAAwB;IACvC,SAAgB,aAAa,CAAC,GAA6B;QACzD,OAAO,CAAC,CAAE,GAAsC,CAAC,IAAI,CAAC;IACxD,CAAC;IAFe,sCAAa,gBAE5B,CAAA;IACD,SAAgB,oBAAoB,CAAC,GAA6B;QAChE,OAAO,CAAC,CAAE,GAAoC,CAAC,KAAK,CAAC;IACvD,CAAC;IAFe,6CAAoB,uBAEnC,CAAA;AACH,CAAC,EAPgB,wBAAwB,wCAAxB,wBAAwB,QAOxC","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 { GenericInstanceFilter } from \"@itwin/core-common\";\nimport { ECSqlQueryDef } from \"@itwin/presentation-shared\";\nimport { NonGroupingHierarchyNode } from \"../HierarchyNode.js\";\nimport {\n ProcessedGenericHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n SourceGenericHierarchyNode,\n SourceInstanceHierarchyNode,\n} from \"./IModelHierarchyNode.js\";\n\n/**\n * A nodes definition that returns a single generic node.\n * @public\n */\nexport interface GenericHierarchyNodeDefinition {\n /** The node to be created in the hierarchy level */\n node: SourceGenericHierarchyNode;\n}\n\n/**\n * A nodes definition that returns an ECSQL query for selecting nodes from an iModel.\n * @public\n */\nexport interface InstanceNodesQueryDefinition {\n /**\n * Full name of the class whose instances are going to be returned. It's okay if the attribute\n * points to a base class of multiple different classes of instances returned by the query, however\n * the more specific this class is, the more efficient hierarchy building process is.\n */\n fullClassName: string;\n /**\n * An ECSQL query that selects nodes from an iModel. `SELECT` clause of the query is expected\n * to be built using `NodeSelectQueryFactory.createSelectClause`.\n */\n query: ECSqlQueryDef;\n}\n\n/**\n * A definition of nodes included in a hierarchy level.\n * @public\n */\nexport type HierarchyNodesDefinition = GenericHierarchyNodeDefinition | InstanceNodesQueryDefinition;\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodesDefinition {\n export function isGenericNode(def: HierarchyNodesDefinition): def is GenericHierarchyNodeDefinition {\n return !!(def as GenericHierarchyNodeDefinition).node;\n }\n export function isInstanceNodesQuery(def: HierarchyNodesDefinition): def is InstanceNodesQueryDefinition {\n return !!(def as InstanceNodesQueryDefinition).query;\n }\n}\n\n/**\n * A definition of a hierarchy level, which may consist of multiple node definitions.\n * @public\n */\nexport type HierarchyLevelDefinition = HierarchyNodesDefinition[];\n\n/**\n * A type for a function that parses a `SourceInstanceHierarchyNode` from provided ECSQL `row` object.\n * @public\n */\nexport type NodeParser = (\n row: { [columnName: string]: any },\n parentNode?: HierarchyDefinitionParentNode,\n) => SourceInstanceHierarchyNode | Promise<SourceInstanceHierarchyNode>;\n\n/**\n * A type for a function that pre-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one. Returning `undefined` omits the node\n * from the hierarchy.\n *\n * @public\n */\nexport type NodePreProcessor = <TNode extends ProcessedGenericHierarchyNode | ProcessedInstanceHierarchyNode>(node: TNode) => Promise<TNode | undefined>;\n\n/**\n * A type for a function that post-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one.\n *\n * @public\n */\nexport type NodePostProcessor = (node: ProcessedHierarchyNode) => Promise<ProcessedHierarchyNode>;\n\n/**\n * A type of node that can be passed to `HierarchyDefinition.defineHierarchyLevel`. This basically means\n * a `HierarchyNode` that:\n * - knows nothing about its children,\n * - is either an instances node (key is of `InstancesNodeKey` type) or a generic node (key is of `GenericNodeKey` type).\n * @public\n */\nexport type HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, \"children\">;\n\n/**\n * Props for `HierarchyDefinition.defineHierarchyLevel`.\n * @public\n */\nexport interface DefineHierarchyLevelProps {\n /** Parent node to get children for. Pass `undefined` to get root nodes. */\n parentNode: HierarchyDefinitionParentNode | undefined;\n\n /** Optional hierarchy level filter. */\n instanceFilter?: GenericInstanceFilter;\n}\n\n/**\n * An interface for a factory that knows how define a hierarchy based on a given parent node.\n * @public\n */\nexport interface HierarchyDefinition {\n /**\n * An optional function for parsing ECInstance node from ECSQL row.\n *\n * Should be used in situations when the `HierarchyDefinition` implementation\n * introduces additional ECSQL columns into the select clause and wants to assign additional\n * data to the nodes it produces.\n *\n * Defaults to a function that parses all `HierarchyNode` attributes from a query, whose SELECT\n * clause is created using `NodeSelectQueryFactory.createSelectClause`.\n */\n parseNode?: NodeParser;\n\n /**\n * An optional function for pre-processing nodes.\n *\n * Pre-processing happens immediately after the nodes are loaded based on `HierarchyLevelDefinition`\n * returned by this `HierarchyDefinition` and before their processing (hiding, grouping, sorting, etc.) starts.\n * The step allows assigning nodes additional data or excluding them from the hierarchy based on some attributes.\n */\n preProcessNode?: NodePreProcessor;\n\n /**\n * An optional function for post-processing nodes.\n *\n * Post-processing happens after the loaded nodes go through all the merging, hiding and grouping\n * steps, but before sorting them. This step allows `HierarchyDefinition` implementations to assign additional data\n * to nodes after they're processed. This is especially true for grouping nodes as they're only created during\n * processing.\n */\n postProcessNode?: NodePostProcessor;\n\n /** A function to create a hierarchy level definition for given parent node. */\n defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;\n}\n"]}
1
+ {"version":3,"file":"IModelHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA6ChG,cAAc;AACd,2DAA2D;AAC3D,IAAiB,wBAAwB,CAOxC;AAPD,WAAiB,wBAAwB;IACvC,SAAgB,aAAa,CAAC,GAA6B;QACzD,OAAO,CAAC,CAAE,GAAsC,CAAC,IAAI,CAAC;IACxD,CAAC;IAFe,sCAAa,gBAE5B,CAAA;IACD,SAAgB,oBAAoB,CAAC,GAA6B;QAChE,OAAO,CAAC,CAAE,GAAoC,CAAC,KAAK,CAAC;IACvD,CAAC;IAFe,6CAAoB,uBAEnC,CAAA;AACH,CAAC,EAPgB,wBAAwB,wCAAxB,wBAAwB,QAOxC","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 { GenericInstanceFilter } from \"@itwin/core-common\";\nimport { ECSqlQueryDef } from \"@itwin/presentation-shared\";\nimport { NonGroupingHierarchyNode } from \"../HierarchyNode.js\";\nimport {\n ProcessedGenericHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n SourceGenericHierarchyNode,\n SourceInstanceHierarchyNode,\n} from \"./IModelHierarchyNode.js\";\n\n/**\n * A nodes definition that returns a single generic node.\n * @public\n */\nexport interface GenericHierarchyNodeDefinition {\n /** The node to be created in the hierarchy level */\n node: SourceGenericHierarchyNode;\n}\n\n/**\n * A nodes definition that returns an ECSQL query for selecting nodes from an iModel.\n * @public\n */\nexport interface InstanceNodesQueryDefinition {\n /**\n * Full name of the class whose instances are going to be returned. It's okay if the attribute\n * points to a base class of multiple different classes of instances returned by the query, however\n * the more specific this class is, the more efficient hierarchy building process is.\n */\n fullClassName: string;\n /**\n * An ECSQL query that selects nodes from an iModel. `SELECT` clause of the query is expected\n * to be built using `NodeSelectQueryFactory.createSelectClause`.\n */\n query: ECSqlQueryDef;\n}\n\n/**\n * A definition of nodes included in a hierarchy level.\n * @public\n */\nexport type HierarchyNodesDefinition = GenericHierarchyNodeDefinition | InstanceNodesQueryDefinition;\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodesDefinition {\n export function isGenericNode(def: HierarchyNodesDefinition): def is GenericHierarchyNodeDefinition {\n return !!(def as GenericHierarchyNodeDefinition).node;\n }\n export function isInstanceNodesQuery(def: HierarchyNodesDefinition): def is InstanceNodesQueryDefinition {\n return !!(def as InstanceNodesQueryDefinition).query;\n }\n}\n\n/**\n * A definition of a hierarchy level, which may consist of multiple node definitions.\n * @public\n */\nexport type HierarchyLevelDefinition = HierarchyNodesDefinition[];\n\n/**\n * A type for a function that parses a `SourceInstanceHierarchyNode` from provided ECSQL `row` object.\n * @public\n */\nexport type NodeParser = (props: {\n /** The ECSQL row object to parse. Keys & value types depend on the executed query. */\n row: { [columnName: string]: any };\n\n /** The parent node whose child node is being parsed. */\n parentNode?: HierarchyDefinitionParentNode;\n\n /** The key of iModel which is used to run the query. */\n imodelKey: string;\n}) => SourceInstanceHierarchyNode | Promise<SourceInstanceHierarchyNode>;\n\n/**\n * A type for a function that pre-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one. Returning `undefined` omits the node\n * from the hierarchy.\n *\n * @public\n */\nexport type NodePreProcessor = <TNode extends ProcessedGenericHierarchyNode | ProcessedInstanceHierarchyNode>(node: TNode) => Promise<TNode | undefined>;\n\n/**\n * A type for a function that post-processes given node. Unless the function decides not to make any modifications,\n * it should return a new - modified - node, rather than modifying the given one.\n *\n * @public\n */\nexport type NodePostProcessor = (node: ProcessedHierarchyNode) => Promise<ProcessedHierarchyNode>;\n\n/**\n * A type of node that can be passed to `HierarchyDefinition.defineHierarchyLevel`. This basically means\n * a `HierarchyNode` that:\n * - knows nothing about its children,\n * - is either an instances node (key is of `InstancesNodeKey` type) or a generic node (key is of `GenericNodeKey` type).\n * @public\n */\nexport type HierarchyDefinitionParentNode = Omit<NonGroupingHierarchyNode, \"children\">;\n\n/**\n * Props for `HierarchyDefinition.defineHierarchyLevel`.\n * @public\n */\nexport interface DefineHierarchyLevelProps {\n /** The key of iModel for which the hierarchy definition is being requested for. */\n imodelKey: string;\n\n /** Parent node to get children for. Pass `undefined` to get root nodes. */\n parentNode: HierarchyDefinitionParentNode | undefined;\n\n /** Optional hierarchy level filter. */\n instanceFilter?: GenericInstanceFilter;\n}\n\n/**\n * An interface for a factory that knows how define a hierarchy based on a given parent node.\n * @public\n */\nexport interface HierarchyDefinition {\n /**\n * An optional function for parsing ECInstance node from ECSQL row.\n *\n * Should be used in situations when the `HierarchyDefinition` implementation\n * introduces additional ECSQL columns into the select clause and wants to assign additional\n * data to the nodes it produces.\n *\n * Defaults to a function that parses all `HierarchyNode` attributes from a query, whose SELECT\n * clause is created using `NodeSelectQueryFactory.createSelectClause`.\n */\n parseNode?: NodeParser;\n\n /**\n * An optional function for pre-processing nodes.\n *\n * Pre-processing happens immediately after the nodes are loaded based on `HierarchyLevelDefinition`\n * returned by this `HierarchyDefinition` and before their processing (hiding, grouping, sorting, etc.) starts.\n * The step allows assigning nodes additional data or excluding them from the hierarchy based on some attributes.\n */\n preProcessNode?: NodePreProcessor;\n\n /**\n * An optional function for post-processing nodes.\n *\n * Post-processing happens after the loaded nodes go through all the merging, hiding and grouping\n * steps, but before sorting them. This step allows `HierarchyDefinition` implementations to assign additional data\n * to nodes after they're processed. This is especially true for grouping nodes as they're only created during\n * processing.\n */\n postProcessNode?: NodePostProcessor;\n\n /** A function to create a hierarchy level definition for given parent node. */\n defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import "../internal/DisposePolyfill.js";
2
2
  import { ECClassHierarchyInspector, ECSchemaProvider, Event, IPrimitiveValueFormatter } from "@itwin/presentation-shared";
3
- import { HierarchyFilteringPath } from "../HierarchyFiltering.js";
4
3
  import { HierarchyProvider } from "../HierarchyProvider.js";
4
+ import { HierarchySearchPath } from "../HierarchySearch.js";
5
5
  import { HierarchyDefinition } from "./IModelHierarchyDefinition.js";
6
6
  import { LimitingECSqlQueryExecutor } from "./LimitingECSqlQueryExecutor.js";
7
7
  /**
@@ -62,10 +62,10 @@ interface IModelHierarchyProviderProps {
62
62
  * by calling `setFormatter` on the provider instance.
63
63
  */
64
64
  formatter?: IPrimitiveValueFormatter;
65
- /** Props for filtering the hierarchy. */
66
- filtering?: {
65
+ /** Props for search the hierarchy. */
66
+ search?: {
67
67
  /** A list of node identifiers from root to target node. */
68
- paths: HierarchyFilteringPath[];
68
+ paths: HierarchySearchPath[];
69
69
  };
70
70
  }
71
71
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"IModelHierarchyProvider.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAKA,OAAO,gCAAgC,CAAC;AA4BxC,OAAO,EAGL,yBAAyB,EACzB,gBAAgB,EAGhB,KAAK,EAIL,wBAAwB,EAEzB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAA0B,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAkBpF,OAAO,EAGL,mBAAmB,EAGpB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAe7E;;;GAGG;AACH,UAAU,uCAAuC;IAC/C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,KAAK,YAAY,GAAG,gBAAgB,GAAG,0BAA0B,GAAG,yBAAyB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtH;;;GAGG;AACH,UAAU,4BAA4B;IACpC;;;;;;OAMG;IACH,YAAY,EAAE,YAAY,CAAC;IAE3B;;;OAGG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IAElC;;;OAGG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;IAEzC,qGAAqG;IACrG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,OAAO,CAAC,uCAAuC,CAAC,CAAC;IAEpE;;;;OAIG;IACH,SAAS,CAAC,EAAE,wBAAwB,CAAC;IAErC,yCAAyC;IACzC,SAAS,CAAC,EAAE;QACV,2DAA2D;QAC3D,KAAK,EAAE,sBAAsB,EAAE,CAAC;KACjC,CAAC;CACH;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,4BAA4B,GAAG,iBAAiB,GAAG,UAAU,CAGjH;AAED;;;GAGG;AACH,UAAU,kCAAmC,SAAQ,IAAI,CAAC,4BAA4B,EAAE,cAAc,GAAG,eAAe,CAAC;IACvH;;;;;OAKG;IACH,OAAO,EAAE,KAAK,CAAC;QACb;;;;;;WAMG;QACH,YAAY,EAAE,YAAY,CAAC;QAE3B;;;WAGG;QACH,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;KACnC,CAAC,CAAC;CACJ;AAED;;;;;;;GAOG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,kCAAkC,GAAG,iBAAiB,GAAG,UAAU,CAE7H"}
1
+ {"version":3,"file":"IModelHierarchyProvider.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAKA,OAAO,gCAAgC,CAAC;A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