@nuskin/ns-product-lib 2.6.0-cx24-3503.1 → 2.6.0-cx24-3372.4

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,31 @@
1
- # [2.6.0-cx24-3503.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.6.0-cx24-3503.1) (2023-03-02)
1
+ # [2.6.0-cx24-3372.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.3...v2.6.0-cx24-3372.4) (2023-03-02)
2
2
 
3
3
 
4
- ### Update
4
+ ### Fix
5
+
6
+ * inventoryProperties atpQty ([60ec521](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/60ec521223367abcd9570969c0e65522f76afe43))
7
+
8
+ # [2.6.0-cx24-3372.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.2...v2.6.0-cx24-3372.3) (2023-03-02)
9
+
10
+
11
+ ### Fix
12
+
13
+ * Kit mapping ([af76396](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/af76396940d95988bbcfad73fc047381945847bb))
14
+
15
+ # [2.6.0-cx24-3372.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.1...v2.6.0-cx24-3372.2) (2023-03-01)
16
+
17
+
18
+ ### New
19
+
20
+ * Product Kit API search ([4260768](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/426076856ed7d1d90f536fc249d84e1bd88e2d12))
21
+
22
+ # [2.6.0-cx24-3372.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.6.0-cx24-3372.1) (2023-03-01)
23
+
24
+
25
+ ### New
5
26
 
6
- * use latest version of configuration-sdk and ns-util (CX24-3503) ([27a2c44](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/27a2c44bf96ccc912df121f610e3a1e616d66b08))
7
- * use latest version of configuration-sdk and ns-util (CX24-3503) ([0f549b9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0f549b92012c18485a751fa8f6930bd5dd74a151))
8
- * use latest version of configuration-sdk and ns-util (CX24-3503) ([d343dbf](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d343dbfcd5b4d946746576f84ae5157bcef403ea))
27
+ * Product Kit API search ([0d69d93](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0d69d931b989ccc250b698148c78db17a003bc13))
28
+ * Product Kit API search ([d549e15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d549e15fa7c967d1b2bbede6d3c2695ecc66265c))
9
29
 
10
30
  # [2.5.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.5.0) (2023-02-22)
11
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.6.0-cx24-3503.1",
3
+ "version": "2.6.0-cx24-3372.4",
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": {
@@ -31,9 +31,9 @@
31
31
  "prettier": "1.19.1"
32
32
  },
33
33
  "dependencies": {
34
- "@nuskin/configuration-sdk": "2.2.3",
34
+ "@nuskin/configuration-sdk": "1.0.1",
35
35
  "@nuskin/ns-common-lib": "1.4.5",
36
- "@nuskin/ns-util": "4.2.2",
36
+ "@nuskin/ns-util": "3.107.0",
37
37
  "axios": "0.27.2",
38
38
  "qs": "6.11.0"
39
39
  },
