style: clean up code with prettier and eslint
This commit is contained in:
1 parent
60278b9e71
commit
fb8e77bb68
378 files changed
+22407
-20689
No files matched your search
+23
-26
@@ -1,61 +1,58 @@
|
||||
import { z } from 'zod'
|
||||
import { z } from "zod";
|
||||
|
||||
/** Convert empty strings to undefined so optional/nullable fields pass validation */
|
||||
const emptyToUndefined = (v: unknown) => (v === '' ? undefined : v)
|
||||
const emptyToUndefined = (v: unknown) => (v === "" ? undefined : v);
|
||||
|
||||
export const eventTypeSchema = z.object({
|
||||
name: z.string().min(1, 'Name is required').max(100),
|
||||
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'),
|
||||
.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'),
|
||||
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(),
|
||||
),
|
||||
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'),
|
||||
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 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'),
|
||||
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(''),
|
||||
})
|
||||
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),
|
||||
})
|
||||
});
|
||||
|
||||
export type EventTypeInput = z.infer<typeof eventTypeSchema>
|
||||
export type CreateEventInput = z.infer<typeof createEventSchema>
|
||||
export type UpdateEventInput = z.infer<typeof updateEventSchema>
|
||||
export type EventPrizeInput = z.infer<typeof eventPrizeSchema>
|
||||
export type EventWinnerInput = z.infer<typeof eventWinnerSchema>
|
||||
export type EventTypeInput = z.infer<typeof eventTypeSchema>;
|
||||
export type CreateEventInput = z.infer<typeof createEventSchema>;
|
||||
export type UpdateEventInput = z.infer<typeof updateEventSchema>;
|
||||
export type EventPrizeInput = z.infer<typeof eventPrizeSchema>;
|
||||
export type EventWinnerInput = z.infer<typeof eventWinnerSchema>;
|
||||
+13
-13
@@ -1,31 +1,31 @@
|
||||
import { z } from 'zod'
|
||||
import { z } from "zod";
|
||||
|
||||
export const createPollSchema = z.object({
|
||||
title: z.string().min(1, 'Title is required').max(255),
|
||||
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'),
|
||||
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 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'),
|
||||
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'),
|
||||
})
|
||||
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),
|
||||
})
|
||||
});
|
||||
|
||||
export type CreatePollInput = z.infer<typeof createPollSchema>
|
||||
export type UpdatePollInput = z.infer<typeof updatePollSchema>
|
||||
export type PollQuestionInput = z.infer<typeof pollQuestionSchema>
|
||||
export type PollVoteInput = z.infer<typeof pollVoteSchema>
|
||||
export type CreatePollInput = z.infer<typeof createPollSchema>;
|
||||
export type UpdatePollInput = z.infer<typeof updatePollSchema>;
|
||||
export type PollQuestionInput = z.infer<typeof pollQuestionSchema>;
|
||||
export type PollVoteInput = z.infer<typeof pollVoteSchema>;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { z } from 'zod'
|
||||
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(),
|
||||
state: z.enum(["open", "locked", "password", "invisible"]).optional(),
|
||||
usersMax: z.number().int().min(1).max(100).optional(),
|
||||
})
|
||||
});
|
||||
|
||||
export type UpdateRoomInput = z.infer<typeof updateRoomSchema>
|
||||
export type UpdateRoomInput = z.infer<typeof updateRoomSchema>;
|
||||
@@ -1,44 +1,37 @@
|
||||
import { z } from 'zod'
|
||||
import { z } from "zod";
|
||||
|
||||
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_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 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),
|
||||
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),
|
||||
})
|
||||
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),
|
||||
})
|
||||
});
|
||||
|
||||
export const assignTicketSchema = z.object({
|
||||
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),
|
||||
})
|
||||
});
|
||||
|
||||
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 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>;
|
||||
+19
-19
@@ -1,16 +1,16 @@
|
||||
import { z } from 'zod'
|
||||
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'),
|
||||
.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(''),
|
||||
})
|
||||
motto: z.string().max(127).default(""),
|
||||
});
|
||||
|
||||
export const updateUserSchema = z.object({
|
||||
username: z.string().min(3).max(20).optional(),
|
||||
@@ -21,22 +21,22 @@ export const updateUserSchema = z.object({
|
||||
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'),
|
||||
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),
|
||||
})
|
||||
badgeCode: z.string().min(1, "Badge code is required").max(20),
|
||||
});
|
||||
|
||||
export type CreateUserInput = z.infer<typeof createUserSchema>
|
||||
export type UpdateUserInput = z.infer<typeof updateUserSchema>
|
||||
export type BanUserInput = z.infer<typeof banUserSchema>
|
||||
export type GiveBadgeInput = z.infer<typeof giveBadgeSchema>
|
||||
export type CreateUserInput = z.infer<typeof createUserSchema>;
|
||||
export type UpdateUserInput = z.infer<typeof updateUserSchema>;
|
||||
export type BanUserInput = z.infer<typeof banUserSchema>;
|
||||
export type GiveBadgeInput = z.infer<typeof giveBadgeSchema>;
|
||||
Reference in new issue
Block a user