@useinsider/guido 3.19.0-beta.d04f200 → 3.19.0-beta.e110e88

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 (43) hide show
  1. package/dist/@types/config/schemas.js +91 -104
  2. package/dist/components/Guido.vue.js +8 -8
  3. package/dist/components/Guido.vue2.js +74 -79
  4. package/dist/components/wrappers/WpModal.vue.js +1 -1
  5. package/dist/components/wrappers/WpModal.vue2.js +3 -4
  6. package/dist/composables/useHttp.js +54 -64
  7. package/dist/composables/useLegacyStrategyConversion.js +19 -23
  8. package/dist/composables/useStripo.js +20 -24
  9. package/dist/composables/useToaster.js +15 -17
  10. package/dist/composables/validators/useLiquidValidator.js +15 -15
  11. package/dist/config/migrator/index.js +13 -14
  12. package/dist/enums/extensions/recommendationBlock.js +29 -30
  13. package/dist/extensions/Blocks/Recommendation/block.js +22 -21
  14. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +107 -97
  15. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +49 -72
  16. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +91 -67
  18. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -21
  19. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +55 -16
  20. package/dist/guido.css +1 -1
  21. package/dist/src/@types/config/schemas.d.ts +0 -16
  22. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -5
  23. package/dist/src/composables/useConfig.d.ts +0 -2
  24. package/dist/src/composables/useHttp.d.ts +0 -2
  25. package/dist/src/config/migrator/index.d.ts +1 -2
  26. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
  27. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
  28. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +13 -2
  29. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -6
  30. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +3 -1
  31. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
  32. package/dist/src/stores/config.d.ts +0 -20
  33. package/dist/static/styles/components/recommendation-strategy.css.js +0 -9
  34. package/package.json +1 -1
  35. package/dist/components/organisms/base/AuthErrorModal.vue.js +0 -18
  36. package/dist/components/organisms/base/AuthErrorModal.vue2.js +0 -42
  37. package/dist/composables/useAuthError.js +0 -52
  38. package/dist/config/migrator/recommendationPartnerMigrator.js +0 -50
  39. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +0 -25
  40. package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +0 -2
  41. package/dist/src/composables/useAuthError.d.ts +0 -12
  42. package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +0 -19
  43. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +0 -33
@@ -1,28 +1,26 @@
1
1
  import { ToasterTypeOptions as T } from "../enums/toaster.js";
