diff --git a/packages/job-worker/src/blueprints/__tests__/context-adlibActions.test.ts b/packages/job-worker/src/blueprints/__tests__/context-adlibActions.test.ts index 55f9bc41d8d..e72b1324ff7 100644 --- a/packages/job-worker/src/blueprints/__tests__/context-adlibActions.test.ts +++ b/packages/job-worker/src/blueprints/__tests__/context-adlibActions.test.ts @@ -31,10 +31,10 @@ import { EmptyPieceTimelineObjectsBlob, serializePieceTimelineObjectsBlob, } from '@sofie-automation/corelib/dist/dataModel/Piece' -import { PartInstanceWithPieces } from '../../playout/cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../../playout/cacheModel/PlayoutPartInstanceModel' import { convertPartInstanceToBlueprints, convertPieceInstanceToBlueprints } from '../context/lib' import { TimelineObjRundown, TimelineObjType } from '@sofie-automation/corelib/dist/dataModel/Timeline' -import { PartInstanceWithPiecesImpl } from '../../playout/cacheModel/implementation/PartInstanceWithPiecesImpl' +import { PlayoutPartInstanceModelImpl } from '../../playout/cacheModel/implementation/PlayoutPartInstanceModelImpl' import { writePartInstancesAndPieceInstances } from '../../playout/cacheModel/implementation/SavePlayoutModel' import * as PlayoutAdlib from '../../playout/adlibUtils' @@ -70,7 +70,7 @@ describe('Test blueprint api context', () => { context: MockJobContext, activationId: RundownPlaylistActivationId, rundownId: RundownId - ): Promise { + ): Promise { const parts = await context.mockCollections.Parts.findFetch({ rundownId }) for (let i = 0; i < parts.length; i++) { const part = parts[i] @@ -135,7 +135,7 @@ describe('Test blueprint api context', () => { const pieceInstances = await context.mockCollections.PieceInstances.findFetch({ partInstanceId: partInstance._id, }) - return new PartInstanceWithPiecesImpl(partInstance, pieceInstances, false) + return new PlayoutPartInstanceModelImpl(partInstance, pieceInstances, false) }) ) } @@ -196,7 +196,7 @@ describe('Test blueprint api context', () => { jobContext: MockJobContext playlistId: RundownPlaylistId rundownId: RundownId - allPartInstances: PartInstanceWithPieces[] + allPartInstances: PlayoutPartInstanceModel[] }> { const context = setupDefaultJobEnvironment() @@ -230,13 +230,13 @@ describe('Test blueprint api context', () => { async function saveAllToDatabase( context: JobContext, cache: PlayoutModel, - allPartInstances: PartInstanceWithPieces[] + allPartInstances: PlayoutPartInstanceModel[] ) { // We need to push changes back to 'mongo' for these tests await Promise.all( writePartInstancesAndPieceInstances( context, - normalizeArrayToMapFunc(allPartInstances as PartInstanceWithPiecesImpl[], (p) => p.PartInstance._id) + normalizeArrayToMapFunc(allPartInstances as PlayoutPartInstanceModelImpl[], (p) => p.PartInstance._id) ) ) await cache.saveAllToDatabase() @@ -245,11 +245,11 @@ describe('Test blueprint api context', () => { async function setPartInstances( jobContext: MockJobContext, playlistId: RundownPlaylistId, - currentPartInstance: PartInstanceWithPieces | DBPartInstance | PieceInstance | undefined | null, - nextPartInstance: PartInstanceWithPieces | DBPartInstance | PieceInstance | undefined | null, - previousPartInstance?: PartInstanceWithPieces | DBPartInstance | PieceInstance | null + currentPartInstance: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | undefined | null, + nextPartInstance: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | undefined | null, + previousPartInstance?: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | null ) { - const convertInfo = (info: PartInstanceWithPieces | DBPartInstance | PieceInstance | null) => { + const convertInfo = (info: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | null) => { if (!info) { return null } else if ('partInstanceId' in info) { @@ -452,7 +452,7 @@ describe('Test blueprint api context', () => { ( context2: JobContext, sourceLayers: SourceLayers, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, now?: number ) => { expect(context2).toBe(jobContext) @@ -1242,7 +1242,7 @@ describe('Test blueprint api context', () => { // Ensure there are no pending updates already for (const partInstance of cache.LoadedPartInstances) { - expect((partInstance as PartInstanceWithPiecesImpl).HasChanges).toBeFalsy() + expect((partInstance as PlayoutPartInstanceModelImpl).HasChanges).toBeFalsy() } // Update it and expect it to match @@ -1289,7 +1289,7 @@ describe('Test blueprint api context', () => { }, } expect(pieceInstance1).toEqual(pieceInstance0After) - expect((partInstance1 as PartInstanceWithPiecesImpl).HasChanges).toBeTruthy() + expect((partInstance1 as PlayoutPartInstanceModelImpl).HasChanges).toBeTruthy() // expect( // Array.from(cache.PieceInstances.documents.values()).filter((doc) => !doc || !!doc.updated) // ).toMatchObject([ @@ -1380,7 +1380,7 @@ describe('Test blueprint api context', () => { playOffset: 0, take: undefined, } - cache.replacePartInstance(new PartInstanceWithPiecesImpl(partInstance, [], true)) + cache.replacePartInstance(new PlayoutPartInstanceModelImpl(partInstance, [], true)) expect(isTooCloseToAutonext(partInstance, true)).toBeTruthy() await expect(context.queuePart({} as any, [{}] as any)).rejects.toThrow( @@ -1720,7 +1720,7 @@ describe('Test blueprint api context', () => { const { context } = await getActionExecutionContext(jobContext, cache) // Ensure there are no pending updates already - expect((cache.NextPartInstance! as PartInstanceWithPiecesImpl).HasChanges).toBeFalsy() + expect((cache.NextPartInstance! as PlayoutPartInstanceModelImpl).HasChanges).toBeFalsy() // Update it and expect it to match const partInstance0Before = clone(partInstance0) @@ -1745,7 +1745,7 @@ describe('Test blueprint api context', () => { }, } expect(partInstance1.PartInstance).toEqual(pieceInstance0After) - expect((partInstance1 as PartInstanceWithPiecesImpl).HasChanges).toBeTruthy() + expect((partInstance1 as PlayoutPartInstanceModelImpl).HasChanges).toBeTruthy() // expect( // Array.from(cache.PartInstances.documents.values()).filter((doc) => !doc || !!doc.updated) // ).toMatchObject([ diff --git a/packages/job-worker/src/blueprints/context/SyncIngestUpdateToPartInstanceContext.ts b/packages/job-worker/src/blueprints/context/SyncIngestUpdateToPartInstanceContext.ts index f100566144b..f984f08227f 100644 --- a/packages/job-worker/src/blueprints/context/SyncIngestUpdateToPartInstanceContext.ts +++ b/packages/job-worker/src/blueprints/context/SyncIngestUpdateToPartInstanceContext.ts @@ -2,7 +2,7 @@ import { PieceInstanceId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { PieceInstance, PieceInstancePiece } from '@sofie-automation/corelib/dist/dataModel/PieceInstance' import { clone, normalizeArrayToMap, omit } from '@sofie-automation/corelib/dist/lib' import { protectString, protectStringArray, unprotectStringArray } from '@sofie-automation/corelib/dist/protectedString' -import { PartInstanceWithPieces } from '../../playout/cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../../playout/cacheModel/PlayoutPartInstanceModel' import { ReadonlyDeep } from 'type-fest' import _ = require('underscore') import { ContextInfo } from './CommonContext' @@ -39,7 +39,7 @@ export class SyncIngestUpdateToPartInstanceContext { private readonly _proposedPieceInstances: Map> - private partInstance: PartInstanceWithPieces | null + private partInstance: PlayoutPartInstanceModel | null constructor( private readonly _context: JobContext, @@ -47,7 +47,7 @@ export class SyncIngestUpdateToPartInstanceContext studio: ReadonlyDeep, showStyleCompound: ReadonlyDeep, rundown: ReadonlyDeep, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, proposedPieceInstances: ReadonlyDeep, private playStatus: 'previous' | 'current' | 'next' ) { diff --git a/packages/job-worker/src/blueprints/context/adlibActions.ts b/packages/job-worker/src/blueprints/context/adlibActions.ts index 544ef9a0ea2..ccf2c9bc802 100644 --- a/packages/job-worker/src/blueprints/context/adlibActions.ts +++ b/packages/job-worker/src/blueprints/context/adlibActions.ts @@ -21,7 +21,7 @@ import { assertNever, getRandomId, omit } from '@sofie-automation/corelib/dist/l import { logger } from '../../logging' import { ReadonlyDeep } from 'type-fest' import { PlayoutModel } from '../../playout/cacheModel/PlayoutModel' -import { PartInstanceWithPieces } from '../../playout/cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../../playout/cacheModel/PlayoutPartInstanceModel' import { UserContextInfo } from './CommonContext' import { ShowStyleUserContext } from './ShowStyleUserContext' import { WatchedPackagesHelper } from './watchedPackages' @@ -66,7 +66,7 @@ import { ProcessedShowStyleConfig } from '../config' import { DatastorePersistenceMode } from '@sofie-automation/shared-lib/dist/core/model/TimelineDatastore' import { getDatastoreId } from '../../playout/datastore' import { executePeripheralDeviceAction, listPlayoutDevices } from '../../peripheralDevice' -import { RundownWithSegments } from '../../playout/cacheModel/RundownWithSegments' +import { PlayoutRundownModel } from '../../playout/cacheModel/PlayoutRundownModel' export enum ActionPartChange { NONE = 0, @@ -123,7 +123,7 @@ export class DatastoreActionExecutionContext export class ActionExecutionContext extends ShowStyleUserContext implements IActionExecutionContext, IEventContext { private readonly _context: JobContext private readonly _cache: PlayoutModel - private readonly rundown: RundownWithSegments + private readonly rundown: PlayoutRundownModel /** To be set by any mutation methods on this context. Indicates to core how extensive the changes are to the current partInstance */ public currentPartState: ActionPartChange = ActionPartChange.NONE @@ -138,7 +138,7 @@ export class ActionExecutionContext extends ShowStyleUserContext implements IAct cache: PlayoutModel, showStyle: ReadonlyDeep, _showStyleBlueprintConfig: ProcessedShowStyleConfig, - rundown: RundownWithSegments, + rundown: PlayoutRundownModel, watchedPackages: WatchedPackagesHelper ) { super(contextInfo, context, showStyle, watchedPackages) @@ -148,7 +148,7 @@ export class ActionExecutionContext extends ShowStyleUserContext implements IAct this.takeAfterExecute = false } - private _getPartInstance(part: 'current' | 'next'): PartInstanceWithPieces | null { + private _getPartInstance(part: 'current' | 'next'): PlayoutPartInstanceModel | null { switch (part) { case 'current': return this._cache.CurrentPartInstance diff --git a/packages/job-worker/src/ingest/__tests__/ingest.test.ts b/packages/job-worker/src/ingest/__tests__/ingest.test.ts index b0a9e3377dd..5ffd310578d 100644 --- a/packages/job-worker/src/ingest/__tests__/ingest.test.ts +++ b/packages/job-worker/src/ingest/__tests__/ingest.test.ts @@ -46,7 +46,7 @@ import { innerStartQueuedAdLib } from '../../playout/adlibUtils' import { IngestJobs, RemoveOrphanedSegmentsProps } from '@sofie-automation/corelib/dist/worker/ingest' import { removeRundownPlaylistFromDb } from './lib' import { UserErrorMessage } from '@sofie-automation/corelib/dist/error' -import { PartInstanceWithPieces } from '../../playout/cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../../playout/cacheModel/PlayoutPartInstanceModel' require('../../peripheralDevice.ts') // include in order to create the Meteor methods needed @@ -2009,7 +2009,7 @@ describe('Test ingest actions for rundowns and segments', () => { const rundown0 = cache.Rundowns[0] expect(rundown0).toBeTruthy() - const currentPartInstance = cache.CurrentPartInstance as PartInstanceWithPieces + const currentPartInstance = cache.CurrentPartInstance as PlayoutPartInstanceModel expect(currentPartInstance).toBeTruthy() const newPartInstance = cache.insertAdlibbedPartInstance({ diff --git a/packages/job-worker/src/ingest/commit.ts b/packages/job-worker/src/ingest/commit.ts index f60a17ff248..39c7ba94c45 100644 --- a/packages/job-worker/src/ingest/commit.ts +++ b/packages/job-worker/src/ingest/commit.ts @@ -9,7 +9,7 @@ import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown' import { unprotectString, protectString } from '@sofie-automation/corelib/dist/protectedString' import { logger } from '../logging' import { PlayoutModel } from '../playout/cacheModel/PlayoutModel' -import { RundownWithSegments } from '../playout/cacheModel/RundownWithSegments' +import { PlayoutRundownModel } from '../playout/cacheModel/PlayoutRundownModel' import { isTooCloseToAutonext } from '../playout/lib' import { allowedToMoveRundownOutOfPlaylist, updatePartInstanceRanks } from '../rundown' import { @@ -42,8 +42,8 @@ import { SegmentOrphanedReason, } from '@sofie-automation/corelib/dist/dataModel/Segment' import { UserError, UserErrorMessage } from '@sofie-automation/corelib/dist/error' -import { RundownWithSegmentsImpl } from '../playout/cacheModel/implementation/RundownWithSegmentsImpl' -import { SegmentWithPartsImpl } from '../playout/cacheModel/implementation/SegmentWithPartsImpl' +import { PlayoutRundownModelImpl } from '../playout/cacheModel/implementation/PlayoutRundownModelImpl' +import { PlayoutSegmentModelImpl } from '../playout/cacheModel/implementation/PlayoutSegmentModelImpl' import { ReadOnlyCache } from '../cache/CacheBase' import { createPlayoutCachefromIngestCache } from '../playout/cacheModel/implementation/LoadPlayoutModel' @@ -344,7 +344,7 @@ async function updatePartInstancesSegmentIds( } } -export function hackConvertIngestCacheToRundownWithSegments(cache: ReadOnlyCache): RundownWithSegments { +export function hackConvertIngestCacheToRundownWithSegments(cache: ReadOnlyCache): PlayoutRundownModel { const rundown = cache.Rundown.doc if (!rundown) { throw new Error(`Rundown "${cache.RundownId}" ("${cache.RundownExternalId}") not found`) @@ -352,11 +352,11 @@ export function hackConvertIngestCacheToRundownWithSegments(cache: ReadOnlyCache const groupedParts = groupByToMap(cache.Parts.findAll(null), 'segmentId') const segmentsWithParts = cache.Segments.findAll(null).map( - (segment) => new SegmentWithPartsImpl(segment, groupedParts.get(segment._id) ?? []) + (segment) => new PlayoutSegmentModelImpl(segment, groupedParts.get(segment._id) ?? []) ) const groupedSegmentsWithParts = groupByToMapFunc(segmentsWithParts, (s) => s.Segment.rundownId) - return new RundownWithSegmentsImpl(rundown, groupedSegmentsWithParts.get(rundown._id) ?? [], []) + return new PlayoutRundownModelImpl(rundown, groupedSegmentsWithParts.get(rundown._id) ?? [], []) } /** @@ -364,7 +364,7 @@ export function hackConvertIngestCacheToRundownWithSegments(cache: ReadOnlyCache */ async function updatePartInstancesBasicProperties( context: JobContext, - rundownModel: RundownWithSegments, + rundownModel: PlayoutRundownModel, playlist: ReadonlyDeep ) { // Get a list of all the Parts that are known to exist diff --git a/packages/job-worker/src/ingest/syncChangesToPartInstance.ts b/packages/job-worker/src/ingest/syncChangesToPartInstance.ts index eeae41fca4d..6daa57d7c88 100644 --- a/packages/job-worker/src/ingest/syncChangesToPartInstance.ts +++ b/packages/job-worker/src/ingest/syncChangesToPartInstance.ts @@ -2,7 +2,7 @@ import { BlueprintSyncIngestNewData, BlueprintSyncIngestPartInstance } from '@so import { ReadOnlyCache } from '../cache/CacheBase' import { JobContext } from '../jobs' import { PlayoutModel } from '../playout/cacheModel/PlayoutModel' -import { PartInstanceWithPieces } from '../playout/cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../playout/cacheModel/PlayoutPartInstanceModel' import { CacheForIngest } from './cache' import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part' import { DBPartInstance } from '@sofie-automation/corelib/dist/dataModel/PartInstance' @@ -32,8 +32,8 @@ import { hackConvertIngestCacheToRundownWithSegments } from './commit' type PlayStatus = 'previous' | 'current' | 'next' type SyncedInstance = { - existingPartInstance: PartInstanceWithPieces - previousPartInstance: PartInstanceWithPieces | null + existingPartInstance: PlayoutPartInstanceModel + previousPartInstance: PlayoutPartInstanceModel | null playStatus: PlayStatus newPart: ReadonlyDeep | undefined piecesThatMayBeActive: Promise @@ -241,8 +241,8 @@ function insertToSyncedInstanceCandidates( instances: SyncedInstance[], cache: PlayoutModel, ingestCache: ReadOnlyCache, - thisPartInstance: PartInstanceWithPieces, - previousPartInstance: PartInstanceWithPieces | null, + thisPartInstance: PlayoutPartInstanceModel, + previousPartInstance: PlayoutPartInstanceModel | null, part: ReadonlyDeep | undefined, playStatus: PlayStatus ): void { @@ -269,8 +269,8 @@ function findPartAndInsertToSyncedInstanceCandidates( instances: SyncedInstance[], cache: PlayoutModel, ingestCache: ReadOnlyCache, - thisPartInstance: PartInstanceWithPieces, - previousPartInstance: PartInstanceWithPieces | null, + thisPartInstance: PlayoutPartInstanceModel, + previousPartInstance: PlayoutPartInstanceModel | null, playStatus: PlayStatus ): void { const newPart = cache.findPart(thisPartInstance.PartInstance.part._id) @@ -295,7 +295,7 @@ function findLastUnorphanedPartInstanceInSegment( cache: PlayoutModel, currentPartInstance: ReadonlyDeep ): { - partInstance: PartInstanceWithPieces + partInstance: PlayoutPartInstanceModel part: ReadonlyDeep } | null { // Find the "latest" (last played), non-orphaned PartInstance in this Segment, in this play-through diff --git a/packages/job-worker/src/playout/__tests__/selectNextPart.test.ts b/packages/job-worker/src/playout/__tests__/selectNextPart.test.ts index f1c82cf68e7..8e72590957c 100644 --- a/packages/job-worker/src/playout/__tests__/selectNextPart.test.ts +++ b/packages/job-worker/src/playout/__tests__/selectNextPart.test.ts @@ -5,8 +5,8 @@ import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment' import { protectString } from '@sofie-automation/corelib/dist/protectedString' import { ReadonlyDeep } from 'type-fest' import { MockJobContext, setupDefaultJobEnvironment } from '../../__mocks__/context' -import { SegmentWithPartsImpl } from '../cacheModel/implementation/SegmentWithPartsImpl' -import { SegmentWithParts } from '../cacheModel/SegmentWithParts' +import { PlayoutSegmentModelImpl } from '../cacheModel/implementation/PlayoutSegmentModelImpl' +import { PlayoutSegmentModel } from '../cacheModel/PlayoutSegmentModel' import { selectNextPart } from '../selectNextPart' class MockPart { @@ -71,9 +71,9 @@ describe('selectNextPart', () => { ignoreUnplayabale = true ) { const parts = [...(defaultParts as unknown as DBPart[])] - const segments: readonly SegmentWithParts[] = defaultSegments.map( + const segments: readonly PlayoutSegmentModel[] = defaultSegments.map( (segment) => - new SegmentWithPartsImpl( + new PlayoutSegmentModelImpl( segment as unknown as DBSegment, parts.filter((p) => p.segmentId === segment._id) ) diff --git a/packages/job-worker/src/playout/__tests__/timeline.test.ts b/packages/job-worker/src/playout/__tests__/timeline.test.ts index de8e5c06220..d2932df6d3f 100644 --- a/packages/job-worker/src/playout/__tests__/timeline.test.ts +++ b/packages/job-worker/src/playout/__tests__/timeline.test.ts @@ -62,9 +62,9 @@ import { PlayoutChangedType, } from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI' import * as _ from 'underscore' -import { RundownWithSegments } from '../cacheModel/RundownWithSegments' -import { PartInstanceWithPieces } from '../cacheModel/PartInstanceWithPieces' -import { PartInstanceWithPiecesImpl } from '../cacheModel/implementation/PartInstanceWithPiecesImpl' +import { PlayoutRundownModel } from '../cacheModel/PlayoutRundownModel' +import { PlayoutPartInstanceModel } from '../cacheModel/PlayoutPartInstanceModel' +import { PlayoutPartInstanceModelImpl } from '../cacheModel/implementation/PlayoutPartInstanceModelImpl' /** * An object used to represent the simplified timeline structure. @@ -180,8 +180,8 @@ function parsePieceGroupPrerollAndPostroll( function checkTimingsRaw( rundownId: RundownId, timeline: TimelineComplete | undefined, - currentPartInstance: PartInstanceWithPieces, - previousPartInstance: PartInstanceWithPieces | undefined, + currentPartInstance: PlayoutPartInstanceModel, + previousPartInstance: PlayoutPartInstanceModel | undefined, expectedTimings: PartTimelineTimings ) { const timelineObjs = timeline ? deserializeTimelineBlob(timeline?.timelineBlob) : [] @@ -448,9 +448,9 @@ async function doUpdateTimeline(context: MockJobContext, playlistId: RundownPlay } interface SelectedPartInstances { - currentPartInstance: PartInstanceWithPieces | undefined - nextPartInstance: PartInstanceWithPieces | undefined - previousPartInstance: PartInstanceWithPieces | undefined + currentPartInstance: PlayoutPartInstanceModel | undefined + nextPartInstance: PlayoutPartInstanceModel | undefined + previousPartInstance: PlayoutPartInstanceModel | undefined } describe('Timeline', () => { @@ -703,13 +703,13 @@ describe('Timeline', () => { async function wrapPartInstance( partInstance: DBPartInstance | null - ): Promise { + ): Promise { if (!partInstance) return undefined const pieceInstances = await context.directCollections.PieceInstances.findFetch({ partInstanceId: partInstance?._id, }) - return new PartInstanceWithPiecesImpl(partInstance, pieceInstances, false) + return new PlayoutPartInstanceModelImpl(partInstance, pieceInstances, false) } return { @@ -1131,11 +1131,11 @@ describe('Timeline', () => { describe('Adlib pieces', () => { async function doStartAdlibPiece( playlistId: RundownPlaylistId, - currentPartInstance: PartInstanceWithPieces, + currentPartInstance: PlayoutPartInstanceModel, adlibSource: AdLibPiece ) { await runJobWithPlayoutCache(context, { playlistId }, null, async (cache) => { - const rundown = cache.getRundown(currentPartInstance.PartInstance.rundownId) as RundownWithSegments + const rundown = cache.getRundown(currentPartInstance.PartInstance.rundownId) as PlayoutRundownModel expect(rundown).toBeTruthy() return innerStartOrQueueAdLibPiece(context, cache, rundown, false, currentPartInstance, adlibSource) diff --git a/packages/job-worker/src/playout/adlibAction.ts b/packages/job-worker/src/playout/adlibAction.ts index dca9e59de01..9ca021edfdb 100644 --- a/packages/job-worker/src/playout/adlibAction.ts +++ b/packages/job-worker/src/playout/adlibAction.ts @@ -20,7 +20,7 @@ import { ActionUserData } from '@sofie-automation/blueprints-integration' import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist' import { logger } from '../logging' import { validateScratchpartPartInstanceProperties } from './scratchpad' -import { RundownWithSegments } from './cacheModel/RundownWithSegments' +import { PlayoutRundownModel } from './cacheModel/PlayoutRundownModel' import { createPlayoutCachefromInitCache, loadPlayoutModelPreInit } from './cacheModel/implementation/LoadPlayoutModel' /** @@ -124,7 +124,7 @@ export interface ExecuteActionParameters { export async function executeActionInner( context: JobContext, cache: PlayoutModel, - rundown: RundownWithSegments, + rundown: PlayoutRundownModel, showStyle: ReadonlyDeep, blueprint: ReadonlyDeep, watchedPackages: WatchedPackagesHelper, diff --git a/packages/job-worker/src/playout/adlibJobs.ts b/packages/job-worker/src/playout/adlibJobs.ts index 2bbe5f77d7e..43ce481a6ee 100644 --- a/packages/job-worker/src/playout/adlibJobs.ts +++ b/packages/job-worker/src/playout/adlibJobs.ts @@ -13,7 +13,7 @@ import { TakePieceAsAdlibNowProps, } from '@sofie-automation/corelib/dist/worker/studio' import { PlayoutModel } from './cacheModel/PlayoutModel' -import { PartInstanceWithPieces } from './cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from './cacheModel/PlayoutPartInstanceModel' import { runJobWithPlayoutCache } from './lock' import { updateTimeline } from './timeline/generate' import { getCurrentTime } from '../lib' @@ -131,10 +131,10 @@ async function pieceTakeNowAsAdlib( context: JobContext, cache: PlayoutModel, showStyleBase: ReadonlyDeep, - currentPartInstance: PartInstanceWithPieces, + currentPartInstance: PlayoutPartInstanceModel, pieceToCopy: PieceInstancePiece, pieceInstanceToCopy: - | { partInstance: PartInstanceWithPieces; pieceInstance: ReadonlyDeep } + | { partInstance: PlayoutPartInstanceModel; pieceInstance: ReadonlyDeep } | undefined ): Promise { /*const newPieceInstance = */ convertAdLibToPieceInstance(context, pieceToCopy, currentPartInstance, false) @@ -394,7 +394,7 @@ export async function handleDisableNextPiece(context: JobContext, data: DisableN const allowedSourceLayers = showStyleBase.sourceLayers - const getNextPiece = (partInstance: PartInstanceWithPieces, ignoreStartedPlayback: boolean) => { + const getNextPiece = (partInstance: PlayoutPartInstanceModel, ignoreStartedPlayback: boolean) => { // Find next piece to disable let nowInPart = 0 @@ -433,7 +433,7 @@ export async function handleDisableNextPiece(context: JobContext, data: DisableN }) } - const partInstances: Array<[PartInstanceWithPieces | null, boolean]> = [ + const partInstances: Array<[PlayoutPartInstanceModel | null, boolean]> = [ [currentPartInstance, false], [nextPartInstance, true], // If not found in currently playing part, let's look in the next one: ] diff --git a/packages/job-worker/src/playout/adlibUtils.ts b/packages/job-worker/src/playout/adlibUtils.ts index 99b55887d8c..becf0d80701 100644 --- a/packages/job-worker/src/playout/adlibUtils.ts +++ b/packages/job-worker/src/playout/adlibUtils.ts @@ -8,7 +8,7 @@ import { MongoQuery } from '@sofie-automation/corelib/dist/mongo' import { getCurrentTime } from '../lib' import { JobContext } from '../jobs' import { PlayoutModel } from './cacheModel/PlayoutModel' -import { PartInstanceWithPieces } from './cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from './cacheModel/PlayoutPartInstanceModel' import { fetchPiecesThatMayBeActiveForPart, getPieceInstancesForPart, @@ -25,14 +25,14 @@ import { setNextPart } from './setNext' import { calculateNowOffsetLatency } from './timeline/multi-gateway' import { logger } from '../logging' import { ReadonlyDeep } from 'type-fest' -import { RundownWithSegments } from './cacheModel/RundownWithSegments' +import { PlayoutRundownModel } from './cacheModel/PlayoutRundownModel' export async function innerStartOrQueueAdLibPiece( context: JobContext, cache: PlayoutModel, - rundown: RundownWithSegments, + rundown: PlayoutRundownModel, queue: boolean, - currentPartInstance: PartInstanceWithPieces, + currentPartInstance: PlayoutPartInstanceModel, adLibPiece: AdLibPiece | BucketAdLib ): Promise { const span = context.startSpan('innerStartOrQueueAdLibPiece') @@ -177,9 +177,9 @@ export async function innerFindLastScriptedPieceOnLayer( export async function innerStartQueuedAdLib( context: JobContext, cache: PlayoutModel, - rundown: RundownWithSegments, - currentPartInstance: PartInstanceWithPieces, - newPartInstance: PartInstanceWithPieces + rundown: PlayoutRundownModel, + currentPartInstance: PlayoutPartInstanceModel, + newPartInstance: PlayoutPartInstanceModel ): Promise { const span = context.startSpan('innerStartQueuedAdLib') @@ -229,7 +229,7 @@ export function innerStopPieces( context: JobContext, cache: PlayoutModel, sourceLayers: SourceLayers, - currentPartInstance: PartInstanceWithPieces, + currentPartInstance: PlayoutPartInstanceModel, filter: (pieceInstance: ReadonlyDeep) => boolean, timeOffset: number | undefined ): Array { diff --git a/packages/job-worker/src/playout/cacheModel/PlayoutModel.ts b/packages/job-worker/src/playout/cacheModel/PlayoutModel.ts index 4df85e52e95..80fe445d183 100644 --- a/packages/job-worker/src/playout/cacheModel/PlayoutModel.ts +++ b/packages/job-worker/src/playout/cacheModel/PlayoutModel.ts @@ -19,9 +19,9 @@ import { StudioPlayoutModelBase, StudioPlayoutModelBaseReadonly } from '../../st import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part' import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance' import { PlaylistLock } from '../../jobs/lock' -import { RundownWithSegments } from './RundownWithSegments' -import { SegmentWithParts } from './SegmentWithParts' -import { PartInstanceWithPieces } from './PartInstanceWithPieces' +import { PlayoutRundownModel } from './PlayoutRundownModel' +import { PlayoutSegmentModel } from './PlayoutSegmentModel' +import { PlayoutPartInstanceModel } from './PlayoutPartInstanceModel' import { PeripheralDevice } from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice' import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown' @@ -47,17 +47,17 @@ export interface PlayoutModelReadonly extends StudioPlayoutModelBaseReadonly { readonly PlaylistLock: PlaylistLock get Playlist(): ReadonlyDeep - get Rundowns(): readonly RundownWithSegments[] + get Rundowns(): readonly PlayoutRundownModel[] - get OlderPartInstances(): PartInstanceWithPieces[] - get PreviousPartInstance(): PartInstanceWithPieces | null - get CurrentPartInstance(): PartInstanceWithPieces | null - get NextPartInstance(): PartInstanceWithPieces | null + get OlderPartInstances(): PlayoutPartInstanceModel[] + get PreviousPartInstance(): PlayoutPartInstanceModel | null + get CurrentPartInstance(): PlayoutPartInstanceModel | null + get NextPartInstance(): PlayoutPartInstanceModel | null get SelectedPartInstanceIds(): PartInstanceId[] - get SelectedPartInstances(): PartInstanceWithPieces[] - get LoadedPartInstances(): PartInstanceWithPieces[] - get SortedLoadedPartInstances(): PartInstanceWithPieces[] - getPartInstance(partInstanceId: PartInstanceId): PartInstanceWithPieces | undefined + get SelectedPartInstances(): PlayoutPartInstanceModel[] + get LoadedPartInstances(): PlayoutPartInstanceModel[] + get SortedLoadedPartInstances(): PlayoutPartInstanceModel[] + getPartInstance(partInstanceId: PartInstanceId): PlayoutPartInstanceModel | undefined /** * Search for a Part through the whole Playlist @@ -66,41 +66,41 @@ export interface PlayoutModelReadonly extends StudioPlayoutModelBaseReadonly { findPart(id: PartId): ReadonlyDeep | undefined getAllOrderedParts(): ReadonlyDeep[] - findSegment(id: SegmentId): ReadonlyDeep | undefined - getAllOrderedSegments(): ReadonlyDeep[] + findSegment(id: SegmentId): ReadonlyDeep | undefined + getAllOrderedSegments(): ReadonlyDeep[] - getRundown(id: RundownId): RundownWithSegments | undefined + getRundown(id: RundownId): PlayoutRundownModel | undefined getRundownIds(): RundownId[] findPieceInstance( id: PieceInstanceId - ): { partInstance: PartInstanceWithPieces; pieceInstance: ReadonlyDeep } | undefined + ): { partInstance: PlayoutPartInstanceModel; pieceInstance: ReadonlyDeep } | undefined } export interface PlayoutModel extends PlayoutModelReadonly, StudioPlayoutModelBase, ICacheBase2 { - createInstanceForPart(nextPart: ReadonlyDeep, pieceInstances: PieceInstance[]): PartInstanceWithPieces - insertAdlibbedPartInstance(part: Omit): PartInstanceWithPieces + createInstanceForPart(nextPart: ReadonlyDeep, pieceInstances: PieceInstance[]): PlayoutPartInstanceModel + insertAdlibbedPartInstance(part: Omit): PlayoutPartInstanceModel insertScratchpadPartInstance( - rundown: RundownWithSegments, + rundown: PlayoutRundownModel, part: Omit - ): PartInstanceWithPieces + ): PlayoutPartInstanceModel /** * HACK: This allows for taking a copy of a `PartInstanceWithPieces` for use in `syncChangesToPartInstances`. * This lets us discard the changes if the blueprint call throws. * We should look at avoiding this messy/dangerous method, and find a better way to do this */ - replacePartInstance(partInstance: PartInstanceWithPieces): void + replacePartInstance(partInstance: PlayoutPartInstanceModel): void /** @deprecated HACK */ removePartInstance(id: PartInstanceId): void setHoldState(newState: RundownHoldState): void - setNextSegment(segment: SegmentWithParts | null): void + setNextSegment(segment: PlayoutSegmentModel | null): void cycleSelectedPartInstances(): void setRundownStartedPlayback(rundownId: RundownId, timestamp: number): void setPartInstanceAsNext( - partInstance: PartInstanceWithPieces | null, + partInstance: PlayoutPartInstanceModel | null, setManually: boolean, consumesNextSegmentId: boolean, nextTimeOffset?: number diff --git a/packages/job-worker/src/playout/cacheModel/PartInstanceWithPieces.ts b/packages/job-worker/src/playout/cacheModel/PlayoutPartInstanceModel.ts similarity index 97% rename from packages/job-worker/src/playout/cacheModel/PartInstanceWithPieces.ts rename to packages/job-worker/src/playout/cacheModel/PlayoutPartInstanceModel.ts index a65bfd46af3..a3e77cf39ed 100644 --- a/packages/job-worker/src/playout/cacheModel/PartInstanceWithPieces.ts +++ b/packages/job-worker/src/playout/cacheModel/PlayoutPartInstanceModel.ts @@ -11,11 +11,11 @@ import { PartNote } from '@sofie-automation/corelib/dist/dataModel/Notes' import { IBlueprintMutatablePart, PieceLifespan, Time } from '@sofie-automation/blueprints-integration' import { PartCalculatedTimings } from '@sofie-automation/corelib/dist/playout/timings' -export interface PartInstanceWithPieces { +export interface PlayoutPartInstanceModel { readonly PartInstance: ReadonlyDeep readonly PieceInstances: ReadonlyDeep[] - clone(): PartInstanceWithPieces + clone(): PlayoutPartInstanceModel setPlaylistActivationId(id: RundownPlaylistActivationId): void diff --git a/packages/job-worker/src/playout/cacheModel/RundownWithSegments.ts b/packages/job-worker/src/playout/cacheModel/PlayoutRundownModel.ts similarity index 72% rename from packages/job-worker/src/playout/cacheModel/RundownWithSegments.ts rename to packages/job-worker/src/playout/cacheModel/PlayoutRundownModel.ts index 2e4398fd1d7..1e8b0ca24a4 100644 --- a/packages/job-worker/src/playout/cacheModel/RundownWithSegments.ts +++ b/packages/job-worker/src/playout/cacheModel/PlayoutRundownModel.ts @@ -3,17 +3,17 @@ import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown' import { ReadonlyDeep } from 'type-fest' import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part' import { RundownBaselineObj } from '@sofie-automation/corelib/dist/dataModel/RundownBaselineObj' -import { SegmentWithParts } from './SegmentWithParts' +import { PlayoutSegmentModel } from './PlayoutSegmentModel' -export interface RundownWithSegments { +export interface PlayoutRundownModel { readonly Rundown: ReadonlyDeep - readonly Segments: readonly SegmentWithParts[] + readonly Segments: readonly PlayoutSegmentModel[] readonly BaselineObjects: ReadonlyDeep getSegmentIds(): SegmentId[] - getSegment(id: SegmentId): SegmentWithParts | undefined + getSegment(id: SegmentId): PlayoutSegmentModel | undefined getAllPartIds(): PartId[] @@ -21,6 +21,6 @@ export interface RundownWithSegments { insertScratchpadSegment(): SegmentId removeScratchpadSegment(): boolean - getScratchpadSegment(): SegmentWithParts | undefined + getScratchpadSegment(): PlayoutSegmentModel | undefined setScratchpadSegmentRank(rank: number): void } diff --git a/packages/job-worker/src/playout/cacheModel/SegmentWithParts.ts b/packages/job-worker/src/playout/cacheModel/PlayoutSegmentModel.ts similarity index 91% rename from packages/job-worker/src/playout/cacheModel/SegmentWithParts.ts rename to packages/job-worker/src/playout/cacheModel/PlayoutSegmentModel.ts index 02a2d22941f..e68de3e16c4 100644 --- a/packages/job-worker/src/playout/cacheModel/SegmentWithParts.ts +++ b/packages/job-worker/src/playout/cacheModel/PlayoutSegmentModel.ts @@ -3,7 +3,7 @@ import { ReadonlyDeep } from 'type-fest' import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment' import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part' -export interface SegmentWithParts { +export interface PlayoutSegmentModel { readonly Segment: ReadonlyDeep readonly Parts: ReadonlyDeep diff --git a/packages/job-worker/src/playout/cacheModel/implementation/LoadPlayoutModel.ts b/packages/job-worker/src/playout/cacheModel/implementation/LoadPlayoutModel.ts index 9bd25575960..03ec62695dc 100644 --- a/packages/job-worker/src/playout/cacheModel/implementation/LoadPlayoutModel.ts +++ b/packages/job-worker/src/playout/cacheModel/implementation/LoadPlayoutModel.ts @@ -6,7 +6,7 @@ import { PlaylistLock } from '../../../jobs/lock' import { ReadonlyDeep } from 'type-fest' import { JobContext } from '../../../jobs' import { PlayoutModelImpl } from './PlayoutModelImpl' -import { RundownWithSegmentsImpl } from './RundownWithSegmentsImpl' +import { PlayoutRundownModelImpl } from './PlayoutRundownModelImpl' import { RundownId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { DBPartInstance } from '@sofie-automation/corelib/dist/dataModel/PartInstance' import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance' @@ -15,9 +15,9 @@ import { TimelineComplete } from '@sofie-automation/corelib/dist/dataModel/Timel import { MongoQuery } from '@sofie-automation/corelib/dist/mongo' import _ = require('underscore') import { clone, groupByToMap, groupByToMapFunc } from '@sofie-automation/corelib/dist/lib' -import { SegmentWithPartsImpl } from './SegmentWithPartsImpl' +import { PlayoutSegmentModelImpl } from './PlayoutSegmentModelImpl' import { unprotectString } from '@sofie-automation/corelib/dist/protectedString' -import { PartInstanceWithPiecesImpl } from './PartInstanceWithPiecesImpl' +import { PlayoutPartInstanceModelImpl } from './PlayoutPartInstanceModelImpl' import { PeripheralDevice } from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice' import { PlayoutModel, PlayoutModelPreInit } from '../PlayoutModel' @@ -149,7 +149,7 @@ async function loadRundowns( context: JobContext, ingestCache: ReadOnlyCache | null, rundowns: ReadonlyDeep -): Promise { +): Promise { const rundownIds = rundowns.map((rd) => rd._id) // If there is an ingestCache, then avoid loading some bits from the db for that rundown @@ -186,7 +186,7 @@ async function loadRundowns( const groupedParts = groupByToMap(parts, 'segmentId') const segmentsWithParts = segments.map( - (segment) => new SegmentWithPartsImpl(segment, groupedParts.get(segment._id) ?? []) + (segment) => new PlayoutSegmentModelImpl(segment, groupedParts.get(segment._id) ?? []) ) const groupedSegmentsWithParts = groupByToMapFunc(segmentsWithParts, (s) => s.Segment.rundownId) @@ -194,7 +194,7 @@ async function loadRundowns( return rundowns.map( (rundown) => - new RundownWithSegmentsImpl( + new PlayoutRundownModelImpl( rundown, groupedSegmentsWithParts.get(rundown._id) ?? [], groupedBaselineObjects.get(rundown._id) ?? [] @@ -210,7 +210,7 @@ async function loadPartInstances( context: JobContext, playlist: ReadonlyDeep, rundownIds: RundownId[] -): Promise { +): Promise { const selectedPartInstanceIds = _.compact([ playlist.currentPartInfo?.partInstanceId, playlist.nextPartInfo?.partInstanceId, @@ -266,9 +266,9 @@ async function loadPartInstances( const groupedPieceInstances = groupByToMap(pieceInstances, 'partInstanceId') - const allPartInstances: PartInstanceWithPiecesImpl[] = [] + const allPartInstances: PlayoutPartInstanceModelImpl[] = [] for (const partInstance of partInstances) { - const wrappedPartInstance = new PartInstanceWithPiecesImpl( + const wrappedPartInstance = new PlayoutPartInstanceModelImpl( partInstance, groupedPieceInstances.get(partInstance._id) ?? [], false diff --git a/packages/job-worker/src/playout/cacheModel/implementation/PlayoutModelImpl.ts b/packages/job-worker/src/playout/cacheModel/implementation/PlayoutModelImpl.ts index dd642e3b375..e71118b33dd 100644 --- a/packages/job-worker/src/playout/cacheModel/implementation/PlayoutModelImpl.ts +++ b/packages/job-worker/src/playout/cacheModel/implementation/PlayoutModelImpl.ts @@ -33,11 +33,11 @@ import { PlaylistLock } from '../../../jobs/lock' import { logger } from '../../../logging' import { clone, getRandomId, literal, normalizeArrayToMapFunc, sleep } from '@sofie-automation/corelib/dist/lib' import { sortRundownIDsInPlaylist } from '@sofie-automation/corelib/dist/playout/playlist' -import { RundownWithSegments } from '../RundownWithSegments' -import { RundownWithSegmentsImpl } from './RundownWithSegmentsImpl' -import { SegmentWithParts } from '../SegmentWithParts' -import { PartInstanceWithPiecesImpl } from './PartInstanceWithPiecesImpl' -import { PartInstanceWithPieces } from '../PartInstanceWithPieces' +import { PlayoutRundownModel } from '../PlayoutRundownModel' +import { PlayoutRundownModelImpl } from './PlayoutRundownModelImpl' +import { PlayoutSegmentModel } from '../PlayoutSegmentModel' +import { PlayoutPartInstanceModelImpl } from './PlayoutPartInstanceModelImpl' +import { PlayoutPartInstanceModel } from '../PlayoutPartInstanceModel' import { getCurrentTime } from '../../../lib' import { protectString } from '@sofie-automation/shared-lib/dist/lib/protectedString' import { queuePartInstanceTimingEvent } from '../../timings/events' @@ -68,8 +68,8 @@ export class PlayoutModelImpl implements PlayoutModel { return this.#Playlist } - readonly #Rundowns: readonly RundownWithSegmentsImpl[] - public get Rundowns(): readonly RundownWithSegments[] { + readonly #Rundowns: readonly PlayoutRundownModelImpl[] + public get Rundowns(): readonly PlayoutRundownModel[] { return this.#Rundowns } @@ -81,28 +81,28 @@ export class PlayoutModelImpl implements PlayoutModel { #PendingPartInstanceTimingEvents = new Set() - #AllPartInstances: Map + #AllPartInstances: Map - public get OlderPartInstances(): PartInstanceWithPieces[] { + public get OlderPartInstances(): PlayoutPartInstanceModel[] { const allPartInstances = this.LoadedPartInstances const ignoreIds = new Set(this.SelectedPartInstanceIds) return allPartInstances.filter((partInstance) => !ignoreIds.has(partInstance.PartInstance._id)) } - public get PreviousPartInstance(): PartInstanceWithPieces | null { + public get PreviousPartInstance(): PlayoutPartInstanceModel | null { if (!this.Playlist.previousPartInfo?.partInstanceId) return null const partInstance = this.#AllPartInstances.get(this.Playlist.previousPartInfo.partInstanceId) if (!partInstance) return null // throw new Error('PreviousPartInstance is missing') return partInstance } - public get CurrentPartInstance(): PartInstanceWithPieces | null { + public get CurrentPartInstance(): PlayoutPartInstanceModel | null { if (!this.Playlist.currentPartInfo?.partInstanceId) return null const partInstance = this.#AllPartInstances.get(this.Playlist.currentPartInfo.partInstanceId) if (!partInstance) return null // throw new Error('CurrentPartInstance is missing') return partInstance } - public get NextPartInstance(): PartInstanceWithPieces | null { + public get NextPartInstance(): PlayoutPartInstanceModel | null { if (!this.Playlist.nextPartInfo?.partInstanceId) return null const partInstance = this.#AllPartInstances.get(this.Playlist.nextPartInfo.partInstanceId) if (!partInstance) return null // throw new Error('NextPartInstance is missing') @@ -117,22 +117,22 @@ export class PlayoutModelImpl implements PlayoutModel { ]) } - public get SelectedPartInstances(): PartInstanceWithPieces[] { + public get SelectedPartInstances(): PlayoutPartInstanceModel[] { return _.compact([this.CurrentPartInstance, this.PreviousPartInstance, this.NextPartInstance]) } - public get LoadedPartInstances(): PartInstanceWithPieces[] { - return Array.from(this.#AllPartInstances.values()).filter((v): v is PartInstanceWithPiecesImpl => v !== null) + public get LoadedPartInstances(): PlayoutPartInstanceModel[] { + return Array.from(this.#AllPartInstances.values()).filter((v): v is PlayoutPartInstanceModelImpl => v !== null) } - public get SortedLoadedPartInstances(): PartInstanceWithPieces[] { + public get SortedLoadedPartInstances(): PlayoutPartInstanceModel[] { const allInstances = this.LoadedPartInstances allInstances.sort((a, b) => a.PartInstance.takeCount - b.PartInstance.takeCount) return allInstances } - public getPartInstance(partInstanceId: PartInstanceId): PartInstanceWithPieces | undefined { + public getPartInstance(partInstanceId: PartInstanceId): PlayoutPartInstanceModel | undefined { return this.#AllPartInstances.get(partInstanceId) ?? undefined } @@ -142,8 +142,8 @@ export class PlayoutModelImpl implements PlayoutModel { playlistId: RundownPlaylistId, peripheralDevices: ReadonlyDeep, playlist: DBRundownPlaylist, - partInstances: PartInstanceWithPiecesImpl[], - rundowns: RundownWithSegmentsImpl[], + partInstances: PlayoutPartInstanceModelImpl[], + rundowns: PlayoutRundownModelImpl[], timeline: TimelineComplete | undefined ) { context.trackCache(this) @@ -194,7 +194,7 @@ export class PlayoutModelImpl implements PlayoutModel { return this.Rundowns.flatMap((rundown) => rundown.getAllOrderedParts()) } - findSegment(id: SegmentId): ReadonlyDeep | undefined { + findSegment(id: SegmentId): ReadonlyDeep | undefined { for (const rundown of this.Rundowns) { const segment = rundown.getSegment(id) if (segment) return segment @@ -202,11 +202,11 @@ export class PlayoutModelImpl implements PlayoutModel { return undefined } - getAllOrderedSegments(): ReadonlyDeep[] { + getAllOrderedSegments(): ReadonlyDeep[] { return this.Rundowns.flatMap((rundown) => rundown.Segments) } - getRundown(id: RundownId): RundownWithSegments | undefined { + getRundown(id: RundownId): PlayoutRundownModel | undefined { return this.Rundowns.find((rundown) => rundown.Rundown._id === id) } getRundownIds(): RundownId[] { @@ -218,7 +218,7 @@ export class PlayoutModelImpl implements PlayoutModel { findPieceInstance( id: PieceInstanceId - ): { partInstance: PartInstanceWithPieces; pieceInstance: ReadonlyDeep } | undefined { + ): { partInstance: PlayoutPartInstanceModel; pieceInstance: ReadonlyDeep } | undefined { for (const partInstance of this.LoadedPartInstances) { const pieceInstance = partInstance.getPieceInstance(id) if (pieceInstance) return { partInstance, pieceInstance } @@ -227,7 +227,7 @@ export class PlayoutModelImpl implements PlayoutModel { return undefined } - createInstanceForPart(nextPart: ReadonlyDeep, pieceInstances: PieceInstance[]): PartInstanceWithPieces { + createInstanceForPart(nextPart: ReadonlyDeep, pieceInstances: PieceInstance[]): PlayoutPartInstanceModel { const playlistActivationId = this.Playlist.activationId if (!playlistActivationId) throw new Error(`Playlist is not active`) @@ -258,13 +258,13 @@ export class PlayoutModelImpl implements PlayoutModel { pieceInstance.partInstanceId = newPartInstance._id } - const partWithPieces = new PartInstanceWithPiecesImpl(newPartInstance, pieceInstances, true) + const partWithPieces = new PlayoutPartInstanceModelImpl(newPartInstance, pieceInstances, true) this.#AllPartInstances.set(newPartInstance._id, partWithPieces) return partWithPieces } - insertAdlibbedPartInstance(part: Omit): PartInstanceWithPieces { + insertAdlibbedPartInstance(part: Omit): PlayoutPartInstanceModel { const currentPartInstance = this.CurrentPartInstance if (!currentPartInstance) throw new Error('No currentPartInstance') @@ -284,16 +284,16 @@ export class PlayoutModelImpl implements PlayoutModel { }, } - const partWithPieces = new PartInstanceWithPiecesImpl(newPartInstance, [], true) + const partWithPieces = new PlayoutPartInstanceModelImpl(newPartInstance, [], true) this.#AllPartInstances.set(newPartInstance._id, partWithPieces) return partWithPieces } insertScratchpadPartInstance( - rundown: RundownWithSegments, + rundown: PlayoutRundownModel, part: Omit - ): PartInstanceWithPieces { + ): PlayoutPartInstanceModel { const currentPartInstance = this.CurrentPartInstance if (!currentPartInstance) throw new Error('No currentPartInstance') @@ -321,7 +321,7 @@ export class PlayoutModelImpl implements PlayoutModel { }, } - const partWithPieces = new PartInstanceWithPiecesImpl(newPartInstance, [], true) + const partWithPieces = new PlayoutPartInstanceModelImpl(newPartInstance, [], true) this.#AllPartInstances.set(newPartInstance._id, partWithPieces) return partWithPieces @@ -332,8 +332,8 @@ export class PlayoutModelImpl implements PlayoutModel { * This lets us discard the changes if the blueprint call throws. * We should look at avoiding this messy/dangerous method, and find a better way to do this */ - replacePartInstance(partInstance: PartInstanceWithPieces): void { - if (!(partInstance instanceof PartInstanceWithPiecesImpl)) + replacePartInstance(partInstance: PlayoutPartInstanceModel): void { + if (!(partInstance instanceof PlayoutPartInstanceModelImpl)) throw new Error(`Expected PartInstanceWithPiecesImpl`) const currentPartInstance = this.CurrentPartInstance @@ -364,7 +364,7 @@ export class PlayoutModelImpl implements PlayoutModel { this.#PlaylistHasChanged = true } - setNextSegment(segment: SegmentWithParts | null): void { + setNextSegment(segment: PlayoutSegmentModel | null): void { // TODO some validation? this.#Playlist.nextSegmentId = segment?.Segment?._id ?? undefined @@ -405,7 +405,7 @@ export class PlayoutModelImpl implements PlayoutModel { } setPartInstanceAsNext( - partInstance: PartInstanceWithPieces | null, + partInstance: PlayoutPartInstanceModel | null, setManually: boolean, consumesNextSegmentId: boolean, nextTimeOffset?: number diff --git a/packages/job-worker/src/playout/cacheModel/implementation/PartInstanceWithPiecesImpl.ts b/packages/job-worker/src/playout/cacheModel/implementation/PlayoutPartInstanceModelImpl.ts similarity index 98% rename from packages/job-worker/src/playout/cacheModel/implementation/PartInstanceWithPiecesImpl.ts rename to packages/job-worker/src/playout/cacheModel/implementation/PlayoutPartInstanceModelImpl.ts index 612582cc703..de6928092a0 100644 --- a/packages/job-worker/src/playout/cacheModel/implementation/PartInstanceWithPiecesImpl.ts +++ b/packages/job-worker/src/playout/cacheModel/implementation/PlayoutPartInstanceModelImpl.ts @@ -27,7 +27,7 @@ import { PieceLifespan, Time, } from '@sofie-automation/blueprints-integration' -import { PartInstanceWithPieces } from '../PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../PlayoutPartInstanceModel' import { protectString } from '@sofie-automation/corelib/dist/protectedString' interface PieceInstanceWrapper { @@ -35,7 +35,7 @@ interface PieceInstanceWrapper { doc: PieceInstance | null } -export class PartInstanceWithPiecesImpl implements PartInstanceWithPieces { +export class PlayoutPartInstanceModelImpl implements PlayoutPartInstanceModel { PartInstanceImpl: DBPartInstance PieceInstancesImpl: Map @@ -92,8 +92,8 @@ export class PartInstanceWithPiecesImpl implements PartInstanceWithPieces { * What is the purpose of this? Without changing the ids it is going to clash with the old copy.. * TODO - this has issues with deleting instances! */ - clone(): PartInstanceWithPieces { - return new PartInstanceWithPiecesImpl( + clone(): PlayoutPartInstanceModel { + return new PlayoutPartInstanceModelImpl( clone(this.PartInstanceImpl), clone(this.PieceInstances), this.#PartInstanceHasChanges diff --git a/packages/job-worker/src/playout/cacheModel/implementation/RundownWithSegmentsImpl.ts b/packages/job-worker/src/playout/cacheModel/implementation/PlayoutRundownModelImpl.ts similarity index 84% rename from packages/job-worker/src/playout/cacheModel/implementation/RundownWithSegmentsImpl.ts rename to packages/job-worker/src/playout/cacheModel/implementation/PlayoutRundownModelImpl.ts index f3af774eecc..22f810064bf 100644 --- a/packages/job-worker/src/playout/cacheModel/implementation/RundownWithSegmentsImpl.ts +++ b/packages/job-worker/src/playout/cacheModel/implementation/PlayoutRundownModelImpl.ts @@ -3,17 +3,17 @@ import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown' import { ReadonlyDeep } from 'type-fest' import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part' import { RundownBaselineObj } from '@sofie-automation/corelib/dist/dataModel/RundownBaselineObj' -import { RundownWithSegments } from '../RundownWithSegments' -import { SegmentWithParts } from '../SegmentWithParts' +import { PlayoutRundownModel } from '../PlayoutRundownModel' +import { PlayoutSegmentModel } from '../PlayoutSegmentModel' import { UserError, UserErrorMessage } from '@sofie-automation/corelib/dist/error' import { SegmentOrphanedReason } from '@sofie-automation/corelib/dist/dataModel/Segment' import { getRandomId } from '@sofie-automation/corelib/dist/lib' import { getCurrentTime } from '../../../lib' -import { SegmentWithPartsImpl } from './SegmentWithPartsImpl' +import { PlayoutSegmentModelImpl } from './PlayoutSegmentModelImpl' -export class RundownWithSegmentsImpl implements RundownWithSegments { +export class PlayoutRundownModelImpl implements PlayoutRundownModel { readonly Rundown: ReadonlyDeep - readonly #segments: SegmentWithPartsImpl[] + readonly #segments: PlayoutSegmentModelImpl[] readonly BaselineObjects: ReadonlyDeep @@ -27,7 +27,7 @@ export class RundownWithSegmentsImpl implements RundownWithSegments { constructor( rundown: ReadonlyDeep, - segments: SegmentWithPartsImpl[], + segments: PlayoutSegmentModelImpl[], baselineObjects: ReadonlyDeep ) { segments.sort((a, b) => a.Segment._rank - b.Segment._rank) @@ -37,7 +37,7 @@ export class RundownWithSegmentsImpl implements RundownWithSegments { this.BaselineObjects = baselineObjects } - get Segments(): readonly SegmentWithParts[] { + get Segments(): readonly PlayoutSegmentModel[] { return this.#segments } @@ -45,7 +45,7 @@ export class RundownWithSegmentsImpl implements RundownWithSegments { return this.Segments.map((segment) => segment.Segment._id) } - getSegment(id: SegmentId): SegmentWithParts | undefined { + getSegment(id: SegmentId): PlayoutSegmentModel | undefined { return this.Segments.find((segment) => segment.Segment._id === id) } @@ -65,7 +65,7 @@ export class RundownWithSegmentsImpl implements RundownWithSegments { const segmentId: SegmentId = getRandomId() this.#segments.unshift( - new SegmentWithPartsImpl( + new PlayoutSegmentModelImpl( { _id: segmentId, _rank: minSegmentRank - 1, @@ -94,7 +94,7 @@ export class RundownWithSegmentsImpl implements RundownWithSegments { return true } - getScratchpadSegment(): SegmentWithParts | undefined { + getScratchpadSegment(): PlayoutSegmentModel | undefined { // Note: this assumes there will be up to one per rundown return this.#segments.find((s) => s.Segment.orphaned === SegmentOrphanedReason.SCRATCHPAD) } diff --git a/packages/job-worker/src/playout/cacheModel/implementation/SegmentWithPartsImpl.ts b/packages/job-worker/src/playout/cacheModel/implementation/PlayoutSegmentModelImpl.ts similarity index 88% rename from packages/job-worker/src/playout/cacheModel/implementation/SegmentWithPartsImpl.ts rename to packages/job-worker/src/playout/cacheModel/implementation/PlayoutSegmentModelImpl.ts index 8966b1903ed..635ca3016b9 100644 --- a/packages/job-worker/src/playout/cacheModel/implementation/SegmentWithPartsImpl.ts +++ b/packages/job-worker/src/playout/cacheModel/implementation/PlayoutSegmentModelImpl.ts @@ -2,9 +2,9 @@ import { PartId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { ReadonlyDeep } from 'type-fest' import { DBSegment, SegmentOrphanedReason } from '@sofie-automation/corelib/dist/dataModel/Segment' import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part' -import { SegmentWithParts } from '../SegmentWithParts' +import { PlayoutSegmentModel } from '../PlayoutSegmentModel' -export class SegmentWithPartsImpl implements SegmentWithParts { +export class PlayoutSegmentModelImpl implements PlayoutSegmentModel { readonly #Segment: DBSegment readonly Parts: ReadonlyDeep diff --git a/packages/job-worker/src/playout/cacheModel/implementation/SavePlayoutModel.ts b/packages/job-worker/src/playout/cacheModel/implementation/SavePlayoutModel.ts index 1906aa93828..27d0b905263 100644 --- a/packages/job-worker/src/playout/cacheModel/implementation/SavePlayoutModel.ts +++ b/packages/job-worker/src/playout/cacheModel/implementation/SavePlayoutModel.ts @@ -5,12 +5,12 @@ import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment' import { protectString } from '@sofie-automation/corelib/dist/protectedString' import { AnyBulkWriteOperation } from 'mongodb' import { JobContext } from '../../../jobs' -import { PartInstanceWithPiecesImpl } from './PartInstanceWithPiecesImpl' -import { RundownWithSegmentsImpl } from './RundownWithSegmentsImpl' +import { PlayoutPartInstanceModelImpl } from './PlayoutPartInstanceModelImpl' +import { PlayoutRundownModelImpl } from './PlayoutRundownModelImpl' export async function writeScratchpadSegments( context: JobContext, - rundowns: readonly RundownWithSegmentsImpl[] + rundowns: readonly PlayoutRundownModelImpl[] ): Promise { const writeOps: AnyBulkWriteOperation[] = [] @@ -49,7 +49,7 @@ export async function writeScratchpadSegments( export function writePartInstancesAndPieceInstances( context: JobContext, - partInstances: Map + partInstances: Map ): [Promise, Promise] { const partInstanceOps: AnyBulkWriteOperation[] = [] const pieceInstanceOps: AnyBulkWriteOperation[] = [] diff --git a/packages/job-worker/src/playout/infinites.ts b/packages/job-worker/src/playout/infinites.ts index f797b6746d9..17bf50bf867 100644 --- a/packages/job-worker/src/playout/infinites.ts +++ b/packages/job-worker/src/playout/infinites.ts @@ -13,8 +13,8 @@ import { processAndPrunePieceInstanceTimings } from '@sofie-automation/corelib/d import { JobContext } from '../jobs' import { ReadonlyDeep } from 'type-fest' import { PlayoutModel } from './cacheModel/PlayoutModel' -import { PartInstanceWithPieces } from './cacheModel/PartInstanceWithPieces' -import { SegmentWithParts } from './cacheModel/SegmentWithParts' +import { PlayoutPartInstanceModel } from './cacheModel/PlayoutPartInstanceModel' +import { PlayoutSegmentModel } from './cacheModel/PlayoutSegmentModel' import { getCurrentTime } from '../lib' import { flatten } from '@sofie-automation/corelib/dist/lib' import _ = require('underscore') @@ -23,12 +23,12 @@ import { CacheForIngest } from '../ingest/cache' import { SegmentOrphanedReason } from '@sofie-automation/corelib/dist/dataModel/Segment' import { sortRundownIDsInPlaylist } from '@sofie-automation/corelib/dist/playout/playlist' import { mongoWhere } from '@sofie-automation/corelib/dist/mongo' -import { RundownWithSegments } from './cacheModel/RundownWithSegments' +import { PlayoutRundownModel } from './cacheModel/PlayoutRundownModel' /** When we crop a piece, set the piece as "it has definitely ended" this far into the future. */ export const DEFINITELY_ENDED_FUTURE_DURATION = 1 * 1000 -function getShowStyleIdsRundownMapping(rundowns: readonly RundownWithSegments[]): Map { +function getShowStyleIdsRundownMapping(rundowns: readonly PlayoutRundownModel[]): Map { const ret = new Map() for (const rundown of rundowns) { @@ -43,7 +43,7 @@ function getShowStyleIdsRundownMapping(rundowns: readonly RundownWithSegments[]) * */ export function candidatePartIsAfterPreviewPartInstance( _context: JobContext, - orderedSegments: readonly SegmentWithParts[], + orderedSegments: readonly PlayoutSegmentModel[], previousPartInstance: ReadonlyDeep | undefined, candidateInstance: ReadonlyDeep ): boolean { @@ -215,8 +215,8 @@ export async function fetchPiecesThatMayBeActiveForPart( export async function syncPlayheadInfinitesForNextPartInstance( context: JobContext, cache: PlayoutModel, - fromPartInstance: PartInstanceWithPieces | null, - toPartInstance: PartInstanceWithPieces | null + fromPartInstance: PlayoutPartInstanceModel | null, + toPartInstance: PlayoutPartInstanceModel | null ): Promise { const span = context.startSpan('syncPlayheadInfinitesForNextPartInstance') @@ -298,8 +298,8 @@ export async function syncPlayheadInfinitesForNextPartInstance( export function getPieceInstancesForPart( context: JobContext, cache: PlayoutModel, - playingPartInstance: PartInstanceWithPieces | null, - rundown: RundownWithSegments, + playingPartInstance: PlayoutPartInstanceModel | null, + rundown: PlayoutRundownModel, part: ReadonlyDeep, possiblePieces: Piece[], newInstanceId: PartInstanceId @@ -322,8 +322,8 @@ export function getPieceInstancesForPart( const rundownIdsToShowstyleIds = getShowStyleIdsRundownMapping(cache.Rundowns) - let playingRundown: RundownWithSegments | undefined - let playingSegment: SegmentWithParts | undefined + let playingRundown: PlayoutRundownModel | undefined + let playingSegment: PlayoutSegmentModel | undefined if (playingPartInstance) { playingRundown = cache.getRundown(playingPartInstance.PartInstance.rundownId) if (!playingRundown) throw new Error(`Rundown "${playingPartInstance.PartInstance.rundownId}" not found!`) diff --git a/packages/job-worker/src/playout/pieces.ts b/packages/job-worker/src/playout/pieces.ts index 4965c71f2e9..4ce6800a412 100644 --- a/packages/job-worker/src/playout/pieces.ts +++ b/packages/job-worker/src/playout/pieces.ts @@ -9,7 +9,7 @@ import _ = require('underscore') import { Piece } from '@sofie-automation/corelib/dist/dataModel/Piece' import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece' import { ReadonlyDeep } from 'type-fest' -import { PartInstanceWithPieces } from './cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from './cacheModel/PlayoutPartInstanceModel' /** * Approximate compare Piece start times (for use in .sort()) @@ -109,7 +109,7 @@ export function convertPieceToAdLibPiece(context: JobContext, piece: PieceInstan export function convertAdLibToPieceInstance( context: JobContext, adLibPiece: AdLibPiece | Piece | BucketAdLib | PieceInstancePiece, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, queue: boolean ): ReadonlyDeep { const span = context.startSpan('convertAdLibToPieceInstance') diff --git a/packages/job-worker/src/playout/resolvedPieces.ts b/packages/job-worker/src/playout/resolvedPieces.ts index 963d8321cbe..f91a3042a66 100644 --- a/packages/job-worker/src/playout/resolvedPieces.ts +++ b/packages/job-worker/src/playout/resolvedPieces.ts @@ -8,7 +8,7 @@ import { resolvePrunedPieceInstance, } from '@sofie-automation/corelib/dist/playout/processAndPrune' import { SelectedPartInstancesTimelineInfo } from './timeline/generate' -import { PartInstanceWithPieces } from './cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from './cacheModel/PlayoutPartInstanceModel' /** * Resolve the PieceInstances for a PartInstance @@ -22,7 +22,7 @@ import { PartInstanceWithPieces } from './cacheModel/PartInstanceWithPieces' export function getResolvedPiecesForCurrentPartInstance( _context: JobContext, sourceLayers: SourceLayers, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, now?: number ): ResolvedPieceInstance[] { if (now === undefined) now = getCurrentTime() diff --git a/packages/job-worker/src/playout/selectNextPart.ts b/packages/job-worker/src/playout/selectNextPart.ts index a3de22878a0..05d64f49790 100644 --- a/packages/job-worker/src/playout/selectNextPart.ts +++ b/packages/job-worker/src/playout/selectNextPart.ts @@ -4,7 +4,7 @@ import { DBPartInstance } from '@sofie-automation/corelib/dist/dataModel/PartIns import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist' import { SegmentId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { ReadonlyDeep } from 'type-fest' -import { SegmentWithParts } from './cacheModel/SegmentWithParts' +import { PlayoutSegmentModel } from './cacheModel/PlayoutSegmentModel' /** * This wraps a Part which has been selected to be next, to include some additional data about that choice @@ -36,7 +36,7 @@ export function selectNextPart( rundownPlaylist: Pick, previousPartInstance: ReadonlyDeep | null, currentlySelectedPartInstance: ReadonlyDeep | null, - segments: readonly SegmentWithParts[], + segments: readonly PlayoutSegmentModel[], parts0: ReadonlyDeep[], ignoreUnplayabale = true ): SelectNextPartResult | null { diff --git a/packages/job-worker/src/playout/setNext.ts b/packages/job-worker/src/playout/setNext.ts index d7ab629fe90..305f92fd647 100644 --- a/packages/job-worker/src/playout/setNext.ts +++ b/packages/job-worker/src/playout/setNext.ts @@ -4,8 +4,8 @@ import { DBPart, isPartPlayable } from '@sofie-automation/corelib/dist/dataModel import { JobContext } from '../jobs' import { PartInstanceId, RundownId, SegmentId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { PlayoutModel } from './cacheModel/PlayoutModel' -import { PartInstanceWithPieces } from './cacheModel/PartInstanceWithPieces' -import { SegmentWithParts } from './cacheModel/SegmentWithParts' +import { PlayoutPartInstanceModel } from './cacheModel/PlayoutPartInstanceModel' +import { PlayoutSegmentModel } from './cacheModel/PlayoutSegmentModel' import { fetchPiecesThatMayBeActiveForPart, getPieceInstancesForPart, @@ -31,7 +31,7 @@ import { ReadonlyDeep } from 'type-fest' export async function setNextPart( context: JobContext, cache: PlayoutModel, - rawNextPart: ReadonlyDeep> | PartInstanceWithPieces | null, + rawNextPart: ReadonlyDeep> | PlayoutPartInstanceModel | null, setManually: boolean, nextTimeOffset?: number | undefined ): Promise { @@ -45,10 +45,10 @@ export async function setNextPart( if (!cache.Playlist.activationId) throw new Error(`RundownPlaylist "${cache.Playlist._id}" is not active`) // create new instance - let newPartInstance: PartInstanceWithPieces + let newPartInstance: PlayoutPartInstanceModel let consumesNextSegmentId: boolean if ('PartInstance' in rawNextPart) { - const inputPartInstance: PartInstanceWithPieces = rawNextPart + const inputPartInstance: PlayoutPartInstanceModel = rawNextPart if (inputPartInstance.PartInstance.part.invalid) { throw new Error('Part is marked as invalid, cannot set as next.') } @@ -122,8 +122,8 @@ export async function setNextPart( async function prepareExistingPartInstanceForBeingNexted( context: JobContext, cache: PlayoutModel, - instance: PartInstanceWithPieces -): Promise { + instance: PlayoutPartInstanceModel +): Promise { await syncPlayheadInfinitesForNextPartInstance(context, cache, cache.CurrentPartInstance, instance) return instance @@ -132,9 +132,9 @@ async function prepareExistingPartInstanceForBeingNexted( async function preparePartInstanceForPartBeingNexted( context: JobContext, cache: PlayoutModel, - currentPartInstance: PartInstanceWithPieces | null, + currentPartInstance: PlayoutPartInstanceModel | null, nextPart: ReadonlyDeep -): Promise { +): Promise { const rundown = cache.getRundown(nextPart.rundownId) if (!rundown) throw new Error(`Could not find rundown ${nextPart.rundownId}`) @@ -307,7 +307,7 @@ async function cleanupOrphanedItems(context: JobContext, cache: PlayoutModel) { export async function setNextSegment( context: JobContext, cache: PlayoutModel, - nextSegment: SegmentWithParts | null + nextSegment: PlayoutSegmentModel | null ): Promise { const span = context.startSpan('setNextSegment') if (nextSegment) { diff --git a/packages/job-worker/src/playout/setNextJobs.ts b/packages/job-worker/src/playout/setNextJobs.ts index 9d84dfbaaf5..95543947b6c 100644 --- a/packages/job-worker/src/playout/setNextJobs.ts +++ b/packages/job-worker/src/playout/setNextJobs.ts @@ -8,7 +8,7 @@ import { runJobWithPlayoutCache } from './lock' import { setNextPartFromPart, setNextSegment } from './setNext' import { moveNextPart } from './moveNextPart' import { updateTimeline } from './timeline/generate' -import { SegmentWithParts } from './cacheModel/SegmentWithParts' +import { PlayoutSegmentModel } from './cacheModel/PlayoutSegmentModel' import { ReadonlyDeep } from 'type-fest' /** @@ -87,7 +87,7 @@ export async function handleSetNextSegment(context: JobContext, data: SetNextSeg } }, async (cache) => { - let nextSegment: ReadonlyDeep | null = null + let nextSegment: ReadonlyDeep | null = null if (data.nextSegmentId) { nextSegment = cache.findSegment(data.nextSegmentId) ?? null if (!nextSegment) throw new Error(`Segment "${data.nextSegmentId}" not found!`) diff --git a/packages/job-worker/src/playout/take.ts b/packages/job-worker/src/playout/take.ts index ff9aeb4227e..1d26bd115db 100644 --- a/packages/job-worker/src/playout/take.ts +++ b/packages/job-worker/src/playout/take.ts @@ -9,7 +9,7 @@ import { UserError, UserErrorMessage } from '@sofie-automation/corelib/dist/erro import { logger } from '../logging' import { JobContext, ProcessedShowStyleCompound } from '../jobs' import { PlayoutModel } from './cacheModel/PlayoutModel' -import { PartInstanceWithPieces } from './cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from './cacheModel/PlayoutPartInstanceModel' import { isTooCloseToAutonext } from './lib' import { selectNextPart } from './selectNextPart' import { setNextPart } from './setNext' @@ -365,8 +365,8 @@ export function updatePartInstanceOnTake( showStyle: ReadonlyDeep, blueprint: ReadonlyDeep, takeRundown: ReadonlyDeep, - takePartInstance: PartInstanceWithPieces, - currentPartInstance: PartInstanceWithPieces | null + takePartInstance: PlayoutPartInstanceModel, + currentPartInstance: PlayoutPartInstanceModel | null ): void { // TODO - the state could change after this sampling point. This should be handled properly let previousPartEndState: PartEndState | undefined = undefined @@ -429,7 +429,7 @@ export function updatePartInstanceOnTake( export async function afterTake( context: JobContext, cache: PlayoutModel, - takePartInstance: PartInstanceWithPieces, + takePartInstance: PlayoutPartInstanceModel, timeOffsetIntoPart: number | null = null ): Promise { const span = context.startSpan('afterTake') @@ -462,8 +462,8 @@ export async function afterTake( */ function startHold( context: JobContext, - holdFromPartInstance: PartInstanceWithPieces | null, - holdToPartInstance: PartInstanceWithPieces | undefined + holdFromPartInstance: PlayoutPartInstanceModel | null, + holdToPartInstance: PlayoutPartInstanceModel | undefined ) { if (!holdFromPartInstance) throw new Error('previousPart not found!') if (!holdToPartInstance) throw new Error('currentPart not found!') @@ -493,7 +493,7 @@ async function completeHold( context: JobContext, cache: PlayoutModel, showStyleCompound: ReadonlyDeep, - currentPartInstance: PartInstanceWithPieces | null + currentPartInstance: PlayoutPartInstanceModel | null ): Promise { cache.setHoldState(RundownHoldState.COMPLETE) diff --git a/packages/job-worker/src/playout/timeline/generate.ts b/packages/job-worker/src/playout/timeline/generate.ts index 740285b9588..7d4c98d52a0 100644 --- a/packages/job-worker/src/playout/timeline/generate.ts +++ b/packages/job-worker/src/playout/timeline/generate.ts @@ -52,7 +52,7 @@ import { } from '@sofie-automation/corelib/dist/playout/timings' import { applyAbPlaybackForTimeline } from '../abPlayback' import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError' -import { PartInstanceWithPieces } from '../cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../cacheModel/PlayoutPartInstanceModel' function isCacheForStudio(cache: StudioPlayoutModelBase): cache is StudioPlayoutModel { const tmp = cache as StudioPlayoutModel @@ -269,7 +269,7 @@ export interface SelectedPartInstanceTimelineInfo { function getPartInstanceTimelineInfo( currentTime: Time, sourceLayers: SourceLayers, - partInstance: PartInstanceWithPieces | null + partInstance: PlayoutPartInstanceModel | null ): SelectedPartInstanceTimelineInfo | undefined { if (partInstance) { const partStarted = partInstance.PartInstance.timings?.plannedStartedPlayback diff --git a/packages/job-worker/src/playout/timeline/multi-gateway.ts b/packages/job-worker/src/playout/timeline/multi-gateway.ts index d66f0dfb8da..b7bff3902af 100644 --- a/packages/job-worker/src/playout/timeline/multi-gateway.ts +++ b/packages/job-worker/src/playout/timeline/multi-gateway.ts @@ -12,7 +12,7 @@ import { PlayoutModel } from '../cacheModel/PlayoutModel' import { RundownTimelineTimingContext, getInfinitePartGroupId } from './rundown' import { getExpectedLatency } from '@sofie-automation/corelib/dist/studio/playout' import { getPieceControlObjectId } from '@sofie-automation/corelib/dist/playout/ids' -import { PartInstanceWithPieces } from '../cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../cacheModel/PlayoutPartInstanceModel' import { ReadonlyDeep } from 'type-fest' /** @@ -93,8 +93,8 @@ function updatePartInstancePlannedTimes( cache: PlayoutModel, targetNowTime: number, timingContext: RundownTimelineTimingContext, - currentPartInstance: PartInstanceWithPieces, - nextPartInstance: PartInstanceWithPieces | null + currentPartInstance: PlayoutPartInstanceModel, + nextPartInstance: PlayoutPartInstanceModel | null ): PartGroupTimings { let currentPartGroupStartTime: number if (!currentPartInstance.PartInstance.timings?.plannedStartedPlayback) { @@ -144,7 +144,7 @@ function updatePartInstancePlannedTimes( function deNowifyCurrentPieces( targetNowTime: number, timingContext: RundownTimelineTimingContext, - currentPartInstance: PartInstanceWithPieces, + currentPartInstance: PlayoutPartInstanceModel, currentPartGroupStartTime: number, timelineObjsMap: Record ) { @@ -200,7 +200,7 @@ function deNowifyCurrentPieces( function updatePlannedTimingsForPieceInstances( cache: PlayoutModel, - currentPartInstance: PartInstanceWithPieces, + currentPartInstance: PlayoutPartInstanceModel, partGroupTimings: PartGroupTimings, timelineObjsMap: Record ) { @@ -239,7 +239,7 @@ function updatePlannedTimingsForPieceInstances( } function setPlannedTimingsOnPieceInstance( - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, pieceInstance: ReadonlyDeep, partPlannedStart: Time, partPlannedEnd: Time | undefined @@ -272,7 +272,7 @@ function setPlannedTimingsOnPieceInstance( function preserveOrTrackInfiniteTimings( existingInfiniteTimings: Map, timelineObjsMap: Record, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, pieceInstance: ReadonlyDeep ): void { if (!pieceInstance.infinite) return diff --git a/packages/job-worker/src/playout/timings/partPlayback.ts b/packages/job-worker/src/playout/timings/partPlayback.ts index 28f791b062c..5abdb98f78c 100644 --- a/packages/job-worker/src/playout/timings/partPlayback.ts +++ b/packages/job-worker/src/playout/timings/partPlayback.ts @@ -2,7 +2,7 @@ import { PartInstanceId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { logger } from '../../logging' import { JobContext } from '../../jobs' import { PlayoutModel } from '../cacheModel/PlayoutModel' -import { PartInstanceWithPieces } from '../cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../cacheModel/PlayoutPartInstanceModel' import { selectNextPart } from '../selectNextPart' import { setNextPart } from '../setNext' import { updateTimeline } from '../timeline/generate' @@ -171,7 +171,7 @@ export function onPartPlaybackStopped( export function reportPartInstanceHasStarted( _context: JobContext, cache: PlayoutModel, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, timestamp: Time ): void { if (partInstance) { @@ -207,7 +207,7 @@ export function reportPartInstanceHasStarted( export function reportPartInstanceHasStopped( _context: JobContext, cache: PlayoutModel, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, timestamp: Time ): void { const timestampUpdated = partInstance.setReportedStoppedPlayback(timestamp) diff --git a/packages/job-worker/src/playout/timings/piecePlayback.ts b/packages/job-worker/src/playout/timings/piecePlayback.ts index 6bf906ca224..78587bdd1d2 100644 --- a/packages/job-worker/src/playout/timings/piecePlayback.ts +++ b/packages/job-worker/src/playout/timings/piecePlayback.ts @@ -4,7 +4,7 @@ import { JobContext } from '../../jobs' import { PlayoutModel } from '../cacheModel/PlayoutModel' import { Time } from '@sofie-automation/blueprints-integration' import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance' -import { PartInstanceWithPieces } from '../cacheModel/PartInstanceWithPieces' +import { PlayoutPartInstanceModel } from '../cacheModel/PlayoutPartInstanceModel' import { ReadonlyDeep } from 'type-fest' /** @@ -112,7 +112,7 @@ export function onPiecePlaybackStopped( function reportPieceHasStarted( _context: JobContext, cache: PlayoutModel, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, pieceInstance: ReadonlyDeep, timestamp: Time ): void { @@ -158,7 +158,7 @@ function reportPieceHasStarted( function reportPieceHasStopped( _context: JobContext, cache: PlayoutModel, - partInstance: PartInstanceWithPieces, + partInstance: PlayoutPartInstanceModel, pieceInstance: ReadonlyDeep, timestamp: Time ): void {