@useinsider/guido 3.30.0 → 3.30.1-beta.8cab2a2

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.
Files changed (43) hide show
  1. package/dist/@types/config/schemas.js +4 -4
  2. package/dist/@types/email-be/templates.js +11 -0
  3. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +11 -16
  4. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +11 -11
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +51 -51
  6. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
  7. package/dist/composables/useExport.js +8 -7
  8. package/dist/composables/useHtmlValidator.js +102 -100
  9. package/dist/composables/useToaster.js +11 -10
  10. package/dist/composables/useVersionHistoryApi.js +22 -21
  11. package/dist/composables/validators/useLiquidValidator.js +26 -24
  12. package/dist/config/migrator/itemsBlockMigrator.js +164 -161
  13. package/dist/enums/defaults.js +4 -5
  14. package/dist/enums/email-be.js +16 -9
  15. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +148 -141
  16. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +53 -53
  17. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +40 -39
  18. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -26
  19. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +33 -32
  20. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +23 -22
  21. package/dist/extensions/Blocks/Recommendation/templates/utils.js +79 -78
  22. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +50 -41
  23. package/dist/guido.css +1 -1
  24. package/dist/node_modules/valibot/dist/index.js +95 -90
  25. package/dist/package.json.js +2 -2
  26. package/dist/services/emailBe/errors/ApiError.js +27 -26
  27. package/dist/services/emailBe/templates/TemplateService.js +112 -0
  28. package/dist/services/emailBe/templates/index.js +6 -0
  29. package/dist/services/templateLibraryApi.js +60 -88
  30. package/dist/src/@types/email-be/templates.d.ts +36 -0
  31. package/dist/src/@types/save-as-template.d.ts +1 -23
  32. package/dist/src/enums/email-be.d.ts +7 -0
  33. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +2 -0
  34. package/dist/src/services/emailBe/templates/TemplateService.d.ts +12 -0
  35. package/dist/src/services/emailBe/templates/index.d.ts +2 -0
  36. package/dist/src/stores/preview.d.ts +3 -0
  37. package/dist/src/utils/ampPreviewSanitizer.d.ts +5 -0
  38. package/dist/src/utils/htmlEscape.d.ts +5 -0
  39. package/dist/stores/preview.js +21 -15
  40. package/dist/utils/ampPreviewSanitizer.js +46 -0
  41. package/dist/utils/htmlEscape.js +5 -1
  42. package/dist/utils/pairProductVariables.js +98 -108
  43. 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 X, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as U, VALID_DYNAMIC_VARIABLE_REGEX as j } from "../enums/html-validator.js";
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 re } from "../stores/recommendation.js";
14
- import { base64EncodeWithSpecialChars as oe } from "../utils/base64.js";
15
- import { computed as ie } from "vue";
16
- import { useHttp as ae } from "./useHttp.js";
17
- import { useToaster as ce } from "./useToaster.js";
18
- import { useTranslations as le } from "./useTranslations.js";
19
- const me = /recommendation-id="(\d+)"/g;
20
- function ue(s) {
21
- return [...s.matchAll(me)].map((m) => m[1]);
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 de(s, m) {
24
- return m.some((f) => s.startsWith(`${f}_`));
25
+ function pe(s, l) {
26
+ return l.some((f) => s.startsWith(`${f}_`));
25
27
  }
26
- const fe = /^(\d+)_\d+_(.+)$/;
27
- function ge(s) {
28
- const m = s.match(fe);
29
- return m ? { recoId: m[1], attribute: m[2] } : null;
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 pe(s) {
32
- const m = new Set(J);
33
+ function ye(s) {
34
+ const l = new Set(J);
33
35
  return Object.values(s).forEach((f) => {
34
- m.add(ee(f).toLowerCase());
35
- }), m;
36
+ l.add(ee(f).toLowerCase());
37
+ }), l;
36
38
  }
37
- function Ee(s, m, f, o, d) {
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(m.map((C) => C.toLowerCase())), E = [];
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 = ge(g);
47
- if (y && o.has(y.recoId)) {
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
- de(g, f) || g.includes(".") || E.push(g);
55
+ pe(g, f) || g.includes(".") || E.push(g);
54
56
  }), E;
55
57
  }
56
- function Ce(s) {
57
- return (s.replace(Y, "$1").match($) ?? []).filter((o) => {
58
- const d = o.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
59
- return U.includes(p) ? !1 : j.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
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 Ve = () => {
63
- const { showToaster: s } = ce(), { post: m } = ae(), { config: f } = V(), o = le(), d = re(), u = Q(), p = ie(
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 pe(u.filterList);
78
+ return ye(u.filterList);
77
79
  }, C = async (e) => {
78
- const n = await m(
79
- "/newsletter/template-library/check-template-html-body",
80
- { html: oe(e) }
81
- ), { status: r, message: a } = n.data;
82
- return r || s({
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: r === void 0 ? a : o("newsletter.invalid-url-link-for-toaster")
85
- }), o(X), a === o(P) && s({
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: o("newsletter.already-in-progress")
88
- }), r;
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 r = !0;
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 [l] = i;
96
- g(l) && !t.includes(l) && (s({
97
+ const [m] = i;
98
+ g(m) && !t.includes(m) && (s({
97
99
  type: c.Warning,
98
- message: o("custom-fields.invalid-custom-fields")
99
- }), r = !1);
100
+ message: r("custom-fields.invalid-custom-fields")
101
+ }), o = !1);
100
102
  }
101
- }), r;
103
+ }), o;
102
104
  }, R = async (e, t, n) => {
103
- const r = n ? await C(e) : !0;
104
- return S(e, t) && r;
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: o("newsletter.html-content-is-empty")
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: o("custom-fields.missing-closing-braces")
114
+ message: r("custom-fields.missing-closing-braces")
113
115
  }), t < n && s({
114
116
  type: c.Warning,
115
- message: o("custom-fields.missing-opening-braces")
117
+ message: r("custom-fields.missing-opening-braces")
116
118
  }), t === n;
