@itwin/core-common 4.0.0-dev.4 → 4.0.0-dev.40

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 (258) hide show
  1. package/CHANGELOG.md +35 -17
  2. package/lib/cjs/BackendTypes.d.ts +3 -3
  3. package/lib/cjs/BackendTypes.d.ts.map +1 -1
  4. package/lib/cjs/BackendTypes.js.map +1 -1
  5. package/lib/cjs/BackgroundMapProvider.js +1 -2
  6. package/lib/cjs/BackgroundMapProvider.js.map +1 -1
  7. package/lib/cjs/BackgroundMapSettings.js +11 -13
  8. package/lib/cjs/BackgroundMapSettings.js.map +1 -1
  9. package/lib/cjs/BriefcaseTypes.d.ts +2 -0
  10. package/lib/cjs/BriefcaseTypes.d.ts.map +1 -1
  11. package/lib/cjs/BriefcaseTypes.js.map +1 -1
  12. package/lib/cjs/ClipStyle.js +6 -8
  13. package/lib/cjs/ClipStyle.js.map +1 -1
  14. package/lib/cjs/CloudStorage.d.ts +5 -5
  15. package/lib/cjs/CloudStorage.js +3 -3
  16. package/lib/cjs/CloudStorage.js.map +1 -1
  17. package/lib/cjs/CloudStorageTileCache.d.ts +1 -1
  18. package/lib/cjs/CloudStorageTileCache.js +2 -3
  19. package/lib/cjs/CloudStorageTileCache.js.map +1 -1
  20. package/lib/cjs/Code.d.ts +3 -3
  21. package/lib/cjs/Code.js +4 -5
  22. package/lib/cjs/Code.js.map +1 -1
  23. package/lib/cjs/ColorDef.js +1 -2
  24. package/lib/cjs/ColorDef.js.map +1 -1
  25. package/lib/cjs/ConcurrentQuery.js +1 -1
  26. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  27. package/lib/cjs/ContextRealityModel.js +6 -8
  28. package/lib/cjs/ContextRealityModel.js.map +1 -1
  29. package/lib/cjs/DisplayStyleSettings.js +16 -20
  30. package/lib/cjs/DisplayStyleSettings.js.map +1 -1
  31. package/lib/cjs/Environment.js +12 -15
  32. package/lib/cjs/Environment.js.map +1 -1
  33. package/lib/cjs/FeatureSymbology.js +1 -2
  34. package/lib/cjs/FeatureSymbology.js.map +1 -1
  35. package/lib/cjs/FeatureTable.js +1 -1
  36. package/lib/cjs/FeatureTable.js.map +1 -1
  37. package/lib/cjs/Gradient.js +2 -4
  38. package/lib/cjs/Gradient.js.map +1 -1
  39. package/lib/cjs/GraphicParams.js +1 -1
  40. package/lib/cjs/GraphicParams.js.map +1 -1
  41. package/lib/cjs/GroundPlane.js +3 -4
  42. package/lib/cjs/GroundPlane.js.map +1 -1
  43. package/lib/cjs/HSLColor.js +1 -1
  44. package/lib/cjs/HSLColor.js.map +1 -1
  45. package/lib/cjs/HSVColor.js +1 -1
  46. package/lib/cjs/HSVColor.js.map +1 -1
  47. package/lib/cjs/HiddenLine.js +3 -5
  48. package/lib/cjs/HiddenLine.js.map +1 -1
  49. package/lib/cjs/IModel.d.ts +1 -2
  50. package/lib/cjs/IModel.d.ts.map +1 -1
  51. package/lib/cjs/IModel.js +1 -1
  52. package/lib/cjs/IModel.js.map +1 -1
  53. package/lib/cjs/LightSettings.js +18 -23
  54. package/lib/cjs/LightSettings.js.map +1 -1
  55. package/lib/cjs/MapImagerySettings.js +2 -2
  56. package/lib/cjs/MapImagerySettings.js.map +1 -1
  57. package/lib/cjs/MapLayerSettings.js +9 -13
  58. package/lib/cjs/MapLayerSettings.js.map +1 -1
  59. package/lib/cjs/ModelClipGroup.js +3 -5
  60. package/lib/cjs/ModelClipGroup.js.map +1 -1
  61. package/lib/cjs/QPoint.js +5 -7
  62. package/lib/cjs/QPoint.js.map +1 -1
  63. package/lib/cjs/RealityModelDisplaySettings.js +14 -15
  64. package/lib/cjs/RealityModelDisplaySettings.js.map +1 -1
  65. package/lib/cjs/RenderMaterial.js +1 -2
  66. package/lib/cjs/RenderMaterial.js.map +1 -1
  67. package/lib/cjs/RenderSchedule.js +30 -40
  68. package/lib/cjs/RenderSchedule.js.map +1 -1
  69. package/lib/cjs/SkyBox.js +10 -11
  70. package/lib/cjs/SkyBox.js.map +1 -1
  71. package/lib/cjs/SolarShadows.js +1 -2
  72. package/lib/cjs/SolarShadows.js.map +1 -1
  73. package/lib/cjs/SpatialClassification.js +1 -2
  74. package/lib/cjs/SpatialClassification.js.map +1 -1
  75. package/lib/cjs/TerrainSettings.js +7 -9
  76. package/lib/cjs/TerrainSettings.js.map +1 -1
  77. package/lib/cjs/TextureMapping.js +4 -5
  78. package/lib/cjs/TextureMapping.js.map +1 -1
  79. package/lib/cjs/ThematicDisplay.js +1 -2
  80. package/lib/cjs/ThematicDisplay.js.map +1 -1
  81. package/lib/cjs/TileProps.js +1 -1
  82. package/lib/cjs/TileProps.js.map +1 -1
  83. package/lib/cjs/ViewDetails.js +1 -1
  84. package/lib/cjs/ViewDetails.js.map +1 -1
  85. package/lib/cjs/ViewFlags.js +24 -25
  86. package/lib/cjs/ViewFlags.js.map +1 -1
  87. package/lib/cjs/WhiteOnWhiteReversalSettings.js +1 -1
  88. package/lib/cjs/WhiteOnWhiteReversalSettings.js.map +1 -1
  89. package/lib/cjs/geometry/AreaPattern.js +1 -2
  90. package/lib/cjs/geometry/AreaPattern.js.map +1 -1
  91. package/lib/cjs/geometry/BoundingSphere.js +1 -1
  92. package/lib/cjs/geometry/BoundingSphere.js.map +1 -1
  93. package/lib/cjs/geometry/CoordinateReferenceSystem.js +1 -2
  94. package/lib/cjs/geometry/CoordinateReferenceSystem.js.map +1 -1
  95. package/lib/cjs/geometry/ElementGeometry.js +1 -1
  96. package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
  97. package/lib/cjs/geometry/FrustumPlanes.d.ts.map +1 -1
  98. package/lib/cjs/geometry/FrustumPlanes.js +0 -4
  99. package/lib/cjs/geometry/FrustumPlanes.js.map +1 -1
  100. package/lib/cjs/geometry/GeodeticDatum.js +1 -2
  101. package/lib/cjs/geometry/GeodeticDatum.js.map +1 -1
  102. package/lib/cjs/geometry/GeodeticEllipsoid.js +1 -2
  103. package/lib/cjs/geometry/GeodeticEllipsoid.js.map +1 -1
  104. package/lib/cjs/geometry/GeometryStream.js +5 -6
  105. package/lib/cjs/geometry/GeometryStream.js.map +1 -1
  106. package/lib/cjs/ipc/IpcWebSocket.js +1 -2
  107. package/lib/cjs/ipc/IpcWebSocket.js.map +1 -1
  108. package/lib/cjs/rpc/DevToolsRpcInterface.d.ts.map +1 -1
  109. package/lib/cjs/rpc/DevToolsRpcInterface.js +6 -2
  110. package/lib/cjs/rpc/DevToolsRpcInterface.js.map +1 -1
  111. package/lib/cjs/rpc/IModelReadRpcInterface.d.ts +1 -1
  112. package/lib/cjs/rpc/IModelReadRpcInterface.d.ts.map +1 -1
  113. package/lib/cjs/rpc/IModelReadRpcInterface.js +1 -1
  114. package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
  115. package/lib/cjs/rpc/IModelTileRpcInterface.d.ts +2 -2
  116. package/lib/cjs/rpc/IModelTileRpcInterface.js +2 -2
  117. package/lib/cjs/rpc/IModelTileRpcInterface.js.map +1 -1
  118. package/lib/cjs/rpc/core/RpcControl.js +1 -1
  119. package/lib/cjs/rpc/core/RpcControl.js.map +1 -1
  120. package/lib/cjs/rpc/core/RpcInvocation.js +3 -5
  121. package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
  122. package/lib/cjs/rpc/core/RpcPendingQueue.js +1 -2
  123. package/lib/cjs/rpc/core/RpcPendingQueue.js.map +1 -1
  124. package/lib/cjs/rpc/core/RpcRegistry.js +1 -2
  125. package/lib/cjs/rpc/core/RpcRegistry.js.map +1 -1
  126. package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js +2 -4
  127. package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
  128. package/lib/cjs/tile/TileMetadata.js +1 -2
  129. package/lib/cjs/tile/TileMetadata.js.map +1 -1
  130. package/lib/esm/BackendTypes.d.ts +3 -3
  131. package/lib/esm/BackendTypes.d.ts.map +1 -1
  132. package/lib/esm/BackendTypes.js.map +1 -1
  133. package/lib/esm/BackgroundMapProvider.js +1 -2
  134. package/lib/esm/BackgroundMapProvider.js.map +1 -1
  135. package/lib/esm/BackgroundMapSettings.js +11 -13
  136. package/lib/esm/BackgroundMapSettings.js.map +1 -1
  137. package/lib/esm/BriefcaseTypes.d.ts +2 -0
  138. package/lib/esm/BriefcaseTypes.d.ts.map +1 -1
  139. package/lib/esm/BriefcaseTypes.js.map +1 -1
  140. package/lib/esm/ClipStyle.js +6 -8
  141. package/lib/esm/ClipStyle.js.map +1 -1
  142. package/lib/esm/CloudStorage.d.ts +5 -5
  143. package/lib/esm/CloudStorage.js +3 -3
  144. package/lib/esm/CloudStorage.js.map +1 -1
  145. package/lib/esm/CloudStorageTileCache.d.ts +1 -1
  146. package/lib/esm/CloudStorageTileCache.js +2 -3
  147. package/lib/esm/CloudStorageTileCache.js.map +1 -1
  148. package/lib/esm/Code.d.ts +3 -3
  149. package/lib/esm/Code.js +4 -5
  150. package/lib/esm/Code.js.map +1 -1
  151. package/lib/esm/ColorDef.js +1 -2
  152. package/lib/esm/ColorDef.js.map +1 -1
  153. package/lib/esm/ConcurrentQuery.js +1 -1
  154. package/lib/esm/ConcurrentQuery.js.map +1 -1
  155. package/lib/esm/ContextRealityModel.js +6 -8
  156. package/lib/esm/ContextRealityModel.js.map +1 -1
  157. package/lib/esm/DisplayStyleSettings.js +16 -20
  158. package/lib/esm/DisplayStyleSettings.js.map +1 -1
  159. package/lib/esm/Environment.js +12 -15
  160. package/lib/esm/Environment.js.map +1 -1
  161. package/lib/esm/FeatureSymbology.js +1 -2
  162. package/lib/esm/FeatureSymbology.js.map +1 -1
  163. package/lib/esm/FeatureTable.js +1 -1
  164. package/lib/esm/FeatureTable.js.map +1 -1
  165. package/lib/esm/Gradient.js +2 -4
  166. package/lib/esm/Gradient.js.map +1 -1
  167. package/lib/esm/GraphicParams.js +1 -1
  168. package/lib/esm/GraphicParams.js.map +1 -1
  169. package/lib/esm/GroundPlane.js +3 -4
  170. package/lib/esm/GroundPlane.js.map +1 -1
  171. package/lib/esm/HSLColor.js +1 -1
  172. package/lib/esm/HSLColor.js.map +1 -1
  173. package/lib/esm/HSVColor.js +1 -1
  174. package/lib/esm/HSVColor.js.map +1 -1
  175. package/lib/esm/HiddenLine.js +3 -5
  176. package/lib/esm/HiddenLine.js.map +1 -1
  177. package/lib/esm/IModel.d.ts +1 -2
  178. package/lib/esm/IModel.d.ts.map +1 -1
  179. package/lib/esm/IModel.js +1 -1
  180. package/lib/esm/IModel.js.map +1 -1
  181. package/lib/esm/LightSettings.js +18 -23
  182. package/lib/esm/LightSettings.js.map +1 -1
  183. package/lib/esm/MapImagerySettings.js +2 -2
  184. package/lib/esm/MapImagerySettings.js.map +1 -1
  185. package/lib/esm/MapLayerSettings.js +9 -13
  186. package/lib/esm/MapLayerSettings.js.map +1 -1
  187. package/lib/esm/ModelClipGroup.js +3 -5
  188. package/lib/esm/ModelClipGroup.js.map +1 -1
  189. package/lib/esm/QPoint.js +5 -7
  190. package/lib/esm/QPoint.js.map +1 -1
  191. package/lib/esm/RealityModelDisplaySettings.js +14 -15
  192. package/lib/esm/RealityModelDisplaySettings.js.map +1 -1
  193. package/lib/esm/RenderMaterial.js +1 -2
  194. package/lib/esm/RenderMaterial.js.map +1 -1
  195. package/lib/esm/RenderSchedule.js +30 -40
  196. package/lib/esm/RenderSchedule.js.map +1 -1
  197. package/lib/esm/SkyBox.js +10 -11
  198. package/lib/esm/SkyBox.js.map +1 -1
  199. package/lib/esm/SolarShadows.js +1 -2
  200. package/lib/esm/SolarShadows.js.map +1 -1
  201. package/lib/esm/SpatialClassification.js +1 -2
  202. package/lib/esm/SpatialClassification.js.map +1 -1
  203. package/lib/esm/TerrainSettings.js +7 -9
  204. package/lib/esm/TerrainSettings.js.map +1 -1
  205. package/lib/esm/TextureMapping.js +4 -5
  206. package/lib/esm/TextureMapping.js.map +1 -1
  207. package/lib/esm/ThematicDisplay.js +1 -2
  208. package/lib/esm/ThematicDisplay.js.map +1 -1
  209. package/lib/esm/TileProps.js +1 -1
  210. package/lib/esm/TileProps.js.map +1 -1
  211. package/lib/esm/ViewDetails.js +1 -1
  212. package/lib/esm/ViewDetails.js.map +1 -1
  213. package/lib/esm/ViewFlags.js +24 -25
  214. package/lib/esm/ViewFlags.js.map +1 -1
  215. package/lib/esm/WhiteOnWhiteReversalSettings.js +1 -1
  216. package/lib/esm/WhiteOnWhiteReversalSettings.js.map +1 -1
  217. package/lib/esm/geometry/AreaPattern.js +1 -2
  218. package/lib/esm/geometry/AreaPattern.js.map +1 -1
  219. package/lib/esm/geometry/BoundingSphere.js +1 -1
  220. package/lib/esm/geometry/BoundingSphere.js.map +1 -1
  221. package/lib/esm/geometry/CoordinateReferenceSystem.js +1 -2
  222. package/lib/esm/geometry/CoordinateReferenceSystem.js.map +1 -1
  223. package/lib/esm/geometry/ElementGeometry.js +1 -1
  224. package/lib/esm/geometry/ElementGeometry.js.map +1 -1
  225. package/lib/esm/geometry/FrustumPlanes.d.ts.map +1 -1
  226. package/lib/esm/geometry/FrustumPlanes.js +0 -4
  227. package/lib/esm/geometry/FrustumPlanes.js.map +1 -1
  228. package/lib/esm/geometry/GeodeticDatum.js +1 -2
  229. package/lib/esm/geometry/GeodeticDatum.js.map +1 -1
  230. package/lib/esm/geometry/GeodeticEllipsoid.js +1 -2
  231. package/lib/esm/geometry/GeodeticEllipsoid.js.map +1 -1
  232. package/lib/esm/geometry/GeometryStream.js +5 -6
  233. package/lib/esm/geometry/GeometryStream.js.map +1 -1
  234. package/lib/esm/ipc/IpcWebSocket.js +1 -2
  235. package/lib/esm/ipc/IpcWebSocket.js.map +1 -1
  236. package/lib/esm/rpc/DevToolsRpcInterface.d.ts.map +1 -1
  237. package/lib/esm/rpc/DevToolsRpcInterface.js +6 -2
  238. package/lib/esm/rpc/DevToolsRpcInterface.js.map +1 -1
  239. package/lib/esm/rpc/IModelReadRpcInterface.d.ts +1 -1
  240. package/lib/esm/rpc/IModelReadRpcInterface.d.ts.map +1 -1
  241. package/lib/esm/rpc/IModelReadRpcInterface.js +1 -1
  242. package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
  243. package/lib/esm/rpc/IModelTileRpcInterface.d.ts +2 -2
  244. package/lib/esm/rpc/IModelTileRpcInterface.js +2 -2
  245. package/lib/esm/rpc/IModelTileRpcInterface.js.map +1 -1
  246. package/lib/esm/rpc/core/RpcControl.js +1 -1
  247. package/lib/esm/rpc/core/RpcControl.js.map +1 -1
  248. package/lib/esm/rpc/core/RpcInvocation.js +3 -5
  249. package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
  250. package/lib/esm/rpc/core/RpcPendingQueue.js +1 -2
  251. package/lib/esm/rpc/core/RpcPendingQueue.js.map +1 -1
  252. package/lib/esm/rpc/core/RpcRegistry.js +1 -2
  253. package/lib/esm/rpc/core/RpcRegistry.js.map +1 -1
  254. package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js +2 -4
  255. package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
  256. package/lib/esm/tile/TileMetadata.js +1 -2
  257. package/lib/esm/tile/TileMetadata.js.map +1 -1
  258. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"RpcControl.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yCAAmC;AAEnC,qDAAkD;AAClD,iDAAqE;AACrE,yDAAsD;AAEtD,iDAA8C;AAC9C,+CAA4C;AAE5C,4CAA4C;AAE5C;;GAEG;AACH,MAAsB,kBAAkB;IAAxC;QACS,YAAO,GAAG,oBAAoB,CAAC;IACxC,CAAC;CAAA;AAFD,gDAEC;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,kBAAkB;IAIxD,qCAAqC;IACrC,YAAmB,UAAkB,EAAE;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AATD,gDASC;AAED;;GAEG;AACH,MAAa,mBAAoB,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,IAAI,CAAC;IAC3B,CAAC;IAED,gBAAgB;IACT,sBAAsB,CAAC,UAAyB,EAAE,MAAW;QAClE,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC;QACxC,IAAI,EAAE,CAAC,gBAAgB,KAAK,SAAS,IAAI,EAAE,CAAC,aAAa,KAAK,mBAAmB,EAAE;YACjF,IAAI,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE;gBACxC,EAAE,CAAC,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;aAC/D;YAED,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AApHH,8CAqHC;AApHC,gBAAgB;AACF,0BAAQ,GAAwB,EAAE,CAAC;AAClC,6BAAW,GAAG,CAAC,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 { Base64 } from \"js-base64\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints, RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An RPC operation control response.\r\n * @public\r\n */\r\nexport abstract class RpcControlResponse {\r\n public message = \"RpcControlResponse\";\r\n}\r\n\r\n/** A pending RPC operation response.\r\n * @public\r\n */\r\nexport class RpcPendingResponse extends RpcControlResponse {\r\n /** Extended status regarding the pending operation. */\r\n public override message: string;\r\n\r\n /** Constructs a pending response. */\r\n public constructor(message: string = \"\") {\r\n super();\r\n this.message = message;\r\n }\r\n}\r\n\r\n/** A RPC operation response.\r\n * @public\r\n */\r\nexport class RpcNotFoundResponse extends RpcControlResponse {\r\n public override message = \"Not found\";\r\n}\r\n\r\n/** Manages requests and responses for an RPC configuration.\r\n * @internal\r\n */\r\nexport class RpcControlChannel {\r\n /** @internal */\r\n public static channels: RpcControlChannel[] = [];\r\n private static _obtainLock = 0;\r\n private _configuration: RpcConfiguration;\r\n private _initialized = false;\r\n private _clientActive = false;\r\n private _describeEndpoints: () => Promise<RpcInterfaceEndpoints[]> = undefined as any;\r\n\r\n /** @internal */\r\n public static ensureInitialized() {\r\n this.channels.forEach((channel) => channel.initialize());\r\n }\r\n\r\n private constructor(configuration: RpcConfiguration) {\r\n this._configuration = configuration;\r\n RpcControlChannel.channels.push(this);\r\n }\r\n\r\n /** @internal */\r\n public async describeEndpoints() {\r\n this.activateClient();\r\n if (!this._channelInterface.interfaceName) {\r\n return [];\r\n }\r\n\r\n return this._describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public static obtain(configuration: RpcConfiguration): RpcControlChannel {\r\n if (RpcControlChannel._obtainLock)\r\n return undefined as any;\r\n\r\n ++RpcControlChannel._obtainLock;\r\n const channel = new RpcControlChannel(configuration);\r\n --RpcControlChannel._obtainLock;\r\n\r\n return channel;\r\n }\r\n\r\n private _channelInterface = class extends RpcInterface {\r\n public static readonly interfaceVersion = \"CONTROL\";\r\n public static readonly interfaceName = \"\";\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> { return this.forward(arguments); }\r\n };\r\n\r\n private _channelImpl = class extends RpcInterface {\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const endpoints: RpcInterfaceEndpoints[] = [];\r\n\r\n this.configuration.interfaces().forEach((definition) => {\r\n if (!RpcRegistry.instance.isRpcInterfaceInitialized(definition))\r\n return;\r\n\r\n const description: RpcInterfaceEndpoints = { interfaceName: definition.interfaceName, interfaceVersion: definition.interfaceVersion, operationNames: [], compatible: true };\r\n RpcOperation.forEach(definition, (operation) => description.operationNames.push(operation.operationName));\r\n endpoints.push(description);\r\n });\r\n\r\n return endpoints;\r\n }\r\n };\r\n\r\n private computeId(): string {\r\n const interfaces: string[] = [];\r\n this._configuration.interfaces().forEach((definition) => interfaces.push(`${definition.interfaceName}@${definition.interfaceVersion}`));\r\n const id = interfaces.sort().join(\",\");\r\n\r\n return Base64.encode(id);\r\n }\r\n\r\n private activateClient() {\r\n if (this._clientActive)\r\n return;\r\n\r\n this.initialize();\r\n\r\n const token: IModelRpcProps = { key: \"none\", iTwinId: \"none\", iModelId: \"none\", changeset: { id: \"none\" } };\r\n RpcOperation.forEach(this._channelInterface, (operation) => operation.policy.token = (_request) => RpcOperation.fallbackToken ?? token);\r\n const client = RpcManager.getClientForInterface(this._channelInterface);\r\n this._describeEndpoints = async () => client.describeEndpoints();\r\n this._clientActive = true;\r\n }\r\n\r\n /** @internal */\r\n public initialize() {\r\n if (this._initialized) {\r\n return;\r\n }\r\n\r\n const id = this.computeId();\r\n Object.defineProperty(this._channelInterface, \"interfaceName\", { value: id });\r\n Object.defineProperty(this._channelImpl, \"interfaceName\", { value: id });\r\n\r\n RpcConfiguration.assign(this._channelInterface, () => this._configuration.constructor as any);\r\n RpcManager.registerImpl(this._channelInterface, this._channelImpl);\r\n RpcManager.initializeInterface(this._channelInterface);\r\n\r\n this._initialized = true;\r\n }\r\n\r\n /** @internal */\r\n public handleUnknownOperation(invocation: RpcInvocation, _error: any): boolean {\r\n this.initialize();\r\n\r\n const op = invocation.request.operation;\r\n if (op.interfaceVersion === \"CONTROL\" && op.operationName === \"describeEndpoints\") {\r\n if (this._channelInterface.interfaceName) {\r\n op.interfaceDefinition = this._channelInterface.interfaceName;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcControl.js","sourceRoot":"","sources":["../../../../src/rpc/core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EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9E,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAEzE,mCAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,WAAkB,CAAC,CAAC;QAC9F,uBAAU,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACnE,uBAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEvD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,gBAAgB;IACT,sBAAsB,CAAC,UAAyB,EAAE,MAAW;QAClE,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC;QACxC,IAAI,EAAE,CAAC,gBAAgB,KAAK,SAAS,IAAI,EAAE,CAAC,aAAa,KAAK,mBAAmB,EAAE;YACjF,IAAI,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE;gBACxC,EAAE,CAAC,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;aAC/D;YAED,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AApHH,8CAqHC;AApHC,gBAAgB;AACF,0BAAQ,GAAwB,EAAE,CAAC;AAClC,6BAAW,GAAG,CAAC,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 { Base64 } from \"js-base64\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints, RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An RPC operation control response.\r\n * @public\r\n */\r\nexport abstract class RpcControlResponse {\r\n public message = \"RpcControlResponse\";\r\n}\r\n\r\n/** A pending RPC operation response.\r\n * @public\r\n */\r\nexport class RpcPendingResponse extends RpcControlResponse {\r\n /** Extended status regarding the pending operation. */\r\n public override message: string;\r\n\r\n /** Constructs a pending response. */\r\n public constructor(message: string = \"\") {\r\n super();\r\n this.message = message;\r\n }\r\n}\r\n\r\n/** A RPC operation response.\r\n * @public\r\n */\r\nexport class RpcNotFoundResponse extends RpcControlResponse {\r\n public override message = \"Not found\";\r\n}\r\n\r\n/** Manages requests and responses for an RPC configuration.\r\n * @internal\r\n */\r\nexport class RpcControlChannel {\r\n /** @internal */\r\n public static channels: RpcControlChannel[] = [];\r\n private static _obtainLock = 0;\r\n private _configuration: RpcConfiguration;\r\n private _initialized = false;\r\n private _clientActive = false;\r\n private _describeEndpoints: () => Promise<RpcInterfaceEndpoints[]> = undefined as any;\r\n\r\n /** @internal */\r\n public static ensureInitialized() {\r\n this.channels.forEach((channel) => channel.initialize());\r\n }\r\n\r\n private constructor(configuration: RpcConfiguration) {\r\n this._configuration = configuration;\r\n RpcControlChannel.channels.push(this);\r\n }\r\n\r\n /** @internal */\r\n public async describeEndpoints() {\r\n this.activateClient();\r\n if (!this._channelInterface.interfaceName) {\r\n return [];\r\n }\r\n\r\n return this._describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public static obtain(configuration: RpcConfiguration): RpcControlChannel {\r\n if (RpcControlChannel._obtainLock)\r\n return undefined as any;\r\n\r\n ++RpcControlChannel._obtainLock;\r\n const channel = new RpcControlChannel(configuration);\r\n --RpcControlChannel._obtainLock;\r\n\r\n return channel;\r\n }\r\n\r\n private _channelInterface = class extends RpcInterface {\r\n public static readonly interfaceVersion = \"CONTROL\";\r\n public static readonly interfaceName = \"\";\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> { return this.forward(arguments); }\r\n };\r\n\r\n private _channelImpl = class extends RpcInterface {\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const endpoints: RpcInterfaceEndpoints[] = [];\r\n\r\n this.configuration.interfaces().forEach((definition) => {\r\n if (!RpcRegistry.instance.isRpcInterfaceInitialized(definition))\r\n return;\r\n\r\n const description: RpcInterfaceEndpoints = { interfaceName: definition.interfaceName, interfaceVersion: definition.interfaceVersion, operationNames: [], compatible: true };\r\n RpcOperation.forEach(definition, (operation) => description.operationNames.push(operation.operationName));\r\n endpoints.push(description);\r\n });\r\n\r\n return endpoints;\r\n }\r\n };\r\n\r\n private computeId(): string {\r\n const interfaces: string[] = [];\r\n this._configuration.interfaces().forEach((definition) => interfaces.push(`${definition.interfaceName}@${definition.interfaceVersion}`));\r\n const id = interfaces.sort().join(\",\");\r\n\r\n return Base64.encode(id);\r\n }\r\n\r\n private activateClient() {\r\n if (this._clientActive)\r\n return;\r\n\r\n this.initialize();\r\n\r\n const token: IModelRpcProps = { key: \"none\", iTwinId: \"none\", iModelId: \"none\", changeset: { id: \"none\" } };\r\n RpcOperation.forEach(this._channelInterface, (operation) => operation.policy.token = (_request) => RpcOperation.fallbackToken ?? token);\r\n const client = RpcManager.getClientForInterface(this._channelInterface);\r\n this._describeEndpoints = async () => client.describeEndpoints();\r\n this._clientActive = true;\r\n }\r\n\r\n /** @internal */\r\n public initialize() {\r\n if (this._initialized) {\r\n return;\r\n }\r\n\r\n const id = this.computeId();\r\n Object.defineProperty(this._channelInterface, \"interfaceName\", { value: id });\r\n Object.defineProperty(this._channelImpl, \"interfaceName\", { value: id });\r\n\r\n RpcConfiguration.assign(this._channelInterface, () => this._configuration.constructor as any);\r\n RpcManager.registerImpl(this._channelInterface, this._channelImpl);\r\n RpcManager.initializeInterface(this._channelInterface);\r\n\r\n this._initialized = true;\r\n }\r\n\r\n /** @internal */\r\n public handleUnknownOperation(invocation: RpcInvocation, _error: any): boolean {\r\n this.initialize();\r\n\r\n const op = invocation.request.operation;\r\n if (op.interfaceVersion === \"CONTROL\" && op.operationName === \"describeEndpoints\") {\r\n if (this._channelInterface.interfaceName) {\r\n op.interfaceDefinition = this._channelInterface.interfaceName;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
@@ -143,11 +143,10 @@ class RpcInvocation {
143
143
  }
144
144
  }
