fast-simon-sdk 1.6.8 → 1.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.d.ts +25 -25
- package/lib/config.js +30 -30
- package/lib/index.d.ts +3 -3
- package/lib/index.js +72 -72
- package/lib/index.js.map +1 -1
- package/lib/models/autocomplete.d.ts +73 -73
- package/lib/models/autocomplete.js +2 -2
- package/lib/models/common.d.ts +267 -267
- package/lib/models/common.js +65 -65
- package/lib/models/common.js.map +1 -1
- package/lib/models/content.d.ts +37 -37
- package/lib/models/content.js +2 -2
- package/lib/models/events.d.ts +113 -113
- package/lib/models/events.js +2 -2
- package/lib/models/exports.d.ts +6 -6
- package/lib/models/exports.js +5 -5
- package/lib/models/fullTextSearch.d.ts +130 -130
- package/lib/models/fullTextSearch.js +17 -17
- package/lib/models/fullTextSearch.js.map +1 -1
- package/lib/models/lookAlikeProductRecommendation.d.ts +8 -8
- package/lib/models/lookAlikeProductRecommendation.js +2 -2
- package/lib/models/productsInventory.d.ts +10 -10
- package/lib/models/productsInventory.js +2 -2
- package/lib/models/related.d.ts +35 -35
- package/lib/models/related.js +2 -2
- package/lib/models/smartCollections.d.ts +94 -94
- package/lib/models/smartCollections.js +2 -2
- package/lib/models/visualDiscovery.d.ts +129 -129
- package/lib/models/visualDiscovery.js +30 -30
- package/lib/models/visualDiscovery.js.map +1 -1
- package/lib/sections/contentSearch/index.d.ts +7 -7
- package/lib/sections/contentSearch/index.js +44 -44
- package/lib/sections/contentSearch/index.js.map +1 -1
- package/lib/sections/enums/index.d.ts +47 -47
- package/lib/sections/enums/index.js +50 -50
- package/lib/sections/eventReporter/index.d.ts +10 -10
- package/lib/sections/eventReporter/index.js +628 -628
- package/lib/sections/eventReporter/index.js.map +1 -1
- package/lib/sections/eventReporter/utils.d.ts +9 -9
- package/lib/sections/eventReporter/utils.js +31 -31
- package/lib/sections/eventReporter/utils.js.map +1 -1
- package/lib/sections/fullTextSearch/index.d.ts +6 -6
- package/lib/sections/fullTextSearch/index.js +178 -178
- package/lib/sections/fullTextSearch/index.js.map +1 -1
- package/lib/sections/fullTextSearch/utils.d.ts +17 -17
- package/lib/sections/fullTextSearch/utils.js +185 -181
- package/lib/sections/fullTextSearch/utils.js.map +1 -1
- package/lib/sections/index.d.ts +3 -3
- package/lib/sections/index.js +432 -434
- package/lib/sections/index.js.map +1 -1
- package/lib/sections/initialization/index.d.ts +8 -8
- package/lib/sections/initialization/index.js +150 -150
- package/lib/sections/initialization/index.js.map +1 -1
- package/lib/sections/initialization/utils.d.ts +11 -11
- package/lib/sections/initialization/utils.js +200 -200
- package/lib/sections/initialization/utils.js.map +1 -1
- package/lib/sections/instantSearch/index.d.ts +6 -6
- package/lib/sections/instantSearch/index.js +66 -66
- package/lib/sections/instantSearch/index.js.map +1 -1
- package/lib/sections/instantSearch/utils.d.ts +21 -21
- package/lib/sections/instantSearch/utils.js +232 -232
- package/lib/sections/instantSearch/utils.js.map +1 -1
- package/lib/sections/landingPage/index.d.ts +6 -6
- package/lib/sections/landingPage/index.js +95 -95
- package/lib/sections/landingPage/index.js.map +1 -1
- package/lib/sections/landingPage/utils.d.ts +14 -14
- package/lib/sections/landingPage/utils.js +96 -96
- package/lib/sections/landingPage/utils.js.map +1 -1
- package/lib/sections/lookAlikeProductRecommendation/index.d.ts +6 -6
- package/lib/sections/lookAlikeProductRecommendation/index.js +23 -23
- package/lib/sections/recommendations/index.d.ts +10 -10
- package/lib/sections/recommendations/index.js +95 -95
- package/lib/sections/recommendations/index.js.map +1 -1
- package/lib/sections/recommendations/utils.d.ts +6 -6
- package/lib/sections/recommendations/utils.js +82 -82
- package/lib/sections/recommendations/utils.js.map +1 -1
- package/lib/sections/smartCollections/index.d.ts +6 -6
- package/lib/sections/smartCollections/index.js +169 -169
- package/lib/sections/smartCollections/index.js.map +1 -1
- package/lib/sections/smartCollections/utils.d.ts +41 -41
- package/lib/sections/smartCollections/utils.js +286 -281
- package/lib/sections/smartCollections/utils.js.map +1 -1
- package/lib/sections/visualDiscovery/index.d.ts +22 -22
- package/lib/sections/visualDiscovery/index.js +261 -265
- package/lib/sections/visualDiscovery/index.js.map +1 -1
- package/lib/services/autocomplete.d.ts +24 -24
- package/lib/services/autocomplete.js +50 -50
- package/lib/services/common.d.ts +35 -35
- package/lib/services/common.js +94 -94
- package/lib/services/content.d.ts +4 -4
- package/lib/services/content.js +25 -25
- package/lib/services/fullTextSearch.d.ts +4 -4
- package/lib/services/fullTextSearch.js +87 -87
- package/lib/services/fullTextSearch.js.map +1 -1
- package/lib/services/landingPage.d.ts +21 -21
- package/lib/services/landingPage.js +44 -44
- package/lib/services/lookAlikeProductRecommendation.d.ts +13 -13
- package/lib/services/lookAlikeProductRecommendation.js +23 -23
- package/lib/services/related.d.ts +48 -48
- package/lib/services/related.js +114 -114
- package/lib/services/related.js.map +1 -1
- package/lib/services/reporting.d.ts +80 -80
- package/lib/services/reporting.js +258 -258
- package/lib/services/reporting.js.map +1 -1
- package/lib/services/smartCollections.d.ts +5 -5
- package/lib/services/smartCollections.js +93 -93
- package/lib/services/smartCollections.js.map +1 -1
- package/lib/services/utils.d.ts +5 -5
- package/lib/services/utils.js +25 -25
- package/lib/services/utils.js.map +1 -1
- package/lib/services/visualDiscovery.d.ts +9 -9
- package/lib/services/visualDiscovery.js +166 -170
- package/lib/services/visualDiscovery.js.map +1 -1
- package/lib/utils/ABTesting.d.ts +2 -2
- package/lib/utils/ABTesting.js +27 -28
- package/lib/utils/ABTesting.js.map +1 -1
- package/lib/utils/API.d.ts +19 -19
- package/lib/utils/API.js +81 -81
- package/lib/utils/API.js.map +1 -1
- package/lib/utils/ArrayUtils.d.ts +2 -2
- package/lib/utils/ArrayUtils.js +16 -17
- package/lib/utils/ArrayUtils.js.map +1 -1
- package/lib/utils/bindingBoxes.d.ts +23 -23
- package/lib/utils/bindingBoxes.js +88 -89
- package/lib/utils/bindingBoxes.js.map +1 -1
- package/lib/utils/cookies.d.ts +13 -13
- package/lib/utils/cookies.js +50 -50
- package/lib/utils/debug.d.ts +4 -4
- package/lib/utils/debug.js +31 -31
- package/lib/utils/debug.js.map +1 -1
- package/lib/utils/duplicationsHandler.d.ts +19 -0
- package/lib/utils/duplicationsHandler.js +70 -0
- package/lib/utils/duplicationsHandler.js.map +1 -0
- package/lib/utils/filtersPersonalization.d.ts +3 -3
- package/lib/utils/filtersPersonalization.js +39 -39
- package/lib/utils/filtersPersonalization.js.map +1 -1
- package/lib/utils/image.d.ts +6 -6
- package/lib/utils/image.js +153 -153
- package/lib/utils/image.js.map +1 -1
- package/lib/utils/klaviyo.js +1 -1
- package/lib/utils/location.d.ts +1 -1
- package/lib/utils/location.js +11 -11
- package/lib/utils/location.js.map +1 -1
- package/lib/utils/mappingUtil.d.ts +4 -4
- package/lib/utils/mappingUtil.js +16 -16
- package/lib/utils/options.d.ts +23 -23
- package/lib/utils/options.js +16 -16
- package/lib/utils/personalization.d.ts +2 -2
- package/lib/utils/personalization.js +20 -20
- package/lib/utils/personalization.js.map +1 -1
- package/lib/utils/segments.d.ts +2 -2
- package/lib/utils/segments.js +19 -20
- package/lib/utils/segments.js.map +1 -1
- package/lib/utils/shopifyMarkets.d.ts +3 -3
- package/lib/utils/shopifyMarkets.js +12 -12
- package/lib/utils/sortUtil.d.ts +1 -1
- package/lib/utils/sortUtil.js +24 -24
- package/lib/utils/sortUtil.js.map +1 -1
- package/lib/utils/updateRecentSearches.d.ts +2 -2
- package/lib/utils/updateRecentSearches.js +56 -57
- package/lib/utils/updateRecentSearches.js.map +1 -1
- package/lib/utils/validation.d.ts +5 -5
- package/lib/utils/validation.js +46 -46
- package/lib/utils/validation.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,282 +1,287 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.hasProductFacetsCallbacks = exports.handleProductFacetsCallbacks = exports.isRecommendedProduct = exports.facetNeeded = exports.savePersonalizedProductsFromCollectionResponse = exports.updateRecentCollectionProducts = exports.getRecentCollectionProducts = exports.getCollectionName = exports.getPersonalizedProducts = exports.handleSmartCollection = exports.getData = exports.setInfiniteScroll = exports.emptyResults = void 0;
|
|
15
|
-
var ArrayUtils_1 = require("../../utils/ArrayUtils");
|
|
16
|
-
var related_1 = require("../../services/related");
|
|
17
|
-
var config_1 = require("../../config");
|
|
18
|
-
var utils_1 = require("../fullTextSearch/utils");
|
|
19
|
-
var utilities_1 = require("@fast-simon/utilities");
|
|
20
|
-
var utils_2 = require("../initialization/utils");
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
result
|
|
41
|
-
result.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
result.
|
|
100
|
-
result.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
var
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
var
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
return
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return category.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
var
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
};
|
|
237
|
-
exports.
|
|
238
|
-
var
|
|
239
|
-
(
|
|
240
|
-
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
var
|
|
249
|
-
var
|
|
250
|
-
return
|
|
251
|
-
};
|
|
252
|
-
exports.
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
//
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.hasProductFacetsCallbacks = exports.handleProductFacetsCallbacks = exports.isRecommendedProduct = exports.facetNeeded = exports.savePersonalizedProductsFromCollectionResponse = exports.updateRecentCollectionProducts = exports.getRecentCollectionProducts = exports.getCollectionName = exports.getPersonalizedProducts = exports.handleSmartCollection = exports.getData = exports.setInfiniteScroll = exports.emptyResults = void 0;
|
|
15
|
+
var ArrayUtils_1 = require("../../utils/ArrayUtils");
|
|
16
|
+
var related_1 = require("../../services/related");
|
|
17
|
+
var config_1 = require("../../config");
|
|
18
|
+
var utils_1 = require("../fullTextSearch/utils");
|
|
19
|
+
var utilities_1 = require("@fast-simon/utilities");
|
|
20
|
+
var utils_2 = require("../initialization/utils");
|
|
21
|
+
var duplicationsHandler_1 = require("../../utils/duplicationsHandler");
|
|
22
|
+
var emptyResults = function (self, categoryID) {
|
|
23
|
+
self.temp.smartCollections = {
|
|
24
|
+
ancestors: [],
|
|
25
|
+
totalResults: 0,
|
|
26
|
+
products: [],
|
|
27
|
+
categoryID: categoryID,
|
|
28
|
+
name: ""
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.emptyResults = emptyResults;
|
|
32
|
+
var setInfiniteScroll = function (self, infiniteCount, productsPerPage) {
|
|
33
|
+
if (infiniteCount && productsPerPage) {
|
|
34
|
+
self.temp.smartCollections.pageCount = Math.ceil(self.temp.smartCollections.totalResults / (productsPerPage / infiniteCount));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.setInfiniteScroll = setInfiniteScroll;
|
|
38
|
+
var getData = function (self, response) {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f;
|
|
40
|
+
var result = {};
|
|
41
|
+
result.products = response.items;
|
|
42
|
+
result.totalResults = response.total_results;
|
|
43
|
+
if (response.ancestor_categories) {
|
|
44
|
+
result.ancestors = response.ancestor_categories;
|
|
45
|
+
}
|
|
46
|
+
if (response.narrow) {
|
|
47
|
+
result.narrow = (0, utils_1.reformatNarrow)(response.narrow);
|
|
48
|
+
}
|
|
49
|
+
if (response.sort_by) {
|
|
50
|
+
result.sortBy = response.sort_by;
|
|
51
|
+
}
|
|
52
|
+
if (response.pop_products_no_results) {
|
|
53
|
+
result.isNoResults = true;
|
|
54
|
+
}
|
|
55
|
+
if (response.total_p) {
|
|
56
|
+
result.pageCount = response.total_p;
|
|
57
|
+
}
|
|
58
|
+
if (response.avoid_tag_prefixes) {
|
|
59
|
+
result.avoidPrefixList = response.avoid_tag_prefixes.split(",");
|
|
60
|
+
}
|
|
61
|
+
if (response.merch) {
|
|
62
|
+
result.merch = response.merch;
|
|
63
|
+
}
|
|
64
|
+
if (response.banner_html) {
|
|
65
|
+
result.bannerHTML = response.banner_html;
|
|
66
|
+
}
|
|
67
|
+
if (response.personalized_products) {
|
|
68
|
+
self.data.personalizedProducts = (0, exports.savePersonalizedProductsFromCollectionResponse)(response.personalized_products);
|
|
69
|
+
}
|
|
70
|
+
if (response.related_categories) {
|
|
71
|
+
result.relatedCategories = (_b = (_a = response.related_categories) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, function (category) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return ({
|
|
74
|
+
id: category === null || category === void 0 ? void 0 : category.id,
|
|
75
|
+
title: category === null || category === void 0 ? void 0 : category.l,
|
|
76
|
+
image: ((_b = (_a = category.t) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, '/missing.')) ? '' : category.t,
|
|
77
|
+
url: category === null || category === void 0 ? void 0 : category.u
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else if ((_c = self === null || self === void 0 ? void 0 : self.data) === null || _c === void 0 ? void 0 : _c.categories) {
|
|
82
|
+
try {
|
|
83
|
+
var platform = (0, utils_2.getPlatform)();
|
|
84
|
+
var localStoragePopCategories = localStorage === null || localStorage === void 0 ? void 0 : localStorage.getItem(utilities_1.FSKeys.FS_POP_CATEGORIES);
|
|
85
|
+
var relatedCategories = utilities_1.RelatedCategories === null || utilities_1.RelatedCategories === void 0 ? void 0 : utilities_1.RelatedCategories.getRelated(((_e = (_d = self === null || self === void 0 ? void 0 : self.data) === null || _d === void 0 ? void 0 : _d.categories) !== null && _e !== void 0 ? _e : (localStoragePopCategories ? JSON.parse(localStoragePopCategories) : [])), response.category_id, undefined, (platform ? platform : undefined));
|
|
86
|
+
result.relatedCategories = (_f = relatedCategories === null || relatedCategories === void 0 ? void 0 : relatedCategories.map) === null || _f === void 0 ? void 0 : _f.call(relatedCategories, function (category) {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
return ({
|
|
89
|
+
id: category.id,
|
|
90
|
+
title: category.l,
|
|
91
|
+
image: ((_b = (_a = category.t) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, '/missing.')) ? '' : category.t,
|
|
92
|
+
url: category.u
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
result.page = response.p || 1;
|
|
100
|
+
result.categoryID = response.category_id;
|
|
101
|
+
result.name = response.category_name;
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
104
|
+
exports.getData = getData;
|
|
105
|
+
var handleSmartCollection = function (_a) {
|
|
106
|
+
var _b, _c;
|
|
107
|
+
var event = _a.event, callback = _a.callback, self = _a.self, personalized = _a.personalized, time = _a.time, isNoResults = _a.isNoResults, page = _a.page, sortBy = _a.sortBy, narrow = _a.narrow, result = _a.result, inventoryCallback = _a.inventoryCallback, access_token = _a.access_token, shop_url = _a.shop_url, onProductsLoaded = _a.onProductsLoaded, onFacetsLoaded = _a.onFacetsLoaded, callbackType = _a.callbackType;
|
|
108
|
+
if (personalized && !isNoResults && page === 1 && (!narrow || narrow.length === 0) && (!sortBy || sortBy === "relevency")) {
|
|
109
|
+
handlePersonalisedProducts(self, result, callback, event, time !== null && time !== void 0 ? time : 356, onProductsLoaded, onFacetsLoaded, callbackType);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
if ((result === null || result === void 0 ? void 0 : result.products) && ((_b = result === null || result === void 0 ? void 0 : result.products) === null || _b === void 0 ? void 0 : _b.length) && ((_c = self.data) === null || _c === void 0 ? void 0 : _c.uuid) === 'a93cd17e-84be-4302-b068-8b2f37c1c415') {
|
|
113
|
+
result.products = duplicationsHandler_1.duplicationsHandler.getFilteredProducts(result);
|
|
114
|
+
}
|
|
115
|
+
if ((0, exports.hasProductFacetsCallbacks)(onProductsLoaded, onFacetsLoaded)) {
|
|
116
|
+
if (callbackType === "products" || callbackType === "facets and products") {
|
|
117
|
+
(0, exports.handleProductFacetsCallbacks)(result, "products", onProductsLoaded, onFacetsLoaded);
|
|
118
|
+
}
|
|
119
|
+
if (callbackType === "facets" || callbackType === "facets and products") {
|
|
120
|
+
(0, exports.handleProductFacetsCallbacks)(result, "facets", onProductsLoaded, onFacetsLoaded);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
callback({
|
|
125
|
+
action: event,
|
|
126
|
+
payload: result
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (access_token && inventoryCallback) {
|
|
131
|
+
(0, utilities_1.getProductsInventory)(result === null || result === void 0 ? void 0 : result.products, access_token, inventoryCallback, shop_url);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
exports.handleSmartCollection = handleSmartCollection;
|
|
135
|
+
var handlePersonalisedProducts = function (self, payload, callback, event, time, onProductsLoaded, onFacetsLoaded, callbackType) {
|
|
136
|
+
var _a;
|
|
137
|
+
var _b = self.data, storeID = _b.storeID, uuid = _b.uuid, userToken = _b.userToken;
|
|
138
|
+
var now = Math.round(Date.now() / 1000);
|
|
139
|
+
var categoryID = payload.categoryID;
|
|
140
|
+
var recent = (0, exports.getRecentCollectionProducts)().filter(function (r) { return r.time + time * 360 > now; });
|
|
141
|
+
localStorage.setItem("".concat(config_1.RECENT_COLLECTION_PRODUCTS_KEY), JSON.stringify(recent));
|
|
142
|
+
var isPersonalizedFiltersActive = ((_a = self.data.dashboard) === null || _a === void 0 ? void 0 : _a.is_personalized_filter) || false;
|
|
143
|
+
var recentProducts = recent.map(function (r) { return r.id; });
|
|
144
|
+
if (recent.length > 0) {
|
|
145
|
+
related_1.Related.getRecentlyViewed({
|
|
146
|
+
uuid: uuid,
|
|
147
|
+
storeID: storeID,
|
|
148
|
+
recent: recentProducts,
|
|
149
|
+
categoryID: categoryID,
|
|
150
|
+
cartToken: self.data.cartToken,
|
|
151
|
+
isPersonalizedFiltersActive: isPersonalizedFiltersActive,
|
|
152
|
+
userToken: userToken
|
|
153
|
+
}).then(function (response) {
|
|
154
|
+
var result = __assign(__assign({}, payload), { products: (0, exports.getPersonalizedProducts)(self, response.widget_responses[0].products, payload.products) });
|
|
155
|
+
if ((0, exports.hasProductFacetsCallbacks)(onProductsLoaded, onFacetsLoaded)) {
|
|
156
|
+
if (callbackType === "products" || callbackType === "facets and products") {
|
|
157
|
+
(0, exports.handleProductFacetsCallbacks)(result, "products", onProductsLoaded, onFacetsLoaded);
|
|
158
|
+
}
|
|
159
|
+
if (callbackType === "facets" || callbackType === "facets and products") {
|
|
160
|
+
(0, exports.handleProductFacetsCallbacks)(result, "facets", onProductsLoaded, onFacetsLoaded);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
callback({
|
|
165
|
+
action: event,
|
|
166
|
+
payload: result
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
if ((0, exports.hasProductFacetsCallbacks)(onProductsLoaded, onFacetsLoaded)) {
|
|
173
|
+
if (callbackType === "products" || callbackType === "facets and products") {
|
|
174
|
+
(0, exports.handleProductFacetsCallbacks)(payload, "products", onProductsLoaded, onFacetsLoaded);
|
|
175
|
+
}
|
|
176
|
+
if (callbackType === "facets" || callbackType === "facets and products") {
|
|
177
|
+
(0, exports.handleProductFacetsCallbacks)(payload, "facets", onProductsLoaded, onFacetsLoaded);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
callback({
|
|
182
|
+
action: event,
|
|
183
|
+
payload: payload
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var getPersonalizedProducts = function (self, recent, products) {
|
|
189
|
+
var recentProducts = recent.filter(function (r, i) {
|
|
190
|
+
var newPosition = i * 2;
|
|
191
|
+
var oldPosition = products.findIndex(function (p) { return p.id === r.id; });
|
|
192
|
+
return oldPosition === -1 || (newPosition < oldPosition);
|
|
193
|
+
});
|
|
194
|
+
var ids = new Set(recentProducts.map(function (p) { return p.id; }));
|
|
195
|
+
var newProducts = products.filter(function (p) { return !ids.has(p.id); });
|
|
196
|
+
for (var i = 0, pos = 1; i < recentProducts.length; i++, pos += 2) {
|
|
197
|
+
(0, ArrayUtils_1.insert)(newProducts, pos, __assign({ rec: true }, recentProducts[i]));
|
|
198
|
+
}
|
|
199
|
+
return newProducts;
|
|
200
|
+
};
|
|
201
|
+
exports.getPersonalizedProducts = getPersonalizedProducts;
|
|
202
|
+
var getCollectionName = function (self, id) {
|
|
203
|
+
id = String(id);
|
|
204
|
+
var category = self.data.categories.find(function (category) { return category.id === id; });
|
|
205
|
+
if (!category) {
|
|
206
|
+
console.warn("can't find the collection / category name for id: ".concat(id));
|
|
207
|
+
return id;
|
|
208
|
+
}
|
|
209
|
+
return category.l;
|
|
210
|
+
};
|
|
211
|
+
exports.getCollectionName = getCollectionName;
|
|
212
|
+
var getRecentCollectionProducts = function () {
|
|
213
|
+
if (config_1.RECENT_COLLECTION_PRODUCTS_KEY in localStorage) {
|
|
214
|
+
return JSON.parse(localStorage.getItem(config_1.RECENT_COLLECTION_PRODUCTS_KEY));
|
|
215
|
+
}
|
|
216
|
+
return [];
|
|
217
|
+
};
|
|
218
|
+
exports.getRecentCollectionProducts = getRecentCollectionProducts;
|
|
219
|
+
var updateRecentCollectionProducts = function (productID, categoryID) {
|
|
220
|
+
var categories = (0, exports.getRecentCollectionProducts)();
|
|
221
|
+
var now = Math.round(Date.now() / 1000);
|
|
222
|
+
var index = categories.findIndex(function (c) { return c.id === productID; });
|
|
223
|
+
if (index !== -1) {
|
|
224
|
+
moveAndUpdate(categories, index);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
categories.push({
|
|
228
|
+
id: productID,
|
|
229
|
+
time: now
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
// Filter out products older than RECENT_PRODUCTS_EXPIRY_DAYS
|
|
233
|
+
var updatedCategoriesProducts = categories.filter(function (c) { return (now - c.time <= (config_1.RECENT_PRODUCTS_EXPIRY_DAYS * 24 * 60 * 60)); });
|
|
234
|
+
var sortedCategoriesProducts = updatedCategoriesProducts.sort(function (a, b) { return b.time - a.time; });
|
|
235
|
+
localStorage.setItem(config_1.RECENT_COLLECTION_PRODUCTS_KEY, JSON.stringify(sortedCategoriesProducts.splice(0, config_1.MAX_RECENT_COLLECTION_PRODUCTS)));
|
|
236
|
+
};
|
|
237
|
+
exports.updateRecentCollectionProducts = updateRecentCollectionProducts;
|
|
238
|
+
var savePersonalizedProductsFromCollectionResponse = function (data) {
|
|
239
|
+
localStorage.setItem(config_1.RECENT_RESPONSE_COLLECTION_PRODUCTS_KEY, JSON.stringify(data.map(function (id) { return String(id); })));
|
|
240
|
+
return data === null || data === void 0 ? void 0 : data.join(',');
|
|
241
|
+
};
|
|
242
|
+
exports.savePersonalizedProductsFromCollectionResponse = savePersonalizedProductsFromCollectionResponse;
|
|
243
|
+
var moveAndUpdate = function (categories, index) {
|
|
244
|
+
(0, ArrayUtils_1.arrayMove)(categories, index, categories.length - 1);
|
|
245
|
+
categories[categories.length - 1].time = Date.now();
|
|
246
|
+
};
|
|
247
|
+
var facetNeeded = function (_a) {
|
|
248
|
+
var self = _a.self, newNarrow = _a.newNarrow, newPage = _a.newPage, newCategoryID = _a.newCategoryID;
|
|
249
|
+
var _b = self.temp.smartCollections, narrow = _b.narrow, page = _b.page, categoryID = _b.categoryID;
|
|
250
|
+
return !(JSON.stringify(narrow) === JSON.stringify(newNarrow) && newPage === page && categoryID === newCategoryID);
|
|
251
|
+
};
|
|
252
|
+
exports.facetNeeded = facetNeeded;
|
|
253
|
+
var isRecommendedProduct = function (productId) {
|
|
254
|
+
var recent = (0, exports.getRecentCollectionProducts)();
|
|
255
|
+
return Boolean(recent.find(function (r) { return r.id === productId; }));
|
|
256
|
+
};
|
|
257
|
+
exports.isRecommendedProduct = isRecommendedProduct;
|
|
258
|
+
var handleProductFacetsCallbacks = function (result, action, onProductsLoaded, onFacetsLoaded) {
|
|
259
|
+
if (action === "products") {
|
|
260
|
+
// Create a shallow copy of the result object to safely remove facets
|
|
261
|
+
var resultWithoutFacets = __assign({}, result);
|
|
262
|
+
// If the facets field exists on the result copy, remove it
|
|
263
|
+
if (resultWithoutFacets === null || resultWithoutFacets === void 0 ? void 0 : resultWithoutFacets.facets) {
|
|
264
|
+
delete resultWithoutFacets.facets;
|
|
265
|
+
}
|
|
266
|
+
// Call the onProductsLoaded function with the result copy that has facets removed
|
|
267
|
+
onProductsLoaded ? onProductsLoaded(resultWithoutFacets) : null;
|
|
268
|
+
}
|
|
269
|
+
if (action === "facets") {
|
|
270
|
+
// Create another shallow copy of the result object to safely remove products
|
|
271
|
+
var resultWithoutProducts = __assign({}, result);
|
|
272
|
+
// If the products field exists on the result copy, remove it
|
|
273
|
+
if (resultWithoutProducts === null || resultWithoutProducts === void 0 ? void 0 : resultWithoutProducts.products) {
|
|
274
|
+
delete resultWithoutProducts.products;
|
|
275
|
+
}
|
|
276
|
+
// Call the onFacetsLoaded function with the result copy that has products removed
|
|
277
|
+
onFacetsLoaded ? onFacetsLoaded(resultWithoutProducts) : null;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
exports.handleProductFacetsCallbacks = handleProductFacetsCallbacks;
|
|
281
|
+
// Dummy implementation of hasProductFacetsCallbacks
|
|
282
|
+
var hasProductFacetsCallbacks = function (onProductsLoaded, onFacetsLoaded) {
|
|
283
|
+
// Logic to check if props contain product facets callbacks
|
|
284
|
+
return !!onProductsLoaded && !!onFacetsLoaded;
|
|
285
|
+
};
|
|
286
|
+
exports.hasProductFacetsCallbacks = hasProductFacetsCallbacks;
|
|
282
287
|
//# sourceMappingURL=utils.js.map
|