pim-import 5.2.0 → 5.3.0

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.
@@ -80,6 +80,7 @@ const getProductFields = async (topicFamily, destination = "PROFESSIONAL_GLOBAL"
80
80
  let productFields = {};
81
81
  productFields.availableTo = [];
82
82
  productFields.totalProducts = topicProductEntries.length;
83
+ productFields.certifiedFilters = [];
83
84
  for (const topicProduct of topicProductEntries) {
84
85
  if (topicProduct?.fields?.productFields?.[defaultEnvironmentLocaleCode]) {
85
86
  const pimDetails = topicProduct?.fields?.productFields?.[defaultEnvironmentLocaleCode];
@@ -125,6 +126,13 @@ const getProductFields = async (topicFamily, destination = "PROFESSIONAL_GLOBAL"
125
126
  productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "locations");
126
127
  (0, logs_1.log)(`Get certificationFilters details...`);
127
128
  productFields.certificationFilters = (0, utils_1.getCertificationFilters)(pimDetails);
129
+ (0, logs_1.log)(`Get certifiedFilters details...`);
130
+ productFields.certifiedFilters = [
131
+ ...new Set([
132
+ ...productFields.certifiedFilters,
133
+ ...(0, utils_1.getCertifiedFilters)(pimDetails),
134
+ ]),
135
+ ];
128
136
  (0, logs_1.log)(`Get filterableCertifications details...`);
129
137
  const filterableCertificationsFields = ["enec", "ul", "certificates"];
130
138
  for (const filterableCertificationsField of filterableCertificationsFields) {
@@ -74,6 +74,7 @@ const getObject = async (topicModel) => {
74
74
  productFields.availableTo = [];
75
75
  if (catalogId) {
76
76
  const topicProducts = await (0, contentful_cda_1.getAllEntries)("topicProduct", "sys,fields.productFields", `fields.models${(0, utils_1.capitalizeFirstLetter)(catalogId)}.sys.id[in]`, topicModelWithFields.sys.id);
77
+ productFields.certifiedFilters = [];
77
78
  topicProducts.forEach((topicProduct) => {
78
79
  const pimDetails = topicProduct?.fields?.productFields?.[defaultEnvironmentLocaleCode];
79
80
  const productColor = pimDetails?.mainColour?.code;
@@ -105,6 +106,12 @@ const getObject = async (topicModel) => {
105
106
  productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "powerSupplyType", "electrical");
106
107
  productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "ipRating", "marking");
107
108
  productFields.certificationFilters = (0, utils_1.getCertificationFilters)(pimDetails);
109
+ productFields.certifiedFilters = [
110
+ ...new Set([
111
+ ...productFields.certifiedFilters,
112
+ ...(0, utils_1.getCertifiedFilters)(pimDetails),
113
+ ]),
114
+ ];
108
115
  });
109
116
  const allDestinations = topicModelWithFields?.fields?.destinations?.[defaultEnvironmentLocaleCode] || [];
110
117
  productFields.totalProducts = {};
@@ -173,6 +173,8 @@ const getObject = async (topicProduct) => {
173
173
  }
174
174
  (0, logs_1.log)(`Get certificationFilters details...`);
175
175
  productFields.certificationFilters = (0, utils_1.getCertificationFilters)(topicProductWithFields?.fields?.productFields?.[defaultEnvironmentLocaleCode]);
176
+ (0, logs_1.log)(`Get certifiedFilters details...`);
177
+ productFields.certifiedFilters = (0, utils_1.getCertifiedFilters)(topicProductWithFields?.fields?.productFields?.[defaultEnvironmentLocaleCode]);
176
178
  (0, logs_1.log)(`Get filterableCertifications details...`);
177
179
  const filterableCertificationsFields = ["enec", "ul", "certificates"];
178
180
  for (const filterableCertificationsField of filterableCertificationsFields) {
@@ -76,6 +76,7 @@ const getProductFields = async (topicSubFamily, destination = "PROFESSIONAL_GLOB
76
76
  for (const destination of allDestinations) {
77
77
  productFields.totalProducts[destination] = topicProductEntries.filter((topicProductEntry) => topicProductEntry?.fields?.productFields?.[defaultEnvironmentLocaleCode]?.destinations?.find((productDestination) => productDestination.code === destination)).length;
78
78
  }
79
+ productFields.certifiedFilters = [];
79
80
  for (const topicProduct of topicProductEntries) {
80
81
  if (topicProduct?.fields?.productFields?.[defaultEnvironmentLocaleCode]) {
81
82
  const pimDetails = topicProduct?.fields?.productFields?.[defaultEnvironmentLocaleCode];
@@ -123,6 +124,12 @@ const getProductFields = async (topicSubFamily, destination = "PROFESSIONAL_GLOB
123
124
  productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "ipRating", "marking");
124
125
  productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "markings", "marking");
125
126
  productFields.certificationFilters = (0, utils_1.getCertificationFilters)(pimDetails);
127
+ productFields.certifiedFilters = [
128
+ ...new Set([
129
+ ...productFields.certifiedFilters,
130
+ ...(0, utils_1.getCertifiedFilters)(pimDetails),
131
+ ]),
132
+ ];
126
133
  const filterableCertificationsFields = ["enec", "ul", "certificates"];
127
134
  for (const filterableCertificationsField of filterableCertificationsFields) {
128
135
  productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, filterableCertificationsField, "certification", "filterableCertifications", false, true);
@@ -1174,5 +1174,124 @@
1174
1174
  "icon": false,
1175
1175
  "dictionary": "DDestination",
1176
1176
  "type": "array"
1177
+ },
1178
+ {
1179
+ "key": "koreaCertified",
1180
+ "parent": "certified",
1181
+ "icon": true,
1182
+ "dictionary": "DBooleanCertification",
1183
+ "type": "object"
1184
+ },
1185
+ {
1186
+ "key": "ulCertified",
1187
+ "parent": "certified",
1188
+ "icon": true,
1189
+ "dictionary": "DBooleanCertification",
1190
+ "type": "object"
1191
+ },
1192
+ {
1193
+ "key": "iramCertified",
1194
+ "parent": "certified",
1195
+ "icon": true,
1196
+ "dictionary": "DBooleanCertification",
1197
+ "type": "object"
1198
+ },
1199
+ {
1200
+ "key": "ukcaCertified",
1201
+ "parent": "certified",
1202
+ "icon": true,
1203
+ "dictionary": "DBooleanCertification",
1204
+ "type": "object"
1205
+ },
1206
+ {
1207
+ "key": "rgCertified",
1208
+ "parent": "certified",
1209
+ "icon": true,
1210
+ "dictionary": "DBooleanCertification",
1211
+ "type": "object"
1212
+ },
1213
+ {
1214
+ "key": "bisCertified",
1215
+ "parent": "certified",
1216
+ "icon": true,
1217
+ "dictionary": "DBooleanCertification",
1218
+ "type": "object"
1219
+ },
1220
+ {
1221
+ "key": "cqcCertified",
1222
+ "parent": "certified",
1223
+ "icon": true,
1224
+ "dictionary": "DBooleanCertification",
1225
+ "type": "object"
1226
+ },
1227
+ {
1228
+ "key": "ja8Certified",
1229
+ "parent": "certified",
1230
+ "icon": true,
1231
+ "dictionary": "DBooleanCertification",
1232
+ "type": "object"
1233
+ },
1234
+ {
1235
+ "key": "ieceecbCertified",
1236
+ "parent": "certified",
1237
+ "icon": true,
1238
+ "dictionary": "DBooleanCertification",
1239
+ "type": "object"
1240
+ },
1241
+ {
1242
+ "key": "sasoCertified",
1243
+ "parent": "certified",
1244
+ "icon": true,
1245
+ "dictionary": "DBooleanCertification",
1246
+ "type": "object"
1247
+ },
1248
+ {
1249
+ "key": "eacCertified",
1250
+ "parent": "certified",
1251
+ "icon": true,
1252
+ "dictionary": "DBooleanCertification",
1253
+ "type": "object"
1254
+ },
1255
+ {
1256
+ "key": "cceaCertified",
1257
+ "parent": "certified",
1258
+ "icon": true,
1259
+ "dictionary": "DBooleanCertification",
1260
+ "type": "object"
1261
+ },
1262
+ {
1263
+ "key": "enecCertified",
1264
+ "parent": "certified",
1265
+ "icon": true,
1266
+ "dictionary": "DBooleanCertification",
1267
+ "type": "object"
1268
+ },
1269
+ {
1270
+ "key": "retilapCertified",
1271
+ "parent": "certified",
1272
+ "icon": true,
1273
+ "dictionary": "DBooleanCertification",
1274
+ "type": "object"
1275
+ },
1276
+ {
1277
+ "key": "cccCertified",
1278
+ "parent": "certified",
1279
+ "icon": true,
1280
+ "dictionary": "DBooleanCertification",
1281
+ "type": "object"
1282
+ },
1283
+ {
1284
+ "key": "ceCertified",
1285
+ "parent": "certified",
1286
+ "icon": true,
1287
+ "dictionary": "DBooleanCertification",
1288
+ "type": "object"
1289
+ },
1290
+ {
1291
+ "key": "mexicoCertified",
1292
+ "parent": "certified",
1293
+ "icon": true,
1294
+ "dictionary": "DBooleanCertification",
1295
+ "type": "object"
1177
1296
  }
1178
1297
  ]
@@ -300,6 +300,8 @@ const getProductFields = async (pimDetails) => {
300
300
  value = {
301
301
  state: !!pimDetails[fieldData.parent][fieldData.key].state,
302
302
  label: pimDetails[fieldData.parent][fieldData.key]?.label?.[`value_${defaultEnvironmentLocaleCode}`] || "",
303
+ code: pimDetails[fieldData.parent][fieldData.key]?.code || "",
304
+ parentName: pimDetails[fieldData.parent][fieldData.key]?.parentName || "",
303
305
  };
304
306
  }
305
307
  else if (typeof pimDetails[fieldData.parent][fieldData.key] !== "object" &&
@@ -459,6 +461,7 @@ const getProductData = async (productEntry, productDetails) => {
459
461
  data.fields.note = (0, utils_1.getPimTranslations)(productDetails, "note");
460
462
  const { currentCatalog, ...pimDetails } = productDetails;
461
463
  (0, logs_1.log)(`Set productFields`);
464
+ pimDetails.certified = pimDetails?.certification?.certified || {};
462
465
  const productFields = await getProductFields(pimDetails);
463
466
  data.fields = await (0, contentful_1.addFieldValue)(data, "productFields", productFields);
464
467
  const catalog = productDetails?.currentCatalog?.catalogCode || "";
@@ -85,6 +85,7 @@ export interface ProductDetails {
85
85
  catalogs?: CatalogsEntity[] | null;
86
86
  currentCatalog?: CatalogsEntity | null;
87
87
  destinations: GenericData[] | null;
88
+ certified?: any;
88
89
  }
89
90
  export interface ProductGroup {
90
91
  code: string;
@@ -151,6 +152,7 @@ export interface Certification {
151
152
  rgCertified?: null;
152
153
  euRule?: null;
153
154
  certificates?: GenericData[] | null;
155
+ certified?: any;
154
156
  }
155
157
  export interface Marking {
156
158
  externalIp: GenericData;
package/dist/utils.d.ts CHANGED
@@ -20,3 +20,4 @@ export declare const replaceAll: (original: string, from: string, to: string) =>
20
20
  export declare const getAllTranslations: (values: any) => Promise<any>;
21
21
  export declare const truncateString: (string: string, limit: number) => string;
22
22
  export declare const getCertificationFilters: (productFields: any) => any;
23
+ export declare const getCertifiedFilters: (productFields: any) => any[];
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCertificationFilters = exports.truncateString = exports.getAllTranslations = exports.replaceAll = exports.addProductFieldValueCodesByPimDetails = exports.keysToLowerCase = exports.capitalizeFirstLetter = exports.getLocalISOTime = exports.doChunk = exports.sanitizeValue = exports.getUnwantedValues = exports.getPimTranslations = exports.getLocale = exports.pimLocaleMap = exports.stringToSlug = exports.secondBetweenTwoDate = exports.basename = exports.getBaseURL = exports.sleep = exports.mergeObjects = void 0;
3
+ exports.getCertifiedFilters = exports.getCertificationFilters = exports.truncateString = exports.getAllTranslations = exports.replaceAll = exports.addProductFieldValueCodesByPimDetails = exports.keysToLowerCase = exports.capitalizeFirstLetter = exports.getLocalISOTime = exports.doChunk = exports.sanitizeValue = exports.getUnwantedValues = exports.getPimTranslations = exports.getLocale = exports.pimLocaleMap = exports.stringToSlug = exports.secondBetweenTwoDate = exports.basename = exports.getBaseURL = exports.sleep = exports.mergeObjects = void 0;
4
4
  const logs_1 = require("./libs/logs");
5
5
  const contentful_1 = require("./libs/contentful");
6
6
  const mergeObjects = (objA, objB) => {
@@ -321,3 +321,11 @@ const getCertificationFilters = (productFields) => {
321
321
  return certificationFilters;
322
322
  };
323
323
  exports.getCertificationFilters = getCertificationFilters;
324
+ const getCertifiedFilters = (productFields) => {
325
+ return productFields?.certified
326
+ ? Object.values(productFields?.certified)
327
+ ?.filter((c) => !!c.state === true)
328
+ ?.map((c) => c.code)
329
+ : [];
330
+ };
331
+ exports.getCertifiedFilters = getCertifiedFilters;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",