react-query-kit 3.2.1 → 3.3.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 (67) hide show
  1. package/README.md +20 -2
  2. package/build/lib/createBaseQuery.d.ts +1 -1
  3. package/build/lib/createBaseQuery.esm.js +2 -2
  4. package/build/lib/createBaseQuery.esm.js.map +1 -1
  5. package/build/lib/createBaseQuery.js +1 -1
  6. package/build/lib/createBaseQuery.js.map +1 -1
  7. package/build/lib/createBaseQuery.mjs +2 -2
  8. package/build/lib/createBaseQuery.mjs.map +1 -1
  9. package/build/lib/createInfiniteQuery.d.ts +2 -2
  10. package/build/lib/createInfiniteQuery.esm.js +2 -2
  11. package/build/lib/createInfiniteQuery.esm.js.map +1 -1
  12. package/build/lib/createInfiniteQuery.js +2 -2
  13. package/build/lib/createInfiniteQuery.js.map +1 -1
  14. package/build/lib/createInfiniteQuery.mjs +2 -2
  15. package/build/lib/createInfiniteQuery.mjs.map +1 -1
  16. package/build/lib/createMutation.d.ts +2 -2
  17. package/build/lib/createMutation.esm.js +2 -2
  18. package/build/lib/createMutation.esm.js.map +1 -1
  19. package/build/lib/createMutation.js +2 -2
  20. package/build/lib/createMutation.js.map +1 -1
  21. package/build/lib/createMutation.mjs +2 -2
  22. package/build/lib/createMutation.mjs.map +1 -1
  23. package/build/lib/createQuery.d.ts +2 -2
  24. package/build/lib/createQuery.esm.js +2 -2
  25. package/build/lib/createQuery.esm.js.map +1 -1
  26. package/build/lib/createQuery.js +2 -2
  27. package/build/lib/createQuery.js.map +1 -1
  28. package/build/lib/createQuery.mjs +2 -2
  29. package/build/lib/createQuery.mjs.map +1 -1
  30. package/build/lib/createSuspenseInfiniteQuery.d.ts +2 -2
  31. package/build/lib/createSuspenseInfiniteQuery.esm.js +2 -2
  32. package/build/lib/createSuspenseInfiniteQuery.esm.js.map +1 -1
  33. package/build/lib/createSuspenseInfiniteQuery.js +2 -2
  34. package/build/lib/createSuspenseInfiniteQuery.js.map +1 -1
  35. package/build/lib/createSuspenseInfiniteQuery.mjs +2 -2
  36. package/build/lib/createSuspenseInfiniteQuery.mjs.map +1 -1
  37. package/build/lib/createSuspenseQuery.d.ts +2 -2
  38. package/build/lib/createSuspenseQuery.esm.js +2 -2
  39. package/build/lib/createSuspenseQuery.esm.js.map +1 -1
  40. package/build/lib/createSuspenseQuery.js +2 -2
  41. package/build/lib/createSuspenseQuery.js.map +1 -1
  42. package/build/lib/createSuspenseQuery.mjs +2 -2
  43. package/build/lib/createSuspenseQuery.mjs.map +1 -1
  44. package/build/lib/router.d.ts +8 -4
  45. package/build/lib/router.esm.js +10 -6
  46. package/build/lib/router.esm.js.map +1 -1
  47. package/build/lib/router.js +10 -6
  48. package/build/lib/router.js.map +1 -1
  49. package/build/lib/router.mjs +10 -6
  50. package/build/lib/router.mjs.map +1 -1
  51. package/build/lib/types.d.ts +7 -7
  52. package/build/stats-html.html +1 -1
  53. package/build/stats.json +112 -112
  54. package/build/umd/index.development.js +21 -17
  55. package/build/umd/index.development.js.map +1 -1
  56. package/build/umd/index.production.js +1 -1
  57. package/build/umd/index.production.js.map +1 -1
  58. package/package.json +2 -2
  59. package/src/createBaseQuery.ts +10 -7
  60. package/src/createInfiniteQuery.ts +2 -2
  61. package/src/createMutation.ts +2 -2
  62. package/src/createQuery.ts +2 -2
  63. package/src/createSuspenseInfiniteQuery.ts +2 -2
  64. package/src/createSuspenseQuery.ts +2 -2
  65. package/src/router.ts +10 -8
  66. package/src/types.ts +11 -6
  67. package/build/zip/zip.esm.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.production.js","sources":["../../src/utils.ts","../../src/createBaseQuery.ts","../../src/createQuery.ts","../../src/createSuspenseQuery.ts","../../src/createInfiniteQuery.ts","../../src/createSuspenseInfiniteQuery.ts","../../src/createMutation.ts","../../src/router.ts"],"sourcesContent":["import * as TanstackReactQuery from '@tanstack/react-query'\nimport type { Query, QueryClient, QueryKey } from '@tanstack/react-query'\n\nimport type { Middleware } from './types'\n\nexport const ReactQuery = TanstackReactQuery\n\nexport const isV5 = !!ReactQuery.useSuspenseQuery\n\nexport const suspenseOptions = {\n enabled: true,\n suspense: true,\n keepPreviousData: undefined,\n useErrorBoundary: (_error: unknown, query: Query) =>\n query.state.data === undefined,\n}\n\nexport const withMiddleware = (\n hook: any,\n defaultOptions: any,\n type: 'queries' | 'mutations'\n) => {\n return function useMiddleware(\n options?: { client?: QueryClient; use?: Middleware[] },\n queryClient?: QueryClient\n ) {\n const [uses, opts]: [Middleware[], any] = [\n ReactQuery.useQueryClient(\n // @ts-ignore Compatible with ReactQuery v4\n isV5 ? queryClient : options\n ).getDefaultOptions()[type],\n defaultOptions,\n options,\n ].reduce(\n ([u1, o1], { use: u2 = [], ...o2 } = {}) => [\n [...u1, ...u2],\n { ...o1, ...o2 },\n ],\n [[]]\n )\n\n return uses.reduceRight((next, use) => use(next), hook)(opts, queryClient)\n }\n}\n\nexport const getKey = (queryKey: QueryKey, variables?: any): QueryKey => {\n return variables === undefined ? queryKey : [...queryKey, variables]\n}\n","import type {\n QueryClient,\n QueryFunctionContext,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport { getKey as getFullKey, withMiddleware } from './utils'\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n fetcher?: any\n variables?: any\n}\n\nexport const createBaseQuery = (\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: Partial<UseInfiniteQueryOptions>\n): any => {\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n console.error(\n '[Bug] useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n\n // @ts-ignore\n if (defaultOptions.queryFn) {\n console.error(\n '[Bug] queryFn is not supported, please use fetcher instead.'\n )\n }\n }\n\n const getQueryOptions = (fetcherFn: any, variables: any) => {\n return {\n queryFn: (context: QueryFunctionContext) => fetcherFn(variables, context),\n queryKey: getFullKey(defaultOptions.queryKey, variables),\n }\n }\n\n const getKey = (variables?: any) =>\n getFullKey(defaultOptions.queryKey, variables)\n\n const getOptions = (variables: any) => {\n return {\n ...defaultOptions,\n ...getQueryOptions(defaultOptions.fetcher, variables),\n }\n }\n\n const getFetchOptions = (variables: any) => {\n return {\n ...getQueryOptions(defaultOptions.fetcher, variables),\n queryKeyHashFn: defaultOptions.queryKeyHashFn,\n getPreviousPageParam: defaultOptions.getPreviousPageParam,\n getNextPageParam: defaultOptions.getNextPageParam,\n initialPageParam: defaultOptions.initialPageParam,\n }\n }\n\n const useBaseHook = (\n options: QueryBaseHookOptions,\n queryClient?: QueryClient\n ) => {\n return useRQHook(\n {\n ...options,\n ...getQueryOptions(options.fetcher, options.variables),\n ...overrideOptions,\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n fetcher: defaultOptions.fetcher,\n getKey,\n getOptions,\n getFetchOptions,\n })\n}\n","import { createBaseQuery } from './createBaseQuery'\nimport type { CompatibleError, CreateQueryOptions, QueryHook } from './types'\nimport { ReactQuery } from './utils'\n\nexport const createQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError\n>(\n options: CreateQueryOptions<TFnData, TVariables, TError>\n): QueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, ReactQuery.useQuery)\n}\n","import { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateSuspenseQueryOptions,\n SuspenseQueryHook,\n} from './types'\nimport { ReactQuery, isV5, suspenseOptions } from './utils'\n\nexport const createSuspenseQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError\n>(\n options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>\n): SuspenseQueryHook<TFnData, TVariables, TError> => {\n return isV5\n ? createBaseQuery(options, ReactQuery.useSuspenseQuery)\n : createBaseQuery(options, ReactQuery.useQuery, suspenseOptions)\n}\n","import { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateInfiniteQueryOptions,\n InfiniteQueryHook,\n} from './types'\nimport { ReactQuery } from './utils'\n\nexport const createInfiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, ReactQuery.useInfiniteQuery)\n}\n","import { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateSuspenseInfiniteQueryOptions,\n SuspenseInfiniteQueryHook,\n} from './types'\nimport { ReactQuery, isV5, suspenseOptions } from './utils'\n\nexport const createSuspenseInfiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: CreateSuspenseInfiniteQueryOptions<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return isV5\n ? createBaseQuery(options, ReactQuery.useSuspenseInfiniteQuery)\n : createBaseQuery(options, ReactQuery.useInfiniteQuery, suspenseOptions)\n}\n","import type {\n CompatibleError,\n CreateMutationOptions,\n MutationHook,\n} from './types'\nimport { ReactQuery, withMiddleware } from './utils'\n\nexport const createMutation = <\n TData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(\n defaultOptions: CreateMutationOptions<TData, TVariables, TError, TContext>\n): MutationHook<TData, TVariables, TError, TContext> => {\n return Object.assign(\n withMiddleware(ReactQuery.useMutation, defaultOptions, 'mutations'),\n {\n getKey: () => defaultOptions.mutationKey,\n getOptions: () => defaultOptions,\n mutationFn: defaultOptions.mutationFn,\n }\n ) as MutationHook<TData, TVariables, TError, TContext>\n}\n","import { QueryKey } from '@tanstack/react-query'\n\nimport { createInfiniteQuery } from './createInfiniteQuery'\nimport { createMutation } from './createMutation'\nimport { createQuery } from './createQuery'\nimport { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery'\nimport { createSuspenseQuery } from './createSuspenseQuery'\nimport type {\n CompatibleError,\n CreateRouter,\n RouterConfig,\n RouterInfiniteQuery,\n RouterInfiniteQueryOptions,\n RouterMutation,\n RouterMutationOptions,\n RouterQuery,\n RouterQueryOptions,\n} from './types'\n\nconst buildRouter = (keys: QueryKey, config: RouterConfig) => {\n return Object.entries(config).reduce(\n (acc, [key, opts]) => {\n if (!opts._type) {\n acc[key] = buildRouter([...keys, key], opts)\n } else {\n const options: any = {\n ...opts,\n [opts._type === `m` ? `mutationKey` : `queryKey`]: [...keys, key],\n }\n\n acc[key] =\n opts._type === `m`\n ? {\n useMutation: createMutation(options),\n ...createMutation(options),\n }\n : opts._type === `q`\n ? {\n useQuery: createQuery(options),\n useSuspenseQuery: createSuspenseQuery(options),\n ...createQuery(options),\n }\n : {\n useInfiniteQuery: createInfiniteQuery(options),\n useSuspenseInfiniteQuery: createSuspenseInfiniteQuery(options),\n ...createInfiniteQuery(options),\n }\n }\n\n return acc\n },\n {\n getKey: () => keys,\n } as any\n )\n}\n\nexport const router = <TConfig extends RouterConfig>(\n key: string | QueryKey,\n config: TConfig\n): CreateRouter<TConfig> => {\n return buildRouter(Array.isArray(key) ? key : [key], config)\n}\n\nrouter.query = <TFnData, TVariables = void, TError = CompatibleError>(\n options: RouterQueryOptions<TFnData, TVariables, TError>\n) => {\n return {\n ...options,\n _type: 'q',\n } as RouterQuery<TFnData, TVariables, TError>\n}\n\nrouter.infiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: RouterInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n) => {\n return { ...options, _type: 'inf' } as RouterInfiniteQuery<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n}\n\nrouter.mutation = <\n TFnData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(\n options: RouterMutationOptions<TFnData, TVariables, TError, TContext>\n) => {\n return { ...options, _type: 'm' } as RouterMutation<\n TFnData,\n TVariables,\n TError,\n TContext\n >\n}\n"],"names":["ReactQuery","isV5","useSuspenseQuery","suspenseOptions","enabled","suspense","keepPreviousData","undefined","useErrorBoundary","_error","query","state","data","withMiddleware","hook","defaultOptions","type","options","queryClient","uses","opts","useQueryClient","getDefaultOptions","reduce","u1","o1","use","u2","o2","reduceRight","next","getKey","queryKey","variables","createBaseQuery","useRQHook","overrideOptions","getQueryOptions","fetcherFn","queryFn","context","getFullKey","Object","assign","fetcher","getOptions","getFetchOptions","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","createQuery","useQuery","createSuspenseQuery","createInfiniteQuery","useInfiniteQuery","createSuspenseInfiniteQuery","useSuspenseInfiniteQuery","createMutation","useMutation","mutationKey","mutationFn","buildRouter","keys","config","entries","acc","key","_type","router","Array","isArray","infiniteQuery","mutation"],"mappings":"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"}
1
+ {"version":3,"file":"index.production.js","sources":["../../src/utils.ts","../../src/createBaseQuery.ts","../../src/createQuery.ts","../../src/createSuspenseQuery.ts","../../src/createInfiniteQuery.ts","../../src/createSuspenseInfiniteQuery.ts","../../src/createMutation.ts","../../src/router.ts"],"sourcesContent":["import * as TanstackReactQuery from '@tanstack/react-query'\nimport type { Query, QueryClient, QueryKey } from '@tanstack/react-query'\n\nimport type { Middleware } from './types'\n\nexport const ReactQuery = TanstackReactQuery\n\nexport const isV5 = !!ReactQuery.useSuspenseQuery\n\nexport const suspenseOptions = {\n enabled: true,\n suspense: true,\n keepPreviousData: undefined,\n useErrorBoundary: (_error: unknown, query: Query) =>\n query.state.data === undefined,\n}\n\nexport const withMiddleware = (\n hook: any,\n defaultOptions: any,\n type: 'queries' | 'mutations'\n) => {\n return function useMiddleware(\n options?: { client?: QueryClient; use?: Middleware[] },\n queryClient?: QueryClient\n ) {\n const [uses, opts]: [Middleware[], any] = [\n ReactQuery.useQueryClient(\n // @ts-ignore Compatible with ReactQuery v4\n isV5 ? queryClient : options\n ).getDefaultOptions()[type],\n defaultOptions,\n options,\n ].reduce(\n ([u1, o1], { use: u2 = [], ...o2 } = {}) => [\n [...u1, ...u2],\n { ...o1, ...o2 },\n ],\n [[]]\n )\n\n return uses.reduceRight((next, use) => use(next), hook)(opts, queryClient)\n }\n}\n\nexport const getKey = (queryKey: QueryKey, variables?: any): QueryKey => {\n return variables === undefined ? queryKey : [...queryKey, variables]\n}\n","import {\n type QueryClient,\n type QueryFunctionContext,\n type UseBaseQueryOptions,\n type UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport { ReactQuery, getKey as getFullKey, withMiddleware } from './utils'\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n fetcher?: any\n variables?: any\n}\n\nexport const createBaseQuery = (\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: Partial<UseInfiniteQueryOptions>\n): any => {\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n console.error(\n '[Bug] useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n\n // @ts-ignore\n if (defaultOptions.queryFn) {\n console.error(\n '[Bug] queryFn is not supported, please use fetcher instead.'\n )\n }\n }\n\n const getQueryOptions = (fetcherFn: any, variables: any) => {\n return {\n queryFn:\n variables && variables === ReactQuery.skipToken\n ? ReactQuery.skipToken\n : (context: QueryFunctionContext) => fetcherFn(variables, context),\n queryKey: getFullKey(defaultOptions.queryKey, variables),\n }\n }\n\n const getKey = (variables?: any) =>\n getFullKey(defaultOptions.queryKey, variables)\n\n const getOptions = (variables: any) => {\n return {\n ...defaultOptions,\n ...getQueryOptions(defaultOptions.fetcher, variables),\n }\n }\n\n const getFetchOptions = (variables: any) => {\n return {\n ...getQueryOptions(defaultOptions.fetcher, variables),\n queryKeyHashFn: defaultOptions.queryKeyHashFn,\n getPreviousPageParam: defaultOptions.getPreviousPageParam,\n getNextPageParam: defaultOptions.getNextPageParam,\n initialPageParam: defaultOptions.initialPageParam,\n }\n }\n\n const useBaseHook = (\n options: QueryBaseHookOptions,\n queryClient?: QueryClient\n ) => {\n return useRQHook(\n {\n ...options,\n ...getQueryOptions(options.fetcher, options.variables),\n ...overrideOptions,\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n fetcher: defaultOptions.fetcher,\n getKey,\n getOptions,\n getFetchOptions,\n })\n}\n","import { createBaseQuery } from './createBaseQuery'\nimport type { CompatibleError, CreateQueryOptions, QueryHook } from './types'\nimport { ReactQuery } from './utils'\n\nexport function createQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError\n>(\n options: CreateQueryOptions<TFnData, TVariables, TError>\n): QueryHook<TFnData, TVariables, TError> {\n return createBaseQuery(options, ReactQuery.useQuery)\n}\n","import { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateSuspenseQueryOptions,\n SuspenseQueryHook,\n} from './types'\nimport { ReactQuery, isV5, suspenseOptions } from './utils'\n\nexport function createSuspenseQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError\n>(\n options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>\n): SuspenseQueryHook<TFnData, TVariables, TError> {\n return isV5\n ? createBaseQuery(options, ReactQuery.useSuspenseQuery)\n : createBaseQuery(options, ReactQuery.useQuery, suspenseOptions)\n}\n","import { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateInfiniteQueryOptions,\n InfiniteQueryHook,\n} from './types'\nimport { ReactQuery } from './utils'\n\nexport function createInfiniteQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> {\n return createBaseQuery(options, ReactQuery.useInfiniteQuery)\n}\n","import { createBaseQuery } from './createBaseQuery'\nimport type {\n CompatibleError,\n CreateSuspenseInfiniteQueryOptions,\n SuspenseInfiniteQueryHook,\n} from './types'\nimport { ReactQuery, isV5, suspenseOptions } from './utils'\n\nexport function createSuspenseInfiniteQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: CreateSuspenseInfiniteQueryOptions<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> {\n return isV5\n ? createBaseQuery(options, ReactQuery.useSuspenseInfiniteQuery)\n : createBaseQuery(options, ReactQuery.useInfiniteQuery, suspenseOptions)\n}\n","import type {\n CompatibleError,\n CreateMutationOptions,\n MutationHook,\n} from './types'\nimport { ReactQuery, withMiddleware } from './utils'\n\nexport function createMutation<\n TData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(\n defaultOptions: CreateMutationOptions<TData, TVariables, TError, TContext>\n): MutationHook<TData, TVariables, TError, TContext> {\n return Object.assign(\n withMiddleware(ReactQuery.useMutation, defaultOptions, 'mutations'),\n {\n getKey: () => defaultOptions.mutationKey,\n getOptions: () => defaultOptions,\n mutationFn: defaultOptions.mutationFn,\n }\n ) as MutationHook<TData, TVariables, TError, TContext>\n}\n","import { QueryKey } from '@tanstack/react-query'\n\nimport { createInfiniteQuery } from './createInfiniteQuery'\nimport { createMutation } from './createMutation'\nimport { createQuery } from './createQuery'\nimport { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery'\nimport { createSuspenseQuery } from './createSuspenseQuery'\nimport type {\n CompatibleError,\n CreateRouter,\n RouterConfig,\n RouterInfiniteQuery,\n RouterInfiniteQueryOptions,\n RouterMutation,\n RouterMutationOptions,\n RouterQuery,\n RouterQueryOptions,\n} from './types'\n\nconst buildRouter = (keys: QueryKey, config: RouterConfig) => {\n return Object.entries(config).reduce(\n (acc, [key, opts]) => {\n if (!opts._type) {\n acc[key] = buildRouter([...keys, key], opts)\n } else {\n const options: any = {\n ...opts,\n [opts._type === `m` ? `mutationKey` : `queryKey`]: [...keys, key],\n }\n\n acc[key] =\n opts._type === `m`\n ? {\n useMutation: createMutation(options),\n ...createMutation(options),\n }\n : opts._type === `q`\n ? {\n useQuery: createQuery(options),\n useSuspenseQuery: createSuspenseQuery(options),\n ...createQuery(options),\n }\n : {\n useInfiniteQuery: createInfiniteQuery(options),\n useSuspenseInfiniteQuery: createSuspenseInfiniteQuery(options),\n ...createInfiniteQuery(options),\n }\n }\n\n return acc\n },\n {\n getKey: () => keys,\n } as any\n )\n}\n\nexport const router = <TConfig extends RouterConfig>(\n key: string | QueryKey,\n config: TConfig\n): CreateRouter<TConfig> => {\n return buildRouter(Array.isArray(key) ? key : [key], config)\n}\n\nfunction query<TFnData, TVariables = void, TError = CompatibleError>(\n options: RouterQueryOptions<TFnData, TVariables, TError>\n) {\n return {\n ...options,\n _type: 'q',\n } as RouterQuery<TFnData, TVariables, TError>\n}\n\nfunction infiniteQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: RouterInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n) {\n return { ...options, _type: 'inf' } as RouterInfiniteQuery<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n}\n\nfunction mutation<\n TFnData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(options: RouterMutationOptions<TFnData, TVariables, TError, TContext>) {\n return { ...options, _type: 'm' } as RouterMutation<\n TFnData,\n TVariables,\n TError,\n TContext\n >\n}\n\nrouter.query = query\nrouter.infiniteQuery = infiniteQuery\nrouter.mutation = mutation\n"],"names":["ReactQuery","isV5","useSuspenseQuery","suspenseOptions","enabled","suspense","keepPreviousData","undefined","useErrorBoundary","_error","query","state","data","withMiddleware","hook","defaultOptions","type","options","queryClient","uses","opts","useQueryClient","getDefaultOptions","reduce","u1","o1","use","u2","o2","reduceRight","next","getKey","queryKey","variables","createBaseQuery","useRQHook","overrideOptions","getQueryOptions","fetcherFn","queryFn","skipToken","context","getFullKey","Object","assign","fetcher","getOptions","getFetchOptions","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","createQuery","useQuery","createSuspenseQuery","createInfiniteQuery","useInfiniteQuery","createSuspenseInfiniteQuery","useSuspenseInfiniteQuery","createMutation","useMutation","mutationKey","mutationFn","buildRouter","keys","config","entries","acc","key","_type","router","Array","isArray","infiniteQuery","mutation"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-kit",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "🕊️ A toolkit for ReactQuery that make ReactQuery hooks more reusable and typesafe",
5
5
  "author": "liaoliao666",
6
6
  "repository": "liaoliao666/react-query-kit",
@@ -27,7 +27,7 @@
27
27
  "@rollup/plugin-commonjs": "^22.0.2",
28
28
  "@rollup/plugin-node-resolve": "^13.2.1",
29
29
  "@rollup/plugin-replace": "^4.0.0",
30
- "@tanstack/react-query": "^5.28.6",
30
+ "@tanstack/react-query": "^5.35.1",
31
31
  "@testing-library/jest-dom": "^5.16.5",
32
32
  "@testing-library/react": "^14.0.0",
33
33
  "@trivago/prettier-plugin-sort-imports": "^4.2.0",
@@ -1,11 +1,11 @@
1
- import type {
2
- QueryClient,
3
- QueryFunctionContext,
4
- UseBaseQueryOptions,
5
- UseInfiniteQueryOptions,
1
+ import {
2
+ type QueryClient,
3
+ type QueryFunctionContext,
4
+ type UseBaseQueryOptions,
5
+ type UseInfiniteQueryOptions,
6
6
  } from '@tanstack/react-query'
7
7
 
8
- import { getKey as getFullKey, withMiddleware } from './utils'
8
+ import { ReactQuery, getKey as getFullKey, withMiddleware } from './utils'
9
9
 
10
10
  type QueryBaseHookOptions = Omit<
11
11
  UseBaseQueryOptions,
@@ -38,7 +38,10 @@ export const createBaseQuery = (
38
38
 
39
39
  const getQueryOptions = (fetcherFn: any, variables: any) => {
40
40
  return {
41
- queryFn: (context: QueryFunctionContext) => fetcherFn(variables, context),
41
+ queryFn:
42
+ variables && variables === ReactQuery.skipToken
43
+ ? ReactQuery.skipToken
44
+ : (context: QueryFunctionContext) => fetcherFn(variables, context),
42
45
  queryKey: getFullKey(defaultOptions.queryKey, variables),
43
46
  }
44
47
  }
@@ -6,13 +6,13 @@ import type {
6
6
  } from './types'
7
7
  import { ReactQuery } from './utils'
8
8
 
9
- export const createInfiniteQuery = <
9
+ export function createInfiniteQuery<
10
10
  TFnData,
11
11
  TVariables = void,
12
12
  TError = CompatibleError,
13
13
  TPageParam = number
14
14
  >(
15
15
  options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>
16
- ): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {
16
+ ): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> {
17
17
  return createBaseQuery(options, ReactQuery.useInfiniteQuery)
18
18
  }
@@ -5,14 +5,14 @@ import type {
5
5
  } from './types'
6
6
  import { ReactQuery, withMiddleware } from './utils'
7
7
 
8
- export const createMutation = <
8
+ export function createMutation<
9
9
  TData = unknown,
10
10
  TVariables = void,
11
11
  TError = CompatibleError,
12
12
  TContext = unknown
13
13
  >(
14
14
  defaultOptions: CreateMutationOptions<TData, TVariables, TError, TContext>
15
- ): MutationHook<TData, TVariables, TError, TContext> => {
15
+ ): MutationHook<TData, TVariables, TError, TContext> {
16
16
  return Object.assign(
17
17
  withMiddleware(ReactQuery.useMutation, defaultOptions, 'mutations'),
18
18
  {
@@ -2,12 +2,12 @@ import { createBaseQuery } from './createBaseQuery'
2
2
  import type { CompatibleError, CreateQueryOptions, QueryHook } from './types'
3
3
  import { ReactQuery } from './utils'
4
4
 
5
- export const createQuery = <
5
+ export function createQuery<
6
6
  TFnData,
7
7
  TVariables = void,
8
8
  TError = CompatibleError
9
9
  >(
10
10
  options: CreateQueryOptions<TFnData, TVariables, TError>
11
- ): QueryHook<TFnData, TVariables, TError> => {
11
+ ): QueryHook<TFnData, TVariables, TError> {
12
12
  return createBaseQuery(options, ReactQuery.useQuery)
13
13
  }
@@ -6,7 +6,7 @@ import type {
6
6
  } from './types'
7
7
  import { ReactQuery, isV5, suspenseOptions } from './utils'
8
8
 
9
- export const createSuspenseInfiniteQuery = <
9
+ export function createSuspenseInfiniteQuery<
10
10
  TFnData,
11
11
  TVariables = void,
12
12
  TError = CompatibleError,
@@ -18,7 +18,7 @@ export const createSuspenseInfiniteQuery = <
18
18
  TError,
19
19
  TPageParam
20
20
  >
21
- ): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {
21
+ ): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> {
22
22
  return isV5
23
23
  ? createBaseQuery(options, ReactQuery.useSuspenseInfiniteQuery)
24
24
  : createBaseQuery(options, ReactQuery.useInfiniteQuery, suspenseOptions)
@@ -6,13 +6,13 @@ import type {
6
6
  } from './types'
7
7
  import { ReactQuery, isV5, suspenseOptions } from './utils'
8
8
 
9
- export const createSuspenseQuery = <
9
+ export function createSuspenseQuery<
10
10
  TFnData,
11
11
  TVariables = void,
12
12
  TError = CompatibleError
13
13
  >(
14
14
  options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>
15
- ): SuspenseQueryHook<TFnData, TVariables, TError> => {
15
+ ): SuspenseQueryHook<TFnData, TVariables, TError> {
16
16
  return isV5
17
17
  ? createBaseQuery(options, ReactQuery.useSuspenseQuery)
18
18
  : createBaseQuery(options, ReactQuery.useQuery, suspenseOptions)
package/src/router.ts CHANGED
@@ -62,23 +62,23 @@ export const router = <TConfig extends RouterConfig>(
62
62
  return buildRouter(Array.isArray(key) ? key : [key], config)
63
63
  }
64
64
 
65
- router.query = <TFnData, TVariables = void, TError = CompatibleError>(
65
+ function query<TFnData, TVariables = void, TError = CompatibleError>(
66
66
  options: RouterQueryOptions<TFnData, TVariables, TError>
67
- ) => {
67
+ ) {
68
68
  return {
69
69
  ...options,
70
70
  _type: 'q',
71
71
  } as RouterQuery<TFnData, TVariables, TError>
72
72
  }
73
73
 
74
- router.infiniteQuery = <
74
+ function infiniteQuery<
75
75
  TFnData,
76
76
  TVariables = void,
77
77
  TError = CompatibleError,
78
78
  TPageParam = number
79
79
  >(
80
80
  options: RouterInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>
81
- ) => {
81
+ ) {
82
82
  return { ...options, _type: 'inf' } as RouterInfiniteQuery<
83
83
  TFnData,
84
84
  TVariables,
@@ -87,14 +87,12 @@ router.infiniteQuery = <
87
87
  >
88
88
  }
89
89
 
90
- router.mutation = <
90
+ function mutation<
91
91
  TFnData = unknown,
92
92
  TVariables = void,
93
93
  TError = CompatibleError,
94
94
  TContext = unknown
95
- >(
96
- options: RouterMutationOptions<TFnData, TVariables, TError, TContext>
97
- ) => {
95
+ >(options: RouterMutationOptions<TFnData, TVariables, TError, TContext>) {
98
96
  return { ...options, _type: 'm' } as RouterMutation<
99
97
  TFnData,
100
98
  TVariables,
@@ -102,3 +100,7 @@ router.mutation = <
102
100
  TContext
103
101
  >
104
102
  }
103
+
104
+ router.query = query
105
+ router.infiniteQuery = infiniteQuery
106
+ router.mutation = mutation
package/src/types.ts CHANGED
@@ -13,6 +13,7 @@ import type {
13
13
  QueryKey,
14
14
  QueryKeyHashFunction,
15
15
  QueryObserverSuccessResult,
16
+ SkipToken,
16
17
  UseInfiniteQueryOptions,
17
18
  UseInfiniteQueryResult,
18
19
  UseMutationOptions,
@@ -100,7 +101,9 @@ export type ExposeMethods<TFnData, TVariables, TError, TPageParam = never> = {
100
101
  QueryKey
101
102
  >
102
103
  getFetchOptions: (
103
- variables: TVariables extends void ? TVariables | void : TVariables
104
+ variables: TVariables extends void
105
+ ? CompatibleWithV4<TVariables | SkipToken, TVariables> | void
106
+ : CompatibleWithV4<TVariables | SkipToken, TVariables>
104
107
  ) => Pick<
105
108
  ReturnType<
106
109
  ExposeMethods<TFnData, TVariables, TError, TPageParam>['getOptions']
@@ -117,7 +120,9 @@ export type ExposeMethods<TFnData, TVariables, TError, TPageParam = never> = {
117
120
  | 'initialPageParam'
118
121
  >
119
122
  getOptions: (
120
- variables: TVariables extends void ? TVariables | void : TVariables
123
+ variables: TVariables extends void
124
+ ? CompatibleWithV4<TVariables | SkipToken, TVariables> | void
125
+ : CompatibleWithV4<TVariables | SkipToken, TVariables>
121
126
  ) => [TPageParam] extends [never]
122
127
  ? CompatibleWithV4<
123
128
  UseQueryOptions<TFnData, TError, TFnData, QueryKey> & {
@@ -169,7 +174,7 @@ export interface QueryHookOptions<TFnData, TError, TData, TVariables>
169
174
  'queryKey' | 'queryFn' | 'queryKeyHashFn'
170
175
  > {
171
176
  use?: Middleware<QueryHook<TFnData, TVariables, TError>>[]
172
- variables?: TVariables
177
+ variables?: CompatibleWithV4<TVariables | SkipToken, TVariables>
173
178
  }
174
179
 
175
180
  export interface DefinedQueryHookOptions<TFnData, TError, TData, TVariables>
@@ -242,7 +247,7 @@ export interface SuspenseQueryHookOptions<TFnData, TError, TData, TVariables>
242
247
  | 'useErrorBoundary'
243
248
  > {
244
249
  use?: Middleware<SuspenseQueryHook<TFnData, TVariables, TVariables>>[]
245
- variables?: TVariables
250
+ variables?: CompatibleWithV4<TVariables | SkipToken, TVariables>
246
251
  }
247
252
 
248
253
  export type SuspenseQueryHookResult<TData, TError> = Omit<
@@ -301,7 +306,7 @@ export interface InfiniteQueryHookOptions<
301
306
  | 'getNextPageParam'
302
307
  > {
303
308
  use?: Middleware<InfiniteQueryHook<TFnData, TVariables, TError, TPageParam>>[]
304
- variables?: TVariables
309
+ variables?: CompatibleWithV4<TVariables | SkipToken, TVariables>
305
310
  }
306
311
 
307
312
  export interface DefinedInfiniteQueryHookOptions<
@@ -411,7 +416,7 @@ export interface SuspenseInfiniteQueryHookOptions<
411
416
  | 'useErrorBoundary'
412
417
  > {
413
418
  use?: Middleware<SuspenseInfiniteQueryHook<TFnData, TVariables, TVariables>>[]
414
- variables?: TVariables
419
+ variables?: CompatibleWithV4<TVariables | SkipToken, TVariables>
415
420
  }
416
421
 
417
422
  export type SuspenseInfiniteQueryHookResult<TData, TError> = Omit<
@@ -1 +0,0 @@
1
- import*as e from"@tanstack/react-query";const t=e,u=!!t.useSuspenseQuery,r={enabled:!0,suspense:!0,keepPreviousData:void 0,useErrorBoundary:(e,t)=>void 0===t.state.data},s=(e,r,s)=>function(n,i){const[a,y]=[t.useQueryClient(u?i:n).getDefaultOptions()[s],r,n].reduce((([e,t],{use:u=[],...r}={})=>[[...e,...u],{...t,...r}]),[[]]);return a.reduceRight(((e,t)=>t(e)),e)(y,i)},n=(e,t)=>void 0===t?e:[...e,t],i=(e,t,u)=>{const r=(t,u)=>({queryFn:e=>t(u,e),queryKey:n(e.queryKey,u)});return Object.assign(s(((e,s)=>t({...e,...r(e.fetcher,e.variables),...u},s)),e,"queries"),{fetcher:e.fetcher,getKey:t=>n(e.queryKey,t),getOptions:t=>({...e,...r(e.fetcher,t)}),getFetchOptions:t=>({...r(e.fetcher,t),queryKeyHashFn:e.queryKeyHashFn,getPreviousPageParam:e.getPreviousPageParam,getNextPageParam:e.getNextPageParam,initialPageParam:e.initialPageParam})})},a=e=>i(e,t.useQuery),y=e=>u?i(e,t.useSuspenseQuery):i(e,t.useQuery,r),o=e=>i(e,t.useInfiniteQuery),g=e=>u?i(e,t.useSuspenseInfiniteQuery):i(e,t.useInfiniteQuery,r),p=e=>Object.assign(s(t.useMutation,e,"mutations"),{getKey:()=>e.mutationKey,getOptions:()=>e,mutationFn:e.mutationFn}),c=(e,t)=>Object.entries(t).reduce(((t,[u,r])=>{if(r._type){const s={...r,["m"===r._type?"mutationKey":"queryKey"]:[...e,u]};t[u]="m"===r._type?{useMutation:p(s),...p(s)}:"q"===r._type?{useQuery:a(s),useSuspenseQuery:y(s),...a(s)}:{useInfiniteQuery:o(s),useSuspenseInfiniteQuery:g(s),...o(s)}}else t[u]=c([...e,u],r);return t}),{getKey:()=>e}),m=(e,t)=>c(Array.isArray(e)?e:[e],t);m.query=e=>({...e,_type:"q"}),m.infiniteQuery=e=>({...e,_type:"inf"}),m.mutation=e=>({...e,_type:"m"});export{o as createInfiniteQuery,p as createMutation,a as createQuery,g as createSuspenseInfiniteQuery,y as createSuspenseQuery,n as getKey,m as router};