chore/port-solidtime-audit-fixes #1

Merged
danijel merged 54 commits from chore/port-solidtime-audit-fixes into main 2026-07-12 21:13:09 +00:00
194 changed files with 5958 additions and 1199 deletions
Showing only changes of commit e71b66908f - Show all commits

View File

@@ -58,8 +58,10 @@ export function createReqScopedAuditErasureHook(
return async ({ doc, req }) => {
if (typeof doc.id !== "string" && typeof doc.id !== "number") return;
const payload = req.payload;
// `slug as string`: apps with generated CollectionSlug types narrow slug
// to their registered union, which need not include "audit-logs".
const hasAuditCollection = payload.config.collections?.some(
(c) => c.slug === "audit-logs",
(c) => (c.slug as string) === "audit-logs",
);
if (!hasAuditCollection) return;
const auditLog = new PayloadAuditLog(

View File

@@ -108,6 +108,9 @@ export function buildPurgeHandler(
);
}
// Re-bind after the guard: narrowing does not flow into hoisted closures.
const targetCollection = collection;
const taskSlug = `retention-purge--${collectionSlug}`;
async function applyAction(
@@ -120,7 +123,7 @@ export function buildPurgeHandler(
if (action === "pseudonymize") {
const piiFields: Record<string, null> = {};
for (const field of collection.fields) {
for (const field of targetCollection.fields) {
const f = field as { name?: string; custom?: { pii?: unknown } };
if (f.name && f.custom?.pii) {
piiFields[f.name] = null;