2
0

🐛 Fix typebot publishing endpoint events parsing

This commit is contained in:
Baptiste Arnaud
2023-11-08 17:12:58 +01:00
parent 64418df3a1
commit 4b67f9e2e2

View File

@ -81,7 +81,11 @@ export const publishTypebot = authenticatedProcedure
groups: parseGroups(existingTypebot.groups, {
typebotVersion: existingTypebot.version,
}),
events: z.tuple([startEventSchema]).parse(existingTypebot.events),
events:
(existingTypebot.version === '6'
? z.tuple([startEventSchema])
: z.null()
).parse(existingTypebot.events) ?? undefined,
settings: settingsSchema.parse(existingTypebot.settings),
variables: z.array(variableSchema).parse(existingTypebot.variables),
theme: themeSchema.parse(existingTypebot.theme),
@ -96,7 +100,11 @@ export const publishTypebot = authenticatedProcedure
groups: parseGroups(existingTypebot.groups, {
typebotVersion: existingTypebot.version,
}),
events: z.tuple([startEventSchema]).parse(existingTypebot.events),
events:
(existingTypebot.version === '6'
? z.tuple([startEventSchema])
: z.null()
).parse(existingTypebot.events) ?? undefined,
settings: settingsSchema.parse(existingTypebot.settings),
variables: z.array(variableSchema).parse(existingTypebot.variables),
theme: themeSchema.parse(existingTypebot.theme),