Skip to content

Commit

Permalink
♻️ Re-organize workspace folders
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 15, 2023
1 parent 25c3679 commit cbc8194
Show file tree
Hide file tree
Showing 987 changed files with 2,657 additions and 2,711 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ RUN apt-get -qy update \
&& apt-get autoremove -yq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY ./packages/db ./packages/db
COPY ./packages/prisma ./packages/prisma
COPY ./apps/${SCOPE}/.env.docker ./apps/${SCOPE}/.env.production
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/apps/${SCOPE}/public ./apps/${SCOPE}/public
COPY --from=builder --chown=node:node /app/apps/${SCOPE}/.next/standalone ./
COPY --from=builder --chown=node:node /app/apps/${SCOPE}/.next/static ./apps/${SCOPE}/.next/static

COPY env.sh ${SCOPE}-entrypoint.sh ./
COPY scripts/env.sh scripts/${SCOPE}-entrypoint.sh ./
RUN chmod +x ./${SCOPE}-entrypoint.sh \
&& chmod +x ./env.sh
ENTRYPOINT ./${SCOPE}-entrypoint.sh
Expand Down
10 changes: 7 additions & 3 deletions apps/builder/next.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { withSentryConfig } = require('@sentry/nextjs')
const path = require('path')
const withTM = require('next-transpile-modules')(['utils', 'models', 'emails'])

/** @type {import('next').NextConfig} */
const nextConfig = withTM({
const nextConfig = {
reactStrictMode: true,
output: 'standalone',
transpilePackages: [
'@typebot.io/lib',
'@typebot.io/schemas',
'@typebot.io/emails',
],
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr', 'pr'],
Expand All @@ -27,7 +31,7 @@ const nextConfig = withTM({
},
]
},
})
}

const sentryWebpackPluginOptions = {
silent: true,
Expand Down
17 changes: 8 additions & 9 deletions apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "0.1.0",
"license": "AGPL-3.0-or-later",
"scripts": {
"dev": "cross-env ENVSH_ENV=.env.local bash ../../env.sh next dev -p 3000",
"build": "cross-env ENVSH_ENV=.env.local bash ../../env.sh next build",
"dev": "cross-env ENVSH_ENV=.env.local bash ../../scripts/env.sh next dev -p 3000",
"build": "cross-env ENVSH_ENV=.env.local bash ../../scripts/env.sh next build",
"build:docker": "next build",
"build:env": "cd ../.. && cross-env ENVSH_ENV=./apps/builder/.env.docker ENVSH_OUTPUT=./apps/builder/public/__env.js bash env.sh",
"build:env": "cd ../.. && cross-env ENVSH_ENV=./apps/builder/.env.docker ENVSH_OUTPUT=./apps/builder/public/__env.js bash scripts/env.sh",
"start": "next start",
"lint": "next lint",
"test": "pnpm playwright test",
Expand Down Expand Up @@ -57,7 +57,7 @@
"codemirror": "6.0.1",
"deep-object-diff": "1.1.9",
"dequal": "2.0.3",
"emails": "workspace:*",
"@typebot.io/emails": "workspace:*",
"emojilib": "3.0.8",
"focus-visible": "5.2.0",
"framer-motion": "10.3.0",
Expand Down Expand Up @@ -112,16 +112,15 @@
"@types/qs": "6.9.7",
"@types/react": "18.0.28",
"@types/tinycolor2": "1.4.3",
"db": "workspace:*",
"@typebot.io/prisma": "workspace:*",
"dotenv": "16.0.3",
"eslint": "8.36.0",
"eslint-config-custom": "workspace:*",
"models": "workspace:*",
"next-transpile-modules": "10.0.0",
"@typebot.io/schemas": "workspace:*",
"superjson": "^1.12.2",
"tsconfig": "workspace:*",
"@typebot.io/tsconfig": "workspace:*",
"typescript": "4.9.5",
"utils": "workspace:*",
"@typebot.io/lib": "workspace:*",
"zod": "3.21.4"
}
}
2 changes: 1 addition & 1 deletion apps/builder/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlaywrightTestConfig } from '@playwright/test'
import path from 'path'
import { playwrightBaseConfig } from 'utils/playwright/baseConfig'
import { playwrightBaseConfig } from '@typebot.io/lib/playwright/baseConfig'

const config: PlaywrightTestConfig = {
...playwrightBaseConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GiphyFetch } from '@giphy/js-fetch-api'
import { Grid } from '@giphy/react-components'
import { GiphyLogo } from './GiphyLogo'
import React, { useState } from 'react'
import { env, isEmpty } from 'utils'
import { env, isEmpty } from '@typebot.io/lib'
import { TextInput } from '../inputs'

type GiphySearchFormProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useToast } from '@/hooks/useToast'
import { compressFile } from '@/utils/helpers'
import { Button, ButtonProps, chakra } from '@chakra-ui/react'
import { ChangeEvent, useState } from 'react'
import { uploadFiles } from 'utils'
import { uploadFiles } from '@typebot.io/lib'

type UploadButtonProps = {
fileType: 'image' | 'audio'
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/components/SetVariableLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useColorModeValue, HStack, Tag, Text } from '@chakra-ui/react'
import { Variable } from 'models'
import { Variable } from '@typebot.io/schemas'

export const SetVariableLabel = ({
variableId,
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/inputs/AutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
} from '@chakra-ui/react'
import { useState, useRef, useEffect, ReactNode } from 'react'
import { useDebouncedCallback } from 'use-debounce'
import { env, isDefined } from 'utils'
import { env, isDefined } from '@typebot.io/lib'
import { useOutsideClick } from '@/hooks/useOutsideClick'
import { useParentModal } from '@/features/graph/providers/ParentModalProvider'
import { VariablesButton } from '@/features/variables'
import { Variable } from 'models'
import { Variable } from '@typebot.io/schemas'
import { injectVariableInText } from '@/features/variables/utils/injectVariableInTextInput'
import { focusInput } from '@/utils/focusInput'
import { MoreInfoTooltip } from '../MoreInfoTooltip'
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/inputs/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
import { useEffect, useRef, useState } from 'react'
import { useDebouncedCallback } from 'use-debounce'
import { VariablesButton } from '@/features/variables'
import { Variable } from 'models'
import { env } from 'utils'
import { Variable } from '@typebot.io/schemas'
import { env } from '@typebot.io/lib'
import CodeMirror, { ReactCodeMirrorRef } from '@uiw/react-codemirror'
import { tokyoNight } from '@uiw/codemirror-theme-tokyo-night'
import { githubLight } from '@uiw/codemirror-theme-github'
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/inputs/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
FormControl,
FormLabel,
} from '@chakra-ui/react'
import { Variable, VariableString } from 'models'
import { Variable, VariableString } from '@typebot.io/schemas'
import { useEffect, useState } from 'react'
import { useDebouncedCallback } from 'use-debounce'
import { env } from 'utils'
import { env } from '@typebot.io/lib'
import { MoreInfoTooltip } from '../MoreInfoTooltip'

type Value<HasVariable> = HasVariable extends true | undefined
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/components/inputs/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
HStack,
} from '@chakra-ui/react'
import { useState, useRef, ChangeEvent } from 'react'
import { isDefined } from 'utils'
import { isDefined } from '@typebot.io/lib'
import { useOutsideClick } from '@/hooks/useOutsideClick'
import { useParentModal } from '@/features/graph/providers/ParentModalProvider'
import { ChevronDownIcon, CloseIcon } from '../icons'
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/inputs/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Input as ChakraInput,
InputProps,
} from '@chakra-ui/react'
import { Variable } from 'models'
import { Variable } from '@typebot.io/schemas'
import React, {
forwardRef,
ReactNode,
Expand All @@ -19,7 +19,7 @@ import React, {
useState,
} from 'react'
import { useDebouncedCallback } from 'use-debounce'
import { env } from 'utils'
import { env } from '@typebot.io/lib'
import { MoreInfoTooltip } from '../MoreInfoTooltip'

export type TextInputProps = {
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/inputs/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
Textarea as ChakraTextarea,
TextareaProps,
} from '@chakra-ui/react'
import { Variable } from 'models'
import { Variable } from '@typebot.io/schemas'
import React, { useEffect, useRef, useState } from 'react'
import { useDebouncedCallback } from 'use-debounce'
import { env } from 'utils'
import { env } from '@typebot.io/lib'
import { MoreInfoTooltip } from '../MoreInfoTooltip'

type Props = {
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/inputs/VariableSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
import { EditIcon, PlusIcon, TrashIcon } from '@/components/icons'
import { useTypebot } from '@/features/editor/providers/TypebotProvider/TypebotProvider'
import { createId } from '@paralleldrive/cuid2'
import { Variable } from 'models'
import { Variable } from '@typebot.io/schemas'
import React, { useState, useRef, ChangeEvent, useEffect } from 'react'
import { byId, isDefined, isNotDefined } from 'utils'
import { byId, isDefined, isNotDefined } from '@typebot.io/lib'
import { useOutsideClick } from '@/hooks/useOutsideClick'
import { useParentModal } from '@/features/graph/providers/ParentModalProvider'

Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/account/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
useEffect,
useState,
} from 'react'
import { env, isDefined, isNotDefined } from 'utils'
import { User } from 'db'
import { env, isDefined, isNotDefined } from '@typebot.io/lib'
import { User } from '@typebot.io/prisma'
import { setUser as setSentryUser } from '@sentry/nextjs'
import { useToast } from '@/hooks/useToast'
import { updateUserQuery } from './queries/updateUserQuery'
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/account/account.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getTestAsset } from '@/test/utils/playwright'
import test, { expect } from '@playwright/test'
import { userId } from 'utils/playwright/databaseSetup'
import { userId } from '@typebot.io/lib/playwright/databaseSetup'

test.describe.configure({ mode: 'parallel' })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
} from '@chakra-ui/react'
import { ConfirmModal } from '@/components/ConfirmModal'
import { useToast } from '@/hooks/useToast'
import { User } from 'db'
import { User } from '@typebot.io/prisma'
import React, { useState } from 'react'
import { byId, isDefined } from 'utils'
import { byId, isDefined } from '@typebot.io/lib'
import { CreateTokenModal } from './CreateTokenModal'
import { useApiTokens } from '../../../hooks/useApiTokens'
import { ApiTokenFromServer } from '../../../types'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
VStack,
Text,
} from '@chakra-ui/react'
import { GraphNavigation } from 'db'
import { GraphNavigation } from '@typebot.io/prisma'

const graphNavigationData = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Stack, Heading, useColorMode } from '@chakra-ui/react'
import { useUser } from '@/features/account'
import { GraphNavigation } from 'db'
import { GraphNavigation } from '@typebot.io/prisma'
import React, { useEffect } from 'react'
import { GraphNavigationRadioGroup } from './GraphNavigationRadioGroup'
import { AppearanceRadioGroup } from './AppearanceRadioGroup'
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/account/hooks/useApiTokens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fetcher } from '@/utils/helpers'
import useSWR from 'swr'
import { env } from 'utils'
import { env } from '@typebot.io/lib'
import { ApiTokenFromServer } from '../types'

type ServerResponse = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sendRequest } from 'utils'
import { sendRequest } from '@typebot.io/lib'
import { ApiTokenFromServer } from '../types'

export const createApiTokenQuery = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiToken } from 'db'
import { sendRequest } from 'utils'
import { ApiToken } from '@typebot.io/prisma'
import { sendRequest } from '@typebot.io/lib'

