@nuskin/ns-product-lib 2.3.0-cx24-2186.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
- # [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)
1
+ # [2.3.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.2.0...v2.3.0) (2022-10-14)
2
2
 
3
3
 
4
- ### New
4
+ ### Update
5
5
 
6
- * 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)
6
+ * Get Kong URL from contentstack (CX24-2447) ([035d01d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/035d01dcdad1b7daab11d76085be65b9e7a29210))
7
7
 
8
8
  # [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)
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.3.0-cx24-2186.1",
3
+ "version": "2.3.0",
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": {
@@ -24,6 +24,7 @@
24
24
  "eslint-config-prettier": "4.1.0",
25
25
  "eslint-plugin-json": "2.1.1",
26
26
  "eslint-plugin-prettier": "3.1.2",
27
+ "axios-mock-adapter": "1.18.2",
27
28
  "jest": "25.1.0",
28
29
  "jest-sonar-reporter": "2.0.0",
29
30
  "prettier": "1.19.1"
package/src/product.js CHANGED
@@ -72,11 +72,6 @@ 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
-
80
75
  this.setMarketAttributes = function(productStatus) {
81
76
  if (productStatus.marketAttributes) {
82
77
  this.marketAttributes = productStatus.marketAttributes;
@@ -631,7 +626,6 @@ const Product = function(productData) {
631
626
  this.marketAttributes = productData.marketAttributes;
632
627
  this.addOns = productData.addOns || [];
633
628
  this.restrictedMarkets = productData.restrictedMarkets || [];
634
- this.inventoryLabel = productData.inventoryLabel || "";
635
629
 
636
630
  if (data.priceType) {
637
631
  this.addPricing(data.priceType, data.price);
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  const axios = require("axios");
3
3
  const contentstack = require('./contentstack/contentstack');
4
- const Product = require("./product");
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,15 +92,13 @@ const ProductData = {
92
92
 
93
93
  eqProductMapper: function (productDataResponse) {
94
94
  let prod = [];
95
-
96
- //sku[0] is equal to base sku
97
95
  let count = 0;
98
96
 
99
97
  let prodArr = productDataResponse.map((data) => {
100
98
  let imageURL = data.sku[count].properties.imageURL;
101
99
  const regex = /\d+.\d+/
102
100
  let thumbnailImage = ''
103
-
101
+
104
102
  if (imageURL.includes('contentstack')) {
105
103
  thumbnailImage = imageURL + '?width=40'
106
104
  } else {
@@ -209,18 +207,16 @@ const ProductData = {
209
207
  "earn": true
210
208
  },
211
209
  "restrictedMarkets": [],
212
- "addOns": [],
213
- inventoryLabel: data.sku[count].inventory || ""
210
+ "addOns": []
214
211
  };
215
-
216
- return new Product(prod);
217
- });
212
+ let newProduct = new product(prod);
213
+ return newProduct
214
+ })
218
215
 
219
216
  let data = {
220
217
  products: prodArr,
221
218
  count: productDataResponse.length
222
219
  };
223
-
224
220
  return {
225
221
  data: {
226
222
  "status": 200,
@@ -256,13 +252,13 @@ const ProductData = {
256
252
  },
257
253
 
258
254
  /**
259
- *
260
- * @param {*} custType
261
- *
255
+ *
256
+ * @param {*} custType
257
+ *
262
258
  */
263
259
  switchCustType: function (custType) {
264
260
  let newCustType = [];
265
- if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
261
+ if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
266
262
  newCustType.push(10)
267
263
  if (custType.includes('Retail Customer'))
268
264
  newCustType.push(20)