@useinsider/guido 3.19.0-beta.2854f4f → 3.19.0-beta.3906ea8
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/README.md +21 -3
- package/dist/@types/config/schemas.js +59 -51
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +57 -55
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +3 -3
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +56 -52
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +18 -18
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -26
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/composables/useCustomInterfaceAppearance.js +54 -50
- package/dist/composables/useLegacyStrategyConversion.js +61 -0
- package/dist/enums/extensions/recommendationBlock.js +34 -25
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +73 -72
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +81 -38
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +169 -108
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +10 -10
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +46 -37
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +5 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +76 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/stores/config.d.ts +322 -0
- package/dist/src/stores/onboarding.d.ts +421 -0
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +70 -5
- package/dist/stores/config.js +74 -60
- package/dist/stores/onboarding.js +6 -1
- package/package.json +2 -2
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { useToaster as D } from "../../../../composables/useToaster.js";
|
|
2
|
-
import { useTranslations as
|
|
3
|
-
import { getRecommendationFeedSourceMaps as
|
|
4
|
-
import { ToasterTypeOptions as
|
|
2
|
+
import { useTranslations as L } from "../../../../composables/useTranslations.js";
|
|
3
|
+
import { getRecommendationFeedSourceMaps as F, strategyEditPath as U, URLS as E, getOperatorOptions as N, PriceAttributes as M } from "../../../../enums/extensions/recommendationBlock.js";
|
|
4
|
+
import { ToasterTypeOptions as A } from "../../../../enums/toaster.js";
|
|
5
5
|
import { useRecommendationApi as T } from "../../../../services/recommendationApi.js";
|
|
6
6
|
import { useConfigStore as k } from "../../../../stores/config.js";
|
|
7
7
|
import { defineStore as B } from "pinia";
|
|
8
8
|
import "../constants/selectors.js";
|
|
9
|
-
import { DEFAULT_MOBILE_CARDS_IN_ROW as O, DEFAULT_CARDS_IN_ROW as
|
|
10
|
-
import { DEFAULT_NODE_CONFIG as
|
|
11
|
-
import { getDefaultProducts as
|
|
12
|
-
import { generateCompleteFilterQuery as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
9
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as O, DEFAULT_CARDS_IN_ROW as z } from "../constants/layout.js";
|
|
10
|
+
import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as x, EXCLUDED_ALGORITHM_IDS as V } from "../constants/defaultConfig.js";
|
|
11
|
+
import { getDefaultProducts as w } from "../templates/utils.js";
|
|
12
|
+
import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
|
|
13
|
+
import { isLegacyStrategyConfig as j } from "../utils/legacyStrategyMigration.js";
|
|
14
|
+
import { getPartnerRecommendationParams as $ } from "../utils/partnerCustomizations.js";
|
|
15
|
+
import { sanitizeProductIds as q } from "../utils/productIds.js";
|
|
16
|
+
import { isFilterValid as K } from "../validation/filterSchema.js";
|
|
17
|
+
import { getInvalidFields as H, isConfigValid as J } from "../validation/requiredFields.js";
|
|
18
|
+
const m = T();
|
|
18
19
|
let S = null, p = null, y = null, I = "", R = null, b = 0;
|
|
19
20
|
const g = /* @__PURE__ */ new Map();
|
|
20
21
|
let l = null;
|
|
21
|
-
function
|
|
22
|
+
function _() {
|
|
22
23
|
return {
|
|
23
|
-
cardsInRow:
|
|
24
|
+
cardsInRow: z,
|
|
24
25
|
currencySettings: {
|
|
25
26
|
name: "USD",
|
|
26
27
|
value: "USD",
|
|
@@ -46,6 +47,7 @@ function G() {
|
|
|
46
47
|
// algorithm from the node-config sync or the save-time seed.
|
|
47
48
|
strategy: k().isFeatureEnabled("reusableRecommendationStrategy") ? "" : "mostPopular",
|
|
48
49
|
strategyId: "",
|
|
50
|
+
nodeConfigVersion: C,
|
|
49
51
|
textTrimming: !0,
|
|
50
52
|
unresponsive: !1,
|
|
51
53
|
size: "6",
|
|
@@ -54,21 +56,23 @@ function G() {
|
|
|
54
56
|
priceHideIfSameAsDiscounted: !1
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
|
-
function
|
|
59
|
+
function G() {
|
|
58
60
|
return {
|
|
59
|
-
recommendationConfigs:
|
|
61
|
+
recommendationConfigs: _(),
|
|
60
62
|
recommendationProducts: [],
|
|
61
63
|
filterStatus: !1,
|
|
62
64
|
filterSelectionDrawerStatus: !1,
|
|
63
65
|
assignStrategyDrawerStatus: !1,
|
|
64
66
|
removeStrategyModalStatus: !1,
|
|
67
|
+
legacyStrategyUpdatedModalStatus: !1,
|
|
65
68
|
filterGroup: 1,
|
|
66
69
|
isInitialized: !1,
|
|
67
70
|
filterSnapshot: null,
|
|
68
|
-
syncedConfigFingerprint: null
|
|
71
|
+
syncedConfigFingerprint: null,
|
|
72
|
+
legacyConversionLoading: !1
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
|
-
const
|
|
75
|
+
const Q = () => ({
|
|
72
76
|
recommendationCampaignUrls: {},
|
|
73
77
|
activePredictiveAlgorithms: [],
|
|
74
78
|
languages: {},
|
|
@@ -83,8 +87,8 @@ const H = () => ({
|
|
|
83
87
|
currentRecommendationId: null,
|
|
84
88
|
strategyPanelOpen: !1,
|
|
85
89
|
configVersion: 0
|
|
86
|
-
}),
|
|
87
|
-
state: () =>
|
|
90
|
+
}), ft = B("guidoRecommendationExtension", {
|
|
91
|
+
state: () => Q(),
|
|
88
92
|
getters: {
|
|
89
93
|
// ====================================================================
|
|
90
94
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -94,7 +98,7 @@ const H = () => ({
|
|
|
94
98
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
95
99
|
*/
|
|
96
100
|
recommendationConfigs(t) {
|
|
97
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
101
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : _();
|
|
98
102
|
},
|
|
99
103
|
/**
|
|
100
104
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -114,6 +118,15 @@ const H = () => ({
|
|
|
114
118
|
removeStrategyModalStatus(t) {
|
|
115
119
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
|
|
116
120
|
},
|
|
121
|
+
isLegacyStrategyBlock() {
|
|
122
|
+
return k().isFeatureEnabled("reusableRecommendationStrategy") && j(this.recommendationConfigs);
|
|
123
|
+
},
|
|
124
|
+
legacyConversionLoading(t) {
|
|
125
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading ?? !1 : !1;
|
|
126
|
+
},
|
|
127
|
+
legacyStrategyUpdatedModalStatus(t) {
|
|
128
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyStrategyUpdatedModalStatus : !1;
|
|
129
|
+
},
|
|
117
130
|
assignedStrategy(t) {
|
|
118
131
|
const { strategyId: e } = this.recommendationConfigs;
|
|
119
132
|
return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
|
|
@@ -149,12 +162,12 @@ const H = () => ({
|
|
|
149
162
|
return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
|
|
150
163
|
},
|
|
151
164
|
getActivePredictiveAlgorithms: (t) => {
|
|
152
|
-
const e =
|
|
153
|
-
return t.activePredictiveAlgorithms.filter((
|
|
154
|
-
r.push(...e.filter((s) => s.id ===
|
|
155
|
-
}), r.map((
|
|
156
|
-
text:
|
|
157
|
-
value:
|
|
165
|
+
const e = F(), r = [];
|
|
166
|
+
return t.activePredictiveAlgorithms.filter((n) => !V.includes(n)).forEach((n) => {
|
|
167
|
+
r.push(...e.filter((s) => s.id === n));
|
|
168
|
+
}), r.map((n) => ({
|
|
169
|
+
text: n.name,
|
|
170
|
+
value: n.key
|
|
158
171
|
}));
|
|
159
172
|
},
|
|
160
173
|
getLanguages: (t) => Object.entries(t.languages).map(([e, r]) => ({
|
|
@@ -168,7 +181,7 @@ const H = () => ({
|
|
|
168
181
|
getFilterList() {
|
|
169
182
|
return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
|
|
170
183
|
let e;
|
|
171
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
184
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : M.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
172
185
|
text: t.displayName,
|
|
173
186
|
value: e,
|
|
174
187
|
type: t.attributeType
|
|
@@ -190,7 +203,7 @@ const H = () => ({
|
|
|
190
203
|
setCurrentBlock(t) {
|
|
191
204
|
this.blockStates[t] || (this.blockStates = {
|
|
192
205
|
...this.blockStates,
|
|
193
|
-
[t]:
|
|
206
|
+
[t]: G()
|
|
194
207
|
}), this.currentRecommendationId = t;
|
|
195
208
|
},
|
|
196
209
|
/**
|
|
@@ -200,13 +213,13 @@ const H = () => ({
|
|
|
200
213
|
removeBlockState(t) {
|
|
201
214
|
const e = t.toString();
|
|
202
215
|
if (this.recommendationCampaignUrls[e]) {
|
|
203
|
-
const
|
|
204
|
-
delete
|
|
216
|
+
const n = { ...this.recommendationCampaignUrls };
|
|
217
|
+
delete n[e], this.recommendationCampaignUrls = n;
|
|
205
218
|
}
|
|
206
219
|
const r = { ...this.blockStates };
|
|
207
220
|
if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
|
|
208
|
-
const
|
|
209
|
-
this.currentRecommendationId =
|
|
221
|
+
const n = Object.keys(this.blockStates).map(Number);
|
|
222
|
+
this.currentRecommendationId = n.length > 0 ? n[0] : null;
|
|
210
223
|
}
|
|
211
224
|
},
|
|
212
225
|
/**
|
|
@@ -226,10 +239,10 @@ const H = () => ({
|
|
|
226
239
|
[e]: o
|
|
227
240
|
};
|
|
228
241
|
}
|
|
229
|
-
const
|
|
230
|
-
|
|
242
|
+
const n = t.toString(), s = e.toString(), i = this.recommendationCampaignUrls[n];
|
|
243
|
+
i && (this.recommendationCampaignUrls = {
|
|
231
244
|
...this.recommendationCampaignUrls,
|
|
232
|
-
[s]:
|
|
245
|
+
[s]: i
|
|
233
246
|
});
|
|
234
247
|
},
|
|
235
248
|
/**
|
|
@@ -254,7 +267,7 @@ const H = () => ({
|
|
|
254
267
|
* `isInitialized`) alone.
|
|
255
268
|
*/
|
|
256
269
|
seedBlockUrlConfig(t, e) {
|
|
257
|
-
const r = (o, a) => o === "." || o === "," || o === " " ? o : a,
|
|
270
|
+
const r = (o, a) => o === "." || o === "," || o === " " ? o : a, n = {
|
|
258
271
|
name: e.currencyCode,
|
|
259
272
|
value: e.currencyCode,
|
|
260
273
|
symbol: e.currencySymbol,
|
|
@@ -262,9 +275,9 @@ const H = () => ({
|
|
|
262
275
|
decimalCount: String(e.currencyDecimalCount),
|
|
263
276
|
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
264
277
|
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
265
|
-
}, s = !this.blockStates[t],
|
|
266
|
-
|
|
267
|
-
...
|
|
278
|
+
}, s = !this.blockStates[t], i = s ? G() : this.blockStates[t];
|
|
279
|
+
i.recommendationConfigs = {
|
|
280
|
+
...i.recommendationConfigs,
|
|
268
281
|
strategy: e.strategy,
|
|
269
282
|
strategyId: e.strategyId,
|
|
270
283
|
language: e.language,
|
|
@@ -272,10 +285,10 @@ const H = () => ({
|
|
|
272
285
|
productIds: e.productIds,
|
|
273
286
|
filters: e.filters,
|
|
274
287
|
shuffleProducts: e.shuffleProducts,
|
|
275
|
-
currencySettings:
|
|
288
|
+
currencySettings: n
|
|
276
289
|
}, s && (this.blockStates = {
|
|
277
290
|
...this.blockStates,
|
|
278
|
-
[t]:
|
|
291
|
+
[t]: i
|
|
279
292
|
});
|
|
280
293
|
},
|
|
281
294
|
/**
|
|
@@ -294,18 +307,18 @@ const H = () => ({
|
|
|
294
307
|
...t.currencySettings || {}
|
|
295
308
|
}
|
|
296
309
|
};
|
|
297
|
-
const { triggerRefetch:
|
|
298
|
-
|
|
310
|
+
const { triggerRefetch: n = !0 } = e;
|
|
311
|
+
n && this.configVersion++;
|
|
299
312
|
},
|
|
300
313
|
/**
|
|
301
314
|
* Creates a filter with the first available attribute and operator pre-selected.
|
|
302
315
|
*/
|
|
303
316
|
createDefaultFilter(t, e) {
|
|
304
|
-
const [r] = this.getFilterList, [
|
|
317
|
+
const [r] = this.getFilterList, [n] = N(r == null ? void 0 : r.type);
|
|
305
318
|
return {
|
|
306
319
|
type: "standardFilter",
|
|
307
320
|
attribute: (r == null ? void 0 : r.value) ?? "",
|
|
308
|
-
operator: (
|
|
321
|
+
operator: (n == null ? void 0 : n.value) ?? "",
|
|
309
322
|
innerGroupOperator: "*",
|
|
310
323
|
outerGroupOperator: "*",
|
|
311
324
|
filterNumber: e,
|
|
@@ -354,6 +367,12 @@ const H = () => ({
|
|
|
354
367
|
closeAssignStrategyDrawer() {
|
|
355
368
|
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !1);
|
|
356
369
|
},
|
|
370
|
+
openLegacyStrategyUpdatedModal() {
|
|
371
|
+
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].legacyStrategyUpdatedModalStatus = !0);
|
|
372
|
+
},
|
|
373
|
+
closeLegacyStrategyUpdatedModal() {
|
|
374
|
+
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].legacyStrategyUpdatedModalStatus = !1);
|
|
375
|
+
},
|
|
357
376
|
openRemoveStrategyModal() {
|
|
358
377
|
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].removeStrategyModalStatus = !0);
|
|
359
378
|
},
|
|
@@ -371,7 +390,7 @@ const H = () => ({
|
|
|
371
390
|
const t = b, e = (async () => {
|
|
372
391
|
this.strategiesLoading = !0;
|
|
373
392
|
try {
|
|
374
|
-
const r = await
|
|
393
|
+
const r = await m.fetchRecommendationStrategies();
|
|
375
394
|
if (t !== b)
|
|
376
395
|
return;
|
|
377
396
|
this.strategies = r, this.strategiesFetched = !0;
|
|
@@ -416,19 +435,19 @@ const H = () => ({
|
|
|
416
435
|
const e = window.open(t, "_blank");
|
|
417
436
|
if (!e)
|
|
418
437
|
return D().showToaster({
|
|
419
|
-
type:
|
|
420
|
-
message:
|
|
438
|
+
type: A.Error,
|
|
439
|
+
message: L()("discovery-strategy.error-description")
|
|
421
440
|
}), !1;
|
|
422
441
|
e.opener = null, l == null || l();
|
|
423
442
|
let r = !1;
|
|
424
|
-
const
|
|
443
|
+
const n = () => {
|
|
425
444
|
document.hidden || r || (e != null && e.closed && (l == null || l()), r = !0, this.invalidateStrategies(), this.fetchStrategies().then(() => this._refreshAssignedStrategyProducts()).catch(() => {
|
|
426
445
|
}).finally(() => {
|
|
427
446
|
r = !1;
|
|
428
447
|
}));
|
|
429
448
|
};
|
|
430
|
-
return document.addEventListener("visibilitychange",
|
|
431
|
-
document.removeEventListener("visibilitychange",
|
|
449
|
+
return document.addEventListener("visibilitychange", n), l = () => {
|
|
450
|
+
document.removeEventListener("visibilitychange", n), l = null;
|
|
432
451
|
}, !0;
|
|
433
452
|
},
|
|
434
453
|
/**
|
|
@@ -459,17 +478,17 @@ const H = () => ({
|
|
|
459
478
|
* edited configuration.
|
|
460
479
|
*/
|
|
461
480
|
openStrategyEdit(t) {
|
|
462
|
-
return this._armStrategyPageReturn(
|
|
481
|
+
return this._armStrategyPageReturn(U(t));
|
|
463
482
|
},
|
|
464
483
|
async resolveStrategyUrlTemplate(t, e) {
|
|
465
|
-
const r = typeof t.updated_at == "string" ? t.updated_at : "",
|
|
484
|
+
const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
|
|
466
485
|
if (s)
|
|
467
486
|
return s;
|
|
468
|
-
const { full_path:
|
|
469
|
-
return
|
|
487
|
+
const { full_path: i = "" } = await m.generateStrategyEndpoint(t, e) ?? {};
|
|
488
|
+
return n && i && (this.strategyUrlTemplates = {
|
|
470
489
|
...this.strategyUrlTemplates,
|
|
471
|
-
[
|
|
472
|
-
}),
|
|
490
|
+
[n]: i
|
|
491
|
+
}), i;
|
|
473
492
|
},
|
|
474
493
|
assignStrategy(t) {
|
|
475
494
|
this.patchCurrentBlockConfig({
|
|
@@ -477,11 +496,44 @@ const H = () => ({
|
|
|
477
496
|
...t.size !== void 0 ? { size: String(t.size) } : {}
|
|
478
497
|
});
|
|
479
498
|
},
|
|
499
|
+
async convertLegacyStrategy(t, e = { scope: "campaign" }) {
|
|
500
|
+
const r = this.currentRecommendationId;
|
|
501
|
+
if (r === null || !this.blockStates[r])
|
|
502
|
+
throw new Error("[Guido] convertLegacyStrategy called without an active block");
|
|
503
|
+
this.blockStates[r].legacyConversionLoading = !0;
|
|
504
|
+
try {
|
|
505
|
+
const n = await m.migrateLegacyStrategy(t, e);
|
|
506
|
+
try {
|
|
507
|
+
await this.fetchStrategies();
|
|
508
|
+
} catch (o) {
|
|
509
|
+
console.error("[Guido] strategy listing refresh after conversion failed", o);
|
|
510
|
+
}
|
|
511
|
+
const s = this.strategies.find((o) => String(o.strategy_id) === n), i = this.blockStates[r];
|
|
512
|
+
return i && (i.recommendationConfigs = {
|
|
513
|
+
...i.recommendationConfigs,
|
|
514
|
+
strategyId: n,
|
|
515
|
+
nodeConfigVersion: C,
|
|
516
|
+
...(s == null ? void 0 : s.size) !== void 0 ? { size: String(s.size) } : {}
|
|
517
|
+
}), this.currentRecommendationId === r && this.configVersion++, n;
|
|
518
|
+
} finally {
|
|
519
|
+
this.blockStates[r] && (this.blockStates[r].legacyConversionLoading = !1);
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
/**
|
|
523
|
+
* Undoes the config half of a conversion whose document write never landed, so the
|
|
524
|
+
* panel and the drawer fall back to "Legacy Strategy" instead of showing an assignment
|
|
525
|
+
* the document never received.
|
|
526
|
+
*/
|
|
527
|
+
revertLegacyConversion(t, e) {
|
|
528
|
+
const r = this.blockStates[t];
|
|
529
|
+
r && (r.recommendationConfigs = { ...r.recommendationConfigs, ...e }, this.currentRecommendationId === t && this.configVersion++);
|
|
530
|
+
},
|
|
480
531
|
removeStrategy() {
|
|
481
532
|
this.patchCurrentBlockConfig({
|
|
482
533
|
strategyId: "",
|
|
483
534
|
strategy: "",
|
|
484
|
-
size:
|
|
535
|
+
size: x.size,
|
|
536
|
+
nodeConfigVersion: C
|
|
485
537
|
});
|
|
486
538
|
},
|
|
487
539
|
// ====================================================================
|
|
@@ -498,10 +550,10 @@ const H = () => ({
|
|
|
498
550
|
activePredictiveAlgorithms: t,
|
|
499
551
|
languages: e,
|
|
500
552
|
currencies: r
|
|
501
|
-
} = await
|
|
553
|
+
} = await m.fetchRecommendationCreateData();
|
|
502
554
|
if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
503
|
-
const
|
|
504
|
-
|
|
555
|
+
const n = this.blockStates[this.currentRecommendationId];
|
|
556
|
+
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
505
557
|
}
|
|
506
558
|
this.currencyList = r;
|
|
507
559
|
})();
|
|
@@ -519,7 +571,7 @@ const H = () => ({
|
|
|
519
571
|
return;
|
|
520
572
|
}
|
|
521
573
|
p = (async () => {
|
|
522
|
-
const t = await
|
|
574
|
+
const t = await m.fetchRecommendationFilters();
|
|
523
575
|
this.filterList = t;
|
|
524
576
|
})();
|
|
525
577
|
try {
|
|
@@ -540,41 +592,41 @@ const H = () => ({
|
|
|
540
592
|
deleteFilterGroup(t) {
|
|
541
593
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
542
594
|
return;
|
|
543
|
-
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.filter((
|
|
544
|
-
e.recommendationConfigs.filters = r.map((
|
|
545
|
-
...
|
|
546
|
-
filterGroup: s.get(
|
|
595
|
+
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]));
|
|
596
|
+
e.recommendationConfigs.filters = r.map((i) => ({
|
|
597
|
+
...i,
|
|
598
|
+
filterGroup: s.get(i.filterGroup) ?? i.filterGroup
|
|
547
599
|
}));
|
|
548
600
|
},
|
|
549
601
|
updateFilter(t) {
|
|
550
602
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
551
603
|
return;
|
|
552
|
-
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((
|
|
604
|
+
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
553
605
|
if (r !== -1) {
|
|
554
|
-
const
|
|
555
|
-
|
|
606
|
+
const n = [...e.recommendationConfigs.filters];
|
|
607
|
+
n[r] = {
|
|
556
608
|
...t,
|
|
557
|
-
isValid:
|
|
558
|
-
}, e.recommendationConfigs.filters =
|
|
609
|
+
isValid: K(t)
|
|
610
|
+
}, e.recommendationConfigs.filters = n;
|
|
559
611
|
}
|
|
560
612
|
},
|
|
561
613
|
deleteFilter(t) {
|
|
562
614
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
563
615
|
return;
|
|
564
|
-
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((
|
|
616
|
+
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
565
617
|
if (r !== -1) {
|
|
566
|
-
let
|
|
567
|
-
if (
|
|
568
|
-
let
|
|
569
|
-
|
|
618
|
+
let n = [...e.recommendationConfigs.filters];
|
|
619
|
+
if (n.splice(r, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
|
|
620
|
+
let i = 1;
|
|
621
|
+
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
570
622
|
} else {
|
|
571
|
-
const
|
|
572
|
-
|
|
623
|
+
const i = [...new Set(n.map((a) => a.filterGroup))].sort((a, d) => a - d), o = new Map(i.map((a, d) => [a, d + 1]));
|
|
624
|
+
n = n.map((a) => ({
|
|
573
625
|
...a,
|
|
574
626
|
filterGroup: o.get(a.filterGroup) ?? a.filterGroup
|
|
575
627
|
}));
|
|
576
628
|
}
|
|
577
|
-
e.recommendationConfigs.filters =
|
|
629
|
+
e.recommendationConfigs.filters = n;
|
|
578
630
|
}
|
|
579
631
|
},
|
|
580
632
|
addFilter(t) {
|
|
@@ -582,8 +634,8 @@ const H = () => ({
|
|
|
582
634
|
return;
|
|
583
635
|
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], s = r.filter(
|
|
584
636
|
(o) => o.filterGroup === t.filterGroup
|
|
585
|
-
).length + 1,
|
|
586
|
-
|
|
637
|
+
).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
638
|
+
i !== -1 ? r.splice(i + 1, 0, {
|
|
587
639
|
...t,
|
|
588
640
|
filterNumber: s
|
|
589
641
|
}) : r.push({
|
|
@@ -592,7 +644,7 @@ const H = () => ({
|
|
|
592
644
|
}), e.recommendationConfigs.filters = r;
|
|
593
645
|
},
|
|
594
646
|
generateFilterQuery() {
|
|
595
|
-
return
|
|
647
|
+
return P(this.recommendationConfigs.filters);
|
|
596
648
|
},
|
|
597
649
|
/**
|
|
598
650
|
* Validation-only check invoked at save-CTA time. Defined as an action
|
|
@@ -600,14 +652,14 @@ const H = () => ({
|
|
|
600
652
|
* every block's recommendationConfigs across user edits.
|
|
601
653
|
*/
|
|
602
654
|
hasInvalidBlock() {
|
|
603
|
-
return Object.values(this.blockStates).some((t) => !
|
|
655
|
+
return Object.values(this.blockStates).some((t) => !J(t.recommendationConfigs, this));
|
|
604
656
|
},
|
|
605
657
|
/**
|
|
606
658
|
* Which required fields are missing across the design's blocks, so the save
|
|
607
659
|
* toaster can name the cause instead of always showing the generic message.
|
|
608
660
|
*/
|
|
609
661
|
invalidBlockFields() {
|
|
610
|
-
return Object.values(this.blockStates).flatMap((t) =>
|
|
662
|
+
return Object.values(this.blockStates).flatMap((t) => H(t.recommendationConfigs, this));
|
|
611
663
|
},
|
|
612
664
|
// ====================================================================
|
|
613
665
|
// Per-Block Product Fetching
|
|
@@ -633,69 +685,78 @@ const H = () => ({
|
|
|
633
685
|
},
|
|
634
686
|
async _doFetchProducts() {
|
|
635
687
|
var h;
|
|
636
|
-
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e,
|
|
637
|
-
if (r.strategyId &&
|
|
688
|
+
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = k();
|
|
689
|
+
if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
|
|
638
690
|
await this._doFetchStrategyProducts(t);
|
|
639
691
|
return;
|
|
640
692
|
}
|
|
641
693
|
const s = (g.get(t) ?? 0) + 1;
|
|
642
694
|
g.set(t, s);
|
|
643
|
-
const
|
|
695
|
+
const i = parseInt(r.size) || 6;
|
|
644
696
|
if (!r.strategy) {
|
|
645
|
-
this._setBlockProducts(t, [],
|
|
697
|
+
this._setBlockProducts(t, [], i);
|
|
646
698
|
return;
|
|
647
699
|
}
|
|
648
|
-
const o = r.filters.filter((
|
|
700
|
+
const o = r.filters.filter((f) => f.isValid), a = P(o), d = ((h = F().find((f) => f.key === r.strategy)) == null ? void 0 : h.path) || "", c = {
|
|
649
701
|
locale: r.language,
|
|
650
702
|
currency: r.currencySettings.value,
|
|
651
|
-
partnerName:
|
|
703
|
+
partnerName: n.partnerName,
|
|
652
704
|
size: r.size,
|
|
653
705
|
details: !0,
|
|
654
|
-
campaignId:
|
|
706
|
+
campaignId: n.variationId
|
|
655
707
|
};
|
|
656
|
-
r.strategy === "manualMerchandising" ? c.productId =
|
|
708
|
+
r.strategy === "manualMerchandising" ? c.productId = q(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(
|
|
657
709
|
c,
|
|
658
|
-
|
|
710
|
+
$(n.partnerName, r.strategy)
|
|
659
711
|
);
|
|
660
712
|
let u;
|
|
661
713
|
try {
|
|
662
|
-
u = await
|
|
714
|
+
u = await m.fetchRecommendationProducts(d, c);
|
|
663
715
|
} catch {
|
|
664
716
|
u = [];
|
|
665
717
|
}
|
|
666
|
-
g.get(t) === s && this._setBlockProducts(t, u,
|
|
718
|
+
g.get(t) === s && this._setBlockProducts(t, u, i);
|
|
719
|
+
},
|
|
720
|
+
/**
|
|
721
|
+
* Block-scoped counterpart of `fetchRecommendationProducts`, which only ever serves the
|
|
722
|
+
* selected block. The legacy conversion must refresh the products of the block that
|
|
723
|
+
* started it even after the user selected another one.
|
|
724
|
+
*/
|
|
725
|
+
async fetchStrategyProductsForBlock(t) {
|
|
726
|
+
var e;
|
|
727
|
+
(e = this.blockStates[t]) != null && e.recommendationConfigs.strategyId && await this._doFetchStrategyProducts(t);
|
|
667
728
|
},
|
|
668
729
|
async _doFetchStrategyProducts(t) {
|
|
669
730
|
const e = (g.get(t) ?? 0) + 1;
|
|
670
731
|
g.set(t, e);
|
|
671
732
|
const { recommendationConfigs: r } = this.blockStates[t];
|
|
672
|
-
let
|
|
733
|
+
let n = [], s = parseInt(r.size) || 6;
|
|
673
734
|
try {
|
|
674
735
|
await this.fetchStrategies();
|
|
675
|
-
const
|
|
736
|
+
const i = this.strategies.find(
|
|
676
737
|
(o) => String(o.strategy_id) === r.strategyId
|
|
677
738
|
);
|
|
678
|
-
if (
|
|
679
|
-
s = parseInt(String(
|
|
680
|
-
const o = r.currencySettings.value,
|
|
681
|
-
|
|
739
|
+
if (i) {
|
|
740
|
+
s = parseInt(String(i.size ?? "")) || s;
|
|
741
|
+
const o = r.currencySettings.value, d = (await this.resolveStrategyUrlTemplate(i, o)).replaceAll("{locale}", r.language).replaceAll("{currency}", o), c = d.indexOf("?"), u = c === -1 ? d : d.slice(0, c), h = (c === -1 ? "" : d.slice(c + 1)).split("&").filter((v) => v && !v.startsWith("user_id=")), f = h.length ? `${u}?${h.join("&")}` : u;
|
|
742
|
+
f && (n = await m.fetchRecommendationProductsByUrl(f));
|
|
682
743
|
}
|
|
683
744
|
} catch {
|
|
684
|
-
|
|
745
|
+
n = [];
|
|
685
746
|
}
|
|
686
|
-
g.get(t) === e && this._setBlockProducts(t,
|
|
747
|
+
g.get(t) === e && this._setBlockProducts(t, n, s);
|
|
687
748
|
},
|
|
688
749
|
_setBlockProducts(t, e, r) {
|
|
689
750
|
if (!this.blockStates[t])
|
|
690
751
|
return;
|
|
691
|
-
const
|
|
752
|
+
const n = e.length > 0 ? e : w(r);
|
|
692
753
|
this.blockStates[t].recommendationProducts = [
|
|
693
|
-
...
|
|
694
|
-
...
|
|
754
|
+
...n.slice(0, r),
|
|
755
|
+
...w(Math.max(0, r - n.length))
|
|
695
756
|
];
|
|
696
757
|
}
|
|
697
758
|
}
|
|
698
759
|
});
|
|
699
760
|
export {
|
|
700
|
-
|
|
761
|
+
ft as useRecommendationExtensionStore
|
|
701
762
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "../constants/selectors.js";
|
|
2
|
+
import { RRS_CONFIG_VERSION as m } from "../constants/defaultConfig.js";
|
|
3
|
+
import { sanitizeProductIds as p } from "./productIds.js";
|
|
4
|
+
const d = "manualMerchandising";
|
|
5
|
+
function N({ strategyId: e, nodeConfigVersion: t }) {
|
|
6
|
+
return !e && t < m;
|
|
7
|
+
}
|
|
8
|
+
const o = (e) => {
|
|
9
|
+
const t = String(e ?? "").trim();
|
|
10
|
+
return /^[1-9]\d*$/.test(t) ? t : null;
|
|
11
|
+
};
|
|
12
|
+
function f({ campaignId: e, templateLibraryId: t }) {
|
|
13
|
+
if (o(e))
|
|
14
|
+
return { scope: "campaign" };
|
|
15
|
+
const n = o(t);
|
|
16
|
+
return n ? { scope: "template", templateId: n } : { scope: "campaign" };
|
|
17
|
+
}
|
|
18
|
+
function y({
|
|
19
|
+
blockId: e,
|
|
20
|
+
url: t,
|
|
21
|
+
campaignId: n,
|
|
22
|
+
variationId: a,
|
|
23
|
+
strategy: c,
|
|
24
|
+
productIds: s,
|
|
25
|
+
target: r
|
|
26
|
+
}) {
|
|
27
|
+
const i = c === d ? p(s).split(",").filter(Boolean) : [];
|
|
28
|
+
return {
|
|
29
|
+
...r.scope === "template" ? { templateId: Number.parseInt(r.templateId) } : {
|
|
30
|
+
campaignId: Number.parseInt(n) || 0,
|
|
31
|
+
variationId: Number.parseInt(a) || 0
|
|
32
|
+
},
|
|
33
|
+
blockId: String(e),
|
|
34
|
+
url: t,
|
|
35
|
+
...i.length ? { productIds: i } : {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
y as buildLegacyMigrationPayload,
|
|
40
|
+
N as isLegacyStrategyConfig,
|
|
41
|
+
f as resolveMigrationTarget
|
|
42
|
+
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { useRecommendationExtensionStore as
|
|
2
|
-
import { commitBlockChangeOutsidePanel as
|
|
3
|
-
async function
|
|
4
|
-
const t =
|
|
1
|
+
import { useRecommendationExtensionStore as d } from "../store/recommendation.js";
|
|
2
|
+
import { commitBlockChangeOutsidePanel as f } from "./nodeConfigWriter.js";
|
|
3
|
+
async function h(e, r) {
|
|
4
|
+
const t = d(), o = t.blockStates[e];
|
|
5
5
|
if (!o)
|
|
6
6
|
return !1;
|
|
7
|
-
const { strategyId: a, strategy: c, size: i } = o.recommendationConfigs;
|
|
7
|
+
const { strategyId: a, strategy: c, size: i, nodeConfigVersion: s } = o.recommendationConfigs;
|
|
8
8
|
if (t.currentRecommendationId === e)
|
|
9
9
|
try {
|
|
10
10
|
await t.fetchRecommendationProducts();
|
|
11
11
|
} catch (m) {
|
|
12
12
|
console.error("[recommendation] product refetch after a strategy change failed", m);
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const n = f(
|
|
15
15
|
e,
|
|
16
|
-
{ strategyId: a, strategy: c, size: i },
|
|
16
|
+
{ strategyId: a, strategy: c, size: i, configVersion: s },
|
|
17
17
|
o.recommendationProducts,
|
|
18
|
-
|
|
18
|
+
r
|
|
19
19
|
);
|
|
20
|
-
return
|
|
20
|
+
return n || console.error("[recommendation] strategy change did not reach a node", { blockId: e }), n;
|
|
21
21
|
}
|
|
22
22
|
export {
|
|
23
|
-
|
|
23
|
+
h as commitStrategyChange
|
|
24
24
|
};
|