@valentine-efagene/qshelter-common 2.0.101 → 2.0.103

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.
Files changed (31) hide show
  1. package/dist/generated/client/browser.d.ts +10 -0
  2. package/dist/generated/client/client.d.ts +10 -0
  3. package/dist/generated/client/commonInputTypes.d.ts +84 -84
  4. package/dist/generated/client/internal/class.d.ts +22 -0
  5. package/dist/generated/client/internal/class.js +2 -2
  6. package/dist/generated/client/internal/prismaNamespace.d.ts +192 -5
  7. package/dist/generated/client/internal/prismaNamespace.js +49 -0
  8. package/dist/generated/client/internal/prismaNamespaceBrowser.d.ts +53 -0
  9. package/dist/generated/client/internal/prismaNamespaceBrowser.js +49 -0
  10. package/dist/generated/client/models/DocumentationPhase.d.ts +231 -1
  11. package/dist/generated/client/models/DocumentationPlan.d.ts +1555 -0
  12. package/dist/generated/client/models/DocumentationPlan.js +1 -0
  13. package/dist/generated/client/models/DocumentationPlanStep.d.ts +1220 -0
  14. package/dist/generated/client/models/DocumentationPlanStep.js +1 -0
  15. package/dist/generated/client/models/DomainEvent.d.ts +281 -2
  16. package/dist/generated/client/models/PaymentMethodPhaseStep.d.ts +0 -3
  17. package/dist/generated/client/models/PropertyPaymentMethodPhase.d.ts +287 -1
  18. package/dist/generated/client/models/Settings.d.ts +211 -4
  19. package/dist/generated/client/models/Social.d.ts +147 -1
  20. package/dist/generated/client/models/Tenant.d.ts +4246 -639
  21. package/dist/generated/client/models/Transaction.d.ts +178 -14
  22. package/dist/generated/client/models/Wallet.d.ts +169 -1
  23. package/dist/generated/client/models/WorkflowBlocker.d.ts +299 -4
  24. package/dist/generated/client/models/index.d.ts +2 -0
  25. package/dist/generated/client/models/index.js +2 -0
  26. package/dist/generated/client/models.d.ts +2 -0
  27. package/dist/src/prisma/tenant.js +2 -8
  28. package/package.json +1 -1
  29. package/prisma/migrations/20260113122855_add_tenant_to_remaining_models/migration.sql +64 -0
  30. package/prisma/migrations/20260114034523_add_documentation_plan/migration.sql +52 -0
  31. package/prisma/schema.prisma +97 -10
