2
0

build: add pnpm

This commit is contained in:
Baptiste Arnaud
2022-08-08 08:21:36 +02:00
parent 8c3b5058f1
commit ee338f62dc
183 changed files with 19442 additions and 18364 deletions

View File

@ -6,7 +6,6 @@ import { customTheme } from 'libs/theme'
import { useRouterProgressBar } from 'libs/routerProgressBar'
import 'assets/styles/routerProgressBar.css'
import 'assets/styles/plate.css'
import 'focus-visible/dist/focus-visible'
import 'assets/styles/submissionsTable.css'
import 'assets/styles/codeMirror.css'
import 'assets/styles/custom.css'
@ -15,15 +14,12 @@ import { TypebotContext } from 'contexts/TypebotContext'
import { useRouter } from 'next/router'
import { KBarProvider } from 'kbar'
import { actions } from 'libs/kbar'
import { enableMocks } from 'mocks'
import { SupportBubble } from 'components/shared/SupportBubble'
import { WorkspaceContext } from 'contexts/WorkspaceContext'
import { toTitleCase } from 'utils'
const { ToastContainer, toast } = createStandaloneToast(customTheme)
if (process.env.NEXT_PUBLIC_E2E_TEST === 'enabled') enableMocks()
const App = ({ Component, pageProps: { session, ...pageProps } }: AppProps) => {
useRouterProgressBar()
const { query, pathname, isReady } = useRouter()
@ -70,6 +66,7 @@ const App = ({ Component, pageProps: { session, ...pageProps } }: AppProps) => {
const displayStripeCallbackMessage = (
status: string | undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toast: any
) => {
if (status && ['pro', 'team'].includes(status)) {

View File

@ -15,7 +15,10 @@ import { env, isNotEmpty } from 'utils'
const providers: Provider[] = []
if (isNotEmpty(process.env.GITHUB_CLIENT_ID))
if (
isNotEmpty(process.env.GITHUB_CLIENT_ID) &&
isNotEmpty(process.env.GITHUB_CLIENT_SECRET)
)
providers.push(
GitHubProvider({
clientId: process.env.GITHUB_CLIENT_ID,

View File

@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const workspaceId = req.query.workspaceId as string | undefined
if (!workspaceId) return badRequest(res)
if (req.method === 'DELETE') {
const credentialsId = req.query.credentialsId.toString()
const credentialsId = req.query.credentialsId as string | undefined
const credentials = await prisma.credentials.deleteMany({
where: {
id: credentialsId,

View File

@ -12,8 +12,10 @@ import { getAuthenticatedUser } from 'services/api/utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
const state = req.query.state as string | undefined
if (!state) return badRequest(res)
const { redirectUrl, blockId, workspaceId } = JSON.parse(
Buffer.from(req.query.state.toString(), 'base64').toString()
Buffer.from(state, 'base64').toString()
)
if (req.method === 'GET') {
const code = req.query.code as string | undefined

View File

@ -11,7 +11,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const workspaceId = req.query.workspaceId as string | undefined
if (!workspaceId) return badRequest(res)
if (req.method === 'DELETE') {
const domain = req.query.domain.toString()
const domain = req.query.domain as string
try {
await deleteDomainOnVercel(domain)
} catch {}

View File

@ -9,7 +9,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
const id = req.query.id.toString()
const id = req.query.id as string
if (req.method === 'GET') {
const folder = await prisma.dashboardFolder.findFirst({
where: {

View File

@ -1,6 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { drive } from '@googleapis/drive'
import { OAuth2Client } from 'googleapis-common'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { badRequest, methodNotAllowed, notAuthenticated } from 'utils'
import { setUser, withSentry } from '@sentry/nextjs'
@ -19,7 +18,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
return res.status(404).send("Couldn't find credentials in database")
const response = await drive({
version: 'v3',
auth: auth.client as unknown as OAuth2Client,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
auth: auth.client,
}).files.list({
q: "mimeType='application/vnd.google-apps.spreadsheet'",
fields: 'nextPageToken, files(id, name)',

View File

@ -4,8 +4,8 @@ import { methodNotAllowed } from 'utils'
const handler = (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'POST') {
const firstParam = req.query.firstParam.toString()
const secondParam = req.query.secondParam.toString()
const firstParam = req.query.firstParam?.toString()
const secondParam = req.query.secondParam?.toString()
const customHeader = req.headers['custom-typebot']
const { body } = req
if (

View File

@ -1,7 +1,12 @@
import { withSentry } from '@sentry/nextjs'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { badRequest, generatePresignedUrl, methodNotAllowed } from 'utils'
import { getAuthenticatedUser } from 'services/api/utils'
import {
badRequest,
generatePresignedUrl,
methodNotAllowed,
notAuthenticated,
} from 'utils'
const handler = async (
req: NextApiRequest,
@ -9,11 +14,8 @@ const handler = async (
): Promise<void> => {
res.setHeader('Access-Control-Allow-Origin', '*')
if (req.method === 'GET') {
const session = await getSession({ req })
if (!session) {
res.status(401)
return
}
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
if (
!process.env.S3_ENDPOINT ||

View File

@ -8,7 +8,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (!process.env.STRIPE_SECRET_KEY)
throw Error('STRIPE_SECRET_KEY var is missing')
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
apiVersion: '2022-08-01',
})
const { email, currency, plan, workspaceId, href } =
typeof req.body === 'string' ? JSON.parse(req.body) : req.body

View File

@ -27,7 +27,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
})
if (!workspace?.stripeId) return forbidden(res)
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
apiVersion: '2022-08-01',
})
const session = await stripe.billingPortal.sessions.create({
customer: workspace.stripeId,

View File

@ -13,7 +13,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (!process.env.STRIPE_SECRET_KEY)
throw Error('STRIPE_SECRET_KEY var is missing')
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
apiVersion: '2022-08-01',
})
const subscriptions = await stripe.subscriptions.list({
customer: customerId,

View File

@ -10,7 +10,7 @@ import { withSentry } from '@sentry/nextjs'
if (!process.env.STRIPE_SECRET_KEY || !process.env.STRIPE_WEBHOOK_SECRET)
throw new Error('STRIPE_SECRET_KEY or STRIPE_WEBHOOK_SECRET missing')
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
apiVersion: '2022-08-01',
})
const cors = Cors({

View File

@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
const typebotId = req.query.typebotId.toString()
const typebotId = req.query.typebotId as string
if (req.method === 'GET') {
const typebot = await prisma.typebot.findFirst({
where: canReadTypebot(typebotId, user),

View File

@ -66,7 +66,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
await prisma.invitation.create({
data: { email: email.toLowerCase().trim(), type, typebotId },
})
if (env('E2E_TEST') !== 'enabled')
if (env('E2E_TEST') !== 'true')
await sendEmailNotification({
to: email,
subject: "You've been invited to collaborate 🤝",

View File

@ -23,9 +23,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
})
if (!workspace) return forbidden(res)
if (req.method === 'GET') {
const typebotId = req.query.typebotId.toString()
const typebotId = req.query.typebotId as string
const lastResultId = req.query.lastResultId?.toString()
const take = parseInt(req.query.limit?.toString())
const take = Number(req.query.limit?.toString())
const results = await prisma.result.findMany({
take: isNaN(take) ? undefined : take,
skip: lastResultId ? 1 : 0,

View File

@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
if (req.method === 'GET') {
const typebotId = req.query.typebotId.toString()
const typebotId = req.query.typebotId as string
const typebot = await prisma.typebot.findFirst({
where: canReadTypebot(typebotId, user),
include: { publishedTypebot: true },

View File

@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
if (req.method === 'GET') {
const typebotId = req.query.typebotId.toString()
const typebotId = req.query.typebotId as string
const totalViews = await prisma.result.count({
where: {

View File

@ -8,7 +8,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
const id = req.query.userId.toString()
const id = req.query.userId as string
if (req.method === 'PUT') {
const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body
const typebots = await prisma.user.update({

View File

@ -9,7 +9,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (!user) return notAuthenticated(res)
if (req.method === 'DELETE') {
const id = req.query.tokenId.toString()
const id = req.query.tokenId as string
const apiToken = await prisma.apiToken.delete({
where: { id },
})

View File

@ -1,11 +1,10 @@
import React, { useEffect, useState } from 'react'
import { Stack, Text, VStack } from '@chakra-ui/layout'
import { DashboardHeader } from 'components/dashboard/DashboardHeader'
import { Seo } from 'components/Seo'
import { FolderContent } from 'components/dashboard/FolderContent'
import { TypebotDndContext } from 'contexts/TypebotDndContext'
import { useRouter } from 'next/router'
import { Spinner } from '@chakra-ui/react'
import { Spinner, Stack, Text, VStack } from '@chakra-ui/react'
import { pay } from 'services/stripe'
import { useUser } from 'contexts/UserContext'
import { NextPageContext } from 'next/types'

View File

@ -1,4 +1,3 @@
import { Flex } from '@chakra-ui/layout'
import { Seo } from 'components/Seo'
import { TypebotHeader } from 'components/shared/TypebotHeader'
import {
@ -16,7 +15,7 @@ import { GraphProvider, GroupsCoordinatesProvider } from 'contexts/GraphContext'
import { GraphDndContext } from 'contexts/GraphDndContext'
import { useTypebot } from 'contexts/TypebotContext'
import { GettingStartedModal } from 'components/editor/GettingStartedModal'
import { Spinner } from '@chakra-ui/react'
import { Spinner, Flex } from '@chakra-ui/react'
const TypebotEditPage = () => {
const { typebot, isReadOnly } = useTypebot()

View File

@ -1,8 +1,7 @@
import { Flex, Text } from '@chakra-ui/layout'
import { Seo } from 'components/Seo'
import { TypebotHeader } from 'components/shared/TypebotHeader'
import React, { useMemo } from 'react'
import { HStack, Button, Tag } from '@chakra-ui/react'
import { HStack, Button, Tag, Flex, Text } from '@chakra-ui/react'
import { NextChakraLink } from 'components/nextChakra/NextChakraLink'
import { ResultsContent } from 'components/results/ResultsContent'
import { useTypebot } from 'contexts/TypebotContext'
@ -34,7 +33,7 @@ const ResultsPage = () => {
stats: { ...stats, totalStarts: stats.totalStarts - total },
})
}
return (
<Flex overflow="hidden" h="100vh" flexDir="column">
<Seo

View File

@ -1,4 +1,4 @@
import { Flex } from '@chakra-ui/layout'
import { Flex } from '@chakra-ui/react'
import { Seo } from 'components/Seo'
import { SettingsContent } from 'layouts/settings/SettingsContent'
import { TypebotHeader } from 'components/shared/TypebotHeader'

View File

@ -1,4 +1,4 @@
import { Flex } from '@chakra-ui/layout'
import { Flex } from '@chakra-ui/react'
import { Seo } from 'components/Seo'
import { ShareContent } from 'components/share/ShareContent'
import { TypebotHeader } from 'components/shared/TypebotHeader'

View File

@ -1,4 +1,4 @@
import { Flex } from '@chakra-ui/layout'
import { Flex } from '@chakra-ui/react'
import { Seo } from 'components/Seo'
import { TypebotHeader } from 'components/shared/TypebotHeader'
import { ThemeContent } from 'layouts/theme/ThemeContent'

View File

@ -1,5 +1,5 @@
import React from 'react'
import { Flex, Stack } from '@chakra-ui/layout'
import { Flex, Stack } from '@chakra-ui/react'
import { DashboardHeader } from 'components/dashboard/DashboardHeader'
import { Seo } from 'components/Seo'
import { FolderContent } from 'components/dashboard/FolderContent'