import { Time } from './common'; import { IBlueprintExternalMessageQueueObj } from './message'; import { PackageInfo } from './packageInfo'; import { IBlueprintMutatablePart, IBlueprintPart, IBlueprintPartInstance, IBlueprintPiece, IBlueprintPieceDB, IBlueprintPieceInstance, IBlueprintResolvedPieceInstance, IBlueprintRundownPlaylist, IBlueprintSegmentDB, IBlueprintSegmentRundown } from './rundown'; import { BlueprintMappings } from './studio'; import { OnGenerateTimelineObj } from './timeline'; /** Common */ 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 declare function isCommonContext(obj: unknown): obj is ICommonContext; 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 declare function isUserNotesContext(obj: unknown): obj is IUserNotesContext; /** Studio */ export interface IStudioContext extends ICommonContext { /** The id of the studio */ readonly studioId: string; /** Returns the Studio blueprint config. If StudioBlueprintManifest.preprocessConfig is provided, a config preprocessed by that function is returned, otherwise it is returned unprocessed */ getStudioConfig: () => unknown; /** Returns a reference to a studio config value, that can later be resolved in Core */ getStudioConfigRef(configKey: string): string; /** Get the mappings for the studio */ getStudioMappings: () => Readonly; } export interface IPackageInfoContext { /** * Get the PackageInfo items for an ExpectedPackage, if any have been reported by the package manager. * Only info for packages with the `listenToPackageInfoUpdates` property set to true can be returned. * The possible packageIds are scoped based on the ownership of the package. * eg, baseline packages can be accessed when generating the baseline objects, piece/adlib packages can be access when regenerating the segment they are from */ getPackageInfo: (packageId: string) => Readonly; hackGetMediaObjectDuration: (mediaId: string) => Promise; } export interface IStudioBaselineContext extends IStudioContext, IPackageInfoContext { } export interface IStudioUserContext extends IUserNotesContext, IStudioContext { } /** Show Style Variant */ export interface IShowStyleContext extends ICommonContext, IStudioContext { /** Returns a ShowStyle blueprint config. If ShowStyleBlueprintManifest.preprocessConfig is provided, a config preprocessed by that function is returned, otherwise it is returned unprocessed */ getShowStyleConfig: () => unknown; /** Returns a reference to a showStyle config value, that can later be resolved in Core */ getShowStyleConfigRef(configKey: string): string; } export interface IShowStyleUserContext extends IUserNotesContext, IShowStyleContext, IPackageInfoContext { } export interface IGetRundownContext extends IShowStyleUserContext { /** Returns a list of the Playlists in the studio */ getPlaylists: () => Promise>; /** Returns the Playlist in which the Rundown currently is in. If it's a new Rundown, this will return undefined. */ getCurrentPlaylist: () => Promise | undefined>; /** Returns a randomized string, intended to be used as ids. */ getRandomId: () => string; } /** Rundown */ export interface IRundownContext extends IShowStyleContext { readonly rundownId: string; readonly rundown: Readonly; } export interface IRundownUserContext extends IUserNotesContext, IRundownContext { } export interface ISegmentUserContext extends IUserNotesContext, IRundownContext, IPackageInfoContext { /** Display a notification to the user of an error */ notifyUserError: (message: string, params?: { [key: string]: any; }, partExternalId?: string) => void; /** Display a notification to the user of an warning */ notifyUserWarning: (message: string, params?: { [key: string]: any; }, partExternalId?: string) => void; /** Display a notification to the user of a note */ notifyUserInfo: (message: string, params?: { [key: string]: any; }, partExternalId?: string) => void; } /** Actions */ export interface IActionExecutionContext extends IShowStyleUserContext, IEventContext { /** Data fetching */ /** Get a PartInstance which can be modified */ getPartInstance(part: 'current' | 'next'): Promise; /** Get the PieceInstances for a modifiable PartInstance */ getPieceInstances(part: 'current' | 'next'): Promise; /** Get the resolved PieceInstances for a modifiable PartInstance */ getResolvedPieceInstances(part: 'current' | 'next'): Promise; /** Get the last active piece on given layer */ findLastPieceOnLayer(sourceLayerId: string | string[], options?: { excludeCurrentPart?: boolean; originalOnly?: boolean; pieceMetaDataFilter?: any; }): Promise; /** 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; /** Gets the PartInstance for a PieceInstance retrieved from findLastPieceOnLayer. This primarily allows for accessing metadata of the PartInstance */ getPartInstanceForPreviousPiece(piece: IBlueprintPieceInstance): Promise; /** Gets the Part for a Piece retrieved from findLastScriptedPieceOnLayer. This primarily allows for accessing metadata of the Part */ getPartForPreviousPiece(piece: IBlueprintPieceDB): Promise; /** Fetch the showstyle config for the specified part */ /** 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; /** Update a piecesInstance */ updatePieceInstance(pieceInstanceId: string, piece: Partial): Promise; /** Insert a queued part to follow the current part */ queuePart(part: IBlueprintPart, pieces: IBlueprintPiece[]): Promise; /** Update a partInstance */ updatePartInstance(part: 'current' | 'next', props: Partial): Promise; /** Destructive actions */ /** Stop any piecesInstances on the specified sourceLayers. Returns ids of piecesInstances that were affected */ stopPiecesOnLayers(sourceLayerIds: string[], timeOffset?: number): Promise; /** Stop piecesInstances by id. Returns ids of piecesInstances that were removed */ stopPieceInstances(pieceInstanceIds: string[], timeOffset?: number): Promise; /** 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; /** 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; /** Set flag to perform take after executing the current action. Returns state of the flag after each call. */ takeAfterExecuteAction(take: boolean): Promise; /** Inform core that a take out of the current partinstance should be blocked until the specified time */ blockTakeUntil(time: Time | null): Promise; } /** Actions */ export interface ISyncIngestUpdateToPartInstanceContext extends IRundownUserContext { /** Sync a pieceInstance. Inserts the pieceInstance if new, updates if existing. Optionally pass in a mutated Piece, to override the content of the instance */ syncPieceInstance(pieceInstanceId: string, mutatedPiece?: Omit): IBlueprintPieceInstance; /** Insert a pieceInstance. Returns id of new PieceInstance. Any timelineObjects will have their ids changed, so are not safe to reference from another piece */ insertPieceInstance(piece: IBlueprintPiece): IBlueprintPieceInstance; /** Update a pieceInstance */ updatePieceInstance(pieceInstanceId: string, piece: Partial): IBlueprintPieceInstance; /** Remove a pieceInstance */ removePieceInstances(...pieceInstanceIds: string[]): string[]; /** Update a partInstance */ updatePartInstance(props: Partial): IBlueprintPartInstance; /** Remove the partInstance. This is only valid when `playstatus: 'next'` */ removePartInstance(): void; } /** Events */ export interface IEventContext { getCurrentTime(): number; } export interface ITimelineEventContext extends IEventContext, IRundownContext { readonly currentPartInstance: Readonly | undefined; readonly nextPartInstance: Readonly | undefined; readonly previousPartInstance: Readonly | 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 */ 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 */ getTimelineObjectAbSessionId(obj: OnGenerateTimelineObj, sessionName: string): string | undefined; } export interface IPartEventContext extends IEventContext, IRundownContext { readonly part: Readonly; } 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>; } export interface IRundownTimingEventContext extends IRundownDataChangedEventContext { readonly previousPart: Readonly | undefined; readonly currentPart: Readonly; readonly nextPart: Readonly | 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>; /** * 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): Promise>; /** * Returns pieces in a partInstance * @param id Id of partInstance to fetch items in */ getPieceInstances(...partInstanceIds: string[]): Promise>; /** * Returns a segment * @param id Id of segment to fetch */ getSegment(id: string): Promise | undefined>; } //# sourceMappingURL=context.d.ts.map