fina-react-ds 1.0.30 → 1.0.32

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.
Files changed (2) hide show
  1. package/dist/lib/http.js +32 -31
  2. 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, r) => p(t, "name", { value: r, configurable: !0 });
2
+ var n = (t, e) => p(t, "name", { value: e, configurable: !0 });
3
3
  import m from "qs";
4
- const h = /* @__PURE__ */ n((t) => t != null, "valueExists"), j = /* @__PURE__ */ n((t, r) => {
5
- if (t) {
4
+ const g = /* @__PURE__ */ n((t) => t != null, "valueExists"), j = /* @__PURE__ */ n((t, e) => {
5
+ if (console.log("Super kéké"), !!t) {
6
6
  if (t instanceof FormData)
7
7
  return t;
8
- if (r) {
9
- const a = new FormData();
10
- return Object.keys(t).forEach((e) => {
11
- if (Array.isArray(t[e]))
12
- for (const s of t[e])
13
- a.append(`${e}[]`, s || "");
14
- else
15
- a.append(e, h(t[e]) ? t[e] : "");
16
- }), a;
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"), d = /* @__PURE__ */ n((t, r = null) => {
21
- let a = t;
22
- return r && (a += `?${m.stringify(r, { encode: !1 })}`), a;
23
- }, "formatUrlForRequest"), v = /* @__PURE__ */ n(async (t, r, a = null, e = null, s = null, i = !1) => {
24
- const u = new Headers({
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
- ...s
27
+ ...a
27
28
  });
28
- !i && !(e instanceof FormData) && u.append("Content-Type", "application/json");
29
- const l = {
29
+ !l && !(r instanceof FormData) && c.append("Content-Type", "application/json");
30
+ const i = {
30
31
  method: t,
31
- headers: u,
32
- body: j(e, i)
32
+ headers: c,
33
+ body: j(r, l)
33
34
  };
34
35
  let o = null;
35
- const c = await fetch(
36
- d(r, a),
37
- l
36
+ const u = await fetch(
37
+ h(e, s),
38
+ i
38
39
  ).catch((f) => (o = f, null));
39
- return o ? Promise.reject(o) : g(c);
40
- }, "requestApi"), g = /* @__PURE__ */ n(async (t) => {
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 r = await (t.headers.get("Content-Type") === "application/json" ? t.json() : t.blob()).catch(() => "Response parsing error");
44
- return t.status >= 200 && t.status < 300 ? Promise.resolve(r) : t.status >= 400 && t.status <= 500 ? Promise.reject({
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: r,
47
- message: r
47
+ raw: e,
48
+ message: e
48
49
  }) : Promise.reject({
49
50
  status: t.status,
50
51
  raw: "",
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "https://github.com/F1na/fina-react-ds"
6
6
  },
7
7
  "private": false,
8
- "version": "1.0.30",
8
+ "version": "1.0.32",
9
9
  "type": "module",
10
10
  "files": [
11
11
  "dist"