Skip to content

Commit f5cfbaf

Browse files
committed
feat: configure peripheral device settings from blueprints
1 parent 6bb0393 commit f5cfbaf

File tree

60 files changed

+1135
-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

+1135
-507
lines changed

meteor/__mocks__/defaultCollectionObjects.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export function defaultStudio(_id: StudioId): DBStudio {
121121
previewContainerIds: [],
122122
thumbnailContainerIds: [],
123123
peripheralDeviceSettings: {
124+
deviceSettings: wrapDefaultObject({}),
124125
playoutDevices: wrapDefaultObject({}),
125126
ingestDevices: wrapDefaultObject({}),
126127
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
@@ -488,7 +488,6 @@ describe('cronjobs', () => {
488488
statusCode: StatusCode.GOOD,
489489
},
490490
token: '',
491-
settings: {},
492491
...props,
493492
})
494493

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'
@@ -412,7 +409,7 @@ describe('test peripheralDevice general API methods', () => {
412409
expect(QueueStudioJobSpy).toHaveBeenNthCalledWith(
413410
1,
414411
StudioJobs.OnPlayoutPlaybackChanged,
415-
device.studioId,
412+
device.studioAndConfigId!.studioId,
416413
literal<Parameters<StudioJobFunc[StudioJobs.OnPlayoutPlaybackChanged]>[0]>({
417414
playlistId: rundownPlaylistID,
418415
changes: [
@@ -474,7 +471,7 @@ describe('test peripheralDevice general API methods', () => {
474471
expect(QueueStudioJobSpy).toHaveBeenNthCalledWith(
475472
1,
476473
StudioJobs.OnTimelineTriggerTime,
477-
device.studioId,
474+
device.studioAndConfigId!.studioId,
478475
literal<OnTimelineTriggerTimeProps>({
479476
results: timelineTriggerTimeResult,
480477
})
@@ -556,7 +553,7 @@ describe('test peripheralDevice general API methods', () => {
556553
expect((deviceWithSecretToken.secretSettings as IngestDeviceSecretSettings).accessToken).toBe(
557554
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
558555
)
559-
expect((deviceWithSecretToken.settings as IngestDeviceSettings).secretAccessToken).toBe(true)
556+
expect(deviceWithSecretToken.secretSettingsStatus?.accessToken).toBe(true)
560557
})
561558

562559
test('uninitialize', async () => {
@@ -643,8 +640,10 @@ describe('test peripheralDevice general API methods', () => {
643640
organizationId: null,
644641
name: 'Mock Media Manager',
645642
deviceName: 'Media Manager',
646-
studioId: env.studio._id,
647-
settings: {},
643+
studioAndConfigId: {
644+
studioId: env.studio._id,
645+
configId: 'test',
646+
},
648647
category: PeripheralDeviceCategory.MEDIA_MANAGER,
649648
configManifest: {
650649
deviceConfigSchema: JSONBlobStringify({}),
@@ -670,7 +669,7 @@ describe('test peripheralDevice general API methods', () => {
670669
deviceId: device._id,
671670
priority: 1,
672671
source: 'MockSource',
673-
studioId: device.studioId!,
672+
studioId: device.studioAndConfigId!.studioId,
674673
finished: false,
675674
success: false,
676675
})
@@ -682,7 +681,7 @@ describe('test peripheralDevice general API methods', () => {
682681
deviceId: device._id,
683682
priority: 2,
684683
status: MediaManagerAPI.WorkStepStatus.IDLE,
685-
studioId: device.studioId!,
684+
studioId: device.studioAndConfigId!.studioId,
686685
workFlowId: workFlowId,
687686
})
688687
await MediaWorkFlowSteps.insertAsync({
@@ -693,14 +692,14 @@ describe('test peripheralDevice general API methods', () => {
693692
deviceId: device._id,
694693
priority: 1,
695694
status: MediaManagerAPI.WorkStepStatus.IDLE,
696-
studioId: device.studioId!,
695+
studioId: device.studioAndConfigId!.studioId,
697696
workFlowId: workFlowId,
698697
})
699698
})
700699
test('getMediaWorkFlowRevisions', async () => {
701700
const workFlows = (
702701
await MediaWorkFlows.findFetchAsync({
703-
studioId: device.studioId,
702+
studioId: device.studioAndConfigId!.studioId,
704703
})
705704
).map((wf) => ({
706705
_id: wf._id,
@@ -714,7 +713,7 @@ describe('test peripheralDevice general API methods', () => {
714713
test('getMediaWorkFlowStepRevisions', async () => {
715714
const workFlowSteps = (
716715
await MediaWorkFlowSteps.findFetchAsync({
717-
studioId: device.studioId,
716+
studioId: device.studioAndConfigId!.studioId,
718717
})
719718
).map((wf) => ({
720719
_id: wf._id,
@@ -799,8 +798,10 @@ describe('test peripheralDevice general API methods', () => {
799798
organizationId: null,
800799
name: 'Mock Media Manager',
801800
deviceName: 'Media Manager',
802-
studioId: env.studio._id,
803-
settings: {},
801+
studioAndConfigId: {
802+
studioId: env.studio._id,
803+
configId: 'test',
804+
},
804805
category: PeripheralDeviceCategory.MEDIA_MANAGER,
805806
configManifest: {
806807
deviceConfigSchema: JSONBlobStringify({}),
@@ -834,7 +835,7 @@ describe('test peripheralDevice general API methods', () => {
834835
mediaSize: 10,
835836
mediaTime: 0,
836837
objId: MOCK_OBJID,
837-
studioId: device.studioId!,
838+
studioId: device.studioAndConfigId!.studioId,
838839
thumbSize: 0,
839840
thumbTime: 0,
840841
tinf: '',
@@ -843,7 +844,7 @@ describe('test peripheralDevice general API methods', () => {
843844
test('getMediaObjectRevisions', async () => {
844845
const mobjects = (
845846
await MediaObjects.findFetchAsync({
846-
studioId: device.studioId,
847+
studioId: device.studioAndConfigId!.studioId,
847848
})
848849
).map((mo) => ({
849850
_id: mo._id,
@@ -864,7 +865,7 @@ describe('test peripheralDevice general API methods', () => {
864865
test('update', async () => {
865866
const mo = (await MediaObjects.findOneAsync({
866867
collectionId: MOCK_COLLECTION,
867-
studioId: device.studioId!,
868+
studioId: device.studioAndConfigId!.studioId,
868869
})) as MediaObject
869870
expect(mo).toBeTruthy()
870871

@@ -882,14 +883,14 @@ describe('test peripheralDevice general API methods', () => {
882883

883884
const updateMo = await MediaObjects.findOneAsync({
884885
collectionId: MOCK_COLLECTION,
885-
studioId: device.studioId!,
886+
studioId: device.studioAndConfigId!.studioId,
886887
})
887888
expect(updateMo).toMatchObject(newMo)
888889
})
889890
test('remove', async () => {
890891
const mo = (await MediaObjects.findOneAsync({
891892
collectionId: MOCK_COLLECTION,
892-
studioId: device.studioId!,
893+
studioId: device.studioAndConfigId!.studioId,
893894
})) as MediaObject
894895
expect(mo).toBeTruthy()
895896

@@ -903,7 +904,7 @@ describe('test peripheralDevice general API methods', () => {
903904

904905
const updateMo = await MediaObjects.findOneAsync({
905906
collectionId: MOCK_COLLECTION,
906-
studioId: device.studioId!,
907+
studioId: device.studioAndConfigId!.studioId,
907908
})
908909
expect(updateMo).toBeFalsy()
909910
})

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)