@useinsider/guido 3.18.1 → 3.18.2-beta.32d291d

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 (56) hide show
  1. package/README.md +21 -3
  2. package/dist/@types/config/schemas.js +59 -51
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +55 -53
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +82 -57
  7. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  8. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  9. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +24 -22
  10. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
  11. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
  12. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
  13. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
  14. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +46 -0
  15. package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +34 -34
  16. package/dist/composables/useCustomInterfaceAppearance.js +46 -42
  17. package/dist/composables/useHttp.js +24 -22
  18. package/dist/composables/useLegacyStrategyConversion.js +61 -0
  19. package/dist/enums/extensions/recommendationBlock.js +40 -31
  20. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +91 -84
  21. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -28
  22. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +45 -44
  23. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -58
  24. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
  25. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +7 -7
  26. package/dist/guido.css +1 -1
  27. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +29 -28
  28. package/dist/package.json.js +1 -1
  29. package/dist/services/recommendationApi.js +46 -37
  30. package/dist/services/templateLibraryApi.js +17 -14
  31. package/dist/src/@types/config/schemas.d.ts +16 -0
  32. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
  33. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
  34. package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
  35. package/dist/src/composables/useConfig.d.ts +4 -0
  36. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  37. package/dist/src/enums/extensions/recommendationBlock.d.ts +5 -1
  38. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -1
  39. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +2 -0
  40. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -0
  41. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +82 -1
  42. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
  43. package/dist/src/services/recommendationApi.d.ts +2 -1
  44. package/dist/src/stores/config.d.ts +322 -0
  45. package/dist/src/stores/onboarding.d.ts +808 -10
  46. package/dist/src/utils/genericUtil.d.ts +6 -0
  47. package/dist/src/utils/liquidDynamicContent.d.ts +20 -0
  48. package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
  49. package/dist/static/assets/icons/line-info.svg.js +5 -0
  50. package/dist/static/styles/components/recommendation-strategy.css.js +70 -5
  51. package/dist/stores/config.js +74 -60
  52. package/dist/stores/onboarding.js +46 -36
  53. package/dist/utils/genericUtil.js +63 -54
  54. package/dist/utils/liquidDynamicContent.js +15 -0
  55. package/dist/utils/templatePreparation.js +54 -52
  56. package/package.json +3 -3
@@ -1,67 +1,71 @@
1
- import S from "../static/assets/icons/line-change.svg.js";
2
- import i from "../static/assets/icons/line-delete.svg.js";
3
- import n from "../static/assets/icons/line-plus.svg.js";
4
- import p from "../static/styles/base.css.js";
5
- import s from "../static/styles/components/alert-message.css.js";
6
- import C from "../static/styles/components/amp-block.css.js";
7
- import a from "../static/styles/components/base-input.css.js";
8
- import f from "../static/styles/components/button-group.css.js";
9
- import c from "../static/styles/components/button.css.js";
10
- import u from "../static/styles/components/combobox.css.js";
11
- import l from "../static/styles/components/counter.css.js";
12
- import d from "../static/styles/components/dropdown-menu.css.js";
1
+ import i from "../static/assets/icons/filled-arrow-rising.svg.js";
2
+ import n from "../static/assets/icons/line-change.svg.js";
3
+ import S from "../static/assets/icons/line-delete.svg.js";
4
+ import p from "../static/assets/icons/line-info.svg.js";
5
+ import s from "../static/assets/icons/line-plus.svg.js";
6
+ import f from "../static/styles/base.css.js";
7
+ import C from "../static/styles/components/alert-message.css.js";
8
+ import a from "../static/styles/components/amp-block.css.js";
9
+ import c from "../static/styles/components/base-input.css.js";
10
+ import l from "../static/styles/components/button-group.css.js";
11
+ import u from "../static/styles/components/button.css.js";
12
+ import d from "../static/styles/components/combobox.css.js";
13
+ import I from "../static/styles/components/counter.css.js";
14
+ import g from "../static/styles/components/dropdown-menu.css.js";
13
15
  import h from "../static/styles/components/loader.css.js";
14
- import g from "../static/styles/components/narrow-panel.css.js";
15
- import I from "../static/styles/components/popup.css.js";
16
- import w from "../static/styles/components/recommendation-strategy.css.js";
17
- import y from "../static/styles/components/switcher.css.js";
18
- import b from "../static/styles/components/tabs.css.js";
19
- import B from "../static/styles/components/tools.css.js";
20
- import $ from "../static/styles/components/version-history.css.js";
21
- import P from "../static/styles/components/wide-panel.css.js";
16
+ import w from "../static/styles/components/narrow-panel.css.js";
17
+ import $ from "../static/styles/components/popup.css.js";
18
+ import y from "../static/styles/components/recommendation-strategy.css.js";
19
+ import b from "../static/styles/components/switcher.css.js";
20
+ import B from "../static/styles/components/tabs.css.js";
21
+ import A from "../static/styles/components/tools.css.js";
22
+ import P from "../static/styles/components/version-history.css.js";
23
+ import R from "../static/styles/components/wide-panel.css.js";
22
24
  import x from "../static/styles/variables.css.js";
