@itwin/core-backend 3.6.0-dev.60 → 3.6.0-dev.65

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 (252) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  3. package/lib/cjs/AliCloudStorageService.js +71 -71
  4. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  5. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  6. package/lib/cjs/BackendHubAccess.js +41 -41
  7. package/lib/cjs/BackendHubAccess.js.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.d.ts +91 -91
  9. package/lib/cjs/BackendLoggerCategory.js +99 -99
  10. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  11. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  12. package/lib/cjs/BisCoreSchema.js +60 -60
  13. package/lib/cjs/BisCoreSchema.js.map +1 -1
  14. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  15. package/lib/cjs/BriefcaseManager.js +414 -414
  16. package/lib/cjs/BriefcaseManager.js.map +1 -1
  17. package/lib/cjs/Category.d.ts +153 -153
  18. package/lib/cjs/Category.js +243 -243
  19. package/lib/cjs/Category.js.map +1 -1
  20. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  21. package/lib/cjs/ChangeSummaryManager.js +447 -447
  22. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  23. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  24. package/lib/cjs/ChangedElementsDb.js +165 -165
  25. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  26. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  27. package/lib/cjs/ChangedElementsManager.js +88 -88
  28. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  29. package/lib/cjs/CheckpointManager.d.ts +121 -121
  30. package/lib/cjs/CheckpointManager.js +349 -349
  31. package/lib/cjs/CheckpointManager.js.map +1 -1
  32. package/lib/cjs/ClassRegistry.d.ts +79 -79
  33. package/lib/cjs/ClassRegistry.js +250 -250
  34. package/lib/cjs/ClassRegistry.js.map +1 -1
  35. package/lib/cjs/CloudSqlite.d.ts +350 -350
  36. package/lib/cjs/CloudSqlite.js +153 -153
  37. package/lib/cjs/CloudSqlite.js.map +1 -1
  38. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  39. package/lib/cjs/CloudStorageBackend.js +173 -173
  40. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  41. package/lib/cjs/CodeService.d.ts +396 -396
  42. package/lib/cjs/CodeService.js +63 -63
  43. package/lib/cjs/CodeService.js.map +1 -1
  44. package/lib/cjs/CodeSpecs.d.ts +55 -55
  45. package/lib/cjs/CodeSpecs.js +124 -124
  46. package/lib/cjs/CodeSpecs.js.map +1 -1
  47. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  48. package/lib/cjs/ConcurrentQuery.js +36 -36
  49. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  50. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  51. package/lib/cjs/CustomViewState3dCreator.js +81 -81
  52. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  53. package/lib/cjs/DevTools.d.ts +71 -71
  54. package/lib/cjs/DevTools.js +154 -154
  55. package/lib/cjs/DevTools.js.map +1 -1
  56. package/lib/cjs/DisplayStyle.d.ts +106 -106
  57. package/lib/cjs/DisplayStyle.js +256 -256
  58. package/lib/cjs/DisplayStyle.js.map +1 -1
  59. package/lib/cjs/ECDb.d.ts +191 -191
  60. package/lib/cjs/ECDb.js +350 -350
  61. package/lib/cjs/ECDb.js.map +1 -1
  62. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  63. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  64. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  65. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  66. package/lib/cjs/ECSqlStatement.js +791 -791
  67. package/lib/cjs/ECSqlStatement.js.map +1 -1
  68. package/lib/cjs/Element.d.ts +1109 -1109
  69. package/lib/cjs/Element.js +1427 -1427
  70. package/lib/cjs/Element.js.map +1 -1
  71. package/lib/cjs/ElementAspect.d.ts +179 -179
  72. package/lib/cjs/ElementAspect.js +211 -211
  73. package/lib/cjs/ElementAspect.js.map +1 -1
  74. package/lib/cjs/ElementGraphics.d.ts +9 -9
  75. package/lib/cjs/ElementGraphics.js +41 -41
  76. package/lib/cjs/ElementGraphics.js.map +1 -1
  77. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  78. package/lib/cjs/ElementTreeWalker.js +409 -409
  79. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  80. package/lib/cjs/Entity.d.ts +106 -106
  81. package/lib/cjs/Entity.js +134 -134
  82. package/lib/cjs/Entity.js.map +1 -1
  83. package/lib/cjs/EntityReferences.d.ts +49 -49
  84. package/lib/cjs/EntityReferences.js +95 -95
  85. package/lib/cjs/EntityReferences.js.map +1 -1
  86. package/lib/cjs/ExportGraphics.d.ts +317 -317
  87. package/lib/cjs/ExportGraphics.js +208 -208
  88. package/lib/cjs/ExportGraphics.js.map +1 -1
  89. package/lib/cjs/ExternalSource.d.ts +96 -96
  90. package/lib/cjs/ExternalSource.js +131 -131
  91. package/lib/cjs/ExternalSource.js.map +1 -1
  92. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  93. package/lib/cjs/GeoCoordConfig.js +85 -85
  94. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  95. package/lib/cjs/GeometrySummary.d.ts +4 -4
  96. package/lib/cjs/GeometrySummary.js +380 -380
  97. package/lib/cjs/GeometrySummary.js.map +1 -1
  98. package/lib/cjs/HubMock.d.ts +94 -94
  99. package/lib/cjs/HubMock.js +222 -222
  100. package/lib/cjs/HubMock.js.map +1 -1
  101. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  102. package/lib/cjs/IModelCloneContext.js +15 -15
  103. package/lib/cjs/IModelCloneContext.js.map +1 -1
  104. package/lib/cjs/IModelDb.d.ts +1196 -1196
  105. package/lib/cjs/IModelDb.js +2392 -2392
  106. package/lib/cjs/IModelDb.js.map +1 -1
  107. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  108. package/lib/cjs/IModelElementCloneContext.js +159 -159
  109. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  110. package/lib/cjs/IModelHost.d.ts +369 -369
  111. package/lib/cjs/IModelHost.js +496 -496
  112. package/lib/cjs/IModelHost.js.map +1 -1
  113. package/lib/cjs/IModelJsFs.d.ts +62 -62
  114. package/lib/cjs/IModelJsFs.js +140 -140
  115. package/lib/cjs/IModelJsFs.js.map +1 -1
  116. package/lib/cjs/IpcHost.d.ts +104 -104
  117. package/lib/cjs/IpcHost.js +278 -278
  118. package/lib/cjs/IpcHost.js.map +1 -1
  119. package/lib/cjs/LineStyle.d.ts +311 -311
  120. package/lib/cjs/LineStyle.js +295 -295
  121. package/lib/cjs/LineStyle.js.map +1 -1
  122. package/lib/cjs/LocalHub.d.ts +162 -162
  123. package/lib/cjs/LocalHub.js +585 -585
  124. package/lib/cjs/LocalHub.js.map +1 -1
  125. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  126. package/lib/cjs/LocalhostIpcHost.js +81 -81
  127. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  128. package/lib/cjs/Material.d.ts +131 -131
  129. package/lib/cjs/Material.js +181 -181
  130. package/lib/cjs/Material.js.map +1 -1
  131. package/lib/cjs/Model.d.ts +392 -392
  132. package/lib/cjs/Model.js +485 -485
  133. package/lib/cjs/Model.js.map +1 -1
  134. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  135. package/lib/cjs/NativeAppStorage.js +202 -202
  136. package/lib/cjs/NativeAppStorage.js.map +1 -1
  137. package/lib/cjs/NativeHost.d.ts +52 -52
  138. package/lib/cjs/NativeHost.js +163 -163
  139. package/lib/cjs/NativeHost.js.map +1 -1
  140. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  141. package/lib/cjs/NavigationRelationship.js +225 -225
  142. package/lib/cjs/NavigationRelationship.js.map +1 -1
  143. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  144. package/lib/cjs/PromiseMemoizer.js +101 -101
  145. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  146. package/lib/cjs/PropertyStore.d.ts +132 -132
  147. package/lib/cjs/PropertyStore.js +11 -11
  148. package/lib/cjs/PropertyStore.js.map +1 -1
  149. package/lib/cjs/Relationship.d.ts +416 -416
  150. package/lib/cjs/Relationship.js +494 -494
  151. package/lib/cjs/Relationship.js.map +1 -1
  152. package/lib/cjs/RpcBackend.d.ts +5 -5
  153. package/lib/cjs/RpcBackend.d.ts.map +1 -1
  154. package/lib/cjs/RpcBackend.js +32 -31
  155. package/lib/cjs/RpcBackend.js.map +1 -1
  156. package/lib/cjs/SQLiteDb.d.ts +219 -219
  157. package/lib/cjs/SQLiteDb.js +214 -214
  158. package/lib/cjs/SQLiteDb.js.map +1 -1
  159. package/lib/cjs/Schema.d.ts +55 -55
  160. package/lib/cjs/Schema.js +83 -83
  161. package/lib/cjs/Schema.js.map +1 -1
  162. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  163. package/lib/cjs/ServerBasedLocks.js +168 -168
  164. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  165. package/lib/cjs/SqliteStatement.d.ts +360 -360
  166. package/lib/cjs/SqliteStatement.js +586 -586
  167. package/lib/cjs/SqliteStatement.js.map +1 -1
  168. package/lib/cjs/Texture.d.ts +58 -58
  169. package/lib/cjs/Texture.js +82 -82
  170. package/lib/cjs/Texture.js.map +1 -1
  171. package/lib/cjs/TileStorage.d.ts +18 -18
  172. package/lib/cjs/TileStorage.js +90 -90
  173. package/lib/cjs/TileStorage.js.map +1 -1
  174. package/lib/cjs/TxnManager.d.ts +202 -202
  175. package/lib/cjs/TxnManager.js +356 -356
  176. package/lib/cjs/TxnManager.js.map +1 -1
  177. package/lib/cjs/ViewDefinition.d.ts +439 -439
  178. package/lib/cjs/ViewDefinition.js +646 -646
  179. package/lib/cjs/ViewDefinition.js.map +1 -1
  180. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  181. package/lib/cjs/ViewStateHydrator.js +103 -103
  182. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  183. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  184. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  185. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  186. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  187. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  188. package/lib/cjs/core-backend.d.ts +184 -184
  189. package/lib/cjs/core-backend.js +204 -204
  190. package/lib/cjs/core-backend.js.map +1 -1
  191. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  192. package/lib/cjs/domains/FunctionalElements.js +145 -145
  193. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  194. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  195. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  196. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  197. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  198. package/lib/cjs/domains/GenericElements.js +263 -263
  199. package/lib/cjs/domains/GenericElements.js.map +1 -1
  200. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  201. package/lib/cjs/domains/GenericSchema.js +28 -28
  202. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  203. package/lib/cjs/rpc/multipart.d.ts +11 -11
  204. package/lib/cjs/rpc/multipart.d.ts.map +1 -1
  205. package/lib/cjs/rpc/multipart.js +71 -70
  206. package/lib/cjs/rpc/multipart.js.map +1 -1
  207. package/lib/cjs/rpc/tracing.d.ts +28 -28
  208. package/lib/cjs/rpc/tracing.d.ts.map +1 -1
  209. package/lib/cjs/rpc/tracing.js +74 -73
  210. package/lib/cjs/rpc/tracing.js.map +1 -1
  211. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  212. package/lib/cjs/rpc/web/logging.d.ts.map +1 -1
  213. package/lib/cjs/rpc/web/logging.js +43 -42
  214. package/lib/cjs/rpc/web/logging.js.map +1 -1
  215. package/lib/cjs/rpc/web/request.d.ts +6 -6
  216. package/lib/cjs/rpc/web/request.d.ts.map +1 -1
  217. package/lib/cjs/rpc/web/request.js +74 -73
  218. package/lib/cjs/rpc/web/request.js.map +1 -1
  219. package/lib/cjs/rpc/web/response.d.ts +6 -6
  220. package/lib/cjs/rpc/web/response.d.ts.map +1 -1
  221. package/lib/cjs/rpc/web/response.js +106 -105
  222. package/lib/cjs/rpc/web/response.js.map +1 -1
  223. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  224. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  225. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  226. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  227. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  228. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +294 -291
  229. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  230. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  231. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  232. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +205 -202
  233. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  234. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  235. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
  236. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  237. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  238. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  239. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  240. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  241. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  242. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  243. package/lib/cjs/workspace/Settings.d.ts +186 -186
  244. package/lib/cjs/workspace/Settings.js +155 -155
  245. package/lib/cjs/workspace/Settings.js.map +1 -1
  246. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  247. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  248. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  249. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  250. package/lib/cjs/workspace/Workspace.js +543 -543
  251. package/lib/cjs/workspace/Workspace.js.map +1 -1
  252. package/package.json +11 -11
@@ -1,43 +1,44 @@
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.WebAppRpcLoggingBackend = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_common_1 = require("@itwin/core-common");
13
- const os = require("os");
14
- class WebAppRpcLoggingBackend extends core_common_1.WebAppRpcLogging {
15
- async logProtocolEvent(event, object) {
16
- switch (event) {
17
- case core_common_1.RpcProtocolEvent.RequestReceived: return this.logRequest(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.request", object.request);
18
- case core_common_1.RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend("RpcInterface.backend.error", object);
19
- case core_common_1.RpcProtocolEvent.BackendResponseCreated: return this.logResponse(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.response", object.request, object.status, object.elapsed);
20
- }
21
- }
22
- getHostname() {
23
- return os.hostname();
24
- }
25
- async logErrorBackend(message, invocation) {
26
- const operationDescriptor = this.buildOperationDescriptor(invocation.operation);
27
- const pathIds = this.findPathIds(invocation.request.path);
28
- const result = await invocation.result;
29
- const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue
30
- core_bentley_1.Logger.logInfo(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({
31
- method: invocation.request.method,
32
- path: invocation.request.path,
33
- status: invocation.status,
34
- errorMessage,
35
- // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
36
- ActivityId: invocation.request.id,
37
- MachineName: this.getHostname(),
38
- ...pathIds,
39
- }));
40
- }
41
- }
42
- exports.WebAppRpcLoggingBackend = WebAppRpcLoggingBackend;
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.WebAppRpcLoggingBackend = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const os = require("os");
14
+ /* eslint-disable deprecation/deprecation */
15
+ class WebAppRpcLoggingBackend extends core_common_1.WebAppRpcLogging {
16
+ async logProtocolEvent(event, object) {
17
+ switch (event) {
18
+ case core_common_1.RpcProtocolEvent.RequestReceived: return this.logRequest(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.request", object.request);
19
+ case core_common_1.RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend("RpcInterface.backend.error", object);
20
+ case core_common_1.RpcProtocolEvent.BackendResponseCreated: return this.logResponse(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.response", object.request, object.status, object.elapsed);
21
+ }
22
+ }
23
+ getHostname() {
24
+ return os.hostname();
25
+ }
26
+ async logErrorBackend(message, invocation) {
27
+ const operationDescriptor = this.buildOperationDescriptor(invocation.operation);
28
+ const pathIds = this.findPathIds(invocation.request.path);
29
+ const result = await invocation.result;
30
+ const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue
31
+ core_bentley_1.Logger.logInfo(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({
32
+ method: invocation.request.method,
33
+ path: invocation.request.path,
34
+ status: invocation.status,
35
+ errorMessage,
36
+ // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
37
+ ActivityId: invocation.request.id,
38
+ MachineName: this.getHostname(),
39
+ ...pathIds,
40
+ }));
41
+ }
42
+ }
43
+ exports.WebAppRpcLoggingBackend = WebAppRpcLoggingBackend;
43
44
  //# sourceMappingURL=logging.js.map
@@ -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,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\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
+ {"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,KAA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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,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 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/request.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAEL,iBAAiB,EASjB,oBAAoB,EAEpB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAgC5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoCrH"}
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/request.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAEL,iBAAiB,EASjB,oBAAoB,EAEpB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAkC5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoCrH"}
@@ -1,74 +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
- function parseHeaders(protocol, req) {
13
- var _a;
14
- const headerNames = protocol.serializedClientRequestContextHeaderNames;
15
- const parsedHeaders = {
16
- id: req.header(headerNames.id) || "",
17
- applicationId: req.header(headerNames.applicationId) || "",
18
- applicationVersion: req.header(headerNames.applicationVersion) || "",
19
- sessionId: req.header(headerNames.sessionId) || "",
20
- authorization: (_a = (headerNames.authorization ? req.header(headerNames.authorization) : "")) !== null && _a !== void 0 ? _a : "",
21
- };
22
- return parsedHeaders;
23
- }
24
- function parseFromPath(operation) {
25
- const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, "base64").toString("binary") : "";
26
- return core_common_1.RpcSerializedValue.create(decoded);
27
- }
28
- async function parseFromBody(req) {
29
- const contentType = core_common_1.WebAppRpcProtocol.computeContentType(req.header(core_common_1.WEB_RPC_CONSTANTS.CONTENT));
30
- if (contentType === core_common_1.RpcContentType.Binary) {
31
- const objects = JSON.stringify([core_common_1.MarshalingBinaryMarker.createDefault()]);
32
- const data = [req.body];
33
- return core_common_1.RpcSerializedValue.create(objects, data);
34
- }
35
- else if (contentType === core_common_1.RpcContentType.Multipart) {
36
- return core_common_1.RpcMultipart.parseRequest(req);
37
- }
38
- else {
39
- return core_common_1.RpcSerializedValue.create(req.body);
40
- }
41
- }
42
- /** @internal */
43
- async function parseRequest(protocol, req) {
44
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
- const operation = protocol.getOperationFromPath(req.url);
46
- const parsedHeaders = parseHeaders(protocol, req);
47
- const request = {
48
- ...parsedHeaders,
49
- operation: {
50
- interfaceDefinition: operation.interfaceDefinition,
51
- operationName: operation.operationName,
52
- interfaceVersion: operation.interfaceVersion,
53
- },
54
- method: req.method,
55
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
56
- path: req.url,
57
- parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),
58
- caching: operation.encodedRequest ? core_common_1.RpcResponseCacheControl.Immutable : core_common_1.RpcResponseCacheControl.None,
59
- };
60
- request.ip = req.ip;
61
- request.protocolVersion = 0;
62
- if (protocol.protocolVersionHeaderName) {
63
- const version = req.header(protocol.protocolVersionHeaderName);
64
- if (version) {
65
- request.protocolVersion = parseInt(version, 10);
66
- }
67
- }
68
- if (!request.id) {
69
- throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);
70
- }
71
- return request;
72
- }
73
- 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;
74
75
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"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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\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.`);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uB,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,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 +1 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAKlB,qBAAqB,EAGrB,oBAAoB,EAEpB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AA2D5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,kBAAkB,iBAqCjL"}
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAKlB,qBAAqB,EAGrB,oBAAoB,EAEpB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AA6D5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,kBAAkB,iBAqCjL"}
@@ -1,106 +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
- function configureResponse(protocol, request, fulfillment, res) {
13
- const success = protocol.getStatus(fulfillment.status) === core_common_1.RpcRequestStatus.Resolved;
14
- // TODO: Use stale-while-revalidate in cache headers. This needs to be tested, and does not currently have support in the router/caching-service.
15
- // This will allow browsers to use stale cached responses while also revalidating with the router, allowing us to start up a backend if necessary.
16
- // RPC Caching Service uses the s-maxage header to determine the TTL for the redis cache.
17
- const oneHourInSeconds = 3600;
18
- if (success && request.caching === core_common_1.RpcResponseCacheControl.Immutable) {
19
- // If response size is > 50 MB, do not cache it.
20
- if (fulfillment.result.objects.length > (50 * 10 ** 7)) {
21
- res.set("Cache-Control", "no-store");
22
- }
23
- else if (request.operation.operationName === "generateTileContent") {
24
- res.set("Cache-Control", "no-store");
25
- }
26
- else if (request.operation.operationName === "getConnectionProps") {
27
- // 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.
28
- res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 24}, max-age=1, immutable`);
29
- }
30
- else if (request.operation.operationName === "getTileCacheContainerUrl") {
31
- // getTileCacheContainerUrl returns a SAS with an expiry of 23:59:59. We can't exceed that time when setting the max-age.
32
- res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 23}, max-age=${oneHourInSeconds * 23}, immutable`);
33
- }
34
- else {
35
- res.set("Cache-Control", `s-maxage=${oneHourInSeconds * 24}, max-age=${oneHourInSeconds * 48}, immutable`);
36
- }
37
- }
38
- if (fulfillment.retry) {
39
- res.set("Retry-After", fulfillment.retry);
40
- }
41
- }
42
- function configureText(fulfillment, res) {
43
- res.set(core_common_1.WEB_RPC_CONSTANTS.CONTENT, core_common_1.WEB_RPC_CONSTANTS.TEXT);
44
- return (fulfillment.status === 204) ? "" : fulfillment.result.objects;
45
- }
46
- function configureBinary(fulfillment, res) {
47
- res.set(core_common_1.WEB_RPC_CONSTANTS.CONTENT, core_common_1.WEB_RPC_CONSTANTS.BINARY);
48
- const data = fulfillment.result.data[0];
49
- return Buffer.isBuffer(data) ? data : Buffer.from(data);
50
- }
51
- function configureMultipart(fulfillment, res) {
52
- const response = core_common_1.RpcMultipart.createStream(fulfillment.result);
53
- const headers = response.getHeaders();
54
- for (const header in headers) {
55
- if (headers.hasOwnProperty(header)) {
56
- res.set(header, headers[header]);
57
- }
58
- }
59
- return response;
60
- }
61
- function configureStream(fulfillment) {
62
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
63
- return fulfillment.result.stream;
64
- }
65
- /** @internal */
66
- async function sendResponse(protocol, request, fulfillment, req, res) {
67
- var _a;
68
- const versionHeader = protocol.protocolVersionHeaderName;
69
- if (versionHeader && core_common_1.RpcProtocol.protocolVersion) {
70
- res.set(versionHeader, core_common_1.RpcProtocol.protocolVersion.toString());
71
- }
72
- // eslint-disable-next-line @typescript-eslint/naming-convention
73
- const { Readable, Stream } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "stream"));
74
- const { createGzip } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "zlib"));
75
- const transportType = core_common_1.WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);
76
- let responseBody;
77
- if (transportType === core_common_1.RpcContentType.Binary) {
78
- responseBody = configureBinary(fulfillment, res);
79
- }
80
- else if (transportType === core_common_1.RpcContentType.Multipart) {
81
- responseBody = configureMultipart(fulfillment, res);
82
- }
83
- else if (transportType === core_common_1.RpcContentType.Stream) {
84
- responseBody = configureStream(fulfillment);
85
- }
86
- else {
87
- responseBody = configureText(fulfillment, res);
88
- }
89
- configureResponse(protocol, request, fulfillment, res);
90
- res.status(fulfillment.status);
91
- if (fulfillment.allowCompression && ((_a = req.header("Accept-Encoding")) === null || _a === void 0 ? void 0 : _a.includes("gzip"))) {
92
- res.set("Content-Encoding", "gzip");
93
- const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);
94
- responseBody = readableResponseBody.pipe(createGzip());
95
- }
96
- // This check should in theory look for instances of Readable, but that would break backend implementation at
97
- // core/backend/src/RpcBackend.ts
98
- if (responseBody instanceof Stream) {
99
- responseBody.pipe(res);
100
- }
101
- else {
102
- res.send(responseBody);
103
- }
104
- }
105
- 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;
106
107
  //# sourceMappingURL=response.js.map