@useinsider/guido 3.4.1-beta.545fc76 → 3.4.1-beta.6a8f00a

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.
package/README.md CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  # @useinsider/guido
10
10
 
11
+ [![Coverus](https://github.com/useinsider/coverus-artifacts/raw/main/badges/github/useinsider/guido/coverage.svg)](http://coverus.internal.dataforce/app/project/github/useinsider/guido)
12
+
11
13
  Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean, type-safe configuration.
12
14
 
13
15
  ## Installation
@@ -21,9 +21,9 @@ const v = () => {
21
21
  resetDataSavedFlag: !1,
22
22
  disableLineHeightsReplace: !0
23
23
  }, ...t }, s = {
24
- callback: (l, p, d, c, u) => {
24
+ callback: (l, r, d, c, u) => {
25
25
  l ? a(l) : e({
26
- html: p,
26
+ html: r,
27
27
  ampHtml: d,
28
28
  ampErrors: c,
29
29
  displayConditions: u
@@ -36,11 +36,11 @@ const v = () => {
36
36
  return {
37
37
  getCompiledEmail: m,
38
38
  getTemplateData: () => new Promise((t) => {
39
- const e = ({ html: a, css: i, width: o, height: r, utmParams: s, syncModulesIds: l }) => t({
39
+ const e = ({ html: a, css: i, width: o, height: p, utmParams: s, syncModulesIds: l }) => t({
40
40
  html: a,
41
41
  css: i,
42
42
  width: o,
43
- height: r,
43
+ height: p,
44
44
  utmParams: s,
45
45
  syncModulesIds: l
46
46
  });
@@ -91,11 +91,7 @@ const v = () => {
91
91
  },
92
92
  editorSave: () => new Promise((t) => {
93
93
  window.StripoEditorApi.actionsApi.save((e) => {
94
- if (e) {
95
- n(e, "Failed to save template"), t(!1);
96
- return;
97
- }
98
- t(!0);
94
+ e && n(e, "Failed to save template"), t();
99
95
  });
100
96
  })
101
97
  };
@@ -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 A = () => ({
7
8
  calculateCardWidth: ({
8
9
  mobileLeftPadding: s,
9
10
  mobileRightPadding: a,
10
11
  cardsInRow: c,
11
- unresponsive: n
12
+ unresponsive: o
12
13
  }) => {
13
- const r = n ? c : 1, e = s + a + (r - 1) * b;
14
- return (R - e) / r;
14
+ const n = o ? c : 1, e = s + a + (n - 1) * b;
15
+ return (C - e) / n;
15
16
  },
16
17
  getRecommendationCampaignData: (s) => {
17
- const a = m(), c = Number(s), n = a.blockStates[c];
18
- if (!n)
18
+ const a = l(), c = Number(s), o = a.blockStates[c];
19
+ if (!o)
19
20
  return {
20
21
  textTrimming: !1,
21
22
  orientation: "vertical",
@@ -28,14 +29,14 @@ const w = () => ({
28
29
  discountBeforeTextValue: "",
29
30
  discountAfterTextValue: ""
30
31
  };
31
- const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
32
+ const { recommendationConfigs: n } = o, e = n.orientation === "grid" ? "vertical" : "horizontal";
32
33
  return {
33
- textTrimming: r.textTrimming,
34
+ textTrimming: n.textTrimming,
34
35
  orientation: e,
35
36
  mobileLeftPadding: 0,
36
37
  mobileRightPadding: 0,
37
- cardsInRow: r.cardsInRow,
38
- unresponsive: r.unresponsive,
38
+ cardsInRow: n.cardsInRow,
39
+ unresponsive: n.unresponsive,
39
40
  priceBeforeTextValue: "",
40
41
  priceAfterTextValue: "",
41
42
  discountBeforeTextValue: "",
@@ -43,38 +44,38 @@ const w = () => ({
43
44
  };
44
45
  },
45
46
  buildCampaignUrl: (s, a) => {
46
- var l;
47
- const c = m(), n = x(), r = Number(s);
47
+ var m;
48
+ const c = l(), o = x(), n = Number(s);
48
49
  let e;
49
50
  if (a)
50
51
  e = a;
51
52
  else {
52
- const i = c.blockStates[r];
53
- if (!i)
53
+ const r = c.blockStates[n];
54
+ if (!r)
54
55
  return "";
55
- const { recommendationConfigs: o } = i;
56
+ const { recommendationConfigs: i } = r;
56
57
  e = {
57
- strategy: o.strategy,
58
- language: o.language,
59
- currencyCode: o.currencySettings.value,
60
- size: o.size,
61
- productIds: o.productIds,
62
- filters: o.filters,
63
- shuffleProducts: o.shuffleProducts
58
+ strategy: i.strategy,
59
+ language: i.language,
60
+ currencyCode: i.currencySettings.value,
61
+ size: i.size,
62
+ productIds: i.productIds,
63
+ filters: i.filters,
64
+ shuffleProducts: i.shuffleProducts
64
65
  };
65
66
  }
66
- const f = ((l = I().find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
67
- if (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") {
68
- const i = parseInt(e.size) || 6;
69
- t.set("productId", e.productIds.slice(0, i).join(","));
67
+ const f = ((m = I().find((r) => r.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
68
+ if (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") {
69
+ const r = parseInt(e.size) || 6;
70
+ t.set("productId", e.productIds.slice(0, r).join(","));
70
71
  } else e.strategy === "similarViewed" && t.set("productId", "{itemId}");
71
72
  e.strategy === "userBased" && t.set("userId", "{user_id}");
72
- const g = e.filters.filter((i) => i.isValid), d = h(g);
73
- d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true");
74
- const p = decodeURIComponent(t.toString()), u = `${C.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
73
+ const g = e.filters.filter((r) => r.isValid), d = h(g);
74
+ d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(o.partnerName, e.strategy)).forEach(([r, i]) => t.set(r, i));
75
+ const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
75
76
  return c.recommendationCampaignUrls[s] = u, u;
76
77
  }
77
78
  });
78
79
  export {
79
- w as useRecommendation
80
+ A as useRecommendation
80
81
  };
@@ -1,31 +1,32 @@
1
1
  import { useActionsApi as x } from "./useActionsApi.js";
2
2
  import { useConfig as y } from "./useConfig.js";
3
3
  import { useSaveStart as w, useSaveComplete as C } from "./useGuidoActions.js";
4
- import { useSyncModuleExtractor as E } from "./useSyncModuleExtractor.js";
5
- import { useStripoApi as H } from "../services/stripoApi.js";
6
- import { useTemplatePreparation as b } from "../utils/templatePreparation.js";
7
- import { useHtmlValidator as q } from "./useHtmlValidator.js";
8
- import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
9
- import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
10
- const z = () => {
11
- const o = w(), s = C(), { validateHtml: r } = q(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = E(), { setSyncModuleUnsubscriptionPages: c } = H(), { editorSave: m } = x();
4
+ import { useSyncModuleExtractor as H } from "./useSyncModuleExtractor.js";
5
+ import { useStripoApi as b } from "../services/stripoApi.js";
6
+ import { useTemplatePreparation as q } from "../utils/templatePreparation.js";
7
+ import { useHtmlValidator as L } from "./useHtmlValidator.js";
8
+ import { useCouponBlockValidator as P } from "./validators/useCouponBlockValidator.js";
9
+ import { useLiquidValidator as E } from "./validators/useLiquidValidator.js";
10
+ const j = () => {
11
+ const o = w(), s = C(), { validateHtml: r } = L(), { validateLiquidSyntax: l } = E(), { validateCouponBlockTags: n } = P(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = H(), { setSyncModuleUnsubscriptionPages: c } = b(), { editorSave: m } = x();
12
12
  return { save: async (p = !1, f = !1) => {
13
13
  var i;
14
14
  o();
15
- const { prepareTemplateDetails: v } = b(), t = await v();
16
- if (!l(t.compiledHtml))
15
+ const { prepareTemplateDetails: v } = q(), t = await v();
16
+ if (!n(t.compiledHtml))
17
17
  return;
18
18
  if (d("liquidSyntax")) {
19
- if (!await n(t.compiledHtml))
19
+ if (!await l(t.compiledHtml))
20
20
  return;
21
21
  } else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
22
22
  return;
23
- if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t) || !await m())
23
+ if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
24
24
  return;
25
+ await m();
25
26
  const { unsubscribePayload: S, stripoModules: V } = u(t.rawHtml);
26
27
  return await c(S), t.modules = V, p || s({ ...t, silent: f }), t;
27
28
  } };
28
29
  };
29
30
  export {
30
- z as useSave
31
+ j as useSave
31
32
  };
@@ -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 w } from "../validation/filterSchema.js";
10
- import { isConfigValid as v } from "../validation/requiredFields.js";
9
+ import { getPartnerRecommendationParams as w } from "../utils/partnerCustomizations.js";
10
+ import { isFilterValid as v } from "../validation/filterSchema.js";
11
+ import { isConfigValid as N } from "../validation/requiredFields.js";
11
12
  const h = C();
12
13
  let m = null, u = null, d = null;
13
14
  function k() {
@@ -49,7 +50,7 @@ function I() {
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
@@ -359,7 +360,7 @@ const N = () => ({
359
360
  const n = [...e.recommendationConfigs.filters];
360
361
  n[r] = {
361
362
  ...t,
362
- isValid: w(t)
363
+ isValid: v(t)
363
364
  }, e.recommendationConfigs.filters = n;
364
365
  }
365
366
  },
@@ -405,7 +406,7 @@ const N = () => ({
405
406
  * every block's recommendationConfigs across user edits.
406
407
  */
407
408
  hasInvalidBlock() {
408
- return Object.values(this.blockStates).some((t) => !v(t.recommendationConfigs, this));
409
+ return Object.values(this.blockStates).some((t) => !N(t.recommendationConfigs, this));
409
410
  },
410
411
  // ====================================================================
411
412
  // Per-Block Product Fetching
@@ -434,7 +435,10 @@ const N = () => ({
434
435
  details: !0,
435
436
  campaignId: o.variationId
436
437
  };
437
- r.strategy === "manualMerchandising" ? a.productId = r.productIds.slice(0, s).join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0);
438
+ r.strategy === "manualMerchandising" ? a.productId = r.productIds.slice(0, s).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(
439
+ a,
440
+ w(o.partnerName, r.strategy)
441
+ );
438
442
  let f;
439
443
  try {
440
444
  f = await h.fetchRecommendationProducts(i, a);
@@ -452,5 +456,5 @@ const N = () => ({
452
456
  }
453
457
  });
454
458
  export {
455
- M as useRecommendationExtensionStore
459
+ T as useRecommendationExtensionStore
456
460
  };
@@ -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
+ };
@@ -7,5 +7,5 @@ export declare const useActionsApi: () => {
7
7
  getPreviewData: (options?: CompileEmailOptions) => Promise<CompiledEmailResult>;
8
8
  updateTimerInClonedTemplate: () => Promise<string | null>;
9
9
  updateHtmlAndCss: (html: string, css: string) => void;
10
- editorSave: () => Promise<boolean>;
10
+ editorSave: () => Promise<void>;
11
11
  };
@@ -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>;
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -1,8 +1,8 @@
1
1
  import "../@types/config/schemas.js";
2
2
  import "../@types/config/defaults.js";
3
- import { parseConfig as n } from "../@types/config/validator.js";
4
- import { defineStore as o } from "pinia";
5
- const s = o("guido-config", {
3
+ import { parseConfig as o } from "../@types/config/validator.js";
4
+ import { defineStore as r } from "pinia";
5
+ const f = r("guido-config", {
6
6
  state: () => ({
7
7
  initialized: !1,
8
8
  config: null
@@ -75,64 +75,65 @@ const s = o("guido-config", {
75
75
  * Get the template ID
76
76
  */
77
77
  templateId: (i) => {
78
- var e;
79
- return ((e = i.config) == null ? void 0 : e.identity.templateId) ?? "";
78
+ var e, t;
79
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.templateId) ?? "";
80
80
  },
81
81
  /**
82
82
  * Get the user ID
83
83
  */
84
84
  userId: (i) => {
85
- var e;
86
- return ((e = i.config) == null ? void 0 : e.identity.userId) ?? "";
85
+ var e, t;
86
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.userId) ?? "";
87
87
  },
88
88
  /**
89
89
  * Get the variation ID
90
90
  */
91
91
  variationId: (i) => {
92
- var e;
93
- return ((e = i.config) == null ? void 0 : e.identity.variationId) ?? "";
92
+ var e, t;
93
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.variationId) ?? "";
94
94
  },
95
95
  /**
96
96
  * Get the partner name
97
97
  */
98
98
  partnerName: (i) => {
99
- var e;
100
- return ((e = i.config) == null ? void 0 : e.partner.name) ?? "";
99
+ var e, t;
100
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.name) ?? "";
101
101
  },
102
102
  /**
103
103
  * Get the product type
104
104
  */
105
105
  productType: (i) => {
106
- var e;
107
- return ((e = i.config) == null ? void 0 : e.partner.productType) ?? 60;
106
+ var e, t;
107
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.productType) ?? 60;
108
108
  },
109
109
  /**
110
110
  * Get the message type
111
111
  */
112
112
  messageType: (i) => {
113
- var e;
114
- return ((e = i.config) == null ? void 0 : e.partner.messageType) ?? 1;
113
+ var e, t;
114
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) ?? 1;
115
115
  },
116
116
  /**
117
117
  * Get the username
118
118
  */
119
119
  username: (i) => {
120
- var e;
121
- return ((e = i.config) == null ? void 0 : e.partner.username) ?? "Guido User";
120
+ var e, t;
121
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.username) ?? "Guido User";
122
122
  },
123
123
  /**
124
124
  * Check if header should be shown
125
125
  */
126
126
  showHeader: (i) => {
127
- var e;
128
- return ((e = i.config) == null ? void 0 : e.ui.showHeader) ?? !0;
127
+ var e, t;
128
+ return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
129
129
  },
130
130
  /**
131
131
  * Check if a specific feature is enabled
132
132
  */
133
+ // eslint-disable-next-line @stylistic/max-len
133
134
  isFeatureEnabled: (i) => (e) => {
134
- var t;
135
- return ((t = i.config) == null ? void 0 : t.features[e]) ?? !0;
135
+ var t, n;
136
+ return ((n = (t = i.config) == null ? void 0 : t.features) == null ? void 0 : n[e]) ?? !0;
136
137
  }
137
138
  },
138
139
  actions: {
@@ -140,7 +141,7 @@ const s = o("guido-config", {
140
141
  * Initialize the config store with validated configuration
141
142
  */
142
143
  init(i) {
143
- const e = n(i);
144
+ const e = o(i);
144
145
  this.config = e, this.initialized = !0;
145
146
  },
146
147
  /**
@@ -152,5 +153,5 @@ const s = o("guido-config", {
152
153
  }
153
154
  });
154
155
  export {
155
- s as useConfigStore
156
+ f as useConfigStore
156
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.4.1-beta.545fc76",
3
+ "version": "3.4.1-beta.6a8f00a",
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",
@@ -24,7 +24,7 @@
24
24
  "lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
25
25
  "lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
26
26
  "type-check": "vue-tsc --noEmit --project tsconfig.config.json && vue-tsc --noEmit --project tsconfig.app.json",
27
- "test": "vitest run",
27
+ "test": "vitest run --coverage",
28
28
  "test:watch": "vitest",
29
29
  "test:visual-update": "npx playwright test --update-snapshots --reporter html",
30
30
  "prepare": "husky",
@@ -61,6 +61,7 @@
61
61
  "@typescript-eslint/parser": "7.18.0",
62
62
  "@useinsider/eslint-config": "1.5.3",
63
63
  "@vitejs/plugin-vue2": "2.3.1",
64
+ "@vitest/coverage-v8": "2.1.9",
64
65
  "eslint": "8.57.1",
65
66
  "eslint-config-airbnb-base": "15.0.0",
66
67
  "eslint-config-airbnb-typescript": "18.0.0",