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 selfHosted, access, pull, nav #3439

Merged
merged 19 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#2720

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 98.12500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 99.09%. Comparing base (bee4722) to head (4c5c4ac).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/access/useGenerateUserToken.ts 92.30% 1 Missing ⚠️
src/services/navigation/useNavLinks/useNavLinks.ts 99.03% 1 Missing ⚠️
...rc/services/selfHosted/useSelfHostedCurrentUser.ts 88.88% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3439      +/-   ##
==========================================
- Coverage   99.10%   99.09%   -0.02%     
==========================================
  Files         804      804              
  Lines       14125    14187      +62     
  Branches     3961     4024      +63     
==========================================
+ Hits        13998    14058      +60     
- Misses        118      120       +2     
  Partials        9        9              
Files with missing lines Coverage Δ
...b/BundleContent/BundleSelection/BundleSelector.tsx 93.93% <ø> (ø)
src/services/navigation/normalize.ts 100.00% <100.00%> (ø)
src/services/navigation/useLocationParams.ts 100.00% <100.00%> (ø)
...rvices/navigation/useNavLinks/useStaticNavLinks.ts 98.86% <100.00%> (ø)
src/services/selfHosted/useSelfHostedHasAdmins.ts 100.00% <100.00%> (ø)
...rc/services/selfHosted/useSelfHostedSeatsConfig.ts 100.00% <100.00%> (ø)
src/services/usePaginatedContents/constants.ts 100.00% <ø> (ø)
...vices/usePaginatedContents/usePaginatedContents.ts 66.66% <100.00%> (ø)
src/services/access/useGenerateUserToken.ts 92.30% <92.30%> (ø)
src/services/navigation/useNavLinks/useNavLinks.ts 99.01% <99.03%> (ø)
... and 1 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <ø> (ø)
Services 99.36% <98.12%> (-0.06%) ⬇️
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 bee4722...4c5c4ac. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 98.12500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 99.09%. Comparing base (bee4722) to head (4c5c4ac).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/access/useGenerateUserToken.ts 92.30% 1 Missing ⚠️
src/services/navigation/useNavLinks/useNavLinks.ts 99.03% 1 Missing ⚠️
...rc/services/selfHosted/useSelfHostedCurrentUser.ts 88.88% 1 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3439      +/-   ##
==========================================
- Coverage   99.10%   99.09%   -0.02%     
==========================================
  Files         804      804              
  Lines       14125    14187      +62     
  Branches     3961     4017      +56     
==========================================
+ Hits        13998    14058      +60     
- Misses        118      120       +2     
  Partials        9        9              
Files with missing lines Coverage Δ
...b/BundleContent/BundleSelection/BundleSelector.tsx 93.93% <ø> (ø)
src/services/navigation/normalize.ts 100.00% <100.00%> (ø)
src/services/navigation/useLocationParams.ts 100.00% <100.00%> (ø)
...rvices/navigation/useNavLinks/useStaticNavLinks.ts 98.86% <100.00%> (ø)
src/services/selfHosted/useSelfHostedHasAdmins.ts 100.00% <100.00%> (ø)
...rc/services/selfHosted/useSelfHostedSeatsConfig.ts 100.00% <100.00%> (ø)
src/services/usePaginatedContents/constants.ts 100.00% <ø> (ø)
...vices/usePaginatedContents/usePaginatedContents.ts 66.66% <100.00%> (ø)
src/services/access/useGenerateUserToken.ts 92.30% <92.30%> (ø)
src/services/navigation/useNavLinks/useNavLinks.ts 99.01% <99.03%> (ø)
... and 1 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <ø> (ø)
Services 99.36% <98.12%> (-0.06%) ⬇️
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 bee4722...4c5c4ac. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 98.12500% with 3 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/access/useGenerateUserToken.ts 92.30% 1 Missing ⚠️
src/services/navigation/useNavLinks/useNavLinks.ts 99.03% 1 Missing ⚠️
...rc/services/selfHosted/useSelfHostedCurrentUser.ts 88.88% 1 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3439      +/-   ##
==========================================
- Coverage   99.10%   99.09%   -0.02%     
==========================================
  Files         804      804              
  Lines       14125    14187      +62     
  Branches     3961     4024      +63     
==========================================
+ Hits        13998    14058      +60     
- Misses        118      120       +2     
  Partials        9        9              
Files with missing lines Coverage Δ
...b/BundleContent/BundleSelection/BundleSelector.tsx 93.93% <ø> (ø)
src/services/navigation/normalize.ts 100.00% <100.00%> (ø)
src/services/navigation/useLocationParams.ts 100.00% <100.00%> (ø)
...rvices/navigation/useNavLinks/useStaticNavLinks.ts 98.86% <100.00%> (ø)
src/services/selfHosted/useSelfHostedHasAdmins.ts 100.00% <100.00%> (ø)
...rc/services/selfHosted/useSelfHostedSeatsConfig.ts 100.00% <100.00%> (ø)
src/services/usePaginatedContents/constants.ts 100.00% <ø> (ø)
...vices/usePaginatedContents/usePaginatedContents.ts 66.66% <100.00%> (ø)
src/services/access/useGenerateUserToken.ts 92.30% <92.30%> (ø)
src/services/navigation/useNavLinks/useNavLinks.ts 99.01% <99.03%> (ø)
... and 1 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <ø> (ø)
Services 99.36% <98.12%> (-0.06%) ⬇️
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 bee4722...4c5c4ac. Read the comment docs.

Copy link

codecov-public-qa bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 98.12500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 99.09%. Comparing base (bee4722) to head (4c5c4ac).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3439      +/-   ##
==========================================
- Coverage   99.10%   99.09%   -0.02%     
==========================================
  Files         804      804              
  Lines       14125    14187      +62     
  Branches     3961     4024      +63     
==========================================
+ Hits        13998    14058      +60     
- Misses        118      120       +2     
  Partials        9        9              
Files Coverage Δ
...b/BundleContent/BundleSelection/BundleSelector.tsx 93.93% <ø> (ø)
src/services/navigation/normalize.ts 100.00% <100.00%> (ø)
src/services/navigation/useLocationParams.ts 100.00% <100.00%> (ø)
...rvices/navigation/useNavLinks/useStaticNavLinks.ts 98.86% <100.00%> (ø)
src/services/selfHosted/useSelfHostedHasAdmins.ts 100.00% <100.00%> (ø)
...rc/services/selfHosted/useSelfHostedSeatsConfig.ts 100.00% <100.00%> (ø)
src/services/usePaginatedContents/constants.ts 100.00% <ø> (ø)
...vices/usePaginatedContents/usePaginatedContents.ts 66.66% <100.00%> (ø)
src/services/access/useGenerateUserToken.ts 92.30% <92.30%> (ø)
src/services/navigation/useNavLinks/useNavLinks.ts 99.01% <99.03%> (ø)
... and 1 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <ø> (ø)
Services 99.36% <98.12%> (-0.06%) ⬇️
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 bee4722...4c5c4ac. Read the comment docs.

Copy link

codecov bot commented Nov 5, 2024

Bundle Report

Changes will increase total bundle size by 1.1kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.75MB 569 bytes (0.01%) ⬆️
gazebo-production-system-esm 5.8MB 529 bytes (0.01%) ⬆️

@codecov-staging
Copy link

codecov-staging bot commented Nov 5, 2024

Bundle Report

Changes will increase total bundle size by 1.1kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system-esm 5.8MB 529 bytes (0.01%) ⬆️
gazebo-staging-system 5.75MB 569 bytes (0.01%) ⬆️

@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
fbb038a Tue, 05 Nov 2024 03:13:32 GMT Expired Expired
87d588a Tue, 05 Nov 2024 18:07:51 GMT Expired Expired
76cff1f Wed, 06 Nov 2024 08:45:45 GMT Expired Expired
1e244d4 Wed, 06 Nov 2024 08:52:34 GMT Expired Expired
3e4c483 Wed, 06 Nov 2024 09:08:37 GMT Expired Expired
1fe356f Thu, 07 Nov 2024 00:08:53 GMT Expired Expired
1fe356f Thu, 07 Nov 2024 00:13:15 GMT Expired Expired
4c5c4ac Thu, 07 Nov 2024 22:32:23 GMT Expired Expired
4c5c4ac Thu, 07 Nov 2024 22:36:44 GMT Cloud Enterprise


const { result } = renderHook(
() => useGenerateUserToken({ provider }),
{ wrapper }
)

result.current.mutate({ sessionid: 1 })
result.current.mutate({ name: '1' })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test was wrong before

@suejung-sentry suejung-sentry marked this pull request as ready for review November 5, 2024 18:01
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

@@ -2,7 +2,7 @@ import omitBy from 'lodash/omitBy'
import qs from 'qs'
import { useHistory, useLocation } from 'react-router-dom'

export function useLocationParams(defaultParams = {}) {
export function useLocationParams(defaultParams: Record<string, unknown> = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can use some TS generics here so that the default params that we pass in are typed to the return value of params

Copy link
Contributor

Choose a reason for hiding this comment

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

And i wonder if we can utilize these same generics to the update functions etc. so that when we call them we know the keys, and their value types.

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 think I had it most of the way there in this file but the changes it touched started to explode to 10+ other files and fixes needed. Spun it into this ticket and I can take another stab later - codecov/engineering-team#2843

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay sounds good

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's gonna be a significant investment, we may want to skip it, and wait until we move routers to save time ... and potentially lots of hair pulling.

Comment on lines 42 to 46
return Promise.reject({
status: 404,
data: {},
dev: 'useSelfHostedSeatsConfig - 404 schema parsing failed',
} 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 here 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

} satisfies NetworkErrorObject)
}

return parsedRes ?? null
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to use the parsedRes.data field here so we only get the data sent from the API over the that plus the zod info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

select below it was pulling out data. I adjusted these 2 to fit the pattern in the rest of our app

Comment on lines 47 to 54
return Promise.reject({
status: 404,
data: {},
dev: 'useSelfHostedHasAdmins - 404 schema parsing failed',
} satisfies NetworkErrorObject)
}

return parsedRes
Copy link
Contributor

Choose a reason for hiding this comment

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

👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another instance of select manipulating the data. I changed it to look like other places in our app.

updated to use the rejectNetworkErrorHelper too

Comment on lines 33 to 37
return Promise.reject({
status: 404,
data: {},
dev: 'useSelfHostedCurrentUser - 404 schema parsing failed',
} 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 throw in the new rejectNetworkError helper function here 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -2,7 +2,7 @@ import omitBy from 'lodash/omitBy'
import qs from 'qs'
import { useHistory, useLocation } from 'react-router-dom'

export function useLocationParams(defaultParams = {}) {
export function useLocationParams(defaultParams: Record<string, unknown> = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay sounds good

@@ -2,7 +2,7 @@ import omitBy from 'lodash/omitBy'
import qs from 'qs'
import { useHistory, useLocation } from 'react-router-dom'

export function useLocationParams(defaultParams = {}) {
export function useLocationParams(defaultParams: Record<string, unknown> = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's gonna be a significant investment, we may want to skip it, and wait until we move routers to save time ... and potentially lots of hair pulling.

createUserToken: z
.object({
error: z
.union([
Copy link
Contributor

Choose a reason for hiding this comment

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

One small nit, can we move this to a .discriminatedUnion(), you can read a bit more about them here, but they're a super awesome way to union on a single field and makes checking for said field super easy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gah totally missed that here - sorry you had to point it out both in the other PR and here - will make sure not to miss that next time!

@suejung-sentry suejung-sentry added this pull request to the merge queue Nov 7, 2024
Merged via the queue into main with commit 525e497 Nov 7, 2024
50 of 62 checks passed
@suejung-sentry suejung-sentry deleted the sshin/fix/2720 branch November 7, 2024 22:46
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 1)
3 participants