@nuskin/ns-product-lib 2.10.0 → 2.11.0-cx24-5092.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [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)
2
+
3
+
4
+ ### New
5
+
6
+ * Moving from AEM to CS for EQ markets ([678e2ff](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/678e2ff682f99f15fac8dd0d5ed355c98419e4d6))
7
+ * Moving from AEM to CS for EQ markets ([ddfe55d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ddfe55d6a04886dc13faa65b1c75fe1cb04aecca))
8
+
9
+ ## [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)
10
+
11
+
12
+ ### Fix
13
+
14
+ * [EQ] backOrderDate is not showing in MySite/PO product card (#CX24-4922) ([99e54dd](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/99e54dd58f8e6f2509d50b1440b94a097ae406c4)), closes [#CX24-4922](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-4922)
15
+
1
16
  # [2.10.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.9.3...v2.10.0) (2023-08-09)
2
17
 
3
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.10.0",
3
+ "version": "2.11.0-cx24-5092.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": {
@@ -0,0 +1,18 @@
1
+
2
+
3
+ /**
4
+ * backOrderDate returns backorder date if product inventory status is BACKORDER.
5
+ * @param {import('./').Product} product
6
+ * @param {*} product
7
+ * @returns {number}
8
+ */
9
+ function backOrderDate(product) {
10
+ if (product.inventoryProperties && product.inventoryProperties.hasOwnProperty('expectedBackOrderAvailabilityDate')) {
11
+ return product.inventoryProperties.expectedBackOrderAvailabilityDate;
12
+ }
13
+
14
+ return 0;
15
+ }
16
+
17
+
18
+ module.exports = backOrderDate;
@@ -198,11 +198,13 @@
198
198
  * @property {string} sku
199
199
  * @property {number} qty
200
200
  */
201
+ const backOrderDate = require('./backOrderDate');
201
202
  const availableQuantity = require('./availableQuantity');
202
203
  const childSKU = require('./childSKU');
203
204
  const childSKUBundles = require('./childSKUBundles');
204
205
 
205
206
  module.exports = {
207
+ mapBackOrderDate: backOrderDate,
206
208
  mapAvailableQuantity: availableQuantity,
207
209
  mapChildSKU: childSKU,
208
210
  mapChildSKUBundle: childSKUBundles
@@ -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;
@@ -7,6 +7,7 @@ const CustomerTypes = require('./models/customerTypes');
7
7
  const ProductStatus = require("./models/productStatus");
8
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',
@@ -26,8 +27,10 @@ const ProductData = {
26
27
 
27
28
  if (isEquinoxEnabled) {
28
29
  const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
30
+ const graphQLResponse = ProductGraphQL.getProductFromGraphQL(skus)
31
+ console.log(graphQLResponse)
29
32
 
30
- if (config.country_code === market && config.active) {
33
+ if (config.active) {
31
34
  return await this.getProductFromEquinox(skus, localeMarket, config);
32
35
  }
33
36
  }
@@ -143,7 +146,7 @@ const ProductData = {
143
146
  * @param {obj} inventory
144
147
  * @returns {number} qty
145
148
  */
146
- getAvailableQty: function(inventory) {
149
+ getAvailableQty: function (inventory) {
147
150
  if (!inventory || (!inventory.hasOwnProperty('backOrdered')
148
151
  || !inventory.hasOwnProperty('atpQty') || !inventory.hasOwnProperty('backOrderedQty'))) {
149
152
  return 0;
@@ -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 axiosConfig = {
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(axiosConfig)
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