pim-import 5.10.0 → 5.12.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/models.d.ts
CHANGED
|
@@ -10,13 +10,14 @@ export declare const reindexModel: (topicModelId: string) => Promise<{
|
|
|
10
10
|
thumbnailImgix?: {} | WrapperImageFields | undefined;
|
|
11
11
|
productFieldFilter?: string | undefined;
|
|
12
12
|
productFields?: string[] | undefined;
|
|
13
|
+
productFieldsUs?: string[] | undefined;
|
|
14
|
+
productFieldsChina?: string[] | undefined;
|
|
13
15
|
productLine?: TopicDetailsResponse | undefined;
|
|
14
16
|
catalogs?: TopicDetailsResponse[] | undefined;
|
|
15
17
|
catalog?: TopicDetailsResponse | undefined;
|
|
16
18
|
subFamily?: TopicDetailsResponse | undefined;
|
|
17
19
|
isNew?: boolean | undefined;
|
|
18
20
|
priority?: number | undefined;
|
|
19
|
-
colors?: string[] | undefined;
|
|
20
21
|
designer?: TopicDetailsResponse | undefined;
|
|
21
22
|
lastSyncDate?: string | undefined;
|
|
22
23
|
destinations?: string[] | undefined;
|
package/dist/algolia/models.js
CHANGED
|
@@ -14,6 +14,57 @@ const getModelAutodescription = async (productLineCode) => {
|
|
|
14
14
|
const isObjectToDelete = (object, defaultEnvironmentLocaleCode) => {
|
|
15
15
|
return (!object?.slugs?.[defaultEnvironmentLocaleCode] || !object?.subFamily?.code);
|
|
16
16
|
};
|
|
17
|
+
const getProductFields = async (topicModelWithFields, catalogId, defaultEnvironmentLocaleCode, destination = "PROFESSIONAL_GLOBAL") => {
|
|
18
|
+
let productFields = {};
|
|
19
|
+
productFields.availableTo = [];
|
|
20
|
+
if (catalogId) {
|
|
21
|
+
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, 50, [{ key: "fields.destinations[in]", value: destination }]);
|
|
22
|
+
productFields.certifiedFilters = [];
|
|
23
|
+
topicProducts.forEach((topicProduct) => {
|
|
24
|
+
const pimDetails = topicProduct?.fields?.productFields?.[defaultEnvironmentLocaleCode];
|
|
25
|
+
(0, logs_1.log)(`Get ${topicProduct.sys.id} productField details...`);
|
|
26
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "destinations");
|
|
27
|
+
if (pimDetails.visibleToShop &&
|
|
28
|
+
!productFields.availableTo.includes("visibleToShop")) {
|
|
29
|
+
productFields.availableTo.push("visibleToShop");
|
|
30
|
+
}
|
|
31
|
+
if (pimDetails.quickDelivery &&
|
|
32
|
+
!productFields.availableTo.includes("quickDelivery")) {
|
|
33
|
+
productFields.availableTo.push("quickDelivery");
|
|
34
|
+
}
|
|
35
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "locations");
|
|
36
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "shapes", "physical");
|
|
37
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "bucketColours");
|
|
38
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "length", "physical");
|
|
39
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "length_us", "physical");
|
|
40
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "mountings");
|
|
41
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "orientations", "physical");
|
|
42
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "opticalType", "optical");
|
|
43
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "wPower", "electrical");
|
|
44
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "realNetFlow", "photometric");
|
|
45
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "temperatureColor", "photometric");
|
|
46
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "cri", "photometric");
|
|
47
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "powerSupplyType", "electrical");
|
|
48
|
+
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "ipRating", "marking");
|
|
49
|
+
productFields.certifiedFilters = [
|
|
50
|
+
...new Set([
|
|
51
|
+
...productFields.certifiedFilters,
|
|
52
|
+
...(0, utils_1.getCertifiedFilters)(pimDetails),
|
|
53
|
+
]),
|
|
54
|
+
];
|
|
55
|
+
});
|
|
56
|
+
const allDestinations = topicModelWithFields?.fields?.destinations?.[defaultEnvironmentLocaleCode] || [];
|
|
57
|
+
productFields.totalProducts = {};
|
|
58
|
+
for (const destination of allDestinations) {
|
|
59
|
+
productFields.totalProducts[destination] = topicProducts.filter((topicProductEntry) => topicProductEntry?.fields?.productFields?.[defaultEnvironmentLocaleCode]?.destinations?.find((productDestination) => productDestination.code === destination)).length;
|
|
60
|
+
}
|
|
61
|
+
return productFields;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
(0, logs_1.log)(`I cannot get the productFields because there is no catalog`, "WARN");
|
|
65
|
+
return productFields;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
17
68
|
const getObject = async (topicModel) => {
|
|
18
69
|
const defaultEnvironmentLocaleCode = await (0, contentful_cda_1.getEnvironmentDefaultLocaleCode)();
|
|
19
70
|
const topicModelId = typeof topicModel === "string" ? topicModel : topicModel?.sys.id;
|
|
@@ -68,59 +119,12 @@ const getObject = async (topicModel) => {
|
|
|
68
119
|
else {
|
|
69
120
|
(0, logs_1.log)(`No thumbnail imgix found`, "WARN");
|
|
70
121
|
}
|
|
71
|
-
(0, logs_1.log)(`Get
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
productFields.certifiedFilters = [];
|
|
78
|
-
topicProducts.forEach((topicProduct) => {
|
|
79
|
-
const pimDetails = topicProduct?.fields?.productFields?.[defaultEnvironmentLocaleCode];
|
|
80
|
-
const productColor = pimDetails?.mainColour?.code;
|
|
81
|
-
if (productColor && colors.indexOf(productColor) === -1) {
|
|
82
|
-
colors.push(productColor);
|
|
83
|
-
}
|
|
84
|
-
(0, logs_1.log)(`Get productField details...`);
|
|
85
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "destinations");
|
|
86
|
-
if (pimDetails.visibleToShop &&
|
|
87
|
-
!productFields.availableTo.includes("visibleToShop")) {
|
|
88
|
-
productFields.availableTo.push("visibleToShop");
|
|
89
|
-
}
|
|
90
|
-
if (pimDetails.quickDelivery &&
|
|
91
|
-
!productFields.availableTo.includes("quickDelivery")) {
|
|
92
|
-
productFields.availableTo.push("quickDelivery");
|
|
93
|
-
}
|
|
94
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "locations");
|
|
95
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "shapes", "physical");
|
|
96
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "bucketColours");
|
|
97
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "length", "physical");
|
|
98
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "length_us", "physical");
|
|
99
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "mountings");
|
|
100
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "orientations", "physical");
|
|
101
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "opticalType", "optical");
|
|
102
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "wPower", "electrical");
|
|
103
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "realNetFlow", "photometric");
|
|
104
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "temperatureColor", "photometric");
|
|
105
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "cri", "photometric");
|
|
106
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "powerSupplyType", "electrical");
|
|
107
|
-
productFields = (0, utils_1.addProductFieldValueCodesByPimDetails)(pimDetails, productFields, "ipRating", "marking");
|
|
108
|
-
productFields.certifiedFilters = [
|
|
109
|
-
...new Set([
|
|
110
|
-
...productFields.certifiedFilters,
|
|
111
|
-
...(0, utils_1.getCertifiedFilters)(pimDetails),
|
|
112
|
-
]),
|
|
113
|
-
];
|
|
114
|
-
});
|
|
115
|
-
const allDestinations = topicModelWithFields?.fields?.destinations?.[defaultEnvironmentLocaleCode] || [];
|
|
116
|
-
productFields.totalProducts = {};
|
|
117
|
-
for (const destination of allDestinations) {
|
|
118
|
-
productFields.totalProducts[destination] = topicProducts.filter((topicProductEntry) => topicProductEntry?.fields?.productFields?.[defaultEnvironmentLocaleCode]?.destinations?.find((productDestination) => productDestination.code === destination)).length;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
(0, logs_1.log)(`I cannot get the colors because there is no catalog`, "WARN");
|
|
123
|
-
}
|
|
122
|
+
(0, logs_1.log)(`Get Global productFields details...`);
|
|
123
|
+
const productFields = await getProductFields(topicModelWithFields, catalogId, defaultEnvironmentLocaleCode);
|
|
124
|
+
(0, logs_1.log)(`Get productFieldsUs details...`);
|
|
125
|
+
const productFieldsUs = await getProductFields(topicModelWithFields, catalogId, defaultEnvironmentLocaleCode, "PROFESSIONAL_US");
|
|
126
|
+
(0, logs_1.log)(`Get productFieldsChina details...`);
|
|
127
|
+
const productFieldsChina = await getProductFields(topicModelWithFields, catalogId, defaultEnvironmentLocaleCode);
|
|
124
128
|
(0, logs_1.log)(`Get autodescription details...`);
|
|
125
129
|
const autodescription = await getModelAutodescription(productLine.code);
|
|
126
130
|
const record = {
|
|
@@ -136,11 +140,12 @@ const getObject = async (topicModel) => {
|
|
|
136
140
|
thumbnailImgix,
|
|
137
141
|
productFieldFilter: topicModelWithFields?.fields?.productFieldFilter?.[defaultEnvironmentLocaleCode] || "",
|
|
138
142
|
productFields,
|
|
143
|
+
productFieldsUs,
|
|
144
|
+
productFieldsChina,
|
|
139
145
|
productLine,
|
|
140
146
|
catalogs,
|
|
141
147
|
catalog,
|
|
142
148
|
subFamily,
|
|
143
|
-
colors,
|
|
144
149
|
designer,
|
|
145
150
|
isNew: topicModelWithFields?.fields?.isNew || false,
|
|
146
151
|
priority: topicModelWithFields?.fields?.priority?.[defaultEnvironmentLocaleCode] ||
|
|
@@ -17,7 +17,7 @@ const products_1 = require("../../algolia/products");
|
|
|
17
17
|
const designers_1 = require("./designers");
|
|
18
18
|
const notifications_1 = require("../../libs/notifications");
|
|
19
19
|
const PIM_DUPLICATE_SEPARATOR = "~";
|
|
20
|
-
const S3_PIM_PAYLOAD_PATH = `pim/payload/`;
|
|
20
|
+
const S3_PIM_PAYLOAD_PATH = `pim/payload/${process.env.FPI_CTF_ENVIRONMENT || ""}/`;
|
|
21
21
|
const isTermsToAdd = async (productDetails, catalog) => {
|
|
22
22
|
if (!productDetails.code.includes(PIM_DUPLICATE_SEPARATOR)) {
|
|
23
23
|
return false;
|
|
@@ -1528,7 +1528,7 @@ const generateTechSpecPdf = async (topicProductId, country = "global", locale =
|
|
|
1528
1528
|
}
|
|
1529
1529
|
footerBaseUrl = footerBaseUrl.replace(/\/?(\?|#|$)/, "/$1");
|
|
1530
1530
|
const layoutUrl = `${baseUrl}${locale}/${country}/tech-spec/${pageSlug}/v-${version}/`;
|
|
1531
|
-
const pdpSiteUrl = `${footerBaseUrl}${locale}/${country}/product/${pageSlug}`.replace(/\/?(\?|#|$)/, "/$1");
|
|
1531
|
+
const pdpSiteUrl = `${footerBaseUrl}${locale}/${country}/product/${encodeURIComponent(pageSlug)}`.replace(/\/?(\?|#|$)/, "/$1");
|
|
1532
1532
|
(0, logs_1.log)(`pdpSiteUrl: ${pdpSiteUrl}`);
|
|
1533
1533
|
const contents = {
|
|
1534
1534
|
footer: {
|
|
@@ -1539,6 +1539,12 @@ const generateTechSpecPdf = async (topicProductId, country = "global", locale =
|
|
|
1539
1539
|
mail: topicCatalogIds.includes("OUTDOOR")
|
|
1540
1540
|
? "flos.outdoor@flos.com"
|
|
1541
1541
|
: "info@flos.com",
|
|
1542
|
+
site: {
|
|
1543
|
+
url: country === "cn"
|
|
1544
|
+
? "https://www.flos.cn/zh/cn/"
|
|
1545
|
+
: "https://professional.flos.com/en/global/",
|
|
1546
|
+
label: country === "cn" ? "www.flos.cn" : "professional.flos.com",
|
|
1547
|
+
},
|
|
1542
1548
|
},
|
|
1543
1549
|
};
|
|
1544
1550
|
if (logs_1.serverUtils) {
|