@nuskin/ns-product-lib 1.4.2 → 1.4.5-cx12-4643.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,3 +1,25 @@
1
+ ## [1.4.5-cx12-4643.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.4...v1.4.5-cx12-4643.1) (2022-07-27)
2
+
3
+
4
+ ### Fix
5
+
6
+ * Check for valid productStatusV2Response before reading items (#CX12-4643) ([40cb2a7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/40cb2a770e76c68da33d7322d2947323696d3781)), closes [#CX12-4643](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX12-4643)
7
+ * sonarQube issue ([82deb06](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/82deb06c84af639829394da786184031a07f4da5))
8
+
9
+ ## [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)
10
+
11
+
12
+ ### Fix
13
+
14
+ * Add locallyProduced flag from productStatus data in addPricingFromStatus function (#CX17-5611) ([0b4b819](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0b4b819125e3dc0f4cc61a2116bcaeacb9555f9b)), closes [#CX17-5611](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX17-5611)
15
+
16
+ ## [1.4.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.2...v1.4.3) (2022-05-03)
17
+
18
+
19
+ ### Fix
20
+
21
+ * not_sold_seperately status appended to productStatus model (#CX12-3738) ([9a503a4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9a503a4f74a31e172a2f6f1a1bcd989c4045742b)), closes [#CX12-3738](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX12-3738)
22
+
1
23
  ## [1.4.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.1...v1.4.2) (2022-04-07)
2
24
 
3
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "1.4.2",
3
+ "version": "1.4.5-cx12-4643.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": {
package/src/product.js CHANGED
@@ -291,6 +291,7 @@ const Product = function(productData) {
291
291
  this.status = productStatus.status;
292
292
  this.availableQuantity = productStatus.availableQuantity;
293
293
  this.maxQuantity = productStatus.maxQuantity || 999;
294
+ this.locallyProduced = productStatus.locallyProduced || false;
294
295
  if (productStatus.backordered) {
295
296
  this.backOrderDate = productStatus.backorderedAvailableDate;
296
297
  }
@@ -307,7 +308,7 @@ const Product = function(productData) {
307
308
  }
308
309
  if (productStatus.csv) {
309
310
  Object.keys(productStatus.csv).map((csvKey) => {
310
- this.addCvWithType(csvKey, productStatus.csv[csvKey]);
311
+ return this.addCvWithType(csvKey, productStatus.csv[csvKey]);
311
312
  }, this);
312
313
  }
313
314
  this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
@@ -6,14 +6,17 @@ const ProductStatus = {
6
6
  ReleasedForSale: "RELEASED_FOR_SALE",
7
7
  NotFound: "NOT_FOUND",
8
8
  StopStatus: "STOP_STATUS",
9
+ // note - we're keeping the incorrect spelling of 'seperately' instead 'separately'
10
+ NotSoldSeperately: "NOT_SOLD_SEPERATELY",
9
11
 
10
- //properties allows you do do something like ProductStatus.properties['DISCONTINUED'].code to get the status code
12
+ // properties allows you do do something like ProductStatus.properties['DISCONTINUED'].code to get the status code
11
13
  properties: {
12
14
  DISCONTINUED: { stringKey: "discontinued", code: 2 },
13
15
  NOT_RELEASED_FOR_SALE: { stringKey: "notReleasedForSale", code: 9 },
14
16
  RELEASED_FOR_SALE: { stringKey: "", code: 10 },
15
17
  STOP_STATUS: { stringKey: "stopStatus", code: 5 },
16
- NOT_FOUND: { stringKey: "", code: 0 }
18
+ NOT_FOUND: { stringKey: "", code: 0 },
19
+ NOT_SOLD_SEPERATELY: {stringKey: "notSoldSeperately", code: 4 }
17
20
  }
18
21
  };
19
22
 
@@ -13,7 +13,7 @@ const ProductStatusMapper = {
13
13
  */
14
14
  createProductStatusesFromV2: function(productStatusV2Response) {
15
15
  const productStatuses = [];
16
- if (productStatusV2Response.items) {
16
+ if (productStatusV2Response && productStatusV2Response.items) {
17
17
  for (const productStatusSku of Object.keys(productStatusV2Response.items)) {
18
18
  const productStatusV2 = productStatusV2Response.items[productStatusSku];
19
19
  productStatusV2.sku = productStatusSku;
@@ -55,11 +55,12 @@ const ProductStatusMapper = {
55
55
  * @return {String}
56
56
  */
57
57
  function getStatusPartFromV2(productStatusV2) {
58
- const retailStatusIsReleased = productStatusV2.status.retail === 'RELEASED_FOR_SALE';
58
+ const status = productStatusV2.status || {};
59
+ const retailStatusIsReleased = status.retail === 'RELEASED_FOR_SALE';
59
60
  const wholesaleStatusIsReleased =
60
- productStatusV2.status.wholesale === 'RELEASED_FOR_SALE';
61
- const retailNotSet = productStatusV2.status.retail === 'NOT_SET_FOR_DIST_TYPE';
62
- const wholesaleNotSet = productStatusV2.status.wholesale === 'NOT_SET_FOR_DIST_TYPE';
61
+ status.wholesale === 'RELEASED_FOR_SALE';
62
+ const retailNotSet = status.retail === 'NOT_SET_FOR_DIST_TYPE';
63
+ const wholesaleNotSet = status.wholesale === 'NOT_SET_FOR_DIST_TYPE';
63
64
  if (retailStatusIsReleased || wholesaleStatusIsReleased) {
64
65
  return 'RELEASED_FOR_SALE';
65
66
  }
@@ -69,14 +70,14 @@ function getStatusPartFromV2(productStatusV2) {
69
70
  return 'NOT_RELEASED_FOR_SALE';
70
71
  }
71
72
  if (retailNotSet) {
72
- return productStatusV2.status.wholesale;
73
+ return status.wholesale;
73
74
  }
74
75
  if (wholesaleNotSet) {
75
- return productStatusV2.status.retail;
76
+ return status.retail;
76
77
  }
77
78
  }
78
79
 
79
- return productStatusV2.status.retail;
80
+ return status.retail;
80
81
  }
81
82
 
82
83
  /**