import { AggNotSupportedError } from '../../../../common/errors' ; import { isMetricEnabled } from '../../../../common/check_ui_restrictions' ; import type { Metric } from '../../../../common/types' ; import type { SearchCapabilities } from '../../search_strategies' ; export function isAggSupported ( metrics , capabilities ) { const metricTypes = metrics . filter ( ( metric ) => ! isMetricEnabled ( metric . type , capabilities . uiRestrictions ) ) ; if ( metricTypes . length ) { throw new AggNotSupportedError ( metricTypes . map ( ( metric ) => `"${ metric . type }"` ) . join ( ', ' ) ) ; } }