@adaptware/eagles-db 0.5.72 → 0.5.74

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.5.72",
3
+ "version": "0.5.74",
4
4
  "description": "A Prisma client package for Treadspace database operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,6 +17,8 @@ model Assessment {
17
17
  /// Attempt Expires At
18
18
  attempt_expires_at DateTime?
19
19
  evaluated_at DateTime?
20
+ /// When this moves forward, prior INTERVIEW_SESSION grants with reference ASSESSMENT are stale.
21
+ consent_epoch_at DateTime @default(now())
20
22
  /// Audit fields
21
23
  created_at DateTime @default(now())
22
24
  updated_at DateTime @updatedAt
@@ -0,0 +1,132 @@
1
+ /// Candidate consent catalog, audit records, and erasure planning (dry-run v1).
2
+
3
+ enum ConsentType {
4
+ PLATFORM_TERMS
5
+ INTERVIEW_SESSION
6
+
7
+ @@schema("public")
8
+ }
9
+
10
+ enum ConsentReferenceType {
11
+ INTERVIEW
12
+ ASSESSMENT
13
+
14
+ @@schema("public")
15
+ }
16
+
17
+ enum ConsentOutcome {
18
+ GRANTED
19
+ DECLINED
20
+
21
+ @@schema("public")
22
+ }
23
+
24
+ enum DataErasureTrigger {
25
+ ADMIN
26
+ USER_REQUEST
27
+ RETENTION_POLICY
28
+ CONSENT_WITHDRAWAL
29
+
30
+ @@schema("public")
31
+ }
32
+
33
+ enum DataErasureMode {
34
+ DRY_RUN
35
+ EXECUTE
36
+
37
+ @@schema("public")
38
+ }
39
+
40
+ enum DataErasureRequestStatus {
41
+ PLANNED
42
+ APPROVED
43
+ EXECUTED
44
+ REJECTED
45
+ FAILED
46
+
47
+ @@schema("public")
48
+ }
49
+
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[]
59
+
60
+ @@schema("public")
61
+ }
62
+
63
+ 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-IN")
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)])
78
+ @@schema("public")
79
+ }
80
+
81
+ 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)
85
+ /// 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)
90
+
91
+ @@unique([document_version_id, checkbox_key])
92
+ @@schema("public")
93
+ }
94
+
95
+ 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)])
113
+ @@schema("public")
114
+ }
115
+
116
+ /// Append-only erasure plan snapshots (v1: DRY_RUN only in application code).
117
+ model DataErasureRequest {
118
+ id String @id @default(uuid())
119
+ subject_user_id String
120
+ subject_user User @relation("ErasureSubjectUser", fields: [subject_user_id], references: [id], onDelete: Cascade)
121
+ trigger DataErasureTrigger
122
+ mode DataErasureMode @default(DRY_RUN)
123
+ status DataErasureRequestStatus @default(PLANNED)
124
+ plan Json @default("{}")
125
+ planner_version String
126
+ requested_by_id String?
127
+ requested_by User? @relation("ErasureRequestedByUser", fields: [requested_by_id], references: [id], onDelete: SetNull)
128
+ created_at DateTime @default(now())
129
+
130
+ @@index([subject_user_id, created_at(sort: Desc)])
131
+ @@schema("public")
132
+ }
@@ -86,12 +86,12 @@ model Interview {
86
86
  /// When final human feedback was submitted.
87
87
  evaluated_at DateTime?
88
88
 
89
- /// Candidate Acceptance & DPDP Consent
90
- candidate_status String? @default("INVITED")
91
- dpdp_consent_given Boolean @default(false)
92
- dpdp_consent_given_at DateTime?
93
- candidate_responded_at DateTime?
94
- decline_reason String?
89
+ /// Candidate invite response (legal consent in ConsentRecord).
90
+ candidate_status String? @default("INVITED")
91
+ candidate_responded_at DateTime?
92
+ decline_reason String?
93
+ /// When this timestamp moves forward, prior INTERVIEW_SESSION consent grants are stale.
94
+ consent_epoch_at DateTime @default(now())
95
95
 
96
96
  /// Self-scheduling
97
97
  reschedule_count Int @default(0)
@@ -0,0 +1,136 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "ConsentType" AS ENUM ('PLATFORM_TERMS', 'INTERVIEW_SESSION');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "ConsentReferenceType" AS ENUM ('INTERVIEW');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "ConsentOutcome" AS ENUM ('GRANTED', 'DECLINED');
9
+
10
+ -- CreateEnum
11
+ CREATE TYPE "DataErasureTrigger" AS ENUM ('ADMIN', 'USER_REQUEST', 'RETENTION_POLICY', 'CONSENT_WITHDRAWAL');
12
+
13
+ -- CreateEnum
14
+ CREATE TYPE "DataErasureMode" AS ENUM ('DRY_RUN', 'EXECUTE');
15
+
16
+ -- CreateEnum
17
+ CREATE TYPE "DataErasureRequestStatus" AS ENUM ('PLANNED', 'APPROVED', 'EXECUTED', 'REJECTED', 'FAILED');
18
+
19
+ -- AlterTable
20
+ ALTER TABLE "Interview" ADD COLUMN "consent_epoch_at" TIMESTAMP(3);
21
+
22
+ UPDATE "Interview"
23
+ SET "consent_epoch_at" = COALESCE("last_rescheduled_at", "created_at", CURRENT_TIMESTAMP);
24
+
25
+ ALTER TABLE "Interview" ALTER COLUMN "consent_epoch_at" SET NOT NULL;
26
+ ALTER TABLE "Interview" ALTER COLUMN "consent_epoch_at" SET DEFAULT CURRENT_TIMESTAMP;
27
+
28
+ -- CreateTable
29
+ CREATE TABLE "ConsentDocument" (
30
+ "id" TEXT NOT NULL,
31
+ "slug" TEXT NOT NULL,
32
+ "consent_type" "ConsentType" NOT NULL,
33
+ "is_active" BOOLEAN NOT NULL DEFAULT true,
34
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
35
+ "updated_at" TIMESTAMP(3) NOT NULL,
36
+
37
+ CONSTRAINT "ConsentDocument_pkey" PRIMARY KEY ("id")
38
+ );
39
+
40
+ -- CreateTable
41
+ CREATE TABLE "ConsentDocumentVersion" (
42
+ "id" TEXT NOT NULL,
43
+ "document_id" TEXT NOT NULL,
44
+ "version_number" INTEGER NOT NULL,
45
+ "content_hash" TEXT NOT NULL,
46
+ "locale" TEXT NOT NULL DEFAULT 'en-IN',
47
+ "content" TEXT NOT NULL,
48
+ "published_at" TIMESTAMP(3),
49
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
50
+
51
+ CONSTRAINT "ConsentDocumentVersion_pkey" PRIMARY KEY ("id")
52
+ );
53
+
54
+ -- CreateTable
55
+ CREATE TABLE "ConsentCheckboxDefinition" (
56
+ "id" TEXT NOT NULL,
57
+ "document_version_id" TEXT NOT NULL,
58
+ "checkbox_key" TEXT NOT NULL,
59
+ "label" TEXT NOT NULL,
60
+ "sort_order" INTEGER NOT NULL DEFAULT 0,
61
+ "default_required_hint" BOOLEAN NOT NULL DEFAULT true,
62
+
63
+ CONSTRAINT "ConsentCheckboxDefinition_pkey" PRIMARY KEY ("id")
64
+ );
65
+
66
+ -- CreateTable
67
+ CREATE TABLE "ConsentRecord" (
68
+ "id" TEXT NOT NULL,
69
+ "user_id" TEXT NOT NULL,
70
+ "consent_type" "ConsentType" NOT NULL,
71
+ "outcome" "ConsentOutcome" NOT NULL,
72
+ "document_version_id" TEXT NOT NULL,
73
+ "selections" JSONB NOT NULL DEFAULT '{}',
74
+ "reference_type" "ConsentReferenceType",
75
+ "reference_id" TEXT,
76
+ "ip_address" TEXT,
77
+ "user_agent" TEXT,
78
+ "decline_reason" TEXT,
79
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
80
+
81
+ CONSTRAINT "ConsentRecord_pkey" PRIMARY KEY ("id")
82
+ );
83
+
84
+ -- CreateTable
85
+ CREATE TABLE "DataErasureRequest" (
86
+ "id" TEXT NOT NULL,
87
+ "subject_user_id" TEXT NOT NULL,
88
+ "trigger" "DataErasureTrigger" NOT NULL,
89
+ "mode" "DataErasureMode" NOT NULL DEFAULT 'DRY_RUN',
90
+ "status" "DataErasureRequestStatus" NOT NULL DEFAULT 'PLANNED',
91
+ "plan" JSONB NOT NULL DEFAULT '{}',
92
+ "planner_version" TEXT NOT NULL,
93
+ "requested_by_id" TEXT,
94
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
95
+
96
+ CONSTRAINT "DataErasureRequest_pkey" PRIMARY KEY ("id")
97
+ );
98
+
99
+ -- CreateIndex
100
+ CREATE UNIQUE INDEX "ConsentDocument_slug_key" ON "ConsentDocument"("slug");
101
+
102
+ -- CreateIndex
103
+ CREATE INDEX "ConsentDocumentVersion_document_id_published_at_idx" ON "ConsentDocumentVersion"("document_id", "published_at" DESC);
104
+
105
+ -- CreateIndex
106
+ CREATE UNIQUE INDEX "ConsentDocumentVersion_document_id_version_number_key" ON "ConsentDocumentVersion"("document_id", "version_number");
107
+
108
+ -- CreateIndex
109
+ CREATE UNIQUE INDEX "ConsentCheckboxDefinition_document_version_id_checkbox_key_key" ON "ConsentCheckboxDefinition"("document_version_id", "checkbox_key");
110
+
111
+ -- CreateIndex
112
+ CREATE INDEX "ConsentRecord_user_id_consent_type_created_at_idx" ON "ConsentRecord"("user_id", "consent_type", "created_at" DESC);
113
+
114
+ -- CreateIndex
115
+ CREATE INDEX "ConsentRecord_reference_type_reference_id_consent_type_crea_idx" ON "ConsentRecord"("reference_type", "reference_id", "consent_type", "created_at" DESC);
116
+
117
+ -- CreateIndex
118
+ CREATE INDEX "DataErasureRequest_subject_user_id_created_at_idx" ON "DataErasureRequest"("subject_user_id", "created_at" DESC);
119
+
120
+ -- AddForeignKey
121
+ ALTER TABLE "ConsentDocumentVersion" ADD CONSTRAINT "ConsentDocumentVersion_document_id_fkey" FOREIGN KEY ("document_id") REFERENCES "ConsentDocument"("id") ON DELETE CASCADE ON UPDATE CASCADE;
122
+
123
+ -- AddForeignKey
124
+ ALTER TABLE "ConsentCheckboxDefinition" ADD CONSTRAINT "ConsentCheckboxDefinition_document_version_id_fkey" FOREIGN KEY ("document_version_id") REFERENCES "ConsentDocumentVersion"("id") ON DELETE CASCADE ON UPDATE CASCADE;
125
+
126
+ -- AddForeignKey
127
+ ALTER TABLE "ConsentRecord" ADD CONSTRAINT "ConsentRecord_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
128
+
129
+ -- AddForeignKey
130
+ ALTER TABLE "ConsentRecord" ADD CONSTRAINT "ConsentRecord_document_version_id_fkey" FOREIGN KEY ("document_version_id") REFERENCES "ConsentDocumentVersion"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
131
+
132
+ -- AddForeignKey
133
+ ALTER TABLE "DataErasureRequest" ADD CONSTRAINT "DataErasureRequest_subject_user_id_fkey" FOREIGN KEY ("subject_user_id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
134
+
135
+ -- AddForeignKey
136
+ ALTER TABLE "DataErasureRequest" ADD CONSTRAINT "DataErasureRequest_requested_by_id_fkey" FOREIGN KEY ("requested_by_id") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,16 @@
1
+ -- Extend consent references for proctored assessments (v1 scaffold).
2
+ ALTER TYPE "ConsentReferenceType" ADD VALUE 'ASSESSMENT';
3
+
4
+ -- Assessment session consent staleness (mirrors Interview.consent_epoch_at).
5
+ ALTER TABLE "Assessment" ADD COLUMN "consent_epoch_at" TIMESTAMP(3);
6
+
7
+ UPDATE "Assessment"
8
+ SET "consent_epoch_at" = COALESCE("updated_at", "created_at", CURRENT_TIMESTAMP)
9
+ WHERE "consent_epoch_at" IS NULL;
10
+
11
+ ALTER TABLE "Assessment" ALTER COLUMN "consent_epoch_at" SET NOT NULL;
12
+ ALTER TABLE "Assessment" ALTER COLUMN "consent_epoch_at" SET DEFAULT CURRENT_TIMESTAMP;
13
+
14
+ -- Legacy interview DPDP flags replaced by ConsentRecord (+ backfill).
15
+ ALTER TABLE "Interview" DROP COLUMN IF EXISTS "dpdp_consent_given";
16
+ ALTER TABLE "Interview" DROP COLUMN IF EXISTS "dpdp_consent_given_at";
@@ -103,6 +103,9 @@ model User {
103
103
 
104
104
  department_members DepartmentMember[] @relation("DepartmentMemberships")
105
105
  assigned_hiring_units PurchasedHiringUnit[] @relation("AssignedHiringUnits")
106
+ consent_records ConsentRecord[]
107
+ erasure_requests_as_subject DataErasureRequest[] @relation("ErasureSubjectUser")
108
+ erasure_requests_requested DataErasureRequest[] @relation("ErasureRequestedByUser")
106
109
 
107
110
  @@index([role_id])
108
111
  @@index([permission_id])
package/prisma/.DS_Store DELETED
Binary file
@@ -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';
Binary file