vue-api-kit 1.1.0 → 1.1.1

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.
@@ -43,5 +43,5 @@ import { ApiClientOptions, ApiMutation, ApiQuery, Infer, MutationResult, QueryRe
43
43
  */
44
44
  export declare function createApiClient<Q extends Record<string, ApiQuery>, M extends Record<string, ApiMutation>>(options: ApiClientOptions<Q, M>): {
45
45
  query: { [K in keyof Q]: (options?: UseQueryOptions<Infer<Q[K]["params"]>, Infer<Q[K]["response"]>>) => QueryResult<Infer<Q[K]["response"]>>; };
46
- mutation: { [K_1 in keyof M]: (options?: UseMutationOptions<Infer<M[K_1]["response"]>>) => MutationResult<Infer<M[K_1]["response"]>, Infer<M[K_1]["data"]>>; };
46
+ mutation: { [K_1 in keyof M]: (options?: UseMutationOptions<Infer<M[K_1]["response"]>>) => MutationResult<Infer<M[K_1]["response"]>, Infer<M[K_1]["data"]>, Infer<M[K_1]["params"]>>; };
47
47
  };
@@ -152,14 +152,15 @@ export interface QueryResult<TResult> {
152
152
  * // isLoading.value indicates loading state
153
153
  * // uploadProgress.value shows upload progress (0-100)
154
154
  */
155
- export interface MutationResult<TResult, TData> {
155
+ export interface MutationResult<TResult, TData = any, TParams = any> {
156
156
  result: Ref<TResult | undefined>;
157
157
  errorMessage: Ref<string | undefined>;
158
158
  zodErrors: Ref<Omit<$ZodIssue, "input">[] | undefined>;
159
159
  isLoading: Ref<boolean>;
160
160
  isDone: Ref<boolean>;
161
161
  uploadProgress: Ref<number>;
162
- mutate: (data: TData & {
163
- params?: any;
162
+ mutate: ({ data, params }: {
163
+ data?: TData;
164
+ params?: TParams;
164
165
  }) => Promise<void>;
165
166
  }
package/dist/index.js CHANGED
@@ -9909,22 +9909,22 @@ function Wm(e) {
9909
9909
  if (!h.value) {
9910
9910
  h.value = !0, d.value = void 0, m.value = 0;
9911
9911
  try {
9912
- const { params: k, ..._ } = b || {};
9913
- let w = _, S = {};
9912
+ const { data: k, params: _ } = b;
9913
+ let w = k ?? {}, S = {};
9914
9914
  if (u.isMultipart) {
9915
9915
  const Z = new FormData();
9916
- for (const [R, V] of Object.entries(_))
9916
+ for (const [R, V] of Object.entries(k))
9917
9917
  V instanceof File || V instanceof Blob ? Z.append(R, V) : Array.isArray(V) ? V.forEach((Je) => {
9918
9918
  Je instanceof File || Je instanceof Blob ? Z.append(R, Je) : Z.append(R, JSON.stringify(Je));
9919
9919
  }) : typeof V == "object" && V !== null ? Z.append(R, JSON.stringify(V)) : Z.append(R, String(V));
9920
9920
  w = Z, S["Content-Type"] = "multipart/form-data";
9921
- } else u.data && u.data.parse(_);
9922
- u.params && k && u.params.parse(k);
9921
+ } else u.data && u.data.parse(k);
9922
+ u.params && _ && u.params.parse(_);
9923
9923
  const x = await t.request({
9924
9924
  method: u.method,
9925
9925
  url: u.path,
9926
9926
  data: w,
9927
- params: k,
9927
+ params: _,
9928
9928
  headers: S,
9929
9929
  onUploadProgress: (Z) => {
9930
9930
  if (Z.total) {