@itwin/core-common 4.10.0-dev.32 → 4.10.0-dev.33

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 (177) hide show
  1. package/lib/cjs/BackgroundMapProvider.js +1 -1
  2. package/lib/cjs/BackgroundMapProvider.js.map +1 -1
  3. package/lib/cjs/BackgroundMapSettings.js +2 -2
  4. package/lib/cjs/BackgroundMapSettings.js.map +1 -1
  5. package/lib/cjs/BriefcaseTypes.js.map +1 -1
  6. package/lib/cjs/ColorDef.d.ts.map +1 -1
  7. package/lib/cjs/ColorDef.js +0 -3
  8. package/lib/cjs/ColorDef.js.map +1 -1
  9. package/lib/cjs/ECSqlReader.js.map +1 -1
  10. package/lib/cjs/ElementMesh.js +1 -1
  11. package/lib/cjs/ElementMesh.js.map +1 -1
  12. package/lib/cjs/IModel.js.map +1 -1
  13. package/lib/cjs/MapLayerSettings.d.ts.map +1 -1
  14. package/lib/cjs/MapLayerSettings.js +0 -1
  15. package/lib/cjs/MapLayerSettings.js.map +1 -1
  16. package/lib/cjs/RenderMaterial.js +4 -4
  17. package/lib/cjs/RenderMaterial.js.map +1 -1
  18. package/lib/cjs/RenderTexture.js.map +1 -1
  19. package/lib/cjs/RpcInterface.js +1 -1
  20. package/lib/cjs/RpcInterface.js.map +1 -1
  21. package/lib/cjs/RpcManager.d.ts.map +1 -1
  22. package/lib/cjs/RpcManager.js.map +1 -1
  23. package/lib/cjs/SubCategoryAppearance.js.map +1 -1
  24. package/lib/cjs/TextureMapping.js.map +1 -1
  25. package/lib/cjs/Tween.d.ts.map +1 -1
  26. package/lib/cjs/Tween.js +0 -1
  27. package/lib/cjs/Tween.js.map +1 -1
  28. package/lib/cjs/geometry/FrustumPlanes.js.map +1 -1
  29. package/lib/cjs/rpc/DevToolsRpcInterface.js.map +1 -1
  30. package/lib/cjs/rpc/IModelReadRpcInterface.js +12 -12
  31. package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
  32. package/lib/cjs/rpc/IModelTileRpcInterface.js +1 -1
  33. package/lib/cjs/rpc/IModelTileRpcInterface.js.map +1 -1
  34. package/lib/cjs/rpc/SnapshotIModelRpcInterface.js.map +1 -1
  35. package/lib/cjs/rpc/TestRpcManager.d.ts.map +1 -1
  36. package/lib/cjs/rpc/TestRpcManager.js +0 -1
  37. package/lib/cjs/rpc/TestRpcManager.js.map +1 -1
  38. package/lib/cjs/rpc/WipRpcInterface.js +1 -1
  39. package/lib/cjs/rpc/WipRpcInterface.js.map +1 -1
  40. package/lib/cjs/rpc/core/RpcConfiguration.d.ts.map +1 -1
  41. package/lib/cjs/rpc/core/RpcConfiguration.js +1 -1
  42. package/lib/cjs/rpc/core/RpcConfiguration.js.map +1 -1
  43. package/lib/cjs/rpc/core/RpcConstants.js +1 -1
  44. package/lib/cjs/rpc/core/RpcConstants.js.map +1 -1
  45. package/lib/cjs/rpc/core/RpcControl.d.ts.map +1 -1
  46. package/lib/cjs/rpc/core/RpcControl.js +0 -1
  47. package/lib/cjs/rpc/core/RpcControl.js.map +1 -1
  48. package/lib/cjs/rpc/core/RpcInvocation.js +1 -1
  49. package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
  50. package/lib/cjs/rpc/core/RpcMarshaling.js +1 -1
  51. package/lib/cjs/rpc/core/RpcMarshaling.js.map +1 -1
  52. package/lib/cjs/rpc/core/RpcOperation.d.ts.map +1 -1
  53. package/lib/cjs/rpc/core/RpcOperation.js +0 -1
  54. package/lib/cjs/rpc/core/RpcOperation.js.map +1 -1
  55. package/lib/cjs/rpc/core/RpcPendingQueue.js +1 -1
  56. package/lib/cjs/rpc/core/RpcPendingQueue.js.map +1 -1
  57. package/lib/cjs/rpc/core/RpcProtocol.js.map +1 -1
  58. package/lib/cjs/rpc/core/RpcPush.d.ts.map +1 -1
  59. package/lib/cjs/rpc/core/RpcPush.js.map +1 -1
  60. package/lib/cjs/rpc/core/RpcRegistry.d.ts.map +1 -1
  61. package/lib/cjs/rpc/core/RpcRegistry.js +0 -2
  62. package/lib/cjs/rpc/core/RpcRegistry.js.map +1 -1
  63. package/lib/cjs/rpc/core/RpcRequest.d.ts.map +1 -1
  64. package/lib/cjs/rpc/core/RpcRequest.js +1 -2
  65. package/lib/cjs/rpc/core/RpcRequest.js.map +1 -1
  66. package/lib/cjs/rpc/core/RpcRequestContext.d.ts.map +1 -1
  67. package/lib/cjs/rpc/core/RpcRequestContext.js.map +1 -1
  68. package/lib/cjs/rpc/core/RpcRoutingToken.d.ts.map +1 -1
  69. package/lib/cjs/rpc/core/RpcRoutingToken.js +0 -1
  70. package/lib/cjs/rpc/core/RpcRoutingToken.js.map +1 -1
  71. package/lib/cjs/rpc/core/RpcSessionInvocation.js +1 -1
  72. package/lib/cjs/rpc/core/RpcSessionInvocation.js.map +1 -1
  73. package/lib/cjs/rpc/web/BentleyCloudRpcManager.js.map +1 -1
  74. package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.d.ts.map +1 -1
  75. package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js +0 -1
  76. package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
  77. package/lib/cjs/rpc/web/OpenAPI.js.map +1 -1
  78. package/lib/cjs/rpc/web/RpcMultipart.js.map +1 -1
  79. package/lib/cjs/rpc/web/WebAppRpcLogging.js +1 -1
  80. package/lib/cjs/rpc/web/WebAppRpcLogging.js.map +1 -1
  81. package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
  82. package/lib/cjs/rpc/web/WebAppRpcRequest.js +1 -1
  83. package/lib/cjs/rpc/web/WebAppRpcRequest.js.map +1 -1
  84. package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
  85. package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js +0 -1
  86. package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
  87. package/lib/cjs/tile/TileMetadata.js +1 -1
  88. package/lib/cjs/tile/TileMetadata.js.map +1 -1
  89. package/lib/esm/BackgroundMapProvider.js +1 -1
  90. package/lib/esm/BackgroundMapProvider.js.map +1 -1
  91. package/lib/esm/BackgroundMapSettings.js +2 -2
  92. package/lib/esm/BackgroundMapSettings.js.map +1 -1
  93. package/lib/esm/BriefcaseTypes.js.map +1 -1
  94. package/lib/esm/ColorDef.d.ts.map +1 -1
  95. package/lib/esm/ColorDef.js +0 -3
  96. package/lib/esm/ColorDef.js.map +1 -1
  97. package/lib/esm/ECSqlReader.js.map +1 -1
  98. package/lib/esm/ElementMesh.js +1 -1
  99. package/lib/esm/ElementMesh.js.map +1 -1
  100. package/lib/esm/IModel.js.map +1 -1
  101. package/lib/esm/MapLayerSettings.d.ts.map +1 -1
  102. package/lib/esm/MapLayerSettings.js +0 -1
  103. package/lib/esm/MapLayerSettings.js.map +1 -1
  104. package/lib/esm/RenderMaterial.js +4 -4
  105. package/lib/esm/RenderMaterial.js.map +1 -1
  106. package/lib/esm/RenderTexture.js.map +1 -1
  107. package/lib/esm/RpcInterface.js +1 -1
  108. package/lib/esm/RpcInterface.js.map +1 -1
  109. package/lib/esm/RpcManager.d.ts.map +1 -1
  110. package/lib/esm/RpcManager.js.map +1 -1
  111. package/lib/esm/SubCategoryAppearance.js.map +1 -1
  112. package/lib/esm/TextureMapping.js.map +1 -1
  113. package/lib/esm/Tween.d.ts.map +1 -1
  114. package/lib/esm/Tween.js +0 -1
  115. package/lib/esm/Tween.js.map +1 -1
  116. package/lib/esm/geometry/FrustumPlanes.js.map +1 -1
  117. package/lib/esm/rpc/DevToolsRpcInterface.js.map +1 -1
  118. package/lib/esm/rpc/IModelReadRpcInterface.js +12 -12
  119. package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
  120. package/lib/esm/rpc/IModelTileRpcInterface.js +1 -1
  121. package/lib/esm/rpc/IModelTileRpcInterface.js.map +1 -1
  122. package/lib/esm/rpc/SnapshotIModelRpcInterface.js.map +1 -1
  123. package/lib/esm/rpc/TestRpcManager.d.ts.map +1 -1
  124. package/lib/esm/rpc/TestRpcManager.js +0 -1
  125. package/lib/esm/rpc/TestRpcManager.js.map +1 -1
  126. package/lib/esm/rpc/WipRpcInterface.js +1 -1
  127. package/lib/esm/rpc/WipRpcInterface.js.map +1 -1
  128. package/lib/esm/rpc/core/RpcConfiguration.d.ts.map +1 -1
  129. package/lib/esm/rpc/core/RpcConfiguration.js +1 -1
  130. package/lib/esm/rpc/core/RpcConfiguration.js.map +1 -1
  131. package/lib/esm/rpc/core/RpcConstants.js +1 -1
  132. package/lib/esm/rpc/core/RpcConstants.js.map +1 -1
  133. package/lib/esm/rpc/core/RpcControl.d.ts.map +1 -1
  134. package/lib/esm/rpc/core/RpcControl.js +0 -1
  135. package/lib/esm/rpc/core/RpcControl.js.map +1 -1
  136. package/lib/esm/rpc/core/RpcInvocation.js +1 -1
  137. package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
  138. package/lib/esm/rpc/core/RpcMarshaling.js +1 -1
  139. package/lib/esm/rpc/core/RpcMarshaling.js.map +1 -1
  140. package/lib/esm/rpc/core/RpcOperation.d.ts.map +1 -1
  141. package/lib/esm/rpc/core/RpcOperation.js +0 -1
  142. package/lib/esm/rpc/core/RpcOperation.js.map +1 -1
  143. package/lib/esm/rpc/core/RpcPendingQueue.js +1 -1
  144. package/lib/esm/rpc/core/RpcPendingQueue.js.map +1 -1
  145. package/lib/esm/rpc/core/RpcProtocol.js.map +1 -1
  146. package/lib/esm/rpc/core/RpcPush.d.ts.map +1 -1
  147. package/lib/esm/rpc/core/RpcPush.js.map +1 -1
  148. package/lib/esm/rpc/core/RpcRegistry.d.ts.map +1 -1
  149. package/lib/esm/rpc/core/RpcRegistry.js +0 -2
  150. package/lib/esm/rpc/core/RpcRegistry.js.map +1 -1
  151. package/lib/esm/rpc/core/RpcRequest.d.ts.map +1 -1
  152. package/lib/esm/rpc/core/RpcRequest.js +1 -2
  153. package/lib/esm/rpc/core/RpcRequest.js.map +1 -1
  154. package/lib/esm/rpc/core/RpcRequestContext.d.ts.map +1 -1
  155. package/lib/esm/rpc/core/RpcRequestContext.js.map +1 -1
  156. package/lib/esm/rpc/core/RpcRoutingToken.d.ts.map +1 -1
  157. package/lib/esm/rpc/core/RpcRoutingToken.js +0 -1
  158. package/lib/esm/rpc/core/RpcRoutingToken.js.map +1 -1
  159. package/lib/esm/rpc/core/RpcSessionInvocation.js +1 -1
  160. package/lib/esm/rpc/core/RpcSessionInvocation.js.map +1 -1
  161. package/lib/esm/rpc/web/BentleyCloudRpcManager.js.map +1 -1
  162. package/lib/esm/rpc/web/BentleyCloudRpcProtocol.d.ts.map +1 -1
  163. package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js +0 -1
  164. package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
  165. package/lib/esm/rpc/web/OpenAPI.js.map +1 -1
  166. package/lib/esm/rpc/web/RpcMultipart.js.map +1 -1
  167. package/lib/esm/rpc/web/WebAppRpcLogging.js +1 -1
  168. package/lib/esm/rpc/web/WebAppRpcLogging.js.map +1 -1
  169. package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
  170. package/lib/esm/rpc/web/WebAppRpcRequest.js +1 -1
  171. package/lib/esm/rpc/web/WebAppRpcRequest.js.map +1 -1
  172. package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
  173. package/lib/esm/rpc/web/multipart/RpcMultipartParser.js +0 -1
  174. package/lib/esm/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
  175. package/lib/esm/tile/TileMetadata.js +1 -1
  176. package/lib/esm/tile/TileMetadata.js.map +1 -1
  177. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"RpcRequestContext.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequestContext.ts"],"names":[],"mappings":"","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\nimport { SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** Interface to enable passing application-specific context with each RPC request.\r\n * @internal\r\n */\r\nexport interface RpcRequestContext {\r\n /** Used to get the id of the request at the frontend */\r\n getId: (request: RpcRequest) => string;\r\n\r\n /** Used at frontend to serialize client specified context */\r\n serialize: (request: RpcRequest) => Promise<SerializedRpcActivity>;\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcRequestContext.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequestContext.ts"],"names":[],"mappings":"","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\nimport { SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/** Interface to enable passing application-specific context with each RPC request.\r\n * @internal\r\n */\r\nexport interface RpcRequestContext {\r\n /** Used to get the id of the request at the frontend */\r\n getId: (request: RpcRequest) => string;\r\n\r\n /** Used at frontend to serialize client specified context */\r\n serialize: (request: RpcRequest) => Promise<SerializedRpcActivity>;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcRoutingToken.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRoutingToken.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,YAAY;AACZ,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAM;WAEZ,QAAQ,CAAC,UAAU,SAAK,GAAG,eAAe;IAIxD,gBAAuB,OAAO,kBAAuC;IAErE,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC,OAAO;CAIR"}
1
+ {"version":3,"file":"RpcRoutingToken.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRoutingToken.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,YAAY;AACZ,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAM;WAEZ,QAAQ,CAAC,UAAU,SAAK,GAAG,eAAe;IAIxD,gBAAuB,OAAO,kBAAuC;IAErE,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC,OAAO;CAIR"}
@@ -8,7 +8,6 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.RpcRoutingToken = void 0;
11
- /* eslint-disable deprecation/deprecation */
12
11
  /** @beta */
13
12
  class RpcRoutingToken {
14
13
  static generate(debugLabel = "") {
@@ -1 +1 @@
1
- {"version":3,"file":"RpcRoutingToken.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRoutingToken.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4CAA4C;AAE5C,YAAY;AACZ,MAAa,eAAe;IAGnB,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,EAAE;QACpC,OAAO,IAAI,eAAe,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC;IAOD,YAAoB,EAAU,EAAE,UAAkB;QAChD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;;AAfH,0CAgBC;AAfgB,qBAAK,GAAG,CAAC,CAAC,CAAC;AAMH,uBAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,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\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @beta */\r\nexport class RpcRoutingToken {\r\n private static _next = -1;\r\n\r\n public static generate(debugLabel = \"\"): RpcRoutingToken {\r\n return new RpcRoutingToken(++this._next, debugLabel);\r\n }\r\n\r\n public static readonly default = RpcRoutingToken.generate(\"default\");\r\n\r\n public readonly id: number;\r\n public readonly debugLabel: string;\r\n\r\n private constructor(id: number, debugLabel: string) {\r\n this.id = id;\r\n this.debugLabel = debugLabel;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcRoutingToken.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRoutingToken.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,YAAY;AACZ,MAAa,eAAe;IAGnB,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,EAAE;QACpC,OAAO,IAAI,eAAe,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC;IAOD,YAAoB,EAAU,EAAE,UAAkB;QAChD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;;AAfH,0CAgBC;AAfgB,qBAAK,GAAG,CAAC,CAAC,CAAC;AAMH,uBAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,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\n/** @beta */\r\nexport class RpcRoutingToken {\r\n private static _next = -1;\r\n\r\n public static generate(debugLabel = \"\"): RpcRoutingToken {\r\n return new RpcRoutingToken(++this._next, debugLabel);\r\n }\r\n\r\n public static readonly default = RpcRoutingToken.generate(\"default\");\r\n\r\n public readonly id: number;\r\n public readonly debugLabel: string;\r\n\r\n private constructor(id: number, debugLabel: string) {\r\n this.id = id;\r\n this.debugLabel = debugLabel;\r\n }\r\n}\r\n"]}
@@ -14,7 +14,7 @@ const RpcInvocation_1 = require("./RpcInvocation");
14
14
  const RpcMarshaling_1 = require("./RpcMarshaling");
15
15
  const RpcProtocol_1 = require("./RpcProtocol");
16
16
  const RpcRequest_1 = require("./RpcRequest");
17
- /* eslint-disable deprecation/deprecation */
17
+ /* eslint-disable @typescript-eslint/no-deprecated */
18
18
  class SessionConfiguration extends RpcConfiguration_1.RpcConfiguration {
19
19
  constructor() {
20
20
  super(...arguments);
@@ -1 +1 @@
1
- {"version":3,"file":"RpcSessionInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcSessionInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,yDAAsD;AACtD,iDAA2E;AAC3E,mDAAgD;AAChD,mDAAqD;AACrD,+CAAkE;AAClE,6CAA0C;AAE1C,4CAA4C;AAE5C,MAAM,oBAAqB,SAAQ,mCAAgB;IAAnD;;QACS,eAAU,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC;IAE/B,CAAC;IADC,IAAW,QAAQ,KAAK,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,eAAgB,SAAQ,yBAAW;IAIvC;QAAgB,KAAK,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;QAF3C,gBAAW,GAAG,uBAAU,CAAC;QAChB,2BAAsB,GAAG,IAAI,CAAC;IACK,CAAC;;AAHtC,wBAAQ,GAAG,IAAI,eAAe,EAAE,AAAxB,CAAyB;AAMjD,gBAAgB;AAChB,MAAa,oBAAqB,SAAQ,6BAAa;IAC9C,MAAM,CAAC,MAAM,CAAC,OAA8B;QACjD,MAAM,iBAAiB,GAAyB;YAC9C,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;YACtB,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa;YAC5C,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,kBAAkB;YACtD,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS;YACpC,aAAa,EAAE,EAAE;YACjB,SAAS,EAAE;gBACT,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC,aAAa;gBACrD,gBAAgB,EAAE,OAAO,CAAC,UAAU,CAAC,gBAAgB;gBACrD,aAAa,EAAE,OAAO,CAAC,SAAS;aACjC;YACD,MAAM,EAAE,OAAO,CAAC,SAAS;YACzB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,kCAAkB,CAAC,MAAM,EAAE;YACvC,kBAAkB,EAAE,OAAO,CAAC,UAAU;YACtC,OAAO,EAAE,sCAAuB,CAAC,IAAI;YACrC,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;SAC/D,CAAC;QAEF,OAAO,IAAI,oBAAoB,CAAC,eAAe,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAC/E,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,MAAM,KAAK,+BAAgB,CAAC,QAAQ,CAAC;IACnD,CAAC;CACF;AA3BD,oDA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { InterceptedRpcRequest } from \"../../ipc/IpcSession\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcProtocol, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nclass SessionConfiguration extends RpcConfiguration {\r\n public interfaces = () => [];\r\n public get protocol() { return SessionProtocol.instance; }\r\n}\r\n\r\nclass SessionProtocol extends RpcProtocol {\r\n public static instance = new SessionProtocol();\r\n public requestType = RpcRequest;\r\n public override supportsStatusCategory = true;\r\n constructor() { super(new SessionConfiguration()); }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcSessionInvocation extends RpcInvocation {\r\n public static create(request: InterceptedRpcRequest): RpcSessionInvocation {\r\n const serializedRequest: SerializedRpcRequest = {\r\n id: request.context.id,\r\n applicationId: request.context.applicationId,\r\n applicationVersion: request.context.applicationVersion,\r\n sessionId: request.context.sessionId,\r\n authorization: \"\",\r\n operation: {\r\n interfaceDefinition: request.definition.interfaceName,\r\n interfaceVersion: request.definition.interfaceVersion,\r\n operationName: request.operation,\r\n },\r\n method: request.operation,\r\n path: \"\",\r\n parameters: RpcSerializedValue.create(),\r\n parametersOverride: request.parameters,\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: parseInt(request.context.protocolVersion, 10),\r\n };\r\n\r\n return new RpcSessionInvocation(SessionProtocol.instance, serializedRequest);\r\n }\r\n\r\n public get rejected() {\r\n return this.status === RpcRequestStatus.Rejected;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcSessionInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcSessionInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,yDAAsD;AACtD,iDAA2E;AAC3E,mDAAgD;AAChD,mDAAqD;AACrD,+CAAkE;AAClE,6CAA0C;AAE1C,qDAAqD;AAErD,MAAM,oBAAqB,SAAQ,mCAAgB;IAAnD;;QACS,eAAU,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC;IAE/B,CAA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,CAAC,QAAQ,CAAC;IACnD,CAAC;CACF;AA3BD,oDA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { InterceptedRpcRequest } from \"../../ipc/IpcSession\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcProtocol, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\nclass SessionConfiguration extends RpcConfiguration {\r\n public interfaces = () => [];\r\n public get protocol() { return SessionProtocol.instance; }\r\n}\r\n\r\nclass SessionProtocol extends RpcProtocol {\r\n public static instance = new SessionProtocol();\r\n public requestType = RpcRequest;\r\n public override supportsStatusCategory = true;\r\n constructor() { super(new SessionConfiguration()); }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcSessionInvocation extends RpcInvocation {\r\n public static create(request: InterceptedRpcRequest): RpcSessionInvocation {\r\n const serializedRequest: SerializedRpcRequest = {\r\n id: request.context.id,\r\n applicationId: request.context.applicationId,\r\n applicationVersion: request.context.applicationVersion,\r\n sessionId: request.context.sessionId,\r\n authorization: \"\",\r\n operation: {\r\n interfaceDefinition: request.definition.interfaceName,\r\n interfaceVersion: request.definition.interfaceVersion,\r\n operationName: request.operation,\r\n },\r\n method: request.operation,\r\n path: \"\",\r\n parameters: RpcSerializedValue.create(),\r\n parametersOverride: request.parameters,\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: parseInt(request.context.protocolVersion, 10),\r\n };\r\n\r\n return new RpcSessionInvocation(SessionProtocol.instance, serializedRequest);\r\n }\r\n\r\n public get rejected() {\r\n return this.status === RpcRequestStatus.Rejected;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BentleyCloudRpcManager.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,iDAA8C;AAC9C,+DAA4D;AAC5D,uDAAuD;AACvD,mDAAwE;AACxE,uEAAoE;AAEpE,6DAA0D;AAoB1D;;GAEG;AACH,MAAsB,4BAA6B,SAAQ,mCAAgB;;AAA3E,oEAUC;AATC,2GAA2G;AACpF,0CAAa,GAAG;IACrC,WAAW,EAAE,GAAG;IAChB,YAAY,EAAE,oBAAoB;IAClC,YAAY,EAAE,qLAAqL;CACpM,CAAC;AAMJ;;GAEG;AACH,MAAa,sBAAuB,SAAQ,uBAAU;IACpD,mFAAmF;IAC5E,MAAM,CAAC,gBAAgB,CAAC,MAA6B,EAAE,UAAoC,EAAE,UAA2B,iCAAe,CAAC,OAAO;QACpJ,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACnF,CAAC;IAED,kFAAkF;IAC3E,MAAM,CAAC,cAAc,CAAC,MAA6B,EAAE,UAAoC;QAC9F,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC1E,CAAC;IAEO,MAAM,CAAC,qBAAqB,CAAC,MAA6B,EAAE,UAAoC,EAAE,UAA2B,iCAAe,CAAC,OAAO;QAC1J,MAAM,QAAQ,GAAG,KAAM,SAAQ,CAAC,MAAM,CAAC,QAAQ,IAAI,iDAAuB,CAAC;YAA1D;;gBACC,eAAU,GAAG,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC;gBAC7C,SAAI,GAAG,MAAM,CAAC,IAAI,CAAC;YAC5B,CAAC;SAAA,CAAC;QAEF,MAAM,MAAM,GAAG,KAAM,SAAQ,4BAA4B;YAA1C;;gBACN,eAAU,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC;gBAC9B,aAAQ,GAA4B,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC9C,YAAO,GAAG,OAAO,CAAC;YACpC,CAAC;SAAA,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,mCAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,QAAQ,GAAG,mCAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEjD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,QAAQ,CAAC,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACnD,CAAC;QAED,mCAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEhD,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;YAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,sBAAsB,CAAC;YAE/C,uBAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;gBAC9C,IAAI,IAAI,KAAK,8BAAe,CAAC,qBAAqB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAC;oBAC7F,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA/CD,wDA+CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcRequestEvent } from \"../core/RpcConstants\";\r\nimport { RpcRequest, RpcRequestEventHandler } from \"../core/RpcRequest\";\r\nimport { BentleyCloudRpcProtocol } from \"./BentleyCloudRpcProtocol\";\r\nimport { OpenAPIInfo } from \"./OpenAPI\";\r\nimport { RpcRoutingToken } from \"../core/RpcRoutingToken\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** Initialization parameters for BentleyCloudRpcConfiguration.\r\n * @beta\r\n */\r\nexport interface BentleyCloudRpcParams {\r\n /** Identifies the remote server that implements a set of RpcInterfaces. Note that the ID of the remote server is not a URI or hostname. It is a string that matches a key in the orchestrator's app registry. */\r\n info: OpenAPIInfo;\r\n /** @internal The protocol for Bentley cloud RPC interface deployments */\r\n protocol?: typeof BentleyCloudRpcProtocol;\r\n /** The URI of the orchestrator that will route requests to the remote RpcInterface server. If not supplied, this default to the origin of the Web page. This is required only when calling initializeClient and only if the server is not the origin of the Web page. */\r\n uriPrefix?: string;\r\n /** @internal Handler for RPC request events. */\r\n pendingRequestListener?: RpcRequestEventHandler;\r\n /** An optional prefix for RPC operation URI paths. */\r\n pathPrefix?: string;\r\n}\r\n\r\n/** Operating parameters for Bentley cloud RPC interface deployments.\r\n * @beta\r\n */\r\nexport abstract class BentleyCloudRpcConfiguration extends RpcConfiguration {\r\n /** Access-Control header values for backend servers that serve frontends using BentleyCloudRpcProtocol. */\r\n public static readonly accessControl = {\r\n allowOrigin: \"*\",\r\n allowMethods: \"POST, GET, OPTIONS\",\r\n allowHeaders: \"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, X-Correlation-Id, X-Session-Id, X-Application-Id, X-Application-Version, X-User-Id, X-Protocol-Version\",\r\n };\r\n\r\n /** @internal The protocol of the configuration. */\r\n public abstract override readonly protocol: BentleyCloudRpcProtocol;\r\n}\r\n\r\n/** Coordinates usage of RPC interfaces for Bentley cloud deployments.\r\n * @beta\r\n */\r\nexport class BentleyCloudRpcManager extends RpcManager {\r\n /** @beta Initializes BentleyCloudRpcManager for the frontend of an application. */\r\n public static initializeClient(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[], routing: RpcRoutingToken = RpcRoutingToken.default): BentleyCloudRpcConfiguration {\r\n return BentleyCloudRpcManager.performInitialization(params, interfaces, routing);\r\n }\r\n\r\n /** @beta Initializes BentleyCloudRpcManager for the backend of an application. */\r\n public static initializeImpl(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[]): BentleyCloudRpcConfiguration {\r\n return BentleyCloudRpcManager.performInitialization(params, interfaces);\r\n }\r\n\r\n private static performInitialization(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[], routing: RpcRoutingToken = RpcRoutingToken.default): BentleyCloudRpcConfiguration {\r\n const protocol = class extends (params.protocol || BentleyCloudRpcProtocol) {\r\n public override pathPrefix = params.uriPrefix || \"\";\r\n public info = params.info;\r\n };\r\n\r\n const config = class extends BentleyCloudRpcConfiguration {\r\n public interfaces = () => interfaces;\r\n public protocol: BentleyCloudRpcProtocol = new protocol(this);\r\n public override routing = routing;\r\n };\r\n\r\n for (const def of interfaces) {\r\n RpcConfiguration.assignWithRouting(def, routing, config);\r\n }\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n if (params.pathPrefix) {\r\n instance.protocol.pathPrefix = params.pathPrefix;\r\n }\r\n\r\n RpcConfiguration.initializeInterfaces(instance);\r\n\r\n if (params.pendingRequestListener) {\r\n const listener = params.pendingRequestListener;\r\n\r\n RpcRequest.events.addListener((type, request) => {\r\n if (type === RpcRequestEvent.PendingUpdateReceived && request.protocol === instance.protocol) {\r\n listener(type, request);\r\n }\r\n });\r\n }\r\n\r\n return instance;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"BentleyCloudRpcManager.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcManager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CAAC;SAAA,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,mCAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,QAAQ,GAAG,mCAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEjD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,QAAQ,CAAC,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACnD,CAAC;QAED,mCAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEhD,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;YAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,sBAAsB,CAAC;YAE/C,uBAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;gBAC9C,IAAI,IAAI,KAAK,8BAAe,CAAC,qBAAqB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAC;oBAC7F,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA/CD,wDA+CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcRequestEvent } from \"../core/RpcConstants\";\r\nimport { RpcRequest, RpcRequestEventHandler } from \"../core/RpcRequest\";\r\nimport { BentleyCloudRpcProtocol } from \"./BentleyCloudRpcProtocol\";\r\nimport { OpenAPIInfo } from \"./OpenAPI\";\r\nimport { RpcRoutingToken } from \"../core/RpcRoutingToken\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\n/** Initialization parameters for BentleyCloudRpcConfiguration.\r\n * @beta\r\n */\r\nexport interface BentleyCloudRpcParams {\r\n /** Identifies the remote server that implements a set of RpcInterfaces. Note that the ID of the remote server is not a URI or hostname. It is a string that matches a key in the orchestrator's app registry. */\r\n info: OpenAPIInfo;\r\n /** @internal The protocol for Bentley cloud RPC interface deployments */\r\n protocol?: typeof BentleyCloudRpcProtocol;\r\n /** The URI of the orchestrator that will route requests to the remote RpcInterface server. If not supplied, this default to the origin of the Web page. This is required only when calling initializeClient and only if the server is not the origin of the Web page. */\r\n uriPrefix?: string;\r\n /** @internal Handler for RPC request events. */\r\n pendingRequestListener?: RpcRequestEventHandler;\r\n /** An optional prefix for RPC operation URI paths. */\r\n pathPrefix?: string;\r\n}\r\n\r\n/** Operating parameters for Bentley cloud RPC interface deployments.\r\n * @beta\r\n */\r\nexport abstract class BentleyCloudRpcConfiguration extends RpcConfiguration {\r\n /** Access-Control header values for backend servers that serve frontends using BentleyCloudRpcProtocol. */\r\n public static readonly accessControl = {\r\n allowOrigin: \"*\",\r\n allowMethods: \"POST, GET, OPTIONS\",\r\n allowHeaders: \"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, X-Correlation-Id, X-Session-Id, X-Application-Id, X-Application-Version, X-User-Id, X-Protocol-Version\",\r\n };\r\n\r\n /** @internal The protocol of the configuration. */\r\n public abstract override readonly protocol: BentleyCloudRpcProtocol;\r\n}\r\n\r\n/** Coordinates usage of RPC interfaces for Bentley cloud deployments.\r\n * @beta\r\n */\r\nexport class BentleyCloudRpcManager extends RpcManager {\r\n /** @beta Initializes BentleyCloudRpcManager for the frontend of an application. */\r\n public static initializeClient(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[], routing: RpcRoutingToken = RpcRoutingToken.default): BentleyCloudRpcConfiguration {\r\n return BentleyCloudRpcManager.performInitialization(params, interfaces, routing);\r\n }\r\n\r\n /** @beta Initializes BentleyCloudRpcManager for the backend of an application. */\r\n public static initializeImpl(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[]): BentleyCloudRpcConfiguration {\r\n return BentleyCloudRpcManager.performInitialization(params, interfaces);\r\n }\r\n\r\n private static performInitialization(params: BentleyCloudRpcParams, interfaces: RpcInterfaceDefinition[], routing: RpcRoutingToken = RpcRoutingToken.default): BentleyCloudRpcConfiguration {\r\n const protocol = class extends (params.protocol || BentleyCloudRpcProtocol) {\r\n public override pathPrefix = params.uriPrefix || \"\";\r\n public info = params.info;\r\n };\r\n\r\n const config = class extends BentleyCloudRpcConfiguration {\r\n public interfaces = () => interfaces;\r\n public protocol: BentleyCloudRpcProtocol = new protocol(this);\r\n public override routing = routing;\r\n };\r\n\r\n for (const def of interfaces) {\r\n RpcConfiguration.assignWithRouting(def, routing, config);\r\n }\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n if (params.pathPrefix) {\r\n instance.protocol.pathPrefix = params.pathPrefix;\r\n }\r\n\r\n RpcConfiguration.initializeInterfaces(instance);\r\n\r\n if (params.pendingRequestListener) {\r\n const listener = params.pendingRequestListener;\r\n\r\n RpcRequest.events.addListener((type, request) => {\r\n if (type === RpcRequestEvent.PendingUpdateReceived && request.protocol === instance.protocol) {\r\n listener(type, request);\r\n }\r\n });\r\n }\r\n\r\n return instance;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BentleyCloudRpcProtocol.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,sBAAsB,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AAC;AAM9D;;GAEG;AACH,8BAAsB,uBAAwB,SAAQ,iBAAiB;IACrD,UAAU,UAAQ;IAElC,iFAAiF;IACjE,yCAAyC,EAAE,qBAAqB,CAe9E;IAEF,mDAAmD;IACnC,yBAAyB,SAAwB;IAEjE,yEAAyE;IACzD,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB;IAoB1E,qEAAqE;IACrD,sBAAsB,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS;IA0C/F;;;OAGG;IACa,YAAY,CAAC,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,oBAAoB,GAAG,cAAc;IA6B1G;;OAEG;IACI,gCAAgC,CAAC,UAAU,EAAE,YAAY,GAAG,gBAAgB,EAAE;CAQtF"}
@@ -13,7 +13,6 @@ const IModelError_1 = require("../../IModelError");
13
13
  const RpcConfiguration_1 = require("../core/RpcConfiguration");
14
14
  const RpcOperation_1 = require("../core/RpcOperation");
15
15
  const WebAppRpcProtocol_1 = require("./WebAppRpcProtocol");
16
- /* eslint-disable deprecation/deprecation */
17
16
  var AppMode;
18
17
  (function (AppMode) {
19
18
  AppMode["MilestoneReview"] = "1";
@@ -1 +1 @@
1
- {"version":3,"file":"BentleyCloudRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AAEpD,mDAAgD;AAChD,+DAA4D;AAC5D,uDAAoD;AAIpD,2DAAwD;AAGxD,4CAA4C;AAE5C,IAAK,OAEJ;AAFD,WAAK,OAAO;IACV,gCAAqB,CAAA;AACvB,CAAC,EAFI,OAAO,KAAP,OAAO,QAEX;AAED;;GAEG;AACH,MAAsB,uBAAwB,SAAQ,qCAAiB;IAAvE;;QACkB,eAAU,GAAG,IAAI,CAAC;QAElC,iFAAiF;QACjE,8CAAyC,GAA0B;YACjF,8CAA8C;YAC9C,E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Q,EAAE,EAAE;SACjF,CAAC;IACJ,CAAC;CACF;AApID,0DAoIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { OpenAPIParameter } from \"./OpenAPI\";\r\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nenum AppMode {\r\n MilestoneReview = \"1\",\r\n}\r\n\r\n/** An http protocol for Bentley cloud RPC interface deployments.\r\n * @internal\r\n */\r\nexport abstract class BentleyCloudRpcProtocol extends WebAppRpcProtocol {\r\n public override checkToken = true;\r\n\r\n /** The name of various HTTP request headers based on client's request context */\r\n public override serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the HTTP request id header. */\r\n id: \"X-Correlation-Id\",\r\n\r\n /** The name of the HTTP application id header. */\r\n applicationId: \"X-Application-Id\",\r\n\r\n /** The name of the HTTP application version header. */\r\n applicationVersion: \"X-Application-Version\",\r\n\r\n /** The name of the HTTP session id header. */\r\n sessionId: \"X-Session-Id\",\r\n\r\n /** The name of the HTTP authorization header. */\r\n authorization: \"Authorization\",\r\n };\r\n\r\n /** The name of the RPC protocol version header. */\r\n public override protocolVersionHeaderName = \"X-Protocol-Version\";\r\n\r\n /** Returns the operation specified by an OpenAPI-compatible URI path. */\r\n public override getOperationFromPath(path: string): SerializedRpcOperation {\r\n const url = new URL(path, \"https://localhost/\");\r\n const components = url.pathname.split(\"/\").filter((x) => x); // filter out empty segments\r\n\r\n const operationComponent = components.slice(-1)[0];\r\n const encodedRequest = url.searchParams.get(\"parameters\") || \"\";\r\n\r\n // The encodedRequest should be base64 - fail now if any other characters detected.\r\n if (/[^a-zA-Z0-9=+\\/$]/.test(encodedRequest))\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Malformed URL parameters detected.`);\r\n\r\n const firstHyphen = operationComponent.indexOf(\"-\");\r\n const lastHyphen = operationComponent.lastIndexOf(\"-\");\r\n const interfaceDefinition = operationComponent.slice(0, firstHyphen);\r\n const interfaceVersion = operationComponent.slice(firstHyphen + 1, lastHyphen);\r\n const operationName = operationComponent.slice(lastHyphen + 1);\r\n\r\n return { interfaceDefinition, operationName, interfaceVersion, encodedRequest };\r\n }\r\n\r\n /** Supplies the OpenAPI-compatible URI path for an RPC operation. */\r\n public override supplyPathForOperation(operation: RpcOperation, request: RpcRequest | undefined) {\r\n const prefix = this.pathPrefix;\r\n const appTitle = this.info.title;\r\n const appVersion = this.info.version;\r\n const operationId = `${operation.interfaceDefinition.interfaceName}-${operation.interfaceVersion}-${operation.operationName}`;\r\n\r\n let appMode: string = \"\";\r\n let iTwinId: string = \"\";\r\n let iModelId: string = \"\";\r\n let routeChangesetId: string | undefined;\r\n /* Note: The changesetId field is omitted in the route in the case of ReadWrite connections since the connection is generally expected to be at the\r\n * latest version and not some specific changeset. Also, for the first version (before any changesets), the changesetId in the route is arbitrarily\r\n * set to \"0\" instead of an empty string, since the latter is more un-intuitive for a route. However, in all other use cases, including the changesetId\r\n * held by the IModelRpcProps itself, the changesetId of \"\" (i.e., empty string) signifies the first version - this is more intuitive and retains\r\n * compatibility with the majority of use cases. */\r\n\r\n if (request === undefined) {\r\n appMode = \"{modeId}\";\r\n iTwinId = \"{iTwinId}\";\r\n iModelId = \"{iModelId}\";\r\n routeChangesetId = \"{changeSetId}\";\r\n } else {\r\n let token = operation.policy.token(request) || RpcOperation.fallbackToken;\r\n\r\n if (!token || !token.iModelId) {\r\n if (RpcConfiguration.disableRoutingValidation) {\r\n token = { key: \"\" };\r\n } else {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid iModelToken for RPC operation request\");\r\n }\r\n }\r\n\r\n iTwinId = encodeURIComponent(token.iTwinId || \"\");\r\n iModelId = encodeURIComponent(token.iModelId!);\r\n\r\n routeChangesetId = token.changeset?.id || \"0\";\r\n appMode = AppMode.MilestoneReview;\r\n }\r\n\r\n return `${prefix}/${appTitle}/${appVersion}/mode/${appMode}/context/${iTwinId}/imodel/${iModelId}${!!routeChangesetId ? `/changeset/${routeChangesetId}` : \"\"}/${operationId}`;\r\n }\r\n\r\n /**\r\n * Inflates the IModelRpcProps from the URL path for each request on the backend.\r\n * @note This function updates the IModelRpcProps value supplied in the request body.\r\n */\r\n public override inflateToken(tokenFromBody: IModelRpcProps, request: SerializedRpcRequest): IModelRpcProps {\r\n const urlPathComponents = request.path.split(\"/\");\r\n\r\n let iModelId = tokenFromBody.iModelId;\r\n let iTwinId = tokenFromBody.iTwinId;\r\n const changeset = { id: tokenFromBody.changeset?.id ?? \"0\", index: tokenFromBody.changeset?.index };\r\n\r\n for (let i = 0; i <= urlPathComponents.length; ++i) {\r\n const key = urlPathComponents[i];\r\n const value = urlPathComponents[i + 1];\r\n if (key === \"mode\") {\r\n ++i;\r\n } else if (key === \"context\") {\r\n iTwinId = value;\r\n ++i;\r\n } else if (key === \"imodel\") {\r\n iModelId = value;\r\n ++i;\r\n } else if (key === \"changeset\") {\r\n changeset.id = (value === \"0\") ? \"\" : value;\r\n ++i;\r\n }\r\n }\r\n\r\n // Overwrite the key if it includes a : because its most likely a guid. We know what it should be based off of the url.\r\n // Leave it alone if its a non guid key.\r\n return { key: tokenFromBody.key === undefined || tokenFromBody.key.includes(\":\") ? `${iModelId}:${changeset.id}` : tokenFromBody.key, iTwinId, iModelId, changeset };\r\n }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[] {\r\n return [\r\n { name: \"modeId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"iTwinId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"iModelId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"changeSetId\", in: \"path\", required: false, schema: { type: \"string\" } },\r\n ];\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"BentleyCloudRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AAEpD,mDAAgD;AAChD,+DAA4D;AAC5D,uDAAoD;AAIpD,2DAAwD;AAGxD,IAAK,OAEJ;AAFD,WAAK,OAAO;IACV,gCAAqB,CAAA;AACvB,CAAC,EAFI,OAAO,KAAP,OAAO,QAEX;AAED;;GAEG;AACH,MAAsB,uBAAwB,SAAQ,qCAAiB;IAAvE;;QACkB,eAAU,GAAG,IAAI,CAAC;QAElC,iFAAiF;QACjE,8CAAyC,GAA0B;YACjF,8CAA8C;YAC9C,EAAE,EAAE,kBAAkB;YAEtB,kDAAkD;YAClD,aAAa,EAAE,kBAAkB;YAEjC,uDAAuD;YACvD,kBAAkB,EAAE,uBAAuB;YAE3C,8CAA8C;YAC9C,SAAS,EAAE,cAAc;YAEzB,iDAAiD;YACjD,aAAa,EAAE,eAAe;SAC/B,CAAC;QAEF,mDAAmD;QACnC,8BAAyB,GAAG,oBAAoB,CAAC;IA8GnE,CAAC;IA5GC,yEAAyE;IACzD,oBAAoB,CAAC,IAAY;QAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ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AG,KAAK,SAAS,IAAI,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACvK,CAAC;IAED;;OAEG;IACI,gCAAgC,CAAC,UAAwB;QAC9D,OAAO;YACL,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC1E,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC3E,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC5E,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;SACjF,CAAC;IACJ,CAAC;CACF;AApID,0DAoIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { OpenAPIParameter } from \"./OpenAPI\";\r\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\r\n\r\nenum AppMode {\r\n MilestoneReview = \"1\",\r\n}\r\n\r\n/** An http protocol for Bentley cloud RPC interface deployments.\r\n * @internal\r\n */\r\nexport abstract class BentleyCloudRpcProtocol extends WebAppRpcProtocol {\r\n public override checkToken = true;\r\n\r\n /** The name of various HTTP request headers based on client's request context */\r\n public override serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the HTTP request id header. */\r\n id: \"X-Correlation-Id\",\r\n\r\n /** The name of the HTTP application id header. */\r\n applicationId: \"X-Application-Id\",\r\n\r\n /** The name of the HTTP application version header. */\r\n applicationVersion: \"X-Application-Version\",\r\n\r\n /** The name of the HTTP session id header. */\r\n sessionId: \"X-Session-Id\",\r\n\r\n /** The name of the HTTP authorization header. */\r\n authorization: \"Authorization\",\r\n };\r\n\r\n /** The name of the RPC protocol version header. */\r\n public override protocolVersionHeaderName = \"X-Protocol-Version\";\r\n\r\n /** Returns the operation specified by an OpenAPI-compatible URI path. */\r\n public override getOperationFromPath(path: string): SerializedRpcOperation {\r\n const url = new URL(path, \"https://localhost/\");\r\n const components = url.pathname.split(\"/\").filter((x) => x); // filter out empty segments\r\n\r\n const operationComponent = components.slice(-1)[0];\r\n const encodedRequest = url.searchParams.get(\"parameters\") || \"\";\r\n\r\n // The encodedRequest should be base64 - fail now if any other characters detected.\r\n if (/[^a-zA-Z0-9=+\\/$]/.test(encodedRequest))\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Malformed URL parameters detected.`);\r\n\r\n const firstHyphen = operationComponent.indexOf(\"-\");\r\n const lastHyphen = operationComponent.lastIndexOf(\"-\");\r\n const interfaceDefinition = operationComponent.slice(0, firstHyphen);\r\n const interfaceVersion = operationComponent.slice(firstHyphen + 1, lastHyphen);\r\n const operationName = operationComponent.slice(lastHyphen + 1);\r\n\r\n return { interfaceDefinition, operationName, interfaceVersion, encodedRequest };\r\n }\r\n\r\n /** Supplies the OpenAPI-compatible URI path for an RPC operation. */\r\n public override supplyPathForOperation(operation: RpcOperation, request: RpcRequest | undefined) {\r\n const prefix = this.pathPrefix;\r\n const appTitle = this.info.title;\r\n const appVersion = this.info.version;\r\n const operationId = `${operation.interfaceDefinition.interfaceName}-${operation.interfaceVersion}-${operation.operationName}`;\r\n\r\n let appMode: string = \"\";\r\n let iTwinId: string = \"\";\r\n let iModelId: string = \"\";\r\n let routeChangesetId: string | undefined;\r\n /* Note: The changesetId field is omitted in the route in the case of ReadWrite connections since the connection is generally expected to be at the\r\n * latest version and not some specific changeset. Also, for the first version (before any changesets), the changesetId in the route is arbitrarily\r\n * set to \"0\" instead of an empty string, since the latter is more un-intuitive for a route. However, in all other use cases, including the changesetId\r\n * held by the IModelRpcProps itself, the changesetId of \"\" (i.e., empty string) signifies the first version - this is more intuitive and retains\r\n * compatibility with the majority of use cases. */\r\n\r\n if (request === undefined) {\r\n appMode = \"{modeId}\";\r\n iTwinId = \"{iTwinId}\";\r\n iModelId = \"{iModelId}\";\r\n routeChangesetId = \"{changeSetId}\";\r\n } else {\r\n let token = operation.policy.token(request) || RpcOperation.fallbackToken;\r\n\r\n if (!token || !token.iModelId) {\r\n if (RpcConfiguration.disableRoutingValidation) {\r\n token = { key: \"\" };\r\n } else {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid iModelToken for RPC operation request\");\r\n }\r\n }\r\n\r\n iTwinId = encodeURIComponent(token.iTwinId || \"\");\r\n iModelId = encodeURIComponent(token.iModelId!);\r\n\r\n routeChangesetId = token.changeset?.id || \"0\";\r\n appMode = AppMode.MilestoneReview;\r\n }\r\n\r\n return `${prefix}/${appTitle}/${appVersion}/mode/${appMode}/context/${iTwinId}/imodel/${iModelId}${!!routeChangesetId ? `/changeset/${routeChangesetId}` : \"\"}/${operationId}`;\r\n }\r\n\r\n /**\r\n * Inflates the IModelRpcProps from the URL path for each request on the backend.\r\n * @note This function updates the IModelRpcProps value supplied in the request body.\r\n */\r\n public override inflateToken(tokenFromBody: IModelRpcProps, request: SerializedRpcRequest): IModelRpcProps {\r\n const urlPathComponents = request.path.split(\"/\");\r\n\r\n let iModelId = tokenFromBody.iModelId;\r\n let iTwinId = tokenFromBody.iTwinId;\r\n const changeset = { id: tokenFromBody.changeset?.id ?? \"0\", index: tokenFromBody.changeset?.index };\r\n\r\n for (let i = 0; i <= urlPathComponents.length; ++i) {\r\n const key = urlPathComponents[i];\r\n const value = urlPathComponents[i + 1];\r\n if (key === \"mode\") {\r\n ++i;\r\n } else if (key === \"context\") {\r\n iTwinId = value;\r\n ++i;\r\n } else if (key === \"imodel\") {\r\n iModelId = value;\r\n ++i;\r\n } else if (key === \"changeset\") {\r\n changeset.id = (value === \"0\") ? \"\" : value;\r\n ++i;\r\n }\r\n }\r\n\r\n // Overwrite the key if it includes a : because its most likely a guid. We know what it should be based off of the url.\r\n // Leave it alone if its a non guid key.\r\n return { key: tokenFromBody.key === undefined || tokenFromBody.key.includes(\":\") ? `${iModelId}:${changeset.id}` : tokenFromBody.key, iTwinId, iModelId, changeset };\r\n }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[] {\r\n return [\r\n { name: \"modeId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"iTwinId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"iModelId\", in: \"path\", required: true, schema: { type: \"string\" } },\r\n { name: \"changeSetId\", in: \"path\", required: false, schema: { type: \"string\" } },\r\n ];\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"OpenAPI.js","sourceRoot":"","sources":["../../../../src/rpc/web/OpenAPI.ts"],"names":[],"mappings":";AAAA;;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AG;YACjB,WAAW,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE;YACxD,SAAS,EAAE;gBACT,GAAG,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE;gBACzD,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE;aAC5D;SACF,CAAC;QAEF,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC;QAC7E,IAAI,UAAU,CAAC,MAAM;YACnB,WAAW,CAAC,UAAU,GAAG,UAAU,CAAC;QAEtC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAzDD,sDAyDC","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 { RpcOperation } from \"../core/RpcOperation\";\r\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An OpenAPI 3.0 root document object.\r\n * @internal\r\n */\r\nexport interface OpenAPIDocument {\r\n openapi: \"3.0.0\";\r\n info: OpenAPIInfo;\r\n paths: OpenAPIPaths;\r\n}\r\n\r\n/** An OpenAPI 3.0 info object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\r\n */\r\nexport interface OpenAPIInfo {\r\n title: string;\r\n version: string;\r\n}\r\n\r\n/** An OpenAPI 3.0 paths object.\r\n * @internal\r\n */\r\nexport interface OpenAPIPaths {\r\n [index: string]: OpenAPIPathItem;\r\n}\r\n\r\n/** An OpenAPI 3.0 path item object.\r\n * @internal\r\n */\r\nexport interface OpenAPIPathItem {\r\n summary?: string;\r\n get?: OpenAPIOperation;\r\n put?: OpenAPIOperation;\r\n post?: OpenAPIOperation;\r\n delete?: OpenAPIOperation;\r\n options?: OpenAPIOperation;\r\n head?: OpenAPIOperation;\r\n patch?: OpenAPIOperation;\r\n trace?: OpenAPIOperation;\r\n parameters?: OpenAPIParameter[];\r\n}\r\n\r\n/** An OpenAPI 3.0 operation object.\r\n * @internal\r\n */\r\nexport interface OpenAPIOperation {\r\n summary?: string;\r\n operationId?: string;\r\n parameters?: OpenAPIParameter[];\r\n requestBody?: OpenAPIRequestBody;\r\n responses: OpenAPIResponses;\r\n}\r\n\r\n/** An OpenAPI 3.0 content map.\r\n * @internal\r\n */\r\nexport interface OpenAPIContentMap {\r\n [index: string]: OpenAPIMediaType;\r\n}\r\n\r\n/** An OpenAPI 3.0 parameter object.\r\n * @internal\r\n */\r\nexport interface OpenAPIParameter {\r\n name: string;\r\n in: \"query\" | \"header\" | \"path\" | \"cookie\";\r\n description?: string;\r\n required?: boolean;\r\n allowEmptyValue?: boolean;\r\n style?: \"matrix\" | \"label\" | \"form\" | \"simple\" | \"spaceDelimited\" | \"pipeDelimited\" | \"deepObject\";\r\n explode?: boolean;\r\n allowReserved?: boolean;\r\n schema?: OpenAPISchema;\r\n content?: OpenAPIContentMap;\r\n}\r\n\r\n/** An OpenAPI 3.0 media type object.\r\n * @internal\r\n */\r\nexport interface OpenAPIMediaType {\r\n schema?: OpenAPISchema;\r\n}\r\n\r\n/** An OpenAPI 3.0 schema object.\r\n * @internal\r\n */\r\nexport interface OpenAPISchema {\r\n type?: \"boolean\" | \"object\" | \"array\" | \"number\" | \"string\";\r\n nullable?: boolean;\r\n description?: string;\r\n}\r\n\r\n/** An OpenAPI 3.0 encoding object.\r\n * @internal\r\n */\r\nexport interface OpenAPIEncoding {\r\n contentType?: string;\r\n style?: string;\r\n explode?: boolean;\r\n allowReserved?: boolean;\r\n}\r\n\r\n/** An OpenAPI 3.0 parameter object.\r\n * @internal\r\n */\r\nexport interface OpenAPIRequestBody {\r\n description?: string;\r\n content: OpenAPIContentMap;\r\n required?: boolean;\r\n}\r\n\r\n/** An OpenAPI 3.0 responses object.\r\n * @internal\r\n */\r\nexport interface OpenAPIResponses {\r\n default?: OpenAPIResponse;\r\n \"200\"?: OpenAPIResponse;\r\n \"301\"?: OpenAPIResponse;\r\n \"302\"?: OpenAPIResponse;\r\n \"400\"?: OpenAPIResponse;\r\n \"404\"?: OpenAPIResponse;\r\n \"500\"?: OpenAPIResponse;\r\n}\r\n\r\n/** An OpenAPI 3.0 response object.\r\n * @internal\r\n */\r\nexport interface OpenAPIResponse {\r\n description: string;\r\n content?: { [index: string]: OpenAPIMediaType };\r\n}\r\n\r\n/** An OpenAPI-compatible description of an RPC protocol.\r\n * @internal\r\n */\r\nexport class RpcOpenAPIDescription {\r\n /** The protocol for this description. */\r\n public readonly protocol: WebAppRpcProtocol;\r\n\r\n /** The OpenAPI paths object for the protocol. */\r\n public get paths(): OpenAPIPaths {\r\n const paths: OpenAPIPaths = {};\r\n\r\n this.protocol.configuration.interfaces().forEach((definition) => {\r\n RpcOperation.forEach(definition, (operation) => {\r\n const path = this.protocol.supplyPathForOperation(operation, undefined);\r\n paths[path] = this.generateDescription(operation);\r\n });\r\n });\r\n\r\n return paths;\r\n }\r\n\r\n /** An OpenAPI 3.0 (Swagger) description of the RESTful API that is exposed through the protocol. */\r\n public get document(): OpenAPIDocument {\r\n return {\r\n openapi: \"3.0.0\",\r\n info: this.protocol.info,\r\n paths: this.paths,\r\n };\r\n }\r\n\r\n /** Creates an OpenAPI description of an RPC protocol. */\r\n public constructor(protocol: WebAppRpcProtocol) {\r\n this.protocol = protocol;\r\n }\r\n\r\n /** Converts to JSON. */\r\n public toJSON() {\r\n return this.document;\r\n }\r\n\r\n private generateDescription(operation: RpcOperation): OpenAPIPathItem {\r\n const requestContent: OpenAPIContentMap = { \"application/json\": { schema: { type: \"array\" } } };\r\n const responseContent: OpenAPIContentMap = { \"application/json\": { schema: { type: \"object\" } } };\r\n\r\n const description: OpenAPIPathItem = {};\r\n\r\n description.head = {\r\n requestBody: { content: requestContent, required: true },\r\n responses: {\r\n 200: { description: \"Success\", content: responseContent },\r\n default: { description: \"Error\", content: responseContent },\r\n },\r\n };\r\n\r\n const parameters = this.protocol.supplyPathParametersForOperation(operation);\r\n if (parameters.length)\r\n description.parameters = parameters;\r\n\r\n return description;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"OpenAPI.js","sourceRoot":"","sources":["../../../../src/rpc/web/OpenAPI.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uDAAoD;AAwIpD;;GAEG;AACH,MAAa,qBAAqB;IAIhC,iDAAiD;IACjD,IAAW,KAAK;QACd,MAAM,KAAK,GAAiB,EAAE,CAAC;QAE/B,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YAC9D,2BAAY,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,EAAE;gBAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACxE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oGAAoG;IACpG,IAAW,QAAQ;QACjB,OAAO;YACL,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;YACxB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;IAED,yDAAyD;IACzD,YAAmB,QAA2B;QAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,wBAAwB;IACjB,MAAM;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEO,mBAAmB,CAAC,SAAuB;QACjD,MAAM,cAAc,GAAsB,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAChG,MAAM,eAAe,GAAsB,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QAElG,MAAM,WAAW,GAAoB,EAAE,CAAC;QAExC,WAAW,CAAC,IAAI,GAAG;YACjB,WAAW,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE;YACxD,SAAS,EAAE;gBACT,GAAG,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE;gBACzD,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE;aAC5D;SACF,CAAC;QAEF,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC;QAC7E,IAAI,UAAU,CAAC,MAAM;YACnB,WAAW,CAAC,UAAU,GAAG,UAAU,CAAC;QAEtC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAzDD,sDAyDC","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 { RpcOperation } from \"../core/RpcOperation\";\r\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\n/** An OpenAPI 3.0 root document object.\r\n * @internal\r\n */\r\nexport interface OpenAPIDocument {\r\n openapi: \"3.0.0\";\r\n info: OpenAPIInfo;\r\n paths: OpenAPIPaths;\r\n}\r\n\r\n/** An OpenAPI 3.0 info object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\r\n */\r\nexport interface OpenAPIInfo {\r\n title: string;\r\n version: string;\r\n}\r\n\r\n/** An OpenAPI 3.0 paths object.\r\n * @internal\r\n */\r\nexport interface OpenAPIPaths {\r\n [index: string]: OpenAPIPathItem;\r\n}\r\n\r\n/** An OpenAPI 3.0 path item object.\r\n * @internal\r\n */\r\nexport interface OpenAPIPathItem {\r\n summary?: string;\r\n get?: OpenAPIOperation;\r\n put?: OpenAPIOperation;\r\n post?: OpenAPIOperation;\r\n delete?: OpenAPIOperation;\r\n options?: OpenAPIOperation;\r\n head?: OpenAPIOperation;\r\n patch?: OpenAPIOperation;\r\n trace?: OpenAPIOperation;\r\n parameters?: OpenAPIParameter[];\r\n}\r\n\r\n/** An OpenAPI 3.0 operation object.\r\n * @internal\r\n */\r\nexport interface OpenAPIOperation {\r\n summary?: string;\r\n operationId?: string;\r\n parameters?: OpenAPIParameter[];\r\n requestBody?: OpenAPIRequestBody;\r\n responses: OpenAPIResponses;\r\n}\r\n\r\n/** An OpenAPI 3.0 content map.\r\n * @internal\r\n */\r\nexport interface OpenAPIContentMap {\r\n [index: string]: OpenAPIMediaType;\r\n}\r\n\r\n/** An OpenAPI 3.0 parameter object.\r\n * @internal\r\n */\r\nexport interface OpenAPIParameter {\r\n name: string;\r\n in: \"query\" | \"header\" | \"path\" | \"cookie\";\r\n description?: string;\r\n required?: boolean;\r\n allowEmptyValue?: boolean;\r\n style?: \"matrix\" | \"label\" | \"form\" | \"simple\" | \"spaceDelimited\" | \"pipeDelimited\" | \"deepObject\";\r\n explode?: boolean;\r\n allowReserved?: boolean;\r\n schema?: OpenAPISchema;\r\n content?: OpenAPIContentMap;\r\n}\r\n\r\n/** An OpenAPI 3.0 media type object.\r\n * @internal\r\n */\r\nexport interface OpenAPIMediaType {\r\n schema?: OpenAPISchema;\r\n}\r\n\r\n/** An OpenAPI 3.0 schema object.\r\n * @internal\r\n */\r\nexport interface OpenAPISchema {\r\n type?: \"boolean\" | \"object\" | \"array\" | \"number\" | \"string\";\r\n nullable?: boolean;\r\n description?: string;\r\n}\r\n\r\n/** An OpenAPI 3.0 encoding object.\r\n * @internal\r\n */\r\nexport interface OpenAPIEncoding {\r\n contentType?: string;\r\n style?: string;\r\n explode?: boolean;\r\n allowReserved?: boolean;\r\n}\r\n\r\n/** An OpenAPI 3.0 parameter object.\r\n * @internal\r\n */\r\nexport interface OpenAPIRequestBody {\r\n description?: string;\r\n content: OpenAPIContentMap;\r\n required?: boolean;\r\n}\r\n\r\n/** An OpenAPI 3.0 responses object.\r\n * @internal\r\n */\r\nexport interface OpenAPIResponses {\r\n default?: OpenAPIResponse;\r\n \"200\"?: OpenAPIResponse;\r\n \"301\"?: OpenAPIResponse;\r\n \"302\"?: OpenAPIResponse;\r\n \"400\"?: OpenAPIResponse;\r\n \"404\"?: OpenAPIResponse;\r\n \"500\"?: OpenAPIResponse;\r\n}\r\n\r\n/** An OpenAPI 3.0 response object.\r\n * @internal\r\n */\r\nexport interface OpenAPIResponse {\r\n description: string;\r\n content?: { [index: string]: OpenAPIMediaType };\r\n}\r\n\r\n/** An OpenAPI-compatible description of an RPC protocol.\r\n * @internal\r\n */\r\nexport class RpcOpenAPIDescription {\r\n /** The protocol for this description. */\r\n public readonly protocol: WebAppRpcProtocol;\r\n\r\n /** The OpenAPI paths object for the protocol. */\r\n public get paths(): OpenAPIPaths {\r\n const paths: OpenAPIPaths = {};\r\n\r\n this.protocol.configuration.interfaces().forEach((definition) => {\r\n RpcOperation.forEach(definition, (operation) => {\r\n const path = this.protocol.supplyPathForOperation(operation, undefined);\r\n paths[path] = this.generateDescription(operation);\r\n });\r\n });\r\n\r\n return paths;\r\n }\r\n\r\n /** An OpenAPI 3.0 (Swagger) description of the RESTful API that is exposed through the protocol. */\r\n public get document(): OpenAPIDocument {\r\n return {\r\n openapi: \"3.0.0\",\r\n info: this.protocol.info,\r\n paths: this.paths,\r\n };\r\n }\r\n\r\n /** Creates an OpenAPI description of an RPC protocol. */\r\n public constructor(protocol: WebAppRpcProtocol) {\r\n this.protocol = protocol;\r\n }\r\n\r\n /** Converts to JSON. */\r\n public toJSON() {\r\n return this.document;\r\n }\r\n\r\n private generateDescription(operation: RpcOperation): OpenAPIPathItem {\r\n const requestContent: OpenAPIContentMap = { \"application/json\": { schema: { type: \"array\" } } };\r\n const responseContent: OpenAPIContentMap = { \"application/json\": { schema: { type: \"object\" } } };\r\n\r\n const description: OpenAPIPathItem = {};\r\n\r\n description.head = {\r\n requestBody: { content: requestContent, required: true },\r\n responses: {\r\n 200: { description: \"Success\", content: responseContent },\r\n default: { description: \"Error\", content: responseContent },\r\n },\r\n };\r\n\r\n const parameters = this.protocol.supplyPathParametersForOperation(operation);\r\n if (parameters.length)\r\n description.parameters = parameters;\r\n\r\n return description;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcMultipart.js","sourceRoot":"","sources":["../../../../src/rpc/web/RpcMultipart.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,mDAA+D;AAiB/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,KAAyB;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,2DAA2D;IACpD,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,GAAsB;QACrD,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACzC,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,CAAC;YAC7C,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;;AAzBH,oCAuCC;AAZC,gBAAgB;AACF,qBAAQ,GAAG;IACvB,YAAY,CAAC,MAA0B;QACrC,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,IAAuB;QACxC,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC;IACD,YAAY,CAAC,CAAS,EAAE,IAAoB,EAAE,KAAyB;QACrE,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;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
+ {"version":3,"file":"RpcMultipart.js","sourceRoot":"","sources":["../../../../src/rpc/web/RpcMultipart.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,mDAA+D;AAiB/D;;GAEG;AACH,MAAa,YAA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E,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 @typescript-eslint/no-deprecated */\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"]}
@@ -14,7 +14,7 @@ const IModelError_1 = require("../../IModelError");
14
14
  const RpcConstants_1 = require("../core/RpcConstants");
15
15
  const RpcInvocation_1 = require("../core/RpcInvocation");
16
16
  const WebAppRpcRequest_1 = require("./WebAppRpcRequest");
17
- /* eslint-disable deprecation/deprecation */
17
+ /* eslint-disable @typescript-eslint/no-deprecated */
18
18
  /** @internal */
19
19
  const BACKEND = Symbol.for("@itwin.WebAppRpcLogging.Backend");
20
20
  const FRONTEND = Symbol.for("@itwin.WebAppRpcLogging.Frontend");
@@ -1 +1 @@
1
- {"version":3,"file":"WebAppRpcLogging.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAC5D,qEAAkE;AAClE,mDAAgD;AAEhD,uDAAwD;AACxD,yDAAsD;AAItD,yDAAsD;AAEtD,4CAA4C;AAE5C,gBAAgB;AAChB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AAC9D,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAEhE,gBAAgB;AAChB,MAAsB,gBAAgB;IAC7B,MAAM,CAAC,iBAAiB,CAAC,QAA0B;QACvD,UAAkB,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;IAC1C,CAAC;IAEM,MAAM,CAAC,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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,EAAE,2DAA2D;YACnF,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,2DAA2D;YAC5F,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/* eslint-disable deprecation/deprecation */\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"]}
1
+ {"version":3,"file":"WebAppRpcLogging.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAC5D,qEAAkE;AAClE,mDAAgD;AAEhD,uDAAwD;A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,EAAE,MAAM,CAAC,CAAC;QAC3H,CAAC;IACH,CAAC;IAEkB,WAAW;QAC5B,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,OAAO,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,OAAO,iBAAiB,CAAC;QAC3B,CAAC;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,EAAE,2DAA2D;YACnF,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,2DAA2D;YAC5F,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/* eslint-disable @typescript-eslint/no-deprecated */\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"]}
@@ -1 +1 @@
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;AA6CtD;;GAEG;AACH,MAAsB,iBAAkB,SAAQ,yBAAW;IAGzD,+EAA+E;IACxE,KAAK,CAAC,yBAAyB,CAAC,GAAsB,EAAE,GAAuB;QACpF,OAAO,IAAI,CAAC,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,gFAAgF;IACzE,KAAK,CAAC,0BAA0B,CAAC,GAAsB,EAAE,GAAuB;QACrF,IAAI,OAA6B,CAAC;QAClC,IAAI,CAAC;YACH,OAAO,GAAG,MAAM,mCAAgB,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,2BAAY,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YACpD,qBAAM,CAAC,QAAQ,CAAC,2CAAoB,CAAC,mBAAmB,EAAE,4BAA4B,OAAO,EAAE,EAAE,2BAAY,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;YACvI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACrD,OA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AC,eAAe,CAAC,CAAC,OAAO,GAAG,CAAC;YAClD,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;QACtB,CAAC;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;IAO3E,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,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,mCAAgB,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IACrG,CAAC;CACF;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 * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\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 trailersDistinct: NodeJS.Dict<string[]>;\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 headersDistinct: NodeJS.Dict<string[]>;\r\n}\r\n\r\n/** An HTTP server response object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\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(async (event, object) => WebAppRpcLogging.logProtocolEvent(event, object));\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,yDAAs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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,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,mCAAgB,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IACrG,CAAC;CACF;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 @typescript-eslint/no-deprecated */\r\n\r\n/** An HTTP server request object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\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 trailersDistinct: NodeJS.Dict<string[]>;\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 headersDistinct: NodeJS.Dict<string[]>;\r\n}\r\n\r\n/** An HTTP server response object.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in the future.\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(async (event, object) => WebAppRpcLogging.logProtocolEvent(event, object));\r\n }\r\n}\r\n"]}
@@ -205,7 +205,7 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
205
205
  }
206
206
  setupTextTransport(parameters) {
207
207
  if (this.operation.policy.allowResponseCaching(this)) {
208
- const encodedBody = btoa(parameters.objects); // eslint-disable-line deprecation/deprecation
208
+ const encodedBody = btoa(parameters.objects);
209
209
  if (encodedBody.length <= _a.maxUrlComponentSize) {
210
210
  this._request.method = "get";
211
211
  this._request.body = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"WebAppRpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAAoD;AACpD,mDAAiF;AAEjF,uDAA2F;AAC3F,yDAAmF;AAEnF,mDAAgD;AAChD,uEAAoE;AACpE,iDAA8C;AAC9C,2DAA+F;AAO/F;;GAEG;AACH,MAAa,gBAAiB,SAAQ,uBAAU;IAI9C,IAAY,QAAQ,KAAK,OAAO,I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AAC,OAAO,CAAC,GAAG,gCAAiB,CAAC,IAAI,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;IAC1C,CAAC;;AA9OH,4CAyPC;;AAnPC;;;;GAIG;AACW,oCAAmB,GAAG,IAAI,GAAG,CAAC,AAAX,CAAY;AAqO7C,gBAAgB;AACF,wBAAO,GAAG;IACtB,YAAY,EAAE,KAAK,EAAE,SAA4B,EAAE,QAA8B,EAAE,YAAmC,EAAE,IAAuB,EAAE,IAAwB,EAAiB,EAAE;QAC1L,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,SAA4B,EAAE,IAAuB,EAAiC,EAAE;QAC3G,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC;CACF,AAPoB,CAOnB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcContentType, RpcProtocolEvent, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\r\nimport { RpcRequestFulfillment, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\r\nimport { RpcMultipart } from \"./RpcMultipart\";\r\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @internal */\r\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n/** A web application RPC request.\r\n * @internal\r\n */\r\nexport class WebAppRpcRequest extends RpcRequest {\r\n private _loading: boolean = false;\r\n private _request: RequestInit = {};\r\n private _pathSuffix: string = \"\";\r\n private get _headers() { return this._request.headers as { [key: string]: string }; }\r\n\r\n /** The maximum size permitted for an encoded component in a URL.\r\n * Note that some backends limit the total cumulative request size. Our current node backends accept requests with a max size of 16 kb.\r\n * In addition to the url size, an authorization header may also add considerably to the request size.\r\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\r\n */\r\n public static maxUrlComponentSize = 1024 * 8;\r\n\r\n /** The HTTP method for this request. */\r\n public override method: HttpMethod_T;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\r\n\r\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\r\n public metadata = { status: 0, message: \"\" };\r\n\r\n /** Parses a request. */\r\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n return this.backend.parseRequest(protocol, req);\r\n }\r\n\r\n /** Sends the response for a web request. */\r\n public static async sendResponse(\r\n protocol: WebAppRpcProtocol,\r\n request: SerializedRpcRequest,\r\n fulfillment: RpcRequestFulfillment,\r\n req: HttpServerRequest,\r\n res: HttpServerResponse,\r\n ): Promise<void> {\r\n return this.backend.sendResponse(protocol, request, fulfillment, req, res);\r\n }\r\n\r\n /** Determines the most efficient transport type for an RPC value. */\r\n public static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\r\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\r\n return RpcContentType.Binary;\r\n } else if (value.data.length > 0) {\r\n return RpcContentType.Multipart;\r\n } else if (value.stream) {\r\n return RpcContentType.Stream;\r\n } else {\r\n return RpcContentType.Text;\r\n }\r\n }\r\n\r\n /** Constructs a web application request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n super(client, operation, parameters);\r\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\r\n this.method = \"head\";\r\n this._request.headers = {};\r\n }\r\n\r\n /** Sets request header values. */\r\n protected setHeader(name: string, value: string): void {\r\n this._headers[name] = value;\r\n }\r\n\r\n /** Sends the request. */\r\n protected async send(): Promise<number> {\r\n this._loading = true;\r\n await this.setupTransport();\r\n\r\n return new Promise<number>(async (resolve, reject) => {\r\n try {\r\n resolve(await this.performFetch());\r\n } catch (reason) {\r\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\r\n }\r\n });\r\n }\r\n\r\n protected override computeRetryAfter(attempts: number): number {\r\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\r\n if (retryAfter) {\r\n this.resetTransientFaultCount();\r\n\r\n const r = Number(retryAfter);\r\n if (Number.isFinite(r)) {\r\n return r * 1000;\r\n }\r\n\r\n const d = Date.parse(retryAfter);\r\n if (!Number.isNaN(d)) {\r\n return d - Date.now();\r\n }\r\n } else {\r\n this.recordTransientFault();\r\n }\r\n\r\n return super.computeRetryAfter(attempts);\r\n }\r\n\r\n protected override handleUnknownResponse(code: number) {\r\n if (this.protocol.isTimeout(code)) {\r\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\r\n } else {\r\n this.reject(new ServerError(code, \"Unknown server response code.\"));\r\n }\r\n }\r\n\r\n protected async load(): Promise<RpcSerializedValue> {\r\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\r\n try {\r\n if (!this._loading)\r\n return;\r\n\r\n const response = this._response;\r\n if (!response) {\r\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\r\n return;\r\n }\r\n\r\n if (this.protocol.protocolVersionHeaderName) {\r\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\r\n if (version) {\r\n this.responseProtocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\r\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\r\n\r\n if (responseType === RpcContentType.Binary) {\r\n resolve(await this.loadBinary(response));\r\n } else if (responseType === RpcContentType.Multipart) {\r\n resolve(await this.loadMultipart(response, contentType!));\r\n } else {\r\n resolve(await this.loadText(response));\r\n }\r\n\r\n this._loading = false;\r\n this.setLastUpdatedTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n } catch (reason) {\r\n if (!this._loading)\r\n return;\r\n\r\n this._loading = false;\r\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\r\n }\r\n });\r\n }\r\n\r\n /** Override to supply an alternate fetch function. */\r\n protected supplyFetch(): typeof fetch {\r\n return fetch;\r\n }\r\n\r\n /** Override to supply an alternate Request function. */\r\n protected supplyRequest(): typeof Request {\r\n return Request;\r\n }\r\n\r\n private async performFetch(): Promise<number> {\r\n const requestClass = this.supplyRequest();\r\n const fetchFunction = this.supplyFetch();\r\n\r\n const path = new URL(this.path, typeof (location) !== \"undefined\" ? location.origin : undefined);\r\n if (this._pathSuffix) {\r\n const params = new URLSearchParams();\r\n params.set(\"parameters\", this._pathSuffix);\r\n path.search = `?${params.toString()}`;\r\n }\r\n\r\n const request = new requestClass(path.toString(), this._request);\r\n const response = await fetchFunction(request);\r\n this._response = response;\r\n this.metadata.status = response.status;\r\n return response.status;\r\n }\r\n\r\n private async loadText(response: Response) {\r\n const value = await response.text();\r\n this.metadata.message = value;\r\n return RpcSerializedValue.create(value);\r\n }\r\n\r\n private async loadBinary(response: Response) {\r\n const value = new Uint8Array(await response.arrayBuffer());\r\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\r\n return RpcSerializedValue.create(objects, [value]);\r\n }\r\n\r\n private async loadMultipart(response: Response, contentType: string) {\r\n const data = await response.arrayBuffer();\r\n const value = new RpcMultipartParser(contentType, new Uint8Array(data)).parse();\r\n return value;\r\n }\r\n\r\n private async setupTransport(): Promise<void> {\r\n const parameters = (await this.protocol.serialize(this)).parameters;\r\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\r\n\r\n if (transportType === RpcContentType.Binary) {\r\n this.setupBinaryTransport(parameters);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n this.setupMultipartTransport(parameters);\r\n } else {\r\n this.setupTextTransport(parameters);\r\n }\r\n }\r\n\r\n private setupBinaryTransport(parameters: RpcSerializedValue) {\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.data[0];\r\n }\r\n\r\n private setupMultipartTransport(parameters: RpcSerializedValue) {\r\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._request.method = \"post\";\r\n this._request.body = RpcMultipart.createForm(parameters);\r\n }\r\n\r\n private setupTextTransport(parameters: RpcSerializedValue) {\r\n if (this.operation.policy.allowResponseCaching(this)) {\r\n const encodedBody = btoa(parameters.objects); // eslint-disable-line deprecation/deprecation\r\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\r\n this._request.method = \"get\";\r\n this._request.body = undefined;\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._pathSuffix = encodedBody;\r\n return;\r\n }\r\n }\r\n\r\n this._pathSuffix = \"\";\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.objects;\r\n }\r\n\r\n /** @internal */\r\n public static backend = {\r\n sendResponse: async (_protocol: WebAppRpcProtocol, _request: SerializedRpcRequest, _fulfillment: RpcRequestFulfillment, _req: HttpServerRequest, _res: HttpServerResponse): Promise<void> => {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\r\n },\r\n parseRequest: async (_protocol: WebAppRpcProtocol, _req: HttpServerRequest): Promise<SerializedRpcRequest> => {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\r\n },\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"WebAppRpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAAoD;AACpD,mDAAiF;AAEjF,uDAA2F;AAC3F,yDAAmF;AAEnF,mDAAgD;AAChD,uEAAoE;AACpE,iDAA8C;AAC9C,2DAA+F;AAO/F;;GAEG;AACH,MAAa,gBAAiB,SAAQ,uBAAU;IAI9C,IAAY,QAAQ,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAoC,CAAC,CAAC,CAAC;IAkBrF,wBAAwB;IACjB,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,QAA2B,EAAE,GAAsB;QAClF,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,4CAA4C;IACrC,MAAM,CAAC,KAAK,CAAC,YAAY,CAC9B,QAA2B,EAC3B,OAA6B,EAC7B,WAAkC,EAClC,GAAsB,EACtB,GAAuB;QAEvB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7E,CAAC;IAED,qEAAqE;IAC9D,MAAM,CAAC,oBAAoB,CAAC,KAAyB,EAAE,MAAW;QACvE,IAAI,MAAM,YAAY,UAAU,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC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AAC;CACF,AAPoB,CAOnB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcContentType, RpcProtocolEvent, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\r\nimport { RpcRequestFulfillment, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\r\nimport { RpcMultipart } from \"./RpcMultipart\";\r\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/* eslint-disable @typescript-eslint/no-deprecated */\r\n\r\n/** @internal */\r\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n/** A web application RPC request.\r\n * @internal\r\n */\r\nexport class WebAppRpcRequest extends RpcRequest {\r\n private _loading: boolean = false;\r\n private _request: RequestInit = {};\r\n private _pathSuffix: string = \"\";\r\n private get _headers() { return this._request.headers as { [key: string]: string }; }\r\n\r\n /** The maximum size permitted for an encoded component in a URL.\r\n * Note that some backends limit the total cumulative request size. Our current node backends accept requests with a max size of 16 kb.\r\n * In addition to the url size, an authorization header may also add considerably to the request size.\r\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\r\n */\r\n public static maxUrlComponentSize = 1024 * 8;\r\n\r\n /** The HTTP method for this request. */\r\n public override method: HttpMethod_T;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\r\n\r\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\r\n public metadata = { status: 0, message: \"\" };\r\n\r\n /** Parses a request. */\r\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n return this.backend.parseRequest(protocol, req);\r\n }\r\n\r\n /** Sends the response for a web request. */\r\n public static async sendResponse(\r\n protocol: WebAppRpcProtocol,\r\n request: SerializedRpcRequest,\r\n fulfillment: RpcRequestFulfillment,\r\n req: HttpServerRequest,\r\n res: HttpServerResponse,\r\n ): Promise<void> {\r\n return this.backend.sendResponse(protocol, request, fulfillment, req, res);\r\n }\r\n\r\n /** Determines the most efficient transport type for an RPC value. */\r\n public static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\r\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\r\n return RpcContentType.Binary;\r\n } else if (value.data.length > 0) {\r\n return RpcContentType.Multipart;\r\n } else if (value.stream) {\r\n return RpcContentType.Stream;\r\n } else {\r\n return RpcContentType.Text;\r\n }\r\n }\r\n\r\n /** Constructs a web application request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n super(client, operation, parameters);\r\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\r\n this.method = \"head\";\r\n this._request.headers = {};\r\n }\r\n\r\n /** Sets request header values. */\r\n protected setHeader(name: string, value: string): void {\r\n this._headers[name] = value;\r\n }\r\n\r\n /** Sends the request. */\r\n protected async send(): Promise<number> {\r\n this._loading = true;\r\n await this.setupTransport();\r\n\r\n return new Promise<number>(async (resolve, reject) => {\r\n try {\r\n resolve(await this.performFetch());\r\n } catch (reason) {\r\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\r\n }\r\n });\r\n }\r\n\r\n protected override computeRetryAfter(attempts: number): number {\r\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\r\n if (retryAfter) {\r\n this.resetTransientFaultCount();\r\n\r\n const r = Number(retryAfter);\r\n if (Number.isFinite(r)) {\r\n return r * 1000;\r\n }\r\n\r\n const d = Date.parse(retryAfter);\r\n if (!Number.isNaN(d)) {\r\n return d - Date.now();\r\n }\r\n } else {\r\n this.recordTransientFault();\r\n }\r\n\r\n return super.computeRetryAfter(attempts);\r\n }\r\n\r\n protected override handleUnknownResponse(code: number) {\r\n if (this.protocol.isTimeout(code)) {\r\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\r\n } else {\r\n this.reject(new ServerError(code, \"Unknown server response code.\"));\r\n }\r\n }\r\n\r\n protected async load(): Promise<RpcSerializedValue> {\r\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\r\n try {\r\n if (!this._loading)\r\n return;\r\n\r\n const response = this._response;\r\n if (!response) {\r\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\r\n return;\r\n }\r\n\r\n if (this.protocol.protocolVersionHeaderName) {\r\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\r\n if (version) {\r\n this.responseProtocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\r\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\r\n\r\n if (responseType === RpcContentType.Binary) {\r\n resolve(await this.loadBinary(response));\r\n } else if (responseType === RpcContentType.Multipart) {\r\n resolve(await this.loadMultipart(response, contentType!));\r\n } else {\r\n resolve(await this.loadText(response));\r\n }\r\n\r\n this._loading = false;\r\n this.setLastUpdatedTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n } catch (reason) {\r\n if (!this._loading)\r\n return;\r\n\r\n this._loading = false;\r\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\r\n }\r\n });\r\n }\r\n\r\n /** Override to supply an alternate fetch function. */\r\n protected supplyFetch(): typeof fetch {\r\n return fetch;\r\n }\r\n\r\n /** Override to supply an alternate Request function. */\r\n protected supplyRequest(): typeof Request {\r\n return Request;\r\n }\r\n\r\n private async performFetch(): Promise<number> {\r\n const requestClass = this.supplyRequest();\r\n const fetchFunction = this.supplyFetch();\r\n\r\n const path = new URL(this.path, typeof (location) !== \"undefined\" ? location.origin : undefined);\r\n if (this._pathSuffix) {\r\n const params = new URLSearchParams();\r\n params.set(\"parameters\", this._pathSuffix);\r\n path.search = `?${params.toString()}`;\r\n }\r\n\r\n const request = new requestClass(path.toString(), this._request);\r\n const response = await fetchFunction(request);\r\n this._response = response;\r\n this.metadata.status = response.status;\r\n return response.status;\r\n }\r\n\r\n private async loadText(response: Response) {\r\n const value = await response.text();\r\n this.metadata.message = value;\r\n return RpcSerializedValue.create(value);\r\n }\r\n\r\n private async loadBinary(response: Response) {\r\n const value = new Uint8Array(await response.arrayBuffer());\r\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\r\n return RpcSerializedValue.create(objects, [value]);\r\n }\r\n\r\n private async loadMultipart(response: Response, contentType: string) {\r\n const data = await response.arrayBuffer();\r\n const value = new RpcMultipartParser(contentType, new Uint8Array(data)).parse();\r\n return value;\r\n }\r\n\r\n private async setupTransport(): Promise<void> {\r\n const parameters = (await this.protocol.serialize(this)).parameters;\r\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\r\n\r\n if (transportType === RpcContentType.Binary) {\r\n this.setupBinaryTransport(parameters);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n this.setupMultipartTransport(parameters);\r\n } else {\r\n this.setupTextTransport(parameters);\r\n }\r\n }\r\n\r\n private setupBinaryTransport(parameters: RpcSerializedValue) {\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.data[0];\r\n }\r\n\r\n private setupMultipartTransport(parameters: RpcSerializedValue) {\r\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._request.method = \"post\";\r\n this._request.body = RpcMultipart.createForm(parameters);\r\n }\r\n\r\n private setupTextTransport(parameters: RpcSerializedValue) {\r\n if (this.operation.policy.allowResponseCaching(this)) {\r\n const encodedBody = btoa(parameters.objects);\r\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\r\n this._request.method = \"get\";\r\n this._request.body = undefined;\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._pathSuffix = encodedBody;\r\n return;\r\n }\r\n }\r\n\r\n this._pathSuffix = \"\";\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.objects;\r\n }\r\n\r\n /** @internal */\r\n public static backend = {\r\n sendResponse: async (_protocol: WebAppRpcProtocol, _request: SerializedRpcRequest, _fulfillment: RpcRequestFulfillment, _req: HttpServerRequest, _res: HttpServerResponse): Promise<void> => {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\r\n },\r\n parseRequest: async (_protocol: WebAppRpcProtocol, _req: HttpServerRequest): Promise<SerializedRpcRequest> => {\r\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\r\n },\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcMultipartParser.d.ts","sourceRoot":"","sources":["../../../../../src/rpc/web/multipart/RpcMultipartParser.ts"],"names":[],"mappings":"AAIA;;GAEG;AA6BH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA4B9D,gBAAgB;AAChB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,mBAAmB,CAAqB;IA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AAa;IAC5B,OAAO,CAAC,MAAM,CAAqB;gBAEhB,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAsCnD,KAAK,IAAI,kBAAkB;IAqOlC,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,kBAAkB;CAE3B"}
@@ -36,7 +36,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
36
36
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37
37
  */
38
38
  const RpcMarshaling_1 = require("../../core/RpcMarshaling");
39
- /* eslint-disable deprecation/deprecation */
40
39
  const START = 0;
41
40
  const START_BOUNDARY = 1;
42
41
  const HEADER_FIELD_START = 2;