Sign In

@uipath/robot

Package Overview
Dependencies
Maintainers
25
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uipath/robot - npm Package Compare versions

Comparing version
1.2.8
to
1.2.9
+8
dist/models/jobArguments.d.ts
/**
* JobArguments sent with the InvokeRobot Request.
*/
export declare class JobArguments {
inputArgs: any;
internalArgs?: string | undefined;
constructor(inputArgs: any, internalArgs?: string | undefined);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JobArguments = void 0;
/**
* JobArguments sent with the InvokeRobot Request.
*/
var JobArguments = /** @class */ (function () {
function JobArguments(inputArgs, internalArgs) {
this.inputArgs = inputArgs;
this.internalArgs = internalArgs;
}
return JobArguments;
}());
exports.JobArguments = JobArguments;
+0
-1

@@ -9,3 +9,2 @@ export declare enum TraceEvent {

User_Consent_Raised = "UserConsentRaised",
SDK_Loaded = "SDKLoaded",
Missing_Components = "MissingComponents",

@@ -12,0 +11,0 @@ Consent_Timeout = "ConsentTimeout",

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

TraceEvent["User_Consent_Raised"] = "UserConsentRaised";
TraceEvent["SDK_Loaded"] = "SDKLoaded";
TraceEvent["Missing_Components"] = "MissingComponents";

@@ -16,0 +15,0 @@ TraceEvent["Consent_Timeout"] = "ConsentTimeout";

@@ -9,2 +9,3 @@ import { WorkflowEventData } from '.';

jobId: string;
internalArguments?: string;
private eventHandlers;

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

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

var constants_1 = require("../utils/constants");
var uuid_1 = require("uuid");
/**

@@ -30,3 +31,3 @@ * Job model used to identify a running/completed Robot process

this.dispatchEvent = function (eventData) { return _this.eventHandlers.dispatch(constants_1.Constants.WORKFLOW_EVENT, eventData); };
this.jobId = '';
this.jobId = uuid_1.v4();
this.processId = processId;

@@ -33,0 +34,0 @@ this.argument = argument;

@@ -8,2 +8,3 @@ import { Deferred } from '../utils';

statusText: string;
isDomainAllowed: boolean;
data?: T | undefined;

@@ -15,6 +16,7 @@ error?: string | undefined;

* @param statusText Http status text of the response
* @param data response data if any
* @param isDomainAllowed Flag returned by the Server, saying if the domain is allowed by configuration
* @param data Response data if any
* @param error Handled error response if any
*/
constructor(httpStatus: number, statusText: string, data?: T | undefined, error?: string | undefined);
constructor(httpStatus: number, statusText: string, isDomainAllowed: boolean, data?: T | undefined, error?: string | undefined);
get isSuccess(): boolean;

@@ -21,0 +23,0 @@ get isUnauthorized(): boolean;

@@ -12,9 +12,11 @@ "use strict";

* @param statusText Http status text of the response
* @param data response data if any
* @param isDomainAllowed Flag returned by the Server, saying if the domain is allowed by configuration
* @param data Response data if any
* @param error Handled error response if any
*/
function Response(httpStatus, statusText, data, error) {
function Response(httpStatus, statusText, isDomainAllowed, data, error) {
var _this = this;
this.httpStatus = httpStatus;
this.statusText = statusText;
this.isDomainAllowed = isDomainAllowed;
this.data = data;

@@ -21,0 +23,0 @@ this.error = error;

@@ -8,2 +8,4 @@ /**

installProcess: boolean;
useGivenJobId: boolean;
internalArguments: boolean;
/**

@@ -10,0 +12,0 @@ * Default constructor

@@ -15,2 +15,4 @@ "use strict";

this.installProcess = this.serverFeatures.includes('InstallProcess');
this.useGivenJobId = this.serverFeatures.includes('UseGivenJobId');
this.internalArguments = this.serverFeatures.includes('InternalArguments');
}

@@ -17,0 +19,0 @@ return ServerFeatures;

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

import { Job, Response } from '../../models/index';
import { Job, Response, ServerFeatures } from '../../models/index';
import { IRequest } from '../iRequest';

@@ -7,11 +7,9 @@ /**

export declare class InvokeRobotRequest implements IRequest<Job> {
robotProcessId: string;
data?: any;
url: string;
job: Job;
/**
* 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.
* @param job The robot Job to run.
*/
constructor(robotProcessId: string, data?: any);
constructor(job: Job);
/**

@@ -21,3 +19,3 @@ * Method that sends the request to invoke a robot.

*/
send: () => Promise<Response<Job>>;
send: (serverFeatures: ServerFeatures) => Promise<Response<Job>>;
/**

@@ -24,0 +22,0 @@ * Set the port to which the request should be sent along with the consent code.

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

var index_1 = require("../../models/index");
var jobArguments_1 = require("../../Models/jobArguments");
var utils_1 = require("../../utils");

@@ -14,9 +15,6 @@ var constants_1 = require("../../utils/constants");

* 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.
* @param job The robot Job to run.
*/
function InvokeRobotRequest(robotProcessId, data) {
function InvokeRobotRequest(job) {
var _this = this;
this.robotProcessId = robotProcessId;
this.data = data;
/**

@@ -26,4 +24,19 @@ * Method that sends the request to invoke a robot.

*/
this.send = function () { return utils_1.HttpUtil.post(_this.url, _this.convertToJob, _this.data); };
this.send = function (serverFeatures) {
var jsonData;
var url;
if (serverFeatures.internalArguments) {
url = _this.url + "&features=internalArguments"; // Added in version 1.2.9
jsonData = JSON.stringify(new jobArguments_1.JobArguments(_this.job.argument, _this.job.internalArguments));
}
else {
url = _this.url;
if (_this.job.argument) {
jsonData = JSON.stringify(_this.job.argument);
}
}
return utils_1.HttpUtil.post(url, _this.convertToJob, jsonData);
};
this.url = '';
this.job = job;
}

@@ -60,3 +73,3 @@ /**

InvokeRobotRequest.prototype.getURL = function (robotInvocationPort, consentCode) {
var url = constants_1.Constants.DEFAULT_ROBOT_INVOKE_DOMAIN + ":" + robotInvocationPort + "/" + constants_1.Constants.INVOKE_ROBOT + "?robotProcessId=" + this.robotProcessId;
var url = constants_1.Constants.DEFAULT_ROBOT_INVOKE_DOMAIN + ":" + robotInvocationPort + "/" + constants_1.Constants.INVOKE_ROBOT + "?robotProcessId=" + this.job.processId + "&jobId=" + this.job.jobId;
return utils_1.UrlUtil.appendConsentCode(url, consentCode);

@@ -63,0 +76,0 @@ };

@@ -0,9 +1,10 @@

import { ServerFeatures } from '../models';
import { Response } from '../models/response';
/**
* Contract to be implemented by every method which interacts with Robot service
*/
import { Response } from '../models/response';
export interface IRequest<T> {
url: string;
send(): Promise<Response<T>>;
send(serverFeatures: ServerFeatures): Promise<Response<T>>;
set(robotInvocationPort: number, consentCode: number): this;
}

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

this.init = function () {
_this.trace(traceEvent_1.TraceEvent.Init, {});
return _this;

@@ -110,5 +109,10 @@ };

case 0:
this.trace(traceEvent_1.TraceEvent.Run_Robot, {});
if (this.serverFeatures.useGivenJobId) {
this.trace(traceEvent_1.TraceEvent.Run_Robot, { JobId: job.jobId, ProcessKey: job.processId });
}
else {
this.trace(traceEvent_1.TraceEvent.Run_Robot, { ProcessKey: job.processId });
}
deferredPromise = new utils_1.Deferred();
return [4 /*yield*/, this.startRobot(job.processId, job.argument)];
return [4 /*yield*/, this.startRobot(job)];
case 1:

@@ -124,3 +128,3 @@ jobResponse = _a.sent();

* Method to stop a robot process job.
* @param job Job object containing all information about the robot process run to cancel.
* @param process The robot process to be stopped.
* @returns Deferred promise which is resolved with job result when robot process is cancelled.

@@ -133,3 +137,3 @@ */

case 0:
this.trace(traceEvent_1.TraceEvent.Stop_Process, {});
this.trace(traceEvent_1.TraceEvent.Stop_Process, { ProcessKey: process.id });
deferredPromise = new utils_1.Deferred();

@@ -165,3 +169,3 @@ _a.label = 1;

return __generator(this, function (_a) {
this.trace(traceEvent_1.TraceEvent.Install_Process, {});
this.trace(traceEvent_1.TraceEvent.Install_Process, { ProcessKey: processId });
if (!this.serverFeatures.installProcess)

@@ -182,15 +186,11 @@ throw new Error("" + language_1.Language.GetResource().api_not_found);

* 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.
* @param job The robot job to be run.
* @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 () {
this.startRobot = function (job) { 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);
this.sendRequest(new implementation_1.InvokeRobotRequest(job), deferredPromise);
}

@@ -217,7 +217,7 @@ catch (error) {

_a.sent();
return [4 /*yield*/, request.set(this.robotInvocationPort, this.consentCode).send()];
return [4 /*yield*/, request.set(this.robotInvocationPort, this.consentCode).send(this.serverFeatures)];
case 2:
response = _a.sent();
if (!response.isUnauthorized) return [3 /*break*/, 4];
return [4 /*yield*/, this.resendAfterConsent(request)];
return [4 /*yield*/, this.resendAfterConsent(request, response.isDomainAllowed)];
case 3:

@@ -262,2 +262,3 @@ response = _a.sent();

this.serverFeatures = new models_1.ServerFeatures(portResponse.serverFeatures);
this.trace(traceEvent_1.TraceEvent.Init, {});
_a.label = 2;

@@ -292,3 +293,3 @@ case 2: return [2 /*return*/];

if (!(response.isUnauthorized && this.consentCode === 0)) return [3 /*break*/, 4];
return [4 /*yield*/, this.askForConsent()];
return [4 /*yield*/, this.askForConsent(response.isDomainAllowed)];
case 3:

@@ -321,7 +322,7 @@ result = _a.sent();

*/
this.askForConsent = function () {
this.askForConsent = function (isDomainAllowed) {
var deferredPromise = new utils_1.Deferred();
_this.consentCode = utils_1.RandomUtil.getRandomNumber();
utils_1.ProtocolUtil.openUiPathProtocol(_this.consentCode);
_this.showConsentCode(_this.consentCode);
_this.showConsentCode(_this.consentCode, isDomainAllowed);
_this.pollForApprovedConsent(_this.getPort)

@@ -349,7 +350,7 @@ .then(function (response) {

*/
this.resendAfterConsent = function (request) { return __awaiter(_this, void 0, void 0, function () {
this.resendAfterConsent = function (request, isDomainAllowed) { 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 0: return [4 /*yield*/, this.askForConsent(isDomainAllowed)];
case 1:

@@ -359,3 +360,3 @@ portResponse = _a.sent();

this.serverFeatures = new models_1.ServerFeatures(portResponse.serverFeatures);
return [2 /*return*/, request.set(this.robotInvocationPort, this.consentCode).send()];
return [2 /*return*/, request.set(this.robotInvocationPort, this.consentCode).send(this.serverFeatures)];
}

@@ -367,3 +368,2 @@ });

* @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.

@@ -429,3 +429,3 @@ */

*/
this.showConsentCode = function (consentCode) {
this.showConsentCode = function (consentCode, isDomainAllowed) {
if (_this.eventHandlers.has(constants_1.Constants.CONSENT_PROMPT)) {

@@ -435,3 +435,5 @@ _this.eventHandlers.dispatch(constants_1.Constants.CONSENT_PROMPT, consentCode);

else {
utils_1.HtmlUtil.showConsentOverlay(consentCode, _this.settings.portNumber);
if (!isDomainAllowed) {
utils_1.HtmlUtil.showConsentOverlay(consentCode, _this.settings.portNumber);
}
}

@@ -438,0 +440,0 @@ };

@@ -22,2 +22,3 @@ export declare class Constants {

static readonly STOP_PROCESS = "StopProcess";
static readonly DOMAIN_ALLOWED = "X-UIPATH-DOMAIN-ALLOWED";
}

@@ -27,4 +27,5 @@ "use strict";

Constants.STOP_PROCESS = 'StopProcess';
Constants.DOMAIN_ALLOWED = 'X-UIPATH-DOMAIN-ALLOWED';
return Constants;
}());
exports.Constants = Constants;

@@ -37,7 +37,8 @@ "use strict";

}
resolve(new models_1.Response(request.status, request.statusText, transform(this.response), HttpUtil.errorResponse(this.response)));
var isDomainAllowed = request.getResponseHeader(constants_1.Constants.DOMAIN_ALLOWED) !== null;
resolve(new models_1.Response(request.status, request.statusText, isDomainAllowed, transform(this.response), HttpUtil.errorResponse(this.response)));
HttpUtil.persistTokentoLocalStorage(request);
};
request.onerror = function () {
reject(new models_1.Response(request.status, request.statusText));
reject(new models_1.Response(request.status, request.statusText, false));
HttpUtil.persistTokentoLocalStorage(request);

@@ -44,0 +45,0 @@ };

@@ -21,5 +21,12 @@ "use strict";

disableAjaxTracking: true,
},
disableExceptionTracking: true,
}
});
_this.appInsights.loadAppInsights();
_this.appInsights.core.logger.maxInternalMessageLimit = function () { return 0; }; // suppress 'AI (Internal)' messages (which are sent to 'traces' in Azure AppInsights)
_this.appInsights.addTelemetryInitializer(function (envelope) {
if (envelope.tags != undefined) {
envelope.tags['ai.operation.name'] = 'UiPathRobotJS';
}
});
};

@@ -26,0 +33,0 @@ this.skipTelemetry = function () { return window.location.protocol === 'file:' || _this.settings.disableTelemetry; };

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

export declare const ROBOTJS_VERSION = "1.2.8";
export declare const ROBOTJS_VERSION = "1.2.9";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ROBOTJS_VERSION = void 0;
exports.ROBOTJS_VERSION = '1.2.8';
exports.ROBOTJS_VERSION = '1.2.9';
{
"name": "@uipath/robot",
"version": "1.2.8",
"version": "1.2.9",
"description": "UiPath Robot javascript SDK enabling web pages to interact with UiPath Robots",

@@ -13,2 +13,3 @@ "scripts": {

"@types/node": "^8.0.14",
"@types/uuid": "^8.3.4",
"copy-webpack-plugin": "^5.1.1",

@@ -26,3 +27,4 @@ "file-system": "^2.2.2",

"@microsoft/applicationinsights-web": "^2.5.9",
"async-mutex": "^0.3.2"
"async-mutex": "^0.3.2",
"uuid": "^8.3.2"
},

@@ -29,0 +31,0 @@ "main": "dist/uipathRobot.js",

Sorry, the diff of this file is too big to display