2
0

♻️ Re-organize workspace folders

This commit is contained in:
Baptiste Arnaud
2023-03-15 08:35:16 +01:00
parent 25c367901f
commit cbc8194f19
987 changed files with 2716 additions and 2770 deletions

View File

@@ -1 +0,0 @@
export { PaymentForm } from './components/PaymentForm/'

View File

@@ -1,5 +1,6 @@
{
"name": "bot-engine",
"private": true,
"license": "AGPL-3.0-or-later",
"version": "0.1.0",
"main": "dist/index.js",
@@ -15,7 +16,6 @@
"@stripe/stripe-js": "1.46.0",
"prop-types": "15.8.1",
"qs": "6.11.0",
"react-frame-component": "5.2.6",
"react-phone-number-input": "3.2.16",
"react-scroll": "1.8.9",
"react-transition-group": "4.4.5",
@@ -29,24 +29,24 @@
"@types/react-scroll": "1.8.6",
"@types/react-transition-group": "4.4.5",
"autoprefixer": "10.4.13",
"db": "workspace:*",
"@typebot.io/prisma": "workspace:*",
"esbuild": "^0.17.5",
"eslint": "8.32.0",
"eslint-config-custom": "workspace:*",
"models": "workspace:*",
"@typebot.io/schemas": "workspace:*",
"postcss": "8.4.21",
"prettier": "2.8.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.2.4",
"tsconfig": "workspace:*",
"@typebot.io/tsconfig": "workspace:*",
"tsup": "6.5.0",
"typebot-js": "workspace:*",
"typescript": "4.9.4",
"utils": "workspace:*"
"@typebot.io/lib": "workspace:*"
},
"peerDependencies": {
"db": "workspace:*",
"@typebot.io/prisma": "workspace:*",
"react": "18.0.0",
"react-dom": "18.0.0"
}

View File

