suparisma 1.2.3 → 1.2.6

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 (130) hide show
  1. package/dist/generators/coreGenerator.js +74 -16
  2. package/dist/generators/hookGenerator.js +6 -2
  3. package/dist/generators/typeGenerator.js +43 -31
  4. package/dist/index.js +6 -1
  5. package/package.json +1 -1
  6. package/tmp/generated-test/hooks/useSuparismaAsset.ts +94 -0
  7. package/tmp/generated-test/hooks/useSuparismaChapter.ts +96 -0
  8. package/tmp/generated-test/hooks/useSuparismaCourse.ts +96 -0
  9. package/tmp/generated-test/hooks/useSuparismaDeviceSession.ts +94 -0
  10. package/tmp/generated-test/hooks/useSuparismaEnrollment.ts +92 -0
  11. package/tmp/generated-test/hooks/useSuparismaLesson.ts +96 -0
  12. package/tmp/generated-test/hooks/useSuparismaLessonPurchase.ts +92 -0
  13. package/tmp/generated-test/hooks/useSuparismaLessonQuestion.ts +96 -0
  14. package/tmp/generated-test/hooks/useSuparismaPayoutMethod.ts +96 -0
  15. package/tmp/generated-test/hooks/useSuparismaPayoutRequest.ts +96 -0
  16. package/tmp/generated-test/hooks/useSuparismaQuestionOption.ts +92 -0
  17. package/tmp/generated-test/hooks/useSuparismaSavedPaymentMethod.ts +96 -0
  18. package/tmp/generated-test/hooks/useSuparismaTeacherPayoutInfo.ts +96 -0
  19. package/tmp/generated-test/hooks/useSuparismaThing.ts +96 -0
  20. package/tmp/generated-test/hooks/useSuparismaUser.ts +96 -0
  21. package/tmp/generated-test/hooks/useSuparismaVideoNote.ts +96 -0
  22. package/tmp/generated-test/hooks/useSuparismaWallet.ts +96 -0
  23. package/tmp/generated-test/hooks/useSuparismaWalletTransaction.ts +96 -0
  24. package/tmp/generated-test/hooks/useSuparismaWatchProgress.ts +96 -0
  25. package/tmp/generated-test/index.ts +140 -0
  26. package/tmp/generated-test/types/AssetTypes.ts +485 -0
  27. package/tmp/generated-test/types/ChapterTypes.ts +488 -0
  28. package/tmp/generated-test/types/CourseTypes.ts +519 -0
  29. package/tmp/generated-test/types/DeviceSessionTypes.ts +489 -0
  30. package/tmp/generated-test/types/EnrollmentTypes.ts +495 -0
  31. package/tmp/generated-test/types/LessonPurchaseTypes.ts +490 -0
  32. package/tmp/generated-test/types/LessonQuestionTypes.ts +496 -0
  33. package/tmp/generated-test/types/LessonTypes.ts +517 -0
  34. package/tmp/generated-test/types/PayoutMethodTypes.ts +517 -0
  35. package/tmp/generated-test/types/PayoutRequestTypes.ts +528 -0
  36. package/tmp/generated-test/types/QuestionOptionTypes.ts +479 -0
  37. package/tmp/generated-test/types/SavedPaymentMethodTypes.ts +497 -0
  38. package/tmp/generated-test/types/TeacherPayoutInfoTypes.ts +480 -0
  39. package/tmp/generated-test/types/ThingTypes.ts +482 -0
  40. package/tmp/generated-test/types/UserTypes.ts +487 -0
  41. package/tmp/generated-test/types/VideoNoteTypes.ts +489 -0
  42. package/tmp/generated-test/types/WalletTransactionTypes.ts +505 -0
  43. package/tmp/generated-test/types/WalletTypes.ts +480 -0
  44. package/tmp/generated-test/types/WatchProgressTypes.ts +493 -0
  45. package/tmp/generated-test/utils/core.ts +2306 -0
  46. package/tmp/generated-test/utils/supabase-client.ts +17 -0
  47. package/tmp/generated-test2/hooks/useSuparismaAsset.ts +94 -0
  48. package/tmp/generated-test2/hooks/useSuparismaChapter.ts +96 -0
  49. package/tmp/generated-test2/hooks/useSuparismaCourse.ts +96 -0
  50. package/tmp/generated-test2/hooks/useSuparismaDeviceSession.ts +94 -0
  51. package/tmp/generated-test2/hooks/useSuparismaEnrollment.ts +92 -0
  52. package/tmp/generated-test2/hooks/useSuparismaLesson.ts +96 -0
  53. package/tmp/generated-test2/hooks/useSuparismaLessonPurchase.ts +92 -0
  54. package/tmp/generated-test2/hooks/useSuparismaLessonQuestion.ts +96 -0
  55. package/tmp/generated-test2/hooks/useSuparismaPayoutMethod.ts +96 -0
  56. package/tmp/generated-test2/hooks/useSuparismaPayoutRequest.ts +96 -0
  57. package/tmp/generated-test2/hooks/useSuparismaQuestionOption.ts +92 -0
  58. package/tmp/generated-test2/hooks/useSuparismaSavedPaymentMethod.ts +96 -0
  59. package/tmp/generated-test2/hooks/useSuparismaTeacherPayoutInfo.ts +96 -0
  60. package/tmp/generated-test2/hooks/useSuparismaThing.ts +96 -0
  61. package/tmp/generated-test2/hooks/useSuparismaUser.ts +96 -0
  62. package/tmp/generated-test2/hooks/useSuparismaVideoNote.ts +96 -0
  63. package/tmp/generated-test2/hooks/useSuparismaWallet.ts +96 -0
  64. package/tmp/generated-test2/hooks/useSuparismaWalletTransaction.ts +96 -0
  65. package/tmp/generated-test2/hooks/useSuparismaWatchProgress.ts +96 -0
  66. package/tmp/generated-test2/index.ts +140 -0
  67. package/tmp/generated-test2/types/AssetTypes.ts +485 -0
  68. package/tmp/generated-test2/types/ChapterTypes.ts +488 -0
  69. package/tmp/generated-test2/types/CourseTypes.ts +522 -0
  70. package/tmp/generated-test2/types/DeviceSessionTypes.ts +489 -0
  71. package/tmp/generated-test2/types/EnrollmentTypes.ts +495 -0
  72. package/tmp/generated-test2/types/LessonPurchaseTypes.ts +490 -0
  73. package/tmp/generated-test2/types/LessonQuestionTypes.ts +496 -0
  74. package/tmp/generated-test2/types/LessonTypes.ts +517 -0
  75. package/tmp/generated-test2/types/PayoutMethodTypes.ts +517 -0
  76. package/tmp/generated-test2/types/PayoutRequestTypes.ts +528 -0
  77. package/tmp/generated-test2/types/QuestionOptionTypes.ts +479 -0
  78. package/tmp/generated-test2/types/SavedPaymentMethodTypes.ts +497 -0
  79. package/tmp/generated-test2/types/TeacherPayoutInfoTypes.ts +480 -0
  80. package/tmp/generated-test2/types/ThingTypes.ts +482 -0
  81. package/tmp/generated-test2/types/UserTypes.ts +490 -0
  82. package/tmp/generated-test2/types/VideoNoteTypes.ts +489 -0
  83. package/tmp/generated-test2/types/WalletTransactionTypes.ts +505 -0
  84. package/tmp/generated-test2/types/WalletTypes.ts +480 -0
  85. package/tmp/generated-test2/types/WatchProgressTypes.ts +493 -0
  86. package/tmp/generated-test2/utils/core.ts +2306 -0
  87. package/tmp/generated-test2/utils/supabase-client.ts +17 -0
  88. package/tmp/generated-test3/hooks/useSuparismaAsset.ts +94 -0
  89. package/tmp/generated-test3/hooks/useSuparismaChapter.ts +98 -0
  90. package/tmp/generated-test3/hooks/useSuparismaCourse.ts +98 -0
  91. package/tmp/generated-test3/hooks/useSuparismaDeviceSession.ts +94 -0
  92. package/tmp/generated-test3/hooks/useSuparismaEnrollment.ts +94 -0
  93. package/tmp/generated-test3/hooks/useSuparismaLesson.ts +98 -0
  94. package/tmp/generated-test3/hooks/useSuparismaLessonPurchase.ts +94 -0
  95. package/tmp/generated-test3/hooks/useSuparismaLessonQuestion.ts +98 -0
  96. package/tmp/generated-test3/hooks/useSuparismaPayoutMethod.ts +96 -0
  97. package/tmp/generated-test3/hooks/useSuparismaPayoutRequest.ts +96 -0
  98. package/tmp/generated-test3/hooks/useSuparismaQuestionOption.ts +94 -0
  99. package/tmp/generated-test3/hooks/useSuparismaSavedPaymentMethod.ts +96 -0
  100. package/tmp/generated-test3/hooks/useSuparismaTeacherPayoutInfo.ts +98 -0
  101. package/tmp/generated-test3/hooks/useSuparismaThing.ts +96 -0
  102. package/tmp/generated-test3/hooks/useSuparismaUser.ts +98 -0
  103. package/tmp/generated-test3/hooks/useSuparismaVideoNote.ts +98 -0
  104. package/tmp/generated-test3/hooks/useSuparismaWallet.ts +98 -0
  105. package/tmp/generated-test3/hooks/useSuparismaWalletTransaction.ts +98 -0
  106. package/tmp/generated-test3/hooks/useSuparismaWatchProgress.ts +98 -0
  107. package/tmp/generated-test3/index.ts +140 -0
  108. package/tmp/generated-test3/types/AssetTypes.ts +485 -0
  109. package/tmp/generated-test3/types/ChapterTypes.ts +488 -0
  110. package/tmp/generated-test3/types/CourseTypes.ts +522 -0
  111. package/tmp/generated-test3/types/DeviceSessionTypes.ts +489 -0
  112. package/tmp/generated-test3/types/EnrollmentTypes.ts +495 -0
  113. package/tmp/generated-test3/types/LessonPurchaseTypes.ts +490 -0
  114. package/tmp/generated-test3/types/LessonQuestionTypes.ts +496 -0
  115. package/tmp/generated-test3/types/LessonTypes.ts +517 -0
  116. package/tmp/generated-test3/types/PayoutMethodTypes.ts +517 -0
  117. package/tmp/generated-test3/types/PayoutRequestTypes.ts +528 -0
  118. package/tmp/generated-test3/types/QuestionOptionTypes.ts +479 -0
  119. package/tmp/generated-test3/types/SavedPaymentMethodTypes.ts +497 -0
  120. package/tmp/generated-test3/types/TeacherPayoutInfoTypes.ts +480 -0
  121. package/tmp/generated-test3/types/ThingTypes.ts +482 -0
  122. package/tmp/generated-test3/types/UserTypes.ts +490 -0
  123. package/tmp/generated-test3/types/VideoNoteTypes.ts +489 -0
  124. package/tmp/generated-test3/types/WalletTransactionTypes.ts +505 -0
  125. package/tmp/generated-test3/types/WalletTypes.ts +480 -0
  126. package/tmp/generated-test3/types/WatchProgressTypes.ts +493 -0
  127. package/tmp/generated-test3/utils/core.ts +2316 -0
  128. package/tmp/generated-test3/utils/supabase-client.ts +17 -0
  129. package/tmp/prisma-test-schema-2.prisma +339 -0
  130. package/tmp/prisma-test-schema.prisma +317 -0
@@ -0,0 +1,17 @@
1
+ // THIS FILE IS AUTO-GENERATED - DO NOT EDIT DIRECTLY
2
+ // Platform: Web (Next.js, Remix, etc.)
3
+ import { createClient } from '@supabase/supabase-js';
4
+
5
+ // For Next.js, use NEXT_PUBLIC_ prefix
6
+ // For other frameworks, adjust the environment variable names as needed
7
+ const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL || '';
8
+ const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || '';
9
+
10
+ if (!SUPABASE_URL || !SUPABASE_ANON_KEY) {
11
+ console.warn(
12
+ '[Suparisma] Supabase credentials not found. Please set NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY ' +
13
+ '(or SUPABASE_URL and SUPABASE_ANON_KEY) in your environment variables.'
14
+ );
15
+ }
16
+
17
+ export const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
@@ -0,0 +1,339 @@
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ }
4
+
5
+ datasource db {
6
+ provider = "postgresql"
7
+ url = env("DATABASE_URL")
8
+ directUrl = env("DIRECT_URL")
9
+ }
10
+
11
+ /// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info.
12
+ model User {
13
+ id String @id @default(uuid())
14
+ email String @unique
15
+ name String?
16
+ createdAt DateTime @default(now())
17
+ phone String?
18
+ updatedAt DateTime @updatedAt
19
+ role String @default("student")
20
+ photo String?
21
+ payoutInfo TeacherPayoutInfo?
22
+ courses Course[] // Courses taught by this user (when role is teacher)
23
+ }
24
+
25
+ // Teacher payout preferences (frequency, etc.) - one per user
26
+ model TeacherPayoutInfo {
27
+ id String @id @default(uuid())
28
+ userId String @unique
29
+ payoutFrequency String @default("daily")
30
+ lastPayoutRequest DateTime?
31
+ createdAt DateTime @default(now())
32
+ updatedAt DateTime @updatedAt
33
+ user User @relation(fields: [userId], references: [id])
34
+ }
35
+
36
+ // Multiple payout methods per teacher
37
+ model PayoutMethod {
38
+ id String @id @default(uuid())
39
+ userId String
40
+ type String // 'wallet' or 'bank_card'
41
+ label String? // User-defined label like "Main Vodafone" or "CIB Card"
42
+ isDefault Boolean @default(false)
43
+
44
+ // Wallet fields
45
+ walletIssuer String? // vodafone, etisalat, orange, bank_wallet
46
+ walletMsisdn String? // Phone number
47
+
48
+ // Bank card fields
49
+ bankFullName String? // Full name on card
50
+ bankCardNumber String? // Card number (last 4 digits stored)
51
+ bankCode String? // Bank code
52
+ bankTxnType String? // cash_transfer, prepaid_card, credit_card
53
+
54
+ isVerified Boolean @default(false)
55
+ verifiedAt DateTime?
56
+ createdAt DateTime @default(now())
57
+ updatedAt DateTime @updatedAt
58
+
59
+ @@index([userId])
60
+ @@index([userId, isDefault])
61
+ }
62
+
63
+ /// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info.
64
+ model Course {
65
+ id String @id @default(uuid())
66
+ title String
67
+ description String?
68
+ thumbnail String?
69
+ published Boolean @default(false)
70
+ teacherId String
71
+ teacher User @relation(fields: [teacherId], references: [id])
72
+ createdAt DateTime @default(now())
73
+ updatedAt DateTime @updatedAt
74
+ allowIndividualLessonPurchase Boolean @default(false)
75
+ blockScreenRecording Boolean @default(true)
76
+ maxDevices Int @default(0)
77
+ price Float @default(0)
78
+ pricingType String @default("paid")
79
+ defaultLessonPrice Float @default(0)
80
+ chapters Chapter[]
81
+ enrollments Enrollment[]
82
+ purchases LessonPurchase[]
83
+
84
+ @@index([teacherId])
85
+ @@index([published])
86
+ @@index([pricingType])
87
+ }
88
+
89
+ /// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info.
90
+ model Chapter {
91
+ id String @id @default(uuid())
92
+ title String
93
+ description String?
94
+ order Int @default(0)
95
+ courseId String
96
+ createdAt DateTime @default(now())
97
+ updatedAt DateTime @updatedAt
98
+ course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
99
+ lessons Lesson[]
100
+
101
+ @@index([courseId])
102
+ }
103
+
104
+ /// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info.
105
+ model Lesson {
106
+ id String @id @default(uuid())
107
+ title String
108
+ description String?
109
+ order Int @default(0)
110
+ courseId String
111
+ videoId String?
112
+ videoDuration Int?
113
+ createdAt DateTime @default(now())
114
+ updatedAt DateTime @updatedAt
115
+ chapterId String?
116
+ isFree Boolean @default(false)
117
+ price Float @default(0)
118
+ chapter Chapter? @relation(fields: [chapterId], references: [id])
119
+ purchases LessonPurchase[]
120
+ questions LessonQuestion[]
121
+ videoNotes VideoNote[]
122
+ watchProgress WatchProgress[]
123
+
124
+ @@index([courseId])
125
+ @@index([chapterId])
126
+ @@index([isFree])
127
+ }
128
+
129
+ model LessonQuestion {
130
+ id String @id @default(uuid())
131
+ lessonId String
132
+ question String
133
+ type String @default("multiple_choice")
134
+ order Int @default(0)
135
+ points Int @default(1)
136
+ explanation String?
137
+ createdAt DateTime @default(now())
138
+ updatedAt DateTime @updatedAt
139
+ lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
140
+ options QuestionOption[]
141
+
142
+ @@index([lessonId])
143
+ }
144
+
145
+ model QuestionOption {
146
+ id String @id @default(uuid())
147
+ questionId String
148
+ text String
149
+ isCorrect Boolean @default(false)
150
+ order Int @default(0)
151
+ question LessonQuestion @relation(fields: [questionId], references: [id], onDelete: Cascade)
152
+
153
+ @@index([questionId])
154
+ }
155
+
156
+ model Enrollment {
157
+ id String @id @default(uuid())
158
+ studentId String
159
+ courseId String
160
+ enrolledAt DateTime @default(now())
161
+ completedAt DateTime?
162
+ paidAmount Float?
163
+ paymentId String?
164
+ course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
165
+
166
+ screenshotAttempts Int @default(0)
167
+ screenRecordingAttempts Int @default(0)
168
+
169
+ @@unique([studentId, courseId])
170
+ @@index([studentId])
171
+ @@index([courseId])
172
+ }
173
+
174
+ model LessonPurchase {
175
+ id String @id @default(uuid())
176
+ studentId String
177
+ lessonId String
178
+ courseId String
179
+ paidAmount Float
180
+ paymentId String?
181
+ purchasedAt DateTime @default(now())
182
+ course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
183
+ lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
184
+
185
+ @@unique([studentId, lessonId])
186
+ @@index([studentId])
187
+ @@index([lessonId])
188
+ @@index([courseId])
189
+ }
190
+
191
+ model WatchProgress {
192
+ id String @id @default(uuid())
193
+ lessonId String
194
+ studentId String
195
+ watchedSeconds Int @default(0)
196
+ lastPosition Int @default(0)
197
+ completed Boolean @default(false)
198
+ lastWatchedAt DateTime @default(now())
199
+ createdAt DateTime @default(now())
200
+ updatedAt DateTime @updatedAt
201
+ lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
202
+
203
+ @@unique([lessonId, studentId])
204
+ @@index([studentId])
205
+ @@index([lessonId])
206
+ }
207
+
208
+ model Asset {
209
+ id String @id @default(uuid())
210
+ title String
211
+ type String
212
+ url String
213
+ lessonId String
214
+ createdAt DateTime @default(now())
215
+ size Int?
216
+
217
+ @@index([lessonId])
218
+ }
219
+
220
+ model VideoNote {
221
+ id String @id @default(uuid())
222
+ lessonId String
223
+ studentId String
224
+ timestamp Int
225
+ content String
226
+ color String @default("default")
227
+ createdAt DateTime @default(now())
228
+ updatedAt DateTime @updatedAt
229
+ lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
230
+
231
+ @@index([lessonId, studentId])
232
+ @@index([studentId])
233
+ }
234
+
235
+ model DeviceSession {
236
+ id String @id @default(uuid())
237
+ studentId String
238
+ courseId String
239
+ deviceId String
240
+ deviceName String?
241
+ deviceType String?
242
+ lastActiveAt DateTime @default(now())
243
+ createdAt DateTime @default(now())
244
+
245
+ @@unique([studentId, courseId, deviceId])
246
+ @@index([studentId, courseId])
247
+ @@index([lastActiveAt])
248
+ }
249
+
250
+ /// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info.
251
+ model Thing {
252
+ id String @id @default(uuid())
253
+ title String
254
+ description String?
255
+ status String @default("pending")
256
+ priority Int @default(0)
257
+ createdAt DateTime @default(now())
258
+ updatedAt DateTime @updatedAt
259
+ }
260
+
261
+ model Wallet {
262
+ id String @id @default(uuid())
263
+ userId String @unique
264
+ balance Float @default(0)
265
+ currency String @default("EGP")
266
+ createdAt DateTime @default(now())
267
+ updatedAt DateTime @updatedAt
268
+ transactions WalletTransaction[]
269
+ }
270
+
271
+ model SavedPaymentMethod {
272
+ id String @id @default(uuid())
273
+ userId String
274
+ cardBrand String
275
+ cardLast4 String
276
+ cardExpiryMonth String?
277
+ cardExpiryYear String?
278
+ paymobToken String
279
+ isDefault Boolean @default(false)
280
+ createdAt DateTime @default(now())
281
+ updatedAt DateTime @updatedAt
282
+
283
+ @@index([userId])
284
+ }
285
+
286
+ model WalletTransaction {
287
+ id String @id @default(uuid())
288
+ walletId String
289
+ amount Float
290
+ type String
291
+ status String @default("pending")
292
+ paymobOrderId String?
293
+ paymobTxnId String?
294
+ paymentMethod String?
295
+ description String?
296
+ metadata String?
297
+ createdAt DateTime @default(now())
298
+ updatedAt DateTime @updatedAt
299
+ wallet Wallet @relation(fields: [walletId], references: [id])
300
+
301
+ @@index([walletId])
302
+ @@index([paymobOrderId])
303
+ @@index([paymobTxnId])
304
+ }
305
+
306
+ /// Payout request from teacher to withdraw their earnings
307
+ model PayoutRequest {
308
+ id String @id @default(uuid())
309
+ teacherId String
310
+ amount Float
311
+ status String @default("pending") // pending, processing, completed, rejected
312
+ payoutMethod String // wallet, bank_card
313
+
314
+ // Wallet payout details (copied from TeacherPayoutInfo at request time)
315
+ walletIssuer String?
316
+ walletMsisdn String?
317
+
318
+ // Bank payout details (copied from TeacherPayoutInfo at request time)
319
+ bankFullName String?
320
+ bankCardNumber String?
321
+ bankCode String?
322
+ bankTxnType String?
323
+
324
+ // Admin fields
325
+ adminNotes String?
326
+ receiptUrl String?
327
+ processedBy String? // Admin email who processed it
328
+ processedAt DateTime?
329
+ rejectionReason String?
330
+
331
+ createdAt DateTime @default(now())
332
+ updatedAt DateTime @updatedAt
333
+
334
+ @@index([teacherId])
335
+ @@index([status])
336
+ @@index([createdAt])
337
+ }
338
+
339
+
@@ -0,0 +1,317 @@
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ }
4
+
5
+ datasource db {
6
+ provider = "postgresql"
7
+ url = env("DATABASE_URL")
8
+ directUrl = env("DIRECT_URL")
9
+ }
10
+
11
+ model User {
12
+ id String @id @default(uuid())
13
+ email String @unique
14
+ name String?
15
+ createdAt DateTime @default(now())
16
+ phone String?
17
+ updatedAt DateTime @updatedAt
18
+ role String @default("student")
19
+ photo String?
20
+ payoutInfo TeacherPayoutInfo?
21
+ }
22
+
23
+ model TeacherPayoutInfo {
24
+ id String @id @default(uuid())
25
+ userId String @unique
26
+ payoutFrequency String @default("daily")
27
+ lastPayoutRequest DateTime?
28
+ createdAt DateTime @default(now())
29
+ updatedAt DateTime @updatedAt
30
+ user User @relation(fields: [userId], references: [id])
31
+ }
32
+
33
+ model PayoutMethod {
34
+ id String @id @default(uuid())
35
+ userId String
36
+ type String
37
+ label String?
38
+ isDefault Boolean @default(false)
39
+ walletIssuer String?
40
+ walletMsisdn String?
41
+ bankFullName String?
42
+ bankCardNumber String?
43
+ bankCode String?
44
+ bankTxnType String?
45
+ isVerified Boolean @default(false)
46
+ verifiedAt DateTime?
47
+ createdAt DateTime @default(now())
48
+ updatedAt DateTime @updatedAt
49
+
50
+ @@index([userId])
51
+ @@index([userId, isDefault])
52
+ }
53
+
54
+ model Course {
55
+ id String @id @default(uuid())
56
+ title String
57
+ description String?
58
+ thumbnail String?
59
+ published Boolean @default(false)
60
+ teacherId String
61
+ createdAt DateTime @default(now())
62
+ updatedAt DateTime @updatedAt
63
+ allowIndividualLessonPurchase Boolean @default(false)
64
+ blockScreenRecording Boolean @default(true)
65
+ maxDevices Int @default(0)
66
+ price Float @default(0)
67
+ pricingType String @default("paid")
68
+ defaultLessonPrice Float @default(0)
69
+ chapters Chapter[]
70
+ enrollments Enrollment[]
71
+ purchases LessonPurchase[]
72
+
73
+ @@index([teacherId])
74
+ @@index([published])
75
+ @@index([pricingType])
76
+ }
77
+
78
+ model Chapter {
79
+ id String @id @default(uuid())
80
+ title String
81
+ description String?
82
+ order Int @default(0)
83
+ courseId String
84
+ createdAt DateTime @default(now())
85
+ updatedAt DateTime @updatedAt
86
+ course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
87
+ lessons Lesson[]
88
+
89
+ @@index([courseId])
90
+ }
91
+
92
+ model Lesson {
93
+ id String @id @default(uuid())
94
+ title String
95
+ description String?
96
+ order Int @default(0)
97
+ courseId String
98
+ videoId String?
99
+ videoDuration Int?
100
+ createdAt DateTime @default(now())
101
+ updatedAt DateTime @updatedAt
102
+ chapterId String?
103
+ isFree Boolean @default(false)
104
+ price Float @default(0)
105
+ chapter Chapter? @relation(fields: [chapterId], references: [id])
106
+ purchases LessonPurchase[]
107
+ questions LessonQuestion[]
108
+ videoNotes VideoNote[]
109
+ watchProgress WatchProgress[]
110
+
111
+ @@index([courseId])
112
+ @@index([chapterId])
113
+ @@index([isFree])
114
+ }
115
+
116
+ model LessonQuestion {
117
+ id String @id @default(uuid())
118
+ lessonId String
119
+ question String
120
+ type String @default("multiple_choice")
121
+ order Int @default(0)
122
+ points Int @default(1)
123
+ explanation String?
124
+ createdAt DateTime @default(now())
125
+ updatedAt DateTime @updatedAt
126
+ lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
127
+ options QuestionOption[]
128
+
129
+ @@index([lessonId])
130
+ }
131
+
132
+ model QuestionOption {
133
+ id String @id @default(uuid())
134
+ questionId String
135
+ text String
136
+ isCorrect Boolean @default(false)
137
+ order Int @default(0)
138
+ question LessonQuestion @relation(fields: [questionId], references: [id], onDelete: Cascade)
139
+
140
+ @@index([questionId])
141
+ }
142
+
143
+ model Enrollment {
144
+ id String @id @default(uuid())
145
+ studentId String
146
+ courseId String
147
+ enrolledAt DateTime @default(now())
148
+ completedAt DateTime?
149
+ paidAmount Float?
150
+ paymentId String?
151
+ course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
152
+
153
+ screenshotAttempts Int @default(0)
154
+ screenRecordingAttempts Int @default(0)
155
+
156
+ @@unique([studentId, courseId])
157
+ @@index([studentId])
158
+ @@index([courseId])
159
+ }
160
+
161
+ model LessonPurchase {
162
+ id String @id @default(uuid())
163
+ studentId String
164
+ lessonId String
165
+ courseId String
166
+ paidAmount Float
167
+ paymentId String?
168
+ purchasedAt DateTime @default(now())
169
+ course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
170
+ lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
171
+
172
+ @@unique([studentId, lessonId])
173
+ @@index([studentId])
174
+ @@index([lessonId])
175
+ @@index([courseId])
176
+ }
177
+
178
+ model WatchProgress {
179
+ id String @id @default(uuid())
180
+ lessonId String
181
+ studentId String
182
+ watchedSeconds Int @default(0)
183
+ lastPosition Int @default(0)
184
+ completed Boolean @default(false)
185
+ lastWatchedAt DateTime @default(now())
186
+ createdAt DateTime @default(now())
187
+ updatedAt DateTime @updatedAt
188
+ lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
189
+
190
+ @@unique([lessonId, studentId])
191
+ @@index([studentId])
192
+ @@index([lessonId])
193
+ }
194
+
195
+ model Asset {
196
+ id String @id @default(uuid())
197
+ title String
198
+ type String
199
+ url String
200
+ lessonId String
201
+ createdAt DateTime @default(now())
202
+ size Int?
203
+
204
+ @@index([lessonId])
205
+ }
206
+
207
+ model VideoNote {
208
+ id String @id @default(uuid())
209
+ lessonId String
210
+ studentId String
211
+ timestamp Int
212
+ content String
213
+ color String @default("default")
214
+ createdAt DateTime @default(now())
215
+ updatedAt DateTime @updatedAt
216
+ lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
217
+
218
+ @@index([lessonId, studentId])
219
+ @@index([studentId])
220
+ }
221
+
222
+ model DeviceSession {
223
+ id String @id @default(uuid())
224
+ studentId String
225
+ courseId String
226
+ deviceId String
227
+ deviceName String?
228
+ deviceType String?
229
+ lastActiveAt DateTime @default(now())
230
+ createdAt DateTime @default(now())
231
+
232
+ @@unique([studentId, courseId, deviceId])
233
+ @@index([studentId, courseId])
234
+ @@index([lastActiveAt])
235
+ }
236
+
237
+ model Thing {
238
+ id String @id @default(uuid())
239
+ title String
240
+ description String?
241
+ status String @default("pending")
242
+ priority Int @default(0)
243
+ createdAt DateTime @default(now())
244
+ updatedAt DateTime @updatedAt
245
+ }
246
+
247
+ model Wallet {
248
+ id String @id @default(uuid())
249
+ userId String @unique
250
+ balance Float @default(0)
251
+ currency String @default("EGP")
252
+ createdAt DateTime @default(now())
253
+ updatedAt DateTime @updatedAt
254
+ transactions WalletTransaction[]
255
+ }
256
+
257
+ model SavedPaymentMethod {
258
+ id String @id @default(uuid())
259
+ userId String
260
+ cardBrand String
261
+ cardLast4 String
262
+ cardExpiryMonth String?
263
+ cardExpiryYear String?
264
+ paymobToken String
265
+ isDefault Boolean @default(false)
266
+ createdAt DateTime @default(now())
267
+ updatedAt DateTime @updatedAt
268
+
269
+ @@index([userId])
270
+ }
271
+
272
+ model WalletTransaction {
273
+ id String @id @default(uuid())
274
+ walletId String
275
+ amount Float
276
+ type String
277
+ status String @default("pending")
278
+ paymobOrderId String?
279
+ paymobTxnId String?
280
+ paymentMethod String?
281
+ description String?
282
+ metadata String?
283
+ createdAt DateTime @default(now())
284
+ updatedAt DateTime @updatedAt
285
+ wallet Wallet @relation(fields: [walletId], references: [id])
286
+
287
+ @@index([walletId])
288
+ @@index([paymobOrderId])
289
+ @@index([paymobTxnId])
290
+ }
291
+
292
+ model PayoutRequest {
293
+ id String @id @default(uuid())
294
+ teacherId String
295
+ amount Float
296
+ status String @default("pending")
297
+ payoutMethod String
298
+ walletIssuer String?
299
+ walletMsisdn String?
300
+ bankFullName String?
301
+ bankCardNumber String?
302
+ bankCode String?
303
+ bankTxnType String?
304
+ adminNotes String?
305
+ receiptUrl String?
306
+ processedBy String?
307
+ processedAt DateTime?
308
+ rejectionReason String?
309
+ createdAt DateTime @default(now())
310
+ updatedAt DateTime @updatedAt
311
+
312
+ @@index([teacherId])
313
+ @@index([status])
314
+ @@index([createdAt])
315
+ }
316
+
317
+