fix(platform-api): resolve 3 TS build errors crashing Vercel deployment#11
Conversation
…elay attempt policy union type Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe pull request modifies how the replayed flag is derived from payment capture results in the booking completion service, changing from accessing a nested field to using a top-level field. Additionally, the relay attempt policy type signature is extended to include Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Why this PR exists
After merging Phase 3 Slice 1 (#10 — booking completion + payment domain event), the
platform-apiTypeScript compiler started emitting 3 errors that crash thetscwatch process and, critically, fail the Vercel build, blocking any deployment.The errors were introduced when
publishPaymentCapturedand the booking-completion payment-capture path were wired up in #10, but two type-level contracts were not updated to accommodate the newPaymentCapturedDomainEvent.Root cause walkthrough
Error 1 — Wrong property accessor on
captureResultFile:
services/platform-api/src/bookings/bookings.service.ts:458PaymentsService.capturePaymentForBookingreturns:replayedis a top-level field on the result wrapper, not on thePaymentRecordentity itself (which only carries persistence fields). The code was incorrectly drilling intocaptureResult.payment.replayedinstead of readingcaptureResult.replayed.Fix:
captureResult.payment.replayed ?? false→captureResult.replayedThe
?? falsefallback is also removed —replayedis typed asboolean(non-optional), so the nullish coalescing was redundant and masked the wrong accessor.Errors 2 & 3 —
PaymentCapturedDomainEventexcluded from relay attempt policy unionFile:
services/platform-api/src/orchestration/relay-attempt-policy.ts:7Manifested in:
relay-domain-event.publisher.ts:209and:236BookingAcceptedRelayAttemptContextwas originally designed to serve only the booking-accepted and booking-declined relay flows:When
publishPaymentCapturedwas added toRelayBookingDomainEventPublisherin #10, it reused the samerelayAttemptPolicy.shouldFailAttempt(...)call — passing aPaymentCapturedDomainEventasevent. BecausePaymentCapturedDomainEventwas never added to the context union, TypeScript correctly rejected the assignment at both call sites (attempt 1 at line 209 and the retry loop at line 236).Fix: Add
PaymentCapturedDomainEventto the import and extend the union:The
NoopBookingAcceptedRelayAttemptPolicyimplementation ignores the context argument entirely (shouldFailAttempt(): boolean { return false; }), so no runtime behaviour changes.Changes
services/platform-api/src/bookings/bookings.service.tsreplayedfrom result wrapper, not fromPaymentRecordservices/platform-api/src/orchestration/relay-attempt-policy.tsPaymentCapturedDomainEventValidation
No logic changes, no test surface added or removed. Both fixes are purely type-contract corrections aligning the code to the types that already existed in
@quickwerk/domain.Summary by CodeRabbit