pim-import 6.0.0 → 6.1.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.
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 } from "./utils";
29
+ export { getLocalISOTime, formatDateToISO } 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.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.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;
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,6 +114,7 @@ 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; } });
117
118
  var endpoints_1 = require("./pim/endpoints");
118
119
  Object.defineProperty(exports, "getStaticDailyProducts", { enumerable: true, get: function () { return endpoints_1.getStaticDailyProducts; } });
119
120
  Object.defineProperty(exports, "getLatestProducts", { enumerable: true, get: function () { return endpoints_1.getLatestProducts; } });
@@ -87,13 +87,17 @@ 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
+ : "";
90
94
  const opts = {
91
95
  onlyweb: true,
92
- lastModified,
96
+ lastModified: formattedLastModified,
93
97
  catalog: catalogCode,
94
98
  page: offset,
95
99
  size: limit,
96
- lastModifiedTo,
100
+ lastModifiedTo: formattedLastModifiedTo,
97
101
  };
98
102
  const { data } = await (0, request_1.getRequest)("micro-service/product/paged/search", {
99
103
  params: opts,
package/dist/utils.d.ts CHANGED
@@ -5,6 +5,7 @@ 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;
8
9
  export declare const stringToSlug: (str: string, skipReplaceDots?: boolean, locale?: string) => string;
9
10
  export declare const pimLocaleMap: Partial<Record<PimLocale, ContentfulLocale>>;
10
11
  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.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.formatDateToISO = 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,6 +22,27 @@ 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;
25
46
  const stringToSlug = (str, skipReplaceDots = false, locale = "en") => {
26
47
  str = str.replace(/^\s+|\s+$/g, "");
27
48
  str = str.toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",