♻️ Remove @typebot.io/schemas from @typebot.io/lib
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user