@useinsider/guido 3.18.1-beta.12053dd → 3.18.1-beta.178a3ec
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/dist/components/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +30 -30
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +11 -13
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +53 -65
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +18 -20
- package/dist/composables/useCustomInterfaceAppearance.js +46 -56
- package/dist/composables/useHtmlValidator.js +79 -84
- package/dist/composables/useRecommendation.js +35 -40
- package/dist/composables/useStripo.js +30 -30
- package/dist/config/migrator/itemsBlockMigrator.js +225 -163
- package/dist/enums/extensions/recommendationBlock.js +31 -38
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +212 -201
- package/dist/extensions/Blocks/Recommendation/block.js +39 -43
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +20 -21
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +58 -63
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +52 -84
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +130 -222
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +12 -21
- package/dist/guido.css +1 -1
- package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -2
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -9
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -75
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +0 -4
- package/dist/src/stores/onboarding.d.ts +0 -377
- package/dist/static/styles/components/recommendation-strategy.css.js +4 -34
- package/dist/stores/onboarding.js +36 -41
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/templatePreparation.js +49 -49
- package/package.json +1 -1
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +0 -21
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +0 -47
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +0 -2
- package/dist/static/styles/components/skeleton.css.js +0 -23
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as
|
|
2
|
-
import { useRecommendationApi as
|
|
3
|
-
import { useConfigStore as
|
|
4
|
-
import { defineStore as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as b, getOperatorOptions as G, PriceAttributes as v } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as D } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as P } from "../../../../stores/config.js";
|
|
4
|
+
import { defineStore as F } from "pinia";
|
|
5
5
|
import "../constants/selectors.js";
|
|
6
|
-
import { DEFAULT_MOBILE_CARDS_IN_ROW as
|
|
7
|
-
import { DEFAULT_NODE_CONFIG as
|
|
8
|
-
import { getDefaultProducts as
|
|
9
|
-
import { generateCompleteFilterQuery as
|
|
10
|
-
import { getPartnerRecommendationParams as
|
|
11
|
-
import { sanitizeProductIds as
|
|
12
|
-
import { isFilterValid as
|
|
13
|
-
import {
|
|
14
|
-
const
|
|
15
|
-
let
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
function P() {
|
|
6
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as _, DEFAULT_CARDS_IN_ROW as U } from "../constants/layout.js";
|
|
7
|
+
import { DEFAULT_NODE_CONFIG as N, EXCLUDED_ALGORITHM_IDS as L } from "../constants/defaultConfig.js";
|
|
8
|
+
import { getDefaultProducts as R } from "../templates/utils.js";
|
|
9
|
+
import { generateCompleteFilterQuery as k } from "../utils/filterUtil.js";
|
|
10
|
+
import { getPartnerRecommendationParams as x } from "../utils/partnerCustomizations.js";
|
|
11
|
+
import { sanitizeProductIds as A } from "../utils/productIds.js";
|
|
12
|
+
import { isFilterValid as B } from "../validation/filterSchema.js";
|
|
13
|
+
import { isConfigValid as M } from "../validation/requiredFields.js";
|
|
14
|
+
const u = D();
|
|
15
|
+
let f = null, h = null, g = null, S = null;
|
|
16
|
+
const p = /* @__PURE__ */ new Map();
|
|
17
|
+
function w() {
|
|
19
18
|
return {
|
|
20
|
-
cardsInRow:
|
|
19
|
+
cardsInRow: U,
|
|
21
20
|
currencySettings: {
|
|
22
21
|
name: "USD",
|
|
23
22
|
value: "USD",
|
|
@@ -31,17 +30,13 @@ function P() {
|
|
|
31
30
|
productIds: [],
|
|
32
31
|
id: 1,
|
|
33
32
|
language: "en_US",
|
|
34
|
-
mobileCardsInRow:
|
|
33
|
+
mobileCardsInRow: _,
|
|
35
34
|
mobileLayoutEnabled: !1,
|
|
36
35
|
orientation: "grid",
|
|
37
36
|
recommendedProducts: [],
|
|
38
37
|
sendProductRequestFlag: !1,
|
|
39
38
|
shuffleProducts: !1,
|
|
40
|
-
|
|
41
|
-
// that default is what reached buildCampaignUrl and baked a most-popular feed URL
|
|
42
|
-
// for a block the user never configured (SD-149916). Legacy blocks still get their real
|
|
43
|
-
// algorithm from the node-config sync or the save-time seed.
|
|
44
|
-
strategy: F().isFeatureEnabled("reusableRecommendationStrategy") ? "" : "mostPopular",
|
|
39
|
+
strategy: "mostPopular",
|
|
45
40
|
strategyId: "",
|
|
46
41
|
textTrimming: !0,
|
|
47
42
|
unresponsive: !1,
|
|
@@ -51,9 +46,9 @@ function P() {
|
|
|
51
46
|
priceHideIfSameAsDiscounted: !1
|
|
52
47
|
};
|
|
53
48
|
}
|
|
54
|
-
function
|
|
49
|
+
function C() {
|
|
55
50
|
return {
|
|
56
|
-
recommendationConfigs:
|
|
51
|
+
recommendationConfigs: w(),
|
|
57
52
|
recommendationProducts: [],
|
|
58
53
|
filterStatus: !1,
|
|
59
54
|
filterSelectionDrawerStatus: !1,
|
|
@@ -64,7 +59,7 @@ function w() {
|
|
|
64
59
|
filterSnapshot: null
|
|
65
60
|
};
|
|
66
61
|
}
|
|
67
|
-
const
|
|
62
|
+
const z = () => ({
|
|
68
63
|
recommendationCampaignUrls: {},
|
|
69
64
|
activePredictiveAlgorithms: [],
|
|
70
65
|
languages: {},
|
|
@@ -73,14 +68,11 @@ const j = () => ({
|
|
|
73
68
|
strategies: [],
|
|
74
69
|
strategiesLoading: !1,
|
|
75
70
|
strategyUrlTemplates: {},
|
|
76
|
-
strategiesFetched: !1,
|
|
77
|
-
strategiesSettled: !1,
|
|
78
71
|
blockStates: {},
|
|
79
72
|
currentRecommendationId: null,
|
|
80
|
-
strategyPanelOpen: !1,
|
|
81
73
|
configVersion: 0
|
|
82
|
-
}),
|
|
83
|
-
state: () =>
|
|
74
|
+
}), Y = F("guidoRecommendationExtension", {
|
|
75
|
+
state: () => z(),
|
|
84
76
|
getters: {
|
|
85
77
|
// ====================================================================
|
|
86
78
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -90,7 +82,7 @@ const j = () => ({
|
|
|
90
82
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
91
83
|
*/
|
|
92
84
|
recommendationConfigs(t) {
|
|
93
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
85
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : w();
|
|
94
86
|
},
|
|
95
87
|
/**
|
|
96
88
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -145,12 +137,12 @@ const j = () => ({
|
|
|
145
137
|
return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
|
|
146
138
|
},
|
|
147
139
|
getActivePredictiveAlgorithms: (t) => {
|
|
148
|
-
const e =
|
|
149
|
-
return t.activePredictiveAlgorithms.filter((
|
|
150
|
-
r.push(...e.filter((s) => s.id ===
|
|
151
|
-
}), r.map((
|
|
152
|
-
text:
|
|
153
|
-
value:
|
|
140
|
+
const e = b(), r = [];
|
|
141
|
+
return t.activePredictiveAlgorithms.filter((n) => !L.includes(n)).forEach((n) => {
|
|
142
|
+
r.push(...e.filter((s) => s.id === n));
|
|
143
|
+
}), r.map((n) => ({
|
|
144
|
+
text: n.name,
|
|
145
|
+
value: n.key
|
|
154
146
|
}));
|
|
155
147
|
},
|
|
156
148
|
getLanguages: (t) => Object.entries(t.languages).map(([e, r]) => ({
|
|
@@ -164,7 +156,7 @@ const j = () => ({
|
|
|
164
156
|
getFilterList() {
|
|
165
157
|
return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
|
|
166
158
|
let e;
|
|
167
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
159
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : v.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
168
160
|
text: t.displayName,
|
|
169
161
|
value: e,
|
|
170
162
|
type: t.attributeType
|
|
@@ -186,7 +178,7 @@ const j = () => ({
|
|
|
186
178
|
setCurrentBlock(t) {
|
|
187
179
|
this.blockStates[t] || (this.blockStates = {
|
|
188
180
|
...this.blockStates,
|
|
189
|
-
[t]:
|
|
181
|
+
[t]: C()
|
|
190
182
|
}), this.currentRecommendationId = t;
|
|
191
183
|
},
|
|
192
184
|
/**
|
|
@@ -196,13 +188,13 @@ const j = () => ({
|
|
|
196
188
|
removeBlockState(t) {
|
|
197
189
|
const e = t.toString();
|
|
198
190
|
if (this.recommendationCampaignUrls[e]) {
|
|
199
|
-
const
|
|
200
|
-
delete
|
|
191
|
+
const n = { ...this.recommendationCampaignUrls };
|
|
192
|
+
delete n[e], this.recommendationCampaignUrls = n;
|
|
201
193
|
}
|
|
202
194
|
const r = { ...this.blockStates };
|
|
203
195
|
if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
|
|
204
|
-
const
|
|
205
|
-
this.currentRecommendationId =
|
|
196
|
+
const n = Object.keys(this.blockStates).map(Number);
|
|
197
|
+
this.currentRecommendationId = n.length > 0 ? n[0] : null;
|
|
206
198
|
}
|
|
207
199
|
},
|
|
208
200
|
/**
|
|
@@ -218,10 +210,10 @@ const j = () => ({
|
|
|
218
210
|
[e]: o
|
|
219
211
|
};
|
|
220
212
|
}
|
|
221
|
-
const
|
|
222
|
-
|
|
213
|
+
const n = t.toString(), s = e.toString(), i = this.recommendationCampaignUrls[n];
|
|
214
|
+
i && (this.recommendationCampaignUrls = {
|
|
223
215
|
...this.recommendationCampaignUrls,
|
|
224
|
-
[s]:
|
|
216
|
+
[s]: i
|
|
225
217
|
});
|
|
226
218
|
},
|
|
227
219
|
/**
|
|
@@ -246,7 +238,7 @@ const j = () => ({
|
|
|
246
238
|
* `isInitialized`) alone.
|
|
247
239
|
*/
|
|
248
240
|
seedBlockUrlConfig(t, e) {
|
|
249
|
-
const r = (o, c) => o === "." || o === "," || o === " " ? o : c,
|
|
241
|
+
const r = (o, c) => o === "." || o === "," || o === " " ? o : c, n = {
|
|
250
242
|
name: e.currencyCode,
|
|
251
243
|
value: e.currencyCode,
|
|
252
244
|
symbol: e.currencyCode,
|
|
@@ -254,9 +246,9 @@ const j = () => ({
|
|
|
254
246
|
decimalCount: String(e.currencyDecimalCount),
|
|
255
247
|
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
256
248
|
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
257
|
-
}, s = !this.blockStates[t],
|
|
258
|
-
|
|
259
|
-
...
|
|
249
|
+
}, s = !this.blockStates[t], i = s ? C() : this.blockStates[t];
|
|
250
|
+
i.recommendationConfigs = {
|
|
251
|
+
...i.recommendationConfigs,
|
|
260
252
|
strategy: e.strategy,
|
|
261
253
|
strategyId: e.strategyId,
|
|
262
254
|
language: e.language,
|
|
@@ -264,10 +256,10 @@ const j = () => ({
|
|
|
264
256
|
productIds: e.productIds,
|
|
265
257
|
filters: e.filters,
|
|
266
258
|
shuffleProducts: e.shuffleProducts,
|
|
267
|
-
currencySettings:
|
|
259
|
+
currencySettings: n
|
|
268
260
|
}, s && (this.blockStates = {
|
|
269
261
|
...this.blockStates,
|
|
270
|
-
[t]:
|
|
262
|
+
[t]: i
|
|
271
263
|
});
|
|
272
264
|
},
|
|
273
265
|
/**
|
|
@@ -286,18 +278,18 @@ const j = () => ({
|
|
|
286
278
|
...t.currencySettings || {}
|
|
287
279
|
}
|
|
288
280
|
};
|
|
289
|
-
const { triggerRefetch:
|
|
290
|
-
|
|
281
|
+
const { triggerRefetch: n = !0 } = e;
|
|
282
|
+
n && this.configVersion++;
|
|
291
283
|
},
|
|
292
284
|
/**
|
|
293
285
|
* Creates a filter with the first available attribute and operator pre-selected.
|
|
294
286
|
*/
|
|
295
287
|
createDefaultFilter(t, e) {
|
|
296
|
-
const [r] = this.getFilterList, [
|
|
288
|
+
const [r] = this.getFilterList, [n] = G(r == null ? void 0 : r.type);
|
|
297
289
|
return {
|
|
298
290
|
type: "standardFilter",
|
|
299
291
|
attribute: (r == null ? void 0 : r.value) ?? "",
|
|
300
|
-
operator: (
|
|
292
|
+
operator: (n == null ? void 0 : n.value) ?? "",
|
|
301
293
|
innerGroupOperator: "*",
|
|
302
294
|
outerGroupOperator: "*",
|
|
303
295
|
filterNumber: e,
|
|
@@ -353,101 +345,33 @@ const j = () => ({
|
|
|
353
345
|
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].removeStrategyModalStatus = !1);
|
|
354
346
|
},
|
|
355
347
|
async fetchStrategies() {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
await p;
|
|
359
|
-
} catch {
|
|
360
|
-
}
|
|
361
|
-
if (this.strategiesFetched)
|
|
348
|
+
if (S) {
|
|
349
|
+
await S;
|
|
362
350
|
return;
|
|
363
|
-
|
|
351
|
+
}
|
|
352
|
+
S = (async () => {
|
|
364
353
|
this.strategiesLoading = !0;
|
|
365
354
|
try {
|
|
366
|
-
|
|
367
|
-
if (t !== y)
|
|
368
|
-
return;
|
|
369
|
-
this.strategies = r, this.strategiesFetched = !0;
|
|
355
|
+
this.strategies = await u.fetchRecommendationStrategies();
|
|
370
356
|
} finally {
|
|
371
|
-
this.strategiesLoading = !1
|
|
357
|
+
this.strategiesLoading = !1;
|
|
372
358
|
}
|
|
373
359
|
})();
|
|
374
|
-
p = e;
|
|
375
360
|
try {
|
|
376
|
-
await
|
|
361
|
+
await S;
|
|
377
362
|
} finally {
|
|
378
|
-
|
|
363
|
+
S = null;
|
|
379
364
|
}
|
|
380
365
|
},
|
|
381
|
-
invalidateStrategies() {
|
|
382
|
-
this.strategiesFetched = !1, this.strategiesSettled = !1, y += 1;
|
|
383
|
-
},
|
|
384
|
-
/**
|
|
385
|
-
* Opens a Smart Recommender strategy page in a new tab and refreshes the list every time
|
|
386
|
-
* the user comes back. `visibilitychange` only: a `focus` listener would also fire when
|
|
387
|
-
* focus merely returns from the Stripo canvas iframe to the panel, refetching and
|
|
388
|
-
* regenerating the canvas while the user never left the editor (SD-149916).
|
|
389
|
-
*
|
|
390
|
-
* Deliberately NOT one-shot: the strategy tab stays open, so a user can create a second
|
|
391
|
-
* strategy in it and come back again — a listener that disarmed on the first return would
|
|
392
|
-
* leave that one missing from the list. It disarms on the first return AFTER that tab is
|
|
393
|
-
* closed instead, so an ordinary alt-tab later in the session costs nothing. Armed only
|
|
394
|
-
* once the user actually opens a strategy page, so anyone who never does pays nothing.
|
|
395
|
-
*/
|
|
396
|
-
_armStrategyPageReturn(t) {
|
|
397
|
-
const e = window.open(t, "_blank");
|
|
398
|
-
if (!e)
|
|
399
|
-
return;
|
|
400
|
-
e.opener = null, l == null || l();
|
|
401
|
-
let r = !1;
|
|
402
|
-
const i = () => {
|
|
403
|
-
document.hidden || r || (e != null && e.closed && (l == null || l()), r = !0, this.invalidateStrategies(), this.fetchStrategies().then(() => this._refreshAssignedStrategyProducts()).catch(() => {
|
|
404
|
-
}).finally(() => {
|
|
405
|
-
r = !1;
|
|
406
|
-
}));
|
|
407
|
-
};
|
|
408
|
-
document.addEventListener("visibilitychange", i), l = () => {
|
|
409
|
-
document.removeEventListener("visibilitychange", i), l = null;
|
|
410
|
-
};
|
|
411
|
-
},
|
|
412
|
-
/**
|
|
413
|
-
* Reloads the products of the block the user is on, so an edit made in the strategy tab
|
|
414
|
-
* lands on the canvas instead of waiting for the assign drawer to be reopened.
|
|
415
|
-
*
|
|
416
|
-
* Only the selected block: the canvas regeneration is driven off the active block's
|
|
417
|
-
* product array, so refreshing an unselected block would fetch without redrawing it.
|
|
418
|
-
*/
|
|
419
|
-
async _refreshAssignedStrategyProducts() {
|
|
420
|
-
var e;
|
|
421
|
-
const t = this.currentRecommendationId;
|
|
422
|
-
t === null || !((e = this.blockStates[t]) != null && e.recommendationConfigs.strategyId) || await this.fetchRecommendationProducts();
|
|
423
|
-
},
|
|
424
|
-
/** Lets the editor tear the return listeners down when it unmounts. */
|
|
425
|
-
disposeStrategyPageReturn() {
|
|
426
|
-
l == null || l();
|
|
427
|
-
},
|
|
428
|
-
/**
|
|
429
|
-
* Opens Smart Recommender's strategy creation page. Every return refreshes the list so the
|
|
430
|
-
* new strategy is offered; the user picks it themselves.
|
|
431
|
-
*/
|
|
432
|
-
openStrategyCreation() {
|
|
433
|
-
this._armStrategyPageReturn(D.RECOMMENDATION_STRATEGY_CREATE_PATH);
|
|
434
|
-
},
|
|
435
|
-
/**
|
|
436
|
-
* Opens the strategy's edit page. Every return refreshes the list so the block reflects the
|
|
437
|
-
* edited configuration.
|
|
438
|
-
*/
|
|
439
|
-
openStrategyEdit(t) {
|
|
440
|
-
this._armStrategyPageReturn(G(t));
|
|
441
|
-
},
|
|
442
366
|
async resolveStrategyUrlTemplate(t, e) {
|
|
443
|
-
const r = typeof t.updated_at == "string" ? t.updated_at : "",
|
|
367
|
+
const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
|
|
444
368
|
if (s)
|
|
445
369
|
return s;
|
|
446
|
-
const { full_path:
|
|
447
|
-
return
|
|
370
|
+
const { full_path: i = "" } = await u.generateStrategyEndpoint(t, e) ?? {};
|
|
371
|
+
return n && i && (this.strategyUrlTemplates = {
|
|
448
372
|
...this.strategyUrlTemplates,
|
|
449
|
-
[
|
|
450
|
-
}),
|
|
373
|
+
[n]: i
|
|
374
|
+
}), i;
|
|
451
375
|
},
|
|
452
376
|
assignStrategy(t) {
|
|
453
377
|
this.patchCurrentBlockConfig({
|
|
@@ -456,54 +380,50 @@ const j = () => ({
|
|
|
456
380
|
});
|
|
457
381
|
},
|
|
458
382
|
removeStrategy() {
|
|
459
|
-
this.patchCurrentBlockConfig({
|
|
460
|
-
strategyId: "",
|
|
461
|
-
strategy: "",
|
|
462
|
-
size: x.size
|
|
463
|
-
});
|
|
383
|
+
this.patchCurrentBlockConfig({ strategyId: "", size: N.size });
|
|
464
384
|
},
|
|
465
385
|
// ====================================================================
|
|
466
386
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
467
387
|
// ====================================================================
|
|
468
388
|
async fetchRecommendationCreateData() {
|
|
469
389
|
if (!this.activePredictiveAlgorithms.length) {
|
|
470
|
-
if (
|
|
471
|
-
await
|
|
390
|
+
if (f) {
|
|
391
|
+
await f;
|
|
472
392
|
return;
|
|
473
393
|
}
|
|
474
|
-
|
|
394
|
+
f = (async () => {
|
|
475
395
|
const {
|
|
476
396
|
activePredictiveAlgorithms: t,
|
|
477
397
|
languages: e,
|
|
478
398
|
currencies: r
|
|
479
|
-
} = await
|
|
399
|
+
} = await u.fetchRecommendationCreateData();
|
|
480
400
|
if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
481
|
-
const
|
|
482
|
-
|
|
401
|
+
const n = this.blockStates[this.currentRecommendationId];
|
|
402
|
+
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
483
403
|
}
|
|
484
404
|
this.currencyList = r;
|
|
485
405
|
})();
|
|
486
406
|
try {
|
|
487
|
-
await
|
|
407
|
+
await f;
|
|
488
408
|
} finally {
|
|
489
|
-
|
|
409
|
+
f = null;
|
|
490
410
|
}
|
|
491
411
|
}
|
|
492
412
|
},
|
|
493
413
|
async fetchRecommendationFilters() {
|
|
494
414
|
if (!Object.keys(this.filterList).length) {
|
|
495
|
-
if (
|
|
496
|
-
await
|
|
415
|
+
if (h) {
|
|
416
|
+
await h;
|
|
497
417
|
return;
|
|
498
418
|
}
|
|
499
|
-
|
|
500
|
-
const t = await
|
|
419
|
+
h = (async () => {
|
|
420
|
+
const t = await u.fetchRecommendationFilters();
|
|
501
421
|
this.filterList = t;
|
|
502
422
|
})();
|
|
503
423
|
try {
|
|
504
|
-
await
|
|
424
|
+
await h;
|
|
505
425
|
} finally {
|
|
506
|
-
|
|
426
|
+
h = null;
|
|
507
427
|
}
|
|
508
428
|
}
|
|
509
429
|
},
|
|
@@ -518,41 +438,41 @@ const j = () => ({
|
|
|
518
438
|
deleteFilterGroup(t) {
|
|
519
439
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
520
440
|
return;
|
|
521
|
-
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.filter((
|
|
522
|
-
e.recommendationConfigs.filters = r.map((
|
|
523
|
-
...
|
|
524
|
-
filterGroup: s.get(
|
|
441
|
+
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(r.map((i) => i.filterGroup))].sort((i, o) => i - o), s = new Map(n.map((i, o) => [i, o + 1]));
|
|
442
|
+
e.recommendationConfigs.filters = r.map((i) => ({
|
|
443
|
+
...i,
|
|
444
|
+
filterGroup: s.get(i.filterGroup) ?? i.filterGroup
|
|
525
445
|
}));
|
|
526
446
|
},
|
|
527
447
|
updateFilter(t) {
|
|
528
448
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
529
449
|
return;
|
|
530
|
-
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((
|
|
450
|
+
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
531
451
|
if (r !== -1) {
|
|
532
|
-
const
|
|
533
|
-
|
|
452
|
+
const n = [...e.recommendationConfigs.filters];
|
|
453
|
+
n[r] = {
|
|
534
454
|
...t,
|
|
535
|
-
isValid:
|
|
536
|
-
}, e.recommendationConfigs.filters =
|
|
455
|
+
isValid: B(t)
|
|
456
|
+
}, e.recommendationConfigs.filters = n;
|
|
537
457
|
}
|
|
538
458
|
},
|
|
539
459
|
deleteFilter(t) {
|
|
540
460
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
541
461
|
return;
|
|
542
|
-
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((
|
|
462
|
+
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
543
463
|
if (r !== -1) {
|
|
544
|
-
let
|
|
545
|
-
if (
|
|
546
|
-
let
|
|
547
|
-
|
|
464
|
+
let n = [...e.recommendationConfigs.filters];
|
|
465
|
+
if (n.splice(r, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
|
|
466
|
+
let i = 1;
|
|
467
|
+
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
548
468
|
} else {
|
|
549
|
-
const
|
|
550
|
-
|
|
469
|
+
const i = [...new Set(n.map((c) => c.filterGroup))].sort((c, a) => c - a), o = new Map(i.map((c, a) => [c, a + 1]));
|
|
470
|
+
n = n.map((c) => ({
|
|
551
471
|
...c,
|
|
552
472
|
filterGroup: o.get(c.filterGroup) ?? c.filterGroup
|
|
553
473
|
}));
|
|
554
474
|
}
|
|
555
|
-
e.recommendationConfigs.filters =
|
|
475
|
+
e.recommendationConfigs.filters = n;
|
|
556
476
|
}
|
|
557
477
|
},
|
|
558
478
|
addFilter(t) {
|
|
@@ -560,8 +480,8 @@ const j = () => ({
|
|
|
560
480
|
return;
|
|
561
481
|
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], s = r.filter(
|
|
562
482
|
(o) => o.filterGroup === t.filterGroup
|
|
563
|
-
).length + 1,
|
|
564
|
-
|
|
483
|
+
).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
484
|
+
i !== -1 ? r.splice(i + 1, 0, {
|
|
565
485
|
...t,
|
|
566
486
|
filterNumber: s
|
|
567
487
|
}) : r.push({
|
|
@@ -570,7 +490,7 @@ const j = () => ({
|
|
|
570
490
|
}), e.recommendationConfigs.filters = r;
|
|
571
491
|
},
|
|
572
492
|
generateFilterQuery() {
|
|
573
|
-
return
|
|
493
|
+
return k(this.recommendationConfigs.filters);
|
|
574
494
|
},
|
|
575
495
|
/**
|
|
576
496
|
* Validation-only check invoked at save-CTA time. Defined as an action
|
|
@@ -578,95 +498,83 @@ const j = () => ({
|
|
|
578
498
|
* every block's recommendationConfigs across user edits.
|
|
579
499
|
*/
|
|
580
500
|
hasInvalidBlock() {
|
|
581
|
-
return Object.values(this.blockStates).some((t) => !
|
|
582
|
-
},
|
|
583
|
-
/**
|
|
584
|
-
* Which required fields are missing across the design's blocks, so the save
|
|
585
|
-
* toaster can name the cause instead of always showing the generic message.
|
|
586
|
-
*/
|
|
587
|
-
invalidBlockFields() {
|
|
588
|
-
return Object.values(this.blockStates).flatMap((t) => z(t.recommendationConfigs, this));
|
|
501
|
+
return Object.values(this.blockStates).some((t) => !M(t.recommendationConfigs, this));
|
|
589
502
|
},
|
|
590
503
|
// ====================================================================
|
|
591
504
|
// Per-Block Product Fetching
|
|
592
505
|
// ====================================================================
|
|
593
506
|
async fetchRecommendationProducts() {
|
|
594
507
|
if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
|
|
595
|
-
if (
|
|
596
|
-
await
|
|
508
|
+
if (g) {
|
|
509
|
+
await g;
|
|
597
510
|
return;
|
|
598
511
|
}
|
|
599
|
-
|
|
512
|
+
g = this._doFetchProducts();
|
|
600
513
|
try {
|
|
601
|
-
await
|
|
514
|
+
await g;
|
|
602
515
|
} finally {
|
|
603
|
-
|
|
516
|
+
g = null;
|
|
604
517
|
}
|
|
605
518
|
}
|
|
606
519
|
},
|
|
607
520
|
async _doFetchProducts() {
|
|
608
|
-
var
|
|
609
|
-
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e,
|
|
610
|
-
if (r.strategyId &&
|
|
521
|
+
var d;
|
|
522
|
+
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = P();
|
|
523
|
+
if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
|
|
611
524
|
await this._doFetchStrategyProducts(t);
|
|
612
525
|
return;
|
|
613
526
|
}
|
|
614
|
-
const s = parseInt(r.size) || 6
|
|
615
|
-
if (!r.strategy) {
|
|
616
|
-
this._setBlockProducts(t, [], s);
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
const n = r.filters.filter((m) => m.isValid), o = v(n), c = ((f = k().find((m) => m.key === r.strategy)) == null ? void 0 : f.path) || "", a = {
|
|
527
|
+
const s = r.filters.filter((m) => m.isValid), i = k(s), o = ((d = b().find((m) => m.key === r.strategy)) == null ? void 0 : d.path) || "", c = parseInt(r.size) || 6, a = {
|
|
620
528
|
locale: r.language,
|
|
621
529
|
currency: r.currencySettings.value,
|
|
622
|
-
partnerName:
|
|
530
|
+
partnerName: n.partnerName,
|
|
623
531
|
size: r.size,
|
|
624
532
|
details: !0,
|
|
625
|
-
campaignId:
|
|
533
|
+
campaignId: n.variationId
|
|
626
534
|
};
|
|
627
|
-
r.strategy === "manualMerchandising" ? a.productId =
|
|
535
|
+
r.strategy === "manualMerchandising" ? a.productId = A(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), i && (a.filter = i), r.shuffleProducts && (a.shuffle = !0), Object.assign(
|
|
628
536
|
a,
|
|
629
|
-
|
|
537
|
+
x(n.partnerName, r.strategy)
|
|
630
538
|
);
|
|
631
|
-
let
|
|
539
|
+
let l;
|
|
632
540
|
try {
|
|
633
|
-
|
|
541
|
+
l = await u.fetchRecommendationProducts(o, a);
|
|
634
542
|
} catch {
|
|
635
|
-
|
|
543
|
+
l = [];
|
|
636
544
|
}
|
|
637
|
-
this._setBlockProducts(t,
|
|
545
|
+
this._setBlockProducts(t, l, c);
|
|
638
546
|
},
|
|
639
547
|
async _doFetchStrategyProducts(t) {
|
|
640
|
-
const e = (
|
|
641
|
-
|
|
548
|
+
const e = (p.get(t) ?? 0) + 1;
|
|
549
|
+
p.set(t, e);
|
|
642
550
|
const { recommendationConfigs: r } = this.blockStates[t];
|
|
643
|
-
let
|
|
551
|
+
let n = [], s = parseInt(r.size) || 6;
|
|
644
552
|
try {
|
|
645
553
|
await this.fetchStrategies();
|
|
646
|
-
const
|
|
554
|
+
const i = this.strategies.find(
|
|
647
555
|
(o) => String(o.strategy_id) === r.strategyId
|
|
648
556
|
);
|
|
649
|
-
if (
|
|
650
|
-
s = parseInt(String(
|
|
651
|
-
const o = r.currencySettings.value, a = (await this.resolveStrategyUrlTemplate(
|
|
652
|
-
|
|
557
|
+
if (i) {
|
|
558
|
+
s = parseInt(String(i.size ?? "")) || s;
|
|
559
|
+
const o = r.currencySettings.value, a = (await this.resolveStrategyUrlTemplate(i, o)).replaceAll("{locale}", r.language).replaceAll("{currency}", o), l = a.indexOf("?"), d = l === -1 ? a : a.slice(0, l), m = (l === -1 ? "" : a.slice(l + 1)).split("&").filter((I) => I && !I.startsWith("user_id=")), y = m.length ? `${d}?${m.join("&")}` : d;
|
|
560
|
+
y && (n = await u.fetchRecommendationProductsByUrl(y));
|
|
653
561
|
}
|
|
654
562
|
} catch {
|
|
655
|
-
|
|
563
|
+
n = [];
|
|
656
564
|
}
|
|
657
|
-
|
|
565
|
+
p.get(t) === e && this._setBlockProducts(t, n, s);
|
|
658
566
|
},
|
|
659
567
|
_setBlockProducts(t, e, r) {
|
|
660
568
|
if (!this.blockStates[t])
|
|
661
569
|
return;
|
|
662
|
-
const
|
|
570
|
+
const n = e.length > 0 ? e : R(r);
|
|
663
571
|
this.blockStates[t].recommendationProducts = [
|
|
664
|
-
...
|
|
665
|
-
...
|
|
572
|
+
...n.slice(0, r),
|
|
573
|
+
...R(Math.max(0, r - n.length))
|
|
666
574
|
];
|
|
667
575
|
}
|
|
668
576
|
}
|
|
669
577
|
});
|
|
670
578
|
export {
|
|
671
|
-
|
|
579
|
+
Y as useRecommendationExtensionStore
|
|
672
580
|
};
|