@kubb/plugin-react-query 5.0.0-alpha.3 → 5.0.0-alpha.30
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-BHQT9ZLc.cjs → components-DQiCnrXP.cjs} +68 -15
- package/dist/components-DQiCnrXP.cjs.map +1 -0
- package/dist/{components-CpyHYGOw.js → components-HG1bVVRU.js} +68 -15
- package/dist/components-HG1bVVRU.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-BZn1n6rK.js → generators-BZKMuZRH.js} +54 -50
- package/dist/generators-BZKMuZRH.js.map +1 -0
- package/dist/{generators-B8Pq52sx.cjs → generators-CeU3eFdF.cjs} +52 -48
- package/dist/generators-CeU3eFdF.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +9 -500
- package/dist/generators.js +1 -1
- package/dist/index.cjs +18 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -12
- package/dist/index.js.map +1 -1
- package/dist/{types--pHE21AC.d.ts → types-DMLrT2SW.d.ts} +13 -3
- package/package.json +12 -12
- package/src/components/InfiniteQueryOptions.tsx +1 -1
- package/src/components/MutationOptions.tsx +1 -1
- package/src/components/QueryOptions.tsx +1 -1
- package/src/components/SuspenseInfiniteQueryOptions.tsx +1 -1
- package/src/generators/customHookOptionsFileGenerator.tsx +3 -3
- package/src/generators/hookOptionsGenerator.tsx +4 -4
- package/src/generators/infiniteQueryGenerator.tsx +10 -14
- package/src/generators/mutationGenerator.tsx +10 -19
- package/src/generators/queryGenerator.tsx +10 -14
- package/src/generators/suspenseInfiniteQueryGenerator.tsx +10 -14
- package/src/generators/suspenseQueryGenerator.tsx +10 -14
- package/src/plugin.ts +15 -10
- package/src/types.ts +13 -2
- package/dist/components-BHQT9ZLc.cjs.map +0 -1
- package/dist/components-CpyHYGOw.js.map +0 -1
- package/dist/generators-B8Pq52sx.cjs.map +0 -1
- package/dist/generators-BZn1n6rK.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { d as MutationKey, f as camelCase, p as pascalCase, u as QueryKey } from "./components-
|
|
3
|
-
import { a as infiniteQueryGenerator, i as mutationGenerator, n as suspenseInfiniteQueryGenerator, o as hookOptionsGenerator, r as queryGenerator, s as customHookOptionsFileGenerator, t as suspenseQueryGenerator } from "./generators-
|
|
2
|
+
import { d as MutationKey, f as camelCase, p as pascalCase, u as QueryKey } from "./components-HG1bVVRU.js";
|
|
3
|
+
import { a as infiniteQueryGenerator, i as mutationGenerator, n as suspenseInfiniteQueryGenerator, o as hookOptionsGenerator, r as queryGenerator, s as customHookOptionsFileGenerator, t as suspenseQueryGenerator } from "./generators-BZKMuZRH.js";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { createPlugin, getBarrelFiles } from "@kubb/core";
|
|
6
6
|
import { pluginClientName } from "@kubb/plugin-client";
|
|
7
7
|
import { source } from "@kubb/plugin-client/templates/clients/axios.source";
|
|
8
8
|
import { source as source$1 } from "@kubb/plugin-client/templates/clients/fetch.source";
|
|
@@ -10,9 +10,12 @@ import { source as source$2 } from "@kubb/plugin-client/templates/config.source"
|
|
|
10
10
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
11
11
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
12
12
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
13
|
+
//#region package.json
|
|
14
|
+
var version = "5.0.0-alpha.30";
|
|
15
|
+
//#endregion
|
|
13
16
|
//#region src/plugin.ts
|
|
14
17
|
const pluginReactQueryName = "plugin-react-query";
|
|
15
|
-
const pluginReactQuery =
|
|
18
|
+
const pluginReactQuery = createPlugin((options) => {
|
|
16
19
|
const { output = {
|
|
17
20
|
path: "hooks",
|
|
18
21
|
barrelType: "named"
|
|
@@ -29,6 +32,7 @@ const pluginReactQuery = definePlugin((options) => {
|
|
|
29
32
|
const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
|
|
30
33
|
return {
|
|
31
34
|
name: pluginReactQueryName,
|
|
35
|
+
version,
|
|
32
36
|
options: {
|
|
33
37
|
output,
|
|
34
38
|
client: {
|
|
@@ -75,7 +79,10 @@ const pluginReactQuery = definePlugin((options) => {
|
|
|
75
79
|
pathParamsType,
|
|
76
80
|
parser,
|
|
77
81
|
paramsCasing,
|
|
78
|
-
group
|
|
82
|
+
group,
|
|
83
|
+
exclude,
|
|
84
|
+
include,
|
|
85
|
+
override
|
|
79
86
|
},
|
|
80
87
|
pre: [
|
|
81
88
|
pluginOasName,
|
|
@@ -83,8 +90,8 @@ const pluginReactQuery = definePlugin((options) => {
|
|
|
83
90
|
parser === "zod" ? pluginZodName : void 0
|
|
84
91
|
].filter(Boolean),
|
|
85
92
|
resolvePath(baseName, pathMode, options) {
|
|
86
|
-
const root =
|
|
87
|
-
if ((pathMode ?? getMode(
|
|
93
|
+
const root = this.root;
|
|
94
|
+
if ((pathMode ?? this.getMode(output)) === "single")
|
|
88
95
|
/**
|
|
89
96
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
90
97
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -106,13 +113,13 @@ const pluginReactQuery = definePlugin((options) => {
|
|
|
106
113
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
107
114
|
return resolvedName;
|
|
108
115
|
},
|
|
109
|
-
async
|
|
110
|
-
const root =
|
|
111
|
-
const mode = getMode(
|
|
116
|
+
async buildStart() {
|
|
117
|
+
const root = this.root;
|
|
118
|
+
const mode = this.getMode(output);
|
|
112
119
|
const oas = await this.getOas();
|
|
113
120
|
const baseURL = await this.getBaseURL();
|
|
114
121
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
115
|
-
const hasClientPlugin = !!this.
|
|
122
|
+
const hasClientPlugin = !!this.getPlugin(pluginClientName);
|
|
116
123
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
117
124
|
baseName: "fetch.ts",
|
|
118
125
|
path: path.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -140,7 +147,7 @@ const pluginReactQuery = definePlugin((options) => {
|
|
|
140
147
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
141
148
|
fabric: this.fabric,
|
|
142
149
|
oas,
|
|
143
|
-
|
|
150
|
+
driver: this.driver,
|
|
144
151
|
events: this.events,
|
|
145
152
|
plugin: this.plugin,
|
|
146
153
|
contentType,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["fetchClientSource","axiosClientSource","configSource"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\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.getPluginByName(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 pluginName: this.plugin.name,\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,KAAA;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,KAAA;IACb,WAAW,KAAA;IACX,eAAe,KAAA;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,SA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ClientSource","axiosClientSource","configSource"],"sources":["../package.json","../src/plugin.ts"],"sourcesContent":["","import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'\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 { version } from '../package.json'\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 = createPlugin<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 version,\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 exclude,\n include,\n override,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = this.root\n const mode = pathMode ?? this.getMode(output)\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: UserGroup['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 buildStart() {\n const root = this.root\n const mode = this.getMode(output)\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.getPlugin(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 driver: this.driver,\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 pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;ACwBA,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;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KACN,OAAOC;KACP,cAAc;KACd,aAAa;KACd,CACF;IACD,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;GAgBJ,MAAM,QAAQ,MAba,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,QAAQ,KAAK;IACb,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,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Output, PluginFactoryOptions, ResolveNameParams, UserGroup } from "@kubb/core";
|
|
3
3
|
import { ClientImportPath, PluginClient } from "@kubb/plugin-client";
|
|
4
4
|
import { Exclude, Include, OperationSchemas, Override, ResolvePathOptions } from "@kubb/plugin-oas";
|
|
5
5
|
import { HttpMethod, Oas, Operation, contentType } from "@kubb/oas";
|
|
@@ -173,7 +173,7 @@ type Options = {
|
|
|
173
173
|
/**
|
|
174
174
|
* Group the @tanstack/query hooks based on the provided name.
|
|
175
175
|
*/
|
|
176
|
-
group?:
|
|
176
|
+
group?: UserGroup;
|
|
177
177
|
client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
178
178
|
/**
|
|
179
179
|
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
@@ -248,6 +248,9 @@ type Options = {
|
|
|
248
248
|
type ResolvedOptions = {
|
|
249
249
|
output: Output<Oas>;
|
|
250
250
|
group: Options['group'];
|
|
251
|
+
exclude: NonNullable<Options['exclude']>;
|
|
252
|
+
include: Options['include'];
|
|
253
|
+
override: NonNullable<Options['override']>;
|
|
251
254
|
client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
252
255
|
parser: Required<NonNullable<Options['parser']>>;
|
|
253
256
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
@@ -265,6 +268,13 @@ type ResolvedOptions = {
|
|
|
265
268
|
customOptions: NonNullable<Required<CustomOptions>> | undefined;
|
|
266
269
|
};
|
|
267
270
|
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
271
|
+
declare global {
|
|
272
|
+
namespace Kubb {
|
|
273
|
+
interface PluginRegistry {
|
|
274
|
+
'plugin-react-query': PluginReactQuery;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
268
278
|
//#endregion
|
|
269
279
|
export { MutationKey$1 as a, QueryKey$1 as i, Options as n, PluginReactQuery as r, Infinite as t };
|
|
270
|
-
//# sourceMappingURL=types
|
|
280
|
+
//# sourceMappingURL=types-DMLrT2SW.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-react-query",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.30",
|
|
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",
|
|
@@ -71,19 +71,19 @@
|
|
|
71
71
|
}
|
|
72
72
|
],
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@kubb/fabric-core": "0.
|
|
75
|
-
"@kubb/react-fabric": "0.
|
|
76
|
-
"remeda": "^2.33.
|
|
77
|
-
"@kubb/core": "5.0.0-alpha.
|
|
78
|
-
"@kubb/oas": "5.0.0-alpha.
|
|
79
|
-
"@kubb/plugin-client": "5.0.0-alpha.
|
|
80
|
-
"@kubb/plugin-oas": "5.0.0-alpha.
|
|
81
|
-
"@kubb/plugin-ts": "5.0.0-alpha.
|
|
82
|
-
"@kubb/plugin-zod": "5.0.0-alpha.
|
|
74
|
+
"@kubb/fabric-core": "0.15.1",
|
|
75
|
+
"@kubb/react-fabric": "0.15.1",
|
|
76
|
+
"remeda": "^2.33.7",
|
|
77
|
+
"@kubb/core": "5.0.0-alpha.30",
|
|
78
|
+
"@kubb/oas": "5.0.0-alpha.30",
|
|
79
|
+
"@kubb/plugin-client": "5.0.0-alpha.30",
|
|
80
|
+
"@kubb/plugin-oas": "5.0.0-alpha.30",
|
|
81
|
+
"@kubb/plugin-ts": "5.0.0-alpha.30",
|
|
82
|
+
"@kubb/plugin-zod": "5.0.0-alpha.30"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"@kubb/fabric-core": "0.
|
|
86
|
-
"@kubb/react-fabric": "0.
|
|
85
|
+
"@kubb/fabric-core": "0.15.1",
|
|
86
|
+
"@kubb/react-fabric": "0.15.1"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|
|
89
89
|
"node": ">=22"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNestedAccessor } from '@internals/utils'
|
|
2
2
|
import { isAllOptional, isOptional } from '@kubb/oas'
|
|
3
|
-
import { Client } from '@kubb/plugin-client
|
|
3
|
+
import { ClientLegacy as Client } from '@kubb/plugin-client'
|
|
4
4
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
5
5
|
import { getPathParams } from '@kubb/plugin-oas/utils'
|
|
6
6
|
import { File, Function, FunctionParams } from '@kubb/react-fabric'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isOptional } from '@kubb/oas'
|
|
2
|
-
import { Client } from '@kubb/plugin-client
|
|
2
|
+
import { ClientLegacy as Client } from '@kubb/plugin-client'
|
|
3
3
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
4
4
|
import { getPathParams } from '@kubb/plugin-oas/utils'
|
|
5
5
|
import { File, Function, FunctionParams } from '@kubb/react-fabric'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isAllOptional, isOptional } from '@kubb/oas'
|
|
2
|
-
import { Client } from '@kubb/plugin-client
|
|
2
|
+
import { ClientLegacy as Client } from '@kubb/plugin-client'
|
|
3
3
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
4
4
|
import { getPathParams } from '@kubb/plugin-oas/utils'
|
|
5
5
|
import { File, Function, FunctionParams } from '@kubb/react-fabric'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNestedAccessor } from '@internals/utils'
|
|
2
2
|
import { isAllOptional, isOptional } from '@kubb/oas'
|
|
3
|
-
import { Client } from '@kubb/plugin-client
|
|
3
|
+
import { ClientLegacy as Client } from '@kubb/plugin-client'
|
|
4
4
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
5
5
|
import { getPathParams } from '@kubb/plugin-oas/utils'
|
|
6
6
|
import { File, Function, FunctionParams } from '@kubb/react-fabric'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
-
import {
|
|
3
|
+
import { useDriver } from '@kubb/core/hooks'
|
|
4
4
|
import type { Operation } from '@kubb/oas'
|
|
5
5
|
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
6
6
|
import { useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
@@ -15,7 +15,7 @@ export const customHookOptionsFileGenerator = createReactGenerator<PluginReactQu
|
|
|
15
15
|
options: { output },
|
|
16
16
|
name: pluginName,
|
|
17
17
|
} = plugin
|
|
18
|
-
const
|
|
18
|
+
const driver = useDriver()
|
|
19
19
|
|
|
20
20
|
const { getFile } = useOperationManager(generator)
|
|
21
21
|
|
|
@@ -37,7 +37,7 @@ export const customHookOptionsFileGenerator = createReactGenerator<PluginReactQu
|
|
|
37
37
|
return getFile(firstOperation, { prefix: 'use' }).path
|
|
38
38
|
}
|
|
39
39
|
// Get the index file of the hooks directory
|
|
40
|
-
return
|
|
40
|
+
return driver.getFile({ name: 'index', extname: '.ts', pluginName }).path
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const ensureExtension = (filePath: string, extname: string) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useDriver } from '@kubb/core/hooks'
|
|
2
2
|
import type { Operation } from '@kubb/oas'
|
|
3
3
|
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
4
4
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
@@ -15,7 +15,7 @@ export const hookOptionsGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
15
15
|
options: { output },
|
|
16
16
|
name: pluginName,
|
|
17
17
|
} = plugin
|
|
18
|
-
const
|
|
18
|
+
const driver = useDriver()
|
|
19
19
|
|
|
20
20
|
const oas = useOas()
|
|
21
21
|
const { getName, getFile } = useOperationManager(generator)
|
|
@@ -25,7 +25,7 @@ export const hookOptionsGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const name = 'HookOptions'
|
|
28
|
-
const file =
|
|
28
|
+
const file = driver.getFile({ name, extname: '.ts', pluginName })
|
|
29
29
|
|
|
30
30
|
const getOperationOptions = (operation: Operation) => {
|
|
31
31
|
const operationOptions = generator.getOptions(operation, operation.method)
|
|
@@ -181,7 +181,7 @@ export const hookOptionsGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
181
181
|
baseName={file.baseName}
|
|
182
182
|
path={file.path}
|
|
183
183
|
meta={file.meta}
|
|
184
|
-
banner={getBanner({ oas, output, config:
|
|
184
|
+
banner={getBanner({ oas, output, config: driver.config })}
|
|
185
185
|
footer={getFooter({ oas, output })}
|
|
186
186
|
>
|
|
187
187
|
{imports}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
3
|
-
import { pluginClientName } from '@kubb/plugin-client'
|
|
4
|
-
import { Client } from '@kubb/plugin-client/components'
|
|
2
|
+
import { useDriver } from '@kubb/core/hooks'
|
|
3
|
+
import { ClientLegacy as Client, pluginClientName } from '@kubb/plugin-client'
|
|
5
4
|
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
6
5
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
7
6
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
@@ -19,7 +18,8 @@ export const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
19
18
|
options,
|
|
20
19
|
options: { output },
|
|
21
20
|
} = plugin
|
|
22
|
-
const
|
|
21
|
+
const driver = useDriver()
|
|
22
|
+
const root = path.resolve(config.root, config.output.path)
|
|
23
23
|
|
|
24
24
|
const oas = useOas()
|
|
25
25
|
const { getSchemas, getName, getFile } = useOperationManager(generator)
|
|
@@ -38,7 +38,7 @@ export const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
38
38
|
file: getFile(operation, { prefix: 'use', suffix: 'infinite' }),
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const hasClientPlugin = !!
|
|
41
|
+
const hasClientPlugin = !!driver.getPlugin(pluginClientName)
|
|
42
42
|
// Class-based clients are not compatible with query hooks, so we generate inline clients
|
|
43
43
|
const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
|
|
44
44
|
const client = {
|
|
@@ -96,7 +96,7 @@ export const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
96
96
|
baseName={query.file.baseName}
|
|
97
97
|
path={query.file.path}
|
|
98
98
|
meta={query.file.meta}
|
|
99
|
-
banner={getBanner({ oas, output, config:
|
|
99
|
+
banner={getBanner({ oas, output, config: driver.config })}
|
|
100
100
|
footer={getFooter({ oas, output })}
|
|
101
101
|
>
|
|
102
102
|
{options.parser === 'zod' && (
|
|
@@ -110,25 +110,21 @@ export const infiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
110
110
|
</>
|
|
111
111
|
) : (
|
|
112
112
|
<>
|
|
113
|
-
{!shouldUseClientPlugin && (
|
|
114
|
-
<File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
|
|
115
|
-
)}
|
|
113
|
+
{!shouldUseClientPlugin && <File.Import name={['fetch']} root={query.file.path} path={path.resolve(root, '.kubb/fetch.ts')} />}
|
|
116
114
|
<File.Import
|
|
117
115
|
name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
|
|
118
116
|
root={query.file.path}
|
|
119
|
-
path={path.resolve(
|
|
117
|
+
path={path.resolve(root, '.kubb/fetch.ts')}
|
|
120
118
|
isTypeOnly
|
|
121
119
|
/>
|
|
122
120
|
{options.client.dataReturnType === 'full' && (
|
|
123
|
-
<File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(
|
|
121
|
+
<File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(root, '.kubb/fetch.ts')} isTypeOnly />
|
|
124
122
|
)}
|
|
125
123
|
</>
|
|
126
124
|
)}
|
|
127
125
|
|
|
128
126
|
{shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}
|
|
129
|
-
{!shouldUseClientPlugin && (
|
|
130
|
-
<File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
|
|
131
|
-
)}
|
|
127
|
+
{!shouldUseClientPlugin && <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(root, '.kubb/config.ts')} />}
|
|
132
128
|
<File.Import
|
|
133
129
|
name={[
|
|
134
130
|
type.schemas.request?.name,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
3
|
-
import { pluginClientName } from '@kubb/plugin-client'
|
|
4
|
-
import { Client } from '@kubb/plugin-client/components'
|
|
2
|
+
import { useDriver } from '@kubb/core/hooks'
|
|
3
|
+
import { ClientLegacy as Client, pluginClientName } from '@kubb/plugin-client'
|
|
5
4
|
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
6
5
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
7
6
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
@@ -20,7 +19,8 @@ export const mutationGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
20
19
|
options,
|
|
21
20
|
options: { output },
|
|
22
21
|
} = plugin
|
|
23
|
-
const
|
|
22
|
+
const driver = useDriver()
|
|
23
|
+
const root = path.resolve(config.root, config.output.path)
|
|
24
24
|
|
|
25
25
|
const oas = useOas()
|
|
26
26
|
const { getSchemas, getName, getFile } = useOperationManager(generator)
|
|
@@ -50,7 +50,7 @@ export const mutationGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
50
50
|
schemas: getSchemas(operation, { pluginName: pluginZodName, type: 'function' }),
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const hasClientPlugin = !!
|
|
53
|
+
const hasClientPlugin = !!driver.getPlugin(pluginClientName)
|
|
54
54
|
// Class-based clients are not compatible with query hooks, so we generate inline clients
|
|
55
55
|
const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
|
|
56
56
|
const client = {
|
|
@@ -83,7 +83,7 @@ export const mutationGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
83
83
|
baseName={mutation.file.baseName}
|
|
84
84
|
path={mutation.file.path}
|
|
85
85
|
meta={mutation.file.meta}
|
|
86
|
-
banner={getBanner({ oas, output, config:
|
|
86
|
+
banner={getBanner({ oas, output, config: driver.config })}
|
|
87
87
|
footer={getFooter({ oas, output })}
|
|
88
88
|
>
|
|
89
89
|
{options.parser === 'zod' && (
|
|
@@ -97,29 +97,20 @@ export const mutationGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
97
97
|
</>
|
|
98
98
|
) : (
|
|
99
99
|
<>
|
|
100
|
-
{!shouldUseClientPlugin && (
|
|
101
|
-
<File.Import name={['fetch']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
|
|
102
|
-
)}
|
|
100
|
+
{!shouldUseClientPlugin && <File.Import name={['fetch']} root={mutation.file.path} path={path.resolve(root, '.kubb/fetch.ts')} />}
|
|
103
101
|
<File.Import
|
|
104
102
|
name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
|
|
105
103
|
root={mutation.file.path}
|
|
106
|
-
path={path.resolve(
|
|
104
|
+
path={path.resolve(root, '.kubb/fetch.ts')}
|
|
107
105
|
isTypeOnly
|
|
108
106
|
/>
|
|
109
107
|
{options.client.dataReturnType === 'full' && (
|
|
110
|
-
<File.Import
|
|
111
|
-
name={['ResponseConfig']}
|
|
112
|
-
root={mutation.file.path}
|
|
113
|
-
path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}
|
|
114
|
-
isTypeOnly
|
|
115
|
-
/>
|
|
108
|
+
<File.Import name={['ResponseConfig']} root={mutation.file.path} path={path.resolve(root, '.kubb/fetch.ts')} isTypeOnly />
|
|
116
109
|
)}
|
|
117
110
|
</>
|
|
118
111
|
)}
|
|
119
112
|
{shouldUseClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}
|
|
120
|
-
{!shouldUseClientPlugin && (
|
|
121
|
-
<File.Import name={['buildFormData']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
|
|
122
|
-
)}
|
|
113
|
+
{!shouldUseClientPlugin && <File.Import name={['buildFormData']} root={mutation.file.path} path={path.resolve(root, '.kubb/config.ts')} />}
|
|
123
114
|
{options.customOptions && <File.Import name={[options.customOptions.name]} path={options.customOptions.importPath} />}
|
|
124
115
|
<File.Import
|
|
125
116
|
name={[
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
3
|
-
import { pluginClientName } from '@kubb/plugin-client'
|
|
4
|
-
import { Client } from '@kubb/plugin-client/components'
|
|
2
|
+
import { useDriver } from '@kubb/core/hooks'
|
|
3
|
+
import { ClientLegacy as Client, pluginClientName } from '@kubb/plugin-client'
|
|
5
4
|
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
6
5
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
7
6
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
@@ -19,7 +18,8 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
19
18
|
options,
|
|
20
19
|
options: { output },
|
|
21
20
|
} = plugin
|
|
22
|
-
const
|
|
21
|
+
const driver = useDriver()
|
|
22
|
+
const root = path.resolve(config.root, config.output.path)
|
|
23
23
|
|
|
24
24
|
const oas = useOas()
|
|
25
25
|
const { getSchemas, getName, getFile } = useOperationManager(generator)
|
|
@@ -37,7 +37,7 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
37
37
|
file: getFile(operation, { prefix: 'use' }),
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const hasClientPlugin = !!
|
|
40
|
+
const hasClientPlugin = !!driver.getPlugin(pluginClientName)
|
|
41
41
|
// Class-based clients are not compatible with query hooks, so we generate inline clients
|
|
42
42
|
const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
|
|
43
43
|
const client = {
|
|
@@ -88,7 +88,7 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
88
88
|
baseName={query.file.baseName}
|
|
89
89
|
path={query.file.path}
|
|
90
90
|
meta={query.file.meta}
|
|
91
|
-
banner={getBanner({ oas, output, config:
|
|
91
|
+
banner={getBanner({ oas, output, config: driver.config })}
|
|
92
92
|
footer={getFooter({ oas, output })}
|
|
93
93
|
>
|
|
94
94
|
{options.parser === 'zod' && (
|
|
@@ -102,25 +102,21 @@ export const queryGenerator = createReactGenerator<PluginReactQuery>({
|
|
|
102
102
|
</>
|
|
103
103
|
) : (
|
|
104
104
|
<>
|
|
105
|
-
{!shouldUseClientPlugin && (
|
|
106
|
-
<File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
|
|
107
|
-
)}
|
|
105
|
+
{!shouldUseClientPlugin && <File.Import name={['fetch']} root={query.file.path} path={path.resolve(root, '.kubb/fetch.ts')} />}
|
|
108
106
|
<File.Import
|
|
109
107
|
name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
|
|
110
108
|
root={query.file.path}
|
|
111
|
-
path={path.resolve(
|
|
109
|
+
path={path.resolve(root, '.kubb/fetch.ts')}
|
|
112
110
|
isTypeOnly
|
|
113
111
|
/>
|
|
114
112
|
{options.client.dataReturnType === 'full' && (
|
|
115
|
-
<File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(
|
|
113
|
+
<File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(root, '.kubb/fetch.ts')} isTypeOnly />
|
|
116
114
|
)}
|
|
117
115
|
</>
|
|
118
116
|
)}
|
|
119
117
|
|
|
120
118
|
{shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}
|
|
121
|
-
{!shouldUseClientPlugin && (
|
|
122
|
-
<File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
|
|
123
|
-
)}
|
|
119
|
+
{!shouldUseClientPlugin && <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(root, '.kubb/config.ts')} />}
|
|
124
120
|
{options.customOptions && <File.Import name={[options.customOptions.name]} path={options.customOptions.importPath} />}
|
|
125
121
|
<File.Import
|
|
126
122
|
name={[
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
3
|
-
import { pluginClientName } from '@kubb/plugin-client'
|
|
4
|
-
import { Client } from '@kubb/plugin-client/components'
|
|
2
|
+
import { useDriver } from '@kubb/core/hooks'
|
|
3
|
+
import { ClientLegacy as Client, pluginClientName } from '@kubb/plugin-client'
|
|
5
4
|
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
6
5
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
7
6
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
@@ -19,7 +18,8 @@ export const suspenseInfiniteQueryGenerator = createReactGenerator<PluginReactQu
|
|
|
19
18
|
options,
|
|
20
19
|
options: { output },
|
|
21
20
|
} = plugin
|
|
22
|
-
const
|
|
21
|
+
const driver = useDriver()
|
|
22
|
+
const root = path.resolve(config.root, config.output.path)
|
|
23
23
|
|
|
24
24
|
const oas = useOas()
|
|
25
25
|
const { getSchemas, getName, getFile } = useOperationManager(generator)
|
|
@@ -39,7 +39,7 @@ export const suspenseInfiniteQueryGenerator = createReactGenerator<PluginReactQu
|
|
|
39
39
|
file: getFile(operation, { prefix: 'use', suffix: 'suspenseInfinite' }),
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const hasClientPlugin = !!
|
|
42
|
+
const hasClientPlugin = !!driver.getPlugin(pluginClientName)
|
|
43
43
|
// Class-based clients are not compatible with query hooks, so we generate inline clients
|
|
44
44
|
const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
|
|
45
45
|
const client = {
|
|
@@ -84,7 +84,7 @@ export const suspenseInfiniteQueryGenerator = createReactGenerator<PluginReactQu
|
|
|
84
84
|
baseName={query.file.baseName}
|
|
85
85
|
path={query.file.path}
|
|
86
86
|
meta={query.file.meta}
|
|
87
|
-
banner={getBanner({ oas, output, config:
|
|
87
|
+
banner={getBanner({ oas, output, config: driver.config })}
|
|
88
88
|
footer={getFooter({ oas, output })}
|
|
89
89
|
>
|
|
90
90
|
{options.parser === 'zod' && (
|
|
@@ -98,25 +98,21 @@ export const suspenseInfiniteQueryGenerator = createReactGenerator<PluginReactQu
|
|
|
98
98
|
</>
|
|
99
99
|
) : (
|
|
100
100
|
<>
|
|
101
|
-
{!shouldUseClientPlugin && (
|
|
102
|
-
<File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
|
|
103
|
-
)}
|
|
101
|
+
{!shouldUseClientPlugin && <File.Import name={['fetch']} root={query.file.path} path={path.resolve(root, '.kubb/fetch.ts')} />}
|
|
104
102
|
<File.Import
|
|
105
103
|
name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
|
|
106
104
|
root={query.file.path}
|
|
107
|
-
path={path.resolve(
|
|
105
|
+
path={path.resolve(root, '.kubb/fetch.ts')}
|
|
108
106
|
isTypeOnly
|
|
109
107
|
/>
|
|
110
108
|
{options.client.dataReturnType === 'full' && (
|
|
111
|
-
<File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(
|
|
109
|
+
<File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(root, '.kubb/fetch.ts')} isTypeOnly />
|
|
112
110
|
)}
|
|
113
111
|
</>
|
|
114
112
|
)}
|
|
115
113
|
|
|
116
114
|
{shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}
|
|
117
|
-
{!shouldUseClientPlugin && (
|
|
118
|
-
<File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
|
|
119
|
-
)}
|
|
115
|
+
{!shouldUseClientPlugin && <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(root, '.kubb/config.ts')} />}
|
|
120
116
|
{options.customOptions && <File.Import name={[options.customOptions.name]} path={options.customOptions.importPath} />}
|
|
121
117
|
<File.Import
|
|
122
118
|
name={[
|