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