@valentine-efagene/qshelter-common 2.0.141 → 2.0.143

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.
@@ -52,6 +52,7 @@ export * from './PropertyVariantAmenity';
52
52
  export * from './PropertyVariantMedia';
53
53
  export * from './QuestionnaireField';
54
54
  export * from './QuestionnairePhase';
55
+ export * from './QuestionnairePhaseReview';
55
56
  export * from './QuestionnairePlan';
56
57
  export * from './QuestionnairePlanQuestion';
57
58
  export * from './RefreshToken';
@@ -52,6 +52,7 @@ export * from './PropertyVariantAmenity';
52
52
  export * from './PropertyVariantMedia';
53
53
  export * from './QuestionnaireField';
54
54
  export * from './QuestionnairePhase';
55
+ export * from './QuestionnairePhaseReview';
55
56
  export * from './QuestionnairePlan';
56
57
  export * from './QuestionnairePlanQuestion';
57
58
  export * from './RefreshToken';
@@ -45,6 +45,7 @@ export type * from './models/Application.js';
45
45
  export type * from './models/ApplicationRefund.js';
46
46
  export type * from './models/ApplicationPhase.js';
47
47
  export type * from './models/QuestionnairePhase.js';
48
+ export type * from './models/QuestionnairePhaseReview.js';
48
49
  export type * from './models/DocumentationPhase.js';
49
50
  export type * from './models/PaymentPhase.js';
50
51
  export type * from './models/QuestionnaireField.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valentine-efagene/qshelter-common",
