feat(core-shared): add retention-purge background job

Adds retention-purge.job.ts to packages/core-shared/src/payload/retention-purge/.
Walks every Payload collection's custom.retention.purgeSchedule, registers one
scheduled job per collection via IJobQueue, queries rows past their activeRetention
period (by createdAt for from-creation, updatedAt for from-last-access), and applies
pseudonymize (null PII fields) or hard-delete per postDeletion.action. Emits one
IAuditLog.record entry per processed row; gracefully skips when auditLog is absent.

Unit tests cover: schedule registration, trigger-type routing, hard-delete branch,
pseudonymize branch, audit emission, graceful auditLog skip, no-activeRetention
short-circuit, and input validation error cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 18:56:14 +00:00
parent d326270e1e
commit 7ea38bc5b9
4 changed files with 841 additions and 22 deletions

View File

@@ -1,18 +1,18 @@
{
"generatedAt": "2026-05-18T18:33:27.459Z",
"commit": "fa1a10c",
"generatedAt": "2026-05-18T18:55:54.185Z",
"commit": "d326270",
"repo": {
"statements": 96.34,
"branches": 91.41,
"functions": 96.76,
"lines": 96.34,
"statements": 96.43,
"branches": 91.71,
"functions": 96.81,
"lines": 96.43,
"counts": {
"lf": 4100,
"lh": 3950,
"brf": 768,
"brh": 702,
"fnf": 247,
"fnh": 239
"lf": 4205,
"lh": 4055,
"brf": 808,
"brh": 741,
"fnf": 251,
"fnh": 243
}
},
"byPackage": {
@@ -59,17 +59,17 @@
}
},
"@repo/core-shared": {
"statements": 97.75,
"branches": 95.54,
"functions": 91.58,
"lines": 97.75,
"statements": 97.98,
"branches": 95.79,
"functions": 91.92,
"lines": 97.98,
"counts": {
"lf": 935,
"lh": 914,
"brf": 269,
"brh": 257,
"fnf": 95,
"fnh": 87
"lf": 1040,
"lh": 1019,
"brf": 309,
"brh": 296,
"fnf": 99,
"fnh": 91
}
},
"@repo/marketing-pages": {