The issue was the serializer’s return type claimed it returned the original generic T, but the implementation intentionally removes reviewToken and rewrites customer.licenseImageUrl. I updated the return type to model the actual serialized dashboard payload: Omit<T, 'reviewToken' | 'customer'> plus the normalized customer and computed fields.
Build & Push / Pipeline Tests (push) Successful in 1m57s
Test / Type Check (all packages) (push) Successful in 54s
Build & Push / Build & Push Docker Image (push) Successful in 5m39s
Test / API Unit Tests (push) Successful in 1m18s
Test / Homepage Unit Tests (push) Successful in 47s
Test / Carplace Unit Tests (push) Successful in 42s
Test / Admin Unit Tests (push) Successful in 42s
Test / Dashboard Unit Tests (push) Successful in 44s
Test / API Integration Tests (push) Successful in 1m10s

This commit is contained in:
root
2026-08-12 16:54:09 -04:00
parent 8fc88ffc14
commit d616621bb6
@@ -124,6 +124,25 @@ export function buildBookingRequestProgress(reservation: {
}
}
type DashboardReservationCustomer = {
id: string
driverLicense?: string | null
dateOfBirth?: Date | null
address?: unknown
licenseImageUrl?: string | null
licenseValidationStatus?: string | null
}
type SerializedDashboardReservation<T> = Omit<T, 'reviewToken' | 'customer'> & {
customer?: DashboardReservationCustomer | null
paymentMode: string | null
spareWheel: boolean
radioCd: boolean
contractFields: Record<string, string>
workflow: ReturnType<typeof buildReservationWorkflow>
bookingRequest: ReturnType<typeof buildBookingRequestProgress>
}
export function serializeReservationForDashboard<T extends {
extras: unknown
status: string
@@ -131,22 +150,8 @@ export function serializeReservationForDashboard<T extends {
contractNumber: string | null
invoiceNumber: string | null
paymentStatus?: string | null
customer?: {
id: string
driverLicense?: string | null
dateOfBirth?: Date | null
address?: unknown
licenseImageUrl?: string | null
licenseValidationStatus?: string | null
} | null
}>(reservation: T): T & {
paymentMode: string | null
spareWheel: boolean
radioCd: boolean
contractFields: Record<string, string>
workflow: ReturnType<typeof buildReservationWorkflow>
bookingRequest: ReturnType<typeof buildBookingRequestProgress>
} {
customer?: DashboardReservationCustomer | null
}>(reservation: T): SerializedDashboardReservation<T> {
const extras = parseReservationExtras(reservation.extras)
const contractFields = serializeContractFields(extras.contractFields)
const customer =
@@ -160,10 +165,14 @@ export function serializeReservationForDashboard<T extends {
: reservation.customer
// S11: never expose reviewToken on API responses (capability URL secret)
const { reviewToken: _reviewToken, ...safeReservation } = reservation as T & { reviewToken?: unknown }
const {
reviewToken: _reviewToken,
customer: _originalCustomer,
...safeReservation
} = reservation as T & { reviewToken?: unknown }
return {
...safeReservation,
...(safeReservation as Omit<T, 'reviewToken' | 'customer'>),
...(customer !== undefined ? { customer } : {}),
paymentMode: typeof extras.paymentMode === 'string' ? extras.paymentMode : null,
spareWheel: typeof extras.spareWheel === 'boolean' ? extras.spareWheel : false,