pim-import 5.9.0 → 5.11.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.
|
@@ -20,6 +20,7 @@ export type AlgoliaFamilyRecord = {
|
|
|
20
20
|
categories: TopicDetailsResponse[];
|
|
21
21
|
productFields: TopicProductFieldsResponse[];
|
|
22
22
|
productFieldsUs: TopicProductFieldsResponse[];
|
|
23
|
+
productFieldsCn: TopicProductFieldsResponse[];
|
|
23
24
|
isNew: boolean;
|
|
24
25
|
priority: number;
|
|
25
26
|
destinations?: string[];
|
|
@@ -53,6 +54,7 @@ export declare const reindexFamily: (topicFamilyEntryId: string) => Promise<{
|
|
|
53
54
|
categories: TopicDetailsResponse[];
|
|
54
55
|
productFields: TopicProductFieldsResponse[];
|
|
55
56
|
productFieldsUs: TopicProductFieldsResponse[];
|
|
57
|
+
productFieldsCn: TopicProductFieldsResponse[];
|
|
56
58
|
isNew: boolean;
|
|
57
59
|
priority: number;
|
|
58
60
|
destinations?: string[] | undefined;
|
package/dist/algolia/families.js
CHANGED
|
@@ -156,6 +156,8 @@ const getObject = async (topicFamily) => {
|
|
|
156
156
|
const productFields = await getProductFields(topicFamily);
|
|
157
157
|
(0, logs_1.log)(`Get productFieldsUs details...`);
|
|
158
158
|
const productFieldsUs = await getProductFields(topicFamily, "PROFESSIONAL_US");
|
|
159
|
+
(0, logs_1.log)(`Get productFieldsCn details...`);
|
|
160
|
+
const productFieldsCn = await getProductFields(topicFamily, "PROFESSIONAL_CHINA");
|
|
159
161
|
const isNew = topicFamilyWithFields?.fields?.isNew?.[defaultEnvironmentLocaleCode] ||
|
|
160
162
|
false;
|
|
161
163
|
(0, logs_1.log)(`Get thumbnail imgix details...`);
|
|
@@ -191,6 +193,7 @@ const getObject = async (topicFamily) => {
|
|
|
191
193
|
categories,
|
|
192
194
|
productFields,
|
|
193
195
|
productFieldsUs,
|
|
196
|
+
productFieldsCn,
|
|
194
197
|
priority,
|
|
195
198
|
isNew,
|
|
196
199
|
destinations: topicFamilyWithFields?.fields?.destinations?.[defaultEnvironmentLocaleCode] || [],
|
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] ||
|
|
@@ -27,6 +27,7 @@ export declare const reindexSubFamily: (topicSubFamilyEntryId: string) => Promis
|
|
|
27
27
|
categories: import("../types").TopicDetailsResponse[];
|
|
28
28
|
productFields: import("../types").TopicProductFieldsResponse[];
|
|
29
29
|
productFieldsUs: import("../types").TopicProductFieldsResponse[];
|
|
30
|
+
productFieldsCn: import("../types").TopicProductFieldsResponse[];
|
|
30
31
|
isNew: boolean;
|
|
31
32
|
priority: number;
|
|
32
33
|
destinations?: string[] | undefined;
|
|
@@ -75,6 +75,7 @@ const getProductFields = async (topicSubFamily, destination = "PROFESSIONAL_GLOB
|
|
|
75
75
|
productFields.totalProducts = {};
|
|
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
|
+
(0, logs_1.log)(`Total products for destination ${destination}: ${productFields.totalProducts[destination]}`);
|
|
78
79
|
}
|
|
79
80
|
productFields.certifiedFilters = [];
|
|
80
81
|
for (const topicProduct of topicProductEntries) {
|
|
@@ -163,6 +164,8 @@ const getObject = async (topicSubFamily) => {
|
|
|
163
164
|
const productFields = await getProductFields(topicSubFamilyWithFields);
|
|
164
165
|
(0, logs_1.log)(`Get productFieldsUs details...`);
|
|
165
166
|
const productFieldsUs = await getProductFields(topicSubFamilyWithFields, "PROFESSIONAL_US");
|
|
167
|
+
(0, logs_1.log)(`Get productFieldsCn details...`);
|
|
168
|
+
const productFieldsCn = await getProductFields(topicSubFamilyWithFields, "PROFESSIONAL_CHINA");
|
|
166
169
|
const isNew = topicSubFamilyWithFields?.fields?.isNew?.[defaultEnvironmentLocaleCode] ||
|
|
167
170
|
false;
|
|
168
171
|
(0, logs_1.log)(`Get thumbnail imgix details...`);
|
|
@@ -229,6 +232,7 @@ const getObject = async (topicSubFamily) => {
|
|
|
229
232
|
parentFamily,
|
|
230
233
|
productFields,
|
|
231
234
|
productFieldsUs,
|
|
235
|
+
productFieldsCn,
|
|
232
236
|
priority,
|
|
233
237
|
isNew,
|
|
234
238
|
destinations: topicSubFamilyWithFields?.fields?.destinations?.[defaultEnvironmentLocaleCode] || [],
|