@itwin/core-common 3.3.0-dev.9 → 3.4.0-dev.0
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.
- package/CHANGELOG.md +30 -1
- package/lib/cjs/AnalysisStyle.d.ts +7 -7
- package/lib/cjs/AnalysisStyle.d.ts.map +1 -1
- package/lib/cjs/AnalysisStyle.js.map +1 -1
- package/lib/cjs/BackgroundMapProvider.d.ts +2 -2
- package/lib/cjs/BackgroundMapProvider.js +1 -1
- package/lib/cjs/BackgroundMapProvider.js.map +1 -1
- package/lib/cjs/BackgroundMapSettings.d.ts +2 -2
- package/lib/cjs/BackgroundMapSettings.d.ts.map +1 -1
- package/lib/cjs/BackgroundMapSettings.js.map +1 -1
- package/lib/cjs/BriefcaseTypes.js.map +1 -1
- package/lib/cjs/ChangedEntities.d.ts +1 -1
- package/lib/cjs/ChangedEntities.js.map +1 -1
- package/lib/cjs/Code.d.ts +7 -7
- package/lib/cjs/Code.d.ts.map +1 -1
- package/lib/cjs/Code.js +5 -5
- package/lib/cjs/Code.js.map +1 -1
- package/lib/cjs/ColorDef.d.ts +2 -0
- package/lib/cjs/ColorDef.d.ts.map +1 -1
- package/lib/cjs/ColorDef.js +4 -0
- package/lib/cjs/ColorDef.js.map +1 -1
- package/lib/cjs/ContextRealityModel.d.ts +6 -6
- package/lib/cjs/ContextRealityModel.d.ts.map +1 -1
- package/lib/cjs/ContextRealityModel.js.map +1 -1
- package/lib/cjs/DisplayStyleSettings.d.ts +58 -57
- package/lib/cjs/DisplayStyleSettings.d.ts.map +1 -1
- package/lib/cjs/DisplayStyleSettings.js +23 -26
- package/lib/cjs/DisplayStyleSettings.js.map +1 -1
- package/lib/cjs/ElementProps.d.ts +6 -6
- package/lib/cjs/ElementProps.d.ts.map +1 -1
- package/lib/cjs/ElementProps.js.map +1 -1
- package/lib/cjs/EmphasizeElementsProps.d.ts +8 -8
- package/lib/cjs/EmphasizeElementsProps.d.ts.map +1 -1
- package/lib/cjs/EmphasizeElementsProps.js.map +1 -1
- package/lib/cjs/EntityProps.d.ts +2 -2
- package/lib/cjs/EntityProps.d.ts.map +1 -1
- package/lib/cjs/EntityProps.js.map +1 -1
- package/lib/cjs/Environment.d.ts +2 -2
- package/lib/cjs/Environment.d.ts.map +1 -1
- package/lib/cjs/Environment.js.map +1 -1
- package/lib/cjs/FeatureIndex.d.ts +0 -1
- package/lib/cjs/FeatureIndex.d.ts.map +1 -1
- package/lib/cjs/FeatureIndex.js +0 -1
- package/lib/cjs/FeatureIndex.js.map +1 -1
- package/lib/cjs/FeatureSymbology.d.ts +40 -9
- package/lib/cjs/FeatureSymbology.d.ts.map +1 -1
- package/lib/cjs/FeatureSymbology.js +41 -6
- package/lib/cjs/FeatureSymbology.js.map +1 -1
- package/lib/cjs/FeatureTable.d.ts +6 -2
- package/lib/cjs/FeatureTable.d.ts.map +1 -1
- package/lib/cjs/FeatureTable.js +26 -6
- package/lib/cjs/FeatureTable.js.map +1 -1
- package/lib/cjs/HiddenLine.d.ts +3 -3
- package/lib/cjs/HiddenLine.d.ts.map +1 -1
- package/lib/cjs/HiddenLine.js.map +1 -1
- package/lib/cjs/IModel.d.ts +9 -6
- package/lib/cjs/IModel.d.ts.map +1 -1
- package/lib/cjs/IModel.js.map +1 -1
- package/lib/cjs/IModelError.d.ts +3 -3
- package/lib/cjs/IModelError.d.ts.map +1 -1
- package/lib/cjs/IModelError.js +1 -2
- package/lib/cjs/IModelError.js.map +1 -1
- package/lib/cjs/LightSettings.d.ts +4 -4
- package/lib/cjs/LightSettings.d.ts.map +1 -1
- package/lib/cjs/LightSettings.js.map +1 -1
- package/lib/cjs/MapImagerySettings.d.ts +7 -7
- package/lib/cjs/MapImagerySettings.d.ts.map +1 -1
- package/lib/cjs/MapImagerySettings.js +3 -3
- package/lib/cjs/MapImagerySettings.js.map +1 -1
- package/lib/cjs/MapLayerSettings.d.ts +21 -14
- package/lib/cjs/MapLayerSettings.d.ts.map +1 -1
- package/lib/cjs/MapLayerSettings.js +6 -6
- package/lib/cjs/MapLayerSettings.js.map +1 -1
- package/lib/cjs/ModelProps.d.ts +1 -1
- package/lib/cjs/ModelProps.js.map +1 -1
- package/lib/cjs/PlanProjectionSettings.d.ts +4 -4
- package/lib/cjs/PlanProjectionSettings.d.ts.map +1 -1
- package/lib/cjs/PlanProjectionSettings.js.map +1 -1
- package/lib/cjs/PlanarClipMask.d.ts +11 -11
- package/lib/cjs/PlanarClipMask.d.ts.map +1 -1
- package/lib/cjs/PlanarClipMask.js.map +1 -1
- package/lib/cjs/RenderSchedule.d.ts +66 -8
- package/lib/cjs/RenderSchedule.d.ts.map +1 -1
- package/lib/cjs/RenderSchedule.js +228 -8
- package/lib/cjs/RenderSchedule.js.map +1 -1
- package/lib/cjs/RgbColor.d.ts +1 -0
- package/lib/cjs/RgbColor.d.ts.map +1 -1
- package/lib/cjs/RgbColor.js +4 -0
- package/lib/cjs/RgbColor.js.map +1 -1
- package/lib/cjs/RpcInterface.d.ts.map +1 -1
- package/lib/cjs/RpcInterface.js +91 -4
- package/lib/cjs/RpcInterface.js.map +1 -1
- package/lib/cjs/SpatialClassification.d.ts +9 -9
- package/lib/cjs/SpatialClassification.d.ts.map +1 -1
- package/lib/cjs/SpatialClassification.js +1 -1
- package/lib/cjs/SpatialClassification.js.map +1 -1
- package/lib/cjs/SubCategoryAppearance.d.ts +10 -10
- package/lib/cjs/SubCategoryAppearance.d.ts.map +1 -1
- package/lib/cjs/SubCategoryAppearance.js.map +1 -1
- package/lib/cjs/SubCategoryOverride.d.ts +6 -6
- package/lib/cjs/SubCategoryOverride.d.ts.map +1 -1
- package/lib/cjs/SubCategoryOverride.js.map +1 -1
- package/lib/cjs/ViewFlags.d.ts +3 -3
- package/lib/cjs/ViewFlags.d.ts.map +1 -1
- package/lib/cjs/ViewFlags.js.map +1 -1
- package/lib/cjs/core-common.d.ts +7 -1
- package/lib/cjs/core-common.d.ts.map +1 -1
- package/lib/cjs/core-common.js +7 -1
- package/lib/cjs/core-common.js.map +1 -1
- package/lib/cjs/ipc/IpcSession.d.ts +24 -0
- package/lib/cjs/ipc/IpcSession.d.ts.map +1 -0
- package/lib/cjs/ipc/IpcSession.js +28 -0
- package/lib/cjs/ipc/IpcSession.js.map +1 -0
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts +1 -0
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.js +38 -2
- package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/IModelTileRpcInterface.d.ts.map +1 -1
- package/lib/cjs/rpc/IModelTileRpcInterface.js +16 -2
- package/lib/cjs/rpc/IModelTileRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/core/RpcControl.d.ts +2 -0
- package/lib/cjs/rpc/core/RpcControl.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcControl.js +13 -1
- package/lib/cjs/rpc/core/RpcControl.js.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.js +17 -4
- package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/cjs/rpc/core/RpcProtocol.d.ts +6 -2
- package/lib/cjs/rpc/core/RpcProtocol.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcProtocol.js.map +1 -1
- package/lib/cjs/rpc/core/RpcRequest.d.ts +11 -6
- package/lib/cjs/rpc/core/RpcRequest.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcRequest.js +12 -14
- package/lib/cjs/rpc/core/RpcRequest.js.map +1 -1
- package/lib/cjs/rpc/core/RpcSessionInvocation.d.ts +11 -0
- package/lib/cjs/rpc/core/RpcSessionInvocation.d.ts.map +1 -0
- package/lib/cjs/rpc/core/RpcSessionInvocation.js +60 -0
- package/lib/cjs/rpc/core/RpcSessionInvocation.js.map +1 -0
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts +0 -5
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js +0 -47
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts +2 -3
- package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.js +25 -20
- package/lib/cjs/rpc/web/WebAppRpcRequest.js.map +1 -1
- package/lib/cjs/tile/ElementGraphics.d.ts +4 -0
- package/lib/cjs/tile/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/tile/ElementGraphics.js.map +1 -1
- package/lib/cjs/tile/IModelTileIO.d.ts +2 -2
- package/lib/cjs/tile/IModelTileIO.js +2 -2
- package/lib/cjs/tile/IModelTileIO.js.map +1 -1
- package/lib/esm/AnalysisStyle.d.ts +7 -7
- package/lib/esm/AnalysisStyle.d.ts.map +1 -1
- package/lib/esm/AnalysisStyle.js.map +1 -1
- package/lib/esm/BackgroundMapProvider.d.ts +2 -2
- package/lib/esm/BackgroundMapProvider.js +1 -1
- package/lib/esm/BackgroundMapProvider.js.map +1 -1
- package/lib/esm/BackgroundMapSettings.d.ts +2 -2
- package/lib/esm/BackgroundMapSettings.d.ts.map +1 -1
- package/lib/esm/BackgroundMapSettings.js.map +1 -1
- package/lib/esm/BriefcaseTypes.js.map +1 -1
- package/lib/esm/ChangedEntities.d.ts +1 -1
- package/lib/esm/ChangedEntities.js.map +1 -1
- package/lib/esm/Code.d.ts +7 -7
- package/lib/esm/Code.d.ts.map +1 -1
- package/lib/esm/Code.js +5 -5
- package/lib/esm/Code.js.map +1 -1
- package/lib/esm/ColorDef.d.ts +2 -0
- package/lib/esm/ColorDef.d.ts.map +1 -1
- package/lib/esm/ColorDef.js +4 -0
- package/lib/esm/ColorDef.js.map +1 -1
- package/lib/esm/ContextRealityModel.d.ts +6 -6
- package/lib/esm/ContextRealityModel.d.ts.map +1 -1
- package/lib/esm/ContextRealityModel.js.map +1 -1
- package/lib/esm/DisplayStyleSettings.d.ts +58 -57
- package/lib/esm/DisplayStyleSettings.d.ts.map +1 -1
- package/lib/esm/DisplayStyleSettings.js +23 -26
- package/lib/esm/DisplayStyleSettings.js.map +1 -1
- package/lib/esm/ElementProps.d.ts +6 -6
- package/lib/esm/ElementProps.d.ts.map +1 -1
- package/lib/esm/ElementProps.js.map +1 -1
- package/lib/esm/EmphasizeElementsProps.d.ts +8 -8
- package/lib/esm/EmphasizeElementsProps.d.ts.map +1 -1
- package/lib/esm/EmphasizeElementsProps.js.map +1 -1
- package/lib/esm/EntityProps.d.ts +2 -2
- package/lib/esm/EntityProps.d.ts.map +1 -1
- package/lib/esm/EntityProps.js.map +1 -1
- package/lib/esm/Environment.d.ts +2 -2
- package/lib/esm/Environment.d.ts.map +1 -1
- package/lib/esm/Environment.js.map +1 -1
- package/lib/esm/FeatureIndex.d.ts +0 -1
- package/lib/esm/FeatureIndex.d.ts.map +1 -1
- package/lib/esm/FeatureIndex.js +0 -1
- package/lib/esm/FeatureIndex.js.map +1 -1
- package/lib/esm/FeatureSymbology.d.ts +40 -9
- package/lib/esm/FeatureSymbology.d.ts.map +1 -1
- package/lib/esm/FeatureSymbology.js +41 -6
- package/lib/esm/FeatureSymbology.js.map +1 -1
- package/lib/esm/FeatureTable.d.ts +6 -2
- package/lib/esm/FeatureTable.d.ts.map +1 -1
- package/lib/esm/FeatureTable.js +26 -6
- package/lib/esm/FeatureTable.js.map +1 -1
- package/lib/esm/HiddenLine.d.ts +3 -3
- package/lib/esm/HiddenLine.d.ts.map +1 -1
- package/lib/esm/HiddenLine.js.map +1 -1
- package/lib/esm/IModel.d.ts +9 -6
- package/lib/esm/IModel.d.ts.map +1 -1
- package/lib/esm/IModel.js.map +1 -1
- package/lib/esm/IModelError.d.ts +3 -3
- package/lib/esm/IModelError.d.ts.map +1 -1
- package/lib/esm/IModelError.js +1 -1
- package/lib/esm/IModelError.js.map +1 -1
- package/lib/esm/LightSettings.d.ts +4 -4
- package/lib/esm/LightSettings.d.ts.map +1 -1
- package/lib/esm/LightSettings.js.map +1 -1
- package/lib/esm/MapImagerySettings.d.ts +7 -7
- package/lib/esm/MapImagerySettings.d.ts.map +1 -1
- package/lib/esm/MapImagerySettings.js +3 -3
- package/lib/esm/MapImagerySettings.js.map +1 -1
- package/lib/esm/MapLayerSettings.d.ts +21 -14
- package/lib/esm/MapLayerSettings.d.ts.map +1 -1
- package/lib/esm/MapLayerSettings.js +6 -6
- package/lib/esm/MapLayerSettings.js.map +1 -1
- package/lib/esm/ModelProps.d.ts +1 -1
- package/lib/esm/ModelProps.js.map +1 -1
- package/lib/esm/PlanProjectionSettings.d.ts +4 -4
- package/lib/esm/PlanProjectionSettings.d.ts.map +1 -1
- package/lib/esm/PlanProjectionSettings.js.map +1 -1
- package/lib/esm/PlanarClipMask.d.ts +11 -11
- package/lib/esm/PlanarClipMask.d.ts.map +1 -1
- package/lib/esm/PlanarClipMask.js.map +1 -1
- package/lib/esm/RenderSchedule.d.ts +66 -8
- package/lib/esm/RenderSchedule.d.ts.map +1 -1
- package/lib/esm/RenderSchedule.js +229 -9
- package/lib/esm/RenderSchedule.js.map +1 -1
- package/lib/esm/RgbColor.d.ts +1 -0
- package/lib/esm/RgbColor.d.ts.map +1 -1
- package/lib/esm/RgbColor.js +4 -0
- package/lib/esm/RgbColor.js.map +1 -1
- package/lib/esm/RpcInterface.d.ts.map +1 -1
- package/lib/esm/RpcInterface.js +91 -4
- package/lib/esm/RpcInterface.js.map +1 -1
- package/lib/esm/SpatialClassification.d.ts +9 -9
- package/lib/esm/SpatialClassification.d.ts.map +1 -1
- package/lib/esm/SpatialClassification.js +1 -1
- package/lib/esm/SpatialClassification.js.map +1 -1
- package/lib/esm/SubCategoryAppearance.d.ts +10 -10
- package/lib/esm/SubCategoryAppearance.d.ts.map +1 -1
- package/lib/esm/SubCategoryAppearance.js.map +1 -1
- package/lib/esm/SubCategoryOverride.d.ts +6 -6
- package/lib/esm/SubCategoryOverride.d.ts.map +1 -1
- package/lib/esm/SubCategoryOverride.js.map +1 -1
- package/lib/esm/ViewFlags.d.ts +3 -3
- package/lib/esm/ViewFlags.d.ts.map +1 -1
- package/lib/esm/ViewFlags.js.map +1 -1
- package/lib/esm/core-common.d.ts +7 -1
- package/lib/esm/core-common.d.ts.map +1 -1
- package/lib/esm/core-common.js +7 -1
- package/lib/esm/core-common.js.map +1 -1
- package/lib/esm/ipc/IpcSession.d.ts +24 -0
- package/lib/esm/ipc/IpcSession.d.ts.map +1 -0
- package/lib/esm/ipc/IpcSession.js +24 -0
- package/lib/esm/ipc/IpcSession.js.map +1 -0
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts +1 -0
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js +37 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/esm/rpc/IModelTileRpcInterface.d.ts.map +1 -1
- package/lib/esm/rpc/IModelTileRpcInterface.js +15 -1
- package/lib/esm/rpc/IModelTileRpcInterface.js.map +1 -1
- package/lib/esm/rpc/core/RpcControl.d.ts +2 -0
- package/lib/esm/rpc/core/RpcControl.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcControl.js +13 -1
- package/lib/esm/rpc/core/RpcControl.js.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.js +18 -5
- package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/esm/rpc/core/RpcProtocol.d.ts +6 -2
- package/lib/esm/rpc/core/RpcProtocol.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcProtocol.js.map +1 -1
- package/lib/esm/rpc/core/RpcRequest.d.ts +11 -6
- package/lib/esm/rpc/core/RpcRequest.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcRequest.js +6 -8
- package/lib/esm/rpc/core/RpcRequest.js.map +1 -1
- package/lib/esm/rpc/core/RpcSessionInvocation.d.ts +11 -0
- package/lib/esm/rpc/core/RpcSessionInvocation.d.ts.map +1 -0
- package/lib/esm/rpc/core/RpcSessionInvocation.js +56 -0
- package/lib/esm/rpc/core/RpcSessionInvocation.js.map +1 -0
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts +0 -5
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.js +0 -47
- package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.d.ts +2 -3
- package/lib/esm/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.js +25 -20
- package/lib/esm/rpc/web/WebAppRpcRequest.js.map +1 -1
- package/lib/esm/tile/ElementGraphics.d.ts +4 -0
- package/lib/esm/tile/ElementGraphics.d.ts.map +1 -1
- package/lib/esm/tile/ElementGraphics.js.map +1 -1
- package/lib/esm/tile/IModelTileIO.d.ts +2 -2
- package/lib/esm/tile/IModelTileIO.js +2 -2
- package/lib/esm/tile/IModelTileIO.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelTileRpcInterface.js","sourceRoot":"","sources":["../../../src/rpc/IModelTileRpcInterface.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;
|
|
1
|
+
{"version":3,"file":"IModelTileRpcInterface.js","sourceRoot":"","sources":["../../../src/rpc/IModelTileRpcInterface.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;AAKH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAA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C;AACpB,oCAAa,GAAG,wBAAwB,CAAC;AAEhE,6CAA6C;AAC/B,uCAAgB,GAAG,OAAO,CAAC;AAWzC;IADC,YAAY,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC;sEAGpE;AAWD;IADC,YAAY,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC;kEACwE","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 { Id64Array } from \"@itwin/core-bentley\";\r\nimport { CloudStorageContainerDescriptor, CloudStorageContainerUrl } from \"../CloudStorage\";\r\nimport { TileContentIdentifier } from \"../CloudStorageTileCache\";\r\nimport { RpcResponseCacheControl } from \"./core/RpcConstants\";\r\nimport { RpcOperation } from \"./core/RpcOperation\";\r\nimport { IModelRpcProps } from \"../IModel\";\r\nimport { RpcInterface } from \"../RpcInterface\";\r\nimport { RpcManager } from \"../RpcManager\";\r\nimport { ElementGraphicsRequestProps } from \"../tile/ElementGraphics\";\r\nimport { IModelTileTreeProps, TileContentSource, TileVersionInfo } from \"../TileProps\";\r\n\r\n/** @public */\r\nexport abstract class IModelTileRpcInterface extends RpcInterface {\r\n public static getClient(): IModelTileRpcInterface { return RpcManager.getClientForInterface(IModelTileRpcInterface); }\r\n\r\n /** The immutable name of the interface. */\r\n public static readonly interfaceName = \"IModelTileRpcInterface\";\r\n\r\n /** The semantic version of the interface. */\r\n public static interfaceVersion = \"3.1.0\";\r\n\r\n /*===========================================================================================\r\n NOTE: Any add/remove/change to the methods below requires an update of the interface version.\r\n NOTE: Please consult the README in this folder for the semantic versioning rules.\r\n ===========================================================================================*/\r\n\r\n /** Returns connection information for external tile cache or an empty `CloudStorageContainerUrl` if no external tile cache is configured on the backend.\r\n * @beta\r\n */\r\n @RpcOperation.allowResponseCaching(RpcResponseCacheControl.Immutable)\r\n public async getTileCacheContainerUrl(_tokenProps: IModelRpcProps, _id: CloudStorageContainerDescriptor): Promise<CloudStorageContainerUrl> {\r\n return this.forward(arguments);\r\n }\r\n\r\n /** Returns true if an external tile cache is configured on the backend.\r\n * @internal @deprecated\r\n */\r\n public async isUsingExternalTileCache(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.forward(arguments);\r\n }\r\n\r\n /** @internal */\r\n @RpcOperation.allowResponseCaching(RpcResponseCacheControl.Immutable)\r\n public async requestTileTreeProps(_tokenProps: IModelRpcProps, _id: string): Promise<IModelTileTreeProps> { return this.forward(arguments); }\r\n\r\n /** Ask the backend to generate content for the specified tile. This function, unlike the deprecated `requestTileContent`, does not check the cloud storage tile cache -\r\n * Use `CloudStorageTileCache.retrieve` for that.\r\n * @returns TileContentSource - if Backend, use retrieveTileContent. If ExternalCache, use TileAdmin.requestCachedTileContent\r\n * @internal\r\n */\r\n public async generateTileContent(_rpcProps: IModelRpcProps, _treeId: string, _contentId: string, _guid: string | undefined): Promise<TileContentSource> {\r\n return this.forward(arguments);\r\n }\r\n\r\n /** Retrieves tile content from the backend once it's generated by generateTileContent.\r\n * @internal\r\n */\r\n public async retrieveTileContent(_rpcProps: IModelRpcProps, _key: TileContentIdentifier): Promise<Uint8Array> {\r\n return this.forward(arguments);\r\n }\r\n\r\n /** @internal */\r\n public async queryVersionInfo(): Promise<TileVersionInfo> {\r\n return this.forward(arguments);\r\n }\r\n\r\n /** This is a temporary workaround for folks developing authoring applications, to be removed when proper support for such applications is introduced.\r\n * Given a set of model Ids, it purges any associated tile tree state on the back-end so that the next request for the tile tree or content will recreate that state.\r\n * Invoked after a modification is made to the model(s).\r\n * If no array of model Ids is supplied, it purges *all* tile trees, which can be quite inefficient.\r\n * @internal\r\n */\r\n public async purgeTileTrees(_tokenProps: IModelRpcProps, _modelIds: Id64Array | undefined): Promise<void> { return this.forward(arguments); }\r\n\r\n /** Requests graphics for a single element in \"iMdl\" format.\r\n * @returns graphics in iMdl format, or `undefined` if the element's geometry produced no graphics or the request was canceled before completion.\r\n * @throws IModelError on bad request (nonexistent element, duplicate request Id, etc).\r\n * @internal\r\n */\r\n public async requestElementGraphics(_rpcProps: IModelRpcProps, _request: ElementGraphicsRequestProps): Promise<Uint8Array | undefined> {\r\n return this.forward(arguments);\r\n }\r\n}\r\n"]}
|
|
@@ -8,6 +8,7 @@ import { RpcInvocation } from "./RpcInvocation";
|
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class RpcControlResponse {
|
|
11
|
+
message: string;
|
|
11
12
|
}
|
|
12
13
|
/** A pending RPC operation response.
|
|
13
14
|
* @public
|
|
@@ -22,6 +23,7 @@ export declare class RpcPendingResponse extends RpcControlResponse {
|
|
|
22
23
|
* @public
|
|
23
24
|
*/
|
|
24
25
|
export declare class RpcNotFoundResponse extends RpcControlResponse {
|
|
26
|
+
message: string;
|
|
25
27
|
}
|
|
26
28
|
/** Manages requests and responses for an RPC configuration.
|
|
27
29
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcControl.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAOH,OAAO,EAAE,qBAAqB,EAAc,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD;;GAEG;AACH,8BAAsB,kBAAkB;CACvC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IACxD,uDAAuD;
|
|
1
|
+
{"version":3,"file":"RpcControl.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAOH,OAAO,EAAE,qBAAqB,EAAc,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD;;GAEG;AACH,8BAAsB,kBAAkB;IAC/B,OAAO,SAAwB;CACvC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IACxD,uDAAuD;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhC,qCAAqC;gBAClB,OAAO,GAAE,MAAW;CAIxC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzC,OAAO,SAAe;CACvC;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,gBAAgB;IAChB,OAAc,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IACjD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAK;IAC/B,OAAO,CAAC,cAAc,CAAmB;IACzC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,kBAAkB,CAA4D;IAEtF,OAAO;IAKP,gBAAgB;IACH,iBAAiB;IAS9B,gBAAgB;WACF,MAAM,CAAC,aAAa,EAAE,gBAAgB,GAAG,iBAAiB;IAWxE,OAAO,CAAC,iBAAiB,CAIvB;IAEF,OAAO,CAAC,YAAY,CAelB;IAEF,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,cAAc;IAkBtB,gBAAgB;IACT,UAAU;IAejB,gBAAgB;IACT,sBAAsB,CAAC,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO;CAY/E"}
|
|
@@ -17,6 +17,9 @@ import { RpcRegistry } from "./RpcRegistry";
|
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
export class RpcControlResponse {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.message = "RpcControlResponse";
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
/** A pending RPC operation response.
|
|
22
25
|
* @public
|
|
@@ -32,6 +35,10 @@ export class RpcPendingResponse extends RpcControlResponse {
|
|
|
32
35
|
* @public
|
|
33
36
|
*/
|
|
34
37
|
export class RpcNotFoundResponse extends RpcControlResponse {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this.message = "Not found";
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
/** Manages requests and responses for an RPC configuration.
|
|
37
44
|
* @internal
|
|
@@ -67,6 +74,9 @@ export class RpcControlChannel {
|
|
|
67
74
|
/** @internal */
|
|
68
75
|
async describeEndpoints() {
|
|
69
76
|
this.activateClient();
|
|
77
|
+
if (!this._channelInterface.interfaceName) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
70
80
|
return this._describeEndpoints();
|
|
71
81
|
}
|
|
72
82
|
/** @internal */
|
|
@@ -119,7 +129,9 @@ export class RpcControlChannel {
|
|
|
119
129
|
handleUnknownOperation(invocation, _error) {
|
|
120
130
|
const op = invocation.request.operation;
|
|
121
131
|
if (op.interfaceVersion === "CONTROL" && op.operationName === "describeEndpoints") {
|
|
122
|
-
|
|
132
|
+
if (this._channelInterface.interfaceName) {
|
|
133
|
+
op.interfaceDefinition = this._channelInterface.interfaceName;
|
|
134
|
+
}
|
|
123
135
|
return true;
|
|
124
136
|
}
|
|
125
137
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcControl.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAyB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,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QAEzB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9E,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAEzE,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,WAAkB,CAAC,CAAC;QAC9F,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACnE,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,sBAAsB,CAAC,UAAyB,EAAE,MAAW;QAClE,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC;QACxC,IAAI,EAAE,CAAC,gBAAgB,KAAK,SAAS,IAAI,EAAE,CAAC,aAAa,KAAK,mBAAmB,EAAE;YACjF,EAAE,CAAC,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;YAC9D,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AA9GD,gBAAgB;AACF,0BAAQ,GAAwB,EAAE,CAAC;AAClC,6BAAW,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { Buffer } from \"buffer\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints, RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/** An RPC operation control response.\r\n * @public\r\n */\r\nexport abstract class RpcControlResponse {\r\n}\r\n\r\n/** A pending RPC operation response.\r\n * @public\r\n */\r\nexport class RpcPendingResponse extends RpcControlResponse {\r\n /** Extended status regarding the pending operation. */\r\n public message: string;\r\n\r\n /** Constructs a pending response. */\r\n public constructor(message: string = \"\") {\r\n super();\r\n this.message = message;\r\n }\r\n}\r\n\r\n/** A RPC operation response.\r\n * @public\r\n */\r\nexport class RpcNotFoundResponse extends RpcControlResponse {\r\n}\r\n\r\n/** Manages requests and responses for an RPC configuration.\r\n * @internal\r\n */\r\nexport class RpcControlChannel {\r\n /** @internal */\r\n public static channels: RpcControlChannel[] = [];\r\n private static _obtainLock = 0;\r\n private _configuration: RpcConfiguration;\r\n private _initialized = false;\r\n private _clientActive = false;\r\n private _describeEndpoints: () => Promise<RpcInterfaceEndpoints[]> = undefined as any;\r\n\r\n private constructor(configuration: RpcConfiguration) {\r\n this._configuration = configuration;\r\n RpcControlChannel.channels.push(this);\r\n }\r\n\r\n /** @internal */\r\n public async describeEndpoints() {\r\n this.activateClient();\r\n return this._describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public static obtain(configuration: RpcConfiguration): RpcControlChannel {\r\n if (RpcControlChannel._obtainLock)\r\n return undefined as any;\r\n\r\n ++RpcControlChannel._obtainLock;\r\n const channel = new RpcControlChannel(configuration);\r\n --RpcControlChannel._obtainLock;\r\n\r\n return channel;\r\n }\r\n\r\n private _channelInterface = class extends RpcInterface {\r\n public static readonly interfaceVersion = \"CONTROL\";\r\n public static readonly interfaceName = \"\";\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> { return this.forward(arguments); }\r\n };\r\n\r\n private _channelImpl = class extends RpcInterface {\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const endpoints: RpcInterfaceEndpoints[] = [];\r\n\r\n this.configuration.interfaces().forEach((definition) => {\r\n if (!RpcRegistry.instance.isRpcInterfaceInitialized(definition))\r\n return;\r\n\r\n const description: RpcInterfaceEndpoints = { interfaceName: definition.interfaceName, interfaceVersion: definition.interfaceVersion, operationNames: [], compatible: true };\r\n RpcOperation.forEach(definition, (operation) => description.operationNames.push(operation.operationName));\r\n endpoints.push(description);\r\n });\r\n\r\n return endpoints;\r\n }\r\n };\r\n\r\n private computeId(): string {\r\n const interfaces: string[] = [];\r\n this._configuration.interfaces().forEach((definition) => interfaces.push(`${definition.interfaceName}@${definition.interfaceVersion}`));\r\n const id = interfaces.sort().join(\",\");\r\n\r\n if (typeof (btoa) !== \"undefined\") // eslint-disable-line deprecation/deprecation\r\n return btoa(id); // eslint-disable-line deprecation/deprecation\r\n else if (typeof (Buffer) !== \"undefined\")\r\n return Buffer.from(id, \"binary\").toString(\"base64\");\r\n else\r\n return id;\r\n }\r\n\r\n private activateClient() {\r\n if (this._clientActive)\r\n return;\r\n\r\n if (!this._initialized) {\r\n if (this._configuration.interfaces().length)\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid state.`);\r\n\r\n this.initialize();\r\n }\r\n\r\n this._clientActive = true;\r\n const token: IModelRpcProps = { key: \"none\", iTwinId: \"none\", iModelId: \"none\", changeset: { id: \"none\" } };\r\n RpcOperation.forEach(this._channelInterface, (operation) => operation.policy.token = (_request) => RpcOperation.fallbackToken ?? token);\r\n const client = RpcManager.getClientForInterface(this._channelInterface);\r\n this._describeEndpoints = async () => client.describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public initialize() {\r\n if (this._initialized)\r\n throw new IModelError(BentleyStatus.ERROR, `Already initialized.`);\r\n\r\n this._initialized = true;\r\n\r\n const id = this.computeId();\r\n Object.defineProperty(this._channelInterface, \"interfaceName\", { value: id });\r\n Object.defineProperty(this._channelImpl, \"interfaceName\", { value: id });\r\n\r\n RpcConfiguration.assign(this._channelInterface, () => this._configuration.constructor as any);\r\n RpcManager.registerImpl(this._channelInterface, this._channelImpl);\r\n RpcManager.initializeInterface(this._channelInterface);\r\n }\r\n\r\n /** @internal */\r\n public handleUnknownOperation(invocation: RpcInvocation, _error: any): boolean {\r\n const op = invocation.request.operation;\r\n if (op.interfaceVersion === \"CONTROL\" && op.operationName === \"describeEndpoints\") {\r\n op.interfaceDefinition = this._channelInterface.interfaceName;\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcControl.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAyB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAgB,kBAAkB;IAAxC;QACS,YAAO,GAAG,oBAAoB,CAAC;IACxC,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IAIxD,qCAAqC;IACrC,YAAmB,UAAkB,EAAE;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAA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MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAEzE,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,WAAkB,CAAC,CAAC;QAC9F,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACnE,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,sBAAsB,CAAC,UAAyB,EAAE,MAAW;QAClE,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC;QACxC,IAAI,EAAE,CAAC,gBAAgB,KAAK,SAAS,IAAI,EAAE,CAAC,aAAa,KAAK,mBAAmB,EAAE;YACjF,IAAI,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE;gBACxC,EAAE,CAAC,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;aAC/D;YAED,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AArHD,gBAAgB;AACF,0BAAQ,GAAwB,EAAE,CAAC;AAClC,6BAAW,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { Buffer } from \"buffer\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints, RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/** An RPC operation control response.\r\n * @public\r\n */\r\nexport abstract class RpcControlResponse {\r\n public message = \"RpcControlResponse\";\r\n}\r\n\r\n/** A pending RPC operation response.\r\n * @public\r\n */\r\nexport class RpcPendingResponse extends RpcControlResponse {\r\n /** Extended status regarding the pending operation. */\r\n public override message: string;\r\n\r\n /** Constructs a pending response. */\r\n public constructor(message: string = \"\") {\r\n super();\r\n this.message = message;\r\n }\r\n}\r\n\r\n/** A RPC operation response.\r\n * @public\r\n */\r\nexport class RpcNotFoundResponse extends RpcControlResponse {\r\n public override message = \"Not found\";\r\n}\r\n\r\n/** Manages requests and responses for an RPC configuration.\r\n * @internal\r\n */\r\nexport class RpcControlChannel {\r\n /** @internal */\r\n public static channels: RpcControlChannel[] = [];\r\n private static _obtainLock = 0;\r\n private _configuration: RpcConfiguration;\r\n private _initialized = false;\r\n private _clientActive = false;\r\n private _describeEndpoints: () => Promise<RpcInterfaceEndpoints[]> = undefined as any;\r\n\r\n private constructor(configuration: RpcConfiguration) {\r\n this._configuration = configuration;\r\n RpcControlChannel.channels.push(this);\r\n }\r\n\r\n /** @internal */\r\n public async describeEndpoints() {\r\n this.activateClient();\r\n if (!this._channelInterface.interfaceName) {\r\n return [];\r\n }\r\n\r\n return this._describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public static obtain(configuration: RpcConfiguration): RpcControlChannel {\r\n if (RpcControlChannel._obtainLock)\r\n return undefined as any;\r\n\r\n ++RpcControlChannel._obtainLock;\r\n const channel = new RpcControlChannel(configuration);\r\n --RpcControlChannel._obtainLock;\r\n\r\n return channel;\r\n }\r\n\r\n private _channelInterface = class extends RpcInterface {\r\n public static readonly interfaceVersion = \"CONTROL\";\r\n public static readonly interfaceName = \"\";\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> { return this.forward(arguments); }\r\n };\r\n\r\n private _channelImpl = class extends RpcInterface {\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const endpoints: RpcInterfaceEndpoints[] = [];\r\n\r\n this.configuration.interfaces().forEach((definition) => {\r\n if (!RpcRegistry.instance.isRpcInterfaceInitialized(definition))\r\n return;\r\n\r\n const description: RpcInterfaceEndpoints = { interfaceName: definition.interfaceName, interfaceVersion: definition.interfaceVersion, operationNames: [], compatible: true };\r\n RpcOperation.forEach(definition, (operation) => description.operationNames.push(operation.operationName));\r\n endpoints.push(description);\r\n });\r\n\r\n return endpoints;\r\n }\r\n };\r\n\r\n private computeId(): string {\r\n const interfaces: string[] = [];\r\n this._configuration.interfaces().forEach((definition) => interfaces.push(`${definition.interfaceName}@${definition.interfaceVersion}`));\r\n const id = interfaces.sort().join(\",\");\r\n\r\n if (typeof (btoa) !== \"undefined\") // eslint-disable-line deprecation/deprecation\r\n return btoa(id); // eslint-disable-line deprecation/deprecation\r\n else if (typeof (Buffer) !== \"undefined\")\r\n return Buffer.from(id, \"binary\").toString(\"base64\");\r\n else\r\n return id;\r\n }\r\n\r\n private activateClient() {\r\n if (this._clientActive)\r\n return;\r\n\r\n if (!this._initialized) {\r\n if (this._configuration.interfaces().length)\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid state.`);\r\n\r\n this.initialize();\r\n }\r\n\r\n this._clientActive = true;\r\n const token: IModelRpcProps = { key: \"none\", iTwinId: \"none\", iModelId: \"none\", changeset: { id: \"none\" } };\r\n RpcOperation.forEach(this._channelInterface, (operation) => operation.policy.token = (_request) => RpcOperation.fallbackToken ?? token);\r\n const client = RpcManager.getClientForInterface(this._channelInterface);\r\n this._describeEndpoints = async () => client.describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public initialize() {\r\n if (this._initialized)\r\n throw new IModelError(BentleyStatus.ERROR, `Already initialized.`);\r\n\r\n this._initialized = true;\r\n\r\n const id = this.computeId();\r\n Object.defineProperty(this._channelInterface, \"interfaceName\", { value: id });\r\n Object.defineProperty(this._channelImpl, \"interfaceName\", { value: id });\r\n\r\n RpcConfiguration.assign(this._channelInterface, () => this._configuration.constructor as any);\r\n RpcManager.registerImpl(this._channelInterface, this._channelImpl);\r\n RpcManager.initializeInterface(this._channelInterface);\r\n }\r\n\r\n /** @internal */\r\n public handleUnknownOperation(invocation: RpcInvocation, _error: any): boolean {\r\n const op = invocation.request.operation;\r\n if (op.interfaceVersion === \"CONTROL\" && op.operationName === \"describeEndpoints\") {\r\n if (this._channelInterface.interfaceName) {\r\n op.interfaceDefinition = this._channelInterface.interfaceName;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcInvocation.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAA+B,UAAU,
|
|
1
|
+
{"version":3,"file":"RpcInvocation.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAA+B,UAAU,EAAqE,MAAM,qBAAqB,CAAC;AAI9J,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAoB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAoB,WAAW,EAAsB,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG/H;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,iFAAiF;IACjF,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC,sCAAsC;IACtC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OAGG;WACW,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa;IAI3D,gCAAgC;gBACb,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,oBAAoB;IA8BvE,OAAO,CAAC,sBAAsB;WAIhB,cAAc,CAAC,QAAQ,CAAC,EAAE,WAAW;;;;;;;YAQrC,OAAO;IAkCrB,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,MAAM,CAAC,aAAa;YAOd,MAAM;YAKN,eAAe;YAOf,eAAe;IA4B7B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,OAAO;IAsBf,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,uBAAuB;CA0BhC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module RpcInterface
|
|
7
7
|
*/
|
|
8
8
|
var _a;
|
|
9
|
-
import { BentleyError, BentleyStatus, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory } from "@itwin/core-bentley";
|
|
9
|
+
import { BentleyError, BentleyStatus, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from "@itwin/core-bentley";
|
|
10
10
|
import { CommonLoggerCategory } from "../../CommonLoggerCategory";
|
|
11
11
|
import { IModelError } from "../../IModelError";
|
|
12
12
|
import { RpcInterface } from "../../RpcInterface";
|
|
@@ -99,15 +99,22 @@ export class RpcInvocation {
|
|
|
99
99
|
};
|
|
100
100
|
try {
|
|
101
101
|
this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);
|
|
102
|
-
const parameters = RpcMarshaling.deserialize(this.protocol, request.parameters);
|
|
102
|
+
const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);
|
|
103
103
|
this.applyPolicies(parameters);
|
|
104
104
|
const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);
|
|
105
105
|
impl[CURRENT_INVOCATION] = this;
|
|
106
106
|
const op = this.lookupOperationFunction(impl);
|
|
107
|
-
return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)
|
|
107
|
+
return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)
|
|
108
|
+
.catch(async (error) => {
|
|
109
|
+
// this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.
|
|
110
|
+
if (!(error instanceof RpcPendingResponse)) {
|
|
111
|
+
Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, "Error in RPC operation", { error: BentleyError.getErrorProps(error) });
|
|
112
|
+
Tracing.setAttributes({ error: true });
|
|
113
|
+
}
|
|
114
|
+
throw error;
|
|
115
|
+
}));
|
|
108
116
|
}
|
|
109
117
|
catch (error) {
|
|
110
|
-
Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, "Error in RPC operation", { error: BentleyError.getErrorProps(error), ...RpcInvocation.sanitizeForLog(activity) });
|
|
111
118
|
return this.reject(error);
|
|
112
119
|
}
|
|
113
120
|
}
|
|
@@ -191,13 +198,14 @@ export class RpcInvocation {
|
|
|
191
198
|
return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;
|
|
192
199
|
}
|
|
193
200
|
fulfill(result, rawResult) {
|
|
201
|
+
var _b;
|
|
194
202
|
const fulfillment = {
|
|
195
203
|
result,
|
|
196
204
|
rawResult,
|
|
197
205
|
status: this.protocol.getCode(this.status),
|
|
198
206
|
id: this.request.id,
|
|
199
207
|
interfaceName: (typeof (this.operation) === "undefined") ? "" : this.operation.interfaceDefinition.interfaceName,
|
|
200
|
-
allowCompression: this.operation.policy.allowResponseCompression,
|
|
208
|
+
allowCompression: ((_b = this.operation) === null || _b === void 0 ? void 0 : _b.policy.allowResponseCompression) || false,
|
|
201
209
|
};
|
|
202
210
|
this.transformResponseStatus(fulfillment, rawResult);
|
|
203
211
|
try {
|
|
@@ -226,10 +234,15 @@ export class RpcInvocation {
|
|
|
226
234
|
else if (this._notFound) {
|
|
227
235
|
managedStatus = "notFound";
|
|
228
236
|
}
|
|
237
|
+
else if (this._noContent) {
|
|
238
|
+
managedStatus = "noContent";
|
|
239
|
+
}
|
|
229
240
|
if (managedStatus) {
|
|
230
241
|
const responseValue = fulfillment.result.objects;
|
|
231
242
|
const status = { iTwinRpcCoreResponse: true, managedStatus, responseValue };
|
|
232
243
|
fulfillment.result.objects = JSON.stringify(status);
|
|
244
|
+
status.responseValue = rawResult; // for ipc case
|
|
245
|
+
fulfillment.rawResult = status;
|
|
233
246
|
}
|
|
234
247
|
if (rawResult instanceof BentleyError) {
|
|
235
248
|
fulfillment.status = StatusCategory.for(rawResult).code;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,OAAO,EAAe,YAAY,EAAE,aAAa,EAAc,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrJ,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,aAAa,EAAsB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAoB,WAAW,EAAE,kBAAkB,EAA+C,MAAM,eAAe,CAAC;AAC/H,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,M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c,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;SACzD;IACH,CAAC;;;AA/Pa,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAG,CAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters));\r\n } catch (error: unknown) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error), ...RpcInvocation.sanitizeForLog(activity) });\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = await RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = await RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation.policy.allowResponseCompression,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n }\r\n\r\n if (rawResult instanceof BentleyError) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,OAAO,EAAe,YAAY,EAAE,aAAa,EAAc,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9J,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAA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K,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,uBAAuB,CAAC,WAAkC,EAAE,SAAc;QAChF,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE;YAClC,OAAO;SACR;QAED,IAAI,aAA+D,CAAC;QACpE,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,aAAa,GAAG,SAAS,CAAC;SAC3B;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE;YACzB,aAAa,GAAG,UAAU,CAAC;SAC5B;aAAM,IAAI,IAAI,CAAC,UAAU,EAAE;YAC1B,aAAa,GAAG,WAAW,CAAC;SAC7B;QAED,IAAI,aAAa,EAAE;YACjB,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;YACjD,MAAM,MAAM,GAAqB,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;YAC9F,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpD,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,eAAe;YACjD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;SAChC;QAED,IAAI,SAAS,YAAY,YAAY,EAAE;YACrC,WAAW,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;SACzD;IACH,CAAC;;;AA1Qa,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAG,CAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.setAttributes({ error: true });\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = await RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = await RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation?.policy.allowResponseCompression || false,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof BentleyError) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -6,6 +6,7 @@ import { IModelRpcProps } from "../../IModel";
|
|
|
6
6
|
import { RpcInterface, RpcInterfaceDefinition } from "../../RpcInterface";
|
|
7
7
|
import { RpcConfiguration } from "./RpcConfiguration";
|
|
8
8
|
import { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from "./RpcConstants";
|
|
9
|
+
import { RpcNotFoundResponse } from "./RpcControl";
|
|
9
10
|
import { RpcInvocation, SerializedRpcActivity } from "./RpcInvocation";
|
|
10
11
|
import { RpcSerializedValue } from "./RpcMarshaling";
|
|
11
12
|
import { RpcOperation } from "./RpcOperation";
|
|
@@ -30,6 +31,7 @@ export interface SerializedRpcRequest extends SerializedRpcActivity {
|
|
|
30
31
|
caching: RpcResponseCacheControl;
|
|
31
32
|
ip?: string;
|
|
32
33
|
protocolVersion?: number;
|
|
34
|
+
parametersOverride?: any[];
|
|
33
35
|
}
|
|
34
36
|
/** An RPC operation request fulfillment.
|
|
35
37
|
* @internal
|
|
@@ -71,8 +73,10 @@ export declare enum RpcProtocolVersion {
|
|
|
71
73
|
*/
|
|
72
74
|
export interface RpcManagedStatus {
|
|
73
75
|
iTwinRpcCoreResponse: true;
|
|
74
|
-
managedStatus: "pending" | "notFound";
|
|
75
|
-
responseValue: string
|
|
76
|
+
managedStatus: "pending" | "notFound" | "noContent";
|
|
77
|
+
responseValue: string | {
|
|
78
|
+
message: string;
|
|
79
|
+
} | RpcNotFoundResponse;
|
|
76
80
|
}
|
|
77
81
|
/** An application protocol for an RPC interface.
|
|
78
82
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcProtocol.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB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B;IACT,oBAAoB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;IAE/F,gBAAgB;IACT,qBAAqB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAElG,gBAAgB;IACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAhH9F,+DAA+D;AACxC,kBAAM,GAAqC,IAAI,OAAO,EAAE,CAAC;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,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 { BeEvent } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcInvocation, SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/** A serialized RPC operation descriptor.\r\n * @internal\r\n */\r\nexport interface SerializedRpcOperation {\r\n interfaceDefinition: string;\r\n operationName: string;\r\n interfaceVersion: string;\r\n encodedRequest?: string;\r\n}\r\n\r\n/** A serialized RPC operation request.\r\n * @internal\r\n */\r\nexport interface SerializedRpcRequest extends SerializedRpcActivity {\r\n operation: SerializedRpcOperation;\r\n method: string;\r\n path: string;\r\n parameters: RpcSerializedValue;\r\n caching: RpcResponseCacheControl;\r\n ip?: string;\r\n protocolVersion?: number;\r\n}\r\n\r\n/** An RPC operation request fulfillment.\r\n * @internal\r\n */\r\nexport interface RpcRequestFulfillment {\r\n /** The RPC interface for the request. */\r\n interfaceName: string;\r\n\r\n /** The id for the request. */\r\n id: string;\r\n\r\n /** The result for the request. */\r\n result: RpcSerializedValue;\r\n\r\n /** The un-serialized result for the request. */\r\n rawResult: any;\r\n\r\n /** A protocol-specific status code value for the request. */\r\n status: number;\r\n\r\n /* A protocol-specific value for retrying this request. */\r\n retry?: string;\r\n\r\n /** Whether to compress the result with one of the client's supported encodings. */\r\n allowCompression?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcRequestFulfillment {\r\n export async function forUnknownError(request: SerializedRpcRequest, error: any): Promise<RpcRequestFulfillment> {\r\n const result = await RpcMarshaling.serialize(undefined, error);\r\n\r\n return {\r\n interfaceName: request.operation.interfaceDefinition,\r\n id: request.id,\r\n result,\r\n rawResult: error,\r\n status: RpcRequestStatus.Rejected,\r\n };\r\n }\r\n}\r\n\r\n/** Handles RPC protocol events.\r\n * @internal\r\n */\r\nexport type RpcProtocolEventHandler = (type: RpcProtocolEvent, object: RpcRequest | RpcInvocation, err?: any) => void;\r\n\r\n/** Documents changes to the RPC protocol version.\r\n * @internal\r\n */\r\nexport enum RpcProtocolVersion {\r\n None = 0,\r\n IntroducedNoContent = 1,\r\n IntroducedStatusCategory = 2\r\n}\r\n\r\n/**\r\n * A backend response that is handled internally by the RPC system.\r\n * @internal\r\n */\r\nexport interface RpcManagedStatus {\r\n iTwinRpcCoreResponse: true;\r\n managedStatus: \"pending\" | \"notFound\";\r\n responseValue: string;\r\n}\r\n\r\n/** An application protocol for an RPC interface.\r\n * @internal\r\n */\r\nexport abstract class RpcProtocol {\r\n /** Events raised by all protocols. See [[RpcProtocolEvent]] */\r\n public static readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** A version code that identifies the RPC protocol capabilties of this endpoint. */\r\n public static readonly protocolVersion: number = RpcProtocolVersion.IntroducedStatusCategory;\r\n\r\n /** The name of the RPC protocol version header. */\r\n public protocolVersionHeaderName = \"\";\r\n\r\n /** Events raised by the protocol. See [[RpcProtocolEvent]] */\r\n public readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** The configuration for the protocol. */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** The RPC request class for this protocol. */\r\n public abstract readonly requestType: typeof RpcRequest;\r\n\r\n /** The RPC invocation class for this protocol. */\r\n public readonly invocationType: typeof RpcInvocation = RpcInvocation;\r\n\r\n public serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the request id header. */\r\n id: \"\",\r\n\r\n /** The name of the application id header */\r\n applicationId: \"\",\r\n\r\n /** The name of the version header. */\r\n applicationVersion: \"\",\r\n\r\n /** The name of the session id header */\r\n sessionId: \"\",\r\n\r\n /** The name of the authorization header. */\r\n authorization: \"\",\r\n };\r\n\r\n /** If greater than zero, specifies where to break large binary request payloads. */\r\n public transferChunkThreshold: number = 0;\r\n\r\n /** Used by protocols that can transmit stream values natively. */\r\n public preserveStreams: boolean = false;\r\n\r\n /** Used by protocols that can transmit IModelRpcProps values natively. */\r\n public checkToken: boolean = false;\r\n\r\n /** Used by protocols that support user-defined status codes. */\r\n public supportsStatusCategory: boolean = false;\r\n\r\n /** If checkToken is true, will be called on the backend to inflate the IModelRpcProps for each request. */\r\n public inflateToken(tokenFromBody: IModelRpcProps, _request: SerializedRpcRequest): IModelRpcProps { return tokenFromBody; }\r\n\r\n /** Override to supply the status corresponding to a protocol-specific code value. */\r\n public getStatus(code: number): RpcRequestStatus {\r\n return code;\r\n }\r\n\r\n /** Override to supply the protocol-specific code corresponding to a status value. */\r\n public getCode(status: RpcRequestStatus): number {\r\n return status;\r\n }\r\n\r\n /** Override to supply the protocol-specific path value for an RPC operation. */\r\n public supplyPathForOperation(operation: RpcOperation, _request: RpcRequest | undefined): string {\r\n return JSON.stringify(operation);\r\n }\r\n\r\n /** Override to supply the operation for a protocol-specific path value. */\r\n public getOperationFromPath(path: string): SerializedRpcOperation {\r\n return JSON.parse(path);\r\n }\r\n\r\n /** Obtains the implementation result on the backend for an RPC operation request. */\r\n public async fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment> {\r\n return new (this.invocationType)(this, request).fulfillment;\r\n }\r\n\r\n /** Serializes a request. */\r\n public async serialize(request: RpcRequest): Promise<SerializedRpcRequest> {\r\n const serializedContext = await RpcConfiguration.requestContext.serialize(request);\r\n return {\r\n ...serializedContext,\r\n operation: {\r\n interfaceDefinition: request.operation.interfaceDefinition.interfaceName,\r\n operationName: request.operation.operationName,\r\n interfaceVersion: request.operation.interfaceVersion,\r\n },\r\n method: request.method,\r\n path: request.path,\r\n parameters: await RpcMarshaling.serialize(request.protocol, request.parameters),\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: RpcProtocol.protocolVersion,\r\n };\r\n }\r\n\r\n /** Constructs a protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n this.configuration = configuration;\r\n this.events.addListener((type, object) => RpcProtocol.events.raiseEvent(type, object));\r\n }\r\n\r\n /** @internal */\r\n public onRpcClientInitialized(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplInitialized(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcClientTerminated(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplTerminated(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAoB,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,C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,mBAAmB,EAAE,OAAO,CAAC,SAAS,CAAC,mBAAmB,CAAC,aAAa;gBACxE,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,aAAa;gBAC9C,gBAAgB,EAAE,OAAO,CAAC,SAAS,CAAC,gBAAgB;aACrD;YACD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,MAAM,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC;YAC/E,OAAO,EAAE,uBAAuB,CAAC,IAAI;YACrC,eAAe,EAAE,WAAW,CAAC,eAAe;SAC7C,CAAC;IACJ,CAAC;IAQD,gBAAgB;IACT,sBAAsB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAEnG,gBAAgB;IACT,oBAAoB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;IAE/F,gBAAgB;IACT,qBAAqB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAElG,gBAAgB;IACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAhH9F,+DAA+D;AACxC,kBAAM,GAAqC,IAAI,OAAO,EAAE,CAAC;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,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 { BeEvent } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse } from \"./RpcControl\";\r\nimport { RpcInvocation, SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/** A serialized RPC operation descriptor.\r\n * @internal\r\n */\r\nexport interface SerializedRpcOperation {\r\n interfaceDefinition: string;\r\n operationName: string;\r\n interfaceVersion: string;\r\n encodedRequest?: string;\r\n}\r\n\r\n/** A serialized RPC operation request.\r\n * @internal\r\n */\r\nexport interface SerializedRpcRequest extends SerializedRpcActivity {\r\n operation: SerializedRpcOperation;\r\n method: string;\r\n path: string;\r\n parameters: RpcSerializedValue;\r\n caching: RpcResponseCacheControl;\r\n ip?: string;\r\n protocolVersion?: number;\r\n parametersOverride?: any[];\r\n}\r\n\r\n/** An RPC operation request fulfillment.\r\n * @internal\r\n */\r\nexport interface RpcRequestFulfillment {\r\n /** The RPC interface for the request. */\r\n interfaceName: string;\r\n\r\n /** The id for the request. */\r\n id: string;\r\n\r\n /** The result for the request. */\r\n result: RpcSerializedValue;\r\n\r\n /** The un-serialized result for the request. */\r\n rawResult: any;\r\n\r\n /** A protocol-specific status code value for the request. */\r\n status: number;\r\n\r\n /* A protocol-specific value for retrying this request. */\r\n retry?: string;\r\n\r\n /** Whether to compress the result with one of the client's supported encodings. */\r\n allowCompression?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcRequestFulfillment {\r\n export async function forUnknownError(request: SerializedRpcRequest, error: any): Promise<RpcRequestFulfillment> {\r\n const result = await RpcMarshaling.serialize(undefined, error);\r\n\r\n return {\r\n interfaceName: request.operation.interfaceDefinition,\r\n id: request.id,\r\n result,\r\n rawResult: error,\r\n status: RpcRequestStatus.Rejected,\r\n };\r\n }\r\n}\r\n\r\n/** Handles RPC protocol events.\r\n * @internal\r\n */\r\nexport type RpcProtocolEventHandler = (type: RpcProtocolEvent, object: RpcRequest | RpcInvocation, err?: any) => void;\r\n\r\n/** Documents changes to the RPC protocol version.\r\n * @internal\r\n */\r\nexport enum RpcProtocolVersion {\r\n None = 0,\r\n IntroducedNoContent = 1,\r\n IntroducedStatusCategory = 2\r\n}\r\n\r\n/**\r\n * A backend response that is handled internally by the RPC system.\r\n * @internal\r\n */\r\nexport interface RpcManagedStatus {\r\n iTwinRpcCoreResponse: true;\r\n managedStatus: \"pending\" | \"notFound\" | \"noContent\";\r\n responseValue: string | { message: string } | RpcNotFoundResponse;\r\n}\r\n\r\n/** An application protocol for an RPC interface.\r\n * @internal\r\n */\r\nexport abstract class RpcProtocol {\r\n /** Events raised by all protocols. See [[RpcProtocolEvent]] */\r\n public static readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** A version code that identifies the RPC protocol capabilties of this endpoint. */\r\n public static readonly protocolVersion: number = RpcProtocolVersion.IntroducedStatusCategory;\r\n\r\n /** The name of the RPC protocol version header. */\r\n public protocolVersionHeaderName = \"\";\r\n\r\n /** Events raised by the protocol. See [[RpcProtocolEvent]] */\r\n public readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** The configuration for the protocol. */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** The RPC request class for this protocol. */\r\n public abstract readonly requestType: typeof RpcRequest;\r\n\r\n /** The RPC invocation class for this protocol. */\r\n public readonly invocationType: typeof RpcInvocation = RpcInvocation;\r\n\r\n public serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the request id header. */\r\n id: \"\",\r\n\r\n /** The name of the application id header */\r\n applicationId: \"\",\r\n\r\n /** The name of the version header. */\r\n applicationVersion: \"\",\r\n\r\n /** The name of the session id header */\r\n sessionId: \"\",\r\n\r\n /** The name of the authorization header. */\r\n authorization: \"\",\r\n };\r\n\r\n /** If greater than zero, specifies where to break large binary request payloads. */\r\n public transferChunkThreshold: number = 0;\r\n\r\n /** Used by protocols that can transmit stream values natively. */\r\n public preserveStreams: boolean = false;\r\n\r\n /** Used by protocols that can transmit IModelRpcProps values natively. */\r\n public checkToken: boolean = false;\r\n\r\n /** Used by protocols that support user-defined status codes. */\r\n public supportsStatusCategory: boolean = false;\r\n\r\n /** If checkToken is true, will be called on the backend to inflate the IModelRpcProps for each request. */\r\n public inflateToken(tokenFromBody: IModelRpcProps, _request: SerializedRpcRequest): IModelRpcProps { return tokenFromBody; }\r\n\r\n /** Override to supply the status corresponding to a protocol-specific code value. */\r\n public getStatus(code: number): RpcRequestStatus {\r\n return code;\r\n }\r\n\r\n /** Override to supply the protocol-specific code corresponding to a status value. */\r\n public getCode(status: RpcRequestStatus): number {\r\n return status;\r\n }\r\n\r\n /** Override to supply the protocol-specific path value for an RPC operation. */\r\n public supplyPathForOperation(operation: RpcOperation, _request: RpcRequest | undefined): string {\r\n return JSON.stringify(operation);\r\n }\r\n\r\n /** Override to supply the operation for a protocol-specific path value. */\r\n public getOperationFromPath(path: string): SerializedRpcOperation {\r\n return JSON.parse(path);\r\n }\r\n\r\n /** Obtains the implementation result on the backend for an RPC operation request. */\r\n public async fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment> {\r\n return new (this.invocationType)(this, request).fulfillment;\r\n }\r\n\r\n /** Serializes a request. */\r\n public async serialize(request: RpcRequest): Promise<SerializedRpcRequest> {\r\n const serializedContext = await RpcConfiguration.requestContext.serialize(request);\r\n return {\r\n ...serializedContext,\r\n operation: {\r\n interfaceDefinition: request.operation.interfaceDefinition.interfaceName,\r\n operationName: request.operation.operationName,\r\n interfaceVersion: request.operation.interfaceVersion,\r\n },\r\n method: request.method,\r\n path: request.path,\r\n parameters: await RpcMarshaling.serialize(request.protocol, request.parameters),\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: RpcProtocol.protocolVersion,\r\n };\r\n }\r\n\r\n /** Constructs a protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n this.configuration = configuration;\r\n this.events.addListener((type, object) => RpcProtocol.events.raiseEvent(type, object));\r\n }\r\n\r\n /** @internal */\r\n public onRpcClientInitialized(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplInitialized(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcClientTerminated(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplTerminated(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n}\r\n"]}
|
|
@@ -9,7 +9,12 @@ import { RpcRequestEvent, RpcRequestStatus, RpcResponseCacheControl } from "./Rp
|
|
|
9
9
|
import { RpcNotFoundResponse } from "./RpcControl";
|
|
10
10
|
import { RpcSerializedValue } from "./RpcMarshaling";
|
|
11
11
|
import { RpcOperation } from "./RpcOperation";
|
|
12
|
-
import { RpcProtocol } from "./RpcProtocol";
|
|
12
|
+
import { RpcProtocol, RpcProtocolVersion } from "./RpcProtocol";
|
|
13
|
+
/** @internal */
|
|
14
|
+
export declare const aggregateLoad: {
|
|
15
|
+
lastRequest: number;
|
|
16
|
+
lastResponse: number;
|
|
17
|
+
};
|
|
13
18
|
/** @internal */
|
|
14
19
|
export declare class ResponseLike implements Response {
|
|
15
20
|
private _data;
|
|
@@ -74,8 +79,10 @@ export declare abstract class RpcRequest<TResponse = any> {
|
|
|
74
79
|
private _created;
|
|
75
80
|
private _lastSubmitted;
|
|
76
81
|
private _lastUpdated;
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
/** @internal */
|
|
83
|
+
_status: RpcRequestStatus;
|
|
84
|
+
/** @internal */
|
|
85
|
+
_extendedStatus: string;
|
|
79
86
|
private _connecting;
|
|
80
87
|
private _active;
|
|
81
88
|
private _hasRawListener;
|
|
@@ -86,7 +93,7 @@ export declare abstract class RpcRequest<TResponse = any> {
|
|
|
86
93
|
private _transientFaults;
|
|
87
94
|
protected _response: Response | undefined;
|
|
88
95
|
protected _rawPromise: Promise<Response | undefined>;
|
|
89
|
-
|
|
96
|
+
responseProtocolVersion: RpcProtocolVersion;
|
|
90
97
|
/** All RPC requests that are currently in flight. */
|
|
91
98
|
static get activeRequests(): ReadonlyMap<string, RpcRequest>;
|
|
92
99
|
/** Events raised by RpcRequest. See [[RpcRequestEvent]] */
|
|
@@ -152,8 +159,6 @@ export declare abstract class RpcRequest<TResponse = any> {
|
|
|
152
159
|
protected abstract setHeader(name: string, value: string): void;
|
|
153
160
|
/** Sets the last updated time for the request. */
|
|
154
161
|
protected setLastUpdatedTime(): void;
|
|
155
|
-
/** Override to describe available headers based on a protocol-specific criteria (such as a CORS whitelist). */
|
|
156
|
-
protected isHeaderAvailable(_name: string): boolean;
|
|
157
162
|
protected computeRetryAfter(attempts: number): number;
|
|
158
163
|
protected recordTransientFault(): void;
|
|
159
164
|
protected resetTransientFaultCount(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcRequest.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAuB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAoB,eAAe,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAoB,WAAW,
|
|
1
|
+
{"version":3,"file":"RpcRequest.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OA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SAAS,CAAC,sBAAsB;IASzB,MAAM;IAcA,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAwDpC,SAAS,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM;IAI5C,OAAO,CAAC,cAAc;IA+BtB,OAAO,CAAC,uBAAuB;IA6B/B,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,OAAO;IAoBf,OAAO,CAAC,UAAU;IAYlB,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAgBnC,gBAAgB;IACT,OAAO,IAAI,IAAI;IAWtB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,oBAAoB;cAeZ,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA2B3C,OAAO,CAAC,SAAS;CAOlB;AAED,gBAAgB;AAChB,eAAO,MAAM,oBAAoB,YA+C7B,CAAC"}
|
|
@@ -15,7 +15,8 @@ import { RpcProtocol, RpcProtocolVersion } from "./RpcProtocol";
|
|
|
15
15
|
import { CURRENT_REQUEST } from "./RpcRegistry";
|
|
16
16
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
17
17
|
// cspell:ignore csrf
|
|
18
|
-
|
|
18
|
+
/** @internal */
|
|
19
|
+
export const aggregateLoad = { lastRequest: 0, lastResponse: 0 };
|
|
19
20
|
/** @internal */
|
|
20
21
|
export class ResponseLike {
|
|
21
22
|
constructor(data) {
|
|
@@ -61,7 +62,9 @@ export class RpcRequest {
|
|
|
61
62
|
this._created = 0;
|
|
62
63
|
this._lastSubmitted = 0;
|
|
63
64
|
this._lastUpdated = 0;
|
|
65
|
+
/** @internal */
|
|
64
66
|
this._status = RpcRequestStatus.Unknown;
|
|
67
|
+
/** @internal */
|
|
65
68
|
this._extendedStatus = "";
|
|
66
69
|
this._connecting = false;
|
|
67
70
|
this._active = true;
|
|
@@ -71,7 +74,7 @@ export class RpcRequest {
|
|
|
71
74
|
this._retryAfter = null;
|
|
72
75
|
this._transientFaults = 0;
|
|
73
76
|
this._response = undefined;
|
|
74
|
-
this.responseProtocolVersion =
|
|
77
|
+
this.responseProtocolVersion = RpcProtocolVersion.None;
|
|
75
78
|
this._created = new Date().getTime();
|
|
76
79
|
this.path = "";
|
|
77
80
|
this.method = "";
|
|
@@ -151,10 +154,6 @@ export class RpcRequest {
|
|
|
151
154
|
setLastUpdatedTime() {
|
|
152
155
|
this._lastUpdated = new Date().getTime();
|
|
153
156
|
}
|
|
154
|
-
/** Override to describe available headers based on a protocol-specific criteria (such as a CORS whitelist). */
|
|
155
|
-
isHeaderAvailable(_name) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
157
|
computeRetryAfter(attempts) {
|
|
159
158
|
return (((Math.pow(2, attempts) - 1) / 2) * 500) + 500;
|
|
160
159
|
}
|
|
@@ -395,9 +394,8 @@ export class RpcRequest {
|
|
|
395
394
|
}
|
|
396
395
|
async setHeaders() {
|
|
397
396
|
const versionHeader = this.protocol.protocolVersionHeaderName;
|
|
398
|
-
if (versionHeader && RpcProtocol.protocolVersion
|
|
397
|
+
if (versionHeader && RpcProtocol.protocolVersion)
|
|
399
398
|
this.setHeader(versionHeader, RpcProtocol.protocolVersion.toString());
|
|
400
|
-
}
|
|
401
399
|
const headerNames = this.protocol.serializedClientRequestContextHeaderNames;
|
|
402
400
|
const headerValues = await RpcConfiguration.requestContext.serialize(this);
|
|
403
401
|
if (headerNames.id)
|