goods-exporter 1.4.8 → 1.4.10
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/dist/bundle.d.ts +2 -1
- package/dist/cjs/index.cjs +39 -14
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +39 -14
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +87 -87
package/dist/bundle.d.ts
CHANGED
|
@@ -639,7 +639,7 @@ declare class ExcelFormatter implements FormatterAbstract {
|
|
|
639
639
|
declare class InsalesFormatter implements FormatterAbstract {
|
|
640
640
|
formatterName: string;
|
|
641
641
|
fileExtension: Extension;
|
|
642
|
-
format(writableStream: Writable, products: Product[], categories?: Category[],
|
|
642
|
+
format(writableStream: Writable, products: Product[], categories?: Category[], brands?: Brand[], __?: FormatterOptions): Promise<void>;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
declare class JSONFormatter implements FormatterAbstract {
|
|
@@ -676,6 +676,7 @@ declare class WooCommerceFormatter implements FormatterAbstract {
|
|
|
676
676
|
formatterName: string;
|
|
677
677
|
fileExtension: Extension;
|
|
678
678
|
private readonly DEFAULT_COLUMNS;
|
|
679
|
+
private readonly CUSTOM_ATTRIBUTES;
|
|
679
680
|
private formatKeyAttribute;
|
|
680
681
|
private formatValueAttribute;
|
|
681
682
|
private formatProducts;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -267,11 +267,13 @@ class InsalesFormatter {
|
|
|
267
267
|
__publicField$9(this, "formatterName", "Insales");
|
|
268
268
|
__publicField$9(this, "fileExtension", Extension.XLSX);
|
|
269
269
|
}
|
|
270
|
-
async format(writableStream, products, categories,
|
|
270
|
+
async format(writableStream, products, categories, brands, __) {
|
|
271
271
|
const mappedCategories = {};
|
|
272
272
|
categories?.forEach(
|
|
273
273
|
(category) => mappedCategories[category.id] = category
|
|
274
274
|
);
|
|
275
|
+
const mappedBrands = {};
|
|
276
|
+
brands?.forEach((brand) => mappedBrands[brand.id] = brand);
|
|
275
277
|
const getParams = (product) => {
|
|
276
278
|
const properties = {};
|
|
277
279
|
product.params?.forEach(
|
|
@@ -338,6 +340,7 @@ class InsalesFormatter {
|
|
|
338
340
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0410\u0440\u0442\u0438\u043A\u0443\u043B",
|
|
339
341
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u041F\u043E\u043B (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
|
|
340
342
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0411\u0440\u0435\u043D\u0434 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
|
|
343
|
+
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u041B\u043E\u0433\u043E\u0442\u0438\u043F \u0431\u0440\u0435\u043D\u0434\u0430 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
|
|
341
344
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0421\u0435\u0440\u0438\u044F (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
|
|
342
345
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0414\u0430\u0442\u0430 \u0440\u0435\u043B\u0438\u0437\u0430 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)",
|
|
343
346
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B",
|
|
@@ -388,6 +391,7 @@ class InsalesFormatter {
|
|
|
388
391
|
// TODO: брать из обычных параметров,
|
|
389
392
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u041F\u043E\u043B (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.gender,
|
|
390
393
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0411\u0440\u0435\u043D\u0434 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.vendor,
|
|
394
|
+
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u041B\u043E\u0433\u043E\u0442\u0438\u043F \u0431\u0440\u0435\u043D\u0434\u0430 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.vendorId === void 0 ? void 0 : mappedBrands[product.vendorId]?.logoUrl,
|
|
391
395
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0421\u0435\u0440\u0438\u044F (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.seriesName,
|
|
392
396
|
"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440: \u0414\u0430\u0442\u0430 \u0440\u0435\u043B\u0438\u0437\u0430 (\u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439)": product.saleDate,
|
|
393
397
|
...getParams(product),
|
|
@@ -667,6 +671,12 @@ class WooCommerceFormatter {
|
|
|
667
671
|
"Images",
|
|
668
672
|
"SizeGrid"
|
|
669
673
|
]);
|
|
674
|
+
__publicField$3(this, "CUSTOM_ATTRIBUTES", {
|
|
675
|
+
gender: "\u041F\u043E\u043B",
|
|
676
|
+
vendor: "\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u0442\u0435\u043B\u044C",
|
|
677
|
+
vendorCode: "\u0410\u0440\u0442\u0438\u043A\u0443\u043B",
|
|
678
|
+
seriesName: "\u0421\u0435\u0440\u0438\u044F"
|
|
679
|
+
});
|
|
670
680
|
}
|
|
671
681
|
formatKeyAttribute(key) {
|
|
672
682
|
const keyWithoutInvalidCharacters = key.replaceAll(",", "").replaceAll(";", "");
|
|
@@ -707,14 +717,17 @@ class WooCommerceFormatter {
|
|
|
707
717
|
const paramsMap = /* @__PURE__ */ new Map();
|
|
708
718
|
const propertiesMap = /* @__PURE__ */ new Map();
|
|
709
719
|
const uniqueAttributes = /* @__PURE__ */ new Map();
|
|
710
|
-
|
|
720
|
+
Object.values(this.CUSTOM_ATTRIBUTES).forEach((attrName) => {
|
|
721
|
+
if (!uniqueAttributes.has(attrName)) {
|
|
722
|
+
uniqueAttributes.set(attrName, uniqueAttributes.size);
|
|
723
|
+
}
|
|
724
|
+
});
|
|
711
725
|
formatedProducts.forEach((product) => {
|
|
712
726
|
product.params?.forEach(({ key }) => {
|
|
713
727
|
if (!uniqueAttributes.has(key)) {
|
|
714
728
|
uniqueAttributes.set(key, uniqueAttributes.size);
|
|
715
729
|
}
|
|
716
730
|
});
|
|
717
|
-
uniqueAttributes.set(genderTitle, uniqueAttributes.size);
|
|
718
731
|
product.properties?.forEach(({ key }) => {
|
|
719
732
|
if (!uniqueAttributes.has(key)) {
|
|
720
733
|
uniqueAttributes.set(key, uniqueAttributes.size);
|
|
@@ -742,18 +755,30 @@ class WooCommerceFormatter {
|
|
|
742
755
|
([key2, value2]) => paramAttributes[key2] = value2
|
|
743
756
|
);
|
|
744
757
|
});
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
758
|
+
Object.entries(this.CUSTOM_ATTRIBUTES).forEach(([field, attrName]) => {
|
|
759
|
+
const value = product[field];
|
|
760
|
+
if (value) {
|
|
761
|
+
const index = uniqueAttributes.get(attrName);
|
|
762
|
+
if (index === void 0) {
|
|
763
|
+
console.error(
|
|
764
|
+
`\u041D\u0435 \u043D\u0430\u0448\u043B\u043E\u0441\u044C \u0443\u043D\u0438\u043A\u0430\u043B\u044C\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 \u0434\u043B\u044F \u043A\u0430\u0441\u0442\u043E\u043C\u043D\u043E\u0433\u043E \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 - ${attrName}`
|
|
765
|
+
);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
if (!paramAttributes[`Attribute ${index} name`]) {
|
|
769
|
+
const attribute = this.createAttribute({
|
|
770
|
+
name: attrName,
|
|
771
|
+
id: index,
|
|
772
|
+
values: value,
|
|
773
|
+
global: 0
|
|
774
|
+
});
|
|
775
|
+
if (!attribute) return;
|
|
776
|
+
Object.entries(attribute).forEach(
|
|
777
|
+
([key, val]) => propertyAttributes[key] = val
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
751
781
|
});
|
|
752
|
-
if (genderAttribute) {
|
|
753
|
-
Object.entries(genderAttribute).forEach(
|
|
754
|
-
([key, value]) => propertyAttributes[key] = value
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
782
|
product.properties?.forEach(({ key, value }) => {
|
|
758
783
|
const index = uniqueAttributes.get(key);
|
|
759
784
|
if (index === void 0) {
|