@ventlio/tanstack-query 0.5.3 → 0.5.5
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/config/bootstrapQueryRequest.d.ts +4 -4
- package/dist/config/bootstrapQueryRequest.js +15 -15
- package/dist/config/config.interface.d.ts +4 -4
- package/dist/config/index.d.ts +6 -6
- package/dist/config/useEnvironmentVariables.d.ts +2 -2
- package/dist/config/useEnvironmentVariables.js +8 -8
- package/dist/config/useQueryConfig.d.ts +2 -2
- package/dist/config/useQueryConfig.js +5 -5
- package/dist/config/useQueryHeaders.d.ts +2 -2
- package/dist/config/useQueryHeaders.js +9 -9
- package/dist/config/useReactNativeEnv.d.ts +5 -5
- package/dist/config/useReactNativeEnv.js +6 -6
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/scrollToTop.d.ts +1 -1
- package/dist/helpers/scrollToTop.js +5 -5
- package/dist/helpers/timeFuncs.d.ts +1 -1
- package/dist/helpers/timeFuncs.js +7 -7
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useUploadProgress.d.ts +5 -5
- package/dist/hooks/useUploadProgress.js +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +907 -830
- package/dist/index.mjs.map +1 -1
- package/dist/model/index.d.ts +4 -4
- package/dist/model/model.interface.d.ts +11 -11
- package/dist/model/useKeyTrackerModel.d.ts +4 -4
- package/dist/model/useKeyTrackerModel.js +14 -14
- package/dist/model/useQueryModel.d.ts +2 -2
- package/dist/model/useQueryModel.js +115 -115
- package/dist/model/useRefetchQuery.d.ts +3 -3
- package/dist/model/useRefetchQuery.js +10 -10
- package/dist/queries/index.d.ts +6 -6
- package/dist/queries/queries.interface.d.ts +17 -17
- package/dist/queries/useDeleteRequest.d.ts +60 -60
- package/dist/queries/useDeleteRequest.js +86 -71
- package/dist/queries/useDeleteRequest.js.map +1 -1
- package/dist/queries/useGetInfiniteRequest.d.ts +108 -110
- package/dist/queries/useGetInfiniteRequest.js +117 -102
- package/dist/queries/useGetInfiniteRequest.js.map +1 -1
- package/dist/queries/useGetRequest.d.ts +73 -74
- package/dist/queries/useGetRequest.js +148 -133
- package/dist/queries/useGetRequest.js.map +1 -1
- package/dist/queries/usePatchRequest.d.ts +86 -86
- package/dist/queries/usePatchRequest.js +86 -70
- package/dist/queries/usePatchRequest.js.map +1 -1
- package/dist/queries/usePostRequest.d.ts +149 -157
- package/dist/queries/usePostRequest.js +94 -78
- package/dist/queries/usePostRequest.js.map +1 -1
- package/dist/queries/usePutRequest.d.ts +86 -86
- package/dist/request/axios-instance.d.ts +3 -3
- package/dist/request/axios-instance.js +6 -6
- package/dist/request/buildFormData.d.ts +1 -1
- package/dist/request/buildFormData.js +40 -40
- package/dist/request/index.d.ts +6 -6
- package/dist/request/make-request.d.ts +2 -2
- package/dist/request/make-request.js +80 -80
- package/dist/request/request.enum.d.ts +11 -11
- package/dist/request/request.enum.js +12 -12
- package/dist/request/request.interface.d.ts +48 -48
- package/dist/request/transformer.d.ts +7 -7
- package/dist/request/transformer.js +18 -18
- package/dist/stores/index.d.ts +2 -2
- package/dist/stores/useHeaderStore.d.ts +7 -7
- package/dist/stores/useHeaderStore.js +5 -5
- package/dist/stores/usePauseFutureRequests.d.ts +7 -7
- package/dist/stores/usePauseFutureRequests.js +13 -13
- package/dist/types/index.d.ts +34 -29
- package/package.json +2 -2
- package/src/queries/useDeleteRequest.ts +24 -5
- package/src/queries/useGetInfiniteRequest.ts +21 -2
- package/src/queries/useGetRequest.ts +26 -9
- package/src/queries/usePatchRequest.ts +21 -1
- package/src/queries/usePostRequest.ts +21 -1
- package/src/queries/usePutRequest.ts +21 -1
- package/src/request/make-request.ts +3 -3
- package/src/request/transformer.ts +1 -1
- package/src/types/index.ts +5 -1
|
@@ -1,74 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { IRequestError, IRequestSuccess } from '../request';
|
|
3
|
+
import { DefaultRequestOptions, TanstackQueryOption } from './queries.interface';
|
|
4
|
+
export declare const useGetRequest: <TResponse extends Record<string, any>>({ path, load, queryOptions, keyTracker, baseUrl, headers, }: {
|
|
5
|
+
path: string;
|
|
6
|
+
load?: boolean;
|
|
7
|
+
queryOptions?: TanstackQueryOption<TResponse>;
|
|
8
|
+
keyTracker?: string;
|
|
9
|
+
} & DefaultRequestOptions) => {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
setRequestPath: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
12
|
+
nextPage: () => void;
|
|
13
|
+
prevPage: () => void;
|
|
14
|
+
get: (link: string, fetchOptions?: UseQueryOptions<IRequestSuccess<TResponse | undefined>, IRequestError, IRequestSuccess<TResponse | undefined>, Array<any>>) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
15
|
+
gotoPage: (pageNumber: number) => void;
|
|
16
|
+
page: number;
|
|
17
|
+
queryKey: {}[];
|
|
18
|
+
data: IRequestSuccess<TResponse>;
|
|
19
|
+
error: any;
|
|
20
|
+
isError: true;
|
|
21
|
+
isPending: false;
|
|
22
|
+
isLoadingError: false;
|
|
23
|
+
isRefetchError: true;
|
|
24
|
+
isSuccess: false;
|
|
25
|
+
status: "error";
|
|
26
|
+
dataUpdatedAt: number;
|
|
27
|
+
errorUpdatedAt: number;
|
|
28
|
+
failureCount: number;
|
|
29
|
+
failureReason: any;
|
|
30
|
+
errorUpdateCount: number;
|
|
31
|
+
isFetched: boolean;
|
|
32
|
+
isFetchedAfterMount: boolean;
|
|
33
|
+
isFetching: boolean;
|
|
34
|
+
isInitialLoading: boolean;
|
|
35
|
+
isPaused: boolean;
|
|
36
|
+
isPlaceholderData: boolean;
|
|
37
|
+
isRefetching: boolean;
|
|
38
|
+
isStale: boolean;
|
|
39
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<IRequestSuccess<TResponse>, any>>;
|
|
40
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
41
|
+
} | {
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
setRequestPath: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
44
|
+
nextPage: () => void;
|
|
45
|
+
prevPage: () => void;
|
|
46
|
+
get: (link: string, fetchOptions?: UseQueryOptions<IRequestSuccess<TResponse | undefined>, IRequestError, IRequestSuccess<TResponse | undefined>, Array<any>>) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
47
|
+
gotoPage: (pageNumber: number) => void;
|
|
48
|
+
page: number;
|
|
49
|
+
queryKey: {}[];
|
|
50
|
+
data: IRequestSuccess<TResponse>;
|
|
51
|
+
error: null;
|
|
52
|
+
isError: false;
|
|
53
|
+
isPending: false;
|
|
54
|
+
isLoadingError: false;
|
|
55
|
+
isRefetchError: false;
|
|
56
|
+
isSuccess: true;
|
|
57
|
+
status: "success";
|
|
58
|
+
dataUpdatedAt: number;
|
|
59
|
+
errorUpdatedAt: number;
|
|
60
|
+
failureCount: number;
|
|
61
|
+
failureReason: any;
|
|
62
|
+
errorUpdateCount: number;
|
|
63
|
+
isFetched: boolean;
|
|
64
|
+
isFetchedAfterMount: boolean;
|
|
65
|
+
isFetching: boolean;
|
|
66
|
+
isInitialLoading: boolean;
|
|
67
|
+
isPaused: boolean;
|
|
68
|
+
isPlaceholderData: boolean;
|
|
69
|
+
isRefetching: boolean;
|
|
70
|
+
isStale: boolean;
|
|
71
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<IRequestSuccess<TResponse>, any>>;
|
|
72
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
73
|
+
};
|
|
@@ -9,139 +9,154 @@ import 'axios';
|
|
|
9
9
|
import { makeRequest } from '../request/make-request.js';
|
|
10
10
|
import '../request/request.enum.js';
|
|
11
11
|
|
|
12
|
-
const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl, headers, }) => {
|
|
13
|
-
const [requestPath, setRequestPath] = useState(path);
|
|
14
|
-
const [options, setOptions] = useState(queryOptions);
|
|
15
|
-
const [page, setPage] = useState(1);
|
|
16
|
-
const { API_URL, TIMEOUT } = useEnvironmentVariables();
|
|
17
|
-
const globalHeaders = useHeaderStore((state) => state.headers);
|
|
18
|
-
const { options: queryConfigOptions } = useQueryConfig();
|
|
19
|
-
const [requestPayload, setRequestPayload] = useState();
|
|
20
|
-
const isFutureQueriesPaused = usePauseFutureRequests((state) => state.isFutureQueriesPaused);
|
|
21
|
-
let queryClient = useQueryClient();
|
|
22
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
-
queryClient = useMemo(() => queryClient, []);
|
|
24
|
-
const sendRequest = async (res, rej, queryKey) => {
|
|
25
|
-
if (load) {
|
|
26
|
-
const [url] = queryKey;
|
|
27
|
-
const requestUrl = (url ?? requestPath);
|
|
28
|
-
const requestOptions = {
|
|
29
|
-
path: requestUrl,
|
|
30
|
-
headers: { ...globalHeaders, ...headers },
|
|
31
|
-
baseURL: baseUrl ?? API_URL,
|
|
32
|
-
timeout: TIMEOUT,
|
|
33
|
-
};
|
|
34
|
-
let shouldContinue = true;
|
|
35
|
-
if (queryConfigOptions?.queryMiddleware) {
|
|
36
|
-
shouldContinue = await queryConfigOptions.queryMiddleware({ queryKey, ...requestOptions });
|
|
37
|
-
}
|
|
38
|
-
if (shouldContinue) {
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
12
|
+
const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl, headers, }) => {
|
|
13
|
+
const [requestPath, setRequestPath] = useState(path);
|
|
14
|
+
const [options, setOptions] = useState(queryOptions);
|
|
15
|
+
const [page, setPage] = useState(1);
|
|
16
|
+
const { API_URL, TIMEOUT } = useEnvironmentVariables();
|
|
17
|
+
const globalHeaders = useHeaderStore((state) => state.headers);
|
|
18
|
+
const { options: queryConfigOptions } = useQueryConfig();
|
|
19
|
+
const [requestPayload, setRequestPayload] = useState();
|
|
20
|
+
const isFutureQueriesPaused = usePauseFutureRequests((state) => state.isFutureQueriesPaused);
|
|
21
|
+
let queryClient = useQueryClient();
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
+
queryClient = useMemo(() => queryClient, []);
|
|
24
|
+
const sendRequest = async (res, rej, queryKey) => {
|
|
25
|
+
if (load) {
|
|
26
|
+
const [url] = queryKey;
|
|
27
|
+
const requestUrl = (url ?? requestPath);
|
|
28
|
+
const requestOptions = {
|
|
29
|
+
path: requestUrl,
|
|
30
|
+
headers: { ...globalHeaders, ...headers },
|
|
31
|
+
baseURL: baseUrl ?? API_URL,
|
|
32
|
+
timeout: TIMEOUT,
|
|
33
|
+
};
|
|
34
|
+
let shouldContinue = true;
|
|
35
|
+
if (queryConfigOptions?.queryMiddleware) {
|
|
36
|
+
shouldContinue = await queryConfigOptions.queryMiddleware({ queryKey, ...requestOptions });
|
|
37
|
+
}
|
|
38
|
+
if (shouldContinue) {
|
|
39
|
+
let getResponse;
|
|
40
|
+
if (queryConfigOptions?.middleware) {
|
|
41
|
+
// perform global middleware
|
|
42
|
+
const middlewareResponse = await queryConfigOptions.middleware(async () => await makeRequest(requestOptions), {
|
|
43
|
+
path,
|
|
44
|
+
baseUrl: baseUrl ?? API_URL,
|
|
45
|
+
});
|
|
46
|
+
if (!middlewareResponse) {
|
|
47
|
+
rej();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
getResponse = middlewareResponse;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
getResponse = await makeRequest(requestOptions);
|
|
54
|
+
}
|
|
55
|
+
if (getResponse.status) {
|
|
56
|
+
res(getResponse);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
rej(getResponse);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
rej(null);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
res(null);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const query = useQuery({
|
|
71
|
+
queryKey: [requestPath, {}],
|
|
72
|
+
queryFn: ({ queryKey }) => new Promise((res, rej) => sendRequest(res, rej, queryKey)),
|
|
73
|
+
enabled: load && !isFutureQueriesPaused,
|
|
74
|
+
...options,
|
|
75
|
+
});
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (path) {
|
|
78
|
+
setRequestPath(path);
|
|
79
|
+
}
|
|
80
|
+
}, [path]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (keyTracker) {
|
|
83
|
+
// set expiration time for the tracker
|
|
84
|
+
queryClient.setQueryDefaults([keyTracker], {
|
|
85
|
+
staleTime: Infinity,
|
|
86
|
+
});
|
|
87
|
+
queryClient.setQueryData([keyTracker], [requestPath, {}]);
|
|
88
|
+
}
|
|
89
|
+
}, [keyTracker, requestPath, queryClient, queryOptions?.staleTime]);
|
|
90
|
+
const nextPage = () => {
|
|
91
|
+
if (query.data.data.pagination) {
|
|
92
|
+
const pagination = query.data.data.pagination;
|
|
93
|
+
if (pagination.next_page !== pagination.current_page && pagination.next_page > pagination.current_page) {
|
|
94
|
+
setRequestPath(constructPaginationLink(requestPath, pagination.next_page));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const prevPage = () => {
|
|
99
|
+
if (query.data.data.pagination) {
|
|
100
|
+
const pagination = query.data.data.pagination;
|
|
101
|
+
if (pagination.previous_page !== pagination.current_page && pagination.previous_page < pagination.current_page) {
|
|
102
|
+
setRequestPath(constructPaginationLink(requestPath, pagination.previous_page));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const constructPaginationLink = (link, pageNumber) => {
|
|
107
|
+
const [pathname, queryString] = link.split('?');
|
|
108
|
+
const queryParams = new URLSearchParams(queryString);
|
|
109
|
+
const oldPage = Number(queryParams.get('page'));
|
|
110
|
+
queryParams.set('page', pageNumber);
|
|
111
|
+
link = pathname + '?' + queryParams.toString();
|
|
112
|
+
// only update page when pagination number changed
|
|
113
|
+
if (oldPage !== pageNumber) {
|
|
114
|
+
setPage(pageNumber);
|
|
115
|
+
}
|
|
116
|
+
return link;
|
|
117
|
+
};
|
|
118
|
+
const gotoPage = (pageNumber) => {
|
|
119
|
+
setRequestPath(constructPaginationLink(requestPath, pageNumber));
|
|
120
|
+
};
|
|
121
|
+
const updatedPathAsync = async (link) => {
|
|
122
|
+
startTransition(() => {
|
|
123
|
+
setRequestPath(link);
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const setOptionsAsync = async (fetchOptions) => {
|
|
127
|
+
startTransition(() => {
|
|
128
|
+
setOptions(fetchOptions);
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const get = async (link, fetchOptions) => {
|
|
132
|
+
if (!isFutureQueriesPaused) {
|
|
133
|
+
await setOptionsAsync(fetchOptions);
|
|
134
|
+
await updatedPathAsync(link);
|
|
135
|
+
return query.data;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
setRequestPayload({ link, fetchOptions });
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!isFutureQueriesPaused && requestPayload) {
|
|
144
|
+
get(requestPayload.link, requestPayload.fetchOptions);
|
|
145
|
+
setRequestPayload(undefined);
|
|
146
|
+
}
|
|
147
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
148
|
+
}, [isFutureQueriesPaused]);
|
|
149
|
+
return {
|
|
150
|
+
...query,
|
|
151
|
+
isLoading: query.isLoading || isFutureQueriesPaused,
|
|
152
|
+
setRequestPath,
|
|
153
|
+
nextPage,
|
|
154
|
+
prevPage,
|
|
155
|
+
get,
|
|
156
|
+
gotoPage,
|
|
157
|
+
page,
|
|
158
|
+
queryKey: [requestPath, {}],
|
|
159
|
+
};
|
|
145
160
|
};
|
|
146
161
|
|
|
147
162
|
export { useGetRequest };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import type { MutateOptions } from '@tanstack/react-query';
|
|
2
|
-
import type { IRequestError, IRequestSuccess } from '../request/request.interface';
|
|
3
|
-
import type { DefaultRequestOptions } from './queries.interface';
|
|
4
|
-
export declare const usePatchRequest: <TResponse>({ path, baseUrl, headers }: {
|
|
5
|
-
path: string;
|
|
6
|
-
} & DefaultRequestOptions) => {
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
data: undefined;
|
|
9
|
-
variables: undefined;
|
|
10
|
-
error: null;
|
|
11
|
-
isError: false;
|
|
12
|
-
isIdle: true;
|
|
13
|
-
isPending: false;
|
|
14
|
-
isSuccess: false;
|
|
15
|
-
status: "idle";
|
|
16
|
-
mutate: import("@tanstack/react-query
|
|
17
|
-
reset: () => void;
|
|
18
|
-
context: unknown;
|
|
19
|
-
failureCount: number;
|
|
20
|
-
failureReason: IRequestError | null;
|
|
21
|
-
isPaused: boolean;
|
|
22
|
-
submittedAt: number;
|
|
23
|
-
mutateAsync: import("@tanstack/react-query
|
|
24
|
-
patch: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
25
|
-
uploadProgressPercent: number;
|
|
26
|
-
} | {
|
|
27
|
-
isLoading: boolean;
|
|
28
|
-
data: undefined;
|
|
29
|
-
variables: void;
|
|
30
|
-
error: null;
|
|
31
|
-
isError: false;
|
|
32
|
-
isIdle: false;
|
|
33
|
-
isPending: true;
|
|
34
|
-
isSuccess: false;
|
|
35
|
-
status: "pending";
|
|
36
|
-
mutate: import("@tanstack/react-query
|
|
37
|
-
reset: () => void;
|
|
38
|
-
context: unknown;
|
|
39
|
-
failureCount: number;
|
|
40
|
-
failureReason: IRequestError | null;
|
|
41
|
-
isPaused: boolean;
|
|
42
|
-
submittedAt: number;
|
|
43
|
-
mutateAsync: import("@tanstack/react-query
|
|
44
|
-
patch: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
45
|
-
uploadProgressPercent: number;
|
|
46
|
-
} | {
|
|
47
|
-
isLoading: boolean;
|
|
48
|
-
data: undefined;
|
|
49
|
-
error: IRequestError;
|
|
50
|
-
variables: void;
|
|
51
|
-
isError: true;
|
|
52
|
-
isIdle: false;
|
|
53
|
-
isPending: false;
|
|
54
|
-
isSuccess: false;
|
|
55
|
-
status: "error";
|
|
56
|
-
mutate: import("@tanstack/react-query
|
|
57
|
-
reset: () => void;
|
|
58
|
-
context: unknown;
|
|
59
|
-
failureCount: number;
|
|
60
|
-
failureReason: IRequestError | null;
|
|
61
|
-
isPaused: boolean;
|
|
62
|
-
submittedAt: number;
|
|
63
|
-
mutateAsync: import("@tanstack/react-query
|
|
64
|
-
patch: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
65
|
-
uploadProgressPercent: number;
|
|
66
|
-
} | {
|
|
67
|
-
isLoading: boolean;
|
|
68
|
-
data: IRequestSuccess<TResponse>;
|
|
69
|
-
error: null;
|
|
70
|
-
variables: void;
|
|
71
|
-
isError: false;
|
|
72
|
-
isIdle: false;
|
|
73
|
-
isPending: false;
|
|
74
|
-
isSuccess: true;
|
|
75
|
-
status: "success";
|
|
76
|
-
mutate: import("@tanstack/react-query
|
|
77
|
-
reset: () => void;
|
|
78
|
-
context: unknown;
|
|
79
|
-
failureCount: number;
|
|
80
|
-
failureReason: IRequestError | null;
|
|
81
|
-
isPaused: boolean;
|
|
82
|
-
submittedAt: number;
|
|
83
|
-
mutateAsync: import("@tanstack/react-query
|
|
84
|
-
patch: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
85
|
-
uploadProgressPercent: number;
|
|
86
|
-
};
|
|
1
|
+
import type { MutateOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { IRequestError, IRequestSuccess } from '../request/request.interface';
|
|
3
|
+
import type { DefaultRequestOptions } from './queries.interface';
|
|
4
|
+
export declare const usePatchRequest: <TResponse>({ path, baseUrl, headers }: {
|
|
5
|
+
path: string;
|
|
6
|
+
} & DefaultRequestOptions) => {
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
data: undefined;
|
|
9
|
+
variables: undefined;
|
|
10
|
+
error: null;
|
|
11
|
+
isError: false;
|
|
12
|
+
isIdle: true;
|
|
13
|
+
isPending: false;
|
|
14
|
+
isSuccess: false;
|
|
15
|
+
status: "idle";
|
|
16
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
|
|
17
|
+
reset: () => void;
|
|
18
|
+
context: unknown;
|
|
19
|
+
failureCount: number;
|
|
20
|
+
failureReason: IRequestError | null;
|
|
21
|
+
isPaused: boolean;
|
|
22
|
+
submittedAt: number;
|
|
23
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
|
|
24
|
+
patch: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
25
|
+
uploadProgressPercent: number;
|
|
26
|
+
} | {
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
data: undefined;
|
|
29
|
+
variables: void;
|
|
30
|
+
error: null;
|
|
31
|
+
isError: false;
|
|
32
|
+
isIdle: false;
|
|
33
|
+
isPending: true;
|
|
34
|
+
isSuccess: false;
|
|
35
|
+
status: "pending";
|
|
36
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
|
|
37
|
+
reset: () => void;
|
|
38
|
+
context: unknown;
|
|
39
|
+
failureCount: number;
|
|
40
|
+
failureReason: IRequestError | null;
|
|
41
|
+
isPaused: boolean;
|
|
42
|
+
submittedAt: number;
|
|
43
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
|
|
44
|
+
patch: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
45
|
+
uploadProgressPercent: number;
|
|
46
|
+
} | {
|
|
47
|
+
isLoading: boolean;
|
|
48
|
+
data: undefined;
|
|
49
|
+
error: IRequestError;
|
|
50
|
+
variables: void;
|
|
51
|
+
isError: true;
|
|
52
|
+
isIdle: false;
|
|
53
|
+
isPending: false;
|
|
54
|
+
isSuccess: false;
|
|
55
|
+
status: "error";
|
|
56
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
|
|
57
|
+
reset: () => void;
|
|
58
|
+
context: unknown;
|
|
59
|
+
failureCount: number;
|
|
60
|
+
failureReason: IRequestError | null;
|
|
61
|
+
isPaused: boolean;
|
|
62
|
+
submittedAt: number;
|
|
63
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
|
|
64
|
+
patch: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
65
|
+
uploadProgressPercent: number;
|
|
66
|
+
} | {
|
|
67
|
+
isLoading: boolean;
|
|
68
|
+
data: IRequestSuccess<TResponse>;
|
|
69
|
+
error: null;
|
|
70
|
+
variables: void;
|
|
71
|
+
isError: false;
|
|
72
|
+
isIdle: false;
|
|
73
|
+
isPending: false;
|
|
74
|
+
isSuccess: true;
|
|
75
|
+
status: "success";
|
|
76
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
|
|
77
|
+
reset: () => void;
|
|
78
|
+
context: unknown;
|
|
79
|
+
failureCount: number;
|
|
80
|
+
failureReason: IRequestError | null;
|
|
81
|
+
isPaused: boolean;
|
|
82
|
+
submittedAt: number;
|
|
83
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
|
|
84
|
+
patch: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
|
|
85
|
+
uploadProgressPercent: number;
|
|
86
|
+
};
|