@nuskin/ns-product-lib 2.6.1-cx24-3607.1 → 2.6.1-cx24-3607.3
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [2.6.1-cx24-3607.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-3607.2...v2.6.1-cx24-3607.3) (2023-03-16)
|
2
|
+
|
3
|
+
|
4
|
+
### Fix
|
5
|
+
|
6
|
+
* check for imageURL ([5d56bae](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5d56baeb4c148cc667cc3c9321fb72e87216c921))
|
7
|
+
|
8
|
+
## [2.6.1-cx24-3607.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-3607.1...v2.6.1-cx24-3607.2) (2023-03-16)
|
9
|
+
|
10
|
+
|
11
|
+
### Fix
|
12
|
+
|
13
|
+
* (equinox-enabled) skip product mapping when an error occurs in PLP #CX24-3607 ([49fa749](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/49fa7499b390aa84cc887fc631037363421d252a)), closes [#CX24-3607](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3607)
|
14
|
+
|
1
15
|
## [2.6.1-cx24-3607.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0...v2.6.1-cx24-3607.1) (2023-03-15)
|
2
16
|
|
3
17
|
|
package/package.json
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
/**
|
2
|
+
* childSKU maps a product variant. Used mainly in subscription.
|
3
|
+
*
|
4
|
+
* @param {import('.').KitSKUQuantity[]} kits
|
5
|
+
* @param {import('.').EquinoxProduct} product
|
6
|
+
*/
|
7
|
+
function childSKU(kits, product) {
|
8
|
+
const sku = product.sku.filter(sku => sku.default)[0];
|
9
|
+
if (!sku) {
|
10
|
+
throw Error('Unable to find the default SKU.');
|
11
|
+
}
|
12
|
+
|
13
|
+
const kit = kits.filter(k => k.sku === sku.identifier)[0];
|
14
|
+
if (!kit) {
|
15
|
+
throw Error('SKU kit does not exist in the list of available variants.');
|
16
|
+
}
|
17
|
+
|
18
|
+
return {
|
19
|
+
productId: product.identifier,
|
20
|
+
skuId: sku.identifier,
|
21
|
+
type: 'MANDATORY',
|
22
|
+
skuQuantity: kit.qty,
|
23
|
+
availableChannels: sku.properties.availableChannels,
|
24
|
+
inventory: {
|
25
|
+
atpQty: sku.inventoryProperties.atpQty,
|
26
|
+
backOrdered: sku.inventoryProperties.backOrdered
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
module.exports = childSKU;
|
@@ -19,14 +19,18 @@
|
|
19
19
|
* @description This model represents a product within an Equinox response.
|
20
20
|
* @typedef EquinoxProduct
|
21
21
|
* @type {object}
|
22
|
-
* @property {
|
22
|
+
* @property {string} identifier
|
23
|
+
* @property {EquinoxProductSKU[]} sku
|
23
24
|
* @property {"kit"|"bundle"} [type]
|
24
25
|
*
|
25
26
|
* @typedef EquinoxProductSKU
|
26
27
|
* @type {object}
|
28
|
+
* @property {boolean} default
|
29
|
+
* For multi-variant products, this indicates that this is the searched SKU
|
30
|
+
* when using catalogs/search endpoint.
|
27
31
|
* @property {string} identifier
|
28
|
-
* @property {EquinoxProductProperties} properties
|
29
32
|
* @property {Inventory} inventoryProperties
|
33
|
+
* @property {EquinoxProductProperties} properties
|
30
34
|
*
|
31
35
|
* @typedef EquinoxProductProperties
|
32
36
|
* @type {object}
|
@@ -49,12 +53,12 @@
|
|
49
53
|
* @typedef KitSKUQuantity
|
50
54
|
* @type {object}
|
51
55
|
* @property {string} sku
|
52
|
-
* @property {number}
|
56
|
+
* @property {number} qty
|
53
57
|
*/
|
54
58
|
const availableQuantity = require('./availableQuantity');
|
55
|
-
const
|
59
|
+
const childSKU = require('./childSKU');
|
56
60
|
|
57
61
|
module.exports = {
|
58
62
|
mapAvailableQuantity: availableQuantity,
|
59
|
-
|
63
|
+
mapChildSKU: childSKU
|
60
64
|
};
|
package/src/productData.js
CHANGED
@@ -5,7 +5,7 @@ const contentstack = require('./contentstack/contentstack');
|
|
5
5
|
const Product = require("./product");
|
6
6
|
const CustomerTypes = require('./models/customerTypes');
|
7
7
|
const ProductStatus = require("./models/productStatus");
|
8
|
-
const { mapAvailableQuantity,
|
8
|
+
const { mapAvailableQuantity, mapChildSKU } = require('./equinox-helpers');
|
9
9
|
|
10
10
|
const productTypes = {
|
11
11
|
kit: 'kit'
|
@@ -129,15 +129,9 @@ const ProductData = {
|
|
129
129
|
*/
|
130
130
|
eqProductVariantMapper: function (eqVariant) {
|
131
131
|
|
132
|
-
let imageURL = eqVariant.properties.imageURL;
|
133
|
-
|
134
|
-
let thumbnailImage = ''
|
132
|
+
let imageURL = eqVariant.properties.imageURL ? eqVariant.properties.imageURL : '';
|
133
|
+
let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
|
135
134
|
|
136
|
-
if (imageURL.includes('contentstack')) {
|
137
|
-
thumbnailImage = imageURL + '?width=40'
|
138
|
-
} else {
|
139
|
-
thumbnailImage = imageURL.replace(regex, '40.40')
|
140
|
-
}
|
141
135
|
|
142
136
|
const { eventName, eventLabels, computedPrice, defaultProductPrice } = this.getEqProductPromotions(eqVariant);
|
143
137
|
const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
|
@@ -351,15 +345,9 @@ const ProductData = {
|
|
351
345
|
for (const productData of productDataResponse) {
|
352
346
|
try {
|
353
347
|
let product = (productData.type && productData.type === "kit") ? productData : productData.sku[count];
|
354
|
-
let imageURL = product.properties.imageURL;
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
if (imageURL.includes('contentstack')) {
|
359
|
-
thumbnailImage = imageURL + '?width=40'
|
360
|
-
} else {
|
361
|
-
thumbnailImage = imageURL.replace(regex, '40.40')
|
362
|
-
}
|
348
|
+
let imageURL = product.properties.imageURL ? product.properties.imageURL : '';
|
349
|
+
let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
|
350
|
+
|
363
351
|
|
364
352
|
if (productData.sku && productData.sku.length > 1) {
|
365
353
|
// exclude base product from variants
|
@@ -522,7 +510,7 @@ const ProductData = {
|
|
522
510
|
type: 'SKUKIT',
|
523
511
|
availableChannels: product.properties.availableChannels
|
524
512
|
},
|
525
|
-
...res.data.product.map(p =>
|
513
|
+
...res.data.product.map(p => mapChildSKU(kits, p))
|
526
514
|
];
|
527
515
|
|
528
516
|
return childSkus;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* childSkus creates an array of object that contains
|
3
|
-
* the list of SKUs of a kit.
|
4
|
-
*
|
5
|
-
* @param {import('./').KitSKUQuantity[]} kits
|
6
|
-
* @param {import('./').EquinoxProduct} product
|
7
|
-
*/
|
8
|
-
function childSkus(kits, product) {
|
9
|
-
const sku = product.sku[0];
|
10
|
-
const kit = kits.filter(k => k.sku === sku.identifier)[0];
|
11
|
-
|
12
|
-
return {
|
13
|
-
productId: product.identifier,
|
14
|
-
skuId: sku.identifier,
|
15
|
-
type: 'MANDATORY',
|
16
|
-
skuQuantity: kit.qty,
|
17
|
-
availableChannels: sku.properties.availableChannels,
|
18
|
-
inventory: {
|
19
|
-
atpQty: sku.inventoryProperties.atpQty,
|
20
|
-
backOrdered: sku.inventoryProperties.backOrdered
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
module.exports = childSkus;
|