@useinsider/guido 3.17.0-beta.77567eb → 3.17.0-beta.7c9fc24

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 (123) hide show
  1. package/README.md +2 -0
  2. package/dist/@types/config/schemas.js +33 -30
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +85 -77
  5. package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
  7. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +106 -0
  8. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.js +17 -0
  9. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +57 -0
  10. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  11. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
  12. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  13. package/dist/components/organisms/header/EditorActions.vue2.js +74 -43
  14. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  15. package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
  16. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
  17. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +48 -0
  18. package/dist/components/wrappers/WpDrawer.vue.js +9 -7
  19. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  20. package/dist/composables/useCustomInterfaceAppearance.js +52 -38
  21. package/dist/composables/useHtmlCompiler.js +37 -26
  22. package/dist/composables/useHtmlValidator.js +2 -0
  23. package/dist/composables/useRecommendation.js +41 -34
  24. package/dist/composables/useSave.js +84 -41
  25. package/dist/composables/useSaveValidation.js +279 -0
  26. package/dist/composables/useSaveValidationRollout.js +9 -0
  27. package/dist/composables/useStripo.js +14 -14
  28. package/dist/composables/validators/useCouponBlockValidator.js +24 -21
  29. package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
  30. package/dist/config/i18n/en/labels.json.js +1 -1
  31. package/dist/config/migrator/index.js +9 -8
  32. package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
  33. package/dist/config/migrator/recommendation/extractors.js +29 -24
  34. package/dist/config/migrator/recommendation/htmlBuilder.js +116 -130
  35. package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
  36. package/dist/config/migrator/recommendationMigrator.js +31 -25
  37. package/dist/config/migrator/recommendationTitleMigrator.js +119 -0
  38. package/dist/enums/academy.js +2 -1
  39. package/dist/enums/date.js +5 -3
  40. package/dist/enums/extensions/recommendationBlock.js +3 -1
  41. package/dist/enums/save-validation.js +4 -0
  42. package/dist/extensions/Blocks/Recommendation/block.js +35 -29
  43. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  44. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  45. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +29 -27
  46. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +35 -28
  47. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +309 -236
  48. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +241 -180
  49. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
  50. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +1 -0
  51. package/dist/extensions/Blocks/Recommendation/controls/title/index.js +44 -0
  52. package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
  53. package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
  54. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +23 -4
  55. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +182 -79
  56. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  57. package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +33 -0
  58. package/dist/extensions/Blocks/Recommendation/templates/utils.js +85 -107
  59. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +22 -0
  60. package/dist/extensions/Blocks/common-control.js +22 -19
  61. package/dist/guido.css +1 -1
  62. package/dist/package.json.js +1 -1
  63. package/dist/services/recommendationApi.js +69 -30
  64. package/dist/src/@types/config/schemas.d.ts +6 -0
  65. package/dist/src/@types/save-validation.d.ts +19 -0
  66. package/dist/src/components/Guido.vue.d.ts +17 -1
  67. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  68. package/dist/src/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.d.ts +2 -0
  69. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
  70. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
  71. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
  72. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
  73. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
  74. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
  75. package/dist/src/composables/useConfig.d.ts +4 -0
  76. package/dist/src/composables/useHtmlValidator.d.ts +21 -0
  77. package/dist/src/composables/useRecommendation.d.ts +1 -0
  78. package/dist/src/composables/useSave.d.ts +6 -1
  79. package/dist/src/composables/useSaveValidation.d.ts +6 -0
  80. package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
  81. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  82. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
  83. package/dist/src/config/migrator/recommendation/extractors.d.ts +8 -0
  84. package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +5 -0
  85. package/dist/src/enums/academy.d.ts +1 -0
  86. package/dist/src/enums/date.d.ts +1 -0
  87. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  88. package/dist/src/enums/save-validation.d.ts +27 -0
  89. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
  90. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -0
  91. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +3 -6
  92. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  93. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -0
  94. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +11 -0
  95. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
  96. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +44 -8
  97. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
  98. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +1 -0
  99. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +86 -0
  100. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
  101. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +181 -10
  102. package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +13 -0
  103. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +7 -0
  104. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +31 -0
  105. package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
  106. package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
  107. package/dist/src/services/recommendationApi.d.ts +4 -1
  108. package/dist/src/stores/config.d.ts +48 -0
  109. package/dist/src/stores/save-as-template.d.ts +4 -3
  110. package/dist/src/stores/save-validation.d.ts +22 -0
  111. package/dist/src/utils/genericUtil.d.ts +5 -0
  112. package/dist/src/utils/templatePreparation.d.ts +30 -0
  113. package/dist/static/assets/icons/line-change.svg.js +5 -0
  114. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  115. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  116. package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
  117. package/dist/static/styles/customEditorStyle.css.js +3 -1
  118. package/dist/stores/config.js +39 -22
  119. package/dist/stores/save-validation.js +30 -0
  120. package/dist/utils/dateUtil.js +23 -10
  121. package/dist/utils/genericUtil.js +28 -27
  122. package/dist/utils/templatePreparation.js +46 -42
  123. package/package.json +3 -2
