Skip to content

[DEV-3839] Refactor guides API layer#2182

Open
Sebastiano-Bertolin wants to merge 4 commits intoDEV-3834-refactor-api-layer-for-case-historiesfrom
DEV-3839-refactor-guides-api-layer
Open

[DEV-3839] Refactor guides API layer#2182
Sebastiano-Bertolin wants to merge 4 commits intoDEV-3834-refactor-api-layer-for-case-historiesfrom
DEV-3839-refactor-guides-api-layer

Conversation

@Sebastiano-Bertolin
Copy link
Copy Markdown
Collaborator

This pull request refactors the guide and guide list page data fetching logic across the codebase, replacing legacy helper functions with new repository patterns. It introduces two repositories, GuidesRepository and GuideListPagesRepository, to centralise and simplify access to guide-related data. The changes also update tests and imports to use these new abstractions, and remove obsolete code.

List of Changes

Repository pattern migration:

  • Introduced GuidesRepository and GuideListPagesRepository to encapsulate all guide and guide list page fetching and mapping logic, replacing previous scattered helper functions. This centralizes guide data access and improves maintainability. (apps/nextjs-website/src/lib/guides/index.ts, apps/nextjs-website/src/lib/guideListPages/index.ts, [1] [2]
  • Refactored all guide and guide list page data fetching in apps/nextjs-website/src/lib/api.ts, apps/nextjs-website/src/app/sitemap.ts, and apps/nextjs-website/src/lib/cmsApi.ts to use the new repository methods instead of legacy helpers. (apps/nextjs-website/src/lib/api.ts, apps/nextjs-website/src/app/sitemap.ts, apps/nextjs-website/src/lib/cmsApi.ts, [1] [2] [3] [4] [5] [6] [7] [8] [9]

Code cleanup and removal:

  • Removed legacy guide and guide list page helper functions (getGuideListPagesProps, getGuidePageProps, getGuidesProps, makeGuideListPagesProps, makeGuidesProps, and related imports), and replaced them with repository calls. (apps/nextjs-website/src/lib/cmsApi.ts, apps/nextjs-website/src/lib/cmsApi.tsL140-R150)
  • Updated fetchers to use the new repository pattern and simplified their signatures. (apps/nextjs-website/src/lib/guideListPages/fetcher.ts, [1] [2]; apps/nextjs-website/src/lib/guides/fetcher.ts, [3]

Test and fixture updates:

  • Renamed and refactored tests for guide and guide list page mapping to use new mapGuides and mapGuideListPages functions, updating fixtures and test descriptions accordingly. (apps/nextjs-website/src/lib/guides/__tests__/mapper.test.ts, apps/nextjs-website/src/lib/guideListPages/__tests__/mapper.test.ts, [1] [2] [3] [4] [5] [6] [7] [8] [9]

Type and mapping improvements:

  • Added and updated types for guides and guide list pages to support the new repository pattern, and migrated mapping functions (mapGuides, mapGuideListPages) to new locations. (apps/nextjs-website/src/lib/guideListPages/types.ts, [1]; apps/nextjs-website/src/lib/guideListPages/mapper.ts, [2]

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Chore (nothing changes by a user perspective)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

- Add fetcher to retrieve guide list pages from Strapi.
- Create mapper to transform Strapi data into application-specific format.
- Implement repository pattern for accessing guide list pages.
- Add tests for mapping guide list pages with various scenarios.
- Introduce factories for generating test data for guide list pages.
- Create shared fixtures for guide list pages and guides.
- Remove obsolete Strapi types related to guide lists.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 4afc926

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nextjs-website Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

Jira Pull Request Link

This Pull Request refers to the following Jira issue DEV-3839

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant