Skip to content

💡 refactor(contentful.js): Cleaning up/improving types related to contentful.js#342

Open
Charles Hudson (phobetron) wants to merge 2 commits into
mainfrom
NT-3558_contentfuljs-cleanup
Open

💡 refactor(contentful.js): Cleaning up/improving types related to contentful.js#342
Charles Hudson (phobetron) wants to merge 2 commits into
mainfrom
NT-3558_contentfuljs-cleanup

Conversation

@phobetron

@phobetron Charles Hudson (phobetron) commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Refactors the Optimization SDK’s Contentful entry typing to rely on the official contentful SDK types instead of locally modeling full Contentful entries with Zod. Runtime validation now focuses on Optimization-owned fields, with shared structural guards for resolved entries, unresolved links, Rich Text values, merge tags, audiences, optimizations, and optimized entries.

Changes

  • Replaced local Contentful entry/link/schema approximations with contentful SDK entry, skeleton, collection, and link types.
  • Added shared structural guards such as isResolvedContentfulEntry, isUnresolvedEntryLink, isRichTextDocument, isResolvedOptimizationEntry, and isResolvedOptimizedEntry.
  • Updated optimized-entry resolution to reject unresolved variant links and ensure selected variants match the baseline entry content type.
  • Changed preview-support fetch and mapper APIs to preserve full Contentful entry collections, including collection-level includes.Entry, so preview variant names can resolve from included entries.
  • Added the Next.js /api-schemas subpath and updated Next.js documentation to point schema/type imports there.
  • Updated Web, React Web, React Native, Next.js, Node, Angular, iOS, and Android consumers to use the shared schema helpers instead of duplicated local guards.
  • Consolidated small shared test/build-script type guard helpers and related cleanup.

Test coverage

  • Added coverage for paginated Contentful collection fetching with included entries.
  • Updated preview entry mapper tests for collection-based inputs.
  • Updated optimized-entry resolver tests for resolved entries, unresolved links, and variant resolution behavior.
  • Updated schema tests for the new Contentful entry and Rich Text guard behavior.
  • Refactored related React Native and Web tests to use shared helper guards.

[NT-3558]

…ntentful.js`

## Summary

Refactors the Optimization SDK’s Contentful entry typing to rely on the official `contentful` SDK types instead of locally modeling full Contentful entries with Zod. Runtime validation now focuses on Optimization-owned fields, with shared structural guards for resolved entries, unresolved links, Rich Text values, merge tags, audiences, optimizations, and optimized entries.

## Changes

- Replaced local Contentful entry/link/schema approximations with `contentful` SDK entry, skeleton, collection, and link types.
- Added shared structural guards such as `isResolvedContentfulEntry`, `isUnresolvedEntryLink`, `isRichTextDocument`, `isResolvedOptimizationEntry`, and `isResolvedOptimizedEntry`.
- Updated optimized-entry resolution to reject unresolved variant links and ensure selected variants match the baseline entry content type.
- Changed preview-support fetch and mapper APIs to preserve full Contentful entry collections, including collection-level `includes.Entry`, so preview variant names can resolve from included entries.
- Added the Next.js `/api-schemas` subpath and updated Next.js documentation to point schema/type imports there.
- Updated Web, React Web, React Native, Next.js, Node, Angular, iOS, and Android consumers to use the shared schema helpers instead of duplicated local guards.
- Consolidated small shared test/build-script type guard helpers and related cleanup.

## Test coverage

- Added coverage for paginated Contentful collection fetching with included entries.
- Updated preview entry mapper tests for collection-based inputs.
- Updated optimized-entry resolver tests for resolved entries, unresolved links, and variant resolution behavior.
- Updated schema tests for the new Contentful entry and Rich Text guard behavior.
- Refactored related React Native and Web tests to use shared helper guards.

[[NT-3558](https://contentful.atlassian.net/browse/NT-3558)]
@wiz-inc-38d59fb8d7

wiz-inc-38d59fb8d7 Bot commented Jun 29, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 2 Low
Software Management Finding Software Management Findings -
Total 2 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

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.

1 participant