@adaptware/eagles-db 0.6.1 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptware/eagles-db",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "A Prisma client package for Treadspace database operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/prisma/.DS_Store CHANGED
Binary file
Binary file
@@ -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
  }
@@ -47,34 +49,88 @@ enum DataErasureRequestStatus {
47
49
  @@schema("public")
48
50
  }
49
51
 
50
- 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[]
52
+ /// Lifecycle for org-managed legal versions (platform seed publishes as PUBLISHED immediately).
53
+ enum ConsentCatalogVersionStatus {
54
+ DRAFT
55
+ PUBLISHED
56
+ ARCHIVED
57
+ /// Emergency takedown — grants blocked even during manifest grace window
58
+ REVOKED
59
59
 
60
60
  @@schema("public")
61
61
  }
62
62
 
63
+ model ConsentDocument {
64
+ id String @id @default(uuid())
65
+ /// Stable key within scope — platform: `platform_terms`, org interview: `interview_session`
66
+ slug String
67
+ consent_type ConsentType
68
+ /// Null = platform-wide catalog row; set = tenant-specific overlay (v1: interview session notice)
69
+ organisation_id String?
70
+ organisation Organisation? @relation(fields: [organisation_id], references: [id], onDelete: Cascade)
71
+ display_name String?
72
+ is_active Boolean @default(true)
73
+ created_at DateTime @default(now())
74
+ updated_at DateTime @updatedAt
75
+ versions ConsentDocumentVersion[]
76
+
77
+ @@unique([organisation_id, slug])
78
+ @@index([consent_type, organisation_id, is_active])
79
+ @@schema("public")
80
+ }
81
+
63
82
  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[]
83
+ id String @id @default(uuid())
84
+ document_id String
85
+ document ConsentDocument @relation(fields: [document_id], references: [id], onDelete: Cascade)
86
+ version_number Int
87
+ content_hash String
88
+ locale String @default("en")
89
+ /// Legacy inline body; new versions use S3 template fields
90
+ content String? @db.Text
91
+ template_version_label String?
92
+ s3_bucket String?
93
+ /// Legacy single key; prefer s3_archive_key + s3_active_key
94
+ s3_key String?
95
+ s3_region String?
96
+ /// Immutable snapshot path (audit binding)
97
+ s3_archive_key String?
98
+ /// Read-optimized current copy under active/
99
+ s3_active_key String?
100
+ /// Decision 6 — immutable archive row in shared Document catalog
101
+ s3_document_id String?
102
+ s3_document Document? @relation(fields: [s3_document_id], references: [id], onDelete: SetNull)
103
+ status ConsentCatalogVersionStatus @default(PUBLISHED)
104
+ published_at DateTime?
105
+ published_by_id String?
106
+ published_by User? @relation("ConsentVersionPublishedBy", fields: [published_by_id], references: [id], onDelete: SetNull)
107
+ approval_notes String? @db.Text
108
+ supersedes_version_id String?
109
+ supersedes_version ConsentDocumentVersion? @relation("ConsentVersionSupersedes", fields: [supersedes_version_id], references: [id], onDelete: SetNull)
110
+ superseded_by ConsentDocumentVersion[] @relation("ConsentVersionSupersedes")
111
+ created_at DateTime @default(now())
112
+ checkboxes ConsentCheckboxDefinition[]
113
+ consent_records ConsentRecord[]
114
+ system_consent_epochs SystemConsentEpoch[]
115
+ version_approvals ConsentDocumentVersionApproval[]
75
116
 
76
117
  @@unique([document_id, version_number])
77
118
  @@index([document_id, published_at(sort: Desc)])
119
+ @@index([s3_document_id])
120
+ @@schema("public")
121
+ }
122
+
123
+ model ConsentDocumentVersionApproval {
124
+ id String @id @default(uuid())
125
+ document_version_id String
126
+ document_version ConsentDocumentVersion @relation(fields: [document_version_id], references: [id], onDelete: Cascade)
127
+ action String
128
+ actor_user_id String?
129
+ actor_user User? @relation("ConsentVersionApprovalActor", fields: [actor_user_id], references: [id], onDelete: SetNull)
130
+ notes String? @db.Text
131
+ created_at DateTime @default(now())
132
+
133
+ @@index([document_version_id, created_at(sort: Desc)])
78
134
  @@schema("public")
79
135
  }
80
136
 
@@ -93,26 +149,45 @@ model ConsentCheckboxDefinition {
93
149
  }
94
150
 
95
151
  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())
152
+ id String @id @default(uuid())
153
+ user_id String
154
+ user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
155
+ consent_type ConsentType
156
+ outcome ConsentOutcome
157
+ document_version_id String
158
+ document_version ConsentDocumentVersion @relation(fields: [document_version_id], references: [id], onDelete: Restrict)
159
+ template_version_label String?
160
+ context_snapshot Json?
161
+ selections Json @default("{}")
162
+ reference_type ConsentReferenceType?
163
+ reference_id String?
164
+ ip_address String?
165
+ user_agent String?
166
+ decline_reason String?
167
+ /// Copy of version s3_archive_key (or legacy s3_key) at grant time
168
+ storage_snapshot_key String?
169
+ content_hash_at_grant String?
170
+ created_at DateTime @default(now())
110
171
 
111
172
  @@index([user_id, consent_type, created_at(sort: Desc)])
112
173
  @@index([reference_type, reference_id, consent_type, created_at(sort: Desc)])
113
174
  @@schema("public")
114
175
  }
115
176
 
177
+ /// Platform-wide re-consent watermark (complements per-interview consent_epoch_at).
178
+ model SystemConsentEpoch {
179
+ id String @id @default(uuid())
180
+ consent_type ConsentType
181
+ epoch_at DateTime @default(now())
182
+ document_version_id String?
183
+ document_version ConsentDocumentVersion? @relation(fields: [document_version_id], references: [id], onDelete: SetNull)
184
+ reason String?
185
+ created_at DateTime @default(now())
186
+
187
+ @@index([consent_type, epoch_at(sort: Desc)])
188
+ @@schema("public")
189
+ }
190
+
116
191
  /// Append-only erasure plan snapshots (v1: DRY_RUN only in application code).
117
192
  model DataErasureRequest {
118
193
  id String @id @default(uuid())
@@ -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])
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "JobDescription"
2
+ ADD COLUMN IF NOT EXISTS "restrict_candidate_upload_to_assigned_recruiters" BOOLEAN;
@@ -85,6 +85,12 @@ 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[]
89
+ /// Deprecated — migrate to org-scoped ConsentDocument; kept for legacy S3 fallback until backfill completes
90
+ has_custom_consent Boolean @default(false)
91
+ consent_s3_bucket String?
92
+ consent_s3_region String?
93
+ custom_interview_consent_s3_key_prefix String?
88
94
 
89
95
  @@index([name])
90
96
  @@schema("public")
@@ -104,6 +104,8 @@ model User {
104
104
  department_members DepartmentMember[] @relation("DepartmentMemberships")
105
105
  assigned_hiring_units PurchasedHiringUnit[] @relation("AssignedHiringUnits")
106
106
  consent_records ConsentRecord[]
107
+ consent_versions_published ConsentDocumentVersion[] @relation("ConsentVersionPublishedBy")
108
+ consent_version_approval_actions ConsentDocumentVersionApproval[] @relation("ConsentVersionApprovalActor")
107
109
  erasure_requests_as_subject DataErasureRequest[] @relation("ErasureSubjectUser")
108
110
  erasure_requests_requested DataErasureRequest[] @relation("ErasureRequestedByUser")
109
111
 
@@ -1,2 +0,0 @@
1
- -- Migrate legacy terminal-positive status to SELECTED (SHORTLISTED enum value retained but unused).
2
- UPDATE applications SET status = 'SELECTED' WHERE status = 'SHORTLISTED';