code made pretty
This commit is contained in:
@@ -1,55 +1,61 @@
|
||||
import { z } from 'zod';
|
||||
import { z } from "zod";
|
||||
|
||||
//category validators
|
||||
|
||||
export const createCategorySchema = z.object({
|
||||
name: z.string().min(1).max(50),
|
||||
position: z.number().min(0),
|
||||
instanceId : z.uuidv7().optional(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4()
|
||||
})
|
||||
name: z.string().min(1).max(50),
|
||||
position: z.number().min(0),
|
||||
instanceId: z.uuidv7().optional(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4(),
|
||||
});
|
||||
|
||||
export const getCategorySchema = z.object({
|
||||
id: z.uuidv7()
|
||||
})
|
||||
id: z.uuidv7(),
|
||||
});
|
||||
|
||||
export const getCategoriesByInstanceIdSchema = z.object({
|
||||
instanceId: z.uuidv7()
|
||||
|
||||
})
|
||||
instanceId: z.uuidv7(),
|
||||
});
|
||||
|
||||
export const updateCategorySchema = z.object({
|
||||
id: z.uuidv7(),
|
||||
name: z.string().min(1).max(50).optional(),
|
||||
position: z.number().min(0).optional(),
|
||||
channels: z.array(z.object({
|
||||
id: z.string()
|
||||
})).optional(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4()
|
||||
})
|
||||
id: z.uuidv7(),
|
||||
name: z.string().min(1).max(50).optional(),
|
||||
position: z.number().min(0).optional(),
|
||||
channels: z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4(),
|
||||
});
|
||||
|
||||
export const deleteCategorySchema = z.object({
|
||||
id: z.uuidv7(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4()
|
||||
})
|
||||
id: z.uuidv7(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4(),
|
||||
});
|
||||
|
||||
export const deleteCategoriesByInstanceIdSchema = z.object({
|
||||
instanceId: z.uuidv7(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4()
|
||||
})
|
||||
instanceId: z.uuidv7(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4(),
|
||||
});
|
||||
|
||||
|
||||
export type CreateCategoryInput = z.infer<typeof createCategorySchema>
|
||||
export type GetCategoryInput = z.infer<typeof getCategorySchema>
|
||||
export type GetCategoriesByInstanceIdInput = z.infer<typeof getCategoriesByInstanceIdSchema>
|
||||
export type UpdateCategoryInput = z.infer<typeof updateCategorySchema>
|
||||
export type DeleteCategoryInput = z.infer<typeof deleteCategorySchema>
|
||||
export type DeleteCategoriesByInstanceIdInput = z.infer<typeof deleteCategoriesByInstanceIdSchema>
|
||||
export type CreateCategoryInput = z.infer<typeof createCategorySchema>;
|
||||
export type GetCategoryInput = z.infer<typeof getCategorySchema>;
|
||||
export type GetCategoriesByInstanceIdInput = z.infer<
|
||||
typeof getCategoriesByInstanceIdSchema
|
||||
>;
|
||||
export type UpdateCategoryInput = z.infer<typeof updateCategorySchema>;
|
||||
export type DeleteCategoryInput = z.infer<typeof deleteCategorySchema>;
|
||||
export type DeleteCategoriesByInstanceIdInput = z.infer<
|
||||
typeof deleteCategoriesByInstanceIdSchema
|
||||
>;
|
||||
|
||||
@@ -3,50 +3,54 @@ import { z } from "zod";
|
||||
//channel validators
|
||||
|
||||
export const createChannelSchema = z.object({
|
||||
type: z.enum(['text', 'voice']),
|
||||
name: z.string().min(1).max(50),
|
||||
description: z.string().max(255),
|
||||
categoryId: z.uuidv7().optional(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4()
|
||||
})
|
||||
type: z.enum(["text", "voice"]),
|
||||
name: z.string().min(1).max(50),
|
||||
description: z.string().max(255),
|
||||
categoryId: z.uuidv7().optional(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4(),
|
||||
});
|
||||
|
||||
export const getChannelSchema = z.object({
|
||||
id: z.uuidv7()
|
||||
})
|
||||
id: z.uuidv7(),
|
||||
});
|
||||
|
||||
export const getChannelsByCategoryIdSchema = z.object({
|
||||
categoryId: z.uuidv7()
|
||||
})
|
||||
categoryId: z.uuidv7(),
|
||||
});
|
||||
|
||||
export const updateChannelSchema = z.object({
|
||||
id: z.uuidv7(),
|
||||
name: z.string().min(1).max(50).optional(),
|
||||
description: z.string().max(255).optional(),
|
||||
categoryId: z.uuidv7().optional(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4()
|
||||
})
|
||||
id: z.uuidv7(),
|
||||
name: z.string().min(1).max(50).optional(),
|
||||
description: z.string().max(255).optional(),
|
||||
categoryId: z.uuidv7().optional(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4(),
|
||||
});
|
||||
|
||||
export const deleteChannelSchema = z.object({
|
||||
id: z.uuidv7(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4()
|
||||
})
|
||||
id: z.uuidv7(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4(),
|
||||
});
|
||||
|
||||
export const deleteChannelsByCategoryIdSchema = z.object({
|
||||
categoryId: z.uuidv7(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4()
|
||||
})
|
||||
categoryId: z.uuidv7(),
|
||||
admin: z.boolean(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.uuidv4(),
|
||||
});
|
||||
|
||||
export type CreateChannelInput = z.infer<typeof createChannelSchema>
|
||||
export type GetChannelInput = z.infer<typeof getChannelSchema>
|
||||
export type GetChannelsByCategoryIdInput = z.infer<typeof getChannelsByCategoryIdSchema>
|
||||
export type UpdateChannelInput = z.infer<typeof updateChannelSchema>
|
||||
export type DeleteChannelInput = z.infer<typeof deleteChannelSchema>
|
||||
export type DeleteChannelsByCategoryIdInput = z.infer<typeof deleteChannelsByCategoryIdSchema>
|
||||
export type CreateChannelInput = z.infer<typeof createChannelSchema>;
|
||||
export type GetChannelInput = z.infer<typeof getChannelSchema>;
|
||||
export type GetChannelsByCategoryIdInput = z.infer<
|
||||
typeof getChannelsByCategoryIdSchema
|
||||
>;
|
||||
export type UpdateChannelInput = z.infer<typeof updateChannelSchema>;
|
||||
export type DeleteChannelInput = z.infer<typeof deleteChannelSchema>;
|
||||
export type DeleteChannelsByCategoryIdInput = z.infer<
|
||||
typeof deleteChannelsByCategoryIdSchema
|
||||
>;
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
import { z } from 'zod';
|
||||
import { z } from "zod";
|
||||
|
||||
export const createInstanceRequestSchema = z.object({
|
||||
name: z.string().min(1, 'Instance name cannot be empty'),
|
||||
icon: z.url().optional(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.string()
|
||||
name: z.string().min(1, "Instance name cannot be empty"),
|
||||
icon: z.url().optional(),
|
||||
requestingUserId: z.uuidv7(),
|
||||
requestingUserToken: z.string(),
|
||||
});
|
||||
|
||||
export const getAllInstancesResponseSchema = z.object({
|
||||
success: z.boolean(),
|
||||
data: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
icon: z.string().nullable(),
|
||||
createdAt: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Invalid date string format"
|
||||
}),
|
||||
updatedAt: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Invalid date string format"
|
||||
})
|
||||
})
|
||||
).optional(),
|
||||
error: z.string().optional()
|
||||
success: z.boolean(),
|
||||
data: z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
icon: z.string().nullable(),
|
||||
createdAt: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Invalid date string format",
|
||||
}),
|
||||
updatedAt: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Invalid date string format",
|
||||
}),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
error: z.string().optional(),
|
||||
});
|
||||
|
||||
export type CreateInstanceRequest = z.infer<typeof createInstanceRequestSchema>;
|
||||
export type GetAllInstancesResponse = z.infer<typeof getAllInstancesResponseSchema>;
|
||||
export type GetAllInstancesResponse = z.infer<
|
||||
typeof getAllInstancesResponseSchema
|
||||
>;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const getMessageByIdSchema = z.object({
|
||||
id: z.uuidv7()
|
||||
})
|
||||
id: z.uuidv7(),
|
||||
});
|
||||
|
||||
export const getMessagesBeforeDate = z.object({
|
||||
date: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Invalid date string format"
|
||||
}),
|
||||
channelId: z.uuidv7()
|
||||
})
|
||||
date: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Invalid date string format",
|
||||
}),
|
||||
channelId: z.uuidv7(),
|
||||
});
|
||||
|
||||
export const sendMessageSchema = z.object({
|
||||
channelId: z.uuidv7(),
|
||||
userId: z.uuidv7(),
|
||||
content: z.string(),
|
||||
token: z.string(),
|
||||
repliedMessageId: z.uuidv7().nullable().optional()
|
||||
})
|
||||
channelId: z.uuidv7(),
|
||||
userId: z.uuidv7(),
|
||||
content: z.string(),
|
||||
token: z.string(),
|
||||
repliedMessageId: z.uuidv7().nullable().optional(),
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ export const queryUserByIdSchema = z.object({
|
||||
export const queryAllUsersByInstanceId = z.object({
|
||||
instanceId: z.uuidv7(),
|
||||
});
|
||||
import { is } from 'zod/v4/locales';
|
||||
import { is } from "zod/v4/locales";
|
||||
export const createUserSchema = z.object({
|
||||
username: z.string().min(3).max(30),
|
||||
nickname: z.string().min(1).max(30).optional(),
|
||||
|
||||
Reference in New Issue
Block a user