pim-import 6.13.1 → 6.14.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.
@@ -1,14 +1,10 @@
1
- import { CfLocalizedEntryField, TopicDetailsResponse, TopicProductFieldsResponse, WrapperImageFields, AvailableCatalogs } from "../types";
1
+ import { CfLocalizedEntryField, TopicDetailsResponse, TopicProductFieldsResponse, WrapperImageFields, AvailableCatalogs, SubFamiliyDownloadButtons } from "../types";
2
2
  export type pageResponse = {
3
3
  slugs: {};
4
4
  type: string;
5
5
  details?: {};
6
+ downloadButtons?: SubFamiliyDownloadButtons;
6
7
  } | null;
7
- type downloadButton = {
8
- key: string;
9
- to: string;
10
- downloadType: string;
11
- };
12
8
  export type AlgoliaFamilyRecord = {
13
9
  objectID: string;
14
10
  names: CfLocalizedEntryField;
@@ -28,7 +24,7 @@ export type AlgoliaFamilyRecord = {
28
24
  productFieldsCn: TopicProductFieldsResponse[];
29
25
  isNew: boolean;
30
26
  priority: number;
31
- downloadButtons?: downloadButton[];
27
+ downloadButtons?: SubFamiliyDownloadButtons;
32
28
  destinations?: string[];
33
29
  lastSyncDate: string;
34
30
  };
@@ -67,10 +63,9 @@ export declare const reindexFamily: (topicFamilyEntryId: string) => Promise<{
67
63
  productFieldsCn: TopicProductFieldsResponse[];
68
64
  isNew: boolean;
69
65
  priority: number;
70
- downloadButtons?: downloadButton[] | undefined;
66
+ downloadButtons?: SubFamiliyDownloadButtons | undefined;
71
67
  destinations?: string[] | undefined;
72
68
  lastSyncDate: string;
73
69
  taskID: number;
74
70
  }>;
75
71
  export declare const removeFamilyObject: (objectId: string) => Promise<void>;
76
- export {};
@@ -6,6 +6,7 @@ const logs_1 = require("../libs/logs");
6
6
  const config_1 = require("./config");
7
7
  const utils_1 = require("../utils");
8
8
  const subfamilies_1 = require("../pim/methods/subfamilies");
9
+ const subFamilies_1 = require("./subFamilies");
9
10
  const imgix_1 = require("../libs/imgix");
10
11
  const indexKey = "families";
11
12
  const getFamilyPage = async (topicFamily) => {
@@ -45,11 +46,14 @@ const getFamilyPage = async (topicFamily) => {
45
46
  (0, logs_1.log)(`The modelPage with id "${modelPageId}" not found`, "WARN");
46
47
  }
47
48
  }
48
- const subFamilyEntry = await (0, contentful_cda_1.getEntryByID)(subFamilyPageId.replace("_PAGE", ""), "topicSubFamily", "sys,fields.catalog,fields.category,fields.parentFamily");
49
+ const subFamilyEntry = await (0, contentful_cda_1.getEntryByID)(subFamilyPageId.replace("_PAGE", ""), "topicSubFamily", "sys,fields.catalog,fields.category,fields.parentFamily,fields.leaflet,fields.datasheet,fields.specsheet_us");
49
50
  if (subFamilyEntry) {
50
51
  const subFamilyPageSlugWithDetails = await (0, subfamilies_1.getSubFamilyPageSlugWithDetails)(subFamilyEntry);
51
52
  if (subFamilyPageSlugWithDetails) {
52
- return subFamilyPageSlugWithDetails;
53
+ return {
54
+ ...subFamilyPageSlugWithDetails,
55
+ downloadButtons: (0, subFamilies_1.getDownloadButtons)(subFamilyEntry, defaultEnvironmentLocaleCode),
56
+ };
53
57
  }
54
58
  }
55
59
  else {
@@ -196,6 +200,7 @@ const getObject = async (topicFamily) => {
196
200
  productFieldsCn,
197
201
  priority,
198
202
  isNew,
203
+ downloadButtons: page?.downloadButtons || {},
199
204
  destinations: topicFamilyWithFields?.fields?.destinations?.[defaultEnvironmentLocaleCode] || [],
200
205
  lastSyncDate: (0, utils_1.getLocalISOTime)(),
201
206
  };
@@ -1,4 +1,6 @@
1
- import { AvailableCatalogs } from "../types";
1
+ import { AvailableCatalogs, SubFamiliyDownloadButtons } from "../types";
2
+ import type { Entry } from "contentful-management/dist/typings/entities/entry";
3
+ export declare const getDownloadButtons: (topicSubFamily: Entry, defaultEnvironmentLocaleCode: string) => SubFamiliyDownloadButtons;
2
4
  export declare const reindexSubFamilies: (offset?: number, limit?: number, catalogCode?: AvailableCatalogs) => Promise<{
3
5
  savedObjectIDs: string[];
4
6
  deletedObjectIDs: string[];
@@ -34,11 +36,7 @@ export declare const reindexSubFamily: (topicSubFamilyEntryId: string) => Promis
34
36
  productFieldsCn: import("../types").TopicProductFieldsResponse[];
35
37
  isNew: boolean;
36
38
  priority: number;
37
- downloadButtons?: {
38
- key: string;
39
- to: string;
40
- downloadType: string;
41
- }[] | undefined;
39
+ downloadButtons?: SubFamiliyDownloadButtons | undefined;
42
40
  destinations?: string[] | undefined;
43
41
  lastSyncDate: string;
44
42
  taskID: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeSubFamilyObject = exports.reindexSubFamily = exports.reindexSubFamilies = void 0;
3
+ exports.removeSubFamilyObject = exports.reindexSubFamily = exports.reindexSubFamilies = exports.getDownloadButtons = void 0;
4
4
  const contentful_cda_1 = require("../libs/contentful-cda");
5
5
  const logs_1 = require("../libs/logs");
6
6
  const config_1 = require("./config");
@@ -144,37 +144,35 @@ const isObjectToDelete = (object, defaultEnvironmentLocaleCode) => {
144
144
  return (!object?.productFields || !object?.slugs?.[defaultEnvironmentLocaleCode]);
145
145
  };
146
146
  const getDownloadButtons = (topicSubFamily, defaultEnvironmentLocaleCode) => {
147
- const downloadButtons = [];
147
+ const downloadButtons = {};
148
148
  const topicSubFamilyFields = topicSubFamily?.fields;
149
149
  if (topicSubFamilyFields?.leaflet?.[defaultEnvironmentLocaleCode]?.fields
150
150
  ?.file?.[defaultEnvironmentLocaleCode]?.url) {
151
- downloadButtons.push({
152
- key: "leaflet",
151
+ downloadButtons.leaflet = {
153
152
  to: topicSubFamilyFields.leaflet?.[defaultEnvironmentLocaleCode]?.fields
154
153
  ?.file?.[defaultEnvironmentLocaleCode]?.url,
155
154
  downloadType: "pdf",
156
- });
155
+ };
157
156
  }
158
157
  if (topicSubFamilyFields?.datasheet?.[defaultEnvironmentLocaleCode]?.fields
159
158
  ?.file?.[defaultEnvironmentLocaleCode]?.url) {
160
- downloadButtons.push({
161
- key: "datasheet",
159
+ downloadButtons.datasheet = {
162
160
  to: topicSubFamilyFields.datasheet?.[defaultEnvironmentLocaleCode]?.fields
163
161
  ?.file?.[defaultEnvironmentLocaleCode]?.url,
164
162
  downloadType: "pdf",
165
- });
163
+ };
166
164
  }
167
165
  if (topicSubFamilyFields?.specsheet_us?.[defaultEnvironmentLocaleCode]?.fields
168
166
  ?.file?.[defaultEnvironmentLocaleCode]?.url) {
169
- downloadButtons.push({
170
- key: "specsheet_us",
167
+ downloadButtons.specsheet_us = {
171
168
  to: topicSubFamilyFields.specsheet_us?.[defaultEnvironmentLocaleCode]
172
169
  ?.fields?.file?.[defaultEnvironmentLocaleCode]?.url,
173
170
  downloadType: "pdf",
174
- });
171
+ };
175
172
  }
176
173
  return downloadButtons;
177
174
  };
175
+ exports.getDownloadButtons = getDownloadButtons;
178
176
  const getObject = async (topicSubFamily) => {
179
177
  const defaultEnvironmentLocaleCode = await (0, contentful_cda_1.getEnvironmentDefaultLocaleCode)();
180
178
  (0, logs_1.log)(`Get details of the ${topicSubFamily.sys.id} topicSubFamily`);
@@ -248,7 +246,7 @@ const getObject = async (topicSubFamily) => {
248
246
  (0, logs_1.log)(`Get priority details...`);
249
247
  const priority = topicSubFamilyWithFields?.fields?.priority?.[defaultEnvironmentLocaleCode] || 0;
250
248
  (0, logs_1.log)(`Get download buttons details...`);
251
- const downloadButtons = getDownloadButtons(topicSubFamilyWithFields, defaultEnvironmentLocaleCode);
249
+ const downloadButtons = (0, exports.getDownloadButtons)(topicSubFamilyWithFields, defaultEnvironmentLocaleCode);
252
250
  const record = {
253
251
  objectID: topicSubFamilyWithFields.sys.id,
254
252
  names: await (0, utils_1.getAllTranslations)(topicSubFamilyWithFields?.fields?.name || {}),
package/dist/types.d.ts CHANGED
@@ -196,3 +196,17 @@ export type AlgoliaObjectFilter = {
196
196
  key: string;
197
197
  value: string;
198
198
  };
199
+ export type SubFamiliyDownloadButtons = {
200
+ leaflet?: {
201
+ to: string;
202
+ downloadType: string;
203
+ };
204
+ datasheet?: {
205
+ to: string;
206
+ downloadType: string;
207
+ };
208
+ specsheet_us?: {
209
+ to: string;
210
+ downloadType: string;
211
+ };
212
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pim-import",
3
- "version": "6.13.1",
3
+ "version": "6.14.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",