@geekmidas/client 10.0.0-alpha.2 → 10.0.0-alpha.21
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/README.md +39 -57
- package/dist/auth-fetcher.cjs +78 -3
- package/dist/auth-fetcher.cjs.map +1 -0
- package/dist/auth-fetcher.d.cts +155 -3
- package/dist/auth-fetcher.d.cts.map +1 -0
- package/dist/auth-fetcher.d.mts +155 -3
- package/dist/auth-fetcher.d.mts.map +1 -0
- package/dist/auth-fetcher.mjs +77 -3
- package/dist/auth-fetcher.mjs.map +1 -0
- package/dist/endpoint-hooks.cjs +11 -15
- package/dist/endpoint-hooks.cjs.map +1 -1
- package/dist/endpoint-hooks.d.cts +4 -7
- package/dist/endpoint-hooks.d.cts.map +1 -1
- package/dist/endpoint-hooks.d.mts +4 -7
- package/dist/endpoint-hooks.d.mts.map +1 -1
- package/dist/endpoint-hooks.mjs +5 -9
- package/dist/endpoint-hooks.mjs.map +1 -1
- package/dist/fetcher.cjs +111 -3
- package/dist/fetcher.cjs.map +1 -0
- package/dist/fetcher.d.cts +23 -3
- package/dist/fetcher.d.cts.map +1 -0
- package/dist/fetcher.d.mts +23 -3
- package/dist/fetcher.d.mts.map +1 -0
- package/dist/fetcher.mjs +86 -2
- package/dist/fetcher.mjs.map +1 -0
- package/dist/index.cjs +9 -6
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +6 -6
- package/dist/infer.cjs +0 -1
- package/dist/infer.d.cts +130 -2
- package/dist/infer.d.cts.map +1 -0
- package/dist/infer.d.mts +130 -2
- package/dist/infer.d.mts.map +1 -0
- package/dist/infer.mjs +1 -1
- package/dist/methods.cjs +21 -0
- package/dist/methods.cjs.map +1 -0
- package/dist/methods.d.cts +23 -0
- package/dist/methods.d.cts.map +1 -0
- package/dist/methods.d.mts +23 -0
- package/dist/methods.d.mts.map +1 -0
- package/dist/methods.mjs +19 -0
- package/dist/methods.mjs.map +1 -0
- package/dist/openapi-hooks.cjs +13 -16
- package/dist/openapi-hooks.cjs.map +1 -1
- package/dist/openapi-hooks.d.cts +8 -11
- package/dist/openapi-hooks.d.cts.map +1 -1
- package/dist/openapi-hooks.d.mts +8 -11
- package/dist/openapi-hooks.d.mts.map +1 -1
- package/dist/openapi-hooks.mjs +9 -12
- package/dist/openapi-hooks.mjs.map +1 -1
- package/dist/openapi-types.d.cts +5 -6
- package/dist/openapi-types.d.cts.map +1 -1
- package/dist/openapi-types.d.mts +5 -6
- package/dist/openapi-types.d.mts.map +1 -1
- package/dist/react-query.cjs +17 -16
- package/dist/react-query.cjs.map +1 -1
- package/dist/react-query.d.cts +12 -17
- package/dist/react-query.d.cts.map +1 -1
- package/dist/react-query.d.mts +12 -17
- package/dist/react-query.d.mts.map +1 -1
- package/dist/react-query.mjs +10 -9
- package/dist/react-query.mjs.map +1 -1
- package/dist/types.cjs +0 -1
- package/dist/types.d.cts +114 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +114 -2
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -1
- package/package.json +14 -14
- package/dist/auth-fetcher-CBYuL6rx.d.cts +0 -158
- package/dist/auth-fetcher-CBYuL6rx.d.cts.map +0 -1
- package/dist/auth-fetcher-DOj0iz21.mjs +0 -77
- package/dist/auth-fetcher-DOj0iz21.mjs.map +0 -1
- package/dist/auth-fetcher-DxS8zOLc.d.mts +0 -158
- package/dist/auth-fetcher-DxS8zOLc.d.mts.map +0 -1
- package/dist/auth-fetcher-HILABmws.cjs +0 -82
- package/dist/auth-fetcher-HILABmws.cjs.map +0 -1
- package/dist/chunk-CUT6urMc.cjs +0 -30
- package/dist/fetcher-C1xtCKpT.d.mts +0 -25
- package/dist/fetcher-C1xtCKpT.d.mts.map +0 -1
- package/dist/fetcher-CakjC9C7.mjs +0 -88
- package/dist/fetcher-CakjC9C7.mjs.map +0 -1
- package/dist/fetcher-CwnSqc4D.cjs +0 -100
- package/dist/fetcher-CwnSqc4D.cjs.map +0 -1
- package/dist/fetcher-cDrfwN-Y.d.cts +0 -25
- package/dist/fetcher-cDrfwN-Y.d.cts.map +0 -1
- package/dist/infer-6KKCgmg1.cjs +0 -0
- package/dist/infer-DfRq5kIb.d.cts +0 -133
- package/dist/infer-DfRq5kIb.d.cts.map +0 -1
- package/dist/infer-bTirNeNW.d.mts +0 -133
- package/dist/infer-bTirNeNW.d.mts.map +0 -1
- package/dist/infer-uCUq1whM.mjs +0 -0
- package/dist/openapi.cjs +0 -526
- package/dist/openapi.cjs.map +0 -1
- package/dist/openapi.mjs +0 -501
- package/dist/openapi.mjs.map +0 -1
- package/dist/types-BH8WgGrm.mjs +0 -0
- package/dist/types-BMGM6sZc.d.mts +0 -110
- package/dist/types-BMGM6sZc.d.mts.map +0 -1
- package/dist/types-DMQMHePI.d.cts +0 -110
- package/dist/types-DMQMHePI.d.cts.map +0 -1
- package/dist/types-a8gm_IaQ.cjs +0 -0
package/dist/react-query.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-query.cjs","names":["options: TypedQueryClientOptions","endpoint: T","config?: FilteredRequestConfig<Paths, T>","options?: Omit<\n\t\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t\t'queryKey' | 'queryFn'\n\t\t>","options?: Omit<\n\t\t\tUseMutationOptions<\n\t\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\t\tResponse,\n\t\t\t\tFilteredRequestConfig<Paths, T>\n\t\t\t>,\n\t\t\t'mutationFn'\n\t\t>","config: FilteredRequestConfig<Paths, T>","options: Omit<\n\t\t\tUseInfiniteQueryOptions<\n\t\t\t\tTPageData,\n\t\t\t\tResponse,\n\t\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\t\tunknown[],\n\t\t\t\tTPageParam\n\t\t\t>,\n\t\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t\t> & {\n\t\t\tgetNextPageParam: (\n\t\t\t\tlastPage: TPageData,\n\t\t\t\tallPages: TPageData[],\n\t\t\t\tlastPageParam: TPageParam,\n\t\t\t\tallPageParams: TPageParam[],\n\t\t\t) => TPageParam | undefined;\n\t\t\tinitialPageParam: TPageParam;\n\t\t}","key: unknown[]","queryClient: QueryClient","options?: TypedQueryClientOptions","client: TypedQueryClient<Paths>","options?: Omit<\n\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t'queryKey' | 'queryFn'\n\t>","options?: Omit<\n\t\tUseMutationOptions<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>,\n\t\t'mutationFn'\n\t>","options: Omit<\n\t\tUseInfiniteQueryOptions<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>,\n\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t> & {\n\t\tgetNextPageParam: (\n\t\t\tlastPage: TPageData,\n\t\t\tallPages: TPageData[],\n\t\t\tlastPageParam: TPageParam,\n\t\t\tallPageParams: TPageParam[],\n\t\t) => TPageParam | undefined;\n\t\tinitialPageParam: TPageParam;\n\t}"],"sources":["../src/react-query.ts"],"sourcesContent":["import type {\n\tQueryClient,\n\tQueryFunctionContext,\n\tUseInfiniteQueryOptions,\n\tUseMutationOptions,\n\tUseQueryOptions,\n} from '@tanstack/react-query';\nimport {\n\tuseInfiniteQuery,\n\tuseMutation,\n\tuseQuery,\n\tuseQueryClient,\n} from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { createTypedFetcher } from './fetcher';\nimport type {\n\tExtractEndpointResponse,\n\tFetcherOptions,\n\tFilteredRequestConfig,\n\tMutationEndpoint,\n\tQueryEndpoint,\n\tTypedEndpoint,\n} from './types';\n\nexport interface TypedQueryClientOptions extends FetcherOptions {\n\tqueryClient?: QueryClient;\n}\n\nexport class TypedQueryClient<Paths> {\n\tprivate fetcher: ReturnType<typeof createTypedFetcher<Paths>>;\n\tprivate queryClient?: QueryClient;\n\n\tconstructor(options: TypedQueryClientOptions = {}) {\n\t\tthis.fetcher = createTypedFetcher<Paths>(options);\n\t\tthis.queryClient = options.queryClient;\n\t}\n\n\tuseQuery<T extends QueryEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\toptions?: Omit<\n\t\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t\t'queryKey' | 'queryFn'\n\t\t>,\n\t) {\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: () => this.fetcher(endpoint, config),\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: queryKey, endpoint, config, and options\n\t\t\t// Note: We stringify config and options to ensure stable references\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[\n\t\t\t\tqueryKey.join(','),\n\t\t\t\tendpoint,\n\t\t\t\tJSON.stringify(config),\n\t\t\t\tJSON.stringify(options),\n\t\t\t],\n\t\t);\n\n\t\treturn useQuery<ExtractEndpointResponse<Paths, T>, Response>(\n\t\t\tmemoizedOptions,\n\t\t);\n\t}\n\n\tuseMutation<T extends MutationEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\toptions?: Omit<\n\t\t\tUseMutationOptions<\n\t\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\t\tResponse,\n\t\t\t\tFilteredRequestConfig<Paths, T>\n\t\t\t>,\n\t\t\t'mutationFn'\n\t\t>,\n\t) {\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tmutationFn: (config: FilteredRequestConfig<Paths, T>) =>\n\t\t\t\t\tthis.fetcher(endpoint, config),\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: endpoint and options\n\t\t\t// Note: We stringify options to ensure stable reference\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[endpoint, JSON.stringify(options)],\n\t\t);\n\n\t\treturn useMutation<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>(memoizedOptions);\n\t}\n\n\tuseInfiniteQuery<\n\t\tT extends QueryEndpoint<Paths>,\n\t\tTPageData = ExtractEndpointResponse<Paths, T>,\n\t\tTPageParam = unknown,\n\t>(\n\t\tendpoint: T,\n\t\toptions: Omit<\n\t\t\tUseInfiniteQueryOptions<\n\t\t\t\tTPageData,\n\t\t\t\tResponse,\n\t\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\t\tunknown[],\n\t\t\t\tTPageParam\n\t\t\t>,\n\t\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t\t> & {\n\t\t\tgetNextPageParam: (\n\t\t\t\tlastPage: TPageData,\n\t\t\t\tallPages: TPageData[],\n\t\t\t\tlastPageParam: TPageParam,\n\t\t\t\tallPageParams: TPageParam[],\n\t\t\t) => TPageParam | undefined;\n\t\t\tinitialPageParam: TPageParam;\n\t\t},\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t) {\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: ({\n\t\t\t\t\tpageParam,\n\t\t\t\t}: QueryFunctionContext<unknown[], TPageParam>) => {\n\t\t\t\t\tlet mergedConfig = config;\n\t\t\t\t\tif (pageParam !== undefined && config) {\n\t\t\t\t\t\t// If pageParam is an object, spread it into query\n\t\t\t\t\t\tconst pageQuery =\n\t\t\t\t\t\t\ttypeof pageParam === 'object' ? pageParam : { page: pageParam };\n\t\t\t\t\t\tmergedConfig = {\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\tquery: { ...(config as any).query, ...pageQuery },\n\t\t\t\t\t\t} as any;\n\t\t\t\t\t} else if (pageParam !== undefined && !config) {\n\t\t\t\t\t\t// If pageParam is an object, use it directly, otherwise wrap in page property\n\t\t\t\t\t\tconst pageQuery =\n\t\t\t\t\t\t\ttypeof pageParam === 'object' ? pageParam : { page: pageParam };\n\t\t\t\t\t\tmergedConfig = { query: pageQuery } as any;\n\t\t\t\t\t}\n\t\t\t\t\treturn this.fetcher(endpoint, mergedConfig) as Promise<TPageData>;\n\t\t\t\t},\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: queryKey, endpoint, config, and options\n\t\t\t// Note: We stringify config and options to ensure stable references\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[\n\t\t\t\tqueryKey.join(','),\n\t\t\t\tendpoint,\n\t\t\t\tJSON.stringify(config),\n\t\t\t\tJSON.stringify(options),\n\t\t\t],\n\t\t);\n\n\t\treturn useInfiniteQuery<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>(memoizedOptions);\n\t}\n\n\tbuildQueryKey<T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): unknown[] {\n\t\tconst key: unknown[] = [endpoint];\n\n\t\tif (config && 'params' in config && config.params) {\n\t\t\tkey.push({ params: config.params });\n\t\t}\n\n\t\tif (config && 'query' in config && config.query) {\n\t\t\tkey.push({ query: config.query });\n\t\t}\n\n\t\treturn key;\n\t}\n\n\t/**\n\t * Invalidate queries for a specific endpoint with optional config\n\t * @param endpoint - The endpoint to invalidate (e.g., 'GET /users')\n\t * @param config - Optional params/query to match specific queries\n\t * @returns Promise that resolves when invalidation is complete\n\t */\n\tinvalidateQueries<T extends QueryEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): Promise<void> {\n\t\tconst queryClient = this.getQueryClient();\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\treturn queryClient.invalidateQueries({\n\t\t\tqueryKey,\n\t\t\texact: !!config, // Use exact matching if config is provided\n\t\t});\n\t}\n\n\t/**\n\t * Invalidate all queries in the cache\n\t * @returns Promise that resolves when invalidation is complete\n\t */\n\tinvalidateAllQueries(): Promise<void> {\n\t\tconst queryClient = this.getQueryClient();\n\t\treturn queryClient.invalidateQueries();\n\t}\n\n\t/**\n\t * Get the underlying QueryClient instance\n\t * @returns The QueryClient instance\n\t */\n\tgetQueryClient(): QueryClient {\n\t\tif (this.queryClient) {\n\t\t\treturn this.queryClient;\n\t\t}\n\n\t\t// If no query client was provided, try to get it from context\n\t\t// This will throw if used outside of QueryClientProvider\n\t\tthrow new Error(\n\t\t\t'No QueryClient set, please provide a QueryClient via the queryClient option or ensure you are within a QueryClientProvider',\n\t\t);\n\t}\n\n\t/**\n\t * Set the QueryClient instance\n\t * @param queryClient - The QueryClient instance to use\n\t */\n\tsetQueryClient(queryClient: QueryClient): void {\n\t\tthis.queryClient = queryClient;\n\t}\n}\n\nexport function createTypedQueryClient<Paths>(\n\toptions?: TypedQueryClientOptions,\n) {\n\treturn new TypedQueryClient<Paths>(options);\n}\n\n// Hook exports for convenience\nexport function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\tconfig?: FilteredRequestConfig<Paths, T>,\n\toptions?: Omit<\n\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t'queryKey' | 'queryFn'\n\t>,\n) {\n\treturn client.useQuery(endpoint, config, options);\n}\n\nexport function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\toptions?: Omit<\n\t\tUseMutationOptions<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>,\n\t\t'mutationFn'\n\t>,\n) {\n\treturn client.useMutation(endpoint, options);\n}\n\nexport function useTypedInfiniteQuery<\n\tPaths,\n\tT extends QueryEndpoint<Paths>,\n\tTPageData = ExtractEndpointResponse<Paths, T>,\n\tTPageParam = unknown,\n>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\toptions: Omit<\n\t\tUseInfiniteQueryOptions<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>,\n\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t> & {\n\t\tgetNextPageParam: (\n\t\t\tlastPage: TPageData,\n\t\t\tallPages: TPageData[],\n\t\t\tlastPageParam: TPageParam,\n\t\t\tallPageParams: TPageParam[],\n\t\t) => TPageParam | undefined;\n\t\tinitialPageParam: TPageParam;\n\t},\n\tconfig?: FilteredRequestConfig<Paths, T>,\n) {\n\treturn client.useInfiniteQuery(endpoint, options, config);\n}\n\n/**\n * Hook to invalidate queries using the current QueryClient from context\n */\nexport function useTypedInvalidateQueries<Paths>(\n\tclient: TypedQueryClient<Paths>,\n) {\n\tconst queryClient = useQueryClient();\n\n\treturn {\n\t\t/**\n\t\t * Invalidate queries for a specific endpoint\n\t\t */\n\t\tinvalidateQueries: <T extends QueryEndpoint<Paths>>(\n\t\t\tendpoint: T,\n\t\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\t) => {\n\t\t\tconst queryKey = client.buildQueryKey(endpoint, config);\n\t\t\treturn queryClient.invalidateQueries({\n\t\t\t\tqueryKey,\n\t\t\t\texact: !!config,\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * Invalidate all queries\n\t\t */\n\t\tinvalidateAllQueries: () => {\n\t\t\treturn queryClient.invalidateQueries();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;AA4BA,IAAa,mBAAb,MAAqC;CACpC,AAAQ;CACR,AAAQ;CAER,YAAYA,UAAmC,CAAE,GAAE;AAClD,OAAK,UAAU,mCAA0B,QAAQ;AACjD,OAAK,cAAc,QAAQ;CAC3B;CAED,SACCC,UACAC,QACAC,SAIC;EACD,MAAM,WAAW,KAAK,cAAc,UAAU,OAAO;EAGrD,MAAM,kBAAkB,mBACvB,OAAO;GACN;GACA,SAAS,MAAM,KAAK,QAAQ,UAAU,OAAO;GAC7C,GAAG;EACH,IAID;GACC,SAAS,KAAK,IAAI;GAClB;GACA,KAAK,UAAU,OAAO;GACtB,KAAK,UAAU,QAAQ;EACvB,EACD;AAED,SAAO,qCACN,gBACA;CACD;CAED,YACCF,UACAG,SAQC;EAED,MAAM,kBAAkB,mBACvB,OAAO;GACN,YAAY,CAACC,WACZ,KAAK,QAAQ,UAAU,OAAO;GAC/B,GAAG;EACH,IAID,CAAC,UAAU,KAAK,UAAU,QAAQ,AAAC,EACnC;AAED,SAAO,wCAIL,gBAAgB;CAClB;CAED,iBAKCJ,UACAK,SAkBAJ,QACC;EACD,MAAM,WAAW,KAAK,cAAc,UAAU,OAAO;EAGrD,MAAM,kBAAkB,mBACvB,OAAO;GACN;GACA,SAAS,CAAC,EACT,WAC6C,KAAK;IAClD,IAAI,eAAe;AACnB,QAAI,wBAA2B,QAAQ;KAEtC,MAAM,mBACE,cAAc,WAAW,YAAY,EAAE,MAAM,UAAW;AAChE,oBAAe;MACd,GAAG;MACH,OAAO;OAAE,GAAI,OAAe;OAAO,GAAG;MAAW;KACjD;IACD,WAAU,yBAA4B,QAAQ;KAE9C,MAAM,mBACE,cAAc,WAAW,YAAY,EAAE,MAAM,UAAW;AAChE,oBAAe,EAAE,OAAO,UAAW;IACnC;AACD,WAAO,KAAK,QAAQ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WAAW,OAAO,cAAc,UAAU,OAAO;AACvD,UAAO,YAAY,kBAAkB;IACpC;IACA,SAAS;GACT,EAAC;EACF;EAKD,sBAAsB,MAAM;AAC3B,UAAO,YAAY,mBAAmB;EACtC;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"react-query.cjs","names":["createTypedFetcher","useMemo","useQuery","useMutation","useInfiniteQuery","useQueryClient"],"sources":["../src/react-query.ts"],"sourcesContent":["import type {\n\tQueryClient,\n\tQueryFunctionContext,\n\tUseInfiniteQueryOptions,\n\tUseMutationOptions,\n\tUseQueryOptions,\n} from '@tanstack/react-query';\nimport {\n\tuseInfiniteQuery,\n\tuseMutation,\n\tuseQuery,\n\tuseQueryClient,\n} from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { createTypedFetcher } from './fetcher';\nimport type {\n\tExtractEndpointResponse,\n\tFetcherOptions,\n\tFilteredRequestConfig,\n\tMutationEndpoint,\n\tQueryEndpoint,\n\tTypedEndpoint,\n} from './types';\n\nexport interface TypedQueryClientOptions extends FetcherOptions {\n\tqueryClient?: QueryClient;\n}\n\nexport class TypedQueryClient<Paths> {\n\tprivate fetcher: ReturnType<typeof createTypedFetcher<Paths>>;\n\tprivate queryClient?: QueryClient;\n\n\tconstructor(options: TypedQueryClientOptions = {}) {\n\t\tthis.fetcher = createTypedFetcher<Paths>(options);\n\t\tthis.queryClient = options.queryClient;\n\t}\n\n\tuseQuery<T extends QueryEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\toptions?: Omit<\n\t\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t\t'queryKey' | 'queryFn'\n\t\t>,\n\t) {\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: () => this.fetcher(endpoint, config),\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: queryKey, endpoint, config, and options\n\t\t\t// Note: We stringify config and options to ensure stable references\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[\n\t\t\t\tqueryKey.join(','),\n\t\t\t\tendpoint,\n\t\t\t\tJSON.stringify(config),\n\t\t\t\tJSON.stringify(options),\n\t\t\t],\n\t\t);\n\n\t\treturn useQuery<ExtractEndpointResponse<Paths, T>, Response>(\n\t\t\tmemoizedOptions,\n\t\t);\n\t}\n\n\tuseMutation<T extends MutationEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\toptions?: Omit<\n\t\t\tUseMutationOptions<\n\t\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\t\tResponse,\n\t\t\t\tFilteredRequestConfig<Paths, T>\n\t\t\t>,\n\t\t\t'mutationFn'\n\t\t>,\n\t) {\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tmutationFn: (config: FilteredRequestConfig<Paths, T>) =>\n\t\t\t\t\tthis.fetcher(endpoint, config),\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: endpoint and options\n\t\t\t// Note: We stringify options to ensure stable reference\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[endpoint, JSON.stringify(options)],\n\t\t);\n\n\t\treturn useMutation<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>(memoizedOptions);\n\t}\n\n\tuseInfiniteQuery<\n\t\tT extends QueryEndpoint<Paths>,\n\t\tTPageData = ExtractEndpointResponse<Paths, T>,\n\t\tTPageParam = unknown,\n\t>(\n\t\tendpoint: T,\n\t\toptions: Omit<\n\t\t\tUseInfiniteQueryOptions<\n\t\t\t\tTPageData,\n\t\t\t\tResponse,\n\t\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\t\tunknown[],\n\t\t\t\tTPageParam\n\t\t\t>,\n\t\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t\t> & {\n\t\t\tgetNextPageParam: (\n\t\t\t\tlastPage: TPageData,\n\t\t\t\tallPages: TPageData[],\n\t\t\t\tlastPageParam: TPageParam,\n\t\t\t\tallPageParams: TPageParam[],\n\t\t\t) => TPageParam | undefined;\n\t\t\tinitialPageParam: TPageParam;\n\t\t},\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t) {\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: ({\n\t\t\t\t\tpageParam,\n\t\t\t\t}: QueryFunctionContext<unknown[], TPageParam>) => {\n\t\t\t\t\tlet mergedConfig = config;\n\t\t\t\t\tif (pageParam !== undefined && config) {\n\t\t\t\t\t\t// If pageParam is an object, spread it into query\n\t\t\t\t\t\tconst pageQuery =\n\t\t\t\t\t\t\ttypeof pageParam === 'object' ? pageParam : { page: pageParam };\n\t\t\t\t\t\tmergedConfig = {\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\tquery: { ...(config as any).query, ...pageQuery },\n\t\t\t\t\t\t} as any;\n\t\t\t\t\t} else if (pageParam !== undefined && !config) {\n\t\t\t\t\t\t// If pageParam is an object, use it directly, otherwise wrap in page property\n\t\t\t\t\t\tconst pageQuery =\n\t\t\t\t\t\t\ttypeof pageParam === 'object' ? pageParam : { page: pageParam };\n\t\t\t\t\t\tmergedConfig = { query: pageQuery } as any;\n\t\t\t\t\t}\n\t\t\t\t\treturn this.fetcher(endpoint, mergedConfig) as Promise<TPageData>;\n\t\t\t\t},\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: queryKey, endpoint, config, and options\n\t\t\t// Note: We stringify config and options to ensure stable references\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[\n\t\t\t\tqueryKey.join(','),\n\t\t\t\tendpoint,\n\t\t\t\tJSON.stringify(config),\n\t\t\t\tJSON.stringify(options),\n\t\t\t],\n\t\t);\n\n\t\treturn useInfiniteQuery<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>(memoizedOptions);\n\t}\n\n\tbuildQueryKey<T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): unknown[] {\n\t\tconst key: unknown[] = [endpoint];\n\n\t\tif (config && 'params' in config && config.params) {\n\t\t\tkey.push({ params: config.params });\n\t\t}\n\n\t\tif (config && 'query' in config && config.query) {\n\t\t\tkey.push({ query: config.query });\n\t\t}\n\n\t\treturn key;\n\t}\n\n\t/**\n\t * Invalidate queries for a specific endpoint with optional config\n\t * @param endpoint - The endpoint to invalidate (e.g., 'GET /users')\n\t * @param config - Optional params/query to match specific queries\n\t * @returns Promise that resolves when invalidation is complete\n\t */\n\tinvalidateQueries<T extends QueryEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): Promise<void> {\n\t\tconst queryClient = this.getQueryClient();\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\treturn queryClient.invalidateQueries({\n\t\t\tqueryKey,\n\t\t\texact: !!config, // Use exact matching if config is provided\n\t\t});\n\t}\n\n\t/**\n\t * Invalidate all queries in the cache\n\t * @returns Promise that resolves when invalidation is complete\n\t */\n\tinvalidateAllQueries(): Promise<void> {\n\t\tconst queryClient = this.getQueryClient();\n\t\treturn queryClient.invalidateQueries();\n\t}\n\n\t/**\n\t * Get the underlying QueryClient instance\n\t * @returns The QueryClient instance\n\t */\n\tgetQueryClient(): QueryClient {\n\t\tif (this.queryClient) {\n\t\t\treturn this.queryClient;\n\t\t}\n\n\t\t// If no query client was provided, try to get it from context\n\t\t// This will throw if used outside of QueryClientProvider\n\t\tthrow new Error(\n\t\t\t'No QueryClient set, please provide a QueryClient via the queryClient option or ensure you are within a QueryClientProvider',\n\t\t);\n\t}\n\n\t/**\n\t * Set the QueryClient instance\n\t * @param queryClient - The QueryClient instance to use\n\t */\n\tsetQueryClient(queryClient: QueryClient): void {\n\t\tthis.queryClient = queryClient;\n\t}\n}\n\nexport function createTypedQueryClient<Paths>(\n\toptions?: TypedQueryClientOptions,\n) {\n\treturn new TypedQueryClient<Paths>(options);\n}\n\n// Hook exports for convenience\nexport function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\tconfig?: FilteredRequestConfig<Paths, T>,\n\toptions?: Omit<\n\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t'queryKey' | 'queryFn'\n\t>,\n) {\n\treturn client.useQuery(endpoint, config, options);\n}\n\nexport function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\toptions?: Omit<\n\t\tUseMutationOptions<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>,\n\t\t'mutationFn'\n\t>,\n) {\n\treturn client.useMutation(endpoint, options);\n}\n\nexport function useTypedInfiniteQuery<\n\tPaths,\n\tT extends QueryEndpoint<Paths>,\n\tTPageData = ExtractEndpointResponse<Paths, T>,\n\tTPageParam = unknown,\n>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\toptions: Omit<\n\t\tUseInfiniteQueryOptions<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>,\n\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t> & {\n\t\tgetNextPageParam: (\n\t\t\tlastPage: TPageData,\n\t\t\tallPages: TPageData[],\n\t\t\tlastPageParam: TPageParam,\n\t\t\tallPageParams: TPageParam[],\n\t\t) => TPageParam | undefined;\n\t\tinitialPageParam: TPageParam;\n\t},\n\tconfig?: FilteredRequestConfig<Paths, T>,\n) {\n\treturn client.useInfiniteQuery(endpoint, options, config);\n}\n\n/**\n * Hook to invalidate queries using the current QueryClient from context\n */\nexport function useTypedInvalidateQueries<Paths>(\n\tclient: TypedQueryClient<Paths>,\n) {\n\tconst queryClient = useQueryClient();\n\n\treturn {\n\t\t/**\n\t\t * Invalidate queries for a specific endpoint\n\t\t */\n\t\tinvalidateQueries: <T extends QueryEndpoint<Paths>>(\n\t\t\tendpoint: T,\n\t\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\t) => {\n\t\t\tconst queryKey = client.buildQueryKey(endpoint, config);\n\t\t\treturn queryClient.invalidateQueries({\n\t\t\t\tqueryKey,\n\t\t\t\texact: !!config,\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * Invalidate all queries\n\t\t */\n\t\tinvalidateAllQueries: () => {\n\t\t\treturn queryClient.invalidateQueries();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;AA4BA,IAAa,mBAAb,MAAqC;CACpC;CACA;CAEA,YAAY,UAAmC,CAAC,GAAG;EAClD,KAAK,UAAUA,gBAAAA,mBAA0B,OAAO;EAChD,KAAK,cAAc,QAAQ;CAC5B;CAEA,SACC,UACA,QACA,SAIC;EACD,MAAM,WAAW,KAAK,cAAc,UAAU,MAAM;EAGpD,MAAM,mBAAA,GAAkBC,MAAAA,QAAAA,QAChB;GACN;GACA,eAAe,KAAK,QAAQ,UAAU,MAAM;GAC5C,GAAG;EACJ,IAIA;GACC,SAAS,KAAK,GAAG;GACjB;GACA,KAAK,UAAU,MAAM;GACrB,KAAK,UAAU,OAAO;EACvB,CACD;EAEA,QAAA,GAAOC,sBAAAA,SAAAA,CACN,eACD;C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UAAU,MAAM;EAEpD,OAAO,YAAY,kBAAkB;GACpC;GACA,OAAO,CAAC,CAAC;EACV,CAAC;CACF;;;;;CAMA,uBAAsC;EAErC,OADoB,KAAK,eACR,CAAC,CAAC,kBAAkB;CACtC;;;;;CAMA,iBAA8B;EAC7B,IAAI,KAAK,aACR,OAAO,KAAK;EAKb,MAAM,IAAI,MACT,4HACD;CACD;;;;;CAMA,eAAe,aAAgC;EAC9C,KAAK,cAAc;CACpB;AACD;AAEA,SAAgB,uBACf,SACC;CACD,OAAO,IAAI,iBAAwB,OAAO;AAC3C;AAGA,SAAgB,cACf,QACA,UACA,QACA,SAIC;CACD,OAAO,OAAO,SAAS,UAAU,QAAQ,OAAO;AACjD;AAEA,SAAgB,iBACf,QACA,UACA,SAQC;CACD,OAAO,OAAO,YAAY,UAAU,OAAO;AAC5C;AAEA,SAAgB,sBAMf,QACA,UACA,SAkBA,QACC;CACD,OAAO,OAAO,iBAAiB,UAAU,SAAS,MAAM;AACzD;;;;AAKA,SAAgB,0BACf,QACC;CACD,MAAM,eAAA,GAAcC,sBAAAA,eAAAA,CAAe;CAEnC,OAAO;;;;EAIN,oBACC,UACA,WACI;GACJ,MAAM,WAAW,OAAO,cAAc,UAAU,MAAM;GACtD,OAAO,YAAY,kBAAkB;IACpC;IACA,OAAO,CAAC,CAAC;GACV,CAAC;EACF;;;;EAKA,4BAA4B;GAC3B,OAAO,YAAY,kBAAkB;EACtC;CACD;AACD"}
|
package/dist/react-query.d.cts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, MutationEndpoint, QueryEndpoint, TypedEndpoint } from "./types
|
|
2
|
-
import * as _tanstack_react_query0 from "@tanstack/react-query";
|
|
1
|
+
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, MutationEndpoint, QueryEndpoint, TypedEndpoint } from "./types.cjs";
|
|
3
2
|
import { QueryClient, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
|
-
|
|
5
3
|
//#region src/react-query.d.ts
|
|
6
|
-
interface TypedQueryClientOptions extends FetcherOptions {
|
|
4
|
+
export interface TypedQueryClientOptions extends FetcherOptions {
|
|
7
5
|
queryClient?: QueryClient;
|
|
8
6
|
}
|
|
9
|
-
declare class TypedQueryClient<Paths> {
|
|
7
|
+
export declare class TypedQueryClient<Paths> {
|
|
10
8
|
private fetcher;
|
|
11
9
|
private queryClient?;
|
|
12
10
|
constructor(options?: TypedQueryClientOptions);
|
|
13
|
-
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>):
|
|
14
|
-
useMutation<T extends MutationEndpoint<Paths>>(endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>):
|
|
11
|
+
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<ExtractEndpointResponse<Paths, T>, Response>;
|
|
12
|
+
useMutation<T extends MutationEndpoint<Paths>>(endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): import("@tanstack/react-query").UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
15
13
|
useInfiniteQuery<T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
16
14
|
pages: TPageData[];
|
|
17
15
|
pageParams: TPageParam[];
|
|
18
16
|
}, unknown[], TPageParam>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
|
|
19
17
|
getNextPageParam: (lastPage: TPageData, allPages: TPageData[], lastPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined;
|
|
20
18
|
initialPageParam: TPageParam;
|
|
21
|
-
}, config?: FilteredRequestConfig<Paths, T>):
|
|
19
|
+
}, config?: FilteredRequestConfig<Paths, T>): import("@tanstack/react-query").UseInfiniteQueryResult<{
|
|
22
20
|
pages: TPageData[];
|
|
23
21
|
pageParams: TPageParam[];
|
|
24
22
|
}, Response>;
|
|
@@ -46,23 +44,23 @@ declare class TypedQueryClient<Paths> {
|
|
|
46
44
|
*/
|
|
47
45
|
setQueryClient(queryClient: QueryClient): void;
|
|
48
46
|
}
|
|
49
|
-
declare function createTypedQueryClient<Paths>(options?: TypedQueryClientOptions): TypedQueryClient<Paths>;
|
|
50
|
-
declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>):
|
|
51
|
-
declare function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>):
|
|
52
|
-
declare function useTypedInfiniteQuery<Paths, T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(client: TypedQueryClient<Paths>, endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
47
|
+
export declare function createTypedQueryClient<Paths>(options?: TypedQueryClientOptions): TypedQueryClient<Paths>;
|
|
48
|
+
export declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<ExtractEndpointResponse<Paths, T>, Response>;
|
|
49
|
+
export declare function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): import("@tanstack/react-query").UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
50
|
+
export declare function useTypedInfiniteQuery<Paths, T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(client: TypedQueryClient<Paths>, endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
53
51
|
pages: TPageData[];
|
|
54
52
|
pageParams: TPageParam[];
|
|
55
53
|
}, unknown[], TPageParam>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
|
|
56
54
|
getNextPageParam: (lastPage: TPageData, allPages: TPageData[], lastPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined;
|
|
57
55
|
initialPageParam: TPageParam;
|
|
58
|
-
}, config?: FilteredRequestConfig<Paths, T>):
|
|
56
|
+
}, config?: FilteredRequestConfig<Paths, T>): import("@tanstack/react-query").UseInfiniteQueryResult<{
|
|
59
57
|
pages: TPageData[];
|
|
60
58
|
pageParams: TPageParam[];
|
|
61
59
|
}, Response>;
|
|
62
60
|
/**
|
|
63
61
|
* Hook to invalidate queries using the current QueryClient from context
|
|
64
62
|
*/
|
|
65
|
-
declare function useTypedInvalidateQueries<Paths>(client: TypedQueryClient<Paths>): {
|
|
63
|
+
export declare function useTypedInvalidateQueries<Paths>(client: TypedQueryClient<Paths>): {
|
|
66
64
|
/**
|
|
67
65
|
* Invalidate queries for a specific endpoint
|
|
68
66
|
*/
|
|
@@ -72,8 +70,5 @@ declare function useTypedInvalidateQueries<Paths>(client: TypedQueryClient<Paths
|
|
|
72
70
|
*/
|
|
73
71
|
invalidateAllQueries: () => Promise<void>;
|
|
74
72
|
};
|
|
75
|
-
//# sourceMappingURL=react-query.d.ts.map
|
|
76
|
-
|
|
77
73
|
//#endregion
|
|
78
|
-
export { TypedQueryClient, TypedQueryClientOptions, createTypedQueryClient, useTypedInfiniteQuery, useTypedInvalidateQueries, useTypedMutation, useTypedQuery };
|
|
79
74
|
//# sourceMappingURL=react-query.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-query.d.cts","names":[],"sources":["../src/react-query.ts"],"
|
|
1
|
+
{"version":3,"file":"react-query.d.cts","names":[],"sources":["../src/react-query.ts"],"mappings":";;;iBAwBiB,gCAAgC;EAChD,cAAc;;qBAGF,iBAAiB;UACrB;UACA;EAER,YAAY,UAAS;EAKrB,SAAS,UAAU,cAAc,QAChC,UAAU,GACV,SAAS,sBAAsB,OAAO,IACtC,UAAU,KACT,gBAAgB,wBAAwB,OAAO,IAAI,qEAEnD,eAAA,wBAAA,OAAA,IAAA;EA2BF,YAAY,UAAU,iBAAiB,QACtC,UAAU,GACV,UAAU,KACT,mBACC,wBAAwB,OAAO,IAC/B,UACA,sBAAsB,OAAO,qDAG9B,kBAAA,wBAAA,OAAA,IAAA,UAAA,sBAAA,OAAA;EAsBF,iBACC,UAAU,cAAc,QACxB,YAAY,wBAAwB,OAAO,IAC3C,sBAEA,UAAU,GACV,SAAS,KACR,wBACC,WACA;IACE,OAAO;IAAa,YAAY;gBAElC;IAID,mBACC,UAAU,WACV,UAAU,aACV,eAAe,YACf,eAAe,iBACX;IACL,kBAAkB;KAEnB,SAAS,sBAAsB,OAAO,qCAAE;IA4C9B,OAAA;IAAyB,YAAA;KAInC;EAED,cAAc,UAAU,cAAc,QACrC,UAAU,GACV,SAAS,sBAAsB,OAAO;;;;;;;EAqBvC,kBAAkB,UAAU,cAAc,QACzC,UAAU,GACV,SAAS,sBAAsB,OAAO,KACpC;;;;;EAcH,wBAAwB;;;;;EASxB,kBAAkB;;;;;EAgBlB,eAAe,aAAa;;wBAKb,uBAAuB,OACtC,UAAU,0BAAuB,iBAAA;wBAMlB,cAAc,OAAO,UAAU,cAAc,QAC5D,QAAQ,iBAAiB,QACzB,UAAU,GACV,SAAS,sBAAsB,OAAO,IACtC,UAAU,KACT,gBAAgB,wBAAwB,OAAO,IAAI,qEAEnD,eAAA,wBAAA,OAAA,IAAA;wBAKc,iBAAiB,OAAO,UAAU,iBAAiB,QAClE,QAAQ,iBAAiB,QACzB,UAAU,GACV,UAAU,KACT,mBACC,wBAAwB,OAAO,IAC/B,UACA,sBAAsB,OAAO,qDAG9B,kBAAA,wBAAA,OAAA,IAAA,UAAA,sBAAA,OAAA;wBAKc,sBACf,OACA,UAAU,cAAc,QACxB,YAAY,wBAAwB,OAAO,IAC3C,sBAEA,QAAQ,iBAAiB,QACzB,UAAU,GACV,SAAS,KACR,wBACC,WACA;EACE,OAAO;EAAa,YAAY;cAElC;EAID,mBACC,UAAU,WACV,UAAU,aACV,eAAe,YACf,eAAe,iBACX;EACL,kBAAkB;GAEnB,SAAS,sBAAsB,OAAO,qCAAE;;;GAGxC;;;;wBAKe,0BAA0B,OACzC,QAAQ,iBAAiB;;;;EAQxB,oBAAoB,UAAU,cAAc,QAAM,UACvC,GAAC,SACF,sBAAsB,OAAO,OAAE;;;;EAYzC,4BAAoB"}
|
package/dist/react-query.d.mts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, MutationEndpoint, QueryEndpoint, TypedEndpoint } from "./types
|
|
2
|
-
import * as _tanstack_react_query3 from "@tanstack/react-query";
|
|
1
|
+
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, MutationEndpoint, QueryEndpoint, TypedEndpoint } from "./types.mjs";
|
|
3
2
|
import { QueryClient, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
|
-
|
|
5
3
|
//#region src/react-query.d.ts
|
|
6
|
-
interface TypedQueryClientOptions extends FetcherOptions {
|
|
4
|
+
export interface TypedQueryClientOptions extends FetcherOptions {
|
|
7
5
|
queryClient?: QueryClient;
|
|
8
6
|
}
|
|
9
|
-
declare class TypedQueryClient<Paths> {
|
|
7
|
+
export declare class TypedQueryClient<Paths> {
|
|
10
8
|
private fetcher;
|
|
11
9
|
private queryClient?;
|
|
12
10
|
constructor(options?: TypedQueryClientOptions);
|
|
13
|
-
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>):
|
|
14
|
-
useMutation<T extends MutationEndpoint<Paths>>(endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>):
|
|
11
|
+
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<ExtractEndpointResponse<Paths, T>, Response>;
|
|
12
|
+
useMutation<T extends MutationEndpoint<Paths>>(endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): import("@tanstack/react-query").UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
15
13
|
useInfiniteQuery<T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
16
14
|
pages: TPageData[];
|
|
17
15
|
pageParams: TPageParam[];
|
|
18
16
|
}, unknown[], TPageParam>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
|
|
19
17
|
getNextPageParam: (lastPage: TPageData, allPages: TPageData[], lastPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined;
|
|
20
18
|
initialPageParam: TPageParam;
|
|
21
|
-
}, config?: FilteredRequestConfig<Paths, T>):
|
|
19
|
+
}, config?: FilteredRequestConfig<Paths, T>): import("@tanstack/react-query").UseInfiniteQueryResult<{
|
|
22
20
|
pages: TPageData[];
|
|
23
21
|
pageParams: TPageParam[];
|
|
24
22
|
}, Response>;
|
|
@@ -46,23 +44,23 @@ declare class TypedQueryClient<Paths> {
|
|
|
46
44
|
*/
|
|
47
45
|
setQueryClient(queryClient: QueryClient): void;
|
|
48
46
|
}
|
|
49
|
-
declare function createTypedQueryClient<Paths>(options?: TypedQueryClientOptions): TypedQueryClient<Paths>;
|
|
50
|
-
declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>):
|
|
51
|
-
declare function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>):
|
|
52
|
-
declare function useTypedInfiniteQuery<Paths, T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(client: TypedQueryClient<Paths>, endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
47
|
+
export declare function createTypedQueryClient<Paths>(options?: TypedQueryClientOptions): TypedQueryClient<Paths>;
|
|
48
|
+
export declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<ExtractEndpointResponse<Paths, T>, Response>;
|
|
49
|
+
export declare function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): import("@tanstack/react-query").UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
50
|
+
export declare function useTypedInfiniteQuery<Paths, T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(client: TypedQueryClient<Paths>, endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
53
51
|
pages: TPageData[];
|
|
54
52
|
pageParams: TPageParam[];
|
|
55
53
|
}, unknown[], TPageParam>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
|
|
56
54
|
getNextPageParam: (lastPage: TPageData, allPages: TPageData[], lastPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined;
|
|
57
55
|
initialPageParam: TPageParam;
|
|
58
|
-
}, config?: FilteredRequestConfig<Paths, T>):
|
|
56
|
+
}, config?: FilteredRequestConfig<Paths, T>): import("@tanstack/react-query").UseInfiniteQueryResult<{
|
|
59
57
|
pages: TPageData[];
|
|
60
58
|
pageParams: TPageParam[];
|
|
61
59
|
}, Response>;
|
|
62
60
|
/**
|
|
63
61
|
* Hook to invalidate queries using the current QueryClient from context
|
|
64
62
|
*/
|
|
65
|
-
declare function useTypedInvalidateQueries<Paths>(client: TypedQueryClient<Paths>): {
|
|
63
|
+
export declare function useTypedInvalidateQueries<Paths>(client: TypedQueryClient<Paths>): {
|
|
66
64
|
/**
|
|
67
65
|
* Invalidate queries for a specific endpoint
|
|
68
66
|
*/
|
|
@@ -72,8 +70,5 @@ declare function useTypedInvalidateQueries<Paths>(client: TypedQueryClient<Paths
|
|
|
72
70
|
*/
|
|
73
71
|
invalidateAllQueries: () => Promise<void>;
|
|
74
72
|
};
|
|
75
|
-
//# sourceMappingURL=react-query.d.ts.map
|
|
76
|
-
|
|
77
73
|
//#endregion
|
|
78
|
-
export { TypedQueryClient, TypedQueryClientOptions, createTypedQueryClient, useTypedInfiniteQuery, useTypedInvalidateQueries, useTypedMutation, useTypedQuery };
|
|
79
74
|
//# sourceMappingURL=react-query.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-query.d.mts","names":[],"sources":["../src/react-query.ts"],"
|
|
1
|
+
{"version":3,"file":"react-query.d.mts","names":[],"sources":["../src/react-query.ts"],"mappings":";;;iBAwBiB,gCAAgC;EAChD,cAAc;;qBAGF,iBAAiB;UACrB;UACA;EAER,YAAY,UAAS;EAKrB,SAAS,UAAU,cAAc,QAChC,UAAU,GACV,SAAS,sBAAsB,OAAO,IACtC,UAAU,KACT,gBAAgB,wBAAwB,OAAO,IAAI,qEAEnD,eAAA,wBAAA,OAAA,IAAA;EA2BF,YAAY,UAAU,iBAAiB,QACtC,UAAU,GACV,UAAU,KACT,mBACC,wBAAwB,OAAO,IAC/B,UACA,sBAAsB,OAAO,qDAG9B,kBAAA,wBAAA,OAAA,IAAA,UAAA,sBAAA,OAAA;EAsBF,iBACC,UAAU,cAAc,QACxB,YAAY,wBAAwB,OAAO,IAC3C,sBAEA,UAAU,GACV,SAAS,KACR,wBACC,WACA;IACE,OAAO;IAAa,YAAY;gBAElC;IAID,mBACC,UAAU,WACV,UAAU,aACV,eAAe,YACf,eAAe,iBACX;IACL,kBAAkB;KAEnB,SAAS,sBAAsB,OAAO,qCAAE;IA4C9B,OAAA;IAAyB,YAAA;KAInC;EAED,cAAc,UAAU,cAAc,QACrC,UAAU,GACV,SAAS,sBAAsB,OAAO;;;;;;;EAqBvC,kBAAkB,UAAU,cAAc,QACzC,UAAU,GACV,SAAS,sBAAsB,OAAO,KACpC;;;;;EAcH,wBAAwB;;;;;EASxB,kBAAkB;;;;;EAgBlB,eAAe,aAAa;;wBAKb,uBAAuB,OACtC,UAAU,0BAAuB,iBAAA;wBAMlB,cAAc,OAAO,UAAU,cAAc,QAC5D,QAAQ,iBAAiB,QACzB,UAAU,GACV,SAAS,sBAAsB,OAAO,IACtC,UAAU,KACT,gBAAgB,wBAAwB,OAAO,IAAI,qEAEnD,eAAA,wBAAA,OAAA,IAAA;wBAKc,iBAAiB,OAAO,UAAU,iBAAiB,QAClE,QAAQ,iBAAiB,QACzB,UAAU,GACV,UAAU,KACT,mBACC,wBAAwB,OAAO,IAC/B,UACA,sBAAsB,OAAO,qDAG9B,kBAAA,wBAAA,OAAA,IAAA,UAAA,sBAAA,OAAA;wBAKc,sBACf,OACA,UAAU,cAAc,QACxB,YAAY,wBAAwB,OAAO,IAC3C,sBAEA,QAAQ,iBAAiB,QACzB,UAAU,GACV,SAAS,KACR,wBACC,WACA;EACE,OAAO;EAAa,YAAY;cAElC;EAID,mBACC,UAAU,WACV,UAAU,aACV,eAAe,YACf,eAAe,iBACX;EACL,kBAAkB;GAEnB,SAAS,sBAAsB,OAAO,qCAAE;;;GAGxC;;;;wBAKe,0BAA0B,OACzC,QAAQ,iBAAiB;;;;EAQxB,oBAAoB,UAAU,cAAc,QAAM,UACvC,GAAC,SACF,sBAAsB,OAAO,OAAE;;;;EAYzC,4BAAoB"}
|
package/dist/react-query.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { createTypedFetcher } from "./fetcher
|
|
1
|
+
import { createTypedFetcher } from "./fetcher.mjs";
|
|
2
2
|
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
|
|
5
4
|
//#region src/react-query.ts
|
|
6
5
|
var TypedQueryClient = class {
|
|
7
6
|
fetcher;
|
|
@@ -46,10 +45,7 @@ var TypedQueryClient = class {
|
|
|
46
45
|
...pageQuery
|
|
47
46
|
}
|
|
48
47
|
};
|
|
49
|
-
} else if (pageParam !== void 0 && !config) {
|
|
50
|
-
const pageQuery = typeof pageParam === "object" ? pageParam : { page: pageParam };
|
|
51
|
-
mergedConfig = { query: pageQuery };
|
|
52
|
-
}
|
|
48
|
+
} else if (pageParam !== void 0 && !config) mergedConfig = { query: typeof pageParam === "object" ? pageParam : { page: pageParam } };
|
|
53
49
|
return this.fetcher(endpoint, mergedConfig);
|
|
54
50
|
},
|
|
55
51
|
...options
|
|
@@ -86,8 +82,7 @@ var TypedQueryClient = class {
|
|
|
86
82
|
* @returns Promise that resolves when invalidation is complete
|
|
87
83
|
*/
|
|
88
84
|
invalidateAllQueries() {
|
|
89
|
-
|
|
90
|
-
return queryClient.invalidateQueries();
|
|
85
|
+
return this.getQueryClient().invalidateQueries();
|
|
91
86
|
}
|
|
92
87
|
/**
|
|
93
88
|
* Get the underlying QueryClient instance
|
|
@@ -123,6 +118,9 @@ function useTypedInfiniteQuery(client, endpoint, options, config) {
|
|
|
123
118
|
function useTypedInvalidateQueries(client) {
|
|
124
119
|
const queryClient = useQueryClient();
|
|
125
120
|
return {
|
|
121
|
+
/**
|
|
122
|
+
* Invalidate queries for a specific endpoint
|
|
123
|
+
*/
|
|
126
124
|
invalidateQueries: (endpoint, config) => {
|
|
127
125
|
const queryKey = client.buildQueryKey(endpoint, config);
|
|
128
126
|
return queryClient.invalidateQueries({
|
|
@@ -130,12 +128,15 @@ function useTypedInvalidateQueries(client) {
|
|
|
130
128
|
exact: !!config
|
|
131
129
|
});
|
|
132
130
|
},
|
|
131
|
+
/**
|
|
132
|
+
* Invalidate all queries
|
|
133
|
+
*/
|
|
133
134
|
invalidateAllQueries: () => {
|
|
134
135
|
return queryClient.invalidateQueries();
|
|
135
136
|
}
|
|
136
137
|
};
|
|
137
138
|
}
|
|
138
|
-
|
|
139
139
|
//#endregion
|
|
140
140
|
export { TypedQueryClient, createTypedQueryClient, useTypedInfiniteQuery, useTypedInvalidateQueries, useTypedMutation, useTypedQuery };
|
|
141
|
+
|
|
141
142
|
//# sourceMappingURL=react-query.mjs.map
|
package/dist/react-query.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-query.mjs","names":["options: TypedQueryClientOptions","endpoint: T","config?: FilteredRequestConfig<Paths, T>","options?: Omit<\n\t\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t\t'queryKey' | 'queryFn'\n\t\t>","options?: Omit<\n\t\t\tUseMutationOptions<\n\t\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\t\tResponse,\n\t\t\t\tFilteredRequestConfig<Paths, T>\n\t\t\t>,\n\t\t\t'mutationFn'\n\t\t>","config: FilteredRequestConfig<Paths, T>","options: Omit<\n\t\t\tUseInfiniteQueryOptions<\n\t\t\t\tTPageData,\n\t\t\t\tResponse,\n\t\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\t\tunknown[],\n\t\t\t\tTPageParam\n\t\t\t>,\n\t\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t\t> & {\n\t\t\tgetNextPageParam: (\n\t\t\t\tlastPage: TPageData,\n\t\t\t\tallPages: TPageData[],\n\t\t\t\tlastPageParam: TPageParam,\n\t\t\t\tallPageParams: TPageParam[],\n\t\t\t) => TPageParam | undefined;\n\t\t\tinitialPageParam: TPageParam;\n\t\t}","key: unknown[]","queryClient: QueryClient","options?: TypedQueryClientOptions","client: TypedQueryClient<Paths>","options?: Omit<\n\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t'queryKey' | 'queryFn'\n\t>","options?: Omit<\n\t\tUseMutationOptions<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>,\n\t\t'mutationFn'\n\t>","options: Omit<\n\t\tUseInfiniteQueryOptions<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>,\n\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t> & {\n\t\tgetNextPageParam: (\n\t\t\tlastPage: TPageData,\n\t\t\tallPages: TPageData[],\n\t\t\tlastPageParam: TPageParam,\n\t\t\tallPageParams: TPageParam[],\n\t\t) => TPageParam | undefined;\n\t\tinitialPageParam: TPageParam;\n\t}"],"sources":["../src/react-query.ts"],"sourcesContent":["import type {\n\tQueryClient,\n\tQueryFunctionContext,\n\tUseInfiniteQueryOptions,\n\tUseMutationOptions,\n\tUseQueryOptions,\n} from '@tanstack/react-query';\nimport {\n\tuseInfiniteQuery,\n\tuseMutation,\n\tuseQuery,\n\tuseQueryClient,\n} from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { createTypedFetcher } from './fetcher';\nimport type {\n\tExtractEndpointResponse,\n\tFetcherOptions,\n\tFilteredRequestConfig,\n\tMutationEndpoint,\n\tQueryEndpoint,\n\tTypedEndpoint,\n} from './types';\n\nexport interface TypedQueryClientOptions extends FetcherOptions {\n\tqueryClient?: QueryClient;\n}\n\nexport class TypedQueryClient<Paths> {\n\tprivate fetcher: ReturnType<typeof createTypedFetcher<Paths>>;\n\tprivate queryClient?: QueryClient;\n\n\tconstructor(options: TypedQueryClientOptions = {}) {\n\t\tthis.fetcher = createTypedFetcher<Paths>(options);\n\t\tthis.queryClient = options.queryClient;\n\t}\n\n\tuseQuery<T extends QueryEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\toptions?: Omit<\n\t\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t\t'queryKey' | 'queryFn'\n\t\t>,\n\t) {\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: () => this.fetcher(endpoint, config),\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: queryKey, endpoint, config, and options\n\t\t\t// Note: We stringify config and options to ensure stable references\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[\n\t\t\t\tqueryKey.join(','),\n\t\t\t\tendpoint,\n\t\t\t\tJSON.stringify(config),\n\t\t\t\tJSON.stringify(options),\n\t\t\t],\n\t\t);\n\n\t\treturn useQuery<ExtractEndpointResponse<Paths, T>, Response>(\n\t\t\tmemoizedOptions,\n\t\t);\n\t}\n\n\tuseMutation<T extends MutationEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\toptions?: Omit<\n\t\t\tUseMutationOptions<\n\t\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\t\tResponse,\n\t\t\t\tFilteredRequestConfig<Paths, T>\n\t\t\t>,\n\t\t\t'mutationFn'\n\t\t>,\n\t) {\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tmutationFn: (config: FilteredRequestConfig<Paths, T>) =>\n\t\t\t\t\tthis.fetcher(endpoint, config),\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: endpoint and options\n\t\t\t// Note: We stringify options to ensure stable reference\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[endpoint, JSON.stringify(options)],\n\t\t);\n\n\t\treturn useMutation<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>(memoizedOptions);\n\t}\n\n\tuseInfiniteQuery<\n\t\tT extends QueryEndpoint<Paths>,\n\t\tTPageData = ExtractEndpointResponse<Paths, T>,\n\t\tTPageParam = unknown,\n\t>(\n\t\tendpoint: T,\n\t\toptions: Omit<\n\t\t\tUseInfiniteQueryOptions<\n\t\t\t\tTPageData,\n\t\t\t\tResponse,\n\t\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\t\tunknown[],\n\t\t\t\tTPageParam\n\t\t\t>,\n\t\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t\t> & {\n\t\t\tgetNextPageParam: (\n\t\t\t\tlastPage: TPageData,\n\t\t\t\tallPages: TPageData[],\n\t\t\t\tlastPageParam: TPageParam,\n\t\t\t\tallPageParams: TPageParam[],\n\t\t\t) => TPageParam | undefined;\n\t\t\tinitialPageParam: TPageParam;\n\t\t},\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t) {\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: ({\n\t\t\t\t\tpageParam,\n\t\t\t\t}: QueryFunctionContext<unknown[], TPageParam>) => {\n\t\t\t\t\tlet mergedConfig = config;\n\t\t\t\t\tif (pageParam !== undefined && config) {\n\t\t\t\t\t\t// If pageParam is an object, spread it into query\n\t\t\t\t\t\tconst pageQuery =\n\t\t\t\t\t\t\ttypeof pageParam === 'object' ? pageParam : { page: pageParam };\n\t\t\t\t\t\tmergedConfig = {\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\tquery: { ...(config as any).query, ...pageQuery },\n\t\t\t\t\t\t} as any;\n\t\t\t\t\t} else if (pageParam !== undefined && !config) {\n\t\t\t\t\t\t// If pageParam is an object, use it directly, otherwise wrap in page property\n\t\t\t\t\t\tconst pageQuery =\n\t\t\t\t\t\t\ttypeof pageParam === 'object' ? pageParam : { page: pageParam };\n\t\t\t\t\t\tmergedConfig = { query: pageQuery } as any;\n\t\t\t\t\t}\n\t\t\t\t\treturn this.fetcher(endpoint, mergedConfig) as Promise<TPageData>;\n\t\t\t\t},\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: queryKey, endpoint, config, and options\n\t\t\t// Note: We stringify config and options to ensure stable references\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[\n\t\t\t\tqueryKey.join(','),\n\t\t\t\tendpoint,\n\t\t\t\tJSON.stringify(config),\n\t\t\t\tJSON.stringify(options),\n\t\t\t],\n\t\t);\n\n\t\treturn useInfiniteQuery<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>(memoizedOptions);\n\t}\n\n\tbuildQueryKey<T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): unknown[] {\n\t\tconst key: unknown[] = [endpoint];\n\n\t\tif (config && 'params' in config && config.params) {\n\t\t\tkey.push({ params: config.params });\n\t\t}\n\n\t\tif (config && 'query' in config && config.query) {\n\t\t\tkey.push({ query: config.query });\n\t\t}\n\n\t\treturn key;\n\t}\n\n\t/**\n\t * Invalidate queries for a specific endpoint with optional config\n\t * @param endpoint - The endpoint to invalidate (e.g., 'GET /users')\n\t * @param config - Optional params/query to match specific queries\n\t * @returns Promise that resolves when invalidation is complete\n\t */\n\tinvalidateQueries<T extends QueryEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): Promise<void> {\n\t\tconst queryClient = this.getQueryClient();\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\treturn queryClient.invalidateQueries({\n\t\t\tqueryKey,\n\t\t\texact: !!config, // Use exact matching if config is provided\n\t\t});\n\t}\n\n\t/**\n\t * Invalidate all queries in the cache\n\t * @returns Promise that resolves when invalidation is complete\n\t */\n\tinvalidateAllQueries(): Promise<void> {\n\t\tconst queryClient = this.getQueryClient();\n\t\treturn queryClient.invalidateQueries();\n\t}\n\n\t/**\n\t * Get the underlying QueryClient instance\n\t * @returns The QueryClient instance\n\t */\n\tgetQueryClient(): QueryClient {\n\t\tif (this.queryClient) {\n\t\t\treturn this.queryClient;\n\t\t}\n\n\t\t// If no query client was provided, try to get it from context\n\t\t// This will throw if used outside of QueryClientProvider\n\t\tthrow new Error(\n\t\t\t'No QueryClient set, please provide a QueryClient via the queryClient option or ensure you are within a QueryClientProvider',\n\t\t);\n\t}\n\n\t/**\n\t * Set the QueryClient instance\n\t * @param queryClient - The QueryClient instance to use\n\t */\n\tsetQueryClient(queryClient: QueryClient): void {\n\t\tthis.queryClient = queryClient;\n\t}\n}\n\nexport function createTypedQueryClient<Paths>(\n\toptions?: TypedQueryClientOptions,\n) {\n\treturn new TypedQueryClient<Paths>(options);\n}\n\n// Hook exports for convenience\nexport function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\tconfig?: FilteredRequestConfig<Paths, T>,\n\toptions?: Omit<\n\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t'queryKey' | 'queryFn'\n\t>,\n) {\n\treturn client.useQuery(endpoint, config, options);\n}\n\nexport function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\toptions?: Omit<\n\t\tUseMutationOptions<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>,\n\t\t'mutationFn'\n\t>,\n) {\n\treturn client.useMutation(endpoint, options);\n}\n\nexport function useTypedInfiniteQuery<\n\tPaths,\n\tT extends QueryEndpoint<Paths>,\n\tTPageData = ExtractEndpointResponse<Paths, T>,\n\tTPageParam = unknown,\n>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\toptions: Omit<\n\t\tUseInfiniteQueryOptions<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>,\n\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t> & {\n\t\tgetNextPageParam: (\n\t\t\tlastPage: TPageData,\n\t\t\tallPages: TPageData[],\n\t\t\tlastPageParam: TPageParam,\n\t\t\tallPageParams: TPageParam[],\n\t\t) => TPageParam | undefined;\n\t\tinitialPageParam: TPageParam;\n\t},\n\tconfig?: FilteredRequestConfig<Paths, T>,\n) {\n\treturn client.useInfiniteQuery(endpoint, options, config);\n}\n\n/**\n * Hook to invalidate queries using the current QueryClient from context\n */\nexport function useTypedInvalidateQueries<Paths>(\n\tclient: TypedQueryClient<Paths>,\n) {\n\tconst queryClient = useQueryClient();\n\n\treturn {\n\t\t/**\n\t\t * Invalidate queries for a specific endpoint\n\t\t */\n\t\tinvalidateQueries: <T extends QueryEndpoint<Paths>>(\n\t\t\tendpoint: T,\n\t\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\t) => {\n\t\t\tconst queryKey = client.buildQueryKey(endpoint, config);\n\t\t\treturn queryClient.invalidateQueries({\n\t\t\t\tqueryKey,\n\t\t\t\texact: !!config,\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * Invalidate all queries\n\t\t */\n\t\tinvalidateAllQueries: () => {\n\t\t\treturn queryClient.invalidateQueries();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;AA4BA,IAAa,mBAAb,MAAqC;CACpC,AAAQ;CACR,AAAQ;CAER,YAAYA,UAAmC,CAAE,GAAE;AAClD,OAAK,UAAU,mBAA0B,QAAQ;AACjD,OAAK,cAAc,QAAQ;CAC3B;CAED,SACCC,UACAC,QACAC,SAIC;EACD,MAAM,WAAW,KAAK,cAAc,UAAU,OAAO;EAGrD,MAAM,kBAAkB,QACvB,OAAO;GACN;GACA,SAAS,MAAM,KAAK,QAAQ,UAAU,OAAO;GAC7C,GAAG;EACH,IAID;GACC,SAAS,KAAK,IAAI;GAClB;GACA,KAAK,UAAU,OAAO;GACtB,KAAK,UAAU,QAAQ;EACvB,EACD;AAED,SAAO,SACN,gB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S;EACT,EAAC;CACF;;;;;CAMD,uBAAsC;EACrC,MAAM,cAAc,KAAK,gBAAgB;AACzC,SAAO,YAAY,mBAAmB;CACtC;;;;;CAMD,iBAA8B;AAC7B,MAAI,KAAK,YACR,QAAO,KAAK;AAKb,QAAM,IAAI,MACT;CAED;;;;;CAMD,eAAeM,aAAgC;AAC9C,OAAK,cAAc;CACnB;AACD;AAED,SAAgB,uBACfC,SACC;AACD,QAAO,IAAI,iBAAwB;AACnC;AAGD,SAAgB,cACfC,QACAT,UACAC,QACAS,SAIC;AACD,QAAO,OAAO,SAAS,UAAU,QAAQ,QAAQ;AACjD;AAED,SAAgB,iBACfD,QACAT,UACAW,SAQC;AACD,QAAO,OAAO,YAAY,UAAU,QAAQ;AAC5C;AAED,SAAgB,sBAMfF,QACAT,UACAY,SAkBAX,QACC;AACD,QAAO,OAAO,iBAAiB,UAAU,SAAS,OAAO;AACzD;;;;AAKD,SAAgB,0BACfQ,QACC;CACD,MAAM,cAAc,gBAAgB;AAEpC,QAAO;EAIN,mBAAmB,CAClBT,UACAC,WACI;GACJ,MAAM,WAAW,OAAO,cAAc,UAAU,OAAO;AACvD,UAAO,YAAY,kBAAkB;IACpC;IACA,SAAS;GACT,EAAC;EACF;EAKD,sBAAsB,MAAM;AAC3B,UAAO,YAAY,mBAAmB;EACtC;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"react-query.mjs","names":[],"sources":["../src/react-query.ts"],"sourcesContent":["import type {\n\tQueryClient,\n\tQueryFunctionContext,\n\tUseInfiniteQueryOptions,\n\tUseMutationOptions,\n\tUseQueryOptions,\n} from '@tanstack/react-query';\nimport {\n\tuseInfiniteQuery,\n\tuseMutation,\n\tuseQuery,\n\tuseQueryClient,\n} from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { createTypedFetcher } from './fetcher';\nimport type {\n\tExtractEndpointResponse,\n\tFetcherOptions,\n\tFilteredRequestConfig,\n\tMutationEndpoint,\n\tQueryEndpoint,\n\tTypedEndpoint,\n} from './types';\n\nexport interface TypedQueryClientOptions extends FetcherOptions {\n\tqueryClient?: QueryClient;\n}\n\nexport class TypedQueryClient<Paths> {\n\tprivate fetcher: ReturnType<typeof createTypedFetcher<Paths>>;\n\tprivate queryClient?: QueryClient;\n\n\tconstructor(options: TypedQueryClientOptions = {}) {\n\t\tthis.fetcher = createTypedFetcher<Paths>(options);\n\t\tthis.queryClient = options.queryClient;\n\t}\n\n\tuseQuery<T extends QueryEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\toptions?: Omit<\n\t\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t\t'queryKey' | 'queryFn'\n\t\t>,\n\t) {\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: () => this.fetcher(endpoint, config),\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: queryKey, endpoint, config, and options\n\t\t\t// Note: We stringify config and options to ensure stable references\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[\n\t\t\t\tqueryKey.join(','),\n\t\t\t\tendpoint,\n\t\t\t\tJSON.stringify(config),\n\t\t\t\tJSON.stringify(options),\n\t\t\t],\n\t\t);\n\n\t\treturn useQuery<ExtractEndpointResponse<Paths, T>, Response>(\n\t\t\tmemoizedOptions,\n\t\t);\n\t}\n\n\tuseMutation<T extends MutationEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\toptions?: Omit<\n\t\t\tUseMutationOptions<\n\t\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\t\tResponse,\n\t\t\t\tFilteredRequestConfig<Paths, T>\n\t\t\t>,\n\t\t\t'mutationFn'\n\t\t>,\n\t) {\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tmutationFn: (config: FilteredRequestConfig<Paths, T>) =>\n\t\t\t\t\tthis.fetcher(endpoint, config),\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: endpoint and options\n\t\t\t// Note: We stringify options to ensure stable reference\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[endpoint, JSON.stringify(options)],\n\t\t);\n\n\t\treturn useMutation<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>(memoizedOptions);\n\t}\n\n\tuseInfiniteQuery<\n\t\tT extends QueryEndpoint<Paths>,\n\t\tTPageData = ExtractEndpointResponse<Paths, T>,\n\t\tTPageParam = unknown,\n\t>(\n\t\tendpoint: T,\n\t\toptions: Omit<\n\t\t\tUseInfiniteQueryOptions<\n\t\t\t\tTPageData,\n\t\t\t\tResponse,\n\t\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\t\tunknown[],\n\t\t\t\tTPageParam\n\t\t\t>,\n\t\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t\t> & {\n\t\t\tgetNextPageParam: (\n\t\t\t\tlastPage: TPageData,\n\t\t\t\tallPages: TPageData[],\n\t\t\t\tlastPageParam: TPageParam,\n\t\t\t\tallPageParams: TPageParam[],\n\t\t\t) => TPageParam | undefined;\n\t\t\tinitialPageParam: TPageParam;\n\t\t},\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t) {\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\t// Memoize the combined options to prevent unnecessary re-renders\n\t\tconst memoizedOptions = useMemo(\n\t\t\t() => ({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: ({\n\t\t\t\t\tpageParam,\n\t\t\t\t}: QueryFunctionContext<unknown[], TPageParam>) => {\n\t\t\t\t\tlet mergedConfig = config;\n\t\t\t\t\tif (pageParam !== undefined && config) {\n\t\t\t\t\t\t// If pageParam is an object, spread it into query\n\t\t\t\t\t\tconst pageQuery =\n\t\t\t\t\t\t\ttypeof pageParam === 'object' ? pageParam : { page: pageParam };\n\t\t\t\t\t\tmergedConfig = {\n\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\tquery: { ...(config as any).query, ...pageQuery },\n\t\t\t\t\t\t} as any;\n\t\t\t\t\t} else if (pageParam !== undefined && !config) {\n\t\t\t\t\t\t// If pageParam is an object, use it directly, otherwise wrap in page property\n\t\t\t\t\t\tconst pageQuery =\n\t\t\t\t\t\t\ttypeof pageParam === 'object' ? pageParam : { page: pageParam };\n\t\t\t\t\t\tmergedConfig = { query: pageQuery } as any;\n\t\t\t\t\t}\n\t\t\t\t\treturn this.fetcher(endpoint, mergedConfig) as Promise<TPageData>;\n\t\t\t\t},\n\t\t\t\t...options,\n\t\t\t}),\n\t\t\t// Dependencies: queryKey, endpoint, config, and options\n\t\t\t// Note: We stringify config and options to ensure stable references\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[\n\t\t\t\tqueryKey.join(','),\n\t\t\t\tendpoint,\n\t\t\t\tJSON.stringify(config),\n\t\t\t\tJSON.stringify(options),\n\t\t\t],\n\t\t);\n\n\t\treturn useInfiniteQuery<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>(memoizedOptions);\n\t}\n\n\tbuildQueryKey<T extends TypedEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): unknown[] {\n\t\tconst key: unknown[] = [endpoint];\n\n\t\tif (config && 'params' in config && config.params) {\n\t\t\tkey.push({ params: config.params });\n\t\t}\n\n\t\tif (config && 'query' in config && config.query) {\n\t\t\tkey.push({ query: config.query });\n\t\t}\n\n\t\treturn key;\n\t}\n\n\t/**\n\t * Invalidate queries for a specific endpoint with optional config\n\t * @param endpoint - The endpoint to invalidate (e.g., 'GET /users')\n\t * @param config - Optional params/query to match specific queries\n\t * @returns Promise that resolves when invalidation is complete\n\t */\n\tinvalidateQueries<T extends QueryEndpoint<Paths>>(\n\t\tendpoint: T,\n\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t): Promise<void> {\n\t\tconst queryClient = this.getQueryClient();\n\t\tconst queryKey = this.buildQueryKey(endpoint, config);\n\n\t\treturn queryClient.invalidateQueries({\n\t\t\tqueryKey,\n\t\t\texact: !!config, // Use exact matching if config is provided\n\t\t});\n\t}\n\n\t/**\n\t * Invalidate all queries in the cache\n\t * @returns Promise that resolves when invalidation is complete\n\t */\n\tinvalidateAllQueries(): Promise<void> {\n\t\tconst queryClient = this.getQueryClient();\n\t\treturn queryClient.invalidateQueries();\n\t}\n\n\t/**\n\t * Get the underlying QueryClient instance\n\t * @returns The QueryClient instance\n\t */\n\tgetQueryClient(): QueryClient {\n\t\tif (this.queryClient) {\n\t\t\treturn this.queryClient;\n\t\t}\n\n\t\t// If no query client was provided, try to get it from context\n\t\t// This will throw if used outside of QueryClientProvider\n\t\tthrow new Error(\n\t\t\t'No QueryClient set, please provide a QueryClient via the queryClient option or ensure you are within a QueryClientProvider',\n\t\t);\n\t}\n\n\t/**\n\t * Set the QueryClient instance\n\t * @param queryClient - The QueryClient instance to use\n\t */\n\tsetQueryClient(queryClient: QueryClient): void {\n\t\tthis.queryClient = queryClient;\n\t}\n}\n\nexport function createTypedQueryClient<Paths>(\n\toptions?: TypedQueryClientOptions,\n) {\n\treturn new TypedQueryClient<Paths>(options);\n}\n\n// Hook exports for convenience\nexport function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\tconfig?: FilteredRequestConfig<Paths, T>,\n\toptions?: Omit<\n\t\tUseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>,\n\t\t'queryKey' | 'queryFn'\n\t>,\n) {\n\treturn client.useQuery(endpoint, config, options);\n}\n\nexport function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\toptions?: Omit<\n\t\tUseMutationOptions<\n\t\t\tExtractEndpointResponse<Paths, T>,\n\t\t\tResponse,\n\t\t\tFilteredRequestConfig<Paths, T>\n\t\t>,\n\t\t'mutationFn'\n\t>,\n) {\n\treturn client.useMutation(endpoint, options);\n}\n\nexport function useTypedInfiniteQuery<\n\tPaths,\n\tT extends QueryEndpoint<Paths>,\n\tTPageData = ExtractEndpointResponse<Paths, T>,\n\tTPageParam = unknown,\n>(\n\tclient: TypedQueryClient<Paths>,\n\tendpoint: T,\n\toptions: Omit<\n\t\tUseInfiniteQueryOptions<\n\t\t\tTPageData,\n\t\t\tResponse,\n\t\t\t{ pages: TPageData[]; pageParams: TPageParam[] },\n\t\t\tunknown[],\n\t\t\tTPageParam\n\t\t>,\n\t\t'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'\n\t> & {\n\t\tgetNextPageParam: (\n\t\t\tlastPage: TPageData,\n\t\t\tallPages: TPageData[],\n\t\t\tlastPageParam: TPageParam,\n\t\t\tallPageParams: TPageParam[],\n\t\t) => TPageParam | undefined;\n\t\tinitialPageParam: TPageParam;\n\t},\n\tconfig?: FilteredRequestConfig<Paths, T>,\n) {\n\treturn client.useInfiniteQuery(endpoint, options, config);\n}\n\n/**\n * Hook to invalidate queries using the current QueryClient from context\n */\nexport function useTypedInvalidateQueries<Paths>(\n\tclient: TypedQueryClient<Paths>,\n) {\n\tconst queryClient = useQueryClient();\n\n\treturn {\n\t\t/**\n\t\t * Invalidate queries for a specific endpoint\n\t\t */\n\t\tinvalidateQueries: <T extends QueryEndpoint<Paths>>(\n\t\t\tendpoint: T,\n\t\t\tconfig?: FilteredRequestConfig<Paths, T>,\n\t\t) => {\n\t\t\tconst queryKey = client.buildQueryKey(endpoint, config);\n\t\t\treturn queryClient.invalidateQueries({\n\t\t\t\tqueryKey,\n\t\t\t\texact: !!config,\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * Invalidate all queries\n\t\t */\n\t\tinvalidateAllQueries: () => {\n\t\t\treturn queryClient.invalidateQueries();\n\t\t},\n\t};\n}\n"],"mappings":";;;;AA4BA,IAAa,mBAAb,MAAqC;CACpC;CACA;CAEA,YAAY,UAAmC,CAAC,GAAG;EAClD,KAAK,UAAU,mBAA0B,OAAO;EAChD,KAAK,cAAc,QAAQ;CAC5B;CAEA,SACC,UACA,QACA,SAIC;EACD,MAAM,WAAW,KAAK,cAAc,UAAU,MAAM;EAGpD,MAAM,kBAAkB,eAChB;GACN;GACA,eAAe,KAAK,QAAQ,UAAU,MAAM;GAC5C,GAAG;EACJ,IAIA;GACC,SAAS,KAAK,GAAG;GACjB;GACA,KAAK,UAAU,MAAM;GACrB,KAAK,UAAU,OAAO;EACvB,CACD;EAEA,OAAO,SACN,eACD;CACD;CAEA,YACC,UACA,SAQC;EAED,MAAM,kBAAkB,eAChB;GACN,aAAa,WACZ,KAAK,QAAQ,UAAU,MAAM;GAC9B,GAAG;EACJ,IAIA,CAAC,UAAU,KAAK,UAAU,OAAO,CAAC,CACnC;EAEA,OAAO,YAIL,eAAe;CAClB;CAEA,iBAKC,UACA,SAkBA,QACC;EACD,MAAM,WAAW,KAAK,cAAc,UAAU,MAAM;EAGpD,MAAM,kBAAkB,eAChB;GACN;GACA,UAAU,EACT,gBACkD;IAClD,IAAI,eAAe;IACnB,IAAI,cAAc,KAAA,KAAa,QAAQ;KAEtC,MAAM,YACL,OAAO,cAAc,WAAW,YAAY,EAAE,MAAM,UAAU;KAC/D,eAAe;MACd,GAAG;MACH,OAAO;OAAE,GAAI,OAAe;OAAO,GAAG;MAAU;KACjD;IACD,OAAO,IAAI,cAAc,KAAA,KAAa,CAAC,QAItC,eAAe,EAAE,OADhB,OAAO,cAAc,WAAW,YAAY,EAAE,MAAM,UAAU,EAC7B;IAEnC,OAAO,KAAK,QAAQ,UAAU,YAA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D,OAAO,YAAY,kBAAkB;IACpC;IACA,OAAO,CAAC,CAAC;GACV,CAAC;EACF;;;;EAKA,4BAA4B;GAC3B,OAAO,YAAY,kBAAkB;EACtC;CACD;AACD"}
|
package/dist/types.cjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('./types-a8gm_IaQ.cjs');
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
export type OpenAPIRoutes<Paths> = keyof Paths;
|
|
3
|
+
type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options';
|
|
4
|
+
export type ExtractMethod<Paths, Route extends OpenAPIRoutes<Paths>> = Extract<keyof Paths[Route], HttpMethod>;
|
|
5
|
+
export type ExtractPathParams<Paths, Route extends OpenAPIRoutes<Paths>> = Paths[Route] extends {
|
|
6
|
+
parameters?: {
|
|
7
|
+
path?: infer P;
|
|
8
|
+
};
|
|
9
|
+
} ? P : never;
|
|
10
|
+
export type ExtractQueryParams<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
|
|
11
|
+
parameters?: {
|
|
12
|
+
query?: infer Q;
|
|
13
|
+
};
|
|
14
|
+
} ? Q : never;
|
|
15
|
+
export type ExtractRequestBody<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
|
|
16
|
+
requestBody?: infer RB;
|
|
17
|
+
} ? [NonNullable<RB>] extends [never] ? never : NonNullable<RB> extends {
|
|
18
|
+
content?: {
|
|
19
|
+
'application/json'?: infer B;
|
|
20
|
+
};
|
|
21
|
+
} ? B : never : never;
|
|
22
|
+
export type ExtractResponse<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
|
|
23
|
+
responses?: {
|
|
24
|
+
200?: {
|
|
25
|
+
content?: {
|
|
26
|
+
'application/json'?: infer R;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
} ? R : Paths[Route][Method] extends {
|
|
31
|
+
responses?: {
|
|
32
|
+
201?: {
|
|
33
|
+
content?: {
|
|
34
|
+
'application/json'?: infer R;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
} ? R : never;
|
|
39
|
+
export type RequestConfig<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = {
|
|
40
|
+
params?: ExtractPathParams<Paths, Route>;
|
|
41
|
+
query?: ExtractQueryParams<Paths, Route, Method>;
|
|
42
|
+
body?: ExtractRequestBody<Paths, Route, Method>;
|
|
43
|
+
headers?: Record<string, string>;
|
|
44
|
+
};
|
|
45
|
+
export type EndpointString = `${Uppercase<string>} ${string}`;
|
|
46
|
+
export type ValidEndpoint<Paths> = { [Route in keyof Paths]: { [Method in Extract<keyof Paths[Route], HttpMethod>]: `${Uppercase<string & Method>} ${string & Route}`; }[Extract<keyof Paths[Route], HttpMethod>]; }[keyof Paths];
|
|
47
|
+
export type TypedEndpoint<Paths> = ValidEndpoint<Paths> extends (infer E) ? (E extends string ? E : never) : never;
|
|
48
|
+
export type FilterEndpointByMethod<Paths, Method extends string> = ValidEndpoint<Paths> extends (infer E) ? E extends `${Method} ${string}` ? E : never : never;
|
|
49
|
+
export type QueryEndpoint<Paths> = FilterEndpointByMethod<Paths, 'GET'>;
|
|
50
|
+
export type MutationEndpoint<Paths> = FilterEndpointByMethod<Paths, 'POST'> | FilterEndpointByMethod<Paths, 'PATCH'> | FilterEndpointByMethod<Paths, 'PUT'> | FilterEndpointByMethod<Paths, 'DELETE'>;
|
|
51
|
+
export type ParseEndpoint<T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? {
|
|
52
|
+
method: Lowercase<Method>;
|
|
53
|
+
route: Route;
|
|
54
|
+
} : never;
|
|
55
|
+
export type ExtractEndpointResponse<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? ExtractResponse<Paths, Route, Lowercase<Method>> : never : never : never;
|
|
56
|
+
export type ExtractEndpointConfig<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? RequestConfig<Paths, Route, Lowercase<Method>> : never : never : never;
|
|
57
|
+
/**
|
|
58
|
+
* Build a request config type where:
|
|
59
|
+
* - `params` is required if the endpoint has path parameters
|
|
60
|
+
* - `body` is required if the endpoint has a request body
|
|
61
|
+
* - `query` is required if it has a required key, optional otherwise
|
|
62
|
+
* - `headers` is always optional
|
|
63
|
+
*/
|
|
64
|
+
export type FilteredRequestConfig<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? BuildRequestConfig<ExtractPathParams<Paths, Route>, ExtractQueryParams<Paths, Route, Lowercase<Method>>, ExtractRequestBody<Paths, Route, Lowercase<Method>>> : never : never : never;
|
|
65
|
+
/**
|
|
66
|
+
* Helper to build request config with correct required/optional fields.
|
|
67
|
+
* Uses [T] extends [never] pattern to prevent distribution over union types,
|
|
68
|
+
* which would cause the entire type to become `never`.
|
|
69
|
+
*/
|
|
70
|
+
type BuildRequestConfig<TParams, TQuery, TBody> = SimplifyIntersection<([TParams] extends [never] ? {} : {
|
|
71
|
+
params: TParams;
|
|
72
|
+
}) & ([TBody] extends [never] ? {} : {
|
|
73
|
+
body: TBody;
|
|
74
|
+
}) & ([TQuery] extends [never] ? {} : {} extends TQuery ? {
|
|
75
|
+
query?: TQuery;
|
|
76
|
+
} : {
|
|
77
|
+
query: TQuery;
|
|
78
|
+
}) & {
|
|
79
|
+
headers?: Record<string, string>;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Simplify intersection types for better IDE display
|
|
83
|
+
*/
|
|
84
|
+
type SimplifyIntersection<T> = { [K in keyof T]: T[K]; };
|
|
85
|
+
/** Whether a query has a key the caller must supply. */
|
|
86
|
+
type HasRequiredQuery<TQuery> = [TQuery] extends [never] ? false : {} extends TQuery ? false : true;
|
|
87
|
+
/**
|
|
88
|
+
* Check if the config object is required (has any required fields)
|
|
89
|
+
*/
|
|
90
|
+
export type IsConfigRequired<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? ExtractPathParams<Paths, Route> extends never ? ExtractRequestBody<Paths, Route, Lowercase<Method>> extends never ? HasRequiredQuery<ExtractQueryParams<Paths, Route, Lowercase<Method>>> : true : true : false : false : false;
|
|
91
|
+
/**
|
|
92
|
+
* Typed function signature for the API client.
|
|
93
|
+
* Config is required when endpoint has path params or body.
|
|
94
|
+
*/
|
|
95
|
+
export type TypedApiFunction<Paths> = <T extends TypedEndpoint<Paths>>(endpoint: T, ...args: IsConfigRequired<Paths, T> extends true ? [config: FilteredRequestConfig<Paths, T>] : [config?: FilteredRequestConfig<Paths, T>]) => Promise<ExtractEndpointResponse<Paths, T>>;
|
|
96
|
+
export interface FetcherOptions {
|
|
97
|
+
baseURL?: string;
|
|
98
|
+
headers?: Record<string, string>;
|
|
99
|
+
onRequest?: (config: RequestInit) => RequestInit | Promise<RequestInit>;
|
|
100
|
+
onResponse?: (response: Response) => Response | Promise<Response>;
|
|
101
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
102
|
+
fetch?: typeof fetch;
|
|
103
|
+
}
|
|
104
|
+
export type WrappedResult<T, E = unknown> = {
|
|
105
|
+
ok: true;
|
|
106
|
+
data: T;
|
|
107
|
+
} | {
|
|
108
|
+
ok: false;
|
|
109
|
+
error: E;
|
|
110
|
+
};
|
|
111
|
+
export type ErrorTransformer<E> = (error: unknown) => E | Promise<E>;
|
|
112
|
+
export type WrappedApiFunction<Paths, E = unknown> = <T extends TypedEndpoint<Paths>>(endpoint: T, ...args: IsConfigRequired<Paths, T> extends true ? [config: FilteredRequestConfig<Paths, T>] : [config?: FilteredRequestConfig<Paths, T>]) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>;
|
|
113
|
+
//#endregion
|
|
114
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";YAAY,cAAc,eAAe;KAEpC;YASO,cAAc,OAAO,cAAc,cAAc,UAAU,cAChE,MAAM,QACZ;YAGW,kBACX,OACA,cAAc,cAAc,UACzB,MAAM;EACT;IAAe,aAAa;;IAE1B;YAGS,mBACX,OACA,cAAc,cAAc,QAC5B,eAAe,cAAc,OAAO,UACjC,MAAM,OAAO;EAAkB;IAAe,cAAc;;IAC7D;YAGS,mBACX,OACA,cAAc,cAAc,QAC5B,eAAe,cAAc,OAAO,UACjC,MAAM,OAAO;EAAkB,oBAAoB;KAIpD,YAAY,+BAEX,YAAY;EAAc;IAAY,2BAA2B;;IAChE;YAIO,gBACX,OACA,cAAc,cAAc,QAC5B,eAAe,cAAc,OAAO,UACjC,MAAM,OAAO;EAChB;IAAc;MAAQ;QAAY,2BAA2B;;;;IAE3D,IACA,MAAM,OAAO;EACZ;IAAc;MAAQ;QAAY,2BAA2B;;;;IAE7D;YAGQ,cACX,OACA,cAAc,cAAc,QAC5B,eAAe,cAAc,OAAO;EAEpC,SAAS,kBAAkB,OAAO;EAClC,QAAQ,mBAAmB,OAAO,OAAO;EACzC,OAAO,mBAAmB,OAAO,OAAO;EACxC,UAAU;;YAGC,oBAAoB;YAIpB,cAAc,YACxB,eAAe,WACd,UAAU,cAAc,MAAM,QAAQ,iBAAiB,mBAC9C,oBACI,WACb,cAAc,MAAM,QAAQ,sBACvB;YAGI,cAAc,SACzB,cAAc,sBAAqB,MAAK,mBAAmB;YAGhD,uBACX,OACA,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