-
Notifications
You must be signed in to change notification settings - Fork 160
feat(parser): support Standard Schema and upgrade to Zod v4 #4164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. I really like how much cleaner the generic type function signatures are now.
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
|
Summary
Changes
This PR updates the codebase to Zod v4 and adds support for it in Parser, as well as making the
parser
Middy.js middleware and class method decorator Standard Schema compatible, meaning it can now accept and parse events using Valibot and other parsing libraries.The PR diff is large, unfortunately I wasn't able to make updates in an orderly fashion because the migration from Zod v3 to v4 has been quite painful. While the upgrade guide is extensive, it focuses primarily on application developers (aka end users). Likewise, the page dedicated to library authors mainly explains how to accept schemas, but falls short of showing complex types or interaction between customer-provided schemas and build-in schemas.
The bulk of the changes in this PR focuses on the built-in envelopes and their unit tests. Envelopes are the area in the utility that is more opinionated and have Zod schemas mixed with custom logic and custom errors. Because of this, the changes required are fairly spread out, causing a large diff.
Aside from this, the rest of the work has gone in expanding types to support Standard Schema and documentation, both in the
docs
page as well as within the code.Finally, while working on this I realized that while we had type-checked tests in the Parser utility, these were not actually type-checking but only showing errors in the IDE. I updated the package
vitest
config to make sure they run correctly.Thank you in advance for your help reviewing.
Issue number: closes #3951, closes #2431
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.