@reportportal/client-javascript 5.0.2 → 5.0.6
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/CHANGELOG.md +44 -18
- package/LICENSE.txt +200 -200
- package/README.md +310 -297
- package/VERSION +1 -1
- package/analytics/analytics.js +15 -15
- package/analytics/constants.js +7 -7
- package/analytics/events.js +16 -16
- package/lib/constants/events.js +7 -7
- package/lib/constants/statuses.js +12 -12
- package/lib/helpers.js +85 -85
- package/lib/publicReportingAPI.js +92 -92
- package/lib/report-portal-client.js +719 -711
- package/lib/rest.js +98 -60
- package/package.json +65 -60
- package/.eslintrc +0 -17
- package/.idea/client-javascript.iml +0 -12
- package/.idea/codeStyles/Project.xml +0 -22
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/copyright/APACHE_2_0.xml +0 -6
- package/.idea/copyright/profiles_settings.xml +0 -3
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -571
- package/.istanbul.yml +0 -3
- package/spec/analytics.spec.js +0 -46
- package/spec/helper.spec.js +0 -142
- package/spec/publicReportingAPI.spec.js +0 -75
- package/spec/report-portal-client.spec.js +0 -730
- package/spec/rest.spec.js +0 -287
- package/spec/support/jasmine.json +0 -11
- package/version_fragment +0 -1
package/lib/rest.js
CHANGED
|
@@ -1,60 +1,98 @@
|
|
|
1
|
-
const axios = require('axios');
|
|
2
|
-
const axiosRetry = require('axios-retry');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
const axiosRetry = require('axios-retry');
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const https = require('https');
|
|
5
|
+
|
|
6
|
+
const DEFAULT_MAX_CONNECTION_TIME_MS = 30000;
|
|
7
|
+
|
|
8
|
+
axiosRetry(axios, { retryDelay: () => 100, retries: 10, retryCondition: axiosRetry.isRetryableError });
|
|
9
|
+
|
|
10
|
+
class RestClient {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.baseURL = options.baseURL;
|
|
13
|
+
this.headers = options.headers;
|
|
14
|
+
this.restClientConfig = options.restClientConfig;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
buildPath(path) {
|
|
18
|
+
return [this.baseURL, path].join('/');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
buildPathToSyncAPI(path) {
|
|
22
|
+
return [this.baseURL.replace('/v2', '/v1'), path].join('/');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static request(method, url, data, options = {}) {
|
|
26
|
+
return axios({
|
|
27
|
+
method,
|
|
28
|
+
url,
|
|
29
|
+
data,
|
|
30
|
+
timeout: DEFAULT_MAX_CONNECTION_TIME_MS,
|
|
31
|
+
...options,
|
|
32
|
+
})
|
|
33
|
+
.then((response) => response.data)
|
|
34
|
+
.catch((error) => {
|
|
35
|
+
const errorMessage = error.message;
|
|
36
|
+
const responseData = error.response && error.response.data;
|
|
37
|
+
throw new Error(`${errorMessage}${
|
|
38
|
+
responseData
|
|
39
|
+
&& typeof responseData === 'object'
|
|
40
|
+
? `: ${JSON.stringify(responseData)}`
|
|
41
|
+
: ''}`);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getRestConfig() {
|
|
46
|
+
if (!this.restClientConfig) return {};
|
|
47
|
+
|
|
48
|
+
const config = Object.keys(this.restClientConfig).reduce((acc, key) => {
|
|
49
|
+
if (key !== 'agent') {
|
|
50
|
+
acc[key] = this.restClientConfig[key];
|
|
51
|
+
}
|
|
52
|
+
return acc;
|
|
53
|
+
}, {});
|
|
54
|
+
|
|
55
|
+
if ('agent' in this.restClientConfig) {
|
|
56
|
+
const { protocol } = new URL(this.baseURL);
|
|
57
|
+
const isHttps = /https:?/;
|
|
58
|
+
const isHttpsRequest = isHttps.test(protocol);
|
|
59
|
+
config[isHttpsRequest ? 'httpsAgent' : 'httpAgent'] = isHttpsRequest
|
|
60
|
+
? new https.Agent(this.restClientConfig.agent)
|
|
61
|
+
: new http.Agent(this.restClientConfig.agent);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return config;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
create(path, data, options = { headers: this.headers }) {
|
|
68
|
+
return RestClient.request('POST', this.buildPath(path), data, { ...options, ...this.getRestConfig() });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
retrieve(path, options = { headers: this.headers }) {
|
|
72
|
+
return RestClient.request('GET', this.buildPath(path), {}, { ...options, ...this.getRestConfig() });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
update(path, data, options = { headers: this.headers }) {
|
|
76
|
+
return RestClient.request('PUT', this.buildPath(path), data, { ...options, ...this.getRestConfig() });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
delete(path, data, options = { headers: this.headers }) {
|
|
80
|
+
return RestClient.request(
|
|
81
|
+
'DELETE',
|
|
82
|
+
this.buildPath(path),
|
|
83
|
+
data,
|
|
84
|
+
{ ...options, ...this.getRestConfig() },
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
retrieveSyncAPI(path, options = { headers: this.headers }) {
|
|
89
|
+
return RestClient.request(
|
|
90
|
+
'GET',
|
|
91
|
+
this.buildPathToSyncAPI(path),
|
|
92
|
+
{},
|
|
93
|
+
{ ...options, ...this.getRestConfig() },
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = RestClient;
|
package/package.json
CHANGED
|
@@ -1,60 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@reportportal/client-javascript",
|
|
3
|
-
"version": "5.0.
|
|
4
|
-
"description": "ReportPortal client for node.js",
|
|
5
|
-
"author": "ReportPortal.io",
|
|
6
|
-
"contributors": [
|
|
7
|
-
{
|
|
8
|
-
"name": "Artsiom Tkachou",
|
|
9
|
-
"email": "artsiom_tkachou@epam.com"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"name": "Alexey Krylov",
|
|
13
|
-
"email": "lexecon117@gmail.com"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"homepage": "https://github.com/reportportal/client-javascript",
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "https://github.com/reportportal/client-javascript.git"
|
|
20
|
-
},
|
|
21
|
-
"directories": {
|
|
22
|
-
"lib": "./lib"
|
|
23
|
-
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@reportportal/client-javascript",
|
|
3
|
+
"version": "5.0.6",
|
|
4
|
+
"description": "ReportPortal client for node.js",
|
|
5
|
+
"author": "ReportPortal.io",
|
|
6
|
+
"contributors": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Artsiom Tkachou",
|
|
9
|
+
"email": "artsiom_tkachou@epam.com"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "Alexey Krylov",
|
|
13
|
+
"email": "lexecon117@gmail.com"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/reportportal/client-javascript",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/reportportal/client-javascript.git"
|
|
20
|
+
},
|
|
21
|
+
"directories": {
|
|
22
|
+
"lib": "./lib"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"/lib",
|
|
26
|
+
"/analytics",
|
|
27
|
+
"/VERSION"
|
|
28
|
+
],
|
|
29
|
+
"main": "./lib/report-portal-client",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">= 10.0.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"axios": "^0.24.0",
|
|
35
|
+
"axios-retry": "^3.2.4",
|
|
36
|
+
"glob": "^7.2.0",
|
|
37
|
+
"uniqid": "^5.4.0",
|
|
38
|
+
"universal-analytics": "^0.4.20"
|
|
39
|
+
},
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"lint": "eslint . --quiet",
|
|
43
|
+
"format": "npm run lint -- --fix",
|
|
44
|
+
"test": "nyc ./node_modules/jasmine/bin/jasmine.js",
|
|
45
|
+
"test:coverage": "nyc report --reporter=lcov --reporter=text-summary"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"eslint": "^7.32.0",
|
|
49
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
50
|
+
"eslint-plugin-import": "^2.25.4",
|
|
51
|
+
"eslint-plugin-node": "^11.1.0",
|
|
52
|
+
"jasmine": "^3.5.0",
|
|
53
|
+
"lodash": "^4.17.11",
|
|
54
|
+
"nock": "^10.0.6",
|
|
55
|
+
"nyc": "^15.1.0"
|
|
56
|
+
},
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/reportportal/client-javascript/issues"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"epam",
|
|
62
|
+
"reportportal",
|
|
63
|
+
"rp"
|
|
64
|
+
]
|
|
65
|
+
}
|
package/.eslintrc
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "airbnb-base",
|
|
3
|
-
"globals": {
|
|
4
|
-
"expectAsync": true
|
|
5
|
-
},
|
|
6
|
-
"env": {
|
|
7
|
-
"node": true,
|
|
8
|
-
"es6": true,
|
|
9
|
-
"jasmine": true
|
|
10
|
-
},
|
|
11
|
-
"rules": {
|
|
12
|
-
"indent": ["error", 4],
|
|
13
|
-
"max-len": ["error", 120],
|
|
14
|
-
"valid-jsdoc": ["error", { "requireReturn": false }],
|
|
15
|
-
"consistent-return": 0
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
-
<code_scheme name="Project" version="173">
|
|
3
|
-
<option name="LINE_SEPARATOR" value=" " />
|
|
4
|
-
<JSCodeStyleSettings version="0">
|
|
5
|
-
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
6
|
-
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
7
|
-
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
8
|
-
<option name="VAR_DECLARATION_WRAP" value="2" />
|
|
9
|
-
<option name="OBJECT_LITERAL_WRAP" value="2" />
|
|
10
|
-
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
11
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
12
|
-
</JSCodeStyleSettings>
|
|
13
|
-
<codeStyleSettings language="JavaScript">
|
|
14
|
-
<option name="RIGHT_MARGIN" value="120" />
|
|
15
|
-
<option name="METHOD_CALL_CHAIN_WRAP" value="2" />
|
|
16
|
-
<option name="IF_BRACE_FORCE" value="1" />
|
|
17
|
-
<option name="DOWHILE_BRACE_FORCE" value="1" />
|
|
18
|
-
<option name="WHILE_BRACE_FORCE" value="1" />
|
|
19
|
-
<option name="FOR_BRACE_FORCE" value="1" />
|
|
20
|
-
</codeStyleSettings>
|
|
21
|
-
</code_scheme>
|
|
22
|
-
</component>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<component name="CopyrightManager">
|
|
2
|
-
<copyright>
|
|
3
|
-
<option name="notice" value=" Copyright 2020 EPAM Systems Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." />
|
|
4
|
-
<option name="myName" value="APACHE-2.0" />
|
|
5
|
-
</copyright>
|
|
6
|
-
</component>
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/client-javascript.iml" filepath="$PROJECT_DIR$/.idea/client-javascript.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|