fina-react-ds 1.0.30 → 1.0.31
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/lib/http.js +31 -30
- package/package.json +1 -1
package/dist/lib/http.js
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
1
|
var p = Object.defineProperty;
|
|
2
|
-
var n = (t,
|
|
2
|
+
var n = (t, e) => p(t, "name", { value: e, configurable: !0 });
|
|
3
3
|
import m from "qs";
|
|
4
|
-
const
|
|
4
|
+
const g = /* @__PURE__ */ n((t) => t != null, "valueExists"), j = /* @__PURE__ */ n((t, e) => {
|
|
5
5
|
if (t) {
|
|
6
6
|
if (t instanceof FormData)
|
|
7
7
|
return t;
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
return Object.keys(t).forEach((
|
|
11
|
-
if (Array.isArray(t[
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
if (e) {
|
|
9
|
+
const s = new FormData();
|
|
10
|
+
return console.log(t), console.log(Object.keys(t)), Object.keys(t).forEach((r) => {
|
|
11
|
+
if (console.log(r), Array.isArray(t[r])) {
|
|
12
|
+
console.log("array");
|
|
13
|
+
for (const a of t[r])
|
|
14
|
+
s.append(`${r}[]`, a || "");
|
|
15
|
+
} else
|
|
16
|
+
s.append(r, g(t[r]) ? t[r] : "");
|
|
17
|
+
}), s;
|
|
17
18
|
}
|
|
18
19
|
return JSON.stringify(t);
|
|
19
20
|
}
|
|
20
|
-
}, "formatBodyForRequest"),
|
|
21
|
-
let
|
|
22
|
-
return
|
|
23
|
-
}, "formatUrlForRequest"), v = /* @__PURE__ */ n(async (t,
|
|
24
|
-
const
|
|
21
|
+
}, "formatBodyForRequest"), h = /* @__PURE__ */ n((t, e = null) => {
|
|
22
|
+
let s = t;
|
|
23
|
+
return e && (s += `?${m.stringify(e, { encode: !1 })}`), s;
|
|
24
|
+
}, "formatUrlForRequest"), v = /* @__PURE__ */ n(async (t, e, s = null, r = null, a = null, l = !1) => {
|
|
25
|
+
const c = new Headers({
|
|
25
26
|
Accept: "application/json",
|
|
26
|
-
...
|
|
27
|
+
...a
|
|
27
28
|
});
|
|
28
|
-
!
|
|
29
|
-
const
|
|
29
|
+
!l && !(r instanceof FormData) && c.append("Content-Type", "application/json");
|
|
30
|
+
const i = {
|
|
30
31
|
method: t,
|
|
31
|
-
headers:
|
|
32
|
-
body: j(
|
|
32
|
+
headers: c,
|
|
33
|
+
body: j(r, l)
|
|
33
34
|
};
|
|
34
35
|
let o = null;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const u = await fetch(
|
|
37
|
+
h(e, s),
|
|
38
|
+
i
|
|
38
39
|
).catch((f) => (o = f, null));
|
|
39
|
-
return o ? Promise.reject(o) :
|
|
40
|
-
}, "requestApi"),
|
|
40
|
+
return o ? Promise.reject(o) : w(u);
|
|
41
|
+
}, "requestApi"), w = /* @__PURE__ */ n(async (t) => {
|
|
41
42
|
if (t.status === 204)
|
|
42
43
|
return Promise.resolve(null);
|
|
43
|
-
const
|
|
44
|
-
return t.status >= 200 && t.status < 300 ? Promise.resolve(
|
|
44
|
+
const e = await (t.headers.get("Content-Type") === "application/json" ? t.json() : t.blob()).catch(() => "Response parsing error");
|
|
45
|
+
return t.status >= 200 && t.status < 300 ? Promise.resolve(e) : t.status >= 400 && t.status <= 500 ? Promise.reject({
|
|
45
46
|
status: t.status,
|
|
46
|
-
raw:
|
|
47
|
-
message:
|
|
47
|
+
raw: e,
|
|
48
|
+
message: e
|
|
48
49
|
}) : Promise.reject({
|
|
49
50
|
status: t.status,
|
|
50
51
|
raw: "",
|