@adaptware/eagles-db 0.6.6 → 0.6.8

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.6",
3
+ "version": "0.6.8",
4
4
  "description": "A Prisma client package for Treadspace database operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
Binary file
Binary file
@@ -23,6 +23,14 @@ enum ConsentOutcome {
23
23
  @@schema("public")
24
24
  }
25
25
 
26
+ enum ConsentCatalogVersionStatus {
27
+ DRAFT
28
+ PUBLISHED
29
+ ARCHIVED
30
+
31
+ @@schema("public")
32
+ }
33
+
26
34
  enum DataErasureTrigger {
27
35
  ADMIN
28
36
  USER_REQUEST
@@ -49,114 +57,77 @@ enum DataErasureRequestStatus {
49
57
  @@schema("public")
50
58
  }
51
59
 
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
-
60
- @@schema("public")
61
- }
62
-
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).
63
63
  model ConsentDocument {
64
- id String @id @default(uuid())
65
- /// Stable key within scope — platform: `platform_terms`, org interview: `interview_session`
66
- slug String
64
+ id String @id @default(uuid())
67
65
  consent_type ConsentType
68
- /// Null = platform-wide catalog row; set = tenant-specific overlay (v1: interview session notice)
69
66
  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
67
+ organisation Organisation? @relation(fields: [organisation_id], references: [id], onDelete: Cascade)
68
+ created_at DateTime @default(now())
69
+ updated_at DateTime @updatedAt
75
70
  versions ConsentDocumentVersion[]
76
71
 
77
- @@unique([organisation_id, slug])
78
- @@index([consent_type, organisation_id, is_active])
72
+ @@unique([organisation_id, consent_type])
73
+ @@index([consent_type, organisation_id])
79
74
  @@schema("public")
80
75
  }
81
76
 
77
+ /// One immutable markdown object per version; S3 location and hash live on the linked Document.
82
78
  model ConsentDocumentVersion {
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
- template_version_label String?
90
- s3_bucket String?
91
- /// Immutable snapshot path (audit binding)
92
- s3_archive_key String?
93
- /// Read-optimized current copy under active/
94
- s3_active_key String?
95
- /// Optional immutable archive row in shared Document catalog (org ingest)
96
- s3_document_id String?
97
- s3_document Document? @relation(fields: [s3_document_id], references: [id], onDelete: SetNull)
98
- status ConsentCatalogVersionStatus @default(PUBLISHED)
99
- published_at DateTime?
100
- created_at DateTime @default(now())
101
- checkboxes ConsentCheckboxDefinition[]
102
- consent_records ConsentRecord[]
103
- system_consent_epochs SystemConsentEpoch[]
104
-
105
- @@unique([document_id, version_number])
106
- @@index([document_id, published_at(sort: Desc)])
107
- @@index([s3_document_id])
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])
108
95
  @@schema("public")
109
96
  }
110
97
 
111
98
  model ConsentCheckboxDefinition {
112
- id String @id @default(uuid())
113
- document_version_id String
114
- 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)
115
102
  /// Stable machine key in ConsentRecord.selections JSON
116
- checkbox_key String
117
- label String
118
- sort_order Int @default(0)
119
- 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)
120
107
 
121
- @@unique([document_version_id, checkbox_key])
108
+ @@unique([consent_document_version_id, checkbox_key])
122
109
  @@schema("public")
123
110
  }
124
111
 
112
+ /// Consent type is resolved via consent_document_version -> consent_document.consent_type.
125
113
  model ConsentRecord {
126
- id String @id @default(uuid())
127
- user_id String
128
- user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
129
- consent_type ConsentType
130
- outcome ConsentOutcome
131
- document_version_id String
132
- document_version ConsentDocumentVersion @relation(fields: [document_version_id], references: [id], onDelete: Restrict)
133
- template_version_label String?
134
- context_snapshot Json?
135
- selections Json @default("{}")
136
- reference_type ConsentReferenceType?
137
- reference_id String?
138
- ip_address String?
139
- user_agent String?
140
- decline_reason String?
141
- created_at DateTime @default(now())
142
-
143
- @@index([user_id, consent_type, created_at(sort: Desc)])
144
- @@index([reference_type, reference_id, consent_type, created_at(sort: Desc)])
145
- @@schema("public")
146
- }
147
-
148
- // Platform-wide re-consent watermark (complements per-interview consent_epoch_at).
149
- // epoch_at is the effective instant for platform re-consent (can differ from created_at when policy changes are backdated).
150
- model SystemConsentEpoch {
151
- id String @id @default(uuid())
152
- consent_type ConsentType
153
- epoch_at DateTime @default(now())
154
- document_version_id String?
155
- document_version ConsentDocumentVersion? @relation(fields: [document_version_id], references: [id], onDelete: SetNull)
156
- reason String?
157
- created_at DateTime @default(now())
158
-
159
- @@index([consent_type, epoch_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])
160
131
  @@schema("public")
161
132
  }
162
133
 
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "Resume"
2
+ ADD COLUMN IF NOT EXISTS "archived_at" TIMESTAMP(3);
@@ -86,11 +86,6 @@ model Organisation {
86
86
  license_package_organisations LicensePackageOrganisation[]
87
87
  ai_cost_ledger_entries AiCostLedgerEntry[]
88
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?
94
89
 
95
90
  @@index([name])
96
91
  @@schema("public")
@@ -63,6 +63,9 @@ model Resume {
63
63
  conversation_history Json?
64
64
  /// Progress 0-100 reported by the ResumeIntake workflow.
65
65
  intake_progress Int?
66
+ /// Set when the candidate archives the resume; null = active. Archived
67
+ /// resumes are hidden from resume pickers (e.g. the apply flow).
68
+ archived_at DateTime?
66
69
  /// Last Orion execution id for the intake/generate workflow, for tracing.
67
70
  orion_execution_id String?
68
71
  /// Snapshot of the candidate's own words, taken immediately before the