fix(utils): medusa internal service returned data should match typings (#12715)

FIXES SUP-1824

**What**
The medusa internal service update should always return the data in the expected shape described by the interface. The medusa service should not have to handle the reshapre
This commit is contained in:
Adrien de Peretti
2025-06-12 17:55:49 +02:00
committed by GitHub
parent ea0b297b44
commit ab634a14ba
9 changed files with 94 additions and 25 deletions

View File

@@ -359,15 +359,13 @@ export default class PaymentModuleService
}
)
paymentSession = (
await this.paymentSessionService_.update(
{
id: paymentSession!.id,
data: { ...input.data, ...providerPaymentSession.data },
},
sharedContext
)
)[0]
paymentSession = await this.paymentSessionService_.update(
{
id: paymentSession!.id,
data: { ...input.data, ...providerPaymentSession.data },
},
sharedContext
)
} catch (error) {
if (providerPaymentSession) {
await this.paymentProviderService_.deleteSession(input.provider_id, {
@@ -440,7 +438,7 @@ export default class PaymentModuleService
sharedContext
)
return await this.baseRepository_.serialize(updated[0], { populate: true })
return await this.baseRepository_.serialize(updated, { populate: true })
}
@InjectManager()
@@ -605,7 +603,7 @@ export default class PaymentModuleService
// NOTE: currently there is no update with the provider but maybe data could be updated
const result = await this.paymentService_.update(data, sharedContext)
return await this.baseRepository_.serialize<PaymentDTO>(result[0])
return await this.baseRepository_.serialize<PaymentDTO>(result)
}
// TODO: This method should return a capture, not a payment