import { ISearchOptions , ISearchSource } from 'src/plugins/data/public' ; import { ExpressionAstFunction } from 'src/plugins/expressions/common' ; import { IAggConfigs } from '../agg_configs' ; import { IAggConfig } from '../agg_config' ; export class BaseParamType < TAggConfig extends IAggConfig = IAggConfig > { name : string ; type : string ; displayName : string ; required : boolean ; advanced : boolean ; default : any ; write : ( aggConfig : TAggConfig , output : Record < string , any > , aggConfigs ? : IAggConfigs , locals ? : Record < string , any > ) => void ; serialize : ( value : any , aggConfig ? : TAggConfig ) => any ; deserialize : ( value : any , aggConfig ? : TAggConfig ) => any ; toExpressionAst ? : ( value : any ) => ExpressionAstFunction | undefined ; options : any [ ] ; valueType ? : any ; onChange ? ( agg ) ; shouldShow ? ( agg ) ; param { AggConfig } aggConfig param { Courier . SearchSource } searchSource returns { Promise < undefined > | undefined } modifyAggConfigOnSearchRequestStart : ( aggConfig : TAggConfig , searchSource ? : ISearchSource , options ? : ISearchOptions ) => void ; constructor ( config ) { this . name = config . name ; this . type = config . type ; this . displayName = config . displayName || this . name ; this . required = config . required === true ; this . advanced = config . advanced || false ; this . onChange = config . onChange ; this . shouldShow = config . shouldShow ; this . default = config . default ; const defaultWrite = ( aggConfig , output ) => { if ( aggConfig . params [ this . name ] ) { output . params [ this . name ] = aggConfig . params [ this . name ] || this . default ; } } ; this . write = config . write || defaultWrite ; this . serialize = config . serialize ; this . deserialize = config . deserialize ; this . toExpressionAst = config . toExpressionAst ; this . options = config . options ; this . modifyAggConfigOnSearchRequestStart = config . modifyAggConfigOnSearchRequestStart || function ( ) { } ; this . valueType = config . valueType || config . type ; } }