@useinsider/guido 3.20.1-beta.2c8da49 → 3.20.1-beta.2d09f29
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/composables/useActionsApi.js +64 -80
- package/dist/composables/useFullStoryBridge.js +10 -9
- package/dist/composables/useGuidoStateBridge.js +3 -3
- package/dist/composables/useLegacyStrategyConversion.js +16 -16
- package/dist/composables/useStripo.js +10 -11
- package/dist/config/migrator/fullStoryScriptMigrator.js +5 -0
- package/dist/config/migrator/index.js +11 -10
- package/dist/extensions/Blocks/Items/block.js +42 -43
- package/dist/extensions/Blocks/Recommendation/block.js +29 -33
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +83 -78
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +2 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +12 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +86 -104
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +263 -348
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +50 -48
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +21 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +40 -44
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +19 -14
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +102 -104
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +23 -18
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +286 -312
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +20 -24
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +7 -6
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +151 -113
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +205 -219
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +40 -111
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +35 -31
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +192 -271
- package/dist/package.json.js +1 -1
- package/dist/src/composables/useActionsApi.d.ts +1 -5
- package/dist/src/config/migrator/fullStoryScriptMigrator.d.ts +1 -0
- package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +0 -8
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +0 -40
- package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -11
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +6 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +12 -21
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +3 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +5 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +3 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -21
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +13 -19
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +8 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -9
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -8
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +11 -18
- package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/controlFactories.d.ts +0 -22
- package/dist/src/stores/editor.d.ts +1 -3
- package/dist/src/utils/fullStoryScripts.d.ts +6 -0
- package/dist/static/styles/components/button.css.js +0 -5
- package/dist/stores/editor.js +0 -5
- package/dist/utils/fullStoryScripts.js +8 -0
- package/package.json +3 -3
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +0 -28
- package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +0 -25
- package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +0 -17
- package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +0 -6
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
import { useToaster as
|
|
2
|
-
import { useTranslations as
|
|
3
|
-
import { getRecommendationFeedSourceMaps as
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import { useRecommendationApi as
|
|
1
|
+
import { useToaster as U } from "../../../../composables/useToaster.js";
|
|
2
|
+
import { useTranslations as M } from "../../../../composables/useTranslations.js";
|
|
3
|
+
import { getRecommendationFeedSourceMaps as w, strategyEditPath as N, strategyCreatePath as B, getOperatorOptions as z, PriceAttributes as E } from "../../../../enums/extensions/recommendationBlock.js";
|
|
4
|
+
import { ToasterTypeOptions as O } from "../../../../enums/toaster.js";
|
|
5
|
+
import { useRecommendationApi as A } from "../../../../services/recommendationApi.js";
|
|
6
6
|
import { useConfigStore as R } from "../../../../stores/config.js";
|
|
7
|
-
import { defineStore as
|
|
7
|
+
import { defineStore as x } from "pinia";
|
|
8
8
|
import "../constants/selectors.js";
|
|
9
|
-
import { DEFAULT_MOBILE_CARDS_IN_ROW as
|
|
10
|
-
import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as
|
|
11
|
-
import { getDefaultProducts as
|
|
12
|
-
import { generateCompleteFilterQuery as
|
|
13
|
-
import { isLegacyStrategyConfig as
|
|
14
|
-
import { getPartnerRecommendationParams as
|
|
15
|
-
import { sanitizeProductIds as
|
|
16
|
-
import { isFilterValid as
|
|
17
|
-
import { getInvalidFields as
|
|
18
|
-
const
|
|
19
|
-
let
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const e = _.get(t);
|
|
25
|
-
return e && e.token === u.get(t) ? e.outcome : !1;
|
|
9
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as T, DEFAULT_CARDS_IN_ROW as V } from "../constants/layout.js";
|
|
10
|
+
import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as j, EXCLUDED_ALGORITHM_IDS as $ } from "../constants/defaultConfig.js";
|
|
11
|
+
import { getDefaultProducts as P } from "../templates/utils.js";
|
|
12
|
+
import { generateCompleteFilterQuery as G } from "../utils/filterUtil.js";
|
|
13
|
+
import { isLegacyStrategyConfig as q } from "../utils/legacyStrategyMigration.js";
|
|
14
|
+
import { getPartnerRecommendationParams as K } from "../utils/partnerCustomizations.js";
|
|
15
|
+
import { sanitizeProductIds as H } from "../utils/productIds.js";
|
|
16
|
+
import { isFilterValid as J } from "../validation/filterSchema.js";
|
|
17
|
+
import { getInvalidFields as Q, isConfigValid as W } from "../validation/requiredFields.js";
|
|
18
|
+
const u = A();
|
|
19
|
+
let S = null, y = null, p = null, I = "", k = null, b = 0;
|
|
20
|
+
const m = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
|
|
21
|
+
function X(t) {
|
|
22
|
+
const e = D.get(t);
|
|
23
|
+
return e && e.token === m.get(t) ? e.outcome : !1;
|
|
26
24
|
}
|
|
27
25
|
let l = null;
|
|
28
|
-
function
|
|
26
|
+
function L() {
|
|
29
27
|
return {
|
|
30
|
-
cardsInRow:
|
|
28
|
+
cardsInRow: V,
|
|
31
29
|
currencySettings: {
|
|
32
30
|
name: "USD",
|
|
33
31
|
value: "USD",
|
|
@@ -41,7 +39,7 @@ function D() {
|
|
|
41
39
|
productIds: [],
|
|
42
40
|
id: 1,
|
|
43
41
|
language: "en_US",
|
|
44
|
-
mobileCardsInRow:
|
|
42
|
+
mobileCardsInRow: T,
|
|
45
43
|
mobileLayoutEnabled: !1,
|
|
46
44
|
orientation: "grid",
|
|
47
45
|
recommendedProducts: [],
|
|
@@ -62,9 +60,9 @@ function D() {
|
|
|
62
60
|
priceHideIfSameAsDiscounted: !1
|
|
63
61
|
};
|
|
64
62
|
}
|
|
65
|
-
function
|
|
63
|
+
function _() {
|
|
66
64
|
return {
|
|
67
|
-
recommendationConfigs:
|
|
65
|
+
recommendationConfigs: L(),
|
|
68
66
|
recommendationProducts: [],
|
|
69
67
|
filterStatus: !1,
|
|
70
68
|
filterSelectionDrawerStatus: !1,
|
|
@@ -75,12 +73,10 @@ function G() {
|
|
|
75
73
|
isInitialized: !1,
|
|
76
74
|
filterSnapshot: null,
|
|
77
75
|
syncedConfigFingerprint: null,
|
|
78
|
-
legacyConversionLoading: !1
|
|
79
|
-
configVersion: 0,
|
|
80
|
-
adoptedSizeVersion: 0
|
|
76
|
+
legacyConversionLoading: !1
|
|
81
77
|
};
|
|
82
78
|
}
|
|
83
|
-
const
|
|
79
|
+
const Y = () => ({
|
|
84
80
|
recommendationCampaignUrls: {},
|
|
85
81
|
activePredictiveAlgorithms: [],
|
|
86
82
|
languages: {},
|
|
@@ -95,8 +91,8 @@ const X = () => ({
|
|
|
95
91
|
currentRecommendationId: null,
|
|
96
92
|
strategyPanelOpen: !1,
|
|
97
93
|
configVersion: 0
|
|
98
|
-
}),
|
|
99
|
-
state: () =>
|
|
94
|
+
}), St = x("guidoRecommendationExtension", {
|
|
95
|
+
state: () => Y(),
|
|
100
96
|
getters: {
|
|
101
97
|
// ====================================================================
|
|
102
98
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -106,7 +102,7 @@ const X = () => ({
|
|
|
106
102
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
107
103
|
*/
|
|
108
104
|
recommendationConfigs(t) {
|
|
109
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
105
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : L();
|
|
110
106
|
},
|
|
111
107
|
/**
|
|
112
108
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -127,7 +123,7 @@ const X = () => ({
|
|
|
127
123
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
|
|
128
124
|
},
|
|
129
125
|
isLegacyStrategyBlock() {
|
|
130
|
-
return R().isFeatureEnabled("reusableRecommendationStrategy") &&
|
|
126
|
+
return R().isFeatureEnabled("reusableRecommendationStrategy") && q(this.recommendationConfigs);
|
|
131
127
|
},
|
|
132
128
|
legacyConversionLoading(t) {
|
|
133
129
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading ?? !1 : !1;
|
|
@@ -137,7 +133,7 @@ const X = () => ({
|
|
|
137
133
|
},
|
|
138
134
|
assignedStrategy(t) {
|
|
139
135
|
const { strategyId: e } = this.recommendationConfigs;
|
|
140
|
-
return e ? t.strategies.find((
|
|
136
|
+
return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
|
|
141
137
|
},
|
|
142
138
|
/**
|
|
143
139
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
|
|
@@ -167,19 +163,19 @@ const X = () => ({
|
|
|
167
163
|
},
|
|
168
164
|
getUniqueFilterGroups() {
|
|
169
165
|
const { filters: t } = this.recommendationConfigs;
|
|
170
|
-
return [...new Set(t.map((e) => e.filterGroup))].sort((e,
|
|
166
|
+
return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
|
|
171
167
|
},
|
|
172
168
|
getActivePredictiveAlgorithms: (t) => {
|
|
173
|
-
const e =
|
|
174
|
-
return t.activePredictiveAlgorithms.filter((
|
|
175
|
-
|
|
176
|
-
}),
|
|
177
|
-
text:
|
|
178
|
-
value:
|
|
169
|
+
const e = w(), r = [];
|
|
170
|
+
return t.activePredictiveAlgorithms.filter((n) => !$.includes(n)).forEach((n) => {
|
|
171
|
+
r.push(...e.filter((s) => s.id === n));
|
|
172
|
+
}), r.map((n) => ({
|
|
173
|
+
text: n.name,
|
|
174
|
+
value: n.key
|
|
179
175
|
}));
|
|
180
176
|
},
|
|
181
|
-
getLanguages: (t) => Object.entries(t.languages).map(([e,
|
|
182
|
-
text:
|
|
177
|
+
getLanguages: (t) => Object.entries(t.languages).map(([e, r]) => ({
|
|
178
|
+
text: r,
|
|
183
179
|
value: e
|
|
184
180
|
})),
|
|
185
181
|
getCurrencySymbolList: (t) => t.currencyList.map((e) => ({
|
|
@@ -189,7 +185,7 @@ const X = () => ({
|
|
|
189
185
|
getFilterList() {
|
|
190
186
|
return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
|
|
191
187
|
let e;
|
|
192
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
188
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : E.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
193
189
|
text: t.displayName,
|
|
194
190
|
value: e,
|
|
195
191
|
type: t.attributeType
|
|
@@ -211,7 +207,7 @@ const X = () => ({
|
|
|
211
207
|
setCurrentBlock(t) {
|
|
212
208
|
this.blockStates[t] || (this.blockStates = {
|
|
213
209
|
...this.blockStates,
|
|
214
|
-
[t]:
|
|
210
|
+
[t]: _()
|
|
215
211
|
}), this.currentRecommendationId = t;
|
|
216
212
|
},
|
|
217
213
|
/**
|
|
@@ -221,13 +217,13 @@ const X = () => ({
|
|
|
221
217
|
removeBlockState(t) {
|
|
222
218
|
const e = t.toString();
|
|
223
219
|
if (this.recommendationCampaignUrls[e]) {
|
|
224
|
-
const
|
|
225
|
-
delete
|
|
220
|
+
const n = { ...this.recommendationCampaignUrls };
|
|
221
|
+
delete n[e], this.recommendationCampaignUrls = n;
|
|
226
222
|
}
|
|
227
|
-
const
|
|
228
|
-
if (delete
|
|
229
|
-
const
|
|
230
|
-
this.currentRecommendationId =
|
|
223
|
+
const r = { ...this.blockStates };
|
|
224
|
+
if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
|
|
225
|
+
const n = Object.keys(this.blockStates).map(Number);
|
|
226
|
+
this.currentRecommendationId = n.length > 0 ? n[0] : null;
|
|
231
227
|
}
|
|
232
228
|
},
|
|
233
229
|
/**
|
|
@@ -239,18 +235,18 @@ const X = () => ({
|
|
|
239
235
|
* (SD-149916).
|
|
240
236
|
*/
|
|
241
237
|
cloneBlockState(t, e) {
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
|
|
238
|
+
const r = this.blockStates[t];
|
|
239
|
+
if (r) {
|
|
240
|
+
const o = structuredClone(r);
|
|
241
|
+
o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (o.isInitialized = !1, o.syncedConfigFingerprint = null), this.blockStates = {
|
|
246
242
|
...this.blockStates,
|
|
247
|
-
[e]:
|
|
243
|
+
[e]: o
|
|
248
244
|
};
|
|
249
245
|
}
|
|
250
|
-
const
|
|
246
|
+
const n = t.toString(), s = e.toString(), i = this.recommendationCampaignUrls[n];
|
|
251
247
|
i && (this.recommendationCampaignUrls = {
|
|
252
248
|
...this.recommendationCampaignUrls,
|
|
253
|
-
[
|
|
249
|
+
[s]: i
|
|
254
250
|
});
|
|
255
251
|
},
|
|
256
252
|
/**
|
|
@@ -275,15 +271,15 @@ const X = () => ({
|
|
|
275
271
|
* `isInitialized`) alone.
|
|
276
272
|
*/
|
|
277
273
|
seedBlockUrlConfig(t, e) {
|
|
278
|
-
const
|
|
274
|
+
const r = (o, a) => o === "." || o === "," || o === " " ? o : a, n = {
|
|
279
275
|
name: e.currencyCode,
|
|
280
276
|
value: e.currencyCode,
|
|
281
277
|
symbol: e.currencySymbol,
|
|
282
278
|
alignment: e.currencyAlignment === "before" ? "0" : "1",
|
|
283
279
|
decimalCount: String(e.currencyDecimalCount),
|
|
284
|
-
decimalSeparator:
|
|
285
|
-
thousandSeparator:
|
|
286
|
-
},
|
|
280
|
+
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
281
|
+
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
282
|
+
}, s = !this.blockStates[t], i = s ? _() : this.blockStates[t];
|
|
287
283
|
i.recommendationConfigs = {
|
|
288
284
|
...i.recommendationConfigs,
|
|
289
285
|
strategy: e.strategy,
|
|
@@ -293,8 +289,8 @@ const X = () => ({
|
|
|
293
289
|
productIds: e.productIds,
|
|
294
290
|
filters: e.filters,
|
|
295
291
|
shuffleProducts: e.shuffleProducts,
|
|
296
|
-
currencySettings:
|
|
297
|
-
},
|
|
292
|
+
currencySettings: n
|
|
293
|
+
}, s && (this.blockStates = {
|
|
298
294
|
...this.blockStates,
|
|
299
295
|
[t]: i
|
|
300
296
|
});
|
|
@@ -306,27 +302,27 @@ const X = () => ({
|
|
|
306
302
|
patchCurrentBlockConfig(t, e = {}) {
|
|
307
303
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
308
304
|
return;
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
...
|
|
305
|
+
const r = this.blockStates[this.currentRecommendationId];
|
|
306
|
+
r.recommendationConfigs = {
|
|
307
|
+
...r.recommendationConfigs,
|
|
312
308
|
...t,
|
|
313
309
|
currencySettings: {
|
|
314
|
-
...
|
|
310
|
+
...r.recommendationConfigs.currencySettings,
|
|
315
311
|
...t.currencySettings || {}
|
|
316
312
|
}
|
|
317
313
|
};
|
|
318
|
-
const { triggerRefetch:
|
|
319
|
-
|
|
314
|
+
const { triggerRefetch: n = !0 } = e;
|
|
315
|
+
n && this.configVersion++;
|
|
320
316
|
},
|
|
321
317
|
/**
|
|
322
318
|
* Creates a filter with the first available attribute and operator pre-selected.
|
|
323
319
|
*/
|
|
324
320
|
createDefaultFilter(t, e) {
|
|
325
|
-
const [
|
|
321
|
+
const [r] = this.getFilterList, [n] = z(r == null ? void 0 : r.type);
|
|
326
322
|
return {
|
|
327
323
|
type: "standardFilter",
|
|
328
|
-
attribute: (
|
|
329
|
-
operator: (
|
|
324
|
+
attribute: (r == null ? void 0 : r.value) ?? "",
|
|
325
|
+
operator: (n == null ? void 0 : n.value) ?? "",
|
|
330
326
|
innerGroupOperator: "*",
|
|
331
327
|
outerGroupOperator: "*",
|
|
332
328
|
filterNumber: e,
|
|
@@ -398,10 +394,10 @@ const X = () => ({
|
|
|
398
394
|
const t = b, e = (async () => {
|
|
399
395
|
this.strategiesLoading = !0;
|
|
400
396
|
try {
|
|
401
|
-
const
|
|
397
|
+
const r = await u.fetchRecommendationStrategies();
|
|
402
398
|
if (t !== b)
|
|
403
399
|
return;
|
|
404
|
-
this.strategies =
|
|
400
|
+
this.strategies = r, this.strategiesFetched = !0;
|
|
405
401
|
} finally {
|
|
406
402
|
this.strategiesLoading = !1, t === b && (this.strategiesSettled = !0);
|
|
407
403
|
}
|
|
@@ -442,20 +438,20 @@ const X = () => ({
|
|
|
442
438
|
_armStrategyPageReturn(t) {
|
|
443
439
|
const e = window.open(t, "_blank");
|
|
444
440
|
if (!e)
|
|
445
|
-
return
|
|
446
|
-
type:
|
|
447
|
-
message:
|
|
441
|
+
return U().showToaster({
|
|
442
|
+
type: O.Error,
|
|
443
|
+
message: M()("discovery-strategy.error-description")
|
|
448
444
|
}), !1;
|
|
449
445
|
e.opener = null, l == null || l();
|
|
450
|
-
let
|
|
451
|
-
const
|
|
452
|
-
document.hidden ||
|
|
446
|
+
let r = !1;
|
|
447
|
+
const n = () => {
|
|
448
|
+
document.hidden || r || (e != null && e.closed && (l == null || l()), r = !0, this.invalidateStrategies(), this.fetchStrategies().then(() => this._refreshAssignedStrategyProducts()).catch(() => {
|
|
453
449
|
}).finally(() => {
|
|
454
|
-
|
|
450
|
+
r = !1;
|
|
455
451
|
}));
|
|
456
452
|
};
|
|
457
|
-
return document.addEventListener("visibilitychange",
|
|
458
|
-
document.removeEventListener("visibilitychange",
|
|
453
|
+
return document.addEventListener("visibilitychange", n), l = () => {
|
|
454
|
+
document.removeEventListener("visibilitychange", n), l = null;
|
|
459
455
|
}, !0;
|
|
460
456
|
},
|
|
461
457
|
/**
|
|
@@ -486,16 +482,16 @@ const X = () => ({
|
|
|
486
482
|
* edited configuration.
|
|
487
483
|
*/
|
|
488
484
|
openStrategyEdit(t) {
|
|
489
|
-
return this._armStrategyPageReturn(
|
|
485
|
+
return this._armStrategyPageReturn(N(t));
|
|
490
486
|
},
|
|
491
487
|
async resolveStrategyUrlTemplate(t, e) {
|
|
492
|
-
const
|
|
493
|
-
if (
|
|
494
|
-
return
|
|
495
|
-
const { full_path: i = "" } = await
|
|
496
|
-
return
|
|
488
|
+
const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
|
|
489
|
+
if (s)
|
|
490
|
+
return s;
|
|
491
|
+
const { full_path: i = "" } = await u.generateStrategyEndpoint(t, e) ?? {};
|
|
492
|
+
return n && i && (this.strategyUrlTemplates = {
|
|
497
493
|
...this.strategyUrlTemplates,
|
|
498
|
-
[
|
|
494
|
+
[n]: i
|
|
499
495
|
}), i;
|
|
500
496
|
},
|
|
501
497
|
assignStrategy(t) {
|
|
@@ -505,27 +501,27 @@ const X = () => ({
|
|
|
505
501
|
});
|
|
506
502
|
},
|
|
507
503
|
async convertLegacyStrategy(t, e = { scope: "campaign" }) {
|
|
508
|
-
const
|
|
509
|
-
if (
|
|
504
|
+
const r = this.currentRecommendationId;
|
|
505
|
+
if (r === null || !this.blockStates[r])
|
|
510
506
|
throw new Error("[Guido] convertLegacyStrategy called without an active block");
|
|
511
|
-
this.blockStates[
|
|
507
|
+
this.blockStates[r].legacyConversionLoading = !0;
|
|
512
508
|
try {
|
|
513
|
-
const
|
|
509
|
+
const n = await u.migrateLegacyStrategy(t, e);
|
|
514
510
|
this.invalidateStrategies();
|
|
515
511
|
try {
|
|
516
512
|
await this.fetchStrategies();
|
|
517
|
-
} catch (
|
|
518
|
-
console.error("[Guido] strategy listing refresh after conversion failed",
|
|
513
|
+
} catch (o) {
|
|
514
|
+
console.error("[Guido] strategy listing refresh after conversion failed", o);
|
|
519
515
|
}
|
|
520
|
-
const
|
|
516
|
+
const s = this.strategies.find((o) => String(o.strategy_id) === n), i = this.blockStates[r];
|
|
521
517
|
return i && (i.recommendationConfigs = {
|
|
522
518
|
...i.recommendationConfigs,
|
|
523
|
-
strategyId:
|
|
519
|
+
strategyId: n,
|
|
524
520
|
nodeConfigVersion: C,
|
|
525
|
-
...(
|
|
526
|
-
}
|
|
521
|
+
...(s == null ? void 0 : s.size) !== void 0 ? { size: String(s.size) } : {}
|
|
522
|
+
}), this.currentRecommendationId === r && this.configVersion++, n;
|
|
527
523
|
} finally {
|
|
528
|
-
this.blockStates[
|
|
524
|
+
this.blockStates[r] && (this.blockStates[r].legacyConversionLoading = !1);
|
|
529
525
|
}
|
|
530
526
|
},
|
|
531
527
|
/**
|
|
@@ -534,14 +530,14 @@ const X = () => ({
|
|
|
534
530
|
* the document never received.
|
|
535
531
|
*/
|
|
536
532
|
revertLegacyConversion(t, e) {
|
|
537
|
-
const
|
|
538
|
-
|
|
533
|
+
const r = this.blockStates[t];
|
|
534
|
+
r && (r.recommendationConfigs = { ...r.recommendationConfigs, ...e }, this.currentRecommendationId === t && this.configVersion++);
|
|
539
535
|
},
|
|
540
536
|
removeStrategy() {
|
|
541
537
|
this.patchCurrentBlockConfig({
|
|
542
538
|
strategyId: "",
|
|
543
539
|
strategy: "",
|
|
544
|
-
size:
|
|
540
|
+
size: j.size,
|
|
545
541
|
nodeConfigVersion: C
|
|
546
542
|
});
|
|
547
543
|
},
|
|
@@ -550,26 +546,26 @@ const X = () => ({
|
|
|
550
546
|
// ====================================================================
|
|
551
547
|
async fetchRecommendationCreateData() {
|
|
552
548
|
if (!this.activePredictiveAlgorithms.length) {
|
|
553
|
-
if (
|
|
554
|
-
await
|
|
549
|
+
if (S) {
|
|
550
|
+
await S;
|
|
555
551
|
return;
|
|
556
552
|
}
|
|
557
|
-
|
|
553
|
+
S = (async () => {
|
|
558
554
|
const {
|
|
559
555
|
activePredictiveAlgorithms: t,
|
|
560
556
|
languages: e,
|
|
561
|
-
currencies:
|
|
562
|
-
} = await
|
|
557
|
+
currencies: r
|
|
558
|
+
} = await u.fetchRecommendationCreateData();
|
|
563
559
|
if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
564
|
-
const
|
|
565
|
-
|
|
560
|
+
const n = this.blockStates[this.currentRecommendationId];
|
|
561
|
+
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
566
562
|
}
|
|
567
|
-
this.currencyList =
|
|
563
|
+
this.currencyList = r;
|
|
568
564
|
})();
|
|
569
565
|
try {
|
|
570
|
-
await
|
|
566
|
+
await S;
|
|
571
567
|
} finally {
|
|
572
|
-
|
|
568
|
+
S = null;
|
|
573
569
|
}
|
|
574
570
|
}
|
|
575
571
|
},
|
|
@@ -580,7 +576,7 @@ const X = () => ({
|
|
|
580
576
|
return;
|
|
581
577
|
}
|
|
582
578
|
y = (async () => {
|
|
583
|
-
const t = await
|
|
579
|
+
const t = await u.fetchRecommendationFilters();
|
|
584
580
|
this.filterList = t;
|
|
585
581
|
})();
|
|
586
582
|
try {
|
|
@@ -601,59 +597,59 @@ const X = () => ({
|
|
|
601
597
|
deleteFilterGroup(t) {
|
|
602
598
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
603
599
|
return;
|
|
604
|
-
const e = this.blockStates[this.currentRecommendationId],
|
|
605
|
-
e.recommendationConfigs.filters =
|
|
600
|
+
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]));
|
|
601
|
+
e.recommendationConfigs.filters = r.map((i) => ({
|
|
606
602
|
...i,
|
|
607
|
-
filterGroup:
|
|
603
|
+
filterGroup: s.get(i.filterGroup) ?? i.filterGroup
|
|
608
604
|
}));
|
|
609
605
|
},
|
|
610
606
|
updateFilter(t) {
|
|
611
607
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
612
608
|
return;
|
|
613
|
-
const e = this.blockStates[this.currentRecommendationId],
|
|
614
|
-
if (
|
|
615
|
-
const
|
|
616
|
-
r
|
|
609
|
+
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
610
|
+
if (r !== -1) {
|
|
611
|
+
const n = [...e.recommendationConfigs.filters];
|
|
612
|
+
n[r] = {
|
|
617
613
|
...t,
|
|
618
|
-
isValid:
|
|
619
|
-
}, e.recommendationConfigs.filters =
|
|
614
|
+
isValid: J(t)
|
|
615
|
+
}, e.recommendationConfigs.filters = n;
|
|
620
616
|
}
|
|
621
617
|
},
|
|
622
618
|
deleteFilter(t) {
|
|
623
619
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
624
620
|
return;
|
|
625
|
-
const e = this.blockStates[this.currentRecommendationId],
|
|
626
|
-
if (
|
|
627
|
-
let
|
|
628
|
-
if (
|
|
621
|
+
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
622
|
+
if (r !== -1) {
|
|
623
|
+
let n = [...e.recommendationConfigs.filters];
|
|
624
|
+
if (n.splice(r, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
|
|
629
625
|
let i = 1;
|
|
630
|
-
|
|
626
|
+
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
631
627
|
} else {
|
|
632
|
-
const i = [...new Set(
|
|
633
|
-
|
|
628
|
+
const i = [...new Set(n.map((a) => a.filterGroup))].sort((a, f) => a - f), o = new Map(i.map((a, f) => [a, f + 1]));
|
|
629
|
+
n = n.map((a) => ({
|
|
634
630
|
...a,
|
|
635
|
-
filterGroup:
|
|
631
|
+
filterGroup: o.get(a.filterGroup) ?? a.filterGroup
|
|
636
632
|
}));
|
|
637
633
|
}
|
|
638
|
-
e.recommendationConfigs.filters =
|
|
634
|
+
e.recommendationConfigs.filters = n;
|
|
639
635
|
}
|
|
640
636
|
},
|
|
641
637
|
addFilter(t) {
|
|
642
638
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
643
639
|
return;
|
|
644
|
-
const e = this.blockStates[this.currentRecommendationId],
|
|
645
|
-
(
|
|
646
|
-
).length + 1, i =
|
|
647
|
-
i !== -1 ?
|
|
640
|
+
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], s = r.filter(
|
|
641
|
+
(o) => o.filterGroup === t.filterGroup
|
|
642
|
+
).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
643
|
+
i !== -1 ? r.splice(i + 1, 0, {
|
|
648
644
|
...t,
|
|
649
|
-
filterNumber:
|
|
650
|
-
}) :
|
|
645
|
+
filterNumber: s
|
|
646
|
+
}) : r.push({
|
|
651
647
|
...t,
|
|
652
|
-
filterNumber:
|
|
653
|
-
}), e.recommendationConfigs.filters =
|
|
648
|
+
filterNumber: s
|
|
649
|
+
}), e.recommendationConfigs.filters = r;
|
|
654
650
|
},
|
|
655
651
|
generateFilterQuery() {
|
|
656
|
-
return
|
|
652
|
+
return G(this.recommendationConfigs.filters);
|
|
657
653
|
},
|
|
658
654
|
/**
|
|
659
655
|
* Validation-only check invoked at save-CTA time. Defined as an action
|
|
@@ -661,77 +657,70 @@ const X = () => ({
|
|
|
661
657
|
* every block's recommendationConfigs across user edits.
|
|
662
658
|
*/
|
|
663
659
|
hasInvalidBlock() {
|
|
664
|
-
return Object.values(this.blockStates).some((t) => !
|
|
660
|
+
return Object.values(this.blockStates).some((t) => !W(t.recommendationConfigs, this));
|
|
665
661
|
},
|
|
666
662
|
/**
|
|
667
663
|
* Which required fields are missing across the design's blocks, so the save
|
|
668
664
|
* toaster can name the cause instead of always showing the generic message.
|
|
669
665
|
*/
|
|
670
666
|
invalidBlockFields() {
|
|
671
|
-
return Object.values(this.blockStates).flatMap((t) =>
|
|
667
|
+
return Object.values(this.blockStates).flatMap((t) => Q(t.recommendationConfigs, this));
|
|
672
668
|
},
|
|
673
669
|
// ====================================================================
|
|
674
670
|
// Per-Block Product Fetching
|
|
675
671
|
// ====================================================================
|
|
676
672
|
async fetchRecommendationProducts() {
|
|
677
|
-
this.currentRecommendationId
|
|
678
|
-
},
|
|
679
|
-
/**
|
|
680
|
-
* Fetches one block's products whether or not it is selected: the panel teardown and the
|
|
681
|
-
* strategy drawer refresh the block they were handed after the user may have moved on.
|
|
682
|
-
*/
|
|
683
|
-
async fetchRecommendationProductsForBlock(t) {
|
|
684
|
-
var i;
|
|
685
|
-
const e = this.blockStates[t];
|
|
686
|
-
if (!e)
|
|
673
|
+
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
687
674
|
return;
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
675
|
+
const t = [
|
|
676
|
+
this.currentRecommendationId,
|
|
677
|
+
this.configVersion,
|
|
678
|
+
b
|
|
679
|
+
].join(":");
|
|
680
|
+
if (p && I === t) {
|
|
681
|
+
await p;
|
|
691
682
|
return;
|
|
692
683
|
}
|
|
693
|
-
|
|
694
|
-
I.set(t, { key: n, promise: o });
|
|
684
|
+
I = t, p = this._doFetchProducts();
|
|
695
685
|
try {
|
|
696
|
-
await
|
|
686
|
+
await p;
|
|
697
687
|
} finally {
|
|
698
|
-
|
|
688
|
+
I === t && (p = null, I = "");
|
|
699
689
|
}
|
|
700
690
|
},
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
await this._doFetchStrategyProducts(e);
|
|
691
|
+
async _doFetchProducts() {
|
|
692
|
+
var h;
|
|
693
|
+
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = R();
|
|
694
|
+
if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
|
|
695
|
+
await this._doFetchStrategyProducts(t);
|
|
707
696
|
return;
|
|
708
697
|
}
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
const
|
|
698
|
+
const s = (m.get(t) ?? 0) + 1;
|
|
699
|
+
m.set(t, s);
|
|
700
|
+
const i = parseInt(r.size) || 6;
|
|
712
701
|
if (!r.strategy) {
|
|
713
|
-
this._setBlockProducts(
|
|
702
|
+
this._setBlockProducts(t, [], i);
|
|
714
703
|
return;
|
|
715
704
|
}
|
|
716
|
-
const
|
|
705
|
+
const o = r.filters.filter((g) => g.isValid), a = G(o), f = ((h = w().find((g) => g.key === r.strategy)) == null ? void 0 : h.path) || "", c = {
|
|
717
706
|
locale: r.language,
|
|
718
707
|
currency: r.currencySettings.value,
|
|
719
|
-
partnerName:
|
|
708
|
+
partnerName: n.partnerName,
|
|
720
709
|
size: r.size,
|
|
721
710
|
details: !0,
|
|
722
|
-
campaignId:
|
|
711
|
+
campaignId: n.variationId
|
|
723
712
|
};
|
|
724
|
-
r.strategy === "manualMerchandising" ? c.productId =
|
|
713
|
+
r.strategy === "manualMerchandising" ? c.productId = H(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), a && (c.filter = a), r.shuffleProducts && (c.shuffle = !0), Object.assign(
|
|
725
714
|
c,
|
|
726
|
-
|
|
715
|
+
K(n.partnerName, r.strategy)
|
|
727
716
|
);
|
|
728
|
-
let
|
|
717
|
+
let d;
|
|
729
718
|
try {
|
|
730
|
-
|
|
719
|
+
d = await u.fetchRecommendationProducts(f, c);
|
|
731
720
|
} catch {
|
|
732
|
-
|
|
721
|
+
d = [];
|
|
733
722
|
}
|
|
734
|
-
|
|
723
|
+
m.get(t) === s && this._setBlockProducts(t, d, i);
|
|
735
724
|
},
|
|
736
725
|
/**
|
|
737
726
|
* Block-scoped counterpart of `fetchRecommendationProducts`, which only serves the selected block:
|
|
@@ -739,8 +728,8 @@ const X = () => ({
|
|
|
739
728
|
* @returns whether real products arrived
|
|
740
729
|
*/
|
|
741
730
|
async fetchStrategyProductsForBlock(t, e = {}) {
|
|
742
|
-
var
|
|
743
|
-
return (
|
|
731
|
+
var r;
|
|
732
|
+
return (r = this.blockStates[t]) != null && r.recommendationConfigs.strategyId ? this._doFetchStrategyProducts(t, e) : !1;
|
|
744
733
|
},
|
|
745
734
|
/**
|
|
746
735
|
* Reloads a block's products and adopts its strategy's current size, which may have
|
|
@@ -748,8 +737,8 @@ const X = () => ({
|
|
|
748
737
|
* @returns whether a fresh listing holds the strategy and its products arrived
|
|
749
738
|
*/
|
|
750
739
|
async refreshStrategyBlock(t) {
|
|
751
|
-
var
|
|
752
|
-
const e = (
|
|
740
|
+
var s;
|
|
741
|
+
const e = (s = this.blockStates[t]) == null ? void 0 : s.recommendationConfigs.strategyId;
|
|
753
742
|
if (!e)
|
|
754
743
|
return !1;
|
|
755
744
|
try {
|
|
@@ -757,53 +746,50 @@ const X = () => ({
|
|
|
757
746
|
} catch {
|
|
758
747
|
return !1;
|
|
759
748
|
}
|
|
760
|
-
const
|
|
761
|
-
if (!
|
|
762
|
-
return !1;
|
|
763
|
-
const r = this.blockStates[t];
|
|
764
|
-
if ((r == null ? void 0 : r.recommendationConfigs.strategyId) !== e)
|
|
749
|
+
const r = this.strategiesFetched ? this.strategies.find((i) => String(i.strategy_id) === e) : void 0;
|
|
750
|
+
if (!r || !await this.fetchStrategyProductsForBlock(t, { keepOnFailure: !0 }))
|
|
765
751
|
return !1;
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
752
|
+
const n = this.blockStates[t];
|
|
753
|
+
return (n == null ? void 0 : n.recommendationConfigs.strategyId) !== e ? !1 : (r.size !== void 0 && (n.recommendationConfigs = {
|
|
754
|
+
...n.recommendationConfigs,
|
|
755
|
+
size: String(r.size)
|
|
756
|
+
}), !0);
|
|
771
757
|
},
|
|
772
758
|
_doFetchStrategyProducts(t, e = {}) {
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
const
|
|
776
|
-
return
|
|
777
|
-
},
|
|
778
|
-
async _loadStrategyProducts(t, e, { keepOnFailure:
|
|
779
|
-
const { recommendationConfigs:
|
|
780
|
-
let
|
|
759
|
+
const r = (m.get(t) ?? 0) + 1;
|
|
760
|
+
m.set(t, r);
|
|
761
|
+
const n = this._loadStrategyProducts(t, r, e);
|
|
762
|
+
return D.set(t, { token: r, outcome: n }), n;
|
|
763
|
+
},
|
|
764
|
+
async _loadStrategyProducts(t, e, { keepOnFailure: r = !1 }) {
|
|
765
|
+
const { recommendationConfigs: n } = this.blockStates[t];
|
|
766
|
+
let s = [], i = parseInt(n.size) || 6;
|
|
781
767
|
try {
|
|
782
768
|
await this.fetchStrategies();
|
|
783
|
-
const
|
|
784
|
-
(a) => String(a.strategy_id) ===
|
|
769
|
+
const o = this.strategies.find(
|
|
770
|
+
(a) => String(a.strategy_id) === n.strategyId
|
|
785
771
|
);
|
|
786
|
-
if (
|
|
787
|
-
i = parseInt(String(
|
|
788
|
-
const a =
|
|
789
|
-
|
|
772
|
+
if (o) {
|
|
773
|
+
i = parseInt(String(o.size ?? "")) || i;
|
|
774
|
+
const a = n.currencySettings.value, c = (await this.resolveStrategyUrlTemplate(o, a)).replaceAll("{locale}", n.language).replaceAll("{currency}", a), d = c.indexOf("?"), h = d === -1 ? c : c.slice(0, d), g = (d === -1 ? "" : c.slice(d + 1)).split("&").filter((F) => F && !F.startsWith("user_id=")), v = g.length ? `${h}?${g.join("&")}` : h;
|
|
775
|
+
v && (s = await u.fetchRecommendationProductsByUrl(v));
|
|
790
776
|
}
|
|
791
777
|
} catch {
|
|
792
|
-
|
|
778
|
+
s = [];
|
|
793
779
|
}
|
|
794
|
-
return
|
|
780
|
+
return m.get(t) !== e ? X(t) : !s.length && r ? !1 : (this._setBlockProducts(t, s, i), s.length > 0);
|
|
795
781
|
},
|
|
796
|
-
_setBlockProducts(t, e,
|
|
782
|
+
_setBlockProducts(t, e, r) {
|
|
797
783
|
if (!this.blockStates[t])
|
|
798
784
|
return;
|
|
799
|
-
const
|
|
785
|
+
const n = e.length > 0 ? e : P(r);
|
|
800
786
|
this.blockStates[t].recommendationProducts = [
|
|
801
|
-
...
|
|
802
|
-
...
|
|
787
|
+
...n.slice(0, r),
|
|
788
|
+
...P(Math.max(0, r - n.length))
|
|
803
789
|
];
|
|
804
790
|
}
|
|
805
791
|
}
|
|
806
792
|
});
|
|
807
793
|
export {
|
|
808
|
-
|
|
794
|
+
St as useRecommendationExtensionStore
|
|
809
795
|
};
|