mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix: allow cron delivery clears
This commit is contained in:
@@ -99,6 +99,39 @@ describe("cron protocol validators", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts nullable delivery clears on update params", () => {
|
||||
expect(
|
||||
validateCronUpdateParams({
|
||||
id: "job-1",
|
||||
patch: {
|
||||
delivery: {
|
||||
channel: null,
|
||||
to: null,
|
||||
threadId: null,
|
||||
accountId: null,
|
||||
failureDestination: null,
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
validateCronUpdateParams({
|
||||
id: "job-1",
|
||||
patch: {
|
||||
delivery: {
|
||||
failureDestination: {
|
||||
channel: null,
|
||||
to: null,
|
||||
accountId: null,
|
||||
mode: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts remove params for id and jobId selectors", () => {
|
||||
expect(validateCronRemoveParams({ id: "job-1" })).toBe(true);
|
||||
expect(validateCronRemoveParams({ jobId: "job-2" })).toBe(true);
|
||||
|
||||
@@ -235,6 +235,18 @@ export const CronFailureDestinationSchema = Type.Object(
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
const CronFailureDestinationPatchSchema = Type.Object(
|
||||
{
|
||||
channel: Type.Optional(Type.Union([Type.Literal("last"), NonEmptyString, Type.Null()])),
|
||||
to: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
||||
accountId: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
||||
mode: Type.Optional(
|
||||
Type.Union([Type.Literal("announce"), Type.Literal("webhook"), Type.Null()]),
|
||||
),
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const CronCompletionDestinationSchema = Type.Object(
|
||||
{
|
||||
mode: Type.Literal("webhook"),
|
||||
@@ -251,6 +263,14 @@ const CronDeliverySharedProperties = {
|
||||
failureDestination: Type.Optional(CronFailureDestinationSchema),
|
||||
};
|
||||
|
||||
const CronDeliveryPatchSharedProperties = {
|
||||
channel: Type.Optional(Type.Union([Type.Literal("last"), NonEmptyString, Type.Null()])),
|
||||
threadId: Type.Optional(Type.Union([Type.String(), Type.Number(), Type.Null()])),
|
||||
accountId: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
||||
bestEffort: Type.Optional(Type.Boolean()),
|
||||
failureDestination: Type.Optional(Type.Union([CronFailureDestinationPatchSchema, Type.Null()])),
|
||||
};
|
||||
|
||||
const CronDeliveryNoopSchema = Type.Object(
|
||||
{
|
||||
mode: Type.Literal("none"),
|
||||
@@ -290,11 +310,11 @@ export const CronDeliveryPatchSchema = Type.Object(
|
||||
mode: Type.Optional(
|
||||
Type.Union([Type.Literal("none"), Type.Literal("announce"), Type.Literal("webhook")]),
|
||||
),
|
||||
...CronDeliverySharedProperties,
|
||||
...CronDeliveryPatchSharedProperties,
|
||||
completionDestination: Type.Optional(
|
||||
Type.Union([CronCompletionDestinationSchema, Type.Null()]),
|
||||
),
|
||||
to: Type.Optional(Type.String()),
|
||||
to: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user