@nuskin/ns-product-lib 2.7.0-cx24-3682.7 → 2.7.0-cx24-3682.9
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/equinox-helpers/childSKU.js +1 -1
- package/src/equinox-helpers/index.js +15 -4
- package/src/equinox-helpers/interceptors/productNotFound.js +12 -13
- package/src/equinox-helpers/mappers/identifier.js +13 -0
- package/src/equinox-helpers/mappers/index.js +7 -1
- package/src/equinox-helpers/mappers/inventoryProperties.js +173 -0
- package/src/equinox-helpers/mappers/variant.js +70 -0
- package/src/equinox-helpers/models/productNotFound.js +26 -4
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# [2.7.0-cx24-3682.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.8...v2.7.0-cx24-3682.9) (2023-03-26)
|
2
|
+
|
3
|
+
|
4
|
+
### New
|
5
|
+
|
6
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([66c977b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/66c977b3114e0cd7517d6eaa19174b0a3a13d1ed)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
7
|
+
|
8
|
+
# [2.7.0-cx24-3682.8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.7...v2.7.0-cx24-3682.8) (2023-03-26)
|
9
|
+
|
10
|
+
|
11
|
+
### New
|
12
|
+
|
13
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([3d69bbe](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3d69bbe486f13f4ae2a9fe4c07f53c4d27932177)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
14
|
+
|
1
15
|
# [2.7.0-cx24-3682.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.6...v2.7.0-cx24-3682.7) (2023-03-25)
|
2
16
|
|
3
17
|
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* childSKU maps a product variant. Used mainly in subscription.
|
3
3
|
*
|
4
4
|
* @param {import('.').KitSKUQuantity[]} kits
|
5
|
-
* @param {import('.').
|
5
|
+
* @param {import('.').EquinoxNormalProduct} product
|
6
6
|
*/
|
7
7
|
function childSKU(kits, product) {
|
8
8
|
const sku = product.sku.filter(sku => sku.default)[0];
|
@@ -38,16 +38,22 @@
|
|
38
38
|
* @description This model represents the response.
|
39
39
|
* @typedef EquinoxResponse
|
40
40
|
* @type {object}
|
41
|
-
* @property {
|
41
|
+
* @property {EquinoxNormalProduct[]} product
|
42
42
|
*/
|
43
43
|
|
44
44
|
/**
|
45
|
-
* @description
|
46
|
-
* @typedef
|
45
|
+
* @description EquinoxNormalProduct represents an equinox Normal product type.
|
46
|
+
* @typedef EquinoxNormalProduct
|
47
47
|
* @type {object}
|
48
48
|
* @property {string} identifier E.g., Normal - "blt8b757df6dcaa199c" | Kit - "02001076"
|
49
49
|
* @property {EquinoxProductProperties} properties
|
50
|
-
* @property {EquinoxProductVariant[]}
|
50
|
+
* @property {EquinoxProductVariant[]} sku or varaints - available only when product is a normal product.
|
51
|
+
*/
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @description EquinoxKitProduct represents an equinox Kit product type.
|
55
|
+
* @typedef EquinoxKitProduct
|
56
|
+
* @type {object}
|
51
57
|
* @property {"kit"|"bundle"} [type] available only when product is type of kit.
|
52
58
|
*/
|
53
59
|
|
@@ -107,6 +113,7 @@
|
|
107
113
|
*/
|
108
114
|
|
109
115
|
/**
|
116
|
+
* @description This does not contain the full list of properties from the response.
|
110
117
|
* @typedef EquinoxProductVariantProperties
|
111
118
|
* @type {object}
|
112
119
|
* @property {string} availableChannels E.g., "subscription,arsPhone,kiosk,mobile,web"
|
@@ -123,6 +130,10 @@
|
|
123
130
|
* @property {string} division E.g., "Nu Skin"
|
124
131
|
* @property {string} status E.g., "active"
|
125
132
|
* @property {string} size E.g., "30 mL / 1 fl.oz"
|
133
|
+
* @property {string} globalProductId
|
134
|
+
* @property {string} excludeFromSearch
|
135
|
+
* @property {string} chargeShipping
|
136
|
+
* @property {string} title
|
126
137
|
* @property {string} [variantLabel]
|
127
138
|
* @property {string} [isExclusive] E.g., "false" - Why is this a string??
|
128
139
|
*/
|
@@ -8,7 +8,7 @@ const httpStatus = { notFound: 404 };
|
|
8
8
|
* Note: Do not polute this file. Create a new file for new interceptor.
|
9
9
|
*
|
10
10
|
* @param {import('axios').AxiosError} error
|
11
|
-
* @returns {import('axios').
|
11
|
+
* @returns {import('axios').AxiosResponse<import('../').EquinoxResponse>}
|
12
12
|
*/
|
13
13
|
function productNotFoundInterceptor(error) {
|
14
14
|
const segments = 'catalogs/search';
|
@@ -20,18 +20,17 @@ function productNotFoundInterceptor(error) {
|
|
20
20
|
const sku = getSKU(filterParam);
|
21
21
|
|
22
22
|
if (sku !== null) {
|
23
|
-
|
24
|
-
...error,
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
23
|
+
const response = {
|
24
|
+
...error.response,
|
25
|
+
data: {
|
26
|
+
product: [
|
27
|
+
productNotFound(sku)
|
28
|
+
]
|
29
|
+
},
|
30
|
+
statusText: getStatusText(error.response)
|
31
|
+
};
|
32
|
+
|
33
|
+
return response;
|
35
34
|
}
|
36
35
|
|
37
36
|
console.error('Unable to detect SKU from the given parameter', filterParam);
|
@@ -1,5 +1,11 @@
|
|
1
|
+
const mapIdentifier = require('./identifier');
|
2
|
+
const mapInventoryProperties = require('./inventoryProperties');
|
1
3
|
const mapProperties = require('./properties');
|
4
|
+
const mapVariant = require('./variant');
|
2
5
|
|
3
6
|
module.exports = {
|
4
|
-
|
7
|
+
mapIdentifier,
|
8
|
+
mapInventoryProperties,
|
9
|
+
mapProperties,
|
10
|
+
mapVariant
|
5
11
|
};
|
@@ -0,0 +1,173 @@
|
|
1
|
+
// @ts-check
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @param {import('../').EquinoxProductInventoryProperties} inventoryProperties
|
5
|
+
*/
|
6
|
+
function mapInventoryProperties(inventoryProperties) {
|
7
|
+
/** @type {import('../').EquinoxProductInventoryProperties} */
|
8
|
+
const model = {};
|
9
|
+
model.available = mapAvailable(inventoryProperties.available);
|
10
|
+
model.lowStock = mapLowStock(inventoryProperties.lowStock);
|
11
|
+
model.binName = mapBinName(inventoryProperties.binName);
|
12
|
+
model.backOrdered = mapBackOrdered(inventoryProperties.backOrdered);
|
13
|
+
model.expectedBackOrderAvailabilityDate = mapExpectedBackOrderAvailabilityDate(
|
14
|
+
inventoryProperties.expectedBackOrderAvailabilityDate
|
15
|
+
);
|
16
|
+
model.preOrdered = mapPreOrdered(inventoryProperties.preOrdered);
|
17
|
+
model.expectedPreOrderAvailabilityDate = mapExpectedPreOrderAvailabilityDate(
|
18
|
+
inventoryProperties.expectedPreOrderAvailabilityDate
|
19
|
+
);
|
20
|
+
model.atpQty = mapAtpQty(inventoryProperties.atpQty);
|
21
|
+
model.preOrderedQty = mapPreOrderedQty(inventoryProperties.preOrderedQty);
|
22
|
+
model.backOrderedQty = mapBackOrderedQty(inventoryProperties.backOrderedQty);
|
23
|
+
model.lowStockThreshold = mapLowStockThreshold(inventoryProperties.lowStockThreshold);
|
24
|
+
model.outOfStockThreshold = mapOutOfStockThreshold(inventoryProperties.outOfStockThreshold);
|
25
|
+
|
26
|
+
return model;
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @param {boolean} available
|
31
|
+
* @returns {boolean}
|
32
|
+
*/
|
33
|
+
function mapAvailable(available) {
|
34
|
+
if (available) {
|
35
|
+
return available;
|
36
|
+
}
|
37
|
+
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* @param {boolean} lowStock
|
43
|
+
* @returns {boolean}
|
44
|
+
*/
|
45
|
+
function mapLowStock(lowStock) {
|
46
|
+
if (lowStock) {
|
47
|
+
return lowStock;
|
48
|
+
}
|
49
|
+
|
50
|
+
return false;
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @param {string} binName
|
55
|
+
* @returns {string}
|
56
|
+
*/
|
57
|
+
function mapBinName(binName) {
|
58
|
+
if (binName) {
|
59
|
+
return binName;
|
60
|
+
}
|
61
|
+
|
62
|
+
return '';
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* @param {boolean} backOrdered
|
67
|
+
* @returns {boolean}
|
68
|
+
*/
|
69
|
+
function mapBackOrdered(backOrdered) {
|
70
|
+
if (backOrdered) {
|
71
|
+
return backOrdered;
|
72
|
+
}
|
73
|
+
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
|
77
|
+
/**
|
78
|
+
* @param {number} expectedBackOrderAvailabilityDate
|
79
|
+
* @returns {number}
|
80
|
+
*/
|
81
|
+
function mapExpectedBackOrderAvailabilityDate(expectedBackOrderAvailabilityDate) {
|
82
|
+
if (expectedBackOrderAvailabilityDate) {
|
83
|
+
return expectedBackOrderAvailabilityDate;
|
84
|
+
}
|
85
|
+
|
86
|
+
return 0;
|
87
|
+
}
|
88
|
+
|
89
|
+
/**
|
90
|
+
* @param {boolean} preOrdered
|
91
|
+
* @returns {boolean}
|
92
|
+
*/
|
93
|
+
function mapPreOrdered(preOrdered) {
|
94
|
+
if (preOrdered) {
|
95
|
+
return preOrdered;
|
96
|
+
}
|
97
|
+
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* @param {number} expectedPreOrderAvailabilityDate
|
103
|
+
* @returns {number}
|
104
|
+
*/
|
105
|
+
function mapExpectedPreOrderAvailabilityDate(expectedPreOrderAvailabilityDate) {
|
106
|
+
if (expectedPreOrderAvailabilityDate) {
|
107
|
+
return expectedPreOrderAvailabilityDate;
|
108
|
+
}
|
109
|
+
|
110
|
+
return 0;
|
111
|
+
}
|
112
|
+
|
113
|
+
/**
|
114
|
+
* @param {number} atpQty
|
115
|
+
* @returns {number}
|
116
|
+
*/
|
117
|
+
function mapAtpQty(atpQty) {
|
118
|
+
if (atpQty) {
|
119
|
+
return atpQty;
|
120
|
+
}
|
121
|
+
|
122
|
+
return 0;
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* @param {number} preOrderedQty
|
127
|
+
* @returns {number}
|
128
|
+
*/
|
129
|
+
function mapPreOrderedQty(preOrderedQty) {
|
130
|
+
if (preOrderedQty) {
|
131
|
+
return preOrderedQty;
|
132
|
+
}
|
133
|
+
|
134
|
+
return 0;
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* @param {number} backOrderedQty
|
139
|
+
* @returns {number}
|
140
|
+
*/
|
141
|
+
function mapBackOrderedQty(backOrderedQty) {
|
142
|
+
if (backOrderedQty) {
|
143
|
+
return backOrderedQty;
|
144
|
+
}
|
145
|
+
|
146
|
+
return 0;
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* @param {number|null} lowStockThreshold
|
151
|
+
* @returns {number|null}
|
152
|
+
*/
|
153
|
+
function mapLowStockThreshold(lowStockThreshold) {
|
154
|
+
if (lowStockThreshold) {
|
155
|
+
return lowStockThreshold;
|
156
|
+
}
|
157
|
+
|
158
|
+
return null;
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* @param {number|null} outOfStockThreshold
|
163
|
+
* @returns {number|null}
|
164
|
+
*/
|
165
|
+
function mapOutOfStockThreshold(outOfStockThreshold) {
|
166
|
+
if (outOfStockThreshold) {
|
167
|
+
return outOfStockThreshold;
|
168
|
+
}
|
169
|
+
|
170
|
+
return null;
|
171
|
+
}
|
172
|
+
|
173
|
+
module.exports = mapInventoryProperties;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
// @ts-check
|
2
|
+
const mapIdentifier = require('./identifier');
|
3
|
+
const mapInventoryProperties = require('./inventoryProperties');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @param {import('../').EquinoxProductVariant} variant
|
7
|
+
*/
|
8
|
+
function mapVariant(variant) {
|
9
|
+
/** @type {import('../').EquinoxProductVariant} */
|
10
|
+
const model = {
|
11
|
+
identifier: mapIdentifier(variant.identifier),
|
12
|
+
inventory: '',
|
13
|
+
properties: {
|
14
|
+
benefits: '{}',
|
15
|
+
excludeFromSearch: '',
|
16
|
+
usage: '{}',
|
17
|
+
description: '',
|
18
|
+
chargeShipping: '',
|
19
|
+
globalProductId: '',
|
20
|
+
title: '',
|
21
|
+
scanQualifiedCount: '0',
|
22
|
+
division: '',
|
23
|
+
isExclusive: 'false',
|
24
|
+
imageURL: '',
|
25
|
+
customerTypes: 'BrandAffiliate,Preferred,Retail',
|
26
|
+
ingredients: '',
|
27
|
+
availableChannels: 'subscription,arsPhone,kiosk,mobile,web',
|
28
|
+
resources: '',
|
29
|
+
market: 'CA',
|
30
|
+
size: '',
|
31
|
+
name: '',
|
32
|
+
status: 'active'
|
33
|
+
},
|
34
|
+
promotion: [],
|
35
|
+
priceFacets: {
|
36
|
+
CV: '',
|
37
|
+
PV: '',
|
38
|
+
SB: '',
|
39
|
+
'Wholesale Price': '',
|
40
|
+
'Regular Price': ''
|
41
|
+
},
|
42
|
+
inventoryProperties: mapInventoryProperties(variant.inventoryProperties),
|
43
|
+
totalValue: {
|
44
|
+
originalPrice: 0,
|
45
|
+
priceAfterDiscount: 0,
|
46
|
+
priceFacets: {
|
47
|
+
CV: {
|
48
|
+
CV: 36
|
49
|
+
},
|
50
|
+
'Regular Price': {
|
51
|
+
'Regular Price': 52
|
52
|
+
},
|
53
|
+
PV: {
|
54
|
+
PV: 25.65
|
55
|
+
},
|
56
|
+
'Wholesale Price': {
|
57
|
+
'Wholesale Price': 42
|
58
|
+
},
|
59
|
+
SB: {
|
60
|
+
SB: 2
|
61
|
+
}
|
62
|
+
},
|
63
|
+
totaldiscount: 0
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
return model;
|
68
|
+
}
|
69
|
+
|
70
|
+
module.exports = mapVariant;
|
@@ -1,14 +1,14 @@
|
|
1
1
|
// @ts-check
|
2
|
-
const { mapProperties } = require('../mappers');
|
2
|
+
const { mapProperties, mapVariant, mapIdentifier, mapInventoryProperties } = require('../mappers');
|
3
3
|
|
4
4
|
/**
|
5
5
|
* @param {string} sku
|
6
|
-
* @returns {import('../').
|
6
|
+
* @returns {import('../').EquinoxNormalProduct}
|
7
7
|
*/
|
8
8
|
function productNotFound(sku) {
|
9
|
-
/** @type {import('../').
|
9
|
+
/** @type {import('../').EquinoxNormalProduct} */
|
10
10
|
const model = {};
|
11
|
-
model.identifier = sku
|
11
|
+
model.identifier = mapIdentifier(sku);
|
12
12
|
model.properties = mapProperties({
|
13
13
|
name: '',
|
14
14
|
imageURL: '',
|
@@ -25,6 +25,28 @@ function productNotFound(sku) {
|
|
25
25
|
size: '',
|
26
26
|
productDetailsDescription: ''
|
27
27
|
});
|
28
|
+
model.sku = [mapVariant({
|
29
|
+
identifier: '',
|
30
|
+
inventory: '',
|
31
|
+
inventoryProperties: mapInventoryProperties({
|
32
|
+
available: false,
|
33
|
+
lowStock: false,
|
34
|
+
binName: '',
|
35
|
+
backOrdered: false,
|
36
|
+
expectedBackOrderAvailabilityDate: 0,
|
37
|
+
preOrdered: false,
|
38
|
+
expectedPreOrderAvailabilityDate: 0,
|
39
|
+
atpQty: 0,
|
40
|
+
preOrderedQty: 0,
|
41
|
+
backOrderedQty: 0,
|
42
|
+
lowStockThreshold: null,
|
43
|
+
outOfStockThreshold: null
|
44
|
+
}),
|
45
|
+
properties: {},
|
46
|
+
promotion: [],
|
47
|
+
priceFacets: {},
|
48
|
+
totalValue: {}
|
49
|
+
})];
|
28
50
|
|
29
51
|
return model;
|
30
52
|
}
|