@nuskin/ns-product-lib 2.10.2-cx24-5155.1 → 2.11.0-cx24-5092.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
- ## [2.10.2-cx24-5155.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.10.1...v2.10.2-cx24-5155.1) (2023-09-08)
1
+ # [2.11.0-cx24-5092.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.1...v2.11.0-cx24-5092.2) (2023-09-08)
2
2
 
3
3
 
4
- ### Fix
4
+ ### New
5
+
6
+ * Moving from AEM to CS for EQ markets ([53d373c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53d373c6a7221409e53e053febf4b7bd49f963ae))
7
+ * Moving from AEM to CS for EQ markets ([6d866bf](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6d866bfcd20ce4c2d1385abca29458ae49ab35fd))
8
+
9
+ # [2.11.0-cx24-5092.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.10.1...v2.11.0-cx24-5092.1) (2023-09-07)
10
+
11
+
12
+ ### New
5
13
 
6
- * backorder support for product bundle/kit (#CX24-5155) ([0ea8e0d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0ea8e0d96718545890e1590568ba63896fe3ba19)), closes [#CX24-5155](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-5155)
14
+ * Moving from AEM to CS for EQ markets ([678e2ff](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/678e2ff682f99f15fac8dd0d5ed355c98419e4d6))
15
+ * Moving from AEM to CS for EQ markets ([ddfe55d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ddfe55d6a04886dc13faa65b1c75fe1cb04aecca))
7
16
 
8
17
  ## [2.10.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.10.0...v2.10.1) (2023-08-31)
9
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.10.2-cx24-5155.1",
3
+ "version": "2.11.0-cx24-5092.2",
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": {
@@ -1,5 +1,3 @@
1
- const mapBackOrderDate = require('./backOrderDate');
2
-
3
1
  /**
4
2
  * childSKU maps a product variant. Used mainly in subscription.
5
3
  *
@@ -26,8 +24,7 @@ function childSKU(kits, product) {
26
24
  inventory: {
27
25
  atpQty: sku.inventoryProperties.atpQty,
28
26
  backOrdered: sku.inventoryProperties.backOrdered,
29
- backOrderedQty: sku.inventoryProperties.backOrderedQty,
30
- backOrderDate: mapBackOrderDate(sku)
27
+ backOrderedQty: sku.inventoryProperties.backOrderedQty
31
28
  }
32
29
  }
33
30
  }
@@ -1,10 +1,8 @@
1
- const mapBackOrderDate = require('./backOrderDate');
2
-
3
1
  /**
4
2
  * childSKU maps a product variant. Used mainly in subscription.
5
3
  *
6
- * @param {import('.').KitSKUQuantity[]} kits
7
- * @param {import('.').EquinoxNormalProduct} product
4
+ * @param {import('.').KitSKUQuantity[]} kits
5
+ * @param {import('.').EquinoxNormalProduct} product
8
6
  */
9
7
  function childSKUBundle(kits, product) {
10
8
  const sku = product.sku.filter(sku => sku.default)[0];
@@ -25,8 +23,7 @@ function childSKUBundle(kits, product) {
25
23
  availableChannels: sku.properties.availableChannels,
26
24
  inventory: {
27
25
  atpQty: sku.inventoryProperties.atpQty,
28
- backOrdered: sku.inventoryProperties.backOrdered,
29
- backOrderDate: mapBackOrderDate(sku)
26
+ backOrdered: sku.inventoryProperties.backOrdered
30
27
  }
31
28
  }
32
29
  }
@@ -0,0 +1,527 @@
1
+ "use strict";
2
+
3
+ const getProductGql = `query getProduct($id: String!, $market: String, $language: String, $useContentSource: String, $okta: String) {
4
+ productById(
5
+ id: $id
6
+ market: $market
7
+ language: $language
8
+ useContentSource: $useContentSource
9
+ okta: $okta
10
+ ) {
11
+ ...Product
12
+ bundle {
13
+ ...Kit
14
+ __typename
15
+ }
16
+ __typename
17
+ }
18
+ }
19
+
20
+ fragment Product on Product {
21
+ id
22
+ slug
23
+ title
24
+ secondaryTitle
25
+ productImages {
26
+ url
27
+ alt
28
+ thumbnail
29
+ __typename
30
+ }
31
+ salesLabel
32
+ salesText
33
+ description
34
+ salesDisclaimer
35
+ variantSelectLabel
36
+ variants {
37
+ ...Variant
38
+ __typename
39
+ }
40
+ features {
41
+ image {
42
+ url
43
+ alt
44
+ thumbnail
45
+ __typename
46
+ }
47
+ subtitle
48
+ features
49
+ backgroundColor
50
+ textColor
51
+ __typename
52
+ }
53
+ productDetails {
54
+ description
55
+ includedItems
56
+ highlights {
57
+ iconUrl
58
+ label
59
+ __typename
60
+ }
61
+ originCountry
62
+ importer
63
+ warnings
64
+ __typename
65
+ }
66
+ benefits {
67
+ benefits
68
+ image {
69
+ url
70
+ alt
71
+ thumbnail
72
+ __typename
73
+ }
74
+ youTubeVideoId
75
+ __typename
76
+ }
77
+ results {
78
+ summary
79
+ results {
80
+ percentage
81
+ text
82
+ __typename
83
+ }
84
+ report {
85
+ url
86
+ text
87
+ __typename
88
+ }
89
+ image {
90
+ url
91
+ alt
92
+ thumbnail
93
+ __typename
94
+ }
95
+ youTubeVideoId
96
+ __typename
97
+ }
98
+ sustainability {
99
+ youTubeVideoId
100
+ image {
101
+ url
102
+ __typename
103
+ }
104
+ description
105
+ highlights {
106
+ image {
107
+ url
108
+ __typename
109
+ }
110
+ description
111
+ __typename
112
+ }
113
+ __typename
114
+ }
115
+ usage {
116
+ steps
117
+ recommendations
118
+ warnings
119
+ additionalText
120
+ image {
121
+ url
122
+ alt
123
+ thumbnail
124
+ __typename
125
+ }
126
+ youTubeVideoId
127
+ markdown
128
+ __typename
129
+ }
130
+ resources {
131
+ title
132
+ url
133
+ image {
134
+ url
135
+ alt
136
+ thumbnail
137
+ __typename
138
+ }
139
+ __typename
140
+ }
141
+ warranty
142
+ faqs {
143
+ question
144
+ answers
145
+ __typename
146
+ }
147
+ ingredients {
148
+ productName
149
+ allIngredients
150
+ otherIngredients
151
+ activeIngredients
152
+ inactiveIngredients
153
+ ingredientDisclaimers
154
+ markdown
155
+ keyIngredients {
156
+ image {
157
+ url
158
+ alt
159
+ thumbnail
160
+ __typename
161
+ }
162
+ name
163
+ description
164
+ __typename
165
+ }
166
+ nutritionInformationImage {
167
+ url
168
+ alt
169
+ __typename
170
+ }
171
+ __typename
172
+ }
173
+ disclaimers
174
+ disclaimerWarnings {
175
+ icon {
176
+ url
177
+ alt
178
+ __typename
179
+ }
180
+ markdown
181
+ __typename
182
+ }
183
+ seoInformation {
184
+ metaDescription
185
+ metaTitle
186
+ canonicalURL
187
+ ogImage {
188
+ url
189
+ alt
190
+ __typename
191
+ }
192
+ __typename
193
+ }
194
+ thirdPartyScripts
195
+ productDataSource {
196
+ source
197
+ webBaseUrl
198
+ apiBaseUrl
199
+ storeId
200
+ __typename
201
+ }
202
+ error {
203
+ name
204
+ errors
205
+ lines
206
+ message
207
+ status
208
+ __typename
209
+ }
210
+ upSellProductIds
211
+ crossProductIds
212
+ __typename
213
+ }
214
+
215
+ fragment Variant on Variant {
216
+ sku
217
+ slug
218
+ variantLabel
219
+ variantColor
220
+ availableQuantity
221
+ maxQuantity
222
+ title
223
+ size
224
+ productImages {
225
+ url
226
+ alt
227
+ thumbnail
228
+ __typename
229
+ }
230
+ salesLabel
231
+ salesText
232
+ description
233
+ salesDisclaimer
234
+ nettoWeight
235
+ features {
236
+ image {
237
+ url
238
+ alt
239
+ thumbnail
240
+ __typename
241
+ }
242
+ subtitle
243
+ features
244
+ backgroundColor
245
+ textColor
246
+ __typename
247
+ }
248
+ productDetails {
249
+ description
250
+ includedItems
251
+ highlights {
252
+ iconUrl
253
+ label
254
+ __typename
255
+ }
256
+ originCountry
257
+ importer
258
+ warnings
259
+ __typename
260
+ }
261
+ benefits {
262
+ benefits
263
+ image {
264
+ url
265
+ alt
266
+ thumbnail
267
+ __typename
268
+ }
269
+ youTubeVideoId
270
+ __typename
271
+ }
272
+ results {
273
+ summary
274
+ results {
275
+ percentage
276
+ text
277
+ __typename
278
+ }
279
+ report {
280
+ url
281
+ text
282
+ __typename
283
+ }
284
+ image {
285
+ url
286
+ alt
287
+ thumbnail
288
+ __typename
289
+ }
290
+ youTubeVideoId
291
+ __typename
292
+ }
293
+ usage {
294
+ steps
295
+ recommendations
296
+ warnings
297
+ additionalText
298
+ image {
299
+ url
300
+ alt
301
+ thumbnail
302
+ __typename
303
+ }
304
+ youTubeVideoId
305
+ markdown
306
+ __typename
307
+ }
308
+ resources {
309
+ title
310
+ url
311
+ image {
312
+ url
313
+ alt
314
+ thumbnail
315
+ __typename
316
+ }
317
+ __typename
318
+ }
319
+ faqs {
320
+ question
321
+ answers
322
+ __typename
323
+ }
324
+ ingredients {
325
+ productName
326
+ allIngredients
327
+ otherIngredients
328
+ activeIngredients
329
+ inactiveIngredients
330
+ ingredientDisclaimers
331
+ markdown
332
+ keyIngredients {
333
+ image {
334
+ url
335
+ alt
336
+ thumbnail
337
+ __typename
338
+ }
339
+ name
340
+ description
341
+ __typename
342
+ }
343
+ nutritionInformationImage {
344
+ url
345
+ alt
346
+ __typename
347
+ }
348
+ __typename
349
+ }
350
+ isExclusive
351
+ price {
352
+ retail
353
+ wholesale
354
+ retailSales
355
+ wholesaleSales
356
+ retailSubscription
357
+ wholesaleSubscription
358
+ currencyCode
359
+ __typename
360
+ }
361
+ totalPrice {
362
+ retail
363
+ wholesale
364
+ retailSales
365
+ wholesaleSales
366
+ retailSubscription
367
+ wholesaleSubscription
368
+ currencyCode
369
+ __typename
370
+ }
371
+ points {
372
+ wholesale {
373
+ cv
374
+ pv
375
+ __typename
376
+ }
377
+ subscription {
378
+ cv
379
+ pv
380
+ __typename
381
+ }
382
+ __typename
383
+ }
384
+ totalPoints {
385
+ wholesale {
386
+ cv
387
+ pv
388
+ __typename
389
+ }
390
+ subscription {
391
+ cv
392
+ pv
393
+ __typename
394
+ }
395
+ __typename
396
+ }
397
+ pricingJson
398
+ availableQuantity
399
+ maxQuantity
400
+ status {
401
+ isBackordered
402
+ backorderedAvailableDate
403
+ status
404
+ __typename
405
+ }
406
+ purchaseTypes {
407
+ buyOnce
408
+ subscription
409
+ __typename
410
+ }
411
+ marketAttributes {
412
+ redeem
413
+ earn
414
+ __typename
415
+ }
416
+ disclaimers
417
+ disclaimerWarnings {
418
+ icon {
419
+ url
420
+ alt
421
+ __typename
422
+ }
423
+ markdown
424
+ __typename
425
+ }
426
+ restrictedMarkets
427
+ matchingVariant
428
+ shadeable
429
+ productType
430
+ primaryBrand
431
+ brandFamily
432
+ __typename
433
+ }
434
+
435
+ fragment Kit on Kit {
436
+ id
437
+ type
438
+ price {
439
+ currencyCode
440
+ retail
441
+ wholesale
442
+ retailSales
443
+ wholesaleSales
444
+ retailSubscription
445
+ wholesaleSubscription
446
+ __typename
447
+ }
448
+ totalPrice {
449
+ currencyCode
450
+ retail
451
+ wholesale
452
+ retailSales
453
+ wholesaleSales
454
+ retailSubscription
455
+ wholesaleSubscription
456
+ __typename
457
+ }
458
+ points {
459
+ wholesale {
460
+ cv
461
+ pv
462
+ __typename
463
+ }
464
+ subscription {
465
+ cv
466
+ pv
467
+ __typename
468
+ }
469
+ __typename
470
+ }
471
+ totalPoints {
472
+ wholesale {
473
+ cv
474
+ pv
475
+ __typename
476
+ }
477
+ subscription {
478
+ cv
479
+ pv
480
+ __typename
481
+ }
482
+ __typename
483
+ }
484
+ retailDiscount
485
+ wholesaleDiscount
486
+ pvDiscount
487
+ cvDiscount
488
+ sbDiscount
489
+ grpDiscount
490
+ availableChannels
491
+ customerTypes
492
+ purchaseTypes {
493
+ buyOnce
494
+ subscription
495
+ __typename
496
+ }
497
+ status {
498
+ status
499
+ isBackordered
500
+ backorderedAvailableDate
501
+ __typename
502
+ }
503
+ availableQuantity
504
+ chargeShipping
505
+ dangerousGoods
506
+ excludeFromSearch
507
+ isExclusive
508
+ marketAttributes {
509
+ discount
510
+ redeem
511
+ earn
512
+ __typename
513
+ }
514
+ restrictedMarkets
515
+ scanQualifiedCount
516
+ kitProducts {
517
+ quantity
518
+ isMandatory
519
+ product {
520
+ ...Product
521
+ __typename
522
+ }
523
+ __typename
524
+ }
525
+ __typename
526
+ }`
527
+ module.exports = getProductGql;
@@ -5,8 +5,9 @@ const contentstack = require('./contentstack/contentstack');
5
5
  const Product = require("./product");
6
6
  const CustomerTypes = require('./models/customerTypes');
7
7
  const ProductStatus = require("./models/productStatus");
8
- const { mapBackOrderDate, mapAvailableQuantity, mapChildSKU, mapChildSKUBundle } = require('./equinox-helpers');
8
+ const { mapAvailableQuantity, mapChildSKU, mapChildSKUBundle } = require('./equinox-helpers');
9
9
  const { productNotFoundInterceptor } = require('./equinox-helpers/interceptors');
10
+ const ProductGraphQL = require('./productGraphQL')
10
11
 
11
12
  const productTypes = {
12
13
  kit: 'kit',
@@ -24,13 +25,19 @@ const ProductData = {
24
25
  getProductData: async function (skus, locale, market, isEquinoxEnabled = false) {
25
26
  const localeMarket = `${locale}_${market}`;
26
27
 
27
- if (isEquinoxEnabled) {
28
- const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
29
28
 
30
- if (config.country_code === market && config.active) {
31
- return await this.getProductFromEquinox(skus, localeMarket, config);
32
- }
29
+ const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
30
+ skus.forEach((sku) => {
31
+ const graphQLResponse = ProductGraphQL.getProductFromGraphQL(sku)
32
+ console.log(graphQLResponse)
33
+ console.log(isEquinoxEnabled)
34
+ })
35
+
36
+
37
+ if (config.active) {
38
+ return await this.getProductFromEquinox(skus, localeMarket, config);
33
39
  }
40
+
34
41
  return await this.getProductFromLegacy(skus, localeMarket);
35
42
  },
36
43
 
@@ -140,11 +147,10 @@ const ProductData = {
140
147
  * Get available product quantity
141
148
  * If backOrdered === true, use backOrderedQty
142
149
  * else use atpQty
143
- * @todo deprecate this and try using equinox-helpers/availableQuantity.js
144
150
  * @param {obj} inventory
145
151
  * @returns {number} qty
146
152
  */
147
- getAvailableQty: function(inventory) {
153
+ getAvailableQty: function (inventory) {
148
154
  if (!inventory || (!inventory.hasOwnProperty('backOrdered')
149
155
  || !inventory.hasOwnProperty('atpQty') || !inventory.hasOwnProperty('backOrderedQty'))) {
150
156
  return 0;
@@ -157,24 +163,6 @@ const ProductData = {
157
163
  return inventory.atpQty;
158
164
  },
159
165
 
160
- /**
161
- * Get backorder date for normal, kit, bundle product
162
- * @param {*} product
163
- * @returns {number} backOrderDate
164
- */
165
- getBackOrderDate: function(product) {
166
-
167
- if ((product.type === productTypes.kit || product.type === productTypes.bundle) && product.childSkus) {
168
-
169
- //return max epoch time since childSkus already mapped in fetchChildSkus
170
- if (product.childSkus.some(sku => sku.inventory && sku.inventory.backOrderDate)) {
171
- return Math.max(...product.childSkus.map(sku => sku.inventory.backOrderDate || 0));
172
- }
173
- }
174
-
175
- return mapBackOrderDate(product);
176
- },
177
-
178
166
  /**
179
167
  * Map product variant
180
168
  * @todo remove unnecessary fields and do code refactoring
@@ -325,7 +313,7 @@ const ProductData = {
325
313
  "orderTypes": this._setOrderType(eqVariant.properties),
326
314
  "custTypes": this.switchCustType(eqVariant.properties.customerTypes),
327
315
  "division": eqVariant.properties.division,
328
- "backOrderDate": this.getBackOrderDate(eqVariant),
316
+ "backOrderDate": null,
329
317
  "locallyProduced": false,
330
318
  "agelocme": null,
331
319
  "count": "",
@@ -510,7 +498,7 @@ const ProductData = {
510
498
  "orderTypes": this._setOrderType(product.properties),
511
499
  "custTypes": this.switchCustType(product.properties.customerTypes),
512
500
  "division": productData.properties.division,
513
- "backOrderDate": this.getBackOrderDate(product),
501
+ "backOrderDate": null,
514
502
  "locallyProduced": false,
515
503
  "agelocme": null,
516
504
  "count": "",
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ //const { getConfiguration, getCachedConfigurations } = require('@nuskin/configuration-sdk');
3
+ const axios = require("axios");
4
+ //const Product = require("./product");
5
+ const getProductGql = require('./graphQl/query')
6
+
7
+
8
+ const ProductGraphQL = {
9
+ getProductFromGraphQL: async function (sku) {
10
+
11
+ let data = JSON.stringify({
12
+ query: getProductGql,
13
+ variables: { "market": "us", "language": "en", "id": sku, "useContentSource": null, "quantity": 1, "okta": null }
14
+ });
15
+
16
+ let axiosGqlConfig = {
17
+ method: 'post',
18
+ url: 'https://product.api.test.nuskin.com/graphql',
19
+ headers: {
20
+ 'authority': 'product.api.test.nuskin.com',
21
+ 'accept': '*/*',
22
+ 'accept-language': 'en-US,en;q=0.9',
23
+ 'content-type': 'application/json',
24
+ 'origin': 'https://mysite.test.mynuskin.com',
25
+ 'referer': 'https://mysite.test.mynuskin.com/'
26
+
27
+ },
28
+ data: data
29
+ };
30
+
31
+ axios.request(axiosGqlConfig)
32
+ .then((response) => {
33
+ return response.data
34
+ })
35
+ .catch((error) => {
36
+ console.log(error);
37
+ });
38
+
39
+ }
40
+
41
+ }
42
+
43
+ module.exports = ProductGraphQL