sofie-core icon indicating copy to clipboard operation
sofie-core copied to clipboard

feat: add getUpcomingParts method to OnSetAsNextContext

Open rjmunro opened this issue 1 month ago • 1 comments

About the Contributor

This pull request is posted on behalf of the BBC.

Type of Contribution

This is a Feature

Current Behavior

This pull request extends the work done in https://github.com/Sofie-Automation/sofie-core/pull/1524

The getUpcomingParts method was available in onTake and action execution contexts, but was missing from the onSetAsNext context. This limited blueprints' ability to access information about upcoming parts when a part is being set as next.

New Behavior

The getUpcomingParts method is now available in the onSetAsNext context, providing blueprints with the ability to query upcoming parts in the rundown during the onSetAsNext callback. This matches the functionality already available in onTake and action contexts.

API Addition:

async getUpcomingParts(limit?: number): Promise<ReadonlyDeep<IBlueprintPart[]>>

This method returns a list of the upcoming Parts in the Rundown, in the order they will be Taken, with a default limit of 5 parts.

Testing

  • [x] I have added one or more unit tests for this PR
  • [ ] I have updated the relevant unit tests
  • [ ] No unit test changes are needed for this PR

Affected areas

This PR affects:

  • The IOnSetAsNextContext interface in the blueprints-integration package
  • The OnSetAsNextContext implementation in the job-worker package
  • Blueprint API surface - blueprints can now use context.getUpcomingParts() inside onSetAsNext callbacks

Time Frame

  • Not urgent, but we would like to get this merged into the in-development release.

Other Information

Implementation details:

  • Uses the existing getOrderedPartsAfterPlayhead utility function (same as OnTakeContext)
  • Returns up to 5 parts by default (configurable via optional limit parameter)
  • Properly typed with ReadonlyDeep to prevent accidental mutations
  • Follows the same pattern as the existing implementation in OnTakeContext

Status

  • [x] PR is ready to be reviewed.
  • [x] The functionality has been tested by the author.
  • [x] Relevant unit tests has been added / updated.
  • [ ] Relevant documentation (code comments, system documentation) has been added / updated.

rjmunro avatar Dec 12 '25 13:12 rjmunro

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests.

:loudspeaker: Thoughts on this report? Let us know!

codecov-commenter avatar Dec 12 '25 13:12 codecov-commenter