New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@reportportal/client-javascript

Package Overview
Dependencies
Maintainers
0
Versions
24
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.2.0 to 5.3.0

171

lib/helpers.js
const fs = require('fs');
const glob = require('glob');
const os = require('os');
const microtime = require('microtime');
const RestClient = require('./rest');

@@ -14,90 +15,108 @@ const pjson = require('../package.json');

module.exports = {
formatName(name) {
const len = name.length;
// eslint-disable-next-line no-mixed-operators
return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
},
const formatName = (name) => {
const len = name.length;
// eslint-disable-next-line no-mixed-operators
return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
};
now() {
return new Date().valueOf();
},
const formatMicrosecondsToISOString = (timestampInMicroseconds) => {
const milliseconds = Math.floor(timestampInMicroseconds / 1000);
const microseconds = String(timestampInMicroseconds).slice(-3);
const isoDate = new Date(milliseconds).toISOString();
// TODO: deprecate and remove
getServerResult(url, request, options, method) {
return new RestClient(options).request(method, url, request, options);
},
return isoDate.replace('Z', `${microseconds}Z`);
};
readLaunchesFromFile() {
const files = glob.sync('rplaunch-*.tmp');
const ids = files.map(getUUIDFromFileName);
const now = () => {
return formatMicrosecondsToISOString(microtime.now());
};
return ids;
},
// TODO: deprecate and remove
const getServerResult = (url, request, options, method) => {
return new RestClient(options).request(method, url, request, options);
};
saveLaunchIdToFile(launchId) {
const filename = `rplaunch-${launchId}.tmp`;
fs.open(filename, 'w', (err) => {
if (err) {
throw err;
}
});
},
const readLaunchesFromFile = () => {
const files = glob.sync('rplaunch-*.tmp');
const ids = files.map(getUUIDFromFileName);
getSystemAttribute() {
const osType = os.type();
const osArchitecture = os.arch();
const RAMSize = os.totalmem();
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,
},
];
return ids;
};
return systemAttr;
},
generateTestCaseId(codeRef, params) {
if (!codeRef) {
return;
const saveLaunchIdToFile = (launchId) => {
const filename = `rplaunch-${launchId}.tmp`;
fs.open(filename, 'w', (err) => {
if (err) {
throw err;
}
});
};
if (!params) {
return codeRef;
}
const getSystemAttribute = () => {
const osType = os.type();
const osArchitecture = os.arch();
const RAMSize = os.totalmem();
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 parameters = params.reduce(
(result, item) => (item.value ? result.concat(item.value) : result),
[],
);
return systemAttr;
};
return `${codeRef}[${parameters}]`;
},
const generateTestCaseId = (codeRef, params) => {
if (!codeRef) {
return;
}
saveLaunchUuidToFile(launchUuid) {
const filename = `rp-launch-uuid-${launchUuid}.tmp`;
fs.open(filename, 'w', (err) => {
if (err) {
throw err;
}
});
},
if (!params) {
return codeRef;
}
const parameters = params.reduce(
(result, item) => (item.value ? result.concat(item.value) : result),
[],
);
return `${codeRef}[${parameters}]`;
};
const saveLaunchUuidToFile = (launchUuid) => {
const filename = `rp-launch-uuid-${launchUuid}.tmp`;
fs.open(filename, 'w', (err) => {
if (err) {
throw err;
}
});
};
module.exports = {
formatName,
formatMicrosecondsToISOString,
now,
getServerResult,
readLaunchesFromFile,
saveLaunchIdToFile,
getSystemAttribute,
generateTestCaseId,
saveLaunchUuidToFile,
};
{
"name": "@reportportal/client-javascript",
"version": "5.2.0",
"version": "5.3.0",
"description": "ReportPortal client for Node.js",

@@ -32,3 +32,4 @@ "author": "ReportPortal.io",

"uniqid": "^5.4.0",
"uuid": "^9.0.1"
"uuid": "^9.0.1",
"microtime": "^3.1.1"
},

@@ -35,0 +36,0 @@ "license": "Apache-2.0",

@@ -132,9 +132,9 @@ # ReportPortal js client

| Option | Necessity | Default | Description |
|-------------|-----------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| startTime | Optional | rpClient.helpers.now() | Start time of the launch (unix time). |
| name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
| mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
| description | Optional | '' | Description of the launch (supports markdown syntax). |
| attributes | Optional | [] | Array of launch attributes (tags). |
| Option | Necessity | Default | Description |
|-------------|-----------|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| startTime | Optional | rpClient.helpers.now() | Start time of the launch (Unix Epoch time, see [time format](#time-format)). |
| name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
| mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
| description | Optional | '' | Description of the launch (supports markdown syntax). |
| attributes | Optional | [] | Array of launch attributes (tags). |
| id | Optional | Not set | `ID` of the existing launch in which tests data would be sent, without this param new launch instance will be created. |

@@ -184,5 +184,5 @@

|Option | Necessity | Default | Description |
|--------- |-----------|---------|---------------------------------------------------------------------------------------------------|
|endTime | Optional | rpClient.helpers.now() | End time of the launch. |
|Option | Necessity | Default | Description |
|--------- |-----------|---------|----------------------------------------------------------------------------------------------------|
|endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
|status | Optional | '' | Status of launch, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |

@@ -270,3 +270,3 @@

|description | Optional | '' | Description of the test item (supports markdown syntax). |
|startTime | Optional | rpClient.helpers.now() | Start time of the test item (unix time). |
|startTime | Optional | rpClient.helpers.now() | Start time of the test item (Unix Epoch time, see [time format](#time-format)). |
|attributes | Optional | [] | Array of the test item attributes. |

@@ -295,4 +295,4 @@

| issue | Optional | true | Test item issue object. `issueType` is required, allowable values: 'pb***', 'ab***', 'si***', 'ti***', 'nd001'. Where `***` is locator id |
| status | Optional | 'PASSED' | Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
| endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time). |
| status | Optional | 'PASSED' | Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
| endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |

@@ -332,7 +332,7 @@ Example issue object:

| Option | Necessity | Default | Description |
|---------|-----------|------------------------|----------------------------------------------------------------------|
| message | Optional | '' | The log message. |
| Option | Necessity | Default | Description |
|---------|-----------|------------------------|---------------------------------------------------------------------|
| message | Optional | '' | The log message. |
| level | Optional | '' | The log level, one of 'trace', 'debug', 'info', 'warn', 'error', ''. |
| time | Optional | rpClient.helpers.now() | The time of the log. |
| time | Optional | rpClient.helpers.now() | The time of the log (Unix Epoch time, see [time format](#time-format)). |

@@ -378,3 +378,3 @@ * file object (optional):

| attributes | Optional | config.attributes or [] | Array of launch attributes (tags). |
| endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time) |
| endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
| extendSuitesDescription | Optional | true | Whether to extend suites description or not. |

@@ -386,2 +386,12 @@ | launches | Optional | ids of the launches saved to filesystem | The array of the real launch ids, not UUIDs |

## Time format
The unix Epoch time ISO string.
The [ReportPortal since product version 24.2]() (Service API version 5.12.0) supports the time with microsecond precision in the ISO string format (`2024-09-23T11:10:46.793546Z`).
Thus, it is recommended to report time in this format to have more accurate logs and test items order on the ReportPortal UI.
**Note:** Reporting the time in ISO string format with millisecond precision (`2024-09-23T11:10:46.793Z`) or as a number of milliseconds (`1727089846793`) is also acceptable with microseconds automatically added as zeros for backward compatibility.
The client use time with microsecond precision in the ISO string format by default since [version 5.3.0]().
# Copyright Notice

@@ -388,0 +398,0 @@

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