import { mapValues , isString } from 'lodash' ; import { FieldMappingSpec , MappingObject } from './types' ; import { OPENSEARCH_FIELD_TYPES } from '../../../data/common/types' ; private type ShorthandFieldMapObject = FieldMappingSpec | OPENSEARCH_FIELD_TYPES | 'json' ; public export const expandShorthand = ( sh ) : MappingObject => { return mapValues ( sh , ( val ) => { const fieldMap = isString ( val ) ? { type : val } : val ; const json = { type : OPENSEARCH_FIELD_TYPES . TEXT , _serialize ( v ) { if ( v ) return JSON . stringify ( v ) ; } , _deserialize ( v ) { if ( v ) return JSON . parse ( v ) ; } , } ; return fieldMap . type === 'json' ? json : fieldMap ; } ) as MappingObject ; } ;