@useinsider/guido 3.27.0 → 3.27.1-beta.389502e
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/composables/useHtmlCompiler.js +16 -13
- package/dist/composables/useHtmlValidator.js +71 -71
- package/dist/composables/useSaveValidation.js +80 -80
- package/dist/config/compiler/pongoCompilerRules.js +13 -0
- package/dist/config/migrator/itemsBlockMigrator.js +220 -178
- package/dist/config/migrator/unsubscribeMigrator.js +112 -100
- package/dist/enums/html-validator.js +8 -7
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +58 -40
- package/dist/extensions/Blocks/Unsubscribe/block.js +104 -96
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +4 -3
- package/dist/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js +5 -0
- package/dist/package.json.js +2 -2
- package/dist/src/config/compiler/pongoCompilerRules.d.ts +2 -0
- package/dist/src/enums/html-validator.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +1 -0
- package/dist/src/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.d.ts +1 -0
- package/dist/static/stripo-runtime-manifest.json.js +2 -2
- package/package.json +2 -2
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
import { getIgnoredRecommendationBlockIds as Y } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
2
|
-
import { CanNotMakeAnyChangesForRunningKey as k,
|
|
2
|
+
import { CanNotMakeAnyChangesForRunningKey as k, CONDITION_TAG_REGEX as U, DISPLAY_CONDITIONS_REGEX as M, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as x } from "../enums/html-validator.js";
|
|
3
3
|
import { SaveValidationRule as o } from "../enums/save-validation.js";
|
|
4
4
|
import { ToasterTypeOptions as r } from "../enums/toaster.js";
|
|
5
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
5
|
+
import { BLOCK_ROOT_SELECTOR as G } from "../extensions/Blocks/Checkbox/constants/selectors.js";
|
|
6
6
|
import { itemsBlockDynamicVariables as W } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
7
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { getInvalidFields as
|
|
10
|
-
import { useConfigStore as
|
|
11
|
-
import { useDynamicContentStore as
|
|
12
|
-
import { useRecommendationStore as
|
|
7
|
+
import { BLOCK_ROOT_SELECTOR as P } from "../extensions/Blocks/RadioButton/constants/selectors.js";
|
|
8
|
+
import { useRecommendationExtensionStore as q } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
|
+
import { getInvalidFields as H, STRATEGY_FIELD_KEY as V, RecommendationAssignStrategyKey as X, RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
10
|
+
import { useConfigStore as z } from "../stores/config.js";
|
|
11
|
+
import { useDynamicContentStore as $ } from "../stores/dynamic-content.js";
|
|
12
|
+
import { useRecommendationStore as Q } from "../stores/recommendation.js";
|
|
13
13
|
import { base64EncodeWithSpecialChars as T } from "../utils/base64.js";
|
|
14
|
-
import { escapeHtml as
|
|
15
|
-
import { useTemplatePreparation as
|
|
16
|
-
import { useActionsApi as
|
|
17
|
-
import { useConfig as
|
|
18
|
-
import { useHtmlCompiler as
|
|
19
|
-
import { buildPartnerAttributeNameSet as
|
|
20
|
-
import { useHttp as
|
|
21
|
-
import { useTranslations as
|
|
22
|
-
import { findInvalidCouponBlocks as
|
|
23
|
-
import { hasInsiderUnsubscribeCode as
|
|
24
|
-
const
|
|
25
|
-
function
|
|
26
|
-
return
|
|
14
|
+
import { escapeHtml as Z } from "../utils/htmlEscape.js";
|
|
15
|
+
import { useTemplatePreparation as J } from "../utils/templatePreparation.js";
|
|
16
|
+
import { useActionsApi as ee } from "./useActionsApi.js";
|
|
17
|
+
import { useConfig as te } from "./useConfig.js";
|
|
18
|
+
import { useHtmlCompiler as ne } from "./useHtmlCompiler.js";
|
|
19
|
+
import { buildPartnerAttributeNameSet as ie, getInvalidDynamicContentTags as oe, getRecommendationBlockIds as re, findInvalidCustomFields as se } from "./useHtmlValidator.js";
|
|
20
|
+
import { useHttp as ae } from "./useHttp.js";
|
|
21
|
+
import { useTranslations as ce } from "./useTranslations.js";
|
|
22
|
+
import { findInvalidCouponBlocks as le, COUPON_TAG_MODIFIED_KEY as ue } from "./validators/useCouponBlockValidator.js";
|
|
23
|
+
import { hasInsiderUnsubscribeCode as me, EXTERNALLY_MANAGED_UNSUBSCRIBE_KEY as de, findDuplicateUnsubPageTypes as pe, countUnsubBlocksWithoutPage as ge, EMPTY_BLOCK_KEY as fe } from "./validators/useUnsubscribeBlockValidator.js";
|
|
24
|
+
const ye = "newsletter.html-content-is-empty", Ee = "custom-fields.missing-closing-braces", Ie = "custom-fields.missing-opening-braces", S = "custom-fields.invalid-custom-fields", Se = "newsletter.display-conditions-invalid-syntax", _e = "custom-conditions.wrong-equality-operators", Ce = "custom-conditions.missing-if-endif-tag", he = "custom-conditions.no-space-after-braces", ke = "custom-conditions.no-braces-inside-if-tag", Te = "newsletter.fill-all-necessary-fields", Fe = "newsletter.invalid-image-type", be = "unsubscribe-templates.select-checkbox-groups", Re = "unsubscribe-templates.select-radio-button-groups", F = "newsletter.invalid-url-link-for-toaster", b = "journey-builder.liquid-validation-failed", Ne = "/newsletter/template-library/check-template-html-body", Oe = /src="[^"]*\.(svg|pst)"/gm, N = /({%(.*?)%})/g, Le = ["if", "endif", "else", "elif", "now"], Ae = (t) => !Le.includes(t.toLowerCase()), De = (t) => ["if", "endif"].includes(t.toLowerCase());
|
|
25
|
+
function ve(t) {
|
|
26
|
+
return le(t).map((i) => ({
|
|
27
27
|
rule: o.CouponTagModified,
|
|
28
28
|
type: r.Warning,
|
|
29
|
-
key:
|
|
29
|
+
key: ue,
|
|
30
30
|
detail: i
|
|
31
31
|
}));
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function Ke(t) {
|
|
34
|
+
return pe(t).map((i) => ({
|
|
35
35
|
rule: o.DuplicateUnsubBlock,
|
|
36
36
|
type: r.Error,
|
|
37
37
|
key: i.messageKey
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
return Array.from({ length:
|
|
40
|
+
function Be(t) {
|
|
41
|
+
return Array.from({ length: ge(t) }, () => ({
|
|
42
42
|
rule: o.UnsubBlockMissingTemplate,
|
|
43
43
|
type: r.Warning,
|
|
44
|
-
key:
|
|
44
|
+
key: fe
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
47
|
+
function we(t) {
|
|
48
|
+
return me(t) ? [{
|
|
49
49
|
rule: o.ExternallyManagedUnsubscribe,
|
|
50
50
|
type: r.Warning,
|
|
51
|
-
key:
|
|
51
|
+
key: de
|
|
52
52
|
}] : [];
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
const n = t.match(
|
|
54
|
+
function Ye(t, i) {
|
|
55
|
+
const n = t.match(N);
|
|
56
56
|
if (!n)
|
|
57
57
|
return [];
|
|
58
58
|
const u = [];
|
|
@@ -60,7 +60,7 @@ function we(t, i) {
|
|
|
60
60
|
const c = m.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
61
61
|
if (c && c.length > 0) {
|
|
62
62
|
const [d] = c;
|
|
63
|
-
|
|
63
|
+
Ae(d) && !i.includes(d) && u.push({
|
|
64
64
|
rule: o.CustomFieldScript,
|
|
65
65
|
type: r.Warning,
|
|
66
66
|
key: S,
|
|
@@ -69,32 +69,32 @@ function we(t, i) {
|
|
|
69
69
|
}
|
|
70
70
|
}), u;
|
|
71
71
|
}
|
|
72
|
-
function Ye(t) {
|
|
73
|
-
return t.length > 0 ? [] : [{ rule: o.EmptyHtml, type: r.Warning, key: fe }];
|
|
74
|
-
}
|
|
75
72
|
function Ue(t) {
|
|
73
|
+
return t.length > 0 ? [] : [{ rule: o.EmptyHtml, type: r.Warning, key: ye }];
|
|
74
|
+
}
|
|
75
|
+
function Me(t) {
|
|
76
76
|
const i = (t.match(/{/gm) || []).length, n = (t.match(/}/gm) || []).length;
|
|
77
77
|
return i > n ? [{
|
|
78
78
|
rule: o.MismatchedBraces,
|
|
79
79
|
type: r.Warning,
|
|
80
|
-
key:
|
|
80
|
+
key: Ee
|
|
81
81
|
}] : i < n ? [{
|
|
82
82
|
rule: o.MismatchedBraces,
|
|
83
83
|
type: r.Warning,
|
|
84
|
-
key:
|
|
84
|
+
key: Ie
|
|
85
85
|
}] : [];
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
return
|
|
87
|
+
function xe(t) {
|
|
88
|
+
return oe(t).map((i) => ({
|
|
89
89
|
rule: o.InvalidDynamicTag,
|
|
90
90
|
type: r.Warning,
|
|
91
91
|
key: S,
|
|
92
92
|
detail: i
|
|
93
93
|
}));
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
const m =
|
|
97
|
-
return
|
|
95
|
+
function Ge(t, i, n, u) {
|
|
96
|
+
const m = re(t);
|
|
97
|
+
return se(t, i, m, n, u).map((c) => ({
|
|
98
98
|
rule: o.InvalidCustomField,
|
|
99
99
|
type: r.Error,
|
|
100
100
|
key: S,
|
|
@@ -102,21 +102,21 @@ function xe(t, i, n, u) {
|
|
|
102
102
|
}));
|
|
103
103
|
}
|
|
104
104
|
function We(t) {
|
|
105
|
-
const i = t.match(
|
|
105
|
+
const i = t.match(U), n = [], u = [];
|
|
106
106
|
if (i && i.forEach((m) => {
|
|
107
|
-
const c = m.match(
|
|
107
|
+
const c = m.match(M), d = m.match(x), I = (c == null ? void 0 : c.join("")) || "";
|
|
108
108
|
(!c || m !== I) && !d && u.push({
|
|
109
109
|
rule: o.ConditionsSyntax,
|
|
110
110
|
type: r.Error,
|
|
111
|
-
key:
|
|
111
|
+
key: Se,
|
|
112
112
|
detail: m
|
|
113
113
|
}), c && c.forEach((g) => {
|
|
114
114
|
g.trim() === "=" && u.push({
|
|
115
115
|
rule: o.WrongEqualityOperator,
|
|
116
116
|
type: r.Error,
|
|
117
|
-
key:
|
|
117
|
+
key: _e
|
|
118
118
|
}), (g.match(/^[a-zA-Z]*$/g) ?? []).forEach((f) => {
|
|
119
|
-
|
|
119
|
+
De(f) && n.push(f);
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
122
|
}), n.length) {
|
|
@@ -124,31 +124,31 @@ function We(t) {
|
|
|
124
124
|
m !== c && u.push({
|
|
125
125
|
rule: o.MissingIfEndif,
|
|
126
126
|
type: r.Error,
|
|
127
|
-
key:
|
|
127
|
+
key: Ce
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
return u;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function Pe(t) {
|
|
133
133
|
const i = (t.match(/{% /gm) || []).length, n = (t.match(/ %}/gm) || []).length;
|
|
134
134
|
return i === n ? [] : [{
|
|
135
135
|
rule: o.ConditionTagSpacing,
|
|
136
136
|
type: r.Warning,
|
|
137
|
-
key:
|
|
137
|
+
key: he
|
|
138
138
|
}];
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
return (t.match(
|
|
140
|
+
function qe(t) {
|
|
141
|
+
return (t.match(N) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, u) => n + u, 0) === 0 ? [] : [{
|
|
142
142
|
rule: o.BracesInsideIfTag,
|
|
143
143
|
type: r.Warning,
|
|
144
|
-
key:
|
|
144
|
+
key: ke
|
|
145
145
|
}];
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
return (t.match(
|
|
147
|
+
function He(t) {
|
|
148
|
+
return (t.match(Oe) ?? []).map((i) => ({
|
|
149
149
|
rule: o.InvalidImageType,
|
|
150
150
|
type: r.Error,
|
|
151
|
-
key:
|
|
151
|
+
key: Fe,
|
|
152
152
|
detail: i
|
|
153
153
|
}));
|
|
154
154
|
}
|
|
@@ -159,12 +159,12 @@ function R(t, i, n, u) {
|
|
|
159
159
|
return !((d = c.id) != null && d.trim());
|
|
160
160
|
}).map(() => ({ rule: n, type: r.Error, key: u }));
|
|
161
161
|
}
|
|
162
|
-
const
|
|
163
|
-
const { config: t, isFeatureEnabled: i } =
|
|
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) => ({
|
|
164
164
|
rule: e.rule,
|
|
165
165
|
type: e.type,
|
|
166
166
|
detail: e.detail,
|
|
167
|
-
message: "key" in e ? n(e.key) :
|
|
167
|
+
message: "key" in e ? n(e.key) : Z(e.message)
|
|
168
168
|
}), A = async (e) => {
|
|
169
169
|
if (e.size === 0)
|
|
170
170
|
return /* @__PURE__ */ new Set();
|
|
@@ -173,10 +173,10 @@ const ft = () => {
|
|
|
173
173
|
} catch {
|
|
174
174
|
return null;
|
|
175
175
|
}
|
|
176
|
-
return
|
|
176
|
+
return ie(y.filterList);
|
|
177
177
|
}, D = async (e) => {
|
|
178
178
|
try {
|
|
179
|
-
const a = await u(
|
|
179
|
+
const a = await u(Ne, { html: T(e) }), { status: s, message: l } = a.data, p = [], E = s === void 0 && !!l && l !== n(F);
|
|
180
180
|
return s || p.push({
|
|
181
181
|
rule: o.InvalidLinks,
|
|
182
182
|
type: r.Error,
|
|
@@ -225,17 +225,17 @@ const ft = () => {
|
|
|
225
225
|
}];
|
|
226
226
|
}
|
|
227
227
|
}, K = () => {
|
|
228
|
-
const e = Object.values(y.blockStates).map((s) =>
|
|
229
|
-
const l = s.every((p) => p ===
|
|
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);
|
|
230
230
|
return {
|
|
231
231
|
rule: o.RecommendationRequiredFields,
|
|
232
232
|
type: l ? r.Warning : r.Error,
|
|
233
|
-
key: l ?
|
|
233
|
+
key: l ? X : j
|
|
234
234
|
};
|
|
235
235
|
}), a = (f.recommendationConfigs ?? []).filter((s) => s.filters.some((l) => l.value === "")).map(() => ({
|
|
236
236
|
rule: o.RecommendationFilters,
|
|
237
237
|
type: r.Error,
|
|
238
|
-
key:
|
|
238
|
+
key: Te
|
|
239
239
|
}));
|
|
240
240
|
return [...e, ...a];
|
|
241
241
|
}, B = async (e, a) => {
|
|
@@ -244,39 +244,39 @@ const ft = () => {
|
|
|
244
244
|
...a.map((w) => w.value),
|
|
245
245
|
...W,
|
|
246
246
|
...((h = (C = t.value) == null ? void 0 : C.template) == null ? void 0 : h.customFieldAttributes) ?? []
|
|
247
|
-
], l = Y(e), p = await A(l), { isTransactional: E } =
|
|
247
|
+
], l = Y(e), p = await A(l), { isTransactional: E } = O;
|
|
248
248
|
return [
|
|
249
249
|
...await D(e),
|
|
250
|
-
...E ? [] :
|
|
251
|
-
...Ye(e),
|
|
250
|
+
...E ? [] : Ye(e, s),
|
|
252
251
|
...Ue(e),
|
|
253
252
|
...Me(e),
|
|
254
|
-
...
|
|
253
|
+
...xe(e),
|
|
254
|
+
...E ? [] : Ge(e, s, l, p),
|
|
255
255
|
...We(e),
|
|
256
|
-
...Ge(e),
|
|
257
256
|
...Pe(e),
|
|
258
|
-
...K(),
|
|
259
257
|
...qe(e),
|
|
258
|
+
...K(),
|
|
259
|
+
...He(e),
|
|
260
260
|
...R(
|
|
261
261
|
e,
|
|
262
|
-
|
|
262
|
+
G,
|
|
263
263
|
o.CheckboxUnsubGroup,
|
|
264
|
-
|
|
264
|
+
be
|
|
265
265
|
),
|
|
266
266
|
...R(
|
|
267
267
|
e,
|
|
268
|
-
|
|
268
|
+
P,
|
|
269
269
|
o.RadioButtonUnsubGroup,
|
|
270
|
-
|
|
270
|
+
Re
|
|
271
271
|
)
|
|
272
272
|
];
|
|
273
273
|
}, _ = async (e, a, s) => [
|
|
274
|
-
...De(e),
|
|
275
|
-
...i("blockUnsubscribeLinks") ? Be(s) : [],
|
|
276
274
|
...ve(e),
|
|
275
|
+
...i("blockUnsubscribeLinks") ? we(s) : [],
|
|
277
276
|
...Ke(e),
|
|
277
|
+
...Be(e),
|
|
278
278
|
...i("liquidSyntax") ? await v(e) : await B(e, a)
|
|
279
|
-
].map(
|
|
279
|
+
].map(L);
|
|
280
280
|
return { collectSaveValidationErrors: _, validateCurrentTemplate: async () => {
|
|
281
281
|
const { html: e } = await c();
|
|
282
282
|
await I(e);
|
|
@@ -285,5 +285,5 @@ const ft = () => {
|
|
|
285
285
|
} };
|
|
286
286
|
};
|
|
287
287
|
export {
|
|
288
|
-
|
|
288
|
+
yt as useSaveValidation
|
|
289
289
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CONDITION_TAG_REGEX as s } from "../../enums/html-validator.js";
|
|
2
|
+
const r = /[^\S\r\n\u2028\u2029]*[\r\n\u2028\u2029]+\s*/g, i = [
|
|
3
|
+
{
|
|
4
|
+
id: "pongo-single-line-tags",
|
|
5
|
+
description: "Collapse line breaks inside {% %} tags to a space",
|
|
6
|
+
type: "custom",
|
|
7
|
+
processor: (e) => e.replace(s, (o) => o.replace(r, " ")),
|
|
8
|
+
priority: 50
|
|
9
|
+
}
|
|
10
|
+
];
|
|
11
|
+
export {
|
|
12
|
+
i as pongoCompilerRules
|
|
13
|
+
};
|