@valentine-efagene/qshelter-common 2.0.37 → 2.0.39

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.
@@ -12,9 +12,11 @@ export * from './ContractTermination';
12
12
  export * from './ContractTransition';
13
13
  export * from './DeviceEndpoint';
14
14
  export * from './DocumentRequirementRule';
15
+ export * from './DocumentTemplate';
15
16
  export * from './DomainEvent';
16
17
  export * from './EmailPreference';
17
18
  export * from './OAuthState';
19
+ export * from './OfferLetter';
18
20
  export * from './PasswordReset';
19
21
  export * from './PaymentMethodChangeRequest';
20
22
  export * from './PaymentMethodPhaseDocument';
@@ -12,9 +12,11 @@ export * from './ContractTermination';
12
12
  export * from './ContractTransition';
13
13
  export * from './DeviceEndpoint';
14
14
  export * from './DocumentRequirementRule';
15
+ export * from './DocumentTemplate';
15
16
  export * from './DomainEvent';
16
17
  export * from './EmailPreference';
17
18
  export * from './OAuthState';
19
+ export * from './OfferLetter';
18
20
  export * from './PasswordReset';
19
21
  export * from './PaymentMethodChangeRequest';
20
22
  export * from './PaymentMethodPhaseDocument';
@@ -39,6 +39,8 @@ export type * from './models/ContractPayment.js';
39
39
  export type * from './models/ContractDocument.js';
40
40
  export type * from './models/ContractTransition.js';
41
41
  export type * from './models/ContractEvent.js';
42
+ export type * from './models/DocumentTemplate.js';
43
+ export type * from './models/OfferLetter.js';
42
44
  export type * from './models/ContractTermination.js';
43
45
  export type * from './models/Prequalification.js';
44
46
  export type * from './models/PaymentMethodChangeRequest.js';
