@uipath/robot
Advanced tools
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.JobState = void 0; | ||
| /** | ||
| * Job state enum | ||
| */ | ||
| var JobState; | ||
| (function (JobState) { | ||
| JobState[JobState["Executing"] = 0] = "Executing"; | ||
| JobState[JobState["Closed"] = 1] = "Closed"; | ||
| JobState[JobState["Canceled"] = 2] = "Canceled"; | ||
| JobState[JobState["Faulted"] = 3] = "Faulted"; | ||
| })(JobState = exports.JobState || (exports.JobState = {})); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.TraceEvent = void 0; | ||
| var TraceEvent; | ||
| (function (TraceEvent) { | ||
| TraceEvent["Invalid_Event"] = "InvalidEvent"; | ||
| TraceEvent["Get_Port"] = "GetPort"; | ||
| TraceEvent["Get_Processes"] = "GetProcesses"; | ||
| TraceEvent["Init"] = "Init"; | ||
| TraceEvent["Run_Robot"] = "RunRobot"; | ||
| TraceEvent["Job_Status_Poll"] = "JobStatusPoll"; | ||
| TraceEvent["User_Consent_Raised"] = "UserConsentRaised"; | ||
| TraceEvent["SDK_Loaded"] = "SDKLoaded"; | ||
| TraceEvent["Missing_Components"] = "MissingComponents"; | ||
| TraceEvent["Consent_Timeout"] = "ConsentTimeout"; | ||
| TraceEvent["Stop_Process"] = "StopProcess"; | ||
| TraceEvent["Install_Process"] = "InstallProcess"; | ||
| })(TraceEvent = exports.TraceEvent || (exports.TraceEvent = {})); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Language = void 0; | ||
| var de_resource_json_1 = __importDefault(require("./resources/de_resource.json")); | ||
| var en_resource_json_1 = __importDefault(require("./resources/en_resource.json")); | ||
| var es_MX_resource_json_1 = __importDefault(require("./resources/es-MX_resource.json")); | ||
| var es_resource_json_1 = __importDefault(require("./resources/es_resource.json")); | ||
| var fr_resource_json_1 = __importDefault(require("./resources/fr_resource.json")); | ||
| var ja_resource_json_1 = __importDefault(require("./resources/ja_resource.json")); | ||
| var ko_resource_json_1 = __importDefault(require("./resources/ko_resource.json")); | ||
| var pt_BR_resource_json_1 = __importDefault(require("./resources/pt-BR_resource.json")); | ||
| var pt_resource_json_1 = __importDefault(require("./resources/pt_resource.json")); | ||
| var ru_resource_json_1 = __importDefault(require("./resources/ru_resource.json")); | ||
| var tr_resource_json_1 = __importDefault(require("./resources/tr_resource.json")); | ||
| var zh_CN_resource_json_1 = __importDefault(require("./resources/zh-CN_resource.json")); | ||
| var Language = /** @class */ (function () { | ||
| function Language() { | ||
| } | ||
| Language.GetResource = function () { | ||
| var language = window.navigator.language.slice(0, 2); | ||
| switch (language) { | ||
| case 'de': return de_resource_json_1.default; | ||
| case 'es-MX': return es_MX_resource_json_1.default; | ||
| case 'es': return es_resource_json_1.default; | ||
| case 'fr': return fr_resource_json_1.default; | ||
| case 'ja': return ja_resource_json_1.default; | ||
| case 'ko': return ko_resource_json_1.default; | ||
| case 'pt-BR': return pt_BR_resource_json_1.default; | ||
| case 'pt': return pt_resource_json_1.default; | ||
| case 'ru': return ru_resource_json_1.default; | ||
| case 'tr': return tr_resource_json_1.default; | ||
| case 'zh-CN': return zh_CN_resource_json_1.default; | ||
| case 'en': | ||
| default: return en_resource_json_1.default; | ||
| } | ||
| }; | ||
| return Language; | ||
| }()); | ||
| exports.Language = Language; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var german = __importStar(require("./de_resource.json")); | ||
| var value = german; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var english = __importStar(require("./en_resource.json")); | ||
| var value = english; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var spanish = __importStar(require("./es_resource.json")); | ||
| var value = spanish; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var spanish_mex = __importStar(require("./es-MX_resource.json")); | ||
| var value = spanish_mex; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var french = __importStar(require("./fr_resource.json")); | ||
| var value = french; | ||
| module.exports = value; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var japanese = __importStar(require("./ja_resource.json")); | ||
| var value = japanese; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var korean = __importStar(require("./ko_resource.json")); | ||
| var value = korean; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var portuguese = __importStar(require("./pt_resource.json")); | ||
| var value = portuguese; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var portuguese_br = __importStar(require("./pt-BR_resource.json")); | ||
| var value = portuguese_br; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var russian = __importStar(require("./ru_resource.json")); | ||
| var value = russian; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var turkish = __importStar(require("./tr_resource.json")); | ||
| var value = turkish; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var chinese = __importStar(require("./zh-CN_resource.json")); | ||
| var value = chinese; | ||
| module.exports = value; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./job"), exports); | ||
| __exportStar(require("./jobPromise"), exports); | ||
| __exportStar(require("./jobResult"), exports); | ||
| __exportStar(require("./jobStatus"), exports); | ||
| __exportStar(require("./response"), exports); | ||
| __exportStar(require("./robotProcess"), exports); | ||
| __exportStar(require("./settings"), exports); | ||
| __exportStar(require("./serverFeatures"), exports); | ||
| __exportStar(require("./portResponse"), exports); | ||
| __exportStar(require("./workflowEventData"), exports); | ||
| __exportStar(require("./inputArgumentSchema"), exports); | ||
| __exportStar(require("./installProcessResult"), exports); |
| /** | ||
| * InputArgumentSchema returned by the installProcess request. | ||
| */ | ||
| export declare class InputArgumentSchema { | ||
| name: string; | ||
| type: string; | ||
| isRequired: boolean; | ||
| hasDefault: boolean; | ||
| /** | ||
| * @param name Input argument name | ||
| * @param type Input argument type | ||
| * @param isRequired Input argument is required | ||
| * @param hasDefault Input argument has default | ||
| */ | ||
| constructor(name: string, type: string, isRequired: boolean, hasDefault: boolean); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.InputArgumentSchema = void 0; | ||
| /** | ||
| * InputArgumentSchema returned by the installProcess request. | ||
| */ | ||
| var InputArgumentSchema = /** @class */ (function () { | ||
| /** | ||
| * @param name Input argument name | ||
| * @param type Input argument type | ||
| * @param isRequired Input argument is required | ||
| * @param hasDefault Input argument has default | ||
| */ | ||
| function InputArgumentSchema(name, type, isRequired, hasDefault) { | ||
| this.name = name; | ||
| this.type = type; | ||
| this.isRequired = isRequired; | ||
| this.hasDefault = hasDefault; | ||
| this.name = name; | ||
| this.type = type; | ||
| this.isRequired = isRequired; | ||
| this.hasDefault = hasDefault; | ||
| } | ||
| return InputArgumentSchema; | ||
| }()); | ||
| exports.InputArgumentSchema = InputArgumentSchema; |
| import { InputArgumentSchema } from "."; | ||
| /** | ||
| * InstallProcessResult returned by the installProcess request. | ||
| */ | ||
| export declare class InstallProcessResult { | ||
| inputArgumentsSchema: InputArgumentSchema[]; | ||
| /** | ||
| * @param inputArgumentsSchema Input arguments schema | ||
| */ | ||
| constructor(inputArgumentsSchema: InputArgumentSchema[]); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.InstallProcessResult = void 0; | ||
| /** | ||
| * InstallProcessResult returned by the installProcess request. | ||
| */ | ||
| var InstallProcessResult = /** @class */ (function () { | ||
| /** | ||
| * @param inputArgumentsSchema Input arguments schema | ||
| */ | ||
| function InstallProcessResult(inputArgumentsSchema) { | ||
| this.inputArgumentsSchema = inputArgumentsSchema; | ||
| this.inputArgumentsSchema = inputArgumentsSchema || []; | ||
| } | ||
| return InstallProcessResult; | ||
| }()); | ||
| exports.InstallProcessResult = InstallProcessResult; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Job = void 0; | ||
| var utils_1 = require("../utils"); | ||
| var constants_1 = require("../utils/constants"); | ||
| /** | ||
| * Job model used to identify a running/completed Robot process | ||
| */ | ||
| 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. | ||
| */ | ||
| 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. | ||
| */ | ||
| this.dispatchEvent = function (eventData) { return _this.eventHandlers.dispatch(constants_1.Constants.WORKFLOW_EVENT, eventData); }; | ||
| this.jobId = ''; | ||
| 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; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.JobPromise = void 0; | ||
| var uipathRobot_1 = require("../uipathRobot"); | ||
| var constants_1 = require("../utils/constants"); | ||
| /** | ||
| * Job promise model used for resolution and/or rejection of Promise<JobResult> | ||
| */ | ||
| var JobPromise = /** @class */ (function () { | ||
| /** | ||
| * Default constructor | ||
| * @param job Job to be wrapped with promise | ||
| */ | ||
| function JobPromise(job) { | ||
| var _this = this; | ||
| this.job = job; | ||
| /** | ||
| * Method to attach job status event handlers. | ||
| * @param eventHanlder Attaches callback which is invoked on job status change. | ||
| */ | ||
| this.onStatus = function (eventHanlder) { | ||
| _this.job.on(constants_1.Constants.STATUS, eventHanlder); | ||
| return _this; | ||
| }; | ||
| /** | ||
| * Method to attach job workflow event handlers. | ||
| * @param eventHandler Attaches callback which is invoked on job workflow event. | ||
| */ | ||
| this.onWorkflowEvent = function (eventHandler) { | ||
| _this.job.on(constants_1.Constants.WORKFLOW_EVENT, eventHandler); | ||
| return _this; | ||
| }; | ||
| this.promise = uipathRobot_1.UiPathRobot.startJob(this.job); | ||
| } | ||
| JobPromise.prototype.then = function (onfulfilled, onrejected) { | ||
| return this.promise.then(onfulfilled, onrejected); | ||
| }; | ||
| JobPromise.prototype.catch = function (onrejected) { | ||
| return this.promise.catch(onrejected); | ||
| }; | ||
| JobPromise.prototype.finally = function (onfinally) { | ||
| return this.promise.finally(onfinally); | ||
| }; | ||
| return JobPromise; | ||
| }()); | ||
| exports.JobPromise = JobPromise; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.JobResult = void 0; | ||
| /** | ||
| * Job result model containing all output arguments from the process. | ||
| * Empty if there are no out arguments. | ||
| */ | ||
| var JobResult = /** @class */ (function () { | ||
| function JobResult() { | ||
| } | ||
| return JobResult; | ||
| }()); | ||
| exports.JobResult = JobResult; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.JobStatus = void 0; | ||
| /** | ||
| * Job status model containing details of the executing job. | ||
| */ | ||
| var JobStatus = /** @class */ (function () { | ||
| /** | ||
| * | ||
| * @param state Current state of the job | ||
| * @param status Current status of the job | ||
| * @param events Workflow events sent by the job | ||
| * @param output Output of the job if any | ||
| * @param exception Exception from the job if any | ||
| */ | ||
| function JobStatus(state, status, events, output, exception) { | ||
| this.state = state; | ||
| this.status = status; | ||
| this.events = events; | ||
| this.output = output; | ||
| this.exception = exception; | ||
| this.events = events || []; | ||
| this.output = output || undefined; | ||
| this.exception = exception || undefined; | ||
| } | ||
| Object.defineProperty(JobStatus.prototype, "isExecuting", { | ||
| get: function () { return this.state === 'Executing'; }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(JobStatus.prototype, "isClosed", { | ||
| get: function () { return this.state === 'Closed'; }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(JobStatus.prototype, "errorResponse", { | ||
| get: function () { | ||
| if (this.exception) { | ||
| this.exception.state = this.state; | ||
| } | ||
| else { | ||
| this.exception = { 'state': this.state }; | ||
| } | ||
| return this.exception; | ||
| }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| return JobStatus; | ||
| }()); | ||
| exports.JobStatus = JobStatus; |
| /** | ||
| * PortResponse returned by the getPort Request. | ||
| */ | ||
| export declare class PortResponse { | ||
| port: number; | ||
| serverFeatures: string[]; | ||
| constructor(); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.PortResponse = void 0; | ||
| /** | ||
| * PortResponse returned by the getPort Request. | ||
| */ | ||
| var PortResponse = /** @class */ (function () { | ||
| function PortResponse() { | ||
| this.port = 0; | ||
| this.serverFeatures = []; | ||
| } | ||
| return PortResponse; | ||
| }()); | ||
| exports.PortResponse = PortResponse; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Response = void 0; | ||
| /** | ||
| * Generic response model | ||
| */ | ||
| var Response = /** @class */ (function () { | ||
| /** | ||
| * | ||
| * @param httpStatus Http status of the response | ||
| * @param statusText Http status text of the response | ||
| * @param data response data if any | ||
| * @param error Handled error response if any | ||
| */ | ||
| function Response(httpStatus, statusText, data, error) { | ||
| var _this = this; | ||
| this.httpStatus = httpStatus; | ||
| this.statusText = statusText; | ||
| this.data = data; | ||
| this.error = error; | ||
| /** | ||
| * Resolve promise if its a successful response. Throws error if response was unsuccessful. | ||
| * @param promise promise which will be resolved if response was successful. | ||
| */ | ||
| this.resolve = function (promise) { | ||
| if (_this.isSuccess) { | ||
| promise.resolve(_this.data); | ||
| } | ||
| else { | ||
| promise.reject(new Error(_this.httpStatus + " - " + _this.error)); | ||
| } | ||
| }; | ||
| this.data = data || undefined; | ||
| } | ||
| Object.defineProperty(Response.prototype, "isSuccess", { | ||
| get: function () { return this.httpStatus >= 200 && this.httpStatus < 300; }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(Response.prototype, "isUnauthorized", { | ||
| get: function () { return this.httpStatus === 401; }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(Response.prototype, "isForbidden", { | ||
| get: function () { return this.httpStatus === 403; }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(Response.prototype, "isEmpty", { | ||
| get: function () { return this.httpStatus === 0; }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(Response.prototype, "isNotFound", { | ||
| get: function () { return this.httpStatus === 404; }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| return Response; | ||
| }()); | ||
| exports.Response = Response; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.RobotProcess = void 0; | ||
| var uipathRobot_1 = require("../uipathRobot"); | ||
| var models_1 = require("../models"); | ||
| /** | ||
| * Robot process model containing details of the robot process available in current system | ||
| */ | ||
| var RobotProcess = /** @class */ (function () { | ||
| /** | ||
| * Default constructor | ||
| * @param id Unique id of the robot process | ||
| * @param name Robot Process name | ||
| * @param description Process Description | ||
| */ | ||
| function RobotProcess(id, name, description) { | ||
| var _this = this; | ||
| if (description === void 0) { description = undefined; } | ||
| this.id = id; | ||
| this.name = name; | ||
| this.description = description; | ||
| /** | ||
| * Start the robot process | ||
| * @param inArguments JSON object. In arguments to be passed to the robot if any. | ||
| */ | ||
| this.start = function (inArguments) { return new models_1.JobPromise(new models_1.Job(_this.id, inArguments)); }; | ||
| /** | ||
| * Install the robot process | ||
| */ | ||
| this.install = function () { return uipathRobot_1.UiPathRobot.installProcess(_this.id); }; | ||
| } | ||
| return RobotProcess; | ||
| }()); | ||
| exports.RobotProcess = RobotProcess; |
| /** | ||
| * ServerFeatures class used to maintain compatibility between different versions of client and server | ||
| */ | ||
| export declare class ServerFeatures { | ||
| private serverFeatures; | ||
| jobStatusUsesLongPolling: boolean; | ||
| installProcess: boolean; | ||
| /** | ||
| * Default constructor | ||
| */ | ||
| constructor(serverFeatures: string[]); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ServerFeatures = void 0; | ||
| /** | ||
| * ServerFeatures class used to maintain compatibility between different versions of client and server | ||
| */ | ||
| var ServerFeatures = /** @class */ (function () { | ||
| /** | ||
| * Default constructor | ||
| */ | ||
| function ServerFeatures(serverFeatures) { | ||
| this.serverFeatures = serverFeatures; | ||
| this.jobStatusUsesLongPolling = this.serverFeatures.includes('JobStatus_LongPolling'); | ||
| this.installProcess = this.serverFeatures.includes('InstallProcess'); | ||
| } | ||
| return ServerFeatures; | ||
| }()); | ||
| exports.ServerFeatures = ServerFeatures; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Settings = void 0; | ||
| /** | ||
| * Settings class used to change default settings of Js SDK | ||
| */ | ||
| var Settings = /** @class */ (function () { | ||
| /** | ||
| * Default constructor | ||
| * @param portNumber Port number of the Http listener | ||
| * @param pollTimeInterval Poll interval time. | ||
| */ | ||
| function Settings(portNumber, pollTimeInterval, disableTelemetry) { | ||
| this.portNumber = portNumber; | ||
| this.pollTimeInterval = pollTimeInterval; | ||
| this.disableTelemetry = disableTelemetry; | ||
| this.appOrigin = window.location.origin; | ||
| } | ||
| return Settings; | ||
| }()); | ||
| exports.Settings = Settings; |
| /** | ||
| * Workflow event data model. | ||
| */ | ||
| export declare class WorkflowEventData { | ||
| name: string; | ||
| payload: string; | ||
| /** | ||
| * Default constructor | ||
| * @param name Workflow event name | ||
| * @param payload Workflow event payload | ||
| */ | ||
| constructor(name: string, payload: string); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.WorkflowEventData = void 0; | ||
| /** | ||
| * Workflow event data model. | ||
| */ | ||
| var WorkflowEventData = /** @class */ (function () { | ||
| /** | ||
| * Default constructor | ||
| * @param name Workflow event name | ||
| * @param payload Workflow event payload | ||
| */ | ||
| function WorkflowEventData(name, payload) { | ||
| this.name = name; | ||
| this.payload = payload; | ||
| } | ||
| return WorkflowEventData; | ||
| }()); | ||
| exports.WorkflowEventData = WorkflowEventData; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./invokeRobotRequest"), exports); | ||
| __exportStar(require("./jobStatusRequest"), exports); | ||
| __exportStar(require("./portRequest"), exports); | ||
| __exportStar(require("./robotProcessRequest"), exports); | ||
| __exportStar(require("./stopProcessRequest"), exports); | ||
| __exportStar(require("./installProcessRequest"), exports); |
| import { Response } from '../../models/index'; | ||
| import { InstallProcessResult } from '../../models/installProcessResult'; | ||
| import { IRequest } from '../iRequest'; | ||
| /** | ||
| * Request class to install a process and retrieve the input arguments schema. | ||
| */ | ||
| export declare class InstallProcessRequest implements IRequest<InstallProcessResult> { | ||
| processId: string; | ||
| url: string; | ||
| /** | ||
| * Default constructor. | ||
| * @param processId Process Id of the process to install. | ||
| */ | ||
| constructor(processId: string); | ||
| /** | ||
| * Method that sends the request to install a process. | ||
| * @returns Promise of Response model type. | ||
| */ | ||
| send: () => Promise<Response<InstallProcessResult>>; | ||
| /** | ||
| * Set the port to which the request should be sent along with the consent code. | ||
| * @param robotInvocationPort Port on which local listener is running. | ||
| * @param consentCode User consented code. | ||
| */ | ||
| set(robotInvocationPort: number, consentCode: number): this; | ||
| /** | ||
| * Mapper method used to convert string response to desired InstallProcessResult model. | ||
| * @param data HttpResponse data sent from listener. | ||
| * @returns InstallProcessResult. | ||
| */ | ||
| private convertToResult; | ||
| /** | ||
| * Method that returns the request endpoint to which request will be sent. | ||
| * @param robotInvocationPort Port of local listener to which request should be sent. | ||
| * @param consentCode User approved consent code if any. | ||
| */ | ||
| private getURL; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.InstallProcessRequest = void 0; | ||
| var inputArgumentSchema_1 = require("../../models/inputArgumentSchema"); | ||
| var installProcessResult_1 = require("../../models/installProcessResult"); | ||
| var utils_1 = require("../../utils"); | ||
| var constants_1 = require("../../utils/constants"); | ||
| /** | ||
| * Request class to install a process and retrieve the input arguments schema. | ||
| */ | ||
| var InstallProcessRequest = /** @class */ (function () { | ||
| /** | ||
| * Default constructor. | ||
| * @param processId Process Id of the process to install. | ||
| */ | ||
| function InstallProcessRequest(processId) { | ||
| var _this = this; | ||
| this.processId = processId; | ||
| /** | ||
| * Method that sends the request to install a process. | ||
| * @returns Promise of Response model type. | ||
| */ | ||
| this.send = function () { return utils_1.HttpUtil.get(_this.url, _this.convertToResult); }; | ||
| this.url = ''; | ||
| } | ||
| /** | ||
| * Set the port to which the request should be sent along with the consent code. | ||
| * @param robotInvocationPort Port on which local listener is running. | ||
| * @param consentCode User consented code. | ||
| */ | ||
| InstallProcessRequest.prototype.set = function (robotInvocationPort, consentCode) { | ||
| this.url = this.getURL(robotInvocationPort, consentCode); | ||
| return this; | ||
| }; | ||
| /** | ||
| * Mapper method used to convert string response to desired InstallProcessResult model. | ||
| * @param data HttpResponse data sent from listener. | ||
| * @returns InstallProcessResult. | ||
| */ | ||
| InstallProcessRequest.prototype.convertToResult = function (httpResponse) { | ||
| if (httpResponse) { | ||
| var jsonResponse = JSON.parse(httpResponse); | ||
| if (jsonResponse && jsonResponse.InputArgumentsSchema) { | ||
| var result = new installProcessResult_1.InstallProcessResult(jsonResponse.InputArgumentsSchema.map(function (a) { | ||
| return new inputArgumentSchema_1.InputArgumentSchema(a.Name, a.Type, a.IsRequired, a.HasDefault); | ||
| })); | ||
| return result; | ||
| } | ||
| } | ||
| return new installProcessResult_1.InstallProcessResult([]); | ||
| }; | ||
| /** | ||
| * Method that returns the request endpoint to which request will be sent. | ||
| * @param robotInvocationPort Port of local listener to which request should be sent. | ||
| * @param consentCode User approved consent code if any. | ||
| */ | ||
| InstallProcessRequest.prototype.getURL = function (robotInvocationPort, consentCode) { | ||
| var url = constants_1.Constants.DEFAULT_ROBOT_INVOKE_DOMAIN + ":" + robotInvocationPort + "/" + constants_1.Constants.INSTALL_PROCESS + "?robotProcessId=" + this.processId; | ||
| return utils_1.UrlUtil.appendConsentCode(url, consentCode); | ||
| }; | ||
| return InstallProcessRequest; | ||
| }()); | ||
| exports.InstallProcessRequest = InstallProcessRequest; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.InvokeRobotRequest = void 0; | ||
| var index_1 = require("../../models/index"); | ||
| var utils_1 = require("../../utils"); | ||
| var constants_1 = require("../../utils/constants"); | ||
| /** | ||
| * Request class to invoke any robot from local system. | ||
| */ | ||
| var InvokeRobotRequest = /** @class */ (function () { | ||
| /** | ||
| * Default constructor. | ||
| * @param robotProcessId PackageId of the robot to run. | ||
| * @param data Data to be passed as in arguments to robot process on start. Optional parameter. | ||
| */ | ||
| function InvokeRobotRequest(robotProcessId, data) { | ||
| var _this = this; | ||
| this.robotProcessId = robotProcessId; | ||
| this.data = data; | ||
| /** | ||
| * Method that sends the request to invoke a robot. | ||
| * @returns Promise of Response model type. | ||
| */ | ||
| this.send = function () { return utils_1.HttpUtil.post(_this.url, _this.convertToJob, _this.data); }; | ||
| this.url = ''; | ||
| } | ||
| /** | ||
| * Set the port to which the request should be sent along with the consent code. | ||
| * @param robotInvocationPort Port on which local listener is running. | ||
| * @param consentCode User consented code. | ||
| */ | ||
| InvokeRobotRequest.prototype.set = function (robotInvocationPort, consentCode) { | ||
| this.url = this.getURL(robotInvocationPort, consentCode); | ||
| return this; | ||
| }; | ||
| /** | ||
| * Mapper method used to convert string response to desired Job model. | ||
| * @param data HttpResponse data sent from listener. | ||
| * @returns Job to uniquely identify this robot process execution. | ||
| */ | ||
| InvokeRobotRequest.prototype.convertToJob = function (data) { | ||
| var job = new index_1.Job(''); | ||
| if (data) { | ||
| var jsonResponse = JSON.parse(data).response; | ||
| if (jsonResponse && jsonResponse.JobId) { | ||
| job.jobId = jsonResponse.JobId; | ||
| } | ||
| } | ||
| return job; | ||
| }; | ||
| /** | ||
| * Method that returns the request endpoint to which request will be sent. | ||
| * @param robotInvocationPort Port of local listener to which request should be sent. | ||
| * @param consentCode User approved consent code if any. | ||
| */ | ||
| InvokeRobotRequest.prototype.getURL = function (robotInvocationPort, consentCode) { | ||
| var url = constants_1.Constants.DEFAULT_ROBOT_INVOKE_DOMAIN + ":" + robotInvocationPort + "/" + constants_1.Constants.INVOKE_ROBOT + "?robotProcessId=" + this.robotProcessId; | ||
| return utils_1.UrlUtil.appendConsentCode(url, consentCode); | ||
| }; | ||
| return InvokeRobotRequest; | ||
| }()); | ||
| exports.InvokeRobotRequest = InvokeRobotRequest; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.JobStatusRequest = void 0; | ||
| var jobState_1 = require("../../enums/jobState"); | ||
| var index_1 = require("../../models/index"); | ||
| var constants_1 = require("../../utils/constants"); | ||
| var httpUtil_1 = require("../../utils/httpUtil"); | ||
| var urlUtil_1 = require("../../utils/urlUtil"); | ||
| /** | ||
| * Request class to get status of any running/completed job. | ||
| */ | ||
| var JobStatusRequest = /** @class */ (function () { | ||
| /** | ||
| * Default constructor. | ||
| * @param job Job object whose status we want to request | ||
| */ | ||
| function JobStatusRequest(job) { | ||
| var _this = this; | ||
| this.job = job; | ||
| /** | ||
| * Method that sends the request to get status of running/completed job. | ||
| * @returns Promise of Response model type. | ||
| */ | ||
| this.send = function () { return httpUtil_1.HttpUtil.get(_this.url, _this.convertToJobStatus); }; | ||
| /** | ||
| * Method that returns the request endpoint to which request will be sent. | ||
| * @param robotInvocationPort Port of local listener to which request should be sent. | ||
| * @param consentCode User approved consent code if any. | ||
| * @param job Job for which the result is to be found. | ||
| */ | ||
| this.getURL = function (robotInvocationPort, consentCode, job) { | ||
| var url = constants_1.Constants.DEFAULT_ROBOT_INVOKE_DOMAIN + ":" + robotInvocationPort + "/" + constants_1.Constants.GET_JOB_STATUS + "?jobId=" + job.jobId; | ||
| return urlUtil_1.UrlUtil.appendConsentCode(url, consentCode); | ||
| }; | ||
| this.url = ''; | ||
| } | ||
| /** | ||
| * Set the port to which the request should be sent along with the consent code. | ||
| * @param robotInvocationPort Port on which local listener is running. | ||
| * @param consentCode User consented code. | ||
| */ | ||
| JobStatusRequest.prototype.set = function (robotInvocationPort, consentCode) { | ||
| this.url = this.getURL(robotInvocationPort, consentCode, this.job); | ||
| return this; | ||
| }; | ||
| /** | ||
| * Mapper method used to convert string response to desired Job status model. | ||
| * @param data HttpResponse sent from listener. | ||
| * @returns Job result of the completed/errored job. | ||
| */ | ||
| JobStatusRequest.prototype.convertToJobStatus = function (data) { | ||
| if (data) { | ||
| var jsonResponse = JSON.parse(data).response; | ||
| if (jsonResponse) { | ||
| return new index_1.JobStatus(jobState_1.JobState[jsonResponse.State], jsonResponse.Status, jsonResponse.Events, jsonResponse.Output, jsonResponse.Error); | ||
| } | ||
| } | ||
| return new index_1.JobStatus('', [], [], undefined, undefined); | ||
| }; | ||
| return JobStatusRequest; | ||
| }()); | ||
| exports.JobStatusRequest = JobStatusRequest; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.PortRequest = void 0; | ||
| var index_1 = require("../../models/index"); | ||
| var utils_1 = require("../../utils"); | ||
| var constants_1 = require("../../utils/constants"); | ||
| /** | ||
| * Request class to get port of listener running on local user session. | ||
| */ | ||
| var PortRequest = /** @class */ (function () { | ||
| /** | ||
| * Default constructor | ||
| * @param listenerPort Port of listener running on session 0. | ||
| * @param consentCode User approved consent code if any. | ||
| */ | ||
| function PortRequest(listenerPort, consentCode) { | ||
| var _this = this; | ||
| /** | ||
| * Method that sends the request to get port of listener running on local user session. | ||
| * @returns Promise of Response model type. | ||
| */ | ||
| this.getPort = function () { return utils_1.HttpUtil.get(_this.url, _this.convertToPort); }; | ||
| /** | ||
| * Mapper method used to convert string response to number. | ||
| * @param response HttpResponse sent from listener. | ||
| * @returns Port number. | ||
| */ | ||
| this.convertToPort = function (data) { | ||
| var portResponse = new index_1.PortResponse(); | ||
| if (data) { | ||
| var jsonResponse = JSON.parse(data); | ||
| portResponse.port = jsonResponse.Port; | ||
| if (jsonResponse.ServerFeatures) | ||
| portResponse.serverFeatures = jsonResponse.ServerFeatures; | ||
| } | ||
| return portResponse; | ||
| }; | ||
| /** | ||
| * Method that sets the request endpoint to which request will be sent. | ||
| * @param listenerEndpoint Endpoint to which request will be sent | ||
| * @param consentCode randomly generated consent code. | ||
| */ | ||
| this.setURL = function (listenerEndpoint, consentCode) { return utils_1.UrlUtil.appendConsentCode(listenerEndpoint + "/" + constants_1.Constants.GET_PORT, consentCode); }; | ||
| var listenerEndpoint = constants_1.Constants.DEFAULT_PORT_DISCOVERY_DOMAIN + ":" + listenerPort; | ||
| this.url = this.setURL(listenerEndpoint, consentCode); | ||
| } | ||
| return PortRequest; | ||
| }()); | ||
| exports.PortRequest = PortRequest; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.RobotProcessRequest = void 0; | ||
| var models_1 = require("../../models"); | ||
| var utils_1 = require("../../utils"); | ||
| var constants_1 = require("../../utils/constants"); | ||
| var RobotProcessRequest = /** @class */ (function () { | ||
| /** | ||
| * Default constructor | ||
| */ | ||
| function RobotProcessRequest() { | ||
| var _this = this; | ||
| /** | ||
| * Request method to get all published robots in local machine. | ||
| * @returns Promise of type Response. | ||
| */ | ||
| this.send = function () { return utils_1.HttpUtil.get(_this.url, _this.convertToRobotProcesses); }; | ||
| /** | ||
| * Set the port to which the request should be sent along with the consent code. | ||
| * @param robotInvocationPort Port on which local listener is running. | ||
| * @param consentCode User consented code. | ||
| */ | ||
| this.set = function (robotInvocationPort, consentCode) { | ||
| _this.url = _this.getURL(robotInvocationPort, consentCode); | ||
| return _this; | ||
| }; | ||
| this.convertToRobotProcesses = function (httpResponse) { | ||
| if (httpResponse) { | ||
| var jsonResponse = JSON.parse(httpResponse).response; | ||
| if (jsonResponse && jsonResponse.length) { | ||
| return jsonResponse.map(function (r) { return new models_1.RobotProcess(r.Key, r.Name, r.Description); }); | ||
| } | ||
| } | ||
| return []; | ||
| }; | ||
| this.url = ''; | ||
| } | ||
| /** | ||
| * Method that returns the request endpoint to which request will be sent. | ||
| * @param robotInvocationPort Port of local listener to which request should be sent. | ||
| * @param consentCode User approved consent code if any. | ||
| */ | ||
| RobotProcessRequest.prototype.getURL = function (robotInvocationPort, consentCode) { | ||
| var url = constants_1.Constants.DEFAULT_ROBOT_INVOKE_DOMAIN + ":" + robotInvocationPort + "/" + constants_1.Constants.GET_ROBOT_PROCESSES; | ||
| return utils_1.UrlUtil.appendConsentCode(url, consentCode); | ||
| }; | ||
| return RobotProcessRequest; | ||
| }()); | ||
| exports.RobotProcessRequest = RobotProcessRequest; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.StopProcessRequest = void 0; | ||
| var constants_1 = require("../../utils/constants"); | ||
| var httpUtil_1 = require("../../utils/httpUtil"); | ||
| var urlUtil_1 = require("../../utils/urlUtil"); | ||
| /** | ||
| * Request class to cancel a running job. | ||
| */ | ||
| var StopProcessRequest = /** @class */ (function () { | ||
| /** | ||
| * Default constructor. | ||
| * @param job Job object whose status we want to request | ||
| */ | ||
| function StopProcessRequest(process) { | ||
| var _this = this; | ||
| this.process = process; | ||
| /** | ||
| * Method that sends the request to cancel running job. | ||
| * @returns Promise of Response model type. | ||
| */ | ||
| this.send = function () { return httpUtil_1.HttpUtil.get(_this.url, _this.convert); }; | ||
| this.convert = function (data) { return ''; }; | ||
| /** | ||
| * Method that returns the request endpoint to which request will be sent. | ||
| * @param robotInvocationPort Port of local listener to which request should be sent. | ||
| * @param consentCode User approved consent code if any. | ||
| * @param process Robot Process to stop | ||
| */ | ||
| this.getURL = function (robotInvocationPort, consentCode, process) { | ||
| var url = constants_1.Constants.DEFAULT_ROBOT_INVOKE_DOMAIN + ":" + robotInvocationPort + "/" + constants_1.Constants.STOP_PROCESS + "?robotProcessId=" + process.id; | ||
| return urlUtil_1.UrlUtil.appendConsentCode(url, consentCode); | ||
| }; | ||
| this.url = ''; | ||
| } | ||
| /** | ||
| * Set the port to which the request should be sent along with the consent code. | ||
| * @param robotInvocationPort Port on which local listener is running. | ||
| * @param consentCode User consented code. | ||
| */ | ||
| StopProcessRequest.prototype.set = function (robotInvocationPort, consentCode) { | ||
| this.url = this.getURL(robotInvocationPort, consentCode, this.process); | ||
| return this; | ||
| }; | ||
| return StopProcessRequest; | ||
| }()); | ||
| exports.StopProcessRequest = StopProcessRequest; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| "use strict"; | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| return new (P || (P = Promise))(function (resolve, reject) { | ||
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
| step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| }); | ||
| }; | ||
| var __generator = (this && this.__generator) || function (thisArg, body) { | ||
| var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
| return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
| function verb(n) { return function (v) { return step([n, v]); }; } | ||
| function step(op) { | ||
| if (f) throw new TypeError("Generator is already executing."); | ||
| while (_) try { | ||
| if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
| if (y = 0, t) op = [op[0] & 2, t.value]; | ||
| switch (op[0]) { | ||
| case 0: case 1: t = op; break; | ||
| case 4: _.label++; return { value: op[1], done: false }; | ||
| case 5: _.label++; y = op[1]; op = [0]; continue; | ||
| case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
| default: | ||
| if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
| if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
| if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
| if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
| if (t[2]) _.ops.pop(); | ||
| _.trys.pop(); continue; | ||
| } | ||
| op = body.call(thisArg, _); | ||
| } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
| if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
| } | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.SDK = void 0; | ||
| var traceEvent_1 = require("../enums/traceEvent"); | ||
| var language_1 = require("../locale/language"); | ||
| var models_1 = require("../models"); | ||
| var implementation_1 = require("../requests/implementation"); | ||
| var utils_1 = require("../utils"); | ||
| var constants_1 = require("../utils/constants"); | ||
| var appinsightsLogger_1 = require("../utils/logger/appinsightsLogger"); | ||
| var async_mutex_1 = require("async-mutex"); | ||
| /** | ||
| * Robot SDK class | ||
| */ | ||
| var RobotSDK = /** @class */ (function () { | ||
| function RobotSDK() { | ||
| var _this = this; | ||
| /** | ||
| * Method to attach event handlers on the SDK. | ||
| * @param eventName Available SDK events are 'consent-prompt', 'missing-components'. | ||
| * @param eventHanlder Event handler callback function called when event occurs. | ||
| */ | ||
| this.on = function (eventName, eventHanlder) { | ||
| switch (eventName) { | ||
| case constants_1.Constants.CONSENT_PROMPT: { | ||
| _this.eventHandlers.on(constants_1.Constants.CONSENT_PROMPT, eventHanlder); | ||
| break; | ||
| } | ||
| case constants_1.Constants.MISSING_COMPONENTS: { | ||
| _this.eventHandlers.on(constants_1.Constants.MISSING_COMPONENTS, eventHanlder); | ||
| break; | ||
| } | ||
| default: { | ||
| _this.trace(traceEvent_1.TraceEvent.Invalid_Event, {}); | ||
| break; | ||
| } | ||
| } | ||
| }; | ||
| /** | ||
| * Init method set custom consent code handling. | ||
| * @returns {IRobotSDK} implemented instance | ||
| */ | ||
| this.init = function () { | ||
| _this.trace(traceEvent_1.TraceEvent.Init, {}); | ||
| return _this; | ||
| }; | ||
| /** | ||
| * Method to retrieve all published robot processes on users local machine. | ||
| * @returns Deferred promise of type RobotProcess[] which will be resolved/rejected based on http response. | ||
| */ | ||
| this.getProcesses = function () { | ||
| _this.trace(traceEvent_1.TraceEvent.Get_Processes, {}); | ||
| var deferredPromise = new utils_1.Deferred(); | ||
| try { | ||
| _this.sendRequest(new implementation_1.RobotProcessRequest(), deferredPromise); | ||
| } | ||
| catch (error) { | ||
| deferredPromise.reject(error); | ||
| _this.traceError(traceEvent_1.TraceEvent.Get_Processes, error); | ||
| } | ||
| return deferredPromise.promise; | ||
| }; | ||
| /** | ||
| * Method to invoke a robot process. | ||
| * @param job Job object containing all information about the robot process to run. | ||
| * @returns Deferred promise which is resolved with job result when robot process completes. | ||
| */ | ||
| this.startJob = function (job) { return __awaiter(_this, void 0, void 0, function () { | ||
| var deferredPromise, jobResponse; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: | ||
| this.trace(traceEvent_1.TraceEvent.Run_Robot, {}); | ||
| deferredPromise = new utils_1.Deferred(); | ||
| return [4 /*yield*/, this.startRobot(job.processId, job.argument)]; | ||
| case 1: | ||
| jobResponse = _a.sent(); | ||
| job.jobId = jobResponse.jobId; | ||
| this.jobStatusPoll(job, deferredPromise); | ||
| return [2 /*return*/, deferredPromise.promise]; | ||
| } | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Method to stop a robot process job. | ||
| * @param job Job object containing all information about the robot process run to cancel. | ||
| * @returns Deferred promise which is resolved with job result when robot process is cancelled. | ||
| */ | ||
| this.stopProcess = function (process) { return __awaiter(_this, void 0, void 0, function () { | ||
| var deferredPromise, response, error_1; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: | ||
| this.trace(traceEvent_1.TraceEvent.Stop_Process, {}); | ||
| deferredPromise = new utils_1.Deferred(); | ||
| _a.label = 1; | ||
| case 1: | ||
| _a.trys.push([1, 3, , 4]); | ||
| return [4 /*yield*/, new implementation_1.StopProcessRequest(process).set(this.robotInvocationPort, this.consentCode).send()]; | ||
| case 2: | ||
| response = _a.sent(); | ||
| if (response.isSuccess) { | ||
| deferredPromise.resolve(); | ||
| } | ||
| else { | ||
| throw response.isEmpty ? "" + language_1.Language.GetResource().api_not_found : response.error; | ||
| } | ||
| return [3 /*break*/, 4]; | ||
| case 3: | ||
| error_1 = _a.sent(); | ||
| deferredPromise.reject(error_1); | ||
| this.traceError(traceEvent_1.TraceEvent.Stop_Process, error_1); | ||
| return [3 /*break*/, 4]; | ||
| case 4: return [2 /*return*/, deferredPromise.promise]; | ||
| } | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Method to install a process. | ||
| * @param processId Process Id of the robot process to install. | ||
| */ | ||
| this.installProcess = function (processId) { return __awaiter(_this, void 0, void 0, function () { | ||
| var deferredPromise; | ||
| return __generator(this, function (_a) { | ||
| this.trace(traceEvent_1.TraceEvent.Install_Process, {}); | ||
| if (!this.serverFeatures.installProcess) | ||
| throw new Error("" + language_1.Language.GetResource().api_not_found); | ||
| deferredPromise = new utils_1.Deferred(); | ||
| try { | ||
| this.sendRequest(new implementation_1.InstallProcessRequest(processId), deferredPromise); | ||
| } | ||
| catch (error) { | ||
| deferredPromise.reject(error); | ||
| this.traceError(traceEvent_1.TraceEvent.Install_Process, error); | ||
| } | ||
| return [2 /*return*/, deferredPromise.promise]; | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Method to invoke a robot on the local user machine. | ||
| * @param robotProcessId Robot package id to uniquely identify robots present on local user machine. | ||
| * @param data In arguments to be passed to the robot if any. | ||
| * @returns Deferred promise of type job which will be resolved/rejected based on http response. | ||
| */ | ||
| this.startRobot = function (robotProcessId, data) { return __awaiter(_this, void 0, void 0, function () { | ||
| var deferredPromise; | ||
| return __generator(this, function (_a) { | ||
| if (data) { | ||
| data = JSON.stringify(data); | ||
| } | ||
| deferredPromise = new utils_1.Deferred(); | ||
| try { | ||
| this.sendRequest(new implementation_1.InvokeRobotRequest(robotProcessId, data), deferredPromise); | ||
| } | ||
| catch (error) { | ||
| deferredPromise.reject(error); | ||
| } | ||
| return [2 /*return*/, deferredPromise.promise]; | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Finds port of local listener and sends request. Requests user consent if required. | ||
| * @param request IRequest to send. | ||
| * @param deferredPromise Promise to resolve on completion of request. | ||
| */ | ||
| this.sendRequest = function (request, deferredPromise) { return __awaiter(_this, void 0, void 0, function () { | ||
| var response, error_2; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: | ||
| _a.trys.push([0, 6, , 7]); | ||
| return [4 /*yield*/, this.initializePort()]; | ||
| case 1: | ||
| _a.sent(); | ||
| return [4 /*yield*/, request.set(this.robotInvocationPort, this.consentCode).send()]; | ||
| case 2: | ||
| response = _a.sent(); | ||
| if (!response.isUnauthorized) return [3 /*break*/, 4]; | ||
| return [4 /*yield*/, this.resendAfterConsent(request)]; | ||
| case 3: | ||
| response = _a.sent(); | ||
| return [3 /*break*/, 5]; | ||
| case 4: | ||
| if (response.isEmpty) { | ||
| this.showMissingComponents(); | ||
| } | ||
| _a.label = 5; | ||
| case 5: | ||
| response.resolve(deferredPromise); | ||
| return [3 /*break*/, 7]; | ||
| case 6: | ||
| error_2 = _a.sent(); | ||
| deferredPromise.reject(error_2); | ||
| return [3 /*break*/, 7]; | ||
| case 7: return [2 /*return*/]; | ||
| } | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Initialize method that initializes listener port running on local session. | ||
| * @returns Promise. | ||
| */ | ||
| this.initializePort = function () { return __awaiter(_this, void 0, void 0, function () { | ||
| var _this = this; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: return [4 /*yield*/, this.initializePortMutex.runExclusive(function () { return __awaiter(_this, void 0, void 0, function () { | ||
| var portResponse; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: | ||
| if (!(this.robotInvocationPort === 0)) return [3 /*break*/, 2]; | ||
| this.consentCode = 0; | ||
| return [4 /*yield*/, this.getPort()]; | ||
| case 1: | ||
| portResponse = _a.sent(); | ||
| this.robotInvocationPort = portResponse.port; | ||
| this.serverFeatures = new models_1.ServerFeatures(portResponse.serverFeatures); | ||
| _a.label = 2; | ||
| case 2: return [2 /*return*/]; | ||
| } | ||
| }); | ||
| }); })]; | ||
| case 1: | ||
| _a.sent(); | ||
| return [2 /*return*/]; | ||
| } | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Method to find the port on which local listener is running. | ||
| * @returns Deferred promise of type number which will be resolved/rejected based on http response. | ||
| */ | ||
| this.getPort = function () { return __awaiter(_this, void 0, void 0, function () { | ||
| var deferredPromise, request, response, result, error_3; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: | ||
| deferredPromise = new utils_1.Deferred(); | ||
| _a.label = 1; | ||
| case 1: | ||
| _a.trys.push([1, 6, , 7]); | ||
| request = new implementation_1.PortRequest(this.settings.portNumber, this.consentCode); | ||
| return [4 /*yield*/, request.getPort()]; | ||
| case 2: | ||
| response = _a.sent(); | ||
| if (!(response.isUnauthorized && this.consentCode === 0)) return [3 /*break*/, 4]; | ||
| return [4 /*yield*/, this.askForConsent()]; | ||
| case 3: | ||
| result = _a.sent(); | ||
| deferredPromise.resolve(result); | ||
| return [3 /*break*/, 5]; | ||
| case 4: | ||
| if (response.isEmpty) { | ||
| this.showMissingComponents(); | ||
| deferredPromise.reject(new Error('500 - Robot Service down')); | ||
| } | ||
| else { | ||
| response.resolve(deferredPromise); | ||
| } | ||
| _a.label = 5; | ||
| case 5: return [3 /*break*/, 7]; | ||
| case 6: | ||
| error_3 = _a.sent(); | ||
| this.traceError(traceEvent_1.TraceEvent.Get_Port, error_3); | ||
| deferredPromise.reject(error_3); | ||
| return [3 /*break*/, 7]; | ||
| case 7: return [2 /*return*/, deferredPromise.promise]; | ||
| } | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Generates a random number which will be passed to protocol handler and shown to user to approve as consent. | ||
| * Polls for 60 seconds to determine if user has consented. | ||
| */ | ||
| this.askForConsent = function () { | ||
| var deferredPromise = new utils_1.Deferred(); | ||
| _this.consentCode = utils_1.RandomUtil.getRandomNumber(); | ||
| utils_1.ProtocolUtil.openUiPathProtocol(_this.consentCode); | ||
| _this.showConsentCode(_this.consentCode); | ||
| _this.pollForApprovedConsent(_this.getPort) | ||
| .then(function (response) { | ||
| utils_1.HtmlUtil.hideConsentOverlay(); | ||
| deferredPromise.resolve(response); | ||
| }) | ||
| .catch(function (error) { | ||
| utils_1.HtmlUtil.hideConsentOverlay(); | ||
| deferredPromise.reject(error); | ||
| _this.traceError(traceEvent_1.TraceEvent.Consent_Timeout, error); | ||
| }); | ||
| _this.trace(traceEvent_1.TraceEvent.User_Consent_Raised, {}); | ||
| return deferredPromise.promise; | ||
| }; | ||
| /** | ||
| * Polls the given function for 1 min until success. | ||
| * @param fn Function to poll. | ||
| */ | ||
| this.pollForApprovedConsent = function (fn) { return utils_1.PollUtil.poll(fn, constants_1.Constants.POLL_TIMEOUT, constants_1.Constants.POLL_TIMEINTERVAL); }; | ||
| /** | ||
| * Makes request after user consents access. | ||
| * @param request IRequest to send. | ||
| */ | ||
| this.resendAfterConsent = function (request) { return __awaiter(_this, void 0, void 0, function () { | ||
| var portResponse; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: return [4 /*yield*/, this.askForConsent()]; | ||
| case 1: | ||
| portResponse = _a.sent(); | ||
| this.robotInvocationPort = portResponse.port; | ||
| this.serverFeatures = new models_1.ServerFeatures(portResponse.serverFeatures); | ||
| return [2 /*return*/, request.set(this.robotInvocationPort, this.consentCode).send()]; | ||
| } | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Polls recursively until completion of currently running robot process job. | ||
| * @param job Job that is currently running. | ||
| * @param statusChangeCallback callback method to call if job status has changed | ||
| * @param deferredPromise Promise to resolve/reject once job completes. | ||
| */ | ||
| this.jobStatusPoll = function (job, deferredPromise) { return __awaiter(_this, void 0, void 0, function () { | ||
| var pollTimeInterval, jobResponse, error_4; | ||
| var _this = this; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: | ||
| _a.trys.push([0, 2, , 3]); | ||
| pollTimeInterval = this.serverFeatures.jobStatusUsesLongPolling ? 0 : this.settings.pollTimeInterval; | ||
| return [4 /*yield*/, this.getJobStatus(job)]; | ||
| case 1: | ||
| jobResponse = _a.sent(); | ||
| jobResponse.events.forEach(function (value) { return job.dispatchEvent(value); }); | ||
| jobResponse.status.forEach(function (value) { return job.dispatch(value); }); | ||
| if (jobResponse.isExecuting) { | ||
| setTimeout(function () { return _this.jobStatusPoll(job, deferredPromise); }, pollTimeInterval); | ||
| } | ||
| else if (jobResponse.isClosed) { | ||
| deferredPromise.resolve(jobResponse.output.Arguments); | ||
| } | ||
| else { | ||
| deferredPromise.reject(jobResponse.errorResponse); | ||
| } | ||
| return [3 /*break*/, 3]; | ||
| case 2: | ||
| error_4 = _a.sent(); | ||
| deferredPromise.reject(error_4); | ||
| this.traceError(traceEvent_1.TraceEvent.Job_Status_Poll, error_4); | ||
| return [3 /*break*/, 3]; | ||
| case 3: return [2 /*return*/]; | ||
| } | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Method to get job status of any running/completed job. | ||
| * @param job Job object for which status needs to be found. | ||
| * @returns Deferred promise of type JobResult which will be resolved/rejected based on http response. | ||
| */ | ||
| this.getJobStatus = function (job) { return __awaiter(_this, void 0, void 0, function () { | ||
| var response; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: return [4 /*yield*/, new implementation_1.JobStatusRequest(job).set(this.robotInvocationPort, this.consentCode).send()]; | ||
| case 1: | ||
| response = _a.sent(); | ||
| if (response.isSuccess && response.data) { | ||
| return [2 /*return*/, response.data]; | ||
| } | ||
| else { | ||
| throw new Error("500 - " + language_1.Language.GetResource().job_status_error); | ||
| } | ||
| return [2 /*return*/]; | ||
| } | ||
| }); | ||
| }); }; | ||
| /** | ||
| * Calls consent-prompt event handler or shows SDK consent overlay | ||
| * @param consentCode Randomly generated consent code | ||
| */ | ||
| this.showConsentCode = function (consentCode) { | ||
| if (_this.eventHandlers.has(constants_1.Constants.CONSENT_PROMPT)) { | ||
| _this.eventHandlers.dispatch(constants_1.Constants.CONSENT_PROMPT, consentCode); | ||
| } | ||
| else { | ||
| utils_1.HtmlUtil.showConsentOverlay(consentCode, _this.settings.portNumber); | ||
| } | ||
| }; | ||
| /** | ||
| * Calls 'missing-components' event handler or shows SDK error overlay | ||
| */ | ||
| this.showMissingComponents = function () { | ||
| if (_this.eventHandlers.has(constants_1.Constants.MISSING_COMPONENTS)) { | ||
| _this.eventHandlers.dispatch(constants_1.Constants.MISSING_COMPONENTS); | ||
| } | ||
| else { | ||
| utils_1.HtmlUtil.showErrorOverlay(); | ||
| } | ||
| _this.trace(traceEvent_1.TraceEvent.Missing_Components, {}); | ||
| }; | ||
| this.trace = function (event, properties) { | ||
| if (!_this.settings.disableTelemetry) { | ||
| _this.logger.trace(event, properties, _this.settings.appOrigin); | ||
| } | ||
| }; | ||
| this.traceError = function (event, error) { | ||
| if (!_this.settings.disableTelemetry) { | ||
| _this.logger.traceError(event, error, _this.settings.appOrigin); | ||
| } | ||
| }; | ||
| this.robotInvocationPort = 0; | ||
| this.consentCode = 0; | ||
| this.settings = new models_1.Settings(constants_1.Constants.DEFAULT_PORT, constants_1.Constants.POLL_TIMEINTERVAL, false); | ||
| this.eventHandlers = new utils_1.Dispatcher(); | ||
| this.logger = new appinsightsLogger_1.AppInsightsLogger(); | ||
| this.serverFeatures = new models_1.ServerFeatures([]); | ||
| this.initializePortMutex = new async_mutex_1.Mutex(); | ||
| } | ||
| return RobotSDK; | ||
| }()); | ||
| var robotSDK = new RobotSDK(); | ||
| /** | ||
| * Class to restrict exposing other private methods in RobotSDK object. | ||
| */ | ||
| var SDK = /** @class */ (function () { | ||
| function SDK() { | ||
| var _this = this; | ||
| /** | ||
| * Init method set custom consent code handling. | ||
| * @returns {IRobotSDK} instance | ||
| */ | ||
| this.init = function () { return _this; }; | ||
| /** | ||
| * Method to retrieve all published robot processes on users local machine. | ||
| * @returns Deferred promise of type RobotProcess[] which will be resolved/rejected based on http response. | ||
| */ | ||
| this.getProcesses = function () { return robotSDK.getProcesses(); }; | ||
| /** | ||
| * Method to attach event handlers on the SDK. | ||
| * @param eventName Available SDK events are 'consent-prompt', 'missing-components'. | ||
| * @param eventHanlder Event handler callback function called when event occurs. | ||
| */ | ||
| this.on = function (eventName, eventHanlder) { return robotSDK.on(eventName, eventHanlder); }; | ||
| /** | ||
| * Method to invoke a robot process. | ||
| * @param job Job object containing all information about the robot process to run. | ||
| * @returns Deferred promise which is resolved with job result when robot process completes. | ||
| */ | ||
| this.startJob = function (job) { return robotSDK.startJob(job); }; | ||
| /** | ||
| * Method to stop an executing/running robot process. | ||
| * @param process RobotProcess object containing all information about the robot process to stop. | ||
| * @returns Deferred promise which is resolved with job result when robot process is cancelled. | ||
| */ | ||
| this.stopProcess = function (process) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
| return [2 /*return*/, robotSDK.stopProcess(process)]; | ||
| }); }); }; | ||
| /** | ||
| * Method to install a process. | ||
| * @param processId Process Id of the robot process to install. | ||
| */ | ||
| this.installProcess = function (processId) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
| return [2 /*return*/, robotSDK.installProcess(processId)]; | ||
| }); }); }; | ||
| } | ||
| Object.defineProperty(SDK.prototype, "settings", { | ||
| /** | ||
| * SDK settings | ||
| */ | ||
| get: function () { | ||
| return robotSDK.settings; | ||
| }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| return SDK; | ||
| }()); | ||
| exports.SDK = SDK; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.UiPathRobot = void 0; | ||
| var traceEvent_1 = require("./enums/traceEvent"); | ||
| var models_1 = require("./models"); | ||
| var robotSDK_1 = require("./sdk/robotSDK"); | ||
| var appinsightsLogger_1 = require("./utils/logger/appinsightsLogger"); | ||
| /** | ||
| * Browser invocation javascript SDK module. Accessible as UiPathRobot from browser console. | ||
| */ | ||
| var UiPathRobot; | ||
| (function (UiPathRobot) { | ||
| var robotSDK = new robotSDK_1.SDK(); | ||
| /** | ||
| * Settings object to change default SDK settings | ||
| * @returns {Settings} | ||
| */ | ||
| UiPathRobot.settings = robotSDK.settings; | ||
| /** | ||
| * On page load analytics | ||
| */ | ||
| document.addEventListener('readystatechange', function () { | ||
| if (document.readyState === 'complete') { | ||
| var logger = new appinsightsLogger_1.AppInsightsLogger(); | ||
| if (!UiPathRobot.settings.disableTelemetry) { | ||
| logger.tracePage(); | ||
| logger.trace(traceEvent_1.TraceEvent.SDK_Loaded, {}, robotSDK.settings.appOrigin); | ||
| } | ||
| } | ||
| }); | ||
| /** | ||
| * Init method set custom consent code handling. | ||
| * @returns {IRobotSDK} instance | ||
| */ | ||
| UiPathRobot.init = function () { return robotSDK.init(); }; | ||
| /** | ||
| * Method to retrieve all published robot processes on users local machine. | ||
| * @returns Deferred promise of type RobotProcess[] which will be resolved/rejected based on http response. | ||
| */ | ||
| UiPathRobot.getProcesses = function () { return robotSDK.getProcesses(); }; | ||
| /** | ||
| * Method to attach event handlers on the SDK. | ||
| * @param eventName Available SDK events are 'consent-prompt', 'missing-components'. | ||
| * @param eventHanlder Event handler callback function called when event occurs. | ||
| */ | ||
| UiPathRobot.on = function (eventName, eventHanlder) { return robotSDK.on(eventName, eventHanlder); }; | ||
| /** | ||
| * Method to invoke a robot process. | ||
| * @param job Job object containing all information about the robot process to run. | ||
| * @returns Deferred promise which is resolved with job result when robot process completes. | ||
| */ | ||
| UiPathRobot.startJob = function (job) { return robotSDK.startJob(job); }; | ||
| /** | ||
| * Method to create a robot Job. | ||
| * @param processId Process Id of the robot process to run. | ||
| * @param argument Input parameters. | ||
| * @returns Deferred promise which is resolved with job result when robot process completes. | ||
| */ | ||
| UiPathRobot.createJob = function (processId, argument) { return new models_1.Job(processId, argument); }; | ||
| /** | ||
| * Method to stop a robot process. | ||
| * @param process Robotprocess object containing all information about the robot process to cancel. | ||
| * @returns Deferred promise which is resolved when robot process is cancelled. | ||
| */ | ||
| UiPathRobot.stopProcess = function (process) { return robotSDK.stopProcess(process); }; | ||
| /** | ||
| * Method to install a process. | ||
| * @param processId Process Id of the robot process to install. | ||
| */ | ||
| UiPathRobot.installProcess = function (processId) { return robotSDK.installProcess(processId); }; | ||
| })(UiPathRobot = exports.UiPathRobot || (exports.UiPathRobot = {})); | ||
| window.UiPathRobot = UiPathRobot; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Constants = void 0; | ||
| var Constants = /** @class */ (function () { | ||
| function Constants() { | ||
| } | ||
| Constants.GET_PORT = 'GetPort'; | ||
| Constants.GET_ROBOT_PROCESSES = 'RobotProcesses'; | ||
| Constants.GET_JOB_STATUS = 'JobStatus'; | ||
| Constants.INVOKE_ROBOT = 'InvokeRobot'; | ||
| Constants.INSTALL_PROCESS = 'InstallProcess'; | ||
| Constants.DEFAULT_ROBOT_INVOKE_DOMAIN = 'http://localhost'; | ||
| Constants.DEFAULT_PORT_DISCOVERY_DOMAIN = 'http://localhost'; | ||
| Constants.DEFAULT_PORT = 2323; | ||
| Constants.UIPATH_PROTOCOL = 'uipath-web'; | ||
| Constants.POLL_TIMEOUT = 60000; | ||
| Constants.POLL_TIMEINTERVAL = 250; | ||
| Constants.HTTP_UNAUTHORIZED = 401; | ||
| Constants.UIPATH_CONSENTOVERLAY_ID = 'uipathConsentOverlay'; | ||
| Constants.UIPATH_CONSENTDIALOG_ID = 'uipathConsentFrame'; | ||
| Constants.CONSENT_PROMPT = 'consent-prompt'; | ||
| Constants.MISSING_COMPONENTS = 'missing-components'; | ||
| Constants.STATUS = 'status'; | ||
| Constants.WORKFLOW_EVENT = 'workflow-event'; | ||
| Constants.UIPATH_TOKEN = 'uipathToken'; | ||
| Constants.STOP_PROCESS = 'StopProcess'; | ||
| return Constants; | ||
| }()); | ||
| exports.Constants = Constants; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Deferred = void 0; | ||
| /** | ||
| * Deferred promise class. | ||
| */ | ||
| var Deferred = /** @class */ (function () { | ||
| function Deferred() { | ||
| var _this = this; | ||
| this.resolve = function (value) { return _this._resolve(value); }; | ||
| this.reject = function (reason) { return _this._reject(reason); }; | ||
| this._promise = new Promise(function (resolve, reject) { | ||
| _this._resolve = resolve; | ||
| _this._reject = reject; | ||
| }); | ||
| } | ||
| Object.defineProperty(Deferred.prototype, "promise", { | ||
| get: function () { | ||
| return this._promise; | ||
| }, | ||
| enumerable: false, | ||
| configurable: true | ||
| }); | ||
| return Deferred; | ||
| }()); | ||
| exports.Deferred = Deferred; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Dispatcher = void 0; | ||
| /** | ||
| * Dispatcher class to allow event handling on custom classes. | ||
| */ | ||
| var Dispatcher = /** @class */ (function () { | ||
| function Dispatcher() { | ||
| var _this = this; | ||
| /** | ||
| * Method to determine if a certain event has been registered. | ||
| * @returns Boolean result | ||
| */ | ||
| this.has = function (eventName) { return _this.dispatchHandlers.has(eventName); }; | ||
| this.dispatchHandlers = new Map(); | ||
| } | ||
| /** | ||
| * Event registration method. | ||
| * @param eventName Name of the event to register. | ||
| * @param handler callback function to call when the event occurs. | ||
| */ | ||
| Dispatcher.prototype.on = function (eventName, handler) { | ||
| var allHandlers = this.dispatchHandlers.get(eventName); | ||
| if (allHandlers && this.dispatchHandlers.has(eventName)) { | ||
| allHandlers.push(handler); | ||
| } | ||
| else { | ||
| this.dispatchHandlers.set(eventName, [handler]); | ||
| } | ||
| }; | ||
| /** | ||
| * Dispatch method to dispatch registered callbacks on the occuring event. | ||
| * @param eventName Name of the event that has occured. | ||
| * @param argument Arguments to pass to callback if any. | ||
| */ | ||
| Dispatcher.prototype.dispatch = function (eventName, argument) { | ||
| var _this = this; | ||
| var allHandlers = this.dispatchHandlers.get(eventName); | ||
| if (allHandlers && this.dispatchHandlers.has(eventName)) { | ||
| allHandlers.forEach(function (handler) { | ||
| handler.apply(_this, [argument]); | ||
| }); | ||
| } | ||
| }; | ||
| return Dispatcher; | ||
| }()); | ||
| exports.Dispatcher = Dispatcher; |
Sorry, the diff of this file is too big to display
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.HttpUtil = void 0; | ||
| /** | ||
| * XMLHttpRequest module used to send Http requests to listeners. | ||
| */ | ||
| var models_1 = require("../models"); | ||
| var constants_1 = require("../utils/constants"); | ||
| var HttpUtil = /** @class */ (function () { | ||
| function HttpUtil() { | ||
| } | ||
| /** | ||
| * HttpGet method. | ||
| * @param url Endpoint to hit. | ||
| * @param transform Method to transform http response string to desired object. | ||
| */ | ||
| HttpUtil.get = function (url, transform) { | ||
| return HttpUtil.httpRequest(url, transform, 'GET'); | ||
| }; | ||
| /** | ||
| * HttpPost method. | ||
| * @param url Endpoint to hit. | ||
| * @param transform Method to transform http response string to desired object. | ||
| * @param data Data to post. | ||
| */ | ||
| HttpUtil.post = function (url, transform, data) { | ||
| return HttpUtil.httpRequest(url, transform, 'POST', data); | ||
| }; | ||
| HttpUtil.httpRequest = function (url, transform, method, data) { | ||
| var _this = this; | ||
| var request = new XMLHttpRequest(); | ||
| return new Promise(function (resolve, reject) { | ||
| request.onreadystatechange = function () { | ||
| if (request.readyState !== 4) { | ||
| return; | ||
| } | ||
| resolve(new models_1.Response(request.status, request.statusText, transform(this.response), HttpUtil.errorResponse(this.response))); | ||
| HttpUtil.persistTokentoLocalStorage(request); | ||
| }; | ||
| request.onerror = function () { | ||
| reject(new models_1.Response(request.status, request.statusText)); | ||
| HttpUtil.persistTokentoLocalStorage(request); | ||
| }; | ||
| request.open(method, url, true); | ||
| request.withCredentials = true; | ||
| _this.addTokenToHeader(request); | ||
| if (data) { | ||
| request.send(data); | ||
| } | ||
| else { | ||
| request.send(); | ||
| } | ||
| }); | ||
| }; | ||
| /** | ||
| * Converts response data into error model if the call failed safely. | ||
| * @param httpResponse response data | ||
| */ | ||
| HttpUtil.errorResponse = function (httpResponse) { | ||
| if (httpResponse) { | ||
| var jsonResponse = JSON.parse(httpResponse).response; | ||
| if (jsonResponse && jsonResponse.Error) { | ||
| return jsonResponse.Error; | ||
| } | ||
| } | ||
| return ''; | ||
| }; | ||
| /** | ||
| * Checks for existing token in local storage and adds it to outgoing request headers. | ||
| * @param request The request to which the token will be added as header. | ||
| */ | ||
| HttpUtil.addTokenToHeader = function (request) { | ||
| var token = window.localStorage.getItem(constants_1.Constants.UIPATH_TOKEN); | ||
| if (token) { | ||
| request.setRequestHeader(constants_1.Constants.UIPATH_TOKEN, token); | ||
| } | ||
| }; | ||
| /** | ||
| * Reads all response headers if token is present, sets token to local storage. | ||
| * @param request request containing the response headers. | ||
| */ | ||
| HttpUtil.persistTokentoLocalStorage = function (request) { | ||
| var allHeaders = request.getAllResponseHeaders(); | ||
| if (allHeaders.indexOf(constants_1.Constants.UIPATH_TOKEN)) { | ||
| var token = request.getResponseHeader(constants_1.Constants.UIPATH_TOKEN); | ||
| if (token) { | ||
| window.localStorage.removeItem(constants_1.Constants.UIPATH_TOKEN); | ||
| window.localStorage.setItem(constants_1.Constants.UIPATH_TOKEN, token); | ||
| } | ||
| } | ||
| }; | ||
| return HttpUtil; | ||
| }()); | ||
| exports.HttpUtil = HttpUtil; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./deferred"), exports); | ||
| __exportStar(require("./dispatcher"), exports); | ||
| __exportStar(require("./htmlUtil"), exports); | ||
| __exportStar(require("./httpUtil"), exports); | ||
| __exportStar(require("./pollUtil"), exports); | ||
| __exportStar(require("./protocolUtil"), exports); | ||
| __exportStar(require("./randomUtil"), exports); | ||
| __exportStar(require("./urlUtil"), exports); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.AppInsightsLogger = void 0; | ||
| var applicationinsights_web_1 = require("@microsoft/applicationinsights-web"); | ||
| var version_1 = require("../../version"); | ||
| /** | ||
| * Appinsights logger. Stops logging for locally hosted files as file path might contain user info. | ||
| */ | ||
| var AppInsightsLogger = /** @class */ (function () { | ||
| function AppInsightsLogger() { | ||
| var _this = this; | ||
| this.appInsights = new applicationinsights_web_1.ApplicationInsights({ | ||
| config: { | ||
| instrumentationKey: process.env.NODE_ENV === 'production' ? '025bfd02-04e8-4969-8293-94a1ec738e4e' : '45d1ba3e-f027-4fb0-a1cc-d6874a40ec00', | ||
| }, | ||
| }); | ||
| /** | ||
| * Trace event method | ||
| * @param event event name | ||
| * @param properties properties to log along with the event. | ||
| */ | ||
| this.trace = function (event, properties, appName) { | ||
| if (window.location.protocol !== 'file:') { | ||
| _this.appInsights.trackEvent({ name: event.toString(), properties: { application: appName, version: version_1.ROBOTJS_VERSION } }, properties); | ||
| } | ||
| }; | ||
| /** | ||
| * Tracing error | ||
| * @param event event name | ||
| * @param error Error to trace. | ||
| */ | ||
| this.traceError = function (event, error, appName) { | ||
| if (window.location.protocol !== 'file:') { | ||
| _this.appInsights.trackException({ | ||
| properties: { method: event.toString(), application: appName, version: version_1.ROBOTJS_VERSION }, | ||
| exception: new Error(error), | ||
| }); | ||
| } | ||
| }; | ||
| /** | ||
| * Tracing page | ||
| */ | ||
| this.tracePage = function () { | ||
| if (window.location.protocol !== 'file:') { | ||
| _this.appInsights.trackPageView(); | ||
| } | ||
| }; | ||
| if (window.location.protocol !== 'file:') { | ||
| this.appInsights.loadAppInsights(); | ||
| } | ||
| } | ||
| return AppInsightsLogger; | ||
| }()); | ||
| exports.AppInsightsLogger = AppInsightsLogger; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.PollUtil = void 0; | ||
| var language_1 = require("../locale/language"); | ||
| /** | ||
| * Poll a particular function until a specified interval/timeout. | ||
| */ | ||
| var PollUtil = /** @class */ (function () { | ||
| function PollUtil() { | ||
| } | ||
| /** | ||
| * Method used for polling. | ||
| * @param fn Function that needs to be polled. | ||
| * @param timeout Time after which the polling will stop. | ||
| * @param interval Time difference between calls while polling. | ||
| */ | ||
| PollUtil.poll = function (fn, timeout, interval) { | ||
| var endTime = Number(new Date()) + (timeout || 2000); | ||
| interval = interval || 1000; | ||
| var checkCondition = function (resolve, reject) { | ||
| fn() | ||
| .then(function (response) { | ||
| resolve(response); | ||
| }) | ||
| .catch(function (error) { | ||
| var message = error.message; | ||
| if (message && message.indexOf('403') > -1) { | ||
| reject(new Error("403 - " + language_1.Language.GetResource().consent_rejected)); | ||
| } | ||
| else if (Number(new Date()) < endTime) { | ||
| setTimeout(checkCondition, interval, resolve, reject); | ||
| } | ||
| else { | ||
| reject(new Error("408 - " + language_1.Language.GetResource().timed_out)); | ||
| } | ||
| }); | ||
| }; | ||
| return new Promise(checkCondition); | ||
| }; | ||
| return PollUtil; | ||
| }()); | ||
| exports.PollUtil = PollUtil; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ProtocolUtil = void 0; | ||
| var constants_1 = require("./constants"); | ||
| /** | ||
| * Protocol util to open consent window application | ||
| */ | ||
| var ProtocolUtil = /** @class */ (function () { | ||
| function ProtocolUtil() { | ||
| } | ||
| ProtocolUtil.openUiPathProtocol = function (consentCode) { | ||
| var url = constants_1.Constants.UIPATH_PROTOCOL + "://consentCode=" + consentCode + "&Origin=" + window.location.origin; | ||
| window.location.href = url; | ||
| }; | ||
| return ProtocolUtil; | ||
| }()); | ||
| exports.ProtocolUtil = ProtocolUtil; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.RandomUtil = void 0; | ||
| /** | ||
| * Module to generate a random number. | ||
| */ | ||
| var RandomUtil = /** @class */ (function () { | ||
| function RandomUtil() { | ||
| } | ||
| /** | ||
| * Function to generate a random number. Range if not specified is capped between 100001-999999. | ||
| * @param min Min value (included) which the random number can take. | ||
| * @param max Max value (included) which the random number can take. | ||
| */ | ||
| RandomUtil.getRandomNumber = function (min, max) { | ||
| min = min || 100001; | ||
| max = max || 999999; | ||
| return Math.floor(Math.random() * (max - min + 1)) + min; | ||
| }; | ||
| return RandomUtil; | ||
| }()); | ||
| exports.RandomUtil = RandomUtil; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.UrlUtil = void 0; | ||
| /** | ||
| * Url utility that adds consent code to url as query parameter. | ||
| */ | ||
| var UrlUtil = /** @class */ (function () { | ||
| function UrlUtil() { | ||
| } | ||
| /** | ||
| * Method that adds consent code to url as query parameter if needed. | ||
| * @param url URL to which the consent code query parameter needs to be appended. | ||
| * @param consentCode consent code that was randomly generated. | ||
| */ | ||
| UrlUtil.appendConsentCode = function (url, consentCode) { | ||
| return consentCode !== 0 ? | ||
| url.indexOf('?') > 0 ? url + "&consentCode=" + consentCode : url + "?consentCode=" + consentCode : | ||
| url; | ||
| }; | ||
| return UrlUtil; | ||
| }()); | ||
| exports.UrlUtil = UrlUtil; |
| export declare const ROBOTJS_VERSION = "1.2.7"; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ROBOTJS_VERSION = void 0; | ||
| exports.ROBOTJS_VERSION = '1.2.7'; |
| var fs = require('file-system'); | ||
| const version = JSON.parse(fs.readFileSync('package.json')).version; | ||
| fs.writeFile('./src/version.ts', `export const ROBOTJS_VERSION = '${version}';`); |
@@ -12,3 +12,4 @@ export declare enum TraceEvent { | ||
| Consent_Timeout = "ConsentTimeout", | ||
| Stop_Process = "StopProcess" | ||
| Stop_Process = "StopProcess", | ||
| Install_Process = "InstallProcess" | ||
| } |
+24
-19
@@ -1,2 +0,2 @@ | ||
| import { Job, JobResult, RobotProcess, Settings } from './models'; | ||
| import { InstallProcessResult, Job, JobResult, RobotProcess, Settings } from './models'; | ||
| /** | ||
@@ -11,29 +11,34 @@ * UiPath Robot SDK | ||
| /** | ||
| * Method to retrieve all published robot processes on users local machine. | ||
| * @returns Deferred promise of type RobotProcess[] which will be resolved/rejected based on http response. | ||
| */ | ||
| * Method to retrieve all published robot processes on users local machine. | ||
| * @returns Deferred promise of type RobotProcess[] which will be resolved/rejected based on http response. | ||
| */ | ||
| getProcesses(): Promise<Array<RobotProcess>>; | ||
| /** | ||
| * Init method set custom consent code handling. | ||
| * @returns {IRobotSDK} instance | ||
| */ | ||
| * Init method set custom consent code handling. | ||
| * @returns {IRobotSDK} instance | ||
| */ | ||
| init(): IRobotSDK; | ||
| /** | ||
| * Method to attach event handlers on the SDK. | ||
| * @param eventName Available SDK events are 'consent-prompt', 'missing-components'. | ||
| * @param eventHanlder Event handler callback function called when event occurs. | ||
| */ | ||
| * Method to attach event handlers on the SDK. | ||
| * @param eventName Available SDK events are 'consent-prompt', 'missing-components'. | ||
| * @param eventHanlder Event handler callback function called when event occurs. | ||
| */ | ||
| on(eventName: string, callback: (argument?: any) => void): void; | ||
| /** | ||
| * Method to invoke a robot process. | ||
| * @param job Job object containing all information about the robot process to run. | ||
| * @returns Deferred promise which is resolved with job result when robot process completes. | ||
| */ | ||
| * Method to invoke a robot process. | ||
| * @param job Job object containing all information about the robot process to run. | ||
| * @returns Deferred promise which is resolved with job result when robot process completes. | ||
| */ | ||
| startJob(job: Job): Promise<JobResult>; | ||
| /** | ||
| * Method to stop an executing robot process. | ||
| * @param process Executing/Running RobotProcess object that needs to be stopped. | ||
| * @returns Deferred promise which is resolved when robot process is cancelled. | ||
| */ | ||
| * Method to stop an executing robot process. | ||
| * @param process Executing/Running RobotProcess object that needs to be stopped. | ||
| * @returns Deferred promise which is resolved when robot process is cancelled. | ||
| */ | ||
| stopProcess(process: RobotProcess): Promise<void>; | ||
| /** | ||
| * Method to install a process. | ||
| * @param processId Process key which identifies the process. | ||
| */ | ||
| installProcess(processId: string): Promise<InstallProcessResult>; | ||
| } |
@@ -8,1 +8,6 @@ export * from './job'; | ||
| export * from './settings'; | ||
| export * from './serverFeatures'; | ||
| export * from './portResponse'; | ||
| export * from './workflowEventData'; | ||
| export * from './inputArgumentSchema'; | ||
| export * from './installProcessResult'; |
@@ -0,1 +1,2 @@ | ||
| import { WorkflowEventData } from '.'; | ||
| /** | ||
@@ -17,3 +18,3 @@ * Job model used to identify a running/completed Robot process | ||
| * Method to attach event handler on the job. | ||
| * @param eventName Available job events are 'status'. | ||
| * @param eventName Available job events are: 'status', 'workflow-event'. | ||
| * @param eventHanlder Event handler callback function called when event occurs. | ||
@@ -27,2 +28,7 @@ */ | ||
| dispatch: (status: string) => void; | ||
| /** | ||
| * Dispatch method to trigger events. | ||
| * @param event argument to pass along while event is dispatched. | ||
| */ | ||
| dispatchEvent: (eventData: WorkflowEventData) => void; | ||
| } |
| import { Job, JobResult } from './index'; | ||
| import { WorkflowEventData } from './workflowEventData'; | ||
| /** | ||
@@ -22,2 +23,7 @@ * Job promise model used for resolution and/or rejection of Promise<JobResult> | ||
| onStatus: (eventHanlder: (argument?: any) => void) => this; | ||
| /** | ||
| * Method to attach job workflow event handlers. | ||
| * @param eventHandler Attaches callback which is invoked on job workflow event. | ||
| */ | ||
| onWorkflowEvent: (eventHandler: (argument: WorkflowEventData) => void) => this; | ||
| } |
@@ -0,3 +1,4 @@ | ||
| import { WorkflowEventData } from './workflowEventData'; | ||
| /** | ||
| * Job status model containings details of the executing job. | ||
| * Job status model containing details of the executing job. | ||
| */ | ||
@@ -7,2 +8,3 @@ export declare class JobStatus { | ||
| status: string[]; | ||
| events: WorkflowEventData[]; | ||
| output: any; | ||
@@ -14,9 +16,10 @@ exception: any; | ||
| * @param status Current status of the job | ||
| * @param events Workflow events sent by the job | ||
| * @param output Output of the job if any | ||
| * @param exception Exception from the job if any | ||
| */ | ||
| constructor(state: string, status: string[], output: any, exception: any); | ||
| readonly isExecuting: boolean; | ||
| readonly isClosed: boolean; | ||
| readonly errorResponse: any; | ||
| constructor(state: string, status: string[], events: WorkflowEventData[], output: any, exception: any); | ||
| get isExecuting(): boolean; | ||
| get isClosed(): boolean; | ||
| get errorResponse(): any; | ||
| } |
@@ -18,7 +18,7 @@ import { Deferred } from '../utils'; | ||
| constructor(httpStatus: number, statusText: string, data?: T | undefined, error?: string | undefined); | ||
| readonly isSuccess: boolean; | ||
| readonly isUnauthorized: boolean; | ||
| readonly isForbidden: boolean; | ||
| readonly isEmpty: boolean; | ||
| readonly isNotFound: boolean; | ||
| get isSuccess(): boolean; | ||
| get isUnauthorized(): boolean; | ||
| get isForbidden(): boolean; | ||
| get isEmpty(): boolean; | ||
| get isNotFound(): boolean; | ||
| /** | ||
@@ -25,0 +25,0 @@ * Resolve promise if its a successful response. Throws error if response was unsuccessful. |
| import { JobPromise } from '../models'; | ||
| import { InstallProcessResult } from './installProcessResult'; | ||
| /** | ||
@@ -8,2 +9,3 @@ * Robot process model containing details of the robot process available in current system | ||
| name: string; | ||
| description: string | undefined; | ||
| /** | ||
@@ -13,4 +15,5 @@ * Default constructor | ||
| * @param name Robot Process name | ||
| * @param description Process Description | ||
| */ | ||
| constructor(id: string, name: string); | ||
| constructor(id: string, name: string, description?: string | undefined); | ||
| /** | ||
@@ -21,2 +24,6 @@ * Start the robot process | ||
| start: (inArguments?: any) => JobPromise; | ||
| /** | ||
| * Install the robot process | ||
| */ | ||
| install: () => Promise<InstallProcessResult>; | ||
| } |
@@ -6,1 +6,2 @@ export * from './invokeRobotRequest'; | ||
| export * from './stopProcessRequest'; | ||
| export * from './installProcessRequest'; |
@@ -1,2 +0,2 @@ | ||
| import { Response } from '../../models/index'; | ||
| import { Response, PortResponse } from '../../models/index'; | ||
| /** | ||
@@ -17,3 +17,3 @@ * Request class to get port of listener running on local user session. | ||
| */ | ||
| getPort: () => Promise<Response<number>>; | ||
| getPort: () => Promise<Response<PortResponse>>; | ||
| /** | ||
@@ -20,0 +20,0 @@ * Mapper method used to convert string response to number. |
@@ -13,3 +13,3 @@ import { Response, RobotProcess } from '../../models'; | ||
| */ | ||
| send: () => Promise<Response<RobotProcess[]>>; | ||
| send: () => Promise<Response<Array<RobotProcess>>>; | ||
| /** | ||
@@ -16,0 +16,0 @@ * Set the port to which the request should be sent along with the consent code. |
| import { IRobotSDK } from '../iRobotSDK'; | ||
| import { Job, JobResult, RobotProcess, Settings } from '../models'; | ||
| import { Job, JobResult, RobotProcess, Settings, InstallProcessResult } from '../models'; | ||
| /** | ||
@@ -10,3 +10,3 @@ * Class to restrict exposing other private methods in RobotSDK object. | ||
| */ | ||
| readonly settings: Settings; | ||
| get settings(): Settings; | ||
| /** | ||
@@ -35,7 +35,12 @@ * Init method set custom consent code handling. | ||
| /** | ||
| * Method to stop an executing/running robot process. | ||
| * @param process RobotProcess object containing all information about the robot process to stop. | ||
| * @returns Deferred promise which is resolved with job result when robot process is cancelled. | ||
| */ | ||
| * Method to stop an executing/running robot process. | ||
| * @param process RobotProcess object containing all information about the robot process to stop. | ||
| * @returns Deferred promise which is resolved with job result when robot process is cancelled. | ||
| */ | ||
| stopProcess: (process: RobotProcess) => Promise<void>; | ||
| /** | ||
| * Method to install a process. | ||
| * @param processId Process Id of the robot process to install. | ||
| */ | ||
| installProcess: (processId: string) => Promise<InstallProcessResult>; | ||
| } |
| import { IRobotSDK } from './iRobotSDK'; | ||
| import { Job, JobResult, RobotProcess, Settings } from './models'; | ||
| import { Job, JobResult, RobotProcess, InstallProcessResult } from './models'; | ||
| /** | ||
@@ -11,3 +11,3 @@ * Browser invocation javascript SDK module. Accessible as UiPathRobot from browser console. | ||
| */ | ||
| const settings: Settings; | ||
| const settings: import("./models").Settings; | ||
| /** | ||
@@ -48,2 +48,7 @@ * Init method set custom consent code handling. | ||
| const stopProcess: (process: RobotProcess) => Promise<void>; | ||
| /** | ||
| * Method to install a process. | ||
| * @param processId Process Id of the robot process to install. | ||
| */ | ||
| const installProcess: (processId: string) => Promise<InstallProcessResult>; | ||
| } |
@@ -6,3 +6,3 @@ export declare class Constants { | ||
| static readonly INVOKE_ROBOT = "InvokeRobot"; | ||
| static readonly UIPATH_EDITION = "UiPathEdition"; | ||
| static readonly INSTALL_PROCESS = "InstallProcess"; | ||
| static readonly DEFAULT_ROBOT_INVOKE_DOMAIN = "http://localhost"; | ||
@@ -20,4 +20,5 @@ static readonly DEFAULT_PORT_DISCOVERY_DOMAIN = "http://localhost"; | ||
| static readonly STATUS = "status"; | ||
| static readonly WORKFLOW_EVENT = "workflow-event"; | ||
| static readonly UIPATH_TOKEN = "uipathToken"; | ||
| static readonly STOP_PROCESS = "StopProcess"; | ||
| } |
@@ -9,5 +9,5 @@ /** | ||
| constructor(); | ||
| readonly promise: Promise<T>; | ||
| get promise(): Promise<T>; | ||
| resolve: (value?: T | PromiseLike<T> | undefined) => void; | ||
| reject: (reason?: any) => void; | ||
| } |
+5
-4
| { | ||
| "name": "@uipath/robot", | ||
| "version": "1.2.6", | ||
| "version": "1.2.7", | ||
| "description": "UiPath Robot javascript SDK enabling web pages to interact with UiPath Robots", | ||
| "scripts": { | ||
| "build:prod": "tsc && webpack --mode production -p --config webpack.config.js", | ||
| "build": "tsc && webpack --mode development --config webpack.config.js", | ||
| "prebuild": "node genversion.js", | ||
| "build": "tsc && webpack --mode production -p --config webpack.config.js", | ||
| "clean": "tsc --build --clean", | ||
@@ -24,3 +24,4 @@ "pack": "npm pack" | ||
| "dependencies": { | ||
| "@microsoft/applicationinsights-web": "^2.5.9" | ||
| "@microsoft/applicationinsights-web": "^2.5.9", | ||
| "async-mutex": "^0.3.2" | ||
| }, | ||
@@ -27,0 +28,0 @@ "main": "dist/uipathRobot.js", |
+1
-27
@@ -1,2 +0,2 @@ | ||
| <img src="https://raw.githubusercontent.com/UiPath/angular-components/master/logo.png" width="135" /> | ||
| <img src="https://raw.githubusercontent.com/UiPath/angular-components/master/logo.png" width="135" /> | ||
@@ -11,24 +11,2 @@ # UiPath Robot Javascript SDK | ||
| ## Installation | ||
| ### In the Browser | ||
| To use the SDK in the browser, simply add the following script tag to your | ||
| HTML pages: | ||
| <script src="//download.uipath.com/js/1.2.6/UiPathRobot.js"></script> | ||
| ### In Node.js | ||
| The preferred way to install the UiPath SDK for Node.js is to use the | ||
| [npm](http://npmjs.org) package manager for Node.js. Simply type the following | ||
| into a terminal window: | ||
| ```sh | ||
| npm install @uipath/robot | ||
| ``` | ||
| [](https://www.npmjs.com/package/@uipath/robot) | ||
| ## Browser Support | ||
@@ -45,4 +23,2 @@ | ||
| To download our add-on separately, visit [here](https://robotjs.uipath.com/download). | ||
| For a brief overview about how to use the robot SDK, visit [here](https://docs.uipath.com/robot/docs/about-the-robot-javascript-sdk). | ||
@@ -54,4 +30,2 @@ | ||
| For troubleshooting common problems, visit [here](https://robotjs.uipath.com/help). | ||
| ## License | ||
@@ -58,0 +32,0 @@ |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Network access
Supply chain riskThis module accesses the network.
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
125
95.31%8
-91.4%6
-95.49%520224
-46.67%2
100%3771
-13.33%3
50%33
-44.07%+ Added
+ Added