From 2b4cd00901e51584239e4f6f90cbee73d111b2d9 Mon Sep 17 00:00:00 2001 From: Alexis Falaise Date: Tue, 8 Apr 2025 12:02:53 +0200 Subject: [PATCH] remove getOutgoingEdgeId unused file --- packages/bot-engine/src/getOutgoingEdgeId.ts | 62 -------------------- 1 file changed, 62 deletions(-) delete mode 100644 packages/bot-engine/src/getOutgoingEdgeId.ts diff --git a/packages/bot-engine/src/getOutgoingEdgeId.ts b/packages/bot-engine/src/getOutgoingEdgeId.ts deleted file mode 100644 index 30b3c8198..000000000 --- a/packages/bot-engine/src/getOutgoingEdgeId.ts +++ /dev/null @@ -1,62 +0,0 @@ -import type { Block } from "@typebot.io/blocks-core/schemas/schema"; -import { defaultChoiceInputOptions } from "@typebot.io/blocks-inputs/choice/constants"; -import { InputBlockType } from "@typebot.io/blocks-inputs/constants"; -import { defaultPictureChoiceOptions } from "@typebot.io/blocks-inputs/pictureChoice/constants"; -import type { SessionState } from "@typebot.io/chat-session/schemas"; -import type { SessionStore } from "@typebot.io/runtime-session-store"; -import { parseVariables } from "@typebot.io/variables/parseVariables"; -import type { SkipReply, SuccessReply } from "./types"; - -export const getOutgoingEdgeId = ( - reply: SuccessReply | SkipReply | undefined, - { - block, - state, - sessionStore, - }: { - block: Block; - state: SessionState; - sessionStore: SessionStore; - }, -): { edgeId: string | undefined; isOffDefaultPath: boolean } => { - if (!reply || reply.status === "skip") - return { edgeId: block.outgoingEdgeId, isOffDefaultPath: false }; - if (reply.outgoingEdgeId) - return { edgeId: reply.outgoingEdgeId, isOffDefaultPath: true }; - const variables = state.typebotsQueue[0].typebot.variables; - if ( - block.type === InputBlockType.CHOICE && - !( - block.options?.isMultipleChoice ?? - defaultChoiceInputOptions.isMultipleChoice - ) && - reply - ) { - const matchedItem = block.items.find( - (item) => - parseVariables(item.content, { - variables, - sessionStore, - }).normalize() === reply.content.normalize(), - ); - if (matchedItem?.outgoingEdgeId) - return { edgeId: matchedItem.outgoingEdgeId, isOffDefaultPath: true }; - } - if ( - block.type === InputBlockType.PICTURE_CHOICE && - !( - block.options?.isMultipleChoice ?? - defaultPictureChoiceOptions.isMultipleChoice - ) && - reply - ) { - const matchedItem = block.items.find( - (item) => - parseVariables(item.title, { variables, sessionStore }).normalize() === - reply.content.normalize(), - ); - if (matchedItem?.outgoingEdgeId) - return { edgeId: matchedItem.outgoingEdgeId, isOffDefaultPath: true }; - } - return { edgeId: block.outgoingEdgeId, isOffDefaultPath: false }; -};