@itwin/core-backend 3.7.0-dev.3 → 3.7.0-dev.6

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 (243) hide show
  1. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  2. package/lib/cjs/AliCloudStorageService.js +71 -71
  3. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  4. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  5. package/lib/cjs/BackendHubAccess.js +41 -41
  6. package/lib/cjs/BackendHubAccess.js.map +1 -1
  7. package/lib/cjs/BackendLoggerCategory.d.ts +91 -91
  8. package/lib/cjs/BackendLoggerCategory.js +99 -99
  9. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  10. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  11. package/lib/cjs/BisCoreSchema.js +60 -60
  12. package/lib/cjs/BisCoreSchema.js.map +1 -1
  13. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  14. package/lib/cjs/BriefcaseManager.js +414 -414
  15. package/lib/cjs/BriefcaseManager.js.map +1 -1
  16. package/lib/cjs/Category.d.ts +153 -153
  17. package/lib/cjs/Category.js +243 -243
  18. package/lib/cjs/Category.js.map +1 -1
  19. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  20. package/lib/cjs/ChangeSummaryManager.js +447 -447
  21. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  22. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  23. package/lib/cjs/ChangedElementsDb.js +165 -165
  24. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  25. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  26. package/lib/cjs/ChangedElementsManager.js +88 -88
  27. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  28. package/lib/cjs/CheckpointManager.d.ts +121 -121
  29. package/lib/cjs/CheckpointManager.js +349 -349
  30. package/lib/cjs/CheckpointManager.js.map +1 -1
  31. package/lib/cjs/ClassRegistry.d.ts +79 -79
  32. package/lib/cjs/ClassRegistry.js +250 -250
  33. package/lib/cjs/ClassRegistry.js.map +1 -1
  34. package/lib/cjs/CloudSqlite.d.ts +350 -350
  35. package/lib/cjs/CloudSqlite.js +153 -153
  36. package/lib/cjs/CloudSqlite.js.map +1 -1
  37. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  38. package/lib/cjs/CloudStorageBackend.js +173 -173
  39. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  40. package/lib/cjs/CodeService.d.ts +396 -396
  41. package/lib/cjs/CodeService.js +63 -63
  42. package/lib/cjs/CodeService.js.map +1 -1
  43. package/lib/cjs/CodeSpecs.d.ts +55 -55
  44. package/lib/cjs/CodeSpecs.js +124 -124
  45. package/lib/cjs/CodeSpecs.js.map +1 -1
  46. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  47. package/lib/cjs/ConcurrentQuery.js +36 -36
  48. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  49. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  50. package/lib/cjs/CustomViewState3dCreator.js +82 -82
  51. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  52. package/lib/cjs/DevTools.d.ts +71 -71
  53. package/lib/cjs/DevTools.js +154 -154
  54. package/lib/cjs/DevTools.js.map +1 -1
  55. package/lib/cjs/DisplayStyle.d.ts +106 -106
  56. package/lib/cjs/DisplayStyle.js +256 -256
  57. package/lib/cjs/DisplayStyle.js.map +1 -1
  58. package/lib/cjs/ECDb.d.ts +194 -194
  59. package/lib/cjs/ECDb.js +355 -355
  60. package/lib/cjs/ECDb.js.map +1 -1
  61. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  62. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  63. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  64. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  65. package/lib/cjs/ECSqlStatement.js +791 -791
  66. package/lib/cjs/ECSqlStatement.js.map +1 -1
  67. package/lib/cjs/Element.d.ts +1109 -1109
  68. package/lib/cjs/Element.js +1427 -1427
  69. package/lib/cjs/Element.js.map +1 -1
  70. package/lib/cjs/ElementAspect.d.ts +179 -179
  71. package/lib/cjs/ElementAspect.js +211 -211
  72. package/lib/cjs/ElementAspect.js.map +1 -1
  73. package/lib/cjs/ElementGraphics.d.ts +9 -9
  74. package/lib/cjs/ElementGraphics.js +41 -41
  75. package/lib/cjs/ElementGraphics.js.map +1 -1
  76. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  77. package/lib/cjs/ElementTreeWalker.js +409 -409
  78. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  79. package/lib/cjs/Entity.d.ts +106 -106
  80. package/lib/cjs/Entity.js +134 -134
  81. package/lib/cjs/Entity.js.map +1 -1
  82. package/lib/cjs/EntityReferences.d.ts +49 -49
  83. package/lib/cjs/EntityReferences.js +95 -95
  84. package/lib/cjs/EntityReferences.js.map +1 -1
  85. package/lib/cjs/ExportGraphics.d.ts +317 -317
  86. package/lib/cjs/ExportGraphics.js +208 -208
  87. package/lib/cjs/ExportGraphics.js.map +1 -1
  88. package/lib/cjs/ExternalSource.d.ts +96 -96
  89. package/lib/cjs/ExternalSource.js +131 -131
  90. package/lib/cjs/ExternalSource.js.map +1 -1
  91. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  92. package/lib/cjs/GeoCoordConfig.js +85 -85
  93. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  94. package/lib/cjs/GeometrySummary.d.ts +4 -4
  95. package/lib/cjs/GeometrySummary.js +380 -380
  96. package/lib/cjs/GeometrySummary.js.map +1 -1
  97. package/lib/cjs/HubMock.d.ts +94 -94
  98. package/lib/cjs/HubMock.js +222 -222
  99. package/lib/cjs/HubMock.js.map +1 -1
  100. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  101. package/lib/cjs/IModelCloneContext.js +15 -15
  102. package/lib/cjs/IModelCloneContext.js.map +1 -1
  103. package/lib/cjs/IModelDb.d.ts +1213 -1213
  104. package/lib/cjs/IModelDb.js +2392 -2392
  105. package/lib/cjs/IModelDb.js.map +1 -1
  106. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  107. package/lib/cjs/IModelElementCloneContext.js +159 -159
  108. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  109. package/lib/cjs/IModelHost.d.ts +369 -369
  110. package/lib/cjs/IModelHost.js +496 -496
  111. package/lib/cjs/IModelHost.js.map +1 -1
  112. package/lib/cjs/IModelJsFs.d.ts +62 -62
  113. package/lib/cjs/IModelJsFs.js +140 -140
  114. package/lib/cjs/IModelJsFs.js.map +1 -1
  115. package/lib/cjs/IpcHost.d.ts +104 -104
  116. package/lib/cjs/IpcHost.js +278 -278
  117. package/lib/cjs/IpcHost.js.map +1 -1
  118. package/lib/cjs/LineStyle.d.ts +311 -311
  119. package/lib/cjs/LineStyle.js +295 -295
  120. package/lib/cjs/LineStyle.js.map +1 -1
  121. package/lib/cjs/LocalHub.d.ts +162 -162
  122. package/lib/cjs/LocalHub.js +585 -585
  123. package/lib/cjs/LocalHub.js.map +1 -1
  124. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  125. package/lib/cjs/LocalhostIpcHost.js +81 -81
  126. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  127. package/lib/cjs/Material.d.ts +131 -131
  128. package/lib/cjs/Material.js +181 -181
  129. package/lib/cjs/Material.js.map +1 -1
  130. package/lib/cjs/Model.d.ts +392 -392
  131. package/lib/cjs/Model.js +485 -485
  132. package/lib/cjs/Model.js.map +1 -1
  133. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  134. package/lib/cjs/NativeAppStorage.js +202 -202
  135. package/lib/cjs/NativeAppStorage.js.map +1 -1
  136. package/lib/cjs/NativeHost.d.ts +52 -52
  137. package/lib/cjs/NativeHost.js +163 -163
  138. package/lib/cjs/NativeHost.js.map +1 -1
  139. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  140. package/lib/cjs/NavigationRelationship.js +225 -225
  141. package/lib/cjs/NavigationRelationship.js.map +1 -1
  142. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  143. package/lib/cjs/PromiseMemoizer.js +101 -101
  144. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  145. package/lib/cjs/PropertyStore.d.ts +132 -132
  146. package/lib/cjs/PropertyStore.js +11 -11
  147. package/lib/cjs/PropertyStore.js.map +1 -1
  148. package/lib/cjs/Relationship.d.ts +416 -416
  149. package/lib/cjs/Relationship.js +494 -494
  150. package/lib/cjs/Relationship.js.map +1 -1
  151. package/lib/cjs/RpcBackend.d.ts +5 -5
  152. package/lib/cjs/RpcBackend.js +32 -32
  153. package/lib/cjs/RpcBackend.js.map +1 -1
  154. package/lib/cjs/SQLiteDb.d.ts +219 -219
  155. package/lib/cjs/SQLiteDb.js +214 -214
  156. package/lib/cjs/SQLiteDb.js.map +1 -1
  157. package/lib/cjs/Schema.d.ts +55 -55
  158. package/lib/cjs/Schema.js +83 -83
  159. package/lib/cjs/Schema.js.map +1 -1
  160. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  161. package/lib/cjs/ServerBasedLocks.js +168 -168
  162. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  163. package/lib/cjs/SqliteStatement.d.ts +360 -360
  164. package/lib/cjs/SqliteStatement.js +586 -586
  165. package/lib/cjs/SqliteStatement.js.map +1 -1
  166. package/lib/cjs/Texture.d.ts +58 -58
  167. package/lib/cjs/Texture.js +82 -82
  168. package/lib/cjs/Texture.js.map +1 -1
  169. package/lib/cjs/TileStorage.d.ts +18 -18
  170. package/lib/cjs/TileStorage.js +90 -90
  171. package/lib/cjs/TileStorage.js.map +1 -1
  172. package/lib/cjs/TxnManager.d.ts +202 -202
  173. package/lib/cjs/TxnManager.js +356 -356
  174. package/lib/cjs/TxnManager.js.map +1 -1
  175. package/lib/cjs/ViewDefinition.d.ts +439 -439
  176. package/lib/cjs/ViewDefinition.js +646 -646
  177. package/lib/cjs/ViewDefinition.js.map +1 -1
  178. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  179. package/lib/cjs/ViewStateHydrator.js +103 -103
  180. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  181. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  182. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  183. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  184. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  185. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  186. package/lib/cjs/core-backend.d.ts +184 -184
  187. package/lib/cjs/core-backend.js +204 -204
  188. package/lib/cjs/core-backend.js.map +1 -1
  189. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  190. package/lib/cjs/domains/FunctionalElements.js +145 -145
  191. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  192. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  193. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  194. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  195. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  196. package/lib/cjs/domains/GenericElements.js +263 -263
  197. package/lib/cjs/domains/GenericElements.js.map +1 -1
  198. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  199. package/lib/cjs/domains/GenericSchema.js +28 -28
  200. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  201. package/lib/cjs/rpc/multipart.d.ts +11 -11
  202. package/lib/cjs/rpc/multipart.js +71 -71
  203. package/lib/cjs/rpc/multipart.js.map +1 -1
  204. package/lib/cjs/rpc/tracing.d.ts +28 -28
  205. package/lib/cjs/rpc/tracing.js +74 -74
  206. package/lib/cjs/rpc/tracing.js.map +1 -1
  207. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  208. package/lib/cjs/rpc/web/logging.js +43 -43
  209. package/lib/cjs/rpc/web/logging.js.map +1 -1
  210. package/lib/cjs/rpc/web/request.d.ts +6 -6
  211. package/lib/cjs/rpc/web/request.js +74 -74
  212. package/lib/cjs/rpc/web/request.js.map +1 -1
  213. package/lib/cjs/rpc/web/response.d.ts +6 -6
  214. package/lib/cjs/rpc/web/response.js +106 -106
  215. package/lib/cjs/rpc/web/response.js.map +1 -1
  216. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  217. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  218. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  219. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  220. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +294 -294
  221. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  222. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  223. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +205 -205
  224. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  225. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  226. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
  227. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  228. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  229. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  230. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  231. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  232. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  233. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  234. package/lib/cjs/workspace/Settings.d.ts +186 -186
  235. package/lib/cjs/workspace/Settings.js +155 -155
  236. package/lib/cjs/workspace/Settings.js.map +1 -1
  237. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  238. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  239. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  240. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  241. package/lib/cjs/workspace/Workspace.js +543 -543
  242. package/lib/cjs/workspace/Workspace.js.map +1 -1
  243. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAA6G;AAC7G,yBAAyB;AAEzB,4CAA4C;AAE5C,MAAa,uBAAwB,SAAQ,8BAAgB;IACxC,KAAK,CAAC,gBAAgB,CAAC,KAAuB,EAAE,MAAqB;QACtF,QAAQ,KAAK,EAAE;YACb,KAAK,8BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACxJ,KAAK,8BAAgB,CAAC,oBAAoB,CAAC,CAAC,OAAO,IAAI,CAAC,eAAe,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;YAC9G,KAAK,8BAAgB,CAAC,sBAAsB,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,+BAA+B,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;SACjM;IACH,CAAC;IAEkB,WAAW;QAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,UAAyB;QACtE,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAChF,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,2CAA2C;QAElH,qBAAM,CAAC,OAAO,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACnG,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,MAAM;YACjC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI;YAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,YAAY;YACZ,uGAAuG;YACvG,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AA9BD,0DA8BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { CommonLoggerCategory, RpcInvocation, RpcProtocolEvent, WebAppRpcLogging } from \"@itwin/core-common\";\nimport * as os from \"os\";\n\n/* eslint-disable deprecation/deprecation */\n\nexport class WebAppRpcLoggingBackend extends WebAppRpcLogging {\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: RpcInvocation): Promise<void> {\n switch (event) {\n case RpcProtocolEvent.RequestReceived: return this.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\n case RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend(\"RpcInterface.backend.error\", object);\n case RpcProtocolEvent.BackendResponseCreated: return this.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\n }\n }\n\n protected override getHostname(): string {\n return os.hostname();\n }\n\n private async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\n const operationDescriptor = this.buildOperationDescriptor(invocation.operation);\n const pathIds = this.findPathIds(invocation.request.path);\n const result = await invocation.result;\n const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue\n\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({\n method: invocation.request.method,\n path: invocation.request.path,\n status: invocation.status,\n errorMessage,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: invocation.request.id, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n"]}
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAA6G;AAC7G,yBAAyB;AAEzB,4CAA4C;AAE5C,MAAa,uBAAwB,SAAQ,8BAAgB;IACxC,KAAK,CAAC,gBAAgB,CAAC,KAAuB,EAAE,MAAqB;QACtF,QAAQ,KAAK,EAAE;YACb,KAAK,8BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACxJ,KAAK,8BAAgB,CAAC,oBAAoB,CAAC,CAAC,OAAO,IAAI,CAAC,eAAe,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;YAC9G,KAAK,8BAAgB,CAAC,sBAAsB,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,+BAA+B,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;SACjM;IACH,CAAC;IAEkB,WAAW;QAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,UAAyB;QACtE,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAChF,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,2CAA2C;QAElH,qBAAM,CAAC,OAAO,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACnG,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,MAAM;YACjC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI;YAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,YAAY;YACZ,uGAAuG;YACvG,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AA9BD,0DA8BC","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 { Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory, RpcInvocation, RpcProtocolEvent, WebAppRpcLogging } from \"@itwin/core-common\";\r\nimport * as os from \"os\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nexport class WebAppRpcLoggingBackend extends WebAppRpcLogging {\r\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: RpcInvocation): Promise<void> {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestReceived: return this.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\r\n case RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend(\"RpcInterface.backend.error\", object);\r\n case RpcProtocolEvent.BackendResponseCreated: return this.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\r\n }\r\n }\r\n\r\n protected override getHostname(): string {\r\n return os.hostname();\r\n }\r\n\r\n private async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\r\n const operationDescriptor = this.buildOperationDescriptor(invocation.operation);\r\n const pathIds = this.findPathIds(invocation.request.path);\r\n const result = await invocation.result;\r\n const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({\r\n method: invocation.request.method,\r\n path: invocation.request.path,\r\n status: invocation.status,\r\n errorMessage,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: invocation.request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
- /** @packageDocumentation
2
- * @module RpcInterface
3
- */
4
- import { HttpServerRequest, SerializedRpcRequest, WebAppRpcProtocol } from "@itwin/core-common";
5
- /** @internal */
6
- export declare function parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest>;
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { HttpServerRequest, SerializedRpcRequest, WebAppRpcProtocol } from "@itwin/core-common";
5
+ /** @internal */
6
+ export declare function parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest>;
7
7
  //# sourceMappingURL=request.d.ts.map
