pim-import 5.8.1 → 5.9.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.
@@ -24,7 +24,11 @@ const triggerPDFGenerator = async (topicProductId, multipleDestinations = false)
24
24
  let destinationsData = [];
25
25
  if (multipleDestinations) {
26
26
  destinationsData = topicProduct.fields.destinations[defaultEnvironmentLocaleCode]
27
- .filter((destination) => ["PROFESSIONAL_GLOBAL", "PROFESSIONAL_US"].includes(destination))
27
+ .filter((destination) => [
28
+ "PROFESSIONAL_GLOBAL",
29
+ "PROFESSIONAL_US",
30
+ "PROFESSIONAL_CHINA",
31
+ ].includes(destination))
28
32
  .map((destination) => {
29
33
  switch (destination) {
30
34
  case "PROFESSIONAL_US":
@@ -32,6 +36,11 @@ const triggerPDFGenerator = async (topicProductId, multipleDestinations = false)
32
36
  locale: "en-US",
33
37
  country: "us",
34
38
  };
39
+ case "PROFESSIONAL_CHINA":
40
+ return {
41
+ locale: "zh",
42
+ country: "cn",
43
+ };
35
44
  default:
36
45
  return defaultData;
37
46
  }
@@ -3,7 +3,7 @@ import type { Entry } from "contentful-management/dist/typings/entities/entry";
3
3
  export declare const publishTopicProduct: (productEntry: Entry) => Promise<void>;
4
4
  export declare const publishAllProductDrafts: (filters: {
5
5
  catalog?: AvailableCatalogs;
6
- family?: string;
6
+ destination?: string;
7
7
  }, limit?: number) => Promise<{
8
8
  completed: boolean;
9
9
  total: number;
@@ -22,7 +22,7 @@ const publishTopicProduct = async (productEntry) => {
22
22
  };
23
23
  exports.publishTopicProduct = publishTopicProduct;
24
24
  const publishAllProductDrafts = async (filters, limit = 100) => {
25
- let logMsg = `publishAllProductDrafts catalog: ${filters?.catalog} family: ${filters?.family} limit: ${limit}`;
25
+ let logMsg = `publishAllProductDrafts limit: ${limit} filters: ${JSON.stringify(filters)}`;
26
26
  (0, logs_1.log)(logMsg);
27
27
  if (logs_1.serverUtils) {
28
28
  logs_1.serverUtils.log(logMsg);
@@ -41,8 +41,8 @@ const publishAllProductDrafts = async (filters, limit = 100) => {
41
41
  if (filters?.catalog) {
42
42
  opts["fields.catalogs.sys.id"] = filters.catalog;
43
43
  }
44
- if (filters?.family) {
45
- opts["fields.families.sys.id"] = filters.family;
44
+ if (filters?.destination) {
45
+ opts["fields.destinations[in]"] = filters.destination;
46
46
  }
47
47
  const { items, total } = await env.getEntries(opts);
48
48
  let count = 0;
@@ -52,6 +52,9 @@ const publishAllProductDrafts = async (filters, limit = 100) => {
52
52
  if (logs_1.serverUtils) {
53
53
  logs_1.serverUtils.log(logMsg);
54
54
  }
55
+ if (item.fields.destinations[defEnvLocaleCode]?.length > 1) {
56
+ console.log(item.sys.id, item.fields.destinations[defEnvLocaleCode]);
57
+ }
55
58
  if (["0000000-TEST"].includes(item.sys.id)) {
56
59
  logMsg = `Skip product test ${item.sys.id}`;
57
60
  }
@@ -1509,16 +1509,22 @@ const generateTechSpecPdf = async (topicProductId, country = "global", locale =
1509
1509
  const fileName = (pageSlug.length >= 170
1510
1510
  ? `tech-spec-${topicProductId}`
1511
1511
  : `tech-spec-${pageSlug}`) + `_${country}-${locale}`;
1512
- let baseUrl = process.env.FPI_TECH_SPEC_BASE_URL ?? "";
1512
+ let baseUrl = country === "cn"
1513
+ ? process.env.FPI_TECH_SPEC_BASE_URL_CN ?? ""
1514
+ : process.env.FPI_TECH_SPEC_BASE_URL ?? "";
1513
1515
  if (!baseUrl) {
1514
- (0, logs_1.log)(`FPI_TECH_SPEC_BASE_URL process env not found`, "ERROR");
1516
+ (0, logs_1.log)(`FPI_TECH_SPEC_BASE_URL process env not found for country ${country}`, "ERROR");
1515
1517
  }
1516
1518
  baseUrl = baseUrl.replace(/\/?(\?|#|$)/, "/$1");
1517
- let footerBaseUrl = process.env.FPI_TECH_SPEC_FOOTER_BASE_URL ??
1518
- process.env.FPI_TECH_SPEC_BASE_URL ??
1519
- "";
1519
+ let footerBaseUrl = country === "cn"
1520
+ ? process.env.FPI_TECH_SPEC_FOOTER_BASE_URL_CN ??
1521
+ process.env.FPI_TECH_SPEC_BASE_URL_CN ??
1522
+ ""
1523
+ : process.env.FPI_TECH_SPEC_FOOTER_BASE_URL ??
1524
+ process.env.FPI_TECH_SPEC_BASE_URL ??
1525
+ "";
1520
1526
  if (!footerBaseUrl) {
1521
- (0, logs_1.log)(`FPI_TECH_SPEC_FOOTER_BASE_URL process env not found`, "ERROR");
1527
+ (0, logs_1.log)(`FPI_TECH_SPEC_FOOTER_BASE_URL process env not found for country ${country}`, "ERROR");
1522
1528
  }
1523
1529
  footerBaseUrl = footerBaseUrl.replace(/\/?(\?|#|$)/, "/$1");
1524
1530
  const layoutUrl = `${baseUrl}${locale}/${country}/tech-spec/${pageSlug}/v-${version}/`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "5.8.1",
3
+ "version": "5.9.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",