2
0

Add attachments option to text input (#1608)

Closes #854
This commit is contained in:
Baptiste Arnaud
2024-06-26 10:13:38 +02:00
committed by GitHub
parent 80da7af4f1
commit 6db0464fd7
88 changed files with 2959 additions and 735 deletions

View File

@@ -23,6 +23,7 @@ import {
} from '@typebot.io/schemas/features/blocks/logic/setVariable/constants'
import { createCodeRunner } from '@typebot.io/variables/codeRunners'
import { stringifyError } from '@typebot.io/lib/stringifyError'
import { AnswerV2 } from '@typebot.io/prisma'
export const executeSetVariable = async (
state: SessionState,
@@ -246,7 +247,7 @@ const toISOWithTz = (date: Date, timeZone: string) => {
}
type ParsedTranscriptProps = {
answers: Pick<Answer, 'blockId' | 'content'>[]
answers: Pick<Answer, 'blockId' | 'content' | 'attachedFileUrls'>[]
setVariableHistory: Pick<
SetVariableHistoryItem,
'blockId' | 'variableId' | 'value'
@@ -273,6 +274,10 @@ const parsePreviewTranscriptProps = async (
}
}
type UnifiedAnswersFromDB = (ParsedTranscriptProps['answers'][number] & {
createdAt: Date
})[]
const parseResultTranscriptProps = async (
state: SessionState
): Promise<ParsedTranscriptProps | undefined> => {
@@ -299,6 +304,7 @@ const parseResultTranscriptProps = async (
blockId: true,
content: true,
createdAt: true,
attachedFileUrls: true,
},
},
setVariableHistory: {
@@ -313,8 +319,8 @@ const parseResultTranscriptProps = async (
})
if (!result) return
return {
answers: result.answersV2
.concat(result.answers)
answers: (result.answersV2 as UnifiedAnswersFromDB)
.concat(result.answers as UnifiedAnswersFromDB)
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime()),
setVariableHistory: (
result.setVariableHistory as SetVariableHistoryItem[]