2
- import { useToasterStore as u } from "../stores/toaster.js";
3
- import { nextTick as c } from "vue";
2
+ import { useToasterStore as c } from "../stores/toaster.js";
3
+ import { nextTick as u } from "vue";
4
4
  const s = /* @__PURE__ */ new WeakMap(), p = () => {
5
- const t = u(), o = () => {
6
- const e = s.get(t);
7
- e && (clearTimeout(e), s.delete(t));
5
+ const e = c(), o = () => {
6
+ const t = s.get(e);
7
+ t && (clearTimeout(t), s.delete(e));
8
8
  };
9
- function i(e = { message: "" }) {
10
- o(), t.hideToaster(), c(() => {
11
- t.showToaster(e), t.shouldAutoHide && s.set(t, setTimeout(() => {
12
- t.hideToaster(), o();
9
+ function r(t = { message: "" }) {
10
+ o(), e.hideToaster(), u(() => {
11
+ e.showToaster(t), e.shouldAutoHide && s.set(e, setTimeout(() => {
12
+ e.hideToaster(), o();
13
13
  }, 6e3));
14
14
  });
15
15
  }
16
- function n() {
17
- o(), t.hideToaster();
16
+ function i() {
17
+ o(), e.hideToaster();
18
18
  }
19
- function a(e, r) {
20
- if (e != null && e.authReported)
21
- return;
22
- const m = e instanceof Error ? e.message : String(e);
23
- i({ type: T.Error, message: `${r}: ${m}` });
19
+ function n(t, a) {
20
+ const m = t instanceof Error ? t.message : String(t);
21
+ r({ type: T.Error, message: `${a}: ${m}` });
24
22
  }
25
- return { showToaster: i, hideToaster: n, handleError: a };
23
+ return { showToaster: r, hideToaster: i, handleError: n };
26
24
  };
27
25
  export {
28
26
  p as useToaster
@@ -1,13 +1,13 @@
1
- import { ToasterTypeOptions as r } from "../../enums/toaster.js";
1
+ import { ToasterTypeOptions as a } from "../../enums/toaster.js";
2
2
  import { base64EncodeWithSpecialChars as u } from "../../utils/base64.js";
3
3
  import { useHttp as d } from "../useHttp.js";
4
- import { useToaster as p } from "../useToaster.js";
5
- import { useTranslations as c } from "../useTranslations.js";
4
+ import { useToaster as c } from "../useToaster.js";
5
+ import { useTranslations as p } from "../useTranslations.js";
6
6
  const v = () => {
7
- const { post: i } = d(), { showToaster: t } = p(), s = c();
7
+ const { post: i } = d(), { showToaster: e } = c(), s = p();
8
8
  return { validateLiquidSyntax: async (o) => {
9
9
  try {
10
- const e = await i("/newsletter/contents/validate-syntax", [{
10
+ const t = await i("/newsletter/contents/validate-syntax", [{
11
11
  identifier: "default",
12
12
  syntax: "liquid",
13
13
  contents: {
@@ -17,21 +17,21 @@ const v = () => {
17
17
  ampHtml: null
18
18
  }
19
19
  }]);
20
- if (!Array.isArray(e.data)) {
21
- const l = e.data;
22
- return t({
23
- type: r.Warning,
20
+ if (!Array.isArray(t.data)) {
21
+ const l = t.data;
22
+ return e({
23
+ type: a.Warning,
24
24
  message: l.message ?? s("journey-builder.liquid-validation-failed")
25
25
  }), !1;
26
26
  }
27
- const [a] = e.data, n = Object.values((a == null ? void 0 : a.errors) ?? {});
28
- return n.length ? (t({
29
- type: r.Warning,
27
+ const [r] = t.data, n = Object.values((r == null ? void 0 : r.errors) ?? {});
28
+ return n.length ? (e({
29
+ type: a.Warning,
30
30
  message: n[0].replace(/^line \d+:\s*/, "")
31
31
  }), !1) : !0;
32
- } catch (e) {
33
- return e != null && e.authReported || t({
34
- type: r.Error,
32
+ } catch {
33
+ return e({
34
+ type: a.Error,
35
35
  message: s("journey-builder.liquid-validation-failed")
36
36
  }), !1;
37
37
  }
@@ -1,17 +1,16 @@
1
- import { migrateCheckbox as i } from "./checkboxMigrator.js";
2
- import { migrateCouponBlock as e } from "./couponBlockMigrator.js";
3
- import { migrateItemsBlock as a } from "./itemsBlockMigrator.js";
4
- import { migrateProductNameLink as n } from "./productNameLinkMigrator.js";
5
- import { migrateRadioButton as c } from "./radioButtonMigrator.js";
6
- import { migrateRecommendation as g } from "./recommendationMigrator.js";
7
- import { migrateRecommendationPartnerScope as f } from "./recommendationPartnerMigrator.js";
8
- import { migrateRecommendationTitle as p } from "./recommendationTitleMigrator.js";
9
- import { migrateSocialIcons as d } from "./socialIconMigrator.js";
10
- import { migrateUnsubscribe as l } from "./unsubscribeMigrator.js";
11
- const h = async (r, t = {}, o) => {
12
- let m = r;
13
- return m = i(m), m = c(m), m = await l(m), m = e(m), m = g(m, t), o && (m = f(m, o)), m = p(m), m = a(m), m = n(m), m = d(m), m;
1
+ import { migrateCheckbox as t } from "./checkboxMigrator.js";
2
+ import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
3
+ import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
4
+ import { migrateProductNameLink as a } from "./productNameLinkMigrator.js";
5
+ import { migrateRadioButton as n } from "./radioButtonMigrator.js";
6
+ import { migrateRecommendation as c } from "./recommendationMigrator.js";
7
+ import { migrateRecommendationTitle as g } from "./recommendationTitleMigrator.js";
8
+ import { migrateSocialIcons as p } from "./socialIconMigrator.js";
9
+ import { migrateUnsubscribe as f } from "./unsubscribeMigrator.js";
10
+ const C = async (o, r = {}) => {
11
+ let m = o;
12
+ return m = t(m), m = n(m), m = await f(m), m = i(m), m = c(m, r), m = g(m), m = e(m), m = a(m), m = p(m), m;
14
13
  };
15
14
  export {
16
- h as migrate
15
+ C as migrate
17
16
  };
@@ -1,5 +1,5 @@
1
1
  import { useTranslations as s } from "../../composables/useTranslations.js";
2
- const t = {
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",
@@ -9,17 +9,17 @@ const t = {
9
9
  MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/migrate-strategies",
10
10
  // The template route narrows the recommendations resource before the action: the id
11
11
  // travels in the body, not the path.
12
- TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies"
13
- }, d = () => {
14
- const { RECOMMENDATION_STRATEGIES_PANEL_PATH: e } = t;
15
- return `${e}/create`;
16
- }, m = (e) => {
17
- const { RECOMMENDATION_STRATEGIES_PANEL_PATH: n } = t;
18
- return `${n}/${e}/edit`;
12
+ TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies",
13
+ // Smart Recommender hides the Email channel unless the URL asks for it, so a strategy created
14
+ // without this flag can never be Email-suitable and would never reach the editor's list.
15
+ RECOMMENDATION_STRATEGY_CREATE_PATH: "/discovery/recommendation-strategies/create?isEmail=true"
16
+ }, d = (e) => {
17
+ const { RECOMMENDATION_STRATEGIES_PANEL_PATH: n } = a;
18
+ return `${n}/${e}/edit?isEmail=true`;
19
+ }, m = {
20
+ campaign: a.MIGRATE_STRATEGIES_PATH,
21
+ template: a.TEMPLATE_MIGRATE_STRATEGIES_PATH
19
22
  }, T = {
20
- campaign: t.MIGRATE_STRATEGIES_PATH,
21
- template: t.TEMPLATE_MIGRATE_STRATEGIES_PATH
22
- }, p = {
23
23
  CLIENT_ID: "clientId"
24
24
  }, E = () => {
25
25
  const e = s();
@@ -85,21 +85,21 @@ const t = {
85
85
  path: "top-sellers"
86
86
  }
87
87
  ];
88
- }, A = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], v = [
88
+ }, p = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], A = [
89
89
  { text: "before the amount", value: "0" },
90
90
  { text: "after the amount", value: "1" }
91
- ], _ = [
91
+ ], v = [
92
92
  { text: "dot(.)", value: "." },
93
93
  { text: "comma(,)", value: "," },
94
94
  { text: "space( )", value: " " }
95
- ], h = [
95
+ ], _ = [
96
96
  { text: "0", value: "0" },
97
97
  { text: "1", value: "1" },
98
98
  { text: "2", value: "2" },
99
99
  { text: "3", value: "3" },
100
100
  { text: "4", value: "4" },
101
101
  { text: "5", value: "5" }
102
- ], r = "||", a = [
102
+ ], r = "||", t = [
103
103
  { text: "is exactly", value: "=" },
104
104
  { text: "contains", value: "~" },
105
105
  { text: "does not contain", value: "!~" },
@@ -121,9 +121,9 @@ const t = {
121
121
  ], c = [
122
122
  { text: "true", value: "==" },
123
123
  { text: "false", value: "!=" }
124
- ], x = (e) => {
124
+ ], h = (e) => {
125
125
  if (!e)
126
- return a;
126
+ return t;
127
127
  switch (e) {
128
128
  case "Boolean":
129
129
  return c;
@@ -132,29 +132,28 @@ const t = {
132
132
  case "Number":
133
133
  return i;
134
134
  case "String":
135
- return a;
135
+ return t;
136
136
  case "Strings":
137
137
  return o;
138
138
  default:
139
- return a;
139
+ return t;
140
140
  }
141
141
  };
142
142
  export {
143
- T as MIGRATION_PATHS,
143
+ m as MIGRATION_PATHS,
144
144
  r as OP_ANY_OF,
145
- A as PriceAttributes,
146
- p as QUERY_PARAMS,
147
- t as URLS,
148
- h as currencyDecimalCounts,
149
- v as currencyLocationMaps,
150
- _ as currencyOperators,
151
- x as getOperatorOptions,
145
+ p as PriceAttributes,
146
+ T as QUERY_PARAMS,
147
+ a as URLS,
148
+ _ as currencyDecimalCounts,
149
+ A as currencyLocationMaps,
150
+ v as currencyOperators,
151
+ h as getOperatorOptions,
152
152
  E as getRecommendationFeedSourceMaps,
153
153
  o as operatorOptionsForArrayOfStrings,
154
154
  c as operatorOptionsForBooleans,
155
155
  u as operatorOptionsForDates,
156
156
  i as operatorOptionsForNumbers,
157
- a as operatorOptionsForStrings,
158
- d as strategyCreatePath,
159
- m as strategyEditPath
157
+ t as operatorOptionsForStrings,
158
+ d as strategyEditPath
160
159
  };
@@ -1,9 +1,9 @@
1
- var y = Object.defineProperty;
2
- var A = (l, c, t) => c in l ? y(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
3
- var h = (l, c, t) => A(l, typeof c != "symbol" ? c + "" : c, t);
4
- import { useConfig as d } from "../../../composables/useConfig.js";
1
+ var b = Object.defineProperty;
2
+ var C = (l, c, t) => c in l ? b(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
3
+ var d = (l, c, t) => C(l, typeof c != "symbol" ? c + "" : c, t);
4
+ import { useConfig as h } from "../../../composables/useConfig.js";
5
5
  import { BlockId as D } from "../../../enums/block.js";
6
- import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
6
+ import { getMigrationBannerHtml as A } from "../../../utils/migrationBannerHtml.js";
7
7
  import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
8
8
  import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as O } from "./constants/defaultConfig.js";
9
9
  import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
@@ -12,19 +12,21 @@ import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLa
12
12
  import { RecommendationConfigService as s } from "./services/configService.js";
13
13
  import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
14
14
  import { getDefaultTemplate as T } from "./templates/grid/template.js";
15
- import { useRecommendationBlockWarning as v } from "./useRecommendationBlockWarning.js";
16
- const k = D.Recommendation, u = "recommendation-block-v2", B = "hide-price";
17
- let b = !1;
18
- class j extends E {
15
+ import { useRecommendationBlockWarning as x } from "./useRecommendationBlockWarning.js";
16
+ import { registerNodeConfigWriter as H } from "./utils/nodeConfigWriter.js";
17
+ import { refreshDuplicatedStrategyBlocks as $ } from "./utils/strategyCommit.js";
18
+ const k = D.Recommendation, u = "recommendation-block-v2", y = "hide-price";
19
+ let B = !1;
20
+ class Y extends E {
19
21
  constructor() {
20
22
  super();
21
23
  /**
22
24
  * Stores the ID generated in getTemplate() so onCreated() can reuse it.
23
25
  * This avoids generating a new (different) ID in onCreated().
24
26
  */
25
- h(this, "_pendingBlockId", null);
27
+ d(this, "_pendingBlockId", null);
26
28
  /** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
27
- h(this, "_resetSourceIds", /* @__PURE__ */ new Set());
29
+ d(this, "_resetSourceIds", /* @__PURE__ */ new Set());
28
30
  }
29
31
  getId() {
30
32
  return k;
@@ -44,7 +46,7 @@ class j extends E {
44
46
  );
45
47
  }
46
48
  getSettingsPanelTitleHtml() {
47
- return C(
49
+ return A(
48
50
  k,
49
51
  this.api.translate("Recommendation Block"),
50
52
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
@@ -91,13 +93,12 @@ class j extends E {
91
93
  }
92
94
  const i = this._pendingBlockId ?? this._generateNextId();
93
95
  this._pendingBlockId = null, this._assignRecommendationId(t, i);
94
- const n = d().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: a } = s.initializeConfig(
96
+ const n = h().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: a } = s.initializeConfig(
95
97
  this.api,
96
98
  t,
97
99
  {
98
100
  recommendationId: i,
99
101
  configVersion: n ? N : O,
100
- ...o ? { partnerName: d().partnerName.value } : {},
101
102
  // An RRS block picks a strategy, not an algorithm, and its algorithm control is
102
103
  // hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
103
104
  // at save for a block the user never configured.
@@ -134,7 +135,7 @@ class j extends E {
134
135
  }
135
136
  this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
136
137
  try {
137
- b || (I(this.api), b = !0);
138
+ B || (I(this.api), B = !0);
138
139
  const e = s.getConfig(t), i = this._getBlockElement(t);
139
140
  if (i) {
140
141
  const n = !e.mobileLayoutEnabled;
@@ -168,7 +169,7 @@ class j extends E {
168
169
  */
169
170
  _warnIfMultipleBlocks() {
170
171
  try {
171
- v().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
172
+ x().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
172
173
  } catch {
173
174
  }
174
175
  }
@@ -198,7 +199,7 @@ class j extends E {
198
199
  * the renamed one depending on where the module was dropped (SD-149916).
199
200
  */
200
201
  _scheduleArrivalReset(t) {
201
- d().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
202
+ h().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
202
203
  const e = this._getRecommendationId(t);
203
204
  e !== null && e > 0 && !this._resetSourceIds.delete(e) && g().resetArrivedBlock(e);
204
205
  }, 0);
@@ -257,7 +258,7 @@ class j extends E {
257
258
  /** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
258
259
  _handleDuplicate(t, e) {
259
260
  const i = this._reassignDuplicateId(t, e), n = g();
260
- n.cloneBlockState(e, i), n.setCurrentBlock(i), d().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), n.resetArrivedBlock(i)), this._warnIfMultipleBlocks();
261
+ n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), H(this.api), $(e, i, s.getConfig(t)).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o))), this._warnIfMultipleBlocks();
261
262
  }
262
263
  /**
263
264
  * Core id-reassignment for a duplicated block: rewrites the DOM
@@ -313,7 +314,7 @@ class j extends E {
313
314
  */
314
315
  _stampHidePrice(t, e) {
315
316
  const i = this._getBlockElement(t);
316
- i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(B, String(e)).apply(new p("Stamp hide-price"));
317
+ i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(y, String(e)).apply(new p("Stamp hide-price"));
317
318
  }
318
319
  /**
319
320
  * Stamps `hide-price` from config only when the block lacks the attribute —
@@ -321,7 +322,7 @@ class j extends E {
321
322
  */
322
323
  _healHidePriceAttr(t) {
323
324
  const e = this._getBlockElement(t);
324
- if (!e || !("getAttribute" in e) || e.getAttribute(B) !== null)
325
+ if (!e || !("getAttribute" in e) || e.getAttribute(y) !== null)
325
326
  return;
326
327
  const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
327
328
  this._stampHidePrice(t, i);
@@ -359,5 +360,5 @@ class j extends E {
359
360
  }
360
361
  export {
361
362
  k as BLOCK_ID,
362
- j as RecommendationBlock
363
+ Y as RecommendationBlock
363
364
  };