pim-import 3.4.5 → 4.1.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.
- package/.env.example +4 -3
- package/dist/algolia/families.js +4 -0
- package/dist/algolia/families.js.map +1 -1
- package/dist/algolia/products.js +18 -9
- package/dist/algolia/products.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/libs/contentful.js +9 -1
- package/dist/libs/contentful.js.map +1 -1
- package/dist/libs/puppeteer.js +18 -12
- package/dist/libs/puppeteer.js.map +1 -1
- package/dist/pim/methods/products.js +39 -26
- package/dist/pim/methods/products.js.map +1 -1
- package/package.json +1 -1
- package/src/algolia/families.ts +6 -0
- package/src/algolia/products.ts +21 -12
- package/src/index.ts +1 -0
- package/src/libs/contentful.ts +18 -0
- package/src/libs/puppeteer.ts +36 -18
- package/src/pim/methods/products.ts +53 -28
- package/src/resources/ProductDetails.ts +1 -0
- package/types/algolia/families.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/libs/contentful.d.ts +3 -1
- package/types/libs/puppeteer.d.ts +10 -3
- package/types/resources/ProductDetails.d.ts +1 -0
|
@@ -400,7 +400,8 @@ export const excludeCertificationFieldsKeys = [
|
|
|
400
400
|
"fMarking",
|
|
401
401
|
];
|
|
402
402
|
|
|
403
|
-
const getProductFields = (pimDetails: any) => {
|
|
403
|
+
const getProductFields = async (pimDetails: any) => {
|
|
404
|
+
const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
|
|
404
405
|
const productFields: any = {};
|
|
405
406
|
productFieldsRequiredData.forEach((fieldData) => {
|
|
406
407
|
if (fieldData.parent) {
|
|
@@ -410,13 +411,18 @@ const getProductFields = (pimDetails: any) => {
|
|
|
410
411
|
) {
|
|
411
412
|
if (Array.isArray(pimDetails[fieldData.parent][fieldData.key])) {
|
|
412
413
|
pimDetails[fieldData.parent][fieldData.key].forEach((item: any) => {
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
|
|
414
|
+
if (
|
|
415
|
+
item.code &&
|
|
416
|
+
sanitizeValue(item.code) &&
|
|
417
|
+
sanitizeValue(item[`value_${defaultEnvironmentLocaleCode}`])
|
|
418
|
+
) {
|
|
419
|
+
if (!productFields?.[fieldData.parent]?.[fieldData.key]) {
|
|
420
|
+
if (!productFields?.[fieldData.parent]) {
|
|
421
|
+
productFields[fieldData.parent] = {};
|
|
422
|
+
}
|
|
423
|
+
productFields[fieldData.parent][fieldData.key] = [];
|
|
416
424
|
}
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
if (item.code && sanitizeValue(item.code)) {
|
|
425
|
+
|
|
420
426
|
productFields[fieldData.parent][fieldData.key].push({
|
|
421
427
|
code: item.code,
|
|
422
428
|
});
|
|
@@ -426,7 +432,12 @@ const getProductFields = (pimDetails: any) => {
|
|
|
426
432
|
let value: any = "";
|
|
427
433
|
if (
|
|
428
434
|
pimDetails?.[fieldData.parent]?.[fieldData.key]?.code &&
|
|
429
|
-
sanitizeValue(pimDetails[fieldData.parent][fieldData.key].code)
|
|
435
|
+
sanitizeValue(pimDetails[fieldData.parent][fieldData.key].code) &&
|
|
436
|
+
sanitizeValue(
|
|
437
|
+
pimDetails[fieldData.parent][fieldData.key][
|
|
438
|
+
`value_${defaultEnvironmentLocaleCode}`
|
|
439
|
+
]
|
|
440
|
+
)
|
|
430
441
|
) {
|
|
431
442
|
value = {
|
|
432
443
|
code:
|
|
@@ -442,11 +453,13 @@ const getProductFields = (pimDetails: any) => {
|
|
|
442
453
|
value = pimDetails[fieldData.parent][fieldData.key];
|
|
443
454
|
}
|
|
444
455
|
|
|
445
|
-
if (
|
|
446
|
-
productFields[fieldData.parent]
|
|
447
|
-
|
|
456
|
+
if (value) {
|
|
457
|
+
if (!productFields[fieldData.parent]) {
|
|
458
|
+
productFields[fieldData.parent] = {};
|
|
459
|
+
}
|
|
448
460
|
|
|
449
|
-
|
|
461
|
+
productFields[fieldData.parent][fieldData.key] = value;
|
|
462
|
+
}
|
|
450
463
|
}
|
|
451
464
|
} else {
|
|
452
465
|
log(
|
|
@@ -457,10 +470,14 @@ const getProductFields = (pimDetails: any) => {
|
|
|
457
470
|
if (pimDetails?.[fieldData.key]) {
|
|
458
471
|
if (Array.isArray(pimDetails[fieldData.key])) {
|
|
459
472
|
pimDetails[fieldData.key].forEach((item: any) => {
|
|
460
|
-
if (
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
473
|
+
if (
|
|
474
|
+
item.code &&
|
|
475
|
+
sanitizeValue(item.code) &&
|
|
476
|
+
sanitizeValue(item[`value_${defaultEnvironmentLocaleCode}`])
|
|
477
|
+
) {
|
|
478
|
+
if (!productFields?.[fieldData.key]) {
|
|
479
|
+
productFields[fieldData.key] = [];
|
|
480
|
+
}
|
|
464
481
|
productFields[fieldData.key].push({
|
|
465
482
|
code: item.code,
|
|
466
483
|
});
|
|
@@ -470,7 +487,10 @@ const getProductFields = (pimDetails: any) => {
|
|
|
470
487
|
let value: any = "";
|
|
471
488
|
if (
|
|
472
489
|
pimDetails[fieldData.key]?.code &&
|
|
473
|
-
sanitizeValue(pimDetails[fieldData.key].code)
|
|
490
|
+
sanitizeValue(pimDetails[fieldData.key].code) &&
|
|
491
|
+
sanitizeValue(
|
|
492
|
+
pimDetails[fieldData.key][`value_${defaultEnvironmentLocaleCode}`]
|
|
493
|
+
)
|
|
474
494
|
) {
|
|
475
495
|
value = {
|
|
476
496
|
code:
|
|
@@ -485,7 +505,9 @@ const getProductFields = (pimDetails: any) => {
|
|
|
485
505
|
) {
|
|
486
506
|
value = pimDetails[fieldData.key];
|
|
487
507
|
}
|
|
488
|
-
|
|
508
|
+
if (value) {
|
|
509
|
+
productFields[fieldData.key] = value;
|
|
510
|
+
}
|
|
489
511
|
}
|
|
490
512
|
} else {
|
|
491
513
|
log(`${fieldData.key} product field not found on the pim`);
|
|
@@ -633,7 +655,7 @@ const getProductData = async (
|
|
|
633
655
|
const { currentCatalog, ...pimDetails } = productDetails;
|
|
634
656
|
|
|
635
657
|
log(`Set productFields`);
|
|
636
|
-
const productFields = getProductFields(pimDetails);
|
|
658
|
+
const productFields = await getProductFields(pimDetails);
|
|
637
659
|
data.fields = await addFieldValue(data, "productFields", productFields);
|
|
638
660
|
|
|
639
661
|
// catalogs
|
|
@@ -903,6 +925,8 @@ const getProductData = async (
|
|
|
903
925
|
}
|
|
904
926
|
|
|
905
927
|
log(`The new imgix url is: ${newImgixUrl}`);
|
|
928
|
+
} else {
|
|
929
|
+
log(`wrapperImgix basename matched`);
|
|
906
930
|
}
|
|
907
931
|
} else {
|
|
908
932
|
log(
|
|
@@ -1945,16 +1969,17 @@ export const generateTechSpecPdf = async (topicProductId: string) => {
|
|
|
1945
1969
|
);
|
|
1946
1970
|
log(`pdpSiteUrl: ${pdpSiteUrl}`);
|
|
1947
1971
|
const contents = {
|
|
1948
|
-
header: {
|
|
1949
|
-
|
|
1950
|
-
},
|
|
1972
|
+
// header: {
|
|
1973
|
+
// right: "Technical Specifications",
|
|
1974
|
+
// },
|
|
1951
1975
|
footer: {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1976
|
+
topLeft: `<a style="text-decoration: none; color:#000" href="${pdpSiteUrl}">${pdpSiteUrl}</a>`,
|
|
1977
|
+
topRight: topicProductId,
|
|
1978
|
+
bottomLeft: ``,
|
|
1979
|
+
bottomRight: ``,
|
|
1980
|
+
mail: topicCatalogIds.includes("OUTDOOR")
|
|
1981
|
+
? "flos.outdoor@flos.com"
|
|
1982
|
+
: "info@flos.com",
|
|
1958
1983
|
},
|
|
1959
1984
|
};
|
|
1960
1985
|
|
|
@@ -29,7 +29,7 @@ export declare const reindexFamilies: (offset?: number, limit?: number, catalogC
|
|
|
29
29
|
s3FilePath?: string | undefined;
|
|
30
30
|
total?: number | undefined;
|
|
31
31
|
}>;
|
|
32
|
-
export declare const reindexFamily: (topicFamilyEntryId: string) => Promise<{
|
|
32
|
+
export declare const reindexFamily: (topicFamilyEntryId: string) => Promise<false | {
|
|
33
33
|
objectID: string;
|
|
34
34
|
names: CfLocalizedEntryField;
|
|
35
35
|
code: string;
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { init as initPim } from "./pim/config";
|
|
2
|
-
export { init as initContentful, initBaseEntries, deletePages, deleteEntries, getEntryByID, getTopicPage, } from "./libs/contentful";
|
|
2
|
+
export { init as initContentful, initBaseEntries, deletePages, deleteEntries, getEntryByID, getTopicPage, getEntries, } from "./libs/contentful";
|
|
3
3
|
export { init as initS3, upload as uploadS3, saveJsonToS3, getFileFromS3, savePDFToS3, } from "./libs/s3";
|
|
4
4
|
export { importDictionaryFields, importDictionaryIcons, importDictionaryProductLine, importDictionaryProductSubLine, } from "./pim/methods/dictionary";
|
|
5
5
|
export { importCategories } from "./pim/methods/catalogs";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Entry, CreateEntryProps } from "contentful-management/dist/typings/entities/entry";
|
|
1
|
+
import type { Entry, CreateEntryProps, EntryProps } from "contentful-management/dist/typings/entities/entry";
|
|
2
|
+
import type { QueryOptions } from "contentful-management/dist/typings/common-types";
|
|
2
3
|
import { Environment, Locale, CreateAssetProps } from "contentful-management/types";
|
|
3
4
|
import { ContentfulLocale, AvailableCatalogs, TopicDetailsResponse, AssetPropFields, OtherFilters, WrapperImageFields } from "../types";
|
|
4
5
|
import { GenericData } from "../resources/ProductDetails";
|
|
@@ -57,3 +58,4 @@ export declare const createWrapperImgix: (id: string, data: WrapperImageFields)
|
|
|
57
58
|
export declare const archiveEntry: (entry: Entry, isProduct?: boolean) => Promise<Entry>;
|
|
58
59
|
export declare const getDesignerData: (designer: GenericData) => Promise<CreateEntryProps<import("contentful-management/types").KeyValueMap>>;
|
|
59
60
|
export declare const addDesignerData: (data: any, designer: GenericData, manyReferences?: boolean) => Promise<any>;
|
|
61
|
+
export declare const getEntries: (opts: QueryOptions) => Promise<import("contentful-management/dist/typings/common-types").Collection<import("contentful-management/dist/typings/entities/entry").Entry, EntryProps<Record<string, any>>>>;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
interface
|
|
2
|
+
interface HeaderColumns {
|
|
3
3
|
left?: string;
|
|
4
4
|
right?: string;
|
|
5
5
|
}
|
|
6
|
+
interface FooterColumns {
|
|
7
|
+
topLeft?: string;
|
|
8
|
+
topRight?: string;
|
|
9
|
+
bottomLeft?: string;
|
|
10
|
+
bottomRight?: string;
|
|
11
|
+
mail?: string;
|
|
12
|
+
}
|
|
6
13
|
interface PDFHeaderAndFooter {
|
|
7
|
-
header?:
|
|
8
|
-
footer?:
|
|
14
|
+
header?: HeaderColumns;
|
|
15
|
+
footer?: FooterColumns;
|
|
9
16
|
}
|
|
10
17
|
export declare const generatePDFByUrl: (url: string, path?: string, contents?: PDFHeaderAndFooter | undefined) => Promise<Buffer | null>;
|
|
11
18
|
export {};
|