Skip to content

Commit

Permalink
feat: Buckets in the HTTP API (SOFIE-2795) (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianshade authored Dec 20, 2023
1 parent 748f0e1 commit 5d94d8a
Show file tree
Hide file tree
Showing 19 changed files with 1,208 additions and 65 deletions.
2 changes: 1 addition & 1 deletion meteor/lib/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export namespace ClientAPI {
/** On success, return success code (by default, use 200) */
success: number
/** Optionally, provide method result */
result?: Result
result: Result
}
export function responseSuccess<Result>(result: Result, code?: number): ClientResponseSuccess<Result> {
if (isClientResponseSuccess(result)) result = result.result
Expand Down
120 changes: 120 additions & 0 deletions meteor/lib/api/rest/v1/buckets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { Meteor } from 'meteor/meteor'
import { ClientAPI } from '../../client'
import { BucketId, ShowStyleBaseId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { IngestAdlib } from '@sofie-automation/blueprints-integration'

export interface BucketsRestAPI {
/**
* Get all available Buckets.
*
* @param connection Connection data including client and header details
* @param event User event string
* @param inputs Migration data to apply
*/
getAllBuckets(
connection: Meteor.Connection,
event: string
): Promise<ClientAPI.ClientResponse<Array<APIBucketComplete>>>

/**
* Get a Bucket.
*
* @param connection Connection data including client and header details
* @param event User event string
* @param inputs Migration data to apply
*/
getBucket(
connection: Meteor.Connection,
event: string,
bucketId: BucketId
): Promise<ClientAPI.ClientResponse<APIBucketComplete>>

/**
* Adds a new Bucket, returns the Id of the newly created Bucket.
*
* @param connection Connection data including client and header details
* @param event User event string
* @param bucket Bucket to add
*/
addBucket(
connection: Meteor.Connection,
event: string,
bucket: APIBucket
): Promise<ClientAPI.ClientResponse<BucketId>>

/**
* Deletes a Bucket.
*
* @param connection Connection data including client and header details
* @param event User event string
* @param bucketId Id of the bucket to delete
*/
deleteBucket(
connection: Meteor.Connection,
event: string,
bucketId: BucketId
): Promise<ClientAPI.ClientResponse<void>>

/**
* Empties a Bucket.
*
* @param connection Connection data including client and header details
* @param event User event string
* @param bucketId Id of the bucket to empty
*/
emptyBucket(
connection: Meteor.Connection,
event: string,
bucketId: BucketId
): Promise<ClientAPI.ClientResponse<void>>

/**
* Deletes a Bucket AdLib.
*
* @param connection Connection data including client and header details
* @param event User event string
* @param adLibId Id of the bucket adlib to delete
*/
deleteBucketAdLib(
connection: Meteor.Connection,
event: string,
externalId: string
): Promise<ClientAPI.ClientResponse<void>>

/**
* Imports a Bucket AdLib.
* If adlibs with the same `ingestItem.externalId` already exist in the bucket, they will be replaced.
*
* @param connection Connection data including client and header details
* @param event User event string
* @param bucketId Id of the bucket where to import the adlib
* @param showStyleBaseId Id of the showStyle to use when importing the adlib
* @param ingestItem Adlib to be imported
*/
importAdLibToBucket(
connection: Meteor.Connection,
event: string,
bucketId: BucketId,
showStyleBaseId: ShowStyleBaseId,
ingestItem: IngestAdlib
): Promise<ClientAPI.ClientResponse<void>>
}

export interface APIBucket {
name: string
studioId: string
}

export interface APIBucketComplete extends APIBucket {
id: string
}

// Based on the IngestAdlib interface
export interface APIImportAdlib {
externalId: string
name: string
payloadType: string
payload?: unknown

showStyleBaseId: string
}
1 change: 1 addition & 0 deletions meteor/lib/api/rest/v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './blueprints'
export * from './buckets'
export * from './devices'
export * from './playlists'
export * from './showstyles'
Expand Down
23 changes: 23 additions & 0 deletions meteor/lib/api/rest/v1/playlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ClientAPI } from '../../client'
import {
AdLibActionId,
BucketAdLibId,
BucketId,
PartId,
PartInstanceId,
PieceId,
Expand Down Expand Up @@ -75,6 +76,28 @@ export interface PlaylistsRestAPI {
adLibId: AdLibActionId | RundownBaselineAdLibActionId | PieceId | BucketAdLibId,
triggerMode?: string
): Promise<ClientAPI.ClientResponse<object>>
/**
* Executes the requested Bucket AdLib/AdLib Action. This is a Bucket AdLib (Action) that has been previously inserted into a Bucket.
* It will automatically find the variation matching the showStyleBaseId and showStyleVariantId of the current Rundown.
*
* Throws if the target Playlist is not active.
* Throws if there is not an on-air part instance.
* @returns a `ClientResponseError` if a bucket or adlib for the provided ids cannot be found.
* @param connection Connection data including client and header details
* @param event User event string
* @param rundownPlaylistId Playlist to execute adLib in.
* @param bucketId Bucket to execute the adlib from
* @param externalId External Id of the Bucket AdLib to execute.
* @param triggerMode A string to specify a particular variation for the AdLibAction, valid actionType strings are to be read from the status API.
*/
executeBucketAdLib(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
bucketId: BucketId,
externalId: string,
triggerMode?: string
): Promise<ClientAPI.ClientResponse<object>>
/**
* Moves the next point by `delta` places. Negative values are allowed to move "backwards" in the script.
*
Expand Down
Loading

0 comments on commit 5d94d8a

Please sign in to comment.