🗃️ Remove list types from db schema
This commit is contained in:
@ -54,7 +54,14 @@ export const subscribeWebhookProcedure = authenticatedProcedure
|
|||||||
await prisma.webhook.upsert({
|
await prisma.webhook.upsert({
|
||||||
where: { id: webhookBlock.webhookId },
|
where: { id: webhookBlock.webhookId },
|
||||||
update: { url, body: '{{state}}', method: 'POST' },
|
update: { url, body: '{{state}}', method: 'POST' },
|
||||||
create: { url, body: '{{state}}', method: 'POST', typebotId },
|
create: {
|
||||||
|
url,
|
||||||
|
body: '{{state}}',
|
||||||
|
method: 'POST',
|
||||||
|
typebotId,
|
||||||
|
headers: [],
|
||||||
|
queryParams: [],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -49,6 +49,7 @@ export function CustomAdapter(p: PrismaClient): Adapter {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
onboardingCategories: [],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (process.env.USER_CREATED_WEBHOOK_URL)
|
if (process.env.USER_CREATED_WEBHOOK_URL)
|
||||||
|
@ -2,6 +2,7 @@ import prisma from '@/lib/prisma'
|
|||||||
import { NextApiRequest, NextApiResponse } from 'next'
|
import { NextApiRequest, NextApiResponse } from 'next'
|
||||||
import { getAuthenticatedUser } from '@/features/auth/api'
|
import { getAuthenticatedUser } from '@/features/auth/api'
|
||||||
import { methodNotAllowed, notAuthenticated } from 'utils/api'
|
import { methodNotAllowed, notAuthenticated } from 'utils/api'
|
||||||
|
import { User } from 'db'
|
||||||
|
|
||||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
const user = await getAuthenticatedUser(req)
|
const user = await getAuthenticatedUser(req)
|
||||||
@ -9,10 +10,15 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
|
|
||||||
const id = req.query.userId as string
|
const id = req.query.userId as string
|
||||||
if (req.method === 'PUT') {
|
if (req.method === 'PUT') {
|
||||||
const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body
|
const data = (
|
||||||
|
typeof req.body === 'string' ? JSON.parse(req.body) : req.body
|
||||||
|
) as User
|
||||||
const typebots = await prisma.user.update({
|
const typebots = await prisma.user.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data,
|
data: {
|
||||||
|
...data,
|
||||||
|
onboardingCategories: data.onboardingCategories ?? [],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
return res.send({ typebots })
|
return res.send({ typebots })
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
await prisma.webhook.upsert({
|
await prisma.webhook.upsert({
|
||||||
where: { id: webhookId },
|
where: { id: webhookId },
|
||||||
update: { url, body: '{{state}}', method: 'POST' },
|
update: { url, body: '{{state}}', method: 'POST' },
|
||||||
create: { url, body: '{{state}}', method: 'POST', typebotId },
|
create: {
|
||||||
|
url,
|
||||||
|
body: '{{state}}',
|
||||||
|
method: 'POST',
|
||||||
|
typebotId,
|
||||||
|
headers: [],
|
||||||
|
queryParams: [],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return res.send({ message: 'success' })
|
return res.send({ message: 'success' })
|
||||||
|
@ -29,7 +29,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
await prisma.webhook.upsert({
|
await prisma.webhook.upsert({
|
||||||
where: { id: webhookId },
|
where: { id: webhookId },
|
||||||
update: { url, body: '{{state}}', method: 'POST' },
|
update: { url, body: '{{state}}', method: 'POST' },
|
||||||
create: { url, body: '{{state}}', method: 'POST', typebotId },
|
create: {
|
||||||
|
url,
|
||||||
|
body: '{{state}}',
|
||||||
|
method: 'POST',
|
||||||
|
typebotId,
|
||||||
|
headers: [],
|
||||||
|
queryParams: [],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return res.send({ message: 'success' })
|
return res.send({ message: 'success' })
|
||||||
|
@ -32,6 +32,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
data: {
|
data: {
|
||||||
typebotId,
|
typebotId,
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
|
variables: [],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
res.send({ result })
|
res.send({ result })
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
ALTER TABLE
|
||||||
|
"PublicTypebot"
|
||||||
|
ALTER COLUMN
|
||||||
|
variables TYPE JSONB USING array_to_json(variables);
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
"Result"
|
||||||
|
ALTER COLUMN
|
||||||
|
variables TYPE JSONB USING array_to_json(variables);
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
"Typebot"
|
||||||
|
ALTER COLUMN
|
||||||
|
variables TYPE JSONB USING array_to_json(variables);
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
"User"
|
||||||
|
ALTER COLUMN
|
||||||
|
"onboardingCategories" TYPE JSONB USING array_to_json("onboardingCategories");
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
"Webhook"
|
||||||
|
ALTER COLUMN
|
||||||
|
"queryParams" TYPE JSONB USING array_to_json("queryParams"),
|
||||||
|
ALTER COLUMN
|
||||||
|
"headers" TYPE JSONB USING array_to_json("headers");
|
@ -46,9 +46,9 @@ model User {
|
|||||||
emailVerified DateTime?
|
emailVerified DateTime?
|
||||||
image String?
|
image String?
|
||||||
company String?
|
company String?
|
||||||
onboardingCategories String[]
|
onboardingCategories Json
|
||||||
graphNavigation GraphNavigation?
|
graphNavigation GraphNavigation?
|
||||||
preferredAppAppearance String?
|
preferredAppAppearance String?
|
||||||
accounts Account[]
|
accounts Account[]
|
||||||
apiTokens ApiToken[]
|
apiTokens ApiToken[]
|
||||||
CollaboratorsOnTypebots CollaboratorsOnTypebots[]
|
CollaboratorsOnTypebots CollaboratorsOnTypebots[]
|
||||||
@ -157,7 +157,7 @@ model Typebot {
|
|||||||
name String
|
name String
|
||||||
folderId String?
|
folderId String?
|
||||||
groups Json
|
groups Json
|
||||||
variables Json[]
|
variables Json
|
||||||
edges Json
|
edges Json
|
||||||
theme Json
|
theme Json
|
||||||
settings Json
|
settings Json
|
||||||
@ -204,7 +204,7 @@ model PublicTypebot {
|
|||||||
updatedAt DateTime @default(now()) @updatedAt
|
updatedAt DateTime @default(now()) @updatedAt
|
||||||
typebotId String @unique
|
typebotId String @unique
|
||||||
groups Json
|
groups Json
|
||||||
variables Json[]
|
variables Json
|
||||||
edges Json
|
edges Json
|
||||||
theme Json
|
theme Json
|
||||||
settings Json
|
settings Json
|
||||||
@ -216,7 +216,7 @@ model Result {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @default(now()) @updatedAt
|
updatedAt DateTime @default(now()) @updatedAt
|
||||||
typebotId String
|
typebotId String
|
||||||
variables Json[]
|
variables Json
|
||||||
isCompleted Boolean
|
isCompleted Boolean
|
||||||
hasStarted Boolean?
|
hasStarted Boolean?
|
||||||
isArchived Boolean? @default(false)
|
isArchived Boolean? @default(false)
|
||||||
@ -266,8 +266,8 @@ model Webhook {
|
|||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
url String?
|
url String?
|
||||||
method String
|
method String
|
||||||
queryParams Json[]
|
queryParams Json
|
||||||
headers Json[]
|
headers Json
|
||||||
body String?
|
body String?
|
||||||
typebotId String
|
typebotId String
|
||||||
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
|
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
|
||||||
|
@ -41,7 +41,8 @@ export const injectFakeResults = async ({
|
|||||||
: new Date(),
|
: new Date(),
|
||||||
isCompleted: rand > 0.5,
|
isCompleted: rand > 0.5,
|
||||||
hasStarted: true,
|
hasStarted: true,
|
||||||
}
|
variables: [],
|
||||||
|
} satisfies Prisma.ResultCreateManyInput
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@ -135,7 +136,10 @@ export const createWorkspaces = async (workspaces: Partial<Workspace>[]) => {
|
|||||||
|
|
||||||
export const updateUser = (data: Partial<User>) =>
|
export const updateUser = (data: Partial<User>) =>
|
||||||
prisma.user.update({
|
prisma.user.update({
|
||||||
data,
|
data: {
|
||||||
|
...data,
|
||||||
|
onboardingCategories: data.onboardingCategories ?? [],
|
||||||
|
},
|
||||||
where: {
|
where: {
|
||||||
id: userId,
|
id: userId,
|
||||||
},
|
},
|
||||||
@ -149,7 +153,14 @@ export const createWebhook = async (
|
|||||||
await prisma.webhook.delete({ where: { id: 'webhook1' } })
|
await prisma.webhook.delete({ where: { id: 'webhook1' } })
|
||||||
} catch {}
|
} catch {}
|
||||||
return prisma.webhook.create({
|
return prisma.webhook.create({
|
||||||
data: { method: 'GET', typebotId, id: 'webhook1', ...webhookProps },
|
data: {
|
||||||
|
method: 'GET',
|
||||||
|
typebotId,
|
||||||
|
id: 'webhook1',
|
||||||
|
...webhookProps,
|
||||||
|
queryParams: webhookProps?.queryParams ?? [],
|
||||||
|
headers: webhookProps?.headers ?? [],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ export const setupUsers = async () => {
|
|||||||
email: 'user@email.com',
|
email: 'user@email.com',
|
||||||
name: 'John Doe',
|
name: 'John Doe',
|
||||||
graphNavigation: GraphNavigation.TRACKPAD,
|
graphNavigation: GraphNavigation.TRACKPAD,
|
||||||
|
onboardingCategories: [],
|
||||||
apiTokens: {
|
apiTokens: {
|
||||||
createMany: {
|
createMany: {
|
||||||
data: [
|
data: [
|
||||||
@ -82,7 +83,12 @@ export const setupUsers = async () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await prisma.user.create({
|
await prisma.user.create({
|
||||||
data: { id: otherUserId, email: 'other-user@email.com', name: 'James Doe' },
|
data: {
|
||||||
|
id: otherUserId,
|
||||||
|
email: 'other-user@email.com',
|
||||||
|
name: 'James Doe',
|
||||||
|
onboardingCategories: [],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
return prisma.memberInWorkspace.createMany({
|
return prisma.memberInWorkspace.createMany({
|
||||||
data: [
|
data: [
|
||||||
|
Reference in New Issue
Block a user