pim-import 6.7.0 → 6.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.
@@ -54,7 +54,7 @@ const getTopicModelData = async (model, topicModel) => {
54
54
  };
55
55
  data.fields.name = (0, utils_1.getPimTranslations)(model.data);
56
56
  data.fields = await (0, contentful_1.addFieldValue)(data, "code", model.code);
57
- data.fields = await (0, contentful_1.addFieldValue)(data, "priority", model.priority);
57
+ data.fields = await (0, contentful_1.addFieldValue)(data, "priority", model?.priority || 0);
58
58
  data.fields.description = (0, utils_1.getPimTranslations)(model, "description1");
59
59
  if (model.subFamilyCode) {
60
60
  const subFamilyEntry = await (0, contentful_1.getEntryByCode)(model.subFamilyCode, "topicSubFamily", "sys,fields.code,fields.catalog");
@@ -1,2 +1,2 @@
1
1
  import { PaginationResults } from "../../types";
2
- export declare const importSubModels: (offset?: number, limit?: number) => Promise<PaginationResults>;
2
+ export declare const importSubModels: (page?: number, size?: number) => Promise<PaginationResults>;
@@ -12,7 +12,7 @@ const getTopicSubModelData = async (subModel, topicSubModel) => {
12
12
  };
13
13
  data.fields.name = (0, utils_1.getPimTranslations)(subModel.data);
14
14
  data.fields = await (0, contentful_1.addFieldValue)(data, "code", subModel.code);
15
- data.fields = await (0, contentful_1.addFieldValue)(data, "priority", subModel.priority);
15
+ data.fields = await (0, contentful_1.addFieldValue)(data, "priority", subModel?.priority || 0);
16
16
  if (subModel.subFamilyCode) {
17
17
  const subFamilyEntry = await (0, contentful_1.getEntryByCode)(subModel.subFamilyCode, "topicSubFamily", "sys,fields.code,fields.catalog");
18
18
  if (subFamilyEntry) {
@@ -85,37 +85,38 @@ const addSubModelToModel = async (topicSubModelId, topicModelId) => {
85
85
  data.fields = await (0, contentful_1.addToRelationFields)(topicModel, "subModels", topicSubModelId, true);
86
86
  topicModel = await (0, contentful_1.updateEntry)(topicModel, data, topicModel.isPublished());
87
87
  };
88
- const importSubModels = async (offset = 0, limit = 50) => {
88
+ const importSubModels = async (page = 0, size = 50) => {
89
89
  const timeStart = new Date();
90
- (0, logs_1.log)(`importSubModels - offset: ${offset}, limit: ${limit}`, "INFO");
91
- const subModels = await (0, endpoints_1.getOtherCatalogData)("submodels", offset, limit);
92
- const total = subModels?.pagedCollection?.length || 0;
93
- if (subModels?.pagedCollection?.length) {
90
+ (0, logs_1.log)(`importSubModels - page: ${page}, size: ${size}`, "INFO");
91
+ const subModels = await (0, endpoints_1.getOtherCatalogData)("submodels", page, size, true);
92
+ const total = subModels?.content?.length || 0;
93
+ if (subModels?.content?.length) {
94
94
  (0, logs_1.log)(`Founded ${total} subModels`);
95
- let count = offset;
95
+ let count = page * size;
96
96
  let current = 0;
97
- for (const subModel of subModels.pagedCollection) {
98
- (0, logs_1.log)(`${++count} of ${subModels.totalCount}`);
97
+ for (const subModel of subModels.content) {
98
+ (0, logs_1.log)(`${++count} of ${subModels.totalElements}`);
99
99
  await importSubModel(subModel);
100
100
  if (logs_1.serverUtils) {
101
101
  logs_1.serverUtils.log(subModel.code);
102
- const progress = Math.floor((++current / subModels.pagedCollection.length) * 100);
102
+ const progress = Math.floor((++current / subModels.content.length) * 100);
103
103
  logs_1.serverUtils.updateProgress(progress);
104
104
  }
105
- if (count % 2 === 0 && count < subModels.totalCount) {
105
+ if (count % 2 === 0 && count < subModels.totalElements) {
106
106
  await (0, utils_1.sleep)(1000);
107
107
  }
108
108
  }
109
109
  }
110
- const nextOffset = Number(offset) + Number(limit);
111
110
  const timeEnd = new Date();
112
111
  const seconds = (0, utils_1.secondBetweenTwoDate)(timeStart, timeEnd);
113
112
  (0, logs_1.log)(`Request time: ${seconds} seconds`);
113
+ const nextPage = Number(page) + 1;
114
114
  return {
115
- offset: nextOffset,
116
- limit: Number(limit),
117
- completed: nextOffset >= subModels.totalCount,
118
- total: subModels.totalCount,
115
+ page: nextPage,
116
+ size: Number(size),
117
+ completed: nextPage >= subModels.totalPages,
118
+ total: subModels.totalElements,
119
+ totalPages: subModels.totalPages,
119
120
  };
120
121
  };
121
122
  exports.importSubModels = importSubModels;
@@ -1,19 +1,19 @@
1
1
  export interface CollectionSubModels {
2
- totalCount: number;
3
- pageSize: number;
4
- pageOffset: number;
5
- pagedCollection?: PagedCollectionEntity[] | null;
2
+ content: SubModelEntity[];
3
+ page: number;
4
+ size: number;
5
+ totalElements: number;
6
+ totalPages: number;
6
7
  }
7
- export interface PagedCollectionEntity {
8
- relatedProducts?: string[] | null;
8
+ export interface SubModelEntity {
9
9
  data: Data;
10
- priority: number;
10
+ destinations?: string[] | null;
11
+ relatedProducts?: string[] | null;
12
+ code: string;
13
+ priority?: number | null;
11
14
  subFamilyCode: string;
12
15
  productLineCode: string;
13
16
  parentModel: ParentModel;
14
- code: string;
15
- othersData: OthersData;
16
- destinations?: string[];
17
17
  }
18
18
  export interface Data {
19
19
  code: string;
@@ -27,11 +27,11 @@ export interface Data {
27
27
  value_no: string;
28
28
  value_da: string;
29
29
  value_ru: string;
30
- othersData: OthersData;
31
- }
32
- export interface OthersData {
30
+ value_zh: string;
31
+ value_ja: string;
32
+ value_ko: string;
33
33
  }
34
34
  export interface ParentModel {
35
35
  code: string;
36
- othersData: OthersData;
36
+ designers?: Data[] | null;
37
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "6.7.0",
3
+ "version": "6.8.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",