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.
@@ -51,10 +51,7 @@ const urlQueryEncode = (inputUrl) => {
51
51
 
52
52
  var __defProp$b = Object.defineProperty;
53
53
  var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
54
- var __publicField$b = (obj, key, value) => {
55
- __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
56
- return value;
57
- };
54
+ var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
58
55
  class CSVStream {
59
56
  constructor({ delimiter, lineSeparator, emptyFieldValue }) {
60
57
  __publicField$b(this, "stream", new PassThrough());
@@ -63,12 +60,9 @@ class CSVStream {
63
60
  __publicField$b(this, "emptyFieldValue", "");
64
61
  __publicField$b(this, "columns", /* @__PURE__ */ new Set());
65
62
  __publicField$b(this, "writer", writeWithDrain(this.stream));
66
- if (delimiter !== void 0)
67
- this.delimiter = delimiter;
68
- if (lineSeparator !== void 0)
69
- this.lineSeparator = lineSeparator;
70
- if (emptyFieldValue !== void 0)
71
- this.emptyFieldValue = emptyFieldValue;
63
+ if (delimiter !== void 0) this.delimiter = delimiter;
64
+ if (lineSeparator !== void 0) this.lineSeparator = lineSeparator;
65
+ if (emptyFieldValue !== void 0) this.emptyFieldValue = emptyFieldValue;
72
66
  }
73
67
  get writableStream() {
74
68
  return this.stream;
@@ -100,10 +94,7 @@ var Extension = /* @__PURE__ */ ((Extension2) => {
100
94
 
101
95
  var __defProp$a = Object.defineProperty;
102
96
  var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
103
- var __publicField$a = (obj, key, value) => {
104
- __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
105
- return value;
106
- };
97
+ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
107
98
  class CSVFormatter {
108
99
  constructor() {
109
100
  __publicField$a(this, "formatterName", "CSV");
@@ -148,8 +139,7 @@ class CSVFormatter {
148
139
  ]);
149
140
  products.forEach((product) => {
150
141
  Object.entries(product).forEach(([key, value]) => {
151
- if (value)
152
- columns.add(key);
142
+ if (value) columns.add(key);
153
143
  });
154
144
  });
155
145
  csvStream.setColumns(columns);
@@ -177,10 +167,7 @@ class CSVFormatter {
177
167
 
178
168
  var __defProp$9 = Object.defineProperty;
179
169
  var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
180
- var __publicField$9 = (obj, key, value) => {
181
- __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
182
- return value;
183
- };
170
+ var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
184
171
  const { stream: stream$2 } = pkg;
185
172
  class ExcelFormatter {
186
173
  constructor() {
@@ -220,8 +207,7 @@ class ExcelFormatter {
220
207
  ]);
221
208
  products.forEach((product) => {
222
209
  Object.entries(product).forEach(([key, value]) => {
223
- if (value)
224
- columns.add(key);
210
+ if (value) columns.add(key);
225
211
  });
226
212
  });
227
213
  const workbook = new stream$2.xlsx.WorkbookWriter({
@@ -257,10 +243,7 @@ class ExcelFormatter {
257
243
 
258
244
  var __defProp$8 = Object.defineProperty;
259
245
  var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
260
- var __publicField$8 = (obj, key, value) => {
261
- __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
262
- return value;
263
- };
246
+ var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
264
247
  const { stream: stream$1 } = pkg;
265
248
  class InsalesFormatter {
266
249
  constructor() {
@@ -290,8 +273,7 @@ class InsalesFormatter {
290
273
  const categories2 = {};
291
274
  const categoryList = new Array();
292
275
  function addCategory(categoryId) {
293
- if (categoryId === void 0)
294
- return;
276
+ if (categoryId === void 0) return;
295
277
  const category = mappedCategories[categoryId];
296
278
  if (category) {
297
279
  categoryList.push(category.name);
@@ -359,7 +341,8 @@ class InsalesFormatter {
359
341
  const row = {
360
342
  "\u0412\u043D\u0435\u0448\u043D\u0438\u0439 ID": externalId,
361
343
  "\u0421\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u0442\u043E\u0432\u0430\u0440": product.url,
362
- \u0410\u0440\u0442\u0438\u043A\u0443\u043B: product.vendorCode,
344
+ \u0410\u0440\u0442\u0438\u043A\u0443\u043B: externalId,
345
+ // TODO: product.vendorCode,
363
346
  "\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,
364
347
  "\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,
365
348
  "\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,
@@ -379,6 +362,8 @@ class InsalesFormatter {
379
362
  "\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,
380
363
  \u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F: product.parentId === void 0 ? void 0 : product.images?.join(" "),
381
364
  "\u0421\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u0432\u0438\u0434\u0435\u043E": product.videos ? product.videos[0] : void 0,
365
+ "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0410\u0440\u0442\u0438\u043A\u0443\u043B": product.vendorCode,
366
+ // TODO: брать из обычных параметров
382
367
  ...getParams(product),
383
368
  ...getProperties(product),
384
369
  "\u0420\u0430\u0437\u043C\u0435\u0440\u043D\u0430\u044F \u0441\u0435\u0442\u043A\u0430": JSON.stringify(product.sizes),
@@ -394,10 +379,7 @@ class InsalesFormatter {
394
379
 
395
380
  var __defProp$7 = Object.defineProperty;
396
381
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
397
- var __publicField$7 = (obj, key, value) => {
398
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
399
- return value;
400
- };
382
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
401
383
  class JSONFormatter {
402
384
  constructor() {
403
385
  __publicField$7(this, "formatterName", "JSON");
@@ -415,10 +397,7 @@ class JSONFormatter {
415
397
 
416
398
  var __defProp$6 = Object.defineProperty;
417
399
  var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
418
- var __publicField$6 = (obj, key, value) => {
419
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
420
- return value;
421
- };
400
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
422
401
  class SimpleJSONFormatter {
423
402
  constructor() {
424
403
  __publicField$6(this, "formatterName", "JSON");
@@ -427,19 +406,16 @@ class SimpleJSONFormatter {
427
406
  async format(writableStream, products, categories, brands, _) {
428
407
  const groupedProduct = /* @__PURE__ */ new Map();
429
408
  products.forEach((product) => {
430
- if (product.parentId !== void 0)
431
- return;
409
+ if (product.parentId !== void 0) return;
432
410
  groupedProduct.set(product.variantId, {
433
411
  ...product,
434
412
  children: []
435
413
  });
436
414
  });
437
415
  products.forEach((product) => {
438
- if (product.parentId === void 0)
439
- return;
416
+ if (product.parentId === void 0) return;
440
417
  const parent = groupedProduct.get(product.parentId);
441
- if (!parent)
442
- return;
418
+ if (!parent) return;
443
419
  parent.children.push(product);
444
420
  });
445
421
  const stream = new JsonStreamStringify({
@@ -453,10 +429,7 @@ class SimpleJSONFormatter {
453
429
 
454
430
  var __defProp$5 = Object.defineProperty;
455
431
  var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
456
- var __publicField$5 = (obj, key, value) => {
457
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
458
- return value;
459
- };
432
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
460
433
  const { stream } = pkg;
461
434
  class TgShopFormatter {
462
435
  constructor() {
@@ -534,10 +507,7 @@ class TgShopFormatter {
534
507
 
535
508
  var __defProp$4 = Object.defineProperty;
536
509
  var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
537
- var __publicField$4 = (obj, key, value) => {
538
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
539
- return value;
540
- };
510
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
541
511
  class TildaFormatter {
542
512
  constructor() {
543
513
  __publicField$4(this, "formatterName", "Tilda");
@@ -590,10 +560,7 @@ class TildaFormatter {
590
560
 
591
561
  var __defProp$3 = Object.defineProperty;
592
562
  var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
593
- var __publicField$3 = (obj, key, value) => {
594
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
595
- return value;
596
- };
563
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
597
564
  class WooCommerceFormatter {
598
565
  constructor() {
599
566
  __publicField$3(this, "formatterName", "WooCommerce");
@@ -637,8 +604,7 @@ class WooCommerceFormatter {
637
604
  });
638
605
  }
639
606
  createAttribute(data) {
640
- if (!data?.name || data.id === void 0)
641
- return;
607
+ if (!data?.name || data.id === void 0) return;
642
608
  const attributeStartName = "Attribute";
643
609
  const attribute = {};
644
610
  attribute[`${attributeStartName} ${data.id} name`] = data.name;
@@ -685,8 +651,7 @@ class WooCommerceFormatter {
685
651
  visible: 0,
686
652
  global: 0
687
653
  });
688
- if (!attribute)
689
- return;
654
+ if (!attribute) return;
690
655
  Object.entries(attribute).forEach(
691
656
  ([key2, value2]) => paramAttributes[key2] = value2
692
657
  );
@@ -719,8 +684,7 @@ class WooCommerceFormatter {
719
684
  values: value,
720
685
  global: 0
721
686
  });
722
- if (!attribute)
723
- return;
687
+ if (!attribute) return;
724
688
  Object.entries(attribute).forEach(
725
689
  ([key2, value2]) => propertyAttributes[key2] = value2
726
690
  );
@@ -732,8 +696,7 @@ class WooCommerceFormatter {
732
696
  }
733
697
  removeVisibleFromAttributes(params) {
734
698
  Object.entries(params).forEach(([key]) => {
735
- if (key.includes("visible"))
736
- params[key] = "";
699
+ if (key.includes("visible")) params[key] = "";
737
700
  });
738
701
  }
739
702
  async format(writableStream, products, categories, _, __) {
@@ -806,8 +769,7 @@ class WooCommerceFormatter {
806
769
  const productParams = attributes.params.get(product.SKU) ?? {};
807
770
  const productProperties = attributes.properties.get(product.SKU) ?? {};
808
771
  Object.entries(productParams).forEach(([key]) => {
809
- if (key.includes("visible"))
810
- productParams[key] = 0;
772
+ if (key.includes("visible")) productParams[key] = 0;
811
773
  });
812
774
  if (currentParent) {
813
775
  Object.entries(productParams).forEach(([key, value]) => {
@@ -838,10 +800,7 @@ class WooCommerceFormatter {
838
800
 
839
801
  var __defProp$2 = Object.defineProperty;
840
802
  var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
841
- var __publicField$2 = (obj, key, value) => {
842
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
843
- return value;
844
- };
803
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
845
804
  class YMLFormatter {
846
805
  constructor() {
847
806
  __publicField$2(this, "formatterName", "YMl");
@@ -901,8 +860,7 @@ class YMLFormatter {
901
860
  });
902
861
  }
903
862
  getBrands(brands) {
904
- if (!brands)
905
- return [];
863
+ if (!brands) return [];
906
864
  return brands.map((brand) => ({
907
865
  "@_id": brand.id,
908
866
  "@_url": brand.coverURL ?? "",
@@ -910,8 +868,7 @@ class YMLFormatter {
910
868
  }));
911
869
  }
912
870
  getCategories(categories) {
913
- if (!categories)
914
- return [];
871
+ if (!categories) return [];
915
872
  return categories.map((cat) => ({
916
873
  "@_id": cat.id,
917
874
  "@_parentId": cat.parentId ?? "",
@@ -1003,10 +960,7 @@ class YMLFormatter {
1003
960
 
1004
961
  var __defProp$1 = Object.defineProperty;
1005
962
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1006
- var __publicField$1 = (obj, key, value) => {
1007
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1008
- return value;
1009
- };
963
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1010
964
  class XMLFormatter extends YMLFormatter {
1011
965
  constructor() {
1012
966
  super(...arguments);
@@ -1030,10 +984,7 @@ const Formatters = {
1030
984
 
1031
985
  var __defProp = Object.defineProperty;
1032
986
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1033
- var __publicField = (obj, key, value) => {
1034
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1035
- return value;
1036
- };
987
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1037
988
  class GoodsExporter {
1038
989
  constructor(context) {
1039
990
  this.context = context;