@@ -30,6 +30,7 @@ import { CommonContext } from '../blueprints/context/index.js'
30
30
import { JobContext } from '../jobs/index.js'
31
31
import { FixUpBlueprintConfigContext } from '@sofie-automation/corelib/dist/fixUpBlueprintConfig/context'
32
32
import { 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'
33
34
34
35
/**
35
36
* Run the Blueprint applyConfig for the studio
@@ -58,37 +59,60 @@ export async function handleBlueprintUpgradeForStudio(context: JobContext, _data
58
59
dev [ 0 ] ,
59
60
literal < Complete < StudioDeviceSettings > > ( {
60
61
name : dev [ 1 ] . name ?? '' ,
61
- options : dev [ 1 ] ,
62
+ options : dev [ 1 ] . options ?? { } ,
62
63
} ) ,
63
64
] )
64
65
)
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
+
65
72
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
+ )
73
86
)
87
+
74
88
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
+ } )
82
100
)
101
+
83
102
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
+ } )
91
114
)
115
+
92
116
const routeSets = Object . fromEntries (
93
117
Object . entries < Partial < StudioRouteSet > > ( result . routeSets ?? { } ) . map ( ( dev ) => [
94
118
dev [ 0 ] ,
0 commit comments