@useinsider/guido 3.28.0 → 3.28.1-beta.556323d

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 (40) hide show
  1. package/dist/@types/config/schemas.js +3 -3
  2. package/dist/@types/email-be/html-validation.js +28 -0
  3. package/dist/composables/useRecommendation.js +8 -16
  4. package/dist/composables/useSave.js +19 -17
  5. package/dist/composables/useSaveValidation.js +134 -252
  6. package/dist/composables/useTranslations.js +14 -9
  7. package/dist/config/compiler/recommendationCompilerRules.js +29 -41
  8. package/dist/enums/email-be.js +27 -0
  9. package/dist/enums/recommendation.js +4 -5
  10. package/dist/enums/save-validation.js +2 -2
  11. package/dist/node_modules/valibot/dist/index.js +232 -154
  12. package/dist/package.json.js +2 -2
  13. package/dist/services/emailBe/errors/ApiError.js +50 -0
  14. package/dist/services/emailBe/errors/handleApiError.js +31 -0
  15. package/dist/services/emailBe/errors/toApiError.js +71 -0
  16. package/dist/services/emailBe/html/HtmlValidationService.js +35 -0
  17. package/dist/services/emailBe/html/index.js +6 -0
  18. package/dist/services/emailBe/http/HttpManager.js +68 -0
  19. package/dist/services/emailBe/http/RetryStack.js +24 -0
  20. package/dist/services/emailBe/http/client.js +61 -0
  21. package/dist/services/emailBe/http/index.js +10 -0
  22. package/dist/services/emailBe/http/transportErrors.js +20 -0
  23. package/dist/src/@types/email-be/html-validation.d.ts +51 -0
  24. package/dist/src/composables/useRecommendation.d.ts +0 -4
  25. package/dist/src/composables/useSaveValidation.d.ts +2 -2
  26. package/dist/src/enums/email-be.d.ts +26 -0
  27. package/dist/src/enums/recommendation.d.ts +0 -1
  28. package/dist/src/enums/save-validation.d.ts +3 -15
  29. package/dist/src/services/emailBe/errors/ApiError.d.ts +40 -0
  30. package/dist/src/services/emailBe/errors/handleApiError.d.ts +11 -0
  31. package/dist/src/services/emailBe/errors/toApiError.d.ts +2 -0
  32. package/dist/src/services/emailBe/html/HtmlValidationService.d.ts +8 -0
  33. package/dist/src/services/emailBe/html/index.d.ts +2 -0
  34. package/dist/src/services/emailBe/http/HttpManager.d.ts +13 -0
  35. package/dist/src/services/emailBe/http/RetryStack.d.ts +6 -0
  36. package/dist/src/services/emailBe/http/client.d.ts +3 -0
  37. package/dist/src/services/emailBe/http/index.d.ts +2 -0
  38. package/dist/src/services/emailBe/http/transportErrors.d.ts +15 -0
  39. package/dist/src/services/emailBe/http/types.d.ts +46 -0
  40. package/package.json +1 -1
@@ -4,15 +4,20 @@ import memoize from "../node_modules/lodash-es/memoize.js";
4
4
  import { ref } from "vue";
5
5
  import { useConfig } from "./useConfig.js";
