♻️ Add a test for internal waitUntil
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
import {
|
||||
WhatsAppWebhookRequestBody,
|
||||
whatsAppWebhookRequestBodySchema,
|
||||
} from '@typebot.io/schemas/features/whatsapp'
|
||||
import { resumeWhatsAppFlow } from '@typebot.io/bot-engine/whatsapp/resumeWhatsAppFlow'
|
||||
import { isNotDefined } from '@typebot.io/lib'
|
||||
import { env } from '@typebot.io/env'
|
||||
import type { RequestContext } from '@vercel/edge'
|
||||
|
||||
const processWhatsAppReply = async (
|
||||
entry: WhatsAppWebhookRequestBody['entry']
|
||||
) => {
|
||||
const receivedMessage = entry.at(0)?.changes.at(0)?.value.messages?.at(0)
|
||||
if (isNotDefined(receivedMessage)) return { message: 'No message found' }
|
||||
const contactName =
|
||||
entry.at(0)?.changes.at(0)?.value?.contacts?.at(0)?.profile?.name ?? ''
|
||||
const contactPhoneNumber =
|
||||
entry.at(0)?.changes.at(0)?.value?.messages?.at(0)?.from ?? ''
|
||||
return resumeWhatsAppFlow({
|
||||
receivedMessage,
|
||||
sessionId: `wa-preview-${receivedMessage.from}`,
|
||||
contact: {
|
||||
name: contactName,
|
||||
phoneNumber: contactPhoneNumber,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function POST(request: Request, context: RequestContext) {
|
||||
if (!env.WHATSAPP_PREVIEW_FROM_PHONE_NUMBER_ID)
|
||||
return new Response(
|
||||
'WHATSAPP_PREVIEW_FROM_PHONE_NUMBER_ID is not defined',
|
||||
{
|
||||
status: 500,
|
||||
}
|
||||
)
|
||||
const body = await request.json()
|
||||
const { entry } = whatsAppWebhookRequestBodySchema.parse(body)
|
||||
context.waitUntil(processWhatsAppReply(entry))
|
||||
return new Response('Message is being processed.', { status: 200 })
|
||||
}
|
||||
@@ -40,7 +40,6 @@ const nextConfig = {
|
||||
transpilePackages: [
|
||||
'@typebot.io/lib',
|
||||
'@typebot.io/schemas',
|
||||
'@typebot.io/emails',
|
||||
'@typebot.io/env',
|
||||
],
|
||||
i18n: {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"format:check": "prettier --check ./src --ignore-path ../../.prettierignore"
|
||||
},
|
||||
"dependencies": {
|
||||
"@faire/mjml-react": "3.3.0",
|
||||
"@typebot.io/theme": "workspace:*",
|
||||
"@braintree/sanitize-url": "7.0.1",
|
||||
"@chakra-ui/anatomy": "2.1.1",
|
||||
@@ -23,7 +24,6 @@
|
||||
"@dnd-kit/utilities": "3.2.1",
|
||||
"@emotion/react": "11.11.1",
|
||||
"@emotion/styled": "11.11.0",
|
||||
"@faire/mjml-react": "3.3.0",
|
||||
"@giphy/js-fetch-api": "5.0.0",
|
||||
"@giphy/js-types": "4.4.0",
|
||||
"@giphy/js-util": "5.0.0",
|
||||
@@ -41,16 +41,18 @@
|
||||
"@trpc/react-query": "10.40.0",
|
||||
"@trpc/server": "10.40.0",
|
||||
"@typebot.io/bot-engine": "workspace:*",
|
||||
"@typebot.io/emails": "workspace:*",
|
||||
"@typebot.io/email-legacy": "workspace:*",
|
||||
"@typebot.io/env": "workspace:*",
|
||||
"@typebot.io/js": "workspace:*",
|
||||
"@typebot.io/nextjs": "workspace:*",
|
||||
"@udecode/cn": "29.0.1",
|
||||
"@udecode/plate-basic-marks": "30.5.3",
|
||||
"@udecode/plate-common": "30.4.5",
|
||||
"@udecode/plate-core": "30.4.5",
|
||||
"@udecode/plate-floating": "30.5.3",
|
||||
"@udecode/plate-link": "30.5.3",
|
||||
"@udecode/cn": "31.0.0",
|
||||
"@udecode/plate-basic-marks": "31.0.0",
|
||||
"@udecode/plate-core": "31.3.2",
|
||||
"@udecode/plate-floating": "31.0.0",
|
||||
"@udecode/plate-link": "31.0.0",
|
||||
"@udecode/slate": "31.0.0",
|
||||
"@udecode/slate-react": "31.0.0",
|
||||
"@udecode/plate-utils": "31.0.0",
|
||||
"@uiw/codemirror-extensions-langs": "4.21.24",
|
||||
"@uiw/codemirror-theme-github": "4.21.24",
|
||||
"@uiw/codemirror-theme-tokyo-night": "4.21.24",
|
||||
@@ -74,7 +76,7 @@
|
||||
"libphonenumber-js": "1.10.37",
|
||||
"micro": "10.0.1",
|
||||
"micro-cors": "0.1.1",
|
||||
"next": "14.1.0",
|
||||
"next": "14.2.1",
|
||||
"next-auth": "4.22.1",
|
||||
"nextjs-cors": "2.1.2",
|
||||
"nodemailer": "6.9.8",
|
||||
@@ -123,7 +125,6 @@
|
||||
"@types/qs": "6.9.7",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/tinycolor2": "1.4.3",
|
||||
"@vercel/edge": "1.1.1",
|
||||
"dotenv-cli": "7.2.1",
|
||||
"eslint": "8.44.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
|
||||
@@ -18,9 +18,9 @@ import CodeMirror, { ReactCodeMirrorRef } from '@uiw/react-codemirror'
|
||||
import { tokyoNight } from '@uiw/codemirror-theme-tokyo-night'
|
||||
import { githubLight } from '@uiw/codemirror-theme-github'
|
||||
import { LanguageName, loadLanguage } from '@uiw/codemirror-extensions-langs'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { CopyButton } from '../CopyButton'
|
||||
import { MoreInfoTooltip } from '../MoreInfoTooltip'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
type Props = {
|
||||
label?: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { sendMagicLinkEmail } from '@typebot.io/emails'
|
||||
import { sendMagicLinkEmail } from '@typebot.io/email-legacy'
|
||||
|
||||
type Props = {
|
||||
identifier: string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
import { Plate } from '@udecode/plate-core'
|
||||
import { platePlugins } from '@/lib/plate'
|
||||
import { TElement } from '@udecode/plate-common'
|
||||
import { TElement } from '@udecode/slate'
|
||||
import { TextEditorEditorContent } from './TextEditorEditorContent'
|
||||
|
||||
type TextBubbleEditorContentProps = {
|
||||
|
||||
@@ -15,8 +15,10 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { TextEditorToolBar } from './TextEditorToolBar'
|
||||
import { useTranslate } from '@tolgee/react'
|
||||
import { PlateContent, useEditorRef } from '@udecode/plate-core'
|
||||
import { focusEditor, insertText, selectEditor } from '@udecode/plate-common'
|
||||
import { useOutsideClick } from '@/hooks/useOutsideClick'
|
||||
import { insertText } from '@udecode/slate'
|
||||
import { focusEditor } from '@udecode/slate-react'
|
||||
import { selectEditor } from '@udecode/plate-utils'
|
||||
|
||||
type Props = {
|
||||
closeEditor: () => void
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import {
|
||||
useMarkToolbarButton,
|
||||
useMarkToolbarButtonState,
|
||||
} from '@udecode/plate-common'
|
||||
} from '@udecode/plate-utils'
|
||||
import { IconButton, IconButtonProps } from '@chakra-ui/react'
|
||||
|
||||
type Props = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TElement, TText, TDescendant } from '@udecode/plate-common'
|
||||
import { TElement, TText, TDescendant } from '@udecode/slate'
|
||||
import { PlateText } from './PlateText'
|
||||
|
||||
export const PlateBlock = ({ element }: { element: TElement | TText }) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { TextInput, NumberInput } from '@/components/inputs'
|
||||
import { SwitchWithLabel } from '@/components/inputs/SwitchWithLabel'
|
||||
import { Stack } from '@chakra-ui/react'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
import { SmtpCredentials } from '@typebot.io/schemas'
|
||||
import React from 'react'
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import { hasDefaultConnector } from '@/features/typebot/helpers/hasDefaultConnec
|
||||
import { setMultipleRefs } from '@/helpers/setMultipleRefs'
|
||||
import { TargetEndpoint } from '../../endpoints/TargetEndpoint'
|
||||
import { SettingsModal } from './SettingsModal'
|
||||
import { TElement } from '@udecode/plate-common'
|
||||
import { TElement } from '@udecode/slate'
|
||||
import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants'
|
||||
import { useGroupsStore } from '@/features/graph/hooks/useGroupsStore'
|
||||
import { TurnableIntoParam } from '@typebot.io/forge'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { FramerInstructions } from './instructions/FramerInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const FramerModal = ({ isOpen, onClose, isPublished }: ModalProps) => {
|
||||
const [selectedEmbedType, setSelectedEmbedType] = useState<
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { GtmInstructions } from './instructions/GtmInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const GtmModal = ({
|
||||
isOpen,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { JavascriptInstructions } from './instructions/JavascriptInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const JavascriptModal = ({
|
||||
isOpen,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { NextjsInstructions } from './instructions/NextjsInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const NextjsModal = ({ isOpen, onClose, isPublished }: ModalProps) => {
|
||||
const [selectedEmbedType, setSelectedEmbedType] = useState<
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { ReactInstructions } from './instructions/ReactInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const ReactModal = ({ isOpen, onClose, isPublished }: ModalProps) => {
|
||||
const [selectedEmbedType, setSelectedEmbedType] = useState<
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { ScriptInstructions } from './instructions/ScriptInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const ScriptModal = ({ isOpen, onClose, isPublished }: ModalProps) => {
|
||||
const [selectedEmbedType, setSelectedEmbedType] = useState<
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { ShopifyInstructions } from './instructions/ShopifyInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const ShopifyModal = ({
|
||||
isOpen,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { WebflowInstructions } from './instructions/WebflowInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const WebflowModal = ({ isOpen, onClose, isPublished }: ModalProps) => {
|
||||
const [selectedEmbedType, setSelectedEmbedType] = useState<
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalProps } from '../../EmbedButton'
|
||||
import { EmbedModal } from '../../EmbedModal'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { WixInstructions } from './instructions/WixInstructions'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const WixModal = ({ isOpen, onClose, isPublished }: ModalProps) => {
|
||||
const [selectedEmbedType, setSelectedEmbedType] = useState<
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { trpc } from '@/lib/trpc'
|
||||
import { isDefined } from '@udecode/plate-common'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
export const useLogs = (
|
||||
typebotId: string,
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
notAuthenticated,
|
||||
} from '@typebot.io/lib/api'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
import { sendGuestInvitationEmail } from '@typebot.io/emails'
|
||||
import { sendGuestInvitationEmail } from '@typebot.io/email-legacy'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
notAuthenticated,
|
||||
} from '@typebot.io/lib/api'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
import { sendWorkspaceMemberInvitationEmail } from '@typebot.io/emails'
|
||||
import { sendWorkspaceMemberInvitationEmail } from '@typebot.io/email-legacy'
|
||||
import { getSeatsLimit } from '@typebot.io/billing/getSeatsLimit'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
|
||||
@@ -3,8 +3,22 @@
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
},
|
||||
"include": ["next-env.d.ts", "tolgee.d.ts", "**/*.ts", "**/*.tsx"]
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"strictNullChecks": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"tolgee.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14532,430 +14532,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"operationId": "whatsApp-receiveMessagePreview",
|
||||
"summary": "Message webhook",
|
||||
"tags": [
|
||||
"WhatsApp"
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"entry": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"changes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"value": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"metadata": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"phone_number_id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"phone_number_id"
|
||||
]
|
||||
},
|
||||
"contacts": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"profile": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"profile"
|
||||
]
|
||||
}
|
||||
},
|
||||
"messages": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"text"
|
||||
]
|
||||
},
|
||||
"text": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"body": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"body"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"type",
|
||||
"text",
|
||||
"timestamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"button"
|
||||
]
|
||||
},
|
||||
"button": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"text": {
|
||||
"type": "string"
|
||||
},
|
||||
"payload": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"text",
|
||||
"payload"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"type",
|
||||
"button",
|
||||
"timestamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"interactive"
|
||||
]
|
||||
},
|
||||
"interactive": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"button_reply": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"title"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"button_reply"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"type",
|
||||
"interactive",
|
||||
"timestamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image"
|
||||
]
|
||||
},
|
||||
"image": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"type",
|
||||
"image",
|
||||
"timestamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"video"
|
||||
]
|
||||
},
|
||||
"video": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"type",
|
||||
"video",
|
||||
"timestamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"audio"
|
||||
]
|
||||
},
|
||||
"audio": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"type",
|
||||
"audio",
|
||||
"timestamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"document"
|
||||
]
|
||||
},
|
||||
"document": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"type",
|
||||
"document",
|
||||
"timestamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"location"
|
||||
]
|
||||
},
|
||||
"location": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"latitude": {
|
||||
"type": "number"
|
||||
},
|
||||
"longitude": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"latitude",
|
||||
"longitude"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"from",
|
||||
"type",
|
||||
"location",
|
||||
"timestamp"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"metadata"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"value"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"changes"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"entry"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"message"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid input data",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/error.BAD_REQUEST"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/folders/{folderId}": {
|
||||
|
||||
@@ -12473,10 +12473,18 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"runtime": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"edge",
|
||||
"nodejs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"messages"
|
||||
"messages",
|
||||
"runtime"
|
||||
]
|
||||
},
|
||||
"lastBubbleBlockId": {
|
||||
@@ -12753,6 +12761,13 @@
|
||||
true
|
||||
]
|
||||
},
|
||||
"runtime": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"edge",
|
||||
"nodejs"
|
||||
]
|
||||
},
|
||||
"lastBubbleBlockId": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -12762,7 +12777,8 @@
|
||||
},
|
||||
"required": [
|
||||
"type",
|
||||
"stream"
|
||||
"stream",
|
||||
"runtime"
|
||||
],
|
||||
"title": "Exec stream"
|
||||
},
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"aos": "2.3.4",
|
||||
"focus-visible": "5.2.0",
|
||||
"framer-motion": "10.12.20",
|
||||
"next": "14.1.0",
|
||||
"next": "14.2.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"@typebot.io/billing": "workspace:*"
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import {
|
||||
WhatsAppWebhookRequestBody,
|
||||
whatsAppWebhookRequestBodySchema,
|
||||
} from '@typebot.io/schemas/features/whatsapp'
|
||||
import { resumeWhatsAppFlow } from '@typebot.io/bot-engine/whatsapp/resumeWhatsAppFlow'
|
||||
import { isNotDefined } from '@typebot.io/lib'
|
||||
import type { RequestContext } from '@vercel/edge'
|
||||
|
||||
type Props = {
|
||||
entry: WhatsAppWebhookRequestBody['entry']
|
||||
workspaceId: string
|
||||
credentialsId: string
|
||||
}
|
||||
|
||||
const processWhatsAppReply = async ({
|
||||
entry,
|
||||
workspaceId,
|
||||
credentialsId,
|
||||
}: Props) => {
|
||||
const receivedMessage = entry.at(0)?.changes.at(0)?.value.messages?.at(0)
|
||||
if (isNotDefined(receivedMessage)) return { message: 'No message found' }
|
||||
const contactName =
|
||||
entry.at(0)?.changes.at(0)?.value?.contacts?.at(0)?.profile?.name ?? ''
|
||||
const contactPhoneNumber =
|
||||
entry.at(0)?.changes.at(0)?.value?.messages?.at(0)?.from ?? ''
|
||||
const phoneNumberId = entry.at(0)?.changes.at(0)?.value
|
||||
.metadata.phone_number_id
|
||||
if (!phoneNumberId) return { message: 'No phone number id found' }
|
||||
return resumeWhatsAppFlow({
|
||||
receivedMessage,
|
||||
sessionId: `wa-${phoneNumberId}-${receivedMessage.from}`,
|
||||
phoneNumberId,
|
||||
credentialsId,
|
||||
workspaceId,
|
||||
contact: {
|
||||
name: contactName,
|
||||
phoneNumber: contactPhoneNumber,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function POST(request: Request, context: RequestContext) {
|
||||
const workspaceId = request.url.match(/\/workspaces\/([^/]+)\//)?.[1]
|
||||
const credentialsId = request.url.match(/\/whatsapp\/([^/]+)\//)?.[1]
|
||||
if (!workspaceId || !credentialsId) {
|
||||
console.error('No workspace or credentials id found')
|
||||
return { message: 'No workspace or credentials id found' }
|
||||
}
|
||||
const body = await request.json()
|
||||
const { entry } = whatsAppWebhookRequestBodySchema.parse(body)
|
||||
context.waitUntil(processWhatsAppReply({ entry, workspaceId, credentialsId }))
|
||||
return new Response('Message is being processed.', { status: 200 })
|
||||
}
|
||||
@@ -41,11 +41,7 @@ const landingPagePaths = [
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
transpilePackages: [
|
||||
'@typebot.io/lib',
|
||||
'@typebot.io/schemas',
|
||||
'@typebot.io/emails',
|
||||
],
|
||||
transpilePackages: ['@typebot.io/lib', '@typebot.io/schemas'],
|
||||
output: 'standalone',
|
||||
experimental: {
|
||||
outputFileTracingRoot: join(__dirname, '../../'),
|
||||
|
||||
@@ -21,13 +21,14 @@
|
||||
"@typebot.io/js": "workspace:*",
|
||||
"@typebot.io/nextjs": "workspace:*",
|
||||
"@typebot.io/prisma": "workspace:*",
|
||||
"@udecode/plate-core": "31.3.2",
|
||||
"ai": "3.0.12",
|
||||
"bot-engine": "workspace:*",
|
||||
"cors": "2.8.5",
|
||||
"google-spreadsheet": "4.1.1",
|
||||
"got": "12.6.0",
|
||||
"ky": "1.2.3",
|
||||
"next": "14.1.0",
|
||||
"next": "14.2.1",
|
||||
"nextjs-cors": "2.1.2",
|
||||
"nodemailer": "6.9.8",
|
||||
"openai": "4.28.4",
|
||||
@@ -40,7 +41,7 @@
|
||||
"@faire/mjml-react": "3.3.0",
|
||||
"@paralleldrive/cuid2": "2.2.1",
|
||||
"@playwright/test": "1.36.0",
|
||||
"@typebot.io/emails": "workspace:*",
|
||||
"@typebot.io/email-legacy": "workspace:*",
|
||||
"@typebot.io/env": "workspace:*",
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/forge-repository": "workspace:*",
|
||||
@@ -56,7 +57,6 @@
|
||||
"@types/papaparse": "5.3.7",
|
||||
"@types/qs": "6.9.7",
|
||||
"@types/react": "18.2.15",
|
||||
"@vercel/edge": "1.1.1",
|
||||
"dotenv": "16.4.5",
|
||||
"dotenv-cli": "7.2.1",
|
||||
"eslint": "8.44.0",
|
||||
|
||||
@@ -13,8 +13,7 @@ import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
||||
|
||||
import Cors from 'cors'
|
||||
import Mail from 'nodemailer/lib/mailer'
|
||||
import { DefaultBotNotificationEmail } from '@typebot.io/emails'
|
||||
import { render } from '@faire/mjml-react/utils/render'
|
||||
import { DefaultBotNotificationEmail, render } from '@typebot.io/email-legacy'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { saveErrorLog } from '@typebot.io/bot-engine/logs/saveErrorLog'
|
||||
|
||||
20
apps/viewer/src/pages/api/waitUntilTest.ts
Normal file
20
apps/viewer/src/pages/api/waitUntilTest.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { createPlateEditor } from '@udecode/plate-core'
|
||||
|
||||
export const config = {
|
||||
supportsResponseStreaming: true,
|
||||
}
|
||||
|
||||
export default async function handler(_: NextApiRequest, res: NextApiResponse) {
|
||||
console.log(createPlateEditor())
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
const ctx = globalThis[Symbol.for('@vercel/request-context')]
|
||||
ctx.get().waitUntil(wait)
|
||||
return res.status(200).send('Message is being processed.')
|
||||
}
|
||||
|
||||
const wait = async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000))
|
||||
return
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@typebot.io/prisma": "workspace:*",
|
||||
"@typebot.io/schemas": "workspace:*",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { DefaultBotNotificationEmail, render } from '@typebot.io/emails'
|
||||
import { render } from '@typebot.io/emails/render'
|
||||
import DefaultSendEmailNotification from '@typebot.io/emails/templates/transactional/DefaultSendEmailNotification'
|
||||
import {
|
||||
AnswerInSessionState,
|
||||
ChatLog,
|
||||
@@ -253,11 +254,11 @@ const getEmailBody = async ({
|
||||
})
|
||||
return {
|
||||
html: render(
|
||||
<DefaultBotNotificationEmail
|
||||
<DefaultSendEmailNotification
|
||||
resultsUrl={`${env.NEXTAUTH_URL}/typebots/${typebot.id}/results`}
|
||||
answers={omit(answers, 'submittedAt')}
|
||||
/>
|
||||
).html,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"@typebot.io/schemas": "workspace:*",
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
"@typebot.io/variables": "workspace:*",
|
||||
"@udecode/plate-common": "30.4.5",
|
||||
"@udecode/slate": "31.0.0",
|
||||
"ai": "3.0.12",
|
||||
"chrono-node": "2.7.5",
|
||||
"date-fns": "2.30.0",
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
getVariablesToParseInfoInText,
|
||||
parseVariables,
|
||||
} from '@typebot.io/variables/parseVariables'
|
||||
import { TDescendant } from '@udecode/plate-common'
|
||||
import { TDescendant } from '@udecode/slate'
|
||||
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
|
||||
import { defaultVideoBubbleContent } from '@typebot.io/schemas/features/blocks/bubbles/video/constants'
|
||||
import { convertMarkdownToRichText } from '@typebot.io/lib/markdown/convertMarkdownToRichText'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@typebot.io/emails",
|
||||
"name": "@typebot.io/email-legacy",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"private": true,
|
||||
@@ -13,7 +13,7 @@
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@faire/mjml-react": "3.3.0",
|
||||
"@types/node": "20.4.2",
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
"lint": "eslint --fix \"src/**/*.ts*\"",
|
||||
"format:check": "prettier --check ./src"
|
||||
},
|
||||
"license": "MIT",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@stripe/stripe-js": "1.54.1",
|
||||
"@udecode/plate-common": "30.4.5",
|
||||
"@udecode/slate": "31.0.0",
|
||||
"dompurify": "3.0.6",
|
||||
"ky": "1.1.3",
|
||||
"marked": "9.0.3",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { TElement, TText, TDescendant } from '@udecode/plate-common'
|
||||
import type { TElement, TText, TDescendant } from '@udecode/slate'
|
||||
import { PlateText, PlateTextProps } from './PlateText'
|
||||
import { For, JSXElement, Match, Switch } from 'solid-js'
|
||||
import { isDefined } from '@typebot.io/lib/utils'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { TDescendant } from '@udecode/plate-common'
|
||||
import type { TDescendant } from '@udecode/slate'
|
||||
|
||||
export const computePlainText = (elements: TDescendant[]): string =>
|
||||
elements
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@babel/preset-react": "7.22.5",
|
||||
"@babel/preset-typescript": "7.22.5",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@ladle/react": "2.5.1"
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"author": "Enchatted P.C.",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"ai": "3.0.12",
|
||||
"openai": "4.28.4"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
|
||||
@@ -162,7 +162,7 @@ const createPackageJson = async (path: string, { id }: { id: unknown }) => {
|
||||
description: '',
|
||||
main: 'index.ts',
|
||||
keywords: [],
|
||||
license: 'ISC',
|
||||
license: 'AGPL-3.0-or-later',
|
||||
devDependencies: {
|
||||
'@typebot.io/forge': 'workspace:*',
|
||||
'@typebot.io/tsconfig': 'workspace:*',
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@clack/prompts": "^0.7.0",
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"zod": "3.22.4"
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/openai-block": "workspace:*",
|
||||
|
||||
@@ -2,9 +2,9 @@ import {
|
||||
createPlateEditor,
|
||||
createPluginFactory,
|
||||
getPluginOptions,
|
||||
isUrl,
|
||||
Value,
|
||||
} from '@udecode/plate-common'
|
||||
} from '@udecode/plate-core'
|
||||
import { Value } from '@udecode/slate'
|
||||
import { isUrl } from '@udecode/utils'
|
||||
import markdown from 'remark-parse'
|
||||
import { unified } from 'unified'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { TElement } from '@udecode/plate-common'
|
||||
import serialize from './serializer/serialize'
|
||||
import { defaultNodeTypes } from './serializer/ast-types'
|
||||
import { TElement } from '@udecode/slate'
|
||||
|
||||
export const convertRichTextToMarkdown = (
|
||||
richText: TElement[],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { getPluginOptions, PlateEditor, Value } from '@udecode/plate-common'
|
||||
import { Value } from '@udecode/slate'
|
||||
import { getPluginOptions, PlateEditor } from '@udecode/plate-core'
|
||||
import markdown from 'remark-parse'
|
||||
import { unified } from 'unified'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Value } from '@udecode/plate-common'
|
||||
import { Value } from '@udecode/slate'
|
||||
import { RemarkElementRules, RemarkTextRules } from '../remark-slate/types'
|
||||
|
||||
export interface DeserializeMdPlugin<V extends Value = Value> {
|
||||
|
||||
@@ -3,13 +3,8 @@ import {
|
||||
ELEMENT_CODE_BLOCK,
|
||||
ELEMENT_CODE_LINE,
|
||||
} from '@udecode/plate-code-block'
|
||||
import {
|
||||
getPluginType,
|
||||
TDescendant,
|
||||
TElement,
|
||||
TText,
|
||||
Value,
|
||||
} from '@udecode/plate-common'
|
||||
import { TDescendant, TElement, TText, Value } from '@udecode/slate'
|
||||
import { getPluginType } from '@udecode/plate-core'
|
||||
import {
|
||||
ELEMENT_H1,
|
||||
ELEMENT_H2,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { MARK_BOLD, MARK_CODE, MARK_ITALIC } from '@udecode/plate-basic-marks'
|
||||
import { getPluginType, Value } from '@udecode/plate-common'
|
||||
import { Value } from '@udecode/slate'
|
||||
import { getPluginType } from '@udecode/plate-core'
|
||||
|
||||
import { RemarkTextRules } from './types'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Value } from '@udecode/plate-common'
|
||||
import { Value } from '@udecode/slate'
|
||||
|
||||
import { remarkTransformNode } from './remarkTransformNode'
|
||||
import { MdastNode, RemarkPluginOptions } from './types'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TElement, Value } from '@udecode/plate-common'
|
||||
import { TElement, Value } from '@udecode/slate'
|
||||
|
||||
import { MdastNode, RemarkPluginOptions } from './types'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TDescendant, Value } from '@udecode/plate-common'
|
||||
import { TDescendant, Value } from '@udecode/slate'
|
||||
|
||||
import { remarkTransformNode } from './remarkTransformNode'
|
||||
import { MdastNode, RemarkPluginOptions } from './types'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TDescendant, Value } from '@udecode/plate-common'
|
||||
import { TDescendant, Value } from '@udecode/slate'
|
||||
|
||||
import { remarkTextTypes } from './remarkTextTypes'
|
||||
import { remarkTransformElement } from './remarkTransformElement'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TText, Value } from '@udecode/plate-common'
|
||||
import { TText, Value } from '@udecode/slate'
|
||||
|
||||
import { remarkDefaultTextRules } from './remarkDefaultTextRules'
|
||||
import { MdastNode, RemarkPluginOptions } from './types'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PlateEditor, TElement, Value } from '@udecode/plate-common'
|
||||
import { TElement, Value } from '@udecode/slate'
|
||||
import { PlateEditor } from '@udecode/plate-core'
|
||||
|
||||
export type MdastElementType =
|
||||
| 'paragraph'
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"@types/escape-html": "^1.0.4",
|
||||
"@types/nodemailer": "6.4.8",
|
||||
"@types/validator": "13.11.9",
|
||||
"next": "14.1.0",
|
||||
"next": "14.2.1",
|
||||
"nodemailer": "6.9.8",
|
||||
"tslib": "2.6.0",
|
||||
"typescript": "5.3.2"
|
||||
@@ -26,16 +26,18 @@
|
||||
"dependencies": {
|
||||
"@sentry/nextjs": "7.77.0",
|
||||
"@trpc/server": "10.40.0",
|
||||
"@udecode/plate-basic-marks": "30.5.3",
|
||||
"@udecode/plate-block-quote": "30.5.3",
|
||||
"@udecode/plate-code-block": "30.7.0",
|
||||
"@udecode/plate-common": "30.4.5",
|
||||
"@udecode/plate-heading": "30.5.3",
|
||||
"@udecode/plate-horizontal-rule": "30.5.3",
|
||||
"@udecode/plate-link": "30.5.3",
|
||||
"@udecode/plate-list": "30.5.3",
|
||||
"@udecode/plate-media": "30.5.3",
|
||||
"@udecode/plate-paragraph": "30.5.3",
|
||||
"@udecode/plate-basic-marks": "31.0.0",
|
||||
"@udecode/plate-block-quote": "31.0.0",
|
||||
"@udecode/plate-code-block": "31.3.4",
|
||||
"@udecode/plate-core": "31.3.2",
|
||||
"@udecode/plate-heading": "31.0.0",
|
||||
"@udecode/plate-horizontal-rule": "31.0.0",
|
||||
"@udecode/plate-link": "31.0.0",
|
||||
"@udecode/plate-list": "31.1.3",
|
||||
"@udecode/plate-media": "31.0.0",
|
||||
"@udecode/plate-paragraph": "31.0.0",
|
||||
"@udecode/slate": "31.0.0",
|
||||
"@udecode/utils": "31.0.0",
|
||||
"escape-html": "1.0.3",
|
||||
"google-auth-library": "8.9.0",
|
||||
"ky": "1.2.3",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"scripts": {},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@typebot.io/schemas": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"scripts": {},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@playwright/test": "^1.42.1",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@udecode/plate-common": "30.4.5"
|
||||
"@udecode/slate": "31.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typebot.io/schemas": "workspace:*",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"scripts": {},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@typebot.io/schemas": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from '../../../../zod'
|
||||
import type { TElement } from '@udecode/plate-common'
|
||||
import type { TElement } from '@udecode/slate'
|
||||
import { blockBaseSchema } from '../../shared'
|
||||
import { BubbleBlockType } from '../constants'
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@udecode/plate-common": "30.4.5",
|
||||
"@udecode/slate": "31.0.0",
|
||||
"zod": "3.22.4",
|
||||
"zod-openapi": "^2.11.0"
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ import { isDefined, isEmpty } from '@typebot.io/lib'
|
||||
import { getChatsLimit } from '@typebot.io/billing/getChatsLimit'
|
||||
import { promptAndSetEnvironment } from './utils'
|
||||
import { Workspace } from '@typebot.io/schemas'
|
||||
import { sendAlmostReachedChatsLimitEmail } from '@typebot.io/emails/src/emails/AlmostReachedChatsLimitEmail'
|
||||
import { sendAlmostReachedChatsLimitEmail } from '@typebot.io/email-legacy/src/emails/AlmostReachedChatsLimitEmail'
|
||||
import { TelemetryEvent } from '@typebot.io/schemas/features/telemetry'
|
||||
import { trackEvents } from '@typebot.io/telemetry/trackEvents'
|
||||
import Stripe from 'stripe'
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"deleteChatSession": "tsx deleteChatSession.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typebot.io/emails": "workspace:*",
|
||||
"@typebot.io/email-legacy": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
"@typebot.io/prisma": "workspace:*",
|
||||
"@typebot.io/schemas": "workspace:*",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"scripts": {},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@typebot.io/schemas": "workspace:*",
|
||||
"ky": "1.2.3",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"scripts": {},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@typebot.io/schemas": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "transactional",
|
||||
"name": "@typebot.io/emails",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
@@ -7,13 +7,15 @@
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@react-email/components": "0.0.14",
|
||||
"react-email": "2.0.0",
|
||||
"@typebot.io/env": "workspace:*"
|
||||
"@react-email/components": "0.0.16",
|
||||
"@react-email/render": "0.0.12",
|
||||
"@typebot.io/env": "workspace:*",
|
||||
"react-email": "2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typebot.io/tsconfig": "workspace:^",
|
||||
"dotenv-cli": "7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
1
packages/transactional/render.ts
Normal file
1
packages/transactional/render.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { render } from '@react-email/render'
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
Button,
|
||||
Section,
|
||||
} from '@react-email/components'
|
||||
import * as React from 'react'
|
||||
import { env } from '@typebot.io/env'
|
||||
import {
|
||||
main,
|
||||
|
||||
@@ -9,10 +9,8 @@ import {
|
||||
Text,
|
||||
Hr,
|
||||
Heading,
|
||||
Button,
|
||||
Section,
|
||||
} from '@react-email/components'
|
||||
import * as React from 'react'
|
||||
import { env } from '@typebot.io/env'
|
||||
import {
|
||||
main,
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
Heading,
|
||||
Section,
|
||||
} from '@react-email/components'
|
||||
import * as React from 'react'
|
||||
import { env } from '@typebot.io/env'
|
||||
import {
|
||||
main,
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import {
|
||||
Body,
|
||||
Button,
|
||||
Container,
|
||||
Head,
|
||||
Html,
|
||||
Link,
|
||||
Text,
|
||||
} from '@react-email/components'
|
||||
|
||||
const emailRegex =
|
||||
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||
|
||||
type Props = {
|
||||
resultsUrl: string
|
||||
answers: { [key: string]: string }
|
||||
}
|
||||
|
||||
const DefaultSendEmailNotification = ({ resultsUrl, answers }: Props) => (
|
||||
<Html>
|
||||
<Head />
|
||||
<Body style={body}>
|
||||
<Container style={container}>
|
||||
{Object.keys(answers).map((key, index) => {
|
||||
const isEmail = emailRegex.test(answers[key])
|
||||
|
||||
return (
|
||||
<Text key={key} style={index === 0 ? firstEntry : entry}>
|
||||
<strong>{key}</strong>:{' '}
|
||||
{isEmail ? (
|
||||
<Link href={`mailto:${answers[key]}`}>{answers[key]}</Link>
|
||||
) : answers[key].includes('\n') ? (
|
||||
answers[key].split('\n').map((line) => (
|
||||
<>
|
||||
{line}
|
||||
<br />
|
||||
</>
|
||||
))
|
||||
) : (
|
||||
answers[key]
|
||||
)}
|
||||
</Text>
|
||||
)
|
||||
})}
|
||||
<Button style={goToResultsButton} href={resultsUrl}>
|
||||
Go to results
|
||||
</Button>
|
||||
</Container>
|
||||
</Body>
|
||||
</Html>
|
||||
)
|
||||
|
||||
const body = {
|
||||
fontFamily:
|
||||
"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
||||
}
|
||||
|
||||
const container = {
|
||||
maxWidth: '600px',
|
||||
margin: '0 auto',
|
||||
padding: '20px 30px',
|
||||
border: '1px solid #eaeaea',
|
||||
}
|
||||
|
||||
const goToResultsButton = {
|
||||
backgroundColor: '#0042DA',
|
||||
padding: '10px 24px',
|
||||
borderRadius: '6px',
|
||||
color: 'white',
|
||||
}
|
||||
|
||||
const firstEntry = {
|
||||
margin: '0 0 24x 0',
|
||||
}
|
||||
|
||||
const entry = {
|
||||
margin: '24px 0',
|
||||
}
|
||||
|
||||
DefaultSendEmailNotification.PreviewProps = {
|
||||
resultsUrl: 'http://localhost:3000',
|
||||
answers: {
|
||||
Name: 'John Doe',
|
||||
Email: 'baptiste@typebot.io',
|
||||
'Additional information': 'I have a question about your product.',
|
||||
},
|
||||
} satisfies Props
|
||||
|
||||
export default DefaultSendEmailNotification
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
Preview,
|
||||
Text,
|
||||
} from '@react-email/components'
|
||||
import * as React from 'react'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
interface Props {
|
||||
|
||||
9
packages/transactional/tsconfig.json
Normal file
9
packages/transactional/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "@typebot.io/tsconfig/base.json",
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["dist", "node_modules"],
|
||||
"compilerOptions": {
|
||||
"jsx": "preserve",
|
||||
"lib": ["ESNext"]
|
||||
}
|
||||
}
|
||||
1265
pnpm-lock.yaml
generated
1265
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user