@geekmidas/client 0.3.0 → 0.5.0

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.
Files changed (80) hide show
  1. package/dist/auth-fetcher.cjs +2 -3
  2. package/dist/auth-fetcher.cjs.map +1 -1
  3. package/dist/auth-fetcher.d.cts +2 -1
  4. package/dist/auth-fetcher.d.cts.map +1 -0
  5. package/dist/auth-fetcher.d.mts +2 -1
  6. package/dist/auth-fetcher.d.mts.map +1 -0
  7. package/dist/auth-fetcher.mjs +2 -3
  8. package/dist/auth-fetcher.mjs.map +1 -1
  9. package/dist/endpoint-hooks.cjs +10 -5
  10. package/dist/endpoint-hooks.cjs.map +1 -1
  11. package/dist/endpoint-hooks.d.cts +2 -2
  12. package/dist/endpoint-hooks.d.cts.map +1 -0
  13. package/dist/endpoint-hooks.d.mts +2 -2
  14. package/dist/endpoint-hooks.d.mts.map +1 -0
  15. package/dist/endpoint-hooks.mjs +10 -5
  16. package/dist/endpoint-hooks.mjs.map +1 -1
  17. package/dist/{fetcher-DLDD_7Sa.mjs → fetcher-5fnBE7Dk.mjs} +2 -2
  18. package/dist/fetcher-5fnBE7Dk.mjs.map +1 -0
  19. package/dist/{fetcher-KdwHgdAl.cjs → fetcher-CgLEaIAC.cjs} +2 -2
  20. package/dist/fetcher-CgLEaIAC.cjs.map +1 -0
  21. package/dist/fetcher.cjs +1 -1
  22. package/dist/fetcher.d.cts +3 -1
  23. package/dist/fetcher.d.cts.map +1 -0
  24. package/dist/fetcher.d.mts +3 -1
  25. package/dist/fetcher.d.mts.map +1 -0
  26. package/dist/fetcher.mjs +1 -1
  27. package/dist/infer.d.cts.map +1 -0
  28. package/dist/infer.d.mts.map +1 -0
  29. package/dist/openapi-hooks.cjs +3 -5
  30. package/dist/openapi-hooks.cjs.map +1 -1
  31. package/dist/openapi-hooks.d.cts +3 -3
  32. package/dist/openapi-hooks.d.cts.map +1 -0
  33. package/dist/openapi-hooks.d.mts +6 -6
  34. package/dist/openapi-hooks.d.mts.map +1 -0
  35. package/dist/openapi-hooks.mjs +3 -5
  36. package/dist/openapi-hooks.mjs.map +1 -1
  37. package/dist/openapi-types.d.cts.map +1 -0
  38. package/dist/openapi-types.d.mts.map +1 -0
  39. package/dist/openapi.cjs.map +1 -1
  40. package/dist/openapi.mjs.map +1 -1
  41. package/dist/react-query.cjs +1 -1
  42. package/dist/react-query.cjs.map +1 -1
  43. package/dist/react-query.d.cts +3 -1
  44. package/dist/react-query.d.cts.map +1 -0
  45. package/dist/react-query.d.mts +10 -8
  46. package/dist/react-query.d.mts.map +1 -0
  47. package/dist/react-query.mjs +1 -1
  48. package/dist/react-query.mjs.map +1 -1
  49. package/dist/{types-D4OSWveN.d.cts → types-4K4N-Fl1.d.cts} +8 -6
  50. package/dist/types-4K4N-Fl1.d.cts.map +1 -0
  51. package/dist/{types-Cdv1XAWr.d.mts → types-hhkZWjQn.d.mts} +8 -6
  52. package/dist/types-hhkZWjQn.d.mts.map +1 -0
  53. package/dist/types.d.cts +1 -1
  54. package/dist/types.d.mts +1 -1
  55. package/package.json +6 -5
  56. package/src/__tests__/auth-fetcher.spec.ts +505 -0
  57. package/src/__tests__/endpoint-hooks.spec.tsx +348 -348
  58. package/src/__tests__/fetcher.spec.ts +403 -403
  59. package/src/__tests__/infer.integration.spec.ts +171 -171
  60. package/src/__tests__/infer.spec.ts +182 -182
  61. package/src/__tests__/method-restrictions.spec.tsx +165 -165
  62. package/src/__tests__/openapi-hooks.spec.tsx +536 -537
  63. package/src/__tests__/react-query-infinite.spec.tsx +989 -989
  64. package/src/__tests__/react-query-invalidation.spec.tsx +223 -222
  65. package/src/__tests__/react-query.spec.tsx +567 -567
  66. package/src/__tests__/setup.ts +260 -260
  67. package/src/__tests__/types.spec.ts +127 -127
  68. package/src/__tests__/url-parsing.spec.ts +191 -191
  69. package/src/auth-fetcher.ts +160 -162
  70. package/src/endpoint-hooks.ts +151 -150
  71. package/src/fetcher.ts +163 -163
  72. package/src/infer.ts +64 -63
  73. package/src/openapi-hooks.ts +146 -146
  74. package/src/openapi-types.d.ts +428 -428
  75. package/src/openapi.json +593 -593
  76. package/src/react-query.ts +281 -281
  77. package/src/types.ts +124 -125
  78. package/tsconfig.json +12 -0
  79. package/dist/fetcher-DLDD_7Sa.mjs.map +0 -1
  80. package/dist/fetcher-KdwHgdAl.cjs.map +0 -1