@@ -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,22 +1,22 @@
1
- import { getRecommendationFeedSourceMaps as I, URLS as R } from "../enums/extensions/recommendationBlock.js";
2
- import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommendation.js";
1
+ import { getRecommendationFeedSourceMaps as y, URLS as I } from "../enums/extensions/recommendationBlock.js";
2
+ import { MinDeviceViewport as C, DefaultPadding as R } from "../enums/recommendation.js";
3
3
  import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
- import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
- import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
4
+ import { generateCompleteFilterQuery as b } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
+ import { getPartnerRecommendationParams as h } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
6
6
  import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
7
7
  import { useConfigStore as P } from "../stores/config.js";
8
8
  const B = () => ({
9
9
  calculateCardWidth: ({
10
- mobileLeftPadding: a,
11
- mobileRightPadding: s,
12
- cardsInRow: c,
10
+ mobileLeftPadding: i,
11
+ mobileRightPadding: c,
12
+ cardsInRow: s,
13
13
  unresponsive: n
14
14
  }) => {
15
- const r = n ? c : 1, e = a + s + (r - 1) * b;
16
- return (C - e) / r;
15
+ const o = n ? s : 1, e = i + c + (o - 1) * R;
16
+ return (C - e) / o;
17
17
  },
18
- getRecommendationCampaignData: (a) => {
19
- const s = l(), c = Number(a), n = s.blockStates[c];
18
+ getRecommendationCampaignData: (i) => {
19
+ const c = l(), s = Number(i), n = c.blockStates[s];
20
20
  if (!n)
21
21
  return {
22
22
  textTrimming: !1,
@@ -30,47 +30,54 @@ const B = () => ({
30
30
  discountBeforeTextValue: "",
31
31
  discountAfterTextValue: ""
32
32
  };
33
- const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
33
+ const { recommendationConfigs: o } = n, e = o.orientation === "grid" ? "vertical" : "horizontal";
34
34
  return {
35
- textTrimming: r.textTrimming,
35
+ textTrimming: o.textTrimming,
36
36
  orientation: e,
37
37
  mobileLeftPadding: 0,
38
38
  mobileRightPadding: 0,
39
- cardsInRow: r.cardsInRow,
40
- unresponsive: r.unresponsive,
39
+ cardsInRow: o.cardsInRow,
40
+ unresponsive: o.unresponsive,
41
41
  priceBeforeTextValue: "",
42
42
  priceAfterTextValue: "",
43
43
  discountBeforeTextValue: "",
44
44
  discountAfterTextValue: ""
45
45
  };
46
46
  },
47
- buildCampaignUrl: (a, s) => {
47
+ buildCampaignUrl: (i, c) => {
48
48
  var m;
49
- const c = l(), n = P(), r = Number(a);
49
+ const s = l(), n = P(), o = Number(i);
50
50
  let e;
51
- if (s)
52
- e = s;
51
+ if (c)
52
+ e = c;
53
53
  else {
54
- const i = c.blockStates[r];
55
- if (!i)
54
+ const a = s.blockStates[o];
55
+ if (!a)
56
56
  return "";
57
- const { recommendationConfigs: o } = i;
57
+ const { recommendationConfigs: r } = a;
58
58
  e = {
59
- strategy: o.strategy,
60
- language: o.language,
61
- currencyCode: o.currencySettings.value,
62
- size: o.size,
63
- productIds: o.productIds,
64
- filters: o.filters,
65
- shuffleProducts: o.shuffleProducts
59
+ strategy: r.strategy,
60
+ strategyId: r.strategyId,
61
+ language: r.language,
62
+ currencyCode: r.currencySettings.value,
63
+ size: r.size,
64
+ productIds: r.productIds,
65
+ filters: r.filters,
66
+ shuffleProducts: r.shuffleProducts
66
67
  };
67
68
  }
68
- const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
69
+ if (e.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy"))
70
+ return s.recommendationCampaignUrls[i] = {
71
+ strategyId: e.strategyId,
72
+ locale: e.language,
73
+ currency: e.currencyCode
74
+ }, "";
75
+ const g = ((m = y().find((a) => a.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
69
76
  t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
70
- const g = e.filters.filter((i) => i.isValid), d = h(g);
71
- d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(n.partnerName, e.strategy)).forEach(([i, o]) => t.set(i, o));
72
- const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
73
- return c.recommendationCampaignUrls[a] = u, u;
77
+ const f = e.filters.filter((a) => a.isValid), d = b(f);
78
+ d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(h(n.partnerName, e.strategy)).forEach(([a, r]) => t.set(a, r));
79
+ const p = decodeURIComponent(t.toString()), u = `${I.RECOMMENDATION_API_URL}/v2/${g}?${p}`;
80
+ return s.recommendationCampaignUrls[i] = u, u;
74
81
  }
75
82
  });
76
83
  export {
@@ -1,51 +1,94 @@
1
- import { useActionsApi as T } from "./useActionsApi.js";
2
- import { useConfig as k } from "./useConfig.js";
3
- import { useSaveStart as B, useSaveComplete as E } from "./useGuidoActions.js";
4
- import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
5
- import { ToasterTypeOptions as C } from "../enums/toaster.js";
1
+ import { useActionsApi as U } from "./useActionsApi.js";
2
+ import { useConfig as L } from "./useConfig.js";
3
+ import { useSaveStart as A, useSaveComplete as q } from "./useGuidoActions.js";
4
+ import { useSaveValidation as M } from "./useSaveValidation.js";
5
+ import { useSaveValidationRollout as R } from "./useSaveValidationRollout.js";
6
+ import { useSyncModuleExtractor as W } from "./useSyncModuleExtractor.js";
7
+ import { ToasterTypeOptions as O } from "../enums/toaster.js";
6
8
  import { useStripoApi as D } from "../services/stripoApi.js";
7
- import { useTemplatePreparation as L } from "../utils/templatePreparation.js";
8
- import { useAllowlist as P } from "./useAllowlist.js";
9
- import { useHtmlValidator as U } from "./useHtmlValidator.js";
10
- import { useToaster as A } from "./useToaster.js";
11
- import { useCouponBlockValidator as M } from "./validators/useCouponBlockValidator.js";
12
- import { useLiquidValidator as h } from "./validators/useLiquidValidator.js";
13
- import { useUnsubscribeBlockValidator as F } from "./validators/useUnsubscribeBlockValidator.js";
14
- const $ = () => {
15
- const n = B(), l = E(), { validateHtml: c } = U(), { validateLiquidSyntax: d } = h(), { validateCouponBlockTags: m } = M(), { validateUnsubscribeBlockUniqueness: u, validateUnsubscribeBlockHasTemplate: p } = F(), { callbacks: e, isFeatureEnabled: a } = k(), { extractSyncModuleData: f } = q(), { setSyncModuleUnsubscriptionPages: v } = D(), { editorSave: S } = T(), { showToaster: b } = A(), { getBlockedDomains: w, resolveToast: V } = P();
16
- return { save: async (y = !1, s = !1) => {
17
- var r;
18
- n();
19
- const { prepareTemplateDetails: H } = L(), t = await H();
20
- if (!m(t.compiledHtml) || !u(t.compiledHtml) || !p(t.compiledHtml))
9
+ import { useConfigStore as F } from "../stores/config.js";
10
+ import { useDynamicContentStore as j } from "../stores/dynamic-content.js";
11
+ import { useSaveValidationStore as z } from "../stores/save-validation.js";
12
+ import { useTemplatePreparation as G, getHtmlReferencedUnsubscribePages as I } from "../utils/templatePreparation.js";
13
+ import { useAllowlist as J } from "./useAllowlist.js";
14
+ import { useHtmlValidator as K } from "./useHtmlValidator.js";
15
+ import { useToaster as N } from "./useToaster.js";
16
+ import { useCouponBlockValidator as Q } from "./validators/useCouponBlockValidator.js";
17
+ import { useLiquidValidator as X } from "./validators/useLiquidValidator.js";
18
+ import { useUnsubscribeBlockValidator as Y } from "./validators/useUnsubscribeBlockValidator.js";
19
+ const wt = () => {
20
+ const r = A(), u = q(), { validateHtml: d } = K(), { validateLiquidSyntax: f } = X(), { validateCouponBlockTags: p } = Q(), { validateUnsubscribeBlockUniqueness: v, validateUnsubscribeBlockHasTemplate: S } = Y(), { callbacks: a, isFeatureEnabled: c } = L(), { extractSyncModuleData: y } = W(), { setSyncModuleUnsubscriptionPages: w } = D(), { editorSave: b, getTemplateData: g } = U(), { showToaster: H } = N(), { getBlockedDomains: V, resolveToast: E } = J(), { prepareTemplateDetails: m } = G(), { collectSaveValidationErrors: C } = M(), { isEnabled: x } = R(), k = z(), B = j(), T = F(), n = async (t, e, o) => {
21
+ if (!c("allowlistEnabled"))
22
+ return !1;
23
+ const i = await V(t, e);
24
+ if (!i.length)
25
+ return !1;
26
+ if (!o) {
27
+ const s = await E(i);
28
+ s != null && s.message && H({
29
+ type: O.Warning,
30
+ message: s.message,
31
+ actionButton: s.actionButton
32
+ });
33
+ }
34
+ return !0;
35
+ }, P = async (t) => !p(t.compiledHtml) || !v(t.compiledHtml) || !S(t.compiledHtml) ? !1 : c("liquidSyntax") ? f(t.compiledHtml) : d(t.compiledHtml, t.dynamicContentList, !0), l = async (t, e) => {
36
+ if (!await b())
21
37
  return;
22
- if (a("liquidSyntax")) {
23
- if (!await d(t.compiledHtml))
38
+ const { unsubscribePayload: i, stripoModules: s } = y(t.rawHtml);
39
+ if (await w(i), t.modules = s, !e.suppress) {
40
+ const h = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
41
+ u({ ...t, ...h, silent: e.silent });
42
+ }
43
+ return t;
44
+ };
45
+ return { save: async (t = !1, e = !1) => {
46
+ var i;
47
+ r();
48
+ const o = await m();
49
+ if (x.value && !e) {
50
+ const s = await C(
51
+ o.compiledHtml,
52
+ o.dynamicContentList
53
+ );
54
+ if (s.length) {
55
+ k.open(s, "save");
24
56
  return;
25
- } else if (!await c(t.compiledHtml, t.dynamicContentList, !0))
57
+ }
58
+ } else if (!await P(o))
26
59
  return;
27
- if ((r = e.value) != null && r.externalValidation && !await e.value.externalValidation(t))
60
+ if (!((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(o)) && !await n(o.compiledHtml, o.css, e))
61
+ return l(o, { silent: e, suppress: t });
62
+ }, saveWithErrors: async () => {
63
+ var e;
64
+ if (!T.allowSaveWithErrors)
28
65
  return;
29
- if (a("allowlistEnabled")) {
30
- const i = await w(t.compiledHtml, t.css);
31
- if (i.length) {
32
- if (!s) {
33
- const o = await V(i);
34
- o != null && o.message && b({
35
- type: C.Warning,
36
- message: o.message,
37
- actionButton: o.actionButton
38
- });
39
- }
40
- return;
41
- }
42
- }
43
- if (!await S())
66
+ r();
67
+ const t = await m();
68
+ if (!((e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t)) && !await n(t.compiledHtml, t.css, !1))
69
+ return l(t, { silent: !1, blankCompiled: !0 });
70
+ }, saveRawOnly: async () => {
71
+ r();
72
+ const { html: t, css: e } = await g();
73
+ if (await n(t, e, !0))
44
74
  return;
45
- const { unsubscribePayload: g, stripoModules: x } = f(t.rawHtml);
46
- return await v(g), t.modules = x, y || l({ ...t, silent: s }), t;
75
+ const o = I(t), i = {
76
+ dynamicContentList: B.getSelectedDynamicContentList,
77
+ compiledHtml: "",
78
+ rawHtml: t,
79
+ css: e,
80
+ ampHtml: "",
81
+ ampErrors: [],
82
+ modules: [],
83
+ recommendation: { campaignUrls: {}, configs: {} },
84
+ unsubscribe: {
85
+ status: o.length > 0,
86
+ config: o
87
+ }
88
+ };
89
+ return l(i, { silent: !0 });
47
90
  } };
48
91
  };
49
92
  export {
50
- $ as useSave
93
+ wt as useSave
51
94
  };
@@ -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
+ };