@nuskin/ns-product-lib 2.6.0-cx24-3503.2.1 → 2.6.0-cx24-3372.7

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,26 +1,52 @@
1
- # [2.6.0-cx24-3503.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3503.1...v2.6.0-cx24-3503.2.1) (2023-03-07)
1
+ # [2.6.0-cx24-3372.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.6...v2.6.0-cx24-3372.7) (2023-03-07)
2
+
3
+
4
+ ### Update
5
+
6
+ * Fixed regex expression for imageURL resize for non contentstack images ([a7c99b5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a7c99b504a6ab361150868e5f9153585c8e60412))
7
+
8
+ # [2.6.0-cx24-3372.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.5...v2.6.0-cx24-3372.6) (2023-03-06)
9
+
10
+
11
+ ### Update
12
+
13
+ * Query for product equinox search ([7f873a5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7f873a56cb579c68d7665947a2c5f9615eeb2101))
14
+
15
+ # [2.6.0-cx24-3372.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.4...v2.6.0-cx24-3372.5) (2023-03-02)
2
16
 
3
17
 
4
18
  ### Fix
5
19
 
6
- * update dependencies #CX24-3503 ([0ea7523](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0ea752306f8e64d5f73d397d5ddf3cf1839865c3)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
7
- * update dependencies #CX24-3503 ([53cea8d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53cea8d5eb39ebaf9ff21b45d2310f02db98e25d)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
8
- * update dependencies #CX24-3503 ([dd38c23](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/dd38c23b0094dea202fce7c6407c06c917d61676)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
9
- * update dependencies #CX24-3503 ([ca67042](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ca670420a7ed79e7c6fabeb4b7c722abc5811a18)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
10
- * update dependencies #CX24-3503 ([2ac0b65](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2ac0b652f84937d37716e861504ad8c424b20beb)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
11
- * update dependencies #CX24-3503 ([682078f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/682078f703ccb8a0e84a559e828543f31f53ccd8)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
12
- * update dependencies #CX24-3503 ([d48fb1a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d48fb1ac5e29dc7477be7b65522f25a2bbf25250)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
20
+ * inventoryProperties atpQty ([3b271aa](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3b271aa16960fbaaa2a68c08a2d1d1c93d54ec15))
21
+
22
+ # [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)
13
23
 
14
- ### Release
15
24
 
16
- * Automated changes by GitLab pipeline [skip ci] ([fa35816](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fa35816ef50672ceaac01173d55615d88cb2c75b))
25
+ ### Fix
17
26
 
18
- ## [2.5.1-cx24-3503.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.5.1-cx24-3503.2.1) (2023-03-07)
27
+ * inventoryProperties atpQty ([60ec521](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/60ec521223367abcd9570969c0e65522f76afe43))
28
+
29
+ # [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)
19
30
 
20
31
 
21
32
  ### Fix
22
33
 
23
- * update dependencies #CX24-3503 ([53cea8d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53cea8d5eb39ebaf9ff21b45d2310f02db98e25d)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
34
+ * Kit mapping ([af76396](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/af76396940d95988bbcfad73fc047381945847bb))
35
+
36
+ # [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)
37
+
38
+
39
+ ### New
40
+
41
+ * Product Kit API search ([4260768](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/426076856ed7d1d90f536fc249d84e1bd88e2d12))
42
+
43
+ # [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)
44
+
45
+
46
+ ### New
47
+
48
+ * Product Kit API search ([0d69d93](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0d69d931b989ccc250b698148c78db17a003bc13))
49
+ * Product Kit API search ([d549e15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d549e15fa7c967d1b2bbede6d3c2695ecc66265c))
24
50
 
25
51
  # [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)
26
52
 
@@ -29,6 +55,24 @@
29
55
 