@@ -1,341 +1,341 @@
1
1
  import type {
2
- QueryClient,
3
- QueryFunctionContext,
4
- UseInfiniteQueryOptions,
5
- UseMutationOptions,
6
- UseQueryOptions,
2
+ QueryClient,
3
+ QueryFunctionContext,
4
+ UseInfiniteQueryOptions,
5
+ UseMutationOptions,
6
+ UseQueryOptions,
7
7
  } from '@tanstack/react-query';
8
8
  import {
9
- useInfiniteQuery,
10
- useMutation,
11
- useQuery,
12
- useQueryClient,
9
+ useInfiniteQuery,
10
+ useMutation,
11
+ useQuery,
12
+ useQueryClient,
13
13
  } from '@tanstack/react-query';
14
14
  import { useMemo } from 'react';
15
15
  import { createTypedFetcher } from './fetcher';
16
16
  import type {
17
- ExtractEndpointResponse,
18
- FetcherOptions,
19
- FilteredRequestConfig,
20
- MutationEndpoint,
21
- QueryEndpoint,
22
- TypedEndpoint,
17
+ ExtractEndpointResponse,
18
+ FetcherOptions,
19
+ FilteredRequestConfig,
20
+ MutationEndpoint,
21
+ QueryEndpoint,
22
+ TypedEndpoint,
23
23
  } from './types';
24
24
 
25
25
  export interface TypedQueryClientOptions extends FetcherOptions {
26
- queryClient?: QueryClient;
26
+ queryClient?: QueryClient;
27
27
  }
28
28
 
