2
0

♻️ Add a test for internal waitUntil

This commit is contained in:
Baptiste Arnaud
2024-04-16 12:56:47 +02:00
parent 8d62898d15
commit 87f5d8515a
89 changed files with 1029 additions and 1154 deletions

View File

@@ -8,7 +8,7 @@
},
"keywords": [],
"author": "Baptiste Arnaud",
"license": "ISC",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@typebot.io/prisma": "workspace:*",
"@typebot.io/schemas": "workspace:*",

View File

@@ -1,4 +1,5 @@
import { DefaultBotNotificationEmail, render } from '@typebot.io/emails'
import { render } from '@typebot.io/emails/render'
import DefaultSendEmailNotification from '@typebot.io/emails/templates/transactional/DefaultSendEmailNotification'
import {
AnswerInSessionState,
ChatLog,
@@ -253,11 +254,11 @@ const getEmailBody = async ({
})
return {
html: render(
<DefaultBotNotificationEmail
<DefaultSendEmailNotification
resultsUrl={`${env.NEXTAUTH_URL}/typebots/${typebot.id}/results`}
answers={omit(answers, 'submittedAt')}
/>
).html,
),
}
}

View File

@@ -18,7 +18,7 @@
"@typebot.io/schemas": "workspace:*",
"@typebot.io/tsconfig": "workspace:*",
"@typebot.io/variables": "workspace:*",
"@udecode/plate-common": "30.4.5",
"@udecode/slate": "31.0.0",
"ai": "3.0.12",
"chrono-node": "2.7.5",
"date-fns": "2.30.0",

View File

@@ -11,7 +11,7 @@ import {
getVariablesToParseInfoInText,
parseVariables,
} from '@typebot.io/variables/parseVariables'
import { TDescendant } from '@udecode/plate-common'
import { TDescendant } from '@udecode/slate'
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
import { defaultVideoBubbleContent } from '@typebot.io/schemas/features/blocks/bubbles/video/constants'
import { convertMarkdownToRichText } from '@typebot.io/lib/markdown/convertMarkdownToRichText'

View File

@@ -1,5 +1,5 @@
{
"name": "@typebot.io/emails",
"name": "@typebot.io/email-legacy",
"version": "1.0.0",
"description": "",
"private": true,
@@ -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",

View File

@@ -11,10 +11,10 @@
"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",
"@udecode/slate": "31.0.0",
"dompurify": "3.0.6",
"ky": "1.1.3",
"marked": "9.0.3",

View File

@@ -1,4 +1,4 @@
import type { TElement, TText, TDescendant } from '@udecode/plate-common'
import type { TElement, TText, TDescendant } from '@udecode/slate'
import { PlateText, PlateTextProps } from './PlateText'
import { For, JSXElement, Match, Switch } from 'solid-js'
import { isDefined } from '@typebot.io/lib/utils'

View File

@@ -1,4 +1,4 @@
import type { TDescendant } from '@udecode/plate-common'
import type { TDescendant } from '@udecode/slate'
export const computePlainText = (elements: TDescendant[]): string =>
elements

View File

@@ -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",

View File

@@ -15,7 +15,7 @@
},
"keywords": [],
"author": "Baptiste Arnaud",
"license": "ISC",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@ladle/react": "2.5.1"
},

View File

@@ -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:*",

View File

@@ -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:*",

View File

@@ -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:*",

View File

@@ -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:*",

View File

@@ -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:*",

View File

@@ -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:*",

View File

@@ -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:*",

View File

@@ -5,7 +5,7 @@
"main": "index.ts",
"keywords": [],
"author": "Baptiste Arnaud",
"license": "ISC",
"license": "AGPL-3.0-or-later",
"dependencies": {
"ai": "3.0.12",
"openai": "4.28.4"

View File

@@ -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:*",
@@ -16,4 +16,4 @@
"dependencies": {
"qrcode": "^1.5.3"
}
}
}

