@useinsider/guido 3.19.0-beta.ab4fcb3 → 3.19.0-beta.b73a570

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 (32) hide show
  1. package/dist/@types/config/schemas.js +91 -104
  2. package/dist/components/Guido.vue.js +6 -6
  3. package/dist/components/Guido.vue2.js +72 -75
  4. package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
  5. package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
  6. package/dist/components/wrappers/WpModal.vue.js +1 -1
  7. package/dist/components/wrappers/WpModal.vue2.js +4 -3
  8. package/dist/composables/useAuthError.js +52 -0
  9. package/dist/composables/useHttp.js +64 -54
  10. package/dist/composables/useToaster.js +17 -15
  11. package/dist/composables/validators/useLiquidValidator.js +15 -15
  12. package/dist/config/migrator/index.js +13 -14
  13. package/dist/extensions/Blocks/Recommendation/block.js +14 -15
  14. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +38 -45
  15. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +49 -72
  16. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +0 -1
  17. package/dist/guido.css +1 -1
  18. package/dist/src/@types/config/schemas.d.ts +0 -16
  19. package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
  20. package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
  21. package/dist/src/composables/useAuthError.d.ts +12 -0
  22. package/dist/src/composables/useConfig.d.ts +0 -2
  23. package/dist/src/composables/useHttp.d.ts +2 -0
  24. package/dist/src/config/migrator/index.d.ts +1 -2
  25. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -6
  26. package/dist/src/stores/config.d.ts +0 -20
  27. package/dist/static/styles/components/recommendation-strategy.css.js +0 -9
  28. package/package.json +1 -1
  29. package/dist/config/migrator/recommendationPartnerMigrator.js +0 -50
  30. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +0 -25
  31. package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +0 -19
  32. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +0 -33
@@ -1,57 +1,58 @@
1
- import { defineComponent as ae, defineAsyncComponent as m, ref as x, computed as u, watch as W, onMounted as se, onUnmounted as ie } from "vue";
2
- import { useCortexBlueprintBridge as ce } from "../composables/useCortexBlueprintBridge.js";
3
- import { useEditorLock as de } from "../composables/useEditorLock.js";
4
- import { provideGuidoActions as me } from "../composables/useGuidoActions.js";
5
- import { useGuidoStateBridge as le } from "../composables/useGuidoStateBridge.js";
6
- import { usePartner as ue } from "../composables/usePartner.js";
7
- import { useStripo as pe } from "../composables/useStripo.js";
8
- import { useTimerClone as fe } from "../composables/useTimerClone.js";
9
- import { migrate as G } from "../config/migrator/index.js";
10
- import { ModuleFolderDefaults as H } from "../enums/defaults.js";
11
- import { RIBBON_SELECTOR as ye } from "../enums/onboarding.js";
12
- import { useRecommendationExtensionStore as h } from "../extensions/Blocks/Recommendation/store/recommendation.js";
13
- import ge from "./organisms/AutoSaveController.vue.js";
14
- import Se from "./organisms/base/Toaster.vue.js";
15
- import ve from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
16
- import be from "./organisms/header/HeaderWrapper.vue.js";
17
- import he from "./organisms/LoadingWrapper.vue.js";
1
+ import { defineComponent as re, defineAsyncComponent as m, ref as O, computed as u, watch as x, onMounted as se, onUnmounted as ae } from "vue";
2
+ import { useCortexBlueprintBridge as ie } from "../composables/useCortexBlueprintBridge.js";
3
+ import { useEditorLock as ce } from "../composables/useEditorLock.js";
4
+ import { provideGuidoActions as de } from "../composables/useGuidoActions.js";
5
+ import { useGuidoStateBridge as me } from "../composables/useGuidoStateBridge.js";
6
+ import { usePartner as le } from "../composables/usePartner.js";
7
+ import { useStripo as ue } from "../composables/useStripo.js";
8
+ import { useTimerClone as pe } from "../composables/useTimerClone.js";
9
+ import { migrate as W } from "../config/migrator/index.js";
10
+ import { ModuleFolderDefaults as G } from "../enums/defaults.js";
11
+ import { RIBBON_SELECTOR as fe } from "../enums/onboarding.js";
12
+ import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
13
+ import ye from "./organisms/AutoSaveController.vue.js";
14
+ import ge from "./organisms/base/AuthErrorModal.vue.js";
15
+ import ve from "./organisms/base/Toaster.vue.js";
16
+ import Se from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
17
+ import he from "./organisms/header/HeaderWrapper.vue.js";
18
+ import be from "./organisms/LoadingWrapper.vue.js";
18
19
  import Ee from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
