@nuskin/ns-product-lib 2.4.0-cx24-2467.2.1 → 2.4.0-cx24-2462.1.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
- # [2.4.0-cx24-2467.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.3.0...v2.4.0-cx24-2467.2.1) (2022-10-19)
1
+ # [2.4.0-cx24-2462.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.3.0...v2.4.0-cx24-2462.1.1) (2022-10-20)
2
2
 
3
3
 
4
- ### New
4
+ ### Fix
5
+
6
+ * To make multiple products work (#CX24-2444) ([ce4c483](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ce4c483b7fbb0527e60045d8174fd503a67e63fa)), closes [#CX24-2444](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2444)
7
+
8
+ ### Release
5
9
 
6
- * add support for product variant (#CX24-2467) ([3f5ad9e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3f5ad9e6c0f00bf40470dbb940a234d55a9ef451)), closes [#CX24-2467](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2467)
10
+ * Automated changes by GitLab pipeline [skip ci] ([8f75316](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8f75316b692ddccda5b7bea830ee6dc625b942c7))
11
+ * Automated changes by GitLab pipeline [skip ci] ([36dca5b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/36dca5b92285ae6d8ae96345256df92102efad8e))
12
+
13
+ ### Update
14
+
15
+ * map product images to carousel images (CX24-2462) ([1e17c6e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1e17c6ec39e54b4bdb2bb804c997eb14c9e501d5))
7
16
 
8
17
  # [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)
9
18
 
@@ -41,6 +50,39 @@
41
50
 
42
51
  * replace runConfig and marketConfig parameters of getProductData with locale and market (CX24-2382) ([b7b8ac7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b7b8ac7fa946df0b3690f700d00f5acfb0073bcf))
43
52
 
53
+ ### Fix
54
+
55
+ * To make multiple products work (#CX24-2444) ([1cbe500](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1cbe5000d2649157de3bdb6456d601fdeecbd3b6)), closes [#CX24-2444](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2444)
56
+ * To make multiple products work (#CX24-2444) ([b4c2218](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b4c221853dca33f2c0b06a06d6ead7fc50e9f0c6)), closes [#CX24-2444](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2444)
57
+
58
+ ### Release
59
+
60
+ * Automated changes by GitLab pipeline [skip ci] ([a974a24](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a974a244a85ee42eca3540b88429d16edcbf57ce))
61
+ * Automated changes by GitLab pipeline [skip ci] ([aa21d8d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/aa21d8dcbed15a1c0798f882b4667bcc2bc071dc))
62
+
63
+ ### Update
64
+
65
+ * updating the product data map (#CX24-2103) ([ea914a4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ea914a4079c2472adcd449fac09be85f22671493)), closes [#CX24-2103](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2103)
66
+
67
+ # [2.0.0-cx24-21035.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.0.0-cx24-21035.1...v2.0.0-cx24-21035.2) (2022-09-22)
68
+
69
+
70
+ ### Fix
71
+
72
+ * To make multiple products work (#CX24-2444) ([1cbe500](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1cbe5000d2649157de3bdb6456d601fdeecbd3b6)), closes [#CX24-2444](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2444)
73
+ * To make multiple products work (#CX24-2444) ([b4c2218](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b4c221853dca33f2c0b06a06d6ead7fc50e9f0c6)), closes [#CX24-2444](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2444)
74
+
75
+ ### Release
76
+
77
+ * Automated changes by GitLab pipeline [skip ci] ([aa21d8d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/aa21d8dcbed15a1c0798f882b4667bcc2bc071dc))
78
+
79
+ ### Update
80
+
81
+ * updating the product data map (#CX24-2103) ([ea914a4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ea914a4079c2472adcd449fac09be85f22671493)), closes [#CX24-2103](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2103)
82
+
83
+ # [2.0.0-cx24-21035.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.0.0-cx24-21035.1...v2.0.0-cx24-21035.2) (2022-09-22)
84
+
85
+
44
86
  ### Fix
45
87
 
46
88
  * To make multiple products work (#CX24-2444) ([b4c2218](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b4c221853dca33f2c0b06a06d6ead7fc50e9f0c6)), closes [#CX24-2444](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2444)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.4.0-cx24-2467.2.1",
3
+ "version": "2.4.0-cx24-2462.1.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": {
@@ -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
  */
@@ -90,149 +90,21 @@ const ProductData = {
90
90
  };
91
91
  },
92
92
 
93
- /**
94
- * Map product variant
95
- * @todo remove unnecessary fields
96
- * @param {*} eqVariant
97
- * @returns Array<Product>
98
- */
99
- eqProductVariantMapper : function (eqVariant) {
100
-
101
- let imageURL = eqVariant.properties.imageURL;
102
- const regex = /\d+.\d+/
103
- let thumbnailImage = ''
104
-
105
- if (imageURL.includes('contentstack')) {
106
- thumbnailImage = imageURL + '?width=40'
107
- } else {
108
- thumbnailImage = imageURL.replace(regex,'40.40')
109
- }
110
-
111
- return {
112
- "sku": eqVariant.identifier,
113
- "globalProductID": eqVariant.identifier,
114
- "title": eqVariant.properties.name,
115
- "country": eqVariant.properties.market,
116
- "language": "en",
117
- "shortDescr": eqVariant.properties.description,
118
- "longDescr": eqVariant.properties.productDetailsDescription,
119
- "fullImage": imageURL,
120
- "imageAltText": eqVariant.properties.name,
121
- "productCarouselImages": [
122
- {
123
- "contentType": "img",
124
- "src": "/content/products/24/00/35/24003529/jcr:content/fullImage.imgw.1280.1280.png",
125
- "alt": ""
126
- }
127
- ],
128
- "thumbnail": thumbnailImage,
129
- "ingredients": eqVariant.properties.ingredients,
130
- "benefits": eqVariant.properties.benefits,
131
- "usage": eqVariant.properties.usage,
132
- "resources": eqVariant.properties.resources,
133
- "videos": "",
134
- "movie": "",
135
- "youtube": "",
136
- "salesEventText": "",
137
- "contentSection": [
138
- {
139
- "sectionContent": "<div class=\"contentSections\"><div class=\"contentSection section\"><div>\n<h3>BENEFITS</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<p>Green tea has been used in China for thousands of years for its health-preserving and revitalizing power. Modern science has identified powerful antioxidants in green tea called polyphenols. One group of polyphenols called catechins is particularly potent and is highly effective at neutralizing free radicals at the cellular level. Catechins support healthy cell function while providing antioxidant protection to critical cell structures such as DNA. Clinical studies show catechins interfere with the production of certain enzymes involved in cell damage. Additionally, catechins have been demonstrated to cause a thermogenic effect that enhances the body s metabolic rate. Tegreen 97<sup>®</sup> from Pharmanex is a proprietary, highly concentrated extract of the catechins found in green tea. Tegreen 97<sup>®</sup> is one of the most potent antioxidant supplements on the market with a 97 percent polyphenol content, 65% catechins. Each Tegreen 97<sup>®</sup> capsule contains the catechin equivalent of approximately seven cups of green tea and is 99.5 percent caffeine free.</p>\r\n\n</div>\n\n</div>\n\n</div>\n</div>\n</div>\n<div class=\"contentSection section\"><div>\n<h3>USAGE</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<p>As a dietary supplement, take one (1) to four (4) capsules daily; preferably one (1) to two (2) each morning and evening with food. Store in a cool, dry place.</p>\r\n\n</div>\n\n</div>\n\n</div>\n</div>\n</div>\n<div class=\"contentSection section\"><div>\n<h3>INGREDIENTS</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<table border=\"1\" cellspacing=\"1\" cellpadding=\"0\" width=\"360\"><tbody>\r\n<tr>\r\n<td><b>Nutritional Facts</b></td>\r\n<td><b>Amount</b></td>\r\n<td><b>% Daily Value</b></td>\r\n</tr>\r\n<tr>\r\n<td colspan=\"3\"><b>Serving Size: 1 Capsule<br>\r\nServings Per Container: 120</b></td>\r\n</tr>\r\n<tr>\r\n<td width=\"55%\">Green tea leaf (20:1) Extract (<i>Camellia sinensis</i></td>\r\n<td width=\"20%\">250 mg</td>\r\n<td width=\"25%\">&nbsp;</td>\r\n</tr>\r\n<tr>\r\n<td width=\"55%\" colspan=\"3\">* Daily Value not established</td>\r\n</tr>\r\n<tr>\r\n<td width=\"55%\" colspan=\"3\"><b>Other Ingredients: Gelatin, Silicon Dioxide, Microcrystalline Cellulose, Magnesium Stearate.</b></td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<p>&nbsp;</p>\r\n\n</div>\n\n</div>\n\n</div>\n</div>\n</div>\n</div>\n"
140
- }
141
- ],
142
- "scanQualified": eqVariant.properties.scanQualifiedCount,
143
- "availableQuantity": 999,
144
- "maxQuantity": 999,
145
- "points": "",
146
- "cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
147
- "pv":eqVariant.priceFacets.PV,
148
- "priceType": "WRTL",
149
- "price": eqVariant.priceFacets["Regular Price"],
150
- "priceMap": {
151
- "WRTL": eqVariant.priceFacets["Regular Price"],
152
- "WADW-WRTL": eqVariant.priceFacets["Regular Price"],
153
- "WADR": 9999.01,
154
- "RTL": eqVariant.priceFacets["Regular Price"],
155
- "WWHL": 9998.01,
156
- "WADW": 9998.01,
157
- "WHL": 9998.01
158
- },
159
- "cvMap": {
160
- "WWHL": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
161
- "WADW": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
162
- "WHL": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : ''
163
- },
164
- "pvMap": {
165
- "WWHL": eqVariant.priceFacets.PV,
166
- "WADW": eqVariant.priceFacets.PV,
167
- "WHL": eqVariant.priceFacets.PV
168
- },
169
- "orderTypes": {
170
- "adr": true,
171
- "order": true,
172
- "zpfc": false,
173
- "zadp": true,
174
- "ars": true,
175
- "kiosk": true,
176
- "mobile": true,
177
- "preferred customer": true,
178
- "retail": true,
179
- "web": true,
180
- "web display": true
181
- },
182
- "division": eqVariant.properties.division,
183
- "backOrderDate": null,
184
- "locallyProduced": false,
185
- "agelocme": null,
186
- "count": "",
187
- "flavor": "",
188
- "size": eqVariant.properties.size,
189
- "shade": "",
190
- "status": this.switchStatusFromEquinox(eqVariant.properties.status),
191
- "variantType": "Other",
192
- "variantDropdownLabel": "Select Type",
193
- "variantDropdownPlaceholder": "Select Type",
194
- "variantsLabel": "Select Type",
195
- "groupOffer": false,
196
- "personalOffer": false,
197
- "savedEventName": null,
198
- "salesLabel": "",
199
- "eventName": null,
200
- "sizeWeight": '',
201
- "nettoWeight": "",
202
- "searchScore": 0,
203
- "isExclusive": false,
204
- "marketAttributes": {
205
- "discount": true,
206
- "redeem": true,
207
- "earn": true
208
- },
209
- "restrictedMarkets": [],
210
- "addOns": []
211
- };
212
- },
213
-
214
93
  eqProductMapper: function (productDataResponse) {
215
94
  let prod = [];
216
95
  let count = 0;
217
- const variants = {};
218
96
 
219
97
  let prodArr = productDataResponse.map((data) => {
220
98
  let imageURL = data.sku[count].properties.imageURL;
221
99
  const regex = /\d+.\d+/
222
100
  let thumbnailImage = ''
223
-
101
+
224
102
  if (imageURL.includes('contentstack')) {
225
103
  thumbnailImage = imageURL + '?width=40'
226
104
  } else {
227
105
  thumbnailImage = imageURL.replace(regex,'40.40')
228
106
  }
229
-
230
- if (data.sku && data.sku.length > 1) {
231
- data.sku.map(variant => {
232
- variants[variant.identifier] = this.eqProductVariantMapper(variant);
233
- return variant;
234
- });
235
- }
107
+ const skuProperties = data.sku[count].properties;
236
108
 
237
109
  prod = {
238
110
  "sku": data.sku[count].identifier,
@@ -244,13 +116,14 @@ const ProductData = {
244
116
  "longDescr": data.properties.productDetailsDescription,
245
117
  "fullImage": imageURL,
246
118
  "imageAltText": data.properties.name,
247
- "productCarouselImages": [
248
- {
249
- "contentType": "img",
250
- "src": "/content/products/24/00/35/24003529/jcr:content/fullImage.imgw.1280.1280.png",
251
- "alt": ""
252
- }
253
- ],
119
+ productCarouselImages: skuProperties.productImages
120
+ ? JSON.parse(skuProperties.productImages).map(img => (
121
+ {
122
+ contentType: /\.jpg/i.test(img.url) ? 'img' : 'video',
123
+ src: img.url,
124
+ alt: img.alt
125
+ }
126
+ )) : [],
254
127
  "thumbnail": thumbnailImage,
255
128
  "ingredients": data.properties.ingredients,
256
129
  "benefits": data.properties.benefits,
@@ -262,7 +135,7 @@ const ProductData = {
262
135
  "salesEventText": "",
263
136
  "contentSection": [
264
137
  {
265
- "sectionContent": "<div class=\"contentSections\"><div class=\"contentSection section\"><div>\n<h3>BENEFITS</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<p>Green tea has been used in China for thousands of years for its health-preserving and revitalizing power. Modern science has identified powerful antioxidants in green tea called polyphenols. One group of polyphenols called catechins is particularly potent and is highly effective at neutralizing free radicals at the cellular level. Catechins support healthy cell function while providing antioxidant protection to critical cell structures such as DNA. Clinical studies show catechins interfere with the production of certain enzymes involved in cell damage. Additionally, catechins have been demonstrated to cause a thermogenic effect that enhances the body s metabolic rate. Tegreen 97<sup>®</sup> from Pharmanex is a proprietary, highly concentrated extract of the catechins found in green tea. Tegreen 97<sup>®</sup> is one of the most potent antioxidant supplements on the market with a 97 percent polyphenol content, 65% catechins. Each Tegreen 97<sup>®</sup> capsule contains the catechin equivalent of approximately seven cups of green tea and is 99.5 percent caffeine free.</p>\r\n\n</div>\n\n</div>\n\n</div>\n</div>\n</div>\n<div class=\"contentSection section\"><div>\n<h3>USAGE</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<p>As a dietary supplement, take one (1) to four (4) capsules daily; preferably one (1) to two (2) each morning and evening with food. Store in a cool, dry place.</p>\r\n\n</div>\n\n</div>\n\n</div>\n</div>\n</div>\n<div class=\"contentSection section\"><div>\n<h3>INGREDIENTS</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<table border=\"1\" cellspacing=\"1\" cellpadding=\"0\" width=\"360\"><tbody>\r\n<tr>\r\n<td><b>Nutritional Facts</b></td>\r\n<td><b>Amount</b></td>\r\n<td><b>% Daily Value</b></td>\r\n</tr>\r\n<tr>\r\n<td colspan=\"3\"><b>Serving Size: 1 Capsule<br>\r\nServings Per Container: 120</b></td>\r\n</tr>\r\n<tr>\r\n<td width=\"55%\">Green tea leaf (20:1) Extract (<i>Camellia sinensis</i></td>\r\n<td width=\"20%\">250 mg</td>\r\n<td width=\"25%\">&nbsp;</td>\r\n</tr>\r\n<tr>\r\n<td width=\"55%\" colspan=\"3\">* Daily Value not established</td>\r\n</tr>\r\n<tr>\r\n<td width=\"55%\" colspan=\"3\"><b>Other Ingredients: Gelatin, Silicon Dioxide, Microcrystalline Cellulose, Magnesium Stearate.</b></td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<p>&nbsp;</p>\r\n\n</div>\n\n</div>\n\n</div>\n</div>\n</div>\n</div>\n"
138
+ "sectionContent": "<div class=\"contentSections\"></div>\n"
266
139
  }
267
140
  ],
268
141
  "scanQualified": data.properties.scanQualifiedCount,
@@ -278,9 +151,9 @@ const ProductData = {
278
151
  "WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
279
152
  "WADR": 9999.01,
280
153
  "RTL": data.sku[count].priceFacets["Regular Price"],
281
- "WWHL": data.sku[count].priceFacets["Regular Price"],
154
+ "WWHL": 9998.01,
282
155
  "WADW": 9998.01,
283
- "WHL": data.sku[count].priceFacets["Regular Price"]
156
+ "WHL": 9998.01
284
157
  },
285
158
  "cvMap": {
286
159
  "WWHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
@@ -327,7 +200,8 @@ const ProductData = {
327
200
  "eventName": null,
328
201
  "sizeWeight": '',
329
202
  "nettoWeight": "",
330
- "variants": variants,
203
+ "variants": {
204
+ },
331
205
  "searchScore": 0,
332
206
  "isExclusive": data.sku[count].properties.isExclusive,
333
207
  "marketAttributes": {
@@ -338,7 +212,7 @@ const ProductData = {
338
212
  "restrictedMarkets": [],
339
213
  "addOns": []
340
214
  };
341
- let newProduct = new Product(prod);
215
+ let newProduct = new product(prod);
342
216
  return newProduct
343
217
  })
344
218
 
@@ -381,13 +255,13 @@ const ProductData = {
381
255
  },
382
256
 
383
257
  /**
384
- *
385
- * @param {*} custType
386
- *
258
+ *
259
+ * @param {*} custType
260
+ *
387
261
  */
388
262
  switchCustType: function (custType) {
389
263
  let newCustType = [];
390
- if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
264
+ if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
391
265
  newCustType.push(10)
392
266
  if (custType.includes('Retail Customer'))
393
267
  newCustType.push(20)