@woocommerce/csv-export
Advanced tools
Comparing version 1.4.0 to 1.5.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = `Date,Orders,Description,"Total Sales",Refunds,Coupons,Taxes,Shipping,"Net Sales","Negative Number" | ||
exports.default = `Date,Orders,Description,"Total sales",Refunds,Coupons,Taxes,Shipping,"Net sales","Negative number" | ||
2018-04-29T00:00:00,30,"Lorem, ""ipsum""",200,19,19,100,19,200,"\t-123"`; |
@@ -17,3 +17,3 @@ "use strict"; | ||
{ | ||
label: 'Total Sales', | ||
label: 'Total sales', | ||
key: 'total_sales', | ||
@@ -38,9 +38,9 @@ }, | ||
{ | ||
label: 'Net Sales', | ||
label: 'Net sales', | ||
key: 'net_revenue', | ||
}, | ||
{ | ||
label: 'Negative Number', | ||
label: 'Negative number', | ||
key: 'neg_num', | ||
}, | ||
]; |
@@ -50,4 +50,4 @@ "use strict"; | ||
* | ||
* @param {Array.<Object>} headers Object with table header information | ||
* @param {Array.Array.<Object>} rows Object with table rows information | ||
* @param {Array.<Object>} headers Object with table header information | ||
* @param {Array.Array.<Object>} rows Object with table rows information | ||
* @return {string} Table contents in a CSV format | ||
@@ -65,4 +65,4 @@ */ | ||
* | ||
* @param {string} [name=''] Name of the file | ||
* @param {Object} [params={}] Object of key-values to append to the file name | ||
* @param {string} [name=''] Name of the file | ||
* @param {Object} [params={}] Object of key-values to append to the file name | ||
* @return {string} Formatted file name | ||
@@ -73,3 +73,3 @@ */ | ||
name.toLowerCase().replace(/[^a-z0-9]/g, '-'), | ||
moment_1.default().format('YYYY-MM-DD'), | ||
(0, moment_1.default)().format('YYYY-MM-DD'), | ||
Object.keys(params) | ||
@@ -89,4 +89,4 @@ .map((key) => key.toLowerCase().replace(/[^a-z0-9]/g, '-') + | ||
* | ||
* @param {string} fileName Name of the file to download | ||
* @param {string} content Contents of the file to download | ||
* @param {string} fileName Name of the file to download | ||
* @param {string} content Contents of the file to download | ||
*/ | ||
@@ -96,4 +96,4 @@ function downloadCSVFile(fileName, content) { | ||
const blob = new Blob([content], { type: 'text/csv;charset=utf-8' }); | ||
browser_filesaver_1.saveAs(blob, fileName); | ||
(0, browser_filesaver_1.saveAs)(blob, fileName); | ||
} | ||
exports.downloadCSVFile = downloadCSVFile; |
@@ -0,1 +1,7 @@ | ||
# Unreleased | ||
# 1.5.0 | ||
- Update all js packages with minor/patch version changes. #8392 | ||
# 1.4.0 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "@woocommerce/csv-export", | ||
"version": "1.4.0", | ||
"description": "WooCommerce utility library to convert data to CSV files.", | ||
"author": "Automattic", | ||
"license": "GPL-3.0-or-later", | ||
"keywords": [ | ||
"wordpress", | ||
"woocommerce", | ||
"csv" | ||
], | ||
"homepage": "https://github.com/woocommerce/woocommerce-admin/tree/main/packages/csv-export/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/woocommerce/woocommerce-admin.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/woocommerce/woocommerce-admin/issues" | ||
}, | ||
"main": "build/index.js", | ||
"module": "build-module/index.js", | ||
"react-native": "src/index", | ||
"dependencies": { | ||
"browser-filesaver": "1.1.1", | ||
"moment": "2.29.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"clean": "npx rimraf build build-*", | ||
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", | ||
"start": "tsc --build --watch", | ||
"prepack": "npm run clean && npm run build", | ||
"test": "lerna run build && npm run test:nobuild", | ||
"test:nobuild": "jest --config ./jest.config.json", | ||
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests" | ||
}, | ||
"gitHead": "f29f789cb9b668b286e41325e36aa369c5bccffd" | ||
} | ||
"name": "@woocommerce/csv-export", | ||
"version": "1.5.0", | ||
"description": "WooCommerce utility library to convert data to CSV files.", | ||
"author": "Automattic", | ||
"license": "GPL-3.0-or-later", | ||
"keywords": [ | ||
"wordpress", | ||
"woocommerce", | ||
"csv" | ||
], | ||
"homepage": "https://github.com/woocommerce/woocommerce-admin/tree/main/packages/csv-export/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/woocommerce/woocommerce-admin.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/woocommerce/woocommerce-admin/issues" | ||
}, | ||
"main": "build/index.js", | ||
"module": "build-module/index.js", | ||
"react-native": "src/index", | ||
"dependencies": { | ||
"browser-filesaver": "^1.1.1", | ||
"moment": "^2.29.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.17.5", | ||
"jest": "^27.5.1", | ||
"jest-cli": "^27.5.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^27.1.3", | ||
"typescript": "^4.6.2" | ||
}, | ||
"scripts": { | ||
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*", | ||
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", | ||
"start": "tsc --build --watch", | ||
"test": "pnpm run build && pnpm run test:nobuild", | ||
"test:nobuild": "jest --config ./jest.config.json", | ||
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests" | ||
}, | ||
"readme": "# CSV Export\n\nA set of functions to convert data into CSV values, and enable a browser download of the CSV data.\n\n## Installation\n\nInstall the module\n\n```bash\npnpm install @woocommerce/csv-export --save\n```\n\n## Usage\n\n```js\nonClick = () => {\n\t// Create a file name based on a title and optional query. Will return a timestamped\n\t// name, for example: revenue-2018-11-01-interval-month.csv\n\tconst name = generateCSVFileName( 'revenue', { interval: 'month' } );\n\n\t// Create a string of CSV data, `headers` is an array of row headers, put at the top\n\t// of the file. `rows` is a 2 dimensional array. Each array is a line in the file,\n\t// separated by newlines. The second-level arrays are the data points in each row.\n\t// For header format, see https://woocommerce.github.io/woocommerce-admin/#/components/table?id=headers-2\n\t// For rows format, see https://woocommerce.github.io/woocommerce-admin/#/components/table?id=rows-1\n\tconst data = generateCSVDataFromTable( headers, rows );\n\n\t// Triggers a browser UI to save a file, named the first argument, with the contents of\n\t// the second argument.\n\tdownloadCSVFile( name, data );\n}\n```\n\n### generateCSVDataFromTable(headers, rows) ⇒ <code>String</code>\nGenerates a CSV string from table contents\n\n**Returns**: <code>String</code> - Table contents in a CSV format\n\n| Param | Type | Description |\n| --- | --- | --- |\n| headers | <code>Array.<Object></code> | Object with table header information |\n| rows | <code>Array.Array.<Object></code> | Object with table rows information |\n\n### generateCSVFileName([name], [params]) ⇒ <code>String</code>\nGenerates a file name for CSV files based on the provided name, the current date\nand the provided params, which are all appended with hyphens.\n\n**Returns**: <code>String</code> - Formatted file name\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| [name] | <code>String</code> | <code>''</code> | Name of the file |\n| [params] | <code>Object</code> | <code>{}</code> | Object of key-values to append to the file name |\n\n### downloadCSVFile(fileName, content)\nDownloads a CSV file with the given file name and contents\n\n| Param | Type | Description |\n| --- | --- | --- |\n| fileName | <code>String</code> | Name of the file to download |\n| content | <code>String</code> | Contents of the file to download |\n" | ||
} |
@@ -10,3 +10,3 @@ # CSV Export | ||
```bash | ||
npm install @woocommerce/csv-export --save | ||
pnpm install @woocommerce/csv-export --save | ||
``` | ||
@@ -13,0 +13,0 @@ |
@@ -1,2 +0,2 @@ | ||
export default `Date,Orders,Description,"Total Sales",Refunds,Coupons,Taxes,Shipping,"Net Sales","Negative Number" | ||
export default `Date,Orders,Description,"Total sales",Refunds,Coupons,Taxes,Shipping,"Net sales","Negative number" | ||
2018-04-29T00:00:00,30,"Lorem, ""ipsum""",200,19,19,100,19,200,"\t-123"`; |
@@ -15,3 +15,3 @@ export default [ | ||
{ | ||
label: 'Total Sales', | ||
label: 'Total sales', | ||
key: 'total_sales', | ||
@@ -36,9 +36,9 @@ }, | ||
{ | ||
label: 'Net Sales', | ||
label: 'Net sales', | ||
key: 'net_revenue', | ||
}, | ||
{ | ||
label: 'Negative Number', | ||
label: 'Negative number', | ||
key: 'neg_num', | ||
}, | ||
]; |
@@ -54,4 +54,4 @@ /** | ||
* | ||
* @param {Array.<Object>} headers Object with table header information | ||
* @param {Array.Array.<Object>} rows Object with table rows information | ||
* @param {Array.<Object>} headers Object with table header information | ||
* @param {Array.Array.<Object>} rows Object with table rows information | ||
* @return {string} Table contents in a CSV format | ||
@@ -69,4 +69,4 @@ */ | ||
* | ||
* @param {string} [name=''] Name of the file | ||
* @param {Object} [params={}] Object of key-values to append to the file name | ||
* @param {string} [name=''] Name of the file | ||
* @param {Object} [params={}] Object of key-values to append to the file name | ||
* @return {string} Formatted file name | ||
@@ -96,4 +96,4 @@ */ | ||
* | ||
* @param {string} fileName Name of the file to download | ||
* @param {string} content Contents of the file to download | ||
* @param {string} fileName Name of the file to download | ||
* @param {string} content Contents of the file to download | ||
*/ | ||
@@ -100,0 +100,0 @@ export function downloadCSVFile( fileName, content ) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
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
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
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
26
2
714
214325
6
+ Addedmoment@2.30.1(transitive)
- Removedmoment@2.29.1(transitive)
Updatedbrowser-filesaver@^1.1.1
Updatedmoment@^2.29.1