@ventlio/tanstack-query 0.2.80 → 0.2.82
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
|
|
719
|
-
|
|
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
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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,22 @@ 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?: T | undefined, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
|
|
33
|
+
post: <T>(data?: T | undefined, options?: (MutateOptions<IRequestSuccess<TResponse>, IRequestError, {
|
|
34
34
|
data: T;
|
|
35
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
36
|
-
}, unknown>
|
|
35
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
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;
|
|
@@ -45,7 +51,7 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
45
51
|
status: "loading";
|
|
46
52
|
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
47
53
|
data: any;
|
|
48
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
54
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
49
55
|
}, unknown>;
|
|
50
56
|
reset: () => void;
|
|
51
57
|
context: unknown;
|
|
@@ -54,16 +60,22 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
54
60
|
isPaused: boolean;
|
|
55
61
|
variables: {
|
|
56
62
|
data: any;
|
|
57
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
63
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
58
64
|
} | undefined;
|
|
59
65
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
60
66
|
data: any;
|
|
61
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
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
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
66
|
-
}, unknown>
|
|
71
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
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;
|
|
@@ -75,7 +87,7 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
75
87
|
status: "error";
|
|
76
88
|
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
77
89
|
data: any;
|
|
78
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
90
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
79
91
|
}, unknown>;
|
|
80
92
|
reset: () => void;
|
|
81
93
|
context: unknown;
|
|
@@ -84,16 +96,22 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
84
96
|
isPaused: boolean;
|
|
85
97
|
variables: {
|
|
86
98
|
data: any;
|
|
87
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
99
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
88
100
|
} | undefined;
|
|
89
101
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
90
102
|
data: any;
|
|
91
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
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
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
96
|
-
}, unknown>
|
|
107
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
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>;
|
|
@@ -105,7 +123,7 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
105
123
|
status: "success";
|
|
106
124
|
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
107
125
|
data: any;
|
|
108
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
126
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
109
127
|
}, unknown>;
|
|
110
128
|
reset: () => void;
|
|
111
129
|
context: unknown;
|
|
@@ -114,15 +132,21 @@ export declare const usePostRequest: <TResponse>({ path, isFormData, baseUrl, he
|
|
|
114
132
|
isPaused: boolean;
|
|
115
133
|
variables: {
|
|
116
134
|
data: any;
|
|
117
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
135
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
118
136
|
} | undefined;
|
|
119
137
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, {
|
|
120
138
|
data: any;
|
|
121
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
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
|
-
requestConfig?: Omit<IMakeRequest, "body"
|
|
126
|
-
}, unknown>
|
|
143
|
+
requestConfig?: Partial<Omit<IMakeRequest, "body">> | undefined;
|
|
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
|
|
57
|
-
|
|
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
|
@@ -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,22 +75,24 @@ 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
82
|
data?: T,
|
|
83
|
-
options?:
|
|
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
|
-
|
|
|
91
|
-
|
|
90
|
+
| { requestConfig?: Partial<Omit<IMakeRequest, 'body'>> }
|
|
91
|
+
| undefined
|
|
92
|
+
) & { requestConfig?: Partial<Omit<IMakeRequest, 'body'>> }
|
|
92
93
|
): Promise<IRequestSuccess<TResponse>> => {
|
|
93
|
-
|
|
94
|
+
const { requestConfig, ...otherOptions } = options ?? {};
|
|
95
|
+
return mutation.mutateAsync({ data, requestConfig }, otherOptions);
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
return { post, uploadProgressPercent, ...mutation };
|