Files
sign/packages/trpc/server/profile-router/schema.ts

80 lines
2.3 KiB
TypeScript
Raw Normal View History

2023-06-09 18:21:18 +10:00
import { z } from 'zod';
import { ZCurrentPasswordSchema, ZPasswordSchema } from '../auth-router/schema';
2024-06-06 14:46:48 +10:00
export const MAX_PROFILE_BIO_LENGTH = 256;
2024-01-30 17:31:27 +11:00
export const ZFindUserSecurityAuditLogsSchema = z.object({
page: z.number().optional(),
perPage: z.number().optional(),
});
2024-06-27 21:50:42 +10:00
export type TFindUserSecurityAuditLogsSchema = z.infer<typeof ZFindUserSecurityAuditLogsSchema>;
2023-09-21 15:10:20 +01:00
export const ZRetrieveUserByIdQuerySchema = z.object({
id: z.number().min(1),
});
2024-06-27 21:50:42 +10:00
export type TRetrieveUserByIdQuerySchema = z.infer<typeof ZRetrieveUserByIdQuerySchema>;
2023-06-09 18:21:18 +10:00
export const ZUpdateProfileMutationSchema = z.object({
name: z.string().min(1),
signature: z.string(),
});
2024-06-27 21:50:42 +10:00
export type TUpdateProfileMutationSchema = z.infer<typeof ZUpdateProfileMutationSchema>;
export const ZUpdatePublicProfileMutationSchema = z.object({
2024-06-08 13:22:51 +10:00
bio: z
.string()
.max(MAX_PROFILE_BIO_LENGTH, {
message: `Bio must be shorter than ${MAX_PROFILE_BIO_LENGTH + 1} characters`,
})
.optional(),
2024-06-06 14:46:48 +10:00
enabled: z.boolean().optional(),
2024-02-29 13:22:21 +11:00
url: z
.string()
.trim()
.toLowerCase()
.min(1, { message: 'Please enter a valid username.' })
.regex(/^[a-z0-9-]+$/, {
message: 'Username can only container alphanumeric characters and dashes.',
2024-06-06 14:46:48 +10:00
})
.optional(),
});
2024-06-27 21:50:42 +10:00
export type TUpdatePublicProfileMutationSchema = z.infer<typeof ZUpdatePublicProfileMutationSchema>;
2023-06-09 18:21:18 +10:00
export const ZUpdatePasswordMutationSchema = z.object({
currentPassword: ZCurrentPasswordSchema,
password: ZPasswordSchema,
2023-06-09 18:21:18 +10:00
});
2024-06-27 21:50:42 +10:00
export type TUpdatePasswordMutationSchema = z.infer<typeof ZUpdatePasswordMutationSchema>;
2023-09-18 11:15:29 +00:00
export const ZForgotPasswordFormSchema = z.object({
email: z.string().email().min(1),
});
2024-06-27 21:50:42 +10:00
export type TForgotPasswordFormSchema = z.infer<typeof ZForgotPasswordFormSchema>;
2023-09-18 14:03:33 +00:00
export const ZResetPasswordFormSchema = z.object({
password: ZPasswordSchema,
2023-09-18 14:03:33 +00:00
token: z.string().min(1),
});
2024-06-27 21:50:42 +10:00
export type TResetPasswordFormSchema = z.infer<typeof ZResetPasswordFormSchema>;
export const ZConfirmEmailMutationSchema = z.object({
email: z.string().email().min(1),
});
export type TConfirmEmailMutationSchema = z.infer<typeof ZConfirmEmailMutationSchema>;
2024-06-27 21:50:42 +10:00
export const ZSetProfileImageMutationSchema = z.object({
bytes: z.string().nullish(),
teamId: z.number().min(1).nullish(),
});
export type TSetProfileImageMutationSchema = z.infer<typeof ZSetProfileImageMutationSchema>;