goods-exporter 1.3.2 → 1.3.4
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 +21 -21
- package/README.md +106 -106
- package/dist/cjs/index.cjs +32 -81
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +32 -81
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +87 -87
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,106 +1,106 @@
|
|
|
1
|
-
# goods-exporter
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/goods-exporter)
|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
[](https://github.com/Bagi4-source/goods-converter/blob/main/LICENSE)
|
|
7
|
-
|
|
8
|
-
A versatile JavaScript library for exporting goods data to various formats such as YML, CSV, and Excel. Simplify data
|
|
9
|
-
export tasks with ease.
|
|
10
|
-
|
|
11
|
-
[](https://t.me/+gGHmBC8VZ4BjYjZi)
|
|
12
|
-
|
|
13
|
-
## Features
|
|
14
|
-
|
|
15
|
-
- Export goods data to JSON, YML, CSV, and Excel formats.
|
|
16
|
-
- Easily integrate into your JavaScript projects.
|
|
17
|
-
- Compatible with Node.js version 16 and above.
|
|
18
|
-
- Comprehensive TypeScript type definitions included.
|
|
19
|
-
- Supports streams.
|
|
20
|
-
|
|
21
|
-
## Supported formats
|
|
22
|
-
|
|
23
|
-
- YML (Yandex Market Language)
|
|
24
|
-
- JSON
|
|
25
|
-
- SimpleJSON (grouped)
|
|
26
|
-
- CSV
|
|
27
|
-
- Excel
|
|
28
|
-
- TgShop
|
|
29
|
-
- Insales
|
|
30
|
-
- Tilda
|
|
31
|
-
- WooCommerce
|
|
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) =>
|
|
82
|
-
products.map((product) => ({
|
|
83
|
-
...product,
|
|
84
|
-
price: product.price + 10000,
|
|
85
|
-
})),
|
|
86
|
-
(products) =>
|
|
87
|
-
products.map((product) => ({
|
|
88
|
-
...product,
|
|
89
|
-
images: product.images?.map((image) => image.replace("image", "pic")),
|
|
90
|
-
})),
|
|
91
|
-
];
|
|
92
|
-
|
|
93
|
-
// Set the formatter for exporting data to YML.
|
|
94
|
-
exporter.setFormatter(new Formatters.YMLFormatter()); // or your own Formatter;
|
|
95
|
-
|
|
96
|
-
// Set transformers based on the specified keys.
|
|
97
|
-
exporter.setTransformers(transformers);
|
|
98
|
-
|
|
99
|
-
// Set an exporter that saves the data to the "output.yml" file.
|
|
100
|
-
exporter.setExporter(fs.createWriteStream("output.yml"));
|
|
101
|
-
await exporter.export(products, categories);
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
# Supported by [PoizonAPI](https://t.me/PoizonAPI)
|
|
105
|
-
|
|
106
|
-
[](https://t.me/PoizonAPI)
|
|
1
|
+
# goods-exporter
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/goods-exporter)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
[](https://github.com/Bagi4-source/goods-converter/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
A versatile JavaScript library for exporting goods data to various formats such as YML, CSV, and Excel. Simplify data
|
|
9
|
+
export tasks with ease.
|
|
10
|
+
|
|
11
|
+
[](https://t.me/+gGHmBC8VZ4BjYjZi)
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Export goods data to JSON, YML, CSV, and Excel formats.
|
|
16
|
+
- Easily integrate into your JavaScript projects.
|
|
17
|
+
- Compatible with Node.js version 16 and above.
|
|
18
|
+
- Comprehensive TypeScript type definitions included.
|
|
19
|
+
- Supports streams.
|
|
20
|
+
|
|
21
|
+
## Supported formats
|
|
22
|
+
|
|
23
|
+
- YML (Yandex Market Language)
|
|
24
|
+
- JSON
|
|
25
|
+
- SimpleJSON (grouped)
|
|
26
|
+
- CSV
|
|
27
|
+
- Excel
|
|
28
|
+
- TgShop
|
|
29
|
+
- Insales
|
|
30
|
+
- Tilda
|
|
31
|
+
- WooCommerce
|
|
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) =>
|
|
82
|
+
products.map((product) => ({
|
|
83
|
+
...product,
|
|
84
|
+
price: product.price + 10000,
|
|
85
|
+
})),
|
|
86
|
+
(products) =>
|
|
87
|
+
products.map((product) => ({
|
|
88
|
+
...product,
|
|
89
|
+
images: product.images?.map((image) => image.replace("image", "pic")),
|
|
90
|
+
})),
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
// Set the formatter for exporting data to YML.
|
|
94
|
+
exporter.setFormatter(new Formatters.YMLFormatter()); // or your own Formatter;
|
|
95
|
+
|
|
96
|
+
// Set transformers based on the specified keys.
|
|
97
|
+
exporter.setTransformers(transformers);
|
|
98
|
+
|
|
99
|
+
// Set an exporter that saves the data to the "output.yml" file.
|
|
100
|
+
exporter.setExporter(fs.createWriteStream("output.yml"));
|
|
101
|
+
await exporter.export(products, categories);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
# Supported by [PoizonAPI](https://t.me/PoizonAPI)
|
|
105
|
+
|
|
106
|
+
[](https://t.me/PoizonAPI)
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -53,10 +53,7 @@ const urlQueryEncode = (inputUrl) => {
|
|
|
53
53
|
|
|
54
54
|
var __defProp$b = Object.defineProperty;
|
|
55
55
|
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
56
|
-
var __publicField$b = (obj, key, value) =>
|
|
57
|
-
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
58
|
-
return value;
|
|
59
|
-
};
|
|
56
|
+
var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
60
57
|
class CSVStream {
|
|
61
58
|
constructor({ delimiter, lineSeparator, emptyFieldValue }) {
|
|
62
59
|
__publicField$b(this, "stream", new stream$3.PassThrough());
|
|
@@ -65,12 +62,9 @@ class CSVStream {
|
|
|
65
62
|
__publicField$b(this, "emptyFieldValue", "");
|
|
66
63
|
__publicField$b(this, "columns", /* @__PURE__ */ new Set());
|
|
67
64
|
__publicField$b(this, "writer", writeWithDrain(this.stream));
|
|
68
|
-
if (delimiter !== void 0)
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
this.lineSeparator = lineSeparator;
|
|
72
|
-
if (emptyFieldValue !== void 0)
|
|
73
|
-
this.emptyFieldValue = emptyFieldValue;
|
|
65
|
+
if (delimiter !== void 0) this.delimiter = delimiter;
|
|
66
|
+
if (lineSeparator !== void 0) this.lineSeparator = lineSeparator;
|
|
67
|
+
if (emptyFieldValue !== void 0) this.emptyFieldValue = emptyFieldValue;
|
|
74
68
|
}
|
|
75
69
|
get writableStream() {
|
|
76
70
|
return this.stream;
|
|
@@ -102,10 +96,7 @@ var Extension = /* @__PURE__ */ ((Extension2) => {
|
|
|
102
96
|
|
|
103
97
|
var __defProp$a = Object.defineProperty;
|
|
104
98
|
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
105
|
-
var __publicField$a = (obj, key, value) =>
|
|
106
|
-
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
107
|
-
return value;
|
|
108
|
-
};
|
|
99
|
+
var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
109
100
|
class CSVFormatter {
|
|
110
101
|
constructor() {
|
|
111
102
|
__publicField$a(this, "formatterName", "CSV");
|
|
@@ -150,8 +141,7 @@ class CSVFormatter {
|
|
|
150
141
|
]);
|
|
151
142
|
products.forEach((product) => {
|
|
152
143
|
Object.entries(product).forEach(([key, value]) => {
|
|
153
|
-
if (value)
|
|
154
|
-
columns.add(key);
|
|
144
|
+
if (value) columns.add(key);
|
|
155
145
|
});
|
|
156
146
|
});
|
|
157
147
|
csvStream.setColumns(columns);
|
|
@@ -179,10 +169,7 @@ class CSVFormatter {
|
|
|
179
169
|
|
|
180
170
|
var __defProp$9 = Object.defineProperty;
|
|
181
171
|
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
182
|
-
var __publicField$9 = (obj, key, value) =>
|
|
183
|
-
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
184
|
-
return value;
|
|
185
|
-
};
|
|
172
|
+
var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
186
173
|
const { stream: stream$2 } = pkg;
|
|
187
174
|
class ExcelFormatter {
|
|
188
175
|
constructor() {
|
|
@@ -222,8 +209,7 @@ class ExcelFormatter {
|
|
|
222
209
|
]);
|
|
223
210
|
products.forEach((product) => {
|
|
224
211
|
Object.entries(product).forEach(([key, value]) => {
|
|
225
|
-
if (value)
|
|
226
|
-
columns.add(key);
|
|
212
|
+
if (value) columns.add(key);
|
|
227
213
|
});
|
|
228
214
|
});
|
|
229
215
|
const workbook = new stream$2.xlsx.WorkbookWriter({
|
|
@@ -259,10 +245,7 @@ class ExcelFormatter {
|
|
|
259
245
|
|
|
260
246
|
var __defProp$8 = Object.defineProperty;
|
|
261
247
|
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
262
|
-
var __publicField$8 = (obj, key, value) =>
|
|
263
|
-
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
264
|
-
return value;
|
|
265
|
-
};
|
|
248
|
+
var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
266
249
|
const { stream: stream$1 } = pkg;
|
|
267
250
|
class InsalesFormatter {
|
|
268
251
|
constructor() {
|
|
@@ -292,8 +275,7 @@ class InsalesFormatter {
|
|
|
292
275
|
const categories2 = {};
|
|
293
276
|
const categoryList = new Array();
|
|
294
277
|
function addCategory(categoryId) {
|
|
295
|
-
if (categoryId === void 0)
|
|
296
|
-
return;
|
|
278
|
+
if (categoryId === void 0) return;
|
|
297
279
|
const category = mappedCategories[categoryId];
|
|
298
280
|
if (category) {
|
|
299
281
|
categoryList.push(category.name);
|
|
@@ -361,7 +343,8 @@ class InsalesFormatter {
|
|
|
361
343
|
const row = {
|
|
362
344
|
"\u0412\u043D\u0435\u0448\u043D\u0438\u0439 ID": externalId,
|
|
363
345
|
"\u0421\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u0442\u043E\u0432\u0430\u0440": product.url,
|
|
364
|
-
\u0410\u0440\u0442\u0438\u043A\u0443\u043B:
|
|
346
|
+
\u0410\u0440\u0442\u0438\u043A\u0443\u043B: externalId,
|
|
347
|
+
// TODO: product.vendorCode,
|
|
365
348
|
"\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0442\u043E\u0432\u0430\u0440\u0430 \u0438\u043B\u0438 \u0443\u0441\u043B\u0443\u0433\u0438": product.title,
|
|
366
349
|
"\u0412\u0440\u0435\u043C\u044F \u0434\u043E\u0441\u0442\u0430\u0432\u043A\u0438: \u041C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435": product.timeDelivery?.min,
|
|
367
350
|
"\u0412\u0440\u0435\u043C\u044F \u0434\u043E\u0441\u0442\u0430\u0432\u043A\u0438: \u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435": product.timeDelivery?.max,
|
|
@@ -381,6 +364,8 @@ class InsalesFormatter {
|
|
|
381
364
|
"\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F \u0432\u0430\u0440\u0438\u0430\u043D\u0442\u0430": product.parentId === void 0 ? product.images?.join(" ") : void 0,
|
|
382
365
|
\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F: product.parentId === void 0 ? void 0 : product.images?.join(" "),
|
|
383
366
|
"\u0421\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u0432\u0438\u0434\u0435\u043E": product.videos ? product.videos[0] : void 0,
|
|
367
|
+
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0410\u0440\u0442\u0438\u043A\u0443\u043B": product.vendorCode,
|
|
368
|
+
// TODO: брать из обычных параметров
|
|
384
369
|
...getParams(product),
|
|
385
370
|
...getProperties(product),
|
|
386
371
|
"\u0420\u0430\u0437\u043C\u0435\u0440\u043D\u0430\u044F \u0441\u0435\u0442\u043A\u0430": JSON.stringify(product.sizes),
|
|
@@ -396,10 +381,7 @@ class InsalesFormatter {
|
|
|
396
381
|
|
|
397
382
|
var __defProp$7 = Object.defineProperty;
|
|
398
383
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
399
|
-
var __publicField$7 = (obj, key, value) =>
|
|
400
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
401
|
-
return value;
|
|
402
|
-
};
|
|
384
|
+
var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
403
385
|
class JSONFormatter {
|
|
404
386
|
constructor() {
|
|
405
387
|
__publicField$7(this, "formatterName", "JSON");
|
|
@@ -417,10 +399,7 @@ class JSONFormatter {
|
|
|
417
399
|
|
|
418
400
|
var __defProp$6 = Object.defineProperty;
|
|
419
401
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
420
|
-
var __publicField$6 = (obj, key, value) =>
|
|
421
|
-
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
422
|
-
return value;
|
|
423
|
-
};
|
|
402
|
+
var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
424
403
|
class SimpleJSONFormatter {
|
|
425
404
|
constructor() {
|
|
426
405
|
__publicField$6(this, "formatterName", "JSON");
|
|
@@ -429,19 +408,16 @@ class SimpleJSONFormatter {
|
|
|
429
408
|
async format(writableStream, products, categories, brands, _) {
|
|
430
409
|
const groupedProduct = /* @__PURE__ */ new Map();
|
|
431
410
|
products.forEach((product) => {
|
|
432
|
-
if (product.parentId !== void 0)
|
|
433
|
-
return;
|
|
411
|
+
if (product.parentId !== void 0) return;
|
|
434
412
|
groupedProduct.set(product.variantId, {
|
|
435
413
|
...product,
|
|
436
414
|
children: []
|
|
437
415
|
});
|
|
438
416
|
});
|
|
439
417
|
products.forEach((product) => {
|
|
440
|
-
if (product.parentId === void 0)
|
|
441
|
-
return;
|
|
418
|
+
if (product.parentId === void 0) return;
|
|
442
419
|
const parent = groupedProduct.get(product.parentId);
|
|
443
|
-
if (!parent)
|
|
444
|
-
return;
|
|
420
|
+
if (!parent) return;
|
|
445
421
|
parent.children.push(product);
|
|
446
422
|
});
|
|
447
423
|
const stream = new jsonStreamStringify.JsonStreamStringify({
|
|
@@ -455,10 +431,7 @@ class SimpleJSONFormatter {
|
|
|
455
431
|
|
|
456
432
|
var __defProp$5 = Object.defineProperty;
|
|
457
433
|
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
458
|
-
var __publicField$5 = (obj, key, value) =>
|
|
459
|
-
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
460
|
-
return value;
|
|
461
|
-
};
|
|
434
|
+
var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
462
435
|
const { stream } = pkg;
|
|
463
436
|
class TgShopFormatter {
|
|
464
437
|
constructor() {
|
|
@@ -536,10 +509,7 @@ class TgShopFormatter {
|
|
|
536
509
|
|
|
537
510
|
var __defProp$4 = Object.defineProperty;
|
|
538
511
|
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
539
|
-
var __publicField$4 = (obj, key, value) =>
|
|
540
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
541
|
-
return value;
|
|
542
|
-
};
|
|
512
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
543
513
|
class TildaFormatter {
|
|
544
514
|
constructor() {
|
|
545
515
|
__publicField$4(this, "formatterName", "Tilda");
|
|
@@ -592,10 +562,7 @@ class TildaFormatter {
|
|
|
592
562
|
|
|
593
563
|
var __defProp$3 = Object.defineProperty;
|
|
594
564
|
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
595
|
-
var __publicField$3 = (obj, key, value) =>
|
|
596
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
597
|
-
return value;
|
|
598
|
-
};
|
|
565
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
599
566
|
class WooCommerceFormatter {
|
|
600
567
|
constructor() {
|
|
601
568
|
__publicField$3(this, "formatterName", "WooCommerce");
|
|
@@ -639,8 +606,7 @@ class WooCommerceFormatter {
|
|
|
639
606
|
});
|
|
640
607
|
}
|
|
641
608
|
createAttribute(data) {
|
|
642
|
-
if (!data?.name || data.id === void 0)
|
|
643
|
-
return;
|
|
609
|
+
if (!data?.name || data.id === void 0) return;
|
|
644
610
|
const attributeStartName = "Attribute";
|
|
645
611
|
const attribute = {};
|
|
646
612
|
attribute[`${attributeStartName} ${data.id} name`] = data.name;
|
|
@@ -687,8 +653,7 @@ class WooCommerceFormatter {
|
|
|
687
653
|
visible: 0,
|
|
688
654
|
global: 0
|
|
689
655
|
});
|
|
690
|
-
if (!attribute)
|
|
691
|
-
return;
|
|
656
|
+
if (!attribute) return;
|
|
692
657
|
Object.entries(attribute).forEach(
|
|
693
658
|
([key2, value2]) => paramAttributes[key2] = value2
|
|
694
659
|
);
|
|
@@ -721,8 +686,7 @@ class WooCommerceFormatter {
|
|
|
721
686
|
values: value,
|
|
722
687
|
global: 0
|
|
723
688
|
});
|
|
724
|
-
if (!attribute)
|
|
725
|
-
return;
|
|
689
|
+
if (!attribute) return;
|
|
726
690
|
Object.entries(attribute).forEach(
|
|
727
691
|
([key2, value2]) => propertyAttributes[key2] = value2
|
|
728
692
|
);
|
|
@@ -734,8 +698,7 @@ class WooCommerceFormatter {
|
|
|
734
698
|
}
|
|
735
699
|
removeVisibleFromAttributes(params) {
|
|
736
700
|
Object.entries(params).forEach(([key]) => {
|
|
737
|
-
if (key.includes("visible"))
|
|
738
|
-
params[key] = "";
|
|
701
|
+
if (key.includes("visible")) params[key] = "";
|
|
739
702
|
});
|
|
740
703
|
}
|
|
741
704
|
async format(writableStream, products, categories, _, __) {
|
|
@@ -808,8 +771,7 @@ class WooCommerceFormatter {
|
|
|
808
771
|
const productParams = attributes.params.get(product.SKU) ?? {};
|
|
809
772
|
const productProperties = attributes.properties.get(product.SKU) ?? {};
|
|
810
773
|
Object.entries(productParams).forEach(([key]) => {
|
|
811
|
-
if (key.includes("visible"))
|
|
812
|
-
productParams[key] = 0;
|
|
774
|
+
if (key.includes("visible")) productParams[key] = 0;
|
|
813
775
|
});
|
|
814
776
|
if (currentParent) {
|
|
815
777
|
Object.entries(productParams).forEach(([key, value]) => {
|
|
@@ -840,10 +802,7 @@ class WooCommerceFormatter {
|
|
|
840
802
|
|
|
841
803
|
var __defProp$2 = Object.defineProperty;
|
|
842
804
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
843
|
-
var __publicField$2 = (obj, key, value) =>
|
|
844
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
845
|
-
return value;
|
|
846
|
-
};
|
|
805
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
847
806
|
class YMLFormatter {
|
|
848
807
|
constructor() {
|
|
849
808
|
__publicField$2(this, "formatterName", "YMl");
|
|
@@ -903,8 +862,7 @@ class YMLFormatter {
|
|
|
903
862
|
});
|
|
904
863
|
}
|
|
905
864
|
getBrands(brands) {
|
|
906
|
-
if (!brands)
|
|
907
|
-
return [];
|
|
865
|
+
if (!brands) return [];
|
|
908
866
|
return brands.map((brand) => ({
|
|
909
867
|
"@_id": brand.id,
|
|
910
868
|
"@_url": brand.coverURL ?? "",
|
|
@@ -912,8 +870,7 @@ class YMLFormatter {
|
|
|
912
870
|
}));
|
|
913
871
|
}
|
|
914
872
|
getCategories(categories) {
|
|
915
|
-
if (!categories)
|
|
916
|
-
return [];
|
|
873
|
+
if (!categories) return [];
|
|
917
874
|
return categories.map((cat) => ({
|
|
918
875
|
"@_id": cat.id,
|
|
919
876
|
"@_parentId": cat.parentId ?? "",
|
|
@@ -1005,10 +962,7 @@ class YMLFormatter {
|
|
|
1005
962
|
|
|
1006
963
|
var __defProp$1 = Object.defineProperty;
|
|
1007
964
|
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1008
|
-
var __publicField$1 = (obj, key, value) =>
|
|
1009
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1010
|
-
return value;
|
|
1011
|
-
};
|
|
965
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1012
966
|
class XMLFormatter extends YMLFormatter {
|
|
1013
967
|
constructor() {
|
|
1014
968
|
super(...arguments);
|
|
@@ -1032,10 +986,7 @@ const Formatters = {
|
|
|
1032
986
|
|
|
1033
987
|
var __defProp = Object.defineProperty;
|
|
1034
988
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1035
|
-
var __publicField = (obj, key, value) =>
|
|
1036
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1037
|
-
return value;
|
|
1038
|
-
};
|
|
989
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1039
990
|
class GoodsExporter {
|
|
1040
991
|
constructor(context) {
|
|
1041
992
|
this.context = context;
|