@ventlio/tanstack-query 0.2.25 → 0.2.26
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/useQueryHeaders.js +1 -1
- package/dist/index.mjs +8 -5
- package/dist/index.mjs.map +1 -1
- package/dist/queries/useDeleteRequest.js +2 -1
- package/dist/queries/useDeleteRequest.js.map +1 -1
- package/dist/queries/useGetRequest.js +1 -1
- package/dist/queries/usePatchRequest.js +2 -1
- package/dist/queries/usePatchRequest.js.map +1 -1
- package/dist/queries/usePostRequest.js +2 -1
- package/dist/queries/usePostRequest.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/config/useQueryHeaders.ts +2 -3
- package/src/queries/useDeleteRequest.ts +2 -1
- package/src/queries/useGetRequest.ts +1 -1
- package/src/queries/usePatchRequest.ts +3 -1
- package/src/queries/usePostRequest.ts +3 -1
- package/src/types/index.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ const useQueryHeaders = () => {
|
|
|
23
23
|
return queryClient.ensureQueryData({
|
|
24
24
|
queryKey: ['config'],
|
|
25
25
|
queryFn: () => {
|
|
26
|
-
return queryClient.getQueryData(['config'])
|
|
26
|
+
return queryClient.getQueryData(['config']);
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
};
|
|
@@ -182,7 +182,8 @@ const useDeleteRequest = () => {
|
|
|
182
182
|
const query = useQuery([requestPath, {}], () => new Promise((res, rej) => {
|
|
183
183
|
setTimeout(async () => {
|
|
184
184
|
// get request headers
|
|
185
|
-
const headers = await getHeadersAsync()
|
|
185
|
+
const headers = (await getHeadersAsync())
|
|
186
|
+
.headers;
|
|
186
187
|
const postResponse = await makeRequest({
|
|
187
188
|
path: requestPath,
|
|
188
189
|
headers,
|
|
@@ -229,7 +230,7 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, }) => {
|
|
|
229
230
|
queryClient = useMemo(() => queryClient, []);
|
|
230
231
|
const sendRequest = async (res, rej) => {
|
|
231
232
|
// get request headers
|
|
232
|
-
const headers = await getHeadersAsync();
|
|
233
|
+
const headers = (await getHeadersAsync()).headers;
|
|
233
234
|
const postResponse = await makeRequest({
|
|
234
235
|
path: requestPath,
|
|
235
236
|
headers,
|
|
@@ -327,7 +328,8 @@ const usePatchRequest = ({ path }) => {
|
|
|
327
328
|
const mutation = useMutation((postData) => new Promise((res, rej) => {
|
|
328
329
|
return (async () => {
|
|
329
330
|
// get request headers
|
|
330
|
-
const headers = await getHeadersAsync()
|
|
331
|
+
const headers = (await getHeadersAsync())
|
|
332
|
+
.headers;
|
|
331
333
|
makeRequest({
|
|
332
334
|
path: path,
|
|
333
335
|
body: postData,
|
|
@@ -365,7 +367,8 @@ const usePostRequest = ({ path, isFormData = false, }) => {
|
|
|
365
367
|
const mutation = useMutation(async (postData) => new Promise((res, rej) => {
|
|
366
368
|
return (async () => {
|
|
367
369
|
// get request headers
|
|
368
|
-
const headers = await getHeadersAsync()
|
|
370
|
+
const headers = (await getHeadersAsync())
|
|
371
|
+
.headers;
|
|
369
372
|
makeRequest({
|
|
370
373
|
path: path,
|
|
371
374
|
body: postData,
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -16,7 +16,8 @@ const useDeleteRequest = () => {
|
|
|
16
16
|
const query = reactQuery.useQuery([requestPath, {}], () => new Promise((res, rej) => {
|
|
17
17
|
setTimeout(async () => {
|
|
18
18
|
// get request headers
|
|
19
|
-
const headers = await getHeadersAsync()
|
|
19
|
+
const headers = (await getHeadersAsync())
|
|
20
|
+
.headers;
|
|
20
21
|
const postResponse = await makeRequest.makeRequest({
|
|
21
22
|
path: requestPath,
|
|
22
23
|
headers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeleteRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDeleteRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -19,7 +19,7 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, }) => {
|
|
|
19
19
|
queryClient = react.useMemo(() => queryClient, []);
|
|
20
20
|
const sendRequest = async (res, rej) => {
|
|
21
21
|
// get request headers
|
|
22
|
-
const headers = await getHeadersAsync();
|
|
22
|
+
const headers = (await getHeadersAsync()).headers;
|
|
23
23
|
const postResponse = await makeRequest.makeRequest({
|
|
24
24
|
path: requestPath,
|
|
25
25
|
headers,
|
|
@@ -15,7 +15,8 @@ const usePatchRequest = ({ path }) => {
|
|
|
15
15
|
const mutation = reactQuery.useMutation((postData) => new Promise((res, rej) => {
|
|
16
16
|
return (async () => {
|
|
17
17
|
// get request headers
|
|
18
|
-
const headers = await getHeadersAsync()
|
|
18
|
+
const headers = (await getHeadersAsync())
|
|
19
|
+
.headers;
|
|
19
20
|
makeRequest.makeRequest({
|
|
20
21
|
path: path,
|
|
21
22
|
body: postData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePatchRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePatchRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -14,7 +14,8 @@ const usePostRequest = ({ path, isFormData = false, }) => {
|
|
|
14
14
|
const mutation = reactQuery.useMutation(async (postData) => new Promise((res, rej) => {
|
|
15
15
|
return (async () => {
|
|
16
16
|
// get request headers
|
|
17
|
-
const headers = await getHeadersAsync()
|
|
17
|
+
const headers = (await getHeadersAsync())
|
|
18
|
+
.headers;
|
|
18
19
|
makeRequest.makeRequest({
|
|
19
20
|
path: path,
|
|
20
21
|
body: postData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePostRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePostRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export interface TanstackQueryConfig {
|
|
|
3
3
|
headers: RawAxiosRequestHeaders;
|
|
4
4
|
}
|
|
5
5
|
export interface IUseQueryHeaders {
|
|
6
|
-
getHeadersAsync: () => Promise<
|
|
6
|
+
getHeadersAsync: () => Promise<TanstackQueryConfig>;
|
|
7
7
|
setQueryHeaders: (header: TanstackQueryConfig['headers']) => void;
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { useQueryClient } from '@tanstack/react-query';
|
|
2
|
-
import type { RawAxiosRequestHeaders } from 'axios';
|
|
3
2
|
import type { IUseQueryHeaders, TanstackQueryConfig } from '../types';
|
|
4
3
|
|
|
5
4
|
export const useQueryHeaders = (): IUseQueryHeaders => {
|
|
6
5
|
const queryClient = useQueryClient();
|
|
7
6
|
|
|
8
|
-
const getHeadersAsync = async (): Promise<
|
|
7
|
+
const getHeadersAsync = async (): Promise<TanstackQueryConfig> => {
|
|
9
8
|
return queryClient.ensureQueryData({
|
|
10
9
|
queryKey: ['config'],
|
|
11
10
|
queryFn: () => {
|
|
12
|
-
return
|
|
11
|
+
return queryClient.getQueryData(['config']);
|
|
13
12
|
},
|
|
14
13
|
});
|
|
15
14
|
};
|
|
@@ -20,7 +20,8 @@ export const useDeleteRequest = <TResponse>() => {
|
|
|
20
20
|
new Promise<IRequestSuccess<TResponse> | IRequestError>((res, rej) => {
|
|
21
21
|
setTimeout(async () => {
|
|
22
22
|
// get request headers
|
|
23
|
-
const headers: RawAxiosRequestHeaders = await getHeadersAsync()
|
|
23
|
+
const headers: RawAxiosRequestHeaders = (await getHeadersAsync())
|
|
24
|
+
.headers;
|
|
24
25
|
|
|
25
26
|
const postResponse = await makeRequest<TResponse>({
|
|
26
27
|
path: requestPath,
|
|
@@ -40,7 +40,7 @@ export const useGetRequest = <TResponse extends Record<string, any>>({
|
|
|
40
40
|
rej: (reason?: any) => void
|
|
41
41
|
) => {
|
|
42
42
|
// get request headers
|
|
43
|
-
const headers: RawAxiosRequestHeaders = await getHeadersAsync();
|
|
43
|
+
const headers: RawAxiosRequestHeaders = (await getHeadersAsync()).headers;
|
|
44
44
|
|
|
45
45
|
const postResponse = await makeRequest<TResponse>({
|
|
46
46
|
path: requestPath,
|
|
@@ -21,7 +21,9 @@ export const usePatchRequest = <TResponse>({ path }: { path: string }) => {
|
|
|
21
21
|
new Promise<IRequestSuccess<TResponse>>((res, rej) => {
|
|
22
22
|
return (async () => {
|
|
23
23
|
// get request headers
|
|
24
|
-
const headers: RawAxiosRequestHeaders = await getHeadersAsync()
|
|
24
|
+
const headers: RawAxiosRequestHeaders = (await getHeadersAsync())
|
|
25
|
+
.headers;
|
|
26
|
+
|
|
25
27
|
makeRequest<TResponse>({
|
|
26
28
|
path: path,
|
|
27
29
|
body: postData,
|
|
@@ -23,7 +23,9 @@ export const usePostRequest = <TResponse>({
|
|
|
23
23
|
new Promise<IRequestSuccess<TResponse>>((res, rej) => {
|
|
24
24
|
return (async () => {
|
|
25
25
|
// get request headers
|
|
26
|
-
const headers: RawAxiosRequestHeaders = await getHeadersAsync()
|
|
26
|
+
const headers: RawAxiosRequestHeaders = (await getHeadersAsync())
|
|
27
|
+
.headers;
|
|
28
|
+
|
|
27
29
|
makeRequest<TResponse>({
|
|
28
30
|
path: path,
|
|
29
31
|
body: postData,
|
package/src/types/index.ts
CHANGED
|
@@ -5,6 +5,6 @@ export interface TanstackQueryConfig {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export interface IUseQueryHeaders {
|
|
8
|
-
getHeadersAsync: () => Promise<
|
|
8
|
+
getHeadersAsync: () => Promise<TanstackQueryConfig>;
|
|
9
9
|
setQueryHeaders: (header: TanstackQueryConfig['headers']) => void;
|
|
10
10
|
}
|