145
145
  static compareTokens(a, b) {
146
- var _b;
147
146
  return a.key === b.key &&
148
147
  a.iTwinId === b.iTwinId &&
149
148
  a.iModelId === b.iModelId &&
150
- (undefined === a.changeset || (a.changeset.id === ((_b = b.changeset) === null || _b === void 0 ? void 0 : _b.id)));
149
+ (undefined === a.changeset || (a.changeset.id === b.changeset?.id));
151
150
  }
152
151
  async reject(error) {
153
152
  this._threw = true;
@@ -170,7 +169,7 @@ class RpcInvocation {
170
169
  result.objects = reason.message;
171
170
  this.protocol.events.raiseEvent(RpcConstants_1.RpcProtocolEvent.BackendReportedPending, this);
172
171
  }
173
- else if (this.supportsNoContent() && (reason === null || reason === void 0 ? void 0 : reason.errorNumber) === core_bentley_1.IModelStatus.NoContent) {
172
+ else if (this.supportsNoContent() && reason?.errorNumber === core_bentley_1.IModelStatus.NoContent) {
174
173
  this._noContent = true;
175
174
  this._threw = false;
176
175
  this.protocol.events.raiseEvent(RpcConstants_1.RpcProtocolEvent.BackendReportedNoContent, this);
@@ -202,14 +201,13 @@ class RpcInvocation {
202
201
  return RpcProtocol_1.RpcProtocol.protocolVersion >= RpcProtocol_1.RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocol_1.RpcProtocolVersion.IntroducedStatusCategory;
203
202
  }
204
203
  fulfill(result, rawResult) {
205
- var _b;
206
204
  const fulfillment = {
207
205
  result,
208
206
  rawResult,
209
207
  status: this.protocol.getCode(this.status),
210
208
  id: this.request.id,
211
209
  interfaceName: (typeof (this.operation) === "undefined") ? "" : this.operation.interfaceDefinition.interfaceName,
212
- allowCompression: ((_b = this.operation) === null || _b === void 0 ? void 0 : _b.policy.allowResponseCompression) || false,
210
+ allowCompression: this.operation?.policy.allowResponseCompression || false,
213
211
  };
214
212
  this.transformResponseStatus(fulfillment, rawResult);
215
213
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAA8J;AAC9J,qEAAkE;AAElE,mDAAgD;AAChD,qDAAkD;AAElD,yDAAsD;AACtD,iDAAoE;AACpE,6CAA0F;AAC1F,mDAAoE;AACpE,iDAA8C;AAC9C,+CAA+H;AAC/H,+CAAgE;AAkChE;;GAEG;AACH,MAAa,aAAa;IA8CxB,gCAAgC;IAChC,YAAmB,QAAqB,EAAE,OAA6B;QA7C/D,WAAM,GAAY,KAAK,CAAC;QACxB,aAAQ,GAAY,KAAK,CAAC;QAC1B,cAAS,GAAY,KAAK,CAAC;QAC3B,eAAU,GAAY,KAAK,CAAC;QAC5B,YAAO,GAAW,CAAC,CAAC;QACpB,aAAQ,GAAW,CAAC,CAAC;QAQ7B,oCAAoC;QACpB,cAAS,GAAiB,SAAgB,CAAC;QAgCzD,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI;YACF,IAAI;gBACF,IAAI,CAAC,SAAS,GAAG,2BAAY,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,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,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAG,CAAA","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 { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcControlChannel, RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n RpcControlChannel.ensureInitialized();\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.setAttributes({ error: true });\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = await RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = await RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation?.policy.allowResponseCompression || false,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof BentleyError) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAA8J;AAC9J,qEAAkE;AAElE,mDAAgD;AAChD,qDAAkD;AAElD,yDAAsD;AACtD,iDAAoE;AACpE,6CA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AE;YAC1B,aAAa,GAAG,WAAW,CAAC;SAC7B;QAED,IAAI,aAAa,EAAE;YACjB,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;YACjD,MAAM,MAAM,GAAqB,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;YAC9F,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpD,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,eAAe;YACjD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;SAChC;QAED,IAAI,SAAS,YAAY,2BAAY,EAAE;YACrC,WAAW,CAAC,MAAM,GAAG,6BAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;SACzD;IACH,CAAC;;AA5QH,sCA6QC;;AA5Qe,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAG,CAAA","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 { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcControlChannel, RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n RpcControlChannel.ensureInitialized();\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.setAttributes({ error: true });\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = await RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = await RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation?.policy.allowResponseCompression || false,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof BentleyError) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
@@ -20,11 +20,10 @@ class RpcPendingQueue {
20
20
  this._pending = [];
21
21
  this._pendingLock = 0;
22
22
  this._pendingIntervalHandler = function () {
23
- var _a;
24
23
  const now = new Date().getTime();
25
24
  ++this._pendingLock;
26
25
  for (const request of this._pending) {
27
- const retry = (_a = request.retryAfter) !== null && _a !== void 0 ? _a : request.retryInterval;
26
+ const retry = request.retryAfter ?? request.retryInterval;
28
27
  if (request.connecting || (request.lastSubmitted + retry) > now) {
29
28
  continue;
30
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RpcPendingQueue.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcPendingQueue.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iDAAmE;AACnE,6CAA0C;AAE1C,4CAA4C;AAE5C;;GAEG;AACH,MAAa,eAAe;IAa1B;QAJQ,qBAAgB,GAAQ,SAAS,CAAC;QAClC,aAAQ,GAAiB,EAAE,CAAC;QAC5B,iBAAY,GAAW,CAAC,CAAC;QAyCzB,4BAAuB,GAAG;;YAChC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YAEjC,EAAE,IAAI,CAAC,YAAY,CAAC;YAEpB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACnC,MAAM,KAAK,GAAG,MAAA,OAAO,C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AAC;IAEO,cAAc,CAAC,OAAmB;QACxC,IAAI,IAAI,CAAC,YAAY;YACnB,OAAO;QAET,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAqBO,mBAAmB;QACzB,IAAI,IAAI,CAAC,YAAY;YACnB,OAAO;QAET,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC7B,OAAO,CAAC,EAAE,EAAE;YACV,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,+BAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;gBAC5F,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAC5B;SACF;QAED,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAEO,kBAAkB;QACxB,IAAI,IAAI,CAAC,gBAAgB;YACvB,OAAO;QAET,IAAI,CAAC,gBAAgB,GAAG,WAAW,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IAEO,oBAAoB;QAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YACzB,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACrC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;SACnC;IACH,CAAC;CACF;AAlGD,0CAkGC","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 { RpcRequestEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** Manages pending RPC requests and responses.\r\n * @internal\r\n */\r\nexport class RpcPendingQueue {\r\n public static instance: RpcPendingQueue;\r\n\r\n public static initialize() {\r\n if (!RpcPendingQueue.instance) {\r\n RpcPendingQueue.instance = new RpcPendingQueue();\r\n }\r\n }\r\n\r\n private _pendingInterval: any = undefined;\r\n private _pending: RpcRequest[] = [];\r\n private _pendingLock: number = 0;\r\n\r\n private constructor() {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n RpcRequest.events.addListener(this.requestEventHandler, this);\r\n }\r\n\r\n private requestEventHandler(type: RpcRequestEvent, request: RpcRequest): void {\r\n if (type !== RpcRequestEvent.StatusChanged)\r\n return;\r\n\r\n switch (request.status) {\r\n case RpcRequestStatus.Submitted: {\r\n this.enqueuePending(request);\r\n break;\r\n }\r\n\r\n case RpcRequestStatus.Resolved:\r\n case RpcRequestStatus.Rejected:\r\n case RpcRequestStatus.NotFound:\r\n case RpcRequestStatus.Cancelled: {\r\n this.dequeuePending(request);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n private enqueuePending(request: RpcRequest) {\r\n this._pending.push(request);\r\n this.setPendingInterval();\r\n }\r\n\r\n private dequeuePending(request: RpcRequest) {\r\n if (this._pendingLock)\r\n return;\r\n\r\n const i = this._pending.indexOf(request);\r\n this._pending.splice(i, 1);\r\n this.clearPendingInterval();\r\n }\r\n\r\n private _pendingIntervalHandler = function (this: RpcPendingQueue) {\r\n const now = new Date().getTime();\r\n\r\n ++this._pendingLock;\r\n\r\n for (const request of this._pending) {\r\n const retry = request.retryAfter ?? request.retryInterval;\r\n if (request.connecting || (request.lastSubmitted + retry) > now) {\r\n continue;\r\n }\r\n\r\n request.submit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n --this._pendingLock;\r\n\r\n this.cleanupPendingQueue();\r\n }.bind(this);\r\n\r\n private cleanupPendingQueue() {\r\n if (this._pendingLock)\r\n return;\r\n\r\n let i = this._pending.length;\r\n while (i--) {\r\n if (!this._pending[i].pending && !RpcRequestStatus.isTransientError(this._pending[i].status)) {\r\n this._pending.splice(i, 1);\r\n }\r\n }\r\n\r\n this.clearPendingInterval();\r\n }\r\n\r\n private setPendingInterval() {\r\n if (this._pendingInterval)\r\n return;\r\n\r\n this._pendingInterval = setInterval(this._pendingIntervalHandler, 0);\r\n }\r\n\r\n private clearPendingInterval() {\r\n if (!this._pending.length) {\r\n clearInterval(this._pendingInterval);\r\n this._pendingInterval = undefined;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcPendingQueue.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcPendingQueue.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iDAAmE;AACnE,6CAA0C;AAE1C,4CAA4C;AAE5C;;GAEG;AACH,MAAa,eAAe;IAa1B;QAJQ,qBAAgB,GAAQ,SAAS,CAAC;QAClC,aAAQ,GAAiB,EAAE,CAAC;QAC5B,iBAAY,GAAW,CAAC,CAAC;QAyCzB,4BAAuB,GAAG;YAChC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YAEjC,EAAE,IAAI,CAAC,YAAY,CAAC;YAEpB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACnC,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC;gBAC1D,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,GAAG,GAAG,EAAE;oBAC/D,SAAS;iBACV;gBAED,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,8DAA8D;aACjF;YAED,EAAE,IAAI,C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,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAqBO,mBAAmB;QACzB,IAAI,IAAI,CAAC,YAAY;YACnB,OAAO;QAET,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC7B,OAAO,CAAC,EAAE,EAAE;YACV,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,+BAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;gBAC5F,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAC5B;SACF;QAED,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAEO,kBAAkB;QACxB,IAAI,IAAI,CAAC,gBAAgB;YACvB,OAAO;QAET,IAAI,CAAC,gBAAgB,GAAG,WAAW,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IAEO,oBAAoB;QAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YACzB,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACrC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;SACnC;IACH,CAAC;CACF;AAlGD,0CAkGC","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 { RpcRequestEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** Manages pending RPC requests and responses.\r\n * @internal\r\n */\r\nexport class RpcPendingQueue {\r\n public static instance: RpcPendingQueue;\r\n\r\n public static initialize() {\r\n if (!RpcPendingQueue.instance) {\r\n RpcPendingQueue.instance = new RpcPendingQueue();\r\n }\r\n }\r\n\r\n private _pendingInterval: any = undefined;\r\n private _pending: RpcRequest[] = [];\r\n private _pendingLock: number = 0;\r\n\r\n private constructor() {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n RpcRequest.events.addListener(this.requestEventHandler, this);\r\n }\r\n\r\n private requestEventHandler(type: RpcRequestEvent, request: RpcRequest): void {\r\n if (type !== RpcRequestEvent.StatusChanged)\r\n return;\r\n\r\n switch (request.status) {\r\n case RpcRequestStatus.Submitted: {\r\n this.enqueuePending(request);\r\n break;\r\n }\r\n\r\n case RpcRequestStatus.Resolved:\r\n case RpcRequestStatus.Rejected:\r\n case RpcRequestStatus.NotFound:\r\n case RpcRequestStatus.Cancelled: {\r\n this.dequeuePending(request);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n private enqueuePending(request: RpcRequest) {\r\n this._pending.push(request);\r\n this.setPendingInterval();\r\n }\r\n\r\n private dequeuePending(request: RpcRequest) {\r\n if (this._pendingLock)\r\n return;\r\n\r\n const i = this._pending.indexOf(request);\r\n this._pending.splice(i, 1);\r\n this.clearPendingInterval();\r\n }\r\n\r\n private _pendingIntervalHandler = function (this: RpcPendingQueue) {\r\n const now = new Date().getTime();\r\n\r\n ++this._pendingLock;\r\n\r\n for (const request of this._pending) {\r\n const retry = request.retryAfter ?? request.retryInterval;\r\n if (request.connecting || (request.lastSubmitted + retry) > now) {\r\n continue;\r\n }\r\n\r\n request.submit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n --this._pendingLock;\r\n\r\n this.cleanupPendingQueue();\r\n }.bind(this);\r\n\r\n private cleanupPendingQueue() {\r\n if (this._pendingLock)\r\n return;\r\n\r\n let i = this._pending.length;\r\n while (i--) {\r\n if (!this._pending[i].pending && !RpcRequestStatus.isTransientError(this._pending[i].status)) {\r\n this._pending.splice(i, 1);\r\n }\r\n }\r\n\r\n this.clearPendingInterval();\r\n }\r\n\r\n private setPendingInterval() {\r\n if (this._pendingInterval)\r\n return;\r\n\r\n this._pendingInterval = setInterval(this._pendingIntervalHandler, 0);\r\n }\r\n\r\n private clearPendingInterval() {\r\n if (!this._pending.length) {\r\n clearInterval(this._pendingInterval);\r\n this._pendingInterval = undefined;\r\n }\r\n }\r\n}\r\n"]}
@@ -144,13 +144,12 @@ class RpcRegistry {
144
144
  return implementation;
145
145
  }
146
146
  instantiateClient(definition, routing = RpcRoutingToken_1.RpcRoutingToken.default) {
147
- var _a;
148
147
  this.checkInitialized(definition);
149
148
  const proxy = new definition(routing);
150
149
  if (!this.proxies.has(definition.interfaceName)) {
151
150
  this.proxies.set(definition.interfaceName, new Map());
152
151
  }
153
- (_a = this.proxies.get(definition.interfaceName)) === null || _a === void 0 ? void 0 : _a.set(routing.id, proxy);
152
+ this.proxies.get(definition.interfaceName)?.set(routing.id, proxy);
154
153
  Object.getOwnPropertyNames(definition.prototype).forEach((operationName) => {
155
154
  if (operationName === "constructor" || operationName === "configurationSupplier")
156
155
  return;
@@ -1 +1 @@
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,4CAA4C;AAE5C,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,QAA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uBAAuB;gBAC9E,OAAO;YAET,MAAM,YAAY,GAAG,2BAAY,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;YAEtE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,iBAAS,CAAC,EAAE;gBACnC,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;aACrF;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;YACX,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;SAC/C;IACH,CAAC;IAEO,gBAAgB;QACtB,IAAA,iCAAoB,GAAE,CAAC;QACvB,iCAAe,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC;CACF;AApND,kCAoNC","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/* eslint-disable deprecation/deprecation */\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\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 // eslint-disable-next-line prefer-arrow/prefer-arrow-functions\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
+ {"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,4CAA4C;AAE5C,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,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,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;aACrF;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;YACX,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;SAC/C;IACH,CAAC;IAEO,gBAAgB;QACtB,IAAA,iCAAoB,GAAE,CAAC;QACvB,iCAAe,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC;CACF;AApND,kCAoNC","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/* eslint-disable deprecation/deprecation */\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\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 // eslint-disable-next-line prefer-arrow/prefer-arrow-functions\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"]}
@@ -59,7 +59,6 @@ class BentleyCloudRpcProtocol extends WebAppRpcProtocol_1.WebAppRpcProtocol {
59
59
  }
60
60
  /** Supplies the OpenAPI-compatible URI path for an RPC operation. */
61
61
  supplyPathForOperation(operation, request) {
62
- var _a;
63
62
  const prefix = this.pathPrefix;
64
63
  const appTitle = this.info.title;
65
64
  const appVersion = this.info.version;
@@ -91,7 +90,7 @@ class BentleyCloudRpcProtocol extends WebAppRpcProtocol_1.WebAppRpcProtocol {
91
90
  }
92
91
  iTwinId = encodeURIComponent(token.iTwinId || "");
93
92
  iModelId = encodeURIComponent(token.iModelId);
94
- routeChangesetId = ((_a = token.changeset) === null || _a === void 0 ? void 0 : _a.id) || "0";
93
+ routeChangesetId = token.changeset?.id || "0";
95
94
  appMode = AppMode.MilestoneReview;
96
95
  }
97
96
  return `${prefix}/${appTitle}/${appVersion}/mode/${appMode}/context/${iTwinId}/imodel/${iModelId}${!!routeChangesetId ? `/changeset/${routeChangesetId}` : ""}/${operationId}`;
@@ -101,12 +100,11 @@ class BentleyCloudRpcProtocol extends WebAppRpcProtocol_1.WebAppRpcProtocol {
101
100
  * @note This function updates the IModelRpcProps value supplied in the request body.
102
101
  */
103
102
  inflateToken(tokenFromBody, request) {
104
- var _a, _b, _c;
105
103
  const urlPathComponents = request.path.split("/");
106
104
  const iModelKey = tokenFromBody.key;
107
105
  let iModelId = tokenFromBody.iModelId;
108
106
  let iTwinId = tokenFromBody.iTwinId;
109
- const changeset = { id: (_b = (_a = tokenFromBody.changeset) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : "0", index: (_c = tokenFromBody.changeset) === null || _c === void 0 ? void 0 : _c.index };
107
+ const changeset = { id: tokenFromBody.changeset?.id ?? "0", index: tokenFromBody.changeset?.index };
110
108
  for (let i = 0; i <= urlPathComponents.length; ++i) {
111
109
  const key = urlPathComponents[i];
112
110
  const value = urlPathComponents[i + 1];
@@ -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,4CAA4C;AAE5C,IAAK,OAEJ;AAFD,WAAK,OAAO;IACV,gCAAqB,CAAA;AACvB,CAAC,EAFI,OAAO,KAAP,OAAO,QAEX;AAED;;GAEG;AACH,MAAsB,uBAAwB,SAAQ,qCAAiB;IAAvE;;QACkB,eAAU,GAAG,IAAI,CAAC;QAElC,iFAAiF;QACjE,8CAAyC,GAA0B;YACjF,8CAA8C;YAC9C,EAAE,EAAE,kBAAkB;YAEtB,kDAAkD;YAClD,aAAa,EAAE,kBAAkB;YAEjC,uDAAuD;YACvD,kBAAkB,EAAE,uBAAuB;YAE3C,8CAA8C;YAC9C,SAAS,EAAE,cAAc;YAEzB,iDAAiD;YACjD,aAAa,EAAE,eAAe;SAC/B,CAAC;QAEF,mDAAmD;QACnC,8BAAyB,GAAG,oBAAoB,CAAC;IA6GnE,CAAC;IA3GC,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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AgC,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;AAnID,0DAmIC","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\n/* eslint-disable deprecation/deprecation */\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-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 const iModelKey = tokenFromBody.key;\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 return { key: iModelKey, 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"]}
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,4CAA4C;AAE5C,IAAK,OAEJ;AAFD,WAAK,OAAO;IACV,gCAAqB,CAAA;AACvB,CAAC,EAFI,OAAO,KAAP,OAAO,QAEX;AAED;;GAEG;AACH,MAAsB,uBAAwB,SAAQ,qCAAiB;IAAvE;;QACkB,eAAU,GAAG,IAAI,CAAC;QAElC,iFAAiF;QACjE,8C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,CAAC,CAAC;aACL;iBAAM,IAAI,GAAG,KAAK,QAAQ,EAAE;gBAC3B,QAAQ,GAAG,KAAK,CAAC;gBACjB,EAAE,CAAC,CAAC;aACL;iBAAM,IAAI,GAAG,KAAK,WAAW,EAAE;gBAC9B,SAAS,CAAC,EAAE,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;gBAC5C,EAAE,CAAC,CAAC;aACL;SACF;QAED,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC1D,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;AAnID,0DAmIC","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\n/* eslint-disable deprecation/deprecation */\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-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 const iModelKey = tokenFromBody.key;\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 return { key: iModelKey, 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"]}
@@ -640,12 +640,11 @@ const scratchRangeDiagonal = new core_geometry_1.Vector3d();
640
640
  * @internal
641
641
  */
642
642
  function computeTileChordTolerance(tile, is3d, tileScreenSize) {
643
- var _a;
644
643
  if (tile.range.isNull)
645
644
  return 0;
646
645
  const diagonal = tile.range.diagonal(scratchRangeDiagonal);
647
646
  const diagDist = is3d ? diagonal.magnitude() : diagonal.magnitudeXY();
648
- const mult = Math.max((_a = tile.sizeMultiplier) !== null && _a !== void 0 ? _a : 1, 1);
647
+ const mult = Math.max(tile.sizeMultiplier ?? 1, 1);
649
648
  return diagDist / (tileScreenSize * Constants.minToleranceRatioMultiplier * Math.max(1, mult));
650
649
  }
651
650
  exports.computeTileChordTolerance = computeTileChordTolerance;