@nuskin/ns-product-lib 2.11.0-cx24-5092.34 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -236
- package/package.json +1 -1
- package/src/equinox-helpers/childSKU.js +4 -1
- package/src/equinox-helpers/childSKUBundles.js +6 -3
- package/src/product.js +5 -0
- package/src/productData.js +31 -14
- package/src/graphQl/query.js +0 -527
- package/src/productGraphQL.js +0 -366
package/CHANGELOG.md
CHANGED
@@ -1,248 +1,20 @@
|
|
1
|
-
# [2.
|
1
|
+
# [2.12.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0...v2.12.0) (2023-09-22)
|
2
2
|
|
3
3
|
|
4
|
-
###
|
5
|
-
|
6
|
-
* Moving from AEM to CS for EQ markets ([9f649ff](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9f649ff3b0e5f6e076d2bdbf429c24b45e685ff6))
|
7
|
-
|
8
|
-
# [2.11.0-cx24-5092.33](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.32...v2.11.0-cx24-5092.33) (2023-09-19)
|
9
|
-
|
10
|
-
|
11
|
-
### New
|
12
|
-
|
13
|
-
* Moving from AEM to CS for EQ markets ([48df449](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/48df44948eced5679da2d0d268d0c628b620b30a))
|
14
|
-
|
15
|
-
# [2.11.0-cx24-5092.32](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.31...v2.11.0-cx24-5092.32) (2023-09-19)
|
16
|
-
|
17
|
-
|
18
|
-
### New
|
19
|
-
|
20
|
-
* Moving from AEM to CS for EQ markets ([23713af](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/23713afd29ced90c1e02962592c85127f551819f))
|
21
|
-
|
22
|
-
# [2.11.0-cx24-5092.31](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.30...v2.11.0-cx24-5092.31) (2023-09-18)
|
23
|
-
|
24
|
-
|
25
|
-
### New
|
26
|
-
|
27
|
-
* Moving from AEM to CS for EQ markets ([77e895c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/77e895ca4b673f40bdb4e426dfa3323d5f341fdc))
|
28
|
-
|
29
|
-
# [2.11.0-cx24-5092.30](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.29...v2.11.0-cx24-5092.30) (2023-09-18)
|
30
|
-
|
31
|
-
|
32
|
-
### New
|
33
|
-
|
34
|
-
* Moving from AEM to CS for EQ markets ([a4a8e19](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a4a8e19032147ed5c4d37a0dc607796e3b687091))
|
35
|
-
|
36
|
-
# [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)
|
37
|
-
|
38
|
-
|
39
|
-
### New
|
40
|
-
|
41
|
-
* Moving from AEM to CS for EQ markets ([6c50857](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6c50857164b3bbe363bd75010015238dacbbf552))
|
42
|
-
|
43
|
-
# [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)
|
44
|
-
|
45
|
-
|
46
|
-
### New
|
47
|
-
|
48
|
-
* Moving from AEM to CS for EQ markets ([2374b2e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2374b2e9abaac6bb92cfcea1d5b35a40f4cf742c))
|
49
|
-
|
50
|
-
# [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)
|
51
|
-
|
52
|
-
|
53
|
-
### New
|
54
|
-
|
55
|
-
* Moving from AEM to CS for EQ markets ([33228f8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/33228f8aad2be23c989d4d96f109c155c9fe7ac3))
|
56
|
-
|
57
|
-
# [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)
|
58
|
-
|
59
|
-
|
60
|
-
### New
|
61
|
-
|
62
|
-
* Moving from AEM to CS for EQ markets ([cb2a5b3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cb2a5b3087fb6ee00e5bcd0b95ae67c16eaf7b1d))
|
63
|
-
|
64
|
-
# [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)
|
65
|
-
|
66
|
-
|
67
|
-
### New
|
68
|
-
|
69
|
-
* Moving from AEM to CS for EQ markets ([5c95f51](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5c95f51f82eefe9dd5060a544f200facab0fbc38))
|
70
|
-
|
71
|
-
# [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)
|
72
|
-
|
73
|
-
|
74
|
-
### New
|
75
|
-
|
76
|
-
* Moving from AEM to CS for EQ markets ([aa54de4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/aa54de461ca03dbf2a67161b1ce352216425b6e8))
|
77
|
-
|
78
|
-
# [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)
|
79
|
-
|
80
|
-
|
81
|
-
### New
|
82
|
-
|
83
|
-
* Moving from AEM to CS for EQ markets ([f7c76ec](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f7c76ec6445f262758600d3e99307ee7f4c85be4))
|
84
|
-
|
85
|
-
# [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)
|
86
|
-
|
87
|
-
|
88
|
-
### New
|
89
|
-
|
90
|
-
* Moving from AEM to CS for EQ markets ([85f3d2d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/85f3d2d724c80b9afefd5d4af6fc9fd4ab5abc32))
|
91
|
-
|
92
|
-
# [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)
|
93
|
-
|
94
|
-
|
95
|
-
### New
|
96
|
-
|
97
|
-
* Moving from AEM to CS for EQ markets ([ff40018](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ff400181cdb045fcb904ce0c2aa22a03f5f1ab22))
|
98
|
-
|
99
|
-
# [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)
|
100
|
-
|
101
|
-
|
102
|
-
### New
|
103
|
-
|
104
|
-
* Moving from AEM to CS for EQ markets ([a8fe3f7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a8fe3f7c832a00bb4cbf29528633ea7542f065d0))
|
105
|
-
|
106
|
-
# [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)
|
107
|
-
|
108
|
-
|
109
|
-
### New
|
110
|
-
|
111
|
-
* Moving from AEM to CS for EQ markets ([b710207](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b710207fbd8df21a9dccd1c42219655636ceced7))
|
112
|
-
|
113
|
-
# [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)
|
114
|
-
|
115
|
-
|
116
|
-
### New
|
117
|
-
|
118
|
-
* Moving from AEM to CS for EQ markets ([fbcefec](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fbcefec2c6ffee1f3b043281027f882da704502a))
|
119
|
-
* Moving from AEM to CS for EQ markets ([4f10a1a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4f10a1a88ace28ab3a8e45f8212d67534737a6a3))
|
120
|
-
|
121
|
-
# [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)
|
122
|
-
|
123
|
-
|
124
|
-
### New
|
125
|
-
|
126
|
-
* Moving from AEM to CS for EQ markets ([a55c20f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a55c20fbd26268215a6d79bc43b818704730c1b3))
|
127
|
-
* Moving from AEM to CS for EQ markets ([b58bab6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b58bab6b7ef78e0444a3f918afc844772de832f8))
|
128
|
-
|
129
|
-
# [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)
|
130
|
-
|
131
|
-
|
132
|
-
### New
|
133
|
-
|
134
|
-
* Moving from AEM to CS for EQ markets ([95c3072](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/95c30729cdbccd4a1520a276057d227d7050f02d))
|
135
|
-
* Moving from AEM to CS for EQ markets ([8dd3f14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8dd3f14feaddd492c657cee8bd630c6c7b533e83))
|
136
|
-
|
137
|
-
# [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)
|
138
|
-
|
139
|
-
|
140
|
-
### New
|
141
|
-
|
142
|
-
* Moving from AEM to CS for EQ markets ([616458b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/616458b98e5d425b456aa82042ddb7af5923ab6d))
|
143
|
-
|
144
|
-
# [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)
|
145
|
-
|
146
|
-
|
147
|
-
### New
|
148
|
-
|
149
|
-
* Moving from AEM to CS for EQ markets ([ce951e1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ce951e13a6200fa8bdd17baecbc914c51167eeb2))
|
150
|
-
|
151
|
-
# [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)
|
152
|
-
|
153
|
-
|
154
|
-
### New
|
155
|
-
|
156
|
-
* Moving from AEM to CS for EQ markets ([fbad8f9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fbad8f951e9f40427de8b8538909d5d932770b6f))
|
157
|
-
* Moving from AEM to CS for EQ markets ([952d737](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/952d737b55c705f7d88c1ad6beff87a82bc9d314))
|
158
|
-
|
159
|
-
# [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)
|
160
|
-
|
161
|
-
|
162
|
-
### New
|
163
|
-
|
164
|
-
* Moving from AEM to CS for EQ markets ([4973d82](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4973d82f1ce7bd7746f357ff357a65e880ad22d0))
|
165
|
-
* Moving from AEM to CS for EQ markets ([1a2ed1b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1a2ed1bbea62a7e3d1b076aae1d0df9f528afb72))
|
166
|
-
|
167
|
-
# [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)
|
168
|
-
|
169
|
-
|
170
|
-
### New
|
171
|
-
|
172
|
-
* Moving from AEM to CS for EQ markets ([538bdc1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/538bdc1d777091afa844985cffccbc693cd04f23))
|
173
|
-
|
174
|
-
# [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)
|
175
|
-
|
176
|
-
|
177
|
-
### New
|
178
|
-
|
179
|
-
* Moving from AEM to CS for EQ markets ([60763aa](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/60763aaaf7311cc95860f24b8e6652a0be13a622))
|
180
|
-
|
181
|
-
# [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)
|
182
|
-
|
183
|
-
|
184
|
-
### New
|
185
|
-
|
186
|
-
* Moving from AEM to CS for EQ markets ([220bf20](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/220bf20a4f6564625e1e8ecc54ffcb8061aaef08))
|
187
|
-
|
188
|
-
# [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)
|
189
|
-
|
190
|
-
|
191
|
-
### New
|
192
|
-
|
193
|
-
* Moving from AEM to CS for EQ markets ([fe4ba38](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fe4ba38001139d8070cbb8de56ce9600e0da3c1c))
|
194
|
-
|
195
|
-
# [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)
|
196
|
-
|
197
|
-
|
198
|
-
### New
|
199
|
-
|
200
|
-
* Moving from AEM to CS for EQ markets ([29c8dab](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/29c8dab12e0d29b237463b09645e6935bd030bec))
|
201
|
-
|
202
|
-
# [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)
|
203
|
-
|
204
|
-
|
205
|
-
### New
|
206
|
-
|
207
|
-
* Moving from AEM to CS for EQ markets ([268dc8f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/268dc8fcd3ed89511050923c3cc3e2650d6fbfce))
|
208
|
-
|
209
|
-
# [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)
|
210
|
-
|
211
|
-
|
212
|
-
### New
|
213
|
-
|
214
|
-
* Moving from AEM to CS for EQ markets ([c6d52c3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/c6d52c3e1f6f8d7d596d5c86095265c90624e53d))
|
215
|
-
* Moving from AEM to CS for EQ markets ([cc8b3fc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cc8b3fc5403e021589d9d42f1db71ff380f87b57))
|
216
|
-
|
217
|
-
# [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)
|
218
|
-
|
219
|
-
|
220
|
-
### New
|
221
|
-
|
222
|
-
* Moving from AEM to CS for EQ markets ([af5acd8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/af5acd8dca1c73004b6ee634faf90d6e47f974fd))
|
223
|
-
|
224
|
-
# [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)
|
225
|
-
|
226
|
-
|
227
|
-
### New
|
228
|
-
|
229
|
-
* Moving from AEM to CS for EQ markets ([1c61841](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1c6184105b06c7a04846f78d2e4d939c3ff67e93))
|
230
|
-
|
231
|
-
# [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)
|
4
|
+
### Update
|
232
5
|
|
6
|
+
* added subscription price flag to product (CX16-10044) ([341cb81](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/341cb81a15a70121f2370eb59913d0c77f0066b9))
|
233
7
|
|
234
|
-
|
8
|
+
# [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)
|
235
9
|
|
236
|
-
* Moving from AEM to CS for EQ markets ([53d373c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53d373c6a7221409e53e053febf4b7bd49f963ae))
|
237
|
-
* Moving from AEM to CS for EQ markets ([6d866bf](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6d866bfcd20ce4c2d1385abca29458ae49ab35fd))
|
238
10
|
|
239
|
-
|
11
|
+
### ix
|
240
12
|
|
13
|
+
* 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)
|
241
14
|
|
242
|
-
###
|
15
|
+
### Update
|
243
16
|
|
244
|
-
*
|
245
|
-
* Moving from AEM to CS for EQ markets ([ddfe55d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ddfe55d6a04886dc13faa65b1c75fe1cb04aecca))
|
17
|
+
* 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)
|
246
18
|
|
247
19
|
## [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)
|
248
20
|
|
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/product.js
CHANGED
@@ -69,6 +69,9 @@ const Product = function (productData) {
|
|
69
69
|
this.marketAttributes = {};
|
70
70
|
this.salesEventText = "";
|
71
71
|
|
72
|
+
// set if item is subscription priced and installments need to be restricted.
|
73
|
+
this.subPriceFlag = false;
|
74
|
+
|
72
75
|
// agelocme stuff
|
73
76
|
this.agelocme = null; // object containing agelocme information (like code, label, name)
|
74
77
|
|
@@ -552,6 +555,7 @@ const Product = function (productData) {
|
|
552
555
|
retData.inventory = this.inventory;
|
553
556
|
retData.equinoxProductId = this.equinoxProductId;
|
554
557
|
retData.properties = this.properties;
|
558
|
+
retData.subPriceFlag = !!this.subPriceFlag;
|
555
559
|
retData.equinox = {
|
556
560
|
sku: {
|
557
561
|
exists: this.equinox.sku.exists
|
@@ -618,6 +622,7 @@ const Product = function (productData) {
|
|
618
622
|
this.contentSection = data.contentSection;
|
619
623
|
this.scanQualified = data.scanQualified;
|
620
624
|
this.status = data.status ? data.status : this.status;
|
625
|
+
this.subPriceFlag = !!data.subPriceFlag;
|
621
626
|
if (data.availableQuantity) {
|
622
627
|
this.availableQuantity = data.availableQuantity;
|
623
628
|
}
|
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,366 +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
|
-
|
8
|
-
const ProductStatus = require("./models/productStatus");
|
9
|
-
const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
const ProductGraphQL = {
|
17
|
-
getProductGraphqlUrl: function () {
|
18
|
-
const env = getEnvironmentFromUrl(window.location.host);
|
19
|
-
|
20
|
-
switch (env) {
|
21
|
-
case "dev":
|
22
|
-
return "https://test.nuskin.com/product-api/graphql";
|
23
|
-
case "stage":
|
24
|
-
case "test":
|
25
|
-
return "https://test.nuskin.com/product-api/graphql";
|
26
|
-
case "unknown":
|
27
|
-
case "prod":
|
28
|
-
default:
|
29
|
-
return "https://www.nuskin.com/product-api/graphql";
|
30
|
-
}
|
31
|
-
},
|
32
|
-
getProductFromGraphQL: async function (id, market, locale, config) {
|
33
|
-
|
34
|
-
console.log(config)
|
35
|
-
const url = this.getProductGraphqlUrl();
|
36
|
-
const payload = {
|
37
|
-
query: getProductGql,
|
38
|
-
variables: { id, market, locale },
|
39
|
-
operationName: "getProduct",
|
40
|
-
useContentSource: "CS"
|
41
|
-
}
|
42
|
-
|
43
|
-
const response = await axios.request({
|
44
|
-
method: 'post',
|
45
|
-
url: url,
|
46
|
-
data: payload,
|
47
|
-
responseType: 'json'
|
48
|
-
});
|
49
|
-
|
50
|
-
let products = [];
|
51
|
-
let mappedResponse = await this.mapResponseToProduct(response.data.data.productById, market, locale, config)
|
52
|
-
products.push(new Product(mappedResponse))
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
return {
|
57
|
-
data: {
|
58
|
-
"status": 200,
|
59
|
-
"messages": [],
|
60
|
-
data: {
|
61
|
-
count: 1,
|
62
|
-
products: products
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
},
|
71
|
-
|
72
|
-
getProductPromotions: async function (sku, productId, config, locale) {
|
73
|
-
|
74
|
-
const url = config.API_Base_URLs
|
75
|
-
const sub = config.kong_subdomains + '/catalogs/products/'
|
76
|
-
const storeId = config.store_id
|
77
|
-
const payload = {
|
78
|
-
"productId": productId,
|
79
|
-
"categoryId": ["all_products"],
|
80
|
-
"skus": [{
|
81
|
-
"skuId": sku,
|
82
|
-
"productId": productId,
|
83
|
-
"type": "DEFAULT"
|
84
|
-
}],
|
85
|
-
"isSubscriptionIncludedInPromotion": true
|
86
|
-
}
|
87
|
-
|
88
|
-
try {
|
89
|
-
const response = await axios.request({
|
90
|
-
method: 'post',
|
91
|
-
url: url + sub + productId + '/promotions?locale=' + locale + '&storeId=' + storeId,
|
92
|
-
data: payload,
|
93
|
-
responseType: 'json'
|
94
|
-
});
|
95
|
-
return response
|
96
|
-
} catch (e) {
|
97
|
-
console.log(e)
|
98
|
-
}
|
99
|
-
|
100
|
-
|
101
|
-
},
|
102
|
-
|
103
|
-
mapResponseToProduct: async function (response, market, locale, config) {
|
104
|
-
//console.log('RESPONSE ' + JSON.stringify(response))
|
105
|
-
let res;
|
106
|
-
if (response.variants.length >= 1) {
|
107
|
-
res = await this.mapProductRegular(response, market, locale, config)
|
108
|
-
const productID = (response.id) ? response.id : response.variants[0].id
|
109
|
-
const promotions = await this.getProductPromotions(response.variants[0].sku, productID, config, locale)
|
110
|
-
console.log(promotions)
|
111
|
-
} else if (typeof response.bundle === 'object' && response.bundle.id) {
|
112
|
-
res = await this.mapProductBundle(response, market.locale, config)
|
113
|
-
} else {
|
114
|
-
res = {}
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
return res;
|
119
|
-
},
|
120
|
-
|
121
|
-
mapProductRegular: async function (response, market, locale) {
|
122
|
-
let res = {
|
123
|
-
"sku": response.variants[0].sku,
|
124
|
-
"globalProductID": response.id,
|
125
|
-
"title": response.variants[0].title,
|
126
|
-
"country": market,
|
127
|
-
"language": locale,
|
128
|
-
"shortDescr": response.variants[0].description,
|
129
|
-
"longDescr": response.variants[0].productDetails.description,
|
130
|
-
"fullImage": response.variants[0].productImages[0].url,
|
131
|
-
"imageAltText": response.variants[0].productImages[0].alt,
|
132
|
-
|
133
|
-
"thumbnail": response.variants[0].productImages[0].thumbnail,
|
134
|
-
"ingredients": response.variants[0].ingredients,
|
135
|
-
"benefits": response.variants[0].benefits,
|
136
|
-
"usage": response.variants[0].usage,
|
137
|
-
"resources": response.variants[0].resoruces,
|
138
|
-
|
139
|
-
|
140
|
-
"availableQuantity": response.variants[0].availableQuantity,
|
141
|
-
"maxQuantity": response.variants[0].maxQuantity,
|
142
|
-
"points": "",
|
143
|
-
"cv": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0,
|
144
|
-
"pv": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0,
|
145
|
-
"priceType": "WRTL",
|
146
|
-
"price": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
|
147
|
-
"priceMap": {
|
148
|
-
"WRTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
|
149
|
-
"WADW-WRTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retailSubscription : response.variants[0].price.retail,
|
150
|
-
"WADR": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retailSubscription : response.variants[0].price.retailSubscription, //retail ADR (subscription) price
|
151
|
-
"RTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
|
152
|
-
"WWHL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.wholesale : response.variants[0].price.wholesale,
|
153
|
-
"WADW": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.wholesaleSubscription : response.variants[0].price.wholesaleSubscription,//wholesale ADR (subscription price)
|
154
|
-
"WHL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.wholesale : response.variants[0].price.wholesale
|
155
|
-
},
|
156
|
-
"cvMap": {
|
157
|
-
"WWHL": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0,
|
158
|
-
"WADW": (response.variants[0].points) ? response.variants[0].points.subscription.cv : 0,
|
159
|
-
"WHL": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0
|
160
|
-
},
|
161
|
-
"pvMap": {
|
162
|
-
"WWHL": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0,
|
163
|
-
"WADW": (response.variants[0].points) ? response.variants[0].points.subscription.pv : 0,
|
164
|
-
"WHL": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0
|
165
|
-
},
|
166
|
-
"orderTypes": this._setOrderType(response.variants[0].purchaseTypes),
|
167
|
-
"custTypes": {},
|
168
|
-
"backOrderDate": response.variants[0].status.backorderedAvailableDate,
|
169
|
-
|
170
|
-
"size": response.variants[0].size,
|
171
|
-
"status": this.switchStatusFromEquinox(response.variants[0].status.status),
|
172
|
-
"variantType": "Other",
|
173
|
-
"variantDropdownLabel": response.variantSelectLabel || '',
|
174
|
-
"variantDropdownPlaceholder": "Select Type",
|
175
|
-
"variantsLabel": response.variants[0].variantLabel || '',
|
176
|
-
"variants": this.mapProductVariants(response.variants),
|
177
|
-
"groupOffer": false,
|
178
|
-
"personalOffer": false,
|
179
|
-
"savedEventName": '',
|
180
|
-
"salesLabel": '',
|
181
|
-
"eventName": '',
|
182
|
-
"sizeWeight": '',
|
183
|
-
"nettoWeight": "",
|
184
|
-
"searchScore": 0,
|
185
|
-
"isExclusive": response.variants[0].isExclusive || false,
|
186
|
-
"equinoxProductId": response.id,
|
187
|
-
"properties": {}
|
188
|
-
}
|
189
|
-
return res;
|
190
|
-
|
191
|
-
},
|
192
|
-
mapProductVariants: function (response, globalProductID, market, locale) {
|
193
|
-
let variants = [];
|
194
|
-
variants.map((res, index) => {
|
195
|
-
if (index >= 1) {
|
196
|
-
return {
|
197
|
-
"sku": res.id,
|
198
|
-
"globalProductID": globalProductID,
|
199
|
-
"title": res.title,
|
200
|
-
"country": market,
|
201
|
-
"language": locale,
|
202
|
-
"shortDescr": res.description,
|
203
|
-
"longDescr": res.productDetails.description,
|
204
|
-
"fullImage": res.productImages[0].url,
|
205
|
-
"imageAltText": res.productImages[0].alt,
|
206
|
-
|
207
|
-
"thumbnail": res.productImages[0].thumbnail,
|
208
|
-
"ingredients": res.ingredients,
|
209
|
-
"benefits": res.benefits,
|
210
|
-
"usage": response.variants[0].usage,
|
211
|
-
"resources": res.resoruces,
|
212
|
-
|
213
|
-
|
214
|
-
"availableQuantity": res.availableQuantity,
|
215
|
-
"maxQuantity": res.maxQuantity,
|
216
|
-
"points": "",
|
217
|
-
"cv": (res.points) ? res.points.wholesale.cv : 0,
|
218
|
-
"pv": (res.points) ? res.points.wholesale.pv : 0,
|
219
|
-
"priceType": "WRTL",
|
220
|
-
"price": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
221
|
-
"priceMap": {
|
222
|
-
"WRTL": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
223
|
-
"WADW-WRTL": (res.totalPrice) ? res.totalPrice.retailSubscription : res.price.retail,
|
224
|
-
"WADR": (res.totalPrice) ? res.totalPrice.retailSubscription : res.price.retailSubscription, //retail ADR (subscription) price
|
225
|
-
"RTL": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
226
|
-
"WWHL": (res.totalPrice) ? res.totalPrice.wholesale : res.price.wholesale,
|
227
|
-
"WADW": (res.totalPrice) ? res.totalPrice.wholesaleSubscription : res.price.wholesaleSubscription,//wholesale ADR (subscription price)
|
228
|
-
"WHL": (res.totalPrice) ? res.totalPrice.wholesale : res.price.wholesale
|
229
|
-
},
|
230
|
-
"cvMap": {
|
231
|
-
"WWHL": (res.points) ? res.points.wholesale.cv : 0,
|
232
|
-
"WADW": (res.points) ? res.points.subscription.cv : 0,
|
233
|
-
"WHL": (res.points) ? res.points.wholesale.cv : 0
|
234
|
-
},
|
235
|
-
"pvMap": {
|
236
|
-
"WWHL": (res.points) ? res.points.wholesale.pv : 0,
|
237
|
-
"WADW": (res.points) ? res.points.subscription.pv : 0,
|
238
|
-
"WHL": (res.points) ? res.points.wholesale.pv : 0
|
239
|
-
},
|
240
|
-
"orderTypes": this._setOrderType(res.purchaseTypes),
|
241
|
-
"custTypes": {},
|
242
|
-
"backOrderDate": res.status.backorderedAvailableDate,
|
243
|
-
|
244
|
-
"size": res.size,
|
245
|
-
"status": this.switchStatusFromEquinox(res.status.status),
|
246
|
-
"variantType": "Other",
|
247
|
-
"variantDropdownLabel": response.variantSelectLabel || '',
|
248
|
-
"variantDropdownPlaceholder": "Select Type",
|
249
|
-
"variantsLabel": res.variantLabel || '',
|
250
|
-
"variants": [],
|
251
|
-
"groupOffer": false,
|
252
|
-
"personalOffer": false,
|
253
|
-
"savedEventName": '',
|
254
|
-
"salesLabel": '',
|
255
|
-
"eventName": '',
|
256
|
-
"sizeWeight": '',
|
257
|
-
"nettoWeight": "",
|
258
|
-
"searchScore": 0,
|
259
|
-
"isExclusive": res.isExclusive || false,
|
260
|
-
"equinoxProductId": response.id,
|
261
|
-
"properties": {}
|
262
|
-
}
|
263
|
-
}
|
264
|
-
})
|
265
|
-
|
266
|
-
|
267
|
-
return variants
|
268
|
-
},
|
269
|
-
mapProductBundle: async function (response, market, locale) {
|
270
|
-
let res;
|
271
|
-
res = this.mapProductRegular(response.bundle.kitProducts[0].product, market, locale)
|
272
|
-
res.priceMap = {
|
273
|
-
"WRTL": (response.bundle.totalPrice) ? response.bundle.totalPrice.retail : response.bundle.price.retail,
|
274
|
-
"WADW-WRTL": (response.bundle.totalPrice) ? response.bundle.totalPrice.retailSubscription : response.bundle.price.retail,
|
275
|
-
"WADR": (response.bundle.totalPrice) ? response.bundle.totalPrice.retailSubscription : response.bundle.price.retailSubscription, //retail ADR (subscription) price
|
276
|
-
"RTL": (response.bundle.totalPrice) ? response.bundle.totalPrice.retail : response.bundle.price.retail,
|
277
|
-
"WWHL": (response.bundle.totalPrice) ? response.bundle.totalPrice.wholesale : response.bundle.price.wholesale,
|
278
|
-
"WADW": (response.bundle.totalPrice) ? response.bundle.totalPrice.wholesaleSubscription : response.bundle.price.wholesaleSubscription,//wholesale ADR (subscription price)
|
279
|
-
"WHL": (response.bundle.totalPrice) ? response.bundle.totalPrice.wholesale : response.bundle.price.wholesale
|
280
|
-
}
|
281
|
-
res.status = this.switchStatusFromEquinox(response.bundle.status.status)
|
282
|
-
|
283
|
-
return res;
|
284
|
-
},
|
285
|
-
/**
|
286
|
-
*
|
287
|
-
* Map status from equinox to legacy
|
288
|
-
*
|
289
|
-
* @param {*} status
|
290
|
-
* @returns {string} productStatus
|
291
|
-
*/
|
292
|
-
switchStatusFromEquinox: function (status) {
|
293
|
-
const { equinoxStatus } = ProductStatus;
|
294
|
-
let newStatus = '';
|
295
|
-
switch (status.toLowerCase()) {
|
296
|
-
case equinoxStatus.SELLABLE:
|
297
|
-
newStatus = ProductStatus.ReleasedForSale;
|
298
|
-
break;
|
299
|
-
case equinoxStatus.PREVIEW_PRODUCT:
|
300
|
-
newStatus = ProductStatus.NotReleasedForSale;
|
301
|
-
break;
|
302
|
-
case equinoxStatus.DISCONTINUED:
|
303
|
-
newStatus = ProductStatus.Discontinued;
|
304
|
-
break;
|
305
|
-
case equinoxStatus.STOPPED:
|
306
|
-
newStatus = ProductStatus.Discontinued;
|
307
|
-
break;
|
308
|
-
case equinoxStatus.REPLACEMENT:
|
309
|
-
newStatus = ProductStatus.NotReleasedForSale;
|
310
|
-
break;
|
311
|
-
default:
|
312
|
-
newStatus = ProductStatus.NotReleasedForSale;
|
313
|
-
break;
|
314
|
-
}
|
315
|
-
|
316
|
-
return newStatus;
|
317
|
-
},
|
318
|
-
|
319
|
-
/**
|
320
|
-
*
|
321
|
-
* @param {*} availableChannels
|
322
|
-
*
|
323
|
-
* This function is use to convert arsPhone,web,kiosk,mobile,subscription
|
324
|
-
* to orderType object
|
325
|
-
* "adr”
|
326
|
-
"order"
|
327
|
-
"zpfc"
|
328
|
-
"zadp"
|
329
|
-
"ars"
|
330
|
-
"kiosk"
|
331
|
-
"mobile"
|
332
|
-
"preferred customer"
|
333
|
-
"retail"
|
334
|
-
"web"
|
335
|
-
"web display"
|
336
|
-
*/
|
337
|
-
_setOrderType: function (purchaseTypes) {
|
338
|
-
let orderType = {
|
339
|
-
"adr": false,
|
340
|
-
"order": false,
|
341
|
-
"zpfc": false,
|
342
|
-
"zadp": false,
|
343
|
-
"ars": false,
|
344
|
-
"kiosk": false,
|
345
|
-
"mobile": false,
|
346
|
-
"preferred customer": false,
|
347
|
-
"retail": false,
|
348
|
-
"web": false,
|
349
|
-
"web display": false
|
350
|
-
};
|
351
|
-
if (purchaseTypes.buyOnce) {
|
352
|
-
orderType.web = true
|
353
|
-
orderType.order = true
|
354
|
-
}
|
355
|
-
if (purchaseTypes.subscription) {
|
356
|
-
orderType.adr = true
|
357
|
-
}
|
358
|
-
|
359
|
-
|
360
|
-
return orderType;
|
361
|
-
}
|
362
|
-
|
363
|
-
|
364
|
-
}
|
365
|
-
|
366
|
-
module.exports = ProductGraphQL
|