pim-import 5.12.6 → 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/algolia/clean.d.ts +2 -1
- package/dist/algolia/downloads.d.ts +2 -1
- package/dist/algolia/families.d.ts +2 -1
- package/dist/algolia/inspirations.d.ts +2 -1
- package/dist/algolia/models.d.ts +2 -1
- package/dist/algolia/news.d.ts +2 -1
- package/dist/algolia/pressRelease.d.ts +2 -1
- package/dist/algolia/pressReview.d.ts +2 -1
- package/dist/algolia/products.d.ts +2 -1
- package/dist/algolia/projects.d.ts +2 -1
- package/dist/algolia/stories.d.ts +2 -1
- package/dist/algolia/subFamilies.d.ts +2 -1
- package/dist/algolia/subModels.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/pim/config.js +1 -1
- package/dist/pim/endpoints.js +12 -8
- package/dist/pim/methods/latestProducts.d.ts +1 -1
- package/dist/pim/methods/latestProducts.js +10 -10
- package/dist/pim/methods/products.js +45 -8
- package/dist/resources/ProductDetails.d.ts +2 -27
- package/dist/types.d.ts +2 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +22 -1
- package/package.json +1 -1
package/dist/algolia/clean.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { AvailableCatalogs, AvailableEntryStatus } from "../types";
|
|
|
2
2
|
import { AvailableIndicesKey } from "./config";
|
|
3
3
|
export declare const removeRecordsByStatus: (indexKey: AvailableIndicesKey, offset?: number, limit?: number, status?: AvailableEntryStatus, catalogCode?: AvailableCatalogs) => Promise<false | {
|
|
4
4
|
objectIds: string[];
|
|
5
|
-
offset
|
|
5
|
+
offset?: number | undefined;
|
|
6
6
|
limit: number;
|
|
7
7
|
completed: boolean;
|
|
8
8
|
s3FilePath?: string | undefined;
|
|
9
9
|
total?: number | undefined;
|
|
10
|
+
nextPage?: number | null | undefined;
|
|
10
11
|
}>;
|
|
@@ -33,10 +33,11 @@ export declare const reindexDownloads: (offset?: number, limit?: number, filterK
|
|
|
33
33
|
savedObjectIDs: string[];
|
|
34
34
|
deletedObjectIDs: string[];
|
|
35
35
|
objects: Readonly<Record<string, any>>[];
|
|
36
|
-
offset
|
|
36
|
+
offset?: number | undefined;
|
|
37
37
|
limit: number;
|
|
38
38
|
completed: boolean;
|
|
39
39
|
s3FilePath?: string | undefined;
|
|
40
40
|
total?: number | undefined;
|
|
41
|
+
nextPage?: number | null | undefined;
|
|
41
42
|
}>;
|
|
42
43
|
export declare const removeDownloadObject: (objectId: string) => Promise<void>;
|
|
@@ -30,11 +30,12 @@ export declare const reindexFamilies: (offset?: number, limit?: number, catalogC
|
|
|
30
30
|
savedObjectIDs: string[];
|
|
31
31
|
deletedObjectIDs: string[];
|
|
32
32
|
objects: Readonly<Record<string, any>>[];
|
|
33
|
-
offset
|
|
33
|
+
offset?: number | undefined;
|
|
34
34
|
limit: number;
|
|
35
35
|
completed: boolean;
|
|
36
36
|
s3FilePath?: string | undefined;
|
|
37
37
|
total?: number | undefined;
|
|
38
|
+
nextPage?: number | null | undefined;
|
|
38
39
|
}>;
|
|
39
40
|
export declare const reindexFamily: (topicFamilyEntryId: string) => Promise<{
|
|
40
41
|
taskID: number;
|
|
@@ -32,10 +32,11 @@ export declare const reindexInspirations: (offset?: number, limit?: number, filt
|
|
|
32
32
|
savedObjectIDs: string[];
|
|
33
33
|
deletedObjectIDs: string[];
|
|
34
34
|
objects: Readonly<Record<string, any>>[];
|
|
35
|
-
offset
|
|
35
|
+
offset?: number | undefined;
|
|
36
36
|
limit: number;
|
|
37
37
|
completed: boolean;
|
|
38
38
|
s3FilePath?: string | undefined;
|
|
39
39
|
total?: number | undefined;
|
|
40
|
+
nextPage?: number | null | undefined;
|
|
40
41
|
}>;
|
|
41
42
|
export declare const removeInspirationObject: (objectId: string) => Promise<void>;
|
package/dist/algolia/models.d.ts
CHANGED
|
@@ -27,10 +27,11 @@ export declare const reindexModels: (offset?: number, limit?: number, catalogCod
|
|
|
27
27
|
savedObjectIDs: string[];
|
|
28
28
|
deletedObjectIDs: string[];
|
|
29
29
|
objects: Readonly<Record<string, any>>[];
|
|
30
|
-
offset
|
|
30
|
+
offset?: number | undefined;
|
|
31
31
|
limit: number;
|
|
32
32
|
completed: boolean;
|
|
33
33
|
s3FilePath?: string | undefined;
|
|
34
34
|
total?: number | undefined;
|
|
35
|
+
nextPage?: number | null | undefined;
|
|
35
36
|
}>;
|
|
36
37
|
export declare const removeModelObject: (topicModelId: string) => Promise<void>;
|
package/dist/algolia/news.d.ts
CHANGED
|
@@ -28,10 +28,11 @@ export declare const reindexPosts: (offset?: number, limit?: number, filterKey?:
|
|
|
28
28
|
savedObjectIDs: string[];
|
|
29
29
|
deletedObjectIDs: string[];
|
|
30
30
|
objects: Readonly<Record<string, any>>[];
|
|
31
|
-
offset
|
|
31
|
+
offset?: number | undefined;
|
|
32
32
|
limit: number;
|
|
33
33
|
completed: boolean;
|
|
34
34
|
s3FilePath?: string | undefined;
|
|
35
35
|
total?: number | undefined;
|
|
36
|
+
nextPage?: number | null | undefined;
|
|
36
37
|
}>;
|
|
37
38
|
export declare const removePostObject: (objectId: string) => Promise<void>;
|
|
@@ -26,10 +26,11 @@ export declare const reindexPressReleases: (offset?: number, limit?: number, fil
|
|
|
26
26
|
savedObjectIDs: string[];
|
|
27
27
|
deletedObjectIDs: string[];
|
|
28
28
|
objects: Readonly<Record<string, any>>[];
|
|
29
|
-
offset
|
|
29
|
+
offset?: number | undefined;
|
|
30
30
|
limit: number;
|
|
31
31
|
completed: boolean;
|
|
32
32
|
s3FilePath?: string | undefined;
|
|
33
33
|
total?: number | undefined;
|
|
34
|
+
nextPage?: number | null | undefined;
|
|
34
35
|
}>;
|
|
35
36
|
export declare const removePressReleaseObject: (objectId: string) => Promise<void>;
|
|
@@ -26,10 +26,11 @@ export declare const reindexPressReviews: (offset?: number, limit?: number, filt
|
|
|
26
26
|
savedObjectIDs: string[];
|
|
27
27
|
deletedObjectIDs: string[];
|
|
28
28
|
objects: Readonly<Record<string, any>>[];
|
|
29
|
-
offset
|
|
29
|
+
offset?: number | undefined;
|
|
30
30
|
limit: number;
|
|
31
31
|
completed: boolean;
|
|
32
32
|
s3FilePath?: string | undefined;
|
|
33
33
|
total?: number | undefined;
|
|
34
|
+
nextPage?: number | null | undefined;
|
|
34
35
|
}>;
|
|
35
36
|
export declare const removePressReviewObject: (objectId: string) => Promise<void>;
|
|
@@ -81,10 +81,11 @@ export declare const reindexProducts: (filterKey: string, filterValue: string, o
|
|
|
81
81
|
savedObjectIDs: string[];
|
|
82
82
|
deletedObjectIDs: string[];
|
|
83
83
|
objects: Readonly<Record<string, any>>[];
|
|
84
|
-
offset
|
|
84
|
+
offset?: number | undefined;
|
|
85
85
|
limit: number;
|
|
86
86
|
completed: boolean;
|
|
87
87
|
s3FilePath?: string | undefined;
|
|
88
88
|
total?: number | undefined;
|
|
89
|
+
nextPage?: number | null | undefined;
|
|
89
90
|
}>;
|
|
90
91
|
export declare const removeProductObject: (topicProductId: string) => Promise<void>;
|
|
@@ -44,10 +44,11 @@ export declare const reindexProjects: (offset?: number, limit?: number, filterKe
|
|
|
44
44
|
savedObjectIDs: string[];
|
|
45
45
|
deletedObjectIDs: string[];
|
|
46
46
|
objects: Readonly<Record<string, any>>[];
|
|
47
|
-
offset
|
|
47
|
+
offset?: number | undefined;
|
|
48
48
|
limit: number;
|
|
49
49
|
completed: boolean;
|
|
50
50
|
s3FilePath?: string | undefined;
|
|
51
51
|
total?: number | undefined;
|
|
52
|
+
nextPage?: number | null | undefined;
|
|
52
53
|
}>;
|
|
53
54
|
export declare const removeProjectObject: (objectId: string) => Promise<void>;
|
|
@@ -40,10 +40,11 @@ export declare const reindexStories: (offset?: number, limit?: number, filterKey
|
|
|
40
40
|
savedObjectIDs: string[];
|
|
41
41
|
deletedObjectIDs: string[];
|
|
42
42
|
objects: Readonly<Record<string, any>>[];
|
|
43
|
-
offset
|
|
43
|
+
offset?: number | undefined;
|
|
44
44
|
limit: number;
|
|
45
45
|
completed: boolean;
|
|
46
46
|
s3FilePath?: string | undefined;
|
|
47
47
|
total?: number | undefined;
|
|
48
|
+
nextPage?: number | null | undefined;
|
|
48
49
|
}>;
|
|
49
50
|
export declare const removeStoryObject: (objectId: string) => Promise<void>;
|
|
@@ -3,11 +3,12 @@ export declare const reindexSubFamilies: (offset?: number, limit?: number, catal
|
|
|
3
3
|
savedObjectIDs: string[];
|
|
4
4
|
deletedObjectIDs: string[];
|
|
5
5
|
objects: Readonly<Record<string, any>>[];
|
|
6
|
-
offset
|
|
6
|
+
offset?: number | undefined;
|
|
7
7
|
limit: number;
|
|
8
8
|
completed: boolean;
|
|
9
9
|
s3FilePath?: string | undefined;
|
|
10
10
|
total?: number | undefined;
|
|
11
|
+
nextPage?: number | null | undefined;
|
|
11
12
|
}>;
|
|
12
13
|
export declare const reindexSubFamily: (topicSubFamilyEntryId: string) => Promise<{
|
|
13
14
|
taskID: number;
|
|
@@ -21,10 +21,11 @@ export declare const reindexSubModels: (offset?: number, limit?: number, catalog
|
|
|
21
21
|
savedObjectIDs: string[];
|
|
22
22
|
deletedObjectIDs: string[];
|
|
23
23
|
objects: Readonly<Record<string, any>>[];
|
|
24
|
-
offset
|
|
24
|
+
offset?: number | undefined;
|
|
25
25
|
limit: number;
|
|
26
26
|
completed: boolean;
|
|
27
27
|
s3FilePath?: string | undefined;
|
|
28
28
|
total?: number | undefined;
|
|
29
|
+
nextPage?: number | null | undefined;
|
|
29
30
|
}>;
|
|
30
31
|
export declare const removeSubModelObject: (topicSubModelId: string) => Promise<void>;
|
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; } });
|
package/dist/pim/config.js
CHANGED
|
@@ -50,7 +50,7 @@ const init = (providedConfig) => {
|
|
|
50
50
|
else if (!providedConfig) {
|
|
51
51
|
throw new Error("Configuration params not found");
|
|
52
52
|
}
|
|
53
|
-
exports.config.baseURL = providedConfig.baseURL;
|
|
53
|
+
exports.config.baseURL = providedConfig.baseURL.replace(/^["']|["']$/g, "");
|
|
54
54
|
exports.config.username =
|
|
55
55
|
typeof providedConfig.username !== "undefined"
|
|
56
56
|
? providedConfig.username
|
package/dist/pim/endpoints.js
CHANGED
|
@@ -87,20 +87,24 @@ 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
|
-
|
|
95
|
-
|
|
96
|
-
lastModifiedTo,
|
|
98
|
+
page: offset,
|
|
99
|
+
size: limit,
|
|
100
|
+
lastModifiedTo: formattedLastModifiedTo,
|
|
97
101
|
};
|
|
98
|
-
const { data } = await (0, request_1.getRequest)("
|
|
102
|
+
const { data } = await (0, request_1.getRequest)("micro-service/product/paged/search", {
|
|
99
103
|
params: opts,
|
|
100
104
|
});
|
|
101
105
|
const timeEnd = new Date();
|
|
102
106
|
const seconds = (0, utils_1.secondBetweenTwoDate)(timeStart, timeEnd);
|
|
103
|
-
(0, logs_1.log)(`Request time: ${seconds} seconds - endpoint:
|
|
107
|
+
(0, logs_1.log)(`Request time: ${seconds} seconds - endpoint: micro-service/product/paged/search`);
|
|
104
108
|
return data;
|
|
105
109
|
}
|
|
106
110
|
catch (err) {
|
|
@@ -111,10 +115,10 @@ exports.getLatestProducts = getLatestProducts;
|
|
|
111
115
|
const getProductDetails = async (code) => {
|
|
112
116
|
try {
|
|
113
117
|
const timeStart = new Date();
|
|
114
|
-
const { data } = await (0, request_1.getRequest)(`product/
|
|
118
|
+
const { data } = await (0, request_1.getRequest)(`micro-service/product/get/${code}`);
|
|
115
119
|
const timeEnd = new Date();
|
|
116
120
|
const seconds = (0, utils_1.secondBetweenTwoDate)(timeStart, timeEnd);
|
|
117
|
-
(0, logs_1.log)(`Request time: ${seconds} seconds - endpoint: product/
|
|
121
|
+
(0, logs_1.log)(`Request time: ${seconds} seconds - endpoint: micro-service/product/get/${code}`);
|
|
118
122
|
return data;
|
|
119
123
|
}
|
|
120
124
|
catch (err) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AvailableCatalogs, PaginationResults } from "../../types";
|
|
2
|
-
export declare const importLatestProducts: (catalog: AvailableCatalogs, lastModified: string,
|
|
2
|
+
export declare const importLatestProducts: (catalog: AvailableCatalogs, lastModified: string, page?: number, limit?: number, lastModifiedTo?: string) => Promise<PaginationResults>;
|
|
@@ -5,20 +5,20 @@ const endpoints_1 = require("../endpoints");
|
|
|
5
5
|
const logs_1 = require("../../libs/logs");
|
|
6
6
|
const products_1 = require("./products");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
|
-
const importLatestProducts = async (catalog, lastModified,
|
|
8
|
+
const importLatestProducts = async (catalog, lastModified, page = 0, limit = 100, lastModifiedTo = "") => {
|
|
9
9
|
const timeStart = new Date();
|
|
10
|
-
|
|
10
|
+
page = Number(page);
|
|
11
11
|
limit = Number(limit);
|
|
12
|
-
(0, logs_1.log)(`importLatestProducts - catalog: ${catalog} lastModified: ${lastModified}
|
|
13
|
-
const data = await (0, endpoints_1.getLatestProducts)(catalog, lastModified,
|
|
14
|
-
const total = data.
|
|
15
|
-
const products = data.
|
|
12
|
+
(0, logs_1.log)(`importLatestProducts - catalog: ${catalog} lastModified: ${lastModified} page: ${page} limit: ${limit} lastModifiedTo: ${lastModifiedTo}`, "INFO");
|
|
13
|
+
const data = await (0, endpoints_1.getLatestProducts)(catalog, lastModified, page, limit, lastModifiedTo);
|
|
14
|
+
const total = data.totalElements;
|
|
15
|
+
const products = data.content;
|
|
16
16
|
(0, logs_1.log)(`${total} products founded`);
|
|
17
|
-
let count =
|
|
17
|
+
let count = page * limit + 1;
|
|
18
18
|
let current = 0;
|
|
19
19
|
for (const product of products) {
|
|
20
20
|
(0, logs_1.log)(`${count} of ${total}`);
|
|
21
|
-
const productDetails = product
|
|
21
|
+
const productDetails = product;
|
|
22
22
|
await (0, products_1.importProduct)(productDetails, catalog);
|
|
23
23
|
count++;
|
|
24
24
|
if (logs_1.serverUtils) {
|
|
@@ -30,9 +30,9 @@ const importLatestProducts = async (catalog, lastModified, offset = 0, limit = 1
|
|
|
30
30
|
const timeEnd = new Date();
|
|
31
31
|
const seconds = (0, utils_1.secondBetweenTwoDate)(timeStart, timeEnd);
|
|
32
32
|
(0, logs_1.log)(`Request time: ${seconds} seconds`);
|
|
33
|
-
const completed =
|
|
33
|
+
const completed = count >= total;
|
|
34
34
|
return {
|
|
35
|
-
|
|
35
|
+
nextPage: completed ? null : page + 1,
|
|
36
36
|
limit,
|
|
37
37
|
completed,
|
|
38
38
|
total,
|
|
@@ -93,7 +93,7 @@ const isTermsToAdd = async (productDetails, catalog) => {
|
|
|
93
93
|
const modelsFieldKey = "models" + (0, utils_1.capitalizeFirstLetter)(catalog);
|
|
94
94
|
if (productDetails.models) {
|
|
95
95
|
for (const model of productDetails.models) {
|
|
96
|
-
const modelCode = model.
|
|
96
|
+
const modelCode = model.code;
|
|
97
97
|
if (modelCode) {
|
|
98
98
|
(0, logs_1.log)(`Get model entry with id ${modelCode}`);
|
|
99
99
|
const modelEntry = await (0, contentful_1.getEntryByID)(modelCode, "topicModel", "sys");
|
|
@@ -116,7 +116,7 @@ const isTermsToAdd = async (productDetails, catalog) => {
|
|
|
116
116
|
const subModelsFieldKey = "subModels" + (0, utils_1.capitalizeFirstLetter)(catalog);
|
|
117
117
|
if (productDetails.submodels) {
|
|
118
118
|
for (const submodel of productDetails.submodels) {
|
|
119
|
-
const subModelCode = submodel.
|
|
119
|
+
const subModelCode = submodel.code;
|
|
120
120
|
if (subModelCode) {
|
|
121
121
|
(0, logs_1.log)(`Get subModel entry with id ${subModelCode}`);
|
|
122
122
|
const subModelEntry = await (0, contentful_1.getEntryByID)(subModelCode, "topicSubModel", "sys");
|
|
@@ -529,7 +529,7 @@ const getProductData = async (productEntry, productDetails) => {
|
|
|
529
529
|
if (productDetails?.models) {
|
|
530
530
|
(0, logs_1.log)(`Set ${productDetails.models.length} model relations`);
|
|
531
531
|
const modelCodes = productDetails.models.map((model) => {
|
|
532
|
-
return model.
|
|
532
|
+
return model.code;
|
|
533
533
|
});
|
|
534
534
|
const topicModelEntries = await (0, contentful_1.getAllEntriesByCodes)(modelCodes, "topicModel", "sys,fields.catalog");
|
|
535
535
|
if (topicModelEntries.length) {
|
|
@@ -553,7 +553,7 @@ const getProductData = async (productEntry, productDetails) => {
|
|
|
553
553
|
if (productDetails?.submodels) {
|
|
554
554
|
(0, logs_1.log)(`Set ${productDetails.submodels.length} subModels relations`);
|
|
555
555
|
const subModelsCodes = productDetails.submodels.map((subModel) => {
|
|
556
|
-
return subModel.
|
|
556
|
+
return subModel.code;
|
|
557
557
|
});
|
|
558
558
|
const topicSubModelEntries = await (0, contentful_1.getAllEntriesByCodes)(subModelsCodes, "topicSubModel", "sys,fields.catalog");
|
|
559
559
|
if (topicSubModelEntries.length) {
|
|
@@ -682,7 +682,46 @@ const getProductColourVariantsData = async (topicProductColourVariantsCode, prod
|
|
|
682
682
|
data.fields.lastPimSyncDate[defaultEnvironmentLocaleCode] = (0, utils_1.getLocalISOTime)();
|
|
683
683
|
return data;
|
|
684
684
|
};
|
|
685
|
+
const removeProductColourVariants = async (productEntryId) => {
|
|
686
|
+
(0, logs_1.log)(`Remove product from all topicProductColourVariants`);
|
|
687
|
+
const env = await (0, contentful_1.getEnvironment)();
|
|
688
|
+
const defEnvLocaleCode = await (0, contentful_1.getEnvironmentDefaultLocaleCode)();
|
|
689
|
+
const { items: allTopicProductColourVariants } = await env.getEntries({
|
|
690
|
+
content_type: "topicProductColourVariants",
|
|
691
|
+
locale: defEnvLocaleCode,
|
|
692
|
+
include: 1,
|
|
693
|
+
links_to_entry: productEntryId,
|
|
694
|
+
limit: 1000,
|
|
695
|
+
});
|
|
696
|
+
(0, logs_1.log)(`Found ${allTopicProductColourVariants.length} topicProductColourVariants`);
|
|
697
|
+
for (let topicProductColourVariants of allTopicProductColourVariants) {
|
|
698
|
+
topicProductColourVariants.fields = await (0, contentful_1.removeFromRelationFields)(topicProductColourVariants, "products", productEntryId, true);
|
|
699
|
+
try {
|
|
700
|
+
topicProductColourVariants = await topicProductColourVariants.update();
|
|
701
|
+
if (topicProductColourVariants.isPublished()) {
|
|
702
|
+
try {
|
|
703
|
+
topicProductColourVariants =
|
|
704
|
+
await topicProductColourVariants.publish();
|
|
705
|
+
}
|
|
706
|
+
catch (err) {
|
|
707
|
+
const message = `addProductColourVariants - Cannot publish entry. ${topicProductColourVariants.sys.id}`;
|
|
708
|
+
await (0, notifications_1.notify)(message, false);
|
|
709
|
+
(0, logs_1.log)(message);
|
|
710
|
+
(0, logs_1.log)(err);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
catch (err) {
|
|
715
|
+
const message = `addProductColourVariants - Cannot update entry. ${topicProductColourVariants.sys.id}`;
|
|
716
|
+
await (0, notifications_1.notify)(message, false);
|
|
717
|
+
(0, logs_1.log)(message);
|
|
718
|
+
(0, logs_1.log)(err);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
};
|
|
685
722
|
const addProductColourVariants = async (colourVariants, productEntryId) => {
|
|
723
|
+
await removeProductColourVariants(productEntryId);
|
|
724
|
+
(0, logs_1.log)(`Add product to the topicProductColourVariants of the ${colourVariants.length} colour variants`);
|
|
686
725
|
for (const colourVariant of colourVariants) {
|
|
687
726
|
const topicId = `PCV_${colourVariant.code}`;
|
|
688
727
|
let topicProductColourVariants = await (0, contentful_1.getEntryByID)(topicId, "topicProductColourVariants");
|
|
@@ -1509,11 +1548,9 @@ const generateTechSpecPdf = async (topicProductId, country = "global", locale =
|
|
|
1509
1548
|
const fileName = (pageSlug.length >= 170
|
|
1510
1549
|
? `tech-spec-${topicProductId}`
|
|
1511
1550
|
: `tech-spec-${pageSlug}`) + `_${country}-${locale}`;
|
|
1512
|
-
let baseUrl =
|
|
1513
|
-
? process.env.FPI_TECH_SPEC_BASE_URL_CN ?? ""
|
|
1514
|
-
: process.env.FPI_TECH_SPEC_BASE_URL ?? "";
|
|
1551
|
+
let baseUrl = process.env.FPI_TECH_SPEC_BASE_URL ?? "";
|
|
1515
1552
|
if (!baseUrl) {
|
|
1516
|
-
(0, logs_1.log)(`FPI_TECH_SPEC_BASE_URL process env not found
|
|
1553
|
+
(0, logs_1.log)(`FPI_TECH_SPEC_BASE_URL process env not found`, "ERROR");
|
|
1517
1554
|
}
|
|
1518
1555
|
baseUrl = baseUrl.replace(/\/?(\?|#|$)/, "/$1");
|
|
1519
1556
|
let footerBaseUrl = country === "cn"
|
|
@@ -265,8 +265,7 @@ export interface CatalogsEntity {
|
|
|
265
265
|
familyCode?: string | null;
|
|
266
266
|
childFamilyCode?: null;
|
|
267
267
|
}
|
|
268
|
-
export interface ModelsEntityOrParentModel {
|
|
269
|
-
data: GenericData;
|
|
268
|
+
export interface ModelsEntityOrParentModel extends GenericData {
|
|
270
269
|
priority: number;
|
|
271
270
|
subFamilyCode: string;
|
|
272
271
|
productLineCode: string;
|
|
@@ -290,23 +289,11 @@ export interface ModelsEntityOrParentModel {
|
|
|
290
289
|
description2_da?: null;
|
|
291
290
|
description2_ru?: null;
|
|
292
291
|
description2_en_us?: null;
|
|
293
|
-
code?: null;
|
|
294
292
|
image?: null;
|
|
295
293
|
imageAlternative?: null;
|
|
296
|
-
value_en?: null;
|
|
297
|
-
value_en_US?: null;
|
|
298
|
-
value_it?: null;
|
|
299
|
-
value_es?: null;
|
|
300
|
-
value_de?: null;
|
|
301
|
-
value_fr?: null;
|
|
302
|
-
value_sv?: null;
|
|
303
|
-
value_no?: null;
|
|
304
|
-
value_da?: null;
|
|
305
|
-
value_ru?: null;
|
|
306
294
|
othersData: OthersData;
|
|
307
295
|
}
|
|
308
|
-
export interface SubmodelsEntity {
|
|
309
|
-
data: GenericData;
|
|
296
|
+
export interface SubmodelsEntity extends GenericData {
|
|
310
297
|
priority: number;
|
|
311
298
|
subFamilyCode?: null;
|
|
312
299
|
productLineCode?: null;
|
|
@@ -331,19 +318,7 @@ export interface SubmodelsEntity {
|
|
|
331
318
|
description2_da?: null;
|
|
332
319
|
description2_ru?: null;
|
|
333
320
|
description2_en_us?: null;
|
|
334
|
-
code?: null;
|
|
335
|
-
image?: null;
|
|
336
321
|
imageAlternative?: null;
|
|
337
|
-
value_en?: null;
|
|
338
|
-
value_en_US?: null;
|
|
339
|
-
value_it?: null;
|
|
340
|
-
value_es?: null;
|
|
341
|
-
value_de?: null;
|
|
342
|
-
value_fr?: null;
|
|
343
|
-
value_sv?: null;
|
|
344
|
-
value_no?: null;
|
|
345
|
-
value_da?: null;
|
|
346
|
-
value_ru?: null;
|
|
347
322
|
othersData: OthersData;
|
|
348
323
|
}
|
|
349
324
|
export interface ColourVariant {
|
package/dist/types.d.ts
CHANGED
|
@@ -61,11 +61,12 @@ export type CfSys = {
|
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
export type PaginationResults = {
|
|
64
|
-
offset
|
|
64
|
+
offset?: number;
|
|
65
65
|
limit: number;
|
|
66
66
|
completed: boolean;
|
|
67
67
|
s3FilePath?: string;
|
|
68
68
|
total?: number;
|
|
69
|
+
nextPage?: number | null;
|
|
69
70
|
};
|
|
70
71
|
export type CfLocalizedEntryField = Partial<Record<ContentfulLocale, string | null>>;
|
|
71
72
|
export type TopicDetailsResponse = {
|
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();
|