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

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 (86) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +102 -87
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +83 -75
  5. package/dist/components/organisms/AutoSaveController.vue2.js +10 -8
  6. package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
  7. package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
  8. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  9. package/dist/components/organisms/header/EditorActions.vue2.js +83 -48
  10. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  11. package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
  12. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
  13. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +50 -0
  14. package/dist/components/wrappers/WpDrawer.vue.js +9 -7
  15. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  16. package/dist/components/wrappers/WpModal.vue.js +1 -1
  17. package/dist/components/wrappers/WpModal.vue2.js +4 -3
  18. package/dist/composables/useActionsApi.js +52 -47
  19. package/dist/composables/useAuthError.js +52 -0
  20. package/dist/composables/useAutoSave.js +44 -42
  21. package/dist/composables/useCodeEditorApi.js +23 -9
  22. package/dist/composables/useHtmlCompiler.js +37 -26
  23. package/dist/composables/useHtmlValidator.js +2 -0
  24. package/dist/composables/useHttp.js +48 -49
  25. package/dist/composables/useLegacyStrategyConversion.js +23 -19
  26. package/dist/composables/useSave.js +92 -45
  27. package/dist/composables/useSaveValidation.js +284 -0
  28. package/dist/composables/useSaveValidationRollout.js +20 -0
  29. package/dist/composables/useStripo.js +24 -20
  30. package/dist/composables/useToaster.js +17 -15
  31. package/dist/composables/useTranslations.js +3 -2
  32. package/dist/composables/useVersionHistoryApi.js +33 -24
  33. package/dist/composables/validators/useCouponBlockValidator.js +24 -21
  34. package/dist/composables/validators/useLiquidValidator.js +15 -15
  35. package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
  36. package/dist/config/migrator/index.js +14 -13
  37. package/dist/config/migrator/recommendationPartnerMigrator.js +50 -0
  38. package/dist/enums/extensions/recommendationBlock.js +30 -29
  39. package/dist/enums/save-validation.js +4 -0
  40. package/dist/extensions/Blocks/Recommendation/block.js +15 -14
  41. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
  42. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
  43. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -29
  44. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
  45. package/dist/guido.css +1 -1
  46. package/dist/services/settingsApi.js +11 -0
  47. package/dist/src/@types/config/schemas.d.ts +20 -0
  48. package/dist/src/@types/save-validation.d.ts +19 -0
  49. package/dist/src/components/Guido.vue.d.ts +17 -1
  50. package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
  51. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
  52. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
  53. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
  54. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
  55. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
  56. package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
  57. package/dist/src/composables/useAuthError.d.ts +12 -0
  58. package/dist/src/composables/useAutoSave.d.ts +4 -1
  59. package/dist/src/composables/useConfig.d.ts +4 -0
  60. package/dist/src/composables/useHtmlValidator.d.ts +21 -0
  61. package/dist/src/composables/useHttp.d.ts +2 -0
  62. package/dist/src/composables/useSave.d.ts +6 -1
  63. package/dist/src/composables/useSaveValidation.d.ts +6 -0
  64. package/dist/src/composables/useSaveValidationRollout.d.ts +4 -0
  65. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  66. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
  67. package/dist/src/config/migrator/index.d.ts +2 -1
  68. package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
  69. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
  70. package/dist/src/enums/save-validation.d.ts +27 -0
  71. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  72. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
  73. package/dist/src/services/settingsApi.d.ts +6 -0
  74. package/dist/src/stores/config.d.ts +52 -0
  75. package/dist/src/stores/save-validation.d.ts +22 -0
  76. package/dist/src/stores/setup-settings.d.ts +4 -0
  77. package/dist/src/utils/stripoEditorApi.d.ts +4 -0
  78. package/dist/src/utils/templatePreparation.d.ts +30 -0
  79. package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
  80. package/dist/stores/config.js +84 -67
  81. package/dist/stores/save-validation.js +30 -0
  82. package/dist/stores/setup-settings.js +10 -0
  83. package/dist/stores/unsubscribe.js +3 -3
  84. package/dist/utils/stripoEditorApi.js +11 -0
  85. package/dist/utils/templatePreparation.js +39 -36
  86. package/package.json +2 -1
@@ -0,0 +1,20 @@
1
+ import { useSettingsApi as l } from "../services/settingsApi.js";
2
+ import { useSetupSettingsStore as s } from "../stores/setup-settings.js";
3
+ import { computed as a } from "vue";
4
+ let o = null;
5
+ const m = () => {
6
+ const t = s();
7
+ return { isEnabled: a(() => t.isEmailAutoSaveEnabled), loadRollout: () => t.isLoaded ? Promise.resolve() : (o ?? (o = l().getSetupSettings().then(({ isEmailAutoSaveEnabled: e }) => {
8
+ t.$patch({
9
+ isEmailAutoSaveEnabled: !!Number(e ?? 0),
10
+ isLoaded: !0
11
+ });
12
+ }).catch((e) => {
13
+ console.warn("Failed to load setup settings; soft-save stays off.", e);
14
+ }).finally(() => {
15
+ o = null;
16
+ })), o) };
17
+ };
18
+ export {
19
+ m as useSaveValidationRollout
20
+ };
@@ -17,21 +17,21 @@ import { buildMergeTagEntries as W, flattenDynamicContentList as Y } from "../ut
17
17
  import Z from "../package.json.js";
18
18
  let n = null;
19
19
  const he = () => {
20
- const { features: c, template: u, isFeatureEnabled: m } = H(), { handleError: p, showToaster: B } = G(), { getToken: M, getCustomFonts: T, getSyncModulesStatus: v } = K(), { handleEvent: F } = z(), { handleModuleAdd: A } = j(), { getStripoBlocksConfig: V } = O(), { getStripoNotifications: _ } = $(), f = () => n || (n = new Promise((i, s) => {
20
+ const { features: c, template: u, isFeatureEnabled: p } = H(), { handleError: m, showToaster: v } = G(), { getToken: B, getCustomFonts: M, getSyncModulesStatus: T } = K(), { handleEvent: F } = z(), { handleModuleAdd: A } = j(), { getStripoBlocksConfig: V } = O(), { getStripoNotifications: _ } = $(), f = () => n || (n = new Promise((r, s) => {
21
21
  var d;
22
22
  if (document.getElementById("UiEditorScript")) {
23
- i();
23
+ r();
24
24
  return;
25
25
  }
26
- const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(d = o == null ? void 0 : o.stripo) == null ? void 0 : d.version}/UIEditor.js`, e = document.createElement("script");
27
- e.id = "UiEditorScript", e.type = "module", e.src = r, e.onload = () => i(), e.onerror = () => {
28
- e.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${r}`));
26
+ const o = Z.guido, i = `https://email-static.useinsider.com/guido/${(d = o == null ? void 0 : o.stripo) == null ? void 0 : d.version}/UIEditor.js`, e = document.createElement("script");
27
+ e.id = "UiEditorScript", e.type = "module", e.src = i, e.onload = () => r(), e.onerror = () => {
28
+ e.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${i}`));
29
29
  }, document.body.appendChild(e);
30
30
  }), n.catch(() => {
31
31
  n = null;
32
- }), n), D = async (i, s, o, a = [], r = !1) => {
32
+ }), n), D = async (r, s, o, a = [], i = !1) => {
33
33
  var y, E, h, C;
34
- const e = k(), { html: d, css: R } = i, { baseBlocks: g, extensions: P } = await V(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, U = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, I = !!d || (((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1), q = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com";
34
+ const e = k(), { html: d, css: R } = r, { baseBlocks: g, extensions: P } = await V(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, U = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, I = !!d || (((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1), q = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com";
35
35
  w().importCss(), await window.UIEditor.initEditor(
36
36
  document.querySelector("#guido-editor"),
37
37
  {
@@ -45,7 +45,7 @@ const he = () => {
45
45
  mobileViewButtonSelector: ".guido__view-option-selection-mobile",
46
46
  desktopViewButtonSelector: ".guido__view-option-selection-desktop",
47
47
  codeEditorButtonSelector: "#guido__code-button",
48
- customAppearanceMergetags: !m("liquidSyntax"),
48
+ customAppearanceMergetags: !p("liquidSyntax"),
49
49
  customAppearanceMergetagsBorderColor: "#f1f3fe",
50
50
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
51
51
  customViewStyles: Q,
@@ -53,7 +53,7 @@ const he = () => {
53
53
  customConditionsEnabled: S,
54
54
  enableXSSSecurity: !0,
55
55
  modulesDisabled: U,
56
- syncModulesEnabled: r,
56
+ syncModulesEnabled: i,
57
57
  messageSettingsEnabled: !0,
58
58
  displayGmailAnnotations: !0,
59
59
  displayHiddenPreheader: !1,
@@ -74,16 +74,16 @@ const he = () => {
74
74
  entries: W(
75
75
  o.preselectedDynamicContentList,
76
76
  Y((C = u.value) == null ? void 0 : C.dynamicContentList),
77
- m("liquidSyntax")
77
+ p("liquidSyntax")
78
78
  )
79
79
  }
80
80
  ],
81
81
  async onTokenRefreshRequest(t) {
82
82
  try {
83
- const l = await M();
83
+ const l = await B();
84
84
  t(l);
85
85
  } catch (l) {
86
- p(l, "Failed to refresh token");
86
+ m(l, "Failed to refresh token");
87
87
  }
88
88
  },
89
89
  onTemplateLoaded() {
@@ -93,7 +93,7 @@ const he = () => {
93
93
  e.hasChanges = !1;
94
94
  }, 1e3);
95
95
  } catch (t) {
96
- p(t, "Failed to load custom interface appearance");
96
+ m(t, "Failed to load custom interface appearance");
97
97
  }
98
98
  },
99
99
  onCodeEditorVisibilityChanged(t) {
@@ -111,27 +111,31 @@ const he = () => {
111
111
  onEvent: F,
112
112
  onModuleAdd: A,
113
113
  notifications: _(),
114
+ // Stripo deselects the block on any click outside the canvas, so every surface
115
+ // that belongs to the block's own flow has to be listed here (SD-153273).
114
116
  ignoreClickOutsideSelectors: [
115
117
  "#guido-dynamic-content-modal",
116
118
  ".in-on-board-wrapper",
117
- ".in-drawer__container"
119
+ ".in-drawer__container",
120
+ ".in-modal-v2-wrapper",
121
+ ".in-toasts-wrapper"
118
122
  ],
119
123
  extensions: P,
120
124
  localePatch: J
121
125
  }
122
126
  );
123
127
  };
124
- return { initPlugin: async (i, s, o) => {
128
+ return { initPlugin: async (r, s, o) => {
125
129
  const a = k();
126
130
  try {
127
131
  await f();
128
- const [r, e] = await Promise.all([
129
- T(),
130
- v()
132
+ const [i, e] = await Promise.all([
133
+ M(),
134
+ T()
131
135
  ]);
132
- a.syncModulesEnabled = e, await D(i, s, o, r, e);
136
+ a.syncModulesEnabled = e, await D(r, s, o, i, e);
133
137
  } catch {
134
- a.loadingStatus = !1, B({
138
+ a.loadingStatus = !1, v({
135
139
  type: X.Error,
136
140
  message: b["An error has occurred. Please report the error code to support."],
137
141
  actionButton: {
@@ -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
@@ -6,9 +6,10 @@ import { useConfig } from "./useConfig.js";
6
6
  const useTranslations = () => {
7
7
  var o, e;
8
8
  const { config } = useConfig(), translationsPath = ((e = (o = config.value) == null ? void 0 : o.editor) == null ? void 0 : e.translationsPath) || DEFAULT_EDITOR.translationsPath, translations = ref(eval(translationsPath)), trans = (t, n) => {
9
- const r = translations.value[t];
9
+ var s;
10
+ const r = (s = translations.value) == null ? void 0 : s[t];
10
11
  return r ? n ? Object.entries(n).reduce(
11
- (s, [i, a]) => s.replace(new RegExp(`{${i}}`, "g"), String(a)),
12
+ (i, [a, l]) => i.replace(new RegExp(`{${a}}`, "g"), String(l)),
12
13
  r
13
14
  ) : r : (console.warn(`Translation key not found: ${t}`), t);
14
15
  };
@@ -1,54 +1,63 @@
1
1
  import { ToasterTypeOptions as t } from "../enums/toaster.js";
2
- import { useVersionHistoryStore as c } from "../stores/version-history.js";
3
- import { useToaster as w } from "./useToaster.js";
4
- const S = () => {
5
- const i = c(), { showToaster: s } = w(), n = (e) => {
6
- i.$reset(), i.updateState(e);
7
- }, p = () => {
8
- i.$reset();
2
+ import { useVersionHistoryStore as m } from "../stores/version-history.js";
3
+ import { findEditorApi as w, EDITOR_NOT_READY_MESSAGE as y } from "../utils/stripoEditorApi.js";
4
+ import { useToaster as V } from "./useToaster.js";
5
+ const d = () => {
6
+ const n = m(), { showToaster: i } = V(), o = (e) => {
7
+ var s;
8
+ const r = (s = w()) == null ? void 0 : s.versionHistoryApi;
9
+ if (!r) {
10
+ i({ type: t.Error, message: y });
11
+ return;
12
+ }
13
+ e(r);
14
+ }, p = (e) => {
15
+ n.$reset(), n.updateState(e);
16
+ }, a = () => {
17
+ n.$reset();
9
18
  };
10
19
  return {
11
20
  openVersionHistory: () => {
12
- window.StripoEditorApi.versionHistoryApi.openVersionHistory(n, p);
21
+ o((e) => e.openVersionHistory(p, a));
13
22
  },
14
23
  closeVersionHistory: () => {
15
- window.StripoEditorApi.versionHistoryApi.closeVersionHistory();
24
+ o((e) => e.closeVersionHistory());
16
25
  },
17
26
  switchToDesktopPreview: () => {
18
- window.StripoEditorApi.versionHistoryApi.switchToDesktopPreview();
27
+ o((e) => e.switchToDesktopPreview());
19
28
  },
20
29
  switchToMobilePreview: () => {
21
- window.StripoEditorApi.versionHistoryApi.switchToMobilePreview();
30
+ o((e) => e.switchToMobilePreview());
22
31
  },
23
32
  previewVersion: (e) => {
24
- window.StripoEditorApi.versionHistoryApi.previewVersion(e, (o) => {
25
- const r = o instanceof Error ? o.message : String(o);
26
- s({
33
+ o((r) => r.previewVersion(e, (s) => {
34
+ const c = s instanceof Error ? s.message : String(s);
35
+ i({
27
36
  type: t.Error,
28
- message: `Error compiling email: ${r}`
37
+ message: `Error compiling email: ${c}`
29
38
  });
30
- });
39
+ }));
31
40
  },
32
41
  restoreVersion: (e) => {
33
- window.StripoEditorApi.versionHistoryApi.restoreVersion(
42
+ o((r) => r.restoreVersion(
34
43
  e,
35
44
  () => {
36
- s({
45
+ i({
37
46
  type: t.Success,
38
47
  message: "Your version has been restored successfully."
39
48
  });
40
49
  },
41
- (o) => {
42
- const r = o instanceof Error ? o.message : String(o);
43
- s({
50
+ (s) => {
51
+ const c = s instanceof Error ? s.message : String(s);
52
+ i({
44
53
  type: t.Error,
45
- message: `Error compiling email: ${r}`
54
+ message: `Error compiling email: ${c}`
46
55
  });
47
56
  }
48
- );
57
+ ));
49
58
  }
50
59
  };
51
60
  };
52
61
  export {
53
- S as useVersionHistoryApi
62
+ d as useVersionHistoryApi
54
63
  };
@@ -1,24 +1,27 @@
1
- import { ToasterTypeOptions as c } from "../../enums/toaster.js";
2
- import { COUPON_PLACEHOLDER_DEFAULT as i, COUPON_PLACEHOLDER_LIQUID as l } from "../../extensions/Blocks/CouponBlock/template.js";
3
- import { useToaster as m } from "../useToaster.js";
4
- import { useTranslations as p } from "../useTranslations.js";
5
- const u = /* @__PURE__ */ new Set([
6
- i,
7
- l
8
- ]), A = () => {
9
- const { showToaster: t } = m(), r = p();
10
- return { validateCouponBlockTags: (e) => {
11
- const n = new DOMParser().parseFromString(e, "text/html");
12
- return Array.from(n.querySelectorAll(".coupon-block")).find((s) => {
13
- var o;
14
- const a = ((o = s.textContent) == null ? void 0 : o.trim()) ?? "";
15
- return !u.has(a);
16
- }) ? (t({
17
- type: c.Warning,
18
- message: r("newsletter.coupon-tag-modified")
19
- }), !1) : !0;
20
- } };
1
+ import { ToasterTypeOptions as n } from "../../enums/toaster.js";
2
+ import { COUPON_PLACEHOLDER_DEFAULT as s, COUPON_PLACEHOLDER_LIQUID as a } from "../../extensions/Blocks/CouponBlock/template.js";
3
+ import { useToaster as i } from "../useToaster.js";
4
+ import { useTranslations as l } from "../useTranslations.js";
5
+ const c = /* @__PURE__ */ new Set([
6
+ s,
7
+ a
8
+ ]), p = "newsletter.coupon-tag-modified";
9
+ function u(r) {
10
+ const e = new DOMParser().parseFromString(r, "text/html");
11
+ return Array.from(e.querySelectorAll(".coupon-block")).map((o) => {
12
+ var t;
13
+ return ((t = o.textContent) == null ? void 0 : t.trim()) ?? "";
14
+ }).filter((o) => !c.has(o));
15
+ }
16
+ const T = () => {
17
+ const { showToaster: r } = i(), e = l();
18
+ return { validateCouponBlockTags: (t) => u(t).length > 0 ? (r({
19
+ type: n.Warning,
20
+ message: e(p)
21
+ }), !1) : !0 };
21
22
  };
22
23
  export {
23
- A as useCouponBlockValidator
24
+ p as COUPON_TAG_MODIFIED_KEY,
25
+ u as findInvalidCouponBlocks,
26
+ T as useCouponBlockValidator
24
27
  };
@@ -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
  }
@@ -1,8 +1,8 @@
1
- import { ToasterTypeOptions as i } from "../../enums/toaster.js";
1
+ import { ToasterTypeOptions as c } from "../../enums/toaster.js";
2
2
  import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
3
- import { UNSUBSCRIBE_BLOCK_SELECTOR as l, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
- import { useToaster as E } from "../useToaster.js";
5
- import { useTranslations as m } from "../useTranslations.js";
3
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as i, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
+ import { useToaster as p } from "../useToaster.js";
5
+ import { useTranslations as l } from "../useTranslations.js";
6
6
  const T = [
7
7
  {
8
8
  pageType: u.GLOBAL_UNSUBSCRIBE,
@@ -12,30 +12,37 @@ const T = [
12
12
  pageType: u.SUBSCRIPTION_PREFERENCE_CENTER,
13
13
  messageKey: "unsubscription-preference.duplicate-pref-center"
14
14
  }
15
- ], g = "unsubscription-preference.duplicate-both", b = "unsubscription-preference.select-page-to-continue", P = () => {
16
- const { showToaster: c } = E(), p = m();
17
- return { validateUnsubscribeBlockUniqueness: (n) => {
18
- const o = new DOMParser().parseFromString(n, "text/html"), r = /* @__PURE__ */ new Map();
19
- o.querySelectorAll(l).forEach((e) => {
20
- const s = Number(e.getAttribute(a.PAGE_TYPE));
21
- r.set(s, (r.get(s) ?? 0) + 1);
22
- });
23
- const t = T.filter((e) => (r.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
24
- return t.length ? (c({
25
- type: i.Error,
26
- message: p(t.length > 1 ? g : t[0])
15
+ ], g = "unsubscription-preference.duplicate-both", E = "unsubscription-preference.select-page-to-continue";
16
+ function m(r) {
17
+ const s = new DOMParser().parseFromString(r, "text/html"), t = /* @__PURE__ */ new Map();
18
+ return s.querySelectorAll(i).forEach((n) => {
19
+ const e = Number(n.getAttribute(a.PAGE_TYPE));
20
+ t.set(e, (t.get(e) ?? 0) + 1);
21
+ }), T.filter((n) => (t.get(n.pageType) ?? 0) > 1);
22
+ }
23
+ function b(r) {
24
+ const s = new DOMParser().parseFromString(r, "text/html");
25
+ return Array.from(s.querySelectorAll(i)).filter((t) => {
26
+ const n = t.getAttribute(a.PAGE_TYPE), e = t.getAttribute(a.PAGE_LIST);
27
+ return !n || !e;
28
+ }).length;
29
+ }
30
+ const y = () => {
31
+ const { showToaster: r } = p(), s = l();
32
+ return { validateUnsubscribeBlockUniqueness: (e) => {
33
+ const o = m(e);
34
+ return o.length ? (r({
35
+ type: c.Error,
36
+ message: s(o.length > 1 ? g : o[0].messageKey)
27
37
  }), !1) : !0;
28
- }, validateUnsubscribeBlockHasTemplate: (n) => {
29
- const o = new DOMParser().parseFromString(n, "text/html");
30
- return Array.from(o.querySelectorAll(l)).some((t) => {
31
- const e = t.getAttribute(a.PAGE_TYPE), s = t.getAttribute(a.PAGE_LIST);
32
- return !e || !s;
33
- }) ? (c({
34
- type: i.Warning,
35
- message: p(b)
36
- }), !1) : !0;
37
- } };
38
+ }, validateUnsubscribeBlockHasTemplate: (e) => b(e) === 0 ? !0 : (r({
39
+ type: c.Warning,
40
+ message: s(E)
41
+ }), !1) };
38
42
  };
39
43
  export {
40
- P as useUnsubscribeBlockValidator
44
+ E as EMPTY_BLOCK_KEY,
45
+ b as countUnsubBlocksWithoutPage,
46
+ m as findDuplicateUnsubPageTypes,
47
+ y as useUnsubscribeBlockValidator
41
48
  };
@@ -1,16 +1,17 @@
1
- import { migrateCheckbox as t } from "./checkboxMigrator.js";
2
- import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
3
- import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
4
- import { migrateProductNameLink as a } from "./productNameLinkMigrator.js";
5
- import { migrateRadioButton as n } from "./radioButtonMigrator.js";
6
- import { migrateRecommendation as c } from "./recommendationMigrator.js";
7
- import { migrateRecommendationTitle as g } from "./recommendationTitleMigrator.js";
8
- import { migrateSocialIcons as p } from "./socialIconMigrator.js";
9
- import { migrateUnsubscribe as f } from "./unsubscribeMigrator.js";
10
- const C = async (o, r = {}) => {
11
- let m = o;
12
- return m = t(m), m = n(m), m = await f(m), m = i(m), m = c(m, r), m = g(m), m = e(m), m = a(m), m = p(m), m;
1
+ import { migrateCheckbox as i } from "./checkboxMigrator.js";
2
+ import { migrateCouponBlock as e } from "./couponBlockMigrator.js";
3
+ import { migrateItemsBlock as a } from "./itemsBlockMigrator.js";
4
+ import { migrateProductNameLink as n } from "./productNameLinkMigrator.js";
5
+ import { migrateRadioButton as c } from "./radioButtonMigrator.js";
6
+ import { migrateRecommendation as g } from "./recommendationMigrator.js";
7
+ import { migrateRecommendationPartnerScope as f } from "./recommendationPartnerMigrator.js";
8
+ import { migrateRecommendationTitle as p } from "./recommendationTitleMigrator.js";
9
+ import { migrateSocialIcons as d } from "./socialIconMigrator.js";
10
+ import { migrateUnsubscribe as l } from "./unsubscribeMigrator.js";
11
+ const h = async (r, t = {}, o) => {
12
+ let m = r;
13
+ return m = i(m), m = c(m), m = await l(m), m = e(m), m = g(m, t), o && (m = f(m, o)), m = p(m), m = a(m), m = n(m), m = d(m), m;
13
14
  };
14
15
  export {
15
- C as migrate
16
+ h as migrate
16
17
  };
@@ -0,0 +1,50 @@
1
+ import { RECOMMENDATION_ID_ATTR as f, SELECTOR_ATTRIBUTE_ROW as _, ATTR_DATA_ATTRIBUTE_TYPE as a, ATTR_CUSTOM_PREFIX as g, ATTR_DATA_CARD_COMPOSITION as O, ATTR_DATA_CUSTOM_ATTRIBUTES as R } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
2
+ import { carriesForeignPartnerConfig as m, canJudgeUnstampedBlock as E, withoutCustomAttributes as d } from "../../extensions/Blocks/Recommendation/utils/partnerScope.js";
3
+ const S = ".recommendation-block-v2[esd-ext-config]", c = "esd-ext-config";
4
+ function C(t) {
5
+ const e = t.getAttribute(c);
6
+ if (!e)
7
+ return null;
8
+ try {
9
+ const r = JSON.parse(e);
10
+ return r && typeof r == "object" && !Array.isArray(r) ? r : null;
11
+ } catch {
12
+ return null;
13
+ }
14
+ }
15
+ function I(t, e, r) {
16
+ const o = d(e.composition ?? []);
17
+ t.querySelectorAll(_).forEach((i) => {
18
+ var s;
19
+ (s = i.getAttribute(a)) != null && s.startsWith(g) && i.remove();
20
+ }), t.setAttribute(O, o.join(",")), t.setAttribute(R, "[]"), t.setAttribute(c, JSON.stringify({
21
+ ...e,
22
+ strategyId: "",
23
+ strategy: "",
24
+ filters: [],
25
+ productIds: [],
26
+ composition: o,
27
+ partnerName: r
28
+ }));
29
+ }
30
+ function p(t, { partnerName: e, campaignUrls: r, rrsEnabled: o }) {
31
+ if (!e)
32
+ return t;
33
+ const i = new DOMParser().parseFromString(t, "text/html"), s = Array.from(i.querySelectorAll(S));
34
+ if (s.length === 0)
35
+ return t;
36
+ let T = 0;
37
+ return s.forEach((u) => {
38
+ const n = C(u), A = Number(u.getAttribute(f));
39
+ if (!(!n || !Number.isFinite(A))) {
40
+ if (m({ config: n, blockId: A, partnerName: e, campaignUrls: r, rrsEnabled: o })) {
41
+ I(u, n, e), T += 1;
42
+ return;
43
+ }
44
+ n.partnerName || !E({ config: n, campaignUrls: r, rrsEnabled: o }) || (u.setAttribute(c, JSON.stringify({ ...n, partnerName: e })), T += 1);
45
+ }
46
+ }), T > 0 ? i.documentElement.outerHTML : t;
47
+ }
48
+ export {
49
+ p as migrateRecommendationPartnerScope
50
+ };