2
0
Files
bot/packages/models/src/features/result.ts

63 lines
1.4 KiB
TypeScript
Raw Normal View History

import { z } from 'zod'
2022-11-21 11:12:43 +01:00
import { answerInputSchema, answerSchema } from './answer'
import { InputBlockType } from './blocks'
import { variableWithValueSchema } from './typebot/variable'
export const resultSchema = z.object({
id: z.string(),
createdAt: z.date(),
updatedAt: z.date(),
typebotId: z.string(),
variables: z.array(variableWithValueSchema),
isCompleted: z.boolean(),
hasStarted: z.boolean().nullable(),
isArchived: z.boolean().nullable(),
})
export const resultWithAnswersSchema = resultSchema.and(
z.object({
answers: z.array(answerSchema),
})
)
2022-11-21 11:12:43 +01:00
export const resultWithAnswersInputSchema = resultSchema.and(
z.object({
answers: z.array(answerInputSchema),
})
)
export const logSchema = z.object({
id: z.string(),
createdAt: z.date(),
resultId: z.string(),
status: z.string(),
description: z.string(),
details: z.string().nullable(),
})
export type Result = z.infer<typeof resultSchema>
export type ResultWithAnswers = z.infer<typeof resultWithAnswersSchema>
2022-11-21 11:12:43 +01:00
export type ResultWithAnswersInput = z.infer<
typeof resultWithAnswersInputSchema
>
export type Log = z.infer<typeof logSchema>
export type ResultValues = Pick<
2022-11-21 11:12:43 +01:00
ResultWithAnswersInput,
'answers' | 'createdAt' | 'variables'
>
export type ResultHeaderCell = {
id: string
label: string
blocks?: {
id: string
groupId: string
}[]
2022-06-11 07:27:38 +02:00
blockType?: InputBlockType
variableIds?: string[]
}