import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey' ; import type { EsQueryConfig } from '@kbn/es-query' ; /**
 * registering a new instance of the rule data client
 * in a new plugin will require updating the below data structure
 * to include the index name where the alerts as data will be written to.
 */ export const AlertConsumers = { APM : 'apm' , LOGS : 'logs' , INFRASTRUCTURE : 'infrastructure' , OBSERVABILITY : 'observability' , SIEM : 'siem' , UPTIME : 'uptime' , } as const ; export type AlertConsumers = typeof AlertConsumers [ keyof typeof AlertConsumers ] ; export type STATUS_VALUES = 'open' | 'acknowledged' | 'closed' | 'in-progress' ; export type ValidFeatureId = AlertConsumers ; export const validFeatureIds = Object . values ( AlertConsumers ) . map ( ( v ) => v as string ) ; export const isValidFeatureId = ( a ) : a is ValidFeatureId => typeof a === 'string' && validFeatureIds . includes ( a ) ; param sortIds returns export const getSafeSortIds = ( sortIds ) => { if ( sortIds == null ) { return sortIds ; } return sortIds . map ( ( sortId ) => { if ( sortId == null || sortId === '' || sortId >= Number . MAX_SAFE_INTEGER ) { return '9223372036854775807' ; } return sortId ; } ) ; } ; interface GetEsQueryConfigParamType { allowLeadingWildcards ? : EsQueryConfig [ 'allowLeadingWildcards' ] ; queryStringOptions ? : EsQueryConfig [ 'queryStringOptions' ] ; ignoreFilterIfFieldNotInIndex ? : EsQueryConfig [ 'ignoreFilterIfFieldNotInIndex' ] ; dateFormatTZ ? : EsQueryConfig [ 'dateFormatTZ' ] ; } type ConfigKeys = keyof GetEsQueryConfigParamType ; export const getEsQueryConfig = ( params ? ) : EsQueryConfig => { const defaultConfigValues = { allowLeadingWildcards : true , queryStringOptions : { analyze_wildcard : true } , ignoreFilterIfFieldNotInIndex : false , dateFormatTZ : 'Zulu' , } ; if ( params == null ) { return defaultConfigValues ; } const paramKeysWithValues = Object . keys ( params ) . reduce ( ( acc , key ) => { const configKey = key as ConfigKeys ; if ( params [ configKey ] != null ) { return { [ key ] : params [ configKey ] , ... acc } ; } return { [ key ] : defaultConfigValues [ configKey ] , ... acc } ; } , { } as EsQueryConfig ) ; return paramKeysWithValues ; } ;