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

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 (65) hide show
  1. package/CHANGELOG.md +26 -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/IModelHierarchyProvider.d.ts +4 -4
  19. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  20. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +20 -20
  21. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  22. package/lib/cjs/hierarchies/imodel/{FilteringHierarchyDefinition.d.ts → SearchHierarchyDefinition.d.ts} +10 -10
  23. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
  24. package/lib/cjs/hierarchies/imodel/{FilteringHierarchyDefinition.js → SearchHierarchyDefinition.js} +53 -53
  25. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
  26. package/lib/cjs/presentation-hierarchies.d.ts +1 -1
  27. package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
  28. package/lib/cjs/presentation-hierarchies.js +4 -5
  29. package/lib/cjs/presentation-hierarchies.js.map +1 -1
  30. package/lib/esm/hierarchies/HierarchyMerge.js +1 -1
  31. package/lib/esm/hierarchies/HierarchyMerge.js.map +1 -1
  32. package/lib/esm/hierarchies/HierarchyNode.d.ts +14 -24
  33. package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
  34. package/lib/esm/hierarchies/HierarchyNode.js +0 -20
  35. package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
  36. package/lib/esm/hierarchies/HierarchyProvider.d.ts +11 -11
  37. package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
  38. package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
  39. package/lib/esm/hierarchies/{HierarchyFiltering.d.ts → HierarchySearch.d.ts} +42 -52
  40. package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -0
  41. package/lib/esm/hierarchies/{HierarchyFiltering.js → HierarchySearch.js} +67 -82
  42. package/lib/esm/hierarchies/HierarchySearch.js.map +1 -0
  43. package/lib/esm/hierarchies/imodel/HierarchyCache.js +3 -3
  44. package/lib/esm/hierarchies/imodel/HierarchyCache.js.map +1 -1
  45. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +4 -4
  46. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  47. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +20 -20
  48. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  49. package/lib/esm/hierarchies/imodel/{FilteringHierarchyDefinition.d.ts → SearchHierarchyDefinition.d.ts} +10 -10
  50. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
  51. package/lib/esm/hierarchies/imodel/{FilteringHierarchyDefinition.js → SearchHierarchyDefinition.js} +48 -48
  52. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
  53. package/lib/esm/presentation-hierarchies.d.ts +1 -1
  54. package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
  55. package/lib/esm/presentation-hierarchies.js +1 -1
  56. package/lib/esm/presentation-hierarchies.js.map +1 -1
  57. package/package.json +1 -1
  58. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +0 -1
  59. package/lib/cjs/hierarchies/HierarchyFiltering.js.map +0 -1
  60. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
  61. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
  62. package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +0 -1
  63. package/lib/esm/hierarchies/HierarchyFiltering.js.map +0 -1
  64. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
  65. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HierarchySearch.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,cAAc;AACd,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,cAAc;AACd,MAAM,WAAW,gCAAgC;IAC/C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,gBAAgB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/
5
5
  import { HierarchyNodeIdentifier } from "./HierarchyNodeIdentifier.js";
6
6
  import { HierarchyNodeKey } from "./HierarchyNodeKey.js";
7
- var HierarchyFilteringPathOptions;
8
- (function (HierarchyFilteringPathOptions) {
7
+ var HierarchySearchPathOptions;
8
+ (function (HierarchySearchPathOptions) {
9
9
  function mergeRevealOptions(lhs, rhs) {
10
10
  if (rhs === true || lhs === true) {
11
11
  return true;
@@ -28,18 +28,18 @@ var HierarchyFilteringPathOptions;
28
28
  }
29
29
  return lhsDepth > rhsDepth ? lhs : rhs;
30
30
  }
31
- HierarchyFilteringPathOptions.mergeRevealOptions = mergeRevealOptions;
31
+ HierarchySearchPathOptions.mergeRevealOptions = mergeRevealOptions;
32
32
  function mergeAutoExpandOption(lhs, rhs) {
33
33
  return lhs || rhs ? true : undefined;
34
34
  }
35
- HierarchyFilteringPathOptions.mergeAutoExpandOption = mergeAutoExpandOption;
36
- })(HierarchyFilteringPathOptions || (HierarchyFilteringPathOptions = {}));
35
+ HierarchySearchPathOptions.mergeAutoExpandOption = mergeAutoExpandOption;
36
+ })(HierarchySearchPathOptions || (HierarchySearchPathOptions = {}));
37
37
  /** @public */