19
20
  import we from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
20
21
  import { useStripoApi as Ce } from "../services/stripoApi.js";
21
22
  import { useConfigStore as De } from "../stores/config.js";
22
23
  import { useDynamicContentStore as ke } from "../stores/dynamic-content.js";
23
- import { useEditorStore as $ } from "../stores/editor.js";
24
- import { usePreviewStore as Fe } from "../stores/preview.js";
25
- import { useTemplateStore as Re } from "../stores/template.js";
26
- import { useUnsubscribeStore as Te } from "../stores/unsubscribe.js";
27
- import { readTrackFloor as z } from "../utils/linkTrackingIds.js";
28
- const ot = /* @__PURE__ */ ae({
24
+ import { useEditorStore as H } from "../stores/editor.js";
25
+ import { usePreviewStore as Me } from "../stores/preview.js";
26
+ import { useTemplateStore as Te } from "../stores/template.js";
27
+ import { useUnsubscribeStore as Fe } from "../stores/unsubscribe.js";
28
+ import { readTrackFloor as $ } from "../utils/linkTrackingIds.js";
29
+ const nt = /* @__PURE__ */ re({
29
30
  __name: "Guido",
30
31
  props: {
31
32
  config: null,
32
33
  ready: { type: Boolean, default: !0 }
33
34
  },
34
35
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
35
- setup(q, { expose: K, emit: r }) {
36
- const s = q, V = m(
36
+ setup(z, { expose: q, emit: r }) {
37
+ const a = z, K = m(
37
38
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
38
- ), j = m(
39
+ ), V = m(
39
40
  () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
40
- ), J = m(
41
+ ), j = m(
41
42
  () => import("./organisms/extensions/recommendation/AssignStrategyDrawer.vue.js")
42
- ), Q = m(
43
+ ), J = m(
43
44
  () => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
44
- ), X = m(
45
+ ), Q = m(
45
46
  () => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
46
- ), E = x(), p = x(), f = ke(), w = Te(), o = De();
47
- s.ready && o.init(s.config);
48
- const c = $(), Y = Fe(), l = u(() => c.hasChanges), { isTestPartner: Z } = ue(), C = () => {
47
+ ), E = O(), p = O(), f = ke(), w = Fe(), o = De();
48
+ a.ready && o.init(a.config);
49
+ const c = H(), X = Me(), l = u(() => c.hasChanges), { isTestPartner: Y } = le(), C = () => {
49
50
  var t;
50
51
  return (t = E.value) == null ? void 0 : t.handleSave(!0);
51
52
  }, D = (t) => {
52
53
  c.loadingStatus = t;
53
54
  };
54
- ce(), le();
55
+ ie(), me();
55
56
  const y = () => {
56
57
  var t, e;
57
58
  return {
@@ -59,18 +60,18 @@ const ot = /* @__PURE__ */ ae({
59
60
  userId: o.userId,
60
61
  username: o.username,
61
62
  partnerName: o.partnerName,
62
- savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || H.SAVED_MODULES,
63
- defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || H.DEFAULT_MODULES
63
+ savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || G.SAVED_MODULES,
64
+ defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || G.DEFAULT_MODULES
64
65
  };
65
- }, { initPlugin: k, preloadRuntime: F } = pe(), { runExclusive: R, beginMount: T, isCurrentMount: M } = de();
66
+ }, { initPlugin: k, preloadRuntime: M } = ue(), { runExclusive: T, beginMount: F, isCurrentMount: R } = ce();
66
67
  let g = 0;
67
- const { getDefaultTemplate: I } = Ce(), { cloneTimersOnSave: L, hasTimerBlocks: U } = fe(), ee = u(() => {
68
+ const { getDefaultTemplate: I } = Ce(), { cloneTimersOnSave: L, hasTimerBlocks: A } = pe(), Z = u(() => {
68
69
  var t;
69
70
  return !((t = o.ui) != null && t.showHeader);
70
- }), te = u(() => o.isFeatureEnabled("reusableRecommendationStrategy")), oe = u(
71
- () => !!h().recommendationConfigs.strategyId
71
+ }), ee = u(() => o.isFeatureEnabled("reusableRecommendationStrategy")), te = u(
72
+ () => !!b().recommendationConfigs.strategyId
72
73
  );
73
- me({
74
+ de({
74
75
  onBack: () => {
75
76
  console.debug("guido:back"), r("back");
76
77
  },
@@ -87,82 +88,78 @@ const ot = /* @__PURE__ */ ae({
87
88
  });
88
89
  const B = (t) => {
89
90
  console.debug("dynamic-content:close", t), f.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
90
- }, N = () => {
91
+ }, U = () => {
91
92
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
92
93
  };
93
- W(() => l.value, () => {
94
+ x(() => l.value, () => {
94
95
  r("on-change", l.value);
95
96
  });
96
- const S = (t) => {
97
- const e = t, { attribute: a, position: d } = e.detail;
98
- console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", a, d);
97
+ const v = (t) => {
98
+ const e = t, { attribute: s, position: d } = e.detail;
99
+ console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", s, d);
99
100
  };
100
101
  let i = null;
101
- const v = () => {
102
+ const S = () => {
102
103
  var e;
103
- const t = document.querySelector(ye);
104
+ const t = document.querySelector(fe);
104
105
  (e = p.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
105
- }, b = async () => {
106
+ }, h = async () => {
106
107
  var t;
107
108
  try {
108
- o.initialized || o.init(s.config), c.templateId = o.templateId;
109
- const e = o.template, a = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", A = (e == null ? void 0 : e.preselectedDynamicContent) || [];
109
+ o.initialized || o.init(a.config), c.templateId = o.templateId;
110
+ const e = o.template, s = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", P = (e == null ? void 0 : e.preselectedDynamicContent) || [];
110
111
  w.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
111
- const P = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, _ = o.isFeatureEnabled("linkTrackingIds"), O = {
112
- partnerName: o.partnerName,
113
- campaignUrls: e == null ? void 0 : e.recommendationCampaignUrls,
114
- rrsEnabled: o.isFeatureEnabled("reusableRecommendationStrategy")
115
- };
112
+ const _ = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, N = o.isFeatureEnabled("linkTrackingIds");
116
113
  let n = {
117
- html: a && await G(a, P, O),
114
+ html: s && await W(s, _),
118
115
  css: d
119
116
  };
120
- n.html || (n = await I(), n.html = await G(n.html, P, O));
121
- const ne = _ ? z(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
122
- U(n.html) && (n.html = await L(n.html)), _ && (c.trackIdSessionFloor = Math.max(ne, z(n.html)));
123
- const re = {
124
- preselectedDynamicContentList: A,
117
+ n.html || (n = await I(), n.html = await W(n.html, _));
118
+ const oe = N ? $(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
119
+ A(n.html) && (n.html = await L(n.html)), N && (c.trackIdSessionFloor = Math.max(oe, $(n.html)));
120
+ const ne = {
121
+ preselectedDynamicContentList: P,
125
122
  onReady: () => {
126
123
  console.debug("guido:ready"), r("ready");
127
124
  }
128
125
  };
129
- g = T(), await k(n, y(), re), f.selectedDynamicContentList = A;
126
+ g = F(), await k(n, y(), ne), f.selectedDynamicContentList = P;
130
127
  } catch (e) {
131
128
  console.error("Failed to initialize Stripo editor:", e);
132
129
  }
133
130
  };
134
131
  return se(async () => {
135
132
  var e;
136
- console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), h().$reset(), $().$reset(), Re().$reset(), v();
133
+ console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), b().$reset(), H().$reset(), Te().$reset(), S();
137
134
  const t = (e = p.value) == null ? void 0 : e.parentElement;
138
- if (t && (i = new ResizeObserver(v), i.observe(t)), F(), s.ready)
139
- await b();
135
+ if (t && (i = new ResizeObserver(S), i.observe(t)), M(), a.ready)
136
+ await h();
140
137
  else {
141
- const a = W(() => s.ready, (d) => {
142
- d && (a(), b());
138
+ const s = x(() => a.ready, (d) => {
139
+ d && (s(), h());
143
140
  });
144
141
  }
145
- document.addEventListener("dynamic-content:open", S);
146
- }), ie(() => {
147
- i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", S), h().disposeStrategyPageReturn(), R(async () => {
148
- if (M(g))
142
+ document.addEventListener("dynamic-content:open", v);
143
+ }), ae(() => {
144
+ i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", v), b().disposeStrategyPageReturn(), T(async () => {
145
+ if (R(g))
149
146
  try {
150
147
  window.UIEditor.removeEditor();
151
148
  } catch {
152
149
  console.debug("Failed to remove Stripo editor: No editor found");
153
150
  }
154
151
  }), o.reset();
155
- }), K({
152
+ }), q({
156
153
  dynamicContent: {
157
154
  insert: B,
158
- close: N
155
+ close: U
159
156
  },
160
157
  hasChanges: l,
161
158
  saveSilent: C,
162
159
  setLoading: D
163
- }), { __sfc: !0, PreviewContainer: V, OnboardingWrapper: j, AssignStrategyDrawer: J, RemoveStrategyModal: Q, LegacyStrategyUpdatedModal: X, headerWrapperRef: E, wrapperRef: p, dynamicContentStore: f, unsubscribeStore: w, props: s, configStore: o, editorStore: c, previewStore: Y, hasChanges: l, isTestPartner: Z, saveSilent: C, setLoading: D, emit: r, buildMetadata: y, initPlugin: k, preloadRuntime: F, runExclusive: R, beginMount: T, isCurrentMount: M, mountGeneration: g, getDefaultTemplate: I, cloneTimersOnSave: L, hasTimerBlocks: U, noHeader: ee, isRrsEnabled: te, hasAssignedStrategy: oe, insertDynamicContent: B, closeDynamicContent: N, handleDynamicContentOpen: S, ribbonObserver: i, updateRibbonOffset: v, startEditor: b, AutoSaveController: ge, Toaster: Se, FilterSelectionDrawer: ve, HeaderWrapper: be, LoadingWrapper: he, SaveAsTemplateDrawer: Ee, UnsubscribeWrapper: we };
160
+ }), { __sfc: !0, PreviewContainer: K, OnboardingWrapper: V, AssignStrategyDrawer: j, RemoveStrategyModal: J, LegacyStrategyUpdatedModal: Q, headerWrapperRef: E, wrapperRef: p, dynamicContentStore: f, unsubscribeStore: w, props: a, configStore: o, editorStore: c, previewStore: X, hasChanges: l, isTestPartner: Y, saveSilent: C, setLoading: D, emit: r, buildMetadata: y, initPlugin: k, preloadRuntime: M, runExclusive: T, beginMount: F, isCurrentMount: R, mountGeneration: g, getDefaultTemplate: I, cloneTimersOnSave: L, hasTimerBlocks: A, noHeader: Z, isRrsEnabled: ee, hasAssignedStrategy: te, insertDynamicContent: B, closeDynamicContent: U, handleDynamicContentOpen: v, ribbonObserver: i, updateRibbonOffset: S, startEditor: h, AutoSaveController: ye, AuthErrorModal: ge, Toaster: ve, FilterSelectionDrawer: Se, HeaderWrapper: he, LoadingWrapper: be, SaveAsTemplateDrawer: Ee, UnsubscribeWrapper: we };
164
161
  }
165
162
  });
166
163
  export {
167
- ot as default
164
+ nt as default
168
165
  };
@@ -0,0 +1,18 @@
1
+ import e from "./AuthErrorModal.vue2.js";
2
+ /* empty css */
3
+ import s from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var a = function() {
5
+ var o = this, r = o._self._c, t = o._self._setupProxy;
6
+ return t.authError ? r("div", { staticClass: "auth-error-modal" }, [r(t.WpModal, { attrs: { id: "guido__auth-error-modal", state: "warning", "close-button-status": !1, "close-on-outside-click": !1, "footer-button-options": t.footerButtonOptions, title: t.title }, on: { close: t.dismiss, "primary-action": t.recover } }, [r("p", [o._v(o._s(t.message))])])], 1) : o._e();
7
+ }, n = [], i = /* @__PURE__ */ s(
8
+ e,
9
+ a,
10
+ n,
11
+ !1,
12
+ null,
13
+ "b4d7ae51"
14
+ );
15
+ const m = i.exports;
16
+ export {
17
+ m as default
18
+ };
@@ -0,0 +1,42 @@
1
+ import { defineComponent as c, computed as n } from "vue";
2
+ import p from "../../wrappers/WpModal.vue.js";
3
+ import { useAuthError as d } from "../../../composables/useAuthError.js";
4
+ import { useTranslations as m } from "../../../composables/useTranslations.js";
5
+ const _ = /* @__PURE__ */ c({
6
+ __name: "AuthErrorModal",
7
+ setup(v) {
8
+ const e = m(), { authError: t } = d(), r = n(() => {
9
+ var o;
10
+ return ((o = t.value) == null ? void 0 : o.status) === 419 && t.value.data !== null;
11
+ }), s = n(() => {
12
+ var o;
13
+ return ((o = t.value) == null ? void 0 : o.status) === 419 && t.value.data === null;
14
+ }), i = n(() => r.value ? e("integration-hub.reload-this-page") : e("action-builder.session-expired")), u = n(() => r.value ? e("auth.error-occurred-refresh") : s.value ? e("settings.session-on-another-device") : e("journey-builder.login-session-expired")), l = n(() => ({
15
+ primaryButton: {
16
+ type: "primary",
17
+ labelText: r.value ? e("integration-hub.reload") : e("journey-builder.login-popup-button")
18
+ },
19
+ cancelOrBackButton: {
20
+ type: "secondary",
21
+ styling: "ghost",
22
+ labelText: e("settings.cancel")
23
+ }
24
+ })), a = () => {
25
+ if (r.value) {
26
+ window.location.reload();
27
+ return;
28
+ }
29
+ window.location.replace("/");
30
+ };
31
+ return { __sfc: !0, trans: e, authError: t, isPageExpired: r, isTakenOver: s, title: i, message: u, footerButtonOptions: l, recover: a, dismiss: () => {
32
+ if (r.value) {
33
+ t.value = null;
34
+ return;
35
+ }
36
+ a();
37
+ }, WpModal: p };
38
+ }
39
+ });
40
+ export {
41
+ _ as default
42
+ };
@@ -2,7 +2,7 @@ import r from "./WpModal.vue2.js";
2
2
  import s from "../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var i = function() {
4
4
  var t = this, o = t._self._c, e = t._self._setupProxy;
5
- return o(e.InModalV2, { attrs: { id: t.id, "description-status": "", status: "", "close-button-status": t.closeButtonStatus, "close-on-outside-click": t.closeOnOutsideClick, "description-text": t.description, "footer-button-group-options": t.footerButtonOptions, "footer-status": t.footerStatus, size: t.size, "title-text": t.title }, on: { cancelOrBackButtonEvent: function(n) {
5
+ return o(e.InModalV2, { attrs: { id: t.id, "description-status": "", status: "", "close-button-status": t.closeButtonStatus, "close-on-outside-click": t.closeOnOutsideClick, "description-text": t.description, "footer-button-group-options": t.footerButtonOptions, "footer-status": t.footerStatus, size: t.size, state: t.state, "title-text": t.title }, on: { cancelOrBackButtonEvent: function(n) {
6
6
  return e.emit("close");
7
7
  }, onCloseEvent: function(n) {
8
8
  return e.emit("close");
@@ -1,11 +1,12 @@
1
1
  import { defineComponent as e } from "vue";
2
2
  import { InModalV2 as o } from "@useinsider/design-system-vue";
3
- const u = /* @__PURE__ */ e({
3
+ const n = /* @__PURE__ */ e({
4
4
  __name: "WpModal",
5
5
  props: {
6
6
  id: null,
7
7
  title: null,
8
8
  description: { default: "" },
9
+ state: { default: "default" },
9
10
  size: { default: "small" },
10
11
  footerButtonOptions: { default: void 0 },
11
12
  closeButtonStatus: { type: Boolean, default: !0 },
@@ -13,10 +14,10 @@ const u = /* @__PURE__ */ e({
13
14
  footerStatus: { type: Boolean, default: !0 }
14
15
  },
15
16
  emits: ["close", "primary-action", "secondary-action"],
16
- setup(l, { emit: t }) {
17
+ setup(a, { emit: t }) {
17
18
  return { __sfc: !0, emit: t, InModalV2: o };
18
19
  }
19
20
  });
20
21
  export {
21
- u as default
22
+ n as default
22
23
  };
@@ -0,0 +1,52 @@
1
+ import { ToasterTypeOptions as l } from "../enums/toaster.js";
2
+ import { ref as p } from "vue";
3
+ import { useToaster as u } from "./useToaster.js";
4
+ import { useTranslations as f } from "./useTranslations.js";
5
+ const d = ["accessExpired", "domainRestricted", "ipRestricted", "insiderAccessRestricted"], n = p(null), a = (e) => {
6
+ try {
7
+ return new URL(e, window.location.href).origin === window.location.origin;
8
+ } catch {
9
+ return !0;
10
+ }
11
+ }, g = (e) => {
12
+ try {
13
+ const o = new URL(e, window.location.href);
14
+ return o.origin === window.location.origin ? o.href : "";
15
+ } catch {
16
+ return "";
17
+ }
18
+ }, w = (e) => {
19
+ try {
20
+ const o = JSON.parse(e);
21
+ return o && typeof o == "object" && Object.keys(o).length ? o : null;
22
+ } catch {
23
+ return null;
24
+ }
25
+ }, y = (e) => typeof (e == null ? void 0 : e.message) == "string" ? e.message : "", s = (e) => y(e) || f()("user-management.collaborate-forbidden-action"), c = (e) => {
26
+ u().showToaster({ type: l.Error, message: e });
27
+ }, R = (e, o, t) => {
28
+ if (t && !a(t))
29
+ return;
30
+ const r = w(o);
31
+ if (e === 403) {
32
+ c(s(r));
33
+ return;
34
+ }
35
+ if (e === 401 && (r == null ? void 0 : r.type) === "groupLevelAccess") {
36
+ c(s(r));
37
+ return;
38
+ }
39
+ if (e === 401 && typeof (r == null ? void 0 : r.type) == "string" && d.includes(r.type)) {
40
+ const i = typeof r.redirect == "string" ? g(r.redirect) : "";
41
+ if (i) {
42
+ window.location.replace(i);
43
+ return;
44
+ }
45
+ }
46
+ e !== 401 && e !== 419 || n.value || (window.isSessionExpired = !0, n.value = { status: e, data: r });
47
+ }, T = () => ({ authError: n });
48
+ export {
49
+ a as isPanelOrigin,
50
+ R as reportAuthError,
51
+ T as useAuthError
52
+ };
@@ -1,88 +1,98 @@
1
- import { getCsrfToken as O } from "../utils/genericUtil.js";
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 = {
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": O(),
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
- ...b
16
- }, w = (e, s) => {
17
+ ...g
18
+ }, x = (e, r) => {
17
19
  if (e.startsWith("http://") || e.startsWith("https://"))
18
20
  return e;
19
- const t = s || v.baseURL || "";
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
- }, P = (e) => new Promise((s, t) => {
23
+ }, R = (e) => new Promise((r, t) => {
22
24
  setTimeout(() => {
23
25
  t(new Error("Request timeout"));
24
26
  }, e);
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 = {
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: { ...n.headers },
32
- signal: u.value.signal,
33
- ...n
33
+ headers: { ...a.headers },
34
+ signal: c.value.signal,
35
+ ...a
34
36
  };
35
- t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
36
- const E = async (h = 0) => {
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(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;
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 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
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 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;
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 E();
73
+ return await v();
62
74
  } finally {
63
- p.value = !1, u.value = null;
75
+ f.value = !1, c.value = null;
64
76
  }
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) => {
66
- u.value && u.value.abort(e);
67
- }, W = () => {
68
- a.value = null;
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
- // State
72
- loading: g,
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: C,
78
- post: R,
79
- put: $,
80
- patch: q,
81
- delete: A,
82
- cancel: U,
83
- clearError: W
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
- X as useHttp
97
+ _ as useHttp
88
98
  };
@@ -1,26 +1,28 @@
1
1
  import { ToasterTypeOptions as T } from "../enums/toaster.js";
2
- import { useToasterStore as c } from "../stores/toaster.js";
3
- import { nextTick as u } from "vue";
2
+ import { useToasterStore as u } from "../stores/toaster.js";
3
+ import { nextTick as c } from "vue";
4
4
  const s = /* @__PURE__ */ new WeakMap(), p = () => {
5
- const e = c(), o = () => {
6
- const t = s.get(e);
7
- t && (clearTimeout(t), s.delete(e));
5
+ const t = u(), o = () => {
6
+ const e = s.get(t);
7
+ e && (clearTimeout(e), s.delete(t));
8
8
  };
9
- function r(t = { message: "" }) {
10
- o(), e.hideToaster(), u(() => {
11
- e.showToaster(t), e.shouldAutoHide && s.set(e, setTimeout(() => {
12
- e.hideToaster(), o();
9
+ function i(e = { message: "" }) {
10
+ o(), t.hideToaster(), c(() => {
11
+ t.showToaster(e), t.shouldAutoHide && s.set(t, setTimeout(() => {
12
+ t.hideToaster(), o();
13
13
  }, 6e3));
14
14
  });
15
15
  }
16
- function i() {
17
- o(), e.hideToaster();
16
+ function n() {
17
+ o(), t.hideToaster();
18
18
  }
19
- function n(t, a) {
20
- const m = t instanceof Error ? t.message : String(t);
21
- r({ type: T.Error, message: `${a}: ${m}` });
19
+ function a(e, r) {
20
+ if (e != null && e.authReported)
21
+ return;
22
+ const m = e instanceof Error ? e.message : String(e);
23
+ i({ type: T.Error, message: `${r}: ${m}` });
22
24
  }
23
- return { showToaster: r, hideToaster: i, handleError: n };
25
+ return { showToaster: i, hideToaster: n, handleError: a };
24
26
  };
25
27
  export {
26
28
  p as useToaster
@@ -1,13 +1,13 @@
1
- import { ToasterTypeOptions as a } from "../../enums/toaster.js";
1
+ import { ToasterTypeOptions as r } from "../../enums/toaster.js";
2
2
  import { base64EncodeWithSpecialChars as u } from "../../utils/base64.js";
3
3
  import { useHttp as d } from "../useHttp.js";
4
- import { useToaster as c } from "../useToaster.js";
5
- import { useTranslations as p } from "../useTranslations.js";
4
+ import { useToaster as p } from "../useToaster.js";
5
+ import { useTranslations as c } from "../useTranslations.js";
6
6
  const v = () => {
7
- const { post: i } = d(), { showToaster: e } = c(), s = p();
7
+ const { post: i } = d(), { showToaster: t } = p(), s = c();
8
8
  return { validateLiquidSyntax: async (o) => {
9
9
  try {
10
- const t = await i("/newsletter/contents/validate-syntax", [{
10
+ const e = await i("/newsletter/contents/validate-syntax", [{
11
11
  identifier: "default",
12
12
  syntax: "liquid",
13
13
  contents: {
@@ -17,21 +17,21 @@ const v = () => {
17
17
  ampHtml: null
18
18
  }
19
19
  }]);
20
- if (!Array.isArray(t.data)) {
21
- const l = t.data;
22
- return e({
23
- type: a.Warning,
20
+ if (!Array.isArray(e.data)) {
21
+ const l = e.data;
22
+ return t({
23
+ type: r.Warning,
24
24
  message: l.message ?? s("journey-builder.liquid-validation-failed")
25
25
  }), !1;
26
26
  }
27
- const [r] = t.data, n = Object.values((r == null ? void 0 : r.errors) ?? {});
28
- return n.length ? (e({
29
- type: a.Warning,
27
+ const [a] = e.data, n = Object.values((a == null ? void 0 : a.errors) ?? {});
28
+ return n.length ? (t({
29
+ type: r.Warning,
30
30
  message: n[0].replace(/^line \d+:\s*/, "")
31
31
  }), !1) : !0;
32
- } catch {
33
- return e({
34
- type: a.Error,
32
+ } catch (e) {
33
+ return e != null && e.authReported || t({
34
+ type: r.Error,
35
35
  message: s("journey-builder.liquid-validation-failed")
36
36
  }), !1;
37
37
  }