@itwin/presentation-common 4.0.0-dev.8 → 4.0.0-dev.81

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 (441) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/Ruleset.schema.json +15 -0
  3. package/lib/cjs/assets/locales/en/Presentation.json +19 -0
  4. package/lib/cjs/assets/locales/en-PSEUDO/Presentation.json +19 -0
  5. package/lib/cjs/presentation-common/AsyncTasks.d.ts +22 -22
  6. package/lib/cjs/presentation-common/AsyncTasks.js +38 -38
  7. package/lib/cjs/presentation-common/CommonLoggerCategory.d.ts +12 -12
  8. package/lib/cjs/presentation-common/CommonLoggerCategory.js +20 -20
  9. package/lib/cjs/presentation-common/Diagnostics.d.ts +125 -125
  10. package/lib/cjs/presentation-common/Diagnostics.d.ts.map +1 -1
  11. package/lib/cjs/presentation-common/Diagnostics.js +72 -72
  12. package/lib/cjs/presentation-common/EC.d.ts +347 -350
  13. package/lib/cjs/presentation-common/EC.d.ts.map +1 -1
  14. package/lib/cjs/presentation-common/EC.js +290 -290
  15. package/lib/cjs/presentation-common/EC.js.map +1 -1
  16. package/lib/cjs/presentation-common/ElementProperties.d.ts +123 -123
  17. package/lib/cjs/presentation-common/ElementProperties.d.ts.map +1 -1
  18. package/lib/cjs/presentation-common/ElementProperties.js +9 -9
  19. package/lib/cjs/presentation-common/Error.d.ts +47 -45
  20. package/lib/cjs/presentation-common/Error.d.ts.map +1 -1
  21. package/lib/cjs/presentation-common/Error.js +64 -62
  22. package/lib/cjs/presentation-common/Error.js.map +1 -1
  23. package/lib/cjs/presentation-common/InstanceFilterDefinition.d.ts +93 -93
  24. package/lib/cjs/presentation-common/InstanceFilterDefinition.d.ts.map +1 -1
  25. package/lib/cjs/presentation-common/InstanceFilterDefinition.js +9 -9
  26. package/lib/cjs/presentation-common/KeySet.d.ts +146 -146
  27. package/lib/cjs/presentation-common/KeySet.d.ts.map +1 -1
  28. package/lib/cjs/presentation-common/KeySet.js +428 -428
  29. package/lib/cjs/presentation-common/KoqPropertyValueFormatter.d.ts +20 -0
  30. package/lib/cjs/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -0
  31. package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js +156 -0
  32. package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js.map +1 -0
  33. package/lib/cjs/presentation-common/LabelDefinition.d.ts +93 -87
  34. package/lib/cjs/presentation-common/LabelDefinition.d.ts.map +1 -1
  35. package/lib/cjs/presentation-common/LabelDefinition.js +78 -73
  36. package/lib/cjs/presentation-common/LabelDefinition.js.map +1 -1
  37. package/lib/cjs/presentation-common/LocalizationHelper.d.ts +29 -29
  38. package/lib/cjs/presentation-common/LocalizationHelper.d.ts.map +1 -1
  39. package/lib/cjs/presentation-common/LocalizationHelper.js +113 -110
  40. package/lib/cjs/presentation-common/LocalizationHelper.js.map +1 -1
  41. package/lib/cjs/presentation-common/PresentationIpcInterface.d.ts +27 -40
  42. package/lib/cjs/presentation-common/PresentationIpcInterface.d.ts.map +1 -1
  43. package/lib/cjs/presentation-common/PresentationIpcInterface.js +12 -12
  44. package/lib/cjs/presentation-common/PresentationIpcInterface.js.map +1 -1
  45. package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts +279 -261
  46. package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
  47. package/lib/cjs/presentation-common/PresentationManagerOptions.js +23 -23
  48. package/lib/cjs/presentation-common/PresentationManagerOptions.js.map +1 -1
  49. package/lib/cjs/presentation-common/PresentationRpcInterface.d.ts +186 -186
  50. package/lib/cjs/presentation-common/PresentationRpcInterface.d.ts.map +1 -1
  51. package/lib/cjs/presentation-common/PresentationRpcInterface.js +108 -104
  52. package/lib/cjs/presentation-common/PresentationRpcInterface.js.map +1 -1
  53. package/lib/cjs/presentation-common/RegisteredRuleset.d.ts +26 -26
  54. package/lib/cjs/presentation-common/RegisteredRuleset.js +33 -33
  55. package/lib/cjs/presentation-common/RpcRequestsHandler.d.ts +82 -83
  56. package/lib/cjs/presentation-common/RpcRequestsHandler.d.ts.map +1 -1
  57. package/lib/cjs/presentation-common/RpcRequestsHandler.js +166 -171
  58. package/lib/cjs/presentation-common/RpcRequestsHandler.js.map +1 -1
  59. package/lib/cjs/presentation-common/RulesetVariables.d.ts +171 -171
  60. package/lib/cjs/presentation-common/RulesetVariables.d.ts.map +1 -1
  61. package/lib/cjs/presentation-common/RulesetVariables.js +55 -55
  62. package/lib/cjs/presentation-common/RulesetsFactory.d.ts +44 -44
  63. package/lib/cjs/presentation-common/RulesetsFactory.d.ts.map +1 -1
  64. package/lib/cjs/presentation-common/RulesetsFactory.js +223 -223
  65. package/lib/cjs/presentation-common/RulesetsFactory.js.map +1 -1
  66. package/lib/cjs/presentation-common/Update.d.ts +150 -213
  67. package/lib/cjs/presentation-common/Update.d.ts.map +1 -1
  68. package/lib/cjs/presentation-common/Update.js +114 -226
  69. package/lib/cjs/presentation-common/Update.js.map +1 -1
  70. package/lib/cjs/presentation-common/Utils.d.ts +62 -62
  71. package/lib/cjs/presentation-common/Utils.d.ts.map +1 -1
  72. package/lib/cjs/presentation-common/Utils.js +43 -43
  73. package/lib/cjs/presentation-common/content/Category.d.ts +49 -49
  74. package/lib/cjs/presentation-common/content/Category.js +48 -48
  75. package/lib/cjs/presentation-common/content/Content.d.ts +38 -38
  76. package/lib/cjs/presentation-common/content/Content.js +56 -56
  77. package/lib/cjs/presentation-common/content/ContentTraverser.d.ts +271 -271
  78. package/lib/cjs/presentation-common/content/ContentTraverser.js +437 -439
  79. package/lib/cjs/presentation-common/content/ContentTraverser.js.map +1 -1
  80. package/lib/cjs/presentation-common/content/Descriptor.d.ts +328 -328
  81. package/lib/cjs/presentation-common/content/Descriptor.js +191 -193
  82. package/lib/cjs/presentation-common/content/Descriptor.js.map +1 -1
  83. package/lib/cjs/presentation-common/content/DisplayTypes.d.ts +21 -21
  84. package/lib/cjs/presentation-common/content/DisplayTypes.js +29 -29
  85. package/lib/cjs/presentation-common/content/Editor.d.ts +15 -15
  86. package/lib/cjs/presentation-common/content/Editor.js +9 -9
  87. package/lib/cjs/presentation-common/content/Fields.d.ts +298 -301
  88. package/lib/cjs/presentation-common/content/Fields.d.ts.map +1 -1
  89. package/lib/cjs/presentation-common/content/Fields.js +393 -397
  90. package/lib/cjs/presentation-common/content/Fields.js.map +1 -1
  91. package/lib/cjs/presentation-common/content/Item.d.ts +85 -85
  92. package/lib/cjs/presentation-common/content/Item.d.ts.map +1 -1
  93. package/lib/cjs/presentation-common/content/Item.js +84 -84
  94. package/lib/cjs/presentation-common/content/Item.js.map +1 -1
  95. package/lib/cjs/presentation-common/content/Property.d.ts +57 -57
  96. package/lib/cjs/presentation-common/content/Property.d.ts.map +1 -1
  97. package/lib/cjs/presentation-common/content/Property.js +40 -40
  98. package/lib/cjs/presentation-common/content/PropertyValueFormatter.d.ts +29 -0
  99. package/lib/cjs/presentation-common/content/PropertyValueFormatter.d.ts.map +1 -0
  100. package/lib/cjs/presentation-common/content/PropertyValueFormatter.js +139 -0
  101. package/lib/cjs/presentation-common/content/PropertyValueFormatter.js.map +1 -0
  102. package/lib/cjs/presentation-common/content/Renderer.d.ts +11 -11
  103. package/lib/cjs/presentation-common/content/Renderer.js +9 -9
  104. package/lib/cjs/presentation-common/content/TypeDescription.d.ts +72 -72
  105. package/lib/cjs/presentation-common/content/TypeDescription.d.ts.map +1 -1
  106. package/lib/cjs/presentation-common/content/TypeDescription.js +23 -23
  107. package/lib/cjs/presentation-common/content/Value.d.ts +204 -189
  108. package/lib/cjs/presentation-common/content/Value.d.ts.map +1 -1
  109. package/lib/cjs/presentation-common/content/Value.js +281 -273
  110. package/lib/cjs/presentation-common/content/Value.js.map +1 -1
  111. package/lib/cjs/presentation-common/hierarchy/HierarchyLevel.d.ts +37 -37
  112. package/lib/cjs/presentation-common/hierarchy/HierarchyLevel.js +31 -31
  113. package/lib/cjs/presentation-common/hierarchy/Key.d.ts +246 -246
  114. package/lib/cjs/presentation-common/hierarchy/Key.d.ts.map +1 -1
  115. package/lib/cjs/presentation-common/hierarchy/Key.js +121 -121
  116. package/lib/cjs/presentation-common/hierarchy/Key.js.map +1 -1
  117. package/lib/cjs/presentation-common/hierarchy/Node.d.ts +154 -154
  118. package/lib/cjs/presentation-common/hierarchy/Node.d.ts.map +1 -1
  119. package/lib/cjs/presentation-common/hierarchy/Node.js +106 -106
  120. package/lib/cjs/presentation-common/hierarchy/Node.js.map +1 -1
  121. package/lib/cjs/presentation-common/hierarchy/NodePathElement.d.ts +96 -96
  122. package/lib/cjs/presentation-common/hierarchy/NodePathElement.js +122 -122
  123. package/lib/cjs/presentation-common/rules/ClassSpecifications.d.ts +45 -45
  124. package/lib/cjs/presentation-common/rules/ClassSpecifications.js +9 -9
  125. package/lib/cjs/presentation-common/rules/RelatedInstanceSpecification.d.ts +31 -31
  126. package/lib/cjs/presentation-common/rules/RelatedInstanceSpecification.js +9 -9
  127. package/lib/cjs/presentation-common/rules/RelationshipDirection.d.ts +13 -13
  128. package/lib/cjs/presentation-common/rules/RelationshipDirection.js +21 -21
  129. package/lib/cjs/presentation-common/rules/RelationshipPathSpecification.d.ts +56 -56
  130. package/lib/cjs/presentation-common/rules/RelationshipPathSpecification.d.ts.map +1 -1
  131. package/lib/cjs/presentation-common/rules/RelationshipPathSpecification.js +9 -9
  132. package/lib/cjs/presentation-common/rules/Rule.d.ts +76 -76
  133. package/lib/cjs/presentation-common/rules/Rule.js +35 -35
  134. package/lib/cjs/presentation-common/rules/Ruleset.d.ts +65 -65
  135. package/lib/cjs/presentation-common/rules/Ruleset.js +9 -9
  136. package/lib/cjs/presentation-common/rules/SchemasSpecification.d.ts +41 -41
  137. package/lib/cjs/presentation-common/rules/SchemasSpecification.js +9 -9
  138. package/lib/cjs/presentation-common/rules/Variables.d.ts +58 -58
  139. package/lib/cjs/presentation-common/rules/Variables.js +25 -25
  140. package/lib/cjs/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.d.ts +41 -41
  141. package/lib/cjs/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.js +9 -9
  142. package/lib/cjs/presentation-common/rules/content/ContentRelatedInstancesSpecification.d.ts +25 -25
  143. package/lib/cjs/presentation-common/rules/content/ContentRelatedInstancesSpecification.js +9 -9
  144. package/lib/cjs/presentation-common/rules/content/ContentRule.d.ts +30 -30
  145. package/lib/cjs/presentation-common/rules/content/ContentRule.js +9 -9
  146. package/lib/cjs/presentation-common/rules/content/ContentSpecification.d.ts +58 -58
  147. package/lib/cjs/presentation-common/rules/content/ContentSpecification.js +20 -20
  148. package/lib/cjs/presentation-common/rules/content/DefaultPropertyCategoryOverride.d.ts +19 -19
  149. package/lib/cjs/presentation-common/rules/content/DefaultPropertyCategoryOverride.js +9 -9
  150. package/lib/cjs/presentation-common/rules/content/PropertySpecification.d.ts +86 -86
  151. package/lib/cjs/presentation-common/rules/content/PropertySpecification.js +9 -9
  152. package/lib/cjs/presentation-common/rules/content/SelectedNodeInstancesSpecification.d.ts +28 -28
  153. package/lib/cjs/presentation-common/rules/content/SelectedNodeInstancesSpecification.js +9 -9
  154. package/lib/cjs/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.d.ts +25 -25
  155. package/lib/cjs/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.js +9 -9
  156. package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.d.ts +64 -57
  157. package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.d.ts.map +1 -1
  158. package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.js +9 -9
  159. package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.js.map +1 -1
  160. package/lib/cjs/presentation-common/rules/content/modifiers/CustomRendererSpecification.d.ts +17 -17
  161. package/lib/cjs/presentation-common/rules/content/modifiers/CustomRendererSpecification.js +9 -9
  162. package/lib/cjs/presentation-common/rules/content/modifiers/PropertyCategorySpecification.d.ts +107 -107
  163. package/lib/cjs/presentation-common/rules/content/modifiers/PropertyCategorySpecification.d.ts.map +1 -1
  164. package/lib/cjs/presentation-common/rules/content/modifiers/PropertyCategorySpecification.js +9 -9
  165. package/lib/cjs/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.d.ts +108 -108
  166. package/lib/cjs/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.js +21 -21
  167. package/lib/cjs/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.d.ts +96 -96
  168. package/lib/cjs/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.js +43 -43
  169. package/lib/cjs/presentation-common/rules/customization/CheckBoxRule.d.ts +44 -44
  170. package/lib/cjs/presentation-common/rules/customization/CheckBoxRule.js +9 -9
  171. package/lib/cjs/presentation-common/rules/customization/CustomizationRule.d.ts +36 -36
  172. package/lib/cjs/presentation-common/rules/customization/CustomizationRule.js +9 -9
  173. package/lib/cjs/presentation-common/rules/customization/ExtendedDataRule.d.ts +27 -27
  174. package/lib/cjs/presentation-common/rules/customization/ExtendedDataRule.js +9 -9
  175. package/lib/cjs/presentation-common/rules/customization/GroupingRule.d.ts +207 -207
  176. package/lib/cjs/presentation-common/rules/customization/GroupingRule.js +51 -51
  177. package/lib/cjs/presentation-common/rules/customization/ImageIdOverride.d.ts +29 -29
  178. package/lib/cjs/presentation-common/rules/customization/ImageIdOverride.js +9 -9
  179. package/lib/cjs/presentation-common/rules/customization/InstanceLabelOverride.d.ts +158 -158
  180. package/lib/cjs/presentation-common/rules/customization/InstanceLabelOverride.d.ts.map +1 -1
  181. package/lib/cjs/presentation-common/rules/customization/InstanceLabelOverride.js +25 -25
  182. package/lib/cjs/presentation-common/rules/customization/LabelOverride.d.ts +40 -40
  183. package/lib/cjs/presentation-common/rules/customization/LabelOverride.js +9 -9
  184. package/lib/cjs/presentation-common/rules/customization/SortingRule.d.ts +58 -58
  185. package/lib/cjs/presentation-common/rules/customization/SortingRule.d.ts.map +1 -1
  186. package/lib/cjs/presentation-common/rules/customization/SortingRule.js +9 -9
  187. package/lib/cjs/presentation-common/rules/customization/StyleOverride.d.ts +48 -48
  188. package/lib/cjs/presentation-common/rules/customization/StyleOverride.js +9 -9
  189. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeRule.d.ts +14 -14
  190. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeRule.js +9 -9
  191. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.d.ts +98 -98
  192. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.d.ts.map +1 -1
  193. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.js +21 -21
  194. package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.d.ts +31 -31
  195. package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.js +9 -9
  196. package/lib/cjs/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.d.ts +79 -79
  197. package/lib/cjs/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js +19 -19
  198. package/lib/cjs/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.d.ts +39 -39
  199. package/lib/cjs/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js +9 -9
  200. package/lib/cjs/presentation-common/rules/hierarchy/NavigationRule.d.ts +50 -50
  201. package/lib/cjs/presentation-common/rules/hierarchy/NavigationRule.d.ts.map +1 -1
  202. package/lib/cjs/presentation-common/rules/hierarchy/NavigationRule.js +9 -9
  203. package/lib/cjs/presentation-common/rules/hierarchy/NodeArtifactsRule.d.ts +27 -27
  204. package/lib/cjs/presentation-common/rules/hierarchy/NodeArtifactsRule.js +9 -9
  205. package/lib/cjs/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.d.ts +27 -27
  206. package/lib/cjs/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js +9 -9
  207. package/lib/cjs/presentation-common/rules/hierarchy/RootNodeRule.d.ts +16 -16
  208. package/lib/cjs/presentation-common/rules/hierarchy/RootNodeRule.js +9 -9
  209. package/lib/cjs/presentation-common/rules/hierarchy/SubCondition.d.ts +35 -35
  210. package/lib/cjs/presentation-common/rules/hierarchy/SubCondition.js +9 -9
  211. package/lib/cjs/presentation-common/selection/SelectionScope.d.ts +38 -38
  212. package/lib/cjs/presentation-common/selection/SelectionScope.d.ts.map +1 -1
  213. package/lib/cjs/presentation-common/selection/SelectionScope.js +9 -9
  214. package/lib/cjs/presentation-common.d.ts +114 -112
  215. package/lib/cjs/presentation-common.d.ts.map +1 -1
  216. package/lib/cjs/presentation-common.js +134 -128
  217. package/lib/cjs/presentation-common.js.map +1 -1
  218. package/lib/esm/presentation-common/AsyncTasks.d.ts +22 -22
  219. package/lib/esm/presentation-common/AsyncTasks.js +34 -34
  220. package/lib/esm/presentation-common/CommonLoggerCategory.d.ts +12 -12
  221. package/lib/esm/presentation-common/CommonLoggerCategory.js +17 -17
  222. package/lib/esm/presentation-common/Diagnostics.d.ts +125 -125
  223. package/lib/esm/presentation-common/Diagnostics.d.ts.map +1 -1
  224. package/lib/esm/presentation-common/Diagnostics.js +67 -67
  225. package/lib/esm/presentation-common/EC.d.ts +347 -350
  226. package/lib/esm/presentation-common/EC.d.ts.map +1 -1
  227. package/lib/esm/presentation-common/EC.js +287 -287
  228. package/lib/esm/presentation-common/EC.js.map +1 -1
  229. package/lib/esm/presentation-common/ElementProperties.d.ts +123 -123
  230. package/lib/esm/presentation-common/ElementProperties.d.ts.map +1 -1
  231. package/lib/esm/presentation-common/ElementProperties.js +8 -8
  232. package/lib/esm/presentation-common/Error.d.ts +47 -45
  233. package/lib/esm/presentation-common/Error.d.ts.map +1 -1
  234. package/lib/esm/presentation-common/Error.js +60 -58
  235. package/lib/esm/presentation-common/Error.js.map +1 -1
  236. package/lib/esm/presentation-common/InstanceFilterDefinition.d.ts +93 -93
  237. package/lib/esm/presentation-common/InstanceFilterDefinition.d.ts.map +1 -1
  238. package/lib/esm/presentation-common/InstanceFilterDefinition.js +8 -8
  239. package/lib/esm/presentation-common/KeySet.d.ts +146 -146
  240. package/lib/esm/presentation-common/KeySet.d.ts.map +1 -1
  241. package/lib/esm/presentation-common/KeySet.js +424 -424
  242. package/lib/esm/presentation-common/KoqPropertyValueFormatter.d.ts +20 -0
  243. package/lib/esm/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -0
  244. package/lib/esm/presentation-common/KoqPropertyValueFormatter.js +152 -0
  245. package/lib/esm/presentation-common/KoqPropertyValueFormatter.js.map +1 -0
  246. package/lib/esm/presentation-common/LabelDefinition.d.ts +93 -87
  247. package/lib/esm/presentation-common/LabelDefinition.d.ts.map +1 -1
  248. package/lib/esm/presentation-common/LabelDefinition.js +75 -70
  249. package/lib/esm/presentation-common/LabelDefinition.js.map +1 -1
  250. package/lib/esm/presentation-common/LocalizationHelper.d.ts +29 -29
  251. package/lib/esm/presentation-common/LocalizationHelper.d.ts.map +1 -1
  252. package/lib/esm/presentation-common/LocalizationHelper.js +109 -106
  253. package/lib/esm/presentation-common/LocalizationHelper.js.map +1 -1
  254. package/lib/esm/presentation-common/PresentationIpcInterface.d.ts +27 -40
  255. package/lib/esm/presentation-common/PresentationIpcInterface.d.ts.map +1 -1
  256. package/lib/esm/presentation-common/PresentationIpcInterface.js +9 -9
  257. package/lib/esm/presentation-common/PresentationIpcInterface.js.map +1 -1
  258. package/lib/esm/presentation-common/PresentationManagerOptions.d.ts +279 -261
  259. package/lib/esm/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
  260. package/lib/esm/presentation-common/PresentationManagerOptions.js +18 -18
  261. package/lib/esm/presentation-common/PresentationManagerOptions.js.map +1 -1
  262. package/lib/esm/presentation-common/PresentationRpcInterface.d.ts +186 -186
  263. package/lib/esm/presentation-common/PresentationRpcInterface.d.ts.map +1 -1
  264. package/lib/esm/presentation-common/PresentationRpcInterface.js +105 -100
  265. package/lib/esm/presentation-common/PresentationRpcInterface.js.map +1 -1
  266. package/lib/esm/presentation-common/RegisteredRuleset.d.ts +26 -26
  267. package/lib/esm/presentation-common/RegisteredRuleset.js +29 -29
  268. package/lib/esm/presentation-common/RpcRequestsHandler.d.ts +82 -83
  269. package/lib/esm/presentation-common/RpcRequestsHandler.d.ts.map +1 -1
  270. package/lib/esm/presentation-common/RpcRequestsHandler.js +162 -167
  271. package/lib/esm/presentation-common/RpcRequestsHandler.js.map +1 -1
  272. package/lib/esm/presentation-common/RulesetVariables.d.ts +171 -171
  273. package/lib/esm/presentation-common/RulesetVariables.d.ts.map +1 -1
  274. package/lib/esm/presentation-common/RulesetVariables.js +52 -52
  275. package/lib/esm/presentation-common/RulesetsFactory.d.ts +44 -44
  276. package/lib/esm/presentation-common/RulesetsFactory.d.ts.map +1 -1
  277. package/lib/esm/presentation-common/RulesetsFactory.js +219 -219
  278. package/lib/esm/presentation-common/RulesetsFactory.js.map +1 -1
  279. package/lib/esm/presentation-common/Update.d.ts +150 -213
  280. package/lib/esm/presentation-common/Update.d.ts.map +1 -1
  281. package/lib/esm/presentation-common/Update.js +111 -223
  282. package/lib/esm/presentation-common/Update.js.map +1 -1
  283. package/lib/esm/presentation-common/Utils.d.ts +62 -62
  284. package/lib/esm/presentation-common/Utils.d.ts.map +1 -1
  285. package/lib/esm/presentation-common/Utils.js +39 -39
  286. package/lib/esm/presentation-common/content/Category.d.ts +49 -49
  287. package/lib/esm/presentation-common/content/Category.js +45 -45
  288. package/lib/esm/presentation-common/content/Content.d.ts +38 -38
  289. package/lib/esm/presentation-common/content/Content.js +52 -52
  290. package/lib/esm/presentation-common/content/ContentTraverser.d.ts +271 -271
  291. package/lib/esm/presentation-common/content/ContentTraverser.js +427 -429
  292. package/lib/esm/presentation-common/content/ContentTraverser.js.map +1 -1
  293. package/lib/esm/presentation-common/content/Descriptor.d.ts +328 -328
  294. package/lib/esm/presentation-common/content/Descriptor.js +187 -189
  295. package/lib/esm/presentation-common/content/Descriptor.js.map +1 -1
  296. package/lib/esm/presentation-common/content/DisplayTypes.d.ts +21 -21
  297. package/lib/esm/presentation-common/content/DisplayTypes.js +26 -26
  298. package/lib/esm/presentation-common/content/Editor.d.ts +15 -15
  299. package/lib/esm/presentation-common/content/Editor.js +8 -8
  300. package/lib/esm/presentation-common/content/Fields.d.ts +298 -301
  301. package/lib/esm/presentation-common/content/Fields.d.ts.map +1 -1
  302. package/lib/esm/presentation-common/content/Fields.js +386 -390
  303. package/lib/esm/presentation-common/content/Fields.js.map +1 -1
  304. package/lib/esm/presentation-common/content/Item.d.ts +85 -85
  305. package/lib/esm/presentation-common/content/Item.d.ts.map +1 -1
  306. package/lib/esm/presentation-common/content/Item.js +80 -80
  307. package/lib/esm/presentation-common/content/Item.js.map +1 -1
  308. package/lib/esm/presentation-common/content/Property.d.ts +57 -57
  309. package/lib/esm/presentation-common/content/Property.d.ts.map +1 -1
  310. package/lib/esm/presentation-common/content/Property.js +37 -37
  311. package/lib/esm/presentation-common/content/PropertyValueFormatter.d.ts +29 -0
  312. package/lib/esm/presentation-common/content/PropertyValueFormatter.d.ts.map +1 -0
  313. package/lib/esm/presentation-common/content/PropertyValueFormatter.js +134 -0
  314. package/lib/esm/presentation-common/content/PropertyValueFormatter.js.map +1 -0
  315. package/lib/esm/presentation-common/content/Renderer.d.ts +11 -11
  316. package/lib/esm/presentation-common/content/Renderer.js +8 -8
  317. package/lib/esm/presentation-common/content/TypeDescription.d.ts +72 -72
  318. package/lib/esm/presentation-common/content/TypeDescription.d.ts.map +1 -1
  319. package/lib/esm/presentation-common/content/TypeDescription.js +20 -20
  320. package/lib/esm/presentation-common/content/Value.d.ts +204 -189
  321. package/lib/esm/presentation-common/content/Value.d.ts.map +1 -1
  322. package/lib/esm/presentation-common/content/Value.js +278 -270
  323. package/lib/esm/presentation-common/content/Value.js.map +1 -1
  324. package/lib/esm/presentation-common/hierarchy/HierarchyLevel.d.ts +37 -37
  325. package/lib/esm/presentation-common/hierarchy/HierarchyLevel.js +28 -28
  326. package/lib/esm/presentation-common/hierarchy/Key.d.ts +246 -246
  327. package/lib/esm/presentation-common/hierarchy/Key.d.ts.map +1 -1
  328. package/lib/esm/presentation-common/hierarchy/Key.js +118 -118
  329. package/lib/esm/presentation-common/hierarchy/Key.js.map +1 -1
  330. package/lib/esm/presentation-common/hierarchy/Node.d.ts +154 -154
  331. package/lib/esm/presentation-common/hierarchy/Node.d.ts.map +1 -1
  332. package/lib/esm/presentation-common/hierarchy/Node.js +103 -103
  333. package/lib/esm/presentation-common/hierarchy/Node.js.map +1 -1
  334. package/lib/esm/presentation-common/hierarchy/NodePathElement.d.ts +96 -96
  335. package/lib/esm/presentation-common/hierarchy/NodePathElement.js +119 -119
  336. package/lib/esm/presentation-common/rules/ClassSpecifications.d.ts +45 -45
  337. package/lib/esm/presentation-common/rules/ClassSpecifications.js +8 -8
  338. package/lib/esm/presentation-common/rules/RelatedInstanceSpecification.d.ts +31 -31
  339. package/lib/esm/presentation-common/rules/RelatedInstanceSpecification.js +8 -8
  340. package/lib/esm/presentation-common/rules/RelationshipDirection.d.ts +13 -13
  341. package/lib/esm/presentation-common/rules/RelationshipDirection.js +18 -18
  342. package/lib/esm/presentation-common/rules/RelationshipPathSpecification.d.ts +56 -56
  343. package/lib/esm/presentation-common/rules/RelationshipPathSpecification.d.ts.map +1 -1
  344. package/lib/esm/presentation-common/rules/RelationshipPathSpecification.js +8 -8
  345. package/lib/esm/presentation-common/rules/Rule.d.ts +76 -76
  346. package/lib/esm/presentation-common/rules/Rule.js +32 -32
  347. package/lib/esm/presentation-common/rules/Ruleset.d.ts +65 -65
  348. package/lib/esm/presentation-common/rules/Ruleset.js +8 -8
  349. package/lib/esm/presentation-common/rules/SchemasSpecification.d.ts +41 -41
  350. package/lib/esm/presentation-common/rules/SchemasSpecification.js +8 -8
  351. package/lib/esm/presentation-common/rules/Variables.d.ts +58 -58
  352. package/lib/esm/presentation-common/rules/Variables.js +22 -22
  353. package/lib/esm/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.d.ts +41 -41
  354. package/lib/esm/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.js +8 -8
  355. package/lib/esm/presentation-common/rules/content/ContentRelatedInstancesSpecification.d.ts +25 -25
  356. package/lib/esm/presentation-common/rules/content/ContentRelatedInstancesSpecification.js +8 -8
  357. package/lib/esm/presentation-common/rules/content/ContentRule.d.ts +30 -30
  358. package/lib/esm/presentation-common/rules/content/ContentRule.js +8 -8
  359. package/lib/esm/presentation-common/rules/content/ContentSpecification.d.ts +58 -58
  360. package/lib/esm/presentation-common/rules/content/ContentSpecification.js +17 -17
  361. package/lib/esm/presentation-common/rules/content/DefaultPropertyCategoryOverride.d.ts +19 -19
  362. package/lib/esm/presentation-common/rules/content/DefaultPropertyCategoryOverride.js +8 -8
  363. package/lib/esm/presentation-common/rules/content/PropertySpecification.d.ts +86 -86
  364. package/lib/esm/presentation-common/rules/content/PropertySpecification.js +8 -8
  365. package/lib/esm/presentation-common/rules/content/SelectedNodeInstancesSpecification.d.ts +28 -28
  366. package/lib/esm/presentation-common/rules/content/SelectedNodeInstancesSpecification.js +8 -8
  367. package/lib/esm/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.d.ts +25 -25
  368. package/lib/esm/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.js +8 -8
  369. package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.d.ts +64 -57
  370. package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.d.ts.map +1 -1
  371. package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.js +8 -8
  372. package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.js.map +1 -1
  373. package/lib/esm/presentation-common/rules/content/modifiers/CustomRendererSpecification.d.ts +17 -17
  374. package/lib/esm/presentation-common/rules/content/modifiers/CustomRendererSpecification.js +8 -8
  375. package/lib/esm/presentation-common/rules/content/modifiers/PropertyCategorySpecification.d.ts +107 -107
  376. package/lib/esm/presentation-common/rules/content/modifiers/PropertyCategorySpecification.d.ts.map +1 -1
  377. package/lib/esm/presentation-common/rules/content/modifiers/PropertyCategorySpecification.js +8 -8
  378. package/lib/esm/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.d.ts +108 -108
  379. package/lib/esm/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.js +18 -18
  380. package/lib/esm/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.d.ts +96 -96
  381. package/lib/esm/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.js +40 -40
  382. package/lib/esm/presentation-common/rules/customization/CheckBoxRule.d.ts +44 -44
  383. package/lib/esm/presentation-common/rules/customization/CheckBoxRule.js +8 -8
  384. package/lib/esm/presentation-common/rules/customization/CustomizationRule.d.ts +36 -36
  385. package/lib/esm/presentation-common/rules/customization/CustomizationRule.js +8 -8
  386. package/lib/esm/presentation-common/rules/customization/ExtendedDataRule.d.ts +27 -27
  387. package/lib/esm/presentation-common/rules/customization/ExtendedDataRule.js +8 -8
  388. package/lib/esm/presentation-common/rules/customization/GroupingRule.d.ts +207 -207
  389. package/lib/esm/presentation-common/rules/customization/GroupingRule.js +48 -48
  390. package/lib/esm/presentation-common/rules/customization/ImageIdOverride.d.ts +29 -29
  391. package/lib/esm/presentation-common/rules/customization/ImageIdOverride.js +8 -8
  392. package/lib/esm/presentation-common/rules/customization/InstanceLabelOverride.d.ts +158 -158
  393. package/lib/esm/presentation-common/rules/customization/InstanceLabelOverride.d.ts.map +1 -1
  394. package/lib/esm/presentation-common/rules/customization/InstanceLabelOverride.js +22 -22
  395. package/lib/esm/presentation-common/rules/customization/LabelOverride.d.ts +40 -40
  396. package/lib/esm/presentation-common/rules/customization/LabelOverride.js +8 -8
  397. package/lib/esm/presentation-common/rules/customization/SortingRule.d.ts +58 -58
  398. package/lib/esm/presentation-common/rules/customization/SortingRule.d.ts.map +1 -1
  399. package/lib/esm/presentation-common/rules/customization/SortingRule.js +8 -8
  400. package/lib/esm/presentation-common/rules/customization/StyleOverride.d.ts +48 -48
  401. package/lib/esm/presentation-common/rules/customization/StyleOverride.js +8 -8
  402. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeRule.d.ts +14 -14
  403. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeRule.js +8 -8
  404. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.d.ts +98 -98
  405. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.d.ts.map +1 -1
  406. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.js +18 -18
  407. package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.d.ts +31 -31
  408. package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.js +8 -8
  409. package/lib/esm/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.d.ts +79 -79
  410. package/lib/esm/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js +16 -16
  411. package/lib/esm/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.d.ts +39 -39
  412. package/lib/esm/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js +8 -8
  413. package/lib/esm/presentation-common/rules/hierarchy/NavigationRule.d.ts +50 -50
  414. package/lib/esm/presentation-common/rules/hierarchy/NavigationRule.d.ts.map +1 -1
  415. package/lib/esm/presentation-common/rules/hierarchy/NavigationRule.js +8 -8
  416. package/lib/esm/presentation-common/rules/hierarchy/NodeArtifactsRule.d.ts +27 -27
  417. package/lib/esm/presentation-common/rules/hierarchy/NodeArtifactsRule.js +8 -8
  418. package/lib/esm/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.d.ts +27 -27
  419. package/lib/esm/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js +8 -8
  420. package/lib/esm/presentation-common/rules/hierarchy/RootNodeRule.d.ts +16 -16
  421. package/lib/esm/presentation-common/rules/hierarchy/RootNodeRule.js +8 -8
  422. package/lib/esm/presentation-common/rules/hierarchy/SubCondition.d.ts +35 -35
  423. package/lib/esm/presentation-common/rules/hierarchy/SubCondition.js +8 -8
  424. package/lib/esm/presentation-common/selection/SelectionScope.d.ts +38 -38
  425. package/lib/esm/presentation-common/selection/SelectionScope.d.ts.map +1 -1
  426. package/lib/esm/presentation-common/selection/SelectionScope.js +8 -8
  427. package/lib/esm/presentation-common.d.ts +114 -112
  428. package/lib/esm/presentation-common.d.ts.map +1 -1
  429. package/lib/esm/presentation-common.js +118 -116
  430. package/lib/esm/presentation-common.js.map +1 -1
  431. package/lib/public/locales/en/Presentation.json +19 -0
  432. package/package.json +17 -15
  433. package/lib/cjs/assets/locales/en/BisCore.json +0 -18
  434. package/lib/cjs/assets/locales/en/ECPresentation.json +0 -9
  435. package/lib/cjs/assets/locales/en/RulesEngine.json +0 -6
  436. package/lib/cjs/assets/locales/en-PSEUDO/BisCore.json +0 -18
  437. package/lib/cjs/assets/locales/en-PSEUDO/ECPresentation.json +0 -9
  438. package/lib/cjs/assets/locales/en-PSEUDO/RulesEngine.json +0 -6
  439. package/lib/public/locales/en/BisCore.json +0 -18
  440. package/lib/public/locales/en/ECPresentation.json +0 -9
  441. package/lib/public/locales/en/RulesEngine.json +0 -6
