@ventlio/tanstack-query 0.2.25 → 0.2.27

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.
@@ -8,7 +8,7 @@ const useQueryHeaders = () => {
8
8
  return queryClient.ensureQueryData({
9
9
  queryKey: ['config'],
10
10
  queryFn: () => {
11
- return queryClient.getQueryData(['config'])?.headers;
11
+ return queryClient.getQueryData(['config']);
12
12
  },
13
13
  });
14
14
  };
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'])?.headers;
26
+ return queryClient.getQueryData(['config']);
27
27
  },
28
28
  });
29
29
  };
@@ -182,7 +182,9 @@ 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;
187
+ console.log({ headers });
186
188
  const postResponse = await makeRequest({
187
189
  path: requestPath,
188
190
  headers,
@@ -229,7 +231,8 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, }) => {
229
231
  queryClient = useMemo(() => queryClient, []);
230
232
  const sendRequest = async (res, rej) => {
231
233
  // get request headers
232
- const headers = await getHeadersAsync();
234
+ const headers = (await getHeadersAsync()).headers;
235
+ console.log({ headers });
233
236
  const postResponse = await makeRequest({
234
237
  path: requestPath,
235
238
  headers,
@@ -327,7 +330,9 @@ const usePatchRequest = ({ path }) => {
327
330
  const mutation = useMutation((postData) => new Promise((res, rej) => {
328
331
  return (async () => {
329
332
  // get request headers
330
- const headers = await getHeadersAsync();
333
+ const headers = (await getHeadersAsync())
334
+ .headers;
335
+ console.log({ headers });
331
336
  makeRequest({
332
337
  path: path,
333
338
  body: postData,
@@ -365,7 +370,9 @@ const usePostRequest = ({ path, isFormData = false, }) => {
365
370
  const mutation = useMutation(async (postData) => new Promise((res, rej) => {
366
371
  return (async () => {
367
372
  // get request headers
368
- const headers = await getHeadersAsync();
373
+ const headers = (await getHeadersAsync())
374
+ .headers;
375
+ console.log({ headers });
369
376
  makeRequest({
370
377
  path: path,
371
378
  body: postData,
@@ -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,9 @@ 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;
21
+ console.log({ headers });
20
22
  const postResponse = await makeRequest.makeRequest({
21
23
  path: requestPath,
22
24
  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,8 @@ 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
+ console.log({ headers });
23
24
  const postResponse = await makeRequest.makeRequest({
24
25
  path: requestPath,
25
26
  headers,
@@ -1 +1 @@
1
- {"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -15,7 +15,9 @@ 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;
20
+ console.log({ headers });
19
21
  makeRequest.makeRequest({
20
22
  path: path,
21
23
  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,9 @@ 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;
19
+ console.log({ headers });
18
20
  makeRequest.makeRequest({
19
21
  path: path,
20
22
  body: postData,
@@ -1 +1 @@
1
- {"version":3,"file":"usePostRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"usePostRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -3,6 +3,6 @@ export interface TanstackQueryConfig {
3
3
  headers: RawAxiosRequestHeaders;
4
4
  }
5
5
  export interface IUseQueryHeaders {
6
- getHeadersAsync: () => Promise<RawAxiosRequestHeaders>;
6
+ getHeadersAsync: () => Promise<TanstackQueryConfig>;
7
7
  setQueryHeaders: (header: TanstackQueryConfig['headers']) => void;
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ventlio/tanstack-query",
3
- "version": "0.2.25",
3
+ "version": "0.2.27",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "contributors": [
@@ -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<RawAxiosRequestHeaders> => {
7
+ const getHeadersAsync = async (): Promise<TanstackQueryConfig> => {
9
8
  return queryClient.ensureQueryData({
10
9
  queryKey: ['config'],
11
10
  queryFn: () => {
12
- return (queryClient.getQueryData(['config']) as any)?.headers;
11
+ return queryClient.getQueryData(['config']);
13
12
  },
14
13
  });
15
14
  };
@@ -20,7 +20,10 @@ 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;
25
+
26
+ console.log({ headers });
24
27
 
25
28
  const postResponse = await makeRequest<TResponse>({
26
29
  path: requestPath,
@@ -40,7 +40,9 @@ 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
+
45
+ console.log({ headers });
44
46
 
45
47
  const postResponse = await makeRequest<TResponse>({
46
48
  path: requestPath,
@@ -21,7 +21,11 @@ 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
+
27
+ console.log({ headers });
28
+
25
29
  makeRequest<TResponse>({
26
30
  path: path,
27
31
  body: postData,
@@ -23,7 +23,11 @@ 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
+
29
+ console.log({ headers });
30
+
27
31
  makeRequest<TResponse>({
28
32
  path: path,
29
33
  body: postData,
@@ -5,6 +5,6 @@ export interface TanstackQueryConfig {
5
5
  }
6
6
 
7
7
  export interface IUseQueryHeaders {
8
- getHeadersAsync: () => Promise<RawAxiosRequestHeaders>;
8
+ getHeadersAsync: () => Promise<TanstackQueryConfig>;
9
9
  setQueryHeaders: (header: TanstackQueryConfig['headers']) => void;
10
10
  }