pim-import 6.1.0 → 6.1.3

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/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export { reindexPressReview, reindexPressReviews, removePressReviewObject, } fro
26
26
  export { reindexPressRelease, reindexPressReleases, removePressReleaseObject, } from "./algolia/pressRelease";
27
27
  export { reindexPost, reindexPosts, removePostObject } from "./algolia/news";
28
28
  export { importDownloads } from "./downloads/import";
29
- export { getLocalISOTime, formatDateToISO } from "./utils";
29
+ export { getLocalISOTime } from "./utils";
30
30
  export { getStaticDailyProducts, getLatestProducts } from "./pim/endpoints";
31
31
  export { log, setServerUtils, setLogId, setLogPath, setLogFilename, getLogFolder, } from "./libs/logs";
32
32
  export { removeRecordsByStatus } from "./algolia/clean";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeSubFamilyObject = exports.reindexSubFamily = exports.reindexSubFamilies = exports.removeFamilyObject = exports.reindexFamily = exports.reindexFamilies = exports.cloneIndexSettings = exports.getIndex = exports.checkTopicDraftAndPagePublished = exports.migrateEntryFields = exports.publishAllProductDrafts = exports.purgeProductThumbCacheByProductCodes = exports.populateDestinations = exports.reimportAuditProducts = exports.getProductPageIdByCode = exports.removeAllProductModelProductRelations = exports.removeProductFromColorVariantsByProductLine = exports.setProductAutodescriptionByTopicId = exports.getProductAutodescription = exports.setProductsAutodescription = exports.generateTechSpecPdf = exports.audit = exports.getAllProductEntriesByCatalog = exports.setProductRelationships = exports.setProductsRelationships = exports.importProductByCode = exports.importFamilies = exports.importSubFamilies = exports.importSubModels = exports.importModels = exports.importLatestProducts = exports.importCategories = exports.importDictionaryProductSubLine = exports.importDictionaryProductLine = exports.importDictionaryData = exports.importDictionaryIcons = exports.importDictionaryFields = exports.savePDFToS3 = exports.getFileFromS3 = exports.saveJsonToS3 = exports.uploadS3 = exports.initS3 = exports.getEntries = exports.getTopicPage = exports.getEntryByID = exports.deleteEntries = exports.deletePages = exports.initBaseEntries = exports.initContentful = exports.initPim = void 0;
4
- exports.netlifyBuild = exports.notify = exports.importDesigner = exports.importDesigners = exports.generatePDFByUrl = exports.removeRecordsByStatus = exports.getLogFolder = exports.setLogFilename = exports.setLogPath = exports.setLogId = exports.setServerUtils = exports.log = exports.getLatestProducts = exports.getStaticDailyProducts = exports.formatDateToISO = exports.getLocalISOTime = exports.importDownloads = exports.removePostObject = exports.reindexPosts = exports.reindexPost = exports.removePressReleaseObject = exports.reindexPressReleases = exports.reindexPressRelease = exports.removePressReviewObject = exports.reindexPressReviews = exports.reindexPressReview = exports.removeStoryObject = exports.reindexStories = exports.reindexStory = exports.removeProjectObject = exports.reindexProjects = exports.reindexProject = exports.removeInspirationObject = exports.reindexInspirations = exports.reindexInspiration = exports.removeDownloadObject = exports.reindexDownloads = exports.reindexDownload = exports.removeModelObject = exports.reindexModels = exports.reindexModel = exports.removeSubModelObject = exports.reindexSubModels = exports.reindexSubModel = exports.triggerPDFGenerator = exports.removeProductObject = exports.reindexProducts = exports.reindexProduct = void 0;
4
+ exports.netlifyBuild = exports.notify = exports.importDesigner = exports.importDesigners = exports.generatePDFByUrl = exports.removeRecordsByStatus = exports.getLogFolder = exports.setLogFilename = exports.setLogPath = exports.setLogId = exports.setServerUtils = exports.log = exports.getLatestProducts = exports.getStaticDailyProducts = exports.getLocalISOTime = exports.importDownloads = exports.removePostObject = exports.reindexPosts = exports.reindexPost = exports.removePressReleaseObject = exports.reindexPressReleases = exports.reindexPressRelease = exports.removePressReviewObject = exports.reindexPressReviews = exports.reindexPressReview = exports.removeStoryObject = exports.reindexStories = exports.reindexStory = exports.removeProjectObject = exports.reindexProjects = exports.reindexProject = exports.removeInspirationObject = exports.reindexInspirations = exports.reindexInspiration = exports.removeDownloadObject = exports.reindexDownloads = exports.reindexDownload = exports.removeModelObject = exports.reindexModels = exports.reindexModel = exports.removeSubModelObject = exports.reindexSubModels = exports.reindexSubModel = exports.triggerPDFGenerator = exports.removeProductObject = exports.reindexProducts = exports.reindexProduct = void 0;
5
5
  var config_1 = require("./pim/config");
6
6
  Object.defineProperty(exports, "initPim", { enumerable: true, get: function () { return config_1.init; } });
7
7
  var contentful_1 = require("./libs/contentful");
@@ -114,7 +114,6 @@ var import_1 = require("./downloads/import");
114
114
  Object.defineProperty(exports, "importDownloads", { enumerable: true, get: function () { return import_1.importDownloads; } });
115
115
  var utils_1 = require("./utils");
116
116
  Object.defineProperty(exports, "getLocalISOTime", { enumerable: true, get: function () { return utils_1.getLocalISOTime; } });
