@adaptware/eagles-db 0.6.7 → 0.6.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptware/eagles-db",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "description": "A Prisma client package for Treadspace database operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3,6 +3,8 @@
3
3
  enum ConsentType {
4
4
  PLATFORM_TERMS
5
5
  INTERVIEW_SESSION
6
+ /// Read-only catalog document; no ConsentRecord submit flow
7
+ PRIVACY_POLICY
6
8
 
7
9
  @@schema("public")
8
10
  }
@@ -21,6 +23,14 @@ enum ConsentOutcome {
21
23
  @@schema("public")
22
24
  }
23
25
 
26
+ enum ConsentCatalogVersionStatus {
27
+ DRAFT
28
+ PUBLISHED
29
+ ARCHIVED
30
+
31
+ @@schema("public")
32
+ }
33
+
24
34
  enum DataErasureTrigger {
25
35
  ADMIN
26
36
  USER_REQUEST
@@ -47,69 +57,77 @@ enum DataErasureRequestStatus {
47
57
  @@schema("public")
48
58
  }
49
59
 
60
+ /// Catalog identity is (organisation_id, consent_type). Null organisation_id = platform default.
61
+ /// Platform rows also need a partial unique index on consent_type WHERE organisation_id IS NULL
62
+ /// (PostgreSQL treats NULLs as distinct in the composite unique below).
50
63
  model ConsentDocument {
51
- id String @id @default(uuid())
52
- /// Stable key, e.g. PLATFORM_TERMS, INTERVIEW_SESSION_DEFAULT
53
- slug String @unique
54
- consent_type ConsentType
55
- is_active Boolean @default(true)
56
- created_at DateTime @default(now())
57
- updated_at DateTime @updatedAt
58
- versions ConsentDocumentVersion[]
59
-
64
+ id String @id @default(uuid())
65
+ consent_type ConsentType
66
+ organisation_id String?
67
+ organisation Organisation? @relation(fields: [organisation_id], references: [id], onDelete: Cascade)
68
+ created_at DateTime @default(now())
69
+ updated_at DateTime @updatedAt
70
+ versions ConsentDocumentVersion[]
71
+
72
+ @@unique([organisation_id, consent_type])
73
+ @@index([consent_type, organisation_id])
60
74
  @@schema("public")
61
75
  }
62
76
 
77
+ /// One immutable markdown object per version; S3 location and hash live on the linked Document.
63
78
  model ConsentDocumentVersion {
64
- id String @id @default(uuid())
65
- document_id String
66
- document ConsentDocument @relation(fields: [document_id], references: [id], onDelete: Cascade)
67
- version_number Int
68
- content_hash String
69
- locale String @default("en")
70
- content String @db.Text
71
- published_at DateTime?
72
- created_at DateTime @default(now())
73
- checkboxes ConsentCheckboxDefinition[]
74
- consent_records ConsentRecord[]
75
-
76
- @@unique([document_id, version_number])
77
- @@index([document_id, published_at(sort: Desc)])
79
+ id String @id @default(uuid())
80
+ consent_document_id String
81
+ consent_document ConsentDocument @relation(fields: [consent_document_id], references: [id], onDelete: Cascade)
82
+ version_number Int
83
+ document_id String?
84
+ document Document? @relation(fields: [document_id], references: [id], onDelete: Restrict)
85
+ status ConsentCatalogVersionStatus @default(DRAFT)
86
+ published_at DateTime?
87
+ created_at DateTime @default(now())
88
+ updated_at DateTime @updatedAt
89
+ checkboxes ConsentCheckboxDefinition[]
90
+ consent_records ConsentRecord[]
91
+
92
+ @@unique([consent_document_id, version_number])
93
+ @@index([consent_document_id, status, version_number(sort: Desc)])
94
+ @@index([document_id])
78
95
  @@schema("public")
79
96
  }
80
97
 
81
98
  model ConsentCheckboxDefinition {
82
- id String @id @default(uuid())
83
- document_version_id String
84
- document_version ConsentDocumentVersion @relation(fields: [document_version_id], references: [id], onDelete: Cascade)
99
+ id String @id @default(uuid())
100
+ consent_document_version_id String
101
+ consent_document_version ConsentDocumentVersion @relation(fields: [consent_document_version_id], references: [id], onDelete: Cascade)
85
102
  /// Stable machine key in ConsentRecord.selections JSON
86
- checkbox_key String
87
- label String
88
- sort_order Int @default(0)
89
- default_required_hint Boolean @default(true)
103
+ checkbox_key String
104
+ label String
105
+ sort_order Int @default(0)
106
+ default_required_hint Boolean @default(true)
90
107
 
91
- @@unique([document_version_id, checkbox_key])
108
+ @@unique([consent_document_version_id, checkbox_key])
92
109
  @@schema("public")
93
110
  }
94
111
 
112
+ /// Consent type is resolved via consent_document_version -> consent_document.consent_type.
95
113
  model ConsentRecord {
96
- id String @id @default(uuid())
97
- user_id String
98
- user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
99
- consent_type ConsentType
100
- outcome ConsentOutcome
101
- document_version_id String
102
- document_version ConsentDocumentVersion @relation(fields: [document_version_id], references: [id], onDelete: Restrict)
103
- selections Json @default("{}")
104
- reference_type ConsentReferenceType?
105
- reference_id String?
106
- ip_address String?
107
- user_agent String?
108
- decline_reason String?
109
- created_at DateTime @default(now())
110
-
111
- @@index([user_id, consent_type, created_at(sort: Desc)])
112
- @@index([reference_type, reference_id, consent_type, created_at(sort: Desc)])
114
+ id String @id @default(uuid())
115
+ user_id String
116
+ user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
117
+ outcome ConsentOutcome
118
+ consent_document_version_id String
119
+ consent_document_version ConsentDocumentVersion @relation(fields: [consent_document_version_id], references: [id], onDelete: Restrict)
120
+ selections Json @default("{}")
121
+ reference_type ConsentReferenceType?
122
+ reference_id String?
123
+ ip_address String?
124
+ user_agent String?
125
+ decline_reason String?
126
+ created_at DateTime @default(now())
127
+
128
+ @@index([user_id, created_at(sort: Desc)])
129
+ @@index([reference_type, reference_id, created_at(sort: Desc)])
130
+ @@index([consent_document_version_id])
113
131
  @@schema("public")
114
132
  }
115
133
 
@@ -38,6 +38,7 @@ model Document {
38
38
  offer_letter_template_snapshots OfferLetter[] @relation("OfferLetterTemplateSnapshot")
39
39
  offer_draft_edited_html Offer[] @relation("OfferDraftEditedHtml")
40
40
  application_fit_check_report Application? @relation("ApplicationFitCheckReportDocument")
41
+ consent_document_versions ConsentDocumentVersion[]
41
42
 
42
43
  // Indexes
43
44
  @@index([candidate_id])
@@ -85,6 +85,7 @@ model Organisation {
85
85
  licensing_ledger_entries LicensingLedgerEntry[]
86
86
  license_package_organisations LicensePackageOrganisation[]
87
87
  ai_cost_ledger_entries AiCostLedgerEntry[]
88
+ consent_documents ConsentDocument[]
88
89
 
89
90
  @@index([name])
90
91
  @@schema("public")