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

chore: Convert to TS - services charts, user, orgUploadToken, image #3440

Merged
merged 15 commits into from
Nov 7, 2024

Conversation

suejung-sentry
Copy link
Contributor

@suejung-sentry suejung-sentry commented Oct 24, 2024

Convert a batch of files to ts
Closes codecov/engineering-team#2721

@codecov-qa
Copy link

codecov-qa bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.10%. Comparing base (81806ae) to head (9b1ef76).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3440      +/-   ##
==========================================
- Coverage   99.10%   99.10%   -0.01%     
==========================================
  Files         805      804       -1     
  Lines       14134    14125       -9     
  Branches     3968     3961       -7     
==========================================
- Hits        14007    13998       -9     
  Misses        118      118              
  Partials        9        9              
Files with missing lines Coverage Δ
src/services/image/useImage.ts 100.00% <100.00%> (ø)
src/services/orgUploadToken/useOrgUploadToken.ts 100.00% <100.00%> (ø)
...Contents/branch/file/usePrefetchBranchFileEntry.ts 100.00% <100.00%> (ø)
src/services/pathContents/utils.ts 100.00% <ø> (ø)
src/services/user/useIsCurrentUserAnAdmin.ts 100.00% <100.00%> (ø)
src/services/user/useOnboardUser.ts 100.00% <100.00%> (ø)
src/services/user/useResyncUser.ts 100.00% <100.00%> (ø)
src/services/user/useUpdateProfile.ts 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <ø> (ø)
Services 99.41% <100.00%> (-0.01%) ⬇️
Shared 99.74% <ø> (ø)
UI 99.15% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81806ae...9b1ef76. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3440      +/-   ##
==========================================
- Coverage   99.10%   99.10%   -0.01%     
==========================================
  Files         805      804       -1     
  Lines       14134    14125       -9     
  Branches     3961     3968       +7     
==========================================
- Hits        14007    13998       -9     
  Misses        118      118              
  Partials        9        9              
Files with missing lines Coverage Δ
src/services/image/useImage.ts 100.00% <100.00%> (ø)
src/services/orgUploadToken/useOrgUploadToken.ts 100.00% <100.00%> (ø)
...Contents/branch/file/usePrefetchBranchFileEntry.ts 100.00% <100.00%> (ø)
src/services/pathContents/utils.ts 100.00% <ø> (ø)
src/services/user/useIsCurrentUserAnAdmin.ts 100.00% <100.00%> (ø)
src/services/user/useOnboardUser.ts 100.00% <100.00%> (ø)
src/services/user/useResyncUser.ts 100.00% <100.00%> (ø)
src/services/user/useUpdateProfile.ts 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <ø> (ø)
Services 99.41% <100.00%> (-0.01%) ⬇️
Shared 99.74% <ø> (ø)
UI 99.15% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81806ae...9b1ef76. Read the comment docs.

Copy link

codecov-public-qa bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.10%. Comparing base (81806ae) to head (9b1ef76).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3440      +/-   ##
==========================================
- Coverage   99.10%   99.10%   -0.01%     
==========================================
  Files         805      804       -1     
  Lines       14134    14125       -9     
  Branches     3968     3961       -7     
==========================================
- Hits        14007    13998       -9     
  Misses        118      118              
  Partials        9        9              
Files Coverage Δ
src/services/image/useImage.ts 100.00% <100.00%> (ø)
src/services/orgUploadToken/useOrgUploadToken.ts 100.00% <100.00%> (ø)
...Contents/branch/file/usePrefetchBranchFileEntry.ts 100.00% <100.00%> (ø)
src/services/pathContents/utils.ts 100.00% <ø> (ø)
src/services/user/useIsCurrentUserAnAdmin.ts 100.00% <100.00%> (ø)
src/services/user/useOnboardUser.ts 100.00% <100.00%> (ø)
src/services/user/useResyncUser.ts 100.00% <100.00%> (ø)
src/services/user/useUpdateProfile.ts 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <ø> (ø)
Services 99.41% <100.00%> (-0.01%) ⬇️
Shared 99.74% <ø> (ø)
UI 99.15% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81806ae...9b1ef76. Read the comment docs.

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.10%. Comparing base (81806ae) to head (7feac53).

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3440      +/-   ##
==========================================
- Coverage   99.10%   99.10%   -0.01%     
==========================================
  Files         805      804       -1     
  Lines       14134    14125       -9     
  Branches     3961     3968       +7     
==========================================
- Hits        14007    13998       -9     
  Misses        118      118              
  Partials        9        9              
Files with missing lines Coverage Δ
src/services/image/useImage.ts 100.00% <100.00%> (ø)
src/services/orgUploadToken/useOrgUploadToken.ts 100.00% <100.00%> (ø)
...Contents/branch/file/usePrefetchBranchFileEntry.ts 100.00% <100.00%> (ø)
src/services/pathContents/utils.ts 100.00% <ø> (ø)
src/services/user/useIsCurrentUserAnAdmin.ts 100.00% <100.00%> (ø)
src/services/user/useOnboardUser.ts 100.00% <100.00%> (ø)
src/services/user/useResyncUser.ts 100.00% <100.00%> (ø)
src/services/user/useUpdateProfile.ts 100.00% <100.00%> (ø)
src/shared/ListRepo/ReposTable/ReposTable.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <ø> (ø)
Services 99.41% <100.00%> (-0.01%) ⬇️
Shared 99.74% <100.00%> (ø)
UI 99.15% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81806ae...7feac53. Read the comment docs.

Copy link

codecov bot commented Nov 5, 2024

Bundle Report

Changes will decrease total bundle size by 6.14MB (-34.7%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.75MB 430 bytes (-0.01%) ⬇️
gazebo-production-system-esm 5.8MB 398 bytes (0.01%) ⬆️
gazebo-production-array-push (removed) 6.14MB (-100.0%) ⬇️

@codecov-staging
Copy link

codecov-staging bot commented Nov 5, 2024

Bundle Report

Changes will decrease total bundle size by 6.14MB (-34.7%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system 5.75MB 430 bytes (-0.01%) ⬇️
gazebo-staging-system-esm* 5.8MB 214 bytes (0.0%) ⬆️
gazebo-staging-array-push (removed) 6.14MB (-100.0%) ⬇️

ℹ️ *Bundle size includes cached data from a previous commit

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Nov 5, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
5b18e77 Tue, 05 Nov 2024 05:46:58 GMT Expired Expired
87488de Tue, 05 Nov 2024 17:19:03 GMT Expired Expired
a9c39d6 Tue, 05 Nov 2024 17:49:53 GMT Expired Expired
e3e1a90 Wed, 06 Nov 2024 23:13:03 GMT Expired Expired
7feac53 Wed, 06 Nov 2024 23:29:54 GMT Expired Expired
7feac53 Wed, 06 Nov 2024 23:31:58 GMT Expired Expired
9b1ef76 Wed, 06 Nov 2024 23:46:36 GMT Cloud Enterprise

@suejung-sentry suejung-sentry marked this pull request as ready for review November 5, 2024 17:32
Copy link
Contributor

@nicholas-codecov nicholas-codecov left a comment

Choose a reason for hiding this comment

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

When we're converting data-fetching/interacting services over to TS, we want to utilize Zod schemas so that we can validate the API response and ensure that we receive the correct data. As well, when the parsing is successful, we get the correct types back and through inference Query will assign those types to the data field etc. from useQuery.

We have some notion docs that you can take a peak at that walk through this here

Would you mind taking a second pass at these data related hooks and update them to use Zod schemas to validate their responses? If you have any questions around this, feel free to reach out, and we can chat about it.

Copy link
Contributor

@nicholas-codecov nicholas-codecov left a comment

Choose a reason for hiding this comment

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

Couple of comments to take a peak at.

Comment on lines 52 to 56
return Promise.reject({
status: 404,
data: {},
dev: 'useOwner - 404 failed to parse',
} satisfies NetworkErrorObject)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the new rejectNetworkError helper function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed - was gonna make a sweep on this so you caught it before then - sorry for sloppy state then

src/services/user/useOwner.ts Outdated Show resolved Hide resolved
src/services/orgUploadToken/useRegenerateOrgUploadToken.ts Outdated Show resolved Hide resolved
src/services/orgUploadToken/useRegenerateOrgUploadToken.ts Outdated Show resolved Hide resolved
@suejung-sentry
Copy link
Contributor Author

thanks for reviewing - it was a mistake to try to do the zod stuff for some of these complicated / high-use hooks in this same PR that already had a bunch of other stuff going on so I'll pull those out here - codecov/engineering-team#2857
I still have to debug an issue with the orgUploadToken (and the corresponding UI components for those are still jsx so I may just do an end-to-end for that use case while I'm at it). And then useOwner broke like 90% of the mocks because a bunch of fields that are supposed required per schema weren't defined in test mocks.

Okay so with that this pared down PR is ready again for review!

@@ -1,30 +0,0 @@
import { useQuery } from '@tanstack/react-query'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these files are not used - removed

const selectedOrg = input?.selectedOrg
mutationFn: (input: { formData?: unknown; selectedOrg?: string }) => {
const formData = input.formData
const selectedOrg = input.selectedOrg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add zod schema validation in here - codecov/engineering-team#2857

@@ -61,7 +61,7 @@ export function useUpdateProfile({ provider }) {
`

return useMutation({
mutationFn: ({ name, email }) => {
mutationFn: ({ name, email }: { name: string; email: string }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add zod schema validation here codecov/engineering-team#2857

Copy link
Contributor

@nicholas-codecov nicholas-codecov left a comment

Choose a reason for hiding this comment

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

LGTM

@suejung-sentry suejung-sentry added this pull request to the merge queue Nov 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2024
@suejung-sentry suejung-sentry added this pull request to the merge queue Nov 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2024
@suejung-sentry suejung-sentry added this pull request to the merge queue Nov 7, 2024
Merged via the queue into main with commit bee4722 Nov 7, 2024
59 of 62 checks passed
@suejung-sentry suejung-sentry deleted the sshin/chore/2721 branch November 7, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Services from JS to TS (Part 2)
3 participants