carbone-sdk
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -0,1 +1,9 @@ | ||
### v1.1.0 | ||
- Throw an error when a relative path is passed to the `render` function. Only absolute path are accepted. | ||
- It is possible retry to render a report with the following 2 configurations: | ||
- `retriesOnError` is the number of retries before returning the error. Default value: 1. | ||
- `retriesIntervalOnError` is the interval of time before retrying. Default value: 0ms. | ||
To change the default value, the `setOptions` method have to be used: `sdk.setOptions({ retriesOnError: 5, retriesIntervalOnError: 2000 });` | ||
### v1.0.0 | ||
@@ -2,0 +10,0 @@ - Release July 3rd, 2020 |
let _config = { | ||
carboneUrl: 'https://render.carbone.io/', | ||
isReturningBuffer: true | ||
isReturningBuffer: true, | ||
retriesOnError: 1, // number of retries | ||
retriesIntervalOnError: 0 // unit ms | ||
}; | ||
@@ -5,0 +7,0 @@ |
{ | ||
"name": "carbone-sdk", | ||
"version": "1.0.0", | ||
"description": "SDK for carbone render API", | ||
"version": "1.1.0", | ||
"description": "Carbone Render NodeJS SDK to generate reports easily (PDF, docx, xlsx, ods, odt, ...)", | ||
"main": "index.js", | ||
@@ -21,3 +21,3 @@ "directories": { | ||
"scripts": { | ||
"test": "./node_modules/mocha/bin/mocha", | ||
"test": "./node_modules/mocha/bin/mocha --timeout 5000", | ||
"lint": "eslint ./*/**.js", | ||
@@ -31,3 +31,3 @@ "lint:fix": "eslint ./*/**.js --fix" | ||
"author": "", | ||
"license": "ISC" | ||
"license": "Apache-2.0" | ||
} |
@@ -48,3 +48,3 @@ const get = require('simple-get'); | ||
if (pathOrId.startsWith('/')) { | ||
if (utils.checkPathIsAbsolute(pathOrId)) { | ||
renderFunctions._calculateHash(pathOrId, data.payload, (err, hash) => { | ||
@@ -57,4 +57,6 @@ if (err) { | ||
}); | ||
} else if (pathOrId.length === 64) { | ||
renderFunctions._renderWithTemplateId(pathOrId, null, data, stream, callback); | ||
} else { | ||
renderFunctions._renderWithTemplateId(pathOrId, null, data, stream, callback); | ||
return utils.returnStreamOrCallbackError(new Error('The path must be an absolute path'), stream, callback); | ||
} | ||
@@ -73,3 +75,3 @@ | ||
*/ | ||
_renderWithTemplateId: function (templateId, filePath, data, stream, callback, _retry = false) { | ||
_renderWithTemplateId: function (templateId, filePath, data, stream, callback, _retries = 0) { | ||
get.concat({ | ||
@@ -87,4 +89,8 @@ method: 'POST', | ||
if (err) { | ||
if (err.code === 'ECONNRESET' && _retry === false) { | ||
return renderFunctions._renderWithTemplateId(templateId, null, data, stream, callback, true); | ||
if ( _retries < config.retriesOnError && | ||
(err.code === 'ECONNRESET' || err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT' || | ||
err.code === 'ECONNREFUSED' || err.code === 'ENOTFOUND' || err.code === 'EPIPE')) { | ||
return setTimeout(() => { | ||
renderFunctions._renderWithTemplateId(templateId, filePath, data, stream, callback, _retries + 1); | ||
}, config.retriesIntervalOnError); | ||
} | ||
@@ -102,3 +108,3 @@ return utils.returnStreamOrCallbackError(err, stream, callback); | ||
renderFunctions._renderWithTemplateId(newTemplateId, filePath, data, stream, callback, _retry); | ||
renderFunctions._renderWithTemplateId(newTemplateId, filePath, data, stream, callback, _retries); | ||
}); | ||
@@ -105,0 +111,0 @@ } |
@@ -30,3 +30,3 @@ const get = require('simple-get'); | ||
if (!utils.checkPathIsAbsolute(localPath)) { | ||
return callback(new Error('Your path must be an absolute path')); | ||
return callback(new Error('The path must be an absolute path')); | ||
} | ||
@@ -33,0 +33,0 @@ |
@@ -0,1 +1,3 @@ | ||
const path = require('path'); | ||
module.exports = { | ||
@@ -7,6 +9,5 @@ /** | ||
checkPathIsAbsolute: function (localPath) { | ||
if (localPath.startsWith('/')) { | ||
if (path.isAbsolute(localPath)) { | ||
return true; | ||
} | ||
return false; | ||
@@ -13,0 +14,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36720
13
559
1