pim-import 5.4.1 → 5.6.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.
@@ -20,6 +20,7 @@ exports.cfLocales = [
20
20
  "es",
21
21
  "de",
22
22
  "fr",
23
+ "zh",
23
24
  ];
24
25
  const checkConfig = (skipInit = false) => {
25
26
  if (!skipInit) {
@@ -1224,6 +1224,13 @@
1224
1224
  "dictionary": "DBooleanCertification",
1225
1225
  "type": "object"
1226
1226
  },
1227
+ {
1228
+ "key": "cmimCertified",
1229
+ "parent": "certified",
1230
+ "icon": true,
1231
+ "dictionary": "DBooleanCertification",
1232
+ "type": "object"
1233
+ },
1227
1234
  {
1228
1235
  "key": "ja8Certified",
1229
1236
  "parent": "certified",
@@ -55,7 +55,7 @@ const getCategorySlugs = async (categoryEntry) => {
55
55
  const defaultEnvironmentLocaleCode = await (0, contentful_1.getEnvironmentDefaultLocaleCode)();
56
56
  for (const locale of contentful_1.cfLocales) {
57
57
  slugs[locale] = (0, utils_1.stringToSlug)(`${categoryEntry.fields.name[locale] ||
58
- categoryEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase());
58
+ categoryEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
59
59
  }
60
60
  return slugs;
61
61
  };
@@ -149,7 +149,7 @@ const importCatalogPage = async (catalogEntry) => {
149
149
  const slugs = {};
150
150
  for (const locale of contentful_1.cfLocales) {
151
151
  slugs[locale] = (0, utils_1.stringToSlug)(`${catalogEntry.fields.name[locale] ||
152
- catalogEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase());
152
+ catalogEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
153
153
  }
154
154
  (0, logs_1.log)(`create/update catalog page ${pageId}...`);
155
155
  let catalogPageEntry = await (0, contentful_1.getEntryByID)(pageId, "page");
@@ -33,7 +33,7 @@ const createOrUpdatePage = async (familyEntry) => {
33
33
  }
34
34
  for (const locale of contentful_1.cfLocales) {
35
35
  slugs[locale] = (0, utils_1.stringToSlug)(`${familyEntry.fields.name[locale] ||
36
- familyEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase());
36
+ familyEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
37
37
  }
38
38
  let familyPageEntry = await (0, contentful_1.getEntryByID)(pageId, "page");
39
39
  const pageData = await getFamilyPageData(names, slugs, pageId, familyEntry, familyPageEntry);
@@ -33,7 +33,7 @@ const createOrUpdatePage = async (modelEntry) => {
33
33
  }
34
34
  for (const locale of contentful_1.cfLocales) {
35
35
  slugs[locale] = (0, utils_1.stringToSlug)(`${modelEntry.fields.name[locale] ||
36
- modelEntry.fields.name[defaultEnvironmentLocaleCode]}-${modelEntry.fields.code[defaultEnvironmentLocaleCode]}`.toLowerCase());
36
+ modelEntry.fields.name[defaultEnvironmentLocaleCode]}-${modelEntry.fields.code[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
37
37
  }
38
38
  let modelPageEntry = await (0, contentful_1.getEntryByID)(pageId, "page");
39
39
  const pageData = await getModelPageData(names, slugs, pageId, modelEntry, modelPageEntry);
@@ -228,7 +228,9 @@ const createOrUpdateProductPage = async (productEntry, unpublish) => {
228
228
  const slugs = {};
229
229
  const code = productEntry.fields.code["en"];
230
230
  for (const name of Object.entries(productEntry.fields.name)) {
231
- slugs[name[0]] = (0, utils_1.stringToSlug)(`${name[1]}-${code}`, true).toLowerCase();
231
+ const locale = name[0];
232
+ const title = `${name[1]}-${code}`;
233
+ slugs[locale] = (0, utils_1.stringToSlug)(title, true, locale).toLowerCase();
232
234
  }
233
235
  let productPageEntry = await (0, contentful_1.getEntryByID)(pageId, "page");
234
236
  const pageData = await getProductPageData(names, slugs, pageId, productEntry, productPageEntry);
@@ -67,7 +67,7 @@ const getSubFamilyPageSlugs = async (catalogPage, categoryPage, subFamilyEntry)
67
67
  categoryPage.fields.slug[defaultEnvironmentLocaleCode]) + "-";
68
68
  }
69
69
  slugs[locale] = (0, utils_1.stringToSlug)(`${slugPrefix}${subFamilyEntry.fields.name[locale] ||
70
- subFamilyEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase());
70
+ subFamilyEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
71
71
  }
72
72
  return slugs;
73
73
  };
package/dist/types.d.ts CHANGED
@@ -3,8 +3,8 @@ export type AvailableEntryStatus = "Published" | "Changed" | "Draft" | "Archived
3
3
  export type NonEmptyArray<T> = [T, ...T[]];
4
4
  export type ObjectPartial = Partial<Record<string, any>>;
5
5
  export type { Config as ContentfulConfig } from "./libs/contentful";
6
- export type PimLocale = "en" | "en_us" | "it" | "es" | "de" | "fr" | "sv" | "no" | "da" | "ru";
7
- export type ContentfulLocale = "en" | "en-US" | "it" | "es" | "de" | "fr";
6
+ export type PimLocale = "en" | "en_us" | "it" | "es" | "de" | "fr" | "sv" | "no" | "da" | "zh" | "ru";
7
+ export type ContentfulLocale = "en" | "en-US" | "it" | "es" | "de" | "fr" | "zh";
8
8
  export type PimValues = {
9
9
  value_en: string;
10
10
  value_en_US?: string | null;
package/dist/utils.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const sleep: (ms: number, showLog?: boolean) => Promise<unknown>;
5
5
  export declare const getBaseURL: (url: string) => string;
6
6
  export declare const basename: (path: string) => string;
7
7
  export declare const secondBetweenTwoDate: (newDate: Date, oldDate: Date) => number;
8
- export declare const stringToSlug: (str: string, skipReplaceDots?: boolean) => string;
8
+ export declare const stringToSlug: (str: string, skipReplaceDots?: boolean, locale?: string) => string;
9
9
  export declare const pimLocaleMap: Partial<Record<PimLocale, ContentfulLocale>>;
10
10
  export declare const getLocale: (pimLocaleCode: PimLocale) => ContentfulLocale | null;
11
11
  export declare const getPimTranslations: (values: Partial<PimValues | PimProductDescription | PimProductExcerpt | AssetsEntity>, fieldKey?: "value" | "description" | "description1" | "description2" | "note" | "title" | "webNaming", defaultValue?: string, limit?: number) => CfLocalizedEntryField;
package/dist/utils.js CHANGED
@@ -22,7 +22,7 @@ const basename = (path) => {
22
22
  exports.basename = basename;
23
23
  const secondBetweenTwoDate = (newDate, oldDate) => Math.abs((newDate.getTime() - oldDate.getTime()) / 1000);
24
24
  exports.secondBetweenTwoDate = secondBetweenTwoDate;
25
- const stringToSlug = (str, skipReplaceDots = false) => {
25
+ const stringToSlug = (str, skipReplaceDots = false, locale = "en") => {
26
26
  str = str.replace(/^\s+|\s+$/g, "");
27
27
  str = str.toLowerCase();
28
28
  const from = "àáäâèéëêìíïîòóöôùúüûñçěščřžýúůďťň·/_,:;";
@@ -30,15 +30,18 @@ const stringToSlug = (str, skipReplaceDots = false) => {
30
30
  for (let i = 0, l = from.length; i < l; i++) {
31
31
  str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
32
32
  }
33
+ if (!locale.startsWith("zh")) {
34
+ str = str.replace(/[^a-z0-9. -]/g, "");
35
+ }
33
36
  str = str
34
- .replace(/[^a-z0-9. -]/g, "")
35
37
  .replace(/\s+/g, "-")
36
38
  .replace(/-+/g, "-")
37
39
  .replace(/\//g, "");
38
40
  if (!skipReplaceDots) {
39
- str = str
40
- .replace(".", "-")
41
- .replace(/[^a-z0-9 -]/g, "");
41
+ str = str.replace(".", "-");
42
+ if (!locale.startsWith("zh")) {
43
+ str = str.replace(/[^a-z0-9. -]/g, "");
44
+ }
42
45
  }
43
46
  return str;
44
47
  };
@@ -50,6 +53,7 @@ exports.pimLocaleMap = {
50
53
  es: "es",
51
54
  de: "de",
52
55
  fr: "fr",
56
+ zh: "zh",
53
57
  };
54
58
  const getLocale = (pimLocaleCode) => {
55
59
  return exports.pimLocaleMap[pimLocaleCode] || null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "5.4.1",
3
+ "version": "5.6.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",