Skip to content

fix(platform-api): resolve 3 TS build errors crashing Vercel deployment#11

Merged
imKXNNY merged 1 commit into
mainfrom
fix/ts-build-crash-payment-relay-types
Apr 1, 2026
Merged

fix(platform-api): resolve 3 TS build errors crashing Vercel deployment#11
imKXNNY merged 1 commit into
mainfrom
fix/ts-build-crash-payment-relay-types

Conversation

@imKXNNY

@imKXNNY imKXNNY commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

Why this PR exists

After merging Phase 3 Slice 1 (#10 — booking completion + payment domain event), the platform-api TypeScript compiler started emitting 3 errors that crash the tsc watch process and, critically, fail the Vercel build, blocking any deployment.

The errors were introduced when publishPaymentCaptured and the booking-completion payment-capture path were wired up in #10, but two type-level contracts were not updated to accommodate the new PaymentCapturedDomainEvent.


Root cause walkthrough

Error 1 — Wrong property accessor on captureResult

File: services/platform-api/src/bookings/bookings.service.ts:458

error TS2339: Property 'replayed' does not exist on type 'PaymentRecord'.

PaymentsService.capturePaymentForBooking returns:

Promise<{ ok: true; payment: PaymentRecord; replayed: boolean }>

replayed is a top-level field on the result wrapper, not on the PaymentRecord entity itself (which only carries persistence fields). The code was incorrectly drilling into captureResult.payment.replayed instead of reading captureResult.replayed.

Fix: captureResult.payment.replayed ?? falsecaptureResult.replayed

The ?? false fallback is also removed — replayed is typed as boolean (non-optional), so the nullish coalescing was redundant and masked the wrong accessor.


Errors 2 & 3 — PaymentCapturedDomainEvent excluded from relay attempt policy union

File: services/platform-api/src/orchestration/relay-attempt-policy.ts:7
Manifested in: relay-domain-event.publisher.ts:209 and :236

error TS2322: Type 'PaymentCapturedDomainEvent' is not assignable to
type 'BookingAcceptedDomainEvent | BookingDeclinedDomainEvent'.

BookingAcceptedRelayAttemptContext was originally designed to serve only the booking-accepted and booking-declined relay flows:

export type BookingAcceptedRelayAttemptContext = {
  event: BookingAcceptedDomainEvent | BookingDeclinedDomainEvent;
  attempt: number;
  maxAttempts: number;
};

When publishPaymentCaptured was added to RelayBookingDomainEventPublisher in #10, it reused the same relayAttemptPolicy.shouldFailAttempt(...) call — passing a PaymentCapturedDomainEvent as event. Because PaymentCapturedDomainEvent was 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 PaymentCapturedDomainEvent to the import and extend the union:

// before
import type { BookingAcceptedDomainEvent, BookingDeclinedDomainEvent } from '@quickwerk/domain';
event: BookingAcceptedDomainEvent | BookingDeclinedDomainEvent;

// after
import type { BookingAcceptedDomainEvent, BookingDeclinedDomainEvent, PaymentCapturedDomainEvent } from '@quickwerk/domain';
event: BookingAcceptedDomainEvent | BookingDeclinedDomainEvent | PaymentCapturedDomainEvent;

The NoopBookingAcceptedRelayAttemptPolicy implementation ignores the context argument entirely (shouldFailAttempt(): boolean { return false; }), so no runtime behaviour changes.


Changes

File Change
services/platform-api/src/bookings/bookings.service.ts Read replayed from result wrapper, not from PaymentRecord
services/platform-api/src/orchestration/relay-attempt-policy.ts Import + union extended to include PaymentCapturedDomainEvent

Validation

cd services/platform-api && npx tsc --noEmit
# exits 0 — no errors

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

  • Bug Fixes
    • Corrected payment replay-state detection during booking completion to ensure accurate tracking of replayed payment transactions.
    • Extended payment capture event support in relay attempt policies to improve handling of payment-related relay scenarios.

…elay attempt policy union type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 653c0c24-4232-4f56-86d8-30c5d859caf6

📥 Commits

Reviewing files that changed from the base of the PR and between 29dbb12 and 9047d7f.

📒 Files selected for processing (2)
  • services/platform-api/src/bookings/bookings.service.ts
  • services/platform-api/src/orchestration/relay-attempt-policy.ts

📝 Walkthrough

Walkthrough

The 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 PaymentCapturedDomainEvent as a valid event type.

Changes

Cohort / File(s) Summary
Booking Service Payment Handling
services/platform-api/src/bookings/bookings.service.ts
Modified completeBooking to derive paymentReplayed from captureResult.replayed instead of captureResult.payment.replayed ?? false, altering the data source for the replayed flag emitted in the payment.captured domain event.
Relay Orchestration Type Extension
services/platform-api/src/orchestration/relay-attempt-policy.ts
Extended BookingAcceptedRelayAttemptContext event union type to include PaymentCapturedDomainEvent alongside existing BookingAcceptedDomainEvent and BookingDeclinedDomainEvent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A captured payment hops from nested deep,
To top-level fields where values leap,
Events relay with clearer sight,
The replayed flag shines ever bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: fixing TypeScript build errors that were crashing Vercel deployments. It aligns directly with the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ts-build-crash-payment-relay-types

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@imKXNNY imKXNNY merged commit 89d49ef into main Apr 1, 2026
1 check passed
@imKXNNY imKXNNY deleted the fix/ts-build-crash-payment-relay-types branch April 1, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant