@useinsider/guido 3.24.0-beta.89982ef → 3.24.0-beta.9a847f0

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 (84) hide show
  1. package/README.md +1 -1
  2. package/dist/@types/config/schemas.js +47 -47
  3. package/dist/components/Guido.vue.js +2 -2
  4. package/dist/components/Guido.vue2.js +92 -98
  5. package/dist/composables/useActionsApi.js +2 -2
  6. package/dist/composables/useBlocksConfig.js +20 -31
  7. package/dist/composables/useEditorTrackingIds.js +49 -0
  8. package/dist/composables/useSave.js +57 -52
  9. package/dist/composables/useSaveValidation.js +118 -110
  10. package/dist/composables/useTranslations.js +1 -2
  11. package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
  12. package/dist/config/compiler/utils/itemsCompilerUtils.js +42 -43
  13. package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -67
  14. package/dist/enums/academy.js +0 -1
  15. package/dist/enums/save-validation.js +1 -1
  16. package/dist/guido.css +1 -1
  17. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
  18. package/dist/node_modules/valibot/dist/index.js +261 -297
  19. package/dist/package.json.js +2 -2
  20. package/dist/services/templateLibraryApi.js +39 -36
  21. package/dist/src/@types/config/schemas.d.ts +4 -4
  22. package/dist/src/composables/useConfig.d.ts +2 -2
  23. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  24. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  25. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
  26. package/dist/src/enums/academy.d.ts +0 -1
  27. package/dist/src/enums/save-validation.d.ts +2 -1
  28. package/dist/src/stores/config.d.ts +20 -167
  29. package/dist/src/utils/linkTrackingIds.d.ts +24 -22
  30. package/dist/static/styles/variables.css.js +0 -1
  31. package/dist/stores/config.js +6 -13
  32. package/dist/utils/linkTrackingIds.js +72 -72
  33. package/dist/utils/pairProductVariables.js +29 -30
  34. package/dist/utils/templatePreparation.js +59 -72
  35. package/package.json +1 -1
  36. package/dist/@types/display-condition.js +0 -25
  37. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -17
  38. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -41
  39. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
  40. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -81
  41. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +0 -17
  42. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +0 -45
  43. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -36
  44. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -63
  45. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
  46. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
  47. package/dist/composables/useDisplayConditions.js +0 -117
  48. package/dist/enums/display-condition.js +0 -12
  49. package/dist/extensions/DisplayConditions/bridge.js +0 -25
  50. package/dist/extensions/DisplayConditions/constants.js +0 -26
  51. package/dist/extensions/DisplayConditions/control.js +0 -215
  52. package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -226
  53. package/dist/extensions/DisplayConditions/extension.js +0 -28
  54. package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
  55. package/dist/extensions/DisplayConditions/library.js +0 -30
  56. package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
  57. package/dist/extensions/LinkTracking/extension.js +0 -17
  58. package/dist/extensions/LinkTracking/writer.js +0 -41
  59. package/dist/services/displayConditionApi.js +0 -39
  60. package/dist/src/@types/display-condition.d.ts +0 -61
  61. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
  62. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +0 -2
  63. package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +0 -18
  64. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
  65. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
  66. package/dist/src/composables/useDisplayConditions.d.ts +0 -18
  67. package/dist/src/enums/display-condition.d.ts +0 -15
  68. package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -7
  69. package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -23
  70. package/dist/src/extensions/DisplayConditions/control.d.ts +0 -25
  71. package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
  72. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
  73. package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
  74. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
  75. package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
  76. package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
  77. package/dist/src/mock/api/display-conditions.d.ts +0 -2
  78. package/dist/src/services/displayConditionApi.d.ts +0 -8
  79. package/dist/src/stores/display-condition.d.ts +0 -86
  80. package/dist/src/utils/displayCondition.d.ts +0 -11
  81. package/dist/src/utils/protectTableText.d.ts +0 -2
  82. package/dist/stores/display-condition.js +0 -29
  83. package/dist/utils/displayCondition.js +0 -29
  84. package/dist/utils/protectTableText.js +0 -22
