goods-exporter 0.2.5 → 0.2.7
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/README.md +26 -12
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -20,6 +20,9 @@ export tasks with ease.
|
|
|
20
20
|
- YML (Yandex Market Language)
|
|
21
21
|
- CSV
|
|
22
22
|
- Excel
|
|
23
|
+
- TgShop
|
|
24
|
+
- Insales
|
|
25
|
+
- Tilda
|
|
23
26
|
|
|
24
27
|
## Installation
|
|
25
28
|
|
|
@@ -31,35 +34,46 @@ npm install goods-exporter --save
|
|
|
31
34
|
yarn add goods-exporter
|
|
32
35
|
```
|
|
33
36
|
|
|
34
|
-
##
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { GoodsExporter, Product, Category, YMLFormatter } from '../src'
|
|
41
|
+
|
|
42
|
+
// Create an instance of the GoodsExporter class.
|
|
43
|
+
const exporter = new GoodsExporter()
|
|
44
|
+
|
|
45
|
+
const products: Product[] = [] // Put your products;
|
|
46
|
+
const categories: Category[] = [{ id: 1, name: 'Обувь' }]
|
|
47
|
+
|
|
48
|
+
// Call the data export method.
|
|
49
|
+
exporter.export(products, categories)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Example
|
|
35
53
|
|
|
36
54
|
```typescript
|
|
37
|
-
import {GoodsExporter, Formatters, Transformer, Category, Currency, Product, Vat} from "goods-exporter";
|
|
38
55
|
import fs from "fs"; // Import the 'fs' module for file writing.
|
|
39
56
|
|
|
40
57
|
// Create an instance of the GoodsExporter class.
|
|
41
|
-
const exporter = new GoodsExporter()
|
|
58
|
+
const exporter = new GoodsExporter()
|
|
42
59
|
|
|
43
60
|
// Define an object 'transformers' that contains data transformation functions.
|
|
44
|
-
const transformers:
|
|
45
|
-
|
|
61
|
+
const transformers: Transformer[] = [
|
|
62
|
+
(product) => ({
|
|
46
63
|
...product,
|
|
47
64
|
price: product.price + 10000
|
|
48
65
|
}),
|
|
49
|
-
|
|
66
|
+
(product) => ({
|
|
50
67
|
...product,
|
|
51
68
|
images: product.images?.map(image => image.replace("image", "pic"))
|
|
52
69
|
})
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// Define an array 'keys' that contains the transformation keys you want to apply.
|
|
56
|
-
const keys = ["PRICE"];
|
|
70
|
+
]
|
|
57
71
|
|
|
58
72
|
// Set the formatter for exporting data to YML.
|
|
59
|
-
exporter.setFormatter(
|
|
73
|
+
exporter.setFormatter(new YMLFormatter()) // or your own Formatter;
|
|
60
74
|
|
|
61
75
|
// Set transformers based on the specified keys.
|
|
62
|
-
exporter.setTransformers(
|
|
76
|
+
exporter.setTransformers(transformers);
|
|
63
77
|
|
|
64
78
|
// Set an exporter that saves the data to the "output.yml" file.
|
|
65
79
|
exporter.setExporter((data: Buffer) => {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://github.com/Bagi4-source/goods-converter/issues"
|
|
12
12
|
},
|
|
13
13
|
"name": "goods-exporter",
|
|
14
|
-
"version": "0.2.
|
|
14
|
+
"version": "0.2.7",
|
|
15
15
|
"description": "A versatile JavaScript library for exporting goods data to various formats such as YML, CSV, and Excel. Simplify data export tasks with ease.",
|
|
16
16
|
"main": "./dist/cjs/index.cjs",
|
|
17
17
|
"exports": {
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"deepcopy": "^2.1.0",
|
|
51
51
|
"fast-xml-parser": "^4.3.2",
|
|
52
|
-
"json-2-csv": "^5.0.1"
|
|
52
|
+
"json-2-csv": "^5.0.1",
|
|
53
|
+
"xlsx": "^0.18.5"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@rollup/plugin-multi-entry": "^6.0.1",
|