@useinsider/guido 3.19.0 → 3.20.0-beta.0849ec7
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 +22 -3
- package/dist/@types/config/schemas.js +76 -53
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +102 -86
- package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/organisms/base/Toaster.vue2.js +13 -12
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +78 -57
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +28 -42
- package/dist/components/organisms/header/EditorActions.vue.js +5 -5
- package/dist/components/organisms/header/EditorActions.vue2.js +90 -57
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +47 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +49 -0
- package/dist/components/wrappers/WpDrawer.vue.js +9 -7
- 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/useActionsApi.js +52 -47
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useCustomInterfaceAppearance.js +65 -51
- package/dist/composables/useEmailTemplateApplier.js +111 -50
- package/dist/composables/useHtmlCompiler.js +37 -26
- package/dist/composables/useHtmlValidator.js +89 -82
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +65 -0
- package/dist/composables/useRecommendation.js +40 -35
- package/dist/composables/useSave.js +90 -45
- package/dist/composables/useSaveValidation.js +282 -0
- package/dist/composables/useSaveValidationRollout.js +9 -0
- package/dist/composables/useStripo.js +43 -39
- package/dist/composables/useToaster.js +18 -22
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/composables/validators/useCouponBlockValidator.js +24 -21
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/itemsBlockMigrator.js +236 -248
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
- package/dist/enums/extensions/recommendationBlock.js +51 -34
- package/dist/enums/save-validation.js +4 -0
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/extensions/Blocks/Recommendation/block.js +65 -45
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +21 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -90
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +150 -52
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -74
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +274 -92
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -16
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +5 -3
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +24 -0
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +46 -37
- package/dist/src/@types/config/schemas.d.ts +36 -0
- package/dist/src/@types/save-validation.d.ts +19 -0
- package/dist/src/components/Guido.vue.d.ts +17 -1
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
- 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 +8 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/composables/useHtmlValidator.d.ts +21 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/composables/useSave.d.ts +6 -1
- package/dist/src/composables/useSaveValidation.d.ts +6 -0
- package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -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 +7 -1
- package/dist/src/enums/save-validation.d.ts +27 -0
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +7 -2
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +162 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +14 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/stores/config.d.ts +374 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/src/stores/onboarding.d.ts +812 -10
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/stores/save-validation.d.ts +22 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/src/utils/stripoEditorApi.d.ts +4 -0
- package/dist/src/utils/templatePreparation.d.ts +30 -0
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +113 -9
- package/dist/static/styles/components/skeleton.css.js +23 -0
- package/dist/static/styles/components/version-history.css.js +2 -6
- package/dist/stores/config.js +55 -24
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/onboarding.js +50 -36
- package/dist/stores/save-validation.js +30 -0
- package/dist/stores/unsubscribe.js +3 -3
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/stripoEditorApi.js +11 -0
- package/dist/utils/templatePreparation.js +54 -51
- package/package.json +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useConfig as V } from "./useConfig.js";
|
|
2
2
|
import { getIgnoredRecommendationBlockIds as M } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
3
3
|
import { TemplateTypes as W } from "../enums/defaults.js";
|
|
4
|
-
import { DISPLAY_CONDITIONS_REGEX as G, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as
|
|
4
|
+
import { DISPLAY_CONDITIONS_REGEX as G, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as K, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as X, DYNAMIC_CONTENT_TAG_REGEX as Y, ALLOWED_DYNAMIC_SYSTEM_TOKENS as $, VALID_DYNAMIC_VARIABLE_REGEX as U } from "../enums/html-validator.js";
|
|
5
5
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
6
6
|
import { BLOCK_ROOT_SELECTOR as j } from "../extensions/Blocks/Checkbox/constants/selectors.js";
|
|
7
7
|
import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
@@ -9,58 +9,58 @@ import { BLOCK_ROOT_SELECTOR as z } from "../extensions/Blocks/RadioButton/const
|
|
|
9
9
|
import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as Z } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
10
10
|
import { useRecommendationExtensionStore as J } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
11
|
import { filterToProductAttrValue as Q } from "../extensions/Blocks/Recommendation/utils/compositionKeys.js";
|
|
12
|
-
import {
|
|
13
|
-
import { useRecommendationStore as
|
|
14
|
-
import { base64EncodeWithSpecialChars as
|
|
15
|
-
import { computed as
|
|
16
|
-
import { useHttp as
|
|
17
|
-
import { useToaster as
|
|
18
|
-
import { useTranslations as
|
|
19
|
-
const
|
|
20
|
-
function
|
|
21
|
-
return [...s.matchAll(
|
|
12
|
+
import { STRATEGY_FIELD_KEY as ee, RecommendationAssignStrategyKey as te, RecommendationRequiredFieldsKey as ne } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
13
|
+
import { useRecommendationStore as se } from "../stores/recommendation.js";
|
|
14
|
+
import { base64EncodeWithSpecialChars as re } from "../utils/base64.js";
|
|
15
|
+
import { computed as oe } from "vue";
|
|
16
|
+
import { useHttp as ie } from "./useHttp.js";
|
|
17
|
+
import { useToaster as ae } from "./useToaster.js";
|
|
18
|
+
import { useTranslations as ce } from "./useTranslations.js";
|
|
19
|
+
const le = /recommendation-id="(\d+)"/g;
|
|
20
|
+
function me(s) {
|
|
21
|
+
return [...s.matchAll(le)].map((m) => m[1]);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
23
|
+
function ue(s, m) {
|
|
24
|
+
return m.some((f) => s.startsWith(`${f}_`));
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
return
|
|
26
|
+
const de = /^(\d+)_\d+_(.+)$/;
|
|
27
|
+
function fe(s) {
|
|
28
|
+
const m = s.match(de);
|
|
29
|
+
return m ? { recoId: m[1], attribute: m[2] } : null;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
31
|
+
function ge(s) {
|
|
32
|
+
const m = new Set(Z);
|
|
33
33
|
return Object.values(s).forEach((f) => {
|
|
34
|
-
|
|
35
|
-
}),
|
|
34
|
+
m.add(Q(f).toLowerCase());
|
|
35
|
+
}), m;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function pe(s, m, f, o, d) {
|
|
38
38
|
const u = s.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
|
|
39
39
|
if (!u)
|
|
40
40
|
return [];
|
|
41
|
-
const
|
|
42
|
-
return u.forEach((
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
41
|
+
const p = new Set(m.map((y) => y.toLowerCase())), E = [];
|
|
42
|
+
return u.forEach((y) => {
|
|
43
|
+
const g = y.slice(2, -2).trim().toLowerCase();
|
|
44
|
+
if (g !== "" && p.has(g))
|
|
45
45
|
return;
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
if (!d || d.has(
|
|
46
|
+
const C = fe(g);
|
|
47
|
+
if (C && o.has(C.recoId)) {
|
|
48
|
+
if (!d || d.has(C.attribute))
|
|
49
49
|
return;
|
|
50
|
-
E.push(
|
|
50
|
+
E.push(g);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
ue(g, f) || g.includes(".") || E.push(g);
|
|
54
54
|
}), E;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return (s.replace(
|
|
58
|
-
const d = o.slice(2, -2), u = d.indexOf("|"),
|
|
59
|
-
return
|
|
56
|
+
function Ee(s) {
|
|
57
|
+
return (s.replace(X, "$1").match(Y) ?? []).filter((o) => {
|
|
58
|
+
const d = o.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
|
|
59
|
+
return $.includes(p) ? !1 : U.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
const { showToaster: s } =
|
|
62
|
+
const ke = () => {
|
|
63
|
+
const { showToaster: s } = ae(), { post: m } = ie(), { config: f } = V(), o = ce(), d = se(), u = J(), p = oe(
|
|
64
64
|
() => {
|
|
65
65
|
var e, t;
|
|
66
66
|
return ((t = (e = f.value) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) === W.transactional;
|
|
@@ -73,39 +73,39 @@ const De = () => {
|
|
|
73
73
|
} catch {
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
|
-
return
|
|
77
|
-
},
|
|
78
|
-
const n = await
|
|
76
|
+
return ge(u.filterList);
|
|
77
|
+
}, y = async (e) => {
|
|
78
|
+
const n = await m(
|
|
79
79
|
"/newsletter/template-library/check-template-html-body",
|
|
80
|
-
{ html:
|
|
80
|
+
{ html: re(e) }
|
|
81
81
|
), { status: r, message: a } = n.data;
|
|
82
82
|
return r || s({
|
|
83
83
|
type: c.Error,
|
|
84
84
|
message: r === void 0 ? a : o("newsletter.invalid-url-link-for-toaster")
|
|
85
|
-
}), o(
|
|
85
|
+
}), o(K), a === o(P) && s({
|
|
86
86
|
type: c.Error,
|
|
87
87
|
message: o("newsletter.already-in-progress")
|
|
88
88
|
}), r;
|
|
89
|
-
},
|
|
89
|
+
}, g = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), C = (e) => ["if", "endif"].includes(e.toLowerCase()), I = (e, t) => {
|
|
90
90
|
const n = e.match(/({%(.*?)%})/g);
|
|
91
91
|
let r = !0;
|
|
92
|
-
return n !== null && !
|
|
92
|
+
return n !== null && !p.value && n.forEach((a) => {
|
|
93
93
|
const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
94
94
|
if (i && i.length > 0) {
|
|
95
|
-
const [
|
|
96
|
-
|
|
95
|
+
const [l] = i;
|
|
96
|
+
g(l) && !t.includes(l) && (s({
|
|
97
97
|
type: c.Warning,
|
|
98
98
|
message: o("custom-fields.invalid-custom-fields")
|
|
99
99
|
}), r = !1);
|
|
100
100
|
}
|
|
101
101
|
}), r;
|
|
102
102
|
}, R = async (e, t, n) => {
|
|
103
|
-
const r = n ? await
|
|
104
|
-
return
|
|
105
|
-
},
|
|
103
|
+
const r = n ? await y(e) : !0;
|
|
104
|
+
return I(e, t) && r;
|
|
105
|
+
}, A = (e) => e.length > 0 ? !0 : (s({
|
|
106
106
|
type: c.Warning,
|
|
107
107
|
message: o("newsletter.html-content-is-empty")
|
|
108
|
-
}), !1),
|
|
108
|
+
}), !1), _ = (e) => {
|
|
109
109
|
const t = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
|
|
110
110
|
return t > n && s({
|
|
111
111
|
type: c.Warning,
|
|
@@ -114,26 +114,26 @@ const De = () => {
|
|
|
114
114
|
type: c.Warning,
|
|
115
115
|
message: o("custom-fields.missing-opening-braces")
|
|
116
116
|
}), t === n;
|
|
117
|
-
},
|
|
118
|
-
const t =
|
|
117
|
+
}, b = (e) => {
|
|
118
|
+
const t = Ee(e).length === 0;
|
|
119
119
|
return t || s({
|
|
120
120
|
type: c.Warning,
|
|
121
121
|
message: o("custom-fields.invalid-custom-fields")
|
|
122
122
|
}), t;
|
|
123
123
|
}, O = (e, t, n, r) => {
|
|
124
|
-
if (
|
|
124
|
+
if (p.value)
|
|
125
125
|
return !0;
|
|
126
|
-
const a =
|
|
126
|
+
const a = pe(
|
|
127
127
|
e,
|
|
128
128
|
t,
|
|
129
|
-
|
|
129
|
+
me(e),
|
|
130
130
|
n,
|
|
131
131
|
r
|
|
132
132
|
);
|
|
133
133
|
if (a.length > 0) {
|
|
134
134
|
const i = `
|
|
135
135
|
<ul>
|
|
136
|
-
${a.map((
|
|
136
|
+
${a.map((l) => `<li>${l}</li>`).join("")}
|
|
137
137
|
</ul>
|
|
138
138
|
`;
|
|
139
139
|
return s({
|
|
@@ -146,22 +146,22 @@ const De = () => {
|
|
|
146
146
|
const t = e.match(/{%(.*?)%}/g), n = [];
|
|
147
147
|
let r = !0;
|
|
148
148
|
if (t && t.forEach((a) => {
|
|
149
|
-
const i = a.match(G),
|
|
150
|
-
(!i || a !== v) && !
|
|
149
|
+
const i = a.match(G), l = a.match(H), v = (i == null ? void 0 : i.join("")) || "";
|
|
150
|
+
(!i || a !== v) && !l && (s({
|
|
151
151
|
type: c.Error,
|
|
152
152
|
message: o("newsletter.display-conditions-invalid-syntax")
|
|
153
|
-
}), r = !1), i && i.forEach((
|
|
154
|
-
|
|
153
|
+
}), r = !1), i && i.forEach((h) => {
|
|
154
|
+
h.trim() === "=" && (s({
|
|
155
155
|
type: c.Error,
|
|
156
156
|
message: o("custom-conditions.wrong-equality-operators")
|
|
157
157
|
}), r = !1);
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
const S = h.match(/^[a-zA-Z]*$/g);
|
|
159
|
+
S && S.forEach((T) => {
|
|
160
|
+
C(T) && n.push(T);
|
|
161
161
|
});
|
|
162
162
|
});
|
|
163
163
|
}), n.length) {
|
|
164
|
-
const a = n.filter((
|
|
164
|
+
const a = n.filter((l) => l === "if"), i = n.filter((l) => l === "endif");
|
|
165
165
|
a.length !== i.length && (s({
|
|
166
166
|
type: c.Error,
|
|
167
167
|
message: o("custom-conditions.missing-if-endif-tag")
|
|
@@ -177,23 +177,28 @@ const De = () => {
|
|
|
177
177
|
}, N = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, r) => n + r, 0) > 0 ? (s({
|
|
178
178
|
type: c.Warning,
|
|
179
179
|
message: o("custom-conditions.no-braces-inside-if-tag")
|
|
180
|
-
}), !1) : !0, B = () =>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
}), !1) : !0, B = () => {
|
|
181
|
+
if (!u.hasInvalidBlock())
|
|
182
|
+
return !0;
|
|
183
|
+
const e = u.invalidBlockFields(), t = e.length > 0 && e.every((n) => n === ee);
|
|
184
|
+
return s({
|
|
185
|
+
type: t ? c.Warning : c.Error,
|
|
186
|
+
message: o(t ? te : ne)
|
|
187
|
+
}), !1;
|
|
188
|
+
}, F = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
|
|
184
189
|
type: c.Error,
|
|
185
190
|
message: o("newsletter.fill-all-necessary-fields")
|
|
186
|
-
}), !1) : !0,
|
|
191
|
+
}), !1) : !0, x = (e) => {
|
|
187
192
|
const t = /src="[^"]*\.(svg|pst)"/gm;
|
|
188
193
|
return e.match(t) === null ? !0 : (s({
|
|
189
194
|
type: c.Error,
|
|
190
195
|
message: o("newsletter.invalid-image-type")
|
|
191
196
|
}), !1);
|
|
192
|
-
},
|
|
197
|
+
}, D = (e) => {
|
|
193
198
|
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(j);
|
|
194
199
|
return Array.from(r).find((i) => {
|
|
195
|
-
var
|
|
196
|
-
return !((
|
|
200
|
+
var l;
|
|
201
|
+
return !((l = i.id) != null && l.trim());
|
|
197
202
|
}) ? (s({
|
|
198
203
|
type: c.Error,
|
|
199
204
|
message: o("unsubscribe-templates.select-checkbox-groups")
|
|
@@ -201,26 +206,28 @@ const De = () => {
|
|
|
201
206
|
}, k = (e) => {
|
|
202
207
|
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(z);
|
|
203
208
|
return Array.from(r).find((i) => {
|
|
204
|
-
var
|
|
205
|
-
return !((
|
|
209
|
+
var l;
|
|
210
|
+
return !((l = i.id) != null && l.trim());
|
|
206
211
|
}) ? (s({
|
|
207
212
|
type: c.Error,
|
|
208
213
|
message: o("unsubscribe-templates.select-radio-button-groups")
|
|
209
214
|
}), !1) : !0;
|
|
210
215
|
};
|
|
211
216
|
return { validateHtml: async (e, t, n = !1) => {
|
|
212
|
-
var v,
|
|
217
|
+
var v, h;
|
|
213
218
|
const r = [
|
|
214
|
-
...t.map((
|
|
219
|
+
...t.map((S) => S.value),
|
|
215
220
|
...q,
|
|
216
|
-
...((
|
|
221
|
+
...((h = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : h.customFieldAttributes) ?? []
|
|
217
222
|
], a = M(e), i = await E(a);
|
|
218
|
-
return await R(e, r, n) &&
|
|
223
|
+
return await R(e, r, n) && A(e) && _(e) && b(e) && O(e, r, a, i) && w(e) && L(e) && N(e) && B() && F() && x(e) && D(e) && k(e);
|
|
219
224
|
} };
|
|
220
225
|
};
|
|
221
226
|
export {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
227
|
+
ge as buildPartnerAttributeNameSet,
|
|
228
|
+
pe as findInvalidCustomFields,
|
|
229
|
+
Ee as getInvalidDynamicContentTags,
|
|
230
|
+
me as getRecommendationBlockIds,
|
|
231
|
+
fe as parseRecommendationVariable,
|
|
232
|
+
ke as useHtmlValidator
|
|
226
233
|
};
|
|
@@ -1,88 +1,98 @@
|
|
|
1
|
-
import { getCsrfToken as
|
|
2
|
-
import { ref as
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getCsrfToken as D } from "../utils/genericUtil.js";
|
|
2
|
+
import { ref as T, computed as w } from "vue";
|
|
3
|
+
import { isPanelOrigin as j, reportAuthError as X } from "./useAuthError.js";
|
|
4
|
+
const k = [401, 403, 419], _ = (g = {}) => {
|
|
5
|
+
const f = T(!1), n = T(null), c = T(null), b = w(() => f.value), y = w(() => n.value !== null), E = {
|
|
5
6
|
baseURL: "",
|
|
6
7
|
timeout: 1e4,
|
|
7
8
|
retry: 0,
|
|
8
9
|
retryDelay: 1e3,
|
|
9
10
|
headers: {
|
|
10
11
|
"Content-Type": "application/json",
|
|
11
|
-
"X-CSRF-TOKEN":
|
|
12
|
+
"X-CSRF-TOKEN": D(),
|
|
12
13
|
Accept: "application/json",
|
|
14
|
+
// Without this a guest fetch gets a 302 to the login page, never an auth status.
|
|
13
15
|
"X-Requested-With": "XMLHttpRequest"
|
|
14
16
|
},
|
|
15
|
-
...
|
|
16
|
-
},
|
|
17
|
+
...g
|
|
18
|
+
}, x = (e, r) => {
|
|
17
19
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
18
20
|
return e;
|
|
19
|
-
const t =
|
|
21
|
+
const t = r || E.baseURL || "";
|
|
20
22
|
return t.endsWith("/") && e.startsWith("/") ? `${t}${e.slice(1)}` : t.endsWith("/") || e.startsWith("/") ? `${t}${e}` : `${t}/${e}`;
|
|
21
|
-
},
|
|
23
|
+
}, R = (e) => new Promise((r, t) => {
|
|
22
24
|
setTimeout(() => {
|
|
23
25
|
t(new Error("Request timeout"));
|
|
24
26
|
}, e);
|
|
25
|
-
}),
|
|
26
|
-
setTimeout(
|
|
27
|
-
}), i = async (e,
|
|
28
|
-
|
|
29
|
-
const
|
|
27
|
+
}), P = (e) => new Promise((r) => {
|
|
28
|
+
setTimeout(r, e);
|
|
29
|
+
}), i = async (e, r, t, W = {}) => {
|
|
30
|
+
n.value = null, f.value = !0, c.value = new AbortController();
|
|
31
|
+
const a = { ...E, ...W }, p = x(r, a.baseURL), d = {
|
|
30
32
|
method: e,
|
|
31
|
-
headers: { ...
|
|
32
|
-
signal:
|
|
33
|
-
...
|
|
33
|
+
headers: { ...a.headers },
|
|
34
|
+
signal: c.value.signal,
|
|
35
|
+
...a
|
|
34
36
|
};
|
|
35
|
-
t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete
|
|
36
|
-
const
|
|
37
|
+
t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete d.headers["Content-Type"], d.body = t) : d.body = JSON.stringify(t));
|
|
38
|
+
const v = async (m = 0) => {
|
|
39
|
+
if (window.isSessionExpired) {
|
|
40
|
+
n.value = { message: "Session expired", authReported: !0 };
|
|
41
|
+
const o = new Error("Session expired");
|
|
42
|
+
throw o.authReported = !0, o;
|
|
43
|
+
}
|
|
37
44
|
try {
|
|
38
|
-
const o = [fetch(
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
const H = `HTTP Error: ${
|
|
43
|
-
throw
|
|
45
|
+
const o = [fetch(p, d)];
|
|
46
|
+
a.timeout && o.push(R(a.timeout));
|
|
47
|
+
const s = await Promise.race(o);
|
|
48
|
+
if (!s.ok) {
|
|
49
|
+
const H = `HTTP Error: ${s.status} ${s.statusText}`, l = new Error(H);
|
|
50
|
+
throw l.status = s.status, l.statusText = s.statusText, l.response = s, l.authReported = k.includes(s.status) && j(p), l.authReported && Promise.resolve().then(() => s.clone().text().catch(() => "")).then((O) => X(
|
|
51
|
+
s.status,
|
|
52
|
+
O,
|
|
53
|
+
new URL(p, window.location.href).href
|
|
54
|
+
)).catch(() => {
|
|
55
|
+
}), l;
|
|
44
56
|
}
|
|
45
|
-
let
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
data:
|
|
49
|
-
status:
|
|
50
|
-
statusText:
|
|
51
|
-
headers:
|
|
57
|
+
let h;
|
|
58
|
+
const u = s.headers.get("content-type");
|
|
59
|
+
return u != null && u.includes("application/json") ? h = await s.json() : u != null && u.includes("text/") ? h = await s.text() : h = await s.blob(), {
|
|
60
|
+
data: h,
|
|
61
|
+
status: s.status,
|
|
62
|
+
statusText: s.statusText,
|
|
63
|
+
headers: s.headers
|
|
52
64
|
};
|
|
53
65
|
} catch (o) {
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
return await
|
|
57
|
-
throw o instanceof Error ? o.name === "AbortError" ?
|
|
66
|
+
const s = o instanceof Error && o.name === "AbortError";
|
|
67
|
+
if (m < (a.retry || 0) && !s)
|
|
68
|
+
return await P(a.retryDelay || 1e3), v(m + 1);
|
|
69
|
+
throw o instanceof Error ? o.name === "AbortError" ? n.value = { message: "Request was cancelled" } : n.value = { message: o.message } : n.value = o, o;
|
|
58
70
|
}
|
|
59
71
|
};
|
|
60
72
|
try {
|
|
61
|
-
return await
|
|
73
|
+
return await v();
|
|
62
74
|
} finally {
|
|
63
|
-
|
|
75
|
+
f.value = !1, c.value = null;
|
|
64
76
|
}
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
|
|
77
|
+
}, A = (e, r) => i("GET", e, void 0, r), S = (e, r, t) => i("POST", e, r, t), U = (e, r, t) => i("PUT", e, r, t), C = (e, r, t) => i("PATCH", e, r, t), $ = (e, r) => i("DELETE", e, void 0, r), q = (e) => {
|
|
78
|
+
c.value && c.value.abort(e);
|
|
79
|
+
}, L = () => {
|
|
80
|
+
n.value = null;
|
|
69
81
|
};
|
|
70
82
|
return {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
error: T(() => a.value),
|
|
83
|
+
loading: b,
|
|
84
|
+
error: w(() => n.value),
|
|
74
85
|
hasError: y,
|
|
75
|
-
// Methods
|
|
76
86
|
request: i,
|
|
77
|
-
get:
|
|
78
|
-
post:
|
|
79
|
-
put:
|
|
80
|
-
patch:
|
|
81
|
-
delete:
|
|
82
|
-
cancel:
|
|
83
|
-
clearError:
|
|
87
|
+
get: A,
|
|
88
|
+
post: S,
|
|
89
|
+
put: U,
|
|
90
|
+
patch: C,
|
|
91
|
+
delete: $,
|
|
92
|
+
cancel: q,
|
|
93
|
+
clearError: L
|
|
84
94
|
};
|
|
85
95
|
};
|
|
86
96
|
export {
|
|
87
|
-
|
|
97
|
+
_ as useHttp
|
|
88
98
|
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useRecommendation as C } from "./useRecommendation.js";
|
|
2
|
+
import { useToaster as I } from "./useToaster.js";
|
|
3
|
+
import { useTranslations as v } from "./useTranslations.js";
|
|
4
|
+
import { ToasterTypeOptions as g } from "../enums/toaster.js";
|
|
5
|
+
import "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
6
|
+
import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
7
|
+
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
8
|
+
import { resolveMigrationTarget as k, buildLegacyMigrationPayload as R } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
|
|
9
|
+
import { commitBlockChangeOutsidePanel as T } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
|
|
10
|
+
import { useConfigStore as h } from "../stores/config.js";
|
|
11
|
+
const F = () => {
|
|
12
|
+
const e = b(), r = h(), { buildCampaignUrl: m } = C(), { showToaster: c } = I(), a = v();
|
|
13
|
+
return { convertLegacyStrategy: async () => {
|
|
14
|
+
const t = e.currentRecommendationId;
|
|
15
|
+
if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
|
|
16
|
+
return "";
|
|
17
|
+
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = k({
|
|
18
|
+
campaignId: r.campaignId,
|
|
19
|
+
templateLibraryId: r.templateLibraryId
|
|
20
|
+
}), S = R({
|
|
21
|
+
blockId: t,
|
|
22
|
+
url: m(String(t)),
|
|
23
|
+
campaignId: r.campaignId,
|
|
24
|
+
variationId: r.variationId,
|
|
25
|
+
strategy: d,
|
|
26
|
+
productIds: y,
|
|
27
|
+
target: s
|
|
28
|
+
});
|
|
29
|
+
let o;
|
|
30
|
+
try {
|
|
31
|
+
o = await e.convertLegacyStrategy(S, s);
|
|
32
|
+
} catch (i) {
|
|
33
|
+
return console.error("[useLegacyStrategyConversion] migration failed", i), c({
|
|
34
|
+
type: g.Error,
|
|
35
|
+
message: a("email-editor.legacy-strategy-migration-failed"),
|
|
36
|
+
actionButton: {
|
|
37
|
+
text: a("ds-steps.create-recommendation-strategy"),
|
|
38
|
+
onClick: () => e.openStrategyCreation()
|
|
39
|
+
}
|
|
40
|
+
}), "";
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
await e.fetchStrategyProductsForBlock(t);
|
|
44
|
+
} catch (i) {
|
|
45
|
+
console.error("[useLegacyStrategyConversion] product refetch failed", i);
|
|
46
|
+
}
|
|
47
|
+
const n = e.blockStates[t];
|
|
48
|
+
return n ? T(
|
|
49
|
+
t,
|
|
50
|
+
{
|
|
51
|
+
strategyId: o,
|
|
52
|
+
size: n.recommendationConfigs.size,
|
|
53
|
+
configVersion: L
|
|
54
|
+
},
|
|
55
|
+
n.recommendationProducts,
|
|
56
|
+
"Converted legacy recommendation strategy"
|
|
57
|
+
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), c({
|
|
58
|
+
type: g.Error,
|
|
59
|
+
message: a("email-editor.legacy-strategy-update-failed")
|
|
60
|
+
}), "") : o;
|
|
61
|
+
} };
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
F as useLegacyStrategyConversion
|
|
65
|
+
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { getRecommendationFeedSourceMaps as y, URLS as I } from "../enums/extensions/recommendationBlock.js";
|
|
2
2
|
import { MinDeviceViewport as C, DefaultPadding as R } from "../enums/recommendation.js";
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
3
|
+
import { useRecommendationExtensionStore as g } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
4
|
import { generateCompleteFilterQuery as b } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
5
|
import { getPartnerRecommendationParams as h } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
6
6
|
import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
|
|
7
7
|
import { useConfigStore as P } from "../stores/config.js";
|
|
8
8
|
const B = () => ({
|
|
9
9
|
calculateCardWidth: ({
|
|
10
|
-
mobileLeftPadding:
|
|
10
|
+
mobileLeftPadding: s,
|
|
11
11
|
mobileRightPadding: c,
|
|
12
|
-
cardsInRow:
|
|
13
|
-
unresponsive:
|
|
12
|
+
cardsInRow: o,
|
|
13
|
+
unresponsive: a
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
return (C - e) /
|
|
15
|
+
const i = a ? o : 1, e = s + c + (i - 1) * R;
|
|
16
|
+
return (C - e) / i;
|
|
17
17
|
},
|
|
18
|
-
getRecommendationCampaignData: (
|
|
19
|
-
const c =
|
|
20
|
-
if (!
|
|
18
|
+
getRecommendationCampaignData: (s) => {
|
|
19
|
+
const c = g(), o = Number(s), a = c.blockStates[o];
|
|
20
|
+
if (!a)
|
|
21
21
|
return {
|
|
22
22
|
textTrimming: !1,
|
|
23
23
|
orientation: "vertical",
|
|
@@ -30,54 +30,59 @@ const B = () => ({
|
|
|
30
30
|
discountBeforeTextValue: "",
|
|
31
31
|
discountAfterTextValue: ""
|
|
32
32
|
};
|
|
33
|
-
const { recommendationConfigs:
|
|
33
|
+
const { recommendationConfigs: i } = a, e = i.orientation === "grid" ? "vertical" : "horizontal";
|
|
34
34
|
return {
|
|
35
|
-
textTrimming:
|
|
35
|
+
textTrimming: i.textTrimming,
|
|
36
36
|
orientation: e,
|
|
37
37
|
mobileLeftPadding: 0,
|
|
38
38
|
mobileRightPadding: 0,
|
|
39
|
-
cardsInRow:
|
|
40
|
-
unresponsive:
|
|
39
|
+
cardsInRow: i.cardsInRow,
|
|
40
|
+
unresponsive: i.unresponsive,
|
|
41
41
|
priceBeforeTextValue: "",
|
|
42
42
|
priceAfterTextValue: "",
|
|
43
43
|
discountBeforeTextValue: "",
|
|
44
44
|
discountAfterTextValue: ""
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
|
-
buildCampaignUrl: (
|
|
48
|
-
var
|
|
49
|
-
const
|
|
47
|
+
buildCampaignUrl: (s, c) => {
|
|
48
|
+
var l;
|
|
49
|
+
const o = g(), a = P(), i = Number(s);
|
|
50
50
|
let e;
|
|
51
51
|
if (c)
|
|
52
52
|
e = c;
|
|
53
53
|
else {
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
54
|
+
const r = o.blockStates[i];
|
|
55
|
+
if (!r)
|
|
56
56
|
return "";
|
|
57
|
-
const { recommendationConfigs:
|
|
57
|
+
const { recommendationConfigs: n } = r;
|
|
58
58
|
e = {
|
|
59
|
-
strategy:
|
|
60
|
-
strategyId:
|
|
61
|
-
language:
|
|
62
|
-
currencyCode:
|
|
63
|
-
size:
|
|
64
|
-
productIds:
|
|
65
|
-
filters:
|
|
66
|
-
shuffleProducts:
|
|
59
|
+
strategy: n.strategy,
|
|
60
|
+
strategyId: n.strategyId,
|
|
61
|
+
language: n.language,
|
|
62
|
+
currencyCode: n.currencySettings.value,
|
|
63
|
+
size: n.size,
|
|
64
|
+
productIds: n.productIds,
|
|
65
|
+
filters: n.filters,
|
|
66
|
+
shuffleProducts: n.shuffleProducts
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
if (e.strategyId &&
|
|
70
|
-
return
|
|
69
|
+
if (e.strategyId && a.isFeatureEnabled("reusableRecommendationStrategy"))
|
|
70
|
+
return o.recommendationCampaignUrls[s] = {
|
|
71
71
|
strategyId: e.strategyId,
|
|
72
72
|
locale: e.language,
|
|
73
73
|
currency: e.currencyCode
|
|
74
74
|
}, "";
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
const d = ((l = y().find((r) => r.key === e.strategy)) == null ? void 0 : l.path) || "";
|
|
76
|
+
if (!d) {
|
|
77
|
+
const r = { ...o.recommendationCampaignUrls };
|
|
78
|
+
return delete r[s], o.recommendationCampaignUrls = r, "";
|
|
79
|
+
}
|
|
80
|
+
const t = new URLSearchParams();
|
|
81
|
+
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", a.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", a.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
82
|
+
const f = e.filters.filter((r) => r.isValid), m = b(f);
|
|
83
|
+
m && t.set("filter", m), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(h(a.partnerName, e.strategy)).forEach(([r, n]) => t.set(r, n));
|
|
84
|
+
const p = decodeURIComponent(t.toString()), u = `${I.RECOMMENDATION_API_URL}/v2/${d}?${p}`;
|
|
85
|
+
return o.recommendationCampaignUrls[s] = u, u;
|
|
81
86
|
}
|
|
82
87
|
});
|
|
83
88
|
export {
|