@juliobrim/prisma-shared 1.0.54 → 1.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/schema.prisma +80 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juliobrim/prisma-shared",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
4
4
  "description": "Schema Prisma compartilhado entre projetos Sabcon",
5
5
  "main": "schema.prisma",
6
6
  "files": [
package/schema.prisma CHANGED
@@ -63,6 +63,8 @@ model Tenant {
63
63
  operatorAvailability OperatorAvailabilityCache[]
64
64
  qualityRegisters QualityRegister[]
65
65
  qualityIssues QualityIssue[]
66
+ supportConversations SupportConversation[]
67
+ supportMessages SupportMessage[]
66
68
 
67
69
  @@map("tenant")
68
70
  }
@@ -812,22 +814,25 @@ model TwoFactorToken {
812
814
  }
813
815
 
814
816
  model User {
815
- id String @id @default(uuid())
816
- name String
817
- email String
818
- emailVerified DateTime?
819
- image String?
820
- password String
821
- isTwoFactorEnabled Boolean @default(false)
822
- roleId String?
823
- role Role? @relation(fields: [roleId], references: [id])
824
- tenantId String
825
- accounts Account[]
826
- follows Follower[]
827
- NotificationToUser NotificationToUser[]
828
- Panel Panel[]
829
- twoFactorConfirmation TwoFactorConfirmation?
830
- tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
817
+ id String @id @default(uuid())
818
+ name String
819
+ email String
820
+ emailVerified DateTime?
821
+ image String?
822
+ password String
823
+ isTwoFactorEnabled Boolean @default(false)
824
+ roleId String?
825
+ role Role? @relation(fields: [roleId], references: [id])
826
+ tenantId String
827
+ accounts Account[]
828
+ follows Follower[]
829
+ NotificationToUser NotificationToUser[]
830
+ Panel Panel[]
831
+ twoFactorConfirmation TwoFactorConfirmation?
832
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
833
+ supportConversationsAsCustomer SupportConversation[] @relation("SupportConversationCustomer")
834
+ supportConversationsAsAssignee SupportConversation[] @relation("SupportConversationAssignee")
835
+ supportMessagesSent SupportMessage[] @relation("SupportMessageSender")
831
836
 
832
837
  @@unique([tenantId, email])
833
838
  @@map("user")
@@ -1174,3 +1179,62 @@ model OperatorAvailabilityCache {
1174
1179
  @@index([shiftId, date])
1175
1180
  @@map("operator_availability_cache")
1176
1181
  }
1182
+
1183
+ // chat
1184
+
1185
+ enum SupportConversationStatus {
1186
+ OPEN
1187
+ CLOSED
1188
+ }
1189
+
1190
+ enum SupportMessageSenderType {
1191
+ USER
1192
+ SUPPORT
1193
+ }
1194
+
1195
+ model SupportConversation {
1196
+ id String @id @default(uuid())
1197
+ tenantId String
1198
+ userId String
1199
+ assignedSupportUserId String?
1200
+ status SupportConversationStatus @default(OPEN)
1201
+ lastMessageAt DateTime @default(now())
1202
+ lastMessagePreview String? @db.VarChar(180)
1203
+ unreadForUserCount Int @default(0)
1204
+ unreadForSupportCount Int @default(0)
1205
+ createdAt DateTime @default(now())
1206
+ updatedAt DateTime @updatedAt
1207
+
1208
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1209
+ user User @relation("SupportConversationCustomer", fields: [userId], references: [id], onDelete: Cascade)
1210
+ assignedSupportUser User? @relation("SupportConversationAssignee", fields: [assignedSupportUserId], references: [id], onDelete: SetNull)
1211
+ messages SupportMessage[]
1212
+
1213
+ @@unique([tenantId, userId])
1214
+ @@index([tenantId, status, lastMessageAt])
1215
+ @@index([tenantId, unreadForSupportCount, lastMessageAt])
1216
+ @@map("support_conversation")
1217
+ }
1218
+
1219
+ model SupportMessage {
1220
+ id String @id @default(uuid())
1221
+ conversationId String
1222
+ tenantId String
1223
+ senderType SupportMessageSenderType
1224
+ senderUserId String?
1225
+ body String? @db.Text
1226
+ attachmentUrl String? @db.Text
1227
+ attachmentName String? @db.VarChar(255)
1228
+ attachmentMimeType String? @db.VarChar(120)
1229
+ attachmentSize Int?
1230
+ readAt DateTime?
1231
+ createdAt DateTime @default(now())
1232
+
1233
+ conversation SupportConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
1234
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1235
+ senderUser User? @relation("SupportMessageSender", fields: [senderUserId], references: [id], onDelete: SetNull)
1236
+
1237
+ @@index([conversationId, createdAt])
1238
+ @@index([tenantId, createdAt])
1239
+ @@map("support_message")
1240
+ }