117
- Object.defineProperty(exports, "formatDateToISO", { enumerable: true, get: function () { return utils_1.formatDateToISO; } });
118
117
  var endpoints_1 = require("./pim/endpoints");
119
118
  Object.defineProperty(exports, "getStaticDailyProducts", { enumerable: true, get: function () { return endpoints_1.getStaticDailyProducts; } });
120
119
  Object.defineProperty(exports, "getLatestProducts", { enumerable: true, get: function () { return endpoints_1.getLatestProducts; } });
@@ -87,18 +87,15 @@ exports.getAllProducts = getAllProducts;
87
87
  const getLatestProducts = async (catalogCode, lastModified, offset = 0, limit = 100, lastModifiedTo = "") => {
88
88
  try {
89
89
  const timeStart = new Date();
90
- const formattedLastModified = (0, utils_1.formatDateToISO)(lastModified);
91
- const formattedLastModifiedTo = lastModifiedTo
92
- ? (0, utils_1.formatDateToISO)(lastModifiedTo)
93
- : "";
94
90
  const opts = {
95
91
  onlyweb: true,
96
- lastModified: formattedLastModified,
92
+ lastModified,
97
93
  catalog: catalogCode,
98
94
  page: offset,
99
95
  size: limit,
100
- lastModifiedTo: formattedLastModifiedTo,
96
+ lastModifiedTo,
101
97
  };
98
+ console.log("getLatestProducts params:", opts);
102
99
  const { data } = await (0, request_1.getRequest)("micro-service/product/paged/search", {
103
100
  params: opts,
104
101
  });
@@ -600,10 +600,7 @@ const getProductData = async (productEntry, productDetails) => {
600
600
  }
601
601
  else {
602
602
  (0, logs_1.log)(`Add thumbnail imgix wrapper with id ${wrapperImgixID} to Contentful`);
603
- const altText = (0, utils_1.getPimTranslations)(pimAssetThumb, "title");
604
- if (altText[defaultEnvironmentLocaleCode] === null) {
605
- altText[defaultEnvironmentLocaleCode] = "Thumbnail";
606
- }
603
+ const altText = (0, utils_1.getPimTranslations)(pimAssetThumb, "title", "Thumbnail");
607
604
  const wrapperImgixAttributes = (0, imgix_1.getDefaultWrapperImgixAttributesByPimUrl)(pimAssetThumb.url);
608
605
  if (wrapperImgixAttributes) {
609
606
  const wrapperImgixFields = {
package/dist/utils.d.ts CHANGED
@@ -5,7 +5,6 @@ export declare const sleep: (ms: number, showLog?: boolean) => Promise<unknown>;
5
5
  export declare const getBaseURL: (url: string) => string;
6
6
  export declare const basename: (path: string) => string;
7
7
  export declare const secondBetweenTwoDate: (newDate: Date, oldDate: Date) => number;
8
- export declare const formatDateToISO: (dateString: string) => string;
9
8
  export declare const stringToSlug: (str: string, skipReplaceDots?: boolean, locale?: string) => string;
10
9
  export declare const pimLocaleMap: Partial<Record<PimLocale, ContentfulLocale>>;
11
10
  export declare const getLocale: (pimLocaleCode: PimLocale) => ContentfulLocale | null;
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCertifiedFilters = 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.formatDateToISO = exports.secondBetweenTwoDate = exports.basename = exports.getBaseURL = exports.sleep = exports.mergeObjects = void 0;
3
+ exports.getCertifiedFilters = 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) => {
@@ -22,27 +22,6 @@ const basename = (path) => {
22
22
  exports.basename = basename;
23
23
  const secondBetweenTwoDate = (newDate, oldDate) => Math.abs((newDate.getTime() - oldDate.getTime()) / 1000);
24
24
  exports.secondBetweenTwoDate = secondBetweenTwoDate;
25
- const formatDateToISO = (dateString) => {
26
- if (!dateString) {
27
- return dateString;
28
- }
29
- if (dateString.includes("-") && dateString.endsWith("Z")) {
30
- return dateString;
31
- }
32
- const compactFormat = /^(\d{4})(\d{2})(\d{2})T(\d{2}):(\d{2}):(\d{2})$/;
33
- const match = dateString.match(compactFormat);
34
- if (match) {
35
- const [, year, month, day, hour, minute, second] = match;
36
- return `${year}-${month}-${day}T${hour}:${minute}:${second}Z`;
37
- }
38
- if (dateString.includes("-") &&
39
- dateString.includes("T") &&
40
- !dateString.endsWith("Z")) {
41
- return `${dateString}Z`;
42
- }
43
- return dateString;
44
- };
45
- exports.formatDateToISO = formatDateToISO;
46
25
  const stringToSlug = (str, skipReplaceDots = false, locale = "en") => {
47
26
  str = str.replace(/^\s+|\s+$/g, "");
48
27
  str = str.toLowerCase();
@@ -102,6 +81,11 @@ const getPimTranslations = (values, fieldKey = "value", defaultValue = "", limit
102
81
  }
103
82
  }
104
83
  }
84
+ if (defaultValue && Object.entries(names).length === 0) {
85
+ for (const locale of contentful_1.cfLocales) {
86
+ names[locale] = defaultValue;
87
+ }
88
+ }
105
89
  return names;
106
90
  };
107
91
  exports.getPimTranslations = getPimTranslations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "6.1.0",
3
+ "version": "6.1.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",