@@ -492,11 +492,12 @@ model Tenant {
492
492
  updatedAt DateTime @updatedAt
493
493
 
494
494
  // Back-relations for multitenancy
495
- users User[]
496
- properties Property[]
497
- paymentPlans PaymentPlan[]
498
- paymentMethods PropertyPaymentMethod[]
499
- applications Application[]
495
+ users User[]
496
+ properties Property[]
497
+ paymentPlans PaymentPlan[]
498
+ documentationPlans DocumentationPlan[]
499
+ paymentMethods PropertyPaymentMethod[]
500
+ applications Application[]
500
501
 
501
502
  // RBAC: Tenant-scoped roles and permissions
502
503
  roles Role[]
@@ -560,6 +561,12 @@ model Tenant {
560
561
  propertyAmenities PropertyAmenity[]
561
562
  eventHandlerExecutions EventHandlerExecution[]
562
563
  amenities Amenity[]
564
+ socials Social[]
565
+ wallets Wallet[]
566
+ transactions Transaction[]
567
+ settings Settings[]
568
+ domainEvents DomainEvent[]
569
+ workflowBlockers WorkflowBlocker[]
563
570
 
564
571
  @@index([subdomain])
565
572
  @@map("tenants")
@@ -692,6 +699,8 @@ model DeviceEndpoint {
692
699
 
693
700
  model Social {
694
701
  id String @id @default(cuid())
702
+ tenantId String
703
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
695
704
  userId String
696
705
  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
697
706
  provider String // google, facebook, twitter, etc
@@ -701,6 +710,7 @@ model Social {
701
710
 
702
711
  @@unique([provider, socialId])
703
712
  @@index([userId])
713
+ @@index([tenantId])
704
714
  @@map("socials")
705
715
  }
706
716
 
@@ -717,6 +727,8 @@ model OAuthState {
717
727
 
718
728
  model Wallet {
719
729
  id String @id @default(cuid())
730
+ tenantId String
731
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
720
732
  balance Float @default(0)
721
733
  currency String @default("USD")
722
734
  user User?
@@ -724,11 +736,14 @@ model Wallet {
724
736
  createdAt DateTime @default(now())
725
737
  updatedAt DateTime @updatedAt
726
738
 
739
+ @@index([tenantId])
727
740
  @@map("wallets")
728
741
  }
729
742
 
730
743
  model Transaction {
731
744
  id String @id @default(cuid())
745
+ tenantId String
746
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
732
747
  walletId String
733
748
  wallet Wallet @relation(fields: [walletId], references: [id], onDelete: Cascade)
734
749
  amount Float
@@ -740,18 +755,23 @@ model Transaction {
740
755
  updatedAt DateTime @updatedAt
741
756
 
742
757
  @@index([walletId])
758
+ @@index([tenantId])
743
759
  @@map("transactions")
744
760
  }
745
761
 
746
762
  model Settings {
747
763
  id String @id @default(cuid())
748
- key String @unique
764
+ tenantId String
765
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
766
+ key String
749
767
  value String @db.Text
750
768
  category String?
751
769
  createdAt DateTime @default(now())
752
770
  updatedAt DateTime @updatedAt
753
771
 
772
+ @@unique([tenantId, key])
754
773
  @@index([category])
774
+ @@index([tenantId])
755
775
  @@map("settings")
756
776
  }
757
777
 
@@ -1004,6 +1024,59 @@ model PropertyAmenity {
1004
1024
  @@map("property_amenities")
1005
1025
  }
1006
1026
 
1027
+ // =============================================================================
1028
+ // DOCUMENTATION PLAN DOMAIN - Reusable step workflow templates
1029
+ // =============================================================================
1030
+
1031
+ // DocumentationPlan = reusable structure for documentation workflows
1032
+ // Examples: "Standard KYC", "Quick Verification", "Full Underwriting"
1033
+ model DocumentationPlan {
1034
+ id String @id @default(cuid())
1035
+ tenantId String? // NULL = global template available to all tenants
1036
+ tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1037
+ name String
1038
+ description String? @db.Text
1039
+ isActive Boolean @default(true)
1040
+
1041
+ // Document requirements for this plan
1042
+ requiredDocumentTypes Json? // Array of document type strings, e.g., ["ID_CARD", "BANK_STATEMENT"]
1043
+
1044
+ createdAt DateTime @default(now())
1045
+ updatedAt DateTime @updatedAt
1046
+
1047
+ // Steps that make up this plan
1048
+ steps DocumentationPlanStep[]
1049
+ // Used by property payment method phases (templates)
1050
+ methodPhases PropertyPaymentMethodPhase[]
1051
+ // Used by instantiated documentation phases
1052
+ documentationPhases DocumentationPhase[]
1053
+
1054
+ @@unique([tenantId, name]) // Unique per tenant, or globally if tenantId is null
1055
+ @@index([tenantId])
1056
+ @@map("documentation_plans")
1057
+ }
1058
+
1059
+ // Step template within a DocumentationPlan
1060
+ model DocumentationPlanStep {
1061
+ id String @id @default(cuid())
1062
+ planId String
1063
+ plan DocumentationPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
1064
+
1065
+ name String
1066
+ stepType StepType
1067
+ order Int
1068
+
1069
+ // Optional: which document type this step handles (for UPLOAD steps)
1070
+ documentType String?
1071
+ metadata Json?
1072
+
1073
+ createdAt DateTime @default(now())
1074
+ updatedAt DateTime @updatedAt
1075
+
1076
+ @@index([planId])
1077
+ @@map("documentation_plan_steps")
1078
+ }
1079
+
1007
1080
  // =============================================================================
1008
1081
  // PAYMENT PLAN DOMAIN - Reusable installment structure templates
1009
1082
  // =============================================================================
@@ -1123,8 +1196,12 @@ model PropertyPaymentMethodPhase {
1123
1196
  tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1124
1197
  paymentMethodId String
1125
1198
  paymentMethod PropertyPaymentMethod @relation(fields: [paymentMethodId], references: [id], onDelete: Cascade)
1126
- paymentPlanId String? // Only for PAYMENT phases
1127
- paymentPlan PaymentPlan? @relation(fields: [paymentPlanId], references: [id])
1199
+
1200
+ // Plan references (only one should be set based on phaseCategory)
1201
+ paymentPlanId String? // Only for PAYMENT phases
1202
+ paymentPlan PaymentPlan? @relation(fields: [paymentPlanId], references: [id])
1203
+ documentationPlanId String? // Only for DOCUMENTATION phases
1204
+ documentationPlan DocumentationPlan? @relation(fields: [documentationPlanId], references: [id])
1128
1205
 
1129
1206
  name String
1130
1207
  description String? @db.Text
@@ -1149,13 +1226,14 @@ model PropertyPaymentMethodPhase {
1149
1226
  completionCriterion CompletionCriterion?
1150
1227
 
1151
1228
  // Snapshots for audit (original config at creation time)
1229
+ // These are still needed for inline definitions (backward compatibility)
1152
1230
  stepDefinitionsSnapshot Json?
1153
1231
  requiredDocumentSnapshot Json?
1154
1232
 
1155
1233
  createdAt DateTime @default(now())
1156
1234
  updatedAt DateTime @updatedAt
1157
1235
 
1158
- // Normalized child tables (for DOCUMENTATION phases)
1236
+ // Normalized child tables (for DOCUMENTATION phases - inline definitions)
1159
1237
  steps PaymentMethodPhaseStep[]
1160
1238
  requiredDocuments PaymentMethodPhaseDocument[]
1161
1239
  // Normalized child tables (for QUESTIONNAIRE phases)
@@ -1166,6 +1244,7 @@ model PropertyPaymentMethodPhase {
1166
1244
  @@index([tenantId])
1167
1245
  @@index([paymentMethodId])
1168
1246
  @@index([paymentPlanId])
1247
+ @@index([documentationPlanId])
1169
1248
  @@index([phaseCategory])
1170
1249
  @@map("property_payment_method_phases")
1171
1250
  }
@@ -1593,6 +1672,10 @@ model DocumentationPhase {
1593
1672
  phaseId String @unique
1594
1673
  phase ApplicationPhase @relation(fields: [phaseId], references: [id], onDelete: Cascade)
1595
1674
 
1675
+ // Documentation plan reference (if created from a plan)
1676
+ documentationPlanId String?
1677
+ documentationPlan DocumentationPlan? @relation(fields: [documentationPlanId], references: [id])
1678
+
1596
1679
  // Current step pointer for UX and orchestration
1597
1680
  currentStepId String?
1598
1681
  currentStep DocumentationStep? @relation("CurrentStep", fields: [currentStepId], references: [id])
@@ -2515,7 +2598,9 @@ model EventHandlerExecution {
2515
2598
  // =============================================================================
2516
2599
 
2517
2600
  model DomainEvent {
2518
- id String @id @default(cuid())
2601
+ id String @id @default(cuid())
2602
+ tenantId String
2603
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
2519
2604
 
2520
2605
  // Event identification
2521
2606
  eventType String // MORTGAGE.CREATED, PHASE.ACTIVATED, PAYMENT.COMPLETED, etc
@@ -2544,6 +2629,7 @@ model DomainEvent {
2544
2629
  createdAt DateTime @default(now())
2545
2630
  updatedAt DateTime @updatedAt
2546
2631
 
2632
+ @@index([tenantId])
2547
2633
  @@index([status, nextRetryAt])
2548
2634
  @@index([eventType])
2549
2635
  @@index([aggregateType, aggregateId])
@@ -2757,6 +2843,7 @@ enum BlockerUrgency {
2757
2843
  model WorkflowBlocker {
2758
2844
  id String @id @default(cuid())
2759
2845
  tenantId String
2846
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
2760
2847
 
2761
2848
  // Reference to the blocked entity
2762
2849
  applicationId String