Skip to content

Commit 6583046

Browse files
committed
feat(lsg): add parts to segments
1 parent ad69190 commit 6583046

6 files changed

Lines changed: 121 additions & 7 deletions

File tree

packages/live-status-gateway-api/api/schemas/extendedActivePlaylist.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $defs:
3636
description: All segments in the playlist
3737
type: array
3838
items:
39-
$ref: 'segments.yaml#/$defs/segment'
39+
$ref: 'segments.yaml#/$defs/extendedSegment'
4040
nextPart:
4141
description: The next Part - if empty, no part will follow live part
4242
$ref: '#/$defs/part'

packages/live-status-gateway-api/api/schemas/segments.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,56 @@ $defs:
7373
countdownType: segment_budget_duration
7474
publicData:
7575
containsLiveSource: true
76+
extendedSegment:
77+
type: object
78+
title: Extended Segment
79+
properties:
80+
id:
81+
description: Unique id of the segment
82+
type: string
83+
identifier:
84+
description: User-facing identifier that can be used to identify the contents of a segment in the Rundown source system
85+
type: string
86+
rundownId:
87+
description: Unique id of the rundown this segment belongs to
88+
type: string
89+
name:
90+
description: Name of the segment
91+
type: string
92+
parts:
93+
description: Parts belonging to a segment
94+
type: array
95+
items:
96+
$ref: 'activePlaylist.yaml#/$defs/partBase'
97+
timing:
98+
type: object
99+
title: SegmentTiming
100+
properties:
101+
expectedDurationMs:
102+
description: Expected duration of the segment (milliseconds)
103+
type: number
104+
budgetDurationMs:
105+
description: Budget duration of the segment (milliseconds)
106+
type: number
107+
countdownType:
108+
description: 'Countdown type within the segment. Default: `part_expected_duration`'
109+
type: string
110+
title: SegmentCountdownType
111+
enum:
112+
- part_expected_duration
113+
- segment_budget_duration
114+
required: [expectedDurationMs]
115+
publicData:
116+
description: Optional arbitrary data
117+
required: [id, rundownId, name, timing]
118+
additionalProperties: false
119+
examples:
120+
- id: 'OKAgZmZ0Buc99lE_2uPPSKVbMrQ_'
121+
rundownId: 'y9HauyWkcxQS3XaAOsW40BRLLsI_'
122+
name: 'Segment 0'
123+
timing:
124+
expectedDurationMs: 15000
125+
budgetDurationMs: 20000
126+
countdownType: segment_budget_duration
127+
publicData:
128+
containsLiveSource: true

