import { mergeIgnoreCase , mergeLeftIgnoreCase , pickNonNullish } from '@sap-cloud-sdk/util' ; import { getAuthHeaders } from './authorization-header' ; import { Destination } from './destination' ; export async function buildHeadersForDestination ( destination , customHeaders ? ) { const authHeaders = await getAuthHeaders ( destination , customHeaders ) ; const sapHeaders = getSapHeaders ( destination , customHeaders ) ; return mergeIgnoreCase ( mergeLeftIgnoreCase ( destination . headers , customHeaders ) , { ... authHeaders , ... sapHeaders } ) ; } function getSapHeaders ( destination , customHeaders ? ) { const defaultHeaders = pickNonNullish ( { 'sap-client' : destination . sapClient , 'SAP-Connectivity-SCC-Location_ID' : destination . cloudConnectorLocationId } ) ; const destinationHeaders = mergeLeftIgnoreCase ( defaultHeaders , destination . headers ) ; return mergeLeftIgnoreCase ( destinationHeaders , customHeaders ) ; }