pim-import 4.13.2 → 4.14.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.
@@ -2232,9 +2232,18 @@ export const importProductByCode = async (
2232
2232
  * @param topicProductId
2233
2233
  * @returns
2234
2234
  */
2235
- export const generateTechSpecPdf = async (topicProductId: string) => {
2235
+ export const generateTechSpecPdf = async (
2236
+ topicProductId: string,
2237
+ country: string = "global",
2238
+ locale: string = "en"
2239
+ ) => {
2236
2240
  log(`generateTechSpecPdf - topicProductId: ${topicProductId}`);
2237
- let topicProduct = await getEntryByID(topicProductId, "topicProduct");
2241
+ let topicProduct = await getEntryByID(
2242
+ topicProductId,
2243
+ "topicProduct",
2244
+ "",
2245
+ locale
2246
+ );
2238
2247
  if (!topicProduct) {
2239
2248
  throw new Error(`topicProduct with id ${topicProductId} not found`);
2240
2249
  } else if (topicProduct.isArchived()) {
@@ -2245,7 +2254,12 @@ export const generateTechSpecPdf = async (topicProductId: string) => {
2245
2254
  }
2246
2255
 
2247
2256
  const topicProductPageId = getProductPageIdByCode(topicProduct.sys.id);
2248
- const topicProductPage = await getEntryByID(topicProductPageId, "page");
2257
+ const topicProductPage = await getEntryByID(
2258
+ topicProductPageId,
2259
+ "page",
2260
+ "",
2261
+ locale
2262
+ );
2249
2263
  if (!topicProductPage) {
2250
2264
  throw new Error(`topicProductPage with id ${topicProductPageId} not found`);
2251
2265
  } else if (topicProductPage.isArchived()) {
@@ -2258,16 +2272,15 @@ export const generateTechSpecPdf = async (topicProductId: string) => {
2258
2272
  serverUtils.updateProgress(20);
2259
2273
  }
2260
2274
 
2261
- const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
2262
- const topicCatalogIds = topicProduct?.fields?.catalogs?.[
2263
- defaultEnvironmentLocaleCode
2264
- ]?.map((catalog: any) => catalog.sys.id);
2265
- const pageSlug = topicProductPage?.fields?.slug[defaultEnvironmentLocaleCode];
2275
+ const topicCatalogIds = topicProduct?.fields?.catalogs?.[locale]?.map(
2276
+ (catalog: any) => catalog.sys.id
2277
+ );
2278
+ const pageSlug = topicProductPage?.fields?.slug[locale];
2266
2279
  const version = topicProduct?.sys?.version;
2267
2280
  const fileName =
2268
- pageSlug.length >= 180
2281
+ (pageSlug.length >= 170
2269
2282
  ? `tech-spec-${topicProductId}`
2270
- : `tech-spec-${pageSlug}`; // 57 caratteri è il resto dell'url di S3
2283
+ : `tech-spec-${pageSlug}`) + `_${country}-${locale}`; // 57 caratteri è il resto dell'url di S3
2271
2284
  let baseUrl = process.env.FPI_TECH_SPEC_BASE_URL ?? "";
2272
2285
  if (!baseUrl) {
2273
2286
  log(`FPI_TECH_SPEC_BASE_URL process env not found`, "ERROR");
@@ -2282,9 +2295,9 @@ export const generateTechSpecPdf = async (topicProductId: string) => {
2282
2295
  }
2283
2296
  footerBaseUrl = footerBaseUrl.replace(/\/?(\?|#|$)/, "/$1");
2284
2297
 
2285
- const layoutUrl = `${baseUrl}${defaultEnvironmentLocaleCode}/global/tech-spec/${pageSlug}/v-${version}/`;
2298
+ const layoutUrl = `${baseUrl}${locale}/${country}/tech-spec/${pageSlug}/v-${version}/`;
2286
2299
  const pdpSiteUrl =
2287
- `${footerBaseUrl}${defaultEnvironmentLocaleCode}/global/product/${pageSlug}`.replace(
2300
+ `${footerBaseUrl}${locale}/${country}/product/${pageSlug}`.replace(
2288
2301
  /\/?(\?|#|$)/,
2289
2302
  "/$1"
2290
2303
  );
@@ -2317,7 +2330,13 @@ export const generateTechSpecPdf = async (topicProductId: string) => {
2317
2330
  }
2318
2331
 
2319
2332
  log(`Update techSpec field...`);
2320
- topicProduct.fields = await addFieldValue(topicProduct, "techSpec", s3Url);
2333
+ topicProduct.fields = await addFieldValue(
2334
+ topicProduct,
2335
+ "techSpec",
2336
+ s3Url,
2337
+ false,
2338
+ locale
2339
+ );
2321
2340
 
2322
2341
  topicProduct = await topicProduct.update();
2323
2342
  if (topicProduct.isPublished()) {
package/src/types.ts CHANGED
@@ -259,3 +259,8 @@ export type RequiredImgixAttributes = Pick<
259
259
  | "content_type"
260
260
  | "name"
261
261
  >;
262
+
263
+ export type AlgoliaObjectFilter = {
264
+ key: string;
265
+ value: string;
266
+ };
@@ -2,42 +2,42 @@ export declare type AvailableIndicesKey = "products" | "families" | "subFamilies
2
2
  export declare const getClient: () => import("algoliasearch").SearchClient;
3
3
  export declare const getIndicesSettings: () => {
4
4
  products: {
5
- name: string | undefined;
5
+ name: string;
6
6
  settings: {
7
7
  attributesForFaceting: string[];
8
8
  searchableAttributes: string[];
9
9
  };
10
10
  };
11
11
  families: {
12
- name: string | undefined;
12
+ name: string;
13
13
  settings: {
14
14
  attributesForFaceting: string[];
15
15
  searchableAttributes: string[];
16
16
  };
17
17
  };
18
18
  subFamilies: {
19
- name: string | undefined;
19
+ name: string;
20
20
  settings: {
21
21
  attributesForFaceting: string[];
22
22
  searchableAttributes: string[];
23
23
  };
24
24
  };
25
25
  subModels: {
26
- name: string | undefined;
26
+ name: string;
27
27
  settings: {
28
28
  attributesForFaceting: string[];
29
29
  searchableAttributes: string[];
30
30
  };
31
31
  };
32
32
  models: {
33
- name: string | undefined;
33
+ name: string;
34
34
  settings: {
35
35
  attributesForFaceting: string[];
36
36
  searchableAttributes: string[];
37
37
  };
38
38
  };
39
39
  downloads: {
40
- name: string | undefined;
40
+ name: string;
41
41
  settings: {
42
42
  attributesForFaceting: string[];
43
43
  searchableAttributes: string[];
@@ -45,7 +45,7 @@ export declare const getIndicesSettings: () => {
45
45
  };
46
46
  };
47
47
  projects: {
48
- name: string | undefined;
48
+ name: string;
49
49
  settings: {
50
50
  attributesForFaceting: string[];
51
51
  searchableAttributes: string[];
@@ -54,7 +54,7 @@ export declare const getIndicesSettings: () => {
54
54
  };
55
55
  };
56
56
  stories: {
57
- name: string | undefined;
57
+ name: string;
58
58
  settings: {
59
59
  attributesForFaceting: string[];
60
60
  searchableAttributes: string[];
@@ -63,7 +63,7 @@ export declare const getIndicesSettings: () => {
63
63
  };
64
64
  };
65
65
  pressReviews: {
66
- name: string | undefined;
66
+ name: string;
67
67
  settings: {
68
68
  attributesForFaceting: string[];
69
69
  searchableAttributes: string[];
@@ -72,7 +72,7 @@ export declare const getIndicesSettings: () => {
72
72
  };
73
73
  };
74
74
  pressRelease: {
75
- name: string | undefined;
75
+ name: string;
76
76
  settings: {
77
77
  attributesForFaceting: string[];
78
78
  searchableAttributes: string[];
@@ -81,7 +81,7 @@ export declare const getIndicesSettings: () => {
81
81
  };
82
82
  };
83
83
  news: {
84
- name: string | undefined;
84
+ name: string;
85
85
  settings: {
86
86
  attributesForFaceting: string[];
87
87
  searchableAttributes: string[];
@@ -1,4 +1,4 @@
1
- import { CfLocalizedEntryField, TopicDetailsResponse, WrapperImageFields } from "../types";
1
+ import { CfLocalizedEntryField, TopicDetailsResponse, WrapperImageFields, AlgoliaObjectFilter } from "../types";
2
2
  export declare type AlgoliaProductRecord = {
3
3
  objectID: string;
4
4
  name?: string;
@@ -66,7 +66,7 @@ export declare const reindexProduct: (topicProductId: string, generatePdf?: bool
66
66
  lastSyncDate?: string | undefined;
67
67
  taskID: number;
68
68
  }>;
69
- export declare const reindexProducts: (filterKey: string, filterValue: string, offset?: number, limit?: number, lastPimSyncDateGte?: string | undefined, generatePdf?: boolean) => Promise<{
69
+ export declare const reindexProducts: (filterKey: string, filterValue: string, offset?: number, limit?: number, lastPimSyncDateGte?: string | undefined, generatePdf?: boolean, filters?: AlgoliaObjectFilter[]) => Promise<{
70
70
  savedObjectIDs: string[];
71
71
  deletedObjectIDs: string[];
72
72
  objects: Readonly<Record<string, any>>[];
@@ -17,6 +17,7 @@ export declare const init: (opts?: Config | undefined) => void;
17
17
  export declare const getConfig: () => Config;
18
18
  export declare const getEnvironment: () => Promise<Environment>;
19
19
  export declare const getEnvironmentDefaultLocale: () => Promise<Locale>;
20
+ export declare const getClient: () => Promise<Environment>;
20
21
  export declare const getEnvironmentDefaultLocaleCode: () => Promise<string>;
21
22
  export declare const uploadFile: (asset: CreateAssetProps) => Promise<any>;
22
23
  export declare const createEntryWithId: (contentTypeId: string, id: string, data: CreateEntryProps, publish?: boolean) => Promise<Entry>;
@@ -24,7 +25,7 @@ export declare const updateEntry: (itemEntry: Entry, data: CreateEntryProps, pub
24
25
  export declare const getEntryByCode: (code: string, contentTypeId: string, select?: string | undefined) => Promise<Entry>;
25
26
  export declare const getAllEntriesByCodes: (codes: string[], contentTypeId: string, select?: string | undefined, filter?: string, otherFilters?: OtherFilters[] | undefined) => Promise<Entry[]>;
26
27
  export declare const getAllEntries: (contentType: string, select?: string | undefined, filterKey?: string | undefined, filterValue?: string | undefined, limit?: number) => Promise<Entry[]>;
27
- export declare const getEntryByID: (entryID: string, contentTypeId: string, select?: string | undefined) => Promise<Entry>;
28
+ export declare const getEntryByID: (entryID: string, contentTypeId: string, select?: string | undefined, locale?: string | undefined) => Promise<Entry>;
28
29
  export declare const initBaseEntries: () => Promise<boolean>;
29
30
  export declare const getDefaultProfessionalPageContentData: (pageContentEntry: Entry, pageContentData: CreateEntryProps) => Promise<CreateEntryProps<import("contentful-management/types").KeyValueMap>>;
30
31
  export declare const deleteAllEntries: (contentType: string, catalogCode?: AvailableCatalogs | undefined) => Promise<{
@@ -45,7 +46,7 @@ export declare const deleteEntries: (contentType: string, catalogCode?: Availabl
45
46
  }>;
46
47
  export declare const addToRelationFields: (entry: Entry | any, fieldKey: string, entrySysIdValue: string, manyReferences?: boolean, resetOldValues?: boolean, linkType?: "Asset" | "Entry") => Promise<Entry>;
47
48
  export declare const removeFromRelationFields: (entry: Entry | any, fieldKey: string, entrySysIdValue: string, manyReferences?: boolean) => Promise<any>;
48
- export declare const addFieldValue: (entry: Entry | any, fieldKey: string, fieldValue: any, manyReferences?: boolean) => Promise<any>;
49
+ export declare const addFieldValue: (entry: Entry | any, fieldKey: string, fieldValue: any, manyReferences?: boolean, locale?: string | undefined) => Promise<any>;
49
50
  export declare const getTopicDetails: (topicEntry: Entry, fieldKey: string, contentType: string, showRelatedEntities?: boolean, isCatalogEntry?: boolean, skipPageSlugs?: boolean) => Promise<TopicDetailsResponse[]>;
50
51
  export declare const getAssetDetails: (assetId: string) => Promise<AssetPropFields>;
51
52
  export declare const getEntryImageDetails: (entry: Entry, fieldKey: string) => Promise<string>;
@@ -40,7 +40,7 @@ export declare const audit: (lastModified: string, catalog: AvailableCatalogs, o
40
40
  total?: undefined;
41
41
  }>;
42
42
  export declare const importProductByCode: (code: string, catalog: AvailableCatalogs) => Promise<void>;
43
- export declare const generateTechSpecPdf: (topicProductId: string) => Promise<any>;
43
+ export declare const generateTechSpecPdf: (topicProductId: string, country?: string, locale?: string) => Promise<any>;
44
44
  export declare const setProductsAutodescription: (catalog: AvailableCatalogs, offset?: number, limit?: number) => Promise<{
45
45
  catalog: AvailableCatalogs;
46
46
  offset: number;
package/types/types.d.ts CHANGED
@@ -186,3 +186,7 @@ export interface ImgixAttributes {
186
186
  warning_violence: number;
187
187
  }
188
188
  export declare type RequiredImgixAttributes = Pick<ImgixAttributes, "origin_path" | "file_size" | "media_width" | "media_height" | "content_type" | "name">;
189
+ export declare type AlgoliaObjectFilter = {
190
+ key: string;
191
+ value: string;
192
+ };