UNPKG

@uipath/robot

Version:

UiPath Robot javascript SDK enabling web pages to interact with UiPath Robots

69 lines (68 loc) 2.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Job = void 0; var utils_1 = require("../utils"); var constants_1 = require("../utils/constants"); var uuid_1 = require("uuid"); var uipathRobot_1 = require("../uipathRobot"); /** * Job model used to identify a running/completed Robot process */ /* @uipath-public */ var Job = /** @class */ (function () { /** * Default constructor * @param processId Unique GUID of the robot process to run. * @param argument In arguments to be passed to the robot process on execution. */ function Job(processId, argument) { var _this = this; this.processId = processId; this.argument = argument; /** * Dispatch method to trigger events. * @param status argument to pass along while event is dispatched. */ /* @uipath-internal */ this.dispatch = function (status) { return _this.eventHandlers.dispatch(constants_1.Constants.STATUS, status); }; /** * Dispatch method to trigger events. * @param event argument to pass along while event is dispatched. */ /* @uipath-internal */ this.dispatchEvent = function (eventData) { return _this.eventHandlers.dispatch(constants_1.Constants.WORKFLOW_EVENT, eventData); }; /** * Send a message to a running job. * @param channelName * @param payload * @returns */ this.sendClientMessage = function (channelName, payload) { return uipathRobot_1.UiPathRobot.sendClientMessage(_this, channelName, payload); }; this.jobId = uuid_1.v4(); this.processId = processId; this.argument = argument; this.eventHandlers = new utils_1.Dispatcher(); } /** * Method to attach event handler on the job. * @param eventName Available job events are: 'status', 'workflow-event'. * @param eventHanlder Event handler callback function called when event occurs. */ Job.prototype.on = function (eventName, eventHanlder) { switch (eventName) { case constants_1.Constants.STATUS: { this.eventHandlers.on(constants_1.Constants.STATUS, eventHanlder); break; } case constants_1.Constants.WORKFLOW_EVENT: { this.eventHandlers.on(constants_1.Constants.WORKFLOW_EVENT, eventHanlder); break; } default: { break; } } }; return Job; }()); exports.Job = Job;