import { i18n } from '@osd/i18n' ; import { siblingPipelineAggWriter } from './sibling_pipeline_agg_writer' ; import { forwardModifyAggConfigOnSearchRequestStart } from './nested_agg_helpers' ; import { IMetricAggConfig , MetricAggParam } from '../metric_agg_type' ; const metricAggFilter = [ '!top_hits' , '!percentiles' , '!percentile_ranks' , '!median' , '!std_dev' , '!sum_bucket' , '!avg_bucket' , '!min_bucket' , '!max_bucket' , '!derivative' , '!moving_avg' , '!serial_diff' , '!cumulative_sum' , '!geo_bounds' , '!geo_centroid' , ] ; const bucketAggFilter = [ ] ; export const siblingPipelineType = i18n . translate ( 'data.search.aggs.metrics.siblingPipelineAggregationsSubtypeTitle' , { defaultMessage : 'Sibling pipeline aggregations' , } ) ; export const siblingPipelineAggHelper = { subtype : siblingPipelineType , params ( ) { return [ { name : 'customBucket' , type : 'agg' , allowedAggs : bucketAggFilter , default : null , makeAgg ( agg , state = { type : 'date_histogram' } ) { const orderAgg = agg . aggConfigs . createAggConfig ( state , { addToAggConfigs : false } ) ; orderAgg . id = agg . id + '-bucket' ; return orderAgg ; } , modifyAggConfigOnSearchRequestStart : forwardModifyAggConfigOnSearchRequestStart ( 'customBucket' ) , write : ( ) => { } , } , { name : 'customMetric' , type : 'agg' , allowedAggs : metricAggFilter , default : null , makeAgg ( agg , state = { type : 'count' } ) { const orderAgg = agg . aggConfigs . createAggConfig ( state , { addToAggConfigs : false } ) ; orderAgg . id = agg . id + '-metric' ; return orderAgg ; } , modifyAggConfigOnSearchRequestStart : forwardModifyAggConfigOnSearchRequestStart ( 'customMetric' ) , write : siblingPipelineAggWriter , } , ] as Array < MetricAggParam < IMetricAggConfig > > ; } , getSerializedFormat ( agg ) { const customMetric = agg . getParam ( 'customMetric' ) ; return customMetric ? customMetric . type . getSerializedFormat ( customMetric ) : { } ; } , } ;