2
0
Files
bot/packages/schemas/features/chat/shared.ts
2023-12-22 09:13:53 +01:00

26 lines
782 B
TypeScript

import { z } from '../../zod'
import { publicTypebotSchemaV5, publicTypebotSchemaV6 } from '../publicTypebot'
import { preprocessTypebot } from '../typebot/helpers/preprocessTypebot'
const typebotInSessionStatePick = {
version: true,
id: true,
groups: true,
events: true,
edges: true,
variables: true,
} as const
export const typebotInSessionStateSchema = z.preprocess(
preprocessTypebot,
z.discriminatedUnion('version', [
publicTypebotSchemaV5._def.schema.pick(typebotInSessionStatePick),
publicTypebotSchemaV6.pick(typebotInSessionStatePick),
])
)
export type TypebotInSession = z.infer<typeof typebotInSessionStateSchema>
export const dynamicThemeSchema = z.object({
hostAvatarUrl: z.string().optional(),
guestAvatarUrl: z.string().optional(),
})