♻️ Export bot-engine code into its own package
This commit is contained in:
@@ -27,8 +27,6 @@
|
||||
"@googleapis/drive": "8.0.0",
|
||||
"@paralleldrive/cuid2": "2.2.1",
|
||||
"@sentry/nextjs": "7.66.0",
|
||||
"@stripe/stripe-js": "1.54.1",
|
||||
"@t3-oss/env-nextjs": "^0.6.0",
|
||||
"@tanstack/react-query": "^4.29.19",
|
||||
"@tanstack/react-table": "8.9.3",
|
||||
"@trpc/client": "10.34.0",
|
||||
@@ -42,7 +40,6 @@
|
||||
"@udecode/plate-common": "^21.1.5",
|
||||
"@udecode/plate-core": "21.1.5",
|
||||
"@udecode/plate-link": "21.2.0",
|
||||
"@udecode/plate-serializer-html": "21.1.5",
|
||||
"@udecode/plate-ui-link": "21.2.0",
|
||||
"@udecode/plate-ui-toolbar": "21.1.5",
|
||||
"@uiw/codemirror-extensions-langs": "^4.21.7",
|
||||
@@ -85,7 +82,6 @@
|
||||
"sharp": "^0.32.4",
|
||||
"slate": "0.94.1",
|
||||
"slate-history": "0.93.0",
|
||||
"slate-hyperscript": "0.77.0",
|
||||
"slate-react": "0.94.2",
|
||||
"stripe": "12.13.0",
|
||||
"svg-round-corners": "0.4.1",
|
||||
@@ -94,7 +90,7 @@
|
||||
"trpc-openapi": "1.2.0",
|
||||
"unsplash-js": "^7.0.18",
|
||||
"use-debounce": "9.0.4",
|
||||
"@typebot.io/viewer": "workspace:*"
|
||||
"@typebot.io/bot-engine": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chakra-ui/styled-system": "2.9.1",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { PublicTypebot } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authOptions } from '@/pages/api/auth/[...nextauth]'
|
||||
import { setUser } from '@sentry/nextjs'
|
||||
import { User } from '@typebot.io/prisma'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Plan } from '@typebot.io/prisma'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Plan } from '@typebot.io/prisma'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import Stripe from 'stripe'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import Stripe from 'stripe'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import Stripe from 'stripe'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { sendTelemetryEvents } from '@typebot.io/lib/telemetry/sendTelemetryEvent'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Plan } from '@typebot.io/prisma'
|
||||
|
||||
@@ -51,7 +51,6 @@ test('should display valid usage', async ({ page }) => {
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 10,000"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 10 GB"')).toBeVisible()
|
||||
await page.getByText('Members', { exact: true }).click()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Members (1/5)' })
|
||||
@@ -63,7 +62,6 @@ test('should display valid usage', async ({ page }) => {
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 100,000"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 50 GB"')).toBeVisible()
|
||||
await expect(page.getByText('Upgrade to Starter')).toBeHidden()
|
||||
await expect(page.getByText('Upgrade to Pro')).toBeHidden()
|
||||
await expect(page.getByText('Need custom limits?')).toBeHidden()
|
||||
@@ -78,7 +76,6 @@ test('should display valid usage', async ({ page }) => {
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 200"')).toBeVisible()
|
||||
await expect(page.locator('text="Storage"')).toBeHidden()
|
||||
await page.getByText('Members', { exact: true }).click()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Members (1/1)' })
|
||||
@@ -95,17 +92,11 @@ test('should display valid usage', async ({ page }) => {
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 2,000"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 2 GB"')).toBeVisible()
|
||||
await expect(page.locator('text="10" >> nth=0')).toBeVisible()
|
||||
await expect(page.locator('[role="progressbar"] >> nth=0')).toHaveAttribute(
|
||||
'aria-valuenow',
|
||||
'1'
|
||||
)
|
||||
await expect(page.locator('text="1.07 GB"')).toBeVisible()
|
||||
await expect(page.locator('[role="progressbar"] >> nth=1')).toHaveAttribute(
|
||||
'aria-valuenow',
|
||||
'54'
|
||||
)
|
||||
|
||||
await injectFakeResults({
|
||||
typebotId: usageTypebotId,
|
||||
@@ -116,10 +107,7 @@ test('should display valid usage', async ({ page }) => {
|
||||
await page.click('text="Billing & Usage"')
|
||||
await expect(page.locator('text="/ 2,000"')).toBeVisible()
|
||||
await expect(page.locator('text="1,100"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 2 GB"')).toBeVisible()
|
||||
await expect(page.locator('text="2.25 GB"')).toBeVisible()
|
||||
await expect(page.locator('[aria-valuenow="55"]')).toBeVisible()
|
||||
await expect(page.locator('[aria-valuenow="112"]')).toBeVisible()
|
||||
})
|
||||
|
||||
test('plan changes should work', async ({ page }) => {
|
||||
@@ -160,9 +148,7 @@ test('plan changes should work', async ({ page }) => {
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 2,000"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 2 GB"')).toBeVisible()
|
||||
await expect(page.getByText('/ 2,000')).toBeVisible()
|
||||
await expect(page.getByText('/ 2 GB')).toBeVisible()
|
||||
await page.click('button >> text="2,000"')
|
||||
await page.click('button >> text="3,500"')
|
||||
await page.click('button >> text="2"')
|
||||
@@ -178,7 +164,6 @@ test('plan changes should work', async ({ page }) => {
|
||||
await page.click('text="Billing & Usage"')
|
||||
await expect(page.locator('text="$73"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 3,500"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 4 GB"')).toBeVisible()
|
||||
await expect(page.getByRole('button', { name: '3,500' })).toBeVisible()
|
||||
await expect(page.getByRole('button', { name: '4' })).toBeVisible()
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ test('options should work', async ({ page }) => {
|
||||
await page.fill('[value="Upload"]', 'Go')
|
||||
await page.fill('[value="Clear"]', 'Reset')
|
||||
await page.fill('[value="Skip"]', 'Pass')
|
||||
await page.fill('input[value="10"]', '20')
|
||||
await page.click('text="Restart"')
|
||||
await expect(page.locator(`text="Pass"`)).toBeVisible()
|
||||
await expect(page.locator(`text="Upload now!!"`)).toBeVisible()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { canReadTypebots } from '@/helpers/databaseRules'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { canReadTypebots } from '@/helpers/databaseRules'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { canWriteTypebots } from '@/helpers/databaseRules'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { canWriteTypebots } from '@/helpers/databaseRules'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { LogicBlockType, typebotSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { canReadTypebots } from '@/helpers/databaseRules'
|
||||
import { User } from '@typebot.io/prisma'
|
||||
import { LogicBlockType, PublicTypebot, Typebot } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import { createId } from '@paralleldrive/cuid2'
|
||||
import { CollaborationType, Plan, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { InputBlockType, defaultTextInputOptions } from '@typebot.io/schemas'
|
||||
import {
|
||||
createTypebots,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { stripeCredentialsSchema } from '@typebot.io/schemas/features/blocks/inputs/payment/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { stripeCredentialsSchema } from '@typebot.io/schemas/features/blocks/inputs/payment/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
domainResponseSchema,
|
||||
domainVerificationStatusSchema,
|
||||
} from '@typebot.io/schemas/features/customDomains'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
@@ -3,7 +3,7 @@ import { TRPCError } from '@trpc/server'
|
||||
import { Group } from '@typebot.io/schemas'
|
||||
import { z } from 'zod'
|
||||
import { archiveResults } from '@typebot.io/lib/api/helpers/archiveResults'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { isWriteTypebotForbidden } from '@/features/typebot/helpers/isWriteTypebotForbidden'
|
||||
|
||||
export const deleteResults = authenticatedProcedure
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { ResultWithAnswers, resultWithAnswersSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { logSchema } from '@typebot.io/schemas'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { ResultWithAnswers, resultWithAnswersSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { ThemeTemplate, themeTemplateSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { ThemeTemplate, themeTemplateSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { ThemeTemplate, themeTemplateSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Plan, WorkspaceRole } from '@typebot.io/prisma'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Group } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { publicTypebotSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Typebot, typebotSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { WorkspaceRole } from '@typebot.io/prisma'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { InputBlockType, typebotSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { typebotCreateSchema, typebotSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { CollaboratorsOnTypebots, User } from '@typebot.io/prisma'
|
||||
import { Typebot } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import {
|
||||
CollaborationType,
|
||||
CollaboratorsOnTypebots,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Plan } from '@typebot.io/prisma'
|
||||
import {
|
||||
Block,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { generatePresignedPostPolicy } from '@typebot.io/lib/s3/generatePresignedPostPolicy'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden'
|
||||
import { isWriteTypebotForbidden } from '@/features/typebot/helpers/isWriteTypebotForbidden'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { z } from 'zod'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { createId } from '@paralleldrive/cuid2'
|
||||
|
||||
export const generateVerificationToken = authenticatedProcedure
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { z } from 'zod'
|
||||
import got from 'got'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { decrypt } from '@typebot.io/lib/api'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { WhatsAppCredentials } from '@typebot.io/schemas/features/whatsapp'
|
||||
|
||||
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
||||
import got from 'got'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { WhatsAppCredentials } from '@typebot.io/schemas/features/whatsapp'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { decrypt } from '@typebot.io/lib/api/encryption'
|
||||
|
||||
const inputSchema = z.object({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { publicProcedure } from '@/helpers/server/trpc'
|
||||
import { whatsAppWebhookRequestBodySchema } from '@typebot.io/schemas/features/whatsapp'
|
||||
import { z } from 'zod'
|
||||
import { resumeWhatsAppFlow } from '@typebot.io/viewer/src/features/whatsApp/helpers/resumeWhatsAppFlow'
|
||||
import { resumeWhatsAppFlow } from '@typebot.io/bot-engine/whatsapp/resumeWhatsAppFlow'
|
||||
import { isNotDefined } from '@typebot.io/lib'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { z } from 'zod'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { sendWhatsAppMessage } from '@typebot.io/lib/whatsApp/sendWhatsAppMessage'
|
||||
import { startSession } from '@typebot.io/viewer/src/features/chat/helpers/startSession'
|
||||
import { startSession } from '@typebot.io/bot-engine/startSession'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { HTTPError } from 'got'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { sendChatReplyToWhatsApp } from '@typebot.io/lib/whatsApp/sendChatReplyToWhatsApp'
|
||||
import { saveStateToDatabase } from '@typebot.io/viewer/src/features/chat/helpers/saveStateToDatabase'
|
||||
import { restartSession } from '@typebot.io/viewer/src/features/chat/queries/restartSession'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { saveStateToDatabase } from '@typebot.io/bot-engine/saveStateToDatabase'
|
||||
import { restartSession } from '@typebot.io/bot-engine/queries/restartSession'
|
||||
import { sendChatReplyToWhatsApp } from '@typebot.io/bot-engine/whatsapp/sendChatReplyToWhatsApp'
|
||||
import { sendWhatsAppMessage } from '@typebot.io/bot-engine/whatsapp/sendWhatsAppMessage'
|
||||
import { isReadTypebotForbidden } from '../typebot/helpers/isReadTypebotForbidden'
|
||||
import { SessionState } from '@typebot.io/schemas'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { z } from 'zod'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
|
||||
export const verifyIfPhoneNumberAvailable = authenticatedProcedure
|
||||
.meta({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { sendTelemetryEvents } from '@typebot.io/lib/telemetry/sendTelemetryEvent'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Workspace, workspaceSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { z } from 'zod'
|
||||
import { isAdminWriteWorkspaceForbidden } from '../helpers/isAdminWriteWorkspaceForbidden'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { workspaceSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { workspaceInvitationSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { workspaceMemberSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { workspaceSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { workspaceSchema } from '@typebot.io/schemas'
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
User,
|
||||
WorkspaceRole,
|
||||
} from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiResponse } from 'next'
|
||||
import { forbidden } from '@typebot.io/lib/api'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
@@ -3,8 +3,8 @@ import { OAuth2Client, Credentials } from 'google-auth-library'
|
||||
import { GoogleSheetsCredentials } from '@typebot.io/schemas'
|
||||
import { isDefined } from '@typebot.io/lib'
|
||||
import { decrypt, encrypt } from '@typebot.io/lib/api'
|
||||
import prisma from './prisma'
|
||||
import { env } from '@typebot.io/env'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
|
||||
export const oauth2Client = new OAuth2Client(
|
||||
env.GOOGLE_CLIENT_ID,
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Instantiates a single instance PrismaClient and save it on the global object.
|
||||
* @link https://www.prisma.io/docs/support/help-articles/nextjs-prisma-client-dev-practices
|
||||
*/
|
||||
import { env } from '@typebot.io/env'
|
||||
import { PrismaClient } from '@typebot.io/prisma'
|
||||
|
||||
const prismaGlobal = global as typeof global & {
|
||||
prisma?: PrismaClient
|
||||
}
|
||||
|
||||
const prisma: PrismaClient =
|
||||
prismaGlobal.prisma ||
|
||||
new PrismaClient({
|
||||
log: env.NODE_ENV === 'development' ? ['error', 'warn'] : ['error'],
|
||||
})
|
||||
|
||||
if (env.NODE_ENV !== 'production') {
|
||||
prismaGlobal.prisma = prisma
|
||||
}
|
||||
|
||||
export default prisma
|
||||
@@ -5,7 +5,7 @@ import GitlabProvider from 'next-auth/providers/gitlab'
|
||||
import GoogleProvider from 'next-auth/providers/google'
|
||||
import FacebookProvider from 'next-auth/providers/facebook'
|
||||
import AzureADProvider from 'next-auth/providers/azure-ad'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Provider } from 'next-auth/providers'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { customAdapter } from '../../../features/auth/api/customAdapter'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Credentials } from '@typebot.io/schemas'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import {
|
||||
badRequest,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { Prisma } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { googleSheetsScopes } from './consent-url'
|
||||
import { stringify } from 'querystring'
|
||||
import { badRequest, encrypt, notAuthenticated } from '@typebot.io/lib/api'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import {
|
||||
badRequest,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DashboardFolder, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import {
|
||||
badRequest,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DashboardFolder } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { methodNotAllowed, notAuthenticated } from '@typebot.io/lib/api'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { methodNotAllowed, notAuthenticated } from '@typebot.io/lib/api'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { InputBlockType, PublicTypebot } from '@typebot.io/schemas'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { canPublishFileInput } from '@/helpers/databaseRules'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { InputBlockType, PublicTypebot } from '@typebot.io/schemas'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { canPublishFileInput, canWriteTypebots } from '@/helpers/databaseRules'
|
||||
|
||||
@@ -3,7 +3,7 @@ import { methodNotAllowed } from '@typebot.io/lib/api'
|
||||
import Stripe from 'stripe'
|
||||
import Cors from 'micro-cors'
|
||||
import { buffer } from 'micro'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Plan, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import { RequestHandler } from 'next/dist/server/next'
|
||||
import { sendTelemetryEvents } from '@typebot.io/lib/telemetry/sendTelemetryEvent'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Stats } from '@typebot.io/schemas'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { canReadTypebots } from '@/helpers/databaseRules'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { canReadTypebots } from '@/helpers/databaseRules'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { canReadTypebots } from '@/helpers/databaseRules'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { canEditGuests } from '@/helpers/databaseRules'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CollaborationType, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import {
|
||||
canReadTypebots,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Invitation } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { canEditGuests } from '@/helpers/databaseRules'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
import { methodNotAllowed, notAuthenticated } from '@typebot.io/lib/api'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
import { generateId } from '@typebot.io/lib'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
import { methodNotAllowed, notAuthenticated } from '@typebot.io/lib/api'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { WorkspaceInvitation, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import {
|
||||
forbidden,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { WorkspaceInvitation, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
import { methodNotAllowed, notAuthenticated } from '@typebot.io/lib/api'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MemberInWorkspace, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser'
|
||||
import { methodNotAllowed, notAuthenticated } from '@typebot.io/lib/api'
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*", "../viewer/src/*"]
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
|
||||
|
||||
@@ -1565,7 +1565,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -5952,7 +5953,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -9974,7 +9976,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -14136,7 +14139,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -18178,7 +18182,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -22275,7 +22280,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -26435,7 +26441,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -33600,12 +33607,17 @@
|
||||
"presignedUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"formData": {
|
||||
"type": "object",
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"fileUrl": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"presignedUrl",
|
||||
"formData",
|
||||
"fileUrl"
|
||||
],
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -1148,7 +1148,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -5075,7 +5076,8 @@
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"description": "Deprecated"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -6348,12 +6350,17 @@
|
||||
"presignedUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"formData": {
|
||||
"type": "object",
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"hasReachedStorageLimit": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"presignedUrl",
|
||||
"formData",
|
||||
"hasReachedStorageLimit"
|
||||
],
|
||||
"additionalProperties": false
|
||||
@@ -6428,12 +6435,17 @@
|
||||
"presignedUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"formData": {
|
||||
"type": "object",
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"fileUrl": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"presignedUrl",
|
||||
"formData",
|
||||
"fileUrl"
|
||||
],
|
||||
"additionalProperties": false
|
||||
@@ -6499,7 +6511,10 @@
|
||||
"/workspaces/{workspaceId}/whatsapp/phoneNumbers/{phoneNumberId}/webhook": {
|
||||
"get": {
|
||||
"operationId": "whatsAppRouter-subscribeWebhook",
|
||||
"summary": "Subscribe WhatsApp webhook",
|
||||
"summary": "Subscribe webhook",
|
||||
"tags": [
|
||||
"WhatsApp"
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
@@ -6557,7 +6572,10 @@
|
||||
},
|
||||
"post": {
|
||||
"operationId": "whatsAppRouter-receiveMessage",
|
||||
"summary": "Receive WhatsApp Message",
|
||||
"summary": "Message webhook",
|
||||
"tags": [
|
||||
"WhatsApp"
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
|
||||
@@ -16,27 +16,21 @@
|
||||
"@trpc/server": "10.34.0",
|
||||
"@typebot.io/nextjs": "workspace:*",
|
||||
"@typebot.io/prisma": "workspace:*",
|
||||
"@udecode/plate-common": "^21.1.5",
|
||||
"ai": "2.1.32",
|
||||
"bot-engine": "workspace:*",
|
||||
"chrono-node": "2.6.6",
|
||||
"cors": "2.8.5",
|
||||
"date-fns": "^2.30.0",
|
||||
"eventsource-parser": "^1.0.0",
|
||||
"google-spreadsheet": "4.0.2",
|
||||
"got": "12.6.0",
|
||||
"libphonenumber-js": "1.10.37",
|
||||
"next": "13.4.3",
|
||||
"nextjs-cors": "2.1.2",
|
||||
"node-html-parser": "^6.1.5",
|
||||
"nodemailer": "6.9.3",
|
||||
"openai-edge": "1.2.2",
|
||||
"qs": "6.11.2",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"remark-slate": "^1.8.6",
|
||||
"stripe": "12.13.0",
|
||||
"trpc-openapi": "1.2.0"
|
||||
"trpc-openapi": "1.2.0",
|
||||
"@typebot.io/bot-engine": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@faire/mjml-react": "3.3.0",
|
||||
@@ -53,13 +47,11 @@
|
||||
"@types/papaparse": "5.3.7",
|
||||
"@types/qs": "6.9.7",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/sanitize-html": "2.9.0",
|
||||
"dotenv-cli": "^7.2.1",
|
||||
"eslint": "8.44.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"google-auth-library": "8.9.0",
|
||||
"next-runtime-env": "^1.6.2",
|
||||
"node-fetch": "3.3.1",
|
||||
"papaparse": "5.4.1",
|
||||
"superjson": "1.12.4",
|
||||
"typescript": "5.1.6",
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { ChoiceInputBlock, Variable } from '@typebot.io/schemas'
|
||||
import { executeCondition } from '../../logic/condition/executeCondition'
|
||||
|
||||
export const filterChoiceItems =
|
||||
(variables: Variable[]) =>
|
||||
(block: ChoiceInputBlock): ChoiceInputBlock => {
|
||||
const filteredItems = block.items.filter((item) => {
|
||||
if (item.displayCondition?.isEnabled && item.displayCondition?.condition)
|
||||
return executeCondition(variables)(item.displayCondition.condition)
|
||||
|
||||
return true
|
||||
})
|
||||
return {
|
||||
...block,
|
||||
items: filteredItems,
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import {
|
||||
SessionState,
|
||||
VariableWithValue,
|
||||
ChoiceInputBlock,
|
||||
ItemType,
|
||||
} from '@typebot.io/schemas'
|
||||
import { isDefined } from '@typebot.io/lib'
|
||||
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
||||
import { transformStringVariablesToList } from '@/features/variables/transformVariablesToList'
|
||||
import { updateVariables } from '@/features/variables/updateVariables'
|
||||
import { filterChoiceItems } from './filterChoiceItems'
|
||||
|
||||
export const injectVariableValuesInButtonsInputBlock =
|
||||
(state: SessionState) =>
|
||||
(block: ChoiceInputBlock): ChoiceInputBlock => {
|
||||
const { variables } = state.typebotsQueue[0].typebot
|
||||
if (block.options.dynamicVariableId) {
|
||||
const variable = variables.find(
|
||||
(variable) =>
|
||||
variable.id === block.options.dynamicVariableId &&
|
||||
isDefined(variable.value)
|
||||
) as VariableWithValue | undefined
|
||||
if (!variable) return block
|
||||
const value = getVariableValue(state)(variable)
|
||||
return {
|
||||
...block,
|
||||
items: value.filter(isDefined).map((item, idx) => ({
|
||||
id: idx.toString(),
|
||||
type: ItemType.BUTTON,
|
||||
blockId: block.id,
|
||||
content: item,
|
||||
})),
|
||||
}
|
||||
}
|
||||
return deepParseVariables(variables)(filterChoiceItems(variables)(block))
|
||||
}
|
||||
|
||||
const getVariableValue =
|
||||
(state: SessionState) =>
|
||||
(variable: VariableWithValue): (string | null)[] => {
|
||||
if (!Array.isArray(variable.value)) {
|
||||
const { variables } = state.typebotsQueue[0].typebot
|
||||
const [transformedVariable] = transformStringVariablesToList(variables)([
|
||||
variable.id,
|
||||
])
|
||||
updateVariables(state)([transformedVariable])
|
||||
return transformedVariable.value as string[]
|
||||
}
|
||||
return variable.value
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
import { ChoiceInputBlock, SessionState } from '@typebot.io/schemas'
|
||||
import { injectVariableValuesInButtonsInputBlock } from './injectVariableValuesInButtonsInputBlock'
|
||||
import { ParsedReply } from '@/features/chat/types'
|
||||
|
||||
export const parseButtonsReply =
|
||||
(state: SessionState) =>
|
||||
(inputValue: string, block: ChoiceInputBlock): ParsedReply => {
|
||||
const displayedItems =
|
||||
injectVariableValuesInButtonsInputBlock(state)(block).items
|
||||
if (block.options.isMultipleChoice) {
|
||||
const longestItemsFirst = [...displayedItems].sort(
|
||||
(a, b) => (b.content?.length ?? 0) - (a.content?.length ?? 0)
|
||||
)
|
||||
const matchedItemsByContent = longestItemsFirst.reduce<{
|
||||
strippedInput: string
|
||||
matchedItemIds: string[]
|
||||
}>(
|
||||
(acc, item) => {
|
||||
if (
|
||||
item.content &&
|
||||
acc.strippedInput.toLowerCase().includes(item.content.toLowerCase())
|
||||
)
|
||||
return {
|
||||
strippedInput: acc.strippedInput.replace(item.content ?? '', ''),
|
||||
matchedItemIds: [...acc.matchedItemIds, item.id],
|
||||
}
|
||||
return acc
|
||||
},
|
||||
{
|
||||
strippedInput: inputValue.trim(),
|
||||
matchedItemIds: [],
|
||||
}
|
||||
)
|
||||
const remainingItems = displayedItems.filter(
|
||||
(item) => !matchedItemsByContent.matchedItemIds.includes(item.id)
|
||||
)
|
||||
const matchedItemsByIndex = remainingItems.reduce<{
|
||||
strippedInput: string
|
||||
matchedItemIds: string[]
|
||||
}>(
|
||||
(acc, item, idx) => {
|
||||
if (acc.strippedInput.includes(`${idx + 1}`))
|
||||
return {
|
||||
strippedInput: acc.strippedInput.replace(`${idx + 1}`, ''),
|
||||
matchedItemIds: [...acc.matchedItemIds, item.id],
|
||||
}
|
||||
return acc
|
||||
},
|
||||
{
|
||||
strippedInput: matchedItemsByContent.strippedInput,
|
||||
matchedItemIds: [],
|
||||
}
|
||||
)
|
||||
const matchedItems = displayedItems.filter((item) =>
|
||||
[
|
||||
...matchedItemsByContent.matchedItemIds,
|
||||
...matchedItemsByIndex.matchedItemIds,
|
||||
].includes(item.id)
|
||||
)
|
||||
if (matchedItems.length === 0) return { status: 'fail' }
|
||||
return {
|
||||
status: 'success',
|
||||
reply: matchedItems.map((item) => item.content).join(', '),
|
||||
}
|
||||
}
|
||||
if (state.whatsApp) {
|
||||
const matchedItem = displayedItems.find((item) => item.id === inputValue)
|
||||
if (!matchedItem) return { status: 'fail' }
|
||||
return {
|
||||
status: 'success',
|
||||
reply: matchedItem.content ?? '',
|
||||
}
|
||||
}
|
||||
const longestItemsFirst = [...displayedItems].sort(
|
||||
(a, b) => (b.content?.length ?? 0) - (a.content?.length ?? 0)
|
||||
)
|
||||
const matchedItem = longestItemsFirst.find(
|
||||
(item) =>
|
||||
item.content &&
|
||||
inputValue.toLowerCase().trim() === item.content.toLowerCase().trim()
|
||||
)
|
||||
if (!matchedItem) return { status: 'fail' }
|
||||
return {
|
||||
status: 'success',
|
||||
reply: matchedItem.content ?? '',
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import { getPrefilledInputValue } from '@/features/chat/helpers/getPrefilledValue'
|
||||
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import {
|
||||
DateInputBlock,
|
||||
DateInputOptions,
|
||||
SessionState,
|
||||
Variable,
|
||||
} from '@typebot.io/schemas'
|
||||
|
||||
export const parseDateInput =
|
||||
(state: SessionState) => (block: DateInputBlock) => {
|
||||
return {
|
||||
...block,
|
||||
options: {
|
||||
...deepParseVariables(state.typebotsQueue[0].typebot.variables)(
|
||||
block.options
|
||||
),
|
||||
min: parseDateLimit(
|
||||
block.options.min,
|
||||
block.options.hasTime,
|
||||
state.typebotsQueue[0].typebot.variables
|
||||
),
|
||||
max: parseDateLimit(
|
||||
block.options.max,
|
||||
block.options.hasTime,
|
||||
state.typebotsQueue[0].typebot.variables
|
||||
),
|
||||
},
|
||||
prefilledValue: getPrefilledInputValue(
|
||||
state.typebotsQueue[0].typebot.variables
|
||||
)(block),
|
||||
}
|
||||
}
|
||||
|
||||
const parseDateLimit = (
|
||||
limit: DateInputOptions['min'] | DateInputOptions['max'],
|
||||
hasTime: DateInputOptions['hasTime'],
|
||||
variables: Variable[]
|
||||
) => {
|
||||
if (!limit) return
|
||||
const parsedLimit = parseVariables(variables)(limit)
|
||||
const dateIsoNoSecondsRegex = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d/
|
||||
const matchDateTime = parsedLimit.match(dateIsoNoSecondsRegex)
|
||||
if (matchDateTime)
|
||||
return hasTime ? matchDateTime[0] : matchDateTime[0].slice(0, 10)
|
||||
return parsedLimit
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import { ParsedReply } from '@/features/chat/types'
|
||||
import { DateInputBlock } from '@typebot.io/schemas'
|
||||
import { parse as chronoParse } from 'chrono-node'
|
||||
import { format } from 'date-fns'
|
||||
|
||||
export const parseDateReply = (
|
||||
reply: string,
|
||||
block: DateInputBlock
|
||||
): ParsedReply => {
|
||||
const parsedDate = chronoParse(reply)
|
||||
if (parsedDate.length === 0) return { status: 'fail' }
|
||||
const formatString =
|
||||
block.options.format ??
|
||||
(block.options.hasTime ? 'dd/MM/yyyy HH:mm' : 'dd/MM/yyyy')
|
||||
|
||||
const detectedStartDate = parseDateWithNeutralTimezone(
|
||||
parsedDate[0].start.date()
|
||||
)
|
||||
const startDate = format(detectedStartDate, formatString)
|
||||
|
||||
const detectedEndDate = parsedDate[0].end?.date()
|
||||
? parseDateWithNeutralTimezone(parsedDate[0].end?.date())
|
||||
: undefined
|
||||
const endDate = detectedEndDate
|
||||
? format(detectedEndDate, formatString)
|
||||
: undefined
|
||||
|
||||
if (block.options.isRange && !endDate) return { status: 'fail' }
|
||||
|
||||
if (
|
||||
block.options.max &&
|
||||
(detectedStartDate > new Date(block.options.max) ||
|
||||
(detectedEndDate && detectedEndDate > new Date(block.options.max)))
|
||||
)
|
||||
return { status: 'fail' }
|
||||
|
||||
if (
|
||||
block.options.min &&
|
||||
(detectedStartDate < new Date(block.options.min) ||
|
||||
(detectedEndDate && detectedEndDate < new Date(block.options.min)))
|
||||
)
|
||||
return { status: 'fail' }
|
||||
|
||||
return {
|
||||
status: 'success',
|
||||
reply: block.options.isRange ? `${startDate} to ${endDate}` : startDate,
|
||||
}
|
||||
}
|
||||
|
||||
const parseDateWithNeutralTimezone = (date: Date) =>
|
||||
new Date(date.valueOf() + date.getTimezoneOffset() * 60 * 1000)
|
||||
@@ -1,4 +0,0 @@
|
||||
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,}))$/
|
||||
|
||||
export const validateEmail = (email: string) => emailRegex.test(email)
|
||||
@@ -1 +0,0 @@
|
||||
export const validateNumber = (inputValue: string) => !isNaN(Number(inputValue))
|
||||
@@ -1,124 +0,0 @@
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import {
|
||||
PaymentInputOptions,
|
||||
PaymentInputRuntimeOptions,
|
||||
SessionState,
|
||||
StripeCredentials,
|
||||
} from '@typebot.io/schemas'
|
||||
import Stripe from 'stripe'
|
||||
import { decrypt } from '@typebot.io/lib/api/encryption'
|
||||
|
||||
export const computePaymentInputRuntimeOptions =
|
||||
(state: SessionState) => (options: PaymentInputOptions) =>
|
||||
createStripePaymentIntent(state)(options)
|
||||
|
||||
const createStripePaymentIntent =
|
||||
(state: SessionState) =>
|
||||
async (options: PaymentInputOptions): Promise<PaymentInputRuntimeOptions> => {
|
||||
const {
|
||||
resultId,
|
||||
typebot: { variables },
|
||||
} = state.typebotsQueue[0]
|
||||
const isPreview = !resultId
|
||||
if (!options.credentialsId)
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: 'Missing credentialsId',
|
||||
})
|
||||
const stripeKeys = await getStripeInfo(options.credentialsId)
|
||||
if (!stripeKeys)
|
||||
throw new TRPCError({
|
||||
code: 'NOT_FOUND',
|
||||
message: 'Credentials not found',
|
||||
})
|
||||
const stripe = new Stripe(
|
||||
isPreview && stripeKeys?.test?.secretKey
|
||||
? stripeKeys.test.secretKey
|
||||
: stripeKeys.live.secretKey,
|
||||
{ apiVersion: '2022-11-15' }
|
||||
)
|
||||
const amount = Math.round(
|
||||
Number(parseVariables(variables)(options.amount)) *
|
||||
(isZeroDecimalCurrency(options.currency) ? 1 : 100)
|
||||
)
|
||||
if (isNaN(amount))
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message:
|
||||
'Could not parse amount, make sure your block is configured correctly',
|
||||
})
|
||||
// Create a PaymentIntent with the order amount and currency
|
||||
const receiptEmail = parseVariables(variables)(
|
||||
options.additionalInformation?.email
|
||||
)
|
||||
const paymentIntent = await stripe.paymentIntents.create({
|
||||
amount,
|
||||
currency: options.currency,
|
||||
receipt_email: receiptEmail === '' ? undefined : receiptEmail,
|
||||
description: options.additionalInformation?.description,
|
||||
automatic_payment_methods: {
|
||||
enabled: true,
|
||||
},
|
||||
})
|
||||
|
||||
if (!paymentIntent.client_secret)
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: 'Could not create payment intent',
|
||||
})
|
||||
|
||||
const priceFormatter = new Intl.NumberFormat(
|
||||
options.currency === 'EUR' ? 'fr-FR' : undefined,
|
||||
{
|
||||
style: 'currency',
|
||||
currency: options.currency,
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
paymentIntentSecret: paymentIntent.client_secret,
|
||||
publicKey:
|
||||
isPreview && stripeKeys.test?.publicKey
|
||||
? stripeKeys.test.publicKey
|
||||
: stripeKeys.live.publicKey,
|
||||
amountLabel: priceFormatter.format(
|
||||
amount / (isZeroDecimalCurrency(options.currency) ? 1 : 100)
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
const getStripeInfo = async (
|
||||
credentialsId: string
|
||||
): Promise<StripeCredentials['data'] | undefined> => {
|
||||
const credentials = await prisma.credentials.findUnique({
|
||||
where: { id: credentialsId },
|
||||
})
|
||||
if (!credentials) return
|
||||
return (await decrypt(
|
||||
credentials.data,
|
||||
credentials.iv
|
||||
)) as StripeCredentials['data']
|
||||
}
|
||||
|
||||
// https://stripe.com/docs/currencies#zero-decimal
|
||||
const isZeroDecimalCurrency = (currency: string) =>
|
||||
[
|
||||
'BIF',
|
||||
'CLP',
|
||||
'DJF',
|
||||
'GNF',
|
||||
'JPY',
|
||||
'KMF',
|
||||
'KRW',
|
||||
'MGA',
|
||||
'PYG',
|
||||
'RWF',
|
||||
'UGX',
|
||||
'VND',
|
||||
'VUV',
|
||||
'XAF',
|
||||
'XOF',
|
||||
'XPF',
|
||||
].includes(currency)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user