import { SavedObjectsImportRetry } from './types' ; import { getNonUniqueEntries } from './get_non_unique_entries' ; import { SavedObjectsErrorHelpers } from '..' ; export const validateRetries = ( retries ) => { const nonUniqueRetryObjects = getNonUniqueEntries ( retries ) ; if ( nonUniqueRetryObjects . length > 0 ) { throw SavedObjectsErrorHelpers . createBadRequestError ( `Non-unique retry objects: [${ nonUniqueRetryObjects . join ( ) }]` ) ; } const destinationEntries = retries . filter ( ( retry ) => retry . destinationId !== undefined ) . map ( ( { type , destinationId } ) => ( { type , id : destinationId ! } ) ) ; const nonUniqueRetryDestinations = getNonUniqueEntries ( destinationEntries ) ; if ( nonUniqueRetryDestinations . length > 0 ) { throw SavedObjectsErrorHelpers . createBadRequestError ( `Non-unique retry destinations: [${ nonUniqueRetryDestinations . join ( ) }]` ) ; } } ;