@@ -1,75 +1,75 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module RpcInterface
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.parseRequest = void 0;
11
- const core_common_1 = require("@itwin/core-common");
12
- /* eslint-disable deprecation/deprecation */
13
- function parseHeaders(protocol, req) {
14
- var _a;
15
- const headerNames = protocol.serializedClientRequestContextHeaderNames;
16
- const parsedHeaders = {
17
- id: req.header(headerNames.id) || "",
18
- applicationId: req.header(headerNames.applicationId) || "",
19
- applicationVersion: req.header(headerNames.applicationVersion) || "",
20
- sessionId: req.header(headerNames.sessionId) || "",
21
- authorization: (_a = (headerNames.authorization ? req.header(headerNames.authorization) : "")) !== null && _a !== void 0 ? _a : "",
22
- };
23
- return parsedHeaders;
24
- }
25
- function parseFromPath(operation) {
26
- const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, "base64").toString("binary") : "";
27
- return core_common_1.RpcSerializedValue.create(decoded);
28
- }
29
- async function parseFromBody(req) {
30
- const contentType = core_common_1.WebAppRpcProtocol.computeContentType(req.header(core_common_1.WEB_RPC_CONSTANTS.CONTENT));
31
- if (contentType === core_common_1.RpcContentType.Binary) {
32
- const objects = JSON.stringify([core_common_1.MarshalingBinaryMarker.createDefault()]);
33
- const data = [req.body];
34
- return core_common_1.RpcSerializedValue.create(objects, data);
35
- }
36
- else if (contentType === core_common_1.RpcContentType.Multipart) {
37
- return core_common_1.RpcMultipart.parseRequest(req);
38
- }
39
- else {
40
- return core_common_1.RpcSerializedValue.create(req.body);
41
- }
42
- }
43
- /** @internal */
44
- async function parseRequest(protocol, req) {
45
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
46
- const operation = protocol.getOperationFromPath(req.url);
47
- const parsedHeaders = parseHeaders(protocol, req);
48
- const request = {
49
- ...parsedHeaders,
50
- operation: {
51
- interfaceDefinition: operation.interfaceDefinition,
52
- operationName: operation.operationName,
53
- interfaceVersion: operation.interfaceVersion,
54
- },
55
- method: req.method,
56
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
57
- path: req.url,
58
- parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),
59
- caching: operation.encodedRequest ? core_common_1.RpcResponseCacheControl.Immutable : core_common_1.RpcResponseCacheControl.None,
60
- };
61
- request.ip = req.ip;
62
- request.protocolVersion = 0;
63
- if (protocol.protocolVersionHeaderName) {
64
- const version = req.header(protocol.protocolVersionHeaderName);
65
- if (version) {
66
- request.protocolVersion = parseInt(version, 10);
67
- }
68
- }
69
- if (!request.id) {
70
- throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);
71
- }
72
- return request;
73
- }
74
- exports.parseRequest = parseRequest;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.parseRequest = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ /* eslint-disable deprecation/deprecation */
13
+ function parseHeaders(protocol, req) {
14
+ var _a;
15
+ const headerNames = protocol.serializedClientRequestContextHeaderNames;
16
+ const parsedHeaders = {
17
+ id: req.header(headerNames.id) || "",
18
+ applicationId: req.header(headerNames.applicationId) || "",
19
+ applicationVersion: req.header(headerNames.applicationVersion) || "",
20
+ sessionId: req.header(headerNames.sessionId) || "",
21
+ authorization: (_a = (headerNames.authorization ? req.header(headerNames.authorization) : "")) !== null && _a !== void 0 ? _a : "",
22
+ };
23
+ return parsedHeaders;
24
+ }
25
+ function parseFromPath(operation) {
26
+ const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, "base64").toString("binary") : "";
27
+ return core_common_1.RpcSerializedValue.create(decoded);
28
+ }
29
+ async function parseFromBody(req) {
30
+ const contentType = core_common_1.WebAppRpcProtocol.computeContentType(req.header(core_common_1.WEB_RPC_CONSTANTS.CONTENT));
31
+ if (contentType === core_common_1.RpcContentType.Binary) {
32
+ const objects = JSON.stringify([core_common_1.MarshalingBinaryMarker.createDefault()]);
33
+ const data = [req.body];
34
+ return core_common_1.RpcSerializedValue.create(objects, data);
35
+ }
36
+ else if (contentType === core_common_1.RpcContentType.Multipart) {
37
+ return core_common_1.RpcMultipart.parseRequest(req);
38
+ }
39
+ else {
40
+ return core_common_1.RpcSerializedValue.create(req.body);
41
+ }
42
+ }
43
+ /** @internal */
44
+ async function parseRequest(protocol, req) {
45
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
46
+ const operation = protocol.getOperationFromPath(req.url);
47
+ const parsedHeaders = parseHeaders(protocol, req);
48
+ const request = {
49
+ ...parsedHeaders,
50
+ operation: {
51
+ interfaceDefinition: operation.interfaceDefinition,
52
+ operationName: operation.operationName,
53
+ interfaceVersion: operation.interfaceVersion,
54
+ },
55
+ method: req.method,
56
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
57
+ path: req.url,
58
+ parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),
59
+ caching: operation.encodedRequest ? core_common_1.RpcResponseCacheControl.Immutable : core_common_1.RpcResponseCacheControl.None,
60
+ };
61
+ request.ip = req.ip;
62
+ request.protocolVersion = 0;
63
+ if (protocol.protocolVersionHeaderName) {
64
+ const version = req.header(protocol.protocolVersionHeaderName);
65
+ if (version) {
66
+ request.protocolVersion = parseInt(version, 10);
67
+ }
68
+ }
69
+ if (!request.id) {
70
+ throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);
71
+ }
72
+ return request;
73
+ }
74
+ exports.parseRequest = parseRequest;
75
75
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/rpc/web/request.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAc4B;AAE5B,4CAA4C;AAE5C,SAAS,YAAY,CAAC,QAA2B,EAAE,GAAsB;;IACvE,MAAM,WAAW,GAA0B,QAAQ,CAAC,yCAAyC,CAAC;IAC9F,MAAM,aAAa,GAA0B;QAC3C,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QACpC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,EAAE;QAC1D,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE;QACpE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE;QAClD,aAAa,EAAE,MAAA,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,mCAAI,EAAE;KAC9F,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,aAAa,CAAC,SAAiC;IACtD,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC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,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC;QAC1F,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,qCAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,qCAAuB,CAAC,IAAI;KACrG,CAAC;IAEF,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;IAEpB,OAAO,CAAC,eAAe,GAAG,CAAC,CAAC;IAE5B,IAAI,QAAQ,CAAC,yBAAyB,EAAE;QACtC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;QAC/D,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SACjD;KACF;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,gDAAgD,CAAC,CAAC;KAC9F;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,oCAoCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport {\n BentleyStatus,\n HttpServerRequest,\n IModelError,\n MarshalingBinaryMarker,\n RpcContentType,\n RpcMultipart,\n RpcResponseCacheControl,\n RpcSerializedValue,\n SerializedRpcActivity,\n SerializedRpcOperation,\n SerializedRpcRequest,\n WEB_RPC_CONSTANTS,\n WebAppRpcProtocol,\n} from \"@itwin/core-common\";\n\n/* eslint-disable deprecation/deprecation */\n\nfunction parseHeaders(protocol: WebAppRpcProtocol, req: HttpServerRequest): SerializedRpcActivity {\n const headerNames: SerializedRpcActivity = protocol.serializedClientRequestContextHeaderNames;\n const parsedHeaders: SerializedRpcActivity = {\n id: req.header(headerNames.id) || \"\",\n applicationId: req.header(headerNames.applicationId) || \"\",\n applicationVersion: req.header(headerNames.applicationVersion) || \"\",\n sessionId: req.header(headerNames.sessionId) || \"\",\n authorization: (headerNames.authorization ? req.header(headerNames.authorization) : \"\") ?? \"\",\n };\n return parsedHeaders;\n}\n\nfunction parseFromPath(operation: SerializedRpcOperation): RpcSerializedValue {\n const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, \"base64\").toString(\"binary\") : \"\";\n return RpcSerializedValue.create(decoded);\n}\n\nasync function parseFromBody(req: HttpServerRequest): Promise<RpcSerializedValue> {\n const contentType = WebAppRpcProtocol.computeContentType(req.header(WEB_RPC_CONSTANTS.CONTENT));\n if (contentType === RpcContentType.Binary) {\n const objects = JSON.stringify([MarshalingBinaryMarker.createDefault()]);\n const data = [req.body as Buffer];\n return RpcSerializedValue.create(objects, data);\n } else if (contentType === RpcContentType.Multipart) {\n return RpcMultipart.parseRequest(req);\n } else {\n return RpcSerializedValue.create(req.body as string);\n }\n}\n\n/** @internal */\nexport async function parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const operation = protocol.getOperationFromPath(req.url!);\n\n const parsedHeaders = parseHeaders(protocol, req);\n\n const request: SerializedRpcRequest = {\n ...parsedHeaders,\n operation: {\n interfaceDefinition: operation.interfaceDefinition,\n operationName: operation.operationName,\n interfaceVersion: operation.interfaceVersion,\n },\n method: req.method,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n path: req.url!,\n parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),\n caching: operation.encodedRequest ? RpcResponseCacheControl.Immutable : RpcResponseCacheControl.None,\n };\n\n request.ip = req.ip;\n\n request.protocolVersion = 0;\n\n if (protocol.protocolVersionHeaderName) {\n const version = req.header(protocol.protocolVersionHeaderName);\n if (version) {\n request.protocolVersion = parseInt(version, 10);\n }\n }\n\n if (!request.id) {\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);\n }\n\n return request;\n}\n"]}
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/rpc/web/request.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAc4B;AAE5B,4CAA4C;AAE5C,SAAS,YAAY,CAAC,QAA2B,EAAE,GAAsB;;IACvE,MAAM,WAAW,GAA0B,QAAQ,CAAC,yCAAyC,CAAC;IAC9F,MAAM,aAAa,GAA0B;QAC3C,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QACpC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,EAAE;QAC1D,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE;QACpE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE;QAClD,aAAa,EAAE,MAAA,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,mCAAI,EAAE;KAC9F,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,aAAa,CAAC,SAAiC;IACtD,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnH,OAAO,gCAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,G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1F,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,qCAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,qCAAuB,CAAC,IAAI;KACrG,CAAC;IAEF,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;IAEpB,OAAO,CAAC,eAAe,GAAG,CAAC,CAAC;IAE5B,IAAI,QAAQ,CAAC,yBAAyB,EAAE;QACtC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;QAC/D,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SACjD;KACF;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,gDAAgD,CAAC,CAAC;KAC9F;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,oCAoCC","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 {\r\n BentleyStatus,\r\n HttpServerRequest,\r\n IModelError,\r\n MarshalingBinaryMarker,\r\n RpcContentType,\r\n RpcMultipart,\r\n RpcResponseCacheControl,\r\n RpcSerializedValue,\r\n SerializedRpcActivity,\r\n SerializedRpcOperation,\r\n SerializedRpcRequest,\r\n WEB_RPC_CONSTANTS,\r\n WebAppRpcProtocol,\r\n} from \"@itwin/core-common\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction parseHeaders(protocol: WebAppRpcProtocol, req: HttpServerRequest): SerializedRpcActivity {\r\n const headerNames: SerializedRpcActivity = protocol.serializedClientRequestContextHeaderNames;\r\n const parsedHeaders: SerializedRpcActivity = {\r\n id: req.header(headerNames.id) || \"\",\r\n applicationId: req.header(headerNames.applicationId) || \"\",\r\n applicationVersion: req.header(headerNames.applicationVersion) || \"\",\r\n sessionId: req.header(headerNames.sessionId) || \"\",\r\n authorization: (headerNames.authorization ? req.header(headerNames.authorization) : \"\") ?? \"\",\r\n };\r\n return parsedHeaders;\r\n}\r\n\r\nfunction parseFromPath(operation: SerializedRpcOperation): RpcSerializedValue {\r\n const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, \"base64\").toString(\"binary\") : \"\";\r\n return RpcSerializedValue.create(decoded);\r\n}\r\n\r\nasync function parseFromBody(req: HttpServerRequest): Promise<RpcSerializedValue> {\r\n const contentType = WebAppRpcProtocol.computeContentType(req.header(WEB_RPC_CONSTANTS.CONTENT));\r\n if (contentType === RpcContentType.Binary) {\r\n const objects = JSON.stringify([MarshalingBinaryMarker.createDefault()]);\r\n const data = [req.body as Buffer];\r\n return RpcSerializedValue.create(objects, data);\r\n } else if (contentType === RpcContentType.Multipart) {\r\n return RpcMultipart.parseRequest(req);\r\n } else {\r\n return RpcSerializedValue.create(req.body as string);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport async function parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n const operation = protocol.getOperationFromPath(req.url!);\r\n\r\n const parsedHeaders = parseHeaders(protocol, req);\r\n\r\n const request: SerializedRpcRequest = {\r\n ...parsedHeaders,\r\n operation: {\r\n interfaceDefinition: operation.interfaceDefinition,\r\n operationName: operation.operationName,\r\n interfaceVersion: operation.interfaceVersion,\r\n },\r\n method: req.method,\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n path: req.url!,\r\n parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),\r\n caching: operation.encodedRequest ? RpcResponseCacheControl.Immutable : RpcResponseCacheControl.None,\r\n };\r\n\r\n request.ip = req.ip;\r\n\r\n request.protocolVersion = 0;\r\n\r\n if (protocol.protocolVersionHeaderName) {\r\n const version = req.header(protocol.protocolVersionHeaderName);\r\n if (version) {\r\n request.protocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n if (!request.id) {\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);\r\n }\r\n\r\n return request;\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
- /** @packageDocumentation
2
- * @module RpcInterface
3
- */
4
- import { HttpServerRequest, HttpServerResponse, RpcRequestFulfillment, SerializedRpcRequest, WebAppRpcProtocol } from "@itwin/core-common";
5
- /** @internal */
6
- export declare function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { HttpServerRequest, HttpServerResponse, RpcRequestFulfillment, SerializedRpcRequest, WebAppRpcProtocol } from "@itwin/core-common";
5
+ /** @internal */
6
+ export declare function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
7
7
  //# sourceMappingURL=response.d.ts.map
@@ -1,107 +1,107 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module RpcInterface
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.sendResponse = void 0;
11
- const core_common_1 = require("@itwin/core-common");
12
- /* eslint-disable deprecation/deprecation */
13
- function configureResponse(protocol, request, fulfillment, res) {
14
- const success = protocol.getStatus(fulfillment.status) === core_common_1.RpcRequestStatus.Resolved;
15
- // TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.
16
- // This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.
17
- // RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.
18
- const oneHourInSeconds = 3600;
19
- if (success && request.caching === core_common_1.RpcResponseCacheControl.Immutable) {
20
- // If response size is > 50 MB, do not cache it.
21
- if (fulfillment.result.objects.length > (50 * 10 ** 7)) {
22
- res.set("Cache-Control", "no-store");
23
- }
24
- else if (request.operation.operationName === "generateTileContent") {
25
- res.set("Cache-Control", "no-store");
26
- }
27
- else if (request.operation.operationName === "getConnectionProps") {
28
- // GetConnectionprops can't be cached on the browser longer than the lifespan of the backend. The lifespan of backend may shrink too. Keep it at 1 second to be safe.
29
- res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);
30
- }
31
- else if (request.operation.operationName === "getTileCacheContainerUrl") {
32
- // getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.
33
- res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);
34
- }
35
- else {
36
- res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);
37
- }
38
- }
39
- if (fulfillment.retry) {
40
- res.set("Retry-After", fulfillment.retry);
41
- }
42
- }
43
- function configureText(fulfillment, res) {
44
- res.set(core_common_1.WEB_RPC_CONSTANTS.CONTENT, core_common_1.WEB_RPC_CONSTANTS.TEXT);
45
- return (fulfillment.status === 204) ? "" : fulfillment.result.objects;
46
- }
47
- function configureBinary(fulfillment, res) {
48
- res.set(core_common_1.WEB_RPC_CONSTANTS.CONTENT, core_common_1.WEB_RPC_CONSTANTS.BINARY);
49
- const data = fulfillment.result.data[0];
50
- return Buffer.isBuffer(data) ? data : Buffer.from(data);
51
- }
52
- function configureMultipart(fulfillment, res) {
53
- const response = core_common_1.RpcMultipart.createStream(fulfillment.result);
54
- const headers = response.getHeaders();
55
- for (const header in headers) {
56
- if (headers.hasOwnProperty(header)) {
57
- res.set(header, headers[header]);
58
- }
59
- }
60
- return response;
61
- }
62
- function configureStream(fulfillment) {
63
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
- return fulfillment.result.stream;
65
- }
66
- /** @internal */
67
- async function sendResponse(protocol, request, fulfillment, req, res) {
68
- var _a;
69
- const versionHeader = protocol.protocolVersionHeaderName;
70
- if (versionHeader && core_common_1.RpcProtocol.protocolVersion) {
71
- res.set(versionHeader, core_common_1.RpcProtocol.protocolVersion.toString());
72
- }
73
- // eslint-disable-next-line @typescript-eslint/naming-convention
74
- const { Readable, Stream } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "stream"));
75
- const { createGzip } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "zlib"));
76
- const transportType = core_common_1.WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);
77
- let responseBody;
78
- if (transportType === core_common_1.RpcContentType.Binary) {
79
- responseBody = configureBinary(fulfillment, res);
80
- }
81
- else if (transportType === core_common_1.RpcContentType.Multipart) {
82
- responseBody = configureMultipart(fulfillment, res);
83
- }
84
- else if (transportType === core_common_1.RpcContentType.Stream) {
85
- responseBody = configureStream(fulfillment);
86
- }
87
- else {
88
- responseBody = configureText(fulfillment, res);
89
- }
90
- configureResponse(protocol, request, fulfillment, res);
91
- res.status(fulfillment.status);
92
- if (fulfillment.allowCompression && ((_a = req.header("Accept-Encoding")) === null || _a === void 0 ? void 0 : _a.includes("gzip"))) {
93
- res.set("Content-Encoding", "gzip");
94
- const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);
95
- responseBody = readableResponseBody.pipe(createGzip());
96
- }
97
- // This check should in theory look for instances of Readable, but that would break backend implementation at
98
- // core/backend/src/RpcBackend.ts
99
- if (responseBody instanceof Stream) {
100
- responseBody.pipe(res);
101
- }
102
- else {
103
- res.send(responseBody);
104
- }
105
- }
106
- exports.sendResponse = sendResponse;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.sendResponse = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ /* eslint-disable deprecation/deprecation */
13
+ function configureResponse(protocol, request, fulfillment, res) {
14
+ const success = protocol.getStatus(fulfillment.status) === core_common_1.RpcRequestStatus.Resolved;
15
+ // TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.
16
+ // This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.
17
+ // RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.
18
+ const oneHourInSeconds = 3600;
19
+ if (success && request.caching === core_common_1.RpcResponseCacheControl.Immutable) {
20
+ // If response size is > 50 MB, do not cache it.
21
+ if (fulfillment.result.objects.length > (50 * 10 ** 7)) {
22
+ res.set("Cache-Control", "no-store");
23
+ }
24
+ else if (request.operation.operationName === "generateTileContent") {
25
+ res.set("Cache-Control", "no-store");
26
+ }
27
+ else if (request.operation.operationName === "getConnectionProps") {
28
+ // GetConnectionprops can't be cached on the browser longer than the lifespan of the backend. The lifespan of backend may shrink too. Keep it at 1 second to be safe.
29
+ res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);
30
+ }
31
+ else if (request.operation.operationName === "getTileCacheContainerUrl") {
32
+ // getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.
33
+ res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);
34
+ }
35
+ else {
36
+ res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);
37
+ }
38
+ }
39
+ if (fulfillment.retry) {
40
+ res.set("Retry-After", fulfillment.retry);
41
+ }
42
+ }
43
+ function configureText(fulfillment, res) {
44
+ res.set(core_common_1.WEB_RPC_CONSTANTS.CONTENT, core_common_1.WEB_RPC_CONSTANTS.TEXT);
45
+ return (fulfillment.status === 204) ? "" : fulfillment.result.objects;
46
+ }
47
+ function configureBinary(fulfillment, res) {
48
+ res.set(core_common_1.WEB_RPC_CONSTANTS.CONTENT, core_common_1.WEB_RPC_CONSTANTS.BINARY);
49
+ const data = fulfillment.result.data[0];
50
+ return Buffer.isBuffer(data) ? data : Buffer.from(data);
51
+ }
52
+ function configureMultipart(fulfillment, res) {
53
+ const response = core_common_1.RpcMultipart.createStream(fulfillment.result);
54
+ const headers = response.getHeaders();
55
+ for (const header in headers) {
56
+ if (headers.hasOwnProperty(header)) {
57
+ res.set(header, headers[header]);
58
+ }
59
+ }
60
+ return response;
61
+ }
62
+ function configureStream(fulfillment) {
63
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
+ return fulfillment.result.stream;
65
+ }
66
+ /** @internal */
67
+ async function sendResponse(protocol, request, fulfillment, req, res) {
68
+ var _a;
69
+ const versionHeader = protocol.protocolVersionHeaderName;
70
+ if (versionHeader && core_common_1.RpcProtocol.protocolVersion) {
71
+ res.set(versionHeader, core_common_1.RpcProtocol.protocolVersion.toString());
72
+ }
73
+ // eslint-disable-next-line @typescript-eslint/naming-convention
74
+ const { Readable, Stream } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "stream"));
75
+ const { createGzip } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "zlib"));
76
+ const transportType = core_common_1.WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);
77
+ let responseBody;
78
+ if (transportType === core_common_1.RpcContentType.Binary) {
79
+ responseBody = configureBinary(fulfillment, res);
80
+ }
81
+ else if (transportType === core_common_1.RpcContentType.Multipart) {
82
+ responseBody = configureMultipart(fulfillment, res);
83
+ }
84
+ else if (transportType === core_common_1.RpcContentType.Stream) {
85
+ responseBody = configureStream(fulfillment);
86
+ }
87
+ else {
88
+ responseBody = configureText(fulfillment, res);
89
+ }
90
+ configureResponse(protocol, request, fulfillment, res);
91
+ res.status(fulfillment.status);
92
+ if (fulfillment.allowCompression && ((_a = req.header("Accept-Encoding")) === null || _a === void 0 ? void 0 : _a.includes("gzip"))) {
93
+ res.set("Content-Encoding", "gzip");
94
+ const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);
95
+ responseBody = readableResponseBody.pipe(createGzip());
96
+ }
97
+ // This check should in theory look for instances of Readable, but that would break backend implementation at
98
+ // core/backend/src/RpcBackend.ts
99
+ if (responseBody instanceof Stream) {
100
+ responseBody.pipe(res);
101
+ }
102
+ else {
103
+ res.send(responseBody);
104
+ }
105
+ }
106
+ exports.sendResponse = sendResponse;
107
107
  //# sourceMappingURL=response.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAc4B;AAE5B,4CAA4C;AAE5C,SAAS,iBAAiB,CAAC,QAA2B,EAAE,OAA6B,EAAE,WAAkC,EAAE,GAAuB;IAChJ,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,8BAAgB,CAAC,QAAQ,CAAC;IACrF,iJAAiJ;IACjJ,kJAAkJ;IAElJ,yFAAyF;IACzF,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAC9B,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,KAAK,qCAAuB,CAAC,SAAS,EAAE;QACpE,gDAAgD;QAChD,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE;YACtD,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;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------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport {\n HttpServerRequest,\n HttpServerResponse,\n ReadableFormData,\n RpcContentType,\n RpcMultipart,\n RpcProtocol,\n RpcRequestFulfillment,\n RpcRequestStatus,\n RpcResponseCacheControl,\n SerializedRpcRequest,\n WEB_RPC_CONSTANTS,\n WebAppRpcProtocol,\n WebAppRpcRequest,\n} from \"@itwin/core-common\";\n\n/* eslint-disable deprecation/deprecation */\n\nfunction configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\n // TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.\n // This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.\n\n // RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.\n const oneHourInSeconds = 3600;\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\n // If response size is > 50 MB, do not cache it.\n if (fulfillment.result.objects.length > (50 * 10 ** 7)) {\n res.set(\"Cache-Control\", \"no-store\");\n } else if (request.operation.operationName === \"generateTileContent\") {\n res.set(\"Cache-Control\", \"no-store\");\n } else if (request.operation.operationName === \"getConnectionProps\") {\n // GetConnectionprops can't be cached on the browser longer than the lifespan of the backend. The lifespan of backend may shrink too. Keep it at 1 second to be safe.\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);\n } else if (request.operation.operationName === \"getTileCacheContainerUrl\") {\n // getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);\n } else {\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);\n }\n }\n\n if (fulfillment.retry) {\n res.set(\"Retry-After\", fulfillment.retry);\n }\n}\n\nfunction configureText(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): string {\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.TEXT);\n return (fulfillment.status === 204) ? \"\" : fulfillment.result.objects;\n}\n\nfunction configureBinary(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): Buffer {\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.BINARY);\n const data = fulfillment.result.data[0];\n return Buffer.isBuffer(data) ? data : Buffer.from(data);\n}\n\nfunction configureMultipart(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): ReadableFormData {\n const response = RpcMultipart.createStream(fulfillment.result);\n const headers = response.getHeaders();\n for (const header in headers) {\n if (headers.hasOwnProperty(header)) {\n res.set(header, headers[header]);\n }\n }\n\n return response;\n}\n\nfunction configureStream(fulfillment: RpcRequestFulfillment) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return fulfillment.result.stream!;\n}\n\n/** @internal */\nexport async function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse) {\n const versionHeader = protocol.protocolVersionHeaderName;\n if (versionHeader && RpcProtocol.protocolVersion) {\n res.set(versionHeader, RpcProtocol.protocolVersion.toString());\n }\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { Readable, Stream } = await import(/* webpackIgnore: true */ \"stream\");\n const { createGzip } = await import(/* webpackIgnore: true */ \"zlib\");\n\n const transportType = WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);\n let responseBody;\n if (transportType === RpcContentType.Binary) {\n responseBody = configureBinary(fulfillment, res);\n } else if (transportType === RpcContentType.Multipart) {\n responseBody = configureMultipart(fulfillment, res);\n } else if (transportType === RpcContentType.Stream) {\n responseBody = configureStream(fulfillment);\n } else {\n responseBody = configureText(fulfillment, res);\n }\n\n configureResponse(protocol, request, fulfillment, res);\n res.status(fulfillment.status);\n\n if (fulfillment.allowCompression && req.header(\"Accept-Encoding\")?.includes(\"gzip\")) {\n res.set(\"Content-Encoding\", \"gzip\");\n const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);\n responseBody = readableResponseBody.pipe(createGzip());\n }\n\n // This check should in theory look for instances of Readable, but that would break backend implementation at\n // core/backend/src/RpcBackend.ts\n if (responseBody instanceof Stream) {\n responseBody.pipe(res);\n } else {\n res.send(responseBody);\n }\n}\n"]}
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAc4B;AAE5B,4CAA4C;AAE5C,SAAS,iBAAiB,CAAC,QAA2B,EAAE,OAA6B,EAAE,WAAkC,EAAE,GAAuB;IAChJ,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,8BAAgB,CAAC,QAAQ,CAAC;IACrF,iJAAiJ;IACjJ,kJAAkJ;IAElJ,yFAAyF;IACzF,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAC9B,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,KAAK,qCAAuB,CAAC,SAAS,EAAE;QACpE,gDAAgD;QAChD,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE;YACtD,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;SACtC;aAAM,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,KAAK,qBAAqB,EAAE;YACpE,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;SACtC;aAAM,IAAI,OAAO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AAG,CAAC,CAAC;KAClD;SAAM,IAAI,aAAa,KAAK,4BAAc,CAAC,SAAS,EAAE;QACrD,YAAY,GAAG,kBAAkB,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;KACrD;SAAM,IAAI,aAAa,KAAK,4BAAc,CAAC,MAAM,EAAE;QAClD,YAAY,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;KAC7C;SAAM;QACL,YAAY,GAAG,aAAa,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;KAChD;IAED,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;IACvD,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAE/B,IAAI,WAAW,CAAC,gBAAgB,KAAI,MAAA,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,0CAAE,QAAQ,CAAC,MAAM,CAAC,CAAA,EAAE;QACnF,GAAG,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QACpC,MAAM,oBAAoB,GAAG,CAAC,YAAY,YAAY,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3G,YAAY,GAAG,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;KACxD;IAED,6GAA6G;IAC7G,iCAAiC;IACjC,IAAI,YAAY,YAAY,MAAM,EAAE;QAClC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACxB;SAAM;QACL,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACxB;AACH,CAAC;AArCD,oCAqCC","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 {\r\n HttpServerRequest,\r\n HttpServerResponse,\r\n ReadableFormData,\r\n RpcContentType,\r\n RpcMultipart,\r\n RpcProtocol,\r\n RpcRequestFulfillment,\r\n RpcRequestStatus,\r\n RpcResponseCacheControl,\r\n SerializedRpcRequest,\r\n WEB_RPC_CONSTANTS,\r\n WebAppRpcProtocol,\r\n WebAppRpcRequest,\r\n} from \"@itwin/core-common\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\r\n // TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.\r\n // This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.\r\n\r\n // RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.\r\n const oneHourInSeconds = 3600;\r\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\r\n // If response size is > 50 MB, do not cache it.\r\n if (fulfillment.result.objects.length > (50 * 10 ** 7)) {\r\n res.set(\"Cache-Control\", \"no-store\");\r\n } else if (request.operation.operationName === \"generateTileContent\") {\r\n res.set(\"Cache-Control\", \"no-store\");\r\n } else if (request.operation.operationName === \"getConnectionProps\") {\r\n // GetConnectionprops can't be cached on the browser longer than the lifespan of the backend. The lifespan of backend may shrink too. Keep it at 1 second to be safe.\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);\r\n } else if (request.operation.operationName === \"getTileCacheContainerUrl\") {\r\n // getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);\r\n } else {\r\n res.set(\"Cache-Control\", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);\r\n }\r\n }\r\n\r\n if (fulfillment.retry) {\r\n res.set(\"Retry-After\", fulfillment.retry);\r\n }\r\n}\r\n\r\nfunction configureText(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): string {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.TEXT);\r\n return (fulfillment.status === 204) ? \"\" : fulfillment.result.objects;\r\n}\r\n\r\nfunction configureBinary(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): Buffer {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.BINARY);\r\n const data = fulfillment.result.data[0];\r\n return Buffer.isBuffer(data) ? data : Buffer.from(data);\r\n}\r\n\r\nfunction configureMultipart(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): ReadableFormData {\r\n const response = RpcMultipart.createStream(fulfillment.result);\r\n const headers = response.getHeaders();\r\n for (const header in headers) {\r\n if (headers.hasOwnProperty(header)) {\r\n res.set(header, headers[header]);\r\n }\r\n }\r\n\r\n return response;\r\n}\r\n\r\nfunction configureStream(fulfillment: RpcRequestFulfillment) {\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n return fulfillment.result.stream!;\r\n}\r\n\r\n/** @internal */\r\nexport async function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse) {\r\n const versionHeader = protocol.protocolVersionHeaderName;\r\n if (versionHeader && RpcProtocol.protocolVersion) {\r\n res.set(versionHeader, RpcProtocol.protocolVersion.toString());\r\n }\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const { Readable, Stream } = await import(/* webpackIgnore: true */ \"stream\");\r\n const { createGzip } = await import(/* webpackIgnore: true */ \"zlib\");\r\n\r\n const transportType = WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);\r\n let responseBody;\r\n if (transportType === RpcContentType.Binary) {\r\n responseBody = configureBinary(fulfillment, res);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n responseBody = configureMultipart(fulfillment, res);\r\n } else if (transportType === RpcContentType.Stream) {\r\n responseBody = configureStream(fulfillment);\r\n } else {\r\n responseBody = configureText(fulfillment, res);\r\n }\r\n\r\n configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status);\r\n\r\n if (fulfillment.allowCompression && req.header(\"Accept-Encoding\")?.includes(\"gzip\")) {\r\n res.set(\"Content-Encoding\", \"gzip\");\r\n const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);\r\n responseBody = readableResponseBody.pipe(createGzip());\r\n }\r\n\r\n // This check should in theory look for instances of Readable, but that would break backend implementation at\r\n // core/backend/src/RpcBackend.ts\r\n if (responseBody instanceof Stream) {\r\n responseBody.pipe(res);\r\n } else {\r\n res.send(responseBody);\r\n }\r\n}\r\n"]}
@@ -1,16 +1,16 @@
1
- /** @packageDocumentation
2
- * @module RpcInterface
3
- */
4
- import { LogLevel } from "@itwin/core-bentley";
5
- import { DevToolsRpcInterface, DevToolsStatsOptions, IModelRpcProps, RpcInterface } from "@itwin/core-common";
6
- /** The backend implementation of WipRpcInterface.
7
- * @internal
8
- */
9
- export declare class DevToolsRpcImpl extends RpcInterface implements DevToolsRpcInterface {
10
- static register(): void;
11
- ping(_tokenProps: IModelRpcProps): Promise<boolean>;
12
- stats(_tokenProps: IModelRpcProps, options: DevToolsStatsOptions): Promise<any>;
13
- versions(_tokenProps: IModelRpcProps): Promise<any>;
14
- setLogLevel(_tokenProps: IModelRpcProps, loggerCategory: string, logLevel: LogLevel): Promise<LogLevel | undefined>;
15
- }
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { LogLevel } from "@itwin/core-bentley";
5
+ import { DevToolsRpcInterface, DevToolsStatsOptions, IModelRpcProps, RpcInterface } from "@itwin/core-common";
6
+ /** The backend implementation of WipRpcInterface.
7
+ * @internal
8
+ */
9
+ export declare class DevToolsRpcImpl extends RpcInterface implements DevToolsRpcInterface {
10
+ static register(): void;
11
+ ping(_tokenProps: IModelRpcProps): Promise<boolean>;
12
+ stats(_tokenProps: IModelRpcProps, options: DevToolsStatsOptions): Promise<any>;
13
+ versions(_tokenProps: IModelRpcProps): Promise<any>;
14
+ setLogLevel(_tokenProps: IModelRpcProps, loggerCategory: string, logLevel: LogLevel): Promise<LogLevel | undefined>;
15
+ }
16
16
  //# sourceMappingURL=DevToolsRpcImpl.d.ts.map
