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.9.1-nightly-featur-ncs-functions-20210416-075213-811be5c.0 to 0.9.1-nightly-fix-mos-messages-in-chunks-20210429-155455-935ac2b.0

507

dist/api.d.ts

@@ -6,3 +6,3 @@ import { IProfiles } from './config/connectionConfig';

import { IMOSExternalMetaData } from './dataTypes/mosExternalMetaData';
import { IMOSListMachInfo, MosItemReplaceOptions } from './mosModel';
import { IMOSListMachInfo, MOSAck, MosItemReplaceOptions } from './mosModel';
import { MosDevice } from './MosDevice';

@@ -22,468 +22,49 @@ export interface IMosConnection {

}
export interface IMOSDevice extends IMOSDeviceProfile0, IMOSDeviceProfile1, IMOSDeviceProfile2, IMOSDeviceProfile3, IMOSDeviceProfile4 {
export interface IMOSDevice {
idPrimary: string;
idSecondary: string | null;
}
/**
* Method definitions for Profile 1
* see http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#Profile1
*/
export interface IMOSDeviceProfile0 {
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* The reqMachInfo message is a method for an NCS or MOS to determine more information about its counterpart.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#reqMachInfo
*/
requestMachineInfo: () => Promise<IMOSListMachInfo>;
/**
* Send message (as NCS) to a MOS device:
* The reqMachInfo message is a method for an NCS or MOS to determine more information about its counterpart.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#reqMachInfo
*/
onRequestMachineInfo: (cb: () => Promise<IMOSListMachInfo>) => void;
/** Assign callback for when the connection status changes. */
getMachineInfo: () => Promise<IMOSListMachInfo>;
onGetMachineInfo: (cb: () => Promise<IMOSListMachInfo>) => void;
onConnectionChange: (cb: (connectionStatus: IMOSConnectionStatus) => void) => void;
/** Get the current connection status */
getConnectionStatus: () => IMOSConnectionStatus;
/** @deprecated getMachineInfo is deprecated, use requestMachineInfo instead */
getMachineInfo: () => Promise<IMOSListMachInfo>;
/** @deprecated onGetMachineInfo is deprecated, use onRequestMachineInfo instead */
onGetMachineInfo: (cb: () => Promise<IMOSListMachInfo>) => void;
}
/**
* Method definitions for Profile 1
* see http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#Profile1
*/
export interface IMOSDeviceProfile1 {
/**
* Contains information that describes a unique MOS Object to the NCS.
* The NCS uses this information to search for and reference the MOS Object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosObj
*/
sendMOSObject(obj: IMOSObject): Promise<IMOSAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Message used by the NCS to request the description of an object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqObj
*/
onRequestMOSObject: (cb: (objId: string) => Promise<IMOSObject | null>) => void;
/**
* Send message (as NCS) to a MOS device:
* Message used by the NCS to request the description of an object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqObj
*/
sendRequestMOSObject: (objId: MosString128) => Promise<IMOSObject>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Method for the NCS to request the MOS to send it a mosObj message for every Object in the MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqAll
*/
onRequestAllMOSObjects: (cb: () => Promise<Array<IMOSObject>>) => void;
/**
* Method for the NCS to request the MOS to send it a mosObj message for every Object in the MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqAll
*/
sendRequestAllMOSObjects: () => Promise<Array<IMOSObject>>;
/** @deprecated getMOSObject is deprecated, use sendRequestMOSObject instead */
onRequestAllMOSObjects: (cb: (pause: number) => Promise<Array<IMOSObject> | IMOSAck>) => void;
getMOSObject: (objId: MosString128) => Promise<IMOSObject>;
/** @deprecated getAllMOSObjects is deprecated, use sendRequestAllMOSObjects instead */
getAllMOSObjects: () => Promise<IMOSObject[]>;
}
/**
* Method definitions for Profile 2
* see http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#Profile2
*/
export interface IMOSDeviceProfile2 {
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Message received from the NCS to the MOS that defines a new Running Order.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roCreate
*/
getAllMOSObjects: () => Promise<Array<IMOSObject>>;
setMOSObject(obj: IMOSObject): Promise<IMOSAck>;
setAllMOSObjects(objs: IMOSObject[]): Promise<IMOSAck>;
onCreateRunningOrder: (cb: (ro: IMOSRunningOrder) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Message from the NCS to the MOS that defines a new Running Order.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roCreate
*/
sendCreateRunningOrder: (ro: IMOSRunningOrder) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Message received from the NCS to the MOS that defines a new Running Order, replacing an existing one.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roReplace
*/
onReplaceRunningOrder: (cb: (ro: IMOSRunningOrder) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Message received from the NCS to the MOS that defines a new Running Order, replacing an existing one.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roReplace
*/
sendReplaceRunningOrder: (ro: IMOSRunningOrder) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Deletes a Running order in the MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roDelete
*/
onDeleteRunningOrder: (cb: (runningOrderId: MosString128) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Deletes a Running order in the MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roDelete
*/
sendDeleteRunningOrder: (runningOrderId: MosString128) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Request for a complete build of a Running Order Playlist. NOTE: This message can be used by either NCS or MOS.
* A MOS can use this to "resync" its Playlist with the NCS Running Order or to obtain a full description of the Playlist at any time.
* An NCS can use this as a diagnostic tool to check the order of the Playlist constructed in the MOS versus the sequence of Items in the Running Order.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roReq
* Response: http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roList
*/
onRequestRunningOrder: (cb: (runningOrderId: MosString128) => Promise<IMOSRunningOrder | null>) => void;
/**
* Send message (as NCS) to a MOS device:
* Request for a complete build of a Running Order Playlist. NOTE: This message can be used by either NCS or MOS.
* A MOS can use this to "resync" its Playlist with the NCS Running Order or to obtain a full description of the Playlist at any time.
* An NCS can use this as a diagnostic tool to check the order of the Playlist constructed in the MOS versus the sequence of Items in the Running Order.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roReq
* Response: http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roList
*/
sendRequestRunningOrder: (runningOrderId: MosString128) => Promise<IMOSRunningOrder | null>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* The roMetadataReplace message allows metadata associated with a running order to be replaced without deleting the running order and sending the entire running order again.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roMetadataReplace
*/
getRunningOrder: (runningOrderId: MosString128) => Promise<IMOSRunningOrder | null>;
onMetadataReplace: (cb: (metadata: IMOSRunningOrderBase) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* The roMetadataReplace message allows metadata associated with a running order to be replaced without deleting the running order and sending the entire running order again.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roMetadataReplace
*/
sendMetadataReplace: (metadata: IMOSRunningOrderBase) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* A method for the MOS to update the NCS on the status of a RO. This allows the NCS to reflect the status of any element in the MOS Running Order in the NCS Running Order display.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.7.2_roElementStat_-
*/
onRunningOrderStatus: (cb: (status: IMOSRunningOrderStatus) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* A method for the MOS to update the NCS on the status of a RO. This allows the NCS to reflect the status of any element in the MOS Running Order in the NCS Running Order display.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.7.2_roElementStat_-
*/
sendRunningOrderStatus: (status: IMOSRunningOrderStatus) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* A method for the MOS to update the NCS on the status of a STORY. This allows the NCS to reflect the status of any element in the MOS Running Order in the NCS Running Order display.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.7.2_roElementStat_-
*/
onStoryStatus: (cb: (status: IMOSStoryStatus) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* A method for the MOS to update the NCS on the status of a STORY. This allows the NCS to reflect the status of any element in the MOS Running Order in the NCS Running Order display.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.7.2_roElementStat_-
*/
sendStoryStatus: (status: IMOSStoryStatus) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* A method for the MOS to update the NCS on the status of an ITEM. This allows the NCS to reflect the status of any element in the MOS Running Order in the NCS Running Order display.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.7.2_roElementStat_-
*/
onItemStatus: (cb: (status: IMOSItemStatus) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* A method for the MOS to update the NCS on the status of an ITEM. This allows the NCS to reflect the status of any element in the MOS Running Order in the NCS Running Order display.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.7.2_roElementStat_-
*/
sendItemStatus: (status: IMOSItemStatus) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* The roReadyToAir message allows the NCS to signal the MOS that a Running Order has been editorially approved ready for air.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roReadyToAir
*/
setRunningOrderStatus: (status: IMOSRunningOrderStatus) => Promise<IMOSROAck>;
setStoryStatus: (status: IMOSStoryStatus) => Promise<IMOSROAck>;
setItemStatus: (status: IMOSItemStatus) => Promise<IMOSROAck>;
onReadyToAir: (cb: (Action: IMOSROReadyToAir) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* The roReadyToAir message allows the NCS to signal the MOS that a Running Order has been editorially approved ready for air.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roReadyToAir
*/
sendReadyToAir: (Action: IMOSROReadyToAir) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Insert one or more story into a Running Order
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onROInsertStories: (cb: (Action: IMOSStoryAction, Stories: Array<IMOSROStory>) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Insert one or more story into a Running Order
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendROInsertStories: (Action: IMOSStoryAction, Stories: Array<IMOSROStory>) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Insert one or more Items into a Story
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onROInsertItems: (cb: (Action: IMOSItemAction, Items: Array<IMOSItem>) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Insert one or more Items into a Story
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendROInsertItems: (Action: IMOSItemAction, Items: Array<IMOSItem>) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Replace (update) a Story with a new story.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onROReplaceStories: (cb: (Action: IMOSStoryAction, Stories: Array<IMOSROStory>) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Replace (update) a Story with a new story.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendROReplaceStories: (Action: IMOSStoryAction, Stories: Array<IMOSROStory>) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Replace (update) an Item with a new Item.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onROReplaceItems: (cb: (Action: IMOSItemAction, Items: Array<IMOSItem>) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Replace (update) an Item with a new Item.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendROReplaceItems: (Action: IMOSItemAction, Items: Array<IMOSItem>) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Move one or more Stories within a Running Order
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onROMoveStories: (cb: (Action: IMOSStoryAction, Stories: Array<MosString128>) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Move one or more Stories within a Running Order
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendROMoveStories: (Action: IMOSStoryAction, Stories: Array<MosString128>) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Move one or more Items within a Story
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onROMoveItems: (cb: (Action: IMOSItemAction, Items: Array<MosString128>) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Move one or more Items within a Story
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendROMoveItems: (Action: IMOSItemAction, Items: Array<MosString128>) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Delete one or more Stories within a Running Order
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onRODeleteStories: (cb: (Action: IMOSROAction, Stories: Array<MosString128>) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Delete one or more Stories within a Running Order
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendRODeleteStories: (Action: IMOSROAction, Stories: Array<MosString128>) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Delete one or more Items within a Story
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onRODeleteItems: (cb: (Action: IMOSStoryAction, Items: Array<MosString128>) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Delete one or more Items within a Story
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendRODeleteItems: (Action: IMOSStoryAction, Items: Array<MosString128>) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Swap two Stories
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onROSwapStories: (cb: (Action: IMOSROAction, StoryID0: MosString128, StoryID1: MosString128) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Swap two Stories
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendROSwapStories: (Action: IMOSROAction, StoryID0: MosString128, StoryID1: MosString128) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* Swap two Items
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
onROSwapItems: (cb: (Action: IMOSStoryAction, ItemID0: MosString128, ItemID1: MosString128) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* Swap two Items
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roElementAction
*/
sendROSwapItems: (Action: IMOSStoryAction, ItemID0: MosString128, ItemID1: MosString128) => Promise<IMOSROAck>;
/** @deprecated getRunningOrder is deprecated, use sendRequestRunningOrder instead */
getRunningOrder: (runningOrderId: MosString128) => Promise<IMOSRunningOrder | null>;
/** @deprecated setRunningOrderStatus is deprecated, use sendRunningOrderStatus instead */
setRunningOrderStatus: (status: IMOSRunningOrderStatus) => Promise<IMOSROAck>;
/** @deprecated setStoryStatus is deprecated, use sendStoryStatus instead */
setStoryStatus: (status: IMOSStoryStatus) => Promise<IMOSROAck>;
/** @deprecated setItemStatus is deprecated, use sendItemStatus instead */
setItemStatus: (status: IMOSItemStatus) => Promise<IMOSROAck>;
}
/**
* Method definitions for Profile 3
* see http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#Profile3
*/
export interface IMOSDeviceProfile3 {
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* mosObjCreate allows an NCS to request the Media Object Server to create a Media Object with specific metadata associated with it.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosObjCreate
*/
onObjectCreate: (cb: (object: IMOSObject) => Promise<IMOSAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* mosObjCreate allows an NCS to request the Media Object Server to create a Media Object with specific metadata associated with it.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosObjCreate
*/
sendObjectCreate: (object: IMOSObject) => Promise<IMOSAck>;
/**
* Assign callback (as a NCS device) for when receiving message from MOS:
* This message allows a Media Object Server to replace an Item Reference in a Story with new metadata values and/or additional tags.
* The Story must be in a MOS Active PlayList.
* This message is initiated by the Media Object Server, rather than the NCS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosItemReplace
*/
onItemReplace: (cb: (roID: MosString128, storyID: MosString128, item: IMOSItem) => Promise<IMOSROAck>) => void;
/**
* Send message (as MOS) to a NCS:
* This message allows a Media Object Server to replace an Item Reference in a Story with new metadata values and/or additional tags.
* The Story must be in a MOS Active PlayList.
* This message is initiated by the Media Object Server, rather than the NCS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosItemReplace
*/
sendItemReplace: (options: MosItemReplaceOptions) => Promise<IMOSROAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* mosReqSearchable Schema is a mechanism used by the NCS to request the MOS to send a pointer to a schema in which searchable fields are defined by the MOS device.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqSearchableSchema
*/
onRequestSearchableSchema: (cb: (username: string) => Promise<IMOSListSearchableSchema>) => void;
/**
* Send message (as NCS) to a MOS device:
* mosReqSearchable Schema is a mechanism used by the NCS to request the MOS to send a pointer to a schema in which searchable fields are defined by the MOS device.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqSearchableSchema
*/
sendRequestSearchableSchema: (username: string) => Promise<IMOSListSearchableSchema>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* mosReqObjList is a mechanism used by a NCS to retrieve only selected object descriptions from a MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqObjList
*/
onRequestObjectList: (cb: (objList: IMOSRequestObjectList) => Promise<IMOSObjectList>) => void;
/**
* Send message (as NCS) to a MOS device:
* mosReqObjList is a mechanism used by a NCS to retrieve only selected object descriptions from a MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqObjList
*/
sendRequestObjectList: (reqObjList: IMOSRequestObjectList) => Promise<IMOSObjectList>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* mosReqObjAction allows an NCS to request the Media Object Server to create, modify or delete a media object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.3.3_mosReqObjAction_%E2%80%93_NCS_request
*/
onRequestObjectActionNew: (cb: (obj: IMOSObject) => Promise<IMOSAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* mosReqObjAction allows an NCS to request the Media Object Server to create, modify or delete a media object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.3.3_mosReqObjAction_%E2%80%93_NCS_request
*/
sendRequestObjectActionNew: (obj: IMOSObject) => Promise<IMOSAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* mosReqObjAction allows an NCS to request the Media Object Server to create, modify or delete a media object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.3.3_mosReqObjAction_%E2%80%93_NCS_request
*/
onRequestObjectActionUpdate: (cb: (objId: MosString128, obj: IMOSObject) => Promise<IMOSAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* mosReqObjAction allows an NCS to request the Media Object Server to create, modify or delete a media object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.3.3_mosReqObjAction_%E2%80%93_NCS_request
*/
sendRequestObjectActionUpdate: (objId: MosString128, obj: IMOSObject) => Promise<IMOSAck>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* mosReqObjAction allows an NCS to request the Media Object Server to create, modify or delete a media object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.3.3_mosReqObjAction_%E2%80%93_NCS_request
*/
onRequestObjectActionDelete: (cb: (objId: MosString128) => Promise<IMOSAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* mosReqObjAction allows an NCS to request the Media Object Server to create, modify or delete a media object.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#_3.3.3_mosReqObjAction_%E2%80%93_NCS_request
*/
sendRequestObjectActionDelete: (objId: MosString128) => Promise<IMOSAck>;
/** @deprecated onMosObjCreate is deprecated, use onObjectCreate instead */
onMosObjCreate: (cb: (object: IMOSObject) => Promise<IMOSAck>) => void;
/** @deprecated mosObjCreate is deprecated, use sendObjectCreate instead */
mosObjCreate: (object: IMOSObject) => Promise<IMOSAck>;
/** @deprecated onMosItemReplace is deprecated, use onItemReplace instead */
mosObjCreate: (object: IMOSObject) => Promise<MOSAck>;
onMosItemReplace: (cb: (roID: MosString128, storyID: MosString128, item: IMOSItem) => Promise<IMOSROAck>) => void;
/** @deprecated mosItemReplace is deprecated, use sendItemReplace instead */
mosItemReplace: (options: MosItemReplaceOptions) => Promise<IMOSROAck>;
/** @deprecated onMosReqSearchableSchema is deprecated, use onRequestSearchableSchema instead */
onMosReqSearchableSchema: (cb: (username: string) => Promise<IMOSListSearchableSchema>) => void;
/** @deprecated mosRequestSearchableSchema is deprecated, use sendRequestSearchableSchema instead */
mosRequestSearchableSchema: (username: string) => Promise<IMOSListSearchableSchema>;
/** @deprecated onMosReqObjectList is deprecated, use onRequestObjectList instead */
onMosReqObjectList: (cb: (objList: IMOSRequestObjectList) => Promise<IMOSObjectList>) => void;
/** @deprecated mosRequestObjectList is deprecated, use sendRequestObjectList instead */
mosRequestObjectList: (reqObjList: IMOSRequestObjectList) => Promise<IMOSObjectList>;
/** @deprecated onMosReqObjectAction is deprecated, use onRequestObjectAction*** instead */
onMosReqSearchableSchema: (cb: (username: string) => Promise<IMOSSearchableSchema>) => void;
mosRequestSearchableSchema: (username: string) => Promise<IMOSSearchableSchema>;
onMosReqObjectList: (cb: (objList: IMosRequestObjectList) => Promise<IMosObjectList>) => void;
mosRequestObjectList: (reqObjList: IMosRequestObjectList) => Promise<IMosObjectList>;
onMosReqObjectAction: (cb: (action: string, obj: IMOSObject) => Promise<IMOSAck>) => void;
}
/**
* Method definitions for Profile 4
* see http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#Profile4
*/
export interface IMOSDeviceProfile4 {
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* roReqAll is a request for a description of all Running Orders known by a NCS from a MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roReqAll
*/
onRequestAllRunningOrders: (cb: () => Promise<IMOSRunningOrder[]>) => void;
/**
* Send message (as NCS) to a MOS device:
* roReqAll is a request for a description of all Running Orders known by a NCS from a MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roReqAll
*/
sendRequestAllRunningOrders: () => Promise<Array<IMOSRunningOrderBase>>;
/**
* Assign callback (as a MOS device) for when receiving message from NCS:
* This message enables sending the body of story from the NCS to a Media Object Server.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roStorySend
*/
onRunningOrderStory: (cb: (story: IMOSROFullStory) => Promise<IMOSROAck>) => void;
/**
* Send message (as NCS) to a MOS device:
* This message enables sending the body of story from the NCS to a Media Object Server.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#roStorySend
*/
sendRunningOrderStory: (story: IMOSROFullStory) => Promise<IMOSROAck>;
/** @deprecated onROReqAll is deprecated use onRequestAllRunningOrders instead */
onROReqAll: (cb: () => Promise<IMOSRunningOrder[]>) => void;
/** @deprecated getAllRunningOrders is deprecated use sendRequestAllRunningOrders instead */
getAllRunningOrders: () => Promise<Array<IMOSRunningOrderBase>>;
/** @deprecated onROStory is deprecated use onRunningOrderStory instead */
onROStory: (cb: (story: IMOSROFullStory) => Promise<IMOSROAck>) => void;
/** @deprecated sendROStory is deprecated use sendRunningOrderStory instead */
sendROStory: (story: IMOSROFullStory) => Promise<IMOSROAck>;
}

@@ -605,33 +186,2 @@ export { IMOSListMachInfo };

}
/** Config object for creating a MOS-device */
export interface IConnectionConfig {
/** The ID of this mos-device */
mosID: string;
/** Whether this mosConnection accepts new connections from othe MOS clients (ie acts as an NCS) */
acceptsConnections: boolean;
/** Only accept connections from this whitelist */
accepsConnectionsFrom?: string[];
/** A list of which profile this mos device is to support */
profiles: IProfiles;
/** If true, this device is assumed to be an NCS (server). Defaults to a MOS (client). */
isNCS?: boolean;
/** Debugging-mode: logs raw mos-messages */
debug?: boolean;
offspecFailover?: boolean;
/** If set to true, a strict check is performed to ensure that all required callbacks are set up for specified profiles */
strict?: boolean;
/** If set, overrides the standard port numbers */
ports?: {
/** Set MOS Lower port (standard: 10540) */
lower: number;
/** Set MOS Upper port (standard: 10541) */
upper: number;
/** Set MOS Query port (standard: 10542) */
query: number;
};
/** When enabled, automatically create new mos-devices on-the-fly when receiving messages to unregistered MOS-ID:s */
openRelay?: boolean | {
options: IMOSDeviceConnectionOptions['primary'];
};
}
export interface IMOSDeviceConnectionOptions {

@@ -697,7 +247,3 @@ /** Connection options for the Primary NCS-server */

}
/**
* Returns selected object descriptions from a MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosObjList
*/
export interface IMOSObjectList {
export interface IMosObjectList {
username: string;

@@ -711,7 +257,3 @@ queryID: string;

}
/**
* mosReqObjList is a mechanism used by a NCS to retrieve only selected object descriptions from a MOS.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosReqObjList
*/
export interface IMOSRequestObjectList {
export interface IMosRequestObjectList {
username: string;

@@ -724,7 +266,6 @@ queryID: MosString128;

searchGroups: Array<{
searchFields: Array<IMOSSearchField>;
searchFields: Array<IMosSearchField>;
}>;
}
/** @see IMOSRequestObjectList */
export interface IMOSSearchField {
export interface IMosSearchField {
XPath: string;

@@ -734,7 +275,3 @@ sortByOrder?: number;

}
/**
* mosListSearchableSchema is a mechanism used by the MOS to send a pointer to a schema in which searchable fields are defined for the NCS device.
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosListSearchableSchema
*/
export interface IMOSListSearchableSchema {
export interface IMOSSearchableSchema {
username: string;

@@ -741,0 +278,0 @@ mosSchema: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IMOSObjectPathType = exports.IMOSObjectAirStatus = exports.IMOSAckStatus = exports.IMOSObjectStatus = exports.IMOSObjectType = void 0;
var IMOSObjectType;

@@ -5,0 +4,0 @@ (function (IMOSObjectType) {

30

dist/config/connectionConfig.d.ts

@@ -1,2 +0,17 @@

import { IConnectionConfig, IMOSDeviceConnectionOptions } from '../api';
/** Config object for creating a MOS-device */
export interface IConnectionConfig {
/** The ID of this mos-device */
mosID: string;
/** Whether this mosConnection accepts new connections from othe MOS clients */
acceptsConnections: boolean;
/** Only accept connections from this whitelist */
accepsConnectionsFrom?: string[];
/** A list of which profile this mos device is to support */
profiles: IProfiles;
/** Debugging-mode: logs raw mos-messages */
debug?: boolean;
/** Automatically create new mos-devices on-the-fly when receiving messages to unregistered MOS-ID:s */
openRelay?: boolean;
offspecFailover?: boolean;
}
/** */

@@ -19,18 +34,9 @@ export interface IProfiles {

debug: boolean;
openRelay: boolean | undefined | {
options: IMOSDeviceConnectionOptions['primary'];
};
openRelay: boolean;
offspecFailover: boolean;
strict?: boolean;
ports?: {
lower: number;
upper: number;
query: number;
};
private _profiles;
constructor(init: IConnectionConfig);
/** */
get profiles(): IProfiles;
/** */
set profiles(profileSupport: IProfiles);
profiles: IProfiles;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionConfig = void 0;
class ConnectionConfig {

@@ -32,7 +31,5 @@ constructor(init) {

this.debug = init.debug || false;
this.openRelay = init.openRelay || undefined;
this.openRelay = init.openRelay || false;
this.offspecFailover = init.offspecFailover || false;
this.profiles = init.profiles;
this.strict = init.strict;
this.ports = init.ports;
}

@@ -39,0 +36,0 @@ /** */

@@ -33,13 +33,11 @@ /// <reference types="node" />

private processQueueTimeout;
private _startingUp;
private dataChunks;
private _disposed;
/** */
constructor(host: string, port: number, description: string, timeout?: number, debug?: boolean);
/** */
set autoReconnect(autoReconnect: boolean);
autoReconnect: boolean;
/** */
set autoReconnectInterval(autoReconnectInterval: number);
autoReconnectInterval: number;
/** */
set autoReconnectAttempts(autoReconnectAttempts: number);
autoReconnectAttempts: number;
/** */

@@ -53,5 +51,5 @@ connect(): void;

/** */
get host(): string;
readonly host: string;
/** */
get port(): number;
readonly port: number;
/** */

@@ -65,5 +63,4 @@ dispose(): void;

/** */
private set connected(value);
/** */
private get connected();
private connected;
private _sendReply;

@@ -81,2 +78,3 @@ /** */

private _onData;
private _tryParseData;
/** */

@@ -87,3 +85,2 @@ private _onError;

private _triggerQueueCleanup;
private debugTrace;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosSocketClient = void 0;
const events_1 = require("events");

@@ -9,3 +8,3 @@ const net_1 = require("net");

const mosModel_1 = require("../mosModel");
const iconv = require("iconv-lite");
const iconv = require('iconv-lite');
class MosSocketClient extends events_1.EventEmitter {

@@ -29,5 +28,4 @@ /** */

this._timedOutCommands = {};
this._startingUp = true;
// private _startingUp: boolean = true
this.dataChunks = '';
this._disposed = false;
this._host = host;

@@ -62,3 +60,2 @@ this._port = port;

this._client.removeAllListeners();
// @ts-expect-error optional property
delete this._client;

@@ -75,4 +72,6 @@ }

// connect:
this.debugTrace(new Date(), `Socket ${this._description} attempting connection`);
this.debugTrace('port', this._port, 'host', this._host);
if (this._debug)
console.log(new Date(), `Socket ${this._description} attempting connection`);
if (this._debug)
console.log('port', this._port, 'host', this._host);
this._client.connect(this._port, this._host);

@@ -98,3 +97,3 @@ this._shouldBeConnected = true;

message.prepare();
// this.debugTrace('queueing', message.messageID, message.constructor.name )
// console.log('queueing', message.messageID, message.constructor.name )
this._queueCallback[message.messageID + ''] = cb;

@@ -105,5 +104,3 @@ this._queueMessages.push({ time: time || Date.now(), msg: message });

processQueue() {
if (this._disposed)
return;
// this.debugTrace('this.connected', this.connected)
// console.log('this.connected', this.connected)
if (!this._sentMessage && this.connected) {

@@ -180,3 +177,2 @@ if (this.processQueueTimeout)

dispose() {
this._disposed = true;
// this._readyToSendMessage = false

@@ -190,3 +186,2 @@ this.connected = false;

this._client.destroy();
// @ts-expect-error optional property
delete this._client;

@@ -199,3 +194,4 @@ }

log(args) {
this.debugTrace(args);
if (this._debug)
console.log(args);
}

@@ -235,13 +231,12 @@ setDebug(debug) {

let sentMessageId = message.msg.messageID;
// this.debugTrace('executeCommand', message)
// console.log('executeCommand', message)
// message.prepare() // @todo, is prepared? is sent already? logic needed
let messageString = message.msg.toString();
let buf = iconv.encode(messageString, 'utf16-be');
// this.debugTrace('sending',this._client.name, str)
// if (this._debug) console.log('sending',this._client.name, str)
// Command timeout:
global.setTimeout(() => {
if (this._disposed)
return;
if (this._sentMessage && this._sentMessage.msg.messageID === sentMessageId) {
this.debugTrace('timeout ' + sentMessageId + ' after ' + this._commandTimeout);
if (this._debug)
console.log('timeout ' + sentMessageId + ' after ' + this._commandTimeout);
if (isRetry) {

@@ -258,3 +253,4 @@ this._sendReply(sentMessageId, Error('Command timed out'), null);

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

@@ -281,7 +277,7 @@ }

_clearConnectionAttemptTimer() {
// @todo create event telling reconnection ended with result: true/false
// only if reconnection interval is true
this._reconnectAttempt = 0;
if (this._connectionAttemptTimer) {
global.clearInterval(this._connectionAttemptTimer);
delete this._connectionAttemptTimer;
}
global.clearInterval(this._connectionAttemptTimer);
delete this._connectionAttemptTimer;
}

@@ -295,3 +291,3 @@ /** */

_onConnected() {
this.emit(socketConnection_1.SocketConnectionEvent.ALIVE);
this._client.emit(socketConnection_1.SocketConnectionEvent.ALIVE);
// global.clearInterval(this._connectionAttemptTimer)

@@ -303,35 +299,57 @@ this._clearConnectionAttemptTimer();

_onData(data) {
this.emit(socketConnection_1.SocketConnectionEvent.ALIVE);
this._client.emit(socketConnection_1.SocketConnectionEvent.ALIVE);
// data = Buffer.from(data, 'ucs2').toString()
let messageString = iconv.decode(data, 'utf16-be').trim();
const messageString = iconv.decode(data, 'utf16-be');
this.emit('rawMessage', 'recieved', messageString);
this.debugTrace(`${this._description} Received: ${messageString}`);
let firstMatch = '<mos>'; // <mos>
let first = messageString.substr(0, firstMatch.length);
let lastMatch = '</mos>'; // </mos>
let last = messageString.substr(-lastMatch.length);
if (this._debug)
console.log(`${this._description} Received: ${messageString}`);
this.dataChunks += messageString;
// parse as many messages as possible from the data
while (this.dataChunks.length > 0) {
// whitespace before a mos message is junk
this.dataChunks = this.dataChunks.trimLeft();
const lengthBefore = this.dataChunks.length;
this._tryParseData();
const lengthAfter = this.dataChunks.length;
if (lengthAfter === lengthBefore) {
// Nothing was plucked, so abort
break;
}
}
}
_tryParseData() {
const startMatch = '<mos>'; // <mos>
const endMatch = '</mos>'; // </mos>
let messageString;
const startIndex = this.dataChunks.indexOf(startMatch);
if (startIndex === -1) {
// No start tag, so looks like we have jibberish
this.dataChunks = '';
}
else {
if (startIndex > 0) {
const junkStr = this.dataChunks.substr(0, startIndex);
if (this._debug) {
console.log(`${this._description} Discarding message fragment: ${junkStr}`);
}
// trim off anything before <mos>, as we can't parse that
this.dataChunks = this.dataChunks.substr(startIndex);
}
const endIndex = this.dataChunks.indexOf(endMatch);
if (endIndex > 0) {
// We have an end too, so pull out the message
const endIndex2 = endIndex + endMatch.length;
messageString = this.dataChunks.substr(0, endIndex2);
this.dataChunks = this.dataChunks.substr(endIndex2);
// parse our xml
}
}
let parsedData;
try {
// this.debugTrace(first === firstMatch, last === lastMatch, last, lastMatch)
if (first === firstMatch && last === lastMatch) {
// Data ready to be parsed:
if (messageString) {
parsedData = Utils_1.xml2js(messageString); // , { compact: true, trim: true, nativeType: true })
this.dataChunks = '';
}
else if (last === lastMatch) {
// Last chunk, ready to parse with saved data:
parsedData = Utils_1.xml2js(this.dataChunks + messageString); // , { compact: true, trim: true, nativeType: true })
this.dataChunks = '';
}
else if (first === firstMatch) {
// Chunk, save for later:
this.dataChunks = messageString;
}
else {
// Chunk, save for later:
this.dataChunks += messageString;
}
// let parsedData: any = parser.toJson(messageString, )
if (parsedData) {
// this.debugTrace(parsedData, newParserData)
// console.log(parsedData, newParserData)
let messageId = parsedData.mos.messageID;

@@ -345,4 +363,6 @@ if (messageId) {

else {
this.debugTrace('Mos reply id diff: ' + messageId + ', ' + sentMessage.msg.messageID);
this.debugTrace(parsedData);
if (this._debug)
console.log('Mos reply id diff: ' + messageId + ', ' + sentMessage.msg.messageID);
if (this._debug)
console.log(parsedData);
this.emit('warning', 'Mos reply id diff: ' + messageId + ', ' + sentMessage.msg.messageID);

@@ -359,3 +379,6 @@ this._triggerQueueCleanup();

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

@@ -365,3 +388,4 @@ }

// huh, we've got a reply to something we've not sent.
this.debugTrace('Got a reply (' + messageId + '), but we haven\'t sent any message', messageString);
if (this._debug)
console.log('Got a reply (' + messageId + '), but we haven\'t sent any message', messageString);
this.emit('warning', 'Got a reply (' + messageId + '), but we haven\'t sent any message ' + messageString);

@@ -378,3 +402,4 @@ }

else {
this.debugTrace('Mos Error message:' + parsedData.mos.mosAck.statusDescription);
if (this._debug)
console.log('Mos Error message:' + parsedData.mos.mosAck.statusDescription);
this.emit('error', 'Error message: ' + parsedData.mos.mosAck.statusDescription);

@@ -392,19 +417,18 @@ }

}
// this.debugTrace('messageString', messageString)
// this.debugTrace('first msg', messageString)
this._startingUp = false;
// console.log('messageString', messageString)
// console.log('first msg', messageString)
// this._startingUp = false
}
catch (e) {
// this.debugTrace('messageString', messageString)
if (this._startingUp) {
// when starting up, we might get half a message, let's ignore this error then
let a = Math.min(20, Math.floor(messageString.length / 2));
console.error('Strange XML-message upon startup: "' + messageString.slice(0, a) + '[...]' + messageString.slice(-a) + '" (length: ' + messageString.length + ')');
console.error('error', e);
}
else {
console.error('dataChunks-------------\n', this.dataChunks);
console.error('messageString---------\n', messageString);
this.emit('error', e);
}
// console.log('messageString', messageString)
// if (this._startingUp) {
// // when starting up, we might get half a message, let's ignore this error then
// let a = Math.min(20, Math.floor(messageString.length / 2))
// console.log('Strange XML-message upon startup: "' + messageString.slice(0, a) + '[...]' + messageString.slice(-a) + '" (length: ' + messageString.length + ')')
// console.log('error', e)
// } else {
console.log('dataChunks-------------\n', this.dataChunks);
console.log('messageString---------\n', messageString);
this.emit('error', e);
// }
}

@@ -418,3 +442,4 @@ // this._readyToSendMessage = true

this.emit('error', `Socket event error: ${error.message}`);
this.debugTrace(`Socket event error: ${error.message}`);
if (this._debug)
console.log(`Socket event error: ${error.message}`);
}

@@ -426,7 +451,9 @@ /** */

if (hadError) {
this.emit('warning', 'Socket closed with error');
this.debugTrace('Socket closed with error');
this.emit('warning', 'Scoket closed with error');
if (this._debug)
console.log('Socket closed with error');
}
else {
this.debugTrace('Socket closed without error');
if (this._debug)
console.log('Socket closed without error');
}

@@ -436,3 +463,4 @@ this.emit(socketConnection_1.SocketConnectionEvent.DISCONNECTED);

this.emit('warning', 'Socket should reconnect');
this.debugTrace('Socket should reconnect');
if (this._debug)
console.log('Socket should reconnect');
this.connect();

@@ -444,5 +472,4 @@ }

setTimeout(() => {
if (this._disposed)
return;
this.debugTrace('QueueCleanup');
if (this._debug)
console.log('QueueCleanup');
for (let i = this._queueMessages.length - 1; i >= 0; i--) {

@@ -457,8 +484,4 @@ let message = this._queueMessages[i];

}
debugTrace(...strs) {
if (this._debug)
console.log(...strs);
}
}
exports.MosSocketClient = MosSocketClient;
//# sourceMappingURL=mosSocketClient.js.map

@@ -17,4 +17,4 @@ /// <reference types="node" />

setDebug(debug: boolean): void;
get port(): number;
get portDescription(): import("../mosModel/MosMessage").PortType;
readonly port: number;
readonly portDescription: IncomingConnectionType;
/** */

@@ -26,3 +26,2 @@ private _onClientConnection;

private _onServerClose;
private debugTrace;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosSocketServer = void 0;
const net_1 = require("net");

@@ -47,9 +46,12 @@ const events_1 = require("events");

listen() {
this.debugTrace('listen', this._portDescription, this._port);
if (this._debug)
console.log('listen', this._portDescription, this._port);
return new Promise((resolve, reject) => {
try {
this.debugTrace('inside promise', this._portDescription, this._port);
if (this._debug)
console.log('inside promise', this._portDescription, this._port);
// already listening
if (this._socketServer.listening) {
this.debugTrace('already listening', this._portDescription, this._port);
if (this._debug)
console.log('already listening', this._portDescription, this._port);
resolve();

@@ -107,3 +109,4 @@ return;

// @todo: implement
this.debugTrace('Server error:', error);
if (this._debug)
console.log('Server error:', error);
}

@@ -113,7 +116,4 @@ /** */

// @todo: implement
this.debugTrace(`Server closed: on port ${this._port}`);
}
debugTrace(...strs) {
if (this._debug)
console.log(...strs);
console.log(`Server closed: on port ${this._port}`);
}

@@ -120,0 +120,0 @@ }

/// <reference types="node" />
import { ConnectionType } from './socketConnection';
import { MosSocketClient, CallBackFunction, QueueMessage } from '../connection/mosSocketClient';
import { MosMessage, PortType } from '../mosModel/MosMessage';
import { MosMessage } from '../mosModel/MosMessage';
import { EventEmitter } from 'events';

@@ -10,3 +10,3 @@ export interface ClientDescription {

client: MosSocketClient;
clientDescription: PortType;
clientDescription: string;
}

@@ -22,3 +22,3 @@ export interface INCSServerConnection {

}
/** Handles connections to a NCS (server) */
/** */
export declare class NCSServerConnection extends EventEmitter implements INCSServerConnection {

@@ -33,7 +33,6 @@ private _connected;

private _clients;
private _emittedConnected;
private _callbackOnConnectionChange;
private _heartBeatsTimer;
private _heartBeatsDelay;
constructor(id: string, host: string, mosID: string, timeout?: number, debug?: boolean);
/** Create a MOS client, which talks to */
createClient(clientID: string, port: number, clientDescription: ConnectionType, useHeartbeats: boolean): void;

@@ -44,13 +43,14 @@ /** */

executeCommand(message: MosMessage): Promise<any>;
onConnectionChange(cb: () => void): void;
setDebug(debug: boolean): void;
get connected(): boolean;
readonly connected: boolean;
private _getClients;
/** */
get lowerPortClients(): MosSocketClient[];
readonly lowerPortClients: MosSocketClient[];
/** */
get upperPortClients(): MosSocketClient[];
readonly upperPortClients: MosSocketClient[];
/** */
get queryPortClients(): MosSocketClient[];
get host(): string;
get id(): string;
readonly queryPortClients: MosSocketClient[];
readonly host: string;
readonly id: string;
handOverQueue(otherConnection: NCSServerConnection): void;

@@ -62,3 +62,2 @@ receiveQueue(queue: {

private _sendHeartBeats;
private debugTrace;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NCSServerConnection = void 0;
const mosSocketClient_1 = require("../connection/mosSocketClient");
const mosModel_1 = require("../mosModel");
const events_1 = require("events");
/** Handles connections to a NCS (server) */
// Namnförslag: NCSServer
// Vi ansluter från oss till NCS
/** */
class NCSServerConnection extends events_1.EventEmitter {

@@ -14,3 +15,2 @@ constructor(id, host, mosID, timeout, debug) {

this._clients = {};
this._emittedConnected = false;
this._id = id;

@@ -25,6 +25,6 @@ this._host = host;

}
/** Create a MOS client, which talks to */
createClient(clientID, port, clientDescription, useHeartbeats) {
let client = new mosSocketClient_1.MosSocketClient(this._host, port, clientDescription, this._timeout, this._debug);
this.debugTrace('registerOutgoingConnection', clientID);
if (this._debug)
console.log('registerOutgoingConnection', clientID);
this._clients[clientID] = {

@@ -55,3 +55,4 @@ useHeartbeats: useHeartbeats,

this.emit('info', `Connect client ${i} on ${this._clients[i].clientDescription} on host ${this._host}`);
this.debugTrace(`Connect client ${i} on ${this._clients[i].clientDescription} on host ${this._host}`);
if (this._debug)
console.log(`Connect client ${i} on ${this._clients[i].clientDescription} on host ${this._host}`);
this._clients[i].client.connect();

@@ -100,2 +101,5 @@ }

}
onConnectionChange(cb) {
this._callbackOnConnectionChange = cb;
}
setDebug(debug) {

@@ -154,3 +158,4 @@ this._debug = debug;

// })
this.debugTrace(this.id + ' ' + this.host + ' handOverQueue');
if (this._debug)
console.log(this.id + ' ' + this.host + ' handOverQueue');
for (const id in this._clients) {

@@ -188,3 +193,4 @@ cmds[id] = this._clients[id].client.handOverQueue();

this._connected = false;
this.emit('connectionChanged');
if (this._callbackOnConnectionChange)
this._callbackOnConnectionChange();
resolveDispose();

@@ -205,10 +211,13 @@ });

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

@@ -219,3 +228,4 @@ .catch((e) => {

this.emit('error', `Heartbeat error on ${this._clients[key].clientDescription}: ${e.toString()}`);
this.debugTrace(`Heartbeat on ${this._clients[key].clientDescription}: ${e.toString()}`);
if (this._debug)
console.log(`Heartbeat on ${this._clients[key].clientDescription}: ${e.toString()}`);
});

@@ -227,11 +237,6 @@ }

}))
.catch((e) => {
triggerNextHeartBeat();
this.emit('error', e);
})
.then(() => {
let connected = this.connected;
if (connected !== this._emittedConnected) {
this._emittedConnected = connected;
this.emit('connectionChanged');
if (connected !== this.connected) {
if (this._callbackOnConnectionChange)
this._callbackOnConnectionChange();
}

@@ -241,11 +246,12 @@ triggerNextHeartBeat();

.catch((e) => {
if (connected !== this.connected) {
if (this._callbackOnConnectionChange)
this._callbackOnConnectionChange();
}
triggerNextHeartBeat();
this.emit('error', e);
});
}
debugTrace(...strs) {
if (this._debug)
console.log(...strs);
}
}
exports.NCSServerConnection = NCSServerConnection;
//# sourceMappingURL=NCSServerConnection.js.map

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

/** */
get lowerPortSockets(): Socket[];
readonly lowerPortSockets: Socket[];
/** */
get upperPortSockets(): Socket[];
readonly upperPortSockets: Socket[];
/** */
get queryPortSockets(): Socket[];
readonly queryPortSockets: Socket[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Server = void 0;
/** */

@@ -5,0 +4,0 @@ class Server {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SocketServerEvent = exports.SocketConnectionEvent = void 0;
/** */

@@ -5,0 +4,0 @@ var SocketConnectionEvent;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosDuration = void 0;
class MosDuration {

@@ -5,0 +4,0 @@ /** */

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

constructor(obj: IMOSExternalMetaData);
get scope(): IMOSScope | undefined;
get schema(): string;
get payload(): any;
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly scope: IMOSScope | undefined;
readonly schema: string;
readonly payload: any;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosExternalMetaData = exports.IMOSScope = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -5,0 +4,0 @@ const Utils_1 = require("..//utils/Utils");

@@ -8,8 +8,8 @@ export declare class MosString128 {

/** */
set string(str: string | {
string: string | {
text: string;
type: string;
} | MosString128 | any);
} | MosString128 | any;
/** */
private _validate;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosString128 = void 0;
class MosString128 {

@@ -5,0 +4,0 @@ /** */

@@ -13,3 +13,2 @@ export declare class MosTime {

getTime(): number;
setTime(timestamp: number): number;
/** */

@@ -16,0 +15,0 @@ private _parseTimeOffset;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosTime = void 0;
const moment = require("moment");

@@ -72,5 +71,2 @@ const Utils_1 = require("./../utils/Utils");

}
setTime(timestamp) {
return this._time.setTime(timestamp);
}
/** */

@@ -77,0 +73,0 @@ _parseTimeOffset(timestamp) {

export * from './MosConnection';
export * from './api';
export { ConnectionConfig, IProfiles } from './config/connectionConfig';
export { IConnectionConfig, ConnectionConfig } from './config/connectionConfig';
export { MosString128 } from './dataTypes/mosString128';

@@ -9,2 +9,1 @@ export { MosDuration } from './dataTypes/mosDuration';

export { MosDevice } from './MosDevice';
export { MosItemReplaceOptions } from './mosModel';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosDevice = exports.MosTime = exports.IMOSScope = exports.MosDuration = exports.MosString128 = exports.ConnectionConfig = void 0;
const tslib_1 = require("tslib");

@@ -8,13 +7,13 @@ tslib_1.__exportStar(require("./MosConnection"), exports);

var connectionConfig_1 = require("./config/connectionConfig");
Object.defineProperty(exports, "ConnectionConfig", { enumerable: true, get: function () { return connectionConfig_1.ConnectionConfig; } });
exports.ConnectionConfig = connectionConfig_1.ConnectionConfig;
var mosString128_1 = require("./dataTypes/mosString128");
Object.defineProperty(exports, "MosString128", { enumerable: true, get: function () { return mosString128_1.MosString128; } });
exports.MosString128 = mosString128_1.MosString128;
var mosDuration_1 = require("./dataTypes/mosDuration");
Object.defineProperty(exports, "MosDuration", { enumerable: true, get: function () { return mosDuration_1.MosDuration; } });
exports.MosDuration = mosDuration_1.MosDuration;
var mosExternalMetaData_1 = require("./dataTypes/mosExternalMetaData");
Object.defineProperty(exports, "IMOSScope", { enumerable: true, get: function () { return mosExternalMetaData_1.IMOSScope; } });
exports.IMOSScope = mosExternalMetaData_1.IMOSScope;
var mosTime_1 = require("./dataTypes/mosTime");
Object.defineProperty(exports, "MosTime", { enumerable: true, get: function () { return mosTime_1.MosTime; } });
exports.MosTime = mosTime_1.MosTime;
var MosDevice_1 = require("./MosDevice");
Object.defineProperty(exports, "MosDevice", { enumerable: true, get: function () { return MosDevice_1.MosDevice; } });
exports.MosDevice = MosDevice_1.MosDevice;
//# sourceMappingURL=index.js.map
/// <reference types="node" />
import { IProfiles } from './config/connectionConfig';
import { IMosConnection, IMOSDeviceConnectionOptions, IConnectionConfig } from './api';
import { IConnectionConfig, IProfiles } from './config/connectionConfig';
import { IMosConnection, IMOSDeviceConnectionOptions } from './api';
import { MosDevice } from './MosDevice';

@@ -36,9 +36,9 @@ import { EventEmitter } from 'events';

/** True if mosConnection is listening for connections */
get isListening(): boolean;
readonly isListening: boolean;
/** TO BE IMPLEMENTED: True if mosConnection is mos-compliant */
get isCompliant(): boolean;
readonly isCompliant: boolean;
/** True if mosConnection is configured to accept connections */
get acceptsConnections(): boolean;
readonly acceptsConnections: boolean;
/** A list of the profiles mosConnection is currently configured to use */
get profiles(): IProfiles;
readonly profiles: IProfiles;
/** Close all connections and clear all data */

@@ -53,3 +53,3 @@ dispose(): Promise<void>;

/** TO BE IMPLEMENTED */
get complianceText(): string;
readonly complianceText: string;
setDebug(debug: boolean): void;

@@ -64,4 +64,3 @@ private _registerMosDevice;

/** Get new unique id */
static get nextSocketID(): string;
private debugTrace;
static readonly nextSocketID: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosConnection = void 0;
const tslib_1 = require("tslib");

@@ -16,3 +15,3 @@ const connectionConfig_1 = require("./config/connectionConfig");

const events_1 = require("events");
const iconv = require("iconv-lite");
const iconv = require('iconv-lite');
class MosConnection extends events_1.EventEmitter {

@@ -37,3 +36,2 @@ /** */

init() {
this.emit('info', `Initializing MOS-Connection, id: ${this._conf.mosID}`);
this._initialized = true;

@@ -63,3 +61,2 @@ if (this._conf.acceptsConnections) {

return new Promise((resolve) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
// Connect to MOS-device:

@@ -81,7 +78,6 @@ let primary = new NCSServerConnection_1.NCSServerConnection(connectionOptions.primary.id, connectionOptions.primary.host, this._conf.mosID, connectionOptions.primary.timeout, this._debug);

});
primary.createClient(MosConnection.nextSocketID, (_b = (_a = connectionOptions.primary.ports) === null || _a === void 0 ? void 0 : _a.lower) !== null && _b !== void 0 ? _b : MosConnection.CONNECTION_PORT_LOWER, 'lower', true);
primary.createClient(MosConnection.nextSocketID, (_d = (_c = connectionOptions.primary.ports) === null || _c === void 0 ? void 0 : _c.upper) !== null && _d !== void 0 ? _d : MosConnection.CONNECTION_PORT_UPPER, 'upper', true);
if (!connectionOptions.primary.dontUseQueryPort) {
primary.createClient(MosConnection.nextSocketID, (_f = (_e = connectionOptions.primary.ports) === null || _e === void 0 ? void 0 : _e.query) !== null && _f !== void 0 ? _f : MosConnection.CONNECTION_PORT_QUERY, 'query', false);
}
primary.createClient(MosConnection.nextSocketID, MosConnection.CONNECTION_PORT_LOWER, 'lower', true);
primary.createClient(MosConnection.nextSocketID, MosConnection.CONNECTION_PORT_UPPER, 'upper', true);
if (!connectionOptions.primary.dontUseQueryPort)
primary.createClient(MosConnection.nextSocketID, MosConnection.CONNECTION_PORT_QUERY, 'query', false);
if (connectionOptions.secondary) {

@@ -102,7 +98,6 @@ secondary = new NCSServerConnection_1.NCSServerConnection(connectionOptions.secondary.id, connectionOptions.secondary.host, this._conf.mosID, connectionOptions.secondary.timeout, this._debug);

});
secondary.createClient(MosConnection.nextSocketID, (_h = (_g = connectionOptions.secondary.ports) === null || _g === void 0 ? void 0 : _g.lower) !== null && _h !== void 0 ? _h : MosConnection.CONNECTION_PORT_LOWER, 'lower', true);
secondary.createClient(MosConnection.nextSocketID, (_k = (_j = connectionOptions.secondary.ports) === null || _j === void 0 ? void 0 : _j.upper) !== null && _k !== void 0 ? _k : MosConnection.CONNECTION_PORT_UPPER, 'upper', true);
if (!connectionOptions.primary.dontUseQueryPort) {
secondary.createClient(MosConnection.nextSocketID, (_m = (_l = connectionOptions.secondary.ports) === null || _l === void 0 ? void 0 : _l.query) !== null && _m !== void 0 ? _m : MosConnection.CONNECTION_PORT_QUERY, 'query', false);
}
secondary.createClient(MosConnection.nextSocketID, MosConnection.CONNECTION_PORT_LOWER, 'lower', true);
secondary.createClient(MosConnection.nextSocketID, MosConnection.CONNECTION_PORT_UPPER, 'upper', true);
if (!connectionOptions.primary.dontUseQueryPort)
secondary.createClient(MosConnection.nextSocketID, MosConnection.CONNECTION_PORT_QUERY, 'query', false);
}

@@ -245,3 +240,3 @@ // Initialize mosDevice:

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

@@ -266,8 +261,7 @@ // Add mosDevice to register:

_initiateIncomingConnections() {
var _a, _b, _c, _d, _e, _f;
if (!this._conf.acceptsConnections) {
return Promise.reject('Not configured for accepting connections');
}
let initSocket = (port, portType) => {
let socketServer = new mosSocketServer_1.MosSocketServer(port, portType);
let initSocket = (port, description) => {
let socketServer = new mosSocketServer_1.MosSocketServer(port, description);
socketServer.on(socketConnection_1.SocketServerEvent.CLIENT_CONNECTED, (e) => this._registerIncomingClient(e));

@@ -280,5 +274,5 @@ socketServer.on(socketConnection_1.SocketServerEvent.ERROR, (e) => {

};
this._lowerSocketServer = initSocket((_b = (_a = this._conf.ports) === null || _a === void 0 ? void 0 : _a.lower) !== null && _b !== void 0 ? _b : MosConnection.CONNECTION_PORT_LOWER, 'lower');
this._upperSocketServer = initSocket((_d = (_c = this._conf.ports) === null || _c === void 0 ? void 0 : _c.upper) !== null && _d !== void 0 ? _d : MosConnection.CONNECTION_PORT_UPPER, 'upper');
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');
this._lowerSocketServer = initSocket(MosConnection.CONNECTION_PORT_LOWER, 'lower');
this._upperSocketServer = initSocket(MosConnection.CONNECTION_PORT_UPPER, 'upper');
this._querySocketServer = initSocket(MosConnection.CONNECTION_PORT_QUERY, 'query');
let handleListen = (socketServer) => {

@@ -309,12 +303,14 @@ return socketServer.listen()

client.socket.on('end', () => {
this.debugTrace('Socket End');
if (this._debug)
console.log('Socket End');
});
client.socket.on('drain', () => {
this.debugTrace('Socket Drain');
if (this._debug)
console.log('Socket Drain');
});
client.socket.on('data', (data) => tslib_1.__awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d;
const messageString = iconv.decode(data, 'utf16-be').trim();
this.emit('rawMessage', 'incoming', 'recieved', messageString);
this.debugTrace(`Socket got data (${socketID}, ${client.socket.remoteAddress}, ${client.portDescription}): ${data}`);
if (this._debug)
console.log(`Socket got data (${socketID}, ${client.socket.remoteAddress}, ${client.portDescription}): ${data}`);
const remoteAddressContent = client.socket.remoteAddress

@@ -359,3 +355,4 @@ ? client.socket.remoteAddress.split(':')

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

@@ -368,21 +365,3 @@ this.emit('rawMessage', 'incoming_' + socketID, 'sent', messageString);

if (ncsID === this._conf.mosID) {
// Setup a "primary" connection back to the mos-device, so that we can automatically
// send commands to it through the mosDevice
let primary = new NCSServerConnection_1.NCSServerConnection(mosID, remoteAddress, this._conf.mosID, undefined, this._debug);
this._ncsConnections[remoteAddress] = primary;
primary.on('rawMessage', (type, message) => {
this.emit('rawMessage', 'primary', type, message);
});
primary.on('warning', (str) => {
this.emit('warning', 'primary: ' + str);
});
primary.on('error', (str) => {
this.emit('error', 'primary: ' + str);
});
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);
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);
mosDevice = this._registerMosDevice(this._conf.mosID, mosID, null, primary, null);
mosDevice = this._registerMosDevice(this._conf.mosID, mosID, null, null, null);
}

@@ -399,3 +378,3 @@ else if (mosID === this._conf.mosID) {

if (mosDevice) {
mosDevice.routeData(parsed, client.portDescription).then((message) => {
mosDevice.routeData(parsed).then((message) => {
sendReply(message);

@@ -410,3 +389,3 @@ }).catch((err) => {

// Log error:
console.error(err);
console.log(err);
// reply with NACK:

@@ -422,2 +401,3 @@ // TODO: implement ACK

}
// console.log(err)
});

@@ -431,3 +411,3 @@ }

msg.Revision = 0;
msg.Description = new mosString128_1.MosString128(`MosDevice "${ncsID + '_' + mosID}" not found`);
msg.Description = new mosString128_1.MosString128('MosDevice not found');
msg.Status = api_1.IMOSAckStatus.NACK;

@@ -439,5 +419,7 @@ sendReply(msg); // TODO: Need tests

catch (e) {
this.debugTrace('chunks-------------\n', client.chunks);
this.debugTrace('messageString---------\n', messageString);
this.debugTrace('error', e);
if (this._debug) {
console.log('chunks-------------\n', client.chunks);
console.log('messageString---------\n', messageString);
console.log('error', e);
}
this.emit('error', e);

@@ -448,7 +430,9 @@ }

this.emit('error', `Socket had error (${socketID}, ${client.socket.remoteAddress}, ${client.portDescription}): ${e}`);
this.debugTrace(`Socket had error (${socketID}, ${client.socket.remoteAddress}, ${client.portDescription}): ${e}`);
if (this._debug)
console.log(`Socket had error (${socketID}, ${client.socket.remoteAddress}, ${client.portDescription}): ${e}`);
});
// Register this socket:
this._incomingSockets[socketID + ''] = client;
this.debugTrace('Added socket: ', socketID);
if (this._debug)
console.log('Added socket: ', socketID);
}

@@ -463,3 +447,4 @@ /** Close socket and clean up */

delete this._incomingSockets[socketID + ''];
this.debugTrace('removed: ', socketID, '\n');
if (this._debug)
console.log('removed: ', socketID, '\n');
}

@@ -470,6 +455,2 @@ /** Get new unique id */

}
debugTrace(...strs) {
if (this._debug)
console.log(...strs);
}
}

@@ -476,0 +457,0 @@ exports.MosConnection = MosConnection;

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

import { IMOSExternalMetaData } from './dataTypes/mosExternalMetaData';
import { IMOSObject, IMOSDevice, IMOSRunningOrder, IMOSRunningOrderBase, IMOSRunningOrderStatus, IMOSStoryStatus, IMOSItemStatus, IMOSROReadyToAir, IMOSStoryAction, IMOSItem, IMOSROAction, IMOSROStory, IMOSItemAction, IMOSROFullStory, IMOSROAck, IMOSConnectionStatus, IMOSObjectList, IMOSRequestObjectList, IMOSListSearchableSchema, IMOSAck, IConnectionConfig } from './api';
import { IMOSListMachInfo, IMOSDefaultActiveX, MosItemReplaceOptions } from './mosModel';
import { PortType } from './mosModel/MosMessage';
import { IMOSObject, IMOSDevice, IMOSRunningOrder, IMOSRunningOrderBase, IMOSRunningOrderStatus, IMOSStoryStatus, IMOSItemStatus, IMOSROReadyToAir, IMOSStoryAction, IMOSItem, IMOSROAction, IMOSROStory, IMOSItemAction, IMOSROFullStory, IMOSROAck, IMOSConnectionStatus, IMosObjectList, IMosRequestObjectList, IMOSSearchableSchema, IMOSAck } from './api';
import { IConnectionConfig } from './config/connectionConfig';
import { IMOSListMachInfo, IMOSDefaultActiveX, MOSAck, MosItemReplaceOptions } from './mosModel';
export declare class MosDevice implements IMOSDevice {

@@ -29,9 +29,6 @@ socket: Socket;

private supportedProfiles;
/** If set, will do more checks that mos-protocol is properly implemented */
private _strict;
private _disposed;
private _primaryConnection;
private _secondaryConnection;
private _currentConnection;
private _callbackOnRequestMachineInfo?;
private _callbackOnGetMachineInfo?;
private _callbackOnConnectionChange?;

@@ -59,156 +56,74 @@ private _callbackOnRequestMOSOBject?;

private _callbackOnROSwapItems?;
private _callbackOnItemReplace?;
private _callbackOnObjectCreate?;
private _callbackOnRequestObjectActionNew?;
private _callbackOnRequestObjectActionUpdate?;
private _callbackOnRequestObjectActionDelete?;
private _callbackOnRequestObjectList?;
private _callbackOnRequestSearchableSchema?;
private _callbackOnRequestAllRunningOrders?;
private _callbackOnRunningOrderStory?;
constructor(idPrimary: string, idSecondary: string | null, connectionConfig: IConnectionConfig, primaryConnection: NCSServerConnection | null, secondaryConnection: NCSServerConnection | null, offSpecFailover?: boolean, strict?: boolean);
private _callbackOnMosItemReplace?;
private _callbackOnMosObjCreate?;
private _callbackOnMosObjAction?;
private _callbackOnMosReqObjList?;
private _callbackOnMosReqSearchableSchema?;
private _callbackOnROStory?;
constructor(idPrimary: string, idSecondary: string | null, connectionConfig: IConnectionConfig, primaryConnection: NCSServerConnection | null, secondaryConnection: NCSServerConnection | null, offSpecFailover?: boolean);
/** True if MOS-device has connection to server (can send messages) */
get hasConnection(): boolean;
readonly hasConnection: boolean;
/** Primary ID (probably the NCS-ID) */
get idPrimary(): string;
/** Secondary / Buddy ID (probably the MOS-ID) */
get idSecondary(): string | null;
readonly idPrimary: string;
/** Secondary ID (probably the MOS-ID) */
readonly idSecondary: string | null;
/** Host name (IP-address) of the primary server */
get primaryHost(): string | null;
readonly primaryHost: string | null;
/** Name (ID) of the primary server */
get primaryId(): string | null;
readonly primaryId: string | null;
/** Host name (IP-address) of the secondary (buddy) server */
get secondaryHost(): string | null;
readonly secondaryHost: string | null;
/** Name (ID) of the secondary (buddy) server */
get secondaryId(): string | null;
readonly secondaryId: string | null;
connect(): void;
dispose(): Promise<void>;
routeData(data: any, port: PortType): Promise<any>;
requestMachineInfo(): Promise<IMOSListMachInfo>;
onRequestMachineInfo(cb: () => Promise<IMOSListMachInfo>): void;
routeData(data: any): Promise<any>;
getMachineInfo(): Promise<IMOSListMachInfo>;
onGetMachineInfo(cb: () => Promise<IMOSListMachInfo>): void;
onConnectionChange(cb: (connectionStatus: IMOSConnectionStatus) => void): void;
getConnectionStatus(): IMOSConnectionStatus;
/** @deprecated getMachineInfo is deprecated, use requestMachineInfo instead */
getMachineInfo(): Promise<IMOSListMachInfo>;
/** @deprecated onGetMachineInfo is deprecated, use onRequestMachineInfo instead */
onGetMachineInfo(cb: () => Promise<IMOSListMachInfo>): void;
sendMOSObject(obj: IMOSObject): Promise<IMOSAck>;
onRequestMOSObject(cb: (objId: string) => Promise<IMOSObject | null>): void;
sendRequestMOSObject(objID: MosString128): Promise<IMOSObject>;
onRequestAllMOSObjects(cb: () => Promise<Array<IMOSObject>>): void;
sendRequestAllMOSObjects(): Promise<Array<IMOSObject>>;
/**
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosListAll
*/
private _sendAllMOSObjects;
/**
* @deprecated getMOSObject is deprecated, use sendRequestMOSObject instead
*/
getMOSObject(objId: MosString128): Promise<IMOSObject>;
/** @deprecated getAllMOSObjects is deprecated, use sendRequestAllMOSObjects instead */
getAllMOSObjects(): Promise<IMOSObject[]>;
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;
sendCreateRunningOrder(ro: IMOSRunningOrder): Promise<IMOSROAck>;
onReplaceRunningOrder(cb: (ro: IMOSRunningOrder) => Promise<IMOSROAck>): void;
sendReplaceRunningOrder(ro: IMOSRunningOrder): Promise<IMOSROAck>;
onDeleteRunningOrder(cb: (runningOrderId: MosString128) => Promise<IMOSROAck>): void;
sendDeleteRunningOrder(runningOrderId: MosString128): Promise<IMOSROAck>;
onRequestRunningOrder(cb: (runningOrderId: MosString128) => Promise<IMOSRunningOrder | null>): void;
sendRequestRunningOrder(runningOrderId: MosString128): Promise<IMOSRunningOrder | null>;
/**
* @deprecated getRunningOrder is deprecated, use sendRequestRunningOrder instead
*/
getRunningOrder(runningOrderId: MosString128): Promise<IMOSRunningOrder | null>;
onMetadataReplace(cb: (metadata: IMOSRunningOrderBase) => Promise<IMOSROAck>): void;
sendMetadataReplace(metadata: IMOSRunningOrderBase): Promise<IMOSROAck>;
onRunningOrderStatus(cb: (status: IMOSRunningOrderStatus) => Promise<IMOSROAck>): void;
onStoryStatus(cb: (status: IMOSStoryStatus) => Promise<IMOSROAck>): void;
onItemStatus(cb: (status: IMOSItemStatus) => Promise<IMOSROAck>): void;
/** @deprecated setRunningOrderStatus is deprecated, use sendRunningOrderStatus instead */
setRunningOrderStatus(status: IMOSRunningOrderStatus): Promise<IMOSROAck>;
/** @deprecated setStoryStatus is deprecated, use sendStoryStatus instead */
setStoryStatus(status: IMOSStoryStatus): Promise<IMOSROAck>;
/** @deprecated setItemStatus is deprecated, use sendItemStatus instead */
setItemStatus(status: IMOSItemStatus): Promise<IMOSROAck>;
sendRunningOrderStatus(status: IMOSRunningOrderStatus): Promise<IMOSROAck>;
sendStoryStatus(status: IMOSStoryStatus): Promise<IMOSROAck>;
sendItemStatus(status: IMOSItemStatus): Promise<IMOSROAck>;
onReadyToAir(cb: (Action: IMOSROReadyToAir) => Promise<IMOSROAck>): void;
sendReadyToAir(Action: IMOSROReadyToAir): Promise<IMOSROAck>;
onROInsertStories(cb: (Action: IMOSStoryAction, Stories: Array<IMOSROStory>) => Promise<IMOSROAck>): void;
sendROInsertStories(Action: IMOSStoryAction, Stories: Array<IMOSROStory>): Promise<IMOSROAck>;
onROInsertItems(cb: (Action: IMOSItemAction, Items: Array<IMOSItem>) => Promise<IMOSROAck>): void;
sendROInsertItems(Action: IMOSItemAction, Items: Array<IMOSItem>): Promise<IMOSROAck>;
onROReplaceStories(cb: (Action: IMOSStoryAction, Stories: Array<IMOSROStory>) => Promise<IMOSROAck>): void;
sendROReplaceStories(Action: IMOSStoryAction, Stories: Array<IMOSROStory>): Promise<IMOSROAck>;
onROReplaceItems(cb: (Action: IMOSItemAction, Items: Array<IMOSItem>) => Promise<IMOSROAck>): void;
sendROReplaceItems(Action: IMOSItemAction, Items: Array<IMOSItem>): Promise<IMOSROAck>;
onROMoveStories(cb: (Action: IMOSStoryAction, Stories: Array<MosString128>) => Promise<IMOSROAck>): void;
sendROMoveStories(Action: IMOSStoryAction, Stories: Array<MosString128>): Promise<IMOSROAck>;
onROMoveItems(cb: (Action: IMOSItemAction, Items: Array<MosString128>) => Promise<IMOSROAck>): void;
sendROMoveItems(Action: IMOSItemAction, Items: Array<MosString128>): Promise<IMOSROAck>;
onRODeleteStories(cb: (Action: IMOSROAction, Stories: Array<MosString128>) => Promise<IMOSROAck>): void;
sendRODeleteStories(Action: IMOSROAction, Stories: Array<MosString128>): Promise<IMOSROAck>;
onRODeleteItems(cb: (Action: IMOSStoryAction, Items: Array<MosString128>) => Promise<IMOSROAck>): void;
sendRODeleteItems(Action: IMOSStoryAction, Items: Array<MosString128>): Promise<IMOSROAck>;
onROSwapStories(cb: (Action: IMOSROAction, StoryID0: MosString128, StoryID1: MosString128) => Promise<IMOSROAck>): void;
sendROSwapStories(Action: IMOSROAction, StoryID0: MosString128, StoryID1: MosString128): Promise<IMOSROAck>;
onROSwapItems(cb: (Action: IMOSStoryAction, ItemID0: MosString128, ItemID1: MosString128) => Promise<IMOSROAck>): void;
sendROSwapItems(Action: IMOSStoryAction, ItemID0: MosString128, ItemID1: MosString128): Promise<IMOSROAck>;
onObjectCreate(cb: (object: IMOSObject) => Promise<IMOSAck>): void;
sendObjectCreate(object: IMOSObject): Promise<IMOSAck>;
onItemReplace(cb: (roID: MosString128, storyID: MosString128, item: IMOSItem) => Promise<IMOSROAck>): void;
sendItemReplace(options: MosItemReplaceOptions): Promise<IMOSROAck>;
onRequestSearchableSchema(cb: (username: string) => Promise<IMOSListSearchableSchema>): void;
sendRequestSearchableSchema(username: string): Promise<IMOSListSearchableSchema>;
onRequestObjectList(cb: (objList: IMOSRequestObjectList) => Promise<IMOSObjectList>): void;
sendRequestObjectList(reqObjList: IMOSRequestObjectList): Promise<IMOSObjectList>;
onRequestObjectActionNew(cb: (obj: IMOSObject) => Promise<IMOSAck>): void;
sendRequestObjectActionNew(obj: IMOSObject): Promise<IMOSAck>;
onRequestObjectActionUpdate(cb: (objId: MosString128, obj: IMOSObject) => Promise<IMOSAck>): void;
sendRequestObjectActionUpdate(objId: MosString128, obj: IMOSObject): Promise<IMOSAck>;
onRequestObjectActionDelete(cb: (objId: MosString128) => Promise<IMOSAck>): void;
sendRequestObjectActionDelete(objId: MosString128): Promise<IMOSAck>;
/** @deprecated onMosObjCreate is deprecated, use onObjectCreate instead */
onMosObjCreate(cb: (object: IMOSObject) => Promise<IMOSAck>): void;
/** @deprecated mosObjCreate is deprecated, use sendObjectCreate instead */
mosObjCreate(object: IMOSObject): Promise<IMOSAck>;
/** @deprecated onMosItemReplace is deprecated, use onItemReplace instead */
mosObjCreate(object: IMOSObject): Promise<MOSAck>;
onMosItemReplace(cb: (roID: MosString128, storyID: MosString128, item: IMOSItem) => Promise<IMOSROAck>): void;
/** @deprecated mosItemReplace is deprecated, use sendItemReplace instead */
mosItemReplace(options: MosItemReplaceOptions): Promise<IMOSROAck>;
/** @deprecated onMosReqSearchableSchema is deprecated, use onRequestSearchableSchema instead */
onMosReqSearchableSchema(cb: (username: string) => Promise<IMOSListSearchableSchema>): void;
/** @deprecated mosRequestSearchableSchema is deprecated, use sendRequestSearchableSchema instead */
mosRequestSearchableSchema(username: string): Promise<IMOSListSearchableSchema>;
/** @deprecated onMosReqObjectList is deprecated, use onRequestObjectList instead */
onMosReqObjectList(cb: (objList: IMOSRequestObjectList) => Promise<IMOSObjectList>): void;
/** @deprecated mosRequestObjectList is deprecated, use sendRequestObjectList instead */
mosRequestObjectList(reqObjList: IMOSRequestObjectList): Promise<IMOSObjectList>;
/** @deprecated onMosReqObjectAction is deprecated, use onRequestObjectAction*** instead */
onMosReqObjectAction(_cb: (action: string, obj: IMOSObject) => Promise<IMOSAck>): void;
onRequestAllRunningOrders(cb: () => Promise<IMOSRunningOrder[]>): void;
sendRequestAllRunningOrders(): Promise<Array<IMOSRunningOrderBase>>;
onRunningOrderStory(cb: (story: IMOSROFullStory) => Promise<IMOSROAck>): void;
sendRunningOrderStory(story: IMOSROFullStory): Promise<IMOSROAck>;
/** @deprecated onROReqAll is deprecated use onRequestAllRunningOrders instead */
onROReqAll(cb: () => Promise<IMOSRunningOrder[]>): void;
/** @deprecated getAllRunningOrders is deprecated use sendRequestAllRunningOrders instead */
onMosReqSearchableSchema(cb: (username: string) => Promise<IMOSSearchableSchema>): void;
mosRequestSearchableSchema(username: string): Promise<IMOSSearchableSchema>;
onMosReqObjectList(cb: (objList: IMosRequestObjectList) => Promise<IMosObjectList>): void;
mosRequestObjectList(reqObjList: IMosRequestObjectList): Promise<IMosObjectList>;
onMosReqObjectAction(cb: (action: string, obj: IMOSObject) => Promise<IMOSAck>): void;
getAllRunningOrders(): Promise<Array<IMOSRunningOrderBase>>;
/** @deprecated onROStory is deprecated use onRunningOrderStory instead */
onROStory(cb: (story: IMOSROFullStory) => Promise<IMOSROAck>): void;
/** @deprecated sendROStory is deprecated use sendRunningOrderStory instead */
sendROStory(story: IMOSROFullStory): Promise<IMOSROAck>;
setDebug(debug: boolean): void;
checkProfileValidness(): void;
private executeCommand;
private switchConnections;
private switchConnectionsAndExecuteCommand;
private _emitConnectionChange;
/** throws if there is an error */
private _ensureReply;
/** throws if something's wrong
*/
private _checkProfileValidness;
private debugTrace;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosDevice = void 0;
const tslib_1 = require("tslib");
const net_1 = require("net");
const mosString128_1 = require("./dataTypes/mosString128");
const mosTime_1 = require("./dataTypes/mosTime");
// import { MosDuration } from './dataTypes/mosDuration'
const api_1 = require("./api");
const Parser_1 = require("./mosModel/Parser");
const mosModel_1 = require("./mosModel");
const ROListAll_1 = require("./mosModel/profile2/ROListAll");
const roCreate_1 = require("./mosModel/profile2/roCreate");
const roReplace_1 = require("./mosModel/profile2/roReplace");
const roDelete_1 = require("./mosModel/profile2/roDelete");
const roActions_1 = require("./mosModel/profile2/roActions");
const roStory_1 = require("./mosModel/profile4/roStory");
const roMetadataReplace_1 = require("./mosModel/profile2/roMetadataReplace");
const roReadyToAir_1 = require("./mosModel/profile2/roReadyToAir");
class MosDevice {
constructor(idPrimary, idSecondary, connectionConfig, primaryConnection, secondaryConnection, offSpecFailover, strict) {
constructor(idPrimary, idSecondary, connectionConfig, primaryConnection, secondaryConnection, offSpecFailover) {
this._debug = false;

@@ -33,3 +24,3 @@ this.supportedProfiles = {

}; // Use same names as IProfiles?
this._disposed = false;
// private _profiles: ProfilesSupport
this._primaryConnection = null;

@@ -53,3 +44,2 @@ this._secondaryConnection = null;

this.mosRev = new mosString128_1.MosString128('2.8.5');
this._strict = strict;
if (connectionConfig) {

@@ -72,4 +62,2 @@ if (connectionConfig.profiles['0'])

this.supportedProfiles.profile7 = true;
if (connectionConfig.isNCS)
this.supportedProfiles.deviceType = 'NCS';
if (connectionConfig.debug)

@@ -80,6 +68,6 @@ this._debug = connectionConfig.debug;

this._primaryConnection = primaryConnection;
this._primaryConnection.on('connectionChanged', () => {
this._primaryConnection.onConnectionChange(() => {
this._emitConnectionChange();
if (offSpecFailover && this._currentConnection !== this._primaryConnection && this._primaryConnection.connected) {
this.switchConnections(); // and hope no current message goes lost
this.switchConnections().catch(() => null); // and hope no current message goes lost
}

@@ -90,17 +78,5 @@ });

this._secondaryConnection = secondaryConnection;
this._secondaryConnection.on('connectionChanged', () => this._emitConnectionChange());
this._secondaryConnection.onConnectionChange(() => this._emitConnectionChange());
}
this._currentConnection = this._primaryConnection || this._secondaryConnection || null;
if (this._strict) {
setTimeout(() => {
if (this._disposed)
return;
try {
this._checkProfileValidness();
}
catch (e) {
console.error(e);
}
}, 1000);
}
this._currentConnection = this._primaryConnection || this._primaryConnection || null;
}

@@ -115,3 +91,3 @@ /** True if MOS-device has connection to server (can send messages) */

}
/** Secondary / Buddy ID (probably the MOS-ID) */
/** Secondary ID (probably the MOS-ID) */
get idSecondary() {

@@ -143,3 +119,3 @@ return this._idSecondary;

dispose() {
const ps = [];
let ps = [];
if (this._primaryConnection)

@@ -154,106 +130,129 @@ ps.push(this._primaryConnection.dispose());

}
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));
routeData(data) {
if (data && data.hasOwnProperty('mos'))
data = data['mos'];
return new Promise((resolve, reject) => {
if (this._debug)
console.log('parsedData', data);
// if (this._debug) console.log('parsedTest', keys)
if (this._debug)
console.log('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);
// send immediate reply:
let ack = new mosModel_1.HeartBeat();
resolve(ack);
}
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);
else if (data.reqMachInfo && typeof this._callbackOnGetMachineInfo === 'function') {
this._callbackOnGetMachineInfo().then((m) => {
let resp = new mosModel_1.ListMachineInfo(m);
resolve(resp);
}).catch(reject);
// 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);
this._callbackOnRequestMOSOBject(data.mosReqObj.objID).then((mosObj) => {
let resp = new mosModel_1.MosObj(mosObj);
resolve(resp);
}).catch(reject);
}
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);
}
this._callbackOnRequestAllMOSObjects(pause)
.then(resp => {
if (Array.isArray(resp)) {
let list = new mosModel_1.MosListAll(resp);
resolve(list);
}
else {
this._sendAllMOSObjects(mosObjects)
.catch(e => {
console.error('Error in async mosListAll response to mosReqAll', e);
});
const mosAck = new mosModel_1.MOSAck();
mosAck.ID = resp.ID;
mosAck.Revision = resp.Revision;
mosAck.Status = resp.Status;
mosAck.Description = resp.Description;
resolve(mosAck);
}
});
const mosAck = new mosModel_1.MOSAck();
return mosAck;
}).catch(reject);
// 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);
let ro = Parser_1.Parser.xml2RO(data.roCreate);
/*
let stories: Array<IMOSROStory> = Parser.xml2Stories(data.roCreate.story)
let ro: IMOSRunningOrder = {
ID: new MosString128(data.roCreate.roID),
Slug: new MosString128(data.roCreate.roSlug),
Stories: stories
}
if (data.roCreate.hasOwnProperty('roEdStart')) ro.EditorialStart = new MosTime(data.roCreate.roEdStart)
if (data.roCreate.hasOwnProperty('roEdDur')) ro.EditorialDuration = new MosDuration(data.roCreate.roEdDur)
if (data.roCreate.hasOwnProperty('mosExternalMetadata')) {
// TODO: Handle an array of mosExternalMetadata
let meta: IMOSExternalMetaData = {
MosSchema: data.roCreate.mosExternalMetadata.mosSchema,
MosPayload: data.roCreate.mosExternalMetadata.mosPayload
}
if (data.roCreate.mosExternalMetadata.hasOwnProperty('mosScope')) meta.MosScope = data.roCreate.mosExternalMetadata.mosScope
ro.MosExternalMetaData = [meta]
}
*/
this._callbackOnCreateRunningOrder(ro).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}
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);
let ro = Parser_1.Parser.xml2RO(data.roReplace);
this._callbackOnReplaceRunningOrder(ro).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}
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);
this._callbackOnDeleteRunningOrder(data.roDelete.roID).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}
else if (data.roReq && typeof this._callbackOnRequestRunningOrder === 'function') {
const ro = yield this._callbackOnRequestRunningOrder(data.roReq.roID);
if (ro) {
const resp = new mosModel_1.ROList();
resp.RO = ro;
return resp;
}
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._callbackOnRequestRunningOrder(data.roReq.roID).then((ro) => {
if (ro) {
let resp = new mosModel_1.ROList();
resp.RO = ro;
resolve(resp);
}
else {
// RO not found
let ack = new mosModel_1.ROAck();
ack.ID = data.roReq.roID;
ack.Status = new mosString128_1.MosString128(api_1.IMOSAckStatus.NACK);
// ack.Stories = resp.Stories
resolve(ack);
}
}).catch(reject);
}
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);
let ro = Parser_1.Parser.xml2ROBase(data.roMetadataReplace);
this._callbackOnMetadataReplace(ro).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}
else if (data.roElementStat && data.roElementStat.element === 'RO' && typeof this._callbackOnRunningOrderStatus === 'function') {
const status = {
let status = {
ID: new mosString128_1.MosString128(data.roElementStat.roID),

@@ -263,7 +262,12 @@ Status: data.roElementStat.status,

};
const resp = yield this._callbackOnRunningOrderStatus(status);
return new mosModel_1.ROAck(resp);
this._callbackOnRunningOrderStatus(status).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}
else if (data.roElementStat && data.roElementStat.element === 'STORY' && typeof this._callbackOnStoryStatus === 'function') {
const status = {
let status = {
RunningOrderId: new mosString128_1.MosString128(data.roElementStat.roID),

@@ -274,4 +278,9 @@ ID: new mosString128_1.MosString128(data.roElementStat.storyID),

};
const resp = yield this._callbackOnStoryStatus(status);
return new mosModel_1.ROAck(resp);
this._callbackOnStoryStatus(status).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -281,3 +290,3 @@ else if (data.roElementStat &&

typeof this._callbackOnItemStatus === 'function') {
const status = {
let status = {
RunningOrderId: new mosString128_1.MosString128(data.roElementStat.roID),

@@ -293,11 +302,21 @@ StoryId: new mosString128_1.MosString128(data.roElementStat.storyID),

status.Channel = new mosString128_1.MosString128(data.roElementStat.itemChannel);
const resp = yield this._callbackOnItemStatus(status);
return new mosModel_1.ROAck(resp);
this._callbackOnItemStatus(status).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}
else if (data.roReadyToAir && typeof this._callbackOnReadyToAir === 'function') {
const resp = yield this._callbackOnReadyToAir({
this._callbackOnReadyToAir({
ID: new mosString128_1.MosString128(data.roReadyToAir.roID),
Status: data.roReadyToAir.roAir
});
return new mosModel_1.ROAck(resp);
}).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -308,9 +327,15 @@ else if (data.roElementAction &&

typeof this._callbackOnROInsertStories === 'function') {
const action = {
let 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);
let stories = Parser_1.Parser.xml2Stories([data.roElementAction.element_source.story]);
this._callbackOnROInsertStories(action, stories)
.then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -321,3 +346,3 @@ else if (data.roElementAction &&

typeof this._callbackOnROInsertItems === 'function') {
const action = {
let action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),

@@ -327,5 +352,11 @@ StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),

};
const items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);
const resp = yield this._callbackOnROInsertItems(action, items);
return new mosModel_1.ROAck(resp);
let items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);
this._callbackOnROInsertItems(action, items)
.then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
// ack.Stories = resp.Stories
resolve(ack);
}).catch(reject);
}

@@ -336,9 +367,14 @@ else if (data.roElementAction &&

typeof this._callbackOnROReplaceStories === 'function') {
const action = {
let 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);
let stories = Parser_1.Parser.xml2Stories([data.roElementAction.element_source.story]);
this._callbackOnROReplaceStories(action, stories).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -349,3 +385,3 @@ else if (data.roElementAction &&

typeof this._callbackOnROReplaceItems === 'function') {
const action = {
let action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),

@@ -355,6 +391,11 @@ StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),

};
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);
let items = Parser_1.Parser.xml2Items(data.roElementAction.element_source.item);
this._callbackOnROReplaceItems(action, items)
.then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
// ack.Stories = resp.Stories
resolve(ack);
}).catch(reject);
}

@@ -365,9 +406,14 @@ else if (data.roElementAction &&

typeof this._callbackOnROMoveStories === 'function') {
const action = {
let 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);
let storyIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
this._callbackOnROMoveStories(action, storyIDs).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -378,3 +424,3 @@ else if (data.roElementAction &&

typeof this._callbackOnROMoveItems === 'function') {
const action = {
let action = {
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID),

@@ -384,5 +430,10 @@ StoryID: new mosString128_1.MosString128((data.roElementAction.element_target || {}).storyID),

};
const itemIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
const resp = yield this._callbackOnROMoveItems(action, itemIDs);
return new mosModel_1.ROAck(resp);
let itemIDs = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
this._callbackOnROMoveItems(action, itemIDs).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -393,7 +444,12 @@ else if (data.roElementAction &&

typeof this._callbackOnRODeleteStories === 'function') {
const stories = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
const resp = yield this._callbackOnRODeleteStories({
let stories = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
this._callbackOnRODeleteStories({
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID)
}, stories);
return new mosModel_1.ROAck(resp);
}, stories).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -404,9 +460,14 @@ else if (data.roElementAction &&

typeof this._callbackOnRODeleteItems === 'function') {
const action = {
let 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);
let items = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
this._callbackOnRODeleteItems(action, items).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -418,7 +479,12 @@ else if (data.roElementAction &&

typeof this._callbackOnROSwapStories === 'function') {
const stories = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
const resp = yield this._callbackOnROSwapStories({
let stories = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.storyID);
this._callbackOnROSwapStories({
RunningOrderID: new mosString128_1.MosString128(data.roElementAction.roID)
}, stories[0], stories[1]);
return new mosModel_1.ROAck(resp);
}, stories[0], stories[1]).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}

@@ -430,56 +496,70 @@ else if (data.roElementAction &&

typeof this._callbackOnROSwapItems === 'function') {
const items = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
const resp = yield this._callbackOnROSwapItems({
let items = Parser_1.Parser.xml2IDs(data.roElementAction.element_source.itemID);
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);
}, items[0], items[1]).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
// 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.mosItemReplace && typeof this._callbackOnMosItemReplace === 'function') {
this._callbackOnMosItemReplace(data.mosItemReplace.ID, data.mosItemReplace.itemID, Parser_1.Parser.xml2Item(data.mosItemReplace.item))
.then(resp => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
}
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.mosObjCreate && typeof this._callbackOnMosObjCreate === 'function') {
this._callbackOnMosObjCreate(Parser_1.Parser.xml2MosObj(data.mosObjCreate))
.then(resp => {
let ack = new mosModel_1.MOSAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Description = resp.Description;
resolve(ack);
}).catch(reject);
}
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 && typeof this._callbackOnMosObjAction === 'function') {
this._callbackOnMosObjAction(data.mosReqObjAction.operation, Parser_1.Parser.xml2MosObj(data.mosReqObjAction)).then(resp => {
let ack = new mosModel_1.MOSAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Description = resp.Description;
resolve(ack);
}).catch(reject);
}
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.mosReqObjList && typeof this._callbackOnMosReqObjList === 'function') {
this._callbackOnMosReqObjList(Parser_1.Parser.xml2ReqObjList(data.mosReqObjList))
.then(resp => {
const reply = new mosModel_1.MosObjList(resp);
resolve(reply);
})
.catch(reject);
}
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);
else if (data.mosReqSearchableSchema && typeof this._callbackOnMosReqSearchableSchema === 'function') {
this._callbackOnMosReqSearchableSchema(data.mosReqSearchableSchema.username)
.then(resp => {
const reply = new mosModel_1.MosListSearchableSchema(resp);
resolve(reply);
})
.catch(reject);
// 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);
else if (data.roStorySend && typeof this._callbackOnROStory === 'function') {
let story = Parser_1.Parser.xml2FullStory(data.roStorySend);
this._callbackOnROStory(story).then((resp) => {
let ack = new mosModel_1.ROAck();
ack.ID = resp.ID;
ack.Status = resp.Status;
ack.Stories = resp.Stories;
resolve(ack);
}).catch(reject);
// TODO: Use MosMessage instead of string

@@ -489,4 +569,5 @@ // TODO: Use reject if function dont exists? Put Nack in ondata

else {
this.debugTrace(data);
const msg = new mosModel_1.MOSAck();
if (this._debug)
console.log(data);
let msg = new mosModel_1.MOSAck();
msg.ID = new mosString128_1.MosString128(0); // Depends on type of message, needs logic

@@ -496,3 +577,3 @@ msg.Revision = 0;

msg.Status = api_1.IMOSAckStatus.NACK;
return msg;
resolve(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>')

@@ -502,30 +583,31 @@ }

}
// ============================================================================================================
// ========================== Profile 0 ===================================================================
// ============================================================================================================
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;
/* Profile 0 */
getMachineInfo() {
let message = new mosModel_1.ReqMachInfo();
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message).then((data) => {
let listMachInfo = data.mos.listMachInfo;
let 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!
};
resolve(list);
}).catch(reject);
}
});
}
onRequestMachineInfo(cb) {
this._callbackOnRequestMachineInfo = cb;
onGetMachineInfo(cb) {
this._callbackOnGetMachineInfo = cb;
}

@@ -544,150 +626,120 @@ onConnectionChange(cb) {

}
// Deprecated methods:
/** @deprecated getMachineInfo is deprecated, use requestMachineInfo instead */
getMachineInfo() {
return this.requestMachineInfo();
}
/** @deprecated onGetMachineInfo is deprecated, use onRequestMachineInfo instead */
onGetMachineInfo(cb) {
return this.onRequestMachineInfo(cb);
}
// ============================================================================================================
// ========================== Profile 1 ===================================================================
// ============================================================================================================
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;
});
}
/* Profile 1 */
onRequestMOSObject(cb) {
this._callbackOnRequestMOSOBject = 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');
}
});
}
onRequestAllMOSObjects(cb) {
this._callbackOnRequestAllMOSObjects = 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());
getMOSObject(objID) {
let message = new mosModel_1.ReqMosObj(objID);
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message).then((data) => {
if (data.mos.roAck) {
reject(Parser_1.Parser.xml2ROAck(data.mos.roAck));
}
else if (data.mos.mosObj) {
let obj = Parser_1.Parser.xml2MosObj(data.mos.mosObj);
resolve(obj);
}
else {
reject('Unknown response');
}
}).catch(reject);
}
else if (reply.mos.mosListAll) {
const objs = Parser_1.Parser.xml2MosObjs(reply.mos.mosListAll.mosObj);
return objs;
});
}
getAllMOSObjects() {
let message = new mosModel_1.ReqMosObjAll();
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message).then((data) => {
if (data.mos.roAck) {
reject(Parser_1.Parser.xml2ROAck(data.mos.roAck));
}
else if (data.mos.mosListAll) {
let objs = Parser_1.Parser.xml2MosObjs(data.mos.mosListAll.mosObj);
resolve(objs);
}
else {
reject('Unknown response');
}
}).catch(reject);
}
else {
throw new Error('Unknown response');
});
}
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);
}
});
}
/**
* http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosListAll
*/
_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;
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);
}
else {
throw new Error('Unknown response');
}
});
}
/**
* @deprecated getMOSObject is deprecated, use sendRequestMOSObject instead
*/
getMOSObject(objId) {
return this.sendRequestMOSObject(objId);
}
/** @deprecated getAllMOSObjects is deprecated, use sendRequestAllMOSObjects instead */
getAllMOSObjects() {
return this.sendRequestAllMOSObjects();
}
// ============================================================================================================
// ========================== Profile 2 ===================================================================
// ============================================================================================================
/* Profile 2 */
onCreateRunningOrder(cb) {
this._callbackOnCreateRunningOrder = cb;
}
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);
});
}
onReplaceRunningOrder(cb) {
this._callbackOnReplaceRunningOrder = 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);
});
}
onDeleteRunningOrder(cb) {
this._callbackOnDeleteRunningOrder = 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);
});
}
// onRequestRunningOrder: (cb: (runningOrderId: MosString128) => Promise<IMOSRunningOrder | null>) => void // get roReq, send roList
onRequestRunningOrder(cb) {
this._callbackOnRequestRunningOrder = 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;
getRunningOrder(runningOrderId) {
let message = new mosModel_1.ROReq(runningOrderId);
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message).then((data) => {
if (data.mos.roAck) {
reject(Parser_1.Parser.xml2ROAck(data.mos.roAck));
}
else if (data.mos.roList) {
let ro = Parser_1.Parser.xml2RO(data.mos.roList);
resolve(ro);
}
else {
reject('Unknown response');
}
})
.catch(reject);
}
else
throw new Error('Unknown response');
});
}
/**
* @deprecated getRunningOrder is deprecated, use sendRequestRunningOrder instead
*/
getRunningOrder(runningOrderId) {
return this.sendRequestRunningOrder(runningOrderId);
}
onMetadataReplace(cb) {
this._callbackOnMetadataReplace = cb;
}
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);
});
}
onRunningOrderStatus(cb) {

@@ -702,192 +754,104 @@ this._callbackOnRunningOrderStatus = cb;

}
/** @deprecated setRunningOrderStatus is deprecated, use sendRunningOrderStatus instead */
setRunningOrderStatus(status) {
return this.sendRunningOrderStatus(status);
let message = new mosModel_1.ROElementStat({
type: mosModel_1.ROElementStatType.RO,
roId: new mosString128_1.MosString128(status.ID),
status: status.Status
});
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message).then((data) => {
let roAck = Parser_1.Parser.xml2ROAck(data.mos.roAck);
resolve(roAck);
}).catch(reject);
}
});
}
/** @deprecated setStoryStatus is deprecated, use sendStoryStatus instead */
setStoryStatus(status) {
return this.sendStoryStatus(status);
let 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
});
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message).then((data) => {
let roAck = Parser_1.Parser.xml2ROAck(data.mos.roAck);
resolve(roAck);
}).catch(reject);
}
});
}
/** @deprecated setItemStatus is deprecated, use sendItemStatus instead */
setItemStatus(status) {
return this.sendItemStatus(status);
}
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);
let 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
});
}
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);
return new Promise((resolve, reject) => {
if (this._currentConnection) {
this.executeCommand(message).then((data) => {
let roAck = Parser_1.Parser.xml2ROAck(data.mos.roAck);
resolve(roAck);
}).catch(reject);
}
});
}
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);
});
}
onReadyToAir(cb) {
this._callbackOnReadyToAir = 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);
});
}
onROInsertStories(cb) {
this._callbackOnROInsertStories = 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);
});
}
onROInsertItems(cb) {
this._callbackOnROInsertItems = 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);
});
}
onROReplaceStories(cb) {
this._callbackOnROReplaceStories = 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);
});
}
onROReplaceItems(cb) {
this._callbackOnROReplaceItems = 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);
});
}
onROMoveStories(cb) {
this._callbackOnROMoveStories = 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);
});
}
onROMoveItems(cb) {
this._callbackOnROMoveItems = 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);
});
}
onRODeleteStories(cb) {
this._callbackOnRODeleteStories = 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);
});
}
onRODeleteItems(cb) {
this._callbackOnRODeleteItems = 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);
});
}
onROSwapStories(cb) {
this._callbackOnROSwapStories = 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);
});
}
onROSwapItems(cb) {
this._callbackOnROSwapItems = 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);
});
/* Profile 3 */
onMosObjCreate(cb) {
this._callbackOnMosObjCreate = cb;
}
// ============================================================================================================
// ========================== Profile 3 ===================================================================
// ============================================================================================================
onObjectCreate(cb) {
this._callbackOnObjectCreate = cb;
mosObjCreate(object) {
const message = new mosModel_1.MosObjCreate(object);
return this.executeCommand(message);
}
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);
});
onMosItemReplace(cb) {
this._callbackOnMosItemReplace = cb;
}
onItemReplace(cb) {
this._callbackOnItemReplace = cb;
mosItemReplace(options) {
const message = new mosModel_1.MosItemReplace(options);
return this.executeCommand(message);
}
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);
});
onMosReqSearchableSchema(cb) {
this._callbackOnMosReqSearchableSchema = cb;
}
onRequestSearchableSchema(cb) {
this._callbackOnRequestSearchableSchema = cb;
}
sendRequestSearchableSchema(username) {
mosRequestSearchableSchema(username) {
const message = new mosModel_1.MosReqSearchableSchema({ username });

@@ -898,6 +862,6 @@ return this.executeCommand(message).then(response => {

}
onRequestObjectList(cb) {
this._callbackOnRequestObjectList = cb;
onMosReqObjectList(cb) {
this._callbackOnMosReqObjList = cb;
}
sendRequestObjectList(reqObjList) {
mosRequestObjectList(reqObjList) {
const message = new mosModel_1.MosReqObjList(reqObjList);

@@ -911,83 +875,8 @@ return this.executeCommand(message).then(response => {

}
onRequestObjectActionNew(cb) {
this._callbackOnRequestObjectActionNew = cb;
onMosReqObjectAction(cb) {
this._callbackOnMosObjAction = cb;
}
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;
});
});
}
onRequestObjectActionUpdate(cb) {
this._callbackOnRequestObjectActionUpdate = cb;
}
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;
});
});
}
onRequestObjectActionDelete(cb) {
this._callbackOnRequestObjectActionDelete = cb;
}
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;
});
});
}
// Deprecated methods:
/** @deprecated onMosObjCreate is deprecated, use onObjectCreate instead */
onMosObjCreate(cb) {
return this.onObjectCreate(cb);
}
/** @deprecated mosObjCreate is deprecated, use sendObjectCreate instead */
mosObjCreate(object) {
return this.sendObjectCreate(object);
}
/** @deprecated onMosItemReplace is deprecated, use onItemReplace instead */
onMosItemReplace(cb) {
return this.onItemReplace(cb);
}
/** @deprecated mosItemReplace is deprecated, use sendItemReplace instead */
mosItemReplace(options) {
return this.sendItemReplace(options);
}
/** @deprecated onMosReqSearchableSchema is deprecated, use onRequestSearchableSchema instead */
onMosReqSearchableSchema(cb) {
return this.onRequestSearchableSchema(cb);
}
/** @deprecated mosRequestSearchableSchema is deprecated, use sendRequestSearchableSchema instead */
mosRequestSearchableSchema(username) {
return this.sendRequestSearchableSchema(username);
}
/** @deprecated onMosReqObjectList is deprecated, use onRequestObjectList instead */
onMosReqObjectList(cb) {
return this.onRequestObjectList(cb);
}
/** @deprecated mosRequestObjectList is deprecated, use sendRequestObjectList instead */
mosRequestObjectList(reqObjList) {
return this.sendRequestObjectList(reqObjList);
}
/** @deprecated onMosReqObjectAction is deprecated, use onRequestObjectAction*** instead */
onMosReqObjectAction(_cb) {
throw new Error('onMosReqObjectAction is deprecated, use onRequestObjectAction*** instead');
}
// ============================================================================================================
// ========================== Profile 4 ===================================================================
// ============================================================================================================
onRequestAllRunningOrders(cb) {
this._callbackOnRequestAllRunningOrders = cb;
}
sendRequestAllRunningOrders() {
const message = new mosModel_1.ROReqAll();
/* Profile 4 */
getAllRunningOrders() {
let message = new mosModel_1.ROReqAll();
return new Promise((resolve, reject) => {

@@ -1000,3 +889,3 @@ if (this._currentConnection) {

xmlRos = [xmlRos];
const ros = [];
let ros = [];
xmlRos.forEach((xmlRo) => {

@@ -1010,3 +899,3 @@ if (xmlRo) {

else {
console.error(data.mos);
console.log(data.mos);
reject('Unknown reply');

@@ -1018,97 +907,62 @@ }

}
onRunningOrderStory(cb) {
this._callbackOnRunningOrderStory = cb;
}
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);
});
}
// Deprecated methods:
/** @deprecated onROReqAll is deprecated use onRequestAllRunningOrders instead */
onROReqAll(cb) {
return this.onRequestAllRunningOrders(cb);
}
/** @deprecated getAllRunningOrders is deprecated use sendRequestAllRunningOrders instead */
getAllRunningOrders() {
return this.sendRequestAllRunningOrders();
}
/** @deprecated onROStory is deprecated use onRunningOrderStory instead */
onROStory(cb) {
return this.onRunningOrderStory(cb);
this._callbackOnROStory = cb;
}
/** @deprecated sendROStory is deprecated use sendRunningOrderStory instead */
sendROStory(story) {
return this.sendRunningOrderStory(story);
}
// =============================================================================================================
// ///////////////////////////////////// End of Profile methods \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
setDebug(debug) {
this._debug = debug;
}
checkProfileValidness() {
this._checkProfileValidness();
}
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) {
return this.switchConnectionsAndExecuteCommand(message);
if (this._currentConnection) {
if (this._debug)
console.log('exec command', message);
if (!this._currentConnection.connected) {
return this.switchConnections(message);
}
return this._currentConnection.executeCommand(message).then((res) => {
if (res.mos.roAck && res.mos.roAck.roStatus === 'Buddy server cannot respond because main server is available') {
return Promise.reject('Buddy server cannot respond because main server is available');
}
try {
const reply = yield this._currentConnection.executeCommand(message);
return this._ensureReply(reply);
return res;
}).catch((e) => {
if (this._debug)
console.log('errored', e);
if (this._primaryConnection && this._secondaryConnection && !resend) {
return this.switchConnections(message);
}
catch (e) {
this.debugTrace('errored', e);
if (this._primaryConnection && this._secondaryConnection && !resend) {
return this.switchConnectionsAndExecuteCommand(message);
}
else {
throw e;
}
else {
return Promise.reject(e);
}
}
else {
throw new Error(`Unable to send message due to no current connection`);
}
});
});
}
else {
return Promise.reject('No connection');
}
}
switchConnections() {
if (!this._currentConnection)
throw new Error('Unable to failover connection: No current connection');
if (!this._primaryConnection)
throw new Error('Unable to failover connection: No primary connection');
if (!this._secondaryConnection)
throw new Error('Unable to failover connection: No secondary connection');
this.debugTrace('switching connection');
let otherConnection = this._currentConnection === this._primaryConnection ? this._secondaryConnection : this._primaryConnection;
let currentConnection = this._currentConnection;
if (!otherConnection.connected)
throw new Error(`Unable to failover connection: Other connection is not connected (${otherConnection.host})`);
// Switch:
this._currentConnection = otherConnection;
otherConnection = currentConnection; // former current connection
otherConnection.handOverQueue(this._currentConnection);
}
switchConnectionsAndExecuteCommand(message) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
this.switchConnections();
this.debugTrace('resending msg');
try {
return yield this.executeCommand(message, true);
switchConnections(message) {
if (this._currentConnection && this._primaryConnection && this._secondaryConnection) {
if (this._debug)
console.log('switching connection');
this._currentConnection = this._currentConnection === this._primaryConnection ? this._secondaryConnection : this._primaryConnection;
if (!this._currentConnection.connected)
return Promise.reject('No connection available for failover');
let p;
if (message) {
if (this._debug)
console.log('resending msg');
p = 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.switchConnections(message);
}
// @ts-ignore - following line will always resolve if called from here
this.switchConnections().catch((e) => {
throw Error('e');
});
return Promise.reject(e);
});
}
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;
}
});
(this._currentConnection === this._primaryConnection ? this._secondaryConnection : this._primaryConnection).handOverQueue(this._currentConnection);
return p || Promise.resolve();
}
return Promise.reject('No connection available for failover');
}

