goods-exporter 1.4.0 → 1.4.1
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 +3 -1
- package/dist/cjs/index.cjs +23 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +23 -7
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -729,6 +729,8 @@ declare const writeWithDrain: (stream: Writable) => (chunk: any) => Promise<void
|
|
|
729
729
|
|
|
730
730
|
declare const delay: (ms: number) => Promise<unknown>;
|
|
731
731
|
|
|
732
|
+
declare function getRFC3339Date(date: Date): string;
|
|
733
|
+
|
|
732
734
|
declare const urlQueryEncode: (inputUrl: string) => string;
|
|
733
735
|
|
|
734
|
-
export { type Brand, type Category, Currency, type Exporter, Extension, FormatterAbstract, type FormatterOptions, Formatters, GoodsExporter, type IParam, type ISize, type Product, type Transformer, Vat, buildCategoryPaths, delay, urlQueryEncode, writeWithDrain };
|
|
736
|
+
export { type Brand, type Category, Currency, type Exporter, Extension, FormatterAbstract, type FormatterOptions, Formatters, GoodsExporter, type IParam, type ISize, type Product, type Transformer, Vat, buildCategoryPaths, delay, getRFC3339Date, urlQueryEncode, writeWithDrain };
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -40,6 +40,21 @@ const writeWithDrain = (stream) => {
|
|
|
40
40
|
|
|
41
41
|
const delay = async (ms) => await new Promise((resolve) => setTimeout(resolve, ms));
|
|
42
42
|
|
|
43
|
+
function getRFC3339Date(date) {
|
|
44
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
45
|
+
const year = date.getFullYear();
|
|
46
|
+
const month = pad(date.getMonth() + 1);
|
|
47
|
+
const day = pad(date.getDate());
|
|
48
|
+
const hour = pad(date.getHours());
|
|
49
|
+
const min = pad(date.getMinutes());
|
|
50
|
+
const tzOffset = -date.getTimezoneOffset();
|
|
51
|
+
const sign = tzOffset >= 0 ? "+" : "-";
|
|
52
|
+
const absOffset = Math.abs(tzOffset);
|
|
53
|
+
const offsetHour = pad(Math.floor(absOffset / 60));
|
|
54
|
+
const offsetMin = pad(absOffset % 60);
|
|
55
|
+
return `${year}-${month}-${day}T${hour}:${min}${sign}${offsetHour}:${offsetMin}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
43
58
|
const urlQueryEncode = (inputUrl) => {
|
|
44
59
|
try {
|
|
45
60
|
const url = new URL(inputUrl);
|
|
@@ -818,7 +833,7 @@ class YMLFormatter {
|
|
|
818
833
|
format: true,
|
|
819
834
|
indentBy: " "
|
|
820
835
|
});
|
|
821
|
-
const date = (/* @__PURE__ */ new Date())
|
|
836
|
+
const date = getRFC3339Date(/* @__PURE__ */ new Date());
|
|
822
837
|
result.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n');
|
|
823
838
|
result.write('<yml_catalog date="' + date + '">\n');
|
|
824
839
|
result.write("<shop>\n");
|
|
@@ -851,6 +866,7 @@ class YMLFormatter {
|
|
|
851
866
|
const offerWriter = writeWithDrain(offerStream);
|
|
852
867
|
offerStream.pipe(result, { end: false });
|
|
853
868
|
for (const product of products) {
|
|
869
|
+
if (product.price === 0) continue;
|
|
854
870
|
const offer = builder.build({ offer: this.getOffer(product) });
|
|
855
871
|
await offerWriter(offer + "\n");
|
|
856
872
|
}
|
|
@@ -875,7 +891,7 @@ class YMLFormatter {
|
|
|
875
891
|
return categories.map((cat) => ({
|
|
876
892
|
"@_id": cat.id,
|
|
877
893
|
"@_parentId": cat.parentId ?? "",
|
|
878
|
-
"#text": cat.name
|
|
894
|
+
"#text": cat.name || `\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F #${cat.id}`
|
|
879
895
|
}));
|
|
880
896
|
}
|
|
881
897
|
getOffer(product) {
|
|
@@ -941,13 +957,13 @@ class YMLFormatter {
|
|
|
941
957
|
dimensions: product.dimensions,
|
|
942
958
|
boxCount: product.boxCount,
|
|
943
959
|
disabled: product.disabled,
|
|
944
|
-
age: product.age
|
|
960
|
+
age: product.age ? {
|
|
945
961
|
"@_unit": product.age.unit,
|
|
946
962
|
"#text": product.age.value
|
|
947
|
-
},
|
|
948
|
-
"tn-ved-codes": product.codesTN?.length
|
|
963
|
+
} : void 0,
|
|
964
|
+
"tn-ved-codes": product.codesTN?.length ? {
|
|
949
965
|
"tn-ved-code": product.codesTN
|
|
950
|
-
},
|
|
966
|
+
} : void 0,
|
|
951
967
|
relatedProduct: product.relatedProducts,
|
|
952
968
|
gender: product.gender
|
|
953
969
|
};
|
|
@@ -1056,6 +1072,7 @@ exports.GoodsExporter = GoodsExporter;
|
|
|
1056
1072
|
exports.Vat = Vat;
|
|
1057
1073
|
exports.buildCategoryPaths = buildCategoryPaths;
|
|
1058
1074
|
exports.delay = delay;
|
|
1075
|
+
exports.getRFC3339Date = getRFC3339Date;
|
|
1059
1076
|
exports.urlQueryEncode = urlQueryEncode;
|
|
1060
1077
|
exports.writeWithDrain = writeWithDrain;
|
|
1061
1078
|
//# sourceMappingURL=index.cjs.map
|