@useinsider/guido 3.30.1-beta.28434b4 → 3.30.1-beta.34bc10d
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/html-validation.js +1 -1
- package/dist/@types/email-be/templates.js +15 -0
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue.js +2 -2
- package/dist/enums/defaults.js +4 -5
- package/dist/enums/email-be.js +20 -9
- package/dist/node_modules/valibot/dist/index.js +95 -90
- package/dist/package.json.js +1 -1
- package/dist/services/emailBe/errors/ApiError.js +27 -26
- package/dist/services/emailBe/templates/TemplateService.js +149 -0
- package/dist/services/emailBe/templates/index.js +6 -0
- package/dist/services/templateLibraryApi.js +59 -87
- package/dist/src/@types/email-be/templates.d.ts +40 -0
- package/dist/src/@types/save-as-template.d.ts +1 -23
- package/dist/src/enums/email-be.d.ts +11 -0
- package/dist/src/services/emailBe/templates/TemplateService.d.ts +13 -0
- package/dist/src/services/emailBe/templates/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModuleFolderDefaults as y } from "../../enums/defaults.js";
|
|
2
|
-
import { object as o, number as c, optional as e, string as t, picklist as m, pipe as r, minLength as p, custom as k, boolean as a, array as n, transform as S, unknown as i,
|
|
2
|
+
import { object as o, number as c, optional as e, string as t, picklist as m, pipe as r, minLength as p, custom as k, boolean as a, array as n, transform as S, unknown as i, variant as R, record as g, fallback as T, looseObject as C, union as h, literal as u, lazy as I } from "../../node_modules/valibot/dist/index.js";
|
|
3
3
|
const b = {
|
|
4
4
|
/** Promotional/marketing emails */
|
|
5
5
|
PROMOTIONAL: 1,
|
|
@@ -76,7 +76,7 @@ const b = {
|
|
|
76
76
|
value: t()
|
|
77
77
|
})
|
|
78
78
|
)
|
|
79
|
-
}), f =
|
|
79
|
+
}), f = I(() => C({
|
|
80
80
|
text: e(t()),
|
|
81
81
|
// eslint-disable-next-line camelcase -- backend field name
|
|
82
82
|
tag_text: e(t()),
|
|
@@ -86,7 +86,7 @@ const b = {
|
|
|
86
86
|
select_items: e(n(f))
|
|
87
87
|
})), P = g(
|
|
88
88
|
t(),
|
|
89
|
-
|
|
89
|
+
T(n(f), [])
|
|
90
90
|
), v = C({
|
|
91
91
|
/** Block ID (matches the dictionary key and the legacy HTML element id) */
|
|
92
92
|
id: e(c()),
|
|
@@ -324,7 +324,7 @@ const b = {
|
|
|
324
324
|
(s) => typeof s == "function",
|
|
325
325
|
"processor must be a function"
|
|
326
326
|
)
|
|
327
|
-
}), V =
|
|
327
|
+
}), V = R("type", [
|
|
328
328
|
H,
|
|
329
329
|
_,
|
|
330
330
|
q,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pipe as o, check as i, object as r, array as l, boolean as s, string as e, fallback as m,
|
|
1
|
+
import { pipe as o, check as i, object as r, array as l, boolean as s, string as e, fallback as m, nullable as d, union as t, number as a, record as h, transform as u, tuple as p } from "../../node_modules/valibot/dist/index.js";
|
|
2
2
|
const b = r({
|
|
3
3
|
code: e(),
|
|
4
4
|
trans: r({
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { array as c, object as e, string as a, number as t, boolean as o, optional as m, record as i, unknown as n } from "../../node_modules/valibot/dist/index.js";
|
|
2
|
+
const r = e({
|
|
3
|
+
id: t(),
|
|
4
|
+
name: a()
|
|
5
|
+
}), s = c(n()), p = e({ exists: o() }), h = e({ id: t() }), d = e({
|
|
6
|
+
clean: o(),
|
|
7
|
+
violations: m(i(a(), n()))
|
|
8
|
+
});
|
|
9
|
+
export {
|
|
10
|
+
d as AllowlistValidationSchema,
|
|
11
|
+
h as CreatedTemplateSchema,
|
|
12
|
+
s as TemplateCategoryListSchema,
|
|
13
|
+
r as TemplateCategorySchema,
|
|
14
|
+
p as TemplateNameCheckSchema
|
|
15
|
+
};
|
|
@@ -4,8 +4,8 @@ var r = function() {
|
|
|
4
4
|
var a = this, e = a._self._c, t = a._self._setupProxy;
|
|
5
5
|
return e(t.WpDrawer, { attrs: { id: "save-as-template-modal", "description-status": "", "description-text": t.trans("newsletter.save-template-description"), "footer-button-group-options": t.footerButtonGroupOptions, status: t.editorStore.isSaveAsTemplateDrawerOpen, "title-text": t.trans("products.save-template") }, on: { cancelOrBackButtonEvent: t.closeModal, onCloseEvent: t.closeModal, primaryButtonEvent: t.saveTemplate } }, [e(t.InBasicTextInput, { staticClass: "mb-5 w-1", attrs: { id: "guido__template-name-input", name: "templateName", "character-counter-status": !1, "disabled-status": t.isSaving, "label-text": t.trans("products.template-name"), "max-character-length": 1e3, "placeholder-text": t.trans("newsletter.enter-template-name"), "skeleton-sizing": { width: 495, height: 44 }, "skeleton-status": t.saveAsTemplateStore.skeletonStatus, "state-message": t.templateNameError, states: t.templateNameError ? "error" : "default", "tooltip-status": !1, value: t.saveAsTemplateStore.templateName }, on: { input: t.handleTemplateName } }), e(t.InMultiSelect, { staticClass: "template-category-dropdown mb-5 w-1", attrs: { id: "guido__template-category-dropdown", "create-option-status": "", "search-status": "", "button-status": !1, "character-limit-validation-text": t.trans("validation-v2.duration-value", {
|
|
6
6
|
min: 1,
|
|
7
|
-
max:
|
|
8
|
-
}), "create-button-label": t.trans("products.create-new-category"), "disabled-status": t.isSaving, "label-text": t.trans("products.template-category"), "loading-state": t.isAddingOption, "max-character-limit":
|
|
7
|
+
max: 40
|
|
8
|
+
}), "create-button-label": t.trans("products.create-new-category"), "disabled-status": t.isSaving, "label-text": t.trans("products.template-category"), "loading-state": t.isAddingOption, "max-character-limit": 40, "max-height": 350, options: t.saveAsTemplateStore.categories, "placeholder-text": t.trans("products.select-template-category"), "skeleton-sizing": { width: 495, height: 44 }, "skeleton-status": t.saveAsTemplateStore.skeletonStatus, value: t.saveAsTemplateStore.selectedCategories }, on: { addOption: t.handleAddOption, change: t.handleCategoryChange, resetAllOptions: t.handleResetAllOptions, selectAllOptions: t.handleSelectAllOptions } })], 1);
|
|
9
9
|
}, l = [], n = /* @__PURE__ */ o(
|
|
10
10
|
s,
|
|
11
11
|
r,
|
package/dist/enums/defaults.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
const e = {
|
|
2
2
|
transactional: 2
|
|
3
|
-
}, s =
|
|
3
|
+
}, s = 13, t = "https://email-static.useinsider.com", a = `${t}/templates/campaign/default.html`, l = `${t}/templates/campaign/default.css`, L = {
|
|
4
4
|
SAVED_MODULES: "savedModules",
|
|
5
5
|
DEFAULT_MODULES: "defaultModules"
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
8
|
l as BLANK_TEMPLATE_CSS_URL,
|
|
9
|
-
|
|
9
|
+
a as BLANK_TEMPLATE_HTML_URL,
|
|
10
10
|
t as EMAIL_STATIC_BASE_URL,
|
|
11
|
-
s as
|
|
12
|
-
|
|
13
|
-
E as ModuleFolderDefaults,
|
|
11
|
+
s as MAX_DEFAULT_TEMPLATE_ID,
|
|
12
|
+
L as ModuleFolderDefaults,
|
|
14
13
|
e as TemplateTypes
|
|
15
14
|
};
|
package/dist/enums/email-be.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
HTML_VALIDATE: "/v1/html/validate"
|
|
3
|
-
|
|
1
|
+
const e = "/email-proxy", E = {
|
|
2
|
+
HTML_VALIDATE: "/v1/html/validate",
|
|
3
|
+
TEMPLATES: "/v1/templates",
|
|
4
|
+
TEMPLATE_NAME_CHECK: "/v1/templates/name-check",
|
|
5
|
+
TEMPLATE_CATEGORIES: "/v1/templates/categories",
|
|
6
|
+
ALLOWLIST_VALIDATE: "/v1/allowlist/validate"
|
|
7
|
+
}, t = "emailTemplateLibrary", T = {
|
|
4
8
|
BAD_GATEWAY: "bad_gateway",
|
|
5
9
|
BAD_REQUEST: "bad_request",
|
|
6
10
|
CONFLICT: "conflict",
|
|
@@ -14,14 +18,21 @@ const E = "/email-proxy", e = {
|
|
|
14
18
|
INVALID_RESPONSE: "invalid_response",
|
|
15
19
|
NETWORK: "network_error",
|
|
16
20
|
TIMEOUT: "timeout",
|
|
17
|
-
UNKNOWN: "unknown"
|
|
18
|
-
|
|
21
|
+
UNKNOWN: "unknown",
|
|
22
|
+
PRODUCT_TYPE_DISABLED: "product-type:errors.disabled",
|
|
23
|
+
PRODUCT_TYPE_FETCH_FAILED: "product-type:errors.fetch-failed",
|
|
24
|
+
TEMPLATE_NAME_CONFLICT: "template:errors.name-conflict",
|
|
25
|
+
TEMPLATE_CATEGORY_NAME_CONFLICT: "template:errors.category-name-conflict",
|
|
26
|
+
TEMPLATE_CONTENT_REJECTED: "template:errors.content-rejected",
|
|
27
|
+
TEMPLATE_ALLOWLIST_UNAVAILABLE: "template:errors.allowlist-unavailable"
|
|
28
|
+
}, r = {
|
|
19
29
|
PONGO: "pongo",
|
|
20
30
|
LIQUID: "liquid"
|
|
21
31
|
};
|
|
22
32
|
export {
|
|
23
|
-
|
|
24
|
-
e as
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
t as ALLOWLIST_TEMPLATE_TYPE,
|
|
34
|
+
e as EMAIL_BE_BASE_URL,
|
|
35
|
+
E as EmailBeEndPoints,
|
|
36
|
+
T as EmailBeErrorCodes,
|
|
37
|
+
r as HtmlSyntax
|
|
27
38
|
};
|
|
@@ -30,21 +30,21 @@ function D(n) {
|
|
|
30
30
|
const r = typeof n;
|
|
31
31
|
return r === "string" ? `"${n}"` : r === "number" || r === "bigint" || r === "boolean" ? `${n}` : r === "object" || r === "function" ? (n && ((s = (e = Object.getPrototypeOf(n)) == null ? void 0 : e.constructor) == null ? void 0 : s.name)) ?? "null" : r;
|
|
32
32
|
}
|
|
33
|
-
function f(n, r, e, s,
|
|
34
|
-
const l =
|
|
33
|
+
function f(n, r, e, s, u) {
|
|
34
|
+
const l = u && "input" in u ? u.input : e.value, t = (u == null ? void 0 : u.expected) ?? n.expects ?? null, p = (u == null ? void 0 : u.received) ?? /* @__PURE__ */ D(l), i = {
|
|
35
35
|
kind: n.kind,
|
|
36
36
|
type: n.type,
|
|
37
37
|
input: l,
|
|
38
|
-
expected:
|
|
38
|
+
expected: t,
|
|
39
39
|
received: p,
|
|
40
|
-
message: `Invalid ${r}: ${
|
|
40
|
+
message: `Invalid ${r}: ${t ? `Expected ${t} but r` : "R"}eceived ${p}`,
|
|
41
41
|
requirement: n.requirement,
|
|
42
|
-
path:
|
|
43
|
-
issues:
|
|
42
|
+
path: u == null ? void 0 : u.path,
|
|
43
|
+
issues: u == null ? void 0 : u.issues,
|
|
44
44
|
lang: s.lang,
|
|
45
45
|
abortEarly: s.abortEarly,
|
|
46
46
|
abortPipeEarly: s.abortPipeEarly
|
|
47
|
-
}, c = n.kind === "schema", a = (
|
|
47
|
+
}, c = n.kind === "schema", a = (u == null ? void 0 : u.message) ?? n.message ?? /* @__PURE__ */ q(n.reference, i.lang) ?? (c ? /* @__PURE__ */ V(i.lang) : null) ?? s.message ?? /* @__PURE__ */ I(i.lang);
|
|
48
48
|
a !== void 0 && (i.message = typeof a == "function" ? a(i) : a), c && (e.typed = !1), e.issues ? e.issues.push(i) : e.issues = [i];
|
|
49
49
|
}
|
|
50
50
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -188,11 +188,11 @@ function ie(n, r) {
|
|
|
188
188
|
return /* @__PURE__ */ o(this);
|
|
189
189
|
},
|
|
190
190
|
"~run"(e, s) {
|
|
191
|
-
const
|
|
192
|
-
return
|
|
191
|
+
const u = n["~run"](e, s);
|
|
192
|
+
return u.issues ? {
|
|
193
193
|
typed: !0,
|
|
194
|
-
value: /* @__PURE__ */ P(this,
|
|
195
|
-
} :
|
|
194
|
+
value: /* @__PURE__ */ P(this, u, s)
|
|
195
|
+
} : u;
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
}
|
|
@@ -201,6 +201,10 @@ function k(n, r, e) {
|
|
|
201
201
|
return typeof n.default == "function" ? n.default(r, e) : n.default;
|
|
202
202
|
}
|
|
203
203
|
// @__NO_SIDE_EFFECTS__
|
|
204
|
+
function le(n, r) {
|
|
205
|
+
return !n["~run"]({ value: r }, { abortEarly: !0 }).issues;
|
|
206
|
+
}
|
|
207
|
+
// @__NO_SIDE_EFFECTS__
|
|
204
208
|
function R(n, r) {
|
|
205
209
|
return {
|
|
206
210
|
kind: "schema",
|
|
@@ -215,17 +219,17 @@ function R(n, r) {
|
|
|
215
219
|
},
|
|
216
220
|
"~run"(e, s) {
|
|
217
221
|
var l;
|
|
218
|
-
const
|
|
219
|
-
if (Array.isArray(
|
|
222
|
+
const u = e.value;
|
|
223
|
+
if (Array.isArray(u)) {
|
|
220
224
|
e.typed = !0, e.value = [];
|
|
221
|
-
for (let
|
|
222
|
-
const p = t
|
|
225
|
+
for (let t = 0; t < u.length; t++) {
|
|
226
|
+
const p = u[t], i = this.item["~run"]({ value: p }, s);
|
|
223
227
|
if (i.issues) {
|
|
224
228
|
const c = {
|
|
225
229
|
type: "array",
|
|
226
230
|
origin: "value",
|
|
227
|
-
input:
|
|
228
|
-
key:
|
|
231
|
+
input: u,
|
|
232
|
+
key: t,
|
|
229
233
|
value: p
|
|
230
234
|
};
|
|
231
235
|
for (const a of i.issues)
|
|
@@ -327,19 +331,19 @@ function T(n, r) {
|
|
|
327
331
|
},
|
|
328
332
|
"~run"(e, s) {
|
|
329
333
|
var l;
|
|
330
|
-
const
|
|
331
|
-
if (
|
|
334
|
+
const u = e.value;
|
|
335
|
+
if (u && typeof u == "object") {
|
|
332
336
|
e.typed = !0, e.value = {};
|
|
333
|
-
for (const
|
|
334
|
-
const p = this.entries[
|
|
335
|
-
if (
|
|
336
|
-
const i =
|
|
337
|
+
for (const t in this.entries) {
|
|
338
|
+
const p = this.entries[t];
|
|
339
|
+
if (t in u || (p.type === "exact_optional" || p.type === "optional" || p.type === "nullish") && p.default !== void 0) {
|
|
340
|
+
const i = t in u ? u[t] : /* @__PURE__ */ k(p), c = p["~run"]({ value: i }, s);
|
|
337
341
|
if (c.issues) {
|
|
338
342
|
const a = {
|
|
339
343
|
type: "object",
|
|
340
344
|
origin: "value",
|
|
341
|
-
input:
|
|
342
|
-
key:
|
|
345
|
+
input: u,
|
|
346
|
+
key: t,
|
|
343
347
|
value: i
|
|
344
348
|
};
|
|
345
349
|
for (const y of c.issues)
|
|
@@ -349,23 +353,23 @@ function T(n, r) {
|
|
|
349
353
|
break;
|
|
350
354
|
}
|
|
351
355
|
}
|
|
352
|
-
c.typed || (e.typed = !1), e.value[
|
|
353
|
-
} else if (p.fallback !== void 0) e.value[
|
|
356
|
+
c.typed || (e.typed = !1), e.value[t] = c.value;
|
|
357
|
+
} else if (p.fallback !== void 0) e.value[t] = /* @__PURE__ */ P(p);
|
|
354
358
|
else if (p.type !== "exact_optional" && p.type !== "optional" && p.type !== "nullish" && (f(this, "key", e, s, {
|
|
355
359
|
input: void 0,
|
|
356
|
-
expected: `"${
|
|
360
|
+
expected: `"${t}"`,
|
|
357
361
|
path: [{
|
|
358
362
|
type: "object",
|
|
359
363
|
origin: "key",
|
|
360
|
-
input:
|
|
361
|
-
key:
|
|
362
|
-
value: t
|
|
364
|
+
input: u,
|
|
365
|
+
key: t,
|
|
366
|
+
value: u[t]
|
|
363
367
|
}]
|
|
364
368
|
}), s.abortEarly))
|
|
365
369
|
break;
|
|
366
370
|
}
|
|
367
371
|
if (!e.issues || !s.abortEarly)
|
|
368
|
-
for (const
|
|
372
|
+
for (const t in u) /* @__PURE__ */ S(u, t) && !(t in this.entries) && (e.value[t] = u[t]);
|
|
369
373
|
} else f(this, "type", e, s);
|
|
370
374
|
return e;
|
|
371
375
|
}
|
|
@@ -439,19 +443,19 @@ function Y(n, r) {
|
|
|
439
443
|
},
|
|
440
444
|
"~run"(e, s) {
|
|
441
445
|
var l;
|
|
442
|
-
const
|
|
443
|
-
if (
|
|
446
|
+
const u = e.value;
|
|
447
|
+
if (u && typeof u == "object") {
|
|
444
448
|
e.typed = !0, e.value = {};
|
|
445
|
-
for (const
|
|
446
|
-
const p = this.entries[
|
|
447
|
-
if (
|
|
448
|
-
const i =
|
|
449
|
+
for (const t in this.entries) {
|
|
450
|
+
const p = this.entries[t];
|
|
451
|
+
if (t in u || (p.type === "exact_optional" || p.type === "optional" || p.type === "nullish") && p.default !== void 0) {
|
|
452
|
+
const i = t in u ? u[t] : /* @__PURE__ */ k(p), c = p["~run"]({ value: i }, s);
|
|
449
453
|
if (c.issues) {
|
|
450
454
|
const a = {
|
|
451
455
|
type: "object",
|
|
452
456
|
origin: "value",
|
|
453
|
-
input:
|
|
454
|
-
key:
|
|
457
|
+
input: u,
|
|
458
|
+
key: t,
|
|
455
459
|
value: i
|
|
456
460
|
};
|
|
457
461
|
for (const y of c.issues)
|
|
@@ -461,17 +465,17 @@ function Y(n, r) {
|
|
|
461
465
|
break;
|
|
462
466
|
}
|
|
463
467
|
}
|
|
464
|
-
c.typed || (e.typed = !1), e.value[
|
|
465
|
-
} else if (p.fallback !== void 0) e.value[
|
|
468
|
+
c.typed || (e.typed = !1), e.value[t] = c.value;
|
|
469
|
+
} else if (p.fallback !== void 0) e.value[t] = /* @__PURE__ */ P(p);
|
|
466
470
|
else if (p.type !== "exact_optional" && p.type !== "optional" && p.type !== "nullish" && (f(this, "key", e, s, {
|
|
467
471
|
input: void 0,
|
|
468
|
-
expected: `"${
|
|
472
|
+
expected: `"${t}"`,
|
|
469
473
|
path: [{
|
|
470
474
|
type: "object",
|
|
471
475
|
origin: "key",
|
|
472
|
-
input:
|
|
473
|
-
key:
|
|
474
|
-
value: t
|
|
476
|
+
input: u,
|
|
477
|
+
key: t,
|
|
478
|
+
value: u[t]
|
|
475
479
|
}]
|
|
476
480
|
}), s.abortEarly))
|
|
477
481
|
break;
|
|
@@ -531,13 +535,13 @@ function ee(n, r, e) {
|
|
|
531
535
|
get "~standard"() {
|
|
532
536
|
return /* @__PURE__ */ o(this);
|
|
533
537
|
},
|
|
534
|
-
"~run"(s,
|
|
535
|
-
var
|
|
538
|
+
"~run"(s, u) {
|
|
539
|
+
var t, p;
|
|
536
540
|
const l = s.value;
|
|
537
541
|
if (l && typeof l == "object") {
|
|
538
542
|
s.typed = !0, s.value = {};
|
|
539
543
|
for (const i in l) if (/* @__PURE__ */ S(l, i)) {
|
|
540
|
-
const c = l[i], a = this.key["~run"]({ value: i },
|
|
544
|
+
const c = l[i], a = this.key["~run"]({ value: i }, u);
|
|
541
545
|
if (a.issues) {
|
|
542
546
|
const b = {
|
|
543
547
|
type: "object",
|
|
@@ -547,13 +551,13 @@ function ee(n, r, e) {
|
|
|
547
551
|
value: c
|
|
548
552
|
};
|
|
549
553
|
for (const h of a.issues)
|
|
550
|
-
h.path = [b], (
|
|
551
|
-
if (s.issues || (s.issues = a.issues),
|
|
554
|
+
h.path = [b], (t = s.issues) == null || t.push(h);
|
|
555
|
+
if (s.issues || (s.issues = a.issues), u.abortEarly) {
|
|
552
556
|
s.typed = !1;
|
|
553
557
|
break;
|
|
554
558
|
}
|
|
555
559
|
}
|
|
556
|
-
const y = this.value["~run"]({ value: c },
|
|
560
|
+
const y = this.value["~run"]({ value: c }, u);
|
|
557
561
|
if (y.issues) {
|
|
558
562
|
const b = {
|
|
559
563
|
type: "object",
|
|
@@ -564,14 +568,14 @@ function ee(n, r, e) {
|
|
|
564
568
|
};
|
|
565
569
|
for (const h of y.issues)
|
|
566
570
|
h.path ? h.path.unshift(b) : h.path = [b], (p = s.issues) == null || p.push(h);
|
|
567
|
-
if (s.issues || (s.issues = y.issues),
|
|
571
|
+
if (s.issues || (s.issues = y.issues), u.abortEarly) {
|
|
568
572
|
s.typed = !1;
|
|
569
573
|
break;
|
|
570
574
|
}
|
|
571
575
|
}
|
|
572
576
|
(!a.typed || !y.typed) && (s.typed = !1), a.typed && (s.value[a.value] = y.value);
|
|
573
577
|
}
|
|
574
|
-
} else f(this, "type", s,
|
|
578
|
+
} else f(this, "type", s, u);
|
|
575
579
|
return s;
|
|
576
580
|
}
|
|
577
581
|
};
|
|
@@ -608,17 +612,17 @@ function re(n, r) {
|
|
|
608
612
|
},
|
|
609
613
|
"~run"(e, s) {
|
|
610
614
|
var l;
|
|
611
|
-
const
|
|
612
|
-
if (Array.isArray(
|
|
615
|
+
const u = e.value;
|
|
616
|
+
if (Array.isArray(u)) {
|
|
613
617
|
e.typed = !0, e.value = [];
|
|
614
|
-
for (let
|
|
615
|
-
const p = t
|
|
618
|
+
for (let t = 0; t < this.items.length; t++) {
|
|
619
|
+
const p = u[t], i = this.items[t]["~run"]({ value: p }, s);
|
|
616
620
|
if (i.issues) {
|
|
617
621
|
const c = {
|
|
618
622
|
type: "array",
|
|
619
623
|
origin: "value",
|
|
620
|
-
input:
|
|
621
|
-
key:
|
|
624
|
+
input: u,
|
|
625
|
+
key: t,
|
|
622
626
|
value: p
|
|
623
627
|
};
|
|
624
628
|
for (const a of i.issues)
|
|
@@ -655,34 +659,34 @@ function se(n, r) {
|
|
|
655
659
|
return /* @__PURE__ */ o(this);
|
|
656
660
|
},
|
|
657
661
|
"~run"(e, s) {
|
|
658
|
-
let
|
|
662
|
+
let u, l, t;
|
|
659
663
|
for (const p of this.options) {
|
|
660
664
|
const i = p["~run"]({ value: e.value }, s);
|
|
661
665
|
if (i.typed) if (i.issues) l ? l.push(i) : l = [i];
|
|
662
666
|
else {
|
|
663
|
-
|
|
667
|
+
u = i;
|
|
664
668
|
break;
|
|
665
669
|
}
|
|
666
|
-
else
|
|
670
|
+
else t ? t.push(i) : t = [i];
|
|
667
671
|
}
|
|
668
|
-
if (
|
|
672
|
+
if (u) return u;
|
|
669
673
|
if (l) {
|
|
670
674
|
if (l.length === 1) return l[0];
|
|
671
675
|
f(this, "type", e, s, { issues: /* @__PURE__ */ A(l) }), e.typed = !0;
|
|
672
676
|
} else {
|
|
673
|
-
if ((
|
|
674
|
-
f(this, "type", e, s, { issues: /* @__PURE__ */ A(
|
|
677
|
+
if ((t == null ? void 0 : t.length) === 1) return t[0];
|
|
678
|
+
f(this, "type", e, s, { issues: /* @__PURE__ */ A(t) });
|
|
675
679
|
}
|
|
676
680
|
return e;
|
|
677
681
|
}
|
|
678
682
|
};
|
|
679
683
|
}
|
|
680
684
|
// @__NO_SIDE_EFFECTS__
|
|
681
|
-
function
|
|
685
|
+
function ue() {
|
|
682
686
|
return {
|
|
683
687
|
kind: "schema",
|
|
684
688
|
type: "unknown",
|
|
685
|
-
reference:
|
|
689
|
+
reference: ue,
|
|
686
690
|
expects: "unknown",
|
|
687
691
|
async: !1,
|
|
688
692
|
get "~standard"() {
|
|
@@ -694,11 +698,11 @@ function te() {
|
|
|
694
698
|
};
|
|
695
699
|
}
|
|
696
700
|
// @__NO_SIDE_EFFECTS__
|
|
697
|
-
function
|
|
701
|
+
function te(n, r, e) {
|
|
698
702
|
return {
|
|
699
703
|
kind: "schema",
|
|
700
704
|
type: "variant",
|
|
701
|
-
reference:
|
|
705
|
+
reference: te,
|
|
702
706
|
expects: "Object",
|
|
703
707
|
async: !1,
|
|
704
708
|
key: n,
|
|
@@ -707,10 +711,10 @@ function ue(n, r, e) {
|
|
|
707
711
|
get "~standard"() {
|
|
708
712
|
return /* @__PURE__ */ o(this);
|
|
709
713
|
},
|
|
710
|
-
"~run"(s,
|
|
714
|
+
"~run"(s, u) {
|
|
711
715
|
const l = s.value;
|
|
712
716
|
if (l && typeof l == "object") {
|
|
713
|
-
let
|
|
717
|
+
let t, p = 0, i = this.key, c = [];
|
|
714
718
|
const a = (y, b) => {
|
|
715
719
|
for (const h of y.options) {
|
|
716
720
|
if (h.type === "variant") a(h, new Set(b).add(h.key));
|
|
@@ -728,15 +732,15 @@ function ue(n, r, e) {
|
|
|
728
732
|
g++;
|
|
729
733
|
}
|
|
730
734
|
if (O) {
|
|
731
|
-
const v = h["~run"]({ value: l },
|
|
732
|
-
(!
|
|
735
|
+
const v = h["~run"]({ value: l }, u);
|
|
736
|
+
(!t || !t.typed && v.typed) && (t = v);
|
|
733
737
|
}
|
|
734
738
|
}
|
|
735
|
-
if (
|
|
739
|
+
if (t && !t.issues) break;
|
|
736
740
|
}
|
|
737
741
|
};
|
|
738
|
-
if (a(this, /* @__PURE__ */ new Set([this.key])),
|
|
739
|
-
f(this, "type", s,
|
|
742
|
+
if (a(this, /* @__PURE__ */ new Set([this.key])), t) return t;
|
|
743
|
+
f(this, "type", s, u, {
|
|
740
744
|
input: l[i],
|
|
741
745
|
expected: /* @__PURE__ */ w(c, "|"),
|
|
742
746
|
path: [{
|
|
@@ -747,18 +751,18 @@ function ue(n, r, e) {
|
|
|
747
751
|
value: l[i]
|
|
748
752
|
}]
|
|
749
753
|
});
|
|
750
|
-
} else f(this, "type", s,
|
|
754
|
+
} else f(this, "type", s, u);
|
|
751
755
|
return s;
|
|
752
756
|
}
|
|
753
757
|
};
|
|
754
758
|
}
|
|
755
|
-
function
|
|
759
|
+
function pe(n, r, e) {
|
|
756
760
|
const s = n["~run"]({ value: r }, /* @__PURE__ */ x(e));
|
|
757
761
|
if (s.issues) throw new K(s.issues);
|
|
758
762
|
return s.value;
|
|
759
763
|
}
|
|
760
764
|
// @__NO_SIDE_EFFECTS__
|
|
761
|
-
function
|
|
765
|
+
function ae(...n) {
|
|
762
766
|
return {
|
|
763
767
|
...n[0],
|
|
764
768
|
pipe: n,
|
|
@@ -778,7 +782,7 @@ function pe(...n) {
|
|
|
778
782
|
};
|
|
779
783
|
}
|
|
780
784
|
// @__NO_SIDE_EFFECTS__
|
|
781
|
-
function
|
|
785
|
+
function ce(...n) {
|
|
782
786
|
return {
|
|
783
787
|
...n[0],
|
|
784
788
|
pipe: n,
|
|
@@ -799,7 +803,7 @@ function ae(...n) {
|
|
|
799
803
|
};
|
|
800
804
|
}
|
|
801
805
|
// @__NO_SIDE_EFFECTS__
|
|
802
|
-
function
|
|
806
|
+
function fe(n, r, e) {
|
|
803
807
|
const s = n["~run"]({ value: r }, /* @__PURE__ */ x(e));
|
|
804
808
|
return {
|
|
805
809
|
typed: s.typed,
|
|
@@ -809,7 +813,7 @@ function ce(n, r, e) {
|
|
|
809
813
|
};
|
|
810
814
|
}
|
|
811
815
|
// @__NO_SIDE_EFFECTS__
|
|
812
|
-
async function
|
|
816
|
+
async function oe(n, r, e) {
|
|
813
817
|
const s = await n["~run"]({ value: r }, /* @__PURE__ */ x(e));
|
|
814
818
|
return {
|
|
815
819
|
typed: s.typed,
|
|
@@ -837,6 +841,7 @@ export {
|
|
|
837
841
|
I as getGlobalMessage,
|
|
838
842
|
V as getSchemaMessage,
|
|
839
843
|
q as getSpecificMessage,
|
|
844
|
+
le as is,
|
|
840
845
|
J as lazy,
|
|
841
846
|
Q as literal,
|
|
842
847
|
T as looseObject,
|
|
@@ -848,18 +853,18 @@ export {
|
|
|
848
853
|
X as number,
|
|
849
854
|
Y as object,
|
|
850
855
|
Z as optional,
|
|
851
|
-
|
|
856
|
+
pe as parse,
|
|
852
857
|
$ as picklist,
|
|
853
|
-
|
|
854
|
-
|
|
858
|
+
ae as pipe,
|
|
859
|
+
ce as pipeAsync,
|
|
855
860
|
ee as record,
|
|
856
|
-
|
|
857
|
-
|
|
861
|
+
fe as safeParse,
|
|
862
|
+
oe as safeParseAsync,
|
|
858
863
|
ne as string,
|
|
859
864
|
C as transform,
|
|
860
865
|
F as trim,
|
|
861
866
|
re as tuple,
|
|
862
867
|
se as union,
|
|
863
|
-
|
|
864
|
-
|
|
868
|
+
ue as unknown,
|
|
869
|
+
te as variant
|
|
865
870
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -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,149 @@
|
|
|
1
|
+
import { useToaster as p } from "../../../composables/useToaster.js";
|
|
2
|
+
import { useTranslations as m } from "../../../composables/useTranslations.js";
|
|
3
|
+
import { EmailBeErrorCodes as o, EmailBeEndPoints as i, ALLOWLIST_TEMPLATE_TYPE as A } from "../../../enums/email-be.js";
|
|
4
|
+
import { ToasterTypeOptions as y } from "../../../enums/toaster.js";
|
|
5
|
+
import { ApiError as h, isValidationError as f } from "../errors/ApiError.js";
|
|
6
|
+
import { handleApiError as c } from "../errors/handleApiError.js";
|
|
7
|
+
import { TemplateCategoryListSchema as O, TemplateCategorySchema as T, TemplateNameCheckSchema as L, AllowlistValidationSchema as w, CreatedTemplateSchema as C } from "../../../@types/email-be/templates.js";
|
|
8
|
+
import { escapeHtml as _ } from "../../../utils/htmlEscape.js";
|
|
9
|
+
import { is as g, safeParse as N } from "../../../node_modules/valibot/dist/index.js";
|
|
10
|
+
const S = "[TEMPLATE_SERVICE]", u = null, P = [
|
|
11
|
+
400,
|
|
12
|
+
404,
|
|
13
|
+
409,
|
|
14
|
+
500,
|
|
15
|
+
503,
|
|
16
|
+
504,
|
|
17
|
+
o.INVALID_RESPONSE,
|
|
18
|
+
o.NETWORK,
|
|
19
|
+
o.TIMEOUT,
|
|
20
|
+
o.UNKNOWN
|
|
21
|
+
], d = () => m()("user-management.forbidden-action"), E = () => m()("newsletter.try-again-later"), k = () => m()("newsletter.template-category-name-exists");
|
|
22
|
+
function I(s) {
|
|
23
|
+
const e = Object.values(s).flatMap((t) => Array.isArray(t) ? t : []).filter((t) => typeof t == "string" && t !== "");
|
|
24
|
+
return [...new Set(e)];
|
|
25
|
+
}
|
|
26
|
+
function M(s, e) {
|
|
27
|
+
return f(s) ? Object.keys(s.errors).length ? s.firstMessage() : (!(s.cause instanceof Error) || s.message !== s.cause.message) && s.message ? s.message : e : e;
|
|
28
|
+
}
|
|
29
|
+
function R(s, e) {
|
|
30
|
+
return new h({ status: 200, code: o.INVALID_RESPONSE, message: s, cause: e });
|
|
31
|
+
}
|
|
32
|
+
function l(s, e, t) {
|
|
33
|
+
const r = N(s, e);
|
|
34
|
+
if (!r.success)
|
|
35
|
+
throw R(t, r.issues);
|
|
36
|
+
return r.output;
|
|
37
|
+
}
|
|
38
|
+
class K {
|
|
39
|
+
constructor(e) {
|
|
40
|
+
this.http = e;
|
|
41
|
+
}
|
|
42
|
+
errorOptions(e, t = "", r = {}) {
|
|
43
|
+
const a = t ? {
|
|
44
|
+
...Object.fromEntries(P.map((n) => [n, () => t])),
|
|
45
|
+
422: (n) => M(n, t)
|
|
46
|
+
} : {};
|
|
47
|
+
return {
|
|
48
|
+
context: `${S} ${e}`,
|
|
49
|
+
...r,
|
|
50
|
+
overrides: {
|
|
51
|
+
...a,
|
|
52
|
+
[o.FORBIDDEN]: d,
|
|
53
|
+
[o.PRODUCT_TYPE_DISABLED]: d,
|
|
54
|
+
[o.TEMPLATE_ALLOWLIST_UNAVAILABLE]: E,
|
|
55
|
+
[o.PRODUCT_TYPE_FETCH_FAILED]: E,
|
|
56
|
+
429: E,
|
|
57
|
+
502: E,
|
|
58
|
+
...r.overrides
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async listCategories(e = "") {
|
|
63
|
+
try {
|
|
64
|
+
const t = await this.http.request({
|
|
65
|
+
method: "GET",
|
|
66
|
+
url: i.TEMPLATE_CATEGORIES
|
|
67
|
+
});
|
|
68
|
+
return { ok: !0, data: l(O, t, "Categories answered without a list").filter((a) => g(T, a)) };
|
|
69
|
+
} catch (t) {
|
|
70
|
+
return { ok: !1, error: c(t, this.errorOptions("listCategories", e)) };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async createCategory(e) {
|
|
74
|
+
try {
|
|
75
|
+
const t = await this.http.request({
|
|
76
|
+
method: "POST",
|
|
77
|
+
url: i.TEMPLATE_CATEGORIES,
|
|
78
|
+
body: { name: e },
|
|
79
|
+
retry: u
|
|
80
|
+
});
|
|
81
|
+
return { ok: !0, data: l(T, t, "Category create answered without a category") };
|
|
82
|
+
} catch (t) {
|
|
83
|
+
return {
|
|
84
|
+
ok: !1,
|
|
85
|
+
error: c(t, this.errorOptions("createCategory", "", {
|
|
86
|
+
overrides: { [o.TEMPLATE_CATEGORY_NAME_CONFLICT]: k }
|
|
87
|
+
}))
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async isNameTaken(e) {
|
|
92
|
+
try {
|
|
93
|
+
const t = await this.http.request({
|
|
94
|
+
method: "POST",
|
|
95
|
+
url: i.TEMPLATE_NAME_CHECK,
|
|
96
|
+
body: { name: e }
|
|
97
|
+
}), { exists: r } = l(L, t, "Name check answered without a verdict");
|
|
98
|
+
return { ok: !0, data: r };
|
|
99
|
+
} catch (t) {
|
|
100
|
+
return { ok: !1, error: c(t, this.errorOptions("isNameTaken", "", { silent: !0 })) };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async checkAllowlist(e, t) {
|
|
104
|
+
try {
|
|
105
|
+
const r = await this.http.request({
|
|
106
|
+
method: "POST",
|
|
107
|
+
url: i.ALLOWLIST_VALIDATE,
|
|
108
|
+
body: { type: A, fields: { html: e.html, css: e.css } }
|
|
109
|
+
}), a = l(w, r, "Allowlist answered without a verdict");
|
|
110
|
+
if (a.clean)
|
|
111
|
+
return { ok: !0, data: !0 };
|
|
112
|
+
const n = _(I(a.violations ?? {}).join(", "));
|
|
113
|
+
return p().showToaster({
|
|
114
|
+
type: y.Error,
|
|
115
|
+
message: m()("newsletter.template-allowlist-blocked-domains", { domains: n })
|
|
116
|
+
}), {
|
|
117
|
+
ok: !1,
|
|
118
|
+
error: new h({
|
|
119
|
+
status: 422,
|
|
120
|
+
code: o.TEMPLATE_CONTENT_REJECTED,
|
|
121
|
+
message: "Content links domains that are not allowlisted"
|
|
122
|
+
})
|
|
123
|
+
};
|
|
124
|
+
} catch (r) {
|
|
125
|
+
return { ok: !1, error: c(r, this.errorOptions("checkAllowlist", t)) };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async create(e, t) {
|
|
129
|
+
try {
|
|
130
|
+
const r = await this.http.request({
|
|
131
|
+
method: "POST",
|
|
132
|
+
url: i.TEMPLATES,
|
|
133
|
+
body: e,
|
|
134
|
+
retry: u
|
|
135
|
+
});
|
|
136
|
+
return { ok: !0, data: l(C, r, "Create answered without a template").id };
|
|
137
|
+
} catch (r) {
|
|
138
|
+
return {
|
|
139
|
+
ok: !1,
|
|
140
|
+
error: c(r, this.errorOptions("create", t.fallback, {
|
|
141
|
+
overrides: { [o.TEMPLATE_NAME_CONFLICT]: () => t.nameTaken }
|
|
142
|
+
}))
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
K as TemplateService
|
|
149
|
+
};
|
|
@@ -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 S } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useConfig as k } from "../composables/useConfig.js";
|
|
3
|
+
import { useToaster as v } 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 L } from "../composables/validators/useLiquidValidator.js";
|
|
7
|
+
import { HtmlSyntax as d } from "../enums/email-be.js";
|
|
8
|
+
import { ToasterTypeOptions as N } from "../enums/toaster.js";
|
|
9
|
+
import { useRecommendationExtensionStore as H } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
10
|
+
import { templateService as o } from "./emailBe/templates/index.js";
|
|
11
|
+
import { useSaveAsTemplateStore as D } from "../stores/save-as-template.js";
|
|
12
|
+
import { ProductType as I, MessageType as x } from "../@types/config/schemas.js";
|
|
13
|
+
import "../@types/config/defaults.js";
|
|
14
|
+
import { base64EncodeWithSpecialChars as s } from "../utils/base64.js";
|
|
15
|
+
import { useTemplatePreparation as E } from "../utils/templatePreparation.js";
|
|
16
|
+
const ee = () => {
|
|
17
|
+
const { handleError: y, showToaster: f } = v(), { config: T, isFeatureEnabled: g } = k(), { validateLiquidSyntax: C } = L(), { validateSingleHtmlDocument: w } = b(), { getTemplateData: h } = S(), i = 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 o.listCategories(i("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 o.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 o.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 } = E(), m = D(), c = await h();
|
|
35
|
+
if (!w(c.html))
|
|
51
36
|
return !1;
|
|
52
|
-
const a = await
|
|
53
|
-
if (
|
|
37
|
+
const a = await t(c), l = g("liquidSyntax");
|
|
38
|
+
if (l && !await C(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
|
-
throw new Error("Unexpected create-template response");
|
|
84
|
-
return f.type === "alert" ? (i({
|
|
85
|
-
message: n(
|
|
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"
|
|
40
|
+
const n = m.getTemplateName, r = (e = T.value) == null ? void 0 : e.partner, p = {
|
|
41
|
+
name: n,
|
|
42
|
+
type: (r == null ? void 0 : r.messageType) === x.TRANSACTIONAL ? "transactional" : "promotional",
|
|
43
|
+
editor: "guido",
|
|
44
|
+
product: (r == null ? void 0 : r.productType) === I.ARCHITECT ? "architect" : "newsletter",
|
|
45
|
+
engine: l ? d.LIQUID : d.PONGO,
|
|
46
|
+
categoryIds: m.getSelectedCategoryIds,
|
|
47
|
+
content: {
|
|
48
|
+
html: s(a.compiledHtml),
|
|
49
|
+
css: s(a.css),
|
|
50
|
+
stripoConfig: s({
|
|
51
|
+
editor: "stripo",
|
|
52
|
+
html: a.rawHtml,
|
|
53
|
+
css: a.css,
|
|
54
|
+
dynamicContentList: a.dynamicContentList
|
|
55
|
+
}),
|
|
56
|
+
recommendationConfigs: s({}),
|
|
57
|
+
recommendationCampaignUrls: s(
|
|
58
|
+
H().recommendationCampaignUrls
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
}, u = i("newsletter.template-library-save-alert", { templateName: n });
|
|
62
|
+
return !(await o.checkAllowlist(p.content, u)).ok || !(await o.create(p, {
|
|
63
|
+
nameTaken: i("save-product-card.name-error"),
|
|
64
|
+
fallback: u
|
|
65
|
+
})).ok ? !1 : (f({
|
|
66
|
+
message: i("newsletter.template-library-save-success", { templateName: n }),
|
|
67
|
+
type: N.Success
|
|
96
68
|
}), !0);
|
|
97
|
-
} catch (
|
|
98
|
-
return
|
|
69
|
+
} catch (t) {
|
|
70
|
+
return y(t, "Failed to create template"), !1;
|
|
99
71
|
}
|
|
100
72
|
}
|
|
101
73
|
};
|
|
102
74
|
};
|
|
103
75
|
export {
|
|
104
|
-
|
|
76
|
+
ee as useTemplateLibraryApi
|
|
105
77
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 declare const AllowlistValidationSchema: v.ObjectSchema<{
|
|
15
|
+
readonly clean: v.BooleanSchema<undefined>;
|
|
16
|
+
readonly violations: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
17
|
+
}, undefined>;
|
|
18
|
+
export type TemplateCategory = v.InferOutput<typeof TemplateCategorySchema>;
|
|
19
|
+
export type TemplateWireType = 'promotional' | 'transactional';
|
|
20
|
+
export type TemplateWireProduct = 'newsletter' | 'architect';
|
|
21
|
+
export interface TemplateCreateContent {
|
|
22
|
+
html: string;
|
|
23
|
+
css: string;
|
|
24
|
+
stripoConfig: string;
|
|
25
|
+
recommendationConfigs: string;
|
|
26
|
+
recommendationCampaignUrls: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TemplateCreateBody {
|
|
29
|
+
name: string;
|
|
30
|
+
type: TemplateWireType;
|
|
31
|
+
editor: 'guido';
|
|
32
|
+
product: TemplateWireProduct;
|
|
33
|
+
engine: HtmlSyntaxValue;
|
|
34
|
+
categoryIds: number[];
|
|
35
|
+
content: TemplateCreateContent;
|
|
36
|
+
}
|
|
37
|
+
export interface TemplateCreateMessages {
|
|
38
|
+
nameTaken: string;
|
|
39
|
+
fallback: string;
|
|
40
|
+
}
|
|
@@ -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,7 +1,12 @@
|
|
|
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";
|
|
7
|
+
readonly ALLOWLIST_VALIDATE: "/v1/allowlist/validate";
|
|
4
8
|
};
|
|
9
|
+
export declare const ALLOWLIST_TEMPLATE_TYPE = "emailTemplateLibrary";
|
|
5
10
|
export declare const EmailBeErrorCodes: {
|
|
6
11
|
readonly BAD_GATEWAY: "bad_gateway";
|
|
7
12
|
readonly BAD_REQUEST: "bad_request";
|
|
@@ -17,6 +22,12 @@ export declare const EmailBeErrorCodes: {
|
|
|
17
22
|
readonly NETWORK: "network_error";
|
|
18
23
|
readonly TIMEOUT: "timeout";
|
|
19
24
|
readonly UNKNOWN: "unknown";
|
|
25
|
+
readonly PRODUCT_TYPE_DISABLED: "product-type:errors.disabled";
|
|
26
|
+
readonly PRODUCT_TYPE_FETCH_FAILED: "product-type:errors.fetch-failed";
|
|
27
|
+
readonly TEMPLATE_NAME_CONFLICT: "template:errors.name-conflict";
|
|
28
|
+
readonly TEMPLATE_CATEGORY_NAME_CONFLICT: "template:errors.category-name-conflict";
|
|
29
|
+
readonly TEMPLATE_CONTENT_REJECTED: "template:errors.content-rejected";
|
|
30
|
+
readonly TEMPLATE_ALLOWLIST_UNAVAILABLE: "template:errors.allowlist-unavailable";
|
|
20
31
|
};
|
|
21
32
|
export type ApiErrorCode = typeof EmailBeErrorCodes[keyof typeof EmailBeErrorCodes];
|
|
22
33
|
export declare const HtmlSyntax: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HttpManager } from '@@/Services/emailBe/http/HttpManager';
|
|
2
|
+
import type { Result } from '@@/Services/emailBe/http/types';
|
|
3
|
+
import type { TemplateCategory, TemplateCreateBody, TemplateCreateContent, 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
|
+
checkAllowlist(content: TemplateCreateContent, fallback: string): Promise<Result<true>>;
|
|
12
|
+
create(body: TemplateCreateBody, messages: TemplateCreateMessages): Promise<Result<number>>;
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.30.1-beta.
|
|
3
|
+
"version": "3.30.1-beta.34bc10d",
|
|
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",
|