pim-import 4.3.2 → 4.4.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.
Files changed (49) hide show
  1. package/dist/algolia/downloads.js +2 -2
  2. package/dist/algolia/downloads.js.map +1 -1
  3. package/dist/algolia/families.js +2 -2
  4. package/dist/algolia/families.js.map +1 -1
  5. package/dist/algolia/models.js +5 -5
  6. package/dist/algolia/models.js.map +1 -1
  7. package/dist/algolia/news.js +3 -3
  8. package/dist/algolia/news.js.map +1 -1
  9. package/dist/algolia/pressRelease.js +3 -3
  10. package/dist/algolia/pressRelease.js.map +1 -1
  11. package/dist/algolia/pressReview.js +1 -1
  12. package/dist/algolia/pressReview.js.map +1 -1
  13. package/dist/algolia/products.js +20 -20
  14. package/dist/algolia/products.js.map +1 -1
  15. package/dist/algolia/projects.js +1 -1
  16. package/dist/algolia/projects.js.map +1 -1
  17. package/dist/algolia/stories.js +8 -10
  18. package/dist/algolia/stories.js.map +1 -1
  19. package/dist/algolia/subFamilies.js +5 -5
  20. package/dist/algolia/subFamilies.js.map +1 -1
  21. package/dist/algolia/subModels.js +6 -6
  22. package/dist/algolia/subModels.js.map +1 -1
  23. package/dist/libs/contentful-cda.js +6 -11
  24. package/dist/libs/contentful-cda.js.map +1 -1
  25. package/dist/libs/contentful.js +13 -19
  26. package/dist/libs/contentful.js.map +1 -1
  27. package/dist/libs/imgix.js +3 -3
  28. package/dist/libs/imgix.js.map +1 -1
  29. package/dist/utils.js +11 -1
  30. package/dist/utils.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/algolia/downloads.ts +1 -3
  33. package/src/algolia/families.ts +2 -4
  34. package/src/algolia/models.ts +4 -7
  35. package/src/algolia/news.ts +10 -4
  36. package/src/algolia/pressRelease.ts +11 -4
  37. package/src/algolia/pressReview.ts +8 -2
  38. package/src/algolia/products.ts +9 -26
  39. package/src/algolia/projects.ts +6 -2
  40. package/src/algolia/stories.ts +21 -12
  41. package/src/algolia/subFamilies.ts +9 -9
  42. package/src/algolia/subModels.ts +10 -10
  43. package/src/libs/contentful-cda.ts +17 -15
  44. package/src/libs/contentful.ts +15 -24
  45. package/src/libs/imgix.ts +6 -4
  46. package/src/utils.ts +22 -0
  47. package/types/libs/contentful-cda.d.ts +1 -1
  48. package/types/libs/contentful.d.ts +1 -1
  49. package/types/utils.d.ts +1 -0
package/src/libs/imgix.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  import axios from "@atoms-studio/axios";
10
10
  import https from "https";
11
11
  import mime from "mime-types";
12
- import { basename } from "../utils";
12
+ import { basename, getAllTranslations } from "../utils";
13
13
 
14
14
  let imgix: ImgixAPI;
15
15
  export const getImgix = () => {
@@ -204,9 +204,11 @@ export const getWrapperImgixFields = async (wrapperImgixId: string) => {
204
204
  focalPoint:
205
205
  wrapperImgix?.fields?.focalPoint?.[defaultEnvironmentLocaleCode]
206
206
  ?.focalPoint || {},
207
- altText: wrapperImgix?.fields?.altText || {},
208
- caption: wrapperImgix?.fields?.caption || {},
209
- hoverTitle: wrapperImgix?.fields?.hoverTitle || {},
207
+ altText: await getAllTranslations(wrapperImgix?.fields?.altText || {}),
208
+ caption: await getAllTranslations(wrapperImgix?.fields?.caption || {}),
209
+ hoverTitle: await getAllTranslations(
210
+ wrapperImgix?.fields?.hoverTitle || {}
211
+ ),
210
212
  forceHoverTitle:
211
213
  !!wrapperImgix?.fields?.forceHoverTitle?.[defaultEnvironmentLocaleCode],
212
214
  };
package/src/utils.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  } from "./types";
9
9
  import { AssetsEntity } from "./resources/ProductDetails";
10
10
  import { log } from "./libs/logs";
11
+ import { cfLocales, getEnvironmentDefaultLocaleCode } from "./libs/contentful";
11
12
 
12
13
  /**
13
14
  * Merge two objects
@@ -326,3 +327,24 @@ export const replaceAll = (original: string, from: string, to: string) => {
326
327
  const regExp = new RegExp(from, "g");
327
328
  return original.replace(regExp, to);
328
329
  };
330
+
331
+ /**
332
+ * Get all locale translations
333
+ *
334
+ *
335
+ * @param {object} values
336
+ *
337
+ * @example getAllTranslations({en:foo}) => {en:foo, it: foo, de: foo...}
338
+ *
339
+ * @returns
340
+ */
341
+ export const getAllTranslations = async (values: any) => {
342
+ const defaultLocale = await getEnvironmentDefaultLocaleCode();
343
+
344
+ const newValue: any = {};
345
+ for (const locale of cfLocales) {
346
+ newValue[locale] = values?.[locale] || values[defaultLocale] || "";
347
+ }
348
+
349
+ return keysToLowerCase(newValue);
350
+ };
@@ -8,7 +8,7 @@ export declare const getEntryByID: (entryID: string, contentTypeId: string, sele
8
8
  export declare const getAllEntries: (contentType: string, select?: string | undefined, filterKey?: string | undefined, filterValue?: string | undefined, limit?: number, otherFilters?: OtherFilters[] | undefined, include?: number) => Promise<Entry[]>;
9
9
  export declare const getAssetDetails: (assetId: string) => Promise<AssetPropFieldsWithoutLocaleKey>;
10
10
  export declare const getEntryImageDetails: (entry: Entry, fieldKey: string) => Promise<string>;
11
- export declare const getTopicDetails: (topicEntry: Entry, fieldKey: string, contentType: string, lowerCaseKeys?: boolean, showRelatedEntities?: boolean, isCatalogEntry?: boolean, skipPageSlugs?: boolean) => Promise<TopicDetailsResponse[]>;
11
+ export declare const getTopicDetails: (topicEntry: Entry, fieldKey: string, contentType: string, showRelatedEntities?: boolean, isCatalogEntry?: boolean, skipPageSlugs?: boolean) => Promise<TopicDetailsResponse[]>;
12
12
  export declare const getSubFamilySlugDetails: (topicSubFamily: Entry) => Promise<{
13
13
  catalogPageSlugs: any;
14
14
  familyPageSlugs: any;
@@ -47,7 +47,7 @@ export declare const deleteEntries: (contentType: string, catalogCode?: Availabl
47
47
  export declare const addToRelationFields: (entry: Entry | any, fieldKey: string, entrySysIdValue: string, manyReferences?: boolean, resetOldValues?: boolean, linkType?: "Asset" | "Entry") => Promise<Entry>;
48
48
  export declare const removeFromRelationFields: (entry: Entry | any, fieldKey: string, entrySysIdValue: string, manyReferences?: boolean) => Promise<any>;
49
49
  export declare const addFieldValue: (entry: Entry | any, fieldKey: string, fieldValue: any, manyReferences?: boolean) => Promise<any>;
50
- export declare const getTopicDetails: (topicEntry: Entry, fieldKey: string, contentType: string, lowerCaseKeys?: boolean, showRelatedEntities?: boolean, isCatalogEntry?: boolean) => Promise<TopicDetailsResponse[]>;
50
+ export declare const getTopicDetails: (topicEntry: Entry, fieldKey: string, contentType: string, showRelatedEntities?: boolean, isCatalogEntry?: boolean, skipPageSlugs?: boolean) => Promise<TopicDetailsResponse[]>;
51
51
  export declare const getAssetDetails: (assetId: string) => Promise<AssetPropFields>;
52
52
  export declare const getEntryImageDetails: (entry: Entry, fieldKey: string) => Promise<string>;
53
53
  export declare const getDictionaryJson: () => Promise<any>;
package/types/utils.d.ts CHANGED
@@ -17,3 +17,4 @@ export declare const capitalizeFirstLetter: (text: string) => string;
17
17
  export declare const keysToLowerCase: (obj: any, includeNestedKeys?: boolean) => any;
18
18
  export declare const addProductFieldValueCodesByPimDetails: (pimDetails: any, productFields: any, fieldKey: string, fieldParentKey?: string | undefined) => string[];
19
19
  export declare const replaceAll: (original: string, from: string, to: string) => string;
20
+ export declare const getAllTranslations: (values: any) => Promise<any>;