2
0
Files
bot/packages/scripts/inspectUser.ts

71 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-06-21 10:43:42 +02:00
import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils'
import { isCancel, text } from '@clack/prompts'
2023-06-21 10:43:42 +02:00
const inspectUser = async () => {
await promptAndSetEnvironment('production')
const email = await text({
2023-06-21 10:43:42 +02:00
message: 'User email',
})
if (!email || isCancel(email)) process.exit()
const prisma = new PrismaClient()
2023-06-21 10:43:42 +02:00
const user = await prisma.user.findFirst({
where: {
email,
2023-06-21 10:43:42 +02:00
},
select: {
name: true,
lastActivityAt: true,
company: true,
onboardingCategories: true,
workspaces: {
where: {
role: 'ADMIN',
},
select: {
workspace: {
select: {
id: true,
2023-06-21 10:43:42 +02:00
name: true,
plan: true,
isVerified: true,
2023-06-21 10:43:42 +02:00
members: {
where: {
user: { email: { not: email } },
2023-06-21 10:43:42 +02:00
},
},
additionalStorageIndex: true,
typebots: {
orderBy: {
updatedAt: 'desc',
},
select: {
id: true,
name: true,
createdAt: true,
updatedAt: true,
riskLevel: true,
2023-06-21 10:43:42 +02:00
publishedTypebot: {
select: {
typebot: {
select: { publicId: true },
},
},
},
},
},
},
},
},
},
},
})
console.log(JSON.stringify(user, null, 2))
2023-06-21 10:43:42 +02:00
}
inspectUser()