26 lines
907 B
TypeScript
26 lines
907 B
TypeScript
import { z } from "zod";
|
|
|
|
const daysSchema = z.union([z.literal("daily"), z.literal("workdays"), z.array(z.enum(["mon", "tue", "wed", "thu", "fri", "sat", "sun"]))]);
|
|
|
|
export const jobSchema = z.object({
|
|
name: z.string(),
|
|
call: z.object({
|
|
service: z.string(),
|
|
method: z.enum(["GET", "POST"]).default("POST"),
|
|
path: z.string(),
|
|
body: z.unknown().optional(),
|
|
}),
|
|
at: z.string().regex(/^\d{2}:\d{2}$/),
|
|
days: daysSchema,
|
|
});
|
|
|
|
export const schedulerSchema = z.object({
|
|
tickSeconds: z.number().default(10),
|
|
missedGraceSeconds: z.number().default(60),
|
|
http: z.object({ host: z.string().default("127.0.0.1"), port: z.number(), token: z.string().min(1) }),
|
|
jobs: z.array(jobSchema),
|
|
services: z.record(z.object({ baseUrl: z.string(), token: z.string() })),
|
|
});
|
|
export type SchedulerSettings = z.infer<typeof schedulerSchema>;
|
|
export type JobSettings = z.infer<typeof jobSchema>;
|