@@ -18,14 +18,14 @@ const ProductData = {
18
18
  const localeMarket = `${locale}_${market}`;
19
19
 
20
20
  if (isEquinoxEnabled) {
21
- const options = {
21
+ let config = (await getConfiguration({
22
+ configMapNames: ['Equinox_Markets'],
22
23
  country: market,
23
24
  environment: contentstackEnv(),
24
25
  clientId: '735b1eb810304bba966af0891ab54053'
25
- };
26
- const config = (await getConfiguration(['Equinox_Markets'], options)).Equinox_Markets;
26
+ }));
27
27
 
28
- if (config.country_code === market && config.active) {
28
+ if (config.Equinox_Markets.country_code === market && config.Equinox_Markets.active) {
29
29
  return await this.getProductFromEquinox(skus, localeMarket, config);
30
30
  }
31
31
  }
@@ -33,17 +33,24 @@ const ProductData = {
33
33
  },
34
34
 
35
35
  getProductFromEquinox: async function (skus, locale, config) {
36
- const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
36
+
37
+ let skuFilter = [];
38
+
39
+ skus.forEach((sku) => {
40
+ skuFilter.push(`index_key_productId="${sku}" OR index_key_skuId="${sku}"`)
41
+ })
42
+
43
+ const filter = skuFilter.join(" OR ")
37
44
  axios.defaults.withCredentials = true;
38
45
 
39
- const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
40
- const href = `${url}?filter=${encodeURI(filter)}`;
46
+ const url = `${config.Equinox_Markets.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
47
+ const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
41
48
  const response = await axios.request({
42
49
  method: 'get',
43
50
  url: href,
44
51
  params: {
45
52
  locale,
46
- storeId: config.store_id
53
+ storeId: config.Equinox_Markets.store_id
47
54
  },
48
55
  headers: this.getEquinoxRequestHeaders(),
49
56
  responseType: 'json'
@@ -324,7 +331,8 @@ const ProductData = {
324
331
  let variants = {};
325
332
 
326
333
  let prodArr = productDataResponse.map((data) => {
327
- let imageURL = data.sku[count].properties.imageURL;
334
+ let product = (data.type && data.type === "kit") ? data : data.sku[count];
335
+ let imageURL = product.properties.imageURL;
328
336
  const regex = /\d+.\d+/
329
337
  let thumbnailImage = ''
330
338
 
@@ -347,15 +355,15 @@ const ProductData = {
347
355
  eventLabels,
348
356
  computedPrice,
349
357
  defaultProductPrice
350
- } = this.getEqProductPromotions(data.sku[count]);
351
- const productPrice = eventName ? defaultProductPrice : data.sku[count].priceFacets["Regular Price"];
352
- const discountedPrice = eventName ? computedPrice : data.sku[count].priceFacets["Regular Price"];
358
+ } = this.getEqProductPromotions(product);
359
+ const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
360
+ const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
353
361
 
354
362
  prod = {
355
- "sku": data.sku[count].identifier,
363
+ "sku": product.identifier,
356
364
  "globalProductID": data.identifier,
357
365
  "title": data.properties.name,
358
- "country": data.sku[count].properties.market,
366
+ "country": product.properties.market,
359
367
  "language": "en",
360
368
  "shortDescr": data.properties.description,
361
369
  "longDescr": data.properties.productDetailsDescription,
@@ -372,7 +380,7 @@ const ProductData = {
372
380
  "ingredients": data.properties.ingredients,
373
381
  "benefits": data.properties.benefits,
374
382
  "usage": data.properties.usage,
375
- "resources": data.sku[count].properties.resources,
383
+ "resources": product.properties.resources,
376
384
  "videos": "",
377
385
  "movie": "",
378
386
  "youtube": "",
@@ -383,48 +391,48 @@ const ProductData = {
383
391
  }
384
392
  ],
385
393
  "scanQualified": data.properties.scanQualifiedCount,
386
- "availableQuantity": data.sku[count].inventoryProperties.atpQty,
394
+ "availableQuantity": product.inventoryProperties.atpQty || 0,
387
395
  "maxQuantity": 999,
388
396
  "points": "",
389
- "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
390
- "pv": data.sku[count].priceFacets.PV,
397
+ "cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
398
+ "pv": product.priceFacets.PV,
391
399
  "priceType": "WRTL",
392
400
  "price": discountedPrice,
393
401
  "priceMap": {
394
402
  "WRTL": productPrice,
395
- "WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
396
- "WADR": data.sku[count].priceFacets["Regular Price"],
397
- "RTL": data.sku[count].priceFacets["Regular Price"],
398
- "WADW": data.sku[count].priceFacets["Wholesale Price"],
399
- "WHL": data.sku[count].priceFacets["Wholesale Price"],
400
- "WWHL": data.sku[count].priceFacets["Wholesale Price"]
403
+ "WADW-WRTL": product.priceFacets["Regular Price"],
404
+ "WADR": product.priceFacets["Regular Price"],
405
+ "RTL": product.priceFacets["Regular Price"],
406
+ "WADW": product.priceFacets["Wholesale Price"],
407
+ "WHL": product.priceFacets["Wholesale Price"],
408
+ "WWHL": product.priceFacets["Wholesale Price"]
401
409
  },
402
410
  "cvMap": {
403
- "WWHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
404
- "WADW": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
405
- "WHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : ''
411
+ "WWHL": (product.priceFacets.CV) ? product.priceFacets.CV : '',
412
+ "WADW": (product.priceFacets.CV) ? product.priceFacets.CV : '',
413
+ "WHL": (product.priceFacets.CV) ? product.priceFacets.CV : ''
406
414
  },
407
415
  "pvMap": {
408
- "WWHL": data.sku[count].priceFacets.PV,
409
- "WADW": data.sku[count].priceFacets.PV,
410
- "WHL": data.sku[count].priceFacets.PV
416
+ "WWHL": product.priceFacets.PV,
417
+ "WADW": product.priceFacets.PV,
418
+ "WHL": product.priceFacets.PV
411
419
  },
412
- "orderTypes": this._setOrderType(data.sku[count].properties),
420
+ "orderTypes": this._setOrderType(product.properties),
413
421
  "childSkus": [],
414
- "custTypes": this.switchCustType(data.sku[count].properties.customerTypes),
422
+ "custTypes": this.switchCustType(product.properties.customerTypes),
415
423
  "division": data.properties.division,
416
424
  "backOrderDate": null,
417
425
  "locallyProduced": false,
418
426
  "agelocme": null,
419
427
  "count": "",
420
428
  "flavor": "",
421
- "size": data.sku[count].properties.size,
429
+ "size": product.properties.size,
422
430
  "shade": "",
423
- "status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
431
+ "status": this.switchStatusFromEquinox(product.properties.productStatus),
424
432
  "variantType": "Other",
425
- "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
433
+ "variantDropdownLabel": product.properties.variantLabel || "",
426
434
  "variantDropdownPlaceholder": "Select Type",
427
- "variantsLabel": data.sku[count].properties.variantLabel || "",
435
+ "variantsLabel": product.properties.variantLabel || "",
428
436
  "groupOffer": false,
429
437
  "personalOffer": false,
430
438
  "savedEventName": eventName,
@@ -434,7 +442,7 @@ const ProductData = {
434
442
  "nettoWeight": "",
435
443
  "variants": variants,
436
444
  "searchScore": 0,
437
- "isExclusive": data.sku[count].properties.isExclusive || false,
445
+ "isExclusive": product.properties.isExclusive || false,
438
446
  "marketAttributes": {
439
447
  "discount": true,
440
448
  "redeem": true,
@@ -442,7 +450,7 @@ const ProductData = {
442
450
  },
443
451
  "restrictedMarkets": [],
444
452
  "addOns": [],
445
- "inventory": data.sku[count].inventory || "", //inventory label
453
+ "inventory": product.inventory || "", //inventory label
446
454
  "equinoxProductId": data.identifier
447
455
  };
448
456
  let newProduct = new Product(prod);