2022-11-18 18:21:40 +01:00
|
|
|
import { z } from 'zod'
|
2023-03-15 08:35:16 +01:00
|
|
|
import { Answer as AnswerPrisma, Prisma } from '@typebot.io/prisma'
|
2021-12-30 10:24:16 +01:00
|
|
|
|
2023-03-09 08:46:36 +01:00
|
|
|
export const answerSchema = z.object({
|
|
|
|
createdAt: z.date(),
|
|
|
|
resultId: z.string(),
|
|
|
|
blockId: z.string(),
|
2023-06-30 12:13:17 +02:00
|
|
|
itemId: z.string().nullable(),
|
2023-03-09 08:46:36 +01:00
|
|
|
groupId: z.string(),
|
|
|
|
variableId: z.string().nullable(),
|
|
|
|
content: z.string(),
|
|
|
|
storageUsed: z.number().nullable(),
|
|
|
|
}) satisfies z.ZodType<AnswerPrisma>
|
2022-11-29 10:02:40 +01:00
|
|
|
|
2023-03-09 08:46:36 +01:00
|
|
|
export const answerInputSchema = answerSchema
|
|
|
|
.omit({
|
|
|
|
createdAt: true,
|
|
|
|
resultId: true,
|
|
|
|
variableId: true,
|
|
|
|
storageUsed: true,
|
|
|
|
})
|
2023-03-14 16:42:12 +01:00
|
|
|
.merge(
|
2023-03-09 08:46:36 +01:00
|
|
|
z.object({
|
|
|
|
variableId: z.string().nullish(),
|
|
|
|
storageUsed: z.number().nullish(),
|
2023-06-30 12:13:17 +02:00
|
|
|
itemId: z.string().nullish(),
|
2023-03-09 08:46:36 +01:00
|
|
|
})
|
|
|
|
) satisfies z.ZodType<Prisma.AnswerUncheckedUpdateInput>
|
2022-11-21 11:12:43 +01:00
|
|
|
|
2022-01-03 17:39:59 +01:00
|
|
|
export type Stats = {
|
|
|
|
totalViews: number
|
|
|
|
totalStarts: number
|
2022-02-12 12:54:16 +01:00
|
|
|
totalCompleted: number
|
2022-01-03 17:39:59 +01:00
|
|
|
}
|
2022-11-18 18:21:40 +01:00
|
|
|
|
|
|
|
export type Answer = z.infer<typeof answerSchema>
|
2022-11-21 11:12:43 +01:00
|
|
|
|
|
|
|
export type AnswerInput = z.infer<typeof answerInputSchema>
|