2
0

♻️ Remove @typebot.io/schemas from @typebot.io/lib

This commit is contained in:
Baptiste Arnaud
2024-03-15 16:32:29 +01:00
parent b53242ce6a
commit 5073be2439
186 changed files with 809 additions and 581 deletions

View File

@@ -0,0 +1 @@
reporters

View File

@@ -9,7 +9,8 @@
"lint": "dotenv -e ./.env -e ../../.env -- next lint",
"format:check": "prettier --check ./src",
"test": "dotenv -e ./.env -e ../../.env -- pnpm playwright test",
"test:report": "pnpm playwright show-report"
"test:report": "pnpm playwright show-report",
"test:ui": "dotenv -e ./.env -e ../../.env -- pnpm playwright test --ui"
},
"dependencies": {
"@lilyrose2798/trpc-openapi": "^1.3.9",
@@ -35,6 +36,7 @@
"stripe": "12.13.0"
},
"devDependencies": {
"dotenv": "16.4.5",
"@faire/mjml-react": "3.3.0",
"@paralleldrive/cuid2": "2.2.1",
"@playwright/test": "1.36.0",
@@ -61,6 +63,8 @@
"papaparse": "5.4.1",
"superjson": "1.12.4",
"typescript": "5.3.2",
"zod": "3.22.4"
"zod": "3.22.4",
"@typebot.io/playwright": "workspace:*",
"@typebot.io/results": "workspace:*"
}
}

View File

@@ -1,20 +1,43 @@
import { PlaywrightTestConfig } from '@playwright/test'
import path from 'path'
import { playwrightBaseConfig } from '@typebot.io/lib/playwright/baseConfig'
import { defineConfig, devices } from '@playwright/test'
const config: PlaywrightTestConfig = {
...playwrightBaseConfig,
testDir: path.join(__dirname, 'src'),
process.env.SKIP_ENV_CHECK = 'true'
export default defineConfig({
timeout: process.env.CI ? 50 * 1000 : 40 * 1000,
expect: {
timeout: process.env.CI ? 10 * 1000 : 5 * 1000,
},
forbidOnly: !!process.env.CI,
workers: process.env.CI ? 1 : 3,
retries: process.env.CI ? 2 : 0,
reporter: [
[process.env.CI ? 'github' : 'list'],
['html', { outputFolder: 'src/test/reporters' }],
],
maxFailures: process.env.CI ? 10 : undefined,
webServer: process.env.CI
? {
...(playwrightBaseConfig.webServer as { command: string }),
command: 'pnpm run start',
timeout: 60_000,
reuseExistingServer: true,
port: 3001,
}
: undefined,
outputDir: './src/test/results',
use: {
...playwrightBaseConfig.use,
trace: 'on-first-retry',
locale: 'en-US',
baseURL: process.env.NEXT_PUBLIC_VIEWER_URL,
},
}
export default config
projects: [
{
name: 'setup db',
testMatch: /global\.setup\.ts/,
},
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
dependencies: ['setup db'],
},
],
})

View File

@@ -4,7 +4,7 @@ import { SessionState } from '@typebot.io/schemas'
import { StreamingTextResponse } from 'ai'
import OpenAI from 'openai'
import { NextResponse } from 'next/dist/server/web/spec-extension/response'
import { getBlockById } from '@typebot.io/lib/getBlockById'
import { getBlockById } from '@typebot.io/schemas/helpers'
import { forgedBlocks } from '@typebot.io/forge-schemas'
import { decryptV2 } from '@typebot.io/lib/api/encryption/decryptV2'
import { ReadOnlyVariableStore } from '@typebot.io/forge'

View File