38
38
  // eslint-disable-next-line @typescript-eslint/no-redeclare
39
- export var HierarchyFilteringPath;
40
- (function (HierarchyFilteringPath) {
39
+ export var HierarchySearchPath;
40
+ (function (HierarchySearchPath) {
41
41
  /**
42
- * Normalizes the hierarchy filtering path to the object form.
42
+ * Normalizes the hierarchy search path to the object form.
43
43
  * @public
44
44
  */
45
45
  function normalize(source) {
@@ -48,9 +48,9 @@ export var HierarchyFilteringPath;
48
48
  }
49
49
  return source;
50
50
  }
51
- HierarchyFilteringPath.normalize = normalize;
51
+ HierarchySearchPath.normalize = normalize;
52
52
  /**
53
- * Merges two given `HierarchyFilteringPathOptions` objects.
53
+ * Merges two given `HierarchySearchPathOptions` objects.
54
54
  *
55
55
  * For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:
56
56
  * - if any one of the inputs is `true`, return `true`,
@@ -63,8 +63,8 @@ export var HierarchyFilteringPath;
63
63
  * @public
64
64
  */
65
65
  function mergeOptions(lhs, rhs) {
66
- const reveal = HierarchyFilteringPathOptions.mergeRevealOptions(lhs?.reveal, rhs?.reveal);
67
- const autoExpand = HierarchyFilteringPathOptions.mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);
66
+ const reveal = HierarchySearchPathOptions.mergeRevealOptions(lhs?.reveal, rhs?.reveal);
67
+ const autoExpand = HierarchySearchPathOptions.mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);
68
68
  return reveal || autoExpand
69
69
  ? {
70
70
  ...(reveal !== undefined ? { reveal } : undefined),
@@ -72,55 +72,40 @@ export var HierarchyFilteringPath;
72
72
  }
73
73
  : undefined;
74
74
  }
75
- HierarchyFilteringPath.mergeOptions = mergeOptions;
76
- })(HierarchyFilteringPath || (HierarchyFilteringPath = {}));
77
- /**
78
- * An utility that extracts filtering properties from given root level filtering props or
79
- * the parent node. Returns `undefined` if filtering props are not present.
80
- * @public
81
- * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.
82
- */
75
+ HierarchySearchPath.mergeOptions = mergeOptions;
76
+ })(HierarchySearchPath || (HierarchySearchPath = {}));
77
+ // TODO: remove c8 ignore start and add tests to cover the gaps
83
78
  /* c8 ignore start */
