@kubb/plugin-react-query 4.0.0 → 4.1.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 (33) hide show
  1. package/dist/{components-DzT-kLe8.cjs → components-DkiO4xNZ.cjs} +283 -229
  2. package/dist/components-DkiO4xNZ.cjs.map +1 -0
  3. package/dist/{components-C51l7G1u.js → components-Dz_s6t75.js} +276 -228
  4. package/dist/components-Dz_s6t75.js.map +1 -0
  5. package/dist/components.cjs +2 -1
  6. package/dist/components.d.cts +136 -106
  7. package/dist/components.d.ts +136 -106
  8. package/dist/components.js +2 -2
  9. package/dist/{generators-Bko771xm.cjs → generators-BiW_MevM.cjs} +27 -9
  10. package/dist/generators-BiW_MevM.cjs.map +1 -0
  11. package/dist/{generators-B3xZ2QoY.js → generators-ByqomtgH.js} +25 -7
  12. package/dist/generators-ByqomtgH.js.map +1 -0
  13. package/dist/generators.cjs +2 -2
  14. package/dist/generators.js +2 -2
  15. package/dist/index.cjs +2 -2
  16. package/dist/index.js +2 -2
  17. package/package.json +9 -10
  18. package/src/components/InfiniteQuery.tsx +21 -14
  19. package/src/components/InfiniteQueryOptions.tsx +19 -7
  20. package/src/components/Mutation.tsx +12 -40
  21. package/src/components/MutationOptions.tsx +113 -0
  22. package/src/components/index.ts +4 -3
  23. package/src/generators/__snapshots__/clientPostImportPath.ts +25 -12
  24. package/src/generators/__snapshots__/findInfiniteByTags.ts +14 -8
  25. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +14 -8
  26. package/src/generators/__snapshots__/updatePetById.ts +25 -12
  27. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +25 -12
  28. package/src/generators/infiniteQueryGenerator.tsx +1 -0
  29. package/src/generators/mutationGenerator.tsx +18 -2
  30. package/dist/components-C51l7G1u.js.map +0 -1
  31. package/dist/components-DzT-kLe8.cjs.map +0 -1
  32. package/dist/generators-B3xZ2QoY.js.map +0 -1
  33. package/dist/generators-Bko771xm.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators-ByqomtgH.js","names":[],"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx","../src/generators/infiniteQueryGenerator.tsx","../src/generators/suspenseQueryGenerator.tsx"],"sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginReactQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginReactQuery>({\n name: 'react-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginReactQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n\n const importPath = options.query ? options.query.importPath : '@tanstack/react-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n // grouping is coming from react-query instead of zod option, we need to pass the options of zod instead\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.queryKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.query && (\n <>\n <File.Import name={['useQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'QueryObserverOptions', 'UseQueryResult', 'QueryClient']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n","import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport { MutationOptions } from '../components/MutationOptions.tsx'\nimport type { PluginReactQuery } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginReactQuery>({\n name: 'react-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginReactQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n !isQuery &&\n difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)\n\n const importPath = options.mutation ? options.mutation.importPath : '@tanstack/react-query'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const mutationOptions = {\n name: getName(operation, { type: 'function', suffix: 'MutationOptions' }),\n }\n\n const mutationKey = {\n name: getName(operation, { type: 'const', suffix: 'MutationKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'MutationKey' }),\n }\n\n if (!isMutation) {\n return null\n }\n\n return (\n <File\n baseName={mutation.file.baseName}\n path={mutation.file.path}\n meta={mutation.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={mutation.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mutation.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.mutationKey}\n />\n\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <File.Import name={['mutationOptions']} path={importPath} />\n\n <MutationOptions\n name={mutationOptions.name}\n clientName={client.name}\n mutationKeyName={mutationKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.mutation && (\n <>\n <File.Import name={['useMutation']} path={importPath} />\n <File.Import name={['UseMutationOptions', 'QueryClient']} path={importPath} isTypeOnly />\n <Mutation\n name={mutation.name}\n mutationOptionsName={mutationOptions.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n />\n </>\n )}\n </File>\n )\n },\n})\n","import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { InfiniteQuery, InfiniteQueryOptions, QueryKey } from '../components'\nimport type { PluginReactQuery } from '../types'\n\nexport const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({\n name: 'react-infinite-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginReactQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n const isInfinite = !!options.infinite\n\n const importPath = options.query ? options.query.importPath : '@tanstack/react-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use', suffix: 'infinite' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use', suffix: 'infinite' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n suffix: 'infinite',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'InfiniteQueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'InfiniteQueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'InfiniteQueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation || !isInfinite) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n {<File.Import name={'fetch'} path={options.client.importPath} />}\n {hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.queryKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n {options.infinite && (\n <>\n <File.Import name={['InfiniteData']} isTypeOnly path={importPath} />\n <File.Import name={['infiniteQueryOptions']} path={importPath} />\n <InfiniteQueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n cursorParam={options.infinite.cursorParam}\n initialPageParam={options.infinite.initialPageParam}\n queryParam={options.infinite.queryParam}\n />\n </>\n )}\n {options.infinite && (\n <>\n <File.Import name={['useInfiniteQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'InfiniteQueryObserverOptions', 'UseInfiniteQueryResult']} path={importPath} isTypeOnly />\n <InfiniteQuery\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n queryParam={options.infinite.queryParam}\n />\n </>\n )}\n </File>\n )\n },\n})\n","import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { QueryKey, QueryOptions, SuspenseQuery } from '../components'\nimport type { PluginReactQuery } from '../types'\n\nexport const suspenseQueryGenerator = createReactGenerator<PluginReactQuery>({\n name: 'react-suspense-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginReactQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n\n const isSuspense = !!options.suspense\n\n const importPath = options.query ? options.query.importPath : '@tanstack/react-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use', suffix: 'suspense' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use', suffix: 'suspense' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n suffix: 'suspense',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'SuspenseQueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'SuspenseQueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'SuspenseQueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation || !isSuspense) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.queryKey}\n />\n\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.suspense && (\n <>\n <File.Import name={['useSuspenseQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'UseSuspenseQueryOptions', 'UseSuspenseQueryResult']} path={importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n\n <SuspenseQuery\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,iBAAiB,qBAAuC;CACnE,MAAM;CACN,UAAU,EAAE,SAAS,aAAa;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,YAEb,kBACE,QAA0B;EAC9B,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,qBAAqB;EAE9D,MAAM,UAAU,OAAO,QAAQ,UAAU,YAAY,OAAO,QAAQ,OAAO,QAAQ,MAAM,WAAW,UAAU,WAAW,OAAO;EAChI,MAAM,aAAa,WAAW,QAAQ,WAAW,QAAQ,SAAS,UAAU,EAAE,EAAE,QAAQ,QAAQ,QAAQ,MAAM,UAAU,EAAE,CAAC,CAAC,MACzH,W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AS,QAAQ,OAAO;KACb;KACX,aAAa,KAAK;KAClB,YAAY,IAAI;KAChB,gBAAgB,QAAQ,OAAO;KAC/B,cAAc,QAAQ;KACtB,YAAY,QAAQ;KACpB,gBAAgB,QAAQ;KACxB,QAAQ,QAAQ;MAChB;IAEJ,oBAAC,KAAK;KAAO,MAAM,CAAC,eAAe;KAAE,MAAM;MAAc;IACzD,oBAAC;KACC,MAAM,aAAa;KACnB,YAAY,OAAO;KACnB,cAAc,SAAS;KACvB,aAAa,KAAK;KAClB,cAAc,QAAQ;KACtB,YAAY,QAAQ;KACpB,gBAAgB,QAAQ;KACxB,gBAAgB,QAAQ,OAAO;MAC/B;IACD,QAAQ,YACP;KACE,oBAAC,KAAK;MAAO,MAAM,CAAC,mBAAmB;MAAE,MAAM;OAAc;KAC7D,oBAAC,KAAK;MAAO,MAAM;OAAC;OAAY;OAAe;OAA2B;OAAyB;MAAE,MAAM;MAAY;OAAa;KACnI,QAAQ,OAAO,mBAAmB,UAAU,oBAAC,KAAK;MAAO,MAAM,CAAC,iBAAiB;MAAE,MAAM,QAAQ,OAAO;MAAY;OAAa;KAElI,oBAAC;MACC,MAAM,MAAM;MACZ,kBAAkB,aAAa;MAC/B,aAAa,KAAK;MAClB,YAAY,QAAQ;MACpB,cAAc,QAAQ;MACtB,gBAAgB,QAAQ;MACb;MACX,gBAAgB,QAAQ,OAAO;MAC/B,cAAc,SAAS;MACvB,kBAAkB,SAAS;OAC3B;QACD;;IAEA;;CAGZ,CAAC"}
@@ -1,5 +1,5 @@
1
- require('./components-DzT-kLe8.cjs');
2
- const require_generators = require('./generators-Bko771xm.cjs');
1
+ require('./components-DkiO4xNZ.cjs');
2
+ const require_generators = require('./generators-BiW_MevM.cjs');
3
3
 
4
4
  exports.infiniteQueryGenerator = require_generators.infiniteQueryGenerator;
5
5
  exports.mutationGenerator = require_generators.mutationGenerator;
@@ -1,4 +1,4 @@
1
- import "./components-C51l7G1u.js";
2
- import { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from "./generators-B3xZ2QoY.js";
1
+ import "./components-Dz_s6t75.js";
2
+ import { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from "./generators-ByqomtgH.js";
3
3
 
4
4
  export { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- const require_components = require('./components-DzT-kLe8.cjs');
2
- const require_generators = require('./generators-Bko771xm.cjs');
1
+ const require_components = require('./components-DkiO4xNZ.cjs');
2
+ const require_generators = require('./generators-BiW_MevM.cjs');
3
3
  let node_path = require("node:path");
4
4
  node_path = require_components.__toESM(node_path);
5
5
  let __kubb_core = require("@kubb/core");
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { MutationKey, QueryKey } from "./components-C51l7G1u.js";
2
- import { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from "./generators-B3xZ2QoY.js";
1
+ import { MutationKey, QueryKey } from "./components-Dz_s6t75.js";
2
+ import { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from "./generators-ByqomtgH.js";
3
3
  import path from "node:path";
4
4
  import { FileManager, PluginManager, createPlugin } from "@kubb/core";
5
5
  import { camelCase, pascalCase } from "@kubb/core/transformers";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-react-query",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "React Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for React applications.",
5
5
  "keywords": [
6
6
  "react-query",
@@ -61,20 +61,19 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "remeda": "^2.32.0",
64
- "@kubb/core": "4.0.0",
65
- "@kubb/oas": "4.0.0",
66
- "@kubb/plugin-client": "4.0.0",
67
- "@kubb/plugin-oas": "4.0.0",
68
- "@kubb/plugin-ts": "4.0.0",
69
- "@kubb/plugin-zod": "4.0.0",
70
- "@kubb/react": "4.0.0"
64
+ "@kubb/core": "4.1.0",
65
+ "@kubb/oas": "4.1.0",
66
+ "@kubb/plugin-client": "4.1.0",
67
+ "@kubb/plugin-oas": "4.1.0",
68
+ "@kubb/plugin-zod": "4.1.0",
69
+ "@kubb/plugin-ts": "4.1.0",
70
+ "@kubb/react": "4.1.0"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/react": "^18.3.24",
74
74
  "react": "^18.3.1",
75
75
  "tsdown": "^0.14.2",
76
- "typescript": "^5.9.2",
77
- "@kubb/config-ts": "4.0.0"
76
+ "typescript": "^5.9.2"
78
77
  },
79
78
  "peerDependencies": {
80
79
  "@kubb/react": "^4.0.0"
@@ -3,7 +3,7 @@ import type { OperationSchemas } from '@kubb/plugin-oas'
3
3
  import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
4
4
  import { File, Function, FunctionParams } from '@kubb/react'
5
5
  import type { ReactNode } from 'react'
6
- import type { PluginReactQuery } from '../types.ts'
6
+ import type { Infinite, PluginReactQuery } from '../types.ts'
7
7
  import { QueryKey } from './QueryKey.tsx'
8
8
  import { QueryOptions } from './QueryOptions.tsx'
9
9
 
@@ -21,20 +21,18 @@ type Props = {
21
21
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
22
22
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
23
23
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
24
+ queryParam?: Infinite['queryParam']
24
25
  }
25
26
 
26
27
  type GetParamsProps = {
27
28
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
28
29
  paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
29
30
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
30
- dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
31
31
  typeSchemas: OperationSchemas
32
+ pageParamGeneric: string
32
33
  }
33
34
 
34
- function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
35
- const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
36
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
37
-
35
+ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }: GetParamsProps) {
38
36
  if (paramsType === 'object') {
39
37
  return FunctionParams.factory({
40
38
  data: {
@@ -67,7 +65,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
67
65
  options: {
68
66
  type: `
69
67
  {
70
- query?: Partial<InfiniteQueryObserverOptions<${[TData, TError, 'TQueryData', 'TQueryKey', 'TQueryData'].join(', ')}>> & { client?: QueryClient },
68
+ query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
71
69
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}
72
70
  }
73
71
  `,
@@ -108,7 +106,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
108
106
  options: {
109
107
  type: `
110
108
  {
111
- query?: Partial<InfiniteQueryObserverOptions<${[TData, TError, 'TQueryData', 'TQueryKey', 'TQueryData'].join(', ')}>> & { client?: QueryClient },
109
+ query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
112
110
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}
113
111
  }
114
112
  `,
@@ -128,11 +126,20 @@ export function InfiniteQuery({
128
126
  dataReturnType,
129
127
  typeSchemas,
130
128
  operation,
129
+ queryParam,
131
130
  }: Props): ReactNode {
132
- const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
133
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
134
- const returnType = `UseInfiniteQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`
135
- const generics = [`TData = InfiniteData<${TData}>`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
131
+ const responseType = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
132
+ const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
133
+ const explicitPageParamType = queryParam && typeSchemas.queryParams?.name ? `NonNullable<${typeSchemas.queryParams?.name}['${queryParam}']>` : undefined
134
+ const pageParamType = explicitPageParamType ?? 'number'
135
+ const returnType = 'UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }'
136
+ const generics = [
137
+ `TQueryFnData = ${responseType}`,
138
+ `TError = ${errorType}`,
139
+ 'TData = InfiniteData<TQueryFnData>',
140
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
141
+ `TPageParam = ${pageParamType}`,
142
+ ]
136
143
 
137
144
  const queryKeyParams = QueryKey.getParams({
138
145
  pathParamsType,
@@ -149,8 +156,8 @@ export function InfiniteQuery({
149
156
  paramsCasing,
150
157
  paramsType,
151
158
  pathParamsType,
152
- dataReturnType,
153
159
  typeSchemas,
160
+ pageParamGeneric: 'TPageParam',
154
161
  })
155
162
 
156
163
  const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`
@@ -175,7 +182,7 @@ export function InfiniteQuery({
175
182
  ...${queryOptions},
176
183
  queryKey,
177
184
  ...queryOptions
178
- } as unknown as InfiniteQueryObserverOptions, queryClient) as ${returnType}
185
+ } as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
179
186
 
180
187
  query.queryKey = queryKey as TQueryKey
181
188
 
@@ -34,7 +34,10 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
34
34
  data: {
35
35
  mode: 'object',
36
36
  children: {
37
- ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
37
+ ...getPathParams(typeSchemas.pathParams, {
38
+ typed: true,
39
+ casing: paramsCasing,
40
+ }),
38
41
  data: typeSchemas.request?.name
39
42
  ? {
40
43
  type: typeSchemas.request?.name,
@@ -68,7 +71,10 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
68
71
  pathParams: typeSchemas.pathParams?.name
69
72
  ? {
70
73
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
71
- children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
74
+ children: getPathParams(typeSchemas.pathParams, {
75
+ typed: true,
76
+ casing: paramsCasing,
77
+ }),
72
78
  optional: isOptional(typeSchemas.pathParams?.schema),
73
79
  }
74
80
  : undefined,
@@ -112,10 +118,16 @@ export function InfiniteQueryOptions({
112
118
  queryParam,
113
119
  queryKeyName,
114
120
  }: Props): ReactNode {
115
- const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
116
- const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
121
+ const queryFnDataType = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
122
+ const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
123
+ const pageParamType = queryParam && typeSchemas.queryParams?.name ? `NonNullable<${typeSchemas.queryParams?.name}['${queryParam}']>` : 'number'
117
124
 
118
- const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
125
+ const params = getParams({
126
+ paramsType,
127
+ paramsCasing,
128
+ pathParamsType,
129
+ typeSchemas,
130
+ })
119
131
  const clientParams = Client.getParams({
120
132
  paramsCasing,
121
133
  typeSchemas,
@@ -164,7 +176,7 @@ export function InfiniteQueryOptions({
164
176
  <Function name={name} export params={params.toConstructor()}>
165
177
  {`
166
178
  const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
167
- return infiniteQueryOptions<${TData}, ${TError}, ${TData}, typeof queryKey, number>({
179
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
168
180
  ${enabledText}
169
181
  queryKey,
170
182
  queryFn: async ({ signal, pageParam }) => {
@@ -185,7 +197,7 @@ export function InfiniteQueryOptions({
185
197
  <Function name={name} export params={params.toConstructor()}>
186
198
  {`
187
199
  const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
188
- return infiniteQueryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
200
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
189
201
  ${enabledText}
190
202
  queryKey,
191
203
  queryFn: async ({ signal }) => {
@@ -1,13 +1,11 @@
1
- import { File, Function, FunctionParams } from '@kubb/react'
2
-
3
- import { type Operation, isOptional } from '@kubb/oas'
4
- import { Client } from '@kubb/plugin-client/components'
1
+ import { isOptional, type Operation } from '@kubb/oas'
5
2
  import type { OperationSchemas } from '@kubb/plugin-oas'
6
3
  import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
7
- import type { Params } from '@kubb/react/types'
4
+ import { File, Function, FunctionParams } from '@kubb/react'
8
5
  import type { ReactNode } from 'react'
9
6
  import type { PluginReactQuery } from '../types.ts'
10
7
  import { MutationKey } from './MutationKey.tsx'
8
+ import { MutationOptions } from './MutationOptions.tsx'
11
9
 
12
10
  type Props = {
13
11
  /**
@@ -15,13 +13,12 @@ type Props = {
15
13
  */
16
14
  name: string
17
15
  typeName: string
18
- clientName: string
16
+ mutationOptionsName: string
19
17
  mutationKeyName: string
20
18
  typeSchemas: OperationSchemas
21
19
  operation: Operation
22
20
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
23
21
  paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
24
- paramsType: PluginReactQuery['resolvedOptions']['paramsType']
25
22
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
26
23
  }
27
24
 
@@ -74,9 +71,8 @@ function getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps
74
71
 
75
72
  export function Mutation({
76
73
  name,
77
- clientName,
74
+ mutationOptionsName,
78
75
  paramsCasing,
79
- paramsType,
80
76
  pathParamsType,
81
77
  dataReturnType,
82
78
  typeSchemas,
@@ -95,14 +91,6 @@ export function Mutation({
95
91
  typeSchemas,
96
92
  })
97
93
 
98
- const clientParams = Client.getParams({
99
- paramsCasing,
100
- paramsType,
101
- typeSchemas,
102
- pathParamsType,
103
- isConfigurable: true,
104
- })
105
-
106
94
  const mutationParams = FunctionParams.factory({
107
95
  ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
108
96
  data: typeSchemas.request?.name
@@ -125,28 +113,14 @@ export function Mutation({
125
113
  : undefined,
126
114
  })
127
115
 
128
- const dataParams = FunctionParams.factory({
129
- data: {
130
- // No use of pathParams because useMutation can only take one argument in object form,
131
- // see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation
132
- mode: 'object',
133
- children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
134
- if (value) {
135
- acc[key] = {
136
- ...value,
137
- type: undefined,
138
- }
139
- }
140
-
141
- return acc
142
- }, {} as Params),
143
- },
144
- })
116
+ const mutationOptionsParams = MutationOptions.getParams({ typeSchemas })
145
117
 
146
118
  const TRequest = mutationParams.toConstructor()
147
119
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
148
120
  const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
149
- const generics = [TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')
121
+ const returnType = `UseMutationOptions<${[TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')}>`
122
+
123
+ const mutationOptions = `${mutationOptionsName}(${mutationOptionsParams.toCall()})`
150
124
 
151
125
  return (
152
126
  <File.Source name={name} isExportable isIndexable>
@@ -164,13 +138,11 @@ export function Mutation({
164
138
  const { client: queryClient, ...mutationOptions } = mutation;
165
139
  const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
166
140
 
167
- return useMutation<${generics}>({
168
- mutationFn: async(${dataParams.toConstructor()}) => {
169
- return ${clientName}(${clientParams.toCall()})
170
- },
141
+ return useMutation({
142
+ ...${mutationOptions},
171
143
  mutationKey,
172
144
  ...mutationOptions
173
- }, queryClient)
145
+ } as unknown as UseMutationOptions, queryClient) as ${returnType}
174
146
  `}
175
147
  </Function>
176
148
  </File.Source>
@@ -0,0 +1,113 @@
1
+ import { isOptional } from '@kubb/oas'
2
+ import { Client } from '@kubb/plugin-client/components'
3
+ import type { OperationSchemas } from '@kubb/plugin-oas'
4
+ import { getPathParams } from '@kubb/plugin-oas/utils'
5
+ import { File, Function, FunctionParams } from '@kubb/react'
6
+ import type { Params } from '@kubb/react/types'
7
+ import type { PluginReactQuery } from '../types.ts'
8
+ import { MutationKey } from './MutationKey.tsx'
9
+
10
+ type Props = {
11
+ name: string
12
+ clientName: string
13
+ mutationKeyName: string
14
+ typeSchemas: OperationSchemas
15
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
16
+ paramsType: PluginReactQuery['resolvedOptions']['paramsType']
17
+ pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
18
+ dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
19
+ }
20
+
21
+ type GetParamsProps = {
22
+ typeSchemas: OperationSchemas
23
+ }
24
+
25
+ function getParams({ typeSchemas }: GetParamsProps) {
26
+ return FunctionParams.factory({
27
+ config: {
28
+ type: typeSchemas.request?.name
29
+ ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`
30
+ : 'Partial<RequestConfig> & { client?: typeof fetch }',
31
+ default: '{}',
32
+ },
33
+ })
34
+ }
35
+
36
+ export function MutationOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, mutationKeyName }: Props) {
37
+ const params = getParams({ typeSchemas })
38
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
39
+ const TError = typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'
40
+
41
+ const clientParams = Client.getParams({
42
+ typeSchemas,
43
+ paramsCasing,
44
+ paramsType,
45
+ pathParamsType,
46
+ isConfigurable: true,
47
+ })
48
+
49
+ const mutationKeyParams = MutationKey.getParams({
50
+ pathParamsType,
51
+ typeSchemas,
52
+ })
53
+
54
+ const mutationParams = FunctionParams.factory({
55
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
56
+ data: typeSchemas.request?.name
57
+ ? {
58
+ type: typeSchemas.request?.name,
59
+ optional: isOptional(typeSchemas.request?.schema),
60
+ }
61
+ : undefined,
62
+ params: typeSchemas.queryParams?.name
63
+ ? {
64
+ type: typeSchemas.queryParams?.name,
65
+ optional: isOptional(typeSchemas.queryParams?.schema),
66
+ }
67
+ : undefined,
68
+ headers: typeSchemas.headerParams?.name
69
+ ? {
70
+ type: typeSchemas.headerParams?.name,
71
+ optional: isOptional(typeSchemas.headerParams?.schema),
72
+ }
73
+ : undefined,
74
+ })
75
+
76
+ const dataParams = FunctionParams.factory({
77
+ data: {
78
+ // No use of pathParams because useMutation can only take one argument in object form,
79
+ // see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation
80
+ mode: 'object',
81
+ children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
82
+ if (value) {
83
+ acc[key] = {
84
+ ...value,
85
+ type: undefined,
86
+ }
87
+ }
88
+
89
+ return acc
90
+ }, {} as Params),
91
+ },
92
+ })
93
+
94
+ const TRequest = mutationParams.toConstructor()
95
+
96
+ return (
97
+ <File.Source name={name} isExportable isIndexable>
98
+ <Function name={name} export params={params.toConstructor()}>
99
+ {`
100
+ const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})
101
+ return mutationOptions<${TData}, ResponseErrorConfig<${TError}>, ${TRequest ? `{${TRequest}}` : 'void'}, typeof mutationKey>({
102
+ mutationKey,
103
+ mutationFn: async(${dataParams.toConstructor()}) => {
104
+ return ${clientName}(${clientParams.toCall()})
105
+ },
106
+ })
107
+ `}
108
+ </Function>
109
+ </File.Source>
110
+ )
111
+ }
112
+
113
+ MutationOptions.getParams = getParams
@@ -1,8 +1,9 @@
1
+ export { InfiniteQuery } from './InfiniteQuery.tsx'
2
+ export { InfiniteQueryOptions } from './InfiniteQueryOptions.tsx'
1
3
  export { Mutation } from './Mutation.tsx'
4
+ export { MutationKey } from './MutationKey.tsx'
5
+ export { MutationOptions } from './MutationOptions.tsx'
2
6
  export { Query } from './Query.tsx'
3
7
  export { QueryKey } from './QueryKey.tsx'
4
- export { MutationKey } from './MutationKey.tsx'
5
8
  export { QueryOptions } from './QueryOptions.tsx'
6
- export { InfiniteQueryOptions } from './InfiniteQueryOptions.tsx'
7
- export { InfiniteQuery } from './InfiniteQuery.tsx'
8
9
  export { SuspenseQuery } from './SuspenseQuery.tsx'
@@ -5,7 +5,7 @@
5
5
  import fetch from 'axios'
6
6
  import type { UseMutationOptions, QueryClient } from '@tanstack/react-query'
7
7
  import type { RequestConfig, ResponseErrorConfig } from 'axios'
8
- import { useMutation } from '@tanstack/react-query'
8
+ import { mutationOptions, useMutation } from '@tanstack/react-query'
9
9
 
10
10
  export const updatePetWithFormMutationKey = () => [{ url: '/pet/:pet_id' }] as const
11
11
 
@@ -35,6 +35,21 @@ export async function updatePetWithForm(
35
35
  return updatePetWithFormMutationResponse.parse(res.data)
36
36
  }
37
37
 
38
+ export function updatePetWithFormMutationOptions(config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: typeof fetch } = {}) {
39
+ const mutationKey = updatePetWithFormMutationKey()
40
+ return mutationOptions<
41
+ UpdatePetWithFormMutationResponse,
42
+ ResponseErrorConfig<UpdatePetWithForm405>,
43
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams },
44
+ typeof mutationKey
45
+ >({
46
+ mutationKey,
47
+ mutationFn: async ({ petId, data, params }) => {
48
+ return updatePetWithForm(petId, data, params, config)
49
+ },
50
+ })
51
+ }
52
+
38
53
  /**
39
54
  * @summary Updates a pet in the store with form data
40
55
  * {@link /pet/:pet_id}
@@ -54,19 +69,17 @@ export function useUpdatePetWithForm<TContext>(
54
69
  const { client: queryClient, ...mutationOptions } = mutation
55
70
  const mutationKey = mutationOptions.mutationKey ?? updatePetWithFormMutationKey()
56
71
 
57
- return useMutation<
58
- UpdatePetWithFormMutationResponse,
59
- ResponseErrorConfig<UpdatePetWithForm405>,
60
- { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams },
61
- TContext
62
- >(
72
+ return useMutation(
63
73
  {
64
- mutationFn: async ({ petId, data, params }) => {
65
- return updatePetWithForm(petId, data, params, config)
66
- },
74
+ ...updatePetWithFormMutationOptions(config),
67
75
  mutationKey,
68
76
  ...mutationOptions,
69
- },
77
+ } as unknown as UseMutationOptions,
70
78
  queryClient,
71
- )
79
+ ) as UseMutationOptions<
80
+ UpdatePetWithFormMutationResponse,
81
+ ResponseErrorConfig<UpdatePetWithForm405>,
82
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams },
83
+ TContext
84
+ >
72
85
  }