import { any, z } from "zod"; import { CameraConfig, FrigateConfig } from "../../types/frigateConfig"; export const putConfigSchema = z.object({ key: z.string(), value: z.string(), }) export const getConfigSchema = z.object({ key: z.string(), value: z.string(), description: z.string(), encrypted: z.boolean(), }) export const getFrigateHostSchema = z.object({ id: z.string(), createAt: z.string(), updateAt: z.string(), name: z.string(), host: z.string(), enabled: z.boolean(), state: z.boolean().nullable().optional() }); export const getFrigateHostWConfigSchema = z.object({ id: z.string(), createAt: z.string(), updateAt: z.string(), name: z.string(), host: z.string(), enabled: z.boolean(), config: z.any(), }); const getCameraSchema = z.object({ id: z.string(), createAt: z.string(), updateAt: z.string(), name: z.string(), url: z.string(), state: z.boolean().nullable(), }); export const getRoleSchema = z.object({ id: z.string(), name: z.string(), createdAt: z.string().datetime(), updatedAt: z.string().datetime(), }) const getCameraWithHostSchema = getCameraSchema.merge(z.object({ frigateHost: getFrigateHostSchema.optional(), roles: getRoleSchema.array().optional(), })) export const getFrigateHostWithCamerasSchema = getFrigateHostSchema.merge(z.object({ cameras: z.array(getCameraSchema), })) export const putFrigateHostSchema = getFrigateHostSchema.omit({ createAt: true, updateAt: true, }); export const deleteFrigateHostSchema = putFrigateHostSchema.pick({ id: true, }); export const getEventsQuerySchema = z.object({ hostName: z.string(), camerasName: z.string().array(), timezone: z.string().optional(), hasClip: z.boolean().optional(), after: z.number().optional(), before: z.number().optional(), labels: z.string().array().optional(), limit: z.number().optional(), includeThumnails: z.boolean().optional(), minScore: z.number().optional(), maxScore: z.number().optional(), }) export const getRoleWCamerasSchema = getRoleSchema.merge(z.object({ cameras: getCameraSchema.array() })) export const getUserByRoleSchema = z.object({ id: z.string(), username: z.string(), enabled: z.boolean(), emailVerified: z.boolean(), firstName: z.string(), lastName: z.string(), email: z.string(), }) export type GetConfig = z.infer export type PutConfig = z.infer export type GetFrigateHost = z.infer export type GetFrigateHostWithCameras = z.infer export type GetFrigateHostWConfig = GetFrigateHost & { config: FrigateConfig } export type GetCameraWHost = z.infer export type GetCameraWHostWConfig = GetCameraWHost & { config?: CameraConfig } export type PutFrigateHost = z.infer export type DeleteFrigateHost = z.infer export type GetRole = z.infer export type GetRoleWCameras = z.infer export type GetUserByRole = z.infer