Run `ts-prune --project tsconfig.json | grep -v '(used in module)' > tsprune.txt` to save the changes to a file and analyze them.
# Unused Components:
### Just removed files:
```
src/common/images/index.ts - AlkemioLogo`
src/common/utils/challenges-mapper.ts:1 - challengesMapper
src/common/utils/shuffleCollection.ts:16 - default
src/common/utils/groups-mapper.ts:1 - groupsMapper
src/common/utils/toFirstCapitalLeter.ts:1 - toFirstCaptitalLetter
src/common/utils/urlStrip.ts:1 - urlStrip
src/core/routing/usePathUtils.ts:11 - useAppendPaths
src/core/routing/usePathUtils.ts:31 - useAppendBreadcrumb
src/core/routing/usePathUtils.ts:37 - useAppendCurrentPath
src/common/components/composite/index.ts:22 - SettingsButton
src/common/utils/remToPx/remToPx.ts:16 - default
src/core/ui/errors/ErrorBoundary.tsx:3 - ErrorBoundary
src/domain/platform/admin/ManagementPageTemplatePage.tsx:77 - default
src/domain/shared/components/DashboardSectionHeaderActions.tsx:19 - default
src/domain/shared/components/FullWidthLoader.tsx:6 - default
src/common/components/composite/sections/ContextSection.tsx:99 - default
src/common/components/composite/sections/ContextSectionIcon.tsx:10 - default
src/common/components/composite/dialogs/PopUpProps.ts:8 - default
src/core/auth/authentication/hooks/useAuthenticate.ts:8 - useAuthenticate
src/common/components/core/dialog/index.ts:4 - DialogTitleWithIcon
src/domain/platform/admin/components/Common/InputField.tsx:47 - default
src/domain/shared/utils/useSearchAcrossMultipleLists.ts:43 - default
src/domain/challenge/space/SpaceCommunityPage/SpaceAuthorizationView.tsx:84 - default
src/domain/challenge/space/views/SpaceAboutView.tsx:11 - SpaceAboutView
src/domain/collaboration/callout/utils/createPostTemplateFromTemplateSet.ts:4 - createPostTemplateFromTemplateSet
src/domain/collaboration/post/PostTemplatePreview/PostTemplatePreview.tsx:65 - default
src/domain/collaboration/whiteboard/entities/WhiteboardDetails.ts:1 - WhiteboardDetails
src/domain/collaboration/whiteboard/icon/WhiteboardAltIcon.tsx:3 - WhiteboardAltIcon
src/domain/collaboration/whiteboard/WhiteboardList/WhiteboardList.tsx:46 - default
src/domain/collaboration/whiteboard/WhiteboardsDashboardPreview/WhiteboardsDashboardPreview.tsx:64 - default
src/domain/community/community/CommunityContributors/CommunityContributorsSearch.tsx:30 - default
src/domain/community/community/CommunityContributors/ContributingUsers.tsx:74 - default
src/domain/community/community/CommunityUpdates/CommunityUpdates.tsx:24 - default
src/domain/community/community/EntityDashboardContributorsSection/DashboardLeads.tsx:34 - default
src/domain/community/community/UserAvatar/UserAvatar.tsx:20 - default
src/domain/platform/cookies/components/Button.tsx:25 - default
src/domain/platform/TopLevelPages/Home/BannerImage.tsx:32 - default
src/domain/platform/TopLevelPages/Home/LoginSection.tsx:16 - default
src/domain/platform/TopLevelPages/Home/OrganizationSection.tsx:20 - default
src/domain/shared/components/ActivityLog/index.ts:51 - ActivityLogResult
src/domain/shared/components/ActivityLog/index.ts:67 - ActivityLogComponentProps
src/domain/shared/components/Backdrops/AuthenticationBackdrop.tsx:30 - default
src/domain/shared/components/ClampedTypography/index.ts:4 - ClampedTypographyProps
src/domain/shared/components/ClampedTypography/ClampedTypography.tsx:23 - default
src/domain/shared/components/DashboardSections/DashboardActivitySection.tsx:25 - default
src/domain/shared/components/DashboardSections/DashboardOpportunityStatistics.tsx:42 - default
src/domain/shared/components/Steps/Steps.tsx:71 - default
src/domain/shared/components/Steps/Step.tsx:1 - default
src/domain/shared/components/Text/Constants.ts:5 - getLineHeight
src/common/components/composite/common/Accordion/Accordion.tsx:21 - Accordion
src/common/components/composite/common/Metrics/MetricsV2.tsx:25 - default
src/common/components/composite/common/MetricsPanel/MetricCard.tsx:41 - default
src/common/components/composite/entities/Project/Cards.tsx:5 - ContentCard
src/common/components/composite/entities/Whiteboard/WhiteboardToolbar.tsx:22 - default
src/common/components/composite/entities/Space/InterestModal.tsx:154 - default
src/common/components/composite/layout/Context/ContextLayout.tsx:22 - default
src/common/components/composite/sections/DashboardSection/DashboardSection.tsx:36 - default
src/common/components/core/card-filter/value-getters/userCardValueGetter.ts:11 - userCardValueGetter
src/common/components/core/card-filter/value-getters/userCardValueGetter.ts:23 - userCardTagsGetter
src/core/ui/themes/default/components/MuiTooltip.ts:11 - default
src/domain/collaboration/callout/creation-dialog/CalloutTemplate/CalloutWhiteboardTemplate.tsx:45 - default
src/domain/collaboration/callout/creation-dialog/CalloutTemplate/PostTemplatesList.tsx:32 - default
src/domain/collaboration/callout/creation-dialog/CalloutTemplate/PostTemplatesListItem.tsx:30 - PostTemplatesListItemSkeleton
src/domain/community/application/views/PendingApplications/PendingApplicationsView.tsx:79 - default
src/domain/community/application/views/PendingApplications/PendingApplicationView.tsx:1 - default
src/domain/community/contributor/organization/pages/CardProps.ts:1 - default
src/domain/community/contributor/organization/pages/InfoSection.tsx:65 - default
src/domain/platform/admin/components/Common/VisualSegment.ts:3 - visualSegmentSchema
src/domain/platform/admin/templates/InnovationTemplates/LifecycleSection.tsx:20 - default
src/domain/shared/components/search-cards/base/SearchBaseCard.tsx:68 - SearchBaseCardImplProps
src/domain/shared/components/search-cards/base/SearchBaseCard.tsx:127 - default
src/domain/shared/components/Steps/step/Step.tsx:27 - default
src/common/components/core/Spacer.tsx:17 - Spacer
src/domain/platform/metrics/SectionHeaderTextWithMetrics.tsx:22 - default
src/common/utils/application/getApplicationTypeTranslation.tsx:12 - default
src/domain/shared/components/LoadingUserCard.tsx:11 - default
src/domain/community/contributor/user/index.ts:5 - useUserMetadata
src/domain/community/contributor/user/index.ts:15 - PendingApplication
src/domain/community/contributor/user/index.ts:17 - UserMetadata
src/domain/community/contributor/user/index.ts:89 - toUserMetadata
src/common/components/composite/common/MetricsPanel/tempMockMetrics.ts:28 - default
src/domain/platform/admin/components/index.ts:14 - ListPage
src/common/components/composite/common/VerifiedStatus/VerifiedStatusChip.tsx:46 - default
src/domain/challenge/common/tabs/About/Types.ts:34 - JourneyAboutWithHost
src/domain/collaboration/callout/creation-dialog/CalloutTemplate/CalloutTemplateProps.ts:3 - CalloutTemplateProps
src/domain/community/contributor/organization/OrganizationVerifiedState/index.tsx:34 - OrganizationVerifiedState
```
### Removed, maybe they should stay:
```
src/core/help/hooks/useFetchMd.ts:3 - useFetchMd
```
### Refactored:
- Removed unused exported members:
```
src/domain/shared/components/SocialLinks/icons/GitHub.tsx:5 - GitHubProps
src/domain/platform/config/configuration.ts:41 - PostTemplate
src/domain/shared/components/SimpleSearchableList.tsx:27 - searchableListItemMapper
src/core/state/global/notifications/notificationMachine.ts:21 - LoginNavigationState
src/domain/collaboration/callout/links/LinkCollectionCallout.tsx:29 - LinkCollectionCalloutData
src/domain/collaboration/post/PostCreationDialog/PostCreationDialog.tsx:26 - CardCreationPostTemplateProfile
src/domain/collaboration/post/PostCreationDialog/PostCreationDialog.tsx:31 - CardCreationPostTemplate
src/domain/collaboration/whiteboard/containers/getWhiteboardCallout.ts:12 - getWhiteboardCalloutContainingWhiteboard
src/domain/collaboration/whiteboard/containers/getWhiteboardCallout.ts:25 - getAllWhiteboardsOnCallouts
src/domain/collaboration/whiteboard/containers/WhiteboardProvider.tsx:25 - TemplateQuery
src/domain/community/community/CommunityContributors/types.ts:5 - Contributors
src/domain/community/contributor/organization/OrganizationInput.ts:20 - CreateOrganizationInput
src/domain/shared/components/search-cards/index.ts:4 - SearchSpaceCardImplProps
src/domain/shared/components/search-cards/index.ts:5 - SearchSpaceCardProps
src/domain/shared/components/search-cards/index.ts:4 - SearchChallengeCardImplProps
src/domain/shared/components/search-cards/index.ts:5 - SearchChallengeCardProps
src/domain/shared/components/search-cards/index.ts:4 - SearchOpportunityCardImplProps
src/domain/shared/components/search-cards/index.ts:5 - SearchOpportunityCardProps
src/domain/shared/components/SearchTagsInput/SearchTagsInput.tsx:7 - ValueType
src/domain/communication/room/Comments/useMessagesTree.ts:21 - default
src/domain/shared/components/ContactDetails/ContactDetails.tsx:96 - default
src/domain/community/contributor/user/index.ts:5 - useUserMetadata
src/domain/community/contributor/user/index.ts:15 - PendingApplication
src/domain/community/contributor/user/index.ts:17 - UserMetadata
src/domain/community/contributor/user/index.ts:89 - toUserMetadata
src/domain/platform/admin/components/index.ts:14 - ListPage
src/common/components/composite/entities/Space/Cards.tsx:164 - SwitchCardComponent
src/common/components/composite/entities/UserProfile/MemberOf.tsx:62 - default
src/domain/community/contributor/user/constants/translation.constants.ts:7 - RoleNameKey
src/domain/community/contributor/user/constants/translation.constants.ts:8 - MessageAuthorRoleNameKey
src/domain/community/profile/views/ProfileView/index.tsx:13 - ContributionViewProps
src/domain/community/profile/views/ProfileView/index.tsx:22 - OrganizationProfileViewProps
src/domain/community/profile/views/ProfileView/index.tsx:11 - CredentialsViewProps
src/domain/shared/components/ActivityLog/views/index.ts:10 - ActivityCalloutPublishedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:10 - ActivityCalloutWhiteboardCreatedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:11 - ActivityCalloutPostCommentCreatedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:10 - ActivityCalloutPostCreatedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:10 - ActivityCalloutLinkCreatedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:16 - ActivityCalloutLinkCreatedView
src/domain/shared/components/ActivityLog/views/index.ts:11 - ActivityDiscussionCommentCreatedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:10 - ActivityMemberJoinedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:10 - ActivityChallengeCreatedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:10 - ActivityOpportunityCreatedViewProps
src/domain/shared/components/ActivityLog/views/index.ts:10 - ActivityOpportunityCreatedViewProps
src/common/components/composite/common/MetricsPanel/StateMetricCardItem.tsx:103 - default
src/common/components/composite/entities/Space/Cards.tsx:142 - MoreProjectsCard
src/common/components/composite/entities/Space/Cards.tsx:152 - AddProjectsCard
src/domain/platform/admin/user/pages/UserPage.tsx:174 - default
```
- Removed unused exported members, but there are more things that could be refactored
```
src/core/routing/useNavigation.ts:22 - useNavigation
src/common/components/core/Section.tsx:91 - SubHeader
src/common/components/core/Section.tsx:116 - Body
src/common/components/core/Spinner.tsx:20 - default
src/domain/collaboration/post/containers/getPostCallout.ts:8 - getCardCallouts
```
- Refactored the buildContext functions and removed this file:
`src/common/utils/buildContext.ts:16 - createContextInput`
### Weird things:
- I don't know what to do with this:
`src/common/utils/functor.ts:6 - functor`
- These two are used, and they appear as if they were not:
`src/common/constants/index.ts:4 - publicGraphQLEndpoint`
`src/common/constants/index.ts:5 - privateGraphQLEndpoint`
- Test utils
`src/common/utils/test/test-utils.tsx`
### Useful: left things eventhough they are not used:
```
src/common/utils/urlBuilders.ts:27 - buildAdminNewChallengeUrl
src/common/utils/urlBuilders.ts:33 - buildAdminNewOpportunityUrl
src/common/utils/urlBuilders.ts:56 - buildProjectUrl
src/common/utils/urlBuilders.ts:68 - buildDiscussionsUrl
src/common/utils/urlBuilders.ts:73 - buildNewDiscussionUrl
src/services/logging/sentry/log.ts:24 - warn
src/core/ui/forms/field-length.constants.ts:2 - TINY_TEXT_LENGTH
src/core/ui/forms/field-length.constants.ts:8 - UUID_LENGTH
src/core/ui/forms/field-length.constants.ts:9 - NAMEID_LENGTH
src/core/ui/forms/field-length.constants.ts:10 - MESSAGEID_LENGTH
src/core/ui/forms/field-length.constants.ts:11 - WHITEBOARD_VALUE_LENGTH
src/core/ui/forms/field-length.constants.ts:12 - LIFECYCLE_DEFINITION_LENGTH
src/domain/platform/config/features.constants.ts:3 - FEATURE_COMMUNICATIONS_DISCUSSIONS
src/domain/shared/types/CoreEntityIds.ts:27 - isOpportunityId
src/domain/shared/utils/findById.ts:6 - default
src/domain/community/application/constants/ApplicationState.ts:3 - APPLICATION_STATE_APPROVED
src/common/components/composite/common/VerifiedStatus/VerifiedStatusChip.tsx:46 - default
src/core/auth/authentication/components/Kratos/helpers.ts:15 - isUiNodeAnchorAttributes
src/core/auth/authentication/components/Kratos/helpers.ts:19 - isUiNodeImageAttributes
src/core/auth/authentication/components/Kratos/helpers.ts:27 - isUiNodeTextAttributes
src/domain/platform/admin/user/pages/UserPage.tsx:174 - default
```
# GraphQL Queries
ts-prune does a great job, but Apollo `codegen` tool doesn't leave it easy to find unused queries.
`codegen` generates `apollo-hooks.ts` and all the Queries and Mutations are inside it.
There are three exported functions to call every query:
- `use......Query`
- `use......LazyQuery`
- `refetch......Query`
Unused refetches are shown but those don't really matter. The problem is ts-prune's results don't show clearly unused queries because `codegen` generates these two lines for each `use...Query` hook:
```
// For example
export type SpaceGroupsListQueryHookResult = ReturnType<typeof useSpaceGroupsListQuery>;
export type SpaceGroupsListLazyQueryHookResult = ReturnType<typeof useSpaceGroupsListLazyQuery>;
```
With these two lines per query, on ts-prune's eyes, all queries are used. The easiest way I've found to find unused queries is:
1) Remove manually all these `export type` lines:
- You can use Find and Replace in VSCode with this regular expression:
`^export type .*? = ReturnType<typeof use.*?Query>;$`

Click on Replace All to turn them into empty lines.
- Don't worry, you don't need to build the client, but it will still build fine because we are not using any of those exported types. Anyway, don't commit this change and run `codegen` after to recover those lines.
2) Now if we run the ts-prune command again, we'll see all the `use...Query` lines. Most of them will be the `Lazy` queries not used. Some of them will be the normal queries not used because we are using only the `Lazy` one. But SOME of them will have 3 lines, the normal query, the `Lazy` query and the `refetch`.
3) Use Search and Replace to remove all the `^use`, the `^refetch` and the `Lazy` words, and you'll have a list like this:

4) In the column `C` you can count how many times every row is repeated, with a formula like `=COUNTIF(A:A,A1)`, then apply auto filter and get the list of the queries that are repeated 3 times:

5) With this, we have a list of the queries that are not used in any of the three ways (normal, `Lazy` or `refetch`).
This time I have found this list:
```
ChallengeActivity
ChallengeCard
AllOpportunities
OpportunityActivity
OpportunityActorGroups
OpportunityEcosystemDetails
OpportunityGroups
OpportunityUserIds
OpportunityWithActivity
SpaceTemplates
PostTemplatesFromSpace
SpaceActivity
SpaceCard ** It is used in common/components/core/card-filter/value-getters/journeyCardValueGetter.ts
SpaceGroupsList
SpaceHostReferences
SpaceMembers
SpaceUserIds
SpaceVisual
TemplatesForCalloutCreation
PostTemplateValue
SpaceWhiteboards
AllCommunities
CommunityMessages
OrganizationDetails
OrganizationName
UserCard
SpaceAvailableLeadUsers
Configuration ** It's used in domain/platform/config/ConfigProvider.tsx
ServerMetadata ** It's used in domain/platform/config/ServerMetadatarovider.tsx
```
6) There is a 4th way to use a query but it's not detectable with this procedure. It is wrapping it in a Provider. For example `await queryRequest<ServerMetadataQuery>`
7) Find in files in `*.graphql` files and you'll be able to remove those queries:

8) Remove all the unused queries
9) When you finish, run codegen again and confirm that the client is still building.
# GraphQL Mutations
Same as before, but removing the exported type `...MutationHookResult`
Regex: `^export type .*?MutationHookResult = ReturnType<typeof use.*?Mutation>;$`
# GraphQL Pending
Maybe refactor Configuration and ServerMetadata to not use Context providers. SpaceQuery can maybe be refactored too
# Other GraphQL notes
Items reported in `src/core/apollo/generated/graphql-schema.ts` are useless