@itwin/core-common 3.2.0-dev.8 → 3.3.0-dev.1
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 +38 -1
- package/lib/cjs/AnalysisStyle.d.ts +3 -0
- package/lib/cjs/AnalysisStyle.d.ts.map +1 -1
- package/lib/cjs/AnalysisStyle.js.map +1 -1
- package/lib/cjs/BackgroundMapProvider.d.ts +6 -0
- package/lib/cjs/BackgroundMapProvider.d.ts.map +1 -1
- package/lib/cjs/BackgroundMapProvider.js +10 -0
- package/lib/cjs/BackgroundMapProvider.js.map +1 -1
- package/lib/cjs/BackgroundMapSettings.d.ts +4 -0
- package/lib/cjs/BackgroundMapSettings.d.ts.map +1 -1
- package/lib/cjs/BackgroundMapSettings.js +1 -0
- package/lib/cjs/BackgroundMapSettings.js.map +1 -1
- package/lib/cjs/Base64EncodedString.d.ts +1 -0
- package/lib/cjs/Base64EncodedString.d.ts.map +1 -1
- package/lib/cjs/Base64EncodedString.js.map +1 -1
- package/lib/cjs/BriefcaseTypes.d.ts +5 -0
- package/lib/cjs/BriefcaseTypes.d.ts.map +1 -1
- package/lib/cjs/BriefcaseTypes.js +2 -0
- package/lib/cjs/BriefcaseTypes.js.map +1 -1
- package/lib/cjs/Camera.d.ts +1 -0
- package/lib/cjs/Camera.d.ts.map +1 -1
- package/lib/cjs/Camera.js.map +1 -1
- package/lib/cjs/ChangedElements.d.ts +2 -0
- package/lib/cjs/ChangedElements.d.ts.map +1 -1
- package/lib/cjs/ChangedElements.js +1 -0
- package/lib/cjs/ChangedElements.js.map +1 -1
- package/lib/cjs/ChangedEntities.d.ts +3 -0
- package/lib/cjs/ChangedEntities.d.ts.map +1 -1
- package/lib/cjs/ChangedEntities.js.map +1 -1
- package/lib/cjs/ChangesetProps.d.ts +9 -1
- package/lib/cjs/ChangesetProps.d.ts.map +1 -1
- package/lib/cjs/ChangesetProps.js +3 -1
- package/lib/cjs/ChangesetProps.js.map +1 -1
- package/lib/cjs/ClipStyle.d.ts +2 -0
- package/lib/cjs/ClipStyle.d.ts.map +1 -1
- package/lib/cjs/ClipStyle.js.map +1 -1
- package/lib/cjs/CloudStorage.d.ts.map +1 -1
- package/lib/cjs/CloudStorage.js +14 -20
- package/lib/cjs/CloudStorage.js.map +1 -1
- package/lib/cjs/Code.d.ts +3 -0
- package/lib/cjs/Code.d.ts.map +1 -1
- package/lib/cjs/Code.js +1 -0
- package/lib/cjs/Code.js.map +1 -1
- package/lib/cjs/ColorByName.d.ts +153 -152
- package/lib/cjs/ColorByName.d.ts.map +1 -1
- package/lib/cjs/ColorByName.js +153 -153
- package/lib/cjs/ColorByName.js.map +1 -1
- package/lib/cjs/ColorDef.d.ts +55 -46
- package/lib/cjs/ColorDef.d.ts.map +1 -1
- package/lib/cjs/ColorDef.js +49 -31
- package/lib/cjs/ColorDef.js.map +1 -1
- package/lib/cjs/CommonLoggerCategory.d.ts +1 -0
- package/lib/cjs/CommonLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/CommonLoggerCategory.js +1 -0
- package/lib/cjs/CommonLoggerCategory.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts +6 -1
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +3 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/ContextRealityModel.d.ts +2 -0
- package/lib/cjs/ContextRealityModel.d.ts.map +1 -1
- package/lib/cjs/ContextRealityModel.js.map +1 -1
- package/lib/cjs/DisplayStyleSettings.d.ts +10 -0
- package/lib/cjs/DisplayStyleSettings.d.ts.map +1 -1
- package/lib/cjs/DisplayStyleSettings.js +1 -0
- package/lib/cjs/DisplayStyleSettings.js.map +1 -1
- package/lib/cjs/ECSqlTypes.d.ts +6 -0
- package/lib/cjs/ECSqlTypes.d.ts.map +1 -1
- package/lib/cjs/ECSqlTypes.js +4 -0
- package/lib/cjs/ECSqlTypes.js.map +1 -1
- package/lib/cjs/ElementProps.d.ts +37 -1
- package/lib/cjs/ElementProps.d.ts.map +1 -1
- package/lib/cjs/ElementProps.js +2 -0
- package/lib/cjs/ElementProps.js.map +1 -1
- package/lib/cjs/EmphasizeElementsProps.d.ts +3 -0
- package/lib/cjs/EmphasizeElementsProps.d.ts.map +1 -1
- package/lib/cjs/EmphasizeElementsProps.js +1 -0
- package/lib/cjs/EmphasizeElementsProps.js.map +1 -1
- package/lib/cjs/EntityProps.d.ts +4 -0
- package/lib/cjs/EntityProps.d.ts.map +1 -1
- package/lib/cjs/EntityProps.js.map +1 -1
- package/lib/cjs/Environment.d.ts +1 -0
- package/lib/cjs/Environment.d.ts.map +1 -1
- package/lib/cjs/Environment.js.map +1 -1
- package/lib/cjs/FeatureSymbology.d.ts +3 -0
- package/lib/cjs/FeatureSymbology.d.ts.map +1 -1
- package/lib/cjs/FeatureSymbology.js.map +1 -1
- package/lib/cjs/FeatureTable.d.ts +1 -0
- package/lib/cjs/FeatureTable.d.ts.map +1 -1
- package/lib/cjs/FeatureTable.js +1 -0
- package/lib/cjs/FeatureTable.js.map +1 -1
- package/lib/cjs/Fonts.d.ts +3 -0
- package/lib/cjs/Fonts.d.ts.map +1 -1
- package/lib/cjs/Fonts.js +1 -0
- package/lib/cjs/Fonts.js.map +1 -1
- package/lib/cjs/Frustum.d.ts +1 -0
- package/lib/cjs/Frustum.d.ts.map +1 -1
- package/lib/cjs/Frustum.js +1 -0
- package/lib/cjs/Frustum.js.map +1 -1
- package/lib/cjs/GeoCoordinateServices.d.ts +1 -0
- package/lib/cjs/GeoCoordinateServices.d.ts.map +1 -1
- package/lib/cjs/GeoCoordinateServices.js +1 -0
- package/lib/cjs/GeoCoordinateServices.js.map +1 -1
- package/lib/cjs/GeometryContainment.d.ts +2 -0
- package/lib/cjs/GeometryContainment.d.ts.map +1 -1
- package/lib/cjs/GeometryContainment.js.map +1 -1
- package/lib/cjs/GeometryParams.d.ts +3 -0
- package/lib/cjs/GeometryParams.d.ts.map +1 -1
- package/lib/cjs/GeometryParams.js +3 -0
- package/lib/cjs/GeometryParams.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts +3 -0
- package/lib/cjs/GeometrySummary.d.ts.map +1 -1
- package/lib/cjs/GeometrySummary.js +1 -0
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/GraphicParams.d.ts +1 -0
- package/lib/cjs/GraphicParams.d.ts.map +1 -1
- package/lib/cjs/GraphicParams.js +1 -0
- package/lib/cjs/GraphicParams.js.map +1 -1
- package/lib/cjs/GroundPlane.d.ts +1 -0
- package/lib/cjs/GroundPlane.d.ts.map +1 -1
- package/lib/cjs/GroundPlane.js.map +1 -1
- package/lib/cjs/HSVColor.d.ts +4 -1
- package/lib/cjs/HSVColor.d.ts.map +1 -1
- package/lib/cjs/HSVColor.js +4 -1
- package/lib/cjs/HSVColor.js.map +1 -1
- package/lib/cjs/HiddenLine.d.ts +12 -17
- package/lib/cjs/HiddenLine.d.ts.map +1 -1
- package/lib/cjs/HiddenLine.js +6 -2
- package/lib/cjs/HiddenLine.js.map +1 -1
- package/lib/cjs/IModel.d.ts +6 -1
- package/lib/cjs/IModel.d.ts.map +1 -1
- package/lib/cjs/IModel.js.map +1 -1
- package/lib/cjs/Image.d.ts +2 -0
- package/lib/cjs/Image.d.ts.map +1 -1
- package/lib/cjs/Image.js +2 -0
- package/lib/cjs/Image.js.map +1 -1
- package/lib/cjs/IpcAppProps.d.ts +1 -0
- package/lib/cjs/IpcAppProps.d.ts.map +1 -1
- package/lib/cjs/IpcAppProps.js.map +1 -1
- package/lib/cjs/LightSettings.d.ts +5 -0
- package/lib/cjs/LightSettings.d.ts.map +1 -1
- package/lib/cjs/LightSettings.js.map +1 -1
- package/lib/cjs/LinePixels.d.ts +1 -0
- package/lib/cjs/LinePixels.d.ts.map +1 -1
- package/lib/cjs/LinePixels.js +1 -0
- package/lib/cjs/LinePixels.js.map +1 -1
- package/lib/cjs/Localization.d.ts +1 -0
- package/lib/cjs/Localization.d.ts.map +1 -1
- package/lib/cjs/Localization.js.map +1 -1
- package/lib/cjs/MassProperties.d.ts +27 -1
- package/lib/cjs/MassProperties.d.ts.map +1 -1
- package/lib/cjs/MassProperties.js +1 -0
- package/lib/cjs/MassProperties.js.map +1 -1
- package/lib/cjs/MaterialProps.d.ts +6 -0
- package/lib/cjs/MaterialProps.d.ts.map +1 -1
- package/lib/cjs/MaterialProps.js +1 -0
- package/lib/cjs/MaterialProps.js.map +1 -1
- package/lib/cjs/ModelClipGroup.d.ts +1 -0
- package/lib/cjs/ModelClipGroup.d.ts.map +1 -1
- package/lib/cjs/ModelClipGroup.js.map +1 -1
- package/lib/cjs/ModelGeometryChanges.d.ts +9 -1
- package/lib/cjs/ModelGeometryChanges.d.ts.map +1 -1
- package/lib/cjs/ModelGeometryChanges.js.map +1 -1
- package/lib/cjs/ModelProps.d.ts +6 -0
- package/lib/cjs/ModelProps.d.ts.map +1 -1
- package/lib/cjs/ModelProps.js.map +1 -1
- package/lib/cjs/PlanProjectionSettings.d.ts +1 -0
- package/lib/cjs/PlanProjectionSettings.d.ts.map +1 -1
- package/lib/cjs/PlanProjectionSettings.js.map +1 -1
- package/lib/cjs/PlanarClipMask.d.ts +3 -0
- package/lib/cjs/PlanarClipMask.d.ts.map +1 -1
- package/lib/cjs/PlanarClipMask.js +2 -0
- package/lib/cjs/PlanarClipMask.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.map +1 -1
- package/lib/cjs/SessionProps.d.ts +1 -0
- package/lib/cjs/SessionProps.d.ts.map +1 -1
- package/lib/cjs/SessionProps.js.map +1 -1
- package/lib/cjs/SkyBox.d.ts +4 -0
- package/lib/cjs/SkyBox.d.ts.map +1 -1
- package/lib/cjs/SkyBox.js +1 -0
- package/lib/cjs/SkyBox.js.map +1 -1
- package/lib/cjs/SolarShadows.d.ts +1 -0
- package/lib/cjs/SolarShadows.d.ts.map +1 -1
- package/lib/cjs/SolarShadows.js.map +1 -1
- package/lib/cjs/SpatialClassification.d.ts +5 -0
- package/lib/cjs/SpatialClassification.d.ts.map +1 -1
- package/lib/cjs/SpatialClassification.js +2 -0
- package/lib/cjs/SpatialClassification.js.map +1 -1
- package/lib/cjs/TerrainSettings.d.ts +3 -0
- package/lib/cjs/TerrainSettings.d.ts.map +1 -1
- package/lib/cjs/TerrainSettings.js +1 -0
- package/lib/cjs/TerrainSettings.js.map +1 -1
- package/lib/cjs/TextureProps.d.ts +3 -0
- package/lib/cjs/TextureProps.d.ts.map +1 -1
- package/lib/cjs/TextureProps.js.map +1 -1
- package/lib/cjs/ThematicDisplay.d.ts +9 -1
- package/lib/cjs/ThematicDisplay.d.ts.map +1 -1
- package/lib/cjs/ThematicDisplay.js +5 -1
- package/lib/cjs/ThematicDisplay.js.map +1 -1
- package/lib/cjs/Thumbnail.d.ts +2 -0
- package/lib/cjs/Thumbnail.d.ts.map +1 -1
- package/lib/cjs/Thumbnail.js.map +1 -1
- package/lib/cjs/TileProps.d.ts +1 -0
- package/lib/cjs/TileProps.d.ts.map +1 -1
- package/lib/cjs/TileProps.js.map +1 -1
- package/lib/cjs/Tween.d.ts +16 -4
- package/lib/cjs/Tween.d.ts.map +1 -1
- package/lib/cjs/Tween.js.map +1 -1
- package/lib/cjs/TxnAction.d.ts +1 -0
- package/lib/cjs/TxnAction.d.ts.map +1 -1
- package/lib/cjs/TxnAction.js +1 -0
- package/lib/cjs/TxnAction.js.map +1 -1
- package/lib/cjs/ViewDetails.d.ts +3 -0
- package/lib/cjs/ViewDetails.d.ts.map +1 -1
- package/lib/cjs/ViewDetails.js +1 -0
- package/lib/cjs/ViewDetails.js.map +1 -1
- package/lib/cjs/ViewFlags.d.ts +4 -0
- package/lib/cjs/ViewFlags.d.ts.map +1 -1
- package/lib/cjs/ViewFlags.js +1 -0
- package/lib/cjs/ViewFlags.js.map +1 -1
- package/lib/cjs/ViewProps.d.ts +69 -3
- package/lib/cjs/ViewProps.d.ts.map +1 -1
- package/lib/cjs/ViewProps.js.map +1 -1
- package/lib/cjs/WhiteOnWhiteReversalSettings.d.ts +1 -0
- package/lib/cjs/WhiteOnWhiteReversalSettings.d.ts.map +1 -1
- package/lib/cjs/WhiteOnWhiteReversalSettings.js.map +1 -1
- package/lib/cjs/domains/FunctionalElementProps.d.ts +4 -1
- package/lib/cjs/domains/FunctionalElementProps.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElementProps.js.map +1 -1
- package/lib/cjs/domains/GenericElementProps.d.ts +8 -2
- package/lib/cjs/domains/GenericElementProps.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElementProps.js.map +1 -1
- package/lib/cjs/geometry/AdditionalTransform.d.ts +2 -0
- package/lib/cjs/geometry/AdditionalTransform.d.ts.map +1 -1
- package/lib/cjs/geometry/AdditionalTransform.js.map +1 -1
- package/lib/cjs/geometry/Cartographic.d.ts +1 -0
- package/lib/cjs/geometry/Cartographic.d.ts.map +1 -1
- package/lib/cjs/geometry/Cartographic.js.map +1 -1
- package/lib/cjs/geometry/CoordinateReferenceSystem.d.ts +5 -0
- package/lib/cjs/geometry/CoordinateReferenceSystem.d.ts.map +1 -1
- package/lib/cjs/geometry/CoordinateReferenceSystem.js.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.d.ts +2 -0
- package/lib/cjs/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.js +1 -0
- package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
- package/lib/cjs/geometry/GeodeticDatum.d.ts +80 -1
- package/lib/cjs/geometry/GeodeticDatum.d.ts.map +1 -1
- package/lib/cjs/geometry/GeodeticDatum.js +79 -1
- package/lib/cjs/geometry/GeodeticDatum.js.map +1 -1
- package/lib/cjs/geometry/GeodeticEllipsoid.d.ts +1 -0
- package/lib/cjs/geometry/GeodeticEllipsoid.d.ts.map +1 -1
- package/lib/cjs/geometry/GeodeticEllipsoid.js.map +1 -1
- package/lib/cjs/geometry/GeometryStream.d.ts +15 -0
- package/lib/cjs/geometry/GeometryStream.d.ts.map +1 -1
- package/lib/cjs/geometry/GeometryStream.js +11 -7
- package/lib/cjs/geometry/GeometryStream.js.map +1 -1
- package/lib/cjs/geometry/ImageGraphic.d.ts +2 -0
- package/lib/cjs/geometry/ImageGraphic.d.ts.map +1 -1
- package/lib/cjs/geometry/ImageGraphic.js.map +1 -1
- package/lib/cjs/geometry/Placement.d.ts +6 -0
- package/lib/cjs/geometry/Placement.d.ts.map +1 -1
- package/lib/cjs/geometry/Placement.js.map +1 -1
- package/lib/cjs/geometry/Projection.d.ts +6 -0
- package/lib/cjs/geometry/Projection.d.ts.map +1 -1
- package/lib/cjs/geometry/Projection.js.map +1 -1
- package/lib/cjs/geometry/TextString.d.ts +1 -0
- package/lib/cjs/geometry/TextString.d.ts.map +1 -1
- package/lib/cjs/geometry/TextString.js.map +1 -1
- package/lib/cjs/ipc/IpcSocket.d.ts +1 -0
- package/lib/cjs/ipc/IpcSocket.d.ts.map +1 -1
- package/lib/cjs/ipc/IpcSocket.js.map +1 -1
- package/lib/cjs/ipc/IpcWebSocketTransport.d.ts.map +1 -1
- package/lib/cjs/ipc/IpcWebSocketTransport.js +3 -2
- package/lib/cjs/ipc/IpcWebSocketTransport.js.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts +5 -2
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.js +4 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/IModelTileRpcInterface.d.ts +4 -2
- package/lib/cjs/rpc/IModelTileRpcInterface.d.ts.map +1 -1
- package/lib/cjs/rpc/IModelTileRpcInterface.js +4 -2
- package/lib/cjs/rpc/IModelTileRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/core/RpcControl.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcControl.js +3 -2
- package/lib/cjs/rpc/core/RpcControl.js.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.d.ts +3 -0
- package/lib/cjs/rpc/core/RpcInvocation.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.js +33 -7
- package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/cjs/rpc/core/RpcMarshaling.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcMarshaling.js +2 -1
- package/lib/cjs/rpc/core/RpcMarshaling.js.map +1 -1
- package/lib/cjs/rpc/core/RpcOperation.d.ts +2 -0
- package/lib/cjs/rpc/core/RpcOperation.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcOperation.js +2 -0
- package/lib/cjs/rpc/core/RpcOperation.js.map +1 -1
- package/lib/cjs/rpc/core/RpcProtocol.d.ts +22 -1
- package/lib/cjs/rpc/core/RpcProtocol.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcProtocol.js +13 -2
- package/lib/cjs/rpc/core/RpcProtocol.js.map +1 -1
- package/lib/cjs/rpc/core/RpcRequest.d.ts +3 -0
- package/lib/cjs/rpc/core/RpcRequest.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcRequest.js +35 -1
- package/lib/cjs/rpc/core/RpcRequest.js.map +1 -1
- package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.d.ts.map +1 -1
- package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js +1 -2
- package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
- package/lib/cjs/rpc/web/RpcMultipart.d.ts +1 -0
- package/lib/cjs/rpc/web/RpcMultipart.d.ts.map +1 -1
- package/lib/cjs/rpc/web/RpcMultipart.js +2 -1
- package/lib/cjs/rpc/web/RpcMultipart.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcLogging.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcLogging.js +14 -10
- package/lib/cjs/rpc/web/WebAppRpcLogging.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts +1 -0
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js +3 -2
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts +5 -6
- package/lib/cjs/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcRequest.js +49 -27
- package/lib/cjs/rpc/web/WebAppRpcRequest.js.map +1 -1
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts +1 -0
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js +4 -3
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
- package/lib/cjs/tile/ElementGraphics.d.ts +16 -2
- 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/cjs/tile/TileMetadata.d.ts +18 -13
- package/lib/cjs/tile/TileMetadata.d.ts.map +1 -1
- package/lib/cjs/tile/TileMetadata.js +164 -134
- package/lib/cjs/tile/TileMetadata.js.map +1 -1
- package/lib/esm/AnalysisStyle.d.ts +3 -0
- package/lib/esm/AnalysisStyle.d.ts.map +1 -1
- package/lib/esm/AnalysisStyle.js.map +1 -1
- package/lib/esm/BackgroundMapProvider.d.ts +6 -0
- package/lib/esm/BackgroundMapProvider.d.ts.map +1 -1
- package/lib/esm/BackgroundMapProvider.js +10 -0
- package/lib/esm/BackgroundMapProvider.js.map +1 -1
- package/lib/esm/BackgroundMapSettings.d.ts +4 -0
- package/lib/esm/BackgroundMapSettings.d.ts.map +1 -1
- package/lib/esm/BackgroundMapSettings.js +1 -0
- package/lib/esm/BackgroundMapSettings.js.map +1 -1
- package/lib/esm/Base64EncodedString.d.ts +1 -0
- package/lib/esm/Base64EncodedString.d.ts.map +1 -1
- package/lib/esm/Base64EncodedString.js.map +1 -1
- package/lib/esm/BriefcaseTypes.d.ts +5 -0
- package/lib/esm/BriefcaseTypes.d.ts.map +1 -1
- package/lib/esm/BriefcaseTypes.js +2 -0
- package/lib/esm/BriefcaseTypes.js.map +1 -1
- package/lib/esm/Camera.d.ts +1 -0
- package/lib/esm/Camera.d.ts.map +1 -1
- package/lib/esm/Camera.js.map +1 -1
- package/lib/esm/ChangedElements.d.ts +2 -0
- package/lib/esm/ChangedElements.d.ts.map +1 -1
- package/lib/esm/ChangedElements.js +1 -0
- package/lib/esm/ChangedElements.js.map +1 -1
- package/lib/esm/ChangedEntities.d.ts +3 -0
- package/lib/esm/ChangedEntities.d.ts.map +1 -1
- package/lib/esm/ChangedEntities.js.map +1 -1
- package/lib/esm/ChangesetProps.d.ts +9 -1
- package/lib/esm/ChangesetProps.d.ts.map +1 -1
- package/lib/esm/ChangesetProps.js +3 -1
- package/lib/esm/ChangesetProps.js.map +1 -1
- package/lib/esm/ClipStyle.d.ts +2 -0
- package/lib/esm/ClipStyle.d.ts.map +1 -1
- package/lib/esm/ClipStyle.js.map +1 -1
- package/lib/esm/CloudStorage.d.ts.map +1 -1
- package/lib/esm/CloudStorage.js +14 -20
- package/lib/esm/CloudStorage.js.map +1 -1
- package/lib/esm/Code.d.ts +3 -0
- package/lib/esm/Code.d.ts.map +1 -1
- package/lib/esm/Code.js +1 -0
- package/lib/esm/Code.js.map +1 -1
- package/lib/esm/ColorByName.d.ts +153 -152
- package/lib/esm/ColorByName.d.ts.map +1 -1
- package/lib/esm/ColorByName.js +153 -153
- package/lib/esm/ColorByName.js.map +1 -1
- package/lib/esm/ColorDef.d.ts +55 -46
- package/lib/esm/ColorDef.d.ts.map +1 -1
- package/lib/esm/ColorDef.js +49 -31
- package/lib/esm/ColorDef.js.map +1 -1
- package/lib/esm/CommonLoggerCategory.d.ts +1 -0
- package/lib/esm/CommonLoggerCategory.d.ts.map +1 -1
- package/lib/esm/CommonLoggerCategory.js +1 -0
- package/lib/esm/CommonLoggerCategory.js.map +1 -1
- package/lib/esm/ConcurrentQuery.d.ts +6 -1
- package/lib/esm/ConcurrentQuery.d.ts.map +1 -1
- package/lib/esm/ConcurrentQuery.js +2 -0
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/ContextRealityModel.d.ts +2 -0
- package/lib/esm/ContextRealityModel.d.ts.map +1 -1
- package/lib/esm/ContextRealityModel.js.map +1 -1
- package/lib/esm/DisplayStyleSettings.d.ts +10 -0
- package/lib/esm/DisplayStyleSettings.d.ts.map +1 -1
- package/lib/esm/DisplayStyleSettings.js +1 -0
- package/lib/esm/DisplayStyleSettings.js.map +1 -1
- package/lib/esm/ECSqlTypes.d.ts +6 -0
- package/lib/esm/ECSqlTypes.d.ts.map +1 -1
- package/lib/esm/ECSqlTypes.js +4 -0
- package/lib/esm/ECSqlTypes.js.map +1 -1
- package/lib/esm/ElementProps.d.ts +37 -1
- package/lib/esm/ElementProps.d.ts.map +1 -1
- package/lib/esm/ElementProps.js +2 -0
- package/lib/esm/ElementProps.js.map +1 -1
- package/lib/esm/EmphasizeElementsProps.d.ts +3 -0
- package/lib/esm/EmphasizeElementsProps.d.ts.map +1 -1
- package/lib/esm/EmphasizeElementsProps.js +1 -0
- package/lib/esm/EmphasizeElementsProps.js.map +1 -1
- package/lib/esm/EntityProps.d.ts +4 -0
- package/lib/esm/EntityProps.d.ts.map +1 -1
- package/lib/esm/EntityProps.js.map +1 -1
- package/lib/esm/Environment.d.ts +1 -0
- package/lib/esm/Environment.d.ts.map +1 -1
- package/lib/esm/Environment.js.map +1 -1
- package/lib/esm/FeatureSymbology.d.ts +3 -0
- package/lib/esm/FeatureSymbology.d.ts.map +1 -1
- package/lib/esm/FeatureSymbology.js.map +1 -1
- package/lib/esm/FeatureTable.d.ts +1 -0
- package/lib/esm/FeatureTable.d.ts.map +1 -1
- package/lib/esm/FeatureTable.js +1 -0
- package/lib/esm/FeatureTable.js.map +1 -1
- package/lib/esm/Fonts.d.ts +3 -0
- package/lib/esm/Fonts.d.ts.map +1 -1
- package/lib/esm/Fonts.js +1 -0
- package/lib/esm/Fonts.js.map +1 -1
- package/lib/esm/Frustum.d.ts +1 -0
- package/lib/esm/Frustum.d.ts.map +1 -1
- package/lib/esm/Frustum.js +1 -0
- package/lib/esm/Frustum.js.map +1 -1
- package/lib/esm/GeoCoordinateServices.d.ts +1 -0
- package/lib/esm/GeoCoordinateServices.d.ts.map +1 -1
- package/lib/esm/GeoCoordinateServices.js +1 -0
- package/lib/esm/GeoCoordinateServices.js.map +1 -1
- package/lib/esm/GeometryContainment.d.ts +2 -0
- package/lib/esm/GeometryContainment.d.ts.map +1 -1
- package/lib/esm/GeometryContainment.js.map +1 -1
- package/lib/esm/GeometryParams.d.ts +3 -0
- package/lib/esm/GeometryParams.d.ts.map +1 -1
- package/lib/esm/GeometryParams.js +3 -0
- package/lib/esm/GeometryParams.js.map +1 -1
- package/lib/esm/GeometrySummary.d.ts +3 -0
- package/lib/esm/GeometrySummary.d.ts.map +1 -1
- package/lib/esm/GeometrySummary.js +1 -0
- package/lib/esm/GeometrySummary.js.map +1 -1
- package/lib/esm/GraphicParams.d.ts +1 -0
- package/lib/esm/GraphicParams.d.ts.map +1 -1
- package/lib/esm/GraphicParams.js +1 -0
- package/lib/esm/GraphicParams.js.map +1 -1
- package/lib/esm/GroundPlane.d.ts +1 -0
- package/lib/esm/GroundPlane.d.ts.map +1 -1
- package/lib/esm/GroundPlane.js.map +1 -1
- package/lib/esm/HSVColor.d.ts +4 -1
- package/lib/esm/HSVColor.d.ts.map +1 -1
- package/lib/esm/HSVColor.js +4 -1
- package/lib/esm/HSVColor.js.map +1 -1
- package/lib/esm/HiddenLine.d.ts +12 -17
- package/lib/esm/HiddenLine.d.ts.map +1 -1
- package/lib/esm/HiddenLine.js +6 -2
- package/lib/esm/HiddenLine.js.map +1 -1
- package/lib/esm/IModel.d.ts +6 -1
- package/lib/esm/IModel.d.ts.map +1 -1
- package/lib/esm/IModel.js.map +1 -1
- package/lib/esm/Image.d.ts +2 -0
- package/lib/esm/Image.d.ts.map +1 -1
- package/lib/esm/Image.js +2 -0
- package/lib/esm/Image.js.map +1 -1
- package/lib/esm/IpcAppProps.d.ts +1 -0
- package/lib/esm/IpcAppProps.d.ts.map +1 -1
- package/lib/esm/IpcAppProps.js.map +1 -1
- package/lib/esm/LightSettings.d.ts +5 -0
- package/lib/esm/LightSettings.d.ts.map +1 -1
- package/lib/esm/LightSettings.js.map +1 -1
- package/lib/esm/LinePixels.d.ts +1 -0
- package/lib/esm/LinePixels.d.ts.map +1 -1
- package/lib/esm/LinePixels.js +1 -0
- package/lib/esm/LinePixels.js.map +1 -1
- package/lib/esm/Localization.d.ts +1 -0
- package/lib/esm/Localization.d.ts.map +1 -1
- package/lib/esm/Localization.js.map +1 -1
- package/lib/esm/MassProperties.d.ts +27 -1
- package/lib/esm/MassProperties.d.ts.map +1 -1
- package/lib/esm/MassProperties.js +1 -0
- package/lib/esm/MassProperties.js.map +1 -1
- package/lib/esm/MaterialProps.d.ts +6 -0
- package/lib/esm/MaterialProps.d.ts.map +1 -1
- package/lib/esm/MaterialProps.js +1 -0
- package/lib/esm/MaterialProps.js.map +1 -1
- package/lib/esm/ModelClipGroup.d.ts +1 -0
- package/lib/esm/ModelClipGroup.d.ts.map +1 -1
- package/lib/esm/ModelClipGroup.js.map +1 -1
- package/lib/esm/ModelGeometryChanges.d.ts +9 -1
- package/lib/esm/ModelGeometryChanges.d.ts.map +1 -1
- package/lib/esm/ModelGeometryChanges.js.map +1 -1
- package/lib/esm/ModelProps.d.ts +6 -0
- package/lib/esm/ModelProps.d.ts.map +1 -1
- package/lib/esm/ModelProps.js.map +1 -1
- package/lib/esm/PlanProjectionSettings.d.ts +1 -0
- package/lib/esm/PlanProjectionSettings.d.ts.map +1 -1
- package/lib/esm/PlanProjectionSettings.js.map +1 -1
- package/lib/esm/PlanarClipMask.d.ts +3 -0
- package/lib/esm/PlanarClipMask.d.ts.map +1 -1
- package/lib/esm/PlanarClipMask.js +2 -0
- package/lib/esm/PlanarClipMask.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.map +1 -1
- package/lib/esm/SessionProps.d.ts +1 -0
- package/lib/esm/SessionProps.d.ts.map +1 -1
- package/lib/esm/SessionProps.js.map +1 -1
- package/lib/esm/SkyBox.d.ts +4 -0
- package/lib/esm/SkyBox.d.ts.map +1 -1
- package/lib/esm/SkyBox.js +1 -0
- package/lib/esm/SkyBox.js.map +1 -1
- package/lib/esm/SolarShadows.d.ts +1 -0
- package/lib/esm/SolarShadows.d.ts.map +1 -1
- package/lib/esm/SolarShadows.js.map +1 -1
- package/lib/esm/SpatialClassification.d.ts +5 -0
- package/lib/esm/SpatialClassification.d.ts.map +1 -1
- package/lib/esm/SpatialClassification.js +2 -0
- package/lib/esm/SpatialClassification.js.map +1 -1
- package/lib/esm/TerrainSettings.d.ts +3 -0
- package/lib/esm/TerrainSettings.d.ts.map +1 -1
- package/lib/esm/TerrainSettings.js +1 -0
- package/lib/esm/TerrainSettings.js.map +1 -1
- package/lib/esm/TextureProps.d.ts +3 -0
- package/lib/esm/TextureProps.d.ts.map +1 -1
- package/lib/esm/TextureProps.js.map +1 -1
- package/lib/esm/ThematicDisplay.d.ts +9 -1
- package/lib/esm/ThematicDisplay.d.ts.map +1 -1
- package/lib/esm/ThematicDisplay.js +5 -1
- package/lib/esm/ThematicDisplay.js.map +1 -1
- package/lib/esm/Thumbnail.d.ts +2 -0
- package/lib/esm/Thumbnail.d.ts.map +1 -1
- package/lib/esm/Thumbnail.js.map +1 -1
- package/lib/esm/TileProps.d.ts +1 -0
- package/lib/esm/TileProps.d.ts.map +1 -1
- package/lib/esm/TileProps.js.map +1 -1
- package/lib/esm/Tween.d.ts +16 -4
- package/lib/esm/Tween.d.ts.map +1 -1
- package/lib/esm/Tween.js.map +1 -1
- package/lib/esm/TxnAction.d.ts +1 -0
- package/lib/esm/TxnAction.d.ts.map +1 -1
- package/lib/esm/TxnAction.js +1 -0
- package/lib/esm/TxnAction.js.map +1 -1
- package/lib/esm/ViewDetails.d.ts +3 -0
- package/lib/esm/ViewDetails.d.ts.map +1 -1
- package/lib/esm/ViewDetails.js +1 -0
- package/lib/esm/ViewDetails.js.map +1 -1
- package/lib/esm/ViewFlags.d.ts +4 -0
- package/lib/esm/ViewFlags.d.ts.map +1 -1
- package/lib/esm/ViewFlags.js +1 -0
- package/lib/esm/ViewFlags.js.map +1 -1
- package/lib/esm/ViewProps.d.ts +69 -3
- package/lib/esm/ViewProps.d.ts.map +1 -1
- package/lib/esm/ViewProps.js.map +1 -1
- package/lib/esm/WhiteOnWhiteReversalSettings.d.ts +1 -0
- package/lib/esm/WhiteOnWhiteReversalSettings.d.ts.map +1 -1
- package/lib/esm/WhiteOnWhiteReversalSettings.js.map +1 -1
- package/lib/esm/domains/FunctionalElementProps.d.ts +4 -1
- package/lib/esm/domains/FunctionalElementProps.d.ts.map +1 -1
- package/lib/esm/domains/FunctionalElementProps.js.map +1 -1
- package/lib/esm/domains/GenericElementProps.d.ts +8 -2
- package/lib/esm/domains/GenericElementProps.d.ts.map +1 -1
- package/lib/esm/domains/GenericElementProps.js.map +1 -1
- package/lib/esm/geometry/AdditionalTransform.d.ts +2 -0
- package/lib/esm/geometry/AdditionalTransform.d.ts.map +1 -1
- package/lib/esm/geometry/AdditionalTransform.js.map +1 -1
- package/lib/esm/geometry/Cartographic.d.ts +1 -0
- package/lib/esm/geometry/Cartographic.d.ts.map +1 -1
- package/lib/esm/geometry/Cartographic.js.map +1 -1
- package/lib/esm/geometry/CoordinateReferenceSystem.d.ts +5 -0
- package/lib/esm/geometry/CoordinateReferenceSystem.d.ts.map +1 -1
- package/lib/esm/geometry/CoordinateReferenceSystem.js.map +1 -1
- package/lib/esm/geometry/ElementGeometry.d.ts +2 -0
- package/lib/esm/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/esm/geometry/ElementGeometry.js +1 -0
- package/lib/esm/geometry/ElementGeometry.js.map +1 -1
- package/lib/esm/geometry/GeodeticDatum.d.ts +80 -1
- package/lib/esm/geometry/GeodeticDatum.d.ts.map +1 -1
- package/lib/esm/geometry/GeodeticDatum.js +77 -0
- package/lib/esm/geometry/GeodeticDatum.js.map +1 -1
- package/lib/esm/geometry/GeodeticEllipsoid.d.ts +1 -0
- package/lib/esm/geometry/GeodeticEllipsoid.d.ts.map +1 -1
- package/lib/esm/geometry/GeodeticEllipsoid.js.map +1 -1
- package/lib/esm/geometry/GeometryStream.d.ts +15 -0
- package/lib/esm/geometry/GeometryStream.d.ts.map +1 -1
- package/lib/esm/geometry/GeometryStream.js +11 -7
- package/lib/esm/geometry/GeometryStream.js.map +1 -1
- package/lib/esm/geometry/ImageGraphic.d.ts +2 -0
- package/lib/esm/geometry/ImageGraphic.d.ts.map +1 -1
- package/lib/esm/geometry/ImageGraphic.js.map +1 -1
- package/lib/esm/geometry/Placement.d.ts +6 -0
- package/lib/esm/geometry/Placement.d.ts.map +1 -1
- package/lib/esm/geometry/Placement.js.map +1 -1
- package/lib/esm/geometry/Projection.d.ts +6 -0
- package/lib/esm/geometry/Projection.d.ts.map +1 -1
- package/lib/esm/geometry/Projection.js.map +1 -1
- package/lib/esm/geometry/TextString.d.ts +1 -0
- package/lib/esm/geometry/TextString.d.ts.map +1 -1
- package/lib/esm/geometry/TextString.js.map +1 -1
- package/lib/esm/ipc/IpcSocket.d.ts +1 -0
- package/lib/esm/ipc/IpcSocket.d.ts.map +1 -1
- package/lib/esm/ipc/IpcSocket.js.map +1 -1
- package/lib/esm/ipc/IpcWebSocketTransport.d.ts.map +1 -1
- package/lib/esm/ipc/IpcWebSocketTransport.js +1 -0
- package/lib/esm/ipc/IpcWebSocketTransport.js.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts +5 -2
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js +4 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/esm/rpc/IModelTileRpcInterface.d.ts +4 -2
- package/lib/esm/rpc/IModelTileRpcInterface.d.ts.map +1 -1
- package/lib/esm/rpc/IModelTileRpcInterface.js +4 -2
- package/lib/esm/rpc/IModelTileRpcInterface.js.map +1 -1
- package/lib/esm/rpc/core/RpcControl.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcControl.js +1 -0
- package/lib/esm/rpc/core/RpcControl.js.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.d.ts +3 -0
- package/lib/esm/rpc/core/RpcInvocation.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.js +35 -9
- package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/esm/rpc/core/RpcMarshaling.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcMarshaling.js +1 -0
- package/lib/esm/rpc/core/RpcMarshaling.js.map +1 -1
- package/lib/esm/rpc/core/RpcOperation.d.ts +2 -0
- package/lib/esm/rpc/core/RpcOperation.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcOperation.js +2 -0
- package/lib/esm/rpc/core/RpcOperation.js.map +1 -1
- package/lib/esm/rpc/core/RpcProtocol.d.ts +22 -1
- package/lib/esm/rpc/core/RpcProtocol.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcProtocol.js +12 -1
- package/lib/esm/rpc/core/RpcProtocol.js.map +1 -1
- package/lib/esm/rpc/core/RpcRequest.d.ts +3 -0
- package/lib/esm/rpc/core/RpcRequest.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcRequest.js +36 -2
- package/lib/esm/rpc/core/RpcRequest.js.map +1 -1
- package/lib/esm/rpc/web/BentleyCloudRpcProtocol.d.ts.map +1 -1
- package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js +0 -1
- package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
- package/lib/esm/rpc/web/RpcMultipart.d.ts +1 -0
- package/lib/esm/rpc/web/RpcMultipart.d.ts.map +1 -1
- package/lib/esm/rpc/web/RpcMultipart.js +1 -0
- package/lib/esm/rpc/web/RpcMultipart.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcLogging.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcLogging.js +14 -10
- package/lib/esm/rpc/web/WebAppRpcLogging.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts +1 -0
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.js +3 -2
- package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.d.ts +5 -6
- package/lib/esm/rpc/web/WebAppRpcRequest.d.ts.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcRequest.js +47 -25
- package/lib/esm/rpc/web/WebAppRpcRequest.js.map +1 -1
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts +1 -0
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.js +1 -0
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.js.map +1 -1
- package/lib/esm/tile/ElementGraphics.d.ts +16 -2
- 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/lib/esm/tile/TileMetadata.d.ts +18 -13
- package/lib/esm/tile/TileMetadata.d.ts.map +1 -1
- package/lib/esm/tile/TileMetadata.js +163 -133
- package/lib/esm/tile/TileMetadata.js.map +1 -1
- package/package.json +25 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcLogging.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"WebAppRpcLogging.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAqBhD,gBAAgB;AAChB,qBAAa,gBAAgB;WACP,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBhH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAIlC,OAAO,CAAC,MAAM,CAAC,WAAW;IAmB1B,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAUvC,OAAO,CAAC,MAAM,CAAC,UAAU;IAiBzB,OAAO,CAAC,MAAM,CAAC,WAAW;IAkB1B,OAAO,CAAC,MAAM,CAAC,gBAAgB;mBAcV,eAAe;CAiBrC"}
|
|
@@ -13,20 +13,24 @@ const CommonLoggerCategory_1 = require("../../CommonLoggerCategory");
|
|
|
13
13
|
const RpcConstants_1 = require("../core/RpcConstants");
|
|
14
14
|
const RpcInvocation_1 = require("../core/RpcInvocation");
|
|
15
15
|
const WebAppRpcRequest_1 = require("./WebAppRpcRequest");
|
|
16
|
-
|
|
17
|
-
const os = (typeof (process) !== "undefined") ? require("os") : undefined;
|
|
16
|
+
let hostname = "";
|
|
18
17
|
function getHostname() {
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return window.location.host;
|
|
18
|
+
if (!hostname) {
|
|
19
|
+
try {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
21
|
+
const os = require("os");
|
|
22
|
+
hostname = os.hostname();
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
catch (_) {
|
|
25
|
+
if (globalThis.window) {
|
|
26
|
+
hostname = globalThis.window.location.host;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
hostname = "imodeljs-mobile";
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
}
|
|
33
|
+
return hostname;
|
|
30
34
|
}
|
|
31
35
|
/** @internal */
|
|
32
36
|
class WebAppRpcLogging {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcLogging.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,qEAAkE;AAElE,uDAAwD;AACxD,yDAAsD;AAItD,yDAAsD;AAEtD,8DAA8D;AAC9D,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1E,SAAS,WAAW;IAClB,IAAI,EAAE,KAAK,SAAS,EAAE;QACpB,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;KACtB;SAAM;QACL,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,WAAW,EAAE;YACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;SAC7B;aAAM;YACL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AC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,2CAA2C;QAElH,qBAAM,CAAC,OAAO,CAAC,2CAAoB,CAAC,mBAAmB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACnG,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,MAAM;YACjC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI;YAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,YAAY;YACZ,uGAAuG;YACvG,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;YACjC,WAAW,EAAE,WAAW,EAAE;YAC1B,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AArHD,4CAqHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcProtocolEvent } from \"../core/RpcConstants\";\r\nimport { RpcInvocation } from \"../core/RpcInvocation\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nconst os = (typeof (process) !== \"undefined\") ? require(\"os\") : undefined;\r\nfunction getHostname(): string {\r\n if (os !== undefined) {\r\n return os.hostname();\r\n } else {\r\n if (typeof (window) !== \"undefined\") {\r\n return window.location.host;\r\n } else {\r\n return \"imodeljs-mobile\";\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class WebAppRpcLogging {\r\n public static async logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void> {\r\n if (object instanceof WebAppRpcRequest) {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestCreated: return WebAppRpcLogging.logRequest(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.request\", object);\r\n case RpcProtocolEvent.ResponseLoaded: return WebAppRpcLogging.logResponse(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.response\", object, object.metadata.status, object.elapsed);\r\n case RpcProtocolEvent.ConnectionErrorReceived: return WebAppRpcLogging.logErrorFrontend(\"RpcInterface.frontend.connectionError\", object);\r\n case RpcProtocolEvent.ConnectionAborted: return WebAppRpcLogging.logErrorFrontend(\"RpcInterface.frontend.connectionAborted\", object);\r\n }\r\n } else if (object instanceof RpcInvocation) {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestReceived: return WebAppRpcLogging.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\r\n case RpcProtocolEvent.BackendErrorOccurred: return WebAppRpcLogging.logErrorBackend(\"RpcInterface.backend.error\", object);\r\n case RpcProtocolEvent.BackendResponseCreated: return WebAppRpcLogging.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\r\n }\r\n }\r\n }\r\n\r\n private static getRpcInterfaceName(g: string | RpcInterfaceDefinition): string {\r\n return (typeof g === \"string\") ? g : g.interfaceName;\r\n }\r\n\r\n private static findPathIds(path: string) {\r\n let iTwinId = \"\";\r\n let iModelId = \"\";\r\n\r\n const tokens = path.split(\"/\");\r\n for (let i = 0; i !== tokens.length; ++i) {\r\n // For backwards compatibility, find old \"context\" or current \"iTwin\" terminology\r\n if ((/^context$/i).test(tokens[i]) || (/^itwin$/i).test(tokens[i])) {\r\n iTwinId = tokens[i + 1] || \"\";\r\n }\r\n\r\n if ((/^imodel$/i).test(tokens[i])) {\r\n iModelId = tokens[i + 1] || \"\";\r\n }\r\n }\r\n\r\n return { iTwinId, iModelId };\r\n }\r\n\r\n private static buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string {\r\n if (!operation) {\r\n return \"unknown.unknown\";\r\n }\r\n\r\n const interfaceName = typeof (operation.interfaceDefinition) === \"string\" ? operation.interfaceDefinition : operation.interfaceDefinition.interfaceName;\r\n const operationName = operation.operationName;\r\n return `${interfaceName}.${operationName}`;\r\n }\r\n\r\n private static logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(object.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(object.path);\r\n\r\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\r\n method: object.method,\r\n path: object.path,\r\n operation: object.operation.operationName,\r\n rpcInterface: WebAppRpcLogging.getRpcInterfaceName(object.operation.interfaceDefinition),\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n TimeElapsed: (\"elapsed\" in object) ? object.elapsed : 0, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(object.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(object.path);\r\n\r\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\r\n method: object.method,\r\n path: object.path,\r\n operation: object.operation.operationName,\r\n rpcInterface: WebAppRpcLogging.getRpcInterfaceName(object.operation.interfaceDefinition),\r\n status,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n TimeElapsed: elapsed, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static logErrorFrontend(message: string, request: WebAppRpcRequest): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(request.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(request.path);\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({\r\n method: request.method,\r\n path: request.path,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(invocation.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(invocation.request.path);\r\n const result = await invocation.result;\r\n const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({\r\n method: invocation.request.method,\r\n path: invocation.request.path,\r\n status: invocation.status,\r\n errorMessage,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: invocation.request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n}\r\n"]}
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CAAC,CAAC;IACN,CAAC;CACF;AArHD,4CAqHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcProtocolEvent } from \"../core/RpcConstants\";\r\nimport { RpcInvocation } from \"../core/RpcInvocation\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\n\r\nlet hostname = \"\";\r\nfunction getHostname(): string {\r\n if (!hostname) {\r\n try {\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const os = require(\"os\");\r\n hostname = os.hostname();\r\n } catch (_) {\r\n if (globalThis.window) {\r\n hostname = globalThis.window.location.host;\r\n } else {\r\n hostname = \"imodeljs-mobile\";\r\n }\r\n }\r\n }\r\n return hostname;\r\n}\r\n\r\n/** @internal */\r\nexport class WebAppRpcLogging {\r\n public static async logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void> {\r\n if (object instanceof WebAppRpcRequest) {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestCreated: return WebAppRpcLogging.logRequest(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.request\", object);\r\n case RpcProtocolEvent.ResponseLoaded: return WebAppRpcLogging.logResponse(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.response\", object, object.metadata.status, object.elapsed);\r\n case RpcProtocolEvent.ConnectionErrorReceived: return WebAppRpcLogging.logErrorFrontend(\"RpcInterface.frontend.connectionError\", object);\r\n case RpcProtocolEvent.ConnectionAborted: return WebAppRpcLogging.logErrorFrontend(\"RpcInterface.frontend.connectionAborted\", object);\r\n }\r\n } else if (object instanceof RpcInvocation) {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestReceived: return WebAppRpcLogging.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\r\n case RpcProtocolEvent.BackendErrorOccurred: return WebAppRpcLogging.logErrorBackend(\"RpcInterface.backend.error\", object);\r\n case RpcProtocolEvent.BackendResponseCreated: return WebAppRpcLogging.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\r\n }\r\n }\r\n }\r\n\r\n private static getRpcInterfaceName(g: string | RpcInterfaceDefinition): string {\r\n return (typeof g === \"string\") ? g : g.interfaceName;\r\n }\r\n\r\n private static findPathIds(path: string) {\r\n let iTwinId = \"\";\r\n let iModelId = \"\";\r\n\r\n const tokens = path.split(\"/\");\r\n for (let i = 0; i !== tokens.length; ++i) {\r\n // For backwards compatibility, find old \"context\" or current \"iTwin\" terminology\r\n if ((/^context$/i).test(tokens[i]) || (/^itwin$/i).test(tokens[i])) {\r\n iTwinId = tokens[i + 1] || \"\";\r\n }\r\n\r\n if ((/^imodel$/i).test(tokens[i])) {\r\n iModelId = tokens[i + 1] || \"\";\r\n }\r\n }\r\n\r\n return { iTwinId, iModelId };\r\n }\r\n\r\n private static buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string {\r\n if (!operation) {\r\n return \"unknown.unknown\";\r\n }\r\n\r\n const interfaceName = typeof (operation.interfaceDefinition) === \"string\" ? operation.interfaceDefinition : operation.interfaceDefinition.interfaceName;\r\n const operationName = operation.operationName;\r\n return `${interfaceName}.${operationName}`;\r\n }\r\n\r\n private static logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(object.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(object.path);\r\n\r\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\r\n method: object.method,\r\n path: object.path,\r\n operation: object.operation.operationName,\r\n rpcInterface: WebAppRpcLogging.getRpcInterfaceName(object.operation.interfaceDefinition),\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n TimeElapsed: (\"elapsed\" in object) ? object.elapsed : 0, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(object.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(object.path);\r\n\r\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\r\n method: object.method,\r\n path: object.path,\r\n operation: object.operation.operationName,\r\n rpcInterface: WebAppRpcLogging.getRpcInterfaceName(object.operation.interfaceDefinition),\r\n status,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n TimeElapsed: elapsed, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static logErrorFrontend(message: string, request: WebAppRpcRequest): void {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(request.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(request.path);\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({\r\n method: request.method,\r\n path: request.path,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n\r\n private static async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\r\n const operationDescriptor = WebAppRpcLogging.buildOperationDescriptor(invocation.operation);\r\n const pathIds = WebAppRpcLogging.findPathIds(invocation.request.path);\r\n const result = await invocation.result;\r\n const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({\r\n method: invocation.request.method,\r\n path: invocation.request.path,\r\n status: invocation.status,\r\n errorMessage,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: invocation.request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n}\r\n"]}
|
|
@@ -75,6 +75,7 @@ export declare abstract class WebAppRpcProtocol extends RpcProtocol {
|
|
|
75
75
|
getStatus(code: number): RpcRequestStatus;
|
|
76
76
|
/** Supplies the protocol-specific code corresponding to a status value. */
|
|
77
77
|
getCode(status: RpcRequestStatus): number;
|
|
78
|
+
supportsStatusCategory: boolean;
|
|
78
79
|
/** Whether an HTTP status code indicates a request timeout. */
|
|
79
80
|
isTimeout(code: number): boolean;
|
|
80
81
|
/** An OpenAPI-compatible description of this protocol.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcProtocol.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"WebAppRpcProtocol.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAGH,OAAO,EA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AgB,GAAG,MAAM;IAczC,sBAAsB,UAAQ;IAE9C,+DAA+D;IACxD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIvC;;OAEG;IACH,IAAW,kBAAkB,0BAA8C;IAE3E;;OAEG;aACa,gCAAgC,CAAC,UAAU,EAAE,YAAY,GAAG,gBAAgB,EAAE;IAE9F,mCAAmC;gBAChB,aAAa,EAAE,gBAAgB;CAInD"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.WebAppRpcProtocol = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
11
12
|
const RpcConfiguration_1 = require("../core/RpcConfiguration");
|
|
12
13
|
const RpcConstants_1 = require("../core/RpcConstants");
|
|
13
14
|
const RpcProtocol_1 = require("../core/RpcProtocol");
|
|
@@ -18,7 +19,6 @@ const CommonLoggerCategory_1 = require("../../CommonLoggerCategory");
|
|
|
18
19
|
const RpcInterface_1 = require("../../RpcInterface");
|
|
19
20
|
const RpcManager_1 = require("../../RpcManager");
|
|
20
21
|
const RpcRoutingToken_1 = require("../core/RpcRoutingToken");
|
|
21
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
22
22
|
class InitializeInterface extends RpcInterface_1.RpcInterface {
|
|
23
23
|
async initialize() { return this.forward(arguments); }
|
|
24
24
|
static createRequest(protocol) {
|
|
@@ -53,6 +53,7 @@ class WebAppRpcProtocol extends RpcProtocol_1.RpcProtocol {
|
|
|
53
53
|
this.pathPrefix = "";
|
|
54
54
|
/** The RPC request class for this protocol. */
|
|
55
55
|
this.requestType = WebAppRpcRequest_1.WebAppRpcRequest;
|
|
56
|
+
this.supportsStatusCategory = true;
|
|
56
57
|
this.events.addListener(WebAppRpcLogging_1.WebAppRpcLogging.logProtocolEvent);
|
|
57
58
|
}
|
|
58
59
|
/** @internal */
|
|
@@ -82,7 +83,7 @@ class WebAppRpcProtocol extends RpcProtocol_1.RpcProtocol {
|
|
|
82
83
|
async handleOperationPostRequest(req, res) {
|
|
83
84
|
const request = await WebAppRpcRequest_1.WebAppRpcRequest.parseRequest(this, req);
|
|
84
85
|
const fulfillment = await this.fulfill(request);
|
|
85
|
-
WebAppRpcRequest_1.WebAppRpcRequest.sendResponse(this, request, fulfillment, res);
|
|
86
|
+
await WebAppRpcRequest_1.WebAppRpcRequest.sendResponse(this, request, fulfillment, req, res);
|
|
86
87
|
}
|
|
87
88
|
/** Convenience handler for an OpenAPI description request for an HTTP server. */
|
|
88
89
|
handleOpenApiDescriptionRequest(_req, res) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+DAA4D;AAC5D,uDAA2F;AAE3F,qDAAkD;AAClD,uCAAiF;AACjF,yDAAsD;AACtD,yDAAsD;AACtD,qEAAkE;AAClE,qDAAkD;AAClD,iDAA8C;AAC9C,6DAA0D;AAC1D,sDAA2D;AAE3D,MAAM,mBAAoB,SAAQ,2BAAY;IAGrC,KAAK,CAAC,UAAU,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEtD,MAAM,CAAC,aAAa,CAAC,QAA2B;QACrD,MAAM,OAAO,GAAG,iCAAe,CAAC,QAAQ,EAAE,CAAC;QAE3C,MAAM,MAAM,GAAG,KAAM,SAAQ,mCAAgB;YAA9B;;gBACN,eAAU,GAAG,GAAG,EAAE,CAAC,CAAC,mBAAmB,CAAC,CAAC;gBACzC,aAAQ,GAAG,QAAQ,CAAC;YAC7B,CAAC;SAAA,CAAC;QAEF,mCAAgB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEzE,MAAM,QAAQ,GAAG,mCAAgB,CAAC,MAAM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,KAAK,+BAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,GAAG,CAAC;YAC3C,KAAK,+BAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,GAAG,CAAC;YAC3C,KAAK,+BAAgB,CAAC,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC;YAC5C,KAAK,+BAAgB,CAAC,UAAU,CAAC,CAAC,OAAO,GAAG,CAAC;YAC7C,KAAK,+BAAgB,CAAC,kBAAkB,CAAC,CAAC,OAAO,GAAG,CAAC;YACrD,KAAK,+BAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,GAAG,CAAC;YACjD,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;SACrB;IACH,CAAC;IAED,+DAA+D;IACxD,SAAS,CAAC,IAAY;QAC3B,OAAO,IAAI,KAAK,GAAG,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,kBAAkB,KAAK,OAAO,IAAI,+BAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAY5E;AA1HD,8CA0HC","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 { Readable, Writable } from \"stream\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcContentType, RpcRequestStatus, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { RpcProtocol } from \"../core/RpcProtocol\";\r\nimport { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from \"./OpenAPI\";\r\nimport { WebAppRpcLogging } from \"./WebAppRpcLogging\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcManager } from \"../../RpcManager\";\r\nimport { RpcRoutingToken } from \"../core/RpcRoutingToken\";\r\nimport { BentleyError, Logger } from \"@itwin/core-bentley\";\r\n\r\nclass InitializeInterface extends RpcInterface {\r\n public static readonly interfaceName = \"InitializeInterface\";\r\n public static readonly interfaceVersion = \"1.0.0\";\r\n public async initialize() { return this.forward(arguments); }\r\n\r\n public static createRequest(protocol: WebAppRpcProtocol) {\r\n const routing = RpcRoutingToken.generate();\r\n\r\n const config = class extends RpcConfiguration {\r\n public interfaces = () => [InitializeInterface];\r\n public protocol = protocol;\r\n };\r\n\r\n RpcConfiguration.assignWithRouting(InitializeInterface, routing, config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n RpcConfiguration.initializeInterfaces(instance);\r\n\r\n const client = RpcManager.getClientForInterface(InitializeInterface, routing);\r\n return new (protocol.requestType)(client, \"initialize\", []);\r\n }\r\n}\r\n\r\n/** An HTTP server request object.\r\n * @public\r\n */\r\nexport interface HttpServerRequest extends Readable {\r\n aborted: boolean;\r\n httpVersion: string;\r\n httpVersionMajor: number;\r\n httpVersionMinor: number;\r\n complete: boolean;\r\n connection: any;\r\n headers: { [header: string]: string | string[] | undefined };\r\n rawHeaders: string[];\r\n trailers: { [key: string]: string | undefined };\r\n rawTrailers: string[];\r\n setTimeout(msecs: number, callback: () => void): this;\r\n url?: string;\r\n statusCode?: number;\r\n statusMessage?: string;\r\n socket: any;\r\n destroy(error?: Error): void;\r\n body: string | Buffer;\r\n path: string;\r\n method: string;\r\n ip?: string;\r\n header: (field: string) => string | undefined;\r\n}\r\n\r\n/** An HTTP server response object.\r\n * @public\r\n */\r\nexport interface HttpServerResponse extends Writable {\r\n send(body?: any): HttpServerResponse;\r\n status(code: number): HttpServerResponse;\r\n set(field: string, value: string): void;\r\n}\r\n\r\n/** The HTTP application protocol.\r\n * @internal\r\n */\r\nexport abstract class WebAppRpcProtocol extends RpcProtocol {\r\n public override preserveStreams = true;\r\n\r\n private _initialized: Promise<void> | undefined;\r\n\r\n /** @internal */\r\n public allowedHeaders: Set<string> = new Set();\r\n\r\n /** @internal */\r\n public async initialize() {\r\n if (this._initialized) {\r\n return this._initialized;\r\n }\r\n\r\n return this._initialized = new Promise(async (resolve) => {\r\n try {\r\n const request = InitializeInterface.createRequest(this);\r\n const response = await request.preflight();\r\n if (response && response.ok) {\r\n (response.headers.get(\"Access-Control-Allow-Headers\") || \"\").split(\",\").forEach((v) => this.allowedHeaders.add(v.trim()));\r\n }\r\n } catch (err) {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceFrontend, \"Unable to discover backend capabilities.\", BentleyError.getErrorProps(err));\r\n }\r\n\r\n resolve();\r\n });\r\n }\r\n\r\n /** Convenience handler for an RPC operation get request for an HTTP server. */\r\n public async handleOperationGetRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n return this.handleOperationPostRequest(req, res);\r\n }\r\n\r\n /** Convenience handler for an RPC operation post request for an HTTP server. */\r\n public async handleOperationPostRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n const request = await WebAppRpcRequest.parseRequest(this, req);\r\n const fulfillment = await this.fulfill(request);\r\n WebAppRpcRequest.sendResponse(this, request, fulfillment, res);\r\n }\r\n\r\n /** Convenience handler for an OpenAPI description request for an HTTP server. */\r\n public handleOpenApiDescriptionRequest(_req: HttpServerRequest, res: HttpServerResponse) {\r\n const description = JSON.stringify(this.openAPIDescription);\r\n res.send(description);\r\n }\r\n\r\n /** Converts an HTTP content type value to an RPC content type value. */\r\n public static computeContentType(httpType: string | null | undefined): RpcContentType {\r\n if (!httpType)\r\n return RpcContentType.Unknown;\r\n\r\n if (httpType.indexOf(WEB_RPC_CONSTANTS.ANY_TEXT) === 0) {\r\n return RpcContentType.Text;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.BINARY) === 0) {\r\n return RpcContentType.Binary;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.MULTIPART) === 0) {\r\n return RpcContentType.Multipart;\r\n } else {\r\n return RpcContentType.Unknown;\r\n }\r\n }\r\n\r\n /** The OpenAPI-compatible info object for this protocol. */\r\n public abstract info: OpenAPIInfo;\r\n\r\n /** An optional prefix for RPC operation URI paths. */\r\n public pathPrefix: string = \"\";\r\n\r\n /** The RPC request class for this protocol. */\r\n public readonly requestType = WebAppRpcRequest;\r\n\r\n /** Supplies the status corresponding to a protocol-specific code value. */\r\n public override getStatus(code: number): RpcRequestStatus {\r\n switch (code) {\r\n case 404: return RpcRequestStatus.NotFound;\r\n case 202: return RpcRequestStatus.Pending;\r\n case 200: return RpcRequestStatus.Resolved;\r\n case 500: return RpcRequestStatus.Rejected;\r\n case 204: return RpcRequestStatus.NoContent;\r\n case 502: return RpcRequestStatus.BadGateway;\r\n case 503: return RpcRequestStatus.ServiceUnavailable;\r\n case 504: return RpcRequestStatus.GatewayTimeout;\r\n default: return RpcRequestStatus.Unknown;\r\n }\r\n }\r\n\r\n /** Supplies the protocol-specific code corresponding to a status value. */\r\n public override getCode(status: RpcRequestStatus): number {\r\n switch (status) {\r\n case RpcRequestStatus.NotFound: return 404;\r\n case RpcRequestStatus.Pending: return 202;\r\n case RpcRequestStatus.Resolved: return 200;\r\n case RpcRequestStatus.Rejected: return 500;\r\n case RpcRequestStatus.NoContent: return 204;\r\n case RpcRequestStatus.BadGateway: return 502;\r\n case RpcRequestStatus.ServiceUnavailable: return 503;\r\n case RpcRequestStatus.GatewayTimeout: return 504;\r\n default: return 501;\r\n }\r\n }\r\n\r\n /** Whether an HTTP status code indicates a request timeout. */\r\n public isTimeout(code: number): boolean {\r\n return code === 504;\r\n }\r\n\r\n /** An OpenAPI-compatible description of this protocol.\r\n * @internal\r\n */\r\n public get openAPIDescription() { return new RpcOpenAPIDescription(this); }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public abstract supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[];\r\n\r\n /** Constructs an HTTP protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n super(configuration);\r\n this.events.addListener(WebAppRpcLogging.logProtocolEvent);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebAppRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAE3D,+DAA4D;AAC5D,uDAA2F;AAE3F,qDAAkD;AAClD,uCAAiF;AACjF,yDAAsD;AACtD,yDAAsD;AACtD,qEAAkE;AAClE,qDAAkD;AAClD,iDAA8C;AAC9C,6DAA0D;AAE1D,MAAM,mBAAoB,SAAQ,2BAAY;IAGrC,KAAK,CAAC,UAAU,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEtD,MAAM,CAAC,aAAa,CAAC,QAA2B;QACrD,MAAM,OAAO,GAAG,iCAAe,CAAC,QAAQ,EAAE,CAAC;QAE3C,MAAM,MAAM,GAAG,KAAM,SAAQ,mCAAgB;YAA9B;;gBACN,eAAU,GAAG,GAAG,EAAE,CAAC,CAAC,mBAAmB,CAAC,CAAC;gBACzC,aAAQ,GAAG,QAAQ,CAAC;YAC7B,CAAC;SAAA,CAAC;QAEF,mCAAgB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEzE,MAAM,QAAQ,GAAG,mCAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,mCAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEhD,MAAM,MAAM,GAAG,uBAAU,CAAC,qBAAqB,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;;AAnBsB,iCAAa,GAAG,qBAAqB,CAAC;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AAK,+BAAgB,CAAC,kBAAkB,CAAC,CAAC,OAAO,GAAG,CAAC;YACrD,KAAK,+BAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,GAAG,CAAC;YACjD,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;SACrB;IACH,CAAC;IAID,+DAA+D;IACxD,SAAS,CAAC,IAAY;QAC3B,OAAO,IAAI,KAAK,GAAG,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,kBAAkB,KAAK,OAAO,IAAI,+BAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAY5E;AA5HD,8CA4HC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyError, Logger } from \"@itwin/core-bentley\";\r\nimport { Readable, Writable } from \"stream\";\r\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\r\nimport { RpcContentType, RpcRequestStatus, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { RpcOperation } from \"../core/RpcOperation\";\r\nimport { RpcProtocol } from \"../core/RpcProtocol\";\r\nimport { OpenAPIInfo, OpenAPIParameter, RpcOpenAPIDescription } from \"./OpenAPI\";\r\nimport { WebAppRpcLogging } from \"./WebAppRpcLogging\";\r\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcManager } from \"../../RpcManager\";\r\nimport { RpcRoutingToken } from \"../core/RpcRoutingToken\";\r\n\r\nclass InitializeInterface extends RpcInterface {\r\n public static readonly interfaceName = \"InitializeInterface\";\r\n public static readonly interfaceVersion = \"1.0.0\";\r\n public async initialize() { return this.forward(arguments); }\r\n\r\n public static createRequest(protocol: WebAppRpcProtocol) {\r\n const routing = RpcRoutingToken.generate();\r\n\r\n const config = class extends RpcConfiguration {\r\n public interfaces = () => [InitializeInterface];\r\n public protocol = protocol;\r\n };\r\n\r\n RpcConfiguration.assignWithRouting(InitializeInterface, routing, config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n RpcConfiguration.initializeInterfaces(instance);\r\n\r\n const client = RpcManager.getClientForInterface(InitializeInterface, routing);\r\n return new (protocol.requestType)(client, \"initialize\", []);\r\n }\r\n}\r\n\r\n/** An HTTP server request object.\r\n * @public\r\n */\r\nexport interface HttpServerRequest extends Readable {\r\n aborted: boolean;\r\n httpVersion: string;\r\n httpVersionMajor: number;\r\n httpVersionMinor: number;\r\n complete: boolean;\r\n connection: any;\r\n headers: { [header: string]: string | string[] | undefined };\r\n rawHeaders: string[];\r\n trailers: { [key: string]: string | undefined };\r\n rawTrailers: string[];\r\n setTimeout(msecs: number, callback: () => void): this;\r\n url?: string;\r\n statusCode?: number;\r\n statusMessage?: string;\r\n socket: any;\r\n destroy(error?: Error): void;\r\n body: string | Buffer;\r\n path: string;\r\n method: string;\r\n ip?: string;\r\n header: (field: string) => string | undefined;\r\n}\r\n\r\n/** An HTTP server response object.\r\n * @public\r\n */\r\nexport interface HttpServerResponse extends Writable {\r\n send(body?: any): HttpServerResponse;\r\n status(code: number): HttpServerResponse;\r\n set(field: string, value: string): void;\r\n}\r\n\r\n/** The HTTP application protocol.\r\n * @internal\r\n */\r\nexport abstract class WebAppRpcProtocol extends RpcProtocol {\r\n public override preserveStreams = true;\r\n\r\n private _initialized: Promise<void> | undefined;\r\n\r\n /** @internal */\r\n public allowedHeaders: Set<string> = new Set();\r\n\r\n /** @internal */\r\n public async initialize() {\r\n if (this._initialized) {\r\n return this._initialized;\r\n }\r\n\r\n return this._initialized = new Promise(async (resolve) => {\r\n try {\r\n const request = InitializeInterface.createRequest(this);\r\n const response = await request.preflight();\r\n if (response && response.ok) {\r\n (response.headers.get(\"Access-Control-Allow-Headers\") || \"\").split(\",\").forEach((v) => this.allowedHeaders.add(v.trim()));\r\n }\r\n } catch (err) {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceFrontend, \"Unable to discover backend capabilities.\", BentleyError.getErrorProps(err));\r\n }\r\n\r\n resolve();\r\n });\r\n }\r\n\r\n /** Convenience handler for an RPC operation get request for an HTTP server. */\r\n public async handleOperationGetRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n return this.handleOperationPostRequest(req, res);\r\n }\r\n\r\n /** Convenience handler for an RPC operation post request for an HTTP server. */\r\n public async handleOperationPostRequest(req: HttpServerRequest, res: HttpServerResponse) {\r\n const request = await WebAppRpcRequest.parseRequest(this, req);\r\n const fulfillment = await this.fulfill(request);\r\n await WebAppRpcRequest.sendResponse(this, request, fulfillment, req, res);\r\n }\r\n\r\n /** Convenience handler for an OpenAPI description request for an HTTP server. */\r\n public handleOpenApiDescriptionRequest(_req: HttpServerRequest, res: HttpServerResponse) {\r\n const description = JSON.stringify(this.openAPIDescription);\r\n res.send(description);\r\n }\r\n\r\n /** Converts an HTTP content type value to an RPC content type value. */\r\n public static computeContentType(httpType: string | null | undefined): RpcContentType {\r\n if (!httpType)\r\n return RpcContentType.Unknown;\r\n\r\n if (httpType.indexOf(WEB_RPC_CONSTANTS.ANY_TEXT) === 0) {\r\n return RpcContentType.Text;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.BINARY) === 0) {\r\n return RpcContentType.Binary;\r\n } else if (httpType.indexOf(WEB_RPC_CONSTANTS.MULTIPART) === 0) {\r\n return RpcContentType.Multipart;\r\n } else {\r\n return RpcContentType.Unknown;\r\n }\r\n }\r\n\r\n /** The OpenAPI-compatible info object for this protocol. */\r\n public abstract info: OpenAPIInfo;\r\n\r\n /** An optional prefix for RPC operation URI paths. */\r\n public pathPrefix: string = \"\";\r\n\r\n /** The RPC request class for this protocol. */\r\n public readonly requestType = WebAppRpcRequest;\r\n\r\n /** Supplies the status corresponding to a protocol-specific code value. */\r\n public override getStatus(code: number): RpcRequestStatus {\r\n switch (code) {\r\n case 404: return RpcRequestStatus.NotFound;\r\n case 202: return RpcRequestStatus.Pending;\r\n case 200: return RpcRequestStatus.Resolved;\r\n case 500: return RpcRequestStatus.Rejected;\r\n case 204: return RpcRequestStatus.NoContent;\r\n case 502: return RpcRequestStatus.BadGateway;\r\n case 503: return RpcRequestStatus.ServiceUnavailable;\r\n case 504: return RpcRequestStatus.GatewayTimeout;\r\n default: return RpcRequestStatus.Unknown;\r\n }\r\n }\r\n\r\n /** Supplies the protocol-specific code corresponding to a status value. */\r\n public override getCode(status: RpcRequestStatus): number {\r\n switch (status) {\r\n case RpcRequestStatus.NotFound: return 404;\r\n case RpcRequestStatus.Pending: return 202;\r\n case RpcRequestStatus.Resolved: return 200;\r\n case RpcRequestStatus.Rejected: return 500;\r\n case RpcRequestStatus.NoContent: return 204;\r\n case RpcRequestStatus.BadGateway: return 502;\r\n case RpcRequestStatus.ServiceUnavailable: return 503;\r\n case RpcRequestStatus.GatewayTimeout: return 504;\r\n default: return 501;\r\n }\r\n }\r\n\r\n public override supportsStatusCategory = true;\r\n\r\n /** Whether an HTTP status code indicates a request timeout. */\r\n public isTimeout(code: number): boolean {\r\n return code === 504;\r\n }\r\n\r\n /** An OpenAPI-compatible description of this protocol.\r\n * @internal\r\n */\r\n public get openAPIDescription() { return new RpcOpenAPIDescription(this); }\r\n\r\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\r\n * @internal\r\n */\r\n public abstract supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[];\r\n\r\n /** Constructs an HTTP protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n super(configuration);\r\n this.events.addListener(WebAppRpcLogging.logProtocolEvent);\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module RpcInterface
|
|
3
3
|
*/
|
|
4
|
-
import "@ungap/url-search-params/index";
|
|
5
4
|
import { RpcInterface } from "../../RpcInterface";
|
|
6
5
|
import { RpcContentType } from "../core/RpcConstants";
|
|
7
6
|
import { RpcSerializedValue } from "../core/RpcMarshaling";
|
|
@@ -36,7 +35,7 @@ export declare class WebAppRpcRequest extends RpcRequest {
|
|
|
36
35
|
/** Parses a request. */
|
|
37
36
|
static parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest>;
|
|
38
37
|
/** Sends the response for a web request. */
|
|
39
|
-
static sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse): void
|
|
38
|
+
static sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
|
|
40
39
|
/** Determines the most efficient transport type for an RPC value. */
|
|
41
40
|
protected static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType;
|
|
42
41
|
/** Constructs a web application request. */
|
|
@@ -56,10 +55,10 @@ export declare class WebAppRpcRequest extends RpcRequest {
|
|
|
56
55
|
/** Override to supply an alternate Request function. */
|
|
57
56
|
protected supplyRequest(): typeof Request;
|
|
58
57
|
private static configureResponse;
|
|
59
|
-
private static
|
|
60
|
-
private static
|
|
61
|
-
private static
|
|
62
|
-
private static
|
|
58
|
+
private static configureText;
|
|
59
|
+
private static configureBinary;
|
|
60
|
+
private static configureMultipart;
|
|
61
|
+
private static configureStream;
|
|
63
62
|
private static parseFromPath;
|
|
64
63
|
private static parseFromBody;
|
|
65
64
|
private performFetch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcRequest.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"WebAppRpcRequest.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":"AAIA;;GAE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ports.WebAppRpcRequest = void 0;
|
|
11
|
-
require("@ungap/url-search-params/index");
|
|
12
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const buffer_1 = require("buffer");
|
|
13
13
|
const IModelError_1 = require("../../IModelError");
|
|
14
14
|
const RpcConstants_1 = require("../core/RpcConstants");
|
|
15
15
|
const RpcMarshaling_1 = require("../core/RpcMarshaling");
|
|
16
|
+
const RpcProtocol_1 = require("../core/RpcProtocol");
|
|
16
17
|
const RpcRequest_1 = require("../core/RpcRequest");
|
|
17
18
|
const RpcMultipartParser_1 = require("./multipart/RpcMultipartParser");
|
|
18
19
|
const RpcMultipart_1 = require("./RpcMultipart");
|
|
@@ -79,19 +80,43 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
|
|
|
79
80
|
return request;
|
|
80
81
|
}
|
|
81
82
|
/** Sends the response for a web request. */
|
|
82
|
-
static sendResponse(protocol, request, fulfillment, res) {
|
|
83
|
+
static async sendResponse(protocol, request, fulfillment, req, res) {
|
|
84
|
+
var _a;
|
|
85
|
+
const versionHeader = protocol.protocolVersionHeaderName;
|
|
86
|
+
if (versionHeader && RpcProtocol_1.RpcProtocol.protocolVersion) {
|
|
87
|
+
res.set(versionHeader, RpcProtocol_1.RpcProtocol.protocolVersion.toString());
|
|
88
|
+
}
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
90
|
+
const { Readable, Stream } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "stream"));
|
|
91
|
+
const { createGzip } = await Promise.resolve().then(() => require(/* webpackIgnore: true */ "zlib"));
|
|
83
92
|
const transportType = WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);
|
|
93
|
+
let responseBody;
|
|
84
94
|
if (transportType === RpcConstants_1.RpcContentType.Binary) {
|
|
85
|
-
WebAppRpcRequest.
|
|
95
|
+
responseBody = WebAppRpcRequest.configureBinary(fulfillment, res);
|
|
86
96
|
}
|
|
87
97
|
else if (transportType === RpcConstants_1.RpcContentType.Multipart) {
|
|
88
|
-
WebAppRpcRequest.
|
|
98
|
+
responseBody = WebAppRpcRequest.configureMultipart(fulfillment, res);
|
|
89
99
|
}
|
|
90
100
|
else if (transportType === RpcConstants_1.RpcContentType.Stream) {
|
|
91
|
-
WebAppRpcRequest.
|
|
101
|
+
responseBody = WebAppRpcRequest.configureStream(fulfillment);
|
|
92
102
|
}
|
|
93
103
|
else {
|
|
94
|
-
WebAppRpcRequest.
|
|
104
|
+
responseBody = WebAppRpcRequest.configureText(fulfillment, res);
|
|
105
|
+
}
|
|
106
|
+
WebAppRpcRequest.configureResponse(protocol, request, fulfillment, res);
|
|
107
|
+
res.status(fulfillment.status);
|
|
108
|
+
if (fulfillment.allowCompression && ((_a = req.header("Accept-Encoding")) === null || _a === void 0 ? void 0 : _a.includes("gzip"))) {
|
|
109
|
+
res.set("Content-Encoding", "gzip");
|
|
110
|
+
const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);
|
|
111
|
+
responseBody = readableResponseBody.pipe(createGzip());
|
|
112
|
+
}
|
|
113
|
+
// This check should in theory look for instances of Readable, but that would break backend implementation at
|
|
114
|
+
// core/backend/src/RpcBackend.ts
|
|
115
|
+
if (responseBody instanceof Stream) {
|
|
116
|
+
responseBody.pipe(res);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
res.send(responseBody);
|
|
95
120
|
}
|
|
96
121
|
}
|
|
97
122
|
/** Determines the most efficient transport type for an RPC value. */
|
|
@@ -177,6 +202,12 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
|
|
|
177
202
|
reject(new IModelError_1.IModelError(core_bentley_1.BentleyStatus.ERROR, "Invalid state."));
|
|
178
203
|
return;
|
|
179
204
|
}
|
|
205
|
+
if (this.protocol.protocolVersionHeaderName) {
|
|
206
|
+
const version = response.headers.get(this.protocol.protocolVersionHeaderName);
|
|
207
|
+
if (version) {
|
|
208
|
+
this.responseProtocolVersion = parseInt(version, 10);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
180
211
|
const contentType = response.headers.get(RpcConstants_1.WEB_RPC_CONSTANTS.CONTENT);
|
|
181
212
|
const responseType = WebAppRpcProtocol_1.WebAppRpcProtocol.computeContentType(contentType);
|
|
182
213
|
if (responseType === RpcConstants_1.RpcContentType.Binary) {
|
|
@@ -217,20 +248,16 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
|
|
|
217
248
|
res.set("Retry-After", fulfillment.retry);
|
|
218
249
|
}
|
|
219
250
|
}
|
|
220
|
-
static
|
|
221
|
-
const response = (fulfillment.status === 204) ? "" : fulfillment.result.objects;
|
|
251
|
+
static configureText(fulfillment, res) {
|
|
222
252
|
res.set(RpcConstants_1.WEB_RPC_CONSTANTS.CONTENT, RpcConstants_1.WEB_RPC_CONSTANTS.TEXT);
|
|
223
|
-
|
|
224
|
-
res.status(fulfillment.status).send(response);
|
|
253
|
+
return (fulfillment.status === 204) ? "" : fulfillment.result.objects;
|
|
225
254
|
}
|
|
226
|
-
static
|
|
227
|
-
const data = fulfillment.result.data[0];
|
|
228
|
-
const response = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
255
|
+
static configureBinary(fulfillment, res) {
|
|
229
256
|
res.set(RpcConstants_1.WEB_RPC_CONSTANTS.CONTENT, RpcConstants_1.WEB_RPC_CONSTANTS.BINARY);
|
|
230
|
-
|
|
231
|
-
|
|
257
|
+
const data = fulfillment.result.data[0];
|
|
258
|
+
return buffer_1.Buffer.isBuffer(data) ? data : buffer_1.Buffer.from(data);
|
|
232
259
|
}
|
|
233
|
-
static
|
|
260
|
+
static configureMultipart(fulfillment, res) {
|
|
234
261
|
const response = RpcMultipart_1.RpcMultipart.createStream(fulfillment.result);
|
|
235
262
|
const headers = response.getHeaders();
|
|
236
263
|
for (const header in headers) {
|
|
@@ -238,18 +265,13 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
|
|
|
238
265
|
res.set(header, headers[header]);
|
|
239
266
|
}
|
|
240
267
|
}
|
|
241
|
-
|
|
242
|
-
res.status(fulfillment.status);
|
|
243
|
-
response.pipe(res);
|
|
268
|
+
return response;
|
|
244
269
|
}
|
|
245
|
-
static
|
|
246
|
-
|
|
247
|
-
WebAppRpcRequest.configureResponse(protocol, request, fulfillment, res);
|
|
248
|
-
res.status(fulfillment.status);
|
|
249
|
-
response.pipe(res);
|
|
270
|
+
static configureStream(fulfillment) {
|
|
271
|
+
return fulfillment.result.stream;
|
|
250
272
|
}
|
|
251
273
|
static parseFromPath(operation) {
|
|
252
|
-
const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, "base64").toString("binary") : "";
|
|
274
|
+
const decoded = operation.encodedRequest ? buffer_1.Buffer.from(operation.encodedRequest, "base64").toString("binary") : "";
|
|
253
275
|
return RpcMarshaling_1.RpcSerializedValue.create(decoded);
|
|
254
276
|
}
|
|
255
277
|
static async parseFromBody(req) {
|
|
@@ -293,7 +315,7 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
|
|
|
293
315
|
}
|
|
294
316
|
async loadMultipart(response, contentType) {
|
|
295
317
|
const data = await response.arrayBuffer();
|
|
296
|
-
const value = new RpcMultipartParser_1.RpcMultipartParser(contentType, Buffer.from(data)).parse();
|
|
318
|
+
const value = new RpcMultipartParser_1.RpcMultipartParser(contentType, buffer_1.Buffer.from(data)).parse();
|
|
297
319
|
return value;
|
|
298
320
|
}
|
|
299
321
|
async setupTransport() {
|
|
@@ -344,5 +366,5 @@ exports.WebAppRpcRequest = WebAppRpcRequest;
|
|
|
344
366
|
/** The maximum size permitted for an encoded component in a URL.
|
|
345
367
|
* @note This is used for features like encoding the payload of a cacheable request in the URL.
|
|
346
368
|
*/
|
|
347
|
-
WebAppRpcRequest.maxUrlComponentSize =
|
|
369
|
+
WebAppRpcRequest.maxUrlComponentSize = 4096;
|
|
348
370
|
//# sourceMappingURL=WebAppRpcRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppRpcR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AI,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;IAC1C,CAAC;;AA9WH,4CA+WC;AAzWC;;GAEG;AACW,oCAAmB,GAAG,IAAI,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 \"@ungap/url-search-params/index\";\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcContentType, RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\r\nimport { RpcRequestFulfillment, SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\r\nimport { RpcMultipart } from \"./RpcMultipart\";\r\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\r\n\r\n/** @internal */\r\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n/** A web application RPC request.\r\n * @internal\r\n */\r\nexport class WebAppRpcRequest extends RpcRequest {\r\n private _loading: boolean = false;\r\n private _request: RequestInit = {};\r\n private _pathSuffix: string = \"\";\r\n private get _headers() { return this._request.headers as { [key: string]: string }; }\r\n\r\n /** The maximum size permitted for an encoded component in a URL.\r\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\r\n */\r\n public static maxUrlComponentSize = 1024;\r\n\r\n /** The HTTP method for this request. */\r\n public override method: HttpMethod_T;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\r\n\r\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\r\n public metadata = { status: 0, message: \"\" };\r\n\r\n /** Parse headers */\r\n private static parseHeaders(protocol: WebAppRpcProtocol, req: HttpServerRequest): SerializedRpcActivity {\r\n const headerNames: SerializedRpcActivity = protocol.serializedClientRequestContextHeaderNames;\r\n const parsedHeaders: SerializedRpcActivity = {\r\n id: req.header(headerNames.id) || \"\",\r\n applicationId: req.header(headerNames.applicationId) || \"\",\r\n applicationVersion: req.header(headerNames.applicationVersion) || \"\",\r\n sessionId: req.header(headerNames.sessionId) || \"\",\r\n authorization: (headerNames.authorization ? req.header(headerNames.authorization) : \"\") ?? \"\",\r\n };\r\n return parsedHeaders;\r\n }\r\n\r\n /** Parses a request. */\r\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n const operation = protocol.getOperationFromPath(req.url!);\r\n\r\n const parsedHeaders = this.parseHeaders(protocol, req);\r\n\r\n const request: SerializedRpcRequest = {\r\n ...parsedHeaders,\r\n operation: {\r\n interfaceDefinition: operation.interfaceDefinition,\r\n operationName: operation.operationName,\r\n interfaceVersion: operation.interfaceVersion,\r\n },\r\n method: req.method,\r\n path: req.url!,\r\n parameters: operation.encodedRequest ? WebAppRpcRequest.parseFromPath(operation) : await WebAppRpcRequest.parseFromBody(req),\r\n caching: operation.encodedRequest ? RpcResponseCacheControl.Immutable : RpcResponseCacheControl.None,\r\n };\r\n\r\n request.ip = req.ip;\r\n\r\n request.protocolVersion = 0;\r\n\r\n if (protocol.protocolVersionHeaderName) {\r\n const version = req.header(protocol.protocolVersionHeaderName);\r\n if (version) {\r\n request.protocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n if (!request.id) {\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid request.`);\r\n }\r\n\r\n return request;\r\n }\r\n\r\n /** Sends the response for a web request. */\r\n public static sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const transportType = WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);\r\n if (transportType === RpcContentType.Binary) {\r\n WebAppRpcRequest.sendBinary(protocol, request, fulfillment, res);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n WebAppRpcRequest.sendMultipart(protocol, request, fulfillment, res);\r\n } else if (transportType === RpcContentType.Stream) {\r\n WebAppRpcRequest.sendStream(protocol, request, fulfillment, res);\r\n } else {\r\n WebAppRpcRequest.sendText(protocol, request, fulfillment, res);\r\n }\r\n }\r\n\r\n /** Determines the most efficient transport type for an RPC value. */\r\n protected static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\r\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\r\n return RpcContentType.Binary;\r\n } else if (value.data.length > 0) {\r\n return RpcContentType.Multipart;\r\n } else if (value.stream) {\r\n return RpcContentType.Stream;\r\n } else {\r\n return RpcContentType.Text;\r\n }\r\n }\r\n\r\n /** Constructs a web application request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n super(client, operation, parameters);\r\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\r\n this.method = \"head\";\r\n this._request.headers = {};\r\n }\r\n\r\n /** @internal */\r\n public async preflight(): Promise<Response | undefined> {\r\n this.method = \"options\";\r\n this._request.method = \"options\";\r\n await this.setHeaders();\r\n await this.send();\r\n return this._response;\r\n }\r\n\r\n protected override isHeaderAvailable(name: string): boolean {\r\n const allowed = this.protocol.allowedHeaders;\r\n return allowed.has(\"*\") || allowed.has(name);\r\n }\r\n\r\n /** Sets request header values. */\r\n protected setHeader(name: string, value: string): void {\r\n this._headers[name] = value;\r\n }\r\n\r\n /** Sends the request. */\r\n protected async send(): Promise<number> {\r\n if (this.method !== \"options\") {\r\n await this.protocol.initialize();\r\n }\r\n\r\n this._loading = true;\r\n await this.setupTransport();\r\n\r\n return new Promise<number>(async (resolve, reject) => {\r\n try {\r\n resolve(await this.performFetch());\r\n } catch (reason) {\r\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\r\n }\r\n });\r\n }\r\n\r\n protected override computeRetryAfter(attempts: number): number {\r\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\r\n if (retryAfter) {\r\n this.resetTransientFaultCount();\r\n\r\n const r = Number(retryAfter);\r\n if (Number.isFinite(r)) {\r\n return r * 1000;\r\n }\r\n\r\n const d = Date.parse(retryAfter);\r\n if (!Number.isNaN(d)) {\r\n return d - Date.now();\r\n }\r\n } else {\r\n this.recordTransientFault();\r\n }\r\n\r\n return super.computeRetryAfter(attempts);\r\n }\r\n\r\n protected override handleUnknownResponse(code: number) {\r\n if (this.protocol.isTimeout(code)) {\r\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\r\n } else {\r\n this.reject(new ServerError(code, \"Unknown server response code.\"));\r\n }\r\n }\r\n\r\n protected async load(): Promise<RpcSerializedValue> {\r\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\r\n try {\r\n if (!this._loading)\r\n return;\r\n\r\n const response = this._response;\r\n if (!response) {\r\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\r\n return;\r\n }\r\n\r\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\r\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\r\n\r\n if (responseType === RpcContentType.Binary) {\r\n resolve(await this.loadBinary(response));\r\n } else if (responseType === RpcContentType.Multipart) {\r\n resolve(await this.loadMultipart(response, contentType!));\r\n } else {\r\n resolve(await this.loadText(response));\r\n }\r\n\r\n this._loading = false;\r\n this.setLastUpdatedTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n } catch (reason) {\r\n if (!this._loading)\r\n return;\r\n\r\n this._loading = false;\r\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\r\n }\r\n });\r\n }\r\n\r\n /** Override to supply an alternate fetch function. */\r\n protected supplyFetch(): typeof fetch {\r\n return fetch;\r\n }\r\n\r\n /** Override to supply an alternate Request function. */\r\n protected supplyRequest(): typeof Request {\r\n return Request;\r\n }\r\n\r\n private static configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\r\n\r\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\r\n res.set(\"Cache-Control\", \"private, max-age=31536000, immutable\");\r\n }\r\n\r\n if (fulfillment.retry) {\r\n res.set(\"Retry-After\", fulfillment.retry);\r\n }\r\n }\r\n\r\n private static sendText(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const response = (fulfillment.status === 204) ? \"\" : fulfillment.result.objects;\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.TEXT);\r\n WebAppRpcRequest.configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status).send(response);\r\n }\r\n\r\n private static sendBinary(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const data = fulfillment.result.data[0];\r\n const response = Buffer.isBuffer(data) ? data : Buffer.from(data);\r\n\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.BINARY);\r\n WebAppRpcRequest.configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status).send(response);\r\n }\r\n\r\n private static sendMultipart(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const response = RpcMultipart.createStream(fulfillment.result);\r\n const headers = response.getHeaders();\r\n for (const header in headers) {\r\n if (headers.hasOwnProperty(header)) {\r\n res.set(header, headers[header]);\r\n }\r\n }\r\n\r\n WebAppRpcRequest.configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status);\r\n response.pipe(res);\r\n }\r\n\r\n private static sendStream(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const response = fulfillment.result.stream;\r\n WebAppRpcRequest.configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status);\r\n response!.pipe(res);\r\n }\r\n\r\n private static parseFromPath(operation: SerializedRpcOperation): RpcSerializedValue {\r\n const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, \"base64\").toString(\"binary\") : \"\";\r\n return RpcSerializedValue.create(decoded);\r\n }\r\n\r\n private static async parseFromBody(req: HttpServerRequest): Promise<RpcSerializedValue> {\r\n const contentType = WebAppRpcProtocol.computeContentType(req.header(WEB_RPC_CONSTANTS.CONTENT));\r\n if (contentType === RpcContentType.Binary) {\r\n const objects = JSON.stringify([MarshalingBinaryMarker.createDefault()]);\r\n const data = [req.body as Buffer];\r\n return RpcSerializedValue.create(objects, data);\r\n } else if (contentType === RpcContentType.Multipart) {\r\n return RpcMultipart.parseRequest(req);\r\n } else {\r\n return RpcSerializedValue.create(req.body as string);\r\n }\r\n }\r\n\r\n private async performFetch(): Promise<number> {\r\n const requestClass = this.supplyRequest();\r\n const fetchFunction = this.supplyFetch();\r\n\r\n const path = new URL(this.path, typeof (location) !== \"undefined\" ? location.origin : undefined);\r\n if (this._pathSuffix) {\r\n const params = new URLSearchParams();\r\n params.set(\"parameters\", this._pathSuffix);\r\n path.search = `?${params.toString()}`;\r\n }\r\n\r\n const request = new requestClass(path.toString(), this._request);\r\n const response = await fetchFunction(request);\r\n this._response = response;\r\n this.metadata.status = response.status;\r\n return response.status;\r\n }\r\n\r\n private async loadText(response: Response) {\r\n const value = await response.text();\r\n this.metadata.message = value;\r\n return RpcSerializedValue.create(value);\r\n }\r\n\r\n private async loadBinary(response: Response) {\r\n const value = new Uint8Array(await response.arrayBuffer());\r\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\r\n return RpcSerializedValue.create(objects, [value]);\r\n }\r\n\r\n private async loadMultipart(response: Response, contentType: string) {\r\n const data = await response.arrayBuffer();\r\n const value = new RpcMultipartParser(contentType, Buffer.from(data)).parse();\r\n return value;\r\n }\r\n\r\n private async setupTransport(): Promise<void> {\r\n if (this.method === \"options\") {\r\n return;\r\n }\r\n\r\n const parameters = (await this.protocol.serialize(this)).parameters;\r\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\r\n\r\n if (transportType === RpcContentType.Binary) {\r\n this.setupBinaryTransport(parameters);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n this.setupMultipartTransport(parameters);\r\n } else {\r\n this.setupTextTransport(parameters);\r\n }\r\n }\r\n\r\n private setupBinaryTransport(parameters: RpcSerializedValue) {\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.data[0];\r\n }\r\n\r\n private setupMultipartTransport(parameters: RpcSerializedValue) {\r\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._request.method = \"post\";\r\n this._request.body = RpcMultipart.createForm(parameters);\r\n }\r\n\r\n private setupTextTransport(parameters: RpcSerializedValue) {\r\n if (this.operation.policy.allowResponseCaching(this)) {\r\n const encodedBody = btoa(parameters.objects); // eslint-disable-line deprecation/deprecation\r\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\r\n this._request.method = \"get\";\r\n this._request.body = undefined;\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._pathSuffix = encodedBody;\r\n return;\r\n }\r\n }\r\n\r\n this._pathSuffix = \"\";\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.objects;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebAppRpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AACpD,mCAAgC;AAChC,mDAAiF;AAEjF,uDAAsI;AAEtI,yDAAmF;AACnF,qDAAuH;AACvH,mDAAgD;AAChD,uEAAoE;AACpE,iDAAgE;AAChE,2DAA+F;AAK/F;;GAEG;AACH,MAAa,gBAAiB,SAAQ,uBAAU;IAiI9C,4CAA4C;IAC5C,YAAmB,MAAoB,EAAE,SAAiB,EAAE,UAAiB;QAC3E,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QAlI/B,aAAQ,GAAY,KAAK,CAAC;QAC1B,aAAQ,GAAgB,EAAE,CAAC;QAC3B,gBAAW,GAAW,EAAE,CAAC;QAWjC,0DAA0D;QACjC,aAAQ,GAAsB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAe,CAAC;QAEjG,+FAA+F;QACxF,aAAQ,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAkH3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,EAAE,CAAC;IAC7B,CAAC;IAnID,IAAY,QAAQ,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAoC,CAA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CAAC,QAAQ,CAAC,IAAI,GAAG,2BAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;IAEO,kBAAkB,CAAC,UAA8B;QACvD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE;YACpD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,8CAA8C;YAC5F,IAAI,WAAW,CAAC,MAAM,IAAI,gBAAgB,CAAC,mBAAmB,EAAE;gBAC9D,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;gBAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,gCAAiB,CAAC,OAAO,CAAC,CAAC;gBAChD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;gBAC/B,OAAO;aACR;SACF;QAED,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,gCAAiB,CAAC,OAAO,CAAC,GAAG,gCAAiB,CAAC,IAAI,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;IAC1C,CAAC;;AA3YH,4CA4YC;AAtYC;;GAEG;AACW,oCAAmB,GAAG,IAAI,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 { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcContentType, RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\r\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\r\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\r\nimport { RpcProtocol, RpcRequestFulfillment, SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\r\nimport { RpcRequest } from \"../core/RpcRequest\";\r\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\r\nimport { ReadableFormData, RpcMultipart } from \"./RpcMultipart\";\r\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\r\n\r\n/** @internal */\r\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n/** A web application RPC request.\r\n * @internal\r\n */\r\nexport class WebAppRpcRequest extends RpcRequest {\r\n private _loading: boolean = false;\r\n private _request: RequestInit = {};\r\n private _pathSuffix: string = \"\";\r\n private get _headers() { return this._request.headers as { [key: string]: string }; }\r\n\r\n /** The maximum size permitted for an encoded component in a URL.\r\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\r\n */\r\n public static maxUrlComponentSize = 4096;\r\n\r\n /** The HTTP method for this request. */\r\n public override method: HttpMethod_T;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\r\n\r\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\r\n public metadata = { status: 0, message: \"\" };\r\n\r\n /** Parse headers */\r\n private static parseHeaders(protocol: WebAppRpcProtocol, req: HttpServerRequest): SerializedRpcActivity {\r\n const headerNames: SerializedRpcActivity = protocol.serializedClientRequestContextHeaderNames;\r\n const parsedHeaders: SerializedRpcActivity = {\r\n id: req.header(headerNames.id) || \"\",\r\n applicationId: req.header(headerNames.applicationId) || \"\",\r\n applicationVersion: req.header(headerNames.applicationVersion) || \"\",\r\n sessionId: req.header(headerNames.sessionId) || \"\",\r\n authorization: (headerNames.authorization ? req.header(headerNames.authorization) : \"\") ?? \"\",\r\n };\r\n return parsedHeaders;\r\n }\r\n\r\n /** Parses a request. */\r\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n const operation = protocol.getOperationFromPath(req.url!);\r\n\r\n const parsedHeaders = this.parseHeaders(protocol, req);\r\n\r\n const request: SerializedRpcRequest = {\r\n ...parsedHeaders,\r\n operation: {\r\n interfaceDefinition: operation.interfaceDefinition,\r\n operationName: operation.operationName,\r\n interfaceVersion: operation.interfaceVersion,\r\n },\r\n method: req.method,\r\n path: req.url!,\r\n parameters: operation.encodedRequest ? WebAppRpcRequest.parseFromPath(operation) : await WebAppRpcRequest.parseFromBody(req),\r\n caching: operation.encodedRequest ? RpcResponseCacheControl.Immutable : RpcResponseCacheControl.None,\r\n };\r\n\r\n request.ip = req.ip;\r\n\r\n request.protocolVersion = 0;\r\n\r\n if (protocol.protocolVersionHeaderName) {\r\n const version = req.header(protocol.protocolVersionHeaderName);\r\n if (version) {\r\n request.protocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n if (!request.id) {\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid request.`);\r\n }\r\n\r\n return request;\r\n }\r\n\r\n /** Sends the response for a web request. */\r\n public static async sendResponse(\r\n protocol: WebAppRpcProtocol,\r\n request: SerializedRpcRequest,\r\n fulfillment: RpcRequestFulfillment,\r\n req: HttpServerRequest,\r\n res: HttpServerResponse,\r\n ): Promise<void> {\r\n const versionHeader = protocol.protocolVersionHeaderName;\r\n if (versionHeader && RpcProtocol.protocolVersion) {\r\n res.set(versionHeader, RpcProtocol.protocolVersion.toString());\r\n }\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const { Readable, Stream } = await import(/* webpackIgnore: true */ \"stream\");\r\n const { createGzip } = await import(/* webpackIgnore: true */ \"zlib\");\r\n\r\n const transportType = WebAppRpcRequest.computeTransportType(fulfillment.result, fulfillment.rawResult);\r\n let responseBody;\r\n if (transportType === RpcContentType.Binary) {\r\n responseBody = WebAppRpcRequest.configureBinary(fulfillment, res);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n responseBody = WebAppRpcRequest.configureMultipart(fulfillment, res);\r\n } else if (transportType === RpcContentType.Stream) {\r\n responseBody = WebAppRpcRequest.configureStream(fulfillment);\r\n } else {\r\n responseBody = WebAppRpcRequest.configureText(fulfillment, res);\r\n }\r\n\r\n WebAppRpcRequest.configureResponse(protocol, request, fulfillment, res);\r\n res.status(fulfillment.status);\r\n\r\n if (fulfillment.allowCompression && req.header(\"Accept-Encoding\")?.includes(\"gzip\")) {\r\n res.set(\"Content-Encoding\", \"gzip\");\r\n const readableResponseBody = (responseBody instanceof Stream) ? responseBody : Readable.from(responseBody);\r\n responseBody = readableResponseBody.pipe(createGzip());\r\n }\r\n\r\n // This check should in theory look for instances of Readable, but that would break backend implementation at\r\n // core/backend/src/RpcBackend.ts\r\n if (responseBody instanceof Stream) {\r\n responseBody.pipe(res);\r\n } else {\r\n res.send(responseBody);\r\n }\r\n }\r\n\r\n /** Determines the most efficient transport type for an RPC value. */\r\n protected static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\r\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\r\n return RpcContentType.Binary;\r\n } else if (value.data.length > 0) {\r\n return RpcContentType.Multipart;\r\n } else if (value.stream) {\r\n return RpcContentType.Stream;\r\n } else {\r\n return RpcContentType.Text;\r\n }\r\n }\r\n\r\n /** Constructs a web application request. */\r\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\r\n super(client, operation, parameters);\r\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\r\n this.method = \"head\";\r\n this._request.headers = {};\r\n }\r\n\r\n /** @internal */\r\n public async preflight(): Promise<Response | undefined> {\r\n this.method = \"options\";\r\n this._request.method = \"options\";\r\n await this.setHeaders();\r\n await this.send();\r\n return this._response;\r\n }\r\n\r\n protected override isHeaderAvailable(name: string): boolean {\r\n const allowed = this.protocol.allowedHeaders;\r\n return allowed.has(\"*\") || allowed.has(name);\r\n }\r\n\r\n /** Sets request header values. */\r\n protected setHeader(name: string, value: string): void {\r\n this._headers[name] = value;\r\n }\r\n\r\n /** Sends the request. */\r\n protected async send(): Promise<number> {\r\n if (this.method !== \"options\") {\r\n await this.protocol.initialize();\r\n }\r\n\r\n this._loading = true;\r\n await this.setupTransport();\r\n\r\n return new Promise<number>(async (resolve, reject) => {\r\n try {\r\n resolve(await this.performFetch());\r\n } catch (reason) {\r\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\r\n }\r\n });\r\n }\r\n\r\n protected override computeRetryAfter(attempts: number): number {\r\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\r\n if (retryAfter) {\r\n this.resetTransientFaultCount();\r\n\r\n const r = Number(retryAfter);\r\n if (Number.isFinite(r)) {\r\n return r * 1000;\r\n }\r\n\r\n const d = Date.parse(retryAfter);\r\n if (!Number.isNaN(d)) {\r\n return d - Date.now();\r\n }\r\n } else {\r\n this.recordTransientFault();\r\n }\r\n\r\n return super.computeRetryAfter(attempts);\r\n }\r\n\r\n protected override handleUnknownResponse(code: number) {\r\n if (this.protocol.isTimeout(code)) {\r\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\r\n } else {\r\n this.reject(new ServerError(code, \"Unknown server response code.\"));\r\n }\r\n }\r\n\r\n protected async load(): Promise<RpcSerializedValue> {\r\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\r\n try {\r\n if (!this._loading)\r\n return;\r\n\r\n const response = this._response;\r\n if (!response) {\r\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\r\n return;\r\n }\r\n\r\n if (this.protocol.protocolVersionHeaderName) {\r\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\r\n if (version) {\r\n this.responseProtocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\r\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\r\n\r\n if (responseType === RpcContentType.Binary) {\r\n resolve(await this.loadBinary(response));\r\n } else if (responseType === RpcContentType.Multipart) {\r\n resolve(await this.loadMultipart(response, contentType!));\r\n } else {\r\n resolve(await this.loadText(response));\r\n }\r\n\r\n this._loading = false;\r\n this.setLastUpdatedTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\r\n } catch (reason) {\r\n if (!this._loading)\r\n return;\r\n\r\n this._loading = false;\r\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\r\n }\r\n });\r\n }\r\n\r\n /** Override to supply an alternate fetch function. */\r\n protected supplyFetch(): typeof fetch {\r\n return fetch;\r\n }\r\n\r\n /** Override to supply an alternate Request function. */\r\n protected supplyRequest(): typeof Request {\r\n return Request;\r\n }\r\n\r\n private static configureResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, res: HttpServerResponse) {\r\n const success = protocol.getStatus(fulfillment.status) === RpcRequestStatus.Resolved;\r\n\r\n if (success && request.caching === RpcResponseCacheControl.Immutable) {\r\n res.set(\"Cache-Control\", \"private, max-age=31536000, immutable\");\r\n }\r\n\r\n if (fulfillment.retry) {\r\n res.set(\"Retry-After\", fulfillment.retry);\r\n }\r\n }\r\n\r\n private static configureText(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): string {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.TEXT);\r\n return (fulfillment.status === 204) ? \"\" : fulfillment.result.objects;\r\n }\r\n\r\n private static configureBinary(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): Buffer {\r\n res.set(WEB_RPC_CONSTANTS.CONTENT, WEB_RPC_CONSTANTS.BINARY);\r\n const data = fulfillment.result.data[0];\r\n return Buffer.isBuffer(data) ? data : Buffer.from(data);\r\n }\r\n\r\n private static configureMultipart(fulfillment: RpcRequestFulfillment, res: HttpServerResponse): ReadableFormData {\r\n const response = RpcMultipart.createStream(fulfillment.result);\r\n const headers = response.getHeaders();\r\n for (const header in headers) {\r\n if (headers.hasOwnProperty(header)) {\r\n res.set(header, headers[header]);\r\n }\r\n }\r\n\r\n return response;\r\n }\r\n\r\n private static configureStream(fulfillment: RpcRequestFulfillment) {\r\n return fulfillment.result.stream!;\r\n }\r\n\r\n private static parseFromPath(operation: SerializedRpcOperation): RpcSerializedValue {\r\n const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, \"base64\").toString(\"binary\") : \"\";\r\n return RpcSerializedValue.create(decoded);\r\n }\r\n\r\n private static async parseFromBody(req: HttpServerRequest): Promise<RpcSerializedValue> {\r\n const contentType = WebAppRpcProtocol.computeContentType(req.header(WEB_RPC_CONSTANTS.CONTENT));\r\n if (contentType === RpcContentType.Binary) {\r\n const objects = JSON.stringify([MarshalingBinaryMarker.createDefault()]);\r\n const data = [req.body as Buffer];\r\n return RpcSerializedValue.create(objects, data);\r\n } else if (contentType === RpcContentType.Multipart) {\r\n return RpcMultipart.parseRequest(req);\r\n } else {\r\n return RpcSerializedValue.create(req.body as string);\r\n }\r\n }\r\n\r\n private async performFetch(): Promise<number> {\r\n const requestClass = this.supplyRequest();\r\n const fetchFunction = this.supplyFetch();\r\n\r\n const path = new URL(this.path, typeof (location) !== \"undefined\" ? location.origin : undefined);\r\n if (this._pathSuffix) {\r\n const params = new URLSearchParams();\r\n params.set(\"parameters\", this._pathSuffix);\r\n path.search = `?${params.toString()}`;\r\n }\r\n\r\n const request = new requestClass(path.toString(), this._request);\r\n const response = await fetchFunction(request);\r\n this._response = response;\r\n this.metadata.status = response.status;\r\n return response.status;\r\n }\r\n\r\n private async loadText(response: Response) {\r\n const value = await response.text();\r\n this.metadata.message = value;\r\n return RpcSerializedValue.create(value);\r\n }\r\n\r\n private async loadBinary(response: Response) {\r\n const value = new Uint8Array(await response.arrayBuffer());\r\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\r\n return RpcSerializedValue.create(objects, [value]);\r\n }\r\n\r\n private async loadMultipart(response: Response, contentType: string) {\r\n const data = await response.arrayBuffer();\r\n const value = new RpcMultipartParser(contentType, Buffer.from(data)).parse();\r\n return value;\r\n }\r\n\r\n private async setupTransport(): Promise<void> {\r\n if (this.method === \"options\") {\r\n return;\r\n }\r\n\r\n const parameters = (await this.protocol.serialize(this)).parameters;\r\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\r\n\r\n if (transportType === RpcContentType.Binary) {\r\n this.setupBinaryTransport(parameters);\r\n } else if (transportType === RpcContentType.Multipart) {\r\n this.setupMultipartTransport(parameters);\r\n } else {\r\n this.setupTextTransport(parameters);\r\n }\r\n }\r\n\r\n private setupBinaryTransport(parameters: RpcSerializedValue) {\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.data[0];\r\n }\r\n\r\n private setupMultipartTransport(parameters: RpcSerializedValue) {\r\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._request.method = \"post\";\r\n this._request.body = RpcMultipart.createForm(parameters);\r\n }\r\n\r\n private setupTextTransport(parameters: RpcSerializedValue) {\r\n if (this.operation.policy.allowResponseCaching(this)) {\r\n const encodedBody = btoa(parameters.objects); // eslint-disable-line deprecation/deprecation\r\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\r\n this._request.method = \"get\";\r\n this._request.body = undefined;\r\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\r\n this._pathSuffix = encodedBody;\r\n return;\r\n }\r\n }\r\n\r\n this._pathSuffix = \"\";\r\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\r\n this._request.method = \"post\";\r\n this._request.body = parameters.objects;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcMultipartParser.d.ts","sourceRoot":"","sources":["../../../../../src/rpc/web/multipart/RpcMultipartParser.ts"],"names":[],"mappings":"AAIA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"RpcMultipartParser.d.ts","sourceRoot":"","sources":["../../../../../src/rpc/web/multipart/RpcMultipartParser.ts"],"names":[],"mappings":"AAIA;;GAEG;;AA6BH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA0B9D,gBAAgB;AAChB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,WAAW,CAAW;IAC9B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAqB;gBAEhB,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAoC/C,KAAK,IAAI,kBAAkB;IAkNlC,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,kBAAkB;CAE3B"}
|