@itwin/presentation-hierarchies 0.6.0 → 0.7.1

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 (305) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +44 -47
  3. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +64 -0
  4. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +1 -0
  5. package/lib/cjs/hierarchies/HierarchyFiltering.js +80 -0
  6. package/lib/cjs/hierarchies/HierarchyFiltering.js.map +1 -0
  7. package/lib/cjs/hierarchies/HierarchyNode.d.ts +29 -233
  8. package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
  9. package/lib/cjs/hierarchies/HierarchyNode.js +25 -8
  10. package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
  11. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts +7 -11
  12. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
  13. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js +9 -8
  14. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
  15. package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts +31 -6
  16. package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  17. package/lib/cjs/hierarchies/HierarchyNodeKey.js +26 -23
  18. package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
  19. package/lib/cjs/hierarchies/HierarchyProvider.d.ts +24 -89
  20. package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
  21. package/lib/cjs/hierarchies/HierarchyProvider.js +24 -381
  22. package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
  23. package/lib/{esm/hierarchies/internal → cjs/hierarchies/imodel}/FilteringHierarchyDefinition.d.ts +9 -9
  24. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -0
  25. package/lib/cjs/hierarchies/{internal → imodel}/FilteringHierarchyDefinition.js +35 -73
  26. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -0
  27. package/lib/cjs/hierarchies/imodel/HierarchyCache.d.ts +18 -0
  28. package/lib/cjs/hierarchies/imodel/HierarchyCache.d.ts.map +1 -0
  29. package/lib/cjs/hierarchies/{internal/ChildNodeObservablesCache.js → imodel/HierarchyCache.js} +4 -4
  30. package/lib/cjs/hierarchies/imodel/HierarchyCache.js.map +1 -0
  31. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +121 -0
  32. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -0
  33. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js +21 -0
  34. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -0
  35. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts +234 -0
  36. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -0
  37. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.js +29 -0
  38. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.js.map +1 -0
  39. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +77 -0
  40. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -0
  41. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +439 -0
  42. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -0
  43. package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.d.ts.map +1 -0
  44. package/lib/cjs/hierarchies/{LimitingECSqlQueryExecutor.js → imodel/LimitingECSqlQueryExecutor.js} +3 -3
  45. package/lib/cjs/hierarchies/imodel/LimitingECSqlQueryExecutor.js.map +1 -0
  46. package/lib/{esm/hierarchies → cjs/hierarchies/imodel}/NodeSelectQueryFactory.d.ts +1 -1
  47. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -0
  48. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -0
  49. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +140 -0
  50. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -0
  51. package/lib/cjs/hierarchies/{HierarchyDefinition.js → imodel/PredicateBasedHierarchyDefinition.js} +26 -36
  52. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -0
  53. package/lib/{esm/hierarchies/internal → cjs/hierarchies/imodel}/TreeNodesReader.d.ts +6 -6
  54. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -0
  55. package/lib/cjs/hierarchies/{internal → imodel}/TreeNodesReader.js +2 -2
  56. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -0
  57. package/lib/cjs/hierarchies/imodel/Utils.d.ts +4 -0
  58. package/lib/cjs/hierarchies/imodel/Utils.d.ts.map +1 -0
  59. package/lib/cjs/hierarchies/imodel/Utils.js +59 -0
  60. package/lib/cjs/hierarchies/imodel/Utils.js.map +1 -0
  61. package/lib/cjs/hierarchies/{internal → imodel}/operators/DetermineChildren.d.ts +1 -1
  62. package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.d.ts.map +1 -0
  63. package/lib/cjs/hierarchies/{internal → imodel}/operators/DetermineChildren.js +3 -3
  64. package/lib/cjs/hierarchies/imodel/operators/DetermineChildren.js.map +1 -0
  65. package/lib/cjs/hierarchies/{internal → imodel}/operators/Grouping.d.ts +2 -1
  66. package/lib/cjs/hierarchies/imodel/operators/Grouping.d.ts.map +1 -0
  67. package/lib/cjs/hierarchies/{internal → imodel}/operators/Grouping.js +6 -6
  68. package/lib/cjs/hierarchies/imodel/operators/Grouping.js.map +1 -0
  69. package/lib/cjs/hierarchies/{internal → imodel}/operators/HideIfNoChildren.d.ts +1 -1
  70. package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -0
  71. package/lib/cjs/hierarchies/{internal → imodel}/operators/HideIfNoChildren.js +5 -5
  72. package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -0
  73. package/lib/{esm/hierarchies/internal → cjs/hierarchies/imodel}/operators/HideNodesInHierarchy.d.ts +1 -1
  74. package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts.map +1 -0
  75. package/lib/cjs/hierarchies/{internal → imodel}/operators/HideNodesInHierarchy.js +22 -9
  76. package/lib/cjs/hierarchies/imodel/operators/HideNodesInHierarchy.js.map +1 -0
  77. package/lib/cjs/hierarchies/imodel/operators/grouping/AutoExpand.d.ts.map +1 -0
  78. package/lib/cjs/hierarchies/imodel/operators/grouping/AutoExpand.js.map +1 -0
  79. package/lib/{esm/hierarchies/internal → cjs/hierarchies/imodel}/operators/grouping/BaseClassGrouping.d.ts +2 -1
  80. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -0
  81. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -0
  82. package/lib/{esm/hierarchies/internal → cjs/hierarchies/imodel}/operators/grouping/ClassGrouping.d.ts +2 -1
  83. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -0
  84. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -0
  85. package/lib/cjs/hierarchies/imodel/operators/grouping/GroupHiding.d.ts.map +1 -0
  86. package/lib/cjs/hierarchies/imodel/operators/grouping/GroupHiding.js.map +1 -0
  87. package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/LabelGrouping.d.ts +1 -1
  88. package/lib/cjs/hierarchies/imodel/operators/grouping/LabelGrouping.d.ts.map +1 -0
  89. package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/LabelGrouping.js +2 -2
  90. package/lib/cjs/hierarchies/imodel/operators/grouping/LabelGrouping.js.map +1 -0
  91. package/lib/{esm/hierarchies/internal → cjs/hierarchies/imodel}/operators/grouping/PropertiesGrouping.d.ts +2 -1
  92. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -0
  93. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -0
  94. package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/Shared.d.ts +1 -1
  95. package/lib/cjs/hierarchies/imodel/operators/grouping/Shared.d.ts.map +1 -0
  96. package/lib/cjs/hierarchies/imodel/operators/grouping/Shared.js.map +1 -0
  97. package/lib/cjs/hierarchies/internal/Common.d.ts +8 -5
  98. package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
  99. package/lib/cjs/hierarchies/internal/Common.js +1 -67
  100. package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
  101. package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts +3 -2
  102. package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
  103. package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
  104. package/lib/cjs/presentation-hierarchies.d.ts +10 -6
  105. package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
  106. package/lib/cjs/presentation-hierarchies.js +18 -10
  107. package/lib/cjs/presentation-hierarchies.js.map +1 -1
  108. package/lib/esm/hierarchies/HierarchyFiltering.d.ts +64 -0
  109. package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +1 -0
  110. package/lib/esm/hierarchies/HierarchyFiltering.js +76 -0
  111. package/lib/esm/hierarchies/HierarchyFiltering.js.map +1 -0
  112. package/lib/esm/hierarchies/HierarchyNode.d.ts +29 -233
  113. package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
  114. package/lib/esm/hierarchies/HierarchyNode.js +24 -7
  115. package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
  116. package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts +7 -11
  117. package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
  118. package/lib/esm/hierarchies/HierarchyNodeIdentifier.js +9 -8
  119. package/lib/esm/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
  120. package/lib/esm/hierarchies/HierarchyNodeKey.d.ts +31 -6
  121. package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  122. package/lib/esm/hierarchies/HierarchyNodeKey.js +26 -23
  123. package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
  124. package/lib/esm/hierarchies/HierarchyProvider.d.ts +24 -89
  125. package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
  126. package/lib/esm/hierarchies/HierarchyProvider.js +25 -382
  127. package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
  128. package/lib/{cjs/hierarchies/internal → esm/hierarchies/imodel}/FilteringHierarchyDefinition.d.ts +9 -9
  129. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -0
  130. package/lib/esm/hierarchies/{internal → imodel}/FilteringHierarchyDefinition.js +36 -74
  131. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -0
  132. package/lib/esm/hierarchies/imodel/HierarchyCache.d.ts +18 -0
  133. package/lib/esm/hierarchies/imodel/HierarchyCache.d.ts.map +1 -0
  134. package/lib/esm/hierarchies/{internal/ChildNodeObservablesCache.js → imodel/HierarchyCache.js} +2 -2
  135. package/lib/esm/hierarchies/imodel/HierarchyCache.js.map +1 -0
  136. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +121 -0
  137. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -0
  138. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js +18 -0
  139. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -0
  140. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts +234 -0
  141. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -0
  142. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.js +26 -0
  143. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.js.map +1 -0
  144. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +77 -0
  145. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -0
  146. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +436 -0
  147. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -0
  148. package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.d.ts.map +1 -0
  149. package/lib/esm/hierarchies/{LimitingECSqlQueryExecutor.js → imodel/LimitingECSqlQueryExecutor.js} +3 -3
  150. package/lib/esm/hierarchies/imodel/LimitingECSqlQueryExecutor.js.map +1 -0
  151. package/lib/{cjs/hierarchies → esm/hierarchies/imodel}/NodeSelectQueryFactory.d.ts +1 -1
  152. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -0
  153. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -0
  154. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +140 -0
  155. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -0
  156. package/lib/esm/hierarchies/{HierarchyDefinition.js → imodel/PredicateBasedHierarchyDefinition.js} +25 -34
  157. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -0
  158. package/lib/{cjs/hierarchies/internal → esm/hierarchies/imodel}/TreeNodesReader.d.ts +6 -6
  159. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -0
  160. package/lib/esm/hierarchies/{internal → imodel}/TreeNodesReader.js +2 -2
  161. package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -0
  162. package/lib/esm/hierarchies/imodel/Utils.d.ts +4 -0
  163. package/lib/esm/hierarchies/imodel/Utils.d.ts.map +1 -0
  164. package/lib/esm/hierarchies/imodel/Utils.js +56 -0
  165. package/lib/esm/hierarchies/imodel/Utils.js.map +1 -0
  166. package/lib/esm/hierarchies/{internal → imodel}/operators/DetermineChildren.d.ts +1 -1
  167. package/lib/esm/hierarchies/imodel/operators/DetermineChildren.d.ts.map +1 -0
  168. package/lib/esm/hierarchies/{internal → imodel}/operators/DetermineChildren.js +3 -3
  169. package/lib/esm/hierarchies/imodel/operators/DetermineChildren.js.map +1 -0
  170. package/lib/esm/hierarchies/{internal → imodel}/operators/Grouping.d.ts +2 -1
  171. package/lib/esm/hierarchies/imodel/operators/Grouping.d.ts.map +1 -0
  172. package/lib/esm/hierarchies/{internal → imodel}/operators/Grouping.js +7 -7
  173. package/lib/esm/hierarchies/imodel/operators/Grouping.js.map +1 -0
  174. package/lib/esm/hierarchies/{internal → imodel}/operators/HideIfNoChildren.d.ts +1 -1
  175. package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -0
  176. package/lib/esm/hierarchies/{internal → imodel}/operators/HideIfNoChildren.js +5 -5
  177. package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -0
  178. package/lib/{cjs/hierarchies/internal → esm/hierarchies/imodel}/operators/HideNodesInHierarchy.d.ts +1 -1
  179. package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.d.ts.map +1 -0
  180. package/lib/esm/hierarchies/{internal → imodel}/operators/HideNodesInHierarchy.js +22 -9
  181. package/lib/esm/hierarchies/imodel/operators/HideNodesInHierarchy.js.map +1 -0
  182. package/lib/esm/hierarchies/imodel/operators/grouping/AutoExpand.d.ts.map +1 -0
  183. package/lib/esm/hierarchies/imodel/operators/grouping/AutoExpand.js.map +1 -0
  184. package/lib/{cjs/hierarchies/internal → esm/hierarchies/imodel}/operators/grouping/BaseClassGrouping.d.ts +2 -1
  185. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -0
  186. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -0
  187. package/lib/{cjs/hierarchies/internal → esm/hierarchies/imodel}/operators/grouping/ClassGrouping.d.ts +2 -1
  188. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -0
  189. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -0
  190. package/lib/esm/hierarchies/imodel/operators/grouping/GroupHiding.d.ts.map +1 -0
  191. package/lib/esm/hierarchies/imodel/operators/grouping/GroupHiding.js.map +1 -0
  192. package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/LabelGrouping.d.ts +1 -1
  193. package/lib/esm/hierarchies/imodel/operators/grouping/LabelGrouping.d.ts.map +1 -0
  194. package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/LabelGrouping.js +2 -2
  195. package/lib/esm/hierarchies/imodel/operators/grouping/LabelGrouping.js.map +1 -0
  196. package/lib/{cjs/hierarchies/internal → esm/hierarchies/imodel}/operators/grouping/PropertiesGrouping.d.ts +2 -1
  197. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -0
  198. package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/PropertiesGrouping.js +1 -1
  199. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -0
  200. package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/Shared.d.ts +1 -1
  201. package/lib/esm/hierarchies/imodel/operators/grouping/Shared.d.ts.map +1 -0
  202. package/lib/esm/hierarchies/imodel/operators/grouping/Shared.js.map +1 -0
  203. package/lib/esm/hierarchies/internal/Common.d.ts +8 -5
  204. package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
  205. package/lib/esm/hierarchies/internal/Common.js +1 -66
  206. package/lib/esm/hierarchies/internal/Common.js.map +1 -1
  207. package/lib/esm/hierarchies/internal/operators/Sorting.d.ts +3 -2
  208. package/lib/esm/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
  209. package/lib/esm/hierarchies/internal/operators/Sorting.js.map +1 -1
  210. package/lib/esm/presentation-hierarchies.d.ts +10 -6
  211. package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
  212. package/lib/esm/presentation-hierarchies.js +8 -4
  213. package/lib/esm/presentation-hierarchies.js.map +1 -1
  214. package/package.json +3 -2
  215. package/lib/cjs/hierarchies/HierarchyDefinition.d.ts +0 -251
  216. package/lib/cjs/hierarchies/HierarchyDefinition.d.ts.map +0 -1
  217. package/lib/cjs/hierarchies/HierarchyDefinition.js.map +0 -1
  218. package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.d.ts.map +0 -1
  219. package/lib/cjs/hierarchies/LimitingECSqlQueryExecutor.js.map +0 -1
  220. package/lib/cjs/hierarchies/NodeSelectQueryFactory.d.ts.map +0 -1
  221. package/lib/cjs/hierarchies/NodeSelectQueryFactory.js.map +0 -1
  222. package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.d.ts +0 -40
  223. package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.d.ts.map +0 -1
  224. package/lib/cjs/hierarchies/internal/ChildNodeObservablesCache.js.map +0 -1
  225. package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +0 -1
  226. package/lib/cjs/hierarchies/internal/FilteringHierarchyDefinition.js.map +0 -1
  227. package/lib/cjs/hierarchies/internal/TreeNodesReader.d.ts.map +0 -1
  228. package/lib/cjs/hierarchies/internal/TreeNodesReader.js.map +0 -1
  229. package/lib/cjs/hierarchies/internal/operators/DetermineChildren.d.ts.map +0 -1
  230. package/lib/cjs/hierarchies/internal/operators/DetermineChildren.js.map +0 -1
  231. package/lib/cjs/hierarchies/internal/operators/Grouping.d.ts.map +0 -1
  232. package/lib/cjs/hierarchies/internal/operators/Grouping.js.map +0 -1
  233. package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.d.ts.map +0 -1
  234. package/lib/cjs/hierarchies/internal/operators/HideIfNoChildren.js.map +0 -1
  235. package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.d.ts.map +0 -1
  236. package/lib/cjs/hierarchies/internal/operators/HideNodesInHierarchy.js.map +0 -1
  237. package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.d.ts.map +0 -1
  238. package/lib/cjs/hierarchies/internal/operators/grouping/AutoExpand.js.map +0 -1
  239. package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.d.ts.map +0 -1
  240. package/lib/cjs/hierarchies/internal/operators/grouping/BaseClassGrouping.js.map +0 -1
  241. package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.d.ts.map +0 -1
  242. package/lib/cjs/hierarchies/internal/operators/grouping/ClassGrouping.js.map +0 -1
  243. package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.d.ts.map +0 -1
  244. package/lib/cjs/hierarchies/internal/operators/grouping/GroupHiding.js.map +0 -1
  245. package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.d.ts.map +0 -1
  246. package/lib/cjs/hierarchies/internal/operators/grouping/LabelGrouping.js.map +0 -1
  247. package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.d.ts.map +0 -1
  248. package/lib/cjs/hierarchies/internal/operators/grouping/PropertiesGrouping.js.map +0 -1
  249. package/lib/cjs/hierarchies/internal/operators/grouping/Shared.d.ts.map +0 -1
  250. package/lib/cjs/hierarchies/internal/operators/grouping/Shared.js.map +0 -1
  251. package/lib/esm/hierarchies/HierarchyDefinition.d.ts +0 -251
  252. package/lib/esm/hierarchies/HierarchyDefinition.d.ts.map +0 -1
  253. package/lib/esm/hierarchies/HierarchyDefinition.js.map +0 -1
  254. package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.d.ts.map +0 -1
  255. package/lib/esm/hierarchies/LimitingECSqlQueryExecutor.js.map +0 -1
  256. package/lib/esm/hierarchies/NodeSelectQueryFactory.d.ts.map +0 -1
  257. package/lib/esm/hierarchies/NodeSelectQueryFactory.js.map +0 -1
  258. package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.d.ts +0 -40
  259. package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.d.ts.map +0 -1
  260. package/lib/esm/hierarchies/internal/ChildNodeObservablesCache.js.map +0 -1
  261. package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.d.ts.map +0 -1
  262. package/lib/esm/hierarchies/internal/FilteringHierarchyDefinition.js.map +0 -1
  263. package/lib/esm/hierarchies/internal/TreeNodesReader.d.ts.map +0 -1
  264. package/lib/esm/hierarchies/internal/TreeNodesReader.js.map +0 -1
  265. package/lib/esm/hierarchies/internal/operators/DetermineChildren.d.ts.map +0 -1
  266. package/lib/esm/hierarchies/internal/operators/DetermineChildren.js.map +0 -1
  267. package/lib/esm/hierarchies/internal/operators/Grouping.d.ts.map +0 -1
  268. package/lib/esm/hierarchies/internal/operators/Grouping.js.map +0 -1
  269. package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.d.ts.map +0 -1
  270. package/lib/esm/hierarchies/internal/operators/HideIfNoChildren.js.map +0 -1
  271. package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.d.ts.map +0 -1
  272. package/lib/esm/hierarchies/internal/operators/HideNodesInHierarchy.js.map +0 -1
  273. package/lib/esm/hierarchies/internal/operators/grouping/AutoExpand.d.ts.map +0 -1
  274. package/lib/esm/hierarchies/internal/operators/grouping/AutoExpand.js.map +0 -1
  275. package/lib/esm/hierarchies/internal/operators/grouping/BaseClassGrouping.d.ts.map +0 -1
  276. package/lib/esm/hierarchies/internal/operators/grouping/BaseClassGrouping.js.map +0 -1
  277. package/lib/esm/hierarchies/internal/operators/grouping/ClassGrouping.d.ts.map +0 -1
  278. package/lib/esm/hierarchies/internal/operators/grouping/ClassGrouping.js.map +0 -1
  279. package/lib/esm/hierarchies/internal/operators/grouping/GroupHiding.d.ts.map +0 -1
  280. package/lib/esm/hierarchies/internal/operators/grouping/GroupHiding.js.map +0 -1
  281. package/lib/esm/hierarchies/internal/operators/grouping/LabelGrouping.d.ts.map +0 -1
  282. package/lib/esm/hierarchies/internal/operators/grouping/LabelGrouping.js.map +0 -1
  283. package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.d.ts.map +0 -1
  284. package/lib/esm/hierarchies/internal/operators/grouping/PropertiesGrouping.js.map +0 -1
  285. package/lib/esm/hierarchies/internal/operators/grouping/Shared.d.ts.map +0 -1
  286. package/lib/esm/hierarchies/internal/operators/grouping/Shared.js.map +0 -1
  287. /package/lib/cjs/hierarchies/{LimitingECSqlQueryExecutor.d.ts → imodel/LimitingECSqlQueryExecutor.d.ts} +0 -0
  288. /package/lib/cjs/hierarchies/{NodeSelectQueryFactory.js → imodel/NodeSelectQueryFactory.js} +0 -0
  289. /package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/AutoExpand.d.ts +0 -0
  290. /package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/AutoExpand.js +0 -0
  291. /package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/BaseClassGrouping.js +0 -0
  292. /package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/ClassGrouping.js +0 -0
  293. /package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/GroupHiding.d.ts +0 -0
  294. /package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/GroupHiding.js +0 -0
  295. /package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/PropertiesGrouping.js +0 -0
  296. /package/lib/cjs/hierarchies/{internal → imodel}/operators/grouping/Shared.js +0 -0
  297. /package/lib/esm/hierarchies/{LimitingECSqlQueryExecutor.d.ts → imodel/LimitingECSqlQueryExecutor.d.ts} +0 -0
  298. /package/lib/esm/hierarchies/{NodeSelectQueryFactory.js → imodel/NodeSelectQueryFactory.js} +0 -0
  299. /package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/AutoExpand.d.ts +0 -0
  300. /package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/AutoExpand.js +0 -0
  301. /package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/BaseClassGrouping.js +0 -0
  302. /package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/ClassGrouping.js +0 -0
  303. /package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/GroupHiding.d.ts +0 -0
  304. /package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/GroupHiding.js +0 -0
  305. /package/lib/esm/hierarchies/{internal → imodel}/operators/grouping/Shared.js +0 -0
