2023-03-15 08:35:16 +01:00
|
|
|
import { PrismaClient } from '@typebot.io/prisma'
|
2022-11-23 11:40:57 +01:00
|
|
|
import { promptAndSetEnvironment } from './utils'
|
2023-03-15 08:35:16 +01:00
|
|
|
import { groupSchema } from '@typebot.io/schemas'
|
2022-12-22 17:02:34 +01:00
|
|
|
import { readFileSync, writeFileSync } from 'fs'
|
|
|
|
import { exit } from 'process'
|
2022-11-23 11:40:57 +01:00
|
|
|
|
|
|
|
const executePlayground = async () => {
|
|
|
|
await promptAndSetEnvironment()
|
2022-12-08 11:02:52 +01:00
|
|
|
const prisma = new PrismaClient({
|
|
|
|
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
|
|
|
|
})
|
|
|
|
|
|
|
|
prisma.$on('query', (e) => {
|
|
|
|
console.log(e.query)
|
|
|
|
console.log(e.params)
|
|
|
|
console.log(e.duration, 'ms')
|
|
|
|
})
|
|
|
|
|
2022-12-22 17:02:34 +01:00
|
|
|
const typebots = JSON.parse(readFileSync('typebots.json', 'utf-8')) as any[]
|
|
|
|
|
|
|
|
for (const typebot of typebots) {
|
|
|
|
for (const group of typebot.groups) {
|
|
|
|
const parser = groupSchema.safeParse(group)
|
|
|
|
if ('error' in parser) {
|
|
|
|
console.log(
|
|
|
|
group.id,
|
|
|
|
parser.error.issues.map((issue) =>
|
|
|
|
JSON.stringify({
|
|
|
|
message: issue.message,
|
|
|
|
path: issue.path,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
writeFileSync('failedTypebot.json', JSON.stringify(typebot))
|
|
|
|
exit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 11:40:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
executePlayground()
|