Skip to content

Commit 6e04a7f

Browse files
committed
chore: doc and fixes after code review
1 parent aefc95d commit 6e04a7f

File tree

19 files changed

+179
-86
lines changed

19 files changed

+179
-86
lines changed

meteor/server/api/ingest/ingestCache.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import {
1313
} from '@sofie-automation/corelib/dist/dataModel/NrcsIngestDataCache'
1414
import { groupByToMap } from '@sofie-automation/corelib/dist/lib'
1515

16+
/**
17+
* This class provides a few convenience methods for fetching IngestRundown
18+
* (or its child types) from the NrcsIngestDataCache collection
19+
*/
1620
export class RundownIngestDataCache {
1721
private constructor(private readonly rundownId: RundownId, private readonly documents: NrcsIngestDataCacheObj[]) {}
1822

meteor/server/collections/rundown.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@ registerIndex(AdLibPieces, {
2929
_rank: 1,
3030
})
3131

32+
/**
33+
* The NrcsIngestDataCache collection is used to store data that comes from an NRCS
34+
*/
3235
export const NrcsIngestDataCache = createAsyncOnlyReadOnlyMongoCollection<NrcsIngestDataCacheObj>(
3336
CollectionName.NrcsIngestDataCache
3437
)
3538
registerIndex(NrcsIngestDataCache, {
3639
rundownId: 1,
3740
})
3841

42+
/**
43+
* The SofieIngestDataCache collection is used to store data that comes from an NRCS and has been modified by Sofie
44+
*/
3945
export const SofieIngestDataCache = createAsyncOnlyReadOnlyMongoCollection<SofieIngestDataCacheObj>(
4046
CollectionName.SofieIngestDataCache
4147
)

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ export interface StudioBlueprintManifest<TRawConfig = IBlueprintConfig, TProcess
9393
coreConfig: BlueprintConfigCoreConfig
9494
) => TProcessedConfig
9595

96+
/**
97+
* Optional method to validate the blueprint config passed to this blueprint according to the API schema.
98+
* Returns a list of messages to the caller that are used for logging or to throw if errors have been found.
99+
*/
100+
validateConfigFromAPI?: (context: ICommonContext, apiConfig: object) => Array<IConfigMessage>
101+
102+
/**
103+
* Optional method to transform from an API blueprint config to the database blueprint config if these are required to be different.
104+
* If this method is not defined the config object will be used directly
105+
*/
106+
blueprintConfigFromAPI?: (context: ICommonContext, config: object) => IBlueprintConfig
107+
108+
/**
109+
* Optional method to transform from a database blueprint config to the API blueprint config if these are required to be different.
110+
* If this method is not defined the config object will be used directly
111+
*/
112+
blueprintConfigToAPI?: (context: ICommonContext, config: TRawConfig) => object
96113
/**
97114
* Process an ingest operation, to apply changes to the sofie interpretation of the ingest data
98115
*/