@@ -7,7 +7,6 @@ import React, {
useState,
} from 'react'
import { Avatar } from '../avatars/Avatar'
import { useFrame } from 'react-frame-component'
import { CSSTransition } from 'react-transition-group'
import { ResizeObserver } from 'resize-observer'
@@ -17,7 +16,6 @@ export const AvatarSideContainer = forwardRef(function AvatarSideContainer(
{ hostAvatarSrc, keepShowing }: Props,
ref: ForwardedRef<unknown>
) {
const { document } = useFrame()
const [show, setShow] = useState(false)
const [avatarTopOffset, setAvatarTopOffset] = useState(0)

View File

@@ -1,8 +1,8 @@
import React, { useState } from 'react'
import { useAnswers } from '../../../providers/AnswersProvider'
import { InputBlock, InputBlockType } from 'models'
import { InputBlock, InputBlockType } from '@typebot.io/schemas'
import { GuestBubble } from './bubbles/GuestBubble'
import { byId } from 'utils'
import { byId } from '@typebot.io/lib'
import { InputSubmitContent } from '@/types'
import { useTypebot } from '@/providers/TypebotProvider'
import { isInputValid } from '@/utils/inputs'

View File

@@ -3,7 +3,7 @@ import { EmbedBubble } from '@/features/blocks/bubbles/embed'
import { ImageBubble } from '@/features/blocks/bubbles/image'
import { TextBubble } from '@/features/blocks/bubbles/textBubble'
import { VideoBubble } from '@/features/blocks/bubbles/video'
import { BubbleBlock, BubbleBlockType } from 'models'
import { BubbleBlock, BubbleBlockType } from '@typebot.io/schemas'
type Props = {
block: BubbleBlock

View File

@@ -11,14 +11,14 @@ import {
isIntegrationBlock,
isLogicBlock,
byId,
} from 'utils'
} from '@typebot.io/lib'
import {
BubbleBlock,
InputBlock,
LogicBlockType,
PublicTypebot,
Block,
} from 'models'
} from '@typebot.io/schemas'
import { HostBubble } from './ChatBlock/bubbles/HostBubble'
import { InputChatBlock } from './ChatBlock/InputChatBlock'
import { parseVariables } from '@/features/variables'

View File

@@ -1,9 +1,14 @@
import React, { useEffect, useRef, useState } from 'react'
import { ChatGroup } from './ChatGroup'
import { useFrame } from 'react-frame-component'
import { useAnswers } from '../providers/AnswersProvider'
import { Group, Edge, PublicTypebot, Theme, VariableWithValue } from 'models'
import { byId, isDefined, isInputBlock, isNotDefined } from 'utils'
import {
Group,
Edge,
PublicTypebot,
Theme,
VariableWithValue,
} from '@typebot.io/schemas'
import { byId, isDefined, isInputBlock, isNotDefined } from '@typebot.io/lib'
import { animateScroll as scroll } from 'react-scroll'
import { LinkedTypebot, useTypebot } from '@/providers/TypebotProvider'
import { setCssVariablesValue } from '@/features/theme'
@@ -29,7 +34,6 @@ export const ConversationContainer = ({
linkedBotQueue,
popEdgeIdFromLinkedTypebotQueue,
} = useTypebot()
const { document: frameDocument } = useFrame()
const [displayedGroups, setDisplayedGroups] = useState<
{ group: Group; startBlockIndex: number }[]
>([])
@@ -122,9 +126,9 @@ export const ConversationContainer = ({
}
useEffect(() => {
if (!frameDocument) return
setCssVariablesValue(theme, frameDocument.body.style)
}, [theme, frameDocument])
if (!document) return
setCssVariablesValue(theme, document.body.style)
}, [theme])
const autoScrollToBottom = () => {
if (!scrollableContainer.current) return

View File

@@ -1,8 +1,6 @@
import React, { useEffect, useRef } from 'react'
import { useFrame } from 'react-frame-component'
export const LiteBadge = () => {
const { document } = useFrame()
const liteBadge = useRef<HTMLAnchorElement | null>(null)
useEffect(() => {

View File

@@ -1,6 +1,5 @@
import { CSSProperties, useMemo } from 'react'
import { TypebotProvider } from '../providers/TypebotProvider'
import Frame from 'react-frame-component'
import styles from '../assets/style.css'
import importantStyles from '../assets/importantStyles.css'
import phoneSyle from '../assets/phone.css'
@@ -12,10 +11,10 @@ import {
Edge,
PublicTypebot,
VariableWithValue,
} from 'models'
import { Log } from 'db'
} from '@typebot.io/schemas'
import { Log } from '@typebot.io/prisma'
import { LiteBadge } from './LiteBadge'
import { getViewerUrl, isEmpty, isNotEmpty } from 'utils'
import { getViewerUrl, isEmpty, isNotEmpty } from '@typebot.io/lib'
export type TypebotViewerProps = {
typebot: Omit<PublicTypebot, 'updatedAt' | 'createdAt'>
@@ -71,21 +70,13 @@ export const TypebotViewer = ({
if (isEmpty(apiHost))
return <p>process.env.NEXT_PUBLIC_VIEWER_URL is missing in env</p>
return (
<Frame
id="typebot-iframe"
head={
<>
<style>
{phoneSyle}
{styles}
</style>
<style>{typebot.theme?.customCss}</style>
<style>{importantStyles}</style>
</>
}
name="Typebot viewer"
style={{ width: '100%', height: '100%', border: 'none', ...style }}
>
<>
<style>
{phoneSyle}
{styles}
</style>
<style>{typebot.theme?.customCss}</style>
<style>{importantStyles}</style>
{isNotEmpty(typebot?.theme?.general?.font) && (
<style
dangerouslySetInnerHTML={{
@@ -128,6 +119,6 @@ export const TypebotViewer = ({
</div>
</AnswersProvider>
</TypebotProvider>
</Frame>
</>
)
}

View File

@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { isDefined } from 'utils'
import { isDefined } from '@typebot.io/lib'
import { DefaultAvatar } from './DefaultAvatar'
export const Avatar = ({ avatarSrc }: { avatarSrc?: string }): JSX.Element => {

View File

@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react'
import { useTypebot } from '@/providers/TypebotProvider'
import { AudioBubbleContent } from 'models'
import { AudioBubbleContent } from '@typebot.io/schemas'
import { TypingBubble } from '@/components/TypingBubble'
import { parseVariables } from '@/features/variables'

View File

@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { EmbedBubbleBlock } from 'models'
import { EmbedBubbleBlock } from '@typebot.io/schemas'
import { TypingBubble } from '../../../../../components/TypingBubble'
import { parseVariables } from '@/features/variables'
import { useTypebot } from '@/providers/TypebotProvider'

View File

@@ -1,6 +1,6 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { useTypebot } from '@/providers/TypebotProvider'
import { ImageBubbleBlock } from 'models'
import { ImageBubbleBlock } from '@typebot.io/schemas'
import { TypingBubble } from '@/components/TypingBubble'
import { parseVariables } from '@/features/variables'

View File

@@ -1,6 +1,6 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { useTypebot } from '@/providers/TypebotProvider'
import { BubbleBlockType, TextBubbleBlock } from 'models'
import { BubbleBlockType, TextBubbleBlock } from '@typebot.io/schemas'
import { computeTypingDuration } from '../utils/computeTypingDuration'
import { parseVariables } from '@/features/variables'
import { TypingBubble } from '@/components/TypingBubble'

View File

@@ -1,4 +1,4 @@
import type { TypingEmulation } from 'models'
import { TypingEmulation } from '@typebot.io/schemas'
export const computeTypingDuration = (
bubbleContent: string,

View File

@@ -5,7 +5,7 @@ import {
VideoBubbleContent,
VideoBubbleContentType,
VideoBubbleBlock,
} from 'models'
} from '@typebot.io/schemas'
import { TypingBubble } from '@/components/TypingBubble'
import { parseVariables } from '@/features/variables'

View File

@@ -2,7 +2,7 @@ import { parseVariables } from '@/features/variables'
import { useAnswers } from '@/providers/AnswersProvider'
import { useTypebot } from '@/providers/TypebotProvider'
import { InputSubmitContent } from '@/types'
import { ChoiceInputBlock } from 'models'
import { ChoiceInputBlock } from '@typebot.io/schemas'
import React, { useState } from 'react'
import { SendButton } from '../../../../../components/SendButton'

View File

@@ -1,6 +1,6 @@
import { SendButton } from '@/components/SendButton'
import { InputSubmitContent } from '@/types'
import { DateInputOptions } from 'models'
import { DateInputOptions } from '@typebot.io/schemas'
import { useState } from 'react'
import { parseReadableDate } from '../utils/parseReadableDate'

View File

@@ -1,7 +1,7 @@
import { ShortTextInput } from '@/components/inputs/ShortTextInput'
import { SendButton } from '@/components/SendButton'
import { InputSubmitContent } from '@/types'
import { EmailInputBlock } from 'models'
import { EmailInputBlock } from '@typebot.io/schemas'
import React, { MutableRefObject, useRef, useState } from 'react'
type EmailInputProps = {

View File

@@ -2,9 +2,9 @@ import { Spinner, SendButton } from '@/components/SendButton'
import { useAnswers } from '@/providers/AnswersProvider'
import { useTypebot } from '@/providers/TypebotProvider'
import { InputSubmitContent } from '@/types'
import { defaultFileInputOptions, FileInputBlock } from 'models'
import { defaultFileInputOptions, FileInputBlock } from '@typebot.io/schemas'
import React, { ChangeEvent, FormEvent, useState, DragEvent } from 'react'
import { uploadFiles } from 'utils'
import { uploadFiles } from '@typebot.io/lib'
type Props = {
block: FileInputBlock

View File

@@ -1,7 +1,7 @@
import { ShortTextInput } from '@/components/inputs/ShortTextInput'
import { SendButton } from '@/components/SendButton'
import { InputSubmitContent } from '@/types'
import { NumberInputBlock } from 'models'
import { NumberInputBlock } from '@typebot.io/schemas'
import React, { MutableRefObject, useRef, useState } from 'react'
type NumberInputProps = {

View File

@@ -1,4 +1,4 @@
import { PaymentInputOptions, PaymentProvider } from 'models'
import { PaymentInputOptions, PaymentProvider } from '@typebot.io/schemas'
import React from 'react'
import { StripePaymentForm } from './StripePaymentForm'

View File

@@ -1,9 +1,8 @@
import React, { FormEvent, useEffect, useState } from 'react'
import { useStripe, useElements, PaymentElement } from '@stripe/react-stripe-js'
import { Elements } from '@stripe/react-stripe-js'
import { PaymentInputOptions, Variable } from 'models'
import { PaymentInputOptions, Variable } from '@typebot.io/schemas'
import { SendButton, Spinner } from '@/components/SendButton'
import { useFrame } from 'react-frame-component'
import { initStripe } from '@/lib/stripe'
import { parseVariables } from '@/features/variables'
import { useChat } from '@/providers/ChatProvider'
@@ -23,7 +22,6 @@ export const StripePaymentForm = ({ options, onSuccess }: Props) => {
typebot: { variables },
onNewLog,
} = useTypebot()
const { window: frameWindow, document: frameDocument } = useFrame()
const [stripe, setStripe] = useState<Stripe | null>(null)
const [clientSecret, setClientSecret] = useState('')
const [amountLabel, setAmountLabel] = useState('')
@@ -42,10 +40,10 @@ export const StripePaymentForm = ({ options, onSuccess }: Props) => {
description: error.name + ' ' + error.message,
details: error.message,
})
if (!data || !frameDocument) return
await initStripe(frameDocument)
if (!frameWindow?.Stripe) return
setStripe(frameWindow.Stripe(data.publicKey))
if (!data || !document) return
await initStripe(document)
if (!window?.Stripe) return
setStripe(window.Stripe(data.publicKey))
setClientSecret(data.clientSecret)
setAmountLabel(data.amountLabel)
})()

View File

@@ -0,0 +1 @@
export { PaymentForm } from './components/PaymentForm'

View File

@@ -1,5 +1,5 @@
import { PaymentInputOptions, Variable } from 'models'
import { sendRequest } from 'utils'
import { PaymentInputOptions, Variable } from '@typebot.io/schemas'
import { sendRequest } from '@typebot.io/lib'
export const createPaymentIntentQuery = ({
apiHost,

View File

@@ -1,7 +1,7 @@
import { SendButton } from '@/components/SendButton'
import { InputSubmitContent } from '@/types'
import { isMobile } from '@/utils/helpers'
import { PhoneNumberInputBlock } from 'models'
import { PhoneNumberInputBlock } from '@typebot.io/schemas'
import React, { useRef, useState } from 'react'
import ReactPhoneNumberInput, { Value, Country } from 'react-phone-number-input'

View File

@@ -1,7 +1,7 @@
import { InputSubmitContent } from '@/types'
import { RatingInputOptions, RatingInputBlock } from 'models'
import { RatingInputOptions, RatingInputBlock } from '@typebot.io/schemas'
import React, { FormEvent, useState } from 'react'
import { isDefined, isEmpty, isNotDefined } from 'utils'
import { isDefined, isEmpty, isNotDefined } from '@typebot.io/lib'
import { SendButton } from '../../../../../components/SendButton'
type Props = {

View File

@@ -2,7 +2,7 @@ import { ShortTextInput } from '@/components/inputs/ShortTextInput'
import { Textarea } from '@/components/inputs/Textarea'
import { SendButton } from '@/components/SendButton'
import { InputSubmitContent } from '@/types'
import { TextInputBlock } from 'models'
import { TextInputBlock } from '@typebot.io/schemas'
import React, { MutableRefObject, useRef, useState } from 'react'
type TextInputProps = {

View File

@@ -1,7 +1,7 @@
import { ShortTextInput } from '@/components/inputs/ShortTextInput'
import { SendButton } from '@/components/SendButton'
import { InputSubmitContent } from '@/types'
import { UrlInputBlock } from 'models'
import { UrlInputBlock } from '@typebot.io/schemas'
import React, { MutableRefObject, useRef, useState } from 'react'
type UrlInputProps = {

View File

@@ -2,7 +2,7 @@ import { parseVariables } from '@/features/variables'
import { IntegrationState } from '@/types'
import { sendEventToParent } from '@/utils/chat'
import { isEmbedded } from '@/utils/helpers'
import { ChatwootBlock, ChatwootOptions } from 'models'
import { ChatwootBlock, ChatwootOptions } from '@typebot.io/schemas'
const parseSetUserCode = (user: ChatwootOptions['user']) => `
window.$chatwoot.setUser("${user?.id ?? ''}", {

View File

@@ -1,7 +1,7 @@
import { parseVariablesInObject } from '@/features/variables'
import { sendGaEvent } from '@/lib/gtag'
import { IntegrationState } from '@/types'
import { GoogleAnalyticsBlock } from 'models'
import { GoogleAnalyticsBlock } from '@typebot.io/schemas'
export const executeGoogleAnalyticsBlock = async (
block: GoogleAnalyticsBlock,

View File

@@ -10,8 +10,8 @@ import {
VariableWithValue,
Cell,
Variable,
} from 'models'
import { sendRequest, byId } from 'utils'
} from '@typebot.io/schemas'
import { sendRequest, byId } from '@typebot.io/lib'
export const executeGoogleSheetBlock = async (
block: GoogleSheetsBlock,

View File

@@ -1,8 +1,8 @@
import { parseVariables } from '@/features/variables'
import { IntegrationState } from '@/types'
import { parseLog } from '@/utils/helpers'
import { SendEmailBlock } from 'models'
import { sendRequest, byId } from 'utils'
import { SendEmailBlock } from '@typebot.io/schemas'
import { sendRequest, byId } from '@typebot.io/lib'
export const executeSendEmailBlock = (
block: SendEmailBlock,

View File

@@ -6,9 +6,9 @@ import {
MakeComBlock,
PabblyConnectBlock,
VariableWithUnknowValue,
} from 'models'
} from '@typebot.io/schemas'
import { stringify } from 'qs'
import { sendRequest, byId } from 'utils'
import { sendRequest, byId } from '@typebot.io/lib'
export const executeWebhook = async (
block: WebhookBlock | ZapierBlock | MakeComBlock | PabblyConnectBlock,

View File

@@ -6,8 +6,8 @@ import {
ConditionBlock,
LogicalOperator,
Variable,
} from 'models'
import { isNotDefined, isDefined } from 'utils'
} from '@typebot.io/schemas'
import { isNotDefined, isDefined } from '@typebot.io/lib'
export const executeCondition = (
block: ConditionBlock,

View File

@@ -1,8 +1,8 @@
import { parseVariables } from '@/features/variables'
import { EdgeId, LogicState } from '@/types'
import { sendEventToParent } from '@/utils/chat'
import { RedirectBlock } from 'models'
import { sanitizeUrl } from 'utils'
import { RedirectBlock } from '@typebot.io/schemas'
import { sanitizeUrl } from '@typebot.io/lib'
export const executeRedirect = (
block: RedirectBlock,

View File

@@ -2,7 +2,7 @@ import { parseVariables, parseCorrectValueType } from '@/features/variables'
import { LogicState } from '@/types'
import { sendEventToParent } from '@/utils/chat'
import { isEmbedded } from '@/utils/helpers'
import { ScriptBlock } from 'models'
import { ScriptBlock } from '@typebot.io/schemas'
export const executeScript = async (
block: ScriptBlock,

View File

@@ -1,5 +1,5 @@
import { SetVariableBlock, Variable } from 'models'
import { byId } from 'utils'
import { SetVariableBlock, Variable } from '@typebot.io/schemas'
import { byId } from '@typebot.io/lib'
import { EdgeId, LogicState } from '@/types'
import { parseVariables, parseCorrectValueType } from '@/features/variables'

View File

@@ -1,7 +1,7 @@
import { LinkedTypebot } from '@/providers/TypebotProvider'
import { LogicState } from '@/types'
import { TypebotLinkBlock, Typebot, PublicTypebot } from 'models'
import { sendRequest } from 'utils'
import { TypebotLinkBlock, Typebot, PublicTypebot } from '@typebot.io/schemas'
import { sendRequest } from '@typebot.io/lib'
export const fetchAndInjectTypebot = async (
block: TypebotLinkBlock,

View File

@@ -1,6 +1,6 @@
import { LinkedTypebot } from '@/providers/TypebotProvider'
import { EdgeId, LogicState } from '@/types'
import { TypebotLinkBlock, Edge, PublicTypebot } from 'models'
import { TypebotLinkBlock, Edge, PublicTypebot } from '@typebot.io/schemas'
import { fetchAndInjectTypebot } from '../queries/fetchAndInjectTypebotQuery'
export const executeTypebotLink = async (

View File

@@ -1,6 +1,6 @@
import { parseVariables } from '@/features/variables'
import { LogicState } from '@/types'
import { WaitBlock } from 'models'
import { WaitBlock } from '@typebot.io/schemas'
export const executeWait = async (
block: WaitBlock,

View File

@@ -6,7 +6,7 @@ import {
GeneralTheme,
InputColors,
Theme,
} from 'models'
} from '@typebot.io/schemas'
const cssVariableNames = {
general: {

View File

@@ -1,5 +1,5 @@
import { Variable, VariableWithValue } from 'models'
import { isDefined, isNotDefined } from 'utils'
import { Variable, VariableWithValue } from '@typebot.io/schemas'
import { isDefined, isNotDefined } from '@typebot.io/lib'
export const stringContainsVariable = (str: string): boolean =>
/\{\{(.*?)\}\}/g.test(str)

View File

@@ -1,4 +1,4 @@
import { GoogleAnalyticsOptions } from 'models'
import { GoogleAnalyticsOptions } from '@typebot.io/schemas'
declare const gtag: (
type: string,

View File

@@ -5,9 +5,9 @@ import {
Variable,
VariableWithUnknowValue,
VariableWithValue,
} from 'models'
} from '@typebot.io/schemas'
import { createContext, ReactNode, useContext, useState } from 'react'
import { isDefined } from 'utils'
import { isDefined } from '@typebot.io/lib'
const answersContext = createContext<{
resultId?: string

View File

@@ -1,8 +1,8 @@
import { TypebotViewerProps } from '@/components/TypebotViewer'
import { safeStringify } from '@/features/variables'
import { sendEventToParent } from '@/utils/chat'
import { Log } from 'db'
import { Edge, PublicTypebot, Typebot, Variable } from 'models'
import { Log } from '@typebot.io/prisma'
import { Edge, PublicTypebot, Typebot, Variable } from '@typebot.io/schemas'
import {
createContext,
ReactNode,
@@ -10,7 +10,7 @@ import {
useEffect,
useState,
} from 'react'
import { isDefined } from 'utils'
import { isDefined } from '@typebot.io/lib'
export type LinkedTypebot = Pick<
PublicTypebot | Typebot,

View File

@@ -1,4 +1,4 @@
import { Log } from 'db'
import { Log } from '@typebot.io/prisma'
import {
Edge,
Group,
@@ -7,7 +7,7 @@ import {
Typebot,
Variable,
VariableWithUnknowValue,
} from 'models'
} from '@typebot.io/schemas'
import { TypebotViewerProps } from './components/TypebotViewer'
import { LinkedTypebot } from './providers/TypebotProvider'

View File

@@ -4,8 +4,8 @@ import {
InputBlock,
InputBlockType,
Block,
} from 'models'
import { isBubbleBlock, isInputBlock } from 'utils'
} from '@typebot.io/schemas'
import { isBubbleBlock, isInputBlock } from '@typebot.io/lib'
import type { TypebotPostMessageData } from 'typebot-js'
export const getLastChatBlockType = (

Some files were not shown because too many files have changed in this diff Show More