2
0

♻️ Remove @typebot.io/schemas from @typebot.io/lib

This commit is contained in:
Baptiste Arnaud
2024-03-15 16:32:29 +01:00
parent b53242ce6a
commit 5073be2439
186 changed files with 809 additions and 581 deletions

View File

@@ -0,0 +1,30 @@
import {
PublicTypebot,
PublicTypebotV6,
Typebot,
TypebotV6,
} from '@typebot.io/schemas'
import { migrateTypebotFromV3ToV4 } from './migrateTypebotFromV3ToV4'
import { migrateTypebotFromV5ToV6 } from './migrateTypebotFromV5ToV6'
export const migrateTypebot = async (typebot: Typebot): Promise<TypebotV6> => {
if (typebot.version === '6') return typebot
let migratedTypebot: any = typebot
if (migratedTypebot.version === '3')
migratedTypebot = await migrateTypebotFromV3ToV4(typebot)
if (migratedTypebot.version === '4' || migratedTypebot.version === '5')
migratedTypebot = migrateTypebotFromV5ToV6(migratedTypebot)
return migratedTypebot
}
export const migratePublicTypebot = async (
typebot: PublicTypebot
): Promise<PublicTypebotV6> => {
if (typebot.version === '6') return typebot
let migratedTypebot: any = typebot
if (migratedTypebot.version === '3')
migratedTypebot = await migrateTypebotFromV3ToV4(typebot)
if (migratedTypebot.version === '4' || migratedTypebot.version === '5')
migratedTypebot = migrateTypebotFromV5ToV6(migratedTypebot)
return migratedTypebot
}