@trycompai/db 1.3.16 → 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
@@ -178,114 +182,115 @@ enum Role {
178
182
  admin
179
183
  auditor
180
184
  employee
185
+ contractor
181
186
  }
182
187
 
183
188
  enum PolicyStatus {
184
- draft
185
- published
186
- needs_review
189
+ draft
190
+ published
191
+ needs_review
187
192
  }
188
193
 
189
194
 
190
195
  // ===== automation-run.prisma =====
191
196
  model EvidenceAutomationRun {
192
- id String @id @default(dbgenerated("generate_prefixed_cuid('ear'::text)"))
193
- createdAt DateTime @default(now())
194
- updatedAt DateTime @updatedAt
195
-
196
- // Relations
197
- evidenceAutomationId String
198
- evidenceAutomation EvidenceAutomation @relation(fields: [evidenceAutomationId], references: [id], onDelete: Cascade)
199
-
200
- // Run details
201
- status EvidenceAutomationRunStatus @default(pending)
202
- startedAt DateTime?
203
- completedAt DateTime?
204
-
205
- // Results
206
- success Boolean?
207
- error String?
208
- logs Json?
209
- output Json?
210
-
211
- // Evaluation
212
- evaluationStatus EvidenceAutomationEvaluationStatus?
213
- evaluationReason String?
214
-
215
- // Metadata
216
- triggeredBy EvidenceAutomationTrigger @default(scheduled)
217
- runDuration Int? // in milliseconds
218
- version Int? // Version number that was executed (null = draft)
219
- Task Task? @relation(fields: [taskId], references: [id])
220
- taskId String?
221
-
222
- @@index([evidenceAutomationId])
223
- @@index([status])
224
- @@index([createdAt])
225
- @@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])
226
231
  }
227
232
 
228
233
  enum EvidenceAutomationRunStatus {
229
- pending
230
- running
231
- completed
232
- failed
233
- cancelled
234
+ pending
235
+ running
236
+ completed
237
+ failed
238
+ cancelled
234
239
  }
235
240
 
236
241
  enum EvidenceAutomationTrigger {
237
- manual
238
- scheduled
239
- api
242
+ manual
243
+ scheduled
244
+ api
240
245
  }
241
246
 
242
247
  enum EvidenceAutomationEvaluationStatus {
243
- pass
244
- fail
248
+ pass
249
+ fail
245
250
  }
246
251
 
247
252
 
248
253
  // ===== automation-version.prisma =====
249
254
  model EvidenceAutomationVersion {
250
- id String @id @default(dbgenerated("generate_prefixed_cuid('eav'::text)"))
251
- createdAt DateTime @default(now())
252
- updatedAt DateTime @updatedAt
255
+ id String @id @default(dbgenerated("generate_prefixed_cuid('eav'::text)"))
256
+ createdAt DateTime @default(now())
257
+ updatedAt DateTime @updatedAt
253
258
 
254
- // Relations
255
- evidenceAutomationId String
256
- evidenceAutomation EvidenceAutomation @relation(fields: [evidenceAutomationId], references: [id], onDelete: Cascade)
259
+ // Relations
260
+ evidenceAutomationId String
261
+ evidenceAutomation EvidenceAutomation @relation(fields: [evidenceAutomationId], references: [id], onDelete: Cascade)
257
262
 
258
- // Version details
259
- version Int // Sequential version number (1, 2, 3...)
260
- scriptKey String // S3 key for this version's script
261
- publishedBy String? // User ID who published
262
- 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
263
268
 
264
- @@unique([evidenceAutomationId, version])
265
- @@index([evidenceAutomationId])
266
- @@index([createdAt])
269
+ @@unique([evidenceAutomationId, version])
270
+ @@index([evidenceAutomationId])
271
+ @@index([createdAt])
267
272
  }
268
273
 
269
274
 
270
275
  // ===== automation.prisma =====
271
276
  model EvidenceAutomation {
272
- id String @id @default(dbgenerated("generate_prefixed_cuid('aut'::text)"))
273
- name String
274
- description String?
275
- createdAt DateTime @default(now())
276
- 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)
277
282
 
278
- chatHistory String?
279
- evaluationCriteria String?
283
+ chatHistory String?
284
+ evaluationCriteria String?
280
285
 
