@trycompai/db 1.3.17 → 1.3.18

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.
@@ -14,161 +14,165 @@ datasource db {
14
14
 
15
15
  // ===== attachments.prisma =====
16
16
  model Attachment {
17
- id String @id @default(dbgenerated("generate_prefixed_cuid('att'::text)"))
18
- name String
19
- url String
20
- type AttachmentType
21
- entityId String
22
- entityType AttachmentEntityType
17
+ id String @id @default(dbgenerated("generate_prefixed_cuid('att'::text)"))
18
+ name String
19
+ url String
20
+ type AttachmentType
21
+ entityId String
22
+ entityType AttachmentEntityType
23
23
 
24
- // Dates
25
- createdAt DateTime @default(now())
26
- updatedAt DateTime @updatedAt
24
+ // Dates
25
+ createdAt DateTime @default(now())
26
+ updatedAt DateTime @updatedAt
27
27
 
28
- // Relationships
29
- organizationId String
30
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
31
- comment Comment? @relation(fields: [commentId], references: [id])
32
- commentId String?
28
+ // Relationships
29
+ organizationId String
30
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
31
+ comment Comment? @relation(fields: [commentId], references: [id])
32
+ commentId String?
33
33
 
34
- @@index([entityId, entityType])
34
+ @@index([entityId, entityType])
35
35
  }
36
36
 
37
37
  enum AttachmentEntityType {
38
- task
39
- vendor
40
- risk
41
- comment
38
+ task
39
+ vendor
40
+ risk
41
+ comment
42
+ trust_nda
42
43
  }
43
44
 
44
45
  enum AttachmentType {
45
- image
46
- video
47
- audio
48
- document
49
- other
46
+ image
47
+ video
48
+ audio
49
+ document
50
+ other
50
51
  }
51
52
 
52
53
 
53
54
  // ===== auth.prisma =====
54
55
  model User {
55
- id String @id @default(dbgenerated("generate_prefixed_cuid('usr'::text)"))
56
- name String
57
- email String
58
- emailVerified Boolean
59
- image String?
60
- createdAt DateTime @default(now())
61
- updatedAt DateTime @updatedAt
62
- lastLogin DateTime?
63
-
64
- accounts Account[]
65
- auditLog AuditLog[]
66
- integrationResults IntegrationResult[]
67
- invitations Invitation[]
68
- members Member[]
69
- sessions Session[]
56
+ id String @id @default(dbgenerated("generate_prefixed_cuid('usr'::text)"))
57
+ name String
58
+ email String
59
+ emailVerified Boolean
60
+ image String?
61
+ createdAt DateTime @default(now())
62
+ updatedAt DateTime @updatedAt
63
+ lastLogin DateTime?
64
+
65
+ accounts Account[]
66
+ auditLog AuditLog[]
67
+ integrationResults IntegrationResult[]
68
+ invitations Invitation[]
69
+ members Member[]
70
+ sessions Session[]
70
71
 
71
- @@unique([email])
72
+ @@unique([email])
72
73
  }
73
74
 
74
75
  model EmployeeTrainingVideoCompletion {
75
- id String @id @default(dbgenerated("generate_prefixed_cuid('evc'::text)"))
76
- completedAt DateTime?
77
- videoId String
76
+ id String @id @default(dbgenerated("generate_prefixed_cuid('evc'::text)"))
77
+ completedAt DateTime?
78
+ videoId String
78
79
 
79
- memberId String
80
- member Member @relation(fields: [memberId], references: [id], onDelete: Cascade)
80
+ memberId String
81
+ member Member @relation(fields: [memberId], references: [id], onDelete: Cascade)
81
82
 
82
- @@unique([memberId, videoId])
83
- @@index([memberId])
83
+ @@unique([memberId, videoId])
84
+ @@index([memberId])
84
85
  }
85
86
 
86
87
  model Session {
87
- id String @id @default(dbgenerated("generate_prefixed_cuid('ses'::text)"))
88
- expiresAt DateTime
89
- token String
90
- createdAt DateTime @default(now())
91
- updatedAt DateTime @updatedAt
92
- ipAddress String?
93
- userAgent String?
94
- userId String
95
- activeOrganizationId String?
96
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
97
-
98
- @@unique([token])
88
+ id String @id @default(dbgenerated("generate_prefixed_cuid('ses'::text)"))
89
+ expiresAt DateTime
90
+ token String
91
+ createdAt DateTime @default(now())
92
+ updatedAt DateTime @updatedAt
93
+ ipAddress String?
94
+ userAgent String?
95
+ userId String
96
+ activeOrganizationId String?
97
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
98
+
99
+ @@unique([token])
99
100
  }
100
101
 
101
102
  model Account {
102
- id String @id @default(dbgenerated("generate_prefixed_cuid('acc'::text)"))
103
- accountId String
104
- providerId String
105
- userId String
106
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
107
- accessToken String?
108
- refreshToken String?
109
- idToken String?
110
- accessTokenExpiresAt DateTime?
111
- refreshTokenExpiresAt DateTime?
112
- scope String?
113
- password String?
114
- createdAt DateTime
115
- updatedAt DateTime
103
+ id String @id @default(dbgenerated("generate_prefixed_cuid('acc'::text)"))
104
+ accountId String
105
+ providerId String
106
+ userId String
107
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
108
+ accessToken String?
109
+ refreshToken String?
110
+ idToken String?
111
+ accessTokenExpiresAt DateTime?
112
+ refreshTokenExpiresAt DateTime?
113
+ scope String?
114
+ password String?
115
+ createdAt DateTime
116
+ updatedAt DateTime
116
117
  }
117
118
 
118
119
  model Verification {
119
- id String @id @default(dbgenerated("generate_prefixed_cuid('ver'::text)"))
120
- identifier String
121
- value String
122
- expiresAt DateTime
123
- createdAt DateTime @default(now())
124
- updatedAt DateTime @updatedAt
120
+ id String @id @default(dbgenerated("generate_prefixed_cuid('ver'::text)"))
121
+ identifier String
122
+ value String
123
+ expiresAt DateTime
124
+ createdAt DateTime @default(now())
125
+ updatedAt DateTime @updatedAt
125
126
  }
126
127
 
127
128
  // JWT Plugin - Required by Better Auth JWT plugin
128
129
  // https://www.better-auth.com/docs/plugins/jwt
129
130
  model Jwks {
130
- id String @id @default(dbgenerated("generate_prefixed_cuid('jwk'::text)"))
131
- publicKey String
132
- privateKey String
133
- createdAt DateTime @default(now())
131
+ id String @id @default(dbgenerated("generate_prefixed_cuid('jwk'::text)"))
132
+ publicKey String
133
+ privateKey String
134
+ createdAt DateTime @default(now())
134
135
 
135
- @@map("jwks")
136
+ @@map("jwks")
136
137
  }
137
138
 
138
139
  model Member {
139
- id String @id @default(dbgenerated("generate_prefixed_cuid('mem'::text)"))
140
- organizationId String
141
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
142
- userId String
143
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
144
- role String // Purposefully a string, since BetterAuth doesn't support enums this way
145
- createdAt DateTime @default(now())
146
-
147
- department Departments @default(none)
148
- isActive Boolean @default(true)
149
- deactivated Boolean @default(false)
150
- employeeTrainingVideoCompletion EmployeeTrainingVideoCompletion[]
151
- fleetDmLabelId Int?
140
+ id String @id @default(dbgenerated("generate_prefixed_cuid('mem'::text)"))
141
+ organizationId String
142
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
143
+ userId String
144
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
145
+ role String // Purposefully a string, since BetterAuth doesn't support enums this way
146
+ createdAt DateTime @default(now())
152
147
 
153
- assignedPolicies Policy[] @relation("PolicyAssignee") // Policies where this member is an assignee
154
- approvedPolicies Policy[] @relation("PolicyApprover") // Policies where this member is an approver
155
- risks Risk[]
156
- tasks Task[]
157
- vendors Vendor[]
158
- comments Comment[]
159
- auditLogs AuditLog[]
148
+ department Departments @default(none)
149
+ isActive Boolean @default(true)
150
+ deactivated Boolean @default(false)
151
+ employeeTrainingVideoCompletion EmployeeTrainingVideoCompletion[]
152
+ fleetDmLabelId Int?
153
+
154
+ assignedPolicies Policy[] @relation("PolicyAssignee") // Policies where this member is an assignee
155
+ approvedPolicies Policy[] @relation("PolicyApprover") // Policies where this member is an approver
156
+ risks Risk[]
157
+ tasks Task[]
158
+ vendors Vendor[]
159
+ comments Comment[]
160
+ auditLogs AuditLog[]
161
+ reviewedAccessRequests TrustAccessRequest[] @relation("TrustAccessRequestReviewer")
162
+ issuedGrants TrustAccessGrant[] @relation("IssuedGrants")
163
+ revokedGrants TrustAccessGrant[] @relation("RevokedGrants")
160
164
  }
161
165
 
162
166
  model Invitation {
163
- id String @id @default(dbgenerated("generate_prefixed_cuid('inv'::text)"))
164
- organizationId String
165
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
166
- email String
167
- role String // Purposefully a string, since BetterAuth doesn't support enums this way
168
- status String
169
- expiresAt DateTime
170
- inviterId String
171
- user User @relation(fields: [inviterId], references: [id], onDelete: Cascade)
167
+ id String @id @default(dbgenerated("generate_prefixed_cuid('inv'::text)"))
168
+ organizationId String
169
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
170
+ email String
171
+ role String // Purposefully a string, since BetterAuth doesn't support enums this way
172
+ status String
173
+ expiresAt DateTime
174
+ inviterId String
175
+ user User @relation(fields: [inviterId], references: [id], onDelete: Cascade)
172
176
  }
173
177
 
174
178
  // This is only for the app to consume, shouldn't be enforced by DB
@@ -182,111 +186,111 @@ enum Role {
182
186
  }
183
187
 
184
188
  enum PolicyStatus {
185
- draft
186
- published
187
- needs_review
189
+ draft
190
+ published
191
+ needs_review
188
192
  }
189
193
 
190
194
 
191
195
  // ===== automation-run.prisma =====
192
196
  model EvidenceAutomationRun {
193
- id String @id @default(dbgenerated("generate_prefixed_cuid('ear'::text)"))
194
- createdAt DateTime @default(now())
195
- updatedAt DateTime @updatedAt
196
-
197
- // Relations
198
- evidenceAutomationId String
199
- evidenceAutomation EvidenceAutomation @relation(fields: [evidenceAutomationId], references: [id], onDelete: Cascade)
200
-
201
- // Run details
202
- status EvidenceAutomationRunStatus @default(pending)
203
- startedAt DateTime?
204
- completedAt DateTime?
205
-
206
- // Results
207
- success Boolean?
208
- error String?
209
- logs Json?
210
- output Json?
211
-
212
- // Evaluation
213
- evaluationStatus EvidenceAutomationEvaluationStatus?
214
- evaluationReason String?
215
-
216
- // Metadata
217
- triggeredBy EvidenceAutomationTrigger @default(scheduled)
218
- runDuration Int? // in milliseconds
219
- version Int? // Version number that was executed (null = draft)
220
- Task Task? @relation(fields: [taskId], references: [id])
221
- taskId String?
222
-
223
- @@index([evidenceAutomationId])
224
- @@index([status])
225
- @@index([createdAt])
226
- @@index([version])
197
+ id String @id @default(dbgenerated("generate_prefixed_cuid('ear'::text)"))
198
+ createdAt DateTime @default(now())
199
+ updatedAt DateTime @updatedAt
200
+
201
+ // Relations
202
+ evidenceAutomationId String
203
+ evidenceAutomation EvidenceAutomation @relation(fields: [evidenceAutomationId], references: [id], onDelete: Cascade)
204
+
205
+ // Run details
206
+ status EvidenceAutomationRunStatus @default(pending)
207
+ startedAt DateTime?
208
+ completedAt DateTime?
209
+
210
+ // Results
211
+ success Boolean?
212
+ error String?
213
+ logs Json?
214
+ output Json?
215
+
216
+ // Evaluation
217
+ evaluationStatus EvidenceAutomationEvaluationStatus?
218
+ evaluationReason String?
219
+
220
+ // Metadata
221
+ triggeredBy EvidenceAutomationTrigger @default(scheduled)
222
+ runDuration Int? // in milliseconds
223
+ version Int? // Version number that was executed (null = draft)
224
+ Task Task? @relation(fields: [taskId], references: [id])
225
+ taskId String?
226
+
227
+ @@index([evidenceAutomationId])
228
+ @@index([status])
229
+ @@index([createdAt])
230
+ @@index([version])
227
231
  }
228
232
 
229
233
  enum EvidenceAutomationRunStatus {
230
- pending
231
- running
232
- completed
233
- failed
234
- cancelled
234
+ pending
235
+ running
236
+ completed
237
+ failed
238
+ cancelled
235
239
  }
236
240
 
237
241
  enum EvidenceAutomationTrigger {
238
- manual
239
- scheduled
240
- api
242
+ manual
243
+ scheduled
244
+ api
241
245
  }
242
246
 
243
247
  enum EvidenceAutomationEvaluationStatus {
244
- pass
245
- fail
248
+ pass
249
+ fail
246
250
  }
247
251
 
248
252
 
249
253
  // ===== automation-version.prisma =====
250
254
  model EvidenceAutomationVersion {
251
- id String @id @default(dbgenerated("generate_prefixed_cuid('eav'::text)"))
252
- createdAt DateTime @default(now())
253
- updatedAt DateTime @updatedAt
255
+ id String @id @default(dbgenerated("generate_prefixed_cuid('eav'::text)"))
256
+ createdAt DateTime @default(now())
257
+ updatedAt DateTime @updatedAt
254
258
 
255
- // Relations
256
- evidenceAutomationId String
257
- evidenceAutomation EvidenceAutomation @relation(fields: [evidenceAutomationId], references: [id], onDelete: Cascade)
259
+ // Relations
260
+ evidenceAutomationId String
261
+ evidenceAutomation EvidenceAutomation @relation(fields: [evidenceAutomationId], references: [id], onDelete: Cascade)
258
262
 
259
- // Version details
260
- version Int // Sequential version number (1, 2, 3...)
261
- scriptKey String // S3 key for this version's script
262
- publishedBy String? // User ID who published
263
- changelog String? // Optional description of changes
263
+ // Version details
264
+ version Int // Sequential version number (1, 2, 3...)
265
+ scriptKey String // S3 key for this version's script
266
+ publishedBy String? // User ID who published
267
+ changelog String? // Optional description of changes
264
268
 
265
- @@unique([evidenceAutomationId, version])
266
- @@index([evidenceAutomationId])
267
- @@index([createdAt])
269
+ @@unique([evidenceAutomationId, version])
270
+ @@index([evidenceAutomationId])
271
+ @@index([createdAt])
268
272
  }
269
273
 
270
274
 
271
275
  // ===== automation.prisma =====
272
276
  model EvidenceAutomation {
273
- id String @id @default(dbgenerated("generate_prefixed_cuid('aut'::text)"))
274
- name String
275
- description String?
276
- createdAt DateTime @default(now())
277
- isEnabled Boolean @default(false)
277
+ id String @id @default(dbgenerated("generate_prefixed_cuid('aut'::text)"))
278
+ name String
279
+ description String?
280
+ createdAt DateTime @default(now())
281
+ isEnabled Boolean @default(false)
278
282
 
279
- chatHistory String?
280
- evaluationCriteria String?
283
+ chatHistory String?
284
+ evaluationCriteria String?
281
285
 
282
- taskId String
283
- task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
286
+ taskId String
287
+ task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
284
288
 
285
- // Relations
286
- runs EvidenceAutomationRun[]
287
- versions EvidenceAutomationVersion[]
289
+ // Relations
290
+ runs EvidenceAutomationRun[]
291
+ versions EvidenceAutomationVersion[]
288
292
 
289
- @@index([taskId])
293
+ @@index([taskId])
290
294
  }
291
295
 
292
296
 
@@ -322,22 +326,22 @@ enum CommentEntityType {
322
326
 
323
327
  // ===== context.prisma =====
324
328
  model Context {
325
- id String @id @default(dbgenerated("generate_prefixed_cuid('ctx'::text)"))
326
- organizationId String
327
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
329
+ id String @id @default(dbgenerated("generate_prefixed_cuid('ctx'::text)"))
330
+ organizationId String
331
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
328
332
 
329
- question String
330
- answer String
333
+ question String
334
+ answer String
331
335
 
332
- tags String[]
336
+ tags String[]
333
337
 
334
- createdAt DateTime @default(now())
335
- updatedAt DateTime @updatedAt
338
+ createdAt DateTime @default(now())
339
+ updatedAt DateTime @updatedAt
336
340
 
337
- @@index([organizationId])
338
- @@index([question])
339
- @@index([answer])
340
- @@index([tags])
341
+ @@index([organizationId])
342
+ @@index([question])
343
+ @@index([answer])
344
+ @@index([tags])
341
345
  }
342
346
 
343
347
 
@@ -368,99 +372,99 @@ model Control {
368
372
  // ===== framework-editor.prisma =====
369
373
  // --- Data for Framework Editor ---
370
374
  model FrameworkEditorVideo {
371
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_vi'::text)"))
372
- title String
373
- description String
374
- youtubeId String
375
- url String
375
+ id String @id @default(dbgenerated("generate_prefixed_cuid('frk_vi'::text)"))
376
+ title String
377
+ description String
378
+ youtubeId String
379
+ url String
376
380
 
377
- // Dates
378
- createdAt DateTime @default(now())
379
- updatedAt DateTime @default(now()) @updatedAt
381
+ // Dates
382
+ createdAt DateTime @default(now())
383
+ updatedAt DateTime @default(now()) @updatedAt
380
384
  }
381
385
 
382
386
  model FrameworkEditorFramework {
383
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk'::text)"))
384
- name String // e.g., "soc2", "iso27001"
385
- version String
386
- description String
387
- visible Boolean @default(false)
387
+ id String @id @default(dbgenerated("generate_prefixed_cuid('frk'::text)"))
388
+ name String // e.g., "soc2", "iso27001"
389
+ version String
390
+ description String
391
+ visible Boolean @default(false)
388
392
 
389
- requirements FrameworkEditorRequirement[]
390
- frameworkInstances FrameworkInstance[]
393
+ requirements FrameworkEditorRequirement[]
394
+ frameworkInstances FrameworkInstance[]
391
395
 
392
- // Dates
393
- createdAt DateTime @default(now())
394
- updatedAt DateTime @default(now()) @updatedAt
396
+ // Dates
397
+ createdAt DateTime @default(now())
398
+ updatedAt DateTime @default(now()) @updatedAt
395
399
  }
396
400
 
397
401
  model FrameworkEditorRequirement {
398
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_rq'::text)"))
399
- frameworkId String
400
- framework FrameworkEditorFramework @relation(fields: [frameworkId], references: [id])
402
+ id String @id @default(dbgenerated("generate_prefixed_cuid('frk_rq'::text)"))
403
+ frameworkId String
404
+ framework FrameworkEditorFramework @relation(fields: [frameworkId], references: [id])
401
405
 
402
- name String // Original requirement ID within that framework, e.g., "Privacy"
403
- identifier String @default("") // Unique identifier for the requirement, e.g., "cc1-1"
404
- description String
406
+ name String // Original requirement ID within that framework, e.g., "Privacy"
407
+ identifier String @default("") // Unique identifier for the requirement, e.g., "cc1-1"
408
+ description String
405
409
 
406
- controlTemplates FrameworkEditorControlTemplate[]
407
- requirementMaps RequirementMap[]
410
+ controlTemplates FrameworkEditorControlTemplate[]
411
+ requirementMaps RequirementMap[]
408
412
 
409
- // Dates
410
- createdAt DateTime @default(now())
411
- updatedAt DateTime @default(now()) @updatedAt
413
+ // Dates
414
+ createdAt DateTime @default(now())
415
+ updatedAt DateTime @default(now()) @updatedAt
412
416
  }
413
417
 
414
418
  model FrameworkEditorPolicyTemplate {
415
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_pt'::text)"))
416
- name String
417
- description String
418
- frequency Frequency // Using the enum from shared.prisma
419
- department Departments // Using the enum from shared.prisma
420
- content Json
419
+ id String @id @default(dbgenerated("generate_prefixed_cuid('frk_pt'::text)"))
420
+ name String
421
+ description String
422
+ frequency Frequency // Using the enum from shared.prisma
423
+ department Departments // Using the enum from shared.prisma
424
+ content Json
421
425
 
422
- controlTemplates FrameworkEditorControlTemplate[]
426
+ controlTemplates FrameworkEditorControlTemplate[]
423
427
 
424
- // Dates
425
- createdAt DateTime @default(now())
426
- updatedAt DateTime @default(now()) @updatedAt
428
+ // Dates
429
+ createdAt DateTime @default(now())
430
+ updatedAt DateTime @default(now()) @updatedAt
427
431
 
428
- // Instances
429
- policies Policy[]
432
+ // Instances
433
+ policies Policy[]
430
434
  }
431
435
 
432
436
  model FrameworkEditorTaskTemplate {
433
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_tt'::text)"))
434
- name String
435
- description String
436
- frequency Frequency // Using the enum from shared.prisma
437
- department Departments // Using the enum from shared.prisma
437
+ id String @id @default(dbgenerated("generate_prefixed_cuid('frk_tt'::text)"))
438
+ name String
439
+ description String
440
+ frequency Frequency // Using the enum from shared.prisma
441
+ department Departments // Using the enum from shared.prisma
438
442
 
439
- controlTemplates FrameworkEditorControlTemplate[]
443
+ controlTemplates FrameworkEditorControlTemplate[]
440
444
 
441
- // Dates
442
- createdAt DateTime @default(now())
443
- updatedAt DateTime @default(now()) @updatedAt
445
+ // Dates
446
+ createdAt DateTime @default(now())
447
+ updatedAt DateTime @default(now()) @updatedAt
444
448
 
445
- // Instances
446
- tasks Task[]
449
+ // Instances
450
+ tasks Task[]
447
451
  }
448
452
 
449
453
  model FrameworkEditorControlTemplate {
450
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_ct'::text)"))
451
- name String
452
- description String
454
+ id String @id @default(dbgenerated("generate_prefixed_cuid('frk_ct'::text)"))
455
+ name String
456
+ description String
453
457
 
454
- policyTemplates FrameworkEditorPolicyTemplate[]
455
- requirements FrameworkEditorRequirement[]
456
- taskTemplates FrameworkEditorTaskTemplate[]
458
+ policyTemplates FrameworkEditorPolicyTemplate[]
459
+ requirements FrameworkEditorRequirement[]
460
+ taskTemplates FrameworkEditorTaskTemplate[]
457
461
 
458
- // Dates
459
- createdAt DateTime @default(now())
460
- updatedAt DateTime @default(now()) @updatedAt
462
+ // Dates
463
+ createdAt DateTime @default(now())
464
+ updatedAt DateTime @default(now()) @updatedAt
461
465
 
462
- // Instances
463
- controls Control[]
466
+ // Instances
467
+ controls Control[]
464
468
  }
465
469
 
466
470
 
@@ -516,24 +520,59 @@ model IntegrationResult {
516
520
  }
517
521
 
518
522
 
523
+ // ===== knowledge-base-document.prisma =====
524
+ model KnowledgeBaseDocument {
525
+ id String @id @default(dbgenerated("generate_prefixed_cuid('kbd'::text)"))
526
+ name String // Original filename
527
+ description String? // Optional user description/notes
528
+ s3Key String // S3 storage key (e.g., "org123/knowledge-base-documents/timestamp-file.pdf")
529
+ fileType String // MIME type (e.g., "application/pdf")
530
+ fileSize Int // File size in bytes
531
+ processingStatus KnowledgeBaseDocumentProcessingStatus @default(pending) // Track indexing status
532
+ processedAt DateTime? // When indexing completed
533
+ triggerRunId String? // Trigger.dev run ID for tracking processing progress
534
+
535
+ // Dates
536
+ createdAt DateTime @default(now())
537
+ updatedAt DateTime @updatedAt
538
+
539
+ // Relationships
540
+ organizationId String
541
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
542
+
543
+ @@index([organizationId])
544
+ @@index([organizationId, processingStatus])
545
+ @@index([s3Key])
546
+ @@index([triggerRunId])
547
+ }
548
+
549
+ enum KnowledgeBaseDocumentProcessingStatus {
550
+ pending // Uploaded but not yet processed/indexed
551
+ processing // Currently being processed/indexed
552
+ completed // Successfully indexed in vector database
553
+ failed // Processing failed
554
+ }
555
+
556
+
557
+
519
558
  // ===== onboarding.prisma =====
520
559
  model Onboarding {
521
- organizationId String @id
522
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
523
- policies Boolean @default(false)
524
- employees Boolean @default(false)
525
- vendors Boolean @default(false)
526
- integrations Boolean @default(false)
527
- risk Boolean @default(false)
528
- team Boolean @default(false)
529
- tasks Boolean @default(false)
530
- callBooked Boolean @default(false)
531
- companyBookingDetails Json?
532
- companyDetails Json?
533
- triggerJobId String?
534
- triggerJobCompleted Boolean @default(false)
560
+ organizationId String @id
561
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
562
+ policies Boolean @default(false)
563
+ employees Boolean @default(false)
564
+ vendors Boolean @default(false)
565
+ integrations Boolean @default(false)
566
+ risk Boolean @default(false)
567
+ team Boolean @default(false)
568
+ tasks Boolean @default(false)
569
+ callBooked Boolean @default(false)
570
+ companyBookingDetails Json?
571
+ companyDetails Json?
572
+ triggerJobId String?
573
+ triggerJobCompleted Boolean @default(false)
535
574
 
536
- @@index([organizationId])
575
+ @@index([organizationId])
537
576
  }
538
577
 
539
578
 
@@ -555,22 +594,28 @@ model Organization {
555
594
  fleetDmLabelId Int?
556
595
  isFleetSetupCompleted Boolean @default(false)
557
596
 
558
- apiKeys ApiKey[]
559
- auditLog AuditLog[]
560
- controls Control[]
561
- frameworkInstances FrameworkInstance[]
562
- integrations Integration[]
563
- invitations Invitation[]
564
- members Member[]
565
- policy Policy[]
566
- risk Risk[]
567
- vendors Vendor[]
568
- tasks Task[]
569
- comments Comment[]
570
- attachments Attachment[]
571
- trust Trust[]
572
- context Context[]
573
- secrets Secret[]
597
+ apiKeys ApiKey[]
598
+ auditLog AuditLog[]
599
+ controls Control[]
600
+ frameworkInstances FrameworkInstance[]
601
+ integrations Integration[]
602
+ invitations Invitation[]
603
+ members Member[]
604
+ policy Policy[]
605
+ risk Risk[]
606
+ vendors Vendor[]
607
+ tasks Task[]
608
+ comments Comment[]
609
+ attachments Attachment[]
610
+ trust Trust[]
611
+ context Context[]
612
+ secrets Secret[]
613
+ trustAccessRequests TrustAccessRequest[]
614
+ trustNdaAgreements TrustNDAAgreement[]
615
+ trustDocuments TrustDocument[]
616
+ knowledgeBaseDocuments KnowledgeBaseDocument[]
617
+ questionnaires Questionnaire[]
618
+ securityQuestionnaireManualAnswers SecurityQuestionnaireManualAnswer[]
574
619
 
575
620
  @@index([slug])
576
621
  }
@@ -618,21 +663,85 @@ model Policy {
618
663
  }
619
664
 
620
665
 
666
+ // ===== questionnaire.prisma =====
667
+ model Questionnaire {
668
+ id String @id @default(dbgenerated("generate_prefixed_cuid('qst'::text)"))
669
+ filename String // Original filename
670
+ s3Key String // S3 storage key for the uploaded file
671
+ fileType String // MIME type (e.g., "application/pdf")
672
+ fileSize Int // File size in bytes
673
+ status QuestionnaireStatus @default(parsing) // Parsing status
674
+ parsedAt DateTime? // When parsing completed
675
+ totalQuestions Int @default(0) // Total number of questions parsed
676
+ answeredQuestions Int @default(0) // Number of questions with answers
677
+
678
+ // Dates
679
+ createdAt DateTime @default(now())
680
+ updatedAt DateTime @updatedAt
681
+
682
+ // Relationships
683
+ organizationId String
684
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
685
+ questions QuestionnaireQuestionAnswer[]
686
+ manualAnswers SecurityQuestionnaireManualAnswer[] // Manual answers saved from this questionnaire
687
+
688
+ @@index([organizationId])
689
+ @@index([organizationId, createdAt])
690
+ @@index([status])
691
+ }
692
+
693
+ model QuestionnaireQuestionAnswer {
694
+ id String @id @default(dbgenerated("generate_prefixed_cuid('qqa'::text)"))
695
+ question String // The question text
696
+ answer String? // The answer (nullable if not provided in file or not generated yet)
697
+ status QuestionnaireAnswerStatus @default(untouched) // Answer status
698
+ questionIndex Int // Order/index of the question in the questionnaire
699
+ sources Json? // Sources used for generated answers (array of source objects)
700
+ generatedAt DateTime? // When answer was generated (if status is generated)
701
+ updatedBy String? // User ID who last updated the answer (if manual)
702
+
703
+ // Dates
704
+ createdAt DateTime @default(now())
705
+ updatedAt DateTime @updatedAt
706
+
707
+ // Relationships
708
+ questionnaireId String
709
+ questionnaire Questionnaire @relation(fields: [questionnaireId], references: [id], onDelete: Cascade)
710
+
711
+ @@index([questionnaireId])
712
+ @@index([questionnaireId, questionIndex])
713
+ @@index([status])
714
+ }
715
+
716
+ enum QuestionnaireStatus {
717
+ parsing // Currently being parsed
718
+ completed // Successfully parsed
719
+ failed // Parsing failed
720
+ }
721
+
722
+ enum QuestionnaireAnswerStatus {
723
+ untouched // No answer yet (empty or not generated)
724
+ generated // AI generated answer
725
+ manual // Manually written/edited by user
726
+ }
727
+
728
+
729
+
621
730
  // ===== requirement.prisma =====
622
731
  model RequirementMap {
623
- id String @id @default(dbgenerated("generate_prefixed_cuid('req'::text)"))
732
+ id String @id @default(dbgenerated("generate_prefixed_cuid('req'::text)"))
624
733
 
625
- requirementId String
626
- requirement FrameworkEditorRequirement @relation(fields: [requirementId], references: [id], onDelete: Cascade)
734
+ requirementId String
735
+ requirement FrameworkEditorRequirement @relation(fields: [requirementId], references: [id], onDelete: Cascade)
627
736
 
628
- controlId String
629
- control Control @relation(fields: [controlId], references: [id], onDelete: Cascade)
737
+ controlId String
738
+ control Control @relation(fields: [controlId], references: [id], onDelete: Cascade)
630
739
 
631
- frameworkInstanceId String
632
- frameworkInstance FrameworkInstance @relation(fields: [frameworkInstanceId], references: [id], onDelete: Cascade)
740
+ frameworkInstanceId String
741
+ frameworkInstance FrameworkInstance @relation(fields: [frameworkInstanceId], references: [id], onDelete: Cascade)
633
742
 
634
- @@unique([controlId, frameworkInstanceId, requirementId])
635
- @@index([requirementId, frameworkInstanceId])
743
+ @@unique([controlId, frameworkInstanceId, requirementId])
744
+ @@index([requirementId, frameworkInstanceId])
636
745
  }
637
746
 
638
747
 
@@ -699,228 +808,406 @@ enum RiskStatus {
699
808
 
700
809
  // ===== secret.prisma =====
701
810
  model Secret {
702
- id String @id @default(dbgenerated("generate_prefixed_cuid('sec'::text)"))
703
- organizationId String @map("organization_id")
704
- name String
705
- value String @db.Text // Encrypted value
706
- description String? @db.Text
707
- category String? // e.g., "api", "webhook", "database", etc.
708
- lastUsedAt DateTime? @map("last_used_at")
709
- createdAt DateTime @default(now()) @map("created_at")
710
- updatedAt DateTime @updatedAt @map("updated_at")
811
+ id String @id @default(dbgenerated("generate_prefixed_cuid('sec'::text)"))
812
+ organizationId String @map("organization_id")
813
+ name String
814
+ value String @db.Text // Encrypted value
815
+ description String? @db.Text
816
+ category String? // e.g., "api", "webhook", "database", etc.
817
+ lastUsedAt DateTime? @map("last_used_at")
818
+ createdAt DateTime @default(now()) @map("created_at")
819
+ updatedAt DateTime @updatedAt @map("updated_at")
820
+
821
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
822
+
823
+ @@unique([organizationId, name])
824
+ @@map("secrets")
825
+ }
711
826
 
712
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
713
827
 
714
- @@unique([organizationId, name])
715
- @@map("secrets")
828
+ // ===== security-questionnaire-manual-answer.prisma =====
829
+ model SecurityQuestionnaireManualAnswer {
830
+ id String @id @default(dbgenerated("generate_prefixed_cuid('sqma'::text)"))
831
+ question String // The question text
832
+ answer String // The answer text (required for saved answers)
833
+ tags String[] @default([]) // Optional tags for categorization
834
+
835
+ // Optional reference to original questionnaire (for tracking)
836
+ sourceQuestionnaireId String?
837
+ sourceQuestionnaire Questionnaire? @relation(fields: [sourceQuestionnaireId], references: [id], onDelete: SetNull)
838
+
839
+ // User who created/updated this answer
840
+ createdBy String? // User ID
841
+ updatedBy String? // User ID
842
+
843
+ // Dates
844
+ createdAt DateTime @default(now())
845
+ updatedAt DateTime @updatedAt
846
+
847
+ // Relationships
848
+ organizationId String
849
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
850
+
851
+ @@index([organizationId])
852
+ @@index([organizationId, question])
853
+ @@index([tags])
854
+ @@index([createdAt])
855
+ @@unique([organizationId, question]) // Prevent duplicate questions per organization
716
856
  }
717
857
 
718
858
 
859
+
719
860
  // ===== shared.prisma =====
720
861
  model ApiKey {
721
- id String @id @default(dbgenerated("generate_prefixed_cuid('apk'::text)"))
722
- name String
723
- key String @unique
724
- salt String?
725
- createdAt DateTime @default(now())
726
- expiresAt DateTime?
727
- lastUsedAt DateTime?
728
- isActive Boolean @default(true)
862
+ id String @id @default(dbgenerated("generate_prefixed_cuid('apk'::text)"))
863
+ name String
864
+ key String @unique
865
+ salt String?
866
+ createdAt DateTime @default(now())
867
+ expiresAt DateTime?
868
+ lastUsedAt DateTime?
869
+ isActive Boolean @default(true)
729
870
 
730
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
731
- organizationId String
871
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
872
+ organizationId String
732
873
 
733
- @@index([organizationId])
734
- @@index([key])
874
+ @@index([organizationId])
875
+ @@index([key])
735
876
  }
736
877
 
737
878
  model AuditLog {
738
- id String @id @default(dbgenerated("generate_prefixed_cuid('aud'::text)"))
739
- timestamp DateTime @default(now())
740
- organizationId String
741
- userId String
742
- memberId String?
743
- data Json
744
- description String?
745
- entityId String?
746
- entityType AuditLogEntityType?
747
-
748
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
749
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
750
- member Member? @relation(fields: [memberId], references: [id], onDelete: Cascade)
751
-
752
- @@index([userId])
753
- @@index([organizationId])
754
- @@index([memberId])
755
- @@index([entityType])
879
+ id String @id @default(dbgenerated("generate_prefixed_cuid('aud'::text)"))
880
+ timestamp DateTime @default(now())
881
+ organizationId String
882
+ userId String
883
+ memberId String?
884
+ data Json
885
+ description String?
886
+ entityId String?
887
+ entityType AuditLogEntityType?
888
+
889
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
890
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
891
+ member Member? @relation(fields: [memberId], references: [id], onDelete: Cascade)
892
+
893
+ @@index([userId])
894
+ @@index([organizationId])
895
+ @@index([memberId])
896
+ @@index([entityType])
756
897
  }
757
898
 
758
899
  enum AuditLogEntityType {
759
- organization
760
- framework
761
- requirement
762
- control
763
- policy
764
- task
765
- people
766
- risk
767
- vendor
768
- tests
769
- integration
900
+ organization
901
+ framework
902
+ requirement
903
+ control
904
+ policy
905
+ task
906
+ people
907
+ risk
908
+ vendor
909
+ tests
910
+ integration
911
+ trust
770
912
  }
771
913
 
772
914
  model GlobalVendors {
773
- website String @id @unique
774
- company_name String?
775
- legal_name String?
776
- company_description String?
777
- company_hq_address String?
778
- privacy_policy_url String?
779
- terms_of_service_url String?
780
- service_level_agreement_url String?
781
- security_page_url String?
782
- trust_page_url String?
783
- security_certifications String[]
784
- subprocessors String[]
785
- type_of_company String?
786
-
787
- approved Boolean @default(false)
788
- createdAt DateTime @default(now())
789
-
790
- @@index([website])
915
+ website String @id @unique
916
+ company_name String?
917
+ legal_name String?
918
+ company_description String?
919
+ company_hq_address String?
920
+ privacy_policy_url String?
921
+ terms_of_service_url String?
922
+ service_level_agreement_url String?
923
+ security_page_url String?
924
+ trust_page_url String?
925
+ security_certifications String[]
926
+ subprocessors String[]
927
+ type_of_company String?
928
+
929
+ approved Boolean @default(false)
930
+ createdAt DateTime @default(now())
931
+
932
+ @@index([website])
791
933
  }
792
934
 
793
935
  enum Departments {
794
- none
795
- admin
796
- gov
797
- hr
798
- it
799
- itsm
800
- qms
936
+ none
937
+ admin
938
+ gov
939
+ hr
940
+ it
941
+ itsm
942
+ qms
801
943
  }
802
944
 
803
945
  enum Frequency {
804
- monthly
805
- quarterly
806
- yearly
946
+ monthly
947
+ quarterly
948
+ yearly
807
949
  }
808
950
 
809
951
  enum Likelihood {
810
- very_unlikely
811
- unlikely
812
- possible
813
- likely
814
- very_likely
952
+ very_unlikely
953
+ unlikely
954
+ possible
955
+ likely
956
+ very_likely
815
957
  }
816
958
 
817
959
  enum Impact {
818
- insignificant
819
- minor
820
- moderate
821
- major
822
- severe
960
+ insignificant
961
+ minor
962
+ moderate
963
+ major
964
+ severe
823
965
  }
824
966
 
825
967
 
826
968
  // ===== task.prisma =====
827
969
  model Task {
828
- // Metadata
829
- id String @id @default(dbgenerated("generate_prefixed_cuid('tsk'::text)"))
830
- title String
831
- description String
832
- status TaskStatus @default(todo)
833
- frequency TaskFrequency?
834
- department Departments? @default(none)
835
- order Int @default(0)
836
-
837
- // Dates
838
- createdAt DateTime @default(now())
839
- updatedAt DateTime @updatedAt
840
- lastCompletedAt DateTime?
841
- reviewDate DateTime?
842
-
843
- // Relationships
844
- assigneeId String?
845
- assignee Member? @relation(fields: [assigneeId], references: [id])
846
- organizationId String
847
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
848
- taskTemplateId String?
849
- taskTemplate FrameworkEditorTaskTemplate? @relation(fields: [taskTemplateId], references: [id])
850
- controls Control[]
851
- vendors Vendor[]
852
- risks Risk[]
853
- evidenceAutomations EvidenceAutomation[]
854
-
855
- EvidenceAutomationRun EvidenceAutomationRun[]
970
+ // Metadata
971
+ id String @id @default(dbgenerated("generate_prefixed_cuid('tsk'::text)"))
972
+ title String
973
+ description String
974
+ status TaskStatus @default(todo)
975
+ frequency TaskFrequency?
976
+ department Departments? @default(none)
977
+ order Int @default(0)
978
+
979
+ // Dates
980
+ createdAt DateTime @default(now())
981
+ updatedAt DateTime @updatedAt
982
+ lastCompletedAt DateTime?
983
+ reviewDate DateTime?
984
+
985
+ // Relationships
986
+ assigneeId String?
987
+ assignee Member? @relation(fields: [assigneeId], references: [id])
988
+ organizationId String
989
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
990
+ taskTemplateId String?
991
+ taskTemplate FrameworkEditorTaskTemplate? @relation(fields: [taskTemplateId], references: [id])
992
+ controls Control[]
993
+ vendors Vendor[]
994
+ risks Risk[]
995
+ evidenceAutomations EvidenceAutomation[]
996
+
997
+ EvidenceAutomationRun EvidenceAutomationRun[]
856
998
  }
857
999
 
858
1000
  enum TaskStatus {
859
- todo
860
- in_progress
861
- done
862
- not_relevant
863
- failed
1001
+ todo
1002
+ in_progress
1003
+ done
1004
+ not_relevant
1005
+ failed
864
1006
  }
865
1007
 
866
1008
  enum TaskFrequency {
867
- daily
868
- weekly
869
- monthly
870
- quarterly
871
- yearly
1009
+ daily
1010
+ weekly
1011
+ monthly
1012
+ quarterly
1013
+ yearly
872
1014
  }
873
1015
 
874
1016
 
875
1017
  // ===== trust.prisma =====
876
1018
  model Trust {
877
- organizationId String
878
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
879
- friendlyUrl String? @unique
880
- domain String?
881
- domainVerified Boolean @default(false)
882
- isVercelDomain Boolean @default(false)
883
- vercelVerification String?
884
- status TrustStatus @default(draft)
885
- contactEmail String?
886
-
887
- email String?
888
- privacyPolicy String?
889
- soc2 Boolean @default(false)
890
- soc2type1 Boolean @default(false)
891
- soc2type2 Boolean @default(false)
892
- iso27001 Boolean @default(false)
893
- iso42001 Boolean @default(false)
894
- nen7510 Boolean @default(false)
895
- gdpr Boolean @default(false)
896
- hipaa Boolean @default(false)
897
- pci_dss Boolean @default(false)
898
-
899
- soc2_status FrameworkStatus @default(started)
900
- soc2type1_status FrameworkStatus @default(started)
901
- soc2type2_status FrameworkStatus @default(started)
902
- iso27001_status FrameworkStatus @default(started)
903
- iso42001_status FrameworkStatus @default(started)
904
- nen7510_status FrameworkStatus @default(started)
905
- gdpr_status FrameworkStatus @default(started)
906
- hipaa_status FrameworkStatus @default(started)
907
- pci_dss_status FrameworkStatus @default(started)
908
-
909
- @@id([status, organizationId])
910
- @@unique([organizationId])
911
- @@index([organizationId])
912
- @@index([friendlyUrl])
1019
+ organizationId String
1020
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
1021
+ friendlyUrl String? @unique
1022
+ domain String?
1023
+ domainVerified Boolean @default(false)
1024
+ isVercelDomain Boolean @default(false)
1025
+ vercelVerification String?
1026
+ status TrustStatus @default(draft)
1027
+ contactEmail String?
1028
+
1029
+ email String?
1030
+ privacyPolicy String?
1031
+ soc2 Boolean @default(false)
1032
+ soc2type1 Boolean @default(false)
1033
+ soc2type2 Boolean @default(false)
1034
+ iso27001 Boolean @default(false)
1035
+ iso42001 Boolean @default(false)
1036
+ nen7510 Boolean @default(false)
1037
+ gdpr Boolean @default(false)
1038
+ hipaa Boolean @default(false)
1039
+ pci_dss Boolean @default(false)
1040
+ iso9001 Boolean @default(false)
1041
+
1042
+ soc2_status FrameworkStatus @default(started)
1043
+ soc2type1_status FrameworkStatus @default(started)
1044
+ soc2type2_status FrameworkStatus @default(started)
1045
+ iso27001_status FrameworkStatus @default(started)
1046
+ iso42001_status FrameworkStatus @default(started)
1047
+ nen7510_status FrameworkStatus @default(started)
1048
+ gdpr_status FrameworkStatus @default(started)
1049
+ hipaa_status FrameworkStatus @default(started)
1050
+ pci_dss_status FrameworkStatus @default(started)
1051
+ iso9001_status FrameworkStatus @default(started)
1052
+
1053
+ @@id([status, organizationId])
1054
+ @@unique([organizationId])
1055
+ @@index([organizationId])
1056
+ @@index([friendlyUrl])
913
1057
  }
914
1058
 
915
1059
  enum TrustStatus {
916
- draft
917
- published
1060
+ draft
1061
+ published
918
1062
  }
919
1063
 
920
1064
  enum FrameworkStatus {
921
- started
922
- in_progress
923
- compliant
1065
+ started
1066
+ in_progress
1067
+ compliant
1068
+ }
1069
+
1070
+ model TrustAccessRequest {
1071
+ id String @id @default(dbgenerated("generate_prefixed_cuid('tar'::text)"))
1072
+ organizationId String
1073
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
1074
+
1075
+ name String
1076
+ email String
1077
+ company String?
1078
+ jobTitle String?
1079
+ purpose String?
1080
+ requestedDurationDays Int?
1081
+
1082
+ status TrustAccessRequestStatus @default(under_review)
1083
+ reviewerMemberId String?
1084
+ reviewer Member? @relation("TrustAccessRequestReviewer", fields: [reviewerMemberId], references: [id], onDelete: SetNull)
1085
+ reviewedAt DateTime?
1086
+ decisionReason String?
1087
+
1088
+ ipAddress String?
1089
+ userAgent String?
1090
+
1091
+ createdAt DateTime @default(now())
1092
+ updatedAt DateTime @updatedAt
1093
+
1094
+ grant TrustAccessGrant? @relation("RequestGrant")
1095
+ ndaAgreements TrustNDAAgreement[] @relation("RequestNDA")
1096
+
1097
+ @@index([organizationId])
1098
+ @@index([email])
1099
+ @@index([status])
1100
+ @@index([organizationId, status])
1101
+ }
1102
+
1103
+ model TrustAccessGrant {
1104
+ id String @id @default(dbgenerated("generate_prefixed_cuid('tag'::text)"))
1105
+
1106
+ accessRequestId String @unique
1107
+ accessRequest TrustAccessRequest @relation("RequestGrant", fields: [accessRequestId], references: [id], onDelete: Cascade)
1108
+
1109
+ subjectEmail String
1110
+
1111
+ status TrustAccessGrantStatus @default(active)
1112
+ expiresAt DateTime
1113
+
1114
+ accessToken String? @unique
1115
+ accessTokenExpiresAt DateTime?
1116
+
1117
+ issuedByMemberId String?
1118
+ issuedBy Member? @relation("IssuedGrants", fields: [issuedByMemberId], references: [id], onDelete: SetNull)
1119
+
1120
+ revokedAt DateTime?
1121
+ revokedByMemberId String?
1122
+ revokedBy Member? @relation("RevokedGrants", fields: [revokedByMemberId], references: [id], onDelete: SetNull)
1123
+ revokeReason String?
1124
+
1125
+ createdAt DateTime @default(now())
1126
+ updatedAt DateTime @updatedAt
1127
+
1128
+ ndaAgreement TrustNDAAgreement? @relation("GrantNDA")
1129
+
1130
+ @@index([accessRequestId])
1131
+ @@index([subjectEmail])
1132
+ @@index([status])
1133
+ @@index([expiresAt])
1134
+ @@index([status, expiresAt])
1135
+ @@index([accessToken])
1136
+ }
1137
+
1138
+ enum TrustAccessRequestStatus {
1139
+ under_review
1140
+ approved
1141
+ denied
1142
+ canceled
1143
+ }
1144
+
1145
+ enum TrustAccessGrantStatus {
1146
+ active
1147
+ expired
1148
+ revoked
1149
+ }
1150
+
1151
+ model TrustNDAAgreement {
1152
+ id String @id @default(dbgenerated("generate_prefixed_cuid('tna'::text)"))
1153
+
1154
+ organizationId String
1155
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
1156
+
1157
+ accessRequestId String
1158
+ accessRequest TrustAccessRequest @relation("RequestNDA", fields: [accessRequestId], references: [id], onDelete: Cascade)
1159
+
1160
+ grantId String? @unique
1161
+ grant TrustAccessGrant? @relation("GrantNDA", fields: [grantId], references: [id], onDelete: SetNull)
1162
+
1163
+ signerName String?
1164
+ signerEmail String?
1165
+
1166
+ status TrustNDAStatus @default(pending)
1167
+
1168
+ signToken String @unique
1169
+ signTokenExpiresAt DateTime
1170
+
1171
+ pdfTemplateKey String?
1172
+ pdfSignedKey String?
1173
+
1174
+ signedAt DateTime?
1175
+
1176
+ ipAddress String?
1177
+ userAgent String?
1178
+
1179
+ createdAt DateTime @default(now())
1180
+ updatedAt DateTime @updatedAt
1181
+
1182
+ @@index([organizationId])
1183
+ @@index([accessRequestId])
1184
+ @@index([signToken])
1185
+ @@index([status])
1186
+ }
1187
+
1188
+ enum TrustNDAStatus {
1189
+ pending
1190
+ signed
1191
+ void
1192
+ }
1193
+
1194
+ model TrustDocument {
1195
+ id String @id @default(dbgenerated("generate_prefixed_cuid('tdoc'::text)"))
1196
+
1197
+ organizationId String
1198
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
1199
+
1200
+ name String
1201
+ description String?
1202
+ s3Key String
1203
+
1204
+ isActive Boolean @default(true)
1205
+
1206
+ createdAt DateTime @default(now())
1207
+ updatedAt DateTime @updatedAt
1208
+
1209
+ @@index([organizationId])
1210
+ @@index([organizationId, isActive])
924
1211
  }
925
1212
 
926
1213