@nuskin/cs-product-lib 1.0.9-cx12-6632.2 → 1.0.9
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/package.json +1 -1
- package/src/formatKit.js +2 -2
- package/src/formatProduct.js +40 -40
- package/src/formatVariant.js +57 -57
package/package.json
CHANGED
package/src/formatKit.js
CHANGED
|
@@ -84,7 +84,7 @@ const parsePrice = (product = []) => {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// sum of price and points from 1st variant of product bundle
|
|
87
|
-
const
|
|
87
|
+
const sumOfPriceAndPoints = variants.reduce((acc, curr) => {
|
|
88
88
|
const price = {}
|
|
89
89
|
const points = {
|
|
90
90
|
subscription : {},
|
|
@@ -106,7 +106,7 @@ const parsePrice = (product = []) => {
|
|
|
106
106
|
|
|
107
107
|
return { price, points}
|
|
108
108
|
}, defaultValues)
|
|
109
|
-
return
|
|
109
|
+
return sumOfPriceAndPoints
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
const parseKitAvailableQuantity = (kit) => {
|
package/src/formatProduct.js
CHANGED
|
@@ -7,31 +7,31 @@ const formatProduct = (parent, homeUrl) => {
|
|
|
7
7
|
const formattedProduct = {
|
|
8
8
|
// Each value is a function with a parameter 'parent' that is the current instance of a Product
|
|
9
9
|
// ContentStack references need to be queried separately (ie: variants)
|
|
10
|
-
id: parent?.uid
|
|
11
|
-
slug: parent?.seo_information?.slug
|
|
12
|
-
variantSelectLabel: parent?.variant_select_label
|
|
13
|
-
secondaryTitle: parent?.secondary_title
|
|
14
|
-
title: parent?.name
|
|
15
|
-
productImages:
|
|
16
|
-
salesLabel: parent?.sales_label
|
|
17
|
-
salesText: parent?.sales_text
|
|
18
|
-
description:
|
|
19
|
-
salesDisclaimer:
|
|
20
|
-
features: helpers?.mapFeatures(parent)
|
|
21
|
-
productDetails:
|
|
10
|
+
id: parent?.uid,
|
|
11
|
+
slug: parent?.seo_information?.slug,
|
|
12
|
+
variantSelectLabel: parent?.variant_select_label,
|
|
13
|
+
secondaryTitle: parent?.secondary_title,
|
|
14
|
+
title: parent?.name,
|
|
15
|
+
productImages: helpers?.getProductImages(parent),
|
|
16
|
+
salesLabel: parent?.sales_label,
|
|
17
|
+
salesText: parent?.sales_text,
|
|
18
|
+
description: entities.decodeHTML(parent?.short_description || ''),
|
|
19
|
+
salesDisclaimer: helpers?.mapSalesDisclaimer(parent?.sales_disclaimer),
|
|
20
|
+
features: helpers?.mapFeatures(parent),
|
|
21
|
+
productDetails: helpers?.mapProductDetails(parent),
|
|
22
22
|
benefitsMedia: {
|
|
23
|
-
image:
|
|
24
|
-
youTubeVideoId: parent?.
|
|
23
|
+
image: helpers?.mapImage(parent?.benefits_media?.image),
|
|
24
|
+
youTubeVideoId: parent?.benefits_media?.youtube_video_id
|
|
25
25
|
},
|
|
26
|
-
benefits: helpers?.mapBenefits(parent)
|
|
27
|
-
benefitsAndFeatures:
|
|
26
|
+
benefits: helpers?.mapBenefits(parent),
|
|
27
|
+
benefitsAndFeatures: helpers?.mapBenefitsAndFeatures(parent),
|
|
28
28
|
bundle: parent?.bundle || parent?.kit,
|
|
29
29
|
type: parent?.type || "product",
|
|
30
|
-
results: helpers?.mapResults(parent)
|
|
31
|
-
sustainability: helpers?.mapSustainability(parent)
|
|
32
|
-
usage: helpers?.mapUsage(parent, parent?.legacy_usage)
|
|
33
|
-
resources: helpers?.mapResources(parent)
|
|
34
|
-
faqs: helpers?.mapFaqs(parent)
|
|
30
|
+
results: helpers?.mapResults(parent),
|
|
31
|
+
sustainability: helpers?.mapSustainability(parent),
|
|
32
|
+
usage: helpers?.mapUsage(parent, parent?.legacy_usage),
|
|
33
|
+
resources: helpers?.mapResources(parent),
|
|
34
|
+
faqs: helpers?.mapFaqs(parent),
|
|
35
35
|
categories: parent?.categories?.map((category) => ({
|
|
36
36
|
displayName: category.display_name,
|
|
37
37
|
id: category.category_id,
|
|
@@ -42,25 +42,25 @@ const formatProduct = (parent, homeUrl) => {
|
|
|
42
42
|
})),
|
|
43
43
|
ingredients: helpers?.mapIngredients(
|
|
44
44
|
parent?.ingredients,
|
|
45
|
-
parent?.legacy_ingredients
|
|
45
|
+
parent?.legacy_ingredients
|
|
46
46
|
),
|
|
47
|
-
legacyBenefits: parent?.legacy_benefits
|
|
48
|
-
legacyLongDescription: parent?.legacy_long_description
|
|
49
|
-
legacyResources: parent?.legacy_resources
|
|
50
|
-
legacyUsage: parent?.legacy_usage
|
|
51
|
-
legacyIngredients: parent?.legacy_ingredients
|
|
52
|
-
legacyImages: parent?.legacy_images ||
|
|
53
|
-
legacyYouTube: parent?.legacy_youtube_video
|
|
47
|
+
legacyBenefits: parent?.legacy_benefits,
|
|
48
|
+
legacyLongDescription: parent?.legacy_long_description,
|
|
49
|
+
legacyResources: parent?.legacy_resources,
|
|
50
|
+
legacyUsage: parent?.legacy_usage,
|
|
51
|
+
legacyIngredients: parent?.legacy_ingredients,
|
|
52
|
+
legacyImages: parent?.legacy_images || [],
|
|
53
|
+
legacyYouTube: parent?.legacy_youtube_video,
|
|
54
54
|
disclaimers: parent?.disclaimers || [],
|
|
55
|
-
disclaimerWarnings:
|
|
55
|
+
disclaimerWarnings: helpers?.mapDisclaimerWarnings(
|
|
56
56
|
parent?.disclaimer_warnings
|
|
57
57
|
),
|
|
58
|
-
seoInformation:
|
|
59
|
-
variants: helpers?.mapVariants(parent)
|
|
60
|
-
refund: helpers?.mapRefund(parent)
|
|
61
|
-
shipping: helpers?.mapShipping(parent)
|
|
62
|
-
generalDisclaimer: parent?.
|
|
63
|
-
thirdPartyScripts: parent?.
|
|
58
|
+
seoInformation: helpers?.mapSeoInformation(parent, homeUrl),
|
|
59
|
+
variants: helpers?.mapVariants(parent),
|
|
60
|
+
refund: helpers?.mapRefund(parent),
|
|
61
|
+
shipping: helpers?.mapShipping(parent),
|
|
62
|
+
generalDisclaimer: parent?.translations?.general_disclaimer_text,
|
|
63
|
+
thirdPartyScripts: parent?.third_party_scripts
|
|
64
64
|
?.filter((tps) => tps.enabled && !!tps.script)
|
|
65
65
|
?.map((tps) => tps.script),
|
|
66
66
|
csAtts: parent.csAtts || {
|
|
@@ -71,10 +71,10 @@ const formatProduct = (parent, homeUrl) => {
|
|
|
71
71
|
createdBy: parent?.created_by || '',
|
|
72
72
|
locale: parent?.locale || ''
|
|
73
73
|
},
|
|
74
|
-
relevancyRank: parent?.relevancy_rank ||
|
|
75
|
-
warranty: helpers?.mapWarranty(parent)
|
|
76
|
-
upSellProductIds:
|
|
77
|
-
crossProductIds:
|
|
74
|
+
relevancyRank: parent?.relevancy_rank || null,
|
|
75
|
+
warranty: helpers?.mapWarranty(parent),
|
|
76
|
+
upSellProductIds: helpers?.mapUpSellProductIds(parent),
|
|
77
|
+
crossProductIds: helpers?.mapCrossProductIds(parent)
|
|
78
78
|
}
|
|
79
79
|
if (parent.bundle || parent.sku_kit || parent.product_bundle) {
|
|
80
80
|
return formatKit(formattedProduct)
|
package/src/formatVariant.js
CHANGED
|
@@ -5,29 +5,29 @@ const entities = require('entities')
|
|
|
5
5
|
const formatVariant = (parent) => ({
|
|
6
6
|
// Each value is a function with a parameter 'parent' that is the current instance of a Variant
|
|
7
7
|
// ContentStack references need to be queried separately
|
|
8
|
-
id: parent?.uid
|
|
9
|
-
globalId: parent?.sap_data?.global_id
|
|
10
|
-
sku:
|
|
8
|
+
id: parent?.uid,
|
|
9
|
+
globalId: parent?.sap_data?.global_id,
|
|
10
|
+
sku: helpers?.getBestSkuData(parent)?.sku,
|
|
11
11
|
slug: parent?.slug,
|
|
12
12
|
size: parent?.size,
|
|
13
|
-
variantLabel: parent?.select_label
|
|
14
|
-
variantColor: parent?.select_color
|
|
15
|
-
title: parent?.name || parent?.defaults?.name
|
|
16
|
-
salesLabel: parent?.sales_label
|
|
17
|
-
salesText: parent?.sales_text
|
|
13
|
+
variantLabel: parent?.select_label,
|
|
14
|
+
variantColor: parent?.select_color,
|
|
15
|
+
title: parent?.name || parent?.defaults?.name,
|
|
16
|
+
salesLabel: parent?.sales_label,
|
|
17
|
+
salesText: parent?.sales_text,
|
|
18
18
|
description: entities.decodeHTML(
|
|
19
19
|
parent?.short_description_override || parent?.defaults.description || ''
|
|
20
|
-
)
|
|
21
|
-
salesDisclaimer: helpers?.mapSalesDisclaimer(parent?.sales_disclaimer)
|
|
22
|
-
nettoWeight: parent?.netto_weight
|
|
23
|
-
productImages:
|
|
24
|
-
isExclusive: parent?.is_exclusive
|
|
25
|
-
pricingJson:
|
|
26
|
-
price: helpers?.mapPrice(parent)
|
|
27
|
-
points: helpers?.mapPoints(parent)
|
|
28
|
-
availableQuantity:
|
|
29
|
-
maxQuantity:
|
|
30
|
-
status:
|
|
20
|
+
),
|
|
21
|
+
salesDisclaimer: helpers?.mapSalesDisclaimer(parent?.sales_disclaimer),
|
|
22
|
+
nettoWeight: parent?.netto_weight,
|
|
23
|
+
productImages: helpers?.mapProductImages(parent),
|
|
24
|
+
isExclusive: parent?.is_exclusive,
|
|
25
|
+
pricingJson: JSON.stringify(parent?.defaults?.status?.pricing) || null,
|
|
26
|
+
price: helpers?.mapPrice(parent),
|
|
27
|
+
points: helpers?.mapPoints(parent),
|
|
28
|
+
availableQuantity: _.get(parent, 'defaults.status.availableQuantity', 0),
|
|
29
|
+
maxQuantity: _.get(parent, 'defaults.status.maxQuantity', 0),
|
|
30
|
+
status: {
|
|
31
31
|
status: _.get(parent, 'defaults.status.status.retail', null),
|
|
32
32
|
retail: _.get(parent, 'defaults.status.status.retail', null),
|
|
33
33
|
wholesale: _.get(parent, 'defaults.status.status.wholesale', null),
|
|
@@ -38,33 +38,33 @@ const formatVariant = (parent) => ({
|
|
|
38
38
|
''
|
|
39
39
|
)
|
|
40
40
|
},
|
|
41
|
-
csStatus:
|
|
42
|
-
purchaseTypes:
|
|
43
|
-
features: helpers?.mapFeatures(parent)
|
|
44
|
-
productDetails:
|
|
45
|
-
ingredients:
|
|
41
|
+
csStatus: helpers?.mapCsStatus(parent),
|
|
42
|
+
purchaseTypes: helpers?.mapPurchaseTypes(parent),
|
|
43
|
+
features: helpers?.mapFeatures(parent),
|
|
44
|
+
productDetails: helpers?.mapProductDetails(parent),
|
|
45
|
+
ingredients: helpers?.mapIngredients(
|
|
46
46
|
parent.ingredients_override,
|
|
47
47
|
parent.legacy_ingredients
|
|
48
48
|
),
|
|
49
|
-
benefitsAndFeatures:
|
|
50
|
-
results: helpers?.mapResults(parent)
|
|
51
|
-
usage: helpers?.mapUsage(parent, parent.legacy_usage)
|
|
52
|
-
resources: helpers?.mapResources(parent)
|
|
53
|
-
faqs: helpers?.mapFaqs(parent)
|
|
49
|
+
benefitsAndFeatures: helpers?.mapBenefitsAndFeatures(parent),
|
|
50
|
+
results: helpers?.mapResults(parent),
|
|
51
|
+
usage: helpers?.mapUsage(parent, parent.legacy_usage),
|
|
52
|
+
resources: helpers?.mapResources(parent),
|
|
53
|
+
faqs: helpers?.mapFaqs(parent),
|
|
54
54
|
disclaimers: parent?.disclaimers || [],
|
|
55
|
-
disclaimerWarnings:
|
|
55
|
+
disclaimerWarnings: helpers?.mapDisclaimerWarnings(
|
|
56
56
|
parent.disclaimer_warnings
|
|
57
57
|
),
|
|
58
|
-
matchingVariant:
|
|
58
|
+
matchingVariant:
|
|
59
59
|
parent.sap_data?.sku_data?.findIndex((s) =>
|
|
60
60
|
parent.searchedSkus.includes(s.sku)
|
|
61
61
|
) > -1,
|
|
62
62
|
shadeable: parent?.shadeable || false,
|
|
63
|
-
restrictedMarkets: parent?.restricted_markets ||
|
|
64
|
-
productType: parent?.sap_data?.product_type
|
|
65
|
-
primaryBrand: parent.sap_data?.primary_brand
|
|
66
|
-
brandFamily: parent?.sap_data?.brand_family
|
|
67
|
-
marketAttributes:
|
|
63
|
+
restrictedMarkets: parent?.restricted_markets || [],
|
|
64
|
+
productType: parent?.sap_data?.product_type,
|
|
65
|
+
primaryBrand: parent.sap_data?.primary_brand,
|
|
66
|
+
brandFamily: parent?.sap_data?.brand_family,
|
|
67
|
+
marketAttributes: {
|
|
68
68
|
discount: _.get(
|
|
69
69
|
parent,
|
|
70
70
|
'defaults.status.marketAttributes.discount',
|
|
@@ -73,14 +73,14 @@ const formatVariant = (parent) => ({
|
|
|
73
73
|
redeem: _.get(parent, 'defaults.status.marketAttributes.redeem', null),
|
|
74
74
|
earn: _.get(parent, 'defaults.status.marketAttributes.earn', null)
|
|
75
75
|
},
|
|
76
|
-
legacyBenefits: parent.legacy_benefits
|
|
77
|
-
legacyLongDescription: parent.legacy_long_description
|
|
78
|
-
legacyResources: parent.legacy_resources
|
|
79
|
-
legacyUsage: parent.legacy_usage
|
|
80
|
-
legacyIngredients: parent.legacy_ingredients
|
|
81
|
-
legacyImages: parent.legacy_images ||
|
|
82
|
-
legacyYouTube: parent.legacy_youtube_video
|
|
83
|
-
csAtts:
|
|
76
|
+
legacyBenefits: parent.legacy_benefits,
|
|
77
|
+
legacyLongDescription: parent.legacy_long_description,
|
|
78
|
+
legacyResources: parent.legacy_resources,
|
|
79
|
+
legacyUsage: parent.legacy_usage,
|
|
80
|
+
legacyIngredients: parent.legacy_ingredients,
|
|
81
|
+
legacyImages: parent.legacy_images || [],
|
|
82
|
+
legacyYouTube: parent.legacy_youtube_video,
|
|
83
|
+
csAtts: {
|
|
84
84
|
version: parent._version || 0,
|
|
85
85
|
updatedAt: parent.updated_at || '',
|
|
86
86
|
updatedBy: parent.updated_by || '',
|
|
@@ -88,24 +88,24 @@ const formatVariant = (parent) => ({
|
|
|
88
88
|
createdBy: parent.created_by || '',
|
|
89
89
|
locale: parent.locale || ''
|
|
90
90
|
},
|
|
91
|
-
searchKeywords: parent?.search_keywords
|
|
92
|
-
excludeFromSearch: parent?.exclude_from_search ||
|
|
93
|
-
customerTypes:
|
|
91
|
+
searchKeywords: parent?.search_keywords,
|
|
92
|
+
excludeFromSearch: parent?.exclude_from_search || helpers?.mapCsStatus(parent).status === 'discontinued' || _.get(parent, 'defaults.status.status.retail', null) === 'DISCONTINUED',
|
|
93
|
+
customerTypes: helpers?.getBestSkuData(parent)?.status_selections
|
|
94
94
|
?.customer_types,
|
|
95
|
-
availableChannels:
|
|
95
|
+
availableChannels: helpers?.getBestSkuData(parent)?.status_selections
|
|
96
96
|
?.display_channels,
|
|
97
|
-
displayChannels:
|
|
97
|
+
displayChannels: helpers?.getBestSkuData(parent)?.status_selections
|
|
98
98
|
?.display_channels,
|
|
99
|
-
scanQualifiedCount:
|
|
99
|
+
scanQualifiedCount: helpers?.getBestSkuData(parent)?.status_selections
|
|
100
100
|
?.scan_qualify_count,
|
|
101
|
-
scanQualifyCount:
|
|
101
|
+
scanQualifyCount: helpers?.getBestSkuData(parent)?.status_selections
|
|
102
102
|
?.scan_qualify_count,
|
|
103
|
-
chargeShipping:
|
|
104
|
-
dangerousGoods:
|
|
105
|
-
channels:
|
|
106
|
-
foreignLimit:
|
|
107
|
-
foreignOrderLimit:
|
|
108
|
-
orderType: parent
|
|
103
|
+
chargeShipping: helpers?.getBestSkuData(parent)?.charge_shipping,
|
|
104
|
+
dangerousGoods: helpers?.getBestSkuData(parent)?.dangerous_goods,
|
|
105
|
+
channels: helpers?.getBestSkuData(parent)?.channels,
|
|
106
|
+
foreignLimit: helpers?.getBestSkuData(parent)?.foreign_limit,
|
|
107
|
+
foreignOrderLimit: helpers?.getBestSkuData(parent)?.foreign_limit,
|
|
108
|
+
orderType: parent.sap_data?.order_type
|
|
109
109
|
})
|
|
110
110
|
|
|
111
111
|
module.exports = {
|