@trycompai/db 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/schema.prisma +52 -144
  2. package/package.json +1 -1
@@ -38,7 +38,6 @@ enum AttachmentEntityType {
38
38
  comment
39
39
  trust_nda
40
40
  task_item
41
- background_check
42
41
  }
43
42
 
44
43
  enum AttachmentType {
@@ -195,7 +194,6 @@ model Member {
195
194
  performedFrameworkSyncOperations FrameworkSyncOperation[] @relation("FrameworkSyncOperationPerformer")
196
195
  approvedTasks Task[] @relation("TaskApprover")
197
196
  devices Device[]
198
- backgroundCheckRequests BackgroundCheckRequest[]
199
197
  }
200
198
 
201
199
  model Invitation {
@@ -345,71 +343,6 @@ model EvidenceAutomation {
345
343
  @@index([taskId])
346
344
  }
347
345
 
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
-
413
346
  // ===== browserbase-context.prisma =====
414
347
  /// Stores Browserbase context IDs for browser-based automation
415
348
  /// One context per organization - shared like a normal browser
@@ -1731,15 +1664,14 @@ model OrganizationChart {
1731
1664
 
1732
1665
  // ===== organization-billing.prisma =====
1733
1666
  model OrganizationBilling {
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")
1667
+ id String @id @default(dbgenerated("generate_prefixed_cuid('obil'::text)"))
1668
+ organizationId String @unique @map("organization_id")
1669
+ stripeCustomerId String @map("stripe_customer_id")
1670
+ createdAt DateTime @default(now()) @map("created_at")
1671
+ updatedAt DateTime @updatedAt @map("updated_at")
1741
1672
 
1742
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
1673
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
1674
+ pentestSubscription PentestSubscription?
1743
1675
 
1744
1676
  @@map("organization_billing")
1745
1677
  }
@@ -1807,11 +1739,9 @@ model Organization {
1807
1739
  integrationOAuthApps IntegrationOAuthApp[]
1808
1740
  integrationSyncLogs IntegrationSyncLog[]
1809
1741
 
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?
1742
+ // Pentest Subscription
1743
+ pentestSubscription PentestSubscription?
1744
+ billing OrganizationBilling?
1815
1745
 
1816
1746
  // Browser Automation
1817
1747
  browserbaseContext BrowserbaseContext?
@@ -1823,9 +1753,6 @@ model Organization {
1823
1753
  // Device Agent
1824
1754
  devices Device[]
1825
1755
 
1826
- // Background Checks
1827
- backgroundCheckRequests BackgroundCheckRequest[]
1828
-
1829
1756
  // Org Chart
1830
1757
  organizationChart OrganizationChart?
1831
1758
 
@@ -1843,51 +1770,26 @@ model Organization {
1843
1770
  @@index([slug])
1844
1771
  }
1845
1772
 
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")
1884
-
1885
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
1773
+ // ===== pentest-subscription.prisma =====
1774
+ model PentestSubscription {
1775
+ id String @id @default(dbgenerated("generate_prefixed_cuid('psub'::text)"))
1776
+ organizationId String @unique @map("organization_id")
1777
+ organizationBillingId String @unique @map("organization_billing_id")
1778
+ stripeSubscriptionId String @map("stripe_subscription_id")
1779
+ stripePriceId String @map("stripe_price_id")
1780
+ stripeOveragePriceId String? @map("stripe_overage_price_id")
1781
+ status String @default("active") // active | cancelled | past_due
1782
+ includedRunsPerPeriod Int @default(3) @map("included_runs_per_period")
1783
+ currentPeriodStart DateTime @map("current_period_start")
1784
+ currentPeriodEnd DateTime @map("current_period_end")
1785
+ createdAt DateTime @default(now()) @map("created_at")
1786
+ updatedAt DateTime @updatedAt @map("updated_at")
1787
+
1788
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
1789
+ organizationBilling OrganizationBilling @relation(fields: [organizationBillingId], references: [id])
1886
1790
 
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")
1791
+ @@index([organizationId])
1792
+ @@map("pentest_subscriptions")
1891
1793
  }
1892
1794
 
1893
1795
  // ===== policy.prisma =====
@@ -2135,6 +2037,20 @@ model Risk {
2135
2037
  residualImpact Impact @default(insignificant)
2136
2038
  treatmentStrategyDescription String?
2137
2039
  treatmentStrategy RiskTreatmentType @default(accept)
2040
+ // Per-strategy text store. When the user switches strategies, the current
2041
+ // `treatmentStrategyDescription` is moved into this map under the OLD
2042
+ // strategy key, and the NEW strategy's saved value is loaded back into the
2043
+ // active field. Lets users keep an independent Mitigate plan + Accept
2044
+ // rationale + Transfer rationale on the same risk.
2045
+ // Shape: { mitigate?: string, accept?: string, transfer?: string, avoid?: string }
2046
+ strategyDescriptions Json?
2047
+
2048
+ // Active auto-link suggestion run (trigger.dev). Set when the user kicks
2049
+ // off an AI suggest scan; cleared when the user applies or discards. Lets
2050
+ // the UI resume an in-flight or completed-but-unreviewed scan after a
2051
+ // page reload so progress isn't lost.
2052
+ autoLinkRunId String?
2053
+ autoLinkRunStartedAt DateTime?
2138
2054
 
2139
2055
  // Dates
2140
2056
  createdAt DateTime @default(now())
@@ -2207,19 +2123,6 @@ model SecurityPenetrationTestRun {
2207
2123
  createdAt DateTime @default(now()) @map("created_at")
2208
2124
  updatedAt DateTime @updatedAt @map("updated_at")
2209
2125
 
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
-
2223
2126
  organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
2224
2127
 
2225
2128
  @@unique([providerRunId])
@@ -2313,7 +2216,6 @@ enum AuditLogEntityType {
2313
2216
  integration
2314
2217
  trust
2315
2218
  finding
2316
- pentest
2317
2219
  }
2318
2220
 
2319
2221
  enum EvidenceFormType {
@@ -2797,7 +2699,6 @@ model Trust {
2797
2699
  soc2 Boolean @default(false)
2798
2700
  soc2type1 Boolean @default(false)
2799
2701
  soc2type2 Boolean @default(false)
2800
- soc3 Boolean @default(false)
2801
2702
  iso27001 Boolean @default(false)
2802
2703
  iso42001 Boolean @default(false)
2803
2704
  nen7510 Boolean @default(false)
@@ -2809,7 +2710,6 @@ model Trust {
2809
2710
  soc2_status FrameworkStatus @default(started)
2810
2711
  soc2type1_status FrameworkStatus @default(started)
2811
2712
  soc2type2_status FrameworkStatus @default(started)
2812
- soc3_status FrameworkStatus @default(started)
2813
2713
  iso27001_status FrameworkStatus @default(started)
2814
2714
  iso42001_status FrameworkStatus @default(started)
2815
2715
  nen7510_status FrameworkStatus @default(started)
@@ -2850,7 +2750,6 @@ enum TrustFramework {
2850
2750
  hipaa
2851
2751
  soc2_type1
2852
2752
  soc2_type2
2853
- soc3
2854
2753
  pci_dss
2855
2754
  nen_7510
2856
2755
  iso_9001
@@ -3044,6 +2943,10 @@ model Vendor {
3044
2943
  inherentImpact Impact @default(insignificant)
3045
2944
  residualProbability Likelihood @default(very_unlikely)
3046
2945
  residualImpact Impact @default(insignificant)
2946
+ treatmentStrategy RiskTreatmentType @default(accept)
2947
+ treatmentStrategyDescription String?
2948
+ // See `Risk.strategyDescriptions`.
2949
+ strategyDescriptions Json?
3047
2950
  website String?
3048
2951
  isSubProcessor Boolean @default(false)
3049
2952
 
@@ -3053,6 +2956,11 @@ model Vendor {
3053
2956
  trustPortalOrder Int?
3054
2957
  complianceBadges Json? // Array of { type: 'soc2' | 'iso27001' | etc, verified: boolean }
3055
2958
 
2959
+ // Active auto-link suggestion run (trigger.dev). Same semantics as
2960
+ // Risk.autoLinkRunId — lets the UI resume an in-flight scan on reload.
2961
+ autoLinkRunId String?
2962
+ autoLinkRunStartedAt DateTime?
2963
+
3056
2964
  createdAt DateTime @default(now())
3057
2965
  updatedAt DateTime @updatedAt
3058
2966
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trycompai/db",
3
3
  "description": "Database package with Prisma client and schema for Comp AI",
4
- "version": "2.0.3",
4
+ "version": "2.1.0",
5
5
  "dependencies": {
6
6
  "@prisma/adapter-pg": "7.6.0",
7
7
  "@prisma/client": "7.6.0",