@valentine-efagene/qshelter-common 2.0.117 → 2.0.119

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": "@valentine-efagene/qshelter-common",
3
- "version": "2.0.117",
3
+ "version": "2.0.119",
4
4
  "description": "Shared database schemas and utilities for QShelter services",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -0,0 +1,29 @@
1
+ -- AlterTable
2
+ ALTER TABLE `documentation_plan_steps` ADD COLUMN `allowReject` BOOLEAN NOT NULL DEFAULT true,
3
+ ADD COLUMN `gateAction` ENUM('APPROVE', 'ACKNOWLEDGE', 'CONFIRM', 'CONSENT') NULL,
4
+ ADD COLUMN `gateActor` ENUM('ADMIN', 'CUSTOMER', 'SPECIFIC_ROLE') NULL,
5
+ ADD COLUMN `gateInstructions` TEXT NULL,
6
+ ADD COLUMN `gateRoleId` VARCHAR(191) NULL,
7
+ ADD COLUMN `rejectBehavior` ENUM('BLOCK', 'RESTART_STEP', 'RESTART_PHASE', 'TERMINATE') NULL,
8
+ ADD COLUMN `requiresComment` BOOLEAN NOT NULL DEFAULT false,
9
+ MODIFY `stepType` ENUM('UPLOAD', 'REVIEW', 'SIGNATURE', 'APPROVAL', 'EXTERNAL_CHECK', 'WAIT', 'GENERATE_DOCUMENT', 'PRE_APPROVAL', 'UNDERWRITING', 'GATE') NOT NULL;
10
+
11
+ -- AlterTable
12
+ ALTER TABLE `documentation_steps` ADD COLUMN `allowReject` BOOLEAN NOT NULL DEFAULT true,
13
+ ADD COLUMN `gateActedAt` DATETIME(3) NULL,
14
+ ADD COLUMN `gateActedById` VARCHAR(191) NULL,
15
+ ADD COLUMN `gateAction` ENUM('APPROVE', 'ACKNOWLEDGE', 'CONFIRM', 'CONSENT') NULL,
16
+ ADD COLUMN `gateActor` ENUM('ADMIN', 'CUSTOMER', 'SPECIFIC_ROLE') NULL,
17
+ ADD COLUMN `gateComment` TEXT NULL,
18
+ ADD COLUMN `gateDecision` VARCHAR(191) NULL,
19
+ ADD COLUMN `gateInstructions` TEXT NULL,
20
+ ADD COLUMN `gateRoleId` VARCHAR(191) NULL,
21
+ ADD COLUMN `rejectBehavior` ENUM('BLOCK', 'RESTART_STEP', 'RESTART_PHASE', 'TERMINATE') NULL,
22
+ ADD COLUMN `requiresComment` BOOLEAN NOT NULL DEFAULT false,
23
+ MODIFY `stepType` ENUM('UPLOAD', 'REVIEW', 'SIGNATURE', 'APPROVAL', 'EXTERNAL_CHECK', 'WAIT', 'GENERATE_DOCUMENT', 'PRE_APPROVAL', 'UNDERWRITING', 'GATE') NOT NULL;
24
+
25
+ -- AlterTable
26
+ ALTER TABLE `payment_method_phase_steps` MODIFY `stepType` ENUM('UPLOAD', 'REVIEW', 'SIGNATURE', 'APPROVAL', 'EXTERNAL_CHECK', 'WAIT', 'GENERATE_DOCUMENT', 'PRE_APPROVAL', 'UNDERWRITING', 'GATE') NOT NULL;
27
+
28
+ -- AddForeignKey
29
+ ALTER TABLE `documentation_steps` ADD CONSTRAINT `documentation_steps_gateActedById_fkey` FOREIGN KEY (`gateActedById`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
@@ -92,6 +92,30 @@ enum StepType {
92
92
  GENERATE_DOCUMENT // Triggers document generation (offer letters, contracts, etc.)
93
93
  PRE_APPROVAL // Customer answers eligibility questionnaire
94
94
  UNDERWRITING // System evaluates DTI, score, eligibility
95
+ GATE // Explicit human gate requiring action (approve, acknowledge, consent)
96
+ }
97
+
98
+ /// Who must perform a GATE step action
99
+ enum GateActor {
100
+ ADMIN // Any tenant admin
101
+ CUSTOMER // The application buyer
102
+ SPECIFIC_ROLE // Requires gateRoleId to be set
103
+ }
104
+
105
+ /// What action is required for a GATE step
106
+ enum GateAction {
107
+ APPROVE // Approve/Reject decision (default)
108
+ ACKNOWLEDGE // Just acknowledge, no reject option
109
+ CONFIRM // Confirm details are correct
110
+ CONSENT // Legal consent (e.g., terms & conditions)
111
+ }
112
+
113
+ /// What happens when a GATE step is rejected
114
+ enum GateRejectBehavior {
115
+ BLOCK // Block progression, admin must resolve
116
+ RESTART_STEP // Reset this step to pending
117
+ RESTART_PHASE // Reset entire phase
118
+ TERMINATE // Terminate the application
95
119
  }
96
120
 
97
121
  enum StepStatus {
@@ -353,9 +377,10 @@ model User {
353
377
  applicationPayments ApplicationPayment[] @relation("ApplicationPayer")
354
378
 
355
379
  // Documentation step assignments and approvals
356
- assignedSteps DocumentationStep[] @relation("DocumentationStepAssignee")
357
- stepApprovals DocumentationStepApproval[] @relation("DocumentationStepApprover")
358
- uploadedDocs ApplicationDocument[] @relation("DocumentUploader")
380
+ assignedSteps DocumentationStep[] @relation("DocumentationStepAssignee")
381
+ gateActedSteps DocumentationStep[] @relation("GateActedBy")
382
+ stepApprovals DocumentationStepApproval[] @relation("DocumentationStepApprover")
383
+ uploadedDocs ApplicationDocument[] @relation("DocumentUploader")
359
384
 
360
385
  // Payment method changes
361
386
  paymentMethodChangeRequests PaymentMethodChangeRequest[] @relation("ChangeRequestor")
@@ -1091,6 +1116,17 @@ model DocumentationPlanStep {
1091
1116
  // { "all": [{ "questionKey": "has_spouse", "operator": "EQUALS", "value": "YES" }, { "questionKey": "spouse_employed", "operator": "EQUALS", "value": "YES" }] }
1092
1117
  condition Json?
1093
1118
 
1119
+ // =========================================================================
1120
+ // GATE STEP CONFIGURATION (only applicable when stepType = GATE)
1121
+ // =========================================================================
1122
+ gateActor GateActor? // Who must perform the action
1123
+ gateAction GateAction? // What action is required
1124
+ gateRoleId String? // If gateActor = SPECIFIC_ROLE, which role
1125
+ gateInstructions String? @db.Text // Instructions shown to actor
1126
+ allowReject Boolean @default(true) // Can the actor reject?
1127
+ rejectBehavior GateRejectBehavior? // What happens on reject
1128
+ requiresComment Boolean @default(false) // Must actor provide a comment?
1129
+
1094
1130
  createdAt DateTime @default(now())
1095
1131
  updatedAt DateTime @updatedAt
1096
1132
 
@@ -2067,6 +2103,24 @@ model DocumentationStep {
2067
2103
  // Required document types for UPLOAD steps (normalized)
2068
2104
  requiredDocuments DocumentationStepDocument[]
2069
2105
 
2106
+ // =========================================================================
2107
+ // GATE STEP CONFIGURATION (only applicable when stepType = GATE)
2108
+ // =========================================================================
2109
+ gateActor GateActor? // Who must perform the action
2110
+ gateAction GateAction? // What action is required
2111
+ gateRoleId String? // If gateActor = SPECIFIC_ROLE, which role
2112
+ gateInstructions String? @db.Text // Instructions shown to actor
2113
+ allowReject Boolean @default(true) // Can the actor reject?
2114
+ rejectBehavior GateRejectBehavior? // What happens on reject
2115
+ requiresComment Boolean @default(false) // Must actor provide a comment?
2116
+
2117
+ // Gate action tracking
2118
+ gateActedAt DateTime? // When the gate action was performed
2119
+ gateActedById String? // Who performed the gate action
2120
+ gateActedBy User? @relation("GateActedBy", fields: [gateActedById], references: [id])
2121
+ gateDecision String? // APPROVED, REJECTED, ACKNOWLEDGED, etc.
2122
+ gateComment String? @db.Text // Comment from actor
2123
+
2070
2124
  // Timing
2071
2125
  dueDate DateTime?
2072
2126
  completedAt DateTime?