@reportportal/client-javascript 5.0.12 → 5.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,17 +52,19 @@ rpClient.checkConnect().then((response) => {
52
52
 
53
53
  When creating a client instance, you need to specify the following options:
54
54
 
55
- | Option | Necessity | Default | Description |
56
- |-----------------------|------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
57
- | apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
58
- | endpoint | Required | | 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'. |
59
- | launch | Required | | Name of launch at creation. |
60
- | project | Required | | The name of the project in which the launches will be created. |
61
- | headers | Optional | {} | The object with custom headers for internal http client. |
62
- | debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
63
- | isLaunchMergeRequired | Optional | 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. |
64
- | restClientConfig | Optional | Not set | 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`. |
65
- | token | Deprecated | Not set | Use `apiKey` instead. |
55
+ | Option | Necessity | Default | Description |
56
+ |-----------------------|------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
57
+ | apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
58
+ | endpoint | Required | | 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'. |
59
+ | launch | Required | | Name of launch at creation. |
60
+ | project | Required | | The name of the project in which the launches will be created. |
61
+ | headers | Optional | {} | The object with custom headers for internal http client. |
62
+ | debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
63
+ | isLaunchMergeRequired | Optional | 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. |
64
+ | restClientConfig | Optional | Not set | 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`. |
65
+ | launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
66
+ | launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR'. Works only if `launchUuidPrint` set to `true`. |
67
+ | token | Deprecated | Not set | Use `apiKey` instead. |
66
68
 
67
69
  ## Asynchronous reporting
68
70
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.13-SNAPSHOT
1
+ 5.0.14-SNAPSHOT
@@ -1,4 +1,13 @@
1
1
  const { ReportPortalRequiredOptionError, ReportPortalValidationError } = require('./errors');
2
+ const { OUTPUT_TYPES } = require('../constants/outputs');
3
+
4
+ const getOption = (options, optionName, defaultValue) => {
5
+ if (!Object.prototype.hasOwnProperty.call(options, optionName) || !options[optionName]) {
6
+ return defaultValue;
7
+ }
8
+
9
+ return options[optionName];
10
+ };
2
11
 
3
12
  const getRequiredOption = (options, optionName) => {
4
13
  if (!Object.prototype.hasOwnProperty.call(options, optionName) || !options[optionName]) {
@@ -32,6 +41,15 @@ const getClientConfig = (options) => {
32
41
  const project = getRequiredOption(options, 'project');
33
42
  const endpoint = getRequiredOption(options, 'endpoint');
34
43
 
44
+ const launchUuidPrintOutputType = getOption(options, 'launchUuidPrintOutput', 'STDOUT')
45
+ .toString()
46
+ .toUpperCase();
47
+ const launchUuidPrintOutput = getOption(
48
+ OUTPUT_TYPES,
49
+ launchUuidPrintOutputType,
50
+ OUTPUT_TYPES.STDOUT,
51
+ );
52
+
35
53
  calculatedOptions = {
36
54
  apiKey,
37
55
  project,
@@ -45,6 +63,8 @@ const getClientConfig = (options) => {
45
63
  attributes: options.attributes,
46
64
  mode: options.mode,
47
65
  description: options.description,
66
+ launchUuidPrint: options.launchUuidPrint,
67
+ launchUuidPrintOutput,
48
68
  };
49
69
  } catch (error) {
50
70
  // don't throw the error up to not break the entire process
@@ -0,0 +1,8 @@
1
+ const OUTPUT_TYPES = {
2
+ // eslint-disable-next-line no-console
3
+ STDOUT: console.log,
4
+ // eslint-disable-next-line no-console
5
+ STDERR: console.error,
6
+ };
7
+
8
+ module.exports = { OUTPUT_TYPES };
@@ -187,6 +187,9 @@ class RPClient {
187
187
  (response) => {
188
188
  this.map[tempId].realId = response.id;
189
189
  this.launchUuid = response.id;
190
+ if (this.config.launchUuidPrint) {
191
+ this.config.launchUuidPrintOutput(`Report Portal Launch UUID: ${this.launchUuid}`);
192
+ }
190
193
 
191
194
  if (this.isLaunchMergeRequired) {
192
195
  helpers.saveLaunchIdToFile(response.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/client-javascript",
3
- "version": "5.0.12",
3
+ "version": "5.0.13",
4
4
  "description": "ReportPortal client for Node.js",
5
5
  "author": "ReportPortal.io",
6
6
  "scripts": {
@@ -2,6 +2,10 @@ const axios = require('axios');
2
2
  const { MEASUREMENT_ID, API_KEY, PJSON_NAME, PJSON_VERSION, INTERPRETER } = require('./constants');
3
3
  const { getClientId } = require('./client-id');
4
4
 
5
+ const hasOption = (options, optionName) => {
6
+ return Object.prototype.hasOwnProperty.call(options, optionName);
7
+ };
8
+
5
9
  class Statistics {
6
10
  constructor(eventName, agentParams) {
7
11
  this.eventName = eventName;
@@ -14,18 +18,10 @@ class Statistics {
14
18
  client_name: PJSON_NAME,
15
19
  client_version: PJSON_VERSION,
16
20
  };
17
- if (
18
- agentParams &&
19
- Object.prototype.hasOwnProperty.call(agentParams, 'name') &&
20
- agentParams.name
21
- ) {
21
+ if (agentParams && hasOption(agentParams, 'name') && agentParams.name) {
22
22
  params.agent_name = agentParams.name;
23
23
  }
24
- if (
25
- agentParams &&
26
- Object.prototype.hasOwnProperty.call(agentParams, 'version') &&
27
- agentParams.version
28
- ) {
24
+ if (agentParams && hasOption(agentParams, 'version') && agentParams.version) {
29
25
  params.agent_version = agentParams.version;
30
26
  }
31
27
  return params;