import { migrateLegacyQuery } from './migrate_legacy_query' ; import { SearchSource , SearchSourceDependencies } from './search_source' ; import { IndexPatternsContract } from '../../index_patterns/index_patterns' ; import { SearchSourceFields } from './types' ; param indexPatterns param searchSourceDependencies return public export const createSearchSource = ( indexPatterns , searchSourceDependencies ) => async ( searchSourceFields = { } ) => { const fields = { ... searchSourceFields } ; if ( fields . index && typeof fields . index === 'string' ) { fields . index = await indexPatterns . get ( searchSourceFields . index as any ) ; } const searchSource = new SearchSource ( fields , searchSourceDependencies ) ; const query = searchSource . getOwnField ( 'query' ) ; if ( typeof query !== 'undefined' ) { searchSource . setField ( 'query' , migrateLegacyQuery ( query ) ) ; } return searchSource ; } ;