29
29
  export class TypedQueryClient<Paths> {
30
- private fetcher: ReturnType<typeof createTypedFetcher<Paths>>;
31
- private queryClient?: QueryClient;
30
+ private fetcher: ReturnType<typeof createTypedFetcher<Paths>>;
31
+ private queryClient?: QueryClient;
32
32
 
33
- constructor(options: TypedQueryClientOptions = {}) {
34
- this.fetcher = createTypedFetcher<Paths>(options);
35
- this.queryClient = options.queryClient;
36
- }
33
+ constructor(options: TypedQueryClientOptions = {}) {
34
+ this.fetcher = createTypedFetcher<Paths>(options);
35
+ this.queryClient = options.queryClient;
36
+ }
37
37
 
38
- useQuery<T extends QueryEndpoint<Paths>>(
39
- endpoint: T,
40
- config?: FilteredRequestConfig<Paths, T>,
41
- options?: Omit<
42
- UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,
43
- 'queryKey' | 'queryFn'
44
- >,
45
- ) {
46
- const queryKey = this.buildQueryKey(endpoint, config);
38
+ useQuery<T extends QueryEndpoint<Paths>>(
39
+ endpoint: T,
40
+ config?: FilteredRequestConfig<Paths, T>,
41
+ options?: Omit<
42
+ UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,
43
+ 'queryKey' | 'queryFn'
44
+ >,
45
+ ) {
46
+ const queryKey = this.buildQueryKey(endpoint, config);
47
47
 
48
- // Memoize the combined options to prevent unnecessary re-renders
49
- const memoizedOptions = useMemo(
50
- () => ({
51
- queryKey,
52
- queryFn: () => this.fetcher(endpoint, config),
53
- ...options,
54
- }),
55
- // Dependencies: queryKey, endpoint, config, and options
56
- // Note: We stringify config and options to ensure stable references
57
- // eslint-disable-next-line react-hooks/exhaustive-deps
58
- [
59
- queryKey.join(','),
60
- endpoint,
61
- JSON.stringify(config),
62
- JSON.stringify(options),
63
- ],
64
- );
48
+ // Memoize the combined options to prevent unnecessary re-renders
49
+ const memoizedOptions = useMemo(
50
+ () => ({
51
+ queryKey,
52
+ queryFn: () => this.fetcher(endpoint, config),
53
+ ...options,
54
+ }),
55
+ // Dependencies: queryKey, endpoint, config, and options
56
+ // Note: We stringify config and options to ensure stable references
57
+ // eslint-disable-next-line react-hooks/exhaustive-deps
58
+ [
59
+ queryKey.join(','),
60
+ endpoint,
61
+ JSON.stringify(config),
62
+ JSON.stringify(options),
63
+ ],
64
+ );
65
65
 
66
- return useQuery<ExtractEndpointResponse<Paths, T>, Response>(
67
- memoizedOptions,
68
- );
69
- }
66
+ return useQuery<ExtractEndpointResponse<Paths, T>, Response>(
67
+ memoizedOptions,
68
+ );
69
+ }
70
70
 
71
- useMutation<T extends MutationEndpoint<Paths>>(
72
- endpoint: T,
73
- options?: Omit<
74
- UseMutationOptions<
75
- ExtractEndpointResponse<Paths, T>,
76
- Response,
77
- FilteredRequestConfig<Paths, T>
78
- >,
79
- 'mutationFn'
80
- >,
81
- ) {
82
- // Memoize the combined options to prevent unnecessary re-renders
83
- const memoizedOptions = useMemo(
84
- () => ({
85
- mutationFn: (config: FilteredRequestConfig<Paths, T>) =>
86
- this.fetcher(endpoint, config),
87
- ...options,
88
- }),
89
- // Dependencies: endpoint and options
90
- // Note: We stringify options to ensure stable reference
91
- // eslint-disable-next-line react-hooks/exhaustive-deps
92
- [endpoint, JSON.stringify(options)],
93
- );
71
+ useMutation<T extends MutationEndpoint<Paths>>(
72
+ endpoint: T,
73
+ options?: Omit<
74
+ UseMutationOptions<
75
+ ExtractEndpointResponse<Paths, T>,
76
+ Response,
77
+ FilteredRequestConfig<Paths, T>
78
+ >,
79
+ 'mutationFn'
80
+ >,
81
+ ) {
82
+ // Memoize the combined options to prevent unnecessary re-renders
83
+ const memoizedOptions = useMemo(
84
+ () => ({
85
+ mutationFn: (config: FilteredRequestConfig<Paths, T>) =>
86
+ this.fetcher(endpoint, config),
87
+ ...options,
88
+ }),
89
+ // Dependencies: endpoint and options
90
+ // Note: We stringify options to ensure stable reference
91
+ // eslint-disable-next-line react-hooks/exhaustive-deps
92
+ [endpoint, JSON.stringify(options)],
93
+ );
94
94
 
95
- return useMutation<
96
- ExtractEndpointResponse<Paths, T>,
97
- Response,
98
- FilteredRequestConfig<Paths, T>
99
- >(memoizedOptions);
100
- }
95
+ return useMutation<
96
+ ExtractEndpointResponse<Paths, T>,
97
+ Response,
98
+ FilteredRequestConfig<Paths, T>
99
+ >(memoizedOptions);
100
+ }
101
101
 
102
- useInfiniteQuery<
103
- T extends QueryEndpoint<Paths>,
104
- TPageData = ExtractEndpointResponse<Paths, T>,
105
- TPageParam = unknown,
106
- >(
107
- endpoint: T,
108
- options: Omit<
109
- UseInfiniteQueryOptions<
110
- TPageData,
111
- Response,
112
- { pages: TPageData[]; pageParams: TPageParam[] },
113
- unknown[],
114
- TPageParam
115
- >,
116
- 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'
117
- > & {
118
- getNextPageParam: (
119
- lastPage: TPageData,
120
- allPages: TPageData[],
121
- lastPageParam: TPageParam,
122
- allPageParams: TPageParam[],
123
- ) => TPageParam | undefined;
124
- initialPageParam: TPageParam;
125
- },
126
- config?: FilteredRequestConfig<Paths, T>,
127
- ) {
128
- const queryKey = this.buildQueryKey(endpoint, config);
102
+ useInfiniteQuery<
103
+ T extends QueryEndpoint<Paths>,
104
+ TPageData = ExtractEndpointResponse<Paths, T>,
105
+ TPageParam = unknown,
106
+ >(
107
+ endpoint: T,
108
+ options: Omit<
109
+ UseInfiniteQueryOptions<
110
+ TPageData,
111
+ Response,
112
+ { pages: TPageData[]; pageParams: TPageParam[] },
113
+ unknown[],
114
+ TPageParam
115
+ >,
116
+ 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'
117
+ > & {
118
+ getNextPageParam: (
119
+ lastPage: TPageData,
120
+ allPages: TPageData[],
121
+ lastPageParam: TPageParam,
122
+ allPageParams: TPageParam[],
123
+ ) => TPageParam | undefined;
124
+ initialPageParam: TPageParam;
125
+ },
126
+ config?: FilteredRequestConfig<Paths, T>,
127
+ ) {
128
+ const queryKey = this.buildQueryKey(endpoint, config);
129
129
 
130
- // Memoize the combined options to prevent unnecessary re-renders
131
- const memoizedOptions = useMemo(
132
- () => ({
133
- queryKey,
134
- queryFn: ({
135
- pageParam,
136
- }: QueryFunctionContext<unknown[], TPageParam>) => {
137
- let mergedConfig = config;
138
- if (pageParam !== undefined && config) {
139
- // If pageParam is an object, spread it into query
140
- const pageQuery =
141
- typeof pageParam === 'object' ? pageParam : { page: pageParam };
142
- mergedConfig = {
143
- ...config,
144
- query: { ...(config as any).query, ...pageQuery },
145
- } as any;
146
- } else if (pageParam !== undefined && !config) {
147
- // If pageParam is an object, use it directly, otherwise wrap in page property
148
- const pageQuery =
149
- typeof pageParam === 'object' ? pageParam : { page: pageParam };
150
- mergedConfig = { query: pageQuery } as any;
151
- }
152
- return this.fetcher(endpoint, mergedConfig) as Promise<TPageData>;
153
- },
154
- ...options,
155
- }),
156
- // Dependencies: queryKey, endpoint, config, and options
157
- // Note: We stringify config and options to ensure stable references
158
- // eslint-disable-next-line react-hooks/exhaustive-deps
159
- [
160
- queryKey.join(','),
161
- endpoint,
162
- JSON.stringify(config),
163
- JSON.stringify(options),
164
- ],
165
- );
130
+ // Memoize the combined options to prevent unnecessary re-renders
131
+ const memoizedOptions = useMemo(
132
+ () => ({
133
+ queryKey,
134
+ queryFn: ({
135
+ pageParam,
136
+ }: QueryFunctionContext<unknown[], TPageParam>) => {
137
+ let mergedConfig = config;
138
+ if (pageParam !== undefined && config) {
139
+ // If pageParam is an object, spread it into query
140
+ const pageQuery =
141
+ typeof pageParam === 'object' ? pageParam : { page: pageParam };
142
+ mergedConfig = {
143
+ ...config,
144
+ query: { ...(config as any).query, ...pageQuery },
145
+ } as any;
146
+ } else if (pageParam !== undefined && !config) {
147
+ // If pageParam is an object, use it directly, otherwise wrap in page property
148
+ const pageQuery =
149
+ typeof pageParam === 'object' ? pageParam : { page: pageParam };
150
+ mergedConfig = { query: pageQuery } as any;
151
+ }
152
+ return this.fetcher(endpoint, mergedConfig) as Promise<TPageData>;
153
+ },
154
+ ...options,
155
+ }),
156
+ // Dependencies: queryKey, endpoint, config, and options
157
+ // Note: We stringify config and options to ensure stable references
158
+ // eslint-disable-next-line react-hooks/exhaustive-deps
159
+ [
160
+ queryKey.join(','),
161
+ endpoint,
162
+ JSON.stringify(config),
163
+ JSON.stringify(options),
164
+ ],
165
+ );
166
166
 
167
- return useInfiniteQuery<
168
- TPageData,
169
- Response,
170
- { pages: TPageData[]; pageParams: TPageParam[] },
171
- unknown[],
172
- TPageParam
173
- >(memoizedOptions);
174
- }
167
+ return useInfiniteQuery<
168
+ TPageData,
169
+ Response,
170
+ { pages: TPageData[]; pageParams: TPageParam[] },
171
+ unknown[],
172
+ TPageParam
173
+ >(memoizedOptions);
174
+ }
175
175
 
176
- buildQueryKey<T extends TypedEndpoint<Paths>>(
177
- endpoint: T,
178
- config?: FilteredRequestConfig<Paths, T>,
179
- ): unknown[] {
180
- const key: unknown[] = [endpoint];
176
+ buildQueryKey<T extends TypedEndpoint<Paths>>(
177
+ endpoint: T,
178
+ config?: FilteredRequestConfig<Paths, T>,
179
+ ): unknown[] {
180
+ const key: unknown[] = [endpoint];
181
181
 
182
- if (config && 'params' in config && config.params) {
183
- key.push({ params: config.params });
184
- }
182
+ if (config && 'params' in config && config.params) {
183
+ key.push({ params: config.params });
184
+ }
185
185
 
186
- if (config && 'query' in config && config.query) {
187
- key.push({ query: config.query });
188
- }
186
+ if (config && 'query' in config && config.query) {
187
+ key.push({ query: config.query });
188
+ }
189
189
 
190
- return key;
191
- }
190
+ return key;
191
+ }
192
192
 
193
- /**
194
- * Invalidate queries for a specific endpoint with optional config
195
- * @param endpoint - The endpoint to invalidate (e.g., 'GET /users')
196
- * @param config - Optional params/query to match specific queries
197
- * @returns Promise that resolves when invalidation is complete
198
- */
199
- invalidateQueries<T extends QueryEndpoint<Paths>>(
200
- endpoint: T,
201
- config?: FilteredRequestConfig<Paths, T>,
202
- ): Promise<void> {
203
- const queryClient = this.getQueryClient();
204
- const queryKey = this.buildQueryKey(endpoint, config);
193
+ /**
194
+ * Invalidate queries for a specific endpoint with optional config
195
+ * @param endpoint - The endpoint to invalidate (e.g., 'GET /users')
196
+ * @param config - Optional params/query to match specific queries
197
+ * @returns Promise that resolves when invalidation is complete
198
+ */
199
+ invalidateQueries<T extends QueryEndpoint<Paths>>(
200
+ endpoint: T,
201
+ config?: FilteredRequestConfig<Paths, T>,
202
+ ): Promise<void> {
203
+ const queryClient = this.getQueryClient();
204
+ const queryKey = this.buildQueryKey(endpoint, config);
205
205
 
206
- return queryClient.invalidateQueries({
207
- queryKey,
208
- exact: !!config, // Use exact matching if config is provided
209
- });
210
- }
206
+ return queryClient.invalidateQueries({
207
+ queryKey,
208
+ exact: !!config, // Use exact matching if config is provided
209
+ });
210
+ }
211
211
 
212
- /**
213
- * Invalidate all queries in the cache
214
- * @returns Promise that resolves when invalidation is complete
215
- */
216
- invalidateAllQueries(): Promise<void> {
217
- const queryClient = this.getQueryClient();
218
- return queryClient.invalidateQueries();
219
- }
212
+ /**
213
+ * Invalidate all queries in the cache
214
+ * @returns Promise that resolves when invalidation is complete
215
+ */
216
+ invalidateAllQueries(): Promise<void> {
217
+ const queryClient = this.getQueryClient();
218
+ return queryClient.invalidateQueries();
219
+ }
220
220
 
221
- /**
222
- * Get the underlying QueryClient instance
223
- * @returns The QueryClient instance
224
- */
225
- getQueryClient(): QueryClient {
226
- if (this.queryClient) {
227
- return this.queryClient;
228
- }
221
+ /**
222
+ * Get the underlying QueryClient instance
223
+ * @returns The QueryClient instance
224
+ */
225
+ getQueryClient(): QueryClient {
226
+ if (this.queryClient) {
227
+ return this.queryClient;
228
+ }
229
229
 
230
- // If no query client was provided, try to get it from context
231
- // This will throw if used outside of QueryClientProvider
232
- throw new Error(
233
- 'No QueryClient set, please provide a QueryClient via the queryClient option or ensure you are within a QueryClientProvider',
234
- );
235
- }
230
+ // If no query client was provided, try to get it from context
231
+ // This will throw if used outside of QueryClientProvider
232
+ throw new Error(
233
+ 'No QueryClient set, please provide a QueryClient via the queryClient option or ensure you are within a QueryClientProvider',
234
+ );
235
+ }
236
236
 
237
- /**
238
- * Set the QueryClient instance
239
- * @param queryClient - The QueryClient instance to use
240
- */
241
- setQueryClient(queryClient: QueryClient): void {
242
- this.queryClient = queryClient;
243
- }
237
+ /**
238
+ * Set the QueryClient instance
239
+ * @param queryClient - The QueryClient instance to use
240
+ */
241
+ setQueryClient(queryClient: QueryClient): void {
242
+ this.queryClient = queryClient;
243
+ }
244
244
  }
