monitor import/export

This commit is contained in:
Alex Holliday committed 2025-11-20 23:27:30 +00:00
1 parent af6fede1b3
commit 6881be7555
12 files changed
+381 -154

No files matched your search

+20
View File
@@ -1,6 +1,7 @@
import {
ChannelTypes,
MonitorStatuses,
MonitorTypes,
ResolutionTypes,
} from "@/db/models/index.js";
import { z } from "zod";
@@ -82,6 +83,25 @@ export const monitorSchema = z
}
});
export const monitorImportSchema = z.object({
monitors: z
.array(
z
.object({
name: z.string().trim().min(1, "Monitor name is required"),
url: z.string().trim().regex(urlRegex, "Invalid URL"),
secret: z.string().trim().optional(),
type: z.enum(MonitorTypes),
interval: z.number().min(1, "Interval must be greater than 0"),
n: z.number().min(1, "n must be at least 1"),
})
.strict()
)
.min(1, { message: "Provide at least one monitor" }),
});
export type MonitorImportPayload = z.infer<typeof monitorImportSchema>;
export const monitorPatchSchema = monitorSchema
.omit({
url: true,