117
119
  }, O = (e) => {
118
- const t = Ce(e).length === 0;
120
+ const t = ve(e).length === 0;
119
121
  return t || s({
120
122
  type: c.Warning,
121
- message: o("custom-fields.invalid-custom-fields")
123
+ message: r("custom-fields.invalid-custom-fields")
122
124
  }), t;
123
- }, b = (e, t, n, r) => {
125
+ }, b = (e, t, n, o) => {
124
126
  if (p.value)
125
127
  return !0;
126
- const a = Ee(
128
+ const a = he(
127
129
  e,
128
130
  t,
129
- ue(e),
131
+ ge(e),
130
132
  n,
131
- r
133
+ o
132
134
  );
133
135
  if (a.length > 0) {
134
136
  const i = `
135
137
  <ul>
136
- ${a.map((l) => `<li>${l}</li>`).join("")}
138
+ ${a.map((m) => `<li>${m}</li>`).join("")}
137
139
  </ul>
138
140
  `;
139
141
  return s({
140
142
  type: c.Error,
141
- message: o("custom-fields.invalid-custom-fields") + i
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 r = !0;
149
+ let o = !0;
148
150
  if (t && t.forEach((a) => {
149
- const i = a.match(H), l = a.match(K), v = (i == null ? void 0 : i.join("")) || "";
150
- (!i || a !== v) && !l && (s({
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: o("newsletter.display-conditions-invalid-syntax")
153
- }), r = !1), i && i.forEach((h) => {
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: o("custom-conditions.wrong-equality-operators")
157
- }), r = !1);
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((l) => l === "if"), i = n.filter((l) => l === "endif");
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: o("custom-conditions.missing-if-endif-tag")
168
- }), r = !1);
169
+ message: r("custom-conditions.missing-if-endif-tag")
170
+ }), o = !1);
169
171
  }
170
- return r;
172
+ return o;
171
173
  }, N = (e) => {
172
- const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, r = t === n;
173
- return r || s({
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: o("custom-conditions.no-space-after-braces")
176
- }), r;
177
- }, L = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, r) => n + r, 0) > 0 ? (s({
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: o("custom-conditions.no-braces-inside-if-tag")
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: o(t ? ne : se)
188
+ message: r(t ? ne : se)
187
189
  }), !1;
188
- }, F = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
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: o("newsletter.fill-all-necessary-fields")
191
- }), !1) : !0, x = (e) => {
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: o("newsletter.invalid-image-type")
197
+ message: r("newsletter.invalid-image-type")
196
198
  }), !1);
197
199
  }, D = (e) => {
198
- const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(q);
199
- return Array.from(r).find((i) => {
200
- var l;
201
- return !((l = i.id) != null && l.trim());
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: o("unsubscribe-templates.select-checkbox-groups")
206
+ message: r("unsubscribe-templates.select-checkbox-groups")
205
207
  }), !1) : !0;
