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

Closed
wants to merge 14 commits into from
Closed

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.

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 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Aug 23, 2024 7:36pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Aug 23, 2024 7:36pm

Copy link

codecov bot commented Feb 4, 2024

Codecov Report

Attention: Patch coverage is 94.80969% with 15 lines in your changes missing coverage. Please review.

Project coverage is 49.12%. Comparing base (e2e71b4) to head (914cf54).

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 ⚠️
packages/builders/src/util/validation.ts 88.88% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #10117       +/-   ##
===========================================
+ Coverage   35.45%   49.12%   +13.66%     
===========================================
  Files         228       93      -135     
  Lines       14319    10339     -3980     
  Branches     1254      692      -562     
===========================================
+ Hits         5077     5079        +2     
+ Misses       9198     5257     -3941     
+ Partials       44        3       -41     
Flag Coverage Δ
builders 91.27% <94.80%> (-0.31%) ⬇️

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.

@Qjuh Qjuh force-pushed the refactor/zod-builders branch from 15460ea to 6b43f5b Compare May 26, 2024 12:25
@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.

@didinele didinele mentioned this pull request Aug 30, 2024
12 tasks
@Qjuh
Copy link
Contributor Author

Qjuh commented Sep 10, 2024

Superseded by #10448

@Qjuh Qjuh closed this Sep 10, 2024
@almeidx almeidx removed the blocked label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants