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
package/lib/sections/index.js
CHANGED
|
@@ -1,435 +1,433 @@
|
|
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
-
var t = {};
|
|
51
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
-
t[p] = s[p];
|
|
53
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
-
t[p[i]] = s[p[i]];
|
|
57
|
-
}
|
|
58
|
-
return t;
|
|
59
|
-
};
|
|
60
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
exports.FastSDK = exports.sdkUtils = void 0;
|
|
62
|
-
var initialization_1 = require("./initialization");
|
|
63
|
-
var instantSearch_1 = require("./instantSearch");
|
|
64
|
-
var common_1 = require("../models/common");
|
|
65
|
-
var fullTextSearch_1 = require("./fullTextSearch");
|
|
66
|
-
var smartCollections_1 = require("./smartCollections");
|
|
67
|
-
var lookAlikeProductRecommendation_1 = require("./lookAlikeProductRecommendation");
|
|
68
|
-
var eventReporter_1 = require("./eventReporter");
|
|
69
|
-
var recommendations_1 = require("./recommendations");
|
|
70
|
-
var validation_1 = require("../utils/validation");
|
|
71
|
-
var utils_1 = require("./initialization/utils");
|
|
72
|
-
var contentSearch_1 = require("./contentSearch");
|
|
73
|
-
var common_2 = require("../services/common");
|
|
74
|
-
var related_1 = require("../services/related");
|
|
75
|
-
var landingPage_1 = require("./landingPage");
|
|
76
|
-
var config_1 = require("../config");
|
|
77
|
-
var visualDiscovery_1 = require("./visualDiscovery");
|
|
78
|
-
exports.sdkUtils = {
|
|
79
|
-
status: "loading",
|
|
80
|
-
type: "MPA",
|
|
81
|
-
temp: common_1.defaultSDKTemp,
|
|
82
|
-
data: common_1.defaultSDKData,
|
|
83
|
-
fsGridCurrentResponse: {}
|
|
84
|
-
};
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
exports.FastSDK = {
|
|
87
|
-
initialization: function (_a) {
|
|
88
|
-
var props = __rest(_a, []);
|
|
89
|
-
if (!(0, validation_1.validateParams)(["uuid", "storeID", "type"], props) || !(0, validation_1.validateUUID)(props.uuid)) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
(0, initialization_1.initialization)(__assign({ self: exports.sdkUtils }, props));
|
|
93
|
-
},
|
|
94
|
-
instantSearch: function (_a) {
|
|
95
|
-
var props = __rest(_a, []);
|
|
96
|
-
if (!(0, validation_1.validateParams)(["query", "callback"], props)) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
var func = function () {
|
|
103
|
-
(0, instantSearch_1.InstantSearch)(__assign({ self: exports.sdkUtils }, props));
|
|
104
|
-
};
|
|
105
|
-
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
106
|
-
func();
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
fullTextSearch: function (_a) {
|
|
110
|
-
var props = __rest(_a, []);
|
|
111
|
-
if (!(0, validation_1.validateParams)(["term"], props)) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (!(0, validation_1.validateCallbackParams)(props)) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
var func = function () {
|
|
121
|
-
(0, fullTextSearch_1.fullTextSearch)(__assign({ self: exports.sdkUtils }, props));
|
|
122
|
-
};
|
|
123
|
-
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
124
|
-
func();
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
landingPage: function (_a) {
|
|
128
|
-
var props = __rest(_a, []);
|
|
129
|
-
if (!(0, validation_1.validateParams)(["slug", "callback"], props)) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
var func = function () {
|
|
136
|
-
(0, landingPage_1.landingPage)(__assign({ self: exports.sdkUtils }, props));
|
|
137
|
-
};
|
|
138
|
-
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
139
|
-
func();
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
smartCollections: function (_a) {
|
|
143
|
-
var props = __rest(_a, []);
|
|
144
|
-
if (!(0, validation_1.validateParams)(["categoryID"], props)) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (!(0, validation_1.validateCallbackParams)(props)) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
var func = function () {
|
|
154
|
-
(0, smartCollections_1.smartCollections)(__assign({ self: exports.sdkUtils }, props));
|
|
155
|
-
};
|
|
156
|
-
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
157
|
-
func();
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
lookAlikeProductRecommendation: function (_a) {
|
|
161
|
-
var props = __rest(_a, []);
|
|
162
|
-
if (!(0, validation_1.validateParams)(["viewedProductId", "callback"], props)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
var func = function () {
|
|
169
|
-
(0, lookAlikeProductRecommendation_1.lookAlikeProductRecommendation)(__assign({ self: exports.sdkUtils }, props));
|
|
170
|
-
};
|
|
171
|
-
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
172
|
-
func();
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
productRecommendation: function (_a) {
|
|
176
|
-
var props = __rest(_a, []);
|
|
177
|
-
if (!(0, validation_1.validateParams)(["productID", "specs", "callback"], props)) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
var func = function () {
|
|
184
|
-
(0, recommendations_1.recommendations)(__assign({ self: exports.sdkUtils }, props));
|
|
185
|
-
};
|
|
186
|
-
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
187
|
-
func();
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
contentSearch: function (_a) {
|
|
191
|
-
var props = __rest(_a, []);
|
|
192
|
-
if (!(0, validation_1.validateParams)(["query", "callback"], props)) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
if (!exports.sdkUtils.data.dashboard.is_content) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
var func = function () {
|
|
202
|
-
(0, contentSearch_1.contentSearch)(__assign({ self: exports.sdkUtils }, props));
|
|
203
|
-
};
|
|
204
|
-
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
205
|
-
func();
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
event: function (_a) {
|
|
209
|
-
var report = __rest(_a, []);
|
|
210
|
-
if (!(0, validation_1.validateParams)(["eventName", "data"], report)) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
if (report.eventName === "productDirect" && config_1.POST_LOAD_EVENT_KEY in localStorage) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
(0, eventReporter_1.event)({
|
|
220
|
-
self: exports.sdkUtils,
|
|
221
|
-
report: report
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
getAllCategories: function (callback) { return __awaiter(void 0, void 0, void 0, function () {
|
|
225
|
-
var categories;
|
|
226
|
-
return __generator(this, function (_a) {
|
|
227
|
-
switch (_a.label) {
|
|
228
|
-
case 0:
|
|
229
|
-
if (exports.sdkUtils.status !== "ready") {
|
|
230
|
-
console.warn("SDK wasn't initialized!!!");
|
|
231
|
-
if (callback)
|
|
232
|
-
callback(null);
|
|
233
|
-
return [2 /*return*/, new Promise(function (resolve) { return (resolve(null)); })];
|
|
234
|
-
}
|
|
235
|
-
if (exports.sdkUtils.data.categories.length > 0) {
|
|
236
|
-
if (callback)
|
|
237
|
-
callback(exports.sdkUtils.data.categories);
|
|
238
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
239
|
-
resolve(exports.sdkUtils.data.categories);
|
|
240
|
-
})];
|
|
241
|
-
}
|
|
242
|
-
return [4 /*yield*/, common_2.Common.getCategories({
|
|
243
|
-
cdn: exports.sdkUtils.data.cdnKey,
|
|
244
|
-
uuid: exports.sdkUtils.data.uuid,
|
|
245
|
-
storeID: exports.sdkUtils.data.storeID
|
|
246
|
-
})];
|
|
247
|
-
case 1:
|
|
248
|
-
categories = _a.sent();
|
|
249
|
-
if (callback)
|
|
250
|
-
callback(categories);
|
|
251
|
-
return [2 /*return*/, categories];
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}); },
|
|
255
|
-
getAllPopularProducts: function (callback, withAttributes) { return __awaiter(void 0, void 0, void 0, function () {
|
|
256
|
-
var hasShopifyMarkets, companyLocationContext, popularProducts;
|
|
257
|
-
var _a, _b, _c, _d;
|
|
258
|
-
return __generator(this, function (_e) {
|
|
259
|
-
switch (_e.label) {
|
|
260
|
-
case 0:
|
|
261
|
-
if (exports.sdkUtils.status !== "ready") {
|
|
262
|
-
console.warn("SDK wasn't initialized!!!");
|
|
263
|
-
if (callback)
|
|
264
|
-
callback(null);
|
|
265
|
-
return [2 /*return*/, new Promise(function (resolve) { return (resolve(null)); })];
|
|
266
|
-
}
|
|
267
|
-
if (exports.sdkUtils.data.popularProducts.length > 0) {
|
|
268
|
-
if ((withAttributes && ((_b = (_a = exports.sdkUtils.data.popularProducts) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.att)) || !withAttributes) {
|
|
269
|
-
if (callback)
|
|
270
|
-
callback(exports.sdkUtils.data.popularProducts);
|
|
271
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
272
|
-
resolve(exports.sdkUtils.data.popularProducts);
|
|
273
|
-
})];
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
hasShopifyMarkets = ((_c = exports.sdkUtils.data.dashboard) === null || _c === void 0 ? void 0 : _c.has_shopify_markets) || false;
|
|
277
|
-
companyLocationContext = (hasShopifyMarkets && (window === null || window === void 0 ? void 0 : window.__FAST_CUSTOMER_DETAILS)) ? (_d = window.__FAST_CUSTOMER_DETAILS) === null || _d === void 0 ? void 0 : _d.customer_current_location : undefined;
|
|
278
|
-
return [4 /*yield*/, common_2.Common.getPopularProducts({
|
|
279
|
-
cdn: exports.sdkUtils.data.cdnKey,
|
|
280
|
-
uuid: exports.sdkUtils.data.uuid,
|
|
281
|
-
storeID: exports.sdkUtils.data.storeID,
|
|
282
|
-
withAttributes: withAttributes,
|
|
283
|
-
hasShopifyMarkets: hasShopifyMarkets,
|
|
284
|
-
companyLocationContext: companyLocationContext
|
|
285
|
-
})];
|
|
286
|
-
case 1:
|
|
287
|
-
popularProducts = _e.sent();
|
|
288
|
-
if (callback)
|
|
289
|
-
callback(popularProducts.products);
|
|
290
|
-
return [2 /*return*/, popularProducts.products];
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
}); },
|
|
294
|
-
getProducts: function (_a) {
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
};
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.FastSDK = exports.sdkUtils = void 0;
|
|
62
|
+
var initialization_1 = require("./initialization");
|
|
63
|
+
var instantSearch_1 = require("./instantSearch");
|
|
64
|
+
var common_1 = require("../models/common");
|
|
65
|
+
var fullTextSearch_1 = require("./fullTextSearch");
|
|
66
|
+
var smartCollections_1 = require("./smartCollections");
|
|
67
|
+
var lookAlikeProductRecommendation_1 = require("./lookAlikeProductRecommendation");
|
|
68
|
+
var eventReporter_1 = require("./eventReporter");
|
|
69
|
+
var recommendations_1 = require("./recommendations");
|
|
70
|
+
var validation_1 = require("../utils/validation");
|
|
71
|
+
var utils_1 = require("./initialization/utils");
|
|
72
|
+
var contentSearch_1 = require("./contentSearch");
|
|
73
|
+
var common_2 = require("../services/common");
|
|
74
|
+
var related_1 = require("../services/related");
|
|
75
|
+
var landingPage_1 = require("./landingPage");
|
|
76
|
+
var config_1 = require("../config");
|
|
77
|
+
var visualDiscovery_1 = require("./visualDiscovery");
|
|
78
|
+
exports.sdkUtils = {
|
|
79
|
+
status: "loading",
|
|
80
|
+
type: "MPA",
|
|
81
|
+
temp: common_1.defaultSDKTemp,
|
|
82
|
+
data: common_1.defaultSDKData,
|
|
83
|
+
fsGridCurrentResponse: {}
|
|
84
|
+
};
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
exports.FastSDK = {
|
|
87
|
+
initialization: function (_a) {
|
|
88
|
+
var props = __rest(_a, []);
|
|
89
|
+
if (!(0, validation_1.validateParams)(["uuid", "storeID", "type"], props) || !(0, validation_1.validateUUID)(props.uuid)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
(0, initialization_1.initialization)(__assign({ self: exports.sdkUtils }, props));
|
|
93
|
+
},
|
|
94
|
+
instantSearch: function (_a) {
|
|
95
|
+
var props = __rest(_a, []);
|
|
96
|
+
if (!(0, validation_1.validateParams)(["query", "callback"], props)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
var func = function () {
|
|
103
|
+
(0, instantSearch_1.InstantSearch)(__assign({ self: exports.sdkUtils }, props));
|
|
104
|
+
};
|
|
105
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
106
|
+
func();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
fullTextSearch: function (_a) {
|
|
110
|
+
var props = __rest(_a, []);
|
|
111
|
+
if (!(0, validation_1.validateParams)(["term"], props)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!(0, validation_1.validateCallbackParams)(props)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
var func = function () {
|
|
121
|
+
(0, fullTextSearch_1.fullTextSearch)(__assign({ self: exports.sdkUtils }, props));
|
|
122
|
+
};
|
|
123
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
124
|
+
func();
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
landingPage: function (_a) {
|
|
128
|
+
var props = __rest(_a, []);
|
|
129
|
+
if (!(0, validation_1.validateParams)(["slug", "callback"], props)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var func = function () {
|
|
136
|
+
(0, landingPage_1.landingPage)(__assign({ self: exports.sdkUtils }, props));
|
|
137
|
+
};
|
|
138
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
139
|
+
func();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
smartCollections: function (_a) {
|
|
143
|
+
var props = __rest(_a, []);
|
|
144
|
+
if (!(0, validation_1.validateParams)(["categoryID"], props)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!(0, validation_1.validateCallbackParams)(props)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
var func = function () {
|
|
154
|
+
(0, smartCollections_1.smartCollections)(__assign({ self: exports.sdkUtils }, props));
|
|
155
|
+
};
|
|
156
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
157
|
+
func();
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
lookAlikeProductRecommendation: function (_a) {
|
|
161
|
+
var props = __rest(_a, []);
|
|
162
|
+
if (!(0, validation_1.validateParams)(["viewedProductId", "callback"], props)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
var func = function () {
|
|
169
|
+
(0, lookAlikeProductRecommendation_1.lookAlikeProductRecommendation)(__assign({ self: exports.sdkUtils }, props));
|
|
170
|
+
};
|
|
171
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
172
|
+
func();
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
productRecommendation: function (_a) {
|
|
176
|
+
var props = __rest(_a, []);
|
|
177
|
+
if (!(0, validation_1.validateParams)(["productID", "specs", "callback"], props)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
var func = function () {
|
|
184
|
+
(0, recommendations_1.recommendations)(__assign({ self: exports.sdkUtils }, props));
|
|
185
|
+
};
|
|
186
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
187
|
+
func();
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
contentSearch: function (_a) {
|
|
191
|
+
var props = __rest(_a, []);
|
|
192
|
+
if (!(0, validation_1.validateParams)(["query", "callback"], props)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (!exports.sdkUtils.data.dashboard.is_content) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
var func = function () {
|
|
202
|
+
(0, contentSearch_1.contentSearch)(__assign({ self: exports.sdkUtils }, props));
|
|
203
|
+
};
|
|
204
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
205
|
+
func();
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
event: function (_a) {
|
|
209
|
+
var report = __rest(_a, []);
|
|
210
|
+
if (!(0, validation_1.validateParams)(["eventName", "data"], report)) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (report.eventName === "productDirect" && config_1.POST_LOAD_EVENT_KEY in localStorage) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
(0, eventReporter_1.event)({
|
|
220
|
+
self: exports.sdkUtils,
|
|
221
|
+
report: report
|
|
222
|
+
});
|
|
223
|
+
},
|
|
224
|
+
getAllCategories: function (callback) { return __awaiter(void 0, void 0, void 0, function () {
|
|
225
|
+
var categories;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0:
|
|
229
|
+
if (exports.sdkUtils.status !== "ready") {
|
|
230
|
+
console.warn("SDK wasn't initialized!!!");
|
|
231
|
+
if (callback)
|
|
232
|
+
callback(null);
|
|
233
|
+
return [2 /*return*/, new Promise(function (resolve) { return (resolve(null)); })];
|
|
234
|
+
}
|
|
235
|
+
if (exports.sdkUtils.data.categories.length > 0) {
|
|
236
|
+
if (callback)
|
|
237
|
+
callback(exports.sdkUtils.data.categories);
|
|
238
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
239
|
+
resolve(exports.sdkUtils.data.categories);
|
|
240
|
+
})];
|
|
241
|
+
}
|
|
242
|
+
return [4 /*yield*/, common_2.Common.getCategories({
|
|
243
|
+
cdn: exports.sdkUtils.data.cdnKey,
|
|
244
|
+
uuid: exports.sdkUtils.data.uuid,
|
|
245
|
+
storeID: exports.sdkUtils.data.storeID
|
|
246
|
+
})];
|
|
247
|
+
case 1:
|
|
248
|
+
categories = _a.sent();
|
|
249
|
+
if (callback)
|
|
250
|
+
callback(categories);
|
|
251
|
+
return [2 /*return*/, categories];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}); },
|
|
255
|
+
getAllPopularProducts: function (callback, withAttributes) { return __awaiter(void 0, void 0, void 0, function () {
|
|
256
|
+
var hasShopifyMarkets, companyLocationContext, popularProducts;
|
|
257
|
+
var _a, _b, _c, _d;
|
|
258
|
+
return __generator(this, function (_e) {
|
|
259
|
+
switch (_e.label) {
|
|
260
|
+
case 0:
|
|
261
|
+
if (exports.sdkUtils.status !== "ready") {
|
|
262
|
+
console.warn("SDK wasn't initialized!!!");
|
|
263
|
+
if (callback)
|
|
264
|
+
callback(null);
|
|
265
|
+
return [2 /*return*/, new Promise(function (resolve) { return (resolve(null)); })];
|
|
266
|
+
}
|
|
267
|
+
if (exports.sdkUtils.data.popularProducts.length > 0) {
|
|
268
|
+
if ((withAttributes && ((_b = (_a = exports.sdkUtils.data.popularProducts) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.att)) || !withAttributes) {
|
|
269
|
+
if (callback)
|
|
270
|
+
callback(exports.sdkUtils.data.popularProducts);
|
|
271
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
272
|
+
resolve(exports.sdkUtils.data.popularProducts);
|
|
273
|
+
})];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
hasShopifyMarkets = ((_c = exports.sdkUtils.data.dashboard) === null || _c === void 0 ? void 0 : _c.has_shopify_markets) || false;
|
|
277
|
+
companyLocationContext = (hasShopifyMarkets && (window === null || window === void 0 ? void 0 : window.__FAST_CUSTOMER_DETAILS)) ? (_d = window.__FAST_CUSTOMER_DETAILS) === null || _d === void 0 ? void 0 : _d.customer_current_location : undefined;
|
|
278
|
+
return [4 /*yield*/, common_2.Common.getPopularProducts({
|
|
279
|
+
cdn: exports.sdkUtils.data.cdnKey,
|
|
280
|
+
uuid: exports.sdkUtils.data.uuid,
|
|
281
|
+
storeID: exports.sdkUtils.data.storeID,
|
|
282
|
+
withAttributes: withAttributes,
|
|
283
|
+
hasShopifyMarkets: hasShopifyMarkets,
|
|
284
|
+
companyLocationContext: companyLocationContext
|
|
285
|
+
})];
|
|
286
|
+
case 1:
|
|
287
|
+
popularProducts = _e.sent();
|
|
288
|
+
if (callback)
|
|
289
|
+
callback(popularProducts.products);
|
|
290
|
+
return [2 /*return*/, popularProducts.products];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}); },
|
|
294
|
+
getProducts: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
295
|
+
var response;
|
|
296
|
+
var _c, _d, _e;
|
|
297
|
+
var productIds = _b.productIds, callback = _b.callback;
|
|
298
|
+
return __generator(this, function (_f) {
|
|
299
|
+
switch (_f.label) {
|
|
300
|
+
case 0:
|
|
301
|
+
if (productIds.length === 0) {
|
|
302
|
+
if (callback)
|
|
303
|
+
callback([]);
|
|
304
|
+
return [2 /*return*/, new Promise(function (resolve) { return resolve([]); })];
|
|
305
|
+
}
|
|
306
|
+
return [4 /*yield*/, related_1.Related.getRecentlyViewed({
|
|
307
|
+
uuid: exports.sdkUtils.data.uuid,
|
|
308
|
+
storeID: exports.sdkUtils.data.storeID,
|
|
309
|
+
categoryID: "",
|
|
310
|
+
cartToken: exports.sdkUtils.data.cartToken,
|
|
311
|
+
recent: productIds,
|
|
312
|
+
isPersonalizedFiltersActive: ((_d = (_c = exports.sdkUtils.data) === null || _c === void 0 ? void 0 : _c.dashboard) === null || _d === void 0 ? void 0 : _d.is_personalized_filter) || false,
|
|
313
|
+
userToken: (_e = exports.sdkUtils === null || exports.sdkUtils === void 0 ? void 0 : exports.sdkUtils.data) === null || _e === void 0 ? void 0 : _e.userToken
|
|
314
|
+
})];
|
|
315
|
+
case 1:
|
|
316
|
+
response = _f.sent();
|
|
317
|
+
if (callback) {
|
|
318
|
+
callback(response.widget_responses[0].products);
|
|
319
|
+
}
|
|
320
|
+
return [2 /*return*/, response.widget_responses[0].products];
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}); },
|
|
324
|
+
getSetup: function (props) {
|
|
325
|
+
var keys = props.keys, callback = props.callback;
|
|
326
|
+
if (!(0, validation_1.validateParams)(["keys", "callback"], props)) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
var func = function () {
|
|
330
|
+
var response = {};
|
|
331
|
+
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
332
|
+
var key = keys_1[_i];
|
|
333
|
+
// @ts-ignore
|
|
334
|
+
response[key] = exports.sdkUtils.data.dashboard[key];
|
|
335
|
+
}
|
|
336
|
+
callback(response);
|
|
337
|
+
};
|
|
338
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
339
|
+
func();
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
productRecommendationByWidget: function (_a) {
|
|
343
|
+
var props = __rest(_a, []);
|
|
344
|
+
if (!(0, validation_1.validateParams)(["widgetsIDS", "callback"], props)) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
var func = function () {
|
|
351
|
+
(0, recommendations_1.recommendationsByWidget)(__assign({ self: exports.sdkUtils }, props));
|
|
352
|
+
};
|
|
353
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
354
|
+
func();
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
productsByDiscovery: function (_a) {
|
|
358
|
+
var props = __rest(_a, []);
|
|
359
|
+
if (!(0, validation_1.validateParams)(["imageID", "mode", "callback"], props)) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
var func = function () {
|
|
366
|
+
(0, visualDiscovery_1.productsByDiscovery)(__assign({ self: exports.sdkUtils }, props));
|
|
367
|
+
};
|
|
368
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
369
|
+
func();
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
discoveryImages: function (_a) {
|
|
373
|
+
var props = __rest(_a, []);
|
|
374
|
+
if (!(0, validation_1.validateParams)(["mode", "callback"], props)) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
var func = function () {
|
|
381
|
+
(0, visualDiscovery_1.discoveryImages)(__assign({ self: exports.sdkUtils }, props));
|
|
382
|
+
};
|
|
383
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
384
|
+
func();
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
sendImage: function (_a) {
|
|
388
|
+
var props = __rest(_a, []);
|
|
389
|
+
if (!(0, validation_1.validateParams)(["fileData", "callback"], props)) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
var func = function () {
|
|
396
|
+
(0, visualDiscovery_1.sendImage)(__assign({ self: exports.sdkUtils }, props));
|
|
397
|
+
};
|
|
398
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
399
|
+
func();
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
ProductsByImage: function (_a) {
|
|
403
|
+
var props = __rest(_a, []);
|
|
404
|
+
if (!(0, validation_1.validateParams)(["imageID", "callback"], props)) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
var func = function () {
|
|
411
|
+
(0, visualDiscovery_1.ProductsByImage)(__assign({ self: exports.sdkUtils }, props));
|
|
412
|
+
};
|
|
413
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
414
|
+
func();
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
visualSearch: function (_a) {
|
|
418
|
+
var props = __rest(_a, []);
|
|
419
|
+
if (!(0, validation_1.validateParams)(["fileData", "callback"], props)) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (!(0, validation_1.isValidAPIUser)(exports.sdkUtils)) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
var func = function () {
|
|
426
|
+
(0, visualDiscovery_1.visualSearch)(__assign({ self: exports.sdkUtils }, props));
|
|
427
|
+
};
|
|
428
|
+
if (!(0, utils_1.registerCallback)(exports.sdkUtils, func)) {
|
|
429
|
+
func();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
};
|
|
435
433
|
//# sourceMappingURL=index.js.map
|