@useinsider/guido 3.19.0-beta.3d545d6 → 3.19.0-beta.400eb14
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 +104 -91
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +80 -76
- package/dist/components/organisms/base/AuthErrorModal.vue.js +5 -5
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +29 -16
- package/dist/composables/useAuthError.js +1 -0
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useHttp.js +34 -31
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useStripo.js +24 -20
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
- package/dist/enums/extensions/recommendationBlock.js +30 -29
- package/dist/extensions/Blocks/Recommendation/block.js +15 -14
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -29
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/composables/useAuthError.d.ts +1 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/stores/onboarding.js +4 -0
- package/package.json +2 -2
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useCortexBlueprintBridge as
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { provideGuidoActions as
|
|
5
|
-
import { useGuidoStateBridge as
|
|
6
|
-
import { usePartner as
|
|
7
|
-
import { useStripo as
|
|
8
|
-
import { useTimerClone as
|
|
9
|
-
import { migrate as
|
|
10
|
-
import { ModuleFolderDefaults as
|
|
11
|
-
import { RIBBON_SELECTOR as
|
|
12
|
-
import { useRecommendationExtensionStore as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
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/AuthErrorModal.vue.js";
|
|
15
15
|
import ve from "./organisms/base/Toaster.vue.js";
|
|
16
|
-
import
|
|
16
|
+
import be from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
|
|
17
17
|
import he from "./organisms/header/HeaderWrapper.vue.js";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { useStripoApi as
|
|
22
|
-
import { useConfigStore as
|
|
23
|
-
import { useDynamicContentStore as
|
|
24
|
-
import { useEditorStore as
|
|
18
|
+
import Ee from "./organisms/LoadingWrapper.vue.js";
|
|
19
|
+
import we from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
|
|
20
|
+
import Ce from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
|
|
21
|
+
import { useStripoApi as De } from "../services/stripoApi.js";
|
|
22
|
+
import { useConfigStore as ke } from "../stores/config.js";
|
|
23
|
+
import { useDynamicContentStore as Fe } from "../stores/dynamic-content.js";
|
|
24
|
+
import { useEditorStore as $ } from "../stores/editor.js";
|
|
25
25
|
import { usePreviewStore as Me } from "../stores/preview.js";
|
|
26
|
-
import { useTemplateStore as
|
|
27
|
-
import { useUnsubscribeStore as
|
|
28
|
-
import { readTrackFloor as
|
|
29
|
-
const
|
|
26
|
+
import { useTemplateStore as Re } from "../stores/template.js";
|
|
27
|
+
import { useUnsubscribeStore as Te } from "../stores/unsubscribe.js";
|
|
28
|
+
import { readTrackFloor as z } from "../utils/linkTrackingIds.js";
|
|
29
|
+
const rt = /* @__PURE__ */ ae({
|
|
30
30
|
__name: "Guido",
|
|
31
31
|
props: {
|
|
32
32
|
config: null,
|
|
33
33
|
ready: { type: Boolean, default: !0 }
|
|
34
34
|
},
|
|
35
35
|
emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
|
|
36
|
-
setup(
|
|
37
|
-
const
|
|
36
|
+
setup(q, { expose: K, emit: r }) {
|
|
37
|
+
const s = q, V = m(
|
|
38
38
|
() => import("./organisms/email-preview/PreviewContainer.vue.js")
|
|
39
|
-
), V = m(
|
|
40
|
-
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
41
39
|
), j = m(
|
|
42
|
-
() => import("./organisms/
|
|
40
|
+
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
43
41
|
), J = m(
|
|
44
|
-
() => import("./organisms/extensions/recommendation/
|
|
42
|
+
() => import("./organisms/extensions/recommendation/AssignStrategyDrawer.vue.js")
|
|
45
43
|
), Q = m(
|
|
44
|
+
() => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
|
|
45
|
+
), X = m(
|
|
46
46
|
() => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
|
|
47
|
-
), E =
|
|
48
|
-
|
|
49
|
-
const c =
|
|
47
|
+
), E = x(), p = x(), f = Fe(), w = Te(), o = ke();
|
|
48
|
+
s.ready && o.init(s.config);
|
|
49
|
+
const c = $(), Y = Me(), l = u(() => c.hasChanges), { isTestPartner: Z } = ue(), C = () => {
|
|
50
50
|
var t;
|
|
51
51
|
return (t = E.value) == null ? void 0 : t.handleSave(!0);
|
|
52
52
|
}, D = (t) => {
|
|
53
53
|
c.loadingStatus = t;
|
|
54
54
|
};
|
|
55
|
-
|
|
55
|
+
ce(), le();
|
|
56
56
|
const y = () => {
|
|
57
57
|
var t, e;
|
|
58
58
|
return {
|
|
@@ -60,18 +60,18 @@ const nt = /* @__PURE__ */ re({
|
|
|
60
60
|
userId: o.userId,
|
|
61
61
|
username: o.username,
|
|
62
62
|
partnerName: o.partnerName,
|
|
63
|
-
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) ||
|
|
64
|
-
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) ||
|
|
63
|
+
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || H.SAVED_MODULES,
|
|
64
|
+
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || H.DEFAULT_MODULES
|
|
65
65
|
};
|
|
66
|
-
}, { initPlugin: k, preloadRuntime:
|
|
66
|
+
}, { initPlugin: k, preloadRuntime: F } = pe(), { runExclusive: M, beginMount: R, isCurrentMount: T } = de();
|
|
67
67
|
let g = 0;
|
|
68
|
-
const { getDefaultTemplate: I } =
|
|
68
|
+
const { getDefaultTemplate: I } = De(), { cloneTimersOnSave: L, hasTimerBlocks: U } = fe(), ee = u(() => {
|
|
69
69
|
var t;
|
|
70
70
|
return !((t = o.ui) != null && t.showHeader);
|
|
71
|
-
}),
|
|
72
|
-
() => !!
|
|
71
|
+
}), te = u(() => o.isFeatureEnabled("reusableRecommendationStrategy")), oe = u(
|
|
72
|
+
() => !!h().recommendationConfigs.strategyId
|
|
73
73
|
);
|
|
74
|
-
|
|
74
|
+
me({
|
|
75
75
|
onBack: () => {
|
|
76
76
|
console.debug("guido:back"), r("back");
|
|
77
77
|
},
|
|
@@ -86,80 +86,84 @@ const nt = /* @__PURE__ */ re({
|
|
|
86
86
|
console.debug("guido:test-email:click"), r("test-email:click");
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
|
-
const
|
|
89
|
+
const A = (t) => {
|
|
90
90
|
console.debug("dynamic-content:close", t), f.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
|
|
91
|
-
},
|
|
91
|
+
}, B = () => {
|
|
92
92
|
console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
|
|
93
93
|
};
|
|
94
|
-
|
|
94
|
+
W(() => l.value, () => {
|
|
95
95
|
r("on-change", l.value);
|
|
96
96
|
});
|
|
97
|
-
const
|
|
98
|
-
const e = t, { attribute:
|
|
99
|
-
console.debug("dynamic-content:open", e.detail), r("dynamic-content:open",
|
|
97
|
+
const S = (t) => {
|
|
98
|
+
const e = t, { attribute: a, position: d } = e.detail;
|
|
99
|
+
console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", a, d);
|
|
100
100
|
};
|
|
101
101
|
let i = null;
|
|
102
|
-
const
|
|
102
|
+
const v = () => {
|
|
103
103
|
var e;
|
|
104
|
-
const t = document.querySelector(
|
|
104
|
+
const t = document.querySelector(ye);
|
|
105
105
|
(e = p.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
|
|
106
|
-
},
|
|
106
|
+
}, b = async () => {
|
|
107
107
|
var t;
|
|
108
108
|
try {
|
|
109
|
-
o.initialized || o.init(
|
|
110
|
-
const e = o.template,
|
|
109
|
+
o.initialized || o.init(s.config), c.templateId = o.templateId;
|
|
110
|
+
const e = o.template, a = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", N = (e == null ? void 0 : e.preselectedDynamicContent) || [];
|
|
111
111
|
w.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
|
|
112
|
-
const
|
|
112
|
+
const P = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, _ = o.isFeatureEnabled("linkTrackingIds"), O = {
|
|
113
|
+
partnerName: o.partnerName,
|
|
114
|
+
campaignUrls: e == null ? void 0 : e.recommendationCampaignUrls,
|
|
115
|
+
rrsEnabled: o.isFeatureEnabled("reusableRecommendationStrategy")
|
|
116
|
+
};
|
|
113
117
|
let n = {
|
|
114
|
-
html:
|
|
118
|
+
html: a && await G(a, P, O),
|
|
115
119
|
css: d
|
|
116
120
|
};
|
|
117
|
-
n.html || (n = await I(), n.html = await
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
preselectedDynamicContentList:
|
|
121
|
+
n.html || (n = await I(), n.html = await G(n.html, P, O));
|
|
122
|
+
const ne = _ ? z(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
|
|
123
|
+
U(n.html) && (n.html = await L(n.html)), _ && (c.trackIdSessionFloor = Math.max(ne, z(n.html)));
|
|
124
|
+
const re = {
|
|
125
|
+
preselectedDynamicContentList: N,
|
|
122
126
|
onReady: () => {
|
|
123
127
|
console.debug("guido:ready"), r("ready");
|
|
124
128
|
}
|
|
125
129
|
};
|
|
126
|
-
g =
|
|
130
|
+
g = R(), await k(n, y(), re), f.selectedDynamicContentList = N;
|
|
127
131
|
} catch (e) {
|
|
128
132
|
console.error("Failed to initialize Stripo editor:", e);
|
|
129
133
|
}
|
|
130
134
|
};
|
|
131
135
|
return se(async () => {
|
|
132
136
|
var e;
|
|
133
|
-
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"),
|
|
137
|
+
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), h().$reset(), $().$reset(), Re().$reset(), v();
|
|
134
138
|
const t = (e = p.value) == null ? void 0 : e.parentElement;
|
|
135
|
-
if (t && (i = new ResizeObserver(
|
|
136
|
-
await
|
|
139
|
+
if (t && (i = new ResizeObserver(v), i.observe(t)), F(), s.ready)
|
|
140
|
+
await b();
|
|
137
141
|
else {
|
|
138
|
-
const
|
|
139
|
-
d && (
|
|
142
|
+
const a = W(() => s.ready, (d) => {
|
|
143
|
+
d && (a(), b());
|
|
140
144
|
});
|
|
141
145
|
}
|
|
142
|
-
document.addEventListener("dynamic-content:open",
|
|
143
|
-
}),
|
|
144
|
-
i == null || i.disconnect(), document.removeEventListener("dynamic-content:open",
|
|
145
|
-
if (
|
|
146
|
+
document.addEventListener("dynamic-content:open", S);
|
|
147
|
+
}), ie(() => {
|
|
148
|
+
i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", S), h().disposeStrategyPageReturn(), M(async () => {
|
|
149
|
+
if (T(g))
|
|
146
150
|
try {
|
|
147
151
|
window.UIEditor.removeEditor();
|
|
148
152
|
} catch {
|
|
149
153
|
console.debug("Failed to remove Stripo editor: No editor found");
|
|
150
154
|
}
|
|
151
155
|
}), o.reset();
|
|
152
|
-
}),
|
|
156
|
+
}), K({
|
|
153
157
|
dynamicContent: {
|
|
154
|
-
insert:
|
|
155
|
-
close:
|
|
158
|
+
insert: A,
|
|
159
|
+
close: B
|
|
156
160
|
},
|
|
157
161
|
hasChanges: l,
|
|
158
162
|
saveSilent: C,
|
|
159
163
|
setLoading: D
|
|
160
|
-
}), { __sfc: !0, PreviewContainer:
|
|
164
|
+
}), { __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: M, beginMount: R, isCurrentMount: T, mountGeneration: g, getDefaultTemplate: I, cloneTimersOnSave: L, hasTimerBlocks: U, noHeader: ee, isRrsEnabled: te, hasAssignedStrategy: oe, insertDynamicContent: A, closeDynamicContent: B, handleDynamicContentOpen: S, ribbonObserver: i, updateRibbonOffset: v, startEditor: b, AutoSaveController: ge, AuthErrorModal: Se, Toaster: ve, FilterSelectionDrawer: be, HeaderWrapper: he, LoadingWrapper: Ee, SaveAsTemplateDrawer: we, UnsubscribeWrapper: Ce };
|
|
161
165
|
}
|
|
162
166
|
});
|
|
163
167
|
export {
|
|
164
|
-
|
|
168
|
+
rt as default
|
|
165
169
|
};
|
|
@@ -2,17 +2,17 @@ import e from "./AuthErrorModal.vue2.js";
|
|
|
2
2
|
/* empty css */
|
|
3
3
|
import s from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
4
|
var a = function() {
|
|
5
|
-
var
|
|
6
|
-
return
|
|
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
7
|
}, n = [], i = /* @__PURE__ */ s(
|
|
8
8
|
e,
|
|
9
9
|
a,
|
|
10
10
|
n,
|
|
11
11
|
!1,
|
|
12
12
|
null,
|
|
13
|
-
"
|
|
13
|
+
"b4d7ae51"
|
|
14
14
|
);
|
|
15
|
-
const
|
|
15
|
+
const m = i.exports;
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
m as default
|
|
18
18
|
};
|
|
@@ -1,27 +1,40 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { useAuthError as
|
|
4
|
-
import { useTranslations as
|
|
5
|
-
const _ = /* @__PURE__ */
|
|
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
6
|
__name: "AuthErrorModal",
|
|
7
|
-
setup(
|
|
8
|
-
const
|
|
9
|
-
var
|
|
10
|
-
return ((
|
|
11
|
-
}), s =
|
|
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(() => ({
|
|
12
15
|
primaryButton: {
|
|
13
16
|
type: "primary",
|
|
14
|
-
labelText:
|
|
17
|
+
labelText: r.value ? e("integration-hub.reload") : e("journey-builder.login-popup-button")
|
|
15
18
|
},
|
|
16
19
|
cancelOrBackButton: {
|
|
17
20
|
type: "secondary",
|
|
18
21
|
styling: "ghost",
|
|
19
|
-
labelText:
|
|
22
|
+
labelText: e("settings.cancel")
|
|
20
23
|
}
|
|
21
|
-
}))
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 };
|
|
25
38
|
}
|
|
26
39
|
});
|
|
27
40
|
export {
|
|
@@ -46,6 +46,7 @@ const d = ["accessExpired", "domainRestricted", "ipRestricted", "insiderAccessRe
|
|
|
46
46
|
e !== 401 && e !== 419 || n.value || (window.isSessionExpired = !0, n.value = { status: e, data: r });
|
|
47
47
|
}, T = () => ({ authError: n });
|
|
48
48
|
export {
|
|
49
|
+
a as isPanelOrigin,
|
|
49
50
|
R as reportAuthError,
|
|
50
51
|
T as useAuthError
|
|
51
52
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useConfig as E } from "./useConfig.js";
|
|
2
|
-
import { useEditorLock as
|
|
3
|
-
import { useAutosaveStore as
|
|
4
|
-
import { useEditorStore as
|
|
2
|
+
import { useEditorLock as f } from "./useEditorLock.js";
|
|
3
|
+
import { useAutosaveStore as p, AUTOSAVE_STATUS as s } from "../stores/autosave.js";
|
|
4
|
+
import { useEditorStore as A } from "../stores/editor.js";
|
|
5
5
|
import { computed as y, watch as I, onUnmounted as L } from "vue";
|
|
6
6
|
const w = 18e4, v = 6e4, R = (b) => {
|
|
7
|
-
const { isFeatureEnabled: S } = E(), o =
|
|
7
|
+
const { isFeatureEnabled: S } = E(), o = A(), t = p(), { isEditorBusy: g } = f();
|
|
8
8
|
let i = null, c = 0;
|
|
9
9
|
const u = y(
|
|
10
10
|
() => S("autosave") && t.isOn
|
|
11
11
|
), m = () => o.hasChanges && o.isInSaveableState, h = () => ({
|
|
12
12
|
hasChanges: o.hasChanges,
|
|
13
13
|
isInSaveableState: o.isInSaveableState
|
|
14
|
-
}),
|
|
14
|
+
}), l = async (e) => {
|
|
15
15
|
if (!u.value) {
|
|
16
16
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
|
|
17
17
|
return;
|
|
@@ -28,7 +28,7 @@ const w = 18e4, v = 6e4, R = (b) => {
|
|
|
28
28
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "editor-busy" });
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
|
|
31
|
+
e === "visibility" && (c = Date.now()), console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
|
|
32
32
|
try {
|
|
33
33
|
if (await b() === void 0) {
|
|
34
34
|
console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = s.ERROR;
|
|
@@ -53,22 +53,22 @@ const w = 18e4, v = 6e4, R = (b) => {
|
|
|
53
53
|
});
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
l("visibility");
|
|
57
57
|
}, d = () => {
|
|
58
58
|
i && (clearInterval(i), i = null);
|
|
59
|
-
},
|
|
59
|
+
}, r = () => {
|
|
60
60
|
document.removeEventListener("visibilitychange", n), window.removeEventListener("pagehide", n);
|
|
61
61
|
};
|
|
62
62
|
I(
|
|
63
63
|
u,
|
|
64
64
|
(e) => {
|
|
65
65
|
console.debug("guido:autosave:active-changed", { active: e }), e ? (d(), i = setInterval(() => {
|
|
66
|
-
console.debug("guido:autosave:interval-tick"),
|
|
67
|
-
}, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(),
|
|
66
|
+
console.debug("guido:autosave:interval-tick"), l("interval");
|
|
67
|
+
}, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(), r(), t.status = s.IDLE);
|
|
68
68
|
},
|
|
69
69
|
{ immediate: !0 }
|
|
70
70
|
), L(() => {
|
|
71
|
-
d(),
|
|
71
|
+
d(), r(), t.status = s.IDLE, t.lastSavedAt = null;
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
74
|
export {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { getCsrfToken as
|
|
2
|
-
import { ref as
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
5
|
-
const
|
|
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 = {
|
|
6
6
|
baseURL: "",
|
|
7
7
|
timeout: 1e4,
|
|
8
8
|
retry: 0,
|
|
9
9
|
retryDelay: 1e3,
|
|
10
10
|
headers: {
|
|
11
11
|
"Content-Type": "application/json",
|
|
12
|
-
"X-CSRF-TOKEN":
|
|
12
|
+
"X-CSRF-TOKEN": D(),
|
|
13
13
|
Accept: "application/json",
|
|
14
14
|
// Without this a guest fetch gets a 302 to the login page, never an auth status.
|
|
15
15
|
"X-Requested-With": "XMLHttpRequest"
|
|
@@ -18,58 +18,61 @@ const X = [401, 403, 419], N = (g = {}) => {
|
|
|
18
18
|
}, x = (e, r) => {
|
|
19
19
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
20
20
|
return e;
|
|
21
|
-
const t = r ||
|
|
21
|
+
const t = r || E.baseURL || "";
|
|
22
22
|
return t.endsWith("/") && e.startsWith("/") ? `${t}${e.slice(1)}` : t.endsWith("/") || e.startsWith("/") ? `${t}${e}` : `${t}/${e}`;
|
|
23
|
-
},
|
|
23
|
+
}, R = (e) => new Promise((r, t) => {
|
|
24
24
|
setTimeout(() => {
|
|
25
25
|
t(new Error("Request timeout"));
|
|
26
26
|
}, e);
|
|
27
|
-
}),
|
|
27
|
+
}), P = (e) => new Promise((r) => {
|
|
28
28
|
setTimeout(r, e);
|
|
29
29
|
}), i = async (e, r, t, W = {}) => {
|
|
30
|
-
n.value = null,
|
|
31
|
-
const a = { ...
|
|
30
|
+
n.value = null, f.value = !0, c.value = new AbortController();
|
|
31
|
+
const a = { ...E, ...W }, p = x(r, a.baseURL), d = {
|
|
32
32
|
method: e,
|
|
33
33
|
headers: { ...a.headers },
|
|
34
34
|
signal: c.value.signal,
|
|
35
35
|
...a
|
|
36
36
|
};
|
|
37
|
-
t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete
|
|
38
|
-
const v = async (
|
|
39
|
-
if (window.isSessionExpired)
|
|
40
|
-
|
|
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
|
+
}
|
|
41
44
|
try {
|
|
42
|
-
const o = [fetch(
|
|
43
|
-
a.timeout && o.push(
|
|
45
|
+
const o = [fetch(p, d)];
|
|
46
|
+
a.timeout && o.push(R(a.timeout));
|
|
44
47
|
const s = await Promise.race(o);
|
|
45
48
|
if (!s.ok) {
|
|
46
|
-
const H = `HTTP Error: ${s.status} ${s.statusText}`,
|
|
47
|
-
throw
|
|
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(
|
|
48
51
|
s.status,
|
|
49
|
-
|
|
50
|
-
new URL(
|
|
52
|
+
O,
|
|
53
|
+
new URL(p, window.location.href).href
|
|
51
54
|
)).catch(() => {
|
|
52
|
-
}),
|
|
55
|
+
}), l;
|
|
53
56
|
}
|
|
54
|
-
let
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
data:
|
|
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,
|
|
58
61
|
status: s.status,
|
|
59
62
|
statusText: s.statusText,
|
|
60
63
|
headers: s.headers
|
|
61
64
|
};
|
|
62
65
|
} catch (o) {
|
|
63
66
|
const s = o instanceof Error && o.name === "AbortError";
|
|
64
|
-
if (
|
|
65
|
-
return await
|
|
67
|
+
if (m < (a.retry || 0) && !s)
|
|
68
|
+
return await P(a.retryDelay || 1e3), v(m + 1);
|
|
66
69
|
throw o instanceof Error ? o.name === "AbortError" ? n.value = { message: "Request was cancelled" } : n.value = { message: o.message } : n.value = o, o;
|
|
67
70
|
}
|
|
68
71
|
};
|
|
69
72
|
try {
|
|
70
73
|
return await v();
|
|
71
74
|
} finally {
|
|
72
|
-
|
|
75
|
+
f.value = !1, c.value = null;
|
|
73
76
|
}
|
|
74
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) => {
|
|
75
78
|
c.value && c.value.abort(e);
|
|
@@ -78,7 +81,7 @@ const X = [401, 403, 419], N = (g = {}) => {
|
|
|
78
81
|
};
|
|
79
82
|
return {
|
|
80
83
|
loading: b,
|
|
81
|
-
error:
|
|
84
|
+
error: w(() => n.value),
|
|
82
85
|
hasError: y,
|
|
83
86
|
request: i,
|
|
84
87
|
get: A,
|
|
@@ -91,5 +94,5 @@ const X = [401, 403, 419], N = (g = {}) => {
|
|
|
91
94
|
};
|
|
92
95
|
};
|
|
93
96
|
export {
|
|
94
|
-
|
|
97
|
+
_ as useHttp
|
|
95
98
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { useToaster as
|
|
1
|
+
import { useRecommendation as C } from "./useRecommendation.js";
|
|
2
|
+
import { useToaster as I } from "./useToaster.js";
|
|
3
3
|
import { useTranslations as v } from "./useTranslations.js";
|
|
4
4
|
import { ToasterTypeOptions as g } from "../enums/toaster.js";
|
|
5
5
|
import "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
6
6
|
import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
7
7
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
8
|
-
import { resolveMigrationTarget as
|
|
9
|
-
import { commitBlockChangeOutsidePanel as
|
|
10
|
-
import { useConfigStore as
|
|
8
|
+
import { resolveMigrationTarget as k, buildLegacyMigrationPayload as R } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
|
|
9
|
+
import { commitBlockChangeOutsidePanel as T } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
|
|
10
|
+
import { useConfigStore as h } from "../stores/config.js";
|
|
11
11
|
const F = () => {
|
|
12
|
-
const e = b(), r =
|
|
12
|
+
const e = b(), r = h(), { buildCampaignUrl: m } = C(), { showToaster: c } = I(), a = v();
|
|
13
13
|
return { convertLegacyStrategy: async () => {
|
|
14
14
|
const t = e.currentRecommendationId;
|
|
15
15
|
if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
|
|
16
16
|
return "";
|
|
17
|
-
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s =
|
|
17
|
+
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = k({
|
|
18
18
|
campaignId: r.campaignId,
|
|
19
19
|
templateLibraryId: r.templateLibraryId
|
|
20
|
-
}), S =
|
|
20
|
+
}), S = R({
|
|
21
21
|
blockId: t,
|
|
22
22
|
url: m(String(t)),
|
|
23
23
|
campaignId: r.campaignId,
|
|
@@ -29,30 +29,34 @@ const F = () => {
|
|
|
29
29
|
let o;
|
|
30
30
|
try {
|
|
31
31
|
o = await e.convertLegacyStrategy(S, s);
|
|
32
|
-
} catch (
|
|
33
|
-
return console.error("[useLegacyStrategyConversion] migration failed",
|
|
32
|
+
} catch (i) {
|
|
33
|
+
return console.error("[useLegacyStrategyConversion] migration failed", i), c({
|
|
34
34
|
type: g.Error,
|
|
35
|
-
message:
|
|
35
|
+
message: a("email-editor.legacy-strategy-migration-failed"),
|
|
36
|
+
actionButton: {
|
|
37
|
+
text: a("ds-steps.create-recommendation-strategy"),
|
|
38
|
+
onClick: () => e.openStrategyCreation()
|
|
39
|
+
}
|
|
36
40
|
}), "";
|
|
37
41
|
}
|
|
38
42
|
try {
|
|
39
43
|
await e.fetchStrategyProductsForBlock(t);
|
|
40
|
-
} catch (
|
|
41
|
-
console.error("[useLegacyStrategyConversion] product refetch failed",
|
|
44
|
+
} catch (i) {
|
|
45
|
+
console.error("[useLegacyStrategyConversion] product refetch failed", i);
|
|
42
46
|
}
|
|
43
|
-
const
|
|
44
|
-
return
|
|
47
|
+
const n = e.blockStates[t];
|
|
48
|
+
return n ? T(
|
|
45
49
|
t,
|
|
46
50
|
{
|
|
47
51
|
strategyId: o,
|
|
48
|
-
size:
|
|
52
|
+
size: n.recommendationConfigs.size,
|
|
49
53
|
configVersion: L
|
|
50
54
|
},
|
|
51
|
-
|
|
55
|
+
n.recommendationProducts,
|
|
52
56
|
"Converted legacy recommendation strategy"
|
|
53
|
-
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f),
|
|
57
|
+
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), c({
|
|
54
58
|
type: g.Error,
|
|
55
|
-
message:
|
|
59
|
+
message: a("email-editor.legacy-strategy-update-failed")
|
|
56
60
|
}), "") : o;
|
|
57
61
|
} };
|
|
58
62
|
};
|