Skip to content

Commit 9cd54fe

Browse files
committed
feat: configure peripheral device settings from blueprints
1 parent daf776f commit 9cd54fe

File tree

60 files changed

+1134
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1134
-507
lines changed

meteor/__mocks__/defaultCollectionObjects.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export function defaultStudio(_id: StudioId): DBStudio {
118118
previewContainerIds: [],
119119
thumbnailContainerIds: [],
120120
peripheralDeviceSettings: {
121+
deviceSettings: wrapDefaultObject({}),
121122
playoutDevices: wrapDefaultObject({}),
122123
ingestDevices: wrapDefaultObject({}),
123124
inputDevices: wrapDefaultObject({}),

meteor/__mocks__/helpers/database.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ export async function setupMockPeripheralDevice(
127127
_id: protectString('mockDevice' + dbI++),
128128
name: 'mockDevice',
129129
organizationId: null,
130-
studioId: studio ? studio._id : undefined,
131-
settings: {},
130+
studioAndConfigId: studio ? { studioId: studio._id, configId: 'test' } : undefined,
132131

133132
category: category,
134133
type: type,

meteor/server/__tests__/cronjobs.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ describe('cronjobs', () => {
436436
statusCode: StatusCode.GOOD,
437437
},
438438
token: '',
439-
settings: {},
440439
...props,
441440
})
442441

meteor/server/api/__tests__/peripheralDevice.test.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import { getCurrentTime } from '../../lib/lib'
1111
import { waitUntil } from '../../../__mocks__/helpers/jest'
1212
import { setupDefaultStudioEnvironment, DefaultEnvironment } from '../../../__mocks__/helpers/database'
1313
import { setLogLevel } from '../../logging'
14-
import {
15-
IngestDeviceSettings,
16-
IngestDeviceSecretSettings,
17-
} from '@sofie-automation/corelib/dist/dataModel/PeripheralDeviceSettings/ingestDevice'
14+
import { IngestDeviceSecretSettings } from '@sofie-automation/corelib/dist/dataModel/PeripheralDeviceSettings/ingestDevice'
1815
import { MediaWorkFlow } from '@sofie-automation/shared-lib/dist/core/model/MediaWorkFlows'
1916
import { MediaWorkFlowStep } from '@sofie-automation/shared-lib/dist/core/model/MediaWorkFlowSteps'
2017
import { MediaManagerAPI } from '@sofie-automation/meteor-lib/dist/api/mediaManager'
@@ -415,7 +412,7 @@ describe('test peripheralDevice general API methods', () => {
415412
expect(QueueStudioJobSpy).toHaveBeenNthCalledWith(
416413
1,
417414
StudioJobs.OnPlayoutPlaybackChanged,
418-
device.studioId,
415+
device.studioAndConfigId!.studioId,
419416
literal<Parameters<StudioJobFunc[StudioJobs.OnPlayoutPlaybackChanged]>[0]>({
420417
playlistId: rundownPlaylistID,
421418
changes: [
@@ -477,7 +474,7 @@ describe('test peripheralDevice general API methods', () => {
477474
expect(QueueStudioJobSpy).toHaveBeenNthCalledWith(
478475
1,
479476
StudioJobs.OnTimelineTriggerTime,
480-
device.studioId,
477+
device.studioAndConfigId!.studioId,
481478
literal<OnTimelineTriggerTimeProps>({
482479
results: timelineTriggerTimeResult,
483480
})
@@ -559,7 +556,7 @@ describe('test peripheralDevice general API methods', () => {
559556
expect((deviceWithSecretToken.secretSettings as IngestDeviceSecretSettings).accessToken).toBe(
560557
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
561558
)
562-
expect((deviceWithSecretToken.settings as IngestDeviceSettings).secretAccessToken).toBe(true)
559+
expect(deviceWithSecretToken.secretSettingsStatus?.accessToken).toBe(true)
563560
})
564561

565562
test('uninitialize', async () => {
@@ -646,8 +643,10 @@ describe('test peripheralDevice general API methods', () => {
646643
organizationId: null,
647644
name: 'Mock Media Manager',
648645
deviceName: 'Media Manager',
649-
studioId: env.studio._id,
650-
settings: {},
646+
studioAndConfigId: {
647+
studioId: env.studio._id,
648+
configId: 'test',
649+
},
651650
category: PeripheralDeviceCategory.MEDIA_MANAGER,
652651
configManifest: {
653652
deviceConfigSchema: JSONBlobStringify({}),
@@ -673,7 +672,7 @@ describe('test peripheralDevice general API methods', () => {
673672
deviceId: device._id,
674673
priority: 1,
675674
source: 'MockSource',
676-
studioId: device.studioId!,
675+
studioId: device.studioAndConfigId!.studioId,
677676
finished: false,
678677
success: false,
679678
})
@@ -685,7 +684,7 @@ describe('test peripheralDevice general API methods', () => {
685684
deviceId: device._id,
686685
priority: 2,
687686
status: MediaManagerAPI.WorkStepStatus.IDLE,
688-
studioId: device.studioId!,
687+
studioId: device.studioAndConfigId!.studioId,
689688
workFlowId: workFlowId,
690689
})
691690
await MediaWorkFlowSteps.insertAsync({
@@ -696,14 +695,14 @@ describe('test peripheralDevice general API methods', () => {
696695
deviceId: device._id,
697696
priority: 1,
698697
status: MediaManagerAPI.WorkStepStatus.IDLE,
699-
studioId: device.studioId!,
698+
studioId: device.studioAndConfigId!.studioId,
700699
workFlowId: workFlowId,
701700
})
702701
})
703702
test('getMediaWorkFlowRevisions', async () => {
704703
const workFlows = (
705704
await MediaWorkFlows.findFetchAsync({
706-
studioId: device.studioId,
705+
studioId: device.studioAndConfigId!.studioId,
707706
})
708707
).map((wf) => ({
709708
_id: wf._id,
@@ -717,7 +716,7 @@ describe('test peripheralDevice general API methods', () => {
717716
test('getMediaWorkFlowStepRevisions', async () => {
718717
const workFlowSteps = (
719718
await MediaWorkFlowSteps.findFetchAsync({
720-
studioId: device.studioId,
719+
studioId: device.studioAndConfigId!.studioId,
721720
})
722721
).map((wf) => ({
723722
_id: wf._id,
@@ -802,8 +801,10 @@ describe('test peripheralDevice general API methods', () => {
802801
organizationId: null,
803802
name: 'Mock Media Manager',
804803
deviceName: 'Media Manager',
805-
studioId: env.studio._id,
806-
settings: {},
804+
studioAndConfigId: {
805+
studioId: env.studio._id,
806+
configId: 'test',
807+
},
807808
category: PeripheralDeviceCategory.MEDIA_MANAGER,
808809
configManifest: {
809810
deviceConfigSchema: JSONBlobStringify({}),
@@ -837,7 +838,7 @@ describe('test peripheralDevice general API methods', () => {
837838
mediaSize: 10,
838839
mediaTime: 0,
839840
objId: MOCK_OBJID,
840-
studioId: device.studioId!,
841+
studioId: device.studioAndConfigId!.studioId,
841842
thumbSize: 0,
842843
thumbTime: 0,
843844
tinf: '',
@@ -846,7 +847,7 @@ describe('test peripheralDevice general API methods', () => {
846847
test('getMediaObjectRevisions', async () => {
847848
const mobjects = (
848849
await MediaObjects.findFetchAsync({
849-
studioId: device.studioId,
850+
studioId: device.studioAndConfigId!.studioId,
850851
})
851852
).map((mo) => ({
852853
_id: mo._id,
@@ -867,7 +868,7 @@ describe('test peripheralDevice general API methods', () => {
867868
test('update', async () => {
868869
const mo = (await MediaObjects.findOneAsync({
869870
collectionId: MOCK_COLLECTION,
870-
studioId: device.studioId!,
871+
studioId: device.studioAndConfigId!.studioId,
871872
})) as MediaObject
872873
expect(mo).toBeTruthy()
873874

@@ -885,14 +886,14 @@ describe('test peripheralDevice general API methods', () => {
885886

886887
const updateMo = await MediaObjects.findOneAsync({
887888
collectionId: MOCK_COLLECTION,
888-
studioId: device.studioId!,
889+
studioId: device.studioAndConfigId!.studioId,
889890
})
890891
expect(updateMo).toMatchObject(newMo)
891892
})
892893
test('remove', async () => {
893894
const mo = (await MediaObjects.findOneAsync({
894895
collectionId: MOCK_COLLECTION,
895-
studioId: device.studioId!,
896+
studioId: device.studioAndConfigId!.studioId,
896897
})) as MediaObject
897898
expect(mo).toBeTruthy()
898899

@@ -906,7 +907,7 @@ describe('test peripheralDevice general API methods', () => {
906907

907908
const updateMo = await MediaObjects.findOneAsync({
908909
collectionId: MOCK_COLLECTION,
909-
studioId: device.studioId!,
910+
studioId: device.studioAndConfigId!.studioId,
910911
})
911912
expect(updateMo).toBeFalsy()
912913
})

meteor/server/api/__tests__/userActions/system.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ describe('User Actions - Disable Peripheral SubDevice', () => {
4040
env.studio,
4141
{
4242
organizationId,
43-
settings: {},
4443
configManifest: {
4544
deviceConfigSchema: JSONBlobStringify({}), // unused
4645
subdeviceManifest: {
@@ -165,7 +164,6 @@ describe('User Actions - Disable Peripheral SubDevice', () => {
165164
env.studio,
166165
{
167166
organizationId: null,
168-
settings: {},
169167
configManifest: {
170168
deviceConfigSchema: JSONBlobStringify({}), // unused
171169
subdeviceManifest: {

meteor/server/api/deviceTriggers/observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export async function receiveInputDeviceTrigger(
102102
check(deviceId, String)
103103
check(triggerId, String)
104104

105-
const studioId = peripheralDevice.studioId
105+
const studioId = peripheralDevice.studioAndConfigId?.studioId
106106
if (!studioId) throw new Meteor.Error(400, `Peripheral Device "${peripheralDevice._id}" not assigned to a studio`)
107107

108108
logger.debug(

meteor/server/api/integration/expectedPackages.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
PackageInfos,
3333
} from '../../collections'
3434
import { logger } from '../../logging'
35+
import _ from 'underscore'
3536

3637
export namespace PackageManagerIntegration {
3738
export async function updateExpectedPackageWorkStatuses(
@@ -58,7 +59,7 @@ export namespace PackageManagerIntegration {
5859
type FromPackage = Omit<ExpectedPackageStatusAPI.WorkBaseInfoFromPackage, 'id'> & { id: ExpectedPackageId }
5960

6061
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
61-
if (!peripheralDevice.studioId)
62+
if (!peripheralDevice.studioAndConfigId)
6263
throw new Meteor.Error(400, 'Device "' + peripheralDevice._id + '" has no studio')
6364

6465
const bulkChanges: AnyBulkWriteOperation<ExpectedPackageWorkStatus>[] = []
@@ -150,11 +151,11 @@ export namespace PackageManagerIntegration {
150151
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
151152

152153
await ExpectedPackageWorkStatuses.removeAsync({
153-
$or: [
154+
$or: _.compact([
154155
{ deviceId: peripheralDevice._id },
155156
// Since we only have one PM in a studio, we can remove everything in the studio:
156-
{ studioId: peripheralDevice.studioId },
157-
],
157+
peripheralDevice.studioAndConfigId ? { studioId: peripheralDevice.studioAndConfigId.studioId } : null,
158+
]),
158159
})
159160
}
160161

@@ -177,10 +178,10 @@ export namespace PackageManagerIntegration {
177178
)[]
178179
): Promise<void> {
179180
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
180-
if (!peripheralDevice.studioId)
181+
if (!peripheralDevice.studioAndConfigId)
181182
throw new Meteor.Error(400, 'Device "' + peripheralDevice._id + '" has no studio')
182183

183-
const studioId = peripheralDevice.studioId
184+
const studioId = peripheralDevice.studioAndConfigId.studioId
184185

185186
const removedIds: PackageContainerPackageId[] = []
186187
const ps: Promise<unknown>[] = []
@@ -189,7 +190,7 @@ export namespace PackageManagerIntegration {
189190
check(change.packageId, String)
190191

191192
const id = getPackageContainerPackageId(
192-
peripheralDevice.studioId,
193+
peripheralDevice.studioAndConfigId.studioId,
193194
change.containerId,
194195
protectString(change.packageId)
195196
)
@@ -245,11 +246,11 @@ export namespace PackageManagerIntegration {
245246
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
246247

247248
await PackageContainerPackageStatuses.removeAsync({
248-
$or: [
249+
$or: _.compact([
249250
{ deviceId: peripheralDevice._id },
250251
// Since we only have one PM in a studio, we can remove everything in the studio:
251-
{ studioId: peripheralDevice.studioId },
252-
],
252+
peripheralDevice.studioAndConfigId ? { studioId: peripheralDevice.studioAndConfigId.studioId } : null,
253+
]),
253254
})
254255
}
255256

@@ -270,17 +271,17 @@ export namespace PackageManagerIntegration {
270271
)[]
271272
): Promise<void> {
272273
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
273-
if (!peripheralDevice.studioId)
274+
if (!peripheralDevice.studioAndConfigId)
274275
throw new Meteor.Error(400, 'Device "' + peripheralDevice._id + '" has no studio')
275276

276-
const studioId = peripheralDevice.studioId
277+
const studioId = peripheralDevice.studioAndConfigId.studioId
277278

278279
const removedIds: PackageContainerId[] = []
279280
const ps: Promise<unknown>[] = []
280281
for (const change of changes) {
281282
check(change.containerId, String)
282283

283-
const id = getPackageContainerId(peripheralDevice.studioId, change.containerId)
284+
const id = getPackageContainerId(peripheralDevice.studioAndConfigId.studioId, change.containerId)
284285

285286
if (change.type === 'delete') {
286287
removedIds.push(id)
@@ -332,11 +333,11 @@ export namespace PackageManagerIntegration {
332333
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
333334

334335
await PackageContainerStatuses.removeAsync({
335-
$or: [
336+
$or: _.compact([
336337
{ deviceId: peripheralDevice._id },
337338
// Since we only have one PM in a studio, we can remove everything in the studio:
338-
{ studioId: peripheralDevice.studioId },
339-
],
339+
peripheralDevice.studioAndConfigId ? { studioId: peripheralDevice.studioAndConfigId.studioId } : null,
340+
]),
340341
})
341342
}
342343

@@ -352,7 +353,7 @@ export namespace PackageManagerIntegration {
352353
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
353354
check(packageIds, [String])
354355
check(type, String)
355-
if (!peripheralDevice.studioId)
356+
if (!peripheralDevice.studioAndConfigId)
356357
throw new Meteor.Error(400, 'Device "' + peripheralDevice._id + '" has no studio')
357358

358359
const ids = packageIds.map((packageId) => getPackageInfoId(packageId, type))
@@ -386,7 +387,7 @@ export namespace PackageManagerIntegration {
386387
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
387388
check(packageId, String)
388389
check(type, String)
389-
if (!peripheralDevice.studioId)
390+
if (!peripheralDevice.studioAndConfigId)
390391
throw new Meteor.Error(400, 'Device "' + peripheralDevice._id + '" has no studio')
391392

392393
const id = getPackageInfoId(packageId, type)
@@ -398,7 +399,7 @@ export namespace PackageManagerIntegration {
398399
expectedContentVersionHash: expectedContentVersionHash,
399400
actualContentVersionHash: actualContentVersionHash,
400401

401-
studioId: peripheralDevice.studioId,
402+
studioId: peripheralDevice.studioAndConfigId.studioId,
402403

403404
deviceId: peripheralDevice._id,
404405

@@ -425,7 +426,7 @@ export namespace PackageManagerIntegration {
425426
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
426427
check(packageId, String)
427428
check(type, String)
428-
if (!peripheralDevice.studioId)
429+
if (!peripheralDevice.studioAndConfigId)
429430
throw new Meteor.Error(400, 'Device "' + peripheralDevice._id + '" has no studio')
430431

431432
const id = getPackageInfoId(packageId, type)

0 commit comments

Comments
 (0)