@nuskin/cs-product-lib 1.0.20 → 1.0.22-cx12-8656.1
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 +10 -2
- package/src/formatKit.js +4 -0
- package/src/formatTranslations.js +1 -0
- package/src/formatVariant.js +3 -1
- package/src/helpers.js +10 -2
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/cs-product-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22-cx12-8656.1",
|
|
4
4
|
"description": "Library for pulling and parsing product content (and applying business logic) retrieved from Contentstack",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"audit": "yarn audit --level high",
|
|
8
8
|
"jsdoc": "node_modules/.bin/jsdoc -a all -c jsdoc.json -r -d jsdocs",
|
|
9
9
|
"lint": "eslint src __tests__",
|
|
10
|
-
"test": "jest --coverage"
|
|
10
|
+
"test": "jest --coverage",
|
|
11
|
+
"security-check": "yarn audit --groups 'dependencies devDependencies' --level high",
|
|
12
|
+
"sc": "yarn security-check"
|
|
11
13
|
},
|
|
12
14
|
"publishConfig": {
|
|
13
15
|
"access": "public"
|
|
@@ -45,5 +47,11 @@
|
|
|
45
47
|
"lodash": "4.17.21",
|
|
46
48
|
"moment": "^2.29.4",
|
|
47
49
|
"turndown": "7.1.1"
|
|
50
|
+
},
|
|
51
|
+
"resolutions": {
|
|
52
|
+
"marked": "4.0.10",
|
|
53
|
+
"semver": "7.5.2",
|
|
54
|
+
"underscore": "1.13.1",
|
|
55
|
+
"word-wrap": "1.2.4"
|
|
48
56
|
}
|
|
49
57
|
}
|
package/src/formatKit.js
CHANGED
|
@@ -154,6 +154,8 @@ const parseKit = (product, market) => {
|
|
|
154
154
|
if (properties?.type === 'kit' && product?.kit) {
|
|
155
155
|
kits.type = 'kit'
|
|
156
156
|
kits.availableQuantity = parseKitAvailableQuantity(product?.kit)
|
|
157
|
+
// kits.backorderQuantity = @TODO
|
|
158
|
+
// kits.backorderedAvailableDate = @TODO
|
|
157
159
|
for (const kit of product?.kit || []) {
|
|
158
160
|
const kitProduct = formatKit(kit, market)
|
|
159
161
|
kitProduct.id = kit?.identifier
|
|
@@ -162,6 +164,8 @@ const parseKit = (product, market) => {
|
|
|
162
164
|
} else if (properties?.type === 'bundle' || (properties?.type === 'kit' && properties?.requiredProducts)) {
|
|
163
165
|
kits.type = properties?.type
|
|
164
166
|
kits.availableQuantity = parseBundleAvailableQuantity(properties)
|
|
167
|
+
// kits.backorderQuantity = @TODO
|
|
168
|
+
// kits.backorderedAvailableDate = @TODO
|
|
165
169
|
for (const kit of properties?.requiredProducts || []) {
|
|
166
170
|
if (kit?.product) {
|
|
167
171
|
const kitProduct = formatKit(kit?.product, market)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const formatTranslations = (parent) => ({
|
|
2
2
|
// each value is a function with 'parent' which is the ProductTranslations instance
|
|
3
|
+
// *** remember to use optional chaining here to prevent undefined fields keeping graphql from returning other authored data ***
|
|
3
4
|
product: parent?.product,
|
|
4
5
|
addToCartButton:
|
|
5
6
|
parent?.common_strings_overrides?.cart?.add_to_cart_button ||
|
package/src/formatVariant.js
CHANGED
|
@@ -25,7 +25,9 @@ const formatVariant = (parent) => ({
|
|
|
25
25
|
pricingJson: JSON.stringify(parent?.defaults?.status?.pricing) || null,
|
|
26
26
|
price: helpers?.mapPrice(parent),
|
|
27
27
|
points: helpers?.mapPoints(parent),
|
|
28
|
-
|
|
28
|
+
backorderedAvailableDate: _.get(parent, 'defaults.status.backorderedAvailableDate', null),
|
|
29
|
+
backorderQuantity: _.get(parent, 'defaults.status.backordered', null) ? _.get(parent, 'defaults.status.availableQuantity', 0) : 0,
|
|
30
|
+
availableQuantity: _.get(parent, 'defaults.status.backordered', null) ? 0 : _.get(parent, 'defaults.status.availableQuantity', 0),
|
|
29
31
|
maxQuantity: _.get(parent, 'defaults.status.maxQuantity', 0),
|
|
30
32
|
status: {
|
|
31
33
|
status: _.get(parent, 'defaults.status.status.retail', null),
|
package/src/helpers.js
CHANGED
|
@@ -500,14 +500,22 @@ function mapImage(image) {
|
|
|
500
500
|
const isSvg = (image.derivatives || {}).original && (image.derivatives || {}).original.includes('.svg');
|
|
501
501
|
return {
|
|
502
502
|
url: isSvg ? (image.derivatives || {}).original : (image.derivatives || {}).webImage,
|
|
503
|
-
alt:
|
|
503
|
+
alt:
|
|
504
|
+
(image.meta || {}).SEO_Tags ||
|
|
505
|
+
image.description ||
|
|
506
|
+
image.name ||
|
|
507
|
+
'',
|
|
504
508
|
thumbnail: (image.derivatives || {}).thumbnail
|
|
505
509
|
}
|
|
506
510
|
} else if ((image || {}).files) {
|
|
507
511
|
const isSvg = (image.files.original || {}).url && (image.files.original || {}).url.includes('.svg');
|
|
508
512
|
return {
|
|
509
513
|
url: isSvg ? (image.files.original || {}).url : (image.files.webImage || {}).url,
|
|
510
|
-
alt:
|
|
514
|
+
alt:
|
|
515
|
+
(image.meta || {}).SEO_Tags ||
|
|
516
|
+
image.description ||
|
|
517
|
+
image.name ||
|
|
518
|
+
'',
|
|
511
519
|
thumbnail: (image.files.thumbnail || {}).url
|
|
512
520
|
}
|
|
513
521
|
}
|