2023-12-22 09:13:53 +01:00
|
|
|
import { z } from '../../zod'
|
2023-11-08 15:34:16 +01:00
|
|
|
import { publicTypebotSchemaV5, publicTypebotSchemaV6 } from '../publicTypebot'
|
2023-08-24 09:11:10 +02:00
|
|
|
import { preprocessTypebot } from '../typebot/helpers/preprocessTypebot'
|
2023-08-24 07:48:30 +02:00
|
|
|
|
2023-11-08 15:34:16 +01:00
|
|
|
const typebotInSessionStatePick = {
|
|
|
|
version: true,
|
|
|
|
id: true,
|
|
|
|
groups: true,
|
|
|
|
events: true,
|
|
|
|
edges: true,
|
|
|
|
variables: true,
|
|
|
|
} as const
|
2023-08-24 09:11:10 +02:00
|
|
|
export const typebotInSessionStateSchema = z.preprocess(
|
|
|
|
preprocessTypebot,
|
2023-11-08 15:34:16 +01:00
|
|
|
z.discriminatedUnion('version', [
|
|
|
|
publicTypebotSchemaV5._def.schema.pick(typebotInSessionStatePick),
|
|
|
|
publicTypebotSchemaV6.pick(typebotInSessionStatePick),
|
|
|
|
])
|
2023-08-24 07:48:30 +02:00
|
|
|
)
|
|
|
|
export type TypebotInSession = z.infer<typeof typebotInSessionStateSchema>
|
|
|
|
|
|
|
|
export const dynamicThemeSchema = z.object({
|
|
|
|
hostAvatarUrl: z.string().optional(),
|
|
|
|
guestAvatarUrl: z.string().optional(),
|
|
|
|
})
|