@useinsider/guido 3.19.0-beta.c8d2be8 → 3.19.0-beta.cac604e

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 (26) hide show
  1. package/dist/@types/config/schemas.js +104 -91
  2. package/dist/components/organisms/header/EditorActions.vue.js +4 -4
  3. package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
  4. package/dist/composables/useActionsApi.js +52 -47
  5. package/dist/composables/useCodeEditorApi.js +23 -9
  6. package/dist/composables/useHttp.js +44 -55
  7. package/dist/composables/useTranslations.js +3 -2
  8. package/dist/composables/useVersionHistoryApi.js +33 -24
  9. package/dist/extensions/Blocks/Recommendation/block.js +88 -53
  10. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
  11. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
  12. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +42 -22
  13. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +26 -0
  14. package/dist/guido.css +1 -1
  15. package/dist/src/@types/config/schemas.d.ts +16 -0
  16. package/dist/src/composables/useConfig.d.ts +2 -0
  17. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +6 -0
  18. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
  19. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  20. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +27 -0
  21. package/dist/src/stores/config.d.ts +20 -0
  22. package/dist/src/utils/stripoEditorApi.d.ts +4 -0
  23. package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
  24. package/dist/stores/unsubscribe.js +3 -3
  25. package/dist/utils/stripoEditorApi.js +11 -0
  26. package/package.json +2 -1
@@ -1,18 +1,23 @@
1
- import { filterAmpErrors as v } from "../utils/ampErrorFilter.js";
2
- import { useToaster as y } from "./useToaster.js";
3
- const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
4
- const w = setTimeout(
5
- () => m(new Error(`${n} did not report completion within ${l}ms`)),
1
+ import { filterAmpErrors as y } from "../utils/ampErrorFilter.js";
2
+ import { getEditorApi as s } from "../utils/stripoEditorApi.js";
3
+ import { useToaster as D } from "./useToaster.js";
4
+ const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
5
+ const f = setTimeout(
6
+ () => p(new Error(`${n} did not report completion within ${l}ms`)),
6
7
  l
7
- ), p = (A) => (t) => {
8
- clearTimeout(w), A(t);
9
- };
10
- u(p(T), p(m));
11
- }), I = () => {
12
- const { handleError: n } = y(), l = (t = {}) => s(
8
+ ), c = (t) => (e) => {
9
+ clearTimeout(f), t(e);
10
+ }, d = c(p);
11
+ try {
12
+ A(c(C), d);
13
+ } catch (t) {
14
+ d(t);
15
+ }
16
+ }), P = () => {
17
+ const { handleError: n } = D(), l = (t = {}) => r(
13
18
  "compileEmail",
14
- d,
15
- (e, a) => {
19
+ T,
20
+ (e, i) => {
16
21
  const o = { ...{
17
22
  minimize: !0,
18
23
  utmEntity: {
@@ -32,53 +37,53 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
32
37
  forceAmp: !1,
33
38
  resetDataSavedFlag: !1,
34
39
  disableLineHeightsReplace: !0
35
- }, ...t }, c = {
36
- callback: (r, C, f, S, g) => {
37
- r ? a(r) : e({
38
- html: C,
39
- ampHtml: f,
40
- ampErrors: v(S ?? []),
41
- displayConditions: g
40
+ }, ...t }, u = {
41
+ callback: (m, g, w, S, v) => {
42
+ m ? i(m) : e({
43
+ html: g,
44
+ ampHtml: w,
45
+ ampErrors: y(S ?? []),
46
+ displayConditions: v
42
47
  });
43
48
  },
44
49
  ...o
45
50
  };
46
- window.StripoEditorApi.actionsApi.compileEmail(c);
51
+ s().actionsApi.compileEmail(u);
47
52
  }
48
53
  );
49
54
  return {
50
55
  getCompiledEmail: l,
51
- getTemplateData: () => s(
56
+ getTemplateData: () => r(
52
57
  "getTemplateData",
53
- d,
58
+ T,
54
59
  (t) => {
55
- const e = ({ html: a, css: i, width: o, height: E, utmParams: c, syncModulesIds: r }) => t({
56
- html: a,
57
- css: i,
60
+ const e = ({ html: i, css: a, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
61
+ html: i,
62
+ css: a,
58
63
  width: o,
59
64
  height: E,
60
- utmParams: c,
61
- syncModulesIds: r
65
+ utmParams: u,
66
+ syncModulesIds: m
62
67
  });
63
- window.StripoEditorApi.actionsApi.getTemplateData(e);
68
+ s().actionsApi.getTemplateData(e);
64
69
  }
65
70
  ),
66
71
  activateCustomViewStyles: (t = !0) => {
67
- window.StripoEditorApi.actionsApi.activateCustomViewStyles(t);
72
+ s().actionsApi.activateCustomViewStyles(t);
68
73
  },
69
74
  getPreviewData: async (t) => {
70
75
  try {
71
76
  const {
72
77
  html: e,
73
- displayConditions: a,
74
- ampHtml: i = "",
78
+ displayConditions: i,
79
+ ampHtml: a = "",
75
80
  ampErrors: o = []
76
81
  } = await l({ minimize: !1, resetDataSavedFlag: !1, ...t });
77
82
  return {
78
83
  html: e,
79
- ampHtml: i,
84
+ ampHtml: a,
80
85
  ampErrors: o,
81
- displayConditions: a
86
+ displayConditions: i
82
87
  };
83
88
  } catch (e) {
84
89
  return n(e, "Error loading preview"), {
@@ -90,30 +95,30 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
90
95
  }
91
96
  },
92
97
  updateTimerInClonedTemplate: () => new Promise((t) => {
93
- var e, a;
94
- if (typeof ((a = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : a.updateTimerInClonedTemplate) != "function") {
98
+ var e, i;
99
+ if (typeof ((i = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : i.updateTimerInClonedTemplate) != "function") {
95
100
  t(null);
96
101
  return;
97
102
  }
98
103
  try {
99
- window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
100
- i ? (n(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
104
+ window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((a, o) => {
105
+ a ? (n(a, "Failed to update timer in cloned template"), t(null)) : t(o || null);
101
106
  });
102
- } catch (i) {
103
- n(i, "Failed to call updateTimerInClonedTemplate"), t(null);
107
+ } catch (a) {
108
+ n(a, "Failed to call updateTimerInClonedTemplate"), t(null);
104
109
  }
105
110
  }),
106
111
  updateHtmlAndCss: (t, e) => {
107
- const { actionsApi: a } = window.StripoEditorApi;
108
- return s("updateHtmlAndCss", D, (i) => {
109
- a.updateHtmlAndCss(t, e, () => i());
112
+ const { actionsApi: i } = s();
113
+ return r("updateHtmlAndCss", h, (a) => {
114
+ i.updateHtmlAndCss(t, e, () => a());
110
115
  });
111
116
  },
112
- editorSave: () => s(
117
+ editorSave: () => r(
113
118
  "save",
114
- d,
119
+ T,
115
120
  (t) => {
116
- window.StripoEditorApi.actionsApi.save((e) => {
121
+ s().actionsApi.save((e) => {
117
122
  if (e) {
118
123
  n(e, "Failed to save template"), t(!1);
119
124
  return;
@@ -125,5 +130,5 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
125
130
  };
126
131
  };
127
132
  export {
128
- I as useActionsApi
133
+ P as useActionsApi
129
134
  };
@@ -1,11 +1,25 @@
1
- const i = () => ({
2
- openCodeEditor: () => {
3
- window.StripoEditorApi.codeEditorApi.openCodeEditor();
4
- },
5
- closeCodeEditor: () => {
6
- window.StripoEditorApi.codeEditorApi.closeCodeEditor();
7
- }
8
- });
1
+ import { ToasterTypeOptions as d } from "../enums/toaster.js";
2
+ import { findEditorApi as s, EDITOR_NOT_READY_MESSAGE as p } from "../utils/stripoEditorApi.js";
3
+ import { useToaster as E } from "./useToaster.js";
4
+ const T = () => {
5
+ const { showToaster: i } = E(), t = (o) => {
6
+ var r;
7
+ const e = (r = s()) == null ? void 0 : r.codeEditorApi;
8
+ if (!e) {
9
+ i({ type: d.Error, message: p });
10
+ return;
11
+ }
12
+ o(e);
13
+ };
14
+ return {
15
+ openCodeEditor: () => {
16
+ t((o) => o.openCodeEditor());
17
+ },
18
+ closeCodeEditor: () => {
19
+ t((o) => o.closeCodeEditor());
20
+ }
21
+ };
22
+ };
9
23
  export {
10
- i as useCodeEditorApi
24
+ T as useCodeEditorApi
11
25
  };
@@ -1,7 +1,7 @@
1
1
  import { getCsrfToken as O } from "../utils/genericUtil.js";
2
- import { ref as m, computed as w } from "vue";
3
- const k = (g = {}) => {
4
- const h = m(!1), n = m(null), u = m(null), b = w(() => h.value), y = w(() => n.value !== null), v = {
2
+ import { ref as m, computed as T } from "vue";
3
+ const X = (b = {}) => {
4
+ const p = m(!1), a = m(null), u = m(null), g = T(() => p.value), y = T(() => a.value !== null), v = {
5
5
  baseURL: "",
6
6
  timeout: 1e4,
7
7
  retry: 0,
@@ -10,90 +10,79 @@ const k = (g = {}) => {
10
10
  "Content-Type": "application/json",
11
11
  "X-CSRF-TOKEN": O(),
12
12
  Accept: "application/json",
13
- // The panel backend only answers 401/419 to ajax requests; without this a guest
14
- // fetch gets a 302 to the login page and never sees an auth status.
15
13
  "X-Requested-With": "XMLHttpRequest"
16
14
  },
17
- ...g
18
- }, x = (e, r) => {
15
+ ...b
16
+ }, w = (e, s) => {
19
17
  if (e.startsWith("http://") || e.startsWith("https://"))
20
18
  return e;
21
- const t = r || v.baseURL || "";
19
+ const t = s || v.baseURL || "";
22
20
  return t.endsWith("/") && e.startsWith("/") ? `${t}${e.slice(1)}` : t.endsWith("/") || e.startsWith("/") ? `${t}${e}` : `${t}/${e}`;
23
- }, P = (e) => new Promise((r, t) => {
21
+ }, P = (e) => new Promise((s, t) => {
24
22
  setTimeout(() => {
25
23
  t(new Error("Request timeout"));
26
24
  }, e);
27
- }), C = (e) => new Promise((r) => {
28
- setTimeout(r, e);
29
- }), i = async (e, r, t, W = {}) => {
30
- n.value = null, h.value = !0, u.value = new AbortController();
31
- const a = { ...v, ...W }, E = x(r, a.baseURL), c = {
25
+ }), x = (e) => new Promise((s) => {
26
+ setTimeout(s, e);
27
+ }), i = async (e, s, t, L = {}) => {
28
+ a.value = null, p.value = !0, u.value = new AbortController();
29
+ const n = { ...v, ...L }, D = w(s, n.baseURL), c = {
32
30
  method: e,
33
- headers: { ...a.headers },
31
+ headers: { ...n.headers },
34
32
  signal: u.value.signal,
35
- ...a
33
+ ...n
36
34
  };
37
35
  t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
38
- const T = async (p = 0) => {
39
- if (window.isSessionExpired)
40
- throw n.value = { message: "Session expired" }, new Error("Session expired");
36
+ const E = async (h = 0) => {
41
37
  try {
42
- const o = [fetch(E, c)];
43
- a.timeout && o.push(P(a.timeout));
44
- const s = await Promise.race(o);
45
- if (!s.ok) {
46
- const D = `HTTP Error: ${s.status} ${s.statusText}`, f = new Error(D);
47
- throw f.status = s.status, f.statusText = s.statusText, f.response = s, [401, 403, 419].includes(s.status) && Promise.resolve().then(() => s.clone().text().catch(() => "")).then((H) => window.dispatchEvent(new CustomEvent("insider:http-auth-error", {
48
- detail: {
49
- status: s.status,
50
- body: H,
51
- url: new URL(E, window.location.href).href
52
- }
53
- }))).catch(() => {
54
- }), f;
38
+ const o = [fetch(D, c)];
39
+ n.timeout && o.push(P(n.timeout));
40
+ const r = await Promise.race(o);
41
+ if (!r.ok) {
42
+ const H = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(H);
43
+ throw d.status = r.status, d.statusText = r.statusText, d.response = r, d;
55
44
  }
56
- let d;
57
- const l = s.headers.get("content-type");
58
- return l != null && l.includes("application/json") ? d = await s.json() : l != null && l.includes("text/") ? d = await s.text() : d = await s.blob(), {
59
- data: d,
60
- status: s.status,
61
- statusText: s.statusText,
62
- headers: s.headers
45
+ let f;
46
+ const l = r.headers.get("content-type");
47
+ return l != null && l.includes("application/json") ? f = await r.json() : l != null && l.includes("text/") ? f = await r.text() : f = await r.blob(), {
48
+ data: f,
49
+ status: r.status,
50
+ statusText: r.statusText,
51
+ headers: r.headers
63
52
  };
64
53
  } catch (o) {
65
- const s = o instanceof Error && o.name === "AbortError";
66
- if (p < (a.retry || 0) && !s)
67
- return await C(a.retryDelay || 1e3), T(p + 1);
68
- throw o instanceof Error ? o.name === "AbortError" ? n.value = { message: "Request was cancelled" } : n.value = { message: o.message } : n.value = o, o;
54
+ const r = o instanceof Error && o.name === "AbortError";
55
+ if (h < (n.retry || 0) && !r)
56
+ return await x(n.retryDelay || 1e3), E(h + 1);
57
+ throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
69
58
  }
70
59
  };
71
60
  try {
72
- return await T();
61
+ return await E();
73
62
  } finally {
74
- h.value = !1, u.value = null;
63
+ p.value = !1, u.value = null;
75
64
  }
76
- }, R = (e, r) => i("GET", e, void 0, r), U = (e, r, t) => i("POST", e, r, t), $ = (e, r, t) => i("PUT", e, r, t), q = (e, r, t) => i("PATCH", e, r, t), A = (e, r) => i("DELETE", e, void 0, r), L = (e) => {
65
+ }, C = (e, s) => i("GET", e, void 0, s), R = (e, s, t) => i("POST", e, s, t), $ = (e, s, t) => i("PUT", e, s, t), q = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), U = (e) => {
77
66
  u.value && u.value.abort(e);
78
- }, S = () => {
79
- n.value = null;
67
+ }, W = () => {
68
+ a.value = null;
80
69
  };
81
70
  return {
82
71
  // State
83
- loading: b,
84
- error: w(() => n.value),
72
+ loading: g,
73
+ error: T(() => a.value),
85
74
  hasError: y,
86
75
  // Methods
87
76
  request: i,
88
- get: R,
89
- post: U,
77
+ get: C,
78
+ post: R,
90
79
  put: $,
91
80
  patch: q,
92
81
  delete: A,
93
- cancel: L,
94
- clearError: S
82
+ cancel: U,
83
+ clearError: W
95
84
  };
96
85
  };
97
86
  export {
98
- k as useHttp
87
+ X as useHttp
99
88
  };
@@ -6,9 +6,10 @@ import { useConfig } from "./useConfig.js";
6
6
  const useTranslations = () => {
7
7
  var o, e;
8
8
  const { config } = useConfig(), translationsPath = ((e = (o = config.value) == null ? void 0 : o.editor) == null ? void 0 : e.translationsPath) || DEFAULT_EDITOR.translationsPath, translations = ref(eval(translationsPath)), trans = (t, n) => {
9
- const r = translations.value[t];
9
+ var s;
10
+ const r = (s = translations.value) == null ? void 0 : s[t];
10
11
  return r ? n ? Object.entries(n).reduce(
11
- (s, [i, a]) => s.replace(new RegExp(`{${i}}`, "g"), String(a)),
12
+ (i, [a, l]) => i.replace(new RegExp(`{${a}}`, "g"), String(l)),
12
13
  r
13
14
  ) : r : (console.warn(`Translation key not found: ${t}`), t);
14
15
  };
@@ -1,54 +1,63 @@
1
1
  import { ToasterTypeOptions as t } from "../enums/toaster.js";
2
- import { useVersionHistoryStore as c } from "../stores/version-history.js";
3
- import { useToaster as w } from "./useToaster.js";
4
- const S = () => {
5
- const i = c(), { showToaster: s } = w(), n = (e) => {
6
- i.$reset(), i.updateState(e);
7
- }, p = () => {
8
- i.$reset();
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;
9
+ if (!r) {
10
+ i({ type: t.Error, message: y });
11
+ return;
12
+ }
13
+ e(r);
14
+ }, p = (e) => {
15
+ n.$reset(), n.updateState(e);
16
+ }, a = () => {
17
+ n.$reset();
9
18
  };
10
19
  return {
11
20
  openVersionHistory: () => {
12
- window.StripoEditorApi.versionHistoryApi.openVersionHistory(n, p);
21
+ o((e) => e.openVersionHistory(p, a));
13
22
  },
14
23
  closeVersionHistory: () => {
15
- window.StripoEditorApi.versionHistoryApi.closeVersionHistory();
24
+ o((e) => e.closeVersionHistory());
16
25
  },
17
26
  switchToDesktopPreview: () => {
18
- window.StripoEditorApi.versionHistoryApi.switchToDesktopPreview();
27
+ o((e) => e.switchToDesktopPreview());
19
28
  },
20
29
  switchToMobilePreview: () => {
21
- window.StripoEditorApi.versionHistoryApi.switchToMobilePreview();
30
+ o((e) => e.switchToMobilePreview());
22
31
  },
23
32
  previewVersion: (e) => {
24
- window.StripoEditorApi.versionHistoryApi.previewVersion(e, (o) => {
25
- const r = o instanceof Error ? o.message : String(o);
26
- s({
33
+ o((r) => r.previewVersion(e, (s) => {
34
+ const c = s instanceof Error ? s.message : String(s);
35
+ i({
27
36
  type: t.Error,
28
- message: `Error compiling email: ${r}`
37
+ message: `Error compiling email: ${c}`
29
38
  });
30
- });
39
+ }));
31
40
  },
32
41
  restoreVersion: (e) => {
33
- window.StripoEditorApi.versionHistoryApi.restoreVersion(
42
+ o((r) => r.restoreVersion(
34
43
  e,
35
44
  () => {
36
- s({
45
+ i({
37
46
  type: t.Success,
38
47
  message: "Your version has been restored successfully."
39
48
  });
40
49
  },
41
- (o) => {
42
- const r = o instanceof Error ? o.message : String(o);
43
- s({
50
+ (s) => {
51
+ const c = s instanceof Error ? s.message : String(s);
52
+ i({
44
53
  type: t.Error,
45
- message: `Error compiling email: ${r}`
54
+ message: `Error compiling email: ${c}`
46
55
  });
47
56
  }
48
- );
57
+ ));
49
58
  }
50
59
  };
51
60
  };
52
61
  export {
53
- S as useVersionHistoryApi
62
+ d as useVersionHistoryApi
54
63
  };