30
56
  * equinox API integration (#CX24) ([a169d58](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a169d5806f20737fae42d0ebe18a7c746861a4fb)), closes [#CX24](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24)
31
57
 
58
+ # [2.5.0-cx24-2179.2.20](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.19...v2.5.0-cx24-2179.2.20) (2023-02-16)
59
+
60
+
61
+ ### Fix
62
+
63
+ * Get test environment if not PROD ([913abb6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/913abb61f8bc6aa8a2cb271d67de08f2f9505c5e))
64
+
65
+ # [2.5.0-cx24-2179.2.19](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.18...v2.5.0-cx24-2179.2.19) (2023-01-27)
66
+
67
+
68
+ ### Fix
69
+
70
+ * parent product customer types (#CX24-3175) ([411b2cc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/411b2cc5a7cf687152dc346579766c8f923b795a)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
71
+
72
+ ### Update
73
+
74
+ * clean ups - expose customerTypes (#CX24-3175) ([3b7d9b1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3b7d9b12a9cf815b11a8af61621ab9ebc76c37b5)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
75
+
32
76
  # [2.5.0-cx24-2179.2.18](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.17...v2.5.0-cx24-2179.2.18) (2023-01-26)
33
77
 
34
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.6.0-cx24-3503.2.1",
3
+ "version": "2.6.0-cx24-3372.7",
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.4",
36
+ "@nuskin/ns-util": "3.107.0",
37
37
  "axios": "0.27.2",
38
38
  "qs": "6.11.0"
39
39
  },
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  const { getConfiguration } = require('@nuskin/configuration-sdk');
3
+ const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
3
4
  const axios = require("axios");
4
5
  const contentstack = require('./contentstack/contentstack');
5
6
  const Product = require("./product");
@@ -17,9 +18,14 @@ const ProductData = {
17
18
  const localeMarket = `${locale}_${market}`;
18
19
 
19
20
  if (isEquinoxEnabled) {
20
- const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
21
-
22
- if (config.country_code === market && config.active) {
21
+ let config = (await getConfiguration({
22
+ configMapNames: ['Equinox_Markets'],
23
+ country: market,
24
+ environment: contentstackEnv(),
25
+ clientId: '735b1eb810304bba966af0891ab54053'
26
+ }));
27
+
28
+ if (config.Equinox_Markets.country_code === market && config.Equinox_Markets.active) {
23
29
  return await this.getProductFromEquinox(skus, localeMarket, config);
24
30
  }
25
31
  }
@@ -27,17 +33,29 @@ const ProductData = {
27
33
  },
28
34
 
29
35
  getProductFromEquinox: async function (skus, locale, config) {
30
- const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
36
+
37
+ let skuFilter = [];
38
+
39
+ if(Array.isArray(skus)) {
40
+ skus.forEach((sku) => {
41
+ skuFilter.push(`index_key_productId="${sku}" OR index_key_skuId="${sku}"`)
42
+ })
43
+ } else {
44
+ //all featured products
45
+ skuFilter.push(`index_key_productId="${skus}" OR index_key_skuId="${skus}"`)
46
+ }
47
+
48
+ const filter = skuFilter.join(" OR ")
31
49
  axios.defaults.withCredentials = true;
32
50
 
33
- const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
34
- const href = `${url}?filter=${encodeURI(filter)}`;
51
+ const url = `${config.Equinox_Markets.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
52
+ const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
35
53
  const response = await axios.request({
36
54
  method: 'get',
37
55
  url: href,
38
56
  params: {
39
57
  locale,
40
- storeId: config.store_id
58
+ storeId: config.Equinox_Markets.store_id
41
59
  },
42
60
  headers: this.getEquinoxRequestHeaders(),
43
61
  responseType: 'json'
@@ -99,7 +117,7 @@ const ProductData = {
99
117
  eqProductVariantMapper: function (eqVariant) {
100
118
 
101
119
  let imageURL = eqVariant.properties.imageURL;
102
- const regex = /\d+.\d+/
120
+ const regex = /\d+\.\d+/
103
121
  let thumbnailImage = ''
104
122
 
105
123
  if (imageURL.includes('contentstack')) {
@@ -318,8 +336,9 @@ const ProductData = {
318
336
  let variants = {};
319
337
 
320
338
  let prodArr = productDataResponse.map((data) => {
321
- let imageURL = data.sku[count].properties.imageURL;
322
- const regex = /\d+.\d+/
339
+ let product = (data.type && data.type === "kit") ? data : data.sku[count];
340
+ let imageURL = product.properties.imageURL;
341
+ const regex = /\d+\.\d+/
323
342
  let thumbnailImage = ''
324
343
 
325
344
  if (imageURL.includes('contentstack')) {
@@ -341,15 +360,15 @@ const ProductData = {
341
360
  eventLabels,
342
361
  computedPrice,
343
362
  defaultProductPrice
344
- } = this.getEqProductPromotions(data.sku[count]);
345
- const productPrice = eventName ? defaultProductPrice : data.sku[count].priceFacets["Regular Price"];
346
- const discountedPrice = eventName ? computedPrice : data.sku[count].priceFacets["Regular Price"];
363
+ } = this.getEqProductPromotions(product);
364
+ const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
365
+ const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
347
366
 
348
367
  prod = {
349
- "sku": data.sku[count].identifier,
368
+ "sku": product.identifier,
350
369
  "globalProductID": data.identifier,
351
370
  "title": data.properties.name,
352
- "country": data.sku[count].properties.market,
371
+ "country": product.properties.market,
353
372
  "language": "en",
354
373
  "shortDescr": data.properties.description,
355
374
  "longDescr": data.properties.productDetailsDescription,
@@ -366,7 +385,7 @@ const ProductData = {
366
385
  "ingredients": data.properties.ingredients,
367
386
  "benefits": data.properties.benefits,
368
387
  "usage": data.properties.usage,
369
- "resources": data.sku[count].properties.resources,
388
+ "resources": product.properties.resources,
370
389
  "videos": "",
371
390
  "movie": "",
372
391
  "youtube": "",
@@ -377,48 +396,48 @@ const ProductData = {
377
396
  }
378
397
  ],
379
398
  "scanQualified": data.properties.scanQualifiedCount,
380
- "availableQuantity": data.sku[count].inventoryProperties.atpQty,
399
+ "availableQuantity": (product.inventoryProperties) ? product.inventoryProperties.atpQty : 0,
381
400
  "maxQuantity": 999,
382
401
  "points": "",
383
- "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
384
- "pv": data.sku[count].priceFacets.PV,
402
+ "cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
403
+ "pv": product.priceFacets.PV,
385
404
  "priceType": "WRTL",
386
405
  "price": discountedPrice,
387
406
  "priceMap": {
388
407
  "WRTL": productPrice,
389
- "WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
390
- "WADR": data.sku[count].priceFacets["Regular Price"],
391
- "RTL": data.sku[count].priceFacets["Regular Price"],
392
- "WADW": data.sku[count].priceFacets["Wholesale Price"],
393
- "WHL": data.sku[count].priceFacets["Wholesale Price"],
394
- "WWHL": data.sku[count].priceFacets["Wholesale Price"]
408
+ "WADW-WRTL": product.priceFacets["Regular Price"],
409
+ "WADR": product.priceFacets["Regular Price"],
410
+ "RTL": product.priceFacets["Regular Price"],
411
+ "WADW": product.priceFacets["Wholesale Price"],
412
+ "WHL": product.priceFacets["Wholesale Price"],
413
+ "WWHL": product.priceFacets["Wholesale Price"]
395
414
  },
396
415
  "cvMap": {
397
- "WWHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
398
- "WADW": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
399
- "WHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : ''
416
+ "WWHL": (product.priceFacets.CV) ? product.priceFacets.CV : '',
417
+ "WADW": (product.priceFacets.CV) ? product.priceFacets.CV : '',
418
+ "WHL": (product.priceFacets.CV) ? product.priceFacets.CV : ''
400
419
  },
401
420
  "pvMap": {
402
- "WWHL": data.sku[count].priceFacets.PV,
403
- "WADW": data.sku[count].priceFacets.PV,
404
- "WHL": data.sku[count].priceFacets.PV
421
+ "WWHL": product.priceFacets.PV,
422
+ "WADW": product.priceFacets.PV,
423
+ "WHL": product.priceFacets.PV
405
424
  },
406
- "orderTypes": this._setOrderType(data.sku[count].properties),
425
+ "orderTypes": this._setOrderType(product.properties),
407
426
  "childSkus": [],
408
- "custTypes": this.switchCustType(data.sku[count].properties.customerTypes),
427
+ "custTypes": this.switchCustType(product.properties.customerTypes),
409
428
  "division": data.properties.division,
410
429
  "backOrderDate": null,
411
430
  "locallyProduced": false,
412
431
  "agelocme": null,
413
432
  "count": "",
414
433
  "flavor": "",
415
- "size": data.sku[count].properties.size,
434
+ "size": product.properties.size,
416
435
  "shade": "",
417
- "status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
436
+ "status": this.switchStatusFromEquinox(product.properties.productStatus),
418
437
  "variantType": "Other",
419
- "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
438
+ "variantDropdownLabel": product.properties.variantLabel || "",
420
439
  "variantDropdownPlaceholder": "Select Type",
421
- "variantsLabel": data.sku[count].properties.variantLabel || "",
440
+ "variantsLabel": product.properties.variantLabel || "",
422
441
  "groupOffer": false,
423
442
  "personalOffer": false,
424
443
  "savedEventName": eventName,
@@ -428,7 +447,7 @@ const ProductData = {
428
447
  "nettoWeight": "",
429
448
  "variants": variants,
430
449
  "searchScore": 0,
431
- "isExclusive": data.sku[count].properties.isExclusive || false,
450
+ "isExclusive": product.properties.isExclusive || false,
432
451
  "marketAttributes": {
433
452
  "discount": true,
434
453
  "redeem": true,
@@ -436,7 +455,7 @@ const ProductData = {
436
455
  },
437
456
  "restrictedMarkets": [],
438
457
  "addOns": [],
439
- "inventory": data.sku[count].inventory || "", //inventory label
458
+ "inventory": product.inventory || "", //inventory label
440
459
  "equinoxProductId": data.identifier
441
460
  };
442
461
  let newProduct = new Product(prod);
@@ -596,4 +615,12 @@ const ProductData = {
596
615
  }
597
616
  }
598
617
 
618
+ function contentstackEnv() {
619
+ if (typeof window === 'undefined') {
620
+ return 'test';
621
+ }
622
+
623
+ return (getEnvironmentFromUrl(window.location.host) != "prod") ? "test" : "prod";
624
+ }
625
+
599
626
  module.exports = ProductData;