Centralize types provided by Kanae - #849
Merged
Merged
Conversation
✅ Deploy Preview for ucmacm ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
Previously, we had hand-written types and interfaces that would represent the proper schema defined within our OpenAPI schema for Kanae. This was fine but caused a lot of issues - where to actually put them. Types would end up in
src/routes/dashboard/events.tsxbut get used insrc/routes/dashboard/manage/events.tsx, etc. Although I already had a system down for it (types used fordashboard/events.tsxgets stored in there to get used indashboard/manage/events.tsxinstead), this gets confusing very quickly. So, we have a source of truth to our types. Via@hey-api/openapi-ts, we take our OpenAPI schema for Kanae, generate some types, and use them. The types now are defined based off our OpenAPI schema, which actually report the correct types.The idea behind this is that in Kanae's repo, we have scripts that generate the openapi schema, and this is ran on a release workflow. Then, once the release gets published, we'll dispatch this info (alongside the info like the new tag to use), run a curl request to obtain the versioned OpenAPI schema, run the
openapi-tstool and then push out a PR that has the changes generated. So, effectively, our types are now properly versioned, and end-to-end typed.I checked and this doesn't change the logic of our code - it compiles and builds just fine.
Note
The
@hey-api/openapi-tstool produces types that useKanaePages, such asKanaePages[FullEvents]being converted toKanaePagesFullEvents. Don't use these are they don't properly reflect the actual generics of it. That's why a separatesrc/types/pages.tsexists. So what@hey-api/openapi-tswould produceKanaePagesFullEvents, insteadKanaePages<FullEvents>should be used instead.Note
I didn't bother with our Ory types. Doing it would produce a ton of code that would be wasteful and we already have a very constrained and locked-down types and interfaces for it.
Types of changes
What types of changes does your code introduce to the UC Merced's ACM Chapter Website?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply