From 0c8b26a9fd97f94510117116a402904da98a3d4f Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Wed, 30 Dec 2020 11:26:47 +0000 Subject: [PATCH] ensure reserved types arent in aciton groups in executor --- .../plugins/alerts/common/builtin_action_groups.ts | 6 +++++- x-pack/plugins/alerts/server/types.ts | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/alerts/common/builtin_action_groups.ts b/x-pack/plugins/alerts/common/builtin_action_groups.ts index ac1e83e4244d1..552250d6e71ce 100644 --- a/x-pack/plugins/alerts/common/builtin_action_groups.ts +++ b/x-pack/plugins/alerts/common/builtin_action_groups.ts @@ -16,8 +16,12 @@ export const RecoveredActionGroup: Readonly> = Object.f }), }); +export type ReservedActionGroups = + | RecoveryActionGroupId + | RecoveredActionGroupId; + export function getBuiltinActionGroups( customRecoveryGroup?: ActionGroup -): [ActionGroup] { +): [ActionGroup>] { return [customRecoveryGroup ?? RecoveredActionGroup]; } diff --git a/x-pack/plugins/alerts/server/types.ts b/x-pack/plugins/alerts/server/types.ts index 429493f3d3f17..f56c0749bd7bb 100644 --- a/x-pack/plugins/alerts/server/types.ts +++ b/x-pack/plugins/alerts/server/types.ts @@ -29,6 +29,7 @@ import { AlertExecutionStatusErrorReasons, AlertsHealth, AlertNotifyWhenType, + ReservedActionGroups, } from '../common'; import { LicenseType } from '../../licensing/server'; @@ -118,7 +119,17 @@ export interface AlertType< actionGroups: Array>; defaultActionGroupId: ActionGroup['id']; recoveryActionGroup?: ActionGroup; - executor: ExecutorType; + executor: ExecutorType< + Params, + State, + InstanceState, + InstanceContext, + /** + * Ensure that the reserved ActionGroups (such as `Recovered`) are not + * available for scheduling in the Executor + */ + ActionGroupIds extends ReservedActionGroups ? never : ActionGroupIds + >; producer: string; actionVariables?: { context?: ActionVariable[];