@@ -30,6 +30,7 @@ import { CommonContext } from '../blueprints/context/index.js'
3030import { JobContext } from '../jobs/index.js'
3131import { FixUpBlueprintConfigContext } from '@sofie-automation/corelib/dist/fixUpBlueprintConfig/context'
3232import { DEFAULT_MINIMUM_TAKE_SPAN } from '@sofie-automation/shared-lib/dist/core/constants'
33+ import { PERIPHERAL_SUBTYPE_PROCESS , PeripheralDevice } from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice'
3334
3435/**
3536 * Run the Blueprint applyConfig for the studio
@@ -58,37 +59,60 @@ export async function handleBlueprintUpgradeForStudio(context: JobContext, _data
5859 dev [ 0 ] ,
5960 literal < Complete < StudioDeviceSettings > > ( {
6061 name : dev [ 1 ] . name ?? '' ,
61- options : dev [ 1 ] ,
62+ options : dev [ 1 ] . options ?? { } ,
6263 } ) ,
6364 ] )
6465 )
66+
67+ const peripheralDevices = ( await context . directCollections . PeripheralDevices . findFetch (
68+ { subType : PERIPHERAL_SUBTYPE_PROCESS , 'studioAndConfigId.studioId' : context . studioId } ,
69+ { projection : { _id : 1 , studioAndConfigId : 1 } }
70+ ) ) as Array < Pick < PeripheralDevice , '_id' | 'studioAndConfigId' > >
71+
6572 const playoutDevices = Object . fromEntries (
66- Object . entries < TSR . DeviceOptionsAny > ( result . playoutDevices ?? { } ) . map ( ( dev ) => [
67- dev [ 0 ] ,
68- literal < Complete < StudioPlayoutDevice > > ( {
69- peripheralDeviceId : undefined ,
70- options : dev [ 1 ] ,
71- } ) ,
72- ] )
73+ Object . entries < { parentDeviceName ?: string ; options : TSR . DeviceOptionsAny } > ( result . playoutDevices ?? { } ) . map (
74+ ( dev ) => {
75+ return [
76+ dev [ 0 ] ,
77+ literal < Complete < StudioPlayoutDevice > > ( {
78+ peripheralDeviceId : peripheralDevices . find (
79+ ( p ) => p . studioAndConfigId ?. configId === dev [ 1 ] . parentDeviceName
80+ ) ?. _id ,
81+ options : dev [ 1 ] . options ,
82+ } ) ,
83+ ]
84+ }
85+ )
7386 )
87+
7488 const ingestDevices = Object . fromEntries (
75- Object . entries < unknown > ( result . ingestDevices ?? { } ) . map ( ( dev ) => [
76- dev [ 0 ] ,
77- literal < Complete < StudioIngestDevice > > ( {
78- peripheralDeviceId : undefined ,
79- options : dev [ 1 ] ,
80- } ) ,
81- ] )
89+ Object . entries < { parentDeviceName ?: string ; options : unknown } > ( result . ingestDevices ?? { } ) . map ( ( dev ) => {
90+ return [
91+ dev [ 0 ] ,
92+ literal < Complete < StudioIngestDevice > > ( {
93+ peripheralDeviceId : peripheralDevices . find (
94+ ( p ) => p . studioAndConfigId ?. configId === dev [ 1 ] . parentDeviceName
95+ ) ?. _id ,
96+ options : dev [ 1 ] . options ,
97+ } ) ,
98+ ]
99+ } )
82100 )
101+
83102 const inputDevices = Object . fromEntries (
84- Object . entries < unknown > ( result . inputDevices ?? { } ) . map ( ( dev ) => [
85- dev [ 0 ] ,
86- literal < Complete < StudioInputDevice > > ( {
87- peripheralDeviceId : undefined ,
88- options : dev [ 1 ] ,
89- } ) ,
90- ] )
103+ Object . entries < { parentDeviceName ?: string ; options : unknown } > ( result . inputDevices ?? { } ) . map ( ( dev ) => {
104+ return [
105+ dev [ 0 ] ,
106+ literal < Complete < StudioInputDevice > > ( {
107+ peripheralDeviceId : peripheralDevices . find (
108+ ( p ) => p . studioAndConfigId ?. configId === dev [ 1 ] . parentDeviceName
109+ ) ?. _id ,
110+ options : dev [ 1 ] . options ,
111+ } ) ,
112+ ]
113+ } )
91114 )
115+
92116 const routeSets = Object . fromEntries (
93117 Object . entries < Partial < StudioRouteSet > > ( result . routeSets ?? { } ) . map ( ( dev ) => [
94118 dev [ 0 ] ,
0 commit comments