281
- taskId String
282
- task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
286
+ taskId String
287
+ task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
283
288
 
284
- // Relations
285
- runs EvidenceAutomationRun[]
286
- versions EvidenceAutomationVersion[]
289
+ // Relations
290
+ runs EvidenceAutomationRun[]
291
+ versions EvidenceAutomationVersion[]
287
292
 
288
- @@index([taskId])
293
+ @@index([taskId])
289
294
  }
290
295
 
291
296
 
@@ -321,22 +326,22 @@ enum CommentEntityType {
321
326
 
322
327
  // ===== context.prisma =====
323
328
  model Context {
324
- id String @id @default(dbgenerated("generate_prefixed_cuid('ctx'::text)"))
325
- organizationId String
326
- 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)
327
332
 
328
- question String
329
- answer String
333
+ question String
334
+ answer String
330
335
 
331
- tags String[]
336
+ tags String[]
332
337
 
333
- createdAt DateTime @default(now())
334
- updatedAt DateTime @updatedAt
338
+ createdAt DateTime @default(now())
339
+ updatedAt DateTime @updatedAt
335
340
 
336
- @@index([organizationId])
337
- @@index([question])
338
- @@index([answer])
339
- @@index([tags])
341
+ @@index([organizationId])
342
+ @@index([question])
343
+ @@index([answer])
344
+ @@index([tags])
340
345
  }
341
346
 
342
347
 
@@ -367,99 +372,99 @@ model Control {
367
372
  // ===== framework-editor.prisma =====
368
373
  // --- Data for Framework Editor ---
369
374
  model FrameworkEditorVideo {
370
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_vi'::text)"))
371
- title String
372
- description String
373
- youtubeId String
374
- 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
375
380
 
376
- // Dates
377
- createdAt DateTime @default(now())
378
- updatedAt DateTime @default(now()) @updatedAt
381
+ // Dates
382
+ createdAt DateTime @default(now())
383
+ updatedAt DateTime @default(now()) @updatedAt
379
384
  }
380
385
 
381
386
  model FrameworkEditorFramework {
382
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk'::text)"))
383
- name String // e.g., "soc2", "iso27001"
384
- version String
385
- description String
386
- 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)
387
392
 
388
- requirements FrameworkEditorRequirement[]
389
- frameworkInstances FrameworkInstance[]
393
+ requirements FrameworkEditorRequirement[]
394
+ frameworkInstances FrameworkInstance[]
390
395
 
391
- // Dates
392
- createdAt DateTime @default(now())
393
- updatedAt DateTime @default(now()) @updatedAt
396
+ // Dates
397
+ createdAt DateTime @default(now())
398
+ updatedAt DateTime @default(now()) @updatedAt
394
399
  }
395
400
 
396
401
  model FrameworkEditorRequirement {
397
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_rq'::text)"))
398
- frameworkId String
399
- 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])
400
405
 
401
- name String // Original requirement ID within that framework, e.g., "Privacy"
402
- identifier String @default("") // Unique identifier for the requirement, e.g., "cc1-1"
403
- 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
404
409
 
405
- controlTemplates FrameworkEditorControlTemplate[]
406
- requirementMaps RequirementMap[]
410
+ controlTemplates FrameworkEditorControlTemplate[]
411
+ requirementMaps RequirementMap[]
407
412
 
408
- // Dates
409
- createdAt DateTime @default(now())
410
- updatedAt DateTime @default(now()) @updatedAt
413
+ // Dates
414
+ createdAt DateTime @default(now())
415
+ updatedAt DateTime @default(now()) @updatedAt
411
416
  }
412
417
 
413
418
  model FrameworkEditorPolicyTemplate {
414
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_pt'::text)"))
415
- name String
416
- description String
417
- frequency Frequency // Using the enum from shared.prisma
418
- department Departments // Using the enum from shared.prisma
419
- 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
420
425
 
421
- controlTemplates FrameworkEditorControlTemplate[]
426
+ controlTemplates FrameworkEditorControlTemplate[]
422
427
 
423
- // Dates
424
- createdAt DateTime @default(now())
425
- updatedAt DateTime @default(now()) @updatedAt
428
+ // Dates
429
+ createdAt DateTime @default(now())
430
+ updatedAt DateTime @default(now()) @updatedAt
426
431
 
427
- // Instances
428
- policies Policy[]
432
+ // Instances
433
+ policies Policy[]
429
434
  }
