vue-api-kit 1.10.2 → 1.10.3

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/index.js +29 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -48,9 +48,9 @@ function K(e) {
48
48
  const i = (m) => {
49
49
  if (m)
50
50
  for (const [d, t] of Object.entries(m)) {
51
- const n = `{${d}}`;
52
- r.url.includes(n) && (r.url = r.url.replace(
53
- n,
51
+ const o = `{${d}}`;
52
+ r.url.includes(o) && (r.url = r.url.replace(
53
+ o,
54
54
  encodeURIComponent(String(t))
55
55
  ), delete m[d]);
56
56
  }
@@ -87,9 +87,9 @@ function K(e) {
87
87
  if (d)
88
88
  if (z(d)) {
89
89
  const t = d;
90
- i[m] = (n) => {
90
+ i[m] = (o) => {
91
91
  let s;
92
- n && typeof n == "object" && ("loadOnMount" in n || "debounce" in n || "onResult" in n || "onError" in n || "onZodError" in n || "onBeforeRequest" in n || "data" in n ? s = n : s = { params: n });
92
+ o && typeof o == "object" && ("loadOnMount" in o || "debounce" in o || "onResult" in o || "onError" in o || "onZodError" in o || "onBeforeRequest" in o || "params" in o || "data" in o ? s = o : s = { params: o });
93
93
  const C = R(), g = R(), q = R(), j = R(!1), A = R(!1), B = R(!0);
94
94
  let w = new AbortController();
95
95
  const u = () => {
@@ -114,18 +114,18 @@ function K(e) {
114
114
  const f = await s.onBeforeRequest(c);
115
115
  f !== void 0 && Object.assign(c, f);
116
116
  }
117
- const h = await y.request(c), o = t.response ? t.response.parse(h.data) : h.data;
118
- C.value = o, s?.onResult?.(o);
117
+ const h = await y.request(c), n = t.response ? t.response.parse(h.data) : h.data;
118
+ C.value = n, s?.onResult?.(n);
119
119
  } catch (a) {
120
120
  if (a instanceof F) {
121
121
  if (a.code !== "ERR_CANCELED") {
122
- const c = a.config?.url, h = a.response?.data?.message || a.message || "An error occurred", o = a.response?.status, f = a.code, v = a.response?.data;
123
- g.value = h, s?.onError?.(a), e.onErrorRequest?.({ message: h, status: o, code: f, data: v, url: c });
122
+ const c = a.config?.url, h = a.response?.data?.message || a.message || "An error occurred", n = a.response?.status, f = a.code, v = a.response?.data;
123
+ g.value = h, s?.onError?.(a), e.onErrorRequest?.({ message: h, status: n, code: f, data: v, url: c });
124
124
  }
125
125
  } else if (a instanceof S) {
126
126
  q.value = a.issues || [];
127
127
  const h = `Validation error: ${q.value.map(
128
- (o) => `${o.path.join(".")}: ${o.message}`
128
+ (n) => `${n.path.join(".")}: ${n.message}`
129
129
  ).join(", ")}`;
130
130
  g.value = h, s?.onError?.(a), s?.onZodError?.(q.value), e.onErrorRequest?.({ message: h, code: "VALIDATION_ERROR" }), e.onZodError && e.onZodError(q.value);
131
131
  } else {
@@ -161,7 +161,7 @@ function K(e) {
161
161
  if (d)
162
162
  if (V(d)) {
163
163
  const t = d;
164
- i[m] = (n) => {
164
+ i[m] = (o) => {
165
165
  const s = R(), C = R(), g = R(), q = R(!1), j = R(!1), A = R(0);
166
166
  return { result: s, errorMessage: C, zodErrors: g, isLoading: q, isDone: j, uploadProgress: A, mutate: async (w) => {
167
167
  if (!q.value) {
@@ -170,12 +170,12 @@ function K(e) {
170
170
  const { data: u = {}, params: l } = w ?? {};
171
171
  let E = u ?? {}, p = {};
172
172
  if (t.isMultipart) {
173
- const o = new FormData();
173
+ const n = new FormData();
174
174
  for (const [f, v] of Object.entries(u))
175
- v instanceof File || v instanceof Blob ? o.append(f, v) : Array.isArray(v) ? v.forEach((P) => {
176
- P instanceof File || P instanceof Blob ? o.append(f, P) : o.append(f, JSON.stringify(P));
177
- }) : typeof v == "object" && v !== null ? o.append(f, JSON.stringify(v)) : o.append(f, String(v));
178
- E = o, p["Content-Type"] = "multipart/form-data";
175
+ v instanceof File || v instanceof Blob ? n.append(f, v) : Array.isArray(v) ? v.forEach((P) => {
176
+ P instanceof File || P instanceof Blob ? n.append(f, P) : n.append(f, JSON.stringify(P));
177
+ }) : typeof v == "object" && v !== null ? n.append(f, JSON.stringify(v)) : n.append(f, String(v));
178
+ E = n, p["Content-Type"] = "multipart/form-data";
179
179
  } else t.data && t.data.parse(u);
180
180
  t.params && l && t.params.parse(l);
181
181
  const a = {
@@ -184,36 +184,36 @@ function K(e) {
184
184
  data: E,
185
185
  params: l,
186
186
  headers: p,
187
- onUploadProgress: (o) => {
188
- if (o.total) {
189
- const f = Math.round(o.loaded * 100 / o.total);
190
- A.value = f, n?.onUploadProgress?.(f);
187
+ onUploadProgress: (n) => {
188
+ if (n.total) {
189
+ const f = Math.round(n.loaded * 100 / n.total);
190
+ A.value = f, o?.onUploadProgress?.(f);
191
191
  }
192
192
  }
193
193
  };
194
194
  if (t.onBeforeRequest) {
195
- const o = await t.onBeforeRequest(a);
196
- o !== void 0 && Object.assign(a, o);
195
+ const n = await t.onBeforeRequest(a);
196
+ n !== void 0 && Object.assign(a, n);
197
197
  }
198
- if (n?.onBeforeRequest) {
199
- const o = await n.onBeforeRequest(a);
200
- o !== void 0 && Object.assign(a, o);
198
+ if (o?.onBeforeRequest) {
199
+ const n = await o.onBeforeRequest(a);
200
+ n !== void 0 && Object.assign(a, n);
201
201
  }
202
202
  const c = await y.request(a), h = t.response ? t.response.parse(c.data) : c.data;
203
- s.value = h, n?.onResult?.(h);
203
+ s.value = h, o?.onResult?.(h);
204
204
  } catch (u) {
205
205
  if (u instanceof F) {
206
206
  const l = u.response?.data?.message || u.message || "An error occurred", E = u.response?.status, p = u.code;
207
- C.value = l, n?.onError?.(u), e.onErrorRequest?.({ message: l, status: E, code: p });
207
+ C.value = l, o?.onError?.(u), e.onErrorRequest?.({ message: l, status: E, code: p });
208
208
  } else if (u instanceof S) {
209
209
  g.value = u.issues || [];
210
210
  const E = `Validation error: ${g.value.map(
211
211
  (p) => `${p.path.join(".")}: ${p.message}`
212
212
  ).join(", ")}`;
213
- C.value = E, n?.onError?.(u), n?.onZodError?.(g.value), e.onErrorRequest?.({ message: E, code: "VALIDATION_ERROR" }), e.onZodError && e.onZodError(g.value);
213
+ C.value = E, o?.onError?.(u), o?.onZodError?.(g.value), e.onErrorRequest?.({ message: E, code: "VALIDATION_ERROR" }), e.onZodError && e.onZodError(g.value);
214
214
  } else {
215
215
  const l = u.message || "An error occurred";
216
- C.value = l, n?.onError?.(u), e.onErrorRequest?.({ message: l });
216
+ C.value = l, o?.onError?.(u), e.onErrorRequest?.({ message: l });
217
217
  }
218
218
  } finally {
219
219
  q.value = !1, j.value = !0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vue-api-kit",
3
3
  "type": "module",
4
- "version": "1.10.2",
4
+ "version": "1.10.3",
5
5
  "description": "A powerful and flexible API client for Vue 3 applications, built with TypeScript and Zod for type-safe API interactions.",
6
6
  "keywords": [
7
7
  "vue3",