import { Geometry , Position } from 'geojson' ; import { set } from '@elastic/safer-lodash-set' ; import { CHECK_IS_DRAWING_INDEX , GET_MATCHING_INDEXES_PATH , INDEX_FEATURE_PATH , } from '../../../../../common/constants' ; import { getHttp } from '../../../../kibana_services' ; export const addFeatureToIndex = async ( indexName , geometry , path , defaultFields ) => { const data = set ( { ... defaultFields } , path , geometry ) ; return await getHttp ( ) . fetch ( { path : `${ INDEX_FEATURE_PATH }` , method : 'POST' , body : JSON . stringify ( { index : indexName , data , } ) , } ) ; } ; export const deleteFeatureFromIndex = async ( indexName , featureId ) => { return await getHttp ( ) . fetch ( { path : `${ INDEX_FEATURE_PATH }/${ featureId }` , method : 'DELETE' , body : JSON . stringify ( { index : indexName , } ) , } ) ; } ; export const getMatchingIndexes = async ( indexPattern ) => { return await getHttp ( ) . fetch < { success : boolean ; matchingIndexes : string [ ] ; } > ( { path : GET_MATCHING_INDEXES_PATH , method : 'GET' , query : { indexPattern } , } ) ; } ; export const getIsDrawLayer = async ( index ) => { return await getHttp ( ) . fetch < { success : boolean ; isDrawingIndex : boolean ; } > ( { path : CHECK_IS_DRAWING_INDEX , method : 'GET' , query : { index } , } ) ; } ;