import { i18n } from '@kbn/i18n' ; import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types' ; import { KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public' ; import { DataViewField } from '../../../../../../src/plugins/data_views/common' ; export function kbnTypeToMLJobType ( field ) { let type ; switch ( field . type ) { case KBN_FIELD_TYPES . STRING : type = field . aggregatable ? ML_JOB_FIELD_TYPES . KEYWORD : ML_JOB_FIELD_TYPES . TEXT ; break ; case KBN_FIELD_TYPES . NUMBER : type = ML_JOB_FIELD_TYPES . NUMBER ; break ; case KBN_FIELD_TYPES . DATE : type = ML_JOB_FIELD_TYPES . DATE ; break ; case KBN_FIELD_TYPES . IP : type = ML_JOB_FIELD_TYPES . IP ; break ; case KBN_FIELD_TYPES . BOOLEAN : type = ML_JOB_FIELD_TYPES . BOOLEAN ; break ; case KBN_FIELD_TYPES . GEO_POINT : type = ML_JOB_FIELD_TYPES . GEO_POINT ; break ; case KBN_FIELD_TYPES . GEO_SHAPE : type = ML_JOB_FIELD_TYPES . GEO_SHAPE ; break ; default : break ; } return type ; } export const mlJobTypeAriaLabels = { BOOLEAN : i18n . translate ( 'xpack.ml.fieldTypeIcon.booleanTypeAriaLabel' , { defaultMessage : 'boolean type' , } ) , DATE : i18n . translate ( 'xpack.ml.fieldTypeIcon.dateTypeAriaLabel' , { defaultMessage : 'date type' , } ) , GEO_POINT : i18n . translate ( 'xpack.ml.fieldTypeIcon.geoPointTypeAriaLabel' , { defaultMessage : '{geoPointParam} type' , values : { geoPointParam : 'geo point' , } , } ) , IP : i18n . translate ( 'xpack.ml.fieldTypeIcon.ipTypeAriaLabel' , { defaultMessage : 'ip type' , } ) , KEYWORD : i18n . translate ( 'xpack.ml.fieldTypeIcon.keywordTypeAriaLabel' , { defaultMessage : 'keyword type' , } ) , NUMBER : i18n . translate ( 'xpack.ml.fieldTypeIcon.numberTypeAriaLabel' , { defaultMessage : 'number type' , } ) , TEXT : i18n . translate ( 'xpack.ml.fieldTypeIcon.textTypeAriaLabel' , { defaultMessage : 'text type' , } ) , UNKNOWN : i18n . translate ( 'xpack.ml.fieldTypeIcon.unknownTypeAriaLabel' , { defaultMessage : 'unknown type' , } ) , } ; export const getMLJobTypeAriaLabel = ( type ) => { const requestedFieldType = Object . keys ( ML_JOB_FIELD_TYPES ) . find ( ( k ) => ML_JOB_FIELD_TYPES [ k as keyof typeof ML_JOB_FIELD_TYPES ] === type ) ; if ( requestedFieldType === undefined ) { return null ; } return mlJobTypeAriaLabels [ requestedFieldType as keyof typeof mlJobTypeAriaLabels ] ; } ;