import { z } from 'zod'; export const GameAnnouncementStatusSchema = z.enum([ 'draft', 'scheduled', 'active', 'ended', 'offline', ]); export const GameAnnouncementChannelSchema = z.enum(['login', 'banner', 'marquee']); export const GameAnnouncementScopeSchema = z.enum(['all', 'servers']); export const GameAnnouncementSchema = z .object({ id: z.string().min(1), title: z.string().min(1), content: z.string().min(1), channel: GameAnnouncementChannelSchema, status: GameAnnouncementStatusSchema, scope: GameAnnouncementScopeSchema, serverIds: z.array(z.string().min(1)), serverNames: z.array(z.string().min(1)), priority: z.number().int().min(1).max(100), startAt: z.string().nullable(), endAt: z.string().nullable(), createdAt: z.string().min(1), updatedAt: z.string().min(1), createdBy: z.string().min(1), publishedAt: z.string().nullable(), viewCount: z.number().int().nonnegative(), clickCount: z.number().int().nonnegative(), }) .strict(); export const GameAnnouncementSummarySchema = z .object({ total: z.number().int().nonnegative(), active: z.number().int().nonnegative(), scheduled: z.number().int().nonnegative(), draft: z.number().int().nonnegative(), inactive: z.number().int().nonnegative(), }) .strict(); export const GameAnnouncementOptionSchema = z .object({ value: z.string().min(1), label: z.string().min(1), }) .strict(); export const GameAnnouncementListSchema = z .object({ items: z.array(GameAnnouncementSchema), total: z.number().int().nonnegative(), page: z.number().int().positive(), pageSize: z.number().int().positive(), summary: GameAnnouncementSummarySchema, serverOptions: z.array(GameAnnouncementOptionSchema), }) .strict(); export const GameAnnouncementUpsertInputSchema = z .object({ title: z.string().trim().min(1).max(80), content: z.string().trim().min(1).max(5000), channel: GameAnnouncementChannelSchema, serverIds: z.array(z.string().min(1)).max(100), priority: z.number().int().min(1).max(100), startAt: z.string().nullable(), endAt: z.string().nullable(), mode: z.enum(['draft', 'publish']), }) .strict() .refine( (value) => !value.startAt || !value.endAt || value.startAt < value.endAt, 'Announcement end time must be later than the start time', ); export const GameAnnouncementStatusInputSchema = z .object({ action: z.enum(['publish', 'offline']) }) .strict(); export type GameAnnouncementStatus = z.infer; export type GameAnnouncementChannel = z.infer; export type GameAnnouncementScope = z.infer; export type GameAnnouncement = z.infer; export type GameAnnouncementSummary = z.infer; export type GameAnnouncementList = z.infer; export type GameAnnouncementUpsertInput = z.infer; export type GameAnnouncementStatusInput = z.infer;