@kubb/plugin-react-query 3.0.0-alpha.4 → 3.0.0-alpha.6

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 (41) hide show
  1. package/dist/{chunk-JFX7DCS7.cjs → chunk-GTVJ55F2.cjs} +116 -150
  2. package/dist/chunk-GTVJ55F2.cjs.map +1 -0
  3. package/dist/{chunk-5IL6M74X.js → chunk-IVMTW4XS.js} +168 -202
  4. package/dist/chunk-IVMTW4XS.js.map +1 -0
  5. package/dist/components.cjs +2 -4
  6. package/dist/components.cjs.map +1 -1
  7. package/dist/components.d.cts +1 -2
  8. package/dist/components.d.ts +1 -2
  9. package/dist/components.js +1 -3
  10. package/dist/{index-C9fwRDH7.d.cts → index-5kpkk-7M.d.cts} +7 -41
  11. package/dist/{index-C9fwRDH7.d.ts → index-5kpkk-7M.d.ts} +7 -41
  12. package/dist/index.cjs +19 -59
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +1 -2
  15. package/dist/index.d.ts +1 -2
  16. package/dist/index.js +7 -47
  17. package/dist/index.js.map +1 -1
  18. package/package.json +14 -14
  19. package/src/OperationGenerator.tsx +0 -29
  20. package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +11 -6
  21. package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +11 -6
  22. package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +11 -6
  23. package/src/__snapshots__/queryOptions/getPetById.ts +9 -5
  24. package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +9 -5
  25. package/src/__snapshots__/upload/UploadFile.ts +11 -6
  26. package/src/__snapshots__/uploadMutation/UploadFile.ts +9 -5
  27. package/src/__snapshots__/variablesTypeMutate/deletePet.ts +7 -4
  28. package/src/components/Mutation.tsx +30 -30
  29. package/src/components/Query.tsx +74 -78
  30. package/src/components/QueryKey.tsx +11 -8
  31. package/src/components/QueryOptions.tsx +21 -13
  32. package/src/components/SchemaType.tsx +9 -5
  33. package/src/components/__snapshots__/gen/showPetById.ts +58 -48
  34. package/src/components/__snapshots__/gen/useCreatePets.ts +36 -36
  35. package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +36 -37
  36. package/src/components/index.ts +0 -1
  37. package/src/plugin.ts +8 -29
  38. package/src/types.ts +0 -3
  39. package/dist/chunk-5IL6M74X.js.map +0 -1
  40. package/dist/chunk-JFX7DCS7.cjs.map +0 -1
  41. package/src/components/Operations.tsx +0 -74
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-react-query/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACTA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAAsC;AACtC,yCAA+B;AAC/B,6CAA8B;AAC9B,gDAAqC;AACrC,2CAA6B;AAC7B,6CAA8B;ADU9B;AACA;AEnBA;AACA,yDAAoB;AACpB,oCAAgC;AAkCG,qDAAA;AArB5B,IAAM,mBAAA,EAAN,MAAA,QAAiC,8BAA2E;AAAA,EACjH,MAAM,GAAA,CAAI,UAAA,EAA0D;AAClE,IAAA,MAAM,EAAE,aAAA,EAAe,GAAA,EAAK,MAAA,EAAQ,KAAK,EAAA,EAAI,IAAA,CAAK,OAAA;AAElD,IAAA,MAAM,KAAA,EAAO,+BAAA;AAAW,MACtB,MAAA,EAAQ,aAAA,CAAc;AAAA,IACxB,CAAC,CAAA;AAED,IAAA,MAAM,UAAA,EAAY;AAAA,MAChB,QAAA,EAAU,0BAAA,CAAS,SAAA;AAAA,MACnB,KAAA,EAAO,uBAAA,CAAM,SAAA;AAAA,MACb,YAAA,EAAc,8BAAA,CAAa,SAAA;AAAA,MAC3B,QAAA,EAAU,0BAAA,CAAS,SAAA;AAAA,MACnB,YAAA,EAAc,8BAAA,CAAa,SAAA;AAAA,MAC3B,UAAA,EAAY,4BAAA,CAAW,SAA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MAAA;AAEW,MAAA;AACX,QAAA;AACrB,UAAA;AACS,UAAA;AAClB,QAAA;AACH,MAAA;AACqB,MAAA;AACW,QAAA;AAChC,MAAA;AAEU,MAAA;AACkC,QAAA;AAC5C,MAAA;AAEO,MAAA;AACT,IAAA;AACmB,IAAA;AAC0C,MAAA;AAEnB,MAAA;AACI,MAAA;AACN,MAAA;AAEP,MAAA;AAC7B,QAAA;AACoB,QAAA;AACP,QAAA;AACsB,QAAA;AACnC,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AAE4C,MAAA;AAClB,MAAA;AAEY,MAAA;AACb,QAAA;AACT,UAAA;AACW,UAAA;AACX,UAAA;AACb,UAAA;AAC4B,UAAA;AAC5B,UAAA;AACA,UAAA;AACD,QAAA;AAE8B,QAAA;AACjC,MAAA;AACF,IAAA;AACiB,IAAA;AACyB,MAAA;AACtC,QAAA;AACF,MAAA;AAE4C,MAAA;AACP,MAAA;AACnC,QAAA;AACA,QAAA;AACmC,QAAA;AACtB,QAAA;AACd,MAAA;AAEmC,MAAA;AACrB,QAAA;AACb,QAAA;AACD,MAAA;AACH,IAAA;AACF,EAAA;AACD;ADqCkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-react-query/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Operations, Query, QueryKey, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser,\n suspense = {},\n infinite,\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n mutate = {},\n query = {},\n queryOptions = {},\n templates,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginReactQueryName,\n options: {\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n pathParamsType,\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n query: query\n ? {\n queryKey: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n }\n : false,\n queryOptions,\n mutate: mutate\n ? {\n variablesType: 'hook',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutate,\n }\n : false,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n operations: Operations.templates,\n ...templates,\n },\n parser,\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 ?? FileManager.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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 prefix: 'use',\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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n\n if (this.config.output.write && group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Hooks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const files = await this.fileManager.getIndexFiles({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n\n await this.fileManager.processFiles({\n logger: this.logger,\n files,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Operations } from './components/Operations.tsx'\nimport { Query } from './components/Query.tsx'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { QueryOptions } from './components/QueryOptions.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { FileMeta, PluginReactQuery } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginReactQuery['resolvedOptions'], PluginReactQuery, FileMeta> {\n async all(operations: Operation[]): OperationMethodResult<FileMeta> {\n const { pluginManager, oas, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n operations: Operations.templates,\n ...this.options.templates,\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={this}>\n {templates.operations && <Operations.File templates={templates.operations} />}\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async operation(operation: Operation, options: PluginReactQuery['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n ...options.templates,\n }\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutate = !isQuery && options.mutate && options.mutate.methods.some((method) => operation.method === method)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n {isMutate && templates?.mutation && <Mutation.File templates={templates.mutation} />}\n {isQuery && templates?.query && templates.queryKey && templates.queryOptions && templates.queryImports && (\n <Query.File\n templates={{\n query: templates.query,\n queryKey: templates.queryKey,\n queryOptions: templates.queryOptions,\n queryImports: templates.queryImports,\n }}\n />\n )}\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-react-query/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx"],"names":[],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AA;AAEnB,MAAA;AACI,MAAA;AACN,MAAA;AAEP,MAAA;AAC7B,QAAA;AACoB,QAAA;AACP,QAAA;AACsB,QAAA;AACnC,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AAE4C,MAAA;AAClB,MAAA;AAEG,MAAA;AACc,QAAA;AACxC,UAAA;AACA,UAAA;AACwB,UAAA;AACX,UAAA;AACA,UAAA;AACd,QAAA;AAE+B,QAAA;AAClC,MAAA;AACF,IAAA;AACF,EAAA;AACD;ADkBkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-react-query/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Query, QueryKey, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser,\n suspense = {},\n infinite,\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n mutate = {},\n query = {},\n queryOptions = {},\n templates,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginReactQueryName,\n options: {\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n pathParamsType,\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n query: query\n ? {\n queryKey: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n }\n : false,\n queryOptions,\n mutate: mutate\n ? {\n variablesType: 'hook',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutate,\n }\n : false,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n ...templates,\n },\n parser,\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 ?? FileManager.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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 prefix: 'use',\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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n\n if (this.config.output.write) {\n const indexFiles = await this.fileManager.getIndexFiles({\n root,\n output,\n files: this.fileManager.files,\n plugin: this.plugin,\n logger: this.logger,\n })\n\n await this.addFile(...indexFiles)\n }\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Query } from './components/Query.tsx'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { QueryOptions } from './components/QueryOptions.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { FileMeta, PluginReactQuery } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginReactQuery['resolvedOptions'], PluginReactQuery, FileMeta> {\n async operation(operation: Operation, options: PluginReactQuery['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n ...options.templates,\n }\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutate = !isQuery && options.mutate && options.mutate.methods.some((method) => operation.method === method)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n {isMutate && templates?.mutation && <Mutation.File templates={templates.mutation} />}\n {isQuery && templates?.query && templates.queryKey && templates.queryOptions && templates.queryImports && (\n <Query.File\n templates={{\n query: templates.query,\n queryKey: templates.queryKey,\n queryOptions: templates.queryOptions,\n queryImports: templates.queryImports,\n }}\n />\n )}\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,11 +1,10 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginReactQuery } from './index-C9fwRDH7.cjs';
2
+ import { O as Options, P as PluginReactQuery } from './index-5kpkk-7M.cjs';
3
3
  import '@kubb/core/utils';
4
4
  import '@kubb/oas';
5
5
  import 'react';
6
6
  import '@kubb/fs/types';
7
7
  import '@kubb/plugin-oas';
8
- import '@kubb/react';
9
8
 
10
9
  declare const pluginReactQueryName = "plugin-react-query";
11
10
  declare const pluginReactQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginReactQuery>;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginReactQuery } from './index-C9fwRDH7.js';
2
+ import { O as Options, P as PluginReactQuery } from './index-5kpkk-7M.js';
3
3
  import '@kubb/core/utils';
4
4
  import '@kubb/oas';
5
5
  import 'react';
6
6
  import '@kubb/fs/types';
7
7
  import '@kubb/plugin-oas';
8
- import '@kubb/react';
9
8
 
10
9
  declare const pluginReactQueryName = "plugin-react-query";
11
10
  declare const pluginReactQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginReactQuery>;
package/dist/index.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import {
2
2
  Mutation,
3
- Operations,
4
3
  Query,
5
4
  QueryImports,
6
5
  QueryKey,
7
6
  QueryOptions
8
- } from "./chunk-5IL6M74X.js";
7
+ } from "./chunk-IVMTW4XS.js";
9
8
 
10
9
  // src/plugin.ts
11
10
  import path from "path";
@@ -13,7 +12,6 @@ import { FileManager, PluginManager, createPlugin } from "@kubb/core";
13
12
  import { camelCase, pascalCase } from "@kubb/core/transformers";
14
13
  import { renderTemplate } from "@kubb/core/utils";
15
14
  import { pluginOasName } from "@kubb/plugin-oas";
16
- import { getGroupedByTagFiles } from "@kubb/plugin-oas/utils";
17
15
  import { pluginTsName } from "@kubb/plugin-ts";
18
16
  import { pluginZodName } from "@kubb/plugin-zod";
19
17
 
@@ -23,25 +21,6 @@ import { Oas } from "@kubb/plugin-oas/components";
23
21
  import { App, createRoot } from "@kubb/react";
24
22
  import { jsx, jsxs } from "@kubb/react/jsx-runtime";
25
23
  var OperationGenerator = class extends Generator {
26
- async all(operations) {
27
- const { pluginManager, oas, plugin, mode } = this.context;
28
- const root = createRoot({
29
- logger: pluginManager.logger
30
- });
31
- const templates = {
32
- mutation: Mutation.templates,
33
- query: Query.templates,
34
- queryOptions: QueryOptions.templates,
35
- queryKey: QueryKey.templates,
36
- queryImports: QueryImports.templates,
37
- operations: Operations.templates,
38
- ...this.options.templates
39
- };
40
- root.render(
41
- /* @__PURE__ */ jsx(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations, generator: this, children: templates.operations && /* @__PURE__ */ jsx(Operations.File, { templates: templates.operations }) }) })
42
- );
43
- return root.files;
44
- }
45
24
  async operation(operation, options) {
46
25
  const { oas, pluginManager, plugin, mode } = this.context;
47
26
  const root = createRoot({
@@ -132,7 +111,6 @@ var pluginReactQuery = createPlugin((options) => {
132
111
  queryOptions: QueryOptions.templates,
133
112
  queryKey: QueryKey.templates,
134
113
  queryImports: QueryImports.templates,
135
- operations: Operations.templates,
136
114
  ...templates
137
115
  },
138
116
  parser
@@ -183,34 +161,16 @@ var pluginReactQuery = createPlugin((options) => {
183
161
  });
184
162
  const files = await operationGenerator.build();
185
163
  await this.addFile(...files);
186
- if (this.config.output.write && group?.type === "tag") {
187
- const rootFiles = await getGroupedByTagFiles({
188
- logger: this.logger,
164
+ if (this.config.output.write) {
165
+ const indexFiles = await this.fileManager.getIndexFiles({
166
+ root,
167
+ output,
189
168
  files: this.fileManager.files,
190
169
  plugin: this.plugin,
191
- template,
192
- exportAs: group.exportAs || "{{tag}}Hooks",
193
- root,
194
- output
170
+ logger: this.logger
195
171
  });
196
- await this.addFile(...rootFiles);
172
+ await this.addFile(...indexFiles);
197
173
  }
198
- },
199
- async buildEnd() {
200
- if (this.config.output.write === false) {
201
- return;
202
- }
203
- const root = path.resolve(this.config.root, this.config.output.path);
204
- const files = await this.fileManager.getIndexFiles({
205
- root,
206
- output,
207
- meta: { pluginKey: this.plugin.key },
208
- logger: this.logger
209
- });
210
- await this.fileManager.processFiles({
211
- logger: this.logger,
212
- files
213
- });
214
174
  }
215
175
  };
216
176
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Operations, Query, QueryKey, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser,\n suspense = {},\n infinite,\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n mutate = {},\n query = {},\n queryOptions = {},\n templates,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginReactQueryName,\n options: {\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n pathParamsType,\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n query: query\n ? {\n queryKey: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n }\n : false,\n queryOptions,\n mutate: mutate\n ? {\n variablesType: 'hook',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutate,\n }\n : false,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n operations: Operations.templates,\n ...templates,\n },\n parser,\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 ?? FileManager.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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 prefix: 'use',\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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n\n if (this.config.output.write && group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Hooks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const files = await this.fileManager.getIndexFiles({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n\n await this.fileManager.processFiles({\n logger: this.logger,\n files,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Operations } from './components/Operations.tsx'\nimport { Query } from './components/Query.tsx'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { QueryOptions } from './components/QueryOptions.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { FileMeta, PluginReactQuery } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginReactQuery['resolvedOptions'], PluginReactQuery, FileMeta> {\n async all(operations: Operation[]): OperationMethodResult<FileMeta> {\n const { pluginManager, oas, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n operations: Operations.templates,\n ...this.options.templates,\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={this}>\n {templates.operations && <Operations.File templates={templates.operations} />}\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async operation(operation: Operation, options: PluginReactQuery['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n ...options.templates,\n }\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutate = !isQuery && options.mutate && options.mutate.methods.some((method) => operation.method === method)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n {isMutate && templates?.mutation && <Mutation.File templates={templates.mutation} />}\n {isQuery && templates?.query && templates.queryKey && templates.queryOptions && templates.queryImports && (\n <Query.File\n templates={{\n query: templates.query,\n queryKey: templates.queryKey,\n queryOptions: templates.queryOptions,\n queryImports: templates.queryImports,\n }}\n />\n )}\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;;;ACR9B,SAAS,sBAAsB,iBAAiB;AAChD,SAAS,WAAW;AACpB,SAAS,KAAK,kBAAkB;AAkCG,cA8BzB,YA9ByB;AArB5B,IAAM,qBAAN,cAAiC,UAA2E;AAAA,EACjH,MAAM,IAAI,YAA0D;AAClE,UAAM,EAAE,eAAe,KAAK,QAAQ,KAAK,IAAI,KAAK;AAElD,UAAM,OAAO,WAAW;AAAA,MACtB,QAAQ,cAAc;AAAA,IACxB,CAAC;AAED,UAAM,YAAY;AAAA,MAChB,UAA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":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Query, QueryKey, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser,\n suspense = {},\n infinite,\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n mutate = {},\n query = {},\n queryOptions = {},\n templates,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginReactQueryName,\n options: {\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n pathParamsType,\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n query: query\n ? {\n queryKey: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n }\n : false,\n queryOptions,\n mutate: mutate\n ? {\n variablesType: 'hook',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutate,\n }\n : false,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n ...templates,\n },\n parser,\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 ?? FileManager.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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 prefix: 'use',\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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n\n if (this.config.output.write) {\n const indexFiles = await this.fileManager.getIndexFiles({\n root,\n output,\n files: this.fileManager.files,\n plugin: this.plugin,\n logger: this.logger,\n })\n\n await this.addFile(...indexFiles)\n }\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Query } from './components/Query.tsx'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { QueryOptions } from './components/QueryOptions.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { FileMeta, PluginReactQuery } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginReactQuery['resolvedOptions'], PluginReactQuery, FileMeta> {\n async operation(operation: Operation, options: PluginReactQuery['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n ...options.templates,\n }\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutate = !isQuery && options.mutate && options.mutate.methods.some((method) => operation.method === method)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n {isMutate && templates?.mutation && <Mutation.File templates={templates.mutation} />}\n {isQuery && templates?.query && templates.queryKey && templates.queryOptions && templates.queryImports && (\n <Query.File\n templates={{\n query: templates.query,\n queryKey: templates.queryKey,\n queryOptions: templates.queryOptions,\n queryImports: templates.queryImports,\n }}\n />\n )}\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n"],"mappings":";;;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAE9B,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;;;ACR9B,SAAS,sBAAsB,iBAAiB;AAChD,SAAS,WAAW;AACpB,SAAS,KAAK,kBAAkB;AAmCtB,SACsC,KADtC;AAvBH,IAAM,qBAAN,cAAiC,UAA2E;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;AAED,YAAM,QAAQ,MAAM,mBAAmB,MAAM;AAC7C,YAAM,KAAK,QAAQ,GAAG,KAAK;AAE3B,UAAI,KAAK,OAAO,OAAO,OAAO;AAC5B,cAAM,aAAa,MAAM,KAAK,YAAY,cAAc;AAAA,UACtD;AAAA,UACA;AAAA,UACA,OAAO,KAAK,YAAY;AAAA,UACxB,QAAQ,KAAK;AAAA,UACb,QAAQ,KAAK;AAAA,QACf,CAAC;AAED,cAAM,KAAK,QAAQ,GAAG,UAAU;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["options"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-react-query",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.6",
4
4
  "description": "Generator react-query hooks",
5
5
  "keywords": [
6
6
  "faker",
@@ -54,27 +54,27 @@
54
54
  "!/**/__tests__/**"
55
55
  ],
56
56
  "dependencies": {
57
- "@kubb/core": "3.0.0-alpha.4",
58
- "@kubb/fs": "3.0.0-alpha.4",
59
- "@kubb/oas": "3.0.0-alpha.4",
60
- "@kubb/parser-ts": "3.0.0-alpha.4",
61
- "@kubb/plugin-faker": "3.0.0-alpha.4",
62
- "@kubb/plugin-oas": "3.0.0-alpha.4",
63
- "@kubb/plugin-ts": "3.0.0-alpha.4",
64
- "@kubb/plugin-zod": "3.0.0-alpha.4",
65
- "@kubb/react": "3.0.0-alpha.4"
57
+ "@kubb/core": "3.0.0-alpha.6",
58
+ "@kubb/fs": "3.0.0-alpha.6",
59
+ "@kubb/oas": "3.0.0-alpha.6",
60
+ "@kubb/parser-ts": "3.0.0-alpha.6",
61
+ "@kubb/plugin-faker": "3.0.0-alpha.6",
62
+ "@kubb/plugin-oas": "3.0.0-alpha.6",
63
+ "@kubb/plugin-ts": "3.0.0-alpha.6",
64
+ "@kubb/plugin-zod": "3.0.0-alpha.6",
65
+ "@kubb/react": "3.0.0-alpha.6"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/react": "^18.3.4",
69
69
  "react": "^18.3.1",
70
70
  "tsup": "^8.2.4",
71
71
  "typescript": "^5.5.4",
72
- "@kubb/config-biome": "3.0.0-alpha.4",
73
- "@kubb/config-ts": "3.0.0-alpha.4",
74
- "@kubb/config-tsup": "3.0.0-alpha.4"
72
+ "@kubb/config-biome": "3.0.0-alpha.6",
73
+ "@kubb/config-ts": "3.0.0-alpha.6",
74
+ "@kubb/config-tsup": "3.0.0-alpha.6"
75
75
  },
76
76
  "peerDependencies": {
77
- "@kubb/react": "3.0.0-alpha.4"
77
+ "@kubb/react": "3.0.0-alpha.6"
78
78
  },
79
79
  "engines": {
80
80
  "node": ">=20"
@@ -3,7 +3,6 @@ import { Oas } from '@kubb/plugin-oas/components'
3
3
  import { App, createRoot } from '@kubb/react'
4
4
 
5
5
  import { Mutation } from './components/Mutation.tsx'
6
- import { Operations } from './components/Operations.tsx'
7
6
  import { Query } from './components/Query.tsx'
8
7
  import { QueryKey } from './components/QueryKey.tsx'
9
8
  import { QueryOptions } from './components/QueryOptions.tsx'
@@ -14,34 +13,6 @@ import { QueryImports } from './components/QueryImports.tsx'
14
13
  import type { FileMeta, PluginReactQuery } from './types.ts'
15
14
 
16
15
  export class OperationGenerator extends Generator<PluginReactQuery['resolvedOptions'], PluginReactQuery, FileMeta> {
17
- async all(operations: Operation[]): OperationMethodResult<FileMeta> {
18
- const { pluginManager, oas, plugin, mode } = this.context
19
-
20
- const root = createRoot({
21
- logger: pluginManager.logger,
22
- })
23
-
24
- const templates = {
25
- mutation: Mutation.templates,
26
- query: Query.templates,
27
- queryOptions: QueryOptions.templates,
28
- queryKey: QueryKey.templates,
29
- queryImports: QueryImports.templates,
30
- operations: Operations.templates,
31
- ...this.options.templates,
32
- }
33
-
34
- root.render(
35
- <App pluginManager={pluginManager} plugin={plugin} mode={mode}>
36
- <Oas oas={oas} operations={operations} generator={this}>
37
- {templates.operations && <Operations.File templates={templates.operations} />}
38
- </Oas>
39
- </App>,
40
- )
41
-
42
- return root.files
43
- }
44
-
45
16
  async operation(operation: Operation, options: PluginReactQuery['resolvedOptions']): OperationMethodResult<FileMeta> {
46
17
  const { oas, pluginManager, plugin, mode } = this.context
47
18
 
@@ -1,9 +1,10 @@
1
+ import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
1
2
  import client from "@kubb/plugin-client/client";
2
3
  import { useQuery } from "@tanstack/react-query";
3
- import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
4
4
 
5
5
  type UpdatePetWithFormClient = typeof client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>;
6
- type UpdatePetWithForm = {
6
+
7
+ type UpdatePetWithForm = {
7
8
  data: UpdatePetWithFormMutationResponse;
8
9
  error: UpdatePetWithForm405;
9
10
  request: UpdatePetWithFormMutationRequest;
@@ -16,11 +17,14 @@ type UpdatePetWithForm = {
16
17
  return: Awaited<ReturnType<UpdatePetWithFormClient>>;
17
18
  };
18
19
  };
19
- export const UpdatePetWithFormQueryKey = ({ petId }: {
20
+
21
+ export const UpdatePetWithFormQueryKey = ({ petId }: {
20
22
  petId: UpdatePetWithFormPathParams["petId"];
21
23
  }, params?: UpdatePetWithForm["queryParams"], data?: UpdatePetWithForm["request"]) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
22
- export type UpdatePetWithFormQueryKey = ReturnType<typeof UpdatePetWithFormQueryKey>;
23
- export function UpdatePetWithFormQueryOptions<TData = UpdatePetWithForm["response"], TQueryData = UpdatePetWithForm["response"]>({ petId }: {
24
+
25
+ export type UpdatePetWithFormQueryKey = ReturnType<typeof UpdatePetWithFormQueryKey>;
26
+
27
+ export function UpdatePetWithFormQueryOptions<TData = UpdatePetWithForm["response"], TQueryData = UpdatePetWithForm["response"]>({ petId }: {
24
28
  petId: UpdatePetWithFormPathParams["petId"];
25
29
  }, params?: UpdatePetWithForm["queryParams"], data?: UpdatePetWithForm["request"], options: UpdatePetWithForm["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<UpdatePetWithForm["response"], UpdatePetWithForm["error"], TData, TQueryData>, "queryKey"> {
26
30
  const queryKey = UpdatePetWithFormQueryKey({ petId }, params, data);
@@ -38,7 +42,8 @@ export function UpdatePetWithFormQueryOptions<TData = UpdatePetWithForm["respons
38
42
  },
39
43
  };
40
44
  }
41
- /**
45
+
46
+ /**
42
47
  * @summary Updates a pet in the store with form data
43
48
  * @link /pet/:petId
44
49
  */
@@ -1,9 +1,10 @@
1
+ import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
1
2
  import client from "@kubb/plugin-client/client";
2
3
  import { useQuery } from "@tanstack/react-query";
3
- import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
4
4
 
5
5
  type GetPetByIdClient = typeof client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, never>;
6
- type GetPetById = {
6
+
7
+ type GetPetById = {
7
8
  data: GetPetByIdQueryResponse;
8
9
  error: GetPetById400 | GetPetById404;
9
10
  request: never;
@@ -16,9 +17,12 @@ type GetPetById = {
16
17
  return: Awaited<ReturnType<GetPetByIdClient>>;
17
18
  };
18
19
  };
19
- export const GetPetByIdQueryKey = (petId: GetPetByIdPathParams["petId"]) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
20
- export type GetPetByIdQueryKey = ReturnType<typeof GetPetByIdQueryKey>;
21
- export function GetPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>(petId: GetPetByIdPathParams["petId"], options: GetPetById["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<GetPetById["response"], GetPetById["error"], TData, TQueryData>, "queryKey"> {
20
+
21
+ export const GetPetByIdQueryKey = (petId: GetPetByIdPathParams["petId"]) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
22
+
23
+ export type GetPetByIdQueryKey = ReturnType<typeof GetPetByIdQueryKey>;
24
+
25
+ export function GetPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>(petId: GetPetByIdPathParams["petId"], options: GetPetById["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<GetPetById["response"], GetPetById["error"], TData, TQueryData>, "queryKey"> {
22
26
  const queryKey = GetPetByIdQueryKey(petId);
23
27
  return {
24
28
  queryKey,
@@ -32,7 +36,8 @@ export function GetPetByIdQueryOptions<TData = GetPetById["response"], TQueryDat
32
36
  },
33
37
  };
34
38
  }
35
- /**
39
+
40
+ /**
36
41
  * @description Returns a single pet
37
42
  * @summary Find pet by ID
38
43
  * @link /pet/:petId
@@ -1,9 +1,10 @@
1
+ import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
1
2
  import client from "@kubb/plugin-client/client";
2
3
  import { useQuery } from "@tanstack/react-query";
3
- import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
4
4
 
5
5
  type GetPetByIdClient = typeof client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, never>;
6
- type GetPetById = {
6
+
7
+ type GetPetById = {
7
8
  data: GetPetByIdQueryResponse;
8
9
  error: GetPetById400 | GetPetById404;
9
10
  request: never;
@@ -16,11 +17,14 @@ type GetPetById = {
16
17
  return: Awaited<ReturnType<GetPetByIdClient>>;
17
18
  };
18
19
  };
19
- export const GetPetByIdQueryKey = ({ petId }: {
20
+
21
+ export const GetPetByIdQueryKey = ({ petId }: {
20
22
  petId: GetPetByIdPathParams["petId"];
21
23
  }) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
22
- export type GetPetByIdQueryKey = ReturnType<typeof GetPetByIdQueryKey>;
23
- export function GetPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>({ petId }: {
24
+
25
+ export type GetPetByIdQueryKey = ReturnType<typeof GetPetByIdQueryKey>;
26
+
27
+ export function GetPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>({ petId }: {
24
28
  petId: GetPetByIdPathParams["petId"];
25
29
  }, options: GetPetById["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<GetPetById["response"], GetPetById["error"], TData, TQueryData>, "queryKey"> {
26
30
  const queryKey = GetPetByIdQueryKey({ petId });
@@ -36,7 +40,8 @@ export function GetPetByIdQueryOptions<TData = GetPetById["response"], TQueryDat
36
40
  },
37
41
  };
38
42
  }
39
- /**
43
+
44
+ /**
40
45
  * @description Returns a single pet
41
46
  * @summary Find pet by ID
42
47
  * @link /pet/:petId
@@ -1,8 +1,9 @@
1
- import client from "@kubb/plugin-client/client";
2
1
  import type { UseBaseQueryOptions, QueryKey, WithRequired } from "@tanstack/react-query";
2
+ import client from "@kubb/plugin-client/client";
3
3
 
4
4
  type GetPetByIdClient = typeof client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, never>;
5
- type GetPetById = {
5
+
6
+ type GetPetById = {
6
7
  data: GetPetByIdQueryResponse;
7
8
  error: GetPetById400 | GetPetById404;
8
9
  request: never;
@@ -15,11 +16,14 @@ type GetPetById = {
15
16
  return: Awaited<ReturnType<GetPetByIdClient>>;
16
17
  };
17
18
  };
18
- export const GetPetByIdQueryKey = ({ petId }: {
19
+
20
+ export const GetPetByIdQueryKey = ({ petId }: {
19
21
  petId: GetPetByIdPathParams["petId"];
20
22
  }) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
21
- export type GetPetByIdQueryKey = ReturnType<typeof GetPetByIdQueryKey>;
22
- export function GetPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>({ petId }: {
23
+
24
+ export type GetPetByIdQueryKey = ReturnType<typeof GetPetByIdQueryKey>;
25
+
26
+ export function GetPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>({ petId }: {
23
27
  petId: GetPetByIdPathParams["petId"];
24
28
  }, options: GetPetById["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<GetPetById["response"], GetPetById["error"], TData, TQueryData>, "queryKey"> {
25
29
  const queryKey = GetPetByIdQueryKey({ petId });
@@ -1,9 +1,10 @@
1
+ import type { UseBaseQueryOptions, UseQueryResult, QueryKey } from "@tanstack/react-query";
1
2
  import client from "@kubb/plugin-client/client";
2
3
  import { useQuery } from "@tanstack/react-query";
3
- import type { UseBaseQueryOptions, UseQueryResult, QueryKey } from "@tanstack/react-query";
4
4
 
5
5
  type GetPetByIdClient = typeof client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, never>;
6
- type GetPetById = {
6
+
7
+ type GetPetById = {
7
8
  data: GetPetByIdQueryResponse;
8
9
  error: GetPetById400 | GetPetById404;
9
10
  request: never;
@@ -16,11 +17,14 @@ type GetPetById = {
16
17
  return: Awaited<ReturnType<GetPetByIdClient>>;
17
18
  };
18
19
  };
19
- export const GetPetByIdQueryKey = ({ petId }: {
20
+
21
+ export const GetPetByIdQueryKey = ({ petId }: {
20
22
  petId: GetPetByIdPathParams["petId"];
21
23
  }) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
22
- export type GetPetByIdQueryKey = ReturnType<typeof GetPetByIdQueryKey>;
23
- /**
24
+
25
+ export type GetPetByIdQueryKey = ReturnType<typeof GetPetByIdQueryKey>;
26
+
27
+ /**
24
28
  * @description Returns a single pet
25
29
  * @summary Find pet by ID
26
30
  * @link /pet/:petId
@@ -1,9 +1,10 @@
1
+ import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
1
2
  import client from "@kubb/plugin-client/client";
2
3
  import { useQuery } from "@tanstack/react-query";
3
- import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
4
4
 
5
5
  type UploadFileClient = typeof client<UploadFileMutationResponse, UploadFile400, FormData>;
6
- type UploadFile = {
6
+
7
+ type UploadFile = {
7
8
  data: UploadFileMutationResponse;
8
9
  error: UploadFile400;
9
10
  request: FormData;
@@ -16,9 +17,12 @@ type UploadFile = {
16
17
  return: Awaited<ReturnType<UploadFileClient>>;
17
18
  };
18
19
  };
19
- export const UploadFileQueryKey = (data: UploadFile["request"]) => [{ url: "/upload" }, ...(data ? [data] : [])] as const;
20
- export type UploadFileQueryKey = ReturnType<typeof UploadFileQueryKey>;
21
- export function UploadFileQueryOptions<TData = UploadFile["response"], TQueryData = UploadFile["response"]>(data: UploadFile["request"], options: UploadFile["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<UploadFile["response"], UploadFile["error"], TData, TQueryData>, "queryKey"> {
20
+
21
+ export const UploadFileQueryKey = (data: UploadFile["request"]) => [{ url: "/upload" }, ...(data ? [data] : [])] as const;
22
+
23
+ export type UploadFileQueryKey = ReturnType<typeof UploadFileQueryKey>;
24
+
25
+ export function UploadFileQueryOptions<TData = UploadFile["response"], TQueryData = UploadFile["response"]>(data: UploadFile["request"], options: UploadFile["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<UploadFile["response"], UploadFile["error"], TData, TQueryData>, "queryKey"> {
22
26
  const queryKey = UploadFileQueryKey(data);
23
27
  return {
24
28
  queryKey,
@@ -43,7 +47,8 @@ export function UploadFileQueryOptions<TData = UploadFile["response"], TQueryDat
43
47
  },
44
48
  };
45
49
  }
46
- /**
50
+
51
+ /**
47
52
  * @description Upload file
48
53
  * @link /upload
49
54
  */
@@ -1,8 +1,9 @@
1
- import client from "@kubb/plugin-client/client";
2
1
  import type { UseBaseQueryOptions, QueryKey, WithRequired } from "@tanstack/react-query";
2
+ import client from "@kubb/plugin-client/client";
3
3
 
4
4
  type UploadFileClient = typeof client<UploadFileMutationResponse, UploadFile400, FormData>;
5
- type UploadFile = {
5
+
6
+ type UploadFile = {
6
7
  data: UploadFileMutationResponse;
7
8
  error: UploadFile400;
8
9
  request: FormData;
@@ -15,9 +16,12 @@ type UploadFile = {
15
16
  return: Awaited<ReturnType<UploadFileClient>>;
16
17
  };
17
18
  };
18
- export const UploadFileQueryKey = (data: UploadFile["request"]) => [{ url: "/upload" }, ...(data ? [data] : [])] as const;
19
- export type UploadFileQueryKey = ReturnType<typeof UploadFileQueryKey>;
20
- export function UploadFileQueryOptions<TData = UploadFile["response"], TQueryData = UploadFile["response"]>(data: UploadFile["request"], options: UploadFile["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<UploadFile["response"], UploadFile["error"], TData, TQueryData>, "queryKey"> {
19
+
20
+ export const UploadFileQueryKey = (data: UploadFile["request"]) => [{ url: "/upload" }, ...(data ? [data] : [])] as const;
21
+
22
+ export type UploadFileQueryKey = ReturnType<typeof UploadFileQueryKey>;
23
+
24
+ export function UploadFileQueryOptions<TData = UploadFile["response"], TQueryData = UploadFile["response"]>(data: UploadFile["request"], options: UploadFile["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<UploadFile["response"], UploadFile["error"], TData, TQueryData>, "queryKey"> {
21
25
  const queryKey = UploadFileQueryKey(data);
22
26
  return {
23
27
  queryKey,
@@ -1,8 +1,9 @@
1
- import client from "@kubb/plugin-client/client";
2
1
  import type { QueryKey } from "@tanstack/react-query";
2
+ import client from "@kubb/plugin-client/client";
3
3
 
4
4
  type DeletePetClient = typeof client<DeletePetMutationResponse, DeletePet400, never>;
5
- type DeletePet = {
5
+
6
+ type DeletePet = {
6
7
  data: DeletePetMutationResponse;
7
8
  error: DeletePet400;
8
9
  request: never;
@@ -15,7 +16,9 @@ type DeletePet = {
15
16
  return: Awaited<ReturnType<DeletePetClient>>;
16
17
  };
17
18
  };
18
- export const DeletePetQueryKey = ({ petId }: {
19
+
20
+ export const DeletePetQueryKey = ({ petId }: {
19
21
  petId: DeletePetPathParams["petId"];
20
22
  }) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
21
- export type DeletePetQueryKey = ReturnType<typeof DeletePetQueryKey>;
23
+
24
+ export type DeletePetQueryKey = ReturnType<typeof DeletePetQueryKey>;