Skip to content

Commit 239bccb

Browse files
committed
wip
1 parent 8338eab commit 239bccb

File tree

13 files changed

+74
-23
lines changed

13 files changed

+74
-23
lines changed

packages/blueprints-integration/src/documents/pieceInstance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { IBlueprintPieceDB } from './piece'
44
export interface IBlueprintPieceInstance<TPrivateData = unknown, TPublicData = unknown> {
55
_id: string
66
/** The part instace this piece belongs to */
7-
partInstanceId: string
7+
partInstanceId: string | null
88

99
/** If this piece has been created play-time using an AdLibPiece, this should be set to it's source piece */
1010
adLibSourceId?: string
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { IBlueprintPieceGeneric } from './pieceGeneric'
2+
3+
/**
4+
* A variant of a Piece, that is owned by the Rundown.
5+
* This
6+
*/
7+
export interface IBlueprintRundownPiece<TPrivateData = unknown, TPublicData = unknown>
8+
extends IBlueprintPieceGeneric<TPrivateData, TPublicData> {
9+
/** When the piece should be active on the timeline. */
10+
enable: {
11+
start: number
12+
duration?: number
13+
14+
// For now, these pieces are always absolute (using wall time) rather than relative to the rundown
15+
isAbsolute: true
16+
}
17+
18+
/** Whether the piece is a real piece, or exists as a marker to stop an infinite piece. If virtual, it does not add any contents to the timeline */
19+
virtual?: boolean
20+
21+
/** Whether the piece affects the output of the Studio or is describing an invisible state within the Studio */
22+
notInVision?: boolean
23+
}
24+
25+
/** The Rundown piece sent from Core */
26+
export interface IBlueprintRundownPieceDB<TPrivateData = unknown, TPublicData = unknown>
27+
extends IBlueprintRundownPiece<TPrivateData, TPublicData> {
28+
_id: string
29+
}

packages/corelib/src/dataModel/PieceInstance.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ export interface PieceInstance {
3434
_id: PieceInstanceId
3535
/** The rundown this piece belongs to */
3636
rundownId: RundownId
37-
/** The part instace this piece belongs to */
38-
partInstanceId: PartInstanceId
37+
/**
38+
* The part instance this piece belongs to.
39+
* If null, the instance belongs to the rundown itself.
40+
*/
41+
partInstanceId: PartInstanceId | null
3942

4043
/** Whether this PieceInstance is a temprorary wrapping of a Piece */
4144
readonly isTemporary?: boolean

packages/corelib/src/dataModel/RundownPlaylist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface ABSessionInfo {
2626
/** Set if the session is being used by an infinite PieceInstance */
2727
infiniteInstanceId?: PieceInstanceInfiniteId
2828
/** Set to the PartInstances this session is used by, if not just used for lookahead */
29-
partInstanceIds?: Array<PartInstanceId>
29+
partInstanceIds?: Array<PartInstanceId | null>
3030
}
3131

3232
export interface ABSessionAssignment {

packages/job-worker/src/blueprints/__tests__/context-events.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,22 +273,19 @@ describe('Test blueprint api context', () => {
273273
rundownId,
274274
})) as PieceInstance
275275
expect(pieceInstance).toBeTruthy()
276+
expect(pieceInstance.partInstanceId).toBe(partInstance._id)
276277

277278
// Check what was generated
278279
const context = await getContext(rundown, undefined, partInstance, undefined)
279-
await expect(
280-
context.getPieceInstances(unprotectString(pieceInstance.partInstanceId))
281-
).resolves.toHaveLength(3)
280+
await expect(context.getPieceInstances(unprotectString(partInstance._id))).resolves.toHaveLength(3)
282281

283282
// mark one of the piece as different activation
284283
await jobContext.mockCollections.PieceInstances.update(pieceInstance._id, {
285284
$set: { playlistActivationId: protectString('another activation') },
286285
})
287286

288287
// should now be less
289-
await expect(
290-
context.getPieceInstances(unprotectString(pieceInstance.partInstanceId))
291-
).resolves.toHaveLength(2)
288+
await expect(context.getPieceInstances(unprotectString(partInstance._id))).resolves.toHaveLength(2)
292289
})
293290

294291
test('getSegment - no id', async () => {

packages/job-worker/src/blueprints/context/services/__tests__/PartAndPieceInstanceActionService.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { postProcessPieces, postProcessTimelineObjects } from '../../../postProc
5757
import { ActionPartChange, PartAndPieceInstanceActionService } from '../PartAndPieceInstanceActionService'
5858
import { mock } from 'jest-mock-extended'
5959
import { QuickLoopService } from '../../../../playout/model/services/QuickLoopService'
60+
import { SelectedPartInstance } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
6061
const { postProcessPieces: postProcessPiecesOrig, postProcessTimelineObjects: postProcessTimelineObjectsOrig } =
6162
jest.requireActual('../../../postProcess')
6263

@@ -233,10 +234,13 @@ describe('Test blueprint api context', () => {
233234
nextPartInstance: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | undefined | null,
234235
previousPartInstance?: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | null
235236
) {
236-
const convertInfo = (info: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | null) => {
237+
const convertInfo = (
238+
info: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | null
239+
): SelectedPartInstance | null => {
237240
if (!info) {
238241
return null
239242
} else if ('partInstanceId' in info) {
243+
if (!info.partInstanceId) return null
240244
return {
241245
partInstanceId: info.partInstanceId,
242246
rundownId: info.rundownId,

packages/job-worker/src/playout/__tests__/playout.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ import { DBPartInstance } from '@sofie-automation/corelib/dist/dataModel/PartIns
4343
import { ReadonlyDeep } from 'type-fest'
4444
import { adjustFakeTime, getCurrentTime, useFakeCurrentTime } from '../../__mocks__/time'
4545
import { PieceLifespan } from '@sofie-automation/blueprints-integration'
46-
import { PlayoutChangedType } from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
46+
import {
47+
PlayoutChangedResult,
48+
PlayoutChangedType,
49+
} from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
4750
import { ProcessedShowStyleCompound } from '../../jobs'
4851
import { handleOnPlayoutPlaybackChanged } from '../timings'
4952
import { sleep } from '@sofie-automation/shared-lib/dist/lib/lib'
@@ -605,7 +608,7 @@ describe('Playout API', () => {
605608
: now) +
606609
Math.random() * TIME_RANDOM,
607610
},
608-
}
611+
} satisfies PlayoutChangedResult
609612
}),
610613
],
611614
})
@@ -698,7 +701,7 @@ describe('Playout API', () => {
698701
: now) +
699702
Math.random() * TIME_RANDOM,
700703
},
701-
}
704+
} satisfies PlayoutChangedResult
702705
}),
703706
],
704707
})

packages/job-worker/src/playout/abPlayback/abSessionHelper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export class AbSessionHelper {
108108
}
109109

110110
// We only want to consider sessions already tagged to this partInstance
111+
// nocommit - is this sane for piece instances without a partInstanceId?
111112
const existingSession = sessionsToConsider.find((s) =>
112113
s.partInstanceIds?.includes(pieceInstance.partInstanceId)
113114
)

packages/job-worker/src/playout/model/implementation/LoadPlayoutModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async function loadPartInstances(
260260
context: JobContext,
261261
playlist: ReadonlyDeep<DBRundownPlaylist>,
262262
rundownIds: RundownId[]
263-
): Promise<{ partInstances: DBPartInstance[]; groupedPieceInstances: Map<PartInstanceId, PieceInstance[]> }> {
263+
): Promise<{ partInstances: DBPartInstance[]; groupedPieceInstances: Map<PartInstanceId | null, PieceInstance[]> }> {
264264
const selectedPartInstanceIds = _.compact([
265265
playlist.currentPartInfo?.partInstanceId,
266266
playlist.nextPartInfo?.partInstanceId,

packages/job-worker/src/playout/model/implementation/PlayoutModelImpl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class PlayoutModelReadonlyImpl implements PlayoutModelReadonly {
9696
peripheralDevices: ReadonlyDeep<PeripheralDevice[]>,
9797
playlist: DBRundownPlaylist,
9898
partInstances: DBPartInstance[],
99-
groupedPieceInstances: Map<PartInstanceId, PieceInstance[]>,
99+
groupedPieceInstances: Map<PartInstanceId | null, PieceInstance[]>,
100100
rundowns: PlayoutRundownModelImpl[],
101101
timeline: TimelineComplete | undefined
102102
) {
@@ -120,7 +120,7 @@ export class PlayoutModelReadonlyImpl implements PlayoutModelReadonly {
120120

121121
private createPartInstanceModelImpls(
122122
partInstances: DBPartInstance[],
123-
groupedPieceInstances: Map<PartInstanceId, PieceInstance[]>
123+
groupedPieceInstances: Map<PartInstanceId | null, PieceInstance[]>
124124
) {
125125
const allPartInstances: PlayoutPartInstanceModelImpl[] = []
126126
for (const partInstance of partInstances) {
@@ -300,7 +300,7 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
300300
peripheralDevices: ReadonlyDeep<PeripheralDevice[]>,
301301
playlist: DBRundownPlaylist,
302302
partInstances: DBPartInstance[],
303-
groupedPieceInstances: Map<PartInstanceId, PieceInstance[]>,
303+
groupedPieceInstances: Map<PartInstanceId | null, PieceInstance[]>,
304304
rundowns: PlayoutRundownModelImpl[],
305305
timeline: TimelineComplete | undefined
306306
) {

0 commit comments

Comments
 (0)