@useinsider/guido 3.19.0-beta.c8d2be8 → 3.19.0-beta.d04f200
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/dist/@types/config/schemas.js +104 -91
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +79 -74
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useActionsApi.js +52 -47
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useHttp.js +48 -49
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useStripo.js +24 -20
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/recommendationPartnerMigrator.js +50 -0
- package/dist/enums/extensions/recommendationBlock.js +30 -29
- package/dist/extensions/Blocks/Recommendation/block.js +15 -14
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -29
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/utils/stripoEditorApi.d.ts +4 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/stores/unsubscribe.js +3 -3
- package/dist/utils/stripoEditorApi.js +11 -0
- package/package.json +2 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateItemsBlock as
|
|
4
|
-
import { migrateProductNameLink as
|
|
5
|
-
import { migrateRadioButton as
|
|
6
|
-
import { migrateRecommendation as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { migrateCheckbox as i } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as e } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateItemsBlock as a } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateProductNameLink as n } from "./productNameLinkMigrator.js";
|
|
5
|
+
import { migrateRadioButton as c } from "./radioButtonMigrator.js";
|
|
6
|
+
import { migrateRecommendation as g } from "./recommendationMigrator.js";
|
|
7
|
+
import { migrateRecommendationPartnerScope as f } from "./recommendationPartnerMigrator.js";
|
|
8
|
+
import { migrateRecommendationTitle as p } from "./recommendationTitleMigrator.js";
|
|
9
|
+
import { migrateSocialIcons as d } from "./socialIconMigrator.js";
|
|
10
|
+
import { migrateUnsubscribe as l } from "./unsubscribeMigrator.js";
|
|
11
|
+
const h = async (r, t = {}, o) => {
|
|
12
|
+
let m = r;
|
|
13
|
+
return m = i(m), m = c(m), m = await l(m), m = e(m), m = g(m, t), o && (m = f(m, o)), m = p(m), m = a(m), m = n(m), m = d(m), m;
|
|
13
14
|
};
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
+
h as migrate
|
|
16
17
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { RECOMMENDATION_ID_ATTR as f, SELECTOR_ATTRIBUTE_ROW as _, ATTR_DATA_ATTRIBUTE_TYPE as a, ATTR_CUSTOM_PREFIX as g, ATTR_DATA_CARD_COMPOSITION as O, ATTR_DATA_CUSTOM_ATTRIBUTES as R } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
import { carriesForeignPartnerConfig as m, canJudgeUnstampedBlock as E, withoutCustomAttributes as d } from "../../extensions/Blocks/Recommendation/utils/partnerScope.js";
|
|
3
|
+
const S = ".recommendation-block-v2[esd-ext-config]", c = "esd-ext-config";
|
|
4
|
+
function C(t) {
|
|
5
|
+
const e = t.getAttribute(c);
|
|
6
|
+
if (!e)
|
|
7
|
+
return null;
|
|
8
|
+
try {
|
|
9
|
+
const r = JSON.parse(e);
|
|
10
|
+
return r && typeof r == "object" && !Array.isArray(r) ? r : null;
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function I(t, e, r) {
|
|
16
|
+
const o = d(e.composition ?? []);
|
|
17
|
+
t.querySelectorAll(_).forEach((i) => {
|
|
18
|
+
var s;
|
|
19
|
+
(s = i.getAttribute(a)) != null && s.startsWith(g) && i.remove();
|
|
20
|
+
}), t.setAttribute(O, o.join(",")), t.setAttribute(R, "[]"), t.setAttribute(c, JSON.stringify({
|
|
21
|
+
...e,
|
|
22
|
+
strategyId: "",
|
|
23
|
+
strategy: "",
|
|
24
|
+
filters: [],
|
|
25
|
+
productIds: [],
|
|
26
|
+
composition: o,
|
|
27
|
+
partnerName: r
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function p(t, { partnerName: e, campaignUrls: r, rrsEnabled: o }) {
|
|
31
|
+
if (!e)
|
|
32
|
+
return t;
|
|
33
|
+
const i = new DOMParser().parseFromString(t, "text/html"), s = Array.from(i.querySelectorAll(S));
|
|
34
|
+
if (s.length === 0)
|
|
35
|
+
return t;
|
|
36
|
+
let T = 0;
|
|
37
|
+
return s.forEach((u) => {
|
|
38
|
+
const n = C(u), A = Number(u.getAttribute(f));
|
|
39
|
+
if (!(!n || !Number.isFinite(A))) {
|
|
40
|
+
if (m({ config: n, blockId: A, partnerName: e, campaignUrls: r, rrsEnabled: o })) {
|
|
41
|
+
I(u, n, e), T += 1;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
n.partnerName || !E({ config: n, campaignUrls: r, rrsEnabled: o }) || (u.setAttribute(c, JSON.stringify({ ...n, partnerName: e })), T += 1);
|
|
45
|
+
}
|
|
46
|
+
}), T > 0 ? i.documentElement.outerHTML : t;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
p as migrateRecommendationPartnerScope
|
|
50
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTranslations as s } from "../../composables/useTranslations.js";
|
|
2
|
-
const
|
|
2
|
+
const t = {
|
|
3
3
|
RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
|
|
4
4
|
// Relative path → same-origin as the embedding inone dashboard.
|
|
5
5
|
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
|
|
@@ -9,17 +9,17 @@ const a = {
|
|
|
9
9
|
MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/migrate-strategies",
|
|
10
10
|
// The template route narrows the recommendations resource before the action: the id
|
|
11
11
|
// travels in the body, not the path.
|
|
12
|
-
TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
const { RECOMMENDATION_STRATEGIES_PANEL_PATH: n } =
|
|
18
|
-
return `${n}/${e}/edit
|
|
19
|
-
}, m = {
|
|
20
|
-
campaign: a.MIGRATE_STRATEGIES_PATH,
|
|
21
|
-
template: a.TEMPLATE_MIGRATE_STRATEGIES_PATH
|
|
12
|
+
TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies"
|
|
13
|
+
}, d = () => {
|
|
14
|
+
const { RECOMMENDATION_STRATEGIES_PANEL_PATH: e } = t;
|
|
15
|
+
return `${e}/create`;
|
|
16
|
+
}, m = (e) => {
|
|
17
|
+
const { RECOMMENDATION_STRATEGIES_PANEL_PATH: n } = t;
|
|
18
|
+
return `${n}/${e}/edit`;
|
|
22
19
|
}, T = {
|
|
20
|
+
campaign: t.MIGRATE_STRATEGIES_PATH,
|
|
21
|
+
template: t.TEMPLATE_MIGRATE_STRATEGIES_PATH
|
|
22
|
+
}, p = {
|
|
23
23
|
CLIENT_ID: "clientId"
|
|
24
24
|
}, E = () => {
|
|
25
25
|
const e = s();
|
|
@@ -85,21 +85,21 @@ const a = {
|
|
|
85
85
|
path: "top-sellers"
|
|
86
86
|
}
|
|
87
87
|
];
|
|
88
|
-
},
|
|
88
|
+
}, A = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], v = [
|
|
89
89
|
{ text: "before the amount", value: "0" },
|
|
90
90
|
{ text: "after the amount", value: "1" }
|
|
91
|
-
],
|
|
91
|
+
], _ = [
|
|
92
92
|
{ text: "dot(.)", value: "." },
|
|
93
93
|
{ text: "comma(,)", value: "," },
|
|
94
94
|
{ text: "space( )", value: " " }
|
|
95
|
-
],
|
|
95
|
+
], h = [
|
|
96
96
|
{ text: "0", value: "0" },
|
|
97
97
|
{ text: "1", value: "1" },
|
|
98
98
|
{ text: "2", value: "2" },
|
|
99
99
|
{ text: "3", value: "3" },
|
|
100
100
|
{ text: "4", value: "4" },
|
|
101
101
|
{ text: "5", value: "5" }
|
|
102
|
-
], r = "||",
|
|
102
|
+
], r = "||", a = [
|
|
103
103
|
{ text: "is exactly", value: "=" },
|
|
104
104
|
{ text: "contains", value: "~" },
|
|
105
105
|
{ text: "does not contain", value: "!~" },
|
|
@@ -121,9 +121,9 @@ const a = {
|
|
|
121
121
|
], c = [
|
|
122
122
|
{ text: "true", value: "==" },
|
|
123
123
|
{ text: "false", value: "!=" }
|
|
124
|
-
],
|
|
124
|
+
], x = (e) => {
|
|
125
125
|
if (!e)
|
|
126
|
-
return
|
|
126
|
+
return a;
|
|
127
127
|
switch (e) {
|
|
128
128
|
case "Boolean":
|
|
129
129
|
return c;
|
|
@@ -132,28 +132,29 @@ const a = {
|
|
|
132
132
|
case "Number":
|
|
133
133
|
return i;
|
|
134
134
|
case "String":
|
|
135
|
-
return
|
|
135
|
+
return a;
|
|
136
136
|
case "Strings":
|
|
137
137
|
return o;
|
|
138
138
|
default:
|
|
139
|
-
return
|
|
139
|
+
return a;
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
export {
|
|
143
|
-
|
|
143
|
+
T as MIGRATION_PATHS,
|
|
144
144
|
r as OP_ANY_OF,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
A as PriceAttributes,
|
|
146
|
+
p as QUERY_PARAMS,
|
|
147
|
+
t as URLS,
|
|
148
|
+
h as currencyDecimalCounts,
|
|
149
|
+
v as currencyLocationMaps,
|
|
150
|
+
_ as currencyOperators,
|
|
151
|
+
x as getOperatorOptions,
|
|
152
152
|
E as getRecommendationFeedSourceMaps,
|
|
153
153
|
o as operatorOptionsForArrayOfStrings,
|
|
154
154
|
c as operatorOptionsForBooleans,
|
|
155
155
|
u as operatorOptionsForDates,
|
|
156
156
|
i as operatorOptionsForNumbers,
|
|
157
|
-
|
|
158
|
-
d as
|
|
157
|
+
a as operatorOptionsForStrings,
|
|
158
|
+
d as strategyCreatePath,
|
|
159
|
+
m as strategyEditPath
|
|
159
160
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
2
|
var A = (l, c, t) => c in l ? y(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
3
|
+
var h = (l, c, t) => A(l, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as d } from "../../../composables/useConfig.js";
|
|
5
5
|
import { BlockId as D } from "../../../enums/block.js";
|
|
6
6
|
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
7
7
|
import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
@@ -10,9 +10,9 @@ import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
|
10
10
|
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
11
11
|
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as w } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
13
|
+
import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
|
|
14
14
|
import { getDefaultTemplate as T } from "./templates/grid/template.js";
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
15
|
+
import { useRecommendationBlockWarning as v } from "./useRecommendationBlockWarning.js";
|
|
16
16
|
const k = D.Recommendation, u = "recommendation-block-v2", B = "hide-price";
|
|
17
17
|
let b = !1;
|
|
18
18
|
class j extends E {
|
|
@@ -22,9 +22,9 @@ class j extends E {
|
|
|
22
22
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
23
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
h(this, "_pendingBlockId", null);
|
|
26
26
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
27
|
-
|
|
27
|
+
h(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
28
28
|
}
|
|
29
29
|
getId() {
|
|
30
30
|
return k;
|
|
@@ -91,18 +91,19 @@ class j extends E {
|
|
|
91
91
|
}
|
|
92
92
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
93
93
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
94
|
-
const n =
|
|
94
|
+
const n = d().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: a } = s.initializeConfig(
|
|
95
95
|
this.api,
|
|
96
96
|
t,
|
|
97
97
|
{
|
|
98
98
|
recommendationId: i,
|
|
99
99
|
configVersion: n ? N : O,
|
|
100
|
+
...o ? { partnerName: d().partnerName.value } : {},
|
|
100
101
|
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
101
102
|
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
102
103
|
// at save for a block the user never configured.
|
|
103
104
|
...o ? { strategy: "" } : {}
|
|
104
105
|
}
|
|
105
|
-
), f =
|
|
106
|
+
), f = g();
|
|
106
107
|
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
107
108
|
I(this.api);
|
|
108
109
|
const _ = this._getBlockElement(t);
|
|
@@ -151,7 +152,7 @@ class j extends E {
|
|
|
151
152
|
*/
|
|
152
153
|
onDelete(t) {
|
|
153
154
|
const e = this._getRecommendationId(t);
|
|
154
|
-
e &&
|
|
155
|
+
e && g().removeBlockState(e);
|
|
155
156
|
}
|
|
156
157
|
/**
|
|
157
158
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -167,7 +168,7 @@ class j extends E {
|
|
|
167
168
|
*/
|
|
168
169
|
_warnIfMultipleBlocks() {
|
|
169
170
|
try {
|
|
170
|
-
|
|
171
|
+
v().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
171
172
|
} catch {
|
|
172
173
|
}
|
|
173
174
|
}
|
|
@@ -197,9 +198,9 @@ class j extends E {
|
|
|
197
198
|
* the renamed one depending on where the module was dropped (SD-149916).
|
|
198
199
|
*/
|
|
199
200
|
_scheduleArrivalReset(t) {
|
|
200
|
-
|
|
201
|
+
d().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
201
202
|
const e = this._getRecommendationId(t);
|
|
202
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
203
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && g().resetArrivedBlock(e);
|
|
203
204
|
}, 0);
|
|
204
205
|
}
|
|
205
206
|
/**
|
|
@@ -255,8 +256,8 @@ class j extends E {
|
|
|
255
256
|
}
|
|
256
257
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
257
258
|
_handleDuplicate(t, e) {
|
|
258
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
259
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i),
|
|
259
|
+
const i = this._reassignDuplicateId(t, e), n = g();
|
|
260
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), d().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), n.resetArrivedBlock(i)), this._warnIfMultipleBlocks();
|
|
260
261
|
}
|
|
261
262
|
/**
|
|
262
263
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (g,
|
|
4
|
-
import { useConfig as
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var p = (g, u, t) => u in g ? C(g, u, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[u] = t;
|
|
3
|
+
var i = (g, u, t) => p(g, typeof u != "symbol" ? u + "" : u, t);
|
|
4
|
+
import { useConfig as h } from "../../../../../composables/useConfig.js";
|
|
5
5
|
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as N } from "../../../common-control.js";
|
|
7
7
|
import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
8
|
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
-
import { RecommendationConfigService as
|
|
9
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
11
|
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
|
-
import { ALGORITHM_CONTROL_ID as
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
15
|
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
@@ -29,9 +29,9 @@ import { ShuffleControl as D } from "./shuffle.js";
|
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
30
|
import { StrategyControl as w } from "./strategy.js";
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as
|
|
34
|
-
import { useDebounceFn as
|
|
32
|
+
import { setCurrencyAttributes as v, getBlockElement as A, isPartnerManagedBlock as B, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as vt, regenerateMobileProductRows as At, updatePricesInPlace as Bt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const W = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
@@ -58,7 +58,7 @@ class at extends N {
|
|
|
58
58
|
/**
|
|
59
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
60
|
*/
|
|
61
|
-
i(this, "_debouncedFetchProducts",
|
|
61
|
+
i(this, "_debouncedFetchProducts", f(async () => {
|
|
62
62
|
try {
|
|
63
63
|
await this.store.fetchRecommendationProducts();
|
|
64
64
|
} finally {
|
|
@@ -76,12 +76,12 @@ class at extends N {
|
|
|
76
76
|
* count. The store pads products to the configured size, so in-place only
|
|
77
77
|
* fails when the size actually changed.
|
|
78
78
|
*/
|
|
79
|
-
i(this, "_debouncedRegenerateWithProducts",
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
80
80
|
const t = this.store.recommendationProducts;
|
|
81
81
|
if (!this.currentNode || !this.api)
|
|
82
82
|
return;
|
|
83
83
|
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
84
|
-
if (
|
|
84
|
+
if (B(this.currentNode)) {
|
|
85
85
|
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
@@ -115,7 +115,7 @@ class at extends N {
|
|
|
115
115
|
}
|
|
116
116
|
getTemplate() {
|
|
117
117
|
var t;
|
|
118
|
-
return this.rrsEnabled =
|
|
118
|
+
return this.rrsEnabled = h().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
119
119
|
var o;
|
|
120
120
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
121
121
|
}), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new k(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
|
|
@@ -140,7 +140,7 @@ class at extends N {
|
|
|
140
140
|
const e = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
141
141
|
if (!e)
|
|
142
142
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null :
|
|
143
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
|
|
144
144
|
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
145
145
|
}
|
|
146
146
|
async onRender() {
|
|
@@ -209,23 +209,30 @@ class at extends N {
|
|
|
209
209
|
const e = this.store.blockStates[t];
|
|
210
210
|
if (!e)
|
|
211
211
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
212
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
|
|
213
213
|
e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
214
214
|
}
|
|
215
215
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
216
|
_isPendingStrategyIdChange() {
|
|
217
217
|
const t = this.pendingNodeConfigWrite;
|
|
218
|
-
return t ?
|
|
218
|
+
return t ? c.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
219
219
|
}
|
|
220
220
|
_capturePendingNodeConfigWrite() {
|
|
221
221
|
const t = this.store.currentRecommendationId;
|
|
222
222
|
if (!this.currentNode || !this.api || t === null)
|
|
223
223
|
return;
|
|
224
|
-
const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs;
|
|
224
|
+
const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs, { partnerName: l } = h();
|
|
225
225
|
this.pendingNodeConfigWrite = {
|
|
226
226
|
blockId: t,
|
|
227
227
|
node: this.currentNode,
|
|
228
|
-
updates: {
|
|
228
|
+
updates: {
|
|
229
|
+
filters: e,
|
|
230
|
+
strategy: o,
|
|
231
|
+
strategyId: n,
|
|
232
|
+
size: s,
|
|
233
|
+
configVersion: r,
|
|
234
|
+
...l.value ? { partnerName: l.value } : {}
|
|
235
|
+
}
|
|
229
236
|
};
|
|
230
237
|
}
|
|
231
238
|
/**
|
|
@@ -240,7 +247,7 @@ class at extends N {
|
|
|
240
247
|
*/
|
|
241
248
|
_stagePendingNodeConfig(t) {
|
|
242
249
|
const e = this.pendingNodeConfigWrite;
|
|
243
|
-
return !e || !this.currentNode ? !1 : (
|
|
250
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
244
251
|
}
|
|
245
252
|
/**
|
|
246
253
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -264,12 +271,12 @@ class at extends N {
|
|
|
264
271
|
const t = this.pendingNodeConfigWrite;
|
|
265
272
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
266
273
|
return;
|
|
267
|
-
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o =
|
|
268
|
-
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size ||
|
|
274
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
275
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
269
276
|
}
|
|
270
277
|
_syncNodeConfigToStore() {
|
|
271
278
|
var n;
|
|
272
|
-
const t =
|
|
279
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
273
280
|
this.store.patchCurrentBlockConfig({
|
|
274
281
|
strategy: t.strategy,
|
|
275
282
|
strategyId: t.strategyId,
|
|
@@ -334,12 +341,12 @@ class at extends N {
|
|
|
334
341
|
_applySmartDefaults() {
|
|
335
342
|
if (!this.currentNode || !this.api)
|
|
336
343
|
return;
|
|
337
|
-
const t =
|
|
344
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
338
345
|
let o = null, n = null, s = null;
|
|
339
346
|
if (t.currency.code === a.currency.code) {
|
|
340
347
|
const { currencyList: r } = this.store;
|
|
341
348
|
r.length > 0 && (r.some(
|
|
342
|
-
(
|
|
349
|
+
(d) => d.value === `price.${a.currency.code}`
|
|
343
350
|
) || (o = r[0].value.replace("price.", ""), e.currency = {
|
|
344
351
|
...a.currency,
|
|
345
352
|
code: o,
|
|
@@ -349,21 +356,21 @@ class at extends N {
|
|
|
349
356
|
if (t.strategy === a.strategy) {
|
|
350
357
|
const r = this.store.getActivePredictiveAlgorithms;
|
|
351
358
|
r.length > 0 && (r.some(
|
|
352
|
-
(
|
|
359
|
+
(d) => d.value === a.strategy
|
|
353
360
|
) || (n = r[0].value, e.strategy = n));
|
|
354
361
|
}
|
|
355
362
|
if (t.language === a.language) {
|
|
356
363
|
const r = this.store.getLanguages;
|
|
357
364
|
r.length > 0 && (r.some(
|
|
358
|
-
(
|
|
365
|
+
(d) => d.value === a.language
|
|
359
366
|
) || (s = r[0].value, e.language = s));
|
|
360
367
|
}
|
|
361
|
-
!o && !n && !s || (
|
|
368
|
+
!o && !n && !s || (c.updateConfig(
|
|
362
369
|
this.api,
|
|
363
370
|
this.currentNode,
|
|
364
371
|
e,
|
|
365
372
|
"Applied smart defaults"
|
|
366
|
-
), o && e.currency &&
|
|
373
|
+
), o && e.currency && v({
|
|
367
374
|
currentNode: this.currentNode,
|
|
368
375
|
documentModifier: this.api.getDocumentModifier(),
|
|
369
376
|
currency: e.currency
|
|
@@ -387,7 +394,7 @@ class at extends N {
|
|
|
387
394
|
* Reads the recommendation-id attribute from the block element within the node
|
|
388
395
|
*/
|
|
389
396
|
_getRecommendationIdFromNode(t) {
|
|
390
|
-
const e =
|
|
397
|
+
const e = A(t);
|
|
391
398
|
if (!e || !("getAttribute" in e))
|
|
392
399
|
return null;
|
|
393
400
|
const o = e.getAttribute(I);
|
|
@@ -420,13 +427,13 @@ class at extends N {
|
|
|
420
427
|
}
|
|
421
428
|
const r = t.$state.configVersion;
|
|
422
429
|
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
423
|
-
const
|
|
424
|
-
|
|
430
|
+
const l = t.recommendationProducts, d = l !== e, m = Array.isArray(l) && l.length > 0;
|
|
431
|
+
d && m && (e = l, this._debouncedRegenerateWithProducts());
|
|
425
432
|
});
|
|
426
433
|
}
|
|
427
434
|
}
|
|
428
435
|
export {
|
|
429
|
-
|
|
436
|
+
ut as ALGORITHM_CONTROL_ID,
|
|
430
437
|
T as AlgorithmControl,
|
|
431
438
|
W as CONTROL_BLOCK_ID,
|
|
432
439
|
gt as CURRENCY_CONTROL_ID,
|
|
@@ -450,15 +457,15 @@ export {
|
|
|
450
457
|
w as StrategyControl,
|
|
451
458
|
Et as adjustProductsToSize,
|
|
452
459
|
Ft as formatProductPrice,
|
|
453
|
-
|
|
460
|
+
A as getBlockElement,
|
|
454
461
|
Dt as getCardComposition,
|
|
455
462
|
wt as getCurrentLayout,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
463
|
+
vt as getMainContainerTbody,
|
|
464
|
+
B as isPartnerManagedBlock,
|
|
465
|
+
At as regenerateMobileProductRows,
|
|
459
466
|
U as regenerateProductRowsWithStyles,
|
|
460
|
-
|
|
461
|
-
|
|
467
|
+
v as setCurrencyAttributes,
|
|
468
|
+
Bt as updatePricesInPlace,
|
|
462
469
|
x as updateProductContentInPlace,
|
|
463
470
|
xt as updateSingleProductContent
|
|
464
471
|
};
|