⚗️ Implement chat API
This commit is contained in:
@ -20,9 +20,7 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"aws-sdk": "2.1152.0",
|
||||
"db": "workspace:*",
|
||||
"models": "workspace:*",
|
||||
"next": "12.0.0",
|
||||
"next": "13.0.0",
|
||||
"nodemailer": "6.7.8"
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ export const importTypebotInDatabase = async (
|
||||
...updates,
|
||||
}
|
||||
await prisma.typebot.create({
|
||||
data: typebot,
|
||||
data: parseCreateTypebot(typebot),
|
||||
})
|
||||
return prisma.publicTypebot.create({
|
||||
data: parseTypebotToPublicTypebot(
|
||||
@ -163,7 +163,7 @@ export const createTypebots = async (partialTypebots: Partial<Typebot>[]) => {
|
||||
}
|
||||
})
|
||||
await prisma.typebot.createMany({
|
||||
data: typebotsWithId.map(parseTestTypebot),
|
||||
data: typebotsWithId.map(parseTestTypebot).map(parseCreateTypebot),
|
||||
})
|
||||
return prisma.publicTypebot.createMany({
|
||||
data: typebotsWithId.map((t) =>
|
||||
@ -177,7 +177,7 @@ export const updateTypebot = async (
|
||||
) => {
|
||||
await prisma.typebot.updateMany({
|
||||
where: { id: partialTypebot.id },
|
||||
data: partialTypebot,
|
||||
data: parseUpdateTypebot(partialTypebot),
|
||||
})
|
||||
return prisma.publicTypebot.updateMany({
|
||||
where: { typebotId: partialTypebot.id },
|
||||
@ -194,3 +194,19 @@ export const updateWorkspace = async (
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
const parseCreateTypebot = (typebot: Typebot) => ({
|
||||
...typebot,
|
||||
resultsTablePreferences:
|
||||
typebot.resultsTablePreferences === null
|
||||
? Prisma.DbNull
|
||||
: typebot.resultsTablePreferences,
|
||||
})
|
||||
|
||||
const parseUpdateTypebot = (typebot: Partial<Typebot>) => ({
|
||||
...typebot,
|
||||
resultsTablePreferences:
|
||||
typebot.resultsTablePreferences === null
|
||||
? Prisma.DbNull
|
||||
: typebot.resultsTablePreferences,
|
||||
})
|
||||
|
@ -22,13 +22,14 @@ export const parseTestTypebot = (
|
||||
theme: defaultTheme,
|
||||
settings: defaultSettings,
|
||||
publicId: null,
|
||||
updatedAt: new Date().toISOString(),
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date(),
|
||||
createdAt: new Date(),
|
||||
publishedTypebotId: null,
|
||||
customDomain: null,
|
||||
icon: null,
|
||||
isArchived: false,
|
||||
isClosed: false,
|
||||
resultsTablePreferences: null,
|
||||
variables: [{ id: 'var1', name: 'var1' }],
|
||||
...partialTypebot,
|
||||
edges: [
|
||||
|
Reference in New Issue
Block a user