import { has } from 'lodash/fp' ; import { BulkErrorSchema } from '@kbn/securitysolution-io-ts-list-types' ; import { ImportResponse } from '../../import_exception_list_and_items' ; import { isImportRegular } from './is_import_regular' ; param responses { array } returns { object } export const sortImportResponses = ( responses ) : { errors : BulkErrorSchema [ ] ; success : boolean ; success_count : number ; } => { const errorsResp = responses . filter ( ( resp ) => has ( 'error' , resp ) ) as BulkErrorSchema [ ] ; const successes = responses . filter ( ( resp ) => { if ( isImportRegular ( resp ) ) { return resp . status_code === 200 ; } else { return false ; } } ) ; return { errors : errorsResp , success : errorsResp . length === 0 , success_count : successes . length , } ; } ;