@nuskin/ns-product-lib 2.6.1-cx24-3607.1 → 2.6.1-cx24-3607.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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.6.1-cx24-3607.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-3607.1...v2.6.1-cx24-3607.2) (2023-03-16)
2
+
3
+
4
+ ### Fix
5
+
6
+ * (equinox-enabled) skip product mapping when an error occurs in PLP #CX24-3607 ([49fa749](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/49fa7499b390aa84cc887fc631037363421d252a)), closes [#CX24-3607](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3607)
7
+
1
8
  ## [2.6.1-cx24-3607.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0...v2.6.1-cx24-3607.1) (2023-03-15)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.6.1-cx24-3607.1",
3
+ "version": "2.6.1-cx24-3607.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": {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * childSKU maps a product variant. Used mainly in subscription.
3
+ *
4
+ * @param {import('.').KitSKUQuantity[]} kits
5
+ * @param {import('.').EquinoxProduct} product
6
+ */
7
+ function childSKU(kits, product) {
8
+ const sku = product.sku.filter(sku => sku.default)[0];
9
+ if (!sku) {
10
+ throw Error('Unable to find the default SKU.');
11
+ }
12
+
13
+ const kit = kits.filter(k => k.sku === sku.identifier)[0];
14
+ if (!kit) {
15
+ throw Error('SKU kit does not exist in the list of available variants.');
16
+ }
17
+
18
+ return {
19
+ productId: product.identifier,
20
+ skuId: sku.identifier,
21
+ type: 'MANDATORY',
22
+ skuQuantity: kit.qty,
23
+ availableChannels: sku.properties.availableChannels,
24
+ inventory: {
25
+ atpQty: sku.inventoryProperties.atpQty,
26
+ backOrdered: sku.inventoryProperties.backOrdered
27
+ }
28
+ }
29
+ }
30
+
31
+ module.exports = childSKU;
@@ -19,14 +19,18 @@
19
19
  * @description This model represents a product within an Equinox response.
20
20
  * @typedef EquinoxProduct
21
21
  * @type {object}
22
- * @property {EquinoxProduct[]} sku
22
+ * @property {string} identifier
23
+ * @property {EquinoxProductSKU[]} sku
23
24
  * @property {"kit"|"bundle"} [type]
24
25
  *
25
26
  * @typedef EquinoxProductSKU
26
27
  * @type {object}
28
+ * @property {boolean} default
29
+ * For multi-variant products, this indicates that this is the searched SKU
30
+ * when using catalogs/search endpoint.
27
31
  * @property {string} identifier
28
- * @property {EquinoxProductProperties} properties
29
32
  * @property {Inventory} inventoryProperties
33
+ * @property {EquinoxProductProperties} properties
30
34
  *
31
35
  * @typedef EquinoxProductProperties
32
36
  * @type {object}
@@ -49,12 +53,12 @@
49
53
  * @typedef KitSKUQuantity
50
54
  * @type {object}
51
55
  * @property {string} sku
52
- * @property {number} number
56
+ * @property {number} qty
53
57
  */
54
58
  const availableQuantity = require('./availableQuantity');
55
- const childSkus = require('./childSkus');
59
+ const childSKU = require('./childSKU');
56
60
 
57
61
  module.exports = {
58
62
  mapAvailableQuantity: availableQuantity,
59
- mapChildSkus: childSkus
63
+ mapChildSKU: childSKU
60
64
  };
@@ -5,7 +5,7 @@ const contentstack = require('./contentstack/contentstack');
5
5
  const Product = require("./product");
6
6
  const CustomerTypes = require('./models/customerTypes');
7
7
  const ProductStatus = require("./models/productStatus");
8
- const { mapAvailableQuantity, mapChildSkus } = require('./equinox-helpers');
8
+ const { mapAvailableQuantity, mapChildSKU } = require('./equinox-helpers');
9
9
 
10
10
  const productTypes = {
11
11
  kit: 'kit'
@@ -522,7 +522,7 @@ const ProductData = {
522
522
  type: 'SKUKIT',
523
523
  availableChannels: product.properties.availableChannels
524
524
  },
525
- ...res.data.product.map(p => mapChildSkus(kits, p))
525
+ ...res.data.product.map(p => mapChildSKU(kits, p))
526
526
  ];
527
527
 
528
528
  return childSkus;
@@ -1,25 +0,0 @@
1
- /**
2
- * childSkus creates an array of object that contains
3
- * the list of SKUs of a kit.
4
- *
5
- * @param {import('./').KitSKUQuantity[]} kits
6
- * @param {import('./').EquinoxProduct} product
7
- */
8
- function childSkus(kits, product) {
9
- const sku = product.sku[0];
10
- const kit = kits.filter(k => k.sku === sku.identifier)[0];
11
-
12
- return {
13
- productId: product.identifier,
14
- skuId: sku.identifier,
15
- type: 'MANDATORY',
16
- skuQuantity: kit.qty,
17
- availableChannels: sku.properties.availableChannels,
18
- inventory: {
19
- atpQty: sku.inventoryProperties.atpQty,
20
- backOrdered: sku.inventoryProperties.backOrdered
21
- }
22
- }
23
- }
24
-
25
- module.exports = childSkus;