@@ -23,6 +23,9 @@ export declare enum NotificationType {
23
23
  CONTRACT_TERMINATION_REQUESTED = "contractTerminationRequested",
24
24
  CONTRACT_TERMINATION_APPROVED = "contractTerminationApproved",
25
25
  CONTRACT_TERMINATED = "contractTerminated",
26
+ OFFER_LETTER_SENT = "offerLetterSent",
27
+ OFFER_LETTER_SIGNED = "offerLetterSigned",
28
+ OFFER_LETTER_EXPIRED = "offerLetterExpired",
26
29
  ADMIN_CONTRIBUTION_RECEIVED = "adminContributionReceived",
27
30
  ADMIN_PROPERTY_ALLOCATION = "adminPropertyAllocation",
28
31
  ADMIN_INVITE = "adminInviteAdmin",
@@ -30,6 +30,10 @@ export var NotificationType;
30
30
  NotificationType["CONTRACT_TERMINATION_REQUESTED"] = "contractTerminationRequested";
31
31
  NotificationType["CONTRACT_TERMINATION_APPROVED"] = "contractTerminationApproved";
32
32
  NotificationType["CONTRACT_TERMINATED"] = "contractTerminated";
33
+ // Offer Letters
34
+ NotificationType["OFFER_LETTER_SENT"] = "offerLetterSent";
35
+ NotificationType["OFFER_LETTER_SIGNED"] = "offerLetterSigned";
36
+ NotificationType["OFFER_LETTER_EXPIRED"] = "offerLetterExpired";
33
37
  // Admin
34
38
  NotificationType["ADMIN_CONTRIBUTION_RECEIVED"] = "adminContributionReceived";
35
39
  NotificationType["ADMIN_PROPERTY_ALLOCATION"] = "adminPropertyAllocation";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valentine-efagene/qshelter-common",
3
- "version": "2.0.37",
3
+ "version": "2.0.39",
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",
@@ -151,9 +151,31 @@ enum CompletionCriterion {
151
151
  }
152
152
 
153
153
  enum DocumentStatus {
154
+ DRAFT
154
155
  PENDING
156
+ PENDING_SIGNATURE
157
+ SENT
158
+ VIEWED
159
+ SIGNED
155
160
  APPROVED
156
161
  REJECTED
162
+ EXPIRED
163
+ CANCELLED
164
+ }
165
+
166
+ enum OfferLetterType {
167
+ PROVISIONAL
168
+ FINAL
169
+ }
170
+
171
+ enum OfferLetterStatus {
172
+ DRAFT
173
+ GENERATED
174
+ SENT
175
+ VIEWED
176
+ SIGNED
177
+ EXPIRED
178
+ CANCELLED
157
179
  }
158
180
 
159
181
  // =============================================================================
@@ -209,6 +231,10 @@ model User {
209
231
  initiatedTerminations ContractTermination[] @relation("TerminationInitiator")
210
232
  reviewedTerminations ContractTermination[] @relation("TerminationReviewer")
211
233
 
234
+ // Offer letters
235
+ offerLettersGenerated OfferLetter[] @relation("OfferLetterGenerator")
236
+ offerLettersSent OfferLetter[] @relation("OfferLetterSender")
237
+
212
238
  @@index([email])
213
239
  @@index([tenantId])
214
240
  @@map("users")
@@ -286,6 +312,10 @@ model Tenant {
286
312
  // Contract terminations
287
313
  contractTerminations ContractTermination[]
288
314
 
315
+ // Offer letters and templates
316
+ documentTemplates DocumentTemplate[]
317
+ offerLetters OfferLetter[]
318
+
289
319
  @@index([subdomain])
290
320
  @@map("tenants")
291
321
  }
@@ -895,6 +925,7 @@ model Contract {
895
925
  transitions ContractTransition[]
896
926
  events ContractEvent[]
897
927
  terminations ContractTermination[]
928
+ offerLetters OfferLetter[]
898
929
 
899
930
  // Prequalification that led to this contract (optional)
900
931
  prequalification Prequalification?
@@ -1175,6 +1206,94 @@ model ContractEvent {
1175
1206
  @@map("contract_events")
1176
1207
  }
1177
1208
 
1209
+ // =============================================================================
1210
+ // OFFER LETTERS - Provisional and Final offer documents
1211
+ // =============================================================================
1212
+
1213
+ model DocumentTemplate {
1214
+ id String @id @default(cuid())
1215
+ tenantId String
1216
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1217
+
1218
+ name String // "Provisional Offer Letter", "Final Offer Letter"
1219
+ code String // PROVISIONAL_OFFER, FINAL_OFFER
1220
+ description String?
1221
+ version Int @default(1)
1222
+
1223
+ // Template content (Handlebars)
1224
+ htmlTemplate String @db.Text
1225
+ cssStyles String? @db.Text
1226
+
1227
+ // Merge field definitions for UI
1228
+ mergeFields Json? // [{name, type, required, description}]
1229
+
1230
+ isActive Boolean @default(true)
1231
+ isDefault Boolean @default(false)
1232
+
1233
+ createdAt DateTime @default(now())
1234
+ updatedAt DateTime @updatedAt
1235
+
1236
+ offerLetters OfferLetter[]
1237
+
1238
+ @@unique([tenantId, code, version])
1239
+ @@index([tenantId])
1240
+ @@index([code])
1241
+ @@map("document_templates")
1242
+ }
1243
+
1244
+ model OfferLetter {
1245
+ id String @id @default(cuid())
1246
+ tenantId String
1247
+ tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
1248
+ contractId String
1249
+ contract Contract @relation(fields: [contractId], references: [id], onDelete: Cascade)
1250
+
1251
+ // Template used
1252
+ templateId String
1253
+ template DocumentTemplate @relation(fields: [templateId], references: [id])
1254
+
1255
+ // Letter details
1256
+ letterNumber String @unique // OL-XXXXXX
1257
+ type OfferLetterType
1258
+ status OfferLetterStatus @default(DRAFT)
1259
+
1260
+ // Generated document
1261
+ htmlContent String? @db.Text // Rendered HTML
1262
+ pdfUrl String? // S3 URL of generated PDF
1263
+ pdfKey String? // S3 key for deletion/access
1264
+
1265
+ // Merge data used (snapshot for audit)
1266
+ mergeData Json? // All data merged into template
1267
+
1268
+ // Signing workflow
1269
+ sentAt DateTime?
1270
+ viewedAt DateTime?
1271
+ signedAt DateTime?
1272
+ signatureIp String?
1273
+ signatureData Json? // {method, timestamp, metadata}
1274
+
1275
+ // Validity
1276
+ expiresAt DateTime?
1277
+ expiredAt DateTime?
1278
+ cancelledAt DateTime?
1279
+ cancelReason String?
1280
+
1281
+ // Audit
1282
+ generatedById String?
1283
+ generatedBy User? @relation("OfferLetterGenerator", fields: [generatedById], references: [id])
1284
+ sentById String?
1285
+ sentBy User? @relation("OfferLetterSender", fields: [sentById], references: [id])
1286
+
1287
+ createdAt DateTime @default(now())
1288
+ updatedAt DateTime @updatedAt
1289
+
1290
+ @@index([tenantId])
1291
+ @@index([contractId])
1292
+ @@index([type])
1293
+ @@index([status])
1294
+ @@map("offer_letters")
1295
+ }
1296
+
1178
1297
  // =============================================================================
1179
1298
  // CONTRACT TERMINATION - Full lifecycle for cancellation/termination
1180
1299
  // =============================================================================