import { SavedObjectsClientContract } from '../../../../../../../src/core/server' ; import { APM_INDICES_SAVED_OBJECT_TYPE , APM_INDICES_SAVED_OBJECT_ID , } from '../../../../common/apm_saved_object_constants' ; import { withApmSpan } from '../../../utils/with_apm_span' ; import { ApmIndicesConfig } from './get_apm_indices' ; export function saveApmIndices ( savedObjectsClient , apmIndices ) { return withApmSpan ( 'save_apm_indices' , ( ) => savedObjectsClient . create ( APM_INDICES_SAVED_OBJECT_TYPE , removeEmpty ( apmIndices ) , { id : APM_INDICES_SAVED_OBJECT_ID , overwrite : true , } ) ) ; } function removeEmpty ( apmIndices ) { return Object . entries ( apmIndices ) . map ( ( [ key , value ] ) => [ key , value ?. trim ( ) ] ) . filter ( ( [ _ , value ] ) => ! ! value ) . reduce ( ( obj , [ key , value ] ) => ( { ... obj , [ key as string ] : value } ) , { } ) ; }