@nuskin/ns-product-lib 2.7.0-cx24-3702.3 → 2.7.0-cx24-3682.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,169 @@
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.resources = mapResources(props.resources);
19
+ properties.customerTypes = mapCustomerTypes(props.customerTypes);
20
+ properties.size = mapSize(props.size);
21
+
22
+ return properties;
23
+ }
24
+
25
+ /**
26
+ * @param {string|undefined} name
27
+ * @returns {string}
28
+ */
29
+ function mapName(name) {
30
+ if (name) {
31
+ return name;
32
+ }
33
+
34
+ return '';
35
+ }
36
+
37
+ /**
38
+ * @param {string|undefined} description
39
+ * @returns {string}
40
+ */
41
+ function mapDescription(description) {
42
+ if (description) {
43
+ return description;
44
+ }
45
+
46
+ return '';
47
+ }
48
+
49
+ /**
50
+ * @param {string|undefined} productDetailsDescription
51
+ * @returns {string}
52
+ */
53
+ function mapProductDetailsDescription(productDetailsDescription) {
54
+ if (productDetailsDescription) {
55
+ return productDetailsDescription;
56
+ }
57
+
58
+ return '';
59
+ }
60
+
61
+ /**
62
+ * @param {string|undefined} ingredients
63
+ * @returns {string}
64
+ */
65
+ function mapIngredients(ingredients) {
66
+ if (ingredients) {
67
+ return ingredients;
68
+ }
69
+
70
+ return '';
71
+ }
72
+
73
+ /**
74
+ * @param {string|undefined} benefits
75
+ * @returns {string}
76
+ */
77
+ function mapBenefits(benefits) {
78
+ if (benefits) {
79
+ return benefits;
80
+ }
81
+
82
+ return '';
83
+ }
84
+
85
+ /**
86
+ * @param {string|undefined} usage
87
+ * @returns {string}
88
+ */
89
+ function mapUsage(usage) {
90
+ if (usage) {
91
+ return usage;
92
+ }
93
+
94
+ return '';
95
+ }
96
+
97
+ /**
98
+ * @param {string|undefined} scanQualifiedCount
99
+ * @returns {string}
100
+ */
101
+ function mapScanQualifiedCount(scanQualifiedCount) {
102
+ if (scanQualifiedCount) {
103
+ return scanQualifiedCount;
104
+ }
105
+
106
+ return '';
107
+ }
108
+
109
+ /**
110
+ * @param {string|undefined} division
111
+ * @returns {string}
112
+ */
113
+ function mapDivision(division) {
114
+ if (division) {
115
+ return division;
116
+ }
117
+
118
+ return '';
119
+ }
120
+
121
+ /**
122
+ * @param {string|undefined} imageURL
123
+ * @returns {string}
124
+ */
125
+ function mapImageURL(imageURL) {
126
+ if (imageURL) {
127
+ return imageURL;
128
+ }
129
+
130
+ return '';
131
+ }
132
+
133
+ /**
134
+ * @param {string|undefined} resources
135
+ * @returns {string}
136
+ */
137
+ function mapResources(resources) {
138
+ if (resources) {
139
+ return resources;
140
+ }
141
+
142
+ return '';
143
+ }
144
+
145
+ /**
146
+ * @param {string|undefined} customerTypes
147
+ * @returns {string}
148
+ */
149
+ function mapCustomerTypes(customerTypes) {
150
+ if (customerTypes) {
151
+ return customerTypes;
152
+ }
153
+
154
+ return '';
155
+ }
156
+
157
+ /**
158
+ * @param {string|undefined} size
159
+ * @returns {string}
160
+ */
161
+ function mapSize(size) {
162
+ if (size) {
163
+ return size;
164
+ }
165
+
166
+ return '';
167
+ }
168
+
169
+ module.exports = mapProperties;
@@ -0,0 +1,51 @@
1
+ // @ts-check
2
+ const mapIdentifier = require('./identifier');
3
+ const mapInventoryProperties = require('./inventoryProperties');
4
+ const mapVariantProperties = require('./variantProperties');
5
+
6
+ /**
7
+ * @param {import('../').EquinoxProductVariant} variant
8
+ */
9
+ function mapVariant(variant) {
10
+ /** @type {import('../').EquinoxProductVariant} */
11
+ const model = {
12
+ identifier: mapIdentifier(variant.identifier),
13
+ inventory: '',
14
+ properties: mapVariantProperties(variant.properties),
15
+ promotion: [],
16
+ priceFacets: {
17
+ CV: '',
18
+ PV: '',
19
+ SB: '',
20
+ 'Wholesale Price': '',
21
+ 'Regular Price': ''
22
+ },
23
+ inventoryProperties: mapInventoryProperties(variant.inventoryProperties),
24
+ totalValue: {
25
+ originalPrice: 0,
26
+ priceAfterDiscount: 0,
27
+ priceFacets: {
28
+ CV: {
29
+ CV: 36
30
+ },
31
+ 'Regular Price': {
32
+ 'Regular Price': 52
33
+ },
34
+ PV: {
35
+ PV: 25.65
36
+ },
37
+ 'Wholesale Price': {
38
+ 'Wholesale Price': 42
39
+ },
40
+ SB: {
41
+ SB: 2
42
+ }
43
+ },
44
+ totaldiscount: 0
45
+ }
46
+ };
47
+
48
+ return model;
49
+ }
50
+
51
+ module.exports = mapVariant;
@@ -0,0 +1,273 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @param {import('../').EquinoxProductVariantProperties} properties
5
+ */
6
+ function mapVariantProperties(properties = {}) {
7
+ /** @type {import('../').EquinoxProductVariantProperties} */
8
+ const model = {};
9
+ model.benefits = mapBenefits(properties.benefits);
10
+ model.excludeFromSearch = mapExcludeFromSearch(properties.excludeFromSearch);
11
+ model.usage = mapUsage(properties.usage);
12
+ model.description = mapDescription(properties.description);
13
+ model.chargeShipping = mapChargeShipping(properties.chargeShipping);
14
+ model.globalProductId = mapGlobalProductId(properties.globalProductId);
15
+ model.title = mapTitle(properties.title);
16
+ model.scanQualifiedCount = mapScanQualifiedCount(properties.scanQualifiedCount);
17
+ model.division = mapDivision(properties.division);
18
+ model.isExclusive = mapIsExclusive('false',);
19
+ model.imageURL = mapImageURL(properties.imageURL);
20
+ model.customerTypes = mapCustomerTypes(properties.customerTypes);
21
+ model.ingredients = mapIngredients(properties.ingredients);
22
+ model.availableChannels = mapAvailableChannels(properties.availableChannels);
23
+ model.resources = mapResources(properties.resources);
24
+ model.market = mapMarket(properties.market);
25
+ model.size = mapSize(properties.size);
26
+ model.name = mapName(properties.name);
27
+ model.status = mapStatus(properties.status);
28
+ model.productStatus = mapProductStatus(properties.productStatus);
29
+
30
+ return model;
31
+ }
32
+
33
+ /**
34
+ * @param {string|undefined} benefits
35
+ * @returns {string}
36
+ */
37
+ function mapBenefits(benefits) {
38
+ if (benefits) {
39
+ return benefits;
40
+ }
41
+
42
+ return '';
43
+ }
44
+
45
+ /**
46
+ * @param {string|undefined} excludeFromSearch
47
+ * @returns {string}
48
+ */
49
+ function mapExcludeFromSearch(excludeFromSearch) {
50
+ if (excludeFromSearch) {
51
+ return excludeFromSearch;
52
+ }
53
+
54
+ return '';
55
+ }
56
+
57
+ /**
58
+ * @param {string|undefined} usage
59
+ * @returns {string}
60
+ */
61
+ function mapUsage(usage) {
62
+ if (usage) {
63
+ return usage;
64
+ }
65
+
66
+ return '';
67
+ }
68
+
69
+ /**
70
+ * @param {string|undefined} description
71
+ * @returns {string}
72
+ */
73
+ function mapDescription(description) {
74
+ if (description) {
75
+ return description;
76
+ }
77
+
78
+ return '';
79
+ }
80
+
81
+ /**
82
+ * @param {string|undefined} chargeShipping
83
+ * @returns {string}
84
+ */
85
+ function mapChargeShipping(chargeShipping) {
86
+ if (chargeShipping) {
87
+ return chargeShipping;
88
+ }
89
+
90
+ return '';
91
+ }
92
+
93
+ /**
94
+ * @param {string|undefined} globalProductId
95
+ * @returns {string}
96
+ */
97
+ function mapGlobalProductId(globalProductId) {
98
+ if (globalProductId) {
99
+ return globalProductId;
100
+ }
101
+
102
+ return '';
103
+ }
104
+
105
+ /**
106
+ * @param {string|undefined} title
107
+ * @returns {string}
108
+ */
109
+ function mapTitle(title) {
110
+ if (title) {
111
+ return title;
112
+ }
113
+
114
+ return '';
115
+ }
116
+
117
+ /**
118
+ * @param {string|undefined} scanQualifiedCount
119
+ * @returns {string}
120
+ */
121
+ function mapScanQualifiedCount(scanQualifiedCount) {
122
+ if (scanQualifiedCount) {
123
+ return scanQualifiedCount;
124
+ }
125
+
126
+ return '';
127
+ }
128
+
129
+ /**
130
+ * @param {string|undefined} division
131
+ * @returns {string}
132
+ */
133
+ function mapDivision(division) {
134
+ if (division) {
135
+ return division;
136
+ }
137
+
138
+ return '';
139
+ }
140
+
141
+ /**
142
+ * @param {string|undefined} isExclusive
143
+ * @returns {string}
144
+ */
145
+ function mapIsExclusive(isExclusive) {
146
+ if (isExclusive) {
147
+ return isExclusive;
148
+ }
149
+
150
+ return '';
151
+ }
152
+
153
+ /**
154
+ * @param {string|undefined} imageURL
155
+ * @returns {string}
156
+ */
157
+ function mapImageURL(imageURL) {
158
+ if (imageURL) {
159
+ return imageURL;
160
+ }
161
+
162
+ return '';
163
+ }
164
+
165
+ /**
166
+ * @param {string|undefined} customerTypes
167
+ * @returns {string}
168
+ */
169
+ function mapCustomerTypes(customerTypes) {
170
+ if (customerTypes) {
171
+ return customerTypes;
172
+ }
173
+
174
+ return '';
175
+ }
176
+
177
+ /**
178
+ * @param {string|undefined} ingredients
179
+ * @returns {string}
180
+ */
181
+ function mapIngredients(ingredients) {
182
+ if (ingredients) {
183
+ return ingredients;
184
+ }
185
+
186
+ return '';
187
+ }
188
+
189
+ /**
190
+ * @param {string|undefined} availableChannels
191
+ * @returns {string}
192
+ */
193
+ function mapAvailableChannels(availableChannels) {
194
+ if (availableChannels) {
195
+ return availableChannels;
196
+ }
197
+
198
+ return '';
199
+ }
200
+
201
+ /**
202
+ * @param {string|undefined} resources
203
+ * @returns {string}
204
+ */
205
+ function mapResources(resources) {
206
+ if (resources) {
207
+ return resources;
208
+ }
209
+
210
+ return '';
211
+ }
212
+
213
+ /**
214
+ * @param {string|undefined} market
215
+ * @returns {string}
216
+ */
217
+ function mapMarket(market) {
218
+ if (market) {
219
+ return market;
220
+ }
221
+
222
+ return '';
223
+ }
224
+
225
+ /**
226
+ * @param {string|undefined} size
227
+ * @returns {string}
228
+ */
229
+ function mapSize(size) {
230
+ if (size) {
231
+ return size;
232
+ }
233
+
234
+ return '';
235
+ }
236
+
237
+ /**
238
+ * @param {string|undefined} name
239
+ * @returns {string}
240
+ */
241
+ function mapName(name) {
242
+ if (name) {
243
+ return name;
244
+ }
245
+
246
+ return '';
247
+ }
248
+
249
+ /**
250
+ * @param {string|undefined} status
251
+ * @returns {string}
252
+ */
253
+ function mapStatus(status) {
254
+ if (status) {
255
+ return status;
256
+ }
257
+
258
+ return '';
259
+ }
260
+
261
+ /**
262
+ * @param {string|undefined} productStatus
263
+ * @returns {string}
264
+ */
265
+ function mapProductStatus(productStatus) {
266
+ if (productStatus) {
267
+ return productStatus;
268
+ }
269
+
270
+ return '';
271
+ }
272
+
273
+ module.exports = mapVariantProperties;
@@ -0,0 +1,5 @@
1
+ const productNotFound = require('./productNotFound');
2
+
3
+ module.exports = {
4
+ productNotFound
5
+ };
@@ -0,0 +1,32 @@
1
+ // @ts-check
2
+ const { mapIdentifier, mapProperties, mapVariant } = require('../mappers');
3
+
4
+ /**
5
+ * @param {import('../').EquinoxNormalProduct} product
6
+ * @param {string} market
7
+ * @returns {import('../').EquinoxNormalProduct}
8
+ */
9
+ function productNotFound(product, market) {
10
+ /** @type {import('../').EquinoxNormalProduct} */
11
+ const model = {};
12
+ model.identifier = mapIdentifier(product.identifier);
13
+ model.properties = mapProperties();
14
+ model.sku = [mapVariant({
15
+ identifier: product.identifier,
16
+ properties: {
17
+ availableChannels: 'subscription,arsPhone,kiosk,mobile,web',
18
+ customerTypes: 'BrandAffiliate,Preferred,Retail',
19
+ imageURL: 'https://nuskin.com/content/dam/global/images/products/01102730-nu-skin-tri-phasic-white-essence.png',
20
+ isExclusive: 'false',
21
+ market,
22
+ productStatus: 'Sellable',
23
+ scanQualifiedCount: '0',
24
+ status: 'active',
25
+ title: product.identifier
26
+ }
27
+ })];
28
+
29
+ return model;
30
+ }
31
+
32
+ module.exports = productNotFound;