@useinsider/guido 3.29.1 → 3.30.0-beta.232ea3c
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 +3 -3
- package/dist/@types/email-be/html-validation.js +28 -0
- package/dist/composables/useSave.js +19 -17
- package/dist/composables/useSaveValidation.js +134 -252
- package/dist/composables/useTranslations.js +14 -9
- package/dist/enums/email-be.js +27 -0
- package/dist/enums/save-validation.js +2 -2
- package/dist/node_modules/valibot/dist/index.js +232 -154
- package/dist/package.json.js +2 -2
- package/dist/services/emailBe/errors/ApiError.js +50 -0
- package/dist/services/emailBe/errors/handleApiError.js +31 -0
- package/dist/services/emailBe/errors/toApiError.js +71 -0
- package/dist/services/emailBe/html/HtmlValidationService.js +35 -0
- package/dist/services/emailBe/html/index.js +6 -0
- package/dist/services/emailBe/http/HttpManager.js +68 -0
- package/dist/services/emailBe/http/RetryStack.js +24 -0
- package/dist/services/emailBe/http/client.js +61 -0
- package/dist/services/emailBe/http/index.js +10 -0
- package/dist/services/emailBe/http/transportErrors.js +20 -0
- package/dist/src/@types/email-be/html-validation.d.ts +51 -0
- package/dist/src/composables/useSaveValidation.d.ts +2 -2
- package/dist/src/enums/email-be.d.ts +26 -0
- package/dist/src/enums/save-validation.d.ts +3 -15
- package/dist/src/services/emailBe/errors/ApiError.d.ts +40 -0
- package/dist/src/services/emailBe/errors/handleApiError.d.ts +11 -0
- package/dist/src/services/emailBe/errors/toApiError.d.ts +2 -0
- package/dist/src/services/emailBe/html/HtmlValidationService.d.ts +8 -0
- package/dist/src/services/emailBe/html/index.d.ts +2 -0
- package/dist/src/services/emailBe/http/HttpManager.d.ts +13 -0
- package/dist/src/services/emailBe/http/RetryStack.d.ts +6 -0
- package/dist/src/services/emailBe/http/client.d.ts +3 -0
- package/dist/src/services/emailBe/http/index.d.ts +2 -0
- package/dist/src/services/emailBe/http/transportErrors.d.ts +15 -0
- package/dist/src/services/emailBe/http/types.d.ts +46 -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, record as g, fallback as R, literal as u, looseObject as C, variant as
|
|
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()),
|
|
@@ -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,
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
const b = r({
|
|
3
|
+
code: e(),
|
|
4
|
+
trans: r({
|
|
5
|
+
key: e(),
|
|
6
|
+
// PHP serializes an empty associative array as `[]`, so an empty list means "no placeholders".
|
|
7
|
+
replace: t([
|
|
8
|
+
h(e(), t([e(), a()])),
|
|
9
|
+
o(p([]), u(() => ({})))
|
|
10
|
+
])
|
|
11
|
+
}),
|
|
12
|
+
// Not rendered yet, so drift here must not block Save.
|
|
13
|
+
anchor: m(d(r({
|
|
14
|
+
selector: e(),
|
|
15
|
+
indexes: l(a())
|
|
16
|
+
})), null),
|
|
17
|
+
details: l(e())
|
|
18
|
+
}), k = o(
|
|
19
|
+
r({
|
|
20
|
+
valid: s(),
|
|
21
|
+
errors: l(b)
|
|
22
|
+
}),
|
|
23
|
+
i(({ valid: n, errors: c }) => n === !c.length, "valid must match the error list")
|
|
24
|
+
);
|
|
25
|
+
export {
|
|
26
|
+
b as HtmlValidationErrorSchema,
|
|
27
|
+
k as HtmlValidationResultSchema
|
|
28
|
+
};
|
|
@@ -16,40 +16,40 @@ import { useHtmlValidator as tt } from "./useHtmlValidator.js";
|
|
|
16
16
|
import { useToaster as et } from "./useToaster.js";
|
|
17
17
|
import { useCouponBlockValidator as ot } from "./validators/useCouponBlockValidator.js";
|
|
18
18
|
import { useHtmlDocumentCountValidator as it } from "./validators/useHtmlDocumentCountValidator.js";
|
|
19
|
-
import { useLiquidValidator as
|
|
20
|
-
import { useSyncModuleBlockValidator as
|
|
19
|
+
import { useLiquidValidator as rt } from "./validators/useLiquidValidator.js";
|
|
20
|
+
import { useSyncModuleBlockValidator as st } from "./validators/useSyncModuleBlockValidator.js";
|
|
21
21
|
import { useUnsubscribeBlockValidator as at } from "./validators/useUnsubscribeBlockValidator.js";
|
|
22
22
|
const Pt = () => {
|
|
23
|
-
const n = I(), S = N(), { validateHtml: y } = tt(), { validateLiquidSyntax: b } =
|
|
23
|
+
const n = I(), S = N(), { validateHtml: y } = tt(), { validateLiquidSyntax: b } = rt(), { validateCouponBlockTags: H } = ot(), {
|
|
24
24
|
validateUnsubscribeBlockUniqueness: E,
|
|
25
25
|
validateUnsubscribeBlockHasTemplate: g,
|
|
26
26
|
validateNoInsiderUnsubscribeCode: V
|
|
27
|
-
} = at(), { validateSyncModuleBlocks: l } =
|
|
27
|
+
} = at(), { validateSyncModuleBlocks: l } = st(), { validateSingleHtmlDocument: c } = it(), { callbacks: a, isFeatureEnabled: u } = D(), { extractSyncModuleData: x } = G(), { setSyncModuleUnsubscriptionPages: k } = K(), { editorSave: C, getTemplateData: m } = O(), { showToaster: h } = et(), { getBlockedDomains: B, resolveToast: T } = $(), { prepareTemplateDetails: p } = Z(), { collectSaveValidationErrors: L } = j(), { isEnabled: P } = z(), U = Y(), A = X(), w = Q(), { runExclusive: d } = F(), f = async (t, e, i) => {
|
|
28
28
|
if (!u("allowlistEnabled"))
|
|
29
29
|
return !1;
|
|
30
30
|
const o = await B(t, e);
|
|
31
31
|
if (!o.length)
|
|
32
32
|
return !1;
|
|
33
33
|
if (!i) {
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const r = await T(o);
|
|
35
|
+
r != null && r.message && h({
|
|
36
36
|
type: J.Warning,
|
|
37
|
-
message:
|
|
38
|
-
actionButton:
|
|
37
|
+
message: r.message,
|
|
38
|
+
actionButton: r.actionButton
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
return !0;
|
|
42
42
|
}, M = async (t, e) => !H(t.compiledHtml) || u("blockUnsubscribeLinks") && !V(t.rawHtml, e) || !E(t.compiledHtml) || !g(t.compiledHtml) ? !1 : u("liquidSyntax") ? b(t.compiledHtml) : y(t.compiledHtml, t.dynamicContentList, !0), v = async (t, e) => {
|
|
43
43
|
if (!await C())
|
|
44
44
|
return;
|
|
45
|
-
const { unsubscribePayload: o, stripoModules:
|
|
46
|
-
if (await k(o), t.modules =
|
|
47
|
-
const
|
|
48
|
-
S({ ...t, ...
|
|
45
|
+
const { unsubscribePayload: o, stripoModules: r } = x(t.rawHtml);
|
|
46
|
+
if (await k(o), t.modules = r, !e.suppress) {
|
|
47
|
+
const s = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
|
|
48
|
+
S({ ...t, ...s, silent: e.silent });
|
|
49
49
|
}
|
|
50
50
|
return t;
|
|
51
51
|
}, W = async (t, e) => {
|
|
52
|
-
var
|
|
52
|
+
var r;
|
|
53
53
|
n();
|
|
54
54
|
const i = await m();
|
|
55
55
|
if (!c(i.html, e))
|
|
@@ -57,18 +57,20 @@ const Pt = () => {
|
|
|
57
57
|
const o = await p(i);
|
|
58
58
|
if (l(o.rawHtml, e)) {
|
|
59
59
|
if (P.value && !e) {
|
|
60
|
-
const
|
|
60
|
+
const s = await L(
|
|
61
61
|
o.compiledHtml,
|
|
62
62
|
o.dynamicContentList,
|
|
63
63
|
o.rawHtml
|
|
64
64
|
);
|
|
65
|
-
if (
|
|
66
|
-
|
|
65
|
+
if (!s)
|
|
66
|
+
return;
|
|
67
|
+
if (s.length) {
|
|
68
|
+
U.open(s, "save");
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
69
71
|
} else if (!await M(o, e))
|
|
70
72
|
return;
|
|
71
|
-
if (!((
|
|
73
|
+
if (!((r = a.value) != null && r.externalValidation && !await a.value.externalValidation(o)) && !await f(o.compiledHtml, o.css, e))
|
|
72
74
|
return v(o, { silent: e, suppress: t });
|
|
73
75
|
}
|
|
74
76
|
}, R = async () => {
|
|
@@ -1,289 +1,171 @@
|
|
|
1
|
-
import { getIgnoredRecommendationBlockIds as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { useTranslations as
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return le(t).map((i) => ({
|
|
27
|
-
rule: o.CouponTagModified,
|
|
28
|
-
type: r.Warning,
|
|
29
|
-
key: ue,
|
|
30
|
-
detail: i
|
|
31
|
-
}));
|
|
1
|
+
import { getIgnoredRecommendationBlockIds as A } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
2
|
+
import { HtmlSyntax as I } from "../enums/email-be.js";
|
|
3
|
+
import { CONDITION_TAG_REGEX as B, DISPLAY_CONDITIONS_REGEX as U } from "../enums/html-validator.js";
|
|
4
|
+
import { SaveValidationRule as m } from "../enums/save-validation.js";
|
|
5
|
+
import { ToasterTypeOptions as l } from "../enums/toaster.js";
|
|
6
|
+
import { BLOCK_ROOT_SELECTOR as h } from "../extensions/Blocks/Checkbox/constants/selectors.js";
|
|
7
|
+
import { itemsBlockDynamicVariables as w } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
8
|
+
import { BLOCK_ROOT_SELECTOR as K } from "../extensions/Blocks/RadioButton/constants/selectors.js";
|
|
9
|
+
import { useRecommendationExtensionStore as G } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
10
|
+
import { getInvalidFields as x, STRATEGY_FIELD_KEY as M, RecommendationAssignStrategyKey as Y, RecommendationRequiredFieldsKey as H } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
11
|
+
import { htmlValidationService as P } from "../services/emailBe/html/index.js";
|
|
12
|
+
import { useConfigStore as q } from "../stores/config.js";
|
|
13
|
+
import { useDynamicContentStore as V } from "../stores/dynamic-content.js";
|
|
14
|
+
import { useRecommendationStore as X } from "../stores/recommendation.js";
|
|
15
|
+
import { escapeHtml as O } from "../utils/htmlEscape.js";
|
|
16
|
+
import { useTemplatePreparation as W } from "../utils/templatePreparation.js";
|
|
17
|
+
import { useActionsApi as j } from "./useActionsApi.js";
|
|
18
|
+
import { useConfig as z } from "./useConfig.js";
|
|
19
|
+
import { useHtmlCompiler as $ } from "./useHtmlCompiler.js";
|
|
20
|
+
import { buildPartnerAttributeNameSet as Q, getInvalidDynamicContentTags as Z, getRecommendationBlockIds as J, findInvalidCustomFields as tt } from "./useHtmlValidator.js";
|
|
21
|
+
import { useTranslations as et } from "./useTranslations.js";
|
|
22
|
+
import { hasInsiderUnsubscribeCode as nt, EXTERNALLY_MANAGED_UNSUBSCRIBE_KEY as it } from "./validators/useUnsubscribeBlockValidator.js";
|
|
23
|
+
const E = "custom-fields.invalid-custom-fields", ot = "custom-conditions.missing-if-endif-tag", rt = "newsletter.fill-all-necessary-fields", st = "unsubscribe-templates.select-checkbox-groups", at = "unsubscribe-templates.select-radio-button-groups", ct = /({%(.*?)%})/g, mt = ["unsubscribe-page-not-selected"], lt = ["malformed-merge-tag"], dt = "liquid-syntax-error", ut = ["if", "endif", "else", "elif", "now"], ft = (t) => !ut.includes(t.toLowerCase()), pt = (t) => ["if", "endif"].includes(t.toLowerCase());
|
|
24
|
+
function gt({ code: t, details: n }) {
|
|
25
|
+
return mt.includes(t) ? "" : (t === dt ? n.slice(1) : n).join(", ");
|
|
32
26
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
function Et(t) {
|
|
28
|
+
const n = gt(t);
|
|
29
|
+
return {
|
|
30
|
+
rule: m.EmailBeHtml,
|
|
31
|
+
type: l.Error,
|
|
32
|
+
key: t.trans.key,
|
|
33
|
+
params: t.trans.replace,
|
|
34
|
+
...n ? { detail: n } : {}
|
|
35
|
+
};
|
|
39
36
|
}
|
|
40
|
-
function
|
|
41
|
-
return
|
|
42
|
-
rule:
|
|
43
|
-
type:
|
|
44
|
-
key:
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
function we(t) {
|
|
48
|
-
return me(t) ? [{
|
|
49
|
-
rule: o.ExternallyManagedUnsubscribe,
|
|
50
|
-
type: r.Warning,
|
|
51
|
-
key: de
|
|
37
|
+
function yt(t) {
|
|
38
|
+
return nt(t) ? [{
|
|
39
|
+
rule: m.ExternallyManagedUnsubscribe,
|
|
40
|
+
type: l.Warning,
|
|
41
|
+
key: it
|
|
52
42
|
}] : [];
|
|
53
43
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
44
|
+
function St(t, n) {
|
|
45
|
+
const r = t.match(ct);
|
|
46
|
+
if (!r)
|
|
57
47
|
return [];
|
|
58
|
-
const
|
|
59
|
-
return
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
const [
|
|
63
|
-
|
|
64
|
-
rule:
|
|
65
|
-
type:
|
|
66
|
-
key:
|
|
67
|
-
detail:
|
|
48
|
+
const s = [];
|
|
49
|
+
return r.forEach((o) => {
|
|
50
|
+
const d = o.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
51
|
+
if (d && d.length > 0) {
|
|
52
|
+
const [u] = d;
|
|
53
|
+
ft(u) && !n.includes(u) && s.push({
|
|
54
|
+
rule: m.CustomFieldScript,
|
|
55
|
+
type: l.Warning,
|
|
56
|
+
key: E,
|
|
57
|
+
detail: u
|
|
68
58
|
});
|
|
69
59
|
}
|
|
70
|
-
}),
|
|
71
|
-
}
|
|
72
|
-
function Ue(t) {
|
|
73
|
-
return t.length > 0 ? [] : [{ rule: o.EmptyHtml, type: r.Warning, key: ye }];
|
|
60
|
+
}), s;
|
|
74
61
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}] : i < n ? [{
|
|
82
|
-
rule: o.MismatchedBraces,
|
|
83
|
-
type: r.Warning,
|
|
84
|
-
key: Ie
|
|
85
|
-
}] : [];
|
|
86
|
-
}
|
|
87
|
-
function xe(t) {
|
|
88
|
-
return oe(t).map((i) => ({
|
|
89
|
-
rule: o.InvalidDynamicTag,
|
|
90
|
-
type: r.Warning,
|
|
91
|
-
key: S,
|
|
92
|
-
detail: i
|
|
62
|
+
function Ct(t) {
|
|
63
|
+
return Z(t).map((n) => ({
|
|
64
|
+
rule: m.InvalidDynamicTag,
|
|
65
|
+
type: l.Warning,
|
|
66
|
+
key: E,
|
|
67
|
+
detail: n
|
|
93
68
|
}));
|
|
94
69
|
}
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
return
|
|
98
|
-
rule:
|
|
99
|
-
type:
|
|
100
|
-
key:
|
|
101
|
-
detail:
|
|
70
|
+
function It(t, n, r, s) {
|
|
71
|
+
const o = J(t);
|
|
72
|
+
return tt(t, n, o, r, s).map((d) => ({
|
|
73
|
+
rule: m.InvalidCustomField,
|
|
74
|
+
type: l.Error,
|
|
75
|
+
key: E,
|
|
76
|
+
detail: d
|
|
102
77
|
}));
|
|
103
78
|
}
|
|
104
|
-
function
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const c = m.match(M), d = m.match(x), I = (c == null ? void 0 : c.join("")) || "";
|
|
108
|
-
(!c || m !== I) && !d && u.push({
|
|
109
|
-
rule: o.ConditionsSyntax,
|
|
110
|
-
type: r.Error,
|
|
111
|
-
key: Se,
|
|
112
|
-
detail: m
|
|
113
|
-
}), c && c.forEach((g) => {
|
|
114
|
-
g.trim() === "=" && u.push({
|
|
115
|
-
rule: o.WrongEqualityOperator,
|
|
116
|
-
type: r.Error,
|
|
117
|
-
key: _e
|
|
118
|
-
}), (g.match(/^[a-zA-Z]*$/g) ?? []).forEach((f) => {
|
|
119
|
-
De(f) && n.push(f);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
}), n.length) {
|
|
123
|
-
const m = n.filter((d) => d === "if").length, c = n.filter((d) => d === "endif").length;
|
|
124
|
-
m !== c && u.push({
|
|
125
|
-
rule: o.MissingIfEndif,
|
|
126
|
-
type: r.Error,
|
|
127
|
-
key: Ce
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return u;
|
|
79
|
+
function _t(t) {
|
|
80
|
+
const n = (t.match(B) ?? []).flatMap((o) => o.match(U) ?? []).flatMap((o) => o.match(/^[a-zA-Z]*$/g) ?? []).filter(pt), r = n.filter((o) => o === "if").length, s = n.filter((o) => o === "endif").length;
|
|
81
|
+
return r === s ? [] : [{ rule: m.MissingIfEndif, type: l.Error, key: ot }];
|
|
131
82
|
}
|
|
132
|
-
function
|
|
133
|
-
const
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}];
|
|
83
|
+
function _(t, n, r, s) {
|
|
84
|
+
const o = new DOMParser().parseFromString(t, "text/html");
|
|
85
|
+
return Array.from(o.querySelectorAll(n)).filter((d) => {
|
|
86
|
+
var u;
|
|
87
|
+
return !((u = d.id) != null && u.trim());
|
|
88
|
+
}).map(() => ({ rule: r, type: l.Error, key: s }));
|
|
139
89
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
rule: o.BracesInsideIfTag,
|
|
143
|
-
type: r.Warning,
|
|
144
|
-
key: ke
|
|
145
|
-
}];
|
|
146
|
-
}
|
|
147
|
-
function He(t) {
|
|
148
|
-
return (t.match(Oe) ?? []).map((i) => ({
|
|
149
|
-
rule: o.InvalidImageType,
|
|
150
|
-
type: r.Error,
|
|
151
|
-
key: Fe,
|
|
152
|
-
detail: i
|
|
153
|
-
}));
|
|
154
|
-
}
|
|
155
|
-
function R(t, i, n, u) {
|
|
156
|
-
const m = new DOMParser().parseFromString(t, "text/html");
|
|
157
|
-
return Array.from(m.querySelectorAll(i)).filter((c) => {
|
|
158
|
-
var d;
|
|
159
|
-
return !((d = c.id) != null && d.trim());
|
|
160
|
-
}).map(() => ({ rule: n, type: r.Error, key: u }));
|
|
161
|
-
}
|
|
162
|
-
const yt = () => {
|
|
163
|
-
const { config: t, isFeatureEnabled: i } = te(), n = ce(), { post: u } = ae(), { getCompiledEmail: m, getTemplateData: c } = ee(), { compileHtml: d } = ne(), { hydrateRecommendationStore: I } = J(), g = $(), f = Q(), y = q(), O = z(), L = (e) => ({
|
|
90
|
+
const Ot = (t) => t && Object.fromEntries(Object.entries(t).map(([n, r]) => [n, O(String(r))])), Xt = () => {
|
|
91
|
+
const { config: t, isFeatureEnabled: n } = z(), r = et(), { getCompiledEmail: s, getTemplateData: o } = j(), { compileHtml: d } = $(), { hydrateRecommendationStore: u } = W(), b = V(), F = X(), p = G(), R = q(), D = (e) => ({
|
|
164
92
|
rule: e.rule,
|
|
165
93
|
type: e.type,
|
|
166
94
|
detail: e.detail,
|
|
167
|
-
message: "key" in e ?
|
|
168
|
-
}),
|
|
95
|
+
message: "key" in e ? r(e.key, Ot(e.params)) : O(e.message)
|
|
96
|
+
}), T = async (e) => {
|
|
169
97
|
if (e.size === 0)
|
|
170
98
|
return /* @__PURE__ */ new Set();
|
|
171
99
|
try {
|
|
172
|
-
await
|
|
100
|
+
await p.fetchRecommendationFilters();
|
|
173
101
|
} catch {
|
|
174
102
|
return null;
|
|
175
103
|
}
|
|
176
|
-
return
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
type: r.Error,
|
|
187
|
-
key: k
|
|
188
|
-
}), p;
|
|
189
|
-
} catch (a) {
|
|
190
|
-
return console.warn("Link-check collector failed; skipping the link rule.", a), [];
|
|
191
|
-
}
|
|
192
|
-
}, v = async (e) => {
|
|
193
|
-
try {
|
|
194
|
-
const a = await u("/newsletter/contents/validate-syntax", [{
|
|
195
|
-
identifier: "default",
|
|
196
|
-
syntax: "liquid",
|
|
197
|
-
contents: {
|
|
198
|
-
subject: null,
|
|
199
|
-
preheader: null,
|
|
200
|
-
html: T(e),
|
|
201
|
-
ampHtml: null
|
|
202
|
-
}
|
|
203
|
-
}]);
|
|
204
|
-
if (!Array.isArray(a.data)) {
|
|
205
|
-
const l = a.data;
|
|
206
|
-
return [{
|
|
207
|
-
rule: o.LiquidSyntax,
|
|
208
|
-
type: r.Warning,
|
|
209
|
-
message: l.message ?? n(b)
|
|
210
|
-
}];
|
|
211
|
-
}
|
|
212
|
-
const [s] = a.data;
|
|
213
|
-
return Object.values((s == null ? void 0 : s.errors) ?? {}).map((l) => ({
|
|
214
|
-
rule: o.LiquidSyntax,
|
|
215
|
-
type: r.Warning,
|
|
216
|
-
message: l.replace(/^line \d+:\s*/, "")
|
|
217
|
-
}));
|
|
218
|
-
} catch (a) {
|
|
219
|
-
if (a != null && a.authReported)
|
|
220
|
-
throw a;
|
|
221
|
-
return [{
|
|
222
|
-
rule: o.LiquidSyntax,
|
|
223
|
-
type: r.Error,
|
|
224
|
-
message: n(b)
|
|
225
|
-
}];
|
|
226
|
-
}
|
|
227
|
-
}, K = () => {
|
|
228
|
-
const e = Object.values(y.blockStates).map((s) => H(s.recommendationConfigs, y)).filter((s) => s.length > 0).map((s) => {
|
|
229
|
-
const l = s.every((p) => p === V);
|
|
104
|
+
return Q(p.filterList);
|
|
105
|
+
}, k = async (e) => {
|
|
106
|
+
const a = await P.validate({
|
|
107
|
+
html: e,
|
|
108
|
+
syntax: n("liquidSyntax") ? I.LIQUID : I.PONGO
|
|
109
|
+
});
|
|
110
|
+
return a.ok ? a.data.errors.filter((i) => !lt.includes(i.code)).map(Et) : null;
|
|
111
|
+
}, N = () => {
|
|
112
|
+
const e = Object.values(p.blockStates).map((i) => x(i.recommendationConfigs, p)).filter((i) => i.length > 0).map((i) => {
|
|
113
|
+
const c = i.every((f) => f === M);
|
|
230
114
|
return {
|
|
231
|
-
rule:
|
|
232
|
-
type:
|
|
233
|
-
key:
|
|
115
|
+
rule: m.RecommendationRequiredFields,
|
|
116
|
+
type: c ? l.Warning : l.Error,
|
|
117
|
+
key: c ? Y : H
|
|
234
118
|
};
|
|
235
|
-
}), a = (
|
|
236
|
-
rule:
|
|
237
|
-
type:
|
|
238
|
-
key:
|
|
119
|
+
}), a = (F.recommendationConfigs ?? []).filter((i) => i.filters.some((c) => c.value === "")).map(() => ({
|
|
120
|
+
rule: m.RecommendationFilters,
|
|
121
|
+
type: l.Error,
|
|
122
|
+
key: rt
|
|
239
123
|
}));
|
|
240
124
|
return [...e, ...a];
|
|
241
|
-
},
|
|
242
|
-
var
|
|
243
|
-
const
|
|
244
|
-
...a.map((
|
|
245
|
-
...
|
|
246
|
-
...((
|
|
247
|
-
],
|
|
125
|
+
}, v = async (e, a) => {
|
|
126
|
+
var S, C;
|
|
127
|
+
const i = [
|
|
128
|
+
...a.map((L) => L.value),
|
|
129
|
+
...w,
|
|
130
|
+
...((C = (S = t.value) == null ? void 0 : S.template) == null ? void 0 : C.customFieldAttributes) ?? []
|
|
131
|
+
], c = A(e), f = await T(c), { isTransactional: g } = R;
|
|
248
132
|
return [
|
|
249
|
-
...
|
|
250
|
-
...
|
|
251
|
-
...
|
|
252
|
-
...
|
|
253
|
-
...
|
|
254
|
-
...
|
|
255
|
-
...We(e),
|
|
256
|
-
...Pe(e),
|
|
257
|
-
...qe(e),
|
|
258
|
-
...K(),
|
|
259
|
-
...He(e),
|
|
260
|
-
...R(
|
|
133
|
+
...g ? [] : St(e, i),
|
|
134
|
+
...Ct(e),
|
|
135
|
+
...g ? [] : It(e, i, c, f),
|
|
136
|
+
..._t(e),
|
|
137
|
+
...N(),
|
|
138
|
+
..._(
|
|
261
139
|
e,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
140
|
+
h,
|
|
141
|
+
m.CheckboxUnsubGroup,
|
|
142
|
+
st
|
|
265
143
|
),
|
|
266
|
-
...
|
|
144
|
+
..._(
|
|
267
145
|
e,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
146
|
+
K,
|
|
147
|
+
m.RadioButtonUnsubGroup,
|
|
148
|
+
at
|
|
271
149
|
)
|
|
272
150
|
];
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
151
|
+
}, y = async (e, a, i) => {
|
|
152
|
+
const [c, f] = await Promise.all([
|
|
153
|
+
k(e),
|
|
154
|
+
n("liquidSyntax") ? [] : v(e, a)
|
|
155
|
+
]);
|
|
156
|
+
return c ? [
|
|
157
|
+
...c,
|
|
158
|
+
...n("blockUnsubscribeLinks") ? yt(i) : [],
|
|
159
|
+
...f
|
|
160
|
+
].map(D) : null;
|
|
161
|
+
};
|
|
162
|
+
return { collectSaveValidationErrors: y, validateCurrentTemplate: async () => {
|
|
163
|
+
const { html: e } = await o();
|
|
164
|
+
await u(e);
|
|
165
|
+
const { html: a } = await s({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: i } = d(a);
|
|
166
|
+
return y(i, b.getSelectedDynamicContentList, e);
|
|
285
167
|
} };
|
|
286
168
|
};
|
|
287
169
|
export {
|
|
288
|
-
|
|
170
|
+
Xt as useSaveValidation
|
|
289
171
|
};
|
|
@@ -4,15 +4,20 @@ import memoize from "../node_modules/lodash-es/memoize.js";
|
|
|
4
4
|
import { ref } from "vue";
|
|
5
5
|
import { useConfig } from "./useConfig.js";
|
|
6
6
|
const useTranslations = () => {
|
|
7
|
-
var
|
|
8
|
-
const { config } = useConfig(), translationsPath = ((
|
|
9
|
-
var
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
var s, i;
|
|
8
|
+
const { config } = useConfig(), translationsPath = ((i = (s = config.value) == null ? void 0 : s.editor) == null ? void 0 : i.translationsPath) || DEFAULT_EDITOR.translationsPath, translations = ref(eval(translationsPath)), trans = (t, n) => {
|
|
9
|
+
var a;
|
|
10
|
+
const o = (a = translations.value) == null ? void 0 : a[t];
|
|
11
|
+
if (!o)
|
|
12
|
+
return console.warn(`Translation key not found: ${t}`), t;
|
|
13
|
+
const r = Object.keys(n ?? {}).filter(Boolean).map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
14
|
+
if (n && r.length) {
|
|
15
|
+
const e = new RegExp(`{(${r.join("|")})}|:(${r.join("|")})\\b`, "g");
|
|
16
|
+
return o.replace(e, (f, l, c) => String(
|
|
17
|
+
n[l ?? c]
|
|
18
|
+
));
|
|
19
|
+
}
|
|
20
|
+
return o;
|
|
16
21
|
};
|
|
17
22
|
return memoize(
|
|
18
23
|
trans,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const E = "/email-proxy", e = {
|
|
2
|
+
HTML_VALIDATE: "/v1/html/validate"
|
|
3
|
+
}, n = {
|
|
4
|
+
BAD_GATEWAY: "bad_gateway",
|
|
5
|
+
BAD_REQUEST: "bad_request",
|
|
6
|
+
CONFLICT: "conflict",
|
|
7
|
+
FORBIDDEN: "forbidden",
|
|
8
|
+
INTERNAL_ERROR: "internal_error",
|
|
9
|
+
NOT_FOUND: "not_found",
|
|
10
|
+
RATE_LIMITED: "rate_limited",
|
|
11
|
+
UNAUTHENTICATED: "unauthenticated",
|
|
12
|
+
VALIDATION_FAILED: "validation_failed",
|
|
13
|
+
SESSION_EXPIRED: "session_expired",
|
|
14
|
+
INVALID_RESPONSE: "invalid_response",
|
|
15
|
+
NETWORK: "network_error",
|
|
16
|
+
TIMEOUT: "timeout",
|
|
17
|
+
UNKNOWN: "unknown"
|
|
18
|
+
}, t = {
|
|
19
|
+
PONGO: "pongo",
|
|
20
|
+
LIQUID: "liquid"
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
E as EMAIL_BE_BASE_URL,
|
|
24
|
+
e as EmailBeEndPoints,
|
|
25
|
+
n as EmailBeErrorCodes,
|
|
26
|
+
t as HtmlSyntax
|
|
27
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var r = /* @__PURE__ */ ((n) => (n.CustomFieldScript = "custom-field-script", n.InvalidDynamicTag = "invalid-dynamic-tag", n.InvalidCustomField = "invalid-custom-field", n.MissingIfEndif = "missing-if-endif", n.RecommendationRequiredFields = "recommendation-required-fields", n.RecommendationFilters = "recommendation-filters", n.CheckboxUnsubGroup = "checkbox-unsub-group", n.RadioButtonUnsubGroup = "radio-button-unsub-group", n.ExternallyManagedUnsubscribe = "externally-managed-unsubscribe", n.EmailBeHtml = "email-be-html", n))(r || {});
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
r as SaveValidationRule
|
|
4
4
|
};
|