@itwin/core-common 5.5.0-dev.2 → 5.5.0-dev.5

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 (346) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/lib/cjs/AmbientOcclusion.js.map +1 -1
  3. package/lib/cjs/AnalysisStyle.js.map +1 -1
  4. package/lib/cjs/Atmosphere.js.map +1 -1
  5. package/lib/cjs/AuthorizationClient.js.map +1 -1
  6. package/lib/cjs/BackgroundMapProvider.js.map +1 -1
  7. package/lib/cjs/BackgroundMapSettings.js.map +1 -1
  8. package/lib/cjs/Base64EncodedString.js.map +1 -1
  9. package/lib/cjs/BlobReader.js.map +1 -1
  10. package/lib/cjs/BriefcaseTypes.js.map +1 -1
  11. package/lib/cjs/Camera.js.map +1 -1
  12. package/lib/cjs/CatalogIModel.js.map +1 -1
  13. package/lib/cjs/CesiumIonAssets.js.map +1 -1
  14. package/lib/cjs/ChangedElements.js.map +1 -1
  15. package/lib/cjs/ChangedEntities.js.map +1 -1
  16. package/lib/cjs/ChangesetProps.js.map +1 -1
  17. package/lib/cjs/ClipStyle.js.map +1 -1
  18. package/lib/cjs/Code.js.map +1 -1
  19. package/lib/cjs/ColorByName.js.map +1 -1
  20. package/lib/cjs/ColorDef.js.map +1 -1
  21. package/lib/cjs/CommonLoggerCategory.js.map +1 -1
  22. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  23. package/lib/cjs/ContextRealityModel.js.map +1 -1
  24. package/lib/cjs/ContourDisplay.js.map +1 -1
  25. package/lib/cjs/DisplayStyleSettings.js.map +1 -1
  26. package/lib/cjs/ECSchemaProps.js.map +1 -1
  27. package/lib/cjs/ECSqlReader.js.map +1 -1
  28. package/lib/cjs/ECSqlTypes.js.map +1 -1
  29. package/lib/cjs/ElementMesh.js.map +1 -1
  30. package/lib/cjs/ElementProps.js.map +1 -1
  31. package/lib/cjs/EmphasizeElementsProps.js.map +1 -1
  32. package/lib/cjs/EntityProps.js.map +1 -1
  33. package/lib/cjs/EntityReference.js.map +1 -1
  34. package/lib/cjs/Environment.js.map +1 -1
  35. package/lib/cjs/FeatureIndex.js.map +1 -1
  36. package/lib/cjs/FeatureSymbology.js.map +1 -1
  37. package/lib/cjs/FeatureTable.js.map +1 -1
  38. package/lib/cjs/Fonts.js.map +1 -1
  39. package/lib/cjs/Frustum.js.map +1 -1
  40. package/lib/cjs/GenericInstanceFilter.js.map +1 -1
  41. package/lib/cjs/GeoCoordinateServices.js.map +1 -1
  42. package/lib/cjs/GeometryContainment.js.map +1 -1
  43. package/lib/cjs/GeometryParams.js.map +1 -1
  44. package/lib/cjs/GeometrySummary.js.map +1 -1
  45. package/lib/cjs/Gradient.js.map +1 -1
  46. package/lib/cjs/GraphicParams.js.map +1 -1
  47. package/lib/cjs/GroundPlane.js.map +1 -1
  48. package/lib/cjs/HSLColor.js.map +1 -1
  49. package/lib/cjs/HSVColor.js.map +1 -1
  50. package/lib/cjs/HiddenLine.js.map +1 -1
  51. package/lib/cjs/Hilite.js.map +1 -1
  52. package/lib/cjs/IModel.js.map +1 -1
  53. package/lib/cjs/IModelError.js.map +1 -1
  54. package/lib/cjs/IModelVersion.js.map +1 -1
  55. package/lib/cjs/ITwinCoreErrors.js.map +1 -1
  56. package/lib/cjs/Image.js.map +1 -1
  57. package/lib/cjs/IpcAppProps.js.map +1 -1
  58. package/lib/cjs/LightSettings.js.map +1 -1
  59. package/lib/cjs/LinePixels.js.map +1 -1
  60. package/lib/cjs/Localization.js.map +1 -1
  61. package/lib/cjs/MapImagerySettings.js.map +1 -1
  62. package/lib/cjs/MapLayerSettings.js.map +1 -1
  63. package/lib/cjs/MassProperties.js.map +1 -1
  64. package/lib/cjs/MaterialProps.js.map +1 -1
  65. package/lib/cjs/ModelClipGroup.js.map +1 -1
  66. package/lib/cjs/ModelGeometryChanges.js.map +1 -1
  67. package/lib/cjs/ModelProps.js.map +1 -1
  68. package/lib/cjs/NativeAppProps.js.map +1 -1
  69. package/lib/cjs/OctEncodedNormal.js.map +1 -1
  70. package/lib/cjs/PlanProjectionSettings.js.map +1 -1
  71. package/lib/cjs/PlanarClipMask.js.map +1 -1
  72. package/lib/cjs/QPoint.js.map +1 -1
  73. package/lib/cjs/RealityDataAccessProps.js.map +1 -1
  74. package/lib/cjs/RealityModelDisplaySettings.js.map +1 -1
  75. package/lib/cjs/RenderMaterial.js.map +1 -1
  76. package/lib/cjs/RenderPolyline.js.map +1 -1
  77. package/lib/cjs/RenderTexture.js.map +1 -1
  78. package/lib/cjs/RgbColor.js.map +1 -1
  79. package/lib/cjs/RpcInterface.js.map +1 -1
  80. package/lib/cjs/RpcManager.js.map +1 -1
  81. package/lib/cjs/SessionProps.js.map +1 -1
  82. package/lib/cjs/SkyBox.js.map +1 -1
  83. package/lib/cjs/SolarCalculate.js.map +1 -1
  84. package/lib/cjs/SolarShadows.js.map +1 -1
  85. package/lib/cjs/SpatialClassification.js.map +1 -1
  86. package/lib/cjs/SubCategoryAppearance.js.map +1 -1
  87. package/lib/cjs/SubCategoryOverride.js.map +1 -1
  88. package/lib/cjs/TerrainSettings.js.map +1 -1
  89. package/lib/cjs/TextureMapping.js.map +1 -1
  90. package/lib/cjs/TextureProps.js.map +1 -1
  91. package/lib/cjs/ThematicDisplay.js.map +1 -1
  92. package/lib/cjs/Thumbnail.js.map +1 -1
  93. package/lib/cjs/TileProps.js.map +1 -1
  94. package/lib/cjs/Tween.js.map +1 -1
  95. package/lib/cjs/TxnAction.js.map +1 -1
  96. package/lib/cjs/ViewDetails.js.map +1 -1
  97. package/lib/cjs/ViewFlags.js.map +1 -1
  98. package/lib/cjs/ViewProps.js.map +1 -1
  99. package/lib/cjs/WhiteOnWhiteReversalSettings.js.map +1 -1
  100. package/lib/cjs/annotation/TextAnnotation.js.map +1 -1
  101. package/lib/cjs/annotation/TextBlock.js.map +1 -1
  102. package/lib/cjs/annotation/TextBlockGeometryProps.js.map +1 -1
  103. package/lib/cjs/annotation/TextBlockLayoutResult.js.map +1 -1
  104. package/lib/cjs/annotation/TextField.js.map +1 -1
  105. package/lib/cjs/annotation/TextStyle.js.map +1 -1
  106. package/lib/cjs/core-common.js.map +1 -1
  107. package/lib/cjs/domains/FunctionalElementProps.js.map +1 -1
  108. package/lib/cjs/domains/GenericElementProps.js.map +1 -1
  109. package/lib/cjs/geometry/AdditionalTransform.js.map +1 -1
  110. package/lib/cjs/geometry/AreaPattern.js.map +1 -1
  111. package/lib/cjs/geometry/BoundingSphere.js.map +1 -1
  112. package/lib/cjs/geometry/Cartographic.js.map +1 -1
  113. package/lib/cjs/geometry/CoordinateReferenceSystem.js.map +1 -1
  114. package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
  115. package/lib/cjs/geometry/ElementGeometryFB.js.map +1 -1
  116. package/lib/cjs/geometry/FrustumPlanes.js.map +1 -1
  117. package/lib/cjs/geometry/GeodeticDatum.js.map +1 -1
  118. package/lib/cjs/geometry/GeodeticEllipsoid.js.map +1 -1
  119. package/lib/cjs/geometry/GeometryStream.js.map +1 -1
  120. package/lib/cjs/geometry/ImageGraphic.js.map +1 -1
  121. package/lib/cjs/geometry/LineStyle.js.map +1 -1
  122. package/lib/cjs/geometry/Placement.js.map +1 -1
  123. package/lib/cjs/geometry/Projection.js.map +1 -1
  124. package/lib/cjs/geometry/TextString.js.map +1 -1
  125. package/lib/cjs/internal/BackendTypes.js.map +1 -1
  126. package/lib/cjs/internal/PackedFeatureTable.js.map +1 -1
  127. package/lib/cjs/internal/RenderMaterialParams.js.map +1 -1
  128. package/lib/cjs/internal/RenderMesh.js.map +1 -1
  129. package/lib/cjs/internal/RenderTextureParams.js.map +1 -1
  130. package/lib/cjs/internal/Snapping.js.map +1 -1
  131. package/lib/cjs/internal/annotations/FieldFormatter.js.map +1 -1
  132. package/lib/cjs/internal/cross-package.js.map +1 -1
  133. package/lib/cjs/ipc/IpcSession.js.map +1 -1
  134. package/lib/cjs/ipc/IpcSocket.js.map +1 -1
  135. package/lib/cjs/ipc/IpcWebSocket.js.map +1 -1
  136. package/lib/cjs/ipc/IpcWebSocketTransport.js.map +1 -1
  137. package/lib/cjs/rpc/DevToolsRpcInterface.js.map +1 -1
  138. package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
  139. package/lib/cjs/rpc/IModelTileRpcInterface.js.map +1 -1
  140. package/lib/cjs/rpc/SnapshotIModelRpcInterface.js.map +1 -1
  141. package/lib/cjs/rpc/TestRpcManager.js.map +1 -1
  142. package/lib/cjs/rpc/core/RpcConfiguration.js.map +1 -1
  143. package/lib/cjs/rpc/core/RpcConstants.js.map +1 -1
  144. package/lib/cjs/rpc/core/RpcControl.js.map +1 -1
  145. package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
  146. package/lib/cjs/rpc/core/RpcMarshaling.js.map +1 -1
  147. package/lib/cjs/rpc/core/RpcOperation.js.map +1 -1
  148. package/lib/cjs/rpc/core/RpcPendingQueue.js.map +1 -1
  149. package/lib/cjs/rpc/core/RpcProtocol.js.map +1 -1
  150. package/lib/cjs/rpc/core/RpcPush.js.map +1 -1
  151. package/lib/cjs/rpc/core/RpcRegistry.js.map +1 -1
  152. package/lib/cjs/rpc/core/RpcRequest.js.map +1 -1
  153. package/lib/cjs/rpc/core/RpcRequestContext.js.map +1 -1
  154. package/lib/cjs/rpc/core/RpcRoutingToken.js.map +1 -1
  155. package/lib/cjs/rpc/core/RpcSessionInvocation.js.map +1 -1
  156. package/lib/cjs/rpc/web/BentleyCloudRpcManager.js.map +1 -1
  157. package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
  158. package/lib/cjs/rpc/web/OpenAPI.js.map +1 -1
  159. package/lib/cjs/rpc/web/RpcMultipart.js.map +1 -1
  160. package/lib/cjs/rpc/web/WebAppRpcLogging.js.map +1 -1
  161. package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
  162. package/lib/cjs/rpc/web/WebAppRpcRequest.js.map +1 -1
  163. package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
  164. package/lib/cjs/tile/B3dmTileIO.js.map +1 -1
  165. package/lib/cjs/tile/CompositeTileIO.js.map +1 -1
  166. package/lib/cjs/tile/ElementGraphics.js.map +1 -1
  167. package/lib/cjs/tile/GltfTileIO.js.map +1 -1
  168. package/lib/cjs/tile/I3dmTileIO.js.map +1 -1
  169. package/lib/cjs/tile/IModelTileIO.js.map +1 -1
  170. package/lib/cjs/tile/PntsTileIO.js.map +1 -1
  171. package/lib/cjs/tile/TileIO.js.map +1 -1
  172. package/lib/cjs/tile/TileMetadata.js.map +1 -1
  173. package/lib/cjs/tile/Tileset3dSchema.js.map +1 -1
  174. package/lib/esm/AmbientOcclusion.js.map +1 -1
  175. package/lib/esm/AnalysisStyle.js.map +1 -1
  176. package/lib/esm/Atmosphere.js.map +1 -1
  177. package/lib/esm/AuthorizationClient.js.map +1 -1
  178. package/lib/esm/BackgroundMapProvider.js.map +1 -1
  179. package/lib/esm/BackgroundMapSettings.js.map +1 -1
  180. package/lib/esm/Base64EncodedString.js.map +1 -1
  181. package/lib/esm/BlobReader.js.map +1 -1
  182. package/lib/esm/BriefcaseTypes.js.map +1 -1
  183. package/lib/esm/Camera.js.map +1 -1
  184. package/lib/esm/CatalogIModel.js.map +1 -1
  185. package/lib/esm/CesiumIonAssets.js.map +1 -1
  186. package/lib/esm/ChangedElements.js.map +1 -1
  187. package/lib/esm/ChangedEntities.js.map +1 -1
  188. package/lib/esm/ChangesetProps.js.map +1 -1
  189. package/lib/esm/ClipStyle.js.map +1 -1
  190. package/lib/esm/Code.js.map +1 -1
  191. package/lib/esm/ColorByName.js.map +1 -1
  192. package/lib/esm/ColorDef.js.map +1 -1
  193. package/lib/esm/CommonLoggerCategory.js.map +1 -1
  194. package/lib/esm/ConcurrentQuery.js.map +1 -1
  195. package/lib/esm/ContextRealityModel.js.map +1 -1
  196. package/lib/esm/ContourDisplay.js.map +1 -1
  197. package/lib/esm/DisplayStyleSettings.js.map +1 -1
  198. package/lib/esm/ECSchemaProps.js.map +1 -1
  199. package/lib/esm/ECSqlReader.js.map +1 -1
  200. package/lib/esm/ECSqlTypes.js.map +1 -1
  201. package/lib/esm/ElementMesh.js.map +1 -1
  202. package/lib/esm/ElementProps.js.map +1 -1
  203. package/lib/esm/EmphasizeElementsProps.js.map +1 -1
  204. package/lib/esm/EntityProps.js.map +1 -1
  205. package/lib/esm/EntityReference.js.map +1 -1
  206. package/lib/esm/Environment.js.map +1 -1
  207. package/lib/esm/FeatureIndex.js.map +1 -1
  208. package/lib/esm/FeatureSymbology.js.map +1 -1
  209. package/lib/esm/FeatureTable.js.map +1 -1
  210. package/lib/esm/Fonts.js.map +1 -1
  211. package/lib/esm/Frustum.js.map +1 -1
  212. package/lib/esm/GenericInstanceFilter.js.map +1 -1
  213. package/lib/esm/GeoCoordinateServices.js.map +1 -1
  214. package/lib/esm/GeometryContainment.js.map +1 -1
  215. package/lib/esm/GeometryParams.js.map +1 -1
  216. package/lib/esm/GeometrySummary.js.map +1 -1
  217. package/lib/esm/Gradient.js.map +1 -1
  218. package/lib/esm/GraphicParams.js.map +1 -1
  219. package/lib/esm/GroundPlane.js.map +1 -1
  220. package/lib/esm/HSLColor.js.map +1 -1
  221. package/lib/esm/HSVColor.js.map +1 -1
  222. package/lib/esm/HiddenLine.js.map +1 -1
  223. package/lib/esm/Hilite.js.map +1 -1
  224. package/lib/esm/IModel.js.map +1 -1
  225. package/lib/esm/IModelError.js.map +1 -1
  226. package/lib/esm/IModelVersion.js.map +1 -1
  227. package/lib/esm/ITwinCoreErrors.js.map +1 -1
  228. package/lib/esm/Image.js.map +1 -1
  229. package/lib/esm/IpcAppProps.js.map +1 -1
  230. package/lib/esm/LightSettings.js.map +1 -1
  231. package/lib/esm/LinePixels.js.map +1 -1
  232. package/lib/esm/Localization.js.map +1 -1
  233. package/lib/esm/MapImagerySettings.js.map +1 -1
  234. package/lib/esm/MapLayerSettings.js.map +1 -1
  235. package/lib/esm/MassProperties.js.map +1 -1
  236. package/lib/esm/MaterialProps.js.map +1 -1
  237. package/lib/esm/ModelClipGroup.js.map +1 -1
  238. package/lib/esm/ModelGeometryChanges.js.map +1 -1
  239. package/lib/esm/ModelProps.js.map +1 -1
  240. package/lib/esm/NativeAppProps.js.map +1 -1
  241. package/lib/esm/OctEncodedNormal.js.map +1 -1
  242. package/lib/esm/PlanProjectionSettings.js.map +1 -1
  243. package/lib/esm/PlanarClipMask.js.map +1 -1
  244. package/lib/esm/QPoint.js.map +1 -1
  245. package/lib/esm/RealityDataAccessProps.js.map +1 -1
  246. package/lib/esm/RealityModelDisplaySettings.js.map +1 -1
  247. package/lib/esm/RenderMaterial.js.map +1 -1
  248. package/lib/esm/RenderPolyline.js.map +1 -1
  249. package/lib/esm/RenderTexture.js.map +1 -1
  250. package/lib/esm/RgbColor.js.map +1 -1
  251. package/lib/esm/RpcInterface.js.map +1 -1
  252. package/lib/esm/RpcManager.js.map +1 -1
  253. package/lib/esm/SessionProps.js.map +1 -1
  254. package/lib/esm/SkyBox.js.map +1 -1
  255. package/lib/esm/SolarCalculate.js.map +1 -1
  256. package/lib/esm/SolarShadows.js.map +1 -1
  257. package/lib/esm/SpatialClassification.js.map +1 -1
  258. package/lib/esm/SubCategoryAppearance.js.map +1 -1
  259. package/lib/esm/SubCategoryOverride.js.map +1 -1
  260. package/lib/esm/TerrainSettings.js.map +1 -1
  261. package/lib/esm/TextureMapping.js.map +1 -1
  262. package/lib/esm/TextureProps.js.map +1 -1
  263. package/lib/esm/ThematicDisplay.js.map +1 -1
  264. package/lib/esm/Thumbnail.js.map +1 -1
  265. package/lib/esm/TileProps.js.map +1 -1
  266. package/lib/esm/Tween.js.map +1 -1
  267. package/lib/esm/TxnAction.js.map +1 -1
  268. package/lib/esm/ViewDetails.js.map +1 -1
  269. package/lib/esm/ViewFlags.js.map +1 -1
  270. package/lib/esm/ViewProps.js.map +1 -1
  271. package/lib/esm/WhiteOnWhiteReversalSettings.js.map +1 -1
  272. package/lib/esm/annotation/TextAnnotation.js.map +1 -1
  273. package/lib/esm/annotation/TextBlock.js.map +1 -1
  274. package/lib/esm/annotation/TextBlockGeometryProps.js.map +1 -1
  275. package/lib/esm/annotation/TextBlockLayoutResult.js.map +1 -1
  276. package/lib/esm/annotation/TextField.js.map +1 -1
  277. package/lib/esm/annotation/TextStyle.js.map +1 -1
  278. package/lib/esm/core-common.js.map +1 -1
  279. package/lib/esm/domains/FunctionalElementProps.js.map +1 -1
  280. package/lib/esm/domains/GenericElementProps.js.map +1 -1
  281. package/lib/esm/geometry/AdditionalTransform.js.map +1 -1
  282. package/lib/esm/geometry/AreaPattern.js.map +1 -1
  283. package/lib/esm/geometry/BoundingSphere.js.map +1 -1
  284. package/lib/esm/geometry/Cartographic.js.map +1 -1
  285. package/lib/esm/geometry/CoordinateReferenceSystem.js.map +1 -1
  286. package/lib/esm/geometry/ElementGeometry.js.map +1 -1
  287. package/lib/esm/geometry/ElementGeometryFB.js.map +1 -1
  288. package/lib/esm/geometry/FrustumPlanes.js.map +1 -1
  289. package/lib/esm/geometry/GeodeticDatum.js.map +1 -1
  290. package/lib/esm/geometry/GeodeticEllipsoid.js.map +1 -1
  291. package/lib/esm/geometry/GeometryStream.js.map +1 -1
  292. package/lib/esm/geometry/ImageGraphic.js.map +1 -1
  293. package/lib/esm/geometry/LineStyle.js.map +1 -1
  294. package/lib/esm/geometry/Placement.js.map +1 -1
  295. package/lib/esm/geometry/Projection.js.map +1 -1
  296. package/lib/esm/geometry/TextString.js.map +1 -1
  297. package/lib/esm/internal/BackendTypes.js.map +1 -1
  298. package/lib/esm/internal/PackedFeatureTable.js.map +1 -1
  299. package/lib/esm/internal/RenderMaterialParams.js.map +1 -1
  300. package/lib/esm/internal/RenderMesh.js.map +1 -1
  301. package/lib/esm/internal/RenderTextureParams.js.map +1 -1
  302. package/lib/esm/internal/Snapping.js.map +1 -1
  303. package/lib/esm/internal/annotations/FieldFormatter.js.map +1 -1
  304. package/lib/esm/internal/cross-package.js.map +1 -1
  305. package/lib/esm/ipc/IpcSession.js.map +1 -1
  306. package/lib/esm/ipc/IpcSocket.js.map +1 -1
  307. package/lib/esm/ipc/IpcWebSocket.js.map +1 -1
  308. package/lib/esm/ipc/IpcWebSocketTransport.js.map +1 -1
  309. package/lib/esm/rpc/DevToolsRpcInterface.js.map +1 -1
  310. package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
  311. package/lib/esm/rpc/IModelTileRpcInterface.js.map +1 -1
  312. package/lib/esm/rpc/SnapshotIModelRpcInterface.js.map +1 -1
  313. package/lib/esm/rpc/TestRpcManager.js.map +1 -1
  314. package/lib/esm/rpc/core/RpcConfiguration.js.map +1 -1
  315. package/lib/esm/rpc/core/RpcConstants.js.map +1 -1
  316. package/lib/esm/rpc/core/RpcControl.js.map +1 -1
  317. package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
  318. package/lib/esm/rpc/core/RpcMarshaling.js.map +1 -1
  319. package/lib/esm/rpc/core/RpcOperation.js.map +1 -1
  320. package/lib/esm/rpc/core/RpcPendingQueue.js.map +1 -1
  321. package/lib/esm/rpc/core/RpcProtocol.js.map +1 -1
  322. package/lib/esm/rpc/core/RpcPush.js.map +1 -1
  323. package/lib/esm/rpc/core/RpcRegistry.js.map +1 -1
  324. package/lib/esm/rpc/core/RpcRequest.js.map +1 -1
  325. package/lib/esm/rpc/core/RpcRequestContext.js.map +1 -1
  326. package/lib/esm/rpc/core/RpcRoutingToken.js.map +1 -1
  327. package/lib/esm/rpc/core/RpcSessionInvocation.js.map +1 -1
  328. package/lib/esm/rpc/web/BentleyCloudRpcManager.js.map +1 -1
  329. package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
  330. package/lib/esm/rpc/web/OpenAPI.js.map +1 -1
  331. package/lib/esm/rpc/web/RpcMultipart.js.map +1 -1
  332. package/lib/esm/rpc/web/WebAppRpcLogging.js.map +1 -1
  333. package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
  334. package/lib/esm/rpc/web/WebAppRpcRequest.js.map +1 -1
  335. package/lib/esm/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
  336. package/lib/esm/tile/B3dmTileIO.js.map +1 -1
  337. package/lib/esm/tile/CompositeTileIO.js.map +1 -1
  338. package/lib/esm/tile/ElementGraphics.js.map +1 -1
  339. package/lib/esm/tile/GltfTileIO.js.map +1 -1
  340. package/lib/esm/tile/I3dmTileIO.js.map +1 -1
  341. package/lib/esm/tile/IModelTileIO.js.map +1 -1
  342. package/lib/esm/tile/PntsTileIO.js.map +1 -1
  343. package/lib/esm/tile/TileIO.js.map +1 -1
  344. package/lib/esm/tile/TileMetadata.js.map +1 -1
  345. package/lib/esm/tile/Tileset3dSchema.js.map +1 -1
  346. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"RpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8C;AAG9C,yDAAsD;AACtD,iDAA6F;AAE7F,mDAAuE;AACvE,mDAAoE;AAwDpE,gBAAgB;AAChB,IAAiB,qBAAqB,CAYrC;AAZD,WAAiB,qBAAqB;IAC7B,KAAK,UAAU,eAAe,CAAC,OAA6B,EAAE,KAAU;QAC7E,MAAM,MAAM,GAAG,6BAAa,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAEzD,OAAO;YACL,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,mBAAmB;YACpD,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,MAAM;YACN,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,+BAAgB,CAAC,QAAQ;SAClC,CAAC;IACJ,CAAC;IAVqB,qCAAe,kBAUpC,CAAA;AACH,CAAC,EAZgB,qBAAqB,qCAArB,qBAAqB,QAYrC;AAOD;;GAEG;AACH,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,2DAAQ,CAAA;IACR,yFAAuB,CAAA;IACvB,mGA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,WAAmC,EAAE,KAAmB,IAAU,CAAC;IAE/F,gBAAgB;IACT,qBAAqB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAElG,gBAAgB;IACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAjHhG,kCAkHC","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/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelRpcProps } from \"../../IModel\";\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\nimport { RpcConfiguration } from \"./RpcConfiguration\";\nimport { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\nimport { RpcNotFoundResponse } from \"./RpcControl\";\nimport { RpcInvocation, SerializedRpcActivity } from \"./RpcInvocation\";\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\nimport { RpcOperation } from \"./RpcOperation\";\nimport { RpcRequest } from \"./RpcRequest\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** A serialized RPC operation descriptor.\n * @internal\n */\nexport interface SerializedRpcOperation {\n interfaceDefinition: string;\n operationName: string;\n interfaceVersion: string;\n encodedRequest?: string;\n}\n\n/** A serialized RPC operation request.\n * @internal\n */\nexport interface SerializedRpcRequest extends SerializedRpcActivity {\n operation: SerializedRpcOperation;\n method: string;\n path: string;\n parameters: RpcSerializedValue;\n caching: RpcResponseCacheControl;\n ip?: string;\n protocolVersion?: number;\n parametersOverride?: any[];\n}\n\n/** An RPC operation request fulfillment.\n * @internal\n */\nexport interface RpcRequestFulfillment {\n /** The RPC interface for the request. */\n interfaceName: string;\n\n /** The id for the request. */\n id: string;\n\n /** The result for the request. */\n result: RpcSerializedValue;\n\n /** The un-serialized result for the request. */\n rawResult: any;\n\n /** A protocol-specific status code value for the request. */\n status: number;\n\n /* A protocol-specific value for retrying this request. */\n retry?: string;\n\n /** Whether to compress the result with one of the client's supported encodings. Defaults to true. */\n allowCompression?: boolean;\n}\n\n/** @internal */\nexport namespace RpcRequestFulfillment {\n export async function forUnknownError(request: SerializedRpcRequest, error: any): Promise<RpcRequestFulfillment> {\n const result = RpcMarshaling.serialize(undefined, error);\n\n return {\n interfaceName: request.operation.interfaceDefinition,\n id: request.id,\n result,\n rawResult: error,\n status: RpcRequestStatus.Rejected,\n };\n }\n}\n\n/** Handles RPC protocol events.\n * @internal\n */\nexport type RpcProtocolEventHandler = (type: RpcProtocolEvent, object: RpcRequest | RpcInvocation, err?: any) => void;\n\n/** Documents changes to the RPC protocol version.\n * @internal\n */\nexport enum RpcProtocolVersion {\n None = 0,\n IntroducedNoContent = 1,\n IntroducedStatusCategory = 2\n}\n\n/**\n * A backend response that is handled internally by the RPC system.\n * @internal\n */\nexport interface RpcManagedStatus {\n iTwinRpcCoreResponse: true;\n managedStatus: \"pending\" | \"notFound\" | \"noContent\";\n responseValue: string | { message: string } | RpcNotFoundResponse;\n}\n\n/** An application protocol for an RPC interface.\n * @internal\n */\nexport abstract class RpcProtocol {\n /** Events raised by all protocols. See [[RpcProtocolEvent]] */\n public static readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\n\n /** A version code that identifies the RPC protocol capabilties of this endpoint. */\n public static readonly protocolVersion: number = RpcProtocolVersion.IntroducedStatusCategory;\n\n /** The name of the RPC protocol version header. */\n public protocolVersionHeaderName = \"\";\n\n /** Events raised by the protocol. See [[RpcProtocolEvent]] */\n public readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\n\n /** The configuration for the protocol. */\n public readonly configuration: RpcConfiguration;\n\n /** The RPC request class for this protocol. */\n public abstract readonly requestType: typeof RpcRequest;\n\n /** The RPC invocation class for this protocol. */\n public readonly invocationType: typeof RpcInvocation = RpcInvocation;\n\n public serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\n /** The name of the request id header. */\n id: \"\",\n\n /** The name of the application id header */\n applicationId: \"\",\n\n /** The name of the version header. */\n applicationVersion: \"\",\n\n /** The name of the session id header */\n sessionId: \"\",\n\n /** The name of the authorization header. */\n authorization: \"\",\n };\n\n /** If greater than zero, specifies where to break large binary request payloads. */\n public transferChunkThreshold: number = 0;\n\n /** Used by protocols that can transmit stream values natively. */\n public preserveStreams: boolean = false;\n\n /** Used by protocols that can transmit IModelRpcProps values natively. */\n public checkToken: boolean = false;\n\n /** Used by protocols that support user-defined status codes. */\n public supportsStatusCategory: boolean = false;\n\n /** If checkToken is true, will be called on the backend to inflate the IModelRpcProps for each request. */\n public inflateToken(tokenFromBody: IModelRpcProps, _request: SerializedRpcRequest): IModelRpcProps { return tokenFromBody; }\n\n /** Override to supply the status corresponding to a protocol-specific code value. */\n public getStatus(code: number): RpcRequestStatus {\n return code;\n }\n\n /** Override to supply the protocol-specific code corresponding to a status value. */\n public getCode(status: RpcRequestStatus): number {\n return status;\n }\n\n /** Override to supply the protocol-specific path value for an RPC operation. */\n public supplyPathForOperation(operation: RpcOperation, _request: RpcRequest | undefined): string {\n return JSON.stringify(operation);\n }\n\n /** Override to supply the operation for a protocol-specific path value. */\n public getOperationFromPath(path: string): SerializedRpcOperation {\n return JSON.parse(path);\n }\n\n /** Obtains the implementation result on the backend for an RPC operation request. */\n public async fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment> {\n return new (this.invocationType)(this, request).fulfillment;\n }\n\n /** Serializes a request. */\n public async serialize(request: RpcRequest): Promise<SerializedRpcRequest> {\n const serializedContext = await RpcConfiguration.requestContext.serialize(request);\n return {\n ...serializedContext,\n operation: {\n interfaceDefinition: request.operation.interfaceDefinition.interfaceName,\n operationName: request.operation.operationName,\n interfaceVersion: request.operation.interfaceVersion,\n },\n method: request.method,\n path: request.path,\n parameters: RpcMarshaling.serialize(request.protocol, request.parameters),\n caching: RpcResponseCacheControl.None,\n protocolVersion: RpcProtocol.protocolVersion,\n };\n }\n\n /** Constructs a protocol. */\n public constructor(configuration: RpcConfiguration) {\n this.configuration = configuration;\n this.events.addListener((type, object) => RpcProtocol.events.raiseEvent(type, object));\n }\n\n /** @internal */\n public onRpcClientInitialized(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\n\n /** @internal */\n public onRpcImplInitialized(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\n\n /** @internal */\n public onRpcClientTerminated(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\n\n /** @internal */\n public onRpcImplTerminated(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\n}\n"]}
