Skip to content

Commit 7cad592

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

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ export async function executeActionInner(
240240
)} (${actionParameters.triggerMode})`
241241
)
242242

243+
let result: ExecuteActionResult | void
244+
243245
try {
244246
const blueprintPersistentState = new PersistentPlayoutStateStore(playoutModel.playlist.previousPersistentState)
245247

246-
await blueprint.blueprint.executeAction(
248+
result = await blueprint.blueprint.executeAction(
247249
actionContext,
248250
blueprintPersistentState,
249251
actionParameters.actionId,
@@ -262,6 +264,17 @@ export async function executeActionInner(
262264
throw UserError.fromUnknown(err)
263265
}
264266

267+
if (result && result.validationErrors) {
268+
throw UserError.from(
269+
new Error(
270+
`AdLib Action "${actionParameters.actionId}" validation failed: ${JSON.stringify(result.validationErrors)}`
271+
),
272+
UserErrorMessage.ValidationFailed,
273+
undefined,
274+
409
275+
)
276+
}
277+
265278
// Store any notes generated by the action
266279
storeNotificationsForCategory(
267280
playoutModel,

0 commit comments

Comments
 (0)