import { UI_SETTINGS } from '../../../constants' ; import { GetConfigFn } from '../../../types' ; import { ISearchRequestParams } from '../../index' ; import { SearchRequest } from './types' ; const sessionId = Date . now ( ) ; export function getSearchParams ( getConfig ) { return { preference : getPreference ( getConfig ) , } ; } export function getPreference ( getConfig ) { const setRequestPreference = getConfig ( UI_SETTINGS . COURIER_SET_REQUEST_PREFERENCE ) ; if ( setRequestPreference === 'sessionId' ) return sessionId ; return setRequestPreference === 'custom' ? getConfig ( UI_SETTINGS . COURIER_CUSTOM_REQUEST_PREFERENCE ) : undefined ; } public export function getSearchParamsFromRequest ( searchRequest , dependencies ) { const { getConfig } = dependencies ; const searchParams = getSearchParams ( getConfig ) ; return { index : searchRequest . index . title || searchRequest . index , body : searchRequest . body , ... searchParams , } ; }