@useinsider/guido 3.30.0 → 3.30.1-beta.8cab2a2
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/dist/@types/config/schemas.js +4 -4
- package/dist/@types/email-be/templates.js +11 -0
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +11 -16
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +11 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +51 -51
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
- package/dist/composables/useExport.js +8 -7
- package/dist/composables/useHtmlValidator.js +102 -100
- package/dist/composables/useToaster.js +11 -10
- package/dist/composables/useVersionHistoryApi.js +22 -21
- package/dist/composables/validators/useLiquidValidator.js +26 -24
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/enums/defaults.js +4 -5
- package/dist/enums/email-be.js +16 -9
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +148 -141
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +53 -53
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +40 -39
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -26
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +33 -32
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +23 -22
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +79 -78
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +50 -41
- package/dist/guido.css +1 -1
- package/dist/node_modules/valibot/dist/index.js +95 -90
- package/dist/package.json.js +2 -2
- package/dist/services/emailBe/errors/ApiError.js +27 -26
- package/dist/services/emailBe/templates/TemplateService.js +112 -0
- package/dist/services/emailBe/templates/index.js +6 -0
- package/dist/services/templateLibraryApi.js +60 -88
- package/dist/src/@types/email-be/templates.d.ts +36 -0
- package/dist/src/@types/save-as-template.d.ts +1 -23
- package/dist/src/enums/email-be.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +2 -0
- package/dist/src/services/emailBe/templates/TemplateService.d.ts +12 -0
- package/dist/src/services/emailBe/templates/index.d.ts +2 -0
- package/dist/src/stores/preview.d.ts +3 -0
- package/dist/src/utils/ampPreviewSanitizer.d.ts +5 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/stores/preview.js +21 -15
- package/dist/utils/ampPreviewSanitizer.js +46 -0
- package/dist/utils/htmlEscape.js +5 -1
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var d = (
|
|
3
|
-
var t = (
|
|
4
|
-
class
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var d = (s, r, e) => r in s ? a(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
|
|
3
|
+
var t = (s, r, e) => d(s, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
class o extends Error {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
super(e.message);
|
|
7
7
|
t(this, "status");
|
|
8
8
|
t(this, "code");
|
|
9
9
|
t(this, "meta");
|
|
@@ -12,39 +12,40 @@ class a extends Error {
|
|
|
12
12
|
// Guido already showed the auth modal/toast for this failure, so callers must not toast again.
|
|
13
13
|
t(this, "authReported");
|
|
14
14
|
t(this, "cause");
|
|
15
|
-
this.name = new.target.name, this.status =
|
|
15
|
+
this.name = new.target.name, this.status = e.status, this.code = e.code, this.meta = e.meta ?? {}, this.errors = e.errors ?? {}, this.requestId = e.requestId ?? "", this.authReported = e.authReported ?? !1, this.cause = e.cause;
|
|
16
16
|
}
|
|
17
|
-
is(
|
|
18
|
-
return this.code ===
|
|
17
|
+
is(e) {
|
|
18
|
+
return this.code === e;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class c extends o {
|
|
22
22
|
firstMessage() {
|
|
23
23
|
const [r] = Object.values(this.errors);
|
|
24
24
|
return (r == null ? void 0 : r[0]) ?? this.message;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class u extends o {
|
|
28
28
|
}
|
|
29
|
-
class
|
|
29
|
+
class h extends o {
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class i extends o {
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class l extends o {
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class E extends o {
|
|
36
36
|
}
|
|
37
|
-
class
|
|
37
|
+
class x extends o {
|
|
38
38
|
}
|
|
39
|
-
const m = (
|
|
39
|
+
const m = (s) => s instanceof o, p = (s) => s instanceof c;
|
|
40
40
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
m as isApiError
|
|
41
|
+
o as ApiError,
|
|
42
|
+
h as ForbiddenError,
|
|
43
|
+
x as NetworkError,
|
|
44
|
+
u as NotFoundError,
|
|
45
|
+
l as RateLimitError,
|
|
46
|
+
E as ServerError,
|
|
47
|
+
i as UnauthorizedError,
|
|
48
|
+
c as ValidationError,
|
|
49
|
+
m as isApiError,
|
|
50
|
+
p as isValidationError
|
|
50
51
|
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { useTranslations as h } from "../../../composables/useTranslations.js";
|
|
2
|
+
import { EmailBeErrorCodes as s, EmailBeEndPoints as o } from "../../../enums/email-be.js";
|
|
3
|
+
import { isValidationError as p, ApiError as l } from "../errors/ApiError.js";
|
|
4
|
+
import { handleApiError as n } from "../errors/handleApiError.js";
|
|
5
|
+
import { TemplateCategoryListSchema as y, TemplateCategorySchema as m, TemplateNameCheckSchema as f, CreatedTemplateSchema as A } from "../../../@types/email-be/templates.js";
|
|
6
|
+
import { is as C, safeParse as O } from "../../../node_modules/valibot/dist/index.js";
|
|
7
|
+
const L = "[TEMPLATE_SERVICE]", T = null, g = [
|
|
8
|
+
400,
|
|
9
|
+
404,
|
|
10
|
+
409,
|
|
11
|
+
500,
|
|
12
|
+
503,
|
|
13
|
+
504,
|
|
14
|
+
s.INVALID_RESPONSE,
|
|
15
|
+
s.NETWORK,
|
|
16
|
+
s.TIMEOUT,
|
|
17
|
+
s.UNKNOWN
|
|
18
|
+
], d = () => h()("user-management.forbidden-action"), i = () => h()("newsletter.try-again-later");
|
|
19
|
+
function N(a, e) {
|
|
20
|
+
return p(a) ? Object.keys(a.errors).length ? a.firstMessage() : (!(a.cause instanceof Error) || a.message !== a.cause.message) && a.message ? a.message : e : e;
|
|
21
|
+
}
|
|
22
|
+
function S(a, e) {
|
|
23
|
+
return new l({ status: 200, code: s.INVALID_RESPONSE, message: a, cause: e });
|
|
24
|
+
}
|
|
25
|
+
function c(a, e, t) {
|
|
26
|
+
const r = O(a, e);
|
|
27
|
+
if (!r.success)
|
|
28
|
+
throw S(t, r.issues);
|
|
29
|
+
return r.output;
|
|
30
|
+
}
|
|
31
|
+
class R {
|
|
32
|
+
constructor(e) {
|
|
33
|
+
this.http = e;
|
|
34
|
+
}
|
|
35
|
+
errorOptions(e, t = "", r = {}) {
|
|
36
|
+
const E = t ? {
|
|
37
|
+
...Object.fromEntries(g.map((u) => [u, () => t])),
|
|
38
|
+
422: (u) => N(u, t)
|
|
39
|
+
} : {};
|
|
40
|
+
return {
|
|
41
|
+
context: `${L} ${e}`,
|
|
42
|
+
...r,
|
|
43
|
+
overrides: {
|
|
44
|
+
...E,
|
|
45
|
+
[s.FORBIDDEN]: d,
|
|
46
|
+
[s.PRODUCT_TYPE_DISABLED]: d,
|
|
47
|
+
[s.TEMPLATE_ALLOWLIST_UNAVAILABLE]: i,
|
|
48
|
+
[s.PRODUCT_TYPE_FETCH_FAILED]: i,
|
|
49
|
+
429: i,
|
|
50
|
+
502: i,
|
|
51
|
+
...r.overrides
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async listCategories(e = "") {
|
|
56
|
+
try {
|
|
57
|
+
const t = await this.http.request({
|
|
58
|
+
method: "GET",
|
|
59
|
+
url: o.TEMPLATE_CATEGORIES
|
|
60
|
+
});
|
|
61
|
+
return { ok: !0, data: c(y, t, "Categories answered without a list").filter((E) => C(m, E)) };
|
|
62
|
+
} catch (t) {
|
|
63
|
+
return { ok: !1, error: n(t, this.errorOptions("listCategories", e)) };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async createCategory(e) {
|
|
67
|
+
try {
|
|
68
|
+
const t = await this.http.request({
|
|
69
|
+
method: "POST",
|
|
70
|
+
url: o.TEMPLATE_CATEGORIES,
|
|
71
|
+
body: { name: e },
|
|
72
|
+
retry: T
|
|
73
|
+
});
|
|
74
|
+
return { ok: !0, data: c(m, t, "Category create answered without a category") };
|
|
75
|
+
} catch (t) {
|
|
76
|
+
return { ok: !1, error: n(t, this.errorOptions("createCategory")) };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async isNameTaken(e) {
|
|
80
|
+
try {
|
|
81
|
+
const t = await this.http.request({
|
|
82
|
+
method: "POST",
|
|
83
|
+
url: o.TEMPLATE_NAME_CHECK,
|
|
84
|
+
body: { name: e }
|
|
85
|
+
}), { exists: r } = c(f, t, "Name check answered without a verdict");
|
|
86
|
+
return { ok: !0, data: r };
|
|
87
|
+
} catch (t) {
|
|
88
|
+
return { ok: !1, error: n(t, this.errorOptions("isNameTaken", "", { silent: !0 })) };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async create(e, t) {
|
|
92
|
+
try {
|
|
93
|
+
const r = await this.http.request({
|
|
94
|
+
method: "POST",
|
|
95
|
+
url: o.TEMPLATES,
|
|
96
|
+
body: e,
|
|
97
|
+
retry: T
|
|
98
|
+
});
|
|
99
|
+
return { ok: !0, data: c(A, r, "Create answered without a template").id };
|
|
100
|
+
} catch (r) {
|
|
101
|
+
return {
|
|
102
|
+
ok: !1,
|
|
103
|
+
error: n(r, this.errorOptions("create", t.fallback, {
|
|
104
|
+
overrides: { [s.TEMPLATE_NAME_CONFLICT]: () => t.nameTaken }
|
|
105
|
+
}))
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
R as TemplateService
|
|
112
|
+
};
|
|
@@ -1,105 +1,77 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { useSaveAsTemplateStore as
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { useActionsApi as v } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useConfig as w } from "../composables/useConfig.js";
|
|
3
|
+
import { useToaster as h } from "../composables/useToaster.js";
|
|
4
|
+
import { useTranslations as A } from "../composables/useTranslations.js";
|
|
5
|
+
import { useHtmlDocumentCountValidator as b } from "../composables/validators/useHtmlDocumentCountValidator.js";
|
|
6
|
+
import { useLiquidValidator as k } from "../composables/validators/useLiquidValidator.js";
|
|
7
|
+
import { HtmlSyntax as p } from "../enums/email-be.js";
|
|
8
|
+
import { ToasterTypeOptions as L } from "../enums/toaster.js";
|
|
9
|
+
import { useRecommendationExtensionStore as N } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
10
|
+
import { templateService as i } from "./emailBe/templates/index.js";
|
|
11
|
+
import { useSaveAsTemplateStore as H } from "../stores/save-as-template.js";
|
|
12
|
+
import { ProductType as D, MessageType as I } from "../@types/config/schemas.js";
|
|
13
|
+
import "../@types/config/defaults.js";
|
|
14
|
+
import { base64EncodeWithSpecialChars as o } from "../utils/base64.js";
|
|
15
|
+
import { useTemplatePreparation as x } from "../utils/templatePreparation.js";
|
|
16
|
+
const _ = () => {
|
|
17
|
+
const { handleError: u, showToaster: d } = h(), { config: y, isFeatureEnabled: T } = w(), { validateLiquidSyntax: f } = k(), { validateSingleHtmlDocument: g } = b(), { getTemplateData: C } = v(), s = A();
|
|
17
18
|
return {
|
|
18
19
|
getCategories: async () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return Array.isArray(e) ? e : ((!w(e) || e.type !== "alert") && console.error("[TEMPLATE_LIBRARY_API] Unexpected get-template-categories response", e), i({
|
|
22
|
-
message: n("newsletter.template-library-service-error"),
|
|
23
|
-
type: T.Error
|
|
24
|
-
}), []);
|
|
25
|
-
} catch (e) {
|
|
26
|
-
return o(e, "Failed to fetch template categories"), [];
|
|
27
|
-
}
|
|
20
|
+
const e = await i.listCategories(s("newsletter.template-library-service-error"));
|
|
21
|
+
return e.ok ? e.data : [];
|
|
28
22
|
},
|
|
29
23
|
checkTemplateNameAvailability: async (e) => {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
return !t;
|
|
24
|
+
const t = await i.isNameTaken(e);
|
|
25
|
+
return !t.ok || !t.data;
|
|
34
26
|
},
|
|
35
27
|
createCategory: async (e) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"/newsletter/template-library/create-category",
|
|
39
|
-
{ name: e }
|
|
40
|
-
);
|
|
41
|
-
return t.toString();
|
|
42
|
-
} catch (t) {
|
|
43
|
-
return o(t, "Failed to create category"), "";
|
|
44
|
-
}
|
|
28
|
+
const t = await i.createCategory(e);
|
|
29
|
+
return t.ok ? t.data.id.toString() : "";
|
|
45
30
|
},
|
|
46
31
|
createTemplate: async () => {
|
|
47
|
-
var e
|
|
32
|
+
var e;
|
|
48
33
|
try {
|
|
49
|
-
const { prepareTemplateDetails:
|
|
50
|
-
if (!
|
|
34
|
+
const { prepareTemplateDetails: t } = x(), m = H(), c = await C();
|
|
35
|
+
if (!g(c.html))
|
|
51
36
|
return !1;
|
|
52
|
-
const a = await
|
|
53
|
-
if (
|
|
37
|
+
const a = await t(c), l = T("liquidSyntax");
|
|
38
|
+
if (l && !await f(a.compiledHtml))
|
|
54
39
|
return !1;
|
|
55
|
-
const
|
|
56
|
-
name:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"newsletter.template-library-save-alert",
|
|
87
|
-
{ templateName: s.getTemplateName }
|
|
88
|
-
),
|
|
89
|
-
type: T.Error
|
|
90
|
-
}), !1) : (i({
|
|
91
|
-
message: n(
|
|
92
|
-
"newsletter.template-library-save-success",
|
|
93
|
-
{ templateName: s.getTemplateName }
|
|
94
|
-
),
|
|
95
|
-
type: "success"
|
|
96
|
-
}), !0);
|
|
97
|
-
} catch (m) {
|
|
98
|
-
return o(m, "Failed to create template"), !1;
|
|
40
|
+
const n = m.getTemplateName, r = (e = y.value) == null ? void 0 : e.partner, S = {
|
|
41
|
+
name: n,
|
|
42
|
+
type: (r == null ? void 0 : r.messageType) === I.TRANSACTIONAL ? "transactional" : "promotional",
|
|
43
|
+
editor: "guido",
|
|
44
|
+
product: (r == null ? void 0 : r.productType) === D.ARCHITECT ? "architect" : "newsletter",
|
|
45
|
+
engine: l ? p.LIQUID : p.PONGO,
|
|
46
|
+
categoryIds: m.getSelectedCategoryIds,
|
|
47
|
+
content: {
|
|
48
|
+
html: o(a.compiledHtml),
|
|
49
|
+
css: o(a.css),
|
|
50
|
+
stripoConfig: o({
|
|
51
|
+
editor: "stripo",
|
|
52
|
+
html: a.rawHtml,
|
|
53
|
+
css: a.css,
|
|
54
|
+
dynamicContentList: a.dynamicContentList
|
|
55
|
+
}),
|
|
56
|
+
recommendationConfigs: o({}),
|
|
57
|
+
recommendationCampaignUrls: o(
|
|
58
|
+
N().recommendationCampaignUrls
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
return (await i.create(S, {
|
|
63
|
+
nameTaken: s("save-product-card.name-error"),
|
|
64
|
+
fallback: s("newsletter.template-library-save-alert", { templateName: n })
|
|
65
|
+
})).ok ? (d({
|
|
66
|
+
message: s("newsletter.template-library-save-success", { templateName: n }),
|
|
67
|
+
type: L.Success
|
|
68
|
+
}), !0) : !1;
|
|
69
|
+
} catch (t) {
|
|
70
|
+
return u(t, "Failed to create template"), !1;
|
|
99
71
|
}
|
|
100
72
|
}
|
|
101
73
|
};
|
|
102
74
|
};
|
|
103
75
|
export {
|
|
104
|
-
|
|
76
|
+
_ as useTemplateLibraryApi
|
|
105
77
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HtmlSyntaxValue } from '@@/Enums/email-be';
|
|
2
|
+
import * as v from 'valibot';
|
|
3
|
+
export declare const TemplateCategorySchema: v.ObjectSchema<{
|
|
4
|
+
readonly id: v.NumberSchema<undefined>;
|
|
5
|
+
readonly name: v.StringSchema<undefined>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export declare const TemplateCategoryListSchema: v.ArraySchema<v.UnknownSchema, undefined>;
|
|
8
|
+
export declare const TemplateNameCheckSchema: v.ObjectSchema<{
|
|
9
|
+
readonly exists: v.BooleanSchema<undefined>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
export declare const CreatedTemplateSchema: v.ObjectSchema<{
|
|
12
|
+
readonly id: v.NumberSchema<undefined>;
|
|
13
|
+
}, undefined>;
|
|
14
|
+
export type TemplateCategory = v.InferOutput<typeof TemplateCategorySchema>;
|
|
15
|
+
export type TemplateWireType = 'promotional' | 'transactional';
|
|
16
|
+
export type TemplateWireProduct = 'newsletter' | 'architect';
|
|
17
|
+
export interface TemplateCreateContent {
|
|
18
|
+
html: string;
|
|
19
|
+
css: string;
|
|
20
|
+
stripoConfig: string;
|
|
21
|
+
recommendationConfigs: string;
|
|
22
|
+
recommendationCampaignUrls: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TemplateCreateBody {
|
|
25
|
+
name: string;
|
|
26
|
+
type: TemplateWireType;
|
|
27
|
+
editor: 'guido';
|
|
28
|
+
product: TemplateWireProduct;
|
|
29
|
+
engine: HtmlSyntaxValue;
|
|
30
|
+
categoryIds: number[];
|
|
31
|
+
content: TemplateCreateContent;
|
|
32
|
+
}
|
|
33
|
+
export interface TemplateCreateMessages {
|
|
34
|
+
nameTaken: string;
|
|
35
|
+
fallback: string;
|
|
36
|
+
}
|
|
@@ -2,29 +2,7 @@ export interface MappedCategory {
|
|
|
2
2
|
value: string;
|
|
3
3
|
text: string;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
6
|
-
id: number;
|
|
7
|
-
name: string;
|
|
8
|
-
partnerId: number;
|
|
9
|
-
isStripo: boolean;
|
|
10
|
-
templatesCount: number;
|
|
11
|
-
}
|
|
5
|
+
export type { TemplateCategory as Category } from '@@/Types/email-be/templates';
|
|
12
6
|
export interface RecommendationCampaignUrls {
|
|
13
7
|
[key: string]: string;
|
|
14
8
|
}
|
|
15
|
-
export interface CreateTemplateRequest {
|
|
16
|
-
name: string;
|
|
17
|
-
categories: number[];
|
|
18
|
-
productId: number;
|
|
19
|
-
editorType: number;
|
|
20
|
-
messageType?: number;
|
|
21
|
-
content: string;
|
|
22
|
-
css?: string;
|
|
23
|
-
stripoConfig: string;
|
|
24
|
-
recommendationConfigs?: string;
|
|
25
|
-
recommendationCampaignUrls?: string;
|
|
26
|
-
unsubscriptionPreferencePages: number[];
|
|
27
|
-
unsubscriptionPreferencePageStatus: boolean;
|
|
28
|
-
isGuido: boolean;
|
|
29
|
-
template_engine: number;
|
|
30
|
-
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export declare const EMAIL_BE_BASE_URL = "/email-proxy";
|
|
2
2
|
export declare const EmailBeEndPoints: {
|
|
3
3
|
readonly HTML_VALIDATE: "/v1/html/validate";
|
|
4
|
+
readonly TEMPLATES: "/v1/templates";
|
|
5
|
+
readonly TEMPLATE_NAME_CHECK: "/v1/templates/name-check";
|
|
6
|
+
readonly TEMPLATE_CATEGORIES: "/v1/templates/categories";
|
|
4
7
|
};
|
|
5
8
|
export declare const EmailBeErrorCodes: {
|
|
6
9
|
readonly BAD_GATEWAY: "bad_gateway";
|
|
@@ -17,6 +20,10 @@ export declare const EmailBeErrorCodes: {
|
|
|
17
20
|
readonly NETWORK: "network_error";
|
|
18
21
|
readonly TIMEOUT: "timeout";
|
|
19
22
|
readonly UNKNOWN: "unknown";
|
|
23
|
+
readonly PRODUCT_TYPE_DISABLED: "product-type:errors.disabled";
|
|
24
|
+
readonly PRODUCT_TYPE_FETCH_FAILED: "product-type:errors.fetch-failed";
|
|
25
|
+
readonly TEMPLATE_NAME_CONFLICT: "template:errors.name-conflict";
|
|
26
|
+
readonly TEMPLATE_ALLOWLIST_UNAVAILABLE: "template:errors.allowlist-unavailable";
|
|
20
27
|
};
|
|
21
28
|
export type ApiErrorCode = typeof EmailBeErrorCodes[keyof typeof EmailBeErrorCodes];
|
|
22
29
|
export declare const HtmlSyntax: {
|
|
@@ -11,6 +11,8 @@ export declare function isDefaultProductAttr(productAttrValue: string): boolean;
|
|
|
11
11
|
export declare function bareAttributeName(productAttrValue: string): string;
|
|
12
12
|
export declare function compositionKeyToProductAttr(compositionKey: string): string;
|
|
13
13
|
export declare function productAttrToCompositionKey(productAttrValue: string): string;
|
|
14
|
+
export declare function isWellFormedProductAttr(productAttrValue: string): boolean;
|
|
15
|
+
export declare function dropMalformedCompositionKeys(composition: string[]): string[];
|
|
14
16
|
/**
|
|
15
17
|
* Canonical identity of a filter entry. Reads the type off the entry itself, so
|
|
16
18
|
* two same-named filters never collapse onto one value.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HttpManager } from '@@/Services/emailBe/http/HttpManager';
|
|
2
|
+
import type { Result } from '@@/Services/emailBe/http/types';
|
|
3
|
+
import type { TemplateCategory, TemplateCreateBody, TemplateCreateMessages } from '@@/Types/email-be/templates';
|
|
4
|
+
export declare class TemplateService {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpManager);
|
|
7
|
+
private errorOptions;
|
|
8
|
+
listCategories(fallback?: string): Promise<Result<TemplateCategory[]>>;
|
|
9
|
+
createCategory(name: string): Promise<Result<TemplateCategory>>;
|
|
10
|
+
isNameTaken(name: string): Promise<Result<boolean>>;
|
|
11
|
+
create(body: TemplateCreateBody, messages: TemplateCreateMessages): Promise<Result<number>>;
|
|
12
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { PreviewState, EmailFormat } from '@@/Types/preview';
|
|
2
|
+
export declare const HTML_PREVIEW_SANDBOX = "allow-same-origin allow-popups allow-popups-to-escape-sandbox";
|
|
3
|
+
export declare const AMP_PREVIEW_SANDBOX = "allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox";
|
|
2
4
|
export declare const usePreviewStore: import("pinia").StoreDefinition<"guidoPreview", PreviewState, {
|
|
3
5
|
isAMPModeEnabled: (state: {
|
|
4
6
|
emailFormat: EmailFormat;
|
|
@@ -10,6 +12,7 @@ export declare const usePreviewStore: import("pinia").StoreDefinition<"guidoPrev
|
|
|
10
12
|
emailSizeKB: number;
|
|
11
13
|
} & import("pinia").PiniaCustomStateProperties<PreviewState>) => boolean;
|
|
12
14
|
previewHtml(): string;
|
|
15
|
+
previewSandbox(): string;
|
|
13
16
|
hasAMP: (state: {
|
|
14
17
|
emailFormat: EmailFormat;
|
|
15
18
|
ampHtml: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips script-running markup from AMP preview HTML, which needs `allow-scripts` for the AMP runtime.
|
|
3
|
+
* Preview only: the DOM round-trip re-encodes attribute text, so never feed the result back into saved HTML.
|
|
4
|
+
*/
|
|
5
|
+
export declare const sanitizeAmpPreviewHtml: (html: string) => string;
|
|
@@ -3,3 +3,8 @@
|
|
|
3
3
|
* or text content. Use for any string that may contain untrusted input.
|
|
4
4
|
*/
|
|
5
5
|
export declare function escapeHtml(text: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Escape untrusted text but keep attribute-free line breaks and inline emphasis
|
|
8
|
+
* (`br`, `b`, `strong`, `i`, `em`, `u`) that translated copy carries.
|
|
9
|
+
*/
|
|
10
|
+
export declare function escapeHtmlKeepFormatting(text: string): string;
|
package/dist/stores/preview.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { sanitizeAmpPreviewHtml as s } from "../utils/ampPreviewSanitizer.js";
|
|
2
|
+
import { defineStore as r } from "pinia";
|
|
3
|
+
const o = "allow-same-origin allow-popups allow-popups-to-escape-sandbox", i = "allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox", a = () => ({
|
|
3
4
|
emailFormat: "html",
|
|
4
5
|
ampHtml: "",
|
|
5
6
|
ampErrors: [],
|
|
@@ -7,18 +8,21 @@ const i = () => ({
|
|
|
7
8
|
isLoaded: !1,
|
|
8
9
|
isAMPErrorModalVisible: !1,
|
|
9
10
|
emailSizeKB: 0
|
|
10
|
-
}),
|
|
11
|
-
state: () =>
|
|
11
|
+
}), p = r("guidoPreview", {
|
|
12
|
+
state: () => a(),
|
|
12
13
|
getters: {
|
|
13
|
-
isAMPModeEnabled: (
|
|
14
|
+
isAMPModeEnabled: (e) => e.emailFormat === "AMP",
|
|
14
15
|
previewHtml() {
|
|
15
|
-
return this.isAMPModeEnabled ? this.ampHtml : this.templateHtml;
|
|
16
|
+
return this.isAMPModeEnabled ? s(this.ampHtml) : this.templateHtml;
|
|
16
17
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return !!((r = t.ampHtml) != null && r.trim());
|
|
18
|
+
previewSandbox() {
|
|
19
|
+
return this.isAMPModeEnabled ? i : o;
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
hasAMP: (e) => {
|
|
22
|
+
var t;
|
|
23
|
+
return !!((t = e.ampHtml) != null && t.trim());
|
|
24
|
+
},
|
|
25
|
+
hasAMPErrors: (e) => e.ampErrors.length > 0,
|
|
22
26
|
showAMPErrorButton() {
|
|
23
27
|
return this.isAMPModeEnabled && this.hasAMPErrors;
|
|
24
28
|
},
|
|
@@ -27,11 +31,11 @@ const i = () => ({
|
|
|
27
31
|
}
|
|
28
32
|
},
|
|
29
33
|
actions: {
|
|
30
|
-
updateAMPData(
|
|
31
|
-
this.ampHtml =
|
|
34
|
+
updateAMPData(e) {
|
|
35
|
+
this.ampHtml = e.ampHtml ?? "", this.ampErrors = e.ampErrors ?? [], this.emailFormat = e.ampHtml ? "AMP" : "html";
|
|
32
36
|
},
|
|
33
|
-
setEmailFormat(
|
|
34
|
-
this.emailFormat =
|
|
37
|
+
setEmailFormat(e) {
|
|
38
|
+
this.emailFormat = e;
|
|
35
39
|
},
|
|
36
40
|
closeErrorModal() {
|
|
37
41
|
this.isAMPErrorModalVisible = !1;
|
|
@@ -42,5 +46,7 @@ const i = () => ({
|
|
|
42
46
|
}
|
|
43
47
|
});
|
|
44
48
|
export {
|
|
45
|
-
|
|
49
|
+
i as AMP_PREVIEW_SANDBOX,
|
|
50
|
+
o as HTML_PREVIEW_SANDBOX,
|
|
51
|
+
p as usePreviewStore
|
|
46
52
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BASE_SAFE_URL_SCHEMES as c } from "./urlSchemes.js";
|
|
2
|
+
const i = "https://cdn.ampproject.org/", a = "http://www.w3.org/1999/xhtml", l = ["application/json", "application/ld+json"], E = [...c, "tel:", "sms:"], u = ["href", "src", "action", "action-xhr", "formaction", "xlink:href", "poster", "background"], m = "iframe, frame, frameset, object, embed, base, noscript, amp-script, animate, set", p = /^on./i, f = "https://preview.invalid/", A = 4, S = (e) => {
|
|
3
|
+
const t = e.trim();
|
|
4
|
+
if (t === "")
|
|
5
|
+
return !0;
|
|
6
|
+
try {
|
|
7
|
+
const { protocol: r } = new URL(t, f);
|
|
8
|
+
return E.includes(r) || /^data:image\//i.test(t);
|
|
9
|
+
} catch {
|
|
10
|
+
return !1;
|
|
11
|
+
}
|
|
12
|
+
}, h = (e) => {
|
|
13
|
+
if (e.namespaceURI !== a)
|
|
14
|
+
return !1;
|
|
15
|
+
const t = e.getAttribute("src");
|
|
16
|
+
return t !== null ? t.trim().startsWith(i) : l.includes((e.getAttribute("type") ?? "").trim().toLowerCase());
|
|
17
|
+
}, _ = (e) => {
|
|
18
|
+
Array.from(e.attributes).forEach(({ name: t, value: r }) => {
|
|
19
|
+
const o = u.includes(t.toLowerCase()) && !S(r);
|
|
20
|
+
(p.test(t) || o) && e.removeAttribute(t);
|
|
21
|
+
});
|
|
22
|
+
}, s = (e) => {
|
|
23
|
+
e.querySelectorAll(m).forEach((t) => t.remove()), e.querySelectorAll("meta[http-equiv]").forEach((t) => {
|
|
24
|
+
var r;
|
|
25
|
+
((r = t.getAttribute("http-equiv")) == null ? void 0 : r.trim().toLowerCase()) === "refresh" && t.remove();
|
|
26
|
+
}), e.querySelectorAll("script").forEach((t) => {
|
|
27
|
+
h(t) || t.remove();
|
|
28
|
+
}), e.querySelectorAll("*").forEach(_), e.querySelectorAll("template").forEach((t) => s(t.content));
|
|
29
|
+
}, n = (e) => {
|
|
30
|
+
const t = new DOMParser().parseFromString(e, "text/html");
|
|
31
|
+
return s(t), `${t.doctype ? `<!DOCTYPE ${t.doctype.name}>` : ""}${t.documentElement.outerHTML}`;
|
|
32
|
+
}, T = (e) => {
|
|
33
|
+
if (e.trim() === "")
|
|
34
|
+
return "";
|
|
35
|
+
let t = n(e);
|
|
36
|
+
for (let r = 1; r < A; r++) {
|
|
37
|
+
const o = n(t);
|
|
38
|
+
if (o === t)
|
|
39
|
+
return t;
|
|
40
|
+
t = o;
|
|
41
|
+
}
|
|
42
|
+
return "";
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
T as sanitizeAmpPreviewHtml
|
|
46
|
+
};
|
package/dist/utils/htmlEscape.js
CHANGED
|
@@ -8,6 +8,10 @@ const c = {
|
|
|
8
8
|
function n(t) {
|
|
9
9
|
return t.replace(/[&<>"']/g, (e) => c[e]);
|
|
10
10
|
}
|
|
11
|
+
function o(t) {
|
|
12
|
+
return n(t).replace(/<\/?br\s*\/?>/gi, "<br>").replace(/<(\/?)(b|strong|i|em|u)>/gi, (e, r, a) => `<${r}${a.toLowerCase()}>`);
|
|
13
|
+
}
|
|
11
14
|
export {
|
|
12
|
-
n as escapeHtml
|
|
15
|
+
n as escapeHtml,
|
|
16
|
+
o as escapeHtmlKeepFormatting
|
|
13
17
|
};
|