Skip to content

[DEV-3677] Refactor API data model and standardise property names#2170

Open
Sebastiano-Bertolin wants to merge 9 commits intoDEV-3238-strapi-5-feature-branchfrom
DEV-3677-refactor-api-layer-for-api-data
Open

[DEV-3677] Refactor API data model and standardise property names#2170
Sebastiano-Bertolin wants to merge 9 commits intoDEV-3238-strapi-5-feature-branchfrom
DEV-3677-refactor-api-layer-for-api-data

Conversation

@Sebastiano-Bertolin
Copy link
Copy Markdown
Collaborator

@Sebastiano-Bertolin Sebastiano-Bertolin commented Mar 17, 2026

This pull request refactors how API Data and API Data List pages fetch and handle their data in the Next.js website. The main change is switching from legacy functions to new repository-based abstractions (ApiDataListRepository and ApiDataListPagesRepository), which centralize data fetching and transformation logic. This improves code maintainability, testability, and clarity. Additionally, related types and tests have been updated to match the new data flow.

List of Changes

Repository abstraction and data fetching:

  • Introduced ApiDataListRepository and ApiDataListPagesRepository to encapsulate fetching and transforming API Data and API Data List pages, replacing direct calls to legacy functions. (apps/nextjs-website/src/lib/apiDataList/index.ts, apps/nextjs-website/src/lib/apiDataListPages/index.ts)
  • Added a new fetcher (fetchApiDataList) to handle Strapi API requests for API Data, with improved population of related entities. (apps/nextjs-website/src/lib/apiDataList/fetcher.ts)

Migration to new repository usage:

  • Refactored page components and metadata functions to use repository methods instead of legacy functions for fetching API Data and API Data List pages. (apps/nextjs-website/src/app/[locale]/[productSlug]/api/[apiDataSlug]/page.tsx, apps/nextjs-website/src/app/[locale]/[productSlug]/api/page.tsx) ([1], [2], [3], [4], [5], [6])

Cleanup and removal of legacy code:

  • Removed obsolete functions (getApiData, getApiDataListPages) and their usages from the api.ts file, consolidating all API Data fetching through repositories. (apps/nextjs-website/src/lib/api.ts) [1] [2] [3]

Type and prop updates:

  • Updated component and prop types to use new base types (BaseApiDataList, ApiDataList) instead of legacy Strapi types, ensuring consistency with the new repositories. (apps/nextjs-website/src/components/templates/ApiDataListTemplate/ApiDataListTemplate.tsx) [1] [2]

Test migration and improvements:

  • Renamed and refactored tests to validate the new mapping logic (mapApiDataList) for API Data List, replacing legacy test functions and updating test cases for edge scenarios. (apps/nextjs-website/src/lib/apiDataList/__tests__/mapper.test.ts) [1] [2] [3] [4] [5] [6] [7] [8] [9]

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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: b6f4fe3

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

…tentUrls for improved clarity and maintainability
@github-actions
Copy link
Copy Markdown
Contributor

This PR exceeds the recommended size of 800 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Copy link
Copy Markdown
Collaborator

@MarcoPonchia MarcoPonchia left a comment

Choose a reason for hiding this comment

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

I add some comment

Co-authored-by: Marco Ponchia <ponchia.marco1994@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

Branch is not up to date with base branch

@Sebastiano-Bertolin it seems this Pull Request is not updated with base branch.
Please proceed with a merge or rebase to solve this.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

Jira Pull Request Link

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

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.

3 participants