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