@@ -13,7 +13,13 @@ import {
1313import { logger } from '../../logging'
1414import { resolveCredentials } from '../../security/lib/credentials'
1515import { NoSecurityReadAccess } from '../../security/noSecurity'
16- import { ContentCache , createReactiveContentCache , ShowStyleBaseFields , StudioFields } from './reactiveContentCache'
16+ import {
17+ ContentCache ,
18+ CoreSystemFields ,
19+ createReactiveContentCache ,
20+ ShowStyleBaseFields ,
21+ StudioFields ,
22+ } from './reactiveContentCache'
1723import { UpgradesContentObserver } from './upgradesContentObserver'
1824import { BlueprintMapEntry , checkDocUpgradeStatus } from './checkStatus'
1925import { BlueprintManifestType } from '@sofie-automation/blueprints-integration'
@@ -23,6 +29,7 @@ import {
2329 UIBlueprintUpgradeStatus ,
2430 UIBlueprintUpgradeStatusId ,
2531} from '@sofie-automation/meteor-lib/dist/api/upgradeStatus'
32+ import { ICoreSystem } from '@sofie-automation/meteor-lib/dist/collections/CoreSystem'
2633
2734type BlueprintUpgradeStatusArgs = Record < string , never >
2835
@@ -33,6 +40,7 @@ export interface BlueprintUpgradeStatusState {
3340interface BlueprintUpgradeStatusUpdateProps {
3441 newCache : ContentCache
3542
43+ invalidateSystem : boolean
3644 invalidateStudioIds : StudioId [ ]
3745 invalidateShowStyleBaseIds : ShowStyleBaseId [ ]
3846 invalidateBlueprintIds : BlueprintId [ ]
@@ -54,6 +62,11 @@ async function setupBlueprintUpgradeStatusPublicationObservers(
5462 return [
5563 mongoObserver ,
5664
65+ cache . CoreSystem . find ( { } ) . observeChanges ( {
66+ added : ( ) => triggerUpdate ( { invalidateSystem : true } ) ,
67+ changed : ( ) => triggerUpdate ( { invalidateSystem : true } ) ,
68+ removed : ( ) => triggerUpdate ( { invalidateSystem : true } ) ,
69+ } ) ,
5770 cache . Studios . find ( { } ) . observeChanges ( {
5871 added : ( id ) => triggerUpdate ( { invalidateStudioIds : [ protectString ( id ) ] } ) ,
5972 changed : ( id ) => triggerUpdate ( { invalidateStudioIds : [ protectString ( id ) ] } ) ,
@@ -72,7 +85,10 @@ async function setupBlueprintUpgradeStatusPublicationObservers(
7285 ]
7386}
7487
75- function getDocumentId ( type : 'studio' | 'showStyle' , id : ProtectedString < any > ) : UIBlueprintUpgradeStatusId {
88+ function getDocumentId (
89+ type : 'coreSystem' | 'studio' | 'showStyle' ,
90+ id : ProtectedString < any >
91+ ) : UIBlueprintUpgradeStatusId {
7692 return protectString ( `${ type } :${ id } ` )
7793}
7894
@@ -100,6 +116,7 @@ export async function manipulateBlueprintUpgradeStatusPublicationData(
100116
101117 const studioBlueprintsMap = new Map < BlueprintId , BlueprintMapEntry > ( )
102118 const showStyleBlueprintsMap = new Map < BlueprintId , BlueprintMapEntry > ( )
119+ const systemBlueprintsMap = new Map < BlueprintId , BlueprintMapEntry > ( )
103120 state . contentCache . Blueprints . find ( { } ) . forEach ( ( blueprint ) => {
104121 switch ( blueprint . blueprintType ) {
105122 case BlueprintManifestType . SHOWSTYLE :
@@ -120,6 +137,15 @@ export async function manipulateBlueprintUpgradeStatusPublicationData(
120137 hasFixUpFunction : blueprint . hasFixUpFunction ,
121138 } )
122139 break
140+ case BlueprintManifestType . SYSTEM :
141+ systemBlueprintsMap . set ( blueprint . _id , {
142+ _id : blueprint . _id ,
143+ configPresets : { } ,
144+ configSchema : undefined , // TODO
145+ blueprintHash : blueprint . blueprintHash ,
146+ hasFixUpFunction : false ,
147+ } )
148+ break
123149 // TODO - default?
124150 }
125151 } )
@@ -136,6 +162,10 @@ export async function manipulateBlueprintUpgradeStatusPublicationData(
136162 state . contentCache . ShowStyleBases . find ( { } ) . forEach ( ( showStyleBase ) => {
137163 updateShowStyleUpgradeStatus ( collection , showStyleBlueprintsMap , showStyleBase )
138164 } )
165+
166+ state . contentCache . CoreSystem . find ( { } ) . forEach ( ( coreSystem ) => {
167+ updateCoreSystemUpgradeStatus ( collection , systemBlueprintsMap , coreSystem )
168+ } )
139169 } else {
140170 const regenerateForStudioIds = new Set ( updateProps . invalidateStudioIds )
141171 const regenerateForShowStyleBaseIds = new Set ( updateProps . invalidateShowStyleBaseIds )
@@ -181,9 +211,31 @@ export async function manipulateBlueprintUpgradeStatusPublicationData(
181211 collection . remove ( getDocumentId ( 'showStyle' , showStyleBaseId ) )
182212 }
183213 }
214+
215+ if ( updateProps . invalidateSystem ) {
216+ state . contentCache . CoreSystem . find ( { } ) . forEach ( ( coreSystem ) => {
217+ updateCoreSystemUpgradeStatus ( collection , systemBlueprintsMap , coreSystem )
218+ } )
219+ }
184220 }
185221}
186222
223+ function updateCoreSystemUpgradeStatus (
224+ collection : CustomPublishCollection < UIBlueprintUpgradeStatus > ,
225+ blueprintsMap : Map < BlueprintId , BlueprintMapEntry > ,
226+ coreSystem : Pick < ICoreSystem , CoreSystemFields >
227+ ) {
228+ const status = checkDocUpgradeStatus ( blueprintsMap , coreSystem )
229+
230+ collection . replace ( {
231+ ...status ,
232+ _id : getDocumentId ( 'coreSystem' , coreSystem . _id ) ,
233+ documentType : 'coreSystem' ,
234+ documentId : coreSystem . _id ,
235+ name : coreSystem . name ?? 'System' ,
236+ } )
237+ }
238+
187239function updateStudioUpgradeStatus (
188240 collection : CustomPublishCollection < UIBlueprintUpgradeStatus > ,
189241 blueprintsMap : Map < BlueprintId , BlueprintMapEntry > ,
0 commit comments