@@ -1,7 +1,6 @@
1
- import s from "../extensions/LinkTracking/extension.js";
2
- import l from "../extensions/ModulesTabIcons/extension.js";
3
- import { useConfigStore as r } from "../stores/config.js";
4
- const c = {
1
+ import r from "../extensions/ModulesTabIcons/extension.js";
2
+ import { useConfigStore as l } from "../stores/config.js";
3
+ const a = {
5
4
  "amp-accordion": "ampAccordionEnabled",
6
5
  "amp-carousel": "ampCarouselEnabled",
7
6
  "amp-form-controls": "ampFormControlsEnabled",
@@ -15,7 +14,7 @@ const c = {
15
14
  "text-block": "textEnabled",
16
15
  "timer-block": "timerEnabled",
17
16
  "video-block": "videoEnabled"
18
- }, b = {
17
+ }, s = {
19
18
  "dynamic-content": () => import("../extensions/DynamicContent/extension.js"),
20
19
  "checkbox-block": () => import("../extensions/Blocks/Checkbox/extension.js"),
21
20
  "radio-button-block": () => import("../extensions/Blocks/RadioButton/extension.js"),
@@ -23,50 +22,40 @@ const c = {
23
22
  "unsubscribe-block": () => import("../extensions/Blocks/Unsubscribe/extension.js"),
24
23
  "coupon-block": () => import("../extensions/Blocks/CouponBlock/extension.js"),
25
24
  "items-block": () => import("../extensions/Blocks/Items/extension.js")
26
- }, m = (n) => {
25
+ }, i = (n) => {
27
26
  if (!n || !n.length)
28
27
  return {};
29
28
  const t = {};
30
29
  return n.forEach((o) => {
31
- const e = c[o];
30
+ const e = a[o];
32
31
  e && (t[e] = !1);
33
32
  }), t;
34
- }, d = async ({ externalDisplayConditions: n, linkTrackingIds: t }) => {
35
- const o = [l];
36
- if (n) {
37
- const e = await import("../extensions/DisplayConditions/extension.js");
38
- o.push(e.default);
39
- }
40
- return t && o.push(s), o;
41
- }, p = async (n, t = { externalDisplayConditions: !1, linkTrackingIds: !1 }) => {
42
- const o = await d(t);
33
+ }, b = () => [r], m = async (n) => {
34
+ const t = b();
43
35
  if (!n || !n.length)
44
- return o;
45
- const e = await Promise.all(
46
- n.map(async (i) => {
47
- const a = b[i];
48
- return a ? (await a()).default : null;
36
+ return t;
37
+ const o = await Promise.all(
38
+ n.map(async (e) => {
39
+ const c = s[e];
40
+ return c ? (await c()).default : null;
49
41
  })
50
42
  );
51
43
  return [
52
- ...o,
53
- ...e.filter((i) => i !== null)
44
+ ...t,
45
+ ...o.filter((e) => e !== null)
54
46
  ];
55
- }, g = () => {
56
- const n = r();
47
+ }, E = () => {
48
+ const n = l();
57
49
  return {
58
50
  getStripoBlocksConfig: async () => {
59
51
  const o = n.blocks;
60
52
  return {
61
- baseBlocks: m(o == null ? void 0 : o.excludeDefaults),
62
- extensions: await p(o == null ? void 0 : o.includeCustoms, {
63
- externalDisplayConditions: n.externalDisplayConditions,
64
- linkTrackingIds: n.isFeatureEnabled("linkTrackingIds")
65
- })
53
+ baseBlocks: i(o == null ? void 0 : o.excludeDefaults),
54
+ extensions: await m(o == null ? void 0 : o.includeCustoms)
66
55
  };
67
56
  }
68
57
  };
69
58
  };
70
59
  export {
71
- g as useBlocksConfig
60
+ E as useBlocksConfig
72
61
  };
@@ -0,0 +1,49 @@
1
+ import { TRACK_ID_ATTRIBUTE as u, writeAnchorTrackIds as I, TRACK_SEQ_ATTRIBUTE as f, planTrackingIds as h, parseTrackSeq as w, readAnchorTrackIds as k } from "../utils/linkTrackingIds.js";
2
+ import { getEditorApi as A } from "../utils/stripoEditorApi.js";
3
+ import { ModificationDescription as x } from "../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
4
+ function T(t, r = []) {
5
+ const o = t.getType();
6
+ if (o === "comment") {
7
+ const e = t.getTextContent() ?? "", i = k(e);
8
+ return i.length && r.push({ kind: "comment", node: t, text: e, rawIds: i }), r;
9
+ }
10
+ if (o === "element") {
11
+ const e = t;
12
+ e.getTagName().toLowerCase() === "a" && r.push({ kind: "element", node: e, rawIds: [e.getAttribute(u) ?? ""] });
13
+ }
14
+ return t.childNodes().forEach((e) => T(e, r)), r;
15
+ }
16
+ function y(t, r) {
17
+ if (!t)
18
+ throw new Error("The editor exposes no editorCopilotApi.");
19
+ const o = t.getDocumentRootHtmlNode(), e = o.querySelector("body");
20
+ if (!e)
21
+ throw new Error("The editor document has no <body> to record tracking ids on.");
22
+ const i = T(o), s = h(
23
+ i.flatMap((d) => d.rawIds),
24
+ w(e.getAttribute(f)),
25
+ r
26
+ );
27
+ return { api: t, seqHost: e, hosts: i, plan: s };
28
+ }
29
+ const H = () => ({ writeTrackingIds: (r) => {
30
+ const { editorCopilotApi: o } = A();
31
+ let e;
32
+ try {
33
+ e = y(o, r);
34
+ } catch (n) {
35
+ return console.warn("Tracking ids skipped for this save:", n), { changed: !1, nextSeq: r };
36
+ }
37
+ const { api: i, seqHost: s, hosts: d, plan: c } = e;
38
+ if (!c.changed)
39
+ return { changed: !1, nextSeq: c.nextSeq };
40
+ const a = i.getTemplateModifier();
41
+ let l = 0;
42
+ return d.forEach((n) => {
43
+ const m = n.rawIds.map((p, g) => c.reassigned[l + g] ? c.ids[l + g] : null);
44
+ l += n.rawIds.length, !m.every((p) => p === null) && (n.kind === "element" ? a.modifyHtml(n.node).setAttribute(u, String(m[0])) : a.modifyHtml(n.node).replaceWith(`<!--${I(n.text, m)}-->`));
45
+ }), a.modifyHtml(s).setAttribute(f, String(c.nextSeq)), a.apply(new x("Updated Insider tracking IDs").asHidden()), { changed: !0, nextSeq: c.nextSeq };
46
+ } });
47
+ export {
48
+ H as useEditorTrackingIds
49
+ };
@@ -1,91 +1,96 @@
1
- import { useActionsApi as q } from "./useActionsApi.js";
2
- import { useConfig as O } from "./useConfig.js";
3
- import { useEditorLock as D } from "./useEditorLock.js";
4
- import { useSaveStart as F, useSaveComplete as j } from "./useGuidoActions.js";
5
- import { useSaveValidation as z } from "./useSaveValidation.js";
6
- import { useSaveValidationRollout as G } from "./useSaveValidationRollout.js";
7
- import { useSyncModuleExtractor as I } from "./useSyncModuleExtractor.js";
1
+ import { useActionsApi as O } from "./useActionsApi.js";
2
+ import { useConfig as D } from "./useConfig.js";
3
+ import { useEditorLock as F } from "./useEditorLock.js";
4
+ import { useSaveStart as I, useSaveComplete as N } from "./useGuidoActions.js";
5
+ import { useSaveValidation as j } from "./useSaveValidation.js";
6
+ import { useSaveValidationRollout as z } from "./useSaveValidationRollout.js";
7
+ import { useSyncModuleExtractor as G } from "./useSyncModuleExtractor.js";
8
8
  import { ToasterTypeOptions as J } from "../enums/toaster.js";
9
9
  import { useStripoApi as K } from "../services/stripoApi.js";
10
- import { useConfigStore as N } from "../stores/config.js";
11
- import { useDynamicContentStore as Q } from "../stores/dynamic-content.js";
12
- import { useSaveValidationStore as X } from "../stores/save-validation.js";
13
- import { useTemplatePreparation as Y, getHtmlReferencedUnsubscribePages as Z } from "../utils/templatePreparation.js";
14
- import { useAllowlist as _ } from "./useAllowlist.js";
15
- import { useHtmlValidator as $ } from "./useHtmlValidator.js";
16
- import { useToaster as tt } from "./useToaster.js";
17
- import { useCouponBlockValidator as et } from "./validators/useCouponBlockValidator.js";
18
- import { useHtmlDocumentCountValidator as ot } from "./validators/useHtmlDocumentCountValidator.js";
19
- import { useLiquidValidator as it } from "./validators/useLiquidValidator.js";
20
- import { useSyncModuleBlockValidator as st } from "./validators/useSyncModuleBlockValidator.js";
10
+ import { useConfigStore as Q } from "../stores/config.js";
11
+ import { useDynamicContentStore as X } from "../stores/dynamic-content.js";
12
+ import { useSaveValidationStore as Y } from "../stores/save-validation.js";
13
+ import { useTemplatePreparation as Z, getHtmlReferencedUnsubscribePages as _ } from "../utils/templatePreparation.js";
14
+ import { useAllowlist as $ } from "./useAllowlist.js";
15
+ import { useHtmlValidator as tt } from "./useHtmlValidator.js";
16
+ import { useToaster as et } from "./useToaster.js";
17
+ import { useCouponBlockValidator as ot } from "./validators/useCouponBlockValidator.js";
18
+ import { useHtmlDocumentCountValidator as it } from "./validators/useHtmlDocumentCountValidator.js";
19
+ import { useLiquidValidator as st } from "./validators/useLiquidValidator.js";
20
+ import { useSyncModuleBlockValidator as rt } from "./validators/useSyncModuleBlockValidator.js";
21
21
  import { useUnsubscribeBlockValidator as at } from "./validators/useUnsubscribeBlockValidator.js";
22
22
  const Pt = () => {
23
- const n = F(), w = j(), { validateHtml: y } = $(), { validateLiquidSyntax: E } = it(), { validateCouponBlockTags: b } = et(), { validateUnsubscribeBlockUniqueness: g, validateUnsubscribeBlockHasTemplate: H } = at(), { validateSyncModuleBlocks: l } = st(), { validateSingleHtmlDocument: c } = ot(), { callbacks: r, isFeatureEnabled: v } = O(), { extractSyncModuleData: V } = I(), { setSyncModuleUnsubscriptionPages: x } = K(), { editorSave: C, getTemplateData: u } = q(), { showToaster: k } = tt(), { getBlockedDomains: h, resolveToast: B } = _(), { prepareTemplateDetails: p } = Y(), { collectSaveValidationErrors: T } = z(), { isEnabled: P } = G(), L = X(), U = Q(), S = N(), { runExclusive: m } = D(), d = async (t, e, i) => {
24
- if (!v("allowlistEnabled"))
23
+ const n = I(), S = N(), { validateHtml: y } = tt(), { validateLiquidSyntax: b } = st(), { validateCouponBlockTags: H } = ot(), {
24
+ validateUnsubscribeBlockUniqueness: E,
25
+ validateUnsubscribeBlockHasTemplate: g,
26
+ validateNoInsiderUnsubscribeCode: V
27
+ } = at(), { validateSyncModuleBlocks: l } = rt(), { validateSingleHtmlDocument: c } = it(), { callbacks: a, isFeatureEnabled: u } = D(), { extractSyncModuleData: x } = G(), { setSyncModuleUnsubscriptionPages: k } = K(), { editorSave: C, getTemplateData: m } = O(), { showToaster: h } = et(), { getBlockedDomains: B, resolveToast: T } = $(), { prepareTemplateDetails: p } = Z(), { collectSaveValidationErrors: L } = j(), { isEnabled: P } = z(), U = Y(), A = X(), w = Q(), { runExclusive: d } = F(), f = async (t, e, i) => {
28
+ if (!u("allowlistEnabled"))
25
29
  return !1;
26
- const o = await h(t, e);
30
+ const o = await B(t, e);
27
31
  if (!o.length)
28
32
  return !1;
29
33
  if (!i) {
30
- const s = await B(o);
31
- s != null && s.message && k({
34
+ const s = await T(o);
35
+ s != null && s.message && h({
32
36
  type: J.Warning,
33
37
  message: s.message,
34
38
  actionButton: s.actionButton
35
39
  });
36
40
  }
37
41
  return !0;
38
- }, A = async (t) => !b(t.compiledHtml) || !g(t.compiledHtml) || !H(t.compiledHtml) ? !1 : v("liquidSyntax") ? E(t.compiledHtml) : y(t.compiledHtml, t.dynamicContentList, !0), f = async (t, e) => {
42
+ }, M = async (t, e) => !H(t.compiledHtml) || u("blockUnsubscribeLinks") && !V(t.rawHtml, e) || !E(t.compiledHtml) || !g(t.compiledHtml) ? !1 : u("liquidSyntax") ? b(t.compiledHtml) : y(t.compiledHtml, t.dynamicContentList, !0), v = async (t, e) => {
39
43
  if (!await C())
40
44
  return;
41
- const { unsubscribePayload: o, stripoModules: s } = V(t.rawHtml);
42
- if (await x(o), t.modules = s, !e.suppress) {
43
- const a = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
44
- w({ ...t, ...a, silent: e.silent });
45
+ const { unsubscribePayload: o, stripoModules: s } = x(t.rawHtml);
46
+ if (await k(o), t.modules = s, !e.suppress) {
47
+ const r = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
48
+ S({ ...t, ...r, silent: e.silent });
45
49
  }
46
50
  return t;
47
- }, M = async (t, e) => {
51
+ }, W = async (t, e) => {
48
52
  var s;
49
53
  n();
50
- const i = await u();
54
+ const i = await m();
51
55
  if (!c(i.html, e))
52
56
  return;
53
57
  const o = await p(i);
54
58
  if (l(o.rawHtml, e)) {
55
59
  if (P.value && !e) {
56
- const a = await T(
60
+ const r = await L(
57
61
  o.compiledHtml,
58
- o.dynamicContentList
62
+ o.dynamicContentList,
63
+ o.rawHtml
59
64
  );
60
- if (a.length) {
61
- L.open(a, "save");
65
+ if (r.length) {
66
+ U.open(r, "save");
62
67
  return;
63
68
  }
64
- } else if (!await A(o))
69
+ } else if (!await M(o, e))
65
70
  return;
66
- if (!((s = r.value) != null && s.externalValidation && !await r.value.externalValidation(o)) && !await d(o.compiledHtml, o.css, e))
67
- return f(o, { silent: e, suppress: t });
71
+ if (!((s = a.value) != null && s.externalValidation && !await a.value.externalValidation(o)) && !await f(o.compiledHtml, o.css, e))
72
+ return v(o, { silent: e, suppress: t });
68
73
  }
69
- }, W = async () => {
74
+ }, R = async () => {
70
75
  var i;
71
- if (!S.allowSaveWithErrors)
76
+ if (!w.allowSaveWithErrors)
72
77
  return;
73
78
  n();
74
- const t = await u();
79
+ const t = await m();
75
80
  if (!c(t.html, !1))
76
81
  return;
77
82
  const e = await p(t);
78
- if (l(e.rawHtml, !1) && !((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(e)) && !await d(e.compiledHtml, e.css, !1))
79
- return f(e, { silent: !1, blankCompiled: !0 });
80
- }, R = async () => {
81
- if (!S.allowSaveWithErrors)
83
+ if (l(e.rawHtml, !1) && !((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(e)) && !await f(e.compiledHtml, e.css, !1))
84
+ return v(e, { silent: !1, blankCompiled: !0 });
85
+ }, q = async () => {
86
+ if (!w.allowSaveWithErrors)
82
87
  return;
83
88
  n();
84
- const { html: t, css: e } = await u();
85
- if (!c(t, !0) || !l(t, !0) || await d(t, e, !0))
89
+ const { html: t, css: e } = await m();
90
+ if (!c(t, !0) || !l(t, !0) || await f(t, e, !0))
86
91
  return;
87
- const i = Z(t), o = {
88
- dynamicContentList: U.getSelectedDynamicContentList,
92
+ const i = _(t), o = {
93
+ dynamicContentList: A.getSelectedDynamicContentList,
89
94
  compiledHtml: "",
90
95
  rawHtml: t,
91
96
  css: e,
@@ -99,11 +104,11 @@ const Pt = () => {
99
104
  config: i
100
105
  }
101
106
  };
102
- return f(o, { silent: !0 });
107
+ return v(o, { silent: !0 });
103
108
  };
104
- return { save: (t = !1, e = !1) => m(
105
- () => M(t, e)
106
- ), saveWithErrors: () => m(W), saveRawOnly: () => m(R) };
109
+ return { save: (t = !1, e = !1) => d(
110
+ () => W(t, e)
111
+ ), saveWithErrors: () => d(R), saveRawOnly: () => d(q) };
107
112
  };
108
113
  export {
109
114
  Pt as useSave