@tv2media/v-connection
Advanced tools
Comparing version 4.0.3 to 5.0.0
@@ -16,2 +16,3 @@ import { VRundown, VTemplate, InternalElement, ExternalElement, VElement, ExternalElementId } from './v-connection'; | ||
constructor(mseRep: MSERep, show: string, profile: string, playlist: string, description: string); | ||
private static makeKey; | ||
private buildChannelMap; | ||
@@ -23,13 +24,13 @@ private ref; | ||
createElement(vcpid: number, channel?: string, alias?: string): Promise<ExternalElement>; | ||
listElements(): Promise<Array<string | number>>; | ||
listElements(): Promise<Array<string | ExternalElementId>>; | ||
activate(twice?: boolean, initShow?: boolean, initPlaylist?: boolean): Promise<CommandResult>; | ||
deactivate(cleanupShow?: boolean): Promise<CommandResult>; | ||
cleanup(): Promise<CommandResult>; | ||
deleteElement(elementName: string | number): Promise<PepResponse>; | ||
cue(elementName: string | number): Promise<CommandResult>; | ||
take(elementName: string | number): Promise<CommandResult>; | ||
continue(elementName: string | number): Promise<CommandResult>; | ||
continueReverse(elementName: string | number): Promise<CommandResult>; | ||
out(elementName: string | number): Promise<CommandResult>; | ||
initialize(elementName: number): Promise<CommandResult>; | ||
deleteElement(elementName: string | number, channel?: string): Promise<PepResponse>; | ||
cue(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
take(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
continue(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
continueReverse(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
out(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
initialize(elementName: number, channel?: string): Promise<CommandResult>; | ||
purge(elementsToKeep?: ExternalElementId[]): Promise<PepResponse>; | ||
@@ -36,0 +37,0 @@ getElement(elementName: string | number, channel?: string): Promise<VElement>; |
@@ -34,5 +34,8 @@ "use strict"; | ||
} | ||
async buildChannelMap(vcpid) { | ||
static makeKey(vcpid, channel) { | ||
return `${vcpid}_${channel || ''}`; | ||
} | ||
async buildChannelMap(vcpid, channel) { | ||
if (typeof vcpid === 'number') { | ||
if (Object.prototype.hasOwnProperty.call(this.channelMap, vcpid)) { | ||
if (Object.prototype.hasOwnProperty.call(this.channelMap, Rundown.makeKey(vcpid, channel))) { | ||
return true; | ||
@@ -42,29 +45,23 @@ } | ||
await this.mse.checkConnection(); | ||
const elements = vcpid ? [vcpid] : await this.listElements(); | ||
const elements = vcpid ? [{ vcpid, channel }] : await this.listElements(); | ||
for (const e of elements) { | ||
if (typeof e === 'number') { | ||
const element = await this.getElement(e); | ||
if (element.channel) { | ||
this.channelMap[e] = { | ||
channelName: element.channel, | ||
refName: Object.prototype.hasOwnProperty.call(element, 'name') && typeof element.name === 'string' | ||
? element.name | ||
: 'ref', | ||
}; | ||
} | ||
else { | ||
this.channelMap[e] = { | ||
channelName: null, | ||
refName: Object.prototype.hasOwnProperty.call(element, 'name') && typeof element.name === 'string' | ||
? element.name | ||
: 'ref', | ||
}; | ||
} | ||
if (typeof e !== 'string') { | ||
const element = await this.getElement(e.vcpid, e.channel); | ||
this.channelMap[Rundown.makeKey(e.vcpid, e.channel)] = { | ||
vcpid: e.vcpid, | ||
channel: element.channel, | ||
refName: Object.prototype.hasOwnProperty.call(element, 'name') && typeof element.name === 'string' | ||
? element.name | ||
: 'ref', | ||
}; | ||
} | ||
} | ||
return typeof vcpid === 'number' ? Object.prototype.hasOwnProperty.call(this.channelMap, vcpid) : false; | ||
return typeof vcpid === 'number' | ||
? Object.prototype.hasOwnProperty.call(this.channelMap, Rundown.makeKey(vcpid, channel)) | ||
: false; | ||
} | ||
ref(id) { | ||
ref(vcpid, channel) { | ||
var _a; | ||
return ((_a = this.channelMap[id]) === null || _a === void 0 ? void 0 : _a.refName) ? this.channelMap[id].refName.replace('#', '%23') : 'ref'; | ||
const key = Rundown.makeKey(vcpid, channel); | ||
return ((_a = this.channelMap[key]) === null || _a === void 0 ? void 0 : _a.refName) ? this.channelMap[key].refName.replace('#', '%23') : 'ref'; | ||
} | ||
@@ -156,4 +153,5 @@ async listTemplates() { | ||
const { body: path } = await this.pep.insert(`/storage/playlists/{${this.playlist}}/elements/`, `<ref available="0.00" loaded="0.00" take_count="0"${vizProgram}>/external/pilotdb/elements/${nameOrID}</ref>`, peptalk_1.LocationType.Last); | ||
this.channelMap[nameOrID] = { | ||
channelName: elementNameOrChannel ? elementNameOrChannel : null, | ||
this.channelMap[Rundown.makeKey(nameOrID, elementNameOrChannel)] = { | ||
vcpid: nameOrID, | ||
channel: elementNameOrChannel, | ||
refName: path ? path.slice(path.lastIndexOf('/') + 1) : 'ref', | ||
@@ -179,5 +177,6 @@ }; | ||
? Object.keys(flatPlaylistElements.elements).map((k) => { | ||
const ref = flatPlaylistElements.elements[k].value; | ||
const entry = flatPlaylistElements.elements[k]; | ||
const ref = entry.value; | ||
const lastSlash = ref.lastIndexOf('/'); | ||
return +ref.slice(lastSlash + 1); | ||
return { vcpid: +ref.slice(lastSlash + 1), channel: entry.viz_program }; | ||
}) | ||
@@ -217,3 +216,3 @@ : []; | ||
} | ||
async deleteElement(elementName) { | ||
async deleteElement(elementName, channel) { | ||
if (typeof elementName === 'string') { | ||
@@ -223,11 +222,11 @@ return this.pep.delete(`/storage/shows/{${this.show}}/elements/${elementName}`); | ||
else { | ||
if (await this.buildChannelMap(elementName)) { | ||
return this.pep.delete(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
if (await this.buildChannelMap(elementName, channel)) { | ||
return this.pep.delete(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
else { | ||
throw new peptalk_1.InexistentError(-1, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
throw new peptalk_1.InexistentError(-1, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
} | ||
} | ||
async cue(elementName) { | ||
async cue(elementName, channel) { | ||
if (typeof elementName === 'string') { | ||
@@ -237,11 +236,11 @@ return this.msehttp.cue(`/storage/shows/{${this.show}}/elements/${elementName}`); | ||
else { | ||
if (await this.buildChannelMap(elementName)) { | ||
return this.msehttp.cue(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
if (await this.buildChannelMap(elementName, channel)) { | ||
return this.msehttp.cue(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
else { | ||
throw new msehttp_1.HTTPRequestError(`Cannot cue external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
throw new msehttp_1.HTTPRequestError(`Cannot cue external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
} | ||
} | ||
async take(elementName) { | ||
async take(elementName, channel) { | ||
if (typeof elementName === 'string') { | ||
@@ -251,11 +250,11 @@ return this.msehttp.take(`/storage/shows/{${this.show}}/elements/${elementName}`); | ||
else { | ||
if (await this.buildChannelMap(elementName)) { | ||
return this.msehttp.take(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
if (await this.buildChannelMap(elementName, channel)) { | ||
return this.msehttp.take(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
else { | ||
throw new msehttp_1.HTTPRequestError(`Cannot take external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
throw new msehttp_1.HTTPRequestError(`Cannot take external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
} | ||
} | ||
async continue(elementName) { | ||
async continue(elementName, channel) { | ||
if (typeof elementName === 'string') { | ||
@@ -265,11 +264,11 @@ return this.msehttp.continue(`/storage/shows/{${this.show}}/elements/${elementName}`); | ||
else { | ||
if (await this.buildChannelMap(elementName)) { | ||
return this.msehttp.continue(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
if (await this.buildChannelMap(elementName, channel)) { | ||
return this.msehttp.continue(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
else { | ||
throw new msehttp_1.HTTPRequestError(`Cannot continue external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
throw new msehttp_1.HTTPRequestError(`Cannot continue external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
} | ||
} | ||
async continueReverse(elementName) { | ||
async continueReverse(elementName, channel) { | ||
if (typeof elementName === 'string') { | ||
@@ -279,11 +278,11 @@ return this.msehttp.continueReverse(`/storage/shows/{${this.show}}/elements/${elementName}`); | ||
else { | ||
if (await this.buildChannelMap(elementName)) { | ||
return this.msehttp.continueReverse(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
if (await this.buildChannelMap(elementName, channel)) { | ||
return this.msehttp.continueReverse(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
else { | ||
throw new msehttp_1.HTTPRequestError(`Cannot continue reverse external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
throw new msehttp_1.HTTPRequestError(`Cannot continue reverse external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
} | ||
} | ||
async out(elementName) { | ||
async out(elementName, channel) { | ||
if (typeof elementName === 'string') { | ||
@@ -293,20 +292,19 @@ return this.msehttp.out(`/storage/shows/{${this.show}}/elements/${elementName}`); | ||
else { | ||
if (await this.buildChannelMap(elementName)) { | ||
return this.msehttp.out(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
if (await this.buildChannelMap(elementName, channel)) { | ||
return this.msehttp.out(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
else { | ||
throw new msehttp_1.HTTPRequestError(`Cannot take out external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
throw new msehttp_1.HTTPRequestError(`Cannot take out external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
} | ||
} | ||
async initialize(elementName) { | ||
if (await this.buildChannelMap(elementName)) { | ||
return this.msehttp.initialize(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
async initialize(elementName, channel) { | ||
if (await this.buildChannelMap(elementName, channel)) { | ||
return this.msehttp.initialize(`/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
else { | ||
throw new msehttp_1.HTTPRequestError(`Cannot initialize external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName)}`); | ||
throw new msehttp_1.HTTPRequestError(`Cannot initialize external element as ID '${elementName}' is not known in this rundown.`, this.msehttp.baseURL, `/storage/playlists/{${this.playlist}}/elements/${this.ref(elementName, channel)}`); | ||
} | ||
} | ||
async purge(elementsToKeep) { | ||
var _a; | ||
// let playlist = await this.mse.getPlaylist(this.playlist) | ||
@@ -320,8 +318,8 @@ // if (playlist.active_profile.value) { | ||
const elementsSet = new Set(elementsToKeep.map((e) => { | ||
return `${e.vcpid}_${e.channelName}`; | ||
return Rundown.makeKey(e.vcpid, e.channel); | ||
})); | ||
for (const vcpid in this.channelMap) { | ||
if (!elementsSet.has(`${vcpid}_${(_a = this.channelMap[vcpid]) === null || _a === void 0 ? void 0 : _a.channelName}`)) { | ||
for (const key in this.channelMap) { | ||
if (!elementsSet.has(key)) { | ||
try { | ||
await this.deleteElement(Number(vcpid)); | ||
await this.deleteElement(this.channelMap[key].vcpid, this.channelMap[key].channel); | ||
} | ||
@@ -328,0 +326,0 @@ catch (e) { |
@@ -103,6 +103,10 @@ /** | ||
} | ||
/** Object uniquely identifying an element loaded into an Engine */ | ||
/** Object uniquely identifying an external element loaded into an Engine */ | ||
export interface ExternalElementId { | ||
/** Unique identifier for the template in the external system. */ | ||
vcpid: number; | ||
channelName?: string; | ||
/** Optional channel specifier used to define which Viz Engines the graphics play on. | ||
* Note when `undefined`, the default is the _program_ channel. | ||
*/ | ||
channel?: string; | ||
} | ||
@@ -163,49 +167,56 @@ /** | ||
*/ | ||
listElements(): Promise<Array<string | number>>; | ||
listElements(): Promise<Array<string | ExternalElementId>>; | ||
/** | ||
* Read the details of a graphical element in this rundown. | ||
* @param elementName Name or reference for the element to retrieve the details | ||
* @param elementName Name or reference (vcpid) for the element to retrieve the details | ||
* for. | ||
* @param channel Optional channel to play out this graphic. Default is the _program_. | ||
* @returns Resolves to provide the details of the named element. | ||
*/ | ||
getElement(elementName: string | number): Promise<VElement>; | ||
getElement(elementName: string | number, channel?: string): Promise<VElement>; | ||
/** | ||
* Delete a graphical element from the rundown. | ||
* @param elementName Name of reference for the element to delete. | ||
* @param elementName Name or reference (vcpid) for the element to delete. | ||
* @param channel Optional channel to play out this graphic. Default is the _program_. | ||
* @returns Resolves to indicate the delete was successful, otherwise rejects. | ||
*/ | ||
deleteElement(elementName: string | number): Promise<PepResponse>; | ||
deleteElement(elementName: string | number, channel?: string): Promise<PepResponse>; | ||
/** | ||
* Send a _cue_ command for a named graphical element, preparing it for smooth display. | ||
* @param elementName Name or reference for the gephical element to cue. | ||
* @param elementName Name or reference (vcpid) for the gephical element to cue. | ||
* @param channel Optional channel to play out this graphic. Default is the _program_. | ||
* @returns Resolves on acceptance of the cue command. | ||
*/ | ||
cue(elementName: string | number): Promise<CommandResult>; | ||
cue(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
/** | ||
* Send a _take_ command for a named graphical element, requesting that it is displayed. | ||
* @param elementName Name or reference for the gephical element to take in. | ||
* @param elementName Name or reference (vcpid) for the gephical element to take in. | ||
* @param channel Optional channel to play out this graphic. Default is the _program_. | ||
* @returns Resolves on acceptance of the take command. | ||
*/ | ||
take(elementName: string | number): Promise<CommandResult>; | ||
take(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
/** | ||
* Send a _continue_ command for a named graphical element, causing the next | ||
* presentation state is to be displayed. | ||
* @param elementName Name or reference for the gephical element to continue. | ||
* @param elementName Name or reference (vcpid) for the gephical element to continue. | ||
* @param channel Optional channel to play out this graphic. Default is the _program_. | ||
* @returns Resolves on acceptance of the continue command. | ||
*/ | ||
continue(elementName: string | number): Promise<CommandResult>; | ||
continue(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
/** | ||
* Send a _continue-reverse_ command for a named graphical element, causing the | ||
* previous presentation state is to be displayed. | ||
* @param elementName Name or reference for the gephical element to continue. | ||
* @param elementName Name or reference (vcpid) for the gephical element to continue. | ||
* @param channel Optional channel to play out this graphic. Default is the _program_. | ||
* @returns Resolves on acceptance of the continue command. | ||
*/ | ||
continueReverse(elementName: string | number): Promise<CommandResult>; | ||
continueReverse(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
/** | ||
* Send an _out_ command for the named graphical element, ending its ongoing | ||
* display. | ||
* @param elementName Name or reference for the graphical element to take-out. | ||
* @param elementName Name or reference (vcpid) for the graphical element to take-out. | ||
* @param channel Optional channel to play out this graphic. Default is the _program_. | ||
* @return Resolves on acceptance of the take-out command. | ||
*/ | ||
out(elementName: string | number): Promise<CommandResult>; | ||
out(elementName: string | number, channel?: string): Promise<CommandResult>; | ||
/** | ||
@@ -216,7 +227,8 @@ * Run the initiaization of an external graphic element. This will cause the | ||
* playlist to know when it is safe to take the element. | ||
* @param elementName Reference for the graphical element to initialize. | ||
* @param vcpid Reference for the graphical element to initialize. | ||
* @param channel Optional channel to play out this graphic. Default is the _program_. | ||
* @returns Resolves on acceptance of the initialize command. Note that this | ||
* is not when the element finishes loading on the VizEngine. | ||
*/ | ||
initialize(elementName: number): Promise<CommandResult>; | ||
initialize(vcpid: number, channel?: string): Promise<CommandResult>; | ||
/** | ||
@@ -223,0 +235,0 @@ * Activate a rundown, causing all initialisations to be requested prior to |
{ | ||
"name": "@tv2media/v-connection", | ||
"version": "4.0.3", | ||
"version": "5.0.0", | ||
"description": "Sofie TV Automation Vizrt Media Sequencer Engine connection library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
169652
2442
0