Files
khb_microservices/packages/scheduler/src/settings.ts
Yuri Yaryshev ebb1cb7950
Some checks failed
ci / test (push) Failing after 20s
ci / deploy (push) Has been skipped
Каркас monorepo: scheduler, data_collector, khbuild_assistant_prep, khb_common; миграции; CI/CD
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 09:44:55 +03:00

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>;