6
6
  const useTranslations = () => {
7
- var o, e;
8
- const { config } = useConfig(), translationsPath = ((e = (o = config.value) == null ? void 0 : o.editor) == null ? void 0 : e.translationsPath) || DEFAULT_EDITOR.translationsPath, translations = ref(eval(translationsPath)), trans = (t, n) => {
9
- var s;
10
- const r = (s = translations.value) == null ? void 0 : s[t];
11
- return r ? n ? Object.entries(n).reduce(
12
- // A function replacer keeps `$&`, `$$` and `$1` in the value literal.
13
- (i, [a, l]) => i.replace(new RegExp(`{${a}}`, "g"), () => String(l)),
14
- r
15
- ) : r : (console.warn(`Translation key not found: ${t}`), t);
7
+ var s, i;
8
+ const { config } = useConfig(), translationsPath = ((i = (s = config.value) == null ? void 0 : s.editor) == null ? void 0 : i.translationsPath) || DEFAULT_EDITOR.translationsPath, translations = ref(eval(translationsPath)), trans = (t, n) => {
9
+ var a;
10
+ const o = (a = translations.value) == null ? void 0 : a[t];
11
+ if (!o)
12
+ return console.warn(`Translation key not found: ${t}`), t;
13
+ const r = Object.keys(n ?? {}).filter(Boolean).map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
14
+ if (n && r.length) {
15
+ const e = new RegExp(`{(${r.join("|")})}|:(${r.join("|")})\\b`, "g");
16
+ return o.replace(e, (f, l, c) => String(
17
+ n[l ?? c]
18
+ ));
19
+ }
20
+ return o;
16
21
  };
17
22
  return memoize(
18
23
  trans,
@@ -1,14 +1,14 @@
1
- import { useRecommendation as N } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as h, REGEX as d, VerticalOrientation as $, CSS as n, ATTRIBUTES as p, CONDITIONS as A, HTML as g } from "../../enums/recommendation.js";
3
- import { prepareRecommendationBlocks as O } from "./utils/recommendationCompilerUtils.js";
4
- const H = [
1
+ import { useRecommendation as R } from "../../composables/useRecommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as A, REGEX as m, VerticalOrientation as y, CSS as n, CONDITIONS as u, ATTRIBUTES as l, HTML as I } from "../../enums/recommendation.js";
3
+ import { prepareRecommendationBlocks as S } from "./utils/recommendationCompilerUtils.js";
4
+ const f = [
5
5
  {
6
6
  id: "replace-images-with-variable-names",
7
7
  description: "Replacing dummy images with variable names in recommendation module",
8
8
  type: "custom",
9
9
  processor: (t) => {
10
10
  let e = t;
11
- return Object.entries(h).forEach(([, r]) => {
11
+ return Object.entries(A).forEach(([, r]) => {
12
12
  Object.entries(r).forEach(([o, i]) => {
13
13
  e = e.replaceAll(i, `{{${o}}}`);
14
14
  });
@@ -42,17 +42,17 @@ const H = [
42
42
  description: "Adding recommendation unresponsive css",
43
43
  type: "custom",
44
44
  processor: (t) => {
45
- const { calculateCardWidth: e, getRecommendationCampaignData: r } = N();
45
+ const { calculateCardWidth: e, getRecommendationCampaignData: r } = R();
46
46
  let o = t;
47
- const i = o.match(d.ID);
47
+ const i = o.match(m.ID);
48
48
  if (i) {
49
- const s = [];
50
- if (i.forEach((c) => {
51
- const m = /recommendation-id="(.*?)"/i.exec(c), E = m ? m[1].trim() : "", u = r(E);
52
- u.textTrimming && u.orientation === $ && s.push(e(u));
53
- }), s.length) {
54
- const c = `width:${Math.min(...s)}px!important;`;
55
- o = o.replace(n.REGULAR_NAME_HEIGHT, `${n.TRIMMED_NAME_HEIGHT} ${c} ${n.ELLIPSIS}`).replace(n.REGULAR_NAME_CONTAINER_HEIGHT, n.TRIMMED_NAME_CONTAINER_CSS).replace(n.RESPONSIVE_NAME_SIZE, `${n.RESPONSIVE_NAME_HEIGHT} ${c} ${n.ELLIPSIS}`).replace(n.RESPONSIVE_NAME_CONTAINER_HEIGHT, n.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
49
+ const c = [];
50
+ if (i.forEach((s) => {
51
+ const a = /recommendation-id="(.*?)"/i.exec(s), d = a ? a[1].trim() : "", p = r(d);
52
+ p.textTrimming && p.orientation === y && c.push(e(p));
53
+ }), c.length) {
54
+ const s = `width:${Math.min(...c)}px!important;`;
55
+ o = o.replace(n.REGULAR_NAME_HEIGHT, `${n.TRIMMED_NAME_HEIGHT} ${s} ${n.ELLIPSIS}`).replace(n.REGULAR_NAME_CONTAINER_HEIGHT, n.TRIMMED_NAME_CONTAINER_CSS).replace(n.RESPONSIVE_NAME_SIZE, `${n.RESPONSIVE_NAME_HEIGHT} ${s} ${n.ELLIPSIS}`).replace(n.RESPONSIVE_NAME_CONTAINER_HEIGHT, n.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
56
56
  }
57
57
  }
58
58
  return o;
@@ -63,36 +63,24 @@ const H = [
63
63
  id: "prepare-recommendations",
64
64
  description: "Replacing product data with template variables in recommendation blocks",
65
65
  type: "custom",
66
- processor: (t) => O(t),
66
+ processor: (t) => S(t),
67
67
  priority: 48
68
68
  },
69
69
  {
70
70
  id: "add-discount-conditions",
71
71
  description: "Adding discount conditions to the recommendation block",
72
72
  type: "custom",
73
- processor: (t) => {
74
- let e = t;
75
- const r = e.match(d.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: o } = N();
76
- return r !== null && r.forEach((i) => {
77
- const s = i.match(d.CUSTOM_FIELD);
78
- if (!s)
79
- return;
80
- const [c] = s, m = c.match(d.CUSTOM_FIELD_INDEXES_PART), E = c.match(d.CUSTOM_FIELD_NAME_PART), u = i.match(d.ATTRIBUTE_PARAGRAPH_START_TAG);
81
- if (!m || !E || !u)
82
- return;
83
- const [T] = m, [I] = E, [_] = u, b = I.substring(1, I.length - 2), S = _.match(d.COMPOSITION) !== null;
84
- let a = c;
85
- if (S) {
86
- const y = T.substring(2, T.length - 3), l = o(y);
87
- b === p.OMNIBUS_PRICE && (l.priceBeforeTextValue && (a = `${l.priceBeforeTextValue}${a}`), l.priceAfterTextValue && (a = `${a}${l.priceAfterTextValue}`)), b === p.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (a = `${l.discountBeforeTextValue}${a}`), l.discountAfterTextValue && (a = `${a}${l.discountAfterTextValue}`));
88
- }
89
- const R = T.substring(2);
90
- let f = "";
91
- b in A.IF && (f = A.IF[b].replaceAll(`{${p.DISCOUNT}}`, `${R}${p.DISCOUNT}`).replaceAll(`{${p.OMNIBUS_DISCOUNT}}`, `${R}${p.OMNIBUS_DISCOUNT}`).replaceAll(`{${p.OMNIBUS_PRICE}}`, `${R}${p.OMNIBUS_PRICE}`));
92
- const M = `${_}${a}${g.PARAGRAPH_END_TAG}`, C = `${f}${S ? M : i}${A.ELSE}${_}${g.PARAGRAPH_END_TAG}${A.END_IF}`;
93
- e = e.replace(i, C);
94
- }), e;
95
- },
73
+ processor: (t) => t.replace(m.ATTRIBUTE_PARAGRAPH, (e) => {
74
+ const r = e.match(m.CUSTOM_FIELD);
75
+ if (!r)
76
+ return e;
77
+ const [o] = r, i = o.match(m.CUSTOM_FIELD_INDEXES_PART), c = o.match(m.CUSTOM_FIELD_NAME_PART), s = e.match(m.ATTRIBUTE_PARAGRAPH_START_TAG);
78
+ if (!i || !c || !s)
79
+ return e;
80
+ const [a] = i, [d] = c, [p] = s, b = d.substring(1, d.length - 2), E = a.substring(2);
81
+ let _ = "";
82
+ return b in u.IF && (_ = u.IF[b].replaceAll(`{${l.DISCOUNT}}`, `${E}${l.DISCOUNT}`).replaceAll(`{${l.OMNIBUS_DISCOUNT}}`, `${E}${l.OMNIBUS_DISCOUNT}`).replaceAll(`{${l.OMNIBUS_PRICE}}`, `${E}${l.OMNIBUS_PRICE}`)), `${_}${e}${u.ELSE}${p}${I.PARAGRAPH_END_TAG}${u.END_IF}`;
83
+ }),
96
84
  priority: 53
97
85
  },
98
86
  {
@@ -147,8 +135,8 @@ const H = [
147
135
  ), e = e.replace(
148
136
  /@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
149
137
  (r, o) => {
150
- const i = o.match(/[^{}]+\{[^{}]*\}/g) || [], s = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
151
- return i.every((m) => s.test(m)) ? "" : r;
138
+ const i = o.match(/[^{}]+\{[^{}]*\}/g) || [], c = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
139
+ return i.every((a) => c.test(a)) ? "" : r;
152
140
  }
153
141
  )), e;
154
142
  },
@@ -208,5 +196,5 @@ const H = [
208
196
  }
209
197
  ];
210
198
  export {
211
- H as recommendationCompilerRules
199
+ f as recommendationCompilerRules
212
200
  };
@@ -0,0 +1,27 @@
1
+ const E = "/email-proxy", e = {
2
+ HTML_VALIDATE: "/v1/html/validate"
3
+ }, n = {
4
+ BAD_GATEWAY: "bad_gateway",
5
+ BAD_REQUEST: "bad_request",
6
+ CONFLICT: "conflict",
7
+ FORBIDDEN: "forbidden",
8
+ INTERNAL_ERROR: "internal_error",
9
+ NOT_FOUND: "not_found",
10
+ RATE_LIMITED: "rate_limited",
11
+ UNAUTHENTICATED: "unauthenticated",
12
+ VALIDATION_FAILED: "validation_failed",
13
+ SESSION_EXPIRED: "session_expired",
14
+ INVALID_RESPONSE: "invalid_response",
15
+ NETWORK: "network_error",
16
+ TIMEOUT: "timeout",
17
+ UNKNOWN: "unknown"
18
+ }, t = {
19
+ PONGO: "pongo",
20
+ LIQUID: "liquid"
21
+ };
22
+ export {
23
+ E as EMAIL_BE_BASE_URL,
24
+ e as EmailBeEndPoints,
25
+ n as EmailBeErrorCodes,
26
+ t as HtmlSyntax
27
+ };
@@ -27,13 +27,12 @@ const e = 20, t = 320, s = "vertical", m = {
27
27
  ID: /recommendation-id="(.*?)"/gi,
28
28
  ATTRIBUTE_PARAGRAPH: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>[\S\s]*?<\/p>/gm,
29
29
  ATTRIBUTE_PARAGRAPH_START_TAG: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>/gm,
30
- COMPOSITION: /composition="true"/gm,
31
30
  CUSTOM_FIELD: /{{(?:reco_)?[0-9]+_[0-8]_(discount|omnibus_discount|omnibus_price)}}/gm,
32
31
  CUSTOM_FIELD_INDEXES_PART: /{{(?:reco_)?[0-9]+_[0-8]_/gm,
33
32
  CUSTOM_FIELD_NAME_PART: /_(discount|omnibus_discount|omnibus_price)}}/gm
34
- }, o = {
35
- PARAGRAPH_END_TAG: "</p>"
36
33
  }, a = {
34
+ PARAGRAPH_END_TAG: "</p>"
35
+ }, o = {
37
36
  REGULAR_NAME_HEIGHT: ".ext-product-name.ins-vertical p { height:90px!important;",
38
37
  TRIMMED_NAME_HEIGHT: ".ext-product-name.ins-vertical p { height:18px!important;",
39
38
  ELLIPSIS: "text-overflow:ellipsis!important; white-space:nowrap!important;",
@@ -47,10 +46,10 @@ const e = 20, t = 320, s = "vertical", m = {
47
46
  export {
48
47
  i as ATTRIBUTES,
49
48
  _ as CONDITIONS,
50
- a as CSS,
49
+ o as CSS,
51
50
  m as DUMMY_IMAGE_MAPPINGS,
52
51
  e as DefaultPadding,
53
- o as HTML,
52
+ a as HTML,
54
53
  t as MinDeviceViewport,
55
54
  n as REGEX,
56
55
  s as VerticalOrientation
@@ -1,4 +1,4 @@
1
- var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s.ExternallyManagedUnsubscribe = "externally-managed-unsubscribe", s))(n || {});
1
+ var r = /* @__PURE__ */ ((n) => (n.CustomFieldScript = "custom-field-script", n.InvalidDynamicTag = "invalid-dynamic-tag", n.InvalidCustomField = "invalid-custom-field", n.MissingIfEndif = "missing-if-endif", n.RecommendationRequiredFields = "recommendation-required-fields", n.RecommendationFilters = "recommendation-filters", n.CheckboxUnsubGroup = "checkbox-unsub-group", n.RadioButtonUnsubGroup = "radio-button-unsub-group", n.ExternallyManagedUnsubscribe = "externally-managed-unsubscribe", n.EmailBeHtml = "email-be-html", n))(r || {});
2
2
  export {
3
- n as SaveValidationRule
3
+ r as SaveValidationRule
4
4
  };