2
0

🧐 Add data exploration scripts

This commit is contained in:
Baptiste Arnaud
2024-01-08 07:38:58 +01:00
parent 2385eaf7d5
commit 7d6c964a0f
7 changed files with 199 additions and 16 deletions

View File

@@ -1,6 +1,10 @@
import { PrismaClient } from '@typebot.io/prisma'
import * as p from '@clack/prompts'
import { isEmpty } from '@typebot.io/lib'
import { promptAndSetEnvironment } from './utils'
const suspendWorkspace = async () => {
await promptAndSetEnvironment('production')
const prisma = new PrismaClient({
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
})
@@ -11,23 +15,46 @@ const suspendWorkspace = async () => {
console.log(e.duration, 'ms')
})
const typebot = await prisma.typebot.findUnique({
where: {
id: '',
},
select: {
workspaceId: true,
},
})
const type = (await p.select({
message: 'Select way',
options: [
{ label: 'Typebot public ID', value: 'typebotId' },
{ label: 'Workspace ID', value: 'workspaceId' },
],
})) as 'typebotId' | 'workspaceId'
if (!typebot) {
console.log('Typebot not found')
const val = (await p.text({
message: 'Enter value',
})) as string
let workspaceId = type === 'workspaceId' ? val : undefined
if (!workspaceId) {
const typebot = await prisma.typebot.findUnique({
where: {
publicId: val,
},
select: {
workspaceId: true,
},
})
if (!typebot) {
console.log('Typebot not found')
return
}
workspaceId = typebot.workspaceId
}
if (isEmpty(workspaceId)) {
console.log('Workspace not found')
return
}
const result = await prisma.workspace.update({
where: {
id: typebot.workspaceId,
id: workspaceId,
},
data: {
isSuspended: true,