import { z } from "zod";
// ─── New Zod schemas ──────────────────────────────────────────────────────────
/** Legacy schema endpoint query: formCode + version */
export const SchemaQuerySchema = z.object({
    formCode: z.string().min(1),
    version: z.string().min(1),
});
/** Submit answers to a form */
export const SubmissionBodySchema = z.object({
    formCode: z.string().min(1),
    version: z.string().min(1),
    moduleCode: z.string().min(1),
    submittedBy: z.string().optional(),
    answers: z.record(z.string(), z.unknown()),
});
/** Create a new form with its initial version */
export const CreateFormBodySchema = z.object({
    code: z.string().min(1),
    displayName: z.string().min(1),
    description: z.string().optional(),
    surveyJson: z.record(z.string(), z.unknown()),
    schemaChecksum: z.string().min(1),
    semver: z.string().optional().default("1.0.0"),
    /** platform.module.code — e.g. "audit", "inspection", "checklist" */
    moduleCode: z.string().optional().default("audit"),
});
/** Update form metadata and/or save a schema draft */
export const UpdateFormBodySchema = z.object({
    displayName: z.string().min(1).optional(),
    description: z.string().nullable().optional(),
    isActive: z.boolean().optional(),
    surveyJson: z.record(z.string(), z.unknown()).optional(),
    schemaChecksum: z.string().optional(),
    semver: z.string().optional(),
});
/** Publish a new version to an existing form */
export const PublishVersionBodySchema = z.object({
    semver: z.string().min(1),
    surveyJson: z.record(z.string(), z.unknown()),
    questionIndex: z.record(z.string(), z.unknown()).optional().default({}),
    schemaChecksum: z.string().min(1),
    publishedBy: z.string().uuid().optional(),
});
/** List submissions query params */
export const ListSubmissionsQuerySchema = z.object({
    formId: z.string().uuid("formId must be a valid UUID"),
    page: z.coerce.number().int().positive().default(1),
    limit: z.coerce.number().int().min(1).max(200).default(50),
    status: z.string().optional(),
});
