✨ Introduce bot v2 in builder (#328)
Also, the new engine is the default for updated typebots for viewer Closes #211
This commit is contained in:
@ -78,6 +78,7 @@ export const importTypebotInDatabase = async (
|
||||
...JSON.parse(readFileSync(path).toString()),
|
||||
workspaceId: proWorkspaceId,
|
||||
...updates,
|
||||
version: '3',
|
||||
}
|
||||
await prisma.typebot.create({
|
||||
data: parseCreateTypebot(typebot),
|
||||
|
@ -16,6 +16,7 @@ export const parseTestTypebot = (
|
||||
partialTypebot: Partial<Typebot>
|
||||
): Typebot => ({
|
||||
id: createId(),
|
||||
version: '3',
|
||||
workspaceId: proWorkspaceId,
|
||||
folderId: null,
|
||||
name: 'My typebot',
|
||||
@ -62,6 +63,7 @@ export const parseTypebotToPublicTypebot = (
|
||||
typebot: Typebot
|
||||
): Omit<PublicTypebot, 'createdAt' | 'updatedAt'> => ({
|
||||
id,
|
||||
version: typebot.version,
|
||||
groups: typebot.groups,
|
||||
typebotId: typebot.id,
|
||||
theme: typebot.theme,
|
||||
|
@ -1,15 +0,0 @@
|
||||
import { Typebot } from 'models'
|
||||
|
||||
export const convertTypebotToV2 = (typebot: any): Typebot => {
|
||||
const newTypebot = JSON.parse(
|
||||
JSON.stringify(typebot)
|
||||
.replace(/\"blocks\":/g, '"groups":')
|
||||
.replace(/\"steps\":/g, '"blocks":')
|
||||
.replace(/\"blockId\":/g, '"groupId":')
|
||||
.replace(/\"blockId\":/g, '"blockId":')
|
||||
)
|
||||
return {
|
||||
version: '2',
|
||||
...newTypebot,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user