2
0

feat(editor): Restore published version button

Had to migrate webhooks into a standalone table
This commit is contained in:
Baptiste Arnaud
2022-03-01 07:13:09 +01:00
parent 0df719d531
commit e17a1a0869
46 changed files with 578 additions and 348 deletions

View File

@ -1,9 +1,7 @@
import {
Block,
CredentialsType,
defaultSettings,
defaultTheme,
PublicBlock,
PublicTypebot,
Step,
Typebot,
@ -39,6 +37,9 @@ export const createUsers = () =>
],
})
export const createWebhook = (typebotId: string) =>
prisma.webhook.create({ data: { method: 'GET', typebotId, id: 'webhook1' } })
export const createCollaboration = (
userId: string,
typebotId: string,
@ -139,7 +140,7 @@ const parseTypebotToPublicTypebot = (
): Omit<PublicTypebot, 'createdAt' | 'updatedAt'> => ({
id,
name: typebot.name,
blocks: parseBlocksToPublicBlocks(typebot.blocks),
blocks: typebot.blocks,
typebotId: typebot.id,
theme: typebot.theme,
settings: typebot.settings,
@ -149,14 +150,6 @@ const parseTypebotToPublicTypebot = (
customDomain: null,
})
const parseBlocksToPublicBlocks = (blocks: Block[]): PublicBlock[] =>
blocks.map((b) => ({
...b,
steps: b.steps.map((s) =>
'webhook' in s ? { ...s, webhook: s.webhook.id } : s
),
}))
const parseTestTypebot = (partialTypebot: Partial<Typebot>): Typebot => ({
id: partialTypebot.id ?? 'typebot',
folderId: null,
@ -232,6 +225,6 @@ export const importTypebotInDatabase = async (
data: parseTypebotToPublicTypebot(
updates?.id ? `${updates?.id}-public` : 'publicBot',
typebot
),
) as any,
})
}