goods-exporter 0.5.2 → 0.5.5

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/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- The MIT License (MIT)
2
-
3
- Copyright © 2023 German Bagdasaryan
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- “Software”), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2023 German Bagdasaryan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ “Software”), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,102 +1,103 @@
1
- # goods-exporter
2
-
3
- [![npm version](https://img.shields.io/npm/v/goods-exporter)](https://www.npmjs.com/package/goods-exporter)
4
- ![npm](https://img.shields.io/npm/dm/goods-exporter)
5
- ![GitHub issues](https://img.shields.io/github/issues/Bagi4-source/goods-converter)
6
- [![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/Bagi4-source/goods-converter/blob/main/LICENSE)
7
-
8
-
9
- A versatile JavaScript library for exporting goods data to various formats such as YML, CSV, and Excel. Simplify data
10
- export tasks with ease.
11
-
12
- [![Telegram](https://img.shields.io/badge/Telegram-%40goods_exporter-blue?logo=telegram)](https://t.me/+gGHmBC8VZ4BjYjZi)
13
-
14
- ## Features
15
-
16
- - Export goods data to JSON, YML, CSV, and Excel formats.
17
- - Easily integrate into your JavaScript projects.
18
- - Compatible with Node.js version 16 and above.
19
- - Comprehensive TypeScript type definitions included.
20
- - Supports streams.
21
-
22
- ## Supported formats
23
-
24
- - YML (Yandex Market Language)
25
- - JSON
26
- - CSV
27
- - Excel
28
- - TgShop
29
- - Insales
30
- - Tilda
31
-
32
- ## Installation
33
-
34
- To use `goods-exporter` in your project, simply add it to your dependencies using npm or yarn:
35
-
36
- ```bash
37
- npm install goods-exporter --save
38
- # or
39
- yarn add goods-exporter
40
- ```
41
-
42
- ## Quick start
43
-
44
- ```typescript
45
- import { GoodsExporter, Product, Category, Formatters } from '../src';
46
- import { PassThrough } from "stream";
47
-
48
- // Create an instance of the GoodsExporter class.
49
- const exporter = new GoodsExporter()
50
-
51
- const products: Product[] = [] // Put your products;
52
- const categories: Category[] = [{ id: 1, name: 'Обувь' }]
53
-
54
- // Call the data export method.
55
- const stream = new PassThrough();
56
- exporter.setExporter(() => stream);
57
- exporter.setFormatter(new Formatters.YMLFormatter());
58
- exporter.setTransformers([
59
- (products) => {
60
- return products.map((product) => ({
61
- ...product,
62
- price: product.price + 10000,
63
- images: product.images?.map((image) => image.replace("image", "pic")),
64
- }));
65
- },
66
- ]);
67
- await exporter.export(products, categories);
68
- ```
69
-
70
- ## Example
71
-
72
- ```typescript
73
- import fs from "fs"; // Import the 'fs' module for file writing.
74
-
75
- // Create an instance of the GoodsExporter class.
76
- const exporter = new GoodsExporter()
77
-
78
- // Define an object 'transformers' that contains data transformation functions.
79
- const transformers: Transformer[] = [
80
- (products) => products.map(product => ({
81
- ...product,
82
- price: product.price + 10000
83
- })),
84
- (products) => products.map(product => ({
85
- ...product,
86
- images: product.images?.map(image => image.replace("image", "pic"))
87
- }))
88
- ]
89
-
90
- // Set the formatter for exporting data to YML.
91
- exporter.setFormatter(new Formatters.YMLFormatter()) // or your own Formatter;
92
-
93
- // Set transformers based on the specified keys.
94
- exporter.setTransformers(transformers);
95
-
96
- // Set an exporter that saves the data to the "output.yml" file.
97
- exporter.setExporter(fs.createWriteStream("output.yml"));
98
- await exporter.export(products, categories);
99
- ```
100
-
101
- # Supported by [PoizonAPI](https://t.me/PoizonAPI)
102
- [![PoizonAPI](https://i.ibb.co/HBbTpp0/Group-1.png)](https://t.me/PoizonAPI)
1
+ # goods-exporter
2
+
3
+ [![npm version](https://img.shields.io/npm/v/goods-exporter)](https://www.npmjs.com/package/goods-exporter)
4
+ ![npm](https://img.shields.io/npm/dm/goods-exporter)
5
+ ![GitHub issues](https://img.shields.io/github/issues/Bagi4-source/goods-converter)
6
+ [![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/Bagi4-source/goods-converter/blob/main/LICENSE)
7
+
8
+
9
+ A versatile JavaScript library for exporting goods data to various formats such as YML, CSV, and Excel. Simplify data
10
+ export tasks with ease.
11
+
12
+ [![Telegram](https://img.shields.io/badge/Telegram-%40goods_exporter-blue?logo=telegram)](https://t.me/+gGHmBC8VZ4BjYjZi)
13
+
14
+ ## Features
15
+
16
+ - Export goods data to JSON, YML, CSV, and Excel formats.
17
+ - Easily integrate into your JavaScript projects.
18
+ - Compatible with Node.js version 16 and above.
19
+ - Comprehensive TypeScript type definitions included.
20
+ - Supports streams.
21
+
22
+ ## Supported formats
23
+
24
+ - YML (Yandex Market Language)
25
+ - JSON
26
+ - SimpleJSON (grouped)
27
+ - CSV
28
+ - Excel
29
+ - TgShop
30
+ - Insales
31
+ - Tilda
32
+
33
+ ## Installation
34
+
35
+ To use `goods-exporter` in your project, simply add it to your dependencies using npm or yarn:
36
+
37
+ ```bash
38
+ npm install goods-exporter --save
39
+ # or
40
+ yarn add goods-exporter
41
+ ```
42
+
43
+ ## Quick start
44
+
45
+ ```typescript
46
+ import { GoodsExporter, Product, Category, Formatters } from '../src';
47
+ import { PassThrough } from "stream";
48
+
49
+ // Create an instance of the GoodsExporter class.
50
+ const exporter = new GoodsExporter()
51
+
52
+ const products: Product[] = [] // Put your products;
53
+ const categories: Category[] = [{ id: 1, name: 'Обувь' }]
54
+
55
+ // Call the data export method.
56
+ const stream = new PassThrough();
57
+ exporter.setExporter(() => stream);
58
+ exporter.setFormatter(new Formatters.YMLFormatter());
59
+ exporter.setTransformers([
60
+ (products) => {
61
+ return products.map((product) => ({
62
+ ...product,
63
+ price: product.price + 10000,
64
+ images: product.images?.map((image) => image.replace("image", "pic")),
65
+ }));
66
+ },
67
+ ]);
68
+ await exporter.export(products, categories);
69
+ ```
70
+
71
+ ## Example
72
+
73
+ ```typescript
74
+ import fs from "fs"; // Import the 'fs' module for file writing.
75
+
76
+ // Create an instance of the GoodsExporter class.
77
+ const exporter = new GoodsExporter()
78
+
79
+ // Define an object 'transformers' that contains data transformation functions.
80
+ const transformers: Transformer[] = [
81
+ (products) => products.map(product => ({
82
+ ...product,
83
+ price: product.price + 10000
84
+ })),
85
+ (products) => products.map(product => ({
86
+ ...product,
87
+ images: product.images?.map(image => image.replace("image", "pic"))
88
+ }))
89
+ ]
90
+
91
+ // Set the formatter for exporting data to YML.
92
+ exporter.setFormatter(new Formatters.YMLFormatter()) // or your own Formatter;
93
+
94
+ // Set transformers based on the specified keys.
95
+ exporter.setTransformers(transformers);
96
+
97
+ // Set an exporter that saves the data to the "output.yml" file.
98
+ exporter.setExporter(fs.createWriteStream("output.yml"));
99
+ await exporter.export(products, categories);
100
+ ```
101
+
102
+ # Supported by [PoizonAPI](https://t.me/PoizonAPI)
103
+ [![PoizonAPI](https://i.ibb.co/HBbTpp0/Group-1.png)](https://t.me/PoizonAPI)
package/dist/bundle.d.ts CHANGED
@@ -87,6 +87,12 @@ interface Product {
87
87
  * Пример: 01.01.2000
88
88
  */
89
89
  saleDate?: string;
90
+ /**
91
+ * **Вендор в магазине**
92
+ *
93
+ * Содержит номер вендора, а не ее название.
94
+ */
95
+ vendorId?: number;
90
96
  /**
91
97
  * **Категория в магазине**
92
98
  *
@@ -622,6 +628,12 @@ declare class JSONFormatter implements FormatterAbstract {
622
628
  format(products: Product[], categories?: Category[], brands?: Brand[], _?: FormatterOptions): Promise<Stream>;
623
629
  }
624
630
 
631
+ declare class SimpleJSONFormatter implements FormatterAbstract {
632
+ formatterName: string;
633
+ fileExtension: Extension;
634
+ format(products: Product[], categories?: Category[], brands?: Brand[], _?: FormatterOptions): Promise<Stream>;
635
+ }
636
+
625
637
  declare class TgShopFormatter implements FormatterAbstract {
626
638
  formatterName: string;
627
639
  fileExtension: Extension;
@@ -640,7 +652,7 @@ declare class YMLFormatter implements FormatterAbstract {
640
652
  format(products: Product[], categories?: Category[], brands?: Brand[], options?: FormatterOptions): Promise<Stream>;
641
653
  private getBrands;
642
654
  private getCategories;
643
- private getOffers;
655
+ private getOffer;
644
656
  }
645
657
 
646
658
  declare const Formatters: {
@@ -651,6 +663,7 @@ declare const Formatters: {
651
663
  TgShopFormatter: typeof TgShopFormatter;
652
664
  ExcelFormatter: typeof ExcelFormatter;
653
665
  JSONFormatter: typeof JSONFormatter;
666
+ SimpleJSONFormatter: typeof SimpleJSONFormatter;
654
667
  };
655
668
 
656
669
  type Transformer = (products: Product[]) => Product[] | Promise<Product[]>;