You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

mos-connection

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mos-connection - npm Package Compare versions

Comparing version

to
1.0.5-0

@@ -5,2 +5,18 @@ # Changelog

### [1.0.5-0](https://github.com/nrkno/tv-automation-mos-connection/compare/1.0.3...1.0.5-0) (2021-11-18)
### Bug Fixes
* remove debugTrace of heartbeats, to reduce logging amount [release] ([c82e09b](https://github.com/nrkno/tv-automation-mos-connection/commit/c82e09b9756347ae9d1f8625e055ad575698264a))
* remove debugTrace to remove duplicate logs (since rawMessage is also emitted there) ([b2f1a27](https://github.com/nrkno/tv-automation-mos-connection/commit/b2f1a27dd564358602d323148eb0cf032edd993d))
### [1.0.4](https://github.com/nrkno/tv-automation-mos-connection/compare/1.0.3...1.0.4) (2021-09-21)
### Bug Fixes
* remove debugTrace of heartbeats, to reduce logging amount [release] ([c82e09b](https://github.com/nrkno/tv-automation-mos-connection/commit/c82e09b9756347ae9d1f8625e055ad575698264a))
* remove debugTrace to remove duplicate logs (since rawMessage is also emitted there) ([b2f1a27](https://github.com/nrkno/tv-automation-mos-connection/commit/b2f1a27dd564358602d323148eb0cf032edd993d))
### [1.0.3](https://github.com/nrkno/tv-automation-mos-connection/compare/1.0.2...1.0.3) (2021-08-16)

@@ -7,0 +23,0 @@

@@ -779,1 +779,2 @@ import { IProfiles } from './config/connectionConfig';

}
//# sourceMappingURL=api.d.ts.map

@@ -9,3 +9,3 @@ "use strict";

IMOSObjectType["VIDEO"] = "VIDEO";
IMOSObjectType["OTHER"] = "OTHER"; // unknown/not speficied
IMOSObjectType["OTHER"] = "OTHER";
})(IMOSObjectType = exports.IMOSObjectType || (exports.IMOSObjectType = {}));

@@ -12,0 +12,0 @@ var IMOSObjectStatus;

@@ -36,1 +36,2 @@ import { IConnectionConfig, IMOSDeviceConnectionOptions } from '../api';

}
//# sourceMappingURL=connectionConfig.d.ts.map

@@ -14,3 +14,3 @@ "use strict";

'6': false,
'7': false
'7': false,
};

@@ -17,0 +17,0 @@ /* tslint:disable */

@@ -12,1 +12,2 @@ /// <reference types="node" />

}
//# sourceMappingURL=mosMessageParser.d.ts.map

@@ -5,3 +5,3 @@ /// <reference types="node" />

import { HandedOverQueue } from './NCSServerConnection';
export declare type CallBackFunction = (err: any, data: object) => void;
export declare type CallBackFunction = (err: any, data: unknown) => void;
export interface QueueMessage {

@@ -25,3 +25,2 @@ time: number;

private _connectionAttemptTimer;
private _commandTimeoutTimer;
private _commandTimeout;

@@ -34,3 +33,3 @@ private _queueCallback;

private _timedOutCommands;
private processQueueTimeout;
private processQueueTimeout?;
private _disposed;

@@ -62,3 +61,3 @@ private messageParser;

*/
log(args: any): void;
log(args: string | number | any): void;
setDebug(debug: boolean): void;

@@ -77,3 +76,2 @@ /** */

/** */
/** */
private _onConnected;

@@ -90,1 +88,2 @@ /** */

}
//# sourceMappingURL=mosSocketClient.d.ts.map

@@ -19,2 +19,3 @@ "use strict";

this._connected = false;
this._lastConnectionAttempt = 0;
this._reconnectAttempt = 0;

@@ -58,3 +59,4 @@ this._queueCallback = {};

// throttling attempts
if (!this._lastConnectionAttempt || (Date.now() - this._lastConnectionAttempt) >= this._reconnectDelay) { // !_lastReconnectionAttempt (means first attempt) OR time > _reconnectionDelay since last attempt
if (!this._lastConnectionAttempt || Date.now() - this._lastConnectionAttempt >= this._reconnectDelay) {
// !_lastReconnectionAttempt (means first attempt) OR time > _reconnectionDelay since last attempt
// recreate client if new attempt:

@@ -105,5 +107,7 @@ if (this._client && this._client.connecting) {

if (!this._sentMessage && this.connected) {
if (this.processQueueTimeout)
if (this.processQueueTimeout) {
clearTimeout(this.processQueueTimeout);
let message = this._queueMessages.shift();
delete this.processQueueTimeout;
}
const message = this._queueMessages.shift();
if (message) {

@@ -118,15 +122,20 @@ // Send the message:

else {
if (!this._sentMessage && this._queueMessages.length > 0) {
if (!this._sentMessage) {
if (Date.now() - this._queueMessages[0].time > this._commandTimeout) {
const msg = this._queueMessages.shift();
this._queueCallback[msg.msg.messageID]('Command timed out', {});
delete this._queueCallback[msg.msg.messageID];
this.processQueue();
if (msg) {
this._queueCallback[msg.msg.messageID]('Command timed out', {});
delete this._queueCallback[msg.msg.messageID];
this.processQueue();
}
}
else {
// Try again later:
clearTimeout(this.processQueueTimeout);
this.processQueueTimeout = setTimeout(() => {
this.processQueue();
}, 200);
if (this._queueMessages.length > 0) {
// Try again later:
if (this.processQueueTimeout)
clearTimeout(this.processQueueTimeout);
this.processQueueTimeout = setTimeout(() => {
this.processQueue();
}, 200);
}
}

@@ -144,3 +153,3 @@ }

messages: this._queueMessages,
callbacks: this._queueCallback
callbacks: this._queueCallback,
};

@@ -150,3 +159,4 @@ if (this._sentMessage && this._sentMessage.msg instanceof mosModel_1.HeartBeat) {

this._lingeringMessage = this._sentMessage;
this._lingeringCallback[this._sentMessage.msg.messageID + ''] = this._queueCallback[this._sentMessage.msg.messageID + ''];
this._lingeringCallback[this._sentMessage.msg.messageID + ''] =
this._queueCallback[this._sentMessage.msg.messageID + ''];
}

@@ -160,3 +170,6 @@ else if (this._lingeringMessage) {

this._sentMessage = null;
clearTimeout(this.processQueueTimeout);
if (this.processQueueTimeout) {
clearTimeout(this.processQueueTimeout);
delete this.processQueueTimeout;
}
return queue;

@@ -186,3 +199,5 @@ }

if (this._client) {
this._client.once('close', () => { this.emit(socketConnection_1.SocketConnectionEvent.DISPOSED); });
this._client.once('close', () => {
this.emit(socketConnection_1.SocketConnectionEvent.DISPOSED);
});
this._client.end();

@@ -213,3 +228,3 @@ this._client.destroy();

_sendReply(messageId, err, res) {
let cb = this._queueCallback[messageId + ''] || this._lingeringCallback[messageId + ''];
const cb = this._queueCallback[messageId + ''] || this._lingeringCallback[messageId + ''];
if (cb) {

@@ -235,7 +250,7 @@ cb(err, res);

this._lingeringMessage = null;
let sentMessageId = message.msg.messageID;
const sentMessageId = message.msg.messageID;
// this.debugTrace('executeCommand', message)
// message.prepare() // @todo, is prepared? is sent already? logic needed
let messageString = message.msg.toString();
let buf = iconv.encode(messageString, 'utf16-be');
const messageString = message.msg.toString();
const buf = iconv.encode(messageString, 'utf16-be');
// this.debugTrace('sending',this._client.name, str)

@@ -261,3 +276,2 @@ // Command timeout:

this._client.write(buf, 'ucs2');
this.debugTrace(`MOS command sent from ${this._description} : ${messageString}\r\nbytes sent: ${this._client.bytesWritten}`);
this.emit('rawMessage', 'sent', messageString);

@@ -268,4 +282,6 @@ }

if (this._autoReconnect) {
if (this._reconnectAttempts > -1) { // no reconnection if no valid reconnectionAttemps is set
if (this._reconnectAttempts > 0 && (this._reconnectAttempt >= this._reconnectAttempts)) { // if current attempt is not less than max attempts
if (this._reconnectAttempts > -1) {
// no reconnection if no valid reconnectionAttemps is set
if (this._reconnectAttempts > 0 && this._reconnectAttempt >= this._reconnectAttempts) {
// if current attempt is not less than max attempts
// reset reconnection behaviour

@@ -292,7 +308,2 @@ this._clearConnectionAttemptTimer();

/** */
// private _onUnhandledCommandTimeout () {
// global.clearTimeout(this._commandTimeoutTimer)
// this.emit(SocketConnectionEvent.TIMEOUT)
// }
/** */
_onConnected() {

@@ -310,3 +321,2 @@ this.emit(socketConnection_1.SocketConnectionEvent.ALIVE);

this.emit('rawMessage', 'recieved', messageString);
this.debugTrace(`${this._description} Received: ${messageString}`);
try {

@@ -320,7 +330,7 @@ this.messageParser.parseMessage(messageString);

_handleMessage(parsedData, messageString) {
let messageId = parsedData.mos.messageID;
const messageId = parsedData.mos.messageID;
if (messageId) {
let sentMessage = this._sentMessage || this._lingeringMessage;
const sentMessage = this._sentMessage || this._lingeringMessage;
if (sentMessage) {
if (sentMessage.msg.messageID.toString() === (messageId + '')) {
if (sentMessage.msg.messageID.toString() === messageId + '') {
this._sendReply(sentMessage.msg.messageID, null, parsedData);

@@ -336,3 +346,3 @@ }

else if (this._timedOutCommands[messageId]) {
this.debugTrace(`Got a reply (${messageId}), but command timed out ${(Date.now() - this._timedOutCommands[messageId])} ms ago`, messageString);
this.debugTrace(`Got a reply (${messageId}), but command timed out ${Date.now() - this._timedOutCommands[messageId]} ms ago`, messageString);
delete this._timedOutCommands[messageId];

@@ -345,3 +355,2 @@ }

}
clearTimeout(this._commandTimeoutTimer);
}

@@ -351,3 +360,5 @@ else {

if (parsedData.mos.mosAck && parsedData.mos.mosAck.status === 'NACK') {
if (this._sentMessage && parsedData.mos.mosAck.statusDescription === 'Buddy server cannot respond because main server is available') {
if (this._sentMessage &&
parsedData.mos.mosAck.statusDescription ===
'Buddy server cannot respond because main server is available') {
this._sendReply(this._sentMessage.msg.messageID, 'Main server available', parsedData);

@@ -399,3 +410,3 @@ }

for (let i = this._queueMessages.length - 1; i >= 0; i--) {
let message = this._queueMessages[i];
const message = this._queueMessages[i];
if (Date.now() - message.time > this._commandTimeout) {

@@ -402,0 +413,0 @@ this._sendReply(message.msg.messageID, Error('Command Timeout'), null);

@@ -18,3 +18,3 @@ /// <reference types="node" />

get port(): number;
get portDescription(): import("../mosModel/MosMessage").PortType;
get portDescription(): IncomingConnectionType;
/** */

@@ -28,1 +28,2 @@ private _onClientConnection;

}
//# sourceMappingURL=mosSocketServer.d.ts.map

@@ -21,5 +21,5 @@ "use strict";

dispose(sockets) {
let closePromises = [];
const closePromises = [];
// close clients
sockets.forEach(socket => {
sockets.forEach((socket) => {
closePromises.push(new Promise((resolve) => {

@@ -92,3 +92,3 @@ socket.on('close', resolve);

socket.on('close', () => {
let i = this._connectedSockets.indexOf(socket);
const i = this._connectedSockets.indexOf(socket);
if (i !== -1) {

@@ -100,3 +100,3 @@ this._connectedSockets.splice(i, 1);

socket: socket,
portDescription: this._portDescription
portDescription: this._portDescription,
});

@@ -103,0 +103,0 @@ }

@@ -32,3 +32,3 @@ /// <reference types="node" />

private _emittedConnected;
private _heartBeatsTimer;
private _heartBeatsTimer?;
private _heartBeatsDelay;

@@ -61,1 +61,2 @@ constructor(id: string, host: string, mosID: string, timeout: number | undefined, debug: boolean);

}
//# sourceMappingURL=NCSServerConnection.d.ts.map

@@ -24,3 +24,3 @@ "use strict";

createClient(clientID, port, clientDescription, useHeartbeats) {
let client = new mosSocketClient_1.MosSocketClient(this._host, port, clientDescription, this._timeout, this._debug);
const client = new mosSocketClient_1.MosSocketClient(this._host, port, clientDescription, this._timeout, this._debug);
this.debugTrace('registerOutgoingConnection', clientID);

@@ -31,3 +31,3 @@ this._clients[clientID] = {

client: client,
clientDescription: clientDescription
clientDescription: clientDescription,
};

@@ -50,3 +50,3 @@ client.on('rawMessage', (type, message) => {

connect() {
for (let i in this._clients) {
for (const i in this._clients) {
// Connect client

@@ -101,3 +101,3 @@ this.emit('info', `Connect client ${i} on ${this._clients[i].clientDescription} on host ${this._host} (${this._clients[i].client.port})`);

Object.keys(this._clients).forEach((clientID) => {
let cd = this._clients[clientID];
const cd = this._clients[clientID];
if (cd) {

@@ -112,4 +112,4 @@ cd.client.setDebug(debug);

let connected = true;
Object.keys(this._clients).forEach(key => {
let client = this._clients[key];
Object.keys(this._clients).forEach((key) => {
const client = this._clients[key];
if (client.useHeartbeats && !client.heartbeatConnected) {

@@ -122,4 +122,4 @@ connected = false;

_getClients(clientDescription) {
let clients = [];
for (let i in this._clients) {
const clients = [];
for (const i in this._clients) {
if (this._clients[i].clientDescription === clientDescription) {

@@ -182,6 +182,9 @@ clients.push(this._clients[i].client);

return new Promise((resolveDispose) => {
for (let key in this._clients) {
for (const key in this._clients) {
this.removeClient(key);
}
global.clearTimeout(this._heartBeatsTimer);
if (this._heartBeatsTimer) {
global.clearTimeout(this._heartBeatsTimer);
delete this._heartBeatsTimer;
}
this._connected = false;

@@ -193,7 +196,9 @@ this.emit('connectionChanged');

_sendHeartBeats() {
if (this._heartBeatsTimer)
if (this._heartBeatsTimer) {
clearTimeout(this._heartBeatsTimer);
delete this._heartBeatsTimer;
}
if (this._disposed)
return;
let triggerNextHeartBeat = () => {
const triggerNextHeartBeat = () => {
this._heartBeatsTimer = global.setTimeout(() => {

@@ -206,9 +211,8 @@ if (!this._disposed) {

Promise.all(Object.keys(this._clients).map((key) => {
let client = this._clients[key];
const client = this._clients[key];
if (client.useHeartbeats) {
let heartbeat = new mosModel_1.HeartBeat(this._clients[key].clientDescription);
const heartbeat = new mosModel_1.HeartBeat(this._clients[key].clientDescription);
return this.executeCommand(heartbeat)
.then(() => {
client.heartbeatConnected = true;
this.debugTrace(`Heartbeat on ${this._clients[key].clientDescription} received.`);
})

@@ -231,3 +235,3 @@ .catch((e) => {

.then(() => {
let connected = this.connected;
const connected = this.connected;
if (connected !== this._emittedConnected) {

@@ -234,0 +238,0 @@ this._emittedConnected = connected;

@@ -19,1 +19,2 @@ /// <reference types="node" />

}
//# sourceMappingURL=Server.d.ts.map

@@ -15,3 +15,3 @@ "use strict";

socket: socket,
portDescription: portDescription
portDescription: portDescription,
};

@@ -24,4 +24,4 @@ }

_getSockets(portDescription) {
let sockets = [];
for (let i in this._sockets) {
const sockets = [];
for (const i in this._sockets) {
if (this._sockets[i].portDescription === portDescription) {

@@ -28,0 +28,0 @@ sockets.push(this._sockets[i].socket);

@@ -28,1 +28,2 @@ /// <reference types="node" />

};
//# sourceMappingURL=socketConnection.d.ts.map

@@ -10,1 +10,2 @@ export declare class MosDuration {

}
//# sourceMappingURL=mosDuration.d.ts.map

@@ -7,8 +7,8 @@ "use strict";

constructor(str) {
let m = str.match(/([\d]+):([\d]+):([\d]+)/);
const m = str.match(/([\d]+):([\d]+):([\d]+)/);
if (!m)
throw Error('MosDuration: Invalid format!');
let hh = parseInt(m[1], 10);
let mm = parseInt(m[2], 10);
let ss = parseInt(m[3], 10);
const hh = parseInt(m[1], 10);
const mm = parseInt(m[2], 10);
const ss = parseInt(m[3], 10);
if (isNaN(hh) || isNaN(mm) || isNaN(ss))

@@ -21,7 +21,7 @@ throw Error('MosDuration: Invalid format!');

let s = this._duration;
let hh = Math.floor(s / 3600);
const hh = Math.floor(s / 3600);
s -= hh * 3600;
let mm = Math.floor(s / 60);
const mm = Math.floor(s / 60);
s -= mm * 60;
let ss = Math.floor(s);
const ss = Math.floor(s);
return hh + ':' + mm + ':' + ss;

@@ -28,0 +28,0 @@ }

@@ -22,1 +22,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=mosExternalMetaData.d.ts.map

@@ -28,3 +28,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('mosExternalMetadata'); // config headless
const root = XMLBuilder.create('mosExternalMetadata'); // config headless
Utils_1.addTextElement(root, 'mosScope', this._scope);

@@ -31,0 +31,0 @@ Utils_1.addTextElement(root, 'mosSchema', this._schema);

@@ -5,12 +5,15 @@ export declare class MosString128 {

/** */
constructor(str: any, strict?: boolean);
constructor(str: AnyString, strict?: boolean);
/** */
toString(): string;
/** */
set string(str: string | {
text: string;
type: string;
} | MosString128 | any);
set string(str: AnyString);
/** */
private _validate;
}
declare type AnyString = string | {
text: string;
type: string;
} | MosString128 | any;
export {};
//# sourceMappingURL=mosString128.d.ts.map

@@ -8,2 +8,3 @@ "use strict";

this.strict = strict;
this._str = 'undefined';
this.string = str;

@@ -10,0 +11,0 @@ }

@@ -19,1 +19,2 @@ export declare class MosTime {

}
//# sourceMappingURL=mosTime.d.ts.map

@@ -24,5 +24,5 @@ "use strict";

// parse out custom Z indicator (mos-centric)
let customFormatParseResult = this._parseMosCustomFormat(timestamp);
const customFormatParseResult = this._parseMosCustomFormat(timestamp);
// parse out custom timezones (mos local-local centric format)
let timezoneParseResult = this._parseTimeOffset(timestamp);
const timezoneParseResult = this._parseTimeOffset(timestamp);
if (customFormatParseResult !== false) {

@@ -32,3 +32,3 @@ this._timezone = customFormatParseResult.timezoneIndicator;

const r = customFormatParseResult;
let dateStr = `${r.yy}-${r.mm}-${r.dd}T${r.hh}:${r.ii}:${r.ss}${(r.ms ? '.' + r.ms : '')}${this._timezoneZuluIndicator}${this._timezoneDeclaration}`;
const dateStr = `${r.yy}-${r.mm}-${r.dd}T${r.hh}:${r.ii}:${r.ss}${r.ms ? '.' + r.ms : ''}${this._timezoneZuluIndicator}${this._timezoneDeclaration}`;
time = new Date(dateStr);

@@ -66,5 +66,4 @@ }

toString() {
let t = moment.utc(this._time).utcOffset(this._timezone);
return t.format('YYYY-MM-DDTHH:mm:ss,SSS##!!##')
.replace('##!!##', this._timezone);
const t = moment.utc(this._time).utcOffset(this._timezone);
return t.format('YYYY-MM-DDTHH:mm:ss,SSS##!!##').replace('##!!##', this._timezone);
}

@@ -82,4 +81,4 @@ /** */

let timezoneDeclaration = '';
const offsetregex = /([+-])([0-9]{1,2})(?:\:{0,1}([0-9]{2})){0,1}(?: {0,1}\(\S+\)){0,1}$/;
let match = timestamp.match(offsetregex);
const offsetregex = /([+-])([0-9]{1,2})(?::{0,1}([0-9]{2})){0,1}(?: {0,1}\(\S+\)){0,1}$/;
const match = timestamp.match(offsetregex);
if (match) {

@@ -102,6 +101,6 @@ let positiveNegativeValue = 0;

}
timeOffsetValue = ((hours * 60) + minutes) * positiveNegativeValue;
timeOffsetValue = (hours * 60 + minutes) * positiveNegativeValue;
return {
timeOffsetValue,
timezoneDeclaration
timezoneDeclaration,
};

@@ -113,16 +112,16 @@ }

_parseMosCustomFormat(timestamp) {
const timestampRegex = /(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)([,\.](\d{3}))?(([+-Z])([:\d]+)?)?/i;
let match = timestamp.match(timestampRegex);
const timestampRegex = /(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)([,.](\d{3}))?(([+-Z])([:\d]+)?)?/i;
const match = timestamp.match(timestampRegex);
if (match) {
let yy = Utils_1.pad(match[1], 4);
let mm = Utils_1.pad(match[2], 2);
let dd = Utils_1.pad(match[3], 2);
let hh = Utils_1.pad(match[4], 2);
let ii = Utils_1.pad(match[5], 2);
let ss = Utils_1.pad(match[6], 2);
let ms = match[8];
const yy = Utils_1.pad(match[1], 4);
const mm = Utils_1.pad(match[2], 2);
const dd = Utils_1.pad(match[3], 2);
const hh = Utils_1.pad(match[4], 2);
const ii = Utils_1.pad(match[5], 2);
const ss = Utils_1.pad(match[6], 2);
const ms = match[8];
let timezoneIndicator = match[9] || MosTime._defaultTimezone;
let m = timezoneIndicator.match(/([+-])(\d+):(\d+)/); // +5:00, -05:00
const m = timezoneIndicator.match(/([+-])(\d+):(\d+)/); // +5:00, -05:00
if (m) {
let tzSign = m[1];
const tzSign = m[1];
let tzHours = m[2];

@@ -144,3 +143,3 @@ let tzMinutes = m[3];

ms,
timezoneIndicator
timezoneIndicator,
};

@@ -147,0 +146,0 @@ }

@@ -11,1 +11,2 @@ export * from './MosConnection';

export * as Utils from './utils/Utils';
//# sourceMappingURL=index.d.ts.map

@@ -21,3 +21,3 @@ /// <reference types="node" />

private _isListening;
private _onconnection;
private _onConnection?;
/** */

@@ -66,1 +66,2 @@ constructor(configOptions: IConnectionConfig);

}
//# sourceMappingURL=MosConnection.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosConnection = void 0;
const tslib_1 = require("tslib");
const connectionConfig_1 = require("./config/connectionConfig");

@@ -63,3 +62,3 @@ const mosSocketServer_1 = require("./connection/mosSocketServer");

// Connect to MOS-device:
let primary = new NCSServerConnection_1.NCSServerConnection(connectionOptions.primary.id, connectionOptions.primary.host, this._conf.mosID, connectionOptions.primary.timeout, this._debug);
const primary = new NCSServerConnection_1.NCSServerConnection(connectionOptions.primary.id, connectionOptions.primary.host, this._conf.mosID, connectionOptions.primary.timeout, this._debug);
let secondary = null;

@@ -106,3 +105,3 @@ this._ncsConnections[connectionOptions.primary.host] = primary;

// Initialize mosDevice:
let mosDevice = this._registerMosDevice(this._conf.mosID, connectionOptions.primary.id, (connectionOptions.secondary ? connectionOptions.secondary.id : null), primary, secondary);
const mosDevice = this._registerMosDevice(this._conf.mosID, connectionOptions.primary.id, connectionOptions.secondary ? connectionOptions.secondary.id : null, primary, secondary);
resolve(mosDevice);

@@ -113,3 +112,3 @@ });

onConnection(cb) {
this._onconnection = cb;
this._onConnection = cb;
}

@@ -134,5 +133,5 @@ /** True if mosConnection is listening for connections */

dispose() {
let sockets = [];
for (let socketID in this._incomingSockets) {
let e = this._incomingSockets[socketID];
const sockets = [];
for (const socketID in this._incomingSockets) {
const e = this._incomingSockets[socketID];
if (e) {

@@ -142,3 +141,3 @@ sockets.push(e.socket);

}
let disposePromises0 = sockets.map((socket) => {
const disposePromises0 = sockets.map((socket) => {
return new Promise((resolve) => {

@@ -150,10 +149,10 @@ socket.on('close', resolve);

});
let disposePromises1 = [
const disposePromises1 = [
this._lowerSocketServer ? this._lowerSocketServer.dispose([]) : Promise.resolve(),
this._upperSocketServer ? this._upperSocketServer.dispose([]) : Promise.resolve(),
this._querySocketServer ? this._querySocketServer.dispose([]) : Promise.resolve()
this._querySocketServer ? this._querySocketServer.dispose([]) : Promise.resolve(),
];
let disposePromises2 = [];
Object.keys(this._mosDevices).map(deviceId => {
let device = this._mosDevices[deviceId];
const disposePromises2 = [];
Object.keys(this._mosDevices).map((deviceId) => {
const device = this._mosDevices[deviceId];
disposePromises2.push(this.disposeMosDevice(device));

@@ -187,3 +186,3 @@ });

// myMosID = myMosIDOrMosDevice
let mosDevice = myMosIDOrMosDevice;
const mosDevice = myMosIDOrMosDevice;
id0 = mosDevice.idPrimary;

@@ -193,9 +192,8 @@ id1 = mosDevice.idSecondary;

else {
let myMosID = myMosIDOrMosDevice;
const myMosID = myMosIDOrMosDevice;
id0 = myMosID + '_' + theirMosId0;
id1 = (theirMosId1 ? myMosID + '_' + theirMosId1 : null);
id1 = theirMosId1 ? myMosID + '_' + theirMosId1 : null;
}
if (this._mosDevices[id0]) {
return this._mosDevices[id0].dispose()
.then(() => {
return this._mosDevices[id0].dispose().then(() => {
delete this._mosDevices[id0];

@@ -205,4 +203,3 @@ });

else if (id1 && this._mosDevices[id1]) {
return this._mosDevices[id1].dispose()
.then(() => {
return this._mosDevices[id1].dispose().then(() => {
delete this._mosDevices[id1 || ''];

@@ -218,4 +215,4 @@ });

if (this.isCompliant) {
let profiles = [];
for (let nextSocketID in this._conf.profiles) {
const profiles = [];
for (const nextSocketID in this._conf.profiles) {
if (this._conf.profiles[nextSocketID] === true) {

@@ -235,3 +232,3 @@ profiles.push(nextSocketID);

Object.keys(this._ncsConnections).forEach((host) => {
let conn = this._ncsConnections[host];
const conn = this._ncsConnections[host];
if (conn) {

@@ -249,5 +246,5 @@ conn.setDebug(debug);

_registerMosDevice(myMosID, theirMosId0, theirMosId1, primary, secondary) {
let id0 = myMosID + '_' + theirMosId0;
let id1 = (theirMosId1 ? myMosID + '_' + theirMosId1 : null);
let mosDevice = new MosDevice_1.MosDevice(id0, id1, this._conf, primary, secondary, this._conf.offspecFailover, this._conf.strict);
const id0 = myMosID + '_' + theirMosId0;
const id1 = theirMosId1 ? myMosID + '_' + theirMosId1 : null;
const mosDevice = new MosDevice_1.MosDevice(id0, id1, this._conf, primary, secondary, this._conf.offspecFailover, this._conf.strict);
mosDevice.setDebug(this._debug);

@@ -266,4 +263,4 @@ // Add mosDevice to register:

// emit to .onConnection:
if (this._onconnection)
this._onconnection(mosDevice);
if (this._onConnection)
this._onConnection(mosDevice);
return mosDevice;

@@ -277,4 +274,4 @@ }

}
let initSocket = (port, portType) => {
let socketServer = new mosSocketServer_1.MosSocketServer(port, portType, this._debug);
const initSocket = (port, portType) => {
const socketServer = new mosSocketServer_1.MosSocketServer(port, portType, this._debug);
socketServer.on(socketConnection_1.SocketServerEvent.CLIENT_CONNECTED, (e) => this._registerIncomingClient(e));

@@ -290,5 +287,4 @@ socketServer.on(socketConnection_1.SocketServerEvent.ERROR, (e) => {

this._querySocketServer = initSocket((_f = (_e = this._conf.ports) === null || _e === void 0 ? void 0 : _e.query) !== null && _f !== void 0 ? _f : MosConnection.CONNECTION_PORT_QUERY, 'query');
let handleListen = (socketServer) => {
return socketServer.listen()
.then(() => {
const handleListen = (socketServer) => {
return socketServer.listen().then(() => {
this.emit('info', 'Listening on port ' + socketServer.port + ' (' + socketServer.portDescription + ')');

@@ -300,3 +296,3 @@ });

handleListen(this._upperSocketServer),
handleListen(this._querySocketServer)
handleListen(this._querySocketServer),
]).then(() => {

@@ -309,3 +305,3 @@ // All sockets are open and listening at this point

_registerIncomingClient(client) {
let socketID = MosConnection.nextSocketID;
const socketID = MosConnection.nextSocketID;
this.emit('rawMessage', 'incoming_' + socketID, 'newConnection', 'From ' + client.socket.remoteAddress + ':' + client.socket.remotePort);

@@ -315,4 +311,3 @@ const messageParser = new mosMessageParser_1.MosMessageParser(`${socketID}, ${client.socket.remoteAddress}, ${client.portDescription}`);

messageParser.on('message', (message, messageString) => {
handleMessage(message, messageString)
.catch((err) => this.emit('error', err));
handleMessage(message, messageString).catch((err) => this.emit('error', err));
});

@@ -341,3 +336,3 @@ // handles socket listeners

});
const handleMessage = (parsed, _messageString) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const handleMessage = async (parsed, _messageString) => {
var _a, _b, _c, _d;

@@ -352,3 +347,3 @@ const remoteAddressContent = client.socket.remoteAddress

let mosDevice = this._mosDevices[ncsID + '_' + mosID] || this._mosDevices[mosID + '_' + ncsID];
let sendReply = (message) => {
const sendReply = (message) => {
message.ncsID = ncsID;

@@ -368,3 +363,3 @@ message.mosID = mosID;

// send commands to it through the mosDevice
let primary = new NCSServerConnection_1.NCSServerConnection(mosID, remoteAddress, this._conf.mosID, undefined, this._debug);
const primary = new NCSServerConnection_1.NCSServerConnection(mosID, remoteAddress, this._conf.mosID, undefined, this._debug);
this._ncsConnections[remoteAddress] = primary;

@@ -380,5 +375,3 @@ primary.on('rawMessage', (type, message) => {

});
const openRelayOptions = (typeof this._conf.openRelay === 'object'
? this._conf.openRelay.options
: undefined);
const openRelayOptions = typeof this._conf.openRelay === 'object' ? this._conf.openRelay.options : undefined;
primary.createClient(MosConnection.nextSocketID, (_b = (_a = openRelayOptions === null || openRelayOptions === void 0 ? void 0 : openRelayOptions.ports) === null || _a === void 0 ? void 0 : _a.lower) !== null && _b !== void 0 ? _b : MosConnection.CONNECTION_PORT_LOWER, 'lower', true);

@@ -389,7 +382,7 @@ primary.createClient(MosConnection.nextSocketID, (_d = (_c = openRelayOptions === null || openRelayOptions === void 0 ? void 0 : openRelayOptions.ports) === null || _c === void 0 ? void 0 : _c.upper) !== null && _d !== void 0 ? _d : MosConnection.CONNECTION_PORT_UPPER, 'upper', true);

else if (mosID === this._conf.mosID) {
mosDevice = yield this.connect({
mosDevice = await this.connect({
primary: {
id: ncsID,
host: remoteAddress
}
host: remoteAddress,
},
});

@@ -399,5 +392,8 @@ }

if (mosDevice) {
mosDevice.routeData(parsed, client.portDescription).then((message) => {
mosDevice
.routeData(parsed, client.portDescription)
.then((message) => {
sendReply(message);
}).catch((err) => {
})
.catch((err) => {
// Something went wrong

@@ -414,7 +410,8 @@ if (err instanceof MosMessage_1.MosMessage) {

// http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS_Protocol_Version_2.8.5_Final.htm#mosAck
let msg = new mosModel_1.MOSAck();
msg.ID = new mosString128_1.MosString128(0);
msg.Revision = 0;
msg.Description = new mosString128_1.MosString128(`MosDevice "${ncsID + '_' + mosID}" not found`);
msg.Status = api_1.IMOSAckStatus.NACK;
const msg = new mosModel_1.MOSAck({
ID: new mosString128_1.MosString128(0),
Revision: 0,
Description: new mosString128_1.MosString128(`MosDevice "${ncsID + '_' + mosID}" not found`),
Status: api_1.IMOSAckStatus.NACK,
});
sendReply(msg); // TODO: Need tests

@@ -427,10 +424,11 @@ }

// We can't handle the message, reply with a NACK:
let msg = new mosModel_1.MOSAck();
msg.ID = new mosString128_1.MosString128(0);
msg.Revision = 0;
msg.Description = new mosString128_1.MosString128('MosDevice not found');
msg.Status = api_1.IMOSAckStatus.NACK;
const msg = new mosModel_1.MOSAck({
ID: new mosString128_1.MosString128(0),
Revision: 0,
Description: new mosString128_1.MosString128('MosDevice not found'),
Status: api_1.IMOSAckStatus.NACK,
});
sendReply(msg); // TODO: Need tests
}
});
};
client.socket.on('error', (e) => {

@@ -446,3 +444,3 @@ this.emit('error', `Socket had error (${socketID}, ${client.socket.remoteAddress}, ${client.portDescription}): ${e}`);

_disposeIncomingSocket(socketID) {
let e = this._incomingSockets[socketID + ''];
const e = this._incomingSockets[socketID + ''];
if (e) {

@@ -449,0 +447,0 @@ e.socket.removeAllListeners();

@@ -10,2 +10,3 @@ /// <reference types="node" />

import { PortType } from './mosModel/MosMessage';
import { AnyXML } from './mosModel/lib';
export declare class MosDevice implements IMOSDevice {

@@ -23,4 +24,4 @@ socket: Socket;

mosRev: MosString128;
defaultActiveX: Array<IMOSDefaultActiveX>;
mosExternalMetaData: Array<IMOSExternalMetaData>;
defaultActiveX?: Array<IMOSDefaultActiveX>;
mosExternalMetaData?: Array<IMOSExternalMetaData>;
private _idPrimary;

@@ -85,3 +86,3 @@ private _idSecondary;

dispose(): Promise<void>;
routeData(data: any, port: PortType): Promise<any>;
routeData(data: AnyXML, port: PortType): Promise<any>;
requestMachineInfo(): Promise<IMOSListMachInfo>;

@@ -227,1 +228,2 @@ onRequestMachineInfo(cb: () => Promise<IMOSListMachInfo>): void;

}
//# sourceMappingURL=MosDevice.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosDevice = void 0;
const tslib_1 = require("tslib");
const net_1 = require("net");

@@ -19,2 +18,3 @@ const mosString128_1 = require("./dataTypes/mosString128");

const roReadyToAir_1 = require("./mosModel/profile2/roReadyToAir");
const lib_1 = require("./mosModel/lib");
class MosDevice {

@@ -32,3 +32,3 @@ constructor(idPrimary, idSecondary, connectionConfig, primaryConnection, secondaryConnection, offSpecFailover, strict) {

profile6: false,
profile7: false
profile7: false,
}; // Use same names as IProfiles?

@@ -80,4 +80,6 @@ this._disposed = false;

this._primaryConnection.on('connectionChanged', () => {
var _a;
this._emitConnectionChange();
if (offSpecFailover && this._currentConnection !== this._primaryConnection && this._primaryConnection.connected) {
if (offSpecFailover &&
this._currentConnection !== this._primaryConnection && ((_a = this._primaryConnection) === null || _a === void 0 ? void 0 : _a.connected)) {
this.switchConnections(); // and hope no current message goes lost

@@ -119,15 +121,15 @@ }

get primaryHost() {
return (this._primaryConnection ? this._primaryConnection.host : null);
return this._primaryConnection ? this._primaryConnection.host : null;
}
/** Name (ID) of the primary server */
get primaryId() {
return (this._primaryConnection ? this._primaryConnection.id : null);
return this._primaryConnection ? this._primaryConnection.id : null;
}
/** Host name (IP-address) of the secondary (buddy) server */
get secondaryHost() {
return (this._secondaryConnection ? this._secondaryConnection.host : null);
return this._secondaryConnection ? this._secondaryConnection.host : null;
}
/** Name (ID) of the secondary (buddy) server */
get secondaryId() {
return (this._secondaryConnection ? this._secondaryConnection.id : null);
return this._secondaryConnection ? this._secondaryConnection.id : null;
}

@@ -146,332 +148,338 @@ connect() {

ps.push(this._secondaryConnection.dispose());
return Promise.all(ps)
.then(() => {
return Promise.all(ps).then(() => {
return;
});
}
routeData(data, port) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (data && data.hasOwnProperty('mos'))
data = data['mos'];
this.debugTrace('parsedData', data);
// this.debugTrace('parsedTest', keys)
this.debugTrace('keys', Object.keys(data));
// Route and format data:
// Profile 0:
if (data.heartbeat) {
// send immediate reply on the same port:
return new mosModel_1.HeartBeat(port);
}
else if (data.reqMachInfo && typeof this._callbackOnRequestMachineInfo === 'function') {
if (port === 'query')
throw new Error('message "reqMachInfo" is invalid on query port');
const m = yield this._callbackOnRequestMachineInfo();
return new mosModel_1.ListMachineInfo(m, port);
// Profile 1:
}
else if (data.mosReqObj && typeof this._callbackOnRequestMOSOBject === 'function') {
const mosObj = yield this._callbackOnRequestMOSOBject(data.mosReqObj.objID);
if (!mosObj)
return null;
return new mosModel_1.MosObj(mosObj);
}
else if (data.mosReqAll && typeof this._callbackOnRequestAllMOSObjects === 'function') {
const pause = data.mosReqAll.pause || 0;
const mosObjects = yield this._callbackOnRequestAllMOSObjects();
setImmediate(() => {
// spec: Pause, when greater than zero, indicates the number of seconds to pause
// between individual mosObj messages.
// Pause of zero indicates that all objects will be sent using the mosListAll message..
// http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqAll
if (pause > 0) {
if (mosObjects.length) {
// const firstObject = mosObjects.shift() as IMOSObject
// const resp = new MosObj(firstObject)
// resolve(resp)
const sendNextObject = () => {
if (this._disposed)
return;
const nextObject = mosObjects.shift();
if (nextObject) {
this.sendMOSObject(nextObject)
.then(() => {
setTimeout(sendNextObject, pause * 1000);
})
.catch(e => {
console.error('Error in async mosObj response to mosReqAll', e);
});
}
};
setTimeout(sendNextObject, pause * 1000);
}
async routeData(data, port) {
if (data && lib_1.has(data, 'mos'))
data = data['mos'];
this.debugTrace('parsedData', data);
// this.debugTrace('parsedTest', keys)
this.debugTrace('keys', Object.keys(data));
// Route and format data:
// Profile 0:
if (data.heartbeat) {
// send immediate reply on the same port:
return new mosModel_1.HeartBeat(port);
}
else if (data.reqMachInfo && typeof this._callbackOnRequestMachineInfo === 'function') {
if (port === 'query')
throw new Error('message "reqMachInfo" is invalid on query port');
const m = await this._callbackOnRequestMachineInfo();
return new mosModel_1.ListMachineInfo(m, port);
// Profile 1:
}
else if (data.mosReqObj && typeof this._callbackOnRequestMOSOBject === 'function') {
const mosObj = await this._callbackOnRequestMOSOBject(data.mosReqObj.objID);
if (!mosObj)
return null;
return new mosModel_1.MosObj(mosObj);
}
else if (data.mosReqAll && typeof this._callbackOnRequestAllMOSObjects === 'function') {
const pause = data.mosReqAll.pause || 0;
const mosObjects = await this._callbackOnRequestAllMOSObjects();
setImmediate(() => {
// spec: Pause, when greater than zero, indicates the number of seconds to pause
// between individual mosObj messages.
// Pause of zero indicates that all objects will be sent using the mosListAll message..
// http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqAll
if (pause > 0) {
if (mosObjects.length) {
// const firstObject = mosObjects.shift() as IMOSObject
// const resp = new MosObj(firstObject)
// resolve(resp)
const sendNextObject = () => {
if (this._disposed)
return;
const nextObject = mosObjects.shift();
if (nextObject) {
this.sendMOSObject(nextObject)
.then(() => {
setTimeout(sendNextObject, pause * 1000);
})
.catch((e) => {
console.error('Error in async mosObj response to mosReqAll', e);
});
}
};
setTimeout(sendNextObject, pause * 1000);
}
else {
this._sendAllMOSObjects(mosObjects)
.catch(e => {
console.error('Error in async mosListAll response to mosReqAll', e);
});
}
});
const mosAck = new mosModel_1.MOSAck();
return mosAck;
// Profile 2:
}
else if (data.roCreate && typeof this._callbackOnCreateRunningOrder === 'function') {
const ro = Parser_1.Parser.xml2RO(data.roCreate);
const resp = yield this._callbackOnCreateRunningOrder(ro);
return new mosModel_1.ROAck(resp);
}
else if (data.roReplace && typeof this._callbackOnReplaceRunningOrder === 'function') {
const ro = Parser_1.Parser.xml2RO(data.roReplace);
const resp = yield this._callbackOnReplaceRunningOrder(ro);
return new mosModel_1.ROAck(resp);
}
else if (data.roDelete && typeof this._callbackOnDeleteRunningOrder === 'function') {
// TODO: Change runningOrderId to RunningOrderID in interface?
const resp = yield this._callbackOnDeleteRunningOrder(data.roDelete.roID);
return new mosModel_1.ROAck(resp);
}
else if (data.roReq && typeof this._callbackOnRequestRunningOrder === 'function') {
const ro = yield this._callbackOnRequestRunningOrder(data.roReq.roID);
if (ro) {
return new mosModel_1.ROList(ro);
}
else {
// RO not found
const ack = new mosModel_1.ROAck();
ack.ID = data.roReq.roID;
ack.Status = new mosString128_1.MosString128(api_1.IMOSAckStatus.NACK);
return ack;
this._sendAllMOSObjects(mosObjects).catch((e) => {
console.error('Error in async mosListAll response to mosReqAll', e);
});
}
});
// What this should contain isn't well defined in the protocol
return new mosModel_1.MOSAck({
ID: new mosString128_1.MosString128(0),
Revision: 0,
Description: new mosString128_1.MosString128(''),
Status: api_1.IMOSAckStatus.ACK,
});
// Profile 2:
}
else if (data.roCreate && typeof this._callbackOnCreateRunningOrder === 'function') {
const ro = Parser_1.Parser.xml2RO(data.roCreate);
const resp = await this._callbackOnCreateRunningOrder(ro);
return new mosModel_1.ROAck(resp);
}
else if (data.roReplace && typeof this._callbackOnReplaceRunningOrder === 'function') {
const ro = Parser_1.Parser.xml2RO(data.roReplace);
const resp = await this._callbackOnReplaceRunningOrder(ro);
return new mosModel_1.ROAck(resp);
}
else if (data.roDelete && typeof this._callbackOnDeleteRunningOrder === 'function') {
// TODO: Change runningOrderId to RunningOrderID in interface?
const resp = await this._callbackOnDeleteRunningOrder(data.roDelete.roID);
return new mosModel_1.ROAck(resp);
}
else if (data.roReq && typeof this._callbackOnRequestRunningOrder === 'function') {
const ro = await this._callbackOnRequestRunningOrder(data.roReq.roID);
if (ro) {
return new mosModel_1.ROList(ro);
}
else if (data.roMetadataReplace && typeof this._callbackOnMetadataReplace === 'function') {
const ro = Parser_1.Parser.xml2ROBase(data.roMetadataReplace);
const resp = yield this._callbackOnMetadataReplace(ro);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementStat && data.roElementStat.element === 'RO' && typeof this._callbackOnRunningOrderStatus === 'function') {
const status = {
ID: new mosString128_1.MosString128(data.roElementStat.roID),
Status: data.roElementStat.status,
Time: new mosTime_1.MosTime(data.roElementStat.time)
};
const resp = yield this._callbackOnRunningOrderStatus(status);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementStat && data.roElementStat.element === 'STORY' && typeof this._callbackOnStoryStatus === 'function') {
const status = {
RunningOrderId: new mosString128_1.MosString128(data.roElementStat.roID),
ID: new mosString128_1.MosString128(data.roElementStat.storyID),
Status: data.roElementStat.status,
Time: new mosTime_1.MosTime(data.roElementStat.time)
};
const resp = yield this._callbackOnStoryStatus(status);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementStat &&
data.roElementStat.element === 'ITEM' &&
typeof this._callbackOnItemStatus === 'function') {
const status = {
RunningOrderId: new mosString128_1.MosString128(data.roElementStat.roID),
StoryId: new mosString128_1.MosString128(data.roElementStat.storyID),
ID: new mosString128_1.MosString128(data.roElementStat.itemID),
Status: data.roElementStat.status,
Time: new mosTime_1.MosTime(data.roElementStat.time)
};
if (data.roElementStat.hasOwnProperty('objID'))
status.ObjectId = new mosString128_1.MosString128(data.roElementStat.objID);
if (data.roElementStat.hasOwnProperty('itemChannel'))
status.Channel = new mosString128_1.MosString128(data.roElementStat.itemChannel);
const resp = yield this._callbackOnItemStatus(status);
return new mosModel_1.ROAck(resp);
}
else if (data.roReadyToAir && typeof this._callbackOnReadyToAir === 'function') {
const resp = yield this._callbackOnReadyToAir({
ID: new mosString128_1.MosString128(data.roReadyToAir.roID),
Status: data.roReadyToAir.roAir
else {
// RO not found
return new mosModel_1.ROAck({
ID: data.roReq.roID,
Status: new mosString128_1.MosString128(api_1.IMOSAckStatus.NACK),
Stories: [],
});
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'INSERT' &&
(data.roElementAction.element_source || {}).story &&
typeof this._callbackOnROInsertStories === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
};
const stories = Parser_1.Parser.xml2Stories([data.roElementAction.element_source.story]);
const resp = yield this._callbackOnROInsertStories(action, stories);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'INSERT' &&
(data.roElementAction.element_source || {}).item &&
typeof this._callbackOnROInsertItems === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID)
};
const items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);
const resp = yield this._callbackOnROInsertItems(action, items);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'REPLACE' &&
(data.roElementAction.element_source || {}).story &&
typeof this._callbackOnROReplaceStories === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
};
const stories = Parser_1.Parser.xml2Stories([data.roElementAction.element_source.story]);
const resp = yield this._callbackOnROReplaceStories(action, stories);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'REPLACE' &&
(data.roElementAction.element_source || {}).item &&
typeof this._callbackOnROReplaceItems === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID)
};
const items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);
const resp = yield this._callbackOnROReplaceItems(action, items);
resp.Stories = []; // dont return these (?)
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'MOVE' &&
(data.roElementAction.element_source || {}).storyID &&
typeof this._callbackOnROMoveStories === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
};
const storyIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
const resp = yield this._callbackOnROMoveStories(action, storyIDs);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'MOVE' &&
(data.roElementAction.element_source || {}).itemID &&
typeof this._callbackOnROMoveItems === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID)
};
const itemIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
const resp = yield this._callbackOnROMoveItems(action, itemIDs);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'DELETE' &&
data.roElementAction.element_source.storyID &&
typeof this._callbackOnRODeleteStories === 'function') {
const stories = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
const resp = yield this._callbackOnRODeleteStories({
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID)
}, stories);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'DELETE' &&
data.roElementAction.element_source.itemID &&
typeof this._callbackOnRODeleteItems === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
};
const items = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
const resp = yield this._callbackOnRODeleteItems(action, items);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'SWAP' &&
data.roElementAction.element_source.storyID &&
data.roElementAction.element_source.storyID.length === 2 &&
typeof this._callbackOnROSwapStories === 'function') {
const stories = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
const resp = yield this._callbackOnROSwapStories({
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID)
}, stories[0], stories[1]);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'SWAP' &&
data.roElementAction.element_source.itemID &&
data.roElementAction.element_source.itemID.length === 2 &&
typeof this._callbackOnROSwapItems === 'function') {
const items = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
const resp = yield this._callbackOnROSwapItems({
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
}, items[0], items[1]);
return new mosModel_1.ROAck(resp);
// Profile 3
}
else if (data.mosItemReplace && typeof this._callbackOnItemReplace === 'function') {
const resp = yield this._callbackOnItemReplace(data.mosItemReplace.ID, data.mosItemReplace.itemID, Parser_1.Parser.xml2Item(data.mosItemReplace.item));
return new mosModel_1.ROAck(resp);
}
else if (data.mosObjCreate && typeof this._callbackOnObjectCreate === 'function') {
const resp = yield this._callbackOnObjectCreate(Parser_1.Parser.xml2MosObj(data.mosObjCreate));
const ack = new mosModel_1.MOSAck(resp);
return ack;
}
else if (data.mosReqObjAction &&
data.mosReqObjAction.operation === 'NEW' &&
typeof this._callbackOnRequestObjectActionNew === 'function') {
const resp = yield this._callbackOnRequestObjectActionNew(Parser_1.Parser.xml2MosObj(data.mosReqObjAction));
return new mosModel_1.MOSAck(resp);
}
else if (data.mosReqObjAction &&
data.mosReqObjAction.operation === 'UPDATE' &&
typeof this._callbackOnRequestObjectActionUpdate === 'function') {
const resp = yield this._callbackOnRequestObjectActionUpdate(data.mosReqObjAction.objID, Parser_1.Parser.xml2MosObj(data.mosReqObjAction));
return new mosModel_1.MOSAck(resp);
}
else if (data.mosReqObjAction &&
data.mosReqObjAction.operation === 'DELETE' &&
typeof this._callbackOnRequestObjectActionDelete === 'function') {
const resp = yield this._callbackOnRequestObjectActionDelete(data.mosReqObjAction.objID);
return new mosModel_1.MOSAck(resp);
}
else if (data.mosReqObjList && typeof this._callbackOnRequestObjectList === 'function') {
const resp = yield this._callbackOnRequestObjectList(Parser_1.Parser.xml2ReqObjList(data.mosReqObjList));
return new mosModel_1.MosObjList(resp);
}
else if (data.mosReqSearchableSchema && typeof this._callbackOnRequestSearchableSchema === 'function') {
const resp = yield this._callbackOnRequestSearchableSchema(data.mosReqSearchableSchema.username);
return new mosModel_1.MosListSearchableSchema(resp);
// Profile 4
}
else if (data.roReqAll && typeof this._callbackOnRequestAllRunningOrders === 'function') {
const list = yield this._callbackOnRequestAllRunningOrders();
const roListAll = new ROListAll_1.ROListAll();
roListAll.ROs = list;
return roListAll;
}
else if (data.roStorySend && typeof this._callbackOnRunningOrderStory === 'function') {
const story = Parser_1.Parser.xml2FullStory(data.roStorySend);
const resp = yield this._callbackOnRunningOrderStory(story);
return new mosModel_1.ROAck(resp);
// TODO: Use MosMessage instead of string
// TODO: Use reject if function dont exists? Put Nack in ondata
}
else {
this.debugTrace(data);
const msg = new mosModel_1.MOSAck();
msg.ID = new mosString128_1.MosString128(0); // Depends on type of message, needs logic
msg.Revision = 0;
msg.Description = new mosString128_1.MosString128('Unsupported function');
msg.Status = api_1.IMOSAckStatus.NACK;
return msg;
// resolve('<mos><mosID>test2.enps.mos</mosID><ncsID>2012R2ENPS8VM</ncsID><messageID>99</messageID><roAck><roID>2012R2ENPS8VM;P_ENPSMOS\W\F_HOLD ROs;DEC46951-28F9-4A11-8B0655D96B347E52</roID><roStatus>Unknown object M000133</roStatus><storyID>5983A501:0049B924:8390EF2B</storyID><itemID>0</itemID><objID>M000224</objID><status>LOADED</status><storyID>3854737F:0003A34D:983A0B28</storyID><itemID>0</itemID><objID>M000133</objID><itemChannel>A</itemChannel><status>UNKNOWN</status></roAck></mos>')
}
});
}
else if (data.roMetadataReplace && typeof this._callbackOnMetadataReplace === 'function') {
const ro = Parser_1.Parser.xml2ROBase(data.roMetadataReplace);
const resp = await this._callbackOnMetadataReplace(ro);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementStat &&
data.roElementStat.element === 'RO' &&
typeof this._callbackOnRunningOrderStatus === 'function') {
const status = {
ID: new mosString128_1.MosString128(data.roElementStat.roID),
Status: data.roElementStat.status,
Time: new mosTime_1.MosTime(data.roElementStat.time),
};
const resp = await this._callbackOnRunningOrderStatus(status);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementStat &&
data.roElementStat.element === 'STORY' &&
typeof this._callbackOnStoryStatus === 'function') {
const status = {
RunningOrderId: new mosString128_1.MosString128(data.roElementStat.roID),
ID: new mosString128_1.MosString128(data.roElementStat.storyID),
Status: data.roElementStat.status,
Time: new mosTime_1.MosTime(data.roElementStat.time),
};
const resp = await this._callbackOnStoryStatus(status);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementStat &&
data.roElementStat.element === 'ITEM' &&
typeof this._callbackOnItemStatus === 'function') {
const status = {
RunningOrderId: new mosString128_1.MosString128(data.roElementStat.roID),
StoryId: new mosString128_1.MosString128(data.roElementStat.storyID),
ID: new mosString128_1.MosString128(data.roElementStat.itemID),
Status: data.roElementStat.status,
Time: new mosTime_1.MosTime(data.roElementStat.time),
};
if (lib_1.has(data.roElementStat, 'objID'))
status.ObjectId = new mosString128_1.MosString128(data.roElementStat.objID);
if (lib_1.has(data.roElementStat, 'itemChannel'))
status.Channel = new mosString128_1.MosString128(data.roElementStat.itemChannel);
const resp = await this._callbackOnItemStatus(status);
return new mosModel_1.ROAck(resp);
}
else if (data.roReadyToAir && typeof this._callbackOnReadyToAir === 'function') {
const resp = await this._callbackOnReadyToAir({
ID: new mosString128_1.MosString128(data.roReadyToAir.roID),
Status: data.roReadyToAir.roAir,
});
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'INSERT' &&
(data.roElementAction.element_source || {}).story &&
typeof this._callbackOnROInsertStories === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
};
const stories = Parser_1.Parser.xml2Stories([data.roElementAction.element_source.story]);
const resp = await this._callbackOnROInsertStories(action, stories);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'INSERT' &&
(data.roElementAction.element_source || {}).item &&
typeof this._callbackOnROInsertItems === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID),
};
const items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);
const resp = await this._callbackOnROInsertItems(action, items);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'REPLACE' &&
(data.roElementAction.element_source || {}).story &&
typeof this._callbackOnROReplaceStories === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
};
const stories = Parser_1.Parser.xml2Stories([data.roElementAction.element_source.story]);
const resp = await this._callbackOnROReplaceStories(action, stories);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'REPLACE' &&
(data.roElementAction.element_source || {}).item &&
typeof this._callbackOnROReplaceItems === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID),
};
const items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);
const resp = await this._callbackOnROReplaceItems(action, items);
resp.Stories = []; // dont return these (?)
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'MOVE' &&
(data.roElementAction.element_source || {}).storyID &&
typeof this._callbackOnROMoveStories === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
};
const storyIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
const resp = await this._callbackOnROMoveStories(action, storyIDs);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'MOVE' &&
(data.roElementAction.element_source || {}).itemID &&
typeof this._callbackOnROMoveItems === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID),
};
const itemIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
const resp = await this._callbackOnROMoveItems(action, itemIDs);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'DELETE' &&
data.roElementAction.element_source.storyID &&
typeof this._callbackOnRODeleteStories === 'function') {
const stories = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
const resp = await this._callbackOnRODeleteStories({
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
}, stories);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'DELETE' &&
data.roElementAction.element_source.itemID &&
typeof this._callbackOnRODeleteItems === 'function') {
const action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
};
const items = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
const resp = await this._callbackOnRODeleteItems(action, items);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'SWAP' &&
data.roElementAction.element_source.storyID &&
data.roElementAction.element_source.storyID.length === 2 &&
typeof this._callbackOnROSwapStories === 'function') {
const stories = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
const resp = await this._callbackOnROSwapStories({
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
}, stories[0], stories[1]);
return new mosModel_1.ROAck(resp);
}
else if (data.roElementAction &&
data.roElementAction.operation === 'SWAP' &&
data.roElementAction.element_source.itemID &&
data.roElementAction.element_source.itemID.length === 2 &&
typeof this._callbackOnROSwapItems === 'function') {
const items = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
const resp = await this._callbackOnROSwapItems({
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
}, items[0], items[1]);
return new mosModel_1.ROAck(resp);
// Profile 3
}
else if (data.mosItemReplace && typeof this._callbackOnItemReplace === 'function') {
const resp = await this._callbackOnItemReplace(data.mosItemReplace.ID, data.mosItemReplace.itemID, Parser_1.Parser.xml2Item(data.mosItemReplace.item));
return new mosModel_1.ROAck(resp);
}
else if (data.mosObjCreate && typeof this._callbackOnObjectCreate === 'function') {
const resp = await this._callbackOnObjectCreate(Parser_1.Parser.xml2MosObj(data.mosObjCreate));
const ack = new mosModel_1.MOSAck(resp);
return ack;
}
else if (data.mosReqObjAction &&
data.mosReqObjAction.operation === 'NEW' &&
typeof this._callbackOnRequestObjectActionNew === 'function') {
const resp = await this._callbackOnRequestObjectActionNew(Parser_1.Parser.xml2MosObj(data.mosReqObjAction));
return new mosModel_1.MOSAck(resp);
}
else if (data.mosReqObjAction &&
data.mosReqObjAction.operation === 'UPDATE' &&
typeof this._callbackOnRequestObjectActionUpdate === 'function') {
const resp = await this._callbackOnRequestObjectActionUpdate(data.mosReqObjAction.objID, Parser_1.Parser.xml2MosObj(data.mosReqObjAction));
return new mosModel_1.MOSAck(resp);
}
else if (data.mosReqObjAction &&
data.mosReqObjAction.operation === 'DELETE' &&
typeof this._callbackOnRequestObjectActionDelete === 'function') {
const resp = await this._callbackOnRequestObjectActionDelete(data.mosReqObjAction.objID);
return new mosModel_1.MOSAck(resp);
}
else if (data.mosReqObjList && typeof this._callbackOnRequestObjectList === 'function') {
const resp = await this._callbackOnRequestObjectList(Parser_1.Parser.xml2ReqObjList(data.mosReqObjList));
return new mosModel_1.MosObjList(resp);
}
else if (data.mosReqSearchableSchema && typeof this._callbackOnRequestSearchableSchema === 'function') {
const resp = await this._callbackOnRequestSearchableSchema(data.mosReqSearchableSchema.username);
return new mosModel_1.MosListSearchableSchema(resp);
// Profile 4
}
else if (data.roReqAll && typeof this._callbackOnRequestAllRunningOrders === 'function') {
const list = await this._callbackOnRequestAllRunningOrders();
const roListAll = new ROListAll_1.ROListAll();
roListAll.ROs = list;
return roListAll;
}
else if (data.roStorySend && typeof this._callbackOnRunningOrderStory === 'function') {
const story = Parser_1.Parser.xml2FullStory(data.roStorySend);
const resp = await this._callbackOnRunningOrderStory(story);
return new mosModel_1.ROAck(resp);
// TODO: Use MosMessage instead of string
// TODO: Use reject if function dont exists? Put Nack in ondata
}
else {
this.debugTrace(data);
return new mosModel_1.MOSAck({
ID: new mosString128_1.MosString128(0),
Revision: 0,
Description: new mosString128_1.MosString128('Unsupported function'),
Status: api_1.IMOSAckStatus.NACK,
});
// resolve('<mos><mosID>test2.enps.mos</mosID><ncsID>2012R2ENPS8VM</ncsID><messageID>99</messageID><roAck><roID>2012R2ENPS8VM;P_ENPSMOS\W\F_HOLD ROs;DEC46951-28F9-4A11-8B0655D96B347E52</roID><roStatus>Unknown object M000133</roStatus><storyID>5983A501:0049B924:8390EF2B</storyID><itemID>0</itemID><objID>M000224</objID><status>LOADED</status><storyID>3854737F:0003A34D:983A0B28</storyID><itemID>0</itemID><objID>M000133</objID><itemChannel>A</itemChannel><status>UNKNOWN</status></roAck></mos>')
}
}

@@ -481,24 +489,22 @@ // ============================================================================================================

// ============================================================================================================
requestMachineInfo() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.ReqMachInfo();
const data = yield this.executeCommand(message);
const listMachInfo = data.mos.listMachInfo;
const list = {
manufacturer: listMachInfo.manufacturer,
model: listMachInfo.model,
hwRev: listMachInfo.hwRev,
swRev: listMachInfo.swRev,
DOM: listMachInfo.DOM,
SN: listMachInfo.SN,
ID: listMachInfo.ID,
time: listMachInfo.time,
opTime: listMachInfo.opTime,
mosRev: listMachInfo.mosRev,
supportedProfiles: this.supportedProfiles,
defaultActiveX: this.defaultActiveX,
mosExternalMetaData: this.mosExternalMetaData // TODO: No data from ENPS, needs test!
};
return list;
});
async requestMachineInfo() {
const message = new mosModel_1.ReqMachInfo();
const data = await this.executeCommand(message);
const listMachInfo = data.mos.listMachInfo;
const list = {
manufacturer: listMachInfo.manufacturer,
model: listMachInfo.model,
hwRev: listMachInfo.hwRev,
swRev: listMachInfo.swRev,
DOM: listMachInfo.DOM,
SN: listMachInfo.SN,
ID: listMachInfo.ID,
time: listMachInfo.time,
opTime: listMachInfo.opTime,
mosRev: listMachInfo.mosRev,
supportedProfiles: this.supportedProfiles,
defaultActiveX: this.defaultActiveX,
mosExternalMetaData: this.mosExternalMetaData,
};
return list;
}

@@ -516,6 +522,6 @@ onRequestMachineInfo(cb) {

return {
PrimaryConnected: (this._primaryConnection ? this._primaryConnection.connected : false),
PrimaryConnected: this._primaryConnection ? this._primaryConnection.connected : false,
PrimaryStatus: '',
SecondaryConnected: (this._secondaryConnection ? this._secondaryConnection.connected : false),
SecondaryStatus: ''
SecondaryConnected: this._secondaryConnection ? this._secondaryConnection.connected : false,
SecondaryStatus: '',
};

@@ -535,9 +541,7 @@ }

// ============================================================================================================
sendMOSObject(obj) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.MosObj(obj);
const reply = yield this.executeCommand(message);
const ack = Parser_1.Parser.xml2Ack(reply.mos.mosAck);
return ack;
});
async sendMOSObject(obj) {
const message = new mosModel_1.MosObj(obj);
const reply = await this.executeCommand(message);
const ack = Parser_1.Parser.xml2Ack(reply.mos.mosAck);
return ack;
}

@@ -548,17 +552,15 @@ onRequestMOSObject(cb) {

}
sendRequestMOSObject(objID) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.ReqMosObj(objID);
const reply = yield this.executeCommand(message);
if (reply.mos.roAck) {
throw new Error(Parser_1.Parser.xml2ROAck(reply.mos.roAck).toString());
}
else if (reply.mos.mosObj) {
const obj = Parser_1.Parser.xml2MosObj(reply.mos.mosObj);
return obj;
}
else {
throw new Error('Unknown response');
}
});
async sendRequestMOSObject(objID) {
const message = new mosModel_1.ReqMosObj(objID);
const reply = await this.executeCommand(message);
if (reply.mos.roAck) {
throw new Error(Parser_1.Parser.xml2ROAck(reply.mos.roAck).toString());
}
else if (reply.mos.mosObj) {
const obj = Parser_1.Parser.xml2MosObj(reply.mos.mosObj);
return obj;
}
else {
throw new Error('Unknown response');
}
}

@@ -569,17 +571,15 @@ onRequestAllMOSObjects(cb) {

}
sendRequestAllMOSObjects() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.ReqMosObjAll();
const reply = yield this.executeCommand(message);
if (reply.mos.roAck) {
throw new Error(Parser_1.Parser.xml2ROAck(reply.mos.roAck).toString());
}
else if (reply.mos.mosListAll) {
const objs = Parser_1.Parser.xml2MosObjs(reply.mos.mosListAll.mosObj);
return objs;
}
else {
throw new Error('Unknown response');
}
});
async sendRequestAllMOSObjects() {
const message = new mosModel_1.ReqMosObjAll();
const reply = await this.executeCommand(message);
if (reply.mos.roAck) {
throw new Error(Parser_1.Parser.xml2ROAck(reply.mos.roAck).toString());
}
else if (reply.mos.mosListAll) {
const objs = Parser_1.Parser.xml2MosObjs(reply.mos.mosListAll.mosObj);
return objs;
}
else {
throw new Error('Unknown response');
}
}

@@ -589,14 +589,12 @@ /**

*/
_sendAllMOSObjects(objs) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.MosListAll(objs);
const reply = yield this.executeCommand(message);
if (reply.mos) {
const ack = Parser_1.Parser.xml2Ack(reply.mos.mosAck);
return ack;
}
else {
throw new Error('Unknown response');
}
});
async _sendAllMOSObjects(objs) {
const message = new mosModel_1.MosListAll(objs);
const reply = await this.executeCommand(message);
if (reply.mos) {
const ack = Parser_1.Parser.xml2Ack(reply.mos.mosAck);
return ack;
}
else {
throw new Error('Unknown response');
}
}

@@ -620,8 +618,6 @@ /**

}
sendCreateRunningOrder(ro) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roCreate_1.ROCreate(ro);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendCreateRunningOrder(ro) {
const message = new roCreate_1.ROCreate(ro);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -632,8 +628,6 @@ onReplaceRunningOrder(cb) {

}
sendReplaceRunningOrder(ro) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roReplace_1.ROReplace(ro);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendReplaceRunningOrder(ro) {
const message = new roReplace_1.ROReplace(ro);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -644,8 +638,6 @@ onDeleteRunningOrder(cb) {

}
sendDeleteRunningOrder(runningOrderId) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roDelete_1.RODelete(runningOrderId);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendDeleteRunningOrder(runningOrderId) {
const message = new roDelete_1.RODelete(runningOrderId);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -656,13 +648,11 @@ onRequestRunningOrder(cb) {

}
sendRequestRunningOrder(runningOrderId) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.ROReq(runningOrderId);
const data = yield this.executeCommand(message);
if (data.mos.roList) {
const ro = Parser_1.Parser.xml2RO(data.mos.roList);
return ro;
}
else
throw new Error('Unknown response');
});
async sendRequestRunningOrder(runningOrderId) {
const message = new mosModel_1.ROReq(runningOrderId);
const data = await this.executeCommand(message);
if (data.mos.roList) {
const ro = Parser_1.Parser.xml2RO(data.mos.roList);
return ro;
}
else
throw new Error('Unknown response');
}

@@ -679,8 +669,6 @@ /**

}
sendMetadataReplace(metadata) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roMetadataReplace_1.ROMetadataReplace(metadata);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendMetadataReplace(metadata) {
const message = new roMetadataReplace_1.ROMetadataReplace(metadata);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -711,39 +699,33 @@ onRunningOrderStatus(cb) {

}
sendRunningOrderStatus(status) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.ROElementStat({
type: mosModel_1.ROElementStatType.RO,
roId: new mosString128_1.MosString128(status.ID),
status: status.Status
});
const reply = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(reply.mos.roAck);
async sendRunningOrderStatus(status) {
const message = new mosModel_1.ROElementStat({
type: mosModel_1.ROElementStatType.RO,
roId: new mosString128_1.MosString128(status.ID),
status: status.Status,
});
const reply = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(reply.mos.roAck);
}
sendStoryStatus(status) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.ROElementStat({
type: mosModel_1.ROElementStatType.STORY,
roId: new mosString128_1.MosString128(status.RunningOrderId),
storyId: new mosString128_1.MosString128(status.ID),
status: status.Status
});
const reply = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(reply.mos.roAck);
async sendStoryStatus(status) {
const message = new mosModel_1.ROElementStat({
type: mosModel_1.ROElementStatType.STORY,
roId: new mosString128_1.MosString128(status.RunningOrderId),
storyId: new mosString128_1.MosString128(status.ID),
status: status.Status,
});
const reply = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(reply.mos.roAck);
}
sendItemStatus(status) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.ROElementStat({
type: mosModel_1.ROElementStatType.ITEM,
roId: new mosString128_1.MosString128(status.RunningOrderId),
storyId: new mosString128_1.MosString128(status.StoryId),
itemId: new mosString128_1.MosString128(status.ID),
objId: new mosString128_1.MosString128(status.ObjectId),
itemChannel: new mosString128_1.MosString128(status.Channel),
status: status.Status
});
const reply = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(reply.mos.roAck);
async sendItemStatus(status) {
const message = new mosModel_1.ROElementStat({
type: mosModel_1.ROElementStatType.ITEM,
roId: new mosString128_1.MosString128(status.RunningOrderId),
storyId: new mosString128_1.MosString128(status.StoryId),
itemId: new mosString128_1.MosString128(status.ID),
objId: new mosString128_1.MosString128(status.ObjectId),
itemChannel: new mosString128_1.MosString128(status.Channel),
status: status.Status,
});
const reply = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(reply.mos.roAck);
}

@@ -754,11 +736,9 @@ onReadyToAir(cb) {

}
sendReadyToAir(Action) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roReadyToAir_1.ROReadyToAir({
roId: Action.ID,
roAir: Action.Status
});
const reply = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(reply.mos.roAck);
async sendReadyToAir(Action) {
const message = new roReadyToAir_1.ROReadyToAir({
roId: Action.ID,
roAir: Action.Status,
});
const reply = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(reply.mos.roAck);
}

@@ -769,8 +749,6 @@ onROInsertStories(cb) {

}
sendROInsertStories(Action, Stories) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.ROInsertStories(Action, Stories);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendROInsertStories(Action, Stories) {
const message = new roActions_1.ROInsertStories(Action, Stories);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -781,8 +759,6 @@ onROInsertItems(cb) {

}
sendROInsertItems(Action, Items) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.ROInsertItems(Action, Items);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendROInsertItems(Action, Items) {
const message = new roActions_1.ROInsertItems(Action, Items);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -793,8 +769,6 @@ onROReplaceStories(cb) {

}
sendROReplaceStories(Action, Stories) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.ROReplaceStories(Action, Stories);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendROReplaceStories(Action, Stories) {
const message = new roActions_1.ROReplaceStories(Action, Stories);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -805,8 +779,6 @@ onROReplaceItems(cb) {

}
sendROReplaceItems(Action, Items) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.ROReplaceItems(Action, Items);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendROReplaceItems(Action, Items) {
const message = new roActions_1.ROReplaceItems(Action, Items);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -817,8 +789,6 @@ onROMoveStories(cb) {

}
sendROMoveStories(Action, Stories) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.ROMoveStories(Action, Stories);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendROMoveStories(Action, Stories) {
const message = new roActions_1.ROMoveStories(Action, Stories);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -829,8 +799,6 @@ onROMoveItems(cb) {

}
sendROMoveItems(Action, Items) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.ROMoveItems(Action, Items);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendROMoveItems(Action, Items) {
const message = new roActions_1.ROMoveItems(Action, Items);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -841,8 +809,6 @@ onRODeleteStories(cb) {

}
sendRODeleteStories(Action, Stories) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.RODeleteStories(Action, Stories);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendRODeleteStories(Action, Stories) {
const message = new roActions_1.RODeleteStories(Action, Stories);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -853,8 +819,6 @@ onRODeleteItems(cb) {

}
sendRODeleteItems(Action, Items) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.RODeleteItems(Action, Items);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendRODeleteItems(Action, Items) {
const message = new roActions_1.RODeleteItems(Action, Items);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -865,8 +829,6 @@ onROSwapStories(cb) {

}
sendROSwapStories(Action, StoryID0, StoryID1) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.ROSwapStories(Action, StoryID0, StoryID1);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendROSwapStories(Action, StoryID0, StoryID1) {
const message = new roActions_1.ROSwapStories(Action, StoryID0, StoryID1);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -877,8 +839,6 @@ onROSwapItems(cb) {

}
sendROSwapItems(Action, ItemID0, ItemID1) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new roActions_1.ROSwapItems(Action, ItemID0, ItemID1);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendROSwapItems(Action, ItemID0, ItemID1) {
const message = new roActions_1.ROSwapItems(Action, ItemID0, ItemID1);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -892,8 +852,6 @@ // ============================================================================================================

}
sendObjectCreate(object) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.MosObjCreate(object);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2Ack(data.mos.mosAck);
});
async sendObjectCreate(object) {
const message = new mosModel_1.MosObjCreate(object);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2Ack(data.mos.mosAck);
}

@@ -904,8 +862,6 @@ onItemReplace(cb) {

}
sendItemReplace(options) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.MosItemReplace(options);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendItemReplace(options) {
const message = new mosModel_1.MosItemReplace(options);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -918,3 +874,3 @@ onRequestSearchableSchema(cb) {

const message = new mosModel_1.MosReqSearchableSchema({ username });
return this.executeCommand(message).then(response => {
return this.executeCommand(message).then((response) => {
return response.mos.mosListSearchableSchema;

@@ -929,3 +885,3 @@ });

const message = new mosModel_1.MosReqObjList(reqObjList);
return this.executeCommand(message).then(response => {
return this.executeCommand(message).then((response) => {
const objList = response.mos.mosObjList;

@@ -941,9 +897,7 @@ if (objList.list)

}
sendRequestObjectActionNew(obj) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.MosReqObjActionNew({ object: obj });
return this.executeCommand(message).then(response => {
const ack = Parser_1.Parser.xml2Ack(response.mos.mosAck);
return ack;
});
async sendRequestObjectActionNew(obj) {
const message = new mosModel_1.MosReqObjActionNew({ object: obj });
return this.executeCommand(message).then((response) => {
const ack = Parser_1.Parser.xml2Ack(response.mos.mosAck);
return ack;
});

@@ -955,9 +909,7 @@ }

}
sendRequestObjectActionUpdate(objId, obj) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.MosReqObjActionUpdate({ object: obj, objectId: objId });
return this.executeCommand(message).then(response => {
const ack = Parser_1.Parser.xml2Ack(response.mos.mosAck);
return ack;
});
async sendRequestObjectActionUpdate(objId, obj) {
const message = new mosModel_1.MosReqObjActionUpdate({ object: obj, objectId: objId });
return this.executeCommand(message).then((response) => {
const ack = Parser_1.Parser.xml2Ack(response.mos.mosAck);
return ack;
});

@@ -969,9 +921,7 @@ }

}
sendRequestObjectActionDelete(objId) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const message = new mosModel_1.MosReqObjActionDelete({ objectId: objId });
return this.executeCommand(message).then(response => {
const ack = Parser_1.Parser.xml2Ack(response.mos.mosAck);
return ack;
});
async sendRequestObjectActionDelete(objId) {
const message = new mosModel_1.MosReqObjActionDelete({ objectId: objId });
return this.executeCommand(message).then((response) => {
const ack = Parser_1.Parser.xml2Ack(response.mos.mosAck);
return ack;
});

@@ -1027,4 +977,5 @@ }

if (this._currentConnection) {
this.executeCommand(message).then((data) => {
if (data.mos.hasOwnProperty('roListAll')) {
this.executeCommand(message)
.then((data) => {
if (lib_1.has(data.mos, 'roListAll')) {
let xmlRos = (data.mos.roListAll || {}).ro;

@@ -1045,3 +996,4 @@ if (!Array.isArray(xmlRos))

}
}).catch(reject);
})
.catch(reject);
}

@@ -1054,9 +1006,7 @@ });

}
sendRunningOrderStory(story) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
// async sendROSwapItems (Action: IMOSStoryAction, ItemID0: MosString128, ItemID1: MosString128): Promise<IMOSROAck> {
const message = new roStory_1.ROStory(story);
const data = yield this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
});
async sendRunningOrderStory(story) {
// async sendROSwapItems (Action: IMOSStoryAction, ItemID0: MosString128, ItemID1: MosString128): Promise<IMOSROAck> {
const message = new roStory_1.ROStory(story);
const data = await this.executeCommand(message);
return Parser_1.Parser.xml2ROAck(data.mos.roAck);
}

@@ -1093,27 +1043,25 @@ // Deprecated methods:

}
executeCommand(message, resend) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (this._currentConnection) {
this.debugTrace('exec command', message);
if (!this._currentConnection.connected) {
async executeCommand(message, resend) {
if (this._currentConnection) {
this.debugTrace('exec command', message);
if (!this._currentConnection.connected) {
return this.switchConnectionsAndExecuteCommand(message);
}
try {
const reply = await this._currentConnection.executeCommand(message);
return this._ensureReply(reply);
}
catch (e) {
this.debugTrace('errored', e);
if (this._primaryConnection && this._secondaryConnection && !resend) {
return this.switchConnectionsAndExecuteCommand(message);
}
try {
const reply = yield this._currentConnection.executeCommand(message);
return this._ensureReply(reply);
else {
throw e;
}
catch (e) {
this.debugTrace('errored', e);
if (this._primaryConnection && this._secondaryConnection && !resend) {
return this.switchConnectionsAndExecuteCommand(message);
}
else {
throw e;
}
}
}
else {
throw new Error(`Unable to send message due to no current connection`);
}
});
}
else {
throw new Error(`Unable to send message due to no current connection`);
}
}

@@ -1129,3 +1077,3 @@ switchConnections() {

let otherConnection = this._currentConnection === this._primaryConnection ? this._secondaryConnection : this._primaryConnection;
let currentConnection = this._currentConnection;
const currentConnection = this._currentConnection;
if (!otherConnection.connected)

@@ -1138,18 +1086,16 @@ throw new Error(`Unable to failover connection: Other connection is not connected (${otherConnection.host})`);

}
switchConnectionsAndExecuteCommand(message) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
async switchConnectionsAndExecuteCommand(message) {
this.switchConnections();
this.debugTrace('resending msg');
try {
return await this.executeCommand(message, true);
}
catch (e) {
if (`${e}` === 'Main server available') {
// @todo: we may deadlock if primary is down for us, but up for buddy
return this.switchConnectionsAndExecuteCommand(message);
}
this.switchConnections();
this.debugTrace('resending msg');
try {
return yield this.executeCommand(message, true);
}
catch (e) {
if (e.toString() === 'Main server available') {
// @todo: we may deadlock if primary is down for us, but up for buddy
return this.switchConnectionsAndExecuteCommand(message);
}
this.switchConnections();
throw e;
}
});
throw e;
}
}

@@ -1164,7 +1110,7 @@ _emitConnectionChange() {

throw new Error(`Unknown data: <mos> missing from message`);
if (reply.mos.roAck && reply.mos.roAck.roStatus === 'Buddy server cannot respond because main server is available') {
if (reply.mos.roAck &&
reply.mos.roAck.roStatus === 'Buddy server cannot respond because main server is available') {
throw new Error('Buddy server cannot respond because main server is available');
}
if (reply.mos.mosAck &&
reply.mos.mosAck.status === 'NACK') {
if (reply.mos.mosAck && reply.mos.mosAck.status === 'NACK') {
throw new Error(`Error in response: ${reply.mos.mosAck.statusDescription || 'No statusDescription given'}`);

@@ -1181,3 +1127,3 @@ }

const requireCallback = (profile, callbackName, method) => {
// @ts-ignore no index signature
// @ts-expect-error no index signature
if (!this[callbackName]) {

@@ -1199,3 +1145,3 @@ throw new Error(`Error: This MOS-device is configured to support Profile ${profile}, but callback ${method.name} has not been set!`);

const requireProfile = (profile, requiredProfile) => {
// @ts-ignore no index signature
// @ts-expect-error no index signature
if (!this.supportedProfiles['profile' + requiredProfile]) {

@@ -1202,0 +1148,0 @@ throw new Error(`Error: This MOS-device is configured to support Profile ${profile}, therefore it must also support Profile ${requiredProfile}!`);

@@ -6,1 +6,2 @@ export * from './profile0';

export * from './profile4';
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,9 @@

export declare function isEmpty(obj: any): boolean;
export declare function numberOrUndefined(value: any): number | undefined;
export declare function isEmpty(obj: unknown): boolean;
export declare function numberOrUndefined(value: unknown): number | undefined;
/** Just a generic type to use instead of "any", for xml objects */
export declare type AnyXML = {
[key: string]: any;
};
/** Return true if the object has a property */
export declare function has(obj: unknown, property: string): boolean;
//# sourceMappingURL=lib.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.numberOrUndefined = exports.isEmpty = void 0;
exports.has = exports.numberOrUndefined = exports.isEmpty = void 0;
function isEmpty(obj) {
if (typeof obj === 'object') {
for (let prop in obj) {
if (obj.hasOwnProperty(prop)) {
for (const prop in obj) {
if (has(obj, prop)) {
return false;

@@ -22,5 +22,15 @@ }

}
return parseFloat(value);
if (typeof value === 'number')
return value;
const num = parseFloat(`${value}`);
if (isNaN(num))
return undefined;
return num;
}
exports.numberOrUndefined = numberOrUndefined;
/** Return true if the object has a property */
function has(obj, property) {
return Object.hasOwnProperty.call(obj, property);
}
exports.has = has;
//# sourceMappingURL=lib.js.map
import * as XMLBuilder from 'xmlbuilder';
export declare type PortType = 'upper' | 'lower' | 'query';
export declare abstract class MosMessage {
port: PortType;
private static MAX_MESSAGE_ID;
private static _messageID;
mosID: string;
ncsID: string;
port: PortType;
private static _staticMessageID;
mosID: string | undefined;
ncsID: string | undefined;
constructor(port: PortType);

@@ -21,1 +21,2 @@ private _messageID;

}
//# sourceMappingURL=MosMessage.d.ts.map

@@ -9,9 +9,12 @@ "use strict";

this.port = port;
this.mosID = undefined;
this.ncsID = undefined;
this._messageID = 0;
}
static getNewMessageID() {
// increments and returns a signed 32-bit int counting from 1, resetting to 1 when wrapping
MosMessage._messageID++;
if (MosMessage._messageID >= MosMessage.MAX_MESSAGE_ID)
MosMessage._messageID = 1;
return MosMessage._messageID;
MosMessage._staticMessageID++;
if (MosMessage._staticMessageID >= MosMessage.MAX_MESSAGE_ID)
MosMessage._staticMessageID = 1;
return MosMessage._staticMessageID;
}

@@ -25,3 +28,3 @@ /** */

// if (!this.port) throw new Error(`Can't prepare message: port missing`)
this._messageID = (messageID ? messageID : MosMessage.getNewMessageID());
this._messageID = messageID ? messageID : MosMessage.getNewMessageID();
}

@@ -34,4 +37,4 @@ /** */

toString() {
let xml = XMLBuilder.create('mos', undefined, undefined, {
headless: true
const xml = XMLBuilder.create('mos', undefined, undefined, {
headless: true,
});

@@ -47,3 +50,3 @@ Utils_1.addTextElement(xml, 'ncsID', this.ncsID);

MosMessage.MAX_MESSAGE_ID = Math.pow(2, 31) - 2;
MosMessage._messageID = 1;
MosMessage._staticMessageID = 1;
//# sourceMappingURL=MosMessage.js.map

@@ -6,19 +6,21 @@ import * as XMLBuilder from 'xmlbuilder';

import { ROAck } from './profile2/ROAck';
import { AnyXML } from './lib';
export declare namespace Parser {
function xml2ROBase(xml: any): IMOSRunningOrderBase;
function xml2RO(xml: any): IMOSRunningOrder;
function xml2ROBase(xml: AnyXML): IMOSRunningOrderBase;
function xml2RO(xml: AnyXML): IMOSRunningOrder;
function xml2Stories(xml: Array<any>): Array<IMOSROStory>;
function xml2FullStory(xml: any): IMOSROFullStory;
function xml2Story(xml: any): IMOSROStory;
function xml2FullStory(xml: AnyXML): IMOSROFullStory;
function xml2Story(xml: AnyXML): IMOSROStory;
function xml2Items(xml: Array<any>): Array<IMOSItem>;
function xml2Item(xml: any): IMOSItem;
function xml2ObjPaths(xml: any): Array<IMOSObjectPath>;
function xml2MetaData(xml: any): Array<IMOSExternalMetaData>;
function xml2Item(xml: AnyXML): IMOSItem;
function xml2ObjPaths(xml: AnyXML): Array<IMOSObjectPath>;
function xml2MetaData(xml: AnyXML): Array<IMOSExternalMetaData>;
function metaData2xml(md: IMOSExternalMetaData): XMLBuilder.XMLElement;
function xml2IDs(xml: any): Array<MosString128>;
function xml2ROAck(xml: any): ROAck;
function xml2Ack(xml: any): IMOSAck;
function xml2MosObjs(xml: any): Array<IMOSObject>;
function xml2MosObj(xml: any): IMOSObject;
function xml2ReqObjList(xml: any): IMOSRequestObjectList;
function xml2IDs(xml: AnyXML): Array<MosString128>;
function xml2ROAck(xml: AnyXML): ROAck;
function xml2Ack(xml: AnyXML): IMOSAck;
function xml2MosObjs(xml: AnyXML): Array<IMOSObject>;
function xml2MosObj(xml: AnyXML): IMOSObject;
function xml2ReqObjList(xml: AnyXML): IMOSRequestObjectList;
}
//# sourceMappingURL=Parser.d.ts.map

@@ -9,2 +9,3 @@ "use strict";

const xmlConversion_4 = require("./profile1/xmlConversion");
/* eslint-disable @typescript-eslint/no-namespace */
var Parser;

@@ -11,0 +12,0 @@ (function (Parser) {

@@ -11,1 +11,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=heartBeat.d.ts.map

@@ -5,1 +5,2 @@ export * from './heartBeat';

export * from './xmlConversion';
//# sourceMappingURL=index.d.ts.map

@@ -67,1 +67,2 @@ import { MosTime } from '../../dataTypes/mosTime';

}
//# sourceMappingURL=listMachInfo.d.ts.map

@@ -22,3 +22,3 @@ "use strict";

get messageXMLBlocks() {
let xmlListMachInfo = XMLBuilder.create('listMachInfo');
const xmlListMachInfo = XMLBuilder.create('listMachInfo');
Utils_1.addTextElement(xmlListMachInfo, 'manufacturer', this.info.manufacturer);

@@ -40,3 +40,3 @@ Utils_1.addTextElement(xmlListMachInfo, 'model', this.info.model);

for (let i = 0; i < 8; i++) {
Utils_1.addTextElement(xmlSupportedProfiles, 'mosProfile', (this.info.supportedProfiles['profile' + i] ? 'YES' : 'NO')).att('number', i);
Utils_1.addTextElement(xmlSupportedProfiles, 'mosProfile', this.info.supportedProfiles['profile' + i] ? 'YES' : 'NO').att('number', i);
}

@@ -43,0 +43,0 @@ xmlListMachInfo.importDocument(xmlSupportedProfiles);

@@ -9,1 +9,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=reqMachInfo.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

get messageXMLBlocks() {
let messageBlock = XMLBuilder.create('reqMachInfo');
const messageBlock = XMLBuilder.create('reqMachInfo');
return messageBlock;

@@ -16,0 +16,0 @@ }

import { MosString128 } from '../../dataTypes/mosString128';
import { AnyXML } from '../lib';
export declare namespace XMLMosIDs {
function fromXML(xml: any): MosString128[];
function fromXML(xml: AnyXML): MosString128[];
}
//# sourceMappingURL=xmlConversion.d.ts.map

@@ -5,6 +5,7 @@ "use strict";

const mosString128_1 = require("../../dataTypes/mosString128");
/* eslint-disable @typescript-eslint/no-namespace */
var XMLMosIDs;
(function (XMLMosIDs) {
function fromXML(xml) {
let arr = [];
const arr = [];
let xmlIds = xml;

@@ -11,0 +12,0 @@ if (!Array.isArray(xmlIds))

@@ -7,1 +7,2 @@ export * from './mosAck';

export * from './xmlConversion';
//# sourceMappingURL=index.d.ts.map

@@ -11,5 +11,6 @@ import * as XMLBuilder from 'xmlbuilder';

/** */
constructor(ack?: IMOSAck);
constructor(ack: IMOSAck);
/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
}
//# sourceMappingURL=mosAck.d.ts.map

@@ -12,11 +12,10 @@ "use strict";

super('lower');
if (ack) {
this.ID = ack.ID;
this.Status = ack.Status;
this.Description = ack.Description;
}
this.ID = ack.ID;
this.Status = ack.Status;
this.Description = ack.Description;
this.Revision = ack.Revision;
}
/** */
get messageXMLBlocks() {
let root = XMLBuilder.create('mosAck');
const root = XMLBuilder.create('mosAck');
Utils_1.addTextElement(root, 'objID', this.ID);

@@ -23,0 +22,0 @@ Utils_1.addTextElement(root, 'objRev', this.Revision);

@@ -11,1 +11,2 @@ import { MosMessage } from '../MosMessage';

}
//# sourceMappingURL=mosListAll.d.ts.map

@@ -15,5 +15,5 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('mosListAll');
const root = XMLBuilder.create('mosListAll');
this.objs.forEach((obj) => {
let xmlMosObj = XMLBuilder.create('mosObj');
const xmlMosObj = XMLBuilder.create('mosObj');
xmlConversion_1.XMLMosObject.toXML(xmlMosObj, obj);

@@ -20,0 +20,0 @@ root.importDocument(xmlMosObj);

@@ -11,1 +11,2 @@ import { MosMessage } from '../MosMessage';

}
//# sourceMappingURL=mosObj.d.ts.map

@@ -15,3 +15,3 @@ "use strict";

get messageXMLBlocks() {
let xmlMosObj = XMLBuilder.create('mosObj');
const xmlMosObj = XMLBuilder.create('mosObj');
xmlConversion_1.XMLMosObject.toXML(xmlMosObj, this.obj);

@@ -18,0 +18,0 @@ return xmlMosObj;

@@ -11,1 +11,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=reqMosObj.d.ts.map

@@ -15,3 +15,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('mosReqObj');
const root = XMLBuilder.create('mosReqObj');
Utils_1.addTextElement(root, 'objID', this.objId);

@@ -18,0 +18,0 @@ return root;

@@ -10,1 +10,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=reqMosObjAll.d.ts.map

@@ -15,3 +15,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('mosReqAll');
const root = XMLBuilder.create('mosReqAll');
Utils_1.addTextElement(root, 'pause', this.pause + '');

@@ -18,0 +18,0 @@ return root;

import * as XMLBuilder from 'xmlbuilder';
import { IMOSRequestObjectList, IMOSObject, IMOSAck } from '../../api';
import { AnyXML } from '../lib';
export declare namespace XMLMosAck {
function fromXML(xml: any): IMOSAck;
function fromXML(xml: AnyXML): IMOSAck;
}
export declare namespace XMLMosObjects {
function fromXML(xml: any): Array<IMOSObject>;
function fromXML(xml: AnyXML): Array<IMOSObject>;
function toXML(xml: XMLBuilder.XMLElement, objs?: IMOSObject[]): void;
}
export declare namespace XMLMosObject {
function fromXML(xml: any): IMOSObject;
function fromXML(xml: AnyXML): IMOSObject;
function toXML(xml: XMLBuilder.XMLElement, obj: IMOSObject): void;
}
export declare namespace XMLMosRequestObjectList {
function fromXML(xml: any): IMOSRequestObjectList;
function fromXML(xml: AnyXML): IMOSRequestObjectList;
}
//# sourceMappingURL=xmlConversion.d.ts.map

@@ -5,2 +5,3 @@ "use strict";

const XMLBuilder = require("xmlbuilder");
const api_1 = require("../../api");
const mosString128_1 = require("../../dataTypes/mosString128");

@@ -10,10 +11,12 @@ const mosTime_1 = require("../../dataTypes/mosTime");

const Utils_1 = require("../../utils/Utils");
const lib_1 = require("../lib");
/* eslint-disable @typescript-eslint/no-namespace */
var XMLMosAck;
(function (XMLMosAck) {
function fromXML(xml) {
let ack = {
const ack = {
ID: new mosString128_1.MosString128(xml.objID),
Revision: typeof xml.objRev === 'number' ? xml.objRev : 0,
Status: typeof xml.status === 'string' ? xml.status : 'ACK',
Description: new mosString128_1.MosString128(typeof xml.statusDescription === 'string' ? xml.statusDescription : '')
Status: typeof xml.status === 'string' ? xml.status : api_1.IMOSAckStatus.ACK,
Description: new mosString128_1.MosString128(typeof xml.statusDescription === 'string' ? xml.statusDescription : ''),
};

@@ -29,4 +32,3 @@ return ack;

return [];
let xmlObjs = [];
xmlObjs = xml;
let xmlObjs = xml;
if (!Array.isArray(xmlObjs))

@@ -41,4 +43,4 @@ xmlObjs = [xmlObjs];

if (objs) {
objs.forEach(MosObject => {
let xmlMosObj = XMLBuilder.create('mosObj');
objs.forEach((MosObject) => {
const xmlMosObj = XMLBuilder.create('mosObj');
XMLMosObject.toXML(xmlMosObj, MosObject);

@@ -54,3 +56,3 @@ xml.importDocument(xmlMosObj);

function fromXML(xml) {
let mosObj = {
const mosObj = {
ID: new mosString128_1.MosString128(xml.objID),

@@ -71,7 +73,7 @@ Slug: new mosString128_1.MosString128(xml.objSlug),

Changed: new mosTime_1.MosTime(xml.changed),
Description: xml.description
Description: xml.description,
};
if (xml.hasOwnProperty('mosExternalMetadata'))
if (lib_1.has(xml, 'mosExternalMetadata'))
mosObj.MosExternalMetaData = xmlConversion_1.XMLMosExternalMetaData.fromXML(xml.mosExternalMetadata);
if (xml.hasOwnProperty('mosItemEditorProgID'))
if (lib_1.has(xml, 'mosItemEditorProgID'))
mosObj.MosItemEditorProgID = new mosString128_1.MosString128(xml.mosItemEditorProgID);

@@ -120,3 +122,3 @@ return mosObj;

mosSchema: xml.mosSchema,
searchGroups: []
searchGroups: [],
};

@@ -123,0 +125,0 @@ if (typeof list.listReturnStart === 'object')

@@ -6,1 +6,2 @@ export * from './ROAck';

export * from './xmlConversion';
//# sourceMappingURL=index.d.ts.map

@@ -10,5 +10,6 @@ import * as XMLBuilder from 'xmlbuilder';

/** */
constructor(roAck?: IMOSROAck);
constructor(roAck: IMOSROAck);
/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
}
//# sourceMappingURL=ROAck.d.ts.map

@@ -11,11 +11,9 @@ "use strict";

super('upper');
if (roAck) {
this.ID = roAck.ID;
this.Status = roAck.Status;
this.Stories = roAck.Stories;
}
this.ID = roAck.ID;
this.Status = roAck.Status;
this.Stories = roAck.Stories;
}
/** */
get messageXMLBlocks() {
let root = XMLBuilder.create('roAck');
const root = XMLBuilder.create('roAck');
Utils_1.addTextElement(root, 'roID', this.ID);

@@ -22,0 +20,0 @@ Utils_1.addTextElement(root, 'roStatus', this.Status);

@@ -70,1 +70,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roActions.d.ts.map

@@ -21,3 +21,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'INSERT');

@@ -28,3 +28,3 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

const xmlSource = Utils_1.addTextElement(root, 'element_source');
this.Stories.forEach(story => {
this.Stories.forEach((story) => {
xmlConversion_1.XMLROStory.toXML(xmlSource, story);

@@ -43,3 +43,3 @@ });

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'INSERT');

@@ -51,3 +51,3 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

const xmlSource = Utils_1.addTextElement(root, 'element_source');
this.Items.forEach(item => {
this.Items.forEach((item) => {
xmlConversion_1.XMLMosItem.toXML(xmlSource, item);

@@ -66,3 +66,3 @@ });

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'REPLACE');

@@ -73,3 +73,3 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

const xmlSource = Utils_1.addTextElement(root, 'element_source');
this.Stories.forEach(story => {
this.Stories.forEach((story) => {
xmlConversion_1.XMLROStory.toXML(xmlSource, story);

@@ -88,3 +88,3 @@ });

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'INSERT');

@@ -96,3 +96,3 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

const xmlSource = Utils_1.addTextElement(root, 'element_source');
this.Items.forEach(item => {
this.Items.forEach((item) => {
xmlConversion_1.XMLMosItem.toXML(xmlSource, item);

@@ -111,3 +111,3 @@ });

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'MOVE');

@@ -118,3 +118,3 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

const xmlSource = Utils_1.addTextElement(root, 'element_source');
this.Stories.forEach(storyID => {
this.Stories.forEach((storyID) => {
Utils_1.addTextElement(xmlSource, 'storyID', storyID);

@@ -133,3 +133,3 @@ });

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'MOVE');

@@ -141,3 +141,3 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

const xmlSource = Utils_1.addTextElement(root, 'element_source');
this.Items.forEach(itemID => {
this.Items.forEach((itemID) => {
Utils_1.addTextElement(xmlSource, 'itemID', itemID);

@@ -156,7 +156,7 @@ });

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'DELETE');
Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);
const xmlSource = Utils_1.addTextElement(root, 'element_source');
this.Stories.forEach(storyID => {
this.Stories.forEach((storyID) => {
Utils_1.addTextElement(xmlSource, 'storyID', storyID);

@@ -175,3 +175,3 @@ });

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'DELETE');

@@ -182,3 +182,3 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

const xmlSource = Utils_1.addTextElement(root, 'element_source');
this.Items.forEach(itemID => {
this.Items.forEach((itemID) => {
Utils_1.addTextElement(xmlSource, 'itemID', itemID);

@@ -198,3 +198,3 @@ });

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'SWAP');

@@ -217,3 +217,3 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementAction');
const root = XMLBuilder.create('roElementAction');
root.att('operation', 'DELETE');

@@ -220,0 +220,0 @@ Utils_1.addTextElement(root, 'roID', this.Action.RunningOrderID);

@@ -12,1 +12,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roCreate.d.ts.map

@@ -15,3 +15,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roCreate');
const root = XMLBuilder.create('roCreate');
this.fillXMLWithROData(root);

@@ -22,3 +22,3 @@ return root;

xmlConversion_1.XMLRunningOrderBase.toXML(root, this.ro);
this.ro.Stories.forEach(story => {
this.ro.Stories.forEach((story) => {
xmlConversion_1.XMLROStory.toXML(root, story);

@@ -25,0 +25,0 @@ });

@@ -9,1 +9,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roDelete.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roDelete');
const root = XMLBuilder.create('roDelete');
Utils_1.addTextElement(root, 'roID', this.roId);

@@ -16,0 +16,0 @@ return root;

@@ -27,1 +27,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roElementStat.d.ts.map

@@ -23,3 +23,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roElementStat');
const root = XMLBuilder.create('roElementStat');
root.attribute('element', this.options.type.toString());

@@ -26,0 +26,0 @@ Utils_1.addTextElement(root, 'roID', this.options.roId);

@@ -12,1 +12,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=ROList.d.ts.map

@@ -15,3 +15,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roList');
const root = XMLBuilder.create('roList');
this.fillXMLWithROData(root);

@@ -22,3 +22,3 @@ return root;

xmlConversion_1.XMLRunningOrderBase.toXML(root, this.ro);
this.ro.Stories.forEach(story => {
this.ro.Stories.forEach((story) => {
xmlConversion_1.XMLROStory.toXML(root, story);

@@ -25,0 +25,0 @@ });

@@ -11,1 +11,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=ROListAll.d.ts.map

@@ -11,8 +11,9 @@ "use strict";

super('upper');
this.ROs = [];
}
/** */
get messageXMLBlocks() {
let root = XMLBuilder.create('roListAll');
const root = XMLBuilder.create('roListAll');
this.ROs.forEach((RO) => {
let xmlRO = XMLBuilder.create('ro');
const xmlRO = XMLBuilder.create('ro');
Utils_1.addTextElement(root, 'roID', RO.ID);

@@ -19,0 +20,0 @@ Utils_1.addTextElement(root, 'roSlug', RO.Slug);

@@ -9,1 +9,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roMetadataReplace.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roMetadataReplace');
const root = XMLBuilder.create('roMetadataReplace');
xmlConversion_1.XMLRunningOrderBase.toXML(root, this.metadata);

@@ -16,0 +16,0 @@ return root;

@@ -13,1 +13,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roReadyToAir.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roReadyToAir');
const root = XMLBuilder.create('roReadyToAir');
Utils_1.addTextElement(root, 'roID', this.options.roId);

@@ -16,0 +16,0 @@ Utils_1.addTextElement(root, 'roAir', this.options.roAir);

@@ -8,1 +8,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roReplace.d.ts.map

@@ -11,3 +11,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roReplace');
const root = XMLBuilder.create('roReplace');
this.fillXMLWithROData(root);

@@ -14,0 +14,0 @@ return root;

@@ -11,1 +11,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roReq.d.ts.map

@@ -15,3 +15,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roReq');
const root = XMLBuilder.create('roReq');
Utils_1.addTextElement(root, 'roID', this.roId);

@@ -18,0 +18,0 @@ return root;

import * as XMLBuilder from 'xmlbuilder';
import { IMOSROStory, IMOSExternalMetaData, IMOSObjectPath, IMOSItem, IMOSROFullStory, IMOSRunningOrderBase, IMOSRunningOrder } from '../../api';
import { AnyXML } from '../lib';
import { ROAck } from './ROAck';
export declare namespace XMLMosROAck {
function fromXML(xml: any): ROAck;
function fromXML(xml: AnyXML): ROAck;
}
export declare namespace XMLRunningOrderBase {
function fromXML(xml: any): IMOSRunningOrderBase;
function fromXML(xml: AnyXML): IMOSRunningOrderBase;
function toXML(xmlRo: XMLBuilder.XMLElement, ro: IMOSRunningOrderBase): void;
}
export declare namespace XMLRunningOrder {
function fromXML(xml: any): IMOSRunningOrder;
function fromXML(xml: AnyXML): IMOSRunningOrder;
}

@@ -21,3 +22,3 @@ export declare namespace XMLROStories {

export declare namespace XMLROStory {
function fromXML(xml: any): IMOSROStory;
function fromXML(xml: AnyXML): IMOSROStory;
function toXML(xmlRoot: XMLBuilder.XMLElement, story: IMOSROStory): void;

@@ -29,12 +30,13 @@ }

export declare namespace XMLMosItem {
function fromXML(xml: any): IMOSItem;
function fromXML(xml: AnyXML): IMOSItem;
function toXML(root: XMLBuilder.XMLElement, item: IMOSItem): void;
}
export declare namespace XMLMosExternalMetaData {
function fromXML(xml: any): IMOSExternalMetaData[];
function fromXML(xml: AnyXML): IMOSExternalMetaData[];
function toXML(xml: XMLBuilder.XMLElement, metadatas?: IMOSExternalMetaData[]): void;
}
export declare namespace XMLObjectPaths {
function fromXML(xml: any): IMOSObjectPath[];
function fromXML(xml: AnyXML): IMOSObjectPath[];
function toXML(xmlItem: XMLBuilder.XMLElement, paths?: IMOSObjectPath[]): void;
}
//# sourceMappingURL=xmlConversion.d.ts.map

@@ -13,8 +13,11 @@ "use strict";

const xmlConversion_1 = require("../profile1/xmlConversion");
/* eslint-disable @typescript-eslint/no-namespace */
var XMLMosROAck;
(function (XMLMosROAck) {
function fromXML(xml) {
let roAck = new ROAck_1.ROAck();
roAck.ID = new mosString128_1.MosString128(xml.roID);
roAck.Status = new mosString128_1.MosString128(xml.roStatus);
const roAck = new ROAck_1.ROAck({
ID: new mosString128_1.MosString128(xml.roID),
Status: new mosString128_1.MosString128(xml.roStatus),
Stories: [],
});
let xmlStoryIDs = xml.storyID;

@@ -33,3 +36,3 @@ let xmlItemIDs = xml.itemID;

roAck.Stories = [];
let iMax = Math.max(xmlStoryIDs.length, xmlItemIDs.length, xmlObjIDs.length, xmlStatuses.length);
const iMax = Math.max(xmlStoryIDs.length, xmlItemIDs.length, xmlObjIDs.length, xmlStatuses.length);
let story = null;

@@ -42,3 +45,3 @@ let item = null;

ID: new mosString128_1.MosString128(xmlStoryIDs[i]),
Items: []
Items: [],
};

@@ -51,3 +54,3 @@ roAck.Stories.push(story);

Channel: new mosString128_1.MosString128(''),
Objects: []
Objects: [],
};

@@ -59,3 +62,3 @@ if (story)

object = {
Status: xmlStatuses[i]
Status: xmlStatuses[i],
};

@@ -73,25 +76,25 @@ if (item)

function fromXML(xml) {
let ro = {
const ro = {
ID: new mosString128_1.MosString128(xml.roID),
Slug: new mosString128_1.MosString128(xml.roSlug)
Slug: new mosString128_1.MosString128(xml.roSlug),
};
if (xml.hasOwnProperty('roEdStart') && !lib_1.isEmpty(xml.roEdStart))
if (lib_1.has(xml, 'roEdStart') && !lib_1.isEmpty(xml.roEdStart))
ro.EditorialStart = new mosTime_1.MosTime(xml.roEdStart);
if (xml.hasOwnProperty('roEdDur') && !lib_1.isEmpty(xml.roEdDur))
if (lib_1.has(xml, 'roEdDur') && !lib_1.isEmpty(xml.roEdDur))
ro.EditorialDuration = new mosDuration_1.MosDuration(xml.roEdDur);
if (xml.hasOwnProperty('roChannel') && !lib_1.isEmpty(xml.roChannel))
if (lib_1.has(xml, 'roChannel') && !lib_1.isEmpty(xml.roChannel))
ro.DefaultChannel = new mosString128_1.MosString128(xml.roChannel);
if (xml.hasOwnProperty('roTrigger') && !lib_1.isEmpty(xml.roTrigger))
if (lib_1.has(xml, 'roTrigger') && !lib_1.isEmpty(xml.roTrigger))
ro.Trigger = new mosString128_1.MosString128(xml.roTrigger);
if (xml.hasOwnProperty('macroIn') && !lib_1.isEmpty(xml.macroIn))
if (lib_1.has(xml, 'macroIn') && !lib_1.isEmpty(xml.macroIn))
ro.MacroIn = new mosString128_1.MosString128(xml.macroIn);
if (xml.hasOwnProperty('macroOut') && !lib_1.isEmpty(xml.macroOut))
if (lib_1.has(xml, 'macroOut') && !lib_1.isEmpty(xml.macroOut))
ro.MacroOut = new mosString128_1.MosString128(xml.macroOut);
if (xml.hasOwnProperty('mosExternalMetadata') && !lib_1.isEmpty(xml.mosExternalMetadata)) {
if (lib_1.has(xml, 'mosExternalMetadata') && !lib_1.isEmpty(xml.mosExternalMetadata)) {
// TODO: Handle an array of mosExternalMetadata
let meta = {
const meta = {
MosSchema: xml.mosExternalMetadata.mosSchema,
MosPayload: xml.mosExternalMetadata.mosPayload
MosPayload: xml.mosExternalMetadata.mosPayload,
};
if (xml.mosExternalMetadata.hasOwnProperty('mosScope'))
if (lib_1.has(xml.mosExternalMetadata, 'mosScope'))
meta.MosScope = xml.mosExternalMetadata.mosScope;

@@ -125,4 +128,7 @@ ro.MosExternalMetaData = [meta];

function fromXML(xml) {
let stories = XMLROStories.fromXML(xml.story);
let ro = Object.assign(Object.assign({}, XMLRunningOrderBase.fromXML(xml)), { Stories: stories });
const stories = XMLROStories.fromXML(xml.story);
const ro = {
...XMLRunningOrderBase.fromXML(xml),
Stories: stories,
};
return ro;

@@ -161,21 +167,18 @@ }

function fromXML(xml) {
let story = {
const story = {
ID: new mosString128_1.MosString128(xml.storyID),
Slug: new mosString128_1.MosString128(xml.storySlug),
Items: []
// TODO: Add & test Number, ObjectID, MOSID, mosAbstract, Paths
// Channel, EditorialStart, EditorialDuration, UserTimingDuration, Trigger, MacroIn, MacroOut, MosExternalMetaData
// MosExternalMetaData: MOSExternalMetaData.fromXML(xml.mosExternalMetadata)
Items: [],
};
if (xml.hasOwnProperty('item'))
if (lib_1.has(xml, 'item'))
story.Items = story.Items.concat(XMLMosItems.fromXML(xml.item));
if (xml.hasOwnProperty('storyBody') && xml.storyBody) {
if (lib_1.has(xml, 'storyBody') && xml.storyBody) {
// Note: the <storyBody> is sent in roStorySend
if (xml.storyBody.hasOwnProperty('storyItem')) {
if (lib_1.has(xml.storyBody, 'storyItem')) {
story.Items = story.Items.concat(XMLMosItems.fromXML(xml.storyBody.storyItem));
}
}
if (xml.hasOwnProperty('mosExternalMetadata'))
if (lib_1.has(xml, 'mosExternalMetadata'))
story.MosExternalMetaData = XMLMosExternalMetaData.fromXML(xml.mosExternalMetadata);
if (xml.hasOwnProperty('storyNum') && !lib_1.isEmpty(xml.storyNum))
if (lib_1.has(xml, 'storyNum') && !lib_1.isEmpty(xml.storyNum))
story.Number = new mosString128_1.MosString128(xml.storyNum || '');

@@ -211,40 +214,36 @@ return story;

function fromXML(xml) {
let item = {
const item = {
ID: new mosString128_1.MosString128(xml.itemID),
ObjectID: new mosString128_1.MosString128(xml.objID),
MOSID: xml.mosID
// TODO: mosAbstract?: string,
// TODO: Channel?: MosString128,
// TODO: MacroIn?: MosString128,
// TODO: MacroOut?: MosString128,
MOSID: xml.mosID,
};
if (xml.hasOwnProperty('itemSlug') && !lib_1.isEmpty(xml.itemSlug))
if (lib_1.has(xml, 'itemSlug') && !lib_1.isEmpty(xml.itemSlug))
item.Slug = new mosString128_1.MosString128(xml.itemSlug);
if (xml.hasOwnProperty('objPaths'))
if (lib_1.has(xml, 'objPaths'))
item.Paths = XMLObjectPaths.fromXML(xml.objPaths);
if (xml.hasOwnProperty('itemEdStart'))
if (lib_1.has(xml, 'itemEdStart'))
item.EditorialStart = lib_1.numberOrUndefined(xml.itemEdStart);
if (xml.hasOwnProperty('itemEdDur'))
if (lib_1.has(xml, 'itemEdDur'))
item.EditorialDuration = lib_1.numberOrUndefined(xml.itemEdDur);
if (xml.hasOwnProperty('itemUserTimingDur'))
if (lib_1.has(xml, 'itemUserTimingDur'))
item.UserTimingDuration = lib_1.numberOrUndefined(xml.itemUserTimingDur);
if (xml.hasOwnProperty('itemTrigger'))
if (lib_1.has(xml, 'itemTrigger'))
item.Trigger = xml.itemTrigger;
if (xml.hasOwnProperty('mosExternalMetadata'))
if (lib_1.has(xml, 'mosExternalMetadata'))
item.MosExternalMetaData = XMLMosExternalMetaData.fromXML(xml.mosExternalMetadata);
if (xml.hasOwnProperty('mosAbstract'))
if (lib_1.has(xml, 'mosAbstract'))
item.mosAbstract = xml.mosAbstract + '';
if (xml.hasOwnProperty('objSlug'))
if (lib_1.has(xml, 'objSlug'))
item.ObjectSlug = new mosString128_1.MosString128(xml.objSlug, false); // temporary fix for long slugs
if (xml.hasOwnProperty('itemChannel'))
if (lib_1.has(xml, 'itemChannel'))
item.Channel = new mosString128_1.MosString128(xml.itemChannel);
if (xml.hasOwnProperty('objDur'))
if (lib_1.has(xml, 'objDur'))
item.Duration = lib_1.numberOrUndefined(xml.objDur);
if (xml.hasOwnProperty('objTB'))
if (lib_1.has(xml, 'objTB'))
item.TimeBase = lib_1.numberOrUndefined(xml.objTB);
if (xml.hasOwnProperty('macroIn'))
if (lib_1.has(xml, 'macroIn'))
item.MacroIn = new mosString128_1.MosString128(xml.macroIn);
if (xml.hasOwnProperty('macroOut'))
if (lib_1.has(xml, 'macroOut'))
item.MacroOut = new mosString128_1.MosString128(xml.macroOut);
if (xml.hasOwnProperty('mosObj')) {
if (lib_1.has(xml, 'mosObj')) {
// Note: the <mosObj> is sent in roStorySend

@@ -299,6 +298,6 @@ item.MosObjects = xmlConversion_1.XMLMosObjects.fromXML(xml.mosObj);

return xmlMetadata.map((xmlmd) => {
let md = {
MosScope: (xmlmd.hasOwnProperty('mosScope') ? xmlmd.mosScope : null),
const md = {
MosScope: lib_1.has(xmlmd, 'mosScope') ? xmlmd.mosScope : null,
MosSchema: xmlmd.mosSchema + '',
MosPayload: _fixPayload(xmlmd.mosPayload)
MosPayload: _fixPayload(xmlmd.mosPayload),
};

@@ -309,44 +308,5 @@ return md;

XMLMosExternalMetaData.fromXML = fromXML;
function _handlePayloadProperties(prop) {
// prop is string, can be a mis-typing of number - if it contains numbers and comma
// strings with numbers and , grouped will trigger
if (prop && typeof prop === 'string' && prop.match(/[0-9]+[,][0-9]+/)) {
// here is the fix for replacing and casting
let commaCast = prop.replace(/,/, '.');
let floatCast = parseFloat(commaCast);
// ensure that the float hasn't changed value or content by checking it in reverse before returning the altered one
if (floatCast.toString() === commaCast) {
return floatCast;
}
}
// return the original content if we failed to identify and mutate the content
return prop;
}
function _fixPayload(obj) {
if (typeof obj === 'object') {
for (let key in obj) {
let o = obj[key];
if (typeof o === 'object') {
if (lib_1.isEmpty(o)) {
obj[key] = '';
}
else {
_fixPayload(o);
}
}
else {
// do property-check on certain props (like MediaTime)
obj[key] = _handlePayloadProperties(o);
}
}
}
else {
// do property-check on certain props (like MediaTime)
obj = _handlePayloadProperties(obj);
}
return obj;
}
function toXML(xml, metadatas) {
if (metadatas) {
metadatas.forEach(metadata => {
metadatas.forEach((metadata) => {
const xmlMetadata = XMLBuilder.create({

@@ -356,4 +316,4 @@ mosExternalMetadata: {

mosPayload: metadata.MosPayload,
mosScope: metadata.MosScope
}
mosScope: metadata.MosScope,
},
});

@@ -366,2 +326,41 @@ xml.importDocument(xmlMetadata);

})(XMLMosExternalMetaData = exports.XMLMosExternalMetaData || (exports.XMLMosExternalMetaData = {}));
function _handlePayloadProperties(prop) {
// prop is string, can be a mis-typing of number - if it contains numbers and comma
// strings with numbers and , grouped will trigger
if (prop && typeof prop === 'string' && prop.match(/[0-9]+[,][0-9]+/)) {
// here is the fix for replacing and casting
const commaCast = prop.replace(/,/, '.');
const floatCast = parseFloat(commaCast);
// ensure that the float hasn't changed value or content by checking it in reverse before returning the altered one
if (floatCast.toString() === commaCast) {
return floatCast;
}
}
// return the original content if we failed to identify and mutate the content
return prop;
}
function _fixPayload(obj) {
if (typeof obj === 'object') {
for (const key in obj) {
const o = obj[key];
if (typeof o === 'object') {
if (lib_1.isEmpty(o)) {
obj[key] = '';
}
else {
_fixPayload(o);
}
}
else {
// do property-check on certain props (like MediaTime)
obj[key] = _handlePayloadProperties(o);
}
}
}
else {
// do property-check on certain props (like MediaTime)
obj = _handlePayloadProperties(obj);
}
return obj;
}
var XMLObjectPaths;

@@ -374,9 +373,9 @@ (function (XMLObjectPaths) {

let type = null;
if (xml.hasOwnProperty('objPath') || xml.$name === 'objPath') {
if (lib_1.has(xml, 'objPath') || xml.$name === 'objPath') {
type = api_1.IMOSObjectPathType.PATH;
}
else if (xml.hasOwnProperty('objProxyPath') || xml.$name === 'objProxyPath') {
else if (lib_1.has(xml, 'objProxyPath') || xml.$name === 'objProxyPath') {
type = api_1.IMOSObjectPathType.PROXY_PATH;
}
else if (xml.hasOwnProperty('objMetadataPath') || xml.$name === 'objMetadataPath') {
else if (lib_1.has(xml, 'objMetadataPath') || xml.$name === 'objMetadataPath') {
type = api_1.IMOSObjectPathType.METADATA_PATH;

@@ -403,3 +402,3 @@ }

Description: description,
Target: target
Target: target,
};

@@ -411,3 +410,3 @@ }

let paths = [];
if (obj.hasOwnProperty('techDescription')) {
if (lib_1.has(obj, 'techDescription')) {
const mosObj = getMosObjectPath(obj);

@@ -419,3 +418,3 @@ if (mosObj) {

else {
Object.keys(obj).forEach(key => {
Object.keys(obj).forEach((key) => {
const element = obj[key];

@@ -445,3 +444,3 @@ if (Array.isArray(element)) {

Utils_1.addTextElement(xmlObjPaths, 'objPath', path.Target, {
techDescription: path.Description
techDescription: path.Description,
});

@@ -451,3 +450,3 @@ }

Utils_1.addTextElement(xmlObjPaths, 'objProxyPath', path.Target, {
techDescription: path.Description
techDescription: path.Description,
});

@@ -457,3 +456,3 @@ }

Utils_1.addTextElement(xmlObjPaths, 'objMetadataPath', path.Target, {
techDescription: path.Description
techDescription: path.Description,
});

@@ -460,0 +459,0 @@ }

@@ -8,1 +8,2 @@ export * from './mosItemReplace';

export * from './mosReqSearchableSchema';
//# sourceMappingURL=index.d.ts.map

@@ -9,1 +9,2 @@ import { MosItemReplaceOptions } from '../../api';

}
//# sourceMappingURL=mosItemReplace.d.ts.map

@@ -9,1 +9,2 @@ import { MosMessage } from '../MosMessage';

}
//# sourceMappingURL=mosListSearchableSchema.d.ts.map

@@ -9,1 +9,2 @@ import { IMOSObject } from '../../api';

}
//# sourceMappingURL=mosObjCreate.d.ts.map

@@ -14,3 +14,3 @@ "use strict";

get messageXMLBlocks() {
let xml = XMLBuilder.create('mosObjCreate');
const xml = XMLBuilder.create('mosObjCreate');
xmlConversion_1.XMLMosObject.toXML(xml, this.object);

@@ -17,0 +17,0 @@ return xml;

@@ -9,1 +9,2 @@ import { IMOSObjectList } from '../../api';

}
//# sourceMappingURL=mosObjList.d.ts.map

@@ -30,1 +30,2 @@ import { IMOSObject } from '../../api';

}
//# sourceMappingURL=mosReqObjAction.d.ts.map

@@ -9,1 +9,2 @@ import { IMOSRequestObjectList } from '../../api';

}
//# sourceMappingURL=mosReqObjList.d.ts.map

@@ -25,5 +25,4 @@ "use strict";

const attributes = {};
Object.keys(searchField).forEach(key => {
// @ts-ignore
attributes[key] = searchField[key] + '';
Object.entries(searchField).forEach(([key, value]) => {
attributes[key] = value + '';
});

@@ -30,0 +29,0 @@ Utils_1.addTextElement(xmlSearchGroup, 'searchField', '', attributes);

@@ -10,1 +10,2 @@ import { MosMessage } from '../MosMessage';

}
//# sourceMappingURL=mosReqSearchableSchema.d.ts.map
export * from './roReqAll';
export * from './xmlConversion';
//# sourceMappingURL=index.d.ts.map

@@ -9,1 +9,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roReqAll.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

get messageXMLBlocks() {
let root = XMLBuilder.create('roReqAll');
const root = XMLBuilder.create('roReqAll');
return root;

@@ -16,0 +16,0 @@ }

@@ -11,1 +11,2 @@ import * as XMLBuilder from 'xmlbuilder';

}
//# sourceMappingURL=roStory.d.ts.map

@@ -17,7 +17,7 @@ "use strict";

get messageXMLBlocks() {
let xmlStory = XMLBuilder.create('roStorySend');
const xmlStory = XMLBuilder.create('roStorySend');
xmlConversion_1.XMLROStoryBase.toXML(xmlStory, this.fullStory);
Utils_1.addTextElement(xmlStory, 'roID', this.fullStory.RunningOrderId);
const xmlStoryBody = Utils_1.addTextElement(xmlStory, 'storyBody');
this.fullStory.Body.forEach(bodyItem => {
this.fullStory.Body.forEach((bodyItem) => {
if (bodyItem.Type === 'storyItem') {

@@ -24,0 +24,0 @@ const xmlItem = Utils_1.addTextElement(xmlStoryBody, 'storyItem');

import { IMOSROFullStory } from '../../api';
import { AnyXML } from '../lib';
export declare namespace XMLROFullStory {
function fromXML(xml: any): IMOSROFullStory;
function fromXML(xml: AnyXML): IMOSROFullStory;
}
//# sourceMappingURL=xmlConversion.d.ts.map

@@ -6,7 +6,10 @@ "use strict";

const mosString128_1 = require("../../dataTypes/mosString128");
/* eslint-disable @typescript-eslint/no-namespace */
var XMLROFullStory;
(function (XMLROFullStory) {
function fromXML(xml) {
let story0 = xmlConversion_1.XMLROStory.fromXML(xml);
let story = {
if (typeof xml !== 'object')
throw new Error('XML is not an object');
const story0 = xmlConversion_1.XMLROStory.fromXML(xml);
const story = {
ID: story0.ID,

@@ -17,3 +20,3 @@ Slug: story0.Slug,

RunningOrderId: new mosString128_1.MosString128(xml.roID),
Body: fromXMLStoryBody(xml.storyBody)
Body: fromXMLStoryBody(xml.storyBody),
};

@@ -23,50 +26,50 @@ return story;

XMLROFullStory.fromXML = fromXML;
function fromXMLStoryBody(xml) {
let body = [];
/*
// Not able to implement this currently, need to change {arrayNotation: true} in xml2json option
let elementKeys = Object.keys(xml)
elementKeys.forEach((key: string) => {
// let elements
let d = xml[key]
})(XMLROFullStory = exports.XMLROFullStory || (exports.XMLROFullStory = {}));
function fromXMLStoryBody(xml) {
const body = [];
/*
// Not able to implement this currently, need to change {arrayNotation: true} in xml2json option
let elementKeys = Object.keys(xml)
elementKeys.forEach((key: string) => {
// let elements
let d = xml[key]
if (!Array.isArray(d)) d = [d]
if (!Array.isArray(d)) d = [d]
d.forEach((el: any) => {
let bodyItem: IMOSROFullStoryBodyItem = {
Type: key,
Content: el
}
body.push(bodyItem)
})
d.forEach((el: any) => {
let bodyItem: IMOSROFullStoryBodyItem = {
Type: key,
Content: el
}
body.push(bodyItem)
})
*/
if (xml.elements && Array.isArray(xml.elements)) {
for (const item of xml.elements) {
let bodyItem = {
Type: item.$name || item.$type,
Content: item
};
if (item.$name === 'storyItem') {
bodyItem.Content = xmlConversion_1.XMLMosItem.fromXML(item);
}
body.push(bodyItem);
})
*/
if (xml.elements && Array.isArray(xml.elements)) {
for (const item of xml.elements) {
const bodyItem = {
Type: item.$name || item.$type,
Content: item,
};
if (item.$name === 'storyItem') {
bodyItem.Content = xmlConversion_1.XMLMosItem.fromXML(item);
}
body.push(bodyItem);
}
// Temporary implementation:
if (xml.storyItem) {
let items = xml.storyItem;
if (!Array.isArray(items))
items = [items];
items.forEach((item) => {
let bodyItem = {
Type: 'storyItem',
Content: item
};
body.push(bodyItem);
});
}
return body;
}
})(XMLROFullStory = exports.XMLROFullStory || (exports.XMLROFullStory = {}));
// Temporary implementation:
if (xml.storyItem) {
let items = xml.storyItem;
if (!Array.isArray(items))
items = [items];
items.forEach((item) => {
const bodyItem = {
Type: 'storyItem',
Content: item,
};
body.push(bodyItem);
});
}
return body;
}
//# sourceMappingURL=xmlConversion.js.map

@@ -7,3 +7,5 @@ import * as XMLBuilder from 'xmlbuilder';

export declare function pad(n: string, width: number, z?: string): string;
export declare function xml2js(messageString: string): object;
export declare function xml2js(messageString: string): {
[key: string]: any;
};
export declare function addTextElement(root: XMLBuilder.XMLElement, elementName: string, text?: string | number | null | MosString128 | MosTime | MosDuration, attributes?: {

@@ -17,1 +19,2 @@ [key: string]: string;

export declare function xmlToObject(root: XMLBuilder.XMLElement): any;
//# sourceMappingURL=Utils.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

function xml2js(messageString) {
let object = xml_js_1.xml2js(messageString, { compact: false, trim: true, nativeType: true });
const object = xml_js_1.xml2js(messageString, { compact: false, trim: true, nativeType: true });
// common tags we typically want to know the order of the contents of:

@@ -62,6 +62,7 @@ const orderedTags = new Set(['storyBody', 'mosAbstract', 'description', 'p', 'em', 'span', 'h1', 'h2', 'i', 'b']);

}
if (!orderedTags.has(element.$name)) { // if the element name is contained in the set of orderedTag names we don't make it any more compact
let names = element.elements.map((obj) => obj.$name || obj.$type || 'unknownElement');
let namesSet = new Set(names);
if ((namesSet.size === 1 && names.length !== 1) && !namesSet.has('type') && !namesSet.has('name')) {
if (!orderedTags.has(element.$name)) {
// if the element name is contained in the set of orderedTag names we don't make it any more compact
const names = element.elements.map((obj) => obj.$name || obj.$type || 'unknownElement');
const namesSet = new Set(names);
if (namesSet.size === 1 && names.length !== 1 && !namesSet.has('type') && !namesSet.has('name')) {
// make array compact:

@@ -108,3 +109,6 @@ const array = [];

for (const childEl of element.elements) {
if (childEl.$type && childEl.$type === 'text' && (Object.keys(childEl).length <= 3 || (!childEl.$name && Object.keys(childEl).length < 3))) {
if (childEl.$type &&
childEl.$type === 'text' &&
(Object.keys(childEl).length <= 3 ||
(!childEl.$name && Object.keys(childEl).length < 3))) {
if (!childEl.text) {

@@ -172,7 +176,3 @@ element.text = childEl.text;

function addTextElement(root, elementName, text, attributes) {
const txt = (text === null ?
null :
text !== undefined ?
text.toString() :
undefined);
const txt = text === null ? null : text !== undefined ? text.toString() : undefined;
const element = root.element(elementName, attributes || {}, txt);

@@ -179,0 +179,0 @@ return element;

{
"name": "mos-connection",
"version": "1.0.3",
"version": "1.0.5-0",
"description": "MOS compliant TCP/IP Socket connection.",

@@ -36,10 +36,9 @@ "main": "dist/index.js",

"build:main": "tsc -p tsconfig.build.json",
"lint": "tslint --project tsconfig.json --config tslint.json",
"eslint": "eslint --ext .ts --ext .js --ext .tsx --ext .jsx --ignore-pattern dist",
"lint": "yarn eslint .",
"lint-fix": "yarn lint --fix",
"unit": "jest --forceExit",
"test": "yarn lint && yarn unit",
"unitci": "jest --forceExit --maxWorkers=2",
"testci": "yarn lint && yarn unitci",
"test:integration": "yarn lint && jest --config=jest-integration.config.js",
"watch": "jest --watch",
"cov": "jest --coverage; open-cli coverage/lcov-report/index.html",
"cov": "jest --coverage=true && yarn cov-open",
"cov-open": "open-cli coverage/lcov-report/index.html",

@@ -49,11 +48,12 @@ "send-coverage": "codecov",

"docs:test": "yarn docs:html",
"docs:html": "typedoc src/index.ts --excludePrivate --theme minimal --out docs",
"docs:html": "typedoc src/index.ts --excludePrivate --theme default --out docs",
"docs:json": "typedoc --json docs/typedoc.json src/index.ts",
"docs:publish": "yarn docs:html && gh-pages -d docs",
"changelog": "standard-version",
"release": "yarn reset && yarn docs:publish && yarn changelog",
"release": "standard-version",
"release:bump-release": "yarn release",
"release:bump-prerelease": "yarn release --prerelease",
"reset": "git clean -dfx && git reset --hard && yarn",
"validate:dependencies": "yarn audit --groups dependencies && yarn license-validate",
"validate:dev-dependencies": "yarn audit --groups devDependencies",
"license-validate": "node-license-validator -p -d --allow-licenses MIT 0BSD BSD BSD-3-Clause ISC Apache"
"license-validate": "yarn sofie-licensecheck --allowPackages caniuse-lite@1.0.30001251"
},

@@ -77,3 +77,2 @@ "scripts-info": {

"docs:publish": "Generate HTML API documentation and push it to GitHub Pages",
"changelog": "Bump package.json version, update CHANGELOG.md, tag a release",
"release": "Clean, build, test, publish docs, and prepare release (a one-step publish process). Updates versions and creates git commits.",

@@ -85,3 +84,3 @@ "reset": "Delete all untracked files and reset the repo to the last commit",

"engines": {
"node": ">=10.10"
"node": ">=12"
},

@@ -95,17 +94,15 @@ "files": [

"devDependencies": {
"@types/jest": "^26.0.22",
"@sofie-automation/code-standard-preset": "^0.4.2",
"@types/jest": "^27.0.2",
"@types/node": "^12.12.3",
"codecov": "^3.8.1",
"gh-pages": "^3.1.0",
"jest": "^26.6.3",
"codecov": "^3.8.3",
"gh-pages": "^3.2.3",
"jest": "^27.2.1",
"mockdate": "^3.0.5",
"node-license-validator": "^1.3.0",
"npm-scripts-info": "^0.3.9",
"open-cli": "^6.0.1",
"standard-version": "^9.2.0",
"standard-version": "^9.3.1",
"trash-cli": "^4.0.0",
"ts-jest": "^26.5.4",
"tslint": "^6.1.3",
"tslint-config-standard": "^9.0.0",
"typedoc": "^0.20.35",
"ts-jest": "^27.0.5",
"typedoc": "^0.22.4",
"typescript": "~4.1.5"

@@ -135,8 +132,19 @@ },

"standard-version": {
"message": "chore(release): %s [skip ci]",
"message": "chore(release): %s",
"tagPrefix": ""
},
"resolutions": {
"node-license-validator/**/minimist": "^1.2.5"
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{css,json,md,scss}": [
"prettier"
],
"*.{ts,tsx,js,jsx}": [
"yarn eslint"
]
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet