⚡ (webhook) Add client execution option
This commit is contained in:
@ -19,6 +19,7 @@ export const webhookOptionsSchema = z.object({
|
||||
responseVariableMapping: z.array(responseVariableMappingSchema),
|
||||
isAdvancedConfig: z.boolean().optional(),
|
||||
isCustomBody: z.boolean().optional(),
|
||||
isExecutedOnClient: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export const webhookBlockSchema = blockBaseSchema.merge(
|
||||
|
@ -18,6 +18,7 @@ import { answerSchema } from './answer'
|
||||
import { BubbleBlockType } from './blocks/bubbles/enums'
|
||||
import { inputBlockSchemas } from './blocks/schemas'
|
||||
import { chatCompletionMessageSchema } from './blocks/integrations/openai'
|
||||
import { executableWebhookSchema } from './webhooks'
|
||||
|
||||
const typebotInSessionStateSchema = publicTypebotSchema.pick({
|
||||
id: true,
|
||||
@ -237,6 +238,11 @@ const clientSideActionSchema = z
|
||||
}),
|
||||
})
|
||||
)
|
||||
.or(
|
||||
z.object({
|
||||
webhookToExecute: executableWebhookSchema,
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
export const chatReplySchema = z.object({
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Webhook as WebhookFromPrisma } from '@typebot.io/prisma'
|
||||
import { z } from 'zod'
|
||||
|
||||
export enum HttpMethod {
|
||||
POST = 'POST',
|
||||
@ -36,3 +37,12 @@ export const defaultWebhookAttributes: Omit<
|
||||
headers: [],
|
||||
queryParams: [],
|
||||
}
|
||||
|
||||
export const executableWebhookSchema = z.object({
|
||||
url: z.string(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
body: z.unknown().optional(),
|
||||
method: z.nativeEnum(HttpMethod).optional(),
|
||||
})
|
||||
|
||||
export type ExecutableWebhook = z.infer<typeof executableWebhookSchema>
|
||||
|
Reference in New Issue
Block a user