import { flow , flatMap , map , flatten , uniq } from 'lodash/fp' ; import { ElasticsearchClient } from 'src/core/server' ; import { SystemIndicesMigrationStatus , SystemIndicesMigrationFeature , SystemIndicesMigrationStarted , } from '../../common/types' ; export const convertFeaturesToIndicesArray = ( features ) : string [ ] => { return flow ( map ( 'indices' ) , map ( flatMap ( 'index' ) ) , flatten , uniq ) ( features ) ; } ; export const getESSystemIndicesMigrationStatus = async ( client ) : Promise < SystemIndicesMigrationStatus > => { const { body } = await client . transport . request ( { method : 'GET' , path : '/_migration/system_features' , } ) ; return body as SystemIndicesMigrationStatus ; } ; export const startESSystemIndicesMigration = async ( client ) : Promise < SystemIndicesMigrationStarted > => { const { body } = await client . transport . request ( { method : 'POST' , path : '/_migration/system_features' , } ) ; return body as SystemIndicesMigrationStarted ; } ;