♻️ Introduce typebot v6 with events (#1013)

Closes #885
This commit is contained in:
Baptiste Arnaud
2023-11-08 15:34:16 +01:00
committed by GitHub
parent 68e4fc71fb
commit 35300eaf34
634 changed files with 58971 additions and 31449 deletions

View File

@@ -1,12 +1,8 @@
import {
BubbleBlock,
BubbleBlockType,
InputBlock,
InputBlockType,
Block,
} from '@typebot.io/schemas'
import { BubbleBlock, InputBlock, Block } from '@typebot.io/schemas'
import { isBubbleBlock, isInputBlock } from '@typebot.io/lib'
import type { TypebotPostMessageData } from 'typebot-js'
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
export const getLastChatBlockType = (
blocks: Block[]

View File

@@ -4,7 +4,8 @@ import { executeGoogleSheetBlock } from '@/features/blocks/integrations/googleSh
import { executeSendEmailBlock } from '@/features/blocks/integrations/sendEmail'
import { executeWebhook } from '@/features/blocks/integrations/webhook'
import { IntegrationState } from '@/types'
import { IntegrationBlock, IntegrationBlockType } from '@typebot.io/schemas'
import { IntegrationBlock } from '@typebot.io/schemas'
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
export const executeIntegration = ({
block,

View File

@@ -6,8 +6,9 @@ import { executeTypebotLink } from '@/features/blocks/logic/typebotLink'
import { executeWait } from '@/features/blocks/logic/wait'
import { LinkedTypebot } from '@/providers/TypebotProvider'
import { EdgeId, LogicState } from '@/types'
import { LogicBlock, LogicBlockType } from '@typebot.io/schemas'
import { LogicBlock } from '@typebot.io/schemas'
import { executeScript } from '@/features/blocks/logic/script/executeScript'
import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants'
export const executeLogic = async (
block: LogicBlock,

View File

@@ -4,16 +4,16 @@ import { validateUrl } from '@/features/blocks/inputs/url'
import { parseVariables } from '@/features/variables'
import {
BubbleBlock,
BubbleBlockType,
Edge,
EmailInputBlock,
InputBlockType,
PhoneNumberInputBlock,
Block,
UrlInputBlock,
Variable,
} from '@typebot.io/schemas'
import { isInputBlock } from '@typebot.io/lib'
import { isDefined, isInputBlock } from '@typebot.io/lib'
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
export const isInputValid = (
inputValue: string,
@@ -33,23 +33,25 @@ export const isInputValid = (
export const blockCanBeRetried = (
block: Block
): block is EmailInputBlock | UrlInputBlock | PhoneNumberInputBlock =>
isInputBlock(block) && 'retryMessageContent' in block.options
isInputBlock(block) &&
isDefined(block.options) &&
'retryMessageContent' in block.options
export const parseRetryBlock = (
block: EmailInputBlock | UrlInputBlock | PhoneNumberInputBlock,
groupId: string,
variables: Variable[],
createEdge: (edge: Edge) => void
): BubbleBlock => {
const content = parseVariables(variables)(block.options.retryMessageContent)
const content = parseVariables(variables)(block.options?.retryMessageContent)
const newBlockId = block.id + Math.random() * 1000
const newEdge: Edge = {
id: (Math.random() * 1000).toString(),
from: { blockId: newBlockId, groupId: block.groupId },
to: { groupId: block.groupId, blockId: block.id },
from: { blockId: newBlockId },
to: { groupId, blockId: block.id },
}
createEdge(newEdge)
return {
groupId: block.groupId,
id: newBlockId,
type: BubbleBlockType.TEXT,
content: {