@useinsider/guido 3.16.0 → 3.17.0-beta.1631b31
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 +1 -0
- package/dist/@types/config/schemas.js +12 -6
- package/dist/components/Guido.vue.js +9 -9
- package/dist/components/Guido.vue2.js +77 -73
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +69 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
- package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +13 -0
- package/dist/composables/useCustomInterfaceAppearance.js +52 -38
- package/dist/composables/useRecommendation.js +43 -35
- package/dist/composables/useStripo.js +30 -29
- package/dist/config/migrator/itemsBlockMigrator.js +1 -1
- package/dist/config/migrator/recommendation/settingsMapper.js +19 -17
- package/dist/config/migrator/recommendationMigrator.js +6 -4
- package/dist/enums/academy.js +2 -1
- package/dist/enums/date.js +4 -3
- package/dist/enums/extensions/recommendationBlock.js +4 -1
- package/dist/enums/recommendation.js +17 -17
- package/dist/extensions/Blocks/Items/enums/productEnums.js +45 -45
- package/dist/extensions/Blocks/Recommendation/block.js +26 -21
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -34
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +37 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +163 -159
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +142 -0
- package/dist/extensions/Blocks/Recommendation/services/configService.js +35 -35
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +222 -78
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +6 -0
- package/dist/extensions/Blocks/common-control.js +22 -19
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +75 -30
- package/dist/src/@types/config/schemas.d.ts +12 -0
- package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
- package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +17 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +7 -6
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +16 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +30 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +206 -10
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +6 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
- package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
- package/dist/src/services/recommendationApi.d.ts +4 -1
- package/dist/src/stores/config.d.ts +18 -0
- package/dist/src/utils/strategyInfoBox.d.ts +35 -0
- package/dist/static/assets/icons/line-change.svg.js +5 -0
- package/dist/static/assets/icons/line-delete.svg.js +5 -0
- package/dist/static/assets/icons/line-plus.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +188 -0
- package/dist/utils/dateUtil.js +29 -10
- package/dist/utils/strategyInfoBox.js +68 -0
- package/dist/utils/templatePreparation.js +37 -34
- package/package.json +2 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import {
|
|
1
|
+
import { ModificationDescription as h } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { PRE_RRS_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as c } from "../constants/defaultConfig.js";
|
|
3
3
|
import { setCurrencyAttributes as D } from "../controls/main/utils.js";
|
|
4
|
-
import { hasMinimalConfig as
|
|
5
|
-
function
|
|
6
|
-
return
|
|
4
|
+
import { hasMinimalConfig as S } from "../types/nodeConfig.js";
|
|
5
|
+
function A(n) {
|
|
6
|
+
return n === "." || n === "," || n === " ";
|
|
7
7
|
}
|
|
8
|
-
function N(
|
|
9
|
-
return
|
|
8
|
+
function N(n) {
|
|
9
|
+
return n === "." || n === "," || n === " " || n === "";
|
|
10
10
|
}
|
|
11
|
-
class
|
|
11
|
+
class F {
|
|
12
12
|
// ========================================================================
|
|
13
13
|
// Read Operations
|
|
14
14
|
// ========================================================================
|
|
@@ -48,7 +48,7 @@ class M {
|
|
|
48
48
|
return !1;
|
|
49
49
|
try {
|
|
50
50
|
const t = i.getNodeConfig();
|
|
51
|
-
return
|
|
51
|
+
return S(t);
|
|
52
52
|
} catch {
|
|
53
53
|
return !1;
|
|
54
54
|
}
|
|
@@ -82,9 +82,9 @@ class M {
|
|
|
82
82
|
* @param description - Human-readable description for undo/redo
|
|
83
83
|
* @returns The new complete configuration
|
|
84
84
|
*/
|
|
85
|
-
static updateConfig(i, t, o,
|
|
85
|
+
static updateConfig(i, t, o, e) {
|
|
86
86
|
const r = this.getConfig(t), u = this.deepMerge(r, o);
|
|
87
|
-
return this.saveConfig(i, t, u,
|
|
87
|
+
return this.saveConfig(i, t, u, e), u;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Initialize configuration for a new block
|
|
@@ -107,12 +107,12 @@ class M {
|
|
|
107
107
|
static initializeConfig(i, t, o) {
|
|
108
108
|
if (this.hasConfig(t))
|
|
109
109
|
return { config: o ? this.updateConfig(i, t, o, "Initialize recommendation block") : this.getConfig(t), wasFreshDrop: !1 };
|
|
110
|
-
const
|
|
111
|
-
return this.saveConfig(i, t,
|
|
110
|
+
const e = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
|
|
111
|
+
return this.saveConfig(i, t, e, "Initialize recommendation block"), D({
|
|
112
112
|
currentNode: t,
|
|
113
113
|
documentModifier: i.getDocumentModifier(),
|
|
114
|
-
currency:
|
|
115
|
-
}), { config:
|
|
114
|
+
currency: e.currency
|
|
115
|
+
}), { config: e, wasFreshDrop: !0 };
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Save complete configuration to a node
|
|
@@ -123,9 +123,9 @@ class M {
|
|
|
123
123
|
* @param config - Complete configuration to save
|
|
124
124
|
* @param description - Human-readable description for undo/redo
|
|
125
125
|
*/
|
|
126
|
-
static saveConfig(i, t, o,
|
|
126
|
+
static saveConfig(i, t, o, e) {
|
|
127
127
|
try {
|
|
128
|
-
i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new
|
|
128
|
+
i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new h(e));
|
|
129
129
|
} catch (r) {
|
|
130
130
|
console.warn("[RecommendationConfigService] Failed to save config:", r);
|
|
131
131
|
}
|
|
@@ -154,33 +154,33 @@ class M {
|
|
|
154
154
|
*/
|
|
155
155
|
static migrateFromDataAttributes(i, t) {
|
|
156
156
|
const o = {
|
|
157
|
-
configVersion:
|
|
157
|
+
configVersion: C
|
|
158
158
|
};
|
|
159
159
|
if ("getAttribute" in t && typeof t.getAttribute == "function") {
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
160
|
+
const e = t.getAttribute("esd-ext-config");
|
|
161
|
+
if (e)
|
|
162
162
|
try {
|
|
163
|
-
const s = JSON.parse(
|
|
164
|
-
s && typeof s == "object" &&
|
|
163
|
+
const s = JSON.parse(e);
|
|
164
|
+
s && typeof s == "object" && Object.assign(o, s);
|
|
165
165
|
} catch {
|
|
166
166
|
}
|
|
167
167
|
const r = t.getAttribute("data-layout");
|
|
168
168
|
r === "list" || r === "horizontal" ? o.layout = "list" : (r === "grid" || r === "vertical") && (o.layout = "grid");
|
|
169
169
|
const u = t.getAttribute("data-card-composition");
|
|
170
170
|
u && (o.composition = u.split(",").filter(Boolean));
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
175
|
-
const s = t.getAttribute("currency"),
|
|
176
|
-
if (s ||
|
|
177
|
-
const a = c.currency,
|
|
171
|
+
const l = t.getAttribute("data-column-spacing");
|
|
172
|
+
l && (o.columnSpacing = parseInt(l) || c.columnSpacing);
|
|
173
|
+
const b = t.getAttribute("data-row-spacing");
|
|
174
|
+
if (b && (o.rowSpacing = parseInt(b) || c.rowSpacing), !o.currency) {
|
|
175
|
+
const s = t.getAttribute("currency"), p = t.getAttribute("currency-symbol"), y = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
|
|
176
|
+
if (s || p || y || f || g || m) {
|
|
177
|
+
const a = c.currency, d = m ? parseInt(m) : NaN;
|
|
178
178
|
o.currency = {
|
|
179
179
|
code: s ?? a.code,
|
|
180
|
-
symbol:
|
|
181
|
-
alignment:
|
|
182
|
-
decimalCount: Number.isFinite(
|
|
183
|
-
decimalSeparator:
|
|
180
|
+
symbol: p ?? a.symbol,
|
|
181
|
+
alignment: y === "0" ? "before" : "after",
|
|
182
|
+
decimalCount: Number.isFinite(d) ? d : a.decimalCount,
|
|
183
|
+
decimalSeparator: A(g) ? g : a.decimalSeparator,
|
|
184
184
|
thousandSeparator: N(f) ? f : a.thousandSeparator
|
|
185
185
|
};
|
|
186
186
|
}
|
|
@@ -194,7 +194,7 @@ class M {
|
|
|
194
194
|
* @returns True if migration is needed
|
|
195
195
|
*/
|
|
196
196
|
static needsMigration(i) {
|
|
197
|
-
return i ? this.hasConfig(i)
|
|
197
|
+
return i ? !this.hasConfig(i) : !1;
|
|
198
198
|
}
|
|
199
199
|
// ========================================================================
|
|
200
200
|
// Internal Helpers
|
|
@@ -279,5 +279,5 @@ class M {
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
export {
|
|
282
|
-
|
|
282
|
+
F as RecommendationConfigService
|
|
283
283
|
};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as
|
|
2
|
-
import { useRecommendationApi as
|
|
3
|
-
import { useConfigStore as
|
|
4
|
-
import { defineStore as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as I, getOperatorOptions as G, PriceAttributes as D } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as P } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as F } from "../../../../stores/config.js";
|
|
4
|
+
import { defineStore as v } 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
|
|
9
|
-
import { generateCompleteFilterQuery as
|
|
10
|
-
import { getPartnerRecommendationParams as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as _, DEFAULT_CARDS_IN_ROW as U } from "../constants/layout.js";
|
|
7
|
+
import { DEFAULT_NODE_CONFIG as N, EXCLUDED_ALGORITHM_IDS as L } from "../constants/defaultConfig.js";
|
|
8
|
+
import { getDefaultProducts as b } from "../templates/utils.js";
|
|
9
|
+
import { generateCompleteFilterQuery as k } from "../utils/filterUtil.js";
|
|
10
|
+
import { getPartnerRecommendationParams as x } from "../utils/partnerCustomizations.js";
|
|
11
|
+
import { sanitizeProductIds as A } from "../utils/productIds.js";
|
|
12
|
+
import { isFilterValid as B } from "../validation/filterSchema.js";
|
|
13
|
+
import { isConfigValid as z } from "../validation/requiredFields.js";
|
|
14
|
+
const m = P();
|
|
15
|
+
let f = null, g = null, h = null, S = null;
|
|
16
|
+
const p = /* @__PURE__ */ new Map();
|
|
17
|
+
function C() {
|
|
16
18
|
return {
|
|
17
|
-
cardsInRow:
|
|
19
|
+
cardsInRow: U,
|
|
18
20
|
currencySettings: {
|
|
19
21
|
name: "USD",
|
|
20
22
|
value: "USD",
|
|
@@ -28,13 +30,14 @@ function k() {
|
|
|
28
30
|
productIds: [],
|
|
29
31
|
id: 1,
|
|
30
32
|
language: "en_US",
|
|
31
|
-
mobileCardsInRow:
|
|
33
|
+
mobileCardsInRow: _,
|
|
32
34
|
mobileLayoutEnabled: !1,
|
|
33
35
|
orientation: "grid",
|
|
34
36
|
recommendedProducts: [],
|
|
35
37
|
sendProductRequestFlag: !1,
|
|
36
38
|
shuffleProducts: !1,
|
|
37
39
|
strategy: "mostPopular",
|
|
40
|
+
strategyId: "",
|
|
38
41
|
textTrimming: !0,
|
|
39
42
|
unresponsive: !1,
|
|
40
43
|
size: "6",
|
|
@@ -43,28 +46,32 @@ function k() {
|
|
|
43
46
|
priceHideIfSameAsDiscounted: !1
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
|
-
function
|
|
49
|
+
function R() {
|
|
47
50
|
return {
|
|
48
|
-
recommendationConfigs:
|
|
51
|
+
recommendationConfigs: C(),
|
|
49
52
|
recommendationProducts: [],
|
|
50
53
|
filterStatus: !1,
|
|
51
54
|
filterSelectionDrawerStatus: !1,
|
|
55
|
+
assignStrategyDrawerStatus: !1,
|
|
52
56
|
filterGroup: 1,
|
|
53
57
|
isInitialized: !1,
|
|
54
58
|
filterSnapshot: null
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
|
-
const
|
|
61
|
+
const O = () => ({
|
|
58
62
|
recommendationCampaignUrls: {},
|
|
59
63
|
activePredictiveAlgorithms: [],
|
|
60
64
|
languages: {},
|
|
61
65
|
currencyList: [],
|
|
62
66
|
filterList: {},
|
|
67
|
+
strategies: [],
|
|
68
|
+
strategiesLoading: !1,
|
|
69
|
+
strategyUrlTemplates: {},
|
|
63
70
|
blockStates: {},
|
|
64
71
|
currentRecommendationId: null,
|
|
65
72
|
configVersion: 0
|
|
66
|
-
}),
|
|
67
|
-
state: () =>
|
|
73
|
+
}), Y = v("guidoRecommendationExtension", {
|
|
74
|
+
state: () => O(),
|
|
68
75
|
getters: {
|
|
69
76
|
// ====================================================================
|
|
70
77
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -74,7 +81,7 @@ const L = () => ({
|
|
|
74
81
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
75
82
|
*/
|
|
76
83
|
recommendationConfigs(t) {
|
|
77
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
84
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : C();
|
|
78
85
|
},
|
|
79
86
|
/**
|
|
80
87
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -88,6 +95,20 @@ const L = () => ({
|
|
|
88
95
|
filterSelectionDrawerStatus(t) {
|
|
89
96
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterSelectionDrawerStatus : !1;
|
|
90
97
|
},
|
|
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
|
+
},
|
|
91
112
|
/**
|
|
92
113
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
|
|
93
114
|
*/
|
|
@@ -119,9 +140,9 @@ const L = () => ({
|
|
|
119
140
|
return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
|
|
120
141
|
},
|
|
121
142
|
getActivePredictiveAlgorithms: (t) => {
|
|
122
|
-
const e =
|
|
123
|
-
return t.activePredictiveAlgorithms.filter((n) => !
|
|
124
|
-
r.push(...e.filter((
|
|
143
|
+
const e = I(), r = [];
|
|
144
|
+
return t.activePredictiveAlgorithms.filter((n) => !L.includes(n)).forEach((n) => {
|
|
145
|
+
r.push(...e.filter((s) => s.id === n));
|
|
125
146
|
}), r.map((n) => ({
|
|
126
147
|
text: n.name,
|
|
127
148
|
value: n.key
|
|
@@ -138,7 +159,7 @@ const L = () => ({
|
|
|
138
159
|
getFilterList() {
|
|
139
160
|
return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
|
|
140
161
|
let e;
|
|
141
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
162
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : D.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
142
163
|
text: t.displayName,
|
|
143
164
|
value: e,
|
|
144
165
|
type: t.attributeType
|
|
@@ -160,7 +181,7 @@ const L = () => ({
|
|
|
160
181
|
setCurrentBlock(t) {
|
|
161
182
|
this.blockStates[t] || (this.blockStates = {
|
|
162
183
|
...this.blockStates,
|
|
163
|
-
[t]:
|
|
184
|
+
[t]: R()
|
|
164
185
|
}), this.currentRecommendationId = t;
|
|
165
186
|
},
|
|
166
187
|
/**
|
|
@@ -192,10 +213,10 @@ const L = () => ({
|
|
|
192
213
|
[e]: o
|
|
193
214
|
};
|
|
194
215
|
}
|
|
195
|
-
const n = t.toString(),
|
|
216
|
+
const n = t.toString(), s = e.toString(), i = this.recommendationCampaignUrls[n];
|
|
196
217
|
i && (this.recommendationCampaignUrls = {
|
|
197
218
|
...this.recommendationCampaignUrls,
|
|
198
|
-
[
|
|
219
|
+
[s]: i
|
|
199
220
|
});
|
|
200
221
|
},
|
|
201
222
|
/**
|
|
@@ -220,7 +241,7 @@ const L = () => ({
|
|
|
220
241
|
* `isInitialized`) alone.
|
|
221
242
|
*/
|
|
222
243
|
seedBlockUrlConfig(t, e) {
|
|
223
|
-
const r = (o,
|
|
244
|
+
const r = (o, c) => o === "." || o === "," || o === " " ? o : c, n = {
|
|
224
245
|
name: e.currencyCode,
|
|
225
246
|
value: e.currencyCode,
|
|
226
247
|
symbol: e.currencyCode,
|
|
@@ -228,17 +249,18 @@ const L = () => ({
|
|
|
228
249
|
decimalCount: String(e.currencyDecimalCount),
|
|
229
250
|
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
230
251
|
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
231
|
-
},
|
|
252
|
+
}, s = !this.blockStates[t], i = s ? R() : this.blockStates[t];
|
|
232
253
|
i.recommendationConfigs = {
|
|
233
254
|
...i.recommendationConfigs,
|
|
234
255
|
strategy: e.strategy,
|
|
256
|
+
strategyId: e.strategyId,
|
|
235
257
|
language: e.language,
|
|
236
258
|
size: e.size,
|
|
237
259
|
productIds: e.productIds,
|
|
238
260
|
filters: e.filters,
|
|
239
261
|
shuffleProducts: e.shuffleProducts,
|
|
240
262
|
currencySettings: n
|
|
241
|
-
},
|
|
263
|
+
}, s && (this.blockStates = {
|
|
242
264
|
...this.blockStates,
|
|
243
265
|
[t]: i
|
|
244
266
|
});
|
|
@@ -266,7 +288,7 @@ const L = () => ({
|
|
|
266
288
|
* Creates a filter with the first available attribute and operator pre-selected.
|
|
267
289
|
*/
|
|
268
290
|
createDefaultFilter(t, e) {
|
|
269
|
-
const [r] = this.getFilterList, [n] =
|
|
291
|
+
const [r] = this.getFilterList, [n] = G(r == null ? void 0 : r.type);
|
|
270
292
|
return {
|
|
271
293
|
type: "standardFilter",
|
|
272
294
|
attribute: (r == null ? void 0 : r.value) ?? "",
|
|
@@ -314,20 +336,102 @@ const L = () => ({
|
|
|
314
336
|
t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
|
|
315
337
|
},
|
|
316
338
|
// ====================================================================
|
|
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 + currency.
|
|
379
|
+
* Failures throw 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
|
+
* Currency joins the key because it is sent in the request body, so two
|
|
385
|
+
* currencies can resolve to different paths for the same revision.
|
|
386
|
+
*/
|
|
387
|
+
async resolveStrategyUrlTemplate(t, e) {
|
|
388
|
+
const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
|
|
389
|
+
if (s)
|
|
390
|
+
return s;
|
|
391
|
+
const { full_path: i } = await m.generateStrategyEndpoint(t, e);
|
|
392
|
+
return n && (this.strategyUrlTemplates = {
|
|
393
|
+
...this.strategyUrlTemplates,
|
|
394
|
+
[n]: i
|
|
395
|
+
}), i;
|
|
396
|
+
},
|
|
397
|
+
/**
|
|
398
|
+
* Assigns a strategy to the current block. The config write is
|
|
399
|
+
* synchronous (before any await) so a block switch cannot misdirect
|
|
400
|
+
* it; the configVersion bump persists it to node config and triggers
|
|
401
|
+
* the product refetch via the coordinator control's subscription.
|
|
402
|
+
*/
|
|
403
|
+
assignStrategy(t) {
|
|
404
|
+
this.patchCurrentBlockConfig({
|
|
405
|
+
strategyId: String(t.strategy_id),
|
|
406
|
+
...t.size !== void 0 ? { size: String(t.size) } : {}
|
|
407
|
+
});
|
|
408
|
+
},
|
|
409
|
+
/**
|
|
410
|
+
* Clears the current block's strategy; it falls back to the per-block
|
|
411
|
+
* algorithm settings.
|
|
412
|
+
*
|
|
413
|
+
* `size` goes back to the default rather than staying on the removed
|
|
414
|
+
* strategy's count: with Number of Products hidden in RRS mode, a block
|
|
415
|
+
* left on that count would have no UI to correct it.
|
|
416
|
+
*/
|
|
417
|
+
removeStrategy() {
|
|
418
|
+
this.patchCurrentBlockConfig({ strategyId: "", size: N.size });
|
|
419
|
+
},
|
|
420
|
+
// ====================================================================
|
|
317
421
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
318
422
|
// ====================================================================
|
|
319
423
|
async fetchRecommendationCreateData() {
|
|
320
424
|
if (!this.activePredictiveAlgorithms.length) {
|
|
321
|
-
if (
|
|
322
|
-
await
|
|
425
|
+
if (f) {
|
|
426
|
+
await f;
|
|
323
427
|
return;
|
|
324
428
|
}
|
|
325
|
-
|
|
429
|
+
f = (async () => {
|
|
326
430
|
const {
|
|
327
431
|
activePredictiveAlgorithms: t,
|
|
328
432
|
languages: e,
|
|
329
433
|
currencies: r
|
|
330
|
-
} = await
|
|
434
|
+
} = await m.fetchRecommendationCreateData();
|
|
331
435
|
if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
332
436
|
const n = this.blockStates[this.currentRecommendationId];
|
|
333
437
|
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
@@ -335,26 +439,26 @@ const L = () => ({
|
|
|
335
439
|
this.currencyList = r;
|
|
336
440
|
})();
|
|
337
441
|
try {
|
|
338
|
-
await
|
|
442
|
+
await f;
|
|
339
443
|
} finally {
|
|
340
|
-
|
|
444
|
+
f = null;
|
|
341
445
|
}
|
|
342
446
|
}
|
|
343
447
|
},
|
|
344
448
|
async fetchRecommendationFilters() {
|
|
345
449
|
if (!Object.keys(this.filterList).length) {
|
|
346
|
-
if (
|
|
347
|
-
await
|
|
450
|
+
if (g) {
|
|
451
|
+
await g;
|
|
348
452
|
return;
|
|
349
453
|
}
|
|
350
|
-
|
|
351
|
-
const t = await
|
|
454
|
+
g = (async () => {
|
|
455
|
+
const t = await m.fetchRecommendationFilters();
|
|
352
456
|
this.filterList = t;
|
|
353
457
|
})();
|
|
354
458
|
try {
|
|
355
|
-
await
|
|
459
|
+
await g;
|
|
356
460
|
} finally {
|
|
357
|
-
|
|
461
|
+
g = null;
|
|
358
462
|
}
|
|
359
463
|
}
|
|
360
464
|
},
|
|
@@ -369,10 +473,10 @@ const L = () => ({
|
|
|
369
473
|
deleteFilterGroup(t) {
|
|
370
474
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
371
475
|
return;
|
|
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),
|
|
476
|
+
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]));
|
|
373
477
|
e.recommendationConfigs.filters = r.map((i) => ({
|
|
374
478
|
...i,
|
|
375
|
-
filterGroup:
|
|
479
|
+
filterGroup: s.get(i.filterGroup) ?? i.filterGroup
|
|
376
480
|
}));
|
|
377
481
|
},
|
|
378
482
|
updateFilter(t) {
|
|
@@ -383,7 +487,7 @@ const L = () => ({
|
|
|
383
487
|
const n = [...e.recommendationConfigs.filters];
|
|
384
488
|
n[r] = {
|
|
385
489
|
...t,
|
|
386
|
-
isValid:
|
|
490
|
+
isValid: B(t)
|
|
387
491
|
}, e.recommendationConfigs.filters = n;
|
|
388
492
|
}
|
|
389
493
|
},
|
|
@@ -397,10 +501,10 @@ const L = () => ({
|
|
|
397
501
|
let i = 1;
|
|
398
502
|
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
399
503
|
} else {
|
|
400
|
-
const i = [...new Set(n.map((
|
|
401
|
-
n = n.map((
|
|
402
|
-
...
|
|
403
|
-
filterGroup: o.get(
|
|
504
|
+
const i = [...new Set(n.map((c) => c.filterGroup))].sort((c, a) => c - a), o = new Map(i.map((c, a) => [c, a + 1]));
|
|
505
|
+
n = n.map((c) => ({
|
|
506
|
+
...c,
|
|
507
|
+
filterGroup: o.get(c.filterGroup) ?? c.filterGroup
|
|
404
508
|
}));
|
|
405
509
|
}
|
|
406
510
|
e.recommendationConfigs.filters = n;
|
|
@@ -409,19 +513,19 @@ const L = () => ({
|
|
|
409
513
|
addFilter(t) {
|
|
410
514
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
411
515
|
return;
|
|
412
|
-
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters],
|
|
516
|
+
const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], s = r.filter(
|
|
413
517
|
(o) => o.filterGroup === t.filterGroup
|
|
414
518
|
).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
415
519
|
i !== -1 ? r.splice(i + 1, 0, {
|
|
416
520
|
...t,
|
|
417
|
-
filterNumber:
|
|
521
|
+
filterNumber: s
|
|
418
522
|
}) : r.push({
|
|
419
523
|
...t,
|
|
420
|
-
filterNumber:
|
|
524
|
+
filterNumber: s
|
|
421
525
|
}), e.recommendationConfigs.filters = r;
|
|
422
526
|
},
|
|
423
527
|
generateFilterQuery() {
|
|
424
|
-
return
|
|
528
|
+
return k(this.recommendationConfigs.filters);
|
|
425
529
|
},
|
|
426
530
|
/**
|
|
427
531
|
* Validation-only check invoked at save-CTA time. Defined as an action
|
|
@@ -429,55 +533,95 @@ const L = () => ({
|
|
|
429
533
|
* every block's recommendationConfigs across user edits.
|
|
430
534
|
*/
|
|
431
535
|
hasInvalidBlock() {
|
|
432
|
-
return Object.values(this.blockStates).some((t) => !
|
|
536
|
+
return Object.values(this.blockStates).some((t) => !z(t.recommendationConfigs, this));
|
|
433
537
|
},
|
|
434
538
|
// ====================================================================
|
|
435
539
|
// Per-Block Product Fetching
|
|
436
540
|
// ====================================================================
|
|
437
541
|
async fetchRecommendationProducts() {
|
|
438
542
|
if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
|
|
439
|
-
if (
|
|
440
|
-
await
|
|
543
|
+
if (h) {
|
|
544
|
+
await h;
|
|
441
545
|
return;
|
|
442
546
|
}
|
|
443
|
-
|
|
547
|
+
h = this._doFetchProducts();
|
|
444
548
|
try {
|
|
445
|
-
await
|
|
549
|
+
await h;
|
|
446
550
|
} finally {
|
|
447
|
-
|
|
551
|
+
h = null;
|
|
448
552
|
}
|
|
449
553
|
}
|
|
450
554
|
},
|
|
451
555
|
async _doFetchProducts() {
|
|
452
|
-
var
|
|
453
|
-
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n =
|
|
556
|
+
var d;
|
|
557
|
+
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = F();
|
|
558
|
+
if (r.strategyId) {
|
|
559
|
+
await this._doFetchStrategyProducts(t);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
const s = r.filters.filter((u) => u.isValid), i = k(s), o = ((d = I().find((u) => u.key === r.strategy)) == null ? void 0 : d.path) || "", c = parseInt(r.size) || 6, a = {
|
|
454
563
|
locale: r.language,
|
|
455
564
|
currency: r.currencySettings.value,
|
|
456
|
-
partnerName:
|
|
565
|
+
partnerName: n.partnerName,
|
|
457
566
|
size: r.size,
|
|
458
567
|
details: !0,
|
|
459
|
-
campaignId:
|
|
568
|
+
campaignId: n.variationId
|
|
460
569
|
};
|
|
461
|
-
r.strategy === "manualMerchandising" ? a.productId = r.productIds
|
|
570
|
+
r.strategy === "manualMerchandising" ? a.productId = A(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), i && (a.filter = i), r.shuffleProducts && (a.shuffle = !0), Object.assign(
|
|
462
571
|
a,
|
|
463
|
-
|
|
572
|
+
x(n.partnerName, r.strategy)
|
|
464
573
|
);
|
|
465
|
-
let
|
|
574
|
+
let l;
|
|
466
575
|
try {
|
|
467
|
-
|
|
576
|
+
l = await m.fetchRecommendationProducts(o, a);
|
|
468
577
|
} catch {
|
|
469
|
-
|
|
578
|
+
l = [];
|
|
470
579
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
580
|
+
this._setBlockProducts(t, l, c);
|
|
581
|
+
},
|
|
582
|
+
/**
|
|
583
|
+
* Fetches products for a strategy-backed block: listing lookup →
|
|
584
|
+
* endpoint-generate template → fill {locale}/{currency}, drop
|
|
585
|
+
* {user_id} (resolved at send time) → fetch. Any failure (dead
|
|
586
|
+
* strategy, resolution error) falls back to placeholder products.
|
|
587
|
+
*/
|
|
588
|
+
async _doFetchStrategyProducts(t) {
|
|
589
|
+
const e = (p.get(t) ?? 0) + 1;
|
|
590
|
+
p.set(t, e);
|
|
591
|
+
const { recommendationConfigs: r } = this.blockStates[t];
|
|
592
|
+
let n = [], s = parseInt(r.size) || 6;
|
|
593
|
+
try {
|
|
594
|
+
await this.fetchStrategies();
|
|
595
|
+
const i = this.strategies.find(
|
|
596
|
+
(o) => String(o.strategy_id) === r.strategyId
|
|
597
|
+
);
|
|
598
|
+
if (i) {
|
|
599
|
+
s = parseInt(String(i.size ?? "")) || s;
|
|
600
|
+
const o = r.currencySettings.value, a = (await this.resolveStrategyUrlTemplate(i, o)).replaceAll("{locale}", r.language).replaceAll("{currency}", o), l = a.indexOf("?"), d = l === -1 ? a : a.slice(0, l), u = (l === -1 ? "" : a.slice(l + 1)).split("&").filter((y) => y && !y.startsWith("user_id=")), w = u.length ? `${d}?${u.join("&")}` : d;
|
|
601
|
+
n = await m.fetchRecommendationProductsByUrl(w);
|
|
602
|
+
}
|
|
603
|
+
} catch {
|
|
604
|
+
n = [];
|
|
477
605
|
}
|
|
606
|
+
p.get(t) === e && this._setBlockProducts(t, n, s);
|
|
607
|
+
},
|
|
608
|
+
/**
|
|
609
|
+
* Writes products to a block's state, padded/clipped to exactly `size`:
|
|
610
|
+
* in-place content updates compare the DOM element count against
|
|
611
|
+
* products.length, and a longer list makes the renderer extend its slot
|
|
612
|
+
* grid, which resets migrator-applied styles.
|
|
613
|
+
*/
|
|
614
|
+
_setBlockProducts(t, e, r) {
|
|
615
|
+
if (!this.blockStates[t])
|
|
616
|
+
return;
|
|
617
|
+
const n = e.length > 0 ? e : b(r);
|
|
618
|
+
this.blockStates[t].recommendationProducts = [
|
|
619
|
+
...n.slice(0, r),
|
|
620
|
+
...b(Math.max(0, r - n.length))
|
|
621
|
+
];
|
|
478
622
|
}
|
|
479
623
|
}
|
|
480
624
|
});
|
|
481
625
|
export {
|
|
482
|
-
|
|
626
|
+
Y as useRecommendationExtensionStore
|
|
483
627
|
};
|