84
- export function extractFilteringProps(rootLevelFilteringProps, parentNode) {
85
- const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
86
- return filteringProps?.filteredNodePaths !== undefined
87
- ? {
88
- filteredNodePaths: filteringProps.filteredNodePaths,
89
- hasFilterTargetAncestor: filteringProps.hasFilterTargetAncestor,
90
- }
91
- : undefined;
92
- }
93
- /* c8 ignore end */
94
- function extractFilteringPropsInternal(rootLevelFilteringProps, parentNode) {
79
+ function extractSearchPropsInternal(rootLevelSearchProps, parentNode) {
95
80
  if (!parentNode) {
96
- return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;
81
+ return rootLevelSearchProps ? { childrenTargetPaths: rootLevelSearchProps, hasSearchTargetAncestor: false } : undefined;
97
82
  }
98
- const filteringProps = {
99
- ...(parentNode.filtering?.filteredChildrenIdentifierPaths ? { filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths } : undefined),
100
- hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor || !!parentNode.filtering?.isFilterTarget,
83
+ const searchProps = {
84
+ ...(parentNode.search?.childrenTargetPaths ? { childrenTargetPaths: parentNode.search.childrenTargetPaths } : undefined),
85
+ hasSearchTargetAncestor: !!parentNode.search?.hasSearchTargetAncestor || !!parentNode.search?.isSearchTarget,
101
86
  };
102
- return filteringProps.filteredNodePaths || filteringProps.hasFilterTargetAncestor ? filteringProps : undefined;
87
+ return searchProps.childrenTargetPaths || searchProps.hasSearchTargetAncestor ? searchProps : undefined;
103
88
  }
104
89
  /**
105
- * Creates a set of utilities for making it easier to filter the given hierarchy
90
+ * Creates a set of utilities for making it easier to search the given hierarchy
106
91
  * level.
107
92
  *
108
93
  * @public
109
94
  */
110
- export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
111
- const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
112
- const hasFilter = !!filteringProps;
113
- function saveFilteringPropsFromPathsIntoReducer(extractionProps) {
95
+ export function createHierarchySearchHelper(rootLevelSearchProps, parentNode) {
96
+ const searchProps = extractSearchPropsInternal(rootLevelSearchProps, parentNode);
97
+ const hasSearch = !!searchProps;
98
+ function saveSearchPropsFromPathsIntoReducer(extractionProps) {
114
99
  // Passes down matching normalized paths to the reducer.
115
- // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` at the first position in filtering path matches the node
100
+ // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` at the first position in search path matches the node
116
101
  // and if it does, the path is passed down to the reducer.
117
102
  // This function returns a promise only if asyncPathMatcher returns a promise.
118
- if (!filteringProps?.filteredNodePaths) {
103
+ if (!searchProps?.childrenTargetPaths) {
119
104
  return;
120
105
  }
121
106
  const matchedPathPromises = new Array();
122
- for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
123
- const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
107
+ for (const childrenTargetPaths of searchProps.childrenTargetPaths) {
108
+ const normalizedPath = HierarchySearchPath.normalize(childrenTargetPaths);
124
109
  /* c8 ignore next 3 */
125
110
  if (normalizedPath.path.length === 0) {
126
111
  continue;
@@ -148,47 +133,47 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
148
133
  return Promise.all(matchedPathPromises).then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && extractionProps.pathsReducer.accept(normalizedPath)));
149
134
  }
150
135
  function createChildNodeProps(props) {
151
- if (!hasFilter) {
136
+ if (!hasSearch) {
152
137
  return undefined;
153
138
  }
154
- const reducer = new MatchingFilteringPathsReducer(filteringProps.hasFilterTargetAncestor);
139
+ const reducer = new MatchingSearchPathsReducer(searchProps.hasSearchTargetAncestor);
155
140
  if ("asyncPathMatcher" in props) {
156
- const extractResult = saveFilteringPropsFromPathsIntoReducer({ pathsReducer: reducer, asyncPathMatcher: props.asyncPathMatcher });
141
+ const extractResult = saveSearchPropsFromPathsIntoReducer({ pathsReducer: reducer, asyncPathMatcher: props.asyncPathMatcher });
157
142
  if (extractResult instanceof Promise) {
158
143
  return extractResult.then(() => reducer.getNodeProps(props.parentKeys));
159
144
  }
160
145
  }
161
146
  else {
162
- saveFilteringPropsFromPathsIntoReducer({ ...props, pathsReducer: reducer });
147
+ saveSearchPropsFromPathsIntoReducer({ ...props, pathsReducer: reducer });
163
148
  }
164
149
  return reducer.getNodeProps(props.parentKeys);
165
150
  }
166
151
  return {
167
152
  /** Returns a flag indicating if the hierarchy level is filtered. */
168
- hasFilter,
153
+ hasSearch,
169
154
  /**
170
155
  * Returns a flag indicating whether this hierarchy level has an ancestor node
171
- * that is a filter target. That generally means that this and all downstream hierarchy
172
- * levels should be displayed without filter being applied to them, even if filter paths
156
+ * that is a search target. That generally means that this and all downstream hierarchy
157
+ * levels should be displayed without search being applied to them, even if search paths
173
158
  * say otherwise.
174
159
  */
175
- hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,
160
+ hasSearchTargetAncestor: searchProps?.hasSearchTargetAncestor ?? false,
176
161
  /**
177
162
  * Returns a list of hierarchy node identifiers that apply specifically for this
178
- * hierarchy level. Returns `undefined` if filtering is not applied to this level.
163
+ * hierarchy level. Returns `undefined` if search is not applied to this level.
179
164
  */
180
- getChildNodeFilteringIdentifiers: () => {
181
- if (!filteringProps?.filteredNodePaths) {
165
+ getChildNodeSearchIdentifiers: () => {
166
+ if (!searchProps?.childrenTargetPaths) {
182
167
  return undefined;
183
168
  }
184
- return filteringProps.filteredNodePaths
185
- .map(HierarchyFilteringPath.normalize)
169
+ return searchProps.childrenTargetPaths
170
+ .map(HierarchySearchPath.normalize)
186
171
  .filter(({ path }) => path.length > 0)
187
172
  .map(({ path }) => path[0]);
188
173
  },
189
174
  /**
190
- * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`
191
- * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
175
+ * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `search`
176
+ * and `autoExpand`) to be set based on the search paths and search options. This function calculates
192
177
  * these props for a child node based on its key or path matcher.
193
178
  *
194
179
  * When using `pathMatcher` or `asyncPathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
@@ -196,7 +181,7 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
196
181
  * `nodeKey` prop can be used to check the whole identifier.
197
182
  *
198
183
  * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:
199
- * - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `filtering` and `autoExpand` prop from `HierarchyNode`;
184
+ * - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;
200
185
  * - `parentKeys` is undefined - does not return `HierarchyNode.autoExpand` option;
201
186
  * - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.
202
187
  */
@@ -204,42 +189,42 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
204
189
  };
205
190
  }
206
191
  /**
207
- * Extracts information from filtering paths and later returns `filtering` and `autoExpand` values from `HierarchyNode`.
192
+ * Extracts information from search paths and later returns `search` and `autoExpand` values from `HierarchyNode`.
208
193
  *
209
194
  * 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`.
210
195
  *
211
196
  * Extracts information using `accept` function:
212
- * - Determines if node is filter target, and if it is saves the options as `filterTargetOptions`
213
- * - Saves `HierarchyFilteringPathOptions` and `filteredChildrenIdentifierPaths`
197
+ * - Determines if node is search target, and if it is saves the options as `searchTargetOptions`
198
+ * - Saves `HierarchySearchPathOptions` and `childrenTargetPaths`
214
199
  */
215
- class MatchingFilteringPathsReducer {
216
- _hasFilterTargetAncestor;
217
- _filteredChildrenIdentifierPaths = new Array();
218
- _isFilterTarget = false;
219
- _filterTargetOptions = undefined;
200
+ class MatchingSearchPathsReducer {
201
+ _hasSearchTargetAncestor;
202
+ _childrenTargetPaths = new Array();
203
+ _isSearchTarget = false;
204
+ _searchTargetOptions = undefined;
220
205
  _revealOption = false;
221
- constructor(_hasFilterTargetAncestor) {
222
- this._hasFilterTargetAncestor = _hasFilterTargetAncestor;
206
+ constructor(_hasSearchTargetAncestor) {
207
+ this._hasSearchTargetAncestor = _hasSearchTargetAncestor;
223
208
  }
224
209
  accept(normalizedPath) {
225
210
  const { path, options } = normalizedPath;
226
211
  if (path.length === 1) {
227
- this._isFilterTarget = true;
228
- this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);
212
+ this._isSearchTarget = true;
213
+ this._searchTargetOptions = HierarchySearchPath.mergeOptions(this._searchTargetOptions, options);
229
214
  }
230
215
  else if (path.length > 1) {
231
- this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });
232
- this._revealOption = HierarchyFilteringPathOptions.mergeRevealOptions(options?.reveal, this._revealOption);
216
+ this._childrenTargetPaths.push({ path: path.slice(1), options });
217
+ this._revealOption = HierarchySearchPathOptions.mergeRevealOptions(options?.reveal, this._revealOption);
233
218
  }
234
219
  }
235
220
  getNodeProps(parentKeys) {
236
221
  return {
237
- ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0
222
+ ...(this._hasSearchTargetAncestor || this._isSearchTarget || this._childrenTargetPaths.length > 0
238
223
  ? {
239
- filtering: {
240
- ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),
241
- ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),
242
- ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),
224
+ search: {
225
+ ...(this._hasSearchTargetAncestor ? { hasSearchTargetAncestor: true } : undefined),
226
+ ...(this._isSearchTarget ? { isSearchTarget: true, searchTargetOptions: this._searchTargetOptions } : undefined),
227
+ ...(this._childrenTargetPaths.length > 0 ? { childrenTargetPaths: this._childrenTargetPaths } : undefined),
243
228
  },
244
229
  }
245
230
  : undefined),
@@ -249,7 +234,7 @@ class MatchingFilteringPathsReducer {
249
234
  nodePositionInHierarchy: parentKeys.length,
250
235
  nodePositionInPath: parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length,
251
236
  }) ||
252
- !!this._filterTargetOptions?.autoExpand)
237
+ !!this._searchTargetOptions?.autoExpand)
253
238
  ? { autoExpand: true }
254
239
  : undefined),
255
240
  };
@@ -268,4 +253,4 @@ export function shouldAutoExpandBasedOnReveal({ reveal, nodePositionInPath, node
268
253
  }
269
254
  return nodePositionInPath < reveal.depthInPath;
270
255
  }
271
- //# sourceMappingURL=HierarchyFiltering.js.map
256
+ //# sourceMappingURL=HierarchySearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HierarchySearch.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,uBAAuB,EAAgC,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAkB,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;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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CAAC,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC;gBACxC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE;gBACtB,CAAC,CAAC,SAAS,CAAC;SACf,CAAC;IACJ,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,UAAU,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"]}
@@ -14,11 +14,11 @@ export class HierarchyCache {
14
14
  }
15
15
  createCacheKeys(props) {
16
16
  function createVariationKey() {
17
- const { instanceFilter, hierarchyLevelSizeLimit, filteredInstanceKeys } = props;
18
- if (instanceFilter === undefined && hierarchyLevelSizeLimit === undefined && filteredInstanceKeys === undefined) {
17
+ const { instanceFilter, hierarchyLevelSizeLimit, targetInstanceKeys } = props;
18
+ if (instanceFilter === undefined && hierarchyLevelSizeLimit === undefined && targetInstanceKeys === undefined) {
19
19
  return undefined;
20
20
  }
21
- return JSON.stringify({ instanceFilter, hierarchyLevelSizeLimit, filteredInstanceKeys });
21
+ return JSON.stringify({ instanceFilter, hierarchyLevelSizeLimit, targetInstanceKeys });
22
22
  }
23
23
  if (!props.parentNode) {
24
24
  return { primaryKey: [], variationKey: createVariationKey() };
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyCache.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/HierarchyCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAY,aAAa,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AA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K,EAAE,CAAC;IACpB,CAAC;CACF;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,gBAAgB,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/HierarchyCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAY,aAAa,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAe1D,gBAAgB;AAChB,MAAM,OAAO,cAAc;IACjB,IAAI,CAA4D;IAChE,MAAM,CAAiC;IAE/C,YAAmB,KAAqC;QACtD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,aAAa,CAA6C,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;IAClH,CAAC;IAEO,eAAe,CACrB,KAGC;QAED,SAAS,kBAAkB;YACzB,MAAM,EAAE,cAAc,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;YAC9E,IAAI,cAAc,KAAK,SAAS,IAAI,uBAAuB,KAAK,SAAS,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;gBAC9G,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,CAAC,CAAC;QACzF,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,kBAAkB,EAAE,EAAE,CAAC;QAChE,CAAC;QAED,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC;QAE/C,OAAO;YACL,UAAU,EAAE,CAAC,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e,CAAC,YAAY,CAAC,CAAC;QACxE,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;IAEM,GAAG,CAAC,YAAoC;QAC7C,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC;IAChE,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACF;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,gBAAgB,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"]}
@@ -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":"","s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AC,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;AA4BxC,OAAO,EAGL,yBAAyB,EACzB,gBAAgB,EAGhB,KAAK,EAIL,wBAAwB,EAEzB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAA0B,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAiB5D,OAAO,EAGL,mBAAmB,EAGpB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAgB7E;;;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,sCAAsC;IACtC,MAAM,CAAC,EAAE;QACP,2DAA2D;QAC3D,KAAK,EAAE,mBAAmB,EAAE,CAAC;KAC9B,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"}
@@ -18,7 +18,6 @@ import { shareReplayWithErrors } from "../internal/operators/ShareReplayWithErro
18
18
  import { sortNodesByLabelOperator } from "../internal/operators/Sorting.js";
19
19
  import { getRxjsHierarchyDefinition } from "../internal/RxjsHierarchyDefinition.js";
20
20
  import { SubscriptionScheduler } from "../internal/SubscriptionScheduler.js";
21
- import { FilteringHierarchyDefinition } from "./FilteringHierarchyDefinition.js";
22
21
  import { HierarchyCache } from "./HierarchyCache.js";
23
22
  import { HierarchyNodesDefinition, } from "./IModelHierarchyDefinition.js";
24
23
  import { NodeSelectClauseColumnNames } from "./NodeSelectQueryFactory.js";
@@ -26,6 +25,7 @@ import { createDetermineChildrenOperator } from "./operators/DetermineChildren.j
26
25
  import { createGroupingOperator } from "./operators/Grouping.js";
27
26
  import { createHideIfNoChildrenOperator } from "./operators/HideIfNoChildren.js";
28
27
  import { createHideNodesInHierarchyOperator } from "./operators/HideNodesInHierarchy.js";
28
+ import { SearchHierarchyDefinition } from "./SearchHierarchyDefinition.js";
29
29
  import { readNodes } from "./TreeNodesReader.js";
30
30
  const LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.IModelHierarchyProvider`;
31
31
  const LOGGING_NAMESPACE_INTERNAL = `${BASE_LOGGING_NAMESPACE_INTERNAL}.IModelHierarchyProvider`;
@@ -83,7 +83,7 @@ class IModelHierarchyProviderImpl {
83
83
  this._localizedStrings = { other: "Other", unspecified: "Not specified", ...props?.localizedStrings };
84
84
  this._queryConcurrency = props.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY;
85
85
  this._querySchedulers = new Map();
86
- this.setHierarchyFilter(props.filtering);
86
+ this.setHierarchySearch(props.search);
87
87
  const queryCacheSize = props.queryCacheSize ?? DEFAULT_QUERY_CACHE_SIZE;
88
88
  if (queryCacheSize !== 0) {
89
89
  this._nodesCache = new HierarchyCache({
@@ -142,24 +142,24 @@ class IModelHierarchyProviderImpl {
142
142
  this._valuesFormatter = formatter ?? createDefaultValueFormatter();
143
143
  this._hierarchyChanged.raiseEvent({ formatterChange: { newFormatter: this._valuesFormatter } });
144
144
  }
145
- setHierarchyFilter(props) {
145
+ setHierarchySearch(props) {
146
146
  if (!props) {
147
147
  if (this._sourceHierarchyDefinition !== this._activeHierarchyDefinition) {
148
148
  this._activeHierarchyDefinition = this._sourceHierarchyDefinition;
149
- this.invalidateHierarchyCache("Hierarchy filter reset");
149
+ this.invalidateHierarchyCache("Hierarchy search reset");
150
150
  }
151
- this._hierarchyChanged.raiseEvent({ filterChange: { newFilter: undefined } });
151
+ this._hierarchyChanged.raiseEvent({ searchChange: { newSearch: undefined } });
152
152
  return;
153
153
  }
154
- this._activeHierarchyDefinition = new FilteringHierarchyDefinition({
154
+ this._activeHierarchyDefinition = new SearchHierarchyDefinition({
155
155
  imodelAccess: this.getPrimaryIModelAccess(),
156
156
  source: this._sourceHierarchyDefinition,
157
157
  sourceName: this.#sourceName,
158
- nodeIdentifierPaths: props.paths,
158
+ targetPaths: props.paths,
159
159
  });
160
- this.invalidateHierarchyCache("Hierarchy filter set");
160
+ this.invalidateHierarchyCache("Hierarchy search set");
161
161
  this._dispose.next();
162
- this._hierarchyChanged.raiseEvent({ filterChange: { newFilter: props } });
162
+ this._hierarchyChanged.raiseEvent({ searchChange: { newSearch: props } });
163
163
  }
164
164
  onGroupingNodeCreated(groupingNode, props) {
165
165
  this._nodesCache?.set({ ...props, parentNode: groupingNode }, { observable: from(groupingNode.children), processingStatus: "pre-processed" });
@@ -205,7 +205,7 @@ class IModelHierarchyProviderImpl {
205
205
  key: { type: "generic", id: def.node.key, source: this.#sourceName },
206
206
  });
207
207
  }
208
- return this.getQueryScheduler(imodelAccess.imodelKey).scheduleSubscription(of(def.query).pipe(map((query) => filterQueryByInstanceKeys(query, props.filteredInstanceKeys)), mergeMap((query) => readNodes({
208
+ return this.getQueryScheduler(imodelAccess.imodelKey).scheduleSubscription(of(def.query).pipe(map((query) => createInstanceKeysFilteredQuery(query, props.targetInstanceKeys)), mergeMap((query) => readNodes({
209
209
  queryExecutor: imodelAccess,
210
210
  query,
211
211
  limit: props.hierarchyLevelSizeLimit,
@@ -283,13 +283,13 @@ class IModelHierarchyProviderImpl {
283
283
  return cached;
284
284
  }
285
285
  // if we don't find an entry for a grouping node, we load its instances by getting a query and applying
286
- // a filter based on grouped instance keys
287
- let filteredInstanceKeys;
286
+ // a search based on grouped instance keys
287
+ let targetInstanceKeys;
288
288
  let parentNonGroupingNode;
289
289
  if (parentNode) {
290
290
  if (HierarchyNode.isGroupingNode(parentNode)) {
291
291
  parentNonGroupingNode = parentNode.nonGroupingAncestor;
292
- filteredInstanceKeys = parentNode.groupedInstanceKeys;
292
+ targetInstanceKeys = parentNode.groupedInstanceKeys;
293
293
  }
294
294
  else {
295
295
  // not sure why type checker doesn't pick this up
@@ -300,7 +300,7 @@ class IModelHierarchyProviderImpl {
300
300
  const nonGroupingNodeChildrenRequestProps = {
301
301
  ...restProps,
302
302
  parentNode: parentNonGroupingNode,
303
- ...(filteredInstanceKeys ? { filteredInstanceKeys } : undefined),
303
+ ...(targetInstanceKeys ? { targetInstanceKeys } : undefined),
304
304
  };
305
305
  const value = { observable: this.createSourceNodesObservable(nonGroupingNodeChildrenRequestProps), processingStatus: "none" };
306
306
  this._nodesCache?.set(nonGroupingNodeChildrenRequestProps, value);
@@ -468,20 +468,20 @@ function createParentNodeKeysList(parentNode) {
468
468
  }
469
469
  return [...parentNode.parentKeys, parentNode.key];
470
470
  }
471
- function filterQueryByInstanceKeys(query, filteredInstanceKeys) {
472
- if (!filteredInstanceKeys || !filteredInstanceKeys.length) {
471
+ function createInstanceKeysFilteredQuery(query, targetInstanceKeys) {
472
+ if (!targetInstanceKeys || !targetInstanceKeys.length) {
473
473
  return query;
474
474
  }
475
475
  const MAX_ALLOWED_BINDINGS = 1000;
476
- if (filteredInstanceKeys.length < MAX_ALLOWED_BINDINGS) {
476
+ if (targetInstanceKeys.length < MAX_ALLOWED_BINDINGS) {
477
477
  return {
478
478
  ...query,
479
479
  ecsql: `
480
480
  SELECT *
481
481
  FROM (${query.ecsql}) q
482
- WHERE q.ECInstanceId IN (${filteredInstanceKeys.map(() => "?").join(",")})
482
+ WHERE q.ECInstanceId IN (${targetInstanceKeys.map(() => "?").join(",")})
483
483
  `,
484
- bindings: [...(query.bindings ?? []), ...filteredInstanceKeys.map((k) => ({ type: "id", value: k.id }))],
484
+ bindings: [...(query.bindings ?? []), ...targetInstanceKeys.map((k) => ({ type: "id", value: k.id }))],
485
485
  };
486
486
  }
487
487
  /* c8 ignore start */
@@ -492,7 +492,7 @@ function filterQueryByInstanceKeys(query, filteredInstanceKeys) {
492
492
  FROM (${query.ecsql}) q
493
493
  WHERE InVirtualSet(?, q.ECInstanceId)
494
494
  `,
495
- bindings: [...(query.bindings ?? []), { type: "idset", value: filteredInstanceKeys.map((k) => k.id) }],
495
+ bindings: [...(query.bindings ?? []), { type: "idset", value: targetInstanceKeys.map((k) => k.id) }],
496
496
  };
497
497
  /* c8 ignore end */
498
498
  }