pim-import 4.30.3 → 4.30.5

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.
Files changed (124) hide show
  1. package/dist/algolia/clean.js +10 -10
  2. package/dist/algolia/clean.js.map +1 -1
  3. package/dist/algolia/config.js +9 -9
  4. package/dist/algolia/config.js.map +1 -1
  5. package/dist/algolia/downloads.js +42 -43
  6. package/dist/algolia/downloads.js.map +1 -1
  7. package/dist/algolia/families.js +71 -73
  8. package/dist/algolia/families.js.map +1 -1
  9. package/dist/algolia/models.js +49 -50
  10. package/dist/algolia/models.js.map +1 -1
  11. package/dist/algolia/news.js +40 -41
  12. package/dist/algolia/news.js.map +1 -1
  13. package/dist/algolia/pressRelease.js +37 -38
  14. package/dist/algolia/pressRelease.js.map +1 -1
  15. package/dist/algolia/pressReview.js +35 -36
  16. package/dist/algolia/pressReview.js.map +1 -1
  17. package/dist/algolia/products.js +84 -85
  18. package/dist/algolia/products.js.map +1 -1
  19. package/dist/algolia/projects.js +44 -45
  20. package/dist/algolia/projects.js.map +1 -1
  21. package/dist/algolia/stories.js +53 -54
  22. package/dist/algolia/stories.js.map +1 -1
  23. package/dist/algolia/subFamilies.js +78 -80
  24. package/dist/algolia/subFamilies.js.map +1 -1
  25. package/dist/algolia/subModels.js +48 -49
  26. package/dist/algolia/subModels.js.map +1 -1
  27. package/dist/downloads/classes/manageEntry.js +3 -3
  28. package/dist/downloads/classes/manageEntry.js.map +1 -1
  29. package/dist/downloads/import.js +27 -27
  30. package/dist/downloads/import.js.map +1 -1
  31. package/dist/libs/contentful-cda.js +37 -44
  32. package/dist/libs/contentful-cda.js.map +1 -1
  33. package/dist/libs/contentful.js +131 -130
  34. package/dist/libs/contentful.js.map +1 -1
  35. package/dist/libs/imgix.js +23 -23
  36. package/dist/libs/imgix.js.map +1 -1
  37. package/dist/libs/logs.js +4 -4
  38. package/dist/libs/logs.js.map +1 -1
  39. package/dist/libs/pdf.js +5 -5
  40. package/dist/libs/pdf.js.map +1 -1
  41. package/dist/libs/s3.js +28 -28
  42. package/dist/libs/s3.js.map +1 -1
  43. package/dist/libs/sentry.js +6 -2
  44. package/dist/libs/sentry.js.map +1 -1
  45. package/dist/pim/config.js +3 -3
  46. package/dist/pim/config.js.map +1 -1
  47. package/dist/pim/endpoints.js +39 -39
  48. package/dist/pim/endpoints.js.map +1 -1
  49. package/dist/pim/methods/bulkPublish.js +10 -10
  50. package/dist/pim/methods/bulkPublish.js.map +1 -1
  51. package/dist/pim/methods/catalogs.js +62 -62
  52. package/dist/pim/methods/catalogs.js.map +1 -1
  53. package/dist/pim/methods/designers.js +19 -19
  54. package/dist/pim/methods/designers.js.map +1 -1
  55. package/dist/pim/methods/dictionary.js +66 -66
  56. package/dist/pim/methods/dictionary.js.map +1 -1
  57. package/dist/pim/methods/families.js +37 -37
  58. package/dist/pim/methods/families.js.map +1 -1
  59. package/dist/pim/methods/latestProducts.js +7 -7
  60. package/dist/pim/methods/latestProducts.js.map +1 -1
  61. package/dist/pim/methods/models.js +47 -47
  62. package/dist/pim/methods/models.js.map +1 -1
  63. package/dist/pim/methods/pages/catalogs.js +6 -6
  64. package/dist/pim/methods/pages/catalogs.js.map +1 -1
  65. package/dist/pim/methods/pages/families.js +7 -7
  66. package/dist/pim/methods/pages/families.js.map +1 -1
  67. package/dist/pim/methods/pages/subfamilies.js +11 -11
  68. package/dist/pim/methods/pages/subfamilies.js.map +1 -1
  69. package/dist/pim/methods/products.js +426 -426
  70. package/dist/pim/methods/products.js.map +1 -1
  71. package/dist/pim/methods/subfamilies.js +107 -107
  72. package/dist/pim/methods/subfamilies.js.map +1 -1
  73. package/dist/pim/methods/submodels.js +37 -37
  74. package/dist/pim/methods/submodels.js.map +1 -1
  75. package/dist/pim/request.js +2 -2
  76. package/dist/pim/request.js.map +1 -1
  77. package/dist/utils.js +23 -23
  78. package/dist/utils.js.map +1 -1
  79. package/package.json +4 -4
  80. package/src/algolia/downloads.ts +1 -2
  81. package/src/algolia/families.ts +2 -4
  82. package/src/algolia/models.ts +1 -2
  83. package/src/algolia/news.ts +1 -2
  84. package/src/algolia/pressRelease.ts +1 -2
  85. package/src/algolia/pressReview.ts +1 -2
  86. package/src/algolia/products.ts +1 -2
  87. package/src/algolia/projects.ts +1 -2
  88. package/src/algolia/stories.ts +1 -2
  89. package/src/algolia/subFamilies.ts +2 -4
  90. package/src/algolia/subModels.ts +1 -2
  91. package/src/downloads/import.ts +1 -1
  92. package/src/libs/contentful-cda.ts +7 -10
  93. package/src/libs/contentful.ts +8 -7
  94. package/src/libs/s3.ts +2 -2
  95. package/src/pim/endpoints.ts +8 -8
  96. package/src/pim/methods/bulkPublish.ts +1 -1
  97. package/src/pim/methods/dictionary.ts +1 -1
  98. package/src/pim/methods/families.ts +1 -1
  99. package/src/pim/methods/products.ts +7 -7
  100. package/types/algolia/clean.d.ts +1 -1
  101. package/types/algolia/config.d.ts +1 -1
  102. package/types/algolia/downloads.d.ts +1 -1
  103. package/types/algolia/families.d.ts +3 -3
  104. package/types/algolia/models.d.ts +1 -1
  105. package/types/algolia/news.d.ts +1 -1
  106. package/types/algolia/pressRelease.d.ts +1 -1
  107. package/types/algolia/pressReview.d.ts +1 -1
  108. package/types/algolia/products.d.ts +2 -2
  109. package/types/algolia/projects.d.ts +1 -1
  110. package/types/algolia/stories.d.ts +1 -1
  111. package/types/algolia/subFamilies.d.ts +1 -1
  112. package/types/algolia/subModels.d.ts +1 -1
  113. package/types/libs/contentful-cda.d.ts +2 -2
  114. package/types/libs/contentful.d.ts +10 -10
  115. package/types/libs/logs.d.ts +1 -1
  116. package/types/libs/pdf.d.ts +1 -1
  117. package/types/libs/s3.d.ts +1 -1
  118. package/types/pim/config.d.ts +1 -1
  119. package/types/pim/endpoints.d.ts +3 -3
  120. package/types/pim/methods/designers.d.ts +1 -1
  121. package/types/pim/methods/products.d.ts +3 -3
  122. package/types/resources/Audit.d.ts +1 -1
  123. package/types/types.d.ts +21 -21
  124. package/types/utils.d.ts +1 -1
@@ -23,7 +23,7 @@ exports.cfLocales = [
23
23
  ];
24
24
  const checkConfig = (skipInit = false) => {
25
25
  if (!skipInit) {
26
- exports.init();
26
+ (0, exports.init)();
27
27
  }
28
28
  const message = 'You must call "init" before using any Contentful method';
29
29
  if (!exports.config.accessToken) {
@@ -47,7 +47,7 @@ const init = (opts) => {
47
47
  };
48
48
  }
49
49
  exports.config = { ...opts };
50
- exports.checkConfig(true);
50
+ (0, exports.checkConfig)(true);
51
51
  };
52
52
  exports.init = init;
53
53
  const getConfig = () => {
@@ -55,11 +55,11 @@ const getConfig = () => {
55
55
  };
56
56
  exports.getConfig = getConfig;
57
57
  const getEnvironment = async () => {
58
- exports.checkConfig();
58
+ (0, exports.checkConfig)();
59
59
  if (exports.environment) {
60
60
  return new Promise((resolve) => resolve(exports.environment));
61
61
  }
62
- const client = contentful_management_1.createClient({
62
+ const client = (0, contentful_management_1.createClient)({
63
63
  accessToken: exports.config.accessToken,
64
64
  });
65
65
  const space = await client.getSpace(exports.config.spaceId);
@@ -75,11 +75,11 @@ const getEnvironment = async () => {
75
75
  };
76
76
  exports.getEnvironment = getEnvironment;
77
77
  const getEnvironmentDefaultLocale = async () => {
78
- exports.checkConfig();
78
+ (0, exports.checkConfig)();
79
79
  if (exports.defaultEnvironmentLocale) {
80
80
  return new Promise((resolve) => resolve(exports.defaultEnvironmentLocale));
81
81
  }
82
- const env = await exports.getEnvironment();
82
+ const env = await (0, exports.getEnvironment)();
83
83
  const environmentLocales = await env.getLocales();
84
84
  if (!environmentLocales) {
85
85
  throw new Error("Environment locales not found");
@@ -95,35 +95,35 @@ const getEnvironmentDefaultLocale = async () => {
95
95
  };
96
96
  exports.getEnvironmentDefaultLocale = getEnvironmentDefaultLocale;
97
97
  const getClient = async () => {
98
- return await exports.getEnvironment();
98
+ return await (0, exports.getEnvironment)();
99
99
  };
100
100
  exports.getClient = getClient;
101
101
  const getEnvironmentDefaultLocaleCode = async () => {
102
- exports.checkConfig();
102
+ (0, exports.checkConfig)();
103
103
  if (exports.defaultEnvironmentLocaleCode) {
104
104
  return new Promise((resolve) => resolve(exports.defaultEnvironmentLocaleCode));
105
105
  }
106
- const defEnvironmentLocale = await exports.getEnvironmentDefaultLocale();
106
+ const defEnvironmentLocale = await (0, exports.getEnvironmentDefaultLocale)();
107
107
  exports.defaultEnvironmentLocaleCode = defEnvironmentLocale.code;
108
108
  return new Promise((resolve) => resolve(exports.defaultEnvironmentLocaleCode));
109
109
  };
110
110
  exports.getEnvironmentDefaultLocaleCode = getEnvironmentDefaultLocaleCode;
111
111
  const uploadFile = async (asset) => {
112
- const env = await exports.getEnvironment();
112
+ const env = await (0, exports.getEnvironment)();
113
113
  const assetRes = await env.createAsset(asset);
114
114
  return assetRes.processForAllLocales();
115
115
  };
116
116
  exports.uploadFile = uploadFile;
117
117
  const createEntryWithId = async (contentTypeId, id, data, publish = false) => {
118
- const env = await exports.getEnvironment();
118
+ const env = await (0, exports.getEnvironment)();
119
119
  const entry = await env.createEntryWithId(contentTypeId, id, data);
120
120
  if (publish) {
121
121
  try {
122
122
  return await entry.publish();
123
123
  }
124
124
  catch (err) {
125
- logs_1.log(`Cannot publish entry.`);
126
- logs_1.log(err);
125
+ (0, logs_1.log)(`Cannot publish entry.`);
126
+ (0, logs_1.log)(err);
127
127
  }
128
128
  }
129
129
  return entry;
@@ -138,16 +138,16 @@ const updateEntry = async (itemEntry, data, publish = false) => {
138
138
  entry = await itemEntry.update();
139
139
  }
140
140
  catch (err) {
141
- logs_1.log(`Cannot update entry.`);
142
- logs_1.log(err);
141
+ (0, logs_1.log)(`Cannot update entry.`);
142
+ (0, logs_1.log)(err);
143
143
  }
144
144
  if (publish) {
145
145
  try {
146
146
  return await entry.publish();
147
147
  }
148
148
  catch (err) {
149
- logs_1.log(`Cannot publish entry.`);
150
- logs_1.log(err);
149
+ (0, logs_1.log)(`Cannot publish entry.`);
150
+ (0, logs_1.log)(err);
151
151
  }
152
152
  }
153
153
  else if (entry.isPublished()) {
@@ -160,8 +160,8 @@ const updateEntry = async (itemEntry, data, publish = false) => {
160
160
  };
161
161
  exports.updateEntry = updateEntry;
162
162
  const getEntryByCode = async (code, contentTypeId, select) => {
163
- const env = await exports.getEnvironment();
164
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
163
+ const env = await (0, exports.getEnvironment)();
164
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
165
165
  const opts = {
166
166
  content_type: contentTypeId,
167
167
  "fields.code": code,
@@ -177,18 +177,18 @@ const getAllEntriesByCodes = async (codes, contentTypeId, select, filter = "fiel
177
177
  if (!codes.length) {
178
178
  return [];
179
179
  }
180
- logs_1.log(`getAllEntriesByCodes codes: ${codes.length} contentTypeId: ${contentTypeId}`);
181
- const env = await exports.getEnvironment();
182
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
180
+ (0, logs_1.log)(`getAllEntriesByCodes codes: ${codes.length} contentTypeId: ${contentTypeId}`);
181
+ const env = await (0, exports.getEnvironment)();
182
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
183
183
  let allItems = [];
184
184
  let othersPagesToFetch = false;
185
185
  let skip = 0;
186
- const limit = 50;
187
- const chunkLimit = 50;
186
+ const limit = 20;
187
+ const chunkLimit = 20;
188
188
  const filterKey = `${filter}[in]`;
189
189
  let codesChunks = [];
190
190
  if (codes.length > chunkLimit) {
191
- codesChunks = utils_1.doChunk(codes, chunkLimit);
191
+ codesChunks = (0, utils_1.doChunk)(codes, chunkLimit);
192
192
  }
193
193
  else {
194
194
  codesChunks.push(codes);
@@ -210,13 +210,14 @@ const getAllEntriesByCodes = async (codes, contentTypeId, select, filter = "fiel
210
210
  opts[otherFilter.key] = otherFilter.value;
211
211
  }
212
212
  }
213
+ console.log("opts", opts);
213
214
  const { items, total } = await env.getEntries(opts);
214
215
  allItems = [...allItems, ...(items || [])];
215
216
  if (total && allItems.length < total) {
216
217
  othersPagesToFetch = true;
217
218
  skip += limit;
218
219
  if (++count % 7 === 0) {
219
- await utils_1.sleep(200);
220
+ await (0, utils_1.sleep)(200);
220
221
  }
221
222
  }
222
223
  else {
@@ -229,8 +230,8 @@ const getAllEntriesByCodes = async (codes, contentTypeId, select, filter = "fiel
229
230
  };
230
231
  exports.getAllEntriesByCodes = getAllEntriesByCodes;
231
232
  const getAllEntries = async (contentType, select, filterKey, filterValue, limit = 50) => {
232
- const env = await exports.getEnvironment();
233
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
233
+ const env = await (0, exports.getEnvironment)();
234
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
234
235
  let allItems = [];
235
236
  let othersPagesToFetch = false;
236
237
  let skip = 0;
@@ -252,7 +253,7 @@ const getAllEntries = async (contentType, select, filterKey, filterValue, limit
252
253
  othersPagesToFetch = true;
253
254
  skip += limit;
254
255
  if (++count % 7 === 0) {
255
- await utils_1.sleep(200);
256
+ await (0, utils_1.sleep)(200);
256
257
  }
257
258
  }
258
259
  else {
@@ -263,8 +264,8 @@ const getAllEntries = async (contentType, select, filterKey, filterValue, limit
263
264
  };
264
265
  exports.getAllEntries = getAllEntries;
265
266
  const getEntryByID = async (entryID, contentTypeId, select, locale) => {
266
- const env = await exports.getEnvironment();
267
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
267
+ const env = await (0, exports.getEnvironment)();
268
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
268
269
  const opts = {
269
270
  content_type: contentTypeId,
270
271
  "sys.id": entryID,
@@ -277,11 +278,11 @@ const getEntryByID = async (entryID, contentTypeId, select, locale) => {
277
278
  };
278
279
  exports.getEntryByID = getEntryByID;
279
280
  const initBaseEntries = async () => {
280
- const defaultEnvCode = await exports.getEnvironmentDefaultLocaleCode();
281
- logs_1.log(`Check topicSite - corporate`);
282
- let siteCorporateEntry = await exports.getEntryByID("SITE_CORPORATE", "topicSite");
281
+ const defaultEnvCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
282
+ (0, logs_1.log)(`Check topicSite - corporate`);
283
+ let siteCorporateEntry = await (0, exports.getEntryByID)("SITE_CORPORATE", "topicSite");
283
284
  if (!siteCorporateEntry) {
284
- logs_1.log(`topicSite - corporate not exists, await...`);
285
+ (0, logs_1.log)(`topicSite - corporate not exists, await...`);
285
286
  const siteCorporateEntryData = {
286
287
  fields: {
287
288
  title: {},
@@ -290,17 +291,17 @@ const initBaseEntries = async () => {
290
291
  };
291
292
  siteCorporateEntryData.fields.title[defaultEnvCode] = "Corporate";
292
293
  siteCorporateEntryData.fields.code[defaultEnvCode] = "corporate";
293
- siteCorporateEntry = await exports.createEntryWithId("topicSite", "SITE_CORPORATE", siteCorporateEntryData);
294
+ siteCorporateEntry = await (0, exports.createEntryWithId)("topicSite", "SITE_CORPORATE", siteCorporateEntryData);
294
295
  siteCorporateEntry = await siteCorporateEntry.publish();
295
- logs_1.log(`topicSite - corporate created with id: ${siteCorporateEntry.sys.id}`);
296
+ (0, logs_1.log)(`topicSite - corporate created with id: ${siteCorporateEntry.sys.id}`);
296
297
  }
297
298
  else {
298
- logs_1.log(`topicSite - corporate already exists with id: ${siteCorporateEntry.sys.id}`);
299
+ (0, logs_1.log)(`topicSite - corporate already exists with id: ${siteCorporateEntry.sys.id}`);
299
300
  }
300
- logs_1.log(`Check topicSite - professional`);
301
- let siteProfessionalEntry = await exports.getEntryByID("SITE_PROFESSIONAL", "topicSite");
301
+ (0, logs_1.log)(`Check topicSite - professional`);
302
+ let siteProfessionalEntry = await (0, exports.getEntryByID)("SITE_PROFESSIONAL", "topicSite");
302
303
  if (!siteProfessionalEntry) {
303
- logs_1.log(`topicSite - professional not exists, await...`);
304
+ (0, logs_1.log)(`topicSite - professional not exists, await...`);
304
305
  const siteProfessionalEntryData = {
305
306
  fields: {
306
307
  title: {},
@@ -309,17 +310,17 @@ const initBaseEntries = async () => {
309
310
  };
310
311
  siteProfessionalEntryData.fields.title[defaultEnvCode] = "Professional";
311
312
  siteProfessionalEntryData.fields.code[defaultEnvCode] = "professional";
312
- siteProfessionalEntry = await exports.createEntryWithId("topicSite", "SITE_PROFESSIONAL", siteProfessionalEntryData);
313
+ siteProfessionalEntry = await (0, exports.createEntryWithId)("topicSite", "SITE_PROFESSIONAL", siteProfessionalEntryData);
313
314
  siteProfessionalEntry = await siteProfessionalEntry.publish();
314
- logs_1.log(`topicSite - professional created with id: ${siteProfessionalEntry.sys.id}`);
315
+ (0, logs_1.log)(`topicSite - professional created with id: ${siteProfessionalEntry.sys.id}`);
315
316
  }
316
317
  else {
317
- logs_1.log(`topicSite - professional already exists with id: ${siteProfessionalEntry.sys.id}`);
318
+ (0, logs_1.log)(`topicSite - professional already exists with id: ${siteProfessionalEntry.sys.id}`);
318
319
  }
319
- logs_1.log(`Check topicRegion - global`);
320
- let regionGlobalEntry = await exports.getEntryByID("REGION_GLOBAL", "topicRegion");
320
+ (0, logs_1.log)(`Check topicRegion - global`);
321
+ let regionGlobalEntry = await (0, exports.getEntryByID)("REGION_GLOBAL", "topicRegion");
321
322
  if (!regionGlobalEntry) {
322
- logs_1.log(`topicRegion - global not exists, await...`);
323
+ (0, logs_1.log)(`topicRegion - global not exists, await...`);
323
324
  const regionGlobalEntryData = {
324
325
  fields: {
325
326
  region: {},
@@ -337,17 +338,17 @@ const initBaseEntries = async () => {
337
338
  "fr",
338
339
  "es",
339
340
  ];
340
- regionGlobalEntry = await exports.createEntryWithId("topicRegion", "REGION_GLOBAL", regionGlobalEntryData);
341
+ regionGlobalEntry = await (0, exports.createEntryWithId)("topicRegion", "REGION_GLOBAL", regionGlobalEntryData);
341
342
  regionGlobalEntry = await regionGlobalEntry.publish();
342
- logs_1.log(`topicRegion - global created with id: ${regionGlobalEntry.sys.id}`);
343
+ (0, logs_1.log)(`topicRegion - global created with id: ${regionGlobalEntry.sys.id}`);
343
344
  }
344
345
  else {
345
- logs_1.log(`topicRegion - global already exists with id: ${regionGlobalEntry.sys.id}`);
346
+ (0, logs_1.log)(`topicRegion - global already exists with id: ${regionGlobalEntry.sys.id}`);
346
347
  }
347
- logs_1.log(`Check topicRegion - us`);
348
- let regionUsEntry = await exports.getEntryByID("REGION_US", "topicRegion");
348
+ (0, logs_1.log)(`Check topicRegion - us`);
349
+ let regionUsEntry = await (0, exports.getEntryByID)("REGION_US", "topicRegion");
349
350
  if (!regionUsEntry) {
350
- logs_1.log(`topicRegion - us not exists, await...`);
351
+ (0, logs_1.log)(`topicRegion - us not exists, await...`);
351
352
  const regionUsEntryData = {
352
353
  fields: {
353
354
  region: {},
@@ -358,18 +359,18 @@ const initBaseEntries = async () => {
358
359
  regionUsEntryData.fields.region[defaultEnvCode] = "us";
359
360
  regionUsEntryData.fields.defaultLocale[defaultEnvCode] = "en-US";
360
361
  regionUsEntryData.fields.locales[defaultEnvCode] = ["en-US"];
361
- regionUsEntry = await exports.createEntryWithId("topicRegion", "REGION_US", regionUsEntryData);
362
+ regionUsEntry = await (0, exports.createEntryWithId)("topicRegion", "REGION_US", regionUsEntryData);
362
363
  regionUsEntry = await regionUsEntry.publish();
363
- logs_1.log(`topicRegion - us created with id: ${regionUsEntry.sys.id}`);
364
+ (0, logs_1.log)(`topicRegion - us created with id: ${regionUsEntry.sys.id}`);
364
365
  }
365
366
  else {
366
- logs_1.log(`topicRegion - us already exists with id: ${regionUsEntry.sys.id}`);
367
+ (0, logs_1.log)(`topicRegion - us already exists with id: ${regionUsEntry.sys.id}`);
367
368
  }
368
369
  return true;
369
370
  };
370
371
  exports.initBaseEntries = initBaseEntries;
371
372
  const getDefaultProfessionalPageContentData = async (pageContentEntry, pageContentData) => {
372
- const regionEntry = await exports.getEntryByID("REGION_GLOBAL", "topicRegion");
373
+ const regionEntry = await (0, exports.getEntryByID)("REGION_GLOBAL", "topicRegion");
373
374
  if (!regionEntry) {
374
375
  throw new Error(`topicRegion with id "REGION_GLOBAL" not exists. Run initBaseEntries() function before.`);
375
376
  }
@@ -389,7 +390,7 @@ const getDefaultProfessionalPageContentData = async (pageContentEntry, pageConte
389
390
  },
390
391
  });
391
392
  }
392
- const siteEntry = await exports.getEntryByID("SITE_PROFESSIONAL", "topicSite");
393
+ const siteEntry = await (0, exports.getEntryByID)("SITE_PROFESSIONAL", "topicSite");
393
394
  if (!siteEntry) {
394
395
  throw new Error(`topicSite with id "SITE_PROFESSIONAL" not exists. Run initBaseEntries() function before.`);
395
396
  }
@@ -413,10 +414,10 @@ const getDefaultProfessionalPageContentData = async (pageContentEntry, pageConte
413
414
  };
414
415
  exports.getDefaultProfessionalPageContentData = getDefaultProfessionalPageContentData;
415
416
  const deleteAllEntries = async (contentType, catalogCode) => {
416
- logs_1.log(`Delete all entries of contentType: ${contentType}`, "INFO");
417
- exports.init();
418
- const env = await exports.getEnvironment();
419
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
417
+ (0, logs_1.log)(`Delete all entries of contentType: ${contentType}`, "INFO");
418
+ (0, exports.init)();
419
+ const env = await (0, exports.getEnvironment)();
420
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
420
421
  let opts = {};
421
422
  if (catalogCode) {
422
423
  opts = {
@@ -446,24 +447,24 @@ const deleteAllEntries = async (contentType, catalogCode) => {
446
447
  if (total) {
447
448
  for (const entry of entries.items) {
448
449
  if (entry.isPublished()) {
449
- logs_1.log(`Unpublish entry ${entry.sys.id}`);
450
+ (0, logs_1.log)(`Unpublish entry ${entry.sys.id}`);
450
451
  const unpublishedEntry = await entry.unpublish();
451
452
  await unpublishedEntry.delete();
452
453
  }
453
454
  else {
454
- logs_1.log(`Delete entry ${entry.sys.id}`);
455
+ (0, logs_1.log)(`Delete entry ${entry.sys.id}`);
455
456
  await entry.delete();
456
457
  }
457
458
  deleted++;
458
459
  }
459
- logs_1.log(`deleted ${deleted} entries of ${total}`);
460
+ (0, logs_1.log)(`deleted ${deleted} entries of ${total}`);
460
461
  }
461
462
  else {
462
- logs_1.log(`No entries found`);
463
+ (0, logs_1.log)(`No entries found`);
463
464
  }
464
465
  }
465
466
  catch (err) {
466
- logs_1.log(err, "ERROR");
467
+ (0, logs_1.log)(err, "ERROR");
467
468
  }
468
469
  } while (Number(deleted) < Number(total));
469
470
  return {
@@ -473,8 +474,8 @@ const deleteAllEntries = async (contentType, catalogCode) => {
473
474
  };
474
475
  exports.deleteAllEntries = deleteAllEntries;
475
476
  const deleteAllPages = async (types) => {
476
- logs_1.log(`Delete all pages of types: ${types.join(",")}`, "INFO");
477
- const env = await exports.getEnvironment();
477
+ (0, logs_1.log)(`Delete all pages of types: ${types.join(",")}`, "INFO");
478
+ const env = await (0, exports.getEnvironment)();
478
479
  const opts = {
479
480
  content_type: "page",
480
481
  "fields.type[in]": types.join(","),
@@ -498,21 +499,21 @@ const deleteAllPages = async (types) => {
498
499
  select: "sys",
499
500
  });
500
501
  if (pageContentEntry.items.length) {
501
- logs_1.log(`Delete page content ${pageContentEntry.items[0].sys.id}`);
502
+ (0, logs_1.log)(`Delete page content ${pageContentEntry.items[0].sys.id}`);
502
503
  await pageContentEntry.items[0].delete();
503
504
  }
504
- logs_1.log(`Delete page ${entry.sys.id}`);
505
+ (0, logs_1.log)(`Delete page ${entry.sys.id}`);
505
506
  await entry.delete();
506
507
  deleted++;
507
508
  }
508
- logs_1.log(`deleted ${deleted} pages of ${total}`);
509
+ (0, logs_1.log)(`deleted ${deleted} pages of ${total}`);
509
510
  }
510
511
  else {
511
- logs_1.log(`No pages found`);
512
+ (0, logs_1.log)(`No pages found`);
512
513
  }
513
514
  }
514
515
  catch (err) {
515
- logs_1.log(err, "ERROR");
516
+ (0, logs_1.log)(err, "ERROR");
516
517
  }
517
518
  } while (Number(deleted) < Number(total));
518
519
  return {
@@ -522,8 +523,8 @@ const deleteAllPages = async (types) => {
522
523
  };
523
524
  exports.deleteAllPages = deleteAllPages;
524
525
  const deletePages = async (types, limit = 100) => {
525
- logs_1.log(`Delete ${limit} pages of types: ${types.join(",")}`, "INFO");
526
- const env = await exports.getEnvironment();
526
+ (0, logs_1.log)(`Delete ${limit} pages of types: ${types.join(",")}`, "INFO");
527
+ const env = await (0, exports.getEnvironment)();
527
528
  const opts = {
528
529
  content_type: "page",
529
530
  "fields.type[in]": types.join(","),
@@ -537,14 +538,14 @@ const deletePages = async (types, limit = 100) => {
537
538
  total = total === 0 ? entries.total : total;
538
539
  if (total) {
539
540
  for (const entry of entries.items) {
540
- logs_1.log(`Delete page ${entry.sys.id}`);
541
+ (0, logs_1.log)(`Delete page ${entry.sys.id}`);
541
542
  await entry.delete();
542
543
  deleted++;
543
544
  }
544
- logs_1.log(`deleted ${deleted} pages of ${total}`);
545
+ (0, logs_1.log)(`deleted ${deleted} pages of ${total}`);
545
546
  }
546
547
  else {
547
- logs_1.log(`No pages found`);
548
+ (0, logs_1.log)(`No pages found`);
548
549
  }
549
550
  return {
550
551
  deleted,
@@ -554,10 +555,10 @@ const deletePages = async (types, limit = 100) => {
554
555
  exports.deletePages = deletePages;
555
556
  const deleteEntries = async (contentType, catalogCode, limit = 100) => {
556
557
  const timeStart = new Date();
557
- logs_1.log(`Delete ${limit} entries of contentType: ${contentType}`, "INFO");
558
- exports.init();
559
- const env = await exports.getEnvironment();
560
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
558
+ (0, logs_1.log)(`Delete ${limit} entries of contentType: ${contentType}`, "INFO");
559
+ (0, exports.init)();
560
+ const env = await (0, exports.getEnvironment)();
561
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
561
562
  let opts = {};
562
563
  if (catalogCode) {
563
564
  opts = {
@@ -585,25 +586,25 @@ const deleteEntries = async (contentType, catalogCode, limit = 100) => {
585
586
  if (total) {
586
587
  for (const entry of entries.items) {
587
588
  if (entry.isPublished()) {
588
- logs_1.log(`Unpublish entry ${entry.sys.id}`);
589
+ (0, logs_1.log)(`Unpublish entry ${entry.sys.id}`);
589
590
  const unpublishedEntry = await entry.unpublish();
590
- logs_1.log(`Delete entry ${entry.sys.id}`);
591
+ (0, logs_1.log)(`Delete entry ${entry.sys.id}`);
591
592
  await unpublishedEntry.delete();
592
593
  }
593
594
  else {
594
- logs_1.log(`Delete entry ${entry.sys.id}`);
595
+ (0, logs_1.log)(`Delete entry ${entry.sys.id}`);
595
596
  await entry.delete();
596
597
  }
597
598
  deleted++;
598
599
  }
599
- logs_1.log(`deleted ${deleted} entries of ${total}`);
600
+ (0, logs_1.log)(`deleted ${deleted} entries of ${total}`);
600
601
  }
601
602
  else {
602
- logs_1.log(`No entries found`);
603
+ (0, logs_1.log)(`No entries found`);
603
604
  }
604
605
  const timeEnd = new Date();
605
- const seconds = utils_1.secondBetweenTwoDate(timeStart, timeEnd);
606
- logs_1.log(`Request time: ${seconds} seconds`);
606
+ const seconds = (0, utils_1.secondBetweenTwoDate)(timeStart, timeEnd);
607
+ (0, logs_1.log)(`Request time: ${seconds} seconds`);
607
608
  return {
608
609
  deleted,
609
610
  total,
@@ -611,7 +612,7 @@ const deleteEntries = async (contentType, catalogCode, limit = 100) => {
611
612
  };
612
613
  exports.deleteEntries = deleteEntries;
613
614
  const addToRelationFields = async (entry, fieldKey, entrySysIdValue, manyReferences = false, resetOldValues = false, linkType = "Entry") => {
614
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
615
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
615
616
  if (resetOldValues && entry.fields?.[fieldKey]?.[defEnvLocaleCode]) {
616
617
  if (manyReferences) {
617
618
  entry.fields[fieldKey][defEnvLocaleCode] = [];
@@ -657,9 +658,9 @@ const addToRelationFields = async (entry, fieldKey, entrySysIdValue, manyReferen
657
658
  };
658
659
  exports.addToRelationFields = addToRelationFields;
659
660
  const removeFromRelationFields = async (entry, fieldKey, entrySysIdValue, manyReferences = false) => {
660
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
661
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
661
662
  if (!entry.fields?.[fieldKey]?.[defEnvLocaleCode]) {
662
- logs_1.log(`The ${fieldKey} relations field of the ${entry.sys.id} entry is empty`, "WARN");
663
+ (0, logs_1.log)(`The ${fieldKey} relations field of the ${entry.sys.id} entry is empty`, "WARN");
663
664
  return entry.fields;
664
665
  }
665
666
  let alreadyValueEsists = false;
@@ -677,15 +678,15 @@ const removeFromRelationFields = async (entry, fieldKey, entrySysIdValue, manyRe
677
678
  }
678
679
  }
679
680
  if (!alreadyValueEsists) {
680
- logs_1.log(`${entrySysIdValue} not found into ${fieldKey} relation field values`, "WARN");
681
+ (0, logs_1.log)(`${entrySysIdValue} not found into ${fieldKey} relation field values`, "WARN");
681
682
  }
682
683
  return entry.fields;
683
684
  };
684
685
  exports.removeFromRelationFields = removeFromRelationFields;
685
686
  const removeFromFieldObject = async (entry, fieldKey, entrySysIdValues) => {
686
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
687
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
687
688
  if (!entry.fields?.[fieldKey]?.[defEnvLocaleCode]) {
688
- logs_1.log(`The ${fieldKey} object field of the ${entry.sys.id} entry is empty`, "WARN");
689
+ (0, logs_1.log)(`The ${fieldKey} object field of the ${entry.sys.id} entry is empty`, "WARN");
689
690
  return entry.fields;
690
691
  }
691
692
  entrySysIdValues = Array.isArray(entrySysIdValues)
@@ -697,14 +698,14 @@ const removeFromFieldObject = async (entry, fieldKey, entrySysIdValues) => {
697
698
  entry.fields[fieldKey][defEnvLocaleCode] = entry.fields[fieldKey][defEnvLocaleCode].filter((item) => item.entryId !== entrySysIdValue);
698
699
  }
699
700
  else {
700
- logs_1.log(`No ${fieldKey} ${entrySysIdValue} found to ${entry.sys.id}`);
701
+ (0, logs_1.log)(`No ${fieldKey} ${entrySysIdValue} found to ${entry.sys.id}`);
701
702
  }
702
703
  }
703
704
  return entry.fields;
704
705
  };
705
706
  exports.removeFromFieldObject = removeFromFieldObject;
706
707
  const addFieldValue = async (entry, fieldKey, fieldValue, manyReferences = false, locale) => {
707
- const defEnvLocaleCode = locale ?? (await exports.getEnvironmentDefaultLocaleCode());
708
+ const defEnvLocaleCode = locale ?? (await (0, exports.getEnvironmentDefaultLocaleCode)());
708
709
  if (!entry.fields?.[fieldKey]?.[exports.defaultEnvironmentLocaleCode]) {
709
710
  entry.fields[fieldKey] = {};
710
711
  if (manyReferences) {
@@ -719,7 +720,7 @@ const addFieldValue = async (entry, fieldKey, fieldValue, manyReferences = false
719
720
  };
720
721
  exports.addFieldValue = addFieldValue;
721
722
  const getTopicDetails = async (topicEntry, fieldKey, contentType, showRelatedEntities = false, isCatalogEntry = true, skipPageSlugs = false) => {
722
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
723
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
723
724
  const isHasToManyField = Array.isArray(topicEntry?.fields?.[fieldKey]?.[defEnvLocaleCode]);
724
725
  const items = [];
725
726
  let entryIds = [];
@@ -736,57 +737,57 @@ const getTopicDetails = async (topicEntry, fieldKey, contentType, showRelatedEnt
736
737
  if (contentType === "topicSubFamily" && showRelatedEntities) {
737
738
  select += ",fields.catalog,fields.category,fields.parentFamily";
738
739
  }
739
- const entries = await exports.getAllEntries(contentType, select, "sys.id[in]", entryIds.join(","));
740
+ const entries = await (0, exports.getAllEntries)(contentType, select, "sys.id[in]", entryIds.join(","));
740
741
  if (entries) {
741
742
  for (const entry of entries) {
742
743
  const data = {
743
- names: await utils_1.getAllTranslations(entry?.fields?.name || {}),
744
+ names: await (0, utils_1.getAllTranslations)(entry?.fields?.name || {}),
744
745
  code: entry?.fields?.code?.[defEnvLocaleCode],
745
746
  };
746
747
  if (!skipPageSlugs) {
747
748
  let entryPage = {};
748
749
  if (isCatalogEntry) {
749
750
  const entryPageId = `${entry.sys.id}_PAGE`;
750
- entryPage = await exports.getEntryByID(entryPageId, "page", "fields.slug");
751
+ entryPage = await (0, exports.getEntryByID)(entryPageId, "page", "fields.slug");
751
752
  }
752
753
  else {
753
- entryPage = await exports.getTopicPage(entry.sys.id);
754
+ entryPage = await (0, exports.getTopicPage)(entry.sys.id);
754
755
  }
755
- data.slugs = await utils_1.getAllTranslations(entryPage?.fields?.slug || {});
756
+ data.slugs = await (0, utils_1.getAllTranslations)(entryPage?.fields?.slug || {});
756
757
  }
757
758
  if (contentType === "topicSubFamily" && showRelatedEntities) {
758
- data.details = await subfamilies_1.getSubFamilySlugDetails(entry);
759
+ data.details = await (0, subfamilies_1.getSubFamilySlugDetails)(entry);
759
760
  }
760
761
  items.push(data);
761
762
  }
762
763
  }
763
764
  }
764
765
  else {
765
- logs_1.log(`No ${fieldKey} found in the ${contentType} ${topicEntry.sys.id}`, "WARN");
766
+ (0, logs_1.log)(`No ${fieldKey} found in the ${contentType} ${topicEntry.sys.id}`, "WARN");
766
767
  }
767
768
  return items;
768
769
  };
769
770
  exports.getTopicDetails = getTopicDetails;
770
771
  const getAssetDetails = async (assetId) => {
771
- const env = await exports.getEnvironment();
772
+ const env = await (0, exports.getEnvironment)();
772
773
  const thumbnailEntry = await env.getAsset(assetId);
773
774
  return thumbnailEntry?.fields
774
- ? utils_1.keysToLowerCase(thumbnailEntry.fields, true)
775
+ ? (0, utils_1.keysToLowerCase)(thumbnailEntry.fields, true)
775
776
  : {};
776
777
  };
777
778
  exports.getAssetDetails = getAssetDetails;
778
779
  const getEntryImageDetails = async (entry, fieldKey) => {
779
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
780
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
780
781
  const assetId = entry?.fields?.[fieldKey]?.[exports.defaultEnvironmentLocaleCode]?.sys?.id;
781
782
  if (assetId) {
782
- const assetEntry = await exports.getAssetDetails(assetId);
783
+ const assetEntry = await (0, exports.getAssetDetails)(assetId);
783
784
  return assetEntry?.file?.[defEnvLocaleCode.toLowerCase()]?.url || "";
784
785
  }
785
786
  return "";
786
787
  };
787
788
  exports.getEntryImageDetails = getEntryImageDetails;
788
789
  const getDictionaryJson = async () => {
789
- const data = await s3_1.getFileFromS3(`dictionary.json`);
790
+ const data = await (0, s3_1.getFileFromS3)(`dictionary.json`);
790
791
  if (!data) {
791
792
  throw new Error("Dictionary JSON file not found on S3.");
792
793
  }
@@ -796,7 +797,7 @@ exports.getDictionaryJson = getDictionaryJson;
796
797
  const getDictionaryValue = async (fieldKey, fieldValue, fieldParent = "", dictionaryJsonFile = {}) => {
797
798
  const dictionaryJson = Object.entries(dictionaryJsonFile)
798
799
  ? dictionaryJsonFile
799
- : await exports.getDictionaryJson();
800
+ : await (0, exports.getDictionaryJson)();
800
801
  let field = null;
801
802
  if (fieldParent && dictionaryJson?.[fieldParent]?.[fieldKey]) {
802
803
  field = dictionaryJson[fieldParent][fieldKey];
@@ -806,23 +807,23 @@ const getDictionaryValue = async (fieldKey, fieldValue, fieldParent = "", dictio
806
807
  }
807
808
  if (field) {
808
809
  if (Array.isArray(field)) {
809
- return utils_1.getPimTranslations(field.find((item) => item.code === fieldValue));
810
+ return (0, utils_1.getPimTranslations)(field.find((item) => item.code === fieldValue));
810
811
  }
811
812
  else if (typeof field === "object" && field?.code) {
812
- return utils_1.getPimTranslations(field);
813
+ return (0, utils_1.getPimTranslations)(field);
813
814
  }
814
815
  else {
815
816
  return field;
816
817
  }
817
818
  }
818
819
  else {
819
- logs_1.log(`No field found with fieldKey: ${fieldKey} fieldValue: ${fieldValue} fieldParent: ${fieldParent}`);
820
+ (0, logs_1.log)(`No field found with fieldKey: ${fieldKey} fieldValue: ${fieldValue} fieldParent: ${fieldParent}`);
820
821
  }
821
822
  };
822
823
  exports.getDictionaryValue = getDictionaryValue;
823
824
  const getDictionaryLocaleValue = async (locale, fieldKey, fieldValue, fieldParent = "", dictionaryJsonFile = {}) => {
824
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
825
- const values = await exports.getDictionaryValue(fieldKey, fieldValue, fieldParent, dictionaryJsonFile);
825
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
826
+ const values = await (0, exports.getDictionaryValue)(fieldKey, fieldValue, fieldParent, dictionaryJsonFile);
826
827
  if (typeof values === "object") {
827
828
  return values?.[locale] || values?.[defEnvLocaleCode];
828
829
  }
@@ -832,7 +833,7 @@ const getDictionaryLocaleValue = async (locale, fieldKey, fieldValue, fieldParen
832
833
  };
833
834
  exports.getDictionaryLocaleValue = getDictionaryLocaleValue;
834
835
  const getTopicPage = async (topicId, select = "sys,fields") => {
835
- const env = await exports.getEnvironment();
836
+ const env = await (0, exports.getEnvironment)();
836
837
  const { items } = await env.getEntries({
837
838
  links_to_entry: topicId,
838
839
  content_type: "page",
@@ -845,13 +846,13 @@ const getTopicPage = async (topicId, select = "sys,fields") => {
845
846
  };
846
847
  exports.getTopicPage = getTopicPage;
847
848
  const createWrapperImgix = async (id, data) => {
848
- let wrapperImgix = await exports.getEntryByID(id, "wrapperImgix");
849
+ let wrapperImgix = await (0, exports.getEntryByID)(id, "wrapperImgix");
849
850
  if (wrapperImgix) {
850
- logs_1.log(`wrapperImgix with id ${id} already exists`);
851
+ (0, logs_1.log)(`wrapperImgix with id ${id} already exists`);
851
852
  return wrapperImgix;
852
853
  }
853
- logs_1.log(`wrapperImgix with id ${id} not found, create it...`);
854
- const defaultEnvCode = await exports.getEnvironmentDefaultLocaleCode();
854
+ (0, logs_1.log)(`wrapperImgix with id ${id} not found, create it...`);
855
+ const defaultEnvCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
855
856
  const entryData = {
856
857
  fields: {},
857
858
  };
@@ -870,37 +871,37 @@ const createWrapperImgix = async (id, data) => {
870
871
  entryData.fields[key][defaultEnvCode] = fieldValue;
871
872
  }
872
873
  }
873
- wrapperImgix = await exports.createEntryWithId("wrapperImgix", id, entryData, true);
874
+ wrapperImgix = await (0, exports.createEntryWithId)("wrapperImgix", id, entryData, true);
874
875
  return wrapperImgix;
875
876
  };
876
877
  exports.createWrapperImgix = createWrapperImgix;
877
878
  const archiveEntry = async (entry, isProduct = false) => {
878
879
  if (!entry.isArchived()) {
879
880
  if (entry.isPublished()) {
880
- logs_1.log(`Unpublish entry ${entry.sys.id}`);
881
+ (0, logs_1.log)(`Unpublish entry ${entry.sys.id}`);
881
882
  entry = await entry.unpublish();
882
883
  }
883
- logs_1.log(`Archive entry ${entry.sys.id}`);
884
+ (0, logs_1.log)(`Archive entry ${entry.sys.id}`);
884
885
  entry = await entry.archive();
885
886
  }
886
887
  else {
887
- logs_1.log(`Entry ${entry.sys.id} is already archived`);
888
+ (0, logs_1.log)(`Entry ${entry.sys.id} is already archived`);
888
889
  }
889
890
  if (isProduct) {
890
- const defEnvLocaleCode = await exports.getEnvironmentDefaultLocaleCode();
891
+ const defEnvLocaleCode = await (0, exports.getEnvironmentDefaultLocaleCode)();
891
892
  const recordObjectId = entry.fields.code[defEnvLocaleCode];
892
893
  if (recordObjectId) {
893
- await products_1.removeProductObject(recordObjectId);
894
+ await (0, products_1.removeProductObject)(recordObjectId);
894
895
  }
895
896
  else {
896
- logs_1.log(`recordObjectId not found`, "WARN");
897
+ (0, logs_1.log)(`recordObjectId not found`, "WARN");
897
898
  }
898
899
  }
899
900
  return entry;
900
901
  };
901
902
  exports.archiveEntry = archiveEntry;
902
903
  const getEntries = async (opts) => {
903
- const env = await exports.getEnvironment();
904
+ const env = await (0, exports.getEnvironment)();
904
905
  const result = await env.getEntries(opts);
905
906
  return result;
906
907
  };