🐛 (sendMessage) Correctly preprocess and parse fetched bot
This commit is contained in:
@@ -20,6 +20,7 @@ import { inputBlockSchemas } from '../blocks/schemas'
|
||||
import { chatCompletionMessageSchema } from '../blocks/integrations/openai'
|
||||
import { sessionStateSchema } from './sessionState'
|
||||
import { dynamicThemeSchema } from './shared'
|
||||
import { preprocessTypebot } from '../typebot/helpers/preprocessTypebot'
|
||||
|
||||
const chatSessionSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -84,14 +85,18 @@ const scriptToExecuteSchema = z.object({
|
||||
),
|
||||
})
|
||||
|
||||
const startTypebotSchema = typebotSchema._def.schema.pick({
|
||||
id: true,
|
||||
groups: true,
|
||||
edges: true,
|
||||
variables: true,
|
||||
settings: true,
|
||||
theme: true,
|
||||
})
|
||||
export const startTypebotSchema = z.preprocess(
|
||||
preprocessTypebot,
|
||||
typebotSchema._def.schema.pick({
|
||||
version: true,
|
||||
id: true,
|
||||
groups: true,
|
||||
edges: true,
|
||||
variables: true,
|
||||
settings: true,
|
||||
theme: true,
|
||||
})
|
||||
)
|
||||
|
||||
const startParamsSchema = z.object({
|
||||
typebot: startTypebotSchema
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { z } from 'zod'
|
||||
import { publicTypebotSchema } from '../publicTypebot'
|
||||
import { preprocessTypebot } from '../typebot/helpers/preprocessTypebot'
|
||||
|
||||
export const typebotInSessionStateSchema = publicTypebotSchema._def.schema.pick(
|
||||
{
|
||||
export const typebotInSessionStateSchema = z.preprocess(
|
||||
preprocessTypebot,
|
||||
publicTypebotSchema._def.schema.pick({
|
||||
version: true,
|
||||
id: true,
|
||||
groups: true,
|
||||
edges: true,
|
||||
variables: true,
|
||||
}
|
||||
})
|
||||
)
|
||||
export type TypebotInSession = z.infer<typeof typebotInSessionStateSchema>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user