/** * `dsgvo verify --user ` — run the cross-table verifier-pass for a * user after a deletion-cascade, printing any straggler rows that still * reference the user. Useful when an operator wants a quick "are we * sure they're gone?" check without waiting for the scheduled verifier * worker run (~1h after the cascade). * * The actual scan logic lives in the worker (apps/worker/src/jobs/ * dsgvo-verify.ts). The CLI just records the request as an AuditEvent * with action=VERIFY_USER_DELETION so the worker can pick it up. */ import { defineCommand } from "citty"; import consola from "consola"; import { randomUUID } from "node:crypto"; export const dsgvoVerifyCommand = defineCommand({ meta: { name: "verify", description: "Schedule a verifier-pass for a deleted user." }, args: { user: { type: "string", required: true, description: "Target User.id (already deleted/pseudonymized)." }, tenant: { type: "string", required: false, description: "Tenant id stamped on the audit row." }, actor: { type: "string", required: false, description: "Operator id stamped on the audit row." }, }, async run({ args }) { const userId = String(args.user); const tenantId = args.tenant ? String(args.tenant) : null; const actorId = args.actor ? String(args.actor) : "cli-operator"; const requestId = randomUUID(); const { createAuditEvent } = await import("@toolctrl/db/audit-events.server"); await createAuditEvent({ tenantId, actorId, actorType: "admin", action: "VERIFY_USER_DELETION", targetType: "User", targetId: userId, regulatoryScope: ["gdpr"], dataSensitivity: "pii", outcome: "success", metadata: { requestId, intent: "verify", source: "cli" }, }); consola.success(`Verifier-pass queued for user=${userId} requestId=${requestId}`); }, });