Skip to content

Commit

Permalink
ensure reserved types arent in aciton groups in executor
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Dec 30, 2020
1 parent 582b60d commit 0c8b26a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion x-pack/plugins/alerts/common/builtin_action_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ export const RecoveredActionGroup: Readonly<ActionGroup<'recovered'>> = Object.f
}),
});

export type ReservedActionGroups<RecoveryActionGroupId extends string> =
| RecoveryActionGroupId
| RecoveredActionGroupId;

export function getBuiltinActionGroups<RecoveryActionGroupId extends string>(
customRecoveryGroup?: ActionGroup<RecoveryActionGroupId>
): [ActionGroup<RecoveryActionGroupId | RecoveredActionGroupId>] {
): [ActionGroup<ReservedActionGroups<RecoveryActionGroupId>>] {
return [customRecoveryGroup ?? RecoveredActionGroup];
}
13 changes: 12 additions & 1 deletion x-pack/plugins/alerts/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
AlertExecutionStatusErrorReasons,
AlertsHealth,
AlertNotifyWhenType,
ReservedActionGroups,
} from '../common';
import { LicenseType } from '../../licensing/server';

Expand Down Expand Up @@ -118,7 +119,17 @@ export interface AlertType<
actionGroups: Array<ActionGroup<ActionGroupIds>>;
defaultActionGroupId: ActionGroup<ActionGroupIds>['id'];
recoveryActionGroup?: ActionGroup<RecoveryActionGroupId>;
executor: ExecutorType<Params, State, InstanceState, InstanceContext, ActionGroupIds>;
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<RecoveryActionGroupId> ? never : ActionGroupIds
>;
producer: string;
actionVariables?: {
context?: ActionVariable[];
Expand Down

0 comments on commit 0c8b26a

Please sign in to comment.