goods-exporter 1.4.2 → 1.4.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.
@@ -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,45 @@ 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
+ params: product.params
431
+ };
432
+ if (product.timeDelivery?.min !== void 0 || product.timeDelivery?.max !== void 0) {
433
+ sku.timeDelivery = {
434
+ min: product.timeDelivery.min ?? 0,
435
+ max: product.timeDelivery.max ?? 0
436
+ };
437
+ }
438
+ if (existing) {
439
+ existing.skus.push(sku);
440
+ } else {
441
+ priceMap.set(product.productId, {
442
+ productId: product.productId,
443
+ skus: [sku]
444
+ });
445
+ }
446
+ });
447
+ const result = Array.from(priceMap.values());
448
+ const stream = new JsonStreamStringify(result);
449
+ stream.pipe(writableStream);
450
+ }
451
+ }
452
+
414
453
  var __defProp$6 = Object.defineProperty;
415
454
  var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
416
455
  var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -1008,7 +1047,8 @@ const Formatters = {
1008
1047
  JSONFormatter,
1009
1048
  SimpleJSONFormatter,
1010
1049
  XMLFormatter,
1011
- WooCommerceFormatter
1050
+ WooCommerceFormatter,
1051
+ PriceFormatter
1012
1052
  };
1013
1053
 
1014
1054
  var __defProp = Object.defineProperty;