This commit is contained in:
1 parent
8efd032cc6
commit
df38dccbf1
735 files changed
+128321
-120870
No files matched your search
+50
-34
@@ -4,51 +4,67 @@ import { z } from "zod";
|
||||
const emptyToUndefined = (v: unknown) => (v === "" ? undefined : v);
|
||||
|
||||
export const eventTypeSchema = z.object({
|
||||
name: z.string().min(1, "Name is required").max(100),
|
||||
slug: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(100)
|
||||
.regex(/^[a-z0-9-]+$/, "Slug must be lowercase with hyphens"),
|
||||
description: z.string().max(500).optional().default(""),
|
||||
color: z.string().max(20).optional().default("#3b82f6"),
|
||||
icon: z.string().max(50).optional().default("calendar"),
|
||||
isActive: z.coerce.number().int().min(0).max(1).default(1),
|
||||
minRank: z.coerce.number().int().min(0).max(7).default(0),
|
||||
name: z.string().min(1, "Name is required").max(100),
|
||||
slug: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(100)
|
||||
.regex(/^[a-z0-9-]+$/, "Slug must be lowercase with hyphens"),
|
||||
description: z.string().max(500).optional().default(""),
|
||||
color: z.string().max(20).optional().default("#3b82f6"),
|
||||
icon: z.string().max(50).optional().default("calendar"),
|
||||
isActive: z.coerce.number().int().min(0).max(1).default(1),
|
||||
minRank: z.coerce.number().int().min(0).max(7).default(0),
|
||||
});
|
||||
|
||||
export const createEventSchema = z.object({
|
||||
title: z.string().min(1, "Title is required").max(255),
|
||||
description: z.string().min(1, "Description is required"),
|
||||
typeId: z.coerce.number().int().positive(),
|
||||
roomId: z.preprocess(emptyToUndefined, z.coerce.number().int().positive().nullable().optional()),
|
||||
startsAt: z.coerce.date(),
|
||||
endsAt: z.preprocess(emptyToUndefined, z.coerce.date().nullable().optional()),
|
||||
maxPlayers: z.preprocess(emptyToUndefined, z.coerce.number().int().positive().nullable().optional()),
|
||||
isRecurring: z.coerce.number().int().min(0).max(1).default(0),
|
||||
recurrenceRule: z.preprocess(emptyToUndefined, z.string().max(255).nullable().optional()),
|
||||
status: z.enum(["draft", "published", "cancelled", "completed"]).default("draft"),
|
||||
image: z.preprocess(emptyToUndefined, z.string().max(500).nullable().optional()),
|
||||
title: z.string().min(1, "Title is required").max(255),
|
||||
description: z.string().min(1, "Description is required"),
|
||||
typeId: z.coerce.number().int().positive(),
|
||||
roomId: z.preprocess(
|
||||
emptyToUndefined,
|
||||
z.coerce.number().int().positive().nullable().optional(),
|
||||
),
|
||||
startsAt: z.coerce.date(),
|
||||
endsAt: z.preprocess(emptyToUndefined, z.coerce.date().nullable().optional()),
|
||||
maxPlayers: z.preprocess(
|
||||
emptyToUndefined,
|
||||
z.coerce.number().int().positive().nullable().optional(),
|
||||
),
|
||||
isRecurring: z.coerce.number().int().min(0).max(1).default(0),
|
||||
recurrenceRule: z.preprocess(
|
||||
emptyToUndefined,
|
||||
z.string().max(255).nullable().optional(),
|
||||
),
|
||||
status: z
|
||||
.enum(["draft", "published", "cancelled", "completed"])
|
||||
.default("draft"),
|
||||
image: z.preprocess(
|
||||
emptyToUndefined,
|
||||
z.string().max(500).nullable().optional(),
|
||||
),
|
||||
});
|
||||
|
||||
export const updateEventSchema = createEventSchema.partial();
|
||||
|
||||
export const eventPrizeSchema = z.object({
|
||||
eventId: z.coerce.number().int().positive(),
|
||||
position: z.coerce.number().int().positive().default(1),
|
||||
prizeType: z.enum(["badge", "credits", "pixels", "points", "item"]).default("badge"),
|
||||
badgeCode: z.string().max(50).nullable().optional(),
|
||||
credits: z.coerce.number().int().min(0).default(0),
|
||||
pixels: z.coerce.number().int().min(0).default(0),
|
||||
points: z.coerce.number().int().min(0).default(0),
|
||||
itemId: z.coerce.number().int().positive().nullable().optional(),
|
||||
description: z.string().max(255).optional().default(""),
|
||||
eventId: z.coerce.number().int().positive(),
|
||||
position: z.coerce.number().int().positive().default(1),
|
||||
prizeType: z
|
||||
.enum(["badge", "credits", "pixels", "points", "item"])
|
||||
.default("badge"),
|
||||
badgeCode: z.string().max(50).nullable().optional(),
|
||||
credits: z.coerce.number().int().min(0).default(0),
|
||||
pixels: z.coerce.number().int().min(0).default(0),
|
||||
points: z.coerce.number().int().min(0).default(0),
|
||||
itemId: z.coerce.number().int().positive().nullable().optional(),
|
||||
description: z.string().max(255).optional().default(""),
|
||||
});
|
||||
|
||||
export const eventWinnerSchema = z.object({
|
||||
eventId: z.coerce.number().int().positive(),
|
||||
userId: z.coerce.number().int().positive(),
|
||||
position: z.coerce.number().int().positive().default(1),
|
||||
eventId: z.coerce.number().int().positive(),
|
||||
userId: z.coerce.number().int().positive(),
|
||||
position: z.coerce.number().int().positive().default(1),
|
||||
});
|
||||
|
||||
export type EventTypeInput = z.infer<typeof eventTypeSchema>;
|
||||
|
||||
+14
-14
@@ -1,28 +1,28 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const createPollSchema = z.object({
|
||||
title: z.string().min(1, "Title is required").max(255),
|
||||
description: z.string().max(2000).nullable().optional(),
|
||||
status: z.enum(["draft", "active", "closed"]).default("draft"),
|
||||
showResults: z.coerce.number().int().min(0).max(1).default(1),
|
||||
multipleChoice: z.coerce.number().int().min(0).max(1).default(0),
|
||||
startsAt: z.coerce.date().nullable().optional(),
|
||||
endsAt: z.coerce.date().nullable().optional(),
|
||||
title: z.string().min(1, "Title is required").max(255),
|
||||
description: z.string().max(2000).nullable().optional(),
|
||||
status: z.enum(["draft", "active", "closed"]).default("draft"),
|
||||
showResults: z.coerce.number().int().min(0).max(1).default(1),
|
||||
multipleChoice: z.coerce.number().int().min(0).max(1).default(0),
|
||||
startsAt: z.coerce.date().nullable().optional(),
|
||||
endsAt: z.coerce.date().nullable().optional(),
|
||||
});
|
||||
|
||||
export const updatePollSchema = createPollSchema.partial();
|
||||
|
||||
export const pollQuestionSchema = z.object({
|
||||
pollId: z.coerce.number().int().positive(),
|
||||
question: z.string().min(1).max(500),
|
||||
type: z.enum(["single", "multiple", "text"]).default("single"),
|
||||
sortOrder: z.coerce.number().int().min(0).default(0),
|
||||
options: z.string().min(1, "Options are required"),
|
||||
pollId: z.coerce.number().int().positive(),
|
||||
question: z.string().min(1).max(500),
|
||||
type: z.enum(["single", "multiple", "text"]).default("single"),
|
||||
sortOrder: z.coerce.number().int().min(0).default(0),
|
||||
options: z.string().min(1, "Options are required"),
|
||||
});
|
||||
|
||||
export const pollVoteSchema = z.object({
|
||||
questionId: z.coerce.number().int().positive(),
|
||||
answer: z.string().min(1).max(500),
|
||||
questionId: z.coerce.number().int().positive(),
|
||||
answer: z.string().min(1).max(500),
|
||||
});
|
||||
|
||||
export type CreatePollInput = z.infer<typeof createPollSchema>;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const updateRoomSchema = z.object({
|
||||
name: z.string().min(1).max(60).optional(),
|
||||
description: z.string().max(512).optional(),
|
||||
state: z.enum(["open", "locked", "password", "invisible"]).optional(),
|
||||
usersMax: z.number().int().min(1).max(100).optional(),
|
||||
name: z.string().min(1).max(60).optional(),
|
||||
description: z.string().max(512).optional(),
|
||||
state: z.enum(["open", "locked", "password", "invisible"]).optional(),
|
||||
usersMax: z.number().int().min(1).max(100).optional(),
|
||||
});
|
||||
|
||||
export type UpdateRoomInput = z.infer<typeof updateRoomSchema>;
|
||||
@@ -1,37 +1,54 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const TICKET_CATEGORIES = ["general", "account", "technical", "report", "billing", "other"] as const;
|
||||
export const TICKET_CATEGORIES = [
|
||||
"general",
|
||||
"account",
|
||||
"technical",
|
||||
"report",
|
||||
"billing",
|
||||
"other",
|
||||
] as const;
|
||||
export const TICKET_PRIORITIES = ["low", "normal", "high", "urgent"] as const;
|
||||
export const TICKET_STATUSES = ["open", "in_progress", "waiting", "closed"] as const;
|
||||
export const TICKET_STATUSES = [
|
||||
"open",
|
||||
"in_progress",
|
||||
"waiting",
|
||||
"closed",
|
||||
] as const;
|
||||
|
||||
export const createTicketSchema = z.object({
|
||||
subject: z.string().min(5, "Subject must be at least 5 characters").max(255),
|
||||
message: z.string().min(10, "Message must be at least 10 characters").max(5000),
|
||||
category: z.enum(TICKET_CATEGORIES),
|
||||
subject: z.string().min(5, "Subject must be at least 5 characters").max(255),
|
||||
message: z
|
||||
.string()
|
||||
.min(10, "Message must be at least 10 characters")
|
||||
.max(5000),
|
||||
category: z.enum(TICKET_CATEGORIES),
|
||||
});
|
||||
|
||||
export const replyTicketSchema = z.object({
|
||||
ticketId: z.coerce.number().int().positive(),
|
||||
message: z.string().min(1, "Message is required").max(5000),
|
||||
ticketId: z.coerce.number().int().positive(),
|
||||
message: z.string().min(1, "Message is required").max(5000),
|
||||
});
|
||||
|
||||
export const updateTicketStatusSchema = z.object({
|
||||
ticketId: z.coerce.number().int().positive(),
|
||||
status: z.enum(TICKET_STATUSES),
|
||||
ticketId: z.coerce.number().int().positive(),
|
||||
status: z.enum(TICKET_STATUSES),
|
||||
});
|
||||
|
||||
export const assignTicketSchema = z.object({
|
||||
ticketId: z.coerce.number().int().positive(),
|
||||
assigneeId: z.coerce.number().int().positive().nullable(),
|
||||
ticketId: z.coerce.number().int().positive(),
|
||||
assigneeId: z.coerce.number().int().positive().nullable(),
|
||||
});
|
||||
|
||||
export const updateTicketPrioritySchema = z.object({
|
||||
ticketId: z.coerce.number().int().positive(),
|
||||
priority: z.enum(TICKET_PRIORITIES),
|
||||
ticketId: z.coerce.number().int().positive(),
|
||||
priority: z.enum(TICKET_PRIORITIES),
|
||||
});
|
||||
|
||||
export type CreateTicketInput = z.infer<typeof createTicketSchema>;
|
||||
export type ReplyTicketInput = z.infer<typeof replyTicketSchema>;
|
||||
export type UpdateTicketStatusInput = z.infer<typeof updateTicketStatusSchema>;
|
||||
export type AssignTicketInput = z.infer<typeof assignTicketSchema>;
|
||||
export type UpdateTicketPriorityInput = z.infer<typeof updateTicketPrioritySchema>;
|
||||
export type UpdateTicketPriorityInput = z.infer<
|
||||
typeof updateTicketPrioritySchema
|
||||
>;
|
||||
+27
-24
@@ -1,39 +1,42 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const createUserSchema = z.object({
|
||||
username: z
|
||||
.string()
|
||||
.min(3, "Username must be at least 3 characters")
|
||||
.max(20, "Username must be at most 20 characters")
|
||||
.regex(/^[a-zA-Z0-9_-]+$/, "Username can only contain letters, numbers, _ and -"),
|
||||
mail: z.string().email("Invalid email address"),
|
||||
password: z.string().min(6, "Password must be at least 6 characters"),
|
||||
rank: z.coerce.number().int().min(1).max(7).default(1),
|
||||
motto: z.string().max(127).default(""),
|
||||
username: z
|
||||
.string()
|
||||
.min(3, "Username must be at least 3 characters")
|
||||
.max(20, "Username must be at most 20 characters")
|
||||
.regex(
|
||||
/^[a-zA-Z0-9_-]+$/,
|
||||
"Username can only contain letters, numbers, _ and -",
|
||||
),
|
||||
mail: z.string().email("Invalid email address"),
|
||||
password: z.string().min(6, "Password must be at least 6 characters"),
|
||||
rank: z.coerce.number().int().min(1).max(7).default(1),
|
||||
motto: z.string().max(127).default(""),
|
||||
});
|
||||
|
||||
export const updateUserSchema = z.object({
|
||||
username: z.string().min(3).max(20).optional(),
|
||||
mail: z.string().email().optional(),
|
||||
rank: z.number().int().min(1).max(7).optional(),
|
||||
motto: z.string().max(127).optional(),
|
||||
credits: z.number().int().min(0).max(2147483647).optional(),
|
||||
pixels: z.number().int().min(0).max(2147483647).optional(),
|
||||
diamonds: z.number().int().min(0).max(2147483647).optional(),
|
||||
duckets: z.number().int().min(0).max(2147483647).optional(),
|
||||
username: z.string().min(3).max(20).optional(),
|
||||
mail: z.string().email().optional(),
|
||||
rank: z.number().int().min(1).max(7).optional(),
|
||||
motto: z.string().max(127).optional(),
|
||||
credits: z.number().int().min(0).max(2147483647).optional(),
|
||||
pixels: z.number().int().min(0).max(2147483647).optional(),
|
||||
diamonds: z.number().int().min(0).max(2147483647).optional(),
|
||||
duckets: z.number().int().min(0).max(2147483647).optional(),
|
||||
});
|
||||
|
||||
export const banUserSchema = z.object({
|
||||
userId: z.coerce.number().int().positive(),
|
||||
reason: z.string().min(1, "Ban reason is required").max(500),
|
||||
duration: z.coerce.number().int().min(0, "Duration must be 0 or more hours"),
|
||||
type: z.enum(["account", "ip", "machine"]).default("account"),
|
||||
ip: z.string().optional(),
|
||||
userId: z.coerce.number().int().positive(),
|
||||
reason: z.string().min(1, "Ban reason is required").max(500),
|
||||
duration: z.coerce.number().int().min(0, "Duration must be 0 or more hours"),
|
||||
type: z.enum(["account", "ip", "machine"]).default("account"),
|
||||
ip: z.string().optional(),
|
||||
});
|
||||
|
||||
export const giveBadgeSchema = z.object({
|
||||
userId: z.coerce.number().int().positive(),
|
||||
badgeCode: z.string().min(1, "Badge code is required").max(20),
|
||||
userId: z.coerce.number().int().positive(),
|
||||
badgeCode: z.string().min(1, "Badge code is required").max(20),
|
||||
});
|
||||
|
||||
export type CreateUserInput = z.infer<typeof createUserSchema>;
|
||||
|
||||
Reference in new issue
Block a user