packages/blueprints-integration/src/context/processIngestDataContext.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import type { IngestDefaultChangesOptions, MutableIngestRundown, NrcsIngestChang
55
export interface IProcessIngestDataContext extends IStudioContext {
66
/**
77
* Perform the default syncing of changes from the ingest data to the rundown.
8-
* This may be overly agressive at removing any changes made by user operations.
9-
* If you are using user operations, you may need to perform some pre and post fixups to ensure changes aren't wiped unnecessarily.
8+
*
9+
* Please note that this may be overly aggressive at removing any changes made by user operations
10+
* If you are using user operations, you may need to perform some pre and post fixups to ensure
11+
* changes aren't wiped unnecessarily.
12+
*
1013
* @param ingestRundown NRCS version of the IngestRundown to copy from
11-
* @param ingestChanges A description of the changes that have been made to the rundown and should be propogated
14+
* @param ingestChanges A description of the changes that have been made to the rundown and should be propagated
1215
* @param options Options for how to apply the changes
1316
*/
1417
defaultApplyIngestChanges<TRundownPayload, TSegmentPayload, TPartPayload>(
@@ -19,9 +22,12 @@ export interface IProcessIngestDataContext extends IStudioContext {
1922
): void
2023

2124
/**
22-
* Group Parts in a MOS Rundown and return a new changes object
25+
* Group the Parts in a MOS Rundown and return a new changes object
2326
* This will group the Parts based on the segment name, using the separator provided to extract the segment name from the part name
24-
* Note: This ignores a lot of the contents of the `ingestChanges` object, and relies more on the `previousIngestRundown` instead
27+
*
28+
* Please note that this ignores some of the granularity of the `ingestChanges` object, and relies more on the `previousIngestRundown` instead
29+
* If you are using user operations, you may need to perform some pre and post fixups to ensure changes aren't wiped unnecessarily.
30+
*
2531
* @param ingestRundown The rundown whose parts needs grouping
2632
* @param previousIngestRundown The rundown prior to the changes, if known
2733
* @param ingestChanges The changes which have been performed in `ingestRundown`, that need to translating
@@ -37,7 +43,10 @@ export interface IProcessIngestDataContext extends IStudioContext {
3743

3844
/**
3945
* Group Parts in a Rundown and return a new changes object
40-
* Note: This ignores a lot of the contents of the `ingestChanges` object, and relies more on the `previousIngestRundown` instead
46+
*
47+
* Please note that this ignores some of the granularity of the `ingestChanges` object, and relies more on the `previousIngestRundown` instead
48+
* If you are using user operations, you may need to perform some pre and post fixups to ensure changes aren't wiped unnecessarily.
49+
*
4150
* @param ingestRundown The rundown whose parts needs grouping
4251
* @param previousIngestRundown The rundown prior to the changes, if known
4352
* @param ingestChanges The changes which have been performed in `ingestRundown`, that need to translating

packages/blueprints-integration/src/ingest-types.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,39 @@ export interface SofieIngestRundown<TRundownPayload = unknown, TSegmentPayload =
99
/** Array of segments in this rundown */
1010
segments: SofieIngestSegment<TSegmentPayload, TPartPayload>[]
1111

12-
/** States for UserEdits, could be lock from NRCS updates,
13-
* lock from user changes,
14-
* or removedByUser
15-
* */
12+
/**
13+
* The userEditStates is a key-value store where Blueprints can store persistent data.
14+
*
15+
* Examples of use cases;
16+
* - locks from NRCS updates
17+
* - locks from user changes
18+
* - removedByUser flags
19+
*/
1620
userEditStates: Record<string, boolean>
1721
}
1822
export interface SofieIngestSegment<TSegmentPayload = unknown, TPartPayload = unknown>
1923
extends IngestSegment<TSegmentPayload, TPartPayload> {
2024
/** Array of parts in this segment */
2125
parts: SofieIngestPart<TPartPayload>[]
2226

23-
/** States for UserEdits, could be lock from NRCS updates,
24-
* lock from user changes,
25-
* or removedByUser
26-
* */
27+
/**
28+
* The userEditStates is a key-value store where Blueprints can store persistent data.
29+
*
30+
* Examples of use cases;
31+
* - locks from NRCS updates
32+
* - locks from user changes
33+
* - removedByUser flags
34+
*/
2735
userEditStates: Record<string, boolean>
2836
}
2937
export interface SofieIngestPart<TPayload = unknown> extends IngestPart<TPayload> {
30-
/** States for UserEdits, could be lock from NRCS updates,
31-
* lock from user changes,
32-
* or removedByUser
33-
* */
38+
/**
39+
* The userEditStates is a key-value store where Blueprints can store persistent data.
40+
*
41+
* Examples of use cases;
42+
* - locks from NRCS updates
43+
* - locks from user changes
44+
* - removedByUser flags
45+
*/
3446
userEditStates: Record<string, boolean>
3547
}

packages/blueprints-integration/src/ingest.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ export interface UserOperationChange<TCustomBlueprintOperations extends { id: st
136136
operationTarget: UserOperationTarget
137137
operation: DefaultUserOperations | TCustomBlueprintOperations
138138
}
139-
139+
/**
140+
* The MutableIngestRundown is used to modify the contents of an IngestRundown during ingest.
141+
* The public properties and methods are used i blueprints to selectively apply incoming
142+
* or apply user operations to the SofieIngestRundown.
143+
*/
140144
export interface MutableIngestRundown<TRundownPayload = unknown, TSegmentPayload = unknown, TPartPayload = unknown> {
141145
/** Id of the rundown as reported by the ingest gateway. Must be unique for each rundown owned by the gateway */
142146
readonly externalId: string
@@ -172,6 +176,10 @@ export interface MutableIngestRundown<TRundownPayload = unknown, TSegmentPayload
172176
}
173177
| undefined
174178

179+
/**
180+
* Returns a Segment with a certain externalId
181+
* @param segmentExternalId
182+
*/
175183
getSegment(segmentExternalId: string): MutableIngestSegment<TSegmentPayload, TPartPayload> | undefined
176184

177185
/**
@@ -261,6 +269,9 @@ export interface MutableIngestRundown<TRundownPayload = unknown, TSegmentPayload
261269
value: ReadonlyDeep<TRundownPayload[TKey]> | TRundownPayload[TKey]
262270
): void
263271

272+
/**
273+
* Set a value in the userEditState
274+
*/
264275
setUserEditState(key: string, value: boolean): void
265276
}
266277

packages/corelib/src/dataModel/NrcsIngestDataCache.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { IngestRundown, IngestSegment, IngestPart } from '@sofie-automation/blue
22
import { NrcsIngestDataCacheObjId, RundownId, SegmentId, PartId } from './Ids'
33
import { RundownSource } from './Rundown'
44

5+
/*
6+
The NRCSIngestDataCache collection is used to store raw data that comes from an NRCS.
7+
See also ./SofieIngestDataCache.ts
8+
For where the ingested data is stored after being processed/modified by Sofie.
9+
*/
10+
511
export enum NrcsIngestCacheType {
612
RUNDOWN = 'rundown',
713
SEGMENT = 'segment',

packages/corelib/src/dataModel/SofieIngestDataCache.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { SofieIngestRundown, SofieIngestSegment, SofieIngestPart } from '@sofie-
22
import { SofieIngestDataCacheObjId, RundownId, SegmentId, PartId } from './Ids'
33
import { RundownSource } from './Rundown'
44

5+
/*
6+
The SofieIngestDataCache collection is used to store data that comes from an NRCS and has been modified by Sofie.
7+
See also ./NrcsIngestDataCache.ts for the raw data from the NRCS.
8+
*/
9+
510
export enum SofieIngestCacheType {
611
RUNDOWN = 'rundown',
712
SEGMENT = 'segment',

packages/job-worker/src/blueprints/context/ProcessIngestDataContext.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { StudioContext } from './StudioContext'
1111
import { defaultApplyIngestChanges } from '../ingest/defaultApplyIngestChanges'
1212
import { groupMosPartsIntoIngestSegments, groupPartsInRundownAndChanges } from '../ingest/groupPartsInRundownAndChanges'
1313

14+
/**
15+
* Provides a context for blueprints while running the blueprints.processIngestData() method.
16+
* Note: This provides some common helpers for doing mutations of the IngestRundown.
17+
* Custom updates of the IngestRundown are done by calling methods on the mutableIngestRundown itself.
18+
*/
1419
export class ProcessIngestDataContext extends StudioContext implements IProcessIngestDataContext {
1520
defaultApplyIngestChanges<TRundownPayload, TSegmentPayload, TPartPayload>(
1621
mutableIngestRundown: MutableIngestRundown<TRundownPayload, TSegmentPayload, TPartPayload>,

packages/job-worker/src/blueprints/context/lib.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ export function translateUserEditsFromBlueprint(
562562
)
563563
}
564564

565+
/**
566+
* Converts a BlueprintMutatablePart into a PlayoutMutatablePart
567+
*/
565568
export function convertPartialBlueprintMutablePartToCore(
566569
updatePart: Partial<IBlueprintMutatablePart>,
567570
blueprintId: BlueprintId

0 commit comments

Comments
 (0)