2
0
Files
bot/packages/schemas/features/answer.ts
Baptiste Arnaud 35300eaf34 ♻️ Introduce typebot v6 with events (#1013)
Closes #885
2023-11-08 15:34:16 +01:00

36 lines
941 B
TypeScript

import { z } from 'zod'
import { Answer as AnswerPrisma, Prisma } from '@typebot.io/prisma'
export const answerSchema = z.object({
createdAt: z.date(),
resultId: z.string(),
blockId: z.string(),
groupId: z.string(),
variableId: z.string().nullable(),
content: z.string(),
storageUsed: z.number().nullable(),
// TO-DO: remove once itemId is removed from database schema
}) satisfies z.ZodType<Omit<AnswerPrisma, 'itemId'>>
export const answerInputSchema = answerSchema
.omit({
createdAt: true,
resultId: true,
variableId: true,
storageUsed: true,
})
.extend({
variableId: z.string().nullish(),
storageUsed: z.number().nullish(),
}) satisfies z.ZodType<Prisma.AnswerUncheckedUpdateInput>
export type Stats = {
totalViews: number
totalStarts: number
totalCompleted: number
}
export type Answer = z.infer<typeof answerSchema>
export type AnswerInput = z.infer<typeof answerInputSchema>