🚑 Fix parsing issue with new events field on ongoing session states
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { edgeSchema } from '../edge'
|
||||
|
||||
export const preprocessTypebot = (typebot: any) => {
|
||||
if (!typebot || typebot.version === '5') return typebot
|
||||
if (!typebot || typebot.version === '5' || typebot.version === '6')
|
||||
return typebot
|
||||
return {
|
||||
...typebot,
|
||||
version:
|
||||
@ -9,6 +10,7 @@ export const preprocessTypebot = (typebot: any) => {
|
||||
? '3'
|
||||
: typebot.version,
|
||||
groups: typebot.groups ? typebot.groups.map(preprocessGroup) : [],
|
||||
events: null,
|
||||
edges: typebot.edges
|
||||
? typebot.edges?.filter((edge: any) => edgeSchema.safeParse(edge).success)
|
||||
: [],
|
||||
|
@ -25,7 +25,7 @@ export const typebotV5Schema = z.preprocess(
|
||||
version: z.enum(['3', '4', '5']),
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
events: z.null(),
|
||||
events: z.preprocess((val) => (val === undefined ? null : val), z.null()),
|
||||
groups: z.array(groupV5Schema),
|
||||
edges: z.array(edgeSchema),
|
||||
variables: z.array(variableSchema),
|
||||
|
Reference in New Issue
Block a user