@nuskin/ns-product-lib 2.5.1-cx24-3282m.1 → 2.5.1-cx24-3503.2.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
- ## [2.5.1-cx24-3282m.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.5.1-cx24-3282m.1) (2023-02-28)
1
+ ## [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)
2
2
 
3
3
 
4
4
  ### Fix
5
5
 
6
- * Do not set availability from status service if eq ([545ec0e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/545ec0e4abe500842cc0631ba2d9b33dd8bee86f))
6
+ * 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)
7
7
 
8
8
  # [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)
9
9
 
@@ -12,13 +12,6 @@
12
12
 
13
13
  * 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)
14
14
 
15
- # [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)
16
-
17
-
18
- ### Fix
19
-
20
- * Get test environment if not PROD ([913abb6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/913abb61f8bc6aa8a2cb271d67de08f2f9505c5e))
21
-
22
15
  # [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)
23
16
 
24
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.5.1-cx24-3282m.1",
3
+ "version": "2.5.1-cx24-3503.2.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": {
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) {
@@ -303,9 +303,7 @@ const Product = function (productData) {
303
303
  if (productStatusSku === this.sku) {
304
304
  this.globalProductID = productStatus.globalProductID;
305
305
  this.status = productStatus.status;
306
- if (!option.isEqPromotion) {
307
- this.availableQuantity = productStatus.availableQuantity;
308
- }
306
+ this.availableQuantity = productStatus.availableQuantity;
309
307
  this.maxQuantity = productStatus.maxQuantity || 999;
310
308
  this.locallyProduced = productStatus.locallyProduced || false;
311
309
  if (productStatus.backordered) {
@@ -328,7 +326,7 @@ const Product = function (productData) {
328
326
  }, this);
329
327
  }
330
328
  this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
331
- if (productStatus.childSkus) {
329
+ if(productStatus.childSkus) {
332
330
  this.childSkus = productStatus.childSkus;
333
331
  }
334
332
  this.setPriceAndPvFromType(priceType, null, option);
@@ -348,15 +346,15 @@ const Product = function (productData) {
348
346
  return modified;
349
347
  };
350
348
 
351
- this.addPvWithType = function (type, pv) {
349
+ this.addPvWithType = function(type, pv) {
352
350
  this.pvMap[type] = pv;
353
351
  };
354
352
 
355
- this.addCvWithType = function (type, cv) {
353
+ this.addCvWithType = function(type, cv) {
356
354
  this.cvMap[type] = cv;
357
355
  };
358
356
 
359
- this.getPricing = function (type) {
357
+ this.getPricing = function(type) {
360
358
  let retVal = null;
361
359
 
362
360
  if (type) {
@@ -383,7 +381,7 @@ const Product = function (productData) {
383
381
  return eventPriceTypes;
384
382
  };
385
383
 
386
- this.getPvWithType = function (type) {
384
+ this.getPvWithType = function(type) {
387
385
  let rv = this.pvMap[type];
388
386
  if (rv == null) {
389
387
  // Assumption: we always have WWHL from the service
@@ -393,7 +391,7 @@ const Product = function (productData) {
393
391
  return rv;
394
392
  };
395
393
 
396
- this.getCvWithType = function (type) {
394
+ this.getCvWithType = function(type) {
397
395
  let rv = this.cvMap[type];
398
396
  if (rv == null) {
399
397
  rv = this.cvMap[PriceType.WWHL];
@@ -401,77 +399,77 @@ const Product = function (productData) {
401
399
  return rv;
402
400
  };
403
401
 
404
- this.hasAdrOption = function () {
402
+ this.hasAdrOption = function() {
405
403
  return this.orderTypes["adr"];
406
404
  };
407
405
 
408
- this.isAdrOnly = function () {
406
+ this.isAdrOnly = function() {
409
407
  return this.hasAdrOption() && !this.hasOrderOption();
410
408
  };
411
409
 
412
- this.hasMultipleOrderTypes = function () {
410
+ this.hasMultipleOrderTypes = function() {
413
411
  return this.hasOrderOption() && this.hasAdrOption();
414
412
  };
415
413
 
416
- this.hasOrderOption = function () {
414
+ this.hasOrderOption = function() {
417
415
  return this.orderTypes["order"];
418
416
  };
419
417
 
420
- this.isDistributor = function () {
418
+ this.isDistributor = function() {
421
419
  return this.custTypes.includes("10");
422
420
  };
423
421
 
424
- this.isCustomer = function () {
422
+ this.isCustomer = function() {
425
423
  return this.custTypes.includes("20");
426
424
  };
427
425
 
428
- this.isPreferredCustomer = function () {
426
+ this.isPreferredCustomer = function() {
429
427
  return this.custTypes.includes("30");
430
428
  };
431
429
 
432
- this.isBase = function () {
430
+ this.isBase = function() {
433
431
  return this.sku.substring(2, 4) === "55";
434
432
  };
435
433
 
436
- this.isVariant = function () {
434
+ this.isVariant = function() {
437
435
  return this.baseSku.length > 0 && this.variantSkus().length === 0;
438
436
  };
439
437
 
440
- this.setVariant = function (variantProduct) {
438
+ this.setVariant = function(variantProduct) {
441
439
  if (variantProduct && variantProduct.sku) {
442
440
  this.variants[variantProduct.sku] = variantProduct;
443
441
  }
444
442
  };
445
443
 
446
- this.getVariant = function (sku) {
444
+ this.getVariant = function(sku) {
447
445
  return this.variants[sku];
448
446
  };
449
447
 
450
- this.variantSkus = function () {
448
+ this.variantSkus = function() {
451
449
  return Object.keys(this.variants);
452
450
  };
453
451
 
454
- this.getVariantsList = function () {
452
+ this.getVariantsList = function() {
455
453
  return Object.values(this.variants);
456
454
  };
457
455
 
458
- this.getMinPrice = function () {
456
+ this.getMinPrice = function() {
459
457
  return this.priceMap[`min-${this.priceType}`];
460
458
  };
461
459
 
462
- this.getMaxPrice = function () {
460
+ this.getMaxPrice = function() {
463
461
  return this.priceMap[`max-${this.priceType}`];
464
462
  };
465
463
 
466
- this.getMinPv = function () {
464
+ this.getMinPv = function() {
467
465
  return this.pvMap[`min-${this.priceType}`];
468
466
  };
469
467
 
470
- this.getMaxPv = function () {
468
+ this.getMaxPv = function() {
471
469
  return this.pvMap[`max-${this.priceType}`];
472
470
  };
473
471
 
474
- this.toJSON = function () {
472
+ this.toJSON = function() {
475
473
  let retData = {};
476
474
  retData.sku = this.sku;
477
475
  retData.globalProductID = this.globalProductID;
@@ -540,11 +538,11 @@ const Product = function (productData) {
540
538
  return retData;
541
539
  };
542
540
 
543
- this.setMeCommerceProductData = function (/*productData*/) {
541
+ this.setMeCommerceProductData = function(/*productData*/) {
544
542
  console.error("setMeCommerceProductData is deprecated!");
545
543
  };
546
544
 
547
- this.setBaseUrl = function (baseUrl) {
545
+ this.setBaseUrl = function(baseUrl) {
548
546
  this.thumbnail = ProductUtils.applyBaseUrl(this.thumbnail, baseUrl);
549
547
  this.fullImage = ProductUtils.applyBaseUrl(this.fullImage, baseUrl);
550
548
 
@@ -556,7 +554,7 @@ const Product = function (productData) {
556
554
  }
557
555
  };
558
556
 
559
- this.setProductData = function (productData) {
557
+ this.setProductData = function(productData) {
560
558
  let data;
561
559
 
562
560
  if (productData) {
@@ -664,7 +662,7 @@ const Product = function (productData) {
664
662
  ? data.pvMap
665
663
  : this.pvMap;
666
664
  this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, data.orderTypes);
667
- if (data.childSkus) {
665
+ if(data.childSkus) {
668
666
  this.childSkus = data.childSkus;
669
667
  }
670
668
  this.custTypes = data.custTypes || [];
@@ -680,7 +678,7 @@ const Product = function (productData) {
680
678
  }
681
679
  };
682
680
 
683
- this.isEmpty = function () {
681
+ this.isEmpty = function() {
684
682
  return (
685
683
  isFieldEmpty(this.sku) &&
686
684
  isFieldEmpty(this.title) &&