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