@useinsider/guido 3.17.0-beta.24a776b → 3.17.0-beta.2ff8586
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 +5 -6
- package/dist/@types/config/schemas.js +6 -12
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +63 -66
- package/dist/composables/useConfig.js +30 -37
- package/dist/composables/useCustomInterfaceAppearance.js +38 -52
- package/dist/composables/useRecommendation.js +41 -49
- package/dist/config/migrator/recommendation/settingsMapper.js +17 -19
- package/dist/config/migrator/recommendationMigrator.js +37 -56
- package/dist/enums/academy.js +1 -2
- package/dist/enums/date.js +3 -4
- package/dist/enums/extensions/recommendationBlock.js +1 -4
- package/dist/extensions/Blocks/Recommendation/block.js +21 -26
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -36
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +95 -96
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +154 -151
- package/dist/extensions/Blocks/Recommendation/services/configService.js +35 -35
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +109 -248
- package/dist/extensions/Blocks/common-control.js +19 -22
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +30 -72
- package/dist/src/@types/config/schemas.d.ts +0 -12
- package/dist/src/composables/useConfig.d.ts +0 -3
- package/dist/src/composables/useRecommendation.d.ts +0 -1
- package/dist/src/enums/academy.d.ts +0 -1
- package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -7
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -9
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +10 -204
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -6
- package/dist/src/extensions/Blocks/common-control.d.ts +1 -4
- package/dist/src/services/recommendationApi.d.ts +1 -4
- package/dist/src/stores/config.d.ts +0 -18
- package/dist/src/stores/template.d.ts +0 -14
- package/dist/src/utils/liquidDynamicContent.d.ts +18 -0
- package/dist/stores/template.js +8 -13
- package/dist/utils/dateUtil.js +10 -23
- package/dist/utils/genericUtil.js +49 -38
- package/dist/utils/liquidDynamicContent.js +9 -0
- package/dist/utils/templatePreparation.js +34 -37
- package/package.json +2 -3
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +0 -18
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +0 -65
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +0 -136
- 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 -29
- package/dist/src/mock/api/recommendation-strategies.d.ts +0 -63
- package/dist/src/utils/strategyInfoBox.d.ts +0 -18
- package/dist/static/assets/icons/line-change.svg.js +0 -5
- package/dist/static/assets/icons/line-delete.svg.js +0 -5
- package/dist/static/assets/icons/line-plus.svg.js +0 -5
- package/dist/static/styles/components/recommendation-strategy.css.js +0 -172
- package/dist/utils/strategyInfoBox.js +0 -37
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { defineStore as F } from "pinia";
|
|
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 P } from "pinia";
|
|
6
5
|
import "../constants/selectors.js";
|
|
7
|
-
import { DEFAULT_MOBILE_CARDS_IN_ROW as
|
|
8
|
-
import {
|
|
9
|
-
import { getDefaultProducts as
|
|
6
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as F, 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";
|
|
10
9
|
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
11
|
-
import { getPartnerRecommendationParams as
|
|
12
|
-
import { sanitizeProductIds as
|
|
13
|
-
import { isFilterValid as
|
|
14
|
-
import { isConfigValid as
|
|
15
|
-
const
|
|
16
|
-
let
|
|
17
|
-
function
|
|
10
|
+
import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
|
|
11
|
+
import { sanitizeProductIds as N } from "../utils/productIds.js";
|
|
12
|
+
import { isFilterValid as x } from "../validation/filterSchema.js";
|
|
13
|
+
import { isConfigValid as L } from "../validation/requiredFields.js";
|
|
14
|
+
const h = y();
|
|
15
|
+
let m = null, u = null, d = null;
|
|
16
|
+
function k() {
|
|
18
17
|
return {
|
|
19
|
-
cardsInRow:
|
|
18
|
+
cardsInRow: D,
|
|
20
19
|
currencySettings: {
|
|
21
20
|
name: "USD",
|
|
22
21
|
value: "USD",
|
|
@@ -30,14 +29,13 @@ function R() {
|
|
|
30
29
|
productIds: [],
|
|
31
30
|
id: 1,
|
|
32
31
|
language: "en_US",
|
|
33
|
-
mobileCardsInRow:
|
|
32
|
+
mobileCardsInRow: F,
|
|
34
33
|
mobileLayoutEnabled: !1,
|
|
35
34
|
orientation: "grid",
|
|
36
35
|
recommendedProducts: [],
|
|
37
36
|
sendProductRequestFlag: !1,
|
|
38
37
|
shuffleProducts: !1,
|
|
39
38
|
strategy: "mostPopular",
|
|
40
|
-
strategyId: "",
|
|
41
39
|
textTrimming: !0,
|
|
42
40
|
unresponsive: !1,
|
|
43
41
|
size: "6",
|
|
@@ -46,32 +44,28 @@ function R() {
|
|
|
46
44
|
priceHideIfSameAsDiscounted: !1
|
|
47
45
|
};
|
|
48
46
|
}
|
|
49
|
-
function
|
|
47
|
+
function I() {
|
|
50
48
|
return {
|
|
51
|
-
recommendationConfigs:
|
|
49
|
+
recommendationConfigs: k(),
|
|
52
50
|
recommendationProducts: [],
|
|
53
51
|
filterStatus: !1,
|
|
54
52
|
filterSelectionDrawerStatus: !1,
|
|
55
|
-
assignStrategyDrawerStatus: !1,
|
|
56
53
|
filterGroup: 1,
|
|
57
54
|
isInitialized: !1,
|
|
58
55
|
filterSnapshot: null
|
|
59
56
|
};
|
|
60
57
|
}
|
|
61
|
-
const
|
|
58
|
+
const U = () => ({
|
|
62
59
|
recommendationCampaignUrls: {},
|
|
63
60
|
activePredictiveAlgorithms: [],
|
|
64
61
|
languages: {},
|
|
65
62
|
currencyList: [],
|
|
66
63
|
filterList: {},
|
|
67
|
-
strategies: [],
|
|
68
|
-
strategiesLoading: !1,
|
|
69
|
-
strategyUrlTemplates: {},
|
|
70
64
|
blockStates: {},
|
|
71
65
|
currentRecommendationId: null,
|
|
72
66
|
configVersion: 0
|
|
73
|
-
}),
|
|
74
|
-
state: () =>
|
|
67
|
+
}), H = P("guidoRecommendationExtension", {
|
|
68
|
+
state: () => U(),
|
|
75
69
|
getters: {
|
|
76
70
|
// ====================================================================
|
|
77
71
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -81,7 +75,7 @@ const z = () => ({
|
|
|
81
75
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
82
76
|
*/
|
|
83
77
|
recommendationConfigs(t) {
|
|
84
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
78
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : k();
|
|
85
79
|
},
|
|
86
80
|
/**
|
|
87
81
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -95,20 +89,6 @@ const z = () => ({
|
|
|
95
89
|
filterSelectionDrawerStatus(t) {
|
|
96
90
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterSelectionDrawerStatus : !1;
|
|
97
91
|
},
|
|
98
|
-
/**
|
|
99
|
-
* Proxy getter: delegates to blockStates[currentRecommendationId].assignStrategyDrawerStatus
|
|
100
|
-
*/
|
|
101
|
-
assignStrategyDrawerStatus(t) {
|
|
102
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].assignStrategyDrawerStatus : !1;
|
|
103
|
-
},
|
|
104
|
-
/**
|
|
105
|
-
* The current block's assigned strategy record from the listing,
|
|
106
|
-
* or null when nothing is assigned / the strategy is no longer listed.
|
|
107
|
-
*/
|
|
108
|
-
assignedStrategy(t) {
|
|
109
|
-
const { strategyId: e } = this.recommendationConfigs;
|
|
110
|
-
return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
|
|
111
|
-
},
|
|
112
92
|
/**
|
|
113
93
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
|
|
114
94
|
*/
|
|
@@ -140,12 +120,12 @@ const z = () => ({
|
|
|
140
120
|
return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
|
|
141
121
|
},
|
|
142
122
|
getActivePredictiveAlgorithms: (t) => {
|
|
143
|
-
const e =
|
|
144
|
-
return t.activePredictiveAlgorithms.filter((
|
|
145
|
-
r.push(...e.filter((
|
|
146
|
-
}), r.map((
|
|
147
|
-
text:
|
|
148
|
-
value:
|
|
123
|
+
const e = g(), r = [];
|
|
124
|
+
return t.activePredictiveAlgorithms.filter((n) => !w.includes(n)).forEach((n) => {
|
|
125
|
+
r.push(...e.filter((c) => c.id === n));
|
|
126
|
+
}), r.map((n) => ({
|
|
127
|
+
text: n.name,
|
|
128
|
+
value: n.key
|
|
149
129
|
}));
|
|
150
130
|
},
|
|
151
131
|
getLanguages: (t) => Object.entries(t.languages).map(([e, r]) => ({
|
|
@@ -159,7 +139,7 @@ const z = () => ({
|
|
|
159
139
|
getFilterList() {
|
|
160
140
|
return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
|
|
161
141
|
let e;
|
|
162
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
142
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : C.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
163
143
|
text: t.displayName,
|
|
164
144
|
value: e,
|
|
165
145
|
type: t.attributeType
|
|
@@ -181,7 +161,7 @@ const z = () => ({
|
|
|
181
161
|
setCurrentBlock(t) {
|
|
182
162
|
this.blockStates[t] || (this.blockStates = {
|
|
183
163
|
...this.blockStates,
|
|
184
|
-
[t]:
|
|
164
|
+
[t]: I()
|
|
185
165
|
}), this.currentRecommendationId = t;
|
|
186
166
|
},
|
|
187
167
|
/**
|
|
@@ -191,13 +171,13 @@ const z = () => ({
|
|
|
191
171
|
removeBlockState(t) {
|
|
192
172
|
const e = t.toString();
|
|
193
173
|
if (this.recommendationCampaignUrls[e]) {
|
|
194
|
-
const
|
|
195
|
-
delete
|
|
174
|
+
const n = { ...this.recommendationCampaignUrls };
|
|
175
|
+
delete n[e], this.recommendationCampaignUrls = n;
|
|
196
176
|
}
|
|
197
177
|
const r = { ...this.blockStates };
|
|
198
178
|
if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
|
|
199
|
-
const
|
|
200
|
-
this.currentRecommendationId =
|
|
179
|
+
const n = Object.keys(this.blockStates).map(Number);
|
|
180
|
+
this.currentRecommendationId = n.length > 0 ? n[0] : null;
|
|
201
181
|
}
|
|
202
182
|
},
|
|
203
183
|
/**
|
|
@@ -213,10 +193,10 @@ const z = () => ({
|
|
|
213
193
|
[e]: o
|
|
214
194
|
};
|
|
215
195
|
}
|
|
216
|
-
const
|
|
217
|
-
|
|
196
|
+
const n = t.toString(), c = e.toString(), i = this.recommendationCampaignUrls[n];
|
|
197
|
+
i && (this.recommendationCampaignUrls = {
|
|
218
198
|
...this.recommendationCampaignUrls,
|
|
219
|
-
[
|
|
199
|
+
[c]: i
|
|
220
200
|
});
|
|
221
201
|
},
|
|
222
202
|
/**
|
|
@@ -241,7 +221,7 @@ const z = () => ({
|
|
|
241
221
|
* `isInitialized`) alone.
|
|
242
222
|
*/
|
|
243
223
|
seedBlockUrlConfig(t, e) {
|
|
244
|
-
const r = (o,
|
|
224
|
+
const r = (o, s) => o === "." || o === "," || o === " " ? o : s, n = {
|
|
245
225
|
name: e.currencyCode,
|
|
246
226
|
value: e.currencyCode,
|
|
247
227
|
symbol: e.currencyCode,
|
|
@@ -249,20 +229,19 @@ const z = () => ({
|
|
|
249
229
|
decimalCount: String(e.currencyDecimalCount),
|
|
250
230
|
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
251
231
|
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
...
|
|
232
|
+
}, c = !this.blockStates[t], i = c ? I() : this.blockStates[t];
|
|
233
|
+
i.recommendationConfigs = {
|
|
234
|
+
...i.recommendationConfigs,
|
|
255
235
|
strategy: e.strategy,
|
|
256
|
-
strategyId: e.strategyId,
|
|
257
236
|
language: e.language,
|
|
258
237
|
size: e.size,
|
|
259
238
|
productIds: e.productIds,
|
|
260
239
|
filters: e.filters,
|
|
261
240
|
shuffleProducts: e.shuffleProducts,
|
|
262
|
-
currencySettings:
|
|
263
|
-
},
|
|
241
|
+
currencySettings: n
|
|
242
|
+
}, c && (this.blockStates = {
|
|
264
243
|
...this.blockStates,
|
|
265
|
-
[t]:
|
|
244
|
+
[t]: i
|
|
266
245
|
});
|
|
267
246
|
},
|
|
268
247
|
/**
|
|
@@ -281,18 +260,18 @@ const z = () => ({
|
|
|
281
260
|
...t.currencySettings || {}
|
|
282
261
|
}
|
|
283
262
|
};
|
|
284
|
-
const { triggerRefetch:
|
|
285
|
-
|
|
263
|
+
const { triggerRefetch: n = !0 } = e;
|
|
264
|
+
n && this.configVersion++;
|
|
286
265
|
},
|
|
287
266
|
/**
|
|
288
267
|
* Creates a filter with the first available attribute and operator pre-selected.
|
|
289
268
|
*/
|
|
290
269
|
createDefaultFilter(t, e) {
|
|
291
|
-
const [r] = this.getFilterList, [
|
|
270
|
+
const [r] = this.getFilterList, [n] = R(r == null ? void 0 : r.type);
|
|
292
271
|
return {
|
|
293
272
|
type: "standardFilter",
|
|
294
273
|
attribute: (r == null ? void 0 : r.value) ?? "",
|
|
295
|
-
operator: (
|
|
274
|
+
operator: (n == null ? void 0 : n.value) ?? "",
|
|
296
275
|
innerGroupOperator: "*",
|
|
297
276
|
outerGroupOperator: "*",
|
|
298
277
|
filterNumber: e,
|
|
@@ -336,127 +315,47 @@ const z = () => ({
|
|
|
336
315
|
t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
|
|
337
316
|
},
|
|
338
317
|
// ====================================================================
|
|
339
|
-
// Reusable Recommendation Strategy (SD-149105)
|
|
340
|
-
// ====================================================================
|
|
341
|
-
/**
|
|
342
|
-
* Opens the Assign Strategy drawer for the current block.
|
|
343
|
-
* Selection state lives in the drawer component until Assign is
|
|
344
|
-
* pressed, so closing without assigning needs no snapshot/revert.
|
|
345
|
-
*/
|
|
346
|
-
openAssignStrategyDrawer() {
|
|
347
|
-
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !0);
|
|
348
|
-
},
|
|
349
|
-
closeAssignStrategyDrawer() {
|
|
350
|
-
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !1);
|
|
351
|
-
},
|
|
352
|
-
/**
|
|
353
|
-
* Fetches the active + EMAIL strategy listing. Always fetches fresh
|
|
354
|
-
* (dead-strategy detection and post-create refresh need freshness);
|
|
355
|
-
* only concurrent in-flight calls share one request.
|
|
356
|
-
*/
|
|
357
|
-
async fetchStrategies() {
|
|
358
|
-
if (S) {
|
|
359
|
-
await S;
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
S = (async () => {
|
|
363
|
-
this.strategiesLoading = !0;
|
|
364
|
-
try {
|
|
365
|
-
this.strategies = await m.fetchRecommendationStrategies();
|
|
366
|
-
} finally {
|
|
367
|
-
this.strategiesLoading = !1;
|
|
368
|
-
}
|
|
369
|
-
})();
|
|
370
|
-
try {
|
|
371
|
-
await S;
|
|
372
|
-
} finally {
|
|
373
|
-
S = null;
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
/**
|
|
377
|
-
* Resolves a strategy's recommendation endpoint template via
|
|
378
|
-
* endpoint-generate, cached per strategy id + revision. Failures throw
|
|
379
|
-
* and are NOT cached, so the next attempt retries.
|
|
380
|
-
*
|
|
381
|
-
* `full_path` bakes in the algorithm path and `size=` as they were when
|
|
382
|
-
* generated, so the revision keys the cache — and a record with no
|
|
383
|
-
* revision is not cached at all, since its key could never change.
|
|
384
|
-
*/
|
|
385
|
-
async resolveStrategyUrlTemplate(t) {
|
|
386
|
-
const e = typeof t.updated_at == "string" ? t.updated_at : "", r = e ? `${t.strategy_id}:${e}` : "", i = r ? this.strategyUrlTemplates[r] : void 0;
|
|
387
|
-
if (i)
|
|
388
|
-
return i;
|
|
389
|
-
const { full_path: s } = await m.generateStrategyEndpoint(t);
|
|
390
|
-
return r && (this.strategyUrlTemplates = {
|
|
391
|
-
...this.strategyUrlTemplates,
|
|
392
|
-
[r]: s
|
|
393
|
-
}), s;
|
|
394
|
-
},
|
|
395
|
-
/**
|
|
396
|
-
* Assigns a strategy to the current block. The config write is
|
|
397
|
-
* synchronous (before any await) so a block switch cannot misdirect
|
|
398
|
-
* it; the configVersion bump persists it to node config and triggers
|
|
399
|
-
* the product refetch via the coordinator control's subscription.
|
|
400
|
-
*/
|
|
401
|
-
assignStrategy(t) {
|
|
402
|
-
this.patchCurrentBlockConfig({
|
|
403
|
-
strategyId: String(t.strategy_id),
|
|
404
|
-
...t.size !== void 0 ? { size: String(t.size) } : {}
|
|
405
|
-
});
|
|
406
|
-
},
|
|
407
|
-
/**
|
|
408
|
-
* Clears the current block's strategy; it falls back to the per-block
|
|
409
|
-
* algorithm settings.
|
|
410
|
-
*
|
|
411
|
-
* `size` goes back to the default rather than staying on the removed
|
|
412
|
-
* strategy's count: with Number of Products hidden in RRS mode, a block
|
|
413
|
-
* left on that count would have no UI to correct it.
|
|
414
|
-
*/
|
|
415
|
-
removeStrategy() {
|
|
416
|
-
this.patchCurrentBlockConfig({ strategyId: "", size: U.size });
|
|
417
|
-
},
|
|
418
|
-
// ====================================================================
|
|
419
318
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
420
319
|
// ====================================================================
|
|
421
320
|
async fetchRecommendationCreateData() {
|
|
422
321
|
if (!this.activePredictiveAlgorithms.length) {
|
|
423
|
-
if (
|
|
424
|
-
await
|
|
322
|
+
if (m) {
|
|
323
|
+
await m;
|
|
425
324
|
return;
|
|
426
325
|
}
|
|
427
|
-
|
|
326
|
+
m = (async () => {
|
|
428
327
|
const {
|
|
429
328
|
activePredictiveAlgorithms: t,
|
|
430
329
|
languages: e,
|
|
431
330
|
currencies: r
|
|
432
|
-
} = await
|
|
331
|
+
} = await h.fetchRecommendationCreateData();
|
|
433
332
|
if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
434
|
-
const
|
|
435
|
-
|
|
333
|
+
const n = this.blockStates[this.currentRecommendationId];
|
|
334
|
+
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
436
335
|
}
|
|
437
336
|
this.currencyList = r;
|
|
438
337
|
})();
|
|
439
338
|
try {
|
|
440
|
-
await
|
|
339
|
+
await m;
|
|
441
340
|
} finally {
|
|
442
|
-
|
|
341
|
+
m = null;
|
|
443
342
|
}
|
|
444
343
|
}
|
|
445
344
|
},
|
|
446
345
|
async fetchRecommendationFilters() {
|
|
447
346
|
if (!Object.keys(this.filterList).length) {
|
|
448
|
-
if (
|
|
449
|
-
await
|
|
347
|
+
if (u) {
|
|
348
|
+
await u;
|
|
450
349
|
return;
|
|
451
350
|
}
|
|
452
|
-
|
|
453
|
-
const t = await
|
|
351
|
+
u = (async () => {
|
|
352
|
+
const t = await h.fetchRecommendationFilters();
|
|
454
353
|
this.filterList = t;
|
|
455
354
|
})();
|
|
456
355
|
try {
|
|
457
|
-
await
|
|
356
|
+
await u;
|
|
458
357
|
} finally {
|
|
459
|
-
|
|
358
|
+
u = null;
|
|
460
359
|
}
|
|
461
360
|
}
|
|
462
361
|
},
|
|
@@ -471,55 +370,55 @@ const z = () => ({
|
|
|
471
370
|
deleteFilterGroup(t) {
|
|
472
371
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
473
372
|
return;
|
|
474
|
-
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.filter((
|
|
475
|
-
e.recommendationConfigs.filters = r.map((
|
|
476
|
-
...
|
|
477
|
-
filterGroup:
|
|
373
|
+
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]));
|
|
374
|
+
e.recommendationConfigs.filters = r.map((i) => ({
|
|
375
|
+
...i,
|
|
376
|
+
filterGroup: c.get(i.filterGroup) ?? i.filterGroup
|
|
478
377
|
}));
|
|
479
378
|
},
|
|
480
379
|
updateFilter(t) {
|
|
481
380
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
482
381
|
return;
|
|
483
|
-
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((
|
|
382
|
+
const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
484
383
|
if (r !== -1) {
|
|
485
|
-
const
|
|
486
|
-
|
|
384
|
+
const n = [...e.recommendationConfigs.filters];
|
|
385
|
+
n[r] = {
|
|
487
386
|
...t,
|
|
488
|
-
isValid:
|
|
489
|
-
}, e.recommendationConfigs.filters =
|
|
387
|
+
isValid: x(t)
|
|
388
|
+
}, e.recommendationConfigs.filters = n;
|
|
490
389
|
}
|
|
491
390
|
},
|
|
492
391
|
deleteFilter(t) {
|
|
493
392
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
494
393
|
return;
|
|
495
|
-
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((
|
|
394
|
+
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
496
395
|
if (r !== -1) {
|
|
497
|
-
let
|
|
498
|
-
if (
|
|
499
|
-
let
|
|
500
|
-
|
|
396
|
+
let n = [...e.recommendationConfigs.filters];
|
|
397
|
+
if (n.splice(r, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
|
|
398
|
+
let i = 1;
|
|
399
|
+
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
501
400
|
} else {
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
...
|
|
505
|
-
filterGroup: o.get(
|
|
401
|
+
const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, a) => s - a), o = new Map(i.map((s, a) => [s, a + 1]));
|
|
402
|
+
n = n.map((s) => ({
|
|
403
|
+
...s,
|
|
404
|
+
filterGroup: o.get(s.filterGroup) ?? s.filterGroup
|
|
506
405
|
}));
|
|
507
406
|
}
|
|
508
|
-
e.recommendationConfigs.filters =
|
|
407
|
+
e.recommendationConfigs.filters = n;
|
|
509
408
|
}
|
|
510
409
|
},
|
|
511
410
|
addFilter(t) {
|
|
512
411
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
513
412
|
return;
|
|
514
|
-
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters],
|
|
413
|
+
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], c = r.filter(
|
|
515
414
|
(o) => o.filterGroup === t.filterGroup
|
|
516
|
-
).length + 1,
|
|
517
|
-
|
|
415
|
+
).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
416
|
+
i !== -1 ? r.splice(i + 1, 0, {
|
|
518
417
|
...t,
|
|
519
|
-
filterNumber:
|
|
418
|
+
filterNumber: c
|
|
520
419
|
}) : r.push({
|
|
521
420
|
...t,
|
|
522
|
-
filterNumber:
|
|
421
|
+
filterNumber: c
|
|
523
422
|
}), e.recommendationConfigs.filters = r;
|
|
524
423
|
},
|
|
525
424
|
generateFilterQuery() {
|
|
@@ -531,93 +430,55 @@ const z = () => ({
|
|
|
531
430
|
* every block's recommendationConfigs across user edits.
|
|
532
431
|
*/
|
|
533
432
|
hasInvalidBlock() {
|
|
534
|
-
return Object.values(this.blockStates).some((t) => !
|
|
433
|
+
return Object.values(this.blockStates).some((t) => !L(t.recommendationConfigs, this));
|
|
535
434
|
},
|
|
536
435
|
// ====================================================================
|
|
537
436
|
// Per-Block Product Fetching
|
|
538
437
|
// ====================================================================
|
|
539
438
|
async fetchRecommendationProducts() {
|
|
540
439
|
if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
|
|
541
|
-
if (
|
|
542
|
-
await
|
|
440
|
+
if (d) {
|
|
441
|
+
await d;
|
|
543
442
|
return;
|
|
544
443
|
}
|
|
545
|
-
|
|
444
|
+
d = this._doFetchProducts();
|
|
546
445
|
try {
|
|
547
|
-
await
|
|
446
|
+
await d;
|
|
548
447
|
} finally {
|
|
549
|
-
|
|
448
|
+
d = null;
|
|
550
449
|
}
|
|
551
450
|
}
|
|
552
451
|
},
|
|
553
452
|
async _doFetchProducts() {
|
|
554
|
-
var
|
|
555
|
-
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e,
|
|
556
|
-
if (s() && r.strategyId) {
|
|
557
|
-
await this._doFetchStrategyProducts(t);
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
const n = r.filters.filter((p) => p.isValid), o = b(n), a = ((d = y().find((p) => p.key === r.strategy)) == null ? void 0 : d.path) || "", l = parseInt(r.size) || 6, c = {
|
|
453
|
+
var p;
|
|
454
|
+
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 = {
|
|
561
455
|
locale: r.language,
|
|
562
456
|
currency: r.currencySettings.value,
|
|
563
|
-
partnerName:
|
|
457
|
+
partnerName: o.partnerName,
|
|
564
458
|
size: r.size,
|
|
565
459
|
details: !0,
|
|
566
|
-
campaignId:
|
|
460
|
+
campaignId: o.variationId
|
|
567
461
|
};
|
|
568
|
-
r.strategy === "manualMerchandising" ?
|
|
569
|
-
|
|
570
|
-
|
|
462
|
+
r.strategy === "manualMerchandising" ? a.productId = N(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
|
|
463
|
+
a,
|
|
464
|
+
v(o.partnerName, r.strategy)
|
|
571
465
|
);
|
|
572
|
-
let
|
|
466
|
+
let f;
|
|
573
467
|
try {
|
|
574
|
-
|
|
468
|
+
f = await h.fetchRecommendationProducts(i, a);
|
|
575
469
|
} catch {
|
|
576
|
-
|
|
470
|
+
f = [];
|
|
577
471
|
}
|
|
578
|
-
this.
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
* strategy, resolution error) falls back to placeholder products.
|
|
585
|
-
*/
|
|
586
|
-
async _doFetchStrategyProducts(t) {
|
|
587
|
-
const { recommendationConfigs: e } = this.blockStates[t];
|
|
588
|
-
let r = [], i = parseInt(e.size) || 6;
|
|
589
|
-
try {
|
|
590
|
-
this.strategies.length || await this.fetchStrategies();
|
|
591
|
-
const s = this.strategies.find(
|
|
592
|
-
(n) => String(n.strategy_id) === e.strategyId
|
|
593
|
-
);
|
|
594
|
-
if (s) {
|
|
595
|
-
i = parseInt(String(s.size ?? "")) || i;
|
|
596
|
-
const o = (await this.resolveStrategyUrlTemplate(s)).replaceAll("{locale}", e.language).replaceAll("{currency}", e.currencySettings.value), a = o.indexOf("?"), l = a === -1 ? o : o.slice(0, a), c = (a === -1 ? "" : o.slice(a + 1)).split("&").filter((d) => d && !d.startsWith("user_id=")), u = c.length ? `${l}?${c.join("&")}` : l;
|
|
597
|
-
r = await m.fetchRecommendationProductsByUrl(u);
|
|
598
|
-
}
|
|
599
|
-
} catch {
|
|
600
|
-
r = [];
|
|
472
|
+
if (this.blockStates[t]) {
|
|
473
|
+
const l = f.length > 0 ? f : S(s);
|
|
474
|
+
l.length < s ? this.blockStates[t].recommendationProducts = [
|
|
475
|
+
...l,
|
|
476
|
+
...S(s - l.length)
|
|
477
|
+
] : l.length > s ? this.blockStates[t].recommendationProducts = l.slice(0, s) : this.blockStates[t].recommendationProducts = l;
|
|
601
478
|
}
|
|
602
|
-
this._setBlockProducts(t, r, i);
|
|
603
|
-
},
|
|
604
|
-
/**
|
|
605
|
-
* Writes products to a block's state, padded/clipped to exactly `size`:
|
|
606
|
-
* in-place content updates compare the DOM element count against
|
|
607
|
-
* products.length, and a longer list makes the renderer extend its slot
|
|
608
|
-
* grid, which resets migrator-applied styles.
|
|
609
|
-
*/
|
|
610
|
-
_setBlockProducts(t, e, r) {
|
|
611
|
-
if (!this.blockStates[t])
|
|
612
|
-
return;
|
|
613
|
-
const i = e.length > 0 ? e : I(r);
|
|
614
|
-
this.blockStates[t].recommendationProducts = [
|
|
615
|
-
...i.slice(0, r),
|
|
616
|
-
...I(Math.max(0, r - i.length))
|
|
617
|
-
];
|
|
618
479
|
}
|
|
619
480
|
}
|
|
620
481
|
});
|
|
621
482
|
export {
|
|
622
|
-
|
|
483
|
+
H as useRecommendationExtensionStore
|
|
623
484
|
};
|