1
+ {"version":3,"file":"RpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8C;AAG9C,yDAAsD;AACtD,iDAA6F;AAE7F,mDAAuE;AACvE,mDAAoE;AAwDpE,gBAAgB;AAChB,IAAiB,qBAAqB,CAYrC;AAZD,WAAiB,qBAAqB;IAC7B,KAAK,UAAU,eAAe,CAAC,OAA6B,EAAE,KAAU;QAC7E,MAAM,MAAM,GAAG,6BAAa,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAEzD,OAAO;YACL,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,mBAAmB;YACpD,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,MAAM;YACN,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,+BAAgB,CAAC,QAAQ;SAClC,CAAC;IACJ,CAAC;IAVqB,qCAAe,kBAUpC,CAAA;AACH,CAAC,EAZgB,qBAAqB,qCAArB,qBAAqB,QAYrC;AAOD;;GAEG;AACH,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,2DAAQ,CAAA;IACR,yFAAuB,CAAA;IACvB,mGAA4B,CAAA;AAC9B,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B;AAYD;;GA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mC,EAAE,OAAqB,IAAU,CAAC;IAElG,gBAAgB;IACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAjHhG,kCAkHC","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 RpcInterface\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse } from \"./RpcControl\";\r\nimport { RpcInvocation, SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\n/** A serialized RPC operation descriptor.\r\n * @internal\r\n */\r\nexport interface SerializedRpcOperation {\r\n interfaceDefinition: string;\r\n operationName: string;\r\n interfaceVersion: string;\r\n encodedRequest?: string;\r\n}\r\n\r\n/** A serialized RPC operation request.\r\n * @internal\r\n */\r\nexport interface SerializedRpcRequest extends SerializedRpcActivity {\r\n operation: SerializedRpcOperation;\r\n method: string;\r\n path: string;\r\n parameters: RpcSerializedValue;\r\n caching: RpcResponseCacheControl;\r\n ip?: string;\r\n protocolVersion?: number;\r\n parametersOverride?: any[];\r\n}\r\n\r\n/** An RPC operation request fulfillment.\r\n * @internal\r\n */\r\nexport interface RpcRequestFulfillment {\r\n /** The RPC interface for the request. */\r\n interfaceName: string;\r\n\r\n /** The id for the request. */\r\n id: string;\r\n\r\n /** The result for the request. */\r\n result: RpcSerializedValue;\r\n\r\n /** The un-serialized result for the request. */\r\n rawResult: any;\r\n\r\n /** A protocol-specific status code value for the request. */\r\n status: number;\r\n\r\n /* A protocol-specific value for retrying this request. */\r\n retry?: string;\r\n\r\n /** Whether to compress the result with one of the client's supported encodings. Defaults to true. */\r\n allowCompression?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcRequestFulfillment {\r\n export async function forUnknownError(request: SerializedRpcRequest, error: any): Promise<RpcRequestFulfillment> {\r\n const result = RpcMarshaling.serialize(undefined, error);\r\n\r\n return {\r\n interfaceName: request.operation.interfaceDefinition,\r\n id: request.id,\r\n result,\r\n rawResult: error,\r\n status: RpcRequestStatus.Rejected,\r\n };\r\n }\r\n}\r\n\r\n/** Handles RPC protocol events.\r\n * @internal\r\n */\r\nexport type RpcProtocolEventHandler = (type: RpcProtocolEvent, object: RpcRequest | RpcInvocation, err?: any) => void;\r\n\r\n/** Documents changes to the RPC protocol version.\r\n * @internal\r\n */\r\nexport enum RpcProtocolVersion {\r\n None = 0,\r\n IntroducedNoContent = 1,\r\n IntroducedStatusCategory = 2\r\n}\r\n\r\n/**\r\n * A backend response that is handled internally by the RPC system.\r\n * @internal\r\n */\r\nexport interface RpcManagedStatus {\r\n iTwinRpcCoreResponse: true;\r\n managedStatus: \"pending\" | \"notFound\" | \"noContent\";\r\n responseValue: string | { message: string } | RpcNotFoundResponse;\r\n}\r\n\r\n/** An application protocol for an RPC interface.\r\n * @internal\r\n */\r\nexport abstract class RpcProtocol {\r\n /** Events raised by all protocols. See [[RpcProtocolEvent]] */\r\n public static readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** A version code that identifies the RPC protocol capabilties of this endpoint. */\r\n public static readonly protocolVersion: number = RpcProtocolVersion.IntroducedStatusCategory;\r\n\r\n /** The name of the RPC protocol version header. */\r\n public protocolVersionHeaderName = \"\";\r\n\r\n /** Events raised by the protocol. See [[RpcProtocolEvent]] */\r\n public readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** The configuration for the protocol. */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** The RPC request class for this protocol. */\r\n public abstract readonly requestType: typeof RpcRequest;\r\n\r\n /** The RPC invocation class for this protocol. */\r\n public readonly invocationType: typeof RpcInvocation = RpcInvocation;\r\n\r\n public serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the request id header. */\r\n id: \"\",\r\n\r\n /** The name of the application id header */\r\n applicationId: \"\",\r\n\r\n /** The name of the version header. */\r\n applicationVersion: \"\",\r\n\r\n /** The name of the session id header */\r\n sessionId: \"\",\r\n\r\n /** The name of the authorization header. */\r\n authorization: \"\",\r\n };\r\n\r\n /** If greater than zero, specifies where to break large binary request payloads. */\r\n public transferChunkThreshold: number = 0;\r\n\r\n /** Used by protocols that can transmit stream values natively. */\r\n public preserveStreams: boolean = false;\r\n\r\n /** Used by protocols that can transmit IModelRpcProps values natively. */\r\n public checkToken: boolean = false;\r\n\r\n /** Used by protocols that support user-defined status codes. */\r\n public supportsStatusCategory: boolean = false;\r\n\r\n /** If checkToken is true, will be called on the backend to inflate the IModelRpcProps for each request. */\r\n public inflateToken(tokenFromBody: IModelRpcProps, _request: SerializedRpcRequest): IModelRpcProps { return tokenFromBody; }\r\n\r\n /** Override to supply the status corresponding to a protocol-specific code value. */\r\n public getStatus(code: number): RpcRequestStatus {\r\n return code;\r\n }\r\n\r\n /** Override to supply the protocol-specific code corresponding to a status value. */\r\n public getCode(status: RpcRequestStatus): number {\r\n return status;\r\n }\r\n\r\n /** Override to supply the protocol-specific path value for an RPC operation. */\r\n public supplyPathForOperation(operation: RpcOperation, _request: RpcRequest | undefined): string {\r\n return JSON.stringify(operation);\r\n }\r\n\r\n /** Override to supply the operation for a protocol-specific path value. */\r\n public getOperationFromPath(path: string): SerializedRpcOperation {\r\n return JSON.parse(path);\r\n }\r\n\r\n /** Obtains the implementation result on the backend for an RPC operation request. */\r\n public async fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment> {\r\n return new (this.invocationType)(this, request).fulfillment;\r\n }\r\n\r\n /** Serializes a request. */\r\n public async serialize(request: RpcRequest): Promise<SerializedRpcRequest> {\r\n const serializedContext = await RpcConfiguration.requestContext.serialize(request);\r\n return {\r\n ...serializedContext,\r\n operation: {\r\n interfaceDefinition: request.operation.interfaceDefinition.interfaceName,\r\n operationName: request.operation.operationName,\r\n interfaceVersion: request.operation.interfaceVersion,\r\n },\r\n method: request.method,\r\n path: request.path,\r\n parameters: RpcMarshaling.serialize(request.protocol, request.parameters),\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: RpcProtocol.protocolVersion,\r\n };\r\n }\r\n\r\n /** Constructs a protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n this.configuration = configuration;\r\n this.events.addListener((type, object) => RpcProtocol.events.raiseEvent(type, object));\r\n }\r\n\r\n /** @internal */\r\n public onRpcClientInitialized(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplInitialized(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcClientTerminated(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplTerminated(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcPush.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcPush.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;+FAE+F;AAC/F;;GAEG;;;AAEH,sDAAqE;AACrE,mDAAgD;AAKhD;;GAEG;AACH,MAAsB,gBAAgB;IAC7B,SAAS,CAAiD;CAClE;AAFD,4CAEC;AAED;;GAEG;AACH,MAAa,cAAc;IACzB,2FAA2F;IACpF,MAAM,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;IAE1C,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I,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QAC3B,IAAI,EAAE,IAAI,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;YAC3B,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACzC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,IAAW,UAAU;QACnB,OAAO,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC;IAC9B,CAAC;;AAnFH,wCAoFC;AAED;;GAEG;AACH,MAAa,mBAAmB;IACd,OAAO,CAAoB;IAC3B,SAAS,GAAG,IAAI,sBAAO,EAA6B,CAAC;IAErE,gBAAgB;IAChB,YAAmB,OAA0B;QAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AARD,kDAQC;AAED;;GAEG;AACH,MAAsB,iBAAiB;IAC9B,MAAM,CAAC,GAAG,CAAI,QAA2B,EAAE,UAAmB,SAAS;QAC5E,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACjE,CAAC;IAEe,OAAO,CAAoB;IAC3B,MAAM,CAAU;IAIhC,YAAsB,OAA0B,EAAE,MAAe;QAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAdD,8CAcC","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/*---------------------------------------------------------------------------------------------\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { assert, BeEvent, BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelError } from \"../../IModelError\";\n\n/** @internal */\nexport type RpcPushMessageListener<T> = (message: T) => void;\n\n/** Defines a transport for push messages.\n * @internal\n */\nexport abstract class RpcPushTransport {\n public onMessage?: (channelId: string, messageData: any) => void;\n}\n\n/** Defines a source of push messages.\n * @internal\n */\nexport class RpcPushService {\n /** The push service for the dedicated backend (for example, an electron or mobile app). */\n public static dedicated = new RpcPushService(\"dedicated\");\n\n public readonly name: string;\n\n public constructor(name: string) {\n this.name = name;\n }\n}\n\n/** Defines a named stream of push messages.\n * @internal\n */\nexport class RpcPushChannel<T> {\n /** @internal */\n public static enabled = false;\n\n private static _channels: Map<string, RpcPushChannel<any>> = new Map();\n\n public static setup(transport: RpcPushTransport) {\n transport.onMessage = RpcPushChannel.notifySubscribers.bind(RpcPushChannel);\n RpcPushChannel.enabled = true;\n }\n\n private static notifySubscribers(channelId: string, messageData: any) {\n const channel = this._channels.get(channelId);\n if (!channel)\n return;\n\n for (const subscriber of channel._subscribers)\n subscriber.onMessage.raiseEvent(messageData);\n }\n\n private _subscribers: RpcPushSubscription<T>[] = [];\n public readonly name: string;\n public readonly service: RpcPushService;\n public get id() { return RpcPushChannel.formatId(this.name, this.service); }\n public get enabled() { return RpcPushChannel.enabled; }\n\n public subscribe(): RpcPushSubscription<T> {\n const subscription = new RpcPushSubscription(this);\n this._subscribers.push(subscription);\n return subscription;\n }\n\n private static formatId(name: string, service: RpcPushService): string {\n return `${service.name}-${name}`;\n }\n\n private constructor(name: string, service: RpcPushService) {\n this.name = name;\n this.service = service;\n }\n\n /** Creates a new RpcPushChannel.\n * @throws IModelError if a channel with the specified name and service already exist.\n */\n public static create<T>(name: string, service = RpcPushService.dedicated): RpcPushChannel<T> {\n return this.get<T>(name, service, false);\n }\n\n /** Obtains an RpcPushChannel, creating it if one with the specified name and service does not already exists. */\n public static obtain<T>(name: string, service = RpcPushService.dedicated): RpcPushChannel<T> {\n return this.get<T>(name, service, true);\n }\n\n private static get<T>(name: string, service: RpcPushService, reuseExisting: boolean): RpcPushChannel<T> {\n const id = this.formatId(name, service);\n let channel = this._channels.get(id);\n if (channel) {\n if (!reuseExisting)\n throw new IModelError(BentleyStatus.ERROR, `Channel \"${id}\" already exists.`);\n\n ++channel._refCount;\n return channel;\n }\n\n channel = new RpcPushChannel(name, service);\n this._channels.set(id, channel);\n return channel;\n }\n\n private _refCount = 1;\n public dispose(): void {\n if (this.isDisposed)\n return;\n\n assert(this._refCount > 0);\n if (--this._refCount === 0) {\n RpcPushChannel._channels.delete(this.id);\n this._subscribers.length = 0;\n }\n }\n\n public get isDisposed(): boolean {\n return 0 === this._refCount;\n }\n}\n\n/** Receives push messages from the backend.\n * @internal\n */\nexport class RpcPushSubscription<T> {\n public readonly channel: RpcPushChannel<T>;\n public readonly onMessage = new BeEvent<RpcPushMessageListener<T>>();\n\n /** @internal */\n public constructor(channel: RpcPushChannel<T>) {\n this.channel = channel;\n }\n}\n\n/** Sends push messages to the frontend.\n * @internal\n */\nexport abstract class RpcPushConnection<T> {\n public static for<T>(_channel: RpcPushChannel<T>, _client: unknown = undefined): RpcPushConnection<T> {\n throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\");\n }\n\n public readonly channel: RpcPushChannel<T>;\n public readonly client: unknown;\n\n public abstract send(messageData: T): Promise<void>;\n\n protected constructor(channel: RpcPushChannel<T>, client: unknown) {\n this.channel = channel;\n this.client = client;\n }\n}\n"]}
1
+ {"version":3,"file":"RpcPush.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcPush.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;+FAE+F;AAC/F;;GAEG;;;AAEH,sDAAqE;AACrE,mDAAgD;AAKhD;;GAEG;AACH,MAAsB,gBAAgB;IAC7B,SAAS,CAAiD;CAClE;AAFD,4CAEC;AAED;;GAEG;AACH,MAAa,cAAc;IACzB,2FAA2F;IACpF,MAAM,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;IAE1C,IAAI,CAAS;IAE7B,YAAmB,IAAY;Q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AAC;QAC3B,IAAI,EAAE,IAAI,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;YAC3B,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACzC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,IAAW,UAAU;QACnB,OAAO,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC;IAC9B,CAAC;;AAnFH,wCAoFC;AAED;;GAEG;AACH,MAAa,mBAAmB;IACd,OAAO,CAAoB;IAC3B,SAAS,GAAG,IAAI,sBAAO,EAA6B,CAAC;IAErE,gBAAgB;IAChB,YAAmB,OAA0B;QAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AARD,kDAQC;AAED;;GAEG;AACH,MAAsB,iBAAiB;IAC9B,MAAM,CAAC,GAAG,CAAI,QAA2B,EAAE,UAAmB,SAAS;QAC5E,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACjE,CAAC;IAEe,OAAO,CAAoB;IAC3B,MAAM,CAAU;IAIhC,YAAsB,OAA0B,EAAE,MAAe;QAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAdD,8CAcC","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/*---------------------------------------------------------------------------------------------\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { assert, BeEvent, BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"../../IModelError\";\r\n\r\n/** @internal */\r\nexport type RpcPushMessageListener<T> = (message: T) => void;\r\n\r\n/** Defines a transport for push messages.\r\n * @internal\r\n */\r\nexport abstract class RpcPushTransport {\r\n public onMessage?: (channelId: string, messageData: any) => void;\r\n}\r\n\r\n/** Defines a source of push messages.\r\n * @internal\r\n */\r\nexport class RpcPushService {\r\n /** The push service for the dedicated backend (for example, an electron or mobile app). */\r\n public static dedicated = new RpcPushService(\"dedicated\");\r\n\r\n public readonly name: string;\r\n\r\n public constructor(name: string) {\r\n this.name = name;\r\n }\r\n}\r\n\r\n/** Defines a named stream of push messages.\r\n * @internal\r\n */\r\nexport class RpcPushChannel<T> {\r\n /** @internal */\r\n public static enabled = false;\r\n\r\n private static _channels: Map<string, RpcPushChannel<any>> = new Map();\r\n\r\n public static setup(transport: RpcPushTransport) {\r\n transport.onMessage = RpcPushChannel.notifySubscribers.bind(RpcPushChannel);\r\n RpcPushChannel.enabled = true;\r\n }\r\n\r\n private static notifySubscribers(channelId: string, messageData: any) {\r\n const channel = this._channels.get(channelId);\r\n if (!channel)\r\n return;\r\n\r\n for (const subscriber of channel._subscribers)\r\n subscriber.onMessage.raiseEvent(messageData);\r\n }\r\n\r\n private _subscribers: RpcPushSubscription<T>[] = [];\r\n public readonly name: string;\r\n public readonly service: RpcPushService;\r\n public get id() { return RpcPushChannel.formatId(this.name, this.service); }\r\n public get enabled() { return RpcPushChannel.enabled; }\r\n\r\n public subscribe(): RpcPushSubscription<T> {\r\n const subscription = new RpcPushSubscription(this);\r\n this._subscribers.push(subscription);\r\n return subscription;\r\n }\r\n\r\n private static formatId(name: string, service: RpcPushService): string {\r\n return `${service.name}-${name}`;\r\n }\r\n\r\n private constructor(name: string, service: RpcPushService) {\r\n this.name = name;\r\n this.service = service;\r\n }\r\n\r\n /** Creates a new RpcPushChannel.\r\n * @throws IModelError if a channel with the specified name and service already exist.\r\n */\r\n public static create<T>(name: string, service = RpcPushService.dedicated): RpcPushChannel<T> {\r\n return this.get<T>(name, service, false);\r\n }\r\n\r\n /** Obtains an RpcPushChannel, creating it if one with the specified name and service does not already exists. */\r\n public static obtain<T>(name: string, service = RpcPushService.dedicated): RpcPushChannel<T> {\r\n return this.get<T>(name, service, true);\r\n }\r\n\r\n private static get<T>(name: string, service: RpcPushService, reuseExisting: boolean): RpcPushChannel<T> {\r\n const id = this.formatId(name, service);\r\n let channel = this._channels.get(id);\r\n if (channel) {\r\n if (!reuseExisting)\r\n throw new IModelError(BentleyStatus.ERROR, `Channel \"${id}\" already exists.`);\r\n\r\n ++channel._refCount;\r\n return channel;\r\n }\r\n\r\n channel = new RpcPushChannel(name, service);\r\n this._channels.set(id, channel);\r\n return channel;\r\n }\r\n\r\n private _refCount = 1;\r\n public dispose(): void {\r\n if (this.isDisposed)\r\n return;\r\n\r\n assert(this._refCount > 0);\r\n if (--this._refCount === 0) {\r\n RpcPushChannel._channels.delete(this.id);\r\n this._subscribers.length = 0;\r\n }\r\n }\r\n\r\n public get isDisposed(): boolean {\r\n return 0 === this._refCount;\r\n }\r\n}\r\n\r\n/** Receives push messages from the backend.\r\n * @internal\r\n */\r\nexport class RpcPushSubscription<T> {\r\n public readonly channel: RpcPushChannel<T>;\r\n public readonly onMessage = new BeEvent<RpcPushMessageListener<T>>();\r\n\r\n /** @internal */\r\n public constructor(channel: RpcPushChannel<T>) {\r\n this.channel = channel;\r\n }\r\n}\r\n\r\n/** Sends push messages to the frontend.\r\n * @internal\r\n */\r\nexport abstract class RpcPushConnection<T> {\r\n public static for<T>(_channel: RpcPushChannel<T>, _client: unknown = undefined): RpcPushConnection<T> {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\");\r\n }\r\n\r\n public readonly channel: RpcPushChannel<T>;\r\n public readonly client: unknown;\r\n\r\n public abstract send(messageData: T): Promise<void>;\r\n\r\n protected constructor(channel: RpcPushChannel<T>, client: unknown) {\r\n this.channel = channel;\r\n this.client = client;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcRegistry.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AC,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;YACzF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAEO,gBAAgB;QACtB,IAAA,iCAAoB,GAAE,CAAC;QACvB,iCAAe,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC;CACF;AAnND,kCAmNC","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/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelError } from \"../../IModelError\";\nimport { RpcConfiguration } from \"./RpcConfiguration\";\nimport { RpcPendingQueue } from \"./RpcPendingQueue\";\nimport { initializeRpcRequest } from \"./RpcRequest\";\nimport { RpcRoutingToken } from \"./RpcRoutingToken\";\nimport { RpcInterface, RpcInterfaceDefinition, RpcInterfaceImplementation } from \"../../RpcInterface\";\nimport { RpcInterfaceEndpoints } from \"../../RpcManager\";\nimport { RpcControlChannel } from \"./RpcControl\";\nimport { RpcOperation, RpcOperationPolicy } from \"./RpcOperation\";\n\n/** @internal */\nexport const REGISTRY = Symbol.for(\"@itwin/core-common/RpcRegistry\");\n\n/** @internal */\nexport const OPERATION = Symbol.for(\"@itwin/core-common/RpcOperation\");\n\n/** @internal */\nexport const POLICY = Symbol.for(\"@itwin/core-common/RpcOperationPolicy\");\n\n/** @internal */\nexport const INSTANCE = Symbol.for(\"@itwin/core-common/RpcInterface/__instance__\");\n\n/** @internal */\nexport const CURRENT_REQUEST = Symbol.for(\"@itwin/core-common/RpcRequest/__current__\");\n\n/** @internal */\nexport const CURRENT_INVOCATION = Symbol.for(\"@itwin/core-common/RpcInvocation/__current__\");\n\ndeclare const self: any;\ndeclare const window: any;\n\n/** @internal */\nexport class RpcRegistry {\n private static _instance: RpcRegistry;\n\n private constructor() {\n }\n\n public static get instance() {\n if (!RpcRegistry._instance) {\n const globalObj: any = typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {};\n if (!globalObj[REGISTRY])\n globalObj[REGISTRY] = new RpcRegistry();\n\n RpcRegistry._instance = globalObj[REGISTRY];\n }\n\n return RpcRegistry._instance;\n }\n\n public lookupInterfaceDefinition(name: string): RpcInterfaceDefinition {\n if (!this.definitionClasses.has(name))\n throw new IModelError(BentleyStatus.ERROR, `RPC interface \"${name}\" is not initialized.`);\n\n return this.definitionClasses.get(name) as RpcInterfaceDefinition;\n }\n\n public async describeAvailableEndpoints(): Promise<RpcInterfaceEndpoints[]> {\n const requests: Array<Promise<RpcInterfaceEndpoints[]>> = [];\n for (const channel of RpcControlChannel.channels) {\n requests.push(channel.describeEndpoints());\n }\n\n const responses = await Promise.all(requests);\n const endpoints = responses.reduce((a, b) => a.concat(b), []);\n for (const endpoint of endpoints) {\n const definition = this.definitionClasses.get(endpoint.interfaceName);\n endpoint.compatible = (definition && RpcInterface.isVersionCompatible(endpoint.interfaceVersion, definition.interfaceVersion)) ? true : false;\n }\n\n return endpoints;\n }\n\n public getClientForInterface<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>, routing: RpcRoutingToken = RpcRoutingToken.default): T {\n let instance: T | undefined;\n\n const proxies = this.proxies.get(definition.interfaceName);\n if (proxies) {\n instance = proxies.get(routing.id) as (T | undefined);\n }\n\n if (!instance)\n instance = this.instantiateClient(definition, routing);\n\n return instance;\n }\n\n public getImplForInterface<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>): T {\n let instance = this.implementations.get(definition.interfaceName) as (T | undefined);\n if (!instance)\n instance = this.instantiateImpl(definition);\n\n return instance;\n }\n\n public lookupImpl<T extends RpcInterface>(interfaceName: string): T {\n const definition = this.lookupInterfaceDefinition(interfaceName);\n return this.getImplForInterface(definition) as T;\n }\n\n public registerImpl<TDefinition extends RpcInterface, TImplementation extends TDefinition>(definition: RpcInterfaceDefinition<TDefinition>, implementation: RpcInterfaceImplementation<TImplementation>) {\n this.unregisterImpl(definition);\n this.implementationClasses.set(definition.interfaceName, implementation);\n }\n\n public unregisterImpl<TDefinition extends RpcInterface>(definition: RpcInterfaceDefinition<TDefinition>) {\n this.implementationClasses.delete(definition.interfaceName);\n\n const impl = this.implementations.get(definition.interfaceName);\n if (impl) {\n impl.configuration.onRpcImplTerminated(definition, impl);\n this.implementations.delete(definition.interfaceName);\n }\n }\n\n public supplyImplInstance<TDefinition extends RpcInterface, TImplementation extends TDefinition>(definition: RpcInterfaceDefinition<TDefinition>, instance: TImplementation): void {\n this.suppliedImplementations.set(definition.interfaceName, instance);\n }\n\n public isRpcInterfaceInitialized<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>): boolean {\n return this.definitionClasses.has(definition.interfaceName);\n }\n\n public initializeRpcInterface<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>): void {\n if (this.definitionClasses.has(definition.interfaceName)) {\n const existing = this.definitionClasses.get(definition.interfaceName);\n if (existing && definition.interfaceVersion === \"CONTROL\" && existing !== definition) {\n this.configureOperations(definition); // configs that differ only by routing still need the control ops initialized\n }\n\n return;\n }\n\n this.notifyInitialize();\n this.definitionClasses.set(definition.interfaceName, definition);\n this.configureOperations(definition);\n }\n\n public terminateRpcInterface<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) {\n this.unregisterImpl(definition);\n this.purgeClient(definition);\n this.definitionClasses.delete(definition.interfaceName);\n }\n\n public definitionClasses: Map<string, RpcInterfaceDefinition> = new Map();\n public proxies: Map<string, Map<number, RpcInterface>> = new Map();\n public implementations: Map<string, RpcInterface> = new Map();\n public suppliedImplementations: Map<string, RpcInterface> = new Map();\n public implementationClasses: Map<string, RpcInterfaceImplementation> = new Map();\n\n public id = (() => {\n let i = 0;\n return () => ++i;\n })();\n\n private instantiateImpl<TDefinition extends RpcInterface, TImplementation extends TDefinition>(definition: RpcInterfaceDefinition<TDefinition>): TImplementation {\n this.checkInitialized(definition);\n\n const registeredImplementation = this.implementationClasses.get(definition.interfaceName) as RpcInterfaceImplementation<TImplementation>;\n if (!registeredImplementation)\n throw new IModelError(BentleyStatus.ERROR, `An RPC interface implementation class for \"${definition.interfaceName}\" is not registered.`);\n\n if (definition.prototype.configurationSupplier)\n registeredImplementation.prototype.configurationSupplier = definition.prototype.configurationSupplier;\n\n const supplied = this.suppliedImplementations.get(definition.interfaceName);\n const implementation = supplied || new registeredImplementation();\n if (!(implementation instanceof registeredImplementation))\n throw new IModelError(BentleyStatus.ERROR, `Invalid RPC interface implementation.`);\n\n if (supplied) {\n (supplied.configuration as any) = RpcConfiguration.supply(supplied);\n }\n\n this.implementations.set(definition.interfaceName, implementation);\n implementation.configuration.onRpcImplInitialized(definition, implementation);\n return implementation;\n }\n\n private instantiateClient<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>, routing: RpcRoutingToken = RpcRoutingToken.default): T {\n this.checkInitialized(definition);\n\n const proxy = new (definition as any)(routing) as T;\n\n if (!this.proxies.has(definition.interfaceName)) {\n this.proxies.set(definition.interfaceName, new Map());\n }\n\n this.proxies.get(definition.interfaceName)?.set(routing.id, proxy);\n\n Object.getOwnPropertyNames(definition.prototype).forEach((operationName) => {\n if (operationName === \"constructor\" || operationName === \"configurationSupplier\")\n return;\n\n this.interceptOperation(proxy, operationName);\n });\n\n proxy.configuration.onRpcClientInitialized(definition, proxy);\n return proxy;\n }\n\n private interceptOperation(proxy: RpcInterface, operation: string) {\n const clientFunction = (proxy as any)[operation];\n (proxy as any)[operation] = function () {\n const args = Array.from(arguments);\n args.push(operation);\n return clientFunction.apply(proxy, args);\n };\n }\n\n private checkInitialized<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) {\n if (!this.definitionClasses.has(definition.interfaceName))\n throw new IModelError(BentleyStatus.ERROR, `RPC interface \"${definition.interfaceName}\" is not initialized.`);\n }\n\n private configureOperations<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) {\n const proto = (definition.prototype as any);\n\n Object.getOwnPropertyNames(proto).forEach((operationName) => {\n if (operationName === \"constructor\" || operationName === \"configurationSupplier\")\n return;\n\n const propertyName = RpcOperation.computeOperationName(operationName);\n\n if (!proto[propertyName][OPERATION]) {\n const policy = (definition as any)[POLICY] || new RpcOperationPolicy();\n proto[propertyName][OPERATION] = new RpcOperation(definition, propertyName, policy);\n }\n });\n }\n\n private purgeClient<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) {\n const proxies = this.proxies.get(definition.interfaceName);\n if (proxies) {\n proxies.forEach((proxy) => proxy.configuration.onRpcClientTerminated(definition, proxy));\n this.proxies.delete(definition.interfaceName);\n }\n }\n\n private notifyInitialize() {\n initializeRpcRequest();\n RpcPendingQueue.initialize();\n }\n}\n"]}
1
+ {"version":3,"file":"RpcRegistry.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AACpD,mDAAgD;AAChD,yDAAsD;AACtD,uDAAoD;AACpD,6CAAoD;AACpD,uDAAoD;AACpD,qDAAsG;AAEtG,6CAAiD;AACjD,iDAAkE;AAElE,gBAAgB;AACH,QAAA,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAErE,gBAAgB;AACH,QAAA,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AAEvE,gBAAgB;AACH,QAAA,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AAE1E,gBAAgB;AACH,QAAA,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;AAEnF,gBAAgB;AACH,QAAA,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;AAEvF,gBAAgB;AACH,QAAA,kBAAkB,GAAG,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CAAC,aAAa,CAAC,CAAC;YAEtE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,iBAAS,CAAC,EAAE,CAAC;gBACpC,MAAM,MAAM,GAAI,UAAkB,CAAC,cAAM,CAAC,IAAI,IAAI,iCAAkB,EAAE,CAAC;gBACvE,KAAK,CAAC,YAAY,CAAC,CAAC,iBAAS,CAAC,GAAG,IAAI,2BAAY,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;YACtF,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,WAAW,CAAyB,UAAqC;QAC/E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAC3D,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;YACzF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAEO,gBAAgB;QACtB,IAAA,iCAAoB,GAAE,CAAC;QACvB,iCAAe,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC;CACF;AAnND,kCAmNC","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 RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcPendingQueue } from \"./RpcPendingQueue\";\r\nimport { initializeRpcRequest } from \"./RpcRequest\";\r\nimport { RpcRoutingToken } from \"./RpcRoutingToken\";\r\nimport { RpcInterface, RpcInterfaceDefinition, RpcInterfaceImplementation } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints } from \"../../RpcManager\";\r\nimport { RpcControlChannel } from \"./RpcControl\";\r\nimport { RpcOperation, RpcOperationPolicy } from \"./RpcOperation\";\r\n\r\n/** @internal */\r\nexport const REGISTRY = Symbol.for(\"@itwin/core-common/RpcRegistry\");\r\n\r\n/** @internal */\r\nexport const OPERATION = Symbol.for(\"@itwin/core-common/RpcOperation\");\r\n\r\n/** @internal */\r\nexport const POLICY = Symbol.for(\"@itwin/core-common/RpcOperationPolicy\");\r\n\r\n/** @internal */\r\nexport const INSTANCE = Symbol.for(\"@itwin/core-common/RpcInterface/__instance__\");\r\n\r\n/** @internal */\r\nexport const CURRENT_REQUEST = Symbol.for(\"@itwin/core-common/RpcRequest/__current__\");\r\n\r\n/** @internal */\r\nexport const CURRENT_INVOCATION = Symbol.for(\"@itwin/core-common/RpcInvocation/__current__\");\r\n\r\ndeclare const self: any;\r\ndeclare const window: any;\r\n\r\n/** @internal */\r\nexport class RpcRegistry {\r\n private static _instance: RpcRegistry;\r\n\r\n private constructor() {\r\n }\r\n\r\n public static get instance() {\r\n if (!RpcRegistry._instance) {\r\n const globalObj: any = typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {};\r\n if (!globalObj[REGISTRY])\r\n globalObj[REGISTRY] = new RpcRegistry();\r\n\r\n RpcRegistry._instance = globalObj[REGISTRY];\r\n }\r\n\r\n return RpcRegistry._instance;\r\n }\r\n\r\n public lookupInterfaceDefinition(name: string): RpcInterfaceDefinition {\r\n if (!this.definitionClasses.has(name))\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface \"${name}\" is not initialized.`);\r\n\r\n return this.definitionClasses.get(name) as RpcInterfaceDefinition;\r\n }\r\n\r\n public async describeAvailableEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const requests: Array<Promise<RpcInterfaceEndpoints[]>> = [];\r\n for (const channel of RpcControlChannel.channels) {\r\n requests.push(channel.describeEndpoints());\r\n }\r\n\r\n const responses = await Promise.all(requests);\r\n const endpoints = responses.reduce((a, b) => a.concat(b), []);\r\n for (const endpoint of endpoints) {\r\n const definition = this.definitionClasses.get(endpoint.interfaceName);\r\n endpoint.compatible = (definition && RpcInterface.isVersionCompatible(endpoint.interfaceVersion, definition.interfaceVersion)) ? true : false;\r\n }\r\n\r\n return endpoints;\r\n }\r\n\r\n public getClientForInterface<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>, routing: RpcRoutingToken = RpcRoutingToken.default): T {\r\n let instance: T | undefined;\r\n\r\n const proxies = this.proxies.get(definition.interfaceName);\r\n if (proxies) {\r\n instance = proxies.get(routing.id) as (T | undefined);\r\n }\r\n\r\n if (!instance)\r\n instance = this.instantiateClient(definition, routing);\r\n\r\n return instance;\r\n }\r\n\r\n public getImplForInterface<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>): T {\r\n let instance = this.implementations.get(definition.interfaceName) as (T | undefined);\r\n if (!instance)\r\n instance = this.instantiateImpl(definition);\r\n\r\n return instance;\r\n }\r\n\r\n public lookupImpl<T extends RpcInterface>(interfaceName: string): T {\r\n const definition = this.lookupInterfaceDefinition(interfaceName);\r\n return this.getImplForInterface(definition) as T;\r\n }\r\n\r\n public registerImpl<TDefinition extends RpcInterface, TImplementation extends TDefinition>(definition: RpcInterfaceDefinition<TDefinition>, implementation: RpcInterfaceImplementation<TImplementation>) {\r\n this.unregisterImpl(definition);\r\n this.implementationClasses.set(definition.interfaceName, implementation);\r\n }\r\n\r\n public unregisterImpl<TDefinition extends RpcInterface>(definition: RpcInterfaceDefinition<TDefinition>) {\r\n this.implementationClasses.delete(definition.interfaceName);\r\n\r\n const impl = this.implementations.get(definition.interfaceName);\r\n if (impl) {\r\n impl.configuration.onRpcImplTerminated(definition, impl);\r\n this.implementations.delete(definition.interfaceName);\r\n }\r\n }\r\n\r\n public supplyImplInstance<TDefinition extends RpcInterface, TImplementation extends TDefinition>(definition: RpcInterfaceDefinition<TDefinition>, instance: TImplementation): void {\r\n this.suppliedImplementations.set(definition.interfaceName, instance);\r\n }\r\n\r\n public isRpcInterfaceInitialized<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>): boolean {\r\n return this.definitionClasses.has(definition.interfaceName);\r\n }\r\n\r\n public initializeRpcInterface<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>): void {\r\n if (this.definitionClasses.has(definition.interfaceName)) {\r\n const existing = this.definitionClasses.get(definition.interfaceName);\r\n if (existing && definition.interfaceVersion === \"CONTROL\" && existing !== definition) {\r\n this.configureOperations(definition); // configs that differ only by routing still need the control ops initialized\r\n }\r\n\r\n return;\r\n }\r\n\r\n this.notifyInitialize();\r\n this.definitionClasses.set(definition.interfaceName, definition);\r\n this.configureOperations(definition);\r\n }\r\n\r\n public terminateRpcInterface<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) {\r\n this.unregisterImpl(definition);\r\n this.purgeClient(definition);\r\n this.definitionClasses.delete(definition.interfaceName);\r\n }\r\n\r\n public definitionClasses: Map<string, RpcInterfaceDefinition> = new Map();\r\n public proxies: Map<string, Map<number, RpcInterface>> = new Map();\r\n public implementations: Map<string, RpcInterface> = new Map();\r\n public suppliedImplementations: Map<string, RpcInterface> = new Map();\r\n public implementationClasses: Map<string, RpcInterfaceImplementation> = new Map();\r\n\r\n public id = (() => {\r\n let i = 0;\r\n return () => ++i;\r\n })();\r\n\r\n private instantiateImpl<TDefinition extends RpcInterface, TImplementation extends TDefinition>(definition: RpcInterfaceDefinition<TDefinition>): TImplementation {\r\n this.checkInitialized(definition);\r\n\r\n const registeredImplementation = this.implementationClasses.get(definition.interfaceName) as RpcInterfaceImplementation<TImplementation>;\r\n if (!registeredImplementation)\r\n throw new IModelError(BentleyStatus.ERROR, `An RPC interface implementation class for \"${definition.interfaceName}\" is not registered.`);\r\n\r\n if (definition.prototype.configurationSupplier)\r\n registeredImplementation.prototype.configurationSupplier = definition.prototype.configurationSupplier;\r\n\r\n const supplied = this.suppliedImplementations.get(definition.interfaceName);\r\n const implementation = supplied || new registeredImplementation();\r\n if (!(implementation instanceof registeredImplementation))\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid RPC interface implementation.`);\r\n\r\n if (supplied) {\r\n (supplied.configuration as any) = RpcConfiguration.supply(supplied);\r\n }\r\n\r\n this.implementations.set(definition.interfaceName, implementation);\r\n implementation.configuration.onRpcImplInitialized(definition, implementation);\r\n return implementation;\r\n }\r\n\r\n private instantiateClient<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>, routing: RpcRoutingToken = RpcRoutingToken.default): T {\r\n this.checkInitialized(definition);\r\n\r\n const proxy = new (definition as any)(routing) as T;\r\n\r\n if (!this.proxies.has(definition.interfaceName)) {\r\n this.proxies.set(definition.interfaceName, new Map());\r\n }\r\n\r\n this.proxies.get(definition.interfaceName)?.set(routing.id, proxy);\r\n\r\n Object.getOwnPropertyNames(definition.prototype).forEach((operationName) => {\r\n if (operationName === \"constructor\" || operationName === \"configurationSupplier\")\r\n return;\r\n\r\n this.interceptOperation(proxy, operationName);\r\n });\r\n\r\n proxy.configuration.onRpcClientInitialized(definition, proxy);\r\n return proxy;\r\n }\r\n\r\n private interceptOperation(proxy: RpcInterface, operation: string) {\r\n const clientFunction = (proxy as any)[operation];\r\n (proxy as any)[operation] = function () {\r\n const args = Array.from(arguments);\r\n args.push(operation);\r\n return clientFunction.apply(proxy, args);\r\n };\r\n }\r\n\r\n private checkInitialized<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) {\r\n if (!this.definitionClasses.has(definition.interfaceName))\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface \"${definition.interfaceName}\" is not initialized.`);\r\n }\r\n\r\n private configureOperations<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) {\r\n const proto = (definition.prototype as any);\r\n\r\n Object.getOwnPropertyNames(proto).forEach((operationName) => {\r\n if (operationName === \"constructor\" || operationName === \"configurationSupplier\")\r\n return;\r\n\r\n const propertyName = RpcOperation.computeOperationName(operationName);\r\n\r\n if (!proto[propertyName][OPERATION]) {\r\n const policy = (definition as any)[POLICY] || new RpcOperationPolicy();\r\n proto[propertyName][OPERATION] = new RpcOperation(definition, propertyName, policy);\r\n }\r\n });\r\n }\r\n\r\n private purgeClient<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>) {\r\n const proxies = this.proxies.get(definition.interfaceName);\r\n if (proxies) {\r\n proxies.forEach((proxy) => proxy.configuration.onRpcClientTerminated(definition, proxy));\r\n this.proxies.delete(definition.interfaceName);\r\n }\r\n }\r\n\r\n private notifyInitialize() {\r\n initializeRpcRequest();\r\n RpcPendingQueue.initialize();\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmE;AAEnE,mDAA8E;AAE9E,yDAAsD;AACtD,iDAA8G;AAE9G,mDAAoE;AACpE,iDAA8C;AAC9C,+CAAkF;AAClF,+CAAgD;AAEhD,yDAAyD;AACzD,qBAAqB;AACrB,qDAAqD;AAErD,gBAAgB;AACH,QAAA,aAAa,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;AAEjE,gBAAgB;AAChB,MAAa,YAAY;IACf,KAAK,CAAe;IAC5B,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,WAAW,KAA2B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,KAAK,CAAC,IAAI,KAAoB,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC/F,KAAK,CAAC,QAAQ,KAAwB,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,kBAAkB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AChB,OAAO;QACT,CAAC;QAED,WAAW,GAAG,IAAI,CAAC;QAEnB,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;YAC9C,IAAI,IAAI,KAAK,8BAAe,CAAC,aAAa;gBACxC,OAAO;YAET,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;gBACvB,KAAK,+BAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;oBAChC,qBAAa,CAAC,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;oBAClD,MAAM;gBACR,CAAC;gBAED,KAAK,+BAAgB,CAAC,OAAO,CAAC;gBAC9B,KAAK,+BAAgB,CAAC,QAAQ,CAAC;gBAC/B,KAAK,+BAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAC/B,qBAAa,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;oBACjD,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,yBAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YACtC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YAEjC,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,+BAAgB,CAAC,eAAe,CAAC,CAAC,CAAC;oBACtC,qBAAa,CAAC,WAAW,GAAG,GAAG,CAAC;oBAChC,MAAM;gBACR,CAAC;gBAED,KAAK,+BAAgB,CAAC,sBAAsB,CAAC;gBAC7C,KAAK,+BAAgB,CAAC,oBAAoB,CAAC;gBAC3C,KAAK,+BAAgB,CAAC,sBAAsB,CAAC,CAAC,CAAC;oBAC7C,qBAAa,CAAC,YAAY,GAAG,GAAG,CAAC;oBACjC,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,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/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BeEvent, BentleyStatus, Guid } from \"@itwin/core-bentley\";\nimport { IModelRpcProps } from \"../../IModel\";\nimport { BackendError, IModelError, NoContentError } from \"../../IModelError\";\nimport { RpcInterface } from \"../../RpcInterface\";\nimport { RpcConfiguration } from \"./RpcConfiguration\";\nimport { RpcProtocolEvent, RpcRequestEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\nimport { RpcNotFoundResponse } from \"./RpcControl\";\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\nimport { RpcOperation } from \"./RpcOperation\";\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion } from \"./RpcProtocol\";\nimport { CURRENT_REQUEST } from \"./RpcRegistry\";\n\n/* eslint-disable @typescript-eslint/naming-convention */\n// cspell:ignore csrf\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** @internal */\nexport const aggregateLoad = { lastRequest: 0, lastResponse: 0 };\n\n/** @internal */\nexport class ResponseLike implements Response {\n private _data: Promise<any>;\n public get body() { return null; }\n public async arrayBuffer(): Promise<ArrayBuffer> { return this._data; }\n public async blob(): Promise<Blob> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\n public async formData(): Promise<FormData> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\n public async json(): Promise<any> { return this._data; }\n public async text(): Promise<string> { return this._data; }\n public get bodyUsed() { return false; }\n public get headers(): Headers { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\n public get ok(): boolean { return this.status >= 200 && this.status <= 299; }\n public get redirected() { return false; }\n public get status() { return 200; }\n public get statusText() { return \"\"; }\n public get trailer(): Promise<Headers> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\n public get type(): \"basic\" | \"cors\" | \"default\" | \"error\" | \"opaque\" | \"opaqueredirect\" { return \"basic\"; }\n public get url() { return \"\"; }\n public clone() { return { ...this }; }\n\n public constructor(data: any) {\n this._data = Promise.resolve(data);\n }\n}\n\n/** Supplies an IModelRpcProps for an RPC request.\n * @internal\n */\nexport type RpcRequestTokenSupplier_T = (request: RpcRequest) => IModelRpcProps | undefined;\n\n/** Supplies the initial retry interval for an RPC request.\n * @internal\n */\nexport type RpcRequestInitialRetryIntervalSupplier_T = (configuration: RpcConfiguration) => number;\n\n/** Notification callback for an RPC request.\n * @internal\n */\nexport type RpcRequestCallback_T = (request: RpcRequest) => void;\n\n/** Determines if caching is permitted for a RPC response.\n * @internal\n */\nexport type RpcResponseCachingCallback_T = (request: RpcRequest) => RpcResponseCacheControl;\n\n/** Runtime information related to the operation load of one or more RPC interfaces.\n * @internal\n */\nexport interface RpcOperationsProfile {\n readonly lastRequest: number;\n readonly lastResponse: number;\n}\n\n/** Handles RPC request events.\n * @internal\n */\nexport type RpcRequestEventHandler = (type: RpcRequestEvent, request: RpcRequest) => void;\n\n/** Resolves \"not found\" responses for RPC requests.\n * @internal\n */\nexport type RpcRequestNotFoundHandler = (request: RpcRequest, response: RpcNotFoundResponse, resubmit: () => void, reject: (reason?: any) => void) => void;\n\nclass Cancellable<T> {\n public promise: Promise<T | undefined>;\n public cancel() { }\n\n public constructor(task: Promise<T>) {\n this.promise = new Promise((resolve, reject) => {\n this.cancel = () => resolve(undefined);\n task.then(resolve, reject);\n });\n }\n}\n\n/** A RPC operation request.\n * @internal\n */\nexport abstract class RpcRequest<TResponse = any> {\n private static _activeRequests: Map<string, RpcRequest> = new Map();\n private _resolve: (value?: TResponse | PromiseLike<TResponse> | undefined) => void = () => undefined;\n protected _resolveRaw: (value?: Response | PromiseLike<Response> | undefined) => void = () => undefined;\n private _reject: (reason?: any) => void = () => undefined;\n private _rejectRaw: (reason?: any) => void = () => undefined;\n private _created: number = 0;\n private _lastSubmitted: number = 0;\n private _lastUpdated: number = 0;\n\n /** @internal */\n public _status: RpcRequestStatus = RpcRequestStatus.Unknown;\n\n /** @internal */\n public _extendedStatus: string = \"\";\n\n private _connecting: boolean = false;\n private _active: boolean = true;\n private _hasRawListener = false;\n private _raw: ArrayBuffer | string | undefined = undefined;\n private _sending?: Cancellable<number>;\n private _attempts = 0;\n private _retryAfter: number | null = null;\n private _transientFaults = 0;\n protected _response: Response | undefined = undefined;\n protected _rawPromise: Promise<Response | undefined>;\n public responseProtocolVersion = RpcProtocolVersion.None;\n\n /** All RPC requests that are currently in flight. */\n public static get activeRequests(): ReadonlyMap<string, RpcRequest> { return this._activeRequests; }\n\n /** Events raised by RpcRequest. See [[RpcRequestEvent]] */\n public static readonly events: BeEvent<RpcRequestEventHandler> = new BeEvent();\n\n /** Resolvers for \"not found\" requests. See [[RpcRequestNotFoundHandler]] */\n public static readonly notFoundHandlers: BeEvent<RpcRequestNotFoundHandler> = new BeEvent();\n\n /** The aggregate operations profile of all active RPC interfaces. */\n public static get aggregateLoad(): RpcOperationsProfile { return aggregateLoad; }\n\n /**\n * The request for the current RPC operation.\n * @note The return value of this function is only reliable if program control was received from a RPC interface class member function that directly returns the result of calling RpcInterface.forward.\n */\n public static current(context: RpcInterface): RpcRequest {\n return (context as any)[CURRENT_REQUEST];\n }\n\n /** The unique identifier of this request. */\n public readonly id: string;\n\n /** The operation for this request. */\n public readonly operation: RpcOperation;\n\n /** The parameters for this request. */\n public parameters: any[];\n\n /** The RPC client instance for this request. */\n public readonly client: RpcInterface;\n\n /** Convenience access to the protocol of this request. */\n public readonly protocol: RpcProtocol;\n\n /** The implementation response for this request. */\n public readonly response: Promise<TResponse | undefined>;\n\n /** The status of this request. */\n public get status() { return this._status; }\n\n /** Extended status information for this request (if available). */\n public get extendedStatus() { return this._extendedStatus; }\n\n /** The last submission for this request. */\n public get lastSubmitted() { return this._lastSubmitted; }\n\n /** The last status update received for this request. */\n public get lastUpdated() { return this._lastUpdated; }\n\n /** The target interval (in milliseconds) between submission attempts for this request. */\n public retryInterval: number;\n\n /** Whether a connection is active for this request. */\n public get connecting() { return this._connecting; }\n\n /** Whether this request is pending. */\n public get pending(): boolean {\n switch (this.status) {\n case RpcRequestStatus.Submitted:\n case RpcRequestStatus.Pending: {\n return true;\n }\n\n default: {\n return false;\n }\n }\n }\n\n /** The elapsed time for this request. */\n public get elapsed(): number {\n return this._lastUpdated - this._created;\n }\n\n /** A protocol-specific path identifier for this request. */\n public path: string;\n\n /** A protocol-specific method identifier for this request. */\n public method: string;\n\n /** An attempt-specific value for when to next retry this request. */\n public get retryAfter() { return this._retryAfter; }\n\n /** Finds the first parameter of a given structural type if present. */\n public findParameterOfType<T>(requiredProperties: { [index: string]: string }): T | undefined {\n for (const param of this.parameters) {\n if (typeof (param) === \"object\" && param !== null) {\n for (const prop of Object.getOwnPropertyNames(requiredProperties)) {\n if (prop in param && typeof (param[prop]) === requiredProperties[prop]) {\n return param;\n }\n }\n }\n }\n\n return undefined;\n }\n\n /** Finds the first IModelRpcProps parameter if present. */\n public findTokenPropsParameter(): IModelRpcProps | undefined {\n return this.findParameterOfType({ iModelId: \"string\" });\n\n }\n\n /** The raw implementation response for this request. */\n public get rawResponse(): Promise<Response | undefined> {\n this._hasRawListener = true;\n return this._rawPromise;\n }\n\n /** Constructs an RPC request. */\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\n this._created = new Date().getTime();\n this.path = \"\";\n this.method = \"\";\n this.client = client;\n this.protocol = client.configuration.protocol;\n this.operation = RpcOperation.lookup(client.constructor as any, operation);\n this.parameters = parameters;\n this.retryInterval = this.operation.policy.retryInterval(client.configuration);\n this.response = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n\n this._rawPromise = new Promise((resolve, reject) => {\n this._resolveRaw = resolve;\n this._rejectRaw = reject;\n });\n\n this.id = RpcConfiguration.requestContext.getId(this) || Guid.createValue();\n this.setStatus(RpcRequestStatus.Created);\n this.operation.policy.requestCallback(this);\n }\n\n /** Override to send the request. */\n protected abstract send(): Promise<number>;\n\n /** Override to load response value. */\n protected abstract load(): Promise<RpcSerializedValue>;\n\n /** Override to set request header values. */\n protected abstract setHeader(name: string, value: string): void;\n\n /** Sets the last updated time for the request. */\n protected setLastUpdatedTime() {\n this._lastUpdated = new Date().getTime();\n }\n\n protected computeRetryAfter(attempts: number) {\n return (((Math.pow(2, attempts) - 1) / 2) * 500) + 500;\n }\n\n protected recordTransientFault() {\n ++this._transientFaults;\n }\n\n protected resetTransientFaultCount() {\n this._transientFaults = 0;\n }\n\n protected supportsStatusCategory() {\n if (!this.protocol.supportsStatusCategory) {\n return false;\n }\n\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.responseProtocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\n }\n\n /* @internal */\n public cancel() {\n if (typeof (this._sending) === \"undefined\") {\n return;\n }\n\n this._sending.cancel();\n this._sending = undefined;\n\n this._connecting = false;\n RpcRequest._activeRequests.delete(this.id);\n this.setStatus(RpcRequestStatus.Cancelled);\n }\n\n /* @internal */\n public async submit(): Promise<void> {\n if (!this._active)\n return;\n\n this._lastSubmitted = new Date().getTime();\n this._retryAfter = null;\n ++this._attempts;\n\n if (this.status === RpcRequestStatus.Created || this.status === RpcRequestStatus.NotFound || this.status === RpcRequestStatus.Cancelled) {\n this.setStatus(RpcRequestStatus.Submitted);\n }\n\n try {\n this._connecting = true;\n RpcRequest._activeRequests.set(this.id, this);\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestCreated, this);\n this._sending = new Cancellable(this.setHeaders().then(async () => this.send()));\n this.operation.policy.sentCallback(this);\n\n const response = await this._sending.promise;\n if (typeof (response) === \"undefined\") {\n return;\n }\n this._sending = undefined;\n\n const status = this.protocol.getStatus(response);\n\n if (this._hasRawListener && status === RpcRequestStatus.Resolved && typeof (this._response) !== \"undefined\") {\n this._connecting = false;\n RpcRequest._activeRequests.delete(this.id);\n this.resolveRaw();\n } else {\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoading, this);\n\n if (status === RpcRequestStatus.Unknown) {\n this._connecting = false;\n RpcRequest._activeRequests.delete(this.id);\n this.handleUnknownResponse(response);\n return;\n }\n\n const value = await this.load();\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\n RpcRequest._activeRequests.delete(this.id);\n this._connecting = false;\n this.handleResponse(response, value);\n }\n } catch (err) {\n this.protocol.events.raiseEvent(RpcProtocolEvent.ConnectionErrorReceived, this, err);\n RpcRequest._activeRequests.delete(this.id);\n this._connecting = false;\n this.reject(err);\n }\n }\n\n protected handleUnknownResponse(code: number) {\n this.reject(new IModelError(BentleyStatus.ERROR, `Unknown response ${code}.`));\n }\n\n private handleResponse(code: number, value: RpcSerializedValue) {\n const protocolStatus = this.protocol.getStatus(code);\n const status = this.transformResponseStatus(protocolStatus, value);\n\n if (RpcRequestStatus.isTransientError(status)) {\n return this.handleTransientError(status);\n }\n\n switch (status) {\n case RpcRequestStatus.Resolved: {\n return this.handleResolved(value);\n }\n\n case RpcRequestStatus.Rejected: {\n return this.handleRejected(value);\n }\n\n case RpcRequestStatus.Pending: {\n return this.setPending(status, value.objects);\n }\n\n case RpcRequestStatus.NotFound: {\n return this.handleNotFound(status, value);\n }\n\n case RpcRequestStatus.NoContent: {\n return this.handleNoContent();\n }\n }\n }\n\n private transformResponseStatus(protocolStatus: RpcRequestStatus, value: RpcSerializedValue): RpcRequestStatus {\n if (!this.supportsStatusCategory()) {\n return protocolStatus;\n }\n\n let status = protocolStatus;\n\n if (protocolStatus === RpcRequestStatus.Pending) {\n status = RpcRequestStatus.Rejected;\n } else if (protocolStatus === RpcRequestStatus.NotFound) {\n status = RpcRequestStatus.Rejected;\n } else if (protocolStatus === RpcRequestStatus.Unknown) {\n status = RpcRequestStatus.Rejected;\n }\n\n if (value.objects.indexOf(\"iTwinRpcCoreResponse\") !== -1 && value.objects.indexOf(\"managedStatus\") !== -1) {\n const managedStatus: RpcManagedStatus = JSON.parse(value.objects);\n value.objects = managedStatus.responseValue as string;\n\n if (managedStatus.managedStatus === \"pending\") {\n status = RpcRequestStatus.Pending;\n } else if (managedStatus.managedStatus === \"notFound\") {\n status = RpcRequestStatus.NotFound;\n }\n }\n\n return status;\n }\n\n private handleResolved(value: RpcSerializedValue) {\n try {\n this._raw = value.objects;\n const result: TResponse = RpcMarshaling.deserialize(this.protocol, value);\n\n if (ArrayBuffer.isView(result)) {\n this._raw = result.buffer;\n }\n\n return this.resolve(result);\n } catch (err) {\n return this.reject(err);\n }\n }\n\n private handleRejected(value: RpcSerializedValue) {\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorReceived, this);\n\n try {\n const error = RpcMarshaling.deserialize(this.protocol, value);\n const hasInfo = error && typeof (error) === \"object\" && error.hasOwnProperty(\"name\") && error.hasOwnProperty(\"message\");\n const name = hasInfo ? error.name : \"\";\n const message = hasInfo ? error.message : \"\";\n const errorNumber = (hasInfo && error.hasOwnProperty(\"errorNumber\")) ? error.errorNumber : BentleyStatus.ERROR;\n return this.reject(new BackendError(errorNumber, name, message, () => error));\n } catch (err) {\n return this.reject(err);\n }\n }\n\n private handleNoContent() {\n return this.reject(new NoContentError());\n }\n\n private handleNotFound(status: RpcRequestStatus, value: RpcSerializedValue) {\n if (RpcRequest.notFoundHandlers.numberOfListeners === 0)\n this.handleRejected(value);\n\n const response = RpcMarshaling.deserialize(this.protocol, value);\n this.setStatus(status);\n\n let resubmitted = false;\n RpcRequest.notFoundHandlers.raiseEvent(this, response, () => {\n if (resubmitted)\n throw new IModelError(BentleyStatus.ERROR, `Already resubmitted using this handler.`);\n\n resubmitted = true;\n void this.submit();\n }, (reason: any) => reason ? this.reject(reason) : this.handleRejected(value));\n return;\n }\n\n private resolve(result: TResponse): void {\n if (!this._active)\n return;\n\n this._active = false;\n this.setLastUpdatedTime();\n this._resolve(result);\n\n if (this._hasRawListener) {\n if (typeof (this._raw) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Cannot access raw response.\");\n }\n\n this._resolveRaw(new ResponseLike(this._raw));\n }\n\n this.setStatus(RpcRequestStatus.Resolved);\n this[Symbol.dispose]();\n }\n\n private resolveRaw() {\n if (typeof (this._response) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Cannot access raw response.\");\n }\n\n this._active = false;\n this.setLastUpdatedTime();\n this._resolveRaw(this._response);\n this.setStatus(RpcRequestStatus.Resolved);\n this[Symbol.dispose]();\n }\n\n protected reject(reason: any): void {\n if (!this._active)\n return;\n\n this._active = false;\n this.setLastUpdatedTime();\n this._reject(reason);\n\n if (this._hasRawListener) {\n this._rejectRaw(reason);\n }\n\n this.setStatus(RpcRequestStatus.Rejected);\n this[Symbol.dispose]();\n }\n\n /** @internal */\n public [Symbol.dispose](): void {\n this.setStatus(RpcRequestStatus.Disposed);\n this._raw = undefined;\n this._response = undefined;\n\n const client = this.client as any;\n if (client[CURRENT_REQUEST] === this) {\n client[CURRENT_REQUEST] = undefined;\n }\n }\n\n private setPending(status: RpcRequestStatus.Pending, extendedStatus: string): void {\n if (!this._active)\n return;\n\n this.setLastUpdatedTime();\n this._extendedStatus = extendedStatus;\n this.setStatus(status);\n RpcRequest.events.raiseEvent(RpcRequestEvent.PendingUpdateReceived, this);\n }\n\n private handleTransientError(status: RpcRequestStatus) {\n if (!this._active)\n return;\n\n this.setLastUpdatedTime();\n this._retryAfter = this.computeRetryAfter(this._attempts - 1);\n\n if (this._transientFaults > this.protocol.configuration.transientFaultLimit) {\n this.reject(new IModelError(BentleyStatus.ERROR, `Exceeded transient fault limit.`));\n } else {\n this.setStatus(status);\n RpcRequest.events.raiseEvent(RpcRequestEvent.TransientErrorReceived, this);\n }\n }\n\n protected async setHeaders(): Promise<void> {\n const versionHeader = this.protocol.protocolVersionHeaderName;\n if (versionHeader && RpcProtocol.protocolVersion)\n this.setHeader(versionHeader, RpcProtocol.protocolVersion.toString());\n\n const headerNames = this.protocol.serializedClientRequestContextHeaderNames;\n const headerValues = await RpcConfiguration.requestContext.serialize(this);\n\n if (headerNames.id)\n this.setHeader(headerNames.id, headerValues.id || this.id); // Cannot be empty\n\n if (headerNames.applicationVersion)\n this.setHeader(headerNames.applicationVersion, headerValues.applicationVersion);\n\n if (headerNames.applicationId)\n this.setHeader(headerNames.applicationId, headerValues.applicationId);\n\n if (headerNames.sessionId)\n this.setHeader(headerNames.sessionId, headerValues.sessionId);\n\n if (headerNames.authorization && headerValues.authorization)\n this.setHeader(headerNames.authorization, headerValues.authorization);\n\n if (headerValues.csrfToken)\n this.setHeader(headerValues.csrfToken.headerName, headerValues.csrfToken.headerValue);\n }\n\n private setStatus(status: RpcRequestStatus): void {\n if (this._status === status)\n return;\n\n this._status = status;\n RpcRequest.events.raiseEvent(RpcRequestEvent.StatusChanged, this);\n }\n}\n\n/** @internal */\nexport const initializeRpcRequest = (() => {\n let initialized = false;\n\n return () => {\n if (initialized) {\n return;\n }\n\n initialized = true;\n\n RpcRequest.events.addListener((type, request) => {\n if (type !== RpcRequestEvent.StatusChanged)\n return;\n\n switch (request.status) {\n case RpcRequestStatus.Submitted: {\n aggregateLoad.lastRequest = request.lastSubmitted;\n break;\n }\n\n case RpcRequestStatus.Pending:\n case RpcRequestStatus.Resolved:\n case RpcRequestStatus.Rejected: {\n aggregateLoad.lastResponse = request.lastUpdated;\n break;\n }\n }\n });\n\n RpcProtocol.events.addListener((type) => {\n const now = new Date().getTime();\n\n switch (type) {\n case RpcProtocolEvent.RequestReceived: {\n aggregateLoad.lastRequest = now;\n break;\n }\n\n case RpcProtocolEvent.BackendReportedPending:\n case RpcProtocolEvent.BackendErrorOccurred:\n case RpcProtocolEvent.BackendResponseCreated: {\n aggregateLoad.lastResponse = now;\n break;\n }\n }\n });\n };\n})();\n"]}
1
+ {"version":3,"file":"RpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmE;AAEnE,mDAA8E;AAE9E,yDAAsD;AACtD,iDAA8G;AAE9G,m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CAAC,CAAC,IAAI,EAAE,EAAE;YACtC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YAEjC,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,+BAAgB,CAAC,eAAe,CAAC,CAAC,CAAC;oBACtC,qBAAa,CAAC,WAAW,GAAG,GAAG,CAAC;oBAChC,MAAM;gBACR,CAAC;gBAED,KAAK,+BAAgB,CAAC,sBAAsB,CAAC;gBAC7C,KAAK,+BAAgB,CAAC,oBAAoB,CAAC;gBAC3C,KAAK,+BAAgB,CAAC,sBAAsB,CAAC,CAAC,CAAC;oBAC7C,qBAAa,CAAC,YAAY,GAAG,GAAG,CAAC;oBACjC,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,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 RpcInterface\r\n */\r\n\r\nimport { BeEvent, BentleyStatus, Guid } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { BackendError, IModelError, NoContentError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion } from \"./RpcProtocol\";\r\nimport { CURRENT_REQUEST } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n// cspell:ignore csrf\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\n/** @internal */\r\nexport const aggregateLoad = { lastRequest: 0, lastResponse: 0 };\r\n\r\n/** @internal */\r\nexport class ResponseLike implements Response {\r\n private _data: Promise<any>;\r\n public get body() { return null; }\r\n public async arrayBuffer(): Promise<ArrayBuffer> { return this._data; }\r\n public async blob(): Promise<Blob> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public async formData(): Promise<FormData> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public async json(): Promise<any> { return this._data; }\r\n public async text(): Promise<string> { return this._data; }\r\n public get bodyUsed() { return false; }\r\n public get headers(): Headers { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public get ok(): boolean { return this.status >= 200 && this.status <= 299; }\r\n public get redirected() { return false; }\r\n public get status() { return 200; }\r\n public get statusText() { return \"\"; }\r\n public get trailer(): Promise<Headers> { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n public get type(): \"basic\" | \"cors\" | \"default\" | \"error\" | \"opaque\" | \"opaqueredirect\" { return \"basic\"; }\r\n public get url() { return \"\"; }\r\n public clone() { return { ...this }; }\r\n\r\n public constructor(data: any) {\r\n this._data = Promise.resolve(data);\r\n }\r\n}\r\n\r\n/** Supplies an IModelRpcProps for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestTokenSupplier_T = (request: RpcRequest) => IModelRpcProps | undefined;\r\n\r\n/** Supplies the initial retry interval for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestInitialRetryIntervalSupplier_T = (configuration: RpcConfiguration) => number;\r\n\r\n/** Notification callback for an RPC request.\r\n * @internal\r\n */\r\nexport type RpcRequestCallback_T = (request: RpcRequest) => void;\r\n\r\n/** Determines if caching is permitted for a RPC response.\r\n * @internal\r\n */\r\nexport type RpcResponseCachingCallback_T = (request: RpcRequest) => RpcResponseCacheControl;\r\n\r\n/** Runtime information related to the operation load of one or more RPC interfaces.\r\n * @internal\r\n */\r\nexport interface RpcOperationsProfile {\r\n readonly lastRequest: number;\r\n readonly lastResponse: number;\r\n}\r\n\r\n/** Handles RPC request events.\r\n * @internal\r\n */\r\nexport type RpcRequestEventHandler = (type: RpcRequestEvent, request: RpcRequest) => void;\r\n\r\n/** Resolves \"not found\" responses for RPC requests.\r\n * @internal\r\n */\r\nexport type RpcRequestNotFoundHandler = (request: RpcRequest, response: RpcNotFoundResponse, resubmit: () => void, reject: (reason?: any) => void) => void;\r\n\r\nclass Cancellable<T> {\r\n public promise: Promise<T | undefined>;\r\n public cancel() { }\r\n\r\n public constructor(task: Promise<T>) {\r\n this.promise = new Promise((resolve, reject) => {\r\n this.cancel = () => resolve(undefined);\r\n task.then(resolve, reject);\r\n });\r\n }\r\n}\r\n\r\n/** A RPC operation request.\r\n * @internal\r\n */\r\nexport abstract class RpcRequest<TResponse = any> {\r\n private static _activeRequests: Map<string, RpcRequest> = new Map();\r\n private _resolve: (value?: TResponse | PromiseLike<TResponse> | undefined) => void = () => undefined;\r\n protected _resolveRaw: (value?: Response | PromiseLike<Response> | undefined) => void = () => undefined;\r\n private _reject: (reason?: any) => void = () => undefined;\r\n private _rejectRaw: (reason?: any) => void = () => undefined;\r\n private _created: number = 0;\r\n private _lastSubmitted: number = 0;\r\n private _lastUpdated: number = 0;\r\n\r\n /** @internal */\r\n public _status: RpcRequestStatus = RpcRequestStatus.Unknown;\r\n\r\n /** @internal */\r\n public _extendedStatus: string = \"\";\r\n\r\n private _connecting: boolean = false;\r\n private _active: boolean = true;\r\n private _hasRawListener = false;\r\n private _raw: ArrayBuffer | string | undefined = undefined;\r\n private _sending?: Cancellable<number>;\r\n private _attempts = 0;\r\n private _retryAfter: number | null = null;\r\n private _transientFaults = 0;\r\n protected _response: Response | undefined = undefined;\r\n protected _rawPromise: Promise<Response | undefined>;\r\n public responseProtocolVersion = RpcProtocolVersion.None;\r\n\r\n /** All RPC requests that are currently in flight. */\r\n public static get activeRequests(): ReadonlyMap<string, RpcRequest> { return this._activeRequests; }\r\n\r\n /** Events raised by RpcRequest. See [[RpcRequestEvent]] */\r\n public static readonly events: BeEvent<RpcRequestEventHandler> = new BeEvent();\r\n\r\n /** Resolvers for \"not found\" requests. See [[RpcRequestNotFoundHandler]] */\r\n public static readonly notFoundHandlers: BeEvent<RpcRequestNotFoundHandler> = new BeEvent();\r\n\r\n /** The aggregate operations profile of all active RPC interfaces. */\r\n public static get aggregateLoad(): RpcOperationsProfile { return aggregateLoad; }\r\n\r\n /**\r\n * The request for the current RPC operation.\r\n * @note The return value of this function is only reliable if program control was received from a RPC interface class member function that directly returns the result of calling RpcInterface.forward.\r\n */\r\n public static current(context: RpcInterface): RpcRequest {\r\n return (context as any)[CURRENT_REQUEST];\r\n }\r\n\r\n /** The unique identifier of this request. */\r\n public readonly id: string;\r\n\r\n /** The operation for this request. */\r\n public readonly operation: RpcOperation;\r\n\r\n /** The parameters for this request. */\r\n public parameters: any[];\r\n\r\n /** The RPC client instance for this request. */\r\n public readonly client: RpcInterface;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The implementation response for this request. */\r\n public readonly response: Promise<TResponse | undefined>;\r\n\r\n /** The status of this request. */\r\n public get status() { return this._status; }\r\n\r\n /** Extended status information for this request (if available). */\r\n public get extendedStatus() { return this._extendedStatus; }\r\n\r\n /** The last submission for this request. */\r\n public get lastSubmitted() { return this._lastSubmitted; }\r\n\r\n /** The last status update received for this request. */\r\n public get lastUpdated() { return this._lastUpdated; }\r\n\r\n /** The target interval (in milliseconds) between submission attempts for this request. */\r\n public retryInterval: number;\r\n\r\n /** Whether a connection is active for this request. */\r\n public get connecting() { return this._connecting; }\r\n\r\n /** Whether this request is pending. */\r\n public get pending(): boolean {\r\n switch (this.status) {\r\n case RpcRequestStatus.Submitted:\r\n case RpcRequestStatus.Pending: {\r\n return true;\r\n }\r\n\r\n default: {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /** The elapsed time for this request. */\r\n public get elapsed(): number {\r\n return this._lastUpdated - this._created;\r\n }\r\n\r\n /** A protocol-specific path identifier for this request. */\r\n public path: string;\r\n\r\n /** A protocol-specific method identifier for this request. */\r\n public method: string;\r\n\r\n /** An attempt-specific value for when to next retry this request. */\r\n public get retryAfter() { return this._retryAfter; }\r\n\r\n /** Finds the first parameter of a given structural type if present. */\r\n public findParameterOfType<T>(requiredProperties: { [index: string]: string }): T | undefined {\r\n for (const param of this.parameters) {\r\n if (typeof (param) === \"object\" && param !== null) {\r\n for (const prop of Object.getOwnPropertyNames(requiredProperties)) {\r\n if (prop in param && typeof (param[prop]) === requiredProperties[prop]) {\r\n return param;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Finds the first IModelRpcProps parameter if present. */\r\n public findTokenPropsParameter(): IModelRpcProps | undefined {\r\n return this.findParameterOfType({ iModelId: \"string\" });\r\n\r\n }\r\n\r\n /** The raw implementation response for this request. */\r\n public get rawResponse(): Promise<Response | undefined> {\r\n this._hasRawListener = true;\r\n return this._rawPromise;\r\n }\r\n\r\n /** Constructs an RPC request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n this._created = new Date().getTime();\r\n this.path = \"\";\r\n this.method = \"\";\r\n this.client = client;\r\n this.protocol = client.configuration.protocol;\r\n this.operation = RpcOperation.lookup(client.constructor as any, operation);\r\n this.parameters = parameters;\r\n this.retryInterval = this.operation.policy.retryInterval(client.configuration);\r\n this.response = new Promise((resolve, reject) => {\r\n this._resolve = resolve;\r\n this._reject = reject;\r\n });\r\n\r\n this._rawPromise = new Promise((resolve, reject) => {\r\n this._resolveRaw = resolve;\r\n this._rejectRaw = reject;\r\n });\r\n\r\n this.id = RpcConfiguration.requestContext.getId(this) || Guid.createValue();\r\n this.setStatus(RpcRequestStatus.Created);\r\n this.operation.policy.requestCallback(this);\r\n }\r\n\r\n /** Override to send the request. */\r\n protected abstract send(): Promise<number>;\r\n\r\n /** Override to load response value. */\r\n protected abstract load(): Promise<RpcSerializedValue>;\r\n\r\n /** Override to set request header values. */\r\n protected abstract setHeader(name: string, value: string): void;\r\n\r\n /** Sets the last updated time for the request. */\r\n protected setLastUpdatedTime() {\r\n this._lastUpdated = new Date().getTime();\r\n }\r\n\r\n protected computeRetryAfter(attempts: number) {\r\n return (((Math.pow(2, attempts) - 1) / 2) * 500) + 500;\r\n }\r\n\r\n protected recordTransientFault() {\r\n ++this._transientFaults;\r\n }\r\n\r\n protected resetTransientFaultCount() {\r\n this._transientFaults = 0;\r\n }\r\n\r\n protected supportsStatusCategory() {\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.responseProtocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n /* @internal */\r\n public cancel() {\r\n if (typeof (this._sending) === \"undefined\") {\r\n return;\r\n }\r\n\r\n this._sending.cancel();\r\n this._sending = undefined;\r\n\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.setStatus(RpcRequestStatus.Cancelled);\r\n }\r\n\r\n /* @internal */\r\n public async submit(): Promise<void> {\r\n if (!this._active)\r\n return;\r\n\r\n this._lastSubmitted = new Date().getTime();\r\n this._retryAfter = null;\r\n ++this._attempts;\r\n\r\n if (this.status === RpcRequestStatus.Created || this.status === RpcRequestStatus.NotFound || this.status === RpcRequestStatus.Cancelled) {\r\n this.setStatus(RpcRequestStatus.Submitted);\r\n }\r\n\r\n try {\r\n this._connecting = true;\r\n RpcRequest._activeRequests.set(this.id, this);\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestCreated, this);\r\n this._sending = new Cancellable(this.setHeaders().then(async () => this.send()));\r\n this.operation.policy.sentCallback(this);\r\n\r\n const response = await this._sending.promise;\r\n if (typeof (response) === \"undefined\") {\r\n return;\r\n }\r\n this._sending = undefined;\r\n\r\n const status = this.protocol.getStatus(response);\r\n\r\n if (this._hasRawListener && status === RpcRequestStatus.Resolved && typeof (this._response) !== \"undefined\") {\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.resolveRaw();\r\n } else {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoading, this);\r\n\r\n if (status === RpcRequestStatus.Unknown) {\r\n this._connecting = false;\r\n RpcRequest._activeRequests.delete(this.id);\r\n this.handleUnknownResponse(response);\r\n return;\r\n }\r\n\r\n const value = await this.load();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n RpcRequest._activeRequests.delete(this.id);\r\n this._connecting = false;\r\n this.handleResponse(response, value);\r\n }\r\n } catch (err) {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ConnectionErrorReceived, this, err);\r\n RpcRequest._activeRequests.delete(this.id);\r\n this._connecting = false;\r\n this.reject(err);\r\n }\r\n }\r\n\r\n protected handleUnknownResponse(code: number) {\r\n this.reject(new IModelError(BentleyStatus.ERROR, `Unknown response ${code}.`));\r\n }\r\n\r\n private handleResponse(code: number, value: RpcSerializedValue) {\r\n const protocolStatus = this.protocol.getStatus(code);\r\n const status = this.transformResponseStatus(protocolStatus, value);\r\n\r\n if (RpcRequestStatus.isTransientError(status)) {\r\n return this.handleTransientError(status);\r\n }\r\n\r\n switch (status) {\r\n case RpcRequestStatus.Resolved: {\r\n return this.handleResolved(value);\r\n }\r\n\r\n case RpcRequestStatus.Rejected: {\r\n return this.handleRejected(value);\r\n }\r\n\r\n case RpcRequestStatus.Pending: {\r\n return this.setPending(status, value.objects);\r\n }\r\n\r\n case RpcRequestStatus.NotFound: {\r\n return this.handleNotFound(status, value);\r\n }\r\n\r\n case RpcRequestStatus.NoContent: {\r\n return this.handleNoContent();\r\n }\r\n }\r\n }\r\n\r\n private transformResponseStatus(protocolStatus: RpcRequestStatus, value: RpcSerializedValue): RpcRequestStatus {\r\n if (!this.supportsStatusCategory()) {\r\n return protocolStatus;\r\n }\r\n\r\n let status = protocolStatus;\r\n\r\n if (protocolStatus === RpcRequestStatus.Pending) {\r\n status = RpcRequestStatus.Rejected;\r\n } else if (protocolStatus === RpcRequestStatus.NotFound) {\r\n status = RpcRequestStatus.Rejected;\r\n } else if (protocolStatus === RpcRequestStatus.Unknown) {\r\n status = RpcRequestStatus.Rejected;\r\n }\r\n\r\n if (value.objects.indexOf(\"iTwinRpcCoreResponse\") !== -1 && value.objects.indexOf(\"managedStatus\") !== -1) {\r\n const managedStatus: RpcManagedStatus = JSON.parse(value.objects);\r\n value.objects = managedStatus.responseValue as string;\r\n\r\n if (managedStatus.managedStatus === \"pending\") {\r\n status = RpcRequestStatus.Pending;\r\n } else if (managedStatus.managedStatus === \"notFound\") {\r\n status = RpcRequestStatus.NotFound;\r\n }\r\n }\r\n\r\n return status;\r\n }\r\n\r\n private handleResolved(value: RpcSerializedValue) {\r\n try {\r\n this._raw = value.objects;\r\n const result: TResponse = RpcMarshaling.deserialize(this.protocol, value);\r\n\r\n if (ArrayBuffer.isView(result)) {\r\n this._raw = result.buffer;\r\n }\r\n\r\n return this.resolve(result);\r\n } catch (err) {\r\n return this.reject(err);\r\n }\r\n }\r\n\r\n private handleRejected(value: RpcSerializedValue) {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorReceived, this);\r\n\r\n try {\r\n const error = RpcMarshaling.deserialize(this.protocol, value);\r\n const hasInfo = error && typeof (error) === \"object\" && error.hasOwnProperty(\"name\") && error.hasOwnProperty(\"message\");\r\n const name = hasInfo ? error.name : \"\";\r\n const message = hasInfo ? error.message : \"\";\r\n const errorNumber = (hasInfo && error.hasOwnProperty(\"errorNumber\")) ? error.errorNumber : BentleyStatus.ERROR;\r\n return this.reject(new BackendError(errorNumber, name, message, () => error));\r\n } catch (err) {\r\n return this.reject(err);\r\n }\r\n }\r\n\r\n private handleNoContent() {\r\n return this.reject(new NoContentError());\r\n }\r\n\r\n private handleNotFound(status: RpcRequestStatus, value: RpcSerializedValue) {\r\n if (RpcRequest.notFoundHandlers.numberOfListeners === 0)\r\n this.handleRejected(value);\r\n\r\n const response = RpcMarshaling.deserialize(this.protocol, value);\r\n this.setStatus(status);\r\n\r\n let resubmitted = false;\r\n RpcRequest.notFoundHandlers.raiseEvent(this, response, () => {\r\n if (resubmitted)\r\n throw new IModelError(BentleyStatus.ERROR, `Already resubmitted using this handler.`);\r\n\r\n resubmitted = true;\r\n void this.submit();\r\n }, (reason: any) => reason ? this.reject(reason) : this.handleRejected(value));\r\n return;\r\n }\r\n\r\n private resolve(result: TResponse): void {\r\n if (!this._active)\r\n return;\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._resolve(result);\r\n\r\n if (this._hasRawListener) {\r\n if (typeof (this._raw) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot access raw response.\");\r\n }\r\n\r\n this._resolveRaw(new ResponseLike(this._raw));\r\n }\r\n\r\n this.setStatus(RpcRequestStatus.Resolved);\r\n this[Symbol.dispose]();\r\n }\r\n\r\n private resolveRaw() {\r\n if (typeof (this._response) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot access raw response.\");\r\n }\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._resolveRaw(this._response);\r\n this.setStatus(RpcRequestStatus.Resolved);\r\n this[Symbol.dispose]();\r\n }\r\n\r\n protected reject(reason: any): void {\r\n if (!this._active)\r\n return;\r\n\r\n this._active = false;\r\n this.setLastUpdatedTime();\r\n this._reject(reason);\r\n\r\n if (this._hasRawListener) {\r\n this._rejectRaw(reason);\r\n }\r\n\r\n this.setStatus(RpcRequestStatus.Rejected);\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** @internal */\r\n public [Symbol.dispose](): void {\r\n this.setStatus(RpcRequestStatus.Disposed);\r\n this._raw = undefined;\r\n this._response = undefined;\r\n\r\n const client = this.client as any;\r\n if (client[CURRENT_REQUEST] === this) {\r\n client[CURRENT_REQUEST] = undefined;\r\n }\r\n }\r\n\r\n private setPending(status: RpcRequestStatus.Pending, extendedStatus: string): void {\r\n if (!this._active)\r\n return;\r\n\r\n this.setLastUpdatedTime();\r\n this._extendedStatus = extendedStatus;\r\n this.setStatus(status);\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.PendingUpdateReceived, this);\r\n }\r\n\r\n private handleTransientError(status: RpcRequestStatus) {\r\n if (!this._active)\r\n return;\r\n\r\n this.setLastUpdatedTime();\r\n this._retryAfter = this.computeRetryAfter(this._attempts - 1);\r\n\r\n if (this._transientFaults > this.protocol.configuration.transientFaultLimit) {\r\n this.reject(new IModelError(BentleyStatus.ERROR, `Exceeded transient fault limit.`));\r\n } else {\r\n this.setStatus(status);\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.TransientErrorReceived, this);\r\n }\r\n }\r\n\r\n protected async setHeaders(): Promise<void> {\r\n const versionHeader = this.protocol.protocolVersionHeaderName;\r\n if (versionHeader && RpcProtocol.protocolVersion)\r\n this.setHeader(versionHeader, RpcProtocol.protocolVersion.toString());\r\n\r\n const headerNames = this.protocol.serializedClientRequestContextHeaderNames;\r\n const headerValues = await RpcConfiguration.requestContext.serialize(this);\r\n\r\n if (headerNames.id)\r\n this.setHeader(headerNames.id, headerValues.id || this.id); // Cannot be empty\r\n\r\n if (headerNames.applicationVersion)\r\n this.setHeader(headerNames.applicationVersion, headerValues.applicationVersion);\r\n\r\n if (headerNames.applicationId)\r\n this.setHeader(headerNames.applicationId, headerValues.applicationId);\r\n\r\n if (headerNames.sessionId)\r\n this.setHeader(headerNames.sessionId, headerValues.sessionId);\r\n\r\n if (headerNames.authorization && headerValues.authorization)\r\n this.setHeader(headerNames.authorization, headerValues.authorization);\r\n\r\n if (headerValues.csrfToken)\r\n this.setHeader(headerValues.csrfToken.headerName, headerValues.csrfToken.headerValue);\r\n }\r\n\r\n private setStatus(status: RpcRequestStatus): void {\r\n if (this._status === status)\r\n return;\r\n\r\n this._status = status;\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.StatusChanged, this);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport const initializeRpcRequest = (() => {\r\n let initialized = false;\r\n\r\n return () => {\r\n if (initialized) {\r\n return;\r\n }\r\n\r\n initialized = true;\r\n\r\n RpcRequest.events.addListener((type, request) => {\r\n if (type !== RpcRequestEvent.StatusChanged)\r\n return;\r\n\r\n switch (request.status) {\r\n case RpcRequestStatus.Submitted: {\r\n aggregateLoad.lastRequest = request.lastSubmitted;\r\n break;\r\n }\r\n\r\n case RpcRequestStatus.Pending:\r\n case RpcRequestStatus.Resolved:\r\n case RpcRequestStatus.Rejected: {\r\n aggregateLoad.lastResponse = request.lastUpdated;\r\n break;\r\n }\r\n }\r\n });\r\n\r\n RpcProtocol.events.addListener((type) => {\r\n const now = new Date().getTime();\r\n\r\n switch (type) {\r\n case RpcProtocolEvent.RequestReceived: {\r\n aggregateLoad.lastRequest = now;\r\n break;\r\n }\r\n\r\n case RpcProtocolEvent.BackendReportedPending:\r\n case RpcProtocolEvent.BackendErrorOccurred:\r\n case RpcProtocolEvent.BackendResponseCreated: {\r\n aggregateLoad.lastResponse = now;\r\n break;\r\n }\r\n }\r\n });\r\n };\r\n})();\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcRequestContext.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequestContext.ts"],"names":[],"mappings":"","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/** @packageDocumentation\n * @module RpcInterface\n */\nimport { SerializedRpcActivity } from \"./RpcInvocation\";\nimport { RpcRequest } from \"./RpcRequest\";\n\n/** Interface to enable passing application-specific context with each RPC request.\n * @internal\n */\nexport interface RpcRequestContext {\n /** Used to get the id of the request at the frontend */\n getId: (request: RpcRequest) => string;\n\n /** Used at frontend to serialize client specified context */\n serialize: (request: RpcRequest) => Promise<SerializedRpcActivity>;\n}\n"]}
1
+ {"version":3,"file":"RpcRequestContext.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequestContext.ts"],"names":[],"mappings":"","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 RpcInterface\r\n */\r\nimport { SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/** Interface to enable passing application-specific context with each RPC request.\r\n * @internal\r\n */\r\nexport interface RpcRequestContext {\r\n /** Used to get the id of the request at the frontend */\r\n getId: (request: RpcRequest) => string;\r\n\r\n /** Used at frontend to serialize client specified context */\r\n serialize: (request: RpcRequest) => Promise<SerializedRpcActivity>;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcRoutingToken.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRoutingToken.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,YAAY;AACZ,MAAa,eAAe;IAClB,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAEnB,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,EAAE;QACpC,OAAO,IAAI,eAAe,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC;IAEM,MAAM,CAAU,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAErD,EAAE,CAAS;IACX,UAAU,CAAS;IAEnC,YAAoB,EAAU,EAAE,UAAkB;QAChD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;;AAfH,0CAgBC","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/** @packageDocumentation\n * @module RpcInterface\n */\n\n/** @beta */\nexport class RpcRoutingToken {\n private static _next = -1;\n\n public static generate(debugLabel = \"\"): RpcRoutingToken {\n return new RpcRoutingToken(++this._next, debugLabel);\n }\n\n public static readonly default = RpcRoutingToken.generate(\"default\");\n\n public readonly id: number;\n public readonly debugLabel: string;\n\n private constructor(id: number, debugLabel: string) {\n this.id = id;\n this.debugLabel = debugLabel;\n }\n}\n"]}
1
+ {"version":3,"file":"RpcRoutingToken.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRoutingToken.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,YAAY;AACZ,MAAa,eAAe;IAClB,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAEnB,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,EAAE;QACpC,OAAO,IAAI,eAAe,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC;IAEM,MAAM,CAAU,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAErD,EAAE,CAAS;IACX,UAAU,CAAS;IAEnC,YAAoB,EAAU,EAAE,UAAkB;QAChD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;;AAfH,0CAgBC","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 RpcInterface\r\n */\r\n\r\n/** @beta */\r\nexport class RpcRoutingToken {\r\n private static _next = -1;\r\n\r\n public static generate(debugLabel = \"\"): RpcRoutingToken {\r\n return new RpcRoutingToken(++this._next, debugLabel);\r\n }\r\n\r\n public static readonly default = RpcRoutingToken.generate(\"default\");\r\n\r\n public readonly id: number;\r\n public readonly debugLabel: string;\r\n\r\n private constructor(id: number, debugLabel: string) {\r\n this.id = id;\r\n this.debugLabel = debugLabel;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcSessionInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcSessionInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,yDAAsD;AACtD,iDAA2E;AAC3E,mDAAgD;AAChD,mDAAqD;AACrD,+CAAkE;AAClE,6CAA0C;AAE1C,qDAAqD;AAErD,MAAM,oBAAqB,SAAQ,mCAAgB;IAC1C,UAAU,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC;IAC7B,IAAW,QAAQ,KAAK,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,eAAgB,SAAQ,yBAAW;IAChC,MAAM,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,WAAW,GAAG,uBAAU,CAAC;IAChB,sBAAsB,GAAG,IAAI,CAAC;IAC9C,gBAAgB,KAAK,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,CAAC;;AAGtD,gBAAgB;AAChB,MAAa,oBAAqB,SAAQ,6BAAa;IAC9C,MAAM,CAAC,MAAM,CAAC,OAA8B;QACjD,MAAM,iBAAiB,GAAyB;YAC9C,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;YACtB,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa;YAC5C,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,kBAAkB;YACtD,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS;YACpC,aAAa,EAAE,EAAE;YACjB,SAAS,EAAE;gBACT,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC,aAAa;gBACrD,gBAAgB,EAAE,OAAO,CAAC,UAAU,CAAC,gBAAgB;gBACrD,aAAa,EAAE,OAAO,CAAC,SAAS;aACjC;YACD,MAAM,EAAE,OAAO,CAAC,SAAS;YACzB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,kCAAkB,CAAC,MAAM,EAAE;YACvC,kBAAkB,EAAE,OAAO,CAAC,UAAU;YACtC,OAAO,EAAE,sCAAuB,CAAC,IAAI;YACrC,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;SAC/D,CAAC;QAEF,OAAO,IAAI,oBAAoB,CAAC,eAAe,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAC/E,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,MAAM,KAAK,+BAAgB,CAAC,QAAQ,CAAC;IACnD,CAAC;CACF;AA3BD,oDA2BC","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/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { InterceptedRpcRequest } from \"../../ipc/IpcSession\";\nimport { RpcConfiguration } from \"./RpcConfiguration\";\nimport { RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\nimport { RpcInvocation } from \"./RpcInvocation\";\nimport { RpcSerializedValue } from \"./RpcMarshaling\";\nimport { RpcProtocol, SerializedRpcRequest } from \"./RpcProtocol\";\nimport { RpcRequest } from \"./RpcRequest\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nclass SessionConfiguration extends RpcConfiguration {\n public interfaces = () => [];\n public get protocol() { return SessionProtocol.instance; }\n}\n\nclass SessionProtocol extends RpcProtocol {\n public static instance = new SessionProtocol();\n public requestType = RpcRequest;\n public override supportsStatusCategory = true;\n constructor() { super(new SessionConfiguration()); }\n}\n\n/** @internal */\nexport class RpcSessionInvocation extends RpcInvocation {\n public static create(request: InterceptedRpcRequest): RpcSessionInvocation {\n const serializedRequest: SerializedRpcRequest = {\n id: request.context.id,\n applicationId: request.context.applicationId,\n applicationVersion: request.context.applicationVersion,\n sessionId: request.context.sessionId,\n authorization: \"\",\n operation: {\n interfaceDefinition: request.definition.interfaceName,\n interfaceVersion: request.definition.interfaceVersion,\n operationName: request.operation,\n },\n method: request.operation,\n path: \"\",\n parameters: RpcSerializedValue.create(),\n parametersOverride: request.parameters,\n caching: RpcResponseCacheControl.None,\n protocolVersion: parseInt(request.context.protocolVersion, 10),\n };\n\n return new RpcSessionInvocation(SessionProtocol.instance, serializedRequest);\n }\n\n public get rejected() {\n return this.status === RpcRequestStatus.Rejected;\n }\n}\n"]}
1
+ {"version":3,"file":"RpcSessionInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcSessionInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,yDAAsD;AACtD,iDAA2E;AAC3E,mDAAgD;AAChD,mDAAqD;AACrD,+CAAkE;AAClE,6CAA0C;AAE1C,qDAAqD;AAErD,MAAM,oBAAqB,SAAQ,mCAAgB;IAC1C,UAAU,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC;IAC7B,IAAW,QAAQ,KAAK,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,eAAgB,SAAQ,yBAAW;IAChC,MAAM,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,WAAW,GAAG,uBAAU,CAAC;IAChB,sBAAsB,GAAG,IAAI,CAAC;IAC9C,gBAAgB,KAAK,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,CAAC;;AAGtD,gBAAgB;AAChB,MAAa,oBAAqB,SAAQ,6BAAa;IAC9C,MAAM,CAAC,MAAM,CAAC,OAA8B;QACjD,MAAM,iBAAiB,GAAyB;YAC9C,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;YACtB,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa;YAC5C,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,kBAAkB;YACtD,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS;YACpC,aAAa,EAAE,EAAE;YACjB,SAAS,EAAE;gBACT,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC,aAAa;gBACrD,gBAAgB,EAAE,OAAO,CAAC,UAAU,CAAC,gBAAgB;gBACrD,aAAa,EAAE,OAAO,CAAC,SAAS;aACjC;YACD,MAAM,EAAE,OAAO,CAAC,SAAS;YACzB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,kCAAkB,CAAC,MAAM,EAAE;YACvC,kBAAkB,EAAE,OAAO,CAAC,UAAU;YACtC,OAAO,EAAE,sCAAuB,CAAC,IAAI;YACrC,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;SAC/D,CAAC;QAEF,OAAO,IAAI,oBAAoB,CAAC,eAAe,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAC/E,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,MAAM,KAAK,+BAAgB,CAAC,QAAQ,CAAC;IACnD,CAAC;CACF;AA3BD,oDA2BC","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 RpcInterface\r\n */\r\n\r\nimport { InterceptedRpcRequest } from \"../../ipc/IpcSession\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcProtocol, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\nclass SessionConfiguration extends RpcConfiguration {\r\n public interfaces = () => [];\r\n public get protocol() { return SessionProtocol.instance; }\r\n}\r\n\r\nclass SessionProtocol extends RpcProtocol {\r\n public static instance = new SessionProtocol();\r\n public requestType = RpcRequest;\r\n public override supportsStatusCategory = true;\r\n constructor() { super(new SessionConfiguration()); }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcSessionInvocation extends RpcInvocation {\r\n public static create(request: InterceptedRpcRequest): RpcSessionInvocation {\r\n const serializedRequest: SerializedRpcRequest = {\r\n id: request.context.id,\r\n applicationId: request.context.applicationId,\r\n applicationVersion: request.context.applicationVersion,\r\n sessionId: request.context.sessionId,\r\n authorization: \"\",\r\n operation: {\r\n interfaceDefinition: request.definition.interfaceName,\r\n interfaceVersion: request.definition.interfaceVersion,\r\n operationName: request.operation,\r\n },\r\n method: request.operation,\r\n path: \"\",\r\n parameters: RpcSerializedValue.create(),\r\n parametersOverride: request.parameters,\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: parseInt(request.context.protocolVersion, 10),\r\n };\r\n\r\n return new RpcSessionInvocation(SessionProtocol.instance, serializedRequest);\r\n }\r\n\r\n public get rejected() {\r\n return this.status === RpcRequestStatus.Rejected;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BentleyCloudRpcManager.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,iDAA8C;AAC9C,+DAA4D;AAC5D,uDAAuD;AACvD,mDAAwE;AACxE,uEAAoE;AAEpE,6DAA0D;AAoB1D;;GAEG;AACH,MAAsB,4BAA6B,SAAQ,mCAAgB;IACzE,2GAA2G;IACpG,MAAM,CAAU,aAAa,GAAG;QACrC,WAAW,EAAE,GAAG;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C,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACnD,CAAC;QAED,mCAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEhD,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;YAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,sBAAsB,CAAC;YAE/C,uBAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;gBAC9C,IAAI,IAAI,KAAK,8BAAe,CAAC,qBAAqB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAC;oBAC7F,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA/CD,wDA+CC","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/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\nimport { RpcManager } from \"../../RpcManager\";\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\nimport { RpcRequestEvent } from \"../core/RpcConstants\";\nimport { RpcRequest, RpcRequestEventHandler } from \"../core/RpcRequest\";\nimport { BentleyCloudRpcProtocol } from \"./BentleyCloudRpcProtocol\";\nimport { OpenAPIInfo } from \"./OpenAPI\";\nimport { RpcRoutingToken } from \"../core/RpcRoutingToken\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Initialization parameters for BentleyCloudRpcConfiguration.\n * @beta\n */\nexport interface BentleyCloudRpcParams {\n /** Identifies the remote server that implements a set of RpcInterfaces. Note that the ID of the remote server is not a URI or hostname. It is a string that matches a key in the orchestrator's app registry. */\n info: OpenAPIInfo;\n /** @internal The protocol for Bentley cloud RPC interface deployments */\n protocol?: typeof BentleyCloudRpcProtocol;\n /** The URI of the orchestrator that will route requests to the remote RpcInterface server. If not supplied, this default to the origin of the Web page. This is required only when calling initializeClient and only if the server is not the origin of the Web page. */\n uriPrefix?: string;\n /** @internal Handler for RPC request events. */\n pendingRequestListener?: RpcRequestEventHandler;\n /** An optional prefix for RPC operation URI paths. */\n pathPrefix?: string;\n}\n\n/** Operating parameters for Bentley cloud RPC interface deployments.\n * @beta\n */\nexport abstract class BentleyCloudRpcConfiguration extends RpcConfiguration {\n /** Access-Control header values for backend servers that serve frontends using BentleyCloudRpcProtocol. */\n public static readonly accessControl = {\n allowOrigin: \"*\",\n allowMethods: \"POST, GET, OPTIONS\",\n allowHeaders: \"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, X-Correlation-Id, X-Session-Id, X-Application-Id, X-Application-Version, X-User-Id, X-Protocol-Version\",\n };\n\n /** @internal The protocol of the configuration. */\n public abstract override readonly protocol: BentleyCloudRpcProtocol;\n}\n\n/** Coordinates usage of RPC interfaces for Bentley cloud deployments.\n * @beta\n */\nexport class BentleyCloudRpcManager extends RpcManager {\n /** @beta Initializes BentleyCloudRpcManager for the frontend of an application. */\n public static initializeClient(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[], routing: RpcRoutingToken = RpcRoutingToken.default): BentleyCloudRpcConfiguration {\n return BentleyCloudRpcManager.performInitialization(params, interfaces, routing);\n }\n\n /** @beta Initializes BentleyCloudRpcManager for the backend of an application. */\n public static initializeImpl(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[]): BentleyCloudRpcConfiguration {\n return BentleyCloudRpcManager.performInitialization(params, interfaces);\n }\n\n private static performInitialization(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[], routing: RpcRoutingToken = RpcRoutingToken.default): BentleyCloudRpcConfiguration {\n const protocol = class extends (params.protocol || BentleyCloudRpcProtocol) {\n public override pathPrefix = params.uriPrefix || \"\";\n public info = params.info;\n };\n\n const config = class extends BentleyCloudRpcConfiguration {\n public interfaces = () => interfaces;\n public protocol: BentleyCloudRpcProtocol = new protocol(this);\n public override routing = routing;\n };\n\n for (const def of interfaces) {\n RpcConfiguration.assignWithRouting(def, routing, config);\n }\n\n const instance = RpcConfiguration.obtain(config);\n\n if (params.pathPrefix) {\n instance.protocol.pathPrefix = params.pathPrefix;\n }\n\n RpcConfiguration.initializeInterfaces(instance);\n\n if (params.pendingRequestListener) {\n const listener = params.pendingRequestListener;\n\n RpcRequest.events.addListener((type, request) => {\n if (type === RpcRequestEvent.PendingUpdateReceived && request.protocol === instance.protocol) {\n listener(type, request);\n }\n });\n }\n\n return instance;\n }\n}\n"]}
1
+ {"version":3,"file":"BentleyCloudRpcManager.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,iDAA8C;AAC9C,+DAA4D;AAC5D,uDAAuD;AACvD,mDAAwE;AACxE,uEAAoE;AAEpE,6DAA0D;AAoB1D;;GAEG;AACH,MAAsB,4BAA6B,SAAQ,mCAAgB;IACzE,2GAA2G;IACpG,MAAM,CAAU,aAAa,GAAG;QACrC,WAAW,EAAE,GAAG;QAChB,YAAY,EAAE,oBAAoB;QAClC,YAAY,EAAE,qLAAqL;KACpM,CAAC;;AANJ,oEAUC;AAED;;GAEG;AACH,MAAa,sBAAuB,SAAQ,uBAAU;IACpD,mFAAmF;IAC5E,MAAM,CAAC,gBAAgB,CAAC,MAA6B,EAAE,UAAoC,EAAE,UAA2B,iCAAe,CAAC,OAAO;QACpJ,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACnF,CAAC;IAED,kFAAkF;IAC3E,MAAM,CAAC,cAAc,CAAC,MAA6B,EAAE,UAAoC;QAC9F,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;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YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA/CD,wDA+CC","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 RpcInterface\r\n */\r\n\r\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcRequestEvent } from \"../core/RpcConstants\";\r\nimport { RpcRequest, RpcRequestEventHandler } from \"../core/RpcRequest\";\r\nimport { BentleyCloudRpcProtocol } from \"./BentleyCloudRpcProtocol\";\r\nimport { OpenAPIInfo } from \"./OpenAPI\";\r\nimport { RpcRoutingToken } from \"../core/RpcRoutingToken\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\n/** Initialization parameters for BentleyCloudRpcConfiguration.\r\n * @beta\r\n */\r\nexport interface BentleyCloudRpcParams {\r\n /** Identifies the remote server that implements a set of RpcInterfaces. Note that the ID of the remote server is not a URI or hostname. It is a string that matches a key in the orchestrator's app registry. */\r\n info: OpenAPIInfo;\r\n /** @internal The protocol for Bentley cloud RPC interface deployments */\r\n protocol?: typeof BentleyCloudRpcProtocol;\r\n /** The URI of the orchestrator that will route requests to the remote RpcInterface server. If not supplied, this default to the origin of the Web page. This is required only when calling initializeClient and only if the server is not the origin of the Web page. */\r\n uriPrefix?: string;\r\n /** @internal Handler for RPC request events. */\r\n pendingRequestListener?: RpcRequestEventHandler;\r\n /** An optional prefix for RPC operation URI paths. */\r\n pathPrefix?: string;\r\n}\r\n\r\n/** Operating parameters for Bentley cloud RPC interface deployments.\r\n * @beta\r\n */\r\nexport abstract class BentleyCloudRpcConfiguration extends RpcConfiguration {\r\n /** Access-Control header values for backend servers that serve frontends using BentleyCloudRpcProtocol. */\r\n public static readonly accessControl = {\r\n allowOrigin: \"*\",\r\n allowMethods: \"POST, GET, OPTIONS\",\r\n allowHeaders: \"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, X-Correlation-Id, X-Session-Id, X-Application-Id, X-Application-Version, X-User-Id, X-Protocol-Version\",\r\n };\r\n\r\n /** @internal The protocol of the configuration. */\r\n public abstract override readonly protocol: BentleyCloudRpcProtocol;\r\n}\r\n\r\n/** Coordinates usage of RPC interfaces for Bentley cloud deployments.\r\n * @beta\r\n */\r\nexport class BentleyCloudRpcManager extends RpcManager {\r\n /** @beta Initializes BentleyCloudRpcManager for the frontend of an application. */\r\n public static initializeClient(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[], routing: RpcRoutingToken = RpcRoutingToken.default): BentleyCloudRpcConfiguration {\r\n return BentleyCloudRpcManager.performInitialization(params, interfaces, routing);\r\n }\r\n\r\n /** @beta Initializes BentleyCloudRpcManager for the backend of an application. */\r\n public static initializeImpl(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[]): BentleyCloudRpcConfiguration {\r\n return BentleyCloudRpcManager.performInitialization(params, interfaces);\r\n }\r\n\r\n private static performInitialization(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[], routing: RpcRoutingToken = RpcRoutingToken.default): BentleyCloudRpcConfiguration {\r\n const protocol = class extends (params.protocol || BentleyCloudRpcProtocol) {\r\n public override pathPrefix = params.uriPrefix || \"\";\r\n public info = params.info;\r\n };\r\n\r\n const config = class extends BentleyCloudRpcConfiguration {\r\n public interfaces = () => interfaces;\r\n public protocol: BentleyCloudRpcProtocol = new protocol(this);\r\n public override routing = routing;\r\n };\r\n\r\n for (const def of interfaces) {\r\n RpcConfiguration.assignWithRouting(def, routing, config);\r\n }\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n if (params.pathPrefix) {\r\n instance.protocol.pathPrefix = params.pathPrefix;\r\n }\r\n\r\n RpcConfiguration.initializeInterfaces(instance);\r\n\r\n if (params.pendingRequestListener) {\r\n const listener = params.pendingRequestListener;\r\n\r\n RpcRequest.events.addListener((type, request) => {\r\n if (type === RpcRequestEvent.PendingUpdateReceived && request.protocol === instance.protocol) {\r\n listener(type, request);\r\n }\r\n });\r\n }\r\n\r\n return instance;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BentleyCloudRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AAEpD,mDAAgD;AAChD,+DAA4D;AAC5D,uDAAoD;AAIpD,2DAAwD;AAGxD,IAAK,OAEJ;AAFD,WAAK,OAAO;IACV,gCAAqB,CAAA;AACvB,CAAC,EAFI,OAAO,KAAP,OAAO,QAEX;AAED;;GAEG;AACH,MAAsB,uBAAwB,SAAQ,qCAAiB;IACrD,UAAU,GAAG,IAAI,CAAC;IAElC,iFAAiF;IACjE,yCAAyC,GAA0B;QACjF,8CAA8C;QAC9C,EAAE,EAAE,kBAAkB;QAEtB,kDAAkD;QAClD,aAAa,EAAE,kBAAkB;QAEjC,uDAAuD;QACvD,kBAAkB,EAAE,uBAAuB;QAE3C,8CAA8C;QAC9C,SAAS,EAAE,cAAc;QAEzB,iDAAiD;QACjD,aAAa,EAAE,eAAe;KAC/B,CAAC;IAEF,mDAAmD;IACnC,yBAAyB,GAAG,oBAAoB,CAAC;IAEjE,yEAAyE;IACzD,oBAAoB,CAAC,IAAY;QAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,4BAA4B;QAEzF,MAAM,kBAAkB,GAAG,UAAU,C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AAC,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACvK,CAAC;IAED;;OAEG;IACI,gCAAgC,CAAC,UAAwB;QAC9D,OAAO;YACL,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC1E,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC3E,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC5E,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;SACjF,CAAC;IACJ,CAAC;CACF;AApID,0DAoIC","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/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelRpcProps } from \"../../IModel\";\nimport { IModelError } from \"../../IModelError\";\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\nimport { RpcOperation } from \"../core/RpcOperation\";\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { OpenAPIParameter } from \"./OpenAPI\";\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\n\nenum AppMode {\n MilestoneReview = \"1\",\n}\n\n/** An http protocol for Bentley cloud RPC interface deployments.\n * @internal\n */\nexport abstract class BentleyCloudRpcProtocol extends WebAppRpcProtocol {\n public override checkToken = true;\n\n /** The name of various HTTP request headers based on client's request context */\n public override serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\n /** The name of the HTTP request id header. */\n id: \"X-Correlation-Id\",\n\n /** The name of the HTTP application id header. */\n applicationId: \"X-Application-Id\",\n\n /** The name of the HTTP application version header. */\n applicationVersion: \"X-Application-Version\",\n\n /** The name of the HTTP session id header. */\n sessionId: \"X-Session-Id\",\n\n /** The name of the HTTP authorization header. */\n authorization: \"Authorization\",\n };\n\n /** The name of the RPC protocol version header. */\n public override protocolVersionHeaderName = \"X-Protocol-Version\";\n\n /** Returns the operation specified by an OpenAPI-compatible URI path. */\n public override getOperationFromPath(path: string): SerializedRpcOperation {\n const url = new URL(path, \"https://localhost/\");\n const components = url.pathname.split(\"/\").filter((x) => x); // filter out empty segments\n\n const operationComponent = components.slice(-1)[0];\n const encodedRequest = url.searchParams.get(\"parameters\") || \"\";\n\n // The encodedRequest should be base64 - fail now if any other characters detected.\n if (/[^a-zA-Z0-9=+\\/$]/.test(encodedRequest))\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Malformed URL parameters detected.`);\n\n const firstHyphen = operationComponent.indexOf(\"-\");\n const lastHyphen = operationComponent.lastIndexOf(\"-\");\n const interfaceDefinition = operationComponent.slice(0, firstHyphen);\n const interfaceVersion = operationComponent.slice(firstHyphen + 1, lastHyphen);\n const operationName = operationComponent.slice(lastHyphen + 1);\n\n return { interfaceDefinition, operationName, interfaceVersion, encodedRequest };\n }\n\n /** Supplies the OpenAPI-compatible URI path for an RPC operation. */\n public override supplyPathForOperation(operation: RpcOperation, request: RpcRequest | undefined) {\n const prefix = this.pathPrefix;\n const appTitle = this.info.title;\n const appVersion = this.info.version;\n const operationId = `${operation.interfaceDefinition.interfaceName}-${operation.interfaceVersion}-${operation.operationName}`;\n\n let appMode: string = \"\";\n let iTwinId: string = \"\";\n let iModelId: string = \"\";\n let routeChangesetId: string | undefined;\n /* Note: The changesetId field is omitted in the route in the case of ReadWrite connections since the connection is generally expected to be at the\n * latest version and not some specific changeset. Also, for the first version (before any changesets), the changesetId in the route is arbitrarily\n * set to \"0\" instead of an empty string, since the latter is more un-intuitive for a route. However, in all other use cases, including the changesetId\n * held by the IModelRpcProps itself, the changesetId of \"\" (i.e., empty string) signifies the first version - this is more intuitive and retains\n * compatibility with the majority of use cases. */\n\n if (request === undefined) {\n appMode = \"{modeId}\";\n iTwinId = \"{iTwinId}\";\n iModelId = \"{iModelId}\";\n routeChangesetId = \"{changeSetId}\";\n } else {\n let token = operation.policy.token(request) || RpcOperation.fallbackToken;\n\n if (!token || !token.iModelId) {\n if (RpcConfiguration.disableRoutingValidation) {\n token = { key: \"\" };\n } else {\n throw new IModelError(BentleyStatus.ERROR, \"Invalid iModelToken for RPC operation request\");\n }\n }\n\n iTwinId = encodeURIComponent(token.iTwinId || \"\");\n iModelId = encodeURIComponent(token.iModelId || \"\");\n\n routeChangesetId = token.changeset?.id || \"0\";\n appMode = AppMode.MilestoneReview;\n }\n\n return `${prefix}/${appTitle}/${appVersion}/mode/${appMode}/context/${iTwinId}/imodel/${iModelId}${!!routeChangesetId ? `/changeset/${routeChangesetId}` : \"\"}/${operationId}`;\n }\n\n /**\n * Inflates the IModelRpcProps from the URL path for each request on the backend.\n * @note This function updates the IModelRpcProps value supplied in the request body.\n */\n public override inflateToken(tokenFromBody: IModelRpcProps, request: SerializedRpcRequest): IModelRpcProps {\n const urlPathComponents = request.path.split(\"/\");\n\n let iModelId = tokenFromBody.iModelId;\n let iTwinId = tokenFromBody.iTwinId;\n const changeset = { id: tokenFromBody.changeset?.id ?? \"0\", index: tokenFromBody.changeset?.index };\n\n for (let i = 0; i <= urlPathComponents.length; ++i) {\n const key = urlPathComponents[i];\n const value = urlPathComponents[i + 1];\n if (key === \"mode\") {\n ++i;\n } else if (key === \"context\") {\n iTwinId = value;\n ++i;\n } else if (key === \"imodel\") {\n iModelId = value;\n ++i;\n } else if (key === \"changeset\") {\n changeset.id = (value === \"0\") ? \"\" : value;\n ++i;\n }\n }\n\n // Overwrite the key if it includes a : because its most likely a guid. We know what it should be based off of the url.\n // Leave it alone if its a non guid key.\n return { key: tokenFromBody.key === undefined || tokenFromBody.key.includes(\":\") ? `${iModelId}:${changeset.id}` : tokenFromBody.key, iTwinId, iModelId, changeset };\n }\n\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\n * @internal\n */\n public supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[] {\n return [\n { name: \"modeId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"iTwinId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"iModelId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"changeSetId\", in: \"path\", required: false, schema: { type: \"string\" } },\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"BentleyCloudRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AAEpD,mDAAgD;AAChD,+DAA4D;AAC5D,uDAAoD;AAIpD,2DAAwD;AAGxD,IAAK,OAEJ;AAFD,WAAK,OAAO;IACV,gCAAqB,CAAA;AACvB,CAAC,EAFI,OAAO,KAAP,OAAO,QAEX;AAED;;GAEG;AACH,MAAsB,uBAAwB,SAAQ,qCAAiB;IACrD,UAAU,GAAG,IAAI,CAAC;IAElC,iFAAiF;IACjE,yCAAyC,GAA0B;QACjF,8CAA8C;QAC9C,EAAE,EAAE,kBAAkB;QAEtB,kDAAkD;QAClD,aAAa,EAAE,kBAAkB;QAEjC,uDAAuD;QACvD,kBAAkB,EAAE,uBAAuB;QAE3C,8CAA8C;QAC9C,SAAS,EAAE,cAAc;QAEzB,iDAAiD;QACjD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WAAW,EAAE,CAAC;gBAC/B,SAAS,CAAC,EAAE,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;gBAC5C,EAAE,CAAC,CAAC;YACN,CAAC;QACH,CAAC;QAED,uHAAuH;QACvH,wCAAwC;QACxC,OAAO,EAAE,GAAG,EAAE,aAAa,CAAC,GAAG,KAAK,SAAS,IAAI,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACvK,CAAC;IAED;;OAEG;IACI,gCAAgC,CAAC,UAAwB;QAC9D,OAAO;YACL,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC1E,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC3E,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC5E,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;SACjF,CAAC;IACJ,CAAC;CACF;AApID,0DAoIC","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 RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { OpenAPIParameter } from \"./OpenAPI\";\r\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\r\n\r\nenum AppMode {\r\n MilestoneReview = \"1\",\r\n}\r\n\r\n/** An http protocol for Bentley cloud RPC interface deployments.\r\n * @internal\r\n */\r\nexport abstract class BentleyCloudRpcProtocol extends WebAppRpcProtocol {\r\n public override checkToken = true;\r\n\r\n /** The name of various HTTP request headers based on client's request context */\r\n public override serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the HTTP request id header. */\r\n id: \"X-Correlation-Id\",\r\n\r\n /** The name of the HTTP application id header. */\r\n applicationId: \"X-Application-Id\",\r\n\r\n /** The name of the HTTP application version header. */\r\n applicationVersion: \"X-Application-Version\",\r\n\r\n /** The name of the HTTP session id header. */\r\n sessionId: \"X-Session-Id\",\r\n\r\n /** The name of the HTTP authorization header. */\r\n authorization: \"Authorization\",\r\n };\r\n\r\n /** The name of the RPC protocol version header. */\r\n public override protocolVersionHeaderName = \"X-Protocol-Version\";\r\n\r\n /** Returns the operation specified by an OpenAPI-compatible URI path. */\r\n public override getOperationFromPath(path: string): SerializedRpcOperation {\r\n const url = new URL(path, \"https://localhost/\");\r\n const components = url.pathname.split(\"/\").filter((x) => x); // filter out empty segments\r\n\r\n const operationComponent = components.slice(-1)[0];\r\n const encodedRequest = url.searchParams.get(\"parameters\") || \"\";\r\n\r\n // The encodedRequest should be base64 - fail now if any other characters detected.\r\n if (/[^a-zA-Z0-9=+\\/$]/.test(encodedRequest))\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Malformed URL parameters detected.`);\r\n\r\n const firstHyphen = operationComponent.indexOf(\"-\");\r\n const lastHyphen = operationComponent.lastIndexOf(\"-\");\r\n const interfaceDefinition = operationComponent.slice(0, firstHyphen);\r\n const interfaceVersion = operationComponent.slice(firstHyphen + 1, lastHyphen);\r\n const operationName = operationComponent.slice(lastHyphen + 1);\r\n\r\n return { interfaceDefinition, operationName, interfaceVersion, encodedRequest };\r\n }\r\n\r\n /** Supplies the OpenAPI-compatible URI path for an RPC operation. */\r\n public override supplyPathForOperation(operation: RpcOperation, request: RpcRequest | undefined) {\r\n const prefix = this.pathPrefix;\r\n const appTitle = this.info.title;\r\n const appVersion = this.info.version;\r\n const operationId = `${operation.interfaceDefinition.interfaceName}-${operation.interfaceVersion}-${operation.operationName}`;\r\n\r\n let appMode: string = \"\";\r\n let iTwinId: string = \"\";\r\n let iModelId: string = \"\";\r\n let routeChangesetId: string | undefined;\r\n /* Note: The changesetId field is omitted in the route in the case of ReadWrite connections since the connection is generally expected to be at the\r\n * latest version and not some specific changeset. Also, for the first version (before any changesets), the changesetId in the route is arbitrarily\r\n * set to \"0\" instead of an empty string, since the latter is more un-intuitive for a route. However, in all other use cases, including the changesetId\r\n * held by the IModelRpcProps itself, the changesetId of \"\" (i.e., empty string) signifies the first version - this is more intuitive and retains\r\n * compatibility with the majority of use cases. */\r\n\r\n if (request === undefined) {\r\n appMode = \"{modeId}\";\r\n iTwinId = \"{iTwinId}\";\r\n iModelId = \"{iModelId}\";\r\n routeChangesetId = \"{changeSetId}\";\r\n } else {\r\n let token = operation.policy.token(request) || RpcOperation.fallbackToken;\r\n\r\n if (!token || !token.iModelId) {\r\n if (RpcConfiguration.disableRoutingValidation) {\r\n token = { key: \"\" };\r\n } else {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid iModelToken for RPC operation request\");\r\n }\r\n }\r\n\r\n iTwinId = encodeURIComponent(token.iTwinId || \"\");\r\n iModelId = encodeURIComponent(token.iModelId || \"\");\r\n\r\n routeChangesetId = token.changeset?.id || \"0\";\r\n appMode = AppMode.MilestoneReview;\r\n }\r\n\r\n return `${prefix}/${appTitle}/${appVersion}/mode/${appMode}/context/${iTwinId}/imodel/${iModelId}${!!routeChangesetId ? `/changeset/${routeChangesetId}` : \"\"}/${operationId}`;\r\n }\r\n\r\n /**\r\n * Inflates the IModelRpcProps from the URL path for each request on the backend.\r\n * @note This function updates the IModelRpcProps value supplied in the request body.\r\n */\r\n public override inflateToken(tokenFromBody: IModelRpcProps, request: SerializedRpcRequest): IModelRpcProps {\r\n const urlPathComponents = request.path.split(\"/\");\r\n\r\n let iModelId = tokenFromBody.iModelId;\r\n let iTwinId = tokenFromBody.iTwinId;\r\n const changeset = { id: tokenFromBody.changeset?.id ?? \"0\", index: tokenFromBody.changeset?.index };\r\n\r\n for (let i = 0; i <= urlPathComponents.length; ++i) {\r\n const key = urlPathComponents[i];\r\n const value = urlPathComponents[i + 1];\r\n if (key === \"mode\") {\r\n ++i;\r\n } else if (key === \"context\") {\r\n iTwinId = value;\r\n ++i;\r\n } else if (key === \"imodel\") {\r\n iModelId = value;\r\n ++i;\r\n } else if (key === \"changeset\") {\r\n changeset.id = (value === \"0\") ? \"\" : value;\r\n ++i;\r\n }\r\n }\r\n\r\n // Overwrite the key if it includes a : because its most likely a guid. We know what it should be based off of the url.\r\n // Leave it alone if its a non guid key.\r\n return { key: tokenFromBody.key === undefined || tokenFromBody.key.includes(\":\") ? `${iModelId}:${changeset.id}` : tokenFromBody.key, iTwinId, iModelId, changeset };\r\n }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[] {\r\n return [\r\n { name: \"modeId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"iTwinId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"iModelId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"changeSetId\", in: \"path\", required: false, schema: { type: \"string\" } },\r\n ];\r\n }\r\n}\r\n"]}