🚸 Improve parsing preprocessing on typebots

This commit is contained in:
Baptiste Arnaud
2023-08-23 10:57:38 +02:00
parent fe54888350
commit 0acede92ef
24 changed files with 132 additions and 584 deletions

View File

@@ -1,14 +0,0 @@
import { Webhook } from '@typebot.io/schemas'
import { sendRequest } from '@typebot.io/lib'
type Props = {
typebotId: string
data: Partial<Omit<Webhook, 'typebotId'>>
}
export const createWebhookQuery = ({ typebotId, data }: Props) =>
sendRequest<{ webhook: Webhook }>({
method: 'POST',
url: `/api/typebots/${typebotId}/webhooks`,
body: { data },
})

View File

@@ -1,27 +0,0 @@
import { Webhook } from '@typebot.io/schemas'
import { sendRequest } from '@typebot.io/lib'
import { createWebhookQuery } from './createWebhookQuery'
type Props = {
existingIds: { typebotId: string; webhookId: string }
newIds: { typebotId: string; webhookId: string }
}
export const duplicateWebhookQuery = async ({
existingIds,
newIds,
}: Props): Promise<Webhook | undefined> => {
const { data } = await sendRequest<{ webhook: Webhook }>(
`/api/typebots/${existingIds.typebotId}/webhooks/${existingIds.webhookId}`
)
if (!data) return
const newWebhook = {
...data.webhook,
id: newIds.webhookId,
typebotId: newIds.typebotId,
}
await createWebhookQuery({
typebotId: newIds.typebotId,
data: { ...data.webhook, id: newIds.webhookId },
})
return newWebhook
}

View File

@@ -1,15 +0,0 @@
import { Webhook } from '@typebot.io/schemas'
import { sendRequest } from '@typebot.io/lib'
type Props = {
typebotId: string
webhookId: string
data: Partial<Omit<Webhook, 'id' | 'typebotId'>>
}
export const updateWebhookQuery = ({ typebotId, webhookId, data }: Props) =>
sendRequest<{ webhook: Webhook }>({
method: 'PATCH',
url: `/api/typebots/${typebotId}/webhooks/${webhookId}`,
body: { data },
})