From fee6b2d151ad6e6118e881bb79ad2ed4898cebf0 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Sat, 2 Mar 2024 09:07:55 +0100 Subject: [PATCH] :monocle_face: Add deleteChatSession script --- packages/scripts/deleteChatSession.ts | 28 +++++++++++++++++++++++++++ packages/scripts/package.json | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 packages/scripts/deleteChatSession.ts diff --git a/packages/scripts/deleteChatSession.ts b/packages/scripts/deleteChatSession.ts new file mode 100644 index 0000000000..bf4371eeab --- /dev/null +++ b/packages/scripts/deleteChatSession.ts @@ -0,0 +1,28 @@ +import { PrismaClient } from '@typebot.io/prisma' +import { promptAndSetEnvironment } from './utils' +import * as p from '@clack/prompts' + +const deleteChatSession = async () => { + await promptAndSetEnvironment('production') + + const id = await p.text({ + message: 'Session ID?', + }) + + if (!id || typeof id !== 'string') { + console.log('No ID provided') + return + } + + const prisma = new PrismaClient() + + const chatSession = await prisma.chatSession.delete({ + where: { + id, + }, + }) + + console.log(JSON.stringify(chatSession, null, 2)) +} + +deleteChatSession() diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 599d2c06e2..36c9ddaf7c 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -29,7 +29,8 @@ "redeemCoupon": "tsx redeemCoupon.ts", "exportResults": "tsx exportResults.ts", "updateUserEmail": "tsx updateUserEmail.ts", - "inspectChatSession": "tsx inspectChatSession.ts" + "inspectChatSession": "tsx inspectChatSession.ts", + "deleteChatSession": "tsx deleteChatSession.ts" }, "devDependencies": { "@typebot.io/emails": "workspace:*",