@trycompai/db 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schema.prisma +146 -30
- package/package.json +1 -1
package/dist/schema.prisma
CHANGED
|
@@ -38,6 +38,7 @@ enum AttachmentEntityType {
|
|
|
38
38
|
comment
|
|
39
39
|
trust_nda
|
|
40
40
|
task_item
|
|
41
|
+
background_check
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
enum AttachmentType {
|
|
@@ -194,6 +195,7 @@ model Member {
|
|
|
194
195
|
performedFrameworkSyncOperations FrameworkSyncOperation[] @relation("FrameworkSyncOperationPerformer")
|
|
195
196
|
approvedTasks Task[] @relation("TaskApprover")
|
|
196
197
|
devices Device[]
|
|
198
|
+
backgroundCheckRequests BackgroundCheckRequest[]
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
model Invitation {
|
|
@@ -343,6 +345,71 @@ model EvidenceAutomation {
|
|
|
343
345
|
@@index([taskId])
|
|
344
346
|
}
|
|
345
347
|
|
|
348
|
+
// ===== background-check.prisma =====
|
|
349
|
+
model BackgroundCheckRequest {
|
|
350
|
+
id String @id @default(dbgenerated("generate_prefixed_cuid('bcr'::text)"))
|
|
351
|
+
organizationId String
|
|
352
|
+
memberId String
|
|
353
|
+
employeeEmail String
|
|
354
|
+
employeeName String
|
|
355
|
+
requesterNotes String?
|
|
356
|
+
identityBackgroundCheckId String? @unique
|
|
357
|
+
candidateUrl String?
|
|
358
|
+
status BackgroundCheckStatus @default(invited)
|
|
359
|
+
identityStatus String?
|
|
360
|
+
employmentStatus String?
|
|
361
|
+
referenceStatus String?
|
|
362
|
+
rightToWorkStatus String?
|
|
363
|
+
adjudicationStatus String?
|
|
364
|
+
stripePaymentIntentId String?
|
|
365
|
+
stripePaymentStatus String?
|
|
366
|
+
stripeRefundId String?
|
|
367
|
+
stripeAmountCents Int?
|
|
368
|
+
stripeCurrency String?
|
|
369
|
+
lastWebhookEventId String?
|
|
370
|
+
lastSyncedAt DateTime?
|
|
371
|
+
reportSnapshot Json?
|
|
372
|
+
reportSyncedAt DateTime?
|
|
373
|
+
createdAt DateTime @default(now())
|
|
374
|
+
updatedAt DateTime @updatedAt
|
|
375
|
+
|
|
376
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
377
|
+
member Member @relation(fields: [memberId], references: [id], onDelete: Cascade)
|
|
378
|
+
webhookEvents BackgroundCheckWebhookEvent[]
|
|
379
|
+
|
|
380
|
+
@@unique([organizationId, memberId])
|
|
381
|
+
@@index([organizationId])
|
|
382
|
+
@@index([memberId])
|
|
383
|
+
@@index([status])
|
|
384
|
+
@@map("background_check_requests")
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
model BackgroundCheckWebhookEvent {
|
|
388
|
+
id String @id @default(dbgenerated("generate_prefixed_cuid('bcw'::text)"))
|
|
389
|
+
eventId String @unique
|
|
390
|
+
eventType String
|
|
391
|
+
backgroundCheckRequestId String?
|
|
392
|
+
identityBackgroundCheckId String?
|
|
393
|
+
payload Json
|
|
394
|
+
processedAt DateTime @default(now())
|
|
395
|
+
|
|
396
|
+
backgroundCheckRequest BackgroundCheckRequest? @relation(fields: [backgroundCheckRequestId], references: [id], onDelete: SetNull)
|
|
397
|
+
|
|
398
|
+
@@index([backgroundCheckRequestId])
|
|
399
|
+
@@index([identityBackgroundCheckId])
|
|
400
|
+
@@map("background_check_webhook_events")
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
enum BackgroundCheckStatus {
|
|
404
|
+
invited
|
|
405
|
+
in_progress
|
|
406
|
+
in_review
|
|
407
|
+
completed
|
|
408
|
+
completed_with_flags
|
|
409
|
+
failed
|
|
410
|
+
cancelled
|
|
411
|
+
}
|
|
412
|
+
|
|
346
413
|
// ===== browserbase-context.prisma =====
|
|
347
414
|
/// Stores Browserbase context IDs for browser-based automation
|
|
348
415
|
/// One context per organization - shared like a normal browser
|
|
@@ -1664,14 +1731,15 @@ model OrganizationChart {
|
|
|
1664
1731
|
|
|
1665
1732
|
// ===== organization-billing.prisma =====
|
|
1666
1733
|
model OrganizationBilling {
|
|
1667
|
-
id
|
|
1668
|
-
organizationId
|
|
1669
|
-
stripeCustomerId
|
|
1670
|
-
|
|
1671
|
-
|
|
1734
|
+
id String @id @default(dbgenerated("generate_prefixed_cuid('obil'::text)"))
|
|
1735
|
+
organizationId String @unique @map("organization_id")
|
|
1736
|
+
stripeCustomerId String @map("stripe_customer_id")
|
|
1737
|
+
stripeBackgroundCheckPaymentMethodId String? @map("stripe_background_check_payment_method_id")
|
|
1738
|
+
backgroundCheckPaymentMethodSetupAt DateTime? @map("background_check_payment_method_setup_at")
|
|
1739
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
1740
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
1672
1741
|
|
|
1673
|
-
organization
|
|
1674
|
-
pentestSubscription PentestSubscription?
|
|
1742
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
1675
1743
|
|
|
1676
1744
|
@@map("organization_billing")
|
|
1677
1745
|
}
|
|
@@ -1739,9 +1807,11 @@ model Organization {
|
|
|
1739
1807
|
integrationOAuthApps IntegrationOAuthApp[]
|
|
1740
1808
|
integrationSyncLogs IntegrationSyncLog[]
|
|
1741
1809
|
|
|
1742
|
-
// Pentest
|
|
1743
|
-
|
|
1744
|
-
|
|
1810
|
+
// Pentest credits — wallet of run-credits an org can spend.
|
|
1811
|
+
// Source of credits (trial / future Stripe subscription / top-up)
|
|
1812
|
+
// is metadata on the row; balance is unified.
|
|
1813
|
+
pentestCredits PentestCredits?
|
|
1814
|
+
billing OrganizationBilling?
|
|
1745
1815
|
|
|
1746
1816
|
// Browser Automation
|
|
1747
1817
|
browserbaseContext BrowserbaseContext?
|
|
@@ -1753,6 +1823,9 @@ model Organization {
|
|
|
1753
1823
|
// Device Agent
|
|
1754
1824
|
devices Device[]
|
|
1755
1825
|
|
|
1826
|
+
// Background Checks
|
|
1827
|
+
backgroundCheckRequests BackgroundCheckRequest[]
|
|
1828
|
+
|
|
1756
1829
|
// Org Chart
|
|
1757
1830
|
organizationChart OrganizationChart?
|
|
1758
1831
|
|
|
@@ -1770,26 +1843,51 @@ model Organization {
|
|
|
1770
1843
|
@@index([slug])
|
|
1771
1844
|
}
|
|
1772
1845
|
|
|
1773
|
-
// ===== pentest-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1846
|
+
// ===== pentest-credits.prisma =====
|
|
1847
|
+
/// Pentest credit wallet — one row per organization, holding the org's
|
|
1848
|
+
/// current quota for penetration test runs.
|
|
1849
|
+
///
|
|
1850
|
+
/// `balance` is the operative number: decremented atomically when a run is
|
|
1851
|
+
/// created, granted by trial bootstrap, future Stripe subscription renewals,
|
|
1852
|
+
/// future top-up purchases, etc. The wallet does not differentiate by
|
|
1853
|
+
/// source — credits are credits. The most recent grant source is recorded
|
|
1854
|
+
/// for support visibility, not for spend logic.
|
|
1855
|
+
///
|
|
1856
|
+
/// For a full audit trail of every grant/consume, a future
|
|
1857
|
+
/// `pentest_credit_entries` ledger table can be layered in. v1 sticks with
|
|
1858
|
+
/// running totals (`totalGranted` / `totalConsumed`) for simplicity.
|
|
1859
|
+
model PentestCredits {
|
|
1860
|
+
id String @id @default(dbgenerated("generate_prefixed_cuid('pcr'::text)"))
|
|
1861
|
+
organizationId String @unique @map("organization_id")
|
|
1862
|
+
|
|
1863
|
+
/// Spendable balance. Never negative.
|
|
1864
|
+
/// Enforced both in code (atomic `updateMany WHERE balance > 0` in
|
|
1865
|
+
/// PentestCreditsService.debitOrThrow) AND at the DB level via a
|
|
1866
|
+
/// CHECK constraint added in migration
|
|
1867
|
+
/// `20260429120000_pentest_credits_balance_check`. Prisma's schema
|
|
1868
|
+
/// DSL doesn't currently support CHECK constraints, hence the
|
|
1869
|
+
/// SQL-only migration.
|
|
1870
|
+
balance Int @default(0)
|
|
1871
|
+
|
|
1872
|
+
/// Lifetime totals — useful for analytics and "why do I have N credits?"
|
|
1873
|
+
/// support questions without needing a full ledger.
|
|
1874
|
+
totalGranted Int @default(0) @map("total_granted")
|
|
1875
|
+
totalConsumed Int @default(0) @map("total_consumed")
|
|
1876
|
+
|
|
1877
|
+
/// Where the most recent grant came from. Free-form string so v2 can add
|
|
1878
|
+
/// new sources (`subscription`, `topup`, `promo`, `refund`, …) without a
|
|
1879
|
+
/// schema change. `trial` is the v1 default.
|
|
1880
|
+
lastGrantSource String @default("trial") @map("last_grant_source")
|
|
1881
|
+
|
|
1882
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
1883
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
1790
1884
|
|
|
1791
|
-
|
|
1792
|
-
|
|
1885
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
1886
|
+
|
|
1887
|
+
// No explicit @@index([organizationId]) — `@unique` on organizationId
|
|
1888
|
+
// already creates a btree index, and a duplicate would just consume
|
|
1889
|
+
// disk + write amplification with no read benefit.
|
|
1890
|
+
@@map("pentest_credits")
|
|
1793
1891
|
}
|
|
1794
1892
|
|
|
1795
1893
|
// ===== policy.prisma =====
|
|
@@ -2109,6 +2207,19 @@ model SecurityPenetrationTestRun {
|
|
|
2109
2207
|
createdAt DateTime @default(now()) @map("created_at")
|
|
2110
2208
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
2111
2209
|
|
|
2210
|
+
/// Set the first time we refund this run's credit (e.g. on
|
|
2211
|
+
/// `pentest.failed` / `pentest.cancelled` webhooks). Used to make the
|
|
2212
|
+
/// refund idempotent — webhook redelivery cannot double-credit because
|
|
2213
|
+
/// the second attempt sees a non-null value here.
|
|
2214
|
+
creditRefundedAt DateTime? @map("credit_refunded_at")
|
|
2215
|
+
|
|
2216
|
+
/// Set the first time we write a `pentest_completed` audit-log entry
|
|
2217
|
+
/// for this run. Webhook redelivery would otherwise create duplicate
|
|
2218
|
+
/// rows in `audit_log` because Maced retries `pentest.completed` on
|
|
2219
|
+
/// transient delivery failures. The atomic claim on this column
|
|
2220
|
+
/// guarantees one audit row per run regardless of retry count.
|
|
2221
|
+
completedAuditAt DateTime? @map("completed_audit_at")
|
|
2222
|
+
|
|
2112
2223
|
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
2113
2224
|
|
|
2114
2225
|
@@unique([providerRunId])
|
|
@@ -2202,6 +2313,7 @@ enum AuditLogEntityType {
|
|
|
2202
2313
|
integration
|
|
2203
2314
|
trust
|
|
2204
2315
|
finding
|
|
2316
|
+
pentest
|
|
2205
2317
|
}
|
|
2206
2318
|
|
|
2207
2319
|
enum EvidenceFormType {
|
|
@@ -2333,7 +2445,7 @@ model SOADocument {
|
|
|
2333
2445
|
isLatest Boolean @default(true) // Whether this is the latest version
|
|
2334
2446
|
|
|
2335
2447
|
// Document status
|
|
2336
|
-
status SOADocumentStatus @default(draft) // draft, in_progress, completed
|
|
2448
|
+
status SOADocumentStatus @default(draft) // draft, in_progress, needs_review, completed
|
|
2337
2449
|
|
|
2338
2450
|
// Document metadata
|
|
2339
2451
|
totalQuestions Int @default(0) // Total number of questions in this document
|
|
@@ -2344,6 +2456,7 @@ model SOADocument {
|
|
|
2344
2456
|
approverId String? // Member ID who will approve this document (set when submitted for approval)
|
|
2345
2457
|
approver Member? @relation("SOADocumentApprover", fields: [approverId], references: [id], onDelete: SetNull, onUpdate: Cascade)
|
|
2346
2458
|
approvedAt DateTime? // When document was approved
|
|
2459
|
+
declinedAt DateTime? // When document was declined
|
|
2347
2460
|
|
|
2348
2461
|
// Dates
|
|
2349
2462
|
completedAt DateTime? // When document was completed
|
|
@@ -2684,6 +2797,7 @@ model Trust {
|
|
|
2684
2797
|
soc2 Boolean @default(false)
|
|
2685
2798
|
soc2type1 Boolean @default(false)
|
|
2686
2799
|
soc2type2 Boolean @default(false)
|
|
2800
|
+
soc3 Boolean @default(false)
|
|
2687
2801
|
iso27001 Boolean @default(false)
|
|
2688
2802
|
iso42001 Boolean @default(false)
|
|
2689
2803
|
nen7510 Boolean @default(false)
|
|
@@ -2695,6 +2809,7 @@ model Trust {
|
|
|
2695
2809
|
soc2_status FrameworkStatus @default(started)
|
|
2696
2810
|
soc2type1_status FrameworkStatus @default(started)
|
|
2697
2811
|
soc2type2_status FrameworkStatus @default(started)
|
|
2812
|
+
soc3_status FrameworkStatus @default(started)
|
|
2698
2813
|
iso27001_status FrameworkStatus @default(started)
|
|
2699
2814
|
iso42001_status FrameworkStatus @default(started)
|
|
2700
2815
|
nen7510_status FrameworkStatus @default(started)
|
|
@@ -2735,6 +2850,7 @@ enum TrustFramework {
|
|
|
2735
2850
|
hipaa
|
|
2736
2851
|
soc2_type1
|
|
2737
2852
|
soc2_type2
|
|
2853
|
+
soc3
|
|
2738
2854
|
pci_dss
|
|
2739
2855
|
nen_7510
|
|
2740
2856
|
iso_9001
|