@useinsider/guido 3.7.0-beta.a6317a3 → 3.7.0-beta.a8c44c1
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.
|
@@ -1,172 +1,172 @@
|
|
|
1
1
|
import { useConfig as V } from "./useConfig.js";
|
|
2
|
-
import { TemplateTypes as
|
|
3
|
-
import { DISPLAY_CONDITIONS_REGEX as
|
|
2
|
+
import { TemplateTypes as G } from "../enums/defaults.js";
|
|
3
|
+
import { DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as M, CampaignCouldNotBeSavedKey as X, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as K } from "../enums/html-validator.js";
|
|
4
4
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
5
|
-
import { itemsBlockDynamicVariables as
|
|
6
|
-
import { useRecommendationExtensionStore as
|
|
5
|
+
import { itemsBlockDynamicVariables as j } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { useRecommendationExtensionStore as U } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
7
7
|
import { RecommendationRequiredFieldsKey as z } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
8
|
-
import { useRecommendationStore as
|
|
9
|
-
import { base64EncodeWithSpecialChars as
|
|
10
|
-
import { useHttp as
|
|
11
|
-
import { useToaster as
|
|
12
|
-
import { useTranslations as
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
return [...
|
|
8
|
+
import { useRecommendationStore as Z } from "../stores/recommendation.js";
|
|
9
|
+
import { base64EncodeWithSpecialChars as J } from "../utils/base64.js";
|
|
10
|
+
import { useHttp as Q } from "./useHttp.js";
|
|
11
|
+
import { useToaster as ee } from "./useToaster.js";
|
|
12
|
+
import { useTranslations as te } from "./useTranslations.js";
|
|
13
|
+
const se = /recommendation-id="(\d+)"/g;
|
|
14
|
+
function ne(i) {
|
|
15
|
+
return [...i.matchAll(se)].map((d) => d[1]);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return d.some((
|
|
17
|
+
function ie(i, d) {
|
|
18
|
+
return d.some((g) => i.startsWith(`${g}_`));
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return (
|
|
22
|
-
const
|
|
23
|
-
return
|
|
20
|
+
function oe(i) {
|
|
21
|
+
return (i.replace(Y, "$1").match($) ?? []).filter((r) => {
|
|
22
|
+
const u = r.slice(2, -2), f = u.indexOf("|"), p = (f === -1 ? u : u.slice(0, f)).trim();
|
|
23
|
+
return q.includes(p) ? !1 : K.test(p) ? f !== -1 && u.slice(f + 1).trim() === "" : !0;
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const Ce = () => {
|
|
27
27
|
var h, v;
|
|
28
|
-
const { showToaster:
|
|
28
|
+
const { showToaster: i } = ee(), { post: d } = Q(), { config: g } = V(), r = te(), u = Z(), f = U(), p = ((v = (h = g.value) == null ? void 0 : h.partner) == null ? void 0 : v.messageType) === G.transactional, A = async (e) => {
|
|
29
29
|
const t = await d(
|
|
30
30
|
"/newsletter/template-library/check-template-html-body",
|
|
31
|
-
{ html:
|
|
31
|
+
{ html: J(e) }
|
|
32
32
|
), { status: n, message: l } = t.data;
|
|
33
|
-
return n ||
|
|
33
|
+
return n || i({
|
|
34
34
|
type: c.Alert,
|
|
35
|
-
message: n === void 0 ? l :
|
|
36
|
-
}),
|
|
35
|
+
message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
|
|
36
|
+
}), r(X), l === r(P) && i({
|
|
37
37
|
type: c.Alert,
|
|
38
|
-
message:
|
|
38
|
+
message: r("newsletter.already-in-progress")
|
|
39
39
|
}), n;
|
|
40
40
|
}, S = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), b = (e) => ["if", "endif"].includes(e.toLowerCase()), I = (e, s) => {
|
|
41
41
|
const t = e.match(/({%(.*?)%})/g);
|
|
42
42
|
let n = !0;
|
|
43
|
-
return t !== null && !
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
const [
|
|
47
|
-
S(
|
|
43
|
+
return t !== null && !p && t.forEach((l) => {
|
|
44
|
+
const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
45
|
+
if (o && o.length > 0) {
|
|
46
|
+
const [a] = o;
|
|
47
|
+
S(a) && !s.includes(a) && (i({
|
|
48
48
|
type: c.Warning,
|
|
49
|
-
message:
|
|
49
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
50
50
|
}), n = !1);
|
|
51
51
|
}
|
|
52
52
|
}), n;
|
|
53
|
-
},
|
|
53
|
+
}, T = async (e, s, t) => {
|
|
54
54
|
const n = t ? await A(e) : !0;
|
|
55
55
|
return I(e, s) && n;
|
|
56
|
-
},
|
|
56
|
+
}, w = (e) => e.length > 0 ? !0 : (i({
|
|
57
57
|
type: c.Warning,
|
|
58
|
-
message:
|
|
59
|
-
}), !1),
|
|
58
|
+
message: r("newsletter.html-content-is-empty")
|
|
59
|
+
}), !1), x = (e) => {
|
|
60
60
|
const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
|
|
61
|
-
return s > t &&
|
|
61
|
+
return s > t && i({
|
|
62
62
|
type: c.Warning,
|
|
63
|
-
message:
|
|
64
|
-
}), s < t &&
|
|
63
|
+
message: r("custom-fields.missing-closing-braces")
|
|
64
|
+
}), s < t && i({
|
|
65
65
|
type: c.Warning,
|
|
66
|
-
message:
|
|
66
|
+
message: r("custom-fields.missing-opening-braces")
|
|
67
67
|
}), s === t;
|
|
68
|
-
},
|
|
69
|
-
const s =
|
|
70
|
-
return s ||
|
|
68
|
+
}, _ = (e) => {
|
|
69
|
+
const s = oe(e).length === 0;
|
|
70
|
+
return s || i({
|
|
71
71
|
type: c.Warning,
|
|
72
|
-
message:
|
|
72
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
73
73
|
}), s;
|
|
74
|
-
},
|
|
74
|
+
}, k = (e, s) => {
|
|
75
75
|
const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
|
|
76
|
-
if (t && !
|
|
77
|
-
const n = new Set(s.map((
|
|
78
|
-
if (t.forEach((
|
|
79
|
-
const m =
|
|
80
|
-
(!n.has(m) || m === "") && !
|
|
81
|
-
}),
|
|
82
|
-
const
|
|
76
|
+
if (t && !p) {
|
|
77
|
+
const n = new Set(s.map((a) => a.toLowerCase())), l = ne(e), o = [];
|
|
78
|
+
if (t.forEach((a) => {
|
|
79
|
+
const m = a.slice(2, -2).trim().toLowerCase();
|
|
80
|
+
(!n.has(m) || m === "") && !ie(m, l) && o.push(m);
|
|
81
|
+
}), o.length > 0) {
|
|
82
|
+
const a = `
|
|
83
83
|
<ul>
|
|
84
|
-
${
|
|
84
|
+
${o.map((m) => `<li>${m}</li>`).join("")}
|
|
85
85
|
</ul>
|
|
86
86
|
`;
|
|
87
|
-
return
|
|
87
|
+
return i({
|
|
88
88
|
type: c.Alert,
|
|
89
|
-
message:
|
|
89
|
+
message: r("custom-fields.invalid-custom-fields") + a
|
|
90
90
|
}), !1;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
return !0;
|
|
94
|
-
},
|
|
94
|
+
}, R = (e) => {
|
|
95
95
|
const s = e.match(/{%(.*?)%}/g), t = [];
|
|
96
96
|
let n = !0;
|
|
97
97
|
if (s && s.forEach((l) => {
|
|
98
|
-
const
|
|
99
|
-
(!
|
|
98
|
+
const o = l.match(H), a = l.match(M), m = (o == null ? void 0 : o.join("")) || "";
|
|
99
|
+
(!o || l !== m) && !a && (i({
|
|
100
100
|
type: c.Alert,
|
|
101
|
-
message:
|
|
102
|
-
}), n = !1),
|
|
103
|
-
|
|
101
|
+
message: r("newsletter.display-conditions-invalid-syntax")
|
|
102
|
+
}), n = !1), o && o.forEach((y) => {
|
|
103
|
+
y.trim() === "=" && (i({
|
|
104
104
|
type: c.Alert,
|
|
105
|
-
message:
|
|
105
|
+
message: r("custom-conditions.wrong-equality-operators")
|
|
106
106
|
}), n = !1);
|
|
107
|
-
const C =
|
|
107
|
+
const C = y.match(/^[a-zA-Z]*$/g);
|
|
108
108
|
C && C.forEach((E) => {
|
|
109
109
|
b(E) && t.push(E);
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
}), t.length) {
|
|
113
|
-
const l = t.filter((
|
|
114
|
-
l.length !==
|
|
113
|
+
const l = t.filter((a) => a === "if"), o = t.filter((a) => a === "endif");
|
|
114
|
+
l.length !== o.length && (i({
|
|
115
115
|
type: c.Alert,
|
|
116
|
-
message:
|
|
116
|
+
message: r("custom-conditions.missing-if-endif-tag")
|
|
117
117
|
}), n = !1);
|
|
118
118
|
}
|
|
119
119
|
return n;
|
|
120
|
-
},
|
|
120
|
+
}, N = (e) => {
|
|
121
121
|
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
|
|
122
|
-
return n ||
|
|
122
|
+
return n || i({
|
|
123
123
|
type: c.Warning,
|
|
124
|
-
message:
|
|
124
|
+
message: r("custom-conditions.no-space-after-braces")
|
|
125
125
|
}), n;
|
|
126
|
-
}, D = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (
|
|
126
|
+
}, D = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (i({
|
|
127
127
|
type: c.Warning,
|
|
128
|
-
message:
|
|
129
|
-
}), !1) : !0, F = () =>
|
|
128
|
+
message: r("custom-conditions.no-braces-inside-if-tag")
|
|
129
|
+
}), !1) : !0, F = () => f.hasInvalidBlock() ? (i({
|
|
130
130
|
type: c.Alert,
|
|
131
|
-
message:
|
|
132
|
-
}), !1) : !0, O = () => u.recommendationConfigs && Object.values(u.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (
|
|
131
|
+
message: r(z)
|
|
132
|
+
}), !1) : !0, O = () => u.recommendationConfigs && Object.values(u.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (i({
|
|
133
133
|
type: c.Alert,
|
|
134
|
-
message:
|
|
134
|
+
message: r("newsletter.fill-all-necessary-fields")
|
|
135
135
|
}), !1) : !0, B = (e) => {
|
|
136
136
|
const s = /src="[^"]*\.(svg|pst)"/gm;
|
|
137
|
-
return e.match(s) === null ? !0 : (
|
|
137
|
+
return e.match(s) === null ? !0 : (i({
|
|
138
138
|
type: c.Alert,
|
|
139
|
-
message:
|
|
139
|
+
message: r("newsletter.invalid-image-type")
|
|
140
140
|
}), !1);
|
|
141
141
|
}, L = (e) => {
|
|
142
142
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
|
|
143
|
-
return Array.from(n).find((
|
|
144
|
-
var
|
|
145
|
-
return !((
|
|
146
|
-
}) ? (
|
|
143
|
+
return Array.from(n).find((o) => {
|
|
144
|
+
var a;
|
|
145
|
+
return !((a = o.id) != null && a.trim());
|
|
146
|
+
}) ? (i({
|
|
147
147
|
type: c.Alert,
|
|
148
|
-
message:
|
|
148
|
+
message: r("unsubscribe-templates.select-checkbox-groups")
|
|
149
149
|
}), !1) : !0;
|
|
150
150
|
}, W = (e) => {
|
|
151
151
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
|
|
152
|
-
return Array.from(n).find((
|
|
153
|
-
var
|
|
154
|
-
return !((
|
|
155
|
-
}) ? (
|
|
152
|
+
return Array.from(n).find((o) => {
|
|
153
|
+
var a;
|
|
154
|
+
return !((a = o.id) != null && a.trim());
|
|
155
|
+
}) ? (i({
|
|
156
156
|
type: c.Alert,
|
|
157
|
-
message:
|
|
157
|
+
message: r("unsubscribe-templates.select-radio-button-groups")
|
|
158
158
|
}), !1) : !0;
|
|
159
159
|
};
|
|
160
160
|
return { validateHtml: async (e, s, t = !1) => {
|
|
161
|
-
var
|
|
161
|
+
var o, a;
|
|
162
162
|
const n = [
|
|
163
163
|
...s.map((m) => m.value),
|
|
164
|
-
...
|
|
165
|
-
...((
|
|
164
|
+
...j,
|
|
165
|
+
...((a = (o = g.value) == null ? void 0 : o.template) == null ? void 0 : a.customFieldAttributes) ?? []
|
|
166
166
|
];
|
|
167
|
-
return await
|
|
167
|
+
return await T(e, n, t) && w(e) && x(e) && _(e) && k(e, n) && R(e) && N(e) && D(e) && F() && O() && B(e) && L(e) && W(e);
|
|
168
168
|
} };
|
|
169
169
|
};
|
|
170
170
|
export {
|
|
171
|
-
|
|
171
|
+
Ce as useHtmlValidator
|
|
172
172
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const n = "newsletter.already-in-progress", e = "newsletter.campaign-could-not-be-saved", s = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|([^”\s\n]+)|(({%)|( %}))/gm, o = /{%( )*now( )(".*")( )*%}/gm,
|
|
1
|
+
const n = "newsletter.already-in-progress", e = "newsletter.campaign-could-not-be-saved", s = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|([^”\s\n]+)|(({%)|( %}))/gm, o = /{%( )*now( )(".*")( )*%}/gm, E = /\{\{[^{}]+\}\}/g, i = /(\s)data-[\w-]+=(?:"[^"]*"|'[^']*')/g, t = /^[A-Za-z0-9_.]+$/, _ = [
|
|
2
2
|
"ins-unsubscribe-link",
|
|
3
3
|
"ins-global-unsubscribe-link",
|
|
4
|
-
"ins-preferences-unsubscribe-link"
|
|
5
|
-
"@COUPON_CODE"
|
|
4
|
+
"ins-preferences-unsubscribe-link"
|
|
6
5
|
];
|
|
7
6
|
export {
|
|
8
7
|
_ as ALLOWED_DYNAMIC_SYSTEM_TOKENS,
|
|
9
8
|
e as CampaignCouldNotBeSavedKey,
|
|
10
9
|
n as CanNotMakeAnyChangesForRunningKey,
|
|
10
|
+
i as DATA_ATTRIBUTE_REGEX,
|
|
11
11
|
o as DISPLAY_CONDITIONS_EXCEPTIONS_REGEX,
|
|
12
12
|
s as DISPLAY_CONDITIONS_REGEX,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
E as DYNAMIC_CONTENT_TAG_REGEX,
|
|
14
|
+
t as VALID_DYNAMIC_VARIABLE_REGEX
|
|
15
15
|
};
|
|
@@ -5,5 +5,6 @@ export declare const DISPLAY_CONDITIONS_REGEX: RegExp;
|
|
|
5
5
|
export declare const DISPLAY_CONDITIONS_EXCEPTIONS_REGEX: RegExp;
|
|
6
6
|
export declare const REMOVE_CONDITIONS_REGEX: RegExp;
|
|
7
7
|
export declare const DYNAMIC_CONTENT_TAG_REGEX: RegExp;
|
|
8
|
+
export declare const DATA_ATTRIBUTE_REGEX: RegExp;
|
|
8
9
|
export declare const VALID_DYNAMIC_VARIABLE_REGEX: RegExp;
|
|
9
10
|
export declare const ALLOWED_DYNAMIC_SYSTEM_TOKENS: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.7.0-beta.
|
|
3
|
+
"version": "3.7.0-beta.a8c44c1",
|
|
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",
|