2
0
Files
bot/packages/schemas/features/answer.ts

39 lines
936 B
TypeScript
Raw Normal View History

import { z } from '../zod'
import { Answer as AnswerV1Prisma, Prisma } from '@typebot.io/prisma'
2021-12-30 10:24:16 +01:00
const answerV1Schema = z.object({
createdAt: z.date(),
resultId: z.string(),
blockId: z.string(),
groupId: z.string(),
variableId: z.string().nullable(),
content: z.string(),
}) satisfies z.ZodType<AnswerV1Prisma>
export const answerSchema = z.object({
blockId: z.string(),
content: z.string(),
})
2022-11-29 10:02:40 +01:00
export const answerInputSchema = answerV1Schema
.omit({
createdAt: true,
resultId: true,
variableId: true,
})
.extend({
variableId: z.string().nullish(),
}) satisfies z.ZodType<Prisma.AnswerUncheckedUpdateInput>
2022-11-21 11:12:43 +01:00
export const statsSchema = z.object({
totalViews: z.number(),
totalStarts: z.number(),
totalCompleted: z.number(),
})
export type Stats = z.infer<typeof statsSchema>
export type Answer = z.infer<typeof answerSchema>
2022-11-21 11:12:43 +01:00
export type AnswerInput = z.infer<typeof answerInputSchema>