@danielcok17/prisma-db 1.4.0 → 1.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielcok17/prisma-db",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Shared Prisma schema for Legal AI applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/prisma/app.prisma CHANGED
@@ -61,15 +61,17 @@ model User {
61
61
  stripeCustomer StripeCustomer? // ✨ B2C Stripe customer
62
62
  ownedOrganizations Organization[] @relation("OrganizationOwner")
63
63
  organizationMembers OrganizationMember[]
64
- accounts Account[]
65
- answers Answer[]
66
- conversations Conversation[]
67
- feedbacks Feedback[]
68
- pageViews PageView[]
69
- sessions Session[]
70
- workflowLogs WorkflowLog[]
71
- verificationTokens VerificationToken[]
72
- passwordResetTokens PasswordResetToken[]
64
+ accounts Account[]
65
+ answers Answer[]
66
+ conversations Conversation[]
67
+ feedbacks Feedback[]
68
+ pageViews PageView[]
69
+ sessions Session[]
70
+ workflowLogs WorkflowLog[]
71
+ verificationTokens VerificationToken[]
72
+ passwordResetTokens PasswordResetToken[]
73
+ canvasDocuments CanvasDocument[]
74
+ canvasDocumentVersions CanvasDocumentVersion[]
73
75
  }
74
76
 
75
77
  // Nový model pre žiadosti o schválenie
@@ -175,6 +177,7 @@ model Conversation {
175
177
  answers Answer[]
176
178
  user User @relation(fields: [userId], references: [id])
177
179
  workflowLogs WorkflowLog[]
180
+ canvasDocuments CanvasDocument[]
178
181
 
179
182
  @@index([userId])
180
183
  @@index([createdAt])
@@ -199,11 +202,12 @@ model Answer {
199
202
  // Relácie
200
203
  conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
201
204
  user User? @relation(fields: [userId], references: [id])
202
- feedback Feedback?
203
- references Reference[]
204
- metrics AnswerMetrics?
205
- WorkflowLog WorkflowLog[]
206
- files MessageFile[]
205
+ feedback Feedback?
206
+ references Reference[]
207
+ metrics AnswerMetrics?
208
+ WorkflowLog WorkflowLog[]
209
+ files MessageFile[]
210
+ canvasDocumentId String? // No FK constraint - flexible document management
207
211
 
208
212
  @@index([conversationId])
209
213
  @@index([messageId])
@@ -516,10 +520,11 @@ enum SubscriptionStatus {
516
520
 
517
521
  // Stripe: Tier predplatného
518
522
  enum SubscriptionTier {
519
- FREE // Bezplatný tier (10 správ)
520
- LAWYER // Právnik tier (1000 správ, €49/mes, 1 user)
521
- LAW_FIRM // Právna kancelária tier (5000 správ, €149/mes, 5 users)
522
- ENTERPRISE // Enterprise tier (unlimited správ, unlimited users, custom price)
523
+ FREE // Free tier (10 messages/month)
524
+ LAWYER // Lawyer tier (1000 messages/month, €29/month, 1 user)
525
+ LAWYER_PRO // Lawyer Pro tier (3000 messages/month, €49/month, 1 user) - RECOMMENDED
526
+ LAW_FIRM // Law Firm tier (10000 messages/month, €129/month, up to 5 users)
527
+ ENTERPRISE // Enterprise tier (unlimited messages, unlimited users, custom pricing)
523
528
  }
524
529
 
525
530
  // Stripe: Billing interval
@@ -528,6 +533,13 @@ enum BillingInterval {
528
533
  YEARLY // Yearly billing (17% discount)
529
534
  }
530
535
 
536
+ // Canvas Document Status
537
+ enum DocumentStatus {
538
+ DRAFT
539
+ SAVED
540
+ ARCHIVED
541
+ }
542
+
531
543
  // Nový model pre logovanie admin akcií
532
544
  model AdminActionLog {
533
545
  id String @id @default(cuid())
@@ -643,3 +655,54 @@ model PasswordResetToken {
643
655
  @@index([userId])
644
656
  @@index([expires])
645
657
  }
658
+
659
+ // ============================================
660
+ // CANVAS DOCUMENT MODELS
661
+ // ============================================
662
+
663
+ model CanvasDocument {
664
+ id String @id @default(cuid())
665
+ userId String
666
+ title String
667
+ status DocumentStatus @default(DRAFT)
668
+ createdAt DateTime @default(now())
669
+ updatedAt DateTime @updatedAt
670
+ originConversationId String?
671
+ originAnswerId String? // No FK constraint - async save reference
672
+ currentVersionId String? @unique
673
+
674
+ // Relations
675
+ user User @relation(fields: [userId], references: [id], onDelete: Restrict)
676
+ originConversation Conversation? @relation(fields: [originConversationId], references: [id], onDelete: SetNull)
677
+ currentVersion CanvasDocumentVersion? @relation("CurrentVersion", fields: [currentVersionId], references: [id], onDelete: SetNull)
678
+ versions CanvasDocumentVersion[] @relation("DocumentVersions")
679
+
680
+ @@index([userId])
681
+ @@index([originConversationId])
682
+ @@index([status])
683
+ @@index([createdAt])
684
+ }
685
+
686
+ model CanvasDocumentVersion {
687
+ id String @id @default(cuid())
688
+ documentId String
689
+ versionNumber Int
690
+ title String
691
+ markdownContent String
692
+ createdAt DateTime @default(now())
693
+ createdBy String
694
+ regenerationPrompt String?
695
+ parentVersionId String?
696
+
697
+ // Relations
698
+ document CanvasDocument @relation("DocumentVersions", fields: [documentId], references: [id], onDelete: Cascade)
699
+ creator User @relation(fields: [createdBy], references: [id], onDelete: Restrict)
700
+ parentVersion CanvasDocumentVersion? @relation("VersionHistory", fields: [parentVersionId], references: [id], onDelete: SetNull)
701
+ childVersions CanvasDocumentVersion[] @relation("VersionHistory")
702
+ currentForDocument CanvasDocument? @relation("CurrentVersion")
703
+
704
+ @@unique([documentId, versionNumber])
705
+ @@index([documentId])
706
+ @@index([createdBy])
707
+ @@index([createdAt])
708
+ }