Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@reportportal/client-javascript

Package Overview
Dependencies
Maintainers
4
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reportportal/client-javascript - npm Package Compare versions

Comparing version 5.0.6 to 5.0.7

3

analytics/events.js

@@ -11,3 +11,4 @@ const { PJSON_VERSION, PJSON_NAME } = require('./constants');

const getAgentEventLabel = (agentParams) => `Agent name "${agentParams.name}", version "${agentParams.version}"`;
const getAgentEventLabel = (agentParams) =>
`Agent name "${agentParams.name}", version "${agentParams.version}"`;

@@ -14,0 +15,0 @@ module.exports = {

## [5.0.7] - 2022-12-26
### Added
- The ability to see verbose logs in debug mode. To enable the debug mode, the `debug: true` flag should be specified in `params`.
### Security
- Updated versions of vulnerable packages (ajv, qs, follow-redirects, minimatch).
## [5.0.6] - 2022-01-13

@@ -42,4 +48,3 @@ ### Fixed

- Full compatibility with ReportPortal version 5.* (see [reportportal releases](https://github.com/reportportal/reportportal/releases))
### Deprecated
- Previous package version (`reportportal-client`) will no longer supported by reportportal.io

@@ -18,3 +18,3 @@ const fs = require('fs');

// eslint-disable-next-line no-mixed-operators
return ((len < MIN) ? (name + new Array(MIN - len + 1).join('.')) : name).slice(-MAX);
return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
},

@@ -27,4 +27,3 @@

getServerResult(url, request, options, method) {
return RestClient
.request(method, url, request, options);
return RestClient.request(method, url, request, options);
},

@@ -53,19 +52,24 @@

const nodeVersion = process.version;
const systemAttr = [{
key: 'client',
value: `${PJSON_NAME}|${PJSON_VERSION}`,
system: true,
}, {
key: 'os',
value: `${osType}|${osArchitecture}`,
system: true,
}, {
key: 'RAMSize',
value: RAMSize,
system: true,
}, {
key: 'nodeJS',
value: nodeVersion,
system: true,
}];
const systemAttr = [
{
key: 'client',
value: `${PJSON_NAME}|${PJSON_VERSION}`,
system: true,
},
{
key: 'os',
value: `${osType}|${osArchitecture}`,
system: true,
},
{
key: 'RAMSize',
value: RAMSize,
system: true,
},
{
key: 'nodeJS',
value: nodeVersion,
system: true,
},
];

@@ -84,3 +88,6 @@ return systemAttr;

const parameters = params.reduce((result, item) => (item.value ? result.concat(item.value) : result), []);
const parameters = params.reduce(
(result, item) => (item.value ? result.concat(item.value) : result),
[],
);

@@ -87,0 +94,0 @@ return `${codeRef}[${parameters}]`;

@@ -8,6 +8,6 @@ const { EVENTS } = require('./constants/events');

/**
* Emit set description event.
* @param {String} text - description of current test/suite.
* @param {String} suite - suite description, optional.
*/
* Emit set description event.
* @param {String} text - description of current test/suite.
* @param {String} suite - suite description, optional.
*/
static setDescription(text, suite) {

@@ -18,11 +18,11 @@ process.emit(EVENTS.SET_DESCRIPTION, { text, suite });

/**
* Emit add attributes event.
* @param {Array} attributes - array of attributes, should looks like this:
* [{
* key: "attrKey",
* value: "attrValue",
* }]
*
* @param {String} suite - suite description, optional.
*/
* Emit add attributes event.
* @param {Array} attributes - array of attributes, should looks like this:
* [{
* key: "attrKey",
* value: "attrValue",
* }]
*
* @param {String} suite - suite description, optional.
*/
static addAttributes(attributes, suite) {

@@ -33,15 +33,15 @@ process.emit(EVENTS.ADD_ATTRIBUTES, { attributes, suite });

/**
* Emit send log to test item event.
* @param {Object} log - log object should looks like this:
* {
* level: "INFO",
* message: "log message",
* file: {
* name: "filename",
* type: "image/png", // media type
* content: data, // file content represented as 64base string
* },
* }
* @param {String} suite - suite description, optional.
*/
* Emit send log to test item event.
* @param {Object} log - log object should looks like this:
* {
* level: "INFO",
* message: "log message",
* file: {
* name: "filename",
* type: "image/png", // media type
* content: data, // file content represented as 64base string
* },
* }
* @param {String} suite - suite description, optional.
*/
static addLog(log, suite) {

@@ -52,14 +52,14 @@ process.emit(EVENTS.ADD_LOG, { log, suite });

/**
* Emit send log to current launch event.
* @param {Object} log - log object should looks like this:
* {
* level: "INFO",
* message: "log message",
* file: {
* name: "filename",
* type: "image/png", // media type
* content: data, // file content represented as 64base string
* },
* }
*/
* Emit send log to current launch event.
* @param {Object} log - log object should looks like this:
* {
* level: "INFO",
* message: "log message",
* file: {
* name: "filename",
* type: "image/png", // media type
* content: data, // file content represented as 64base string
* },
* }
*/
static addLaunchLog(log) {

@@ -70,6 +70,6 @@ process.emit(EVENTS.ADD_LAUNCH_LOG, log);

/**
* Emit set testCaseId event.
* @param {String} testCaseId - testCaseId of current test/suite.
* @param {String} suite - suite description, optional.
*/
* Emit set testCaseId event.
* @param {String} testCaseId - testCaseId of current test/suite.
* @param {String} suite - suite description, optional.
*/
static setTestCaseId(testCaseId, suite) {

@@ -80,5 +80,5 @@ process.emit(EVENTS.SET_TEST_CASE_ID, { testCaseId, suite });

/**
* Emit set status to current launch event.
* @param {String} status - status of current launch.
*/
* Emit set status to current launch event.
* @param {String} status - status of current launch.
*/
static setLaunchStatus(status) {

@@ -89,6 +89,6 @@ process.emit(EVENTS.SET_LAUNCH_STATUS, status);

/**
* Emit set status event.
* @param {String} status - status of current test/suite.
* @param {String} suite - suite description, optional.
*/
* Emit set status event.
* @param {String} status - status of current test/suite.
* @param {String} suite - suite description, optional.
*/
static setStatus(status, suite) {

@@ -95,0 +95,0 @@ process.emit(EVENTS.SET_STATUS, { status, suite });

@@ -14,22 +14,23 @@ /* eslint-disable quotes,no-console,class-methods-use-this */

/**
* Create a client for RP.
* @param {Object} params - config object.
* params should look like this
* {
* token: "00000000-0000-0000-0000-000000000000",
* endpoint: "http://localhost:8080/api/v1",
* launch: "YOUR LAUNCH NAME",
* project: "PROJECT NAME",
* }
*
* @param {Object} agentParams - agent's info object.
* agentParams should look like this
* {
* name: "AGENT NAME",
* version: "AGENT VERSION",
* }
*/
* Create a client for RP.
* @param {Object} params - config object.
* params should look like this
* {
* token: "00000000-0000-0000-0000-000000000000",
* endpoint: "http://localhost:8080/api/v1",
* launch: "YOUR LAUNCH NAME",
* project: "PROJECT NAME",
* }
*
* @param {Object} agentParams - agent's info object.
* agentParams should look like this
* {
* name: "AGENT NAME",
* version: "AGENT VERSION",
* }
*/
constructor(params, agentParams) {
this.debug = params.debug;
this.isLaunchMergeRequired = params.isLaunchMergeRequired === undefined ? false : params.isLaunchMergeRequired;
this.isLaunchMergeRequired =
params.isLaunchMergeRequired === undefined ? false : params.isLaunchMergeRequired;
this.map = {};

@@ -61,5 +62,5 @@ this.baseURL = [params.endpoint, params.project].join('/');

*/
logDebug(msg) {
logDebug(msg, dataMsg = '') {
if (this.debug) {
console.log(msg);
console.log(msg, dataMsg);
}

@@ -87,10 +88,10 @@ }

const obj = {
promiseStart: (new Promise(startPromiseFunc)),
promiseStart: new Promise(startPromiseFunc),
realId: '',
children: [],
finishSend: false,
promiseFinish: (new Promise((resolve, reject) => {
promiseFinish: new Promise((resolve, reject) => {
resolveFinish = resolve;
rejectFinish = reject;
})),
}),
};

@@ -191,5 +192,5 @@ obj.resolveFinish = resolveFinish;

const url = 'launch';
this.logDebug(`Start launch ${tempId}`);
this.restClient.create(url, launchData, { headers: this.headers })
.then((response) => {
this.logDebug(`Start launch with tempId ${tempId}`, launchDataRQ);
this.restClient.create(url, launchData, { headers: this.headers }).then(
(response) => {
this.map[tempId].realId = response.id;

@@ -202,7 +203,11 @@ this.launchUuid = response.id;

this.logDebug(`Success start launch with tempId ${tempId}`, response);
resolve(response);
}, (error) => {
},
(error) => {
this.logDebug(`Error start launch with tempId ${tempId}`, error);
console.dir(error);
reject(error);
});
},
);
});

@@ -218,16 +223,19 @@ }

/**
* Finish launch.
* @param {string} launchTempId - temp launch id (returned in the query "startLaunch").
* @param {Object} finishExecutionRQ - finish launch info should include time and status.
* finishExecutionRQ should look like this
* {
* "endTime": this.helper.now(),
* "status": "passed" or one of ‘passed’, ‘failed’, ‘stopped’, ‘skipped’, ‘interrupted’, ‘cancelled’
* }
* @Returns {Object} - an object which contains a tempID and a promise
*/
* Finish launch.
* @param {string} launchTempId - temp launch id (returned in the query "startLaunch").
* @param {Object} finishExecutionRQ - finish launch info should include time and status.
* finishExecutionRQ should look like this
* {
* "endTime": this.helper.now(),
* "status": "passed" or one of ‘passed’, ‘failed’, ‘stopped’, ‘skipped’, ‘interrupted’, ‘cancelled’
* }
* @Returns {Object} - an object which contains a tempID and a promise
*/
finishLaunch(launchTempId, finishExecutionRQ) {
const launchObj = this.map[launchTempId];
if (!launchObj) {
return this.getRejectAnswer(launchTempId, new Error(`Launch "${launchTempId}" not found`));
return this.getRejectAnswer(
launchTempId,
new Error(`Launch with tempId "${launchTempId}" not found`),
);
}

@@ -238,23 +246,31 @@

launchObj.finishSend = true;
Promise.all(launchObj.children.map((itemId) => this.map[itemId].promiseFinish))
.then(() => {
launchObj.promiseStart
.then(() => {
this.logDebug(`Finish launch ${launchTempId}`);
Promise.all(launchObj.children.map((itemId) => this.map[itemId].promiseFinish)).then(
() => {
launchObj.promiseStart.then(
() => {
this.logDebug(`Finish launch with tempId ${launchTempId}`, finishExecutionData);
const url = ['launch', launchObj.realId, 'finish'].join('/');
this.restClient.update(url, finishExecutionData, { headers: this.headers })
.then((response) => {
this.logDebug(`Success finish launch ${launchTempId}`);
this.restClient.update(url, finishExecutionData, { headers: this.headers }).then(
(response) => {
this.logDebug(`Success finish launch with tempId ${launchTempId}`, response);
launchObj.resolveFinish(response);
}, (error) => {
this.logDebug(`Error finish launch ${launchTempId}`);
},
(error) => {
this.logDebug(`Error finish launch with tempId ${launchTempId}`, error);
console.dir(error);
launchObj.rejectFinish(error);
});
}, (error) => {
},
);
},
(error) => {
console.dir(error);
launchObj.rejectFinish(error);
});
}, (error) => {
},
);
},
(error) => {
console.dir(error);
launchObj.rejectFinish(error);
});
},
);

@@ -268,14 +284,14 @@ return {

/*
* This method is used to create data object for merge request to ReportPortal.
*
* @Returns {Object} - an object which contains a data for merge launches in ReportPortal.
*/
* This method is used to create data object for merge request to ReportPortal.
*
* @Returns {Object} - an object which contains a data for merge launches in ReportPortal.
*/
getMergeLaunchesRequest(launchIds) {
return {
description: "Merged launch",
description: 'Merged launch',
endTime: this.helpers.now(),
extendSuitesDescription: true,
launches: launchIds,
mergeType: "BASIC",
mode: "DEFAULT",
mergeType: 'BASIC',
mode: 'DEFAULT',
name: this.config.launch || 'Test launch name',

@@ -287,7 +303,7 @@ attributes: this.config.attributes,

/*
* This method is used for merge launches in ReportPortal.
*
* Please, keep in mind that this method is work only in case
* the option isLaunchMergeRequired is true.
*/
* This method is used for merge launches in ReportPortal.
*
* Please, keep in mind that this method is work only in case
* the option isLaunchMergeRequired is true.
*/
mergeLaunches() {

@@ -300,12 +316,19 @@ if (this.isLaunchMergeRequired) {

const launchSearchUrl = `launch?${params.toString()}`;
return this.restClient.retrieveSyncAPI(launchSearchUrl, { headers: this.headers })
.then((response) => {
const launchIds = response.content.map((launch) => launch.id);
this.logDebug(`Found launches: ${launchIds}`);
return launchIds;
}, (error) => {
console.dir(error);
})
this.logDebug(`Find launches with UUIDs to merge: ${launchUUIds}`);
return this.restClient
.retrieveSyncAPI(launchSearchUrl, { headers: this.headers })
.then(
(response) => {
const launchIds = response.content.map((launch) => launch.id);
this.logDebug(`Found launches: ${launchIds}`, response.content);
return launchIds;
},
(error) => {
this.logDebug(`Error during launches search with UUIDs: ${launchUUIds}`, error);
console.dir(error);
},
)
.then((launchIds) => {
const request = this.getMergeLaunchesRequest(launchIds);
this.logDebug(`Merge launches with ids: ${launchIds}`, request);
const mergeURL = 'launch/merge';

@@ -315,19 +338,21 @@ return this.restClient.create(mergeURL, request, { headers: this.headers });

.then(() => {
this.logDebug(`Launches successfully merged!`);
this.logDebug(`Launches with UUIDs: ${launchUUIds} were successfully merged!`);
})
.catch((error) => {
this.logDebug('ERROR');
this.logDebug(error);
this.logDebug(`Error merging launches with UUIDs: ${launchUUIds}`, error);
console.dir(error);
});
}
this.logDebug('Option isLaunchMergeRequired is false');
this.logDebug(
'Option isLaunchMergeRequired is false, merge process cannot be done as no launch UUIDs where saved.',
);
}
/*
* This method is used for frameworks as Jasmine. There is problem when
* it doesn't wait for promise resolve and stop the process. So it better to call
* this method at the spec's function as @afterAll() and manually resolve this promise.
*
* @return Promise
*/
* This method is used for frameworks as Jasmine. There is problem when
* it doesn't wait for promise resolve and stop the process. So it better to call
* this method at the spec's function as @afterAll() and manually resolve this promise.
*
* @return Promise
*/
getPromiseFinishAllItems(launchTempId) {

@@ -361,3 +386,6 @@ const launchObj = this.map[launchTempId];

if (!launchObj) {
return this.getRejectAnswer(launchTempId, new Error(`Launch "${launchTempId}" not found`));
return this.getRejectAnswer(
launchTempId,
new Error(`Launch with tempId "${launchTempId}" not found`),
);
}

@@ -371,13 +399,22 @@ let resolvePromise;

launchObj.promiseFinish.then(() => {
const url = ['launch', launchObj.realId, 'update'].join('/');
this.restClient.update(url, launchData, { headers: this.headers })
.then((response) => {
resolvePromise(response);
}, (error) => {
rejectPromise(error);
});
}, (error) => {
rejectPromise(error);
});
launchObj.promiseFinish.then(
() => {
const url = ['launch', launchObj.realId, 'update'].join('/');
this.logDebug(`Update launch with tempId ${launchTempId}`, launchData);
this.restClient.update(url, launchData, { headers: this.headers }).then(
(response) => {
this.logDebug(`Launch with tempId ${launchTempId} were successfully updated`, response);
resolvePromise(response);
},
(error) => {
this.logDebug(`Error when updating launch with tempId ${launchTempId}`, error);
console.dir(error);
rejectPromise(error);
},
);
},
(error) => {
rejectPromise(error);
},
);
return {

@@ -420,12 +457,23 @@ tempId: launchTempId,

if (!launchObj) {
return this.getRejectAnswer(launchTempId, new Error(`Launch "${launchTempId}" not found`));
return this.getRejectAnswer(
launchTempId,
new Error(`Launch with tempId "${launchTempId}" not found`),
);
}
// TODO: Allow items reporting to finished launch
if (launchObj.finishSend) {
const err = new Error(`Launch "${launchTempId}" is already finished, you can not add an item to it`);
const err = new Error(
`Launch with tempId "${launchTempId}" is already finished, you can not add an item to it`,
);
return this.getRejectAnswer(launchTempId, err);
}
const testCaseId = testItemDataRQ.testCaseId
|| helpers.generateTestCaseId(testItemDataRQ.codeRef, testItemDataRQ.parameters);
const testItemData = { startTime: this.helpers.now(), ...testItemDataRQ, ...(testCaseId && { testCaseId }) };
const testCaseId =
testItemDataRQ.testCaseId ||
helpers.generateTestCaseId(testItemDataRQ.codeRef, testItemDataRQ.parameters);
const testItemData = {
startTime: this.helpers.now(),
...testItemDataRQ,
...(testCaseId && { testCaseId }),
};

@@ -437,3 +485,6 @@ let parentPromise = launchObj.promiseStart;

if (!parentObj) {
return this.getRejectAnswer(launchTempId, new Error(`Item "${parentTempId}" not found`));
return this.getRejectAnswer(
launchTempId,
new Error(`Item with tempId "${parentTempId}" not found`),
);
}

@@ -456,25 +507,30 @@ parentPromise = parentObj.promiseStart;

this.map[tempId] = this.getNewItemObj((resolve, reject) => {
parentPromise.then(() => {
const realLaunchId = this.map[launchTempId].realId;
let url = 'item/';
if (parentTempId) {
const realParentId = this.map[parentTempId].realId;
url += `${realParentId}`;
}
testItemData.launchUuid = realLaunchId;
this.logDebug(`Start test item ${tempId}`);
this.restClient.create(url, testItemData, { headers: this.headers })
.then((response) => {
this.logDebug(`Success start item ${tempId}`);
this.map[tempId].realId = response.id;
this.nonRetriedItemMap.delete(itemKey);
resolve(response);
}, (error) => {
this.logDebug(`Error start item ${tempId}:`);
console.dir(error);
reject(error);
});
}, (error) => {
reject(error);
});
parentPromise.then(
() => {
const realLaunchId = this.map[launchTempId].realId;
let url = 'item/';
if (parentTempId) {
const realParentId = this.map[parentTempId].realId;
url += `${realParentId}`;
}
testItemData.launchUuid = realLaunchId;
this.logDebug(`Start test item with tempId ${tempId}`, testItemData);
this.restClient.create(url, testItemData, { headers: this.headers }).then(
(response) => {
this.logDebug(`Success start item with tempId ${tempId}`, response);
this.map[tempId].realId = response.id;
this.nonRetriedItemMap.delete(itemKey);
resolve(response);
},
(error) => {
this.logDebug(`Error start item with tempId ${tempId}`, error);
console.dir(error);
reject(error);
},
);
},
(error) => {
reject(error);
},
);
});

@@ -520,3 +576,6 @@ this.map[parentMapId].children.push(tempId);

if (!itemObj) {
return this.getRejectAnswer(itemTempId, new Error(`Item "${itemTempId}" not found`));
return this.getRejectAnswer(
itemTempId,
new Error(`Item with tempId "${itemTempId}" not found`),
);
}

@@ -531,5 +590,12 @@

itemObj.finishSend = true;
Promise.all(itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish))
.then(() => {
this.logDebug(`Finish all children for test item with tempId ${itemTempId}`);
Promise.all(
itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish),
).then(
() => {
this.cleanMap(itemObj.children);
this.logDebug(
`All children for test item with tempId ${itemTempId} successfully finished.`,
);
this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
this.finishTestItemPromiseStart(

@@ -540,6 +606,7 @@ itemObj,

);
}, () => {
},
() => {
this.cleanMap(itemObj.children);
this.logDebug(`Error finish children of test item ${itemTempId}`);
this.logDebug(`Finish test item ${itemTempId}`);
this.logDebug(`Error finish children of test item with tempId ${itemTempId}`);
this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
this.finishTestItemPromiseStart(

@@ -550,3 +617,4 @@ itemObj,

);
});
},
);

@@ -562,14 +630,21 @@ return {

this.map[tempId] = this.getNewItemObj((resolve, reject) => {
itemObj.promiseStart.then(() => {
this.logDebug(`Save log ${tempId}`);
requestPromiseFunc(itemObj.realId, this.launchUuid).then((response) => {
this.logDebug(`Successfully save log ${tempId}`);
resolve(response);
}, (error) => {
this.logDebug(`Error finish log: ${error}`);
itemObj.promiseStart.then(
() => {
this.logDebug(`Save log with tempId ${tempId}`, itemObj);
requestPromiseFunc(itemObj.realId, this.launchUuid).then(
(response) => {
this.logDebug(`Successfully save log with tempId ${tempId}`, response);
resolve(response);
},
(error) => {
this.logDebug(`Error save log with tempId ${tempId}`, error);
console.dir(error);
reject(error);
},
);
},
(error) => {
reject(error);
});
}, (error) => {
reject(error);
});
},
);
});

@@ -580,3 +655,6 @@ itemObj.children.push(tempId);

logObj.finishSend = true;
logObj.promiseStart.then((response) => logObj.resolveFinish(response), (error) => logObj.rejectFinish(error));
logObj.promiseStart.then(
(response) => logObj.resolveFinish(response),
(error) => logObj.rejectFinish(error),
);

@@ -604,17 +682,20 @@ return {

/**
* Send log of test results.
* @param {string} itemTempId - temp item id (returned in the query "startTestItem").
* @param {Object} saveLogRQ - object with data of test result.
* saveLogRQ should look like this
* {
* level: 'error' or one of 'trace', 'debug', 'info', 'warn', 'error', '',
* message: 'string' (support markdown),
* time: this.helpers.now()
* }
* @Returns {Object} - an object which contains a tempId and a promise
*/
* Send log of test results.
* @param {string} itemTempId - temp item id (returned in the query "startTestItem").
* @param {Object} saveLogRQ - object with data of test result.
* saveLogRQ should look like this
* {
* level: 'error' or one of 'trace', 'debug', 'info', 'warn', 'error', '',
* message: 'string' (support markdown),
* time: this.helpers.now()
* }
* @Returns {Object} - an object which contains a tempId and a promise
*/
sendLogWithoutFile(itemTempId, saveLogRQ) {
const itemObj = this.map[itemTempId];
if (!itemObj) {
return this.getRejectAnswer(itemTempId, new Error(`Item "${itemTempId}" not found`));
return this.getRejectAnswer(
itemTempId,
new Error(`Item with tempId "${itemTempId}" not found`),
);
}

@@ -627,7 +708,3 @@

url,
Object.assign(
saveLogRQ,
{ launchUuid },
isItemUuid && { itemUuid },
),
Object.assign(saveLogRQ, { launchUuid }, isItemUuid && { itemUuid }),
{ headers: this.headers },

@@ -663,10 +740,15 @@ );

if (!itemObj) {
return this.getRejectAnswer(itemTempId, new Error(`Item "${itemTempId}" not found`));
return this.getRejectAnswer(
itemTempId,
new Error(`Item with tempId "${itemTempId}" not found`),
);
}
// eslint-disable-next-line max-len
const requestPromise = (itemUuid, launchUuid) => {
const isItemUuid = itemUuid !== launchUuid;
// eslint-disable-next-line max-len
return this.getRequestLogWithFile(Object.assign(saveLogRQ, { launchUuid }, isItemUuid && { itemUuid }), fileObj);
return this.getRequestLogWithFile(
Object.assign(saveLogRQ, { launchUuid }, isItemUuid && { itemUuid }),
fileObj,
);
};

@@ -681,13 +763,17 @@

saveLogRQ.file = { name: fileObj.name };
return this.restClient.create(
url,
this.buildMultiPartStream([saveLogRQ], fileObj, MULTIPART_BOUNDARY),
{
headers: { ...this.headers, 'Content-Type': `multipart/form-data; boundary=${MULTIPART_BOUNDARY}` },
},
)
.then((response) => response)
this.logDebug(`Save log with file: ${fileObj.name}`, saveLogRQ);
return this.restClient
.create(url, this.buildMultiPartStream([saveLogRQ], fileObj, MULTIPART_BOUNDARY), {
headers: {
...this.headers,
'Content-Type': `multipart/form-data; boundary=${MULTIPART_BOUNDARY}`,
},
})
.then((response) => {
this.logDebug(`Success save log with file: ${fileObj.name}`, response);
return response;
})
.catch((error) => {
this.logDebug('ERROR');
this.logDebug(error);
this.logDebug(`Error save log with file: ${fileObj.name}`, error);
console.dir(error);
});

@@ -702,3 +788,3 @@ }

buildMultiPartStream(jsonPart, filePart, boundary) {
const eol = "\r\n";
const eol = '\r\n';
const bx = `--${boundary}`;

@@ -709,5 +795,12 @@ const buffers = [

// eslint-disable-next-line prefer-template
bx + eol + "Content-Disposition: form-data; name=\"json_request_part\""
+ eol + "Content-Type: application/json" + eol
+ eol + eol + JSON.stringify(jsonPart) + eol,
bx +
eol +
'Content-Disposition: form-data; name="json_request_part"' +
eol +
'Content-Type: application/json' +
eol +
eol +
eol +
JSON.stringify(jsonPart) +
eol,
),

@@ -717,4 +810,12 @@ // eslint-disable-next-line function-paren-newline

// eslint-disable-next-line prefer-template
bx + eol + "Content-Disposition: form-data; name=\"file\"; filename=\"" + filePart.name + "\"" + eol
+ "Content-Type: " + filePart.type + eol + eol,
bx +
eol +
'Content-Disposition: form-data; name="file"; filename="' +
filePart.name +
'"' +
eol +
'Content-Type: ' +
filePart.type +
eol +
eol,
),

@@ -728,19 +829,26 @@ Buffer.from(filePart.content, 'base64'),

finishTestItemPromiseStart(itemObj, itemTempId, finishTestItemData) {
itemObj.promiseStart
.then(() => {
itemObj.promiseStart.then(
() => {
const url = ['item', itemObj.realId].join('/');
this.logDebug(`Finish test item ${itemTempId}`);
// eslint-disable-next-line max-len
this.restClient.update(url, Object.assign(finishTestItemData, { launchUuid: this.launchUuid }), { headers: this.headers })
.then((response) => {
this.logDebug(`Success finish item ${itemTempId}`);
itemObj.resolveFinish(response);
}, (error) => {
this.logDebug(`Error finish test item ${itemTempId}`);
console.dir(error);
itemObj.rejectFinish(error);
});
}, (error) => {
this.logDebug(`Finish test item with tempId ${itemTempId}`, itemObj);
this.restClient
.update(url, Object.assign(finishTestItemData, { launchUuid: this.launchUuid }), {
headers: this.headers,
})
.then(
(response) => {
this.logDebug(`Success finish item with tempId ${itemTempId}`, response);
itemObj.resolveFinish(response);
},
(error) => {
this.logDebug(`Error finish test item with tempId ${itemTempId}`, error);
console.dir(error);
itemObj.rejectFinish(error);
},
);
},
(error) => {
itemObj.rejectFinish(error);
});
},
);
}

@@ -747,0 +855,0 @@ }

@@ -8,3 +8,7 @@ const axios = require('axios');

axiosRetry(axios, { retryDelay: () => 100, retries: 10, retryCondition: axiosRetry.isRetryableError });
axiosRetry(axios, {
retryDelay: () => 100,
retries: 10,
retryCondition: axiosRetry.isRetryableError,
});

@@ -38,7 +42,12 @@ class RestClient {

const responseData = error.response && error.response.data;
throw new Error(`${errorMessage}${
responseData
&& typeof responseData === 'object'
? `: ${JSON.stringify(responseData)}`
: ''}`);
throw new Error(
`${errorMessage}${
responseData && typeof responseData === 'object'
? `: ${JSON.stringify(responseData)}`
: ''
}
URL: ${url}
method: ${method}
Request data: ${JSON.stringify(data)}`,
);
});

@@ -70,20 +79,29 @@ }

create(path, data, options = { headers: this.headers }) {
return RestClient.request('POST', this.buildPath(path), data, { ...options, ...this.getRestConfig() });
return RestClient.request('POST', this.buildPath(path), data, {
...options,
...this.getRestConfig(),
});
}
retrieve(path, options = { headers: this.headers }) {
return RestClient.request('GET', this.buildPath(path), {}, { ...options, ...this.getRestConfig() });
return RestClient.request(
'GET',
this.buildPath(path),
{},
{ ...options, ...this.getRestConfig() },
);
}
update(path, data, options = { headers: this.headers }) {
return RestClient.request('PUT', this.buildPath(path), data, { ...options, ...this.getRestConfig() });
return RestClient.request('PUT', this.buildPath(path), data, {
...options,
...this.getRestConfig(),
});
}
delete(path, data, options = { headers: this.headers }) {
return RestClient.request(
'DELETE',
this.buildPath(path),
data,
{ ...options, ...this.getRestConfig() },
);
return RestClient.request('DELETE', this.buildPath(path), data, {
...options,
...this.getRestConfig(),
});
}

@@ -90,0 +108,0 @@

{
"name": "@reportportal/client-javascript",
"version": "5.0.6",
"version": "5.0.7",
"description": "ReportPortal client for node.js",

@@ -34,11 +34,13 @@ "author": "ReportPortal.io",

"dependencies": {
"axios": "^0.24.0",
"axios": "^0.27.2",
"axios-retry": "^3.2.4",
"glob": "^7.2.0",
"uniqid": "^5.4.0",
"universal-analytics": "^0.4.20"
"universal-analytics": "^0.5.3"
},
"license": "Apache-2.0",
"scripts": {
"lint": "eslint . --quiet",
"build": "npm run clean && tsc",
"clean": "rimraf ./build",
"lint": "eslint ./analytics/**/* ./lib/**/* ./spec/**/*",
"format": "npm run lint -- --fix",

@@ -51,8 +53,20 @@ "test": "nyc ./node_modules/jasmine/bin/jasmine.js",

"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"typescript": "^4.7.4",
"jasmine": "^3.5.0",
"lodash": "^4.17.11",
"nock": "^10.0.6",
"nyc": "^15.1.0"
"nock": "^13.2.9",
"nyc": "^15.1.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"@types/jasmine": "^4.0.3",
"@types/node": "^18.7.6",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jasmine-ts": "^0.4.0",
"ts-node": "^10.9.1"
},

@@ -59,0 +73,0 @@ "bugs": {

@@ -51,10 +51,12 @@ # ReportPortal js client

Parameter | Description
--------- | -----------
token | User's token Report Portal from which you want to send requests. It can be found on the profile page of this user.
endpoint | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'.
launch | Name of launch at creation.
project | The name of the project in which the launches will be created.
headers | (optional) The object with custom headers for internal http client.
restClientConfig | (optional) The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`.
| Parameter | Description |
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| token | User's token Report Portal from which you want to send requests. It can be found on the profile page of this user. |
| endpoint | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'. |
| launch | Name of launch at creation. |
| project | The name of the project in which the launches will be created. |
| headers | (optional) The object with custom headers for internal http client. |
| debug | (optional) *Default: false.* This flag allows seeing the logs of the client. Useful for debugging. |
| isLaunchMergeRequired | (optional) *Default: false.* Allows client to merge launches into one at the end of the run via saving their UUIDs to the file system. At the end of the run launches can be merged using `mergeLaunches` method. |
| restClientConfig | (optional) The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`. |

@@ -78,3 +80,3 @@ ## Asynchronous reporting

You can simply change this timeout by adding a `timeout` property to `restClientConfig` with your desired numeric value.
You can simply change this timeout by adding a `timeout` property to `restClientConfig` with your desired numeric value (in _ms_) or *0* to disable it.

@@ -81,0 +83,0 @@ ### checkConnect

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc