Skip to content

Conversation

@jjolton-contentful
Copy link
Contributor

Summary

  • Adds multi-entry support to existing deriveLinkedEntries, enabling 0..N child entries per source/locale and populating an Array<Link> field.
  • New options:
    • deriveEntriesForLocale (multi-mode)
    • derivedEntryId (deterministic IDs)
    • publishDerived (child publishing)

Description

  • Deterministic, idempotent upserts with a sensible default ID format.
  • Validates destination field type and linkContentType where applicable.
  • 100% backwards compatible with existing single-entry deriveEntryForLocale.
  • Updated README with examples; added unit tests to cover new paths.

Motivation and Context

A user asked for an easy way to convert a JSON field into many linked entries (e.g., fanning out arrays/objects into normalized child entries). This change adds multi-entry derivation so migrations can deterministically create 0..N child entries per locale and link them back, making that workflow simple and repeatable without breaking existing scripts.

@jjolton-contentful jjolton-contentful requested a review from a team as a code owner August 13, 2025 23:22
Copy link

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 the existing deriveLinkedEntries functionality to support creating multiple derived entries per source entry and locale, while maintaining full backwards compatibility. The enhancement enables migrations to convert JSON fields into normalized child entries with deterministic IDs and flexible publishing controls.

Key changes:

  • Added multi-entry mode via new deriveEntriesForLocale function that returns an array of child entries
  • Introduced deterministic ID generation with customizable derivedEntryId function
  • Added granular publishing control for derived children through publishDerived option

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/lib/interfaces/entry-derive.ts Added new optional properties for multi-entry mode with detailed JSDoc documentation
src/lib/action/entry-derive.ts Implemented multi-entry derivation logic with validation, upsert semantics, and deterministic ID generation
src/lib/intent-validator/entry-derive.ts Updated validation schema to accept new optional properties while maintaining backwards compatibility
test/unit/lib/actions/entry-derive.spec.js Added comprehensive tests for multi-entry mode including empty array handling
test/unit/lib/intent-validator/entry-derive.spec.ts Added validation test for multi-entry mode configuration
README.md Updated documentation with detailed examples and usage patterns for both single and multi-entry modes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

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.

2 participants