pim-import 2.78.2 → 2.79.1

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.
@@ -265,6 +265,13 @@
265
265
  "dictionary": "",
266
266
  "type": "number"
267
267
  },
268
+ {
269
+ "key": "length_us",
270
+ "parent": "physical",
271
+ "icon": false,
272
+ "dictionary": "",
273
+ "type": "number"
274
+ },
268
275
  {
269
276
  "key": "netWeight",
270
277
  "parent": "logistic",
@@ -475,6 +482,13 @@
475
482
  "dictionary": "",
476
483
  "type": "number"
477
484
  },
485
+ {
486
+ "key": "vac",
487
+ "parent": "electrical",
488
+ "icon": false,
489
+ "dictionary": "",
490
+ "type": "string"
491
+ },
478
492
  {
479
493
  "key": "vdc",
480
494
  "parent": "electrical",
@@ -783,6 +797,13 @@
783
797
  "dictionary": "",
784
798
  "type": "number"
785
799
  },
800
+ {
801
+ "key": "rgGamutIndex",
802
+ "parent": "photomestric",
803
+ "icon": false,
804
+ "dictionary": "",
805
+ "type": "number"
806
+ },
786
807
  {
787
808
  "key": "transversalTilting",
788
809
  "parent": "physical",
@@ -838,5 +859,229 @@
838
859
  "icon": false,
839
860
  "dictionary": "DTernaryFlag",
840
861
  "type": "object"
862
+ },
863
+ {
864
+ "key": "priceLists",
865
+ "parent": "",
866
+ "icon": false,
867
+ "dictionary": "DPriceList",
868
+ "type": "array"
869
+ },
870
+ {
871
+ "key": "productionSite",
872
+ "parent": "",
873
+ "icon": false,
874
+ "dictionary": "DProductionSite",
875
+ "type": "object"
876
+ },
877
+ {
878
+ "key": "customProduct",
879
+ "parent": "",
880
+ "icon": false,
881
+ "dictionary": "DTernaryFlag",
882
+ "type": "object"
883
+ },
884
+ {
885
+ "key": "bucketColours",
886
+ "parent": "",
887
+ "icon": true,
888
+ "dictionary": "DWebColour",
889
+ "type": "array"
890
+ },
891
+ {
892
+ "key": "quickDelivery",
893
+ "parent": "",
894
+ "icon": false,
895
+ "dictionary": "DTernaryFlag",
896
+ "type": "object"
897
+ },
898
+ {
899
+ "key": "reflectorFinish",
900
+ "parent": "optical",
901
+ "icon": false,
902
+ "dictionary": "DReflectorFinish",
903
+ "type": "object"
904
+ },
905
+ {
906
+ "key": "screenFinish",
907
+ "parent": "optical",
908
+ "icon": false,
909
+ "dictionary": "",
910
+ "type": "string"
911
+ },
912
+ {
913
+ "key": "cutOff",
914
+ "parent": "electrical",
915
+ "icon": false,
916
+ "dictionary": "",
917
+ "type": "boolean"
918
+ },
919
+ {
920
+ "key": "emergencyLightingFlux",
921
+ "parent": "electrical",
922
+ "icon": false,
923
+ "dictionary": "",
924
+ "type": "number"
925
+ },
926
+ {
927
+ "key": "lightSourceIncluded",
928
+ "parent": "electrical",
929
+ "icon": false,
930
+ "dictionary": "",
931
+ "type": "string"
932
+ },
933
+ {
934
+ "key": "phases",
935
+ "parent": "electrical",
936
+ "icon": false,
937
+ "dictionary": "DPhase",
938
+ "type": "array"
939
+ },
940
+ {
941
+ "key": "maximumWattage",
942
+ "parent": "electrical",
943
+ "icon": false,
944
+ "dictionary": "",
945
+ "type": "number"
946
+ },
947
+ {
948
+ "key": "driverInputVoltage",
949
+ "parent": "electrical",
950
+ "icon": false,
951
+ "dictionary": "",
952
+ "type": "string"
953
+ },
954
+ {
955
+ "key": "driverOutputVoltage",
956
+ "parent": "electrical",
957
+ "icon": false,
958
+ "dictionary": "",
959
+ "type": "string"
960
+ },
961
+ {
962
+ "key": "lor",
963
+ "parent": "photometric",
964
+ "icon": false,
965
+ "dictionary": "",
966
+ "type": "string"
967
+ },
968
+ {
969
+ "key": "rgGamutIndex",
970
+ "parent": "photometric",
971
+ "icon": false,
972
+ "dictionary": "",
973
+ "type": "number"
974
+ },
975
+ {
976
+ "key": "suspensionType",
977
+ "parent": "physical",
978
+ "icon": false,
979
+ "dictionary": "DSuspensionType",
980
+ "type": "object"
981
+ },
982
+ {
983
+ "key": "constructionMaterial",
984
+ "parent": "physical",
985
+ "icon": false,
986
+ "dictionary": "",
987
+ "type": "string"
988
+ },
989
+ {
990
+ "key": "width",
991
+ "parent": "physical",
992
+ "icon": false,
993
+ "dictionary": "",
994
+ "type": "number"
995
+ },
996
+ {
997
+ "key": "width_us",
998
+ "parent": "physical",
999
+ "icon": false,
1000
+ "dictionary": "",
1001
+ "type": "number"
1002
+ },
1003
+ {
1004
+ "key": "height",
1005
+ "parent": "physical",
1006
+ "icon": false,
1007
+ "dictionary": "",
1008
+ "type": "number"
1009
+ },
1010
+ {
1011
+ "key": "height_us",
1012
+ "parent": "physical",
1013
+ "icon": false,
1014
+ "dictionary": "",
1015
+ "type": "number"
1016
+ },
1017
+ {
1018
+ "key": "cableIngress",
1019
+ "parent": "physical",
1020
+ "icon": false,
1021
+ "dictionary": "DCableIngress",
1022
+ "type": "object"
1023
+ },
1024
+ {
1025
+ "key": "cordsColour",
1026
+ "parent": "physical",
1027
+ "icon": false,
1028
+ "dictionary": "DWebColour",
1029
+ "type": "array"
1030
+ },
1031
+ {
1032
+ "key": "canopyColor",
1033
+ "parent": "physical",
1034
+ "icon": false,
1035
+ "dictionary": "DWebColour",
1036
+ "type": "object"
1037
+ },
1038
+ {
1039
+ "key": "shippingPkgQty",
1040
+ "parent": "logistic",
1041
+ "icon": false,
1042
+ "dictionary": "",
1043
+ "type": "string"
1044
+ },
1045
+ {
1046
+ "key": "pkgRefCode",
1047
+ "parent": "logistic",
1048
+ "icon": false,
1049
+ "dictionary": "",
1050
+ "type": "string"
1051
+ },
1052
+ {
1053
+ "key": "available",
1054
+ "parent": "logistic",
1055
+ "icon": false,
1056
+ "dictionary": "DTernaryFlag",
1057
+ "type": "object"
1058
+ },
1059
+ {
1060
+ "key": "production",
1061
+ "parent": "logistic",
1062
+ "icon": false,
1063
+ "dictionary": "DProduction",
1064
+ "type": "object"
1065
+ },
1066
+ {
1067
+ "key": "euRule",
1068
+ "parent": "certification",
1069
+ "icon": false,
1070
+ "dictionary": "",
1071
+ "type": "string"
1072
+ },
1073
+ {
1074
+ "key": "lightObjMinDist",
1075
+ "parent": "marking",
1076
+ "icon": false,
1077
+ "dictionary": "",
1078
+ "type": "number"
1079
+ },
1080
+ {
1081
+ "key": "spareParts",
1082
+ "parent": "DTernaryFlag",
1083
+ "icon": false,
1084
+ "dictionary": "",
1085
+ "type": "object"
841
1086
  }
