@useinsider/guido 3.16.0-beta.ff4f1bd → 3.16.1-beta.626490d
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 +0 -1
- package/dist/@types/config/schemas.js +6 -12
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +30 -31
- package/dist/composables/useRecommendation.js +36 -43
- package/dist/config/migrator/recommendationMigrator.js +4 -6
- package/dist/enums/extensions/recommendationBlock.js +23 -25
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +11 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +90 -112
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +53 -188
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +28 -77
- package/dist/src/@types/config/schemas.d.ts +0 -12
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/composables/useRecommendation.d.ts +0 -1
- package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -6
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +10 -199
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -6
- package/dist/src/services/recommendationApi.d.ts +1 -4
- package/dist/src/stores/config.d.ts +0 -18
- package/dist/utils/templatePreparation.js +34 -37
- package/package.json +1 -2
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +0 -18
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +0 -61
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +0 -106
- package/dist/node_modules/@useinsider/design-system-organisms/dist/index-5JHlb8rM.js +0 -524
- package/dist/node_modules/@useinsider/design-system-organisms/dist/index.js +0 -8450
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InAccordion.js +0 -174
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InBasicTextInput.js +0 -381
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InBox.js +0 -236
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InBulkActions.js +0 -70
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InButton.js +0 -350
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InButtonV2.js +0 -371
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InCheckBox.js +0 -152
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InChips.js +0 -141
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InCustomDropDown.js +0 -1047
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InDataTableV2.js +0 -96050
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InDatePicker.js +0 -2042
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InDrawer.js +0 -166
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InDropDown.js +0 -1098
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InIcons.js +0 -55
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InInfoBox.js +0 -265
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InLinks.js +0 -184
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InLoading.js +0 -50
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InModals.js +0 -453
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InNoData.js +0 -145
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InOnPageMessage.js +0 -176
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InProgress.js +0 -266
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InRadioButton.js +0 -114
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InSegments.js +0 -200
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InSelect.js +0 -451
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InSkeleton.js +0 -49
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InStatusText.js +0 -119
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTabs.js +0 -4309
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTagsText.js +0 -129
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTextInput.js +0 -503
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InToasts.js +0 -253
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InToggle.js +0 -107
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTooltip.js +0 -134
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTooltipV2.js +0 -464
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/_commonjsHelpers.BItOPCY9.js +0 -28
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/_plugin-vue2_normalizer.WQT2Fc8L.js +0 -23
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/clickOutside.qP9M0QCm.js +0 -29
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/helpers.CgHNyjAJ.js +0 -109
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/index.Bw_06igr.js +0 -2339
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/localLocalesMixin.DYMhydo2.js +0 -16
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/useLocalLocales.Ckuhy7d-.js +0 -17
- package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/vue-property-decorator.BtlM7Epa.js +0 -188
- package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -26
- package/dist/src/mock/api/recommendation-strategies.d.ts +0 -41
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as
|
|
2
|
-
import { useRecommendationApi as
|
|
3
|
-
import { useConfigStore as
|
|
4
|
-
import { defineStore as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as C } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as G } 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 { EXCLUDED_ALGORITHM_IDS as
|
|
8
|
-
import { getDefaultProducts as
|
|
6
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as P, DEFAULT_CARDS_IN_ROW as D } from "../constants/layout.js";
|
|
7
|
+
import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
|
|
8
|
+
import { getDefaultProducts as S } from "../templates/utils.js";
|
|
9
9
|
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
10
|
-
import { getPartnerRecommendationParams as
|
|
11
|
-
import { isFilterValid as
|
|
12
|
-
import { isConfigValid as
|
|
13
|
-
const
|
|
14
|
-
let m = null, u = null, d = null
|
|
10
|
+
import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
|
|
11
|
+
import { isFilterValid as N } from "../validation/filterSchema.js";
|
|
12
|
+
import { isConfigValid as x } from "../validation/requiredFields.js";
|
|
13
|
+
const h = y();
|
|
14
|
+
let m = null, u = null, d = null;
|
|
15
15
|
function k() {
|
|
16
16
|
return {
|
|
17
|
-
cardsInRow:
|
|
17
|
+
cardsInRow: D,
|
|
18
18
|
currencySettings: {
|
|
19
19
|
name: "USD",
|
|
20
20
|
value: "USD",
|
|
@@ -28,14 +28,13 @@ function k() {
|
|
|
28
28
|
productIds: [],
|
|
29
29
|
id: 1,
|
|
30
30
|
language: "en_US",
|
|
31
|
-
mobileCardsInRow:
|
|
31
|
+
mobileCardsInRow: P,
|
|
32
32
|
mobileLayoutEnabled: !1,
|
|
33
33
|
orientation: "grid",
|
|
34
34
|
recommendedProducts: [],
|
|
35
35
|
sendProductRequestFlag: !1,
|
|
36
36
|
shuffleProducts: !1,
|
|
37
37
|
strategy: "mostPopular",
|
|
38
|
-
strategyId: "",
|
|
39
38
|
textTrimming: !0,
|
|
40
39
|
unresponsive: !1,
|
|
41
40
|
size: "6",
|
|
@@ -50,26 +49,22 @@ function I() {
|
|
|
50
49
|
recommendationProducts: [],
|
|
51
50
|
filterStatus: !1,
|
|
52
51
|
filterSelectionDrawerStatus: !1,
|
|
53
|
-
assignStrategyDrawerStatus: !1,
|
|
54
52
|
filterGroup: 1,
|
|
55
53
|
isInitialized: !1,
|
|
56
54
|
filterSnapshot: null
|
|
57
55
|
};
|
|
58
56
|
}
|
|
59
|
-
const
|
|
57
|
+
const L = () => ({
|
|
60
58
|
recommendationCampaignUrls: {},
|
|
61
59
|
activePredictiveAlgorithms: [],
|
|
62
60
|
languages: {},
|
|
63
61
|
currencyList: [],
|
|
64
62
|
filterList: {},
|
|
65
|
-
strategies: [],
|
|
66
|
-
strategiesLoading: !1,
|
|
67
|
-
strategyUrlTemplates: {},
|
|
68
63
|
blockStates: {},
|
|
69
64
|
currentRecommendationId: null,
|
|
70
65
|
configVersion: 0
|
|
71
|
-
}),
|
|
72
|
-
state: () =>
|
|
66
|
+
}), $ = F("guidoRecommendationExtension", {
|
|
67
|
+
state: () => L(),
|
|
73
68
|
getters: {
|
|
74
69
|
// ====================================================================
|
|
75
70
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -93,20 +88,6 @@ const N = () => ({
|
|
|
93
88
|
filterSelectionDrawerStatus(t) {
|
|
94
89
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterSelectionDrawerStatus : !1;
|
|
95
90
|
},
|
|
96
|
-
/**
|
|
97
|
-
* Proxy getter: delegates to blockStates[currentRecommendationId].assignStrategyDrawerStatus
|
|
98
|
-
*/
|
|
99
|
-
assignStrategyDrawerStatus(t) {
|
|
100
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].assignStrategyDrawerStatus : !1;
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* The current block's assigned strategy record from the listing,
|
|
104
|
-
* or null when nothing is assigned / the strategy is no longer listed.
|
|
105
|
-
*/
|
|
106
|
-
assignedStrategy(t) {
|
|
107
|
-
const { strategyId: e } = this.recommendationConfigs;
|
|
108
|
-
return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
|
|
109
|
-
},
|
|
110
91
|
/**
|
|
111
92
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
|
|
112
93
|
*/
|
|
@@ -138,9 +119,9 @@ const N = () => ({
|
|
|
138
119
|
return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
|
|
139
120
|
},
|
|
140
121
|
getActivePredictiveAlgorithms: (t) => {
|
|
141
|
-
const e =
|
|
142
|
-
return t.activePredictiveAlgorithms.filter((n) => !
|
|
143
|
-
r.push(...e.filter((
|
|
122
|
+
const e = g(), r = [];
|
|
123
|
+
return t.activePredictiveAlgorithms.filter((n) => !w.includes(n)).forEach((n) => {
|
|
124
|
+
r.push(...e.filter((c) => c.id === n));
|
|
144
125
|
}), r.map((n) => ({
|
|
145
126
|
text: n.name,
|
|
146
127
|
value: n.key
|
|
@@ -211,10 +192,10 @@ const N = () => ({
|
|
|
211
192
|
[e]: o
|
|
212
193
|
};
|
|
213
194
|
}
|
|
214
|
-
const n = t.toString(),
|
|
195
|
+
const n = t.toString(), c = e.toString(), i = this.recommendationCampaignUrls[n];
|
|
215
196
|
i && (this.recommendationCampaignUrls = {
|
|
216
197
|
...this.recommendationCampaignUrls,
|
|
217
|
-
[
|
|
198
|
+
[c]: i
|
|
218
199
|
});
|
|
219
200
|
},
|
|
220
201
|
/**
|
|
@@ -239,7 +220,7 @@ const N = () => ({
|
|
|
239
220
|
* `isInitialized`) alone.
|
|
240
221
|
*/
|
|
241
222
|
seedBlockUrlConfig(t, e) {
|
|
242
|
-
const r = (o,
|
|
223
|
+
const r = (o, s) => o === "." || o === "," || o === " " ? o : s, n = {
|
|
243
224
|
name: e.currencyCode,
|
|
244
225
|
value: e.currencyCode,
|
|
245
226
|
symbol: e.currencyCode,
|
|
@@ -247,18 +228,17 @@ const N = () => ({
|
|
|
247
228
|
decimalCount: String(e.currencyDecimalCount),
|
|
248
229
|
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
249
230
|
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
250
|
-
},
|
|
231
|
+
}, c = !this.blockStates[t], i = c ? I() : this.blockStates[t];
|
|
251
232
|
i.recommendationConfigs = {
|
|
252
233
|
...i.recommendationConfigs,
|
|
253
234
|
strategy: e.strategy,
|
|
254
|
-
strategyId: e.strategyId,
|
|
255
235
|
language: e.language,
|
|
256
236
|
size: e.size,
|
|
257
237
|
productIds: e.productIds,
|
|
258
238
|
filters: e.filters,
|
|
259
239
|
shuffleProducts: e.shuffleProducts,
|
|
260
240
|
currencySettings: n
|
|
261
|
-
},
|
|
241
|
+
}, c && (this.blockStates = {
|
|
262
242
|
...this.blockStates,
|
|
263
243
|
[t]: i
|
|
264
244
|
});
|
|
@@ -334,78 +314,6 @@ const N = () => ({
|
|
|
334
314
|
t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
|
|
335
315
|
},
|
|
336
316
|
// ====================================================================
|
|
337
|
-
// Reusable Recommendation Strategy (SD-149105)
|
|
338
|
-
// ====================================================================
|
|
339
|
-
/**
|
|
340
|
-
* Opens the Assign Strategy drawer for the current block.
|
|
341
|
-
* Selection state lives in the drawer component until Assign is
|
|
342
|
-
* pressed, so closing without assigning needs no snapshot/revert.
|
|
343
|
-
*/
|
|
344
|
-
openAssignStrategyDrawer() {
|
|
345
|
-
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !0);
|
|
346
|
-
},
|
|
347
|
-
closeAssignStrategyDrawer() {
|
|
348
|
-
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !1);
|
|
349
|
-
},
|
|
350
|
-
/**
|
|
351
|
-
* Fetches the active + EMAIL strategy listing. Always fetches fresh
|
|
352
|
-
* (dead-strategy detection and post-create refresh need freshness);
|
|
353
|
-
* only concurrent in-flight calls share one request.
|
|
354
|
-
*/
|
|
355
|
-
async fetchStrategies() {
|
|
356
|
-
if (f) {
|
|
357
|
-
await f;
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
f = (async () => {
|
|
361
|
-
this.strategiesLoading = !0;
|
|
362
|
-
try {
|
|
363
|
-
this.strategies = await l.fetchRecommendationStrategies();
|
|
364
|
-
} finally {
|
|
365
|
-
this.strategiesLoading = !1;
|
|
366
|
-
}
|
|
367
|
-
})();
|
|
368
|
-
try {
|
|
369
|
-
await f;
|
|
370
|
-
} finally {
|
|
371
|
-
f = null;
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
/**
|
|
375
|
-
* Resolves a strategy's recommendation endpoint template via
|
|
376
|
-
* endpoint-generate, cached per strategy id. Failures throw and are
|
|
377
|
-
* NOT cached, so the next attempt retries.
|
|
378
|
-
*/
|
|
379
|
-
async resolveStrategyUrlTemplate(t) {
|
|
380
|
-
const e = String(t.strategy_id), r = this.strategyUrlTemplates[e];
|
|
381
|
-
if (r)
|
|
382
|
-
return r;
|
|
383
|
-
const { full_path: n } = await l.generateStrategyEndpoint(t);
|
|
384
|
-
return this.strategyUrlTemplates = {
|
|
385
|
-
...this.strategyUrlTemplates,
|
|
386
|
-
[e]: n
|
|
387
|
-
}, n;
|
|
388
|
-
},
|
|
389
|
-
/**
|
|
390
|
-
* Assigns a strategy to the current block. The config write is
|
|
391
|
-
* synchronous (before any await) so a block switch cannot misdirect
|
|
392
|
-
* it; the configVersion bump persists it to node config and triggers
|
|
393
|
-
* the product refetch via the coordinator control's subscription.
|
|
394
|
-
*/
|
|
395
|
-
assignStrategy(t) {
|
|
396
|
-
this.patchCurrentBlockConfig({
|
|
397
|
-
strategyId: String(t.strategy_id),
|
|
398
|
-
...t.size !== void 0 ? { size: String(t.size) } : {}
|
|
399
|
-
});
|
|
400
|
-
},
|
|
401
|
-
/**
|
|
402
|
-
* Clears the current block's strategy; it falls back to the
|
|
403
|
-
* per-block algorithm settings.
|
|
404
|
-
*/
|
|
405
|
-
removeStrategy() {
|
|
406
|
-
this.patchCurrentBlockConfig({ strategyId: "" });
|
|
407
|
-
},
|
|
408
|
-
// ====================================================================
|
|
409
317
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
410
318
|
// ====================================================================
|
|
411
319
|
async fetchRecommendationCreateData() {
|
|
@@ -419,7 +327,7 @@ const N = () => ({
|
|
|
419
327
|
activePredictiveAlgorithms: t,
|
|
420
328
|
languages: e,
|
|
421
329
|
currencies: r
|
|
422
|
-
} = await
|
|
330
|
+
} = await h.fetchRecommendationCreateData();
|
|
423
331
|
if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
424
332
|
const n = this.blockStates[this.currentRecommendationId];
|
|
425
333
|
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
@@ -440,7 +348,7 @@ const N = () => ({
|
|
|
440
348
|
return;
|
|
441
349
|
}
|
|
442
350
|
u = (async () => {
|
|
443
|
-
const t = await
|
|
351
|
+
const t = await h.fetchRecommendationFilters();
|
|
444
352
|
this.filterList = t;
|
|
445
353
|
})();
|
|
446
354
|
try {
|
|
@@ -461,10 +369,10 @@ const N = () => ({
|
|
|
461
369
|
deleteFilterGroup(t) {
|
|
462
370
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
463
371
|
return;
|
|
464
|
-
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),
|
|
372
|
+
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), c = new Map(n.map((i, o) => [i, o + 1]));
|
|
465
373
|
e.recommendationConfigs.filters = r.map((i) => ({
|
|
466
374
|
...i,
|
|
467
|
-
filterGroup:
|
|
375
|
+
filterGroup: c.get(i.filterGroup) ?? i.filterGroup
|
|
468
376
|
}));
|
|
469
377
|
},
|
|
470
378
|
updateFilter(t) {
|
|
@@ -475,7 +383,7 @@ const N = () => ({
|
|
|
475
383
|
const n = [...e.recommendationConfigs.filters];
|
|
476
384
|
n[r] = {
|
|
477
385
|
...t,
|
|
478
|
-
isValid:
|
|
386
|
+
isValid: N(t)
|
|
479
387
|
}, e.recommendationConfigs.filters = n;
|
|
480
388
|
}
|
|
481
389
|
},
|
|
@@ -489,10 +397,10 @@ const N = () => ({
|
|
|
489
397
|
let i = 1;
|
|
490
398
|
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
491
399
|
} else {
|
|
492
|
-
const i = [...new Set(n.map((
|
|
493
|
-
n = n.map((
|
|
494
|
-
...
|
|
495
|
-
filterGroup: o.get(
|
|
400
|
+
const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, a) => s - a), o = new Map(i.map((s, a) => [s, a + 1]));
|
|
401
|
+
n = n.map((s) => ({
|
|
402
|
+
...s,
|
|
403
|
+
filterGroup: o.get(s.filterGroup) ?? s.filterGroup
|
|
496
404
|
}));
|
|
497
405
|
}
|
|
498
406
|
e.recommendationConfigs.filters = n;
|
|
@@ -501,15 +409,15 @@ const N = () => ({
|
|
|
501
409
|
addFilter(t) {
|
|
502
410
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
503
411
|
return;
|
|
504
|
-
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters],
|
|
412
|
+
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], c = r.filter(
|
|
505
413
|
(o) => o.filterGroup === t.filterGroup
|
|
506
414
|
).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
507
415
|
i !== -1 ? r.splice(i + 1, 0, {
|
|
508
416
|
...t,
|
|
509
|
-
filterNumber:
|
|
417
|
+
filterNumber: c
|
|
510
418
|
}) : r.push({
|
|
511
419
|
...t,
|
|
512
|
-
filterNumber:
|
|
420
|
+
filterNumber: c
|
|
513
421
|
}), e.recommendationConfigs.filters = r;
|
|
514
422
|
},
|
|
515
423
|
generateFilterQuery() {
|
|
@@ -521,7 +429,7 @@ const N = () => ({
|
|
|
521
429
|
* every block's recommendationConfigs across user edits.
|
|
522
430
|
*/
|
|
523
431
|
hasInvalidBlock() {
|
|
524
|
-
return Object.values(this.blockStates).some((t) => !
|
|
432
|
+
return Object.values(this.blockStates).some((t) => !x(t.recommendationConfigs, this));
|
|
525
433
|
},
|
|
526
434
|
// ====================================================================
|
|
527
435
|
// Per-Block Product Fetching
|
|
@@ -541,13 +449,8 @@ const N = () => ({
|
|
|
541
449
|
}
|
|
542
450
|
},
|
|
543
451
|
async _doFetchProducts() {
|
|
544
|
-
var
|
|
545
|
-
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e
|
|
546
|
-
if (r.strategyId) {
|
|
547
|
-
await this._doFetchStrategyProducts(t);
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
const n = r.filters.filter((h) => h.isValid), s = b(n), i = ((S = p().find((h) => h.key === r.strategy)) == null ? void 0 : S.path) || "", o = P(), a = parseInt(r.size) || 6, c = {
|
|
452
|
+
var p;
|
|
453
|
+
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = r.filters.filter((l) => l.isValid), c = b(n), i = ((p = g().find((l) => l.key === r.strategy)) == null ? void 0 : p.path) || "", o = G(), s = parseInt(r.size) || 6, a = {
|
|
551
454
|
locale: r.language,
|
|
552
455
|
currency: r.currencySettings.value,
|
|
553
456
|
partnerName: o.partnerName,
|
|
@@ -555,64 +458,26 @@ const N = () => ({
|
|
|
555
458
|
details: !0,
|
|
556
459
|
campaignId: o.variationId
|
|
557
460
|
};
|
|
558
|
-
r.strategy === "manualMerchandising" ?
|
|
559
|
-
|
|
560
|
-
|
|
461
|
+
r.strategy === "manualMerchandising" ? a.productId = r.productIds.join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
|
|
462
|
+
a,
|
|
463
|
+
v(o.partnerName, r.strategy)
|
|
561
464
|
);
|
|
562
|
-
let
|
|
465
|
+
let f;
|
|
563
466
|
try {
|
|
564
|
-
|
|
467
|
+
f = await h.fetchRecommendationProducts(i, a);
|
|
565
468
|
} catch {
|
|
566
|
-
|
|
469
|
+
f = [];
|
|
567
470
|
}
|
|
568
|
-
this.
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
* strategy, resolution error) falls back to placeholder products.
|
|
575
|
-
*/
|
|
576
|
-
async _doFetchStrategyProducts(t) {
|
|
577
|
-
const { recommendationConfigs: e } = this.blockStates[t];
|
|
578
|
-
let r = [], n = parseInt(e.size) || 6;
|
|
579
|
-
try {
|
|
580
|
-
this.strategies.length || await this.fetchStrategies();
|
|
581
|
-
const s = this.strategies.find(
|
|
582
|
-
(i) => String(i.strategy_id) === e.strategyId
|
|
583
|
-
);
|
|
584
|
-
if (s) {
|
|
585
|
-
n = parseInt(String(s.size ?? "")) || n;
|
|
586
|
-
const i = await this.resolveStrategyUrlTemplate(s), o = new URL(
|
|
587
|
-
i.replaceAll("{locale}", e.language).replaceAll("{currency}", e.currencySettings.value)
|
|
588
|
-
);
|
|
589
|
-
o.searchParams.delete("user_id"), r = await l.fetchRecommendationProductsByUrl(o.toString());
|
|
590
|
-
}
|
|
591
|
-
} catch {
|
|
592
|
-
r = [];
|
|
471
|
+
if (this.blockStates[t]) {
|
|
472
|
+
const l = f.length > 0 ? f : S(s);
|
|
473
|
+
l.length < s ? this.blockStates[t].recommendationProducts = [
|
|
474
|
+
...l,
|
|
475
|
+
...S(s - l.length)
|
|
476
|
+
] : l.length > s ? this.blockStates[t].recommendationProducts = l.slice(0, s) : this.blockStates[t].recommendationProducts = l;
|
|
593
477
|
}
|
|
594
|
-
this._setBlockProducts(t, r, n);
|
|
595
|
-
},
|
|
596
|
-
/**
|
|
597
|
-
* Writes products to a block's state, padded/clipped to `size` so
|
|
598
|
-
* in-place content updates (which compare DOM element count vs
|
|
599
|
-
* products.length) succeed:
|
|
600
|
-
* - API returned nothing → fill entirely with defaults
|
|
601
|
-
* - fewer than requested → pad with dummies
|
|
602
|
-
* - more than requested → clip, preventing the renderer from extending
|
|
603
|
-
* its slot grid (which would reset migrator-applied styles).
|
|
604
|
-
*/
|
|
605
|
-
_setBlockProducts(t, e, r) {
|
|
606
|
-
if (!this.blockStates[t])
|
|
607
|
-
return;
|
|
608
|
-
const n = e.length > 0 ? e : y(r);
|
|
609
|
-
n.length < r ? this.blockStates[t].recommendationProducts = [
|
|
610
|
-
...n,
|
|
611
|
-
...y(r - n.length)
|
|
612
|
-
] : n.length > r ? this.blockStates[t].recommendationProducts = n.slice(0, r) : this.blockStates[t].recommendationProducts = n;
|
|
613
478
|
}
|
|
614
479
|
}
|
|
615
480
|
});
|
|
616
481
|
export {
|
|
617
|
-
|
|
482
|
+
$ as useRecommendationExtensionStore
|
|
618
483
|
};
|