@nuskin/ns-product-lib 1.5.0-cx24-2121.1.5 → 1.5.0-cx24-2126.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 CHANGED
@@ -1,38 +1,9 @@
1
- # [1.5.0-cx24-2121.1.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-cx24-2121.1.4...v1.5.0-cx24-2121.1.5) (2022-08-19)
1
+ # [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)
2
2
 
3
3
 
4
- ### Update
5
-
6
- * pass the store ID to getProductData (CX24-2121) ([9449dac](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9449dac0eb6544e852c517515655e90503c2ac06))
7
- * pass the store ID to getProductData (CX24-2121) ([50a3d07](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/50a3d07502564ebeb2639c2096c2af5c6822e601))
8
-
9
- # [1.5.0-cx24-2121.1.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-cx24-2121.1.3...v1.5.0-cx24-2121.1.4) (2022-08-19)
10
-
11
-
12
- ### Update
13
-
14
- * pass the store ID to getProductData (CX24-2121) ([2f994f6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2f994f6214d9854648bf4bef62d47694f59e4001))
15
-
16
- # [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)
17
-
18
-
19
- ### Update
20
-
21
- * pass the store ID to getProductData (CX24-2121) ([8bb39fb](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8bb39fb1179514ed02a5efd35ed86e1f75b53ff7))
22
-
23
- # [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)
24
-
25
-
26
- ### Update
27
-
28
- * remove hardcoded store ID (CX24-2121) ([3dd107e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3dd107ee1cf12de883f6756f271fc7954f0d60f2))
29
-
30
- # [1.5.0-cx24-2121.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-CX24.1...v1.5.0-cx24-2121.1.1) (2022-08-18)
31
-
32
-
33
- ### Update
4
+ ### New
34
5
 
35
- * add getMarket that returns the market name and store ID (CX24-2121) ([c3821fb](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/c3821fb4722e5d5e83bff93aa735ea75741b8a32))
6
+ * 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)
36
7
 
37
8
  # [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)
38
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "1.5.0-cx24-2121.1.5",
3
+ "version": "1.5.0-cx24-2126.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": {
@@ -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-cx24-2121.1.2",
33
+ "@nuskin/ns-util": "3.104.0-CX24.1",
34
34
  "axios": "0.27.2",
35
35
  "qs": "6.11.0"
36
36
  },
@@ -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
- return await this.getProductFromLegacy(skus, locale, marketConfig);
20
- },
21
-
22
- getProductFromEquinox: async function(skus, locale, marketConfig, storeID) {
23
- const filter = `{
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 = `https://${marketConfig.mySiteKongURL || "storefront.api.wts.nuskin.io"}`;
42
10
 
43
- return this.eqProductMapper(productDataResponse.data.product);
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
- getProductFromLegacy: async function(skus, locale, marketConfig) {
47
- const lambdaUrl = `${marketConfig.awsUrl}/productData/v1`;
48
- const payload = { locale, skus };
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 await axios.request({
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,