@useinsider/guido 3.6.0-beta.859e737 → 3.6.0-beta.f584946

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.
@@ -1,21 +1,22 @@
1
- import { getRecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
2
- import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
3
- import { useRecommendationExtensionStore as m } from "../extensions/Blocks/Recommendation/store/recommendation.js";
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";
3
+ import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
4
  import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
+ import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
5
6
  import { useConfigStore as x } from "../stores/config.js";
6
- const w = () => ({
7
+ const k = () => ({
7
8
  calculateCardWidth: ({
8
- mobileLeftPadding: o,
9
+ mobileLeftPadding: a,
9
10
  mobileRightPadding: s,
10
- cardsInRow: a,
11
- unresponsive: n
11
+ cardsInRow: c,
12
+ unresponsive: o
12
13
  }) => {
13
- const r = n ? a : 1, e = o + s + (r - 1) * b;
14
- return (R - e) / r;
14
+ const r = o ? c : 1, e = a + s + (r - 1) * b;
15
+ return (C - e) / r;
15
16
  },
16
- getRecommendationCampaignData: (o) => {
17
- const s = m(), a = Number(o), n = s.blockStates[a];
18
- if (!n)
17
+ getRecommendationCampaignData: (a) => {
18
+ const s = l(), c = Number(a), o = s.blockStates[c];
19
+ if (!o)
19
20
  return {
20
21
  textTrimming: !1,
21
22
  orientation: "vertical",
@@ -28,7 +29,7 @@ const w = () => ({
28
29
  discountBeforeTextValue: "",
29
30
  discountAfterTextValue: ""
30
31
  };
31
- const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
32
+ const { recommendationConfigs: r } = o, e = r.orientation === "grid" ? "vertical" : "horizontal";
32
33
  return {
33
34
  textTrimming: r.textTrimming,
34
35
  orientation: e,
@@ -42,35 +43,35 @@ const w = () => ({
42
43
  discountAfterTextValue: ""
43
44
  };
44
45
  },
45
- buildCampaignUrl: (o, s) => {
46
- var l;
47
- const a = m(), n = x(), r = Number(o);
46
+ buildCampaignUrl: (a, s) => {
47
+ var m;
48
+ const c = l(), o = x(), r = Number(a);
48
49
  let e;
49
50
  if (s)
50
51
  e = s;
51
52
  else {
52
- const c = a.blockStates[r];
53
- if (!c)
53
+ const i = c.blockStates[r];
54
+ if (!i)
54
55
  return "";
55
- const { recommendationConfigs: i } = c;
56
+ const { recommendationConfigs: n } = i;
56
57
  e = {
57
- strategy: i.strategy,
58
- language: i.language,
59
- currencyCode: i.currencySettings.value,
60
- size: i.size,
61
- productIds: i.productIds,
62
- filters: i.filters,
63
- shuffleProducts: i.shuffleProducts
58
+ strategy: n.strategy,
59
+ language: n.language,
60
+ currencyCode: n.currencySettings.value,
61
+ size: n.size,
62
+ productIds: n.productIds,
63
+ filters: n.filters,
64
+ shuffleProducts: n.shuffleProducts
64
65
  };
65
66
  }
66
- const f = ((l = I().find((c) => c.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
67
- 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", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
68
- const g = e.filters.filter((c) => c.isValid), d = h(g);
69
- d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true");
70
- const p = decodeURIComponent(t.toString()), u = `${C.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
71
- return a.recommendationCampaignUrls[o] = u, u;
67
+ const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
68
+ t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
69
+ const g = e.filters.filter((i) => i.isValid), d = h(g);
70
+ d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(o.partnerName, e.strategy)).forEach(([i, n]) => t.set(i, n));
71
+ const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
72
+ return c.recommendationCampaignUrls[a] = u, u;
72
73
  }
73
74
  });
74
75
  export {
75
- w as useRecommendation
76
+ k as useRecommendation
76
77
  };
@@ -6,8 +6,9 @@ import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
6
6
  import { EXCLUDED_ALGORITHM_IDS as D } from "../constants/defaultConfig.js";
7
7
  import { getDefaultProducts as S } from "../templates/utils.js";
8
8
  import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
9
- import { isFilterValid as v } from "../validation/filterSchema.js";
10
- import { isConfigValid as w } from "../validation/requiredFields.js";
9
+ import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
10
+ import { isFilterValid as w } from "../validation/filterSchema.js";
11
+ import { isConfigValid as N } from "../validation/requiredFields.js";
11
12
  const h = y();
12
13
  let m = null, u = null, d = null;
13
14
  function I() {
@@ -49,7 +50,7 @@ function k() {
49
50
  filterSnapshot: null
50
51
  };
51
52
  }
52
- const N = () => ({
53
+ const x = () => ({
53
54
  recommendationCampaignUrls: {},
54
55
  activePredictiveAlgorithms: [],
55
56
  languages: {},
@@ -58,8 +59,8 @@ const N = () => ({
58
59
  blockStates: {},
59
60
  currentRecommendationId: null,
60
61
  configVersion: 0
61
- }), M = P("guidoRecommendationExtension", {
62
- state: () => N(),
62
+ }), T = P("guidoRecommendationExtension", {
63
+ state: () => x(),
63
64
  getters: {
64
65
  // ====================================================================
65
66
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -378,7 +379,7 @@ const N = () => ({
378
379
  const n = [...e.recommendationConfigs.filters];
379
380
  n[r] = {
380
381
  ...t,
381
- isValid: v(t)
382
+ isValid: w(t)
382
383
  }, e.recommendationConfigs.filters = n;
383
384
  }
384
385
  },
@@ -424,7 +425,7 @@ const N = () => ({
424
425
  * every block's recommendationConfigs across user edits.
425
426
  */
426
427
  hasInvalidBlock() {
427
- return Object.values(this.blockStates).some((t) => !w(t.recommendationConfigs, this));
428
+ return Object.values(this.blockStates).some((t) => !N(t.recommendationConfigs, this));
428
429
  },
429
430
  // ====================================================================
430
431
  // Per-Block Product Fetching
@@ -453,7 +454,10 @@ const N = () => ({
453
454
  details: !0,
454
455
  campaignId: o.variationId
455
456
  };
456
- r.strategy === "manualMerchandising" ? a.productId = r.productIds.join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0);
457
+ r.strategy === "manualMerchandising" ? a.productId = r.productIds.join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
458
+ a,
459
+ v(o.partnerName, r.strategy)
460
+ );
457
461
  let f;
458
462
  try {
459
463
  f = await h.fetchRecommendationProducts(i, a);
@@ -471,5 +475,5 @@ const N = () => ({
471
475
  }
472
476
  });
473
477
  export {
474
- M as useRecommendationExtensionStore
478
+ T as useRecommendationExtensionStore
475
479
  };
@@ -0,0 +1,21 @@
1
+ const i = [
2
+ "ozonebg",
3
+ "ozonehr",
4
+ "ozonero",
5
+ "ozoneinfo",
6
+ "babybg",
7
+ "ozongr",
8
+ "iboodat",
9
+ "iboodbe",
10
+ "iboodde",
11
+ "iboodfr",
12
+ "iboodnl",
13
+ "iboodpl"
14
+ ], r = ["interencheres", "interencherespreprod"], d = ["lodenfrey", "lodenfreyuat"], c = "manualMerchandising";
15
+ function s(e, n) {
16
+ const o = {};
17
+ return i.includes(e) && (o.excludePurchaseDay = "30", o.userId = "{user_id}"), r.includes(e) && (o.hp = "1"), d.includes(e) && n === c && (o.includeOutOfStockItems = "true"), o;
18
+ }
19
+ export {
20
+ s as getPartnerRecommendationParams
21
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns the extra recommendation feed query params for an account, if any.
3
+ * Accounts without customizations get an empty object.
4
+ * @param partnerName Account subdomain (`config.partner.name`)
5
+ * @param strategy Recommendation strategy key of the block
6
+ */
7
+ export declare function getPartnerRecommendationParams(partnerName: string, strategy: string): Record<string, string>;
@@ -1,20 +1,4 @@
1
1
  import type { SavedTemplateDetails } from '@@/Types/stripo';
2
- /**
3
- * Collects every unsubscribe page id referenced by the unsubscribe blocks
4
- * present in the email HTML, deduped.
5
- *
6
- * The email's unsubscribe link is variation-scoped on the backend, which
7
- * resolves the page to render from the page ids the FE persists for that
8
- * variation. Those ids must reflect the blocks actually in the email — not a
9
- * UI-only selection store — otherwise a block that entered the editor by any
10
- * path other than the page-selection UI (e.g. a dropped saved module) sends an
11
- * empty association and the backend falls back to the default page.
12
- *
13
- * Read from raw editor HTML: the `data-unsubscribe-page-list` attribute lives
14
- * on the block node there (the save-time sync-module extractor relies on the
15
- * same source), so it is reliably present regardless of how the block was added.
16
- */
17
- export declare function getHtmlReferencedUnsubscribePages(html: string): number[];
18
2
  export declare const useTemplatePreparation: () => {
19
3
  prepareTemplateDetails: () => Promise<Omit<SavedTemplateDetails, "metadata">>;
20
4
  };
@@ -1,58 +1,58 @@
1
- import { useActionsApi as T } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as D } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { useActionsApi as C } from "../composables/useActionsApi.js";
2
+ import { useHtmlCompiler as T } from "../composables/useHtmlCompiler.js";
3
+ import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
4
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { DATA_ATTRIBUTES as h } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { parsePageList as P } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
- import { useDynamicContentStore as w } from "../stores/dynamic-content.js";
8
- import { useUnsubscribeStore as E } from "../stores/unsubscribe.js";
9
- function U(c) {
10
- const n = new DOMParser().parseFromString(c, "text/html").querySelectorAll(`[${h.PAGE_LIST}]`), t = [];
11
- return n.forEach((s) => {
12
- const r = s.getAttribute(h.PAGE_LIST);
13
- r && t.push(...P(r));
14
- }), [...new Set(t)];
5
+ import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { parsePageList as D } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
+ import { useDynamicContentStore as P } from "../stores/dynamic-content.js";
8
+ import { useUnsubscribeStore as w } from "../stores/unsubscribe.js";
9
+ function E(i, o) {
10
+ const t = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), c = [];
11
+ return t.forEach((r) => {
12
+ const a = r.getAttribute(S.PAGE_LIST);
13
+ a && c.push(...D(a));
14
+ }), o.filter((r) => c.includes(r));
15
15
  }
16
- async function F(c) {
17
- const i = new DOMParser().parseFromString(c, "text/html").querySelectorAll(".recommendation-block-v2");
18
- if (i.length === 0)
16
+ async function U(i) {
17
+ const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
18
+ if (m.length === 0)
19
19
  return;
20
- const n = b();
21
- i.forEach((t) => {
22
- var p, g, f, o, y;
23
- const s = t.getAttribute("recommendation-id"), r = s ? Number(s) : NaN;
20
+ const l = b();
21
+ m.forEach((t) => {
22
+ var g, f, u, n, y;
23
+ const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
24
24
  if (!Number.isFinite(r))
25
25
  return;
26
- const d = t.getAttribute("esd-ext-config");
27
- if (!d)
26
+ const a = t.getAttribute("esd-ext-config");
27
+ if (!a)
28
28
  return;
29
29
  let e;
30
30
  try {
31
- e = JSON.parse(d);
31
+ e = JSON.parse(a);
32
32
  } catch {
33
33
  return;
34
34
  }
35
35
  if (!e || typeof e != "object" || Array.isArray(e))
36
36
  return;
37
- const m = {
38
- strategy: e.strategy ?? a.strategy,
39
- language: e.language ?? a.language,
40
- size: e.size ?? a.size,
37
+ const p = {
38
+ strategy: e.strategy ?? s.strategy,
39
+ language: e.language ?? s.language,
40
+ size: e.size ?? s.size,
41
41
  // Spread the default arrays so each block gets a fresh reference
42
42
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
- productIds: e.productIds ?? [...a.productIds],
44
- filters: e.filters ?? [...a.filters],
45
- shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
46
- currencyCode: ((p = e.currency) == null ? void 0 : p.code) ?? l.code,
47
- currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? l.alignment,
48
- currencyDecimalCount: ((f = e.currency) == null ? void 0 : f.decimalCount) ?? l.decimalCount,
49
- currencyDecimalSeparator: ((o = e.currency) == null ? void 0 : o.decimalSeparator) ?? l.decimalSeparator,
50
- currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? l.thousandSeparator
43
+ productIds: e.productIds ?? [...s.productIds],
44
+ filters: e.filters ?? [...s.filters],
45
+ shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
46
+ currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? d.code,
47
+ currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? d.alignment,
48
+ currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? d.decimalCount,
49
+ currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? d.decimalSeparator,
50
+ currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? d.thousandSeparator
51
51
  };
52
- n.seedBlockUrlConfig(r, m);
52
+ l.seedBlockUrlConfig(r, p);
53
53
  });
54
54
  try {
55
- await n.fetchRecommendationCreateData();
55
+ await l.fetchRecommendationCreateData();
56
56
  } catch (t) {
57
57
  console.warn(
58
58
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -60,43 +60,42 @@ async function F(c) {
60
60
  );
61
61
  }
62
62
  }
63
- const k = () => {
64
- const c = w(), u = E(), { getCompiledEmail: i, getTemplateData: n } = T(), { compileHtml: t } = D();
63
+ const _ = () => {
64
+ const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
65
65
  return {
66
66
  prepareTemplateDetails: async () => {
67
- const { html: r, ampHtml: d = "", ampErrors: e = [] } = await i({
67
+ const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
68
68
  minimize: !0,
69
69
  resetDataSavedFlag: !1
70
- }), { html: m, css: p, syncModulesIds: g = [] } = await n();
71
- u.selectedUnsubscribePages.length && await u.fetchTemplates(), await F(m);
72
- const { compiledHtml: f, stats: o, appliedRules: y } = t(r), A = c.getSelectedDynamicContentList, C = b(), S = U(m);
70
+ }), { html: p, css: g, syncModulesIds: f = [] } = await l();
71
+ o.selectedUnsubscribePages.length && await o.fetchTemplates(), await U(p);
72
+ const { compiledHtml: u, stats: n, appliedRules: y } = t(r), h = i.getSelectedDynamicContentList, A = b();
73
73
  return console.debug("HTML Compilation Stats:", {
74
- originalSize: o.originalSize,
75
- compiledSize: o.compiledSize,
76
- reduction: `${o.reductionPercentage.toFixed(2)}%`,
74
+ originalSize: n.originalSize,
75
+ compiledSize: n.compiledSize,
76
+ reduction: `${n.reductionPercentage.toFixed(2)}%`,
77
77
  appliedRules: y,
78
- executionTime: `${o.executionTime.toFixed(2)}ms`
78
+ executionTime: `${n.executionTime.toFixed(2)}ms`
79
79
  }), {
80
- dynamicContentList: A,
81
- compiledHtml: f,
82
- rawHtml: m,
83
- css: p,
84
- ampHtml: d,
80
+ dynamicContentList: h,
81
+ compiledHtml: u,
82
+ rawHtml: p,
83
+ css: g,
84
+ ampHtml: a,
85
85
  ampErrors: e,
86
- modules: g.map(Number),
86
+ modules: f.map(Number),
87
87
  recommendation: {
88
- campaignUrls: C.recommendationCampaignUrls,
88
+ campaignUrls: A.recommendationCampaignUrls,
89
89
  configs: {}
90
90
  },
91
91
  unsubscribe: {
92
- status: S.length > 0,
93
- config: S
92
+ status: o.unsubscribePagesStatus,
93
+ config: E(u, o.selectedUnsubscribePages)
94
94
  }
95
95
  };
96
96
  }
97
97
  };
98
98
  };
99
99
  export {
100
- U as getHtmlReferencedUnsubscribePages,
101
- k as useTemplatePreparation
100
+ _ as useTemplatePreparation
102
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.6.0-beta.859e737",
3
+ "version": "3.6.0-beta.f584946",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",
@@ -1 +0,0 @@
1
- export {};