react-query-kit 3.2.0 → 3.2.2
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 +1 -1
- package/build/lib/createInfiniteQuery.d.ts +2 -2
- package/build/lib/createInfiniteQuery.esm.js +2 -2
- package/build/lib/createInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createInfiniteQuery.js +2 -2
- package/build/lib/createInfiniteQuery.js.map +1 -1
- package/build/lib/createInfiniteQuery.mjs +2 -2
- package/build/lib/createInfiniteQuery.mjs.map +1 -1
- package/build/lib/createMutation.d.ts +2 -2
- package/build/lib/createMutation.esm.js +2 -2
- package/build/lib/createMutation.esm.js.map +1 -1
- package/build/lib/createMutation.js +2 -2
- package/build/lib/createMutation.js.map +1 -1
- package/build/lib/createMutation.mjs +2 -2
- package/build/lib/createMutation.mjs.map +1 -1
- package/build/lib/createQuery.d.ts +2 -2
- package/build/lib/createQuery.esm.js +2 -2
- package/build/lib/createQuery.esm.js.map +1 -1
- package/build/lib/createQuery.js +2 -2
- package/build/lib/createQuery.js.map +1 -1
- package/build/lib/createQuery.mjs +2 -2
- package/build/lib/createQuery.mjs.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.d.ts +2 -2
- package/build/lib/createSuspenseInfiniteQuery.esm.js +2 -2
- package/build/lib/createSuspenseInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.js +2 -2
- package/build/lib/createSuspenseInfiniteQuery.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.mjs +2 -2
- package/build/lib/createSuspenseInfiniteQuery.mjs.map +1 -1
- package/build/lib/createSuspenseQuery.d.ts +2 -2
- package/build/lib/createSuspenseQuery.esm.js +2 -2
- package/build/lib/createSuspenseQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseQuery.js +2 -2
- package/build/lib/createSuspenseQuery.js.map +1 -1
- package/build/lib/createSuspenseQuery.mjs +2 -2
- package/build/lib/createSuspenseQuery.mjs.map +1 -1
- package/build/lib/router.d.ts +8 -4
- package/build/lib/router.esm.js +10 -6
- package/build/lib/router.esm.js.map +1 -1
- package/build/lib/router.js +10 -6
- package/build/lib/router.js.map +1 -1
- package/build/lib/router.mjs +10 -6
- package/build/lib/router.mjs.map +1 -1
- package/build/lib/types.d.ts +3 -3
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.esm.js +1 -1
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +1 -1
- package/build/lib/utils.mjs.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats.json +108 -108
- package/build/umd/index.development.js +21 -17
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/build/zip/zip.esm.js +1 -1
- package/package.json +2 -2
- package/src/createInfiniteQuery.ts +2 -2
- package/src/createMutation.ts +2 -2
- package/src/createQuery.ts +2 -2
- package/src/createSuspenseInfiniteQuery.ts +2 -2
- package/src/createSuspenseQuery.ts +2 -2
- package/src/router.ts +10 -8
- package/src/types.ts +3 -3
- package/src/utils.ts +1 -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 placeholderData: 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","placeholderData","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":"4lBAKO,MAAMA,OAEAC,IAASD,EAAWE,iBAEpBC,EAAkB,CAC7BC,SAAS,EACTC,UAAU,EACVC,qBAAiBC,EACjBC,iBAAkB,CAACC,EAAiBC,SACbH,IAArBG,EAAMC,MAAMC,MAGHC,EAAiB,CAC5BC,EACAC,EACAC,IAEO,SACLC,EACAC,GAEA,MAAOC,EAAMC,GAA6B,CACxCpB,EAAWqB,eAETpB,EAAOiB,EAAcD,GACrBK,oBAAoBN,GACtBD,EACAE,GACAM,QACA,EAAEC,EAAIC,IAAOC,IAAKC,EAAK,MAAOC,GAAO,CAAA,IAAO,CAC1C,IAAIJ,KAAOG,GACX,IAAKF,KAAOG,KAEd,CAAC,KAGH,OAAOT,EAAKU,aAAY,CAACC,EAAMJ,IAAQA,EAAII,IAAOhB,EAA3CK,CAAiDC,EAAMF,IAIrDa,EAAS,CAACC,EAAoBC,SACpB1B,IAAd0B,EAA0BD,EAAW,IAAIA,EAAUC,GC7B/CC,EAAkB,CAC7BnB,EACAoB,EACAC,KAkBA,MAAMC,EAAkB,CAACC,EAAgBL,KAChC,CACLM,QAAUC,GAAkCF,EAAUL,EAAWO,GACjER,SAAUS,EAAW1B,EAAeiB,SAAUC,KAsClD,OAAOS,OAAOC,OAAO9B,GAdD,CAClBI,EACAC,IAEOiB,EACL,IACKlB,KACAoB,EAAgBpB,EAAQ2B,QAAS3B,EAAQgB,cACzCG,GAELlB,IAI6CH,EAAgB,WAAY,CAC3E6B,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iD,EAAIC,GAAOL,EAAY,IAAIC,EAAMI,GAAM/C,GA0BzC,OAAO8C,CAAP,GAEF,CACEnC,OAAQ,IAAMgC,IAKPM,EAAS,CACpBF,EACAH,IAEOF,EAAYQ,MAAMC,QAAQJ,GAAOA,EAAM,CAACA,GAAMH,GAGvDK,EAAO3D,MACLO,IAEO,IACFA,EACHmD,MAAO,MAIXC,EAAOG,cAMLvD,IAEO,IAAKA,EAASmD,MAAO,QAQ9BC,EAAOI,SAMLxD,IAEO,IAAKA,EAASmD,MAAO"}
|
|
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 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","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":"4lBAKO,MAAMA,OAEAC,IAASD,EAAWE,iBAEpBC,EAAkB,CAC7BC,SAAS,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mD,MAAO,MAM7B,EAkBDC,EAAOI,SAhBP,SAKExD,GACA,MAAO,IAAKA,EAASmD,MAAO,IAM7B"}
|
package/build/zip/zip.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"@tanstack/react-query";const t=e,u=!!t.useSuspenseQuery,
|
|
1
|
+
import*as e from"@tanstack/react-query";const t=e,u=!!t.useSuspenseQuery,n={enabled:!0,suspense:!0,keepPreviousData:void 0,useErrorBoundary:(e,t)=>void 0===t.state.data},r=(e,n,r)=>function(i,s){const[a,y]=[t.useQueryClient(u?s:i).getDefaultOptions()[r],n,i].reduce((([e,t],{use:u=[],...n}={})=>[[...e,...u],{...t,...n}]),[[]]);return a.reduceRight(((e,t)=>t(e)),e)(y,s)},i=(e,t)=>void 0===t?e:[...e,t],s=(e,t,u)=>{const n=(t,u)=>({queryFn:e=>t(u,e),queryKey:i(e.queryKey,u)});return Object.assign(r(((e,r)=>t({...e,...n(e.fetcher,e.variables),...u},r)),e,"queries"),{fetcher:e.fetcher,getKey:t=>i(e.queryKey,t),getOptions:t=>({...e,...n(e.fetcher,t)}),getFetchOptions:t=>({...n(e.fetcher,t),queryKeyHashFn:e.queryKeyHashFn,getPreviousPageParam:e.getPreviousPageParam,getNextPageParam:e.getNextPageParam,initialPageParam:e.initialPageParam})})};function a(e){return s(e,t.useQuery)}function y(e){return u?s(e,t.useSuspenseQuery):s(e,t.useQuery,n)}function o(e){return s(e,t.useInfiniteQuery)}function c(e){return u?s(e,t.useSuspenseInfiniteQuery):s(e,t.useInfiniteQuery,n)}function f(e){return Object.assign(r(t.useMutation,e,"mutations"),{getKey:()=>e.mutationKey,getOptions:()=>e,mutationFn:e.mutationFn})}const g=(e,t)=>Object.entries(t).reduce(((t,[u,n])=>{if(n._type){const r={...n,["m"===n._type?"mutationKey":"queryKey"]:[...e,u]};t[u]="m"===n._type?{useMutation:f(r),...f(r)}:"q"===n._type?{useQuery:a(r),useSuspenseQuery:y(r),...a(r)}:{useInfiniteQuery:o(r),useSuspenseInfiniteQuery:c(r),...o(r)}}else t[u]=g([...e,u],n);return t}),{getKey:()=>e}),p=(e,t)=>g(Array.isArray(e)?e:[e],t);p.query=function(e){return{...e,_type:"q"}},p.infiniteQuery=function(e){return{...e,_type:"inf"}},p.mutation=function(e){return{...e,_type:"m"}};export{o as createInfiniteQuery,f as createMutation,a as createQuery,c as createSuspenseInfiniteQuery,y as createSuspenseQuery,i as getKey,p as router};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-query-kit",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
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.
|
|
30
|
+
"@tanstack/react-query": "^5.28.6",
|
|
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",
|
|
@@ -6,13 +6,13 @@ import type {
|
|
|
6
6
|
} from './types'
|
|
7
7
|
import { ReactQuery } from './utils'
|
|
8
8
|
|
|
9
|
-
export
|
|
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
|
}
|
package/src/createMutation.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type {
|
|
|
5
5
|
} from './types'
|
|
6
6
|
import { ReactQuery, withMiddleware } from './utils'
|
|
7
7
|
|
|
8
|
-
export
|
|
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
|
{
|
package/src/createQuery.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
@@ -189,7 +189,7 @@ export type DefinedQueryHookResult<TData, TError> = DefinedUseQueryResult<
|
|
|
189
189
|
|
|
190
190
|
export interface QueryHook<
|
|
191
191
|
TFnData = unknown,
|
|
192
|
-
TVariables =
|
|
192
|
+
TVariables = void,
|
|
193
193
|
TError = CompatibleError
|
|
194
194
|
> extends ExposeMethods<TFnData, TVariables, TError> {
|
|
195
195
|
<TData = TFnData>(
|
|
@@ -494,7 +494,7 @@ export interface MutationHook<
|
|
|
494
494
|
// infer types
|
|
495
495
|
|
|
496
496
|
export type inferVariables<T> = T extends {
|
|
497
|
-
fetcher: ExposeFetcher<any, infer TVariables,
|
|
497
|
+
fetcher: ExposeFetcher<any, infer TVariables, infer _TPageParam>
|
|
498
498
|
}
|
|
499
499
|
? TVariables
|
|
500
500
|
: T extends ExposeMutationMethods<any, infer TVariables, any, any>
|
|
@@ -512,7 +512,7 @@ export type inferData<T> = T extends {
|
|
|
512
512
|
: never
|
|
513
513
|
|
|
514
514
|
export type inferFnData<T> = T extends {
|
|
515
|
-
fetcher: ExposeFetcher<infer TFnData, any,
|
|
515
|
+
fetcher: ExposeFetcher<infer TFnData, any, infer _TPageParam>
|
|
516
516
|
}
|
|
517
517
|
? TFnData
|
|
518
518
|
: T extends ExposeMutationMethods<infer TFnData, any, any, any>
|
package/src/utils.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const isV5 = !!ReactQuery.useSuspenseQuery
|
|
|
10
10
|
export const suspenseOptions = {
|
|
11
11
|
enabled: true,
|
|
12
12
|
suspense: true,
|
|
13
|
-
|
|
13
|
+
keepPreviousData: undefined,
|
|
14
14
|
useErrorBoundary: (_error: unknown, query: Query) =>
|
|
15
15
|
query.state.data === undefined,
|
|
16
16
|
}
|