@nuskin/ns-product-lib 2.2.0 → 2.3.0-cx24-2186.2
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/CHANGELOG.md +14 -0
- package/package.json +2 -2
- package/src/product.js +6 -0
- package/src/productData.js +19 -18
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# [2.3.0-cx24-2186.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.3.0-cx24-2186.1...v2.3.0-cx24-2186.2) (2022-10-17)
|
2
|
+
|
3
|
+
|
4
|
+
### Fix
|
5
|
+
|
6
|
+
* added stable ns-util version (#CX24-2186) ([cb868f1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cb868f14be7420ea5d70d542a77cf470cdfec40c)), closes [#CX24-2186](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2186)
|
7
|
+
|
8
|
+
# [2.3.0-cx24-2186.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.2.0...v2.3.0-cx24-2186.1) (2022-10-13)
|
9
|
+
|
10
|
+
|
11
|
+
### New
|
12
|
+
|
13
|
+
* added inventory label in the mapping (#CX24-2186) ([a24fc39](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a24fc39915e3d7e525949a2de8be04727c5226fd)), closes [#CX24-2186](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2186)
|
14
|
+
|
1
15
|
# [2.2.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.1.0...v2.2.0) (2022-10-13)
|
2
16
|
|
3
17
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.3.0-cx24-2186.2",
|
4
4
|
"description": "This project contains shared Product models and code between the backend and frontend.",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"scripts": {
|
@@ -30,7 +30,7 @@
|
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
32
|
"@nuskin/ns-common-lib": "1.4.5",
|
33
|
-
"@nuskin/ns-util": "3.
|
33
|
+
"@nuskin/ns-util": "3.105.0-CX24.1",
|
34
34
|
"axios": "0.27.2",
|
35
35
|
"qs": "6.11.0"
|
36
36
|
},
|
package/src/product.js
CHANGED
@@ -72,6 +72,11 @@ const Product = function(productData) {
|
|
72
72
|
// agelocme stuff
|
73
73
|
this.agelocme = null; // object containing agelocme information (like code, label, name)
|
74
74
|
|
75
|
+
//equinox API inventory label
|
76
|
+
//@example "IN STOCK"
|
77
|
+
//@string inventoryLabel
|
78
|
+
this.inventoryLabel = "";
|
79
|
+
|
75
80
|
this.setMarketAttributes = function(productStatus) {
|
76
81
|
if (productStatus.marketAttributes) {
|
77
82
|
this.marketAttributes = productStatus.marketAttributes;
|
@@ -626,6 +631,7 @@ const Product = function(productData) {
|
|
626
631
|
this.marketAttributes = productData.marketAttributes;
|
627
632
|
this.addOns = productData.addOns || [];
|
628
633
|
this.restrictedMarkets = productData.restrictedMarkets || [];
|
634
|
+
this.inventoryLabel = productData.inventoryLabel || "";
|
629
635
|
|
630
636
|
if (data.priceType) {
|
631
637
|
this.addPricing(data.priceType, data.price);
|
package/src/productData.js
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
const axios = require("axios");
|
3
3
|
const contentstack = require('./contentstack/contentstack');
|
4
|
-
const
|
4
|
+
const Product = require("./product");
|
5
5
|
|
6
6
|
/** @type {*} */
|
7
7
|
const ProductData = {
|
8
8
|
/**
|
9
|
-
* @param {string[]} skus
|
10
|
-
* @param {string} locale
|
11
|
-
* @param {string} market
|
12
|
-
* @param {boolean} isEquinoxEnabled
|
9
|
+
* @param {string[]} skus
|
10
|
+
* @param {string} locale
|
11
|
+
* @param {string} market
|
12
|
+
* @param {boolean} isEquinoxEnabled
|
13
13
|
*/
|
14
14
|
getProductData: async function (skus, locale, market, isEquinoxEnabled = false) {
|
15
15
|
const localeMarket = `${locale}_${market}`;
|
@@ -28,7 +28,7 @@ const ProductData = {
|
|
28
28
|
getProductFromEquinox: async function (skus, locale, storeID) {
|
29
29
|
const filter = '{"filters":[{"field":"index_key_skuId","operation":"IN","value":"' + skus.toString() + '"}]}';
|
30
30
|
axios.defaults.withCredentials = true;
|
31
|
-
|
31
|
+
|
32
32
|
const url = await contentstack.getKongUrl() + `/orchestrationservices/storefront/catalogs/search/`;
|
33
33
|
console.log("Dynamic URL", url)
|
34
34
|
const href = `${url}?filter=${encodeURI(filter)}`;
|
@@ -78,7 +78,7 @@ const ProductData = {
|
|
78
78
|
responseType: 'json'
|
79
79
|
});
|
80
80
|
},
|
81
|
-
|
81
|
+
|
82
82
|
/**
|
83
83
|
* @param {contentstack.MarketConfig} marketConfig
|
84
84
|
*/
|
@@ -92,13 +92,12 @@ const ProductData = {
|
|
92
92
|
|
93
93
|
eqProductMapper: function (productDataResponse) {
|
94
94
|
let prod = [];
|
95
|
-
let count = 0;
|
96
95
|
|
97
|
-
let prodArr = productDataResponse.map((data) => {
|
96
|
+
let prodArr = productDataResponse.map((data, count) => {
|
98
97
|
let imageURL = data.sku[count].properties.imageURL;
|
99
98
|
const regex = /\d+.\d+/
|
100
99
|
let thumbnailImage = ''
|
101
|
-
|
100
|
+
|
102
101
|
if (imageURL.includes('contentstack')) {
|
103
102
|
thumbnailImage = imageURL + '?width=40'
|
104
103
|
} else {
|
@@ -207,16 +206,18 @@ const ProductData = {
|
|
207
206
|
"earn": true
|
208
207
|
},
|
209
208
|
"restrictedMarkets": [],
|
210
|
-
"addOns": []
|
209
|
+
"addOns": [],
|
210
|
+
inventoryLabel: data.sku[count].inventory || ""
|
211
211
|
};
|
212
|
-
|
213
|
-
return
|
214
|
-
})
|
212
|
+
|
213
|
+
return new Product(prod);
|
214
|
+
});
|
215
215
|
|
216
216
|
let data = {
|
217
217
|
products: prodArr,
|
218
218
|
count: productDataResponse.length
|
219
219
|
};
|
220
|
+
|
220
221
|
return {
|
221
222
|
data: {
|
222
223
|
"status": 200,
|
@@ -252,13 +253,13 @@ const ProductData = {
|
|
252
253
|
},
|
253
254
|
|
254
255
|
/**
|
255
|
-
*
|
256
|
-
* @param {*} custType
|
257
|
-
*
|
256
|
+
*
|
257
|
+
* @param {*} custType
|
258
|
+
*
|
258
259
|
*/
|
259
260
|
switchCustType: function (custType) {
|
260
261
|
let newCustType = [];
|
261
|
-
if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
|
262
|
+
if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
|
262
263
|
newCustType.push(10)
|
263
264
|
if (custType.includes('Retail Customer'))
|
264
265
|
newCustType.push(20)
|