import { z } from "zod"; import { CameraConfig, FrigateConfig } from "../../types/frigateConfig"; import { cameraTag } from "../../types/tags"; export const putConfigSchema = z.object({ key: z.string(), value: z.string(), }) export const oidpConfig = z.object({ clientId: z.string(), clientSecret: z.string(), clientUsername: z.string(), clientPassword: z.string(), clientURL: 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(), tags: cameraTag.array() }); 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 const getExpotedFile = z.object({ name: z.string(), type: z.string(), mtime: z.string(), size: z.number(), }) export const recordingSchema = z.object({ hostName: z.string(), cameraName: z.string(), hour: z.string(), day: z.string(), timezone: z.string(), }) export type GetConfig = z.infer export type PutConfig = z.infer export type OIDPConfig = z.infer export type GetFrigateHost = z.infer // export type GetFrigateHostWithCameras = z.infer export type GetFrigateHostWConfig = GetFrigateHost & { config: FrigateConfig } export type GetCamera = z.infer 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 export type GetExportedFile = z.infer