@useinsider/guido 3.24.0-beta.88c24c1 → 3.24.0-beta.8e9f4e2

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 (39) hide show
  1. package/README.md +6 -2
  2. package/dist/@types/config/schemas.js +9 -11
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +1 -1
  5. package/dist/composables/useActionsApi.js +2 -2
  6. package/dist/composables/useEditorTrackingIds.js +49 -0
  7. package/dist/composables/useHtmlCompiler.js +2 -0
  8. package/dist/composables/useSave.js +52 -57
  9. package/dist/composables/useSaveValidation.js +110 -118
  10. package/dist/composables/useStripo.js +70 -70
  11. package/dist/composables/validators/useUnsubscribeBlockValidator.js +33 -48
  12. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  13. package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
  14. package/dist/config/migrator/recommendationMigrator.js +69 -63
  15. package/dist/enums/save-validation.js +1 -1
  16. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  18. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  19. package/dist/guido.css +1 -1
  20. package/dist/package.json.js +4 -4
  21. package/dist/services/templateLibraryApi.js +39 -36
  22. package/dist/src/@types/config/schemas.d.ts +0 -4
  23. package/dist/src/composables/useConfig.d.ts +0 -2
  24. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  25. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  26. package/dist/src/composables/useStripo.d.ts +1 -1
  27. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -4
  28. package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
  29. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
  30. package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
  31. package/dist/src/enums/save-validation.d.ts +1 -2
  32. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  33. package/dist/src/stores/config.d.ts +0 -20
  34. package/dist/src/utils/linkTrackingIds.d.ts +19 -0
  35. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  36. package/dist/utils/linkTrackingIds.js +82 -48
  37. package/dist/utils/templatePreparation.js +30 -33
  38. package/dist/utils/trimHrefWhitespace.js +10 -0
  39. package/package.json +1 -1