245
245
 
246
246
  export function createTypedQueryClient<Paths>(
247
- options?: TypedQueryClientOptions,
247
+ options?: TypedQueryClientOptions,
248
248
  ) {
249
- return new TypedQueryClient<Paths>(options);
249
+ return new TypedQueryClient<Paths>(options);
250
250
  }
251
251
 
252
252
  // Hook exports for convenience
253
253
  export function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(
254
- client: TypedQueryClient<Paths>,
255
- endpoint: T,
256
- config?: FilteredRequestConfig<Paths, T>,
257
- options?: Omit<
258
- UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,
259
- 'queryKey' | 'queryFn'
260
- >,
254
+ client: TypedQueryClient<Paths>,
255
+ endpoint: T,
256
+ config?: FilteredRequestConfig<Paths, T>,
257
+ options?: Omit<
258
+ UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,
259
+ 'queryKey' | 'queryFn'
260
+ >,
261
261
  ) {
262
- return client.useQuery(endpoint, config, options);
262
+ return client.useQuery(endpoint, config, options);
263
263
  }
264
264
 
265
265
  export function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(
266
- client: TypedQueryClient<Paths>,
267
- endpoint: T,
268
- options?: Omit<
269
- UseMutationOptions<
270
- ExtractEndpointResponse<Paths, T>,
271
- Response,
272
- FilteredRequestConfig<Paths, T>
273
- >,
274
- 'mutationFn'
275
- >,
266
+ client: TypedQueryClient<Paths>,
267
+ endpoint: T,
268
+ options?: Omit<
269
+ UseMutationOptions<
270
+ ExtractEndpointResponse<Paths, T>,
271
+ Response,
272
+ FilteredRequestConfig<Paths, T>
273
+ >,
274
+ 'mutationFn'
275
+ >,
276
276
  ) {
277
- return client.useMutation(endpoint, options);
277
+ return client.useMutation(endpoint, options);
278
278
  }
