2
0
Files
bot/packages/scripts/inspectWorkspace.ts
2024-01-10 11:11:12 +01:00

50 lines
969 B
TypeScript

import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils'
import * as p from '@clack/prompts'
const inspectWorkspace = async () => {
await promptAndSetEnvironment('production')
const id = await p.text({
message: 'Workspace ID?',
})
if (!id || typeof id !== 'string') {
console.log('No ID provided')
return
}
const prisma = new PrismaClient({
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
})
const workspace = await prisma.workspace.findFirst({
where: {
id,
},
include: {
typebots: {
select: {
id: true,
name: true,
},
},
members: {
select: {
user: { select: { email: true } },
role: true,
},
},
},
})
if (!workspace) {
console.log('Workspace not found')
return
}
console.log(JSON.stringify(workspace, null, 2))
}
inspectWorkspace()