@nuskin/ns-product-lib 2.5.0-cx24-2179.2.14 → 2.5.0-cx24-2179.2.16

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.5.0-cx24-2179.2.16](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.15...v2.5.0-cx24-2179.2.16) (2023-01-24)
2
+
3
+
4
+ ### Update
5
+
6
+ * Re-map changed Equinox properties after data migration (#CX24-3175) ([f20cbc4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f20cbc4bd63a3e0f810fbd6d0b2c5ad1aa236a8f)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
7
+
8
+ # [2.5.0-cx24-2179.2.15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.14...v2.5.0-cx24-2179.2.15) (2023-01-23)
9
+
10
+
11
+ ### Fix
12
+
13
+ * undefined value of the URL (CX24-3122,CX24-3234) ([5605d97](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5605d971de278b941d9d5776563fc8681a6c732a))
14
+
1
15
  # [2.5.0-cx24-2179.2.14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.13...v2.5.0-cx24-2179.2.14) (2023-01-23)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.5.0-cx24-2179.2.14",
3
+ "version": "2.5.0-cx24-2179.2.16",
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": {
@@ -98,7 +98,7 @@ function getCachedData(key) {
98
98
  * @property {string} checkout_client_secret
99
99
  *
100
100
  * @export
101
- * @return {Promise<null|MarketConfig>}
101
+ * @return {Promise<null|MarketConfig>}
102
102
  */
103
103
  async function getAEMConfig() {
104
104
  try {
@@ -137,7 +137,7 @@ async function getAEMConfig() {
137
137
  * @property {string} market_name
138
138
  * @property {string} country_code
139
139
  * @property {string} store_id
140
- *
140
+ *
141
141
  * @typedef EquinoxEnabledMarkets
142
142
  * @property {EquinoxEnabledMarket[]} [dev_markets]
143
143
  * @property {EquinoxEnabledMarket[]} [test_markets]
@@ -145,7 +145,7 @@ async function getAEMConfig() {
145
145
  * @property {EquinoxEnabledMarket[]} [prod_markets]
146
146
  *
147
147
  * @export
148
- * @return {Promise<EquinoxEnabledMarkets>}
148
+ * @return {Promise<EquinoxEnabledMarkets>}
149
149
  */
150
150
  async function getEquinoxMarkets() {
151
151
  try {
@@ -176,8 +176,8 @@ async function getEquinoxMarkets() {
176
176
  }
177
177
  }
178
178
 
179
- /**getKongUrl gets the URL for Kong in contentstack
180
- *
179
+ /**getKongUrl gets the URL for Kong in contentstack
180
+ *
181
181
  * @returns {string}
182
182
  */
183
183
  async function getKongUrl() {
package/src/index.js CHANGED
@@ -7,10 +7,10 @@
7
7
 
8
8
  const Agelocme = require("./agelocme.js");
9
9
  const Contentstack = require('./contentstack/contentstack');
10
- const PriceType = require("./priceType.js");
10
+ const PriceType = require("./models/priceType.js");
11
11
  const Product = require("./product.js");
12
12
  const ProductContentMapper = require("./productContentMapper.js");
13
- const ProductStatus = require("./productStatus.js");
13
+ const ProductStatus = require("./models/productStatus.js");
14
14
  const ProductStatusMapper = require("./productStatusMapper.js");
15
15
  const ProductUtils = require("./productUtils.js");
16
16
  const ProductData = require("./productData.js");
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ const CustomerTypes = {
4
+ BrandAffiliate: "brandaffiliate",
5
+ Preferred: "preferred",
6
+ PreferredCustomer: "preferred customer",
7
+ Retail: "retail",
8
+ properties: {
9
+ BRAND_AFFILIATE: { stringKey: "DIST", code: 10 },
10
+ RETAIL: { stringKey: "CUST", code: 20 },
11
+ PREFERRED: { stringKey: "preferred", code: 30 },
12
+ PREFERRED_CUSTOMER: { stringKey: "PREF", code: 30 }
13
+ }
14
+ };
15
+
16
+ module.exports = CustomerTypes;
File without changes
@@ -17,6 +17,13 @@ const ProductStatus = {
17
17
  STOP_STATUS: { stringKey: "stopStatus", code: 5 },
18
18
  NOT_FOUND: { stringKey: "", code: 0 },
19
19
  NOT_SOLD_SEPERATELY: {stringKey: "notSoldSeperately", code: 4 }
20
+ },
21
+ equinoxStatus: {
22
+ SELLABLE: 'sellable',
23
+ PREVIEW_PRODUCT: 'preview product',
24
+ DISCONTINUED: 'discontinued',
25
+ STOPPED: 'stopped',
26
+ REPLACEMENT: 'Replacement'
20
27
  }
21
28
  };
22
29
 
package/src/product.js CHANGED
@@ -5,8 +5,8 @@ const { isTrue } = require("@nuskin/ns-common-lib");
5
5
  const ProductUtils = require("./productUtils.js");
6
6
 
7
7
  const Agelocme = require("./agelocme.js");
8
- const PriceType = require("./priceType.js");
9
- const ProductStatus = require("./productStatus.js");
8
+ const PriceType = require("./models/priceType.js");
9
+ const ProductStatus = require("./models/productStatus.js");
10
10
 
11
11
  const Product = function(productData) {
12
12
  this.priceMap = {};
@@ -4,7 +4,8 @@ const { getConfiguration } = require('@nuskin/configuration-sdk');
4
4
  const axios = require("axios");
5
5
  const contentstack = require('./contentstack/contentstack');
6
6
  const Product = require("./product");
7
-
7
+ const CustomerTypes = require('./models/customerTypes');
8
+ const ProductStatus = require("./models/productStatus");
8
9
  /** @type {*} */
9
10
  const ProductData = {
10
11
  /**
@@ -15,7 +16,7 @@ const ProductData = {
15
16
  */
16
17
  getProductData: async function (skus, locale, market, isEquinoxEnabled = false) {
17
18
  const localeMarket = `${locale}_${market}`;
18
-
19
+
19
20
  if (isEquinoxEnabled) {
20
21
  let config = (await getConfiguration({
21
22
  configMapNames: ['Equinox_Markets'],
@@ -30,9 +31,8 @@ const ProductData = {
30
31
  }
31
32
  return await this.getProductFromLegacy(skus, localeMarket);
32
33
  },
33
-
34
+
34
35
  getProductFromEquinox: async function (skus, locale, config) {
35
- console.trace(config);
36
36
  const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
37
37
  axios.defaults.withCredentials = true;
38
38
 
@@ -177,6 +177,7 @@ const ProductData = {
177
177
  "WHL": eqVariant.priceFacets.PV
178
178
  },
179
179
  "orderTypes": this._setOrderType(eqVariant.properties),
180
+ "custTypes": this.switchCustType(eqVariant.properties.customerTypes),
180
181
  "division": eqVariant.properties.division,
181
182
  "backOrderDate": null,
182
183
  "locallyProduced": false,
@@ -187,9 +188,9 @@ const ProductData = {
187
188
  "shade": "",
188
189
  "status": this.switchStatusFromEquinox(eqVariant.properties.status),
189
190
  "variantType": "Other",
190
- "variantDropdownLabel": eqVariant.properties.variantLabel || "",
191
+ "variantDropdownLabel": eqVariant.properties.variantSelectLabel || "",
191
192
  "variantDropdownPlaceholder": "Select Type",
192
- "variantsLabel": eqVariant.properties.variantLabel || "",
193
+ "variantsLabel": eqVariant.properties.variantSelectLabel || "",
193
194
  "groupOffer": false,
194
195
  "personalOffer": false,
195
196
  "savedEventName": eventName,
@@ -198,7 +199,7 @@ const ProductData = {
198
199
  "sizeWeight": '',
199
200
  "nettoWeight": "",
200
201
  "searchScore": 0,
201
- "isExclusive": false,
202
+ "isExclusive": eqVariant.properties.isExclusive || false,
202
203
  "marketAttributes": {
203
204
  "discount": true,
204
205
  "redeem": true,
@@ -356,7 +357,7 @@ const ProductData = {
356
357
  "nettoWeight": "",
357
358
  "variants": variants,
358
359
  "searchScore": 0,
359
- "isExclusive": data.sku[count].properties.isExclusive,
360
+ "isExclusive": data.sku[count].properties.isExclusive || false,
360
361
  "marketAttributes": {
361
362
  "discount": true,
362
363
  "redeem": true,
@@ -385,27 +386,29 @@ const ProductData = {
385
386
  },
386
387
 
387
388
  switchStatusFromEquinox: function (status) {
389
+ const { equinoxStatus } = ProductStatus;
388
390
  let newStatus = '';
389
- switch (status) {
390
- case 'Sellable':
391
- newStatus = 'RELEASED_FOR_SALE';
391
+ switch (status.toLowerCase()) {
392
+ case equinoxStatus.SELLABLE:
393
+ newStatus = ProductStatus.ReleasedForSale;
392
394
  break;
393
- case 'Preview product':
394
- newStatus = 'NOT_RELEASED_FOR_SALE';
395
+ case equinoxStatus.PREVIEW_PRODUCT:
396
+ newStatus = ProductStatus.NotReleasedForSale;
395
397
  break;
396
- case 'Discontinued':
397
- newStatus = 'DISCONTINUED';
398
+ case equinoxStatus.DISCONTINUED:
399
+ newStatus = ProductStatus.Discontinued;
398
400
  break;
399
- case 'Stopped':
400
- newStatus = 'DISCONTINUED';
401
+ case equinoxStatus.STOPPED:
402
+ newStatus = ProductStatus.Discontinued;
401
403
  break;
402
- case 'Replacement':
403
- newStatus = 'NOT_RELEASED_FOR_SALE';
404
+ case equinoxStatus.REPLACEMENT:
405
+ newStatus = ProductStatus.NotReleasedForSale;
404
406
  break;
405
407
  default:
406
- newStatus = 'NOT_RELEASED_FOR_SALE'
408
+ newStatus = ProductStatus.NotReleasedForSale;
407
409
  break;
408
410
  }
411
+
409
412
  return newStatus;
410
413
  },
411
414
 
@@ -414,14 +417,32 @@ const ProductData = {
414
417
  * @param {*} custType
415
418
  *
416
419
  */
417
- switchCustType: function (custType) {
420
+
421
+ /**
422
+ * map customer types from string to code
423
+ * @param {*} eqCustomerTypes
424
+ * @returns
425
+ */
426
+ switchCustType: function (eqCustomerTypes) {
427
+ if (!eqCustomerTypes) {
428
+ return "";
429
+ }
430
+
431
+ const custTypes = eqCustomerTypes.split(',').map(customerType => customerType.trim().toLowerCase());
432
+
418
433
  let newCustType = [];
419
- if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
420
- newCustType.push(10)
421
- if (custType.includes('Retail Customer'))
422
- newCustType.push(20)
423
- if (custType.includes('Preferred Customer/Member'))
424
- newCustType.push(30)
434
+ if (custTypes.includes(CustomerTypes.BrandAffiliate)) {
435
+ newCustType.push(CustomerTypes.properties.BRAND_AFFILIATE.code);
436
+ }
437
+
438
+ if (custTypes.includes(CustomerTypes.Retail)) {
439
+ newCustType.push(CustomerTypes.properties.RETAIL.code);
440
+ }
441
+
442
+ if (custTypes.includes(CustomerTypes.Preferred) || custTypes.includes(CustomerTypes.PreferredCustomer)) {
443
+ newCustType.push(CustomerTypes.properties.PREFERRED.code);
444
+ }
445
+
425
446
  return newCustType.toString()
426
447
  },
427
448