@useinsider/guido 3.18.0-beta.599df29 → 3.18.0-beta.6817b07

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 (52) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +28 -26
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +83 -85
  5. package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
  6. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  7. package/dist/components/organisms/header/EditorActions.vue2.js +72 -54
  8. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  9. package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
  10. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
  11. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +48 -0
  12. package/dist/components/wrappers/WpDrawer.vue.js +9 -7
  13. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  14. package/dist/composables/useActionsApi.js +67 -82
  15. package/dist/composables/useAutoSave.js +26 -31
  16. package/dist/composables/useGuidoStateBridge.js +31 -37
  17. package/dist/composables/useHtmlCompiler.js +37 -26
  18. package/dist/composables/useHtmlValidator.js +2 -0
  19. package/dist/composables/useSave.js +89 -47
  20. package/dist/composables/useSaveValidation.js +279 -0
  21. package/dist/composables/useSaveValidationRollout.js +9 -0
  22. package/dist/composables/validators/useCouponBlockValidator.js +24 -21
  23. package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
  24. package/dist/enums/save-validation.js +4 -0
  25. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +41 -34
  26. package/dist/guido.css +1 -1
  27. package/dist/src/@types/config/schemas.d.ts +4 -0
  28. package/dist/src/@types/save-validation.d.ts +19 -0
  29. package/dist/src/components/Guido.vue.d.ts +17 -1
  30. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
  31. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
  32. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
  33. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
  34. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
  35. package/dist/src/composables/useConfig.d.ts +2 -0
  36. package/dist/src/composables/useHtmlValidator.d.ts +21 -0
  37. package/dist/src/composables/useSave.d.ts +6 -1
  38. package/dist/src/composables/useSaveValidation.d.ts +6 -0
  39. package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
  40. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  41. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
  42. package/dist/src/enums/save-validation.d.ts +27 -0
  43. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
  44. package/dist/src/stores/config.d.ts +30 -0
  45. package/dist/src/stores/save-validation.d.ts +22 -0
  46. package/dist/src/utils/templatePreparation.d.ts +30 -0
  47. package/dist/stores/config.js +39 -22
  48. package/dist/stores/save-validation.js +30 -0
  49. package/dist/utils/templatePreparation.js +28 -25
  50. package/package.json +1 -1
  51. package/dist/composables/useEditorLock.js +0 -20
  52. package/dist/src/composables/useEditorLock.d.ts +0 -10