@@ -1119,120 +973,4 @@ _emitConnectionChange() {

}
/** throws if there is an error */
_ensureReply(reply) {
if (!reply.mos)
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') {
throw new Error('Buddy server cannot respond because main server is available');
}
if (reply.mos.mosAck &&
reply.mos.mosAck.status === 'NACK') {
throw new Error(`Error in response: ${reply.mos.mosAck.statusDescription || 'No statusDescription given'}`);
}
return reply;
}
/** throws if something's wrong
*/
_checkProfileValidness() {
if (!this._strict)
return;
/** For MOS-devices: Require a callback to have been set */
const requireCallback = (profile, callbackName, method) => {
// @ts-ignore no index signature
if (!this[callbackName]) {
throw new Error(`Error: This MOS-device is configured to support Profile ${profile}, but callback ${method.name} has not been set!`);
}
};
/** Check: Requires that a callback has been set */
const requireMOSCallback = (profile, callbackName, method) => {
if (this.supportedProfiles.deviceType !== 'MOS')
return;
requireCallback(profile, callbackName, method);
};
// const requireNCSCallback = (profile: string, callbackName: string, method: Function) => {
// if (this.supportedProfiles.deviceType !== 'NCS') return
// requireCallback(profile, callbackName, method)
// }
/** Require another profile to have been set */
const requireProfile = (profile, requiredProfile) => {
// @ts-ignore no index signature
if (!this.supportedProfiles['profile' + requiredProfile]) {
throw new Error(`Error: This MOS-device is configured to support Profile ${profile}, therefore it must also support Profile ${requiredProfile}!`);
}
};
if (this.supportedProfiles.profile0) {
requireCallback('0', '_callbackOnRequestMachineInfo', this.onRequestMachineInfo);
// _callbackOnConnectionChange not required
}
if (this.supportedProfiles.profile1) {
requireProfile(1, 0);
requireMOSCallback('1', '_callbackOnRequestMOSOBject', this.onRequestMOSObject);
requireMOSCallback('1', '_callbackOnRequestAllMOSObjects', this.onRequestAllMOSObjects);
}
if (this.supportedProfiles.profile2) {
requireProfile(2, 0);
requireProfile(2, 1);
requireMOSCallback('2', '_callbackOnCreateRunningOrder', this.onCreateRunningOrder);
requireMOSCallback('2', '_callbackOnReplaceRunningOrder', this.onReplaceRunningOrder);
requireMOSCallback('2', '_callbackOnDeleteRunningOrder', this.onDeleteRunningOrder);
requireMOSCallback('2', '_callbackOnRequestRunningOrder', this.onRequestRunningOrder);
requireMOSCallback('2', '_callbackOnMetadataReplace', this.onMetadataReplace);
requireMOSCallback('2', '_callbackOnRunningOrderStatus', this.onRunningOrderStatus);
requireMOSCallback('2', '_callbackOnStoryStatus', this.onStoryStatus);
requireMOSCallback('2', '_callbackOnItemStatus', this.onItemStatus);
requireMOSCallback('2', '_callbackOnReadyToAir', this.onReadyToAir);
requireMOSCallback('2', '_callbackOnROInsertStories', this.onROInsertStories);
requireMOSCallback('2', '_callbackOnROInsertItems', this.onROInsertItems);
requireMOSCallback('2', '_callbackOnROReplaceStories', this.onROReplaceStories);
requireMOSCallback('2', '_callbackOnROReplaceItems', this.onROReplaceItems);
requireMOSCallback('2', '_callbackOnROMoveStories', this.onROMoveStories);
requireMOSCallback('2', '_callbackOnROMoveItems', this.onROMoveItems);
requireMOSCallback('2', '_callbackOnRODeleteStories', this.onRODeleteStories);
requireMOSCallback('2', '_callbackOnRODeleteItems', this.onRODeleteItems);
requireMOSCallback('2', '_callbackOnROSwapStories', this.onROSwapStories);
requireMOSCallback('2', '_callbackOnROSwapItems', this.onROSwapItems);
}
if (this.supportedProfiles.profile3) {
requireProfile(3, 0);
requireProfile(3, 1);
requireProfile(3, 2);
requireMOSCallback('3', '_callbackOnItemReplace', this.onItemReplace);
requireMOSCallback('3', '_callbackOnObjectCreate', this.onObjectCreate);
requireMOSCallback('3', '_callbackOnRequestObjectActionNew', this.onRequestObjectActionNew);
requireMOSCallback('3', '_callbackOnRequestObjectActionUpdate', this.onRequestObjectActionUpdate);
requireMOSCallback('3', '_callbackOnRequestObjectActionDelete', this.onRequestObjectActionDelete);
requireMOSCallback('3', '_callbackOnRequestObjectList', this.onRequestObjectList);
requireMOSCallback('3', '_callbackOnRequestSearchableSchema', this.onRequestSearchableSchema);
}
if (this.supportedProfiles.profile4) {
requireProfile(4, 0);
requireProfile(4, 1);
requireProfile(4, 2);
requireMOSCallback('4', '_callbackOnRequestAllRunningOrders', this.onRequestAllRunningOrders);
requireMOSCallback('4', '_callbackOnRunningOrderStory', this.onRunningOrderStory);
}
if (this.supportedProfiles.profile5) {
requireProfile(5, 0);
requireProfile(5, 1);
requireProfile(5, 2);
throw new Error('Erorr: Profile 5 is not currently implemented!');
}
if (this.supportedProfiles.profile6) {
requireProfile(6, 0);
requireProfile(6, 1);
requireProfile(6, 2);
throw new Error('Erorr: Profile 6 is not currently implemented!');
}
if (this.supportedProfiles.profile7) {
requireProfile(7, 0);
requireProfile(7, 1);
requireProfile(7, 2);
throw new Error('Erorr: Profile 7 is not currently implemented!');
}
}
debugTrace(...strs) {
if (this._debug)
console.log(...strs);
}
}
exports.MosDevice = MosDevice;
//# sourceMappingURL=MosDevice.js.map
import * as XMLBuilder from 'xmlbuilder';
export declare type PortType = 'upper' | 'lower' | 'query';
export declare abstract class MosMessage {

@@ -8,4 +7,3 @@ private static MAX_MESSAGE_ID;

ncsID: string;
port: PortType;
constructor(port: PortType);
port: string;
private _messageID;

@@ -16,7 +14,7 @@ private static getNewMessageID;

/** */
get messageID(): number;
readonly messageID: number;
/** */
toString(): string;
/** */
protected abstract get messageXMLBlocks(): XMLBuilder.XMLElement;
protected abstract readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosMessage = void 0;
const XMLBuilder = require("xmlbuilder");
const Utils_1 = require("../utils/Utils");
class MosMessage {
constructor(port) {
this.port = port;
}
static getNewMessageID() {

@@ -11,0 +7,0 @@ // increments and returns a signed 32-bit int counting from 1, resetting to 1 when wrapping

import * as XMLBuilder from 'xmlbuilder';
import { IMOSRunningOrder, IMOSROStory, IMOSItem, IMOSObjectPath, IMOSRunningOrderBase, IMOSObject, IMOSROFullStory, IMOSRequestObjectList, IMOSAck } from '../api';
import { IMOSRunningOrder, IMOSROStory, IMOSItem, IMOSObjectPath, IMOSRunningOrderBase, IMOSObject, IMOSROFullStory, IMOSROFullStoryBodyItem, IMosRequestObjectList, IMOSAck } from '../api';
import { IMOSExternalMetaData } from '../dataTypes/mosExternalMetaData';
import { MosString128 } from '../dataTypes/mosString128';
import { ROAck } from './profile2/ROAck';
import { ROAck } from './index';
export declare namespace Parser {

@@ -12,5 +12,8 @@ function xml2ROBase(xml: any): IMOSRunningOrderBase;

function xml2Story(xml: any): IMOSROStory;
function story2xml(story: IMOSROStory): XMLBuilder.XMLElement;
function xml2Items(xml: Array<any>): Array<IMOSItem>;
function xml2Item(xml: any): IMOSItem;
function xml2ObjPaths(xml: any): Array<IMOSObjectPath>;
function objPaths2xml(paths: Array<IMOSObjectPath>): XMLBuilder.XMLElement;
function item2xml(item: IMOSItem): XMLBuilder.XMLElement;
function xml2MetaData(xml: any): Array<IMOSExternalMetaData>;

@@ -23,3 +26,6 @@ function metaData2xml(md: IMOSExternalMetaData): XMLBuilder.XMLElement;

function xml2MosObj(xml: any): IMOSObject;
function xml2ReqObjList(xml: any): IMOSRequestObjectList;
function mosObj2xml(obj: IMOSObject): XMLBuilder.XMLElement;
function attachMosObj2xml(obj: IMOSObject, xml: XMLBuilder.XMLElement): void;
function xml2Body(xml: any): Array<IMOSROFullStoryBodyItem>;
function xml2ReqObjList(xml: any): IMosRequestObjectList;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parser = void 0;
const XMLBuilder = require("xmlbuilder");
const xmlConversion_1 = require("./profile2/xmlConversion");
const xmlConversion_2 = require("./profile4/xmlConversion");
const xmlConversion_3 = require("./profile0/xmlConversion");
const xmlConversion_4 = require("./profile1/xmlConversion");
const api_1 = require("../api");
const mosString128_1 = require("../dataTypes/mosString128");
const mosTime_1 = require("../dataTypes/mosTime");
const mosDuration_1 = require("../dataTypes/mosDuration");
const index_1 = require("./index");
const Utils_1 = require("../utils/Utils");
function isEmpty(obj) {
if (typeof obj === 'object') {
for (let prop in obj) {
if (obj.hasOwnProperty(prop)) {
return false;
}
}
return JSON.stringify(obj) === JSON.stringify({});
}
else {
return !obj;
}
}
var Parser;
(function (Parser) {
function xml2ROBase(xml) {
return xmlConversion_1.XMLRunningOrderBase.fromXML(xml);
let ro = {
ID: new mosString128_1.MosString128(xml.roID),
Slug: new mosString128_1.MosString128(xml.roSlug)
};
if (xml.hasOwnProperty('roEdStart') && !isEmpty(xml.roEdStart))
ro.EditorialStart = new mosTime_1.MosTime(xml.roEdStart);
if (xml.hasOwnProperty('roEdDur') && !isEmpty(xml.roEdDur))
ro.EditorialDuration = new mosDuration_1.MosDuration(xml.roEdDur);
if (xml.hasOwnProperty('roChannel') && !isEmpty(xml.roChannel))
ro.DefaultChannel = new mosString128_1.MosString128(xml.roChannel);
if (xml.hasOwnProperty('roTrigger') && !isEmpty(xml.roTrigger))
ro.Trigger = new mosString128_1.MosString128(xml.roTrigger);
if (xml.hasOwnProperty('macroIn') && !isEmpty(xml.macroIn))
ro.MacroIn = new mosString128_1.MosString128(xml.macroIn);
if (xml.hasOwnProperty('macroOut') && !isEmpty(xml.macroOut))
ro.MacroOut = new mosString128_1.MosString128(xml.macroOut);
if (xml.hasOwnProperty('mosExternalMetadata') && !isEmpty(xml.mosExternalMetadata)) {
// TODO: Handle an array of mosExternalMetadata
let meta = {
MosSchema: xml.mosExternalMetadata.mosSchema,
MosPayload: xml.mosExternalMetadata.mosPayload
};
if (xml.mosExternalMetadata.hasOwnProperty('mosScope'))
meta.MosScope = xml.mosExternalMetadata.mosScope;
ro.MosExternalMetaData = [meta];
}
return ro;
}
Parser.xml2ROBase = xml2ROBase;
function xml2RO(xml) {
return xmlConversion_1.XMLRunningOrder.fromXML(xml);
let stories = xml2Stories(xml.story);
let ro = xml2ROBase(xml);
ro.Stories = stories;
return ro;
}

@@ -24,36 +67,310 @@ Parser.xml2RO = xml2RO;

function xml2Stories(xml) {
return xmlConversion_1.XMLROStories.fromXML(xml);
if (!xml)
return [];
let xmlStories = xml;
if (!Array.isArray(xmlStories))
xmlStories = [xmlStories];
return xmlStories.map((xmlStory) => {
return xml2Story(xmlStory);
});
}
Parser.xml2Stories = xml2Stories;
function xml2FullStory(xml) {
return xmlConversion_2.XMLROFullStory.fromXML(xml);
let story0 = xml2Story(xml);
let story = {
ID: story0.ID,
Slug: story0.Slug,
Number: story0.Number,
MosExternalMetaData: story0.MosExternalMetaData,
RunningOrderId: new mosString128_1.MosString128(xml.roID),
Body: xml2Body(xml.storyBody)
};
return story;
}
Parser.xml2FullStory = xml2FullStory;
function xml2Story(xml) {
return xmlConversion_1.XMLROStory.fromXML(xml);
let 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: xml2MetaData(xml.mosExternalMetadata)
};
if (xml.hasOwnProperty('item'))
story.Items = story.Items.concat(xml2Items(xml.item));
if (xml.hasOwnProperty('storyBody') && xml.storyBody) {
// Note: the <storyBody> is sent in roStorySend
if (xml.storyBody.hasOwnProperty('storyItem')) {
story.Items = story.Items.concat(xml2Items(xml.storyBody.storyItem));
}
}
if (xml.hasOwnProperty('mosExternalMetadata'))
story.MosExternalMetaData = xml2MetaData(xml.mosExternalMetadata);
if (xml.hasOwnProperty('storyNum') && !isEmpty(xml.storyNum))
story.Number = new mosString128_1.MosString128(xml.storyNum || '');
return story;
}
Parser.xml2Story = xml2Story;
// export function story2xml (story: IMOSROStory): XMLBuilder.XMLElement {
// return ROStory.toXML(story)
// }
function story2xml(story) {
let xmlStory = XMLBuilder.create('story');
Utils_1.addTextElement(xmlStory, 'storyID', {}, story.ID);
// if (story.Slug) addTextElement(xmlStory, 'storySlug', {}, story.)
if (story.Slug)
Utils_1.addTextElement(xmlStory, 'storySlug', {}, story.Slug);
if (story.Number)
Utils_1.addTextElement(xmlStory, 'storyNum', {}, story.Number);
if (story.MosExternalMetaData) {
story.MosExternalMetaData.forEach((md) => {
let xmlMD = metaData2xml(md);
xmlStory.importDocument(xmlMD);
});
}
story.Items.forEach((item) => {
let xmlItem = item2xml(item);
xmlStory.importDocument(xmlItem);
});
return xmlStory;
}
Parser.story2xml = story2xml;
function xml2Items(xml) {
return xmlConversion_1.XMLMosItems.fromXML(xml);
if (!xml)
return [];
let xmlItems = xml;
if (!Array.isArray(xmlItems))
xmlItems = [xmlItems];
return xmlItems.map((xmlItem) => {
return xml2Item(xmlItem);
});
}
Parser.xml2Items = xml2Items;
function xml2Item(xml) {
return xmlConversion_1.XMLMosItem.fromXML(xml);
let 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,
};
if (xml.hasOwnProperty('itemSlug') && !isEmpty(xml.itemSlug))
item.Slug = new mosString128_1.MosString128(xml.itemSlug);
if (xml.hasOwnProperty('objPaths'))
item.Paths = xml2ObjPaths(xml.objPaths);
if (xml.hasOwnProperty('itemEdStart'))
item.EditorialStart = xml.itemEdStart;
if (xml.hasOwnProperty('itemEdDur'))
item.EditorialDuration = xml.itemEdDur;
if (xml.hasOwnProperty('itemUserTimingDur'))
item.UserTimingDuration = xml.itemUserTimingDur;
if (xml.hasOwnProperty('itemTrigger'))
item.Trigger = xml.itemTrigger;
if (xml.hasOwnProperty('mosExternalMetadata'))
item.MosExternalMetaData = xml2MetaData(xml.mosExternalMetadata);
if (xml.hasOwnProperty('mosAbstract'))
item.mosAbstract = xml.mosAbstract + '';
if (xml.hasOwnProperty('objSlug'))
item.ObjectSlug = new mosString128_1.MosString128(xml.objSlug);
if (xml.hasOwnProperty('itemChannel'))
item.Channel = new mosString128_1.MosString128(xml.itemChannel);
if (xml.hasOwnProperty('objDur'))
item.Duration = xml.objDur;
if (xml.hasOwnProperty('objTB'))
item.TimeBase = xml.objTB;
if (xml.hasOwnProperty('macroIn'))
item.MacroIn = new mosString128_1.MosString128(xml.macroIn);
if (xml.hasOwnProperty('macroOut'))
item.MacroOut = new mosString128_1.MosString128(xml.macroOut);
if (xml.hasOwnProperty('mosObj')) {
// Note: the <mosObj> is sent in roStorySend
item.MosObjects = xml2MosObjs(xml.mosObj);
}
return item;
}
Parser.xml2Item = xml2Item;
function xml2ObjPaths(xml) {
return xmlConversion_1.XMLObjectPaths.fromXML(xml);
if (!xml)
return [];
const getType = (xml) => {
let type = null;
if (xml.hasOwnProperty('objPath') || xml.$name === 'objPath') {
type = api_1.IMOSObjectPathType.PATH;
}
else if (xml.hasOwnProperty('objProxyPath') || xml.$name === 'objProxyPath') {
type = api_1.IMOSObjectPathType.PROXY_PATH;
}
else if (xml.hasOwnProperty('objMetadataPath') || xml.$name === 'objMetadataPath') {
type = api_1.IMOSObjectPathType.METADATA_PATH;
}
return type;
};
const getDescription = (xml) => {
return xml.techDescription || (xml.attributes ? xml.attributes.techDescription : '');
};
const getTarget = (xml) => {
return xml.text || xml.$t;
};
const getMosObjectPath = (element, key) => {
let type = getType(element);
if (!type && key) {
type = getType({ $name: key });
}
const target = getTarget(element);
const description = getDescription(element);
if (type && target) {
return {
Type: type,
Description: description,
Target: target
};
}
return undefined;
};
const xmlToArray = (obj) => {
let paths = [];
if (obj.hasOwnProperty('techDescription')) {
const mosObj = getMosObjectPath(obj);
if (mosObj) {
paths.push(mosObj);
}
}
else {
Object.keys(obj).forEach(key => {
const element = obj[key];
if (Array.isArray(element)) {
paths = paths.concat(xmlToArray(element));
}
else {
const mosObj = getMosObjectPath(element, key);
if (mosObj) {
paths.push(mosObj);
}
}
});
}
return paths;
};
const xmlPaths = xmlToArray(xml);
return xmlPaths;
}
Parser.xml2ObjPaths = xml2ObjPaths;
// export function objPaths2xml (paths: Array<IMOSObjectPath>): XMLBuilder.XMLElement {
// return ObjectPaths.toXML(xmlItem, paths)
// }
// export function item2xml (item: IMOSItem): XMLBuilder.XMLElement {
// MOSItem.toXML(xmlItem, item)
// }
function objPaths2xml(paths) {
let xmlObjPaths = XMLBuilder.create('objPaths');
paths.forEach((path) => {
if (path.Type === api_1.IMOSObjectPathType.PATH) {
Utils_1.addTextElement(xmlObjPaths, 'objPath', {
techDescription: path.Description
}, path.Target);
}
else if (path.Type === api_1.IMOSObjectPathType.PROXY_PATH) {
Utils_1.addTextElement(xmlObjPaths, 'objProxyPath', {
techDescription: path.Description
}, path.Target);
}
else if (path.Type === api_1.IMOSObjectPathType.METADATA_PATH) {
Utils_1.addTextElement(xmlObjPaths, 'objMetadataPath', {
techDescription: path.Description
}, path.Target);
}
});
return xmlObjPaths;
}
Parser.objPaths2xml = objPaths2xml;
function item2xml(item) {
let xmlItem = XMLBuilder.create('item');
Utils_1.addTextElement(xmlItem, 'itemID', {}, item.ID);
if (item.Slug)
Utils_1.addTextElement(xmlItem, 'itemSlug', {}, item.Slug);
Utils_1.addTextElement(xmlItem, 'objID', {}, item.ObjectID);
Utils_1.addTextElement(xmlItem, 'mosID', {}, item.MOSID);
if (item.mosAbstract)
Utils_1.addTextElement(xmlItem, 'mosAbstract', {}, item.mosAbstract);
if (item.Paths) {
let xmlObjPaths = objPaths2xml(item.Paths);
xmlItem.importDocument(xmlObjPaths);
}
// objPaths?
// objPath*
// objProxyPath*
// objMetadataPath*
if (item.Channel)
Utils_1.addTextElement(xmlItem, 'itemChannel', {}, item.Channel);
if (item.EditorialStart !== undefined)
Utils_1.addTextElement(xmlItem, 'itemEdStart', {}, item.EditorialStart);
if (item.EditorialDuration !== undefined)
Utils_1.addTextElement(xmlItem, 'itemEdDur', {}, item.EditorialDuration);
if (item.UserTimingDuration !== undefined) {
Utils_1.addTextElement(xmlItem, 'itemUserTimingDur', {}, item.UserTimingDuration);
}
if (item.Trigger)
Utils_1.addTextElement(xmlItem, 'itemTrigger', {}, item.Trigger);
if (item.MacroIn)
Utils_1.addTextElement(xmlItem, 'macroIn', {}, item.MacroIn);
if (item.MacroOut)
Utils_1.addTextElement(xmlItem, 'macroOut', {}, item.MacroOut);
if (item.MacroOut)
Utils_1.addTextElement(xmlItem, 'mosExternalMetadata', {}, item.MacroOut);
if (item.MosExternalMetaData) {
item.MosExternalMetaData.forEach((md) => {
let xmlMetaData = metaData2xml(md);
xmlItem.importDocument(xmlMetaData);
});
}
return xmlItem;
}
Parser.item2xml = item2xml;
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 (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 xml2MetaData(xml) {
return xmlConversion_1.XMLMosExternalMetaData.fromXML(xml);
if (!xml)
return [];
let xmlMetadata = xml;
if (!Array.isArray(xml))
xmlMetadata = [xmlMetadata];
return xmlMetadata.map((xmlmd) => {
let md = {
MosScope: (xmlmd.hasOwnProperty('mosScope') ? xmlmd.mosScope : null),
MosSchema: xmlmd.mosSchema + '',
MosPayload: fixPayload(xmlmd.mosPayload)
};
return md;
});
}

@@ -73,29 +390,221 @@ Parser.xml2MetaData = xml2MetaData;

function xml2IDs(xml) {
return xmlConversion_3.XMLMosIDs.fromXML(xml);
let arr = [];
let xmlIds = xml;
if (!Array.isArray(xmlIds))
xmlIds = [xmlIds];
xmlIds.forEach((id) => {
arr.push(new mosString128_1.MosString128(id));
});
return arr;
}
Parser.xml2IDs = xml2IDs;
function xml2ROAck(xml) {
return xmlConversion_1.XMLMosROAck.fromXML(xml);
let roAck = new index_1.ROAck();
roAck.ID = new mosString128_1.MosString128(xml.roID);
roAck.Status = new mosString128_1.MosString128(xml.roStatus);
let xmlStoryIDs = xml.storyID;
let xmlItemIDs = xml.itemID;
let xmlObjIDs = xml.objID;
let xmlStatuses = xml.status;
if (!Array.isArray(xmlStoryIDs))
xmlStoryIDs = [xmlStoryIDs];
if (!Array.isArray(xmlItemIDs))
xmlItemIDs = [xmlItemIDs];
if (!Array.isArray(xmlObjIDs))
xmlObjIDs = [xmlObjIDs];
if (!Array.isArray(xmlStatuses))
xmlStatuses = [xmlStatuses];
roAck.Stories = [];
let iMax = Math.max(xmlStoryIDs.length, xmlItemIDs.length, xmlObjIDs.length, xmlStatuses.length);
let story = null;
let item = null;
let object = null;
for (let i = 0; i < iMax; i++) {
if (xmlStoryIDs[i]) {
story = {
ID: new mosString128_1.MosString128(xmlStoryIDs[i]),
Items: []
};
roAck.Stories.push(story);
}
if (xmlItemIDs[i]) {
item = {
ID: new mosString128_1.MosString128(xmlStoryIDs[i]),
Channel: new mosString128_1.MosString128(''),
Objects: []
};
if (story)
story.Items.push(item);
}
if (xmlObjIDs[i] && xmlStatuses[i]) {
object = {
Status: xmlStatuses[i]
};
if (item)
item.Objects.push(object);
}
}
return roAck;
}
Parser.xml2ROAck = xml2ROAck;
function xml2Ack(xml) {
return xmlConversion_4.XMLMosAck.fromXML(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) {
return xmlConversion_4.XMLMosObjects.fromXML(xml);
if (!xml)
return [];
let xmlObjs = [];
xmlObjs = xml;
if (!Array.isArray(xmlObjs))
xmlObjs = [xmlObjs];
return xmlObjs.map((xmlObj) => {
return xml2MosObj(xmlObj);
});
}
Parser.xml2MosObjs = xml2MosObjs;
function xml2MosObj(xml) {
return xmlConversion_4.XMLMosObject.fromXML(xml);
let mosObj = {
ID: new mosString128_1.MosString128(xml.objID),
Slug: new mosString128_1.MosString128(xml.objSlug),
MosAbstract: xml.mosAbstract,
Group: xml.objGroup,
Type: xml.objType,
TimeBase: xml.objTB,
Revision: xml.objRev,
Duration: xml.objDur,
Status: xml.status,
AirStatus: xml.objAir,
Paths: xml2ObjPaths(xml.objPaths),
CreatedBy: new mosString128_1.MosString128(xml.createdBy),
Created: new mosTime_1.MosTime(xml.created),
ChangedBy: new mosString128_1.MosString128(xml.changedBy),
Changed: new mosTime_1.MosTime(xml.changed),
Description: xml.description
};
if (xml.hasOwnProperty('mosExternalMetadata'))
mosObj.MosExternalMetaData = xml2MetaData(xml.mosExternalMetadata);
if (xml.hasOwnProperty('mosItemEditorProgID'))
mosObj.MosItemEditorProgID = new mosString128_1.MosString128(xml.mosItemEditorProgID);
return mosObj;
}
Parser.xml2MosObj = xml2MosObj;
// export function mosObj2xml (obj: IMOSObject): XMLBuilder.XMLElement {
// let xml = XMLBuilder.create('mosObj')
// MOSObject.toXML(xml, obj)
// // Todo: metadata:
// return xml
// }
function mosObj2xml(obj) {
let xml = XMLBuilder.create('mosObj');
attachMosObj2xml(obj, xml);
// Todo: metadata:
return xml;
}
Parser.mosObj2xml = mosObj2xml;
function attachMosObj2xml(obj, xml) {
if (obj.ID)
Utils_1.addTextElement(xml, 'objID', {}, obj.ID);
Utils_1.addTextElement(xml, 'objSlug', {}, obj.Slug);
if (obj.MosAbstract)
Utils_1.addTextElement(xml, 'mosAbstract', {}, obj.MosAbstract);
if (obj.Group)
Utils_1.addTextElement(xml, 'objGroup', {}, obj.Group);
Utils_1.addTextElement(xml, 'objType', {}, obj.Type);
Utils_1.addTextElement(xml, 'objTB', {}, obj.TimeBase);
Utils_1.addTextElement(xml, 'objRev', {}, obj.Revision);
Utils_1.addTextElement(xml, 'objDur', {}, obj.Duration);
Utils_1.addTextElement(xml, 'status', {}, obj.Status);
Utils_1.addTextElement(xml, 'objAir', {}, obj.AirStatus);
if (obj.Paths) {
let xmlObjPaths = objPaths2xml(obj.Paths);
xml.importDocument(xmlObjPaths);
}
Utils_1.addTextElement(xml, 'createdBy', {}, obj.CreatedBy);
Utils_1.addTextElement(xml, 'created', {}, obj.Created);
if (obj.ChangedBy)
Utils_1.addTextElement(xml, 'changedBy', {}, obj.ChangedBy);
if (obj.Changed)
Utils_1.addTextElement(xml, 'changed', {}, obj.Changed);
if (obj.Description)
Utils_1.addTextElement(xml, 'description', {}, obj.Description);
if (obj.MosExternalMetaData) {
obj.MosExternalMetaData.forEach((md) => {
let xmlMetaData = metaData2xml(md);
xml.importDocument(xmlMetaData);
});
}
}
Parser.attachMosObj2xml = attachMosObj2xml;
function xml2Body(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]
if (!Array.isArray(d)) d = [d]
d.forEach((el: any) => {
let bodyItem: IMOSROFullStoryBodyItem = {
Type: key,
Content: el
}
body.push(bodyItem)
})
})
console.log('xml2Body', body)
*/
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 = xml2Item(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;
}
Parser.xml2Body = xml2Body;
function xml2ReqObjList(xml) {
return xmlConversion_4.XMLMosRequestObjectList.fromXML(xml);
const list = {
username: xml.username,
queryID: xml.queryID,
listReturnStart: xml.listReturnStart,
listReturnEnd: xml.listReturnEnd,
generalSearch: xml.generalSearch,
mosSchema: xml.mosSchema,
searchGroups: []
};
if (typeof list.listReturnStart === 'object')
list.listReturnStart = null;
if (typeof list.listReturnEnd === 'object')
list.listReturnEnd = null;
for (const searchGroup of xml.searchGroup) {
const i = list.searchGroups.push({ searchFields: searchGroup.searchField });
for (const searchField of list.searchGroups[i - 1].searchFields) {
if (searchField.sortByOrder)
searchField.sortByOrder = parseInt(searchField.sortByOrder + '', 10);
}
}
return list;
}

@@ -102,0 +611,0 @@ Parser.xml2ReqObjList = xml2ReqObjList;

import * as XMLBuilder from 'xmlbuilder';
import { MosTime } from '../../dataTypes/mosTime';
import { MosMessage, PortType } from '../MosMessage';
import { MosMessage } from '../MosMessage';
export declare class HeartBeat extends MosMessage {
time: MosTime;
/** */
constructor(port: PortType, time?: MosTime);
constructor(time?: MosTime);
/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HeartBeat = void 0;
const XMLBuilder = require("xmlbuilder");

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

/** */
constructor(port, time = new mosTime_1.MosTime()) {
super(port);
constructor(time = new mosTime_1.MosTime()) {
super();
this.time = time;

@@ -17,5 +16,4 @@ }

get messageXMLBlocks() {
const heartbeat = XMLBuilder.create('heartbeat');
Utils_1.addTextElement(heartbeat, 'time', this.time);
return heartbeat;
let messageBlock = Utils_1.addTextElement(XMLBuilder.create('heartbeat'), 'time', {}, this.time);
return messageBlock;
}

@@ -22,0 +20,0 @@ }

@@ -12,25 +12,22 @@ import { MosTime } from '../../dataTypes/mosTime';

}
export interface IMOSDefaultActiveX {
mode: IMOSListMachInfoDefaultActiveXMode;
controlFileLocation: string;
controlSlug: MosString128;
controlName: string;
controlDefaultParams: string;
}
export interface IMOSListMachInfo {
/** Used in MOS ActiveX messages. Manufacturer: Text description. 128 chars max. */
manufacturer: MosString128;
/** Model: Text description. 128 chars max. */
model: MosString128;
/** HW Revision: 128 chars max. */
hwRev: MosString128;
/** Software Revision: (MOS) Text description. 128 chars max., example: '2.1.0.37' */
swRev: MosString128;
/** Date of Manufacture. */
DOM: MosTime;
/** Serial Number: text serial number. 128 chars max. ex: '927748927' */
SN: MosString128;
/** Identification of a Machine: text. 128 chars max. */
ID: MosString128;
/** Time: Time object changed status. Format is YYYY-MM-DD'T'hh:mm:ss[,ddd]['Z'] */
time: MosTime;
/** Operational Time: date and time of last machine start. Format is YYYY-MM-DD'T'hh:mm:ss[,ddd]['Z'] */
opTime?: MosTime;
/** MOS Revision: Text description. 128 chars max. */
mosRev: MosString128;
supportedProfiles: {
deviceType: 'NCS' | 'MOS';
deviceType: string;
profile0?: boolean;

@@ -45,24 +42,11 @@ profile1?: boolean;

};
/** defaultActiveX contains tags that describe the correct settings for the ActiveX control (NOTE: no two <defaultActivX> elements can have the same <mode> value). */
defaultActiveX?: Array<IMOSDefaultActiveX>;
mosExternalMetaData?: Array<IMOSExternalMetaData>;
}
export interface IMOSDefaultActiveX {
/** Used in MOS ActiveX messages. How the ActiveX Plug-In window appears in the NCS Host window: MODALDIALOG, MODELESS, CONTAINED, TOOLBAR. */
mode: IMOSListMachInfoDefaultActiveXMode;
/** controlFileLocation is the file location for the default ActiveX control. */
controlFileLocation: string;
/** Defined by MOS 128 characters max */
controlSlug: MosString128;
/** This value represents the key/classid key used to load the ActiveX from the registry., ex: "contained.containedCTRL.1" */
controlName: string;
/** This value represents the parameters that can be passed to an ActiveX. ex "URL=http:" */
controlDefaultParams: string;
}
export declare class ListMachineInfo extends MosMessage {
info: IMOSListMachInfo;
/** */
constructor(info: IMOSListMachInfo, port: 'upper' | 'lower');
constructor(info: IMOSListMachInfo);
/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ListMachineInfo = exports.IMOSListMachInfoDefaultActiveXMode = void 0;
const MosMessage_1 = require("../MosMessage");

@@ -16,4 +15,4 @@ const XMLBuilder = require("xmlbuilder");

/** */
constructor(info, port) {
super(port);
constructor(info) {
super();
this.info = info;

@@ -23,23 +22,19 @@ }

get messageXMLBlocks() {
let xmlListMachInfo = XMLBuilder.create('listMachInfo');
Utils_1.addTextElement(xmlListMachInfo, 'manufacturer', this.info.manufacturer);
Utils_1.addTextElement(xmlListMachInfo, 'model', this.info.model);
Utils_1.addTextElement(xmlListMachInfo, 'hwRev', this.info.hwRev);
Utils_1.addTextElement(xmlListMachInfo, 'swRev', this.info.swRev);
Utils_1.addTextElement(xmlListMachInfo, 'DOM', this.info.DOM);
Utils_1.addTextElement(xmlListMachInfo, 'SN', this.info.SN);
Utils_1.addTextElement(xmlListMachInfo, 'ID', this.info.ID);
Utils_1.addTextElement(xmlListMachInfo, 'time', this.info.time);
let root = XMLBuilder.create('listMachInfo');
Utils_1.addTextElement(root, 'manufacturer', this.info.manufacturer);
Utils_1.addTextElement(root, 'model', this.info.model);
Utils_1.addTextElement(root, 'hwRev', this.info.hwRev);
Utils_1.addTextElement(root, 'swRev', this.info.swRev);
Utils_1.addTextElement(root, 'DOM', this.info.DOM);
Utils_1.addTextElement(root, 'SN', this.info.SN);
Utils_1.addTextElement(root, 'ID', this.info.ID);
Utils_1.addTextElement(root, 'time', this.info.time);
if (this.info.opTime)
Utils_1.addTextElement(xmlListMachInfo, 'opTime', this.info.opTime);
Utils_1.addTextElement(xmlListMachInfo, 'mosRev', this.info.mosRev);
// TODO: the supportedProfiles should be changed to an Array
const xmlSupportedProfiles = XMLBuilder.create('supportedProfiles');
xmlSupportedProfiles.att('deviceType', this.info.supportedProfiles.deviceType);
// let p = addTextElement(root, 'supportedProfiles').att('deviceType', this.info.supportedProfiles.deviceType)
Utils_1.addTextElement(root, 'opTime', this.info.opTime);
Utils_1.addTextElement(root, 'mosRev', this.info.mosRev);
let p = Utils_1.addTextElement(root, 'supportedProfiles').att('deviceType', this.info.supportedProfiles.deviceType);
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(p, 'mosProfile', (this.info.supportedProfiles['profile' + i] ? 'YES' : 'NO')).att('number', i);
}
xmlListMachInfo.importDocument(xmlSupportedProfiles);
return xmlListMachInfo;
return root;
}

@@ -46,0 +41,0 @@ }

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReqMachInfo = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -9,3 +8,4 @@ const MosMessage_1 = require("../MosMessage");

constructor() {
super('lower');
super();
this.port = 'lower';
}

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

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

/** */
constructor(ack?: IMOSAck);
constructor();
/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MOSAck = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -10,9 +9,4 @@ const MosMessage_1 = require("../MosMessage");

/** */
constructor(ack) {
super('lower');
if (ack) {
this.ID = ack.ID;
this.Status = ack.Status;
this.Description = ack.Description;
}
constructor() {
super();
}

@@ -22,6 +16,6 @@ /** */

let root = XMLBuilder.create('mosAck');
Utils_1.addTextElement(root, 'objID', this.ID);
Utils_1.addTextElement(root, 'objRev', this.Revision);
Utils_1.addTextElement(root, 'status', api_1.IMOSAckStatus[this.Status]);
Utils_1.addTextElement(root, 'statusDescription', this.Description);
Utils_1.addTextElement(root, 'objID', {}, this.ID);
Utils_1.addTextElement(root, 'objRev', {}, this.Revision);
Utils_1.addTextElement(root, 'status', {}, api_1.IMOSAckStatus[this.Status]);
Utils_1.addTextElement(root, 'statusDescription', {}, this.Description);
return root;

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

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosListAll = void 0;
const MosMessage_1 = require("../MosMessage");
const XMLBuilder = require("xmlbuilder");
const xmlConversion_1 = require("../profile1/xmlConversion");
const Parser_1 = require("../Parser");
class MosListAll extends MosMessage_1.MosMessage {
/** */
constructor(objs) {
super('lower');
super();
this.objs = objs;

@@ -17,5 +16,3 @@ }

this.objs.forEach((obj) => {
let xmlMosObj = XMLBuilder.create('mosObj');
xmlConversion_1.XMLMosObject.toXML(xmlMosObj, obj);
root.importDocument(xmlMosObj);
root.importDocument(Parser_1.Parser.mosObj2xml(obj));
});

@@ -22,0 +19,0 @@ return root;

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosObj = void 0;
const MosMessage_1 = require("../MosMessage");
const XMLBuilder = require("xmlbuilder");
const xmlConversion_1 = require("./xmlConversion");
const Parser_1 = require("../Parser");
class MosObj extends MosMessage_1.MosMessage {
/** */
constructor(obj) {
super('lower');
super();
this.obj = obj;
this.port = 'lower';
}
/** */
get messageXMLBlocks() {
let xmlMosObj = XMLBuilder.create('mosObj');
xmlConversion_1.XMLMosObject.toXML(xmlMosObj, this.obj);
return xmlMosObj;
return Parser_1.Parser.mosObj2xml(this.obj);
}

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

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReqMosObj = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -10,3 +9,4 @@ const MosMessage_1 = require("../MosMessage");

constructor(objId) {
super('lower');
super();
this.port = 'lower';
this.objId = objId;

@@ -17,3 +17,3 @@ }

let root = XMLBuilder.create('mosReqObj');
Utils_1.addTextElement(root, 'objID', this.objId);
Utils_1.addTextElement(root, 'objID', {}, this.objId);
return root;

@@ -20,0 +20,0 @@ }

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReqMosObjAll = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -10,4 +9,5 @@ const MosMessage_1 = require("../MosMessage");

constructor(pause = 0) {
super('lower');
super();
this.pause = pause;
this.port = 'lower';
}

@@ -17,3 +17,3 @@ /** */

let root = XMLBuilder.create('mosReqAll');
Utils_1.addTextElement(root, 'pause', this.pause + '');
Utils_1.addTextElement(root, 'pause', {}, this.pause + '');
return root;

@@ -20,0 +20,0 @@ }

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

/** */
constructor(roAck?: IMOSROAck);
constructor();
/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ROAck = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -9,9 +8,4 @@ const MosMessage_1 = require("../MosMessage");

/** */
constructor(roAck) {
super('upper');
if (roAck) {
this.ID = roAck.ID;
this.Status = roAck.Status;
this.Stories = roAck.Stories;
}
constructor() {
super();
}

@@ -21,4 +15,4 @@ /** */

let root = XMLBuilder.create('roAck');
Utils_1.addTextElement(root, 'roID', this.ID);
Utils_1.addTextElement(root, 'roStatus', this.Status);
Utils_1.addTextElement(root, 'roID', {}, this.ID);
Utils_1.addTextElement(root, 'roStatus', {}, this.Status);
// TODO: Loop over Stories, Items and Object

@@ -25,0 +19,0 @@ return root;

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ROElementStat = exports.ROElementStatType = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -17,5 +16,6 @@ const MosMessage_1 = require("../MosMessage");

constructor(options) {
super('upper');
super();
this.options = options;
this.time = new mosTime_1.MosTime();
this.port = 'upper';
}

@@ -26,13 +26,13 @@ /** */

root.attribute('element', this.options.type.toString());
Utils_1.addTextElement(root, 'roID', this.options.roId);
Utils_1.addTextElement(root, 'roID', {}, this.options.roId);
if (this.options.storyId)
Utils_1.addTextElement(root, 'storyID', this.options.storyId);
Utils_1.addTextElement(root, 'storyID', {}, this.options.storyId);
if (this.options.itemId)
Utils_1.addTextElement(root, 'itemID', this.options.itemId);
Utils_1.addTextElement(root, 'itemID', {}, this.options.itemId);
if (this.options.objId)
Utils_1.addTextElement(root, 'objID', this.options.objId);
Utils_1.addTextElement(root, 'objID', {}, this.options.objId);
if (this.options.itemChannel)
Utils_1.addTextElement(root, 'itemChannel', this.options.itemChannel);
Utils_1.addTextElement(root, 'status', this.options.status);
Utils_1.addTextElement(root, 'time', this.time);
Utils_1.addTextElement(root, 'itemChannel', {}, this.options.itemChannel);
Utils_1.addTextElement(root, 'status', {}, this.options.status);
Utils_1.addTextElement(root, 'time', {}, this.time);
return root;

@@ -39,0 +39,0 @@ }

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ROList = void 0;
const XMLBuilder = require("xmlbuilder");
const MosMessage_1 = require("../MosMessage");
const Parser_1 = require("../Parser");
const Utils_1 = require("../../utils/Utils");
const xmlConversion_1 = require("./xmlConversion");
class ROList extends MosMessage_1.MosMessage {
/** */
constructor() {
super('upper');
super();
}

@@ -16,6 +15,7 @@ /** */

let root = XMLBuilder.create('roList');
Utils_1.addTextElement(root, 'roID', this.RO.ID);
Utils_1.addTextElement(root, 'roSlug', this.RO.Slug);
Utils_1.addTextElement(root, 'roID', {}, this.RO.ID);
Utils_1.addTextElement(root, 'roSlug', {}, this.RO.Slug);
this.RO.Stories.forEach((story) => {
xmlConversion_1.XMLROStory.toXML(root, story);
let xmlStory = Parser_1.Parser.story2xml(story);
root.importDocument(xmlStory);
});

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

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ROReq = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -10,3 +9,4 @@ const MosMessage_1 = require("../MosMessage");

constructor(roId) {
super('upper');
super();
this.port = 'upper';
this.roId = roId;

@@ -17,3 +17,3 @@ }

let root = XMLBuilder.create('roReq');
Utils_1.addTextElement(root, 'roID', this.roId);
Utils_1.addTextElement(root, 'roID', {}, this.roId);
return root;

@@ -20,0 +20,0 @@ }

@@ -13,3 +13,3 @@ import { IMOSItem } from '../../api';

constructor(options: MosItemReplaceOptions);
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosItemReplace = void 0;
const MosMessage_1 = require("../MosMessage");
const XMLBuilder = require("xmlbuilder");
const Parser_1 = require("../Parser");
const Utils_1 = require("../../utils/Utils");
const xmlConversion_1 = require("../profile2/xmlConversion");
class MosItemReplace extends MosMessage_1.MosMessage {
constructor(options) {
super('upper');
super();
this.options = options;
this.port = 'upper';
}

@@ -16,5 +16,5 @@ get messageXMLBlocks() {

const root = XMLBuilder.create('mosItemReplace');
Utils_1.addTextElement(root, 'roID', this.options.roID);
Utils_1.addTextElement(root, 'storyID', this.options.storyID);
xmlConversion_1.XMLMosItem.toXML(root, item);
Utils_1.addTextElement(root, 'roID', {}, this.options.roID);
Utils_1.addTextElement(root, 'storyID', {}, this.options.storyID);
root.importDocument(Parser_1.Parser.item2xml(item));
return root;

@@ -21,0 +21,0 @@ }

import { MosMessage } from '../MosMessage';
import * as XMLBuilder from 'xmlbuilder';
import { IMOSListSearchableSchema } from '../../api';
import { IMOSSearchableSchema } from '../../api';
export declare class MosListSearchableSchema extends MosMessage {
private options;
constructor(options: IMOSListSearchableSchema);
get messageXMLBlocks(): XMLBuilder.XMLElement;
constructor(options: IMOSSearchableSchema);
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosListSearchableSchema = void 0;
const MosMessage_1 = require("../MosMessage");

@@ -9,4 +8,5 @@ const XMLBuilder = require("xmlbuilder");

constructor(options) {
super('query');
super();
this.options = options;
this.port = 'query';
}

@@ -16,3 +16,3 @@ get messageXMLBlocks() {

xml.att('username', this.options.username);
Utils_1.addTextElement(xml, 'mosSchema', this.options.mosSchema);
Utils_1.addTextElement(xml, 'mosSchema', {}, this.options.mosSchema);
return xml;

@@ -19,0 +19,0 @@ }

@@ -7,3 +7,3 @@ import { IMOSObject } from '../../api';

constructor(object: IMOSObject);
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosObjCreate = void 0;
const MosMessage_1 = require("../MosMessage");
const XMLBuilder = require("xmlbuilder");
const xmlConversion_1 = require("../profile1/xmlConversion");
// http://mosprotocol.com/wp-content/MOS-Protocol-Documents/MOS-Protocol-2.8.4-Current.htm#mosObjCreate
const Parser_1 = require("../Parser");
class MosObjCreate extends MosMessage_1.MosMessage {
constructor(object) {
super('lower');
super();
this.object = object;
this.port = 'lower';
}
get messageXMLBlocks() {
let xml = XMLBuilder.create('mosObjCreate');
xmlConversion_1.XMLMosObject.toXML(xml, this.object);
Parser_1.Parser.attachMosObj2xml(this.object, xml);
return xml;

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

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

import { IMOSObjectList } from '../../api';
import { IMosObjectList } from '../../api';
import { MosMessage } from '../MosMessage';

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

private options;
constructor(options: IMOSObjectList);
get messageXMLBlocks(): XMLBuilder.XMLElement;
constructor(options: IMosObjectList);
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosObjList = void 0;
const MosMessage_1 = require("../MosMessage");
const XMLBuilder = require("xmlbuilder");
const Parser_1 = require("../Parser");
const Utils_1 = require("../../utils/Utils");
const xmlConversion_1 = require("../profile1/xmlConversion");
class MosObjList extends MosMessage_1.MosMessage {
constructor(options) {
super('upper');
super();
this.options = options;
this.port = 'upper';
}
get messageXMLBlocks() {
const xmlMosObjList = XMLBuilder.create('mosObjList');
xmlMosObjList.att('username', this.options.username);
Utils_1.addTextElement(xmlMosObjList, 'queryID', this.options.queryID);
Utils_1.addTextElement(xmlMosObjList, 'listReturnStart', this.options.listReturnStart);
Utils_1.addTextElement(xmlMosObjList, 'listReturnEnd', this.options.listReturnEnd);
Utils_1.addTextElement(xmlMosObjList, 'listReturnTotal', this.options.listReturnTotal);
const xml = XMLBuilder.create('mosObjList');
xml.att('username', this.options.username);
Utils_1.addTextElement(xml, 'queryID', {}, this.options.queryID);
Utils_1.addTextElement(xml, 'listReturnStart', {}, this.options.listReturnStart);
Utils_1.addTextElement(xml, 'listReturnEnd', {}, this.options.listReturnEnd);
Utils_1.addTextElement(xml, 'listReturnTotal', {}, this.options.listReturnTotal);
if (this.options.listReturnStatus)
Utils_1.addTextElement(xmlMosObjList, 'listReturnStatus', this.options.listReturnStatus);
Utils_1.addTextElement(xml, 'listReturnStatus', {}, this.options.listReturnStatus);
if (this.options.list) {
const xmlList = XMLBuilder.create('list');
xmlConversion_1.XMLMosObjects.toXML(xmlList, this.options.list);
xmlMosObjList.importDocument(xmlList);
const listEl = Utils_1.addTextElement(xml, 'list');
for (const object of this.options.list) {
listEl.importDocument(Parser_1.Parser.mosObj2xml(object));
}
}
return xmlMosObjList;
return xml;
}

@@ -29,0 +30,0 @@ }

import { IMOSObject } from '../../api';
import { MosMessage } from '../MosMessage';
import * as XMLBuilder from 'xmlbuilder';
import { MosString128 } from '../../dataTypes/mosString128';
export interface MosReqObjActionOptionsNew {
export interface MosReqObjActionOptions {
object: IMOSObject;
action: 'NEW' | 'UPDATE' | 'DELETE';
}
export declare class MosReqObjActionNew extends MosMessage {
export declare class MosReqObjAction extends MosMessage {
private options;
constructor(options: MosReqObjActionOptionsNew);
get messageXMLBlocks(): XMLBuilder.XMLElement;
constructor(options: MosReqObjActionOptions);
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
export interface MosReqObjActionOptionsUpdate {
object: IMOSObject;
objectId: MosString128;
}
export declare class MosReqObjActionUpdate extends MosMessage {
private options;
constructor(options: MosReqObjActionOptionsUpdate);
get messageXMLBlocks(): XMLBuilder.XMLElement;
}
export interface MosReqObjActionOptionsDelete {
objectId: MosString128;
}
export declare class MosReqObjActionDelete extends MosMessage {
private options;
constructor(options: MosReqObjActionOptionsDelete);
get messageXMLBlocks(): XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosReqObjActionDelete = exports.MosReqObjActionUpdate = exports.MosReqObjActionNew = void 0;
const MosMessage_1 = require("../MosMessage");
const XMLBuilder = require("xmlbuilder");
const xmlConversion_1 = require("../profile1/xmlConversion");
class MosReqObjActionNew extends MosMessage_1.MosMessage {
const Parser_1 = require("../Parser");
class MosReqObjAction extends MosMessage_1.MosMessage {
constructor(options) {
super('lower');
super();
this.options = options;
this.port = 'lower';
}
get messageXMLBlocks() {
const xml = XMLBuilder.create('mosReqObjAction');
xml.att('operation', 'NEW');
xmlConversion_1.XMLMosObject.toXML(xml, this.options.object);
xml.att('operation', this.options.action);
if (this.options.action !== 'NEW')
xml.att('objID', this.options.object.ID);
Parser_1.Parser.attachMosObj2xml(this.options.object, xml);
return xml;
}
}
exports.MosReqObjActionNew = MosReqObjActionNew;
class MosReqObjActionUpdate extends MosMessage_1.MosMessage {
constructor(options) {
super('lower');
this.options = options;
}
get messageXMLBlocks() {
const xml = XMLBuilder.create('mosReqObjAction');
xml.att('operation', 'UPDATE');
xml.att('objID', this.options.objectId);
xmlConversion_1.XMLMosObject.toXML(xml, this.options.object);
return xml;
}
}
exports.MosReqObjActionUpdate = MosReqObjActionUpdate;
class MosReqObjActionDelete extends MosMessage_1.MosMessage {
constructor(options) {
super('lower');
this.options = options;
}
get messageXMLBlocks() {
const xml = XMLBuilder.create('mosReqObjAction');
xml.att('operation', 'DELETE');
xml.att('objID', this.options.objectId);
return xml;
}
}
exports.MosReqObjActionDelete = MosReqObjActionDelete;
exports.MosReqObjAction = MosReqObjAction;
//# sourceMappingURL=mosReqObjAction.js.map

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

import { IMOSRequestObjectList } from '../../api';
import { IMosRequestObjectList } from '../../api';
import { MosMessage } from '../MosMessage';

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

private options;
constructor(options: IMOSRequestObjectList);
get messageXMLBlocks(): XMLBuilder.XMLElement;
constructor(options: IMosRequestObjectList);
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosReqObjList = void 0;
const MosMessage_1 = require("../MosMessage");

@@ -9,27 +8,22 @@ const XMLBuilder = require("xmlbuilder");

constructor(options) {
super('query');
super();
this.options = options;
this.port = 'query';
}
get messageXMLBlocks() {
const xmlMosReqObjList = XMLBuilder.create('mosReqObjList');
xmlMosReqObjList.att('username', this.options.username);
Utils_1.addTextElement(xmlMosReqObjList, 'username', this.options.username);
Utils_1.addTextElement(xmlMosReqObjList, 'queryID', this.options.queryID);
Utils_1.addTextElement(xmlMosReqObjList, 'listReturnStart', this.options.listReturnStart);
Utils_1.addTextElement(xmlMosReqObjList, 'listReturnEnd', this.options.listReturnEnd);
Utils_1.addTextElement(xmlMosReqObjList, 'generalSearch', this.options.generalSearch);
Utils_1.addTextElement(xmlMosReqObjList, 'mosSchema', this.options.mosSchema);
const xml = XMLBuilder.create('mosReqObjList');
xml.att('username', this.options.username);
Utils_1.addTextElement(xml, 'username', {}, this.options.username);
Utils_1.addTextElement(xml, 'queryID', {}, this.options.queryID);
Utils_1.addTextElement(xml, 'listReturnStart', {}, this.options.listReturnStart);
Utils_1.addTextElement(xml, 'listReturnEnd', {}, this.options.listReturnEnd);
Utils_1.addTextElement(xml, 'generalSearch', {}, this.options.generalSearch);
Utils_1.addTextElement(xml, 'mosSchema', {}, this.options.mosSchema);
for (const searchGroup of this.options.searchGroups) {
const xmlSearchGroup = XMLBuilder.create('searchGroup');
const groupEle = Utils_1.addTextElement(xml, 'searchGroup');
for (const searchField of searchGroup.searchFields) {
const attributes = {};
Object.keys(searchField).forEach(key => {
// @ts-ignore
attributes[key] = searchField[key] + '';
});
Utils_1.addTextElement(xmlSearchGroup, 'searchField', '', attributes);
Utils_1.addTextElement(groupEle, 'searchField', searchField);
}
xmlMosReqObjList.importDocument(xmlSearchGroup);
}
return xmlMosReqObjList;
return xml;
}

@@ -36,0 +30,0 @@ }

@@ -8,3 +8,3 @@ import { MosMessage } from '../MosMessage';

});
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MosReqSearchableSchema = void 0;
const MosMessage_1 = require("../MosMessage");

@@ -8,4 +7,5 @@ const XMLBuilder = require("xmlbuilder");

constructor(options) {
super('query');
super();
this.options = options;
this.port = 'query';
}

@@ -12,0 +12,0 @@ get messageXMLBlocks() {

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

/** */
get messageXMLBlocks(): XMLBuilder.XMLElement;
readonly messageXMLBlocks: XMLBuilder.XMLElement;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ROReqAll = void 0;
const XMLBuilder = require("xmlbuilder");

@@ -9,3 +8,4 @@ const MosMessage_1 = require("../MosMessage");

constructor() {
super('upper');
super();
this.port = 'upper';
}

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

import * as XMLBuilder from 'xmlbuilder';
import { MosString128 } from '../dataTypes/mosString128';
import { MosTime } from '../dataTypes/mosTime';
import { MosDuration } from '../dataTypes/mosDuration';
/** */
export declare function pad(n: string, width: number, z?: string): string;
export declare function xml2js(messageString: string): object;
export declare function addTextElement(root: XMLBuilder.XMLElement, elementName: string, text?: string | number | null | MosString128 | MosTime | MosDuration, attributes?: {
[key: string]: string;
}): XMLBuilder.XMLElement;
export declare function addTextElement(root: XMLBuilder.XMLElement, elementName: string, attributes?: Object, text?: string | number | null | MosString128 | MosTime): XMLBuilder.XMLElement;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addTextElement = exports.xml2js = exports.pad = void 0;
const xml_js_1 = require("xml-js");

@@ -168,4 +167,4 @@ /** */

exports.xml2js = xml2js;
function addTextElement(root, elementName, text, attributes) {
const txt = (text === null ?
function addTextElement(root, elementName, attributes, text) {
root.element(elementName, attributes, text === null ?
null :

@@ -175,6 +174,5 @@ text !== undefined ?

undefined);
const element = root.element(elementName, attributes || {}, txt);
return element;
return root;
}
exports.addTextElement = addTextElement;
//# sourceMappingURL=Utils.js.map
{
"name": "mos-connection",
"version": "0.9.1-nightly-featur-ncs-functions-20210416-075213-811be5c.0",
"version": "0.9.1-nightly-fix-mos-messages-in-chunks-20210429-155455-935ac2b.0",
"description": "MOS compliant TCP/IP Socket connection.",

@@ -37,3 +37,3 @@ "main": "dist/index.js",

"lint": "tslint --project tsconfig.json --config tslint.json",
"unit": "jest --detectOpenHandles",
"unit": "jest --forceExit",
"test": "yarn lint && yarn unit",

@@ -47,4 +47,4 @@ "test:integration": "yarn lint && jest --config=jest-integration.config.js",

"docs:test": "yarn docs:html",
"docs:html": "typedoc src/index.ts --excludePrivate --theme minimal --out docs",
"docs:json": "typedoc --json docs/typedoc.json src/index.ts",
"docs:html": "typedoc src/index.ts --excludePrivate --mode file --theme minimal --out docs",
"docs:json": "typedoc --mode file --json docs/typedoc.json src/index.ts",
"docs:publish": "yarn docs:html && gh-pages -d docs",

@@ -91,18 +91,17 @@ "changelog": "standard-version",

"devDependencies": {
"@types/jest": "^26.0.22",
"@types/jest": "^25.2.3",
"@types/node": "^12.12.3",
"codecov": "^3.8.1",
"gh-pages": "^3.1.0",
"jest": "^26.6.3",
"mockdate": "^3.0.5",
"codecov": "^3.6.5",
"gh-pages": "^3.0.0",
"jest": "^24.9.0",
"node-license-validator": "^1.3.0",
"npm-scripts-info": "^0.3.9",
"open-cli": "^6.0.1",
"standard-version": "^9.2.0",
"trash-cli": "^4.0.0",
"ts-jest": "^26.5.4",
"tslint": "^6.1.3",
"standard-version": "^8.0.0",
"trash-cli": "^3.0.0",
"ts-jest": "^24.0.2",
"tslint": "^6.1.2",
"tslint-config-standard": "^9.0.0",
"typedoc": "^0.20.35",
"typescript": "~4.1.5"
"typedoc": "^0.16.8",
"typescript": "~3.6.5"
},

@@ -124,5 +123,5 @@ "keywords": [

"dependencies": {
"iconv-lite": "^0.6.2",
"moment": "^2.29.1",
"tslib": "^2.2.0",
"iconv-lite": "^0.5.0",
"moment": "^2.26.0",
"tslib": "^1.13.0",
"xml-js": "^1.6.11",

@@ -129,0 +128,0 @@ "xmlbuilder": "^15.1.1"

@@ -34,3 +34,3 @@ # Sofie: The Modern TV News Studio Automation System (MOS Connection library)

// Setup callbacks to pipe data:
device.onRequestMachineInfo(() => {})
device.onGetMachineInfo(() => {})
device.onCreateRunningOrder((ro) => {})

@@ -37,0 +37,0 @@ device.onDeleteRunningOrder((RunningOrderID: MosString128) => {})

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

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