@useinsider/guido 3.26.0-beta.8251afd → 3.26.0-beta.a188943

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 (69) hide show
  1. package/dist/components/Guido.vue.js +1 -1
  2. package/dist/components/Guido.vue2.js +46 -45
  3. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +5 -6
  4. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +19 -18
  5. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +5 -5
  6. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +15 -15
  7. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +6 -6
  8. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +28 -27
  9. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +3 -3
  10. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +42 -27
  11. package/dist/composables/useCustomInterfaceAppearance.js +50 -50
  12. package/dist/composables/useFullStoryBridge.js +10 -9
  13. package/dist/composables/useSave.js +17 -19
  14. package/dist/composables/useSaveValidation.js +249 -142
  15. package/dist/composables/useTranslations.js +9 -14
  16. package/dist/enums/save-validation.js +1 -1
  17. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +14 -14
  18. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +52 -40
  19. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +15 -15
  20. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +17 -15
  21. package/dist/extensions/Blocks/common-control.js +25 -25
  22. package/dist/extensions/DynamicContent/dynamic-content.js +15 -17
  23. package/dist/guido.css +1 -1
  24. package/dist/node_modules/valibot/dist/index.js +122 -184
  25. package/dist/package.json.js +1 -1
  26. package/dist/src/composables/useSaveValidation.d.ts +2 -2
  27. package/dist/src/enums/save-validation.d.ts +14 -3
  28. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +2 -0
  29. package/dist/src/extensions/Blocks/common-control.d.ts +1 -1
  30. package/dist/src/stores/onboarding.d.ts +1 -0
  31. package/dist/src/utils/editorShadowRoot.d.ts +1 -0
  32. package/dist/stores/onboarding.js +4 -1
  33. package/dist/utils/editorShadowRoot.js +8 -0
  34. package/package.json +11 -3
  35. package/dist/@types/email-be/html-validation.js +0 -24
  36. package/dist/enums/email-be.js +0 -27
  37. package/dist/services/emailBe/errors/ApiError.js +0 -50
  38. package/dist/services/emailBe/errors/handleApiError.js +0 -31
  39. package/dist/services/emailBe/errors/toApiError.js +0 -71
  40. package/dist/services/emailBe/html/HtmlValidationService.js +0 -35
  41. package/dist/services/emailBe/html/index.js +0 -6
  42. package/dist/services/emailBe/http/HttpManager.js +0 -68
  43. package/dist/services/emailBe/http/RetryStack.js +0 -23
  44. package/dist/services/emailBe/http/client.js +0 -61
  45. package/dist/services/emailBe/http/index.js +0 -10
  46. package/dist/services/emailBe/http/transportErrors.js +0 -20
  47. package/dist/src/@types/email-be/html-validation.d.ts +0 -35
  48. package/dist/src/enums/email-be.d.ts +0 -26
  49. package/dist/src/extensions/Blocks/_Boilerplate/block.d.ts +0 -11
  50. package/dist/src/extensions/Blocks/_Boilerplate/constants/controlIds.d.ts +0 -7
  51. package/dist/src/extensions/Blocks/_Boilerplate/constants/index.d.ts +0 -10
  52. package/dist/src/extensions/Blocks/_Boilerplate/constants/selectors.d.ts +0 -16
  53. package/dist/src/extensions/Blocks/_Boilerplate/control.d.ts +0 -17
  54. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +0 -15
  55. package/dist/src/extensions/Blocks/_Boilerplate/extension.d.ts +0 -2
  56. package/dist/src/extensions/Blocks/_Boilerplate/iconsRegistry.d.ts +0 -4
  57. package/dist/src/extensions/Blocks/_Boilerplate/settingsPanel.d.ts +0 -4
  58. package/dist/src/extensions/Blocks/_Boilerplate/template.d.ts +0 -6
  59. package/dist/src/services/emailBe/errors/ApiError.d.ts +0 -40
  60. package/dist/src/services/emailBe/errors/handleApiError.d.ts +0 -11
  61. package/dist/src/services/emailBe/errors/toApiError.d.ts +0 -2
  62. package/dist/src/services/emailBe/html/HtmlValidationService.d.ts +0 -8
  63. package/dist/src/services/emailBe/html/index.d.ts +0 -2
  64. package/dist/src/services/emailBe/http/HttpManager.d.ts +0 -13
  65. package/dist/src/services/emailBe/http/RetryStack.d.ts +0 -6
  66. package/dist/src/services/emailBe/http/client.d.ts +0 -3
  67. package/dist/src/services/emailBe/http/index.d.ts +0 -2
  68. package/dist/src/services/emailBe/http/transportErrors.d.ts +0 -15
  69. package/dist/src/services/emailBe/http/types.d.ts +0 -46
@@ -1,17 +1,28 @@
1
1
  /**
2
2
  * Stable discriminators for each save-validation rule site — one per rule that
3
- * can produce a drawer row, kept in sync with the collector; email-be rows share EmailBeHtml.
3
+ * can produce a drawer row, kept in sync with the collector + legacy validator chains.
4
4
  */
5
5
  export declare enum SaveValidationRule {
6
+ CouponTagModified = "coupon-tag-modified",
7
+ DuplicateUnsubBlock = "duplicate-unsub-block",
8
+ UnsubBlockMissingTemplate = "unsub-block-missing-template",
9
+ LiquidSyntax = "liquid-syntax",
10
+ InvalidLinks = "invalid-links",
6
11
  LinkCheckInProgress = "link-check-in-progress",
7
12
  CustomFieldScript = "custom-field-script",
13
+ EmptyHtml = "empty-html",
14
+ MismatchedBraces = "mismatched-braces",
8
15
  InvalidDynamicTag = "invalid-dynamic-tag",
9
16
  InvalidCustomField = "invalid-custom-field",
17
+ ConditionsSyntax = "conditions-syntax",
18
+ WrongEqualityOperator = "wrong-equality-operator",
10
19
  MissingIfEndif = "missing-if-endif",
20
+ ConditionTagSpacing = "condition-tag-spacing",
21
+ BracesInsideIfTag = "braces-inside-if-tag",
11
22
  RecommendationRequiredFields = "recommendation-required-fields",
12
23
  RecommendationFilters = "recommendation-filters",
24
+ InvalidImageType = "invalid-image-type",
13
25
  CheckboxUnsubGroup = "checkbox-unsub-group",
14
26
  RadioButtonUnsubGroup = "radio-button-unsub-group",
15
- ExternallyManagedUnsubscribe = "externally-managed-unsubscribe",
16
- EmailBeHtml = "email-be-html"
27
+ ExternallyManagedUnsubscribe = "externally-managed-unsubscribe"
17
28
  }
@@ -22,5 +22,7 @@ export declare class StrategyControl extends CommonControl {
22
22
  onDestroy(): void;
23
23
  private _teardown;
24
24
  private _setupButtonListeners;
25
+ private _closeLegacyOnboarding;
26
+ private _syncLegacyOnboarding;
25
27
  private _renderState;
26
28
  }
@@ -71,7 +71,7 @@ export declare abstract class CommonControl extends Control {
71
71
  abstract getId(): string;
72
72
  abstract getTemplate(): string;
73
73
  abstract onRender(): Promise<void> | void;
74
- getContainer(): ShadowRoot;
74
+ getContainer(): ShadowRoot | null;
75
75
  onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
76
76
  onDestroy(): void;
77
77
  protected forgetLastPanelNode(): void;
@@ -3120,6 +3120,7 @@ export declare const useOnboardingStore: import("pinia").StoreDefinition<"guidoO
3120
3120
  start(type: OnboardingType): void;
3121
3121
  startOnboarding(type: OnboardingType): void;
3122
3122
  closeForSession(type: OnboardingType): void;
3123
+ resetOnboarding(type: OnboardingType): void;
3123
3124
  close(type: OnboardingType): Promise<void>;
3124
3125
  next(type: OnboardingType): void;
3125
3126
  previous(type: OnboardingType): void;
@@ -0,0 +1 @@
1
+ export declare const findEditorShadowRoot: () => ShadowRoot | null;
@@ -89,7 +89,10 @@ const e = () => ({
89
89
  this.shouldShowOnboarding(n) && !this.isActive(n) && this.start(n);
90
90
  },
91
91
  closeForSession(n) {
92
- this.closedThisSession.includes(n) || this.closedThisSession.push(n), this.onboardings[n].isActive = !1, this.onboardings[n].cardIndex = 0, this.onboardings[n].config = [], this.onboardings[n].cardOffset = 0;
92
+ this.resetOnboarding(n), this.closedThisSession.push(n);
93
+ },
94
+ resetOnboarding(n) {
95
+ this.closedThisSession = this.closedThisSession.filter((o) => o !== n), this.onboardings[n].isActive = !1, this.onboardings[n].cardIndex = 0, this.onboardings[n].config = [], this.onboardings[n].cardOffset = 0;
93
96
  },
94
97
  async close(n) {
95
98
  this.closeForSession(n);
@@ -0,0 +1,8 @@
1
+ import { UI_EDITOR_SELECTOR as t } from "../enums/onboarding.js";
2
+ const n = () => {
3
+ const o = document.querySelector(t);
4
+ return (o == null ? void 0 : o.shadowRoot) ?? null;
5
+ };
6
+ export {
7
+ n as findEditorShadowRoot
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.26.0-beta.8251afd",
3
+ "version": "3.26.0-beta.a188943",
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",
@@ -46,9 +46,11 @@
46
46
  "test:watch": "vitest",
47
47
  "test:visual-update": "npx playwright test --update-snapshots --reporter html",
48
48
  "test:e2e:coverage": "E2E_COVERAGE=true playwright test",
49
+ "coverage:e2e:seed": "node scripts/e2e-coverage/seed-unloaded-coverage.mjs",
49
50
  "coverage:e2e:report": "nyc report --reporter=lcov --reporter=text-summary --report-dir=coverage/e2e",
51
+ "coverage:e2e:verify": "node scripts/e2e-coverage/verify-lcov-inventory.mjs",
50
52
  "test:mutation": "stryker run",
51
- "test:mutation:since": "CHANGED=$(git diff --name-only --diff-filter=AMR origin/develop...HEAD -- 'src/**/*.ts' ':(glob)src/components/organisms/onboarding/**/*.vue' ':(glob)src/components/organisms/header/**/*.vue' ':(glob)src/components/organisms/unsubscribe/**/*.vue' ':(glob)src/components/organisms/save-as-template/**/*.vue' ':(glob)src/components/organisms/email-preview/**/*.vue' ':(glob)src/components/wrappers/**/*.vue' 'src/components/Guido.vue' ':(exclude)src/**/*.test.ts' ':(exclude)src/**/index.ts' ':(exclude)src/@types/**' ':(exclude)src/enums/**' ':(exclude)src/mock/**' ':(exclude)src/**/_Boilerplate/**' | paste -sd, -); if [ -n \"$CHANGED\" ]; then stryker run --incremental --mutate \"$CHANGED\"; else echo \"No changed mutatable src files vs origin/develop\"; fi",
53
+ "test:mutation:since": "CHANGED=$(git diff --name-only --diff-filter=AMR origin/develop...HEAD -- 'src/**/*.ts' ':(glob)src/components/organisms/onboarding/**/*.vue' ':(glob)src/components/organisms/header/**/*.vue' ':(glob)src/components/organisms/unsubscribe/**/*.vue' ':(glob)src/components/organisms/save-as-template/**/*.vue' ':(glob)src/components/organisms/email-preview/**/*.vue' ':(glob)src/components/wrappers/**/*.vue' 'src/components/Guido.vue' ':(exclude)src/**/*.test.ts' ':(exclude)src/**/index.ts' ':(exclude)src/@types/**' ':(exclude)src/enums/**' ':(exclude)src/mock/**' | paste -sd, -); if [ -n \"$CHANGED\" ]; then stryker run --incremental --mutate \"$CHANGED\"; else echo \"No changed mutatable src files vs origin/develop\"; fi",
52
54
  "stripo:manifest": "node scripts/stripo-runtime-manifest.mjs",
53
55
  "prepare": "husky",
54
56
  "preinstall": "rm -rf ./node_modules/.vite"
@@ -58,7 +60,7 @@
58
60
  "license": "ISC",
59
61
  "dependencies": {
60
62
  "@stripoinc/ui-editor-extensions": "3.11.0",
61
- "@useinsider/design-system-organisms": "0.0.3-beta.d816f06",
63
+ "@useinsider/design-system-organisms": "0.4.0",
62
64
  "@useinsider/design-system-vue": "2.5.0",
63
65
  "@vueuse/core": "11.3.0",
64
66
  "lodash-es": "4.17.21",
@@ -99,9 +101,11 @@
99
101
  "globals": "16.0.0",
100
102
  "happy-dom": "15.11.7",
101
103
  "husky": "9.1.7",
104
+ "istanbul-lib-instrument": "6.0.3",
102
105
  "msw": "2.10.3",
103
106
  "nyc": "18.0.0",
104
107
  "sass": "1.69.7",
108
+ "test-exclude": "7.0.2",
105
109
  "typescript": "5.5.4",
106
110
  "typescript-eslint": "8.26.0",
107
111
  "vite-plugin-dts": "4.5.4",
@@ -124,6 +128,10 @@
124
128
  "lcov",
125
129
  "text-summary"
126
130
  ],
131
+ "extension": [
132
+ ".ts",
133
+ ".vue"
134
+ ],
127
135
  "all": false
128
136
  },
129
137
  "guido": {
@@ -1,24 +0,0 @@
1
- import { object as r, array as o, boolean as l, string as e, nullable as n, union as a, number as t, record as i, pipe as c, transform as s, tuple as m } from "../../node_modules/valibot/dist/index.js";
2
- const d = r({
3
- code: e(),
4
- trans: r({
5
- key: e(),
6
- // PHP serializes an empty associative array as `[]`, so an empty list means "no placeholders".
7
- replace: a([
8
- i(e(), a([e(), t()])),
9
- c(m([]), s(() => ({})))
10
- ])
11
- }),
12
- anchor: n(r({
13
- selector: e(),
14
- indexes: o(t())
15
- })),
16
- details: o(e())
17
- }), u = r({
18
- valid: l(),
19
- errors: o(d)
20
- });
21
- export {
22
- d as HtmlValidationErrorSchema,
23
- u as HtmlValidationResultSchema
24
- };
@@ -1,27 +0,0 @@
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
- };
@@ -1,50 +0,0 @@
1
- var o = Object.defineProperty;
2
- var d = (e, r, s) => r in e ? o(e, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[r] = s;
3
- var t = (e, r, s) => d(e, typeof r != "symbol" ? r + "" : r, s);
4
- class a extends Error {
5
- constructor(s) {
6
- super(s.message);
7
- t(this, "status");
8
- t(this, "code");
9
- t(this, "meta");
10
- t(this, "errors");
11
- t(this, "requestId");
12
- // Guido already showed the auth modal/toast for this failure, so callers must not toast again.
13
- t(this, "authReported");
14
- t(this, "cause");
15
- this.name = new.target.name, this.status = s.status, this.code = s.code, this.meta = s.meta ?? {}, this.errors = s.errors ?? {}, this.requestId = s.requestId ?? "", this.authReported = s.authReported ?? !1, this.cause = s.cause;
16
- }
17
- is(s) {
18
- return this.code === s;
19
- }
20
- }
21
- class u extends a {
22
- firstMessage() {
23
- const [r] = Object.values(this.errors);
24
- return (r == null ? void 0 : r[0]) ?? this.message;
25
- }
26
- }
27
- class h extends a {
28
- }
29
- class n extends a {
30
- }
31
- class l extends a {
32
- }
33
- class E extends a {
34
- }
35
- class x extends a {
36
- }
37
- class i extends a {
38
- }
39
- const m = (e) => e instanceof a;
40
- export {
41
- a as ApiError,
42
- n as ForbiddenError,
43
- i as NetworkError,
44
- h as NotFoundError,
45
- E as RateLimitError,
46
- x as ServerError,
47
- l as UnauthorizedError,
48
- u as ValidationError,
49
- m as isApiError
50
- };
@@ -1,31 +0,0 @@
1
- import { useToaster as a } from "../../../composables/useToaster.js";
2
- import { useTranslations as f } from "../../../composables/useTranslations.js";
3
- import { ToasterTypeOptions as i } from "../../../enums/toaster.js";
4
- import { UnauthorizedError as u, ValidationError as c } from "./ApiError.js";
5
- import { toApiError as m } from "./toApiError.js";
6
- const p = "products.something-went-wrong";
7
- function l(o) {
8
- return o instanceof c ? o.firstMessage() : f()(p);
9
- }
10
- function E(o, t) {
11
- return (t == null ? void 0 : t[o.code]) ?? (t == null ? void 0 : t[o.status]);
12
- }
13
- function A(o, t) {
14
- const r = m(o);
15
- if (r.authReported || r instanceof u)
16
- return r;
17
- const s = E(r, t.overrides);
18
- let n = "";
19
- if (s) {
20
- const e = s(r);
21
- if (e === !1)
22
- return r;
23
- n = typeof e == "string" ? e : "";
24
- } else
25
- n = l(r);
26
- return console.error(`${t.context} failed`, r), n && !t.silent && a().showToaster({ type: i.Error, message: n }), r;
27
- }
28
- export {
29
- p as GENERIC_MESSAGE_KEY,
30
- A as handleApiError
31
- };
@@ -1,71 +0,0 @@
1
- import { EmailBeErrorCodes as t } from "../../../enums/email-be.js";
2
- import { HttpStatusError as u, TransportNetworkError as i, SessionExpiredError as c } from "../http/transportErrors.js";
3
- import { isApiError as d, NetworkError as m, UnauthorizedError as a, ServerError as E, ApiError as N, RateLimitError as A, ValidationError as T, NotFoundError as f, ForbiddenError as I } from "./ApiError.js";
4
- const p = {
5
- 400: t.BAD_REQUEST,
6
- 401: t.UNAUTHENTICATED,
7
- 403: t.FORBIDDEN,
8
- 404: t.NOT_FOUND,
9
- 409: t.CONFLICT,
10
- 419: t.SESSION_EXPIRED,
11
- 422: t.VALIDATION_FAILED,
12
- 429: t.RATE_LIMITED,
13
- 500: t.INTERNAL_ERROR,
14
- 502: t.BAD_GATEWAY
15
- };
16
- function R(e) {
17
- return typeof e == "object" && e !== null && !Array.isArray(e);
18
- }
19
- function S(e) {
20
- const { status: n } = e, o = R(e.body) ? e.body : {}, r = o.error ?? {}, s = {
21
- status: n,
22
- code: r.code ?? p[n] ?? t.UNKNOWN,
23
- message: r.message ?? e.message,
24
- meta: r.meta ?? {},
25
- errors: r.errors ?? {},
26
- requestId: o.requestId ?? e.requestId,
27
- authReported: e.authReported,
28
- cause: e
29
- };
30
- switch (n) {
31
- case 401:
32
- case 419:
33
- return new a(s);
34
- case 403:
35
- return new I(s);
36
- case 404:
37
- return new f(s);
38
- case 422:
39
- return new T(s);
40
- case 429:
41
- return new A(s);
42
- default:
43
- return n >= 500 ? new E(s) : new N(s);
44
- }
45
- }
46
- function g(e) {
47
- if (d(e))
48
- return e;
49
- if (e instanceof u)
50
- return S(e);
51
- if (e instanceof i)
52
- return new m({
53
- status: 0,
54
- code: e.isTimeout ? t.TIMEOUT : t.NETWORK,
55
- message: e.message,
56
- cause: e.cause
57
- });
58
- if (e instanceof c)
59
- return new a({
60
- status: 0,
61
- code: t.SESSION_EXPIRED,
62
- message: e.message,
63
- authReported: !0,
64
- cause: e
65
- });
66
- const n = e instanceof Error ? e.message : String(e);
67
- return new E({ status: 0, code: t.UNKNOWN, message: n, cause: e });
68
- }
69
- export {
70
- g as toApiError
71
- };
@@ -1,35 +0,0 @@
1
- import { EmailBeEndPoints as a, EmailBeErrorCodes as s } from "../../../enums/email-be.js";
2
- import { ApiError as i } from "../errors/ApiError.js";
3
- import { handleApiError as c } from "../errors/handleApiError.js";
4
- import { HtmlValidationResultSchema as m } from "../../../@types/email-be/html-validation.js";
5
- import { base64EncodeWithSpecialChars as n } from "../../../utils/base64.js";
6
- import { safeParse as d } from "../../../node_modules/valibot/dist/index.js";
7
- const l = "[HTML_VALIDATION_SERVICE]", p = { maxRetries: 1, backoffMs: [500] };
8
- class I {
9
- constructor(t) {
10
- this.http = t;
11
- }
12
- async validate({ html: t, syntax: o }) {
13
- try {
14
- const r = await this.http.request({
15
- method: "POST",
16
- url: a.HTML_VALIDATE,
17
- body: { html: n(t), syntax: o },
18
- retry: p
19
- }), e = d(m, r);
20
- if (!e.success)
21
- throw new i({
22
- status: 200,
23
- code: s.INVALID_RESPONSE,
24
- message: "Validate answered with an unexpected body",
25
- cause: e.issues
26
- });
27
- return { ok: !0, data: e.output };
28
- } catch (r) {
29
- return { ok: !1, error: c(r, { context: `${l} validate` }) };
30
- }
31
- }
32
- }
33
- export {
34
- I as HtmlValidationService
35
- };
@@ -1,6 +0,0 @@
1
- import { emailBeHttp as t } from "../http/index.js";
2
- import { HtmlValidationService as i } from "./HtmlValidationService.js";
3
- const m = new i(t);
4
- export {
5
- m as htmlValidationService
6
- };
@@ -1,68 +0,0 @@
1
- var u = Object.defineProperty;
2
- var l = (r, t, e) => t in r ? u(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var o = (r, t, e) => l(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { toApiError as y } from "../errors/toApiError.js";
5
- import { defaultRetryFor as d, shouldRetry as h, delay as p, backoffDelay as c } from "./RetryStack.js";
6
- const f = 204, m = (r, t) => {
7
- if (t === null || typeof t != "object" || Array.isArray(t))
8
- return t;
9
- const e = t;
10
- return Object.fromEntries(Object.keys(e).sort().map((s) => [s, e[s]]));
11
- };
12
- function a(r) {
13
- return r == null ? "" : typeof r == "string" ? r : JSON.stringify(r, m);
14
- }
15
- class w {
16
- constructor(t, e) {
17
- o(this, "inFlight", /* @__PURE__ */ new Map());
18
- this.transport = t, this.defaults = e;
19
- }
20
- async request(t) {
21
- return (await this.requestEnvelope(t)).data;
22
- }
23
- async requestEnvelope(t) {
24
- if (!this.shouldDedup(t))
25
- return this.executeWithRetry(t);
26
- const e = this.buildKey(t), s = this.inFlight.get(e);
27
- if (s)
28
- return s;
29
- const i = this.executeWithRetry(t);
30
- this.inFlight.set(e, i);
31
- try {
32
- return await i;
33
- } finally {
34
- this.inFlight.delete(e);
35
- }
36
- }
37
- buildKey(t) {
38
- return [
39
- t.method,
40
- t.url,
41
- a(t.params),
42
- a(t.body)
43
- ].join("|");
44
- }
45
- shouldDedup(t) {
46
- return t.body instanceof FormData || t.dedup === !1 ? !1 : t.dedup === !0 || this.defaults.dedup && t.method === "GET";
47
- }
48
- resolveRetry(t) {
49
- return t.retry === null ? null : t.retry ?? d(t.method, this.defaults.retry);
50
- }
51
- async executeWithRetry(t) {
52
- const e = this.resolveRetry(t);
53
- let s = 0;
54
- for (; ; )
55
- try {
56
- const { status: i, data: n } = await this.transport.request(t);
57
- return i === f || n === "" || n == null ? { data: void 0, meta: [] } : n;
58
- } catch (i) {
59
- const n = y(i);
60
- if (!h(n, e, s))
61
- throw n;
62
- await p(c(e, s)), s += 1;
63
- }
64
- }
65
- }
66
- export {
67
- w as HttpManager
68
- };
@@ -1,23 +0,0 @@
1
- import { NetworkError as f } from "../errors/ApiError.js";
2
- const s = /* @__PURE__ */ new Set(["GET", "PUT", "DELETE"]);
3
- function a(t, e) {
4
- return s.has(t) ? e : null;
5
- }
6
- function o(t, e, n) {
7
- return !e || n >= e.maxRetries || t.authReported ? !1 : t instanceof f || t.status === 429 || t.status >= 500;
8
- }
9
- function r(t, e) {
10
- const n = t.backoffMs[t.backoffMs.length - 1] ?? 0;
11
- return t.backoffMs[e] ?? n;
12
- }
13
- function c(t) {
14
- return new Promise((e) => {
15
- setTimeout(e, t);
16
- });
17
- }
18
- export {
19
- r as backoffDelay,
20
- a as defaultRetryFor,
21
- c as delay,
22
- o as shouldRetry
23
- };
@@ -1,61 +0,0 @@
1
- import { isPanelOrigin as u, reportAuthError as l } from "../../../composables/useAuthError.js";
2
- import { getCsrfToken as p } from "../../../utils/genericUtil.js";
3
- import { SessionExpiredError as h, TransportNetworkError as m, HttpStatusError as T } from "./transportErrors.js";
4
- const w = 3e4, y = [401, 403, 419], S = ["POST", "PUT", "PATCH"], E = (t, s, e) => {
5
- const o = new URLSearchParams();
6
- Object.entries(e ?? {}).forEach(([i, r]) => {
7
- r != null && o.append(i, String(r));
8
- });
9
- const n = o.toString();
10
- return `${t}${s}${n ? `?${n}` : ""}`;
11
- }, b = (t, s) => {
12
- const e = {
13
- Accept: "application/json",
14
- "X-CSRF-TOKEN": p(),
15
- // Without this a guest fetch gets a 302 to the login page, never an auth status.
16
- "X-Requested-With": "XMLHttpRequest"
17
- }, o = { method: t.method, headers: e, signal: s, credentials: "same-origin" };
18
- return t.body !== void 0 && S.includes(t.method) && (t.body instanceof FormData ? o.body = t.body : (e["Content-Type"] = "application/json", o.body = JSON.stringify(t.body))), o;
19
- }, f = (t) => {
20
- if (t === "")
21
- return null;
22
- try {
23
- return JSON.parse(t);
24
- } catch {
25
- return t;
26
- }
27
- }, O = (t, s, e) => {
28
- try {
29
- l(t, s, new URL(e, window.location.href).href);
30
- } catch {
31
- }
32
- }, q = (t, s = w) => ({
33
- async request(e) {
34
- if (window.isSessionExpired)
35
- throw new h();
36
- const o = E(t, e.url, e.params), n = new AbortController(), i = setTimeout(() => n.abort(), e.timeoutMs ?? s);
37
- let r, c;
38
- try {
39
- r = await fetch(o, b(e, n.signal)), c = await r.text();
40
- } catch (a) {
41
- throw new m(n.signal.aborted, a);
42
- } finally {
43
- clearTimeout(i);
44
- }
45
- const d = f(c);
46
- if (!r.ok) {
47
- const a = y.includes(r.status) && u(o);
48
- throw a && O(r.status, c, o), new T(
49
- r.status,
50
- d,
51
- r.headers.get("x-request-id") ?? "",
52
- a
53
- );
54
- }
55
- return { status: r.status, data: d };
56
- }
57
- });
58
- export {
59
- w as REQUEST_TIMEOUT_MS,
60
- q as createFetchTransport
61
- };
@@ -1,10 +0,0 @@
1
- import { EMAIL_BE_BASE_URL as r } from "../../../enums/email-be.js";
2
- import { createFetchTransport as t } from "./client.js";
3
- import { HttpManager as e } from "./HttpManager.js";
4
- const a = new e(t(r), {
5
- retry: { maxRetries: 2, backoffMs: [250, 1e3] },
6
- dedup: !0
7
- });
8
- export {
9
- a as emailBeHttp
10
- };
@@ -1,20 +0,0 @@
1
- class i extends Error {
2
- constructor(r, t, e, o) {
3
- super(`HTTP Error: ${r}`), this.status = r, this.body = t, this.requestId = e, this.authReported = o, this.name = "HttpStatusError";
4
- }
5
- }
6
- class n extends Error {
7
- constructor(r, t) {
8
- super(r ? "Request timeout" : "Network error"), this.isTimeout = r, this.cause = t, this.name = "TransportNetworkError";
9
- }
10
- }
11
- class u extends Error {
12
- constructor() {
13
- super("Session expired"), this.name = "SessionExpiredError";
14
- }
15
- }
16
- export {
17
- i as HttpStatusError,
18
- u as SessionExpiredError,
19
- n as TransportNetworkError
20
- };
@@ -1,35 +0,0 @@
1
- import type { HtmlSyntaxValue } from '@@/Enums/email-be';
2
- import * as v from 'valibot';
3
- export declare const HtmlValidationErrorSchema: v.ObjectSchema<{
4
- readonly code: v.StringSchema<undefined>;
5
- readonly trans: v.ObjectSchema<{
6
- readonly key: v.StringSchema<undefined>;
7
- readonly replace: v.UnionSchema<[v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.SchemaWithPipe<readonly [v.TupleSchema<[], undefined>, v.TransformAction<[], {}>]>], undefined>;
8
- }, undefined>;
9
- readonly anchor: v.NullableSchema<v.ObjectSchema<{
10
- readonly selector: v.StringSchema<undefined>;
11
- readonly indexes: v.ArraySchema<v.NumberSchema<undefined>, undefined>;
12
- }, undefined>, undefined>;
13
- readonly details: v.ArraySchema<v.StringSchema<undefined>, undefined>;
14
- }, undefined>;
15
- export declare const HtmlValidationResultSchema: v.ObjectSchema<{
16
- readonly valid: v.BooleanSchema<undefined>;
17
- readonly errors: v.ArraySchema<v.ObjectSchema<{
18
- readonly code: v.StringSchema<undefined>;
19
- readonly trans: v.ObjectSchema<{
20
- readonly key: v.StringSchema<undefined>;
21
- readonly replace: v.UnionSchema<[v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.SchemaWithPipe<readonly [v.TupleSchema<[], undefined>, v.TransformAction<[], {}>]>], undefined>;
22
- }, undefined>;
23
- readonly anchor: v.NullableSchema<v.ObjectSchema<{
24
- readonly selector: v.StringSchema<undefined>;
25
- readonly indexes: v.ArraySchema<v.NumberSchema<undefined>, undefined>;
26
- }, undefined>, undefined>;
27
- readonly details: v.ArraySchema<v.StringSchema<undefined>, undefined>;
28
- }, undefined>, undefined>;
29
- }, undefined>;
30
- export type HtmlValidationError = v.InferOutput<typeof HtmlValidationErrorSchema>;
31
- export type HtmlValidationResult = v.InferOutput<typeof HtmlValidationResultSchema>;
32
- export type ValidateHtmlParams = {
33
- html: string;
34
- syntax: HtmlSyntaxValue;
35
- };
@@ -1,26 +0,0 @@
1
- export declare const EMAIL_BE_BASE_URL = "/email-proxy";
2
- export declare const EmailBeEndPoints: {
3
- readonly HTML_VALIDATE: "/v1/html/validate";
4
- };
5
- export declare const EmailBeErrorCodes: {
6
- readonly BAD_GATEWAY: "bad_gateway";
7
- readonly BAD_REQUEST: "bad_request";
8
- readonly CONFLICT: "conflict";
9
- readonly FORBIDDEN: "forbidden";
10
- readonly INTERNAL_ERROR: "internal_error";
11
- readonly NOT_FOUND: "not_found";
12
- readonly RATE_LIMITED: "rate_limited";
13
- readonly UNAUTHENTICATED: "unauthenticated";
14
- readonly VALIDATION_FAILED: "validation_failed";
15
- readonly SESSION_EXPIRED: "session_expired";
16
- readonly INVALID_RESPONSE: "invalid_response";
17
- readonly NETWORK: "network_error";
18
- readonly TIMEOUT: "timeout";
19
- readonly UNKNOWN: "unknown";
20
- };
21
- export type ApiErrorCode = typeof EmailBeErrorCodes[keyof typeof EmailBeErrorCodes];
22
- export declare const HtmlSyntax: {
23
- readonly PONGO: "pongo";
24
- readonly LIQUID: "liquid";
25
- };
26
- export type HtmlSyntaxValue = typeof HtmlSyntax[keyof typeof HtmlSyntax];
@@ -1,11 +0,0 @@
1
- import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
2
- export declare const BLOCK_ID = "{{your-block}}";
3
- export declare class CustomBlock extends Block {
4
- constructor();
5
- getId(): string;
6
- getIcon(): string;
7
- getBlockCompositionType(): BlockCompositionType;
8
- getName(): string;
9
- getDescription(): string;
10
- getTemplate(): string;
11
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Control IDs used in the Extension
3
- * These IDs are returned by the getId() method of each control
4
- */
5
- export declare enum BlockControlId {
6
- BLOCK_BACKGROUND = "{{your-block}}-background-color-control"
7
- }