@nuskin/ns-product-lib 2.6.0-cx24-3372.7 → 2.6.0-cx24-3377.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,52 +1,42 @@
1
- # [2.6.0-cx24-3372.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.6...v2.6.0-cx24-3372.7) (2023-03-07)
1
+ # [2.6.0-cx24-3377.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.1...v2.6.0-cx24-3377.1) (2023-03-08)
2
2
 
3
3
 
4
- ### Update
5
-
6
- * Fixed regex expression for imageURL resize for non contentstack images ([a7c99b5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a7c99b504a6ab361150868e5f9153585c8e60412))
7
-
8
- # [2.6.0-cx24-3372.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.5...v2.6.0-cx24-3372.6) (2023-03-06)
9
-
10
-
11
- ### Update
12
-
13
- * Query for product equinox search ([7f873a5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7f873a56cb579c68d7665947a2c5f9615eeb2101))
14
-
15
- # [2.6.0-cx24-3372.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.4...v2.6.0-cx24-3372.5) (2023-03-02)
16
-
17
-
18
- ### Fix
4
+ ### New
19
5
 
20
- * inventoryProperties atpQty ([3b271aa](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3b271aa16960fbaaa2a68c08a2d1d1c93d54ec15))
6
+ * Fix multiple variants not loading properly (CX24-3377) ([fb7a856](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fb7a856a39cb7189862d7b7be51b36b15569189e))
7
+ * Fix multiple variants not loading properly (CX24-3377) ([2990272](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/29902726ac21a246638586b5645a070bed1b7fa4))
8
+ * Fix multiple variants not loading properly (CX24-3377) ([0cee74b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0cee74bc366a9032966d235e54b731d03333f902))
21
9
 
22
- # [2.6.0-cx24-3372.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.3...v2.6.0-cx24-3372.4) (2023-03-02)
10
+ ## [2.5.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.5.1) (2023-03-07)
23
11
 
24
12
 
25
13
  ### Fix
26
14
 
27
- * inventoryProperties atpQty ([60ec521](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/60ec521223367abcd9570969c0e65522f76afe43))
15
+ * update getConfiguration call to work with new version of configuration-sdk #CX24-3503 ([8be370e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8be370ebfda910deea01fc562d28c199ed520467)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
28
16
 
29
- # [2.6.0-cx24-3372.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.2...v2.6.0-cx24-3372.3) (2023-03-02)
17
+ # [2.6.0-cx24-3503.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3503.1...v2.6.0-cx24-3503.2.1) (2023-03-07)
30
18
 
31
19
 
32
20
  ### Fix
33
21
 
34
- * Kit mapping ([af76396](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/af76396940d95988bbcfad73fc047381945847bb))
22
+ * update dependencies #CX24-3503 ([0ea7523](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0ea752306f8e64d5f73d397d5ddf3cf1839865c3)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
23
+ * update dependencies #CX24-3503 ([53cea8d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53cea8d5eb39ebaf9ff21b45d2310f02db98e25d)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
24
+ * update dependencies #CX24-3503 ([dd38c23](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/dd38c23b0094dea202fce7c6407c06c917d61676)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
25
+ * update dependencies #CX24-3503 ([ca67042](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ca670420a7ed79e7c6fabeb4b7c722abc5811a18)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
26
+ * update dependencies #CX24-3503 ([2ac0b65](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2ac0b652f84937d37716e861504ad8c424b20beb)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
27
+ * update dependencies #CX24-3503 ([682078f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/682078f703ccb8a0e84a559e828543f31f53ccd8)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
28
+ * update dependencies #CX24-3503 ([d48fb1a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d48fb1ac5e29dc7477be7b65522f25a2bbf25250)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
35
29
 
36
- # [2.6.0-cx24-3372.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.1...v2.6.0-cx24-3372.2) (2023-03-01)
37
-
38
-
39
- ### New
30
+ ### Release
40
31
 
41
- * Product Kit API search ([4260768](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/426076856ed7d1d90f536fc249d84e1bd88e2d12))
32
+ * Automated changes by GitLab pipeline [skip ci] ([fa35816](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fa35816ef50672ceaac01173d55615d88cb2c75b))
42
33
 
