Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Buckets in the HTTP API (SOFIE-2795) #1070

Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9539c4a
wip(EAV-95): expose bucket api over http
ianshade Oct 25, 2023
84cf765
wip(EAV-95): refactor buckets api and add definitions
ianshade Nov 6, 2023
e9ed808
Merge branch 'contribute/EAV-33/buckets-api-http' into contribute/EAV…
ianshade Nov 13, 2023
cc3044b
fix(EAV-95): interface inconsistencies
ianshade Nov 13, 2023
f45aa1b
Merge branch 'contribute/EAV-33/buckets-api-http' into contribute/EAV…
ianshade Nov 13, 2023
abed9ec
fix(openapi): missing and incorrect parameter definition
ianshade Nov 13, 2023
0a2d666
Merge branch 'contribute/EAV-33/buckets-api-http' into contribute/EAV…
ianshade Nov 13, 2023
65539b9
fix(openapi): incorrect return type
ianshade Nov 13, 2023
adaae83
Merge branch 'contribute/EAV-33/buckets-api-http' into contribute/EAV…
ianshade Nov 13, 2023
c9c5e89
chore: fix types and imports
ianshade Nov 17, 2023
8d050ea
chore(openapi): fix bucket adlib payload type
ianshade Nov 17, 2023
deb5f96
Merge branch 'contribute/EAV-33/buckets-api-http' into contribute/EAV…
ianshade Nov 28, 2023
114a41f
refactor: make bucket adlibs removable by externalId
ianshade Dec 6, 2023
af4e5e2
feat: allow executing bucket adlibs by `externalId`
ianshade Dec 7, 2023
4bd22b1
fix(openapi): url parameter name
ianshade Dec 7, 2023
78314c0
Merge branch 'contribute/EAV-33/buckets-api-http' into contribute/EAV…
ianshade Dec 7, 2023
e502ed1
fix(openapi): buckets definitions and tests
ianshade Dec 7, 2023
4f468c6
Merge branch 'contribute/EAV-33/buckets-api-http' into contribute/EAV…
ianshade Dec 7, 2023
26ae99e
fix: bucket selectors and unhandled promises
ianshade Dec 20, 2023
6c2a1bf
fix: save to database when starting a piece
ianshade Dec 20, 2023
a3cf788
Merge branch 'contribute/EAV-33/buckets-api-http' into contribute/EAV…
ianshade Dec 20, 2023
68ef09a
Merge remote-tracking branch 'origin/release51' into contribute/EAV-3…
ianshade Dec 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Julusian marked this conversation as resolved.
Show resolved Hide resolved
* 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
}

Check warning on line 120 in meteor/lib/api/rest/v1/buckets.ts

View check run for this annotation

Codecov / codecov/patch

meteor/lib/api/rest/v1/buckets.ts#L1-L120

Added lines #L1 - L120 were not covered by tests
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'

Check warning on line 2 in meteor/lib/api/rest/v1/index.ts

View check run for this annotation

Codecov / codecov/patch

meteor/lib/api/rest/v1/index.ts#L2

Added line #L2 was not covered by tests
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 {
AdLibActionId,
BucketAdLibId,
BucketId,

Check warning on line 5 in meteor/lib/api/rest/v1/playlists.ts

View check run for this annotation

Codecov / codecov/patch

meteor/lib/api/rest/v1/playlists.ts#L5

Added line #L5 was not covered by tests
PartId,
PartInstanceId,
PieceId,
Expand Down Expand Up @@ -75,6 +76,28 @@
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>>

Check warning on line 100 in meteor/lib/api/rest/v1/playlists.ts

View check run for this annotation

Codecov / codecov/patch

meteor/lib/api/rest/v1/playlists.ts#L79-L100

Added lines #L79 - L100 were not covered by tests
/**
* Moves the next point by `delta` places. Negative values are allowed to move "backwards" in the script.
*
Expand Down