@useinsider/guido 2.1.0-beta.42f5dfa → 2.1.0-beta.486ee9c
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 +36 -0
- package/dist/@types/config/schemas.js +70 -65
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +69 -58
- package/dist/components/organisms/base/Toaster.vue.js +4 -4
- package/dist/components/organisms/base/Toaster.vue2.js +12 -9
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +54 -23
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +7 -5
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +34 -21
- package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
- package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +48 -36
- package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +11 -9
- package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
- package/dist/composables/useBlocksConfig.js +26 -16
- package/dist/composables/useHtmlValidator.js +107 -119
- package/dist/composables/useRecommendation.js +9 -9
- package/dist/composables/useStripo.js +25 -23
- package/dist/composables/useVersionHistoryApi.js +1 -1
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -23
- package/dist/config/i18n/en/index.js +11 -0
- package/dist/config/i18n/en/labels.json.js +7 -0
- package/dist/config/i18n/en/toasters.json.js +56 -0
- package/dist/config/i18n/en/tooltips.json.js +82 -0
- package/dist/config/i18n/index.js +7 -0
- package/dist/config/migrator/itemsBlockMigrator.js +127 -122
- package/dist/config/migrator/recommendationMigrator.js +1 -1
- package/dist/enums/defaults.js +8 -4
- package/dist/extensions/Blocks/Recommendation/block.js +26 -23
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +37 -33
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -12
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -11
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +41 -29
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +217 -94
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +97 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +304 -209
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +223 -99
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +237 -140
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +27 -32
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -30
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +22 -27
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +50 -38
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
- package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
- package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
- package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
- package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
- package/dist/extensions/ModulesTabIcons/extension.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
- package/dist/services/recommendationApi.js +11 -9
- package/dist/services/stripoApi.js +20 -17
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
- package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +17 -1
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/config/i18n/en/index.d.ts +1 -0
- package/dist/src/config/i18n/index.d.ts +16 -0
- package/dist/src/enums/defaults.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +12 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +50 -11
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +36 -16
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +50 -17
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +26 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -3
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +14 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
- package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
- package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/static/styles/components/notification.css.js +19 -0
- package/dist/static/styles/components/tools.css.js +6 -2
- package/dist/static/styles/components/version-history.css.js +10 -2
- package/dist/static/styles/components/wide-panel.css.js +18 -2
- package/dist/static/styles/customEditorStyle.css.js +59 -31
- package/dist/static/styles/variables.css.js +2 -0
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/dist/stores/unsubscribe.js +37 -34
- package/package.json +2 -2
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { RecommendationFeedSourceMaps as
|
|
2
|
-
import { useRecommendationApi as
|
|
3
|
-
import { useConfigStore as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
import { DEFAULT_CARDS_IN_ROW as
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { RecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as k } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
|
|
3
|
+
import { useConfigStore as C } from "../../../../stores/config.js";
|
|
4
|
+
import { defineStore as G } from "pinia";
|
|
5
|
+
import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
|
|
6
|
+
import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
|
|
7
|
+
import { getDefaultProducts as S } from "../templates/utils.js";
|
|
8
|
+
import { generateCompleteFilterQuery as I } from "../utils/filterUtil.js";
|
|
9
|
+
import { isFilterValid as D } from "../validation/filterSchema.js";
|
|
10
|
+
const h = y();
|
|
11
|
+
let u = null, m = null, d = null;
|
|
12
|
+
function b() {
|
|
9
13
|
return {
|
|
10
|
-
cardsInRow:
|
|
14
|
+
cardsInRow: F,
|
|
11
15
|
currencySettings: {
|
|
12
16
|
name: "USD",
|
|
13
17
|
value: "USD",
|
|
@@ -20,7 +24,7 @@ function f() {
|
|
|
20
24
|
filters: [],
|
|
21
25
|
productIds: [],
|
|
22
26
|
id: 1,
|
|
23
|
-
language: "
|
|
27
|
+
language: "en_US",
|
|
24
28
|
orientation: "grid",
|
|
25
29
|
recommendedProducts: [],
|
|
26
30
|
sendProductRequestFlag: !1,
|
|
@@ -31,16 +35,18 @@ function f() {
|
|
|
31
35
|
size: "6"
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
|
-
function
|
|
38
|
+
function P() {
|
|
35
39
|
return {
|
|
36
|
-
recommendationConfigs:
|
|
40
|
+
recommendationConfigs: b(),
|
|
37
41
|
recommendationProducts: [],
|
|
38
42
|
filterStatus: !1,
|
|
39
43
|
filterSelectionDrawerStatus: !1,
|
|
40
|
-
filterGroup: 1
|
|
44
|
+
filterGroup: 1,
|
|
45
|
+
isInitialized: !1,
|
|
46
|
+
filterSnapshot: null
|
|
41
47
|
};
|
|
42
48
|
}
|
|
43
|
-
const
|
|
49
|
+
const v = () => ({
|
|
44
50
|
recommendationCampaignUrls: {},
|
|
45
51
|
activePredictiveAlgorithms: [],
|
|
46
52
|
languages: {},
|
|
@@ -49,8 +55,8 @@ const k = () => ({
|
|
|
49
55
|
blockStates: {},
|
|
50
56
|
currentRecommendationId: null,
|
|
51
57
|
configVersion: 0
|
|
52
|
-
}),
|
|
53
|
-
state: () =>
|
|
58
|
+
}), E = G("guidoRecommendationExtension", {
|
|
59
|
+
state: () => v(),
|
|
54
60
|
getters: {
|
|
55
61
|
// ====================================================================
|
|
56
62
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -59,32 +65,32 @@ const k = () => ({
|
|
|
59
65
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationConfigs
|
|
60
66
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
61
67
|
*/
|
|
62
|
-
recommendationConfigs(
|
|
63
|
-
return
|
|
68
|
+
recommendationConfigs(t) {
|
|
69
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : b();
|
|
64
70
|
},
|
|
65
71
|
/**
|
|
66
72
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
67
73
|
*/
|
|
68
|
-
recommendationProducts(
|
|
69
|
-
return
|
|
74
|
+
recommendationProducts(t) {
|
|
75
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationProducts : [];
|
|
70
76
|
},
|
|
71
77
|
/**
|
|
72
78
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterSelectionDrawerStatus
|
|
73
79
|
*/
|
|
74
|
-
filterSelectionDrawerStatus(
|
|
75
|
-
return
|
|
80
|
+
filterSelectionDrawerStatus(t) {
|
|
81
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterSelectionDrawerStatus : !1;
|
|
76
82
|
},
|
|
77
83
|
/**
|
|
78
84
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
|
|
79
85
|
*/
|
|
80
|
-
filterStatus(
|
|
81
|
-
return
|
|
86
|
+
filterStatus(t) {
|
|
87
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterStatus : !1;
|
|
82
88
|
},
|
|
83
89
|
/**
|
|
84
90
|
* Proxy getter: delegates to blockStates[currentRecommendationId].filterGroup
|
|
85
91
|
*/
|
|
86
|
-
filterGroup(
|
|
87
|
-
return
|
|
92
|
+
filterGroup(t) {
|
|
93
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterGroup : 1;
|
|
88
94
|
},
|
|
89
95
|
// ====================================================================
|
|
90
96
|
// Existing Getters (now reading through proxy)
|
|
@@ -92,40 +98,48 @@ const k = () => ({
|
|
|
92
98
|
hasFilters() {
|
|
93
99
|
return !!this.recommendationConfigs.filters.length;
|
|
94
100
|
},
|
|
101
|
+
hasValidFilters() {
|
|
102
|
+
const { filters: t } = this.recommendationConfigs;
|
|
103
|
+
return t.length ? t.every((r) => r.isValid) : !1;
|
|
104
|
+
},
|
|
95
105
|
getFilterGroupCount() {
|
|
96
|
-
const { filters:
|
|
97
|
-
return
|
|
106
|
+
const { filters: t } = this.recommendationConfigs;
|
|
107
|
+
return t.length ? new Set(t.map((r) => r.filterGroup)).size : 0;
|
|
108
|
+
},
|
|
109
|
+
getUniqueFilterGroups() {
|
|
110
|
+
const { filters: t } = this.recommendationConfigs;
|
|
111
|
+
return [...new Set(t.map((r) => r.filterGroup))].sort((r, e) => r - e);
|
|
98
112
|
},
|
|
99
|
-
getActivePredictiveAlgorithms: (
|
|
113
|
+
getActivePredictiveAlgorithms: (t) => {
|
|
100
114
|
const r = [];
|
|
101
|
-
return
|
|
102
|
-
r.push(...
|
|
103
|
-
}), r.map((
|
|
104
|
-
text:
|
|
105
|
-
value:
|
|
115
|
+
return t.activePredictiveAlgorithms.filter((e) => !w.includes(e)).forEach((e) => {
|
|
116
|
+
r.push(...g.filter((n) => n.id === e));
|
|
117
|
+
}), r.map((e) => ({
|
|
118
|
+
text: e.name,
|
|
119
|
+
value: e.key
|
|
106
120
|
}));
|
|
107
121
|
},
|
|
108
|
-
getLanguages: (
|
|
109
|
-
text:
|
|
122
|
+
getLanguages: (t) => Object.entries(t.languages).map(([r, e]) => ({
|
|
123
|
+
text: e,
|
|
110
124
|
value: r
|
|
111
125
|
})),
|
|
112
|
-
getCurrencySymbolList: (
|
|
126
|
+
getCurrencySymbolList: (t) => t.currencyList.map((r) => ({
|
|
113
127
|
text: r.text,
|
|
114
128
|
value: r.text
|
|
115
129
|
})),
|
|
116
130
|
getFilterList() {
|
|
117
|
-
return Object.values(this.filterList).map((
|
|
118
|
-
const r =
|
|
119
|
-
let n = r ?
|
|
120
|
-
return n =
|
|
121
|
-
text:
|
|
131
|
+
return Object.values(this.filterList).map((t) => {
|
|
132
|
+
const r = t.type === "defaultAttribute", e = k.includes(t.attributeName);
|
|
133
|
+
let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
|
|
134
|
+
return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
|
|
135
|
+
text: t.displayName,
|
|
122
136
|
value: n,
|
|
123
|
-
type:
|
|
137
|
+
type: t.attributeType
|
|
124
138
|
};
|
|
125
139
|
});
|
|
126
140
|
},
|
|
127
141
|
getSelectedFilterGroup() {
|
|
128
|
-
return (
|
|
142
|
+
return (t) => [...this.recommendationConfigs.filters].filter((r) => r.filterGroup === t);
|
|
129
143
|
}
|
|
130
144
|
},
|
|
131
145
|
actions: {
|
|
@@ -136,169 +150,252 @@ const k = () => ({
|
|
|
136
150
|
* Sets the currently active block ID.
|
|
137
151
|
* Creates a new entry in blockStates if one doesn't exist.
|
|
138
152
|
*/
|
|
139
|
-
setCurrentBlock(
|
|
140
|
-
this.blockStates[
|
|
153
|
+
setCurrentBlock(t) {
|
|
154
|
+
this.blockStates[t] || (this.blockStates = {
|
|
141
155
|
...this.blockStates,
|
|
142
|
-
[
|
|
143
|
-
}), this.currentRecommendationId =
|
|
156
|
+
[t]: P()
|
|
157
|
+
}), this.currentRecommendationId = t;
|
|
144
158
|
},
|
|
145
159
|
/**
|
|
146
160
|
* Removes a block's state from the store.
|
|
147
161
|
* Resets currentRecommendationId if it was the deleted block.
|
|
148
162
|
*/
|
|
149
|
-
removeBlockState(
|
|
163
|
+
removeBlockState(t) {
|
|
150
164
|
const r = { ...this.blockStates };
|
|
151
|
-
if (delete r[
|
|
152
|
-
const
|
|
153
|
-
this.currentRecommendationId =
|
|
165
|
+
if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
|
|
166
|
+
const e = Object.keys(this.blockStates).map(Number);
|
|
167
|
+
this.currentRecommendationId = e.length > 0 ? e[0] : null;
|
|
154
168
|
}
|
|
155
169
|
},
|
|
170
|
+
/**
|
|
171
|
+
* Marks a block as initialized (initial API data has been fetched).
|
|
172
|
+
* Automatically cleaned up when removeBlockState deletes the block entry.
|
|
173
|
+
*/
|
|
174
|
+
markBlockInitialized(t) {
|
|
175
|
+
this.blockStates[t] && (this.blockStates[t].isInitialized = !0);
|
|
176
|
+
},
|
|
156
177
|
/**
|
|
157
178
|
* Patches the current block's recommendationConfigs.
|
|
158
179
|
* Replaces `store.$patch({ recommendationConfigs: { ... } })` pattern.
|
|
159
180
|
*/
|
|
160
|
-
patchCurrentBlockConfig(
|
|
181
|
+
patchCurrentBlockConfig(t, r = {}) {
|
|
161
182
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
162
183
|
return;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
...
|
|
166
|
-
...
|
|
184
|
+
const e = this.blockStates[this.currentRecommendationId];
|
|
185
|
+
e.recommendationConfigs = {
|
|
186
|
+
...e.recommendationConfigs,
|
|
187
|
+
...t,
|
|
167
188
|
currencySettings: {
|
|
168
|
-
...
|
|
169
|
-
...
|
|
189
|
+
...e.recommendationConfigs.currencySettings,
|
|
190
|
+
...t.currencySettings || {}
|
|
170
191
|
}
|
|
171
192
|
};
|
|
172
193
|
const { triggerRefetch: n = !0 } = r;
|
|
173
194
|
n && this.configVersion++;
|
|
174
195
|
},
|
|
175
196
|
/**
|
|
176
|
-
*
|
|
177
|
-
* If no filters exist, initializes with a default empty filter
|
|
178
|
-
* so the user has a starting point for input.
|
|
197
|
+
* Creates a filter with the first available attribute and operator pre-selected.
|
|
179
198
|
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const e = this.blockStates[this.currentRecommendationId];
|
|
184
|
-
e.recommendationConfigs.filters.length || (e.recommendationConfigs.filters = [{
|
|
199
|
+
createDefaultFilter(t, r) {
|
|
200
|
+
const [e] = this.getFilterList, [n] = R(e == null ? void 0 : e.type);
|
|
201
|
+
return {
|
|
185
202
|
type: "standardFilter",
|
|
186
|
-
attribute: "",
|
|
187
|
-
|
|
188
|
-
operator: "",
|
|
203
|
+
attribute: (e == null ? void 0 : e.value) ?? "",
|
|
204
|
+
operator: (n == null ? void 0 : n.value) ?? "",
|
|
189
205
|
innerGroupOperator: "*",
|
|
190
206
|
outerGroupOperator: "*",
|
|
191
|
-
filterNumber:
|
|
192
|
-
filterGroup:
|
|
207
|
+
filterNumber: r,
|
|
208
|
+
filterGroup: t,
|
|
193
209
|
isValid: !1,
|
|
194
210
|
value: ""
|
|
195
|
-
}
|
|
211
|
+
};
|
|
196
212
|
},
|
|
197
213
|
/**
|
|
198
|
-
*
|
|
214
|
+
* Opens the filter selection drawer for the current block.
|
|
215
|
+
* Saves a snapshot of current filters for cancel/revert.
|
|
216
|
+
* If no filters exist, initializes with a default filter
|
|
217
|
+
* so the user has a starting point for input.
|
|
218
|
+
*/
|
|
219
|
+
openFilterDrawer() {
|
|
220
|
+
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
221
|
+
return;
|
|
222
|
+
const t = this.blockStates[this.currentRecommendationId];
|
|
223
|
+
t.filterSnapshot = JSON.parse(
|
|
224
|
+
JSON.stringify(t.recommendationConfigs.filters)
|
|
225
|
+
), t.recommendationConfigs.filters.length || (t.recommendationConfigs.filters = [this.createDefaultFilter(1, 1)]), t.filterSelectionDrawerStatus = !0;
|
|
226
|
+
},
|
|
227
|
+
/**
|
|
228
|
+
* Closes the filter selection drawer for the current block.
|
|
229
|
+
* Called after successful apply — discards the snapshot.
|
|
199
230
|
*/
|
|
200
231
|
closeFilterDrawer() {
|
|
201
|
-
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId]
|
|
232
|
+
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
233
|
+
return;
|
|
234
|
+
const t = this.blockStates[this.currentRecommendationId];
|
|
235
|
+
t.filterSnapshot = null, t.filterSelectionDrawerStatus = !1;
|
|
236
|
+
},
|
|
237
|
+
/**
|
|
238
|
+
* Cancels the filter selection drawer and reverts filters
|
|
239
|
+
* to the snapshot taken when the drawer was opened.
|
|
240
|
+
*/
|
|
241
|
+
cancelFilterDrawer() {
|
|
242
|
+
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
243
|
+
return;
|
|
244
|
+
const t = this.blockStates[this.currentRecommendationId];
|
|
245
|
+
t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
|
|
202
246
|
},
|
|
203
247
|
// ====================================================================
|
|
204
248
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
205
249
|
// ====================================================================
|
|
206
250
|
async fetchRecommendationCreateData() {
|
|
207
|
-
if (this.activePredictiveAlgorithms.length)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
251
|
+
if (!this.activePredictiveAlgorithms.length) {
|
|
252
|
+
if (u) {
|
|
253
|
+
await u;
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
u = (async () => {
|
|
257
|
+
const {
|
|
258
|
+
activePredictiveAlgorithms: t,
|
|
259
|
+
languages: r,
|
|
260
|
+
currencies: e
|
|
261
|
+
} = await h.fetchRecommendationCreateData();
|
|
262
|
+
if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
263
|
+
const n = this.blockStates[this.currentRecommendationId];
|
|
264
|
+
n.filterStatus = !!n.recommendationConfigs.filters.length;
|
|
265
|
+
}
|
|
266
|
+
this.currencyList = e;
|
|
267
|
+
})();
|
|
268
|
+
try {
|
|
269
|
+
await u;
|
|
270
|
+
} finally {
|
|
271
|
+
u = null;
|
|
272
|
+
}
|
|
219
273
|
}
|
|
220
|
-
this.currencyList = t;
|
|
221
274
|
},
|
|
222
275
|
async fetchRecommendationFilters() {
|
|
223
|
-
|
|
224
|
-
|
|
276
|
+
if (!Object.keys(this.filterList).length) {
|
|
277
|
+
if (m) {
|
|
278
|
+
await m;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
m = (async () => {
|
|
282
|
+
const t = await h.fetchRecommendationFilters();
|
|
283
|
+
this.filterList = t;
|
|
284
|
+
})();
|
|
285
|
+
try {
|
|
286
|
+
await m;
|
|
287
|
+
} finally {
|
|
288
|
+
m = null;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
225
291
|
},
|
|
226
292
|
// ====================================================================
|
|
227
293
|
// Per-Block Filter Actions
|
|
228
294
|
// ====================================================================
|
|
229
|
-
addFilterGroup(
|
|
230
|
-
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
filterGroup:
|
|
241
|
-
});
|
|
295
|
+
addFilterGroup(t) {
|
|
296
|
+
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push(
|
|
297
|
+
this.createDefaultFilter(t, 1)
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
deleteFilterGroup(t) {
|
|
301
|
+
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
302
|
+
return;
|
|
303
|
+
const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o), c = new Map(n.map((i, o) => [i, o + 1]));
|
|
304
|
+
r.recommendationConfigs.filters = e.map((i) => ({
|
|
305
|
+
...i,
|
|
306
|
+
filterGroup: c.get(i.filterGroup) ?? i.filterGroup
|
|
307
|
+
}));
|
|
242
308
|
},
|
|
243
|
-
updateFilter(
|
|
309
|
+
updateFilter(t) {
|
|
244
310
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
245
311
|
return;
|
|
246
|
-
const r = this.blockStates[this.currentRecommendationId],
|
|
247
|
-
if (
|
|
312
|
+
const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
313
|
+
if (e !== -1) {
|
|
248
314
|
const n = [...r.recommendationConfigs.filters];
|
|
249
|
-
n[
|
|
315
|
+
n[e] = {
|
|
316
|
+
...t,
|
|
317
|
+
isValid: D(t)
|
|
318
|
+
}, r.recommendationConfigs.filters = n;
|
|
250
319
|
}
|
|
251
320
|
},
|
|
252
|
-
deleteFilter(
|
|
321
|
+
deleteFilter(t) {
|
|
253
322
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
254
323
|
return;
|
|
255
|
-
const r = this.blockStates[this.currentRecommendationId],
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
n.splice(
|
|
324
|
+
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
|
|
325
|
+
if (e !== -1) {
|
|
326
|
+
let n = [...r.recommendationConfigs.filters];
|
|
327
|
+
if (n.splice(e, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
|
|
328
|
+
let i = 1;
|
|
329
|
+
n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
|
|
330
|
+
} else {
|
|
331
|
+
const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, l) => s - l), o = new Map(i.map((s, l) => [s, l + 1]));
|
|
332
|
+
n = n.map((s) => ({
|
|
333
|
+
...s,
|
|
334
|
+
filterGroup: o.get(s.filterGroup) ?? s.filterGroup
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
r.recommendationConfigs.filters = n;
|
|
259
338
|
}
|
|
260
339
|
},
|
|
261
|
-
addFilter(
|
|
340
|
+
addFilter(t) {
|
|
262
341
|
if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
|
|
263
342
|
return;
|
|
264
|
-
const r = this.blockStates[this.currentRecommendationId],
|
|
265
|
-
(
|
|
266
|
-
).length + 1, i =
|
|
267
|
-
i !== -1 ?
|
|
268
|
-
...
|
|
269
|
-
filterNumber:
|
|
270
|
-
}) :
|
|
271
|
-
...
|
|
272
|
-
filterNumber:
|
|
273
|
-
}), r.recommendationConfigs.filters =
|
|
343
|
+
const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], c = e.filter(
|
|
344
|
+
(o) => o.filterGroup === t.filterGroup
|
|
345
|
+
).length + 1, i = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
|
|
346
|
+
i !== -1 ? e.splice(i + 1, 0, {
|
|
347
|
+
...t,
|
|
348
|
+
filterNumber: c
|
|
349
|
+
}) : e.push({
|
|
350
|
+
...t,
|
|
351
|
+
filterNumber: c
|
|
352
|
+
}), r.recommendationConfigs.filters = e;
|
|
274
353
|
},
|
|
275
354
|
generateFilterQuery() {
|
|
276
|
-
return
|
|
355
|
+
return I(this.recommendationConfigs.filters);
|
|
277
356
|
},
|
|
278
357
|
// ====================================================================
|
|
279
358
|
// Per-Block Product Fetching
|
|
280
359
|
// ====================================================================
|
|
281
360
|
async fetchRecommendationProducts() {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
361
|
+
if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
|
|
362
|
+
if (d) {
|
|
363
|
+
await d;
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
d = this._doFetchProducts();
|
|
367
|
+
try {
|
|
368
|
+
await d;
|
|
369
|
+
} finally {
|
|
370
|
+
d = null;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
async _doFetchProducts() {
|
|
375
|
+
var p;
|
|
376
|
+
const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((a) => a.isValid), c = I(n), i = ((p = g.find((a) => a.key === e.strategy)) == null ? void 0 : p.path) || "", o = C(), s = {
|
|
377
|
+
locale: e.language,
|
|
378
|
+
currency: e.currencySettings.value,
|
|
379
|
+
partnerName: o.partnerName,
|
|
380
|
+
size: e.size,
|
|
290
381
|
details: !0,
|
|
291
|
-
campaignId:
|
|
382
|
+
campaignId: o.variationId
|
|
292
383
|
};
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
384
|
+
e.strategy === "manualMerchandising" ? s.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (s.productId = "{itemId}"), e.strategy === "userBased" && (s.userId = "{user_id}"), c && (s.filter = c), e.shuffleProducts && (s.shuffle = !0);
|
|
385
|
+
const l = parseInt(e.size) || 6;
|
|
386
|
+
let f;
|
|
387
|
+
try {
|
|
388
|
+
f = await h.fetchRecommendationProducts(i, s);
|
|
389
|
+
} catch {
|
|
390
|
+
f = [];
|
|
391
|
+
}
|
|
392
|
+
if (this.blockStates[t]) {
|
|
393
|
+
const a = f.length > 0 ? f : S(l);
|
|
394
|
+
this.blockStates[t].recommendationProducts = a.length < l ? [...a, ...S(l - a.length)] : a;
|
|
395
|
+
}
|
|
299
396
|
}
|
|
300
397
|
}
|
|
301
398
|
});
|
|
302
399
|
export {
|
|
303
|
-
|
|
400
|
+
E as useRecommendationExtensionStore
|
|
304
401
|
};
|