@ventlio/tanstack-query 0.2.79 → 0.2.81
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.
|
@@ -15,7 +15,7 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
15
15
|
status: "idle";
|
|
16
16
|
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
17
17
|
data: any;
|
|
18
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
18
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
19
19
|
}, unknown>;
|
|
20
20
|
reset: () => void;
|
|
21
21
|
context: unknown;
|
|
@@ -24,16 +24,16 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
24
24
|
isPaused: boolean;
|
|
25
25
|
variables: {
|
|
26
26
|
data: any;
|
|
27
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
27
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
28
28
|
} | undefined;
|
|
29
29
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
30
30
|
data: any;
|
|
31
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
31
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
32
32
|
}, unknown>;
|
|
33
|
-
post: <T>(data
|
|
33
|
+
post: <T>(data?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
|
|
34
34
|
data: T;
|
|
35
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
36
|
-
}, unknown> | undefined, requestConfig?: Omit<IMakeRequest, 'body'
|
|
35
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
36
|
+
}, unknown> | undefined, requestConfig?: Partial<Omit<IMakeRequest, 'body'>>) => Promise<IRequestSuccess<TResponse>>;
|
|
37
37
|
uploadProgressPercent: number;
|
|
38
38
|
} | {
|
|
39
39
|
data: undefined;
|
|
@@ -45,7 +45,7 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
45
45
|
status: "loading";
|
|
46
46
|
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
47
47
|
data: any;
|
|
48
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
48
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
49
49
|
}, unknown>;
|
|
50
50
|
reset: () => void;
|
|
51
51
|
context: unknown;
|
|
@@ -54,16 +54,16 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
54
54
|
isPaused: boolean;
|
|
55
55
|
variables: {
|
|
56
56
|
data: any;
|
|
57
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
57
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
58
58
|
} | undefined;
|
|
59
59
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
60
60
|
data: any;
|
|
61
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
61
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
62
62
|
}, unknown>;
|
|
63
|
-
post: <T>(data
|
|
63
|
+
post: <T>(data?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
|
|
64
64
|
data: T;
|
|
65
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
66
|
-
}, unknown> | undefined, requestConfig?: Omit<IMakeRequest, 'body'
|
|
65
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
66
|
+
}, unknown> | undefined, requestConfig?: Partial<Omit<IMakeRequest, 'body'>>) => Promise<IRequestSuccess<TResponse>>;
|
|
67
67
|
uploadProgressPercent: number;
|
|
68
68
|
} | {
|
|
69
69
|
data: undefined;
|
|
@@ -75,7 +75,7 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
75
75
|
status: "error";
|
|
76
76
|
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
77
77
|
data: any;
|
|
78
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
78
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
79
79
|
}, unknown>;
|
|
80
80
|
reset: () => void;
|
|
81
81
|
context: unknown;
|
|
@@ -84,16 +84,16 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
84
84
|
isPaused: boolean;
|
|
85
85
|
variables: {
|
|
86
86
|
data: any;
|
|
87
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
87
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
88
88
|
} | undefined;
|
|
89
89
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
90
90
|
data: any;
|
|
91
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
91
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
92
92
|
}, unknown>;
|
|
93
|
-
post: <T>(data
|
|
93
|
+
post: <T>(data?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
|
|
94
94
|
data: T;
|
|
95
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
96
|
-
}, unknown> | undefined, requestConfig?: Omit<IMakeRequest, 'body'
|
|
95
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
96
|
+
}, unknown> | undefined, requestConfig?: Partial<Omit<IMakeRequest, 'body'>>) => Promise<IRequestSuccess<TResponse>>;
|
|
97
97
|
uploadProgressPercent: number;
|
|
98
98
|
} | {
|
|
99
99
|
data: IRequestSuccess<TResponse>;
|
|
@@ -105,7 +105,7 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
105
105
|
status: "success";
|
|
106
106
|
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
107
107
|
data: any;
|
|
108
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
108
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
109
109
|
}, unknown>;
|
|
110
110
|
reset: () => void;
|
|
111
111
|
context: unknown;
|
|
@@ -114,15 +114,15 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
114
114
|
isPaused: boolean;
|
|
115
115
|
variables: {
|
|
116
116
|
data: any;
|
|
117
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
117
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
118
118
|
} | undefined;
|
|
119
119
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
120
120
|
data: any;
|
|
121
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
121
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
122
122
|
}, unknown>;
|
|
123
|
-
post: <T>(data
|
|
123
|
+
post: <T>(data?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
|
|
124
124
|
data: T;
|
|
125
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
126
|
-
}, unknown> | undefined, requestConfig?: Omit<IMakeRequest, 'body'
|
|
125
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
126
|
+
}, unknown> | undefined, requestConfig?: Partial<Omit<IMakeRequest, 'body'>>) => Promise<IRequestSuccess<TResponse>>;
|
|
127
127
|
uploadProgressPercent: number;
|
|
128
128
|
};
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ export const usePostRequest = <TResponse>({
|
|
|
30
30
|
const sendRequest = async (
|
|
31
31
|
res: (value: any) => void,
|
|
32
32
|
rej: (reason?: any) => void,
|
|
33
|
-
postData: { data: any; requestConfig?: IMakeRequest }
|
|
33
|
+
postData: { data: any; requestConfig?: Partial<IMakeRequest> }
|
|
34
34
|
) => {
|
|
35
35
|
// get request headers
|
|
36
36
|
const globalHeaders: RawAxiosRequestHeaders = getHeaders();
|
|
@@ -75,20 +75,20 @@ export const usePostRequest = <TResponse>({
|
|
|
75
75
|
const mutation = useMutation<
|
|
76
76
|
IRequestSuccess<TResponse>,
|
|
77
77
|
IRequestError,
|
|
78
|
-
{ data: any; requestConfig?: Omit<IMakeRequest, 'body'
|
|
78
|
+
{ data: any; requestConfig?: Partial<Omit<IMakeRequest, 'body'>> }
|
|
79
79
|
>(async (postData) => new Promise<IRequestSuccess<TResponse>>((res, rej) => sendRequest(res, rej, postData)));
|
|
80
80
|
|
|
81
81
|
const post = async <T>(
|
|
82
|
-
data
|
|
82
|
+
data?: T,
|
|
83
83
|
options?:
|
|
84
84
|
| MutateOptions<
|
|
85
85
|
IRequestSuccess<TResponse>,
|
|
86
86
|
IRequestError,
|
|
87
|
-
{ data: T; requestConfig?: Omit<IMakeRequest, 'body'
|
|
87
|
+
{ data: T; requestConfig?: Partial<Omit<IMakeRequest, 'body'>> },
|
|
88
88
|
unknown
|
|
89
89
|
>
|
|
90
90
|
| undefined,
|
|
91
|
-
requestConfig?: Omit<IMakeRequest, 'body'
|
|
91
|
+
requestConfig?: Partial<Omit<IMakeRequest, 'body'>>
|
|
92
92
|
): Promise<IRequestSuccess<TResponse>> => {
|
|
93
93
|
return mutation.mutateAsync({ data, requestConfig }, options);
|
|
94
94
|
};
|