♻️ Export bot-engine code into its own package
This commit is contained in:
@@ -3,10 +3,10 @@ import { ErrorPage } from '@/components/ErrorPage'
|
||||
import { NotFoundPage } from '@/components/NotFoundPage'
|
||||
import { GetServerSideProps, GetServerSidePropsContext } from 'next'
|
||||
import { isNotDefined } from '@typebot.io/lib'
|
||||
import prisma from '../lib/prisma'
|
||||
import { TypebotPageProps, TypebotPageV2 } from '@/components/TypebotPageV2'
|
||||
import { TypebotPageV3, TypebotV3PageProps } from '@/components/TypebotPageV3'
|
||||
import { env } from '@typebot.io/env'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
|
||||
// Browsers that doesn't support ES modules and/or web components
|
||||
const incompatibleBrowsers = [
|
||||
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
} from '@typebot.io/schemas'
|
||||
import Cors from 'cors'
|
||||
import { getAuthenticatedGoogleClient } from '@/lib/google-sheets'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||
import { saveErrorLog } from '@typebot.io/bot-engine/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@typebot.io/bot-engine/logs/saveSuccessLog'
|
||||
|
||||
const cors = initMiddleware(Cors())
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { getChatCompletionStream } from '@/features/blocks/integrations/openai/getChatCompletionStream'
|
||||
import { connect } from '@planetscale/database'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { IntegrationBlockType, SessionState } from '@typebot.io/schemas'
|
||||
import { StreamingTextResponse } from 'ai'
|
||||
import { ChatCompletionRequestMessage } from 'openai-edge'
|
||||
import { getChatCompletionStream } from '@typebot.io/bot-engine/blocks/integrations/openai/getChatCompletionStream'
|
||||
|
||||
export const config = {
|
||||
runtime: 'edge',
|
||||
|
||||
@@ -14,8 +14,8 @@ import {
|
||||
StripeCredentials,
|
||||
Variable,
|
||||
} from '@typebot.io/schemas'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { parseVariables } from '@typebot.io/bot-engine/variables/parseVariables'
|
||||
|
||||
const cors = initMiddleware(Cors())
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import Cors from 'cors'
|
||||
import { initMiddleware, methodNotAllowed, notFound } from '@typebot.io/lib/api'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { authenticateUser } from '@/helpers/authenticateUser'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { methodNotAllowed } from '@typebot.io/lib/api'
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ import { parseAnswers } from '@typebot.io/lib/results'
|
||||
import { initMiddleware, methodNotAllowed, notFound } from '@typebot.io/lib/api'
|
||||
import { stringify } from 'qs'
|
||||
import Cors from 'cors'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import { parseSampleResult } from '@/features/blocks/integrations/webhook/parseSampleResult'
|
||||
import { fetchLinkedTypebots } from '@/features/blocks/logic/typebotLink/fetchLinkedTypebots'
|
||||
import { getPreviouslyLinkedTypebots } from '@/features/blocks/logic/typebotLink/getPreviouslyLinkedTypebots'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { HttpMethod } from '@typebot.io/schemas/features/blocks/integrations/webhook/enums'
|
||||
import { fetchLinkedTypebots } from '@typebot.io/bot-engine/blocks/logic/typebotLink/fetchLinkedTypebots'
|
||||
import { getPreviouslyLinkedTypebots } from '@typebot.io/bot-engine/blocks/logic/typebotLink/getPreviouslyLinkedTypebots'
|
||||
import { parseVariables } from '@typebot.io/bot-engine/variables/parseVariables'
|
||||
import { saveErrorLog } from '@typebot.io/bot-engine/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@typebot.io/bot-engine/logs/saveSuccessLog'
|
||||
import { parseSampleResult } from '@typebot.io/bot-engine/blocks/integrations/webhook/parseSampleResult'
|
||||
|
||||
const cors = initMiddleware(Cors())
|
||||
|
||||
@@ -128,10 +128,10 @@ export const executeWebhook =
|
||||
convertKeyValueTableToObject(webhook.queryParams, variables)
|
||||
)
|
||||
const contentType = headers ? headers['Content-Type'] : undefined
|
||||
const linkedTypebotsParents = await fetchLinkedTypebots({
|
||||
const linkedTypebotsParents = (await fetchLinkedTypebots({
|
||||
isPreview: !('typebotId' in typebot),
|
||||
typebotIds: parentTypebotIds,
|
||||
})
|
||||
})) as (Typebot | PublicTypebot)[]
|
||||
const linkedTypebotsChildren = await getPreviouslyLinkedTypebots({
|
||||
isPreview: !('typebotId' in typebot),
|
||||
typebots: [typebot],
|
||||
|
||||
@@ -14,10 +14,10 @@ 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 prisma from '@/lib/prisma'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { saveErrorLog } from '@typebot.io/bot-engine/logs/saveErrorLog'
|
||||
import { saveSuccessLog } from '@typebot.io/bot-engine/logs/saveSuccessLog'
|
||||
|
||||
const cors = initMiddleware(Cors())
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { authenticateUser } from '@/helpers/authenticateUser'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { ResultWithAnswers } from '@typebot.io/schemas'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { methodNotAllowed } from '@typebot.io/lib/api'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Result } from '@typebot.io/schemas'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { methodNotAllowed } from '@typebot.io/lib/api'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Answer } from '@typebot.io/prisma'
|
||||
import { got } from 'got'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { authenticateUser } from '@/helpers/authenticateUser'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Group, WebhookBlock } from '@typebot.io/schemas'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { byId, isWebhookBlock, parseGroupTitle } from '@typebot.io/lib'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { authenticateUser } from '@/helpers/authenticateUser'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Group, WebhookBlock } from '@typebot.io/schemas'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import {
|
||||
|
||||
@@ -3,8 +3,8 @@ import { ErrorPage } from '@/components/ErrorPage'
|
||||
import { NotFoundPage } from '@/components/NotFoundPage'
|
||||
import { GetServerSideProps, GetServerSidePropsContext } from 'next'
|
||||
import { isDefined, isNotDefined, omit } from '@typebot.io/lib'
|
||||
import prisma from '../../lib/prisma'
|
||||
import { TypebotPageProps, TypebotPageV2 } from '@/components/TypebotPageV2'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (
|
||||
context: GetServerSidePropsContext
|
||||
|
||||
Reference in New Issue
Block a user