import { toPath } from 'lodash' ; import { SavedObjectsFieldMapping , IndexMapping } from '../types' ; function getPropertyMappingFromObjectMapping ( mapping , path ) { const props = ( mapping && ( mapping as IndexMapping ) . properties ) || ( mapping && ( mapping as SavedObjectsFieldMapping ) . fields ) ; if ( ! props ) { return undefined ; } if ( path . length > 1 ) { return getPropertyMappingFromObjectMapping ( props [ path [ 0 ] ] , path . slice ( 1 ) ) ; } else { return props [ path [ 0 ] ] ; } } export function getProperty ( mappings , path ) { return getPropertyMappingFromObjectMapping ( mappings , toPath ( path ) ) ; }