@nuskin/ns-product-lib 2.7.0-cx24-3682.13 → 2.7.0-cx24-3702.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +15 -67
- package/package.json +2 -2
- package/src/equinox-helpers/childSKU.js +1 -1
- package/src/equinox-helpers/index.js +31 -172
- package/src/product.js +65 -62
- package/src/productData.js +43 -27
- package/src/equinox-helpers/interceptors/index.js +0 -5
- package/src/equinox-helpers/interceptors/productNotFound.js +0 -70
- package/src/equinox-helpers/mappers/identifier.js +0 -13
- package/src/equinox-helpers/mappers/index.js +0 -11
- package/src/equinox-helpers/mappers/inventoryProperties.js +0 -173
- package/src/equinox-helpers/mappers/properties.js +0 -182
- package/src/equinox-helpers/mappers/variant.js +0 -71
- package/src/equinox-helpers/models/index.js +0 -5
- package/src/equinox-helpers/models/productNotFound.js +0 -54
@@ -1,11 +0,0 @@
|
|
1
|
-
const mapIdentifier = require('./identifier');
|
2
|
-
const mapInventoryProperties = require('./inventoryProperties');
|
3
|
-
const mapProperties = require('./properties');
|
4
|
-
const mapVariant = require('./variant');
|
5
|
-
|
6
|
-
module.exports = {
|
7
|
-
mapIdentifier,
|
8
|
-
mapInventoryProperties,
|
9
|
-
mapProperties,
|
10
|
-
mapVariant
|
11
|
-
};
|
@@ -1,173 +0,0 @@
|
|
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;
|
@@ -1,182 +0,0 @@
|
|
1
|
-
// @ts-check
|
2
|
-
/**
|
3
|
-
* mapProperties maps the properties of a product.
|
4
|
-
* @param {import('../').EquinoxProductProperties} props
|
5
|
-
*/
|
6
|
-
function mapProperties(props) {
|
7
|
-
/** @type {import('../').EquinoxProductProperties} */
|
8
|
-
const properties = {};
|
9
|
-
properties.name = mapName(props.name);
|
10
|
-
properties.description = mapDescription(props.description);
|
11
|
-
properties.productDetailsDescription = mapProductDetailsDescription(props.productDetailsDescription);
|
12
|
-
properties.ingredients = mapIngredients(props.ingredients);
|
13
|
-
properties.benefits = mapBenefits(props.benefits);
|
14
|
-
properties.usage = mapUsage(props.usage);
|
15
|
-
properties.scanQualifiedCount = mapScanQualifiedCount(props.scanQualifiedCount);
|
16
|
-
properties.division = mapDivision(props.division);
|
17
|
-
properties.imageURL = mapImageURL(props.imageURL);
|
18
|
-
properties.market = mapMarket(props.market);
|
19
|
-
properties.resources = mapResources(props.resources);
|
20
|
-
properties.customerTypes = mapCustomerTypes(props.customerTypes);
|
21
|
-
properties.size = mapSize(props.size);
|
22
|
-
|
23
|
-
return properties;
|
24
|
-
}
|
25
|
-
|
26
|
-
/**
|
27
|
-
* @param {string|undefined} name
|
28
|
-
* @returns {string}
|
29
|
-
*/
|
30
|
-
function mapName(name) {
|
31
|
-
if (name) {
|
32
|
-
return name;
|
33
|
-
}
|
34
|
-
|
35
|
-
return '';
|
36
|
-
}
|
37
|
-
|
38
|
-
/**
|
39
|
-
* @param {string|undefined} description
|
40
|
-
* @returns {string}
|
41
|
-
*/
|
42
|
-
function mapDescription(description) {
|
43
|
-
if (description) {
|
44
|
-
return description;
|
45
|
-
}
|
46
|
-
|
47
|
-
return '';
|
48
|
-
}
|
49
|
-
|
50
|
-
/**
|
51
|
-
* @param {string} productDetailsDescription
|
52
|
-
* @returns {string}
|
53
|
-
*/
|
54
|
-
function mapProductDetailsDescription(productDetailsDescription) {
|
55
|
-
if (productDetailsDescription) {
|
56
|
-
return productDetailsDescription;
|
57
|
-
}
|
58
|
-
|
59
|
-
return '';
|
60
|
-
}
|
61
|
-
|
62
|
-
/**
|
63
|
-
* @param {string|undefined} ingredients
|
64
|
-
* @returns {string}
|
65
|
-
*/
|
66
|
-
function mapIngredients(ingredients) {
|
67
|
-
if (ingredients) {
|
68
|
-
return ingredients;
|
69
|
-
}
|
70
|
-
|
71
|
-
return '';
|
72
|
-
}
|
73
|
-
|
74
|
-
/**
|
75
|
-
* @param {string|undefined} benefits
|
76
|
-
* @returns {string}
|
77
|
-
*/
|
78
|
-
function mapBenefits(benefits) {
|
79
|
-
if (benefits) {
|
80
|
-
return benefits;
|
81
|
-
}
|
82
|
-
|
83
|
-
return '';
|
84
|
-
}
|
85
|
-
|
86
|
-
/**
|
87
|
-
* @param {string|undefined} usage
|
88
|
-
* @returns {string}
|
89
|
-
*/
|
90
|
-
function mapUsage(usage) {
|
91
|
-
if (usage) {
|
92
|
-
return usage;
|
93
|
-
}
|
94
|
-
|
95
|
-
return '';
|
96
|
-
}
|
97
|
-
|
98
|
-
/**
|
99
|
-
* @param {string|undefined} scanQualifiedCount
|
100
|
-
* @returns {string}
|
101
|
-
*/
|
102
|
-
function mapScanQualifiedCount(scanQualifiedCount) {
|
103
|
-
if (scanQualifiedCount) {
|
104
|
-
return scanQualifiedCount;
|
105
|
-
}
|
106
|
-
|
107
|
-
return '';
|
108
|
-
}
|
109
|
-
|
110
|
-
/**
|
111
|
-
* @param {string|undefined} division
|
112
|
-
* @returns {string}
|
113
|
-
*/
|
114
|
-
function mapDivision(division) {
|
115
|
-
if (division) {
|
116
|
-
return division;
|
117
|
-
}
|
118
|
-
|
119
|
-
return '';
|
120
|
-
}
|
121
|
-
|
122
|
-
/**
|
123
|
-
* @param {string|undefined} imageURL
|
124
|
-
* @returns {string}
|
125
|
-
*/
|
126
|
-
function mapImageURL(imageURL) {
|
127
|
-
if (imageURL) {
|
128
|
-
return imageURL;
|
129
|
-
}
|
130
|
-
|
131
|
-
return '';
|
132
|
-
}
|
133
|
-
|
134
|
-
/**
|
135
|
-
* @param {string|undefined} market
|
136
|
-
* @returns {string}
|
137
|
-
*/
|
138
|
-
function mapMarket(market) {
|
139
|
-
if (market) {
|
140
|
-
return market;
|
141
|
-
}
|
142
|
-
|
143
|
-
return '';
|
144
|
-
}
|
145
|
-
|
146
|
-
/**
|
147
|
-
* @param {string|undefined} resources
|
148
|
-
* @returns {string}
|
149
|
-
*/
|
150
|
-
function mapResources(resources) {
|
151
|
-
if (resources) {
|
152
|
-
return resources;
|
153
|
-
}
|
154
|
-
|
155
|
-
return '';
|
156
|
-
}
|
157
|
-
|
158
|
-
/**
|
159
|
-
* @param {string|undefined} customerTypes
|
160
|
-
* @returns {string}
|
161
|
-
*/
|
162
|
-
function mapCustomerTypes(customerTypes) {
|
163
|
-
if (customerTypes) {
|
164
|
-
return customerTypes;
|
165
|
-
}
|
166
|
-
|
167
|
-
return '';
|
168
|
-
}
|
169
|
-
|
170
|
-
/**
|
171
|
-
* @param {string|undefined} size
|
172
|
-
* @returns {string}
|
173
|
-
*/
|
174
|
-
function mapSize(size) {
|
175
|
-
if (size) {
|
176
|
-
return size;
|
177
|
-
}
|
178
|
-
|
179
|
-
return '';
|
180
|
-
}
|
181
|
-
|
182
|
-
module.exports = mapProperties;
|
@@ -1,71 +0,0 @@
|
|
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: 'https://nuskin.com/content/dam/global/images/products/01102730-nu-skin-tri-phasic-white-essence.png',
|
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
|
-
productStatus: 'Sellable'
|
34
|
-
},
|
35
|
-
promotion: [],
|
36
|
-
priceFacets: {
|
37
|
-
CV: '',
|
38
|
-
PV: '',
|
39
|
-
SB: '',
|
40
|
-
'Wholesale Price': '',
|
41
|
-
'Regular Price': ''
|
42
|
-
},
|
43
|
-
inventoryProperties: mapInventoryProperties(variant.inventoryProperties),
|
44
|
-
totalValue: {
|
45
|
-
originalPrice: 0,
|
46
|
-
priceAfterDiscount: 0,
|
47
|
-
priceFacets: {
|
48
|
-
CV: {
|
49
|
-
CV: 36
|
50
|
-
},
|
51
|
-
'Regular Price': {
|
52
|
-
'Regular Price': 52
|
53
|
-
},
|
54
|
-
PV: {
|
55
|
-
PV: 25.65
|
56
|
-
},
|
57
|
-
'Wholesale Price': {
|
58
|
-
'Wholesale Price': 42
|
59
|
-
},
|
60
|
-
SB: {
|
61
|
-
SB: 2
|
62
|
-
}
|
63
|
-
},
|
64
|
-
totaldiscount: 0
|
65
|
-
}
|
66
|
-
};
|
67
|
-
|
68
|
-
return model;
|
69
|
-
}
|
70
|
-
|
71
|
-
module.exports = mapVariant;
|
@@ -1,54 +0,0 @@
|
|
1
|
-
// @ts-check
|
2
|
-
const { mapProperties, mapVariant, mapIdentifier, mapInventoryProperties } = require('../mappers');
|
3
|
-
|
4
|
-
/**
|
5
|
-
* @param {string} sku
|
6
|
-
* @returns {import('../').EquinoxNormalProduct}
|
7
|
-
*/
|
8
|
-
function productNotFound(sku) {
|
9
|
-
/** @type {import('../').EquinoxNormalProduct} */
|
10
|
-
const model = {};
|
11
|
-
model.identifier = mapIdentifier(sku);
|
12
|
-
model.properties = mapProperties({
|
13
|
-
name: '',
|
14
|
-
imageURL: '',
|
15
|
-
market: '',
|
16
|
-
description: '',
|
17
|
-
customerTypes: '',
|
18
|
-
division: '',
|
19
|
-
ingredients: '',
|
20
|
-
benefits: '',
|
21
|
-
usage: '',
|
22
|
-
resources: '',
|
23
|
-
scanQualifiedCount: '',
|
24
|
-
status: '',
|
25
|
-
size: '',
|
26
|
-
productDetailsDescription: ''
|
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
|
-
})];
|
50
|
-
|
51
|
-
return model;
|
52
|
-
}
|
53
|
-
|
54
|
-
module.exports = productNotFound;
|