import { SavedObjectAttribute , SavedObjectAttributes , SavedObjectsResolveResponse , } from 'kibana/server' ; import { AlertNotifyWhenType } from './alert_notify_when_type' ; export type AlertTypeState = Record < string , unknown > ; export type AlertTypeParams = Record < string , unknown > ; export interface IntervalSchedule extends SavedObjectAttributes { interval : string ; } export const AlertExecutionStatusValues = [ 'ok' , 'active' , 'error' , 'pending' , 'unknown' ] as const ; export type AlertExecutionStatuses = typeof AlertExecutionStatusValues [ number ] ; export enum AlertExecutionStatusErrorReasons { Read = 'read' , Decrypt = 'decrypt' , Execute = 'execute' , Unknown = 'unknown' , License = 'license' , Timeout = 'timeout' , Disabled = 'disabled' } export interface AlertExecutionStatus { status : AlertExecutionStatuses ; lastExecutionDate : Date ; lastDuration ? : number ; error ? : { reason : AlertExecutionStatusErrorReasons ; message : string ; } ; } export type AlertActionParams = SavedObjectAttributes ; export type AlertActionParam = SavedObjectAttribute ; export interface AlertAction { group : string ; id : string ; actionTypeId : string ; params : AlertActionParams ; } export interface AlertAggregations { alertExecutionStatus : { [ status ] : number ; } ; ruleEnabledStatus : { enabled : number ; disabled : number ; } ; ruleMutedStatus : { muted : number ; unmuted : number ; } ; } export interface Alert < Params extends AlertTypeParams = never > { id : string ; enabled : boolean ; name : string ; tags : string [ ] ; alertTypeId : string ; consumer : string ; schedule : IntervalSchedule ; actions : AlertAction [ ] ; params : Params ; scheduledTaskId ? : string ; createdBy : string | null ; updatedBy : string | null ; createdAt : Date ; updatedAt : Date ; apiKey : string | null ; apiKeyOwner : string | null ; throttle : string | null ; notifyWhen : AlertNotifyWhenType | null ; muteAll : boolean ; mutedInstanceIds : string [ ] ; executionStatus : AlertExecutionStatus ; } export type SanitizedAlert < Params extends AlertTypeParams = never > = Omit < Alert < Params > , 'apiKey' > ; export type ResolvedSanitizedRule < Params extends AlertTypeParams = never > = SanitizedAlert < Params > & Omit < SavedObjectsResolveResponse , 'saved_object' > ; export type SanitizedRuleConfig = Pick < SanitizedAlert , 'name' | 'tags' | 'consumer' | 'enabled' | 'schedule' | 'actions' | 'createdBy' | 'updatedBy' | 'createdAt' | 'updatedAt' | 'throttle' | 'notifyWhen' > & { producer : string ; ruleTypeId : string ; ruleTypeName : string ; } ; export enum HealthStatus { OK = 'ok' , Warning = 'warn' , Error = 'error' } export interface AlertsHealth { decryptionHealth : { status : HealthStatus ; timestamp : string ; } ; executionHealth : { status : HealthStatus ; timestamp : string ; } ; readHealth : { status : HealthStatus ; timestamp : string ; } ; } export interface ActionVariable { name : string ; description : string ; deprecated ? : boolean ; useWithTripleBracesInTemplates ? : boolean ; }