mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
feat: add teams (#848)
## Description Add support for teams which will allow users to collaborate on documents. Teams features allows users to: - Create, manage and transfer teams - Manage team members - Manage team emails - Manage a shared team inbox and documents These changes do NOT include the following, which are planned for a future release: - Team templates - Team API - Search menu integration ## Testing Performed - Added E2E tests for general team management - Added E2E tests to validate document counts ## Checklist - [X] I have tested these changes locally and they work as expected. - [X] I have added/updated tests that prove the effectiveness of these changes. - [ ] I have updated the documentation to reflect these changes, if applicable. - [X] I have followed the project's coding style guidelines.
This commit is contained in:
@ -37,6 +37,9 @@ model User {
|
||||
Document Document[]
|
||||
Subscription Subscription[]
|
||||
PasswordResetToken PasswordResetToken[]
|
||||
ownedTeams Team[]
|
||||
ownedPendingTeams TeamPending[]
|
||||
teamMembers TeamMember[]
|
||||
twoFactorSecret String?
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
twoFactorBackupCodes String?
|
||||
@ -103,12 +106,14 @@ model Subscription {
|
||||
planId String @unique
|
||||
priceId String
|
||||
periodEnd DateTime?
|
||||
userId Int
|
||||
userId Int?
|
||||
teamId Int? @unique
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
cancelAtPeriodEnd Boolean @default(false)
|
||||
|
||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
team Team? @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
User User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
@ -162,6 +167,8 @@ model Document {
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
completedAt DateTime?
|
||||
deletedAt DateTime?
|
||||
teamId Int?
|
||||
team Team? @relation(fields: [teamId], references: [id])
|
||||
|
||||
@@unique([documentDataId])
|
||||
@@index([userId])
|
||||
@ -300,6 +307,104 @@ model DocumentShareLink {
|
||||
@@unique([documentId, email])
|
||||
}
|
||||
|
||||
enum TeamMemberRole {
|
||||
ADMIN
|
||||
MANAGER
|
||||
MEMBER
|
||||
}
|
||||
|
||||
enum TeamMemberInviteStatus {
|
||||
ACCEPTED
|
||||
PENDING
|
||||
}
|
||||
|
||||
model Team {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
url String @unique
|
||||
createdAt DateTime @default(now())
|
||||
customerId String? @unique
|
||||
ownerUserId Int
|
||||
members TeamMember[]
|
||||
invites TeamMemberInvite[]
|
||||
teamEmail TeamEmail?
|
||||
emailVerification TeamEmailVerification?
|
||||
transferVerification TeamTransferVerification?
|
||||
|
||||
owner User @relation(fields: [ownerUserId], references: [id])
|
||||
subscription Subscription?
|
||||
|
||||
document Document[]
|
||||
}
|
||||
|
||||
model TeamPending {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
url String @unique
|
||||
createdAt DateTime @default(now())
|
||||
customerId String @unique
|
||||
ownerUserId Int
|
||||
|
||||
owner User @relation(fields: [ownerUserId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TeamMember {
|
||||
id Int @id @default(autoincrement())
|
||||
teamId Int
|
||||
createdAt DateTime @default(now())
|
||||
role TeamMemberRole
|
||||
userId Int
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([userId, teamId])
|
||||
}
|
||||
|
||||
model TeamEmail {
|
||||
teamId Int @id @unique
|
||||
createdAt DateTime @default(now())
|
||||
name String
|
||||
email String @unique
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TeamEmailVerification {
|
||||
teamId Int @id @unique
|
||||
name String
|
||||
email String
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TeamTransferVerification {
|
||||
teamId Int @id @unique
|
||||
userId Int
|
||||
name String
|
||||
email String
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
clearPaymentMethods Boolean @default(false)
|
||||
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TeamMemberInvite {
|
||||
id Int @id @default(autoincrement())
|
||||
teamId Int
|
||||
createdAt DateTime @default(now())
|
||||
email String
|
||||
status TeamMemberInviteStatus @default(PENDING)
|
||||
role TeamMemberRole
|
||||
token String @unique
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([teamId, email])
|
||||
}
|
||||
|
||||
enum TemplateType {
|
||||
PUBLIC
|
||||
PRIVATE
|
||||
|
||||
Reference in New Issue
Block a user