2
0

♻️ Introduce typebot v6 with events (#1013)

Closes #885
This commit is contained in:
Baptiste Arnaud
2023-11-08 15:34:16 +01:00
committed by GitHub
parent 68e4fc71fb
commit 35300eaf34
634 changed files with 58971 additions and 31449 deletions

View File

@ -8,6 +8,7 @@ type Props = {
hasStarted: boolean
isCompleted: boolean
}
export const createResultIfNotExist = async ({
resultId,
typebot,

View File

@ -10,6 +10,7 @@ export const findPublicTypebot = ({ publicId }: Props) =>
select: {
version: true,
groups: true,
events: true,
edges: true,
settings: true,
theme: true,

View File

@ -12,6 +12,7 @@ export const findTypebot = ({ id, userId }: Props) =>
version: true,
id: true,
groups: true,
events: true,
edges: true,
settings: true,
theme: true,

View File

@ -0,0 +1,8 @@
import prisma from '@typebot.io/lib/prisma'
import { VisitedEdge } from '@typebot.io/prisma'
export const saveVisitedEdges = (visitedEdges: VisitedEdge[]) =>
prisma.visitedEdge.createMany({
data: visitedEdges,
skipDuplicates: true,
})

View File

@ -4,18 +4,16 @@ import { InputBlock, SessionState } from '@typebot.io/schemas'
type Props = {
answer: Omit<Prisma.AnswerUncheckedCreateInput, 'resultId'>
block: InputBlock
reply: string
itemId?: string
state: SessionState
}
export const upsertAnswer = async ({ answer, block, state }: Props) => {
export const upsertAnswer = async ({ answer, state }: Props) => {
const resultId = state.typebotsQueue[0].resultId
if (!resultId) return
const where = {
resultId,
blockId: block.id,
groupId: block.groupId,
blockId: answer.blockId,
groupId: answer.groupId,
}
const existingAnswer = await prisma.answer.findUnique({
where: {
@ -28,7 +26,6 @@ export const upsertAnswer = async ({ answer, block, state }: Props) => {
where,
data: {
content: answer.content,
itemId: answer.itemId,
},
})
return prisma.answer.createMany({