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
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:
@@ -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 {
|
export function serializeReservationForDashboard<T extends {
|
||||||
extras: unknown
|
extras: unknown
|
||||||
status: string
|
status: string
|
||||||
@@ -131,22 +150,8 @@ export function serializeReservationForDashboard<T extends {
|
|||||||
contractNumber: string | null
|
contractNumber: string | null
|
||||||
invoiceNumber: string | null
|
invoiceNumber: string | null
|
||||||
paymentStatus?: string | null
|
paymentStatus?: string | null
|
||||||
customer?: {
|
customer?: DashboardReservationCustomer | null
|
||||||
id: string
|
}>(reservation: T): SerializedDashboardReservation<T> {
|
||||||
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>
|
|
||||||
} {
|
|
||||||
const extras = parseReservationExtras(reservation.extras)
|
const extras = parseReservationExtras(reservation.extras)
|
||||||
const contractFields = serializeContractFields(extras.contractFields)
|
const contractFields = serializeContractFields(extras.contractFields)
|
||||||
const customer =
|
const customer =
|
||||||
@@ -160,10 +165,14 @@ export function serializeReservationForDashboard<T extends {
|
|||||||
: reservation.customer
|
: reservation.customer
|
||||||
|
|
||||||
// S11: never expose reviewToken on API responses (capability URL secret)
|
// 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 {
|
return {
|
||||||
...safeReservation,
|
...(safeReservation as Omit<T, 'reviewToken' | 'customer'>),
|
||||||
...(customer !== undefined ? { customer } : {}),
|
...(customer !== undefined ? { customer } : {}),
|
||||||
paymentMode: typeof extras.paymentMode === 'string' ? extras.paymentMode : null,
|
paymentMode: typeof extras.paymentMode === 'string' ? extras.paymentMode : null,
|
||||||
spareWheel: typeof extras.spareWheel === 'boolean' ? extras.spareWheel : false,
|
spareWheel: typeof extras.spareWheel === 'boolean' ? extras.spareWheel : false,
|
||||||
|
|||||||
Reference in New Issue
Block a user