Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(payments-next): actions response validation and dto updates #18457

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

julianpoy
Copy link
Member

Because

  • We want response validation
  • We want a better way of doing IO validation for actions without the hassle of conversion to class-validator format each time

This pull request

  • Adds a decorator that does the above

Issue that this pull request solves

Closes FXA-10708

@julianpoy julianpoy force-pushed the FXA-10708 branch 7 times, most recently from c845324 to 74e2881 Compare February 26, 2025 19:13
cartId,
})
);
const cart = await actionsService.restartCart({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the rationale behind sometimes doing the const { something } pojo initialization vs the const something assignment? I see both at play, but am not sure I understand the reason behind it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintaining compatibility. Class validator requires that values be classes, and primitive values can't be transformed to a class like an object can. Because of that, I have moved some methods that previously returned a primitive type over to an object return type that then subsequently gets spread out in the actions layer to return the primitive we want in the frontend.

* Will capture timing for this method and send them to StatsD. Requires the target class to have statsd exposed as a public property.
* Timings will appear as ClassName_methodName in StatsD.
*/
export function NextIOValidator<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change this to something like MethodTypeValidator? IO is an overloaded term that feels like less of a "clear" fit here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term type is overloaded imo, especially in TypeScript, and additionally means something that doesn't impact runtime.

@julianpoy julianpoy marked this pull request as ready for review February 26, 2025 20:08
@julianpoy julianpoy requested a review from a team as a code owner February 26, 2025 20:08
Because:

- We want response validation
- We want a better way of doing IO validation for actions without the
  hassle of conversion to class-validator format each time

This commit:

- Adds a decorator that does the above

Closes FXA-10708
@julianpoy julianpoy merged commit 62491e6 into main Feb 27, 2025
23 checks passed
@julianpoy julianpoy deleted the FXA-10708 branch February 27, 2025 22:00
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants