@useinsider/guido 3.30.0 → 3.30.1-beta.34bc10d
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 +4 -4
- package/dist/@types/email-be/html-validation.js +1 -1
- package/dist/@types/email-be/templates.js +15 -0
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +11 -16
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +11 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +51 -51
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue.js +2 -2
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
- package/dist/composables/useExport.js +8 -7
- package/dist/composables/useHtmlValidator.js +102 -100
- package/dist/composables/useToaster.js +11 -10
- package/dist/composables/useVersionHistoryApi.js +22 -21
- package/dist/composables/validators/useLiquidValidator.js +26 -24
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/enums/defaults.js +4 -5
- package/dist/enums/email-be.js +20 -9
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +148 -141
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +53 -53
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +40 -39
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -26
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +33 -32
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +23 -22
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +79 -78
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +50 -41
- package/dist/guido.css +1 -1
- package/dist/node_modules/valibot/dist/index.js +95 -90
- package/dist/package.json.js +2 -2
- package/dist/services/emailBe/errors/ApiError.js +27 -26
- package/dist/services/emailBe/templates/TemplateService.js +149 -0
- package/dist/services/emailBe/templates/index.js +6 -0
- package/dist/services/templateLibraryApi.js +59 -87
- package/dist/src/@types/email-be/templates.d.ts +40 -0
- package/dist/src/@types/save-as-template.d.ts +1 -23
- package/dist/src/enums/email-be.d.ts +11 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +2 -0
- package/dist/src/services/emailBe/templates/TemplateService.d.ts +13 -0
- package/dist/src/services/emailBe/templates/index.d.ts +2 -0
- package/dist/src/stores/preview.d.ts +3 -0
- package/dist/src/utils/ampPreviewSanitizer.d.ts +5 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/stores/preview.js +21 -15
- package/dist/utils/ampPreviewSanitizer.js +46 -0
- package/dist/utils/htmlEscape.js +5 -1
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -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 { CONDITION_TAG_REGEX as G, DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as K, CampaignCouldNotBeSavedKey as
|
|
4
|
+
import { CONDITION_TAG_REGEX as G, DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as K, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as X, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as j, 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 q } from "../extensions/Blocks/Checkbox/constants/selectors.js";
|
|
7
7
|
import { itemsBlockDynamicVariables as z } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
@@ -10,57 +10,59 @@ import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as J } from "../extensions/B
|
|
|
10
10
|
import { useRecommendationExtensionStore as Q } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
11
|
import { filterToProductAttrValue as ee } from "../extensions/Blocks/Recommendation/utils/compositionKeys.js";
|
|
12
12
|
import { STRATEGY_FIELD_KEY as te, RecommendationAssignStrategyKey as ne, RecommendationRequiredFieldsKey as se } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
13
|
-
import { useRecommendationStore as
|
|
14
|
-
import { base64EncodeWithSpecialChars as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
import { useRecommendationStore as oe } from "../stores/recommendation.js";
|
|
14
|
+
import { base64EncodeWithSpecialChars as re } from "../utils/base64.js";
|
|
15
|
+
import { isPlainObject as ie, asText as ae } from "../utils/genericUtil.js";
|
|
16
|
+
import { escapeHtmlKeepFormatting as ce } from "../utils/htmlEscape.js";
|
|
17
|
+
import { computed as me } from "vue";
|
|
18
|
+
import { useHttp as le } from "./useHttp.js";
|
|
19
|
+
import { useToaster as ue } from "./useToaster.js";
|
|
20
|
+
import { useTranslations as de } from "./useTranslations.js";
|
|
21
|
+
const fe = /recommendation-id="(\d+)"/g;
|
|
22
|
+
function ge(s) {
|
|
23
|
+
return [...s.matchAll(fe)].map((l) => l[1]);
|
|
22
24
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
25
|
+
function pe(s, l) {
|
|
26
|
+
return l.some((f) => s.startsWith(`${f}_`));
|
|
25
27
|
}
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
return
|
|
28
|
+
const Ee = /^(\d+)_\d+_(.+)$/;
|
|
29
|
+
function Ce(s) {
|
|
30
|
+
const l = s.match(Ee);
|
|
31
|
+
return l ? { recoId: l[1], attribute: l[2] } : null;
|
|
30
32
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
+
function ye(s) {
|
|
34
|
+
const l = new Set(J);
|
|
33
35
|
return Object.values(s).forEach((f) => {
|
|
34
|
-
|
|
35
|
-
}),
|
|
36
|
+
l.add(ee(f).toLowerCase());
|
|
37
|
+
}), l;
|
|
36
38
|
}
|
|
37
|
-
function
|
|
39
|
+
function he(s, l, f, r, d) {
|
|
38
40
|
const u = s.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
|
|
39
41
|
if (!u)
|
|
40
42
|
return [];
|
|
41
|
-
const p = new Set(
|
|
43
|
+
const p = new Set(l.map((C) => C.toLowerCase())), E = [];
|
|
42
44
|
return u.forEach((C) => {
|
|
43
45
|
const g = C.slice(2, -2).trim().toLowerCase();
|
|
44
46
|
if (g !== "" && p.has(g))
|
|
45
47
|
return;
|
|
46
|
-
const y =
|
|
47
|
-
if (y &&
|
|
48
|
+
const y = Ce(g);
|
|
49
|
+
if (y && r.has(y.recoId)) {
|
|
48
50
|
if (!d || d.has(y.attribute))
|
|
49
51
|
return;
|
|
50
52
|
E.push(g);
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
|
-
|
|
55
|
+
pe(g, f) || g.includes(".") || E.push(g);
|
|
54
56
|
}), E;
|
|
55
57
|
}
|
|
56
|
-
function
|
|
57
|
-
return (s.replace(Y, "$1").match($) ?? []).filter((
|
|
58
|
-
const d =
|
|
59
|
-
return
|
|
58
|
+
function ve(s) {
|
|
59
|
+
return (s.replace(Y, "$1").match($) ?? []).filter((r) => {
|
|
60
|
+
const d = r.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
|
|
61
|
+
return j.includes(p) ? !1 : U.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
|
-
const
|
|
63
|
-
const { showToaster: s } =
|
|
64
|
+
const Ke = () => {
|
|
65
|
+
const { showToaster: s } = ue(), { post: l } = le(), { config: f } = V(), r = de(), d = oe(), u = Q(), p = me(
|
|
64
66
|
() => {
|
|
65
67
|
var e, t;
|
|
66
68
|
return ((t = (e = f.value) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) === W.transactional;
|
|
@@ -73,161 +75,161 @@ const Ve = () => {
|
|
|
73
75
|
} catch {
|
|
74
76
|
return null;
|
|
75
77
|
}
|
|
76
|
-
return
|
|
78
|
+
return ye(u.filterList);
|
|
77
79
|
}, C = async (e) => {
|
|
78
|
-
const n = await
|
|
79
|
-
|
|
80
|
-
{ html:
|
|
81
|
-
), { status:
|
|
82
|
-
return
|
|
80
|
+
const t = "/newsletter/template-library/check-template-html-body", { data: n } = await l(
|
|
81
|
+
t,
|
|
82
|
+
{ html: re(e) }
|
|
83
|
+
), { status: o, message: a } = ie(n) ? n : { status: void 0, message: void 0 }, i = ae(a);
|
|
84
|
+
return o || s({
|
|
83
85
|
type: c.Error,
|
|
84
|
-
message:
|
|
85
|
-
}),
|
|
86
|
+
message: o === void 0 && i !== "" ? ce(i) : r("newsletter.invalid-url-link-for-toaster")
|
|
87
|
+
}), r(P), a === r(X) && s({
|
|
86
88
|
type: c.Error,
|
|
87
|
-
message:
|
|
88
|
-
}),
|
|
89
|
+
message: r("newsletter.already-in-progress")
|
|
90
|
+
}), !!o;
|
|
89
91
|
}, g = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), y = (e) => ["if", "endif"].includes(e.toLowerCase()), S = (e, t) => {
|
|
90
92
|
const n = e.match(/({%(.*?)%})/g);
|
|
91
|
-
let
|
|
93
|
+
let o = !0;
|
|
92
94
|
return n !== null && !p.value && n.forEach((a) => {
|
|
93
95
|
const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
94
96
|
if (i && i.length > 0) {
|
|
95
|
-
const [
|
|
96
|
-
g(
|
|
97
|
+
const [m] = i;
|
|
98
|
+
g(m) && !t.includes(m) && (s({
|
|
97
99
|
type: c.Warning,
|
|
98
|
-
message:
|
|
99
|
-
}),
|
|
100
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
101
|
+
}), o = !1);
|
|
100
102
|
}
|
|
101
|
-
}),
|
|
103
|
+
}), o;
|
|
102
104
|
}, R = async (e, t, n) => {
|
|
103
|
-
const
|
|
104
|
-
return S(e, t) &&
|
|
105
|
+
const o = n ? await C(e) : !0;
|
|
106
|
+
return S(e, t) && o;
|
|
105
107
|
}, _ = (e) => e.length > 0 ? !0 : (s({
|
|
106
108
|
type: c.Warning,
|
|
107
|
-
message:
|
|
109
|
+
message: r("newsletter.html-content-is-empty")
|
|
108
110
|
}), !1), A = (e) => {
|
|
109
111
|
const t = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
|
|
110
112
|
return t > n && s({
|
|
111
113
|
type: c.Warning,
|
|
112
|
-
message:
|
|
114
|
+
message: r("custom-fields.missing-closing-braces")
|
|
113
115
|
}), t < n && s({
|
|
114
116
|
type: c.Warning,
|
|
115
|
-
message:
|
|
117
|
+
message: r("custom-fields.missing-opening-braces")
|
|
116
118
|
}), t === n;
|
|
117
119
|
}, O = (e) => {
|
|
118
|
-
const t =
|
|
120
|
+
const t = ve(e).length === 0;
|
|
119
121
|
return t || s({
|
|
120
122
|
type: c.Warning,
|
|
121
|
-
message:
|
|
123
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
122
124
|
}), t;
|
|
123
|
-
}, b = (e, t, n,
|
|
125
|
+
}, b = (e, t, n, o) => {
|
|
124
126
|
if (p.value)
|
|
125
127
|
return !0;
|
|
126
|
-
const a =
|
|
128
|
+
const a = he(
|
|
127
129
|
e,
|
|
128
130
|
t,
|
|
129
|
-
|
|
131
|
+
ge(e),
|
|
130
132
|
n,
|
|
131
|
-
|
|
133
|
+
o
|
|
132
134
|
);
|
|
133
135
|
if (a.length > 0) {
|
|
134
136
|
const i = `
|
|
135
137
|
<ul>
|
|
136
|
-
${a.map((
|
|
138
|
+
${a.map((m) => `<li>${m}</li>`).join("")}
|
|
137
139
|
</ul>
|
|
138
140
|
`;
|
|
139
141
|
return s({
|
|
140
142
|
type: c.Error,
|
|
141
|
-
message:
|
|
143
|
+
message: r("custom-fields.invalid-custom-fields") + i
|
|
142
144
|
}), !1;
|
|
143
145
|
}
|
|
144
146
|
return !0;
|
|
145
147
|
}, w = (e) => {
|
|
146
148
|
const t = e.match(G), n = [];
|
|
147
|
-
let
|
|
149
|
+
let o = !0;
|
|
148
150
|
if (t && t.forEach((a) => {
|
|
149
|
-
const i = a.match(H),
|
|
150
|
-
(!i || a !== v) && !
|
|
151
|
+
const i = a.match(H), m = a.match(K), v = (i == null ? void 0 : i.join("")) || "";
|
|
152
|
+
(!i || a !== v) && !m && (s({
|
|
151
153
|
type: c.Error,
|
|
152
|
-
message:
|
|
153
|
-
}),
|
|
154
|
+
message: r("newsletter.display-conditions-invalid-syntax")
|
|
155
|
+
}), o = !1), i && i.forEach((h) => {
|
|
154
156
|
h.trim() === "=" && (s({
|
|
155
157
|
type: c.Error,
|
|
156
|
-
message:
|
|
157
|
-
}),
|
|
158
|
+
message: r("custom-conditions.wrong-equality-operators")
|
|
159
|
+
}), o = !1);
|
|
158
160
|
const T = h.match(/^[a-zA-Z]*$/g);
|
|
159
161
|
T && T.forEach((I) => {
|
|
160
162
|
y(I) && n.push(I);
|
|
161
163
|
});
|
|
162
164
|
});
|
|
163
165
|
}), n.length) {
|
|
164
|
-
const a = n.filter((
|
|
166
|
+
const a = n.filter((m) => m === "if"), i = n.filter((m) => m === "endif");
|
|
165
167
|
a.length !== i.length && (s({
|
|
166
168
|
type: c.Error,
|
|
167
|
-
message:
|
|
168
|
-
}),
|
|
169
|
+
message: r("custom-conditions.missing-if-endif-tag")
|
|
170
|
+
}), o = !1);
|
|
169
171
|
}
|
|
170
|
-
return
|
|
172
|
+
return o;
|
|
171
173
|
}, N = (e) => {
|
|
172
|
-
const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length,
|
|
173
|
-
return
|
|
174
|
+
const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, o = t === n;
|
|
175
|
+
return o || s({
|
|
174
176
|
type: c.Warning,
|
|
175
|
-
message:
|
|
176
|
-
}),
|
|
177
|
-
}, L = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n,
|
|
177
|
+
message: r("custom-conditions.no-space-after-braces")
|
|
178
|
+
}), o;
|
|
179
|
+
}, L = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, o) => n + o, 0) > 0 ? (s({
|
|
178
180
|
type: c.Warning,
|
|
179
|
-
message:
|
|
181
|
+
message: r("custom-conditions.no-braces-inside-if-tag")
|
|
180
182
|
}), !1) : !0, B = () => {
|
|
181
183
|
if (!u.hasInvalidBlock())
|
|
182
184
|
return !0;
|
|
183
185
|
const e = u.invalidBlockFields(), t = e.length > 0 && e.every((n) => n === te);
|
|
184
186
|
return s({
|
|
185
187
|
type: t ? c.Warning : c.Error,
|
|
186
|
-
message:
|
|
188
|
+
message: r(t ? ne : se)
|
|
187
189
|
}), !1;
|
|
188
|
-
},
|
|
190
|
+
}, x = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
|
|
189
191
|
type: c.Error,
|
|
190
|
-
message:
|
|
191
|
-
}), !1) : !0,
|
|
192
|
+
message: r("newsletter.fill-all-necessary-fields")
|
|
193
|
+
}), !1) : !0, F = (e) => {
|
|
192
194
|
const t = /src="[^"]*\.(svg|pst)"/gm;
|
|
193
195
|
return e.match(t) === null ? !0 : (s({
|
|
194
196
|
type: c.Error,
|
|
195
|
-
message:
|
|
197
|
+
message: r("newsletter.invalid-image-type")
|
|
196
198
|
}), !1);
|
|
197
199
|
}, D = (e) => {
|
|
198
|
-
const
|
|
199
|
-
return Array.from(
|
|
200
|
-
var
|
|
201
|
-
return !((
|
|
200
|
+
const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(q);
|
|
201
|
+
return Array.from(o).find((i) => {
|
|
202
|
+
var m;
|
|
203
|
+
return !((m = i.id) != null && m.trim());
|
|
202
204
|
}) ? (s({
|
|
203
205
|
type: c.Error,
|
|
204
|
-
message:
|
|
206
|
+
message: r("unsubscribe-templates.select-checkbox-groups")
|
|
205
207
|
}), !1) : !0;
|
|
206
208
|
}, k = (e) => {
|
|
207
|
-
const
|
|
208
|
-
return Array.from(
|
|
209
|
-
var
|
|
210
|
-
return !((
|
|
209
|
+
const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Z);
|
|
210
|
+
return Array.from(o).find((i) => {
|
|
211
|
+
var m;
|
|
212
|
+
return !((m = i.id) != null && m.trim());
|
|
211
213
|
}) ? (s({
|
|
212
214
|
type: c.Error,
|
|
213
|
-
message:
|
|
215
|
+
message: r("unsubscribe-templates.select-radio-button-groups")
|
|
214
216
|
}), !1) : !0;
|
|
215
217
|
};
|
|
216
218
|
return { validateHtml: async (e, t, n = !1) => {
|
|
217
219
|
var v, h;
|
|
218
|
-
const
|
|
220
|
+
const o = [
|
|
219
221
|
...t.map((T) => T.value),
|
|
220
222
|
...z,
|
|
221
223
|
...((h = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : h.customFieldAttributes) ?? []
|
|
222
224
|
], a = M(e), i = await E(a);
|
|
223
|
-
return await R(e,
|
|
225
|
+
return await R(e, o, n) && _(e) && A(e) && O(e) && b(e, o, a, i) && w(e) && N(e) && L(e) && B() && x() && F(e) && D(e) && k(e);
|
|
224
226
|
} };
|
|
225
227
|
};
|
|
226
228
|
export {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
ye as buildPartnerAttributeNameSet,
|
|
230
|
+
he as findInvalidCustomFields,
|
|
231
|
+
ve as getInvalidDynamicContentTags,
|
|
232
|
+
ge as getRecommendationBlockIds,
|
|
233
|
+
Ce as parseRecommendationVariable,
|
|
234
|
+
Ke as useHtmlValidator
|
|
233
235
|
};
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { ToasterTypeOptions as T } from "../enums/toaster.js";
|
|
2
|
-
import { useToasterStore as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { useToasterStore as c } from "../stores/toaster.js";
|
|
3
|
+
import { escapeHtml as u } from "../utils/htmlEscape.js";
|
|
4
|
+
import { nextTick as d } from "vue";
|
|
5
|
+
const s = /* @__PURE__ */ new WeakMap(), l = () => {
|
|
6
|
+
const t = c(), o = () => {
|
|
6
7
|
const e = s.get(t);
|
|
7
8
|
e && (clearTimeout(e), s.delete(t));
|
|
8
9
|
};
|
|
9
10
|
function i(e = { message: "" }) {
|
|
10
|
-
o(), t.hideToaster(),
|
|
11
|
+
o(), t.hideToaster(), d(() => {
|
|
11
12
|
t.showToaster(e), t.shouldAutoHide && s.set(t, setTimeout(() => {
|
|
12
13
|
t.hideToaster(), o();
|
|
13
14
|
}, 6e3));
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function a() {
|
|
17
18
|
o(), t.hideToaster();
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function n(e, r) {
|
|
20
21
|
if (e != null && e.authReported)
|
|
21
22
|
return;
|
|
22
23
|
const m = e instanceof Error ? e.message : String(e);
|
|
23
|
-
i({ type: T.Error, message: `${r}: ${m}` });
|
|
24
|
+
i({ type: T.Error, message: `${r}: ${u(m)}` });
|
|
24
25
|
}
|
|
25
|
-
return { showToaster: i, hideToaster:
|
|
26
|
+
return { showToaster: i, hideToaster: a, handleError: n };
|
|
26
27
|
};
|
|
27
28
|
export {
|
|
28
|
-
|
|
29
|
+
l as useToaster
|
|
29
30
|
};
|
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import { ToasterTypeOptions as t } from "../enums/toaster.js";
|
|
2
|
-
import { useVersionHistoryStore as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { useVersionHistoryStore as w } from "../stores/version-history.js";
|
|
3
|
+
import { escapeHtml as p } from "../utils/htmlEscape.js";
|
|
4
|
+
import { findEditorApi as y, EDITOR_NOT_READY_MESSAGE as V } from "../utils/stripoEditorApi.js";
|
|
5
|
+
import { useToaster as l } from "./useToaster.js";
|
|
6
|
+
const P = () => {
|
|
7
|
+
const n = w(), { showToaster: i } = l(), s = (e) => {
|
|
8
|
+
var o;
|
|
9
|
+
const r = (o = y()) == null ? void 0 : o.versionHistoryApi;
|
|
9
10
|
if (!r) {
|
|
10
|
-
i({ type: t.Error, message:
|
|
11
|
+
i({ type: t.Error, message: V });
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
14
|
e(r);
|
|
14
|
-
},
|
|
15
|
+
}, m = (e) => {
|
|
15
16
|
n.$reset(), n.updateState(e);
|
|
16
17
|
}, a = () => {
|
|
17
18
|
n.$reset();
|
|
18
19
|
};
|
|
19
20
|
return {
|
|
20
21
|
openVersionHistory: () => {
|
|
21
|
-
|
|
22
|
+
s((e) => e.openVersionHistory(m, a));
|
|
22
23
|
},
|
|
23
24
|
closeVersionHistory: () => {
|
|
24
|
-
|
|
25
|
+
s((e) => e.closeVersionHistory());
|
|
25
26
|
},
|
|
26
27
|
switchToDesktopPreview: () => {
|
|
27
|
-
|
|
28
|
+
s((e) => e.switchToDesktopPreview());
|
|
28
29
|
},
|
|
29
30
|
switchToMobilePreview: () => {
|
|
30
|
-
|
|
31
|
+
s((e) => e.switchToMobilePreview());
|
|
31
32
|
},
|
|
32
33
|
previewVersion: (e) => {
|
|
33
|
-
|
|
34
|
-
const c =
|
|
34
|
+
s((r) => r.previewVersion(e, (o) => {
|
|
35
|
+
const c = o instanceof Error ? o.message : String(o);
|
|
35
36
|
i({
|
|
36
37
|
type: t.Error,
|
|
37
|
-
message: `Error compiling email: ${c}`
|
|
38
|
+
message: `Error compiling email: ${p(c)}`
|
|
38
39
|
});
|
|
39
40
|
}));
|
|
40
41
|
},
|
|
41
42
|
restoreVersion: (e) => {
|
|
42
|
-
|
|
43
|
+
s((r) => r.restoreVersion(
|
|
43
44
|
e,
|
|
44
45
|
() => {
|
|
45
46
|
i({
|
|
@@ -47,11 +48,11 @@ const d = () => {
|
|
|
47
48
|
message: "Your version has been restored successfully."
|
|
48
49
|
});
|
|
49
50
|
},
|
|
50
|
-
(
|
|
51
|
-
const c =
|
|
51
|
+
(o) => {
|
|
52
|
+
const c = o instanceof Error ? o.message : String(o);
|
|
52
53
|
i({
|
|
53
54
|
type: t.Error,
|
|
54
|
-
message: `Error compiling email: ${c}`
|
|
55
|
+
message: `Error compiling email: ${p(c)}`
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
));
|
|
@@ -59,5 +60,5 @@ const d = () => {
|
|
|
59
60
|
};
|
|
60
61
|
};
|
|
61
62
|
export {
|
|
62
|
-
|
|
63
|
+
P as useVersionHistoryApi
|
|
63
64
|
};
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
import { ToasterTypeOptions as
|
|
2
|
-
import { base64EncodeWithSpecialChars as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ToasterTypeOptions as s } from "../../enums/toaster.js";
|
|
2
|
+
import { base64EncodeWithSpecialChars as d } from "../../utils/base64.js";
|
|
3
|
+
import { asText as m } from "../../utils/genericUtil.js";
|
|
4
|
+
import { escapeHtml as o } from "../../utils/htmlEscape.js";
|
|
5
|
+
import { useHttp as p } from "../useHttp.js";
|
|
6
|
+
import { useToaster as c } from "../useToaster.js";
|
|
7
|
+
import { useTranslations as f } from "../useTranslations.js";
|
|
8
|
+
const j = () => {
|
|
9
|
+
const { post: l } = p(), { showToaster: a } = c(), i = f();
|
|
10
|
+
return { validateLiquidSyntax: async (u) => {
|
|
9
11
|
try {
|
|
10
|
-
const
|
|
12
|
+
const t = await l("/newsletter/contents/validate-syntax", [{
|
|
11
13
|
identifier: "default",
|
|
12
14
|
syntax: "liquid",
|
|
13
15
|
contents: {
|
|
14
16
|
subject: null,
|
|
15
17
|
preheader: null,
|
|
16
|
-
html: u
|
|
18
|
+
html: d(u),
|
|
17
19
|
ampHtml: null
|
|
18
20
|
}
|
|
19
21
|
}]);
|
|
20
|
-
if (!Array.isArray(
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
type:
|
|
24
|
-
message:
|
|
22
|
+
if (!Array.isArray(t.data)) {
|
|
23
|
+
const e = t.data;
|
|
24
|
+
return a({
|
|
25
|
+
type: s.Warning,
|
|
26
|
+
message: typeof (e == null ? void 0 : e.message) == "string" ? o(e.message) : i("journey-builder.liquid-validation-failed")
|
|
25
27
|
}), !1;
|
|
26
28
|
}
|
|
27
|
-
const [
|
|
28
|
-
return n.length ? (
|
|
29
|
-
type:
|
|
30
|
-
message: n[0].replace(/^line \d+:\s*/, "")
|
|
29
|
+
const [r] = t.data, n = Object.values((r == null ? void 0 : r.errors) ?? {});
|
|
30
|
+
return n.length ? (a({
|
|
31
|
+
type: s.Warning,
|
|
32
|
+
message: o(m(n[0]).replace(/^line \d+:\s*/, ""))
|
|
31
33
|
}), !1) : !0;
|
|
32
|
-
} catch (
|
|
33
|
-
return
|
|
34
|
-
type:
|
|
35
|
-
message:
|
|
34
|
+
} catch (t) {
|
|
35
|
+
return t != null && t.authReported || a({
|
|
36
|
+
type: s.Error,
|
|
37
|
+
message: i("journey-builder.liquid-validation-failed")
|
|
36
38
|
}), !1;
|
|
37
39
|
}
|
|
38
40
|
} };
|
|
39
41
|
};
|
|
40
42
|
export {
|
|
41
|
-
|
|
43
|
+
j as useLiquidValidator
|
|
42
44
|
};
|