81 lines
2.5 KiB
Plaintext
81 lines
2.5 KiB
Plaintext
// VA-P28c: provider-neutral connections for HiveGrid's own admin sales workspace.
|
|
//
|
|
// These rows are tenant-less and belong to one active AdminUser. Credentials
|
|
// use a dedicated platform envelope key and never reuse a Tenant DEK or the
|
|
// legacy CRYPTO_SECRET contract.
|
|
|
|
enum AdminConnectionProvider {
|
|
google_mail
|
|
microsoft_mail
|
|
aircall
|
|
google_calendar
|
|
microsoft_calendar
|
|
slack
|
|
linkedin
|
|
meeting_webhook
|
|
}
|
|
|
|
enum AdminConnectionCapability {
|
|
email
|
|
telephony
|
|
calendar
|
|
team_chat
|
|
professional_network
|
|
meeting_artifact
|
|
}
|
|
|
|
enum AdminConnectionStatus {
|
|
pending
|
|
active
|
|
degraded
|
|
revoked
|
|
}
|
|
|
|
model AdminDataConnection {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
adminUserId String
|
|
provider AdminConnectionProvider
|
|
capability AdminConnectionCapability
|
|
label String
|
|
externalAccountId String?
|
|
externalAccountEmail String?
|
|
status AdminConnectionStatus @default(pending)
|
|
scopes String[] @default([])
|
|
tokenExpiresAt DateTime?
|
|
lastHealthCheckAt DateTime?
|
|
healthMessageKey String?
|
|
webhookRegistrationId String?
|
|
revokedAt DateTime?
|
|
archivedAt DateTime?
|
|
|
|
adminUser AdminUser @relation(fields: [adminUserId], references: [id], onDelete: Restrict)
|
|
credential AdminConnectionCredential?
|
|
mailboxes AdminMailbox[]
|
|
phoneConnection AdminPhoneConnection?
|
|
calendarConnection AdminCalendarConnection?
|
|
|
|
@@unique([adminUserId, provider, externalAccountId], name: "admin_data_connection_account_key")
|
|
@@index([adminUserId, capability, archivedAt], name: "admin_data_connection_owner_capability_idx")
|
|
@@index([provider, status, tokenExpiresAt], name: "admin_data_connection_refresh_idx")
|
|
}
|
|
|
|
model AdminConnectionCredential {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
connectionId String @unique
|
|
adminUserId String
|
|
wrappedDek Bytes
|
|
ciphertext String
|
|
keyVersion Int @default(1)
|
|
rotatedAt DateTime?
|
|
revokedAt DateTime?
|
|
|
|
connection AdminDataConnection @relation(fields: [connectionId], references: [id], onDelete: Cascade)
|
|
adminUser AdminUser @relation(fields: [adminUserId], references: [id], onDelete: Restrict)
|
|
|
|
@@index([adminUserId, revokedAt], name: "admin_connection_credential_owner_revoked_idx")
|
|
}
|