43
- # [2.6.0-cx24-3372.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.6.0-cx24-3372.1) (2023-03-01)
34
+ ## [2.5.1-cx24-3503.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.5.1-cx24-3503.2.1) (2023-03-07)
44
35
 
45
36
 
46
- ### New
37
+ ### Fix
47
38
 
48
- * Product Kit API search ([0d69d93](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0d69d931b989ccc250b698148c78db17a003bc13))
49
- * Product Kit API search ([d549e15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d549e15fa7c967d1b2bbede6d3c2695ecc66265c))
39
+ * update dependencies #CX24-3503 ([53cea8d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53cea8d5eb39ebaf9ff21b45d2310f02db98e25d)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
50
40
 
51
41
  # [2.5.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.5.0) (2023-02-22)
52
42
 
@@ -55,24 +45,6 @@
55
45
 
56
46
  * equinox API integration (#CX24) ([a169d58](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a169d5806f20737fae42d0ebe18a7c746861a4fb)), closes [#CX24](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24)
57
47
 
58
- # [2.5.0-cx24-2179.2.20](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.19...v2.5.0-cx24-2179.2.20) (2023-02-16)
59
-
60
-
61
- ### Fix
62
-
63
- * Get test environment if not PROD ([913abb6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/913abb61f8bc6aa8a2cb271d67de08f2f9505c5e))
64
-
65
- # [2.5.0-cx24-2179.2.19](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.18...v2.5.0-cx24-2179.2.19) (2023-01-27)
66
-
67
-
68
- ### Fix
69
-
70
- * parent product customer types (#CX24-3175) ([411b2cc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/411b2cc5a7cf687152dc346579766c8f923b795a)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
71
-
72
- ### Update
73
-
74
- * clean ups - expose customerTypes (#CX24-3175) ([3b7d9b1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3b7d9b12a9cf815b11a8af61621ab9ebc76c37b5)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
75
-
76
48
  # [2.5.0-cx24-2179.2.18](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.17...v2.5.0-cx24-2179.2.18) (2023-01-26)
77
49
 
78
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.6.0-cx24-3372.7",
3
+ "version": "2.6.0-cx24-3377.1",
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": {
@@ -31,9 +31,9 @@
31
31
  "prettier": "1.19.1"
32
32
  },
33
33
  "dependencies": {
34
- "@nuskin/configuration-sdk": "1.0.1",
34
+ "@nuskin/configuration-sdk": "2.2.3",
35
35
  "@nuskin/ns-common-lib": "1.4.5",
36
- "@nuskin/ns-util": "3.107.0",
36
+ "@nuskin/ns-util": "4.2.4",
37
37
  "axios": "0.27.2",
38
38
  "qs": "6.11.0"
39
39
  },
package/src/product.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const { isTrue } = require("@nuskin/ns-common-lib");
3
+ const { isTrue } = require("@nuskin/ns-common-lib");
4
4
 
5
5
  const ProductUtils = require("./productUtils.js");
6
6
 
@@ -8,7 +8,7 @@ const Agelocme = require("./agelocme.js");
8
8
  const PriceType = require("./models/priceType.js");
9
9
  const ProductStatus = require("./models/productStatus.js");
10
10
 
11
- const Product = function(productData) {
11
+ const Product = function (productData) {
12
12
  this.priceMap = {};
13
13
  this.pvMap = {};
14
14
  this.cvMap = {};
@@ -77,13 +77,13 @@ const Product = function(productData) {
77
77
  this.inventory = "";
78
78
  this.equinoxProductId = "";
79
79
 
80
- this.setMarketAttributes = function(productStatus) {
80
+ this.setMarketAttributes = function (productStatus) {
81
81
  if (productStatus.marketAttributes) {
82
82
  this.marketAttributes = productStatus.marketAttributes;
83
83
  }
84
84
  };
85
85
 
86
- this.getAgelocmeKeyPart = function() {
86
+ this.getAgelocmeKeyPart = function () {
87
87
  let keyPart = null;
88
88
  if (this.agelocme) {
89
89
  keyPart =
@@ -97,27 +97,27 @@ const Product = function(productData) {
97
97
  return keyPart;
98
98
  };
99
99
 
100
- this.getHighlightedSku = function() {
100
+ this.getHighlightedSku = function () {
101
101
  let rv = this.sku;
102
102
  if (this.highlightedSku) rv = this.highlightedSku;
103
103
  return rv;
104
104
  };
105
105
 
106
- this.getProductSearchTitle = function() {
106
+ this.getProductSearchTitle = function () {
107
107
  if (this.agelocme && this.agelocme.label) {
108
108
  return this.agelocme.label;
109
109
  }
110
110
  return this.title;
111
111
  };
112
112
 
113
- this.getProductSearchSku = function() {
113
+ this.getProductSearchSku = function () {
114
114
  if (this.agelocme && this.agelocme.code) {
115
115
  return this.agelocme.code;
116
116
  }
117
117
  return this.getHighlightedSku();
118
118
  };
119
119
 
120
- this.getDescription = function() {
120
+ this.getDescription = function () {
121
121
  let description = this.longDescr;
122
122
  if (!description || description.length === 0) {
123
123
  return this.shortDescr;
@@ -125,7 +125,7 @@ const Product = function(productData) {
125
125
  return description;
126
126
  };
127
127
 
128
- this.setFullImage = function(fullImage) {
128
+ this.setFullImage = function (fullImage) {
129
129
  if (fullImage) {
130
130
  this.fullImage = fullImage.replace("http:", "https:");
131
131
  } else {
@@ -133,19 +133,19 @@ const Product = function(productData) {
133
133
  }
134
134
  };
135
135
 
136
- this.getFullImage = function() {
136
+ this.getFullImage = function () {
137
137
  return this.fullImage ? this.fullImage.replace("http:", "https:") : "";
138
138
  };
139
139
 
140
- this.setProductCarouselImages = function(productCarouselImages) {
140
+ this.setProductCarouselImages = function (productCarouselImages) {
141
141
  this.productCarouselImages = productCarouselImages;
142
142
  };
143
143
 
144
- this.getProductCarouselImages = function() {
144
+ this.getProductCarouselImages = function () {
145
145
  return this.productCarouselImages;
146
146
  };
147
147
 
148
- this.setImageAltText = function(altText) {
148
+ this.setImageAltText = function (altText) {
149
149
  if (altText) {
150
150
  this.imageAltText = altText;
151
151
  } else {
@@ -153,11 +153,11 @@ const Product = function(productData) {
153
153
  }
154
154
  };
155
155
 
156
- this.getImageAltText = function() {
156
+ this.getImageAltText = function () {
157
157
  return this.imageAltText || this.title;
158
158
  };
159
159
 
160
- this.setThumbnail = function(thumbnail) {
160
+ this.setThumbnail = function (thumbnail) {
161
161
  if (thumbnail) {
162
162
  this.thumbnail = thumbnail.replace("http:", "https:");
163
163
  } else {
@@ -165,7 +165,7 @@ const Product = function(productData) {
165
165
  }
166
166
  };
167
167
 
168
- this.setThumbnailFromSku = function(sku) {
168
+ this.setThumbnailFromSku = function (sku) {
169
169
  // WARNING: Base URL will need to be handled in the client (call setBaseUrl)
170
170
  // eslint-disable-next-line max-len
171
171
  // this.thumbnail = `${RunConfigService.getBaseUrl()}/content/products/${ProductUtils.getTokenizedSku(sku)}/jcr:content/fullImage.img.100.100.png`;
@@ -175,43 +175,43 @@ const Product = function(productData) {
175
175
  )}/jcr:content/fullImage.img.100.100.png`;
176
176
  };
177
177
 
178
- this.getThumbnail = function() {
178
+ this.getThumbnail = function () {
179
179
  return this.thumbnail ? this.thumbnail.replace("http:", "https:") : "";
180
180
  };
181
181
 
182
- this.hasAvailableQuantity = function(qty = 1) {
182
+ this.hasAvailableQuantity = function (qty = 1) {
183
183
  return Math.min(this.maxQuantity, this.availableQuantity) >= qty;
184
184
  };
185
185
 
186
- this.setPoints = function(points) {
186
+ this.setPoints = function (points) {
187
187
  this.points = ensureFloatVal(points) || "";
188
188
  };
189
189
 
190
- this.getPointsFixed = function() {
190
+ this.getPointsFixed = function () {
191
191
  return parseFloat(this.points).toFixed(2);
192
192
  };
193
193
 
194
- this.setCv = function(cv) {
194
+ this.setCv = function (cv) {
195
195
  this.cv = ensureFloatVal(cv) || "";
196
196
  };
197
197
 
198
- this.getCvFixed = function() {
198
+ this.getCvFixed = function () {
199
199
  return parseFloat(this.cv).toFixed(2);
200
200
  };
201
201
 
202
- this.setPv = function(pv) {
202
+ this.setPv = function (pv) {
203
203
  this.pv = ensureFloatVal(pv) || "";
204
204
  };
205
205
 
206
- this.getPvFixed = function() {
206
+ this.getPvFixed = function () {
207
207
  return parseFloat(this.pv || 0).toFixed(2);
208
208
  };
209
209
 
210
- this.setPrice = function(price) {
210
+ this.setPrice = function (price) {
211
211
  this.price = ensureFloatVal(price, true);
212
212
  };
213
213
 
214
- this.setFormattedPrice = function(formattedPrice) {
214
+ this.setFormattedPrice = function (formattedPrice) {
215
215
  this.formattedPrice = formattedPrice;
216
216
  };
217
217
 
@@ -220,13 +220,13 @@ const Product = function(productData) {
220
220
  * added to the cart the event pricing needs to be remembered if toggling between
221
221
  * pricetypes with event pricing and pricetype without event pricing
222
222
  */
223
- this.lockEventName = function() {
223
+ this.lockEventName = function () {
224
224
  if (!this.savedEventName && this.eventName) {
225
225
  this.savedEventName = this.eventName;
226
226
  }
227
227
  };
228
228
 
229
- this.setPriceAndPvFromType = function(_priceType, _activeEvents = null, option = {}) {
229
+ this.setPriceAndPvFromType = function (_priceType, _activeEvents = null, option = {}) {
230
230
  // WARNING: priceType needs to be handled client-side
231
231
  // const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
232
232
  // ? PriceType.WWHL
@@ -271,11 +271,11 @@ const Product = function(productData) {
271
271
  return changed;
272
272
  };
273
273
 
274
- this.getPrice = function() {
274
+ this.getPrice = function () {
275
275
  return this.price ? this.price : 0;
276
276
  };
277
277
 
278
- this.getPriceFixed = function() {
278
+ this.getPriceFixed = function () {
279
279
  if (typeof this.price === "number") {
280
280
  return parseFloat(this.price.toFixed(2));
281
281
  } else {
@@ -283,15 +283,15 @@ const Product = function(productData) {
283
283
  }
284
284
  };
285
285
 
286
- this.getOriginalPrice = function() {
286
+ this.getOriginalPrice = function () {
287
287
  return this.priceType ? this.priceMap[this.priceType] : null;
288
288
  };
289
289
 
290
- this.addPricing = function(type, price) {
290
+ this.addPricing = function (type, price) {
291
291
  this.priceMap[type] = price;
292
292
  };
293
293
 
294
- this.addPricingFromStatus = function(productStatus, priceType, option ={}) {
294
+ this.addPricingFromStatus = function (productStatus, priceType, option = {}) {
295
295
  let modified = false;
296
296
 
297
297
  if (!priceType) {
@@ -326,7 +326,7 @@ const Product = function(productData) {
326
326
  }, this);
327
327
  }
328
328
  this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
329
- if(productStatus.childSkus) {
329
+ if (productStatus.childSkus) {
330
330
  this.childSkus = productStatus.childSkus;
331
331
  }
332
332
  this.setPriceAndPvFromType(priceType, null, option);
@@ -346,15 +346,15 @@ const Product = function(productData) {
346
346
  return modified;
347
347
  };
348
348
 
349
- this.addPvWithType = function(type, pv) {
349
+ this.addPvWithType = function (type, pv) {
350
350
  this.pvMap[type] = pv;
351
351
  };
352
352
 
353
- this.addCvWithType = function(type, cv) {
353
+ this.addCvWithType = function (type, cv) {
354
354
  this.cvMap[type] = cv;
355
355
  };
356
356
 
357
- this.getPricing = function(type) {
357
+ this.getPricing = function (type) {
358
358
  let retVal = null;
359
359
 
360
360
  if (type) {
@@ -381,7 +381,7 @@ const Product = function(productData) {
381
381
  return eventPriceTypes;
382
382
  };
383
383
 
384
- this.getPvWithType = function(type) {
384
+ this.getPvWithType = function (type) {
385
385
  let rv = this.pvMap[type];
386
386
  if (rv == null) {
387
387
  // Assumption: we always have WWHL from the service
@@ -391,7 +391,7 @@ const Product = function(productData) {
391
391
  return rv;
392
392
  };
393
393
 
394
- this.getCvWithType = function(type) {
394
+ this.getCvWithType = function (type) {
395
395
  let rv = this.cvMap[type];
396
396
  if (rv == null) {
397
397
  rv = this.cvMap[PriceType.WWHL];
@@ -399,77 +399,80 @@ const Product = function(productData) {
399
399
  return rv;
400
400
  };
401
401
 
402
- this.hasAdrOption = function() {
402
+ this.hasAdrOption = function () {
403
403
  return this.orderTypes["adr"];
404
404
  };
405
405
 
406
- this.isAdrOnly = function() {
406
+ this.isAdrOnly = function () {
407
407
  return this.hasAdrOption() && !this.hasOrderOption();
408
408
  };
409
409
 
410
- this.hasMultipleOrderTypes = function() {
410
+ this.hasMultipleOrderTypes = function () {
411
411
  return this.hasOrderOption() && this.hasAdrOption();
412
412
  };
413
413
 
414
- this.hasOrderOption = function() {
414
+ this.hasOrderOption = function () {
415
415
  return this.orderTypes["order"];
416
416
  };
417
417
 
418
- this.isDistributor = function() {
418
+ this.isDistributor = function () {
419
419
  return this.custTypes.includes("10");
420
420
  };
421
421
 
422
- this.isCustomer = function() {
422
+ this.isCustomer = function () {
423
423
  return this.custTypes.includes("20");
424
424
  };
425
425
 
426
- this.isPreferredCustomer = function() {
426
+ this.isPreferredCustomer = function () {
427
427
  return this.custTypes.includes("30");
428
428
  };
429
429
 
430
- this.isBase = function() {
430
+ this.isBase = function (option = {}) {
431
+ if (option && option.isEquinoxEnabled) {
432
+ return !!this.variants;
433
+ }
431
434
  return this.sku.substring(2, 4) === "55";
432
435
  };
433
436
 
434
- this.isVariant = function() {
437
+ this.isVariant = function () {
435
438
  return this.baseSku.length > 0 && this.variantSkus().length === 0;
436
439
  };
437
440
 
438
- this.setVariant = function(variantProduct) {
441
+ this.setVariant = function (variantProduct) {
439
442
  if (variantProduct && variantProduct.sku) {
440
443
  this.variants[variantProduct.sku] = variantProduct;
441
444
  }
442
445
  };
443
446
 
444
- this.getVariant = function(sku) {
447
+ this.getVariant = function (sku) {
445
448
  return this.variants[sku];
446
449
  };
447
450
 
448
- this.variantSkus = function() {
451
+ this.variantSkus = function () {
449
452
  return Object.keys(this.variants);
450
453
  };
451
454
 
452
- this.getVariantsList = function() {
455
+ this.getVariantsList = function () {
453
456
  return Object.values(this.variants);
454
457
  };
455
458
 
456
- this.getMinPrice = function() {
459
+ this.getMinPrice = function () {
457
460
  return this.priceMap[`min-${this.priceType}`];
458
461
  };
459
462
 
460
- this.getMaxPrice = function() {
463
+ this.getMaxPrice = function () {
461
464
  return this.priceMap[`max-${this.priceType}`];
462
465
  };
463
466
 
464
- this.getMinPv = function() {
467
+ this.getMinPv = function () {
465
468
  return this.pvMap[`min-${this.priceType}`];
466
469
  };
467
470
 
468
- this.getMaxPv = function() {
471
+ this.getMaxPv = function () {
469
472
  return this.pvMap[`max-${this.priceType}`];
470
473
  };
471
474
 
472
- this.toJSON = function() {
475
+ this.toJSON = function () {
473
476
  let retData = {};
474
477
  retData.sku = this.sku;
475
478
  retData.globalProductID = this.globalProductID;
@@ -538,15 +541,15 @@ const Product = function(productData) {
538
541
  return retData;
539
542
  };
540
543
 
541
- this.setMeCommerceProductData = function(/*productData*/) {
544
+ this.setMeCommerceProductData = function (/*productData*/) {
542
545
  console.error("setMeCommerceProductData is deprecated!");
543
546
  };
544
547
 
545
- this.setBaseUrl = function(baseUrl) {
548
+ this.setBaseUrl = function (baseUrl, option = {}) {
546
549
  this.thumbnail = ProductUtils.applyBaseUrl(this.thumbnail, baseUrl);
547
550
  this.fullImage = ProductUtils.applyBaseUrl(this.fullImage, baseUrl);
548
551
 
549
- if (this.isBase()) {
552
+ if (this.isBase(option)) {
550
553
  for (const variantSku in this.variants) {
551
554
  const variant = this.variants[variantSku];
552
555
  variant.setBaseUrl(baseUrl);
@@ -554,7 +557,7 @@ const Product = function(productData) {
554
557
  }
555
558
  };
556
559
 
557
- this.setProductData = function(productData) {
560
+ this.setProductData = function (productData) {
558
561
  let data;
559
562
 
560
563
  if (productData) {
@@ -662,7 +665,7 @@ const Product = function(productData) {
662
665
  ? data.pvMap
663
666
  : this.pvMap;
664
667
  this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, data.orderTypes);
665
- if(data.childSkus) {
668
+ if (data.childSkus) {
666
669
  this.childSkus = data.childSkus;
667
670
  }
668
671
  this.custTypes = data.custTypes || [];
@@ -678,7 +681,7 @@ const Product = function(productData) {
678
681
  }
679
682
  };
680
683
 
681
- this.isEmpty = function() {
684
+ this.isEmpty = function () {
682
685
  return (
683
686
  isFieldEmpty(this.sku) &&
684
687
  isFieldEmpty(this.title) &&
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  const { getConfiguration } = require('@nuskin/configuration-sdk');
3
- const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
4
3
  const axios = require("axios");
5
4
  const contentstack = require('./contentstack/contentstack');
6
5
  const Product = require("./product");
@@ -18,14 +17,9 @@ const ProductData = {
18
17
  const localeMarket = `${locale}_${market}`;
19
18
 
20
19
  if (isEquinoxEnabled) {
21
- let config = (await getConfiguration({
22
- configMapNames: ['Equinox_Markets'],
23
- country: market,
24
- environment: contentstackEnv(),
25
- clientId: '735b1eb810304bba966af0891ab54053'
26
- }));
27
-
28
- if (config.Equinox_Markets.country_code === market && config.Equinox_Markets.active) {
20
+ const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
21
+
22
+ if (config.country_code === market && config.active) {
29
23
  return await this.getProductFromEquinox(skus, localeMarket, config);
30
24
  }
31
25
  }
@@ -33,29 +27,17 @@ const ProductData = {
33
27
  },
34
28
 
35
29
  getProductFromEquinox: async function (skus, locale, config) {
36
-
37
- let skuFilter = [];
38
-
39
- if(Array.isArray(skus)) {
40
- skus.forEach((sku) => {
41
- skuFilter.push(`index_key_productId="${sku}" OR index_key_skuId="${sku}"`)
42
- })
43
- } else {
44
- //all featured products
45
- skuFilter.push(`index_key_productId="${skus}" OR index_key_skuId="${skus}"`)
46
- }
47
-
48
- const filter = skuFilter.join(" OR ")
30
+ const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
49
31
  axios.defaults.withCredentials = true;
50
32
 
51
- const url = `${config.Equinox_Markets.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
52
- const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
33
+ const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
34
+ const href = `${url}?filter=${encodeURI(filter)}`;
53
35
  const response = await axios.request({
54
36
  method: 'get',
55
37
  url: href,
56
38
  params: {
57
39
  locale,
58
- storeId: config.Equinox_Markets.store_id
40
+ storeId: config.store_id
59
41
  },
60
42
  headers: this.getEquinoxRequestHeaders(),
61
43
  responseType: 'json'
@@ -117,7 +99,7 @@ const ProductData = {
117
99
  eqProductVariantMapper: function (eqVariant) {
118
100
 
119
101
  let imageURL = eqVariant.properties.imageURL;
120
- const regex = /\d+\.\d+/
102
+ const regex = /\d+.\d+/
121
103
  let thumbnailImage = ''
122
104
 
123
105
  if (imageURL.includes('contentstack')) {
@@ -336,9 +318,8 @@ const ProductData = {
336
318
  let variants = {};
337
319
 
338
320
  let prodArr = productDataResponse.map((data) => {
339
- let product = (data.type && data.type === "kit") ? data : data.sku[count];
340
- let imageURL = product.properties.imageURL;
341
- const regex = /\d+\.\d+/
321
+ let imageURL = data.sku[count].properties.imageURL;
322
+ const regex = /\d+.\d+/
342
323
  let thumbnailImage = ''
343
324
 
344
325
  if (imageURL.includes('contentstack')) {
@@ -360,15 +341,15 @@ const ProductData = {
360
341
  eventLabels,
361
342
  computedPrice,
362
343
  defaultProductPrice
363
- } = this.getEqProductPromotions(product);
364
- const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
365
- const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
344
+ } = this.getEqProductPromotions(data.sku[count]);
345
+ const productPrice = eventName ? defaultProductPrice : data.sku[count].priceFacets["Regular Price"];
346
+ const discountedPrice = eventName ? computedPrice : data.sku[count].priceFacets["Regular Price"];
366
347
 
367
348
  prod = {
368
- "sku": product.identifier,
349
+ "sku": data.sku[count].identifier,
369
350
  "globalProductID": data.identifier,
370
351
  "title": data.properties.name,
371
- "country": product.properties.market,
352
+ "country": data.sku[count].properties.market,
372
353
  "language": "en",
373
354
  "shortDescr": data.properties.description,
374
355
  "longDescr": data.properties.productDetailsDescription,
@@ -385,7 +366,7 @@ const ProductData = {
385
366
  "ingredients": data.properties.ingredients,
386
367
  "benefits": data.properties.benefits,
387
368
  "usage": data.properties.usage,
388
- "resources": product.properties.resources,
369
+ "resources": data.sku[count].properties.resources,
389
370
  "videos": "",
390
371
  "movie": "",
391
372
  "youtube": "",
@@ -396,48 +377,48 @@ const ProductData = {
396
377
  }
397
378
  ],
398
379
  "scanQualified": data.properties.scanQualifiedCount,
399
- "availableQuantity": (product.inventoryProperties) ? product.inventoryProperties.atpQty : 0,
380
+ "availableQuantity": data.sku[count].inventoryProperties.atpQty,
400
381
  "maxQuantity": 999,
401
382
  "points": "",
402
- "cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
403
- "pv": product.priceFacets.PV,
383
+ "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
384
+ "pv": data.sku[count].priceFacets.PV,
404
385
  "priceType": "WRTL",
405
386
  "price": discountedPrice,
406
387
  "priceMap": {
407
388
  "WRTL": productPrice,
408
- "WADW-WRTL": product.priceFacets["Regular Price"],
409
- "WADR": product.priceFacets["Regular Price"],
410
- "RTL": product.priceFacets["Regular Price"],
411
- "WADW": product.priceFacets["Wholesale Price"],
412
- "WHL": product.priceFacets["Wholesale Price"],
413
- "WWHL": product.priceFacets["Wholesale Price"]
389
+ "WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
390
+ "WADR": data.sku[count].priceFacets["Regular Price"],
391
+ "RTL": data.sku[count].priceFacets["Regular Price"],
392
+ "WADW": data.sku[count].priceFacets["Wholesale Price"],
393
+ "WHL": data.sku[count].priceFacets["Wholesale Price"],
394
+ "WWHL": data.sku[count].priceFacets["Wholesale Price"]
414
395
  },
415
396
  "cvMap": {
416
- "WWHL": (product.priceFacets.CV) ? product.priceFacets.CV : '',
417
- "WADW": (product.priceFacets.CV) ? product.priceFacets.CV : '',
418
- "WHL": (product.priceFacets.CV) ? product.priceFacets.CV : ''
397
+ "WWHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
398
+ "WADW": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
399
+ "WHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : ''
419
400
  },
420
401
  "pvMap": {
421
- "WWHL": product.priceFacets.PV,
422
- "WADW": product.priceFacets.PV,
423
- "WHL": product.priceFacets.PV
402
+ "WWHL": data.sku[count].priceFacets.PV,
403
+ "WADW": data.sku[count].priceFacets.PV,
404
+ "WHL": data.sku[count].priceFacets.PV
424
405
  },
425
- "orderTypes": this._setOrderType(product.properties),
406
+ "orderTypes": this._setOrderType(data.sku[count].properties),
426
407
  "childSkus": [],
427
- "custTypes": this.switchCustType(product.properties.customerTypes),
408
+ "custTypes": this.switchCustType(data.sku[count].properties.customerTypes),
428
409
  "division": data.properties.division,
429
410
  "backOrderDate": null,
430
411
  "locallyProduced": false,
431
412
  "agelocme": null,
432
413
  "count": "",
433
414
  "flavor": "",
434
- "size": product.properties.size,
415
+ "size": data.sku[count].properties.size,
435
416
  "shade": "",
436
- "status": this.switchStatusFromEquinox(product.properties.productStatus),
417
+ "status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
437
418
  "variantType": "Other",
438
- "variantDropdownLabel": product.properties.variantLabel || "",
419
+ "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
439
420
  "variantDropdownPlaceholder": "Select Type",
440
- "variantsLabel": product.properties.variantLabel || "",
421
+ "variantsLabel": data.sku[count].properties.variantLabel || "",
441
422
  "groupOffer": false,
442
423
  "personalOffer": false,
443
424
  "savedEventName": eventName,
@@ -447,7 +428,7 @@ const ProductData = {
447
428
  "nettoWeight": "",
448
429
  "variants": variants,
449
430
  "searchScore": 0,
450
- "isExclusive": product.properties.isExclusive || false,
431
+ "isExclusive": data.sku[count].properties.isExclusive || false,
451
432
  "marketAttributes": {
452
433
  "discount": true,
453
434
  "redeem": true,
@@ -455,7 +436,7 @@ const ProductData = {
455
436
  },
456
437
  "restrictedMarkets": [],
457
438
  "addOns": [],
458
- "inventory": product.inventory || "", //inventory label
439
+ "inventory": data.sku[count].inventory || "", //inventory label
459
440
  "equinoxProductId": data.identifier
460
441
  };
461
442
  let newProduct = new Product(prod);
@@ -615,12 +596,4 @@ const ProductData = {
615
596
  }
616
597
  }
617
598
 
618
- function contentstackEnv() {
619
- if (typeof window === 'undefined') {
620
- return 'test';
621
- }
622
-
623
- return (getEnvironmentFromUrl(window.location.host) != "prod") ? "test" : "prod";
624
- }
625
-
626
599
  module.exports = ProductData;