@valentine-efagene/qshelter-common 2.0.71 → 2.0.73
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/dist/generated/client/browser.d.ts +11 -0
- package/dist/generated/client/client.d.ts +11 -0
- package/dist/generated/client/commonInputTypes.d.ts +60 -0
- package/dist/generated/client/enums.d.ts +18 -0
- package/dist/generated/client/enums.js +17 -1
- package/dist/generated/client/internal/class.d.ts +22 -0
- package/dist/generated/client/internal/class.js +2 -2
- package/dist/generated/client/internal/prismaNamespace.d.ts +199 -1
- package/dist/generated/client/internal/prismaNamespace.js +55 -3
- package/dist/generated/client/internal/prismaNamespaceBrowser.d.ts +56 -0
- package/dist/generated/client/internal/prismaNamespaceBrowser.js +55 -3
- package/dist/generated/client/models/Contract.d.ts +1522 -280
- package/dist/generated/client/models/EventHandler.d.ts +154 -4
- package/dist/generated/client/models/PaymentMethodPhaseStep.d.ts +133 -0
- package/dist/generated/client/models/PropertyTransferRequest.d.ts +2535 -0
- package/dist/generated/client/models/PropertyTransferRequest.js +1 -0
- package/dist/generated/client/models/PropertyUnit.d.ts +147 -0
- package/dist/generated/client/models/StepEventAttachment.d.ts +1331 -0
- package/dist/generated/client/models/StepEventAttachment.js +1 -0
- package/dist/generated/client/models/Tenant.d.ts +219 -0
- package/dist/generated/client/models/User.d.ts +632 -0
- package/dist/generated/client/models.d.ts +2 -0
- package/dist/src/events/workflow-event.service.d.ts +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20260106062140_add_step_event_attachments/migration.sql +22 -0
- package/prisma/migrations/20260107121844_add_property_transfer_requests/migration.sql +64 -0
- package/prisma/schema.prisma +134 -0
|
@@ -29,6 +29,7 @@ export type * from './models/PropertyPaymentMethod.js';
|
|
|
29
29
|
export type * from './models/PropertyPaymentMethodLink.js';
|
|
30
30
|
export type * from './models/PropertyPaymentMethodPhase.js';
|
|
31
31
|
export type * from './models/PaymentMethodPhaseStep.js';
|
|
32
|
+
export type * from './models/StepEventAttachment.js';
|
|
32
33
|
export type * from './models/PaymentMethodPhaseDocument.js';
|
|
33
34
|
export type * from './models/Contract.js';
|
|
34
35
|
export type * from './models/ContractPhase.js';
|
|
@@ -50,4 +51,5 @@ export type * from './models/EventHandler.js';
|
|
|
50
51
|
export type * from './models/WorkflowEvent.js';
|
|
51
52
|
export type * from './models/EventHandlerExecution.js';
|
|
52
53
|
export type * from './models/DomainEvent.js';
|
|
54
|
+
export type * from './models/PropertyTransferRequest.js';
|
|
53
55
|
export type * from './commonInputTypes.js';
|
|
@@ -123,10 +123,10 @@ export declare class WorkflowEventService {
|
|
|
123
123
|
id: string;
|
|
124
124
|
createdAt: Date;
|
|
125
125
|
status: import("./workflow-types").ExecutionStatus;
|
|
126
|
+
handlerId: string;
|
|
126
127
|
completedAt: Date | null;
|
|
127
128
|
error: string | null;
|
|
128
129
|
eventId: string;
|
|
129
|
-
handlerId: string;
|
|
130
130
|
attempt: number;
|
|
131
131
|
input: import("@prisma/client/runtime/client").JsonValue | null;
|
|
132
132
|
output: import("@prisma/client/runtime/client").JsonValue | null;
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE `step_event_attachments` (
|
|
3
|
+
`id` VARCHAR(191) NOT NULL,
|
|
4
|
+
`stepId` VARCHAR(191) NOT NULL,
|
|
5
|
+
`trigger` ENUM('ON_COMPLETE', 'ON_REJECT', 'ON_SUBMIT', 'ON_RESUBMIT', 'ON_START') NOT NULL,
|
|
6
|
+
`handlerId` VARCHAR(191) NOT NULL,
|
|
7
|
+
`priority` INTEGER NOT NULL DEFAULT 100,
|
|
8
|
+
`enabled` BOOLEAN NOT NULL DEFAULT true,
|
|
9
|
+
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
10
|
+
`updatedAt` DATETIME(3) NOT NULL,
|
|
11
|
+
|
|
12
|
+
INDEX `step_event_attachments_stepId_idx`(`stepId`),
|
|
13
|
+
INDEX `step_event_attachments_handlerId_idx`(`handlerId`),
|
|
14
|
+
UNIQUE INDEX `step_event_attachments_stepId_handlerId_trigger_key`(`stepId`, `handlerId`, `trigger`),
|
|
15
|
+
PRIMARY KEY (`id`)
|
|
16
|
+
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
17
|
+
|
|
18
|
+
-- AddForeignKey
|
|
19
|
+
ALTER TABLE `step_event_attachments` ADD CONSTRAINT `step_event_attachments_stepId_fkey` FOREIGN KEY (`stepId`) REFERENCES `payment_method_phase_steps`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
20
|
+
|
|
21
|
+
-- AddForeignKey
|
|
22
|
+
ALTER TABLE `step_event_attachments` ADD CONSTRAINT `step_event_attachments_handlerId_fkey` FOREIGN KEY (`handlerId`) REFERENCES `event_handlers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- A unique constraint covering the columns `[transferredFromId]` on the table `contracts` will be added. If there are existing duplicate values, this will fail.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
-- AlterTable
|
|
8
|
+
ALTER TABLE `contracts` ADD COLUMN `transferredFromId` VARCHAR(191) NULL,
|
|
9
|
+
MODIFY `status` ENUM('DRAFT', 'PENDING', 'ACTIVE', 'COMPLETED', 'CANCELLED', 'TERMINATED', 'TRANSFERRED') NOT NULL DEFAULT 'DRAFT',
|
|
10
|
+
MODIFY `state` ENUM('DRAFT', 'PENDING', 'ACTIVE', 'COMPLETED', 'CANCELLED', 'TERMINATED', 'TRANSFERRED') NOT NULL DEFAULT 'DRAFT';
|
|
11
|
+
|
|
12
|
+
-- CreateTable
|
|
13
|
+
CREATE TABLE `property_transfer_requests` (
|
|
14
|
+
`id` VARCHAR(191) NOT NULL,
|
|
15
|
+
`tenantId` VARCHAR(191) NOT NULL,
|
|
16
|
+
`sourceContractId` VARCHAR(191) NOT NULL,
|
|
17
|
+
`targetPropertyUnitId` VARCHAR(191) NOT NULL,
|
|
18
|
+
`requestedById` VARCHAR(191) NOT NULL,
|
|
19
|
+
`reviewedById` VARCHAR(191) NULL,
|
|
20
|
+
`status` ENUM('PENDING', 'APPROVED', 'REJECTED', 'IN_PROGRESS', 'COMPLETED', 'FAILED') NOT NULL DEFAULT 'PENDING',
|
|
21
|
+
`reason` TEXT NULL,
|
|
22
|
+
`reviewNotes` TEXT NULL,
|
|
23
|
+
`priceAdjustmentHandling` VARCHAR(191) NULL,
|
|
24
|
+
`sourceTotalAmount` DOUBLE NULL,
|
|
25
|
+
`targetTotalAmount` DOUBLE NULL,
|
|
26
|
+
`priceAdjustment` DOUBLE NULL,
|
|
27
|
+
`paymentsMigrated` INTEGER NULL,
|
|
28
|
+
`targetContractId` VARCHAR(191) NULL,
|
|
29
|
+
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
30
|
+
`reviewedAt` DATETIME(3) NULL,
|
|
31
|
+
`completedAt` DATETIME(3) NULL,
|
|
32
|
+
`updatedAt` DATETIME(3) NOT NULL,
|
|
33
|
+
|
|
34
|
+
INDEX `property_transfer_requests_tenantId_idx`(`tenantId`),
|
|
35
|
+
INDEX `property_transfer_requests_sourceContractId_idx`(`sourceContractId`),
|
|
36
|
+
INDEX `property_transfer_requests_targetPropertyUnitId_idx`(`targetPropertyUnitId`),
|
|
37
|
+
INDEX `property_transfer_requests_requestedById_idx`(`requestedById`),
|
|
38
|
+
INDEX `property_transfer_requests_status_idx`(`status`),
|
|
39
|
+
PRIMARY KEY (`id`)
|
|
40
|
+
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
41
|
+
|
|
42
|
+
-- CreateIndex
|
|
43
|
+
CREATE UNIQUE INDEX `contracts_transferredFromId_key` ON `contracts`(`transferredFromId`);
|
|
44
|
+
|
|
45
|
+
-- AddForeignKey
|
|
46
|
+
ALTER TABLE `contracts` ADD CONSTRAINT `contracts_transferredFromId_fkey` FOREIGN KEY (`transferredFromId`) REFERENCES `contracts`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
|
47
|
+
|
|
48
|
+
-- AddForeignKey
|
|
49
|
+
ALTER TABLE `property_transfer_requests` ADD CONSTRAINT `property_transfer_requests_tenantId_fkey` FOREIGN KEY (`tenantId`) REFERENCES `tenants`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
50
|
+
|
|
51
|
+
-- AddForeignKey
|
|
52
|
+
ALTER TABLE `property_transfer_requests` ADD CONSTRAINT `property_transfer_requests_sourceContractId_fkey` FOREIGN KEY (`sourceContractId`) REFERENCES `contracts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
53
|
+
|
|
54
|
+
-- AddForeignKey
|
|
55
|
+
ALTER TABLE `property_transfer_requests` ADD CONSTRAINT `property_transfer_requests_targetPropertyUnitId_fkey` FOREIGN KEY (`targetPropertyUnitId`) REFERENCES `property_units`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
56
|
+
|
|
57
|
+
-- AddForeignKey
|
|
58
|
+
ALTER TABLE `property_transfer_requests` ADD CONSTRAINT `property_transfer_requests_requestedById_fkey` FOREIGN KEY (`requestedById`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
59
|
+
|
|
60
|
+
-- AddForeignKey
|
|
61
|
+
ALTER TABLE `property_transfer_requests` ADD CONSTRAINT `property_transfer_requests_reviewedById_fkey` FOREIGN KEY (`reviewedById`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
|
62
|
+
|
|
63
|
+
-- AddForeignKey
|
|
64
|
+
ALTER TABLE `property_transfer_requests` ADD CONSTRAINT `property_transfer_requests_targetContractId_fkey` FOREIGN KEY (`targetContractId`) REFERENCES `contracts`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -48,6 +48,16 @@ enum ContractStatus {
|
|
|
48
48
|
COMPLETED
|
|
49
49
|
CANCELLED
|
|
50
50
|
TERMINATED
|
|
51
|
+
TRANSFERRED // Contract was transferred to a different property
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
enum TransferRequestStatus {
|
|
55
|
+
PENDING
|
|
56
|
+
APPROVED
|
|
57
|
+
REJECTED
|
|
58
|
+
IN_PROGRESS
|
|
59
|
+
COMPLETED
|
|
60
|
+
FAILED
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
enum PhaseStatus {
|
|
@@ -84,6 +94,15 @@ enum StepStatus {
|
|
|
84
94
|
AWAITING_REVIEW // Submitted, waiting for admin/system review
|
|
85
95
|
}
|
|
86
96
|
|
|
97
|
+
/// When a step event attachment should trigger
|
|
98
|
+
enum StepTrigger {
|
|
99
|
+
ON_COMPLETE // When step is approved/completed
|
|
100
|
+
ON_REJECT // When step is rejected
|
|
101
|
+
ON_SUBMIT // When step is submitted for review
|
|
102
|
+
ON_RESUBMIT // When step is resubmitted after rejection
|
|
103
|
+
ON_START // When step transitions to IN_PROGRESS
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
enum InstallmentStatus {
|
|
88
107
|
PENDING
|
|
89
108
|
PAID
|
|
@@ -283,6 +302,10 @@ model User {
|
|
|
283
302
|
offerLettersGenerated OfferLetter[] @relation("OfferLetterGenerator")
|
|
284
303
|
offerLettersSent OfferLetter[] @relation("OfferLetterSender")
|
|
285
304
|
|
|
305
|
+
// Property transfer requests
|
|
306
|
+
transferRequestsSubmitted PropertyTransferRequest[] @relation("TransferRequestor")
|
|
307
|
+
transferRequestsReviewed PropertyTransferRequest[] @relation("TransferReviewer")
|
|
308
|
+
|
|
286
309
|
@@index([email])
|
|
287
310
|
@@index([tenantId])
|
|
288
311
|
@@map("users")
|
|
@@ -372,6 +395,9 @@ model Tenant {
|
|
|
372
395
|
eventHandlers EventHandler[]
|
|
373
396
|
workflowEvents WorkflowEvent[]
|
|
374
397
|
|
|
398
|
+
// Property transfer requests
|
|
399
|
+
propertyTransferRequests PropertyTransferRequest[]
|
|
400
|
+
|
|
375
401
|
@@index([subdomain])
|
|
376
402
|
@@map("tenants")
|
|
377
403
|
}
|
|
@@ -770,6 +796,9 @@ model PropertyUnit {
|
|
|
770
796
|
// Relations
|
|
771
797
|
contracts Contract[]
|
|
772
798
|
|
|
799
|
+
// Transfer requests targeting this unit
|
|
800
|
+
transferRequests PropertyTransferRequest[]
|
|
801
|
+
|
|
773
802
|
@@unique([variantId, unitNumber])
|
|
774
803
|
@@index([variantId])
|
|
775
804
|
@@index([status])
|
|
@@ -947,10 +976,42 @@ model PaymentMethodPhaseStep {
|
|
|
947
976
|
createdAt DateTime @default(now())
|
|
948
977
|
updatedAt DateTime @updatedAt
|
|
949
978
|
|
|
979
|
+
// Event attachments - handlers that fire on step transitions
|
|
980
|
+
eventAttachments StepEventAttachment[]
|
|
981
|
+
|
|
950
982
|
@@index([phaseId])
|
|
951
983
|
@@map("payment_method_phase_steps")
|
|
952
984
|
}
|
|
953
985
|
|
|
986
|
+
/// Step Event Attachment - Links event handlers to step template triggers
|
|
987
|
+
/// When a step transitions (complete, reject, etc.), attached handlers fire
|
|
988
|
+
model StepEventAttachment {
|
|
989
|
+
id String @id @default(cuid())
|
|
990
|
+
stepId String
|
|
991
|
+
step PaymentMethodPhaseStep @relation(fields: [stepId], references: [id], onDelete: Cascade)
|
|
992
|
+
|
|
993
|
+
/// When this handler should fire
|
|
994
|
+
trigger StepTrigger
|
|
995
|
+
|
|
996
|
+
/// The event handler to execute
|
|
997
|
+
handlerId String
|
|
998
|
+
handler EventHandler @relation(fields: [handlerId], references: [id], onDelete: Cascade)
|
|
999
|
+
|
|
1000
|
+
/// Order of execution (lower = first)
|
|
1001
|
+
priority Int @default(100)
|
|
1002
|
+
|
|
1003
|
+
/// Whether this attachment is active
|
|
1004
|
+
enabled Boolean @default(true)
|
|
1005
|
+
|
|
1006
|
+
createdAt DateTime @default(now())
|
|
1007
|
+
updatedAt DateTime @updatedAt
|
|
1008
|
+
|
|
1009
|
+
@@unique([stepId, handlerId, trigger])
|
|
1010
|
+
@@index([stepId])
|
|
1011
|
+
@@index([handlerId])
|
|
1012
|
+
@@map("step_event_attachments")
|
|
1013
|
+
}
|
|
1014
|
+
|
|
954
1015
|
// Required document within a DOCUMENTATION phase
|
|
955
1016
|
model PaymentMethodPhaseDocument {
|
|
956
1017
|
id String @id @default(cuid())
|
|
@@ -1042,6 +1103,16 @@ model Contract {
|
|
|
1042
1103
|
// Payment method change requests for this contract
|
|
1043
1104
|
paymentMethodChangeRequests PaymentMethodChangeRequest[]
|
|
1044
1105
|
|
|
1106
|
+
// Transfer tracking - when a contract is transferred to a different property
|
|
1107
|
+
transferredFromId String? @unique // Source contract if this was created via transfer
|
|
1108
|
+
transferredFrom Contract? @relation("ContractTransfer", fields: [transferredFromId], references: [id])
|
|
1109
|
+
transferredTo Contract? @relation("ContractTransfer")
|
|
1110
|
+
|
|
1111
|
+
// Transfer requests where this contract is the source
|
|
1112
|
+
outgoingTransferRequests PropertyTransferRequest[] @relation("SourceContract")
|
|
1113
|
+
// Transfer requests where this contract is the target (created after approval)
|
|
1114
|
+
incomingTransferRequests PropertyTransferRequest[] @relation("TargetContract")
|
|
1115
|
+
|
|
1045
1116
|
@@index([tenantId])
|
|
1046
1117
|
@@index([propertyUnitId])
|
|
1047
1118
|
@@index([buyerId])
|
|
@@ -1789,6 +1860,9 @@ model EventHandler {
|
|
|
1789
1860
|
/// Handler execution logs
|
|
1790
1861
|
executions EventHandlerExecution[]
|
|
1791
1862
|
|
|
1863
|
+
/// Step attachments - steps that have attached this handler
|
|
1864
|
+
stepAttachments StepEventAttachment[]
|
|
1865
|
+
|
|
1792
1866
|
createdAt DateTime @default(now())
|
|
1793
1867
|
updatedAt DateTime @updatedAt
|
|
1794
1868
|
|
|
@@ -1930,3 +2004,63 @@ model DomainEvent {
|
|
|
1930
2004
|
@@index([occurredAt])
|
|
1931
2005
|
@@map("domain_events")
|
|
1932
2006
|
}
|
|
2007
|
+
|
|
2008
|
+
// =============================================================================
|
|
2009
|
+
// Property Transfer Request
|
|
2010
|
+
// =============================================================================
|
|
2011
|
+
// Allows a buyer to request transferring their contract to a different property
|
|
2012
|
+
// while preserving payments, completed workflow steps, and progress.
|
|
2013
|
+
// =============================================================================
|
|
2014
|
+
|
|
2015
|
+
model PropertyTransferRequest {
|
|
2016
|
+
id String @id @default(cuid())
|
|
2017
|
+
tenantId String
|
|
2018
|
+
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
|
|
2019
|
+
|
|
2020
|
+
// Source contract being transferred
|
|
2021
|
+
sourceContractId String
|
|
2022
|
+
sourceContract Contract @relation("SourceContract", fields: [sourceContractId], references: [id], onDelete: Cascade)
|
|
2023
|
+
|
|
2024
|
+
// Target property unit
|
|
2025
|
+
targetPropertyUnitId String
|
|
2026
|
+
targetPropertyUnit PropertyUnit @relation(fields: [targetPropertyUnitId], references: [id])
|
|
2027
|
+
|
|
2028
|
+
// Requestor (buyer) and reviewer (admin)
|
|
2029
|
+
requestedById String
|
|
2030
|
+
requestedBy User @relation("TransferRequestor", fields: [requestedById], references: [id])
|
|
2031
|
+
reviewedById String?
|
|
2032
|
+
reviewedBy User? @relation("TransferReviewer", fields: [reviewedById], references: [id])
|
|
2033
|
+
|
|
2034
|
+
// Status and workflow
|
|
2035
|
+
status TransferRequestStatus @default(PENDING)
|
|
2036
|
+
|
|
2037
|
+
// Request details
|
|
2038
|
+
reason String? @db.Text // Buyer's reason for transfer
|
|
2039
|
+
|
|
2040
|
+
// Review details
|
|
2041
|
+
reviewNotes String? @db.Text // Admin notes on decision
|
|
2042
|
+
priceAdjustmentHandling String? // How to handle price difference: ADD_TO_MORTGAGE, REQUIRE_PAYMENT, CREDIT_BUYER
|
|
2043
|
+
|
|
2044
|
+
// Computed values
|
|
2045
|
+
sourceTotalAmount Float? // Original contract total
|
|
2046
|
+
targetTotalAmount Float? // New contract total (based on target property)
|
|
2047
|
+
priceAdjustment Float? // Difference (positive = buyer owes more)
|
|
2048
|
+
paymentsMigrated Int? // Number of payments migrated
|
|
2049
|
+
|
|
2050
|
+
// Result - new contract created after approval
|
|
2051
|
+
targetContractId String?
|
|
2052
|
+
targetContract Contract? @relation("TargetContract", fields: [targetContractId], references: [id])
|
|
2053
|
+
|
|
2054
|
+
// Timestamps
|
|
2055
|
+
createdAt DateTime @default(now())
|
|
2056
|
+
reviewedAt DateTime?
|
|
2057
|
+
completedAt DateTime?
|
|
2058
|
+
updatedAt DateTime @updatedAt
|
|
2059
|
+
|
|
2060
|
+
@@index([tenantId])
|
|
2061
|
+
@@index([sourceContractId])
|
|
2062
|
+
@@index([targetPropertyUnitId])
|
|
2063
|
+
@@index([requestedById])
|
|
2064
|
+
@@index([status])
|
|
2065
|
+
@@map("property_transfer_requests")
|
|
2066
|
+
}
|