430
435
 
431
436
  model FrameworkEditorTaskTemplate {
432
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_tt'::text)"))
433
- name String
434
- description String
435
- frequency Frequency // Using the enum from shared.prisma
436
- 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
437
442
 
438
- controlTemplates FrameworkEditorControlTemplate[]
443
+ controlTemplates FrameworkEditorControlTemplate[]
439
444
 
440
- // Dates
441
- createdAt DateTime @default(now())
442
- updatedAt DateTime @default(now()) @updatedAt
445
+ // Dates
446
+ createdAt DateTime @default(now())
447
+ updatedAt DateTime @default(now()) @updatedAt
443
448
 
444
- // Instances
445
- tasks Task[]
449
+ // Instances
450
+ tasks Task[]
446
451
  }
447
452
 
448
453
  model FrameworkEditorControlTemplate {
449
- id String @id @default(dbgenerated("generate_prefixed_cuid('frk_ct'::text)"))
450
- name String
451
- description String
454
+ id String @id @default(dbgenerated("generate_prefixed_cuid('frk_ct'::text)"))
455
+ name String
456
+ description String
452
457
 
453
- policyTemplates FrameworkEditorPolicyTemplate[]
454
- requirements FrameworkEditorRequirement[]
455
- taskTemplates FrameworkEditorTaskTemplate[]
458
+ policyTemplates FrameworkEditorPolicyTemplate[]
459
+ requirements FrameworkEditorRequirement[]
460
+ taskTemplates FrameworkEditorTaskTemplate[]
456
461
 
457
- // Dates
458
- createdAt DateTime @default(now())
459
- updatedAt DateTime @default(now()) @updatedAt
462
+ // Dates
463
+ createdAt DateTime @default(now())
464
+ updatedAt DateTime @default(now()) @updatedAt
460
465
 
461
- // Instances
462
- controls Control[]
466
+ // Instances
467
+ controls Control[]
463
468
  }
464
469
 
465
470
 
@@ -515,24 +520,59 @@ model IntegrationResult {
515
520
  }
516
521
 
517
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
+
518
558
  // ===== onboarding.prisma =====
519
559
  model Onboarding {
520
- organizationId String @id
521
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
522
- policies Boolean @default(false)
523
- employees Boolean @default(false)
524
- vendors Boolean @default(false)
525
- integrations Boolean @default(false)
526
- risk Boolean @default(false)
527
- team Boolean @default(false)
528
- tasks Boolean @default(false)
529
- callBooked Boolean @default(false)
530
- companyBookingDetails Json?
531
- companyDetails Json?
532
- triggerJobId String?
533
- 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)
534
574
 
535
- @@index([organizationId])
575
+ @@index([organizationId])
536
576
  }
537
577
 
538
578
 
@@ -554,22 +594,28 @@ model Organization {
554
594
  fleetDmLabelId Int?
555
595
  isFleetSetupCompleted Boolean @default(false)
556
596
 
557
- apiKeys ApiKey[]
558
- auditLog AuditLog[]
559
- controls Control[]
560
- frameworkInstances FrameworkInstance[]
561
- integrations Integration[]
562
- invitations Invitation[]
563
- members Member[]
564
- policy Policy[]
565
- risk Risk[]
566
- vendors Vendor[]
567
- tasks Task[]
568
- comments Comment[]
569
- attachments Attachment[]
570
- trust Trust[]
571
- context Context[]
572
- 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[]
573
619
 
574
620
  @@index([slug])
575
621
  }
@@ -617,21 +663,85 @@ model Policy {
617
663
  }
618
664
 
619
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
+
620
730
  // ===== requirement.prisma =====
