Skip to content

Commit 08494df

Browse files
committed
feat: Add getUpcomingParts to action context
So that an action can be taken based on what items may be coming up (further ahead than the next part instance)
1 parent 76dfbd2 commit 08494df

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

packages/blueprints-integration/src/context/partsAndPieceActionContext.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ReadonlyDeep } from 'type-fest'
12
import {
23
IBlueprintMutatablePart,
34
IBlueprintPart,
@@ -48,6 +49,12 @@ export interface IPartAndPieceActionContext {
4849
/** Gets the Segment. This primarily allows for accessing metadata */
4950
getSegment(segment: 'current' | 'next'): Promise<IBlueprintSegment | undefined>
5051

52+
/** Get a list of the upcoming Parts in the Rundown, in the order that they will be Taken */
53+
getUpcomingParts(
54+
/** The max number of parts returned. */
55+
limit?: number
56+
): Promise<ReadonlyDeep<IBlueprintPart[]>>
57+
5158
/**
5259
* Creative actions
5360
*/

packages/job-worker/src/blueprints/context/OnTakeContext.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { JobContext, ProcessedShowStyleCompound } from '../../jobs/index.js'
2525
import { executePeripheralDeviceAction, listPlayoutDevices } from '../../peripheralDevice.js'
2626
import { ActionPartChange, PartAndPieceInstanceActionService } from './services/PartAndPieceInstanceActionService.js'
2727
import { BlueprintQuickLookInfo } from '@sofie-automation/blueprints-integration/dist/context/quickLoopInfo'
28+
import { getOrderedPartsAfterPlayhead } from '../../playout/lookahead/util.js'
2829

2930
export class OnTakeContext extends ShowStyleUserContext implements IOnTakeContext, IEventContext {
3031
public isTakeAborted: boolean
@@ -52,6 +53,10 @@ export class OnTakeContext extends ShowStyleUserContext implements IOnTakeContex
5253
this.isTakeAborted = false
5354
}
5455

56+
async getUpcomingParts(limit: number = 5): Promise<ReadonlyDeep<IBlueprintPart[]>> {
57+
return getOrderedPartsAfterPlayhead(this._context, this._playoutModel, limit)
58+
}
59+
5560
abortTake(): void {
5661
this.isTakeAborted = true
5762
}

packages/job-worker/src/blueprints/context/adlibActions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { executePeripheralDeviceAction, listPlayoutDevices } from '../../periphe
3232
import { ActionPartChange, PartAndPieceInstanceActionService } from './services/PartAndPieceInstanceActionService.js'
3333
import { BlueprintQuickLookInfo } from '@sofie-automation/blueprints-integration/dist/context/quickLoopInfo'
3434
import { setNextPartFromPart } from '../../playout/setNext.js'
35+
import { getOrderedPartsAfterPlayhead } from '../../playout/lookahead/util.js'
3536

3637
export class DatastoreActionExecutionContext
3738
extends ShowStyleUserContext
@@ -102,6 +103,10 @@ export class ActionExecutionContext extends ShowStyleUserContext implements IAct
102103
super(contextInfo, _context, showStyle, watchedPackages)
103104
}
104105

106+
async getUpcomingParts(limit: number = 5): Promise<ReadonlyDeep<IBlueprintPart[]>> {
107+
return getOrderedPartsAfterPlayhead(this._context, this._playoutModel, limit)
108+
}
109+
105110
async getPartInstance(part: 'current' | 'next'): Promise<IBlueprintPartInstance | undefined> {
106111
return this.partAndPieceInstanceService.getPartInstance(part)
107112
}

0 commit comments

Comments
 (0)