From 311753fd0e2a6702d2c2390d7ae12aaaf4b8f1f4 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Mon, 8 Jan 2024 15:11:19 +0100 Subject: [PATCH] :monocle_face: Improve suspendWorkspace script --- packages/scripts/suspendWorkspace.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/scripts/suspendWorkspace.ts b/packages/scripts/suspendWorkspace.ts index d0560342d..6947f9eb0 100644 --- a/packages/scripts/suspendWorkspace.ts +++ b/packages/scripts/suspendWorkspace.ts @@ -15,24 +15,29 @@ const suspendWorkspace = async () => { console.log(e.duration, 'ms') }) - const type = (await p.select({ + const type = await p.select({ message: 'Select way', options: [ - { label: 'Typebot public ID', value: 'typebotId' }, + { label: 'Typebot ID', value: 'id' }, + { label: 'Typebot public ID', value: 'publicId' }, { 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', - })) as string + }) + + if (!val || typeof val !== 'string') return let workspaceId = type === 'workspaceId' ? val : undefined if (!workspaceId) { - const typebot = await prisma.typebot.findUnique({ + const typebot = await prisma.typebot.findFirst({ where: { - publicId: val, + [type]: val, }, select: { workspaceId: true,