2
0

feat(editor): Team workspaces

This commit is contained in:
Baptiste Arnaud
2022-05-13 15:22:44 -07:00
parent 6c2986590b
commit f0fdf08b00
132 changed files with 3354 additions and 1228 deletions

View File

@ -50,7 +50,7 @@ model User {
sessions Session[]
typebots Typebot[]
folders DashboardFolder[]
plan Plan @default(FREE)
plan Plan? @default(FREE)
stripeId String? @unique
credentials Credentials[]
customDomains CustomDomain[]
@ -59,6 +59,47 @@ model User {
company String?
onboardingCategories String[]
graphNavigation GraphNavigation?
workspaces MemberInWorkspace[]
}
model Workspace {
id String @id @default(cuid())
name String
icon String?
members MemberInWorkspace[]
folders DashboardFolder[]
typebots Typebot[]
createdAt DateTime @default(now())
plan Plan @default(FREE)
stripeId String? @unique
customDomains CustomDomain[]
credentials Credentials[]
invitations WorkspaceInvitation[]
}
model MemberInWorkspace {
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
workspaceId String
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
role WorkspaceRole
@@unique([userId, workspaceId])
}
enum WorkspaceRole {
ADMIN
MEMBER
GUEST
}
model WorkspaceInvitation {
id String @id @default(cuid())
createdAt DateTime @default(now())
email String
workspaceId String
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
type WorkspaceRole
}
enum GraphNavigation {
@ -67,21 +108,25 @@ enum GraphNavigation {
}
model CustomDomain {
name String @id
createdAt DateTime @default(now())
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
name String @id
createdAt DateTime @default(now())
ownerId String?
owner User? @relation(fields: [ownerId], references: [id], onDelete: Cascade)
workspaceId String?
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
}
model Credentials {
id String @id @default(cuid())
createdAt DateTime @default(now())
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
data String // Encrypted data
name String
type String
iv String
id String @id @default(cuid())
createdAt DateTime @default(now())
ownerId String?
owner User? @relation(fields: [ownerId], references: [id], onDelete: Cascade)
workspaceId String?
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
data String // Encrypted data
name String
type String
iv String
@@unique([name, type, ownerId])
}
@ -89,6 +134,7 @@ model Credentials {
enum Plan {
FREE
PRO
TEAM
LIFETIME
OFFERED
}
@ -106,12 +152,14 @@ model DashboardFolder {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
name String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
owner User? @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String?
parentFolderId String?
parentFolder DashboardFolder? @relation("ParentChild", fields: [parentFolderId], references: [id])
childrenFolder DashboardFolder[] @relation("ParentChild")
typebots Typebot[]
workspaceId String?
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
@@unique([id, ownerId])
}
@ -122,8 +170,8 @@ model Typebot {
updatedAt DateTime @default(now()) @updatedAt
icon String?
name String
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String?
owner User? @relation(fields: [ownerId], references: [id], onDelete: Cascade)
publishedTypebotId String?
publishedTypebot PublicTypebot?
results Result[]
@ -139,6 +187,8 @@ model Typebot {
collaborators CollaboratorsOnTypebots[]
invitations Invitation[]
webhooks Webhook[]
workspaceId String?
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
@@unique([id, ownerId])
}
@ -166,6 +216,7 @@ model CollaboratorsOnTypebots {
enum CollaborationType {
READ
WRITE
FULL_ACCESS
}
model PublicTypebot {