import { z } from "zod"; // Shared between apps/api (server-side validation, source of truth) and // apps/admin-web (client-side validation for instant feedback). Same // rationale as schemas/auth.ts — one set of rules, French messages surfaced // as-is in the admin login form. /** * Payload accepted by `POST /admin/auth/login`. Deliberately its own schema * (not a re-export of `loginSchema`): the admin surface is a separate * contract from the end-user one even though the shape currently matches. */ export const adminLoginSchema = z.object({ email: z.string().trim().toLowerCase().email("Email invalide"), password: z.string().min(1, "Le mot de passe est requis"), }); /** Inferred TS type for {@link adminLoginSchema}'s validated output. */ export type AdminLoginInput = z.infer; /** * Query params for `GET /admin/metrics` — `?days=` bounds how far back the * time-series go (and how many daily buckets they carry). Coerced from the * query string; clamped to a sane window so a huge value can't make the * dashboard scan the whole history. */ export const getMetricsSchema = z.object({ days: z.coerce.number().int().min(7).max(365).default(30), }); /** Inferred TS type for {@link getMetricsSchema}'s validated output. */ export type GetMetricsInput = z.infer;