feat(client-archive): async Documenso voids + next-in-line sales notifications

Post-archive side-effects now run with backpressure:
- Documenso envelope voids enqueue to BullMQ documents queue with retry/DLQ
- Released berths fan out a "next in line" notification to port users with
  interests.change_stage; informational only, no auto stage transitions

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-05-06 19:12:55 +02:00
parent 8c02f88cbd
commit 1ae5d88af4
3 changed files with 159 additions and 5 deletions

View File

@@ -15,6 +15,26 @@ export const documentsWorker = new Worker(
await processDocumensoPoll();
break;
}
case 'documenso-void': {
// Async cleanup of a Documenso envelope. Producers: smart-archive
// (when the operator opts to void in-flight envelopes during
// client archive). BullMQ retries with exponential backoff per
// QUEUE_CONFIGS; permanently-failed jobs land in the DLQ via
// the failed-job listener.
const { documentId, documensoId, portId } = job.data as {
documentId: string;
documensoId: string;
portId: string;
};
if (!documensoId) {
logger.warn({ documentId }, 'documenso-void: no documensoId, skipping');
return;
}
const { voidDocument } = await import('@/lib/services/documenso-client');
await voidDocument(documensoId, portId);
logger.info({ documentId, documensoId, portId }, 'Documenso envelope voided');
break;
}
default:
logger.warn({ jobName: job.name }, 'Unknown documents job');
}