23
- function r(t, o) {
24
- return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(o.trim())}");`;
25
+ function o(t, r) {
26
+ return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(r.trim())}");`;
25
27
  }
26
- const A = `:host {
27
- ${r("line-change", S)}
28
- ${r("line-delete", i)}
29
- ${r("line-plus", n)}
30
- }`, R = [
28
+ const V = `:host {
29
+ ${o("line-change", n)}
30
+ ${o("line-delete", S)}
31
+ ${o("filled-arrow-rising", i)}
32
+ ${o("line-info", p)}
33
+ ${o("line-plus", s)}
34
+ }`, D = [
31
35
  x,
32
36
  // Must be on top
33
- A,
34
- p,
37
+ V,
38
+ f,
35
39
  // Must be on top
36
- s,
37
40
  C,
38
41
  a,
39
- f,
40
42
  c,
41
- u,
42
43
  l,
44
+ u,
43
45
  d,
44
- h,
45
- g,
46
46
  I,
47
- y,
47
+ g,
48
+ h,
49
+ w,
50
+ $,
48
51
  b,
49
52
  B,
50
- $,
53
+ A,
51
54
  P,
52
- w
55
+ R,
56
+ y
53
57
  // Last: overrides button.css / wide-panel.css defaults
54
58
  ].join(`
55
59
 
56
- `), Y = () => ({ importCss: () => {
57
- const o = new CSSStyleSheet();
58
- o.replaceSync(R);
60
+ `), ro = () => ({ importCss: () => {
61
+ const r = new CSSStyleSheet();
62
+ r.replaceSync(D);
59
63
  const e = document.querySelector("ui-editor");
60
64
  if (!e)
61
65
  return;
62
66
  const m = e.shadowRoot;
63
- m && (m.adoptedStyleSheets = [o]);
67
+ m && (m.adoptedStyleSheets = [r]);
64
68
  } });
65
69
  export {
66
- Y as useCustomInterfaceAppearance
70
+ ro as useCustomInterfaceAppearance
67
71
  };
@@ -1,14 +1,16 @@
1
- import { getCsrfToken as H } from "../utils/genericUtil.js";
2
- import { ref as p, computed as T } from "vue";
3
- const k = (b = {}) => {
4
- const h = p(!1), a = p(null), u = p(null), g = T(() => h.value), y = T(() => a.value !== null), v = {
1
+ import { getCsrfToken as O } from "../utils/genericUtil.js";
2
+ import { ref as m, computed as T } from "vue";
3
+ const X = (b = {}) => {
4
+ const p = m(!1), a = m(null), u = m(null), g = T(() => p.value), y = T(() => a.value !== null), v = {
5
5
  baseURL: "",
6
6
  timeout: 1e4,
7
7
  retry: 0,
8
8
  retryDelay: 1e3,
9
9
  headers: {
10
10
  "Content-Type": "application/json",
11
- "X-CSRF-TOKEN": H()
11
+ "X-CSRF-TOKEN": O(),
12
+ Accept: "application/json",
13
+ "X-Requested-With": "XMLHttpRequest"
12
14
  },
13
15
  ...b
14
16
  }, w = (e, s) => {
@@ -22,22 +24,22 @@ const k = (b = {}) => {
22
24
  }, e);
23
25
  }), x = (e) => new Promise((s) => {
24
26
  setTimeout(s, e);
25
- }), i = async (e, s, t, D = {}) => {
26
- a.value = null, h.value = !0, u.value = new AbortController();
27
- const n = { ...v, ...D }, L = w(s, n.baseURL), c = {
27
+ }), i = async (e, s, t, L = {}) => {
28
+ a.value = null, p.value = !0, u.value = new AbortController();
29
+ const n = { ...v, ...L }, D = w(s, n.baseURL), c = {
28
30
  method: e,
29
31
  headers: { ...n.headers },
30
32
  signal: u.value.signal,
31
33
  ...n
32
34
  };
33
35
  t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
34
- const E = async (m = 0) => {
36
+ const E = async (h = 0) => {
35
37
  try {
36
- const o = [fetch(L, c)];
38
+ const o = [fetch(D, c)];
37
39
  n.timeout && o.push(P(n.timeout));
38
40
  const r = await Promise.race(o);
39
41
  if (!r.ok) {
40
- const O = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(O);
42
+ const H = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(H);
41
43
  throw d.status = r.status, d.statusText = r.statusText, d.response = r, d;
42
44
  }
43
45
  let f;
@@ -50,19 +52,19 @@ const k = (b = {}) => {
50
52
  };
51
53
  } catch (o) {
52
54
  const r = o instanceof Error && o.name === "AbortError";
53
- if (m < (n.retry || 0) && !r)
54
- return await x(n.retryDelay || 1e3), E(m + 1);
55
+ if (h < (n.retry || 0) && !r)
56
+ return await x(n.retryDelay || 1e3), E(h + 1);
55
57
  throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
56
58
  }
57
59
  };
58
60
  try {
59
61
  return await E();
60
62
  } finally {
61
- h.value = !1, u.value = null;
63
+ p.value = !1, u.value = null;
62
64
  }
63
- }, C = (e, s) => i("GET", e, void 0, s), $ = (e, s, t) => i("POST", e, s, t), R = (e, s, t) => i("PUT", e, s, t), U = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), W = (e) => {
65
+ }, C = (e, s) => i("GET", e, void 0, s), R = (e, s, t) => i("POST", e, s, t), $ = (e, s, t) => i("PUT", e, s, t), q = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), U = (e) => {
64
66
  u.value && u.value.abort(e);
65
- }, q = () => {
67
+ }, W = () => {
66
68
  a.value = null;
67
69
  };
68
70
  return {
@@ -73,14 +75,14 @@ const k = (b = {}) => {
73
75
  // Methods
74
76
  request: i,
75
77
  get: C,
76
- post: $,
77
- put: R,
78
- patch: U,
78
+ post: R,
79
+ put: $,
80
+ patch: q,
79
81
  delete: A,
80
- cancel: W,
81
- clearError: q
82
+ cancel: U,
83
+ clearError: W
82
84
  };
83
85
  };
84
86
  export {
85
- k as useHttp
87
+ X as useHttp
86
88
  };
@@ -0,0 +1,61 @@
1
+ import { useRecommendation as I } from "./useRecommendation.js";
2
+ import { useToaster as C } from "./useToaster.js";
3
+ import { useTranslations as v } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as g } from "../enums/toaster.js";
5
+ import "../extensions/Blocks/Recommendation/constants/selectors.js";
6
+ import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
7
+ import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
8
+ import { resolveMigrationTarget as R, buildLegacyMigrationPayload as T } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
9
+ import { commitBlockChangeOutsidePanel as h } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
10
+ import { useConfigStore as k } from "../stores/config.js";
11
+ const F = () => {
12
+ const e = b(), r = k(), { buildCampaignUrl: m } = I(), { showToaster: i } = C(), c = v();
13
+ return { convertLegacyStrategy: async () => {
14
+ const t = e.currentRecommendationId;
15
+ if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
16
+ return "";
17
+ const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = R({
18
+ campaignId: r.campaignId,
19
+ templateLibraryId: r.templateLibraryId
20
+ }), S = T({
21
+ blockId: t,
22
+ url: m(String(t)),
23
+ campaignId: r.campaignId,
24
+ variationId: r.variationId,
25
+ strategy: d,
26
+ productIds: y,
27
+ target: s
28
+ });
29
+ let o;
30
+ try {
31
+ o = await e.convertLegacyStrategy(S, s);
32
+ } catch (n) {
33
+ return console.error("[useLegacyStrategyConversion] migration failed", n), i({
34
+ type: g.Error,
35
+ message: c("email-editor.legacy-strategy-update-failed")
36
+ }), "";
37
+ }
38
+ try {
39
+ await e.fetchStrategyProductsForBlock(t);
40
+ } catch (n) {
41
+ console.error("[useLegacyStrategyConversion] product refetch failed", n);
42
+ }
43
+ const a = e.blockStates[t];
44
+ return a ? h(
45
+ t,
46
+ {
47
+ strategyId: o,
48
+ size: a.recommendationConfigs.size,
49
+ configVersion: L
50
+ },
51
+ a.recommendationProducts,
52
+ "Converted legacy recommendation strategy"
53
+ ) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), i({
54
+ type: g.Error,
55
+ message: c("email-editor.legacy-strategy-update-failed")
56
+ }), "") : o;
57
+ } };
58
+ };
59
+ export {
60
+ F as useLegacyStrategyConversion
61
+ };
@@ -1,14 +1,22 @@
1
- import { useTranslations as r } from "../../composables/useTranslations.js";
2
- const l = {
1
+ import { useTranslations as n } from "../../composables/useTranslations.js";
2
+ const a = {
3
3
  RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
4
4
  // Relative path → same-origin as the embedding inone dashboard.
5
5
  PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
6
6
  RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
7
- RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
7
+ RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies",
8
+ NEWSLETTER_RECOMMENDATIONS_PATH: "/newsletter/recommendations",
9
+ MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/migrate-strategies",
10
+ // The template route narrows the recommendations resource before the action: the id
11
+ // travels in the body, not the path.
12
+ TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies"
8
13
  }, c = {
14
+ campaign: a.MIGRATE_STRATEGIES_PATH,
15
+ template: a.TEMPLATE_MIGRATE_STRATEGIES_PATH
16
+ }, d = {
9
17
  CLIENT_ID: "clientId"
10
- }, d = () => {
11
- const e = r();
18
+ }, m = () => {
19
+ const e = n();
12
20
  return [
13
21
  {
14
22
  id: 11,
@@ -71,73 +79,74 @@ const l = {
71
79
  path: "top-sellers"
72
80
  }
73
81
  ];
74
- }, m = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], p = [
82
+ }, p = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], T = [
75
83
  { text: "before the amount", value: "0" },
76
84
  { text: "after the amount", value: "1" }
77
85
  ], v = [
78
86
  { text: "dot(.)", value: "." },
79
87
  { text: "comma(,)", value: "," },
80
88
  { text: "space( )", value: " " }
81
- ], h = [
89
+ ], A = [
82
90
  { text: "0", value: "0" },
83
91
  { text: "1", value: "1" },
84
92
  { text: "2", value: "2" },
85
93
  { text: "3", value: "3" },
86
94
  { text: "4", value: "4" },
87
95
  { text: "5", value: "5" }
88
- ], a = "||", t = [
96
+ ], r = "||", t = [
89
97
  { text: "is exactly", value: "=" },
90
98
  { text: "contains", value: "~" },
91
99
  { text: "does not contain", value: "!~" },
92
- { text: "any of", value: a }
93
- ], n = [
100
+ { text: "any of", value: r }
101
+ ], o = [
94
102
  { text: "is exactly", value: "=" },
95
103
  { text: "is not exactly", value: "!==" },
96
104
  { text: "contains", value: "~" },
97
105
  { text: "does not contain", value: "!~" },
98
- { text: "any of", value: a }
99
- ], o = [
106
+ { text: "any of", value: r }
107
+ ], s = [
100
108
  { text: "is equal to", value: "=" },
101
109
  { text: "is greater than", value: ">" },
102
110
  { text: "is less than", value: "<" }
103
- ], s = [
111
+ ], i = [
104
112
  { text: "is equal to", value: "=" },
105
113
  { text: "after", value: ">" },
106
114
  { text: "before", value: "<" }
107
- ], i = [
115
+ ], u = [
108
116
  { text: "true", value: "==" },
109
117
  { text: "false", value: "!=" }
110
- ], x = (e) => {
118
+ ], E = (e) => {
111
119
  if (!e)
112
120
  return t;
113
121
  switch (e) {
114
122
  case "Boolean":
115
- return i;
123
+ return u;
116
124
  case "Date":
117
- return s;
125
+ return i;
118
126
  case "Number":
119
- return o;
127
+ return s;
120
128
  case "String":
121
129
  return t;
122
130
  case "Strings":
123
- return n;
131
+ return o;
124
132
  default:
125
133
  return t;
126
134
  }
127
135
  };
128
136
  export {
129
- a as OP_ANY_OF,
130
- m as PriceAttributes,
131
- c as QUERY_PARAMS,
132
- l as URLS,
133
- h as currencyDecimalCounts,
134
- p as currencyLocationMaps,
137
+ c as MIGRATION_PATHS,
138
+ r as OP_ANY_OF,
139
+ p as PriceAttributes,
140
+ d as QUERY_PARAMS,
141
+ a as URLS,
142
+ A as currencyDecimalCounts,
143
+ T as currencyLocationMaps,
135
144
  v as currencyOperators,
136
- x as getOperatorOptions,
137
- d as getRecommendationFeedSourceMaps,
138
- n as operatorOptionsForArrayOfStrings,
139
- i as operatorOptionsForBooleans,
140
- s as operatorOptionsForDates,
141
- o as operatorOptionsForNumbers,
145
+ E as getOperatorOptions,
146
+ m as getRecommendationFeedSourceMaps,
147
+ o as operatorOptionsForArrayOfStrings,
148
+ u as operatorOptionsForBooleans,
149
+ i as operatorOptionsForDates,
150
+ s as operatorOptionsForNumbers,
142
151
  t as operatorOptionsForStrings
143
152
  };