@danielcok17/prisma-db 1.8.0 → 1.9.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 +203 -0
- package/prisma/generated/app/edge.js +104 -5
- package/prisma/generated/app/index-browser.js +101 -2
- package/prisma/generated/app/index.d.ts +23487 -12142
- package/prisma/generated/app/index.js +104 -5
- package/prisma/generated/app/package.json +1 -1
- package/prisma/generated/app/schema.prisma +203 -0
- package/prisma/generated/app/wasm.js +104 -5
- package/prisma/migrations/20260114184556_add_folder_structure/migration.sql +173 -0
- package/prisma/migrations/20260120212010_add_user_company_fields/migration.sql +22 -0
package/package.json
CHANGED
package/prisma/app.prisma
CHANGED
|
@@ -57,6 +57,16 @@ model User {
|
|
|
57
57
|
messageCount Int @default(10) // ✅ OPRAVENÉ z 100 na 10
|
|
58
58
|
messageCountResetAt DateTime? // Kedy sa má resetovať message count
|
|
59
59
|
adminGrantExpiresAt DateTime? // Kedy admin grant expiruje
|
|
60
|
+
// ✨ COMPANY FIELDS (pre SZČO - samostatne zárobkovo činná osoba)
|
|
61
|
+
customerType CustomerType @default(INDIVIDUAL) // Typ zákazníka: fyzická osoba alebo SZČO
|
|
62
|
+
companyName String? // Obchodné meno (pre SZČO)
|
|
63
|
+
companyNumber String? // IČO (povinné pre SZČO, 8 číslic)
|
|
64
|
+
vatNumber String? // IČ DPH (SK + 10 číslic, nepovinné)
|
|
65
|
+
taxNumber String? // DIČ (10 číslic, nepovinné)
|
|
66
|
+
companyStreet String? // Ulica a číslo (pre SZČO)
|
|
67
|
+
companyCity String? // Mesto (pre SZČO)
|
|
68
|
+
companyPostalCode String? // PSČ (pre SZČO, formát: XXX XX)
|
|
69
|
+
companyCountry String? @default("SK") // Krajina (ISO kód, default SK)
|
|
60
70
|
// Relations
|
|
61
71
|
approvalRequest UserApprovalRequest?
|
|
62
72
|
stripeCustomer StripeCustomer? // ✨ B2C Stripe customer
|
|
@@ -74,6 +84,16 @@ model User {
|
|
|
74
84
|
passwordResetTokens PasswordResetToken[]
|
|
75
85
|
canvasDocuments CanvasDocument[]
|
|
76
86
|
canvasDocumentVersions CanvasDocumentVersion[]
|
|
87
|
+
// Folder system relations
|
|
88
|
+
ownedFolders Folder[] @relation("FolderOwner")
|
|
89
|
+
addedFolderItems FolderItem[] @relation("FolderItemAdder")
|
|
90
|
+
folderActivities FolderActivity[] @relation("FolderActivityUser")
|
|
91
|
+
folderSharesReceived FolderShare[] @relation("FolderShareUser")
|
|
92
|
+
createdFolderShares FolderShare[] @relation("FolderShareCreator")
|
|
93
|
+
|
|
94
|
+
@@index([customerType])
|
|
95
|
+
@@index([companyNumber])
|
|
96
|
+
@@index([email, customerType])
|
|
77
97
|
}
|
|
78
98
|
|
|
79
99
|
// Nový model pre žiadosti o schválenie
|
|
@@ -131,6 +151,7 @@ model Organization {
|
|
|
131
151
|
members OrganizationMember[]
|
|
132
152
|
invites OrganizationInvite[]
|
|
133
153
|
stripeCustomer StripeCustomer?
|
|
154
|
+
folderShares FolderShare[]
|
|
134
155
|
|
|
135
156
|
createdAt DateTime @default(now())
|
|
136
157
|
updatedAt DateTime @updatedAt
|
|
@@ -548,6 +569,12 @@ enum SubscriptionStatus {
|
|
|
548
569
|
PAUSED // Predplatné pozastavené (Stripe feature)
|
|
549
570
|
}
|
|
550
571
|
|
|
572
|
+
// Customer type: Individuálny vs SZČO
|
|
573
|
+
enum CustomerType {
|
|
574
|
+
INDIVIDUAL // Fyzická osoba (bez IČO)
|
|
575
|
+
SELF_EMPLOYED // SZČO - Samostatne zárobkovo činná osoba (s IČO)
|
|
576
|
+
}
|
|
577
|
+
|
|
551
578
|
// Stripe: Tier predplatného
|
|
552
579
|
enum SubscriptionTier {
|
|
553
580
|
FREE // Free tier (10 messages/month)
|
|
@@ -570,6 +597,40 @@ enum DocumentStatus {
|
|
|
570
597
|
ARCHIVED
|
|
571
598
|
}
|
|
572
599
|
|
|
600
|
+
// ============================================
|
|
601
|
+
// FOLDER SYSTEM ENUMS
|
|
602
|
+
// ============================================
|
|
603
|
+
|
|
604
|
+
// Folder item types (what can be stored in folders)
|
|
605
|
+
enum FolderItemType {
|
|
606
|
+
CONVERSATION
|
|
607
|
+
CANVAS_DOCUMENT
|
|
608
|
+
REFERENCE
|
|
609
|
+
ATTACHMENT
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// Folder activity types (for timeline)
|
|
613
|
+
enum FolderActivityType {
|
|
614
|
+
FOLDER_CREATED
|
|
615
|
+
FOLDER_UPDATED
|
|
616
|
+
FOLDER_MOVED
|
|
617
|
+
FOLDER_ARCHIVED
|
|
618
|
+
ITEM_ADDED
|
|
619
|
+
ITEM_REMOVED
|
|
620
|
+
ITEM_UPDATED
|
|
621
|
+
SHARE_ADDED
|
|
622
|
+
SHARE_REMOVED
|
|
623
|
+
USER_MESSAGE
|
|
624
|
+
USER_NOTE
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// Folder permission levels
|
|
628
|
+
enum FolderPermission {
|
|
629
|
+
VIEW
|
|
630
|
+
EDIT
|
|
631
|
+
ADMIN
|
|
632
|
+
}
|
|
633
|
+
|
|
573
634
|
// Nový model pre logovanie admin akcií
|
|
574
635
|
model AdminActionLog {
|
|
575
636
|
id String @id @default(cuid())
|
|
@@ -736,3 +797,145 @@ model CanvasDocumentVersion {
|
|
|
736
797
|
@@index([createdBy])
|
|
737
798
|
@@index([createdAt])
|
|
738
799
|
}
|
|
800
|
+
|
|
801
|
+
// ============================================
|
|
802
|
+
// FOLDER SYSTEM MODELS
|
|
803
|
+
// ============================================
|
|
804
|
+
|
|
805
|
+
// Main folder entity with hierarchy support via parentId
|
|
806
|
+
// Uses materialized path pattern for efficient hierarchy queries
|
|
807
|
+
model Folder {
|
|
808
|
+
id String @id @default(cuid())
|
|
809
|
+
name String
|
|
810
|
+
description String?
|
|
811
|
+
color String? @default("#6366f1")
|
|
812
|
+
icon String? @default("folder")
|
|
813
|
+
|
|
814
|
+
// Ownership (always user-owned)
|
|
815
|
+
ownerId String
|
|
816
|
+
|
|
817
|
+
// Hierarchy
|
|
818
|
+
parentId String?
|
|
819
|
+
rootFolderId String? // NULL for root folders, points to top-level ancestor
|
|
820
|
+
path String @default("/") // Materialized path: "/parentId/grandparentId/..."
|
|
821
|
+
depth Int @default(0)
|
|
822
|
+
|
|
823
|
+
// Metadata
|
|
824
|
+
sortOrder Int @default(0)
|
|
825
|
+
isArchived Boolean @default(false)
|
|
826
|
+
createdAt DateTime @default(now())
|
|
827
|
+
updatedAt DateTime @updatedAt
|
|
828
|
+
|
|
829
|
+
// Relations
|
|
830
|
+
owner User @relation("FolderOwner", fields: [ownerId], references: [id], onDelete: Cascade)
|
|
831
|
+
parent Folder? @relation("FolderHierarchy", fields: [parentId], references: [id], onDelete: Cascade)
|
|
832
|
+
children Folder[] @relation("FolderHierarchy")
|
|
833
|
+
items FolderItem[]
|
|
834
|
+
activities FolderActivity[]
|
|
835
|
+
shares FolderShare[]
|
|
836
|
+
|
|
837
|
+
@@index([ownerId])
|
|
838
|
+
@@index([parentId])
|
|
839
|
+
@@index([rootFolderId])
|
|
840
|
+
@@index([path])
|
|
841
|
+
@@index([isArchived])
|
|
842
|
+
@@index([ownerId, isArchived])
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// Links entities (conversations, documents, etc.) to folders
|
|
846
|
+
// Polymorphic: entityType + entityId point to any supported entity
|
|
847
|
+
model FolderItem {
|
|
848
|
+
id String @id @default(cuid())
|
|
849
|
+
folderId String
|
|
850
|
+
|
|
851
|
+
// Polymorphic reference
|
|
852
|
+
entityType FolderItemType
|
|
853
|
+
entityId String
|
|
854
|
+
|
|
855
|
+
// Optional metadata override
|
|
856
|
+
displayName String?
|
|
857
|
+
notes String?
|
|
858
|
+
|
|
859
|
+
// Denormalized for efficient hierarchy queries
|
|
860
|
+
rootFolderId String?
|
|
861
|
+
|
|
862
|
+
// Tracking
|
|
863
|
+
addedById String
|
|
864
|
+
sortOrder Int @default(0)
|
|
865
|
+
createdAt DateTime @default(now())
|
|
866
|
+
updatedAt DateTime @updatedAt
|
|
867
|
+
|
|
868
|
+
// Relations
|
|
869
|
+
folder Folder @relation(fields: [folderId], references: [id], onDelete: Cascade)
|
|
870
|
+
addedBy User @relation("FolderItemAdder", fields: [addedById], references: [id], onDelete: Restrict)
|
|
871
|
+
|
|
872
|
+
@@unique([folderId, entityType, entityId])
|
|
873
|
+
@@index([folderId])
|
|
874
|
+
@@index([entityType, entityId])
|
|
875
|
+
@@index([rootFolderId])
|
|
876
|
+
@@index([addedById])
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// Timeline entries for folders (system events + user messages)
|
|
880
|
+
// Opening ANY folder shows ALL activities from the entire folder tree
|
|
881
|
+
model FolderActivity {
|
|
882
|
+
id String @id @default(cuid())
|
|
883
|
+
folderId String
|
|
884
|
+
|
|
885
|
+
// Denormalized for cross-folder timeline queries
|
|
886
|
+
rootFolderId String?
|
|
887
|
+
|
|
888
|
+
// Activity details
|
|
889
|
+
activityType FolderActivityType
|
|
890
|
+
userId String
|
|
891
|
+
content String? // For USER_MESSAGE, USER_NOTE types
|
|
892
|
+
metadata Json? // For system event details
|
|
893
|
+
relatedItemId String? // Optional reference to FolderItem
|
|
894
|
+
|
|
895
|
+
// Timestamp
|
|
896
|
+
createdAt DateTime @default(now())
|
|
897
|
+
|
|
898
|
+
// Relations
|
|
899
|
+
folder Folder @relation(fields: [folderId], references: [id], onDelete: Cascade)
|
|
900
|
+
user User @relation("FolderActivityUser", fields: [userId], references: [id], onDelete: Restrict)
|
|
901
|
+
|
|
902
|
+
@@index([folderId])
|
|
903
|
+
@@index([rootFolderId])
|
|
904
|
+
@@index([userId])
|
|
905
|
+
@@index([activityType])
|
|
906
|
+
@@index([createdAt])
|
|
907
|
+
@@index([rootFolderId, createdAt(sort: Desc)])
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// Sharing permissions for folders
|
|
911
|
+
// Can share with individual user OR entire organization (not both)
|
|
912
|
+
model FolderShare {
|
|
913
|
+
id String @id @default(cuid())
|
|
914
|
+
folderId String
|
|
915
|
+
|
|
916
|
+
// Share target (either user OR organization, enforced by application logic)
|
|
917
|
+
userId String?
|
|
918
|
+
organizationId String?
|
|
919
|
+
|
|
920
|
+
// Permission level
|
|
921
|
+
permission FolderPermission @default(VIEW)
|
|
922
|
+
|
|
923
|
+
// Sharing metadata
|
|
924
|
+
sharedById String
|
|
925
|
+
sharedAt DateTime @default(now())
|
|
926
|
+
expiresAt DateTime?
|
|
927
|
+
|
|
928
|
+
// Relations
|
|
929
|
+
folder Folder @relation(fields: [folderId], references: [id], onDelete: Cascade)
|
|
930
|
+
user User? @relation("FolderShareUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
931
|
+
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
932
|
+
sharedBy User @relation("FolderShareCreator", fields: [sharedById], references: [id], onDelete: Restrict)
|
|
933
|
+
|
|
934
|
+
// Partial unique indexes for nullable columns
|
|
935
|
+
@@unique([folderId, userId])
|
|
936
|
+
@@unique([folderId, organizationId])
|
|
937
|
+
@@index([folderId])
|
|
938
|
+
@@index([userId])
|
|
939
|
+
@@index([organizationId])
|
|
940
|
+
@@index([sharedById])
|
|
941
|
+
}
|