UNPKG

@mos-connection/helper

Version:

Helper functions for the MOS-connection library

213 lines 10.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ROSwapItems = exports.ROSwapStories = exports.RODeleteItems = exports.RODeleteStories = exports.ROMoveItems = exports.ROMoveStories = exports.ROReplaceItems = exports.ROReplaceStories = exports.ROInsertItems = exports.ROInsertStories = exports.MosSendMessage = void 0; const XMLBuilder = require("xmlbuilder"); const MosMessage_1 = require("../MosMessage"); const xmlConversion_1 = require("./xmlConversion"); const Utils_1 = require("../../utils/Utils"); class MosSendMessage extends MosMessage_1.MosMessage { constructor(strict) { super('upper', strict); } } exports.MosSendMessage = MosSendMessage; class ROInsertStories extends MosSendMessage { constructor(Action, Stories, strict) { super(strict); this.Action = Action; this.Stories = Stories; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'INSERT'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlTarget = (0, Utils_1.addTextElementInternal)(root, 'element_target', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'storyID', this.Action.StoryID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); this.Stories.forEach((story) => { xmlConversion_1.XMLROStory.toXML(xmlSource, story, true); }); return root; } } exports.ROInsertStories = ROInsertStories; class ROInsertItems extends MosSendMessage { constructor(Action, Items, strict) { super(strict); this.Action = Action; this.Items = Items; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'INSERT'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlTarget = (0, Utils_1.addTextElementInternal)(root, 'element_target', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'storyID', this.Action.StoryID, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'itemID', this.Action.ItemID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); this.Items.forEach((item) => { xmlConversion_1.XMLMosItem.toXML(xmlSource, item, true); }); return root; } } exports.ROInsertItems = ROInsertItems; class ROReplaceStories extends MosSendMessage { constructor(Action, Stories, strict) { super(strict); this.Action = Action; this.Stories = Stories; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'REPLACE'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlTarget = (0, Utils_1.addTextElementInternal)(root, 'element_target', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'storyID', this.Action.StoryID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); this.Stories.forEach((story) => { xmlConversion_1.XMLROStory.toXML(xmlSource, story, true); }); return root; } } exports.ROReplaceStories = ROReplaceStories; class ROReplaceItems extends MosSendMessage { constructor(Action, Items, strict) { super(strict); this.Action = Action; this.Items = Items; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'REPLACE'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlTarget = (0, Utils_1.addTextElementInternal)(root, 'element_target', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'storyID', this.Action.StoryID, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'itemID', this.Action.ItemID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); this.Items.forEach((item) => { xmlConversion_1.XMLMosItem.toXML(xmlSource, item, true); }); return root; } } exports.ROReplaceItems = ROReplaceItems; class ROMoveStories extends MosSendMessage { constructor(Action, Stories, strict) { super(strict); this.Action = Action; this.Stories = Stories; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'MOVE'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlTarget = (0, Utils_1.addTextElementInternal)(root, 'element_target', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'storyID', this.Action.StoryID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); this.Stories.forEach((storyID) => { (0, Utils_1.addTextElementInternal)(xmlSource, 'storyID', storyID, undefined, this.strict); }); return root; } } exports.ROMoveStories = ROMoveStories; class ROMoveItems extends MosSendMessage { constructor(Action, Items, strict) { super(strict); this.Action = Action; this.Items = Items; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'MOVE'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlTarget = (0, Utils_1.addTextElementInternal)(root, 'element_target', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'storyID', this.Action.StoryID, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'itemID', this.Action.ItemID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); this.Items.forEach((itemID) => { (0, Utils_1.addTextElementInternal)(xmlSource, 'itemID', itemID, undefined, this.strict); }); return root; } } exports.ROMoveItems = ROMoveItems; class RODeleteStories extends MosSendMessage { constructor(Action, Stories, strict) { super(strict); this.Action = Action; this.Stories = Stories; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'DELETE'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); this.Stories.forEach((storyID) => { (0, Utils_1.addTextElementInternal)(xmlSource, 'storyID', storyID, undefined, this.strict); }); return root; } } exports.RODeleteStories = RODeleteStories; class RODeleteItems extends MosSendMessage { constructor(Action, Items, strict) { super(strict); this.Action = Action; this.Items = Items; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'DELETE'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlTarget = (0, Utils_1.addTextElementInternal)(root, 'element_target', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'storyID', this.Action.StoryID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); this.Items.forEach((itemID) => { (0, Utils_1.addTextElementInternal)(xmlSource, 'itemID', itemID, undefined, this.strict); }); return root; } } exports.RODeleteItems = RODeleteItems; class ROSwapStories extends MosSendMessage { constructor(Action, StoryID0, StoryID1, strict) { super(strict); this.Action = Action; this.StoryID0 = StoryID0; this.StoryID1 = StoryID1; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'SWAP'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlSource, 'storyID', this.StoryID0, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlSource, 'storyID', this.StoryID1, undefined, this.strict); return root; } } exports.ROSwapStories = ROSwapStories; class ROSwapItems extends MosSendMessage { constructor(Action, ItemID0, ItemID1, strict) { super(strict); this.Action = Action; this.ItemID0 = ItemID0; this.ItemID1 = ItemID1; } get messageXMLBlocks() { const root = XMLBuilder.create('roElementAction'); root.att('operation', 'SWAP'); (0, Utils_1.addTextElementInternal)(root, 'roID', this.Action.RunningOrderID, undefined, this.strict); const xmlTarget = (0, Utils_1.addTextElementInternal)(root, 'element_target', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlTarget, 'storyID', this.Action.StoryID, undefined, this.strict); const xmlSource = (0, Utils_1.addTextElementInternal)(root, 'element_source', undefined, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlSource, 'itemID', this.ItemID0, undefined, this.strict); (0, Utils_1.addTextElementInternal)(xmlSource, 'itemID', this.ItemID1, undefined, this.strict); return root; } } exports.ROSwapItems = ROSwapItems; //# sourceMappingURL=roActions.js.map