monti-apm-core
Advanced tools
Comparing version 1.6.0 to 1.7.0
# Change Log | ||
## 1.7.0 | ||
March 15, 2020 | ||
* Remove request and babel-runtime dependencies | ||
* Add `Kadira.get(path, options)` | ||
## 1.6.0 | ||
@@ -4,0 +10,0 @@ August 12, 2020 |
@@ -32,5 +32,5 @@ 'use strict'; | ||
var _request = require('request'); | ||
var _axios = require('axios'); | ||
var _request2 = _interopRequireDefault(_request); | ||
var _axios2 = _interopRequireDefault(_axios); | ||
@@ -108,10 +108,9 @@ var _clock = require('./clock.js'); | ||
value: function getJob(id) { | ||
var body = { action: 'get', params: {} }; | ||
(0, _assign2.default)(body.params, { id: id }); | ||
var data = { action: 'get', params: {} }; | ||
(0, _assign2.default)(data.params, { id: id }); | ||
var url = this._options.endpoint + '/jobs'; | ||
var params = { | ||
body: body, | ||
headers: this._headers, | ||
json: true | ||
data: data, | ||
headers: this._headers | ||
}; | ||
@@ -125,10 +124,9 @@ | ||
value: function updateJob(id, diff) { | ||
var body = { action: 'set', params: {} }; | ||
(0, _assign2.default)(body.params, diff, { id: id }); | ||
var data = { action: 'set', params: {} }; | ||
(0, _assign2.default)(data.params, diff, { id: id }); | ||
var url = this._options.endpoint + '/jobs'; | ||
var params = { | ||
body: body, | ||
headers: this._headers, | ||
json: true | ||
data: data, | ||
headers: this._headers | ||
}; | ||
@@ -150,12 +148,25 @@ | ||
var url = this._options.endpoint; | ||
var body = (0, _stringify2.default)(payload); | ||
var data = (0, _stringify2.default)(payload); | ||
var params = { | ||
body: body, | ||
data: data, | ||
headers: this._headers | ||
}; | ||
logger('send data - ' + body.substr(0, 50) + '...'); | ||
logger('send data - ' + data.substr(0, 50) + '...'); | ||
return this._send(url, params); | ||
} | ||
}, { | ||
key: 'get', | ||
value: function get(path) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var url = this._options.endpoint + path; | ||
var params = { | ||
headers: (0, _extends3.default)({}, this._headers), | ||
noRetry: options.noRetry | ||
}; | ||
logger('get request to ' + url); | ||
return this._send(url, params); | ||
} | ||
}, { | ||
key: 'sendStream', | ||
@@ -165,3 +176,3 @@ value: function sendStream(path, stream) { | ||
var params = { | ||
body: stream, | ||
data: stream, | ||
headers: (0, _extends3.default)({}, this._headers, { | ||
@@ -187,4 +198,4 @@ 'content-type': 'application/octet-stream' | ||
// communicates with the server with http (using fetch) | ||
// Also handles response http status codes and retries | ||
// communicates with the server with http | ||
// Also handles response http status codes and retries | ||
@@ -194,27 +205,45 @@ }, { | ||
value: function _send(url, params) { | ||
var retryEnabled = true; | ||
if (params.noRetry) { | ||
retryEnabled = false; | ||
delete params.noRetry; | ||
} | ||
return (0, _retry2.default)(function () { | ||
return new _promise2.default(function (resolve, reject) { | ||
_request2.default.post(url, params, function (err, res, body) { | ||
if (err) { | ||
return reject(err); | ||
} | ||
(0, _axios2.default)((0, _extends3.default)({ | ||
url: url | ||
}, params, { | ||
method: params.method || 'POST' | ||
})).then(function (res) { | ||
return resolve(res.data); | ||
}).catch(function (err) { | ||
if (err.response && err.response.status) { | ||
var status = err.response.status; | ||
if (res.statusCode === 200) { | ||
return resolve(body); | ||
} | ||
if (status === 401) { | ||
logger('Error: Unauthorized'); | ||
return reject(new _retry.ByPassRetryError('Unauthorized')); | ||
} else if (status >= 400 && status < 500) { | ||
var _message = 'Agent Error: ' + status; | ||
logger('Error: ' + _message); | ||
return reject(new _retry.ByPassRetryError(_message)); | ||
} | ||
if (res.statusCode === 401) { | ||
logger('Error: Unauthorized'); | ||
return reject(new _retry.ByPassRetryError('Unauthorized')); | ||
var message = 'Request failed: ' + status; | ||
var ErrConstructor = retryEnabled ? Error : _retry.ByPassRetryError; | ||
logger('Error: ' + message); | ||
return reject(new ErrConstructor(message)); | ||
} | ||
if (res.statusCode >= 400 && res.statusCode < 500) { | ||
var _message = 'Agent Error: ' + res.statusCode; | ||
logger('Error: ' + _message); | ||
return reject(new _retry.ByPassRetryError(_message)); | ||
if (!retryEnabled) { | ||
var oldErr = err; | ||
// eslint-disable-next-line no-param-reassign | ||
err = new _retry.ByPassRetryError(oldErr.message); | ||
err.stack = oldErr.stack; | ||
} | ||
var message = 'Request failed: ' + res.statusCode; | ||
logger('Error: ' + message); | ||
reject(new Error(message)); | ||
return reject(err); | ||
}); | ||
@@ -221,0 +250,0 @@ }); |
{ | ||
"name": "monti-apm-core", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Monti APM Core API", | ||
@@ -17,3 +17,3 @@ "main": "./dist/", | ||
"prepublish": "./node_modules/.bin/babel --plugins \"transform-runtime\" lib --ignore __tests__ --out-dir ./dist", | ||
"lint": "./node_modules/.bin/eslint ./lib", | ||
"lint": "./node_modules/.bin/eslint ./lib --cache", | ||
"lintfix": "./node_modules/.bin/eslint ./lib --fix", | ||
@@ -52,7 +52,5 @@ "testonly": "mocha --require scripts/mocha-bootload lib/**/__tests__/**/*.js", | ||
"dependencies": { | ||
"axios": "^0.19.2", | ||
"babel-runtime": "6.x.x", | ||
"debug": "^3.2.6", | ||
"request": "2.x.x" | ||
"axios": "^0.21.1", | ||
"debug": "^3.2.6" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
17294
2
383
0
+ Addedaxios@0.21.4(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedbabel-runtime@6.x.x
- Removedrequest@2.x.x
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedaxios@0.19.2(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfollow-redirects@1.5.10(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updatedaxios@^0.21.1