621
731
  model RequirementMap {
622
- id String @id @default(dbgenerated("generate_prefixed_cuid('req'::text)"))
732
+ id String @id @default(dbgenerated("generate_prefixed_cuid('req'::text)"))
623
733
 
624
- requirementId String
625
- requirement FrameworkEditorRequirement @relation(fields: [requirementId], references: [id], onDelete: Cascade)
734
+ requirementId String
735
+ requirement FrameworkEditorRequirement @relation(fields: [requirementId], references: [id], onDelete: Cascade)
626
736
 
627
- controlId String
628
- control Control @relation(fields: [controlId], references: [id], onDelete: Cascade)
737
+ controlId String
738
+ control Control @relation(fields: [controlId], references: [id], onDelete: Cascade)
629
739
 
630
- frameworkInstanceId String
631
- frameworkInstance FrameworkInstance @relation(fields: [frameworkInstanceId], references: [id], onDelete: Cascade)
740
+ frameworkInstanceId String
741
+ frameworkInstance FrameworkInstance @relation(fields: [frameworkInstanceId], references: [id], onDelete: Cascade)
632
742
 
633
- @@unique([controlId, frameworkInstanceId, requirementId])
634
- @@index([requirementId, frameworkInstanceId])
743
+ @@unique([controlId, frameworkInstanceId, requirementId])
744
+ @@index([requirementId, frameworkInstanceId])
635
745
  }
636
746
 
637
747
 
@@ -698,228 +808,406 @@ enum RiskStatus {
698
808
 
699
809
  // ===== secret.prisma =====
700
810
  model Secret {
701
- id String @id @default(dbgenerated("generate_prefixed_cuid('sec'::text)"))
702
- organizationId String @map("organization_id")
703
- name String
704
- value String @db.Text // Encrypted value
705
- description String? @db.Text
706
- category String? // e.g., "api", "webhook", "database", etc.
707
- lastUsedAt DateTime? @map("last_used_at")
708
- createdAt DateTime @default(now()) @map("created_at")
709
- 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
+ }
710
826
 
711
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
712
827
 
713
- @@unique([organizationId, name])
714
- @@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
715
856
  }
716
857
 
717
858
 
859
+
718
860
  // ===== shared.prisma =====
719
861
  model ApiKey {
720
- id String @id @default(dbgenerated("generate_prefixed_cuid('apk'::text)"))
721
- name String
722
- key String @unique
723
- salt String?
724
- createdAt DateTime @default(now())
725
- expiresAt DateTime?
726
- lastUsedAt DateTime?
727
- 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)
728
870
 
729
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
730
- organizationId String
871
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
872
+ organizationId String
731
873
 
732
- @@index([organizationId])
733
- @@index([key])
874
+ @@index([organizationId])
875
+ @@index([key])
734
876
  }
735
877
 
736
878
  model AuditLog {
737
- id String @id @default(dbgenerated("generate_prefixed_cuid('aud'::text)"))
738
- timestamp DateTime @default(now())
739
- organizationId String
740
- userId String
741
- memberId String?
742
- data Json
743
- description String?
744
- entityId String?
745
- entityType AuditLogEntityType?
746
-
747
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
748
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
749
- member Member? @relation(fields: [memberId], references: [id], onDelete: Cascade)
750
-
751
- @@index([userId])
752
- @@index([organizationId])
753
- @@index([memberId])
754
- @@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])
755
897
  }
756
898
 
757
899
  enum AuditLogEntityType {
758
- organization
759
- framework
760
- requirement
761
- control
762
- policy
763
- task
764
- people
765
- risk
766
- vendor
767
- tests
768
- 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
769
912
  }
770
913
 
771
914
  model GlobalVendors {
772
- website String @id @unique
773
- company_name String?
774
- legal_name String?
775
- company_description String?
776
- company_hq_address String?
777
- privacy_policy_url String?
778
- terms_of_service_url String?
779
- service_level_agreement_url String?
780
- security_page_url String?
781
- trust_page_url String?
782
- security_certifications String[]
783
- subprocessors String[]
784
- type_of_company String?
785
-
786
- approved Boolean @default(false)
787
- createdAt DateTime @default(now())
788
-
789
- @@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])
790
933
  }
791
934
 
792
935
  enum Departments {
793
- none
794
- admin
795
- gov
796
- hr
797
- it
798
- itsm
799
- qms
936
+ none
937
+ admin
938
+ gov
939
+ hr
940
+ it
941
+ itsm
942
+ qms
800
943
  }
801
944
 
802
945
  enum Frequency {
803
- monthly
804
- quarterly
805
- yearly
946
+ monthly
947
+ quarterly
948
+ yearly
806
949
  }
807
950
 
808
951
  enum Likelihood {
809
- very_unlikely
810
- unlikely
811
- possible
812
- likely
813
- very_likely
952
+ very_unlikely
953
+ unlikely
954
+ possible
955
+ likely
956
+ very_likely
814
957
  }
815
958
 
816
959
  enum Impact {
817
- insignificant
818
- minor
819
- moderate
820
- major
821
- severe
960
+ insignificant
961
+ minor
962
+ moderate
963
+ major
964
+ severe
822
965
  }
823
966
 
824
967
 
825
968
  // ===== task.prisma =====
826
969
  model Task {
827
- // Metadata
828
- id String @id @default(dbgenerated("generate_prefixed_cuid('tsk'::text)"))
829
- title String
830
- description String
831
- status TaskStatus @default(todo)
832
- frequency TaskFrequency?
833
- department Departments? @default(none)
834
- order Int @default(0)
835
-
836
- // Dates
837
- createdAt DateTime @default(now())
838
- updatedAt DateTime @updatedAt
839
- lastCompletedAt DateTime?
840
- reviewDate DateTime?
841
-
842
- // Relationships
843
- assigneeId String?
844
- assignee Member? @relation(fields: [assigneeId], references: [id])
845
- organizationId String
846
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
847
- taskTemplateId String?
848
- taskTemplate FrameworkEditorTaskTemplate? @relation(fields: [taskTemplateId], references: [id])
849
- controls Control[]
850
- vendors Vendor[]
851
- risks Risk[]
852
- evidenceAutomations EvidenceAutomation[]
853
-
854
- 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[]
855
998
  }
856
999
 
857
1000
  enum TaskStatus {
858
- todo
859
- in_progress
860
- done
861
- not_relevant
862
- failed
1001
+ todo
1002
+ in_progress
1003
+ done
1004
+ not_relevant
1005
+ failed
863
1006
  }
864
1007
 
865
1008
  enum TaskFrequency {
866
- daily
867
- weekly
868
- monthly
869
- quarterly
870
- yearly
1009
+ daily
1010
+ weekly
1011
+ monthly
1012
+ quarterly
1013
+ yearly
871
1014
  }
872
1015
 
873
1016
 
874
1017
  // ===== trust.prisma =====
875
1018
  model Trust {
876
- organizationId String
877
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
878
- friendlyUrl String? @unique
879
- domain String?
880
- domainVerified Boolean @default(false)
881
- isVercelDomain Boolean @default(false)
882
- vercelVerification String?
883
- status TrustStatus @default(draft)
884
- contactEmail String?
885
-
886
- email String?
887
- privacyPolicy String?
888
- soc2 Boolean @default(false)
889
- soc2type1 Boolean @default(false)
890
- soc2type2 Boolean @default(false)
891
- iso27001 Boolean @default(false)
892
- iso42001 Boolean @default(false)
893
- nen7510 Boolean @default(false)
894
- gdpr Boolean @default(false)
895
- hipaa Boolean @default(false)
896
- pci_dss Boolean @default(false)
897
-
898
- soc2_status FrameworkStatus @default(started)
899
- soc2type1_status FrameworkStatus @default(started)
900
- soc2type2_status FrameworkStatus @default(started)
901
- iso27001_status FrameworkStatus @default(started)
902
- iso42001_status FrameworkStatus @default(started)
903
- nen7510_status FrameworkStatus @default(started)
904
- gdpr_status FrameworkStatus @default(started)
905
- hipaa_status FrameworkStatus @default(started)
906
- pci_dss_status FrameworkStatus @default(started)
907
-
908
- @@id([status, organizationId])
909
- @@unique([organizationId])
910
- @@index([organizationId])
911
- @@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])
912
1057
  }
913
1058
 
914
1059
  enum TrustStatus {
915
- draft
916
- published
1060
+ draft
1061
+ published
917
1062
  }
918
1063
 
919
1064
  enum FrameworkStatus {
920
- started
921
- in_progress
922
- 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])
923
1211
  }
924
1212
 
925
1213