Skip to content

Commit

Permalink
wip: update to r50 - copy unexported types from Core
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Mar 8, 2024
1 parent 287e1c5 commit 93aae76
Show file tree
Hide file tree
Showing 9 changed files with 6,897 additions and 9,042 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ downloads
credentials.json
token.json
.env
.vscode/settings.json
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@
"@sofie-automation/shared-lib": "^1.50.0",
"clone": "^2.1.2",
"dotenv": "^16.4.5",
"fast-clone": "^1.5.13",
"googleapis": "^133.0.0",
"lodash": "^4.17.21",
"marked": "^12.0.1",
"object-path": "^0.11.8",
"request": "^2.88.2",
"request-promise": "^4.2.6",
"type-fest": "^4.11.1",
"underscore": "^1.13.6",
"uuid": "^9.0.1",
"winston": "^3.12.0"
Expand All @@ -85,6 +88,7 @@
"@types/clone": "^2.1.4",
"@types/jest": "^28.0.3",
"@types/node": "^18.19.1",
"@types/object-path": "^0.11.4",
"@types/request-promise": "^4.1.51",
"@types/underscore": "^1.11.15",
"@types/uuid": "^9.0.8",
Expand Down
2 changes: 1 addition & 1 deletion src/classes/media.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface MediaDict {
export type MediaDict = {
[id: string]: MediaInfo
}

Expand Down
22 changes: 14 additions & 8 deletions src/coreHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import { MediaDict } from './classes/media'
import { IOutputLayer } from '@sofie-automation/blueprints-integration'
import { SPREADSHEET_DEVICE_CONFIG_MANIFEST } from './configManifest'
import { SpreadsheetHandler } from './spreadsheetHandler'
import { MediaObject } from '@sofie-automation/shared-lib/dist/core/model/MediaObjects'
import { DBShowStyleBase } from './sofie-core-copy/dataModel/ShowStyleBase'
import { DBStudio } from './sofie-core-copy/dataModel/Studio'
import { applyAndValidateOverrides } from './sofie-core-copy/objectWithOverrides'
export interface CoreConfig {
host: string
port: number
Expand Down Expand Up @@ -374,7 +378,7 @@ export class CoreHandler {

const addedChanged = (id: string) => {
// Check collection exists.
const media = this.core.getCollection('mediaObjects')
const media = this.core.getCollection<MediaObject>('mediaObjects')
if (!media) throw Error('"mediaObjects" collection not found!')

// Add file path to list.
Expand Down Expand Up @@ -450,20 +454,22 @@ export class CoreHandler {
this._observers.push(observerStudios)

const addedChanged = () => {
const showStyles = this.core.getCollection('showStyleBases')
const showStyles = this.core.getCollection<DBShowStyleBase>('showStyleBases')
if (!showStyles) throw Error('"showStyleBases" collection not found!')

const studios = this.core.getCollection('studios')
const studios = this.core.getCollection<DBStudio>('studios')
if (!studios) throw Error('"studios" collection not found!')

const studio = studios.findOne(protectString(this._studioId || ''))
const studio = this._studioId ? studios.findOne(protectString(this._studioId)) : undefined
if (studio) {
this._outputLayers = []

showStyles.find({}).forEach((style: any) => {
if ((studio['supportedShowStyleBase'] as Array<string>).indexOf(style._id) !== 1) {
;(style['outputLayers'] as IOutputLayer[]).forEach((layer) => {
if (!layer.isPGM) {
showStyles.find({}).forEach((style) => {
if (studio.supportedShowStyleBase.indexOf(style._id) !== 1) {
Object.values<IOutputLayer | undefined>(
applyAndValidateOverrides(style.outputLayersWithOverrides).obj
).forEach((layer) => {
if (layer && !layer.isPGM) {
this._outputLayers.push(layer)
}
})
Expand Down
63 changes: 63 additions & 0 deletions src/sofie-core-copy/dataModel/ShowStyleBase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { IBlueprintConfig, IOutputLayer, ISourceLayer, SourceLayerType } from '@sofie-automation/blueprints-integration'
import { ObjectWithOverrides } from '../objectWithOverrides'
// import { BlueprintHash, LastBlueprintConfig } from './Blueprint'
import {
// BlueprintId, OrganizationId,
ShowStyleBaseId,
} from '@sofie-automation/shared-lib/dist/core/model/Ids'

export interface HotkeyDefinition {
_id: string
/** Reference to the hotkey in Sofie */
key: string
/** Label of the key, to be displayed in GUI */
label: string

// --------- Note: The properties below are used in a TV2-only feature --------------

/** Alternate hotkey that can be used through AutoHotKey, after importing the script */
platformKey?: string
/** Used for the color */
sourceLayerType?: SourceLayerType
/** Alternate color */
buttonColor?: string
up?: (e: any) => void
down?: (e: any) => void
}

export type OutputLayers = Record<string, IOutputLayer | undefined>
export type SourceLayers = Record<string, ISourceLayer | undefined>

export interface DBShowStyleBase {
_id: ShowStyleBaseId

/** Name of this show style */
name: string
/** Id of the blueprint used by this show-style */
// blueprintId: BlueprintId
/** Id of the blueprint config preset */
blueprintConfigPresetId?: string
/** Whether blueprintConfigPresetId is invalid, and does not match a currently exposed preset from the Blueprint */
blueprintConfigPresetIdUnlinked?: boolean

/** If set, the Organization that owns this ShowStyleBase */
// organizationId: OrganizationId | null

/** A list of hotkeys, used to display a legend of hotkeys for the user in GUI */
hotkeyLegend?: Array<HotkeyDefinition>

/** "Outputs" in the UI */
outputLayersWithOverrides: ObjectWithOverrides<OutputLayers>
/** "Layers" in the GUI */
sourceLayersWithOverrides: ObjectWithOverrides<SourceLayers>

/** Config values are used by the Blueprints */
blueprintConfigWithOverrides: ObjectWithOverrides<IBlueprintConfig>

_rundownVersionHash: string

/** Details on the last blueprint used to generate the defaults values for this */
// lastBlueprintConfig: LastBlueprintConfig | undefined
/** Last BlueprintHash where the fixupConfig method was run */
// lastBlueprintFixUpHash: BlueprintHash | undefined
}
212 changes: 212 additions & 0 deletions src/sofie-core-copy/dataModel/Studio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
import { BlueprintMapping, IBlueprintConfig, PackageContainer, TSR } from '@sofie-automation/blueprints-integration'
import { ObjectWithOverrides } from '../objectWithOverrides'
import {
StudioId,
// OrganizationId,
// BlueprintId,
ShowStyleBaseId,
MappingsHash,
PeripheralDeviceId,
} from '@sofie-automation/shared-lib/dist/core/model/Ids'
// import { BlueprintHash, LastBlueprintConfig } from './Blueprint'
import { MappingsExt } from '@sofie-automation/shared-lib/dist/core/model/Timeline'

// export { MappingsExt, MappingExt, MappingsHash }

export interface IStudioSettings {
/** The framerate (frames per second) used to convert internal timing information (in milliseconds)
* into timecodes and timecode-like strings and interpret timecode user input
* Default: 25
*/
frameRate: number

/** URL to endpoint where media preview are exposed */
mediaPreviewsUrl: string // (former media_previews_url in config)
/** URLs for slack webhook to send evaluations */
slackEvaluationUrls?: string // (former slack_evaluation in config)

/** Media Resolutions supported by the studio for media playback */
supportedMediaFormats?: string // (former mediaResolutions in config)
/** Audio Stream Formats supported by the studio for media playback */
supportedAudioStreams?: string // (former audioStreams in config)

/** Should the play from anywhere feature be enabled in this studio */
enablePlayFromAnywhere?: boolean

/**
* If set, forces the multi-playout-gateway mode (aka set "now"-time right away)
* for single playout-gateways setups
*/
forceMultiGatewayMode?: boolean

/** How much extra delay to add to the Now-time (used for the "multi-playout-gateway" feature) .
* A higher value adds delays in playout, but reduces the risk of missed frames. */
multiGatewayNowSafeLatency?: number

/** Allow resets while a rundown is on-air */
allowRundownResetOnAir?: boolean

/** Preserve unsynced segments psoition in the rundown, relative to the other segments */
preserveOrphanedSegmentPositionInRundown?: boolean

/**
* The minimum amount of time, in milliseconds, that must pass after a take before another take may be performed.
* Default: 1000
*/
minimumTakeSpan: number

/** Whether to allow scratchpad mode, before a Part is playing in a Playlist */
allowScratchpad?: boolean
}

export type StudioLight = Omit<DBStudio, 'mappingsWithOverrides' | 'blueprintConfigWithOverrides'>

/** A set of available layer groups in a given installation */
export interface DBStudio {
_id: StudioId
/** If set, this studio is owned by that organization */
// organizationId: OrganizationId | null

/** User-presentable name for the studio installation */
name: string
/** Id of the blueprint used by this studio-installation */
// blueprintId?: BlueprintId
/** Id of the blueprint config preset */
blueprintConfigPresetId?: string
/** Whether blueprintConfigPresetId is invalid, and does not match a currently exposed preset from the Blueprint */
blueprintConfigPresetIdUnlinked?: boolean

/** Mappings between the physical devices / outputs and logical ones */
mappingsWithOverrides: ObjectWithOverrides<MappingsExt>

/**
* A hash that is to be changed whenever there is a change to the mappings or routeSets
* The reason for this to exist is to be able to sync the timeline to what set of mappings it was created (routed) from.
*/
mappingsHash?: MappingsHash

/** List of which ShowStyleBases this studio wants to support */
supportedShowStyleBase: Array<ShowStyleBaseId>

/** Config values are used by the Blueprints */
blueprintConfigWithOverrides: ObjectWithOverrides<IBlueprintConfig>

settings: IStudioSettings

_rundownVersionHash: string

routeSets: Record<string, StudioRouteSet>
routeSetExclusivityGroups: Record<string, StudioRouteSetExclusivityGroup>

/** Contains settings for which Package Containers are present in the studio.
* (These are used by the Package Manager and the Expected Packages)
*/
packageContainers: Record<string, StudioPackageContainer>

/** Which package containers is used for media previews in GUI */
previewContainerIds: string[]
thumbnailContainerIds: string[]

peripheralDeviceSettings: StudioPeripheralDeviceSettings

/** Details on the last blueprint used to generate the defaults values for this */
// lastBlueprintConfig: LastBlueprintConfig | undefined
/** Last BlueprintHash where the fixupConfig method was run */
// lastBlueprintFixUpHash: BlueprintHash | undefined
}

export interface StudioPeripheralDeviceSettings {
/** Playout gateway sub-devices */
playoutDevices: ObjectWithOverrides<Record<string, StudioPlayoutDevice>>

/** Ingest gateway sub-devices */
ingestDevices: ObjectWithOverrides<Record<string, StudioIngestDevice>>

/** Input gateway sub-devices */
inputDevices: ObjectWithOverrides<Record<string, StudioInputDevice>>
}

export interface StudioIngestDevice {
/**
* The id of the gateway this is assigned to
* Future: This may be replaced with some other grouping or way of assigning devices
*/
peripheralDeviceId: PeripheralDeviceId | undefined
/** Settings blob of the subdevice, from the sub-device config schema */
options: unknown
}

export interface StudioInputDevice {
/**
* The id of the gateway this is assigned to
* Future: This may be replaced with some other grouping or way of assigning devices
*/
peripheralDeviceId: PeripheralDeviceId | undefined
/** Settings blob of the subdevice, from the sub-device config schema */
options: unknown
}

export interface StudioPlayoutDevice {
/**
* The id of the gateway this is assigned to
* Future: This may be replaced with some other grouping or way of assigning devices
*/
peripheralDeviceId: PeripheralDeviceId | undefined

options: TSR.DeviceOptionsAny
}

export interface StudioPackageContainer {
/** List of which peripheraldevices uses this packageContainer */
deviceIds: string[]
container: PackageContainer
}
export interface StudioRouteSetExclusivityGroup {
name: string
}

export interface StudioRouteSet {
/** User-presentable name */
name: string
/** Whether this group is active or not */
active: boolean
/** Default state of this group */
defaultActive?: boolean
/** Only one Route can be active at the same time in the exclusivity-group */
exclusivityGroup?: string
/** If true, should be displayed and toggleable by user */
behavior: StudioRouteBehavior

routes: RouteMapping[]
}
export enum StudioRouteBehavior {
HIDDEN = 0,
TOGGLE = 1,
ACTIVATE_ONLY = 2,
}

export enum StudioRouteType {
/** Default */
REROUTE = 0,
/** Replace all properties with a new mapping */
REMAP = 1,
}

export interface RouteMapping extends ResultingMappingRoute {
/** Which original layer to route. If false, a "new" layer will be inserted during routing */
mappedLayer: string | undefined
}
export interface ResultingMappingRoutes {
/** Routes that route existing layers */
existing: {
[mappedLayer: string]: ResultingMappingRoute[]
}
/** Routes that create new layers, from nothing */
inserted: ResultingMappingRoute[]
}
export interface ResultingMappingRoute {
outputMappedLayer: string
deviceType?: TSR.DeviceType
remapping?: Partial<BlueprintMapping>
routeType: StudioRouteType
}
7 changes: 7 additions & 0 deletions src/sofie-core-copy/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import fastClone = require('fast-clone')
import { ReadonlyDeep } from 'type-fest'

export function clone<T>(o: ReadonlyDeep<T> | Readonly<T> | T): T {
// Use this instead of fast-clone directly, as this retains the type
return fastClone(o as any)
}
Loading

0 comments on commit 93aae76

Please sign in to comment.