import { i18n } from '@osd/i18n' ; import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common' ; import { AggExpressionType , AggExpressionFunctionArgs , METRIC_TYPES } from '../' ; import { getParsedValue } from '../utils/get_parsed_value' ; const fnName = 'aggStdDeviation' ; type Input = any ; type AggArgs = AggExpressionFunctionArgs < typeof METRIC_TYPES . STD_DEV > ; type Output = AggExpressionType ; type FunctionDefinition = ExpressionFunctionDefinition < typeof fnName , Input , AggArgs , Output > ; export const aggStdDeviation = ( ) : FunctionDefinition => ( { name : fnName , help : i18n . translate ( 'data.search.aggs.function.metrics.std_deviation.help' , { defaultMessage : 'Generates a serialized agg config for a Standard Deviation agg' , } ) , type : 'agg_type' , args : { id : { types : [ 'string' ] , help : i18n . translate ( 'data.search.aggs.metrics.std_deviation.id.help' , { defaultMessage : 'ID for this aggregation' , } ) , } , enabled : { types : [ 'boolean' ] , default : true , help : i18n . translate ( 'data.search.aggs.metrics.std_deviation.enabled.help' , { defaultMessage : 'Specifies whether this aggregation should be enabled' , } ) , } , schema : { types : [ 'string' ] , help : i18n . translate ( 'data.search.aggs.metrics.std_deviation.schema.help' , { defaultMessage : 'Schema to use for this aggregation' , } ) , } , field : { types : [ 'string' ] , required : true , help : i18n . translate ( 'data.search.aggs.metrics.std_deviation.field.help' , { defaultMessage : 'Field to use for this aggregation' , } ) , } , json : { types : [ 'string' ] , help : i18n . translate ( 'data.search.aggs.metrics.std_deviation.json.help' , { defaultMessage : 'Advanced json to include when the agg is sent to OpenSearch' , } ) , } , customLabel : { types : [ 'string' ] , help : i18n . translate ( 'data.search.aggs.metrics.std_deviation.customLabel.help' , { defaultMessage : 'Represents a custom label for this aggregation' , } ) , } , } , fn : ( input , args ) => { const { id , enabled , schema , ... rest } = args ; return { type : 'agg_type' , value : { id , enabled , schema , type : METRIC_TYPES . STD_DEV , params : { ... rest , json : getParsedValue ( args , 'json' ) , } , } , } ; } , } ) ;