import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey' ; import { Calendar } from '../../../../../plugins/ml/server/models/calendar' ; type ScheduledEvent = estypes . MlCalendarEvent ; export const assertAllEventsExistInCalendar = ( eventsToCheck , calendar ) : boolean => { const updatedCalendarEvents = calendar . events ; let allEventsAreUpdated = true ; for ( const eventToCheck of eventsToCheck ) { if ( updatedCalendarEvents . findIndex ( ( updatedEvent ) => updatedEvent . description === eventToCheck . description && updatedEvent . start_time === eventToCheck . start_time && updatedEvent . end_time === eventToCheck . end_time ) < 0 ) { allEventsAreUpdated = false ; break ; } } return allEventsAreUpdated ; } ;