package/README.md CHANGED
@@ -124,7 +124,12 @@ const config: GuidoConfigInput = {
124
124
  // host-side). Omit it and the repair is a silent no-op. Default: {}.
125
125
  dynamicContentList?: DynamicContentList,
126
126
  selectedUnsubscribePages?: number[],
127
- forceRecreate?: boolean, // Default: false - Force recreate template in Stripo storage
127
+ // Default: false. Stripo opens its stored copy for the templateId unless this is true;
128
+ // Guido sets it itself when a load-time migration rewrote the html. Set it to true
129
+ // whenever the host changed html under an existing templateId outside the editor.
130
+ // Behaviour change: releases up to v3.23.0 forced a recreate for any non-empty html and
131
+ // ignored this option, so a host that sends `false` now gets Stripo's stored copy.
132
+ forceRecreate?: boolean,
128
133
  migration?: {
129
134
  // Legacy block configs keyed by block ID. Consumed once by the migrator
130
135
  // when upgrading templates authored with v1 block formats. See the
@@ -167,7 +172,6 @@ const config: GuidoConfigInput = {
167
172
  allowSaveWithErrors?: boolean, // Default: true - Allow the validation drawer's "Save and Continue" soft-save. Set false to hard-block invalid saves (transactional + unsubscribe pages).
168
173
  reusableRecommendationStrategy?: boolean, // Default: false - Assign an RRS strategy to recommendation blocks instead of per-block algorithm/filters/shuffle/product-count settings.
169
174
  accessibilityTesting?: boolean, // Default: false - Show the Accessibility Test entry in the header kebab menu (Stripo's checker: contrast, image alternatives, colour-vision simulation) and the tab-bar onboarding tour that points at it.
170
- blockUnsubscribeLinks?: boolean, // Default: false - Warn on save when the design carries an Insider unsubscribe link or code ({{ins-*-unsubscribe-link}}, <%asm_*_raw_url%>, <%unsub%>): the legacy save is rejected with a warning toaster; with the validation drawer on it is a warning row that "Save and Continue" can skip. Launch blocking is up to the host. Set true for accounts whose unsubscribes are managed outside Insider (SFMC).
171
175
  },
172
176
 
173
177
  // Optional: Callbacks
@@ -1,6 +1,6 @@
1
1
  import { ModuleFolderDefaults as S } from "../../enums/defaults.js";
2
- import { object as a, number as s, optional as e, string as t, picklist as m, pipe as i, minLength as p, custom as k, boolean as o, array as c, transform as y, unknown as r, record as g, fallback as R, literal as u, looseObject as C, variant as T, union as h, lazy as I } from "../../node_modules/valibot/dist/index.js";
3
- const b = {
2
+ import { object as a, number as s, optional as e, string as t, picklist as m, pipe as i, minLength as b, custom as k, boolean as o, array as c, transform as y, unknown as r, record as g, fallback as R, literal as u, looseObject as C, variant as T, union as h, lazy as I } from "../../node_modules/valibot/dist/index.js";
3
+ const p = {
4
4
  /** Promotional/marketing emails */
5
5
  PROMOTIONAL: 1,
6
6
  /** Transactional/system emails */
@@ -16,12 +16,12 @@ const b = {
16
16
  /** Unique identifier for the template being edited */
17
17
  templateId: i(
18
18
  t(),
19
- p(1, "templateId is required")
19
+ b(1, "templateId is required")
20
20
  ),
21
21
  /** Unique identifier for the user editing the template */
22
22
  userId: i(
23
23
  t(),
24
- p(1, "userId is required")
24
+ b(1, "userId is required")
25
25
  ),
26
26
  /** Optional variation ID for A/B testing */
27
27
  variationId: e(t()),
@@ -42,7 +42,7 @@ const b = {
42
42
  /** Partner/organization name (required) */
43
43
  name: i(
44
44
  t(),
45
- p(1, "partner.name is required")
45
+ b(1, "partner.name is required")
46
46
  ),
47
47
  /** Product type identifier */
48
48
  productType: e(
@@ -55,8 +55,8 @@ const b = {
55
55
  ),
56
56
  /** Message type (promotional or transactional) */
57
57
  messageType: e(
58
- m([b.PROMOTIONAL, b.TRANSACTIONAL]),
59
- b.PROMOTIONAL
58
+ m([p.PROMOTIONAL, p.TRANSACTIONAL]),
59
+ p.PROMOTIONAL
60
60
  ),
61
61
  /** Display name for the current user */
62
62
  username: e(t(), "Guido User"),
@@ -244,9 +244,7 @@ const b = {
244
244
  linkTrackingIds: e(o(), !1),
245
245
  /** Allow persisting a template that still has validation errors (drawer "Save and Continue" soft-save). Host sets false for transactional + unsubscribe. */
246
246
  allowSaveWithErrors: e(o(), !0),
247
- reusableRecommendationStrategy: e(o(), !1),
248
- /** Warn on save when the design carries an Insider unsubscribe link or code (host sets true for SFMC accounts) */
249
- blockUnsubscribeLinks: e(o(), !1)
247
+ reusableRecommendationStrategy: e(o(), !1)
250
248
  }), w = m([
251
249
  "amp-accordion",
252
250
  "amp-carousel",
@@ -379,7 +377,7 @@ export {
379
377
  K as GuidoConfigSchema,
380
378
  A as IdentitySchema,
381
379
  P as LegacyRecommendationConfigSchema,
382
- b as MessageType,
380
+ p as MessageType,
383
381
  E as PartnerSchema,
384
382
  l as ProductType,
385
383
  _ as RegexRuleSchema,
@@ -12,7 +12,7 @@ var t = function() {
12
12
  s,
13
13
  !1,
14
14
  null,
15
- "8422eef8"
15
+ "0191951d"
16
16
  );
17
17
  const c = n.exports;
18
18
  export {
@@ -151,7 +151,7 @@ const Ft = /* @__PURE__ */ le({
151
151
  console.debug("guido:ready"), s("ready");
152
152
  }
153
153
  };
154
- p = U(), await R(r, v(), de), g.selectedDynamicContentList = x;
154
+ p = U(), await R(r, v(), de, r.html !== i), g.selectedDynamicContentList = x;
155
155
  } catch (e) {
156
156
  console.error("Failed to initialize Stripo editor:", e), n.markFailed();
157
157
  }
@@ -111,8 +111,8 @@ const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((C, p) => {
111
111
  }),
112
112
  updateHtmlAndCss: (t, e) => {
113
113
  const { actionsApi: i } = r();
114
- return m("updateHtmlAndCss", H, (a) => {
115
- i.updateHtmlAndCss(t, e, () => a());
114
+ return m("updateHtmlAndCss", H, (a, o) => {
115
+ i.updateHtmlAndCss(t, e, () => a(), o);
116
116
  });
117
117
  },
118
118
  editorSave: () => m(
@@ -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
+ };
@@ -16,6 +16,8 @@ const x = /* @__PURE__ */ new Set([
16
16
  "fix-tags-end",
17
17
  // Unwrap translate-injected <font dir="auto"> tags — pure removal, never emits AMP-forbidden output.
18
18
  "strip-font-tags",
19
+ // Trim whitespace inside href values — attribute-value edit only, emits nothing new.
20
+ "trim-href-whitespace",
19
21
  // Image domain corrections — plain string replacement.
20
22
  "replace-old-image-domain",
21
23
  "replace-old-v2-image-domain",
@@ -1,96 +1,91 @@
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";
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";
8
8
  import { ToasterTypeOptions as J } from "../enums/toaster.js";
9
9
  import { useStripoApi as K } from "../services/stripoApi.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";
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";
21
21
  import { useUnsubscribeBlockValidator as at } from "./validators/useUnsubscribeBlockValidator.js";
22
22
  const Pt = () => {
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"))
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"))
29
25
  return !1;
30
- const o = await B(t, e);
26
+ const o = await h(t, e);
31
27
  if (!o.length)
32
28
  return !1;
33
29
  if (!i) {
34
- const s = await T(o);
35
- s != null && s.message && h({
30
+ const s = await B(o);
31
+ s != null && s.message && k({
36
32
  type: J.Warning,
37
33
  message: s.message,
38
34
  actionButton: s.actionButton
39
35
  });
40
36
  }
41
37
  return !0;
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) => {
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) => {
43
39
  if (!await C())
44
40
  return;
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 });
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 });
49
45
  }
50
46
  return t;
51
- }, W = async (t, e) => {
47
+ }, M = async (t, e) => {
52
48
  var s;
53
49
  n();
54
- const i = await m();
50
+ const i = await u();
55
51
  if (!c(i.html, e))
56
52
  return;
57
53
  const o = await p(i);
58
54
  if (l(o.rawHtml, e)) {
59
55
  if (P.value && !e) {
60
- const r = await L(
56
+ const a = await T(
61
57
  o.compiledHtml,
62
- o.dynamicContentList,
63
- o.rawHtml
58
+ o.dynamicContentList
64
59
  );
65
- if (r.length) {
66
- U.open(r, "save");
60
+ if (a.length) {
61
+ L.open(a, "save");
67
62
  return;
68
63
  }
69
- } else if (!await M(o, e))
64
+ } else if (!await A(o))
70
65
  return;
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 });
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 });
73
68
  }
74
- }, R = async () => {
69
+ }, W = async () => {
75
70
  var i;
76
- if (!w.allowSaveWithErrors)
71
+ if (!S.allowSaveWithErrors)
77
72
  return;
78
73
  n();
79
- const t = await m();
74
+ const t = await u();
80
75
  if (!c(t.html, !1))
81
76
  return;
82
77
  const e = await p(t);
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)
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)
87
82
  return;
88
83
  n();
89
- const { html: t, css: e } = await m();
90
- if (!c(t, !0) || !l(t, !0) || await f(t, e, !0))
84
+ const { html: t, css: e } = await u();
85
+ if (!c(t, !0) || !l(t, !0) || await d(t, e, !0))
91
86
  return;
92
- const i = _(t), o = {
93
- dynamicContentList: A.getSelectedDynamicContentList,
87
+ const i = Z(t), o = {
88
+ dynamicContentList: U.getSelectedDynamicContentList,
94
89
  compiledHtml: "",
95
90
  rawHtml: t,
96
91
  css: e,
@@ -104,11 +99,11 @@ const Pt = () => {
104
99
  config: i
105
100
  }
106
101
  };
107
- return v(o, { silent: !0 });
102
+ return f(o, { silent: !0 });
108
103
  };
109
- return { save: (t = !1, e = !1) => d(
110
- () => W(t, e)
111
- ), saveWithErrors: () => d(R), saveRawOnly: () => d(q) };
104
+ return { save: (t = !1, e = !1) => m(
105
+ () => M(t, e)
106
+ ), saveWithErrors: () => m(W), saveRawOnly: () => m(R) };
112
107
  };
113
108
  export {
114
109
  Pt as useSave