@danielcok17/prisma-db 1.5.0 → 1.7.0
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.
- package/package.json +1 -1
- package/prisma/app.prisma +78 -14
- package/prisma/generated/app/edge.js +42 -6
- package/prisma/generated/app/index-browser.js +38 -3
- package/prisma/generated/app/index.d.ts +7905 -2678
- package/prisma/generated/app/index.js +42 -6
- package/prisma/generated/app/package.json +1 -1
- package/prisma/generated/app/schema.prisma +128 -64
- package/prisma/generated/app/wasm.js +42 -6
- package/prisma/migrations/20260110200252_add_canvas_documents/migration.sql +80 -0
- package/prisma/migrations/20260113150746_add_admin_grant_expiration/migration.sql +5 -0
|
@@ -29,47 +29,50 @@ model Account {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
model User {
|
|
32
|
-
id
|
|
33
|
-
name
|
|
34
|
-
email
|
|
35
|
-
emailVerified
|
|
36
|
-
image
|
|
32
|
+
id String @id @default(cuid())
|
|
33
|
+
name String?
|
|
34
|
+
email String? @unique
|
|
35
|
+
emailVerified DateTime?
|
|
36
|
+
image String?
|
|
37
37
|
// Credentials authentication fields
|
|
38
|
-
password
|
|
39
|
-
createdAt
|
|
40
|
-
agreedToTerms
|
|
41
|
-
practiceArea
|
|
42
|
-
lawFirm
|
|
43
|
-
yearsOfExperience
|
|
38
|
+
password String? // Hashed password pre credentials login
|
|
39
|
+
createdAt DateTime @default(now())
|
|
40
|
+
agreedToTerms Boolean @default(false)
|
|
41
|
+
practiceArea String[]
|
|
42
|
+
lawFirm String?
|
|
43
|
+
yearsOfExperience Int?
|
|
44
44
|
// Nové polia pre schvalovanie používateľov
|
|
45
|
-
isApproved
|
|
46
|
-
isRejected
|
|
47
|
-
approvedAt
|
|
48
|
-
rejectedAt
|
|
49
|
-
approvedBy
|
|
50
|
-
rejectedBy
|
|
51
|
-
rejectionReason
|
|
45
|
+
isApproved Boolean @default(false) // Či je používateľ schválený
|
|
46
|
+
isRejected Boolean @default(false) // Či je používateľ zamietnutý
|
|
47
|
+
approvedAt DateTime? // Kedy bol schválený
|
|
48
|
+
rejectedAt DateTime? // Kedy bol zamietnutý
|
|
49
|
+
approvedBy String? // ID admina, ktorý schválil
|
|
50
|
+
rejectedBy String? // ID admina, ktorý zamietol
|
|
51
|
+
rejectionReason String? // Dôvod zamietnutia
|
|
52
52
|
// Nové polia pre tracking a žiadosť
|
|
53
|
-
referralSource
|
|
54
|
-
applicationText
|
|
53
|
+
referralSource String? // Odkiaľ sa o nás dozvedel (Google, Facebook, LinkedIn, etc.)
|
|
54
|
+
applicationText String? // Text žiadosti o prihlásenie
|
|
55
55
|
// ✨ STRIPE FIELDS (B2C - len pre individuálnych používateľov)
|
|
56
|
-
subscriptionTier
|
|
57
|
-
messageCount
|
|
58
|
-
messageCountResetAt
|
|
56
|
+
subscriptionTier SubscriptionTier @default(FREE) // Aktuálny subscription tier (cache)
|
|
57
|
+
messageCount Int @default(10) // ✅ OPRAVENÉ z 100 na 10
|
|
58
|
+
messageCountResetAt DateTime? // Kedy sa má resetovať message count
|
|
59
|
+
adminGrantExpiresAt DateTime? // Kedy admin grant expiruje
|
|
59
60
|
// Relations
|
|
60
|
-
approvalRequest
|
|
61
|
-
stripeCustomer
|
|
62
|
-
ownedOrganizations
|
|
63
|
-
organizationMembers
|
|
64
|
-
accounts
|
|
65
|
-
answers
|
|
66
|
-
conversations
|
|
67
|
-
feedbacks
|
|
68
|
-
pageViews
|
|
69
|
-
sessions
|
|
70
|
-
workflowLogs
|
|
71
|
-
verificationTokens
|
|
72
|
-
passwordResetTokens
|
|
61
|
+
approvalRequest UserApprovalRequest?
|
|
62
|
+
stripeCustomer StripeCustomer? // ✨ B2C Stripe customer
|
|
63
|
+
ownedOrganizations Organization[] @relation("OrganizationOwner")
|
|
64
|
+
organizationMembers OrganizationMember[]
|
|
65
|
+
accounts Account[]
|
|
66
|
+
answers Answer[]
|
|
67
|
+
conversations Conversation[]
|
|
68
|
+
feedbacks Feedback[]
|
|
69
|
+
pageViews PageView[]
|
|
70
|
+
sessions Session[]
|
|
71
|
+
workflowLogs WorkflowLog[]
|
|
72
|
+
verificationTokens VerificationToken[]
|
|
73
|
+
passwordResetTokens PasswordResetToken[]
|
|
74
|
+
canvasDocuments CanvasDocument[]
|
|
75
|
+
canvasDocumentVersions CanvasDocumentVersion[]
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
// Nový model pre žiadosti o schválenie
|
|
@@ -115,6 +118,7 @@ model Organization {
|
|
|
115
118
|
messageCount Int @default(0) // Spoločný pool správ pre všetkých členov
|
|
116
119
|
messageLimit Int @default(100) // Limit správ podľa tieru
|
|
117
120
|
messageCountResetAt DateTime? // Kedy sa má resetovať pool
|
|
121
|
+
adminGrantExpiresAt DateTime? // Kedy admin grant expiruje
|
|
118
122
|
|
|
119
123
|
// Settings
|
|
120
124
|
isActive Boolean @default(true)
|
|
@@ -161,20 +165,21 @@ enum MemberRole {
|
|
|
161
165
|
|
|
162
166
|
// ZJEDNODUŠENÝ Conversation - len metadata, bez duplikátov
|
|
163
167
|
model Conversation {
|
|
164
|
-
id String
|
|
168
|
+
id String @id @default(cuid())
|
|
165
169
|
name String
|
|
166
170
|
userId String
|
|
167
|
-
isShareable Boolean
|
|
168
|
-
shareUrl String?
|
|
171
|
+
isShareable Boolean @default(false)
|
|
172
|
+
shareUrl String? @unique
|
|
169
173
|
sharedAt DateTime?
|
|
170
|
-
createdAt DateTime
|
|
171
|
-
updatedAt DateTime
|
|
174
|
+
createdAt DateTime @default(now())
|
|
175
|
+
updatedAt DateTime @updatedAt
|
|
172
176
|
summary String?
|
|
173
|
-
messagesSinceLastSummary Int?
|
|
177
|
+
messagesSinceLastSummary Int? @default(0)
|
|
174
178
|
// Relácie
|
|
175
179
|
answers Answer[]
|
|
176
|
-
user User
|
|
180
|
+
user User @relation(fields: [userId], references: [id])
|
|
177
181
|
workflowLogs WorkflowLog[]
|
|
182
|
+
canvasDocuments CanvasDocument[]
|
|
178
183
|
|
|
179
184
|
@@index([userId])
|
|
180
185
|
@@index([createdAt])
|
|
@@ -182,28 +187,29 @@ model Conversation {
|
|
|
182
187
|
|
|
183
188
|
// Hlavný model - všetky správy, bez duplikátov
|
|
184
189
|
model Answer {
|
|
185
|
-
id
|
|
186
|
-
conversationId
|
|
187
|
-
messageId
|
|
188
|
-
role
|
|
189
|
-
content
|
|
190
|
-
question
|
|
191
|
-
answer
|
|
192
|
-
evaluation
|
|
193
|
-
isWelcome
|
|
194
|
-
processingTime
|
|
195
|
-
model
|
|
196
|
-
userId
|
|
197
|
-
createdAt
|
|
198
|
-
updatedAt
|
|
190
|
+
id String @id @default(cuid())
|
|
191
|
+
conversationId String
|
|
192
|
+
messageId String @unique
|
|
193
|
+
role Role
|
|
194
|
+
content String
|
|
195
|
+
question String?
|
|
196
|
+
answer String?
|
|
197
|
+
evaluation String?
|
|
198
|
+
isWelcome Boolean @default(false)
|
|
199
|
+
processingTime Int?
|
|
200
|
+
model String?
|
|
201
|
+
userId String?
|
|
202
|
+
createdAt DateTime @default(now())
|
|
203
|
+
updatedAt DateTime @updatedAt
|
|
199
204
|
// Relácie
|
|
200
|
-
conversation
|
|
201
|
-
user
|
|
202
|
-
feedback
|
|
203
|
-
references
|
|
204
|
-
metrics
|
|
205
|
-
WorkflowLog
|
|
206
|
-
files
|
|
205
|
+
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
206
|
+
user User? @relation(fields: [userId], references: [id])
|
|
207
|
+
feedback Feedback?
|
|
208
|
+
references Reference[]
|
|
209
|
+
metrics AnswerMetrics?
|
|
210
|
+
WorkflowLog WorkflowLog[]
|
|
211
|
+
files MessageFile[]
|
|
212
|
+
canvasDocumentId String? // No FK constraint - flexible document management
|
|
207
213
|
|
|
208
214
|
@@index([conversationId])
|
|
209
215
|
@@index([messageId])
|
|
@@ -529,6 +535,13 @@ enum BillingInterval {
|
|
|
529
535
|
YEARLY // Yearly billing (17% discount)
|
|
530
536
|
}
|
|
531
537
|
|
|
538
|
+
// Canvas Document Status
|
|
539
|
+
enum DocumentStatus {
|
|
540
|
+
DRAFT
|
|
541
|
+
SAVED
|
|
542
|
+
ARCHIVED
|
|
543
|
+
}
|
|
544
|
+
|
|
532
545
|
// Nový model pre logovanie admin akcií
|
|
533
546
|
model AdminActionLog {
|
|
534
547
|
id String @id @default(cuid())
|
|
@@ -644,3 +657,54 @@ model PasswordResetToken {
|
|
|
644
657
|
@@index([userId])
|
|
645
658
|
@@index([expires])
|
|
646
659
|
}
|
|
660
|
+
|
|
661
|
+
// ============================================
|
|
662
|
+
// CANVAS DOCUMENT MODELS
|
|
663
|
+
// ============================================
|
|
664
|
+
|
|
665
|
+
model CanvasDocument {
|
|
666
|
+
id String @id @default(cuid())
|
|
667
|
+
userId String
|
|
668
|
+
title String
|
|
669
|
+
status DocumentStatus @default(DRAFT)
|
|
670
|
+
createdAt DateTime @default(now())
|
|
671
|
+
updatedAt DateTime @updatedAt
|
|
672
|
+
originConversationId String?
|
|
673
|
+
originAnswerId String? // No FK constraint - async save reference
|
|
674
|
+
currentVersionId String? @unique
|
|
675
|
+
|
|
676
|
+
// Relations
|
|
677
|
+
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
678
|
+
originConversation Conversation? @relation(fields: [originConversationId], references: [id], onDelete: SetNull)
|
|
679
|
+
currentVersion CanvasDocumentVersion? @relation("CurrentVersion", fields: [currentVersionId], references: [id], onDelete: SetNull)
|
|
680
|
+
versions CanvasDocumentVersion[] @relation("DocumentVersions")
|
|
681
|
+
|
|
682
|
+
@@index([userId])
|
|
683
|
+
@@index([originConversationId])
|
|
684
|
+
@@index([status])
|
|
685
|
+
@@index([createdAt])
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
model CanvasDocumentVersion {
|
|
689
|
+
id String @id @default(cuid())
|
|
690
|
+
documentId String
|
|
691
|
+
versionNumber Int
|
|
692
|
+
title String
|
|
693
|
+
markdownContent String
|
|
694
|
+
createdAt DateTime @default(now())
|
|
695
|
+
createdBy String
|
|
696
|
+
regenerationPrompt String?
|
|
697
|
+
parentVersionId String?
|
|
698
|
+
|
|
699
|
+
// Relations
|
|
700
|
+
document CanvasDocument @relation("DocumentVersions", fields: [documentId], references: [id], onDelete: Cascade)
|
|
701
|
+
creator User @relation(fields: [createdBy], references: [id], onDelete: Restrict)
|
|
702
|
+
parentVersion CanvasDocumentVersion? @relation("VersionHistory", fields: [parentVersionId], references: [id], onDelete: SetNull)
|
|
703
|
+
childVersions CanvasDocumentVersion[] @relation("VersionHistory")
|
|
704
|
+
currentForDocument CanvasDocument? @relation("CurrentVersion")
|
|
705
|
+
|
|
706
|
+
@@unique([documentId, versionNumber])
|
|
707
|
+
@@index([documentId])
|
|
708
|
+
@@index([createdBy])
|
|
709
|
+
@@index([createdAt])
|
|
710
|
+
}
|