@nuskin/ns-product-lib 2.7.0-cx24-3682.8 → 2.7.0-cx24-3682.10

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.7.0-cx24-3682.10](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.9...v2.7.0-cx24-3682.10) (2023-03-27)
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 ([249f3b7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/249f3b79b30a774c45e90886f01d8bd4d4874b4b)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
7
+
8
+ # [2.7.0-cx24-3682.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.8...v2.7.0-cx24-3682.9) (2023-03-26)
9
+
10
+
11
+ ### New
12
+
13
+ * MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([66c977b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/66c977b3114e0cd7517d6eaa19174b0a3a13d1ed)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
14
+
1
15
  # [2.7.0-cx24-3682.8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.7...v2.7.0-cx24-3682.8) (2023-03-26)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.7.0-cx24-3682.8",
3
+ "version": "2.7.0-cx24-3682.10",
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": {
@@ -2,7 +2,7 @@
2
2
  * childSKU maps a product variant. Used mainly in subscription.
3
3
  *
4
4
  * @param {import('.').KitSKUQuantity[]} kits
5
- * @param {import('.').EquinoxProduct} product
5
+ * @param {import('.').EquinoxNormalProduct} product
6
6
  */
7
7
  function childSKU(kits, product) {
8
8
  const sku = product.sku.filter(sku => sku.default)[0];
@@ -38,16 +38,22 @@
38
38
  * @description This model represents the response.
39
39
  * @typedef EquinoxResponse
40
40
  * @type {object}
41
- * @property {EquinoxProduct[]} product
41
+ * @property {EquinoxNormalProduct[]} product
42
42
  */
43
43
 
44
44
  /**
45
- * @description This model represents a product within an Equinox response.
46
- * @typedef EquinoxProduct
45
+ * @description EquinoxNormalProduct represents an equinox Normal product type.
46
+ * @typedef EquinoxNormalProduct
47
47
  * @type {object}
48
- * @property {string} identifier E.g., Normal - "blt8b757df6dcaa199c" | Kit - "02001076"
48
+ * @property {string} identifier e.g., Normal - "blt8b757df6dcaa199c" | Kit - "02001076"
49
49
  * @property {EquinoxProductProperties} properties
50
- * @property {EquinoxProductVariant[]} [sku] or varaints - available only when product is a normal product.
50
+ * @property {EquinoxProductVariant[]} sku or varaints - available only when product is a normal product.
51
+ */
52
+
53
+ /**
54
+ * @description EquinoxKitProduct represents an equinox Kit product type.
55
+ * @typedef EquinoxKitProduct
56
+ * @type {object}
51
57
  * @property {"kit"|"bundle"} [type] available only when product is type of kit.
52
58
  */
53
59
 
@@ -65,40 +71,40 @@
65
71
  * @property {string} benefits
66
72
  * @property {string} usage
67
73
  * @property {string} resources
68
- * @property {string} scanQualifiedCount E.g., "0"
69
- * @property {string} status E.g., "active"
70
- * @property {string} size E.g., "30 mL / 1 fl.oz"
71
- * @property {string} productDetailsDescription E.g., "[]"
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., "[]"
72
78
  */
73
79
 
74
80
  /**
75
81
  * @description These are the properties unique to Kit product type.
76
82
  * @typedef EquinoxKitProductProperties
77
83
  * @type {object}
78
- * @property {string} skukits E.g., "02002145~1,02002146~1,02002147~1,02002148~1,02002142~1,02002143~1"
79
- * @property {string} productStatus E.g., "Sellable"
80
- * @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"
81
87
  */
82
88
 
83
89
  /**
84
90
  * @description These are the common properties between Normal and Kit product types
85
91
  * @typedef EquinoxProductCommonProperties
86
92
  * @type {object}
87
- * @property {string} name E.g., "180° Cell Renewal Fluid"
88
- * @property {string} imageURL E.g., "https://nuskin.com/content/dam/global/...ule-refreshed.jpg"
89
- * @property {string} market E.g., "CA"
90
- * @property {string} description E.g., "180° Ampoule"
91
- * @property {string} customerTypes E.g., "BrandAffiliate,Preferred,Retail"
92
- * @property {string} division E.g., "Nu Skin"
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"
93
99
  */
94
100
 
95
101
  /**
96
102
  * @typedef EquinoxProductVariant
97
103
  * @type {object}
98
- * @property {string} identifier E.g., "02002145"
99
- * @property {string} inventory E.g., "IN STOCK"
104
+ * @property {string} identifier e.g., "02002145"
105
+ * @property {string} inventory e.g., "IN STOCK"
100
106
  * @property {EquinoxProductVariantProperties} properties
101
- * @property {any[]} promotion E.g., ???
107
+ * @property {any[]} promotion e.g., ???
102
108
  * @property {EquinoxProductPriceFacets} priceFacets
103
109
  * @property {EquinoxProductInventoryProperties} inventoryProperties
104
110
  * @property {EquinxProductTotalValue} totalValue
@@ -107,62 +113,68 @@
107
113
  */
108
114
 
109
115
  /**
116
+ * @description This does not contain the full list of properties from the response.
110
117
  * @typedef EquinoxProductVariantProperties
111
118
  * @type {object}
112
- * @property {string} availableChannels E.g., "subscription,arsPhone,kiosk,mobile,web"
113
- * @property {string} imageURL E.g., "https://nuskin.com/cont...21/ca-180-Ampoule-refreshed.jpg"
114
- * @property {string} name E.g., "180° Cell Renewal Fluid"
115
- * @property {string} market E.g., "CA"
116
- * @property {string} description E.g., "180° Ampoule"
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"
117
124
  * @property {string} ingredients
118
125
  * @property {string} benefits
119
126
  * @property {string} usage
120
127
  * @property {string} resources
121
- * @property {string} scanQualifiedCount E.g., "0"
122
- * @property {string} customerTypes E.g., "BrandAffiliate,Preferred,Retail"
123
- * @property {string} division E.g., "Nu Skin"
124
- * @property {string} status E.g., "active"
125
- * @property {string} size E.g., "30 mL / 1 fl.oz"
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"
126
138
  * @property {string} [variantLabel]
127
- * @property {string} [isExclusive] E.g., "false" - Why is this a string??
139
+ * @property {string} [isExclusive] e.g., "false" - Why is this a string??
128
140
  */
129
141
 
130
142
  /**
131
143
  * @description Why are properties not camelCase and type of string instead of number? Super weird!
132
144
  * @typedef EquinoxProductPriceFacets
133
145
  * @type {object}
134
- * @property {string} CV E.g., "76.0"
135
- * @property {string} Regular Price E.g., "76.0"
136
- * @property {string} PV E.g., "54.15"
137
- * @property {string} Wholesale Price E.g., "88.0"
138
- * @property {string} SB E.g., "4.25"
146
+ * @property {string} CV e.g., "76.0"
147
+ * @property {string} Regular Price e.g., "76.0"
148
+ * @property {string} PV e.g., "54.15"
149
+ * @property {string} Wholesale Price e.g., "88.0"
150
+ * @property {string} SB e.g., "4.25"
139
151
  */
140
152
 
141
153
  /**
142
154
  * @description
143
155
  * @typedef EquinoxProductInventoryProperties
144
156
  * @type {object}
145
- * @property {boolean} available E.g., true
146
- * @property {boolean} lowStock E.g., false
147
- * @property {string} binName E.g., "1046_CA01"
148
- * @property {boolean} backOrdered E.g., false
149
- * @property {number} expectedBackOrderAvailabilityDate E.g., 0
150
- * @property {boolean} preOrdered E.g., false
151
- * @property {number} expectedPreOrderAvailabilityDate E.g., 0
152
- * @property {number} atpQty E.g., 49882
153
- * @property {number} preOrderedQty E.g., 0
154
- * @property {number} backOrderedQty E.g., 0
155
- * @property {number|null} lowStockThreshold E.g., null
156
- * @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
157
169
  */
158
170
 
159
171
  /**
160
172
  * @description
161
173
  * @typedef EquinxProductTotalValue
162
174
  * @type {object}
163
- * @property {number} priceAfterDiscount E.g., 2
164
- * @property {number} originalPrice E.g., 2
165
- * @property {number} totaldiscount E.g., 0
175
+ * @property {number} priceAfterDiscount e.g., 2
176
+ * @property {number} originalPrice e.g., 2
177
+ * @property {number} totaldiscount e.g., 0
166
178
  * @property {{
167
179
  * CV: { CV: number },
168
180
  * "Regular Price": {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @param {string} identifier
3
+ * @returns {string}
4
+ */
5
+ function mapIdentifier(identifier) {
6
+ if (identifier) {
7
+ return identifier;
8
+ }
9
+
10
+ return '';
11
+ }
12
+
13
+ module.exports = mapIdentifier;
@@ -1,5 +1,11 @@
1
+ const mapIdentifier = require('./identifier');
2
+ const mapInventoryProperties = require('./inventoryProperties');
1
3
  const mapProperties = require('./properties');
4
+ const mapVariant = require('./variant');
2
5
 
3
6
  module.exports = {
4
- mapProperties
7
+ mapIdentifier,
8
+ mapInventoryProperties,
9
+ mapProperties,
10
+ mapVariant
5
11
  };
@@ -0,0 +1,173 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @param {import('../').EquinoxProductInventoryProperties} inventoryProperties
5
+ */
6
+ function mapInventoryProperties(inventoryProperties) {
7
+ /** @type {import('../').EquinoxProductInventoryProperties} */
8
+ const model = {};
9
+ model.available = mapAvailable(inventoryProperties.available);
10
+ model.lowStock = mapLowStock(inventoryProperties.lowStock);
11
+ model.binName = mapBinName(inventoryProperties.binName);
12
+ model.backOrdered = mapBackOrdered(inventoryProperties.backOrdered);
13
+ model.expectedBackOrderAvailabilityDate = mapExpectedBackOrderAvailabilityDate(
14
+ inventoryProperties.expectedBackOrderAvailabilityDate
15
+ );
16
+ model.preOrdered = mapPreOrdered(inventoryProperties.preOrdered);
17
+ model.expectedPreOrderAvailabilityDate = mapExpectedPreOrderAvailabilityDate(
18
+ inventoryProperties.expectedPreOrderAvailabilityDate
19
+ );
20
+ model.atpQty = mapAtpQty(inventoryProperties.atpQty);
21
+ model.preOrderedQty = mapPreOrderedQty(inventoryProperties.preOrderedQty);
22
+ model.backOrderedQty = mapBackOrderedQty(inventoryProperties.backOrderedQty);
23
+ model.lowStockThreshold = mapLowStockThreshold(inventoryProperties.lowStockThreshold);
24
+ model.outOfStockThreshold = mapOutOfStockThreshold(inventoryProperties.outOfStockThreshold);
25
+
26
+ return model;
27
+ }
28
+
29
+ /**
30
+ * @param {boolean} available
31
+ * @returns {boolean}
32
+ */
33
+ function mapAvailable(available) {
34
+ if (available) {
35
+ return available;
36
+ }
37
+
38
+ return false;
39
+ }
40
+
41
+ /**
42
+ * @param {boolean} lowStock
43
+ * @returns {boolean}
44
+ */
45
+ function mapLowStock(lowStock) {
46
+ if (lowStock) {
47
+ return lowStock;
48
+ }
49
+
50
+ return false;
51
+ }
52
+
53
+ /**
54
+ * @param {string} binName
55
+ * @returns {string}
56
+ */
57
+ function mapBinName(binName) {
58
+ if (binName) {
59
+ return binName;
60
+ }
61
+
62
+ return '';
63
+ }
64
+
65
+ /**
66
+ * @param {boolean} backOrdered
67
+ * @returns {boolean}
68
+ */
69
+ function mapBackOrdered(backOrdered) {
70
+ if (backOrdered) {
71
+ return backOrdered;
72
+ }
73
+
74
+ return false;
75
+ }
76
+
77
+ /**
78
+ * @param {number} expectedBackOrderAvailabilityDate
79
+ * @returns {number}
80
+ */
81
+ function mapExpectedBackOrderAvailabilityDate(expectedBackOrderAvailabilityDate) {
82
+ if (expectedBackOrderAvailabilityDate) {
83
+ return expectedBackOrderAvailabilityDate;
84
+ }
85
+
86
+ return 0;
87
+ }
88
+
89
+ /**
90
+ * @param {boolean} preOrdered
91
+ * @returns {boolean}
92
+ */
93
+ function mapPreOrdered(preOrdered) {
94
+ if (preOrdered) {
95
+ return preOrdered;
96
+ }
97
+
98
+ return false;
99
+ }
100
+
101
+ /**
102
+ * @param {number} expectedPreOrderAvailabilityDate
103
+ * @returns {number}
104
+ */
105
+ function mapExpectedPreOrderAvailabilityDate(expectedPreOrderAvailabilityDate) {
106
+ if (expectedPreOrderAvailabilityDate) {
107
+ return expectedPreOrderAvailabilityDate;
108
+ }
109
+
110
+ return 0;
111
+ }
112
+
113
+ /**
114
+ * @param {number} atpQty
115
+ * @returns {number}
116
+ */
117
+ function mapAtpQty(atpQty) {
118
+ if (atpQty) {
119
+ return atpQty;
120
+ }
121
+
122
+ return 0;
123
+ }
124
+
125
+ /**
126
+ * @param {number} preOrderedQty
127
+ * @returns {number}
128
+ */
129
+ function mapPreOrderedQty(preOrderedQty) {
130
+ if (preOrderedQty) {
131
+ return preOrderedQty;
132
+ }
133
+
134
+ return 0;
135
+ }
136
+
137
+ /**
138
+ * @param {number} backOrderedQty
139
+ * @returns {number}
140
+ */
141
+ function mapBackOrderedQty(backOrderedQty) {
142
+ if (backOrderedQty) {
143
+ return backOrderedQty;
144
+ }
145
+
146
+ return 0;
147
+ }
148
+
149
+ /**
150
+ * @param {number|null} lowStockThreshold
151
+ * @returns {number|null}
152
+ */
153
+ function mapLowStockThreshold(lowStockThreshold) {
154
+ if (lowStockThreshold) {
155
+ return lowStockThreshold;
156
+ }
157
+
158
+ return null;
159
+ }
160
+
161
+ /**
162
+ * @param {number|null} outOfStockThreshold
163
+ * @returns {number|null}
164
+ */
165
+ function mapOutOfStockThreshold(outOfStockThreshold) {
166
+ if (outOfStockThreshold) {
167
+ return outOfStockThreshold;
168
+ }
169
+
170
+ return null;
171
+ }
172
+
173
+ module.exports = mapInventoryProperties;
@@ -0,0 +1,71 @@
1
+ // @ts-check
2
+ const mapIdentifier = require('./identifier');
3
+ const mapInventoryProperties = require('./inventoryProperties');
4
+
5
+ /**
6
+ * @param {import('../').EquinoxProductVariant} variant
7
+ */
8
+ function mapVariant(variant) {
9
+ /** @type {import('../').EquinoxProductVariant} */
10
+ const model = {
11
+ identifier: mapIdentifier(variant.identifier),
12
+ 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: '',
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
+ },
35
+ promotion: [],
36
+ priceFacets: {
37
+ CV: '',
38
+ PV: '',
39
+ SB: '',
40
+ 'Wholesale Price': '',
41
+ 'Regular Price': ''
42
+ },
43
+ inventoryProperties: mapInventoryProperties(variant.inventoryProperties),
44
+ totalValue: {
45
+ originalPrice: 0,
46
+ priceAfterDiscount: 0,
47
+ priceFacets: {
48
+ CV: {
49
+ CV: 36
50
+ },
51
+ 'Regular Price': {
52
+ 'Regular Price': 52
53
+ },
54
+ PV: {
55
+ PV: 25.65
56
+ },
57
+ 'Wholesale Price': {
58
+ 'Wholesale Price': 42
59
+ },
60
+ SB: {
61
+ SB: 2
62
+ }
63
+ },
64
+ totaldiscount: 0
65
+ }
66
+ };
67
+
68
+ return model;
69
+ }
70
+
71
+ module.exports = mapVariant;
@@ -1,14 +1,14 @@
1
1
  // @ts-check
2
- const { mapProperties } = require('../mappers');
2
+ const { mapProperties, mapVariant, mapIdentifier, mapInventoryProperties } = require('../mappers');
3
3
 
4
4
  /**
5
5
  * @param {string} sku
6
- * @returns {import('../').EquinoxProduct}
6
+ * @returns {import('../').EquinoxNormalProduct}
7
7
  */
8
8
  function productNotFound(sku) {
9
- /** @type {import('../').EquinoxProduct} */
9
+ /** @type {import('../').EquinoxNormalProduct} */
10
10
  const model = {};
11
- model.identifier = sku || '';
11
+ model.identifier = mapIdentifier(sku);
12
12
  model.properties = mapProperties({
13
13
  name: '',
14
14
  imageURL: '',
@@ -25,6 +25,28 @@ function productNotFound(sku) {
25
25
  size: '',
26
26
  productDetailsDescription: ''
27
27
  });
28
+ 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: {}
49
+ })];
28
50
 
29
51
  return model;
30
52
  }