book.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { z } from "zod";
  2. export const PlatformSchema = z.enum(["tomato", "feilu", "qidian", "other"]);
  3. export type Platform = z.infer<typeof PlatformSchema>;
  4. export const GenreSchema = z.string().min(1);
  5. export type Genre = z.infer<typeof GenreSchema>;
  6. export const BookStatusSchema = z.enum([
  7. "incubating",
  8. "outlining",
  9. "active",
  10. "paused",
  11. "completed",
  12. "dropped",
  13. ]);
  14. export type BookStatus = z.infer<typeof BookStatusSchema>;
  15. export const FanficModeSchema = z.enum(["canon", "au", "ooc", "cp"]);
  16. export type FanficMode = z.infer<typeof FanficModeSchema>;
  17. export const BookConfigSchema = z.object({
  18. id: z.string().min(1),
  19. title: z.string().min(1),
  20. platform: PlatformSchema,
  21. genre: GenreSchema,
  22. status: BookStatusSchema,
  23. targetChapters: z.number().int().min(1).default(200),
  24. chapterWordCount: z.number().int().min(1000).default(3000),
  25. language: z.enum(["zh", "en"]).optional(),
  26. createdAt: z.string().datetime(),
  27. updatedAt: z.string().datetime(),
  28. parentBookId: z.string().optional(),
  29. fanficMode: FanficModeSchema.optional(),
  30. });
  31. export type BookConfig = z.infer<typeof BookConfigSchema>;