From 5073be2439df88bcd4275b909ad7b20120efbfa7 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Fri, 15 Mar 2024 16:32:29 +0100 Subject: [PATCH] :recycle: Remove @typebot.io/schemas from @typebot.io/lib --- apps/builder/package.json | 7 +- apps/builder/playwright.config.ts | 47 ++++-- .../ImageUploadContent/UnsplashPicker.tsx | 8 +- .../src/features/account/account.spec.ts | 2 +- .../src/features/analytics/analytics.spec.ts | 4 +- .../features/analytics/api/getTotalAnswers.ts | 2 +- .../helpers/computeTotalUsersAtBlock.ts | 3 +- .../src/features/auth/api/customAdapter.ts | 2 +- .../billing/api/updateSubscription.ts | 2 +- .../src/features/billing/billing.spec.ts | 4 +- .../billing/components/ChangePlanForm.tsx | 2 +- .../billing/components/ChatsProTiersModal.tsx | 4 +- .../billing/components/ProPlanPricingCard.tsx | 4 +- .../components/StarterPlanPricingCard.tsx | 4 +- .../billing/components/UsageProgressBars.tsx | 2 +- .../blocks/bubbles/audio/audio.spec.ts | 6 +- .../blocks/bubbles/embed/embed.spec.ts | 4 +- .../blocks/bubbles/image/image.spec.ts | 6 +- .../bubbles/textBubble/textBubble.spec.ts | 5 +- .../video/components/VideoUploadContent.tsx | 2 +- .../blocks/bubbles/video/video.spec.ts | 4 +- .../blocks/inputs/buttons/buttons.spec.ts | 26 +-- .../features/blocks/inputs/date/date.spec.ts | 9 +- .../inputs/emailInput/emailInput.spec.ts | 5 +- .../inputs/fileUpload/fileUpload.spec.ts | 7 +- .../blocks/inputs/number/number.spec.ts | 5 +- .../blocks/inputs/payment/payment.spec.ts | 4 +- .../blocks/inputs/phone/phone.spec.ts | 5 +- .../pictureChoice/pictureChoice.spec.ts | 4 +- .../blocks/inputs/rating/rating.spec.ts | 4 +- .../blocks/inputs/textInput/textInput.spec.ts | 5 +- .../features/blocks/inputs/url/url.spec.ts | 7 +- .../integrations/chatwoot/chatwoot.spec.ts | 4 +- .../googleAnalytics/googleAnalytics.spec.ts | 4 +- .../googleSheets/googleSheets.spec.ts | 11 +- .../blocks/integrations/openai/openai.spec.ts | 37 ----- .../blocks/integrations/pixel/pixel.spec.ts | 4 +- .../integrations/sendEmail/sendEmail.spec.ts | 4 +- .../webhook/api/getResultExample.ts | 12 +- .../webhook/api/listWebhookBlocks.ts | 3 +- .../webhook/api/subscribeWebhook.ts | 3 +- .../webhook/api/unsubscribeWebhook.ts | 3 +- .../integrations/webhook/webhook.spec.ts | 8 +- .../blocks/logic/abTest/abTest.spec.ts | 2 +- .../blocks/logic/condition/condition.spec.ts | 2 +- .../features/blocks/logic/jump/jump.spec.ts | 2 +- .../blocks/logic/redirect/redirect.spec.ts | 2 +- .../blocks/logic/script/script.spec.ts | 2 +- .../logic/setVariable/setVariable.spec.ts | 2 +- .../logic/typebotLink/typebotLink.spec.ts | 2 +- .../features/blocks/logic/wait/wait.spec.ts | 2 +- .../collaboration/collaboration.spec.ts | 6 +- .../credentials/api/createCredentials.ts | 2 +- .../customDomains/api/createCustomDomain.ts | 2 +- .../customDomains/customDomains.spec.ts | 8 +- .../dashboard/components/DashboardPage.tsx | 2 +- .../src/features/dashboard/dashboard.spec.ts | 4 +- .../src/features/editor/editor.spec.ts | 44 +---- .../editor/providers/typebotActions/blocks.ts | 3 +- .../editor/providers/typebotActions/edges.ts | 3 +- .../editor/providers/typebotActions/groups.ts | 3 +- .../editor/providers/typebotActions/items.ts | 3 +- .../src/features/folders/api/createFolder.ts | 2 +- .../graph/components/GraphElements.tsx | 2 +- .../graph/components/edges/DropOffEdge.tsx | 3 +- .../components/nodes/block/BlockNode.tsx | 6 +- .../src/features/publish/publish.spec.ts | 4 +- .../src/features/results/ResultsProvider.tsx | 4 +- .../src/features/results/api/deleteResults.ts | 2 +- .../results/components/ResultModal.tsx | 2 +- .../table/ExportAllResultsModal.tsx | 6 +- .../results/components/table/ResultsTable.tsx | 2 +- .../components/table/SelectionToolbar.tsx | 2 +- .../src/features/results/results.spec.ts | 2 +- .../src/features/settings/settings.spec.ts | 4 +- .../telemetry/api/trackClientEvents.ts | 2 +- .../helpers/trackAnalyticsPageView.ts | 2 +- apps/builder/src/features/theme/theme.spec.ts | 14 +- .../src/features/typebot/api/createTypebot.ts | 2 +- .../src/features/typebot/api/deleteTypebot.ts | 2 +- .../typebot/api/getPublishedTypebot.ts | 2 +- .../src/features/typebot/api/getTypebot.ts | 2 +- .../src/features/typebot/api/importTypebot.ts | 4 +- .../features/typebot/api/publishTypebot.ts | 2 +- .../src/features/typebot/api/updateTypebot.ts | 2 +- .../typebot/helpers/hasDefaultConnector.ts | 4 +- .../features/typebot/helpers/parseNewBlock.ts | 2 +- .../features/workspace/api/createWorkspace.ts | 2 +- .../workspace/components/MembersList.tsx | 2 +- .../src/features/workspace/workspaces.spec.ts | 10 +- .../src/pages/api/auth/[...nextauth].ts | 2 +- apps/builder/src/pages/api/stripe/webhook.ts | 4 +- apps/builder/src/pages/api/users/[userId].ts | 2 +- .../workspaces/[workspaceId]/invitations.ts | 2 +- .../typebots/integrations/googleSheets.json | 4 +- .../integrations/googleSheetsGet.json | 4 +- apps/builder/src/test/global.setup.ts | 6 + .../builder/src/test/utils/databaseActions.ts | 2 +- .../PricingPage/ChatsProTiersModal.tsx | 4 +- .../components/PricingPage/FreePlanCard.tsx | 2 +- .../PricingPage/PlanComparisonTables.tsx | 8 +- .../PricingPage/PricingCard/index.tsx | 2 +- .../components/PricingPage/ProPlanCard.tsx | 2 +- .../PricingPage/StarterPlanCard.tsx | 2 +- apps/landing-page/package.json | 3 +- apps/viewer/.prettierignore | 1 + apps/viewer/package.json | 8 +- apps/viewer/playwright.config.ts | 45 +++-- .../api/integrations/openai/streamer/route.ts | 2 +- .../fileUpload/api/generateUploadUrl.ts | 2 +- .../blocks/[blockId]/executeWebhook.ts | 13 +- .../[typebotId]/integrations/email.tsx | 2 +- .../api/typebots/[typebotId]/webhookBlocks.ts | 2 +- .../api/typebots/[typebotId]/webhookSteps.ts | 3 +- apps/viewer/src/test/chat.spec.ts | 2 +- apps/viewer/src/test/chatwoot.spec.ts | 4 +- apps/viewer/src/test/fileUpload.spec.ts | 2 +- apps/viewer/src/test/global.setup.ts | 6 + apps/viewer/src/test/results.spec.ts | 2 +- apps/viewer/src/test/sendEmail.spec.ts | 2 +- apps/viewer/src/test/settings.spec.ts | 4 +- apps/viewer/src/test/typebotLink.spec.ts | 2 +- apps/viewer/src/test/utils/databaseActions.ts | 2 +- apps/viewer/src/test/variables.spec.ts | 2 +- apps/viewer/src/test/webhook.spec.ts | 2 +- package.json | 2 +- packages/{lib => }/billing/constants.ts | 0 packages/{lib => }/billing/formatPrice.ts | 0 packages/{lib => }/billing/getChatsLimit.ts | 0 packages/{lib => }/billing/getSeatsLimit.ts | 0 .../billing/guessIfUserIsEuropean.ts | 0 packages/billing/package.json | 20 +++ packages/billing/tsconfig.json | 8 + .../sendEmail/executeSendEmailBlock.tsx | 2 +- .../webhook/executeWebhookBlock.ts | 2 +- .../integrations/webhook/parseSampleResult.ts | 19 ++- .../zemanticAi/executeZemanticAiBlock.ts | 2 +- packages/bot-engine/computeCurrentProgress.ts | 8 +- packages/bot-engine/continueBotFlow.ts | 5 +- packages/bot-engine/executeGroup.ts | 4 +- packages/bot-engine/package.json | 3 +- packages/bot-engine/parseBubbleBlock.ts | 2 +- packages/bot-engine/startSession.ts | 3 +- .../ChatGroup/ChatBlock/InputChatBlock.tsx | 2 +- .../src/components/ChatGroup/ChatGroup.tsx | 7 +- .../src/components/ConversationContainer.tsx | 3 +- .../deprecated/bot-engine/src/utils/chat.ts | 2 +- .../deprecated/bot-engine/src/utils/inputs.ts | 3 +- packages/lib/getBlockById.ts | 24 --- packages/lib/google.ts | 13 +- packages/lib/mockedUser.ts | 3 +- packages/lib/package.json | 1 - packages/lib/playwright/baseConfig.ts | 32 ---- packages/lib/playwright/globalSetup.ts | 11 -- packages/lib/utils.ts | 105 ------------ .../migrations/migratePublicTypebot.ts | 0 .../{lib => }/migrations/migrateTypebot.ts | 0 .../migrations/migrateTypebotFromV3ToV4.ts | 5 +- .../migrations/migrateTypebotFromV5ToV6.ts | 4 +- packages/migrations/package.json | 17 ++ packages/migrations/tsconfig.json | 8 + .../{lib => }/playwright/databaseActions.ts | 2 +- .../{lib => }/playwright/databaseHelpers.ts | 5 +- .../{lib => }/playwright/databaseSetup.ts | 2 +- packages/playwright/globalSetup.ts | 6 + packages/playwright/package.json | 19 +++ packages/{lib => }/playwright/testHelpers.ts | 0 packages/playwright/tsconfig.json | 8 + .../api/helpers => results}/archiveResults.ts | 2 +- .../results/convertResultsToTableData.ts | 2 +- packages/results/package.json | 17 ++ packages/{lib => }/results/parseAnswers.ts | 2 +- .../{lib => }/results/parseColumnsOrder.ts | 0 .../{lib => }/results/parseResultHeader.ts | 3 +- packages/results/tsconfig.json | 8 + .../features/blocks/bubbles/video/helpers.ts} | 16 +- packages/schemas/helpers.ts | 128 ++++++++++++++ packages/scripts/checkAndReportChatsUsage.ts | 4 +- packages/scripts/cleanDatabase.ts | 2 +- packages/scripts/createChatsPrices.ts | 5 +- packages/scripts/exportResults.ts | 6 +- packages/scripts/package.json | 5 +- packages/telemetry/package.json | 18 ++ packages/{lib => }/telemetry/trackEvents.ts | 0 packages/telemetry/tsconfig.json | 8 + pnpm-lock.yaml | 156 +++++++++++++++++- 186 files changed, 809 insertions(+), 581 deletions(-) delete mode 100644 apps/builder/src/features/blocks/integrations/openai/openai.spec.ts create mode 100644 apps/builder/src/test/global.setup.ts create mode 100644 apps/viewer/.prettierignore create mode 100644 apps/viewer/src/test/global.setup.ts rename packages/{lib => }/billing/constants.ts (100%) rename packages/{lib => }/billing/formatPrice.ts (100%) rename packages/{lib => }/billing/getChatsLimit.ts (100%) rename packages/{lib => }/billing/getSeatsLimit.ts (100%) rename packages/{lib => }/billing/guessIfUserIsEuropean.ts (100%) create mode 100644 packages/billing/package.json create mode 100644 packages/billing/tsconfig.json delete mode 100644 packages/lib/getBlockById.ts delete mode 100644 packages/lib/playwright/baseConfig.ts delete mode 100644 packages/lib/playwright/globalSetup.ts rename packages/{lib => }/migrations/migratePublicTypebot.ts (100%) rename packages/{lib => }/migrations/migrateTypebot.ts (100%) rename packages/{lib => }/migrations/migrateTypebotFromV3ToV4.ts (92%) rename packages/{lib => }/migrations/migrateTypebotFromV5ToV6.ts (97%) create mode 100644 packages/migrations/package.json create mode 100644 packages/migrations/tsconfig.json rename packages/{lib => }/playwright/databaseActions.ts (99%) rename packages/{lib => }/playwright/databaseHelpers.ts (96%) rename packages/{lib => }/playwright/databaseSetup.ts (98%) create mode 100644 packages/playwright/globalSetup.ts create mode 100644 packages/playwright/package.json rename packages/{lib => }/playwright/testHelpers.ts (100%) create mode 100644 packages/playwright/tsconfig.json rename packages/{lib/api/helpers => results}/archiveResults.ts (96%) rename packages/{lib => }/results/convertResultsToTableData.ts (98%) create mode 100644 packages/results/package.json rename packages/{lib => }/results/parseAnswers.ts (95%) rename packages/{lib => }/results/parseColumnsOrder.ts (100%) rename packages/{lib => }/results/parseResultHeader.ts (98%) create mode 100644 packages/results/tsconfig.json rename packages/{lib/parseVideoUrl.ts => schemas/features/blocks/bubbles/video/helpers.ts} (94%) create mode 100644 packages/schemas/helpers.ts create mode 100644 packages/telemetry/package.json rename packages/{lib => }/telemetry/trackEvents.ts (100%) create mode 100644 packages/telemetry/tsconfig.json diff --git a/apps/builder/package.json b/apps/builder/package.json index 5b147f976..2dd57074f 100644 --- a/apps/builder/package.json +++ b/apps/builder/package.json @@ -122,6 +122,11 @@ "next-runtime-env": "1.6.2", "superjson": "1.12.4", "typescript": "5.3.2", - "zod": "3.22.4" + "zod": "3.22.4", + "@typebot.io/playwright": "workspace:*", + "@typebot.io/billing": "workspace:*", + "@typebot.io/results": "workspace:*", + "@typebot.io/migrations": "workspace:*", + "@typebot.io/telemetry": "workspace:*" } } diff --git a/apps/builder/playwright.config.ts b/apps/builder/playwright.config.ts index 9e00557af..8ef248c58 100644 --- a/apps/builder/playwright.config.ts +++ b/apps/builder/playwright.config.ts @@ -1,20 +1,45 @@ -import { PlaywrightTestConfig } from '@playwright/test' -import path from 'path' -import { playwrightBaseConfig } from '@typebot.io/lib/playwright/baseConfig' +import { defineConfig, devices } from '@playwright/test' -const config: PlaywrightTestConfig = { - ...playwrightBaseConfig, +export default defineConfig({ + timeout: process.env.CI ? 50 * 1000 : 40 * 1000, + expect: { + timeout: process.env.CI ? 10 * 1000 : 5 * 1000, + }, + forbidOnly: !!process.env.CI, + workers: process.env.CI ? 1 : 3, + retries: process.env.CI ? 2 : 0, + reporter: [ + [process.env.CI ? 'github' : 'list'], + ['html', { outputFolder: 'src/test/reporters' }], + ], + maxFailures: process.env.CI ? 10 : undefined, webServer: process.env.CI ? { - ...(playwrightBaseConfig.webServer as { command: string }), + command: 'pnpm run start', + timeout: 60_000, + reuseExistingServer: true, port: 3000, } : undefined, + outputDir: './src/test/results', use: { - ...playwrightBaseConfig.use, + trace: 'on-first-retry', + locale: 'en-US', baseURL: process.env.NEXTAUTH_URL, - storageState: path.join(__dirname, 'src/test/storageState.json'), + storageState: './src/test/storageState.json', }, -} - -export default config + projects: [ + { + name: 'setup db', + testMatch: /global\.setup\.ts/, + }, + { + name: 'chromium', + use: { + ...devices['Desktop Chrome'], + viewport: { width: 1400, height: 1000 }, + }, + dependencies: ['setup db'], + }, + ], +}) diff --git a/apps/builder/src/components/ImageUploadContent/UnsplashPicker.tsx b/apps/builder/src/components/ImageUploadContent/UnsplashPicker.tsx index debfff906..219db0101 100644 --- a/apps/builder/src/components/ImageUploadContent/UnsplashPicker.tsx +++ b/apps/builder/src/components/ImageUploadContent/UnsplashPicker.tsx @@ -17,7 +17,7 @@ import { import { isDefined } from '@typebot.io/lib' import { useCallback, useEffect, useRef, useState } from 'react' import { createApi } from 'unsplash-js' -import { Basic as UnsplashImage } from 'unsplash-js/dist/methods/photos/types' +import { Basic as UnsplashImageType } from 'unsplash-js/dist/methods/photos/types' import { TextInput } from '../inputs' import { UnsplashLogo } from '../logos/UnsplashLogo' import { TextLink } from '../TextLink' @@ -35,7 +35,7 @@ type Props = { export const UnsplashPicker = ({ imageSize, onImageSelect }: Props) => { const unsplashLogoFillColor = useColorModeValue('black', 'white') const [isFetching, setIsFetching] = useState(false) - const [images, setImages] = useState([]) + const [images, setImages] = useState([]) const [error, setError] = useState(null) const [searchQuery, setSearchQuery] = useState('') const scrollContainer = useRef(null) @@ -113,7 +113,7 @@ export const UnsplashPicker = ({ imageSize, onImageSelect }: Props) => { setIsFetching(false) } - const selectImage = (image: UnsplashImage) => { + const selectImage = (image: UnsplashImageType) => { const url = image.urls[imageSize] api.photos.trackDownload({ downloadLocation: image.links.download_location, @@ -185,7 +185,7 @@ export const UnsplashPicker = ({ imageSize, onImageSelect }: Props) => { } type UnsplashImageProps = { - image: UnsplashImage + image: UnsplashImageType onClick: () => void } diff --git a/apps/builder/src/features/account/account.spec.ts b/apps/builder/src/features/account/account.spec.ts index 588e81e0f..18adb985d 100644 --- a/apps/builder/src/features/account/account.spec.ts +++ b/apps/builder/src/features/account/account.spec.ts @@ -1,7 +1,7 @@ import { getTestAsset } from '@/test/utils/playwright' import test, { expect } from '@playwright/test' import { env } from '@typebot.io/env' -import { userId } from '@typebot.io/lib/playwright/databaseSetup' +import { userId } from '@typebot.io/playwright/databaseSetup' test.describe.configure({ mode: 'parallel' }) diff --git a/apps/builder/src/features/analytics/analytics.spec.ts b/apps/builder/src/features/analytics/analytics.spec.ts index cf891042d..7352dfe61 100644 --- a/apps/builder/src/features/analytics/analytics.spec.ts +++ b/apps/builder/src/features/analytics/analytics.spec.ts @@ -4,8 +4,8 @@ import { createId } from '@paralleldrive/cuid2' import { importTypebotInDatabase, injectFakeResults, -} from '@typebot.io/lib/playwright/databaseActions' -import { starterWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup' +} from '@typebot.io/playwright/databaseActions' +import { starterWorkspaceId } from '@typebot.io/playwright/databaseSetup' test('analytics are not available for non-pro workspaces', async ({ page }) => { const typebotId = createId() diff --git a/apps/builder/src/features/analytics/api/getTotalAnswers.ts b/apps/builder/src/features/analytics/api/getTotalAnswers.ts index 50dc0fe3d..99da05ee2 100644 --- a/apps/builder/src/features/analytics/api/getTotalAnswers.ts +++ b/apps/builder/src/features/analytics/api/getTotalAnswers.ts @@ -5,7 +5,7 @@ import { z } from 'zod' import { canReadTypebots } from '@/helpers/databaseRules' import { totalAnswersSchema } from '@typebot.io/schemas/features/analytics' import { parseGroups } from '@typebot.io/schemas' -import { isInputBlock } from '@typebot.io/lib' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { defaultTimeFilter, timeFilterValues } from '../constants' import { parseFromDateFromTimeFilter, diff --git a/apps/builder/src/features/analytics/helpers/computeTotalUsersAtBlock.ts b/apps/builder/src/features/analytics/helpers/computeTotalUsersAtBlock.ts index e2c944c5f..65304b6b2 100644 --- a/apps/builder/src/features/analytics/helpers/computeTotalUsersAtBlock.ts +++ b/apps/builder/src/features/analytics/helpers/computeTotalUsersAtBlock.ts @@ -1,5 +1,6 @@ -import { isInputBlock, isNotDefined } from '@typebot.io/lib' +import { isNotDefined } from '@typebot.io/lib' import { PublicTypebotV6 } from '@typebot.io/schemas' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { TotalAnswers, TotalVisitedEdges, diff --git a/apps/builder/src/features/auth/api/customAdapter.ts b/apps/builder/src/features/auth/api/customAdapter.ts index c07367b21..891de5be3 100644 --- a/apps/builder/src/features/auth/api/customAdapter.ts +++ b/apps/builder/src/features/auth/api/customAdapter.ts @@ -14,7 +14,7 @@ import { getNewUserInvitations } from '@/features/auth/helpers/getNewUserInvitat import { joinWorkspaces } from '@/features/auth/helpers/joinWorkspaces' import { parseWorkspaceDefaultPlan } from '@/features/workspace/helpers/parseWorkspaceDefaultPlan' import { env } from '@typebot.io/env' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' export function customAdapter(p: PrismaClient): Adapter { return { diff --git a/apps/builder/src/features/billing/api/updateSubscription.ts b/apps/builder/src/features/billing/api/updateSubscription.ts index ed92f3a08..30948f38f 100644 --- a/apps/builder/src/features/billing/api/updateSubscription.ts +++ b/apps/builder/src/features/billing/api/updateSubscription.ts @@ -8,7 +8,7 @@ import { z } from 'zod' import { createCheckoutSessionUrl } from './createCheckoutSession' import { isAdminWriteWorkspaceForbidden } from '@/features/workspace/helpers/isAdminWriteWorkspaceForbidden' import { env } from '@typebot.io/env' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' export const updateSubscription = authenticatedProcedure .meta({ diff --git a/apps/builder/src/features/billing/billing.spec.ts b/apps/builder/src/features/billing/billing.spec.ts index a703f3f53..0391eeb69 100644 --- a/apps/builder/src/features/billing/billing.spec.ts +++ b/apps/builder/src/features/billing/billing.spec.ts @@ -11,7 +11,7 @@ import { createWorkspaces, deleteWorkspaces, injectFakeResults, -} from '@typebot.io/lib/playwright/databaseActions' +} from '@typebot.io/playwright/databaseActions' import { env } from '@typebot.io/env' const usageWorkspaceId = createId() @@ -148,7 +148,7 @@ test('plan changes should work', async ({ page }) => { await expect(page.locator('text="$89"')).toBeVisible() await page.click('button >> text=Upgrade') await expect( - page.locator('text="Workspace PRO plan successfully updated 🎉" >> nth=0') + page.locator('text="Workspace PRO plan successfully updated" >> nth=0') ).toBeVisible() // Go to customer portal diff --git a/apps/builder/src/features/billing/components/ChangePlanForm.tsx b/apps/builder/src/features/billing/components/ChangePlanForm.tsx index dc142dc56..4571b8807 100644 --- a/apps/builder/src/features/billing/components/ChangePlanForm.tsx +++ b/apps/builder/src/features/billing/components/ChangePlanForm.tsx @@ -11,7 +11,7 @@ import { StarterPlanPricingCard } from './StarterPlanPricingCard' import { ProPlanPricingCard } from './ProPlanPricingCard' import { useTranslate } from '@tolgee/react' import { StripeClimateLogo } from './StripeClimateLogo' -import { guessIfUserIsEuropean } from '@typebot.io/lib/billing/guessIfUserIsEuropean' +import { guessIfUserIsEuropean } from '@typebot.io/billing/guessIfUserIsEuropean' import { WorkspaceInApp } from '@/features/workspace/WorkspaceProvider' type Props = { diff --git a/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx b/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx index 211678720..0d31c3d30 100644 --- a/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx +++ b/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx @@ -17,8 +17,8 @@ import { Tr, } from '@chakra-ui/react' import { useTranslate } from '@tolgee/react' -import { proChatTiers } from '@typebot.io/lib/billing/constants' -import { formatPrice } from '@typebot.io/lib/billing/formatPrice' +import { proChatTiers } from '@typebot.io/billing/constants' +import { formatPrice } from '@typebot.io/billing/formatPrice' type Props = { isOpen: boolean diff --git a/apps/builder/src/features/billing/components/ProPlanPricingCard.tsx b/apps/builder/src/features/billing/components/ProPlanPricingCard.tsx index a14dd9537..654a5b0a9 100644 --- a/apps/builder/src/features/billing/components/ProPlanPricingCard.tsx +++ b/apps/builder/src/features/billing/components/ProPlanPricingCard.tsx @@ -14,9 +14,9 @@ import { import { Plan } from '@typebot.io/prisma' import { FeaturesList } from './FeaturesList' import { MoreInfoTooltip } from '@/components/MoreInfoTooltip' -import { formatPrice } from '@typebot.io/lib/billing/formatPrice' +import { formatPrice } from '@typebot.io/billing/formatPrice' import { ChatsProTiersModal } from './ChatsProTiersModal' -import { prices } from '@typebot.io/lib/billing/constants' +import { prices } from '@typebot.io/billing/constants' import { T, useTranslate } from '@tolgee/react' type Props = { diff --git a/apps/builder/src/features/billing/components/StarterPlanPricingCard.tsx b/apps/builder/src/features/billing/components/StarterPlanPricingCard.tsx index 795b9be96..7e0024c7a 100644 --- a/apps/builder/src/features/billing/components/StarterPlanPricingCard.tsx +++ b/apps/builder/src/features/billing/components/StarterPlanPricingCard.tsx @@ -10,8 +10,8 @@ import { import { Plan } from '@typebot.io/prisma' import { FeaturesList } from './FeaturesList' import { MoreInfoTooltip } from '@/components/MoreInfoTooltip' -import { formatPrice } from '@typebot.io/lib/billing/formatPrice' -import { prices } from '@typebot.io/lib/billing/constants' +import { formatPrice } from '@typebot.io/billing/formatPrice' +import { prices } from '@typebot.io/billing/constants' import { T, useTranslate } from '@tolgee/react' type Props = { diff --git a/apps/builder/src/features/billing/components/UsageProgressBars.tsx b/apps/builder/src/features/billing/components/UsageProgressBars.tsx index f0485ed80..bff66ba38 100644 --- a/apps/builder/src/features/billing/components/UsageProgressBars.tsx +++ b/apps/builder/src/features/billing/components/UsageProgressBars.tsx @@ -12,7 +12,7 @@ import { AlertIcon } from '@/components/icons' import { WorkspaceInApp } from '@/features/workspace/WorkspaceProvider' import { parseNumberWithCommas } from '@typebot.io/lib' import { defaultQueryOptions, trpc } from '@/lib/trpc' -import { getChatsLimit } from '@typebot.io/lib/billing/getChatsLimit' +import { getChatsLimit } from '@typebot.io/billing/getChatsLimit' import { useTranslate } from '@tolgee/react' type Props = { diff --git a/apps/builder/src/features/blocks/bubbles/audio/audio.spec.ts b/apps/builder/src/features/blocks/bubbles/audio/audio.spec.ts index c410b5c52..1eb59c256 100644 --- a/apps/builder/src/features/blocks/bubbles/audio/audio.spec.ts +++ b/apps/builder/src/features/blocks/bubbles/audio/audio.spec.ts @@ -1,9 +1,9 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' -import { proWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup' +import { proWorkspaceId } from '@typebot.io/playwright/databaseSetup' import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants' const audioSampleUrl = diff --git a/apps/builder/src/features/blocks/bubbles/embed/embed.spec.ts b/apps/builder/src/features/blocks/bubbles/embed/embed.spec.ts index feadb36f4..008b43dcf 100644 --- a/apps/builder/src/features/blocks/bubbles/embed/embed.spec.ts +++ b/apps/builder/src/features/blocks/bubbles/embed/embed.spec.ts @@ -1,7 +1,7 @@ import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants' const pdfSrc = 'https://www.orimi.com/pdf-test.pdf' diff --git a/apps/builder/src/features/blocks/bubbles/image/image.spec.ts b/apps/builder/src/features/blocks/bubbles/image/image.spec.ts index 8d9732250..1e84c4354 100644 --- a/apps/builder/src/features/blocks/bubbles/image/image.spec.ts +++ b/apps/builder/src/features/blocks/bubbles/image/image.spec.ts @@ -1,9 +1,9 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' -import { proWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup' +import { proWorkspaceId } from '@typebot.io/playwright/databaseSetup' import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants' const unsplashImageSrc = diff --git a/apps/builder/src/features/blocks/bubbles/textBubble/textBubble.spec.ts b/apps/builder/src/features/blocks/bubbles/textBubble/textBubble.spec.ts index 87e158eff..458ce4f8c 100644 --- a/apps/builder/src/features/blocks/bubbles/textBubble/textBubble.spec.ts +++ b/apps/builder/src/features/blocks/bubbles/textBubble/textBubble.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants' @@ -18,6 +18,7 @@ test.describe('Text bubble block', () => { await page.goto(`/typebots/${typebotId}/edit`) + await page.getByTestId('block block2').locator('div').first().click() await page.click('[data-testid="bold-button"]') await page.type('div[role="textbox"]', 'Bold text') await page.press('div[role="textbox"]', 'Shift+Enter') diff --git a/apps/builder/src/features/blocks/bubbles/video/components/VideoUploadContent.tsx b/apps/builder/src/features/blocks/bubbles/video/components/VideoUploadContent.tsx index 2b64586ed..6d43172f1 100644 --- a/apps/builder/src/features/blocks/bubbles/video/components/VideoUploadContent.tsx +++ b/apps/builder/src/features/blocks/bubbles/video/components/VideoUploadContent.tsx @@ -2,7 +2,7 @@ import { Stack, Text } from '@chakra-ui/react' import { VideoBubbleBlock } from '@typebot.io/schemas' import { TextInput } from '@/components/inputs' import { useTranslate } from '@tolgee/react' -import { parseVideoUrl } from '@typebot.io/lib/parseVideoUrl' +import { parseVideoUrl } from '@typebot.io/schemas/features/blocks/bubbles/video/helpers' import { defaultVideoBubbleContent } from '@typebot.io/schemas/features/blocks/bubbles/video/constants' type Props = { diff --git a/apps/builder/src/features/blocks/bubbles/video/video.spec.ts b/apps/builder/src/features/blocks/bubbles/video/video.spec.ts index 489a15bfe..d7d0047e0 100644 --- a/apps/builder/src/features/blocks/bubbles/video/video.spec.ts +++ b/apps/builder/src/features/blocks/bubbles/video/video.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants' import { VideoBubbleContentType } from '@typebot.io/schemas/features/blocks/bubbles/video/constants' diff --git a/apps/builder/src/features/blocks/inputs/buttons/buttons.spec.ts b/apps/builder/src/features/blocks/inputs/buttons/buttons.spec.ts index e675aca51..9a0b20c45 100644 --- a/apps/builder/src/features/blocks/inputs/buttons/buttons.spec.ts +++ b/apps/builder/src/features/blocks/inputs/buttons/buttons.spec.ts @@ -2,8 +2,8 @@ import test, { expect } from '@playwright/test' import { createTypebots, importTypebotInDatabase, -} from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +} from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' @@ -26,13 +26,13 @@ test.describe.parallel('Buttons input block', () => { ]) await page.goto(`/typebots/${typebotId}/edit`) - await page.fill('input[value="Click to edit"]', 'Item 1') - await page.press('input[value="Item 1"]', 'Enter') - await page.fill('input[value="Click to edit"]', 'Item 2') - await page.press('input[value="Item 2"]', 'Enter') - await page.fill('input[value="Click to edit"]', 'Item 3') - await page.press('input[value="Item 3"]', 'Enter') - await page.press('input[value="Click to edit"]', 'Escape') + await page.getByRole('textbox').fill('Item 1') + await page.getByRole('textbox').press('Enter') + await page.getByRole('textbox').fill('Item 2') + await page.getByRole('textbox').press('Enter') + await page.getByRole('textbox').fill('Item 3') + await page.getByRole('textbox').press('Enter') + await page.getByRole('textbox').press('Escape') await page.click('text=Item 2', { button: 'right' }) await page.click('text=Delete') await expect(page.locator('text=Item 2')).toBeHidden() @@ -51,11 +51,11 @@ test.describe.parallel('Buttons input block', () => { await expect(page.getByText('Setvar1')).toBeVisible() await page.getByTestId('block block2').click({ position: { x: 0, y: 0 } }) - await page.locator('text=Item 1').hover() + await page.locator('span').filter({ hasText: 'Item 1' }).hover() await page.waitForTimeout(1000) await page.click('[aria-label="Add item"]') - await page.fill('input[value="Click to edit"]', 'Item 2') - await page.press('input[value="Item 2"]', 'Enter') + await page.getByTestId('block block2').getByRole('textbox').fill('Item 2') + await page.getByTestId('block block2').getByRole('textbox').press('Enter') await page.click('text=Test') @@ -82,7 +82,7 @@ test('Variable buttons should work', async ({ page }) => { await expect(page.getByTestId('guest-bubble')).toHaveText('Variable item') await expect(page.locator('text=Ok great!')).toBeVisible() await page.click('text="Item 1"') - await page.fill('input[value="Item 1"]', '{{Item 2}}') + await page.getByRole('textbox').fill('{{Item 2}}') await page.getByTestId('block block1').click({ position: { x: 0, y: 0 } }) await page.click('text=Multiple choice?') await page.click('text="Restart"') diff --git a/apps/builder/src/features/blocks/inputs/date/date.spec.ts b/apps/builder/src/features/blocks/inputs/date/date.spec.ts index e87f3d813..83291aad2 100644 --- a/apps/builder/src/features/blocks/inputs/date/date.spec.ts +++ b/apps/builder/src/features/blocks/inputs/date/date.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' @@ -23,12 +23,11 @@ test.describe('Date input block', () => { 'type', 'date' ) - await expect(page.getByRole('button', { name: 'Send' })).toBeDisabled() await page.locator('[data-testid="from-date"]').fill('2021-01-01') await page.getByRole('button', { name: 'Send' }).click() await expect(page.locator('text="01/01/2021"')).toBeVisible() - await page.click(`text=Pick a date...`) + await page.click(`text=Pick a date`) await page.click('text=Is range?') await page.click('text=With time?') await page.getByLabel('From label:').fill('Previous:') @@ -51,7 +50,7 @@ test.describe('Date input block', () => { page.locator('text="01/01/2021 11:00 to 01/01/2022 09:00"') ).toBeVisible() - await page.click(`text=Pick a date...`) + await page.click(`text=Pick a date`) await page.getByPlaceholder('dd/MM/yyyy HH:mm').fill('dd.MM HH:mm') await page.click('text=Restart') await page.locator('[data-testid="from-date"]').fill('2023-01-01T11:00') diff --git a/apps/builder/src/features/blocks/inputs/emailInput/emailInput.spec.ts b/apps/builder/src/features/blocks/inputs/emailInput/emailInput.spec.ts index 62e1151cb..e071964d8 100644 --- a/apps/builder/src/features/blocks/inputs/emailInput/emailInput.spec.ts +++ b/apps/builder/src/features/blocks/inputs/emailInput/emailInput.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { defaultEmailInputOptions } from '@typebot.io/schemas/features/blocks/inputs/email/constants' @@ -25,7 +25,6 @@ test.describe('Email input block', () => { `input[placeholder="${defaultEmailInputOptions.labels.placeholder}"]` ) ).toHaveAttribute('type', 'email') - await expect(page.getByRole('button', { name: 'Send' })).toBeDisabled() await page.click(`text=${defaultEmailInputOptions.labels.placeholder}`) await page.fill( diff --git a/apps/builder/src/features/blocks/inputs/fileUpload/fileUpload.spec.ts b/apps/builder/src/features/blocks/inputs/fileUpload/fileUpload.spec.ts index 82cd29ceb..9bdb69903 100644 --- a/apps/builder/src/features/blocks/inputs/fileUpload/fileUpload.spec.ts +++ b/apps/builder/src/features/blocks/inputs/fileUpload/fileUpload.spec.ts @@ -1,8 +1,8 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' -import { freeWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup' +import { freeWorkspaceId } from '@typebot.io/playwright/databaseSetup' import { getTestAsset } from '@/test/utils/playwright' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' @@ -32,6 +32,7 @@ test('options should work', async ({ page }) => { await page.click('text="Required?"') await page.click('text="Allow multiple files?"') await page.fill('div[contenteditable=true]', 'Upload now!!') + await page.click('text="Labels"') await page.fill('[value="Upload"]', 'Go') await page.fill('[value="Clear"]', 'Reset') await page.fill('[value="Skip"]', 'Pass') diff --git a/apps/builder/src/features/blocks/inputs/number/number.spec.ts b/apps/builder/src/features/blocks/inputs/number/number.spec.ts index 49a657529..50f490090 100644 --- a/apps/builder/src/features/blocks/inputs/number/number.spec.ts +++ b/apps/builder/src/features/blocks/inputs/number/number.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { defaultNumberInputOptions } from '@typebot.io/schemas/features/blocks/inputs/number/constants' @@ -25,7 +25,6 @@ test.describe('Number input block', () => { `input[placeholder="${defaultNumberInputOptions.labels.placeholder}"]` ) ).toHaveAttribute('type', 'number') - await expect(page.getByRole('button', { name: 'Send' })).toBeDisabled() await page.click(`text=${defaultNumberInputOptions.labels.placeholder}`) await page.getByLabel('Placeholder:').fill('Your number...') diff --git a/apps/builder/src/features/blocks/inputs/payment/payment.spec.ts b/apps/builder/src/features/blocks/inputs/payment/payment.spec.ts index df1242f60..4b3a3a41c 100644 --- a/apps/builder/src/features/blocks/inputs/payment/payment.spec.ts +++ b/apps/builder/src/features/blocks/inputs/payment/payment.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { stripePaymentForm } from '@/test/utils/selectorUtils' import { env } from '@typebot.io/env' diff --git a/apps/builder/src/features/blocks/inputs/phone/phone.spec.ts b/apps/builder/src/features/blocks/inputs/phone/phone.spec.ts index 02c2c3227..0f522830a 100644 --- a/apps/builder/src/features/blocks/inputs/phone/phone.spec.ts +++ b/apps/builder/src/features/blocks/inputs/phone/phone.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { defaultPhoneInputOptions } from '@typebot.io/schemas/features/blocks/inputs/phone/constants' @@ -25,7 +25,6 @@ test.describe('Phone input block', () => { `input[placeholder="${defaultPhoneInputOptions.labels.placeholder}"]` ) ).toHaveAttribute('type', 'tel') - await expect(page.getByRole('button', { name: 'Send' })).toBeDisabled() await page.click(`text=${defaultPhoneInputOptions.labels.placeholder}`) await page.getByLabel('Placeholder:').fill('+33 XX XX XX XX') diff --git a/apps/builder/src/features/blocks/inputs/pictureChoice/pictureChoice.spec.ts b/apps/builder/src/features/blocks/inputs/pictureChoice/pictureChoice.spec.ts index f89f986d5..207f41306 100644 --- a/apps/builder/src/features/blocks/inputs/pictureChoice/pictureChoice.spec.ts +++ b/apps/builder/src/features/blocks/inputs/pictureChoice/pictureChoice.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' diff --git a/apps/builder/src/features/blocks/inputs/rating/rating.spec.ts b/apps/builder/src/features/blocks/inputs/rating/rating.spec.ts index c4c5b36f4..db174fa86 100644 --- a/apps/builder/src/features/blocks/inputs/rating/rating.spec.ts +++ b/apps/builder/src/features/blocks/inputs/rating/rating.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' diff --git a/apps/builder/src/features/blocks/inputs/textInput/textInput.spec.ts b/apps/builder/src/features/blocks/inputs/textInput/textInput.spec.ts index 87adbb124..0b5edb44e 100644 --- a/apps/builder/src/features/blocks/inputs/textInput/textInput.spec.ts +++ b/apps/builder/src/features/blocks/inputs/textInput/textInput.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { defaultTextInputOptions } from '@typebot.io/schemas/features/blocks/inputs/text/constants' @@ -25,7 +25,6 @@ test.describe.parallel('Text input block', () => { `input[placeholder="${defaultTextInputOptions.labels.placeholder}"]` ) ).toHaveAttribute('type', 'text') - await expect(page.getByRole('button', { name: 'Send' })).toBeDisabled() await page.click(`text=${defaultTextInputOptions.labels.placeholder}`) await page.getByLabel('Placeholder:').fill('Your name...') diff --git a/apps/builder/src/features/blocks/inputs/url/url.spec.ts b/apps/builder/src/features/blocks/inputs/url/url.spec.ts index 58813472e..9bcd6ca3e 100644 --- a/apps/builder/src/features/blocks/inputs/url/url.spec.ts +++ b/apps/builder/src/features/blocks/inputs/url/url.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { defaultUrlInputOptions } from '@typebot.io/schemas/features/blocks/inputs/url/constants' @@ -25,9 +25,6 @@ test.describe('Url input block', () => { `input[placeholder="${defaultUrlInputOptions.labels.placeholder}"]` ) ).toHaveAttribute('type', 'url') - await expect( - page.locator('typebot-standard').locator(`button`) - ).toBeDisabled() await page.click(`text=${defaultUrlInputOptions.labels.placeholder}`) await page.getByLabel('Placeholder:').fill('Your URL...') diff --git a/apps/builder/src/features/blocks/integrations/chatwoot/chatwoot.spec.ts b/apps/builder/src/features/blocks/integrations/chatwoot/chatwoot.spec.ts index 61b2aae02..d51e2147c 100644 --- a/apps/builder/src/features/blocks/integrations/chatwoot/chatwoot.spec.ts +++ b/apps/builder/src/features/blocks/integrations/chatwoot/chatwoot.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' import { defaultChatwootOptions } from '@typebot.io/schemas/features/blocks/integrations/chatwoot/constants' diff --git a/apps/builder/src/features/blocks/integrations/googleAnalytics/googleAnalytics.spec.ts b/apps/builder/src/features/blocks/integrations/googleAnalytics/googleAnalytics.spec.ts index 7ab799b62..a4966ffc3 100644 --- a/apps/builder/src/features/blocks/integrations/googleAnalytics/googleAnalytics.spec.ts +++ b/apps/builder/src/features/blocks/integrations/googleAnalytics/googleAnalytics.spec.ts @@ -1,6 +1,6 @@ import test from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' diff --git a/apps/builder/src/features/blocks/integrations/googleSheets/googleSheets.spec.ts b/apps/builder/src/features/blocks/integrations/googleSheets/googleSheets.spec.ts index 4dfaafde0..420304589 100644 --- a/apps/builder/src/features/blocks/integrations/googleSheets/googleSheets.spec.ts +++ b/apps/builder/src/features/blocks/integrations/googleSheets/googleSheets.spec.ts @@ -1,5 +1,5 @@ import test, { expect, Page } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' @@ -153,15 +153,6 @@ const fillInSpreadsheetInfo = async (page: Page) => { await page.click('text=pro-user@email.com') await page.waitForTimeout(1000) - await page.getByRole('button', { name: 'Pick a spreadsheet' }).click() - await page - .frameLocator('.picker-frame') - .getByLabel('CRM Google Sheets Not selected') - .click() - await page - .frameLocator('.picker-frame') - .getByRole('button', { name: 'Select' }) - .click() await page.fill('input[placeholder="Select the sheet"]', 'Sh') await page.click('text=Sheet1') diff --git a/apps/builder/src/features/blocks/integrations/openai/openai.spec.ts b/apps/builder/src/features/blocks/integrations/openai/openai.spec.ts deleted file mode 100644 index 5e09e4ea5..000000000 --- a/apps/builder/src/features/blocks/integrations/openai/openai.spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { createId } from '@paralleldrive/cuid2' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' -import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' - -const typebotId = createId() - -test('should be configurable', async ({ page }) => { - await createTypebots([ - { - id: typebotId, - ...parseDefaultGroupWithBlock({ - type: IntegrationBlockType.OPEN_AI, - }), - }, - ]) - await page.goto(`/typebots/${typebotId}/edit`) - await page.getByText('Configure...').click() - await page.getByRole('button', { name: 'Add OpenAI account' }).click() - await expect(page.getByRole('button', { name: 'Create' })).toBeDisabled() - await page.getByPlaceholder('My account').fill('My account') - await page.getByPlaceholder('sk-...').fill('sk-test') - await page.getByRole('button', { name: 'Create' }).click() - await page.getByRole('button', { name: 'Select task' }).click() - await page.getByRole('menuitem', { name: 'Create chat completion' }).click() - await page.getByRole('button', { name: 'Messages' }).click() - await page.getByRole('button', { name: 'Select type' }).click() - await page.getByRole('menuitem', { name: 'system' }).click() - await page.getByPlaceholder('Content').first().fill('You are a helpful bot') - await page.getByRole('button', { name: 'Add message' }).nth(1).click() - await page.getByRole('button', { name: 'Select type' }).click() - await page.getByRole('menuitem', { name: 'assistant' }).click() - await page.getByPlaceholder('Content').nth(1).fill('Hi there!') - await page.getByRole('button', { name: 'Save answer' }).click() - await page.getByTestId('variables-input').click() -}) diff --git a/apps/builder/src/features/blocks/integrations/pixel/pixel.spec.ts b/apps/builder/src/features/blocks/integrations/pixel/pixel.spec.ts index 380346460..45ed6b092 100644 --- a/apps/builder/src/features/blocks/integrations/pixel/pixel.spec.ts +++ b/apps/builder/src/features/blocks/integrations/pixel/pixel.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { createId } from '@paralleldrive/cuid2' import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' diff --git a/apps/builder/src/features/blocks/integrations/sendEmail/sendEmail.spec.ts b/apps/builder/src/features/blocks/integrations/sendEmail/sendEmail.spec.ts index 9746674da..ff6ded078 100644 --- a/apps/builder/src/features/blocks/integrations/sendEmail/sendEmail.spec.ts +++ b/apps/builder/src/features/blocks/integrations/sendEmail/sendEmail.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' import { env } from '@typebot.io/env' @@ -57,7 +57,7 @@ test.describe('Send email block', () => { ) await page.getByLabel('Subject:').fill('Email subject') await page.click('text="Custom content?"') - await page.locator('textarea').fill('Here is my email') + await page.locator('textarea').last().fill('Here is my email') await page.click('text=Test') await page.locator('typebot-standard').locator('text=Go').click() diff --git a/apps/builder/src/features/blocks/integrations/webhook/api/getResultExample.ts b/apps/builder/src/features/blocks/integrations/webhook/api/getResultExample.ts index 1f09745e9..c77689e1e 100644 --- a/apps/builder/src/features/blocks/integrations/webhook/api/getResultExample.ts +++ b/apps/builder/src/features/blocks/integrations/webhook/api/getResultExample.ts @@ -6,7 +6,7 @@ import { Typebot } from '@typebot.io/schemas' import { z } from 'zod' import { fetchLinkedTypebots } from '@/features/blocks/logic/typebotLink/helpers/fetchLinkedTypebots' import { parseSampleResult } from '@typebot.io/bot-engine/blocks/integrations/webhook/parseSampleResult' -import { getBlockById } from '@typebot.io/lib/getBlockById' +import { getBlockById } from '@typebot.io/schemas/helpers' export const getResultExample = authenticatedProcedure .meta({ @@ -32,6 +32,7 @@ export const getResultExample = authenticatedProcedure }) ) .query(async ({ input: { typebotId, blockId }, ctx: { user } }) => { + console.log('user', user) const typebot = (await prisma.typebot.findFirst({ where: canReadTypebots(typebotId, user), select: { @@ -53,9 +54,10 @@ export const getResultExample = authenticatedProcedure const linkedTypebots = await fetchLinkedTypebots(typebot, user) return { - resultExample: await parseSampleResult(typebot, linkedTypebots)( - group.id, - typebot.variables - ), + resultExample: await parseSampleResult( + typebot, + linkedTypebots, + user.email ?? undefined + )(group.id, typebot.variables), } }) diff --git a/apps/builder/src/features/blocks/integrations/webhook/api/listWebhookBlocks.ts b/apps/builder/src/features/blocks/integrations/webhook/api/listWebhookBlocks.ts index 16baf6c49..732875142 100644 --- a/apps/builder/src/features/blocks/integrations/webhook/api/listWebhookBlocks.ts +++ b/apps/builder/src/features/blocks/integrations/webhook/api/listWebhookBlocks.ts @@ -6,7 +6,8 @@ import { z } from 'zod' import { parseGroups } from '@typebot.io/schemas/features/typebot/group' import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' import { Block } from '@typebot.io/schemas' -import { byId, isWebhookBlock } from '@typebot.io/lib' +import { isWebhookBlock } from '@typebot.io/schemas/helpers' +import { byId } from '@typebot.io/lib' export const listWebhookBlocks = authenticatedProcedure .meta({ diff --git a/apps/builder/src/features/blocks/integrations/webhook/api/subscribeWebhook.ts b/apps/builder/src/features/blocks/integrations/webhook/api/subscribeWebhook.ts index 1c3c7ee55..0cf76517a 100644 --- a/apps/builder/src/features/blocks/integrations/webhook/api/subscribeWebhook.ts +++ b/apps/builder/src/features/blocks/integrations/webhook/api/subscribeWebhook.ts @@ -3,7 +3,8 @@ import { canWriteTypebots } from '@/helpers/databaseRules' import { authenticatedProcedure } from '@/helpers/server/trpc' import { TRPCError } from '@trpc/server' import { Block, HttpRequestBlock, parseGroups } from '@typebot.io/schemas' -import { byId, isWebhookBlock } from '@typebot.io/lib' +import { byId } from '@typebot.io/lib' +import { isWebhookBlock } from '@typebot.io/schemas/helpers' import { z } from 'zod' export const subscribeWebhook = authenticatedProcedure diff --git a/apps/builder/src/features/blocks/integrations/webhook/api/unsubscribeWebhook.ts b/apps/builder/src/features/blocks/integrations/webhook/api/unsubscribeWebhook.ts index cff53f36f..38d508e30 100644 --- a/apps/builder/src/features/blocks/integrations/webhook/api/unsubscribeWebhook.ts +++ b/apps/builder/src/features/blocks/integrations/webhook/api/unsubscribeWebhook.ts @@ -3,7 +3,8 @@ import { canWriteTypebots } from '@/helpers/databaseRules' import { authenticatedProcedure } from '@/helpers/server/trpc' import { TRPCError } from '@trpc/server' import { Block, HttpRequestBlock, parseGroups } from '@typebot.io/schemas' -import { byId, isWebhookBlock } from '@typebot.io/lib' +import { byId } from '@typebot.io/lib' +import { isWebhookBlock } from '@typebot.io/schemas/helpers' import { z } from 'zod' export const unsubscribeWebhook = authenticatedProcedure diff --git a/apps/builder/src/features/blocks/integrations/webhook/webhook.spec.ts b/apps/builder/src/features/blocks/integrations/webhook/webhook.spec.ts index a2f26a5d9..fb8f8bc6e 100644 --- a/apps/builder/src/features/blocks/integrations/webhook/webhook.spec.ts +++ b/apps/builder/src/features/blocks/integrations/webhook/webhook.spec.ts @@ -2,10 +2,10 @@ import test, { expect, Page } from '@playwright/test' import { createWebhook, importTypebotInDatabase, -} from '@typebot.io/lib/playwright/databaseActions' +} from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' -import { apiToken } from '@typebot.io/lib/playwright/databaseSetup' +import { apiToken } from '@typebot.io/playwright/databaseSetup' import { env } from '@typebot.io/env' import { HttpMethod } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants' @@ -22,7 +22,7 @@ test.describe('Builder', () => { await page.goto(`/typebots/${typebotId}/edit`) await page.click('text=Configure...') await page.fill( - 'input[placeholder="Paste webhook URL..."]', + 'input[placeholder="Paste URL..."]', `${env.NEXTAUTH_URL}/api/mock/webhook-easy-config` ) await page.click('text=Test the request') @@ -45,7 +45,7 @@ test.describe('Builder', () => { await page.goto(`/typebots/${typebotId}/edit`) await page.click('text=Configure...') await page.fill( - 'input[placeholder="Paste webhook URL..."]', + 'input[placeholder="Paste URL..."]', `${env.NEXTAUTH_URL}/api/mock/webhook` ) await page.click('text=Advanced configuration') diff --git a/apps/builder/src/features/blocks/logic/abTest/abTest.spec.ts b/apps/builder/src/features/blocks/logic/abTest/abTest.spec.ts index 862d0e6a5..7067ffd73 100644 --- a/apps/builder/src/features/blocks/logic/abTest/abTest.spec.ts +++ b/apps/builder/src/features/blocks/logic/abTest/abTest.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' diff --git a/apps/builder/src/features/blocks/logic/condition/condition.spec.ts b/apps/builder/src/features/blocks/logic/condition/condition.spec.ts index 889349d50..0963c8fe8 100644 --- a/apps/builder/src/features/blocks/logic/condition/condition.spec.ts +++ b/apps/builder/src/features/blocks/logic/condition/condition.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' diff --git a/apps/builder/src/features/blocks/logic/jump/jump.spec.ts b/apps/builder/src/features/blocks/logic/jump/jump.spec.ts index dbd44672b..b640ea9d0 100644 --- a/apps/builder/src/features/blocks/logic/jump/jump.spec.ts +++ b/apps/builder/src/features/blocks/logic/jump/jump.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' diff --git a/apps/builder/src/features/blocks/logic/redirect/redirect.spec.ts b/apps/builder/src/features/blocks/logic/redirect/redirect.spec.ts index c4bbb6642..2ce5a503f 100644 --- a/apps/builder/src/features/blocks/logic/redirect/redirect.spec.ts +++ b/apps/builder/src/features/blocks/logic/redirect/redirect.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' diff --git a/apps/builder/src/features/blocks/logic/script/script.spec.ts b/apps/builder/src/features/blocks/logic/script/script.spec.ts index 729c3bfa5..50d19d4a6 100644 --- a/apps/builder/src/features/blocks/logic/script/script.spec.ts +++ b/apps/builder/src/features/blocks/logic/script/script.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' diff --git a/apps/builder/src/features/blocks/logic/setVariable/setVariable.spec.ts b/apps/builder/src/features/blocks/logic/setVariable/setVariable.spec.ts index 840cceaf5..bfee76958 100644 --- a/apps/builder/src/features/blocks/logic/setVariable/setVariable.spec.ts +++ b/apps/builder/src/features/blocks/logic/setVariable/setVariable.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' diff --git a/apps/builder/src/features/blocks/logic/typebotLink/typebotLink.spec.ts b/apps/builder/src/features/blocks/logic/typebotLink/typebotLink.spec.ts index ebe0e23c1..fb83ba9c1 100644 --- a/apps/builder/src/features/blocks/logic/typebotLink/typebotLink.spec.ts +++ b/apps/builder/src/features/blocks/logic/typebotLink/typebotLink.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' diff --git a/apps/builder/src/features/blocks/logic/wait/wait.spec.ts b/apps/builder/src/features/blocks/logic/wait/wait.spec.ts index 72ac81b08..0a32e4339 100644 --- a/apps/builder/src/features/blocks/logic/wait/wait.spec.ts +++ b/apps/builder/src/features/blocks/logic/wait/wait.spec.ts @@ -1,5 +1,5 @@ import test, { expect } from '@playwright/test' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { createId } from '@paralleldrive/cuid2' import { getTestAsset } from '@/test/utils/playwright' diff --git a/apps/builder/src/features/collaboration/collaboration.spec.ts b/apps/builder/src/features/collaboration/collaboration.spec.ts index c13ea3445..c385acf13 100644 --- a/apps/builder/src/features/collaboration/collaboration.spec.ts +++ b/apps/builder/src/features/collaboration/collaboration.spec.ts @@ -5,9 +5,9 @@ import prisma from '@typebot.io/lib/prisma' import { createTypebots, injectFakeResults, -} from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' -import { userId } from '@typebot.io/lib/playwright/databaseSetup' +} from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' +import { userId } from '@typebot.io/playwright/databaseSetup' import { createFolder } from '@/test/utils/databaseActions' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' diff --git a/apps/builder/src/features/credentials/api/createCredentials.ts b/apps/builder/src/features/credentials/api/createCredentials.ts index 04bc087f2..4fe564f78 100644 --- a/apps/builder/src/features/credentials/api/createCredentials.ts +++ b/apps/builder/src/features/credentials/api/createCredentials.ts @@ -14,7 +14,7 @@ import { } from '@typebot.io/schemas' import { isDefined } from '@typebot.io/lib/utils' import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' const inputShape = { data: true, diff --git a/apps/builder/src/features/customDomains/api/createCustomDomain.ts b/apps/builder/src/features/customDomains/api/createCustomDomain.ts index 51f480ffe..a9d7585e1 100644 --- a/apps/builder/src/features/customDomains/api/createCustomDomain.ts +++ b/apps/builder/src/features/customDomains/api/createCustomDomain.ts @@ -6,7 +6,7 @@ import { customDomainSchema } from '@typebot.io/schemas/features/customDomains' import got, { HTTPError } from 'got' import { env } from '@typebot.io/env' import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' export const createCustomDomain = authenticatedProcedure .meta({ diff --git a/apps/builder/src/features/customDomains/customDomains.spec.ts b/apps/builder/src/features/customDomains/customDomains.spec.ts index c48a2ba02..0a08570ec 100644 --- a/apps/builder/src/features/customDomains/customDomains.spec.ts +++ b/apps/builder/src/features/customDomains/customDomains.spec.ts @@ -1,8 +1,8 @@ import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' -import { starterWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' +import { starterWorkspaceId } from '@typebot.io/playwright/databaseSetup' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' test('should be able to connect custom domain', async ({ page }) => { @@ -26,7 +26,7 @@ test('should be able to connect custom domain', async ({ page }) => { await expect(page.locator('text="CNAME"')).toBeVisible() await page.click('text=Save') await expect(page.locator('text="https://sub.yolozeeer.com/"')).toBeVisible() - await page.click('text="Edit" >> nth=1') + await page.click('text="Edit"') await page.fill('text=https://sub.yolozeeer.com/Copy >> input', 'custom-path') await page.press( 'text=https://sub.yolozeeer.com/custom-path >> input', diff --git a/apps/builder/src/features/dashboard/components/DashboardPage.tsx b/apps/builder/src/features/dashboard/components/DashboardPage.tsx index 7ecc656b3..a8ceb984f 100644 --- a/apps/builder/src/features/dashboard/components/DashboardPage.tsx +++ b/apps/builder/src/features/dashboard/components/DashboardPage.tsx @@ -14,7 +14,7 @@ import { FolderContent } from '@/features/folders/components/FolderContent' import { TypebotDndProvider } from '@/features/folders/TypebotDndProvider' import { ParentModalProvider } from '@/features/graph/providers/ParentModalProvider' import { trpc } from '@/lib/trpc' -import { guessIfUserIsEuropean } from '@typebot.io/lib/billing/guessIfUserIsEuropean' +import { guessIfUserIsEuropean } from '@typebot.io/billing/guessIfUserIsEuropean' import { useTranslate } from '@tolgee/react' export const DashboardPage = () => { diff --git a/apps/builder/src/features/dashboard/dashboard.spec.ts b/apps/builder/src/features/dashboard/dashboard.spec.ts index 26e0566dc..163c8f468 100644 --- a/apps/builder/src/features/dashboard/dashboard.spec.ts +++ b/apps/builder/src/features/dashboard/dashboard.spec.ts @@ -2,20 +2,18 @@ import { createFolders } from '@/test/utils/databaseActions' import { deleteButtonInConfirmDialog } from '@/test/utils/selectorUtils' import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' +import { createTypebots } from '@typebot.io/playwright/databaseActions' test('folders navigation should work', async ({ page }) => { await page.goto('/typebots') const createFolderButton = page.locator('button:has-text("Create a folder")') await expect(createFolderButton).not.toBeDisabled() await createFolderButton.click() - await page.click('text="New folder"') await page.fill('input[value="New folder"]', 'My folder #1') await page.press('input[value="My folder #1"]', 'Enter') await page.click('li:has-text("My folder #1")') await expect(page.locator('h1:has-text("My folder #1")')).toBeVisible() await createFolderButton.click() - await page.click('text="New folder"') await page.fill('input', 'My folder #2') await page.press('input', 'Enter') diff --git a/apps/builder/src/features/editor/editor.spec.ts b/apps/builder/src/features/editor/editor.spec.ts index 53c2442b0..530fd9f9f 100644 --- a/apps/builder/src/features/editor/editor.spec.ts +++ b/apps/builder/src/features/editor/editor.spec.ts @@ -3,8 +3,8 @@ import { createId } from '@paralleldrive/cuid2' import { createTypebots, importTypebotInDatabase, -} from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +} from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { getTestAsset } from '@/test/utils/playwright' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' @@ -113,46 +113,6 @@ test('Drag and drop blocks and items should work', async ({ page }) => { 'Name=John' ) }) -test('Undo / Redo and Zoom buttons should work', async ({ page }) => { - const typebotId = createId() - await createTypebots([ - { - id: typebotId, - ...parseDefaultGroupWithBlock({ - type: InputBlockType.TEXT, - }), - }, - ]) - - await page.goto(`/typebots/${typebotId}/edit`) - await page.click('text=Group #1', { button: 'right' }) - await page.click('text=Duplicate') - await expect(page.locator('text="Group #1"')).toBeVisible() - await expect(page.locator('text="Group #1 (1)"')).toBeVisible() - await page.click('text="Group #1"', { button: 'right' }) - await page.click('text=Delete') - await expect(page.locator('text="Group #1"')).toBeHidden() - await page.click('button[aria-label="Undo"]') - await expect(page.locator('text="Group #1"')).toBeVisible() - await page.click('button[aria-label="Redo"]') - await expect(page.locator('text="Group #1"')).toBeHidden() - await page.getByRole('button', { name: 'Zoom in' }).click() - await expect(page.getByTestId('graph')).toHaveAttribute( - 'style', - /scale\(1\.2\)/ - ) - await page.getByRole('button', { name: 'Zoom in' }).click() - await expect(page.getByTestId('graph')).toHaveAttribute( - 'style', - /scale\(1\.4\)/ - ) - await page.getByRole('button', { name: 'Zoom out' }).dblclick() - await page.getByRole('button', { name: 'Zoom out' }).dblclick() - await expect(page.getByTestId('graph')).toHaveAttribute( - 'style', - /scale\(0\.6\)/ - ) -}) test('Rename and icon change should work', async ({ page }) => { const typebotId = createId() diff --git a/apps/builder/src/features/editor/providers/typebotActions/blocks.ts b/apps/builder/src/features/editor/providers/typebotActions/blocks.ts index a2d420235..49c574812 100644 --- a/apps/builder/src/features/editor/providers/typebotActions/blocks.ts +++ b/apps/builder/src/features/editor/providers/typebotActions/blocks.ts @@ -10,7 +10,8 @@ import { SetTypebot } from '../TypebotProvider' import { produce, Draft } from 'immer' import { deleteConnectedEdgesDraft, deleteEdgeDraft } from './edges' import { createId } from '@paralleldrive/cuid2' -import { byId, blockHasItems } from '@typebot.io/lib' +import { byId } from '@typebot.io/lib' +import { blockHasItems } from '@typebot.io/schemas/helpers' import { duplicateItemDraft } from './items' import { parseNewBlock } from '@/features/typebot/helpers/parseNewBlock' diff --git a/apps/builder/src/features/editor/providers/typebotActions/edges.ts b/apps/builder/src/features/editor/providers/typebotActions/edges.ts index ceb5ebf6b..08a163b22 100644 --- a/apps/builder/src/features/editor/providers/typebotActions/edges.ts +++ b/apps/builder/src/features/editor/providers/typebotActions/edges.ts @@ -9,7 +9,8 @@ import { } from '@typebot.io/schemas' import { SetTypebot } from '../TypebotProvider' import { Draft, produce } from 'immer' -import { byId, isDefined, blockHasItems } from '@typebot.io/lib' +import { byId, isDefined } from '@typebot.io/lib' +import { blockHasItems } from '@typebot.io/schemas/helpers' import { createId } from '@paralleldrive/cuid2' export type EdgesActions = { diff --git a/apps/builder/src/features/editor/providers/typebotActions/groups.ts b/apps/builder/src/features/editor/providers/typebotActions/groups.ts index 34fc60cda..14aee9486 100644 --- a/apps/builder/src/features/editor/providers/typebotActions/groups.ts +++ b/apps/builder/src/features/editor/providers/typebotActions/groups.ts @@ -14,7 +14,8 @@ import { createBlockDraft, duplicateBlockDraft, } from './blocks' -import { blockHasItems, byId, isEmpty } from '@typebot.io/lib' +import { byId, isEmpty } from '@typebot.io/lib' +import { blockHasItems } from '@typebot.io/schemas/helpers' import { Coordinates, CoordinatesMap } from '@/features/graph/types' import { parseUniqueKey } from '@typebot.io/lib/parseUniqueKey' diff --git a/apps/builder/src/features/editor/providers/typebotActions/items.ts b/apps/builder/src/features/editor/providers/typebotActions/items.ts index 9030d23ec..282b14700 100644 --- a/apps/builder/src/features/editor/providers/typebotActions/items.ts +++ b/apps/builder/src/features/editor/providers/typebotActions/items.ts @@ -9,7 +9,8 @@ import { import { SetTypebot } from '../TypebotProvider' import { Draft, produce } from 'immer' import { deleteConnectedEdgesDraft } from './edges' -import { byId, blockHasItems } from '@typebot.io/lib' +import { byId } from '@typebot.io/lib' +import { blockHasItems } from '@typebot.io/schemas/helpers' import { createId } from '@paralleldrive/cuid2' import { BlockWithCreatableItems, diff --git a/apps/builder/src/features/folders/api/createFolder.ts b/apps/builder/src/features/folders/api/createFolder.ts index ab78c321d..4276819bb 100644 --- a/apps/builder/src/features/folders/api/createFolder.ts +++ b/apps/builder/src/features/folders/api/createFolder.ts @@ -5,7 +5,7 @@ import { DashboardFolder, Plan, WorkspaceRole } from '@typebot.io/prisma' import { folderSchema } from '@typebot.io/schemas' import { z } from 'zod' import { getUserRoleInWorkspace } from '@/features/workspace/helpers/getUserRoleInWorkspace' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' export const createFolder = authenticatedProcedure .meta({ diff --git a/apps/builder/src/features/graph/components/GraphElements.tsx b/apps/builder/src/features/graph/components/GraphElements.tsx index 89adec163..23981e5b9 100644 --- a/apps/builder/src/features/graph/components/GraphElements.tsx +++ b/apps/builder/src/features/graph/components/GraphElements.tsx @@ -7,7 +7,7 @@ import React, { memo } from 'react' import { EndpointsProvider } from '../providers/EndpointsProvider' import { Edges } from './edges/Edges' import { GroupNode } from './nodes/group/GroupNode' -import { isInputBlock } from '@typebot.io/lib' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { EventNode } from './nodes/event' type Props = { diff --git a/apps/builder/src/features/graph/components/edges/DropOffEdge.tsx b/apps/builder/src/features/graph/components/edges/DropOffEdge.tsx index a5b51cd9a..a95ad4745 100644 --- a/apps/builder/src/features/graph/components/edges/DropOffEdge.tsx +++ b/apps/builder/src/features/graph/components/edges/DropOffEdge.tsx @@ -18,7 +18,8 @@ import { TotalVisitedEdges, } from '@typebot.io/schemas/features/analytics' import { computeTotalUsersAtBlock } from '@/features/analytics/helpers/computeTotalUsersAtBlock' -import { blockHasItems, byId } from '@typebot.io/lib' +import { byId } from '@typebot.io/lib' +import { blockHasItems } from '@typebot.io/schemas/helpers' import { groupWidth } from '../../constants' import { getTotalAnswersAtBlock } from '@/features/analytics/helpers/getTotalAnswersAtBlock' import { useGroupsStore } from '../../hooks/useGroupsStore' diff --git a/apps/builder/src/features/graph/components/nodes/block/BlockNode.tsx b/apps/builder/src/features/graph/components/nodes/block/BlockNode.tsx index 100929dc1..5b93d0b05 100644 --- a/apps/builder/src/features/graph/components/nodes/block/BlockNode.tsx +++ b/apps/builder/src/features/graph/components/nodes/block/BlockNode.tsx @@ -15,12 +15,12 @@ import { TextBubbleBlock, BlockV6, } from '@typebot.io/schemas' +import { isDefined } from '@typebot.io/lib' import { - isBubbleBlock, - isDefined, isInputBlock, + isBubbleBlock, isTextBubbleBlock, -} from '@typebot.io/lib' +} from '@typebot.io/schemas/helpers' import { BlockNodeContent } from './BlockNodeContent' import { BlockSettings, SettingsPopoverContent } from './SettingsPopoverContent' import { BlockNodeContextMenu } from './BlockNodeContextMenu' diff --git a/apps/builder/src/features/publish/publish.spec.ts b/apps/builder/src/features/publish/publish.spec.ts index deefe219e..eeb0434d5 100644 --- a/apps/builder/src/features/publish/publish.spec.ts +++ b/apps/builder/src/features/publish/publish.spec.ts @@ -1,7 +1,7 @@ import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' test('should not be able to submit taken url ID', async ({ page }) => { diff --git a/apps/builder/src/features/results/ResultsProvider.tsx b/apps/builder/src/features/results/ResultsProvider.tsx index 69e762246..31605407b 100644 --- a/apps/builder/src/features/results/ResultsProvider.tsx +++ b/apps/builder/src/features/results/ResultsProvider.tsx @@ -11,8 +11,8 @@ import { useResultsQuery } from './hooks/useResultsQuery' import { trpc } from '@/lib/trpc' import { isDefined } from '@typebot.io/lib/utils' import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants' -import { parseResultHeader } from '@typebot.io/lib/results/parseResultHeader' -import { convertResultsToTableData } from '@typebot.io/lib/results/convertResultsToTableData' +import { parseResultHeader } from '@typebot.io/results/parseResultHeader' +import { convertResultsToTableData } from '@typebot.io/results/convertResultsToTableData' import { parseCellContent } from './helpers/parseCellContent' import { timeFilterValues } from '../analytics/constants' diff --git a/apps/builder/src/features/results/api/deleteResults.ts b/apps/builder/src/features/results/api/deleteResults.ts index 8fcb82220..835c5b9fe 100644 --- a/apps/builder/src/features/results/api/deleteResults.ts +++ b/apps/builder/src/features/results/api/deleteResults.ts @@ -1,7 +1,7 @@ import { authenticatedProcedure } from '@/helpers/server/trpc' import { TRPCError } from '@trpc/server' import { z } from 'zod' -import { archiveResults } from '@typebot.io/lib/api/helpers/archiveResults' +import { archiveResults } from '@typebot.io/results/archiveResults' import prisma from '@typebot.io/lib/prisma' import { isWriteTypebotForbidden } from '@/features/typebot/helpers/isWriteTypebotForbidden' import { Typebot } from '@typebot.io/schemas' diff --git a/apps/builder/src/features/results/components/ResultModal.tsx b/apps/builder/src/features/results/components/ResultModal.tsx index 9abd73b84..19e04ccef 100644 --- a/apps/builder/src/features/results/components/ResultModal.tsx +++ b/apps/builder/src/features/results/components/ResultModal.tsx @@ -14,7 +14,7 @@ import React from 'react' import { byId, isDefined } from '@typebot.io/lib' import { HeaderIcon } from './HeaderIcon' import { useTypebot } from '@/features/editor/providers/TypebotProvider' -import { parseColumnsOrder } from '@typebot.io/lib/results/parseColumnsOrder' +import { parseColumnsOrder } from '@typebot.io/results/parseColumnsOrder' type Props = { resultId: string | null diff --git a/apps/builder/src/features/results/components/table/ExportAllResultsModal.tsx b/apps/builder/src/features/results/components/table/ExportAllResultsModal.tsx index 8a4823334..e11ef76cb 100644 --- a/apps/builder/src/features/results/components/table/ExportAllResultsModal.tsx +++ b/apps/builder/src/features/results/components/table/ExportAllResultsModal.tsx @@ -20,9 +20,9 @@ import { import { TRPCError } from '@trpc/server' import { unparse } from 'papaparse' import { useState } from 'react' -import { parseResultHeader } from '@typebot.io/lib/results/parseResultHeader' -import { convertResultsToTableData } from '@typebot.io/lib/results/convertResultsToTableData' -import { parseColumnsOrder } from '@typebot.io/lib/results/parseColumnsOrder' +import { parseResultHeader } from '@typebot.io/results/parseResultHeader' +import { convertResultsToTableData } from '@typebot.io/results/convertResultsToTableData' +import { parseColumnsOrder } from '@typebot.io/results/parseColumnsOrder' import { parseUniqueKey } from '@typebot.io/lib/parseUniqueKey' import { useResults } from '../../ResultsProvider' import { byId, isDefined } from '@typebot.io/lib' diff --git a/apps/builder/src/features/results/components/table/ResultsTable.tsx b/apps/builder/src/features/results/components/table/ResultsTable.tsx index 68a80c058..c3555e70d 100644 --- a/apps/builder/src/features/results/components/table/ResultsTable.tsx +++ b/apps/builder/src/features/results/components/table/ResultsTable.tsx @@ -30,7 +30,7 @@ import { HeaderRow } from './HeaderRow' import { IndeterminateCheckbox } from './IndeterminateCheckbox' import { colors } from '@/lib/theme' import { HeaderIcon } from '../HeaderIcon' -import { parseColumnsOrder } from '@typebot.io/lib/results/parseColumnsOrder' +import { parseColumnsOrder } from '@typebot.io/results/parseColumnsOrder' import { TimeFilterDropdown } from '@/features/analytics/components/TimeFilterDropdown' import { timeFilterValues } from '@/features/analytics/constants' diff --git a/apps/builder/src/features/results/components/table/SelectionToolbar.tsx b/apps/builder/src/features/results/components/table/SelectionToolbar.tsx index f15cc79e3..0f708116b 100644 --- a/apps/builder/src/features/results/components/table/SelectionToolbar.tsx +++ b/apps/builder/src/features/results/components/table/SelectionToolbar.tsx @@ -15,7 +15,7 @@ import { useToast } from '@/hooks/useToast' import { useResults } from '../../ResultsProvider' import { trpc } from '@/lib/trpc' import { byId } from '@typebot.io/lib/utils' -import { parseColumnsOrder } from '@typebot.io/lib/results/parseColumnsOrder' +import { parseColumnsOrder } from '@typebot.io/results/parseColumnsOrder' import { parseUniqueKey } from '@typebot.io/lib/parseUniqueKey' type Props = { diff --git a/apps/builder/src/features/results/results.spec.ts b/apps/builder/src/features/results/results.spec.ts index b96149068..c5672d55a 100644 --- a/apps/builder/src/features/results/results.spec.ts +++ b/apps/builder/src/features/results/results.spec.ts @@ -7,7 +7,7 @@ import { parse } from 'papaparse' import { importTypebotInDatabase, injectFakeResults, -} from '@typebot.io/lib/playwright/databaseActions' +} from '@typebot.io/playwright/databaseActions' const typebotId = createId() diff --git a/apps/builder/src/features/settings/settings.spec.ts b/apps/builder/src/features/settings/settings.spec.ts index 25a1f07d8..8de449b0b 100644 --- a/apps/builder/src/features/settings/settings.spec.ts +++ b/apps/builder/src/features/settings/settings.spec.ts @@ -1,7 +1,7 @@ import { getTestAsset } from '@/test/utils/playwright' import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { defaultTextInputOptions } from '@typebot.io/schemas/features/blocks/inputs/text/constants' test.describe.parallel('Settings page', () => { @@ -38,7 +38,7 @@ test.describe.parallel('Settings page', () => { await expect( page.locator('a:has-text("Made with Typebot")') ).toHaveAttribute('href', 'https://www.typebot.io/?utm_source=litebadge') - await page.click('button:has-text("Typing emulation")') + await page.click('button:has-text("Typing")') await page.fill('[data-testid="speed"] input', '350') await page.fill('[data-testid="max-delay"] input', '1.5') await page.click('text="Typing emulation" >> nth=-1') diff --git a/apps/builder/src/features/telemetry/api/trackClientEvents.ts b/apps/builder/src/features/telemetry/api/trackClientEvents.ts index 981b98fcc..95a411d5c 100644 --- a/apps/builder/src/features/telemetry/api/trackClientEvents.ts +++ b/apps/builder/src/features/telemetry/api/trackClientEvents.ts @@ -5,7 +5,7 @@ import prisma from '@typebot.io/lib/prisma' import { getUserRoleInWorkspace } from '@/features/workspace/helpers/getUserRoleInWorkspace' import { WorkspaceRole } from '@typebot.io/prisma' import { isWriteTypebotForbidden } from '@/features/typebot/helpers/isWriteTypebotForbidden' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' import { clientSideCreateEventSchema } from '@typebot.io/schemas' export const trackClientEvents = authenticatedProcedure diff --git a/apps/builder/src/features/telemetry/helpers/trackAnalyticsPageView.ts b/apps/builder/src/features/telemetry/helpers/trackAnalyticsPageView.ts index 19ca6e5a1..c96927846 100644 --- a/apps/builder/src/features/telemetry/helpers/trackAnalyticsPageView.ts +++ b/apps/builder/src/features/telemetry/helpers/trackAnalyticsPageView.ts @@ -1,6 +1,6 @@ import { getAuthOptions } from '@/pages/api/auth/[...nextauth]' import prisma from '@typebot.io/lib/prisma' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' import { User } from '@typebot.io/schemas' import { GetServerSidePropsContext } from 'next' import { getServerSession } from 'next-auth' diff --git a/apps/builder/src/features/theme/theme.spec.ts b/apps/builder/src/features/theme/theme.spec.ts index 78d9f9e91..1bb26f04a 100644 --- a/apps/builder/src/features/theme/theme.spec.ts +++ b/apps/builder/src/features/theme/theme.spec.ts @@ -1,8 +1,8 @@ import { getTestAsset } from '@/test/utils/playwright' import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' -import { freeWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' +import { freeWorkspaceId } from '@typebot.io/playwright/databaseSetup' const hostAvatarUrl = 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1760&q=80' @@ -31,9 +31,10 @@ test.describe.parallel('Theme page', () => { // Font await page.getByRole('textbox').fill('Roboto Slab') + await page.getByRole('menuitem', { name: 'Roboto Slab' }).click() await expect(page.locator('.typebot-container')).toHaveCSS( 'font-family', - /"Roboto Slab"/ + /Roboto Slab/ ) // BG color @@ -184,10 +185,9 @@ test.describe.parallel('Theme page', () => { .locator('input[placeholder="Paste the image link..."]') .fill(guestAvatarUrl) await page.getByRole('button', { name: 'Go' }).click() - await expect(page.locator('.typebot-container img')).toHaveAttribute( - 'src', - guestAvatarUrl - ) + await expect( + page.getByRole('img', { name: 'Bot avatar' }).nth(2) + ).toHaveAttribute('src', guestAvatarUrl) await page.waitForTimeout(1000) // Input diff --git a/apps/builder/src/features/typebot/api/createTypebot.ts b/apps/builder/src/features/typebot/api/createTypebot.ts index 097640a87..6c1588dc2 100644 --- a/apps/builder/src/features/typebot/api/createTypebot.ts +++ b/apps/builder/src/features/typebot/api/createTypebot.ts @@ -13,7 +13,7 @@ import { } from '../helpers/sanitizers' import { createId } from '@paralleldrive/cuid2' import { EventType } from '@typebot.io/schemas/features/events/constants' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' const typebotCreateSchemaPick = { name: true, diff --git a/apps/builder/src/features/typebot/api/deleteTypebot.ts b/apps/builder/src/features/typebot/api/deleteTypebot.ts index e43e5a3d8..c32212f94 100644 --- a/apps/builder/src/features/typebot/api/deleteTypebot.ts +++ b/apps/builder/src/features/typebot/api/deleteTypebot.ts @@ -4,7 +4,7 @@ import { TRPCError } from '@trpc/server' import { Typebot } from '@typebot.io/schemas' import { z } from 'zod' import { isWriteTypebotForbidden } from '../helpers/isWriteTypebotForbidden' -import { archiveResults } from '@typebot.io/lib/api/helpers/archiveResults' +import { archiveResults } from '@typebot.io/results/archiveResults' export const deleteTypebot = authenticatedProcedure .meta({ diff --git a/apps/builder/src/features/typebot/api/getPublishedTypebot.ts b/apps/builder/src/features/typebot/api/getPublishedTypebot.ts index 99467180e..0940f885b 100644 --- a/apps/builder/src/features/typebot/api/getPublishedTypebot.ts +++ b/apps/builder/src/features/typebot/api/getPublishedTypebot.ts @@ -9,7 +9,7 @@ import { } from '@typebot.io/schemas' import { z } from 'zod' import { isReadTypebotForbidden } from '../helpers/isReadTypebotForbidden' -import { migratePublicTypebot } from '@typebot.io/lib/migrations/migrateTypebot' +import { migratePublicTypebot } from '@typebot.io/migrations/migrateTypebot' export const getPublishedTypebot = authenticatedProcedure .meta({ diff --git a/apps/builder/src/features/typebot/api/getTypebot.ts b/apps/builder/src/features/typebot/api/getTypebot.ts index bf4cf4ad8..f6ed58b74 100644 --- a/apps/builder/src/features/typebot/api/getTypebot.ts +++ b/apps/builder/src/features/typebot/api/getTypebot.ts @@ -4,7 +4,7 @@ import { TRPCError } from '@trpc/server' import { typebotSchema } from '@typebot.io/schemas' import { z } from 'zod' import { isReadTypebotForbidden } from '../helpers/isReadTypebotForbidden' -import { migrateTypebot } from '@typebot.io/lib/migrations/migrateTypebot' +import { migrateTypebot } from '@typebot.io/migrations/migrateTypebot' import { CollaborationType } from '@typebot.io/prisma' import { env } from '@typebot.io/env' diff --git a/apps/builder/src/features/typebot/api/importTypebot.ts b/apps/builder/src/features/typebot/api/importTypebot.ts index 7c55ab84f..a56f2cd57 100644 --- a/apps/builder/src/features/typebot/api/importTypebot.ts +++ b/apps/builder/src/features/typebot/api/importTypebot.ts @@ -17,8 +17,8 @@ import { sanitizeSettings, } from '../helpers/sanitizers' import { preprocessTypebot } from '@typebot.io/schemas/features/typebot/helpers/preprocessTypebot' -import { migrateTypebot } from '@typebot.io/lib/migrations/migrateTypebot' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { migrateTypebot } from '@typebot.io/migrations/migrateTypebot' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' const omittedProps = { id: true, diff --git a/apps/builder/src/features/typebot/api/publishTypebot.ts b/apps/builder/src/features/typebot/api/publishTypebot.ts index c9efac762..db069b9f5 100644 --- a/apps/builder/src/features/typebot/api/publishTypebot.ts +++ b/apps/builder/src/features/typebot/api/publishTypebot.ts @@ -15,7 +15,7 @@ import { Plan } from '@typebot.io/prisma' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { computeRiskLevel } from '@typebot.io/radar' import { env } from '@typebot.io/env' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' import { parseTypebotPublishEvents } from '@/features/telemetry/helpers/parseTypebotPublishEvents' export const publishTypebot = authenticatedProcedure diff --git a/apps/builder/src/features/typebot/api/updateTypebot.ts b/apps/builder/src/features/typebot/api/updateTypebot.ts index ea4b3212e..6a49180ff 100644 --- a/apps/builder/src/features/typebot/api/updateTypebot.ts +++ b/apps/builder/src/features/typebot/api/updateTypebot.ts @@ -18,7 +18,7 @@ import { isWriteTypebotForbidden } from '../helpers/isWriteTypebotForbidden' import { isCloudProdInstance } from '@/helpers/isCloudProdInstance' import { Prisma } from '@typebot.io/prisma' import { hasProPerks } from '@/features/billing/helpers/hasProPerks' -import { migrateTypebot } from '@typebot.io/lib/migrations/migrateTypebot' +import { migrateTypebot } from '@typebot.io/migrations/migrateTypebot' const typebotUpdateSchemaPick = { version: true, diff --git a/apps/builder/src/features/typebot/helpers/hasDefaultConnector.ts b/apps/builder/src/features/typebot/helpers/hasDefaultConnector.ts index 9684e1dd3..9d6e46009 100644 --- a/apps/builder/src/features/typebot/helpers/hasDefaultConnector.ts +++ b/apps/builder/src/features/typebot/helpers/hasDefaultConnector.ts @@ -1,9 +1,9 @@ +import { isDefined } from '@typebot.io/lib' import { isChoiceInput, isConditionBlock, - isDefined, isPictureChoiceInput, -} from '@typebot.io/lib' +} from '@typebot.io/schemas/helpers' import { BlockV6 } from '@typebot.io/schemas' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants' diff --git a/apps/builder/src/features/typebot/helpers/parseNewBlock.ts b/apps/builder/src/features/typebot/helpers/parseNewBlock.ts index 04a59a78b..36f18b8d1 100644 --- a/apps/builder/src/features/typebot/helpers/parseNewBlock.ts +++ b/apps/builder/src/features/typebot/helpers/parseNewBlock.ts @@ -1,5 +1,5 @@ import { createId } from '@paralleldrive/cuid2' -import { blockTypeHasItems } from '@typebot.io/lib' +import { blockTypeHasItems } from '@typebot.io/schemas/helpers' import { BlockV6, BlockWithItems, ItemV6 } from '@typebot.io/schemas' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants' diff --git a/apps/builder/src/features/workspace/api/createWorkspace.ts b/apps/builder/src/features/workspace/api/createWorkspace.ts index 765643a08..9dfb5b029 100644 --- a/apps/builder/src/features/workspace/api/createWorkspace.ts +++ b/apps/builder/src/features/workspace/api/createWorkspace.ts @@ -4,7 +4,7 @@ import { TRPCError } from '@trpc/server' import { Workspace, workspaceSchema } from '@typebot.io/schemas' import { z } from 'zod' import { parseWorkspaceDefaultPlan } from '../helpers/parseWorkspaceDefaultPlan' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' export const createWorkspace = authenticatedProcedure .meta({ diff --git a/apps/builder/src/features/workspace/components/MembersList.tsx b/apps/builder/src/features/workspace/components/MembersList.tsx index 3c82a6be5..7b8c650b6 100644 --- a/apps/builder/src/features/workspace/components/MembersList.tsx +++ b/apps/builder/src/features/workspace/components/MembersList.tsx @@ -19,7 +19,7 @@ import { updateInvitationQuery } from '../queries/updateInvitationQuery' import { updateMemberQuery } from '../queries/updateMemberQuery' import { Member } from '../types' import { useWorkspace } from '../WorkspaceProvider' -import { getSeatsLimit } from '@typebot.io/lib/billing/getSeatsLimit' +import { getSeatsLimit } from '@typebot.io/billing/getSeatsLimit' import { useTranslate } from '@tolgee/react' export const MembersList = () => { diff --git a/apps/builder/src/features/workspace/workspaces.spec.ts b/apps/builder/src/features/workspace/workspaces.spec.ts index def8e8257..6d51ec44e 100644 --- a/apps/builder/src/features/workspace/workspaces.spec.ts +++ b/apps/builder/src/features/workspace/workspaces.spec.ts @@ -1,12 +1,12 @@ import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' +import { createTypebots } from '@typebot.io/playwright/databaseActions' import { proWorkspaceId, starterWorkspaceId, -} from '@typebot.io/lib/playwright/databaseSetup' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' -import { mockSessionResponsesToOtherUser } from '@typebot.io/lib/playwright/testHelpers' +} from '@typebot.io/playwright/databaseSetup' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' +import { mockSessionResponsesToOtherUser } from '@typebot.io/playwright/testHelpers' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' const proTypebotId = createId() @@ -162,7 +162,7 @@ test("can't add new members when limit is reached", async ({ page }) => { await expect(page.locator('button >> text="Invite"')).toBeDisabled() await expect( page.locator( - 'text="Upgrade your plan to work with more team members, and unlock awesome power features 🚀"' + 'text="Upgrade your plan to work with more team members, and unlock awesome power features"' ) ).toBeVisible() await page.click('text="Free workspace"', { force: true }) diff --git a/apps/builder/src/pages/api/auth/[...nextauth].ts b/apps/builder/src/pages/api/auth/[...nextauth].ts index 6defcbae9..0b467891a 100644 --- a/apps/builder/src/pages/api/auth/[...nextauth].ts +++ b/apps/builder/src/pages/api/auth/[...nextauth].ts @@ -20,7 +20,7 @@ import got from 'got' import { env } from '@typebot.io/env' import * as Sentry from '@sentry/nextjs' import { getIp } from '@typebot.io/lib/getIp' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' const providers: Provider[] = [] diff --git a/apps/builder/src/pages/api/stripe/webhook.ts b/apps/builder/src/pages/api/stripe/webhook.ts index dd0ee237a..2c3cd68b9 100644 --- a/apps/builder/src/pages/api/stripe/webhook.ts +++ b/apps/builder/src/pages/api/stripe/webhook.ts @@ -8,8 +8,8 @@ import { Plan, WorkspaceRole } from '@typebot.io/prisma' import { RequestHandler } from 'next/dist/server/next' import { Settings } from '@typebot.io/schemas' import { env } from '@typebot.io/env' -import { prices } from '@typebot.io/lib/billing/constants' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { prices } from '@typebot.io/billing/constants' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' if (!env.STRIPE_SECRET_KEY || !env.STRIPE_WEBHOOK_SECRET) throw new Error('STRIPE_SECRET_KEY or STRIPE_WEBHOOK_SECRET missing') diff --git a/apps/builder/src/pages/api/users/[userId].ts b/apps/builder/src/pages/api/users/[userId].ts index c44f80a0d..658bf67eb 100644 --- a/apps/builder/src/pages/api/users/[userId].ts +++ b/apps/builder/src/pages/api/users/[userId].ts @@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next' import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser' import { methodNotAllowed, notAuthenticated } from '@typebot.io/lib/api' import { User } from '@typebot.io/schemas' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' import { Prisma } from '@typebot.io/prisma' const handler = async (req: NextApiRequest, res: NextApiResponse) => { diff --git a/apps/builder/src/pages/api/workspaces/[workspaceId]/invitations.ts b/apps/builder/src/pages/api/workspaces/[workspaceId]/invitations.ts index 5d5d2c2d7..8162bae47 100644 --- a/apps/builder/src/pages/api/workspaces/[workspaceId]/invitations.ts +++ b/apps/builder/src/pages/api/workspaces/[workspaceId]/invitations.ts @@ -8,7 +8,7 @@ import { } from '@typebot.io/lib/api' import { getAuthenticatedUser } from '@/features/auth/helpers/getAuthenticatedUser' import { sendWorkspaceMemberInvitationEmail } from '@typebot.io/emails' -import { getSeatsLimit } from '@typebot.io/lib/billing/getSeatsLimit' +import { getSeatsLimit } from '@typebot.io/billing/getSeatsLimit' import { env } from '@typebot.io/env' const handler = async (req: NextApiRequest, res: NextApiResponse) => { diff --git a/apps/builder/src/test/assets/typebots/integrations/googleSheets.json b/apps/builder/src/test/assets/typebots/integrations/googleSheets.json index 9a0ed9431..865eda191 100644 --- a/apps/builder/src/test/assets/typebots/integrations/googleSheets.json +++ b/apps/builder/src/test/assets/typebots/integrations/googleSheets.json @@ -46,7 +46,9 @@ "id": "s1ZvUqWxV6b8UgFGYWh39pV", "groupId": "jd4S6BQsUQ2RuKieHXYKs9", "type": "Google Sheets", - "options": {} + "options": { + "spreadsheetId": "1k_pIDw3YHl9tlZusbBVSBRY0PeRPd2H6t4Nj7rwnOtM" + } } ] } diff --git a/apps/builder/src/test/assets/typebots/integrations/googleSheetsGet.json b/apps/builder/src/test/assets/typebots/integrations/googleSheetsGet.json index fb646ff83..2d42d840d 100644 --- a/apps/builder/src/test/assets/typebots/integrations/googleSheetsGet.json +++ b/apps/builder/src/test/assets/typebots/integrations/googleSheetsGet.json @@ -46,7 +46,9 @@ "id": "s1ZvUqWxV6b8UgFGYWh39pV", "groupId": "jd4S6BQsUQ2RuKieHXYKs9", "type": "Google Sheets", - "options": {}, + "options": { + "spreadsheetId": "1k_pIDw3YHl9tlZusbBVSBRY0PeRPd2H6t4Nj7rwnOtM" + }, "outgoingEdgeId": "tBsPNYzMW1mMSvFMHZpmx8" } ] diff --git a/apps/builder/src/test/global.setup.ts b/apps/builder/src/test/global.setup.ts new file mode 100644 index 000000000..42a15de96 --- /dev/null +++ b/apps/builder/src/test/global.setup.ts @@ -0,0 +1,6 @@ +import { test as setup } from '@playwright/test' +import { globalSetup } from '@typebot.io/playwright/globalSetup' + +setup('setup db', async () => { + await globalSetup() +}) diff --git a/apps/builder/src/test/utils/databaseActions.ts b/apps/builder/src/test/utils/databaseActions.ts index 8c4269190..8db1f273e 100644 --- a/apps/builder/src/test/utils/databaseActions.ts +++ b/apps/builder/src/test/utils/databaseActions.ts @@ -6,7 +6,7 @@ import { Workspace, } from '@typebot.io/prisma' import Stripe from 'stripe' -import { proWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup' +import { proWorkspaceId } from '@typebot.io/playwright/databaseSetup' import { env } from '@typebot.io/env' const prisma = new PrismaClient() diff --git a/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx b/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx index a9960bda6..1922bcef1 100644 --- a/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx +++ b/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx @@ -16,8 +16,8 @@ import { Thead, Tr, } from '@chakra-ui/react' -import { proChatTiers } from '@typebot.io/lib/billing/constants' -import { formatPrice } from '@typebot.io/lib/billing/formatPrice' +import { proChatTiers } from '@typebot.io/billing/constants' +import { formatPrice } from '@typebot.io/billing/formatPrice' type Props = { isOpen: boolean diff --git a/apps/landing-page/components/PricingPage/FreePlanCard.tsx b/apps/landing-page/components/PricingPage/FreePlanCard.tsx index 90c865fad..783561988 100644 --- a/apps/landing-page/components/PricingPage/FreePlanCard.tsx +++ b/apps/landing-page/components/PricingPage/FreePlanCard.tsx @@ -3,7 +3,7 @@ import { HelpCircleIcon } from 'assets/icons/HelpCircleIcon' import Link from 'next/link' import React from 'react' import { PricingCard } from './PricingCard' -import { chatsLimits } from '@typebot.io/lib/billing/constants' +import { chatsLimits } from '@typebot.io/billing/constants' export const FreePlanCard = () => ( void diff --git a/apps/landing-page/components/PricingPage/PricingCard/index.tsx b/apps/landing-page/components/PricingPage/PricingCard/index.tsx index 4fe4906ce..113441e17 100644 --- a/apps/landing-page/components/PricingPage/PricingCard/index.tsx +++ b/apps/landing-page/components/PricingPage/PricingCard/index.tsx @@ -11,7 +11,7 @@ import { import * as React from 'react' import { CheckCircleIcon } from '../../../assets/icons/CheckCircleIcon' import { Card, CardProps } from './Card' -import { formatPrice } from '@typebot.io/lib/billing/formatPrice' +import { formatPrice } from '@typebot.io/billing/formatPrice' export interface PricingCardData { features: React.ReactNode[] diff --git a/apps/landing-page/components/PricingPage/ProPlanCard.tsx b/apps/landing-page/components/PricingPage/ProPlanCard.tsx index bb6108369..54c85cce3 100644 --- a/apps/landing-page/components/PricingPage/ProPlanCard.tsx +++ b/apps/landing-page/components/PricingPage/ProPlanCard.tsx @@ -11,7 +11,7 @@ import { HelpCircleIcon } from 'assets/icons/HelpCircleIcon' import { Plan } from '@typebot.io/prisma' import React from 'react' import { PricingCard } from './PricingCard' -import { prices, seatsLimits } from '@typebot.io/lib/billing/constants' +import { prices, seatsLimits } from '@typebot.io/billing/constants' type Props = { onChatsTiersClick: () => void diff --git a/apps/landing-page/components/PricingPage/StarterPlanCard.tsx b/apps/landing-page/components/PricingPage/StarterPlanCard.tsx index ad40a06cc..ad21202dd 100644 --- a/apps/landing-page/components/PricingPage/StarterPlanCard.tsx +++ b/apps/landing-page/components/PricingPage/StarterPlanCard.tsx @@ -4,7 +4,7 @@ import { Plan } from '@typebot.io/prisma' import Link from 'next/link' import React from 'react' import { PricingCard } from './PricingCard' -import { prices, seatsLimits } from '@typebot.io/lib/billing/constants' +import { prices, seatsLimits } from '@typebot.io/billing/constants' export const StarterPlanCard = () => { return ( diff --git a/apps/landing-page/package.json b/apps/landing-page/package.json index 697b40d1c..ba0b7a029 100644 --- a/apps/landing-page/package.json +++ b/apps/landing-page/package.json @@ -22,7 +22,8 @@ "framer-motion": "10.12.20", "next": "14.1.0", "react": "18.2.0", - "react-dom": "18.2.0" + "react-dom": "18.2.0", + "@typebot.io/billing": "workspace:*" }, "devDependencies": { "@babel/core": "7.22.9", diff --git a/apps/viewer/.prettierignore b/apps/viewer/.prettierignore new file mode 100644 index 000000000..a1f770ea5 --- /dev/null +++ b/apps/viewer/.prettierignore @@ -0,0 +1 @@ +reporters \ No newline at end of file diff --git a/apps/viewer/package.json b/apps/viewer/package.json index 8be77f14d..3a0a48335 100644 --- a/apps/viewer/package.json +++ b/apps/viewer/package.json @@ -9,7 +9,8 @@ "lint": "dotenv -e ./.env -e ../../.env -- next lint", "format:check": "prettier --check ./src", "test": "dotenv -e ./.env -e ../../.env -- pnpm playwright test", - "test:report": "pnpm playwright show-report" + "test:report": "pnpm playwright show-report", + "test:ui": "dotenv -e ./.env -e ../../.env -- pnpm playwright test --ui" }, "dependencies": { "@lilyrose2798/trpc-openapi": "^1.3.9", @@ -35,6 +36,7 @@ "stripe": "12.13.0" }, "devDependencies": { + "dotenv": "16.4.5", "@faire/mjml-react": "3.3.0", "@paralleldrive/cuid2": "2.2.1", "@playwright/test": "1.36.0", @@ -61,6 +63,8 @@ "papaparse": "5.4.1", "superjson": "1.12.4", "typescript": "5.3.2", - "zod": "3.22.4" + "zod": "3.22.4", + "@typebot.io/playwright": "workspace:*", + "@typebot.io/results": "workspace:*" } } diff --git a/apps/viewer/playwright.config.ts b/apps/viewer/playwright.config.ts index 928c303fb..44f664cc8 100644 --- a/apps/viewer/playwright.config.ts +++ b/apps/viewer/playwright.config.ts @@ -1,20 +1,43 @@ -import { PlaywrightTestConfig } from '@playwright/test' -import path from 'path' -import { playwrightBaseConfig } from '@typebot.io/lib/playwright/baseConfig' +import { defineConfig, devices } from '@playwright/test' -const config: PlaywrightTestConfig = { - ...playwrightBaseConfig, - testDir: path.join(__dirname, 'src'), +process.env.SKIP_ENV_CHECK = 'true' + +export default defineConfig({ + timeout: process.env.CI ? 50 * 1000 : 40 * 1000, + expect: { + timeout: process.env.CI ? 10 * 1000 : 5 * 1000, + }, + forbidOnly: !!process.env.CI, + workers: process.env.CI ? 1 : 3, + retries: process.env.CI ? 2 : 0, + reporter: [ + [process.env.CI ? 'github' : 'list'], + ['html', { outputFolder: 'src/test/reporters' }], + ], + maxFailures: process.env.CI ? 10 : undefined, webServer: process.env.CI ? { - ...(playwrightBaseConfig.webServer as { command: string }), + command: 'pnpm run start', + timeout: 60_000, + reuseExistingServer: true, port: 3001, } : undefined, + outputDir: './src/test/results', use: { - ...playwrightBaseConfig.use, + trace: 'on-first-retry', + locale: 'en-US', baseURL: process.env.NEXT_PUBLIC_VIEWER_URL, }, -} - -export default config + projects: [ + { + name: 'setup db', + testMatch: /global\.setup\.ts/, + }, + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + dependencies: ['setup db'], + }, + ], +}) diff --git a/apps/viewer/src/app/api/integrations/openai/streamer/route.ts b/apps/viewer/src/app/api/integrations/openai/streamer/route.ts index 425d93ef1..93be0d999 100644 --- a/apps/viewer/src/app/api/integrations/openai/streamer/route.ts +++ b/apps/viewer/src/app/api/integrations/openai/streamer/route.ts @@ -4,7 +4,7 @@ import { SessionState } from '@typebot.io/schemas' import { StreamingTextResponse } from 'ai' import OpenAI from 'openai' import { NextResponse } from 'next/dist/server/web/spec-extension/response' -import { getBlockById } from '@typebot.io/lib/getBlockById' +import { getBlockById } from '@typebot.io/schemas/helpers' import { forgedBlocks } from '@typebot.io/forge-schemas' import { decryptV2 } from '@typebot.io/lib/api/encryption/decryptV2' import { ReadOnlyVariableStore } from '@typebot.io/forge' diff --git a/apps/viewer/src/features/fileUpload/api/generateUploadUrl.ts b/apps/viewer/src/features/fileUpload/api/generateUploadUrl.ts index 5e1118d43..92457bcf8 100644 --- a/apps/viewer/src/features/fileUpload/api/generateUploadUrl.ts +++ b/apps/viewer/src/features/fileUpload/api/generateUploadUrl.ts @@ -7,7 +7,7 @@ import prisma from '@typebot.io/lib/prisma' import { getSession } from '@typebot.io/bot-engine/queries/getSession' import { parseGroups } from '@typebot.io/schemas' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' -import { getBlockById } from '@typebot.io/lib/getBlockById' +import { getBlockById } from '@typebot.io/schemas/helpers' export const generateUploadUrl = publicProcedure .meta({ diff --git a/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts b/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts index 090616f55..490371fc4 100644 --- a/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts +++ b/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts @@ -9,14 +9,9 @@ import { } from '@typebot.io/schemas' import { NextApiRequest, NextApiResponse } from 'next' import got, { Method, Headers, HTTPError } from 'got' -import { - byId, - isEmpty, - isNotDefined, - isWebhookBlock, - omit, -} from '@typebot.io/lib' -import { parseAnswers } from '@typebot.io/lib/results/parseAnswers' +import { byId, isEmpty, isNotDefined, omit } from '@typebot.io/lib' +import { isWebhookBlock } from '@typebot.io/schemas/helpers' +import { parseAnswers } from '@typebot.io/results/parseAnswers' import { initMiddleware, methodNotAllowed, notFound } from '@typebot.io/lib/api' import { stringify } from 'qs' import Cors from 'cors' @@ -33,7 +28,7 @@ import { defaultWebhookAttributes, maxTimeout, } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants' -import { getBlockById } from '@typebot.io/lib/getBlockById' +import { getBlockById } from '@typebot.io/schemas/helpers' import { convertKeyValueTableToObject, longReqTimeoutWhitelist, diff --git a/apps/viewer/src/pages/api/typebots/[typebotId]/integrations/email.tsx b/apps/viewer/src/pages/api/typebots/[typebotId]/integrations/email.tsx index b36ffb930..d018bf3df 100644 --- a/apps/viewer/src/pages/api/typebots/[typebotId]/integrations/email.tsx +++ b/apps/viewer/src/pages/api/typebots/[typebotId]/integrations/email.tsx @@ -7,7 +7,7 @@ import { import { NextApiRequest, NextApiResponse } from 'next' import { createTransport, getTestMessageUrl } from 'nodemailer' import { isDefined, isEmpty, isNotDefined, omit } from '@typebot.io/lib' -import { parseAnswers } from '@typebot.io/lib/results/parseAnswers' +import { parseAnswers } from '@typebot.io/results/parseAnswers' import { methodNotAllowed, initMiddleware } from '@typebot.io/lib/api' import { decrypt } from '@typebot.io/lib/api/encryption/decrypt' diff --git a/apps/viewer/src/pages/api/typebots/[typebotId]/webhookBlocks.ts b/apps/viewer/src/pages/api/typebots/[typebotId]/webhookBlocks.ts index 7d1402c65..55c873cf3 100644 --- a/apps/viewer/src/pages/api/typebots/[typebotId]/webhookBlocks.ts +++ b/apps/viewer/src/pages/api/typebots/[typebotId]/webhookBlocks.ts @@ -2,7 +2,7 @@ import { authenticateUser } from '@/helpers/authenticateUser' import prisma from '@typebot.io/lib/prisma' import { Group, HttpRequestBlock } from '@typebot.io/schemas' import { NextApiRequest, NextApiResponse } from 'next' -import { isWebhookBlock } from '@typebot.io/lib' +import { isWebhookBlock } from '@typebot.io/schemas/helpers' import { methodNotAllowed } from '@typebot.io/lib/api' const handler = async (req: NextApiRequest, res: NextApiResponse) => { diff --git a/apps/viewer/src/pages/api/typebots/[typebotId]/webhookSteps.ts b/apps/viewer/src/pages/api/typebots/[typebotId]/webhookSteps.ts index be0e256f6..29547121a 100644 --- a/apps/viewer/src/pages/api/typebots/[typebotId]/webhookSteps.ts +++ b/apps/viewer/src/pages/api/typebots/[typebotId]/webhookSteps.ts @@ -2,7 +2,8 @@ import { authenticateUser } from '@/helpers/authenticateUser' import prisma from '@typebot.io/lib/prisma' import { Group } from '@typebot.io/schemas' import { NextApiRequest, NextApiResponse } from 'next' -import { isNotDefined, isWebhookBlock } from '@typebot.io/lib' +import { isNotDefined } from '@typebot.io/lib' +import { isWebhookBlock } from '@typebot.io/schemas/helpers' import { methodNotAllowed } from '@typebot.io/lib/api' const handler = async (req: NextApiRequest, res: NextApiResponse) => { diff --git a/apps/viewer/src/test/chat.spec.ts b/apps/viewer/src/test/chat.spec.ts index 2631b70ff..edddd66c0 100644 --- a/apps/viewer/src/test/chat.spec.ts +++ b/apps/viewer/src/test/chat.spec.ts @@ -7,7 +7,7 @@ import { deleteTypebots, deleteWebhooks, importTypebotInDatabase, -} from '@typebot.io/lib/playwright/databaseActions' +} from '@typebot.io/playwright/databaseActions' import { HttpMethod } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants' import { StartChatInput, StartPreviewChatInput } from '@typebot.io/schemas' diff --git a/apps/viewer/src/test/chatwoot.spec.ts b/apps/viewer/src/test/chatwoot.spec.ts index 83460590f..80b88f72b 100644 --- a/apps/viewer/src/test/chatwoot.spec.ts +++ b/apps/viewer/src/test/chatwoot.spec.ts @@ -1,7 +1,7 @@ import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { createTypebots } from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +import { createTypebots } from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' const typebotId = createId() diff --git a/apps/viewer/src/test/fileUpload.spec.ts b/apps/viewer/src/test/fileUpload.spec.ts index c543726d5..229c96ae5 100644 --- a/apps/viewer/src/test/fileUpload.spec.ts +++ b/apps/viewer/src/test/fileUpload.spec.ts @@ -3,7 +3,7 @@ import { createId } from '@paralleldrive/cuid2' import { parse } from 'papaparse' import { readFileSync } from 'fs' import { isDefined } from '@typebot.io/lib' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { getTestAsset } from '@/test/utils/playwright' import { env } from '@typebot.io/env' diff --git a/apps/viewer/src/test/global.setup.ts b/apps/viewer/src/test/global.setup.ts new file mode 100644 index 000000000..42a15de96 --- /dev/null +++ b/apps/viewer/src/test/global.setup.ts @@ -0,0 +1,6 @@ +import { test as setup } from '@playwright/test' +import { globalSetup } from '@typebot.io/playwright/globalSetup' + +setup('setup db', async () => { + await globalSetup() +}) diff --git a/apps/viewer/src/test/results.spec.ts b/apps/viewer/src/test/results.spec.ts index 5b0764c10..addfc45df 100644 --- a/apps/viewer/src/test/results.spec.ts +++ b/apps/viewer/src/test/results.spec.ts @@ -1,7 +1,7 @@ import { getTestAsset } from '@/test/utils/playwright' import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { env } from '@typebot.io/env' test('Big groups should work as expected', async ({ page }) => { diff --git a/apps/viewer/src/test/sendEmail.spec.ts b/apps/viewer/src/test/sendEmail.spec.ts index 91c24f62c..ac1e570ef 100644 --- a/apps/viewer/src/test/sendEmail.spec.ts +++ b/apps/viewer/src/test/sendEmail.spec.ts @@ -1,6 +1,6 @@ import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' import { SmtpCredentials } from '@typebot.io/schemas' import { env } from '@typebot.io/env' import { createSmtpCredentials } from './utils/databaseActions' diff --git a/apps/viewer/src/test/settings.spec.ts b/apps/viewer/src/test/settings.spec.ts index b94e158fb..49b80aecd 100644 --- a/apps/viewer/src/test/settings.spec.ts +++ b/apps/viewer/src/test/settings.spec.ts @@ -3,8 +3,8 @@ import { createId } from '@paralleldrive/cuid2' import { createTypebots, updateTypebot, -} from '@typebot.io/lib/playwright/databaseActions' -import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers' +} from '@typebot.io/playwright/databaseActions' +import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { Settings } from '@typebot.io/schemas' import { defaultTextInputOptions } from '@typebot.io/schemas/features/blocks/inputs/text/constants' diff --git a/apps/viewer/src/test/typebotLink.spec.ts b/apps/viewer/src/test/typebotLink.spec.ts index 0e240f923..c4cee2bf5 100644 --- a/apps/viewer/src/test/typebotLink.spec.ts +++ b/apps/viewer/src/test/typebotLink.spec.ts @@ -1,7 +1,7 @@ import { getTestAsset } from '@/test/utils/playwright' import test, { expect } from '@playwright/test' import { env } from '@typebot.io/env' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' const typebotId = 'cl0ibhi7s0018n21aarlmg0cm' const typebotWithMergeDisabledId = 'cl0ibhi7s0018n21aarlag0cm' diff --git a/apps/viewer/src/test/utils/databaseActions.ts b/apps/viewer/src/test/utils/databaseActions.ts index bec240ff9..c7303202e 100644 --- a/apps/viewer/src/test/utils/databaseActions.ts +++ b/apps/viewer/src/test/utils/databaseActions.ts @@ -1,7 +1,7 @@ import { PrismaClient } from '@typebot.io/prisma' import { SmtpCredentials } from '@typebot.io/schemas' import { encrypt } from '@typebot.io/lib/api/encryption/encrypt' -import { proWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup' +import { proWorkspaceId } from '@typebot.io/playwright/databaseSetup' const prisma = new PrismaClient() diff --git a/apps/viewer/src/test/variables.spec.ts b/apps/viewer/src/test/variables.spec.ts index b1b21be70..492377b67 100644 --- a/apps/viewer/src/test/variables.spec.ts +++ b/apps/viewer/src/test/variables.spec.ts @@ -1,7 +1,7 @@ import { getTestAsset } from '@/test/utils/playwright' import test, { expect } from '@playwright/test' import { createId } from '@paralleldrive/cuid2' -import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions' +import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions' test('should correctly be injected', async ({ page }) => { const typebotId = createId() diff --git a/apps/viewer/src/test/webhook.spec.ts b/apps/viewer/src/test/webhook.spec.ts index 1d0b2b0e2..ee9d42551 100644 --- a/apps/viewer/src/test/webhook.spec.ts +++ b/apps/viewer/src/test/webhook.spec.ts @@ -3,7 +3,7 @@ import { createId } from '@paralleldrive/cuid2' import { createWebhook, importTypebotInDatabase, -} from '@typebot.io/lib/playwright/databaseActions' +} from '@typebot.io/playwright/databaseActions' import { getTestAsset } from '@/test/utils/playwright' import { HttpMethod } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants' diff --git a/package.json b/package.json index e4e8bd7bc..5b3f585ae 100644 --- a/package.json +++ b/package.json @@ -32,5 +32,5 @@ "path": "node_modules/cz-emoji" } }, - "packageManager": "pnpm@8.14.1" + "packageManager": "pnpm@8.15.4" } diff --git a/packages/lib/billing/constants.ts b/packages/billing/constants.ts similarity index 100% rename from packages/lib/billing/constants.ts rename to packages/billing/constants.ts diff --git a/packages/lib/billing/formatPrice.ts b/packages/billing/formatPrice.ts similarity index 100% rename from packages/lib/billing/formatPrice.ts rename to packages/billing/formatPrice.ts diff --git a/packages/lib/billing/getChatsLimit.ts b/packages/billing/getChatsLimit.ts similarity index 100% rename from packages/lib/billing/getChatsLimit.ts rename to packages/billing/getChatsLimit.ts diff --git a/packages/lib/billing/getSeatsLimit.ts b/packages/billing/getSeatsLimit.ts similarity index 100% rename from packages/lib/billing/getSeatsLimit.ts rename to packages/billing/getSeatsLimit.ts diff --git a/packages/lib/billing/guessIfUserIsEuropean.ts b/packages/billing/guessIfUserIsEuropean.ts similarity index 100% rename from packages/lib/billing/guessIfUserIsEuropean.ts rename to packages/billing/guessIfUserIsEuropean.ts diff --git a/packages/billing/package.json b/packages/billing/package.json new file mode 100644 index 000000000..fca687e88 --- /dev/null +++ b/packages/billing/package.json @@ -0,0 +1,20 @@ +{ + "name": "@typebot.io/billing", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "Baptiste Arnaud", + "license": "ISC", + "dependencies": { + "@typebot.io/prisma": "workspace:*", + "@typebot.io/schemas": "workspace:*", + "stripe": "12.13.0" + }, + "devDependencies": { + "@typebot.io/tsconfig": "workspace:*" + } +} diff --git a/packages/billing/tsconfig.json b/packages/billing/tsconfig.json new file mode 100644 index 000000000..075fbaa1f --- /dev/null +++ b/packages/billing/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@typebot.io/tsconfig/base.json", + "include": ["**/*.ts"], + "exclude": ["node_modules"], + "compilerOptions": { + "lib": ["ES2021", "DOM"] + } +} diff --git a/packages/bot-engine/blocks/integrations/sendEmail/executeSendEmailBlock.tsx b/packages/bot-engine/blocks/integrations/sendEmail/executeSendEmailBlock.tsx index f99065912..36161dd87 100644 --- a/packages/bot-engine/blocks/integrations/sendEmail/executeSendEmailBlock.tsx +++ b/packages/bot-engine/blocks/integrations/sendEmail/executeSendEmailBlock.tsx @@ -19,7 +19,7 @@ import { ExecuteIntegrationResponse } from '../../../types' import prisma from '@typebot.io/lib/prisma' import { parseVariables } from '@typebot.io/variables/parseVariables' import { defaultSendEmailOptions } from '@typebot.io/schemas/features/blocks/integrations/sendEmail/constants' -import { parseAnswers } from '@typebot.io/lib/results/parseAnswers' +import { parseAnswers } from '@typebot.io/results/parseAnswers' export const sendEmailSuccessDescription = 'Email successfully sent' export const sendEmailErrorDescription = 'Email not sent' diff --git a/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts b/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts index 71dc7f668..2e8ab6961 100644 --- a/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts +++ b/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts @@ -26,7 +26,7 @@ import { maxTimeout, } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants' import { env } from '@typebot.io/env' -import { parseAnswers } from '@typebot.io/lib/results/parseAnswers' +import { parseAnswers } from '@typebot.io/results/parseAnswers' type ParsedWebhook = ExecutableHttpRequest & { basicAuth: { username?: string; password?: string } diff --git a/packages/bot-engine/blocks/integrations/webhook/parseSampleResult.ts b/packages/bot-engine/blocks/integrations/webhook/parseSampleResult.ts index 38a8f27df..e3499f054 100644 --- a/packages/bot-engine/blocks/integrations/webhook/parseSampleResult.ts +++ b/packages/bot-engine/blocks/integrations/webhook/parseSampleResult.ts @@ -7,15 +7,17 @@ import { TypebotLinkBlock, Variable, } from '@typebot.io/schemas' -import { isInputBlock, byId, isNotDefined } from '@typebot.io/lib' +import { byId, isNotDefined } from '@typebot.io/lib' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants' -import { parseResultHeader } from '@typebot.io/lib/results/parseResultHeader' +import { parseResultHeader } from '@typebot.io/results/parseResultHeader' export const parseSampleResult = ( typebot: Pick, - linkedTypebots: (Typebot | PublicTypebot)[] + linkedTypebots: (Typebot | PublicTypebot)[], + userEmail?: string ) => async ( currentGroupId: string, @@ -30,7 +32,7 @@ export const parseSampleResult = return { message: 'This is a sample result, it has been generated ⬇️', submittedAt: new Date().toISOString(), - ...parseResultSample(linkedInputBlocks, header, variables), + ...parseResultSample(linkedInputBlocks, header, variables, userEmail), } } @@ -83,7 +85,8 @@ const extractLinkedInputBlocks = const parseResultSample = ( inputBlocks: InputBlock[], headerCells: ResultHeaderCell[], - variables: Variable[] + variables: Variable[], + userEmail?: string ) => headerCells.reduce>( (resultSample, cell) => { @@ -107,7 +110,7 @@ const parseResultSample = ( const variableValue = variables.find( (variable) => cell.variableIds?.includes(variable.id) && variable.value )?.value - const value = variableValue ?? getSampleValue(inputBlock) + const value = variableValue ?? getSampleValue(inputBlock, userEmail) return { ...resultSample, [cell.label]: value, @@ -116,7 +119,7 @@ const parseResultSample = ( {} ) -const getSampleValue = (block: InputBlock): string => { +const getSampleValue = (block: InputBlock, userEmail?: string): string => { switch (block.type) { case InputBlockType.CHOICE: return block.options?.isMultipleChoice @@ -125,7 +128,7 @@ const getSampleValue = (block: InputBlock): string => { case InputBlockType.DATE: return new Date().toUTCString() case InputBlockType.EMAIL: - return 'test@email.com' + return userEmail ?? 'test@email.com' case InputBlockType.NUMBER: return '20' case InputBlockType.PHONE: diff --git a/packages/bot-engine/blocks/integrations/zemanticAi/executeZemanticAiBlock.ts b/packages/bot-engine/blocks/integrations/zemanticAi/executeZemanticAiBlock.ts index 1fb199dbf..edaba5487 100644 --- a/packages/bot-engine/blocks/integrations/zemanticAi/executeZemanticAiBlock.ts +++ b/packages/bot-engine/blocks/integrations/zemanticAi/executeZemanticAiBlock.ts @@ -10,7 +10,7 @@ import { byId, isDefined, isEmpty } from '@typebot.io/lib' import prisma from '@typebot.io/lib/prisma' import { ExecuteIntegrationResponse } from '../../../types' import { updateVariablesInSession } from '@typebot.io/variables/updateVariablesInSession' -import { parseAnswers } from '@typebot.io/lib/results/parseAnswers' +import { parseAnswers } from '@typebot.io/results/parseAnswers' const URL = 'https://api.zemantic.ai/v1/search-documents' diff --git a/packages/bot-engine/computeCurrentProgress.ts b/packages/bot-engine/computeCurrentProgress.ts index c5ce72d8c..9958faa3e 100644 --- a/packages/bot-engine/computeCurrentProgress.ts +++ b/packages/bot-engine/computeCurrentProgress.ts @@ -1,5 +1,9 @@ -import { blockHasItems, isDefined, isInputBlock, byId } from '@typebot.io/lib' -import { getBlockById } from '@typebot.io/lib/getBlockById' +import { isDefined, byId } from '@typebot.io/lib' +import { + getBlockById, + blockHasItems, + isInputBlock, +} from '@typebot.io/schemas/helpers' import { Block, SessionState } from '@typebot.io/schemas' type Props = { diff --git a/packages/bot-engine/continueBotFlow.ts b/packages/bot-engine/continueBotFlow.ts index 689247641..810315672 100644 --- a/packages/bot-engine/continueBotFlow.ts +++ b/packages/bot-engine/continueBotFlow.ts @@ -6,7 +6,8 @@ import { InputBlock, SessionState, } from '@typebot.io/schemas' -import { isInputBlock, byId } from '@typebot.io/lib' +import { byId } from '@typebot.io/lib' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { executeGroup, parseInput } from './executeGroup' import { getNextGroup } from './getNextGroup' import { validateEmail } from './blocks/inputs/email/validateEmail' @@ -34,7 +35,7 @@ import { defaultChoiceInputOptions } from '@typebot.io/schemas/features/blocks/i import { defaultPictureChoiceOptions } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice/constants' import { defaultFileInputOptions } from '@typebot.io/schemas/features/blocks/inputs/file/constants' import { VisitedEdge } from '@typebot.io/prisma' -import { getBlockById } from '@typebot.io/lib/getBlockById' +import { getBlockById } from '@typebot.io/schemas/helpers' import { ForgedBlock, forgedBlocks } from '@typebot.io/forge-schemas' import { enabledBlocks } from '@typebot.io/forge-repository' import { resumeChatCompletion } from './blocks/integrations/legacy/openai/resumeChatCompletion' diff --git a/packages/bot-engine/executeGroup.ts b/packages/bot-engine/executeGroup.ts index 911c7190b..c5beeb59f 100644 --- a/packages/bot-engine/executeGroup.ts +++ b/packages/bot-engine/executeGroup.ts @@ -5,13 +5,13 @@ import { RuntimeOptions, SessionState, } from '@typebot.io/schemas' +import { isNotEmpty } from '@typebot.io/lib' import { isBubbleBlock, isInputBlock, isIntegrationBlock, isLogicBlock, - isNotEmpty, -} from '@typebot.io/lib' +} from '@typebot.io/schemas/helpers' import { getNextGroup } from './getNextGroup' import { executeLogic } from './executeLogic' import { executeIntegration } from './executeIntegration' diff --git a/packages/bot-engine/package.json b/packages/bot-engine/package.json index 49b56939d..7b35acba3 100644 --- a/packages/bot-engine/package.json +++ b/packages/bot-engine/package.json @@ -30,7 +30,8 @@ "nodemailer": "6.9.3", "openai": "4.28.4", "qs": "6.11.2", - "stripe": "12.13.0" + "stripe": "12.13.0", + "@typebot.io/results": "workspace:*" }, "devDependencies": { "@typebot.io/forge": "workspace:*", diff --git a/packages/bot-engine/parseBubbleBlock.ts b/packages/bot-engine/parseBubbleBlock.ts index 44330cbaa..f943e1d07 100644 --- a/packages/bot-engine/parseBubbleBlock.ts +++ b/packages/bot-engine/parseBubbleBlock.ts @@ -1,4 +1,4 @@ -import { parseVideoUrl } from '@typebot.io/lib/parseVideoUrl' +import { parseVideoUrl } from '@typebot.io/schemas/features/blocks/bubbles/video/helpers' import { BubbleBlock, Variable, diff --git a/packages/bot-engine/startSession.ts b/packages/bot-engine/startSession.ts index 2218921c4..76333a497 100644 --- a/packages/bot-engine/startSession.ts +++ b/packages/bot-engine/startSession.ts @@ -1,6 +1,7 @@ import { createId } from '@paralleldrive/cuid2' import { TRPCError } from '@trpc/server' -import { isDefined, omit, isNotEmpty, isInputBlock } from '@typebot.io/lib' +import { isDefined, omit, isNotEmpty } from '@typebot.io/lib' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { Variable, VariableWithValue, diff --git a/packages/deprecated/bot-engine/src/components/ChatGroup/ChatBlock/InputChatBlock.tsx b/packages/deprecated/bot-engine/src/components/ChatGroup/ChatBlock/InputChatBlock.tsx index 028a32264..f24c66420 100644 --- a/packages/deprecated/bot-engine/src/components/ChatGroup/ChatBlock/InputChatBlock.tsx +++ b/packages/deprecated/bot-engine/src/components/ChatGroup/ChatBlock/InputChatBlock.tsx @@ -19,7 +19,7 @@ import { RatingForm } from '@/features/blocks/inputs/rating' import { FileUploadForm } from '@/features/blocks/inputs/fileUpload' import { defaultSettings } from '@typebot.io/schemas/features/typebot/settings/constants' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' -import { getBlockById } from '@typebot.io/lib/getBlockById' +import { getBlockById } from '@typebot.io/schemas/helpers' export const InputChatBlock = ({ block, diff --git a/packages/deprecated/bot-engine/src/components/ChatGroup/ChatGroup.tsx b/packages/deprecated/bot-engine/src/components/ChatGroup/ChatGroup.tsx index a6d4713aa..306595c50 100644 --- a/packages/deprecated/bot-engine/src/components/ChatGroup/ChatGroup.tsx +++ b/packages/deprecated/bot-engine/src/components/ChatGroup/ChatGroup.tsx @@ -2,16 +2,15 @@ import { useEffect, useRef, useState } from 'react' import { TransitionGroup, CSSTransition } from 'react-transition-group' import { AvatarSideContainer } from './AvatarSideContainer' import { LinkedTypebot, useTypebot } from '../../providers/TypebotProvider' +import { isDefined, byId } from '@typebot.io/lib' import { isBubbleBlock, isBubbleBlockType, isChoiceInput, - isDefined, isInputBlock, isIntegrationBlock, isLogicBlock, - byId, -} from '@typebot.io/lib' +} from '@typebot.io/schemas/helpers' import { BubbleBlock, InputBlock, @@ -30,7 +29,7 @@ import { executeLogic } from '@/utils/executeLogic' import { blockCanBeRetried, parseRetryBlock } from '@/utils/inputs' import { PopupBlockedToast } from '../PopupBlockedToast' import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants' -import { getBlockById } from '@typebot.io/lib/getBlockById' +import { getBlockById } from '@typebot.io/schemas/helpers' type ChatGroupProps = { blocks: Block[] diff --git a/packages/deprecated/bot-engine/src/components/ConversationContainer.tsx b/packages/deprecated/bot-engine/src/components/ConversationContainer.tsx index de83427e4..d222237c8 100644 --- a/packages/deprecated/bot-engine/src/components/ConversationContainer.tsx +++ b/packages/deprecated/bot-engine/src/components/ConversationContainer.tsx @@ -8,7 +8,8 @@ import { Theme, VariableWithValue, } from '@typebot.io/schemas' -import { byId, isDefined, isInputBlock, isNotDefined } from '@typebot.io/lib' +import { byId, isDefined, isNotDefined } from '@typebot.io/lib' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { animateScroll as scroll } from 'react-scroll' import { LinkedTypebot, useTypebot } from '@/providers/TypebotProvider' import { setCssVariablesValue } from '@/features/theme' diff --git a/packages/deprecated/bot-engine/src/utils/chat.ts b/packages/deprecated/bot-engine/src/utils/chat.ts index bcfec0a13..1365c6236 100644 --- a/packages/deprecated/bot-engine/src/utils/chat.ts +++ b/packages/deprecated/bot-engine/src/utils/chat.ts @@ -1,5 +1,5 @@ import { BubbleBlock, InputBlock, Block } from '@typebot.io/schemas' -import { isBubbleBlock, isInputBlock } from '@typebot.io/lib' +import { isInputBlock, isBubbleBlock } from '@typebot.io/schemas/helpers' import type { TypebotPostMessageData } from 'typebot-js' import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' diff --git a/packages/deprecated/bot-engine/src/utils/inputs.ts b/packages/deprecated/bot-engine/src/utils/inputs.ts index c2753db7f..8d6a361e8 100644 --- a/packages/deprecated/bot-engine/src/utils/inputs.ts +++ b/packages/deprecated/bot-engine/src/utils/inputs.ts @@ -11,7 +11,8 @@ import { UrlInputBlock, Variable, } from '@typebot.io/schemas' -import { isDefined, isInputBlock } from '@typebot.io/lib' +import { isDefined } from '@typebot.io/lib' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants' diff --git a/packages/lib/getBlockById.ts b/packages/lib/getBlockById.ts deleted file mode 100644 index 74c5e21a7..000000000 --- a/packages/lib/getBlockById.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Block, Group } from '@typebot.io/schemas' - -export const getBlockById = ( - blockId: string, - groups: Group[] -): { block: Block; group: Group; blockIndex: number; groupIndex: number } => { - for (let groupIndex = 0; groupIndex < groups.length; groupIndex++) { - for ( - let blockIndex = 0; - blockIndex < (groups.at(groupIndex)?.blocks?.length ?? 0); - blockIndex++ - ) { - if (groups.at(groupIndex)?.blocks?.at(blockIndex)?.id === blockId) { - return { - block: groups[groupIndex].blocks[blockIndex], - group: groups[groupIndex], - blockIndex, - groupIndex, - } - } - } - } - throw new Error(`Block with id ${blockId} was not found`) -} diff --git a/packages/lib/google.ts b/packages/lib/google.ts index 663bbf415..5f4ab3093 100644 --- a/packages/lib/google.ts +++ b/packages/lib/google.ts @@ -1,6 +1,5 @@ import { env } from '@typebot.io/env' import { Credentials as CredentialsFromDb } from '@typebot.io/prisma' -import { GoogleSheetsCredentials } from '@typebot.io/schemas' import { decrypt } from './api/encryption/decrypt' import { encrypt } from './api/encryption/encrypt' import prisma from './prisma' @@ -14,10 +13,7 @@ export const getAuthenticatedGoogleClient = async ( where: { id: credentialsId }, })) as CredentialsFromDb | undefined if (!credentials) return - const data = (await decrypt( - credentials.data, - credentials.iv - )) as GoogleSheetsCredentials['data'] + const data = await decrypt(credentials.data, credentials.iv) const oauth2Client = new OAuth2Client( env.GOOGLE_CLIENT_ID, @@ -30,17 +26,14 @@ export const getAuthenticatedGoogleClient = async ( } const updateTokens = - ( - credentialsId: string, - existingCredentials: GoogleSheetsCredentials['data'] - ) => + (credentialsId: string, existingCredentials: any) => async (credentials: Credentials) => { if ( isDefined(existingCredentials.id_token) && credentials.id_token !== existingCredentials.id_token ) return - const newCredentials: GoogleSheetsCredentials['data'] = { + const newCredentials = { ...existingCredentials, expiry_date: credentials.expiry_date, access_token: credentials.access_token, diff --git a/packages/lib/mockedUser.ts b/packages/lib/mockedUser.ts index e93617ae0..1b6b8fa77 100644 --- a/packages/lib/mockedUser.ts +++ b/packages/lib/mockedUser.ts @@ -1,5 +1,4 @@ import { User } from '@typebot.io/prisma' -import { graphGestureNotficationKey } from '@typebot.io/schemas/features/user/constants' export const mockedUser: User = { id: 'userId', @@ -15,7 +14,7 @@ export const mockedUser: User = { onboardingCategories: [], updatedAt: new Date('2022-01-01'), displayedInAppNotifications: { - [graphGestureNotficationKey]: true, + ['graphGestureNotification']: true, }, referral: null, } diff --git a/packages/lib/package.json b/packages/lib/package.json index 05d251ce1..d77f2abde 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -11,7 +11,6 @@ "@typebot.io/env": "workspace:*", "@typebot.io/forge-repository": "workspace:*", "@typebot.io/prisma": "workspace:*", - "@typebot.io/schemas": "workspace:*", "@typebot.io/tsconfig": "workspace:*", "@types/escape-html": "^1.0.4", "@types/nodemailer": "6.4.8", diff --git a/packages/lib/playwright/baseConfig.ts b/packages/lib/playwright/baseConfig.ts deleted file mode 100644 index 9c2e55865..000000000 --- a/packages/lib/playwright/baseConfig.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { PlaywrightTestConfig } from '@playwright/test' -import path from 'path' - -export const playwrightBaseConfig: PlaywrightTestConfig = { - globalSetup: require.resolve(path.join(__dirname, 'globalSetup')), - timeout: process.env.CI ? 50 * 1000 : 40 * 1000, - expect: { - timeout: process.env.CI ? 10 * 1000 : 5 * 1000, - }, - retries: 0, - workers: process.env.CI ? 2 : 3, - reporter: [ - [process.env.CI ? 'github' : 'list'], - ['html', { outputFolder: 'src/test/reporters' }], - ], - maxFailures: process.env.CI ? 10 : undefined, - webServer: process.env.CI - ? { - command: 'pnpm run start', - timeout: 60_000, - reuseExistingServer: true, - } - : undefined, - outputDir: './src/test/results', - use: { - trace: 'on-first-retry', - video: 'retain-on-failure', - locale: 'en-US', - browserName: 'chromium', - viewport: { width: 1400, height: 1000 }, - }, -} diff --git a/packages/lib/playwright/globalSetup.ts b/packages/lib/playwright/globalSetup.ts deleted file mode 100644 index 0a92188ab..000000000 --- a/packages/lib/playwright/globalSetup.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { FullConfig } from '@playwright/test' -import { setupDatabase, teardownDatabase } from './databaseSetup' - -async function globalSetup(config: FullConfig) { - const { baseURL } = config.projects[0].use - if (!baseURL) throw new Error('baseURL is missing') - await teardownDatabase() - await setupDatabase() -} - -export default globalSetup diff --git a/packages/lib/utils.ts b/packages/lib/utils.ts index 57da0d088..38873c147 100644 --- a/packages/lib/utils.ts +++ b/packages/lib/utils.ts @@ -1,26 +1,3 @@ -import type { - BubbleBlock, - ChoiceInputBlock, - ConditionBlock, - InputBlock, - IntegrationBlock, - LogicBlock, - Block, - TextInputBlock, - TextBubbleBlock, - HttpRequestBlock, - ImageBubbleBlock, - VideoBubbleBlock, - BlockWithOptionsType, -} from '@typebot.io/schemas' -import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants' -import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' -import { PictureChoiceBlock } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice' -import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' -import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants' -import { defaultChoiceInputOptions } from '@typebot.io/schemas/features/blocks/inputs/choice/constants' -import { enabledBlocks } from '@typebot.io/forge-repository' - export const sendRequest = async ( params: | { @@ -72,88 +49,6 @@ export const isEmpty = ( export const isNotEmpty = (value: string | undefined | null): value is string => value !== undefined && value !== null && value !== '' -export const isInputBlock = (block: Block): block is InputBlock => - (Object.values(InputBlockType) as string[]).includes(block.type) - -export const isBubbleBlock = (block: Block): block is BubbleBlock => - (Object.values(BubbleBlockType) as string[]).includes(block.type) - -export const isLogicBlock = (block: Block): block is LogicBlock => - (Object.values(LogicBlockType) as string[]).includes(block.type) - -export const isTextBubbleBlock = (block: Block): block is TextBubbleBlock => - block.type === BubbleBlockType.TEXT - -export const isMediaBubbleBlock = ( - block: Block -): block is ImageBubbleBlock | VideoBubbleBlock => - block.type === BubbleBlockType.IMAGE || block.type === BubbleBlockType.VIDEO - -export const isTextInputBlock = (block: Block): block is TextInputBlock => - block.type === InputBlockType.TEXT - -export const isChoiceInput = (block: Block): block is ChoiceInputBlock => - block.type === InputBlockType.CHOICE - -export const isPictureChoiceInput = ( - block: Block -): block is PictureChoiceBlock => block.type === InputBlockType.PICTURE_CHOICE - -export const isSingleChoiceInput = (block: Block): block is ChoiceInputBlock => - block.type === InputBlockType.CHOICE && - 'options' in block && - !( - block.options?.isMultipleChoice ?? - defaultChoiceInputOptions.isMultipleChoice - ) - -export const isConditionBlock = (block: Block): block is ConditionBlock => - block.type === LogicBlockType.CONDITION - -export const isIntegrationBlock = (block: Block): block is IntegrationBlock => - ( - Object.values(IntegrationBlockType).concat( - enabledBlocks as readonly any[] - ) as any[] - ).includes(block.type) - -export const isWebhookBlock = (block: Block): block is HttpRequestBlock => - [ - IntegrationBlockType.WEBHOOK, - IntegrationBlockType.PABBLY_CONNECT, - IntegrationBlockType.ZAPIER, - IntegrationBlockType.MAKE_COM, - ].includes(block.type as IntegrationBlockType) - -export const isBubbleBlockType = ( - type: Block['type'] -): type is BubbleBlockType => - (Object.values(BubbleBlockType) as string[]).includes(type) - -export const blockTypeHasOption = ( - type: Block['type'] -): type is BlockWithOptionsType => - (Object.values(InputBlockType) as string[]) - .concat(Object.values(LogicBlockType)) - .concat(Object.values(IntegrationBlockType)) - .includes(type) - -export const blockTypeHasItems = ( - type: Block['type'] -): type is - | LogicBlockType.CONDITION - | InputBlockType.CHOICE - | LogicBlockType.AB_TEST => - type === LogicBlockType.CONDITION || - type === InputBlockType.CHOICE || - type === LogicBlockType.AB_TEST || - type === InputBlockType.PICTURE_CHOICE - -export const blockHasItems = ( - block: Block -): block is ConditionBlock | ChoiceInputBlock => - 'items' in block && isDefined(block.items) - export const byId = (id?: string) => (obj: { id: string }) => obj.id === id export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1) diff --git a/packages/lib/migrations/migratePublicTypebot.ts b/packages/migrations/migratePublicTypebot.ts similarity index 100% rename from packages/lib/migrations/migratePublicTypebot.ts rename to packages/migrations/migratePublicTypebot.ts diff --git a/packages/lib/migrations/migrateTypebot.ts b/packages/migrations/migrateTypebot.ts similarity index 100% rename from packages/lib/migrations/migrateTypebot.ts rename to packages/migrations/migrateTypebot.ts diff --git a/packages/lib/migrations/migrateTypebotFromV3ToV4.ts b/packages/migrations/migrateTypebotFromV3ToV4.ts similarity index 92% rename from packages/lib/migrations/migrateTypebotFromV3ToV4.ts rename to packages/migrations/migrateTypebotFromV3ToV4.ts index ad75ae0ee..400533ce8 100644 --- a/packages/lib/migrations/migrateTypebotFromV3ToV4.ts +++ b/packages/migrations/migrateTypebotFromV3ToV4.ts @@ -5,8 +5,9 @@ import { TypebotV5, HttpRequest, } from '@typebot.io/schemas' -import { isWebhookBlock, isDefined } from '../utils' -import prisma from '../prisma' +import { isWebhookBlock } from '@typebot.io/schemas/helpers' +import { isDefined } from '@typebot.io/lib/utils' +import prisma from '@typebot.io/lib/prisma' import { HttpMethod, defaultWebhookAttributes, diff --git a/packages/lib/migrations/migrateTypebotFromV5ToV6.ts b/packages/migrations/migrateTypebotFromV5ToV6.ts similarity index 97% rename from packages/lib/migrations/migrateTypebotFromV5ToV6.ts rename to packages/migrations/migrateTypebotFromV5ToV6.ts index 7733b1acb..94ae7afb9 100644 --- a/packages/lib/migrations/migrateTypebotFromV5ToV6.ts +++ b/packages/migrations/migrateTypebotFromV5ToV6.ts @@ -11,9 +11,9 @@ import { import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' import { GoogleSheetsAction } from '@typebot.io/schemas/features/blocks/integrations/googleSheets/constants' import { ComparisonOperators } from '@typebot.io/schemas/features/blocks/logic/condition/constants' -import { createId } from '@paralleldrive/cuid2' +import { createId } from '@typebot.io/lib/createId' import { EventType } from '@typebot.io/schemas/features/events/constants' -import { byId } from '../utils' +import { byId } from '@typebot.io/lib/utils' export const migrateTypebotFromV5ToV6 = async ( typebot: TypebotV5 | PublicTypebotV5 diff --git a/packages/migrations/package.json b/packages/migrations/package.json new file mode 100644 index 000000000..a238e0ec0 --- /dev/null +++ b/packages/migrations/package.json @@ -0,0 +1,17 @@ +{ + "name": "@typebot.io/migrations", + "version": "1.0.0", + "description": "", + "scripts": {}, + "keywords": [], + "author": "Baptiste Arnaud", + "license": "ISC", + "dependencies": { + "@typebot.io/schemas": "workspace:*", + "@typebot.io/lib": "workspace:*", + "@typebot.io/prisma": "workspace:*" + }, + "devDependencies": { + "@typebot.io/tsconfig": "workspace:*" + } +} diff --git a/packages/migrations/tsconfig.json b/packages/migrations/tsconfig.json new file mode 100644 index 000000000..075fbaa1f --- /dev/null +++ b/packages/migrations/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@typebot.io/tsconfig/base.json", + "include": ["**/*.ts"], + "exclude": ["node_modules"], + "compilerOptions": { + "lib": ["ES2021", "DOM"] + } +} diff --git a/packages/lib/playwright/databaseActions.ts b/packages/playwright/databaseActions.ts similarity index 99% rename from packages/lib/playwright/databaseActions.ts rename to packages/playwright/databaseActions.ts index 8ea590912..2541d8069 100644 --- a/packages/lib/playwright/databaseActions.ts +++ b/packages/playwright/databaseActions.ts @@ -6,7 +6,7 @@ import { Workspace, WorkspaceRole, } from '@typebot.io/prisma' -import { createId } from '@paralleldrive/cuid2' +import { createId } from '@typebot.io/lib/createId' import { Typebot, TypebotV6, HttpRequest } from '@typebot.io/schemas' import { readFileSync } from 'fs' import { proWorkspaceId, userId } from './databaseSetup' diff --git a/packages/lib/playwright/databaseHelpers.ts b/packages/playwright/databaseHelpers.ts similarity index 96% rename from packages/lib/playwright/databaseHelpers.ts rename to packages/playwright/databaseHelpers.ts index b66476ee8..793e28cb1 100644 --- a/packages/lib/playwright/databaseHelpers.ts +++ b/packages/playwright/databaseHelpers.ts @@ -1,13 +1,12 @@ -import { createId } from '@paralleldrive/cuid2' import { BlockV5, BlockV6, - Group, PublicTypebot, Typebot, TypebotV6, } from '@typebot.io/schemas' -import { isDefined } from '../utils' +import { isDefined } from '@typebot.io/lib/utils' +import { createId } from '@typebot.io/lib/createId' import { proWorkspaceId } from './databaseSetup' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' import { EventType } from '@typebot.io/schemas/features/events/constants' diff --git a/packages/lib/playwright/databaseSetup.ts b/packages/playwright/databaseSetup.ts similarity index 98% rename from packages/lib/playwright/databaseSetup.ts rename to packages/playwright/databaseSetup.ts index 03f7826b9..8c12f4a35 100644 --- a/packages/lib/playwright/databaseSetup.ts +++ b/packages/playwright/databaseSetup.ts @@ -4,7 +4,7 @@ import { PrismaClient, WorkspaceRole, } from '@typebot.io/prisma' -import { encrypt } from '../api/encryption/encrypt' +import { encrypt } from '@typebot.io/lib/api/encryption/encrypt' const prisma = new PrismaClient() diff --git a/packages/playwright/globalSetup.ts b/packages/playwright/globalSetup.ts new file mode 100644 index 000000000..668836055 --- /dev/null +++ b/packages/playwright/globalSetup.ts @@ -0,0 +1,6 @@ +import { setupDatabase, teardownDatabase } from './databaseSetup' + +export const globalSetup = async () => { + await teardownDatabase() + await setupDatabase() +} diff --git a/packages/playwright/package.json b/packages/playwright/package.json new file mode 100644 index 000000000..c5778293b --- /dev/null +++ b/packages/playwright/package.json @@ -0,0 +1,19 @@ +{ + "name": "@typebot.io/playwright", + "version": "1.0.0", + "description": "", + "scripts": {}, + "keywords": [], + "author": "Baptiste Arnaud", + "license": "ISC", + "dependencies": { + "@playwright/test": "^1.42.1", + "@typebot.io/lib": "workspace:*", + "@typebot.io/prisma": "workspace:*", + "@typebot.io/schemas": "workspace:*" + }, + "devDependencies": { + "@types/node": "^20.11.26", + "@typebot.io/tsconfig": "workspace:*" + } +} diff --git a/packages/lib/playwright/testHelpers.ts b/packages/playwright/testHelpers.ts similarity index 100% rename from packages/lib/playwright/testHelpers.ts rename to packages/playwright/testHelpers.ts diff --git a/packages/playwright/tsconfig.json b/packages/playwright/tsconfig.json new file mode 100644 index 000000000..075fbaa1f --- /dev/null +++ b/packages/playwright/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@typebot.io/tsconfig/base.json", + "include": ["**/*.ts"], + "exclude": ["node_modules"], + "compilerOptions": { + "lib": ["ES2021", "DOM"] + } +} diff --git a/packages/lib/api/helpers/archiveResults.ts b/packages/results/archiveResults.ts similarity index 96% rename from packages/lib/api/helpers/archiveResults.ts rename to packages/results/archiveResults.ts index 53abeaa1d..b19db6b9f 100644 --- a/packages/lib/api/helpers/archiveResults.ts +++ b/packages/results/archiveResults.ts @@ -1,6 +1,6 @@ import { Prisma, PrismaClient } from '@typebot.io/prisma' import { Block, Typebot } from '@typebot.io/schemas' -import { deleteFilesFromBucket } from '../../s3/deleteFilesFromBucket' +import { deleteFilesFromBucket } from '@typebot.io/lib/s3/deleteFilesFromBucket' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' type ArchiveResultsProps = { diff --git a/packages/lib/results/convertResultsToTableData.ts b/packages/results/convertResultsToTableData.ts similarity index 98% rename from packages/lib/results/convertResultsToTableData.ts rename to packages/results/convertResultsToTableData.ts index 4ac35438e..57153903d 100644 --- a/packages/lib/results/convertResultsToTableData.ts +++ b/packages/results/convertResultsToTableData.ts @@ -6,7 +6,7 @@ import { TableData, } from '@typebot.io/schemas' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' -import { isDefined } from '../utils' +import { isDefined } from '../lib/utils' type CellParser = ( content: VariableWithValue['value'], diff --git a/packages/results/package.json b/packages/results/package.json new file mode 100644 index 000000000..719100746 --- /dev/null +++ b/packages/results/package.json @@ -0,0 +1,17 @@ +{ + "name": "@typebot.io/results", + "version": "1.0.0", + "description": "", + "scripts": {}, + "keywords": [], + "author": "Baptiste Arnaud", + "license": "ISC", + "dependencies": { + "@typebot.io/schemas": "workspace:*", + "@typebot.io/lib": "workspace:*", + "@typebot.io/prisma": "workspace:*" + }, + "devDependencies": { + "@typebot.io/tsconfig": "workspace:*" + } +} diff --git a/packages/lib/results/parseAnswers.ts b/packages/results/parseAnswers.ts similarity index 95% rename from packages/lib/results/parseAnswers.ts rename to packages/results/parseAnswers.ts index dcd5636ea..737f055ca 100644 --- a/packages/lib/results/parseAnswers.ts +++ b/packages/results/parseAnswers.ts @@ -3,7 +3,7 @@ import { Variable, VariableWithValue, } from '@typebot.io/schemas' -import { isDefined, isEmpty } from '../utils' +import { isDefined, isEmpty } from '../lib/utils' export const parseAnswers = ({ answers, diff --git a/packages/lib/results/parseColumnsOrder.ts b/packages/results/parseColumnsOrder.ts similarity index 100% rename from packages/lib/results/parseColumnsOrder.ts rename to packages/results/parseColumnsOrder.ts diff --git a/packages/lib/results/parseResultHeader.ts b/packages/results/parseResultHeader.ts similarity index 98% rename from packages/lib/results/parseResultHeader.ts rename to packages/results/parseResultHeader.ts index 2f5f817b4..601bc3e26 100644 --- a/packages/lib/results/parseResultHeader.ts +++ b/packages/results/parseResultHeader.ts @@ -6,8 +6,9 @@ import { InputBlock, Typebot, } from '@typebot.io/schemas' +import { isInputBlock } from '@typebot.io/schemas/helpers' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants' -import { isInputBlock, byId, isNotEmpty } from '../utils' +import { byId, isNotEmpty } from '@typebot.io/lib/utils' export const parseResultHeader = ( typebot: Pick, diff --git a/packages/results/tsconfig.json b/packages/results/tsconfig.json new file mode 100644 index 000000000..075fbaa1f --- /dev/null +++ b/packages/results/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@typebot.io/tsconfig/base.json", + "include": ["**/*.ts"], + "exclude": ["node_modules"], + "compilerOptions": { + "lib": ["ES2021", "DOM"] + } +} diff --git a/packages/lib/parseVideoUrl.ts b/packages/schemas/features/blocks/bubbles/video/helpers.ts similarity index 94% rename from packages/lib/parseVideoUrl.ts rename to packages/schemas/features/blocks/bubbles/video/helpers.ts index 55909b071..8876b4ebc 100644 --- a/packages/lib/parseVideoUrl.ts +++ b/packages/schemas/features/blocks/bubbles/video/helpers.ts @@ -1,14 +1,14 @@ -import { VideoBubbleBlock } from '@typebot.io/schemas' import { VideoBubbleContentType, - gumletRegex, - horizontalVideoSuggestionSize, - oneDriveRegex, - tiktokRegex, - verticalVideoSuggestionSize, - vimeoRegex, youtubeRegex, -} from '@typebot.io/schemas/features/blocks/bubbles/video/constants' + verticalVideoSuggestionSize, + horizontalVideoSuggestionSize, + vimeoRegex, + tiktokRegex, + gumletRegex, + oneDriveRegex, +} from './constants' +import { VideoBubbleBlock } from './schema' export const parseVideoUrl = ( url: string diff --git a/packages/schemas/helpers.ts b/packages/schemas/helpers.ts new file mode 100644 index 000000000..c80dd79a6 --- /dev/null +++ b/packages/schemas/helpers.ts @@ -0,0 +1,128 @@ +import { enabledBlocks } from '@typebot.io/forge-repository' +import { + Block, + InputBlock, + BubbleBlock, + LogicBlock, + TextBubbleBlock, + ImageBubbleBlock, + VideoBubbleBlock, + TextInputBlock, + ChoiceInputBlock, + PictureChoiceBlock, + ConditionBlock, + IntegrationBlock, + HttpRequestBlock, + BlockWithOptionsType, +} from './features/blocks' +import { BubbleBlockType } from './features/blocks/bubbles/constants' +import { defaultChoiceInputOptions } from './features/blocks/inputs/choice/constants' +import { InputBlockType } from './features/blocks/inputs/constants' +import { IntegrationBlockType } from './features/blocks/integrations/constants' +import { LogicBlockType } from './features/blocks/logic/constants' +import { Group } from './features/typebot/types' + +export const isInputBlock = (block: Block): block is InputBlock => + (Object.values(InputBlockType) as string[]).includes(block.type) + +export const isBubbleBlock = (block: Block): block is BubbleBlock => + (Object.values(BubbleBlockType) as string[]).includes(block.type) + +export const isLogicBlock = (block: Block): block is LogicBlock => + (Object.values(LogicBlockType) as string[]).includes(block.type) + +export const isTextBubbleBlock = (block: Block): block is TextBubbleBlock => + block.type === BubbleBlockType.TEXT + +export const isMediaBubbleBlock = ( + block: Block +): block is ImageBubbleBlock | VideoBubbleBlock => + block.type === BubbleBlockType.IMAGE || block.type === BubbleBlockType.VIDEO + +export const isTextInputBlock = (block: Block): block is TextInputBlock => + block.type === InputBlockType.TEXT + +export const isChoiceInput = (block: Block): block is ChoiceInputBlock => + block.type === InputBlockType.CHOICE + +export const isPictureChoiceInput = ( + block: Block +): block is PictureChoiceBlock => block.type === InputBlockType.PICTURE_CHOICE + +export const isSingleChoiceInput = (block: Block): block is ChoiceInputBlock => + block.type === InputBlockType.CHOICE && + 'options' in block && + !( + block.options?.isMultipleChoice ?? + defaultChoiceInputOptions.isMultipleChoice + ) + +export const isConditionBlock = (block: Block): block is ConditionBlock => + block.type === LogicBlockType.CONDITION + +export const isIntegrationBlock = (block: Block): block is IntegrationBlock => + ( + Object.values(IntegrationBlockType).concat( + enabledBlocks as readonly any[] + ) as any[] + ).includes(block.type) + +export const isWebhookBlock = (block: Block): block is HttpRequestBlock => + [ + IntegrationBlockType.WEBHOOK, + IntegrationBlockType.PABBLY_CONNECT, + IntegrationBlockType.ZAPIER, + IntegrationBlockType.MAKE_COM, + ].includes(block.type as IntegrationBlockType) + +export const isBubbleBlockType = ( + type: Block['type'] +): type is BubbleBlockType => + (Object.values(BubbleBlockType) as string[]).includes(type) + +export const blockTypeHasOption = ( + type: Block['type'] +): type is BlockWithOptionsType => + (Object.values(InputBlockType) as string[]) + .concat(Object.values(LogicBlockType)) + .concat(Object.values(IntegrationBlockType)) + .includes(type) + +export const blockTypeHasItems = ( + type: Block['type'] +): type is + | LogicBlockType.CONDITION + | InputBlockType.CHOICE + | LogicBlockType.AB_TEST => + type === LogicBlockType.CONDITION || + type === InputBlockType.CHOICE || + type === LogicBlockType.AB_TEST || + type === InputBlockType.PICTURE_CHOICE + +export const blockHasItems = ( + block: Block +): block is ConditionBlock | ChoiceInputBlock => + 'items' in block && block.items !== undefined && block.items !== null + +export const getBlockById = ( + blockId: string, + groups: Group[] +): { block: Block; group: Group; blockIndex: number; groupIndex: number } => { + for (let groupIndex = 0; groupIndex < groups.length; groupIndex++) { + for ( + let blockIndex = 0; + blockIndex < (groups.at(groupIndex)?.blocks?.length ?? 0); + blockIndex++ + ) { + if (groups.at(groupIndex)?.blocks?.at(blockIndex)?.id === blockId) { + return { + block: groups[groupIndex].blocks[blockIndex], + group: groups[groupIndex], + blockIndex, + groupIndex, + } + } + } + } + throw new Error(`Block with id ${blockId} was not found`) +} diff --git a/packages/scripts/checkAndReportChatsUsage.ts b/packages/scripts/checkAndReportChatsUsage.ts index ad9de9395..46a880601 100644 --- a/packages/scripts/checkAndReportChatsUsage.ts +++ b/packages/scripts/checkAndReportChatsUsage.ts @@ -1,11 +1,11 @@ import { Plan, PrismaClient, WorkspaceRole } from '@typebot.io/prisma' import { isDefined, isEmpty } from '@typebot.io/lib' -import { getChatsLimit } from '@typebot.io/lib/billing/getChatsLimit' +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 { TelemetryEvent } from '@typebot.io/schemas/features/telemetry' -import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' import Stripe from 'stripe' import { createId } from '@paralleldrive/cuid2' diff --git a/packages/scripts/cleanDatabase.ts b/packages/scripts/cleanDatabase.ts index bb218eda1..3feaf839a 100644 --- a/packages/scripts/cleanDatabase.ts +++ b/packages/scripts/cleanDatabase.ts @@ -1,6 +1,6 @@ import { PrismaClient } from '@typebot.io/prisma' import { promptAndSetEnvironment } from './utils' -import { archiveResults } from '@typebot.io/lib/api/helpers/archiveResults' +import { archiveResults } from '@typebot.io/results/archiveResults' import { Typebot } from '@typebot.io/schemas' const prisma = new PrismaClient() diff --git a/packages/scripts/createChatsPrices.ts b/packages/scripts/createChatsPrices.ts index 7efc01f2a..ea2345e88 100644 --- a/packages/scripts/createChatsPrices.ts +++ b/packages/scripts/createChatsPrices.ts @@ -1,9 +1,6 @@ import Stripe from 'stripe' import { promptAndSetEnvironment } from './utils' -import { - proChatTiers, - starterChatTiers, -} from '@typebot.io/lib/billing/constants' +import { proChatTiers, starterChatTiers } from '@typebot.io/billing/constants' const chatsProductId = 'prod_MVXtq5sATQzIcM' diff --git a/packages/scripts/exportResults.ts b/packages/scripts/exportResults.ts index f7e229a11..9cf7963da 100644 --- a/packages/scripts/exportResults.ts +++ b/packages/scripts/exportResults.ts @@ -9,9 +9,9 @@ import { resultWithAnswersSchema, } from '@typebot.io/schemas' import { byId } from '@typebot.io/lib' -import { parseResultHeader } from '@typebot.io/lib/results/parseResultHeader' -import { convertResultsToTableData } from '@typebot.io/lib/results/convertResultsToTableData' -import { parseColumnsOrder } from '@typebot.io/lib/results/parseColumnsOrder' +import { parseResultHeader } from '@typebot.io/results/parseResultHeader' +import { convertResultsToTableData } from '@typebot.io/results/convertResultsToTableData' +import { parseColumnsOrder } from '@typebot.io/results/parseColumnsOrder' import { parseUniqueKey } from '@typebot.io/lib/parseUniqueKey' import { unparse } from 'papaparse' import { z } from 'zod' diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 36c9ddaf7..e37c98a72 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -53,6 +53,9 @@ "@clack/prompts": "^0.7.0", "@paralleldrive/cuid2": "2.2.1", "cli-progress": "^3.12.0", - "papaparse": "5.4.1" + "papaparse": "5.4.1", + "@typebot.io/results": "workspace:*", + "@typebot.io/billing": "workspace:*", + "@typebot.io/telemetry": "workspace:*" } } diff --git a/packages/telemetry/package.json b/packages/telemetry/package.json new file mode 100644 index 000000000..a733fed19 --- /dev/null +++ b/packages/telemetry/package.json @@ -0,0 +1,18 @@ +{ + "name": "@typebot.io/telemetry", + "version": "1.0.0", + "description": "", + "scripts": {}, + "keywords": [], + "author": "Baptiste Arnaud", + "license": "ISC", + "dependencies": { + "@typebot.io/schemas": "workspace:*", + "got": "12.6.0", + "posthog-node": "3.1.1", + "@typebot.io/env": "workspace:*" + }, + "devDependencies": { + "@typebot.io/tsconfig": "workspace:*" + } +} diff --git a/packages/lib/telemetry/trackEvents.ts b/packages/telemetry/trackEvents.ts similarity index 100% rename from packages/lib/telemetry/trackEvents.ts rename to packages/telemetry/trackEvents.ts diff --git a/packages/telemetry/tsconfig.json b/packages/telemetry/tsconfig.json new file mode 100644 index 000000000..075fbaa1f --- /dev/null +++ b/packages/telemetry/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@typebot.io/tsconfig/base.json", + "include": ["**/*.ts"], + "exclude": ["node_modules"], + "compilerOptions": { + "lib": ["ES2021", "DOM"] + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b1586350..236ad3c6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -276,6 +276,9 @@ importers: '@playwright/test': specifier: 1.41.2 version: 1.41.2 + '@typebot.io/billing': + specifier: workspace:* + version: link:../../packages/billing '@typebot.io/forge': specifier: workspace:* version: link:../../packages/forge/core @@ -288,15 +291,27 @@ importers: '@typebot.io/lib': specifier: workspace:* version: link:../../packages/lib + '@typebot.io/migrations': + specifier: workspace:* + version: link:../../packages/migrations + '@typebot.io/playwright': + specifier: workspace:* + version: link:../../packages/playwright '@typebot.io/prisma': specifier: workspace:* version: link:../../packages/prisma '@typebot.io/radar': specifier: workspace:* version: link:../../packages/radar + '@typebot.io/results': + specifier: workspace:* + version: link:../../packages/results '@typebot.io/schemas': specifier: workspace:* version: link:../../packages/schemas + '@typebot.io/telemetry': + specifier: workspace:* + version: link:../../packages/telemetry '@typebot.io/tsconfig': specifier: workspace:* version: link:../../packages/tsconfig @@ -381,6 +396,9 @@ importers: '@emotion/styled': specifier: 11.11.0 version: 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.15)(react@18.2.0) + '@typebot.io/billing': + specifier: workspace:* + version: link:../../packages/billing '@typebot.io/lib': specifier: workspace:* version: link:../../packages/lib @@ -557,6 +575,12 @@ importers: '@typebot.io/lib': specifier: workspace:* version: link:../../packages/lib + '@typebot.io/playwright': + specifier: workspace:* + version: link:../../packages/playwright + '@typebot.io/results': + specifier: workspace:* + version: link:../../packages/results '@typebot.io/schemas': specifier: workspace:* version: link:../../packages/schemas @@ -584,6 +608,9 @@ importers: '@types/react': specifier: 18.2.15 version: 18.2.15 + dotenv: + specifier: 16.4.5 + version: 16.4.5 dotenv-cli: specifier: 7.2.1 version: 7.2.1 @@ -612,6 +639,22 @@ importers: specifier: 3.22.4 version: 3.22.4 + packages/billing: + dependencies: + '@typebot.io/prisma': + specifier: workspace:* + version: link:../prisma + '@typebot.io/schemas': + specifier: workspace:* + version: link:../schemas + stripe: + specifier: 12.13.0 + version: 12.13.0 + devDependencies: + '@typebot.io/tsconfig': + specifier: workspace:* + version: link:../tsconfig + packages/bot-engine: dependencies: '@paralleldrive/cuid2': @@ -638,6 +681,9 @@ importers: '@typebot.io/prisma': specifier: workspace:* version: link:../prisma + '@typebot.io/results': + specifier: workspace:* + version: link:../results '@typebot.io/schemas': specifier: workspace:* version: link:../schemas @@ -1580,9 +1626,6 @@ importers: '@typebot.io/prisma': specifier: workspace:* version: link:../prisma - '@typebot.io/schemas': - specifier: workspace:* - version: link:../schemas '@typebot.io/tsconfig': specifier: workspace:* version: link:../tsconfig @@ -1605,6 +1648,44 @@ importers: specifier: 5.3.2 version: 5.3.2 + packages/migrations: + dependencies: + '@typebot.io/lib': + specifier: workspace:* + version: link:../lib + '@typebot.io/prisma': + specifier: workspace:* + version: link:../prisma + '@typebot.io/schemas': + specifier: workspace:* + version: link:../schemas + devDependencies: + '@typebot.io/tsconfig': + specifier: workspace:* + version: link:../tsconfig + + packages/playwright: + dependencies: + '@playwright/test': + specifier: ^1.42.1 + version: 1.42.1 + '@typebot.io/lib': + specifier: workspace:* + version: link:../lib + '@typebot.io/prisma': + specifier: workspace:* + version: link:../prisma + '@typebot.io/schemas': + specifier: workspace:* + version: link:../schemas + devDependencies: + '@typebot.io/tsconfig': + specifier: workspace:* + version: link:../tsconfig + '@types/node': + specifier: ^20.11.26 + version: 20.11.26 + packages/prisma: dependencies: '@prisma/client': @@ -1652,6 +1733,22 @@ importers: specifier: 5.3.2 version: 5.3.2 + packages/results: + dependencies: + '@typebot.io/lib': + specifier: workspace:* + version: link:../lib + '@typebot.io/prisma': + specifier: workspace:* + version: link:../prisma + '@typebot.io/schemas': + specifier: workspace:* + version: link:../schemas + devDependencies: + '@typebot.io/tsconfig': + specifier: workspace:* + version: link:../tsconfig + packages/schemas: dependencies: '@udecode/plate-common': @@ -1685,6 +1782,15 @@ importers: '@paralleldrive/cuid2': specifier: 2.2.1 version: 2.2.1 + '@typebot.io/billing': + specifier: workspace:* + version: link:../billing + '@typebot.io/results': + specifier: workspace:* + version: link:../results + '@typebot.io/telemetry': + specifier: workspace:* + version: link:../telemetry cli-progress: specifier: ^3.12.0 version: 3.12.0 @@ -1738,6 +1844,25 @@ importers: specifier: 3.22.4 version: 3.22.4 + packages/telemetry: + dependencies: + '@typebot.io/env': + specifier: workspace:* + version: link:../env + '@typebot.io/schemas': + specifier: workspace:* + version: link:../schemas + got: + specifier: 12.6.0 + version: 12.6.0 + posthog-node: + specifier: 3.1.1 + version: 3.1.1 + devDependencies: + '@typebot.io/tsconfig': + specifier: workspace:* + version: link:../tsconfig + packages/transactional: dependencies: '@react-email/components': @@ -7622,6 +7747,14 @@ packages: playwright: 1.41.2 dev: true + /@playwright/test@1.42.1: + resolution: {integrity: sha512-Gq9rmS54mjBL/7/MvBaNOBwbfnh7beHvS6oS4srqXFcQHpQCV1+c8JXWE8VLPyRDhgS3H8x8A7hztqI9VnwrAQ==} + engines: {node: '>=16'} + hasBin: true + dependencies: + playwright: 1.42.1 + dev: false + /@popperjs/core@2.11.8: resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} dev: false @@ -14358,7 +14491,6 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] requiresBuild: true - dev: true optional: true /fsevents@2.3.3: @@ -18776,6 +18908,12 @@ packages: hasBin: true dev: true + /playwright-core@1.42.1: + resolution: {integrity: sha512-mxz6zclokgrke9p1vtdy/COWBH+eOZgYUVVU34C73M+4j4HLlQJHtfcqiqqxpP0o8HhMkflvfbquLX5dg6wlfA==} + engines: {node: '>=16'} + hasBin: true + dev: false + /playwright@1.41.2: resolution: {integrity: sha512-v0bOa6H2GJChDL8pAeLa/LZC4feoAMbSQm1/jF/ySsWWoaNItvrMP7GEkvEEFyCTUYKMxjQKaTSg5up7nR6/8A==} engines: {node: '>=16'} @@ -18786,6 +18924,16 @@ packages: fsevents: 2.3.2 dev: true + /playwright@1.42.1: + resolution: {integrity: sha512-PgwB03s2DZBcNRoW+1w9E+VkLBxweib6KTXM0M3tkiT4jVxKSi6PmVJ591J+0u10LUrgxB7dLRbiJqO5s2QPMg==} + engines: {node: '>=16'} + hasBin: true + dependencies: + playwright-core: 1.42.1 + optionalDependencies: + fsevents: 2.3.2 + dev: false + /pngjs@5.0.0: resolution: {integrity: sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==} engines: {node: '>=10.13.0'}