2022-03-25 22:26:22 +00:00
|
|
|
import { withValidation } from "next-validations";
|
2022-04-01 20:04:42 +00:00
|
|
|
import { z } from "zod";
|
2022-03-27 00:19:49 +00:00
|
|
|
|
2022-03-30 12:17:55 +00:00
|
|
|
import { _UserModel as User } from "@calcom/prisma/zod";
|
2022-03-25 22:26:22 +00:00
|
|
|
|
2022-04-01 20:04:42 +00:00
|
|
|
export const schemaUserBaseBodyParams = User.omit({
|
2022-03-30 12:17:55 +00:00
|
|
|
id: true,
|
|
|
|
createdAt: true,
|
|
|
|
password: true,
|
|
|
|
twoFactorEnabled: true,
|
|
|
|
twoFactorSecret: true,
|
2022-04-01 15:53:52 +00:00
|
|
|
}).partial();
|
2022-03-30 12:17:55 +00:00
|
|
|
|
2022-04-01 20:04:42 +00:00
|
|
|
const schemaUserRequiredParams = z.object({
|
|
|
|
email: z.string().email(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const schemaUserBodyParams = schemaUserBaseBodyParams.merge(schemaUserRequiredParams);
|
|
|
|
|
2022-03-30 12:17:55 +00:00
|
|
|
export const schemaUserPublic = User.omit({
|
|
|
|
identityProvider: true,
|
|
|
|
identityProviderId: true,
|
|
|
|
plan: true,
|
|
|
|
metadata: true,
|
|
|
|
password: true,
|
|
|
|
twoFactorEnabled: true,
|
|
|
|
twoFactorSecret: true,
|
|
|
|
trialEndsAt: true,
|
|
|
|
completedOnboarding: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const withValidUser = withValidation({
|
|
|
|
schema: schemaUserBodyParams,
|
2022-03-25 22:26:22 +00:00
|
|
|
type: "Zod",
|
|
|
|
mode: "body",
|
|
|
|
});
|