goods-exporter 1.4.1 → 1.4.3

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.
@@ -64,17 +64,17 @@ const urlQueryEncode = (inputUrl) => {
64
64
  }
65
65
  };
66
66
 
67
- var __defProp$b = Object.defineProperty;
68
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
69
- var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
67
+ var __defProp$c = Object.defineProperty;
68
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
69
+ var __publicField$c = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
70
70
  class CSVStream {
71
71
  constructor({ delimiter, lineSeparator, emptyFieldValue }) {
72
- __publicField$b(this, "stream", new PassThrough());
73
- __publicField$b(this, "delimiter", ";");
74
- __publicField$b(this, "lineSeparator", "\n");
75
- __publicField$b(this, "emptyFieldValue", "");
76
- __publicField$b(this, "columns", /* @__PURE__ */ new Set());
77
- __publicField$b(this, "writer", writeWithDrain(this.stream));
72
+ __publicField$c(this, "stream", new PassThrough());
73
+ __publicField$c(this, "delimiter", ";");
74
+ __publicField$c(this, "lineSeparator", "\n");
75
+ __publicField$c(this, "emptyFieldValue", "");
76
+ __publicField$c(this, "columns", /* @__PURE__ */ new Set());
77
+ __publicField$c(this, "writer", writeWithDrain(this.stream));
78
78
  if (delimiter !== void 0) this.delimiter = delimiter;
79
79
  if (lineSeparator !== void 0) this.lineSeparator = lineSeparator;
80
80
  if (emptyFieldValue !== void 0) this.emptyFieldValue = emptyFieldValue;
@@ -107,13 +107,13 @@ var Extension = /* @__PURE__ */ ((Extension2) => {
107
107
  return Extension2;
108
108
  })(Extension || {});
109
109
 
110
- var __defProp$a = Object.defineProperty;
111
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
112
- var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
110
+ var __defProp$b = Object.defineProperty;
111
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
112
+ var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
113
113
  class CSVFormatter {
114
114
  constructor() {
115
- __publicField$a(this, "formatterName", "CSV");
116
- __publicField$a(this, "fileExtension", Extension.CSV);
115
+ __publicField$b(this, "formatterName", "CSV");
116
+ __publicField$b(this, "fileExtension", Extension.CSV);
117
117
  }
118
118
  async format(writableStream, products, categories, _, __) {
119
119
  const mappedCategories = {};
@@ -180,14 +180,14 @@ class CSVFormatter {
180
180
  }
181
181
  }
182
182
 
183
- var __defProp$9 = Object.defineProperty;
184
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
185
- var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
183
+ var __defProp$a = Object.defineProperty;
184
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
185
+ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
186
186
  const { stream: stream$2 } = pkg;
187
187
  class ExcelFormatter {
188
188
  constructor() {
189
- __publicField$9(this, "formatterName", "Excel");
190
- __publicField$9(this, "fileExtension", Extension.XLSX);
189
+ __publicField$a(this, "formatterName", "Excel");
190
+ __publicField$a(this, "fileExtension", Extension.XLSX);
191
191
  }
192
192
  async format(writableStream, products, categories, _, __) {
193
193
  const mappedCategories = {};
@@ -256,14 +256,14 @@ class ExcelFormatter {
256
256
  }
257
257
  }
258
258
 
259
- var __defProp$8 = Object.defineProperty;
260
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
261
- var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
259
+ var __defProp$9 = Object.defineProperty;
260
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
261
+ var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
262
262
  const { stream: stream$1 } = pkg;
263
263
  class InsalesFormatter {
264
264
  constructor() {
265
- __publicField$8(this, "formatterName", "Insales");
266
- __publicField$8(this, "fileExtension", Extension.XLSX);
265
+ __publicField$9(this, "formatterName", "Insales");
266
+ __publicField$9(this, "fileExtension", Extension.XLSX);
267
267
  }
268
268
  async format(writableStream, products, categories, _, __) {
269
269
  const mappedCategories = {};
@@ -393,13 +393,13 @@ class InsalesFormatter {
393
393
  }
394
394
  }
395
395
 
396
- var __defProp$7 = Object.defineProperty;
397
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
398
- var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
396
+ var __defProp$8 = Object.defineProperty;
397
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
398
+ var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
399
399
  class JSONFormatter {
400
400
  constructor() {
401
- __publicField$7(this, "formatterName", "JSON");
402
- __publicField$7(this, "fileExtension", Extension.JSON);
401
+ __publicField$8(this, "formatterName", "JSON");
402
+ __publicField$8(this, "fileExtension", Extension.JSON);
403
403
  }
404
404
  async format(writableStream, products, categories, brands, _) {
405
405
  const stream = new JsonStreamStringify({
@@ -411,6 +411,44 @@ class JSONFormatter {
411
411
  }
412
412
  }
413
413
 
414
+ var __defProp$7 = Object.defineProperty;
415
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
416
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
417
+ class PriceFormatter {
418
+ constructor() {
419
+ __publicField$7(this, "formatterName", "Price");
420
+ __publicField$7(this, "fileExtension", Extension.JSON);
421
+ }
422
+ async format(writableStream, products, _categories, _brands, _) {
423
+ const priceMap = /* @__PURE__ */ new Map();
424
+ products.forEach((product) => {
425
+ const existing = priceMap.get(product.productId);
426
+ const sku = {
427
+ skuId: String(product.variantId),
428
+ price: product.price,
429
+ currency: product.currency
430
+ };
431
+ if (product.timeDelivery?.min !== void 0 || product.timeDelivery?.max !== void 0) {
432
+ sku.timeDelivery = {
433
+ min: product.timeDelivery.min ?? 0,
434
+ max: product.timeDelivery.max ?? 0
435
+ };
436
+ }
437
+ if (existing) {
438
+ existing.skus.push(sku);
439
+ } else {
440
+ priceMap.set(product.productId, {
441
+ productId: product.productId,
442
+ skus: [sku]
443
+ });
444
+ }
445
+ });
446
+ const result = Array.from(priceMap.values());
447
+ const stream = new JsonStreamStringify(result);
448
+ stream.pipe(writableStream);
449
+ }
450
+ }
451
+
414
452
  var __defProp$6 = Object.defineProperty;
415
453
  var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
416
454
  var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -533,7 +571,7 @@ class TildaFormatter {
533
571
  const mappedCategories = {};
534
572
  categories?.forEach(({ id, name }) => mappedCategories[id] = name);
535
573
  const csvStream = new CSVStream({
536
- delimiter: ";",
574
+ delimiter: " ",
537
575
  emptyFieldValue: "",
538
576
  lineSeparator: "\n"
539
577
  });
@@ -552,6 +590,15 @@ class TildaFormatter {
552
590
  "External ID",
553
591
  "Parent UID"
554
592
  ]);
593
+ const characteristics = /* @__PURE__ */ new Set();
594
+ products.forEach((product) => {
595
+ product.properties?.forEach(({ key }) => {
596
+ characteristics.add(key);
597
+ });
598
+ });
599
+ characteristics.forEach((charKey) => {
600
+ columns.add(`Characteristics:${charKey}`);
601
+ });
555
602
  csvStream.setColumns(columns);
556
603
  for (const product of products) {
557
604
  const row = {
@@ -560,7 +607,7 @@ class TildaFormatter {
560
607
  Category: mappedCategories[product.categoryId],
561
608
  Title: product.title,
562
609
  Text: product.description,
563
- Photo: product.images?.join(";"),
610
+ Photo: product.images?.map(urlQueryEncode).join(","),
564
611
  Price: product.price,
565
612
  "Price Old": product.oldPrice,
566
613
  Quantity: product.count,
@@ -568,6 +615,9 @@ class TildaFormatter {
568
615
  "External ID": product.variantId,
569
616
  "Parent UID": product.parentId
570
617
  };
618
+ product.properties?.forEach(({ key, value }) => {
619
+ row[`Characteristics:${key}`] = value;
620
+ });
571
621
  await csvStream.addRow(row);
572
622
  }
573
623
  csvStream.writableStream.end();
@@ -996,7 +1046,8 @@ const Formatters = {
996
1046
  JSONFormatter,
997
1047
  SimpleJSONFormatter,
998
1048
  XMLFormatter,
999
- WooCommerceFormatter
1049
+ WooCommerceFormatter,
1050
+ PriceFormatter
1000
1051
  };
1001
1052
 
1002
1053
  var __defProp = Object.defineProperty;