@@ -1,33 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DevToolsRpcImpl = void 0;
4
- const core_common_1 = require("@itwin/core-common");
5
- const DevTools_1 = require("../DevTools");
6
- /** The backend implementation of WipRpcInterface.
7
- * @internal
8
- */
9
- class DevToolsRpcImpl extends core_common_1.RpcInterface {
10
- static register() { core_common_1.RpcManager.registerImpl(core_common_1.DevToolsRpcInterface, DevToolsRpcImpl); }
11
- // Returns true if the backend received the ping
12
- async ping(_tokenProps) {
13
- return DevTools_1.DevTools.ping();
14
- }
15
- // Returns JSON object with statistics
16
- async stats(_tokenProps, options) {
17
- const stats = DevTools_1.DevTools.stats();
18
- if (options === core_common_1.DevToolsStatsOptions.None)
19
- return stats;
20
- const formattedStats = DevTools_1.DevToolsStatsFormatter.toFormattedJson(stats);
21
- return formattedStats;
22
- }
23
- // Returns JSON object with backend versions (application and iModelJs)
24
- async versions(_tokenProps) {
25
- return DevTools_1.DevTools.versions();
26
- }
27
- // Sets up a log level at the backend
28
- async setLogLevel(_tokenProps, loggerCategory, logLevel) {
29
- return DevTools_1.DevTools.setLogLevel(loggerCategory, logLevel);
30
- }
31
- }
32
- exports.DevToolsRpcImpl = DevToolsRpcImpl;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DevToolsRpcImpl = void 0;
4
+ const core_common_1 = require("@itwin/core-common");
5
+ const DevTools_1 = require("../DevTools");
6
+ /** The backend implementation of WipRpcInterface.
7
+ * @internal
8
+ */
9
+ class DevToolsRpcImpl extends core_common_1.RpcInterface {
10
+ static register() { core_common_1.RpcManager.registerImpl(core_common_1.DevToolsRpcInterface, DevToolsRpcImpl); }
11
+ // Returns true if the backend received the ping
12
+ async ping(_tokenProps) {
13
+ return DevTools_1.DevTools.ping();
14
+ }
15
+ // Returns JSON object with statistics
16
+ async stats(_tokenProps, options) {
17
+ const stats = DevTools_1.DevTools.stats();
18
+ if (options === core_common_1.DevToolsStatsOptions.None)
19
+ return stats;
20
+ const formattedStats = DevTools_1.DevToolsStatsFormatter.toFormattedJson(stats);
21
+ return formattedStats;
22
+ }
23
+ // Returns JSON object with backend versions (application and iModelJs)
24
+ async versions(_tokenProps) {
25
+ return DevTools_1.DevTools.versions();
26
+ }
27
+ // Sets up a log level at the backend
28
+ async setLogLevel(_tokenProps, loggerCategory, logLevel) {
29
+ return DevTools_1.DevTools.setLogLevel(loggerCategory, logLevel);
30
+ }
31
+ }
32
+ exports.DevToolsRpcImpl = DevToolsRpcImpl;
33
33
  //# sourceMappingURL=DevToolsRpcImpl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DevToolsRpcImpl.js","sourceRoot":"","sources":["../../../src/rpc-impl/DevToolsRpcImpl.ts"],"names":[],"mappings":";;;AAQA,oDAA0H;AAC1H,0CAA+D;AAE/D;;GAEG;AACH,MAAa,eAAgB,SAAQ,0BAAY;IACxC,MAAM,CAAC,QAAQ,KAAK,wBAAU,CAAC,YAAY,CAAC,kCAAoB,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAE5F,gDAAgD;IACzC,KAAK,CAAC,IAAI,CAAC,WAA2B;QAC3C,OAAO,mBAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,sCAAsC;IAC/B,KAAK,CAAC,KAAK,CAAC,WAA2B,EAAE,OAA6B;QAC3E,MAAM,KAAK,GAAG,mBAAQ,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,OAAO,KAAK,kCAAoB,CAAC,IAAI;YACvC,OAAO,KAAK,CAAC;QACf,MAAM,cAAc,GAAG,iCAAsB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACrE,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,uEAAuE;IAChE,KAAK,CAAC,QAAQ,CAAC,WAA2B;QAC/C,OAAO,mBAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED,qCAAqC;IAC9B,KAAK,CAAC,WAAW,CAAC,WAA2B,EAAE,cAAsB,EAAE,QAAkB;QAC9F,OAAO,mBAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF;AA1BD,0CA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\nimport { LogLevel } from \"@itwin/core-bentley\";\nimport { DevToolsRpcInterface, DevToolsStatsOptions, IModelRpcProps, RpcInterface, RpcManager } from \"@itwin/core-common\";\nimport { DevTools, DevToolsStatsFormatter } from \"../DevTools\";\n\n/** The backend implementation of WipRpcInterface.\n * @internal\n */\nexport class DevToolsRpcImpl extends RpcInterface implements DevToolsRpcInterface { // eslint-disable-line deprecation/deprecation\n public static register() { RpcManager.registerImpl(DevToolsRpcInterface, DevToolsRpcImpl); }\n\n // Returns true if the backend received the ping\n public async ping(_tokenProps: IModelRpcProps): Promise<boolean> {\n return DevTools.ping();\n }\n\n // Returns JSON object with statistics\n public async stats(_tokenProps: IModelRpcProps, options: DevToolsStatsOptions): Promise<any> {\n const stats = DevTools.stats();\n if (options === DevToolsStatsOptions.None)\n return stats;\n const formattedStats = DevToolsStatsFormatter.toFormattedJson(stats);\n return formattedStats;\n }\n\n // Returns JSON object with backend versions (application and iModelJs)\n public async versions(_tokenProps: IModelRpcProps): Promise<any> {\n return DevTools.versions();\n }\n\n // Sets up a log level at the backend\n public async setLogLevel(_tokenProps: IModelRpcProps, loggerCategory: string, logLevel: LogLevel): Promise<LogLevel | undefined> {\n return DevTools.setLogLevel(loggerCategory, logLevel);\n }\n}\n"]}