packages/live-status-gateway-api/src/generated/schema.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ interface ExtendedActivePlaylistEvent {
440440
/**
441441
* All segments in the playlist
442442
*/
443-
segments?: Segment[]
443+
segments?: ExtendedSegment[]
444444
nextPart: PartStatus | null
445445
/**
446446
* Optional arbitrary data
@@ -456,7 +456,7 @@ interface ExtendedActivePlaylistEvent {
456456
quickLoop?: ActivePlaylistQuickLoop
457457
}
458458

459-
interface Segment {
459+
interface ExtendedSegment {
460460
/**
461461
* Unique id of the segment
462462
*/
@@ -473,6 +473,10 @@ interface Segment {
473473
* Name of the segment
474474
*/
475475
name: string
476+
/**
477+
* Parts belonging to a segment
478+
*/
479+
parts?: PartStatus[]
476480
timing: SegmentTiming
477481
/**
478482
* Optional arbitrary data
@@ -520,6 +524,30 @@ interface SegmentsEvent {
520524
segments: Segment[]
521525
}
522526

527+
interface Segment {
528+
/**
529+
* Unique id of the segment
530+
*/
531+
id: string
532+
/**
533+
* User-facing identifier that can be used to identify the contents of a segment in the Rundown source system
534+
*/
535+
identifier?: string
536+
/**
537+
* Unique id of the rundown this segment belongs to
538+
*/
539+
rundownId: string
540+
/**
541+
* Name of the segment
542+
*/
543+
name: string
544+
timing: SegmentTiming
545+
/**
546+
* Optional arbitrary data
547+
*/
548+
publicData?: any
549+
}
550+
523551
interface AdLibsEvent {
524552
event: 'adLibs'
525553
/**
@@ -795,10 +823,11 @@ export {
795823
QuickLoopMarker,
796824
QuickLoopMarkerType,
797825
ExtendedActivePlaylistEvent,
798-
Segment,
826+
ExtendedSegment,
799827
SegmentTiming,
800828
ActivePiecesEvent,
801829
SegmentsEvent,
830+
Segment,
802831
AdLibsEvent,
803832
AdLibStatus,
804833
AdLibActionType,

packages/live-status-gateway/src/topics/helpers/part/partStatus.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,22 @@ export function toPartStatus(
3434

3535
return literal<PartStatus>(base)
3636
}
37+
38+
export function toExtendedPartStatus(
39+
{ pieceInstancesInCurrentPartInstance, showStyleBaseExt }: PlaylistStatusCache,
40+
part: DBPart | null
41+
): PartStatus | null {
42+
if (!part) return null
43+
44+
const base = {
45+
id: unprotectString(part._id),
46+
name: part.title,
47+
autoNext: part.autoNext,
48+
segmentId: unprotectString(part.segmentId),
49+
// TODO: fix pieces
50+
pieces: (pieceInstancesInCurrentPartInstance ?? []).map((piece) => toPieceStatus(piece, showStyleBaseExt)),
51+
publicData: part.publicData,
52+
}
53+
54+
return literal<PartStatus>(base)
55+
}

packages/live-status-gateway/src/topics/helpers/playlist/extendedPlaylistStatus.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
55
import { PlaylistStatusCache } from './playlistStatus.js'
66
import { toPlaylistTiming } from './timing.js'
77
import { transformQuickLoopStatus } from './quickLoop.js'
8-
import { toCurrentSegmentStatus, toSegmentStatus } from '../segment/segmentStatus.js'
8+
import { toCurrentSegmentStatus, toExtendedSegmentStatus } from '../segment/segmentStatus.js'
99
import { toCurrentPartStatus, toPartStatus } from '../part/partStatus.js'
1010

1111
export function toExtendedPlaylistStatus(props: PlaylistStatusCache): ExtendedActivePlaylistEvent {
@@ -29,7 +29,7 @@ export function toExtendedPlaylistStatus(props: PlaylistStatusCache): ExtendedAc
2929
// TODO: add all fields to this object, then add parts to it.
3030
segments: segmentsById
3131
? Object.entries<DBSegment | undefined>(segmentsById)
32-
.map(([_id, segment]) => (segment ? toSegmentStatus(props, segment) : null))
32+
.map(([_id, segment]) => (segment ? toExtendedSegmentStatus(props, segment) : null))
3333
.filter((segment) => segment !== null)
3434
: [],
3535
nextPart: toPartStatus(props, nextPart),

packages/live-status-gateway/src/topics/helpers/segment/segmentStatus.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
2-
import { CurrentSegment, Segment as SegmentStatus } from '@sofie-automation/live-status-gateway-api'
2+
import { CurrentSegment, ExtendedSegment, Segment as SegmentStatus } from '@sofie-automation/live-status-gateway-api'
33
import { literal, unprotectString } from '@sofie-automation/server-core-integration'
44
import { getCurrentSegmentParts } from '../segmentParts.js'
55
import { calculateCurrentSegmentTiming, calculateSegmentTiming } from '../segmentTiming.js'
66
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
77
import { PlaylistStatusCache } from '../playlist/playlistStatus.js'
8+
import { toPartStatus } from '../part/partStatus.js'
89

910
export function toCurrentSegmentStatus(
1011
{
@@ -33,6 +34,18 @@ export function toCurrentSegmentStatus(
3334
}
3435

3536
// TODO: use proper types here
37+
export function toExtendedSegmentStatus(cache: PlaylistStatusCache, segment: DBSegment): ExtendedSegment | null {
38+
const { partsBySegmentId } = cache
39+
const segmentId = unprotectString(segment._id)
40+
const segmentStatus = toSegmentStatus(cache, segment)
41+
if (!segmentStatus) return null
42+
43+
return {
44+
...segmentStatus,
45+
parts: partsBySegmentId[segmentId].map((part) => toPartStatus(cache, part)).filter((part) => part !== null),
46+
}
47+
}
48+
3649
export function toSegmentStatus({ partsBySegmentId }: PlaylistStatusCache, segment: DBSegment): SegmentStatus | null {
3750
const segmentId = unprotectString(segment._id)
3851
return {

0 commit comments

Comments
 (0)