@useinsider/guido 3.30.2-beta.a9ecedf → 3.30.2-beta.cc492bd
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/components/organisms/save-as-template/SaveAsTemplateDrawer.vue.js +2 -2
- package/dist/enums/defaults.js +5 -4
- package/dist/enums/email-be.js +9 -20
- package/dist/node_modules/valibot/dist/index.js +90 -95
- package/dist/package.json.js +4 -4
- package/dist/services/emailBe/errors/ApiError.js +26 -27
- package/dist/services/templateLibraryApi.js +87 -59
- package/dist/src/@types/save-as-template.d.ts +23 -1
- package/dist/src/enums/email-be.d.ts +0 -11
- package/package.json +2 -2
- package/dist/@types/email-be/templates.js +0 -15
- package/dist/services/emailBe/templates/TemplateService.js +0 -149
- package/dist/services/emailBe/templates/index.js +0 -6
- package/dist/src/@types/email-be/templates.d.ts +0 -40
- package/dist/src/services/emailBe/templates/TemplateService.d.ts +0 -13
- package/dist/src/services/emailBe/templates/index.d.ts +0 -2
|
@@ -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, record as g, fallback as R, literal as u, lazy as T, looseObject as C, variant as I, union as h } 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 = T(() => 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
|
+
R(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 = I("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, union as t, nullable as d, record as h, number as a, 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({
|
|
@@ -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: 25
|
|
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": 25, "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,14 +1,15 @@
|
|
|
1
1
|
const e = {
|
|
2
2
|
transactional: 2
|
|
3
|
-
}, s = 13, t = "https://email-static.useinsider.com",
|
|
3
|
+
}, s = 2, a = 13, t = "https://email-static.useinsider.com", o = `${t}/templates/campaign/default.html`, l = `${t}/templates/campaign/default.css`, E = {
|
|
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
|
+
o as BLANK_TEMPLATE_HTML_URL,
|
|
10
10
|
t as EMAIL_STATIC_BASE_URL,
|
|
11
|
-
s as
|
|
12
|
-
|
|
11
|
+
s as EditorType,
|
|
12
|
+
a as MAX_DEFAULT_TEMPLATE_ID,
|
|
13
|
+
E as ModuleFolderDefaults,
|
|
13
14
|
e as TemplateTypes
|
|
14
15
|
};
|
package/dist/enums/email-be.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
HTML_VALIDATE: "/v1/html/validate"
|
|
3
|
-
|
|
4
|
-
TEMPLATE_NAME_CHECK: "/v1/templates/name-check",
|
|
5
|
-
TEMPLATE_CATEGORIES: "/v1/templates/categories",
|
|
6
|
-
ALLOWLIST_VALIDATE: "/v1/allowlist/validate"
|
|
7
|
-
}, t = "emailTemplateLibrary", T = {
|
|
1
|
+
const E = "/email-proxy", e = {
|
|
2
|
+
HTML_VALIDATE: "/v1/html/validate"
|
|
3
|
+
}, n = {
|
|
8
4
|
BAD_GATEWAY: "bad_gateway",
|
|
9
5
|
BAD_REQUEST: "bad_request",
|
|
10
6
|
CONFLICT: "conflict",
|
|
@@ -18,21 +14,14 @@ const e = "/email-proxy", E = {
|
|
|
18
14
|
INVALID_RESPONSE: "invalid_response",
|
|
19
15
|
NETWORK: "network_error",
|
|
20
16
|
TIMEOUT: "timeout",
|
|
21
|
-
UNKNOWN: "unknown"
|
|
22
|
-
|
|
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 = {
|
|
17
|
+
UNKNOWN: "unknown"
|
|
18
|
+
}, t = {
|
|
29
19
|
PONGO: "pongo",
|
|
30
20
|
LIQUID: "liquid"
|
|
31
21
|
};
|
|
32
22
|
export {
|
|
33
|
-
|
|
34
|
-
e as
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
r as HtmlSyntax
|
|
23
|
+
E as EMAIL_BE_BASE_URL,
|
|
24
|
+
e as EmailBeEndPoints,
|
|
25
|
+
n as EmailBeErrorCodes,
|
|
26
|
+
t as HtmlSyntax
|
|
38
27
|
};
|
|
@@ -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, t) {
|
|
34
|
+
const l = t && "input" in t ? t.input : e.value, u = (t == null ? void 0 : t.expected) ?? n.expects ?? null, p = (t == null ? void 0 : t.received) ?? /* @__PURE__ */ D(l), i = {
|
|
35
35
|
kind: n.kind,
|
|
36
36
|
type: n.type,
|
|
37
37
|
input: l,
|
|
38
|
-
expected:
|
|
38
|
+
expected: u,
|
|
39
39
|
received: p,
|
|
40
|
-
message: `Invalid ${r}: ${
|
|
40
|
+
message: `Invalid ${r}: ${u ? `Expected ${u} but r` : "R"}eceived ${p}`,
|
|
41
41
|
requirement: n.requirement,
|
|
42
|
-
path:
|
|
43
|
-
issues:
|
|
42
|
+
path: t == null ? void 0 : t.path,
|
|
43
|
+
issues: t == null ? void 0 : t.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 = (t == null ? void 0 : t.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 t = n["~run"](e, s);
|
|
192
|
+
return t.issues ? {
|
|
193
193
|
typed: !0,
|
|
194
|
-
value: /* @__PURE__ */ P(this,
|
|
195
|
-
} :
|
|
194
|
+
value: /* @__PURE__ */ P(this, t, s)
|
|
195
|
+
} : t;
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
}
|
|
@@ -201,10 +201,6 @@ 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__
|
|
208
204
|
function R(n, r) {
|
|
209
205
|
return {
|
|
210
206
|
kind: "schema",
|
|
@@ -219,17 +215,17 @@ function R(n, r) {
|
|
|
219
215
|
},
|
|
220
216
|
"~run"(e, s) {
|
|
221
217
|
var l;
|
|
222
|
-
const
|
|
223
|
-
if (Array.isArray(
|
|
218
|
+
const t = e.value;
|
|
219
|
+
if (Array.isArray(t)) {
|
|
224
220
|
e.typed = !0, e.value = [];
|
|
225
|
-
for (let
|
|
226
|
-
const p = u
|
|
221
|
+
for (let u = 0; u < t.length; u++) {
|
|
222
|
+
const p = t[u], i = this.item["~run"]({ value: p }, s);
|
|
227
223
|
if (i.issues) {
|
|
228
224
|
const c = {
|
|
229
225
|
type: "array",
|
|
230
226
|
origin: "value",
|
|
231
|
-
input:
|
|
232
|
-
key:
|
|
227
|
+
input: t,
|
|
228
|
+
key: u,
|
|
233
229
|
value: p
|
|
234
230
|
};
|
|
235
231
|
for (const a of i.issues)
|
|
@@ -331,19 +327,19 @@ function T(n, r) {
|
|
|
331
327
|
},
|
|
332
328
|
"~run"(e, s) {
|
|
333
329
|
var l;
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
330
|
+
const t = e.value;
|
|
331
|
+
if (t && typeof t == "object") {
|
|
336
332
|
e.typed = !0, e.value = {};
|
|
337
|
-
for (const
|
|
338
|
-
const p = this.entries[
|
|
339
|
-
if (
|
|
340
|
-
const i =
|
|
333
|
+
for (const u in this.entries) {
|
|
334
|
+
const p = this.entries[u];
|
|
335
|
+
if (u in t || (p.type === "exact_optional" || p.type === "optional" || p.type === "nullish") && p.default !== void 0) {
|
|
336
|
+
const i = u in t ? t[u] : /* @__PURE__ */ k(p), c = p["~run"]({ value: i }, s);
|
|
341
337
|
if (c.issues) {
|
|
342
338
|
const a = {
|
|
343
339
|
type: "object",
|
|
344
340
|
origin: "value",
|
|
345
|
-
input:
|
|
346
|
-
key:
|
|
341
|
+
input: t,
|
|
342
|
+
key: u,
|
|
347
343
|
value: i
|
|
348
344
|
};
|
|
349
345
|
for (const y of c.issues)
|
|
@@ -353,23 +349,23 @@ function T(n, r) {
|
|
|
353
349
|
break;
|
|
354
350
|
}
|
|
355
351
|
}
|
|
356
|
-
c.typed || (e.typed = !1), e.value[
|
|
357
|
-
} else if (p.fallback !== void 0) e.value[
|
|
352
|
+
c.typed || (e.typed = !1), e.value[u] = c.value;
|
|
353
|
+
} else if (p.fallback !== void 0) e.value[u] = /* @__PURE__ */ P(p);
|
|
358
354
|
else if (p.type !== "exact_optional" && p.type !== "optional" && p.type !== "nullish" && (f(this, "key", e, s, {
|
|
359
355
|
input: void 0,
|
|
360
|
-
expected: `"${
|
|
356
|
+
expected: `"${u}"`,
|
|
361
357
|
path: [{
|
|
362
358
|
type: "object",
|
|
363
359
|
origin: "key",
|
|
364
|
-
input:
|
|
365
|
-
key:
|
|
366
|
-
value: u
|
|
360
|
+
input: t,
|
|
361
|
+
key: u,
|
|
362
|
+
value: t[u]
|
|
367
363
|
}]
|
|
368
364
|
}), s.abortEarly))
|
|
369
365
|
break;
|
|
370
366
|
}
|
|
371
367
|
if (!e.issues || !s.abortEarly)
|
|
372
|
-
for (const
|
|
368
|
+
for (const u in t) /* @__PURE__ */ S(t, u) && !(u in this.entries) && (e.value[u] = t[u]);
|
|
373
369
|
} else f(this, "type", e, s);
|
|
374
370
|
return e;
|
|
375
371
|
}
|
|
@@ -443,19 +439,19 @@ function Y(n, r) {
|
|
|
443
439
|
},
|
|
444
440
|
"~run"(e, s) {
|
|
445
441
|
var l;
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
442
|
+
const t = e.value;
|
|
443
|
+
if (t && typeof t == "object") {
|
|
448
444
|
e.typed = !0, e.value = {};
|
|
449
|
-
for (const
|
|
450
|
-
const p = this.entries[
|
|
451
|
-
if (
|
|
452
|
-
const i =
|
|
445
|
+
for (const u in this.entries) {
|
|
446
|
+
const p = this.entries[u];
|
|
447
|
+
if (u in t || (p.type === "exact_optional" || p.type === "optional" || p.type === "nullish") && p.default !== void 0) {
|
|
448
|
+
const i = u in t ? t[u] : /* @__PURE__ */ k(p), c = p["~run"]({ value: i }, s);
|
|
453
449
|
if (c.issues) {
|
|
454
450
|
const a = {
|
|
455
451
|
type: "object",
|
|
456
452
|
origin: "value",
|
|
457
|
-
input:
|
|
458
|
-
key:
|
|
453
|
+
input: t,
|
|
454
|
+
key: u,
|
|
459
455
|
value: i
|
|
460
456
|
};
|
|
461
457
|
for (const y of c.issues)
|
|
@@ -465,17 +461,17 @@ function Y(n, r) {
|
|
|
465
461
|
break;
|
|
466
462
|
}
|
|
467
463
|
}
|
|
468
|
-
c.typed || (e.typed = !1), e.value[
|
|
469
|
-
} else if (p.fallback !== void 0) e.value[
|
|
464
|
+
c.typed || (e.typed = !1), e.value[u] = c.value;
|
|
465
|
+
} else if (p.fallback !== void 0) e.value[u] = /* @__PURE__ */ P(p);
|
|
470
466
|
else if (p.type !== "exact_optional" && p.type !== "optional" && p.type !== "nullish" && (f(this, "key", e, s, {
|
|
471
467
|
input: void 0,
|
|
472
|
-
expected: `"${
|
|
468
|
+
expected: `"${u}"`,
|
|
473
469
|
path: [{
|
|
474
470
|
type: "object",
|
|
475
471
|
origin: "key",
|
|
476
|
-
input:
|
|
477
|
-
key:
|
|
478
|
-
value: u
|
|
472
|
+
input: t,
|
|
473
|
+
key: u,
|
|
474
|
+
value: t[u]
|
|
479
475
|
}]
|
|
480
476
|
}), s.abortEarly))
|
|
481
477
|
break;
|
|
@@ -535,13 +531,13 @@ function ee(n, r, e) {
|
|
|
535
531
|
get "~standard"() {
|
|
536
532
|
return /* @__PURE__ */ o(this);
|
|
537
533
|
},
|
|
538
|
-
"~run"(s,
|
|
539
|
-
var
|
|
534
|
+
"~run"(s, t) {
|
|
535
|
+
var u, p;
|
|
540
536
|
const l = s.value;
|
|
541
537
|
if (l && typeof l == "object") {
|
|
542
538
|
s.typed = !0, s.value = {};
|
|
543
539
|
for (const i in l) if (/* @__PURE__ */ S(l, i)) {
|
|
544
|
-
const c = l[i], a = this.key["~run"]({ value: i },
|
|
540
|
+
const c = l[i], a = this.key["~run"]({ value: i }, t);
|
|
545
541
|
if (a.issues) {
|
|
546
542
|
const b = {
|
|
547
543
|
type: "object",
|
|
@@ -551,13 +547,13 @@ function ee(n, r, e) {
|
|
|
551
547
|
value: c
|
|
552
548
|
};
|
|
553
549
|
for (const h of a.issues)
|
|
554
|
-
h.path = [b], (
|
|
555
|
-
if (s.issues || (s.issues = a.issues),
|
|
550
|
+
h.path = [b], (u = s.issues) == null || u.push(h);
|
|
551
|
+
if (s.issues || (s.issues = a.issues), t.abortEarly) {
|
|
556
552
|
s.typed = !1;
|
|
557
553
|
break;
|
|
558
554
|
}
|
|
559
555
|
}
|
|
560
|
-
const y = this.value["~run"]({ value: c },
|
|
556
|
+
const y = this.value["~run"]({ value: c }, t);
|
|
561
557
|
if (y.issues) {
|
|
562
558
|
const b = {
|
|
563
559
|
type: "object",
|
|
@@ -568,14 +564,14 @@ function ee(n, r, e) {
|
|
|
568
564
|
};
|
|
569
565
|
for (const h of y.issues)
|
|
570
566
|
h.path ? h.path.unshift(b) : h.path = [b], (p = s.issues) == null || p.push(h);
|
|
571
|
-
if (s.issues || (s.issues = y.issues),
|
|
567
|
+
if (s.issues || (s.issues = y.issues), t.abortEarly) {
|
|
572
568
|
s.typed = !1;
|
|
573
569
|
break;
|
|
574
570
|
}
|
|
575
571
|
}
|
|
576
572
|
(!a.typed || !y.typed) && (s.typed = !1), a.typed && (s.value[a.value] = y.value);
|
|
577
573
|
}
|
|
578
|
-
} else f(this, "type", s,
|
|
574
|
+
} else f(this, "type", s, t);
|
|
579
575
|
return s;
|
|
580
576
|
}
|
|
581
577
|
};
|
|
@@ -612,17 +608,17 @@ function re(n, r) {
|
|
|
612
608
|
},
|
|
613
609
|
"~run"(e, s) {
|
|
614
610
|
var l;
|
|
615
|
-
const
|
|
616
|
-
if (Array.isArray(
|
|
611
|
+
const t = e.value;
|
|
612
|
+
if (Array.isArray(t)) {
|
|
617
613
|
e.typed = !0, e.value = [];
|
|
618
|
-
for (let
|
|
619
|
-
const p = u
|
|
614
|
+
for (let u = 0; u < this.items.length; u++) {
|
|
615
|
+
const p = t[u], i = this.items[u]["~run"]({ value: p }, s);
|
|
620
616
|
if (i.issues) {
|
|
621
617
|
const c = {
|
|
622
618
|
type: "array",
|
|
623
619
|
origin: "value",
|
|
624
|
-
input:
|
|
625
|
-
key:
|
|
620
|
+
input: t,
|
|
621
|
+
key: u,
|
|
626
622
|
value: p
|
|
627
623
|
};
|
|
628
624
|
for (const a of i.issues)
|
|
@@ -659,34 +655,34 @@ function se(n, r) {
|
|
|
659
655
|
return /* @__PURE__ */ o(this);
|
|
660
656
|
},
|
|
661
657
|
"~run"(e, s) {
|
|
662
|
-
let
|
|
658
|
+
let t, l, u;
|
|
663
659
|
for (const p of this.options) {
|
|
664
660
|
const i = p["~run"]({ value: e.value }, s);
|
|
665
661
|
if (i.typed) if (i.issues) l ? l.push(i) : l = [i];
|
|
666
662
|
else {
|
|
667
|
-
|
|
663
|
+
t = i;
|
|
668
664
|
break;
|
|
669
665
|
}
|
|
670
|
-
else
|
|
666
|
+
else u ? u.push(i) : u = [i];
|
|
671
667
|
}
|
|
672
|
-
if (
|
|
668
|
+
if (t) return t;
|
|
673
669
|
if (l) {
|
|
674
670
|
if (l.length === 1) return l[0];
|
|
675
671
|
f(this, "type", e, s, { issues: /* @__PURE__ */ A(l) }), e.typed = !0;
|
|
676
672
|
} else {
|
|
677
|
-
if ((
|
|
678
|
-
f(this, "type", e, s, { issues: /* @__PURE__ */ A(
|
|
673
|
+
if ((u == null ? void 0 : u.length) === 1) return u[0];
|
|
674
|
+
f(this, "type", e, s, { issues: /* @__PURE__ */ A(u) });
|
|
679
675
|
}
|
|
680
676
|
return e;
|
|
681
677
|
}
|
|
682
678
|
};
|
|
683
679
|
}
|
|
684
680
|
// @__NO_SIDE_EFFECTS__
|
|
685
|
-
function
|
|
681
|
+
function te() {
|
|
686
682
|
return {
|
|
687
683
|
kind: "schema",
|
|
688
684
|
type: "unknown",
|
|
689
|
-
reference:
|
|
685
|
+
reference: te,
|
|
690
686
|
expects: "unknown",
|
|
691
687
|
async: !1,
|
|
692
688
|
get "~standard"() {
|
|
@@ -698,11 +694,11 @@ function ue() {
|
|
|
698
694
|
};
|
|
699
695
|
}
|
|
700
696
|
// @__NO_SIDE_EFFECTS__
|
|
701
|
-
function
|
|
697
|
+
function ue(n, r, e) {
|
|
702
698
|
return {
|
|
703
699
|
kind: "schema",
|
|
704
700
|
type: "variant",
|
|
705
|
-
reference:
|
|
701
|
+
reference: ue,
|
|
706
702
|
expects: "Object",
|
|
707
703
|
async: !1,
|
|
708
704
|
key: n,
|
|
@@ -711,10 +707,10 @@ function te(n, r, e) {
|
|
|
711
707
|
get "~standard"() {
|
|
712
708
|
return /* @__PURE__ */ o(this);
|
|
713
709
|
},
|
|
714
|
-
"~run"(s,
|
|
710
|
+
"~run"(s, t) {
|
|
715
711
|
const l = s.value;
|
|
716
712
|
if (l && typeof l == "object") {
|
|
717
|
-
let
|
|
713
|
+
let u, p = 0, i = this.key, c = [];
|
|
718
714
|
const a = (y, b) => {
|
|
719
715
|
for (const h of y.options) {
|
|
720
716
|
if (h.type === "variant") a(h, new Set(b).add(h.key));
|
|
@@ -732,15 +728,15 @@ function te(n, r, e) {
|
|
|
732
728
|
g++;
|
|
733
729
|
}
|
|
734
730
|
if (O) {
|
|
735
|
-
const v = h["~run"]({ value: l },
|
|
736
|
-
(!
|
|
731
|
+
const v = h["~run"]({ value: l }, t);
|
|
732
|
+
(!u || !u.typed && v.typed) && (u = v);
|
|
737
733
|
}
|
|
738
734
|
}
|
|
739
|
-
if (
|
|
735
|
+
if (u && !u.issues) break;
|
|
740
736
|
}
|
|
741
737
|
};
|
|
742
|
-
if (a(this, /* @__PURE__ */ new Set([this.key])),
|
|
743
|
-
f(this, "type", s,
|
|
738
|
+
if (a(this, /* @__PURE__ */ new Set([this.key])), u) return u;
|
|
739
|
+
f(this, "type", s, t, {
|
|
744
740
|
input: l[i],
|
|
745
741
|
expected: /* @__PURE__ */ w(c, "|"),
|
|
746
742
|
path: [{
|
|
@@ -751,18 +747,18 @@ function te(n, r, e) {
|
|
|
751
747
|
value: l[i]
|
|
752
748
|
}]
|
|
753
749
|
});
|
|
754
|
-
} else f(this, "type", s,
|
|
750
|
+
} else f(this, "type", s, t);
|
|
755
751
|
return s;
|
|
756
752
|
}
|
|
757
753
|
};
|
|
758
754
|
}
|
|
759
|
-
function
|
|
755
|
+
function le(n, r, e) {
|
|
760
756
|
const s = n["~run"]({ value: r }, /* @__PURE__ */ x(e));
|
|
761
757
|
if (s.issues) throw new K(s.issues);
|
|
762
758
|
return s.value;
|
|
763
759
|
}
|
|
764
760
|
// @__NO_SIDE_EFFECTS__
|
|
765
|
-
function
|
|
761
|
+
function pe(...n) {
|
|
766
762
|
return {
|
|
767
763
|
...n[0],
|
|
768
764
|
pipe: n,
|
|
@@ -782,7 +778,7 @@ function ae(...n) {
|
|
|
782
778
|
};
|
|
783
779
|
}
|
|
784
780
|
// @__NO_SIDE_EFFECTS__
|
|
785
|
-
function
|
|
781
|
+
function ae(...n) {
|
|
786
782
|
return {
|
|
787
783
|
...n[0],
|
|
788
784
|
pipe: n,
|
|
@@ -803,7 +799,7 @@ function ce(...n) {
|
|
|
803
799
|
};
|
|
804
800
|
}
|
|
805
801
|
// @__NO_SIDE_EFFECTS__
|
|
806
|
-
function
|
|
802
|
+
function ce(n, r, e) {
|
|
807
803
|
const s = n["~run"]({ value: r }, /* @__PURE__ */ x(e));
|
|
808
804
|
return {
|
|
809
805
|
typed: s.typed,
|
|
@@ -813,7 +809,7 @@ function fe(n, r, e) {
|
|
|
813
809
|
};
|
|
814
810
|
}
|
|
815
811
|
// @__NO_SIDE_EFFECTS__
|
|
816
|
-
async function
|
|
812
|
+
async function fe(n, r, e) {
|
|
817
813
|
const s = await n["~run"]({ value: r }, /* @__PURE__ */ x(e));
|
|
818
814
|
return {
|
|
819
815
|
typed: s.typed,
|
|
@@ -841,7 +837,6 @@ export {
|
|
|
841
837
|
I as getGlobalMessage,
|
|
842
838
|
V as getSchemaMessage,
|
|
843
839
|
q as getSpecificMessage,
|
|
844
|
-
le as is,
|
|
845
840
|
J as lazy,
|
|
846
841
|
Q as literal,
|
|
847
842
|
T as looseObject,
|
|
@@ -853,18 +848,18 @@ export {
|
|
|
853
848
|
X as number,
|
|
854
849
|
Y as object,
|
|
855
850
|
Z as optional,
|
|
856
|
-
|
|
851
|
+
le as parse,
|
|
857
852
|
$ as picklist,
|
|
858
|
-
|
|
859
|
-
|
|
853
|
+
pe as pipe,
|
|
854
|
+
ae as pipeAsync,
|
|
860
855
|
ee as record,
|
|
861
|
-
|
|
862
|
-
|
|
856
|
+
ce as safeParse,
|
|
857
|
+
fe as safeParseAsync,
|
|
863
858
|
ne as string,
|
|
864
859
|
C as transform,
|
|
865
860
|
F as trim,
|
|
866
861
|
re as tuple,
|
|
867
862
|
se as union,
|
|
868
|
-
|
|
869
|
-
|
|
863
|
+
te as unknown,
|
|
864
|
+
ue as variant
|
|
870
865
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const o = "3.30.2-beta.
|
|
1
|
+
const o = "3.30.2-beta.cc492bd", s = { stripo: { version: "2.87.0" } }, t = {
|
|
2
2
|
version: o,
|
|
3
|
-
guido:
|
|
3
|
+
guido: s
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
t as default,
|
|
7
|
+
s as guido,
|
|
8
8
|
o as version
|
|
9
9
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var d = (
|
|
3
|
-
var t = (
|
|
4
|
-
class
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
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
7
|
t(this, "status");
|
|
8
8
|
t(this, "code");
|
|
9
9
|
t(this, "meta");
|
|
@@ -12,40 +12,39 @@ class o 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 = 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
16
|
}
|
|
17
|
-
is(
|
|
18
|
-
return this.code ===
|
|
17
|
+
is(s) {
|
|
18
|
+
return this.code === s;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class u extends a {
|
|
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 h extends a {
|
|
28
28
|
}
|
|
29
|
-
class
|
|
29
|
+
class n extends a {
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class l extends a {
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class E extends a {
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class x extends a {
|
|
36
36
|
}
|
|
37
|
-
class
|
|
37
|
+
class i extends a {
|
|
38
38
|
}
|
|
39
|
-
const m = (
|
|
39
|
+
const m = (e) => e instanceof a;
|
|
40
40
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
m as isApiError
|
|
50
|
-
p as isValidationError
|
|
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
|
|
51
50
|
};
|
|
@@ -1,77 +1,105 @@
|
|
|
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
|
-
const
|
|
17
|
-
const { handleError: y, showToaster: f } = v(), { config: T, isFeatureEnabled: g } = k(), { validateLiquidSyntax: C } = L(), { validateSingleHtmlDocument: w } = b(), { getTemplateData: h } = S(), i = A();
|
|
1
|
+
import { useActionsApi as A } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useConfig as S } from "../composables/useConfig.js";
|
|
3
|
+
import { useHttp as E } from "../composables/useHttp.js";
|
|
4
|
+
import { useToaster as x } from "../composables/useToaster.js";
|
|
5
|
+
import { useTranslations as P } from "../composables/useTranslations.js";
|
|
6
|
+
import { useHtmlDocumentCountValidator as L } from "../composables/validators/useHtmlDocumentCountValidator.js";
|
|
7
|
+
import { useLiquidValidator as N } from "../composables/validators/useLiquidValidator.js";
|
|
8
|
+
import { EditorType as H } from "../enums/defaults.js";
|
|
9
|
+
import { ToasterTypeOptions as T } from "../enums/toaster.js";
|
|
10
|
+
import { useRecommendationExtensionStore as D } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
|
+
import { useSaveAsTemplateStore as q } from "../stores/save-as-template.js";
|
|
12
|
+
import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
|
|
13
|
+
import { isPlainObject as w } from "../utils/genericUtil.js";
|
|
14
|
+
import { useTemplatePreparation as F } from "../utils/templatePreparation.js";
|
|
15
|
+
const Z = () => {
|
|
16
|
+
const { get: l, post: c } = E(), { handleError: o, showToaster: i } = x(), { config: p, isFeatureEnabled: u } = S(), { validateLiquidSyntax: b } = N(), { validateSingleHtmlDocument: C } = L(), { getTemplateData: h } = A(), n = P();
|
|
18
17
|
return {
|
|
19
18
|
getCategories: async () => {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
try {
|
|
20
|
+
const { data: e } = await l("/newsletter/template-library/get-template-categories");
|
|
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
|
+
}
|
|
22
28
|
},
|
|
23
29
|
checkTemplateNameAvailability: async (e) => {
|
|
24
|
-
const t = await
|
|
25
|
-
|
|
30
|
+
const { data: { status: t = !1 } } = await l(
|
|
31
|
+
`/newsletter/template-library/template-name-exists?name=${e}`
|
|
32
|
+
);
|
|
33
|
+
return !t;
|
|
26
34
|
},
|
|
27
35
|
createCategory: async (e) => {
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
try {
|
|
37
|
+
const { data: { id: t } } = await c(
|
|
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
|
+
}
|
|
30
45
|
},
|
|
31
46
|
createTemplate: async () => {
|
|
32
|
-
var e;
|
|
47
|
+
var e, t, d, y;
|
|
33
48
|
try {
|
|
34
|
-
const { prepareTemplateDetails:
|
|
35
|
-
if (!
|
|
49
|
+
const { prepareTemplateDetails: m } = F(), s = q(), g = await h();
|
|
50
|
+
if (!C(g.html))
|
|
36
51
|
return !1;
|
|
37
|
-
const a = await
|
|
38
|
-
if (
|
|
52
|
+
const a = await m(g);
|
|
53
|
+
if (u("liquidSyntax") && !await b(a.compiledHtml))
|
|
39
54
|
return !1;
|
|
40
|
-
const
|
|
41
|
-
name:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
const v = {
|
|
56
|
+
name: s.getTemplateName,
|
|
57
|
+
categories: s.getSelectedCategoryIds,
|
|
58
|
+
productId: ((t = (e = p.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
|
|
59
|
+
editorType: H,
|
|
60
|
+
messageType: ((y = (d = p.value) == null ? void 0 : d.partner) == null ? void 0 : y.messageType) || 0,
|
|
61
|
+
content: r(a.compiledHtml),
|
|
62
|
+
css: r(a.css),
|
|
63
|
+
unsubscriptionPreferencePageStatus: !1,
|
|
64
|
+
unsubscriptionPreferencePages: [],
|
|
65
|
+
recommendationCampaignUrls: r(
|
|
66
|
+
D().recommendationCampaignUrls
|
|
67
|
+
),
|
|
68
|
+
recommendationConfigs: r({}),
|
|
69
|
+
isGuido: !0,
|
|
70
|
+
// eslint-disable-next-line camelcase
|
|
71
|
+
template_engine: u("liquidSyntax") ? 1 : 0,
|
|
72
|
+
stripoConfig: r({
|
|
73
|
+
editor: "stripo",
|
|
74
|
+
html: a.rawHtml,
|
|
75
|
+
css: a.css,
|
|
76
|
+
dynamicContentList: a.dynamicContentList
|
|
77
|
+
})
|
|
78
|
+
}, { data: f } = await c(
|
|
79
|
+
"/newsletter/template-library/create-template",
|
|
80
|
+
v
|
|
81
|
+
);
|
|
82
|
+
if (!w(f))
|
|
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"
|
|
68
96
|
}), !0);
|
|
69
|
-
} catch (
|
|
70
|
-
return
|
|
97
|
+
} catch (m) {
|
|
98
|
+
return o(m, "Failed to create template"), !1;
|
|
71
99
|
}
|
|
72
100
|
}
|
|
73
101
|
};
|
|
74
102
|
};
|
|
75
103
|
export {
|
|
76
|
-
|
|
104
|
+
Z as useTemplateLibraryApi
|
|
77
105
|
};
|
|
@@ -2,7 +2,29 @@ export interface MappedCategory {
|
|
|
2
2
|
value: string;
|
|
3
3
|
text: string;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
5
|
+
export interface Category {
|
|
6
|
+
id: number;
|
|
7
|
+
name: string;
|
|
8
|
+
partnerId: number;
|
|
9
|
+
isStripo: boolean;
|
|
10
|
+
templatesCount: number;
|
|
11
|
+
}
|
|
6
12
|
export interface RecommendationCampaignUrls {
|
|
7
13
|
[key: string]: string;
|
|
8
14
|
}
|
|
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,12 +1,7 @@
|
|
|
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";
|
|
8
4
|
};
|
|
9
|
-
export declare const ALLOWLIST_TEMPLATE_TYPE = "emailTemplateLibrary";
|
|
10
5
|
export declare const EmailBeErrorCodes: {
|
|
11
6
|
readonly BAD_GATEWAY: "bad_gateway";
|
|
12
7
|
readonly BAD_REQUEST: "bad_request";
|
|
@@ -22,12 +17,6 @@ export declare const EmailBeErrorCodes: {
|
|
|
22
17
|
readonly NETWORK: "network_error";
|
|
23
18
|
readonly TIMEOUT: "timeout";
|
|
24
19
|
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";
|
|
31
20
|
};
|
|
32
21
|
export type ApiErrorCode = typeof EmailBeErrorCodes[keyof typeof EmailBeErrorCodes];
|
|
33
22
|
export declare const HtmlSyntax: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.30.2-beta.
|
|
3
|
+
"version": "3.30.2-beta.cc492bd",
|
|
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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"coverage:e2e:report": "nyc report --reporter=lcov --reporter=text-summary --report-dir=coverage/e2e",
|
|
51
51
|
"coverage:e2e:verify": "node scripts/e2e-coverage/verify-lcov-inventory.mjs",
|
|
52
52
|
"test:mutation": "stryker run",
|
|
53
|
-
"test:mutation:since": "
|
|
53
|
+
"test:mutation:since": "node scripts/mutation-changed.mjs",
|
|
54
54
|
"stripo:manifest": "node scripts/stripo-runtime-manifest.mjs",
|
|
55
55
|
"prepare": "husky",
|
|
56
56
|
"preinstall": "rm -rf ./node_modules/.vite"
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,149 +0,0 @@
|
|
|
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,40 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|