New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mos-connection

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mos-connection - npm Package Compare versions

Comparing version 0.8.4 to 0.8.5

2

CHANGELOG.md

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

### [0.8.5](https://github.com/nrkno/tv-automation-mos-connection/compare/0.8.4...0.8.5) (2019-10-25)
### [0.8.4](https://github.com/nrkno/tv-automation-mos-connection/compare/0.8.3...0.8.4) (2019-08-20)

@@ -7,0 +9,0 @@

4

dist/api.d.ts

@@ -29,5 +29,7 @@ import { IProfiles } from './config/connectionConfig';

onRequestMOSObject: (cb: (objId: string) => Promise<IMOSObject | null>) => void;
onRequestAllMOSObjects: (cb: () => Promise<Array<IMOSObject>>) => void;
onRequestAllMOSObjects: (cb: (pause: number) => Promise<Array<IMOSObject> | IMOSAck>) => void;
getMOSObject: (objId: MosString128) => Promise<IMOSObject>;
getAllMOSObjects: () => Promise<Array<IMOSObject>>;
setMOSObject(obj: IMOSObject): Promise<IMOSAck>;
setAllMOSObjects(objs: IMOSObject[]): Promise<IMOSAck>;
onCreateRunningOrder: (cb: (ro: IMOSRunningOrder) => Promise<IMOSROAck>) => void;

@@ -34,0 +36,0 @@ onReplaceRunningOrder: (cb: (ro: IMOSRunningOrder) => Promise<IMOSROAck>) => void;

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

if (str.text) {
this._str = '' + str.text + '';
this._str = str.text.toString();
}
else if (str._str) {
this._str = '' + str._str + '';
this._str = str._str.toString();
}
else if (Object.keys(str).length === 0) { // is empty?
else if (Object.keys(str).length === 0) {
// is empty?
this._str = '';

@@ -30,3 +31,3 @@ }

else {
this._str = '' + str + '';
this._str = str !== `undefined` ? String(str) : '';
}

@@ -33,0 +34,0 @@ this._validate();

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const connectionConfig_1 = require("./config/connectionConfig");

@@ -293,13 +294,17 @@ const mosSocketServer_1 = require("./connection/mosSocketServer");

});
client.socket.on('data', (data) => {
let messageString = iconv.decode(data, 'utf16-be').trim();
client.socket.on('data', (data) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const messageString = iconv.decode(data, 'utf16-be').trim();
this.emit('rawMessage', 'incoming', 'recieved', messageString);
if (this._debug)
console.log(`Socket got data (${socketID}, ${client.socket.remoteAddress}, ${client.portDescription}): ${data}`);
const remoteAddressContent = client.socket.remoteAddress
? client.socket.remoteAddress.split(':')
: undefined;
const remoteAddress = remoteAddressContent ? remoteAddressContent[remoteAddressContent.length - 1] : '';
// Figure out if the message buffer contains a complete MOS-message:
let parsed = null;
let firstMatch = '<mos>';
let first = messageString.substr(0, firstMatch.length);
let lastMatch = '</mos>';
let last = messageString.substr(-lastMatch.length);
const firstMatch = '<mos>';
const first = messageString.substr(0, firstMatch.length);
const lastMatch = '</mos>';
const last = messageString.substr(-lastMatch.length);
if (!client.chunks)

@@ -326,7 +331,6 @@ client.chunks = '';

if (parsed !== null) {
let mosDevice = (this._mosDevices[parsed.mos.ncsID + '_' + parsed.mos.mosID] ||
this._mosDevices[parsed.mos.mosID + '_' + parsed.mos.ncsID]);
let mosMessageId = parsed.mos.messageID;
let ncsID = parsed.mos.ncsID;
let mosID = parsed.mos.mosID;
const ncsID = parsed.mos.ncsID;
const mosID = parsed.mos.mosID;
const mosMessageId = parsed.mos.messageID;
let mosDevice = this._mosDevices[ncsID + '_' + mosID] || this._mosDevices[mosID + '_' + ncsID];
let sendReply = (message) => {

@@ -336,4 +340,4 @@ message.ncsID = ncsID;

message.prepare(mosMessageId);
let messageString = message.toString();
let buf = iconv.encode(messageString, 'utf16-be');
const messageString = message.toString();
const buf = iconv.encode(messageString, 'utf16-be');
client.socket.write(buf, 'usc2');

@@ -345,7 +349,12 @@ this.emit('rawMessage', 'incoming_' + socketID, 'sent', messageString);

// Register a new mosDevice to use for this connection:
if (parsed.mos.ncsID === this._conf.mosID) {
mosDevice = this._registerMosDevice(this._conf.mosID, parsed.mos.mosID, null, null, null);
if (ncsID === this._conf.mosID) {
mosDevice = this._registerMosDevice(this._conf.mosID, mosID, null, null, null);
}
else if (parsed.mos.mosID === this._conf.mosID) {
mosDevice = this._registerMosDevice(this._conf.mosID, parsed.mos.ncsID, null, null, null);
else if (mosID === this._conf.mosID) {
mosDevice = yield this.connect({
primary: {
id: ncsID,
host: remoteAddress
}
});
}

@@ -398,3 +407,3 @@ }

}
});
}));
client.socket.on('error', (e) => {

@@ -401,0 +410,0 @@ if (this._debug)

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

onRequestMOSObject(cb: (objId: string) => Promise<IMOSObject | null>): void;
onRequestAllMOSObjects(cb: () => Promise<Array<IMOSObject>>): void;
onRequestAllMOSObjects(cb: (pause: number) => Promise<Array<IMOSObject> | IMOSAck>): void;
getMOSObject(objID: MosString128): Promise<IMOSObject>;
getAllMOSObjects(): Promise<Array<IMOSObject>>;
setMOSObject(obj: IMOSObject): Promise<IMOSAck>;
setAllMOSObjects(objs: IMOSObject[]): Promise<IMOSAck>;
onCreateRunningOrder(cb: (ro: IMOSRunningOrder) => Promise<IMOSROAck>): void;

@@ -88,0 +90,0 @@ onReplaceRunningOrder(cb: (ro: IMOSRunningOrder) => Promise<IMOSROAck>): void;

@@ -153,5 +153,17 @@ "use strict";

else if (data.mosReqAll && typeof this._callbackOnRequestAllMOSObjects === 'function') {
this._callbackOnRequestAllMOSObjects().then((mosObjs) => {
let resp = new mosModel_1.MosListAll(mosObjs);
resolve(resp);
const pause = data.mosReqAll.pause || 0;
this._callbackOnRequestAllMOSObjects(pause)
.then(resp => {
if (Array.isArray(resp)) {
let list = new mosModel_1.MosListAll(resp);
resolve(list);
}
else {
const mosAck = new mosModel_1.MOSAck();
mosAck.ID = resp.ID;
mosAck.Revision = resp.Revision;
mosAck.Status = resp.Status;
mosAck.Description = resp.Description;
resolve(mosAck);
}
}).catch(reject);

@@ -306,3 +318,3 @@ // Profile 2:

RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128(data.roElementAction.element_target.storyID)
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
};

@@ -325,4 +337,4 @@ let stories = Parser_1.Parser.xml2Stories([data.roElementAction.element_source.story]);

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)
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID)
};

@@ -345,3 +357,3 @@ let items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);

RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128(data.roElementAction.element_target.storyID)
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
};

@@ -363,4 +375,4 @@ let stories = Parser_1.Parser.xml2Stories([data.roElementAction.element_source.story]);

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)
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID)
};

@@ -383,3 +395,3 @@ let items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);

RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128(data.roElementAction.element_target.storyID)
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
};

@@ -401,4 +413,4 @@ let storyIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);

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)
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),
ItemID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).itemID)
};

@@ -435,3 +447,3 @@ let itemIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);

RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128(data.roElementAction.element_target.storyID)
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
};

@@ -471,3 +483,3 @@ let items = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);

RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),
StoryID: new mosString128_1.MosString128(data.roElementAction.element_target.storyID)
StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID)
}, items[0], items[1]).then((resp) => {

@@ -640,2 +652,38 @@ let ack = new mosModel_1.ROAck();

}
setMOSObject(obj) {
let message = new mosModel_1.MosObj(obj);
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message)
.then(data => {
if (data.mos) {
let ack = Parser_1.Parser.xml2Ack(data.mos.mosAck);
resolve(ack);
}
else {
reject('Unknown response');
}
})
.catch(reject);
}
});
}
setAllMOSObjects(objs) {
let message = new mosModel_1.MosListAll(objs);
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message)
.then(data => {
if (data.mos) {
let ack = Parser_1.Parser.xml2Ack(data.mos.mosAck);
resolve(ack);
}
else {
reject('Unknown response');
}
})
.catch(reject);
}
});
}
/* Profile 2 */

@@ -642,0 +690,0 @@ onCreateRunningOrder(cb) {

import * as XMLBuilder from 'xmlbuilder';
import { IMOSRunningOrder, IMOSROStory, IMOSItem, IMOSObjectPath, IMOSRunningOrderBase, IMOSObject, IMOSROFullStory, IMOSROFullStoryBodyItem, IMosRequestObjectList } from '../api';
import { IMOSRunningOrder, IMOSROStory, IMOSItem, IMOSObjectPath, IMOSRunningOrderBase, IMOSObject, IMOSROFullStory, IMOSROFullStoryBodyItem, IMosRequestObjectList, IMOSAck } from '../api';
import { IMOSExternalMetaData } from '../dataTypes/mosExternalMetaData';

@@ -22,2 +22,3 @@ import { MosString128 } from '../dataTypes/mosString128';

function xml2ROAck(xml: any): ROAck;
function xml2Ack(xml: any): IMOSAck;
function xml2MosObjs(xml: any): Array<IMOSObject>;

@@ -24,0 +25,0 @@ function xml2MosObj(xml: any): IMOSObject;

@@ -446,2 +446,12 @@ "use strict";

Parser.xml2ROAck = xml2ROAck;
function xml2Ack(xml) {
let 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 : '')
};
return ack;
}
Parser.xml2Ack = xml2Ack;
function xml2MosObjs(xml) {

@@ -448,0 +458,0 @@ if (!xml)

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

this.obj = obj;
this.port = 'lower';
}

@@ -12,0 +13,0 @@ /** */

{
"name": "mos-connection",
"version": "0.8.4",
"version": "0.8.5",
"description": "MOS compliant TCP/IP Socket connection.",

@@ -86,5 +86,5 @@ "main": "dist/index.js",

"@types/node": "^8.0.4",
"codecov": "^3.5.0",
"codecov": "^3.6.1",
"gh-pages": "^2.0.1",
"jest": "^24.8.0",
"jest": "^24.9.0",
"mkdirp": "^0.5.1",

@@ -91,0 +91,0 @@ "node-license-validator": "^1.3.0",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc