@bcgov/carbone-render
Advanced tools
+2
-2
| { | ||
| "name": "@bcgov/carbone-render", | ||
| "version": "2.1.2", | ||
| "version": "2.2.0", | ||
| "description": "Async wrapper around Carbone render", | ||
@@ -38,3 +38,3 @@ "main": "index.js", | ||
| "dependencies": { | ||
| "carbone": "^2.1.1", | ||
| "carbone": "^3.1.0", | ||
| "fs-extra": "^10.0.0", | ||
@@ -41,0 +41,0 @@ "uuid": "^8.3.2" |
+49
-39
@@ -1,34 +0,45 @@ | ||
| ## carbone-render | ||
| Library to generate a document from an existing template and JSON data. This is a wrapper around [carbone](https://carbone.io), please refer to their documentation for more detail. | ||
| # carbone-render | ||
| ### important | ||
| This library will require LibreOffice installed. It requires LibreOffice to do pdf generation. | ||
| [](https://www.npmjs.com/package/@bcgov/carbone-render) | ||
| [](https://npmcharts.com/compare/@bcgov/carbone-render?minimal=true) | ||
| [](LICENSE) | ||
| [](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md) | ||
| ### usage | ||
| Library to generate a document from an existing template and JSON data. This is a wrapper around [carbone](https://carbone.io), please refer to their documentation for more detail. | ||
| #### install/initialize | ||
| ## Prerequisites | ||
| ``` | ||
| This library will require LibreOffice installed to do pdf generation. | ||
| ## Installation | ||
| ```sh | ||
| npm i @bcgov/carbone-render | ||
| ... | ||
| ``` | ||
| ## Usage | ||
| ```js | ||
| const carboneRenderer = require('@bcgov/carbone-render'); | ||
| ``` | ||
| #### startFactory | ||
| Optional call to start up the carbone python converter. This is recommended to call on start of your application, otherwise, the first call to render will take longer as it starts the converter. | ||
| ### startFactory | ||
| ``` | ||
| Optional call to start up the carbone python converter. This is recommended to call on the start of your application. Otherwise, the first call to render will take longer as it starts the converter in the background. | ||
| ```js | ||
| carboneRenderer.startFactory(); | ||
| ``` | ||
| #### fileTypes | ||
| Return a dictionary of allowable file conversions. Convert to pdf is always allowed. | ||
| ### fileTypes | ||
| ``` | ||
| Return a dictionary of allowable file conversions. Convert to pdf is always allowed. | ||
| ```js | ||
| const allowedConversions = carboneRenderer.fileTypes; | ||
| ``` | ||
| ##### returns object | ||
| ``` | ||
| Returns dictionary | ||
| ```json | ||
| { | ||
@@ -99,14 +110,15 @@ "csv": [ | ||
| #### async render | ||
| Generate a new document from a template and JSON data. Render the report. | ||
| ### async render | ||
| ``` | ||
| const data = { | ||
| Generate a new document from a template and JSON data. Render the report. | ||
| ```js | ||
| const data = { | ||
| "firstName": "Jane", | ||
| "lastName": "Smith", | ||
| "title": "Who?" | ||
| "title": "Who?" | ||
| }; | ||
| const options = { | ||
| "convertTo": "pdf", | ||
| "convertTo": "pdf", | ||
| "reportName": "{d.firstName}-{d.lastName}.docx", | ||
@@ -120,6 +132,6 @@ "overwrite": "true", | ||
| yesOrNo : function (data) { // data = d.myBoolean | ||
| if (this.lang === 'fr') { | ||
| return data === true ? 'oui' : 'non'; | ||
| } | ||
| return data === true ? 'yes' : 'no'; | ||
| if (this.lang === 'fr') { | ||
| return data === true ? 'oui' : 'non'; | ||
| } | ||
| return data === true ? 'yes' : 'no'; | ||
| } | ||
@@ -140,10 +152,11 @@ }; | ||
| ##### returns object | ||
| ``` | ||
| { | ||
| success: false, | ||
| errorType: null, | ||
| errorMsg: null, | ||
| reportName: null, | ||
| report: null | ||
| Returns object | ||
| ```json | ||
| { | ||
| "success": false, | ||
| "errorType": null, | ||
| "errorMsg": null, | ||
| "reportName": null, | ||
| "report": null | ||
| } | ||
@@ -159,4 +172,1 @@ ``` | ||
| | report | binary - generated file | | ||
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
20650
1.44%169
6.29%0
-100%+ Added
- Removed
Updated