@kubb/plugin-react-query 4.27.3 → 4.28.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.
- package/dist/{components-4AuOG0-B.cjs → components-Bud7cJEj.cjs} +17 -7
- package/dist/components-Bud7cJEj.cjs.map +1 -0
- package/dist/{components-B1qUEUDQ.js → components-DcRvg3r2.js} +17 -7
- package/dist/components-DcRvg3r2.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-OMqW9ebl.js → generators-D9wuuYX2.js} +2 -2
- package/dist/{generators-OMqW9ebl.js.map → generators-D9wuuYX2.js.map} +1 -1
- package/dist/{generators-D1_YChnq.cjs → generators-FaoMN0Iz.cjs} +2 -2
- package/dist/{generators-D1_YChnq.cjs.map → generators-FaoMN0Iz.cjs.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +1 -0
- package/dist/generators.d.ts +2 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +7 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/InfiniteQueryOptions.tsx +6 -2
- package/src/components/QueryOptions.tsx +3 -1
- package/src/components/SuspenseInfiniteQueryOptions.tsx +6 -2
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +3 -1
- package/src/generators/__snapshots__/clientGetImportPath.ts +3 -1
- package/src/generators/__snapshots__/createUsersWithListInputAsQuery.ts +3 -1
- package/src/generators/__snapshots__/findByStatusAllOptional.ts +3 -1
- package/src/generators/__snapshots__/findByStatusAllOptionalInline.ts +3 -1
- package/src/generators/__snapshots__/findByTags.ts +3 -1
- package/src/generators/__snapshots__/findByTagsObject.ts +3 -1
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +3 -1
- package/src/generators/__snapshots__/findByTagsTemplateString.ts +3 -1
- package/src/generators/__snapshots__/findByTagsWithCustomOptions.ts +3 -1
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +3 -1
- package/src/generators/__snapshots__/findByTagsWithZod.ts +3 -1
- package/src/generators/__snapshots__/findInfiniteByStatusAllOptional.ts +3 -1
- package/src/generators/__snapshots__/findInfiniteByTags.ts +3 -1
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +3 -1
- package/src/generators/__snapshots__/findInfiniteByTagsNextAndPreviousParam.ts +3 -1
- package/src/generators/__snapshots__/findInfiniteByTagsNextParam.ts +3 -1
- package/src/generators/__snapshots__/findInfiniteByTagsWithCustomOptions.ts +3 -1
- package/src/generators/__snapshots__/findSuspenseByStatusAllOptional.ts +3 -1
- package/src/generators/__snapshots__/findSuspenseByTags.ts +3 -1
- package/src/generators/__snapshots__/findSuspenseByTagsWithCustomOptions.ts +3 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByStatusAllOptional.ts +3 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByTags.ts +3 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByTagsCursor.ts +3 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByTagsWithCustomOptions.ts +3 -1
- package/src/generators/__snapshots__/getPetIdCamelCase.ts +3 -1
- package/src/generators/__snapshots__/postAsQuery.ts +3 -1
- package/src/generators/__snapshots__/requiredOneOfRequestBody.ts +94 -0
- package/src/generators/__snapshots__/requiredOneOfRequestBodyWithClientPlugin.ts +71 -0
- package/src/plugin.ts +5 -5
- package/dist/components-4AuOG0-B.cjs.map +0 -1
- package/dist/components-B1qUEUDQ.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport {\n customHookOptionsFileGenerator,\n hookOptionsGenerator,\n infiniteQueryGenerator,\n mutationGenerator,\n queryGenerator,\n suspenseInfiniteQueryGenerator,\n suspenseQueryGenerator,\n} from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n generators = [\n queryGenerator,\n suspenseQueryGenerator,\n infiniteQueryGenerator,\n suspenseInfiniteQueryGenerator,\n mutationGenerator,\n hookOptionsGenerator,\n customHookOptionsFileGenerator,\n ].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n customOptions,\n paramsCasing,\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n paramsCasing,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n customOptions: customOptions ? { name: 'useCustomHookOptions', ...customOptions } : undefined,\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.upsertFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAa,uBAAuB;AAEpC,MAAa,mBAAmB,cAAgC,YAAY;CAC1E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,WAAW,EAAE,EACb,WAAW,OACX,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,OAAO,QAAQ,EACjB,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cAAc,YAAY,gBAC1B,WAAW,SAAS,gBACpB,eACA,cACA,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,m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SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;GAgBJ,MAAM,QAAQ,MAba,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","fetchClientSource","axiosClientSource","configSource"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport {\n customHookOptionsFileGenerator,\n hookOptionsGenerator,\n infiniteQueryGenerator,\n mutationGenerator,\n queryGenerator,\n suspenseInfiniteQueryGenerator,\n suspenseQueryGenerator,\n} from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n generators = [\n queryGenerator,\n suspenseQueryGenerator,\n infiniteQueryGenerator,\n suspenseInfiniteQueryGenerator,\n mutationGenerator,\n hookOptionsGenerator,\n customHookOptionsFileGenerator,\n ].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n customOptions,\n paramsCasing,\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n paramsCasing,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n customOptions: customOptions ? { name: 'useCustomHookOptions', ...customOptions } : undefined,\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.upsertFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAa,uBAAuB;AAEpC,MAAa,mBAAmB,cAAgC,YAAY;CAC1E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,WAAW,EAAE,EACb,WAAW,OACX,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,OAAO,QAAQ,EACjB,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cAAc,YAAY,gBAC1B,WAAW,SAAS,gBACpB,eACA,cACA,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe;AAEhH,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,QAAQ;IACN,QAAQ,QAAQ;IAChB,SAAS,QAAQ;IACjB,QAAQ;IACR,YAAY,QAAQ,cAAc;IAClC,gBAAgB,QAAQ,kBAAkB;IAC1C;IACA,YAAY;IACZ;IACD;GACD,UAAU,WACN;IACE,YAAY;IACZ,kBAAkB;IAClB,aAAa;IACb,WAAW;IACX,eAAe;IACf,GAAG;IACJ,GACD;GACJ;GACA;GACA,OACE,UAAU,QACN,QACA;IACE,SAAS,CAAC,MAAM;IAChB,YAAY;IACZ,GAAG;IACJ;GACP;GACA,UACE,aAAa,QACT,QACA;IACE,SAAS;KAAC;KAAQ;KAAO;KAAS;KAAS;IA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ubb/plugin-react-query",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.28.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",
|
|
@@ -74,12 +74,12 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@kubb/react-fabric": "0.12.11",
|
|
76
76
|
"remeda": "^2.33.6",
|
|
77
|
-
"@kubb/core": "4.
|
|
78
|
-
"@kubb/oas": "4.
|
|
79
|
-
"@kubb/plugin-client": "4.
|
|
80
|
-
"@kubb/plugin-oas": "4.
|
|
81
|
-
"@kubb/plugin-ts": "4.
|
|
82
|
-
"@kubb/plugin-zod": "4.
|
|
77
|
+
"@kubb/core": "4.28.0",
|
|
78
|
+
"@kubb/oas": "4.28.0",
|
|
79
|
+
"@kubb/plugin-client": "4.28.0",
|
|
80
|
+
"@kubb/plugin-oas": "4.28.0",
|
|
81
|
+
"@kubb/plugin-ts": "4.28.0",
|
|
82
|
+
"@kubb/plugin-zod": "4.28.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@kubb/react-fabric": "0.12.11"
|
|
@@ -240,7 +240,9 @@ export function InfiniteQueryOptions({
|
|
|
240
240
|
${enabledText}
|
|
241
241
|
queryKey,
|
|
242
242
|
queryFn: async ({ signal, pageParam }) => {
|
|
243
|
-
config.signal
|
|
243
|
+
if (!config.signal) {
|
|
244
|
+
config.signal = signal
|
|
245
|
+
}
|
|
244
246
|
${infiniteOverrideParams}
|
|
245
247
|
return ${clientName}(${clientParams.toCall()})
|
|
246
248
|
},
|
|
@@ -261,7 +263,9 @@ export function InfiniteQueryOptions({
|
|
|
261
263
|
${enabledText}
|
|
262
264
|
queryKey,
|
|
263
265
|
queryFn: async ({ signal }) => {
|
|
264
|
-
config.signal
|
|
266
|
+
if (!config.signal) {
|
|
267
|
+
config.signal = signal
|
|
268
|
+
}
|
|
265
269
|
return ${clientName}(${clientParams.toCall()})
|
|
266
270
|
},
|
|
267
271
|
${queryOptions.join(',\n')}
|
|
@@ -161,7 +161,9 @@ export function QueryOptions({
|
|
|
161
161
|
${enabledText}
|
|
162
162
|
queryKey,
|
|
163
163
|
queryFn: async ({ signal }) => {
|
|
164
|
-
config.signal
|
|
164
|
+
if (!config.signal) {
|
|
165
|
+
config.signal = signal
|
|
166
|
+
}
|
|
165
167
|
return ${clientName}(${clientParams.toCall({})})
|
|
166
168
|
},
|
|
167
169
|
})
|
|
@@ -240,7 +240,9 @@ export function SuspenseInfiniteQueryOptions({
|
|
|
240
240
|
${enabledText}
|
|
241
241
|
queryKey,
|
|
242
242
|
queryFn: async ({ signal, pageParam }) => {
|
|
243
|
-
config.signal
|
|
243
|
+
if (!config.signal) {
|
|
244
|
+
config.signal = signal
|
|
245
|
+
}
|
|
244
246
|
${infiniteOverrideParams}
|
|
245
247
|
return ${clientName}(${clientParams.toCall()})
|
|
246
248
|
},
|
|
@@ -261,7 +263,9 @@ export function SuspenseInfiniteQueryOptions({
|
|
|
261
263
|
${enabledText}
|
|
262
264
|
queryKey,
|
|
263
265
|
queryFn: async ({ signal }) => {
|
|
264
|
-
config.signal
|
|
266
|
+
if (!config.signal) {
|
|
267
|
+
config.signal = signal
|
|
268
|
+
}
|
|
265
269
|
return ${clientName}(${clientParams.toCall()})
|
|
266
270
|
},
|
|
267
271
|
${queryOptions.join(',\n')}
|
|
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
|
|
|
42
42
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
43
43
|
queryKey,
|
|
44
44
|
queryFn: async ({ signal }) => {
|
|
45
|
-
config.signal
|
|
45
|
+
if (!config.signal) {
|
|
46
|
+
config.signal = signal
|
|
47
|
+
}
|
|
46
48
|
return findPetsByTags(headers, params, config)
|
|
47
49
|
},
|
|
48
50
|
})
|
|
@@ -42,7 +42,9 @@ export function createUsersWithListInputQueryOptions(
|
|
|
42
42
|
return queryOptions<CreateUsersWithListInputMutationResponse, ResponseErrorConfig<Error>, CreateUsersWithListInputMutationResponse, typeof queryKey>({
|
|
43
43
|
queryKey,
|
|
44
44
|
queryFn: async ({ signal }) => {
|
|
45
|
-
config.signal
|
|
45
|
+
if (!config.signal) {
|
|
46
|
+
config.signal = signal
|
|
47
|
+
}
|
|
46
48
|
return createUsersWithListInput(data, config)
|
|
47
49
|
},
|
|
48
50
|
})
|
|
@@ -36,7 +36,9 @@ export function findPetsByStatusQueryOptions(
|
|
|
36
36
|
return queryOptions<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, FindPetsByStatusQueryResponse, typeof queryKey>({
|
|
37
37
|
queryKey,
|
|
38
38
|
queryFn: async ({ signal }) => {
|
|
39
|
-
config.signal
|
|
39
|
+
if (!config.signal) {
|
|
40
|
+
config.signal = signal
|
|
41
|
+
}
|
|
40
42
|
return findPetsByStatus({ params }, config)
|
|
41
43
|
},
|
|
42
44
|
})
|
|
@@ -33,7 +33,9 @@ export function findPetsByStatusQueryOptions(params?: FindPetsByStatusQueryParam
|
|
|
33
33
|
return queryOptions<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, FindPetsByStatusQueryResponse, typeof queryKey>({
|
|
34
34
|
queryKey,
|
|
35
35
|
queryFn: async ({ signal }) => {
|
|
36
|
-
config.signal
|
|
36
|
+
if (!config.signal) {
|
|
37
|
+
config.signal = signal
|
|
38
|
+
}
|
|
37
39
|
return findPetsByStatus(params, config)
|
|
38
40
|
},
|
|
39
41
|
})
|
|
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
|
|
|
42
42
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
43
43
|
queryKey,
|
|
44
44
|
queryFn: async ({ signal }) => {
|
|
45
|
-
config.signal
|
|
45
|
+
if (!config.signal) {
|
|
46
|
+
config.signal = signal
|
|
47
|
+
}
|
|
46
48
|
return findPetsByTags(headers, params, config)
|
|
47
49
|
},
|
|
48
50
|
})
|
|
@@ -40,7 +40,9 @@ export function findPetsByTagsQueryOptions(
|
|
|
40
40
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
41
41
|
queryKey,
|
|
42
42
|
queryFn: async ({ signal }) => {
|
|
43
|
-
config.signal
|
|
43
|
+
if (!config.signal) {
|
|
44
|
+
config.signal = signal
|
|
45
|
+
}
|
|
44
46
|
return findPetsByTags({ headers, params }, config)
|
|
45
47
|
},
|
|
46
48
|
})
|
|
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
|
|
|
42
42
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
43
43
|
queryKey,
|
|
44
44
|
queryFn: async ({ signal }) => {
|
|
45
|
-
config.signal
|
|
45
|
+
if (!config.signal) {
|
|
46
|
+
config.signal = signal
|
|
47
|
+
}
|
|
46
48
|
return findPetsByTags(headers, params, config)
|
|
47
49
|
},
|
|
48
50
|
})
|
|
@@ -43,7 +43,9 @@ export function findPetsByTagsQueryOptions(
|
|
|
43
43
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
44
44
|
queryKey,
|
|
45
45
|
queryFn: async ({ signal }) => {
|
|
46
|
-
config.signal
|
|
46
|
+
if (!config.signal) {
|
|
47
|
+
config.signal = signal
|
|
48
|
+
}
|
|
47
49
|
return findPetsByTags(headers, params, config)
|
|
48
50
|
},
|
|
49
51
|
})
|
|
@@ -43,7 +43,9 @@ export function findPetsByTagsQueryOptions(
|
|
|
43
43
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
44
44
|
queryKey,
|
|
45
45
|
queryFn: async ({ signal }) => {
|
|
46
|
-
config.signal
|
|
46
|
+
if (!config.signal) {
|
|
47
|
+
config.signal = signal
|
|
48
|
+
}
|
|
47
49
|
return findPetsByTags(headers, params, config)
|
|
48
50
|
},
|
|
49
51
|
})
|
|
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
|
|
|
42
42
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
43
43
|
queryKey,
|
|
44
44
|
queryFn: async ({ signal }) => {
|
|
45
|
-
config.signal
|
|
45
|
+
if (!config.signal) {
|
|
46
|
+
config.signal = signal
|
|
47
|
+
}
|
|
46
48
|
return findPetsByTags(headers, params, config)
|
|
47
49
|
},
|
|
48
50
|
})
|
|
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
|
|
|
42
42
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
43
43
|
queryKey,
|
|
44
44
|
queryFn: async ({ signal }) => {
|
|
45
|
-
config.signal
|
|
45
|
+
if (!config.signal) {
|
|
46
|
+
config.signal = signal
|
|
47
|
+
}
|
|
46
48
|
return findPetsByTags(headers, params, config)
|
|
47
49
|
},
|
|
48
50
|
})
|
|
@@ -40,7 +40,9 @@ export function findPetsByStatusSuspenseQueryOptions(
|
|
|
40
40
|
return queryOptions<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, FindPetsByStatusQueryResponse, typeof queryKey>({
|
|
41
41
|
queryKey,
|
|
42
42
|
queryFn: async ({ signal }) => {
|
|
43
|
-
config.signal
|
|
43
|
+
if (!config.signal) {
|
|
44
|
+
config.signal = signal
|
|
45
|
+
}
|
|
44
46
|
return findPetsByStatusSuspense({ params }, config)
|
|
45
47
|
},
|
|
46
48
|
})
|
|
@@ -42,7 +42,9 @@ export function findPetsByTagsSuspenseQueryOptions(
|
|
|
42
42
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
43
43
|
queryKey,
|
|
44
44
|
queryFn: async ({ signal }) => {
|
|
45
|
-
config.signal
|
|
45
|
+
if (!config.signal) {
|
|
46
|
+
config.signal = signal
|
|
47
|
+
}
|
|
46
48
|
return findPetsByTagsSuspense(headers, params, config)
|
|
47
49
|
},
|
|
48
50
|
})
|
|
@@ -43,7 +43,9 @@ export function findPetsByTagsSuspenseQueryOptions(
|
|
|
43
43
|
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
44
44
|
queryKey,
|
|
45
45
|
queryFn: async ({ signal }) => {
|
|
46
|
-
config.signal
|
|
46
|
+
if (!config.signal) {
|
|
47
|
+
config.signal = signal
|
|
48
|
+
}
|
|
47
49
|
return findPetsByTagsSuspense(headers, params, config)
|
|
48
50
|
},
|
|
49
51
|
})
|
|
@@ -35,7 +35,9 @@ export function getPetByIdQueryOptions(petId: GetPetByIdPathParams['petId'], con
|
|
|
35
35
|
enabled: !!petId,
|
|
36
36
|
queryKey,
|
|
37
37
|
queryFn: async ({ signal }) => {
|
|
38
|
-
config.signal
|
|
38
|
+
if (!config.signal) {
|
|
39
|
+
config.signal = signal
|
|
40
|
+
}
|
|
39
41
|
return getPetById(petId, config)
|
|
40
42
|
},
|
|
41
43
|
})
|
|
@@ -50,7 +50,9 @@ export function updatePetWithFormQueryOptions(
|
|
|
50
50
|
enabled: !!petId,
|
|
51
51
|
queryKey,
|
|
52
52
|
queryFn: async ({ signal }) => {
|
|
53
|
-
config.signal
|
|
53
|
+
if (!config.signal) {
|
|
54
|
+
config.signal = signal
|
|
55
|
+
}
|
|
54
56
|
return updatePetWithForm(petId, data, params, config)
|
|
55
57
|
},
|
|
56
58
|
})
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { Client, RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
6
|
+
import type { UseMutationOptions, UseMutationResult, QueryClient } from '@tanstack/react-query'
|
|
7
|
+
import { fetch } from './test/.kubb/fetch'
|
|
8
|
+
import { mutationOptions, useMutation } from '@tanstack/react-query'
|
|
9
|
+
|
|
10
|
+
export const createOrderMutationKey = () => [{ url: '/orders' }] as const
|
|
11
|
+
|
|
12
|
+
export type CreateOrderMutationKey = ReturnType<typeof createOrderMutationKey>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* {@link /orders}
|
|
16
|
+
*/
|
|
17
|
+
export async function createOrder(
|
|
18
|
+
data: CreateOrderMutationRequest,
|
|
19
|
+
headers?: CreateOrderHeaderParams,
|
|
20
|
+
config: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client } = {},
|
|
21
|
+
) {
|
|
22
|
+
const { client: request = fetch, ...requestConfig } = config
|
|
23
|
+
|
|
24
|
+
const requestData = createOrderMutationRequest.parse(data)
|
|
25
|
+
|
|
26
|
+
const res = await request<CreateOrderMutationResponse, ResponseErrorConfig<Error>, CreateOrderMutationRequest>({
|
|
27
|
+
method: 'POST',
|
|
28
|
+
url: `/orders`,
|
|
29
|
+
data: requestData,
|
|
30
|
+
...requestConfig,
|
|
31
|
+
headers: { ...headers, ...requestConfig.headers },
|
|
32
|
+
})
|
|
33
|
+
return createOrderMutationResponse.parse(res.data)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function createOrderMutationOptions<TContext = unknown>(config: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client } = {}) {
|
|
37
|
+
const mutationKey = createOrderMutationKey()
|
|
38
|
+
return mutationOptions<
|
|
39
|
+
CreateOrderMutationResponse,
|
|
40
|
+
ResponseErrorConfig<Error>,
|
|
41
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
42
|
+
TContext
|
|
43
|
+
>({
|
|
44
|
+
mutationKey,
|
|
45
|
+
mutationFn: async ({ data, headers }) => {
|
|
46
|
+
return createOrder(data, headers, config)
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* {@link /orders}
|
|
53
|
+
*/
|
|
54
|
+
export function useCreateOrder<TContext>(
|
|
55
|
+
options: {
|
|
56
|
+
mutation?: UseMutationOptions<
|
|
57
|
+
CreateOrderMutationResponse,
|
|
58
|
+
ResponseErrorConfig<Error>,
|
|
59
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
60
|
+
TContext
|
|
61
|
+
> & { client?: QueryClient }
|
|
62
|
+
client?: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client }
|
|
63
|
+
} = {},
|
|
64
|
+
) {
|
|
65
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
66
|
+
const { client: queryClient, ...mutationOptions } = mutation
|
|
67
|
+
const mutationKey = mutationOptions.mutationKey ?? createOrderMutationKey()
|
|
68
|
+
|
|
69
|
+
const baseOptions = createOrderMutationOptions(config) as UseMutationOptions<
|
|
70
|
+
CreateOrderMutationResponse,
|
|
71
|
+
ResponseErrorConfig<Error>,
|
|
72
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
73
|
+
TContext
|
|
74
|
+
>
|
|
75
|
+
|
|
76
|
+
return useMutation<
|
|
77
|
+
CreateOrderMutationResponse,
|
|
78
|
+
ResponseErrorConfig<Error>,
|
|
79
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
80
|
+
TContext
|
|
81
|
+
>(
|
|
82
|
+
{
|
|
83
|
+
...baseOptions,
|
|
84
|
+
mutationKey,
|
|
85
|
+
...mutationOptions,
|
|
86
|
+
},
|
|
87
|
+
queryClient,
|
|
88
|
+
) as UseMutationResult<
|
|
89
|
+
CreateOrderMutationResponse,
|
|
90
|
+
ResponseErrorConfig<Error>,
|
|
91
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
92
|
+
TContext
|
|
93
|
+
>
|
|
94
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { Client, RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
6
|
+
import type { UseMutationOptions, UseMutationResult, QueryClient } from '@tanstack/react-query'
|
|
7
|
+
import { mutationOptions, useMutation } from '@tanstack/react-query'
|
|
8
|
+
|
|
9
|
+
export const createOrderMutationKey = () => [{ url: '/orders' }] as const
|
|
10
|
+
|
|
11
|
+
export type CreateOrderMutationKey = ReturnType<typeof createOrderMutationKey>
|
|
12
|
+
|
|
13
|
+
export function createOrderMutationOptions<TContext = unknown>(config: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client } = {}) {
|
|
14
|
+
const mutationKey = createOrderMutationKey()
|
|
15
|
+
return mutationOptions<
|
|
16
|
+
CreateOrderMutationResponse,
|
|
17
|
+
ResponseErrorConfig<Error>,
|
|
18
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
19
|
+
TContext
|
|
20
|
+
>({
|
|
21
|
+
mutationKey,
|
|
22
|
+
mutationFn: async ({ data, headers }) => {
|
|
23
|
+
return createOrder(data, headers, config)
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* {@link /orders}
|
|
30
|
+
*/
|
|
31
|
+
export function useCreateOrder<TContext>(
|
|
32
|
+
options: {
|
|
33
|
+
mutation?: UseMutationOptions<
|
|
34
|
+
CreateOrderMutationResponse,
|
|
35
|
+
ResponseErrorConfig<Error>,
|
|
36
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
37
|
+
TContext
|
|
38
|
+
> & { client?: QueryClient }
|
|
39
|
+
client?: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client }
|
|
40
|
+
} = {},
|
|
41
|
+
) {
|
|
42
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
43
|
+
const { client: queryClient, ...mutationOptions } = mutation
|
|
44
|
+
const mutationKey = mutationOptions.mutationKey ?? createOrderMutationKey()
|
|
45
|
+
|
|
46
|
+
const baseOptions = createOrderMutationOptions(config) as UseMutationOptions<
|
|
47
|
+
CreateOrderMutationResponse,
|
|
48
|
+
ResponseErrorConfig<Error>,
|
|
49
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
50
|
+
TContext
|
|
51
|
+
>
|
|
52
|
+
|
|
53
|
+
return useMutation<
|
|
54
|
+
CreateOrderMutationResponse,
|
|
55
|
+
ResponseErrorConfig<Error>,
|
|
56
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
57
|
+
TContext
|
|
58
|
+
>(
|
|
59
|
+
{
|
|
60
|
+
...baseOptions,
|
|
61
|
+
mutationKey,
|
|
62
|
+
...mutationOptions,
|
|
63
|
+
},
|
|
64
|
+
queryClient,
|
|
65
|
+
) as UseMutationResult<
|
|
66
|
+
CreateOrderMutationResponse,
|
|
67
|
+
ResponseErrorConfig<Error>,
|
|
68
|
+
{ data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
|
|
69
|
+
TContext
|
|
70
|
+
>
|
|
71
|
+
}
|