pim-import 6.1.4 → 6.1.8
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.
|
@@ -9,6 +9,7 @@ export declare const certificationFields: string[];
|
|
|
9
9
|
export declare const excludeCertificationFieldsKeys: string[];
|
|
10
10
|
export declare const getProductPageIdByCode: (productCode: string) => string;
|
|
11
11
|
export declare const importProduct: (productDetails: ProductDetails, catalog: AvailableCatalogs, familyCodeIn?: string[], subFamilyCodeIn?: string[]) => Promise<boolean>;
|
|
12
|
+
export declare const pimKeyRenamedCheck: (key: string) => string;
|
|
12
13
|
export declare const setProductRelationships: (code: string, fieldKey?: AvailableRelationFieldKeys | null) => Promise<void>;
|
|
13
14
|
export declare const setProductsRelationships: (catalog: AvailableCatalogs, lastModified: string, fieldKey: AvailableRelationFieldKeys | null, offset?: number, limit?: number, s3FilePath?: string) => Promise<{
|
|
14
15
|
offset: number;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.purgeProductThumbCacheByProductCodes = exports.populateDestinations = exports.reimportAuditProducts = exports.removeAllProductModelProductRelations = exports.removeProductFromColorVariantsByProductLine = exports.getProductAutodescription = exports.setProductAutodescriptionByTopicId = exports.setProductsAutodescription = exports.generateTechSpecPdf = exports.importProductByCode = exports.audit = exports.getAllProductEntriesByCatalog = exports.setProductsRelationships = exports.setProductRelationships = exports.importProduct = exports.getProductPageIdByCode = exports.excludeCertificationFieldsKeys = exports.certificationFields = exports.setHideInRegionField = void 0;
|
|
6
|
+
exports.purgeProductThumbCacheByProductCodes = exports.populateDestinations = exports.reimportAuditProducts = exports.removeAllProductModelProductRelations = exports.removeProductFromColorVariantsByProductLine = exports.getProductAutodescription = exports.setProductAutodescriptionByTopicId = exports.setProductsAutodescription = exports.generateTechSpecPdf = exports.importProductByCode = exports.audit = exports.getAllProductEntriesByCatalog = exports.setProductsRelationships = exports.setProductRelationships = exports.pimKeyRenamedCheck = exports.importProduct = exports.getProductPageIdByCode = exports.excludeCertificationFieldsKeys = exports.certificationFields = exports.setHideInRegionField = void 0;
|
|
7
7
|
const logs_1 = require("../../libs/logs");
|
|
8
8
|
const contentful_1 = require("../../libs/contentful");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
@@ -807,6 +807,14 @@ const importProduct = async (productDetails, catalog, familyCodeIn, subFamilyCod
|
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
809
|
exports.importProduct = importProduct;
|
|
810
|
+
const pimKeyRenamedCheck = (key) => {
|
|
811
|
+
const renamedKeys = {
|
|
812
|
+
spareparts: "spareParts",
|
|
813
|
+
sparepartOf: "sparePartOf",
|
|
814
|
+
};
|
|
815
|
+
return renamedKeys[key] || key;
|
|
816
|
+
};
|
|
817
|
+
exports.pimKeyRenamedCheck = pimKeyRenamedCheck;
|
|
810
818
|
const setProductRelationships = async (code, fieldKey = null) => {
|
|
811
819
|
(0, logs_1.log)(`setProductRelationships - code: ${code} fieldKey: ${fieldKey}`, "INFO");
|
|
812
820
|
const fieldKeys = [
|
|
@@ -838,13 +846,13 @@ const setProductRelationships = async (code, fieldKey = null) => {
|
|
|
838
846
|
let fieldKeysCount = 0;
|
|
839
847
|
for (const currentFieldKey of currentFieldKeys) {
|
|
840
848
|
(0, logs_1.log)(`Set ${currentFieldKey} relations to product with code ${code}`);
|
|
841
|
-
const fieldValues = productDetails[currentFieldKey];
|
|
842
|
-
if (fieldValues) {
|
|
849
|
+
const fieldValues = productDetails[(0, exports.pimKeyRenamedCheck)(currentFieldKey)];
|
|
850
|
+
if (fieldValues?.length) {
|
|
843
851
|
const relationships = [];
|
|
844
|
-
const
|
|
852
|
+
const productRelationCodes = fieldValues.map((fieldValue) => {
|
|
845
853
|
return fieldValue.code;
|
|
846
854
|
});
|
|
847
|
-
const entries = await (0, contentful_1.getAllEntriesByCodes)(
|
|
855
|
+
const entries = await (0, contentful_1.getAllEntriesByCodes)(productRelationCodes, "topicProduct", "sys,fields.code");
|
|
848
856
|
for (const fieldValue of fieldValues) {
|
|
849
857
|
const entry = entries.find((currentEntry) => currentEntry.fields.code[defaultEnvironmentLocaleCode] ===
|
|
850
858
|
fieldValue.code);
|
|
@@ -866,7 +874,7 @@ const setProductRelationships = async (code, fieldKey = null) => {
|
|
|
866
874
|
(0, logs_1.log)(`No product relationships found of the field ${currentFieldKey} for the product ${code}, i remove ${prevItemsCount} pre-existing relationships`);
|
|
867
875
|
}
|
|
868
876
|
else {
|
|
869
|
-
(0, logs_1.log)(`Founded ${relationships.length} relationships of ${
|
|
877
|
+
(0, logs_1.log)(`Founded ${relationships.length} relationships of ${productRelationCodes.length} PIM relationships for the field ${currentFieldKey} of product ${code}`);
|
|
870
878
|
}
|
|
871
879
|
productEntry.fields[currentFieldKey] = {};
|
|
872
880
|
productEntry.fields[currentFieldKey][defaultEnvironmentLocaleCode] =
|
|
@@ -1551,12 +1559,12 @@ const generateTechSpecPdf = async (topicProductId, country = "global", locale =
|
|
|
1551
1559
|
}
|
|
1552
1560
|
baseUrl = baseUrl.replace(/\/?(\?|#|$)/, "/$1");
|
|
1553
1561
|
let footerBaseUrl = country === "cn"
|
|
1554
|
-
? process.env.FPI_TECH_SPEC_FOOTER_BASE_URL_CN ??
|
|
1562
|
+
? (process.env.FPI_TECH_SPEC_FOOTER_BASE_URL_CN ??
|
|
1555
1563
|
process.env.FPI_TECH_SPEC_BASE_URL_CN ??
|
|
1556
|
-
""
|
|
1557
|
-
: process.env.FPI_TECH_SPEC_FOOTER_BASE_URL ??
|
|
1564
|
+
"")
|
|
1565
|
+
: (process.env.FPI_TECH_SPEC_FOOTER_BASE_URL ??
|
|
1558
1566
|
process.env.FPI_TECH_SPEC_BASE_URL ??
|
|
1559
|
-
"";
|
|
1567
|
+
"");
|
|
1560
1568
|
if (!footerBaseUrl) {
|
|
1561
1569
|
(0, logs_1.log)(`FPI_TECH_SPEC_FOOTER_BASE_URL process env not found for country ${country}`, "ERROR");
|
|
1562
1570
|
}
|
|
@@ -1768,10 +1776,12 @@ const getTopicProductAutodescription = async (topicProductFields) => {
|
|
|
1768
1776
|
autoDescription = topicProductFields?.description;
|
|
1769
1777
|
break;
|
|
1770
1778
|
case "PLINE1":
|
|
1771
|
-
autoDescription =
|
|
1779
|
+
autoDescription =
|
|
1780
|
+
await getLightModuleAutoDescriptionByProductFields(productFileds);
|
|
1772
1781
|
break;
|
|
1773
1782
|
default:
|
|
1774
|
-
autoDescription =
|
|
1783
|
+
autoDescription =
|
|
1784
|
+
await getOtherAutoDescriptionByProductFields(productFileds);
|
|
1775
1785
|
break;
|
|
1776
1786
|
}
|
|
1777
1787
|
return autoDescription;
|