import { ElasticsearchClient } from '../../elasticsearch' ; import { IndexMapping } from '../mappings' ; import { Logger } from '../../logging' ; import type { SavedObjectsMigrationVersion } from '../types' ; import type { TransformRawDocs } from './types' ; import { MigrationResult } from '../migrations/core' ; import { next } from './next' ; import { model } from './model' ; import { createInitialState } from './initial_state' ; import { migrationStateActionMachine } from './migrations_state_action_machine' ; import { SavedObjectsMigrationConfigType } from '../saved_objects_config' ; import type { ISavedObjectTypeRegistry } from '../saved_objects_type_registry' ; /**
 * Migrates the provided indexPrefix index using a resilient algorithm that is
 * completely lock-free so that any failure can always be retried by
 * restarting Kibana.
 */ export async function runResilientMigrator ( { client , kibanaVersion , targetMappings , logger , preMigrationScript , transformRawDocs , migrationVersionPerType , indexPrefix , migrationsConfig , typeRegistry , } ) { const initialState = createInitialState ( { kibanaVersion , targetMappings , preMigrationScript , migrationVersionPerType , indexPrefix , migrationsConfig , typeRegistry , } ) ; return migrationStateActionMachine ( { initialState , logger , next : next ( client , transformRawDocs ) , model , client , } ) ; }