3
- "version": "2.0.141",
3
+ "version": "2.0.143",
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,102 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `completedStepsCount` on the `documentation_phases` table. All the data in the column will be lost.
5
+ - You are about to drop the column `completionCriterion` on the `documentation_phases` table. All the data in the column will be lost.
6
+ - You are about to drop the column `currentStepId` on the `documentation_phases` table. All the data in the column will be lost.
7
+ - You are about to drop the column `minimumCompletionPercentage` on the `documentation_phases` table. All the data in the column will be lost.
8
+ - You are about to drop the column `requiredDocumentSnapshot` on the `documentation_phases` table. All the data in the column will be lost.
9
+ - You are about to drop the column `stepDefinitionsSnapshot` on the `documentation_phases` table. All the data in the column will be lost.
10
+ - You are about to drop the column `totalStepsCount` on the `documentation_phases` table. All the data in the column will be lost.
11
+ - You are about to drop the `documentation_plan_steps` table. If the table is not empty, all the data it contains will be lost.
12
+ - You are about to drop the `documentation_step_approvals` table. If the table is not empty, all the data it contains will be lost.
13
+ - You are about to drop the `documentation_step_documents` table. If the table is not empty, all the data it contains will be lost.
14
+ - You are about to drop the `documentation_steps` table. If the table is not empty, all the data it contains will be lost.
15
+
16
+ */
17
+ -- DropForeignKey
18
+ ALTER TABLE `documentation_phases` DROP FOREIGN KEY `documentation_phases_currentStepId_fkey`;
19
+
20
+ -- DropForeignKey
21
+ ALTER TABLE `documentation_plan_steps` DROP FOREIGN KEY `documentation_plan_steps_planId_fkey`;
22
+
23
+ -- DropForeignKey
24
+ ALTER TABLE `documentation_step_approvals` DROP FOREIGN KEY `documentation_step_approvals_approverId_fkey`;
25
+
26
+ -- DropForeignKey
27
+ ALTER TABLE `documentation_step_approvals` DROP FOREIGN KEY `documentation_step_approvals_stepId_fkey`;
28
+
29
+ -- DropForeignKey
30
+ ALTER TABLE `documentation_step_approvals` DROP FOREIGN KEY `documentation_step_approvals_tenantId_fkey`;
31
+
32
+ -- DropForeignKey
33
+ ALTER TABLE `documentation_step_documents` DROP FOREIGN KEY `documentation_step_documents_stepId_fkey`;
34
+
35
+ -- DropForeignKey
36
+ ALTER TABLE `documentation_step_documents` DROP FOREIGN KEY `documentation_step_documents_tenantId_fkey`;
37
+
38
+ -- DropForeignKey
39
+ ALTER TABLE `documentation_steps` DROP FOREIGN KEY `documentation_steps_assigneeId_fkey`;
40
+
41
+ -- DropForeignKey
42
+ ALTER TABLE `documentation_steps` DROP FOREIGN KEY `documentation_steps_documentationPhaseId_fkey`;
43
+
44
+ -- DropForeignKey
45
+ ALTER TABLE `documentation_steps` DROP FOREIGN KEY `documentation_steps_gateActedById_fkey`;
46
+
47
+ -- DropForeignKey
48
+ ALTER TABLE `documentation_steps` DROP FOREIGN KEY `documentation_steps_tenantId_fkey`;
49
+
50
+ -- DropIndex
51
+ DROP INDEX `documentation_phases_currentStepId_idx` ON `documentation_phases`;
52
+
53
+ -- AlterTable
54
+ ALTER TABLE `documentation_phases` DROP COLUMN `completedStepsCount`,
55
+ DROP COLUMN `completionCriterion`,
56
+ DROP COLUMN `currentStepId`,
57
+ DROP COLUMN `minimumCompletionPercentage`,
58
+ DROP COLUMN `requiredDocumentSnapshot`,
59
+ DROP COLUMN `stepDefinitionsSnapshot`,
60
+ DROP COLUMN `totalStepsCount`,
61
+ ADD COLUMN `approvalStagesSnapshot` JSON NULL,
62
+ ADD COLUMN `currentStageOrder` INTEGER NOT NULL DEFAULT 1,
63
+ ADD COLUMN `documentDefinitionsSnapshot` JSON NULL;
64
+
65
+ -- DropTable
66
+ DROP TABLE `documentation_plan_steps`;
67
+
68
+ -- DropTable
69
+ DROP TABLE `documentation_step_approvals`;
70
+
71
+ -- DropTable
72
+ DROP TABLE `documentation_step_documents`;
73
+
74
+ -- DropTable
75
+ DROP TABLE `documentation_steps`;
76
+
77
+ -- CreateTable
78
+ CREATE TABLE `questionnaire_phase_reviews` (
79
+ `id` VARCHAR(191) NOT NULL,
80
+ `tenantId` VARCHAR(191) NOT NULL,
81
+ `questionnairePhaseId` VARCHAR(191) NOT NULL,
82
+ `reviewerId` VARCHAR(191) NOT NULL,
83
+ `decision` ENUM('PENDING', 'APPROVED', 'REJECTED', 'CHANGES_REQUESTED', 'WAIVED') NOT NULL,
84
+ `notes` TEXT NULL,
85
+ `scoreAtReview` INTEGER NULL,
86
+ `passedAtReview` BOOLEAN NULL,
87
+ `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
88
+
89
+ INDEX `questionnaire_phase_reviews_tenantId_idx`(`tenantId`),
90
+ INDEX `questionnaire_phase_reviews_questionnairePhaseId_idx`(`questionnairePhaseId`),
91
+ INDEX `questionnaire_phase_reviews_reviewerId_idx`(`reviewerId`),
92
+ PRIMARY KEY (`id`)
93
+ ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
94
+
95
+ -- AddForeignKey
96
+ ALTER TABLE `questionnaire_phase_reviews` ADD CONSTRAINT `questionnaire_phase_reviews_tenantId_fkey` FOREIGN KEY (`tenantId`) REFERENCES `tenants`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
97
+
98
+ -- AddForeignKey
99
+ ALTER TABLE `questionnaire_phase_reviews` ADD CONSTRAINT `questionnaire_phase_reviews_questionnairePhaseId_fkey` FOREIGN KEY (`questionnairePhaseId`) REFERENCES `questionnaire_phases`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
100
+
101
+ -- AddForeignKey
102
+ ALTER TABLE `questionnaire_phase_reviews` ADD CONSTRAINT `questionnaire_phase_reviews_reviewerId_fkey` FOREIGN KEY (`reviewerId`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -487,9 +487,9 @@ model User {
487
487
  applicationPayments ApplicationPayment[] @relation("ApplicationPayer")
488
488
 
489
489
  // Documentation (new model)
490
- uploadedDocs ApplicationDocument[] @relation("DocumentUploader")
491
- documentApprovals DocumentApproval[] @relation("DocumentApprovalReviewer")
492
- completedStages ApprovalStageProgress[] @relation("StageCompletedBy")
490
+ uploadedDocs ApplicationDocument[] @relation("DocumentUploader")
491
+ documentApprovals DocumentApproval[] @relation("DocumentApprovalReviewer")
492
+ completedStages ApprovalStageProgress[] @relation("StageCompletedBy")
493
493
 
494
494
  // Payment method changes
495
495
  paymentMethodChangeRequests PaymentMethodChangeRequest[] @relation("ChangeRequestor")
@@ -520,6 +520,9 @@ model User {
520
520
  // Document reviews by this user
521
521
  documentReviews DocumentReview[] @relation("DocumentReviewer")
522
522
 
523
+ // Questionnaire phase reviews by this user
524
+ questionnaireReviews QuestionnairePhaseReview[] @relation("QuestionnaireReviewer")
525
+
523
526
  // Organization memberships (user can be employee of banks/developers)
524
527
  organizationMemberships OrganizationMember[]
525
528
 
@@ -809,6 +812,7 @@ model Tenant {
809
812
  domainEvents DomainEvent[]
810
813
  workflowBlockers WorkflowBlocker[]
811
814
  questionnairePlans QuestionnairePlan[]
815
+ questionnairePhaseReviews QuestionnairePhaseReview[]
812
816
  documentReviews DocumentReview[]
813
817
 
814
818
  // Organizations (Banks, Developers) operating on this tenant
@@ -1289,10 +1293,10 @@ model DocumentationPlan {
1289
1293
 
1290
1294
  // Document definitions (what documents to collect)
1291
1295
  documentDefinitions DocumentDefinition[]
1292
-
1296
+
1293
1297
  // Approval stages (sequential workflow for reviewing documents)
1294
- approvalStages ApprovalStage[]
1295
-
1298
+ approvalStages ApprovalStage[]
1299
+
1296
1300
  // Used by property payment method phases (templates)
1297
1301
  methodPhases PropertyPaymentMethodPhase[]
1298
1302
  // Used by instantiated documentation phases
@@ -2144,6 +2148,9 @@ model QuestionnairePhase {
2144
2148
  // Child records
2145
2149
  fields QuestionnaireField[]
2146
2150
 
2151
+ // Review audit trail
2152
+ reviews QuestionnairePhaseReview[]
2153
+
2147
2154
  // Back-relation: Documentation phases that use this questionnaire's answers for conditions
2148
2155
  dependentDocumentationPhases DocumentationPhase[] @relation("SourceQuestionnaire")
2149
2156
 
@@ -2153,6 +2160,39 @@ model QuestionnairePhase {
2153
2160
  @@map("questionnaire_phases")
2154
2161
  }
2155
2162
 
2163
+ // =============================================================================
2164
+ // QUESTIONNAIRE PHASE REVIEW - Audit trail for questionnaire reviews
2165
+ // =============================================================================
2166
+ // Captures every review decision made on a questionnaire phase.
2167
+ // Supports workflows where questionnaire may be rejected → resubmitted → approved.
2168
+ // The scoring serves as guidance; reviewer makes the final decision.
2169
+ // =============================================================================
2170
+
2171
+ model QuestionnairePhaseReview {
2172
+ id String @id @default(cuid())
2173
+ tenantId String
2174
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
2175
+ questionnairePhaseId String
2176
+ questionnairePhase QuestionnairePhase @relation(fields: [questionnairePhaseId], references: [id], onDelete: Cascade)
2177
+
2178
+ // Review details
2179
+ reviewerId String
2180
+ reviewer User @relation("QuestionnaireReviewer", fields: [reviewerId], references: [id])
2181
+ decision ReviewDecision
2182
+ notes String? @db.Text
2183
+
2184
+ // Snapshot of scores at time of review (for audit)
2185
+ scoreAtReview Int? // The totalScore when this review was made
2186
+ passedAtReview Boolean? // The passed flag when this review was made
2187
+
2188
+ createdAt DateTime @default(now())
2189
+
2190
+ @@index([tenantId])
2191
+ @@index([questionnairePhaseId])
2192
+ @@index([reviewerId])
2193
+ @@map("questionnaire_phase_reviews")
2194
+ }
2195
+
2156
2196
  // =============================================================================
2157
2197
  // DOCUMENTATION PHASE DATA - Extension for DOCUMENTATION phases
2158
2198
  // =============================================================================