@@ -0,0 +1,436 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { catchError, concat, defaultIfEmpty, defer, EMPTY, filter, finalize, from, map, merge, mergeAll, mergeMap, of, Subject, take, takeUntil, tap, } from "rxjs";
6
+ import { assert, BeEvent, Guid, StopWatch } from "@itwin/core-bentley";
7
+ import { createDefaultValueFormatter, formatConcatenatedValue, normalizeFullClassName, } from "@itwin/presentation-shared";
8
+ import { RowsLimitExceededError } from "../HierarchyErrors";
9
+ import { HierarchyNode } from "../HierarchyNode";
10
+ import { HierarchyNodeKey } from "../HierarchyNodeKey";
11
+ import { LOGGING_NAMESPACE as BASE_LOGGING_NAMESPACE, LOGGING_NAMESPACE_INTERNAL as BASE_LOGGING_NAMESPACE_INTERNAL, LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE, createNodeIdentifierForLogging, hasChildren, } from "../internal/Common";
12
+ import { eachValueFrom } from "../internal/EachValueFrom";
13
+ import { doLog, log } from "../internal/LoggingUtils";
14
+ import { partition } from "../internal/operators/Partition";
15
+ import { reduceToMergeMapList } from "../internal/operators/ReduceToMergeMap";
16
+ import { shareReplayWithErrors } from "../internal/operators/ShareReplayWithErrors";
17
+ import { sortNodesByLabelOperator } from "../internal/operators/Sorting";
18
+ import { SubscriptionScheduler } from "../internal/SubscriptionScheduler";
19
+ import { FilteringHierarchyDefinition } from "./FilteringHierarchyDefinition";
20
+ import { HierarchyCache } from "./HierarchyCache";
21
+ import { HierarchyNodesDefinition } from "./IModelHierarchyDefinition";
22
+ import { NodeSelectClauseColumnNames } from "./NodeSelectQueryFactory";
23
+ import { createDetermineChildrenOperator } from "./operators/DetermineChildren";
24
+ import { createGroupingOperator } from "./operators/Grouping";
25
+ import { createHideIfNoChildrenOperator } from "./operators/HideIfNoChildren";
26
+ import { createHideNodesInHierarchyOperator } from "./operators/HideNodesInHierarchy";
27
+ import { readNodes } from "./TreeNodesReader";
28
+ const LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.IModelHierarchyProvider`;
29
+ const LOGGING_NAMESPACE_INTERNAL = `${BASE_LOGGING_NAMESPACE_INTERNAL}.IModelHierarchyProvider`;
30
+ const LOGGING_NAMESPACE_PERFORMANCE = `${BASE_LOGGING_NAMESPACE_PERFORMANCE}.IModelHierarchyProvider`;
31
+ const DEFAULT_QUERY_CONCURRENCY = 10;
32
+ const DEFAULT_QUERY_CACHE_SIZE = 1;
33
+ /**
34
+ * Creates an instance of `HierarchyProvider` that creates a hierarchy based on given iModel and
35
+ * a hierarchy definition, which defines each hierarchy level through ECSQL queries.
36
+ *
37
+ * @beta
38
+ */
39
+ export function createIModelHierarchyProvider(props) {
40
+ return new IModelHierarchyProviderImpl(props);
41
+ }
42
+ class IModelHierarchyProviderImpl {
43
+ _imodelAccess;
44
+ _imodelChanged;
45
+ _valuesFormatter;
46
+ _sourceHierarchyDefinition;
47
+ _activeHierarchyDefinition;
48
+ _localizedStrings;
49
+ _queryScheduler;
50
+ _nodesCache;
51
+ _unsubscribe;
52
+ _dispose = new Subject();
53
+ constructor(props) {
54
+ this._imodelAccess = props.imodelAccess;
55
+ this._imodelChanged = props.imodelChanged ?? new BeEvent();
56
+ this._activeHierarchyDefinition = this._sourceHierarchyDefinition = props.hierarchyDefinition;
57
+ this._valuesFormatter = props?.formatter ?? createDefaultValueFormatter();
58
+ this._localizedStrings = { other: "Other", unspecified: "Not specified", ...props?.localizedStrings };
59
+ this._queryScheduler = new SubscriptionScheduler(props.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY);
60
+ this.setHierarchyFilter(props.filtering);
61
+ const queryCacheSize = props.queryCacheSize ?? DEFAULT_QUERY_CACHE_SIZE;
62
+ if (queryCacheSize !== 0) {
63
+ this._nodesCache = new HierarchyCache({
64
+ // we divide the size by 2, because each variation also counts as a query that we cache
65
+ size: Math.ceil(queryCacheSize / 2),
66
+ variationsCount: 1,
67
+ });
68
+ this._unsubscribe = props.imodelChanged?.addListener(() => {
69
+ this.invalidateHierarchyCache("Data source changed");
70
+ this._dispose.next();
71
+ });
72
+ }
73
+ }
74
+ dispose() {
75
+ this._dispose.next();
76
+ this._unsubscribe?.();
77
+ }
78
+ get hierarchyChanged() {
79
+ return this._imodelChanged;
80
+ }
81
+ invalidateHierarchyCache(reason) {
82
+ doLog({
83
+ category: `${LOGGING_NAMESPACE}.Events`,
84
+ message: /* istanbul ignore next */ () => (reason ? `${reason}: clear hierarchy cache` : `Clear hierarchy cache`),
85
+ });
86
+ this._nodesCache?.clear();
87
+ }
88
+ /**
89
+ * Sets `HierarchyProvider` values formatter that formats nodes' labels. If provided `undefined`, then defaults to the
90
+ * result of `createDefaultValueFormatter` called with default parameters.
91
+ */
92
+ setFormatter(formatter) {
93
+ this._valuesFormatter = formatter ?? createDefaultValueFormatter();
94
+ }
95
+ setHierarchyFilter(props) {
96
+ if (!props) {
97
+ if (this._sourceHierarchyDefinition !== this._activeHierarchyDefinition) {
98
+ this._activeHierarchyDefinition = this._sourceHierarchyDefinition;
99
+ this.invalidateHierarchyCache("Hierarchy filter reset");
100
+ }
101
+ return;
102
+ }
103
+ this._activeHierarchyDefinition = new FilteringHierarchyDefinition({
104
+ imodelAccess: this._imodelAccess,
105
+ source: this._sourceHierarchyDefinition,
106
+ nodeIdentifierPaths: props.paths,
107
+ });
108
+ this.invalidateHierarchyCache("Hierarchy filter set");
109
+ this._dispose.next();
110
+ }
111
+ onGroupingNodeCreated(groupingNode, props) {
112
+ this._nodesCache?.set({ ...props, parentNode: groupingNode }, { observable: from(groupingNode.children), processingStatus: "pre-processed" });
113
+ }
114
+ createHierarchyLevelDefinitionsObservable(props) {
115
+ const { requestContext, ...defineHierarchyLevelProps } = props;
116
+ doLog({
117
+ category: LOGGING_NAMESPACE_PERFORMANCE,
118
+ message: /* istanbul ignore next */ () => `[${requestContext.requestId}] Requesting hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,
119
+ });
120
+ return from(defer(async () => {
121
+ let parentNode = props.parentNode;
122
+ if (parentNode && HierarchyNode.isGeneric(parentNode) && parentNode.key.source && parentNode.key.source !== this._imodelAccess.imodelKey) {
123
+ return [];
124
+ }
125
+ if (parentNode && HierarchyNode.isInstancesNode(parentNode)) {
126
+ parentNode = {
127
+ ...parentNode,
128
+ key: {
129
+ ...parentNode.key,
130
+ instanceKeys: parentNode.key.instanceKeys.filter((ik) => !ik.imodelKey || ik.imodelKey === this._imodelAccess.imodelKey),
131
+ },
132
+ };
133
+ assert(HierarchyNodeKey.isInstances(parentNode.key));
134
+ if (parentNode.key.instanceKeys.length === 0) {
135
+ return [];
136
+ }
137
+ }
138
+ return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode });
139
+ })).pipe(mergeAll(), finalize(() => doLog({
140
+ category: LOGGING_NAMESPACE_PERFORMANCE,
141
+ message: /* istanbul ignore next */ () => `[${requestContext.requestId}] Received all hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,
142
+ })));
143
+ }
144
+ createSourceNodesObservable(props) {
145
+ // pipe definitions to nodes and put "share replay" on it
146
+ return this.createHierarchyLevelDefinitionsObservable(props).pipe(mergeMap((def) => {
147
+ if (HierarchyNodesDefinition.isGenericNode(def)) {
148
+ return of({ ...def.node, key: { type: "generic", id: def.node.key, source: this._imodelAccess.imodelKey } });
149
+ }
150
+ return this._queryScheduler.scheduleSubscription(of(def.query).pipe(map((query) => filterQueryByInstanceKeys(query, props.filteredInstanceKeys)), mergeMap((query) => readNodes({ queryExecutor: this._imodelAccess, query, limit: props.hierarchyLevelSizeLimit, parser: this._activeHierarchyDefinition.parseNode })), map((node) => ({
151
+ ...node,
152
+ key: { ...node.key, instanceKeys: node.key.instanceKeys.map((key) => ({ ...key, imodelKey: this._imodelAccess.imodelKey })) },
153
+ }))));
154
+ }), finalize(() => doLog({
155
+ category: LOGGING_NAMESPACE_PERFORMANCE,
156
+ message: /* istanbul ignore next */ () => `[${props.requestContext.requestId}] Read all child nodes ${createNodeIdentifierForLogging(props.parentNode)}`,
157
+ })), shareReplayWithErrors());
158
+ }
159
+ createPreProcessedNodesObservable(queryNodesObservable, props) {
160
+ return queryNodesObservable.pipe(
161
+ // we're going to be mutating the nodes, but don't want to mutate the original one, so just clone it here once
162
+ map((node) => ({ ...node })),
163
+ // set parent node keys on the source node
164
+ map((node) => Object.assign(node, { parentKeys: createParentNodeKeysList(props.parentNode) })),
165
+ // format `ConcatenatedValue` labels into string labels
166
+ mergeMap(async (node) => applyLabelsFormatting(node, this._valuesFormatter)),
167
+ // we have `ProcessedHierarchyNode` from here
168
+ preProcessNodes(this._activeHierarchyDefinition),
169
+ // process hiding
170
+ createHideIfNoChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes), createHideNodesInHierarchyOperator(
171
+ // note: for child nodes created because of hidden parent, we want to use parent's request props (instance filter, limit)
172
+ (n) => this.getChildNodesObservables({ ...props, parentNode: n }).processedNodes, false), finalize(() => doLog({
173
+ category: LOGGING_NAMESPACE_PERFORMANCE,
174
+ message: /* istanbul ignore next */ () => `[${props.requestContext.requestId}] Finished pre-processing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,
175
+ })));
176
+ }
177
+ createProcessedNodesObservable(preprocessedNodesObservable, props) {
178
+ return preprocessedNodesObservable.pipe(createGroupingOperator(this._imodelAccess, props.parentNode, this._valuesFormatter, this._localizedStrings, (gn) => this.onGroupingNodeCreated(gn, props)), finalize(() => doLog({
179
+ category: LOGGING_NAMESPACE_PERFORMANCE,
180
+ message: /* istanbul ignore next */ () => `[${props.requestContext.requestId}] Finished grouping child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,
181
+ })));
182
+ }
183
+ createFinalizedNodesObservable(processedNodesObservable, props) {
184
+ return processedNodesObservable.pipe(createDetermineChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes), postProcessNodes(this._activeHierarchyDefinition), sortNodesByLabelOperator, map((n) => {
185
+ if ("processingParams" in n) {
186
+ delete n.processingParams;
187
+ }
188
+ return Object.assign(n, {
189
+ children: hasChildren(n),
190
+ });
191
+ }), takeUntil(this._dispose), finalize(() => doLog({
192
+ category: LOGGING_NAMESPACE_PERFORMANCE,
193
+ message: /* istanbul ignore next */ () => `[${props.requestContext.requestId}] Finished finalizing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,
194
+ })));
195
+ }
196
+ createHasNodesObservable(preprocessedNodesObservable, possiblyKnownChildrenObservable, props) {
197
+ const loggingCategory = `${LOGGING_NAMESPACE_INTERNAL}.HasNodes`;
198
+ return concat((possiblyKnownChildrenObservable ?? EMPTY).pipe(filter((n) => hasChildren(n))), preprocessedNodesObservable).pipe(log({
199
+ category: loggingCategory,
200
+ message: /* istanbul ignore next */ (n) => `[${props.requestContext.requestId}] Node before mapping to 'true': ${createNodeIdentifierForLogging(n)}`,
201
+ }), take(1), map(() => true), defaultIfEmpty(false), catchError((e) => {
202
+ doLog({
203
+ category: loggingCategory,
204
+ message: /* istanbul ignore next */ () => `[${props.requestContext.requestId}] Error while determining children: ${e.message}`,
205
+ });
206
+ if (e instanceof RowsLimitExceededError) {
207
+ return of(true);
208
+ }
209
+ throw e;
210
+ }), log({ category: loggingCategory, message: /* istanbul ignore next */ (r) => `[${props.requestContext.requestId}] Result: ${r}` }));
211
+ }
212
+ getCachedObservableEntry(props) {
213
+ const loggingCategory = `${LOGGING_NAMESPACE}.QueryResultsCache`;
214
+ const { parentNode, ...restProps } = props;
215
+ const cached = props.ignoreCache || !this._nodesCache ? undefined : this._nodesCache.get(props);
216
+ if (cached) {
217
+ // istanbul ignore next
218
+ doLog({
219
+ category: loggingCategory,
220
+ message: /* istanbul ignore next */ () => `[${props.requestContext.requestId}] Found query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,
221
+ });
222
+ return cached;
223
+ }
224
+ // if we don't find an entry for a grouping node, we load its instances by getting a query and applying
225
+ // a filter based on grouped instance keys
226
+ let filteredInstanceKeys;
227
+ let parentNonGroupingNode;
228
+ if (parentNode) {
229
+ if (HierarchyNode.isGroupingNode(parentNode)) {
230
+ parentNonGroupingNode = parentNode.nonGroupingAncestor;
231
+ filteredInstanceKeys = parentNode.groupedInstanceKeys;
232
+ }
233
+ else {
234
+ // not sure why type checker doesn't pick this up
235
+ assert(HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));
236
+ parentNonGroupingNode = parentNode;
237
+ }
238
+ }
239
+ const nonGroupingNodeChildrenRequestProps = {
240
+ ...restProps,
241
+ parentNode: parentNonGroupingNode,
242
+ ...(filteredInstanceKeys ? { filteredInstanceKeys } : undefined),
243
+ };
244
+ const value = { observable: this.createSourceNodesObservable(nonGroupingNodeChildrenRequestProps), processingStatus: "none" };
245
+ this._nodesCache?.set(nonGroupingNodeChildrenRequestProps, value);
246
+ doLog({
247
+ category: loggingCategory,
248
+ message: /* istanbul ignore next */ () => `[${props.requestContext.requestId}] Saved query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,
249
+ });
250
+ return value;
251
+ }
252
+ getChildNodesObservables(props) {
253
+ const entry = this.getCachedObservableEntry(props);
254
+ switch (entry.processingStatus) {
255
+ case "none": {
256
+ const pre = this.createPreProcessedNodesObservable(entry.observable, props);
257
+ const post = this.createProcessedNodesObservable(pre, props);
258
+ return {
259
+ processedNodes: post,
260
+ hasNodes: this.createHasNodesObservable(pre, entry.observable, props),
261
+ finalizedNodes: this.createFinalizedNodesObservable(post, props),
262
+ };
263
+ }
264
+ case "pre-processed": {
265
+ const post = this.createProcessedNodesObservable(entry.observable, props);
266
+ return {
267
+ processedNodes: post,
268
+ hasNodes: this.createHasNodesObservable(entry.observable, undefined, props),
269
+ finalizedNodes: this.createFinalizedNodesObservable(post, props),
270
+ };
271
+ }
272
+ }
273
+ }
274
+ /**
275
+ * Creates and runs a query based on provided props, then processes retrieved nodes and returns them.
276
+ */
277
+ getNodes(props) {
278
+ const requestContext = { requestId: Guid.createValue() };
279
+ const loggingCategory = `${LOGGING_NAMESPACE}.GetNodes`;
280
+ const timer = new StopWatch(undefined, true);
281
+ let error;
282
+ let nodesCount = 0;
283
+ doLog({
284
+ category: loggingCategory,
285
+ message: /* istanbul ignore next */ () => `[${requestContext.requestId}] Requesting child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,
286
+ });
287
+ return eachValueFrom(this.getChildNodesObservables({ ...props, requestContext }).finalizedNodes.pipe(tap(() => ++nodesCount), catchError((e) => {
288
+ error = e;
289
+ throw e;
290
+ }), finalize(() => {
291
+ doLog({
292
+ category: loggingCategory,
293
+ message: /* istanbul ignore next */ () => error
294
+ ? `[${requestContext.requestId}] Error creating child nodes for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`
295
+ : `[${requestContext.requestId}] Returned ${nodesCount} child nodes for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,
296
+ });
297
+ })));
298
+ }
299
+ getNodeInstanceKeysObs(props) {
300
+ const { parentNode, instanceFilter, hierarchyLevelSizeLimit = "unbounded", requestContext } = props;
301
+ if (parentNode && HierarchyNode.isGroupingNode(parentNode)) {
302
+ return from(parentNode.groupedInstanceKeys);
303
+ }
304
+ assert(!parentNode || HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));
305
+ const hierarchyLevelDefinitions = this.createHierarchyLevelDefinitionsObservable({ parentNode, instanceFilter, requestContext });
306
+ // split the definitions based on whether they're for generic nodes or for instance nodes
307
+ const [genericDefs, instanceDefs] = partition(hierarchyLevelDefinitions, HierarchyNodesDefinition.isGenericNode);
308
+ // query instance keys and a flag whether they should be hidden
309
+ const instanceKeys = instanceDefs.pipe(mergeMap((def) => this._queryScheduler.scheduleSubscription(of(def.query).pipe(mergeMap(async (query) => {
310
+ const ecsql = `
311
+ SELECT
312
+ ${NodeSelectClauseColumnNames.FullClassName},
313
+ ${NodeSelectClauseColumnNames.ECInstanceId},
314
+ ${NodeSelectClauseColumnNames.HideNodeInHierarchy}
315
+ FROM (
316
+ ${query.ecsql}
317
+ )
318
+ `;
319
+ const reader = this._imodelAccess.createQueryReader({ ...query, ecsql }, { rowFormat: "Indexes", limit: hierarchyLevelSizeLimit });
320
+ return from(reader).pipe(map((row) => ({
321
+ key: {
322
+ className: normalizeFullClassName(row[0]),
323
+ id: row[1],
324
+ imodelKey: this._imodelAccess.imodelKey,
325
+ },
326
+ hide: !!row[2],
327
+ })));
328
+ }), mergeAll()))));
329
+ // split the instance keys observable based on whether they should be hidden or not
330
+ const [visibleNodeInstanceKeys, hiddenNodeInstanceKeys] = partition(instanceKeys, ({ hide }) => !hide);
331
+ // hidden items' handling:
332
+ // - if a generic node is hidden, we'll want to retrieve instance keys of its children, otherwise we don't care about it,
333
+ // - if an instance key is hidden, we want to create a merged node similar to what we do in `createHideNodesInHierarchyOperator`
334
+ const hiddenParentNodes = merge(genericDefs.pipe(filter((def) => !!def.node.processingParams?.hideInHierarchy), map((def) => ({
335
+ type: "generic",
336
+ id: def.node.key,
337
+ source: this._imodelAccess.imodelKey,
338
+ }))), hiddenNodeInstanceKeys.pipe(
339
+ // first merge all keys by class
340
+ reduceToMergeMapList(({ key }) => key.className, ({ key }) => key.id),
341
+ // then, for each class, create an instance key
342
+ mergeMap((mergedMap) => [...mergedMap.entries()].map(([className, ids]) => ({
343
+ type: "instances",
344
+ instanceKeys: ids.map((id) => ({ className, id, imodelKey: this._imodelAccess.imodelKey })),
345
+ }))))).pipe(map((key) => ({
346
+ key,
347
+ parentKeys: [],
348
+ label: "",
349
+ })));
350
+ // merge visible instance keys from this level & the ones we get recursively requesting from deeper levels
351
+ return merge(visibleNodeInstanceKeys.pipe(map(({ key }) => key)), hiddenParentNodes.pipe(mergeMap((hiddenNode) => this.getNodeInstanceKeysObs({ parentNode: hiddenNode, requestContext })))).pipe(takeUntil(this._dispose));
352
+ }
353
+ /**
354
+ * Creates an iterator for all child hierarchy level instance keys, taking into account any hidden hierarchy levels
355
+ * that there may be under the given parent node.
356
+ */
357
+ getNodeInstanceKeys(props) {
358
+ const requestContext = { requestId: Guid.createValue() };
359
+ const loggingCategory = `${LOGGING_NAMESPACE}.GetNodeInstanceKeys`;
360
+ const timer = new StopWatch(undefined, true);
361
+ doLog({
362
+ category: loggingCategory,
363
+ message: /* istanbul ignore next */ () => `[${requestContext.requestId}] Requesting keys for ${createNodeIdentifierForLogging(props.parentNode)}`,
364
+ });
365
+ let error;
366
+ let keysCount = 0;
367
+ return eachValueFrom(this.getNodeInstanceKeysObs({ ...props, requestContext }).pipe(tap(() => ++keysCount), catchError((e) => {
368
+ error = e;
369
+ throw e;
370
+ }), finalize(() => {
371
+ doLog({
372
+ category: loggingCategory,
373
+ message: /* istanbul ignore next */ () => error
374
+ ? `[${requestContext.requestId}] Error creating node instance keys for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`
375
+ : `[${requestContext.requestId}] Returned ${keysCount} instance keys for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,
376
+ });
377
+ })));
378
+ }
379
+ }
380
+ function preProcessNodes(hierarchyFactory) {
381
+ return hierarchyFactory.preProcessNode
382
+ ? processNodes(hierarchyFactory.preProcessNode.bind(hierarchyFactory))
383
+ : (o) => o;
384
+ }
385
+ function postProcessNodes(hierarchyFactory) {
386
+ return hierarchyFactory.postProcessNode
387
+ ? processNodes(hierarchyFactory.postProcessNode.bind(hierarchyFactory))
388
+ : (o) => o;
389
+ }
390
+ function processNodes(processor) {
391
+ return (nodes) => nodes.pipe(mergeMap(processor), filter((n) => !!n));
392
+ }
393
+ async function applyLabelsFormatting(node, valueFormatter) {
394
+ return {
395
+ ...node,
396
+ label: await formatConcatenatedValue({
397
+ value: node.label,
398
+ valueFormatter,
399
+ }),
400
+ };
401
+ }
402
+ function createParentNodeKeysList(parentNode) {
403
+ if (!parentNode) {
404
+ return [];
405
+ }
406
+ return [...parentNode.parentKeys, parentNode.key];
407
+ }
408
+ function filterQueryByInstanceKeys(query, filteredInstanceKeys) {
409
+ if (!filteredInstanceKeys || !filteredInstanceKeys.length) {
410
+ return query;
411
+ }
412
+ const MAX_ALLOWED_BINDINGS = 1000;
413
+ // istanbul ignore else
414
+ if (filteredInstanceKeys.length < MAX_ALLOWED_BINDINGS) {
415
+ return {
416
+ ...query,
417
+ ecsql: `
418
+ SELECT *
419
+ FROM (${query.ecsql}) q
420
+ WHERE q.ECInstanceId IN (${filteredInstanceKeys.map(() => "?").join(",")})
421
+ `,
422
+ bindings: [...(query.bindings ?? []), ...filteredInstanceKeys.map((k) => ({ type: "id", value: k.id }))],
423
+ };
424
+ }
425
+ // istanbul ignore next
426
+ return {
427
+ ...query,
428
+ ecsql: `
429
+ SELECT *
430
+ FROM (${query.ecsql}) q
431
+ WHERE InVirtualSet(?, q.ECInstanceId)
432
+ `,
433
+ bindings: [...(query.bindings ?? []), { type: "idset", value: filteredInstanceKeys.map((k) => k.id) }],
434
+ };
435
+ }
436
+ //# sourceMappingURL=IModelHierarchyProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelHierarchyProvider.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/IModelHierarchyProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EACL,UAAU,EACV,MAAM,EACN,cAAc,EACd,KAAK,EACL,KAAK,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,KAAK,EACL,QAAQ,EACR,QAAQ,EA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EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,GAAG,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,yBAAyB,CAAC,KAAoB,EAAE,oBAA+C;IACtG,IAAI,CAAC,oBAAoB,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,oBAAoB,GAAG,IAAI,CAAC;IAClC,uBAAuB;IACvB,IAAI,oBAAoB,CAAC,MAAM,GAAG,oBAAoB,EAAE,CAAC;QACvD,OAAO;YACL,GAAG,KAAK;YACR,KAAK,EAAE;;gBAEG,KAAK,CAAC,KAAK;mCACQ,oBAAoB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;OACzE;YACD,QAAQ,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;SACvH,CAAC;IACJ,CAAC;IACD,uBAAuB;IACvB,OAAO;QACL,GAAG,KAAK;QACR,KAAK,EAAE;;cAEG,KAAK,CAAC,KAAK;;KAEpB;QACD,QAAQ,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;KACvG,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport {\n catchError,\n concat,\n defaultIfEmpty,\n defer,\n EMPTY,\n filter,\n finalize,\n from,\n map,\n merge,\n mergeAll,\n mergeMap,\n Observable,\n ObservableInput,\n of,\n Subject,\n take,\n takeUntil,\n tap,\n} from \"rxjs\";\nimport { assert, BeEvent, Guid, StopWatch } from \"@itwin/core-bentley\";\nimport {\n ConcatenatedValue,\n createDefaultValueFormatter,\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSqlBinding,\n ECSqlQueryDef,\n Event,\n formatConcatenatedValue,\n InstanceKey,\n IPrimitiveValueFormatter,\n normalizeFullClassName,\n} from \"@itwin/presentation-shared\";\nimport { RowsLimitExceededError } from \"../HierarchyErrors\";\nimport { HierarchyFilteringPath } from \"../HierarchyFiltering\";\nimport { HierarchyNode, NonGroupingHierarchyNode, ParentHierarchyNode } from \"../HierarchyNode\";\nimport { GenericNodeKey, HierarchyNodeKey, IModelInstanceKey, InstancesNodeKey } from \"../HierarchyNodeKey\";\nimport { GetHierarchyNodesProps, HierarchyProvider } from \"../HierarchyProvider\";\nimport {\n LOGGING_NAMESPACE as BASE_LOGGING_NAMESPACE,\n LOGGING_NAMESPACE_INTERNAL as BASE_LOGGING_NAMESPACE_INTERNAL,\n LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE,\n createNodeIdentifierForLogging,\n hasChildren,\n} from \"../internal/Common\";\nimport { eachValueFrom } from \"../internal/EachValueFrom\";\nimport { doLog, log } from \"../internal/LoggingUtils\";\nimport { partition } from \"../internal/operators/Partition\";\nimport { reduceToMergeMapList } from \"../internal/operators/ReduceToMergeMap\";\nimport { shareReplayWithErrors } from \"../internal/operators/ShareReplayWithErrors\";\nimport { sortNodesByLabelOperator } from \"../internal/operators/Sorting\";\nimport { SubscriptionScheduler } from \"../internal/SubscriptionScheduler\";\nimport { FilteringHierarchyDefinition } from \"./FilteringHierarchyDefinition\";\nimport { HierarchyCache } from \"./HierarchyCache\";\nimport { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyNodesDefinition } from \"./IModelHierarchyDefinition\";\nimport {\n ProcessedGenericHierarchyNode,\n ProcessedGroupingHierarchyNode,\n ProcessedHierarchyNode,\n ProcessedInstanceHierarchyNode,\n SourceGenericHierarchyNode,\n SourceInstanceHierarchyNode,\n} from \"./IModelHierarchyNode\";\nimport { LimitingECSqlQueryExecutor } from \"./LimitingECSqlQueryExecutor\";\nimport { NodeSelectClauseColumnNames } from \"./NodeSelectQueryFactory\";\nimport { createDetermineChildrenOperator } from \"./operators/DetermineChildren\";\nimport { createGroupingOperator } from \"./operators/Grouping\";\nimport { createHideIfNoChildrenOperator } from \"./operators/HideIfNoChildren\";\nimport { createHideNodesInHierarchyOperator } from \"./operators/HideNodesInHierarchy\";\nimport { readNodes } from \"./TreeNodesReader\";\n\nconst LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.IModelHierarchyProvider`;\nconst LOGGING_NAMESPACE_INTERNAL = `${BASE_LOGGING_NAMESPACE_INTERNAL}.IModelHierarchyProvider`;\nconst LOGGING_NAMESPACE_PERFORMANCE = `${BASE_LOGGING_NAMESPACE_PERFORMANCE}.IModelHierarchyProvider`;\n\nconst DEFAULT_QUERY_CONCURRENCY = 10;\nconst DEFAULT_QUERY_CACHE_SIZE = 1;\n\n/**\n * Defines the strings used by hierarchy provider.\n * @beta\n */\ninterface IModelHierarchyProviderLocalizedStrings {\n /**\n * A string for \"Unspecified\". Used for labels of property grouping nodes\n * that group by an empty value.\n */\n unspecified: string;\n\n /**\n * A string for \"Other\". Used for label of a range property grouping node that\n * groups values which don't fit into any other range.\n */\n other: string;\n}\n\n/** @beta */\ntype IModelAccess = ECSchemaProvider & LimitingECSqlQueryExecutor & ECClassHierarchyInspector & { imodelKey: string };\n\n/**\n * Props for `createIModelHierarchyProvider`.\n * @beta\n */\ninterface IModelHierarchyProviderProps {\n /**\n * An object that provides access to iModel's data and metadata.\n *\n * @see `ECSchemaProvider`\n * @see `LimitingECSqlQueryExecutor`\n * @see `ECClassHierarchyInspector`\n */\n imodelAccess: IModelAccess;\n\n /** An event that is raised when iModel data, that may affect the hierarchy, changes. */\n imodelChanged?: Event<() => void>;\n\n /**\n * A function that returns a hierarchy definition, describing how the hierarchy that the provider should be create. The\n * function is called once during the provider's construction.\n */\n hierarchyDefinition: HierarchyDefinition;\n\n /** Maximum number of queries that the provider attempts to execute in parallel. Defaults to `10`. */\n queryConcurrency?: number;\n /**\n * The amount of queries whose results are stored in-memory for quick retrieval. Defaults to `1`,\n * which means only results of the last run query are cached.\n */\n queryCacheSize?: number;\n\n /** A set of localized strings to use. Defaults to English strings. */\n localizedStrings?: Partial<IModelHierarchyProviderLocalizedStrings>;\n\n /**\n * A values formatter for formatting node labels. Defaults to the\n * result of `createDefaultValueFormatter` called with default parameters. May be overridden\n * by calling `setFormatter` on the provider instance.\n */\n formatter?: IPrimitiveValueFormatter;\n /** Props for filtering the hierarchy. */\n filtering?: {\n /** A list of node identifiers from root to target node. */\n paths: HierarchyFilteringPath[];\n };\n}\n\n/**\n * Creates an instance of `HierarchyProvider` that creates a hierarchy based on given iModel and\n * a hierarchy definition, which defines each hierarchy level through ECSQL queries.\n *\n * @beta\n */\nexport function createIModelHierarchyProvider(props: IModelHierarchyProviderProps): HierarchyProvider & { dispose: () => void } {\n return new IModelHierarchyProviderImpl(props);\n}\n\ninterface RequestContextProp {\n requestContext: {\n requestId: string;\n };\n}\n\nclass IModelHierarchyProviderImpl implements HierarchyProvider {\n private _imodelAccess: IModelAccess;\n private _imodelChanged: Event<() => void>;\n private _valuesFormatter: IPrimitiveValueFormatter;\n private _sourceHierarchyDefinition: HierarchyDefinition;\n private _activeHierarchyDefinition: HierarchyDefinition;\n private _localizedStrings: IModelHierarchyProviderLocalizedStrings;\n private _queryScheduler: SubscriptionScheduler;\n private _nodesCache?: HierarchyCache<HierarchyCacheEntry>;\n private _unsubscribe?: () => void;\n private _dispose = new Subject<void>();\n\n public constructor(props: IModelHierarchyProviderProps) {\n this._imodelAccess = props.imodelAccess;\n this._imodelChanged = props.imodelChanged ?? new BeEvent();\n this._activeHierarchyDefinition = this._sourceHierarchyDefinition = props.hierarchyDefinition;\n this._valuesFormatter = props?.formatter ?? createDefaultValueFormatter();\n this._localizedStrings = { other: \"Other\", unspecified: \"Not specified\", ...props?.localizedStrings };\n this._queryScheduler = new SubscriptionScheduler(props.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY);\n this.setHierarchyFilter(props.filtering);\n\n const queryCacheSize = props.queryCacheSize ?? DEFAULT_QUERY_CACHE_SIZE;\n if (queryCacheSize !== 0) {\n this._nodesCache = new HierarchyCache({\n // we divide the size by 2, because each variation also counts as a query that we cache\n size: Math.ceil(queryCacheSize / 2),\n variationsCount: 1,\n });\n this._unsubscribe = props.imodelChanged?.addListener(() => {\n this.invalidateHierarchyCache(\"Data source changed\");\n this._dispose.next();\n });\n }\n }\n\n public dispose() {\n this._dispose.next();\n this._unsubscribe?.();\n }\n\n public get hierarchyChanged() {\n return this._imodelChanged;\n }\n\n private invalidateHierarchyCache(reason?: string) {\n doLog({\n category: `${LOGGING_NAMESPACE}.Events`,\n message: /* istanbul ignore next */ () => (reason ? `${reason}: clear hierarchy cache` : `Clear hierarchy cache`),\n });\n this._nodesCache?.clear();\n }\n\n /**\n * Sets `HierarchyProvider` values formatter that formats nodes' labels. If provided `undefined`, then defaults to the\n * result of `createDefaultValueFormatter` called with default parameters.\n */\n public setFormatter(formatter: IPrimitiveValueFormatter | undefined) {\n this._valuesFormatter = formatter ?? createDefaultValueFormatter();\n }\n\n public setHierarchyFilter(props: IModelHierarchyProviderProps[\"filtering\"]) {\n if (!props) {\n if (this._sourceHierarchyDefinition !== this._activeHierarchyDefinition) {\n this._activeHierarchyDefinition = this._sourceHierarchyDefinition;\n this.invalidateHierarchyCache(\"Hierarchy filter reset\");\n }\n return;\n }\n this._activeHierarchyDefinition = new FilteringHierarchyDefinition({\n imodelAccess: this._imodelAccess,\n source: this._sourceHierarchyDefinition,\n nodeIdentifierPaths: props.paths,\n });\n this.invalidateHierarchyCache(\"Hierarchy filter set\");\n this._dispose.next();\n }\n\n private onGroupingNodeCreated(groupingNode: ProcessedGroupingHierarchyNode, props: GetHierarchyNodesProps) {\n this._nodesCache?.set({ ...props, parentNode: groupingNode }, { observable: from(groupingNode.children), processingStatus: \"pre-processed\" });\n }\n\n private createHierarchyLevelDefinitionsObservable(props: DefineHierarchyLevelProps & RequestContextProp): Observable<HierarchyNodesDefinition> {\n const { requestContext, ...defineHierarchyLevelProps } = props;\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* istanbul ignore next */ () =>\n `[${requestContext.requestId}] Requesting hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n return from(\n defer(async () => {\n let parentNode = props.parentNode;\n if (parentNode && HierarchyNode.isGeneric(parentNode) && parentNode.key.source && parentNode.key.source !== this._imodelAccess.imodelKey) {\n return [];\n }\n if (parentNode && HierarchyNode.isInstancesNode(parentNode)) {\n parentNode = {\n ...parentNode,\n key: {\n ...parentNode.key,\n instanceKeys: parentNode.key.instanceKeys.filter((ik) => !ik.imodelKey || ik.imodelKey === this._imodelAccess.imodelKey),\n },\n };\n assert(HierarchyNodeKey.isInstances(parentNode.key));\n if (parentNode.key.instanceKeys.length === 0) {\n return [];\n }\n }\n return this._activeHierarchyDefinition.defineHierarchyLevel({ ...defineHierarchyLevelProps, parentNode });\n }),\n ).pipe(\n mergeAll(),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* istanbul ignore next */ () =>\n `[${requestContext.requestId}] Received all hierarchy level definitions for ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n );\n }\n\n private createSourceNodesObservable(\n props: DefineHierarchyLevelProps & { hierarchyLevelSizeLimit?: number | \"unbounded\"; filteredInstanceKeys?: InstanceKey[] } & RequestContextProp,\n ): SourceNodesObservable {\n // pipe definitions to nodes and put \"share replay\" on it\n return this.createHierarchyLevelDefinitionsObservable(props).pipe(\n mergeMap((def): ObservableInput<SourceHierarchyNode> => {\n if (HierarchyNodesDefinition.isGenericNode(def)) {\n return of({ ...def.node, key: { type: \"generic\", id: def.node.key, source: this._imodelAccess.imodelKey } });\n }\n return this._queryScheduler.scheduleSubscription(\n of(def.query).pipe(\n map((query) => filterQueryByInstanceKeys(query, props.filteredInstanceKeys)),\n mergeMap((query) =>\n readNodes({ queryExecutor: this._imodelAccess, query, limit: props.hierarchyLevelSizeLimit, parser: this._activeHierarchyDefinition.parseNode }),\n ),\n map((node) => ({\n ...node,\n key: { ...node.key, instanceKeys: node.key.instanceKeys.map((key) => ({ ...key, imodelKey: this._imodelAccess.imodelKey })) },\n })),\n ),\n );\n }),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* istanbul ignore next */ () =>\n `[${props.requestContext.requestId}] Read all child nodes ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n shareReplayWithErrors(),\n );\n }\n\n private createPreProcessedNodesObservable(\n queryNodesObservable: SourceNodesObservable,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<ProcessedHierarchyNode> {\n return queryNodesObservable.pipe(\n // we're going to be mutating the nodes, but don't want to mutate the original one, so just clone it here once\n map((node) => ({ ...node })),\n // set parent node keys on the source node\n map((node) => Object.assign(node, { parentKeys: createParentNodeKeysList(props.parentNode) })),\n // format `ConcatenatedValue` labels into string labels\n mergeMap(async (node) => applyLabelsFormatting(node, this._valuesFormatter)),\n // we have `ProcessedHierarchyNode` from here\n preProcessNodes(this._activeHierarchyDefinition),\n // process hiding\n createHideIfNoChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes),\n createHideNodesInHierarchyOperator(\n // note: for child nodes created because of hidden parent, we want to use parent's request props (instance filter, limit)\n (n) => this.getChildNodesObservables({ ...props, parentNode: n }).processedNodes,\n false,\n ),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* istanbul ignore next */ () =>\n `[${props.requestContext.requestId}] Finished pre-processing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n );\n }\n\n private createProcessedNodesObservable(\n preprocessedNodesObservable: Observable<ProcessedHierarchyNode>,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<ProcessedHierarchyNode> {\n return preprocessedNodesObservable.pipe(\n createGroupingOperator(this._imodelAccess, props.parentNode, this._valuesFormatter, this._localizedStrings, (gn) =>\n this.onGroupingNodeCreated(gn, props),\n ),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* istanbul ignore next */ () =>\n `[${props.requestContext.requestId}] Finished grouping child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n );\n }\n\n private createFinalizedNodesObservable(\n processedNodesObservable: Observable<ProcessedHierarchyNode>,\n props: GetHierarchyNodesProps & RequestContextProp,\n ): Observable<HierarchyNode> {\n return processedNodesObservable.pipe(\n createDetermineChildrenOperator((n) => this.getChildNodesObservables({ parentNode: n, requestContext: props.requestContext }).hasNodes),\n postProcessNodes(this._activeHierarchyDefinition),\n sortNodesByLabelOperator,\n map((n): HierarchyNode => {\n if (\"processingParams\" in n) {\n delete n.processingParams;\n }\n return Object.assign(n, {\n children: hasChildren(n),\n });\n }),\n takeUntil(this._dispose),\n finalize(() =>\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n message: /* istanbul ignore next */ () =>\n `[${props.requestContext.requestId}] Finished finalizing child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n }),\n ),\n );\n }\n\n private createHasNodesObservable(\n preprocessedNodesObservable: Observable<ProcessedHierarchyNode>,\n possiblyKnownChildrenObservable: SourceNodesObservable | undefined,\n props: RequestContextProp,\n ): Observable<boolean> {\n const loggingCategory = `${LOGGING_NAMESPACE_INTERNAL}.HasNodes`;\n return concat((possiblyKnownChildrenObservable ?? EMPTY).pipe(filter((n) => hasChildren(n))), preprocessedNodesObservable).pipe(\n log({\n category: loggingCategory,\n message: /* istanbul ignore next */ (n) => `[${props.requestContext.requestId}] Node before mapping to 'true': ${createNodeIdentifierForLogging(n)}`,\n }),\n take(1),\n map(() => true),\n defaultIfEmpty(false),\n catchError((e: Error) => {\n doLog({\n category: loggingCategory,\n message: /* istanbul ignore next */ () => `[${props.requestContext.requestId}] Error while determining children: ${e.message}`,\n });\n if (e instanceof RowsLimitExceededError) {\n return of(true);\n }\n throw e;\n }),\n log({ category: loggingCategory, message: /* istanbul ignore next */ (r) => `[${props.requestContext.requestId}] Result: ${r}` }),\n );\n }\n\n private getCachedObservableEntry(props: GetHierarchyNodesProps & RequestContextProp): HierarchyCacheEntry {\n const loggingCategory = `${LOGGING_NAMESPACE}.QueryResultsCache`;\n const { parentNode, ...restProps } = props;\n const cached = props.ignoreCache || !this._nodesCache ? undefined : this._nodesCache.get(props);\n if (cached) {\n // istanbul ignore next\n doLog({\n category: loggingCategory,\n message: /* istanbul ignore next */ () =>\n `[${props.requestContext.requestId}] Found query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,\n });\n return cached;\n }\n\n // if we don't find an entry for a grouping node, we load its instances by getting a query and applying\n // a filter based on grouped instance keys\n let filteredInstanceKeys: InstanceKey[] | undefined;\n let parentNonGroupingNode: ParentHierarchyNode<NonGroupingHierarchyNode> | undefined;\n if (parentNode) {\n if (HierarchyNode.isGroupingNode(parentNode)) {\n parentNonGroupingNode = parentNode.nonGroupingAncestor;\n filteredInstanceKeys = parentNode.groupedInstanceKeys;\n } else {\n // not sure why type checker doesn't pick this up\n assert(HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));\n parentNonGroupingNode = parentNode;\n }\n }\n\n const nonGroupingNodeChildrenRequestProps = {\n ...restProps,\n parentNode: parentNonGroupingNode,\n ...(filteredInstanceKeys ? { filteredInstanceKeys } : undefined),\n };\n const value = { observable: this.createSourceNodesObservable(nonGroupingNodeChildrenRequestProps), processingStatus: \"none\" as const };\n this._nodesCache?.set(nonGroupingNodeChildrenRequestProps, value);\n doLog({\n category: loggingCategory,\n message: /* istanbul ignore next */ () =>\n `[${props.requestContext.requestId}] Saved query nodes observable for ${createNodeIdentifierForLogging(parentNode)}`,\n });\n return value;\n }\n\n private getChildNodesObservables(props: GetHierarchyNodesProps & { hierarchyLevelSizeLimit?: number | \"unbounded\" } & RequestContextProp) {\n const entry = this.getCachedObservableEntry(props);\n switch (entry.processingStatus) {\n case \"none\": {\n const pre = this.createPreProcessedNodesObservable(entry.observable, props);\n const post = this.createProcessedNodesObservable(pre, props);\n return {\n processedNodes: post,\n hasNodes: this.createHasNodesObservable(pre, entry.observable, props),\n finalizedNodes: this.createFinalizedNodesObservable(post, props),\n };\n }\n case \"pre-processed\": {\n const post = this.createProcessedNodesObservable(entry.observable, props);\n return {\n processedNodes: post,\n hasNodes: this.createHasNodesObservable(entry.observable, undefined, props),\n finalizedNodes: this.createFinalizedNodesObservable(post, props),\n };\n }\n }\n }\n\n /**\n * Creates and runs a query based on provided props, then processes retrieved nodes and returns them.\n */\n public getNodes(props: GetHierarchyNodesProps): AsyncIterableIterator<HierarchyNode> {\n const requestContext = { requestId: Guid.createValue() };\n const loggingCategory = `${LOGGING_NAMESPACE}.GetNodes`;\n const timer = new StopWatch(undefined, true);\n let error: any;\n let nodesCount = 0;\n doLog({\n category: loggingCategory,\n message: /* istanbul ignore next */ () => `[${requestContext.requestId}] Requesting child nodes for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n return eachValueFrom(\n this.getChildNodesObservables({ ...props, requestContext }).finalizedNodes.pipe(\n tap(() => ++nodesCount),\n catchError((e) => {\n error = e;\n throw e;\n }),\n finalize(() => {\n doLog({\n category: loggingCategory,\n message: /* istanbul ignore next */ () =>\n error\n ? `[${requestContext.requestId}] Error creating child nodes for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`\n : `[${requestContext.requestId}] Returned ${nodesCount} child nodes for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,\n });\n }),\n ),\n );\n }\n\n private getNodeInstanceKeysObs(props: Omit<GetHierarchyNodesProps, \"ignoreCache\"> & RequestContextProp): Observable<InstanceKey> {\n const { parentNode, instanceFilter, hierarchyLevelSizeLimit = \"unbounded\", requestContext } = props;\n if (parentNode && HierarchyNode.isGroupingNode(parentNode)) {\n return from(parentNode.groupedInstanceKeys);\n }\n assert(!parentNode || HierarchyNode.isGeneric(parentNode) || HierarchyNode.isInstancesNode(parentNode));\n\n const hierarchyLevelDefinitions = this.createHierarchyLevelDefinitionsObservable({ parentNode, instanceFilter, requestContext });\n\n // split the definitions based on whether they're for generic nodes or for instance nodes\n const [genericDefs, instanceDefs] = partition(hierarchyLevelDefinitions, HierarchyNodesDefinition.isGenericNode);\n\n // query instance keys and a flag whether they should be hidden\n const instanceKeys = instanceDefs.pipe(\n mergeMap((def) =>\n this._queryScheduler.scheduleSubscription(\n of(def.query).pipe(\n mergeMap(async (query) => {\n const ecsql = `\n SELECT\n ${NodeSelectClauseColumnNames.FullClassName},\n ${NodeSelectClauseColumnNames.ECInstanceId},\n ${NodeSelectClauseColumnNames.HideNodeInHierarchy}\n FROM (\n ${query.ecsql}\n )\n `;\n const reader = this._imodelAccess.createQueryReader({ ...query, ecsql }, { rowFormat: \"Indexes\", limit: hierarchyLevelSizeLimit });\n return from(reader).pipe(\n map((row) => ({\n key: {\n className: normalizeFullClassName(row[0]),\n id: row[1],\n imodelKey: this._imodelAccess.imodelKey,\n } satisfies IModelInstanceKey,\n hide: !!row[2],\n })),\n );\n }),\n mergeAll(),\n ),\n ),\n ),\n );\n // split the instance keys observable based on whether they should be hidden or not\n const [visibleNodeInstanceKeys, hiddenNodeInstanceKeys] = partition(instanceKeys, ({ hide }) => !hide);\n\n // hidden items' handling:\n // - if a generic node is hidden, we'll want to retrieve instance keys of its children, otherwise we don't care about it,\n // - if an instance key is hidden, we want to create a merged node similar to what we do in `createHideNodesInHierarchyOperator`\n const hiddenParentNodes = merge(\n genericDefs.pipe(\n filter((def) => !!def.node.processingParams?.hideInHierarchy),\n map(\n (def): GenericNodeKey => ({\n type: \"generic\",\n id: def.node.key,\n source: this._imodelAccess.imodelKey,\n }),\n ),\n ),\n hiddenNodeInstanceKeys.pipe(\n // first merge all keys by class\n reduceToMergeMapList(\n ({ key }) => key.className,\n ({ key }) => key.id,\n ),\n // then, for each class, create an instance key\n mergeMap((mergedMap): InstancesNodeKey[] =>\n [...mergedMap.entries()].map(([className, ids]) => ({\n type: \"instances\",\n instanceKeys: ids.map((id) => ({ className, id, imodelKey: this._imodelAccess.imodelKey })),\n })),\n ),\n ),\n ).pipe(\n map((key) => ({\n key,\n parentKeys: [],\n label: \"\",\n })),\n );\n\n // merge visible instance keys from this level & the ones we get recursively requesting from deeper levels\n return merge(\n visibleNodeInstanceKeys.pipe(map(({ key }) => key)),\n hiddenParentNodes.pipe(mergeMap((hiddenNode) => this.getNodeInstanceKeysObs({ parentNode: hiddenNode, requestContext }))),\n ).pipe(takeUntil(this._dispose));\n }\n\n /**\n * Creates an iterator for all child hierarchy level instance keys, taking into account any hidden hierarchy levels\n * that there may be under the given parent node.\n */\n public getNodeInstanceKeys(props: Omit<GetHierarchyNodesProps, \"ignoreCache\">): AsyncIterableIterator<InstanceKey> {\n const requestContext = { requestId: Guid.createValue() };\n const loggingCategory = `${LOGGING_NAMESPACE}.GetNodeInstanceKeys`;\n const timer = new StopWatch(undefined, true);\n doLog({\n category: loggingCategory,\n message: /* istanbul ignore next */ () => `[${requestContext.requestId}] Requesting keys for ${createNodeIdentifierForLogging(props.parentNode)}`,\n });\n let error: any;\n let keysCount = 0;\n return eachValueFrom(\n this.getNodeInstanceKeysObs({ ...props, requestContext }).pipe(\n tap(() => ++keysCount),\n catchError((e) => {\n error = e;\n throw e;\n }),\n finalize(() => {\n doLog({\n category: loggingCategory,\n message: /* istanbul ignore next */ () =>\n error\n ? `[${requestContext.requestId}] Error creating node instance keys for ${createNodeIdentifierForLogging(props.parentNode)}: ${error instanceof Error ? error.message : error.toString()}`\n : `[${requestContext.requestId}] Returned ${keysCount} instance keys for ${createNodeIdentifierForLogging(props.parentNode)} in ${timer.currentSeconds.toFixed(2)} s.`,\n });\n }),\n ),\n );\n }\n}\n\ntype SourceHierarchyNode = SourceInstanceHierarchyNode | (Omit<SourceGenericHierarchyNode, \"key\"> & { key: GenericNodeKey });\ntype SourceNodesObservable = Observable<SourceHierarchyNode>;\ntype ProcessedNodesObservable = Observable<ProcessedHierarchyNode>;\ntype HierarchyCacheEntry =\n | { observable: SourceNodesObservable; processingStatus: \"none\" }\n | { observable: ProcessedNodesObservable; processingStatus: \"pre-processed\" };\n\nfunction preProcessNodes(hierarchyFactory: HierarchyDefinition) {\n return hierarchyFactory.preProcessNode\n ? processNodes(hierarchyFactory.preProcessNode.bind(hierarchyFactory))\n : (o: Observable<ProcessedGenericHierarchyNode | ProcessedInstanceHierarchyNode>) => o;\n}\n\nfunction postProcessNodes<ProcessedHierarchyNode>(hierarchyFactory: HierarchyDefinition) {\n return hierarchyFactory.postProcessNode\n ? processNodes(hierarchyFactory.postProcessNode.bind(hierarchyFactory))\n : (o: Observable<ProcessedHierarchyNode>) => o;\n}\n\nfunction processNodes<TNode>(processor: (node: TNode) => Promise<TNode | undefined>) {\n return (nodes: Observable<TNode>) =>\n nodes.pipe(\n mergeMap(processor),\n filter((n): n is TNode => !!n),\n );\n}\n\nasync function applyLabelsFormatting<TNode extends { label: string | ConcatenatedValue }>(\n node: TNode,\n valueFormatter: IPrimitiveValueFormatter,\n): Promise<TNode & { label: string }> {\n return {\n ...node,\n label: await formatConcatenatedValue({\n value: node.label,\n valueFormatter,\n }),\n };\n}\n\nfunction createParentNodeKeysList(parentNode: ParentHierarchyNode | undefined) {\n if (!parentNode) {\n return [];\n }\n return [...parentNode.parentKeys, parentNode.key];\n}\n\nfunction filterQueryByInstanceKeys(query: ECSqlQueryDef, filteredInstanceKeys: InstanceKey[] | undefined): ECSqlQueryDef {\n if (!filteredInstanceKeys || !filteredInstanceKeys.length) {\n return query;\n }\n const MAX_ALLOWED_BINDINGS = 1000;\n // istanbul ignore else\n if (filteredInstanceKeys.length < MAX_ALLOWED_BINDINGS) {\n return {\n ...query,\n ecsql: `\n SELECT *\n FROM (${query.ecsql}) q\n WHERE q.ECInstanceId IN (${filteredInstanceKeys.map(() => \"?\").join(\",\")})\n `,\n bindings: [...(query.bindings ?? []), ...filteredInstanceKeys.map((k): ECSqlBinding => ({ type: \"id\", value: k.id }))],\n };\n }\n // istanbul ignore next\n return {\n ...query,\n ecsql: `\n SELECT *\n FROM (${query.ecsql}) q\n WHERE InVirtualSet(?, q.ECInstanceId)\n `,\n bindings: [...(query.bindings ?? []), { type: \"idset\", value: filteredInstanceKeys.map((k) => k.id) }],\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimitingECSqlQueryExecutor.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/LimitingECSqlQueryExecutor.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EAGxB,MAAM,4BAA4B,CAAC;AAKpC;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,iBAAiB,CACf,KAAK,EAAE,aAAa,EACpB,MAAM,CAAC,EAAE,uBAAuB,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,GAClE,UAAU,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC;CACxD;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,GAAG,WAAW,GAAG,0BAA0B,CA4CjJ"}
@@ -4,9 +4,9 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { Guid, StopWatch } from "@itwin/core-bentley";
6
6
  import { createMainThreadReleaseOnTimePassedHandler, trimWhitespace, } from "@itwin/presentation-shared";
7
- import { RowsLimitExceededError } from "./HierarchyErrors";
8
- import { LOGGING_NAMESPACE as BASE_LOGGING_NAMESPACE, LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE } from "./internal/Common";
9
- import { doLog } from "./internal/LoggingUtils";
7
+ import { RowsLimitExceededError } from "../HierarchyErrors";
8
+ import { LOGGING_NAMESPACE as BASE_LOGGING_NAMESPACE, LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE } from "../internal/Common";
9
+ import { doLog } from "../internal/LoggingUtils";
10
10
  /**
11
11
  * Creates an `LimitingECSqlQueryExecutor` that throws `RowsLimitExceededError` if the query exceeds given amount of rows.
12
12
  * @beta
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimitingECSqlQueryExecutor.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/LimitingECSqlQueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EACL,0CAA0C,EAK1C,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,IAAI,sBAAsB,EAAE,6BAA6B,IAAI,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AACtJ,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAkBjD;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,YAAgC,EAAE,YAAkC;IACnH,OAAO;QACL,KAAK,CAAC,CAAC,iBAAiB,CAAC,KAAoB,EAAE,MAAmE;YAChH,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,IAAI,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,UAAU;YACR,uBAAuB;YACvB,KAAK,CAAC;gBACJ,QAAQ,EAAE,6BAA6B;gBACvC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY,IAAI,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;gBACrF,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,gBAAgB,KAAK,CAAC,cAAc,WAAW,SAAS,QAAQ;aAC3F,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAED,uBAAuB;AACvB,SAAS,qBAAqB,CAAC,KAAoB;IACjD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjF,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,IAAI,eAAe,IAAI,UAAU,CAAC;IAC1C,CAAC;IACD,MAAM,IAAI,YAAY,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;IACxD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,gBAAgB,QAAQ,OAAO,CAAC;IAC5C,CAAC;IACD,MAAM,IAAI,GAAG,CAAC;IACd,OAAO,MAAM,CAAC;AAChB,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 { Guid, StopWatch } from \"@itwin/core-bentley\";\nimport {\n createMainThreadReleaseOnTimePassedHandler,\n ECSqlQueryDef,\n ECSqlQueryExecutor,\n ECSqlQueryReaderOptions,\n ECSqlQueryRow,\n trimWhitespace,\n} from \"@itwin/presentation-shared\";\nimport { RowsLimitExceededError } from \"../HierarchyErrors\";\nimport { LOGGING_NAMESPACE as BASE_LOGGING_NAMESPACE, LOGGING_NAMESPACE_PERFORMANCE as BASE_LOGGING_NAMESPACE_PERFORMANCE } from \"../internal/Common\";\nimport { doLog } from \"../internal/LoggingUtils\";\n\n/**\n * An interface for something that knows how to create a limiting ECSQL query reader.\n * @beta\n */\nexport interface LimitingECSqlQueryExecutor {\n /**\n * Creates a query reader for given query, but makes sure it doesn't return more than the configured\n * limit of rows.\n * @throws `RowsLimitExceededError` when the query returns more than configured limit of rows.\n */\n createQueryReader(\n query: ECSqlQueryDef,\n config?: ECSqlQueryReaderOptions & { limit?: number | \"unbounded\" },\n ): ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]>;\n}\n\n/**\n * Creates an `LimitingECSqlQueryExecutor` that throws `RowsLimitExceededError` if the query exceeds given amount of rows.\n * @beta\n */\nexport function createLimitingECSqlQueryExecutor(baseExecutor: ECSqlQueryExecutor, defaultLimit: number | \"unbounded\"): LimitingECSqlQueryExecutor {\n return {\n async *createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions & { limit?: number | \"unbounded\" }) {\n const { limit: configLimit, ...restConfig } = config ?? {};\n const limit = configLimit ?? defaultLimit;\n const queryLogger = createQueryLogger(query);\n const releaseMainThread = createMainThreadReleaseOnTimePassedHandler();\n\n // handle \"unbounded\" case without a buffer\n const reader = baseExecutor.createQueryReader({ ...query, ecsql: addLimit(query.ecsql, limit) }, restConfig);\n if (limit === \"unbounded\") {\n try {\n for await (const row of reader) {\n await releaseMainThread();\n queryLogger.onStep();\n yield row;\n }\n } finally {\n queryLogger.onComplete();\n }\n return;\n }\n\n // avoid streaming until we know the number of rows is okay\n const buffer: ECSqlQueryRow[] = [];\n try {\n for await (const row of reader) {\n await releaseMainThread();\n queryLogger.onStep();\n buffer.push(row);\n if (buffer.length > limit) {\n throw new RowsLimitExceededError(limit);\n }\n }\n } finally {\n queryLogger.onComplete();\n }\n\n for (const row of buffer) {\n await releaseMainThread();\n yield row;\n }\n },\n };\n}\n\nfunction addLimit(ecsql: string, limit: number | \"unbounded\") {\n if (limit === \"unbounded\") {\n return ecsql;\n }\n return `\n SELECT *\n FROM (${ecsql})\n LIMIT ${limit + 1}\n `;\n}\n\nconst LOGGING_NAMESPACE = `${BASE_LOGGING_NAMESPACE}.Queries`;\nconst LOGGING_NAMESPACE_PERFORMANCE = `${BASE_LOGGING_NAMESPACE_PERFORMANCE}.Queries`;\nfunction createQueryLogger(query: ECSqlQueryDef, firstStepWarningThreshold = 3000, allRowsWarningThreshold = 5000) {\n const queryId = Guid.createValue();\n doLog({\n category: LOGGING_NAMESPACE,\n message: /* istanbul ignore next */ () => `Executing query [${queryId}]: ${createQueryLogMessage(query)}`,\n });\n\n let firstStep = true;\n let rowsCount = 0;\n const timer = new StopWatch(undefined, true);\n return {\n onStep() {\n if (firstStep) {\n // istanbul ignore next\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n severity: timer.current.milliseconds >= firstStepWarningThreshold ? \"warning\" : \"trace\",\n message: () => `[${queryId}] First step took ${timer.currentSeconds} s.`,\n });\n firstStep = false;\n }\n ++rowsCount;\n },\n onComplete() {\n // istanbul ignore next\n doLog({\n category: LOGGING_NAMESPACE_PERFORMANCE,\n severity: timer.current.milliseconds >= allRowsWarningThreshold ? \"warning\" : \"trace\",\n message: () => `[${queryId}] Query took ${timer.currentSeconds} s. for ${rowsCount} rows.`,\n });\n },\n };\n}\n\n// istanbul ignore next\nfunction createQueryLogMessage(query: ECSqlQueryDef): string {\n const ctes = query.ctes?.map((cte) => ` ${trimWhitespace(cte)}`).join(\", \\n\");\n const bindings = query.bindings?.map((b) => JSON.stringify(b.value)).join(\", \");\n let output = \"{\\n\";\n if (ctes) {\n output += ` ctes: [ \\n${ctes} \\n], \\n`;\n }\n output += ` ecsql: ${trimWhitespace(query.ecsql)}, \\n`;\n if (bindings) {\n output += ` bindings: [${bindings}], \\n`;\n }\n output += \"}\";\n return output;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { Id64String } from "@itwin/core-bentley";
2
2
  import { GenericInstanceFilter } from "@itwin/core-common";
3
3
  import { ECClassHierarchyInspector, ECSchemaProvider, IInstanceLabelSelectClauseFactory } from "@itwin/presentation-shared";
4
- import { HierarchyNodeAutoExpandProp } from "./HierarchyNode";
4
+ import { HierarchyNodeAutoExpandProp } from "./IModelHierarchyNode";
5
5
  /**
6
6
  * Column names of the SELECT clause created by `NodeSelectClauseFactory`. Order of the names matches the order of columns
7
7
  * created by the factory.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeSelectQueryFactory.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/NodeSelectQueryFactory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,qBAAqB,EAOtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,yBAAyB,EACzB,gBAAgB,EAGhB,iCAAiC,EAGlC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;;;;GAKG;AACH,oBAAY,2BAA2B;IACrC,kHAAkH;IAClH,aAAa,kBAAkB;IAC/B,6EAA6E;IAC7E,YAAY,iBAAiB;IAC7B,qCAAqC;IACrC,YAAY,iBAAiB;IAC7B;;;;;OAKG;IACH,WAAW,gBAAgB;IAC3B,6FAA6F;IAC7F,gBAAgB,qBAAqB;IACrC,oHAAoH;IACpH,mBAAmB,wBAAwB;IAC3C,mEAAmE;IACnE,QAAQ,aAAa;IACrB,4EAA4E;IAC5E,YAAY,iBAAiB;IAC7B,2EAA2E;IAC3E,UAAU,eAAe;IACzB,2E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