Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: switch to generated types#1394

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
code-asher merged 10 commits intomainfromasher/generated-types
May 12, 2022
Merged

Conversation

code-asher
Copy link
Member

@code-ashercode-asher commentedMay 11, 2022
edited
Loading

Closes#1210. More information can be found in the commits!

That way the renderer only takes `string` for example when rendering thename field instead of `string | number` when the interface has somefields that are strings and some fields are numbers.This will be necessary when switching to generated types since some ofthe fields are numbers (like the owner count on a template).
In some places the organization ID is part of the URL but not part ofthe request so I separated out the ID into a separate argument in therelevant API functions.Otherwise this was a straightforward replacement where I mostly onlyneeded to change some of the interface names (User instead ofUserResponse for example) and add a few missing but required properties.Arguably `parameter_values` could be made optional but I am just passingin an empty array for now mostly just to make it obvious that we couldpass stuff there if we need to.I kind of winged the template form; I am not sure what the differencebetween a template and template version is or why the latter comesbefore the former so the form just returns all the data required tocreate both.
@codecov
Copy link

codecovbot commentedMay 11, 2022
edited
Loading

Codecov Report

Merging#1394 (f8f6125) intomain (e8e6d3c) willincrease coverage by0.01%.
The diff coverage is72.05%.

@@            Coverage Diff             @@##             main    #1394      +/-   ##==========================================+ Coverage   67.01%   67.03%   +0.01%==========================================  Files         287      288       +1       Lines       18850    19083     +233       Branches      241      241              ==========================================+ Hits        12633    12792     +159- Misses       4931     4985      +54- Partials     1286     1306      +20
FlagCoverage Δ
unittest-go-macos-latest54.22% <ø> (+0.09%)⬆️
unittest-go-postgres-65.60% <ø> (+0.14%)⬆️
unittest-go-ubuntu-latest56.50% <ø> (+0.03%)⬆️
unittest-go-windows-202252.60% <ø> (+0.19%)⬆️
unittest-js74.19% <72.05%> (-0.05%)⬇️
Impacted FilesCoverage Δ
codersdk/organizations.go68.88% <ø> (ø)
codersdk/users.go63.79% <ø> (ø)
codersdk/workspaces.go63.63% <ø> (ø)
site/src/components/Footer/Footer.tsx100.00% <ø> (ø)
site/src/components/NavbarView/NavbarView.tsx93.33% <ø> (ø)
site/src/components/Table/Table.tsx96.00% <ø> (ø)
site/src/components/UserDropdown/UsersDropdown.tsx96.15% <ø> (ø)
...src/components/UserProfileCard/UserProfileCard.tsx100.00% <ø> (ø)
site/src/components/UsersTable/UsersTable.tsx96.00% <ø> (ø)
site/src/components/Workspace/Workspace.tsx100.00% <ø> (ø)
... and31 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatee8e6d3c...f8f6125. Read thecomment docs.

Except for UserAgent which seems to be purely frontend andReconnectingPTYRequest which is not in codersdk so I am just leaving itfor now.
@code-ashercode-asher marked this pull request as ready for reviewMay 11, 2022 19:44
@code-ashercode-asher requested review frompresleyp anda team ascode ownersMay 11, 2022 19:44
This reverts commitf5d1b62.This will be added in a separate PR.
@code-ashercode-asher changed the titleSwitch to generated typeschore: switch to generated typesMay 11, 2022
@presleyp
Copy link
Contributor

I don't have time to properly review right now but I wanted to mention that I think more fields onCreateWorkspaceBuildRequest are optional than what shows intypesGenerated - if I understand right, everything buttransition. Not sure if this is the only case missing optionality. If that's easy to fix it would be nice to have it right before we start relying more on generated types.

@code-asher
Copy link
MemberAuthor

code-asher commentedMay 11, 2022
edited
Loading

Looks like you are right. Fortunately it is pretty easy, we just need to addomitempty and then runmake gen (ormake site/src/api/typesGenerated.ts); I will do that now forCreateWorkspaceBuildRequest.

I am not sure what the best way to tackle this is (not sure if I have to read the code to find what is optional or if everything without arequired tag can be safely considered optional) but I think I will at the very least check all the*Request interfaces to make sure they have the right optionalities.

@Kira-Pilot
Copy link
Member

nice! seems likemake gen is run on save - is that right?

@code-asher
Copy link
MemberAuthor

code-asher commentedMay 11, 2022
edited
Loading

All right the request interfaces are looking good.UpdateWorkspaceAutostartRequest andUpdateWorkspaceAutostopRequest have aschedule property that could technically be made optional but I left them as-is so you have to explicitly set an empty string to disable the schedule. Not sure if that is the right call (maybe disabling should be an entirely separate endpoint but that seems like a separate discussion).

@Kira-Pilot I seemake gen running on saves to .sql files (if using VS Code) but not other changes so if we make changes to interfaces or types (or if using a different editor) I think we have to run it manually (entirely possible I missed something though).

Kira-Pilot reacted with thumbs up emoji

Copy link
Member

@Kira-PilotKira-Pilot left a comment

Choose a reason for hiding this comment

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

I'm still learning but this looks good to me!

code-asher reacted with heart emoji
@presleyp
Copy link
Contributor

@code-asher yay thanks! The empty string for schedule makes sense to me.

code-asher reacted with heart emoji

@Emyrk
Copy link
Member

@Kira-Pilot we run it manually. On save is a bit excessive since it does takesome time. But CI will have a failing step if you changed something andmake gen needs to be run again. So I usually let CI tell me if I need to run it 🤷

presleyp and code-asher reacted with thumbs up emojiKira-Pilot and code-asher reacted with rocket emoji

Copy link
Contributor

@presleyppresleyp left a comment

Choose a reason for hiding this comment

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

Super appreciate this!

code-asher reacted with heart emoji
@code-ashercode-asher merged commit26b04cc intomainMay 12, 2022
@code-ashercode-asher deleted the asher/generated-types branchMay 12, 2022 15:01
@missknissmisskniss added this to theV2 Beta milestoneMay 15, 2022
kylecarbs pushed a commit that referenced this pull requestJun 10, 2022
* Make column renderer use the same type as its keyThat way the renderer only takes `string` for example when rendering thename field instead of `string | number` when the interface has somefields that are strings and some fields are numbers.This will be necessary when switching to generated types since some ofthe fields are numbers (like the owner count on a template).* Switch fully to generated typesIn some places the organization ID is part of the URL but not part ofthe request so I separated out the ID into a separate argument in therelevant API functions.Otherwise this was a straightforward replacement where I mostly onlyneeded to change some of the interface names (User instead ofUserResponse for example) and add a few missing but required properties.I kind of winged the template form; I am not sure what the differencebetween a template and template version is or why the latter comesbefore the former so the form just returns all the data required tocreate both.* Delete handwritten typesExcept for UserAgent which seems to be purely frontend andReconnectingPTYRequest which is not in codersdk so I am just leaving itfor now.* Remove implemented omitempty as a future ideaThis was implemented in2d3dc43.* Add missing optionalities to generated request interfaces
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@EmyrkEmyrkEmyrk left review comments

@greyscaledgreyscaledgreyscaled left review comments

@presleyppresleyppresleyp approved these changes

@Kira-PilotKira-PilotKira-Pilot approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
V2 Beta
Development

Successfully merging this pull request may close these issues.

Switch to using generated types
6 participants
@code-asher@presleyp@Kira-Pilot@Emyrk@greyscaled@misskniss

[8]ページ先頭

©2009-2025 Movatter.jp