@nuskin/ns-product-lib 1.4.4 → 1.5.0-cx24-1810.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/CHANGELOG.md +14 -0
- package/package.json +4 -2
- package/src/index.js +3 -1
- package/src/productData.js +65 -0
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# [1.5.0-cx24-1810.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.4...v1.5.0-cx24-1810.1) (2022-07-07)
|
2
|
+
|
3
|
+
|
4
|
+
### New
|
5
|
+
|
6
|
+
* Adding product data to get from different source (#CX24-1810) ([5b7f0c1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5b7f0c1015361ff9aa6f2f21f649fea1b7174b29)), closes [#CX24-1810](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-1810)
|
7
|
+
* Creating EQ product data query (#CX24-1810) ([77fadd2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/77fadd25bbe26044502ef80663e1cc91625c4602)), closes [#CX24-1810](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-1810)
|
8
|
+
* Creating EQ product data query (#CX24-1810) ([9047a30](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9047a30356d707fcf246af6a2aeb47d502f077bf)), closes [#CX24-1810](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-1810)
|
9
|
+
* Creating EQ product data query (#CX24-1810) ([8d9741f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8d9741f48bbdab5a5704ac38262bd8f56ff1d180)), closes [#CX24-1810](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-1810)
|
10
|
+
* Creating EQ product data query (#CX24-1810) ([9e630e3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9e630e33e4aee1049ddfb60af1f299d90eadee08)), closes [#CX24-1810](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-1810)
|
11
|
+
* Creating EQ product data query (#CX24-1810) ([9dc067e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9dc067e9e2dbb18aa327222339521d205d2086f8)), closes [#CX24-1810](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-1810)
|
12
|
+
* Creating EQ product data query (#CX24-1810) ([a846bdc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a846bdc2976d12d722dfca77e136e3f47e27998c)), closes [#CX24-1810](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-1810)
|
13
|
+
* Creating EQ product data query (#CX24-1810) ([4be96a8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4be96a89388dc2b226d0f02361f533fb3565b36b)), closes [#CX24-1810](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-1810)
|
14
|
+
|
1
15
|
## [1.4.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.3...v1.4.4) (2022-06-10)
|
2
16
|
|
3
17
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.5.0-cx24-1810.1",
|
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": {
|
@@ -29,7 +29,9 @@
|
|
29
29
|
"prettier": "1.19.1"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@nuskin/ns-common-lib": "1.3.0"
|
32
|
+
"@nuskin/ns-common-lib": "1.3.0",
|
33
|
+
"@nuskin/ns-util": "3.103.0-cx24-1810.2",
|
34
|
+
"axios": "^0.27.2"
|
33
35
|
},
|
34
36
|
"files": [
|
35
37
|
"src/"
|
package/src/index.js
CHANGED
@@ -12,6 +12,7 @@ const ProductContentMapper = require("./productContentMapper.js");
|
|
12
12
|
const ProductStatus = require("./productStatus.js");
|
13
13
|
const ProductStatusMapper = require("./productStatusMapper.js");
|
14
14
|
const ProductUtils = require("./productUtils.js");
|
15
|
+
const ProductData = require('./productData.js');
|
15
16
|
|
16
17
|
module.exports = {
|
17
18
|
Agelocme,
|
@@ -20,5 +21,6 @@ module.exports = {
|
|
20
21
|
ProductContentMapper,
|
21
22
|
ProductStatus,
|
22
23
|
ProductStatusMapper,
|
23
|
-
ProductUtils
|
24
|
+
ProductUtils,
|
25
|
+
ProductData
|
24
26
|
};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
const axios = require("axios");
|
3
|
+
|
4
|
+
const ProductData = {
|
5
|
+
getProductData: async function (skus, runConfig, marketConfig, eqMarkets) {
|
6
|
+
let productResponse = {};
|
7
|
+
let locale = `${runConfig.language}_${runConfig.country}`;
|
8
|
+
if (this.findMarket(runConfig.country, eqMarkets)) {
|
9
|
+
let lambdaUrl = "https://storefront.api.wde.nuskin.io/orchestrationservices/storefront/catalogs/search";
|
10
|
+
const payload = {
|
11
|
+
storeId: "422",
|
12
|
+
filter:
|
13
|
+
'{"filters":[{"field":"index_key_skuId","operation":"IN","value":"' +
|
14
|
+
skus.toString() +
|
15
|
+
'"}]}'
|
16
|
+
|
17
|
+
};
|
18
|
+
let productDataResponse = await axios.request({
|
19
|
+
method: "get",
|
20
|
+
url: lambdaUrl,
|
21
|
+
data: payload,
|
22
|
+
//headers: getProductDataRequestHeaders(marketConfig),
|
23
|
+
responseType: "json"
|
24
|
+
});
|
25
|
+
|
26
|
+
productResponse = this.eqProductMapper(productDataResponse)
|
27
|
+
|
28
|
+
} else {
|
29
|
+
let lambdaUrl = `${marketConfig.awsUrl}/productData/v1`;
|
30
|
+
const payload = {
|
31
|
+
locale: locale,
|
32
|
+
skus: skus
|
33
|
+
};
|
34
|
+
productResponse = await axios.request({
|
35
|
+
method: "post",
|
36
|
+
url: lambdaUrl,
|
37
|
+
data: payload,
|
38
|
+
// headers: getProductDataRequestHeaders(marketConfig),
|
39
|
+
responseType: "json"
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
return productResponse;
|
44
|
+
},
|
45
|
+
|
46
|
+
findMarket: function (code, eqMarkets) {
|
47
|
+
return eqMarkets.filter(
|
48
|
+
function (eqMarkets) { return eqMarkets.code == code }
|
49
|
+
);
|
50
|
+
},
|
51
|
+
|
52
|
+
eqProductMapper: function (productDataResponse) {
|
53
|
+
return productDataResponse;
|
54
|
+
},
|
55
|
+
|
56
|
+
getProductDataRequestHeaders: function (marketConfig) {
|
57
|
+
return {
|
58
|
+
"Content-Type": "application/json",
|
59
|
+
client_id: marketConfig.checkout.clientId,
|
60
|
+
client_secret: marketConfig.checkout.clientSecret
|
61
|
+
};
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
module.exports = ProductData;
|