@@ -1,168 +1,163 @@
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
- /** @packageDocumentation
6
- * @module RPC
7
- */
8
- import { Guid, Logger } from "@itwin/core-bentley";
9
- import { RpcManager } from "@itwin/core-common";
10
- import { PresentationCommonLoggerCategory } from "./CommonLoggerCategory";
11
- import { PresentationError, PresentationStatus } from "./Error";
12
- import { PresentationRpcInterface, } from "./PresentationRpcInterface";
13
- /**
14
- * RPC requests handler that wraps [[PresentationRpcInterface]] and
15
- * adds handling for cases when backend needs to be synced with client
16
- * state.
17
- *
18
- * @internal
19
- */
20
- export class RpcRequestsHandler {
21
- constructor(props) {
22
- this.maxRequestRepeatCount = 5;
23
- this.clientId = (props && props.clientId) ? props.clientId : Guid.createValue();
24
- }
25
- dispose() {
26
- }
27
- // eslint-disable-next-line @typescript-eslint/naming-convention
28
- get rpcClient() { return RpcManager.getClientForInterface(PresentationRpcInterface); }
29
- async requestRepeatedly(func, diagnosticsHandler, repeatCount = 1) {
30
- let diagnostics;
31
- let error;
32
- let shouldRepeat = false;
33
- try {
34
- const response = await func();
35
- diagnostics = response.diagnostics;
36
- if (response.statusCode === PresentationStatus.Success)
37
- return response.result;
38
- if (response.statusCode === PresentationStatus.BackendTimeout && repeatCount < this.maxRequestRepeatCount)
39
- shouldRepeat = true;
40
- else
41
- error = new PresentationError(response.statusCode, response.errorMessage);
42
- }
43
- catch (e) {
44
- error = e;
45
- if (repeatCount < this.maxRequestRepeatCount)
46
- shouldRepeat = true;
47
- }
48
- finally {
49
- diagnosticsHandler && diagnostics && diagnosticsHandler(diagnostics);
50
- }
51
- if (shouldRepeat) {
52
- ++repeatCount;
53
- return this.requestRepeatedly(func, diagnosticsHandler, repeatCount);
54
- }
55
- throw error;
56
- }
57
- /**
58
- * Send the request to backend.
59
- *
60
- * If the backend responds with [[PresentationStatus.BackendTimeout]] or there's an RPC-related error,
61
- * the request is repeated up to `this._maxRequestRepeatCount` times. If we fail to get a valid success or error
62
- * response from the backend, throw the last encountered error.
63
- *
64
- * @internal
65
- */
66
- async request(func, options, ...additionalOptions) {
67
- const { imodel, diagnostics, ...optionsNoIModel } = options;
68
- const { handler: diagnosticsHandler, ...diagnosticsOptions } = diagnostics !== null && diagnostics !== void 0 ? diagnostics : {};
69
- if (isOptionsWithRuleset(optionsNoIModel))
70
- optionsNoIModel.rulesetOrId = cleanupRuleset(optionsNoIModel.rulesetOrId);
71
- const rpcOptions = {
72
- ...optionsNoIModel,
73
- clientId: this.clientId,
74
- };
75
- if (diagnostics)
76
- rpcOptions.diagnostics = diagnosticsOptions;
77
- const doRequest = async () => func(imodel, rpcOptions, ...additionalOptions);
78
- return this.requestRepeatedly(doRequest, diagnosticsHandler);
79
- }
80
- async getNodesCount(options) {
81
- return this.request(this.rpcClient.getNodesCount.bind(this.rpcClient), options);
82
- }
83
- // eslint-disable-next-line deprecation/deprecation
84
- async getPagedNodes(options) {
85
- // eslint-disable-next-line deprecation/deprecation
86
- return this.request(this.rpcClient.getPagedNodes.bind(this.rpcClient), options);
87
- }
88
- async getNodesDescriptor(options) {
89
- const response = await this.request(this.rpcClient.getNodesDescriptor.bind(this.rpcClient), options);
90
- if (typeof response === "string")
91
- return JSON.parse(response);
92
- return response;
93
- }
94
- // eslint-disable-next-line deprecation/deprecation
95
- async getNodePaths(options) {
96
- // eslint-disable-next-line deprecation/deprecation
97
- return this.request(this.rpcClient.getNodePaths.bind(this.rpcClient), options);
98
- }
99
- // eslint-disable-next-line deprecation/deprecation
100
- async getFilteredNodePaths(options) {
101
- // eslint-disable-next-line deprecation/deprecation
102
- return this.request(this.rpcClient.getFilteredNodePaths.bind(this.rpcClient), options);
103
- }
104
- async getContentSources(options) {
105
- return this.request(this.rpcClient.getContentSources.bind(this.rpcClient), options);
106
- }
107
- async getContentDescriptor(options) {
108
- return this.request(this.rpcClient.getContentDescriptor.bind(this.rpcClient), options);
109
- }
110
- async getContentSetSize(options) {
111
- return this.request(this.rpcClient.getContentSetSize.bind(this.rpcClient), options);
112
- }
113
- async getPagedContent(options) {
114
- return this.request(this.rpcClient.getPagedContent.bind(this.rpcClient), options);
115
- }
116
- async getPagedContentSet(options) {
117
- return this.request(this.rpcClient.getPagedContentSet.bind(this.rpcClient), options);
118
- }
119
- // eslint-disable-next-line deprecation/deprecation
120
- async getPagedDistinctValues(options) {
121
- // eslint-disable-next-line deprecation/deprecation
122
- return this.request(this.rpcClient.getPagedDistinctValues.bind(this.rpcClient), options);
123
- }
124
- async getElementProperties(options) {
125
- return this.request(this.rpcClient.getElementProperties.bind(this.rpcClient), options);
126
- }
127
- async getContentInstanceKeys(options) {
128
- return this.request(this.rpcClient.getContentInstanceKeys.bind(this.rpcClient), options);
129
- }
130
- async getDisplayLabelDefinition(options) {
131
- return this.request(this.rpcClient.getDisplayLabelDefinition.bind(this.rpcClient), options);
132
- }
133
- async getPagedDisplayLabelDefinitions(options) {
134
- return this.request(this.rpcClient.getPagedDisplayLabelDefinitions.bind(this.rpcClient), options);
135
- }
136
- async getSelectionScopes(options) {
137
- return this.request(this.rpcClient.getSelectionScopes.bind(this.rpcClient), options);
138
- }
139
- async computeSelection(options) {
140
- return this.request(
141
- // eslint-disable-next-line deprecation/deprecation
142
- this.rpcClient.computeSelection.bind(this.rpcClient), options);
143
- }
144
- }
145
- function isOptionsWithRuleset(options) {
146
- return (typeof options.rulesetOrId === "object");
147
- }
148
- const RULESET_SUPPORTED_PROPERTIES_OBJ = {
149
- id: true,
150
- rules: true,
151
- version: true,
152
- requiredSchemas: true,
153
- supplementationInfo: true,
154
- vars: true,
155
- };
156
- function cleanupRuleset(ruleset) {
157
- const cleanedUpRuleset = { ...ruleset };
158
- for (const propertyKey of Object.keys(cleanedUpRuleset)) {
159
- if (!RULESET_SUPPORTED_PROPERTIES_OBJ.hasOwnProperty(propertyKey)) {
160
- if (propertyKey === "$schema")
161
- delete cleanedUpRuleset[propertyKey];
162
- else
163
- Logger.logWarning(PresentationCommonLoggerCategory.Package, `Provided ruleset contains unrecognized attribute '${propertyKey}'. It either doesn't exist or may be no longer supported.`);
164
- }
165
- }
166
- return cleanedUpRuleset;
167
- }
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
+ /** @packageDocumentation
6
+ * @module RPC
7
+ */
8
+ import { BeDuration, BeTimePoint, Guid, Logger } from "@itwin/core-bentley";
9
+ import { RpcManager } from "@itwin/core-common";
10
+ import { PresentationCommonLoggerCategory } from "./CommonLoggerCategory";
11
+ import { PresentationError, PresentationStatus } from "./Error";
12
+ import { PresentationRpcInterface, } from "./PresentationRpcInterface";
13
+ /**
14
+ * Default timeout for how long we're going to wait for RPC request to be fulfilled before throwing
15
+ * a timeout error.
16
+ */
17
+ const DEFAULT_REQUEST_TIMEOUT = 10 * 60 * 1000; // 10 minutes
18
+ /**
19
+ * RPC requests handler that wraps [[PresentationRpcInterface]] and
20
+ * adds handling for cases when backend needs to be synced with client
21
+ * state.
22
+ *
23
+ * @internal
24
+ */
25
+ export class RpcRequestsHandler {
26
+ constructor(props) {
27
+ this.clientId = props?.clientId ?? Guid.createValue();
28
+ this.timeout = props?.timeout ?? DEFAULT_REQUEST_TIMEOUT;
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/naming-convention
31
+ get rpcClient() { return RpcManager.getClientForInterface(PresentationRpcInterface); }
32
+ async requestWithTimeout(func, diagnosticsHandler) {
33
+ const start = BeTimePoint.now();
34
+ const timeout = BeDuration.fromMilliseconds(this.timeout);
35
+ let diagnostics;
36
+ while (start.plus(timeout).isInFuture) {
37
+ try {
38
+ const response = await func();
39
+ diagnostics = response.diagnostics;
40
+ switch (response.statusCode) {
41
+ case PresentationStatus.Success: return response.result;
42
+ case PresentationStatus.BackendTimeout: break;
43
+ default: throw new PresentationError(response.statusCode, response.errorMessage);
44
+ }
45
+ }
46
+ finally {
47
+ diagnosticsHandler && diagnostics && diagnosticsHandler(diagnostics);
48
+ }
49
+ }
50
+ throw new PresentationError(PresentationStatus.BackendTimeout);
51
+ }
52
+ /**
53
+ * Send the request to backend.
54
+ *
55
+ * If the backend responds with [[PresentationStatus.BackendTimeout]], the request is repeated until we hit `timeout` or get
56
+ * a response. If the response is other than [[PresentationStatus.BackendTimeout]] or [[PresentationStatus.Success]], a [[PresentationError]]
57
+ * is thrown with the details from the response.
58
+ */
59
+ async request(func, options, ...additionalOptions) {
60
+ const { imodel, diagnostics, ...optionsNoIModel } = options;
61
+ const { handler: diagnosticsHandler, ...diagnosticsOptions } = diagnostics ?? {};
62
+ if (isOptionsWithRuleset(optionsNoIModel)) {
63
+ optionsNoIModel.rulesetOrId = cleanupRuleset(optionsNoIModel.rulesetOrId);
64
+ }
65
+ const rpcOptions = {
66
+ ...optionsNoIModel,
67
+ clientId: this.clientId,
68
+ };
69
+ if (diagnostics) {
70
+ rpcOptions.diagnostics = diagnosticsOptions;
71
+ }
72
+ const doRequest = async () => func(imodel, rpcOptions, ...additionalOptions);
73
+ return this.requestWithTimeout(doRequest, diagnosticsHandler);
74
+ }
75
+ async getNodesCount(options) {
76
+ return this.request(this.rpcClient.getNodesCount.bind(this.rpcClient), options);
77
+ }
78
+ // eslint-disable-next-line deprecation/deprecation
79
+ async getPagedNodes(options) {
80
+ // eslint-disable-next-line deprecation/deprecation
81
+ return this.request(this.rpcClient.getPagedNodes.bind(this.rpcClient), options);
82
+ }
83
+ async getNodesDescriptor(options) {
84
+ const response = await this.request(this.rpcClient.getNodesDescriptor.bind(this.rpcClient), options);
85
+ if (typeof response === "string")
86
+ return JSON.parse(response);
87
+ return response;
88
+ }
89
+ // eslint-disable-next-line deprecation/deprecation
90
+ async getNodePaths(options) {
91
+ // eslint-disable-next-line deprecation/deprecation
92
+ return this.request(this.rpcClient.getNodePaths.bind(this.rpcClient), options);
93
+ }
94
+ // eslint-disable-next-line deprecation/deprecation
95
+ async getFilteredNodePaths(options) {
96
+ // eslint-disable-next-line deprecation/deprecation
97
+ return this.request(this.rpcClient.getFilteredNodePaths.bind(this.rpcClient), options);
98
+ }
99
+ async getContentSources(options) {
100
+ return this.request(this.rpcClient.getContentSources.bind(this.rpcClient), options);
101
+ }
102
+ async getContentDescriptor(options) {
103
+ return this.request(this.rpcClient.getContentDescriptor.bind(this.rpcClient), options);
104
+ }
105
+ async getContentSetSize(options) {
106
+ return this.request(this.rpcClient.getContentSetSize.bind(this.rpcClient), options);
107
+ }
108
+ async getPagedContent(options) {
109
+ return this.request(this.rpcClient.getPagedContent.bind(this.rpcClient), options);
110
+ }
111
+ async getPagedContentSet(options) {
112
+ return this.request(this.rpcClient.getPagedContentSet.bind(this.rpcClient), options);
113
+ }
114
+ // eslint-disable-next-line deprecation/deprecation
115
+ async getPagedDistinctValues(options) {
116
+ // eslint-disable-next-line deprecation/deprecation
117
+ return this.request(this.rpcClient.getPagedDistinctValues.bind(this.rpcClient), options);
118
+ }
119
+ async getElementProperties(options) {
120
+ return this.request(this.rpcClient.getElementProperties.bind(this.rpcClient), options);
121
+ }
122
+ async getContentInstanceKeys(options) {
123
+ return this.request(this.rpcClient.getContentInstanceKeys.bind(this.rpcClient), options);
124
+ }
125
+ async getDisplayLabelDefinition(options) {
126
+ return this.request(this.rpcClient.getDisplayLabelDefinition.bind(this.rpcClient), options);
127
+ }
128
+ async getPagedDisplayLabelDefinitions(options) {
129
+ return this.request(this.rpcClient.getPagedDisplayLabelDefinitions.bind(this.rpcClient), options);
130
+ }
131
+ async getSelectionScopes(options) {
132
+ return this.request(this.rpcClient.getSelectionScopes.bind(this.rpcClient), options);
133
+ }
134
+ async computeSelection(options) {
135
+ return this.request(
136
+ // eslint-disable-next-line deprecation/deprecation
137
+ this.rpcClient.computeSelection.bind(this.rpcClient), options);
138
+ }
139
+ }
140
+ function isOptionsWithRuleset(options) {
141
+ return (typeof options.rulesetOrId === "object");
142
+ }
143
+ const RULESET_SUPPORTED_PROPERTIES_OBJ = {
144
+ id: true,
145
+ rules: true,
146
+ version: true,
147
+ requiredSchemas: true,
148
+ supplementationInfo: true,
149
+ vars: true,
150
+ };
151
+ function cleanupRuleset(ruleset) {
152
+ const cleanedUpRuleset = { ...ruleset };
153
+ for (const propertyKey of Object.keys(cleanedUpRuleset)) {
154
+ if (!RULESET_SUPPORTED_PROPERTIES_OBJ.hasOwnProperty(propertyKey)) {
155
+ if (propertyKey === "$schema")
156
+ delete cleanedUpRuleset[propertyKey];
157
+ else
158
+ Logger.logWarning(PresentationCommonLoggerCategory.Package, `Provided ruleset contains unrecognized attribute '${propertyKey}'. It either doesn't exist or may be no longer supported.`);
159
+ }
160
+ }
161
+ return cleanedUpRuleset;
162
+ }
168
163
  //# sourceMappingURL=RpcRequestsHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RpcRequestsHandler.js","sourceRoot":"","sources":["../../../src/pres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;IACrB,mBAAmB,EAAE,IAAI;IACzB,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,SAAS,cAAc,CAAC,OAAgB;IACtC,MAAM,gBAAgB,GAAY,EAAE,GAAG,OAAO,EAAE,CAAC;IAEjD,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE;QACvD,IAAI,CAAC,gCAAgC,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;YACjE,IAAI,WAAW,KAAK,SAAS;gBAC3B,OAAQ,gBAAwB,CAAC,WAAW,CAAC,CAAC;;gBAE9C,MAAM,CAAC,UAAU,CAAC,gCAAgC,CAAC,OAAO,EAAE,qDAAqD,WAAW,2DAA2D,CAAC,CAAC;SAC5L;KACF;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RPC\r\n */\r\n\r\nimport { Guid, IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps, RpcManager } from \"@itwin/core-common\";\r\nimport { PresentationCommonLoggerCategory } from \"./CommonLoggerCategory\";\r\nimport { DescriptorJSON, DescriptorOverrides } from \"./content/Descriptor\";\r\nimport { ItemJSON } from \"./content/Item\";\r\nimport { DisplayValueGroupJSON } from \"./content/Value\";\r\nimport { ClientDiagnostics, ClientDiagnosticsAttribute, ClientDiagnosticsHandler } from \"./Diagnostics\";\r\nimport { InstanceKey } from \"./EC\";\r\nimport { ElementProperties } from \"./ElementProperties\";\r\nimport { PresentationError, PresentationStatus } from \"./Error\";\r\nimport { NodeKey } from \"./hierarchy/Key\";\r\nimport { NodeJSON } from \"./hierarchy/Node\";\r\nimport { NodePathElementJSON } from \"./hierarchy/NodePathElement\";\r\nimport { KeySetJSON } from \"./KeySet\";\r\nimport { LabelDefinition } from \"./LabelDefinition\";\r\nimport {\r\n ComputeSelectionRequestOptions, ContentDescriptorRequestOptions, ContentInstanceKeysRequestOptions, ContentRequestOptions,\r\n ContentSourcesRequestOptions, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DistinctValuesRequestOptions,\r\n FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions,\r\n Paged, RequestOptions, RequestOptionsWithRuleset, SelectionScopeRequestOptions, SingleElementPropertiesRequestOptions,\r\n} from \"./PresentationManagerOptions\";\r\nimport {\r\n ContentSourcesRpcResult, PresentationRpcInterface, PresentationRpcRequestOptions, PresentationRpcResponse,\r\n} from \"./PresentationRpcInterface\";\r\nimport { Ruleset } from \"./rules/Ruleset\";\r\nimport { RulesetVariableJSON } from \"./RulesetVariables\";\r\nimport { SelectionScope } from \"./selection/SelectionScope\";\r\nimport { PagedResponse } from \"./Utils\";\r\n\r\n/**\r\n * Configuration parameters for [[RpcRequestsHandler]].\r\n *\r\n * @internal\r\n */\r\nexport interface RpcRequestsHandlerProps {\r\n /**\r\n * Optional ID used to identify client that requests data. If not specified,\r\n * the handler creates a unique GUID as a client id.\r\n * @internal\r\n */\r\n clientId?: string;\r\n}\r\n\r\n/**\r\n * RPC requests handler that wraps [[PresentationRpcInterface]] and\r\n * adds handling for cases when backend needs to be synced with client\r\n * state.\r\n *\r\n * @internal\r\n */\r\nexport class RpcRequestsHandler implements IDisposable {\r\n public readonly maxRequestRepeatCount: number = 5;\r\n\r\n /** ID that identifies this handler as a client */\r\n public readonly clientId: string;\r\n\r\n public constructor(props?: RpcRequestsHandlerProps) {\r\n this.clientId = (props && props.clientId) ? props.clientId : Guid.createValue();\r\n }\r\n\r\n public dispose() {\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private get rpcClient(): PresentationRpcInterface { return RpcManager.getClientForInterface(PresentationRpcInterface); }\r\n\r\n private async requestRepeatedly<TResult>(func: () => PresentationRpcResponse<TResult>, diagnosticsHandler?: ClientDiagnosticsHandler, repeatCount: number = 1): Promise<TResult> {\r\n let diagnostics: ClientDiagnostics | undefined;\r\n let error: unknown | undefined;\r\n let shouldRepeat = false;\r\n try {\r\n const response = await func();\r\n diagnostics = response.diagnostics;\r\n\r\n if (response.statusCode === PresentationStatus.Success)\r\n return response.result!;\r\n\r\n if (response.statusCode === PresentationStatus.BackendTimeout && repeatCount < this.maxRequestRepeatCount)\r\n shouldRepeat = true;\r\n else\r\n error = new PresentationError(response.statusCode, response.errorMessage);\r\n\r\n } catch (e) {\r\n error = e;\r\n if (repeatCount < this.maxRequestRepeatCount)\r\n shouldRepeat = true;\r\n\r\n } finally {\r\n diagnosticsHandler && diagnostics && diagnosticsHandler(diagnostics);\r\n }\r\n\r\n if (shouldRepeat) {\r\n ++repeatCount;\r\n return this.requestRepeatedly(func, diagnosticsHandler, repeatCount);\r\n }\r\n\r\n throw error;\r\n }\r\n\r\n /**\r\n * Send the request to backend.\r\n *\r\n * If the backend responds with [[PresentationStatus.BackendTimeout]] or there's an RPC-related error,\r\n * the request is repeated up to `this._maxRequestRepeatCount` times. If we fail to get a valid success or error\r\n * response from the backend, throw the last encountered error.\r\n *\r\n * @internal\r\n */\r\n public async request<TResult, TOptions extends (RequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute), TArg = any>(\r\n func: (token: IModelRpcProps, options: PresentationRpcRequestOptions<TOptions>, ...args: TArg[]) => PresentationRpcResponse<TResult>,\r\n options: TOptions,\r\n ...additionalOptions: TArg[]\r\n ): Promise<TResult> {\r\n const { imodel, diagnostics, ...optionsNoIModel } = options;\r\n const { handler: diagnosticsHandler, ...diagnosticsOptions } = diagnostics ?? {};\r\n if (isOptionsWithRuleset(optionsNoIModel))\r\n optionsNoIModel.rulesetOrId = cleanupRuleset(optionsNoIModel.rulesetOrId);\r\n const rpcOptions: PresentationRpcRequestOptions<TOptions> = {\r\n ...optionsNoIModel,\r\n clientId: this.clientId,\r\n };\r\n if (diagnostics)\r\n rpcOptions.diagnostics = diagnosticsOptions;\r\n const doRequest = async () => func(imodel, rpcOptions, ...additionalOptions);\r\n return this.requestRepeatedly(doRequest, diagnosticsHandler);\r\n }\r\n\r\n public async getNodesCount(options: HierarchyRequestOptions<IModelRpcProps, NodeKey, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<number> {\r\n return this.request<number, typeof options>(\r\n this.rpcClient.getNodesCount.bind(this.rpcClient), options);\r\n }\r\n // eslint-disable-next-line deprecation/deprecation\r\n public async getPagedNodes(options: Paged<HierarchyRequestOptions<IModelRpcProps, NodeKey, RulesetVariableJSON>> & ClientDiagnosticsAttribute): Promise<PagedResponse<NodeJSON>> {\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this.request<PagedResponse<NodeJSON>, typeof options>(\r\n this.rpcClient.getPagedNodes.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getNodesDescriptor(options: HierarchyLevelDescriptorRequestOptions<IModelRpcProps, NodeKey, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<DescriptorJSON | undefined> {\r\n const response = await this.request<string | DescriptorJSON | undefined, typeof options>(\r\n this.rpcClient.getNodesDescriptor.bind(this.rpcClient), options);\r\n if (typeof response === \"string\")\r\n return JSON.parse(response);\r\n return response;\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public async getNodePaths(options: FilterByInstancePathsHierarchyRequestOptions<IModelRpcProps, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<NodePathElementJSON[]> {\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this.request<NodePathElementJSON[], typeof options>(\r\n this.rpcClient.getNodePaths.bind(this.rpcClient), options);\r\n }\r\n // eslint-disable-next-line deprecation/deprecation\r\n public async getFilteredNodePaths(options: FilterByTextHierarchyRequestOptions<IModelRpcProps, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<NodePathElementJSON[]> {\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this.request<NodePathElementJSON[], typeof options>(\r\n this.rpcClient.getFilteredNodePaths.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getContentSources(options: ContentSourcesRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<ContentSourcesRpcResult> {\r\n return this.request<ContentSourcesRpcResult, typeof options>(\r\n this.rpcClient.getContentSources.bind(this.rpcClient), options);\r\n }\r\n public async getContentDescriptor(options: ContentDescriptorRequestOptions<IModelRpcProps, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<DescriptorJSON | undefined> {\r\n return this.request<DescriptorJSON | undefined, typeof options>(\r\n this.rpcClient.getContentDescriptor.bind(this.rpcClient), options);\r\n }\r\n public async getContentSetSize(options: ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<number> {\r\n return this.request<number, typeof options>(\r\n this.rpcClient.getContentSetSize.bind(this.rpcClient), options);\r\n }\r\n public async getPagedContent(options: Paged<ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute>) {\r\n return this.request<{ descriptor: DescriptorJSON, contentSet: PagedResponse<ItemJSON> } | undefined, typeof options>(\r\n this.rpcClient.getPagedContent.bind(this.rpcClient), options);\r\n }\r\n public async getPagedContentSet(options: Paged<ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute>) {\r\n return this.request<PagedResponse<ItemJSON>, typeof options>(\r\n this.rpcClient.getPagedContentSet.bind(this.rpcClient), options);\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public async getPagedDistinctValues(options: DistinctValuesRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<PagedResponse<DisplayValueGroupJSON>> {\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this.request<PagedResponse<DisplayValueGroupJSON>, typeof options>(\r\n this.rpcClient.getPagedDistinctValues.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getElementProperties(options: SingleElementPropertiesRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<ElementProperties | undefined> {\r\n return this.request<ElementProperties | undefined, typeof options>(\r\n this.rpcClient.getElementProperties.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getContentInstanceKeys(options: ContentInstanceKeysRequestOptions<IModelRpcProps, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<{ total: number, items: KeySetJSON }> {\r\n return this.request<{ total: number, items: KeySetJSON }, typeof options>(\r\n this.rpcClient.getContentInstanceKeys.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getDisplayLabelDefinition(options: DisplayLabelRequestOptions<IModelRpcProps, InstanceKey> & ClientDiagnosticsAttribute): Promise<LabelDefinition> {\r\n return this.request<LabelDefinition, typeof options>(\r\n this.rpcClient.getDisplayLabelDefinition.bind(this.rpcClient), options);\r\n }\r\n public async getPagedDisplayLabelDefinitions(options: DisplayLabelsRequestOptions<IModelRpcProps, InstanceKey> & ClientDiagnosticsAttribute): Promise<PagedResponse<LabelDefinition>> {\r\n return this.request<PagedResponse<LabelDefinition>, typeof options>(\r\n this.rpcClient.getPagedDisplayLabelDefinitions.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getSelectionScopes(options: SelectionScopeRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<SelectionScope[]> {\r\n return this.request<SelectionScope[], typeof options>(\r\n this.rpcClient.getSelectionScopes.bind(this.rpcClient), options);\r\n }\r\n public async computeSelection(options: ComputeSelectionRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<KeySetJSON> {\r\n return this.request<KeySetJSON, typeof options>(\r\n // eslint-disable-next-line deprecation/deprecation\r\n this.rpcClient.computeSelection.bind(this.rpcClient), options);\r\n }\r\n}\r\n\r\nfunction isOptionsWithRuleset(options: Object): options is { rulesetOrId: Ruleset } {\r\n return (typeof (options as RequestOptionsWithRuleset<any, any>).rulesetOrId === \"object\");\r\n}\r\n\r\ntype RulesetWithRequiredProperties = {\r\n [key in keyof Ruleset]-?: true;\r\n};\r\n\r\nconst RULESET_SUPPORTED_PROPERTIES_OBJ: RulesetWithRequiredProperties = {\r\n id: true,\r\n rules: true,\r\n version: true,\r\n requiredSchemas: true,\r\n supplementationInfo: true,\r\n vars: true,\r\n};\r\n\r\nfunction cleanupRuleset(ruleset: Ruleset): Ruleset {\r\n const cleanedUpRuleset: Ruleset = { ...ruleset };\r\n\r\n for (const propertyKey of Object.keys(cleanedUpRuleset)) {\r\n if (!RULESET_SUPPORTED_PROPERTIES_OBJ.hasOwnProperty(propertyKey)) {\r\n if (propertyKey === \"$schema\")\r\n delete (cleanedUpRuleset as any)[propertyKey];\r\n else\r\n Logger.logWarning(PresentationCommonLoggerCategory.Package, `Provided ruleset contains unrecognized attribute '${propertyKey}'. It either doesn't exist or may be no longer supported.`);\r\n }\r\n }\r\n\r\n return cleanedUpRuleset;\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcRequestsHandler.js","sourceRoot":"","sources":["../../../src/presentation-common/RpcRequestsHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAkB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAO1E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAYhE,OAAO,EACoB,wBAAwB,GAClD,MAAM,4BAA4B,CAAC;AAMpC;;;GAGG;AACH,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAmB7D;;;;;;GAMG;AACH,MAAM,OAAO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CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,OAAkF;QAChH,OAAO,IAAI,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IACM,KAAK,CAAC,gBAAgB,CAAC,OAAoF;QAChH,OAAO,IAAI,CAAC,OAAO;QACjB,mDAAmD;QACnD,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;CACF;AAED,SAAS,oBAAoB,CAAC,OAAe;IAC3C,OAAO,CAAC,OAAQ,OAA+C,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC;AAC5F,CAAC;AAMD,MAAM,gCAAgC,GAAkC;IACtE,EAAE,EAAE,IAAI;IACR,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,IAAI;IACrB,mBAAmB,EAAE,IAAI;IACzB,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,SAAS,cAAc,CAAC,OAAgB;IACtC,MAAM,gBAAgB,GAAY,EAAE,GAAG,OAAO,EAAE,CAAC;IAEjD,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE;QACvD,IAAI,CAAC,gCAAgC,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;YACjE,IAAI,WAAW,KAAK,SAAS;gBAC3B,OAAQ,gBAAwB,CAAC,WAAW,CAAC,CAAC;;gBAE9C,MAAM,CAAC,UAAU,CAAC,gCAAgC,CAAC,OAAO,EAAE,qDAAqD,WAAW,2DAA2D,CAAC,CAAC;SAC5L;KACF;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RPC\r\n */\r\n\r\nimport { BeDuration, BeTimePoint, Guid, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps, RpcManager } from \"@itwin/core-common\";\r\nimport { PresentationCommonLoggerCategory } from \"./CommonLoggerCategory\";\r\nimport { DescriptorJSON, DescriptorOverrides } from \"./content/Descriptor\";\r\nimport { ItemJSON } from \"./content/Item\";\r\nimport { DisplayValueGroupJSON } from \"./content/Value\";\r\nimport { ClientDiagnostics, ClientDiagnosticsAttribute, ClientDiagnosticsHandler } from \"./Diagnostics\";\r\nimport { InstanceKey } from \"./EC\";\r\nimport { ElementProperties } from \"./ElementProperties\";\r\nimport { PresentationError, PresentationStatus } from \"./Error\";\r\nimport { NodeKey } from \"./hierarchy/Key\";\r\nimport { NodeJSON } from \"./hierarchy/Node\";\r\nimport { NodePathElementJSON } from \"./hierarchy/NodePathElement\";\r\nimport { KeySetJSON } from \"./KeySet\";\r\nimport { LabelDefinition } from \"./LabelDefinition\";\r\nimport {\r\n ComputeSelectionRequestOptions, ContentDescriptorRequestOptions, ContentInstanceKeysRequestOptions, ContentRequestOptions,\r\n ContentSourcesRequestOptions, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DistinctValuesRequestOptions,\r\n FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions,\r\n Paged, RequestOptions, RequestOptionsWithRuleset, SelectionScopeRequestOptions, SingleElementPropertiesRequestOptions,\r\n} from \"./PresentationManagerOptions\";\r\nimport {\r\n ContentSourcesRpcResult, PresentationRpcInterface, PresentationRpcRequestOptions, PresentationRpcResponse,\r\n} from \"./PresentationRpcInterface\";\r\nimport { Ruleset } from \"./rules/Ruleset\";\r\nimport { RulesetVariableJSON } from \"./RulesetVariables\";\r\nimport { SelectionScope } from \"./selection/SelectionScope\";\r\nimport { PagedResponse } from \"./Utils\";\r\n\r\n/**\r\n * Default timeout for how long we're going to wait for RPC request to be fulfilled before throwing\r\n * a timeout error.\r\n */\r\nconst DEFAULT_REQUEST_TIMEOUT = 10 * 60 * 1000; // 10 minutes\r\n\r\n/**\r\n * Configuration parameters for [[RpcRequestsHandler]].\r\n *\r\n * @internal\r\n */\r\nexport interface RpcRequestsHandlerProps {\r\n /**\r\n * Optional ID used to identify client that requests data. If not specified,\r\n * the handler creates a unique GUID as a client id.\r\n * @internal\r\n */\r\n clientId?: string;\r\n\r\n /** @internal */\r\n timeout?: number;\r\n}\r\n\r\n/**\r\n * RPC requests handler that wraps [[PresentationRpcInterface]] and\r\n * adds handling for cases when backend needs to be synced with client\r\n * state.\r\n *\r\n * @internal\r\n */\r\nexport class RpcRequestsHandler {\r\n /** Timeout for how long the handler going to wait for RPC request to be fulfilled before throwing a timeout error. */\r\n public readonly timeout: number;\r\n\r\n /** ID that identifies this handler as a client */\r\n public readonly clientId: string;\r\n\r\n public constructor(props?: RpcRequestsHandlerProps) {\r\n this.clientId = props?.clientId ?? Guid.createValue();\r\n this.timeout = props?.timeout ?? DEFAULT_REQUEST_TIMEOUT;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private get rpcClient(): PresentationRpcInterface { return RpcManager.getClientForInterface(PresentationRpcInterface); }\r\n\r\n private async requestWithTimeout<TResult>(func: () => PresentationRpcResponse<TResult>, diagnosticsHandler?: ClientDiagnosticsHandler): Promise<TResult> {\r\n const start = BeTimePoint.now();\r\n const timeout = BeDuration.fromMilliseconds(this.timeout);\r\n let diagnostics: ClientDiagnostics | undefined;\r\n while (start.plus(timeout).isInFuture) {\r\n try {\r\n const response = await func();\r\n diagnostics = response.diagnostics;\r\n switch (response.statusCode) {\r\n case PresentationStatus.Success: return response.result!;\r\n case PresentationStatus.BackendTimeout: break;\r\n default: throw new PresentationError(response.statusCode, response.errorMessage);\r\n }\r\n } finally {\r\n diagnosticsHandler && diagnostics && diagnosticsHandler(diagnostics);\r\n }\r\n }\r\n throw new PresentationError(PresentationStatus.BackendTimeout);\r\n }\r\n\r\n /**\r\n * Send the request to backend.\r\n *\r\n * If the backend responds with [[PresentationStatus.BackendTimeout]], the request is repeated until we hit `timeout` or get\r\n * a response. If the response is other than [[PresentationStatus.BackendTimeout]] or [[PresentationStatus.Success]], a [[PresentationError]]\r\n * is thrown with the details from the response.\r\n */\r\n public async request<TResult, TOptions extends (RequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute), TArg = any>(\r\n func: (token: IModelRpcProps, options: PresentationRpcRequestOptions<TOptions>, ...args: TArg[]) => PresentationRpcResponse<TResult>,\r\n options: TOptions,\r\n ...additionalOptions: TArg[]\r\n ): Promise<TResult> {\r\n const { imodel, diagnostics, ...optionsNoIModel } = options;\r\n const { handler: diagnosticsHandler, ...diagnosticsOptions } = diagnostics ?? {};\r\n if (isOptionsWithRuleset(optionsNoIModel)) {\r\n optionsNoIModel.rulesetOrId = cleanupRuleset(optionsNoIModel.rulesetOrId);\r\n }\r\n const rpcOptions: PresentationRpcRequestOptions<TOptions> = {\r\n ...optionsNoIModel,\r\n clientId: this.clientId,\r\n };\r\n if (diagnostics) {\r\n rpcOptions.diagnostics = diagnosticsOptions;\r\n }\r\n const doRequest = async () => func(imodel, rpcOptions, ...additionalOptions);\r\n return this.requestWithTimeout(doRequest, diagnosticsHandler);\r\n }\r\n\r\n public async getNodesCount(options: HierarchyRequestOptions<IModelRpcProps, NodeKey, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<number> {\r\n return this.request<number, typeof options>(\r\n this.rpcClient.getNodesCount.bind(this.rpcClient), options);\r\n }\r\n // eslint-disable-next-line deprecation/deprecation\r\n public async getPagedNodes(options: Paged<HierarchyRequestOptions<IModelRpcProps, NodeKey, RulesetVariableJSON>> & ClientDiagnosticsAttribute): Promise<PagedResponse<NodeJSON>> {\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this.request<PagedResponse<NodeJSON>, typeof options>(\r\n this.rpcClient.getPagedNodes.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getNodesDescriptor(options: HierarchyLevelDescriptorRequestOptions<IModelRpcProps, NodeKey, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<DescriptorJSON | undefined> {\r\n const response = await this.request<string | DescriptorJSON | undefined, typeof options>(\r\n this.rpcClient.getNodesDescriptor.bind(this.rpcClient), options);\r\n if (typeof response === \"string\")\r\n return JSON.parse(response);\r\n return response;\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public async getNodePaths(options: FilterByInstancePathsHierarchyRequestOptions<IModelRpcProps, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<NodePathElementJSON[]> {\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this.request<NodePathElementJSON[], typeof options>(\r\n this.rpcClient.getNodePaths.bind(this.rpcClient), options);\r\n }\r\n // eslint-disable-next-line deprecation/deprecation\r\n public async getFilteredNodePaths(options: FilterByTextHierarchyRequestOptions<IModelRpcProps, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<NodePathElementJSON[]> {\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this.request<NodePathElementJSON[], typeof options>(\r\n this.rpcClient.getFilteredNodePaths.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getContentSources(options: ContentSourcesRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<ContentSourcesRpcResult> {\r\n return this.request<ContentSourcesRpcResult, typeof options>(\r\n this.rpcClient.getContentSources.bind(this.rpcClient), options);\r\n }\r\n public async getContentDescriptor(options: ContentDescriptorRequestOptions<IModelRpcProps, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<DescriptorJSON | undefined> {\r\n return this.request<DescriptorJSON | undefined, typeof options>(\r\n this.rpcClient.getContentDescriptor.bind(this.rpcClient), options);\r\n }\r\n public async getContentSetSize(options: ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<number> {\r\n return this.request<number, typeof options>(\r\n this.rpcClient.getContentSetSize.bind(this.rpcClient), options);\r\n }\r\n public async getPagedContent(options: Paged<ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute>) {\r\n return this.request<{ descriptor: DescriptorJSON, contentSet: PagedResponse<ItemJSON> } | undefined, typeof options>(\r\n this.rpcClient.getPagedContent.bind(this.rpcClient), options);\r\n }\r\n public async getPagedContentSet(options: Paged<ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute>) {\r\n return this.request<PagedResponse<ItemJSON>, typeof options>(\r\n this.rpcClient.getPagedContentSet.bind(this.rpcClient), options);\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public async getPagedDistinctValues(options: DistinctValuesRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<PagedResponse<DisplayValueGroupJSON>> {\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this.request<PagedResponse<DisplayValueGroupJSON>, typeof options>(\r\n this.rpcClient.getPagedDistinctValues.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getElementProperties(options: SingleElementPropertiesRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<ElementProperties | undefined> {\r\n return this.request<ElementProperties | undefined, typeof options>(\r\n this.rpcClient.getElementProperties.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getContentInstanceKeys(options: ContentInstanceKeysRequestOptions<IModelRpcProps, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<{ total: number, items: KeySetJSON }> {\r\n return this.request<{ total: number, items: KeySetJSON }, typeof options>(\r\n this.rpcClient.getContentInstanceKeys.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getDisplayLabelDefinition(options: DisplayLabelRequestOptions<IModelRpcProps, InstanceKey> & ClientDiagnosticsAttribute): Promise<LabelDefinition> {\r\n return this.request<LabelDefinition, typeof options>(\r\n this.rpcClient.getDisplayLabelDefinition.bind(this.rpcClient), options);\r\n }\r\n public async getPagedDisplayLabelDefinitions(options: DisplayLabelsRequestOptions<IModelRpcProps, InstanceKey> & ClientDiagnosticsAttribute): Promise<PagedResponse<LabelDefinition>> {\r\n return this.request<PagedResponse<LabelDefinition>, typeof options>(\r\n this.rpcClient.getPagedDisplayLabelDefinitions.bind(this.rpcClient), options);\r\n }\r\n\r\n public async getSelectionScopes(options: SelectionScopeRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<SelectionScope[]> {\r\n return this.request<SelectionScope[], typeof options>(\r\n this.rpcClient.getSelectionScopes.bind(this.rpcClient), options);\r\n }\r\n public async computeSelection(options: ComputeSelectionRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<KeySetJSON> {\r\n return this.request<KeySetJSON, typeof options>(\r\n // eslint-disable-next-line deprecation/deprecation\r\n this.rpcClient.computeSelection.bind(this.rpcClient), options);\r\n }\r\n}\r\n\r\nfunction isOptionsWithRuleset(options: Object): options is { rulesetOrId: Ruleset } {\r\n return (typeof (options as RequestOptionsWithRuleset<any, any>).rulesetOrId === \"object\");\r\n}\r\n\r\ntype RulesetWithRequiredProperties = {\r\n [key in keyof Ruleset]-?: true;\r\n};\r\n\r\nconst RULESET_SUPPORTED_PROPERTIES_OBJ: RulesetWithRequiredProperties = {\r\n id: true,\r\n rules: true,\r\n version: true,\r\n requiredSchemas: true,\r\n supplementationInfo: true,\r\n vars: true,\r\n};\r\n\r\nfunction cleanupRuleset(ruleset: Ruleset): Ruleset {\r\n const cleanedUpRuleset: Ruleset = { ...ruleset };\r\n\r\n for (const propertyKey of Object.keys(cleanedUpRuleset)) {\r\n if (!RULESET_SUPPORTED_PROPERTIES_OBJ.hasOwnProperty(propertyKey)) {\r\n if (propertyKey === \"$schema\")\r\n delete (cleanedUpRuleset as any)[propertyKey];\r\n else\r\n Logger.logWarning(PresentationCommonLoggerCategory.Package, `Provided ruleset contains unrecognized attribute '${propertyKey}'. It either doesn't exist or may be no longer supported.`);\r\n }\r\n }\r\n\r\n return cleanedUpRuleset;\r\n}\r\n"]}