import { ES_FIELD_TYPES } from '../../../../../../../src/plugins/data/public' ; import { newJobCapsServiceAnalytics } from '../../services/new_job_capabilities/new_job_capabilities_service_analytics' ; import { getDefaultFieldsFromJobCaps , DataFrameAnalyticsConfig } from '../common' ; export interface FieldTypes { [ key ] : ES_FIELD_TYPES ; } export const getIndexFields = ( jobConfig , needsDestIndexFields ) => { const { fields } = newJobCapsServiceAnalytics ; if ( jobConfig !== undefined ) { const { selectedFields : defaultSelected , docFields } = getDefaultFieldsFromJobCaps ( fields , jobConfig , needsDestIndexFields ) ; const types = { } ; const allFields = [ ] ; docFields . forEach ( ( field ) => { types [ field . id ] = field . type ; allFields . push ( field . id ) ; } ) ; return { defaultSelectedFields : defaultSelected . map ( ( field ) => field . id ) , fieldTypes : types , tableFields : allFields , } ; } else { return { defaultSelectedFields : [ ] , fieldTypes : { } , tableFields : [ ] , } ; } } ;