279
279
 
280
280
  export function useTypedInfiniteQuery<
281
- Paths,
282
- T extends QueryEndpoint<Paths>,
283
- TPageData = ExtractEndpointResponse<Paths, T>,
284
- TPageParam = unknown,
281
+ Paths,
282
+ T extends QueryEndpoint<Paths>,
283
+ TPageData = ExtractEndpointResponse<Paths, T>,
284
+ TPageParam = unknown,
285
285
  >(
286
- client: TypedQueryClient<Paths>,
287
- endpoint: T,
288
- options: Omit<
289
- UseInfiniteQueryOptions<
290
- TPageData,
291
- Response,
292
- { pages: TPageData[]; pageParams: TPageParam[] },
293
- unknown[],
294
- TPageParam
295
- >,
296
- 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'
297
- > & {
298
- getNextPageParam: (
299
- lastPage: TPageData,
300
- allPages: TPageData[],
301
- lastPageParam: TPageParam,
302
- allPageParams: TPageParam[],
303
- ) => TPageParam | undefined;
304
- initialPageParam: TPageParam;
305
- },
306
- config?: FilteredRequestConfig<Paths, T>,
286
+ client: TypedQueryClient<Paths>,
287
+ endpoint: T,
288
+ options: Omit<
289
+ UseInfiniteQueryOptions<
290
+ TPageData,
291
+ Response,
292
+ { pages: TPageData[]; pageParams: TPageParam[] },
293
+ unknown[],
294
+ TPageParam
295
+ >,
296
+ 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'
297
+ > & {
298
+ getNextPageParam: (
299
+ lastPage: TPageData,
300
+ allPages: TPageData[],
301
+ lastPageParam: TPageParam,
302
+ allPageParams: TPageParam[],
303
+ ) => TPageParam | undefined;
304
+ initialPageParam: TPageParam;
305
+ },
306
+ config?: FilteredRequestConfig<Paths, T>,
307
307
  ) {
308
- return client.useInfiniteQuery(endpoint, options, config);
308
+ return client.useInfiniteQuery(endpoint, options, config);
309
309
  }
