From 0eacbebbbe4366bf4467c196eb3fa922bc82f628 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 23 May 2024 10:42:23 +0200 Subject: [PATCH] :page_facing_up: Add Commercial License for ee folder (#1532) --- LICENSE | 8 + README.md | 2 +- .../billing/api/createCheckoutSession.ts | 134 +------ .../api/createCustomCheckoutSession.ts | 162 +-------- .../billing/api/getBillingPortalUrl.ts | 45 +-- .../features/billing/api/getSubscription.ts | 71 +--- .../src/features/billing/api/getUsage.ts | 93 +---- .../src/features/billing/api/listInvoices.ts | 56 +-- .../billing/api/updateSubscription.ts | 149 +------- .../billing/components/ChangePlanForm.tsx | 2 +- .../billing/components/ChatsProTiersModal.tsx | 2 +- .../billing/components/PreCheckoutModal.tsx | 2 +- .../billing/components/ProPlanPricingCard.tsx | 2 +- .../components/StarterPlanPricingCard.tsx | 2 +- .../billing/components/UsageProgressBars.tsx | 2 +- .../dashboard/components/DashboardPage.tsx | 2 +- .../workspace/components/MembersList.tsx | 2 +- apps/builder/src/pages/api/stripe/webhook.ts | 333 +---------------- .../workspaces/[workspaceId]/invitations.ts | 2 +- apps/docs/self-hosting/configuration.mdx | 33 -- apps/docs/self-hosting/get-started.mdx | 23 +- apps/landing-page/LICENSE | 19 - apps/landing-page/README.md | 3 - ee/LICENSE | 34 ++ ee/README.md | 36 ++ {apps => ee/apps}/landing-page/.eslintrc.js | 0 .../apps}/landing-page/app/blog/Posts.tsx | 0 .../landing-page/app/blog/[slug]/Post.tsx | 0 .../landing-page/app/blog/[slug]/Table.tsx | 0 .../landing-page/app/blog/[slug]/Tweet.tsx | 0 .../landing-page/app/blog/[slug]/page.tsx | 0 .../landing-page/app/blog/[slug]/tweet.css | 0 .../apps}/landing-page/app/blog/page.tsx | 0 {apps => ee/apps}/landing-page/app/db/blog.ts | 0 {apps => ee/apps}/landing-page/app/layout.tsx | 0 .../apps}/landing-page/app/og/route.tsx | 0 .../apps}/landing-page/app/providers.tsx | 0 .../landing-page/assets/Outfit-Medium.ttf | Bin .../assets/icons/AccessibilityIcon.tsx | 0 .../landing-page/assets/icons/ArrowRight.tsx | 0 .../assets/icons/CaluclatorIcon.tsx | 0 .../assets/icons/CapterraIcon.tsx | 0 .../assets/icons/CheckCircleIcon.tsx | 0 .../landing-page/assets/icons/CheckIcon.tsx | 0 .../assets/icons/ChevronDownIcon.tsx | 0 .../assets/icons/ChevronRightIcon.tsx | 0 .../landing-page/assets/icons/CloseIcon.tsx | 0 .../assets/icons/ConditionIcon.tsx | 0 .../landing-page/assets/icons/DoIcon.tsx | 0 .../landing-page/assets/icons/DocIcon.tsx | 0 .../landing-page/assets/icons/DontIcon.tsx | 0 .../landing-page/assets/icons/EmailIcon.tsx | 0 .../assets/icons/ExternalLinkIcon.tsx | 0 .../landing-page/assets/icons/FolderIcon.tsx | 0 .../landing-page/assets/icons/GithubLogo.tsx | 0 .../assets/icons/HamburgerIcon.tsx | 0 .../assets/icons/HelpCircleIcon.tsx | 0 .../apps}/landing-page/assets/icons/Logo.tsx | 0 .../landing-page/assets/icons/MapIcon.tsx | 0 .../assets/icons/PeopleCircleIcon.tsx | 0 .../assets/icons/PersonAddIcon.tsx | 0 .../assets/icons/ProductHuntIcon.tsx | 0 .../assets/icons/QuoteLeftIcon.tsx | 0 .../landing-page/assets/icons/RedditIcon.tsx | 0 .../landing-page/assets/icons/ShareIcon.tsx | 0 .../apps}/landing-page/assets/icons/index.ts | 0 .../assets/illustrations/Flare.tsx | 0 .../assets/illustrations/HandDrawnArrow.tsx | 0 .../assets/logos/AirtableLogo.tsx | 0 .../assets/logos/CalendlyLogo.tsx | 0 .../landing-page/assets/logos/GmailLogo.tsx | 0 .../assets/logos/GoogleCalendarLogo.tsx | 0 .../assets/logos/GoogleDriveLogo.tsx | 0 .../assets/logos/GoogleSheetsLogo.tsx | 0 .../landing-page/assets/logos/HubspotLogo.tsx | 0 .../assets/logos/MailchimpLogo.tsx | 0 .../landing-page/assets/logos/N8nLogo.tsx | 0 .../landing-page/assets/logos/NotionLogo.tsx | 0 .../assets/logos/PipedriveLogo.tsx | 0 .../assets/logos/SalesforceLogo.tsx | 0 .../landing-page/assets/logos/ShopifyLogo.tsx | 0 .../landing-page/assets/logos/SlackLogo.tsx | 0 .../assets/logos/StripeClimateLogo.tsx | 0 .../landing-page/assets/logos/WebflowLogo.tsx | 0 .../landing-page/assets/logos/WixLogo.tsx | 0 .../assets/logos/WordpressLogo.tsx | 0 .../landing-page/assets/logos/ZapierLogo.tsx | 0 .../apps}/landing-page/assets/logos/index.ts | 0 .../apps}/landing-page/assets/prose.css | 0 .../apps}/landing-page/assets/style.css | 0 .../Homepage/EasyBuildingExperience.tsx | 0 .../components/Homepage/EasyEmbed.tsx | 0 .../components/Homepage/EndCta.tsx | 0 .../Homepage/Features/FeatureCard.tsx | 0 .../components/Homepage/Features/Features.tsx | 0 .../components/Homepage/Features/index.tsx | 0 .../Homepage/Hero/BackgroundPolygons.tsx | 0 .../components/Homepage/Hero/Brands.tsx | 0 .../components/Homepage/Hero/Hero.tsx | 0 .../components/Homepage/Hero/index.tsx | 0 .../components/Homepage/Integrations.tsx | 0 .../Homepage/IntroducingChatApps.tsx | 0 .../components/Homepage/RealTimeResults.tsx | 0 .../Homepage/Testimonials/Testimonial.tsx | 0 .../Homepage/Testimonials/Testimonials.tsx | 0 .../components/Homepage/Testimonials/index.ts | 0 .../PricingPage/ChatsProTiersModal.tsx | 2 +- .../PricingPage/EnterprisePlanCard.tsx | 0 .../components/PricingPage/Faq.tsx | 0 .../components/PricingPage/FreePlanCard.tsx | 0 .../PricingPage/PlanComparisonTables.tsx | 2 +- .../PricingPage/PricingCard/Card.tsx | 0 .../PricingPage/PricingCard/CardBadge.tsx | 0 .../PricingPage/PricingCard/index.tsx | 2 +- .../components/PricingPage/ProPlanCard.tsx | 0 .../PricingPage/StarterPlanCard.tsx | 0 .../components/common/ArticleCta.tsx | 0 .../landing-page/components/common/Footer.tsx | 0 .../components/common/Header/Header.tsx | 0 .../components/common/Header/MobileMenu.tsx | 0 .../common/Header/ResourcesMenu.tsx | 0 .../components/common/Header/_data.tsx | 0 .../components/common/SocialMetaTags.tsx | 0 .../components/common/TableCells.tsx | 0 .../components/common/TextLink.tsx | 0 .../content/best-chatbot-for-wordpress.mdx | 0 .../content/best-whatsapp-chatbot.mdx | 0 .../apps}/landing-page/content/example.mdx | 0 .../content/landbot-alternative.mdx | 0 .../content/lead-generation-chatbot.mdx | 0 .../apps}/landing-page/lib/chakraTheme.ts | 0 {apps => ee/apps}/landing-page/next-env.d.ts | 0 .../apps}/landing-page/next.config.mjs | 0 {apps => ee/apps}/landing-page/package.json | 8 +- {apps => ee/apps}/landing-page/pages/_app.tsx | 0 .../apps}/landing-page/pages/_document.tsx | 0 .../apps}/landing-page/pages/about.tsx | 0 .../apps}/landing-page/pages/index.tsx | 0 .../apps}/landing-page/pages/oss-friends.tsx | 0 .../apps}/landing-page/pages/pricing.tsx | 0 .../landing-page/pages/privacy-policies.tsx | 0 .../landing-page/pages/terms-of-service.tsx | 0 .../apps}/landing-page/postcss.config.js | 0 .../apps}/landing-page/public/favicon.png | Bin .../landing-page/public/images/abhay.jpeg | Bin .../landing-page/public/images/annaFilou.jpeg | Bin .../landing-page/public/images/barretta.jpeg | Bin .../acobot-website.png | Bin .../botsify-website.png | Bin .../botstar-website.png | Bin .../chattymongo-website.png | Bin .../drift-website.png | Bin .../intercom-website.png | Bin .../landbot-website.png | Bin .../wpbot-website.png | Bin .../best-whatsapp-chatbot/aivo-website.png | Bin .../botpress-website.png | Bin .../respond-io-website.png | Bin .../best-whatsapp-chatbot/tidio-website.png | Bin .../chatbot-com-website.png | Bin .../collect-chat-website.png | Bin .../landbot-alternative/manychat-website.png | Bin .../landbot-alternative/typeform-website.png | Bin .../lead-generation-chatbot/ask-for-email.gif | Bin .../create-new-typebot.png | Bin .../create-welcome-message.gif | Bin .../drift-chatbot-example.png | Bin .../example-custom-chatbot.png | Bin .../geico-chatbot-example.png | Bin .../intercom-chatbot-example.png | Bin .../pendo-chatbot-example.png | Bin .../send-to-google-sheets.png | Bin .../public/images/blog/typebot-website.png | Bin .../public/images/builder-dnd.png | Bin .../public/images/builder-screenshot.png | Bin .../landing-page/public/images/favicon.png | Bin .../landing-page/public/images/invictuz.png | Bin .../landing-page/public/images/joshua.jpg | Bin .../landing-page/public/images/julien.jpeg | Bin .../landing-page/public/images/kurnia.jpeg | Bin .../landing-page/public/images/laszlo.jpeg | Bin .../landing-page/public/images/lucas.png | Bin .../public/images/native-feeling.png | Bin .../landing-page/public/images/nicolai.jpg | Bin .../landing-page/public/images/og-bg.png | Bin .../landing-page/public/images/oscar.jpeg | Bin .../landing-page/public/images/preview.png | Bin .../landing-page/public/images/selfie.png | Bin .../landing-page/public/images/steve.jpg | Bin .../landing-page/public/images/theo.jpeg | Bin .../public/styles/aos-noscript.css | 0 .../public/typebots/lead-gen-lp.json | 0 .../public/typebots/realtime-airtable.json | 0 .../apps}/landing-page/tailwind.config.js | 0 {apps => ee/apps}/landing-page/tsconfig.json | 0 .../billing/api/createCheckoutSession.ts | 104 ++++++ .../api/createCustomCheckoutSession.ts | 158 ++++++++ .../billing/api/getBillingPortalUrl.ts | 47 +++ ee/packages/billing/api/getSubscription.ts | 74 ++++ ee/packages/billing/api/getUsage.ts | 96 +++++ ee/packages/billing/api/listInvoices.ts | 59 +++ ee/packages/billing/api/updateSubscription.ts | 153 ++++++++ ee/packages/billing/api/webhookHandler.ts | 336 +++++++++++++++++ .../packages}/billing/constants.ts | 0 .../helpers/createCheckoutSessionUrl.ts | 51 +++ .../packages/billing/helpers}/formatPrice.ts | 0 .../billing/helpers}/getChatsLimit.ts | 2 +- .../billing/helpers}/getSeatsLimit.ts | 2 +- .../billing/helpers}/guessIfUserIsEuropean.ts | 0 ee/packages/billing/package.json | 28 ++ .../packages}/billing/taxIdTypes.ts | 0 .../packages}/billing/tsconfig.json | 0 package.json | 3 +- .../isAdminWriteWorkspaceForbidden.ts | 13 + packages/db-rules/isReadWorkspaceFobidden.ts | 16 + packages/{billing => db-rules}/package.json | 10 +- packages/emails/package.json | 2 +- packages/embeds/js/package.json | 2 +- packages/embeds/nextjs/package.json | 2 +- packages/embeds/react/package.json | 2 +- packages/embeds/wordpress/trunk/LICENSE.txt | 339 ------------------ packages/forge/blocks/anthropic/package.json | 2 +- packages/forge/blocks/calCom/package.json | 2 +- packages/forge/blocks/chatNode/package.json | 2 +- packages/forge/blocks/difyAi/package.json | 2 +- packages/forge/blocks/elevenlabs/package.json | 2 +- packages/forge/blocks/mistral/package.json | 2 +- packages/forge/blocks/openRouter/package.json | 2 +- packages/forge/blocks/openai/package.json | 2 +- packages/forge/blocks/qrcode/package.json | 2 +- packages/forge/blocks/togetherAi/package.json | 2 +- packages/forge/blocks/zemanticAi/package.json | 2 +- packages/forge/cli/index.ts | 2 +- packages/forge/cli/package.json | 2 +- packages/forge/core/package.json | 2 +- packages/forge/repository/package.json | 2 +- packages/logic/package.json | 2 +- packages/migrations/package.json | 2 +- packages/playwright/package.json | 2 +- packages/results/package.json | 2 +- packages/scripts/checkAndReportChatsUsage.ts | 2 +- packages/telemetry/package.json | 2 +- packages/theme/package.json | 2 +- packages/transactional/package.json | 2 +- pnpm-lock.yaml | 280 ++++++++------- pnpm-workspace.yaml | 2 + 246 files changed, 1472 insertions(+), 1588 deletions(-) delete mode 100644 apps/landing-page/LICENSE delete mode 100644 apps/landing-page/README.md create mode 100644 ee/LICENSE create mode 100644 ee/README.md rename {apps => ee/apps}/landing-page/.eslintrc.js (100%) rename {apps => ee/apps}/landing-page/app/blog/Posts.tsx (100%) rename {apps => ee/apps}/landing-page/app/blog/[slug]/Post.tsx (100%) rename {apps => ee/apps}/landing-page/app/blog/[slug]/Table.tsx (100%) rename {apps => ee/apps}/landing-page/app/blog/[slug]/Tweet.tsx (100%) rename {apps => ee/apps}/landing-page/app/blog/[slug]/page.tsx (100%) rename {apps => ee/apps}/landing-page/app/blog/[slug]/tweet.css (100%) rename {apps => ee/apps}/landing-page/app/blog/page.tsx (100%) rename {apps => ee/apps}/landing-page/app/db/blog.ts (100%) rename {apps => ee/apps}/landing-page/app/layout.tsx (100%) rename {apps => ee/apps}/landing-page/app/og/route.tsx (100%) rename {apps => ee/apps}/landing-page/app/providers.tsx (100%) rename {apps => ee/apps}/landing-page/assets/Outfit-Medium.ttf (100%) rename {apps => ee/apps}/landing-page/assets/icons/AccessibilityIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/ArrowRight.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/CaluclatorIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/CapterraIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/CheckCircleIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/CheckIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/ChevronDownIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/ChevronRightIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/CloseIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/ConditionIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/DoIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/DocIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/DontIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/EmailIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/ExternalLinkIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/FolderIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/GithubLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/HamburgerIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/HelpCircleIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/Logo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/MapIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/PeopleCircleIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/PersonAddIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/ProductHuntIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/QuoteLeftIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/RedditIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/ShareIcon.tsx (100%) rename {apps => ee/apps}/landing-page/assets/icons/index.ts (100%) rename {apps => ee/apps}/landing-page/assets/illustrations/Flare.tsx (100%) rename {apps => ee/apps}/landing-page/assets/illustrations/HandDrawnArrow.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/AirtableLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/CalendlyLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/GmailLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/GoogleCalendarLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/GoogleDriveLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/GoogleSheetsLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/HubspotLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/MailchimpLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/N8nLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/NotionLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/PipedriveLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/SalesforceLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/ShopifyLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/SlackLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/StripeClimateLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/WebflowLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/WixLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/WordpressLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/ZapierLogo.tsx (100%) rename {apps => ee/apps}/landing-page/assets/logos/index.ts (100%) rename {apps => ee/apps}/landing-page/assets/prose.css (100%) rename {apps => ee/apps}/landing-page/assets/style.css (100%) rename {apps => ee/apps}/landing-page/components/Homepage/EasyBuildingExperience.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/EasyEmbed.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/EndCta.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Features/FeatureCard.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Features/Features.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Features/index.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Hero/BackgroundPolygons.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Hero/Brands.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Hero/Hero.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Hero/index.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Integrations.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/IntroducingChatApps.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/RealTimeResults.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Testimonials/Testimonial.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Testimonials/Testimonials.tsx (100%) rename {apps => ee/apps}/landing-page/components/Homepage/Testimonials/index.ts (100%) rename {apps => ee/apps}/landing-page/components/PricingPage/ChatsProTiersModal.tsx (97%) rename {apps => ee/apps}/landing-page/components/PricingPage/EnterprisePlanCard.tsx (100%) rename {apps => ee/apps}/landing-page/components/PricingPage/Faq.tsx (100%) rename {apps => ee/apps}/landing-page/components/PricingPage/FreePlanCard.tsx (100%) rename {apps => ee/apps}/landing-page/components/PricingPage/PlanComparisonTables.tsx (99%) rename {apps => ee/apps}/landing-page/components/PricingPage/PricingCard/Card.tsx (100%) rename {apps => ee/apps}/landing-page/components/PricingPage/PricingCard/CardBadge.tsx (100%) rename {apps => ee/apps}/landing-page/components/PricingPage/PricingCard/index.tsx (97%) rename {apps => ee/apps}/landing-page/components/PricingPage/ProPlanCard.tsx (100%) rename {apps => ee/apps}/landing-page/components/PricingPage/StarterPlanCard.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/ArticleCta.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/Footer.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/Header/Header.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/Header/MobileMenu.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/Header/ResourcesMenu.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/Header/_data.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/SocialMetaTags.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/TableCells.tsx (100%) rename {apps => ee/apps}/landing-page/components/common/TextLink.tsx (100%) rename {apps => ee/apps}/landing-page/content/best-chatbot-for-wordpress.mdx (100%) rename {apps => ee/apps}/landing-page/content/best-whatsapp-chatbot.mdx (100%) rename {apps => ee/apps}/landing-page/content/example.mdx (100%) rename {apps => ee/apps}/landing-page/content/landbot-alternative.mdx (100%) rename {apps => ee/apps}/landing-page/content/lead-generation-chatbot.mdx (100%) rename {apps => ee/apps}/landing-page/lib/chakraTheme.ts (100%) rename {apps => ee/apps}/landing-page/next-env.d.ts (100%) rename {apps => ee/apps}/landing-page/next.config.mjs (100%) rename {apps => ee/apps}/landing-page/package.json (85%) rename {apps => ee/apps}/landing-page/pages/_app.tsx (100%) rename {apps => ee/apps}/landing-page/pages/_document.tsx (100%) rename {apps => ee/apps}/landing-page/pages/about.tsx (100%) rename {apps => ee/apps}/landing-page/pages/index.tsx (100%) rename {apps => ee/apps}/landing-page/pages/oss-friends.tsx (100%) rename {apps => ee/apps}/landing-page/pages/pricing.tsx (100%) rename {apps => ee/apps}/landing-page/pages/privacy-policies.tsx (100%) rename {apps => ee/apps}/landing-page/pages/terms-of-service.tsx (100%) rename {apps => ee/apps}/landing-page/postcss.config.js (100%) rename {apps => ee/apps}/landing-page/public/favicon.png (100%) rename {apps => ee/apps}/landing-page/public/images/abhay.jpeg (100%) rename {apps => ee/apps}/landing-page/public/images/annaFilou.jpeg (100%) rename {apps => ee/apps}/landing-page/public/images/barretta.jpeg (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-chatbot-for-wordpress/acobot-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-chatbot-for-wordpress/botsify-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-chatbot-for-wordpress/botstar-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-chatbot-for-wordpress/chattymongo-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-chatbot-for-wordpress/drift-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-chatbot-for-wordpress/intercom-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-chatbot-for-wordpress/landbot-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-chatbot-for-wordpress/wpbot-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-whatsapp-chatbot/aivo-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-whatsapp-chatbot/botpress-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-whatsapp-chatbot/respond-io-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/best-whatsapp-chatbot/tidio-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/landbot-alternative/chatbot-com-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/landbot-alternative/collect-chat-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/landbot-alternative/manychat-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/landbot-alternative/typeform-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/ask-for-email.gif (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/create-new-typebot.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/create-welcome-message.gif (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/drift-chatbot-example.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/example-custom-chatbot.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/geico-chatbot-example.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/intercom-chatbot-example.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/pendo-chatbot-example.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/lead-generation-chatbot/send-to-google-sheets.png (100%) rename {apps => ee/apps}/landing-page/public/images/blog/typebot-website.png (100%) rename {apps => ee/apps}/landing-page/public/images/builder-dnd.png (100%) rename {apps => ee/apps}/landing-page/public/images/builder-screenshot.png (100%) rename {apps => ee/apps}/landing-page/public/images/favicon.png (100%) rename {apps => ee/apps}/landing-page/public/images/invictuz.png (100%) rename {apps => ee/apps}/landing-page/public/images/joshua.jpg (100%) rename {apps => ee/apps}/landing-page/public/images/julien.jpeg (100%) rename {apps => ee/apps}/landing-page/public/images/kurnia.jpeg (100%) rename {apps => ee/apps}/landing-page/public/images/laszlo.jpeg (100%) rename {apps => ee/apps}/landing-page/public/images/lucas.png (100%) rename {apps => ee/apps}/landing-page/public/images/native-feeling.png (100%) rename {apps => ee/apps}/landing-page/public/images/nicolai.jpg (100%) rename {apps => ee/apps}/landing-page/public/images/og-bg.png (100%) rename {apps => ee/apps}/landing-page/public/images/oscar.jpeg (100%) rename {apps => ee/apps}/landing-page/public/images/preview.png (100%) rename {apps => ee/apps}/landing-page/public/images/selfie.png (100%) rename {apps => ee/apps}/landing-page/public/images/steve.jpg (100%) rename {apps => ee/apps}/landing-page/public/images/theo.jpeg (100%) rename {apps => ee/apps}/landing-page/public/styles/aos-noscript.css (100%) rename {apps => ee/apps}/landing-page/public/typebots/lead-gen-lp.json (100%) rename {apps => ee/apps}/landing-page/public/typebots/realtime-airtable.json (100%) rename {apps => ee/apps}/landing-page/tailwind.config.js (100%) rename {apps => ee/apps}/landing-page/tsconfig.json (100%) create mode 100644 ee/packages/billing/api/createCheckoutSession.ts create mode 100644 ee/packages/billing/api/createCustomCheckoutSession.ts create mode 100644 ee/packages/billing/api/getBillingPortalUrl.ts create mode 100644 ee/packages/billing/api/getSubscription.ts create mode 100644 ee/packages/billing/api/getUsage.ts create mode 100644 ee/packages/billing/api/listInvoices.ts create mode 100644 ee/packages/billing/api/updateSubscription.ts create mode 100644 ee/packages/billing/api/webhookHandler.ts rename {packages => ee/packages}/billing/constants.ts (100%) create mode 100644 ee/packages/billing/helpers/createCheckoutSessionUrl.ts rename {packages/billing => ee/packages/billing/helpers}/formatPrice.ts (100%) rename {packages/billing => ee/packages/billing/helpers}/getChatsLimit.ts (91%) rename {packages/billing => ee/packages/billing/helpers}/getSeatsLimit.ts (89%) rename {packages/billing => ee/packages/billing/helpers}/guessIfUserIsEuropean.ts (100%) create mode 100644 ee/packages/billing/package.json rename {apps/builder/src/features => ee/packages}/billing/taxIdTypes.ts (100%) rename {packages => ee/packages}/billing/tsconfig.json (100%) create mode 100644 packages/db-rules/isAdminWriteWorkspaceForbidden.ts create mode 100644 packages/db-rules/isReadWorkspaceFobidden.ts rename packages/{billing => db-rules}/package.json (58%) delete mode 100644 packages/embeds/wordpress/trunk/LICENSE.txt diff --git a/LICENSE b/LICENSE index 0ad25db4bd..9656c4ab0a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,11 @@ + Copyright (c) 2020-present Typebot + +Portions of this software are licensed as follows: + +- All content that resides under https://github.com/baptisteArno/typebot.io/tree/main/ee directory of this repository is licensed under the license defined in [ee/LICENSE](./ee/LICENSE). +- Content outside of the above mentioned directories or restrictions above is available under the "AGPLv3" license as defined below. + + GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 diff --git a/README.md b/README.md index 35c5c5faa1..087f3c14c2 100644 --- a/README.md +++ b/README.md @@ -110,4 +110,4 @@ Made with [contrib.rocks](https://contrib.rocks). ## License -Typebot is open-source under the GNU Affero General Public License Version 3 (AGPLv3). You will find more information about the license and how to comply with it [here](https://docs.typebot.io/self-hosting#license-requirements). +Most of Typebot's code is open-source under the GNU Affero General Public License Version 3 (AGPLv3). You will find more information about the license and how to comply with it [here](https://docs.typebot.io/self-hosting#license-requirements). diff --git a/apps/builder/src/features/billing/api/createCheckoutSession.ts b/apps/builder/src/features/billing/api/createCheckoutSession.ts index 9d44f8eb4d..7d15cced98 100644 --- a/apps/builder/src/features/billing/api/createCheckoutSession.ts +++ b/apps/builder/src/features/billing/api/createCheckoutSession.ts @@ -1,11 +1,7 @@ -import prisma from '@typebot.io/lib/prisma' import { authenticatedProcedure } from '@/helpers/server/trpc' -import { TRPCError } from '@trpc/server' import { Plan } from '@typebot.io/prisma' -import Stripe from 'stripe' import { z } from 'zod' -import { isAdminWriteWorkspaceForbidden } from '@/features/workspace/helpers/isAdminWriteWorkspaceForbidden' -import { env } from '@typebot.io/env' +import { createCheckoutSession as createCheckoutSessionHandler } from '@typebot.io/billing/api/createCheckoutSession' export const createCheckoutSession = authenticatedProcedure .meta({ @@ -38,130 +34,6 @@ export const createCheckoutSession = authenticatedProcedure checkoutUrl: z.string(), }) ) - .mutation( - async ({ - input: { vat, email, company, workspaceId, currency, plan, returnUrl }, - ctx: { user }, - }) => { - if (!env.STRIPE_SECRET_KEY) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: 'Stripe environment variables are missing', - }) - const workspace = await prisma.workspace.findFirst({ - where: { - id: workspaceId, - }, - select: { - stripeId: true, - members: { - select: { - userId: true, - role: true, - }, - }, - }, - }) - - if (!workspace || isAdminWriteWorkspaceForbidden(workspace, user)) - throw new TRPCError({ - code: 'NOT_FOUND', - message: 'Workspace not found', - }) - if (workspace.stripeId) - throw new TRPCError({ - code: 'BAD_REQUEST', - message: 'Customer already exists, use updateSubscription endpoint.', - }) - - const stripe = new Stripe(env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-15', - }) - - await prisma.user.updateMany({ - where: { - id: user.id, - }, - data: { - company, - }, - }) - - const customer = await stripe.customers.create({ - email, - name: company, - metadata: { workspaceId }, - tax_id_data: vat - ? [vat as Stripe.CustomerCreateParams.TaxIdDatum] - : undefined, - }) - - const checkoutUrl = await createCheckoutSessionUrl(stripe)({ - customerId: customer.id, - userId: user.id, - workspaceId, - currency, - plan, - returnUrl, - }) - - if (!checkoutUrl) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: 'Stripe checkout session creation failed', - }) - - return { - checkoutUrl, - } - } + .mutation(async ({ input, ctx: { user } }) => + createCheckoutSessionHandler({ ...input, user }) ) - -type Props = { - customerId: string - workspaceId: string - currency: 'usd' | 'eur' - plan: 'STARTER' | 'PRO' - returnUrl: string - userId: string -} - -export const createCheckoutSessionUrl = - (stripe: Stripe) => - async ({ customerId, workspaceId, currency, plan, returnUrl }: Props) => { - const session = await stripe.checkout.sessions.create({ - success_url: `${returnUrl}?stripe=${plan}&success=true`, - cancel_url: `${returnUrl}?stripe=cancel`, - allow_promotion_codes: true, - customer: customerId, - customer_update: { - address: 'auto', - name: 'never', - }, - mode: 'subscription', - metadata: { - workspaceId, - plan, - }, - currency, - billing_address_collection: 'required', - automatic_tax: { enabled: true }, - line_items: [ - { - price: - plan === 'STARTER' - ? env.STRIPE_STARTER_PRICE_ID - : env.STRIPE_PRO_PRICE_ID, - quantity: 1, - }, - { - price: - plan === 'STARTER' - ? env.STRIPE_STARTER_CHATS_PRICE_ID - : env.STRIPE_PRO_CHATS_PRICE_ID, - }, - ], - }) - - return session.url - } diff --git a/apps/builder/src/features/billing/api/createCustomCheckoutSession.ts b/apps/builder/src/features/billing/api/createCustomCheckoutSession.ts index 697214d7a0..a397434f95 100644 --- a/apps/builder/src/features/billing/api/createCustomCheckoutSession.ts +++ b/apps/builder/src/features/billing/api/createCustomCheckoutSession.ts @@ -1,11 +1,6 @@ -import prisma from '@typebot.io/lib/prisma' import { authenticatedProcedure } from '@/helpers/server/trpc' -import { TRPCError } from '@trpc/server' -import { Plan } from '@typebot.io/prisma' -import Stripe from 'stripe' import { z } from 'zod' -import { isAdminWriteWorkspaceForbidden } from '@/features/workspace/helpers/isAdminWriteWorkspaceForbidden' -import { env } from '@typebot.io/env' +import { createCustomCheckoutSession as createCustomCheckoutSessionHandler } from '@typebot.io/billing/api/createCustomCheckoutSession' export const createCustomCheckoutSession = authenticatedProcedure .meta({ @@ -30,154 +25,9 @@ export const createCustomCheckoutSession = authenticatedProcedure checkoutUrl: z.string(), }) ) - .mutation( - async ({ input: { email, workspaceId, returnUrl }, ctx: { user } }) => { - if (!env.STRIPE_SECRET_KEY) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: 'Stripe environment variables are missing', - }) - const workspace = await prisma.workspace.findFirst({ - where: { - id: workspaceId, - }, - select: { - stripeId: true, - claimableCustomPlan: true, - name: true, - members: { - select: { - userId: true, - role: true, - }, - }, - }, - }) - if ( - !workspace?.claimableCustomPlan || - workspace.claimableCustomPlan.claimedAt || - isAdminWriteWorkspaceForbidden(workspace, user) - ) - throw new TRPCError({ - code: 'NOT_FOUND', - message: 'Custom plan not found', - }) - const stripe = new Stripe(env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-15', - }) - - const vat = - workspace.claimableCustomPlan.vatValue && - workspace.claimableCustomPlan.vatType - ? ({ - type: workspace.claimableCustomPlan.vatType, - value: workspace.claimableCustomPlan.vatValue, - } as Stripe.CustomerCreateParams.TaxIdDatum) - : undefined - - const customer = workspace.stripeId - ? await stripe.customers.retrieve(workspace.stripeId) - : await stripe.customers.create({ - email, - name: workspace.claimableCustomPlan.companyName ?? workspace.name, - metadata: { workspaceId }, - tax_id_data: vat ? [vat] : undefined, - }) - - const session = await stripe.checkout.sessions.create({ - success_url: `${returnUrl}?stripe=${Plan.CUSTOM}&success=true`, - cancel_url: `${returnUrl}?stripe=cancel`, - allow_promotion_codes: true, - customer: customer.id, - customer_update: { - address: 'auto', - name: 'never', - }, - mode: 'subscription', - metadata: { - claimableCustomPlanId: workspace.claimableCustomPlan.id, - }, - currency: workspace.claimableCustomPlan.currency, - billing_address_collection: 'required', - automatic_tax: { enabled: true }, - line_items: [ - { - price_data: { - currency: workspace.claimableCustomPlan.currency, - tax_behavior: 'exclusive', - recurring: { - interval: workspace.claimableCustomPlan.isYearly - ? 'year' - : 'month', - }, - product_data: { - name: workspace.claimableCustomPlan.name, - description: - workspace.claimableCustomPlan.description ?? undefined, - }, - unit_amount: workspace.claimableCustomPlan.price * 100, - }, - quantity: 1, - }, - { - price_data: { - currency: workspace.claimableCustomPlan.currency, - tax_behavior: 'exclusive', - recurring: { - interval: workspace.claimableCustomPlan.isYearly - ? 'year' - : 'month', - }, - product_data: { - name: 'Included chats per month', - }, - unit_amount: 0, - }, - quantity: workspace.claimableCustomPlan.chatsLimit, - }, - { - price_data: { - currency: workspace.claimableCustomPlan.currency, - tax_behavior: 'exclusive', - recurring: { - interval: workspace.claimableCustomPlan.isYearly - ? 'year' - : 'month', - }, - product_data: { - name: 'Included storage per month', - }, - unit_amount: 0, - }, - quantity: workspace.claimableCustomPlan.storageLimit, - }, - { - price_data: { - currency: workspace.claimableCustomPlan.currency, - tax_behavior: 'exclusive', - recurring: { - interval: workspace.claimableCustomPlan.isYearly - ? 'year' - : 'month', - }, - product_data: { - name: 'Included seats', - }, - unit_amount: 0, - }, - quantity: workspace.claimableCustomPlan.seatsLimit, - }, - ], - }) - - if (!session.url) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: 'Stripe checkout session creation failed', - }) - - return { - checkoutUrl: session.url, - } - } + .mutation(async ({ input, ctx: { user } }) => + createCustomCheckoutSessionHandler({ + ...input, + user, + }) ) diff --git a/apps/builder/src/features/billing/api/getBillingPortalUrl.ts b/apps/builder/src/features/billing/api/getBillingPortalUrl.ts index 48bb8405b5..7b1b3e8ab0 100644 --- a/apps/builder/src/features/billing/api/getBillingPortalUrl.ts +++ b/apps/builder/src/features/billing/api/getBillingPortalUrl.ts @@ -1,10 +1,6 @@ -import prisma from '@typebot.io/lib/prisma' import { authenticatedProcedure } from '@/helpers/server/trpc' -import { TRPCError } from '@trpc/server' -import Stripe from 'stripe' import { z } from 'zod' -import { isAdminWriteWorkspaceForbidden } from '@/features/workspace/helpers/isAdminWriteWorkspaceForbidden' -import { env } from '@typebot.io/env' +import { getBillingPortalUrl as getBillingPortalUrlHandler } from '@typebot.io/billing/api/getBillingPortalUrl' export const getBillingPortalUrl = authenticatedProcedure .meta({ @@ -26,39 +22,6 @@ export const getBillingPortalUrl = authenticatedProcedure billingPortalUrl: z.string(), }) ) - .query(async ({ input: { workspaceId }, ctx: { user } }) => { - if (!env.STRIPE_SECRET_KEY) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: 'STRIPE_SECRET_KEY var is missing', - }) - const workspace = await prisma.workspace.findFirst({ - where: { - id: workspaceId, - }, - select: { - stripeId: true, - members: { - select: { - userId: true, - role: true, - }, - }, - }, - }) - if (!workspace?.stripeId || isAdminWriteWorkspaceForbidden(workspace, user)) - throw new TRPCError({ - code: 'NOT_FOUND', - message: 'Workspace not found', - }) - const stripe = new Stripe(env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-15', - }) - const portalSession = await stripe.billingPortal.sessions.create({ - customer: workspace.stripeId, - return_url: `${env.NEXTAUTH_URL}/typebots`, - }) - return { - billingPortalUrl: portalSession.url, - } - }) + .query(async ({ input: { workspaceId }, ctx: { user } }) => + getBillingPortalUrlHandler({ workspaceId, user }) + ) diff --git a/apps/builder/src/features/billing/api/getSubscription.ts b/apps/builder/src/features/billing/api/getSubscription.ts index 663d73848c..3c17e52823 100644 --- a/apps/builder/src/features/billing/api/getSubscription.ts +++ b/apps/builder/src/features/billing/api/getSubscription.ts @@ -1,11 +1,7 @@ -import prisma from '@typebot.io/lib/prisma' import { authenticatedProcedure } from '@/helpers/server/trpc' -import { TRPCError } from '@trpc/server' -import Stripe from 'stripe' import { z } from 'zod' import { subscriptionSchema } from '@typebot.io/schemas/features/billing/subscription' -import { isReadWorkspaceFobidden } from '@/features/workspace/helpers/isReadWorkspaceFobidden' -import { env } from '@typebot.io/env' +import { getSubscription as getSubscriptionHandler } from '@typebot.io/billing/api/getSubscription' export const getSubscription = authenticatedProcedure .meta({ @@ -27,65 +23,6 @@ export const getSubscription = authenticatedProcedure subscription: subscriptionSchema.or(z.null().openapi({ type: 'string' })), }) ) - .query(async ({ input: { workspaceId }, ctx: { user } }) => { - if (!env.STRIPE_SECRET_KEY) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: 'Stripe environment variables are missing', - }) - const workspace = await prisma.workspace.findFirst({ - where: { - id: workspaceId, - }, - select: { - stripeId: true, - members: { - select: { - userId: true, - }, - }, - }, - }) - if (!workspace || isReadWorkspaceFobidden(workspace, user)) - throw new TRPCError({ - code: 'NOT_FOUND', - message: 'Workspace not found', - }) - if (!workspace?.stripeId) - return { - subscription: null, - } - const stripe = new Stripe(env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-15', - }) - const subscriptions = await stripe.subscriptions.list({ - customer: workspace.stripeId, - }) - - const currentSubscription = subscriptions.data - .filter((sub) => ['past_due', 'active'].includes(sub.status)) - .sort((a, b) => a.created - b.created) - .shift() - - if (!currentSubscription) - return { - subscription: null, - } - - return { - subscription: { - currentBillingPeriod: - subscriptionSchema.shape.currentBillingPeriod.parse({ - start: new Date(currentSubscription.current_period_start), - end: new Date(currentSubscription.current_period_end), - }), - status: subscriptionSchema.shape.status.parse( - currentSubscription.status - ), - currency: currentSubscription.currency as 'usd' | 'eur', - cancelDate: currentSubscription.cancel_at - ? new Date(currentSubscription.cancel_at * 1000) - : undefined, - }, - } - }) + .query(async ({ input: { workspaceId }, ctx: { user } }) => + getSubscriptionHandler({ workspaceId, user }) + ) diff --git a/apps/builder/src/features/billing/api/getUsage.ts b/apps/builder/src/features/billing/api/getUsage.ts index 39419ea5dc..2e006019a9 100644 --- a/apps/builder/src/features/billing/api/getUsage.ts +++ b/apps/builder/src/features/billing/api/getUsage.ts @@ -1,10 +1,6 @@ -import prisma from '@typebot.io/lib/prisma' import { authenticatedProcedure } from '@/helpers/server/trpc' -import { TRPCError } from '@trpc/server' import { z } from 'zod' -import { isReadWorkspaceFobidden } from '@/features/workspace/helpers/isReadWorkspaceFobidden' -import { env } from '@typebot.io/env' -import Stripe from 'stripe' +import { getUsage as getUsageHandler } from '@typebot.io/billing/api/getUsage' export const getUsage = authenticatedProcedure .meta({ @@ -26,87 +22,6 @@ export const getUsage = authenticatedProcedure }) ) .output(z.object({ totalChatsUsed: z.number(), resetsAt: z.date() })) - .query(async ({ input: { workspaceId }, ctx: { user } }) => { - const workspace = await prisma.workspace.findFirst({ - where: { - id: workspaceId, - }, - select: { - stripeId: true, - plan: true, - members: { - select: { - userId: true, - }, - }, - typebots: { - select: { id: true }, - }, - }, - }) - if (!workspace || isReadWorkspaceFobidden(workspace, user)) - throw new TRPCError({ - code: 'NOT_FOUND', - message: 'Workspace not found', - }) - - if ( - !env.STRIPE_SECRET_KEY || - !workspace.stripeId || - (workspace.plan !== 'STARTER' && workspace.plan !== 'PRO') - ) { - const now = new Date() - const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1) - - const totalChatsUsed = await prisma.result.count({ - where: { - typebotId: { in: workspace.typebots.map((typebot) => typebot.id) }, - hasStarted: true, - createdAt: { - gte: firstDayOfMonth, - }, - }, - }) - - const firstDayOfNextMonth = new Date( - firstDayOfMonth.getFullYear(), - firstDayOfMonth.getMonth() + 1, - 1 - ) - return { totalChatsUsed, resetsAt: firstDayOfNextMonth } - } - - const stripe = new Stripe(env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-15', - }) - - const subscriptions = await stripe.subscriptions.list({ - customer: workspace.stripeId, - }) - - const currentSubscription = subscriptions.data - .filter((sub) => ['past_due', 'active'].includes(sub.status)) - .sort((a, b) => a.created - b.created) - .shift() - - if (!currentSubscription) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: `No subscription found on workspace: ${workspaceId}`, - }) - - const totalChatsUsed = await prisma.result.count({ - where: { - typebotId: { in: workspace.typebots.map((typebot) => typebot.id) }, - hasStarted: true, - createdAt: { - gte: new Date(currentSubscription.current_period_start * 1000), - }, - }, - }) - - return { - totalChatsUsed, - resetsAt: new Date(currentSubscription.current_period_end * 1000), - } - }) + .query(async ({ input: { workspaceId }, ctx: { user } }) => + getUsageHandler({ workspaceId, user }) + ) diff --git a/apps/builder/src/features/billing/api/listInvoices.ts b/apps/builder/src/features/billing/api/listInvoices.ts index f778e57251..074b521e76 100644 --- a/apps/builder/src/features/billing/api/listInvoices.ts +++ b/apps/builder/src/features/billing/api/listInvoices.ts @@ -1,12 +1,7 @@ -import prisma from '@typebot.io/lib/prisma' import { authenticatedProcedure } from '@/helpers/server/trpc' -import { TRPCError } from '@trpc/server' -import Stripe from 'stripe' -import { isDefined } from '@typebot.io/lib' import { z } from 'zod' import { invoiceSchema } from '@typebot.io/schemas/features/billing/invoice' -import { isAdminWriteWorkspaceForbidden } from '@/features/workspace/helpers/isAdminWriteWorkspaceForbidden' -import { env } from '@typebot.io/env' +import { listInvoices as listInvoicesHandler } from '@typebot.io/billing/api/listInvoices' export const listInvoices = authenticatedProcedure .meta({ @@ -32,49 +27,6 @@ export const listInvoices = authenticatedProcedure invoices: z.array(invoiceSchema), }) ) - .query(async ({ input: { workspaceId }, ctx: { user } }) => { - if (!env.STRIPE_SECRET_KEY) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: 'STRIPE_SECRET_KEY var is missing', - }) - const workspace = await prisma.workspace.findFirst({ - where: { - id: workspaceId, - }, - select: { - stripeId: true, - members: { - select: { - userId: true, - role: true, - }, - }, - }, - }) - if (!workspace?.stripeId || isAdminWriteWorkspaceForbidden(workspace, user)) - throw new TRPCError({ - code: 'NOT_FOUND', - message: 'Workspace not found', - }) - const stripe = new Stripe(env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-15', - }) - const invoices = await stripe.invoices.list({ - customer: workspace.stripeId, - limit: 50, - }) - return { - invoices: invoices.data - .filter( - (invoice) => isDefined(invoice.invoice_pdf) && isDefined(invoice.id) - ) - .map((invoice) => ({ - id: invoice.number as string, - url: invoice.invoice_pdf as string, - amount: invoice.subtotal, - currency: invoice.currency, - date: invoice.status_transitions.paid_at, - })), - } - }) + .query(async ({ input: { workspaceId }, ctx: { user } }) => + listInvoicesHandler({ workspaceId, user }) + ) diff --git a/apps/builder/src/features/billing/api/updateSubscription.ts b/apps/builder/src/features/billing/api/updateSubscription.ts index 30948f38fe..c83b582b9d 100644 --- a/apps/builder/src/features/billing/api/updateSubscription.ts +++ b/apps/builder/src/features/billing/api/updateSubscription.ts @@ -1,14 +1,8 @@ -import prisma from '@typebot.io/lib/prisma' import { authenticatedProcedure } from '@/helpers/server/trpc' -import { TRPCError } from '@trpc/server' import { Plan } from '@typebot.io/prisma' import { workspaceSchema } from '@typebot.io/schemas' -import Stripe from 'stripe' 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/telemetry/trackEvents' +import { updateSubscription as updateSubscriptionHandler } from '@typebot.io/billing/api/updateSubscription' export const updateSubscription = authenticatedProcedure .meta({ @@ -34,140 +28,9 @@ export const updateSubscription = authenticatedProcedure checkoutUrl: z.string().nullish(), }) ) - .mutation( - async ({ - input: { workspaceId, plan, currency, returnUrl }, - ctx: { user }, - }) => { - if (!env.STRIPE_SECRET_KEY) - throw new TRPCError({ - code: 'INTERNAL_SERVER_ERROR', - message: 'Stripe environment variables are missing', - }) - const workspace = await prisma.workspace.findFirst({ - where: { - id: workspaceId, - }, - select: { - isPastDue: true, - stripeId: true, - members: { - select: { - userId: true, - role: true, - }, - }, - }, - }) - if (workspace?.isPastDue) - throw new TRPCError({ - code: 'BAD_REQUEST', - message: - 'You have unpaid invoices. Please head over your billing portal to pay it.', - }) - if ( - !workspace?.stripeId || - isAdminWriteWorkspaceForbidden(workspace, user) - ) - throw new TRPCError({ - code: 'NOT_FOUND', - message: 'Workspace not found', - }) - - const stripe = new Stripe(env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-15', - }) - const { data } = await stripe.subscriptions.list({ - customer: workspace.stripeId, - limit: 1, - status: 'active', - }) - const subscription = data[0] as Stripe.Subscription | undefined - const currentPlanItemId = subscription?.items.data.find((item) => - [env.STRIPE_STARTER_PRICE_ID, env.STRIPE_PRO_PRICE_ID].includes( - item.price.id - ) - )?.id - const currentUsageItemId = subscription?.items.data.find( - (item) => - item.price.id === env.STRIPE_STARTER_CHATS_PRICE_ID || - item.price.id === env.STRIPE_PRO_CHATS_PRICE_ID - )?.id - - const items = [ - { - id: currentPlanItemId, - price: - plan === Plan.STARTER - ? env.STRIPE_STARTER_PRICE_ID - : env.STRIPE_PRO_PRICE_ID, - quantity: 1, - }, - { - id: currentUsageItemId, - price: - plan === Plan.STARTER - ? env.STRIPE_STARTER_CHATS_PRICE_ID - : env.STRIPE_PRO_CHATS_PRICE_ID, - }, - ] - - if (subscription) { - if (plan === 'STARTER') { - const totalChatsUsed = await prisma.result.count({ - where: { - typebot: { workspaceId }, - hasStarted: true, - createdAt: { - gte: new Date(subscription.current_period_start * 1000), - }, - }, - }) - if (totalChatsUsed >= 4000) { - throw new TRPCError({ - code: 'BAD_REQUEST', - message: - "You have collected more than 4000 chats during this billing cycle. You can't downgrade to the Starter.", - }) - } - } - - await stripe.subscriptions.update(subscription.id, { - items, - proration_behavior: 'always_invoice', - }) - } else { - const checkoutUrl = await createCheckoutSessionUrl(stripe)({ - customerId: workspace.stripeId, - userId: user.id, - workspaceId, - currency, - plan, - returnUrl, - }) - - return { checkoutUrl } - } - - const updatedWorkspace = await prisma.workspace.update({ - where: { id: workspaceId }, - data: { - plan, - isQuarantined: false, - }, - }) - - await trackEvents([ - { - name: 'Subscription updated', - workspaceId, - userId: user.id, - data: { - plan, - }, - }, - ]) - - return { workspace: updatedWorkspace } - } + .mutation(async ({ input, ctx: { user } }) => + updateSubscriptionHandler({ + ...input, + user, + }) ) diff --git a/apps/builder/src/features/billing/components/ChangePlanForm.tsx b/apps/builder/src/features/billing/components/ChangePlanForm.tsx index 4571b88070..5524a130ff 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/billing/guessIfUserIsEuropean' +import { guessIfUserIsEuropean } from '@typebot.io/billing/helpers/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 0d31c3d30a..b6206fb3bb 100644 --- a/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx +++ b/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx @@ -18,7 +18,7 @@ import { } from '@chakra-ui/react' import { useTranslate } from '@tolgee/react' import { proChatTiers } from '@typebot.io/billing/constants' -import { formatPrice } from '@typebot.io/billing/formatPrice' +import { formatPrice } from '@typebot.io/billing/helpers/formatPrice' type Props = { isOpen: boolean diff --git a/apps/builder/src/features/billing/components/PreCheckoutModal.tsx b/apps/builder/src/features/billing/components/PreCheckoutModal.tsx index 2ce472b007..5b4c550c0b 100644 --- a/apps/builder/src/features/billing/components/PreCheckoutModal.tsx +++ b/apps/builder/src/features/billing/components/PreCheckoutModal.tsx @@ -17,8 +17,8 @@ import { import { useRouter } from 'next/router' import React, { FormEvent, useState } from 'react' import { isDefined } from '@typebot.io/lib' -import { taxIdTypes } from '../taxIdTypes' import { useTranslate } from '@tolgee/react' +import { taxIdTypes } from '@typebot.io/billing/taxIdTypes' export type PreCheckoutModalProps = { selectedSubscription: diff --git a/apps/builder/src/features/billing/components/ProPlanPricingCard.tsx b/apps/builder/src/features/billing/components/ProPlanPricingCard.tsx index 654a5b0a96..aa336584b2 100644 --- a/apps/builder/src/features/billing/components/ProPlanPricingCard.tsx +++ b/apps/builder/src/features/billing/components/ProPlanPricingCard.tsx @@ -14,7 +14,7 @@ import { import { Plan } from '@typebot.io/prisma' import { FeaturesList } from './FeaturesList' import { MoreInfoTooltip } from '@/components/MoreInfoTooltip' -import { formatPrice } from '@typebot.io/billing/formatPrice' +import { formatPrice } from '@typebot.io/billing/helpers/formatPrice' import { ChatsProTiersModal } from './ChatsProTiersModal' import { prices } from '@typebot.io/billing/constants' import { T, useTranslate } from '@tolgee/react' diff --git a/apps/builder/src/features/billing/components/StarterPlanPricingCard.tsx b/apps/builder/src/features/billing/components/StarterPlanPricingCard.tsx index 7e0024c7a9..2ebdabcd95 100644 --- a/apps/builder/src/features/billing/components/StarterPlanPricingCard.tsx +++ b/apps/builder/src/features/billing/components/StarterPlanPricingCard.tsx @@ -10,7 +10,7 @@ import { import { Plan } from '@typebot.io/prisma' import { FeaturesList } from './FeaturesList' import { MoreInfoTooltip } from '@/components/MoreInfoTooltip' -import { formatPrice } from '@typebot.io/billing/formatPrice' +import { formatPrice } from '@typebot.io/billing/helpers/formatPrice' import { prices } from '@typebot.io/billing/constants' import { T, useTranslate } from '@tolgee/react' diff --git a/apps/builder/src/features/billing/components/UsageProgressBars.tsx b/apps/builder/src/features/billing/components/UsageProgressBars.tsx index bff66ba38f..b3f454794a 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/billing/getChatsLimit' +import { getChatsLimit } from '@typebot.io/billing/helpers/getChatsLimit' import { useTranslate } from '@tolgee/react' type Props = { diff --git a/apps/builder/src/features/dashboard/components/DashboardPage.tsx b/apps/builder/src/features/dashboard/components/DashboardPage.tsx index a8ceb984f8..b0d5b7fede 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/billing/guessIfUserIsEuropean' +import { guessIfUserIsEuropean } from '@typebot.io/billing/helpers/guessIfUserIsEuropean' import { useTranslate } from '@tolgee/react' export const DashboardPage = () => { diff --git a/apps/builder/src/features/workspace/components/MembersList.tsx b/apps/builder/src/features/workspace/components/MembersList.tsx index 7b8c650b6a..0d7eb5b408 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/billing/getSeatsLimit' +import { getSeatsLimit } from '@typebot.io/billing/helpers/getSeatsLimit' import { useTranslate } from '@tolgee/react' export const MembersList = () => { diff --git a/apps/builder/src/pages/api/stripe/webhook.ts b/apps/builder/src/pages/api/stripe/webhook.ts index 2c3cd68b9a..aff5b38d77 100644 --- a/apps/builder/src/pages/api/stripe/webhook.ts +++ b/apps/builder/src/pages/api/stripe/webhook.ts @@ -1,346 +1,15 @@ -import { NextApiRequest, NextApiResponse } from 'next' -import { methodNotAllowed } from '@typebot.io/lib/api' -import Stripe from 'stripe' import Cors from 'micro-cors' -import { buffer } from 'micro' -import prisma from '@typebot.io/lib/prisma' -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/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') -const stripe = new Stripe(env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-15', -}) +import { webhookHandler } from '@typebot.io/billing/api/webhookHandler' const cors = Cors({ allowMethods: ['POST', 'HEAD'], }) -const webhookSecret = env.STRIPE_WEBHOOK_SECRET as string - export const config = { api: { bodyParser: false, }, } -const webhookHandler = async (req: NextApiRequest, res: NextApiResponse) => { - if (req.method === 'POST') { - const buf = await buffer(req) - const sig = req.headers['stripe-signature'] - - if (!sig) return res.status(400).send(`stripe-signature is missing`) - try { - const event = stripe.webhooks.constructEvent( - buf.toString(), - sig.toString(), - webhookSecret - ) - switch (event.type) { - case 'checkout.session.completed': { - const session = event.data.object as Stripe.Checkout.Session - const metadata = session.metadata as unknown as - | { - plan: 'STARTER' | 'PRO' - workspaceId: string - userId: string - } - | { claimableCustomPlanId: string; userId: string } - if ('plan' in metadata) { - const { workspaceId, plan } = metadata - if (!workspaceId || !plan) - return res - .status(500) - .send({ message: `Couldn't retrieve valid metadata` }) - - const workspace = await prisma.workspace.update({ - where: { id: workspaceId }, - data: { - plan, - stripeId: session.customer as string, - isQuarantined: false, - }, - include: { - members: { - select: { userId: true }, - where: { - role: WorkspaceRole.ADMIN, - }, - }, - }, - }) - - await trackEvents( - workspace.members.map((m) => ({ - name: 'Subscription updated', - workspaceId, - userId: m.userId, - data: { - plan, - }, - })) - ) - } else { - const { claimableCustomPlanId, userId } = metadata - if (!claimableCustomPlanId) - return res - .status(500) - .send({ message: `Couldn't retrieve valid metadata` }) - const { workspaceId, chatsLimit, seatsLimit, storageLimit } = - await prisma.claimableCustomPlan.update({ - where: { id: claimableCustomPlanId }, - data: { claimedAt: new Date() }, - }) - - await prisma.workspace.updateMany({ - where: { id: workspaceId }, - data: { - plan: Plan.CUSTOM, - stripeId: session.customer as string, - customChatsLimit: chatsLimit, - customStorageLimit: storageLimit, - customSeatsLimit: seatsLimit, - }, - }) - - await trackEvents([ - { - name: 'Subscription updated', - workspaceId, - userId, - data: { - plan: Plan.CUSTOM, - }, - }, - ]) - } - - return res.status(200).send({ message: 'workspace upgraded in DB' }) - } - case 'customer.subscription.updated': { - const subscription = event.data.object as Stripe.Subscription - if (subscription.status !== 'past_due') - return res.send({ message: 'Not past_due, skipping.' }) - const existingWorkspace = await prisma.workspace.findFirst({ - where: { - stripeId: subscription.customer as string, - }, - select: { - isPastDue: true, - id: true, - members: { - select: { userId: true, role: true }, - where: { role: WorkspaceRole.ADMIN }, - }, - }, - }) - if (!existingWorkspace) throw new Error('Workspace not found') - if (existingWorkspace?.isPastDue) - return res.send({ - message: 'Workspace already past due, skipping.', - }) - await prisma.workspace.updateMany({ - where: { - id: existingWorkspace.id, - }, - data: { - isPastDue: true, - }, - }) - await trackEvents( - existingWorkspace.members.map((m) => ({ - name: 'Workspace past due', - workspaceId: existingWorkspace.id, - userId: m.userId, - })) - ) - return res.send({ message: 'Workspace set to past due.' }) - } - case 'invoice.paid': { - const invoice = event.data.object as Stripe.Invoice - const workspace = await prisma.workspace.findFirst({ - where: { - stripeId: invoice.customer as string, - }, - select: { - isPastDue: true, - }, - }) - if (!workspace?.isPastDue) - return res.send({ message: 'Workspace not past_due, skipping.' }) - const outstandingInvoices = await stripe.invoices.list({ - customer: invoice.customer as string, - status: 'open', - }) - const outstandingInvoicesWithAdditionalUsageCosts = - outstandingInvoices.data.filter( - (invoice) => invoice.amount_due > prices['PRO'] * 100 - ) - if (outstandingInvoicesWithAdditionalUsageCosts.length > 0) - return res.send({ - message: 'Workspace has outstanding invoices, skipping.', - }) - const updatedWorkspace = await prisma.workspace.update({ - where: { - stripeId: invoice.customer as string, - }, - data: { - isPastDue: false, - }, - select: { - id: true, - members: { - select: { userId: true }, - where: { - role: WorkspaceRole.ADMIN, - }, - }, - }, - }) - await trackEvents( - updatedWorkspace.members.map((m) => ({ - name: 'Workspace past due status removed', - workspaceId: updatedWorkspace.id, - userId: m.userId, - })) - ) - return res.send({ message: 'Workspace was regulated' }) - } - case 'customer.subscription.deleted': { - const subscription = event.data.object as Stripe.Subscription - const { data } = await stripe.subscriptions.list({ - customer: subscription.customer as string, - limit: 1, - status: 'active', - }) - const existingSubscription = data[0] as - | Stripe.Subscription - | undefined - if (existingSubscription) - return res.send({ - message: - 'An active subscription still exists. Skipping downgrade.', - }) - const outstandingInvoices = await stripe.invoices.list({ - customer: subscription.customer as string, - status: 'open', - }) - const outstandingInvoicesWithAdditionalUsageCosts = - outstandingInvoices.data.filter( - (invoice) => invoice.amount_due > prices['PRO'] * 100 - ) - - const workspaceExist = - (await prisma.workspace.count({ - where: { - stripeId: subscription.customer as string, - }, - })) > 0 - - if (!workspaceExist) - return res.send({ message: 'Workspace not found, skipping...' }) - - const workspace = await prisma.workspace.update({ - where: { - stripeId: subscription.customer as string, - }, - data: { - plan: Plan.FREE, - customChatsLimit: null, - customStorageLimit: null, - customSeatsLimit: null, - isPastDue: outstandingInvoicesWithAdditionalUsageCosts.length > 0, - }, - include: { - members: { - select: { userId: true }, - where: { - role: WorkspaceRole.ADMIN, - }, - }, - }, - }) - - await trackEvents( - workspace.members.map((m) => ({ - name: 'Subscription updated', - workspaceId: workspace.id, - userId: m.userId, - data: { - plan: Plan.FREE, - }, - })) - ) - - const typebots = await prisma.typebot.findMany({ - where: { - workspaceId: workspace.id, - isArchived: { not: true }, - }, - include: { publishedTypebot: true }, - }) - for (const typebot of typebots) { - const settings = typebot.settings as Settings - if (settings.general?.isBrandingEnabled) continue - await prisma.typebot.updateMany({ - where: { id: typebot.id }, - data: { - settings: { - ...settings, - general: { - ...settings.general, - isBrandingEnabled: true, - }, - whatsApp: settings.whatsApp - ? { - ...settings.whatsApp, - isEnabled: false, - } - : undefined, - }, - }, - }) - const publishedTypebotSettings = typebot.publishedTypebot - ?.settings as Settings | null - if ( - !publishedTypebotSettings || - publishedTypebotSettings?.general?.isBrandingEnabled - ) - continue - await prisma.publicTypebot.updateMany({ - where: { id: typebot.id }, - data: { - settings: { - ...publishedTypebotSettings, - general: { - ...publishedTypebotSettings.general, - isBrandingEnabled: true, - }, - }, - }, - }) - } - return res.send({ message: 'workspace downgraded in DB' }) - } - default: { - return res.status(304).send({ message: 'event not handled' }) - } - } - } catch (err) { - console.error(err) - if (err instanceof Error) { - console.error(err) - return res.status(400).send(`Webhook Error: ${err.message}`) - } - return res.status(500).send(`Error occured: ${err}`) - } - } - return methodNotAllowed(res) -} - export default cors(webhookHandler as RequestHandler) diff --git a/apps/builder/src/pages/api/workspaces/[workspaceId]/invitations.ts b/apps/builder/src/pages/api/workspaces/[workspaceId]/invitations.ts index 8162bae472..d62ab13929 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/billing/getSeatsLimit' +import { getSeatsLimit } from '@typebot.io/billing/helpers/getSeatsLimit' import { env } from '@typebot.io/env' const handler = async (req: NextApiRequest, res: NextApiResponse) => { diff --git a/apps/docs/self-hosting/configuration.mdx b/apps/docs/self-hosting/configuration.mdx index 79187b53cd..71fd8f6a13 100644 --- a/apps/docs/self-hosting/configuration.mdx +++ b/apps/docs/self-hosting/configuration.mdx @@ -298,31 +298,6 @@ The [official Typebot managed service](https://app.typebot.io/) uses other servi The related environment variables are listed here but you are probably not interested in these if you self-host Typebot. - - -| Parameter | Default | Description | -| ----------------------------- | ------- | ----------------------------------------- | -| NEXT_PUBLIC_STRIPE_PUBLIC_KEY | | Stripe public key | -| STRIPE_SECRET_KEY | | Stripe secret key | -| STRIPE_STARTER_PRICE_ID | | Starter plan price id | -| STRIPE_PRO_PRICE_ID | | Pro monthly plan price id | -| STRIPE_STARTER_CHATS_PRICE_ID | | Starter Additional chats monthly price id | -| STRIPE_PRO_CHATS_PRICE_ID | | Pro Additional chats monthly price id | -| STRIPE_WEBHOOK_SECRET | | Stripe Webhook secret | - - - - - -| Parameter | Default | Description | -| ---------------------- | ------- | -------------------------------------- | -| NEXT_PUBLIC_SENTRY_DSN | | Sentry DSN | -| SENTRY_AUTH_TOKEN | | Used to upload sourcemaps on app build | -| SENTRY_PROJECT | | Sentry project name | -| SENTRY_ORG | | Sentry organization name | - - - | Parameter | Default | Description | @@ -333,14 +308,6 @@ The related environment variables are listed here but you are probably not inter - - -| Parameter | Default | Description | -| ----------------- | ------- | ------------------------------------------------------------------------ | -| SLEEKPLAN_SSO_KEY | | Sleekplan SSO key used to automatically authenticate a user in Sleekplan | - - - | Parameter | Default | Description | diff --git a/apps/docs/self-hosting/get-started.mdx b/apps/docs/self-hosting/get-started.mdx index 81570ae4e0..ae8c1b9cf4 100644 --- a/apps/docs/self-hosting/get-started.mdx +++ b/apps/docs/self-hosting/get-started.mdx @@ -3,7 +3,7 @@ title: Overview icon: server --- -Typebot is 100% open-source and can be self-hosted on your own server. This guide will walk you through the process of setting up your own instance of Typebot. +Typebot is open-source and can be self-hosted on your own server. This guide will walk you through the process of setting up your own instance of Typebot. The easiest way to get started with Typebot is with [the official managed @@ -25,11 +25,16 @@ Typebot is 100% open-source and can be self-hosted on your own server. This guid ## License requirements -Typebot is open-source under the GNU Affero General Public License Version 3 (AGPLv3). You can find it [here](https://raw.githubusercontent.com/baptisteArno/typebot.io/main/LICENSE). The goal of the AGPLv3 license is to: +You can find the full license [here](https://raw.githubusercontent.com/baptisteArno/typebot.io/main/LICENSE). + +Here is a summary of the license: + +All content that resides under the [ee](https://github.com/baptisteArno/typebot.io/tree/main/ee) directory of this repository is licensed under the license defined in [ee/LICENSE](./ee/LICENSE). The [ee](https://github.com/baptisteArno/typebot.io/tree/main/ee) folder contains the code for the [landing page](https://typebot.io) and the billing feature. We restrict these to a Commercial License to make sure other companies can't simply clone Typebot's homepage and billing system and offer the same service without contributing to the open-source project. + +Content outside of this directory is available under the GNU Affero General Public License Version 3 (AGPLv3). The goal of the AGPLv3 license is to: - Maximize user freedom and to encourage companies to contribute to open source. -- Prevent corporations from taking the code and using it as part of their closed-source proprietary products -- Prevent corporations from offering Typebot as a service without contributing to the open source project +- Prevent corporations from offering Typebot as a service without contributing back to the open source project - Prevent corporations from confusing people and making them think that the service they sell is in any shape or form approved by the original team Here are the 3 different possible use cases: @@ -46,7 +51,7 @@ Here are the 3 different possible use cases:
    -
  1. You need to open-source your modifications.
  2. {' '} +
  3. You need to open-source your fork of the project.
  4. After your users registration, you should provide a prominent mention and link to the original project (https://typebot.io). You should clearly @@ -54,11 +59,19 @@ Here are the 3 different possible use cases: Typebot. It would be also a good place to explain your version advantages comparing to the original project.
  5. +
  6. If you want to use code that resides under the [ee](https://github.com/baptisteArno/typebot.io/tree/main/ee) folder (landing page or billing feature), you need a [Commercial License key](https://typebot.io/enterprise-lead-form).
  7. You need to provide a link to your forked repository somewhere in the landing page or the builder. This way, interested users can easily access and review the modifications you've made.
+ + Either use case, [sponsoring the + project](https://github.com/sponsors/baptisteArno) is a great way to give back + to the community and to contribute to the long-term sustainability of the + project. ❤️ + + Typebot is composed of 2 Next.js applications you need to deploy: - the builder, where you build your typebots diff --git a/apps/landing-page/LICENSE b/apps/landing-page/LICENSE deleted file mode 100644 index d13cc4b26a..0000000000 --- a/apps/landing-page/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -The MIT License (MIT) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/apps/landing-page/README.md b/apps/landing-page/README.md deleted file mode 100644 index 0b1f27508b..0000000000 --- a/apps/landing-page/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Typebot.io - -This repository contains the source code of [Typebot's landing page](https://www.typebot.io) diff --git a/ee/LICENSE b/ee/LICENSE new file mode 100644 index 0000000000..5714df50d2 --- /dev/null +++ b/ee/LICENSE @@ -0,0 +1,34 @@ +The Typebot Commercial License (the “Commercial License”) +Copyright (c) 2024-present Typebot + +With regard to the Typebot Software: + +This software and associated documentation files (the "Software") may only be +used in production, if you (and any entity that you represent) have a valid +Typebot Enterprise Edition subscription ("Commercial Subscription"). Subject to the foregoing sentence, +you are free to modify this Software and publish patches to the Software. You agree +that Typebot and/or its licensors (as applicable) retain all right, title and interest in +and to all such modifications and/or patches, and all such modifications and/or +patches may only be used, copied, modified, displayed, distributed, or otherwise +exploited with a valid Commercial Subscription for the correct number of hosts. +Notwithstanding the foregoing, you may copy and modify the Software for development +and testing purposes, without requiring a subscription. You agree that Typebot and/or +its licensors (as applicable) retain all right, title and interest in and to all such +modifications. You are not granted any other rights beyond what is expressly stated herein. +Subject to the foregoing, it is forbidden to copy, merge, publish, distribute, sublicense, +and/or sell the Software. + +This Commercial License applies only to the part of this Software that is not distributed under +the AGPLv3 license. Any part of this Software distributed under the MIT license or which +is served client-side as an image, font, cascading stylesheet (CSS), file which produces +or is compiled, arranged, augmented, or combined into client-side JavaScript, in whole or +in part, is copyrighted under the AGPLv3 license. The full text of this Commercial License shall +be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ee/README.md b/ee/README.md new file mode 100644 index 0000000000..bcdf42ab3c --- /dev/null +++ b/ee/README.md @@ -0,0 +1,36 @@ +
+

+ + Typebot illustration + + + Typebot illustration + +

+
+ + +Get a license key + + +## Enterprise Edition + +The /ee subfolder is the place for all the Enterprise Edition features from our hosted plan. + +This folder contains all the code associated to the landing page and billing features. + +This Enterprise edition exists mainly to prevent people to simply fork the project and re-sell it without providing any modifications. + +> ❗ WARNING: This repository is copyrighted (unlike the main repo). You are not allowed to use this code in your self-hosted instance of Typebot without obtaining a proper [license](https://typebot.io/enterprise-lead-form) first❗ + +### Configure STRIPE + +| Parameter | Default | Description | +| ----------------------------- | ------- | ----------------------------------------- | +| NEXT_PUBLIC_STRIPE_PUBLIC_KEY | | Stripe public key | +| STRIPE_SECRET_KEY | | Stripe secret key | +| STRIPE_STARTER_PRICE_ID | | Starter plan price id | +| STRIPE_PRO_PRICE_ID | | Pro monthly plan price id | +| STRIPE_STARTER_CHATS_PRICE_ID | | Starter Additional chats monthly price id | +| STRIPE_PRO_CHATS_PRICE_ID | | Pro Additional chats monthly price id | +| STRIPE_WEBHOOK_SECRET | | Stripe Webhook secret | diff --git a/apps/landing-page/.eslintrc.js b/ee/apps/landing-page/.eslintrc.js similarity index 100% rename from apps/landing-page/.eslintrc.js rename to ee/apps/landing-page/.eslintrc.js diff --git a/apps/landing-page/app/blog/Posts.tsx b/ee/apps/landing-page/app/blog/Posts.tsx similarity index 100% rename from apps/landing-page/app/blog/Posts.tsx rename to ee/apps/landing-page/app/blog/Posts.tsx diff --git a/apps/landing-page/app/blog/[slug]/Post.tsx b/ee/apps/landing-page/app/blog/[slug]/Post.tsx similarity index 100% rename from apps/landing-page/app/blog/[slug]/Post.tsx rename to ee/apps/landing-page/app/blog/[slug]/Post.tsx diff --git a/apps/landing-page/app/blog/[slug]/Table.tsx b/ee/apps/landing-page/app/blog/[slug]/Table.tsx similarity index 100% rename from apps/landing-page/app/blog/[slug]/Table.tsx rename to ee/apps/landing-page/app/blog/[slug]/Table.tsx diff --git a/apps/landing-page/app/blog/[slug]/Tweet.tsx b/ee/apps/landing-page/app/blog/[slug]/Tweet.tsx similarity index 100% rename from apps/landing-page/app/blog/[slug]/Tweet.tsx rename to ee/apps/landing-page/app/blog/[slug]/Tweet.tsx diff --git a/apps/landing-page/app/blog/[slug]/page.tsx b/ee/apps/landing-page/app/blog/[slug]/page.tsx similarity index 100% rename from apps/landing-page/app/blog/[slug]/page.tsx rename to ee/apps/landing-page/app/blog/[slug]/page.tsx diff --git a/apps/landing-page/app/blog/[slug]/tweet.css b/ee/apps/landing-page/app/blog/[slug]/tweet.css similarity index 100% rename from apps/landing-page/app/blog/[slug]/tweet.css rename to ee/apps/landing-page/app/blog/[slug]/tweet.css diff --git a/apps/landing-page/app/blog/page.tsx b/ee/apps/landing-page/app/blog/page.tsx similarity index 100% rename from apps/landing-page/app/blog/page.tsx rename to ee/apps/landing-page/app/blog/page.tsx diff --git a/apps/landing-page/app/db/blog.ts b/ee/apps/landing-page/app/db/blog.ts similarity index 100% rename from apps/landing-page/app/db/blog.ts rename to ee/apps/landing-page/app/db/blog.ts diff --git a/apps/landing-page/app/layout.tsx b/ee/apps/landing-page/app/layout.tsx similarity index 100% rename from apps/landing-page/app/layout.tsx rename to ee/apps/landing-page/app/layout.tsx diff --git a/apps/landing-page/app/og/route.tsx b/ee/apps/landing-page/app/og/route.tsx similarity index 100% rename from apps/landing-page/app/og/route.tsx rename to ee/apps/landing-page/app/og/route.tsx diff --git a/apps/landing-page/app/providers.tsx b/ee/apps/landing-page/app/providers.tsx similarity index 100% rename from apps/landing-page/app/providers.tsx rename to ee/apps/landing-page/app/providers.tsx diff --git a/apps/landing-page/assets/Outfit-Medium.ttf b/ee/apps/landing-page/assets/Outfit-Medium.ttf similarity index 100% rename from apps/landing-page/assets/Outfit-Medium.ttf rename to ee/apps/landing-page/assets/Outfit-Medium.ttf diff --git a/apps/landing-page/assets/icons/AccessibilityIcon.tsx b/ee/apps/landing-page/assets/icons/AccessibilityIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/AccessibilityIcon.tsx rename to ee/apps/landing-page/assets/icons/AccessibilityIcon.tsx diff --git a/apps/landing-page/assets/icons/ArrowRight.tsx b/ee/apps/landing-page/assets/icons/ArrowRight.tsx similarity index 100% rename from apps/landing-page/assets/icons/ArrowRight.tsx rename to ee/apps/landing-page/assets/icons/ArrowRight.tsx diff --git a/apps/landing-page/assets/icons/CaluclatorIcon.tsx b/ee/apps/landing-page/assets/icons/CaluclatorIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/CaluclatorIcon.tsx rename to ee/apps/landing-page/assets/icons/CaluclatorIcon.tsx diff --git a/apps/landing-page/assets/icons/CapterraIcon.tsx b/ee/apps/landing-page/assets/icons/CapterraIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/CapterraIcon.tsx rename to ee/apps/landing-page/assets/icons/CapterraIcon.tsx diff --git a/apps/landing-page/assets/icons/CheckCircleIcon.tsx b/ee/apps/landing-page/assets/icons/CheckCircleIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/CheckCircleIcon.tsx rename to ee/apps/landing-page/assets/icons/CheckCircleIcon.tsx diff --git a/apps/landing-page/assets/icons/CheckIcon.tsx b/ee/apps/landing-page/assets/icons/CheckIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/CheckIcon.tsx rename to ee/apps/landing-page/assets/icons/CheckIcon.tsx diff --git a/apps/landing-page/assets/icons/ChevronDownIcon.tsx b/ee/apps/landing-page/assets/icons/ChevronDownIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/ChevronDownIcon.tsx rename to ee/apps/landing-page/assets/icons/ChevronDownIcon.tsx diff --git a/apps/landing-page/assets/icons/ChevronRightIcon.tsx b/ee/apps/landing-page/assets/icons/ChevronRightIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/ChevronRightIcon.tsx rename to ee/apps/landing-page/assets/icons/ChevronRightIcon.tsx diff --git a/apps/landing-page/assets/icons/CloseIcon.tsx b/ee/apps/landing-page/assets/icons/CloseIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/CloseIcon.tsx rename to ee/apps/landing-page/assets/icons/CloseIcon.tsx diff --git a/apps/landing-page/assets/icons/ConditionIcon.tsx b/ee/apps/landing-page/assets/icons/ConditionIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/ConditionIcon.tsx rename to ee/apps/landing-page/assets/icons/ConditionIcon.tsx diff --git a/apps/landing-page/assets/icons/DoIcon.tsx b/ee/apps/landing-page/assets/icons/DoIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/DoIcon.tsx rename to ee/apps/landing-page/assets/icons/DoIcon.tsx diff --git a/apps/landing-page/assets/icons/DocIcon.tsx b/ee/apps/landing-page/assets/icons/DocIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/DocIcon.tsx rename to ee/apps/landing-page/assets/icons/DocIcon.tsx diff --git a/apps/landing-page/assets/icons/DontIcon.tsx b/ee/apps/landing-page/assets/icons/DontIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/DontIcon.tsx rename to ee/apps/landing-page/assets/icons/DontIcon.tsx diff --git a/apps/landing-page/assets/icons/EmailIcon.tsx b/ee/apps/landing-page/assets/icons/EmailIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/EmailIcon.tsx rename to ee/apps/landing-page/assets/icons/EmailIcon.tsx diff --git a/apps/landing-page/assets/icons/ExternalLinkIcon.tsx b/ee/apps/landing-page/assets/icons/ExternalLinkIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/ExternalLinkIcon.tsx rename to ee/apps/landing-page/assets/icons/ExternalLinkIcon.tsx diff --git a/apps/landing-page/assets/icons/FolderIcon.tsx b/ee/apps/landing-page/assets/icons/FolderIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/FolderIcon.tsx rename to ee/apps/landing-page/assets/icons/FolderIcon.tsx diff --git a/apps/landing-page/assets/icons/GithubLogo.tsx b/ee/apps/landing-page/assets/icons/GithubLogo.tsx similarity index 100% rename from apps/landing-page/assets/icons/GithubLogo.tsx rename to ee/apps/landing-page/assets/icons/GithubLogo.tsx diff --git a/apps/landing-page/assets/icons/HamburgerIcon.tsx b/ee/apps/landing-page/assets/icons/HamburgerIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/HamburgerIcon.tsx rename to ee/apps/landing-page/assets/icons/HamburgerIcon.tsx diff --git a/apps/landing-page/assets/icons/HelpCircleIcon.tsx b/ee/apps/landing-page/assets/icons/HelpCircleIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/HelpCircleIcon.tsx rename to ee/apps/landing-page/assets/icons/HelpCircleIcon.tsx diff --git a/apps/landing-page/assets/icons/Logo.tsx b/ee/apps/landing-page/assets/icons/Logo.tsx similarity index 100% rename from apps/landing-page/assets/icons/Logo.tsx rename to ee/apps/landing-page/assets/icons/Logo.tsx diff --git a/apps/landing-page/assets/icons/MapIcon.tsx b/ee/apps/landing-page/assets/icons/MapIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/MapIcon.tsx rename to ee/apps/landing-page/assets/icons/MapIcon.tsx diff --git a/apps/landing-page/assets/icons/PeopleCircleIcon.tsx b/ee/apps/landing-page/assets/icons/PeopleCircleIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/PeopleCircleIcon.tsx rename to ee/apps/landing-page/assets/icons/PeopleCircleIcon.tsx diff --git a/apps/landing-page/assets/icons/PersonAddIcon.tsx b/ee/apps/landing-page/assets/icons/PersonAddIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/PersonAddIcon.tsx rename to ee/apps/landing-page/assets/icons/PersonAddIcon.tsx diff --git a/apps/landing-page/assets/icons/ProductHuntIcon.tsx b/ee/apps/landing-page/assets/icons/ProductHuntIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/ProductHuntIcon.tsx rename to ee/apps/landing-page/assets/icons/ProductHuntIcon.tsx diff --git a/apps/landing-page/assets/icons/QuoteLeftIcon.tsx b/ee/apps/landing-page/assets/icons/QuoteLeftIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/QuoteLeftIcon.tsx rename to ee/apps/landing-page/assets/icons/QuoteLeftIcon.tsx diff --git a/apps/landing-page/assets/icons/RedditIcon.tsx b/ee/apps/landing-page/assets/icons/RedditIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/RedditIcon.tsx rename to ee/apps/landing-page/assets/icons/RedditIcon.tsx diff --git a/apps/landing-page/assets/icons/ShareIcon.tsx b/ee/apps/landing-page/assets/icons/ShareIcon.tsx similarity index 100% rename from apps/landing-page/assets/icons/ShareIcon.tsx rename to ee/apps/landing-page/assets/icons/ShareIcon.tsx diff --git a/apps/landing-page/assets/icons/index.ts b/ee/apps/landing-page/assets/icons/index.ts similarity index 100% rename from apps/landing-page/assets/icons/index.ts rename to ee/apps/landing-page/assets/icons/index.ts diff --git a/apps/landing-page/assets/illustrations/Flare.tsx b/ee/apps/landing-page/assets/illustrations/Flare.tsx similarity index 100% rename from apps/landing-page/assets/illustrations/Flare.tsx rename to ee/apps/landing-page/assets/illustrations/Flare.tsx diff --git a/apps/landing-page/assets/illustrations/HandDrawnArrow.tsx b/ee/apps/landing-page/assets/illustrations/HandDrawnArrow.tsx similarity index 100% rename from apps/landing-page/assets/illustrations/HandDrawnArrow.tsx rename to ee/apps/landing-page/assets/illustrations/HandDrawnArrow.tsx diff --git a/apps/landing-page/assets/logos/AirtableLogo.tsx b/ee/apps/landing-page/assets/logos/AirtableLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/AirtableLogo.tsx rename to ee/apps/landing-page/assets/logos/AirtableLogo.tsx diff --git a/apps/landing-page/assets/logos/CalendlyLogo.tsx b/ee/apps/landing-page/assets/logos/CalendlyLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/CalendlyLogo.tsx rename to ee/apps/landing-page/assets/logos/CalendlyLogo.tsx diff --git a/apps/landing-page/assets/logos/GmailLogo.tsx b/ee/apps/landing-page/assets/logos/GmailLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/GmailLogo.tsx rename to ee/apps/landing-page/assets/logos/GmailLogo.tsx diff --git a/apps/landing-page/assets/logos/GoogleCalendarLogo.tsx b/ee/apps/landing-page/assets/logos/GoogleCalendarLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/GoogleCalendarLogo.tsx rename to ee/apps/landing-page/assets/logos/GoogleCalendarLogo.tsx diff --git a/apps/landing-page/assets/logos/GoogleDriveLogo.tsx b/ee/apps/landing-page/assets/logos/GoogleDriveLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/GoogleDriveLogo.tsx rename to ee/apps/landing-page/assets/logos/GoogleDriveLogo.tsx diff --git a/apps/landing-page/assets/logos/GoogleSheetsLogo.tsx b/ee/apps/landing-page/assets/logos/GoogleSheetsLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/GoogleSheetsLogo.tsx rename to ee/apps/landing-page/assets/logos/GoogleSheetsLogo.tsx diff --git a/apps/landing-page/assets/logos/HubspotLogo.tsx b/ee/apps/landing-page/assets/logos/HubspotLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/HubspotLogo.tsx rename to ee/apps/landing-page/assets/logos/HubspotLogo.tsx diff --git a/apps/landing-page/assets/logos/MailchimpLogo.tsx b/ee/apps/landing-page/assets/logos/MailchimpLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/MailchimpLogo.tsx rename to ee/apps/landing-page/assets/logos/MailchimpLogo.tsx diff --git a/apps/landing-page/assets/logos/N8nLogo.tsx b/ee/apps/landing-page/assets/logos/N8nLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/N8nLogo.tsx rename to ee/apps/landing-page/assets/logos/N8nLogo.tsx diff --git a/apps/landing-page/assets/logos/NotionLogo.tsx b/ee/apps/landing-page/assets/logos/NotionLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/NotionLogo.tsx rename to ee/apps/landing-page/assets/logos/NotionLogo.tsx diff --git a/apps/landing-page/assets/logos/PipedriveLogo.tsx b/ee/apps/landing-page/assets/logos/PipedriveLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/PipedriveLogo.tsx rename to ee/apps/landing-page/assets/logos/PipedriveLogo.tsx diff --git a/apps/landing-page/assets/logos/SalesforceLogo.tsx b/ee/apps/landing-page/assets/logos/SalesforceLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/SalesforceLogo.tsx rename to ee/apps/landing-page/assets/logos/SalesforceLogo.tsx diff --git a/apps/landing-page/assets/logos/ShopifyLogo.tsx b/ee/apps/landing-page/assets/logos/ShopifyLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/ShopifyLogo.tsx rename to ee/apps/landing-page/assets/logos/ShopifyLogo.tsx diff --git a/apps/landing-page/assets/logos/SlackLogo.tsx b/ee/apps/landing-page/assets/logos/SlackLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/SlackLogo.tsx rename to ee/apps/landing-page/assets/logos/SlackLogo.tsx diff --git a/apps/landing-page/assets/logos/StripeClimateLogo.tsx b/ee/apps/landing-page/assets/logos/StripeClimateLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/StripeClimateLogo.tsx rename to ee/apps/landing-page/assets/logos/StripeClimateLogo.tsx diff --git a/apps/landing-page/assets/logos/WebflowLogo.tsx b/ee/apps/landing-page/assets/logos/WebflowLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/WebflowLogo.tsx rename to ee/apps/landing-page/assets/logos/WebflowLogo.tsx diff --git a/apps/landing-page/assets/logos/WixLogo.tsx b/ee/apps/landing-page/assets/logos/WixLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/WixLogo.tsx rename to ee/apps/landing-page/assets/logos/WixLogo.tsx diff --git a/apps/landing-page/assets/logos/WordpressLogo.tsx b/ee/apps/landing-page/assets/logos/WordpressLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/WordpressLogo.tsx rename to ee/apps/landing-page/assets/logos/WordpressLogo.tsx diff --git a/apps/landing-page/assets/logos/ZapierLogo.tsx b/ee/apps/landing-page/assets/logos/ZapierLogo.tsx similarity index 100% rename from apps/landing-page/assets/logos/ZapierLogo.tsx rename to ee/apps/landing-page/assets/logos/ZapierLogo.tsx diff --git a/apps/landing-page/assets/logos/index.ts b/ee/apps/landing-page/assets/logos/index.ts similarity index 100% rename from apps/landing-page/assets/logos/index.ts rename to ee/apps/landing-page/assets/logos/index.ts diff --git a/apps/landing-page/assets/prose.css b/ee/apps/landing-page/assets/prose.css similarity index 100% rename from apps/landing-page/assets/prose.css rename to ee/apps/landing-page/assets/prose.css diff --git a/apps/landing-page/assets/style.css b/ee/apps/landing-page/assets/style.css similarity index 100% rename from apps/landing-page/assets/style.css rename to ee/apps/landing-page/assets/style.css diff --git a/apps/landing-page/components/Homepage/EasyBuildingExperience.tsx b/ee/apps/landing-page/components/Homepage/EasyBuildingExperience.tsx similarity index 100% rename from apps/landing-page/components/Homepage/EasyBuildingExperience.tsx rename to ee/apps/landing-page/components/Homepage/EasyBuildingExperience.tsx diff --git a/apps/landing-page/components/Homepage/EasyEmbed.tsx b/ee/apps/landing-page/components/Homepage/EasyEmbed.tsx similarity index 100% rename from apps/landing-page/components/Homepage/EasyEmbed.tsx rename to ee/apps/landing-page/components/Homepage/EasyEmbed.tsx diff --git a/apps/landing-page/components/Homepage/EndCta.tsx b/ee/apps/landing-page/components/Homepage/EndCta.tsx similarity index 100% rename from apps/landing-page/components/Homepage/EndCta.tsx rename to ee/apps/landing-page/components/Homepage/EndCta.tsx diff --git a/apps/landing-page/components/Homepage/Features/FeatureCard.tsx b/ee/apps/landing-page/components/Homepage/Features/FeatureCard.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Features/FeatureCard.tsx rename to ee/apps/landing-page/components/Homepage/Features/FeatureCard.tsx diff --git a/apps/landing-page/components/Homepage/Features/Features.tsx b/ee/apps/landing-page/components/Homepage/Features/Features.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Features/Features.tsx rename to ee/apps/landing-page/components/Homepage/Features/Features.tsx diff --git a/apps/landing-page/components/Homepage/Features/index.tsx b/ee/apps/landing-page/components/Homepage/Features/index.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Features/index.tsx rename to ee/apps/landing-page/components/Homepage/Features/index.tsx diff --git a/apps/landing-page/components/Homepage/Hero/BackgroundPolygons.tsx b/ee/apps/landing-page/components/Homepage/Hero/BackgroundPolygons.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Hero/BackgroundPolygons.tsx rename to ee/apps/landing-page/components/Homepage/Hero/BackgroundPolygons.tsx diff --git a/apps/landing-page/components/Homepage/Hero/Brands.tsx b/ee/apps/landing-page/components/Homepage/Hero/Brands.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Hero/Brands.tsx rename to ee/apps/landing-page/components/Homepage/Hero/Brands.tsx diff --git a/apps/landing-page/components/Homepage/Hero/Hero.tsx b/ee/apps/landing-page/components/Homepage/Hero/Hero.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Hero/Hero.tsx rename to ee/apps/landing-page/components/Homepage/Hero/Hero.tsx diff --git a/apps/landing-page/components/Homepage/Hero/index.tsx b/ee/apps/landing-page/components/Homepage/Hero/index.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Hero/index.tsx rename to ee/apps/landing-page/components/Homepage/Hero/index.tsx diff --git a/apps/landing-page/components/Homepage/Integrations.tsx b/ee/apps/landing-page/components/Homepage/Integrations.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Integrations.tsx rename to ee/apps/landing-page/components/Homepage/Integrations.tsx diff --git a/apps/landing-page/components/Homepage/IntroducingChatApps.tsx b/ee/apps/landing-page/components/Homepage/IntroducingChatApps.tsx similarity index 100% rename from apps/landing-page/components/Homepage/IntroducingChatApps.tsx rename to ee/apps/landing-page/components/Homepage/IntroducingChatApps.tsx diff --git a/apps/landing-page/components/Homepage/RealTimeResults.tsx b/ee/apps/landing-page/components/Homepage/RealTimeResults.tsx similarity index 100% rename from apps/landing-page/components/Homepage/RealTimeResults.tsx rename to ee/apps/landing-page/components/Homepage/RealTimeResults.tsx diff --git a/apps/landing-page/components/Homepage/Testimonials/Testimonial.tsx b/ee/apps/landing-page/components/Homepage/Testimonials/Testimonial.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Testimonials/Testimonial.tsx rename to ee/apps/landing-page/components/Homepage/Testimonials/Testimonial.tsx diff --git a/apps/landing-page/components/Homepage/Testimonials/Testimonials.tsx b/ee/apps/landing-page/components/Homepage/Testimonials/Testimonials.tsx similarity index 100% rename from apps/landing-page/components/Homepage/Testimonials/Testimonials.tsx rename to ee/apps/landing-page/components/Homepage/Testimonials/Testimonials.tsx diff --git a/apps/landing-page/components/Homepage/Testimonials/index.ts b/ee/apps/landing-page/components/Homepage/Testimonials/index.ts similarity index 100% rename from apps/landing-page/components/Homepage/Testimonials/index.ts rename to ee/apps/landing-page/components/Homepage/Testimonials/index.ts diff --git a/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx b/ee/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx similarity index 97% rename from apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx rename to ee/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx index 1922bcef19..ce572aa598 100644 --- a/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx +++ b/ee/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx @@ -17,7 +17,7 @@ import { Tr, } from '@chakra-ui/react' import { proChatTiers } from '@typebot.io/billing/constants' -import { formatPrice } from '@typebot.io/billing/formatPrice' +import { formatPrice } from '@typebot.io/billing/helpers/formatPrice' type Props = { isOpen: boolean diff --git a/apps/landing-page/components/PricingPage/EnterprisePlanCard.tsx b/ee/apps/landing-page/components/PricingPage/EnterprisePlanCard.tsx similarity index 100% rename from apps/landing-page/components/PricingPage/EnterprisePlanCard.tsx rename to ee/apps/landing-page/components/PricingPage/EnterprisePlanCard.tsx diff --git a/apps/landing-page/components/PricingPage/Faq.tsx b/ee/apps/landing-page/components/PricingPage/Faq.tsx similarity index 100% rename from apps/landing-page/components/PricingPage/Faq.tsx rename to ee/apps/landing-page/components/PricingPage/Faq.tsx diff --git a/apps/landing-page/components/PricingPage/FreePlanCard.tsx b/ee/apps/landing-page/components/PricingPage/FreePlanCard.tsx similarity index 100% rename from apps/landing-page/components/PricingPage/FreePlanCard.tsx rename to ee/apps/landing-page/components/PricingPage/FreePlanCard.tsx diff --git a/apps/landing-page/components/PricingPage/PlanComparisonTables.tsx b/ee/apps/landing-page/components/PricingPage/PlanComparisonTables.tsx similarity index 99% rename from apps/landing-page/components/PricingPage/PlanComparisonTables.tsx rename to ee/apps/landing-page/components/PricingPage/PlanComparisonTables.tsx index 4d6cfe1a44..a5dfbafbcf 100644 --- a/apps/landing-page/components/PricingPage/PlanComparisonTables.tsx +++ b/ee/apps/landing-page/components/PricingPage/PlanComparisonTables.tsx @@ -21,7 +21,7 @@ import Link from 'next/link' import React from 'react' import { parseNumberWithCommas } from '@typebot.io/lib' import { chatsLimits, prices, seatsLimits } from '@typebot.io/billing/constants' -import { formatPrice } from '@typebot.io/billing/formatPrice' +import { formatPrice } from '@typebot.io/billing/helpers/formatPrice' type Props = { onChatsTiersClick: () => void diff --git a/apps/landing-page/components/PricingPage/PricingCard/Card.tsx b/ee/apps/landing-page/components/PricingPage/PricingCard/Card.tsx similarity index 100% rename from apps/landing-page/components/PricingPage/PricingCard/Card.tsx rename to ee/apps/landing-page/components/PricingPage/PricingCard/Card.tsx diff --git a/apps/landing-page/components/PricingPage/PricingCard/CardBadge.tsx b/ee/apps/landing-page/components/PricingPage/PricingCard/CardBadge.tsx similarity index 100% rename from apps/landing-page/components/PricingPage/PricingCard/CardBadge.tsx rename to ee/apps/landing-page/components/PricingPage/PricingCard/CardBadge.tsx diff --git a/apps/landing-page/components/PricingPage/PricingCard/index.tsx b/ee/apps/landing-page/components/PricingPage/PricingCard/index.tsx similarity index 97% rename from apps/landing-page/components/PricingPage/PricingCard/index.tsx rename to ee/apps/landing-page/components/PricingPage/PricingCard/index.tsx index 113441e173..2bb1286250 100644 --- a/apps/landing-page/components/PricingPage/PricingCard/index.tsx +++ b/ee/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/billing/formatPrice' +import { formatPrice } from '@typebot.io/billing/helpers/formatPrice' export interface PricingCardData { features: React.ReactNode[] diff --git a/apps/landing-page/components/PricingPage/ProPlanCard.tsx b/ee/apps/landing-page/components/PricingPage/ProPlanCard.tsx similarity index 100% rename from apps/landing-page/components/PricingPage/ProPlanCard.tsx rename to ee/apps/landing-page/components/PricingPage/ProPlanCard.tsx diff --git a/apps/landing-page/components/PricingPage/StarterPlanCard.tsx b/ee/apps/landing-page/components/PricingPage/StarterPlanCard.tsx similarity index 100% rename from apps/landing-page/components/PricingPage/StarterPlanCard.tsx rename to ee/apps/landing-page/components/PricingPage/StarterPlanCard.tsx diff --git a/apps/landing-page/components/common/ArticleCta.tsx b/ee/apps/landing-page/components/common/ArticleCta.tsx similarity index 100% rename from apps/landing-page/components/common/ArticleCta.tsx rename to ee/apps/landing-page/components/common/ArticleCta.tsx diff --git a/apps/landing-page/components/common/Footer.tsx b/ee/apps/landing-page/components/common/Footer.tsx similarity index 100% rename from apps/landing-page/components/common/Footer.tsx rename to ee/apps/landing-page/components/common/Footer.tsx diff --git a/apps/landing-page/components/common/Header/Header.tsx b/ee/apps/landing-page/components/common/Header/Header.tsx similarity index 100% rename from apps/landing-page/components/common/Header/Header.tsx rename to ee/apps/landing-page/components/common/Header/Header.tsx diff --git a/apps/landing-page/components/common/Header/MobileMenu.tsx b/ee/apps/landing-page/components/common/Header/MobileMenu.tsx similarity index 100% rename from apps/landing-page/components/common/Header/MobileMenu.tsx rename to ee/apps/landing-page/components/common/Header/MobileMenu.tsx diff --git a/apps/landing-page/components/common/Header/ResourcesMenu.tsx b/ee/apps/landing-page/components/common/Header/ResourcesMenu.tsx similarity index 100% rename from apps/landing-page/components/common/Header/ResourcesMenu.tsx rename to ee/apps/landing-page/components/common/Header/ResourcesMenu.tsx diff --git a/apps/landing-page/components/common/Header/_data.tsx b/ee/apps/landing-page/components/common/Header/_data.tsx similarity index 100% rename from apps/landing-page/components/common/Header/_data.tsx rename to ee/apps/landing-page/components/common/Header/_data.tsx diff --git a/apps/landing-page/components/common/SocialMetaTags.tsx b/ee/apps/landing-page/components/common/SocialMetaTags.tsx similarity index 100% rename from apps/landing-page/components/common/SocialMetaTags.tsx rename to ee/apps/landing-page/components/common/SocialMetaTags.tsx diff --git a/apps/landing-page/components/common/TableCells.tsx b/ee/apps/landing-page/components/common/TableCells.tsx similarity index 100% rename from apps/landing-page/components/common/TableCells.tsx rename to ee/apps/landing-page/components/common/TableCells.tsx diff --git a/apps/landing-page/components/common/TextLink.tsx b/ee/apps/landing-page/components/common/TextLink.tsx similarity index 100% rename from apps/landing-page/components/common/TextLink.tsx rename to ee/apps/landing-page/components/common/TextLink.tsx diff --git a/apps/landing-page/content/best-chatbot-for-wordpress.mdx b/ee/apps/landing-page/content/best-chatbot-for-wordpress.mdx similarity index 100% rename from apps/landing-page/content/best-chatbot-for-wordpress.mdx rename to ee/apps/landing-page/content/best-chatbot-for-wordpress.mdx diff --git a/apps/landing-page/content/best-whatsapp-chatbot.mdx b/ee/apps/landing-page/content/best-whatsapp-chatbot.mdx similarity index 100% rename from apps/landing-page/content/best-whatsapp-chatbot.mdx rename to ee/apps/landing-page/content/best-whatsapp-chatbot.mdx diff --git a/apps/landing-page/content/example.mdx b/ee/apps/landing-page/content/example.mdx similarity index 100% rename from apps/landing-page/content/example.mdx rename to ee/apps/landing-page/content/example.mdx diff --git a/apps/landing-page/content/landbot-alternative.mdx b/ee/apps/landing-page/content/landbot-alternative.mdx similarity index 100% rename from apps/landing-page/content/landbot-alternative.mdx rename to ee/apps/landing-page/content/landbot-alternative.mdx diff --git a/apps/landing-page/content/lead-generation-chatbot.mdx b/ee/apps/landing-page/content/lead-generation-chatbot.mdx similarity index 100% rename from apps/landing-page/content/lead-generation-chatbot.mdx rename to ee/apps/landing-page/content/lead-generation-chatbot.mdx diff --git a/apps/landing-page/lib/chakraTheme.ts b/ee/apps/landing-page/lib/chakraTheme.ts similarity index 100% rename from apps/landing-page/lib/chakraTheme.ts rename to ee/apps/landing-page/lib/chakraTheme.ts diff --git a/apps/landing-page/next-env.d.ts b/ee/apps/landing-page/next-env.d.ts similarity index 100% rename from apps/landing-page/next-env.d.ts rename to ee/apps/landing-page/next-env.d.ts diff --git a/apps/landing-page/next.config.mjs b/ee/apps/landing-page/next.config.mjs similarity index 100% rename from apps/landing-page/next.config.mjs rename to ee/apps/landing-page/next.config.mjs diff --git a/apps/landing-page/package.json b/ee/apps/landing-page/package.json similarity index 85% rename from apps/landing-page/package.json rename to ee/apps/landing-page/package.json index 0c299dd522..1706659c03 100644 --- a/apps/landing-page/package.json +++ b/ee/apps/landing-page/package.json @@ -1,10 +1,12 @@ { "name": "landing-page", "version": "1.0.0", + "license": "UNLICENSED", + "private": "true", "scripts": { - "dev": "dotenv -e ./.env -e ../../.env -- next dev -p 3003", - "start": "dotenv -e ./.env -e ../../.env -- next start", - "build": "dotenv -e ./.env -e ../../.env -- next build", + "dev": "dotenv -e ./.env -e ../../../.env -- next dev -p 3003", + "start": "dotenv -e ./.env -e ../../../.env -- next start", + "build": "dotenv -e ./.env -e ../../../.env -- next build", "lint": "next lint", "analyze": "cross-env ANALYZE=true next build" }, diff --git a/apps/landing-page/pages/_app.tsx b/ee/apps/landing-page/pages/_app.tsx similarity index 100% rename from apps/landing-page/pages/_app.tsx rename to ee/apps/landing-page/pages/_app.tsx diff --git a/apps/landing-page/pages/_document.tsx b/ee/apps/landing-page/pages/_document.tsx similarity index 100% rename from apps/landing-page/pages/_document.tsx rename to ee/apps/landing-page/pages/_document.tsx diff --git a/apps/landing-page/pages/about.tsx b/ee/apps/landing-page/pages/about.tsx similarity index 100% rename from apps/landing-page/pages/about.tsx rename to ee/apps/landing-page/pages/about.tsx diff --git a/apps/landing-page/pages/index.tsx b/ee/apps/landing-page/pages/index.tsx similarity index 100% rename from apps/landing-page/pages/index.tsx rename to ee/apps/landing-page/pages/index.tsx diff --git a/apps/landing-page/pages/oss-friends.tsx b/ee/apps/landing-page/pages/oss-friends.tsx similarity index 100% rename from apps/landing-page/pages/oss-friends.tsx rename to ee/apps/landing-page/pages/oss-friends.tsx diff --git a/apps/landing-page/pages/pricing.tsx b/ee/apps/landing-page/pages/pricing.tsx similarity index 100% rename from apps/landing-page/pages/pricing.tsx rename to ee/apps/landing-page/pages/pricing.tsx diff --git a/apps/landing-page/pages/privacy-policies.tsx b/ee/apps/landing-page/pages/privacy-policies.tsx similarity index 100% rename from apps/landing-page/pages/privacy-policies.tsx rename to ee/apps/landing-page/pages/privacy-policies.tsx diff --git a/apps/landing-page/pages/terms-of-service.tsx b/ee/apps/landing-page/pages/terms-of-service.tsx similarity index 100% rename from apps/landing-page/pages/terms-of-service.tsx rename to ee/apps/landing-page/pages/terms-of-service.tsx diff --git a/apps/landing-page/postcss.config.js b/ee/apps/landing-page/postcss.config.js similarity index 100% rename from apps/landing-page/postcss.config.js rename to ee/apps/landing-page/postcss.config.js diff --git a/apps/landing-page/public/favicon.png b/ee/apps/landing-page/public/favicon.png similarity index 100% rename from apps/landing-page/public/favicon.png rename to ee/apps/landing-page/public/favicon.png diff --git a/apps/landing-page/public/images/abhay.jpeg b/ee/apps/landing-page/public/images/abhay.jpeg similarity index 100% rename from apps/landing-page/public/images/abhay.jpeg rename to ee/apps/landing-page/public/images/abhay.jpeg diff --git a/apps/landing-page/public/images/annaFilou.jpeg b/ee/apps/landing-page/public/images/annaFilou.jpeg similarity index 100% rename from apps/landing-page/public/images/annaFilou.jpeg rename to ee/apps/landing-page/public/images/annaFilou.jpeg diff --git a/apps/landing-page/public/images/barretta.jpeg b/ee/apps/landing-page/public/images/barretta.jpeg similarity index 100% rename from apps/landing-page/public/images/barretta.jpeg rename to ee/apps/landing-page/public/images/barretta.jpeg diff --git a/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/acobot-website.png b/ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/acobot-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-chatbot-for-wordpress/acobot-website.png rename to ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/acobot-website.png diff --git a/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/botsify-website.png b/ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/botsify-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-chatbot-for-wordpress/botsify-website.png rename to ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/botsify-website.png diff --git a/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/botstar-website.png b/ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/botstar-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-chatbot-for-wordpress/botstar-website.png rename to ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/botstar-website.png diff --git a/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/chattymongo-website.png b/ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/chattymongo-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-chatbot-for-wordpress/chattymongo-website.png rename to ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/chattymongo-website.png diff --git a/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/drift-website.png b/ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/drift-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-chatbot-for-wordpress/drift-website.png rename to ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/drift-website.png diff --git a/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/intercom-website.png b/ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/intercom-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-chatbot-for-wordpress/intercom-website.png rename to ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/intercom-website.png diff --git a/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/landbot-website.png b/ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/landbot-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-chatbot-for-wordpress/landbot-website.png rename to ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/landbot-website.png diff --git a/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/wpbot-website.png b/ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/wpbot-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-chatbot-for-wordpress/wpbot-website.png rename to ee/apps/landing-page/public/images/blog/best-chatbot-for-wordpress/wpbot-website.png diff --git a/apps/landing-page/public/images/blog/best-whatsapp-chatbot/aivo-website.png b/ee/apps/landing-page/public/images/blog/best-whatsapp-chatbot/aivo-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-whatsapp-chatbot/aivo-website.png rename to ee/apps/landing-page/public/images/blog/best-whatsapp-chatbot/aivo-website.png diff --git a/apps/landing-page/public/images/blog/best-whatsapp-chatbot/botpress-website.png b/ee/apps/landing-page/public/images/blog/best-whatsapp-chatbot/botpress-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-whatsapp-chatbot/botpress-website.png rename to ee/apps/landing-page/public/images/blog/best-whatsapp-chatbot/botpress-website.png diff --git a/apps/landing-page/public/images/blog/best-whatsapp-chatbot/respond-io-website.png b/ee/apps/landing-page/public/images/blog/best-whatsapp-chatbot/respond-io-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-whatsapp-chatbot/respond-io-website.png rename to ee/apps/landing-page/public/images/blog/best-whatsapp-chatbot/respond-io-website.png diff --git a/apps/landing-page/public/images/blog/best-whatsapp-chatbot/tidio-website.png b/ee/apps/landing-page/public/images/blog/best-whatsapp-chatbot/tidio-website.png similarity index 100% rename from apps/landing-page/public/images/blog/best-whatsapp-chatbot/tidio-website.png rename to ee/apps/landing-page/public/images/blog/best-whatsapp-chatbot/tidio-website.png diff --git a/apps/landing-page/public/images/blog/landbot-alternative/chatbot-com-website.png b/ee/apps/landing-page/public/images/blog/landbot-alternative/chatbot-com-website.png similarity index 100% rename from apps/landing-page/public/images/blog/landbot-alternative/chatbot-com-website.png rename to ee/apps/landing-page/public/images/blog/landbot-alternative/chatbot-com-website.png diff --git a/apps/landing-page/public/images/blog/landbot-alternative/collect-chat-website.png b/ee/apps/landing-page/public/images/blog/landbot-alternative/collect-chat-website.png similarity index 100% rename from apps/landing-page/public/images/blog/landbot-alternative/collect-chat-website.png rename to ee/apps/landing-page/public/images/blog/landbot-alternative/collect-chat-website.png diff --git a/apps/landing-page/public/images/blog/landbot-alternative/manychat-website.png b/ee/apps/landing-page/public/images/blog/landbot-alternative/manychat-website.png similarity index 100% rename from apps/landing-page/public/images/blog/landbot-alternative/manychat-website.png rename to ee/apps/landing-page/public/images/blog/landbot-alternative/manychat-website.png diff --git a/apps/landing-page/public/images/blog/landbot-alternative/typeform-website.png b/ee/apps/landing-page/public/images/blog/landbot-alternative/typeform-website.png similarity index 100% rename from apps/landing-page/public/images/blog/landbot-alternative/typeform-website.png rename to ee/apps/landing-page/public/images/blog/landbot-alternative/typeform-website.png diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/ask-for-email.gif b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/ask-for-email.gif similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/ask-for-email.gif rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/ask-for-email.gif diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/create-new-typebot.png b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/create-new-typebot.png similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/create-new-typebot.png rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/create-new-typebot.png diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/create-welcome-message.gif b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/create-welcome-message.gif similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/create-welcome-message.gif rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/create-welcome-message.gif diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/drift-chatbot-example.png b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/drift-chatbot-example.png similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/drift-chatbot-example.png rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/drift-chatbot-example.png diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/example-custom-chatbot.png b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/example-custom-chatbot.png similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/example-custom-chatbot.png rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/example-custom-chatbot.png diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/geico-chatbot-example.png b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/geico-chatbot-example.png similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/geico-chatbot-example.png rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/geico-chatbot-example.png diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/intercom-chatbot-example.png b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/intercom-chatbot-example.png similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/intercom-chatbot-example.png rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/intercom-chatbot-example.png diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/pendo-chatbot-example.png b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/pendo-chatbot-example.png similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/pendo-chatbot-example.png rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/pendo-chatbot-example.png diff --git a/apps/landing-page/public/images/blog/lead-generation-chatbot/send-to-google-sheets.png b/ee/apps/landing-page/public/images/blog/lead-generation-chatbot/send-to-google-sheets.png similarity index 100% rename from apps/landing-page/public/images/blog/lead-generation-chatbot/send-to-google-sheets.png rename to ee/apps/landing-page/public/images/blog/lead-generation-chatbot/send-to-google-sheets.png diff --git a/apps/landing-page/public/images/blog/typebot-website.png b/ee/apps/landing-page/public/images/blog/typebot-website.png similarity index 100% rename from apps/landing-page/public/images/blog/typebot-website.png rename to ee/apps/landing-page/public/images/blog/typebot-website.png diff --git a/apps/landing-page/public/images/builder-dnd.png b/ee/apps/landing-page/public/images/builder-dnd.png similarity index 100% rename from apps/landing-page/public/images/builder-dnd.png rename to ee/apps/landing-page/public/images/builder-dnd.png diff --git a/apps/landing-page/public/images/builder-screenshot.png b/ee/apps/landing-page/public/images/builder-screenshot.png similarity index 100% rename from apps/landing-page/public/images/builder-screenshot.png rename to ee/apps/landing-page/public/images/builder-screenshot.png diff --git a/apps/landing-page/public/images/favicon.png b/ee/apps/landing-page/public/images/favicon.png similarity index 100% rename from apps/landing-page/public/images/favicon.png rename to ee/apps/landing-page/public/images/favicon.png diff --git a/apps/landing-page/public/images/invictuz.png b/ee/apps/landing-page/public/images/invictuz.png similarity index 100% rename from apps/landing-page/public/images/invictuz.png rename to ee/apps/landing-page/public/images/invictuz.png diff --git a/apps/landing-page/public/images/joshua.jpg b/ee/apps/landing-page/public/images/joshua.jpg similarity index 100% rename from apps/landing-page/public/images/joshua.jpg rename to ee/apps/landing-page/public/images/joshua.jpg diff --git a/apps/landing-page/public/images/julien.jpeg b/ee/apps/landing-page/public/images/julien.jpeg similarity index 100% rename from apps/landing-page/public/images/julien.jpeg rename to ee/apps/landing-page/public/images/julien.jpeg diff --git a/apps/landing-page/public/images/kurnia.jpeg b/ee/apps/landing-page/public/images/kurnia.jpeg similarity index 100% rename from apps/landing-page/public/images/kurnia.jpeg rename to ee/apps/landing-page/public/images/kurnia.jpeg diff --git a/apps/landing-page/public/images/laszlo.jpeg b/ee/apps/landing-page/public/images/laszlo.jpeg similarity index 100% rename from apps/landing-page/public/images/laszlo.jpeg rename to ee/apps/landing-page/public/images/laszlo.jpeg diff --git a/apps/landing-page/public/images/lucas.png b/ee/apps/landing-page/public/images/lucas.png similarity index 100% rename from apps/landing-page/public/images/lucas.png rename to ee/apps/landing-page/public/images/lucas.png diff --git a/apps/landing-page/public/images/native-feeling.png b/ee/apps/landing-page/public/images/native-feeling.png similarity index 100% rename from apps/landing-page/public/images/native-feeling.png rename to ee/apps/landing-page/public/images/native-feeling.png diff --git a/apps/landing-page/public/images/nicolai.jpg b/ee/apps/landing-page/public/images/nicolai.jpg similarity index 100% rename from apps/landing-page/public/images/nicolai.jpg rename to ee/apps/landing-page/public/images/nicolai.jpg diff --git a/apps/landing-page/public/images/og-bg.png b/ee/apps/landing-page/public/images/og-bg.png similarity index 100% rename from apps/landing-page/public/images/og-bg.png rename to ee/apps/landing-page/public/images/og-bg.png diff --git a/apps/landing-page/public/images/oscar.jpeg b/ee/apps/landing-page/public/images/oscar.jpeg similarity index 100% rename from apps/landing-page/public/images/oscar.jpeg rename to ee/apps/landing-page/public/images/oscar.jpeg diff --git a/apps/landing-page/public/images/preview.png b/ee/apps/landing-page/public/images/preview.png similarity index 100% rename from apps/landing-page/public/images/preview.png rename to ee/apps/landing-page/public/images/preview.png diff --git a/apps/landing-page/public/images/selfie.png b/ee/apps/landing-page/public/images/selfie.png similarity index 100% rename from apps/landing-page/public/images/selfie.png rename to ee/apps/landing-page/public/images/selfie.png diff --git a/apps/landing-page/public/images/steve.jpg b/ee/apps/landing-page/public/images/steve.jpg similarity index 100% rename from apps/landing-page/public/images/steve.jpg rename to ee/apps/landing-page/public/images/steve.jpg diff --git a/apps/landing-page/public/images/theo.jpeg b/ee/apps/landing-page/public/images/theo.jpeg similarity index 100% rename from apps/landing-page/public/images/theo.jpeg rename to ee/apps/landing-page/public/images/theo.jpeg diff --git a/apps/landing-page/public/styles/aos-noscript.css b/ee/apps/landing-page/public/styles/aos-noscript.css similarity index 100% rename from apps/landing-page/public/styles/aos-noscript.css rename to ee/apps/landing-page/public/styles/aos-noscript.css diff --git a/apps/landing-page/public/typebots/lead-gen-lp.json b/ee/apps/landing-page/public/typebots/lead-gen-lp.json similarity index 100% rename from apps/landing-page/public/typebots/lead-gen-lp.json rename to ee/apps/landing-page/public/typebots/lead-gen-lp.json diff --git a/apps/landing-page/public/typebots/realtime-airtable.json b/ee/apps/landing-page/public/typebots/realtime-airtable.json similarity index 100% rename from apps/landing-page/public/typebots/realtime-airtable.json rename to ee/apps/landing-page/public/typebots/realtime-airtable.json diff --git a/apps/landing-page/tailwind.config.js b/ee/apps/landing-page/tailwind.config.js similarity index 100% rename from apps/landing-page/tailwind.config.js rename to ee/apps/landing-page/tailwind.config.js diff --git a/apps/landing-page/tsconfig.json b/ee/apps/landing-page/tsconfig.json similarity index 100% rename from apps/landing-page/tsconfig.json rename to ee/apps/landing-page/tsconfig.json diff --git a/ee/packages/billing/api/createCheckoutSession.ts b/ee/packages/billing/api/createCheckoutSession.ts new file mode 100644 index 0000000000..8c3f570a86 --- /dev/null +++ b/ee/packages/billing/api/createCheckoutSession.ts @@ -0,0 +1,104 @@ +import { isAdminWriteWorkspaceForbidden } from '@typebot.io/db-rules/isAdminWriteWorkspaceForbidden' +import { env } from '@typebot.io/env' +import prisma from '@typebot.io/lib/prisma' +import { User } from '@typebot.io/prisma' +import Stripe from 'stripe' +import { createCheckoutSessionUrl } from '../helpers/createCheckoutSessionUrl' +import { TRPCError } from '@trpc/server' + +type Props = { + workspaceId: string + user: Pick + returnUrl: string + email: string + company: string + plan: 'STARTER' | 'PRO' + currency: 'usd' | 'eur' + vat?: { + type: string + value: string + } +} + +export const createCheckoutSession = async ({ + workspaceId, + user, + returnUrl, + email, + company, + plan, + currency, + vat, +}: Props) => { + if (!env.STRIPE_SECRET_KEY) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: 'Stripe environment variables are missing', + }) + const workspace = await prisma.workspace.findFirst({ + where: { + id: workspaceId, + }, + select: { + stripeId: true, + members: { + select: { + userId: true, + role: true, + }, + }, + }, + }) + + if (!workspace || isAdminWriteWorkspaceForbidden(workspace, user)) + throw new TRPCError({ + code: 'NOT_FOUND', + message: 'Workspace not found', + }) + if (workspace.stripeId) + throw new TRPCError({ + code: 'BAD_REQUEST', + message: 'Customer already exists, use updateSubscription endpoint.', + }) + + const stripe = new Stripe(env.STRIPE_SECRET_KEY, { + apiVersion: '2022-11-15', + }) + + await prisma.user.updateMany({ + where: { + id: user.id, + }, + data: { + company, + }, + }) + + const customer = await stripe.customers.create({ + email, + name: company, + metadata: { workspaceId }, + tax_id_data: vat + ? [vat as Stripe.CustomerCreateParams.TaxIdDatum] + : undefined, + }) + + const checkoutUrl = await createCheckoutSessionUrl(stripe)({ + customerId: customer.id, + userId: user.id, + workspaceId, + currency, + plan, + returnUrl, + }) + + if (!checkoutUrl) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: 'Stripe checkout session creation failed', + }) + + return { + checkoutUrl, + } +} diff --git a/ee/packages/billing/api/createCustomCheckoutSession.ts b/ee/packages/billing/api/createCustomCheckoutSession.ts new file mode 100644 index 0000000000..76cfd178b1 --- /dev/null +++ b/ee/packages/billing/api/createCustomCheckoutSession.ts @@ -0,0 +1,158 @@ +import { TRPCError } from '@trpc/server' +import { isAdminWriteWorkspaceForbidden } from '@typebot.io/db-rules/isAdminWriteWorkspaceForbidden' +import { env } from '@typebot.io/env' +import prisma from '@typebot.io/lib/prisma' +import { Plan, User } from '@typebot.io/prisma' +import Stripe from 'stripe' + +type Props = { + workspaceId: string + user: Pick + returnUrl: string + email: string +} +export const createCustomCheckoutSession = async ({ + workspaceId, + user, + returnUrl, + email, +}: Props) => { + if (!env.STRIPE_SECRET_KEY) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: 'Stripe environment variables are missing', + }) + const workspace = await prisma.workspace.findFirst({ + where: { + id: workspaceId, + }, + select: { + stripeId: true, + claimableCustomPlan: true, + name: true, + members: { + select: { + userId: true, + role: true, + }, + }, + }, + }) + if ( + !workspace?.claimableCustomPlan || + workspace.claimableCustomPlan.claimedAt || + isAdminWriteWorkspaceForbidden(workspace, user) + ) + throw new TRPCError({ + code: 'NOT_FOUND', + message: 'Custom plan not found', + }) + const stripe = new Stripe(env.STRIPE_SECRET_KEY, { + apiVersion: '2022-11-15', + }) + + const vat = + workspace.claimableCustomPlan.vatValue && + workspace.claimableCustomPlan.vatType + ? ({ + type: workspace.claimableCustomPlan.vatType, + value: workspace.claimableCustomPlan.vatValue, + } as Stripe.CustomerCreateParams.TaxIdDatum) + : undefined + + const customer = workspace.stripeId + ? await stripe.customers.retrieve(workspace.stripeId) + : await stripe.customers.create({ + email, + name: workspace.claimableCustomPlan.companyName ?? workspace.name, + metadata: { workspaceId }, + tax_id_data: vat ? [vat] : undefined, + }) + + const session = await stripe.checkout.sessions.create({ + success_url: `${returnUrl}?stripe=${Plan.CUSTOM}&success=true`, + cancel_url: `${returnUrl}?stripe=cancel`, + allow_promotion_codes: true, + customer: customer.id, + customer_update: { + address: 'auto', + name: 'never', + }, + mode: 'subscription', + metadata: { + claimableCustomPlanId: workspace.claimableCustomPlan.id, + }, + currency: workspace.claimableCustomPlan.currency, + billing_address_collection: 'required', + automatic_tax: { enabled: true }, + line_items: [ + { + price_data: { + currency: workspace.claimableCustomPlan.currency, + tax_behavior: 'exclusive', + recurring: { + interval: workspace.claimableCustomPlan.isYearly ? 'year' : 'month', + }, + product_data: { + name: workspace.claimableCustomPlan.name, + description: workspace.claimableCustomPlan.description ?? undefined, + }, + unit_amount: workspace.claimableCustomPlan.price * 100, + }, + quantity: 1, + }, + { + price_data: { + currency: workspace.claimableCustomPlan.currency, + tax_behavior: 'exclusive', + recurring: { + interval: workspace.claimableCustomPlan.isYearly ? 'year' : 'month', + }, + product_data: { + name: 'Included chats per month', + }, + unit_amount: 0, + }, + quantity: workspace.claimableCustomPlan.chatsLimit, + }, + { + price_data: { + currency: workspace.claimableCustomPlan.currency, + tax_behavior: 'exclusive', + recurring: { + interval: workspace.claimableCustomPlan.isYearly ? 'year' : 'month', + }, + product_data: { + name: 'Included storage per month', + }, + unit_amount: 0, + }, + quantity: workspace.claimableCustomPlan.storageLimit, + }, + { + price_data: { + currency: workspace.claimableCustomPlan.currency, + tax_behavior: 'exclusive', + recurring: { + interval: workspace.claimableCustomPlan.isYearly ? 'year' : 'month', + }, + product_data: { + name: 'Included seats', + }, + unit_amount: 0, + }, + quantity: workspace.claimableCustomPlan.seatsLimit, + }, + ], + }) + + if (!session.url) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: 'Stripe checkout session creation failed', + }) + + return { + checkoutUrl: session.url, + } +} diff --git a/ee/packages/billing/api/getBillingPortalUrl.ts b/ee/packages/billing/api/getBillingPortalUrl.ts new file mode 100644 index 0000000000..842f78f379 --- /dev/null +++ b/ee/packages/billing/api/getBillingPortalUrl.ts @@ -0,0 +1,47 @@ +import { TRPCError } from '@trpc/server' +import { isAdminWriteWorkspaceForbidden } from '@typebot.io/db-rules/isAdminWriteWorkspaceForbidden' +import { env } from '@typebot.io/env' +import prisma from '@typebot.io/lib/prisma' +import { User } from '@typebot.io/prisma' +import Stripe from 'stripe' + +type Props = { + workspaceId: string + user: Pick +} +export const getBillingPortalUrl = async ({ workspaceId, user }: Props) => { + if (!env.STRIPE_SECRET_KEY) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: 'STRIPE_SECRET_KEY var is missing', + }) + const workspace = await prisma.workspace.findFirst({ + where: { + id: workspaceId, + }, + select: { + stripeId: true, + members: { + select: { + userId: true, + role: true, + }, + }, + }, + }) + if (!workspace?.stripeId || isAdminWriteWorkspaceForbidden(workspace, user)) + throw new TRPCError({ + code: 'NOT_FOUND', + message: 'Workspace not found', + }) + const stripe = new Stripe(env.STRIPE_SECRET_KEY, { + apiVersion: '2022-11-15', + }) + const portalSession = await stripe.billingPortal.sessions.create({ + customer: workspace.stripeId, + return_url: `${env.NEXTAUTH_URL}/typebots`, + }) + return { + billingPortalUrl: portalSession.url, + } +} diff --git a/ee/packages/billing/api/getSubscription.ts b/ee/packages/billing/api/getSubscription.ts new file mode 100644 index 0000000000..fd3924488a --- /dev/null +++ b/ee/packages/billing/api/getSubscription.ts @@ -0,0 +1,74 @@ +import { TRPCError } from '@trpc/server' +import { isReadWorkspaceFobidden } from '@typebot.io/db-rules/isReadWorkspaceFobidden' +import { env } from '@typebot.io/env' +import prisma from '@typebot.io/lib/prisma' +import { User } from '@typebot.io/prisma' +import Stripe from 'stripe' +import { subscriptionSchema } from '@typebot.io/schemas/features/billing/subscription' + +type Props = { + workspaceId: string + user: Pick +} + +export const getSubscription = async ({ workspaceId, user }: Props) => { + if (!env.STRIPE_SECRET_KEY) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: 'Stripe environment variables are missing', + }) + const workspace = await prisma.workspace.findFirst({ + where: { + id: workspaceId, + }, + select: { + stripeId: true, + members: { + select: { + userId: true, + }, + }, + }, + }) + if (!workspace || isReadWorkspaceFobidden(workspace, user)) + throw new TRPCError({ + code: 'NOT_FOUND', + message: 'Workspace not found', + }) + if (!workspace?.stripeId) + return { + subscription: null, + } + const stripe = new Stripe(env.STRIPE_SECRET_KEY, { + apiVersion: '2022-11-15', + }) + const subscriptions = await stripe.subscriptions.list({ + customer: workspace.stripeId, + }) + + const currentSubscription = subscriptions.data + .filter((sub) => ['past_due', 'active'].includes(sub.status)) + .sort((a, b) => a.created - b.created) + .shift() + + if (!currentSubscription) + return { + subscription: null, + } + + return { + subscription: { + currentBillingPeriod: subscriptionSchema.shape.currentBillingPeriod.parse( + { + start: new Date(currentSubscription.current_period_start), + end: new Date(currentSubscription.current_period_end), + } + ), + status: subscriptionSchema.shape.status.parse(currentSubscription.status), + currency: currentSubscription.currency as 'usd' | 'eur', + cancelDate: currentSubscription.cancel_at + ? new Date(currentSubscription.cancel_at * 1000) + : undefined, + }, + } +} diff --git a/ee/packages/billing/api/getUsage.ts b/ee/packages/billing/api/getUsage.ts new file mode 100644 index 0000000000..6bbe242b20 --- /dev/null +++ b/ee/packages/billing/api/getUsage.ts @@ -0,0 +1,96 @@ +import { TRPCError } from '@trpc/server' +import { env } from '@typebot.io/env' +import prisma from '@typebot.io/lib/prisma' +import { User } from '@typebot.io/prisma' +import Stripe from 'stripe' +import { isReadWorkspaceFobidden } from '@typebot.io/db-rules/isReadWorkspaceFobidden' + +type Props = { + workspaceId: string + user: Pick +} + +export const getUsage = async ({ workspaceId, user }: Props) => { + const workspace = await prisma.workspace.findFirst({ + where: { + id: workspaceId, + }, + select: { + stripeId: true, + plan: true, + members: { + select: { + userId: true, + }, + }, + typebots: { + select: { id: true }, + }, + }, + }) + if (!workspace || isReadWorkspaceFobidden(workspace, user)) + throw new TRPCError({ + code: 'NOT_FOUND', + message: 'Workspace not found', + }) + + if ( + !env.STRIPE_SECRET_KEY || + !workspace.stripeId || + (workspace.plan !== 'STARTER' && workspace.plan !== 'PRO') + ) { + const now = new Date() + const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1) + + const totalChatsUsed = await prisma.result.count({ + where: { + typebotId: { in: workspace.typebots.map((typebot) => typebot.id) }, + hasStarted: true, + createdAt: { + gte: firstDayOfMonth, + }, + }, + }) + + const firstDayOfNextMonth = new Date( + firstDayOfMonth.getFullYear(), + firstDayOfMonth.getMonth() + 1, + 1 + ) + return { totalChatsUsed, resetsAt: firstDayOfNextMonth } + } + + const stripe = new Stripe(env.STRIPE_SECRET_KEY, { + apiVersion: '2022-11-15', + }) + + const subscriptions = await stripe.subscriptions.list({ + customer: workspace.stripeId, + }) + + const currentSubscription = subscriptions.data + .filter((sub) => ['past_due', 'active'].includes(sub.status)) + .sort((a, b) => a.created - b.created) + .shift() + + if (!currentSubscription) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: `No subscription found on workspace: ${workspaceId}`, + }) + + const totalChatsUsed = await prisma.result.count({ + where: { + typebotId: { in: workspace.typebots.map((typebot) => typebot.id) }, + hasStarted: true, + createdAt: { + gte: new Date(currentSubscription.current_period_start * 1000), + }, + }, + }) + + return { + totalChatsUsed, + resetsAt: new Date(currentSubscription.current_period_end * 1000), + } +} diff --git a/ee/packages/billing/api/listInvoices.ts b/ee/packages/billing/api/listInvoices.ts new file mode 100644 index 0000000000..2fe4e326f7 --- /dev/null +++ b/ee/packages/billing/api/listInvoices.ts @@ -0,0 +1,59 @@ +import { TRPCError } from '@trpc/server' +import { isAdminWriteWorkspaceForbidden } from '@typebot.io/db-rules/isAdminWriteWorkspaceForbidden' +import { env } from '@typebot.io/env' +import { isDefined } from '@typebot.io/lib' +import prisma from '@typebot.io/lib/prisma' +import { User } from '@typebot.io/prisma' +import { Stripe } from 'stripe' + +type Props = { + workspaceId: string + user: Pick +} + +export const listInvoices = async ({ workspaceId, user }: Props) => { + if (!env.STRIPE_SECRET_KEY) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: 'STRIPE_SECRET_KEY var is missing', + }) + const workspace = await prisma.workspace.findFirst({ + where: { + id: workspaceId, + }, + select: { + stripeId: true, + members: { + select: { + userId: true, + role: true, + }, + }, + }, + }) + if (!workspace?.stripeId || isAdminWriteWorkspaceForbidden(workspace, user)) + throw new TRPCError({ + code: 'NOT_FOUND', + message: 'Workspace not found', + }) + const stripe = new Stripe(env.STRIPE_SECRET_KEY, { + apiVersion: '2022-11-15', + }) + const invoices = await stripe.invoices.list({ + customer: workspace.stripeId, + limit: 50, + }) + return { + invoices: invoices.data + .filter( + (invoice) => isDefined(invoice.invoice_pdf) && isDefined(invoice.id) + ) + .map((invoice) => ({ + id: invoice.number as string, + url: invoice.invoice_pdf as string, + amount: invoice.subtotal, + currency: invoice.currency, + date: invoice.status_transitions.paid_at, + })), + } +} diff --git a/ee/packages/billing/api/updateSubscription.ts b/ee/packages/billing/api/updateSubscription.ts new file mode 100644 index 0000000000..b5064eea54 --- /dev/null +++ b/ee/packages/billing/api/updateSubscription.ts @@ -0,0 +1,153 @@ +import { TRPCError } from '@trpc/server' +import { env } from '@typebot.io/env' +import prisma from '@typebot.io/lib/prisma' +import { Plan } from '@typebot.io/prisma' +import Stripe from 'stripe' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' +import { isAdminWriteWorkspaceForbidden } from '@typebot.io/db-rules/isAdminWriteWorkspaceForbidden' +import { User } from '@typebot.io/schemas' +import { createCheckoutSessionUrl } from '../helpers/createCheckoutSessionUrl' + +type Props = { + workspaceId: string + user: Pick + plan: 'STARTER' | 'PRO' + returnUrl: string + currency: 'usd' | 'eur' +} + +export const updateSubscription = async ({ + workspaceId, + user, + plan, + returnUrl, + currency, +}: Props) => { + if (!env.STRIPE_SECRET_KEY) + throw new TRPCError({ + code: 'INTERNAL_SERVER_ERROR', + message: 'Stripe environment variables are missing', + }) + const workspace = await prisma.workspace.findFirst({ + where: { + id: workspaceId, + }, + select: { + isPastDue: true, + stripeId: true, + members: { + select: { + userId: true, + role: true, + }, + }, + }, + }) + if (workspace?.isPastDue) + throw new TRPCError({ + code: 'BAD_REQUEST', + message: + 'You have unpaid invoices. Please head over your billing portal to pay it.', + }) + if (!workspace?.stripeId || isAdminWriteWorkspaceForbidden(workspace, user)) + throw new TRPCError({ + code: 'NOT_FOUND', + message: 'Workspace not found', + }) + + const stripe = new Stripe(env.STRIPE_SECRET_KEY, { + apiVersion: '2022-11-15', + }) + const { data } = await stripe.subscriptions.list({ + customer: workspace.stripeId, + limit: 1, + status: 'active', + }) + const subscription = data[0] as Stripe.Subscription | undefined + const currentPlanItemId = subscription?.items.data.find((item) => + [env.STRIPE_STARTER_PRICE_ID, env.STRIPE_PRO_PRICE_ID].includes( + item.price.id + ) + )?.id + const currentUsageItemId = subscription?.items.data.find( + (item) => + item.price.id === env.STRIPE_STARTER_CHATS_PRICE_ID || + item.price.id === env.STRIPE_PRO_CHATS_PRICE_ID + )?.id + + const items = [ + { + id: currentPlanItemId, + price: + plan === Plan.STARTER + ? env.STRIPE_STARTER_PRICE_ID + : env.STRIPE_PRO_PRICE_ID, + quantity: 1, + }, + { + id: currentUsageItemId, + price: + plan === Plan.STARTER + ? env.STRIPE_STARTER_CHATS_PRICE_ID + : env.STRIPE_PRO_CHATS_PRICE_ID, + }, + ] + + if (subscription) { + if (plan === 'STARTER') { + const totalChatsUsed = await prisma.result.count({ + where: { + typebot: { workspaceId }, + hasStarted: true, + createdAt: { + gte: new Date(subscription.current_period_start * 1000), + }, + }, + }) + if (totalChatsUsed >= 4000) { + throw new TRPCError({ + code: 'BAD_REQUEST', + message: + "You have collected more than 4000 chats during this billing cycle. You can't downgrade to the Starter.", + }) + } + } + + await stripe.subscriptions.update(subscription.id, { + items, + proration_behavior: 'always_invoice', + }) + } else { + const checkoutUrl = await createCheckoutSessionUrl(stripe)({ + customerId: workspace.stripeId, + userId: user.id, + workspaceId, + currency, + plan, + returnUrl, + }) + + return { checkoutUrl } + } + + const updatedWorkspace = await prisma.workspace.update({ + where: { id: workspaceId }, + data: { + plan, + isQuarantined: false, + }, + }) + + await trackEvents([ + { + name: 'Subscription updated', + workspaceId, + userId: user.id, + data: { + plan, + }, + }, + ]) + + return { workspace: updatedWorkspace } +} diff --git a/ee/packages/billing/api/webhookHandler.ts b/ee/packages/billing/api/webhookHandler.ts new file mode 100644 index 0000000000..b13c6801e2 --- /dev/null +++ b/ee/packages/billing/api/webhookHandler.ts @@ -0,0 +1,336 @@ +import { NextApiRequest, NextApiResponse } from 'next' +import { Stripe } from 'stripe' +import { buffer } from 'micro' +import { env } from '@typebot.io/env' +import { Plan, WorkspaceRole } from '@typebot.io/prisma' +import prisma from '@typebot.io/lib/prisma' +import { trackEvents } from '@typebot.io/telemetry/trackEvents' +import { prices } from '../constants' +import { Settings } from '@typebot.io/schemas' +import { methodNotAllowed } from '@typebot.io/lib/api/utils' + +if (!env.STRIPE_SECRET_KEY || !env.STRIPE_WEBHOOK_SECRET) + throw new Error('STRIPE_SECRET_KEY or STRIPE_WEBHOOK_SECRET missing') + +const stripe = new Stripe(env.STRIPE_SECRET_KEY, { + apiVersion: '2022-11-15', +}) + +const webhookSecret = env.STRIPE_WEBHOOK_SECRET as string + +export const webhookHandler = async ( + req: NextApiRequest, + res: NextApiResponse +) => { + if (req.method === 'POST') { + const buf = await buffer(req) + const sig = req.headers['stripe-signature'] + + if (!sig) return res.status(400).send(`stripe-signature is missing`) + try { + const event = stripe.webhooks.constructEvent( + buf.toString(), + sig.toString(), + webhookSecret + ) + switch (event.type) { + case 'checkout.session.completed': { + const session = event.data.object as Stripe.Checkout.Session + const metadata = session.metadata as unknown as + | { + plan: 'STARTER' | 'PRO' + workspaceId: string + userId: string + } + | { claimableCustomPlanId: string; userId: string } + if ('plan' in metadata) { + const { workspaceId, plan } = metadata + if (!workspaceId || !plan) + return res + .status(500) + .send({ message: `Couldn't retrieve valid metadata` }) + + const workspace = await prisma.workspace.update({ + where: { id: workspaceId }, + data: { + plan, + stripeId: session.customer as string, + isQuarantined: false, + }, + include: { + members: { + select: { userId: true }, + where: { + role: WorkspaceRole.ADMIN, + }, + }, + }, + }) + + await trackEvents( + workspace.members.map((m) => ({ + name: 'Subscription updated', + workspaceId, + userId: m.userId, + data: { + plan, + }, + })) + ) + } else { + const { claimableCustomPlanId, userId } = metadata + if (!claimableCustomPlanId) + return res + .status(500) + .send({ message: `Couldn't retrieve valid metadata` }) + const { workspaceId, chatsLimit, seatsLimit, storageLimit } = + await prisma.claimableCustomPlan.update({ + where: { id: claimableCustomPlanId }, + data: { claimedAt: new Date() }, + }) + + await prisma.workspace.updateMany({ + where: { id: workspaceId }, + data: { + plan: Plan.CUSTOM, + stripeId: session.customer as string, + customChatsLimit: chatsLimit, + customStorageLimit: storageLimit, + customSeatsLimit: seatsLimit, + }, + }) + + await trackEvents([ + { + name: 'Subscription updated', + workspaceId, + userId, + data: { + plan: Plan.CUSTOM, + }, + }, + ]) + } + + return res.status(200).send({ message: 'workspace upgraded in DB' }) + } + case 'customer.subscription.updated': { + const subscription = event.data.object as Stripe.Subscription + if (subscription.status !== 'past_due') + return res.send({ message: 'Not past_due, skipping.' }) + const existingWorkspace = await prisma.workspace.findFirst({ + where: { + stripeId: subscription.customer as string, + }, + select: { + isPastDue: true, + id: true, + members: { + select: { userId: true, role: true }, + where: { role: WorkspaceRole.ADMIN }, + }, + }, + }) + if (!existingWorkspace) throw new Error('Workspace not found') + if (existingWorkspace?.isPastDue) + return res.send({ + message: 'Workspace already past due, skipping.', + }) + await prisma.workspace.updateMany({ + where: { + id: existingWorkspace.id, + }, + data: { + isPastDue: true, + }, + }) + await trackEvents( + existingWorkspace.members.map((m) => ({ + name: 'Workspace past due', + workspaceId: existingWorkspace.id, + userId: m.userId, + })) + ) + return res.send({ message: 'Workspace set to past due.' }) + } + case 'invoice.paid': { + const invoice = event.data.object as Stripe.Invoice + const workspace = await prisma.workspace.findFirst({ + where: { + stripeId: invoice.customer as string, + }, + select: { + isPastDue: true, + }, + }) + if (!workspace?.isPastDue) + return res.send({ message: 'Workspace not past_due, skipping.' }) + const outstandingInvoices = await stripe.invoices.list({ + customer: invoice.customer as string, + status: 'open', + }) + const outstandingInvoicesWithAdditionalUsageCosts = + outstandingInvoices.data.filter( + (invoice) => invoice.amount_due > prices['PRO'] * 100 + ) + if (outstandingInvoicesWithAdditionalUsageCosts.length > 0) + return res.send({ + message: 'Workspace has outstanding invoices, skipping.', + }) + const updatedWorkspace = await prisma.workspace.update({ + where: { + stripeId: invoice.customer as string, + }, + data: { + isPastDue: false, + }, + select: { + id: true, + members: { + select: { userId: true }, + where: { + role: WorkspaceRole.ADMIN, + }, + }, + }, + }) + await trackEvents( + updatedWorkspace.members.map((m) => ({ + name: 'Workspace past due status removed', + workspaceId: updatedWorkspace.id, + userId: m.userId, + })) + ) + return res.send({ message: 'Workspace was regulated' }) + } + case 'customer.subscription.deleted': { + const subscription = event.data.object as Stripe.Subscription + const { data } = await stripe.subscriptions.list({ + customer: subscription.customer as string, + limit: 1, + status: 'active', + }) + const existingSubscription = data[0] as + | Stripe.Subscription + | undefined + if (existingSubscription) + return res.send({ + message: + 'An active subscription still exists. Skipping downgrade.', + }) + const outstandingInvoices = await stripe.invoices.list({ + customer: subscription.customer as string, + status: 'open', + }) + const outstandingInvoicesWithAdditionalUsageCosts = + outstandingInvoices.data.filter( + (invoice) => invoice.amount_due > prices['PRO'] * 100 + ) + + const workspaceExist = + (await prisma.workspace.count({ + where: { + stripeId: subscription.customer as string, + }, + })) > 0 + + if (!workspaceExist) + return res.send({ message: 'Workspace not found, skipping...' }) + + const workspace = await prisma.workspace.update({ + where: { + stripeId: subscription.customer as string, + }, + data: { + plan: Plan.FREE, + customChatsLimit: null, + customStorageLimit: null, + customSeatsLimit: null, + isPastDue: outstandingInvoicesWithAdditionalUsageCosts.length > 0, + }, + include: { + members: { + select: { userId: true }, + where: { + role: WorkspaceRole.ADMIN, + }, + }, + }, + }) + + await trackEvents( + workspace.members.map((m) => ({ + name: 'Subscription updated', + workspaceId: workspace.id, + userId: m.userId, + data: { + plan: Plan.FREE, + }, + })) + ) + + const typebots = await prisma.typebot.findMany({ + where: { + workspaceId: workspace.id, + isArchived: { not: true }, + }, + include: { publishedTypebot: true }, + }) + for (const typebot of typebots) { + const settings = typebot.settings as Settings + if (settings.general?.isBrandingEnabled) continue + await prisma.typebot.updateMany({ + where: { id: typebot.id }, + data: { + settings: { + ...settings, + general: { + ...settings.general, + isBrandingEnabled: true, + }, + whatsApp: settings.whatsApp + ? { + ...settings.whatsApp, + isEnabled: false, + } + : undefined, + }, + }, + }) + const publishedTypebotSettings = typebot.publishedTypebot + ?.settings as Settings | null + if ( + !publishedTypebotSettings || + publishedTypebotSettings?.general?.isBrandingEnabled + ) + continue + await prisma.publicTypebot.updateMany({ + where: { id: typebot.id }, + data: { + settings: { + ...publishedTypebotSettings, + general: { + ...publishedTypebotSettings.general, + isBrandingEnabled: true, + }, + }, + }, + }) + } + return res.send({ message: 'workspace downgraded in DB' }) + } + default: { + return res.status(304).send({ message: 'event not handled' }) + } + } + } catch (err) { + console.error(err) + if (err instanceof Error) { + console.error(err) + return res.status(400).send(`Webhook Error: ${err.message}`) + } + return res.status(500).send(`Error occured: ${err}`) + } + } + return methodNotAllowed(res) +} diff --git a/packages/billing/constants.ts b/ee/packages/billing/constants.ts similarity index 100% rename from packages/billing/constants.ts rename to ee/packages/billing/constants.ts diff --git a/ee/packages/billing/helpers/createCheckoutSessionUrl.ts b/ee/packages/billing/helpers/createCheckoutSessionUrl.ts new file mode 100644 index 0000000000..a2a326443c --- /dev/null +++ b/ee/packages/billing/helpers/createCheckoutSessionUrl.ts @@ -0,0 +1,51 @@ +import { env } from '@typebot.io/env' +import Stripe from 'stripe' + +type Props = { + customerId: string + workspaceId: string + currency: 'usd' | 'eur' + plan: 'STARTER' | 'PRO' + returnUrl: string + userId: string +} + +export const createCheckoutSessionUrl = + (stripe: Stripe) => + async ({ customerId, workspaceId, currency, plan, returnUrl }: Props) => { + const session = await stripe.checkout.sessions.create({ + success_url: `${returnUrl}?stripe=${plan}&success=true`, + cancel_url: `${returnUrl}?stripe=cancel`, + allow_promotion_codes: true, + customer: customerId, + customer_update: { + address: 'auto', + name: 'never', + }, + mode: 'subscription', + metadata: { + workspaceId, + plan, + }, + currency, + billing_address_collection: 'required', + automatic_tax: { enabled: true }, + line_items: [ + { + price: + plan === 'STARTER' + ? env.STRIPE_STARTER_PRICE_ID + : env.STRIPE_PRO_PRICE_ID, + quantity: 1, + }, + { + price: + plan === 'STARTER' + ? env.STRIPE_STARTER_CHATS_PRICE_ID + : env.STRIPE_PRO_CHATS_PRICE_ID, + }, + ], + }) + + return session.url + } diff --git a/packages/billing/formatPrice.ts b/ee/packages/billing/helpers/formatPrice.ts similarity index 100% rename from packages/billing/formatPrice.ts rename to ee/packages/billing/helpers/formatPrice.ts diff --git a/packages/billing/getChatsLimit.ts b/ee/packages/billing/helpers/getChatsLimit.ts similarity index 91% rename from packages/billing/getChatsLimit.ts rename to ee/packages/billing/helpers/getChatsLimit.ts index b5227e4238..15fabcd985 100644 --- a/packages/billing/getChatsLimit.ts +++ b/ee/packages/billing/helpers/getChatsLimit.ts @@ -1,5 +1,5 @@ import { Plan } from '@typebot.io/prisma' -import { chatsLimits } from './constants' +import { chatsLimits } from '../constants' import { Workspace } from '@typebot.io/schemas' export const getChatsLimit = ({ diff --git a/packages/billing/getSeatsLimit.ts b/ee/packages/billing/helpers/getSeatsLimit.ts similarity index 89% rename from packages/billing/getSeatsLimit.ts rename to ee/packages/billing/helpers/getSeatsLimit.ts index 0843f05865..ce06ff16fa 100644 --- a/packages/billing/getSeatsLimit.ts +++ b/ee/packages/billing/helpers/getSeatsLimit.ts @@ -1,5 +1,5 @@ import { Workspace } from '@typebot.io/schemas' -import { seatsLimits } from './constants' +import { seatsLimits } from '../constants' import { Plan } from '@typebot.io/prisma' export const getSeatsLimit = ({ diff --git a/packages/billing/guessIfUserIsEuropean.ts b/ee/packages/billing/helpers/guessIfUserIsEuropean.ts similarity index 100% rename from packages/billing/guessIfUserIsEuropean.ts rename to ee/packages/billing/helpers/guessIfUserIsEuropean.ts diff --git a/ee/packages/billing/package.json b/ee/packages/billing/package.json new file mode 100644 index 0000000000..9d6300bb0f --- /dev/null +++ b/ee/packages/billing/package.json @@ -0,0 +1,28 @@ +{ + "name": "@typebot.io/billing", + "version": "1.0.0", + "description": "", + "main": "index.js", + "license": "UNLICENSED", + "private": true, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "Baptiste Arnaud", + "dependencies": { + "@typebot.io/prisma": "workspace:*", + "@typebot.io/schemas": "workspace:*", + "stripe": "12.13.0", + "@typebot.io/lib": "workspace:*", + "@trpc/server": "10.40.0", + "@typebot.io/env": "workspace:*", + "@typebot.io/telemetry": "workspace:*", + "@typebot.io/db-rules": "workspace:*", + "next": "14.1.0", + "micro": "10.0.1" + }, + "devDependencies": { + "@typebot.io/tsconfig": "workspace:*" + } +} diff --git a/apps/builder/src/features/billing/taxIdTypes.ts b/ee/packages/billing/taxIdTypes.ts similarity index 100% rename from apps/builder/src/features/billing/taxIdTypes.ts rename to ee/packages/billing/taxIdTypes.ts diff --git a/packages/billing/tsconfig.json b/ee/packages/billing/tsconfig.json similarity index 100% rename from packages/billing/tsconfig.json rename to ee/packages/billing/tsconfig.json diff --git a/package.json b/package.json index 323997213b..0bdb2c3cff 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,9 @@ "version": "2.25.2", "name": "typebot-os", "private": true, - "license": "AGPL-3.0-or-later", "workspaces": [ + "ee/apps/*", + "ee/packages/*", "packages/*", "packages/deprecated/*", "packages/embeds/*", diff --git a/packages/db-rules/isAdminWriteWorkspaceForbidden.ts b/packages/db-rules/isAdminWriteWorkspaceForbidden.ts new file mode 100644 index 0000000000..2522009d15 --- /dev/null +++ b/packages/db-rules/isAdminWriteWorkspaceForbidden.ts @@ -0,0 +1,13 @@ +import { MemberInWorkspace, User } from '@typebot.io/prisma' + +export const isAdminWriteWorkspaceForbidden = ( + workspace: { + members: Pick[] + }, + user: Pick +) => { + const userRole = workspace.members.find( + (member) => member.userId === user.id + )?.role + return !userRole || userRole !== 'ADMIN' +} diff --git a/packages/db-rules/isReadWorkspaceFobidden.ts b/packages/db-rules/isReadWorkspaceFobidden.ts new file mode 100644 index 0000000000..be24384f9d --- /dev/null +++ b/packages/db-rules/isReadWorkspaceFobidden.ts @@ -0,0 +1,16 @@ +import { env } from '@typebot.io/env' +import { MemberInWorkspace, User } from '@typebot.io/prisma' + +export const isReadWorkspaceFobidden = ( + workspace: { + members: Pick[] + }, + user: Pick +) => { + if ( + env.ADMIN_EMAIL?.some((email) => email === user.email) || + workspace.members.find((member) => member.userId === user.id) + ) + return false + return true +} diff --git a/packages/billing/package.json b/packages/db-rules/package.json similarity index 58% rename from packages/billing/package.json rename to packages/db-rules/package.json index fca687e88f..5bb0c7b3e8 100644 --- a/packages/billing/package.json +++ b/packages/db-rules/package.json @@ -1,5 +1,5 @@ { - "name": "@typebot.io/billing", + "name": "@typebot.io/db-rules", "version": "1.0.0", "description": "", "main": "index.js", @@ -8,13 +8,9 @@ }, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@typebot.io/prisma": "workspace:*", - "@typebot.io/schemas": "workspace:*", - "stripe": "12.13.0" - }, - "devDependencies": { - "@typebot.io/tsconfig": "workspace:*" + "@typebot.io/env": "workspace:*" } } diff --git a/packages/emails/package.json b/packages/emails/package.json index e6bd1d876c..eeabea3e32 100644 --- a/packages/emails/package.json +++ b/packages/emails/package.json @@ -13,7 +13,7 @@ }, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@faire/mjml-react": "3.3.0", "@types/node": "20.4.2", diff --git a/packages/embeds/js/package.json b/packages/embeds/js/package.json index 2ddd5da455..0eeaeb973b 100644 --- a/packages/embeds/js/package.json +++ b/packages/embeds/js/package.json @@ -11,7 +11,7 @@ "lint": "eslint --fix \"src/**/*.ts*\"", "format:check": "prettier --check ./src" }, - "license": "MIT", + "license": "AGPL-3.0-or-later", "dependencies": { "@stripe/stripe-js": "1.54.1", "@udecode/plate-common": "30.4.5", diff --git a/packages/embeds/nextjs/package.json b/packages/embeds/nextjs/package.json index 9cea3f5564..e7dd0368cf 100644 --- a/packages/embeds/nextjs/package.json +++ b/packages/embeds/nextjs/package.json @@ -13,7 +13,7 @@ }, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@babel/preset-react": "7.22.5", "@babel/preset-typescript": "7.22.5", diff --git a/packages/embeds/react/package.json b/packages/embeds/react/package.json index 526d569bd8..10eb90c6d3 100644 --- a/packages/embeds/react/package.json +++ b/packages/embeds/react/package.json @@ -15,7 +15,7 @@ }, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@ladle/react": "2.5.1" }, diff --git a/packages/embeds/wordpress/trunk/LICENSE.txt b/packages/embeds/wordpress/trunk/LICENSE.txt deleted file mode 100644 index ecbc059373..0000000000 --- a/packages/embeds/wordpress/trunk/LICENSE.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. \ No newline at end of file diff --git a/packages/forge/blocks/anthropic/package.json b/packages/forge/blocks/anthropic/package.json index bc55518aa1..91cbc5699e 100644 --- a/packages/forge/blocks/anthropic/package.json +++ b/packages/forge/blocks/anthropic/package.json @@ -5,7 +5,7 @@ "main": "index.ts", "keywords": [], "author": "Enchatted P.C.", - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/forge/blocks/calCom/package.json b/packages/forge/blocks/calCom/package.json index a0a3ab43a0..df70c07b9b 100644 --- a/packages/forge/blocks/calCom/package.json +++ b/packages/forge/blocks/calCom/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/tsconfig": "workspace:*", diff --git a/packages/forge/blocks/chatNode/package.json b/packages/forge/blocks/chatNode/package.json index 69bb7d2865..3afe4669d8 100644 --- a/packages/forge/blocks/chatNode/package.json +++ b/packages/forge/blocks/chatNode/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/forge/blocks/difyAi/package.json b/packages/forge/blocks/difyAi/package.json index 92558715dc..8635e2e48f 100644 --- a/packages/forge/blocks/difyAi/package.json +++ b/packages/forge/blocks/difyAi/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/forge/blocks/elevenlabs/package.json b/packages/forge/blocks/elevenlabs/package.json index e4734d2186..427b9aa687 100644 --- a/packages/forge/blocks/elevenlabs/package.json +++ b/packages/forge/blocks/elevenlabs/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/forge/blocks/mistral/package.json b/packages/forge/blocks/mistral/package.json index d5af453a85..f169904822 100644 --- a/packages/forge/blocks/mistral/package.json +++ b/packages/forge/blocks/mistral/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/forge/blocks/openRouter/package.json b/packages/forge/blocks/openRouter/package.json index 1735c36725..cfac41ad84 100644 --- a/packages/forge/blocks/openRouter/package.json +++ b/packages/forge/blocks/openRouter/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/tsconfig": "workspace:*", diff --git a/packages/forge/blocks/openai/package.json b/packages/forge/blocks/openai/package.json index 352cb3cb12..c8738a923b 100644 --- a/packages/forge/blocks/openai/package.json +++ b/packages/forge/blocks/openai/package.json @@ -5,7 +5,7 @@ "main": "index.ts", "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "ai": "3.1.12", "openai": "4.47.1" diff --git a/packages/forge/blocks/qrcode/package.json b/packages/forge/blocks/qrcode/package.json index 80395a9801..b3fadcf1fa 100644 --- a/packages/forge/blocks/qrcode/package.json +++ b/packages/forge/blocks/qrcode/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/forge/blocks/togetherAi/package.json b/packages/forge/blocks/togetherAi/package.json index b36e0dca35..6478f1d627 100644 --- a/packages/forge/blocks/togetherAi/package.json +++ b/packages/forge/blocks/togetherAi/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/forge/blocks/zemanticAi/package.json b/packages/forge/blocks/zemanticAi/package.json index edb6fbae53..3e6fde996b 100644 --- a/packages/forge/blocks/zemanticAi/package.json +++ b/packages/forge/blocks/zemanticAi/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.ts", "keywords": [], - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/tsconfig": "workspace:*", diff --git a/packages/forge/cli/index.ts b/packages/forge/cli/index.ts index f2466723a8..a30a9e8893 100644 --- a/packages/forge/cli/index.ts +++ b/packages/forge/cli/index.ts @@ -168,7 +168,7 @@ const createPackageJson = async (path: string, { id }: { id: unknown }) => { description: '', main: 'index.ts', keywords: [], - license: 'ISC', + license: 'AGPL-3.0-or-later', devDependencies: { '@typebot.io/forge': 'workspace:*', '@typebot.io/tsconfig': 'workspace:*', diff --git a/packages/forge/cli/package.json b/packages/forge/cli/package.json index b549e3598c..f052fe87ef 100644 --- a/packages/forge/cli/package.json +++ b/packages/forge/cli/package.json @@ -8,7 +8,7 @@ }, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@clack/prompts": "^0.7.0", "@typebot.io/tsconfig": "workspace:*", diff --git a/packages/forge/core/package.json b/packages/forge/core/package.json index 173ff867cf..31231a309f 100644 --- a/packages/forge/core/package.json +++ b/packages/forge/core/package.json @@ -5,7 +5,7 @@ "main": "index.ts", "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "zod": "3.22.4" }, diff --git a/packages/forge/repository/package.json b/packages/forge/repository/package.json index 9e10c1c1f7..779a0845be 100644 --- a/packages/forge/repository/package.json +++ b/packages/forge/repository/package.json @@ -4,7 +4,7 @@ "description": "", "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "devDependencies": { "@typebot.io/forge": "workspace:*", "@typebot.io/openai-block": "workspace:*", diff --git a/packages/logic/package.json b/packages/logic/package.json index 028191af18..72ea8c97a2 100644 --- a/packages/logic/package.json +++ b/packages/logic/package.json @@ -5,7 +5,7 @@ "scripts": {}, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@typebot.io/schemas": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/migrations/package.json b/packages/migrations/package.json index a238e0ec0c..f19cde1ff5 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -5,7 +5,7 @@ "scripts": {}, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@typebot.io/schemas": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/playwright/package.json b/packages/playwright/package.json index d43158c8f4..62012492b3 100644 --- a/packages/playwright/package.json +++ b/packages/playwright/package.json @@ -5,7 +5,7 @@ "scripts": {}, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@playwright/test": "^1.42.1", "@typebot.io/lib": "workspace:*", diff --git a/packages/results/package.json b/packages/results/package.json index 7191007465..86f2ae0e40 100644 --- a/packages/results/package.json +++ b/packages/results/package.json @@ -5,7 +5,7 @@ "scripts": {}, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@typebot.io/schemas": "workspace:*", "@typebot.io/lib": "workspace:*", diff --git a/packages/scripts/checkAndReportChatsUsage.ts b/packages/scripts/checkAndReportChatsUsage.ts index 46a8806014..14cbad1e59 100644 --- a/packages/scripts/checkAndReportChatsUsage.ts +++ b/packages/scripts/checkAndReportChatsUsage.ts @@ -1,6 +1,6 @@ import { Plan, PrismaClient, WorkspaceRole } from '@typebot.io/prisma' import { isDefined, isEmpty } from '@typebot.io/lib' -import { getChatsLimit } from '@typebot.io/billing/getChatsLimit' +import { getChatsLimit } from '@typebot.io/billing/helpers/getChatsLimit' import { promptAndSetEnvironment } from './utils' import { Workspace } from '@typebot.io/schemas' import { sendAlmostReachedChatsLimitEmail } from '@typebot.io/emails/src/emails/AlmostReachedChatsLimitEmail' diff --git a/packages/telemetry/package.json b/packages/telemetry/package.json index b836b27579..41fa6cdcb1 100644 --- a/packages/telemetry/package.json +++ b/packages/telemetry/package.json @@ -5,7 +5,7 @@ "scripts": {}, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@typebot.io/schemas": "workspace:*", "ky": "1.2.3", diff --git a/packages/theme/package.json b/packages/theme/package.json index c9caec17a7..b5ed84a220 100644 --- a/packages/theme/package.json +++ b/packages/theme/package.json @@ -5,7 +5,7 @@ "scripts": {}, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@typebot.io/schemas": "workspace:*", "@typebot.io/lib": "workspace:*" diff --git a/packages/transactional/package.json b/packages/transactional/package.json index 23bd4c198c..dd0ee46a5b 100644 --- a/packages/transactional/package.json +++ b/packages/transactional/package.json @@ -7,7 +7,7 @@ }, "keywords": [], "author": "Baptiste Arnaud", - "license": "ISC", + "license": "AGPL-3.0-or-later", "dependencies": { "@react-email/components": "0.0.14", "react-email": "2.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1a3e32e20e..c04af5da51 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -290,7 +290,7 @@ importers: version: 1.43.1 '@typebot.io/billing': specifier: workspace:* - version: link:../../packages/billing + version: link:../../ee/packages/billing '@typebot.io/forge': specifier: workspace:* version: link:../../packages/forge/core @@ -394,124 +394,6 @@ importers: specifier: ^4.6.2 version: 4.7.1 - apps/landing-page: - dependencies: - '@chakra-ui/icon': - specifier: 3.0.15 - version: 3.0.15(@chakra-ui/system@2.6.2)(react@18.2.0) - '@chakra-ui/next-js': - specifier: 2.2.0 - version: 2.2.0(@chakra-ui/react@2.7.1)(@emotion/react@11.11.1)(next@14.1.0)(react@18.2.0) - '@chakra-ui/react': - specifier: 2.7.1 - version: 2.7.1(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(framer-motion@10.12.20)(react-dom@18.2.0)(react@18.2.0) - '@emotion/react': - specifier: 11.11.1 - version: 11.11.1(@types/react@18.2.15)(react@18.2.0) - '@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 - '@typebot.io/nextjs': - specifier: workspace:* - version: link:../../packages/embeds/nextjs - '@typebot.io/prisma': - specifier: workspace:* - version: link:../../packages/prisma - '@typebot.io/schemas': - specifier: workspace:* - version: link:../../packages/schemas - aos: - specifier: 2.3.4 - version: 2.3.4 - focus-visible: - specifier: 5.2.0 - version: 5.2.0 - framer-motion: - specifier: 10.12.20 - version: 10.12.20(react-dom@18.2.0)(react@18.2.0) - next: - specifier: 14.1.0 - version: 14.1.0(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) - next-mdx-remote: - specifier: 4.4.1 - version: 4.4.1(react-dom@18.2.0)(react@18.2.0) - react: - specifier: 18.2.0 - version: 18.2.0 - react-dom: - specifier: 18.2.0 - version: 18.2.0(react@18.2.0) - react-tweet: - specifier: 3.2.1 - version: 3.2.1(react-dom@18.2.0)(react@18.2.0) - sugar-high: - specifier: 0.6.0 - version: 0.6.0 - devDependencies: - '@babel/core': - specifier: 7.22.9 - version: 7.22.9 - '@chakra-ui/styled-system': - specifier: 2.9.1 - version: 2.9.1 - '@tailwindcss/typography': - specifier: 0.5.12 - version: 0.5.12(tailwindcss@3.3.3) - '@typebot.io/env': - specifier: workspace:* - version: link:../../packages/env - '@typebot.io/tsconfig': - specifier: workspace:* - version: link:../../packages/tsconfig - '@types/aos': - specifier: 3.0.4 - version: 3.0.4 - '@types/node': - specifier: 20.4.2 - version: 20.4.2 - '@types/react': - specifier: 18.2.15 - version: 18.2.15 - autoprefixer: - specifier: 10.4.14 - version: 10.4.14(postcss@8.4.26) - cross-env: - specifier: 7.0.3 - version: 7.0.3 - dotenv-cli: - specifier: 7.4.1 - version: 7.4.1 - eslint: - specifier: 8.44.0 - version: 8.44.0 - eslint-config-custom: - specifier: workspace:* - version: link:../../packages/eslint-config-custom - next-runtime-env: - specifier: 1.6.2 - version: 1.6.2 - next-transpile-modules: - specifier: 10.0.0 - version: 10.0.0 - postcss: - specifier: 8.4.26 - version: 8.4.26 - prettier: - specifier: 3.0.0 - version: 3.0.0 - tailwindcss: - specifier: 3.3.3 - version: 3.3.3 - typescript: - specifier: 5.4.5 - version: 5.4.5 - apps/viewer: dependencies: '@lilyrose2798/trpc-openapi': @@ -672,21 +554,160 @@ importers: specifier: 3.22.4 version: 3.22.4 - packages/billing: + ee/apps/landing-page: dependencies: + '@chakra-ui/icon': + specifier: 3.0.15 + version: 3.0.15(@chakra-ui/system@2.6.2)(react@18.2.0) + '@chakra-ui/next-js': + specifier: 2.2.0 + version: 2.2.0(@chakra-ui/react@2.7.1)(@emotion/react@11.11.1)(next@14.1.0)(react@18.2.0) + '@chakra-ui/react': + specifier: 2.7.1 + version: 2.7.1(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(framer-motion@10.12.20)(react-dom@18.2.0)(react@18.2.0) + '@emotion/react': + specifier: 11.11.1 + version: 11.11.1(@types/react@18.2.15)(react@18.2.0) + '@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 + '@typebot.io/nextjs': + specifier: workspace:* + version: link:../../../packages/embeds/nextjs '@typebot.io/prisma': specifier: workspace:* - version: link:../prisma + version: link:../../../packages/prisma '@typebot.io/schemas': specifier: workspace:* - version: link:../schemas + version: link:../../../packages/schemas + aos: + specifier: 2.3.4 + version: 2.3.4 + focus-visible: + specifier: 5.2.0 + version: 5.2.0 + framer-motion: + specifier: 10.12.20 + version: 10.12.20(react-dom@18.2.0)(react@18.2.0) + next: + specifier: 14.1.0 + version: 14.1.0(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + next-mdx-remote: + specifier: 4.4.1 + version: 4.4.1(react-dom@18.2.0)(react@18.2.0) + react: + specifier: 18.2.0 + version: 18.2.0 + react-dom: + specifier: 18.2.0 + version: 18.2.0(react@18.2.0) + react-tweet: + specifier: 3.2.1 + version: 3.2.1(react-dom@18.2.0)(react@18.2.0) + sugar-high: + specifier: 0.6.0 + version: 0.6.0 + devDependencies: + '@babel/core': + specifier: 7.22.9 + version: 7.22.9 + '@chakra-ui/styled-system': + specifier: 2.9.1 + version: 2.9.1 + '@tailwindcss/typography': + specifier: 0.5.12 + version: 0.5.12(tailwindcss@3.3.3) + '@typebot.io/env': + specifier: workspace:* + version: link:../../../packages/env + '@typebot.io/tsconfig': + specifier: workspace:* + version: link:../../../packages/tsconfig + '@types/aos': + specifier: 3.0.4 + version: 3.0.4 + '@types/node': + specifier: 20.4.2 + version: 20.4.2 + '@types/react': + specifier: 18.2.15 + version: 18.2.15 + autoprefixer: + specifier: 10.4.14 + version: 10.4.14(postcss@8.4.26) + cross-env: + specifier: 7.0.3 + version: 7.0.3 + dotenv-cli: + specifier: 7.4.1 + version: 7.4.1 + eslint: + specifier: 8.44.0 + version: 8.44.0 + eslint-config-custom: + specifier: workspace:* + version: link:../../../packages/eslint-config-custom + next-runtime-env: + specifier: 1.6.2 + version: 1.6.2 + next-transpile-modules: + specifier: 10.0.0 + version: 10.0.0 + postcss: + specifier: 8.4.26 + version: 8.4.26 + prettier: + specifier: 3.0.0 + version: 3.0.0 + tailwindcss: + specifier: 3.3.3 + version: 3.3.3 + typescript: + specifier: 5.4.5 + version: 5.4.5 + + ee/packages/billing: + dependencies: + '@trpc/server': + specifier: 10.40.0 + version: 10.40.0 + '@typebot.io/db-rules': + specifier: workspace:* + version: link:../../../packages/db-rules + '@typebot.io/env': + specifier: workspace:* + version: link:../../../packages/env + '@typebot.io/lib': + specifier: workspace:* + version: link:../../../packages/lib + '@typebot.io/prisma': + specifier: workspace:* + version: link:../../../packages/prisma + '@typebot.io/schemas': + specifier: workspace:* + version: link:../../../packages/schemas + '@typebot.io/telemetry': + specifier: workspace:* + version: link:../../../packages/telemetry + micro: + specifier: 10.0.1 + version: 10.0.1 + next: + specifier: 14.1.0 + version: 14.1.0(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) stripe: specifier: 12.13.0 version: 12.13.0 devDependencies: '@typebot.io/tsconfig': specifier: workspace:* - version: link:../tsconfig + version: link:../../../packages/tsconfig packages/bot-engine: dependencies: @@ -791,6 +812,15 @@ importers: specifier: 6.9.7 version: 6.9.7 + packages/db-rules: + dependencies: + '@typebot.io/env': + specifier: workspace:* + version: link:../env + '@typebot.io/prisma': + specifier: workspace:* + version: link:../prisma + packages/deprecated/bot-engine: dependencies: '@stripe/react-stripe-js': @@ -1843,7 +1873,7 @@ importers: version: 2.2.1 '@typebot.io/billing': specifier: workspace:* - version: link:../billing + version: link:../../ee/packages/billing '@typebot.io/results': specifier: workspace:* version: link:../results @@ -21476,7 +21506,7 @@ packages: resolution: {integrity: sha512-mn7CxL71FCRWkQp33jcJ7+xfRF7HGzPYZlq2c87U+6kxL1qd7f/N3S1g1E5uaSWe83V5v3jN/IiWqg9y8+kWRw==} engines: {node: '>=12.*'} dependencies: - '@types/node': 20.12.4 + '@types/node': 20.4.9 qs: 6.11.2 /strnum@1.0.5: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 1cad8008f0..a57566c76b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -6,3 +6,5 @@ packages: - 'packages/forge/blocks/*' - 'apps/*' - 'packages/transactional/.react-email' + - 'ee/packages/*' + - 'ee/apps/*'