import { z } from "zod";

export const createTextbookSchema = z.object({
  title: z.string().min(1).max(255),
  subjectId: z.string().min(1).max(32),
  gradeId: z.string().min(1).max(32),
  version: z.string().max(32).optional().default("1.0"),
  metadata: z.record(z.unknown()).nullish(),
});

export const updateTextbookSchema = z.object({
  title: z.string().min(1).max(255).optional(),
  status: z
    .enum(["draft", "pending_review", "published", "archived"])
    .optional(),
  metadata: z.record(z.unknown()).nullish(),
});

export const listTextbooksSchema = z.object({
  subjectId: z.string().optional(),
  gradeId: z.string().optional(),
  page: z.coerce.number().int().min(1).default(1),
  pageSize: z.coerce.number().int().min(1).max(100).default(20),
});

export type CreateTextbookDto = z.infer<typeof createTextbookSchema>;
export type UpdateTextbookDto = z.infer<typeof updateTextbookSchema>;
export type ListTextbooksDto = z.infer<typeof listTextbooksSchema>;
