@nuskin/ns-product-lib 1.5.0-cx24-2121.1.4 → 1.5.0-cx24-2126.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 +7 -20
- package/package.json +2 -2
- package/src/productData.js +38 -50
package/CHANGELOG.md
CHANGED
@@ -1,30 +1,17 @@
|
|
1
|
-
# [1.5.0-cx24-
|
1
|
+
# [1.5.0-cx24-2126.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-cx24-2126.1...v1.5.0-cx24-2126.2) (2022-08-23)
|
2
2
|
|
3
3
|
|
4
|
-
###
|
5
|
-
|
6
|
-
* pass the store ID to getProductData (CX24-2121) ([2f994f6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2f994f6214d9854648bf4bef62d47694f59e4001))
|
7
|
-
|
8
|
-
# [1.5.0-cx24-2121.1.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-cx24-2121.1.2...v1.5.0-cx24-2121.1.3) (2022-08-19)
|
9
|
-
|
10
|
-
|
11
|
-
### Update
|
12
|
-
|
13
|
-
* pass the store ID to getProductData (CX24-2121) ([8bb39fb](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8bb39fb1179514ed02a5efd35ed86e1f75b53ff7))
|
14
|
-
|
15
|
-
# [1.5.0-cx24-2121.1.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-cx24-2121.1.1...v1.5.0-cx24-2121.1.2) (2022-08-19)
|
16
|
-
|
17
|
-
|
18
|
-
### Update
|
4
|
+
### New
|
19
5
|
|
20
|
-
*
|
6
|
+
* merged dynamic kong URL (#CX24-2126) ([e823b62](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e823b6238a85929d19aa3b86de28ffd4d1b65641)), closes [#CX24-2126](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2126)
|
7
|
+
* update condition for dynamic kong URL (#CX24-2126) ([e0149a6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e0149a6fee3e9405709efbb2669abffd01fc8a5b)), closes [#CX24-2126](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2126)
|
21
8
|
|
22
|
-
# [1.5.0-cx24-
|
9
|
+
# [1.5.0-cx24-2126.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-CX24.1...v1.5.0-cx24-2126.1) (2022-08-22)
|
23
10
|
|
24
11
|
|
25
|
-
###
|
12
|
+
### New
|
26
13
|
|
27
|
-
*
|
14
|
+
* added dynamic kong url (#CX24-2126) ([7c5064d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7c5064d36632097e68c82bd984555478bd165d62)), closes [#CX24-2126](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2126)
|
28
15
|
|
29
16
|
# [1.5.0-CX24.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.5...v1.5.0-CX24.1) (2022-08-11)
|
30
17
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "1.5.0-cx24-
|
3
|
+
"version": "1.5.0-cx24-2126.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.3.0",
|
33
|
-
"@nuskin/ns-util": "3.104.0-
|
33
|
+
"@nuskin/ns-util": "3.104.0-CX24.1",
|
34
34
|
"axios": "0.27.2",
|
35
35
|
"qs": "6.11.0"
|
36
36
|
},
|
package/src/productData.js
CHANGED
@@ -1,59 +1,47 @@
|
|
1
1
|
"use strict";
|
2
2
|
const axios = require("axios");
|
3
3
|
const product = require("./product")
|
4
|
-
/** @type {*} */
|
5
|
-
const ProductData = {
|
6
|
-
/**
|
7
|
-
* @param {*} skus
|
8
|
-
* @param {*} runConfig
|
9
|
-
* @param {*} marketConfig
|
10
|
-
* @param {{ isEnabled: boolean, storeID: string }} equinoxOptions
|
11
|
-
*/
|
12
|
-
getProductData: async function (skus, runConfig, marketConfig, equinoxOptions) {
|
13
|
-
const locale = `${runConfig.language}_${runConfig.country}`;
|
14
|
-
|
15
|
-
if (equinoxOptions !== undefined && equinoxOptions.isEnabled === true) {
|
16
|
-
return await this.getProductFromEquinox(skus, locale, marketConfig, equinoxOptions.storeID);
|
17
|
-
}
|
18
4
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
const
|
24
|
-
"filters": [{
|
25
|
-
"field": "index_key_skuId",
|
26
|
-
"operation": "IN",
|
27
|
-
"value": "${skus.toString()}"
|
28
|
-
}]
|
29
|
-
}`;
|
30
|
-
axios.defaults.withCredentials = true;
|
31
|
-
const productDataResponse = await axios.request({
|
32
|
-
method: 'get',
|
33
|
-
url: `https://storefront.api.wts.nuskin.io/orchestrationservices/storefront/catalogs/search/`,
|
34
|
-
params: {
|
35
|
-
locale,
|
36
|
-
storeId: storeID,
|
37
|
-
filter
|
38
|
-
},
|
39
|
-
headers: this.getProductDataRequestHeaders(marketConfig),
|
40
|
-
responseType: "json"
|
41
|
-
});
|
5
|
+
const ProductData = {
|
6
|
+
getProductData: async function (skus, runConfig, marketConfig, isEqEnabled) {
|
7
|
+
let productResponse = {};
|
8
|
+
let locale = `${runConfig.language}_${runConfig.country}`;
|
9
|
+
const kongBaseUrl = marketConfig.mySiteKongURL ? `https://${marketConfig.mySiteKongURL}` : "";
|
42
10
|
|
43
|
-
|
44
|
-
|
11
|
+
if (isEqEnabled == true) {
|
12
|
+
let filter = '{"filters":[{"field":"index_key_skuId","operation":"IN","value":"' +
|
13
|
+
skus.toString() +
|
14
|
+
'"}]}'
|
15
|
+
axios.defaults.withCredentials = true;
|
16
|
+
let productDataResponse = await axios.request({
|
17
|
+
method: 'get',
|
18
|
+
url: `${kongBaseUrl}/orchestrationservices/storefront/catalogs/search/`,
|
19
|
+
params: {
|
20
|
+
locale: locale,
|
21
|
+
storeId: '406',
|
22
|
+
filter: filter
|
23
|
+
},
|
24
|
+
headers: this.getProductDataRequestHeaders(marketConfig),
|
25
|
+
responseType: "json"
|
26
|
+
});
|
27
|
+
productResponse = this.eqProductMapper(productDataResponse.data.product)
|
45
28
|
|
46
|
-
|
47
|
-
|
48
|
-
|
29
|
+
} else {
|
30
|
+
let lambdaUrl = `${marketConfig.awsUrl}/productData/v1`;
|
31
|
+
const payload = {
|
32
|
+
locale: locale,
|
33
|
+
skus: skus
|
34
|
+
};
|
35
|
+
productResponse = await axios.request({
|
36
|
+
method: "post",
|
37
|
+
url: lambdaUrl,
|
38
|
+
data: payload,
|
39
|
+
headers: this.getProductDataRequestHeaders(marketConfig),
|
40
|
+
responseType: "json"
|
41
|
+
});
|
42
|
+
}
|
49
43
|
|
50
|
-
return
|
51
|
-
method: "post",
|
52
|
-
url: lambdaUrl,
|
53
|
-
data: payload,
|
54
|
-
headers: this.getProductDataRequestHeaders(marketConfig),
|
55
|
-
responseType: "json"
|
56
|
-
});
|
44
|
+
return productResponse;
|
57
45
|
},
|
58
46
|
|
59
47
|
/* eqProductMapper: function(productDataResponse) {
|
@@ -66,7 +54,7 @@ const ProductData = {
|
|
66
54
|
let count = 0;
|
67
55
|
productDataResponse.forEach((data, index) => {
|
68
56
|
count++
|
69
|
-
|
57
|
+
|
70
58
|
prod = {
|
71
59
|
"sku": data.sku[0].identifier,
|
72
60
|
"globalProductID": data.identifier,
|