Skip to content

Commit e0135c3

Browse files
author
Ivan Maretić
committed
feat: return adlib action validation errors to client
1 parent a0f7688 commit e0135c3

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

packages/blueprints-integration/src/api/showStyle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export interface ShowStyleBlueprintManifest<
142142
privateData: unknown | undefined,
143143
publicData: unknown | undefined,
144144
actionOptions: { [key: string]: any } | undefined
145-
) => Promise<void>
145+
) => Promise<{ validationErrors: any } | void>
146146

147147
/** Generate adlib piece from ingest data */
148148
getAdlibItem?: (

packages/corelib/src/worker/studio.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export interface ExecuteBucketAdLibOrActionProps extends RundownPlayoutPropsBase
285285
export interface ExecuteActionResult {
286286
queuedPartInstanceId?: PartInstanceId
287287
taken?: boolean
288+
validationErrors?: any
288289
}
289290
export interface TakeNextPartProps extends RundownPlayoutPropsBase {
290291
fromPartInstanceId: PartInstanceId | null

packages/job-worker/src/playout/adlibAction.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export async function executeActionInner(
243243
try {
244244
const blueprintPersistentState = new PersistentPlayoutStateStore(playoutModel.playlist.previousPersistentState)
245245

246-
await blueprint.blueprint.executeAction(
246+
const result = await blueprint.blueprint.executeAction(
247247
actionContext,
248248
blueprintPersistentState,
249249
actionParameters.actionId,
@@ -253,6 +253,14 @@ export async function executeActionInner(
253253
actionParameters.publicData,
254254
actionParameters.actionOptions ?? {}
255255
)
256+
if (result && result.validationErrors) {
257+
throw UserError.from(
258+
new Error(`AdLib Action validation failed: ${JSON.stringify(result.validationErrors)}`),
259+
UserErrorMessage.ValidationFailed,
260+
undefined,
261+
409
262+
)
263+
}
256264

257265
if (blueprintPersistentState.hasChanges) {
258266
playoutModel.setBlueprintPersistentState(blueprintPersistentState.getAll())

0 commit comments

Comments
 (0)