pim-import 6.1.3 → 6.1.6

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];
849
+ const fieldValues = productDetails[(0, exports.pimKeyRenamedCheck)(currentFieldKey)];
842
850
  if (fieldValues) {
843
851
  const relationships = [];
844
- const producRelationCodes = fieldValues.map((fieldValue) => {
852
+ const productRelationCodes = fieldValues.map((fieldValue) => {
845
853
  return fieldValue.code;
846
854
  });
847
- const entries = await (0, contentful_1.getAllEntriesByCodes)(producRelationCodes, "topicProduct", "sys,fields.code");
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 ${producRelationCodes.length} PIM relationships for the field ${currentFieldKey} of product ${code}`);
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] =
package/dist/utils.js CHANGED
@@ -82,6 +82,7 @@ const getPimTranslations = (values, fieldKey = "value", defaultValue = "", limit
82
82
  }
83
83
  }
84
84
  if (defaultValue && Object.entries(names).length === 0) {
85
+ (0, logs_1.log)(`No translations found for fieldKey ${valueString}, setting default value (${defaultValue}) for all locales`, "WARN");
85
86
  for (const locale of contentful_1.cfLocales) {
86
87
  names[locale] = defaultValue;
87
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "6.1.3",
3
+ "version": "6.1.6",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",