fix(cron): use separate schema for failureDestination and fix type cast

- Create CronFailureDestinationSchema excluding after/cooldownMs fields
- Fix type cast in sendFailureNotificationAnnounce to use CronMessageChannel
This commit is contained in:
Evgeny Zislis
2026-03-02 02:21:05 +02:00
committed by Tak Hoffman
parent 7146ec31da
commit 59d2af8dee
2 changed files with 12 additions and 2 deletions

View File

@@ -215,7 +215,7 @@ export async function sendFailureNotificationAnnounce(
): Promise<void> {
const cfg = loadConfig();
const resolvedTarget = await resolveDeliveryTarget(cfg, agentId, {
channel: target.channel as "last" | undefined,
channel: target.channel as CronMessageChannel | undefined,
to: target.to,
accountId: target.accountId,
});

View File

@@ -150,11 +150,21 @@ export const CronFailureAlertSchema = Type.Object(
{ additionalProperties: false },
);
export const CronFailureDestinationSchema = Type.Object(
{
channel: Type.Optional(Type.Union([Type.Literal("last"), NonEmptyString])),
to: Type.Optional(Type.String()),
accountId: Type.Optional(NonEmptyString),
mode: Type.Optional(Type.Union([Type.Literal("announce"), Type.Literal("webhook")])),
},
{ additionalProperties: false },
);
const CronDeliverySharedProperties = {
channel: Type.Optional(Type.Union([Type.Literal("last"), NonEmptyString])),
accountId: Type.Optional(NonEmptyString),
bestEffort: Type.Optional(Type.Boolean()),
failureDestination: Type.Optional(CronFailureAlertSchema),
failureDestination: Type.Optional(CronFailureDestinationSchema),
};
const CronDeliveryNoopSchema = Type.Object(