2
0

🧐 Improve suspendWorkspace script

This commit is contained in:
Baptiste Arnaud
2024-01-08 15:11:19 +01:00
parent 56e0342e86
commit 311753fd0e

View File

@@ -15,24 +15,29 @@ const suspendWorkspace = async () => {
console.log(e.duration, 'ms') console.log(e.duration, 'ms')
}) })
const type = (await p.select({ const type = await p.select({
message: 'Select way', message: 'Select way',
options: [ options: [
{ label: 'Typebot public ID', value: 'typebotId' }, { label: 'Typebot ID', value: 'id' },
{ label: 'Typebot public ID', value: 'publicId' },
{ label: 'Workspace ID', value: 'workspaceId' }, { label: 'Workspace ID', value: 'workspaceId' },
], ],
})) as 'typebotId' | 'workspaceId' })
const val = (await p.text({ if (!type || typeof type !== 'string') return
const val = await p.text({
message: 'Enter value', message: 'Enter value',
})) as string })
if (!val || typeof val !== 'string') return
let workspaceId = type === 'workspaceId' ? val : undefined let workspaceId = type === 'workspaceId' ? val : undefined
if (!workspaceId) { if (!workspaceId) {
const typebot = await prisma.typebot.findUnique({ const typebot = await prisma.typebot.findFirst({
where: { where: {
publicId: val, [type]: val,
}, },
select: { select: {
workspaceId: true, workspaceId: true,