206
208
  }, k = (e) => {
207
- const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Z);
208
- return Array.from(r).find((i) => {
209
- var l;
210
- return !((l = i.id) != null && l.trim());
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: o("unsubscribe-templates.select-radio-button-groups")
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 r = [
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, r, n) && _(e) && A(e) && O(e) && b(e, r, a, i) && w(e) && N(e) && L(e) && B() && F() && x(e) && D(e) && k(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
- pe as buildPartnerAttributeNameSet,
228
- Ee as findInvalidCustomFields,
229
- Ce as getInvalidDynamicContentTags,
230
- ue as getRecommendationBlockIds,
231
- ge as parseRecommendationVariable,
232
- Ve as useHtmlValidator
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 u } from "../stores/toaster.js";
3
- import { nextTick as c } from "vue";
4
- const s = /* @__PURE__ */ new WeakMap(), p = () => {
5
- const t = u(), o = () => {
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(), c(() => {
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 n() {
17
+ function a() {
17
18
  o(), t.hideToaster();
18
19
  }
19
- function a(e, r) {
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: n, handleError: a };
26
+ return { showToaster: i, hideToaster: a, handleError: n };
26
27
  };
27
28
  export {
28
- p as useToaster
29
+ l as useToaster
29
30
  };
@@ -1,45 +1,46 @@
1
1
  import { ToasterTypeOptions as t } from "../enums/toaster.js";
2
- import { useVersionHistoryStore as m } from "../stores/version-history.js";
3
- import { findEditorApi as w, EDITOR_NOT_READY_MESSAGE as y } from "../utils/stripoEditorApi.js";
4
- import { useToaster as V } from "./useToaster.js";
5
- const d = () => {
6
- const n = m(), { showToaster: i } = V(), o = (e) => {
7
- var s;
8
- const r = (s = w()) == null ? void 0 : s.versionHistoryApi;
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: y });
11
+ i({ type: t.Error, message: V });
11
12
  return;
12
13
  }
13
14
  e(r);
14
- }, p = (e) => {
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
- o((e) => e.openVersionHistory(p, a));
22
+ s((e) => e.openVersionHistory(m, a));
22
23
  },
23
24
  closeVersionHistory: () => {
24
- o((e) => e.closeVersionHistory());
25
+ s((e) => e.closeVersionHistory());
25
26
  },
26
27
  switchToDesktopPreview: () => {
27
- o((e) => e.switchToDesktopPreview());
28
+ s((e) => e.switchToDesktopPreview());
28
29
  },
29
30
  switchToMobilePreview: () => {
30
- o((e) => e.switchToMobilePreview());
31
+ s((e) => e.switchToMobilePreview());
31
32
  },
32
33
  previewVersion: (e) => {
33
- o((r) => r.previewVersion(e, (s) => {
34
- const c = s instanceof Error ? s.message : String(s);
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
- o((r) => r.restoreVersion(
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
- (s) => {
51
- const c = s instanceof Error ? s.message : String(s);
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
- d as useVersionHistoryApi
63
+ P as useVersionHistoryApi
63
64
  };
@@ -1,42 +1,44 @@
1
- import { ToasterTypeOptions as r } from "../../enums/toaster.js";
2
- import { base64EncodeWithSpecialChars as u } from "../../utils/base64.js";
3
- import { useHttp as d } from "../useHttp.js";
4
- import { useToaster as p } from "../useToaster.js";
5
- import { useTranslations as c } from "../useTranslations.js";
6
- const v = () => {
7
- const { post: i } = d(), { showToaster: t } = p(), s = c();
8
- return { validateLiquidSyntax: async (o) => {
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 e = await i("/newsletter/contents/validate-syntax", [{
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(o),
18
+ html: d(u),
17
19
  ampHtml: null
18
20
  }
19
21
  }]);
20
- if (!Array.isArray(e.data)) {
21
- const l = e.data;
22
- return t({
23
- type: r.Warning,
24
- message: l.message ?? s("journey-builder.liquid-validation-failed")
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 [a] = e.data, n = Object.values((a == null ? void 0 : a.errors) ?? {});
28
- return n.length ? (t({
29
- type: r.Warning,
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 (e) {
33
- return e != null && e.authReported || t({
34
- type: r.Error,
35
- message: s("journey-builder.liquid-validation-failed")
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
- v as useLiquidValidator
43
+ j as useLiquidValidator
42
44
  };