Skip to content

Commit

Permalink
🧐 Add inspectWorkspace script
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 10, 2024
1 parent c1c053b commit 2b2e7c7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/scripts/inspectTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const inspectTypebot = async () => {
id: true,
name: true,
riskLevel: true,
publicId: true,
customDomain: true,
workspace: {
select: {
id: true,
Expand Down
49 changes: 49 additions & 0 deletions packages/scripts/inspectWorkspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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()
1 change: 1 addition & 0 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"updateTypebot": "tsx updateTypebot.ts",
"updateWorkspace": "tsx updateWorkspace.ts",
"inspectTypebot": "tsx inspectTypebot.ts",
"inspectWorkspace": "tsx inspectWorkspace.ts",
"getCoupon": "tsx getCoupon.ts"
},
"devDependencies": {
Expand Down

0 comments on commit 2b2e7c7

Please sign in to comment.