Skip to content

Commit

Permalink
Merge pull request #1077 from tv2norge-collab/contribute/EAV-31/bluep…
Browse files Browse the repository at this point in the history
…rintsData

feat: Introduce privateData and publicData
  • Loading branch information
jstarpl authored Jan 11, 2024
2 parents 5a25fa6 + e90066f commit af9f080
Show file tree
Hide file tree
Showing 30 changed files with 419 additions and 317 deletions.
6 changes: 3 additions & 3 deletions meteor/__mocks__/helpers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export async function setupMockShowStyleBlueprint(
name: ingestRundown.name,
// expectedStart?:
// expectedDuration?: number;
metaData: ingestRundown.payload,
privateData: ingestRundown.payload,
timing: {
type: 'none' as any,
},
Expand All @@ -455,7 +455,7 @@ export async function setupMockShowStyleBlueprint(
getSegment: (_context: unknown, ingestSegment: IngestSegment): BlueprintResultSegment => {
const segment: IBlueprintSegment = {
name: ingestSegment.name ? ingestSegment.name : ingestSegment.externalId,
metaData: ingestSegment.payload,
privateData: ingestSegment.payload,
isHidden: ingestSegment.payload?.hidden,
}
const parts: BlueprintResultPart[] = []
Expand All @@ -464,7 +464,7 @@ export async function setupMockShowStyleBlueprint(
const part: IBlueprintPart = {
externalId: ingestPart.externalId,
title: ingestPart.name,
metaData: ingestPart.payload,
privateData: ingestPart.payload,
// autoNext?: boolean;
// autoNextOverlap?: number;
// prerollDuration?: number;
Expand Down
4 changes: 2 additions & 2 deletions meteor/client/ui/MediaStatus/MediaStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function useRundownPlaylists(playlistIds: RundownPlaylistId[]) {
holdState: 0,
lastIncorrectPartPlaybackReported: 0,
lastTakeTime: 0,
metaData: 0,
privateData: 0,
modified: 0,
nextPartInfo: 0,
queuedSegmentId: 0,
Expand All @@ -121,7 +121,7 @@ function useRundownPlaylists(playlistIds: RundownPlaylistId[]) {
displayAs: 0,
externalId: 0,
externalModified: 0,
metaData: 0,
privateData: 0,
notes: 0,
segmentTiming: 0,
showShelf: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default function DefaultItemRenderer(
<dt>{piece.sourceLayerId}</dt>
<dd>outputLayerId</dd>
<dt>{piece.outputLayerId}</dt>
<dd>metaData</dd>
<dt>{JSON.stringify(piece.metaData || {})}</dt>
<dd>publicData</dd>
<dt>{JSON.stringify(piece.publicData || {})}</dt>
</dl>
</>
)
Expand All @@ -66,8 +66,8 @@ export default function DefaultItemRenderer(
<dt>{piece.sourceLayerId}</dt>
<dd>outputLayerId</dd>
<dt>{piece.outputLayerId}</dt>
<dd>metaData</dd>
<dt>{JSON.stringify(piece.metaData || {})}</dt>
<dd>publicData</dd>
<dt>{JSON.stringify(piece.publicData || {})}</dt>
</dl>
</>
)
Expand Down
5 changes: 3 additions & 2 deletions meteor/server/api/rest/v1/playlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ class PlaylistsServerAPI implements PlaylistsRestAPI {
segmentAdLibPiece,
bucketAdLibPiece,
AdLibActions.findOneAsync(adLibId as AdLibActionId, {
projection: { _id: 1, actionId: 1, userData: 1 },
projection: { _id: 1, actionId: 1, userData: 1, privateData: 1 },
}),
RundownBaselineAdLibActions.findOneAsync(adLibId as RundownBaselineAdLibActionId, {
projection: { _id: 1, actionId: 1, userData: 1 },
projection: { _id: 1, actionId: 1, userData: 1, privateData: 1 },
}),
]
)
Expand Down Expand Up @@ -204,6 +204,7 @@ class PlaylistsServerAPI implements PlaylistsRestAPI {
actionId: adLibActionDoc.actionId,
userData: adLibActionDoc.userData,
triggerMode: triggerMode ?? undefined,
privateData: adLibActionDoc.privateData,
}
)
} else {
Expand Down
3 changes: 2 additions & 1 deletion meteor/server/api/userActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ class ServerUserActionAPI
actionDocId,
actionId,
userData,
triggerMode: triggerMode || undefined,
triggerMode: triggerMode ?? undefined,
privateData: null,
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ describe('lib/mediaObjects', () => {
prerollDuration: 0,
externalId: '',
lifespan: PieceLifespan.WithinPart,
metaData: {},
privateData: {},
outputLayerId: '',
sourceLayerId: '',
content: literal<VTContent>({
Expand Down Expand Up @@ -347,7 +347,7 @@ describe('lib/mediaObjects', () => {
prerollDuration: 0,
externalId: '',
lifespan: PieceLifespan.WithinPart,
metaData: {},
privateData: {},
outputLayerId: '',
sourceLayerId: '',
content: literal<VTContent>({
Expand All @@ -363,7 +363,7 @@ describe('lib/mediaObjects', () => {
prerollDuration: 0,
externalId: '',
lifespan: PieceLifespan.WithinPart,
metaData: {},
privateData: {},
outputLayerId: '',
sourceLayerId: '',
content: literal<VTContent>({
Expand Down
49 changes: 32 additions & 17 deletions meteor/server/publications/rundown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ meteorPublish(PeripheralDevicePubSub.rundownsForDevice, async function (deviceId

const modifier: FindOptions<DBRundown> = {
fields: {
metaData: 0,
privateData: 0,
},
}

Expand Down Expand Up @@ -97,7 +97,7 @@ meteorPublish(

const modifier: FindOptions<DBRundown> = {
fields: {
metaData: 0,
privateData: 0,
},
}

Expand Down Expand Up @@ -131,7 +131,7 @@ meteorPublish(

const modifier: FindOptions<DBRundown> = {
fields: {
metaData: 0,
privateData: 0,
},
}

Expand Down Expand Up @@ -167,7 +167,7 @@ meteorPublish(
) {
return Segments.findWithCursor(selector, {
fields: {
metaData: 0,
privateData: 0,
},
})
}
Expand All @@ -186,7 +186,7 @@ meteorPublish(

const modifier: FindOptions<DBPart> = {
fields: {
metaData: 0,
privateData: 0,
},
}

Expand Down Expand Up @@ -222,7 +222,7 @@ meteorPublish(
const modifier: FindOptions<DBPartInstance> = {
fields: {
// @ts-expect-error Mongo typings aren't clever enough yet
'part.metaData': 0,
'part.privateData': 0,
},
}

Expand Down Expand Up @@ -266,7 +266,7 @@ meteorPublish(
return PartInstances.findWithCursor(selector, {
fields: literal<MongoFieldSpecifierZeroes<DBPartInstance>>({
// @ts-expect-error Mongo typings aren't clever enough yet
'part.metaData': 0,
'part.privateData': 0,
isTaken: 0,
timings: 0,
}),
Expand All @@ -293,7 +293,7 @@ meteorPublish(
{
fields: {
// @ts-expect-error Mongo typings aren't clever enough yet
'part.metaData': 0,
'part.privateData': 0,
},
sort: {
takeCount: 1,
Expand All @@ -307,7 +307,7 @@ meteorPublish(
)

const piecesSubFields: MongoFieldSpecifierZeroes<Piece> = {
metaData: 0,
privateData: 0,
timelineObjectsString: 0,
}

Expand Down Expand Up @@ -382,7 +382,7 @@ meteorPublish(
)

const adlibPiecesSubFields: MongoFieldSpecifierZeroes<AdLibPiece> = {
metaData: 0,
privateData: 0,
timelineObjectsString: 0,
}

Expand Down Expand Up @@ -425,7 +425,7 @@ meteorPublish(MeteorPubSub.adLibPiecesForPart, async function (partId: PartId, s

const pieceInstanceFields: MongoFieldSpecifierZeroes<PieceInstance> = {
// @ts-expect-error Mongo typings aren't clever enough yet
'piece.metaData': 0,
'piece.privateData': 0,
'piece.timelineObjectsString': 0,
}

Expand Down Expand Up @@ -592,12 +592,18 @@ meteorPublish(
return RundownBaselineAdLibPieces.findWithCursor(selector, {
fields: {
timelineObjectsString: 0,
privateData: 0,
},
})
}
return null
}
)

const adlibActionSubFields: MongoFieldSpecifierZeroes<AdLibAction> = {
privateData: 0,
}

meteorPublish(CorelibPubSub.adLibActions, async function (rundownIds: RundownId[], token: string | undefined) {
check(rundownIds, Array)

Expand All @@ -611,7 +617,9 @@ meteorPublish(CorelibPubSub.adLibActions, async function (rundownIds: RundownId[
NoSecurityReadAccess.any() ||
(await RundownReadAccess.rundownContent(selector.rundownId, { userId: this.userId, token }))
) {
return AdLibActions.findWithCursor(selector)
return AdLibActions.findWithCursor(selector, {
fields: adlibActionSubFields,
})
}
return null
})
Expand All @@ -622,10 +630,15 @@ meteorPublish(MeteorPubSub.adLibActionsForPart, async function (partId: PartId,
// Future: This needs some thought for a security enabled environment
if (!NoSecurityReadAccess.any()) return null

return AdLibActions.findWithCursor({
partId,
'display.sourceLayerId': { $in: sourceLayerIds },
})
return AdLibActions.findWithCursor(
{
partId,
'display.sourceLayerId': { $in: sourceLayerIds },
},
{
fields: adlibActionSubFields,
}
)
})

meteorPublish(
Expand All @@ -643,7 +656,9 @@ meteorPublish(
NoSecurityReadAccess.any() ||
(await RundownReadAccess.rundownContent(selector.rundownId, { userId: this.userId, token }))
) {
return RundownBaselineAdLibActions.findWithCursor(selector)
return RundownBaselineAdLibActions.findWithCursor(selector, {
fields: adlibActionSubFields,
})
}
return null
}
Expand Down
13 changes: 10 additions & 3 deletions packages/blueprints-integration/src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export interface IBlueprintActionTriggerMode {
}
}

export interface IBlueprintActionManifest {
export interface IBlueprintActionManifest<TPrivateData = unknown, TPublicData = unknown> {
/**
* An identifier for this Action
* It should be unique within the part it belongs to, and consistent across ingest updates
Expand All @@ -74,9 +74,16 @@ export interface IBlueprintActionManifest {

/** Id of the action */
actionId: string
/** Properties defining the action behaviour */
/** Arbitraty data storage for internal use in the blueprints */
privateData?: TPrivateData
/** Arbitraty data relevant for other systems, made available to them through APIs */
publicData?: TPublicData
/**
* Arbitrary data relevant for other systems and/or users, available through APIs.
* It can be overriden when executing the action.
* It can be made user-editable with userDataManifest.
*/
userData: ActionUserData

/**
* Set if ad-lib action should be limited in context to the current part/segment
* Note: Only valid for items returned from getSegment
Expand Down
3 changes: 2 additions & 1 deletion packages/blueprints-integration/src/api/showStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ export interface ShowStyleBlueprintManifest<TRawConfig = IBlueprintConfig, TProc
context: IActionExecutionContext,
actionId: string,
userData: ActionUserData,
triggerMode?: string
triggerMode: string | undefined,
privateData?: unknown
) => Promise<void>

/** Generate adlib piece from ingest data */
Expand Down
8 changes: 5 additions & 3 deletions packages/blueprints-integration/src/documents/part.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export enum PartHoldMode {
TO = 2,
}

export interface IBlueprintMutatablePart<TMetadata = unknown> {
export interface IBlueprintMutatablePart<TPrivateData = unknown, TPublicData = unknown> {
/** The story title */
title: string
/**
Expand All @@ -32,8 +32,10 @@ export interface IBlueprintMutatablePart<TMetadata = unknown> {
*/
prompterTitle?: string

/** Arbitrary data storage for plugins */
metaData?: TMetadata
/** Arbitraty data storage for internal use in the blueprints */
privateData?: TPrivateData
/** Arbitraty data relevant for other systems, made available to them through APIs */
publicData?: TPublicData

/** Should this item should progress to the next automatically */
autoNext?: boolean
Expand Down
8 changes: 5 additions & 3 deletions packages/blueprints-integration/src/documents/pieceGeneric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ export interface IBlueprintDirectPlayAdLibAction extends IBlueprintDirectPlayBas
}
export type IBlueprintDirectPlay = IBlueprintDirectPlayAdLibPiece | IBlueprintDirectPlayAdLibAction

export interface IBlueprintPieceGeneric<TMetadata = unknown> {
export interface IBlueprintPieceGeneric<TPrivateData = unknown, TPublicData = unknown> {
/**
* An identifier for this Piece
* It should be unique within the part it belongs to, and consistent across ingest updates
*/
externalId: string
/** User-presentable name for the timeline item */
name: string
/** Arbitrary data storage for plugins */
metaData?: TMetadata
/** Arbitraty data storage for internal use in the blueprints */
privateData?: TPrivateData
/** Arbitraty data relevant for other systems, made available to them through APIs */
publicData?: TPublicData

/** Whether and how the piece is infinite */
lifespan: PieceLifespan
Expand Down
Loading

0 comments on commit af9f080

Please sign in to comment.