@@ -7,7 +7,7 @@ import prisma from '@typebot.io/lib/prisma'
import { getSession } from '@typebot.io/bot-engine/queries/getSession'
import { parseGroups } from '@typebot.io/schemas'
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
import { getBlockById } from '@typebot.io/lib/getBlockById'
import { getBlockById } from '@typebot.io/schemas/helpers'
export const generateUploadUrl = publicProcedure
.meta({

View File

@@ -9,14 +9,9 @@ import {
} from '@typebot.io/schemas'
import { NextApiRequest, NextApiResponse } from 'next'
import got, { Method, Headers, HTTPError } from 'got'
import {
byId,
isEmpty,
isNotDefined,
isWebhookBlock,
omit,
} from '@typebot.io/lib'
import { parseAnswers } from '@typebot.io/lib/results/parseAnswers'
import { byId, isEmpty, isNotDefined, omit } from '@typebot.io/lib'
import { isWebhookBlock } from '@typebot.io/schemas/helpers'
import { parseAnswers } from '@typebot.io/results/parseAnswers'
import { initMiddleware, methodNotAllowed, notFound } from '@typebot.io/lib/api'
import { stringify } from 'qs'
import Cors from 'cors'
@@ -33,7 +28,7 @@ import {
defaultWebhookAttributes,
maxTimeout,
} from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'
import { getBlockById } from '@typebot.io/lib/getBlockById'
import { getBlockById } from '@typebot.io/schemas/helpers'
import {
convertKeyValueTableToObject,
longReqTimeoutWhitelist,

View File

@@ -7,7 +7,7 @@ import {
import { NextApiRequest, NextApiResponse } from 'next'
import { createTransport, getTestMessageUrl } from 'nodemailer'
import { isDefined, isEmpty, isNotDefined, omit } from '@typebot.io/lib'
import { parseAnswers } from '@typebot.io/lib/results/parseAnswers'
import { parseAnswers } from '@typebot.io/results/parseAnswers'
import { methodNotAllowed, initMiddleware } from '@typebot.io/lib/api'
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'

View File

@@ -2,7 +2,7 @@ import { authenticateUser } from '@/helpers/authenticateUser'
import prisma from '@typebot.io/lib/prisma'
import { Group, HttpRequestBlock } from '@typebot.io/schemas'
import { NextApiRequest, NextApiResponse } from 'next'
import { isWebhookBlock } from '@typebot.io/lib'
import { isWebhookBlock } from '@typebot.io/schemas/helpers'
import { methodNotAllowed } from '@typebot.io/lib/api'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {

View File

@@ -2,7 +2,8 @@ import { authenticateUser } from '@/helpers/authenticateUser'
import prisma from '@typebot.io/lib/prisma'
import { Group } from '@typebot.io/schemas'
import { NextApiRequest, NextApiResponse } from 'next'
import { isNotDefined, isWebhookBlock } from '@typebot.io/lib'
import { isNotDefined } from '@typebot.io/lib'
import { isWebhookBlock } from '@typebot.io/schemas/helpers'
import { methodNotAllowed } from '@typebot.io/lib/api'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {

View File

@@ -7,7 +7,7 @@ import {
deleteTypebots,
deleteWebhooks,
importTypebotInDatabase,
} from '@typebot.io/lib/playwright/databaseActions'
} from '@typebot.io/playwright/databaseActions'
import { HttpMethod } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'
import { StartChatInput, StartPreviewChatInput } from '@typebot.io/schemas'

View File

@@ -1,7 +1,7 @@
import test, { expect } from '@playwright/test'
import { createId } from '@paralleldrive/cuid2'
import { createTypebots } from '@typebot.io/lib/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers'
import { createTypebots } from '@typebot.io/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers'
import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants'
const typebotId = createId()

View File

@@ -3,7 +3,7 @@ import { createId } from '@paralleldrive/cuid2'
import { parse } from 'papaparse'
import { readFileSync } from 'fs'
import { isDefined } from '@typebot.io/lib'
import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions'
import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions'
import { getTestAsset } from '@/test/utils/playwright'
import { env } from '@typebot.io/env'

View File

@@ -0,0 +1,6 @@
import { test as setup } from '@playwright/test'
import { globalSetup } from '@typebot.io/playwright/globalSetup'
setup('setup db', async () => {
await globalSetup()
})

View File

@@ -1,7 +1,7 @@
import { getTestAsset } from '@/test/utils/playwright'
import test, { expect } from '@playwright/test'
import { createId } from '@paralleldrive/cuid2'
import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions'
import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions'
import { env } from '@typebot.io/env'
test('Big groups should work as expected', async ({ page }) => {

View File

@@ -1,6 +1,6 @@
import test, { expect } from '@playwright/test'
import { createId } from '@paralleldrive/cuid2'
import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions'
import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions'
import { SmtpCredentials } from '@typebot.io/schemas'
import { env } from '@typebot.io/env'
import { createSmtpCredentials } from './utils/databaseActions'

View File

@@ -3,8 +3,8 @@ import { createId } from '@paralleldrive/cuid2'
import {
createTypebots,
updateTypebot,
} from '@typebot.io/lib/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from '@typebot.io/lib/playwright/databaseHelpers'
} from '@typebot.io/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from '@typebot.io/playwright/databaseHelpers'
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
import { Settings } from '@typebot.io/schemas'
import { defaultTextInputOptions } from '@typebot.io/schemas/features/blocks/inputs/text/constants'

View File

@@ -1,7 +1,7 @@
import { getTestAsset } from '@/test/utils/playwright'
import test, { expect } from '@playwright/test'
import { env } from '@typebot.io/env'
import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions'
import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions'
const typebotId = 'cl0ibhi7s0018n21aarlmg0cm'
const typebotWithMergeDisabledId = 'cl0ibhi7s0018n21aarlag0cm'

View File

@@ -1,7 +1,7 @@
import { PrismaClient } from '@typebot.io/prisma'
import { SmtpCredentials } from '@typebot.io/schemas'
import { encrypt } from '@typebot.io/lib/api/encryption/encrypt'
import { proWorkspaceId } from '@typebot.io/lib/playwright/databaseSetup'
import { proWorkspaceId } from '@typebot.io/playwright/databaseSetup'
const prisma = new PrismaClient()

View File

@@ -1,7 +1,7 @@
import { getTestAsset } from '@/test/utils/playwright'
import test, { expect } from '@playwright/test'
import { createId } from '@paralleldrive/cuid2'
import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions'
import { importTypebotInDatabase } from '@typebot.io/playwright/databaseActions'
test('should correctly be injected', async ({ page }) => {
const typebotId = createId()

View File

@@ -3,7 +3,7 @@ import { createId } from '@paralleldrive/cuid2'
import {
createWebhook,
importTypebotInDatabase,
} from '@typebot.io/lib/playwright/databaseActions'
} from '@typebot.io/playwright/databaseActions'
import { getTestAsset } from '@/test/utils/playwright'
import { HttpMethod } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'