842
1087
  ]
@@ -5,9 +5,6 @@ import {
5
5
  ProductFieldsRequiredData,
6
6
  } from "../../types";
7
7
  import {
8
- getEnvironment,
9
- getEnvironmentDefaultLocaleCode,
10
- getEntryByID,
11
8
  createEntryWithId,
12
9
  updateEntry,
13
10
  getEntryByCode,
@@ -20,6 +17,7 @@ import {
20
17
  checkConfig as checkS3Config,
21
18
  upload as uploadToS3,
22
19
  getFileFromS3,
20
+ saveJsonToS3,
23
21
  } from "../../libs/s3";
24
22
  import type {
25
23
  CreateEntryProps,
@@ -53,69 +51,6 @@ type DictionaryRecord = {
53
51
  otherData: ObjectPartial;
54
52
  };
55
53
 
56
- interface DictionaryContentfulData {
57
- [key: string]: DictionaryRecord[];
58
- }
59
-
60
- const updateContentfulDictionaryData = async (
61
- data: DictionaryContentfulData,
62
- clearBefore: boolean = false
63
- ) => {
64
- log(`updateContentfulDictionaryData - Start`, "INFO");
65
-
66
- const environment = await getEnvironment();
67
- const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
68
-
69
- // Check if entry exists
70
- log(`Check if dictionary entry exists`);
71
- let entry = await getEntryByID(entryId, contentTypeId);
72
-
73
- const entryData: CreateEntryProps = {
74
- fields: {},
75
- };
76
-
77
- if (entry) {
78
- // Entry exists. Update entry data
79
- log(`Dictionary entry exists. Update entry data`);
80
- if (
81
- clearBefore &&
82
- Object.entries(entry.fields.json[defaultEnvironmentLocaleCode]).length
83
- ) {
84
- entry.fields.json[defaultEnvironmentLocaleCode] = {};
85
- entry = await entry.update();
86
- }
87
-
88
- entryData.fields = entry?.fields || {};
89
-
90
- entryData.fields = await addFieldValue(
91
- entryData,
92
- "internalName",
93
- "DictionaryProductFields"
94
- );
95
- entryData.fields = await addFieldValue(entryData, "json", data);
96
- entry = await entry.update();
97
- entry = await entry.publish();
98
- } else {
99
- // Entry not exists. Create new entry with data
100
- log(`Entry not exists. Create new entry with data`);
101
-
102
- entryData.fields = await addFieldValue(
103
- entryData,
104
- "internalName",
105
- "DictionaryProductFields"
106
- );
107
- entryData.fields = await addFieldValue(entryData, "json", data);
108
- entry = await environment.createEntryWithId(
109
- contentTypeId,
110
- entryId,
111
- entryData
112
- );
113
- entry = await entry.publish();
114
- }
115
-
116
- log(`updateContentfulDictionaryData - Completed`);
117
- };
118
-
119
54
  const getRequiredDictionaryDataWithIcons = (): ProductFieldsRequiredData[] => {
120
55
  return productFieldsRequiredData.filter((field) => field.icon);
121
56
  };
@@ -174,17 +109,13 @@ export const importDictionaryIcons = async (
174
109
  checkS3Config();
175
110
 
176
111
  log("importDictionaryIcons - Start", "INFO");
177
- log("Get dictionary Contentful entry");
178
- const defaultEnvironmentLocaleCode =
179
- await getEnvironmentDefaultLocaleCode();
180
- const entry = await getEntryByID(entryId, contentTypeId);
112
+ log("Get S3 JSON dictionary file");
181
113
 
182
- if (!entry) {
183
- throw new Error("Dictionary entry not exists.");
114
+ const data = await getFileFromS3(`dictionary.json`);
115
+ if (!data) {
116
+ throw new Error("Dictionary JSON file not found on S3.");
184
117
  }
185
118
 
186
- const data = entry.fields.json[defaultEnvironmentLocaleCode];
187
-
188
119
  const requiredDictionaryDataWithIcons =
189
120
  getRequiredDictionaryDataWithIcons();
190
121
  for (const reqField of requiredDictionaryDataWithIcons) {
@@ -224,9 +155,9 @@ export const importDictionaryIcons = async (
224
155
  log(`No certifications found into contenful dictionary`);
225
156
  }
226
157
 
227
- // Updating Contentful dictionary entry data
228
- log("Updating Contentful dictionary entry data");
229
- await updateContentfulDictionaryData(data, true);
158
+ // Updating S3 dictionary entry data
159
+ log("Updating S3 dictionary entry data");
160
+ await saveJsonToS3(data, "dictionary.json");
230
161
  log("importDictionaryIcons - Completed");
231
162
 
232
163
  return { completed: true };
@@ -327,7 +258,9 @@ export const importDictionaryFields = async (
327
258
  if (Object.entries(data).length) {
328
259
  // Create/Update Contentful entry
329
260
  log("Create/Update Contentful entry");
330
- await updateContentfulDictionaryData(data, offset === 0);
261
+ // await updateContentfulDictionaryData(data, offset === 0);
262
+
263
+ await saveJsonToS3(data, "dictionary.json", "");
331
264
  } else {
332
265
  log("no matches found", "ERROR");
333
266
  }
@@ -58,7 +58,11 @@ import {
58
58
  import { getAudit, getProductDetails } from "../endpoints";
59
59
  import { getCategoryTopicCode } from "./catalogs";
60
60
  import productFieldsRequiredData from "../data/productFields.json";
61
- import { getDefaultWrapperImgixAttributesByPimUrl } from "../../libs/imgix";
61
+ import {
62
+ getDefaultWrapperImgixAttributesByPimUrl,
63
+ getImgixPimUrlByOriginPath,
64
+ getOriginPathByPimUrl,
65
+ } from "../../libs/imgix";
62
66
  import { generatePDFByUrl } from "../../libs/puppeteer";
63
67
 
64
68
  export type AvailableProductStatus =
@@ -843,15 +847,34 @@ const getProductData = async (
843
847
 
844
848
  // THUMB
845
849
  if (pimAssetThumb?.url) {
850
+ log(`Set THUMB`);
846
851
  // THUMB WRAPPER IMGIX
847
852
  const wrapperImgixID = pimAssetThumb.md5;
848
853
  let wrapperImgix = await getEntryByID(
849
854
  wrapperImgixID,
850
855
  "wrapperImgix",
851
- "sys"
856
+ "sys,fields"
852
857
  );
853
858
  if (wrapperImgix) {
854
859
  log(`wrapperImgix with id ${wrapperImgixID} already exists`);
860
+ const imgixBasename = basename(
861
+ wrapperImgix.fields.imgixData[defaultEnvironmentLocaleCode].url
862
+ );
863
+ const pimBasename = basename(pimAssetThumb.url);
864
+ if (imgixBasename !== pimBasename) {
865
+ log(`Update img url from ${imgixBasename} to ${pimBasename}`);
866
+ const newImgixUrl = getImgixPimUrlByOriginPath(
867
+ getOriginPathByPimUrl(pimAssetThumb.url)
868
+ );
869
+ wrapperImgix.fields.imgixData[defaultEnvironmentLocaleCode].url =
870
+ newImgixUrl;
871
+ wrapperImgix = await wrapperImgix.update();
872
+ if (wrapperImgix.isPublished()) {
873
+ wrapperImgix = await wrapperImgix.publish();
874
+ }
875
+
876
+ log(`The new imgix url is: ${newImgixUrl}`);
877
+ }
855
878
  } else {
856
879
  log(
857
880
  `Add thumbnail imgix wrapper with id ${wrapperImgixID} to Contentful`
@@ -0,0 +1,32 @@
1
+ export { reportError } from "./libs/sentry";
2
+ export { init as initPim } from "./pim/config";
3
+ export { init as initContentful, initBaseEntries, deletePages, deleteEntries, getEntryByID, getTopicPage, } from "./libs/contentful";
4
+ export { init as initS3, upload as uploadS3, saveJsonToS3, getFileFromS3, savePDFToS3, } from "./libs/s3";
5
+ export { importDictionaryFields, importDictionaryIcons, importDictionaryProductLine, importDictionaryProductSubLine, } from "./pim/methods/dictionary";
6
+ export { importCategories } from "./pim/methods/catalogs";
7
+ export { importLatestProducts } from "./pim/methods/latestProducts";
8
+ export { dailyProductsUpdate } from "./pim/methods/dailyProductsUpdate";
9
+ export { importModels } from "./pim/methods/models";
10
+ export { importSubModels } from "./pim/methods/submodels";
11
+ export { importSubFamilies } from "./pim/methods/subfamilies";
12
+ export { importFamilies } from "./pim/methods/families";
13
+ export { importProductByCode, setProductsRelationships, setProductRelationships, getAllProductEntriesByCatalog, audit, generateTechSpecPdf, setProductsAutodescription, getProductAutodescription, setProductAutodescriptionByTopicId, removeProductFromColorVariantsByProductLine, removeAllProductModelProductRelations, } from "./pim/methods/products";
14
+ export { resetIndexSettings } from "./algolia/config";
15
+ export { reindexFamilies, reindexFamily, removeFamilyObject, } from "./algolia/families";
16
+ export { pipedreamReindex } from "./algolia/pipedreamReindex";
17
+ export { reindexSubFamilies, reindexSubFamily, removeSubFamilyObject, } from "./algolia/subFamilies";
18
+ export { reindexProduct, reindexProducts, removeProductObject, } from "./algolia/products";
19
+ export { reindexSubModel, reindexSubModels, removeSubModelObject, } from "./algolia/subModels";
20
+ export { reindexModel, reindexModels, removeModelObject, } from "./algolia/models";
21
+ export { reindexDownload, reindexDownloads, removeDownloadObject, } from "./algolia/downloads";
22
+ export { reindexProject, reindexProjects, removeProjectObject, } from "./algolia/projects";
23
+ export { reindexStory, reindexStories, removeStoryObject, } from "./algolia/stories";
24
+ export { reindexPressReview, reindexPressReviews, removePressReviewObject, } from "./algolia/pressReview";
25
+ export { reindexPressRelease, reindexPressReleases, removePressReleaseObject, } from "./algolia/pressRelease";
26
+ export { reindexPost, reindexPosts, removePostObject } from "./algolia/news";
27
+ export { importDownloads } from "./downloads/import";
28
+ export { getLocalISOTime } from "./utils";
29
+ export { getStaticDailyProducts } from "./pim/endpoints";
30
+ export { log, setLogId, setLogOptions } from "./libs/logs";
31
+ export { removeRecordsByStatus } from "./algolia/clean";
32
+ export { generatePDFByUrl } from "./libs/puppeteer";
@@ -7,6 +7,7 @@ export declare const getNameByPimUrl: (pimImgUrl: string) => string;
7
7
  export declare const getContentTypeByPimUrl: (pimImgUrl: string) => string;
8
8
  export declare const getImageAttributesByOriginPath: (originPath: string, sourceId: string) => Promise<{}>;
9
9
  export declare const getImageAttributesByPimUrl: (pimUrl: string) => Promise<ImgixAttributes>;
10
+ export declare const getImgixPimUrlByOriginPath: (originPath: string) => string;
10
11
  export declare const getWrapperImgixAttributesByPimUrl: (pimUrl: string) => Promise<ImgixData | null>;
11
12
  export declare const getDefaultWrapperImgixAttributesByPimUrl: (pimUrl: string) => ImgixData;
12
13
  export declare const getWrapperImgixFields: (wrapperImgixId: string) => Promise<{}>;
@@ -2,7 +2,7 @@ import { ObjectPartial } from "../types";
2
2
  export declare type LogLevels = "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL";
3
3
  export declare const logStatus = true;
4
4
  export declare const logLevelToHide: LogLevels[];
5
- export declare const getLogger: () => any;
5
+ export declare const getLogger: () => null;
6
6
  export declare const setLogId: (id: string) => void;
7
7
  export declare const setLogOptions: (opts: ObjectPartial) => void;
8
8
  export declare const log: (message: string, level?: LogLevels) => void;