@@ -8,23 +8,27 @@ import type { RundownId } from '@sofie-automation/corelib/dist/dataModel/Ids'
88import type { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
99import type { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
1010
11- export type PlaylistFields = '_id' | 'activationId' | 'rehearsal' | 'currentPartInfo' | 'nextPartInfo'
12- export const playlistFieldSpecifier = literal < MongoFieldSpecifierOnesStrict < Pick < DBRundownPlaylist , PlaylistFields > > > ( {
11+ export type PlaylistCompact = Pick <
12+ DBRundownPlaylist ,
13+ '_id' | 'activationId' | 'rehearsal' | 'currentPartInfo' | 'nextPartInfo'
14+ >
15+ export const playlistFieldSpecifier = literal < MongoFieldSpecifierOnesStrict < PlaylistCompact > > ( {
1316 _id : 1 ,
1417 activationId : 1 ,
1518 rehearsal : 1 ,
1619 currentPartInfo : 1 ,
1720 nextPartInfo : 1 ,
1821} )
1922
20- export type RundownFields = '_id' | 'externalId' | 'playlistId'
21- export const rundownFieldSpecifier = literal < MongoFieldSpecifierOnesStrict < Pick < DBRundown , RundownFields > > > ( {
23+ export type RundownCompact = Pick < DBRundown , '_id' | 'externalId' | 'playlistId' >
24+ export const rundownFieldSpecifier = literal < MongoFieldSpecifierOnesStrict < RundownCompact > > ( {
2225 _id : 1 ,
2326 externalId : 1 ,
2427 playlistId : 1 ,
2528} )
2629
27- export type PartFields =
30+ export type PartCompact = Pick <
31+ DBPart ,
2832 | '_id'
2933 | 'rundownId'
3034 | 'segmentId'
@@ -33,7 +37,8 @@ export type PartFields =
3337 | 'ingestNotifyPartReady'
3438 | 'ingestNotifyItemsReady'
3539 | 'ingestNotifyPartExternalId'
36- export const partFieldSpecifier = literal < MongoFieldSpecifierOnesStrict < Pick < DBPart , PartFields > > > ( {
40+ >
41+ export const partFieldSpecifier = literal < MongoFieldSpecifierOnesStrict < PartCompact > > ( {
3742 _id : 1 ,
3843 rundownId : 1 ,
3944 segmentId : 1 ,
@@ -44,36 +49,50 @@ export const partFieldSpecifier = literal<MongoFieldSpecifierOnesStrict<Pick<DBP
4449 ingestNotifyPartExternalId : 1 ,
4550} )
4651
47- export type PartInstanceFields = '_id' | 'rundownId' | 'segmentId' | 'part' | 'takeCount'
48- export const partInstanceFieldSpecifier = literal <
49- MongoFieldSpecifierOnesStrict < Pick < PartInstance , PartInstanceFields > >
50- > ( {
52+ export type PartInstanceCompact = Pick < PartInstance , '_id' | 'rundownId' | 'segmentId' | 'part' | 'takeCount' >
53+ export const partInstanceFieldSpecifier = literal < MongoFieldSpecifierOnesStrict < PartInstanceCompact > > ( {
5154 _id : 1 ,
5255 rundownId : 1 ,
5356 segmentId : 1 ,
5457 part : 1 , // This could be more granular, but it should be pretty stable
5558 takeCount : 1 ,
5659} )
5760
61+ export type NrcsIngestDataCacheObjCompact = Pick <
62+ NrcsIngestDataCacheObj ,
63+ '_id' | 'type' | 'rundownId' | 'segmentId' | 'partId'
64+ > & { data : { externalId : string } }
65+ export const nrcsIngestDataCacheObjSpecifier = literal < MongoFieldSpecifierOnesStrict < NrcsIngestDataCacheObjCompact > > ( {
66+ _id : 1 ,
67+ type : 1 ,
68+ rundownId : 1 ,
69+ segmentId : 1 ,
70+ partId : 1 ,
71+ data : {
72+ // We need to be very selective here, as the payload portion could contain data not safe for minimongo
73+ externalId : 1 ,
74+ } ,
75+ } )
76+
5877export interface ContentCache {
5978 RundownIds : RundownId [ ]
6079
61- Playlists : ReactiveCacheCollection < Pick < DBRundownPlaylist , PlaylistFields > >
62- Rundowns : ReactiveCacheCollection < Pick < DBRundown , RundownFields > >
63- NrcsIngestData : ReactiveCacheCollection < NrcsIngestDataCacheObj >
64- Parts : ReactiveCacheCollection < Pick < DBPart , PartFields > >
65- PartInstances : ReactiveCacheCollection < Pick < PartInstance , PartInstanceFields > >
80+ Playlists : ReactiveCacheCollection < PlaylistCompact >
81+ Rundowns : ReactiveCacheCollection < RundownCompact >
82+ NrcsIngestData : ReactiveCacheCollection < NrcsIngestDataCacheObjCompact >
83+ Parts : ReactiveCacheCollection < PartCompact >
84+ PartInstances : ReactiveCacheCollection < PartInstanceCompact >
6685}
6786
6887export function createReactiveContentCache ( rundownIds : RundownId [ ] ) : ContentCache {
6988 const cache : ContentCache = {
7089 RundownIds : rundownIds ,
7190
72- Playlists : new ReactiveCacheCollection < Pick < DBRundownPlaylist , PlaylistFields > > ( 'playlists' ) ,
73- Rundowns : new ReactiveCacheCollection < Pick < DBRundown , RundownFields > > ( 'rundowns' ) ,
74- NrcsIngestData : new ReactiveCacheCollection < NrcsIngestDataCacheObj > ( 'nrcsIngestData' ) , // TODO - is this needed?
75- Parts : new ReactiveCacheCollection < Pick < DBPart , PartFields > > ( 'parts' ) ,
76- PartInstances : new ReactiveCacheCollection < Pick < PartInstance , PartInstanceFields > > ( 'partInstances' ) ,
91+ Playlists : new ReactiveCacheCollection < PlaylistCompact > ( 'playlists' ) ,
92+ Rundowns : new ReactiveCacheCollection < RundownCompact > ( 'rundowns' ) ,
93+ NrcsIngestData : new ReactiveCacheCollection < NrcsIngestDataCacheObjCompact > ( 'nrcsIngestData' ) ,
94+ Parts : new ReactiveCacheCollection < PartCompact > ( 'parts' ) ,
95+ PartInstances : new ReactiveCacheCollection < PartInstanceCompact > ( 'partInstances' ) ,
7796 }
7897
7998 return cache
0 commit comments