export const deleteApiTokenQuery = ({
userId,
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/account/queries/updateUserQuery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { User } from 'db'
import { sendRequest } from 'utils'
import { User } from '@typebot.io/prisma'
import { sendRequest } from '@typebot.io/lib'

export const updateUserQuery = async (id: string, user: User) =>
sendRequest({
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/analytics/analytics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { createId } from '@paralleldrive/cuid2'
import {
importTypebotInDatabase,
injectFakeResults,
} from 'utils/playwright/databaseActions'
import { starterWorkspaceId } from 'utils/playwright/databaseSetup'
} from '@typebot.io/lib/playwright/databaseActions'
import { starterWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup'

test('analytics are not available for non-pro workspaces', async ({ page }) => {
const typebotId = createId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@chakra-ui/react'
import { useToast } from '@/hooks/useToast'
import { useTypebot } from '@/features/editor'
import { Stats } from 'models'
import { Stats } from '@typebot.io/schemas'
import React from 'react'
import { useAnswersCount } from '../hooks/useAnswersCount'
import {
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/analytics/components/StatsCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
StatNumber,
useColorModeValue,
} from '@chakra-ui/react'
import { Stats } from 'models'
import { Stats } from '@typebot.io/schemas'
import React from 'react'

const computeCompletionRate = (
const computeCompletionRate = (
totalCompleted: number,
totalStarts: number
): string => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Invitation, PrismaClient, WorkspaceRole } from 'db'
import { Invitation, PrismaClient, WorkspaceRole } from '@typebot.io/prisma'

export type InvitationWithWorkspaceId = Invitation & {
typebot: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/auth/api/getAuthenticatedUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import prisma from '@/lib/prisma'
import { setUser } from '@sentry/nextjs'
import { User } from 'db'
import { User } from '@typebot.io/prisma'
import { NextApiRequest } from 'next'
import { getSession } from 'next-auth/react'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaClient, WorkspaceInvitation } from 'db'
import { PrismaClient, WorkspaceInvitation } from '@typebot.io/prisma'
import { InvitationWithWorkspaceId } from './convertInvitationsToCollaborations'

export const getNewUserInvitations = async (
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/auth/api/joinWorkspaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaClient, WorkspaceInvitation } from 'db'
import { PrismaClient, WorkspaceInvitation } from '@typebot.io/prisma'

export const joinWorkspaces = async (
p: PrismaClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { stringify } from 'qs'
import { BuiltInProviderType } from 'next-auth/providers'
import { GoogleLogo } from '@/components/GoogleLogo'
import { AzureAdLogo, FacebookLogo, GitlabLogo } from './logos'
import { omit } from 'utils'
import { omit } from '@typebot.io/lib'

type Props = {
providers:
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/auth/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { User } from 'db'
import { User } from '@typebot.io/prisma'

export const mockedUser: User = {
id: 'userId',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prisma from '@/lib/prisma'
import { authenticatedProcedure } from '@/utils/server/trpc'
import { TRPCError } from '@trpc/server'
import { Plan, WorkspaceRole } from 'db'
import { Plan, WorkspaceRole } from '@typebot.io/prisma'
import Stripe from 'stripe'
import { z } from 'zod'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prisma from '@/lib/prisma'
import { authenticatedProcedure } from '@/utils/server/trpc'
import { TRPCError } from '@trpc/server'
import { Plan, WorkspaceRole } from 'db'
import { Plan, WorkspaceRole } from '@typebot.io/prisma'
import Stripe from 'stripe'
import { z } from 'zod'
import { parseSubscriptionItems } from '../utils/parseSubscriptionItems'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prisma from '@/lib/prisma'
import { authenticatedProcedure } from '@/utils/server/trpc'
import { TRPCError } from '@trpc/server'
import { WorkspaceRole } from 'db'
import { WorkspaceRole } from '@typebot.io/prisma'
import Stripe from 'stripe'
import { z } from 'zod'

Expand Down
Loading

0 comments on commit cbc8194

Please sign in to comment.