@nuskin/ns-product-lib 2.11.0-cx24-5092.30 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5 -212
- package/package.json +1 -1
- package/src/equinox-helpers/childSKU.js +4 -1
- package/src/equinox-helpers/childSKUBundles.js +6 -3
- package/src/productData.js +31 -14
- package/src/graphQl/query.js +0 -527
- package/src/productGraphQL.js +0 -353
package/CHANGELOG.md
CHANGED
@@ -1,220 +1,13 @@
|
|
1
|
-
# [2.11.0
|
1
|
+
# [2.11.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.10.1...v2.11.0) (2023-09-18)
|
2
2
|
|
3
3
|
|
4
|
-
###
|
5
|
-
|
6
|
-
* Moving from AEM to CS for EQ markets ([a4a8e19](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a4a8e19032147ed5c4d37a0dc607796e3b687091))
|
7
|
-
|
8
|
-
# [2.11.0-cx24-5092.29](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.28...v2.11.0-cx24-5092.29) (2023-09-18)
|
9
|
-
|
10
|
-
|
11
|
-
### New
|
12
|
-
|
13
|
-
* Moving from AEM to CS for EQ markets ([6c50857](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6c50857164b3bbe363bd75010015238dacbbf552))
|
14
|
-
|
15
|
-
# [2.11.0-cx24-5092.28](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.27...v2.11.0-cx24-5092.28) (2023-09-18)
|
16
|
-
|
17
|
-
|
18
|
-
### New
|
19
|
-
|
20
|
-
* Moving from AEM to CS for EQ markets ([2374b2e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2374b2e9abaac6bb92cfcea1d5b35a40f4cf742c))
|
21
|
-
|
22
|
-
# [2.11.0-cx24-5092.27](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.26...v2.11.0-cx24-5092.27) (2023-09-18)
|
23
|
-
|
24
|
-
|
25
|
-
### New
|
26
|
-
|
27
|
-
* Moving from AEM to CS for EQ markets ([33228f8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/33228f8aad2be23c989d4d96f109c155c9fe7ac3))
|
28
|
-
|
29
|
-
# [2.11.0-cx24-5092.26](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.25...v2.11.0-cx24-5092.26) (2023-09-18)
|
30
|
-
|
31
|
-
|
32
|
-
### New
|
33
|
-
|
34
|
-
* Moving from AEM to CS for EQ markets ([cb2a5b3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cb2a5b3087fb6ee00e5bcd0b95ae67c16eaf7b1d))
|
35
|
-
|
36
|
-
# [2.11.0-cx24-5092.25](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.24...v2.11.0-cx24-5092.25) (2023-09-18)
|
37
|
-
|
38
|
-
|
39
|
-
### New
|
40
|
-
|
41
|
-
* Moving from AEM to CS for EQ markets ([5c95f51](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5c95f51f82eefe9dd5060a544f200facab0fbc38))
|
42
|
-
|
43
|
-
# [2.11.0-cx24-5092.24](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.23...v2.11.0-cx24-5092.24) (2023-09-15)
|
44
|
-
|
45
|
-
|
46
|
-
### New
|
47
|
-
|
48
|
-
* Moving from AEM to CS for EQ markets ([aa54de4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/aa54de461ca03dbf2a67161b1ce352216425b6e8))
|
49
|
-
|
50
|
-
# [2.11.0-cx24-5092.23](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.22...v2.11.0-cx24-5092.23) (2023-09-15)
|
51
|
-
|
52
|
-
|
53
|
-
### New
|
54
|
-
|
55
|
-
* Moving from AEM to CS for EQ markets ([f7c76ec](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f7c76ec6445f262758600d3e99307ee7f4c85be4))
|
56
|
-
|
57
|
-
# [2.11.0-cx24-5092.22](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.21...v2.11.0-cx24-5092.22) (2023-09-15)
|
58
|
-
|
59
|
-
|
60
|
-
### New
|
61
|
-
|
62
|
-
* Moving from AEM to CS for EQ markets ([85f3d2d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/85f3d2d724c80b9afefd5d4af6fc9fd4ab5abc32))
|
63
|
-
|
64
|
-
# [2.11.0-cx24-5092.21](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.20...v2.11.0-cx24-5092.21) (2023-09-14)
|
65
|
-
|
66
|
-
|
67
|
-
### New
|
68
|
-
|
69
|
-
* Moving from AEM to CS for EQ markets ([ff40018](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ff400181cdb045fcb904ce0c2aa22a03f5f1ab22))
|
70
|
-
|
71
|
-
# [2.11.0-cx24-5092.20](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.19...v2.11.0-cx24-5092.20) (2023-09-14)
|
72
|
-
|
73
|
-
|
74
|
-
### New
|
75
|
-
|
76
|
-
* Moving from AEM to CS for EQ markets ([a8fe3f7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a8fe3f7c832a00bb4cbf29528633ea7542f065d0))
|
77
|
-
|
78
|
-
# [2.11.0-cx24-5092.19](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.18...v2.11.0-cx24-5092.19) (2023-09-14)
|
79
|
-
|
80
|
-
|
81
|
-
### New
|
82
|
-
|
83
|
-
* Moving from AEM to CS for EQ markets ([b710207](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b710207fbd8df21a9dccd1c42219655636ceced7))
|
84
|
-
|
85
|
-
# [2.11.0-cx24-5092.18](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.17...v2.11.0-cx24-5092.18) (2023-09-14)
|
86
|
-
|
87
|
-
|
88
|
-
### New
|
89
|
-
|
90
|
-
* Moving from AEM to CS for EQ markets ([fbcefec](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fbcefec2c6ffee1f3b043281027f882da704502a))
|
91
|
-
* Moving from AEM to CS for EQ markets ([4f10a1a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4f10a1a88ace28ab3a8e45f8212d67534737a6a3))
|
92
|
-
|
93
|
-
# [2.11.0-cx24-5092.17](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.16...v2.11.0-cx24-5092.17) (2023-09-14)
|
94
|
-
|
95
|
-
|
96
|
-
### New
|
97
|
-
|
98
|
-
* Moving from AEM to CS for EQ markets ([a55c20f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a55c20fbd26268215a6d79bc43b818704730c1b3))
|
99
|
-
* Moving from AEM to CS for EQ markets ([b58bab6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b58bab6b7ef78e0444a3f918afc844772de832f8))
|
100
|
-
|
101
|
-
# [2.11.0-cx24-5092.16](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.15...v2.11.0-cx24-5092.16) (2023-09-14)
|
102
|
-
|
103
|
-
|
104
|
-
### New
|
105
|
-
|
106
|
-
* Moving from AEM to CS for EQ markets ([95c3072](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/95c30729cdbccd4a1520a276057d227d7050f02d))
|
107
|
-
* Moving from AEM to CS for EQ markets ([8dd3f14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8dd3f14feaddd492c657cee8bd630c6c7b533e83))
|
108
|
-
|
109
|
-
# [2.11.0-cx24-5092.15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.14...v2.11.0-cx24-5092.15) (2023-09-14)
|
4
|
+
### ix
|
110
5
|
|
6
|
+
* filter child sku to get BO date for BO sku only for kit/bundle (#CX24-5155) ([6f1537d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6f1537dcf06e30b6643707e6c2c60491abe9ced4)), closes [#CX24-5155](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-5155)
|
111
7
|
|
112
|
-
###
|
113
|
-
|
114
|
-
* Moving from AEM to CS for EQ markets ([616458b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/616458b98e5d425b456aa82042ddb7af5923ab6d))
|
115
|
-
|
116
|
-
# [2.11.0-cx24-5092.14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.13...v2.11.0-cx24-5092.14) (2023-09-13)
|
117
|
-
|
118
|
-
|
119
|
-
### New
|
120
|
-
|
121
|
-
* Moving from AEM to CS for EQ markets ([ce951e1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ce951e13a6200fa8bdd17baecbc914c51167eeb2))
|
122
|
-
|
123
|
-
# [2.11.0-cx24-5092.13](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.12...v2.11.0-cx24-5092.13) (2023-09-13)
|
124
|
-
|
125
|
-
|
126
|
-
### New
|
127
|
-
|
128
|
-
* Moving from AEM to CS for EQ markets ([fbad8f9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fbad8f951e9f40427de8b8538909d5d932770b6f))
|
129
|
-
* Moving from AEM to CS for EQ markets ([952d737](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/952d737b55c705f7d88c1ad6beff87a82bc9d314))
|
130
|
-
|
131
|
-
# [2.11.0-cx24-5092.12](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.11...v2.11.0-cx24-5092.12) (2023-09-13)
|
132
|
-
|
133
|
-
|
134
|
-
### New
|
135
|
-
|
136
|
-
* Moving from AEM to CS for EQ markets ([4973d82](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4973d82f1ce7bd7746f357ff357a65e880ad22d0))
|
137
|
-
* Moving from AEM to CS for EQ markets ([1a2ed1b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1a2ed1bbea62a7e3d1b076aae1d0df9f528afb72))
|
138
|
-
|
139
|
-
# [2.11.0-cx24-5092.11](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.10...v2.11.0-cx24-5092.11) (2023-09-13)
|
140
|
-
|
141
|
-
|
142
|
-
### New
|
143
|
-
|
144
|
-
* Moving from AEM to CS for EQ markets ([538bdc1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/538bdc1d777091afa844985cffccbc693cd04f23))
|
145
|
-
|
146
|
-
# [2.11.0-cx24-5092.10](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.9...v2.11.0-cx24-5092.10) (2023-09-13)
|
147
|
-
|
148
|
-
|
149
|
-
### New
|
150
|
-
|
151
|
-
* Moving from AEM to CS for EQ markets ([60763aa](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/60763aaaf7311cc95860f24b8e6652a0be13a622))
|
152
|
-
|
153
|
-
# [2.11.0-cx24-5092.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.8...v2.11.0-cx24-5092.9) (2023-09-13)
|
154
|
-
|
155
|
-
|
156
|
-
### New
|
157
|
-
|
158
|
-
* Moving from AEM to CS for EQ markets ([220bf20](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/220bf20a4f6564625e1e8ecc54ffcb8061aaef08))
|
159
|
-
|
160
|
-
# [2.11.0-cx24-5092.8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.7...v2.11.0-cx24-5092.8) (2023-09-13)
|
161
|
-
|
162
|
-
|
163
|
-
### New
|
164
|
-
|
165
|
-
* Moving from AEM to CS for EQ markets ([fe4ba38](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fe4ba38001139d8070cbb8de56ce9600e0da3c1c))
|
166
|
-
|
167
|
-
# [2.11.0-cx24-5092.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.6...v2.11.0-cx24-5092.7) (2023-09-09)
|
168
|
-
|
169
|
-
|
170
|
-
### New
|
171
|
-
|
172
|
-
* Moving from AEM to CS for EQ markets ([29c8dab](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/29c8dab12e0d29b237463b09645e6935bd030bec))
|
173
|
-
|
174
|
-
# [2.11.0-cx24-5092.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.5...v2.11.0-cx24-5092.6) (2023-09-09)
|
175
|
-
|
176
|
-
|
177
|
-
### New
|
178
|
-
|
179
|
-
* Moving from AEM to CS for EQ markets ([268dc8f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/268dc8fcd3ed89511050923c3cc3e2650d6fbfce))
|
180
|
-
|
181
|
-
# [2.11.0-cx24-5092.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.4...v2.11.0-cx24-5092.5) (2023-09-09)
|
182
|
-
|
183
|
-
|
184
|
-
### New
|
185
|
-
|
186
|
-
* Moving from AEM to CS for EQ markets ([c6d52c3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/c6d52c3e1f6f8d7d596d5c86095265c90624e53d))
|
187
|
-
* Moving from AEM to CS for EQ markets ([cc8b3fc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cc8b3fc5403e021589d9d42f1db71ff380f87b57))
|
188
|
-
|
189
|
-
# [2.11.0-cx24-5092.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.3...v2.11.0-cx24-5092.4) (2023-09-08)
|
190
|
-
|
191
|
-
|
192
|
-
### New
|
193
|
-
|
194
|
-
* Moving from AEM to CS for EQ markets ([af5acd8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/af5acd8dca1c73004b6ee634faf90d6e47f974fd))
|
195
|
-
|
196
|
-
# [2.11.0-cx24-5092.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.2...v2.11.0-cx24-5092.3) (2023-09-08)
|
197
|
-
|
198
|
-
|
199
|
-
### New
|
200
|
-
|
201
|
-
* Moving from AEM to CS for EQ markets ([1c61841](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1c6184105b06c7a04846f78d2e4d939c3ff67e93))
|
202
|
-
|
203
|
-
# [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)
|
204
|
-
|
205
|
-
|
206
|
-
### New
|
207
|
-
|
208
|
-
* Moving from AEM to CS for EQ markets ([53d373c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53d373c6a7221409e53e053febf4b7bd49f963ae))
|
209
|
-
* Moving from AEM to CS for EQ markets ([6d866bf](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6d866bfcd20ce4c2d1385abca29458ae49ab35fd))
|
210
|
-
|
211
|
-
# [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)
|
212
|
-
|
213
|
-
|
214
|
-
### New
|
8
|
+
### Update
|
215
9
|
|
216
|
-
*
|
217
|
-
* Moving from AEM to CS for EQ markets ([ddfe55d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ddfe55d6a04886dc13faa65b1c75fe1cb04aecca))
|
10
|
+
* added unitest for product bundle backorder date (#CX24-5155) ([051c962](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/051c962862d6bfc2c4e2403ccbcfcbcc0635aeca)), closes [#CX24-5155](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-5155)
|
218
11
|
|
219
12
|
## [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)
|
220
13
|
|
package/package.json
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
const mapBackOrderDate = require('./backOrderDate');
|
2
|
+
|
1
3
|
/**
|
2
4
|
* childSKU maps a product variant. Used mainly in subscription.
|
3
5
|
*
|
@@ -24,7 +26,8 @@ function childSKU(kits, product) {
|
|
24
26
|
inventory: {
|
25
27
|
atpQty: sku.inventoryProperties.atpQty,
|
26
28
|
backOrdered: sku.inventoryProperties.backOrdered,
|
27
|
-
backOrderedQty: sku.inventoryProperties.backOrderedQty
|
29
|
+
backOrderedQty: sku.inventoryProperties.backOrderedQty,
|
30
|
+
backOrderDate: mapBackOrderDate(sku)
|
28
31
|
}
|
29
32
|
}
|
30
33
|
}
|
@@ -1,8 +1,10 @@
|
|
1
|
+
const mapBackOrderDate = require('./backOrderDate');
|
2
|
+
|
1
3
|
/**
|
2
4
|
* childSKU maps a product variant. Used mainly in subscription.
|
3
5
|
*
|
4
|
-
* @param {import('.').KitSKUQuantity[]} kits
|
5
|
-
* @param {import('.').EquinoxNormalProduct} product
|
6
|
+
* @param {import('.').KitSKUQuantity[]} kits
|
7
|
+
* @param {import('.').EquinoxNormalProduct} product
|
6
8
|
*/
|
7
9
|
function childSKUBundle(kits, product) {
|
8
10
|
const sku = product.sku.filter(sku => sku.default)[0];
|
@@ -23,7 +25,8 @@ function childSKUBundle(kits, product) {
|
|
23
25
|
availableChannels: sku.properties.availableChannels,
|
24
26
|
inventory: {
|
25
27
|
atpQty: sku.inventoryProperties.atpQty,
|
26
|
-
backOrdered: sku.inventoryProperties.backOrdered
|
28
|
+
backOrdered: sku.inventoryProperties.backOrdered,
|
29
|
+
backOrderDate: mapBackOrderDate(sku)
|
27
30
|
}
|
28
31
|
}
|
29
32
|
}
|
package/src/productData.js
CHANGED
@@ -5,9 +5,8 @@ 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 { mapAvailableQuantity, mapChildSKU, mapChildSKUBundle } = require('./equinox-helpers');
|
8
|
+
const { mapBackOrderDate, mapAvailableQuantity, mapChildSKU, mapChildSKUBundle } = require('./equinox-helpers');
|
9
9
|
const { productNotFoundInterceptor } = require('./equinox-helpers/interceptors');
|
10
|
-
const ProductGraphQL = require('./productGraphQL')
|
11
10
|
|
12
11
|
const productTypes = {
|
13
12
|
kit: 'kit',
|
@@ -22,18 +21,17 @@ const ProductData = {
|
|
22
21
|
* @param {string} market
|
23
22
|
* @param {boolean} isEquinoxEnabled
|
24
23
|
*/
|
25
|
-
getProductData: async function (skus, locale, market) {
|
24
|
+
getProductData: async function (skus, locale, market, isEquinoxEnabled = false) {
|
26
25
|
const localeMarket = `${locale}_${market}`;
|
27
|
-
let graphQLResponse;
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
return await this.getProductFromLegacy(skus, localeMarket);
|
27
|
+
if (isEquinoxEnabled) {
|
28
|
+
const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
|
29
|
+
|
30
|
+
if (config.country_code === market && config.active) {
|
31
|
+
return await this.getProductFromEquinox(skus, localeMarket, config);
|
32
|
+
}
|
36
33
|
}
|
34
|
+
return await this.getProductFromLegacy(skus, localeMarket);
|
37
35
|
},
|
38
36
|
|
39
37
|
getProductFromEquinox: async function (skus, locale, config) {
|
@@ -142,10 +140,11 @@ const ProductData = {
|
|
142
140
|
* Get available product quantity
|
143
141
|
* If backOrdered === true, use backOrderedQty
|
144
142
|
* else use atpQty
|
143
|
+
* @todo deprecate this and try using equinox-helpers/availableQuantity.js
|
145
144
|
* @param {obj} inventory
|
146
145
|
* @returns {number} qty
|
147
146
|
*/
|
148
|
-
getAvailableQty: function
|
147
|
+
getAvailableQty: function(inventory) {
|
149
148
|
if (!inventory || (!inventory.hasOwnProperty('backOrdered')
|
150
149
|
|| !inventory.hasOwnProperty('atpQty') || !inventory.hasOwnProperty('backOrderedQty'))) {
|
151
150
|
return 0;
|
@@ -158,6 +157,24 @@ const ProductData = {
|
|
158
157
|
return inventory.atpQty;
|
159
158
|
},
|
160
159
|
|
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.filter(sku => sku.inventory && sku.inventory.backOrdered).map(sku => (sku.inventory && sku.inventory.backOrderDate) || 0));
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
return mapBackOrderDate(product);
|
176
|
+
},
|
177
|
+
|
161
178
|
/**
|
162
179
|
* Map product variant
|
163
180
|
* @todo remove unnecessary fields and do code refactoring
|
@@ -308,7 +325,7 @@ const ProductData = {
|
|
308
325
|
"orderTypes": this._setOrderType(eqVariant.properties),
|
309
326
|
"custTypes": this.switchCustType(eqVariant.properties.customerTypes),
|
310
327
|
"division": eqVariant.properties.division,
|
311
|
-
"backOrderDate":
|
328
|
+
"backOrderDate": this.getBackOrderDate(eqVariant),
|
312
329
|
"locallyProduced": false,
|
313
330
|
"agelocme": null,
|
314
331
|
"count": "",
|
@@ -493,7 +510,7 @@ const ProductData = {
|
|
493
510
|
"orderTypes": this._setOrderType(product.properties),
|
494
511
|
"custTypes": this.switchCustType(product.properties.customerTypes),
|
495
512
|
"division": productData.properties.division,
|
496
|
-
"backOrderDate":
|
513
|
+
"backOrderDate": this.getBackOrderDate(product),
|
497
514
|
"locallyProduced": false,
|
498
515
|
"agelocme": null,
|
499
516
|
"count": "",
|
package/src/graphQl/query.js
DELETED
@@ -1,527 +0,0 @@
|
|
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;
|
package/src/productGraphQL.js
DELETED
@@ -1,353 +0,0 @@
|
|
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
|
-
const ProductStatus = require("./models/productStatus");
|
8
|
-
const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
const ProductGraphQL = {
|
16
|
-
getProductGraphqlUrl: function () {
|
17
|
-
const env = getEnvironmentFromUrl(window.location.host);
|
18
|
-
|
19
|
-
switch (env) {
|
20
|
-
case "dev":
|
21
|
-
return "https://test.nuskin.com/product-api/graphql";
|
22
|
-
case "stage":
|
23
|
-
case "test":
|
24
|
-
return "https://test.nuskin.com/product-api/graphql";
|
25
|
-
case "unknown":
|
26
|
-
case "prod":
|
27
|
-
default:
|
28
|
-
return "https://www.nuskin.com/product-api/graphql";
|
29
|
-
}
|
30
|
-
},
|
31
|
-
getProductFromGraphQL: async function (id, market, locale, config) {
|
32
|
-
|
33
|
-
console.log(config)
|
34
|
-
const url = this.getProductGraphqlUrl();
|
35
|
-
const payload = {
|
36
|
-
query: getProductGql,
|
37
|
-
variables: { id, market, locale },
|
38
|
-
operationName: "getProduct",
|
39
|
-
useContentSource: "CS"
|
40
|
-
}
|
41
|
-
|
42
|
-
const response = await axios.request({
|
43
|
-
method: 'post',
|
44
|
-
url: url,
|
45
|
-
data: payload,
|
46
|
-
responseType: 'json'
|
47
|
-
});
|
48
|
-
|
49
|
-
let products = [];
|
50
|
-
let mappedResponse = await this.mapResponseToProduct(response.data.data.productById, market, locale, config)
|
51
|
-
products.push(mappedResponse)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
return {
|
56
|
-
data: {
|
57
|
-
"status": 200,
|
58
|
-
"messages": [],
|
59
|
-
data: {
|
60
|
-
count: 1,
|
61
|
-
products: products
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
},
|
70
|
-
|
71
|
-
getProductPromotions: async function (sku, productId, config, locale) {
|
72
|
-
|
73
|
-
const url = config.API_Base_URLs
|
74
|
-
const sub = config.kong_subdomains + '/catalogs/products/'
|
75
|
-
const storeId = config.store_id
|
76
|
-
const payload = {
|
77
|
-
"productId": productId,
|
78
|
-
"categoryId": ["all_products"],
|
79
|
-
"skus": [{
|
80
|
-
"skuId": sku,
|
81
|
-
"productId": productId,
|
82
|
-
"type": "DEFAULT"
|
83
|
-
}],
|
84
|
-
"isSubscriptionIncludedInPromotion": true
|
85
|
-
}
|
86
|
-
|
87
|
-
try {
|
88
|
-
const response = await axios.request({
|
89
|
-
method: 'post',
|
90
|
-
url: url + sub + productId + '/promotions?locale=' + locale + '&storeId=' + storeId,
|
91
|
-
data: payload,
|
92
|
-
responseType: 'json'
|
93
|
-
});
|
94
|
-
return response
|
95
|
-
} catch (e) {
|
96
|
-
console.log(e)
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
|
-
},
|
101
|
-
|
102
|
-
mapResponseToProduct: async function (response, market, locale, config) {
|
103
|
-
//console.log('RESPONSE ' + JSON.stringify(response))
|
104
|
-
let res;
|
105
|
-
if (response.variants && response.variants.length >= 1) {
|
106
|
-
res = await this.mapProductRegular(response, market, locale, config)
|
107
|
-
const productID = (response.id) ? response.id : response.variants[0].id
|
108
|
-
const promotions = await this.getProductPromotions(response.variants[0].sku, productID, config, locale)
|
109
|
-
console.log(promotions)
|
110
|
-
}
|
111
|
-
if (typeof response.bundle === 'object') {
|
112
|
-
res = await this.mapProductBundle(response, market.locale, config)
|
113
|
-
}
|
114
|
-
|
115
|
-
|
116
|
-
return res;
|
117
|
-
},
|
118
|
-
|
119
|
-
mapProductRegular: async function (response, market, locale) {
|
120
|
-
let res = {
|
121
|
-
"sku": response.variants[0].id,
|
122
|
-
"globalProductID": response.id,
|
123
|
-
"title": response.variants[0].title,
|
124
|
-
"country": market,
|
125
|
-
"language": locale,
|
126
|
-
"shortDescr": response.variants[0].description,
|
127
|
-
"longDescr": response.variants[0].productDetails.description,
|
128
|
-
"fullImage": response.variants[0].productImages[0].url,
|
129
|
-
"imageAltText": response.variants[0].productImages[0].alt,
|
130
|
-
|
131
|
-
"thumbnail": response.variants[0].productImages[0].thumbnail,
|
132
|
-
"ingredients": response.variants[0].ingredients,
|
133
|
-
"benefits": response.variants[0].benefits,
|
134
|
-
"usage": response.variants[0].usage,
|
135
|
-
"resources": response.variants[0].resoruces,
|
136
|
-
|
137
|
-
|
138
|
-
"availableQuantity": response.variants[0].availableQuantity,
|
139
|
-
"maxQuantity": response.variants[0].maxQuantity,
|
140
|
-
"points": "",
|
141
|
-
"cv": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0,
|
142
|
-
"pv": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0,
|
143
|
-
"priceType": "WRTL",
|
144
|
-
"price": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
|
145
|
-
"priceMap": {
|
146
|
-
"WRTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
|
147
|
-
"WADW-WRTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retailSubscription : response.variants[0].price.retail,
|
148
|
-
"WADR": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retailSubscription : response.variants[0].price.retailSubscription, //retail ADR (subscription) price
|
149
|
-
"RTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
|
150
|
-
"WWHL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.wholesale : response.variants[0].price.wholesale,
|
151
|
-
"WADW": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.wholesaleSubscription : response.variants[0].price.wholesaleSubscription,//wholesale ADR (subscription price)
|
152
|
-
"WHL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.wholesale : response.variants[0].price.wholesale
|
153
|
-
},
|
154
|
-
"cvMap": {
|
155
|
-
"WWHL": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0,
|
156
|
-
"WADW": (response.variants[0].points) ? response.variants[0].points.subscription.cv : 0,
|
157
|
-
"WHL": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0
|
158
|
-
},
|
159
|
-
"pvMap": {
|
160
|
-
"WWHL": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0,
|
161
|
-
"WADW": (response.variants[0].points) ? response.variants[0].points.subscription.pv : 0,
|
162
|
-
"WHL": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0
|
163
|
-
},
|
164
|
-
"orderTypes": this._setOrderType(response.variants[0].purchaseTypes),
|
165
|
-
"custTypes": {},
|
166
|
-
"backOrderDate": response.variants[0].status.backorderedAvailableDate,
|
167
|
-
|
168
|
-
"size": response.variants[0].size,
|
169
|
-
"status": this.switchStatusFromEquinox(response.variants[0].status.status),
|
170
|
-
"variantType": "Other",
|
171
|
-
"variantDropdownLabel": response.variantSelectLabel || '',
|
172
|
-
"variantDropdownPlaceholder": "Select Type",
|
173
|
-
"variantsLabel": response.variants[0].variantLabel || '',
|
174
|
-
"variants": this.mapProductVariants(response.variants),
|
175
|
-
"groupOffer": false,
|
176
|
-
"personalOffer": false,
|
177
|
-
"savedEventName": '',
|
178
|
-
"salesLabel": '',
|
179
|
-
"eventName": '',
|
180
|
-
"sizeWeight": '',
|
181
|
-
"nettoWeight": "",
|
182
|
-
"searchScore": 0,
|
183
|
-
"isExclusive": response.variants[0].isExclusive || false,
|
184
|
-
"equinoxProductId": response.id,
|
185
|
-
"properties": {}
|
186
|
-
}
|
187
|
-
return res;
|
188
|
-
|
189
|
-
},
|
190
|
-
mapProductVariants: function (response, globalProductID, market, locale) {
|
191
|
-
let variants = [];
|
192
|
-
variants.map((res, index) => {
|
193
|
-
if (index >= 1) {
|
194
|
-
return {
|
195
|
-
"sku": res.id,
|
196
|
-
"globalProductID": globalProductID,
|
197
|
-
"title": res.title,
|
198
|
-
"country": market,
|
199
|
-
"language": locale,
|
200
|
-
"shortDescr": res.description,
|
201
|
-
"longDescr": res.productDetails.description,
|
202
|
-
"fullImage": res.productImages[0].url,
|
203
|
-
"imageAltText": res.productImages[0].alt,
|
204
|
-
|
205
|
-
"thumbnail": res.productImages[0].thumbnail,
|
206
|
-
"ingredients": res.ingredients,
|
207
|
-
"benefits": res.benefits,
|
208
|
-
"usage": response.variants[0].usage,
|
209
|
-
"resources": res.resoruces,
|
210
|
-
|
211
|
-
|
212
|
-
"availableQuantity": res.availableQuantity,
|
213
|
-
"maxQuantity": res.maxQuantity,
|
214
|
-
"points": "",
|
215
|
-
"cv": (res.points) ? res.points.wholesale.cv : 0,
|
216
|
-
"pv": (res.points) ? res.points.wholesale.pv : 0,
|
217
|
-
"priceType": "WRTL",
|
218
|
-
"price": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
219
|
-
"priceMap": {
|
220
|
-
"WRTL": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
221
|
-
"WADW-WRTL": (res.totalPrice) ? res.totalPrice.retailSubscription : res.price.retail,
|
222
|
-
"WADR": (res.totalPrice) ? res.totalPrice.retailSubscription : res.price.retailSubscription, //retail ADR (subscription) price
|
223
|
-
"RTL": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
224
|
-
"WWHL": (res.totalPrice) ? res.totalPrice.wholesale : res.price.wholesale,
|
225
|
-
"WADW": (res.totalPrice) ? res.totalPrice.wholesaleSubscription : res.price.wholesaleSubscription,//wholesale ADR (subscription price)
|
226
|
-
"WHL": (res.totalPrice) ? res.totalPrice.wholesale : res.price.wholesale
|
227
|
-
},
|
228
|
-
"cvMap": {
|
229
|
-
"WWHL": (res.points) ? res.points.wholesale.cv : 0,
|
230
|
-
"WADW": (res.points) ? res.points.subscription.cv : 0,
|
231
|
-
"WHL": (res.points) ? res.points.wholesale.cv : 0
|
232
|
-
},
|
233
|
-
"pvMap": {
|
234
|
-
"WWHL": (res.points) ? res.points.wholesale.pv : 0,
|
235
|
-
"WADW": (res.points) ? res.points.subscription.pv : 0,
|
236
|
-
"WHL": (res.points) ? res.points.wholesale.pv : 0
|
237
|
-
},
|
238
|
-
"orderTypes": this._setOrderType(res.purchaseTypes),
|
239
|
-
"custTypes": {},
|
240
|
-
"backOrderDate": res.status.backorderedAvailableDate,
|
241
|
-
|
242
|
-
"size": res.size,
|
243
|
-
"status": this.switchStatusFromEquinox(res.status.status),
|
244
|
-
"variantType": "Other",
|
245
|
-
"variantDropdownLabel": response.variantSelectLabel || '',
|
246
|
-
"variantDropdownPlaceholder": "Select Type",
|
247
|
-
"variantsLabel": res.variantLabel || '',
|
248
|
-
"variants": [],
|
249
|
-
"groupOffer": false,
|
250
|
-
"personalOffer": false,
|
251
|
-
"savedEventName": '',
|
252
|
-
"salesLabel": '',
|
253
|
-
"eventName": '',
|
254
|
-
"sizeWeight": '',
|
255
|
-
"nettoWeight": "",
|
256
|
-
"searchScore": 0,
|
257
|
-
"isExclusive": res.isExclusive || false,
|
258
|
-
"equinoxProductId": response.id,
|
259
|
-
"properties": {}
|
260
|
-
}
|
261
|
-
}
|
262
|
-
})
|
263
|
-
|
264
|
-
|
265
|
-
return variants
|
266
|
-
},
|
267
|
-
mapProductBundle: async function (response, market, locale) {
|
268
|
-
let res;
|
269
|
-
res = this.mapProductRegular(response.bundle.kitProducts[0].product, market, locale)
|
270
|
-
return res;
|
271
|
-
},
|
272
|
-
/**
|
273
|
-
*
|
274
|
-
* Map status from equinox to legacy
|
275
|
-
*
|
276
|
-
* @param {*} status
|
277
|
-
* @returns {string} productStatus
|
278
|
-
*/
|
279
|
-
switchStatusFromEquinox: function (status) {
|
280
|
-
const { equinoxStatus } = ProductStatus;
|
281
|
-
let newStatus = '';
|
282
|
-
switch (status.toLowerCase()) {
|
283
|
-
case equinoxStatus.SELLABLE:
|
284
|
-
newStatus = ProductStatus.ReleasedForSale;
|
285
|
-
break;
|
286
|
-
case equinoxStatus.PREVIEW_PRODUCT:
|
287
|
-
newStatus = ProductStatus.NotReleasedForSale;
|
288
|
-
break;
|
289
|
-
case equinoxStatus.DISCONTINUED:
|
290
|
-
newStatus = ProductStatus.Discontinued;
|
291
|
-
break;
|
292
|
-
case equinoxStatus.STOPPED:
|
293
|
-
newStatus = ProductStatus.Discontinued;
|
294
|
-
break;
|
295
|
-
case equinoxStatus.REPLACEMENT:
|
296
|
-
newStatus = ProductStatus.NotReleasedForSale;
|
297
|
-
break;
|
298
|
-
default:
|
299
|
-
newStatus = ProductStatus.NotReleasedForSale;
|
300
|
-
break;
|
301
|
-
}
|
302
|
-
|
303
|
-
return newStatus;
|
304
|
-
},
|
305
|
-
|
306
|
-
/**
|
307
|
-
*
|
308
|
-
* @param {*} availableChannels
|
309
|
-
*
|
310
|
-
* This function is use to convert arsPhone,web,kiosk,mobile,subscription
|
311
|
-
* to orderType object
|
312
|
-
* "adr”
|
313
|
-
"order"
|
314
|
-
"zpfc"
|
315
|
-
"zadp"
|
316
|
-
"ars"
|
317
|
-
"kiosk"
|
318
|
-
"mobile"
|
319
|
-
"preferred customer"
|
320
|
-
"retail"
|
321
|
-
"web"
|
322
|
-
"web display"
|
323
|
-
*/
|
324
|
-
_setOrderType: function (purchaseTypes) {
|
325
|
-
let orderType = {
|
326
|
-
"adr": false,
|
327
|
-
"order": false,
|
328
|
-
"zpfc": false,
|
329
|
-
"zadp": false,
|
330
|
-
"ars": false,
|
331
|
-
"kiosk": false,
|
332
|
-
"mobile": false,
|
333
|
-
"preferred customer": false,
|
334
|
-
"retail": false,
|
335
|
-
"web": false,
|
336
|
-
"web display": false
|
337
|
-
};
|
338
|
-
if (purchaseTypes.buyOnce) {
|
339
|
-
orderType.web = true
|
340
|
-
orderType.order = true
|
341
|
-
}
|
342
|
-
if (purchaseTypes.subscription) {
|
343
|
-
orderType.adr = true
|
344
|
-
}
|
345
|
-
|
346
|
-
|
347
|
-
return orderType;
|
348
|
-
}
|
349
|
-
|
350
|
-
|
351
|
-
}
|
352
|
-
|
353
|
-
module.exports = ProductGraphQL
|