Skip to content

Commit 0261601

Browse files
committed
feat: add the ability to create rundowns without specifying a playlist
1 parent 23b7ecc commit 0261601

5 files changed

Lines changed: 64 additions & 4 deletions

File tree

meteor/server/api/rest/v1/ingest.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,11 @@ class IngestServerAPI implements IngestRestAPI {
456456
_connection: Meteor.Connection,
457457
_event: string,
458458
studioId: StudioId,
459-
playlistId: string,
459+
playlistId: string | undefined,
460460
ingestRundown: RestApiIngestRundown
461461
): Promise<ClientAPI.ClientResponse<void>> {
462462
check(studioId, String)
463-
check(playlistId, String)
463+
if (playlistId !== undefined) check(playlistId, String)
464464
check(ingestRundown, Object)
465465

466466
const studio = await this.findStudio(studioId)
@@ -488,7 +488,8 @@ class IngestServerAPI implements IngestRestAPI {
488488

489489
await runIngestOperation(studio._id, IngestJobs.UpdateRundown, {
490490
rundownExternalId: ingestRundown.externalId,
491-
ingestRundown: { ...ingestRundown, playlistExternalId: playlistId },
491+
ingestRundown:
492+
playlistId !== undefined ? { ...ingestRundown, playlistExternalId: playlistId } : ingestRundown,
492493
isCreateAction: true,
493494
rundownSource: {
494495
type: 'restApi',
@@ -1249,6 +1250,26 @@ export function registerRoutes(registerRoute: APIRegisterHook<IngestRestAPI>): v
12491250
)
12501251

12511252
// Create rundown
1253+
registerRoute<{ studioId: string }, never, void>(
1254+
'post',
1255+
'/ingest/:studioId/rundowns',
1256+
new Map(),
1257+
ingestAPIFactory,
1258+
async (serverAPI, connection, event, params, body) => {
1259+
logger.info(`INGEST API POST: Rundowns (studio-scoped)`)
1260+
1261+
const studioId = protectString<StudioId>(params.studioId)
1262+
check(studioId, String)
1263+
1264+
const ingestRundown = body as RestApiIngestRundown
1265+
if (!ingestRundown) throw new Meteor.Error(400, 'Upload rundown: Missing request body')
1266+
if (typeof ingestRundown !== 'object') throw new Meteor.Error(400, 'Upload rundown: Invalid request body')
1267+
1268+
return await serverAPI.postRundown(connection, event, studioId, undefined, ingestRundown)
1269+
}
1270+
)
1271+
1272+
// Create rundown in a playlist
12521273
registerRoute<{ studioId: string; playlistId: string; rundownId: string }, never, void>(
12531274
'post',
12541275
'/ingest/:studioId/playlists/:playlistId/rundowns',

meteor/server/lib/rest/v1/ingest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface IngestRestAPI {
6060
_connection: Meteor.Connection,
6161
_event: string,
6262
studioId: StudioId,
63-
playlistId: string,
63+
playlistId: string | undefined,
6464
ingestRundown: RestApiIngestRundown
6565
): Promise<ClientAPI.ClientResponse<void>>
6666

packages/openapi/api/actions.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ paths:
118118
$ref: 'definitions/ingest.yaml#/resources/playlists'
119119
/ingest/{studioId}/playlists/{playlistId}:
120120
$ref: 'definitions/ingest.yaml#/resources/playlist'
121+
/ingest/{studioId}/rundowns:
122+
$ref: 'definitions/ingest.yaml#/resources/rundownsInStudio'
121123
/ingest/{studioId}/playlists/{playlistId}/rundowns:
122124
$ref: 'definitions/ingest.yaml#/resources/rundowns'
123125
/ingest/{studioId}/playlists/{playlistId}/rundowns/{rundownId}:

packages/openapi/api/definitions/ingest.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,31 @@ resources:
212212
description: Request accepted.
213213
404:
214214
$ref: '#/components/responses/idNotFound'
215+
rundownsInStudio:
216+
post:
217+
operationId: postRundownInStudio
218+
summary: Creates a Rundown in a specified Studio. For all other rundown operations use the /ingest/{studioId}/playlists/{playlistId}/rundowns routes.
219+
tags:
220+
- ingest
221+
parameters:
222+
- name: studioId
223+
in: path
224+
description: ID of the studio that is performing ingest operation.
225+
required: true
226+
schema:
227+
type: string
228+
requestBody:
229+
description: Rundown data to ingest. Must include playlistExternalId.
230+
required: true
231+
content:
232+
application/json:
233+
schema:
234+
$ref: '#/components/schemas/rundown'
235+
responses:
236+
202:
237+
description: Request has been accepted.
238+
400:
239+
description: Bad request.
215240
rundown:
216241
get:
217242
operationId: getRundown
@@ -1104,6 +1129,9 @@ components:
11041129
payload:
11051130
type: object
11061131
additionalProperties: true
1132+
playlistExternalId:
1133+
type: string
1134+
example: playlist1
11071135
required:
11081136
- externalId
11091137
- name

packages/openapi/src/__tests__/ingest.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ describe('Ingest API', () => {
143143
expect(result).toBe(undefined)
144144
})
145145

146+
test('Can create rundown (studio-scoped)', async () => {
147+
const result = await ingestApi.postRundown({
148+
studioId,
149+
playlistId: undefined,
150+
rundown,
151+
})
152+
expect(result).toBe(undefined)
153+
})
154+
146155
test('Can update multiple rundowns', async () => {
147156
const result = await ingestApi.putRundowns({ studioId, playlistId: playlistIds[0], rundown: [rundown] })
148157
expect(result).toBe(undefined)

0 commit comments

Comments
 (0)