-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release51' into feat/config-upgrade-step
# Conflicts: # packages/blueprints-integration/src/context/index.ts
- Loading branch information
Showing
10 changed files
with
394 additions
and
336 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
packages/blueprints-integration/src/context/adlibActionContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import type { DatastorePersistenceMode, Time } from '../common' | ||
import type { IEventContext } from '.' | ||
import type { IShowStyleUserContext } from './showStyleContext' | ||
import type { | ||
IBlueprintMutatablePart, | ||
IBlueprintPart, | ||
IBlueprintPartInstance, | ||
IBlueprintPiece, | ||
IBlueprintPieceDB, | ||
IBlueprintPieceInstance, | ||
IBlueprintResolvedPieceInstance, | ||
} from '../documents' | ||
import type { PeripheralDeviceId } from '@sofie-automation/shared-lib/dist/core/model/Ids' | ||
import type { TSR } from '../timeline' | ||
import type { IBlueprintPlayoutDevice } from '..' | ||
|
||
/** Actions */ | ||
export interface IDataStoreActionExecutionContext extends IShowStyleUserContext, IEventContext { | ||
/** | ||
* Setting a value in the datastore allows us to overwrite parts of a timeline content object with that value | ||
* @param key Key to use when referencing from the timeline object | ||
* @param value Value to overwrite the timeline object's content with | ||
* @param mode In temporary mode the value may be removed when the key is no longer on the timeline | ||
*/ | ||
setTimelineDatastoreValue(key: string, value: any, mode: DatastorePersistenceMode): Promise<void> | ||
/** Deletes a previously set value from the datastore */ | ||
removeTimelineDatastoreValue(key: string): Promise<void> | ||
} | ||
|
||
export interface IActionExecutionContext | ||
extends IShowStyleUserContext, | ||
IEventContext, | ||
IDataStoreActionExecutionContext { | ||
/** Data fetching */ | ||
// getIngestRundown(): IngestRundown // TODO - for which part? | ||
/** Get a PartInstance which can be modified */ | ||
getPartInstance(part: 'current' | 'next'): Promise<IBlueprintPartInstance | undefined> | ||
/** Get the PieceInstances for a modifiable PartInstance */ | ||
getPieceInstances(part: 'current' | 'next'): Promise<IBlueprintPieceInstance[]> | ||
/** Get the resolved PieceInstances for a modifiable PartInstance */ | ||
getResolvedPieceInstances(part: 'current' | 'next'): Promise<IBlueprintResolvedPieceInstance[]> | ||
/** Get the last active piece on given layer */ | ||
findLastPieceOnLayer( | ||
sourceLayerId: string | string[], | ||
options?: { | ||
excludeCurrentPart?: boolean | ||
originalOnly?: boolean | ||
pieceMetaDataFilter?: any // Mongo query against properties inside of piece.metaData | ||
} | ||
): Promise<IBlueprintPieceInstance | undefined> | ||
/** Get the previous scripted piece on a given layer, looking backwards from the current part. */ | ||
findLastScriptedPieceOnLayer( | ||
sourceLayerId: string | string[], | ||
options?: { | ||
excludeCurrentPart?: boolean | ||
pieceMetaDataFilter?: any | ||
} | ||
): Promise<IBlueprintPiece | undefined> | ||
/** Gets the PartInstance for a PieceInstance retrieved from findLastPieceOnLayer. This primarily allows for accessing metadata of the PartInstance */ | ||
getPartInstanceForPreviousPiece(piece: IBlueprintPieceInstance): Promise<IBlueprintPartInstance> | ||
/** Gets the Part for a Piece retrieved from findLastScriptedPieceOnLayer. This primarily allows for accessing metadata of the Part */ | ||
getPartForPreviousPiece(piece: IBlueprintPieceDB): Promise<IBlueprintPart | undefined> | ||
/** Fetch the showstyle config for the specified part */ | ||
// getNextShowStyleConfig(): Readonly<{ [key: string]: ConfigItemValue }> | ||
|
||
/** Creative actions */ | ||
/** Insert a pieceInstance. Returns id of new PieceInstance. Any timelineObjects will have their ids changed, so are not safe to reference from another piece */ | ||
insertPiece(part: 'current' | 'next', piece: IBlueprintPiece): Promise<IBlueprintPieceInstance> | ||
/** Update a piecesInstance */ | ||
updatePieceInstance(pieceInstanceId: string, piece: Partial<IBlueprintPiece>): Promise<IBlueprintPieceInstance> | ||
/** Insert a queued part to follow the current part */ | ||
queuePart(part: IBlueprintPart, pieces: IBlueprintPiece[]): Promise<IBlueprintPartInstance> | ||
/** Update a partInstance */ | ||
updatePartInstance( | ||
part: 'current' | 'next', | ||
props: Partial<IBlueprintMutatablePart> | ||
): Promise<IBlueprintPartInstance> | ||
|
||
/** Destructive actions */ | ||
/** Stop any piecesInstances on the specified sourceLayers. Returns ids of piecesInstances that were affected */ | ||
stopPiecesOnLayers(sourceLayerIds: string[], timeOffset?: number): Promise<string[]> | ||
/** Stop piecesInstances by id. Returns ids of piecesInstances that were removed */ | ||
stopPieceInstances(pieceInstanceIds: string[], timeOffset?: number): Promise<string[]> | ||
/** Remove piecesInstances by id. Returns ids of piecesInstances that were removed. Note: For now we only allow removing from the next, but this might change to include current if there is justification */ | ||
removePieceInstances(part: 'next', pieceInstanceIds: string[]): Promise<string[]> | ||
|
||
/** Move the next part through the rundown. Can move by either a number of parts, or segments in either direction. */ | ||
moveNextPart(partDelta: number, segmentDelta: number): Promise<void> | ||
/** Set flag to perform take after executing the current action. Returns state of the flag after each call. */ | ||
takeAfterExecuteAction(take: boolean): Promise<boolean> | ||
/** Inform core that a take out of the current partinstance should be blocked until the specified time */ | ||
blockTakeUntil(time: Time | null): Promise<void> | ||
|
||
/** Misc actions */ | ||
// updateAction(newManifest: Pick<IBlueprintAdLibActionManifest, 'description' | 'payload'>): void // only updates itself. to allow for the next one to do something different | ||
// executePeripheralDeviceAction(deviceId: string, functionName: string, args: any[]): Promise<any> | ||
// openUIDialogue(message: string) // ????? | ||
/** Returns a list of the PeripheralDevices */ | ||
listPlayoutDevices(): Promise<IBlueprintPlayoutDevice[]> | ||
/** Execute an action on a certain PeripheralDevice */ | ||
executeTSRAction( | ||
deviceId: PeripheralDeviceId, | ||
actionId: string, | ||
payload: Record<string, any> | ||
): Promise<TSR.ActionExecutionResult> | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/blueprints-integration/src/context/baseContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Base context type that all others should extend from. | ||
* This is to provide logging and some other utilities | ||
*/ | ||
export interface ICommonContext { | ||
/** | ||
* Hash a string. Will return a unique string, to be used for all _id:s that are to be inserted in database | ||
* @param originString A representation of the origin of the hash (for logging) | ||
* @param originIsNotUnique If the originString is not guaranteed to be unique, set this to true | ||
*/ | ||
getHashId: (originString: string, originIsNotUnique?: boolean) => string | ||
/** Un-hash, is return the string that created the hash */ | ||
unhashId: (hash: string) => string | ||
|
||
/** Log a message to the sofie log with level 'debug' */ | ||
logDebug: (message: string) => void | ||
/** Log a message to the sofie log with level 'info' */ | ||
logInfo: (message: string) => void | ||
/** Log a message to the sofie log with level 'warn' */ | ||
logWarning: (message: string) => void | ||
/** Log a message to the sofie log with level 'error' */ | ||
logError: (message: string) => void | ||
} | ||
|
||
export function isCommonContext(obj: unknown): obj is ICommonContext { | ||
if (!obj || typeof obj !== 'object') { | ||
return false | ||
} | ||
|
||
const { getHashId, unhashId, logDebug, logInfo, logWarning, logError } = obj as ICommonContext | ||
|
||
return ( | ||
typeof getHashId === 'function' && | ||
typeof unhashId === 'function' && | ||
typeof logDebug === 'function' && | ||
typeof logInfo === 'function' && | ||
typeof logWarning === 'function' && | ||
typeof logError === 'function' | ||
) | ||
} | ||
|
||
export interface IUserNotesContext extends ICommonContext { | ||
/** Display a notification to the user of an error */ | ||
notifyUserError(message: string, params?: { [key: string]: any }): void | ||
/** Display a notification to the user of an warning */ | ||
notifyUserWarning(message: string, params?: { [key: string]: any }): void | ||
/** Display a notification to the user of a note */ | ||
notifyUserInfo(message: string, params?: { [key: string]: any }): void | ||
} | ||
|
||
export function isUserNotesContext(obj: unknown): obj is IUserNotesContext { | ||
if (!isCommonContext(obj)) { | ||
return false | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
const { notifyUserError, notifyUserWarning, notifyUserInfo } = obj as IUserNotesContext | ||
|
||
return ( | ||
typeof notifyUserError === 'function' && | ||
typeof notifyUserWarning === 'function' && | ||
typeof notifyUserInfo === 'function' | ||
) | ||
} |
75 changes: 75 additions & 0 deletions
75
packages/blueprints-integration/src/context/eventContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import type { OnGenerateTimelineObj, TSR } from '../timeline' | ||
import type { IBlueprintPartInstance, IBlueprintPieceInstance, IBlueprintSegmentDB } from '../documents' | ||
import type { IRundownContext } from './rundownContext' | ||
import type { IBlueprintExternalMessageQueueObj } from '../message' | ||
|
||
export interface IEventContext { | ||
getCurrentTime(): number | ||
} | ||
|
||
export interface ITimelineEventContext extends IEventContext, IRundownContext { | ||
readonly currentPartInstance: Readonly<IBlueprintPartInstance> | undefined | ||
readonly nextPartInstance: Readonly<IBlueprintPartInstance> | undefined | ||
readonly previousPartInstance: Readonly<IBlueprintPartInstance> | undefined | ||
|
||
/** | ||
* Get the full session id for an ab playback session. | ||
* Note: sessionName should be unique within the segment unless pieces want to share a session | ||
* @deprecated use the core provided AB implementation instead | ||
*/ | ||
getPieceABSessionId(piece: IBlueprintPieceInstance, sessionName: string): string | ||
/** | ||
* Get the full session id for a timelineobject that belongs to an ab playback session | ||
* sessionName should also be used in calls to getPieceABSessionId for the owning piece | ||
* @deprecated use the core provided AB implementation instead | ||
*/ | ||
getTimelineObjectAbSessionId( | ||
obj: OnGenerateTimelineObj<TSR.TSRTimelineContent, any, any>, | ||
sessionName: string | ||
): string | undefined | ||
} | ||
|
||
export interface IPartEventContext extends IEventContext, IRundownContext { | ||
readonly part: Readonly<IBlueprintPartInstance> | ||
} | ||
|
||
export interface IRundownDataChangedEventContext extends IEventContext, IRundownContext { | ||
formatDateAsTimecode(time: number): string | ||
formatDurationAsTimecode(time: number): string | ||
|
||
/** Get all unsent and queued messages in the rundown */ | ||
getAllUnsentQueuedMessages(): Promise<Readonly<IBlueprintExternalMessageQueueObj[]>> | ||
} | ||
|
||
export interface IRundownTimingEventContext extends IRundownDataChangedEventContext { | ||
readonly previousPart: Readonly<IBlueprintPartInstance> | undefined | ||
readonly currentPart: Readonly<IBlueprintPartInstance> | ||
readonly nextPart: Readonly<IBlueprintPartInstance> | undefined | ||
|
||
/** | ||
* Returns the first PartInstance in the Rundown within the current playlist activation. | ||
* This allows for a start time for the Rundown to be determined | ||
* @param allowUntimed Whether to consider a Part which has the untimed property set | ||
*/ | ||
getFirstPartInstanceInRundown(allowUntimed?: boolean): Promise<Readonly<IBlueprintPartInstance>> | ||
|
||
/** | ||
* Returns the partInstances in the Segment, limited to the playthrough of the segment that refPartInstance is part of | ||
* @param refPartInstance PartInstance to use as the basis of the search | ||
*/ | ||
getPartInstancesInSegmentPlayoutId( | ||
refPartInstance: Readonly<IBlueprintPartInstance> | ||
): Promise<Readonly<IBlueprintPartInstance[]>> | ||
|
||
/** | ||
* Returns pieces in a partInstance | ||
* @param id Id of partInstance to fetch items in | ||
*/ | ||
getPieceInstances(...partInstanceIds: string[]): Promise<Readonly<IBlueprintPieceInstance[]>> | ||
|
||
/** | ||
* Returns a segment | ||
* @param id Id of segment to fetch | ||
*/ | ||
getSegment(id: string): Promise<Readonly<IBlueprintSegmentDB> | undefined> | ||
} |
6 changes: 3 additions & 3 deletions
6
packages/blueprints-integration/src/context/fixUpConfigContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.