2
0

🚸 Rename "webhook" block to "HTTP request"

This commit is contained in:
Baptiste Arnaud
2024-02-16 12:04:25 +01:00
parent 8d50dc9dfa
commit 33cbb2b254
35 changed files with 165 additions and 154 deletions

View File

@@ -3,8 +3,8 @@ import {
ResultValues,
Typebot,
Variable,
Webhook,
WebhookResponse,
HttpRequest,
HttpResponse,
Block,
} from '@typebot.io/schemas'
import { NextApiRequest, NextApiResponse } from 'next'
@@ -58,7 +58,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const typebot = (await prisma.typebot.findUnique({
where: { id: typebotId },
include: { webhooks: true },
})) as unknown as (Typebot & { webhooks: Webhook[] }) | null
})) as unknown as (Typebot & { webhooks: HttpRequest[] }) | null
if (!typebot) return notFound(res)
const block = typebot.groups
.flatMap<Block>((g) => g.blocks)
@@ -106,7 +106,7 @@ export const executeWebhook =
isCustomBody,
timeout,
}: {
webhook: Webhook
webhook: HttpRequest
variables: Variable[]
groupId: string
resultValues?: ResultValues
@@ -114,7 +114,7 @@ export const executeWebhook =
parentTypebotIds: string[]
isCustomBody?: boolean
timeout?: number
}): Promise<WebhookResponse> => {
}): Promise<HttpResponse> => {
if (!webhook.url)
return {
statusCode: 400,

View File

@@ -1,6 +1,6 @@
import { authenticateUser } from '@/helpers/authenticateUser'
import prisma from '@typebot.io/lib/prisma'
import { Group, WebhookBlock } from '@typebot.io/schemas'
import { Group, HttpRequestBlock } from '@typebot.io/schemas'
import { NextApiRequest, NextApiResponse } from 'next'
import { isWebhookBlock } from '@typebot.io/lib'
import { methodNotAllowed } from '@typebot.io/lib/api'
@@ -22,7 +22,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
>((emptyWebhookBlocks, group) => {
const blocks = group.blocks.filter((block) =>
isWebhookBlock(block)
) as WebhookBlock[]
) as HttpRequestBlock[]
return [
...emptyWebhookBlocks,
...blocks.map((b) => ({