@@ -1,54 +1,48 @@
1
- import { useActionsApi as b } from "./useActionsApi.js";
2
- import { useEditorLock as v } from "./useEditorLock.js";
3
- import { useConfigStore as T } from "../stores/config.js";
4
- import { useEditorStore as w } from "../stores/editor.js";
5
- import { useGuidoEmailEditorStore as y } from "../stores/guido-email-editor.js";
6
- import { watch as a, onUnmounted as B } from "vue";
7
- const C = 500, L = () => {
8
- const i = w(), u = y(), l = T(), { getTemplateData: d } = b(), { runExclusive: m, isEditorBusy: p } = v();
9
- let o = null, s = !1;
10
- const n = () => {
11
- o && (clearTimeout(o), o = null);
12
- }, c = (t) => {
13
- n(), o = setTimeout(() => {
14
- o = null, t();
15
- }, C);
16
- }, e = async () => {
17
- var t, r;
18
- if (!(s || !i.isStripoInitialized)) {
19
- if (p()) {
20
- c(() => void e());
21
- return;
22
- }
1
+ import { useActionsApi as g } from "./useActionsApi.js";
2
+ import { useConfigStore as I } from "../stores/config.js";
3
+ import { useEditorStore as b } from "../stores/editor.js";
4
+ import { useGuidoEmailEditorStore as E } from "../stores/guido-email-editor.js";
5
+ import { watch as c, onUnmounted as T } from "vue";
6
+ const w = 500, z = () => {
7
+ const i = b(), a = E(), l = I(), { getTemplateData: m } = g();
8
+ let e = null, n = !1;
9
+ const r = () => {
10
+ e && (clearTimeout(e), e = null);
11
+ }, s = async () => {
12
+ var t, o;
13
+ if (!(n || !i.isStripoInitialized))
23
14
  try {
24
- const { html: E, css: g } = await m(d), I = ((r = (t = l.config) == null ? void 0 : t.identity) == null ? void 0 : r.templateId) ?? "";
25
- if (s)
15
+ const { html: f, css: h } = await m(), S = ((o = (t = l.config) == null ? void 0 : t.identity) == null ? void 0 : o.templateId) ?? "";
16
+ if (n)
26
17
  return;
27
- u.$patch({
28
- html: E ?? "",
29
- css: g ?? "",
30
- templateId: I,
18
+ a.$patch({
19
+ html: f ?? "",
20
+ css: h ?? "",
21
+ templateId: S,
31
22
  lastUpdatedAt: Date.now()
32
23
  });
33
24
  } catch {
34
25
  }
35
- }
36
- }, f = () => c(() => void e()), h = a(
26
+ }, u = () => {
27
+ r(), e = setTimeout(() => {
28
+ e = null, s();
29
+ }, w);
30
+ }, d = c(
37
31
  () => i.isStripoInitialized,
38
32
  (t) => {
39
- t && e();
33
+ t && s();
40
34
  },
41
35
  { immediate: !0 }
42
- ), S = a(
36
+ ), p = c(
43
37
  () => i.hasChanges,
44
- (t, r) => {
45
- i.isStripoInitialized && (t ? f() : r && (n(), e()));
38
+ (t, o) => {
39
+ i.isStripoInitialized && (t ? u() : o && (r(), s()));
46
40
  }
47
41
  );
48
- B(() => {
49
- s = !0, n(), h(), S();
42
+ T(() => {
43
+ n = !0, r(), d(), p();
50
44
  });
51
45
  };
52
46
  export {
53
- L as useGuidoStateBridge
47
+ z as useGuidoStateBridge
54
48
  };
@@ -1,13 +1,14 @@
1
- import { defaultHtmlCompilerRules as R } from "../config/compiler/htmlCompilerRules.js";
2
- import { itemsCompilerRules as g } from "../config/compiler/itemsCompilerRules.js";
3
- import { liquidCompilerRules as C } from "../config/compiler/liquidCompilerRules.js";
4
- import { outlookCompilerRules as b } from "../config/compiler/outlookCompilerRules.js";
1
+ import { defaultHtmlCompilerRules as d } from "../config/compiler/htmlCompilerRules.js";
2
+ import { itemsCompilerRules as f } from "../config/compiler/itemsCompilerRules.js";
3
+ import { liquidCompilerRules as g } from "../config/compiler/liquidCompilerRules.js";
4
+ import { outlookCompilerRules as R } from "../config/compiler/outlookCompilerRules.js";
5
5
  import { recommendationCompilerRules as v } from "../config/compiler/recommendationCompilerRules.js";
6
6
  import { socialCompilerRules as H } from "../config/compiler/socialCompilerRules.js";
7
- import { unsubscribeCompilerRules as x } from "../config/compiler/unsubscribeCompilerRules.js";
8
- import { createHtmlCompiler as s } from "../utils/htmlCompiler.js";
9
- import { useConfig as k } from "./useConfig.js";
10
- const y = /* @__PURE__ */ new Set([
7
+ import { unsubscribeCompilerRules as b } from "../config/compiler/unsubscribeCompilerRules.js";
8
+ import { createHtmlCompiler as n } from "../utils/htmlCompiler.js";
9
+ import { computed as p } from "vue";
10
+ import { useConfig as C } from "./useConfig.js";
11
+ const x = /* @__PURE__ */ new Set([
11
12
  // URL/tag encoding fixes — keep merge-tag and placeholder integrity intact.
12
13
  "fix-url-encoding-start",
13
14
  "fix-url-encoding-end",
@@ -30,24 +31,34 @@ const y = /* @__PURE__ */ new Set([
30
31
  // Editor-only attribute strip — AMP4EMAIL has no `contenteditable`, so leaving
31
32
  // it in narrows/breaks rendering. Pure attribute removal, emits nothing.
32
33
  "remove-contenteditable"
33
- ]), M = () => {
34
- var i, m, r;
35
- const { compiler: o, isFeatureEnabled: n, partner: a } = k(), p = ((i = o.value) == null ? void 0 : i.customRules) || [], l = [
36
- ...!!((m = o.value) != null && m.ignoreDefaultRules) ? [] : R,
37
- ...v,
38
- ...x,
39
- ...g,
40
- ...b,
41
- ...H,
42
- ...n("liquidSyntax") ? C : [],
43
- ...p.map((e, f) => ({
44
- ...e,
45
- priority: e.priority + 1e3 + f
46
- // Ensure additional rules run after default rules
47
- }))
48
- ], u = s(l), c = l.filter((e) => y.has(e.id)), d = s(c), t = (r = a.value) == null ? void 0 : r.fallbackFont;
49
- return { compileHtml: (e) => u.compile(e, void 0, t), compileAmpHtml: (e) => d.compile(e, void 0, t) };
34
+ ]), I = () => {
35
+ const { compiler: i, isFeatureEnabled: u, partner: a } = C(), c = p(() => {
36
+ var m, l;
37
+ const e = ((m = i.value) == null ? void 0 : m.customRules) || [];
38
+ return [
39
+ ...!!((l = i.value) != null && l.ignoreDefaultRules) ? [] : d,
40
+ ...v,
41
+ ...b,
42
+ ...f,
43
+ ...R,
44
+ ...H,
45
+ ...u("liquidSyntax") ? g : [],
46
+ ...e.map((t, o) => ({
47
+ ...t,
48
+ priority: t.priority + 1e3 + o
49
+ // Ensure additional rules run after default rules
50
+ }))
51
+ ];
52
+ }), r = p(() => {
53
+ var t;
54
+ const e = c.value, s = n(e), m = n(e.filter((o) => x.has(o.id))), l = (t = a.value) == null ? void 0 : t.fallbackFont;
55
+ return {
56
+ compileHtml: (o) => s.compile(o, void 0, l),
57
+ compileAmpHtml: (o) => m.compile(o, void 0, l)
58
+ };
59
+ });
60
+ return { compileHtml: (e) => r.value.compileHtml(e), compileAmpHtml: (e) => r.value.compileAmpHtml(e) };
50
61
  };
51
62
  export {
52
- M as useHtmlCompiler
63
+ I as useHtmlCompiler
53
64
  };
@@ -221,6 +221,8 @@ const De = () => {
221
221
  export {
222
222
  de as buildPartnerAttributeNameSet,
223
223
  fe as findInvalidCustomFields,
224
+ pe as getInvalidDynamicContentTags,
225
+ ce as getRecommendationBlockIds,
224
226
  ue as parseRecommendationVariable,
225
227
  De as useHtmlValidator
226
228
  };
@@ -1,55 +1,97 @@
1
- import { useActionsApi as T } from "./useActionsApi.js";
2
- import { useConfig as q } from "./useConfig.js";
3
- import { useEditorLock as C } from "./useEditorLock.js";
4
- import { useSaveStart as L, useSaveComplete as M } from "./useGuidoActions.js";
5
- import { useSyncModuleExtractor as D } from "./useSyncModuleExtractor.js";
6
- import { ToasterTypeOptions as P } from "../enums/toaster.js";
7
- import { useStripoApi as U } from "../services/stripoApi.js";
8
- import { useTemplatePreparation as A } from "../utils/templatePreparation.js";
9
- import { useAllowlist as h } from "./useAllowlist.js";
10
- import { useHtmlValidator as F } from "./useHtmlValidator.js";
11
- import { useToaster as O } from "./useToaster.js";
12
- import { useCouponBlockValidator as W } from "./validators/useCouponBlockValidator.js";
13
- import { useLiquidValidator as j } from "./validators/useLiquidValidator.js";
14
- import { useSyncModuleBlockValidator as z } from "./validators/useSyncModuleBlockValidator.js";
15
- import { useUnsubscribeBlockValidator as G } from "./validators/useUnsubscribeBlockValidator.js";
16
- const rt = () => {
17
- const n = L(), c = M(), { validateHtml: d } = F(), { validateLiquidSyntax: m } = j(), { validateCouponBlockTags: u } = W(), { validateUnsubscribeBlockUniqueness: p, validateUnsubscribeBlockHasTemplate: f } = G(), { validateSyncModuleBlocks: v } = z(), { callbacks: s, isFeatureEnabled: r } = q(), { extractSyncModuleData: S } = D(), { setSyncModuleUnsubscriptionPages: b } = U(), { editorSave: w } = T(), { showToaster: V } = O(), { getBlockedDomains: y, resolveToast: k } = h(), { runExclusive: x } = C(), H = async (a, o) => {
18
- var l;
19
- n();
20
- const { prepareTemplateDetails: B } = A(), t = await B();
21
- if (!v(t.rawHtml, o) || !u(t.compiledHtml) || !p(t.compiledHtml) || !f(t.compiledHtml))
22
- return;
23
- if (r("liquidSyntax")) {
24
- if (!await m(t.compiledHtml))
25
- return;
26
- } else if (!await d(t.compiledHtml, t.dynamicContentList, !0))
27
- return;
28
- if ((l = s.value) != null && l.externalValidation && !await s.value.externalValidation(t))
1
+ import { useActionsApi as L } from "./useActionsApi.js";
2
+ import { useConfig as A } from "./useConfig.js";
3
+ import { useSaveStart as M, useSaveComplete as q } from "./useGuidoActions.js";
4
+ import { useSaveValidation as R } from "./useSaveValidation.js";
5
+ import { useSaveValidationRollout as W } from "./useSaveValidationRollout.js";
6
+ import { useSyncModuleExtractor as O } from "./useSyncModuleExtractor.js";
7
+ import { ToasterTypeOptions as D } from "../enums/toaster.js";
8
+ import { useStripoApi as F } from "../services/stripoApi.js";
9
+ import { useConfigStore as j } from "../stores/config.js";
10
+ import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
11
+ import { useSaveValidationStore as G } from "../stores/save-validation.js";
12
+ import { useTemplatePreparation as I, getHtmlReferencedUnsubscribePages as J } from "../utils/templatePreparation.js";
13
+ import { useAllowlist as K } from "./useAllowlist.js";
14
+ import { useHtmlValidator as N } from "./useHtmlValidator.js";
15
+ import { useToaster as Q } from "./useToaster.js";
16
+ import { useCouponBlockValidator as X } from "./validators/useCouponBlockValidator.js";
17
+ import { useLiquidValidator as Y } from "./validators/useLiquidValidator.js";
18
+ import { useSyncModuleBlockValidator as Z } from "./validators/useSyncModuleBlockValidator.js";
19
+ import { useUnsubscribeBlockValidator as _ } from "./validators/useUnsubscribeBlockValidator.js";
20
+ const Ht = () => {
21
+ const r = M(), d = q(), { validateHtml: f } = N(), { validateLiquidSyntax: p } = Y(), { validateCouponBlockTags: v } = X(), { validateUnsubscribeBlockUniqueness: S, validateUnsubscribeBlockHasTemplate: y } = _(), { validateSyncModuleBlocks: c } = Z(), { callbacks: a, isFeatureEnabled: m } = A(), { extractSyncModuleData: w } = O(), { setSyncModuleUnsubscriptionPages: b } = F(), { editorSave: g, getTemplateData: H } = L(), { showToaster: V } = Q(), { getBlockedDomains: E, resolveToast: C } = K(), { prepareTemplateDetails: u } = I(), { collectSaveValidationErrors: k } = R(), { isEnabled: x } = W(), B = G(), T = z(), P = j(), n = async (t, e, o) => {
22
+ if (!m("allowlistEnabled"))
23
+ return !1;
24
+ const s = await E(t, e);
25
+ if (!s.length)
26
+ return !1;
27
+ if (!o) {
28
+ const i = await C(s);
29
+ i != null && i.message && V({
30
+ type: D.Warning,
31
+ message: i.message,
32
+ actionButton: i.actionButton
33
+ });
34
+ }
35
+ return !0;
36
+ }, h = async (t) => !v(t.compiledHtml) || !S(t.compiledHtml) || !y(t.compiledHtml) ? !1 : m("liquidSyntax") ? p(t.compiledHtml) : f(t.compiledHtml, t.dynamicContentList, !0), l = async (t, e) => {
37
+ if (!await g())
29
38
  return;
30
- if (r("allowlistEnabled")) {
31
- const i = await y(t.compiledHtml, t.css);
32
- if (i.length) {
33
- if (!o) {
34
- const e = await k(i);
35
- e != null && e.message && V({
36
- type: P.Warning,
37
- message: e.message,
38
- actionButton: e.actionButton
39
- });
39
+ const { unsubscribePayload: s, stripoModules: i } = w(t.rawHtml);
40
+ if (await b(s), t.modules = i, !e.suppress) {
41
+ const U = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
42
+ d({ ...t, ...U, silent: e.silent });
43
+ }
44
+ return t;
45
+ };
46
+ return { save: async (t = !1, e = !1) => {
47
+ var s;
48
+ r();
49
+ const o = await u();
50
+ if (c(o.rawHtml, e)) {
51
+ if (x.value && !e) {
52
+ const i = await k(
53
+ o.compiledHtml,
54
+ o.dynamicContentList
55
+ );
56
+ if (i.length) {
57
+ B.open(i, "save");
58
+ return;
40
59
  }
60
+ } else if (!await h(o))
41
61
  return;
42
- }
62
+ if (!((s = a.value) != null && s.externalValidation && !await a.value.externalValidation(o)) && !await n(o.compiledHtml, o.css, e))
63
+ return l(o, { silent: e, suppress: t });
43
64
  }
44
- if (!await w())
65
+ }, saveWithErrors: async () => {
66
+ var e;
67
+ if (!P.allowSaveWithErrors)
45
68
  return;
46
- const { unsubscribePayload: E, stripoModules: g } = S(t.rawHtml);
47
- return await b(E), t.modules = g, a || c({ ...t, silent: o }), t;
48
- };
49
- return { save: (a = !1, o = !1) => x(
50
- () => H(a, o)
51
- ) };
69
+ r();
70
+ const t = await u();
71
+ if (!((e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t)) && !await n(t.compiledHtml, t.css, !1))
72
+ return l(t, { silent: !1, blankCompiled: !0 });
73
+ }, saveRawOnly: async () => {
74
+ r();
75
+ const { html: t, css: e } = await H();
76
+ if (!c(t, !0) || await n(t, e, !0))
77
+ return;
78
+ const o = J(t), s = {
79
+ dynamicContentList: T.getSelectedDynamicContentList,
80
+ compiledHtml: "",
81
+ rawHtml: t,
82
+ css: e,
83
+ ampHtml: "",
84
+ ampErrors: [],
85
+ modules: [],
86
+ recommendation: { campaignUrls: {}, configs: {} },
87
+ unsubscribe: {
88
+ status: o.length > 0,
89
+ config: o
90
+ }
91
+ };
92
+ return l(s, { silent: !0 });
93
+ } };
52
94
  };
53
95
  export {
54
- rt as useSave
96
+ Ht as useSave
55
97
  };
@@ -0,0 +1,279 @@
1
+ import { getIgnoredRecommendationBlockIds as B } from "../config/compiler/utils/recommendationIgnoreUtils.js";
2
+ import { CanNotMakeAnyChangesForRunningKey as k, DISPLAY_CONDITIONS_REGEX as Y, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as x } from "../enums/html-validator.js";
3
+ import { SaveValidationRule as o } from "../enums/save-validation.js";
4
+ import { ToasterTypeOptions as r } from "../enums/toaster.js";
5
+ import { BLOCK_ROOT_SELECTOR as U } from "../extensions/Blocks/Checkbox/constants/selectors.js";
6
+ import { itemsBlockDynamicVariables as M } from "../extensions/Blocks/Items/enums/productEnums.js";
7
+ import { BLOCK_ROOT_SELECTOR as P } from "../extensions/Blocks/RadioButton/constants/selectors.js";
8
+ import { useRecommendationExtensionStore as W } from "../extensions/Blocks/Recommendation/store/recommendation.js";
9
+ import { RecommendationRequiredFieldsKey as G } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
10
+ import { useConfigStore as q } from "../stores/config.js";
11
+ import { useDynamicContentStore as H } from "../stores/dynamic-content.js";
12
+ import { useRecommendationStore as V } from "../stores/recommendation.js";
13
+ import { base64EncodeWithSpecialChars as T } from "../utils/base64.js";
14
+ import { useTemplatePreparation as X } from "../utils/templatePreparation.js";
15
+ import { useActionsApi as j } from "./useActionsApi.js";
16
+ import { useConfig as z } from "./useConfig.js";
17
+ import { useHtmlCompiler as $ } from "./useHtmlCompiler.js";
18
+ import { buildPartnerAttributeNameSet as Q, getInvalidDynamicContentTags as Z, getRecommendationBlockIds as J, findInvalidCustomFields as tt } from "./useHtmlValidator.js";
19
+ import { useHttp as et } from "./useHttp.js";
20
+ import { useTranslations as nt } from "./useTranslations.js";
21
+ import { findInvalidCouponBlocks as it, COUPON_TAG_MODIFIED_KEY as ot } from "./validators/useCouponBlockValidator.js";
22
+ import { findDuplicateUnsubPageTypes as rt, countUnsubBlocksWithoutPage as st, EMPTY_BLOCK_KEY as at } from "./validators/useUnsubscribeBlockValidator.js";
23
+ const ct = "newsletter.html-content-is-empty", lt = "custom-fields.missing-closing-braces", ut = "custom-fields.missing-opening-braces", I = "custom-fields.invalid-custom-fields", mt = "newsletter.display-conditions-invalid-syntax", dt = "custom-conditions.wrong-equality-operators", pt = "custom-conditions.missing-if-endif-tag", gt = "custom-conditions.no-space-after-braces", ft = "custom-conditions.no-braces-inside-if-tag", yt = "newsletter.fill-all-necessary-fields", Et = "newsletter.invalid-image-type", It = "unsubscribe-templates.select-checkbox-groups", St = "unsubscribe-templates.select-radio-button-groups", Ct = "newsletter.invalid-url-link-for-toaster", F = "journey-builder.liquid-validation-failed", _t = "/newsletter/template-library/check-template-html-body", ht = /src="[^"]*\.(svg|pst)"/gm, R = /({%(.*?)%})/g, kt = ["if", "endif", "else", "elif", "now"], Tt = (e) => !kt.includes(e.toLowerCase()), Ft = (e) => ["if", "endif"].includes(e.toLowerCase());
24
+ function Ot(e) {
25
+ return it(e).map((i) => ({
26
+ rule: o.CouponTagModified,
27
+ type: r.Warning,
28
+ key: ot,
29
+ detail: i
30
+ }));
31
+ }
32
+ function Rt(e) {
33
+ return rt(e).map((i) => ({
34
+ rule: o.DuplicateUnsubBlock,
35
+ type: r.Error,
36
+ key: i.messageKey
37
+ }));
38
+ }
39
+ function Lt(e) {
40
+ return Array.from({ length: st(e) }, () => ({
41
+ rule: o.UnsubBlockMissingTemplate,
42
+ type: r.Warning,
43
+ key: at
44
+ }));
45
+ }
46
+ function Nt(e, i) {
47
+ const n = e.match(R);
48
+ if (!n)
49
+ return [];
50
+ const a = [];
51
+ return n.forEach((u) => {
52
+ const s = u.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
53
+ if (s && s.length > 0) {
54
+ const [m] = s;
55
+ Tt(m) && !i.includes(m) && a.push({
56
+ rule: o.CustomFieldScript,
57
+ type: r.Warning,
58
+ key: I,
59
+ detail: m
60
+ });
61
+ }
62
+ }), a;
63
+ }
64
+ function bt(e) {
65
+ return e.length > 0 ? [] : [{ rule: o.EmptyHtml, type: r.Warning, key: ct }];
66
+ }
67
+ function At(e) {
68
+ const i = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
69
+ return i > n ? [{
70
+ rule: o.MismatchedBraces,
71
+ type: r.Warning,
72
+ key: lt
73
+ }] : i < n ? [{
74
+ rule: o.MismatchedBraces,
75
+ type: r.Warning,
76
+ key: ut
77
+ }] : [];
78
+ }
79
+ function Dt(e) {
80
+ return Z(e).map((i) => ({
81
+ rule: o.InvalidDynamicTag,
82
+ type: r.Warning,
83
+ key: I,
84
+ detail: i
85
+ }));
86
+ }
87
+ function vt(e, i, n, a) {
88
+ const u = J(e);
89
+ return tt(e, i, u, n, a).map((s) => ({
90
+ rule: o.InvalidCustomField,
91
+ type: r.Error,
92
+ key: I,
93
+ detail: s
94
+ }));
95
+ }
96
+ function Kt(e) {
97
+ const i = e.match(/{%(.*?)%}/g), n = [], a = [];
98
+ if (i && i.forEach((u) => {
99
+ const s = u.match(Y), m = u.match(x), y = (s == null ? void 0 : s.join("")) || "";
100
+ (!s || u !== y) && !m && a.push({
101
+ rule: o.ConditionsSyntax,
102
+ type: r.Error,
103
+ key: mt,
104
+ detail: u
105
+ }), s && s.forEach((g) => {
106
+ g.trim() === "=" && a.push({
107
+ rule: o.WrongEqualityOperator,
108
+ type: r.Error,
109
+ key: dt
110
+ }), (g.match(/^[a-zA-Z]*$/g) ?? []).forEach((f) => {
111
+ Ft(f) && n.push(f);
112
+ });
113
+ });
114
+ }), n.length) {
115
+ const u = n.filter((m) => m === "if").length, s = n.filter((m) => m === "endif").length;
116
+ u !== s && a.push({
117
+ rule: o.MissingIfEndif,
118
+ type: r.Error,
119
+ key: pt
120
+ });
121
+ }
122
+ return a;
123
+ }
124
+ function wt(e) {
125
+ const i = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length;
126
+ return i === n ? [] : [{
127
+ rule: o.ConditionTagSpacing,
128
+ type: r.Warning,
129
+ key: gt
130
+ }];
131
+ }
132
+ function Bt(e) {
133
+ return (e.match(R) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, a) => n + a, 0) === 0 ? [] : [{
134
+ rule: o.BracesInsideIfTag,
135
+ type: r.Warning,
136
+ key: ft
137
+ }];
138
+ }
139
+ function Yt(e) {
140
+ return (e.match(ht) ?? []).map((i) => ({
141
+ rule: o.InvalidImageType,
142
+ type: r.Error,
143
+ key: Et,
144
+ detail: i
145
+ }));
146
+ }
147
+ function O(e, i, n, a) {
148
+ const u = new DOMParser().parseFromString(e, "text/html");
149
+ return Array.from(u.querySelectorAll(i)).filter((s) => {
150
+ var m;
151
+ return !((m = s.id) != null && m.trim());
152
+ }).map(() => ({ rule: n, type: r.Error, key: a }));
153
+ }
154
+ const ae = () => {
155
+ const { config: e, isFeatureEnabled: i } = z(), n = nt(), { post: a } = et(), { getCompiledEmail: u, getTemplateData: s } = j(), { compileHtml: m } = $(), { hydrateRecommendationStore: y } = X(), g = H(), f = V(), E = W(), L = q(), N = (t) => ({
156
+ rule: t.rule,
157
+ type: t.type,
158
+ detail: t.detail,
159
+ message: "key" in t ? n(t.key) : t.message
160
+ }), b = async (t) => {
161
+ if (t.size === 0)
162
+ return /* @__PURE__ */ new Set();
163
+ try {
164
+ await E.fetchRecommendationFilters();
165
+ } catch {
166
+ return null;
167
+ }
168
+ return Q(E.filterList);
169
+ }, A = async (t) => {
170
+ try {
171
+ const l = await a(_t, { html: T(t) }), { status: c, message: d } = l.data, p = [];
172
+ return c || p.push({
173
+ rule: o.InvalidLinks,
174
+ type: r.Error,
175
+ // status===undefined means a bare message instead of a boolean; surface it,
176
+ // but fall back to the canned key when it's missing so a malformed body
177
+ // never renders a literal 'undefined' row (SD-147430).
178
+ ...c === void 0 && d ? { message: d } : { key: Ct }
179
+ }), d === n(k) && p.push({
180
+ rule: o.LinkCheckInProgress,
181
+ type: r.Error,
182
+ key: k
183
+ }), p;
184
+ } catch (l) {
185
+ return console.warn("Link-check collector failed; skipping the link rule.", l), [];
186
+ }
187
+ }, D = async (t) => {
188
+ try {
189
+ const l = await a("/newsletter/contents/validate-syntax", [{
190
+ identifier: "default",
191
+ syntax: "liquid",
192
+ contents: {
193
+ subject: null,
194
+ preheader: null,
195
+ html: T(t),
196
+ ampHtml: null
197
+ }
198
+ }]);
199
+ if (!Array.isArray(l.data)) {
200
+ const d = l.data;
201
+ return [{
202
+ rule: o.LiquidSyntax,
203
+ type: r.Warning,
204
+ message: d.message ?? n(F)
205
+ }];
206
+ }
207
+ const [c] = l.data;
208
+ return Object.values((c == null ? void 0 : c.errors) ?? {}).map((d) => ({
209
+ rule: o.LiquidSyntax,
210
+ type: r.Warning,
211
+ message: d.replace(/^line \d+:\s*/, "")
212
+ }));
213
+ } catch {
214
+ return [{
215
+ rule: o.LiquidSyntax,
216
+ type: r.Error,
217
+ message: n(F)
218
+ }];
219
+ }
220
+ }, v = () => {
221
+ const t = E.invalidBlockIds().map((c) => ({
222
+ rule: o.RecommendationRequiredFields,
223
+ type: r.Error,
224
+ key: G,
225
+ detail: c
226
+ })), l = (f.recommendationConfigs ?? []).filter((c) => c.filters.some((d) => d.value === "")).map(() => ({
227
+ rule: o.RecommendationFilters,
228
+ type: r.Error,
229
+ key: yt
230
+ }));
231
+ return [...t, ...l];
232
+ }, K = async (t, l) => {
233
+ var _, h;
234
+ const c = [
235
+ ...l.map((w) => w.value),
236
+ ...M,
237
+ ...((h = (_ = e.value) == null ? void 0 : _.template) == null ? void 0 : h.customFieldAttributes) ?? []
238
+ ], d = B(t), p = await b(d), { isTransactional: C } = L;
239
+ return [
240
+ ...await A(t),
241
+ ...C ? [] : Nt(t, c),
242
+ ...bt(t),
243
+ ...At(t),
244
+ ...Dt(t),
245
+ ...C ? [] : vt(t, c, d, p),
246
+ ...Kt(t),
247
+ ...wt(t),
248
+ ...Bt(t),
249
+ ...v(),
250
+ ...Yt(t),
251
+ ...O(
252
+ t,
253
+ U,
254
+ o.CheckboxUnsubGroup,
255
+ It
256
+ ),
257
+ ...O(
258
+ t,
259
+ P,
260
+ o.RadioButtonUnsubGroup,
261
+ St
262
+ )
263
+ ];
264
+ }, S = async (t, l) => [
265
+ ...Ot(t),
266
+ ...Rt(t),
267
+ ...Lt(t),
268
+ ...i("liquidSyntax") ? await D(t) : await K(t, l)
269
+ ].map(N);
270
+ return { collectSaveValidationErrors: S, validateCurrentTemplate: async () => {
271
+ const { html: t } = await s();
272
+ await y(t);
273
+ const { html: l } = await u({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: c } = m(l);
274
+ return S(c, g.getSelectedDynamicContentList);
275
+ } };
276
+ };
277
+ export {
278
+ ae as useSaveValidation
279
+ };
@@ -0,0 +1,9 @@
1
+ import { useConfigStore as t } from "../stores/config.js";
2
+ import { computed as o } from "vue";
3
+ const n = ["newsletteruatcamp", "newsletterqacamp"], c = () => {
4
+ const e = t();
5
+ return { isEnabled: o(() => n.includes(e.partnerName)) };
6
+ };
7
+ export {
8
+ c as useSaveValidationRollout
9
+ };
@@ -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
  };