@valentine-efagene/qshelter-common 2.0.55 → 2.0.57

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.
@@ -927,7 +927,6 @@ model Contract {
927
927
  phases ContractPhase[]
928
928
  documents ContractDocument[]
929
929
  payments ContractPayment[]
930
- transitions ContractTransition[]
931
930
  events ContractEvent[]
932
931
  terminations ContractTermination[]
933
932
  offerLetters OfferLetter[]
@@ -1193,31 +1192,35 @@ model ContractDocument {
1193
1192
  @@map("contract_documents")
1194
1193
  }
1195
1194
 
1196
- // FSM transitions for audit
1197
- model ContractTransition {
1198
- id String @id @default(cuid())
1199
- contractId String
1200
- contract Contract @relation(fields: [contractId], references: [id], onDelete: Cascade)
1201
- fromState String
1202
- toState String
1203
- trigger String
1204
- metadata String? @db.Text // JSON
1205
- transitionedAt DateTime @default(now())
1206
-
1207
- @@index([contractId])
1208
- @@map("contract_transitions")
1209
- }
1210
-
1211
- // Domain events for audit and integration
1195
+ // Contract domain events (FSM transitions, payments, documents, etc.)
1212
1196
  model ContractEvent {
1213
1197
  id String @id @default(cuid())
1214
1198
  contractId String
1215
1199
  contract Contract @relation(fields: [contractId], references: [id], onDelete: Cascade)
1216
- event String
1217
- data String? @db.Text // JSON
1218
- createdAt DateTime @default(now())
1200
+
1201
+ // Event classification
1202
+ eventType String // STATE.TRANSITION, PHASE.ACTIVATED, PAYMENT.COMPLETED, etc.
1203
+ eventGroup String? // STATE_CHANGE, PAYMENT, DOCUMENT, NOTIFICATION (for filtering)
1204
+
1205
+ // For state transitions (optional - only populated for STATE.TRANSITION events)
1206
+ fromState String?
1207
+ toState String?
1208
+ trigger String?
1209
+
1210
+ // Event payload (all event-specific data)
1211
+ data Json?
1212
+
1213
+ // Actor tracking
1214
+ actorId String?
1215
+ actorType String? // USER, SYSTEM, WEBHOOK
1216
+
1217
+ // Timing
1218
+ occurredAt DateTime @default(now())
1219
1219
 
1220
1220
  @@index([contractId])
1221
+ @@index([eventType])
1222
+ @@index([eventGroup])
1223
+ @@index([occurredAt])
1221
1224
  @@map("contract_events")
1222
1225
  }
1223
1226
 
@@ -1401,8 +1404,6 @@ model ContractTermination {
1401
1404
  @@map("contract_terminations")
1402
1405
  }
1403
1406
 
1404
-
1405
-
1406
1407
  // =============================================================================
1407
1408
  // PAYMENT METHOD CHANGE REQUEST - Mid-contract payment method changes
1408
1409
  // =============================================================================