@useinsider/guido 3.19.0-beta.3abc7c5 → 3.19.0-beta.3d545d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/@types/config/schemas.js +31 -33
- package/dist/components/Guido.vue.js +9 -9
- package/dist/components/Guido.vue2.js +57 -58
- package/dist/components/organisms/AutoSaveController.vue2.js +8 -9
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +29 -0
- package/dist/components/organisms/header/EditorActions.vue.js +5 -5
- package/dist/components/organisms/header/EditorActions.vue2.js +55 -85
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +12 -16
- package/dist/components/wrappers/WpDrawer.vue.js +7 -9
- package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useAuthError.js +51 -0
- package/dist/composables/useHtmlCompiler.js +26 -37
- package/dist/composables/useHtmlValidator.js +0 -2
- package/dist/composables/useHttp.js +58 -51
- package/dist/composables/useSave.js +45 -90
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/validators/useCouponBlockValidator.js +21 -24
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +27 -34
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +47 -54
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/components/Guido.vue.d.ts +1 -17
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -17
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -17
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -17
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +3 -4
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +11 -0
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/composables/useHtmlValidator.d.ts +0 -21
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/composables/useSave.d.ts +1 -6
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -5
- package/dist/src/stores/config.d.ts +0 -32
- package/dist/src/utils/templatePreparation.d.ts +0 -30
- package/dist/stores/config.js +67 -84
- package/dist/utils/templatePreparation.js +36 -39
- package/package.json +1 -1
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +0 -20
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +0 -48
- package/dist/composables/useSaveValidation.js +0 -279
- package/dist/composables/useSaveValidationRollout.js +0 -9
- package/dist/enums/save-validation.js +0 -4
- package/dist/src/@types/save-validation.d.ts +0 -19
- package/dist/src/composables/useSaveValidation.d.ts +0 -6
- package/dist/src/composables/useSaveValidationRollout.d.ts +0 -3
- package/dist/src/enums/save-validation.d.ts +0 -27
- package/dist/src/stores/save-validation.d.ts +0 -22
- package/dist/stores/save-validation.js +0 -30
- /package/dist/src/components/organisms/{validation/ValidationErrorDrawer.vue.d.ts → base/AuthErrorModal.vue.d.ts} +0 -0
|
@@ -1,100 +1,55 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
1
|
+
import { useActionsApi as T } from "./useActionsApi.js";
|
|
2
2
|
import { useConfig as q } from "./useConfig.js";
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { useSaveStart as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const r = D(), f = F(), { validateHtml: p } = _(), { validateLiquidSyntax: v } = et(), { validateCouponBlockTags: y } = tt(), { validateUnsubscribeBlockUniqueness: S, validateUnsubscribeBlockHasTemplate: w } = st(), { validateSyncModuleBlocks: u } = ot(), { callbacks: a, isFeatureEnabled: m } = q(), { extractSyncModuleData: b } = G(), { setSyncModuleUnsubscriptionPages: g } = J(), { editorSave: E, getTemplateData: H } = W(), { showToaster: V } = $(), { getBlockedDomains: x, resolveToast: k } = Z(), { prepareTemplateDetails: d } = X(), { collectSaveValidationErrors: C } = j(), { isEnabled: B } = z(), T = Q(), h = N(), P = K(), { runExclusive: n } = O(), l = async (t, e, o) => {
|
|
23
|
-
if (!m("allowlistEnabled"))
|
|
24
|
-
return !1;
|
|
25
|
-
const i = await x(t, e);
|
|
26
|
-
if (!i.length)
|
|
27
|
-
return !1;
|
|
28
|
-
if (!o) {
|
|
29
|
-
const s = await k(i);
|
|
30
|
-
s != null && s.message && V({
|
|
31
|
-
type: I.Warning,
|
|
32
|
-
message: s.message,
|
|
33
|
-
actionButton: s.actionButton
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return !0;
|
|
37
|
-
}, L = async (t) => !y(t.compiledHtml) || !S(t.compiledHtml) || !w(t.compiledHtml) ? !1 : m("liquidSyntax") ? v(t.compiledHtml) : p(t.compiledHtml, t.dynamicContentList, !0), c = async (t, e) => {
|
|
38
|
-
if (!await E())
|
|
3
|
+
import { useEditorLock as C } from "./useEditorLock.js";
|
|
4
|
+
import { useSaveStart as L, useSaveComplete as M } from "./useGuidoActions.js";
|
|
5
|
+
import { useSyncModuleExtractor as D } from "./useSyncModuleExtractor.js";
|
|
6
|
+
import { ToasterTypeOptions as P } from "../enums/toaster.js";
|
|
7
|
+
import { useStripoApi as U } from "../services/stripoApi.js";
|
|
8
|
+
import { useTemplatePreparation as A } from "../utils/templatePreparation.js";
|
|
9
|
+
import { useAllowlist as h } from "./useAllowlist.js";
|
|
10
|
+
import { useHtmlValidator as F } from "./useHtmlValidator.js";
|
|
11
|
+
import { useToaster as O } from "./useToaster.js";
|
|
12
|
+
import { useCouponBlockValidator as W } from "./validators/useCouponBlockValidator.js";
|
|
13
|
+
import { useLiquidValidator as j } from "./validators/useLiquidValidator.js";
|
|
14
|
+
import { useSyncModuleBlockValidator as z } from "./validators/useSyncModuleBlockValidator.js";
|
|
15
|
+
import { useUnsubscribeBlockValidator as G } from "./validators/useUnsubscribeBlockValidator.js";
|
|
16
|
+
const rt = () => {
|
|
17
|
+
const n = L(), c = M(), { validateHtml: d } = F(), { validateLiquidSyntax: m } = j(), { validateCouponBlockTags: u } = W(), { validateUnsubscribeBlockUniqueness: p, validateUnsubscribeBlockHasTemplate: f } = G(), { validateSyncModuleBlocks: v } = z(), { callbacks: s, isFeatureEnabled: r } = q(), { extractSyncModuleData: S } = D(), { setSyncModuleUnsubscriptionPages: b } = U(), { editorSave: w } = T(), { showToaster: V } = O(), { getBlockedDomains: y, resolveToast: k } = h(), { runExclusive: x } = C(), H = async (a, o) => {
|
|
18
|
+
var l;
|
|
19
|
+
n();
|
|
20
|
+
const { prepareTemplateDetails: B } = A(), t = await B();
|
|
21
|
+
if (!v(t.rawHtml, o) || !u(t.compiledHtml) || !p(t.compiledHtml) || !f(t.compiledHtml))
|
|
39
22
|
return;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const R = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
|
|
43
|
-
f({ ...t, ...R, silent: e.silent });
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
}, U = async (t, e) => {
|
|
47
|
-
var i;
|
|
48
|
-
r();
|
|
49
|
-
const o = await d();
|
|
50
|
-
if (u(o.rawHtml, e)) {
|
|
51
|
-
if (B.value && !e) {
|
|
52
|
-
const s = await C(
|
|
53
|
-
o.compiledHtml,
|
|
54
|
-
o.dynamicContentList
|
|
55
|
-
);
|
|
56
|
-
if (s.length) {
|
|
57
|
-
T.open(s, "save");
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
} else if (!await L(o))
|
|
23
|
+
if (r("liquidSyntax")) {
|
|
24
|
+
if (!await m(t.compiledHtml))
|
|
61
25
|
return;
|
|
62
|
-
|
|
63
|
-
return c(o, { silent: e, suppress: t });
|
|
64
|
-
}
|
|
65
|
-
}, A = async () => {
|
|
66
|
-
var e;
|
|
67
|
-
if (!P.allowSaveWithErrors)
|
|
26
|
+
} else if (!await d(t.compiledHtml, t.dynamicContentList, !0))
|
|
68
27
|
return;
|
|
69
|
-
|
|
70
|
-
const t = await d();
|
|
71
|
-
if (!((e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t)) && !await l(t.compiledHtml, t.css, !1))
|
|
72
|
-
return c(t, { silent: !1, blankCompiled: !0 });
|
|
73
|
-
}, M = async () => {
|
|
74
|
-
r();
|
|
75
|
-
const { html: t, css: e } = await H();
|
|
76
|
-
if (!u(t, !0) || await l(t, e, !0))
|
|
28
|
+
if ((l = s.value) != null && l.externalValidation && !await s.value.externalValidation(t))
|
|
77
29
|
return;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
30
|
+
if (r("allowlistEnabled")) {
|
|
31
|
+
const i = await y(t.compiledHtml, t.css);
|
|
32
|
+
if (i.length) {
|
|
33
|
+
if (!o) {
|
|
34
|
+
const e = await k(i);
|
|
35
|
+
e != null && e.message && V({
|
|
36
|
+
type: P.Warning,
|
|
37
|
+
message: e.message,
|
|
38
|
+
actionButton: e.actionButton
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
90
42
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
43
|
+
}
|
|
44
|
+
if (!await w())
|
|
45
|
+
return;
|
|
46
|
+
const { unsubscribePayload: E, stripoModules: g } = S(t.rawHtml);
|
|
47
|
+
return await b(E), t.modules = g, a || c({ ...t, silent: o }), t;
|
|
93
48
|
};
|
|
94
|
-
return { save: (
|
|
95
|
-
() =>
|
|
96
|
-
)
|
|
49
|
+
return { save: (a = !1, o = !1) => x(
|
|
50
|
+
() => H(a, o)
|
|
51
|
+
) };
|
|
97
52
|
};
|
|
98
53
|
export {
|
|
99
|
-
|
|
54
|
+
rt as useSave
|
|
100
55
|
};
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { ToasterTypeOptions as T } from "../enums/toaster.js";
|
|
2
|
-
import { useToasterStore as
|
|
3
|
-
import { nextTick as
|
|
2
|
+
import { useToasterStore as u } from "../stores/toaster.js";
|
|
3
|
+
import { nextTick as c } from "vue";
|
|
4
4
|
const s = /* @__PURE__ */ new WeakMap(), p = () => {
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
const t = u(), o = () => {
|
|
6
|
+
const e = s.get(t);
|
|
7
|
+
e && (clearTimeout(e), s.delete(t));
|
|
8
8
|
};
|
|
9
|
-
function
|
|
10
|
-
o(),
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
function i(e = { message: "" }) {
|
|
10
|
+
o(), t.hideToaster(), c(() => {
|
|
11
|
+
t.showToaster(e), t.shouldAutoHide && s.set(t, setTimeout(() => {
|
|
12
|
+
t.hideToaster(), o();
|
|
13
13
|
}, 6e3));
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
o(),
|
|
16
|
+
function n() {
|
|
17
|
+
o(), t.hideToaster();
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
function a(e, r) {
|
|
20
|
+
if (e != null && e.authReported)
|
|
21
|
+
return;
|
|
22
|
+
const m = e instanceof Error ? e.message : String(e);
|
|
23
|
+
i({ type: T.Error, message: `${r}: ${m}` });
|
|
22
24
|
}
|
|
23
|
-
return { showToaster:
|
|
25
|
+
return { showToaster: i, hideToaster: n, handleError: a };
|
|
24
26
|
};
|
|
25
27
|
export {
|
|
26
28
|
p as useToaster
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
import { ToasterTypeOptions as
|
|
2
|
-
import { COUPON_PLACEHOLDER_DEFAULT as
|
|
3
|
-
import { useToaster as
|
|
4
|
-
import { useTranslations as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
]),
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}), !1) : !0 };
|
|
1
|
+
import { ToasterTypeOptions as c } from "../../enums/toaster.js";
|
|
2
|
+
import { COUPON_PLACEHOLDER_DEFAULT as i, COUPON_PLACEHOLDER_LIQUID as l } from "../../extensions/Blocks/CouponBlock/template.js";
|
|
3
|
+
import { useToaster as m } from "../useToaster.js";
|
|
4
|
+
import { useTranslations as p } from "../useTranslations.js";
|
|
5
|
+
const u = /* @__PURE__ */ new Set([
|
|
6
|
+
i,
|
|
7
|
+
l
|
|
8
|
+
]), A = () => {
|
|
9
|
+
const { showToaster: t } = m(), r = p();
|
|
10
|
+
return { validateCouponBlockTags: (e) => {
|
|
11
|
+
const n = new DOMParser().parseFromString(e, "text/html");
|
|
12
|
+
return Array.from(n.querySelectorAll(".coupon-block")).find((s) => {
|
|
13
|
+
var o;
|
|
14
|
+
const a = ((o = s.textContent) == null ? void 0 : o.trim()) ?? "";
|
|
15
|
+
return !u.has(a);
|
|
16
|
+
}) ? (t({
|
|
17
|
+
type: c.Warning,
|
|
18
|
+
message: r("newsletter.coupon-tag-modified")
|
|
19
|
+
}), !1) : !0;
|
|
20
|
+
} };
|
|
22
21
|
};
|
|
23
22
|
export {
|
|
24
|
-
|
|
25
|
-
u as findInvalidCouponBlocks,
|
|
26
|
-
T as useCouponBlockValidator
|
|
23
|
+
A as useCouponBlockValidator
|
|
27
24
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ToasterTypeOptions as
|
|
1
|
+
import { ToasterTypeOptions as r } from "../../enums/toaster.js";
|
|
2
2
|
import { base64EncodeWithSpecialChars as u } from "../../utils/base64.js";
|
|
3
3
|
import { useHttp as d } from "../useHttp.js";
|
|
4
|
-
import { useToaster as
|
|
5
|
-
import { useTranslations as
|
|
4
|
+
import { useToaster as p } from "../useToaster.js";
|
|
5
|
+
import { useTranslations as c } from "../useTranslations.js";
|
|
6
6
|
const v = () => {
|
|
7
|
-
const { post: i } = d(), { showToaster:
|
|
7
|
+
const { post: i } = d(), { showToaster: t } = p(), s = c();
|
|
8
8
|
return { validateLiquidSyntax: async (o) => {
|
|
9
9
|
try {
|
|
10
|
-
const
|
|
10
|
+
const e = await i("/newsletter/contents/validate-syntax", [{
|
|
11
11
|
identifier: "default",
|
|
12
12
|
syntax: "liquid",
|
|
13
13
|
contents: {
|
|
@@ -17,21 +17,21 @@ const v = () => {
|
|
|
17
17
|
ampHtml: null
|
|
18
18
|
}
|
|
19
19
|
}]);
|
|
20
|
-
if (!Array.isArray(
|
|
21
|
-
const l =
|
|
22
|
-
return
|
|
23
|
-
type:
|
|
20
|
+
if (!Array.isArray(e.data)) {
|
|
21
|
+
const l = e.data;
|
|
22
|
+
return t({
|
|
23
|
+
type: r.Warning,
|
|
24
24
|
message: l.message ?? s("journey-builder.liquid-validation-failed")
|
|
25
25
|
}), !1;
|
|
26
26
|
}
|
|
27
|
-
const [
|
|
28
|
-
return n.length ? (
|
|
29
|
-
type:
|
|
27
|
+
const [a] = e.data, n = Object.values((a == null ? void 0 : a.errors) ?? {});
|
|
28
|
+
return n.length ? (t({
|
|
29
|
+
type: r.Warning,
|
|
30
30
|
message: n[0].replace(/^line \d+:\s*/, "")
|
|
31
31
|
}), !1) : !0;
|
|
32
|
-
} catch {
|
|
33
|
-
return e({
|
|
34
|
-
type:
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return e != null && e.authReported || t({
|
|
34
|
+
type: r.Error,
|
|
35
35
|
message: s("journey-builder.liquid-validation-failed")
|
|
36
36
|
}), !1;
|
|
37
37
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ToasterTypeOptions as
|
|
1
|
+
import { ToasterTypeOptions as i } from "../../enums/toaster.js";
|
|
2
2
|
import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
|
|
3
|
-
import { UNSUBSCRIBE_BLOCK_SELECTOR as
|
|
4
|
-
import { useToaster as
|
|
5
|
-
import { useTranslations as
|
|
3
|
+
import { UNSUBSCRIBE_BLOCK_SELECTOR as l, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
4
|
+
import { useToaster as E } from "../useToaster.js";
|
|
5
|
+
import { useTranslations as m } from "../useTranslations.js";
|
|
6
6
|
const T = [
|
|
7
7
|
{
|
|
8
8
|
pageType: u.GLOBAL_UNSUBSCRIBE,
|
|
@@ -12,37 +12,30 @@ const T = [
|
|
|
12
12
|
pageType: u.SUBSCRIPTION_PREFERENCE_CENTER,
|
|
13
13
|
messageKey: "unsubscription-preference.duplicate-pref-center"
|
|
14
14
|
}
|
|
15
|
-
], g = "unsubscription-preference.duplicate-both",
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return !n || !e;
|
|
28
|
-
}).length;
|
|
29
|
-
}
|
|
30
|
-
const y = () => {
|
|
31
|
-
const { showToaster: r } = p(), s = l();
|
|
32
|
-
return { validateUnsubscribeBlockUniqueness: (e) => {
|
|
33
|
-
const o = m(e);
|
|
34
|
-
return o.length ? (r({
|
|
35
|
-
type: c.Error,
|
|
36
|
-
message: s(o.length > 1 ? g : o[0].messageKey)
|
|
15
|
+
], g = "unsubscription-preference.duplicate-both", b = "unsubscription-preference.select-page-to-continue", P = () => {
|
|
16
|
+
const { showToaster: c } = E(), p = m();
|
|
17
|
+
return { validateUnsubscribeBlockUniqueness: (n) => {
|
|
18
|
+
const o = new DOMParser().parseFromString(n, "text/html"), r = /* @__PURE__ */ new Map();
|
|
19
|
+
o.querySelectorAll(l).forEach((e) => {
|
|
20
|
+
const s = Number(e.getAttribute(a.PAGE_TYPE));
|
|
21
|
+
r.set(s, (r.get(s) ?? 0) + 1);
|
|
22
|
+
});
|
|
23
|
+
const t = T.filter((e) => (r.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
|
|
24
|
+
return t.length ? (c({
|
|
25
|
+
type: i.Error,
|
|
26
|
+
message: p(t.length > 1 ? g : t[0])
|
|
37
27
|
}), !1) : !0;
|
|
38
|
-
}, validateUnsubscribeBlockHasTemplate: (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
}, validateUnsubscribeBlockHasTemplate: (n) => {
|
|
29
|
+
const o = new DOMParser().parseFromString(n, "text/html");
|
|
30
|
+
return Array.from(o.querySelectorAll(l)).some((t) => {
|
|
31
|
+
const e = t.getAttribute(a.PAGE_TYPE), s = t.getAttribute(a.PAGE_LIST);
|
|
32
|
+
return !e || !s;
|
|
33
|
+
}) ? (c({
|
|
34
|
+
type: i.Warning,
|
|
35
|
+
message: p(b)
|
|
36
|
+
}), !1) : !0;
|
|
37
|
+
} };
|
|
42
38
|
};
|
|
43
39
|
export {
|
|
44
|
-
|
|
45
|
-
b as countUnsubBlocksWithoutPage,
|
|
46
|
-
m as findDuplicateUnsubPageTypes,
|
|
47
|
-
y as useUnsubscribeBlockValidator
|
|
40
|
+
P as useUnsubscribeBlockValidator
|
|
48
41
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { useToaster as
|
|
2
|
-
import { useTranslations as
|
|
3
|
-
import { getRecommendationFeedSourceMaps as F, strategyEditPath as
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import { useRecommendationApi as
|
|
6
|
-
import { useConfigStore as
|
|
7
|
-
import { defineStore as
|
|
1
|
+
import { useToaster as D } from "../../../../composables/useToaster.js";
|
|
2
|
+
import { useTranslations as L } from "../../../../composables/useTranslations.js";
|
|
3
|
+
import { getRecommendationFeedSourceMaps as F, strategyEditPath as U, URLS as E, getOperatorOptions as N, PriceAttributes as M } from "../../../../enums/extensions/recommendationBlock.js";
|
|
4
|
+
import { ToasterTypeOptions as A } from "../../../../enums/toaster.js";
|
|
5
|
+
import { useRecommendationApi as T } from "../../../../services/recommendationApi.js";
|
|
6
|
+
import { useConfigStore as k } from "../../../../stores/config.js";
|
|
7
|
+
import { defineStore as B } from "pinia";
|
|
8
8
|
import "../constants/selectors.js";
|
|
9
|
-
import { DEFAULT_MOBILE_CARDS_IN_ROW as
|
|
10
|
-
import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as
|
|
9
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as O, DEFAULT_CARDS_IN_ROW as z } from "../constants/layout.js";
|
|
10
|
+
import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as x, EXCLUDED_ALGORITHM_IDS as V } from "../constants/defaultConfig.js";
|
|
11
11
|
import { getDefaultProducts as w } from "../templates/utils.js";
|
|
12
12
|
import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
|
|
13
|
-
import { isLegacyStrategyConfig as
|
|
14
|
-
import { getPartnerRecommendationParams as
|
|
15
|
-
import { sanitizeProductIds as
|
|
16
|
-
import { isFilterValid as
|
|
17
|
-
import { getInvalidFields as
|
|
18
|
-
const m =
|
|
19
|
-
let S = null, p = null, y = null, I = "",
|
|
13
|
+
import { isLegacyStrategyConfig as j } from "../utils/legacyStrategyMigration.js";
|
|
14
|
+
import { getPartnerRecommendationParams as $ } from "../utils/partnerCustomizations.js";
|
|
15
|
+
import { sanitizeProductIds as q } from "../utils/productIds.js";
|
|
16
|
+
import { isFilterValid as K } from "../validation/filterSchema.js";
|
|
17
|
+
import { getInvalidFields as H, isConfigValid as J } from "../validation/requiredFields.js";
|
|
18
|
+
const m = T();
|
|
19
|
+
let S = null, p = null, y = null, I = "", R = null, b = 0;
|
|
20
20
|
const g = /* @__PURE__ */ new Map();
|
|
21
21
|
let l = null;
|
|
22
|
-
function
|
|
22
|
+
function _() {
|
|
23
23
|
return {
|
|
24
|
-
cardsInRow:
|
|
24
|
+
cardsInRow: z,
|
|
25
25
|
currencySettings: {
|
|
26
26
|
name: "USD",
|
|
27
27
|
value: "USD",
|
|
@@ -35,7 +35,7 @@ function D() {
|
|
|
35
35
|
productIds: [],
|
|
36
36
|
id: 1,
|
|
37
37
|
language: "en_US",
|
|
38
|
-
mobileCardsInRow:
|
|
38
|
+
mobileCardsInRow: O,
|
|
39
39
|
mobileLayoutEnabled: !1,
|
|
40
40
|
orientation: "grid",
|
|
41
41
|
recommendedProducts: [],
|
|
@@ -45,7 +45,7 @@ function D() {
|
|
|
45
45
|
// that default is what reached buildCampaignUrl and baked a most-popular feed URL
|
|
46
46
|
// for a block the user never configured (SD-149916). Legacy blocks still get their real
|
|
47
47
|
// algorithm from the node-config sync or the save-time seed.
|
|
48
|
-
strategy:
|
|
48
|
+
strategy: k().isFeatureEnabled("reusableRecommendationStrategy") ? "" : "mostPopular",
|
|
49
49
|
strategyId: "",
|
|
50
50
|
nodeConfigVersion: C,
|
|
51
51
|
textTrimming: !0,
|
|
@@ -56,9 +56,9 @@ function D() {
|
|
|
56
56
|
priceHideIfSameAsDiscounted: !1
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function G() {
|
|
60
60
|
return {
|
|
61
|
-
recommendationConfigs:
|
|
61
|
+
recommendationConfigs: _(),
|
|
62
62
|
recommendationProducts: [],
|
|
63
63
|
filterStatus: !1,
|
|
64
64
|
filterSelectionDrawerStatus: !1,
|
|
@@ -87,7 +87,7 @@ const Q = () => ({
|
|
|
87
87
|
currentRecommendationId: null,
|
|
88
88
|
strategyPanelOpen: !1,
|
|
89
89
|
configVersion: 0
|
|
90
|
-
}), ft =
|
|
90
|
+
}), ft = B("guidoRecommendationExtension", {
|
|
91
91
|
state: () => Q(),
|
|
92
92
|
getters: {
|
|
93
93
|
// ====================================================================
|
|
@@ -98,7 +98,7 @@ const Q = () => ({
|
|
|
98
98
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
99
99
|
*/
|
|
100
100
|
recommendationConfigs(t) {
|
|
101
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
101
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : _();
|
|
102
102
|
},
|
|
103
103
|
/**
|
|
104
104
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -119,7 +119,7 @@ const Q = () => ({
|
|
|
119
119
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
|
|
120
120
|
},
|
|
121
121
|
isLegacyStrategyBlock() {
|
|
122
|
-
return
|
|
122
|
+
return k().isFeatureEnabled("reusableRecommendationStrategy") && j(this.recommendationConfigs);
|
|
123
123
|
},
|
|
124
124
|
legacyConversionLoading(t) {
|
|
125
125
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading ?? !1 : !1;
|
|
@@ -163,7 +163,7 @@ const Q = () => ({
|
|
|
163
163
|
},
|
|
164
164
|
getActivePredictiveAlgorithms: (t) => {
|
|
165
165
|
const e = F(), r = [];
|
|
166
|
-
return t.activePredictiveAlgorithms.filter((n) => !
|
|
166
|
+
return t.activePredictiveAlgorithms.filter((n) => !V.includes(n)).forEach((n) => {
|
|
167
167
|
r.push(...e.filter((s) => s.id === n));
|
|
168
168
|
}), r.map((n) => ({
|
|
169
169
|
text: n.name,
|
|
@@ -181,7 +181,7 @@ const Q = () => ({
|
|
|
181
181
|
getFilterList() {
|
|
182
182
|
return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
|
|
183
183
|
let e;
|
|
184
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
184
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : M.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
185
185
|
text: t.displayName,
|
|
186
186
|
value: e,
|
|
187
187
|
type: t.attributeType
|
|
@@ -203,7 +203,7 @@ const Q = () => ({
|
|
|
203
203
|
setCurrentBlock(t) {
|
|
204
204
|
this.blockStates[t] || (this.blockStates = {
|
|
205
205
|
...this.blockStates,
|
|
206
|
-
[t]:
|
|
206
|
+
[t]: G()
|
|
207
207
|
}), this.currentRecommendationId = t;
|
|
208
208
|
},
|
|
209
209
|
/**
|
|
@@ -234,7 +234,7 @@ const Q = () => ({
|
|
|
234
234
|
const r = this.blockStates[t];
|
|
235
235
|
if (r) {
|
|
236
236
|
const o = structuredClone(r);
|
|
237
|
-
o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId &&
|
|
237
|
+
o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId && k().isFeatureEnabled("reusableRecommendationStrategy") && (o.isInitialized = !1, o.syncedConfigFingerprint = null), this.blockStates = {
|
|
238
238
|
...this.blockStates,
|
|
239
239
|
[e]: o
|
|
240
240
|
};
|
|
@@ -275,7 +275,7 @@ const Q = () => ({
|
|
|
275
275
|
decimalCount: String(e.currencyDecimalCount),
|
|
276
276
|
decimalSeparator: r(e.currencyDecimalSeparator, ","),
|
|
277
277
|
thousandSeparator: r(e.currencyThousandSeparator, ".")
|
|
278
|
-
}, s = !this.blockStates[t], i = s ?
|
|
278
|
+
}, s = !this.blockStates[t], i = s ? G() : this.blockStates[t];
|
|
279
279
|
i.recommendationConfigs = {
|
|
280
280
|
...i.recommendationConfigs,
|
|
281
281
|
strategy: e.strategy,
|
|
@@ -314,7 +314,7 @@ const Q = () => ({
|
|
|
314
314
|
* Creates a filter with the first available attribute and operator pre-selected.
|
|
315
315
|
*/
|
|
316
316
|
createDefaultFilter(t, e) {
|
|
317
|
-
const [r] = this.getFilterList, [n] =
|
|
317
|
+
const [r] = this.getFilterList, [n] = N(r == null ? void 0 : r.type);
|
|
318
318
|
return {
|
|
319
319
|
type: "standardFilter",
|
|
320
320
|
attribute: (r == null ? void 0 : r.value) ?? "",
|
|
@@ -380,9 +380,9 @@ const Q = () => ({
|
|
|
380
380
|
this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].removeStrategyModalStatus = !1);
|
|
381
381
|
},
|
|
382
382
|
async fetchStrategies() {
|
|
383
|
-
for (;
|
|
383
|
+
for (; R; )
|
|
384
384
|
try {
|
|
385
|
-
await
|
|
385
|
+
await R;
|
|
386
386
|
} catch {
|
|
387
387
|
}
|
|
388
388
|
if (this.strategiesFetched)
|
|
@@ -398,11 +398,11 @@ const Q = () => ({
|
|
|
398
398
|
this.strategiesLoading = !1, t === b && (this.strategiesSettled = !0);
|
|
399
399
|
}
|
|
400
400
|
})();
|
|
401
|
-
|
|
401
|
+
R = e;
|
|
402
402
|
try {
|
|
403
403
|
await e;
|
|
404
404
|
} finally {
|
|
405
|
-
|
|
405
|
+
R = null;
|
|
406
406
|
}
|
|
407
407
|
},
|
|
408
408
|
/**
|
|
@@ -434,9 +434,9 @@ const Q = () => ({
|
|
|
434
434
|
_armStrategyPageReturn(t) {
|
|
435
435
|
const e = window.open(t, "_blank");
|
|
436
436
|
if (!e)
|
|
437
|
-
return
|
|
438
|
-
type:
|
|
439
|
-
message:
|
|
437
|
+
return D().showToaster({
|
|
438
|
+
type: A.Error,
|
|
439
|
+
message: L()("discovery-strategy.error-description")
|
|
440
440
|
}), !1;
|
|
441
441
|
e.opener = null, l == null || l();
|
|
442
442
|
let r = !1;
|
|
@@ -471,14 +471,14 @@ const Q = () => ({
|
|
|
471
471
|
* new strategy is offered; the user picks it themselves.
|
|
472
472
|
*/
|
|
473
473
|
openStrategyCreation() {
|
|
474
|
-
return this._armStrategyPageReturn(
|
|
474
|
+
return this._armStrategyPageReturn(E.RECOMMENDATION_STRATEGY_CREATE_PATH);
|
|
475
475
|
},
|
|
476
476
|
/**
|
|
477
477
|
* Opens the strategy's edit page. Every return refreshes the list so the block reflects the
|
|
478
478
|
* edited configuration.
|
|
479
479
|
*/
|
|
480
480
|
openStrategyEdit(t) {
|
|
481
|
-
return this._armStrategyPageReturn(
|
|
481
|
+
return this._armStrategyPageReturn(U(t));
|
|
482
482
|
},
|
|
483
483
|
async resolveStrategyUrlTemplate(t, e) {
|
|
484
484
|
const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
|
|
@@ -532,7 +532,7 @@ const Q = () => ({
|
|
|
532
532
|
this.patchCurrentBlockConfig({
|
|
533
533
|
strategyId: "",
|
|
534
534
|
strategy: "",
|
|
535
|
-
size:
|
|
535
|
+
size: x.size,
|
|
536
536
|
nodeConfigVersion: C
|
|
537
537
|
});
|
|
538
538
|
},
|
|
@@ -606,7 +606,7 @@ const Q = () => ({
|
|
|
606
606
|
const n = [...e.recommendationConfigs.filters];
|
|
607
607
|
n[r] = {
|
|
608
608
|
...t,
|
|
609
|
-
isValid:
|
|
609
|
+
isValid: K(t)
|
|
610
610
|
}, e.recommendationConfigs.filters = n;
|
|
611
611
|
}
|
|
612
612
|
},
|
|
@@ -652,21 +652,14 @@ const Q = () => ({
|
|
|
652
652
|
* every block's recommendationConfigs across user edits.
|
|
653
653
|
*/
|
|
654
654
|
hasInvalidBlock() {
|
|
655
|
-
return Object.values(this.blockStates).some((t) => !
|
|
656
|
-
},
|
|
657
|
-
/**
|
|
658
|
-
* Per-instance counterpart to `hasInvalidBlock`: the ids of every block
|
|
659
|
-
* that fails required-field validation, one drawer row each (SD-147430).
|
|
660
|
-
*/
|
|
661
|
-
invalidBlockIds() {
|
|
662
|
-
return Object.entries(this.blockStates).filter(([, t]) => !G(t.recommendationConfigs, this)).map(([t]) => t);
|
|
655
|
+
return Object.values(this.blockStates).some((t) => !J(t.recommendationConfigs, this));
|
|
663
656
|
},
|
|
664
657
|
/**
|
|
665
658
|
* Which required fields are missing across the design's blocks, so the save
|
|
666
659
|
* toaster can name the cause instead of always showing the generic message.
|
|
667
660
|
*/
|
|
668
661
|
invalidBlockFields() {
|
|
669
|
-
return Object.values(this.blockStates).flatMap((t) =>
|
|
662
|
+
return Object.values(this.blockStates).flatMap((t) => H(t.recommendationConfigs, this));
|
|
670
663
|
},
|
|
671
664
|
// ====================================================================
|
|
672
665
|
// Per-Block Product Fetching
|
|
@@ -692,7 +685,7 @@ const Q = () => ({
|
|
|
692
685
|
},
|
|
693
686
|
async _doFetchProducts() {
|
|
694
687
|
var h;
|
|
695
|
-
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n =
|
|
688
|
+
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = k();
|
|
696
689
|
if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
|
|
697
690
|
await this._doFetchStrategyProducts(t);
|
|
698
691
|
return;
|
|
@@ -712,9 +705,9 @@ const Q = () => ({
|
|
|
712
705
|
details: !0,
|
|
713
706
|
campaignId: n.variationId
|
|
714
707
|
};
|
|
715
|
-
r.strategy === "manualMerchandising" ? c.productId =
|
|
708
|
+
r.strategy === "manualMerchandising" ? c.productId = q(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), a && (c.filter = a), r.shuffleProducts && (c.shuffle = !0), Object.assign(
|
|
716
709
|
c,
|
|
717
|
-
|
|
710
|
+
$(n.partnerName, r.strategy)
|
|
718
711
|
);
|
|
719
712
|
let u;
|
|
720
713
|
try {
|