module license import { ModuleRpcCommon } from '../../common' ; import { ModuleRpcClient } from '../../client' ; import { ModuleRpcContextCommon } from '../common' ; /**
 * Maps the connector names to their client context connectors.
 */ export type CompositeClientContextConnectorsFor < ResponseContext extends ModuleRpcContextCommon . CompositeContext > = { [ connectorName in keyof ResponseContext ] : ModuleRpcClient . ClientContextConnector < ResponseContext [ connectorName ] > ; } ; export class CompositeClientContextConnector < CompositeResponseContext extends ModuleRpcContextCommon . CompositeContext > implements ModuleRpcClient . ClientContextConnector < CompositeResponseContext > { constructor ( private readonly clientContextConnectors ) { } async provideRequestContext ( ) { let encodedRequestContext = { } ; for ( const connectorName in this . clientContextConnectors ) { encodedRequestContext = { ... encodedRequestContext , ... ( await this . clientContextConnectors [ connectorName ] . provideRequestContext ( ) ) , } ; } return encodedRequestContext ; } async decodeResponseContext ( encodedResponseContext ) { const responseContext = { } as any ; for ( const connectorName in this . clientContextConnectors ) { responseContext [ connectorName ] = await this . clientContextConnectors [ connectorName ] . decodeResponseContext ( encodedResponseContext ) ; } return responseContext ; } }