import { createOsdFieldTypes , OsdFieldTypeUnknown } from './osd_field_types_factory' ; import { OsdFieldType } from './osd_field_type' ; import { OPENSEARCH_FIELD_TYPES , OSD_FIELD_TYPES } from './types' ; private const registeredOsdTypes = createOsdFieldTypes ( ) ; param { string } typeName return { OsdFieldType } export const getOsdFieldType = ( typeName ) : OsdFieldType => registeredOsdTypes . find ( ( t ) => t . name === typeName ) || OsdFieldTypeUnknown ; return { Array < string > } export const getOsdTypeNames = ( ) : string [ ] => registeredOsdTypes . filter ( ( type ) => type . name ) . map ( ( type ) => type . name ) ; param { string } opensearchType return { string } export const castOpenSearchToOsdFieldTypeName = ( opensearchType ) : OSD_FIELD_TYPES => { const type = registeredOsdTypes . find ( ( t ) => t . esTypes . includes ( opensearchType as OPENSEARCH_FIELD_TYPES ) ) ; return type && type . name ? ( type . name as OSD_FIELD_TYPES ) : OSD_FIELD_TYPES . UNKNOWN ; } ; return { Array < string > } export const getFilterableOsdTypeNames = ( ) : string [ ] => registeredOsdTypes . filter ( ( type ) => type . filterable ) . map ( ( type ) => type . name ) ;