mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-27 17:36:25 +02:00
34 lines
898 B
TypeScript
34 lines
898 B
TypeScript
|
|
import { z } from 'zod';
|
||
|
|
|
||
|
|
export const InlineTaskScheduleSchema = z.discriminatedUnion('type', [
|
||
|
|
z.object({
|
||
|
|
type: z.literal('cron'),
|
||
|
|
expression: z.string(),
|
||
|
|
startDate: z.string(),
|
||
|
|
endDate: z.string(),
|
||
|
|
}),
|
||
|
|
z.object({
|
||
|
|
type: z.literal('window'),
|
||
|
|
cron: z.string(),
|
||
|
|
startTime: z.string(),
|
||
|
|
endTime: z.string(),
|
||
|
|
startDate: z.string(),
|
||
|
|
endDate: z.string(),
|
||
|
|
}),
|
||
|
|
z.object({
|
||
|
|
type: z.literal('once'),
|
||
|
|
runAt: z.string(),
|
||
|
|
}),
|
||
|
|
]);
|
||
|
|
|
||
|
|
export type InlineTaskSchedule = z.infer<typeof InlineTaskScheduleSchema>;
|
||
|
|
|
||
|
|
export const InlineTaskBlockSchema = z.object({
|
||
|
|
instruction: z.string(),
|
||
|
|
schedule: InlineTaskScheduleSchema.optional(),
|
||
|
|
'schedule-label': z.string().optional(),
|
||
|
|
lastRunAt: z.string().optional(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export type InlineTaskBlock = z.infer<typeof InlineTaskBlockSchema>;
|