310
310
 
311
311
  /**
312
312
  * Hook to invalidate queries using the current QueryClient from context
313
313
  */
314
314
  export function useTypedInvalidateQueries<Paths>(
315
- client: TypedQueryClient<Paths>,
315
+ client: TypedQueryClient<Paths>,
316
316
  ) {
317
- const queryClient = useQueryClient();
317
+ const queryClient = useQueryClient();
318
318
 
319
- return {
320
- /**
321
- * Invalidate queries for a specific endpoint
322
- */
323
- invalidateQueries: <T extends QueryEndpoint<Paths>>(
324
- endpoint: T,
325
- config?: FilteredRequestConfig<Paths, T>,
326
- ) => {
327
- const queryKey = client.buildQueryKey(endpoint, config);
328
- return queryClient.invalidateQueries({
329
- queryKey,
330
- exact: !!config,
331
- });
332
- },
319
+ return {
320
+ /**
321
+ * Invalidate queries for a specific endpoint
322
+ */
323
+ invalidateQueries: <T extends QueryEndpoint<Paths>>(
324
+ endpoint: T,
325
+ config?: FilteredRequestConfig<Paths, T>,
326
+ ) => {
327
+ const queryKey = client.buildQueryKey(endpoint, config);
328
+ return queryClient.invalidateQueries({
329
+ queryKey,
330
+ exact: !!config,
331
+ });
332
+ },
333
333
 
334
- /**
335
- * Invalidate all queries
336
- */
337
- invalidateAllQueries: () => {
338
- return queryClient.invalidateQueries();
339
- },
340
- };
334
+ /**
335
+ * Invalidate all queries
336
+ */
337
+ invalidateAllQueries: () => {
338
+ return queryClient.invalidateQueries();
339
+ },
340
+ };
341
341
  }