♻️ 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/*"
|
||||
]
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"strictNullChecks": true
|
||||
},
|
||||
"include": ["next-env.d.ts", "tolgee.d.ts", "**/*.ts", "**/*.tsx"]
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"tolgee.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user