Skip to content
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

refactor: use zod in builders #10117

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

Qjuh
Copy link
Contributor

@Qjuh Qjuh commented Feb 4, 2024

Please describe the changes this PR makes and why it should be merged:

Replaces shapeshift with zod and zod-validation-error in @discordjs/builders.

Closes #9468.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

Copy link

vercel bot commented Feb 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview May 26, 2024 0:32am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview May 26, 2024 0:32am

Copy link

codecov bot commented Feb 4, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 95.93%. Comparing base (a468ae8) to head (9a91657).

Files Patch % Lines
...ers/src/components/selectMenu/ChannelSelectMenu.ts 16.66% 5 Missing ⚠️
...src/components/selectMenu/MentionableSelectMenu.ts 20.00% 4 Missing ⚠️
...ilders/src/components/selectMenu/RoleSelectMenu.ts 33.33% 2 Missing ⚠️
...ilders/src/components/selectMenu/UserSelectMenu.ts 33.33% 2 Missing ⚠️
...ilders/src/components/selectMenu/BaseSelectMenu.ts 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            main   #10117       +/-   ##
==========================================
+ Coverage   1.42%   95.93%   +94.51%     
==========================================
  Files         64       44       -20     
  Lines       3238     3664      +426     
  Branches      64      117       +53     
==========================================
+ Hits          46     3515     +3469     
+ Misses      3192      149     -3043     
Flag Coverage Δ
brokers 95.93% <95.83%> (+94.51%) ⬆️
builders 95.93% <95.83%> (+94.51%) ⬆️
collection 95.93% <95.83%> (+94.51%) ⬆️
discord.js 95.93% <95.83%> (+94.51%) ⬆️
formatters 95.93% <95.83%> (+94.51%) ⬆️
guide 95.93% <95.83%> (+94.51%) ⬆️
next 95.93% <95.83%> (+94.51%) ⬆️
proxy 95.93% <95.83%> (+94.51%) ⬆️
rest 95.93% <95.83%> (+94.51%) ⬆️
util 95.93% <95.83%> (+94.51%) ⬆️
utilities 95.93% <95.83%> (+94.51%) ⬆️
voice 95.93% <95.83%> (+94.51%) ⬆️
website 95.93% <95.83%> (+94.51%) ⬆️
ws 95.93% <95.83%> (+94.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Qjuh Qjuh marked this pull request as ready for review February 4, 2024 19:32
@Qjuh Qjuh requested review from a team and iCrawl as code owners February 4, 2024 19:32
Copy link
Member

@vladfrangu vladfrangu left a comment

Choose a reason for hiding this comment

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

Also, this needs a rebase

packages/builders/src/util/validation.ts Show resolved Hide resolved
pnpm-lock.yaml Outdated Show resolved Hide resolved
@favna
Copy link
Contributor

favna commented Apr 17, 2024

Builders used to use Zod but there were many many complaints about it. That was after /builders initially used the ow library as well. It was changed to the at the time freshly made shapeshift. One of the reasons for us to even make shapeshift was improvements to /builders.

I can reason this is related to confusing errors (the actual linked issue is a duplicate). I very strongly recommend you instead contribute to Shapeshift by fulfilling this issue for which most work is already finished in this pr and only unit tests need to be updated. Once that issue is resolved custom messages can be assigned in /builders and get very clear errors.

Also relevant:

@didinele
Copy link
Member

This has all already been discussed in internals, albeit rather scattered, see:

there's probably more if you search for "shapeshift".

@favna
Copy link
Contributor

favna commented Apr 17, 2024

Copying my message from Discord to here after reading that conversation:

So I understand the argument of "it's still a draft", but there's also a good reason for that, there's simply still tasks to do. I've buggered @vladfrangu and @kyranet for (checks date of PR) 1,5 years now to help me with the PR because I'm inclined to think that I overcorrected in the source code as evident from what I see get returned in the unit tests, but I've never received any. Ergo, PR is stuck.

Adding to it, technically I could finish that PR in a couple of days if I really sit down and just finish it. I've just been lacking the motivation to do so. Once it's finished though, adding custom messages is a singe.

@favna
Copy link
Contributor

favna commented May 20, 2024

Dumping a comment on here as well as follow-up to my reply above, the shapeshfit version with custom messages has been released. We can review where we want to take this PR further now.

@didinele
Copy link
Member

I'm personally of the opinion that we should go further with zod after all.

I understand that an effort was made for that shapeshift release, but it's too little too late, on top of other accumulating issues. I know we keep on going back and forth on this, but the argument of "just wait until zod has an issue and we decide to switch back" really falls apart considering zod is a massive project that iterates quicker than shapeshift ever could - on top of, at least at this time, to my knowledge, having no big issues for us, while shapeshift has been problematic in various ways since the moment we introduced it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

None yet

5 participants