pim-import 6.5.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.
@@ -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>;
@@ -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>;
@@ -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");
@@ -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;
@@ -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,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
  }
@@ -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/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.5.0",
3
+ "version": "6.8.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",