Skip to content

feat: accept resource links to native external references in v10 type generator #407

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

Merged

Conversation

alecpm
Copy link
Contributor

@alecpm alecpm commented Apr 19, 2025

Trying to use cf-content-types-generator with a Contentful schema that includes fields with native external references currently results in an exception and failure to generate types. This PR updates renderPropResourceLinkV10 to recognize the ExternalResourceLink type and allow it. When encountering an unknown allowedResources value it logs the value and treats it as EntryFieldTypes.ExternalResourceLink. Includes updated tests.

@alecpm alecpm force-pushed the external-reference-support branch from 61edf3d to b2748c5 Compare April 19, 2025 23:24
@marcolink marcolink requested a review from Copilot April 22, 2025 06:55
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends type generation support in v10 to correctly handle fields with native external references by recognizing the ExternalResourceLink type. Key changes include updated test cases to cover external references and modifications in the resource link renderer to add external resource types without failing.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
test/renderer/field/render-prop-resource-link.test.ts Updated and added tests to verify behavior for resource links with both external and cross-space references.
src/renderer/field/render-prop-resource-link.ts Modified rendering logic in v10 to distinguish between Contentful entries and native external references, and to dynamically build a union of types.
Files not reviewed (1)
  • package.json: Language not supported
Comments suppressed due to low confidence (2)

test/renderer/field/render-prop-resource-link.test.ts:36

  • [nitpick] The test description now mentions 'with a space', which may be ambiguous; consider clarifying the description to explicitly state how whitespace impacts the rejection behavior.
it('rejects a "ResourceLink" with a space and unknown resource type', () => {

src/renderer/field/render-prop-resource-link.ts:28

  • [nitpick] Consider simplifying the set initialization to 'new Set()' for improved readability and type safety.
const resourceTypes = new Set([]) as Set<string>;

Copy link
Collaborator

@marcolink marcolink left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution 👏

…low mixed cross-space and native external references.
@alecpm alecpm force-pushed the external-reference-support branch from 4caec9b to d79bf16 Compare April 22, 2025 08:13
@alecpm alecpm requested a review from marcolink April 22, 2025 08:14
@marcolink marcolink merged commit 7304cdb into contentful-userland:master Apr 22, 2025
Copy link

🎉 This issue has been resolved in version 2.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants