@itwin/core-common 3.5.0-dev.8 → 3.6.0-dev.3

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 (190) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/lib/cjs/BackendTypes.d.ts +13 -0
  3. package/lib/cjs/BackendTypes.d.ts.map +1 -0
  4. package/lib/cjs/BackendTypes.js +10 -0
  5. package/lib/cjs/BackendTypes.js.map +1 -0
  6. package/lib/cjs/Base64EncodedString.d.ts +2 -0
  7. package/lib/cjs/Base64EncodedString.d.ts.map +1 -1
  8. package/lib/cjs/Base64EncodedString.js +10 -0
  9. package/lib/cjs/Base64EncodedString.js.map +1 -1
  10. package/lib/cjs/ChangedElements.d.ts +3 -1
  11. package/lib/cjs/ChangedElements.d.ts.map +1 -1
  12. package/lib/cjs/ChangedElements.js +2 -0
  13. package/lib/cjs/ChangedElements.js.map +1 -1
  14. package/lib/cjs/ConcurrentQuery.d.ts +181 -1
  15. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  16. package/lib/cjs/ConcurrentQuery.js +175 -3
  17. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  18. package/lib/cjs/ElementMesh.d.ts +40 -0
  19. package/lib/cjs/ElementMesh.d.ts.map +1 -0
  20. package/lib/cjs/ElementMesh.js +57 -0
  21. package/lib/cjs/ElementMesh.js.map +1 -0
  22. package/lib/cjs/ElementProps.d.ts +4 -1
  23. package/lib/cjs/ElementProps.d.ts.map +1 -1
  24. package/lib/cjs/ElementProps.js.map +1 -1
  25. package/lib/cjs/EntityReference.d.ts +52 -0
  26. package/lib/cjs/EntityReference.d.ts.map +1 -0
  27. package/lib/cjs/EntityReference.js +57 -0
  28. package/lib/cjs/EntityReference.js.map +1 -0
  29. package/lib/cjs/IpcAppProps.d.ts +18 -1
  30. package/lib/cjs/IpcAppProps.d.ts.map +1 -1
  31. package/lib/cjs/IpcAppProps.js +6 -1
  32. package/lib/cjs/IpcAppProps.js.map +1 -1
  33. package/lib/cjs/Localization.d.ts +2 -0
  34. package/lib/cjs/Localization.d.ts.map +1 -1
  35. package/lib/cjs/Localization.js.map +1 -1
  36. package/lib/cjs/ModelProps.d.ts +1 -0
  37. package/lib/cjs/ModelProps.d.ts.map +1 -1
  38. package/lib/cjs/ModelProps.js.map +1 -1
  39. package/lib/cjs/RenderSchedule.d.ts +12 -9
  40. package/lib/cjs/RenderSchedule.d.ts.map +1 -1
  41. package/lib/cjs/RenderSchedule.js +11 -9
  42. package/lib/cjs/RenderSchedule.js.map +1 -1
  43. package/lib/cjs/TextureMapping.d.ts +17 -2
  44. package/lib/cjs/TextureMapping.d.ts.map +1 -1
  45. package/lib/cjs/TextureMapping.js.map +1 -1
  46. package/lib/cjs/ViewDetails.d.ts.map +1 -1
  47. package/lib/cjs/ViewDetails.js +10 -2
  48. package/lib/cjs/ViewDetails.js.map +1 -1
  49. package/lib/cjs/core-common.d.ts +4 -0
  50. package/lib/cjs/core-common.d.ts.map +1 -1
  51. package/lib/cjs/core-common.js +4 -0
  52. package/lib/cjs/core-common.js.map +1 -1
  53. package/lib/cjs/ipc/IpcWebSocketTransport.d.ts.map +1 -1
  54. package/lib/cjs/ipc/IpcWebSocketTransport.js +5 -3
  55. package/lib/cjs/ipc/IpcWebSocketTransport.js.map +1 -1
  56. package/lib/cjs/rpc/IModelReadRpcInterface.d.ts +25 -1
  57. package/lib/cjs/rpc/IModelReadRpcInterface.d.ts.map +1 -1
  58. package/lib/cjs/rpc/IModelReadRpcInterface.js +8 -1
  59. package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
  60. package/lib/cjs/rpc/core/RpcConfiguration.d.ts.map +1 -1
  61. package/lib/cjs/rpc/core/RpcConfiguration.js +0 -1
  62. package/lib/cjs/rpc/core/RpcConfiguration.js.map +1 -1
  63. package/lib/cjs/rpc/core/RpcControl.d.ts +2 -0
  64. package/lib/cjs/rpc/core/RpcControl.d.ts.map +1 -1
  65. package/lib/cjs/rpc/core/RpcControl.js +13 -18
  66. package/lib/cjs/rpc/core/RpcControl.js.map +1 -1
  67. package/lib/cjs/rpc/core/RpcInvocation.d.ts.map +1 -1
  68. package/lib/cjs/rpc/core/RpcInvocation.js +1 -0
  69. package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
  70. package/lib/cjs/rpc/core/RpcMarshaling.d.ts +2 -3
  71. package/lib/cjs/rpc/core/RpcMarshaling.d.ts.map +1 -1
  72. package/lib/cjs/rpc/core/RpcMarshaling.js +5 -2
  73. package/lib/cjs/rpc/core/RpcMarshaling.js.map +1 -1
  74. package/lib/cjs/rpc/web/RpcMultipart.d.ts +11 -7
  75. package/lib/cjs/rpc/web/RpcMultipart.d.ts.map +1 -1
  76. package/lib/cjs/rpc/web/RpcMultipart.js +17 -12
  77. package/lib/cjs/rpc/web/RpcMultipart.js.map +1 -1
  78. package/lib/cjs/rpc/web/WebAppRpcLogging.d.ts +19 -8
  79. package/lib/cjs/rpc/web/WebAppRpcLogging.d.ts.map +1 -1
  80. package/lib/cjs/rpc/web/WebAppRpcLogging.js +62 -63
  81. package/lib/cjs/rpc/web/WebAppRpcLogging.js.map +1 -1
  82. package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts +4 -3
  83. package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts.map +1 -1
  84. package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
  85. package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts +6 -10
  86. package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
  87. package/lib/cjs/rpc/web/WebAppRpcRequest.js +14 -149
  88. package/lib/cjs/rpc/web/WebAppRpcRequest.js.map +1 -1
  89. package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts +2 -3
  90. package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
  91. package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js +34 -21
  92. package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
  93. package/lib/cjs/tile/ElementGraphics.d.ts +13 -2
  94. package/lib/cjs/tile/ElementGraphics.d.ts.map +1 -1
  95. package/lib/cjs/tile/ElementGraphics.js.map +1 -1
  96. package/lib/esm/BackendTypes.d.ts +13 -0
  97. package/lib/esm/BackendTypes.d.ts.map +1 -0
  98. package/lib/esm/BackendTypes.js +9 -0
  99. package/lib/esm/BackendTypes.js.map +1 -0
  100. package/lib/esm/Base64EncodedString.d.ts +2 -0
  101. package/lib/esm/Base64EncodedString.d.ts.map +1 -1
  102. package/lib/esm/Base64EncodedString.js +10 -0
  103. package/lib/esm/Base64EncodedString.js.map +1 -1
  104. package/lib/esm/ChangedElements.d.ts +3 -1
  105. package/lib/esm/ChangedElements.d.ts.map +1 -1
  106. package/lib/esm/ChangedElements.js +2 -0
  107. package/lib/esm/ChangedElements.js.map +1 -1
  108. package/lib/esm/ConcurrentQuery.d.ts +181 -1
  109. package/lib/esm/ConcurrentQuery.d.ts.map +1 -1
  110. package/lib/esm/ConcurrentQuery.js +175 -3
  111. package/lib/esm/ConcurrentQuery.js.map +1 -1
  112. package/lib/esm/ElementMesh.d.ts +40 -0
  113. package/lib/esm/ElementMesh.d.ts.map +1 -0
  114. package/lib/esm/ElementMesh.js +53 -0
  115. package/lib/esm/ElementMesh.js.map +1 -0
  116. package/lib/esm/ElementProps.d.ts +4 -1
  117. package/lib/esm/ElementProps.d.ts.map +1 -1
  118. package/lib/esm/ElementProps.js.map +1 -1
  119. package/lib/esm/EntityReference.d.ts +52 -0
  120. package/lib/esm/EntityReference.d.ts.map +1 -0
  121. package/lib/esm/EntityReference.js +53 -0
  122. package/lib/esm/EntityReference.js.map +1 -0
  123. package/lib/esm/IpcAppProps.d.ts +18 -1
  124. package/lib/esm/IpcAppProps.d.ts.map +1 -1
  125. package/lib/esm/IpcAppProps.js +4 -0
  126. package/lib/esm/IpcAppProps.js.map +1 -1
  127. package/lib/esm/Localization.d.ts +2 -0
  128. package/lib/esm/Localization.d.ts.map +1 -1
  129. package/lib/esm/Localization.js.map +1 -1
  130. package/lib/esm/ModelProps.d.ts +1 -0
  131. package/lib/esm/ModelProps.d.ts.map +1 -1
  132. package/lib/esm/ModelProps.js.map +1 -1
  133. package/lib/esm/RenderSchedule.d.ts +12 -9
  134. package/lib/esm/RenderSchedule.d.ts.map +1 -1
  135. package/lib/esm/RenderSchedule.js +11 -9
  136. package/lib/esm/RenderSchedule.js.map +1 -1
  137. package/lib/esm/TextureMapping.d.ts +17 -2
  138. package/lib/esm/TextureMapping.d.ts.map +1 -1
  139. package/lib/esm/TextureMapping.js.map +1 -1
  140. package/lib/esm/ViewDetails.d.ts.map +1 -1
  141. package/lib/esm/ViewDetails.js +11 -3
  142. package/lib/esm/ViewDetails.js.map +1 -1
  143. package/lib/esm/core-common.d.ts +4 -0
  144. package/lib/esm/core-common.d.ts.map +1 -1
  145. package/lib/esm/core-common.js +4 -0
  146. package/lib/esm/core-common.js.map +1 -1
  147. package/lib/esm/ipc/IpcWebSocketTransport.d.ts.map +1 -1
  148. package/lib/esm/ipc/IpcWebSocketTransport.js +5 -3
  149. package/lib/esm/ipc/IpcWebSocketTransport.js.map +1 -1
  150. package/lib/esm/rpc/IModelReadRpcInterface.d.ts +25 -1
  151. package/lib/esm/rpc/IModelReadRpcInterface.d.ts.map +1 -1
  152. package/lib/esm/rpc/IModelReadRpcInterface.js +8 -1
  153. package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
  154. package/lib/esm/rpc/core/RpcConfiguration.d.ts.map +1 -1
  155. package/lib/esm/rpc/core/RpcConfiguration.js +0 -1
  156. package/lib/esm/rpc/core/RpcConfiguration.js.map +1 -1
  157. package/lib/esm/rpc/core/RpcControl.d.ts +2 -0
  158. package/lib/esm/rpc/core/RpcControl.d.ts.map +1 -1
  159. package/lib/esm/rpc/core/RpcControl.js +13 -18
  160. package/lib/esm/rpc/core/RpcControl.js.map +1 -1
  161. package/lib/esm/rpc/core/RpcInvocation.d.ts.map +1 -1
  162. package/lib/esm/rpc/core/RpcInvocation.js +2 -1
  163. package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
  164. package/lib/esm/rpc/core/RpcMarshaling.d.ts +2 -3
  165. package/lib/esm/rpc/core/RpcMarshaling.d.ts.map +1 -1
  166. package/lib/esm/rpc/core/RpcMarshaling.js +5 -2
  167. package/lib/esm/rpc/core/RpcMarshaling.js.map +1 -1
  168. package/lib/esm/rpc/web/RpcMultipart.d.ts +11 -7
  169. package/lib/esm/rpc/web/RpcMultipart.d.ts.map +1 -1
  170. package/lib/esm/rpc/web/RpcMultipart.js +17 -12
  171. package/lib/esm/rpc/web/RpcMultipart.js.map +1 -1
  172. package/lib/esm/rpc/web/WebAppRpcLogging.d.ts +19 -8
  173. package/lib/esm/rpc/web/WebAppRpcLogging.d.ts.map +1 -1
  174. package/lib/esm/rpc/web/WebAppRpcLogging.js +62 -63
  175. package/lib/esm/rpc/web/WebAppRpcLogging.js.map +1 -1
  176. package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts +4 -3
  177. package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts.map +1 -1
  178. package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
  179. package/lib/esm/rpc/web/WebAppRpcRequest.d.ts +6 -10
  180. package/lib/esm/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
  181. package/lib/esm/rpc/web/WebAppRpcRequest.js +15 -150
  182. package/lib/esm/rpc/web/WebAppRpcRequest.js.map +1 -1
  183. package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts +2 -3
  184. package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
  185. package/lib/esm/rpc/web/multipart/RpcMultipartParser.js +34 -21
  186. package/lib/esm/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
  187. package/lib/esm/tile/ElementGraphics.d.ts +13 -2
  188. package/lib/esm/tile/ElementGraphics.d.ts.map +1 -1
  189. package/lib/esm/tile/ElementGraphics.js.map +1 -1
  190. package/package.json +8 -10
@@ -1 +1 @@
1
- {"version":3,"file":"RpcMultipart.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/RpcMultipart.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,gBAAgB;AAChB,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9E;AAED,gBAAgB;AAChB,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,UAAU,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACtC;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,wDAAwD;WAC1C,UAAU,CAAC,KAAK,EAAE,kBAAkB,GAAG,QAAQ;IAM7D,mDAAmD;WACrC,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,gBAAgB;IAIxE,2DAA2D;WACvC,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAItF,gBAAgB;WACF,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,kBAAkB;CAY/E"}
1
+ {"version":3,"file":"RpcMultipart.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/RpcMultipart.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAI7D,gBAAgB;AAChB,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrF;AAED,gBAAgB;AAChB,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,UAAU,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACtC;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,wDAAwD;WAC1C,UAAU,CAAC,KAAK,EAAE,kBAAkB,GAAG,QAAQ;IAM7D,mDAAmD;WACrC,YAAY,CAAC,KAAK,EAAE,kBAAkB,GAAG,gBAAgB;IAIvE,2DAA2D;WACvC,YAAY,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIrF,gBAAgB;WACF,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,kBAAkB;IAQ9E,gBAAgB;IAChB,OAAc,QAAQ;6BACC,kBAAkB,GAAG,gBAAgB;2BAGjC,iBAAiB,GAAG,QAAQ,kBAAkB,CAAC;wBAGxD,MAAM,QAAQ,cAAc,SAAS,kBAAkB,GAAG,IAAI;MAG9E;CACH"}
@@ -8,7 +8,6 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.RpcMultipart = void 0;
11
- const buffer_1 = require("buffer");
12
11
  const IModelError_1 = require("../../IModelError");
13
12
  /** Support for transporting RPC values using the HTTP multipart content type.
14
13
  * @internal
@@ -21,26 +20,32 @@ class RpcMultipart {
21
20
  return form;
22
21
  }
23
22
  /** Creates a multipart stream for an RPC value. */
24
- static createStream(_value) {
25
- throw new IModelError_1.IModelError(IModelError_1.BentleyStatus.ERROR, "Not implemented.");
23
+ static createStream(value) {
24
+ return this.platform.createStream(value);
26
25
  }
27
26
  /** Obtains the RPC value from a multipart HTTP request. */
28
- static async parseRequest(_req) {
29
- throw new IModelError_1.IModelError(IModelError_1.BentleyStatus.ERROR, "Not implemented.");
27
+ static async parseRequest(req) {
28
+ return this.platform.parseRequest(req);
30
29
  }
31
30
  /** @internal */
32
31
  static writeValueToForm(form, value) {
33
32
  form.append("objects", value.objects);
34
33
  for (let i = 0; i !== value.data.length; ++i) {
35
- if (typeof (Blob) !== "undefined") {
36
- form.append(`data-${i}`, new Blob([value.data[i]], { type: "application/octet-stream" }));
37
- }
38
- else {
39
- const buf = value.data[i];
40
- form.append(`data-${i}`, buffer_1.Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength));
41
- }
34
+ this.platform.appendToForm(i, form, value);
42
35
  }
43
36
  }
44
37
  }
45
38
  exports.RpcMultipart = RpcMultipart;
39
+ /** @internal */
40
+ RpcMultipart.platform = {
41
+ createStream(_value) {
42
+ throw new IModelError_1.IModelError(IModelError_1.BentleyStatus.ERROR, "Not bound.");
43
+ },
44
+ async parseRequest(_req) {
45
+ throw new IModelError_1.IModelError(IModelError_1.BentleyStatus.ERROR, "Not bound.");
46
+ },
47
+ appendToForm(i, form, value) {
48
+ form.append(`data-${i}`, new Blob([value.data[i]], { type: "application/octet-stream" }));
49
+ },
50
+ };
46
51
  //# sourceMappingURL=RpcMultipart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RpcMultipart.js","sourceRoot":"","sources":["../../../../src/rpc/web/RpcMultipart.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,mCAAgC;AAEhC,mDAA+D;AAc/D;;GAEG;AACH,MAAa,YAAY;IACvB,wDAAwD;IACjD,MAAM,CAAC,UAAU,CAAC,KAAyB;QAChD,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC5B,YAAY,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mDAAmD;IAC5C,MAAM,CAAC,YAAY,CAAC,MAA0B;QACnD,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACjE,CAAC;IAED,2DAA2D;IACpD,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,IAAuB;QACtD,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACjE,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,gBAAgB,CAAC,IAAoB,EAAE,KAAyB;QAC5E,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAC5C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE;gBACjC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC,CAAC,CAAC;aAC3F;iBAAM;gBACL,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,eAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;aACnF;SACF;IACH,CAAC;CACF;AA/BD,oCA+BC","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 { Buffer } from \"buffer\";\r\nimport { Readable } from \"stream\";\r\nimport { BentleyStatus, IModelError } from \"../../IModelError\";\r\nimport { RpcSerializedValue } from \"../core/RpcMarshaling\";\r\nimport { HttpServerRequest } from \"../web/WebAppRpcProtocol\";\r\n\r\n/** @internal */\r\nexport interface FormDataCommon {\r\n append(name: string, value: string | Blob | Buffer, fileName?: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport interface ReadableFormData extends Readable {\r\n getHeaders(): { [key: string]: any };\r\n}\r\n\r\n/** Support for transporting RPC values using the HTTP multipart content type.\r\n * @internal\r\n */\r\nexport class RpcMultipart {\r\n /** Creates a multipart form object for an RPC value. */\r\n public static createForm(value: RpcSerializedValue): FormData {\r\n const form = new FormData();\r\n RpcMultipart.writeValueToForm(form, value);\r\n return form;\r\n }\r\n\r\n /** Creates a multipart stream for an RPC value. */\r\n public static createStream(_value: RpcSerializedValue): ReadableFormData {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\");\r\n }\r\n\r\n /** Obtains the RPC value from a multipart HTTP request. */\r\n public static async parseRequest(_req: HttpServerRequest): Promise<RpcSerializedValue> {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\");\r\n }\r\n\r\n /** @internal */\r\n public static writeValueToForm(form: FormDataCommon, value: RpcSerializedValue) {\r\n form.append(\"objects\", value.objects);\r\n\r\n for (let i = 0; i !== value.data.length; ++i) {\r\n if (typeof (Blob) !== \"undefined\") {\r\n form.append(`data-${i}`, new Blob([value.data[i]], { type: \"application/octet-stream\" }));\r\n } else {\r\n const buf = value.data[i];\r\n form.append(`data-${i}`, Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength));\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcMultipart.js","sourceRoot":"","sources":["../../../../src/rpc/web/RpcMultipart.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,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AC,QAAQ,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC,CAAC,CAAC;IAC5F,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus, IModelError } from \"../../IModelError\";\r\nimport { BackendBuffer, BackendReadable } from \"../../BackendTypes\";\r\nimport { RpcSerializedValue } from \"../core/RpcMarshaling\";\r\nimport { HttpServerRequest } from \"../web/WebAppRpcProtocol\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @internal */\r\nexport interface FormDataCommon {\r\n append(name: string, value: string | Blob | BackendBuffer, fileName?: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport interface ReadableFormData extends BackendReadable {\r\n getHeaders(): { [key: string]: any };\r\n}\r\n\r\n/** Support for transporting RPC values using the HTTP multipart content type.\r\n * @internal\r\n */\r\nexport class RpcMultipart {\r\n /** Creates a multipart form object for an RPC value. */\r\n public static createForm(value: RpcSerializedValue): FormData {\r\n const form = new FormData();\r\n RpcMultipart.writeValueToForm(form, value);\r\n return form;\r\n }\r\n\r\n /** Creates a multipart stream for an RPC value. */\r\n public static createStream(value: RpcSerializedValue): ReadableFormData {\r\n return this.platform.createStream(value);\r\n }\r\n\r\n /** Obtains the RPC value from a multipart HTTP request. */\r\n public static async parseRequest(req: HttpServerRequest): Promise<RpcSerializedValue> {\r\n return this.platform.parseRequest(req);\r\n }\r\n\r\n /** @internal */\r\n public static writeValueToForm(form: FormDataCommon, value: RpcSerializedValue) {\r\n form.append(\"objects\", value.objects);\r\n\r\n for (let i = 0; i !== value.data.length; ++i) {\r\n this.platform.appendToForm(i, form, value);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static platform = {\r\n createStream(_value: RpcSerializedValue): ReadableFormData {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\r\n },\r\n async parseRequest(_req: HttpServerRequest): Promise<RpcSerializedValue> {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\r\n },\r\n appendToForm(i: number, form: FormDataCommon, value: RpcSerializedValue): void {\r\n form.append(`data-${i}`, new Blob([value.data[i]], { type: \"application/octet-stream\" }));\r\n },\r\n };\r\n}\r\n\r\n"]}
@@ -1,18 +1,29 @@
1
1
  /** @packageDocumentation
2
2
  * @module RpcInterface
3
3
  */
4
+ import { RpcInterfaceDefinition } from "../../RpcInterface";
4
5
  import { RpcProtocolEvent } from "../core/RpcConstants";
5
6
  import { RpcInvocation } from "../core/RpcInvocation";
7
+ import { RpcOperation } from "../core/RpcOperation";
8
+ import { SerializedRpcOperation, SerializedRpcRequest } from "../core/RpcProtocol";
6
9
  import { RpcRequest } from "../core/RpcRequest";
10
+ import { WebAppRpcRequest } from "./WebAppRpcRequest";
7
11
  /** @internal */
8
- export declare class WebAppRpcLogging {
12
+ export declare abstract class WebAppRpcLogging {
13
+ static initializeBackend(instance: WebAppRpcLogging): void;
14
+ static initializeFrontend(instance: WebAppRpcLogging): void;
15
+ private static get backend();
16
+ private static get frontend();
9
17
  static logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void>;
10
- private static getRpcInterfaceName;
11
- private static findPathIds;
12
- private static buildOperationDescriptor;
13
- private static logRequest;
14
- private static logResponse;
15
- private static logErrorFrontend;
16
- private static logErrorBackend;
18
+ protected abstract logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void>;
19
+ protected abstract getHostname(): string;
20
+ protected getRpcInterfaceName(g: string | RpcInterfaceDefinition): string;
21
+ protected findPathIds(path: string): {
22
+ iTwinId: string;
23
+ iModelId: string;
24
+ };
25
+ protected buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string;
26
+ protected logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void;
27
+ protected logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void;
17
28
  }
18
29
  //# sourceMappingURL=WebAppRpcLogging.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebAppRpcLogging.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAqBhD,gBAAgB;AAChB,qBAAa,gBAAgB;WACP,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBhH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAIlC,OAAO,CAAC,MAAM,CAAC,WAAW;IAmB1B,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAUvC,OAAO,CAAC,MAAM,CAAC,UAAU;IAiBzB,OAAO,CAAC,MAAM,CAAC,WAAW;IAkB1B,OAAO,CAAC,MAAM,CAAC,gBAAgB;mBAcV,eAAe;CAiBrC"}
1
+ {"version":3,"file":"WebAppRpcLogging.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACp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Module", { value: true });
10
10
  exports.WebAppRpcLogging = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const CommonLoggerCategory_1 = require("../../CommonLoggerCategory");
13
+ const IModelError_1 = require("../../IModelError");
13
14
  const RpcConstants_1 = require("../core/RpcConstants");
14
15
  const RpcInvocation_1 = require("../core/RpcInvocation");
15
16
  const WebAppRpcRequest_1 = require("./WebAppRpcRequest");
16
- let hostname = "";
17
- function getHostname() {
18
- if (!hostname) {
19
- try {
20
- // eslint-disable-next-line @typescript-eslint/no-var-requires
21
- const os = require("os");
22
- hostname = os.hostname();
17
+ /** @internal */
18
+ const BACKEND = Symbol.for("@itwin.WebAppRpcLogging.Backend");
19
+ const FRONTEND = Symbol.for("@itwin.WebAppRpcLogging.Frontend");
20
+ /** @internal */
21
+ class WebAppRpcLogging {
22
+ static initializeBackend(instance) {
23
+ globalThis[BACKEND] = instance;
24
+ }
25
+ static initializeFrontend(instance) {
26
+ globalThis[FRONTEND] = instance;
27
+ }
28
+ static get backend() {
29
+ const instance = globalThis[BACKEND];
30
+ if (typeof (instance) === "undefined") {
31
+ throw new IModelError_1.IModelError(core_bentley_1.BentleyStatus.ERROR, "Backend logging is not initialized.");
23
32
  }
24
- catch (_) {
25
- if (globalThis.window) {
26
- hostname = globalThis.window.location.host;
27
- }
28
- else {
29
- hostname = "imodeljs-mobile";
30
- }
33
+ return instance;
34
+ }
35
+ static get frontend() {
36
+ const instance = globalThis[FRONTEND];
37
+ if (typeof (instance) === "undefined") {
38
+ throw new IModelError_1.IModelError(core_bentley_1.BentleyStatus.ERROR, "Frontend logging is not initialized.");
31
39
  }
40
+ return instance;
32
41
  }
33
- return hostname;
34
- }
35
- /** @internal */
36
- class WebAppRpcLogging {
37
42
  static async logProtocolEvent(event, object) {
38
43
  if (object instanceof WebAppRpcRequest_1.WebAppRpcRequest) {
39
- switch (event) {
40
- case RpcConstants_1.RpcProtocolEvent.RequestCreated: return WebAppRpcLogging.logRequest(CommonLoggerCategory_1.CommonLoggerCategory.RpcInterfaceFrontend, "RpcInterface.frontend.request", object);
41
- case RpcConstants_1.RpcProtocolEvent.ResponseLoaded: return WebAppRpcLogging.logResponse(CommonLoggerCategory_1.CommonLoggerCategory.RpcInterfaceFrontend, "RpcInterface.frontend.response", object, object.metadata.status, object.elapsed);
42
- case RpcConstants_1.RpcProtocolEvent.ConnectionErrorReceived: return WebAppRpcLogging.logErrorFrontend("RpcInterface.frontend.connectionError", object);
43
- case RpcConstants_1.RpcProtocolEvent.ConnectionAborted: return WebAppRpcLogging.logErrorFrontend("RpcInterface.frontend.connectionAborted", object);
44
- }
44
+ await WebAppRpcLogging.frontend.logProtocolEvent(event, object);
45
45
  }
46
46
  else if (object instanceof RpcInvocation_1.RpcInvocation) {
47
- switch (event) {
48
- case RpcConstants_1.RpcProtocolEvent.RequestReceived: return WebAppRpcLogging.logRequest(CommonLoggerCategory_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.request", object.request);
49
- case RpcConstants_1.RpcProtocolEvent.BackendErrorOccurred: return WebAppRpcLogging.logErrorBackend("RpcInterface.backend.error", object);
50
- case RpcConstants_1.RpcProtocolEvent.BackendResponseCreated: return WebAppRpcLogging.logResponse(CommonLoggerCategory_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.response", object.request, object.status, object.elapsed);
51
- }
47
+ await WebAppRpcLogging.backend.logProtocolEvent(event, object);
52
48
  }
53
49
  }
54
- static getRpcInterfaceName(g) {
50
+ getRpcInterfaceName(g) {
55
51
  return (typeof g === "string") ? g : g.interfaceName;
56
52
  }
57
- static findPathIds(path) {
53
+ findPathIds(path) {
58
54
  let iTwinId = "";
59
55
  let iModelId = "";
60
56
  const tokens = path.split("/");
@@ -69,7 +65,7 @@ class WebAppRpcLogging {
69
65
  }
70
66
  return { iTwinId, iModelId };
71
67
  }
72
- static buildOperationDescriptor(operation) {
68
+ buildOperationDescriptor(operation) {
73
69
  if (!operation) {
74
70
  return "unknown.unknown";
75
71
  }
@@ -77,65 +73,68 @@ class WebAppRpcLogging {
77
73
  const operationName = operation.operationName;
78
74
  return `${interfaceName}.${operationName}`;
79
75
  }
80
- static logRequest(loggerCategory, message, object) {
81
- const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(object.operation);
82
- const pathIds = WebAppRpcLogging.findPathIds(object.path);
76
+ logRequest(loggerCategory, message, object) {
77
+ const operationDescriptor = this.buildOperationDescriptor(object.operation);
78
+ const pathIds = this.findPathIds(object.path);
83
79
  core_bentley_1.Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({
84
80
  method: object.method,
85
81
  path: object.path,
86
82
  operation: object.operation.operationName,
87
- rpcInterface: WebAppRpcLogging.getRpcInterfaceName(object.operation.interfaceDefinition),
83
+ rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),
88
84
  // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
89
85
  ActivityId: object.id,
90
86
  TimeElapsed: ("elapsed" in object) ? object.elapsed : 0,
91
- MachineName: getHostname(),
87
+ MachineName: this.getHostname(),
92
88
  ...pathIds,
93
89
  }));
94
90
  }
95
- static logResponse(loggerCategory, message, object, status, elapsed) {
96
- const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(object.operation);
97
- const pathIds = WebAppRpcLogging.findPathIds(object.path);
91
+ logResponse(loggerCategory, message, object, status, elapsed) {
92
+ const operationDescriptor = this.buildOperationDescriptor(object.operation);
93
+ const pathIds = this.findPathIds(object.path);
98
94
  core_bentley_1.Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({
99
95
  method: object.method,
100
96
  path: object.path,
101
97
  operation: object.operation.operationName,
102
- rpcInterface: WebAppRpcLogging.getRpcInterfaceName(object.operation.interfaceDefinition),
98
+ rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),
103
99
  status,
104
100
  // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
105
101
  ActivityId: object.id,
106
102
  TimeElapsed: elapsed,
107
- MachineName: getHostname(),
103
+ MachineName: this.getHostname(),
108
104
  ...pathIds,
109
105
  }));
110
106
  }
111
- static logErrorFrontend(message, request) {
112
- const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(request.operation);
113
- const pathIds = WebAppRpcLogging.findPathIds(request.path);
107
+ }
108
+ exports.WebAppRpcLogging = WebAppRpcLogging;
109
+ class WebAppRpcLoggingFrontend extends WebAppRpcLogging {
110
+ async logProtocolEvent(event, object) {
111
+ switch (event) {
112
+ case RpcConstants_1.RpcProtocolEvent.RequestCreated: return this.logRequest(CommonLoggerCategory_1.CommonLoggerCategory.RpcInterfaceFrontend, "RpcInterface.frontend.request", object);
113
+ case RpcConstants_1.RpcProtocolEvent.ResponseLoaded: return this.logResponse(CommonLoggerCategory_1.CommonLoggerCategory.RpcInterfaceFrontend, "RpcInterface.frontend.response", object, object.metadata.status, object.elapsed);
114
+ case RpcConstants_1.RpcProtocolEvent.ConnectionErrorReceived: return this.logErrorFrontend("RpcInterface.frontend.connectionError", object);
115
+ case RpcConstants_1.RpcProtocolEvent.ConnectionAborted: return this.logErrorFrontend("RpcInterface.frontend.connectionAborted", object);
116
+ }
117
+ }
118
+ getHostname() {
119
+ if (globalThis.window) {
120
+ return globalThis.window.location.host;
121
+ }
122
+ else {
123
+ return "imodeljs-mobile";
124
+ }
125
+ }
126
+ logErrorFrontend(message, request) {
127
+ const operationDescriptor = this.buildOperationDescriptor(request.operation);
128
+ const pathIds = this.findPathIds(request.path);
114
129
  core_bentley_1.Logger.logInfo(CommonLoggerCategory_1.CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({
115
130
  method: request.method,
116
131
  path: request.path,
117
132
  // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
118
133
  ActivityId: request.id,
119
- MachineName: getHostname(),
120
- ...pathIds,
121
- }));
122
- }
123
- static async logErrorBackend(message, invocation) {
124
- const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(invocation.operation);
125
- const pathIds = WebAppRpcLogging.findPathIds(invocation.request.path);
126
- const result = await invocation.result;
127
- const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue
128
- core_bentley_1.Logger.logInfo(CommonLoggerCategory_1.CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({
129
- method: invocation.request.method,
130
- path: invocation.request.path,
131
- status: invocation.status,
132
- errorMessage,
133
- // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
134
- ActivityId: invocation.request.id,
135
- MachineName: getHostname(),
134
+ MachineName: this.getHostname(),
136
135
  ...pathIds,
137
136
  }));
138
137
  }
139
138
  }
140
- exports.WebAppRpcLogging = WebAppRpcLogging;
139
+ WebAppRpcLogging.initializeFrontend(new WebAppRpcLoggingFrontend());
141
140
  //# sourceMappingURL=WebAppRpcLogging.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebAppRpcLogging.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,qEAAkE;AAElE,uDAAwD;AACxD,yDAAsD;AAItD,yDAAsD;AAEtD,IAAI,QAAQ,GAAG,EAAE,CAAC;AAClB,SAAS,WAAW;IAClB,IAAI,CAAC,QAAQ,EAAE;QACb,IAAI;YACF,8DAA8D;YAC9D,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;YACzB,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;SAC1B;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,UAAU,CAAC,MAAM,EAAE;gBACrB,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;aAC5C;iBAAM;gBACL,QAAQ,GAAG,iBAAiB,CAAC;aAC9B;SACF;KACF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,gBAAgB;AAChB,MAAa,gBAAgB;IACpB,MAAM,C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C,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,2CAAoB,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,WAAW,EAAE;YAC1B,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AArHD,4CAqHC","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 } from \"../../CommonLoggerCategory\";\r\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcProtocolEvent } from \"../core/RpcConstants\";\r\nimport { RpcInvocation } from \"../core/RpcInvocation\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\n\r\nlet hostname = \"\";\r\nfunction getHostname(): string {\r\n if (!hostname) {\r\n try {\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const os = require(\"os\");\r\n hostname = os.hostname();\r\n } catch (_) {\r\n if (globalThis.window) {\r\n hostname = globalThis.window.location.host;\r\n } else {\r\n hostname = \"imodeljs-mobile\";\r\n }\r\n }\r\n }\r\n return hostname;\r\n}\r\n\r\n/** @internal */\r\nexport class WebAppRpcLogging {\r\n public static async logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void> {\r\n if (object instanceof WebAppRpcRequest) {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestCreated: return WebAppRpcLogging.logRequest(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.request\", object);\r\n case RpcProtocolEvent.ResponseLoaded: return WebAppRpcLogging.logResponse(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.response\", object, object.metadata.status, object.elapsed);\r\n case RpcProtocolEvent.ConnectionErrorReceived: return WebAppRpcLogging.logErrorFrontend(\"RpcInterface.frontend.connectionError\", object);\r\n case RpcProtocolEvent.ConnectionAborted: return WebAppRpcLogging.logErrorFrontend(\"RpcInterface.frontend.connectionAborted\", object);\r\n }\r\n } else if (object instanceof RpcInvocation) {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestReceived: return WebAppRpcLogging.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\r\n case RpcProtocolEvent.BackendErrorOccurred: return WebAppRpcLogging.logErrorBackend(\"RpcInterface.backend.error\", object);\r\n case RpcProtocolEvent.BackendResponseCreated: return WebAppRpcLogging.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\r\n }\r\n }\r\n }\r\n\r\n private static getRpcInterfaceName(g: string | RpcInterfaceDefinition): string {\r\n return (typeof g === \"string\") ? g : g.interfaceName;\r\n }\r\n\r\n private static findPathIds(path: string) {\r\n let iTwinId = \"\";\r\n let iModelId = \"\";\r\n\r\n const tokens = path.split(\"/\");\r\n for (let i = 0; i !== tokens.length; ++i) {\r\n // For backwards compatibility, find old \"context\" or current \"iTwin\" terminology\r\n if ((/^context$/i).test(tokens[i]) || (/^itwin$/i).test(tokens[i])) {\r\n iTwinId = tokens[i + 1] || \"\";\r\n }\r\n\r\n if ((/^imodel$/i).test(tokens[i])) {\r\n iModelId = tokens[i + 1] || \"\";\r\n }\r\n }\r\n\r\n return { iTwinId, iModelId };\r\n }\r\n\r\n private static buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string {\r\n if (!operation) {\r\n return \"unknown.unknown\";\r\n }\r\n\r\n const interfaceName = typeof (operation.interfaceDefinition) === \"string\" ? operation.interfaceDefinition : operation.interfaceDefinition.interfaceName;\r\n const operationName = operation.operationName;\r\n return `${interfaceName}.${operationName}`;\r\n }\r\n\r\n private static logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(object.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(object.path);\r\n\r\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\r\n method: object.method,\r\n path: object.path,\r\n operation: object.operation.operationName,\r\n rpcInterface: WebAppRpcLogging.getRpcInterfaceName(object.operation.interfaceDefinition),\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n TimeElapsed: (\"elapsed\" in object) ? object.elapsed : 0, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(object.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(object.path);\r\n\r\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\r\n method: object.method,\r\n path: object.path,\r\n operation: object.operation.operationName,\r\n rpcInterface: WebAppRpcLogging.getRpcInterfaceName(object.operation.interfaceDefinition),\r\n status,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n TimeElapsed: elapsed, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static logErrorFrontend(message: string, request: WebAppRpcRequest): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(request.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(request.path);\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({\r\n method: request.method,\r\n path: request.path,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(invocation.operation);\r\n const pathIds = WebAppRpcLogging.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: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"WebAppRpcLogging.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRp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AAM,EAAE;YACrB,OAAO,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;SACxC;aAAM;YACL,OAAO,iBAAiB,CAAC;SAC1B;IACH,CAAC;IAEO,gBAAgB,CAAC,OAAe,EAAE,OAAyB;QACjE,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE/C,qBAAM,CAAC,OAAO,CAAC,2CAAoB,CAAC,oBAAoB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACpG,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,uGAAuG;YACvG,UAAU,EAAE,OAAO,CAAC,EAAE;YACtB,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAED,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcProtocolEvent } from \"../core/RpcConstants\";\r\nimport { RpcInvocation } from \"../core/RpcInvocation\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\n\r\n/** @internal */\r\nconst BACKEND = Symbol.for(\"@itwin.WebAppRpcLogging.Backend\");\r\nconst FRONTEND = Symbol.for(\"@itwin.WebAppRpcLogging.Frontend\");\r\n\r\n/** @internal */\r\nexport abstract class WebAppRpcLogging {\r\n public static initializeBackend(instance: WebAppRpcLogging) {\r\n (globalThis as any)[BACKEND] = instance;\r\n }\r\n\r\n public static initializeFrontend(instance: WebAppRpcLogging) {\r\n (globalThis as any)[FRONTEND] = instance;\r\n }\r\n\r\n private static get backend(): WebAppRpcLogging {\r\n const instance = (globalThis as any)[BACKEND];\r\n if (typeof (instance) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"Backend logging is not initialized.\");\r\n }\r\n\r\n return instance;\r\n }\r\n\r\n private static get frontend(): WebAppRpcLogging {\r\n const instance = (globalThis as any)[FRONTEND];\r\n if (typeof (instance) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"Frontend logging is not initialized.\");\r\n }\r\n\r\n return instance;\r\n }\r\n\r\n public static async logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void> {\r\n if (object instanceof WebAppRpcRequest) {\r\n await WebAppRpcLogging.frontend.logProtocolEvent(event, object);\r\n } else if (object instanceof RpcInvocation) {\r\n await WebAppRpcLogging.backend.logProtocolEvent(event, object);\r\n }\r\n }\r\n\r\n protected abstract logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void>;\r\n\r\n protected abstract getHostname(): string;\r\n\r\n protected getRpcInterfaceName(g: string | RpcInterfaceDefinition): string {\r\n return (typeof g === \"string\") ? g : g.interfaceName;\r\n }\r\n\r\n protected findPathIds(path: string) {\r\n let iTwinId = \"\";\r\n let iModelId = \"\";\r\n\r\n const tokens = path.split(\"/\");\r\n for (let i = 0; i !== tokens.length; ++i) {\r\n // For backwards compatibility, find old \"context\" or current \"iTwin\" terminology\r\n if ((/^context$/i).test(tokens[i]) || (/^itwin$/i).test(tokens[i])) {\r\n iTwinId = tokens[i + 1] || \"\";\r\n }\r\n\r\n if ((/^imodel$/i).test(tokens[i])) {\r\n iModelId = tokens[i + 1] || \"\";\r\n }\r\n }\r\n\r\n return { iTwinId, iModelId };\r\n }\r\n\r\n protected buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string {\r\n if (!operation) {\r\n return \"unknown.unknown\";\r\n }\r\n\r\n const interfaceName = typeof (operation.interfaceDefinition) === \"string\" ? operation.interfaceDefinition : operation.interfaceDefinition.interfaceName;\r\n const operationName = operation.operationName;\r\n return `${interfaceName}.${operationName}`;\r\n }\r\n\r\n protected logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void {\r\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\r\n const pathIds = this.findPathIds(object.path);\r\n\r\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\r\n method: object.method,\r\n path: object.path,\r\n operation: object.operation.operationName,\r\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n TimeElapsed: (\"elapsed\" in object) ? object.elapsed : 0, // 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 protected logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void {\r\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\r\n const pathIds = this.findPathIds(object.path);\r\n\r\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\r\n method: object.method,\r\n path: object.path,\r\n operation: object.operation.operationName,\r\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\r\n status,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n TimeElapsed: elapsed, // 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\r\nclass WebAppRpcLoggingFrontend extends WebAppRpcLogging {\r\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: WebAppRpcRequest): Promise<void> {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestCreated: return this.logRequest(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.request\", object);\r\n case RpcProtocolEvent.ResponseLoaded: return this.logResponse(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.response\", object, object.metadata.status, object.elapsed);\r\n case RpcProtocolEvent.ConnectionErrorReceived: return this.logErrorFrontend(\"RpcInterface.frontend.connectionError\", object);\r\n case RpcProtocolEvent.ConnectionAborted: return this.logErrorFrontend(\"RpcInterface.frontend.connectionAborted\", object);\r\n }\r\n }\r\n\r\n protected override getHostname(): string {\r\n if (globalThis.window) {\r\n return globalThis.window.location.host;\r\n } else {\r\n return \"imodeljs-mobile\";\r\n }\r\n }\r\n\r\n private logErrorFrontend(message: string, request: WebAppRpcRequest): void {\r\n const operationDescriptor = this.buildOperationDescriptor(request.operation);\r\n const pathIds = this.findPathIds(request.path);\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({\r\n method: request.method,\r\n path: request.path,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: 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\r\nWebAppRpcLogging.initializeFrontend(new WebAppRpcLoggingFrontend());\r\n"]}
@@ -2,7 +2,7 @@
2
2
  * @module RpcInterface
3
3
  */
4
4
  /// <reference types="node" />
5
- import { Readable, Writable } from "stream";
5
+ import { BackendReadable, BackendWritable } from "../../BackendTypes";
6
6
  import { RpcConfiguration } from "../core/RpcConfiguration";
7
7
  import { RpcContentType, RpcRequestStatus } from "../core/RpcConstants";
8
8
  import { RpcOperation } from "../core/RpcOperation";
@@ -12,7 +12,7 @@ import { WebAppRpcRequest } from "./WebAppRpcRequest";
12
12
  /** An HTTP server request object.
13
13
  * @public
14
14
  */
15
- export interface HttpServerRequest extends Readable {
15
+ export interface HttpServerRequest extends BackendReadable {
16
16
  aborted: boolean;
17
17
  httpVersion: string;
18
18
  httpVersionMajor: number;
@@ -27,6 +27,7 @@ export interface HttpServerRequest extends Readable {
27
27
  [key: string]: string | undefined;
28
28
  };
29
29
  rawTrailers: string[];
30
+ setTimeout(msecs: number, callback: () => void): void;
30
31
  setTimeout(msecs: number, callback: () => void): this;
31
32
  url?: string;
32
33
  statusCode?: number;
@@ -42,7 +43,7 @@ export interface HttpServerRequest extends Readable {
42
43
  /** An HTTP server response object.
43
44
  * @public
44
45
  */
45
- export interface HttpServerResponse extends Writable {
46
+ export interface HttpServerResponse extends BackendWritable {
46
47
  send(body?: any): HttpServerResponse;
47
48
  status(code: number): HttpServerResponse;
48
49
  set(field: string, value: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"WebAppRpcProtocol.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAGH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAqB,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAwB,MAAM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,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC;YAC5C,KAAK,+BAAgB,CAAC,UAAU,CAAC,CAAC,OAAO,GAAG,CAAC;YAC7C,KAAK,+BAAgB,CAAC,kBAAkB,CAAC,CAAC,OAAO,GAAG,CAAC;YACrD,KAAK,+BAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,GAAG,CAAC;YACjD,KAAK,+BAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,GAAG,CAAC;YACjD,KAAK,+BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,GAAG,CAAC;YAClD,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;SACrB;IACH,CAAC;IAID,+DAA+D;IACxD,SAAS,CAAC,IAAY;QAC3B,OAAO,IAAI,KAAK,GAAG,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,kBAAkB,KAAK,OAAO,IAAI,+BAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAY5E;AA/GD,8CA+GC","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 { BentleyError, Logger } from \"@itwin/core-bentley\";\r\nimport { Readable, Writable } from \"stream\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcContentType, RpcRequestStatus, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { RpcProtocol, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from \"./OpenAPI\";\r\nimport { WebAppRpcLogging } from \"./WebAppRpcLogging\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\n\r\n/** An HTTP server request object.\r\n * @public\r\n */\r\nexport interface HttpServerRequest extends Readable {\r\n aborted: boolean;\r\n httpVersion: string;\r\n httpVersionMajor: number;\r\n httpVersionMinor: number;\r\n complete: boolean;\r\n connection: any;\r\n headers: { [header: string]: string | string[] | undefined };\r\n rawHeaders: string[];\r\n trailers: { [key: string]: string | undefined };\r\n rawTrailers: string[];\r\n setTimeout(msecs: number, callback: () => void): this;\r\n url?: string;\r\n statusCode?: number;\r\n statusMessage?: string;\r\n socket: any;\r\n destroy(error?: Error): this;\r\n body: string | Buffer;\r\n path: string;\r\n method: string;\r\n ip?: string;\r\n header: (field: string) => string | undefined;\r\n}\r\n\r\n/** An HTTP server response object.\r\n * @public\r\n */\r\nexport interface HttpServerResponse extends Writable {\r\n send(body?: any): HttpServerResponse;\r\n status(code: number): HttpServerResponse;\r\n set(field: string, value: string): void;\r\n}\r\n\r\n/** The HTTP application protocol.\r\n * @internal\r\n */\r\nexport abstract class WebAppRpcProtocol extends RpcProtocol {\r\n public override preserveStreams = true;\r\n\r\n /** Convenience handler for an RPC operation get request for an HTTP server. */\r\n public async handleOperationGetRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n return this.handleOperationPostRequest(req, res);\r\n }\r\n\r\n /** Convenience handler for an RPC operation post request for an HTTP server. */\r\n public async handleOperationPostRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n let request: SerializedRpcRequest;\r\n try {\r\n request = await WebAppRpcRequest.parseRequest(this, req);\r\n } catch (error) {\r\n const message = BentleyError.getErrorMessage(error);\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, `Failed to parse request: ${message}`, BentleyError.getErrorMetadata(error));\r\n res.status(400);\r\n res.send(JSON.stringify({ message, isError: true }));\r\n return;\r\n }\r\n const fulfillment = await this.fulfill(request);\r\n await WebAppRpcRequest.sendResponse(this, request, fulfillment, req, res);\r\n }\r\n\r\n /** Convenience handler for an OpenAPI description request for an HTTP server. */\r\n public handleOpenApiDescriptionRequest(_req: HttpServerRequest, res: HttpServerResponse) {\r\n const description = JSON.stringify(this.openAPIDescription);\r\n res.send(description);\r\n }\r\n\r\n /** Converts an HTTP content type value to an RPC content type value. */\r\n public static computeContentType(httpType: string | null | undefined): RpcContentType {\r\n if (!httpType)\r\n return RpcContentType.Unknown;\r\n\r\n if (httpType.indexOf(WEB_RPC_CONSTANTS.ANY_TEXT) === 0) {\r\n return RpcContentType.Text;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.BINARY) === 0) {\r\n return RpcContentType.Binary;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.MULTIPART) === 0) {\r\n return RpcContentType.Multipart;\r\n } else {\r\n return RpcContentType.Unknown;\r\n }\r\n }\r\n\r\n /** The OpenAPI-compatible info object for this protocol. */\r\n public abstract info: OpenAPIInfo;\r\n\r\n /** An optional prefix for RPC operation URI paths. */\r\n public pathPrefix: string = \"\";\r\n\r\n /** The RPC request class for this protocol. */\r\n public readonly requestType = WebAppRpcRequest;\r\n\r\n /** Supplies the status corresponding to a protocol-specific code value. */\r\n public override getStatus(code: number): RpcRequestStatus {\r\n switch (code) {\r\n case 404: return RpcRequestStatus.NotFound;\r\n case 202: return RpcRequestStatus.Pending;\r\n case 200: return RpcRequestStatus.Resolved;\r\n case 500: return RpcRequestStatus.Rejected;\r\n case 204: return RpcRequestStatus.NoContent;\r\n case 502: return RpcRequestStatus.BadGateway;\r\n case 503: return RpcRequestStatus.ServiceUnavailable;\r\n case 504: return RpcRequestStatus.GatewayTimeout;\r\n case 408: return RpcRequestStatus.RequestTimeout;\r\n case 429: return RpcRequestStatus.TooManyRequests;\r\n default: return RpcRequestStatus.Unknown;\r\n }\r\n }\r\n\r\n /** Supplies the protocol-specific code corresponding to a status value. */\r\n public override getCode(status: RpcRequestStatus): number {\r\n switch (status) {\r\n case RpcRequestStatus.NotFound: return 404;\r\n case RpcRequestStatus.Pending: return 202;\r\n case RpcRequestStatus.Resolved: return 200;\r\n case RpcRequestStatus.Rejected: return 500;\r\n case RpcRequestStatus.NoContent: return 204;\r\n case RpcRequestStatus.BadGateway: return 502;\r\n case RpcRequestStatus.ServiceUnavailable: return 503;\r\n case RpcRequestStatus.GatewayTimeout: return 504;\r\n case RpcRequestStatus.RequestTimeout: return 408;\r\n case RpcRequestStatus.TooManyRequests: return 429;\r\n default: return 501;\r\n }\r\n }\r\n\r\n public override supportsStatusCategory = true;\r\n\r\n /** Whether an HTTP status code indicates a request timeout. */\r\n public isTimeout(code: number): boolean {\r\n return code === 504;\r\n }\r\n\r\n /** An OpenAPI-compatible description of this protocol.\r\n * @internal\r\n */\r\n public get openAPIDescription() { return new RpcOpenAPIDescription(this); }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public abstract supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[];\r\n\r\n /** Constructs an HTTP protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n super(configuration);\r\n this.events.addListener(WebAppRpcLogging.logProtocolEvent);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"WebAppRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,qEAAkE;AAGlE,uDAA2F;AAE3F,qDAAwE;AACxE,uCAAiF;AACjF,yDAAsD;AACtD,yDAAsD;AAyCtD;;GAEG;AACH,MAAsB,iBAAkB,SAAQ,yBAAW;IA0GzD,mCAAmC;IACnC,YAAmB,aAA+B;QAChD,KAAK,CAAC,aAAa,CAAC,CAAC;QA3GP,oBAAe,GAAG,IAAI,CAAC;QAgDvC,sDAAsD;QAC/C,eAAU,GAAW,EAAE,CAAC;QAE/B,+CAA+C;QAC/B,gBAAW,GAAG,mCAAgB,CAAC;QAoC/B,2BAAsB,GAAG,IAAI,CAAC;QAoB5C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC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AAC,OAAO,+BAAgB,CAAC,OAAO,CAAC;SAC1C;IACH,CAAC;IAED,2EAA2E;IAC3D,OAAO,CAAC,MAAwB;QAC9C,QAAQ,MAAM,EAAE;YACd,KAAK,+BAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,GAAG,CAAC;YAC3C,KAAK,+BAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;YAC1C,KAAK,+BAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,GAAG,CAAC;YAC3C,KAAK,+BAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,GAAG,CAAC;YAC3C,KAAK,+BAAgB,CAAC,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC;YAC5C,KAAK,+BAAgB,CAAC,UAAU,CAAC,CAAC,OAAO,GAAG,CAAC;YAC7C,KAAK,+BAAgB,CAAC,kBAAkB,CAAC,CAAC,OAAO,GAAG,CAAC;YACrD,KAAK,+BAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,GAAG,CAAC;YACjD,KAAK,+BAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,GAAG,CAAC;YACjD,KAAK,+BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,GAAG,CAAC;YAClD,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;SACrB;IACH,CAAC;IAID,+DAA+D;IACxD,SAAS,CAAC,IAAY;QAC3B,OAAO,IAAI,KAAK,GAAG,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,kBAAkB,KAAK,OAAO,IAAI,+BAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAY5E;AA/GD,8CA+GC","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 { BentleyError, Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { BackendReadable, BackendWritable } from \"../../BackendTypes\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcContentType, RpcRequestStatus, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { RpcProtocol, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from \"./OpenAPI\";\r\nimport { WebAppRpcLogging } from \"./WebAppRpcLogging\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An HTTP server request object.\r\n * @public\r\n */\r\nexport interface HttpServerRequest extends BackendReadable {\r\n aborted: boolean;\r\n httpVersion: string;\r\n httpVersionMajor: number;\r\n httpVersionMinor: number;\r\n complete: boolean;\r\n connection: any;\r\n headers: { [header: string]: string | string[] | undefined };\r\n rawHeaders: string[];\r\n trailers: { [key: string]: string | undefined };\r\n rawTrailers: string[];\r\n setTimeout(msecs: number, callback: () => void): void;\r\n setTimeout(msecs: number, callback: () => void): this;\r\n url?: string;\r\n statusCode?: number;\r\n statusMessage?: string;\r\n socket: any;\r\n destroy(error?: Error): this;\r\n body: string | Buffer;\r\n path: string;\r\n method: string;\r\n ip?: string;\r\n header: (field: string) => string | undefined;\r\n}\r\n\r\n/** An HTTP server response object.\r\n * @public\r\n */\r\nexport interface HttpServerResponse extends BackendWritable {\r\n send(body?: any): HttpServerResponse;\r\n status(code: number): HttpServerResponse;\r\n set(field: string, value: string): void;\r\n}\r\n\r\n/** The HTTP application protocol.\r\n * @internal\r\n */\r\nexport abstract class WebAppRpcProtocol extends RpcProtocol {\r\n public override preserveStreams = true;\r\n\r\n /** Convenience handler for an RPC operation get request for an HTTP server. */\r\n public async handleOperationGetRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n return this.handleOperationPostRequest(req, res);\r\n }\r\n\r\n /** Convenience handler for an RPC operation post request for an HTTP server. */\r\n public async handleOperationPostRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n let request: SerializedRpcRequest;\r\n try {\r\n request = await WebAppRpcRequest.parseRequest(this, req);\r\n } catch (error) {\r\n const message = BentleyError.getErrorMessage(error);\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, `Failed to parse request: ${message}`, BentleyError.getErrorMetadata(error));\r\n res.status(400);\r\n res.send(JSON.stringify({ message, isError: true }));\r\n return;\r\n }\r\n const fulfillment = await this.fulfill(request);\r\n await WebAppRpcRequest.sendResponse(this, request, fulfillment, req, res);\r\n }\r\n\r\n /** Convenience handler for an OpenAPI description request for an HTTP server. */\r\n public handleOpenApiDescriptionRequest(_req: HttpServerRequest, res: HttpServerResponse) {\r\n const description = JSON.stringify(this.openAPIDescription);\r\n res.send(description);\r\n }\r\n\r\n /** Converts an HTTP content type value to an RPC content type value. */\r\n public static computeContentType(httpType: string | null | undefined): RpcContentType {\r\n if (!httpType)\r\n return RpcContentType.Unknown;\r\n\r\n if (httpType.indexOf(WEB_RPC_CONSTANTS.ANY_TEXT) === 0) {\r\n return RpcContentType.Text;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.BINARY) === 0) {\r\n return RpcContentType.Binary;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.MULTIPART) === 0) {\r\n return RpcContentType.Multipart;\r\n } else {\r\n return RpcContentType.Unknown;\r\n }\r\n }\r\n\r\n /** The OpenAPI-compatible info object for this protocol. */\r\n public abstract info: OpenAPIInfo;\r\n\r\n /** An optional prefix for RPC operation URI paths. */\r\n public pathPrefix: string = \"\";\r\n\r\n /** The RPC request class for this protocol. */\r\n public readonly requestType = WebAppRpcRequest;\r\n\r\n /** Supplies the status corresponding to a protocol-specific code value. */\r\n public override getStatus(code: number): RpcRequestStatus {\r\n switch (code) {\r\n case 404: return RpcRequestStatus.NotFound;\r\n case 202: return RpcRequestStatus.Pending;\r\n case 200: return RpcRequestStatus.Resolved;\r\n case 500: return RpcRequestStatus.Rejected;\r\n case 204: return RpcRequestStatus.NoContent;\r\n case 502: return RpcRequestStatus.BadGateway;\r\n case 503: return RpcRequestStatus.ServiceUnavailable;\r\n case 504: return RpcRequestStatus.GatewayTimeout;\r\n case 408: return RpcRequestStatus.RequestTimeout;\r\n case 429: return RpcRequestStatus.TooManyRequests;\r\n default: return RpcRequestStatus.Unknown;\r\n }\r\n }\r\n\r\n /** Supplies the protocol-specific code corresponding to a status value. */\r\n public override getCode(status: RpcRequestStatus): number {\r\n switch (status) {\r\n case RpcRequestStatus.NotFound: return 404;\r\n case RpcRequestStatus.Pending: return 202;\r\n case RpcRequestStatus.Resolved: return 200;\r\n case RpcRequestStatus.Rejected: return 500;\r\n case RpcRequestStatus.NoContent: return 204;\r\n case RpcRequestStatus.BadGateway: return 502;\r\n case RpcRequestStatus.ServiceUnavailable: return 503;\r\n case RpcRequestStatus.GatewayTimeout: return 504;\r\n case RpcRequestStatus.RequestTimeout: return 408;\r\n case RpcRequestStatus.TooManyRequests: return 429;\r\n default: return 501;\r\n }\r\n }\r\n\r\n public override supportsStatusCategory = true;\r\n\r\n /** Whether an HTTP status code indicates a request timeout. */\r\n public isTimeout(code: number): boolean {\r\n return code === 504;\r\n }\r\n\r\n /** An OpenAPI-compatible description of this protocol.\r\n * @internal\r\n */\r\n public get openAPIDescription() { return new RpcOpenAPIDescription(this); }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public abstract supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[];\r\n\r\n /** Constructs an HTTP protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n super(configuration);\r\n this.events.addListener(WebAppRpcLogging.logProtocolEvent);\r\n }\r\n}\r\n"]}
@@ -32,14 +32,12 @@ export declare class WebAppRpcRequest extends RpcRequest {
32
32
  status: number;
33
33
  message: string;
34
34
  };
35
- /** Parse headers */
36
- private static parseHeaders;
37
35
  /** Parses a request. */
38
36
  static parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest>;
39
37
  /** Sends the response for a web request. */
40
38
  static sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
41
39
  /** Determines the most efficient transport type for an RPC value. */
42
- protected static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType;
40
+ static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType;
43
41
  /** Constructs a web application request. */
44
42
  constructor(client: RpcInterface, operation: string, parameters: any[]);
45
43
  /** Sets request header values. */
@@ -53,13 +51,6 @@ export declare class WebAppRpcRequest extends RpcRequest {
53
51
  protected supplyFetch(): typeof fetch;
54
52
  /** Override to supply an alternate Request function. */
55
53
  protected supplyRequest(): typeof Request;
56
- private static configureResponse;
57
- private static configureText;
58
- private static configureBinary;
59
- private static configureMultipart;
60
- private static configureStream;
61
- private static parseFromPath;
62
- private static parseFromBody;
63
54
  private performFetch;
64
55
  private loadText;
65
56
  private loadBinary;
@@ -68,5 +59,10 @@ export declare class WebAppRpcRequest extends RpcRequest {
68
59
  private setupBinaryTransport;
69
60
  private setupMultipartTransport;
70
61
  private setupTextTransport;
62
+ /** @internal */
63
+ static backend: {
64
+ sendResponse: (_protocol: WebAppRpcProtocol, _request: SerializedRpcRequest, _fulfillment: RpcRequestFulfillment, _req: HttpServerRequest, _res: HttpServerResponse) => Promise<void>;
65
+ parseRequest: (_protocol: WebAppRpcProtocol, _req: HttpServerRequest) => Promise<SerializedRpcRequest>;
66
+ };
71
67
  }
72
68
  //# sourceMappingURL=WebAppRpcRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebAppRpcRequest.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,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