View File

@@ -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:*",

View File

@@ -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:*",

View File

@@ -162,7 +162,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:*',

View File

@@ -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:*",

View File

@@ -5,7 +5,7 @@
"main": "index.ts",
"keywords": [],
"author": "Baptiste Arnaud",
"license": "ISC",
"license": "AGPL-3.0-or-later",
"dependencies": {
"zod": "3.22.4"
},

View File

@@ -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:*",

View File

@@ -2,9 +2,9 @@ import {
createPlateEditor,
createPluginFactory,
getPluginOptions,
isUrl,
Value,
} from '@udecode/plate-common'
} from '@udecode/plate-core'
import { Value } from '@udecode/slate'
import { isUrl } from '@udecode/utils'
import markdown from 'remark-parse'
import { unified } from 'unified'

View File

@@ -1,6 +1,6 @@
import { TElement } from '@udecode/plate-common'
import serialize from './serializer/serialize'
import { defaultNodeTypes } from './serializer/ast-types'
import { TElement } from '@udecode/slate'
export const convertRichTextToMarkdown = (
richText: TElement[],

View File

@@ -1,4 +1,5 @@
import { getPluginOptions, PlateEditor, Value } from '@udecode/plate-common'
import { Value } from '@udecode/slate'
import { getPluginOptions, PlateEditor } from '@udecode/plate-core'
import markdown from 'remark-parse'
import { unified } from 'unified'

View File

@@ -1,4 +1,4 @@
import { Value } from '@udecode/plate-common'
import { Value } from '@udecode/slate'
import { RemarkElementRules, RemarkTextRules } from '../remark-slate/types'
export interface DeserializeMdPlugin<V extends Value = Value> {

View File

@@ -3,13 +3,8 @@ import {
ELEMENT_CODE_BLOCK,
ELEMENT_CODE_LINE,
} from '@udecode/plate-code-block'
import {
getPluginType,
TDescendant,
TElement,
TText,
Value,
} from '@udecode/plate-common'
import { TDescendant, TElement, TText, Value } from '@udecode/slate'
import { getPluginType } from '@udecode/plate-core'
import {
ELEMENT_H1,
ELEMENT_H2,

View File

@@ -1,5 +1,6 @@
import { MARK_BOLD, MARK_CODE, MARK_ITALIC } from '@udecode/plate-basic-marks'
import { getPluginType, Value } from '@udecode/plate-common'
import { Value } from '@udecode/slate'
import { getPluginType } from '@udecode/plate-core'
import { RemarkTextRules } from './types'

View File

@@ -1,4 +1,4 @@
import { Value } from '@udecode/plate-common'
import { Value } from '@udecode/slate'
import { remarkTransformNode } from './remarkTransformNode'
import { MdastNode, RemarkPluginOptions } from './types'

View File

@@ -1,4 +1,4 @@
import { TElement, Value } from '@udecode/plate-common'
import { TElement, Value } from '@udecode/slate'
import { MdastNode, RemarkPluginOptions } from './types'

View File

@@ -1,4 +1,4 @@
import { TDescendant, Value } from '@udecode/plate-common'
import { TDescendant, Value } from '@udecode/slate'
import { remarkTransformNode } from './remarkTransformNode'
import { MdastNode, RemarkPluginOptions } from './types'

View File

@@ -1,4 +1,4 @@
import { TDescendant, Value } from '@udecode/plate-common'
import { TDescendant, Value } from '@udecode/slate'
import { remarkTextTypes } from './remarkTextTypes'
import { remarkTransformElement } from './remarkTransformElement'

View File

@@ -1,4 +1,4 @@
import { TText, Value } from '@udecode/plate-common'
import { TText, Value } from '@udecode/slate'
import { remarkDefaultTextRules } from './remarkDefaultTextRules'
import { MdastNode, RemarkPluginOptions } from './types'

View File

@@ -1,4 +1,5 @@
import { PlateEditor, TElement, Value } from '@udecode/plate-common'
import { TElement, Value } from '@udecode/slate'
import { PlateEditor } from '@udecode/plate-core'
export type MdastElementType =
| 'paragraph'

View File

@@ -14,7 +14,7 @@
"@types/escape-html": "^1.0.4",
"@types/nodemailer": "6.4.8",
"@types/validator": "13.11.9",
"next": "14.1.0",
"next": "14.2.1",
"nodemailer": "6.9.8",
"tslib": "2.6.0",
"typescript": "5.3.2"
@@ -26,16 +26,18 @@
"dependencies": {
"@sentry/nextjs": "7.77.0",
"@trpc/server": "10.40.0",
"@udecode/plate-basic-marks": "30.5.3",
"@udecode/plate-block-quote": "30.5.3",
"@udecode/plate-code-block": "30.7.0",
"@udecode/plate-common": "30.4.5",
"@udecode/plate-heading": "30.5.3",
"@udecode/plate-horizontal-rule": "30.5.3",
"@udecode/plate-link": "30.5.3",
"@udecode/plate-list": "30.5.3",
"@udecode/plate-media": "30.5.3",
"@udecode/plate-paragraph": "30.5.3",
"@udecode/plate-basic-marks": "31.0.0",
"@udecode/plate-block-quote": "31.0.0",
"@udecode/plate-code-block": "31.3.4",
"@udecode/plate-core": "31.3.2",
"@udecode/plate-heading": "31.0.0",
"@udecode/plate-horizontal-rule": "31.0.0",
"@udecode/plate-link": "31.0.0",
"@udecode/plate-list": "31.1.3",
"@udecode/plate-media": "31.0.0",
"@udecode/plate-paragraph": "31.0.0",
"@udecode/slate": "31.0.0",
"@udecode/utils": "31.0.0",
"escape-html": "1.0.3",
"google-auth-library": "8.9.0",
"ky": "1.2.3",

View File

@@ -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:*",

View File

@@ -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:*",

View File

@@ -6,7 +6,7 @@
"license": "AGPL-3.0-or-later",
"private": true,
"dependencies": {
"@udecode/plate-common": "30.4.5"
"@udecode/slate": "31.0.0"
},
"devDependencies": {
"@typebot.io/schemas": "workspace:*",

View File

@@ -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:*",

View File

@@ -1,5 +1,5 @@
import { z } from '../../../../zod'
import type { TElement } from '@udecode/plate-common'
import type { TElement } from '@udecode/slate'
import { blockBaseSchema } from '../../shared'
import { BubbleBlockType } from '../constants'

View File

@@ -6,7 +6,7 @@
"license": "AGPL-3.0-or-later",
"private": true,
"dependencies": {
"@udecode/plate-common": "30.4.5",
"@udecode/slate": "31.0.0",
"zod": "3.22.4",
"zod-openapi": "^2.11.0"
},

View File

@@ -3,7 +3,7 @@ import { isDefined, isEmpty } from '@typebot.io/lib'
import { getChatsLimit } from '@typebot.io/billing/getChatsLimit'
import { promptAndSetEnvironment } from './utils'
import { Workspace } from '@typebot.io/schemas'
import { sendAlmostReachedChatsLimitEmail } from '@typebot.io/emails/src/emails/AlmostReachedChatsLimitEmail'
import { sendAlmostReachedChatsLimitEmail } from '@typebot.io/email-legacy/src/emails/AlmostReachedChatsLimitEmail'
import { TelemetryEvent } from '@typebot.io/schemas/features/telemetry'
import { trackEvents } from '@typebot.io/telemetry/trackEvents'
import Stripe from 'stripe'

View File

@@ -33,7 +33,7 @@
"deleteChatSession": "tsx deleteChatSession.ts"
},
"devDependencies": {
"@typebot.io/emails": "workspace:*",
"@typebot.io/email-legacy": "workspace:*",
"@typebot.io/lib": "workspace:*",
"@typebot.io/prisma": "workspace:*",
"@typebot.io/schemas": "workspace:*",

View File

@@ -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",

View File

@@ -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:*"

View File

@@ -1,5 +1,5 @@
{
"name": "transactional",
"name": "@typebot.io/emails",
"version": "1.0.0",
"description": "",
"scripts": {
@@ -7,13 +7,15 @@
},
"keywords": [],
"author": "Baptiste Arnaud",
"license": "ISC",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@react-email/components": "0.0.14",
"react-email": "2.0.0",
"@typebot.io/env": "workspace:*"
"@react-email/components": "0.0.16",
"@react-email/render": "0.0.12",
"@typebot.io/env": "workspace:*",
"react-email": "2.1.1"
},
"devDependencies": {
"@typebot.io/tsconfig": "workspace:^",
"dotenv-cli": "7.2.1"
}
}

View File

@@ -0,0 +1 @@
export { render } from '@react-email/render'

View File

@@ -12,7 +12,6 @@ import {
Button,
Section,
} from '@react-email/components'
import * as React from 'react'
import { env } from '@typebot.io/env'
import {
main,

View File

@@ -9,10 +9,8 @@ import {
Text,
Hr,
Heading,
Button,
Section,
} from '@react-email/components'
import * as React from 'react'
import { env } from '@typebot.io/env'
import {
main,

View File

@@ -11,7 +11,6 @@ import {
Heading,
Section,
} from '@react-email/components'
import * as React from 'react'
import { env } from '@typebot.io/env'
import {
main,

View File

@@ -0,0 +1,89 @@
import {
Body,
Button,
Container,
Head,
Html,
Link,
Text,
} from '@react-email/components'
const emailRegex =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
type Props = {
resultsUrl: string
answers: { [key: string]: string }
}
const DefaultSendEmailNotification = ({ resultsUrl, answers }: Props) => (
<Html>
<Head />
<Body style={body}>
<Container style={container}>
{Object.keys(answers).map((key, index) => {
const isEmail = emailRegex.test(answers[key])
return (
<Text key={key} style={index === 0 ? firstEntry : entry}>
<strong>{key}</strong>:{' '}
{isEmail ? (
<Link href={`mailto:${answers[key]}`}>{answers[key]}</Link>
) : answers[key].includes('\n') ? (
answers[key].split('\n').map((line) => (
<>
{line}
<br />
</>
))
) : (
answers[key]
)}
</Text>
)
})}
<Button style={goToResultsButton} href={resultsUrl}>
Go to results
</Button>
</Container>
</Body>
</Html>
)
const body = {
fontFamily:
"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
}
const container = {
maxWidth: '600px',
margin: '0 auto',
padding: '20px 30px',
border: '1px solid #eaeaea',
}
const goToResultsButton = {
backgroundColor: '#0042DA',
padding: '10px 24px',
borderRadius: '6px',
color: 'white',
}
const firstEntry = {
margin: '0 0 24x 0',
}
const entry = {
margin: '24px 0',
}
DefaultSendEmailNotification.PreviewProps = {
resultsUrl: 'http://localhost:3000',
answers: {
Name: 'John Doe',
Email: 'baptiste@typebot.io',
'Additional information': 'I have a question about your product.',
},
} satisfies Props
export default DefaultSendEmailNotification

View File

@@ -9,7 +9,6 @@ import {
Preview,
Text,
} from '@react-email/components'
import * as React from 'react'
import { env } from '@typebot.io/env'
interface Props {

View File

@@ -0,0 +1,9 @@
{
"extends": "@typebot.io/tsconfig/base.json",
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["dist", "node_modules"],
"compilerOptions": {
"jsx": "preserve",
"lib": ["ESNext"]
}
}