2022-11-30 13:57:28 +01:00
|
|
|
import { z } from 'zod'
|
|
|
|
import {
|
|
|
|
Workspace as WorkspacePrisma,
|
|
|
|
Plan,
|
|
|
|
MemberInWorkspace as MemberInWorkspacePrisma,
|
|
|
|
WorkspaceRole,
|
|
|
|
User as UserPrisma,
|
|
|
|
WorkspaceInvitation as WorkspaceInvitationPrisma,
|
2023-03-15 08:35:16 +01:00
|
|
|
} from '@typebot.io/prisma'
|
2022-11-30 13:57:28 +01:00
|
|
|
|
2023-03-09 08:46:36 +01:00
|
|
|
export const workspaceMemberSchema = z.object({
|
|
|
|
workspaceId: z.string(),
|
|
|
|
user: z.object({
|
|
|
|
name: z.string().nullable(),
|
|
|
|
email: z.string().nullable(),
|
|
|
|
image: z.string().nullable(),
|
|
|
|
}),
|
|
|
|
role: z.nativeEnum(WorkspaceRole),
|
|
|
|
}) satisfies z.ZodType<
|
2023-02-03 07:58:14 +01:00
|
|
|
Omit<MemberInWorkspacePrisma, 'userId' | 'createdAt' | 'updatedAt'> & {
|
2022-11-30 13:57:28 +01:00
|
|
|
user: Pick<UserPrisma, 'name' | 'email' | 'image'>
|
|
|
|
}
|
2023-03-09 08:46:36 +01:00
|
|
|
>
|
2022-11-30 13:57:28 +01:00
|
|
|
|
2023-03-09 08:46:36 +01:00
|
|
|
export const workspaceInvitationSchema = z.object({
|
|
|
|
createdAt: z.date(),
|
|
|
|
updatedAt: z.date(),
|
|
|
|
email: z.string(),
|
|
|
|
type: z.nativeEnum(WorkspaceRole),
|
|
|
|
}) satisfies z.ZodType<
|
2022-11-30 13:57:28 +01:00
|
|
|
Omit<WorkspaceInvitationPrisma, 'workspaceId' | 'userId' | 'id'>
|
2023-03-09 08:46:36 +01:00
|
|
|
>
|
2022-11-30 13:57:28 +01:00
|
|
|
|
2023-03-09 08:46:36 +01:00
|
|
|
export const workspaceSchema = z.object({
|
|
|
|
id: z.string(),
|
|
|
|
createdAt: z.date(),
|
|
|
|
updatedAt: z.date(),
|
|
|
|
name: z.string(),
|
|
|
|
icon: z.string().nullable(),
|
|
|
|
plan: z.nativeEnum(Plan),
|
|
|
|
stripeId: z.string().nullable(),
|
|
|
|
additionalChatsIndex: z.number(),
|
|
|
|
additionalStorageIndex: z.number(),
|
|
|
|
chatsLimitFirstEmailSentAt: z.date().nullable(),
|
|
|
|
chatsLimitSecondEmailSentAt: z.date().nullable(),
|
|
|
|
storageLimitFirstEmailSentAt: z.date().nullable(),
|
|
|
|
storageLimitSecondEmailSentAt: z.date().nullable(),
|
|
|
|
customChatsLimit: z.number().nullable(),
|
|
|
|
customStorageLimit: z.number().nullable(),
|
|
|
|
customSeatsLimit: z.number().nullable(),
|
2023-04-23 20:57:51 +02:00
|
|
|
isQuarantined: z.boolean(),
|
2023-07-04 14:56:36 +02:00
|
|
|
isSuspended: z.boolean(),
|
2023-03-09 08:46:36 +01:00
|
|
|
}) satisfies z.ZodType<WorkspacePrisma>
|
2022-11-30 13:57:28 +01:00
|
|
|
|
|
|
|
export type Workspace = z.infer<typeof workspaceSchema>
|
|
|
|
export type WorkspaceMember = z.infer<typeof workspaceMemberSchema>
|
|
|
|
export type WorkspaceInvitation = z.infer<typeof workspaceInvitationSchema>
|