feat(agreements): emit milestone events from updateMilestone (issue #6)#33
Conversation
…halos-Infrastructure#6) Implements GrantsFox OSS issue Thalos-Infrastructure#6 (Closes: Thalos-Infrastructure#6). Domain code in AgreementsService.updateMilestone() now emits typed events on the in-process bus (from Thalos-Infrastructure#3) using the shared constants in src/events/agreement-events.ts. NotificationsService listens via @onevent so emails fire end-to-end for both flows. Behavior: - status='approved' -> emits AgreementEventName.MilestoneApproved with the agreement title/amount/asset, milestone index and description enriched from the row (acceptance criterion: approving a milestone notifies participants with the correct amount/description). - evidence_description and/or evidence_url set on the DTO -> emits AgreementEventName.EvidenceSubmitted (acceptance criterion: submitting evidence notifies the other participants). - Both events may fire on the same call when both conditions hold. DTO changes (UpdateMilestoneDto): - Added optional evidence_description (1..2000 chars), evidence_url (validated by IsUrl), submitter_name (1..120 chars). All backward compatible: existing callers that only send milestone_index/status/actor_wallet keep working. Error isolation (DoD): - AgreementsService.safeEmit() wraps the sync EventEmitter2.emit so a throwing listener never bubbles back into updateMilestone. - @onevent handlers in NotificationsService also wrap their await call in try/catch for the async path. - safeEmit returns boolean with a warn-level log (not error) so observability distinguishes 'no listeners' from 'sync throw'. Visual evidence: - docs/EMAIL_NOTIFICATIONS_PLAN.md explains how to reproduce locally including the failure-isolation case (RESEND_API_KEY=re_invalid_key). - docs/samples/milestone-events.http has ready-to-run curl snippets for both flows.
|
@iyanumajekodunmi756 is attempting to deploy a commit to the ManuelJG's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hello @iyanumajekodunmi756, your PR looks good. Could you please resolve the conflicts? Thank you for your colaboration |
|
Could you please resolve the conflicts? |
|
Could you please resolve the conflicts? Looking forward to your PR's resolution. Thank you. |
|
Hi @iyanumajekodunmi756 — solid work on #6 and thanks for the docs/samples. @leandromasotti’s approval still stands on the approach, but this PR cannot merge as-is. Blockers
After rebase, keep:
Drop / reconcile on rebase:
DoD checklist post-rebase:
Please push the rebased branch and we can merge quickly. Thanks! |
Implements GrantsFox OSS issue #6 (Closes: #6).
Domain code in AgreementsService.updateMilestone() now emits typed events on the in-process bus (from #3) using the shared constants in src/events/agreement-events.ts. NotificationsService listens via @onevent so emails fire end-to-end for both flows.
Behavior:
DTO changes (UpdateMilestoneDto):
Error isolation (DoD):
Visual evidence:
closes #6