import { createLogger , exclude , mergeIgnoreCase } from '@sap-cloud-sdk/util' ; import { HttpRequestConfig , HttpRequestConfigWithOrigin , OriginOptions } from './http-client-types' ; const logger = createLogger ( { package : 'http-client' , messageContext : 'http-request-config' } ) ; param customRequestConfig param disallowedKeys returns internal export function filterCustomRequestConfig ( customRequestConfig , disallowedKeys = defaultDisallowedKeys ) { const removedKeys = Object . keys ( customRequestConfig ) . filter ( key => disallowedKeys . includes ( key ) ) ; if ( removedKeys . length ) { logger . warn ( `The following keys are found in the custom request config that will be removed: ${ removedKeys . join ( ', ' ) }` ) ; } return exclude ( disallowedKeys , customRequestConfig ) as Record < string , string > ; } /**
 * A list of request config keys that are not allowed to be customized by default.
 */ const defaultDisallowedKeys = [ 'method' , 'url' , 'baseURL' , 'data' , 'headers' , 'params' ] ; param configWithOrigin returns internal export function buildHttpRequestConfig ( configWithOrigin ) { const requestConfig = configWithOrigin as HttpRequestConfig ; requestConfig . headers = mergeOptionsWithPriority ( configWithOrigin . headers ) ; requestConfig . params = mergeOptionsWithPriority ( configWithOrigin . params ) ; return requestConfig ; } param headersOrParams returns export function mergeOptionsWithPriority ( headersOrParams ? ) { if ( headersOrParams ) { return origins . reduce ( ( mergedHeadersOrParams , origin ) => mergeIgnoreCase ( mergedHeadersOrParams , headersOrParams [ origin ] ) , { } ) ; } } /**
 * All origins ordered from low to high priority.
 */ const origins = [ 'requestConfig' , 'destination' , 'destinationProperty' , 'custom' ] ;