pim-import 6.4.0 → 6.7.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.
@@ -10,4 +10,5 @@ export declare const removeRecordsByStatus: (indexKey: AvailableIndicesKey, offs
10
10
  s3FilePath?: string | undefined;
11
11
  total?: number | undefined;
12
12
  nextPage?: number | null | undefined;
13
+ totalPages?: number | null | undefined;
13
14
  }>;
@@ -41,5 +41,6 @@ export declare const reindexDownloads: (offset?: number, limit?: number, filterK
41
41
  s3FilePath?: string | undefined;
42
42
  total?: number | undefined;
43
43
  nextPage?: number | null | undefined;
44
+ totalPages?: number | null | undefined;
44
45
  }>;
45
46
  export declare const removeDownloadObject: (objectId: string) => Promise<void>;
@@ -38,6 +38,7 @@ export declare const reindexFamilies: (offset?: number, limit?: number, catalogC
38
38
  s3FilePath?: string | undefined;
39
39
  total?: number | undefined;
40
40
  nextPage?: number | null | undefined;
41
+ totalPages?: number | null | undefined;
41
42
  }>;
42
43
  export declare const reindexFamily: (topicFamilyEntryId: string) => Promise<{
43
44
  taskID: number;
@@ -40,5 +40,6 @@ export declare const reindexInspirations: (offset?: number, limit?: number, filt
40
40
  s3FilePath?: string | undefined;
41
41
  total?: number | undefined;
42
42
  nextPage?: number | null | undefined;
43
+ totalPages?: number | null | undefined;
43
44
  }>;
44
45
  export declare const removeInspirationObject: (objectId: string) => Promise<void>;
@@ -35,5 +35,6 @@ export declare const reindexModels: (offset?: number, limit?: number, catalogCod
35
35
  s3FilePath?: string | undefined;
36
36
  total?: number | undefined;
37
37
  nextPage?: number | null | undefined;
38
+ totalPages?: number | null | undefined;
38
39
  }>;
39
40
  export declare const removeModelObject: (topicModelId: string) => Promise<void>;
@@ -36,5 +36,6 @@ export declare const reindexPosts: (offset?: number, limit?: number, filterKey?:
36
36
  s3FilePath?: string | undefined;
37
37
  total?: number | undefined;
38
38
  nextPage?: number | null | undefined;
39
+ totalPages?: number | null | undefined;
39
40
  }>;
40
41
  export declare const removePostObject: (objectId: string) => Promise<void>;
@@ -34,5 +34,6 @@ export declare const reindexPressReleases: (offset?: number, limit?: number, fil
34
34
  s3FilePath?: string | undefined;
35
35
  total?: number | undefined;
36
36
  nextPage?: number | null | undefined;
37
+ totalPages?: number | null | undefined;
37
38
  }>;
38
39
  export declare const removePressReleaseObject: (objectId: string) => Promise<void>;
@@ -34,5 +34,6 @@ export declare const reindexPressReviews: (offset?: number, limit?: number, filt
34
34
  s3FilePath?: string | undefined;
35
35
  total?: number | undefined;
36
36
  nextPage?: number | null | undefined;
37
+ totalPages?: number | null | undefined;
37
38
  }>;
38
39
  export declare const removePressReviewObject: (objectId: string) => Promise<void>;
@@ -89,5 +89,6 @@ export declare const reindexProducts: (filterKey: string, filterValue: string, o
89
89
  s3FilePath?: string | undefined;
90
90
  total?: number | undefined;
91
91
  nextPage?: number | null | undefined;
92
+ totalPages?: number | null | undefined;
92
93
  }>;
93
94
  export declare const removeProductObject: (topicProductId: string) => Promise<void>;
@@ -52,5 +52,6 @@ export declare const reindexProjects: (offset?: number, limit?: number, filterKe
52
52
  s3FilePath?: string | undefined;
53
53
  total?: number | undefined;
54
54
  nextPage?: number | null | undefined;
55
+ totalPages?: number | null | undefined;
55
56
  }>;
56
57
  export declare const removeProjectObject: (objectId: string) => Promise<void>;
@@ -48,5 +48,6 @@ export declare const reindexStories: (offset?: number, limit?: number, filterKey
48
48
  s3FilePath?: string | undefined;
49
49
  total?: number | undefined;
50
50
  nextPage?: number | null | undefined;
51
+ totalPages?: number | null | undefined;
51
52
  }>;
52
53
  export declare const removeStoryObject: (objectId: string) => Promise<void>;
@@ -11,6 +11,7 @@ export declare const reindexSubFamilies: (offset?: number, limit?: number, catal
11
11
  s3FilePath?: string | undefined;
12
12
  total?: number | undefined;
13
13
  nextPage?: number | null | undefined;
14
+ totalPages?: number | null | undefined;
14
15
  }>;
15
16
  export declare const reindexSubFamily: (topicSubFamilyEntryId: string) => Promise<{
16
17
  taskID: number;
@@ -29,5 +29,6 @@ export declare const reindexSubModels: (offset?: number, limit?: number, catalog
29
29
  s3FilePath?: string | undefined;
30
30
  total?: number | undefined;
31
31
  nextPage?: number | null | undefined;
32
+ totalPages?: number | null | undefined;
32
33
  }>;
33
34
  export declare const removeSubModelObject: (topicSubModelId: string) => Promise<void>;
package/dist/libs/s3.js CHANGED
@@ -153,9 +153,9 @@ const saveCatalogToS3 = async (catalog) => {
153
153
  const timeStart = new Date();
154
154
  const dateNow = new Date();
155
155
  const dateDirName = dateNow.toISOString().split("T")[0];
156
- const path = `pim/${dateDirName}/catalog/`;
156
+ const path = `pim/${dateDirName}/catalog/${process.env.FPI_CTF_ENVIRONMENT ? process.env.FPI_CTF_ENVIRONMENT + "/" : ""}`;
157
157
  const fileName = `catalogs-${catalog}.json`;
158
- const fileUrl = `${config_1.config.baseURL}catalogs?onlyweb=true&catalog=${catalog}`;
158
+ const fileUrl = `${config_1.config.baseURL}micro-service/dictionary/get/catalogs?onlyWeb=true&catalog=${catalog}`;
159
159
  (0, logs_1.log)(`Uploading "${fileName}" to S3 path "${path}"`, "INFO");
160
160
  await (0, exports.upload)(fileUrl, fileName, path);
161
161
  (0, logs_1.log)(`"${fileName}" saved to S3`);
@@ -21,8 +21,8 @@ const getCatalogTaxonomiesHierarchy = async (catalogCode, jsonFile) => {
21
21
  const timeStart = new Date();
22
22
  let data;
23
23
  if (!jsonFile) {
24
- const res = await (0, request_1.getRequest)("catalogs", {
25
- params: { onlyweb: true, catalog: catalogCode },
24
+ const res = await (0, request_1.getRequest)("micro-service/dictionary/get/catalogs", {
25
+ params: { onlyWeb: true, catalog: catalogCode },
26
26
  });
27
27
  data = res.data;
28
28
  }
@@ -32,7 +32,7 @@ const getCatalogTaxonomiesHierarchy = async (catalogCode, jsonFile) => {
32
32
  const catalogData = data.find((item) => item.data.code === catalogCode);
33
33
  const timeEnd = new Date();
34
34
  const seconds = (0, utils_1.secondBetweenTwoDate)(timeStart, timeEnd);
35
- (0, logs_1.log)(`Request time: ${seconds} seconds - endpoint: catalogs`);
35
+ (0, logs_1.log)(`Request time: ${seconds} seconds - endpoint: micro-service/dictionary/get/catalogs`);
36
36
  if (!catalogData) {
37
37
  throw new Error(`No catalog data found. Catalog code: ${catalogCode}`);
38
38
  }
@@ -88,7 +88,7 @@ const getLatestProducts = async (catalogCode, lastModified, offset = 0, limit =
88
88
  try {
89
89
  const timeStart = new Date();
90
90
  const opts = {
91
- onlyweb: true,
91
+ onlyWeb: true,
92
92
  lastModified,
93
93
  catalog: catalogCode,
94
94
  page: offset,
@@ -36,6 +36,7 @@ const importLatestProducts = async (catalog, lastModified, page = 0, limit = 100
36
36
  limit,
37
37
  completed,
38
38
  total,
39
+ totalPages: data.totalPages,
39
40
  };
40
41
  };
41
42
  exports.importLatestProducts = importLatestProducts;
@@ -1,2 +1,2 @@
1
1
  import { PaginationResults } from "../../types";
2
- export declare const importModels: (offset?: number, limit?: number) => Promise<PaginationResults>;
2
+ export declare const importModels: (page?: number, size?: number) => Promise<PaginationResults>;
@@ -87,7 +87,7 @@ const getTopicModelData = async (model, topicModel) => {
87
87
  (0, logs_1.log)(`topicProductLine with code ${model.productLineCode} not found`, "WARN");
88
88
  }
89
89
  }
90
- if (model.designers.length) {
90
+ if (model?.designers?.length) {
91
91
  const designerCode = model.designers[0].code;
92
92
  const designerEntry = await (0, contentful_1.getEntryByCode)(designerCode, "topicDesigner", "sys,fields.code");
93
93
  if (designerEntry) {
@@ -139,25 +139,25 @@ const importModel = async (model) => {
139
139
  }
140
140
  return topicModel;
141
141
  };
142
- const importModels = async (offset = 0, limit = 40) => {
143
- (0, logs_1.log)(`importModels - offset: ${offset}, limit: ${limit}`, "INFO");
144
- const models = await (0, endpoints_1.getOtherCatalogData)("models", offset, limit);
145
- const total = models?.pagedCollection?.length || 0;
146
- if (models?.pagedCollection?.length) {
142
+ const importModels = async (page = 0, size = 40) => {
143
+ (0, logs_1.log)(`importModels - page: ${page}, size: ${size}`, "INFO");
144
+ const models = await (0, endpoints_1.getOtherCatalogData)("models", page, size, true);
145
+ const total = models?.content?.length || 0;
146
+ if (models?.content?.length) {
147
147
  (0, logs_1.log)(`Founded ${total} models`);
148
- let count = offset;
148
+ let count = page * size;
149
149
  let current = 0;
150
- for (const model of models.pagedCollection) {
151
- (0, logs_1.log)(`${++count} of ${models.totalCount}`);
150
+ for (const model of models.content) {
151
+ (0, logs_1.log)(`${++count} of ${models.totalElements}`);
152
152
  const topicModel = await importModel(model);
153
153
  await createOrUpdatePage(topicModel);
154
154
  await updateComponentModelOfSubFamilyPages(topicModel);
155
155
  if (logs_1.serverUtils) {
156
156
  logs_1.serverUtils.log(model.code);
157
- const progress = Math.floor((++current / models.pagedCollection.length) * 100);
157
+ const progress = Math.floor((++current / models.content.length) * 100);
158
158
  logs_1.serverUtils.updateProgress(progress);
159
159
  }
160
- if (count % 2 === 0 && count < models.totalCount) {
160
+ if (count % 2 === 0 && count < models.totalElements) {
161
161
  await (0, utils_1.sleep)(1000);
162
162
  }
163
163
  }
@@ -165,12 +165,13 @@ const importModels = async (offset = 0, limit = 40) => {
165
165
  else {
166
166
  (0, logs_1.log)(`No models found`);
167
167
  }
168
- const nextOffset = Number(offset) + Number(limit);
168
+ const nextPage = Number(page) + 1;
169
169
  return {
170
- offset: nextOffset,
171
- limit: Number(limit),
172
- completed: nextOffset >= models.totalCount,
173
- total: models.totalCount,
170
+ page: nextPage,
171
+ size: Number(size),
172
+ completed: nextPage >= models.totalPages,
173
+ total: models.totalElements,
174
+ totalPages: models.totalPages,
174
175
  };
175
176
  };
176
177
  exports.importModels = importModels;
@@ -252,6 +252,7 @@ const importSubFamilies = async (page = 0, size = 50, catalog) => {
252
252
  size: Number(size),
253
253
  completed: nextPage >= subFamilies.totalPages,
254
254
  total: subFamilies.totalElements,
255
+ totalPages: subFamilies.totalPages,
255
256
  };
256
257
  };
257
258
  exports.importSubFamilies = importSubFamilies;
@@ -5,6 +5,7 @@ export interface CatalogDetails {
5
5
  export interface Data {
6
6
  code: string;
7
7
  value_en: string;
8
+ value_en_US: string;
8
9
  value_it: string;
9
10
  value_es: string;
10
11
  value_de: string;
@@ -13,34 +14,22 @@ export interface Data {
13
14
  value_no: string;
14
15
  value_da: string;
15
16
  value_ru: string;
16
- othersData: OthersData;
17
- }
18
- export interface OthersData {
17
+ value_zh: string;
18
+ value_ja: string;
19
+ value_ko: string;
19
20
  }
20
21
  export interface CategoriesEntity {
21
22
  data: Data;
22
- subfamilies?: (SubfamiliesEntity | null)[] | null;
23
+ subfamilies?: SubfamiliesEntity[] | null;
23
24
  }
24
25
  export interface SubfamiliesEntity {
25
- data: FamilyData;
26
- childfamilies?: (ChildfamiliesEntity | null)[] | null;
27
- designers?: null[] | null;
28
- parentFamily?: FamilyData | null;
29
- }
30
- export interface FamilyData {
31
- code: string;
32
- value_en: string;
33
- value_en_US?: string | null;
34
- value_it: string;
35
- value_es: string;
36
- value_de: string;
37
- value_fr: string;
38
- value_sv: string;
39
- value_no: string;
40
- value_da: string;
41
- value_ru: string;
42
- othersData: OthersData;
26
+ data: Data;
27
+ parentFamily?: ParentFamily | null;
28
+ designers?: Data[] | null;
29
+ destinations?: string[] | null;
43
30
  }
44
- export interface ChildfamiliesEntity {
31
+ export interface ParentFamily {
45
32
  data: Data;
33
+ designers?: Data[] | null;
34
+ destinations?: string[] | null;
46
35
  }
@@ -1,29 +1,32 @@
1
1
  export interface CollectionModels {
2
- totalCount: number;
3
- pageSize: number;
4
- pageOffset: number;
5
- pagedCollection?: PagedCollectionEntity[] | null;
2
+ content: ModelEntity[];
3
+ page: number;
4
+ size: number;
5
+ totalElements: number;
6
+ totalPages: number;
6
7
  }
7
- export interface PagedCollectionEntity {
8
- designers: Data[];
9
- relatedProducts?: string[] | null;
8
+ export interface ModelEntity {
10
9
  data: Data;
11
- priority?: number | null;
10
+ destinations?: string[] | null;
11
+ relatedProducts?: string[] | null;
12
12
  subFamilyCode: string;
13
13
  productLineCode: string;
14
+ designers?: Data[] | null;
15
+ priority?: number | null;
14
16
  code: string;
15
- othersData: OthersData;
16
- description1_en?: string;
17
- description1_en_us?: string;
18
- description1_it?: string;
19
- description1_es?: string;
20
- description1_de?: string;
21
- description1_fr?: string;
22
- description1_sv?: string;
23
- description1_no?: string;
24
- description1_da?: string;
25
- description1_ru?: string;
26
- destinations?: string[];
17
+ description1_en?: string | null;
18
+ description1_en_us?: string | null;
19
+ description1_it?: string | null;
20
+ description1_es?: string | null;
21
+ description1_de?: string | null;
22
+ description1_fr?: string | null;
23
+ description1_sv?: string | null;
24
+ description1_no?: string | null;
25
+ description1_da?: string | null;
26
+ description1_ru?: string | null;
27
+ description1_zh?: string | null;
28
+ description1_ja?: string | null;
29
+ description1_ko?: string | null;
27
30
  }
28
31
  export interface Data {
29
32
  code: string;
@@ -37,7 +40,7 @@ export interface Data {
37
40
  value_no: string;
38
41
  value_da: string;
39
42
  value_ru: string;
40
- othersData: OthersData;
41
- }
42
- export interface OthersData {
43
+ value_zh: string;
44
+ value_ja: string;
45
+ value_ko: string;
43
46
  }
package/dist/types.d.ts CHANGED
@@ -69,6 +69,7 @@ export type PaginationResults = {
69
69
  s3FilePath?: string;
70
70
  total?: number;
71
71
  nextPage?: number | null;
72
+ totalPages?: number | null;
72
73
  };
73
74
  export type CfLocalizedEntryField = Partial<Record<ContentfulLocale, string | null>>;
74
75
  export type TopicDetailsResponse = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "6.4.0",
3
+ "version": "6.7.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",