@hortiview/modulebase 0.0.15690 → 0.0.20436
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/ModuleCore-DpwHP0IU.js +14973 -0
- package/dist/{QueryClientProvider-VtJdNkDw.js → QueryClientProvider-Beog9TR7.js} +25 -23
- package/dist/{_baseGet-B7FwMMGI.js → _baseGet-C6jMXSsQ.js} +447 -447
- package/dist/api-CogBuK0n.js +473 -0
- package/dist/components/ModuleBase.js +1 -1
- package/dist/components/ModuleCore.js +9 -14698
- package/dist/constants.js +1 -1
- package/dist/enum/ActionStorage.js +4 -0
- package/dist/hooks/useCustom.js +15 -18
- package/dist/hooks/useCustomMutation.js +12 -11
- package/dist/hooks/useEntity.js +48 -60
- package/dist/hooks/useOffline.js +57 -0
- package/dist/hooks/useOption.js +15 -15
- package/dist/hooks/useServiceBus.js +1 -1
- package/dist/hooks/useStores.js +1 -1
- package/dist/{query-CFoO2uy7.js → isRestoring-CLuxJVSA.js} +21 -17
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/enum/ActionStorage.d.ts +7 -0
- package/dist/lib/hooks/useCustom.d.ts +3 -2
- package/dist/lib/hooks/useCustomMutation.d.ts +2 -1
- package/dist/lib/hooks/useEntity.d.ts +9 -23
- package/dist/lib/hooks/useOffline.d.ts +15 -0
- package/dist/lib/hooks/useStores.d.ts +10 -2
- package/dist/lib/main.d.ts +4 -0
- package/dist/lib/types/ActionStorage.d.ts +8 -0
- package/dist/lib/types/BaseProps.d.ts +10 -1
- package/dist/lib/types/CommonOptions.d.ts +2 -1
- package/dist/lib/types/Deprecated.d.ts +4 -0
- package/dist/lib/types/Entities.d.ts +22 -0
- package/dist/lib/utils/IndexedDbService.d.ts +33 -0
- package/dist/lib/utils/api.d.ts +1 -1
- package/dist/lib/utils/baseFetches.d.ts +2 -2
- package/dist/lib/utils/fetches.d.ts +2 -2
- package/dist/lib/utils/helper.d.ts +1 -0
- package/dist/main.js +218 -144
- package/dist/{mutation-CnKIetRs.js → mutation-DSKlaYzY.js} +1 -1
- package/dist/{omit-B7MWDtHq.js → omit-C9Qe80rl.js} +1 -1
- package/dist/types/ActionStorage.js +1 -0
- package/dist/types/CommonOptions.js +1 -1
- package/dist/types/Entities.js +25 -0
- package/dist/{useMutation-Num57Ulc.js → useMutation-zu8uxBak.js} +16 -16
- package/dist/{useQuery-XBGd5Kep.js → useQuery-Bj9k9zik.js} +39 -39
- package/dist/utils/IndexedDbService.js +43 -0
- package/dist/utils/api.js +1 -1
- package/dist/utils/baseFetches.js +15 -15
- package/dist/utils/fetches.js +10 -10
- package/dist/utils/helper.js +25 -20
- package/package.json +7 -3
- package/dist/api-D9Lmqe6S.js +0 -458
package/dist/api-D9Lmqe6S.js
DELETED
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import { g as z } from "./_commonjsHelpers-BkfeUUK-.js";
|
|
2
|
-
import { r as F, a as J, b as Q, c as V, d as W, e as Y, f as Z, g as K, h as tt } from "./_baseGet-B7FwMMGI.js";
|
|
3
|
-
import { RETRY_HTTP_STATUS_CODES as rt, RETRIES as nt } from "./constants.js";
|
|
4
|
-
import { useBasePropsStore as R } from "./stores/BasePropsStore.js";
|
|
5
|
-
var C, N;
|
|
6
|
-
function et() {
|
|
7
|
-
if (N) return C;
|
|
8
|
-
N = 1;
|
|
9
|
-
var t = F(), n = J(), r = Q(), e = Z(), o = V(), c = W(), u = K(), p = Y(), h = "[object Map]", O = "[object Set]", f = Object.prototype, d = f.hasOwnProperty;
|
|
10
|
-
function a(s) {
|
|
11
|
-
if (s == null)
|
|
12
|
-
return !0;
|
|
13
|
-
if (o(s) && (e(s) || typeof s == "string" || typeof s.splice == "function" || c(s) || p(s) || r(s)))
|
|
14
|
-
return !s.length;
|
|
15
|
-
var l = n(s);
|
|
16
|
-
if (l == h || l == O)
|
|
17
|
-
return !s.size;
|
|
18
|
-
if (u(s))
|
|
19
|
-
return !t(s).length;
|
|
20
|
-
for (var y in s)
|
|
21
|
-
if (d.call(s, y))
|
|
22
|
-
return !1;
|
|
23
|
-
return !0;
|
|
24
|
-
}
|
|
25
|
-
return C = a, C;
|
|
26
|
-
}
|
|
27
|
-
var ot = et();
|
|
28
|
-
const M = /* @__PURE__ */ z(ot);
|
|
29
|
-
var I, P;
|
|
30
|
-
function ct() {
|
|
31
|
-
if (P) return I;
|
|
32
|
-
P = 1;
|
|
33
|
-
var t = tt();
|
|
34
|
-
function n(r, e, o) {
|
|
35
|
-
var c = r == null ? void 0 : t(r, e);
|
|
36
|
-
return c === void 0 ? o : c;
|
|
37
|
-
}
|
|
38
|
-
return I = n, I;
|
|
39
|
-
}
|
|
40
|
-
var at = ct();
|
|
41
|
-
const U = /* @__PURE__ */ z(at);
|
|
42
|
-
var S = function() {
|
|
43
|
-
return S = Object.assign || function(n) {
|
|
44
|
-
for (var r, e = 1, o = arguments.length; e < o; e++) {
|
|
45
|
-
r = arguments[e];
|
|
46
|
-
for (var c in r) Object.prototype.hasOwnProperty.call(r, c) && (n[c] = r[c]);
|
|
47
|
-
}
|
|
48
|
-
return n;
|
|
49
|
-
}, S.apply(this, arguments);
|
|
50
|
-
};
|
|
51
|
-
function it(t, n) {
|
|
52
|
-
var r = {};
|
|
53
|
-
for (var e in t) Object.prototype.hasOwnProperty.call(t, e) && n.indexOf(e) < 0 && (r[e] = t[e]);
|
|
54
|
-
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
55
|
-
for (var o = 0, e = Object.getOwnPropertySymbols(t); o < e.length; o++)
|
|
56
|
-
n.indexOf(e[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, e[o]) && (r[e[o]] = t[e[o]]);
|
|
57
|
-
return r;
|
|
58
|
-
}
|
|
59
|
-
var st = ["eq", "ne", "gt", "ge", "lt", "le"], $ = ["and", "or", "not"], ut = ["any", "all"], ft = ["startswith", "endswith", "contains", "matchespattern"], pt = [
|
|
60
|
-
"expand",
|
|
61
|
-
"levels",
|
|
62
|
-
"select",
|
|
63
|
-
"skip",
|
|
64
|
-
"top",
|
|
65
|
-
"count",
|
|
66
|
-
"orderby",
|
|
67
|
-
"filter"
|
|
68
|
-
], L = /\((.*)\)/, G = /(?!indexof)\((\w+)\)/, D;
|
|
69
|
-
(function(t) {
|
|
70
|
-
t.sum = "sum", t.min = "min", t.max = "max", t.average = "average", t.countdistinct = "countdistinct";
|
|
71
|
-
})(D || (D = {}));
|
|
72
|
-
var g = "";
|
|
73
|
-
function dt(t) {
|
|
74
|
-
var n = t === void 0 ? {} : t, r = n.select, e = n.search, o = n.skiptoken, c = n.format, u = n.top, p = n.skip, h = n.filter, O = n.transform, f = n.orderBy, d = n.key, a = n.count, s = n.expand, l = n.action, y = n.func, b = "", w = [], i = {};
|
|
75
|
-
if (d != null && (b += "(".concat(v(d, w), ")")), (h || typeof a == "object") && (i.$filter = T(typeof a == "object" ? a : h, w)), O && (i.$apply = X(O)), s && (i.$expand = k(s)), f && (i.$orderby = x(f)), a && (typeof a == "boolean" ? i.$count = !0 : b += "/$count"), typeof u == "number" && (i.$top = u), typeof p == "number" && (i.$skip = p), l && (b += "/".concat(l)), y) {
|
|
76
|
-
if (typeof y == "string")
|
|
77
|
-
b += "/".concat(y);
|
|
78
|
-
else if (typeof y == "object") {
|
|
79
|
-
var m = Object.keys(y)[0], E = v(y[m], w);
|
|
80
|
-
b += "/".concat(m), E !== "" && (b += "(".concat(E, ")"));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return w.length > 0 && Object.assign(i, w.reduce(function(_, A) {
|
|
84
|
-
var j;
|
|
85
|
-
return Object.assign(_, (j = {}, j["@".concat(A.name)] = v(A.value), j));
|
|
86
|
-
}, {})), lt(b, S({ $select: r, $search: e, $skiptoken: o, $format: c }, i));
|
|
87
|
-
}
|
|
88
|
-
function B(t, n, r) {
|
|
89
|
-
return r === void 0 && (r = []), "".concat(t, " eq ").concat(v(n, r));
|
|
90
|
-
}
|
|
91
|
-
function T(t, n, r) {
|
|
92
|
-
return t === void 0 && (t = {}), n === void 0 && (n = []), r === void 0 && (r = ""), (Array.isArray(t) ? t : [t]).reduce(function(c, u) {
|
|
93
|
-
if (u) {
|
|
94
|
-
var p = e(u, n, r);
|
|
95
|
-
p && c.push(p);
|
|
96
|
-
}
|
|
97
|
-
return c;
|
|
98
|
-
}, []).join(" and ");
|
|
99
|
-
function e(c, u, p) {
|
|
100
|
-
c === void 0 && (c = {}), u === void 0 && (u = []), p === void 0 && (p = "");
|
|
101
|
-
var h = "";
|
|
102
|
-
if (typeof c == "string")
|
|
103
|
-
h = c;
|
|
104
|
-
else if (c && typeof c == "object") {
|
|
105
|
-
var O = Object.keys(c).reduce(function(f, d) {
|
|
106
|
-
var a = c[d];
|
|
107
|
-
if (a === void 0)
|
|
108
|
-
return f;
|
|
109
|
-
var s = "";
|
|
110
|
-
if (p ? d === g ? s = p : G.test(d) ? s = d.replace(G, function(i, m) {
|
|
111
|
-
return m.trim() === g ? "(".concat(p, ")") : "(".concat(p, "/").concat(m.trim(), ")");
|
|
112
|
-
}) : L.test(d) ? s = d.replace(L, function(i, m) {
|
|
113
|
-
return m.trim() === g ? "(".concat(p, ")") : "(".concat(p, "/").concat(m.trim(), ")");
|
|
114
|
-
}) : s = "".concat(p, "/").concat(d) : s = d, d === g && Array.isArray(a))
|
|
115
|
-
return f.concat(a.map(function(i) {
|
|
116
|
-
return B(s, i);
|
|
117
|
-
}));
|
|
118
|
-
if (["number", "string", "boolean"].indexOf(typeof a) !== -1 || a instanceof Date || a === null)
|
|
119
|
-
f.push(B(s, a, u));
|
|
120
|
-
else if (Array.isArray(a)) {
|
|
121
|
-
var l = d, y = a.map(function(i) {
|
|
122
|
-
return T(i, u, p);
|
|
123
|
-
}).filter(function(i) {
|
|
124
|
-
return i;
|
|
125
|
-
}).map(function(i) {
|
|
126
|
-
return $.indexOf(l) !== -1 ? "(".concat(i, ")") : i;
|
|
127
|
-
});
|
|
128
|
-
y.length && ($.indexOf(l) !== -1 ? y.length && (l === "not" ? f.push(H(y)) : f.push("(".concat(y.join(" ".concat(l, " ")), ")"))) : f.push(y.join(" ".concat(l, " "))));
|
|
129
|
-
} else if ($.indexOf(s) !== -1) {
|
|
130
|
-
var b = s, y = Object.keys(a).map(function(m) {
|
|
131
|
-
var E;
|
|
132
|
-
return e((E = {}, E[m] = a[m], E));
|
|
133
|
-
});
|
|
134
|
-
y.length && (b === "not" ? f.push(H(y)) : f.push("(".concat(y.join(" ".concat(b, " ")), ")")));
|
|
135
|
-
} else if (typeof a == "object")
|
|
136
|
-
if ("type" in a)
|
|
137
|
-
f.push(B(s, a, u));
|
|
138
|
-
else {
|
|
139
|
-
var w = Object.keys(a);
|
|
140
|
-
w.forEach(function(i) {
|
|
141
|
-
var m;
|
|
142
|
-
if (a[i] !== void 0)
|
|
143
|
-
if (st.indexOf(i) !== -1)
|
|
144
|
-
f.push("".concat(s, " ").concat(i, " ").concat(v(a[i], u)));
|
|
145
|
-
else if ($.indexOf(i) !== -1)
|
|
146
|
-
Array.isArray(a[i]) ? f.push(a[i].map(function(j) {
|
|
147
|
-
return "(" + e(j, u, s) + ")";
|
|
148
|
-
}).join(" ".concat(i, " "))) : f.push("(" + e(a[i], u, s) + ")");
|
|
149
|
-
else if (ut.indexOf(i) !== -1) {
|
|
150
|
-
var E = o(d.toLowerCase(), a[i], i, s);
|
|
151
|
-
E && f.push(E);
|
|
152
|
-
} else if (i === "has")
|
|
153
|
-
f.push("".concat(s, " ").concat(i, " ").concat(v(a[i], u)));
|
|
154
|
-
else if (i === "in") {
|
|
155
|
-
var _ = Array.isArray(a[i]) ? a[i] : a[i].value.map(function(j) {
|
|
156
|
-
return {
|
|
157
|
-
type: a[i].type,
|
|
158
|
-
value: j
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
f.push(s + " in (" + _.map(function(j) {
|
|
162
|
-
return v(j, u);
|
|
163
|
-
}).join(",") + ")");
|
|
164
|
-
} else if (ft.indexOf(i) !== -1)
|
|
165
|
-
f.push("".concat(i, "(").concat(s, ",").concat(v(a[i], u), ")"));
|
|
166
|
-
else {
|
|
167
|
-
var A = e((m = {}, m[i] = a[i], m), u, s);
|
|
168
|
-
A && f.push(A);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
else
|
|
173
|
-
throw new Error("Unexpected value type: ".concat(a));
|
|
174
|
-
return f;
|
|
175
|
-
}, []);
|
|
176
|
-
h = O.join(" and ");
|
|
177
|
-
}
|
|
178
|
-
return h;
|
|
179
|
-
}
|
|
180
|
-
function o(c, u, p, h) {
|
|
181
|
-
var O = "";
|
|
182
|
-
if (typeof u == "string" || u instanceof String)
|
|
183
|
-
O = yt(c, u, p, h);
|
|
184
|
-
else if (u) {
|
|
185
|
-
var f = Array.isArray(u) ? u.reduce(function(a, s) {
|
|
186
|
-
return s.hasOwnProperty(g) ? (a.hasOwnProperty(g) || (a[g] = []), a[g].push(s[g]), a) : S(S({}, a), s);
|
|
187
|
-
}, {}) : u, d = e(f, n, c);
|
|
188
|
-
O = "".concat(h, "/").concat(p, "(").concat(d ? "".concat(c, ":").concat(d) : "", ")");
|
|
189
|
-
}
|
|
190
|
-
return O;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function yt(t, n, r, e) {
|
|
194
|
-
var o = "", c = r == "all" ? "ne" : "eq";
|
|
195
|
-
return o = "".concat(e, "/").concat(r, "(").concat(t, ": ").concat(t, " ").concat(c, " '").concat(n, "')"), o;
|
|
196
|
-
}
|
|
197
|
-
function ht(t) {
|
|
198
|
-
return t = t.replace(/%/g, "%25"), t = t.replace(/\+/g, "%2B"), t = t.replace(/\//g, "%2F"), t = t.replace(/\?/g, "%3F"), t = t.replace(/#/g, "%23"), t = t.replace(/&/g, "%26"), t = t.replace(/'/g, "''"), t;
|
|
199
|
-
}
|
|
200
|
-
function v(t, n) {
|
|
201
|
-
if (typeof t == "string")
|
|
202
|
-
return "'".concat(ht(t), "'");
|
|
203
|
-
if (t instanceof Date)
|
|
204
|
-
return t.toISOString();
|
|
205
|
-
if (typeof t == "number")
|
|
206
|
-
return t;
|
|
207
|
-
if (Array.isArray(t))
|
|
208
|
-
return "[".concat(t.map(function(r) {
|
|
209
|
-
return v(r);
|
|
210
|
-
}).join(","), "]");
|
|
211
|
-
if (t === null)
|
|
212
|
-
return t;
|
|
213
|
-
if (typeof t == "object")
|
|
214
|
-
switch (t.type) {
|
|
215
|
-
case "raw":
|
|
216
|
-
case "guid":
|
|
217
|
-
return t.value;
|
|
218
|
-
case "duration":
|
|
219
|
-
return "duration'".concat(t.value, "'");
|
|
220
|
-
case "binary":
|
|
221
|
-
return "binary'".concat(t.value, "'");
|
|
222
|
-
case "alias":
|
|
223
|
-
return Array.isArray(n) && n.push(t), "@".concat(t.name);
|
|
224
|
-
case "json":
|
|
225
|
-
return escape(JSON.stringify(t.value));
|
|
226
|
-
case "decimal":
|
|
227
|
-
return "".concat(t.value, "M");
|
|
228
|
-
default:
|
|
229
|
-
return Object.entries(t).filter(function(r) {
|
|
230
|
-
var e = r[1];
|
|
231
|
-
return e !== void 0;
|
|
232
|
-
}).map(function(r) {
|
|
233
|
-
var e = r[0], o = r[1];
|
|
234
|
-
return "".concat(e, "=").concat(v(o, n));
|
|
235
|
-
}).join(",");
|
|
236
|
-
}
|
|
237
|
-
return t;
|
|
238
|
-
}
|
|
239
|
-
function k(t) {
|
|
240
|
-
if (typeof t == "number")
|
|
241
|
-
return t;
|
|
242
|
-
if (typeof t == "string")
|
|
243
|
-
return t.indexOf("/") === -1 ? t : t.split("/").reverse().reduce(function(r, e, o, c) {
|
|
244
|
-
return o === 0 ? "$expand=".concat(e) : o === c.length - 1 ? "".concat(e, "(").concat(r, ")") : "$expand=".concat(e, "(").concat(r, ")");
|
|
245
|
-
}, "");
|
|
246
|
-
if (Array.isArray(t))
|
|
247
|
-
return "".concat(t.map(function(r) {
|
|
248
|
-
return k(r);
|
|
249
|
-
}).join(","));
|
|
250
|
-
if (typeof t == "object") {
|
|
251
|
-
var n = Object.keys(t);
|
|
252
|
-
return n.some(function(r) {
|
|
253
|
-
return pt.indexOf(r.toLowerCase()) !== -1;
|
|
254
|
-
}) ? n.map(function(r) {
|
|
255
|
-
var e;
|
|
256
|
-
switch (r) {
|
|
257
|
-
case "filter":
|
|
258
|
-
e = T(t[r]);
|
|
259
|
-
break;
|
|
260
|
-
case "orderBy":
|
|
261
|
-
e = x(t[r]);
|
|
262
|
-
break;
|
|
263
|
-
case "levels":
|
|
264
|
-
case "count":
|
|
265
|
-
case "skip":
|
|
266
|
-
case "top":
|
|
267
|
-
e = "".concat(t[r]);
|
|
268
|
-
break;
|
|
269
|
-
default:
|
|
270
|
-
e = k(t[r]);
|
|
271
|
-
}
|
|
272
|
-
return "$".concat(r.toLowerCase(), "=").concat(e);
|
|
273
|
-
}).join(";") : n.map(function(r) {
|
|
274
|
-
var e = k(t[r]);
|
|
275
|
-
return e ? "".concat(r, "(").concat(e, ")") : r;
|
|
276
|
-
}).join(",");
|
|
277
|
-
}
|
|
278
|
-
return "";
|
|
279
|
-
}
|
|
280
|
-
function X(t) {
|
|
281
|
-
var n = Array.isArray(t) ? t : [t], r = n.reduce(function(e, o) {
|
|
282
|
-
var c = o.aggregate, u = o.filter, p = o.groupBy, h = it(o, ["aggregate", "filter", "groupBy"]), O = Object.keys(h);
|
|
283
|
-
if (O.length)
|
|
284
|
-
throw new Error("Unsupported transform(s): ".concat(O));
|
|
285
|
-
if (c && e.push("aggregate(".concat(Ot(c), ")")), u) {
|
|
286
|
-
var f = T(u);
|
|
287
|
-
f && e.push("filter(".concat(T(f), ")"));
|
|
288
|
-
}
|
|
289
|
-
return p && e.push("groupby(".concat(mt(p), ")")), e;
|
|
290
|
-
}, []);
|
|
291
|
-
return r.join("/") || void 0;
|
|
292
|
-
}
|
|
293
|
-
function Ot(t) {
|
|
294
|
-
var n = Array.isArray(t) ? t : [t];
|
|
295
|
-
return n.map(function(r) {
|
|
296
|
-
return typeof r == "string" ? r : Object.keys(r).map(function(e) {
|
|
297
|
-
var o = r[e];
|
|
298
|
-
if (!o.with && o.as)
|
|
299
|
-
return "".concat(e, " as ").concat(o.as);
|
|
300
|
-
if (!o.with)
|
|
301
|
-
throw new Error("'with' property required for '".concat(e, "'"));
|
|
302
|
-
if (!o.as)
|
|
303
|
-
throw new Error("'as' property required for '".concat(e, "'"));
|
|
304
|
-
return "".concat(e, " with ").concat(o.with, " as ").concat(o.as);
|
|
305
|
-
});
|
|
306
|
-
}).join(",");
|
|
307
|
-
}
|
|
308
|
-
function mt(t) {
|
|
309
|
-
if (!t.properties)
|
|
310
|
-
throw new Error("'properties' property required for groupBy");
|
|
311
|
-
var n = "(".concat(t.properties.join(","), ")");
|
|
312
|
-
return t.transform && (n += ",".concat(X(t.transform))), n;
|
|
313
|
-
}
|
|
314
|
-
function x(t, n) {
|
|
315
|
-
return n === void 0 && (n = ""), Array.isArray(t) ? t.map(function(r) {
|
|
316
|
-
return Array.isArray(r) && r.length === 2 && ["asc", "desc"].indexOf(r[1]) !== -1 ? r.join(" ") : r;
|
|
317
|
-
}).map(function(r) {
|
|
318
|
-
return "".concat(n).concat(String(r));
|
|
319
|
-
}).join(",") : typeof t == "object" ? Object.entries(t).map(function(r) {
|
|
320
|
-
var e = r[0], o = r[1];
|
|
321
|
-
return x(o, "".concat(e, "/"));
|
|
322
|
-
}).map(function(r) {
|
|
323
|
-
return "".concat(n).concat(r);
|
|
324
|
-
}).join(",") : "".concat(n).concat(String(t));
|
|
325
|
-
}
|
|
326
|
-
function lt(t, n) {
|
|
327
|
-
var r = Object.getOwnPropertyNames(n).filter(function(e) {
|
|
328
|
-
return n[e] !== void 0 && n[e] !== "";
|
|
329
|
-
}).map(function(e) {
|
|
330
|
-
return "".concat(e, "=").concat(n[e]);
|
|
331
|
-
});
|
|
332
|
-
return r.length ? "".concat(t, "?").concat(r.join("&")) : t;
|
|
333
|
-
}
|
|
334
|
-
function H(t) {
|
|
335
|
-
return "not (".concat(t.join(" and "), ")");
|
|
336
|
-
}
|
|
337
|
-
const St = (t, n, r, e = "GET", o) => {
|
|
338
|
-
const c = new Headers();
|
|
339
|
-
return c.append("Content-Type", "application/json"), n && c.append("orgId", n), r && c.append("languageId", r), c.append("Authorization", `Bearer ${t}`), o && o.forEach((u, p) => {
|
|
340
|
-
c.set(p, u);
|
|
341
|
-
}), {
|
|
342
|
-
redirect: "follow",
|
|
343
|
-
credentials: "omit",
|
|
344
|
-
method: e,
|
|
345
|
-
headers: c
|
|
346
|
-
};
|
|
347
|
-
}, bt = async (t, n, r = nt, e = !0) => {
|
|
348
|
-
const o = R.getState().throwError;
|
|
349
|
-
let c = Promise.resolve();
|
|
350
|
-
try {
|
|
351
|
-
c = await fetch(t, n);
|
|
352
|
-
} catch {
|
|
353
|
-
o?.("Network error", 500);
|
|
354
|
-
}
|
|
355
|
-
if (vt(c, t, n, r), c?.status === 401)
|
|
356
|
-
return o?.("Unauthorized", 401), q(c);
|
|
357
|
-
if (!e)
|
|
358
|
-
return q(c);
|
|
359
|
-
const u = Object.values(rt);
|
|
360
|
-
return r > 0 && u.includes(c?.status) ? bt(t, n, r - 1) : Et(c);
|
|
361
|
-
}, q = async (t) => {
|
|
362
|
-
const n = await t.text();
|
|
363
|
-
let r;
|
|
364
|
-
try {
|
|
365
|
-
r = JSON.parse(n);
|
|
366
|
-
} catch {
|
|
367
|
-
r = {
|
|
368
|
-
value: n
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
return r;
|
|
372
|
-
}, vt = async (t, n, r, e) => {
|
|
373
|
-
const o = t.clone(), c = R.getState().logEvent, u = R.getState().logError;
|
|
374
|
-
try {
|
|
375
|
-
t.ok && c ? c({
|
|
376
|
-
name: `request: ${o?.status.toString()} - ${n}`,
|
|
377
|
-
properties: {
|
|
378
|
-
try: e,
|
|
379
|
-
requestUrl: n,
|
|
380
|
-
requestHeaders: { ...r.headers, Authorization: void 0 },
|
|
381
|
-
requestMethod: r.method,
|
|
382
|
-
requestBody: U(r, "body"),
|
|
383
|
-
responseStatus: o?.status.toString(),
|
|
384
|
-
responseStatusText: o?.statusText,
|
|
385
|
-
responseBody: await q(o)
|
|
386
|
-
}
|
|
387
|
-
}) : u?.({
|
|
388
|
-
exception: {
|
|
389
|
-
name: `request: ${o?.status.toString()} - ${n}`,
|
|
390
|
-
message: o?.statusText
|
|
391
|
-
},
|
|
392
|
-
properties: {
|
|
393
|
-
requestUrl: n,
|
|
394
|
-
requestHeaders: { ...r.headers, Authorization: void 0 },
|
|
395
|
-
requestMethod: r.method,
|
|
396
|
-
requestBody: U(r, "body"),
|
|
397
|
-
responseStatus: o?.status.toString(),
|
|
398
|
-
responseStatusText: o?.statusText,
|
|
399
|
-
responseBody: await q(o)
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
} catch {
|
|
403
|
-
console.error("Error while tracking event or exception in AppInsights");
|
|
404
|
-
}
|
|
405
|
-
}, Et = async (t) => {
|
|
406
|
-
const n = R.getState().throwError;
|
|
407
|
-
if (t.ok)
|
|
408
|
-
return q(t);
|
|
409
|
-
const r = {
|
|
410
|
-
detail: t.statusText,
|
|
411
|
-
status: t.status,
|
|
412
|
-
stack: void 0,
|
|
413
|
-
title: "BaseError"
|
|
414
|
-
};
|
|
415
|
-
try {
|
|
416
|
-
const e = await t.json();
|
|
417
|
-
M(e) || (r.title = e.title ?? "UnexpectedError", r.stack = e.message ?? e.title ?? t.statusText, r.detail = e.detail);
|
|
418
|
-
} catch {
|
|
419
|
-
r.detail = t.statusText;
|
|
420
|
-
}
|
|
421
|
-
throw n?.(r.detail, r.status);
|
|
422
|
-
}, Tt = (t, n = !0) => {
|
|
423
|
-
const r = n ? "api-version=1.0" : "", e = n ? "?" : "", o = n ? "&" : "";
|
|
424
|
-
if (!t) return `${e}${r}`;
|
|
425
|
-
const {
|
|
426
|
-
filter: c = [],
|
|
427
|
-
orderBy: u = [],
|
|
428
|
-
select: p,
|
|
429
|
-
top: h,
|
|
430
|
-
skip: O,
|
|
431
|
-
expand: f = [],
|
|
432
|
-
count: d = !0,
|
|
433
|
-
overwrite: a = ""
|
|
434
|
-
// last resort for uncommon query string
|
|
435
|
-
} = t;
|
|
436
|
-
if (a)
|
|
437
|
-
return a;
|
|
438
|
-
{
|
|
439
|
-
const s = dt({
|
|
440
|
-
expand: f,
|
|
441
|
-
filter: c,
|
|
442
|
-
orderBy: u,
|
|
443
|
-
select: p,
|
|
444
|
-
top: h,
|
|
445
|
-
skip: O,
|
|
446
|
-
count: d
|
|
447
|
-
});
|
|
448
|
-
return M(s) ? `${e}${r}` : `${s}${o}${r}`;
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
export {
|
|
452
|
-
St as a,
|
|
453
|
-
Tt as b,
|
|
454
|
-
bt as f,
|
|
455
|
-
U as g,
|
|
456
|
-
Et as h,
|
|
457
|
-
M as i
|
|
458
|
-
};
|