import type { Query } from 'src/plugins/data/common' ; import { SOURCE_BOUNDS_DATA_REQUEST_ID } from '../../../../common/constants' ; import { MapExtent } from '../../../../common/descriptor_types' ; import { DataRequestContext } from '../../../actions' ; import { IVectorSource } from '../../sources/vector_source' ; export async function syncBoundsData ( { layerId , syncContext , source , sourceQuery , } ) { const { startLoading , stopLoading , registerCancelCallback , dataFilters } = syncContext ; const requestToken = Symbol ( `${ SOURCE_BOUNDS_DATA_REQUEST_ID }-${ layerId }` ) ; const boundsFilters = { sourceQuery : sourceQuery ? sourceQuery : undefined , query : dataFilters . query , timeFilters : dataFilters . timeFilters , timeslice : dataFilters . timeslice , filters : dataFilters . filters , applyGlobalQuery : source . getApplyGlobalQuery ( ) , applyGlobalTime : source . getApplyGlobalTime ( ) , } ; let bounds = null ; try { startLoading ( SOURCE_BOUNDS_DATA_REQUEST_ID , requestToken , boundsFilters ) ; bounds = await source . getBoundsForFilters ( boundsFilters , registerCancelCallback . bind ( null , requestToken ) ) ; } finally { stopLoading ( SOURCE_BOUNDS_DATA_REQUEST_ID , requestToken , bounds ? bounds : { } ) ; } return bounds ; }