pim-import 4.6.0 → 4.8.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.
@@ -31,7 +31,6 @@ import {
31
31
  getDictionaryJson,
32
32
  getAllEntries,
33
33
  archiveEntry,
34
- addDesignerData,
35
34
  } from "../../libs/contentful";
36
35
  import type {
37
36
  Entry,
@@ -64,6 +63,7 @@ import {
64
63
  } from "../../libs/imgix";
65
64
  import { generatePDFByUrl } from "../../libs/pdf";
66
65
  import { reindexProduct } from "../../algolia/products";
66
+ import { addDesignerData } from "./designers";
67
67
 
68
68
  export type AvailableProductStatus =
69
69
  | "To be review"
@@ -1280,15 +1280,22 @@ export const importProduct = async (
1280
1280
  }
1281
1281
 
1282
1282
  if (
1283
- productDetails.visibleToWeb === true ||
1284
- productDetails.code === "0000000-TEST"
1283
+ (productDetails.visibleToWeb === true ||
1284
+ productDetails.code === "0000000-TEST") &&
1285
+ productDetails.destinations?.filter((item) =>
1286
+ item.code.includes("PROFESSIONAL_")
1287
+ ).length
1285
1288
  ) {
1286
1289
  await addProduct(productDetails);
1287
1290
  return true;
1288
1291
  } else {
1289
1292
  await notVisibleToWebProduct(productDetails.code);
1293
+ const destinations = productDetails.destinations
1294
+ ?.map((item) => item.code)
1295
+ .join(", ");
1296
+
1290
1297
  log(
1291
- `Product not to be imported: ${productDetails.code} - visibleToWeb = ${productDetails.visibleToWeb}`
1298
+ `Product not to be imported: ${productDetails.code} - visibleToWeb = ${productDetails.visibleToWeb} - destinations = [${destinations}]`
1292
1299
  );
1293
1300
  return false;
1294
1301
  }
@@ -9,7 +9,6 @@ import {
9
9
  cfLocales,
10
10
  addToRelationFields,
11
11
  addFieldValue,
12
- addDesignerData,
13
12
  } from "../../libs/contentful";
14
13
  import { log, serverUtils } from "../../libs/logs";
15
14
  import type {
@@ -37,6 +36,7 @@ import {
37
36
  } from "../../types";
38
37
  import { updateSubFamiliesRelToEntry, getCategoryTopicCode } from "./catalogs";
39
38
  import { pageResponse } from "../../algolia/families";
39
+ import { addDesignerData } from "./designers";
40
40
 
41
41
  const getComponentModelPagesData = async (
42
42
  componentID: string,
@@ -85,6 +85,7 @@ export interface ProductDetails {
85
85
  spareParts?: null;
86
86
  catalogs?: CatalogsEntity[] | null;
87
87
  currentCatalog?: CatalogsEntity | null;
88
+ destinations: GenericData[] | null;
88
89
  }
89
90
  export interface ProductGroup {
90
91
  code: string;
package/types/index.d.ts CHANGED
@@ -28,3 +28,4 @@ export { getStaticDailyProducts, getLatestProducts } from "./pim/endpoints";
28
28
  export { log, setServerUtils, setLogId, setLogPath, setLogFilename, getLogFolder, } from "./libs/logs";
29
29
  export { removeRecordsByStatus } from "./algolia/clean";
30
30
  export { generatePDFByUrl } from "./libs/pdf";
31
+ export { importDesigners, importDesigner } from "./pim/methods/designers";
@@ -2,7 +2,6 @@ import type { Entry, CreateEntryProps, EntryProps } from "contentful-management/
2
2
  import type { QueryOptions } from "contentful-management/dist/typings/common-types";
3
3
  import { Environment, Locale, CreateAssetProps } from "contentful-management/types";
4
4
  import { ContentfulLocale, AvailableCatalogs, TopicDetailsResponse, AssetPropFields, OtherFilters, WrapperImageFields } from "../types";
5
- import { GenericData } from "../resources/ProductDetails";
6
5
  export declare type Config = {
7
6
  accessToken: string;
8
7
  spaceId: string;
@@ -56,6 +55,4 @@ export declare const getDictionaryLocaleValue: (locale: string, fieldKey: string
56
55
  export declare const getTopicPage: (topicId: string, select?: string) => Promise<Entry>;
57
56
  export declare const createWrapperImgix: (id: string, data: WrapperImageFields) => Promise<Entry>;
58
57
  export declare const archiveEntry: (entry: Entry, isProduct?: boolean) => Promise<Entry>;
59
- export declare const getDesignerData: (designer: GenericData) => Promise<CreateEntryProps<import("contentful-management/types").KeyValueMap>>;
60
- export declare const addDesignerData: (data: any, designer: GenericData, manyReferences?: boolean) => Promise<any>;
61
58
  export declare const getEntries: (opts: QueryOptions) => Promise<import("contentful-management/dist/typings/common-types").Collection<import("contentful-management/dist/typings/entities/entry").Entry, EntryProps<Record<string, any>>>>;
@@ -0,0 +1,6 @@
1
+ import { Entry, CreateEntryProps } from "contentful-management/dist/typings/entities/entry";
2
+ import { GenericData } from "../../resources/ProductDetails";
3
+ export declare const getDesignerData: (designer: GenericData) => Promise<CreateEntryProps<import("contentful-management/types").KeyValueMap>>;
4
+ export declare const addDesignerData: (data: any, designer: GenericData, manyReferences?: boolean) => Promise<any>;
5
+ export declare const importDesigner: (designer: GenericData, skipUpdate?: boolean) => Promise<Entry>;
6
+ export declare const importDesigners: () => Promise<void>;
@@ -84,6 +84,7 @@ export interface ProductDetails {
84
84
  spareParts?: null;
85
85
  catalogs?: CatalogsEntity[] | null;
86
86
  currentCatalog?: CatalogsEntity | null;
87
+ destinations: GenericData[] | null;
87
88
  }
88
89
  export interface ProductGroup {
89
90
  code: string;