@useinsider/guido 3.30.0-beta.02005ef → 3.30.0-beta.0c48424
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/useAuthError.js +15 -12
- package/dist/composables/useHtmlValidator.js +138 -130
- package/dist/composables/useHttp.js +70 -61
- package/dist/composables/useSave.js +1 -1
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +59 -57
- package/dist/package.json.js +2 -2
- package/dist/services/recommendationApi.js +37 -33
- package/dist/services/templateLibraryApi.js +35 -33
- package/dist/src/composables/useAuthError.d.ts +1 -0
- package/dist/src/composables/useHtmlValidator.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +14 -0
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ToasterTypeOptions as l } from "../enums/toaster.js";
|
|
2
|
-
import { ref as
|
|
3
|
-
import { useToaster as
|
|
2
|
+
import { ref as u } from "vue";
|
|
3
|
+
import { useToaster as p } from "./useToaster.js";
|
|
4
4
|
import { useTranslations as f } from "./useTranslations.js";
|
|
5
|
-
const d = ["accessExpired", "domainRestricted", "ipRestricted", "insiderAccessRestricted"], n =
|
|
5
|
+
const d = ["accessExpired", "domainRestricted", "ipRestricted", "insiderAccessRestricted"], n = u(null), a = (e) => {
|
|
6
6
|
try {
|
|
7
7
|
return new URL(e, window.location.href).origin === window.location.origin;
|
|
8
8
|
} catch {
|
|
@@ -22,31 +22,34 @@ const d = ["accessExpired", "domainRestricted", "ipRestricted", "insiderAccessRe
|
|
|
22
22
|
} catch {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
}, y = (e) => typeof (e == null ? void 0 : e.message) == "string" ? e.message : "",
|
|
26
|
-
|
|
25
|
+
}, y = (e) => typeof (e == null ? void 0 : e.message) == "string" ? e.message : "", i = (e) => y(e) || f()("user-management.collaborate-forbidden-action"), s = (e) => {
|
|
26
|
+
p().showToaster({ type: l.Error, message: e });
|
|
27
27
|
}, R = (e, o, t) => {
|
|
28
28
|
if (t && !a(t))
|
|
29
29
|
return;
|
|
30
30
|
const r = w(o);
|
|
31
31
|
if (e === 403) {
|
|
32
|
-
|
|
32
|
+
s(i(r));
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
if (e === 401 && (r == null ? void 0 : r.type) === "groupLevelAccess") {
|
|
36
|
-
|
|
36
|
+
s(i(r));
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
if (e === 401 && typeof (r == null ? void 0 : r.type) == "string" && d.includes(r.type)) {
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
window.location.replace(
|
|
40
|
+
const c = typeof r.redirect == "string" ? g(r.redirect) : "";
|
|
41
|
+
if (c) {
|
|
42
|
+
window.location.replace(c);
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
e !== 401 && e !== 419 || n.value || (window.isSessionExpired = !0, n.value = { status: e, data: r });
|
|
47
|
-
}, T = () =>
|
|
47
|
+
}, T = (e) => {
|
|
48
|
+
s(i(e));
|
|
49
|
+
}, O = () => ({ authError: n });
|
|
48
50
|
export {
|
|
49
51
|
a as isPanelOrigin,
|
|
50
52
|
R as reportAuthError,
|
|
51
|
-
T as
|
|
53
|
+
T as reportProductRefusal,
|
|
54
|
+
O as useAuthError
|
|
52
55
|
};
|
|
@@ -1,233 +1,241 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { getIgnoredRecommendationBlockIds as
|
|
3
|
-
import { TemplateTypes as
|
|
4
|
-
import { CONDITION_TAG_REGEX as
|
|
5
|
-
import { ToasterTypeOptions as
|
|
6
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
7
|
-
import { itemsBlockDynamicVariables as
|
|
8
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
9
|
-
import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { filterToProductAttrValue as
|
|
12
|
-
import { STRATEGY_FIELD_KEY as
|
|
13
|
-
import { useRecommendationStore as
|
|
14
|
-
import { base64EncodeWithSpecialChars as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { useConfig as W } from "./useConfig.js";
|
|
2
|
+
import { getIgnoredRecommendationBlockIds as G } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
3
|
+
import { TemplateTypes as H } from "../enums/defaults.js";
|
|
4
|
+
import { CONDITION_TAG_REGEX as K, DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as X, CampaignCouldNotBeSavedKey as Y, CanNotMakeAnyChangesForRunningKey as $, DATA_ATTRIBUTE_REGEX as j, DYNAMIC_CONTENT_TAG_REGEX as U, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as z } from "../enums/html-validator.js";
|
|
5
|
+
import { ToasterTypeOptions as l } from "../enums/toaster.js";
|
|
6
|
+
import { BLOCK_ROOT_SELECTOR as Z } from "../extensions/Blocks/Checkbox/constants/selectors.js";
|
|
7
|
+
import { itemsBlockDynamicVariables as J } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
8
|
+
import { BLOCK_ROOT_SELECTOR as Q } from "../extensions/Blocks/RadioButton/constants/selectors.js";
|
|
9
|
+
import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as ee } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
10
|
+
import { useRecommendationExtensionStore as te } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
|
+
import { filterToProductAttrValue as ne } from "../extensions/Blocks/Recommendation/utils/compositionKeys.js";
|
|
12
|
+
import { STRATEGY_FIELD_KEY as se, RecommendationAssignStrategyKey as re, RecommendationRequiredFieldsKey as oe } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
13
|
+
import { useRecommendationStore as ie } from "../stores/recommendation.js";
|
|
14
|
+
import { base64EncodeWithSpecialChars as ae } from "../utils/base64.js";
|
|
15
|
+
import { isPlainObject as S } from "../utils/genericUtil.js";
|
|
16
|
+
import { computed as ce } from "vue";
|
|
17
|
+
import { useHttp as le } from "./useHttp.js";
|
|
18
|
+
import { useToaster as me } from "./useToaster.js";
|
|
19
|
+
import { useTranslations as ue } from "./useTranslations.js";
|
|
20
|
+
const de = /recommendation-id="(\d+)"/g;
|
|
21
|
+
function fe(s) {
|
|
22
|
+
return [...s.matchAll(de)].map((m) => m[1]);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
return m.some((
|
|
24
|
+
function ge(s, m) {
|
|
25
|
+
return m.some((g) => s.startsWith(`${g}_`));
|
|
25
26
|
}
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
const m = s.match(
|
|
27
|
+
const pe = /^(\d+)_\d+_(.+)$/;
|
|
28
|
+
function Ee(s) {
|
|
29
|
+
const m = s.match(pe);
|
|
29
30
|
return m ? { recoId: m[1], attribute: m[2] } : null;
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
-
const m = new Set(
|
|
33
|
-
return Object.values(s).forEach((
|
|
34
|
-
m.add(
|
|
32
|
+
function ye(s) {
|
|
33
|
+
const m = new Set(ee);
|
|
34
|
+
return Object.values(s).forEach((g) => {
|
|
35
|
+
m.add(ne(g).toLowerCase());
|
|
35
36
|
}), m;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function Ce(s, m, g, p, o) {
|
|
38
39
|
const u = s.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
|
|
39
40
|
if (!u)
|
|
40
41
|
return [];
|
|
41
|
-
const
|
|
42
|
-
return u.forEach((
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
42
|
+
const d = new Set(m.map((y) => y.toLowerCase())), E = [];
|
|
43
|
+
return u.forEach((y) => {
|
|
44
|
+
const f = y.slice(2, -2).trim().toLowerCase();
|
|
45
|
+
if (f !== "" && d.has(f))
|
|
45
46
|
return;
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
if (!
|
|
47
|
+
const C = Ee(f);
|
|
48
|
+
if (C && p.has(C.recoId)) {
|
|
49
|
+
if (!o || o.has(C.attribute))
|
|
49
50
|
return;
|
|
50
|
-
E.push(
|
|
51
|
+
E.push(f);
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
ge(f, g) || f.includes(".") || E.push(f);
|
|
54
55
|
}), E;
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
-
return (s.replace(
|
|
58
|
-
const
|
|
59
|
-
return
|
|
57
|
+
function he(s) {
|
|
58
|
+
return (s.replace(j, "$1").match(U) ?? []).filter((p) => {
|
|
59
|
+
const o = p.slice(2, -2), u = o.indexOf("|"), d = (u === -1 ? o : o.slice(0, u)).trim();
|
|
60
|
+
return q.includes(d) ? !1 : z.test(d) ? u !== -1 && o.slice(u + 1).trim() === "" : !0;
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
const
|
|
63
|
-
const { showToaster: s } =
|
|
63
|
+
const Ge = () => {
|
|
64
|
+
const { showToaster: s, handleError: m } = me(), { post: g } = le(), { config: p } = W(), o = ue(), u = ie(), d = te(), E = ce(
|
|
64
65
|
() => {
|
|
65
66
|
var e, t;
|
|
66
|
-
return ((t = (e =
|
|
67
|
+
return ((t = (e = p.value) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) === H.transactional;
|
|
67
68
|
}
|
|
68
|
-
),
|
|
69
|
+
), y = async (e) => {
|
|
69
70
|
if (e.size === 0)
|
|
70
71
|
return /* @__PURE__ */ new Set();
|
|
71
72
|
try {
|
|
72
|
-
await
|
|
73
|
+
await d.fetchRecommendationFilters();
|
|
73
74
|
} catch {
|
|
74
75
|
return null;
|
|
75
76
|
}
|
|
76
|
-
return
|
|
77
|
-
},
|
|
78
|
-
const n =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
77
|
+
return ye(d.filterList);
|
|
78
|
+
}, f = async (e, t) => {
|
|
79
|
+
const n = "/newsletter/template-library/check-template-html-body";
|
|
80
|
+
let r;
|
|
81
|
+
try {
|
|
82
|
+
({ data: r } = await g(
|
|
83
|
+
n,
|
|
84
|
+
{ html: ae(e) }
|
|
85
|
+
));
|
|
86
|
+
} catch (c) {
|
|
87
|
+
return t || m(c, "Failed to check links"), !1;
|
|
88
|
+
}
|
|
89
|
+
const a = S(r) ? r.status : void 0, i = S(r) && typeof r.message == "string" ? r.message : "";
|
|
90
|
+
return a || s({
|
|
91
|
+
type: l.Error,
|
|
92
|
+
message: a === void 0 && i ? i : o("newsletter.invalid-url-link-for-toaster")
|
|
93
|
+
}), o(Y), i === o($) && s({
|
|
94
|
+
type: l.Error,
|
|
87
95
|
message: o("newsletter.already-in-progress")
|
|
88
|
-
}),
|
|
89
|
-
},
|
|
96
|
+
}), !!a;
|
|
97
|
+
}, C = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), R = (e) => ["if", "endif"].includes(e.toLowerCase()), _ = (e, t) => {
|
|
90
98
|
const n = e.match(/({%(.*?)%})/g);
|
|
91
99
|
let r = !0;
|
|
92
|
-
return n !== null && !
|
|
100
|
+
return n !== null && !E.value && n.forEach((a) => {
|
|
93
101
|
const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
94
102
|
if (i && i.length > 0) {
|
|
95
|
-
const [
|
|
96
|
-
|
|
97
|
-
type:
|
|
103
|
+
const [c] = i;
|
|
104
|
+
C(c) && !t.includes(c) && (s({
|
|
105
|
+
type: l.Warning,
|
|
98
106
|
message: o("custom-fields.invalid-custom-fields")
|
|
99
107
|
}), r = !1);
|
|
100
108
|
}
|
|
101
109
|
}), r;
|
|
102
|
-
},
|
|
103
|
-
const
|
|
104
|
-
return
|
|
105
|
-
},
|
|
106
|
-
type:
|
|
110
|
+
}, A = async (e, t, n, r) => {
|
|
111
|
+
const a = n ? await f(e, r) : !0;
|
|
112
|
+
return _(e, t) && a;
|
|
113
|
+
}, O = (e) => e.length > 0 ? !0 : (s({
|
|
114
|
+
type: l.Warning,
|
|
107
115
|
message: o("newsletter.html-content-is-empty")
|
|
108
|
-
}), !1),
|
|
116
|
+
}), !1), b = (e) => {
|
|
109
117
|
const t = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
|
|
110
118
|
return t > n && s({
|
|
111
|
-
type:
|
|
119
|
+
type: l.Warning,
|
|
112
120
|
message: o("custom-fields.missing-closing-braces")
|
|
113
121
|
}), t < n && s({
|
|
114
|
-
type:
|
|
122
|
+
type: l.Warning,
|
|
115
123
|
message: o("custom-fields.missing-opening-braces")
|
|
116
124
|
}), t === n;
|
|
117
|
-
},
|
|
118
|
-
const t =
|
|
125
|
+
}, w = (e) => {
|
|
126
|
+
const t = he(e).length === 0;
|
|
119
127
|
return t || s({
|
|
120
|
-
type:
|
|
128
|
+
type: l.Warning,
|
|
121
129
|
message: o("custom-fields.invalid-custom-fields")
|
|
122
130
|
}), t;
|
|
123
|
-
},
|
|
124
|
-
if (
|
|
131
|
+
}, N = (e, t, n, r) => {
|
|
132
|
+
if (E.value)
|
|
125
133
|
return !0;
|
|
126
|
-
const a =
|
|
134
|
+
const a = Ce(
|
|
127
135
|
e,
|
|
128
136
|
t,
|
|
129
|
-
|
|
137
|
+
fe(e),
|
|
130
138
|
n,
|
|
131
139
|
r
|
|
132
140
|
);
|
|
133
141
|
if (a.length > 0) {
|
|
134
142
|
const i = `
|
|
135
143
|
<ul>
|
|
136
|
-
${a.map((
|
|
144
|
+
${a.map((c) => `<li>${c}</li>`).join("")}
|
|
137
145
|
</ul>
|
|
138
146
|
`;
|
|
139
147
|
return s({
|
|
140
|
-
type:
|
|
148
|
+
type: l.Error,
|
|
141
149
|
message: o("custom-fields.invalid-custom-fields") + i
|
|
142
150
|
}), !1;
|
|
143
151
|
}
|
|
144
152
|
return !0;
|
|
145
|
-
},
|
|
146
|
-
const t = e.match(
|
|
153
|
+
}, L = (e) => {
|
|
154
|
+
const t = e.match(K), n = [];
|
|
147
155
|
let r = !0;
|
|
148
156
|
if (t && t.forEach((a) => {
|
|
149
|
-
const i = a.match(
|
|
150
|
-
(!i || a !==
|
|
151
|
-
type:
|
|
157
|
+
const i = a.match(P), c = a.match(X), I = (i == null ? void 0 : i.join("")) || "";
|
|
158
|
+
(!i || a !== I) && !c && (s({
|
|
159
|
+
type: l.Error,
|
|
152
160
|
message: o("newsletter.display-conditions-invalid-syntax")
|
|
153
161
|
}), r = !1), i && i.forEach((h) => {
|
|
154
162
|
h.trim() === "=" && (s({
|
|
155
|
-
type:
|
|
163
|
+
type: l.Error,
|
|
156
164
|
message: o("custom-conditions.wrong-equality-operators")
|
|
157
165
|
}), r = !1);
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
const v = h.match(/^[a-zA-Z]*$/g);
|
|
167
|
+
v && v.forEach((T) => {
|
|
168
|
+
R(T) && n.push(T);
|
|
161
169
|
});
|
|
162
170
|
});
|
|
163
171
|
}), n.length) {
|
|
164
|
-
const a = n.filter((
|
|
172
|
+
const a = n.filter((c) => c === "if"), i = n.filter((c) => c === "endif");
|
|
165
173
|
a.length !== i.length && (s({
|
|
166
|
-
type:
|
|
174
|
+
type: l.Error,
|
|
167
175
|
message: o("custom-conditions.missing-if-endif-tag")
|
|
168
176
|
}), r = !1);
|
|
169
177
|
}
|
|
170
178
|
return r;
|
|
171
|
-
},
|
|
179
|
+
}, B = (e) => {
|
|
172
180
|
const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, r = t === n;
|
|
173
181
|
return r || s({
|
|
174
|
-
type:
|
|
182
|
+
type: l.Warning,
|
|
175
183
|
message: o("custom-conditions.no-space-after-braces")
|
|
176
184
|
}), r;
|
|
177
|
-
},
|
|
178
|
-
type:
|
|
185
|
+
}, F = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, r) => n + r, 0) > 0 ? (s({
|
|
186
|
+
type: l.Warning,
|
|
179
187
|
message: o("custom-conditions.no-braces-inside-if-tag")
|
|
180
|
-
}), !1) : !0,
|
|
181
|
-
if (!
|
|
188
|
+
}), !1) : !0, k = () => {
|
|
189
|
+
if (!d.hasInvalidBlock())
|
|
182
190
|
return !0;
|
|
183
|
-
const e =
|
|
191
|
+
const e = d.invalidBlockFields(), t = e.length > 0 && e.every((n) => n === se);
|
|
184
192
|
return s({
|
|
185
|
-
type: t ?
|
|
186
|
-
message: o(t ?
|
|
193
|
+
type: t ? l.Warning : l.Error,
|
|
194
|
+
message: o(t ? re : oe)
|
|
187
195
|
}), !1;
|
|
188
|
-
},
|
|
189
|
-
type:
|
|
196
|
+
}, x = () => u.recommendationConfigs && Object.values(u.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
|
|
197
|
+
type: l.Error,
|
|
190
198
|
message: o("newsletter.fill-all-necessary-fields")
|
|
191
|
-
}), !1) : !0,
|
|
199
|
+
}), !1) : !0, D = (e) => {
|
|
192
200
|
const t = /src="[^"]*\.(svg|pst)"/gm;
|
|
193
201
|
return e.match(t) === null ? !0 : (s({
|
|
194
|
-
type:
|
|
202
|
+
type: l.Error,
|
|
195
203
|
message: o("newsletter.invalid-image-type")
|
|
196
204
|
}), !1);
|
|
197
|
-
},
|
|
198
|
-
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(
|
|
205
|
+
}, V = (e) => {
|
|
206
|
+
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Z);
|
|
199
207
|
return Array.from(r).find((i) => {
|
|
200
|
-
var
|
|
201
|
-
return !((
|
|
208
|
+
var c;
|
|
209
|
+
return !((c = i.id) != null && c.trim());
|
|
202
210
|
}) ? (s({
|
|
203
|
-
type:
|
|
211
|
+
type: l.Error,
|
|
204
212
|
message: o("unsubscribe-templates.select-checkbox-groups")
|
|
205
213
|
}), !1) : !0;
|
|
206
|
-
},
|
|
207
|
-
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(
|
|
214
|
+
}, M = (e) => {
|
|
215
|
+
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Q);
|
|
208
216
|
return Array.from(r).find((i) => {
|
|
209
|
-
var
|
|
210
|
-
return !((
|
|
217
|
+
var c;
|
|
218
|
+
return !((c = i.id) != null && c.trim());
|
|
211
219
|
}) ? (s({
|
|
212
|
-
type:
|
|
220
|
+
type: l.Error,
|
|
213
221
|
message: o("unsubscribe-templates.select-radio-button-groups")
|
|
214
222
|
}), !1) : !0;
|
|
215
223
|
};
|
|
216
|
-
return { validateHtml: async (e, t, n = !1) => {
|
|
217
|
-
var
|
|
218
|
-
const
|
|
224
|
+
return { validateHtml: async (e, t, n = !1, r = !1) => {
|
|
225
|
+
var h, v;
|
|
226
|
+
const a = [
|
|
219
227
|
...t.map((T) => T.value),
|
|
220
|
-
...
|
|
221
|
-
...((
|
|
222
|
-
],
|
|
223
|
-
return await
|
|
228
|
+
...J,
|
|
229
|
+
...((v = (h = p.value) == null ? void 0 : h.template) == null ? void 0 : v.customFieldAttributes) ?? []
|
|
230
|
+
], i = G(e), c = await y(i);
|
|
231
|
+
return await A(e, a, n, r) && O(e) && b(e) && w(e) && N(e, a, i, c) && L(e) && B(e) && F(e) && k() && x() && D(e) && V(e) && M(e);
|
|
224
232
|
} };
|
|
225
233
|
};
|
|
226
234
|
export {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
235
|
+
ye as buildPartnerAttributeNameSet,
|
|
236
|
+
Ce as findInvalidCustomFields,
|
|
237
|
+
he as getInvalidDynamicContentTags,
|
|
238
|
+
fe as getRecommendationBlockIds,
|
|
239
|
+
Ee as parseRecommendationVariable,
|
|
240
|
+
Ge as useHtmlValidator
|
|
233
241
|
};
|
|
@@ -1,98 +1,107 @@
|
|
|
1
|
-
import { getCsrfToken as
|
|
2
|
-
import { ref as
|
|
3
|
-
import { isPanelOrigin as
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
import { getCsrfToken as X, isPlainObject as k } from "../utils/genericUtil.js";
|
|
2
|
+
import { ref as g, computed as T } from "vue";
|
|
3
|
+
import { isPanelOrigin as b, reportAuthError as F, reportProductRefusal as M } from "./useAuthError.js";
|
|
4
|
+
const N = [401, 403, 419], J = (y = {}) => {
|
|
5
|
+
const m = g(!1), a = g(null), f = g(null), P = T(() => m.value), x = T(() => a.value !== null), v = {
|
|
6
6
|
baseURL: "",
|
|
7
7
|
timeout: 1e4,
|
|
8
8
|
retry: 0,
|
|
9
9
|
retryDelay: 1e3,
|
|
10
10
|
headers: {
|
|
11
11
|
"Content-Type": "application/json",
|
|
12
|
-
"X-CSRF-TOKEN":
|
|
12
|
+
"X-CSRF-TOKEN": X(),
|
|
13
13
|
Accept: "application/json",
|
|
14
14
|
// Without this a guest fetch gets a 302 to the login page, never an auth status.
|
|
15
15
|
"X-Requested-With": "XMLHttpRequest"
|
|
16
16
|
},
|
|
17
|
-
...
|
|
18
|
-
},
|
|
17
|
+
...y
|
|
18
|
+
}, A = (e, r) => {
|
|
19
19
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
20
20
|
return e;
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
},
|
|
21
|
+
const s = r || v.baseURL || "";
|
|
22
|
+
return s.endsWith("/") && e.startsWith("/") ? `${s}${e.slice(1)}` : s.endsWith("/") || e.startsWith("/") ? `${s}${e}` : `${s}/${e}`;
|
|
23
|
+
}, S = (e) => new Promise((r, s) => {
|
|
24
24
|
setTimeout(() => {
|
|
25
|
-
|
|
25
|
+
s(new Error("Request timeout"));
|
|
26
26
|
}, e);
|
|
27
|
-
}),
|
|
27
|
+
}), U = (e) => new Promise((r) => {
|
|
28
28
|
setTimeout(r, e);
|
|
29
|
-
}),
|
|
30
|
-
|
|
31
|
-
const
|
|
29
|
+
}), u = async (e, r, s, j = {}) => {
|
|
30
|
+
a.value = null, m.value = !0, f.value = new AbortController();
|
|
31
|
+
const i = { ...v, ...j }, h = A(r, i.baseURL), p = {
|
|
32
32
|
method: e,
|
|
33
|
-
headers: { ...
|
|
34
|
-
signal:
|
|
35
|
-
...
|
|
33
|
+
headers: { ...i.headers },
|
|
34
|
+
signal: f.value.signal,
|
|
35
|
+
...i
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
const
|
|
37
|
+
s && ["POST", "PUT", "PATCH"].includes(e) && (s instanceof FormData ? (delete p.headers["Content-Type"], p.body = s) : p.body = JSON.stringify(s));
|
|
38
|
+
const E = async (w = 0) => {
|
|
39
|
+
var R;
|
|
39
40
|
if (window.isSessionExpired) {
|
|
40
|
-
|
|
41
|
+
a.value = { message: "Session expired", authReported: !0 };
|
|
41
42
|
const o = new Error("Session expired");
|
|
42
43
|
throw o.authReported = !0, o;
|
|
43
44
|
}
|
|
44
45
|
try {
|
|
45
|
-
const o = [fetch(
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
49
|
-
const
|
|
50
|
-
throw
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
new URL(
|
|
46
|
+
const o = [fetch(h, p)];
|
|
47
|
+
i.timeout && o.push(S(i.timeout));
|
|
48
|
+
const t = await Promise.race(o);
|
|
49
|
+
if (!t.ok) {
|
|
50
|
+
const c = `HTTP Error: ${t.status} ${t.statusText}`, d = new Error(c);
|
|
51
|
+
throw d.status = t.status, d.statusText = t.statusText, d.response = t, d.authReported = N.includes(t.status) && b(h), d.authReported && Promise.resolve().then(() => t.clone().text().catch(() => "")).then((D) => F(
|
|
52
|
+
t.status,
|
|
53
|
+
D,
|
|
54
|
+
new URL(h, window.location.href).href
|
|
54
55
|
)).catch(() => {
|
|
55
|
-
}),
|
|
56
|
+
}), d;
|
|
56
57
|
}
|
|
57
|
-
let
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
let n;
|
|
59
|
+
const l = t.headers.get("content-type");
|
|
60
|
+
if (l != null && l.includes("application/json") ? n = await t.json() : l != null && l.includes("text/") ? n = await t.text() : n = await t.blob(), b(h) && k(n) && n.unauthorized === !0 && n.success === !1) {
|
|
61
|
+
const c = new Error(
|
|
62
|
+
typeof n.message == "string" ? n.message : "Product access refused"
|
|
63
|
+
);
|
|
64
|
+
throw c.status = t.status, c.authReported = !0, M(n), a.value = { message: c.message, status: t.status, authReported: !0 }, c;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
data: n,
|
|
68
|
+
status: t.status,
|
|
69
|
+
statusText: t.statusText,
|
|
70
|
+
headers: t.headers
|
|
64
71
|
};
|
|
65
72
|
} catch (o) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
if ((R = a.value) != null && R.authReported)
|
|
74
|
+
throw o;
|
|
75
|
+
const t = o instanceof Error && o.name === "AbortError";
|
|
76
|
+
if (w < (i.retry || 0) && !t)
|
|
77
|
+
return await U(i.retryDelay || 1e3), E(w + 1);
|
|
78
|
+
throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
|
|
70
79
|
}
|
|
71
80
|
};
|
|
72
81
|
try {
|
|
73
|
-
return await
|
|
82
|
+
return await E();
|
|
74
83
|
} finally {
|
|
75
|
-
|
|
84
|
+
m.value = !1, f.value = null;
|
|
76
85
|
}
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
|
|
86
|
+
}, C = (e, r) => u("GET", e, void 0, r), $ = (e, r, s) => u("POST", e, r, s), q = (e, r, s) => u("PUT", e, r, s), L = (e, r, s) => u("PATCH", e, r, s), O = (e, r) => u("DELETE", e, void 0, r), W = (e) => {
|
|
87
|
+
f.value && f.value.abort(e);
|
|
88
|
+
}, H = () => {
|
|
89
|
+
a.value = null;
|
|
81
90
|
};
|
|
82
91
|
return {
|
|
83
|
-
loading:
|
|
84
|
-
error:
|
|
85
|
-
hasError:
|
|
86
|
-
request:
|
|
87
|
-
get:
|
|
88
|
-
post:
|
|
89
|
-
put:
|
|
90
|
-
patch:
|
|
91
|
-
delete:
|
|
92
|
-
cancel:
|
|
93
|
-
clearError:
|
|
92
|
+
loading: P,
|
|
93
|
+
error: T(() => a.value),
|
|
94
|
+
hasError: x,
|
|
95
|
+
request: u,
|
|
96
|
+
get: C,
|
|
97
|
+
post: $,
|
|
98
|
+
put: q,
|
|
99
|
+
patch: L,
|
|
100
|
+
delete: O,
|
|
101
|
+
cancel: W,
|
|
102
|
+
clearError: H
|
|
94
103
|
};
|
|
95
104
|
};
|
|
96
105
|
export {
|
|
97
|
-
|
|
106
|
+
J as useHttp
|
|
98
107
|
};
|
|
@@ -39,7 +39,7 @@ const Pt = () => {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
return !0;
|
|
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) => {
|
|
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, e), v = async (t, e) => {
|
|
43
43
|
if (!await C())
|
|
44
44
|
return;
|
|
45
45
|
const { unsubscribePayload: o, stripoModules: r } = x(t.rawHtml);
|