2
0

🧐 Add more data inspection scripts

This commit is contained in:
Baptiste Arnaud
2024-01-08 13:47:23 +01:00
parent 244a29423b
commit 3775919543
3 changed files with 85 additions and 1 deletions

View File

@ -0,0 +1,30 @@
import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils'
import * as p from '@clack/prompts'
const getCoupon = async () => {
await promptAndSetEnvironment('production')
const val = (await p.text({
message: 'Enter coupon code',
})) as string
const prisma = new PrismaClient({
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
})
const coupon = await prisma.coupon.findFirst({
where: {
code: val,
},
})
if (!coupon) {
console.log('Coupon not found')
return
}
console.log(JSON.stringify(coupon, null, 2))
}
getCoupon()

View File

@ -0,0 +1,52 @@
import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils'
import * as p from '@clack/prompts'
const inspectTypebot = async () => {
await promptAndSetEnvironment('production')
const type = (await p.select({
message: 'Select way',
options: [
{ label: 'ID', value: 'id' },
{ label: 'Public ID', value: 'publicId' },
],
})) as 'id' | 'publicId'
const val = (await p.text({
message: 'Enter value',
})) as string
const prisma = new PrismaClient({
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
})
const typebot = await prisma.typebot.findFirst({
where: {
[type]: val,
},
select: {
id: true,
name: true,
riskLevel: true,
workspace: {
select: {
id: true,
name: true,
plan: true,
},
},
},
})
if (!typebot) {
console.log('Typebot not found')
return
}
console.log(`https://app.typebot.io/typebots/${typebot.id}/edit`)
console.log(JSON.stringify(typebot, null, 2))
}
inspectTypebot()

View File

@ -22,7 +22,9 @@
"suspendWorkspace": "tsx suspendWorkspace.ts",
"destroyUser": "tsx destroyUser.ts",
"updateTypebot": "tsx updateTypebot.ts",
"updateWorkspace": "tsx updateWorkspace.ts"
"updateWorkspace": "tsx updateWorkspace.ts",
"inspectTypebot": "tsx inspectTypebot.ts",
"getCoupon": "tsx getCoupon.ts"
},
"devDependencies": {
"@typebot.io/emails": "workspace:*",