@nuskin/ns-product-lib 2.5.0-cx24-2179.2.15 → 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 +7 -0
- package/package.json +1 -1
- package/src/contentstack/contentstack.js +5 -5
- package/src/index.js +2 -2
- package/src/models/customerTypes.js +16 -0
- package/src/{priceType.js → models/priceType.js} +0 -0
- package/src/{productStatus.js → models/productStatus.js} +7 -0
- package/src/product.js +2 -2
- package/src/productData.js +48 -26
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
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
|
+
|
1
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)
|
2
9
|
|
3
10
|
|
package/package.json
CHANGED
@@ -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 = {};
|
package/src/productData.js
CHANGED
@@ -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,7 +31,7 @@ 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
36
|
const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
|
36
37
|
axios.defaults.withCredentials = true;
|
@@ -176,6 +177,7 @@ const ProductData = {
|
|
176
177
|
"WHL": eqVariant.priceFacets.PV
|
177
178
|
},
|
178
179
|
"orderTypes": this._setOrderType(eqVariant.properties),
|
180
|
+
"custTypes": this.switchCustType(eqVariant.properties.customerTypes),
|
179
181
|
"division": eqVariant.properties.division,
|
180
182
|
"backOrderDate": null,
|
181
183
|
"locallyProduced": false,
|
@@ -186,9 +188,9 @@ const ProductData = {
|
|
186
188
|
"shade": "",
|
187
189
|
"status": this.switchStatusFromEquinox(eqVariant.properties.status),
|
188
190
|
"variantType": "Other",
|
189
|
-
"variantDropdownLabel": eqVariant.properties.
|
191
|
+
"variantDropdownLabel": eqVariant.properties.variantSelectLabel || "",
|
190
192
|
"variantDropdownPlaceholder": "Select Type",
|
191
|
-
"variantsLabel": eqVariant.properties.
|
193
|
+
"variantsLabel": eqVariant.properties.variantSelectLabel || "",
|
192
194
|
"groupOffer": false,
|
193
195
|
"personalOffer": false,
|
194
196
|
"savedEventName": eventName,
|
@@ -197,7 +199,7 @@ const ProductData = {
|
|
197
199
|
"sizeWeight": '',
|
198
200
|
"nettoWeight": "",
|
199
201
|
"searchScore": 0,
|
200
|
-
"isExclusive": false,
|
202
|
+
"isExclusive": eqVariant.properties.isExclusive || false,
|
201
203
|
"marketAttributes": {
|
202
204
|
"discount": true,
|
203
205
|
"redeem": true,
|
@@ -355,7 +357,7 @@ const ProductData = {
|
|
355
357
|
"nettoWeight": "",
|
356
358
|
"variants": variants,
|
357
359
|
"searchScore": 0,
|
358
|
-
"isExclusive": data.sku[count].properties.isExclusive,
|
360
|
+
"isExclusive": data.sku[count].properties.isExclusive || false,
|
359
361
|
"marketAttributes": {
|
360
362
|
"discount": true,
|
361
363
|
"redeem": true,
|
@@ -384,27 +386,29 @@ const ProductData = {
|
|
384
386
|
},
|
385
387
|
|
386
388
|
switchStatusFromEquinox: function (status) {
|
389
|
+
const { equinoxStatus } = ProductStatus;
|
387
390
|
let newStatus = '';
|
388
|
-
switch (status) {
|
389
|
-
case
|
390
|
-
newStatus =
|
391
|
+
switch (status.toLowerCase()) {
|
392
|
+
case equinoxStatus.SELLABLE:
|
393
|
+
newStatus = ProductStatus.ReleasedForSale;
|
391
394
|
break;
|
392
|
-
case
|
393
|
-
newStatus =
|
395
|
+
case equinoxStatus.PREVIEW_PRODUCT:
|
396
|
+
newStatus = ProductStatus.NotReleasedForSale;
|
394
397
|
break;
|
395
|
-
case
|
396
|
-
newStatus =
|
398
|
+
case equinoxStatus.DISCONTINUED:
|
399
|
+
newStatus = ProductStatus.Discontinued;
|
397
400
|
break;
|
398
|
-
case
|
399
|
-
newStatus =
|
401
|
+
case equinoxStatus.STOPPED:
|
402
|
+
newStatus = ProductStatus.Discontinued;
|
400
403
|
break;
|
401
|
-
case
|
402
|
-
newStatus =
|
404
|
+
case equinoxStatus.REPLACEMENT:
|
405
|
+
newStatus = ProductStatus.NotReleasedForSale;
|
403
406
|
break;
|
404
407
|
default:
|
405
|
-
newStatus =
|
408
|
+
newStatus = ProductStatus.NotReleasedForSale;
|
406
409
|
break;
|
407
410
|
}
|
411
|
+
|
408
412
|
return newStatus;
|
409
413
|
},
|
410
414
|
|
@@ -413,14 +417,32 @@ const ProductData = {
|
|
413
417
|
* @param {*} custType
|
414
418
|
*
|
415
419
|
*/
|
416
|
-
|
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
|
+
|
417
433
|
let newCustType = [];
|
418
|
-
if (
|
419
|
-
newCustType.push(
|
420
|
-
|
421
|
-
|
422
|
-
if (
|
423
|
-
newCustType.push(
|
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
|
+
|
424
446
|
return newCustType.toString()
|
425
447
|
},
|
426
448
|
|