1
+ {"version":3,"file":"DevToolsRpcImpl.js","sourceRoot":"","sources":["../../../src/rpc-impl/DevToolsRpcImpl.ts"],"names":[],"mappings":";;;AAQA,oDAA0H;AAC1H,0CAA+D;AAE/D;;GAEG;AACH,MAAa,eAAgB,SAAQ,0BAAY;IACxC,MAAM,CAAC,QAAQ,KAAK,wBAAU,CAAC,YAAY,CAAC,kCAAoB,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAE5F,gDAAgD;IACzC,KAAK,CAAC,IAAI,CAAC,WAA2B;QAC3C,OAAO,mBAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,sCAAsC;IAC/B,KAAK,CAAC,KAAK,CAAC,WAA2B,EAAE,OAA6B;QAC3E,MAAM,KAAK,GAAG,mBAAQ,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,OAAO,KAAK,kCAAoB,CAAC,IAAI;YACvC,OAAO,KAAK,CAAC;QACf,MAAM,cAAc,GAAG,iCAAsB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACrE,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,uEAAuE;IAChE,KAAK,CAAC,QAAQ,CAAC,WAA2B;QAC/C,OAAO,mBAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED,qCAAqC;IAC9B,KAAK,CAAC,WAAW,CAAC,WAA2B,EAAE,cAAsB,EAAE,QAAkB;QAC9F,OAAO,mBAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF;AA1BD,0CA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\nimport { LogLevel } from \"@itwin/core-bentley\";\r\nimport { DevToolsRpcInterface, DevToolsStatsOptions, IModelRpcProps, RpcInterface, RpcManager } from \"@itwin/core-common\";\r\nimport { DevTools, DevToolsStatsFormatter } from \"../DevTools\";\r\n\r\n/** The backend implementation of WipRpcInterface.\r\n * @internal\r\n */\r\nexport class DevToolsRpcImpl extends RpcInterface implements DevToolsRpcInterface { // eslint-disable-line deprecation/deprecation\r\n public static register() { RpcManager.registerImpl(DevToolsRpcInterface, DevToolsRpcImpl); }\r\n\r\n // Returns true if the backend received the ping\r\n public async ping(_tokenProps: IModelRpcProps): Promise<boolean> {\r\n return DevTools.ping();\r\n }\r\n\r\n // Returns JSON object with statistics\r\n public async stats(_tokenProps: IModelRpcProps, options: DevToolsStatsOptions): Promise<any> {\r\n const stats = DevTools.stats();\r\n if (options === DevToolsStatsOptions.None)\r\n return stats;\r\n const formattedStats = DevToolsStatsFormatter.toFormattedJson(stats);\r\n return formattedStats;\r\n }\r\n\r\n // Returns JSON object with backend versions (application and iModelJs)\r\n public async versions(_tokenProps: IModelRpcProps): Promise<any> {\r\n return DevTools.versions();\r\n }\r\n\r\n // Sets up a log level at the backend\r\n public async setLogLevel(_tokenProps: IModelRpcProps, loggerCategory: string, logLevel: LogLevel): Promise<LogLevel | undefined> {\r\n return DevTools.setLogLevel(loggerCategory, logLevel);\r\n }\r\n}\r\n"]}