@nuskin/ns-product-lib 2.7.0-cx24-3682.13 → 2.7.0-cx24-3682.14

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # [2.7.0-cx24-3682.14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.13...v2.7.0-cx24-3682.14) (2023-03-28)
2
+
3
+
4
+ ### New
5
+
6
+ * MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([aae3544](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/aae35440a744d4740a680471f57c7350fc6b9714)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
7
+ * MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([6124e9b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6124e9b4fa30f976dbe52ea88c2fcb588b2187cf)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
8
+
1
9
  # [2.7.0-cx24-3682.13](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.12...v2.7.0-cx24-3682.13) (2023-03-27)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.7.0-cx24-3682.13",
3
+ "version": "2.7.0-cx24-3682.14",
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": {
@@ -67,47 +67,47 @@
67
67
  * @description These are the properties unique to Normal product type.
68
68
  * @typedef EquinoxNormalProductProperties
69
69
  * @type {object}
70
- * @property {string} ingredients
71
- * @property {string} benefits
72
- * @property {string} usage
73
- * @property {string} resources
74
- * @property {string} scanQualifiedCount e.g., "0"
75
- * @property {string} status e.g., "active"
76
- * @property {string} size e.g., "30 mL / 1 fl.oz"
77
- * @property {string} productDetailsDescription e.g., "[]"
70
+ * @property {string} [ingredients]
71
+ * @property {string} [benefits]
72
+ * @property {string} [usage]
73
+ * @property {string} [resources]
74
+ * @property {string} [scanQualifiedCount] e.g., "0"
75
+ * @property {string} [status] e.g., "active"
76
+ * @property {string} [size] e.g., "30 mL / 1 fl.oz"
77
+ * @property {string} [productDetailsDescription] e.g., "[]"
78
78
  */
79
79
 
80
80
  /**
81
81
  * @description These are the properties unique to Kit product type.
82
82
  * @typedef EquinoxKitProductProperties
83
83
  * @type {object}
84
- * @property {string} skukits e.g., "02002145~1,02002146~1,02002147~1,02002148~1,02002142~1,02002143~1"
85
- * @property {string} productStatus e.g., "Sellable"
86
- * @property {string} availableChannels e.g., "subscription,arsPhone,kiosk,mobile,web"
84
+ * @property {string} [skukits] e.g., "02002145~1,02002146~1,02002147~1,02002148~1,02002142~1,02002143~1"
85
+ * @property {string} [productStatus] e.g., "Sellable"
86
+ * @property {string} [availableChannels] e.g., "subscription,arsPhone,kiosk,mobile,web"
87
+ * @property {string} [market] e.g., "CA"
87
88
  */
88
89
 
89
90
  /**
90
91
  * @description These are the common properties between Normal and Kit product types
91
92
  * @typedef EquinoxProductCommonProperties
92
93
  * @type {object}
93
- * @property {string} name e.g., "180° Cell Renewal Fluid"
94
- * @property {string} imageURL e.g., "https://nuskin.com/content/dam/global/...ule-refreshed.jpg"
95
- * @property {string} market e.g., "CA"
96
- * @property {string} description e.g., "180° Ampoule"
97
- * @property {string} customerTypes e.g., "BrandAffiliate,Preferred,Retail"
98
- * @property {string} division e.g., "Nu Skin"
94
+ * @property {string} [name] e.g., "180° Cell Renewal Fluid"
95
+ * @property {string} [imageURL] e.g., "https://nuskin.com/content/dam/global/...ule-refreshed.jpg"
96
+ * @property {string} [description] e.g., "180° Ampoule"
97
+ * @property {string} [customerTypes] e.g., "BrandAffiliate,Preferred,Retail"
98
+ * @property {string} [division] e.g., "Nu Skin"
99
99
  */
100
100
 
101
101
  /**
102
102
  * @typedef EquinoxProductVariant
103
103
  * @type {object}
104
- * @property {string} identifier e.g., "02002145"
105
- * @property {string} inventory e.g., "IN STOCK"
106
- * @property {EquinoxProductVariantProperties} properties
107
- * @property {any[]} promotion e.g., ???
108
- * @property {EquinoxProductPriceFacets} priceFacets
109
- * @property {EquinoxProductInventoryProperties} inventoryProperties
110
- * @property {EquinxProductTotalValue} totalValue
104
+ * @property {string} [identifier] e.g., "02002145"
105
+ * @property {string} [inventory] e.g., "IN STOCK"
106
+ * @property {EquinoxProductVariantProperties} [properties]
107
+ * @property {any[]} [promotion] e.g., ???
108
+ * @property {EquinoxProductPriceFacets} [priceFacets]
109
+ * @property {EquinoxProductInventoryProperties} [inventoryProperties]
110
+ * @property {EquinxProductTotalValue} [totalValue]
111
111
  * @property {boolean} [default] For multi-variant products, this indicates that this is the searched SKU
112
112
  * when using catalogs/search endpoint.
113
113
  */
@@ -116,25 +116,25 @@
116
116
  * @description This does not contain the full list of properties from the response.
117
117
  * @typedef EquinoxProductVariantProperties
118
118
  * @type {object}
119
- * @property {string} availableChannels e.g., "subscription,arsPhone,kiosk,mobile,web"
120
- * @property {string} imageURL e.g., "https://nuskin.com/cont...21/ca-180-Ampoule-refreshed.jpg"
121
- * @property {string} name e.g., "180° Cell Renewal Fluid"
122
- * @property {string} market e.g., "CA"
123
- * @property {string} description e.g., "180° Ampoule"
124
- * @property {string} ingredients
125
- * @property {string} benefits
126
- * @property {string} usage
127
- * @property {string} resources
128
- * @property {string} scanQualifiedCount e.g., "0"
129
- * @property {string} customerTypes e.g., "BrandAffiliate,Preferred,Retail"
130
- * @property {string} division e.g., "Nu Skin"
131
- * @property {string} status e.g., "active"
132
- * @property {string} size e.g., "30 mL / 1 fl.oz"
133
- * @property {string} globalProductId
134
- * @property {string} excludeFromSearch
135
- * @property {string} chargeShipping
136
- * @property {string} title
137
- * @property {string} productStatus e.g., "Sellable"
119
+ * @property {string} [availableChannels] e.g., "subscription,arsPhone,kiosk,mobile,web"
120
+ * @property {string} [imageURL] e.g., "https://nuskin.com/cont...21/ca-180-Ampoule-refreshed.jpg"
121
+ * @property {string} [name] e.g., "180° Cell Renewal Fluid"
122
+ * @property {string} [market] e.g., "CA"
123
+ * @property {string} [description] e.g., "180° Ampoule"
124
+ * @property {string} [ingredients]
125
+ * @property {string} [benefits]
126
+ * @property {string} [usage]
127
+ * @property {string} [resources]
128
+ * @property {string} [scanQualifiedCount] e.g., "0"
129
+ * @property {string} [customerTypes] e.g., "BrandAffiliate,Preferred,Retail"
130
+ * @property {string} [division] e.g., "Nu Skin"
131
+ * @property {string} [status] e.g., "active"
132
+ * @property {string} [size] e.g., "30 mL / 1 fl.oz"
133
+ * @property {string} [globalProductId]
134
+ * @property {string} [excludeFromSearch]
135
+ * @property {string} [chargeShipping]
136
+ * @property {string} [title]
137
+ * @property {string} [productStatus] e.g., "Sellable"
138
138
  * @property {string} [variantLabel]
139
139
  * @property {string} [isExclusive] e.g., "false" - Why is this a string??
140
140
  */
@@ -154,18 +154,18 @@
154
154
  * @description
155
155
  * @typedef EquinoxProductInventoryProperties
156
156
  * @type {object}
157
- * @property {boolean} available e.g., true
158
- * @property {boolean} lowStock e.g., false
159
- * @property {string} binName e.g., "1046_CA01"
160
- * @property {boolean} backOrdered e.g., false
161
- * @property {number} expectedBackOrderAvailabilityDate e.g., 0
162
- * @property {boolean} preOrdered e.g., false
163
- * @property {number} expectedPreOrderAvailabilityDate e.g., 0
164
- * @property {number} atpQty e.g., 49882
165
- * @property {number} preOrderedQty e.g., 0
166
- * @property {number} backOrderedQty e.g., 0
167
- * @property {number|null} lowStockThreshold e.g., null
168
- * @property {number|null} outOfStockThreshold e.g., null
157
+ * @property {boolean} [available] e.g., true
158
+ * @property {boolean} [lowStock] e.g., false
159
+ * @property {string} [binName] e.g., "1046_CA01"
160
+ * @property {boolean} [backOrdered] e.g., false
161
+ * @property {number} [expectedBackOrderAvailabilityDate] e.g., 0
162
+ * @property {boolean} [preOrdered] e.g., false
163
+ * @property {number} [expectedPreOrderAvailabilityDate] e.g., 0
164
+ * @property {number} [atpQty] e.g., 49882
165
+ * @property {number} [preOrderedQty] e.g., 0
166
+ * @property {number} [backOrderedQty] e.g., 0
167
+ * @property {number|null} [lowStockThreshold] e.g., null
168
+ * @property {number|null} [outOfStockThreshold] e.g., null
169
169
  */
170
170
 
171
171
  /**
@@ -1,3 +1,4 @@
1
+ const { getCachedConfiguration } = require('@nuskin/configuration-sdk');
1
2
  const { productNotFound } = require('../models');
2
3
 
3
4
  // httpStatus codes
@@ -20,11 +21,12 @@ function productNotFoundInterceptor(error) {
20
21
  const sku = getSKU(filterParam);
21
22
 
22
23
  if (sku !== null) {
24
+ const market = getCachedConfiguration('Equinox_Markets').country_code;
23
25
  const response = {
24
26
  ...error.response,
25
27
  data: {
26
28
  product: [
27
- productNotFound(sku)
29
+ productNotFound({ identifier: sku }, market)
28
30
  ]
29
31
  },
30
32
  statusText: getStatusText(error.response)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @param {string} identifier
2
+ * @param {string|undefined} identifier
3
3
  * @returns {string}
4
4
  */
5
5
  function mapIdentifier(identifier) {
@@ -2,10 +2,12 @@ const mapIdentifier = require('./identifier');
2
2
  const mapInventoryProperties = require('./inventoryProperties');
3
3
  const mapProperties = require('./properties');
4
4
  const mapVariant = require('./variant');
5
+ const mapVariantProperties = require('./variantProperties');
5
6
 
6
7
  module.exports = {
7
8
  mapIdentifier,
8
9
  mapInventoryProperties,
9
10
  mapProperties,
10
- mapVariant
11
+ mapVariant,
12
+ mapVariantProperties
11
13
  };
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * @param {import('../').EquinoxProductInventoryProperties} inventoryProperties
5
5
  */
6
- function mapInventoryProperties(inventoryProperties) {
6
+ function mapInventoryProperties(inventoryProperties = {}) {
7
7
  /** @type {import('../').EquinoxProductInventoryProperties} */
8
8
  const model = {};
9
9
  model.available = mapAvailable(inventoryProperties.available);
@@ -27,7 +27,7 @@ function mapInventoryProperties(inventoryProperties) {
27
27
  }
28
28
 
29
29
  /**
30
- * @param {boolean} available
30
+ * @param {boolean|undefined} available
31
31
  * @returns {boolean}
32
32
  */
33
33
  function mapAvailable(available) {
@@ -39,7 +39,7 @@ function mapAvailable(available) {
39
39
  }
40
40
 
41
41
  /**
42
- * @param {boolean} lowStock
42
+ * @param {boolean|undefined} lowStock
43
43
  * @returns {boolean}
44
44
  */
45
45
  function mapLowStock(lowStock) {
@@ -51,7 +51,7 @@ function mapLowStock(lowStock) {
51
51
  }
52
52
 
53
53
  /**
54
- * @param {string} binName
54
+ * @param {string|undefined} binName
55
55
  * @returns {string}
56
56
  */
57
57
  function mapBinName(binName) {
@@ -63,7 +63,7 @@ function mapBinName(binName) {
63
63
  }
64
64
 
65
65
  /**
66
- * @param {boolean} backOrdered
66
+ * @param {boolean|undefined} backOrdered
67
67
  * @returns {boolean}
68
68
  */
69
69
  function mapBackOrdered(backOrdered) {
@@ -75,7 +75,7 @@ function mapBackOrdered(backOrdered) {
75
75
  }
76
76
 
77
77
  /**
78
- * @param {number} expectedBackOrderAvailabilityDate
78
+ * @param {number|undefined} expectedBackOrderAvailabilityDate
79
79
  * @returns {number}
80
80
  */
81
81
  function mapExpectedBackOrderAvailabilityDate(expectedBackOrderAvailabilityDate) {
@@ -87,7 +87,7 @@ function mapExpectedBackOrderAvailabilityDate(expectedBackOrderAvailabilityDate)
87
87
  }
88
88
 
89
89
  /**
90
- * @param {boolean} preOrdered
90
+ * @param {boolean|undefined} preOrdered
91
91
  * @returns {boolean}
92
92
  */
93
93
  function mapPreOrdered(preOrdered) {
@@ -99,7 +99,7 @@ function mapPreOrdered(preOrdered) {
99
99
  }
100
100
 
101
101
  /**
102
- * @param {number} expectedPreOrderAvailabilityDate
102
+ * @param {number|undefined} expectedPreOrderAvailabilityDate
103
103
  * @returns {number}
104
104
  */
105
105
  function mapExpectedPreOrderAvailabilityDate(expectedPreOrderAvailabilityDate) {
@@ -111,7 +111,7 @@ function mapExpectedPreOrderAvailabilityDate(expectedPreOrderAvailabilityDate) {
111
111
  }
112
112
 
113
113
  /**
114
- * @param {number} atpQty
114
+ * @param {number|undefined} atpQty
115
115
  * @returns {number}
116
116
  */
117
117
  function mapAtpQty(atpQty) {
@@ -123,7 +123,7 @@ function mapAtpQty(atpQty) {
123
123
  }
124
124
 
125
125
  /**
126
- * @param {number} preOrderedQty
126
+ * @param {number|undefined} preOrderedQty
127
127
  * @returns {number}
128
128
  */
129
129
  function mapPreOrderedQty(preOrderedQty) {
@@ -135,7 +135,7 @@ function mapPreOrderedQty(preOrderedQty) {
135
135
  }
136
136
 
137
137
  /**
138
- * @param {number} backOrderedQty
138
+ * @param {number|undefined} backOrderedQty
139
139
  * @returns {number}
140
140
  */
141
141
  function mapBackOrderedQty(backOrderedQty) {
@@ -147,7 +147,7 @@ function mapBackOrderedQty(backOrderedQty) {
147
147
  }
148
148
 
149
149
  /**
150
- * @param {number|null} lowStockThreshold
150
+ * @param {number|null|undefined} lowStockThreshold
151
151
  * @returns {number|null}
152
152
  */
153
153
  function mapLowStockThreshold(lowStockThreshold) {
@@ -159,7 +159,7 @@ function mapLowStockThreshold(lowStockThreshold) {
159
159
  }
160
160
 
161
161
  /**
162
- * @param {number|null} outOfStockThreshold
162
+ * @param {number|null|undefined} outOfStockThreshold
163
163
  * @returns {number|null}
164
164
  */
165
165
  function mapOutOfStockThreshold(outOfStockThreshold) {
@@ -3,7 +3,7 @@
3
3
  * mapProperties maps the properties of a product.
4
4
  * @param {import('../').EquinoxProductProperties} props
5
5
  */
6
- function mapProperties(props) {
6
+ function mapProperties(props = {}) {
7
7
  /** @type {import('../').EquinoxProductProperties} */
8
8
  const properties = {};
9
9
  properties.name = mapName(props.name);
@@ -15,7 +15,6 @@ function mapProperties(props) {
15
15
  properties.scanQualifiedCount = mapScanQualifiedCount(props.scanQualifiedCount);
16
16
  properties.division = mapDivision(props.division);
17
17
  properties.imageURL = mapImageURL(props.imageURL);
18
- properties.market = mapMarket(props.market);
19
18
  properties.resources = mapResources(props.resources);
20
19
  properties.customerTypes = mapCustomerTypes(props.customerTypes);
21
20
  properties.size = mapSize(props.size);
@@ -48,7 +47,7 @@ function mapDescription(description) {
48
47
  }
49
48
 
50
49
  /**
51
- * @param {string} productDetailsDescription
50
+ * @param {string|undefined} productDetailsDescription
52
51
  * @returns {string}
53
52
  */
54
53
  function mapProductDetailsDescription(productDetailsDescription) {
@@ -131,18 +130,6 @@ function mapImageURL(imageURL) {
131
130
  return '';
132
131
  }
133
132
 
134
- /**
135
- * @param {string|undefined} market
136
- * @returns {string}
137
- */
138
- function mapMarket(market) {
139
- if (market) {
140
- return market;
141
- }
142
-
143
- return '';
144
- }
145
-
146
133
  /**
147
134
  * @param {string|undefined} resources
148
135
  * @returns {string}
@@ -1,6 +1,7 @@
1
1
  // @ts-check
2
2
  const mapIdentifier = require('./identifier');
3
3
  const mapInventoryProperties = require('./inventoryProperties');
4
+ const mapVariantProperties = require('./variantProperties');
4
5
 
5
6
  /**
6
7
  * @param {import('../').EquinoxProductVariant} variant
@@ -10,28 +11,7 @@ function mapVariant(variant) {
10
11
  const model = {
11
12
  identifier: mapIdentifier(variant.identifier),
12
13
  inventory: '',
13
- properties: {
14
- benefits: '{}',
15
- excludeFromSearch: '',
16
- usage: '{}',
17
- description: '',
18
- chargeShipping: '',
19
- globalProductId: '',
20
- title: '',
21
- scanQualifiedCount: '0',
22
- division: '',
23
- isExclusive: 'false',
24
- imageURL: 'https://nuskin.com/content/dam/global/images/products/01102730-nu-skin-tri-phasic-white-essence.png',
25
- customerTypes: 'BrandAffiliate,Preferred,Retail',
26
- ingredients: '',
27
- availableChannels: 'subscription,arsPhone,kiosk,mobile,web',
28
- resources: '',
29
- market: 'CA',
30
- size: '',
31
- name: '',
32
- status: 'active',
33
- productStatus: 'Sellable'
34
- },
14
+ properties: mapVariantProperties(variant.properties),
35
15
  promotion: [],
36
16
  priceFacets: {
37
17
  CV: '',
@@ -0,0 +1,273 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @param {import('../').EquinoxProductVariantProperties} properties
5
+ */
6
+ function mapVariantProperties(properties = {}) {
7
+ /** @type {import('../').EquinoxProductVariantProperties} */
8
+ const model = {};
9
+ model.benefits = mapBenefits(properties.benefits);
10
+ model.excludeFromSearch = mapExcludeFromSearch(properties.excludeFromSearch);
11
+ model.usage = mapUsage(properties.usage);
12
+ model.description = mapDescription(properties.description);
13
+ model.chargeShipping = mapChargeShipping(properties.chargeShipping);
14
+ model.globalProductId = mapGlobalProductId(properties.globalProductId);
15
+ model.title = mapTitle(properties.title);
16
+ model.scanQualifiedCount = mapScanQualifiedCount(properties.scanQualifiedCount);
17
+ model.division = mapDivision(properties.division);
18
+ model.isExclusive = mapIsExclusive('false',);
19
+ model.imageURL = mapImageURL(properties.imageURL);
20
+ model.customerTypes = mapCustomerTypes(properties.customerTypes);
21
+ model.ingredients = mapIngredients(properties.ingredients);
22
+ model.availableChannels = mapAvailableChannels(properties.availableChannels);
23
+ model.resources = mapResources(properties.resources);
24
+ model.market = mapMarket(properties.market);
25
+ model.size = mapSize(properties.size);
26
+ model.name = mapName(properties.name);
27
+ model.status = mapStatus(properties.status);
28
+ model.productStatus = mapProductStatus(properties.productStatus);
29
+
30
+ return model;
31
+ }
32
+
33
+ /**
34
+ * @param {string|undefined} benefits
35
+ * @returns {string}
36
+ */
37
+ function mapBenefits(benefits) {
38
+ if (benefits) {
39
+ return benefits;
40
+ }
41
+
42
+ return '';
43
+ }
44
+
45
+ /**
46
+ * @param {string|undefined} excludeFromSearch
47
+ * @returns {string}
48
+ */
49
+ function mapExcludeFromSearch(excludeFromSearch) {
50
+ if (excludeFromSearch) {
51
+ return excludeFromSearch;
52
+ }
53
+
54
+ return '';
55
+ }
56
+
57
+ /**
58
+ * @param {string|undefined} usage
59
+ * @returns {string}
60
+ */
61
+ function mapUsage(usage) {
62
+ if (usage) {
63
+ return usage;
64
+ }
65
+
66
+ return '';
67
+ }
68
+
69
+ /**
70
+ * @param {string|undefined} description
71
+ * @returns {string}
72
+ */
73
+ function mapDescription(description) {
74
+ if (description) {
75
+ return description;
76
+ }
77
+
78
+ return '';
79
+ }
80
+
81
+ /**
82
+ * @param {string|undefined} chargeShipping
83
+ * @returns {string}
84
+ */
85
+ function mapChargeShipping(chargeShipping) {
86
+ if (chargeShipping) {
87
+ return chargeShipping;
88
+ }
89
+
90
+ return '';
91
+ }
92
+
93
+ /**
94
+ * @param {string|undefined} globalProductId
95
+ * @returns {string}
96
+ */
97
+ function mapGlobalProductId(globalProductId) {
98
+ if (globalProductId) {
99
+ return globalProductId;
100
+ }
101
+
102
+ return '';
103
+ }
104
+
105
+ /**
106
+ * @param {string|undefined} title
107
+ * @returns {string}
108
+ */
109
+ function mapTitle(title) {
110
+ if (title) {
111
+ return title;
112
+ }
113
+
114
+ return '';
115
+ }
116
+
117
+ /**
118
+ * @param {string|undefined} scanQualifiedCount
119
+ * @returns {string}
120
+ */
121
+ function mapScanQualifiedCount(scanQualifiedCount) {
122
+ if (scanQualifiedCount) {
123
+ return scanQualifiedCount;
124
+ }
125
+
126
+ return '';
127
+ }
128
+
129
+ /**
130
+ * @param {string|undefined} division
131
+ * @returns {string}
132
+ */
133
+ function mapDivision(division) {
134
+ if (division) {
135
+ return division;
136
+ }
137
+
138
+ return '';
139
+ }
140
+
141
+ /**
142
+ * @param {string|undefined} isExclusive
143
+ * @returns {string}
144
+ */
145
+ function mapIsExclusive(isExclusive) {
146
+ if (isExclusive) {
147
+ return isExclusive;
148
+ }
149
+
150
+ return '';
151
+ }
152
+
153
+ /**
154
+ * @param {string|undefined} imageURL
155
+ * @returns {string}
156
+ */
157
+ function mapImageURL(imageURL) {
158
+ if (imageURL) {
159
+ return imageURL;
160
+ }
161
+
162
+ return '';
163
+ }
164
+
165
+ /**
166
+ * @param {string|undefined} customerTypes
167
+ * @returns {string}
168
+ */
169
+ function mapCustomerTypes(customerTypes) {
170
+ if (customerTypes) {
171
+ return customerTypes;
172
+ }
173
+
174
+ return '';
175
+ }
176
+
177
+ /**
178
+ * @param {string|undefined} ingredients
179
+ * @returns {string}
180
+ */
181
+ function mapIngredients(ingredients) {
182
+ if (ingredients) {
183
+ return ingredients;
184
+ }
185
+
186
+ return '';
187
+ }
188
+
189
+ /**
190
+ * @param {string|undefined} availableChannels
191
+ * @returns {string}
192
+ */
193
+ function mapAvailableChannels(availableChannels) {
194
+ if (availableChannels) {
195
+ return availableChannels;
196
+ }
197
+
198
+ return '';
199
+ }
200
+
201
+ /**
202
+ * @param {string|undefined} resources
203
+ * @returns {string}
204
+ */
205
+ function mapResources(resources) {
206
+ if (resources) {
207
+ return resources;
208
+ }
209
+
210
+ return '';
211
+ }
212
+
213
+ /**
214
+ * @param {string|undefined} market
215
+ * @returns {string}
216
+ */
217
+ function mapMarket(market) {
218
+ if (market) {
219
+ return market;
220
+ }
221
+
222
+ return '';
223
+ }
224
+
225
+ /**
226
+ * @param {string|undefined} size
227
+ * @returns {string}
228
+ */
229
+ function mapSize(size) {
230
+ if (size) {
231
+ return size;
232
+ }
233
+
234
+ return '';
235
+ }
236
+
237
+ /**
238
+ * @param {string|undefined} name
239
+ * @returns {string}
240
+ */
241
+ function mapName(name) {
242
+ if (name) {
243
+ return name;
244
+ }
245
+
246
+ return '';
247
+ }
248
+
249
+ /**
250
+ * @param {string|undefined} status
251
+ * @returns {string}
252
+ */
253
+ function mapStatus(status) {
254
+ if (status) {
255
+ return status;
256
+ }
257
+
258
+ return '';
259
+ }
260
+
261
+ /**
262
+ * @param {string|undefined} productStatus
263
+ * @returns {string}
264
+ */
265
+ function mapProductStatus(productStatus) {
266
+ if (productStatus) {
267
+ return productStatus;
268
+ }
269
+
270
+ return '';
271
+ }
272
+
273
+ module.exports = mapVariantProperties;
@@ -1,51 +1,26 @@
1
1
  // @ts-check
2
- const { mapProperties, mapVariant, mapIdentifier, mapInventoryProperties } = require('../mappers');
2
+ const { mapIdentifier, mapProperties, mapVariant } = require('../mappers');
3
3
 
4
4
  /**
5
- * @param {string} sku
5
+ * @param {import('../').EquinoxNormalProduct} product
6
+ * @param {string} market
6
7
  * @returns {import('../').EquinoxNormalProduct}
7
8
  */
8
- function productNotFound(sku) {
9
+ function productNotFound(product, market) {
9
10
  /** @type {import('../').EquinoxNormalProduct} */
10
11
  const model = {};
11
- model.identifier = mapIdentifier(sku);
12
- model.properties = mapProperties({
13
- name: '',
14
- imageURL: '',
15
- market: '',
16
- description: '',
17
- customerTypes: '',
18
- division: '',
19
- ingredients: '',
20
- benefits: '',
21
- usage: '',
22
- resources: '',
23
- scanQualifiedCount: '',
24
- status: '',
25
- size: '',
26
- productDetailsDescription: ''
27
- });
12
+ model.identifier = mapIdentifier(product.identifier);
13
+ model.properties = mapProperties();
28
14
  model.sku = [mapVariant({
29
- identifier: '',
30
- inventory: '',
31
- inventoryProperties: mapInventoryProperties({
32
- available: false,
33
- lowStock: false,
34
- binName: '',
35
- backOrdered: false,
36
- expectedBackOrderAvailabilityDate: 0,
37
- preOrdered: false,
38
- expectedPreOrderAvailabilityDate: 0,
39
- atpQty: 0,
40
- preOrderedQty: 0,
41
- backOrderedQty: 0,
42
- lowStockThreshold: null,
43
- outOfStockThreshold: null
44
- }),
45
- properties: {},
46
- promotion: [],
47
- priceFacets: {},
48
- totalValue: {}
15
+ identifier: product.identifier,
16
+ properties: {
17
+ availableChannels: 'subscription,arsPhone,kiosk,mobile,web',
18
+ customerTypes: 'BrandAffiliate,Preferred,Retail',
19
+ imageURL: 'https://nuskin.com/content/dam/global/images/products/01102730-nu-skin-tri-phasic-white-essence.png',
20
+ market,
21
+ productStatus: 'Sellable',
22
+ status: 'active'
23
+ }
49
24
  })];
50
25
 
51
26
  return model;