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

@@ -19,7 +19,7 @@ import { ExecuteIntegrationResponse } from '../../../types'
import prisma from '@typebot.io/lib/prisma'
import { parseVariables } from '@typebot.io/variables/parseVariables'
import { defaultSendEmailOptions } from '@typebot.io/schemas/features/blocks/integrations/sendEmail/constants'
import { parseAnswers } from '@typebot.io/lib/results/parseAnswers'
import { parseAnswers } from '@typebot.io/results/parseAnswers'
export const sendEmailSuccessDescription = 'Email successfully sent'
export const sendEmailErrorDescription = 'Email not sent'

View File

@@ -26,7 +26,7 @@ import {
maxTimeout,
} from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'
import { env } from '@typebot.io/env'
import { parseAnswers } from '@typebot.io/lib/results/parseAnswers'
import { parseAnswers } from '@typebot.io/results/parseAnswers'
type ParsedWebhook = ExecutableHttpRequest & {
basicAuth: { username?: string; password?: string }

View File

@@ -7,15 +7,17 @@ import {
TypebotLinkBlock,
Variable,
} from '@typebot.io/schemas'
import { isInputBlock, byId, isNotDefined } from '@typebot.io/lib'
import { byId, isNotDefined } from '@typebot.io/lib'
import { isInputBlock } from '@typebot.io/schemas/helpers'
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
import { LogicBlockType } from '@typebot.io/schemas/features/blocks/logic/constants'
import { parseResultHeader } from '@typebot.io/lib/results/parseResultHeader'
import { parseResultHeader } from '@typebot.io/results/parseResultHeader'
export const parseSampleResult =
(
typebot: Pick<Typebot | PublicTypebot, 'groups' | 'variables' | 'edges'>,
linkedTypebots: (Typebot | PublicTypebot)[]
linkedTypebots: (Typebot | PublicTypebot)[],
userEmail?: string
) =>
async (
currentGroupId: string,
@@ -30,7 +32,7 @@ export const parseSampleResult =
return {
message: 'This is a sample result, it has been generated ⬇️',
submittedAt: new Date().toISOString(),
...parseResultSample(linkedInputBlocks, header, variables),
...parseResultSample(linkedInputBlocks, header, variables, userEmail),
}
}
@@ -83,7 +85,8 @@ const extractLinkedInputBlocks =
const parseResultSample = (
inputBlocks: InputBlock[],
headerCells: ResultHeaderCell[],
variables: Variable[]
variables: Variable[],
userEmail?: string
) =>
headerCells.reduce<Record<string, string | (string | null)[] | undefined>>(
(resultSample, cell) => {
@@ -107,7 +110,7 @@ const parseResultSample = (
const variableValue = variables.find(
(variable) => cell.variableIds?.includes(variable.id) && variable.value
)?.value
const value = variableValue ?? getSampleValue(inputBlock)
const value = variableValue ?? getSampleValue(inputBlock, userEmail)
return {
...resultSample,
[cell.label]: value,
@@ -116,7 +119,7 @@ const parseResultSample = (
{}
)
const getSampleValue = (block: InputBlock): string => {
const getSampleValue = (block: InputBlock, userEmail?: string): string => {
switch (block.type) {
case InputBlockType.CHOICE:
return block.options?.isMultipleChoice
@@ -125,7 +128,7 @@ const getSampleValue = (block: InputBlock): string => {
case InputBlockType.DATE:
return new Date().toUTCString()
case InputBlockType.EMAIL:
return 'test@email.com'
return userEmail ?? 'test@email.com'
case InputBlockType.NUMBER:
return '20'
case InputBlockType.PHONE:

View File

@@ -10,7 +10,7 @@ import { byId, isDefined, isEmpty } from '@typebot.io/lib'
import prisma from '@typebot.io/lib/prisma'
import { ExecuteIntegrationResponse } from '../../../types'
import { updateVariablesInSession } from '@typebot.io/variables/updateVariablesInSession'
import { parseAnswers } from '@typebot.io/lib/results/parseAnswers'
import { parseAnswers } from '@typebot.io/results/parseAnswers'
const URL = 'https://api.zemantic.ai/v1/search-documents'

View File

@@ -1,5 +1,9 @@
import { blockHasItems, isDefined, isInputBlock, byId } from '@typebot.io/lib'
import { getBlockById } from '@typebot.io/lib/getBlockById'
import { isDefined, byId } from '@typebot.io/lib'
import {
getBlockById,
blockHasItems,
isInputBlock,
} from '@typebot.io/schemas/helpers'
import { Block, SessionState } from '@typebot.io/schemas'
type Props = {

View File

@@ -6,7 +6,8 @@ import {
InputBlock,
SessionState,
} from '@typebot.io/schemas'
import { isInputBlock, byId } from '@typebot.io/lib'
import { byId } from '@typebot.io/lib'
import { isInputBlock } from '@typebot.io/schemas/helpers'
import { executeGroup, parseInput } from './executeGroup'
import { getNextGroup } from './getNextGroup'
import { validateEmail } from './blocks/inputs/email/validateEmail'
@@ -34,7 +35,7 @@ import { defaultChoiceInputOptions } from '@typebot.io/schemas/features/blocks/i
import { defaultPictureChoiceOptions } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice/constants'
import { defaultFileInputOptions } from '@typebot.io/schemas/features/blocks/inputs/file/constants'
import { VisitedEdge } from '@typebot.io/prisma'
import { getBlockById } from '@typebot.io/lib/getBlockById'
import { getBlockById } from '@typebot.io/schemas/helpers'
import { ForgedBlock, forgedBlocks } from '@typebot.io/forge-schemas'
import { enabledBlocks } from '@typebot.io/forge-repository'
import { resumeChatCompletion } from './blocks/integrations/legacy/openai/resumeChatCompletion'

View File

@@ -5,13 +5,13 @@ import {
RuntimeOptions,
SessionState,
} from '@typebot.io/schemas'
import { isNotEmpty } from '@typebot.io/lib'
import {
isBubbleBlock,
isInputBlock,
isIntegrationBlock,
isLogicBlock,
isNotEmpty,
} from '@typebot.io/lib'
} from '@typebot.io/schemas/helpers'
import { getNextGroup } from './getNextGroup'
import { executeLogic } from './executeLogic'
import { executeIntegration } from './executeIntegration'

View File

@@ -30,7 +30,8 @@
"nodemailer": "6.9.3",
"openai": "4.28.4",
"qs": "6.11.2",
"stripe": "12.13.0"
"stripe": "12.13.0",
"@typebot.io/results": "workspace:*"
},
"devDependencies": {
"@typebot.io/forge": "workspace:*",

View File

@@ -1,4 +1,4 @@
import { parseVideoUrl } from '@typebot.io/lib/parseVideoUrl'
import { parseVideoUrl } from '@typebot.io/schemas/features/blocks/bubbles/video/helpers'
import {
BubbleBlock,
Variable,

View File

@@ -1,6 +1,7 @@
import { createId } from '@paralleldrive/cuid2'
import { TRPCError } from '@trpc/server'
import { isDefined, omit, isNotEmpty, isInputBlock } from '@typebot.io/lib'
import { isDefined, omit, isNotEmpty } from '@typebot.io/lib'
import { isInputBlock } from '@typebot.io/schemas/helpers'
import {
Variable,
VariableWithValue,