@useinsider/guido 3.20.1 → 3.21.0-beta.1bd7edd
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 +1 -0
- package/dist/@types/config/schemas.js +41 -39
- package/dist/@types/display-condition.js +25 -0
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +86 -83
- package/dist/components/organisms/AutoSaveController.vue2.js +10 -9
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +53 -51
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +23 -22
- package/dist/composables/useAutoSave.js +46 -44
- package/dist/composables/useBlocksConfig.js +32 -24
- package/dist/composables/useDisplayConditions.js +102 -0
- package/dist/composables/useLegacyStrategyConversion.js +16 -16
- package/dist/composables/useSave.js +26 -23
- package/dist/composables/useSaveValidation.js +113 -114
- package/dist/composables/useSaveValidationRollout.js +17 -6
- package/dist/composables/useStripo.js +4 -3
- package/dist/enums/academy.js +1 -0
- package/dist/enums/display-condition.js +12 -0
- package/dist/extensions/Blocks/Items/block.js +43 -42
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +296 -223
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +221 -203
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +19 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +51 -36
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +31 -35
- package/dist/extensions/Blocks/Unsubscribe/block.js +70 -75
- package/dist/extensions/DisplayConditions/bridge.js +17 -0
- package/dist/extensions/DisplayConditions/constants.js +17 -0
- package/dist/extensions/DisplayConditions/control.js +178 -0
- package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
- package/dist/extensions/DisplayConditions/extension.js +28 -0
- package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
- package/dist/extensions/DisplayConditions/library.js +27 -0
- package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +272 -192
- package/dist/node_modules/valibot/dist/index.js +297 -261
- package/dist/package.json.js +1 -1
- package/dist/services/displayConditionApi.js +39 -0
- package/dist/services/settingsApi.js +11 -0
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/display-condition.d.ts +59 -0
- package/dist/src/components/Guido.vue.d.ts +1 -1
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/src/composables/useAutoSave.d.ts +4 -1
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useDisplayConditions.d.ts +16 -0
- package/dist/src/composables/useSaveValidationRollout.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/display-condition.d.ts +15 -0
- package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
- package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +18 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +9 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +17 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +7 -0
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +1 -6
- package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +6 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +23 -0
- package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
- package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
- package/dist/src/mock/api/display-conditions.d.ts +2 -0
- package/dist/src/services/displayConditionApi.d.ts +8 -0
- package/dist/src/services/settingsApi.d.ts +6 -0
- package/dist/src/stores/config.d.ts +166 -0
- package/dist/src/stores/display-condition.d.ts +81 -0
- package/dist/src/stores/setup-settings.d.ts +4 -0
- package/dist/src/utils/displayCondition.d.ts +10 -0
- package/dist/src/utils/protectTableText.d.ts +2 -0
- package/dist/static/styles/components/button.css.js +5 -0
- package/dist/stores/config.js +13 -6
- package/dist/stores/display-condition.js +28 -0
- package/dist/stores/setup-settings.js +10 -0
- package/dist/utils/displayCondition.js +26 -0
- package/dist/utils/pairProductVariables.js +15 -14
- package/dist/utils/protectTableText.js +22 -0
- package/package.json +4 -4
|
@@ -1,76 +1,78 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useEditorLock as
|
|
3
|
-
import { useAutosaveStore as
|
|
4
|
-
import { useEditorStore as
|
|
5
|
-
import { computed as
|
|
6
|
-
const
|
|
7
|
-
const { isFeatureEnabled:
|
|
8
|
-
let
|
|
9
|
-
const
|
|
10
|
-
() =>
|
|
11
|
-
),
|
|
12
|
-
hasChanges:
|
|
13
|
-
isInSaveableState:
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { useConfig as p } from "./useConfig.js";
|
|
2
|
+
import { useEditorLock as y } from "./useEditorLock.js";
|
|
3
|
+
import { useAutosaveStore as I, AUTOSAVE_STATUS as a } from "../stores/autosave.js";
|
|
4
|
+
import { useEditorStore as L } from "../stores/editor.js";
|
|
5
|
+
import { computed as w, watch as V, onUnmounted as k } from "vue";
|
|
6
|
+
const D = 18e4, b = 6e4, _ = (g, { clearsChanges: h = () => !0 } = {}) => {
|
|
7
|
+
const { isFeatureEnabled: m } = p(), s = L(), t = I(), { isEditorBusy: f } = y();
|
|
8
|
+
let o = null, l = 0, u = -1;
|
|
9
|
+
const d = w(
|
|
10
|
+
() => m("autosave") && t.isOn
|
|
11
|
+
), A = () => s.hasChanges && s.isInSaveableState && s.changeSeq !== u, E = () => ({
|
|
12
|
+
hasChanges: s.hasChanges,
|
|
13
|
+
isInSaveableState: s.isInSaveableState,
|
|
14
|
+
isUnchangedSinceLastSave: s.changeSeq === u
|
|
15
|
+
}), r = async (e) => {
|
|
16
|
+
if (!d.value) {
|
|
16
17
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
if (!
|
|
20
|
-
console.debug("guido:autosave:skipped", { trigger: e, reason: "gates-blocked", gates:
|
|
20
|
+
if (!A()) {
|
|
21
|
+
console.debug("guido:autosave:skipped", { trigger: e, reason: "gates-blocked", gates: E() });
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
|
-
if (t.status ===
|
|
24
|
+
if (t.status === a.SAVING) {
|
|
24
25
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "already-saving" });
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
if (
|
|
28
|
+
if (f()) {
|
|
28
29
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "editor-busy" });
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
e === "visibility" && (
|
|
32
|
+
e === "visibility" && (l = Date.now()), console.debug("guido:autosave:save-start", { trigger: e }), t.status = a.SAVING;
|
|
33
|
+
const n = s.changeSeq;
|
|
32
34
|
try {
|
|
33
|
-
if (await
|
|
34
|
-
console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status =
|
|
35
|
+
if (await g() === void 0) {
|
|
36
|
+
console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = a.ERROR;
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
} catch (
|
|
39
|
-
console.debug("guido:autosave:error", { trigger: e, error:
|
|
39
|
+
u = n, h() && (s.hasChanges = !1), t.status = a.SAVED, t.lastSavedAt = /* @__PURE__ */ new Date(), console.debug("guido:autosave:save-complete", { trigger: e, at: t.lastSavedAt });
|
|
40
|
+
} catch (S) {
|
|
41
|
+
console.debug("guido:autosave:error", { trigger: e, error: S }), t.status = a.ERROR;
|
|
40
42
|
}
|
|
41
|
-
},
|
|
43
|
+
}, i = () => {
|
|
42
44
|
const { visibilityState: e } = document;
|
|
43
45
|
if (console.debug("guido:autosave:visibility-change", {
|
|
44
46
|
visibilityState: e,
|
|
45
|
-
isActive:
|
|
47
|
+
isActive: d.value
|
|
46
48
|
}), e !== "hidden")
|
|
47
49
|
return;
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
+
const n = Date.now() - l;
|
|
51
|
+
if (n < b) {
|
|
50
52
|
console.debug("guido:autosave:visibility-debounced", {
|
|
51
|
-
sinceLastMs:
|
|
52
|
-
debounceMs:
|
|
53
|
+
sinceLastMs: n,
|
|
54
|
+
debounceMs: b
|
|
53
55
|
});
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
document.removeEventListener("visibilitychange",
|
|
58
|
+
r("visibility");
|
|
59
|
+
}, c = () => {
|
|
60
|
+
o && (clearInterval(o), o = null);
|
|
61
|
+
}, v = () => {
|
|
62
|
+
document.removeEventListener("visibilitychange", i), window.removeEventListener("pagehide", i);
|
|
61
63
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
V(
|
|
65
|
+
d,
|
|
64
66
|
(e) => {
|
|
65
|
-
console.debug("guido:autosave:active-changed", { active: e }), e ? (
|
|
66
|
-
console.debug("guido:autosave:interval-tick"),
|
|
67
|
-
},
|
|
67
|
+
console.debug("guido:autosave:active-changed", { active: e }), e ? (c(), o = setInterval(() => {
|
|
68
|
+
console.debug("guido:autosave:interval-tick"), r("interval");
|
|
69
|
+
}, D), document.addEventListener("visibilitychange", i), window.addEventListener("pagehide", i)) : (c(), v(), t.status = a.IDLE);
|
|
68
70
|
},
|
|
69
71
|
{ immediate: !0 }
|
|
70
|
-
),
|
|
71
|
-
|
|
72
|
+
), k(() => {
|
|
73
|
+
c(), v(), t.status = a.IDLE, t.lastSavedAt = null;
|
|
72
74
|
});
|
|
73
75
|
};
|
|
74
76
|
export {
|
|
75
|
-
|
|
77
|
+
_ as useAutoSave
|
|
76
78
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useConfigStore as
|
|
3
|
-
const
|
|
1
|
+
import l from "../extensions/ModulesTabIcons/extension.js";
|
|
2
|
+
import { useConfigStore as c } from "../stores/config.js";
|
|
3
|
+
const s = {
|
|
4
4
|
"amp-accordion": "ampAccordionEnabled",
|
|
5
5
|
"amp-carousel": "ampCarouselEnabled",
|
|
6
6
|
"amp-form-controls": "ampFormControlsEnabled",
|
|
@@ -14,7 +14,7 @@ const a = {
|
|
|
14
14
|
"text-block": "textEnabled",
|
|
15
15
|
"timer-block": "timerEnabled",
|
|
16
16
|
"video-block": "videoEnabled"
|
|
17
|
-
},
|
|
17
|
+
}, i = {
|
|
18
18
|
"dynamic-content": () => import("../extensions/DynamicContent/extension.js"),
|
|
19
19
|
"checkbox-block": () => import("../extensions/Blocks/Checkbox/extension.js"),
|
|
20
20
|
"radio-button-block": () => import("../extensions/Blocks/RadioButton/extension.js"),
|
|
@@ -22,40 +22,48 @@ const a = {
|
|
|
22
22
|
"unsubscribe-block": () => import("../extensions/Blocks/Unsubscribe/extension.js"),
|
|
23
23
|
"coupon-block": () => import("../extensions/Blocks/CouponBlock/extension.js"),
|
|
24
24
|
"items-block": () => import("../extensions/Blocks/Items/extension.js")
|
|
25
|
-
},
|
|
26
|
-
if (!
|
|
25
|
+
}, b = (o) => {
|
|
26
|
+
if (!o || !o.length)
|
|
27
27
|
return {};
|
|
28
28
|
const t = {};
|
|
29
|
-
return
|
|
30
|
-
const e =
|
|
29
|
+
return o.forEach((n) => {
|
|
30
|
+
const e = s[n];
|
|
31
31
|
e && (t[e] = !1);
|
|
32
32
|
}), t;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
}, m = async (o) => {
|
|
34
|
+
if (!o)
|
|
35
|
+
return [l];
|
|
36
|
+
const t = await import("../extensions/DisplayConditions/extension.js");
|
|
37
|
+
return [l, t.default];
|
|
38
|
+
}, d = async (o, t = !1) => {
|
|
39
|
+
const n = await m(t);
|
|
40
|
+
if (!o || !o.length)
|
|
41
|
+
return n;
|
|
42
|
+
const e = await Promise.all(
|
|
43
|
+
o.map(async (r) => {
|
|
44
|
+
const a = i[r];
|
|
45
|
+
return a ? (await a()).default : null;
|
|
41
46
|
})
|
|
42
47
|
);
|
|
43
48
|
return [
|
|
44
|
-
...
|
|
45
|
-
...
|
|
49
|
+
...n,
|
|
50
|
+
...e.filter((r) => r !== null)
|
|
46
51
|
];
|
|
47
|
-
},
|
|
48
|
-
const
|
|
52
|
+
}, k = () => {
|
|
53
|
+
const o = c();
|
|
49
54
|
return {
|
|
50
55
|
getStripoBlocksConfig: async () => {
|
|
51
|
-
const
|
|
56
|
+
const n = o.blocks;
|
|
52
57
|
return {
|
|
53
|
-
baseBlocks:
|
|
54
|
-
extensions: await
|
|
58
|
+
baseBlocks: b(n == null ? void 0 : n.excludeDefaults),
|
|
59
|
+
extensions: await d(
|
|
60
|
+
n == null ? void 0 : n.includeCustoms,
|
|
61
|
+
o.externalDisplayConditions
|
|
62
|
+
)
|
|
55
63
|
};
|
|
56
64
|
}
|
|
57
65
|
};
|
|
58
66
|
};
|
|
59
67
|
export {
|
|
60
|
-
|
|
68
|
+
k as useBlocksConfig
|
|
61
69
|
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useToaster as T } from "./useToaster.js";
|
|
2
|
+
import { useTranslations as x } from "./useTranslations.js";
|
|
3
|
+
import { DISPLAY_CONDITION_LIMITS as s, DisplayConditionEvent as S } from "../enums/display-condition.js";
|
|
4
|
+
import { ToasterTypeOptions as d } from "../enums/toaster.js";
|
|
5
|
+
import { useDisplayConditionApi as M } from "../services/displayConditionApi.js";
|
|
6
|
+
import { useConfigStore as N } from "../stores/config.js";
|
|
7
|
+
import { useDisplayConditionStore as _ } from "../stores/display-condition.js";
|
|
8
|
+
import { findInvalidCodeFields as O, nextConditionId as L } from "../utils/displayCondition.js";
|
|
9
|
+
import { escapeHtml as B } from "../utils/htmlEscape.js";
|
|
10
|
+
import { computed as P } from "vue";
|
|
11
|
+
const i = "email-editor.display-conditions", X = 409, y = (n, p, r) => ({
|
|
12
|
+
id: L(),
|
|
13
|
+
name: n.name.trim(),
|
|
14
|
+
description: n.description.trim(),
|
|
15
|
+
beforeScript: n.codeBefore,
|
|
16
|
+
afterScript: n.codeAfter,
|
|
17
|
+
extraData: JSON.stringify(r === void 0 ? { source: p } : { source: p, savedId: r })
|
|
18
|
+
}), C = (n) => ({
|
|
19
|
+
name: n.name,
|
|
20
|
+
description: n.description,
|
|
21
|
+
codeBefore: n.codeBefore,
|
|
22
|
+
codeAfter: n.codeAfter
|
|
23
|
+
}), U = () => {
|
|
24
|
+
const n = _(), p = N(), r = M(), o = x(), { showToaster: a } = T(), u = P(() => {
|
|
25
|
+
var e;
|
|
26
|
+
return (e = p.features) != null && e.liquidSyntax ? "liquid" : "pongo";
|
|
27
|
+
}), f = (e) => {
|
|
28
|
+
const t = { condition: e };
|
|
29
|
+
document.dispatchEvent(new CustomEvent(S.APPLY, { detail: t })), n.close();
|
|
30
|
+
}, E = () => {
|
|
31
|
+
n.view !== "none" && (document.dispatchEvent(new CustomEvent(S.CANCEL)), n.close());
|
|
32
|
+
}, $ = (e) => {
|
|
33
|
+
if (e.mode === "select") {
|
|
34
|
+
n.openSelect();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
n.openCreate(e.mode === "edit" ? e.current : null);
|
|
38
|
+
}, g = async () => {
|
|
39
|
+
n.listStatus = "loading";
|
|
40
|
+
try {
|
|
41
|
+
n.list = await r.list(u.value), n.listStatus = "loaded";
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.warn("Display conditions could not be loaded.", e), n.listStatus = "error";
|
|
44
|
+
}
|
|
45
|
+
}, h = (e) => {
|
|
46
|
+
const t = {}, m = e.name.trim();
|
|
47
|
+
m ? m.length < s.NAME_MIN ? t.name = o(`${i}.error-name-min`, { min: s.NAME_MIN }) : m.length > s.NAME_MAX && (t.name = o(`${i}.error-name-max`, { max: s.NAME_MAX })) : t.name = o(`${i}.error-name-required`);
|
|
48
|
+
const { DESCRIPTION_MAX: A } = s;
|
|
49
|
+
e.description.trim().length > A && (t.description = o(`${i}.error-description-max`, { max: A }));
|
|
50
|
+
const D = O(e.codeBefore, e.codeAfter);
|
|
51
|
+
return ["codeBefore", "codeAfter"].forEach((c) => {
|
|
52
|
+
e[c].trim() ? D.includes(c) ? t[c] = o(`${i}.error-code-invalid`) : e[c].length > s.CODE_MAX && (t[c] = o(`${i}.error-code-max`, { max: s.CODE_MAX })) : t[c] = o(`${i}.error-code-required`);
|
|
53
|
+
}), t;
|
|
54
|
+
}, I = () => {
|
|
55
|
+
a({ type: d.Error, message: o(`${i}.validation-failed`) });
|
|
56
|
+
}, l = (e) => ({ name: B(e) }), v = (e, t) => {
|
|
57
|
+
e != null && e.authReported || (console.warn(t, e), a({ type: d.Error, message: t }));
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
syntax: u,
|
|
61
|
+
handleOpen: $,
|
|
62
|
+
cancel: E,
|
|
63
|
+
loadList: g,
|
|
64
|
+
validate: h,
|
|
65
|
+
notifyInvalid: I,
|
|
66
|
+
createInline: (e) => {
|
|
67
|
+
f(y(e, "inline")), a({
|
|
68
|
+
type: d.Success,
|
|
69
|
+
message: o(`${i}.created`, l(e.name.trim()))
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
createAndSave: async (e) => {
|
|
73
|
+
try {
|
|
74
|
+
const t = await r.create(e, u.value);
|
|
75
|
+
return n.list = [t, ...n.list.filter((m) => m.id !== t.id)], f(y(C(t), "saved", t.id)), a({
|
|
76
|
+
type: d.Success,
|
|
77
|
+
message: o(`${i}.created-and-saved`, l(t.name))
|
|
78
|
+
}), {};
|
|
79
|
+
} catch (t) {
|
|
80
|
+
return (t == null ? void 0 : t.status) === X ? { name: o(`${i}.error-name-exists`) } : (v(t, o(`${i}.save-failed`, l(e.name.trim()))), null);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
select: (e) => {
|
|
84
|
+
f(y(C(e), "saved", e.id)), a({ type: d.Success, message: o(`${i}.applied`, l(e.name)) });
|
|
85
|
+
},
|
|
86
|
+
deleteSaved: async (e) => {
|
|
87
|
+
try {
|
|
88
|
+
await r.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), a({
|
|
89
|
+
type: d.Success,
|
|
90
|
+
message: o(`${i}.deleted`, l(e.name))
|
|
91
|
+
});
|
|
92
|
+
} catch (t) {
|
|
93
|
+
v(t, o(`${i}.delete-failed`));
|
|
94
|
+
} finally {
|
|
95
|
+
n.pendingDelete = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
U as useDisplayConditions
|
|
102
|
+
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
1
|
+
import { useRecommendation as S } from "./useRecommendation.js";
|
|
2
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
|
-
import { useRecommendationExtensionStore as
|
|
8
|
-
import { resolveMigrationTarget as
|
|
7
|
+
import { useRecommendationExtensionStore as R } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
8
|
+
import { resolveMigrationTarget as b, buildLegacyMigrationPayload as k } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
|
|
9
9
|
import { commitBlockChangeOutsidePanel as T } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
|
|
10
10
|
import { useConfigStore as h } from "../stores/config.js";
|
|
11
11
|
const F = () => {
|
|
12
|
-
const e =
|
|
12
|
+
const e = R(), o = h(), { buildCampaignUrl: m } = S(), { 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 =
|
|
18
|
-
campaignId:
|
|
19
|
-
templateLibraryId:
|
|
20
|
-
}),
|
|
17
|
+
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = b({
|
|
18
|
+
campaignId: o.campaignId,
|
|
19
|
+
templateLibraryId: o.templateLibraryId
|
|
20
|
+
}), C = k({
|
|
21
21
|
blockId: t,
|
|
22
22
|
url: m(String(t)),
|
|
23
|
-
campaignId:
|
|
24
|
-
variationId:
|
|
23
|
+
campaignId: o.campaignId,
|
|
24
|
+
variationId: o.variationId,
|
|
25
25
|
strategy: d,
|
|
26
26
|
productIds: y,
|
|
27
27
|
target: s
|
|
28
28
|
});
|
|
29
|
-
let
|
|
29
|
+
let r;
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
r = await e.convertLegacyStrategy(C, s);
|
|
32
32
|
} catch (i) {
|
|
33
33
|
return console.error("[useLegacyStrategyConversion] migration failed", i), c({
|
|
34
34
|
type: g.Error,
|
|
@@ -40,7 +40,7 @@ const F = () => {
|
|
|
40
40
|
}), "";
|
|
41
41
|
}
|
|
42
42
|
try {
|
|
43
|
-
await e.
|
|
43
|
+
await e.fetchRecommendationProductsForBlock(t);
|
|
44
44
|
} catch (i) {
|
|
45
45
|
console.error("[useLegacyStrategyConversion] product refetch failed", i);
|
|
46
46
|
}
|
|
@@ -48,16 +48,16 @@ const F = () => {
|
|
|
48
48
|
return n ? T(
|
|
49
49
|
t,
|
|
50
50
|
{
|
|
51
|
-
strategyId:
|
|
51
|
+
strategyId: r,
|
|
52
52
|
size: n.recommendationConfigs.size,
|
|
53
53
|
configVersion: L
|
|
54
54
|
},
|
|
55
55
|
n.recommendationProducts,
|
|
56
56
|
"Converted legacy recommendation strategy"
|
|
57
|
-
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(),
|
|
57
|
+
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), r) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), c({
|
|
58
58
|
type: g.Error,
|
|
59
59
|
message: a("email-editor.legacy-strategy-update-failed")
|
|
60
|
-
}), "") :
|
|
60
|
+
}), "") : r;
|
|
61
61
|
} };
|
|
62
62
|
};
|
|
63
63
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
1
|
+
import { useActionsApi as R } from "./useActionsApi.js";
|
|
2
2
|
import { useConfig as q } from "./useConfig.js";
|
|
3
3
|
import { useEditorLock as O } from "./useEditorLock.js";
|
|
4
4
|
import { useSaveStart as D, useSaveComplete as F } from "./useGuidoActions.js";
|
|
@@ -19,37 +19,37 @@ import { useLiquidValidator as et } from "./validators/useLiquidValidator.js";
|
|
|
19
19
|
import { useSyncModuleBlockValidator as ot } from "./validators/useSyncModuleBlockValidator.js";
|
|
20
20
|
import { useUnsubscribeBlockValidator as st } from "./validators/useUnsubscribeBlockValidator.js";
|
|
21
21
|
const Bt = () => {
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
22
|
+
const a = D(), p = F(), { validateHtml: v } = _(), { validateLiquidSyntax: S } = et(), { validateCouponBlockTags: y } = tt(), { validateUnsubscribeBlockUniqueness: w, validateUnsubscribeBlockHasTemplate: E } = st(), { validateSyncModuleBlocks: n } = ot(), { callbacks: r, isFeatureEnabled: d } = q(), { extractSyncModuleData: b } = G(), { setSyncModuleUnsubscriptionPages: g } = J(), { editorSave: H, getTemplateData: V } = R(), { showToaster: x } = $(), { getBlockedDomains: k, resolveToast: C } = Z(), { prepareTemplateDetails: m } = X(), { collectSaveValidationErrors: B } = j(), { isEnabled: h } = z(), T = Q(), P = N(), f = K(), { runExclusive: l } = O(), c = async (t, e, o) => {
|
|
23
|
+
if (!d("allowlistEnabled"))
|
|
24
24
|
return !1;
|
|
25
|
-
const i = await
|
|
25
|
+
const i = await k(t, e);
|
|
26
26
|
if (!i.length)
|
|
27
27
|
return !1;
|
|
28
28
|
if (!o) {
|
|
29
|
-
const s = await
|
|
30
|
-
s != null && s.message &&
|
|
29
|
+
const s = await C(i);
|
|
30
|
+
s != null && s.message && x({
|
|
31
31
|
type: I.Warning,
|
|
32
32
|
message: s.message,
|
|
33
33
|
actionButton: s.actionButton
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
return !0;
|
|
37
|
-
}, L = async (t) => !y(t.compiledHtml) || !
|
|
38
|
-
if (!await
|
|
37
|
+
}, L = async (t) => !y(t.compiledHtml) || !w(t.compiledHtml) || !E(t.compiledHtml) ? !1 : d("liquidSyntax") ? S(t.compiledHtml) : v(t.compiledHtml, t.dynamicContentList, !0), u = async (t, e) => {
|
|
38
|
+
if (!await H())
|
|
39
39
|
return;
|
|
40
40
|
const { unsubscribePayload: i, stripoModules: s } = b(t.rawHtml);
|
|
41
41
|
if (await g(i), t.modules = s, !e.suppress) {
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const W = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
|
|
43
|
+
p({ ...t, ...W, silent: e.silent });
|
|
44
44
|
}
|
|
45
45
|
return t;
|
|
46
46
|
}, U = async (t, e) => {
|
|
47
47
|
var i;
|
|
48
|
-
|
|
49
|
-
const o = await
|
|
48
|
+
a();
|
|
49
|
+
const o = await m();
|
|
50
50
|
if (n(o.rawHtml, e)) {
|
|
51
|
-
if (
|
|
52
|
-
const s = await
|
|
51
|
+
if (h.value && !e) {
|
|
52
|
+
const s = await B(
|
|
53
53
|
o.compiledHtml,
|
|
54
54
|
o.dynamicContentList
|
|
55
55
|
);
|
|
@@ -59,31 +59,34 @@ const Bt = () => {
|
|
|
59
59
|
}
|
|
60
60
|
} else if (!await L(o))
|
|
61
61
|
return;
|
|
62
|
-
if (!((i =
|
|
62
|
+
if (!((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(o)) && !await c(o.compiledHtml, o.css, e))
|
|
63
63
|
return u(o, { silent: e, suppress: t });
|
|
64
64
|
}
|
|
65
65
|
}, A = async () => {
|
|
66
66
|
var e;
|
|
67
|
-
if (!
|
|
67
|
+
if (!f.allowSaveWithErrors)
|
|
68
68
|
return;
|
|
69
|
-
|
|
70
|
-
const t = await
|
|
71
|
-
if (n(t.rawHtml, !1) && !((e =
|
|
69
|
+
a();
|
|
70
|
+
const t = await m();
|
|
71
|
+
if (n(t.rawHtml, !1) && !((e = r.value) != null && e.externalValidation && !await r.value.externalValidation(t)) && !await c(t.compiledHtml, t.css, !1))
|
|
72
72
|
return u(t, { silent: !1, blankCompiled: !0 });
|
|
73
73
|
}, M = async () => {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
if (!f.allowSaveWithErrors)
|
|
75
|
+
return;
|
|
76
|
+
a();
|
|
77
|
+
const { html: t, css: e } = await V();
|
|
76
78
|
if (!n(t, !0) || await c(t, e, !0))
|
|
77
79
|
return;
|
|
78
80
|
const o = Y(t), i = {
|
|
79
|
-
dynamicContentList:
|
|
81
|
+
dynamicContentList: P.getSelectedDynamicContentList,
|
|
80
82
|
compiledHtml: "",
|
|
81
83
|
rawHtml: t,
|
|
82
84
|
css: e,
|
|
83
85
|
ampHtml: "",
|
|
84
86
|
ampErrors: [],
|
|
85
87
|
modules: [],
|
|
86
|
-
|
|
88
|
+
// No campaignUrls: hosts overwrite their stored map with any object, and raw HTML can't rebuild it.
|
|
89
|
+
recommendation: { configs: {} },
|
|
87
90
|
unsubscribe: {
|
|
88
91
|
status: o.length > 0,
|
|
89
92
|
config: o
|