@useinsider/guido 3.19.0-beta.5355c3f → 3.19.0-beta.f02eaa1
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/README.md +21 -3
- package/dist/@types/config/schemas.js +59 -51
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +83 -87
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +53 -49
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +24 -22
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +46 -0
- package/dist/composables/useActionsApi.js +20 -24
- package/dist/composables/useCortexBlueprintBridge.js +54 -115
- package/dist/composables/useCustomInterfaceAppearance.js +46 -42
- package/dist/composables/useEmailTemplateApplier.js +50 -93
- package/dist/composables/useLegacyStrategyConversion.js +61 -0
- package/dist/enums/extensions/recommendationBlock.js +40 -31
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +77 -76
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -28
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +45 -44
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +110 -46
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +7 -7
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +46 -37
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +3 -4
- package/dist/src/composables/useEmailTemplateApplier.d.ts +2 -22
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +5 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +70 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/stores/config.d.ts +322 -0
- package/dist/src/stores/guido-email-editor.d.ts +10 -32
- package/dist/src/stores/onboarding.d.ts +808 -10
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +70 -5
- package/dist/stores/config.js +74 -60
- package/dist/stores/guido-email-editor.js +1 -3
- package/dist/stores/onboarding.js +46 -36
- package/package.json +1 -1
|
@@ -1,131 +1,70 @@
|
|
|
1
|
-
import { useEmailTemplateApplier as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import { useTranslations as
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const W = "email_template", tt = "chat", et = "guido:debug:ai", rt = 2, nt = 500, ot = (A, p) => `${A}:${p ?? 1}`;
|
|
9
|
-
let v = null;
|
|
10
|
-
const it = () => {
|
|
1
|
+
import { useEmailTemplateApplier as w, resetEmailTemplateApplier as _ } from "./useEmailTemplateApplier.js";
|
|
2
|
+
import { useToaster as I } from "./useToaster.js";
|
|
3
|
+
import { useTranslations as P } from "./useTranslations.js";
|
|
4
|
+
import { ToasterTypeOptions as S } from "../enums/toaster.js";
|
|
5
|
+
import { getActivePinia as v } from "pinia";
|
|
6
|
+
import { watch as B, onUnmounted as D } from "vue";
|
|
7
|
+
const x = "email_template", L = "chat", M = "guido:debug:ai", R = () => {
|
|
11
8
|
if (typeof window > "u")
|
|
12
9
|
return !1;
|
|
13
10
|
try {
|
|
14
|
-
return window.localStorage.getItem(
|
|
11
|
+
return window.localStorage.getItem(M) === "1";
|
|
15
12
|
} catch {
|
|
16
13
|
return !1;
|
|
17
14
|
}
|
|
18
|
-
},
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
15
|
+
}, H = () => {
|
|
16
|
+
const c = v();
|
|
17
|
+
if (!c)
|
|
21
18
|
return;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
if (
|
|
32
|
-
return;
|
|
33
|
-
const n = p.applyAcks[t], l = Math.max(Date.now(), ((n == null ? void 0 : n.ackAt) ?? 0) + 1), c = { status: e, requestedAt: o, ackAt: l };
|
|
34
|
-
r !== void 0 && (c.error = K(r)), p.$patch((a) => {
|
|
35
|
-
a.applyAcks = { ...a.applyAcks, [t]: c };
|
|
36
|
-
});
|
|
37
|
-
}, B = (t) => (d.get(t) ?? 0) > 0, w = async (t, e, o, r) => {
|
|
38
|
-
var a, i, q;
|
|
39
|
-
const n = ((a = o.blueprintData) == null ? void 0 : a.html) ?? "", l = ((i = o.blueprintData) == null ? void 0 : i.css) ?? "", c = o.applyRequestedAt ?? 0;
|
|
40
|
-
d.set(t, (d.get(t) ?? 0) + 1);
|
|
41
|
-
try {
|
|
42
|
-
const s = r === "debounced" ? await I(e, { html: n, css: l }) : await F(e, { html: n, css: l });
|
|
43
|
-
if (s.status === "superseded")
|
|
44
|
-
return;
|
|
45
|
-
if (s.status === "applied") {
|
|
46
|
-
h.set(e, n), u.delete(t), D(t, "applied", c);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const m = u.get(t);
|
|
50
|
-
u.set(t, { html: n, count: (m == null ? void 0 : m.html) === n ? m.count + 1 : 1 }), D(t, "failed", c, s.error);
|
|
51
|
-
} finally {
|
|
52
|
-
d.set(t, (d.get(t) ?? 1) - 1);
|
|
53
|
-
const s = E.get(t);
|
|
54
|
-
s && !B(t) && (E.delete(t), (((q = s.blueprintData) == null ? void 0 : q.html) ?? "") !== n && w(t, e, s, r));
|
|
55
|
-
}
|
|
56
|
-
}, U = (t) => {
|
|
57
|
-
var a;
|
|
58
|
-
if (t.blueprintType !== W)
|
|
59
|
-
return;
|
|
60
|
-
const { blueprintId: e } = t, o = (a = t.blueprintData) == null ? void 0 : a.html;
|
|
61
|
-
if (!e || !o)
|
|
19
|
+
const l = c._s, p = l == null ? void 0 : l.get(L);
|
|
20
|
+
if (!p)
|
|
21
|
+
return;
|
|
22
|
+
const { markPending: d, applyTemplate: f, applyTemplateDebounced: T } = w(), { showToaster: E } = I(), h = P(), y = (r, t) => {
|
|
23
|
+
const e = h(r);
|
|
24
|
+
return e === r ? t : e;
|
|
25
|
+
}, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), u = R(), A = (r, t) => {
|
|
26
|
+
u && console.debug(`[guido:cortex] msg=${r ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
|
|
27
|
+
}, b = (r) => {
|
|
28
|
+
if (r.blueprintType !== x)
|
|
62
29
|
return;
|
|
63
|
-
|
|
64
|
-
|
|
30
|
+
const t = r.blueprintId, e = r.blueprintData;
|
|
31
|
+
if (!t || !(e != null && e.html))
|
|
65
32
|
return;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (l === void 0 || n > l) {
|
|
69
|
-
const i = l === void 0;
|
|
70
|
-
if (S.set(r, n), u.delete(r), i && G().has(r)) {
|
|
71
|
-
h.set(e, o);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
w(r, e, t, "immediate");
|
|
33
|
+
if (!r.applyRequested) {
|
|
34
|
+
d(t);
|
|
75
35
|
return;
|
|
76
36
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Array.isArray(r) && r.forEach((n) => {
|
|
101
|
-
if (n)
|
|
102
|
-
switch (O(o, n), n.type) {
|
|
103
|
-
case "blueprint":
|
|
104
|
-
U(n);
|
|
105
|
-
break;
|
|
106
|
-
case "error":
|
|
107
|
-
g(o);
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
37
|
+
const o = i.get(t);
|
|
38
|
+
o === void 0 ? (i.set(t, e.html), f(t, e)) : o !== e.html && (i.set(t, e.html), T(t, e));
|
|
39
|
+
}, s = (r) => r === void 0 || a.has(r) ? !1 : (a.add(r), E({
|
|
40
|
+
type: S.Error,
|
|
41
|
+
message: y("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
|
|
42
|
+
}), !0), m = B(
|
|
43
|
+
() => p.messages,
|
|
44
|
+
(r) => {
|
|
45
|
+
Array.isArray(r) && r.forEach((t) => {
|
|
46
|
+
const e = t == null ? void 0 : t.id;
|
|
47
|
+
(t == null ? void 0 : t.isError) === !0 && s(e) && u && console.debug(`[guido:cortex] message-level error id=${e}`, t);
|
|
48
|
+
const o = t == null ? void 0 : t.segments;
|
|
49
|
+
Array.isArray(o) && o.forEach((n) => {
|
|
50
|
+
if (n)
|
|
51
|
+
switch (A(e, n), n.type) {
|
|
52
|
+
case "blueprint":
|
|
53
|
+
b(n);
|
|
54
|
+
break;
|
|
55
|
+
case "error":
|
|
56
|
+
s(e);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
110
60
|
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return (t = A._s) == null ? void 0 : t.get(tt);
|
|
117
|
-
}, L = (t) => {
|
|
118
|
-
f = t, b = Z(() => t.messages, Y, { deep: !0, immediate: !0 });
|
|
119
|
-
}, R = $();
|
|
120
|
-
R ? L(R) : T = setInterval(() => {
|
|
121
|
-
const t = $();
|
|
122
|
-
t && (P(), L(t));
|
|
123
|
-
}, nt), V(() => {
|
|
124
|
-
P(), b == null || b(), f = void 0, h.clear(), S.clear(), u.clear(), d.clear(), E.clear(), _.clear(), v === y && (v = null, p.$patch((t) => {
|
|
125
|
-
t.bridgeActive = !1, t.applyAcks = {};
|
|
126
|
-
}), N());
|
|
61
|
+
},
|
|
62
|
+
{ deep: !0, immediate: !0 }
|
|
63
|
+
);
|
|
64
|
+
D(() => {
|
|
65
|
+
m(), i.clear(), a.clear(), _();
|
|
127
66
|
});
|
|
128
67
|
};
|
|
129
68
|
export {
|
|
130
|
-
|
|
69
|
+
H as useCortexBlueprintBridge
|
|
131
70
|
};
|
|
@@ -1,67 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import p from "../static/
|
|
5
|
-
import s from "../static/
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import c from "../static/styles/components/
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import d from "../static/styles/components/
|
|
1
|
+
import i from "../static/assets/icons/filled-arrow-rising.svg.js";
|
|
2
|
+
import n from "../static/assets/icons/line-change.svg.js";
|
|
3
|
+
import S from "../static/assets/icons/line-delete.svg.js";
|
|
4
|
+
import p from "../static/assets/icons/line-info.svg.js";
|
|
5
|
+
import s from "../static/assets/icons/line-plus.svg.js";
|
|
6
|
+
import f from "../static/styles/base.css.js";
|
|
7
|
+
import C from "../static/styles/components/alert-message.css.js";
|
|
8
|
+
import a from "../static/styles/components/amp-block.css.js";
|
|
9
|
+
import c from "../static/styles/components/base-input.css.js";
|
|
10
|
+
import l from "../static/styles/components/button-group.css.js";
|
|
11
|
+
import u from "../static/styles/components/button.css.js";
|
|
12
|
+
import d from "../static/styles/components/combobox.css.js";
|
|
13
|
+
import I from "../static/styles/components/counter.css.js";
|
|
14
|
+
import g from "../static/styles/components/dropdown-menu.css.js";
|
|
13
15
|
import h from "../static/styles/components/loader.css.js";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
16
|
+
import w from "../static/styles/components/narrow-panel.css.js";
|
|
17
|
+
import $ from "../static/styles/components/popup.css.js";
|
|
18
|
+
import y from "../static/styles/components/recommendation-strategy.css.js";
|
|
19
|
+
import b from "../static/styles/components/switcher.css.js";
|
|
20
|
+
import B from "../static/styles/components/tabs.css.js";
|
|
21
|
+
import A from "../static/styles/components/tools.css.js";
|
|
22
|
+
import P from "../static/styles/components/version-history.css.js";
|
|
23
|
+
import R from "../static/styles/components/wide-panel.css.js";
|
|
22
24
|
import x from "../static/styles/variables.css.js";
|
|
23
|
-
function
|
|
24
|
-
return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(
|
|
25
|
+
function o(t, r) {
|
|
26
|
+
return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(r.trim())}");`;
|
|
25
27
|
}
|
|
26
|
-
const
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
-
${
|
|
30
|
-
}
|
|
28
|
+
const V = `:host {
|
|
29
|
+
${o("line-change", n)}
|
|
30
|
+
${o("line-delete", S)}
|
|
31
|
+
${o("filled-arrow-rising", i)}
|
|
32
|
+
${o("line-info", p)}
|
|
33
|
+
${o("line-plus", s)}
|
|
34
|
+
}`, D = [
|
|
31
35
|
x,
|
|
32
36
|
// Must be on top
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
V,
|
|
38
|
+
f,
|
|
35
39
|
// Must be on top
|
|
36
|
-
s,
|
|
37
40
|
C,
|
|
38
41
|
a,
|
|
39
|
-
f,
|
|
40
42
|
c,
|
|
41
|
-
u,
|
|
42
43
|
l,
|
|
44
|
+
u,
|
|
43
45
|
d,
|
|
44
|
-
h,
|
|
45
|
-
g,
|
|
46
46
|
I,
|
|
47
|
-
|
|
47
|
+
g,
|
|
48
|
+
h,
|
|
49
|
+
w,
|
|
50
|
+
$,
|
|
48
51
|
b,
|
|
49
52
|
B,
|
|
50
|
-
|
|
53
|
+
A,
|
|
51
54
|
P,
|
|
52
|
-
|
|
55
|
+
R,
|
|
56
|
+
y
|
|
53
57
|
// Last: overrides button.css / wide-panel.css defaults
|
|
54
58
|
].join(`
|
|
55
59
|
|
|
56
|
-
`),
|
|
57
|
-
const
|
|
58
|
-
|
|
60
|
+
`), ro = () => ({ importCss: () => {
|
|
61
|
+
const r = new CSSStyleSheet();
|
|
62
|
+
r.replaceSync(D);
|
|
59
63
|
const e = document.querySelector("ui-editor");
|
|
60
64
|
if (!e)
|
|
61
65
|
return;
|
|
62
66
|
const m = e.shadowRoot;
|
|
63
|
-
m && (m.adoptedStyleSheets = [
|
|
67
|
+
m && (m.adoptedStyleSheets = [r]);
|
|
64
68
|
} });
|
|
65
69
|
export {
|
|
66
|
-
|
|
70
|
+
ro as useCustomInterfaceAppearance
|
|
67
71
|
};
|
|
@@ -1,102 +1,59 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var e, t;
|
|
20
|
-
return E.isStripoInitialized && typeof ((t = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : t.updateHtmlAndCss) == "function";
|
|
21
|
-
}, P = (e) => {
|
|
22
|
-
i.value[e] === void 0 && (i.value = { ...i.value, [e]: "pending" });
|
|
23
|
-
}, m = (e, t) => {
|
|
24
|
-
i.value = { ...i.value, [e]: t };
|
|
25
|
-
}, _ = (e) => {
|
|
26
|
-
var t;
|
|
1
|
+
import { useActionsApi as C } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as h } from "./useConfig.js";
|
|
3
|
+
import { useToaster as D } from "./useToaster.js";
|
|
4
|
+
import { useTranslations as E } from "./useTranslations.js";
|
|
5
|
+
import { ToasterTypeOptions as f } from "../enums/toaster.js";
|
|
6
|
+
import { useDynamicContentStore as A } from "../stores/dynamic-content.js";
|
|
7
|
+
import { flattenDynamicContentList as w } from "../utils/genericUtil.js";
|
|
8
|
+
import { extractUsedDynamicContent as S } from "../utils/registerUsedDynamicContent.js";
|
|
9
|
+
import { ref as O } from "vue";
|
|
10
|
+
const U = 250, o = O({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
|
|
11
|
+
const { updateHtmlAndCss: r } = C(), { showToaster: m } = D(), y = E(), { template: T } = h(), d = A(), g = (e, t) => {
|
|
12
|
+
const a = y(e);
|
|
13
|
+
return a === e ? t : a;
|
|
14
|
+
}, v = (e) => {
|
|
15
|
+
o.value[e] === void 0 && (o.value = { ...o.value, [e]: "pending" });
|
|
16
|
+
}, l = (e, t, a) => {
|
|
17
|
+
var c;
|
|
18
|
+
o.value = { ...o.value, [e]: "applying" };
|
|
27
19
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
await M(() => a(t, o));
|
|
20
|
+
r(t, a).catch((n) => {
|
|
21
|
+
console.warn("Editor did not acknowledge the template apply.", n);
|
|
22
|
+
}), o.value = { ...o.value, [e]: "applied" };
|
|
23
|
+
try {
|
|
24
|
+
const n = w((c = T.value) == null ? void 0 : c.dynamicContentList), i = S(t, n);
|
|
25
|
+
i.length > 0 && d.registerDynamicContent(i);
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
u.get(e) !== t && (u.set(e, t), m({
|
|
29
|
+
type: f.Success,
|
|
30
|
+
message: g("newsletter.ai-template-applied", "Template applied to the editor")
|
|
31
|
+
}));
|
|
42
32
|
} catch (n) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, k = (e) => {
|
|
47
|
-
const t = r.get(e);
|
|
48
|
-
t && (clearTimeout(t.timer), r.delete(e), t.settle(c));
|
|
49
|
-
}, w = (e) => {
|
|
50
|
-
const t = p.get(e);
|
|
51
|
-
t && (clearTimeout(t.timer), p.delete(e), t.settle(c));
|
|
52
|
-
}, B = (e, t, o) => new Promise((s) => {
|
|
53
|
-
k(e);
|
|
54
|
-
const n = setTimeout(() => {
|
|
55
|
-
r.delete(e), m(e, "failed"), T(e, t), s({
|
|
56
|
-
status: "failed",
|
|
57
|
-
error: new Error(`Editor did not become ready within ${S}ms`)
|
|
33
|
+
o.value = { ...o.value, [e]: "failed" }, m({
|
|
34
|
+
type: f.Error,
|
|
35
|
+
message: n instanceof Error ? n.message : "Failed to apply template"
|
|
58
36
|
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return;
|
|
64
|
-
const e = [...r.entries()];
|
|
65
|
-
r.clear(), e.forEach(([, n]) => clearTimeout(n.timer));
|
|
66
|
-
const t = e.pop();
|
|
67
|
-
if (e.forEach(([n, f]) => {
|
|
68
|
-
m(n, "pending"), f.settle(c);
|
|
69
|
-
}), !t)
|
|
70
|
-
return;
|
|
71
|
-
const [o, s] = t;
|
|
72
|
-
s.settle(await g(o, s.html, s.css));
|
|
37
|
+
}
|
|
38
|
+
}, p = (e) => {
|
|
39
|
+
const t = s[e];
|
|
40
|
+
t && (clearTimeout(t), delete s[e]);
|
|
73
41
|
};
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
}, { immediate: !0 }), { applyStatus: i, markPending: P, applyTemplate: (e, t) => {
|
|
77
|
-
const { html: o } = t;
|
|
78
|
-
return o ? (w(e), C(e, o, t.css ?? "")) : Promise.resolve(h);
|
|
42
|
+
return { applyStatus: o, markPending: v, applyTemplate: (e, t) => {
|
|
43
|
+
t.html && (p(e), l(e, t.html, t.css ?? ""));
|
|
79
44
|
}, applyTemplateDebounced: (e, t) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
p.delete(e), C(e, o, s).then(n);
|
|
88
|
-
}, K);
|
|
89
|
-
p.set(e, { timer: f, settle: n });
|
|
90
|
-
});
|
|
45
|
+
if (!t.html)
|
|
46
|
+
return;
|
|
47
|
+
p(e);
|
|
48
|
+
const { html: a } = t, c = t.css ?? "";
|
|
49
|
+
s[e] = setTimeout(() => {
|
|
50
|
+
delete s[e], l(e, a, c);
|
|
51
|
+
}, U);
|
|
91
52
|
} };
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
clearTimeout(a.timer), a.settle(c);
|
|
95
|
-
}), p.clear(), r.forEach((a) => {
|
|
96
|
-
clearTimeout(a.timer), a.settle(c);
|
|
97
|
-
}), r.clear(), l.clear(), u.clear(), i.value = {};
|
|
53
|
+
}, G = () => {
|
|
54
|
+
Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((r) => delete s[r]), o.value = {};
|
|
98
55
|
};
|
|
99
56
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
57
|
+
G as resetEmailTemplateApplier,
|
|
58
|
+
z as useEmailTemplateApplier
|
|
102
59
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useRecommendation as I } from "./useRecommendation.js";
|
|
2
|
+
import { useToaster as C } from "./useToaster.js";
|
|
3
|
+
import { useTranslations as v } from "./useTranslations.js";
|
|
4
|
+
import { ToasterTypeOptions as g } from "../enums/toaster.js";
|
|
5
|
+
import "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
6
|
+
import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
7
|
+
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
8
|
+
import { resolveMigrationTarget as R, buildLegacyMigrationPayload as T } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
|
|
9
|
+
import { commitBlockChangeOutsidePanel as h } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
|
|
10
|
+
import { useConfigStore as k } from "../stores/config.js";
|
|
11
|
+
const F = () => {
|
|
12
|
+
const e = b(), r = k(), { buildCampaignUrl: m } = I(), { showToaster: i } = C(), c = v();
|
|
13
|
+
return { convertLegacyStrategy: async () => {
|
|
14
|
+
const t = e.currentRecommendationId;
|
|
15
|
+
if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
|
|
16
|
+
return "";
|
|
17
|
+
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = R({
|
|
18
|
+
campaignId: r.campaignId,
|
|
19
|
+
templateLibraryId: r.templateLibraryId
|
|
20
|
+
}), S = T({
|
|
21
|
+
blockId: t,
|
|
22
|
+
url: m(String(t)),
|
|
23
|
+
campaignId: r.campaignId,
|
|
24
|
+
variationId: r.variationId,
|
|
25
|
+
strategy: d,
|
|
26
|
+
productIds: y,
|
|
27
|
+
target: s
|
|
28
|
+
});
|
|
29
|
+
let o;
|
|
30
|
+
try {
|
|
31
|
+
o = await e.convertLegacyStrategy(S, s);
|
|
32
|
+
} catch (n) {
|
|
33
|
+
return console.error("[useLegacyStrategyConversion] migration failed", n), i({
|
|
34
|
+
type: g.Error,
|
|
35
|
+
message: c("email-editor.legacy-strategy-update-failed")
|
|
36
|
+
}), "";
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
await e.fetchStrategyProductsForBlock(t);
|
|
40
|
+
} catch (n) {
|
|
41
|
+
console.error("[useLegacyStrategyConversion] product refetch failed", n);
|
|
42
|
+
}
|
|
43
|
+
const a = e.blockStates[t];
|
|
44
|
+
return a ? h(
|
|
45
|
+
t,
|
|
46
|
+
{
|
|
47
|
+
strategyId: o,
|
|
48
|
+
size: a.recommendationConfigs.size,
|
|
49
|
+
configVersion: L
|
|
50
|
+
},
|
|
51
|
+
a.recommendationProducts,
|
|
52
|
+
"Converted legacy recommendation strategy"
|
|
53
|
+
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), i({
|
|
54
|
+
type: g.Error,
|
|
55
|
+
message: c("email-editor.legacy-strategy-update-failed")
|
|
56
|
+
}), "") : o;
|
|
57
|
+
} };
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
F as useLegacyStrategyConversion
|
|
61
|
+
};
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { useTranslations as
|
|
2
|
-
const
|
|
1
|
+
import { useTranslations as n } from "../../composables/useTranslations.js";
|
|
2
|
+
const a = {
|
|
3
3
|
RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
|
|
4
4
|
// Relative path → same-origin as the embedding inone dashboard.
|
|
5
5
|
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
|
|
6
6
|
RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
|
|
7
|
-
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
|
|
7
|
+
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies",
|
|
8
|
+
NEWSLETTER_RECOMMENDATIONS_PATH: "/newsletter/recommendations",
|
|
9
|
+
MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/migrate-strategies",
|
|
10
|
+
// The template route narrows the recommendations resource before the action: the id
|
|
11
|
+
// travels in the body, not the path.
|
|
12
|
+
TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies"
|
|
8
13
|
}, c = {
|
|
14
|
+
campaign: a.MIGRATE_STRATEGIES_PATH,
|
|
15
|
+
template: a.TEMPLATE_MIGRATE_STRATEGIES_PATH
|
|
16
|
+
}, d = {
|
|
9
17
|
CLIENT_ID: "clientId"
|
|
10
|
-
},
|
|
11
|
-
const e =
|
|
18
|
+
}, m = () => {
|
|
19
|
+
const e = n();
|
|
12
20
|
return [
|
|
13
21
|
{
|
|
14
22
|
id: 11,
|
|
@@ -71,73 +79,74 @@ const l = {
|
|
|
71
79
|
path: "top-sellers"
|
|
72
80
|
}
|
|
73
81
|
];
|
|
74
|
-
},
|
|
82
|
+
}, p = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], T = [
|
|
75
83
|
{ text: "before the amount", value: "0" },
|
|
76
84
|
{ text: "after the amount", value: "1" }
|
|
77
85
|
], v = [
|
|
78
86
|
{ text: "dot(.)", value: "." },
|
|
79
87
|
{ text: "comma(,)", value: "," },
|
|
80
88
|
{ text: "space( )", value: " " }
|
|
81
|
-
],
|
|
89
|
+
], A = [
|
|
82
90
|
{ text: "0", value: "0" },
|
|
83
91
|
{ text: "1", value: "1" },
|
|
84
92
|
{ text: "2", value: "2" },
|
|
85
93
|
{ text: "3", value: "3" },
|
|
86
94
|
{ text: "4", value: "4" },
|
|
87
95
|
{ text: "5", value: "5" }
|
|
88
|
-
],
|
|
96
|
+
], r = "||", t = [
|
|
89
97
|
{ text: "is exactly", value: "=" },
|
|
90
98
|
{ text: "contains", value: "~" },
|
|
91
99
|
{ text: "does not contain", value: "!~" },
|
|
92
|
-
{ text: "any of", value:
|
|
93
|
-
],
|
|
100
|
+
{ text: "any of", value: r }
|
|
101
|
+
], o = [
|
|
94
102
|
{ text: "is exactly", value: "=" },
|
|
95
103
|
{ text: "is not exactly", value: "!==" },
|
|
96
104
|
{ text: "contains", value: "~" },
|
|
97
105
|
{ text: "does not contain", value: "!~" },
|
|
98
|
-
{ text: "any of", value:
|
|
99
|
-
],
|
|
106
|
+
{ text: "any of", value: r }
|
|
107
|
+
], s = [
|
|
100
108
|
{ text: "is equal to", value: "=" },
|
|
101
109
|
{ text: "is greater than", value: ">" },
|
|
102
110
|
{ text: "is less than", value: "<" }
|
|
103
|
-
],
|
|
111
|
+
], i = [
|
|
104
112
|
{ text: "is equal to", value: "=" },
|
|
105
113
|
{ text: "after", value: ">" },
|
|
106
114
|
{ text: "before", value: "<" }
|
|
107
|
-
],
|
|
115
|
+
], u = [
|
|
108
116
|
{ text: "true", value: "==" },
|
|
109
117
|
{ text: "false", value: "!=" }
|
|
110
|
-
],
|
|
118
|
+
], E = (e) => {
|
|
111
119
|
if (!e)
|
|
112
120
|
return t;
|
|
113
121
|
switch (e) {
|
|
114
122
|
case "Boolean":
|
|
115
|
-
return
|
|
123
|
+
return u;
|
|
116
124
|
case "Date":
|
|
117
|
-
return
|
|
125
|
+
return i;
|
|
118
126
|
case "Number":
|
|
119
|
-
return
|
|
127
|
+
return s;
|
|
120
128
|
case "String":
|
|
121
129
|
return t;
|
|
122
130
|
case "Strings":
|
|
123
|
-
return
|
|
131
|
+
return o;
|
|
124
132
|
default:
|
|
125
133
|
return t;
|
|
126
134
|
}
|
|
127
135
|
};
|
|
128
136
|
export {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
c as MIGRATION_PATHS,
|
|
138
|
+
r as OP_ANY_OF,
|
|
139
|
+
p as PriceAttributes,
|
|
140
|
+
d as QUERY_PARAMS,
|
|
141
|
+
a as URLS,
|
|
142
|
+
A as currencyDecimalCounts,
|
|
143
|
+
T as currencyLocationMaps,
|
|
135
144
|
v as currencyOperators,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
E as getOperatorOptions,
|
|
146
|
+
m as getRecommendationFeedSourceMaps,
|
|
147
|
+
o as operatorOptionsForArrayOfStrings,
|
|
148
|
+
u as operatorOptionsForBooleans,
|
|
149
|
+
i as operatorOptionsForDates,
|
|
150
|
+
s as operatorOptionsForNumbers,
|
|
142
151
|
t as operatorOptionsForStrings
|
|
143
152
|
};
|