@ventlio/tanstack-query 0.2.81 → 0.2.83

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/index.mjs CHANGED
@@ -715,8 +715,9 @@ const usePostRequest = ({ path, isFormData = false, baseUrl, headers, fileSelect
715
715
  };
716
716
  // register post mutation
717
717
  const mutation = useMutation(async (postData) => new Promise((res, rej) => sendRequest(res, rej, postData)));
718
- const post = async (data, options, requestConfig) => {
719
- return mutation.mutateAsync({ data, requestConfig }, options);
718
+ const post = async (data, options) => {
719
+ const { requestConfig, ...otherOptions } = options ?? {};
720
+ return mutation.mutateAsync({ data, requestConfig }, otherOptions);
720
721
  };
721
722
  return { post, uploadProgressPercent, ...mutation };
722
723
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -30,10 +30,16 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
30
30
  data: any;
31
31
  requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
32
32
  }, unknown>;
33
- post: <T>(data?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
33
+ post: <T>(data?: T | undefined, options?: (MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
34
34
  data: T;
35
35
  requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
36
- }, unknown> | undefined, requestConfig?: Partial<Omit<IMakeRequest, 'body'>>) => Promise<IRequestSuccess<TResponse>>;
36
+ }, unknown> & {
37
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
38
+ }) | ({
39
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
40
+ } & {
41
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
42
+ }) | undefined) => Promise<IRequestSuccess<TResponse>>;
37
43
  uploadProgressPercent: number;
38
44
  } | {
39
45
  data: undefined;
@@ -60,10 +66,16 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
60
66
  data: any;
61
67
  requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
62
68
  }, unknown>;
63
- post: <T>(data?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
69
+ post: <T>(data?: T | undefined, options?: (MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
64
70
  data: T;
65
71
  requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
66
- }, unknown> | undefined, requestConfig?: Partial<Omit<IMakeRequest, 'body'>>) => Promise<IRequestSuccess<TResponse>>;
72
+ }, unknown> & {
73
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
74
+ }) | ({
75
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
76
+ } & {
77
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
78
+ }) | undefined) => Promise<IRequestSuccess<TResponse>>;
67
79
  uploadProgressPercent: number;
68
80
  } | {
69
81
  data: undefined;
@@ -90,10 +102,16 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
90
102
  data: any;
91
103
  requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
92
104
  }, unknown>;
93
- post: <T>(data?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
105
+ post: <T>(data?: T | undefined, options?: (MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
94
106
  data: T;
95
107
  requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
96
- }, unknown> | undefined, requestConfig?: Partial<Omit<IMakeRequest, 'body'>>) => Promise<IRequestSuccess<TResponse>>;
108
+ }, unknown> & {
109
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
110
+ }) | ({
111
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
112
+ } & {
113
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
114
+ }) | undefined) => Promise<IRequestSuccess<TResponse>>;
97
115
  uploadProgressPercent: number;
98
116
  } | {
99
117
  data: IRequestSuccess<TResponse>;
@@ -120,9 +138,15 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
120
138
  data: any;
121
139
  requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
122
140
  }, unknown>;
123
- post: <T>(data?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
141
+ post: <T>(data?: T | undefined, options?: (MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
124
142
  data: T;
125
143
  requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
126
- }, unknown> | undefined, requestConfig?: Partial<Omit<IMakeRequest, 'body'>>) => Promise<IRequestSuccess<TResponse>>;
144
+ }, unknown> & {
145
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
146
+ }) | ({
147
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
148
+ } & {
149
+ requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
150
+ }) | undefined) => Promise<IRequestSuccess<TResponse>>;
127
151
  uploadProgressPercent: number;
128
152
  };
@@ -53,8 +53,9 @@ const usePostRequest = ({ path, isFormData = false, baseUrl, headers, fileSelect
53
53
  };
54
54
  // register post mutation
55
55
  const mutation = useMutation(async (postData) => new Promise((res, rej) => sendRequest(res, rej, postData)));
56
- const post = async (data, options, requestConfig) => {
57
- return mutation.mutateAsync({ data, requestConfig }, options);
56
+ const post = async (data, options) => {
57
+ const { requestConfig, ...otherOptions } = options ?? {};
58
+ return mutation.mutateAsync({ data, requestConfig }, otherOptions);
58
59
  };
59
60
  return { post, uploadProgressPercent, ...mutation };
60
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"usePostRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"usePostRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ventlio/tanstack-query",
3
- "version": "0.2.81",
3
+ "version": "0.2.83",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "contributors": [
@@ -80,17 +80,19 @@ export const usePostRequest = <TResponse>({
80
80
 
81
81
  const post = async <T>(
82
82
  data?: T,
83
- options?:
83
+ options?: (
84
84
  | MutateOptions<
85
85
  IRequestSuccess<TResponse>,
86
86
  IRequestError,
87
87
  { data: T; requestConfig?: Partial<Omit<IMakeRequest, 'body'>> },
88
88
  unknown
89
89
  >
90
- | undefined,
91
- requestConfig?: Partial<Omit<IMakeRequest, 'body'>>
90
+ | { requestConfig?: Partial<Omit<IMakeRequest, 'body'>> }
91
+ | undefined
92
+ ) & { requestConfig?: Partial<Omit<IMakeRequest, 'body'>> }
92
93
  ): Promise<IRequestSuccess<TResponse>> => {
93
- return mutation.mutateAsync({ data, requestConfig }, options);
94
+ const { requestConfig, ...otherOptions } = options ?? {};
95
+ return mutation.mutateAsync({ data, requestConfig }, otherOptions);
94
96
  };
95
97
 
96
98
  return { post, uploadProgressPercent, ...mutation };
@@ -6,7 +6,7 @@ import type { IMakeRequest } from './request.interface';
6
6
  import { errorTransformer, successTransformer } from './transformer';
7
7
 
8
8
  export async function makeRequest<TResponse>({
9
- body,
9
+ body = {},
10
10
  method = HttpMethod.GET,
11
11
  path,
12
12
  isFormData,