UNPKG

@kubb/plugin-react-query

Version:

Generator react-query hooks

870 lines (867 loc) 34.8 kB
import { Url, Client, Operations, QueryKey, QueryOptions, Query, MutationKey, Mutation, InfiniteQueryOptions, InfiniteQuery, SuspenseQuery } from './chunk-B5HX4HGF.js'; import path from 'node:path'; import { createPlugin, PluginManager, FileManager } from '@kubb/core'; import { camelCase } from '@kubb/core/transformers'; import { createReactGenerator, pluginOasName, OperationGenerator } from '@kubb/plugin-oas'; import { pluginZodName } from '@kubb/plugin-zod'; import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'; import { getFooter, getBanner } from '@kubb/plugin-oas/utils'; import { pluginTsName } from '@kubb/plugin-ts'; import { useApp, File, Function } from '@kubb/react'; import { jsxs, jsx, Fragment } from '@kubb/react/jsx-runtime'; import { difference } from 'remeda'; var clientGenerator = createReactGenerator({ name: "client", Operation({ options, operation }) { const { plugin: { options: { output, urlType } }, pluginManager } = useApp(); const oas = useOas(); const { getSchemas, getName, getFile } = useOperationManager(); const client = { name: getName(operation, { type: "function" }), file: getFile(operation) }; const url = { name: getName(operation, { type: "function", suffix: "url", prefix: "get" }), file: getFile(operation) }; const type = { file: getFile(operation, { pluginKey: [pluginTsName] }), schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" }) }; const zod = { file: getFile(operation, { pluginKey: [pluginZodName] }), schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" }) }; return /* @__PURE__ */ jsxs( File, { baseName: client.file.baseName, path: client.file.path, meta: client.file.meta, banner: getBanner({ oas, output, config: pluginManager.config }), footer: getFooter({ oas, output }), children: [ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.importPath }), /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.importPath, isTypeOnly: true }), options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: client.file.path, path: zod.file.path }), /* @__PURE__ */ jsx( File.Import, { name: [ type.schemas.request?.name, type.schemas.response.name, type.schemas.pathParams?.name, type.schemas.queryParams?.name, type.schemas.headerParams?.name, ...type.schemas.statusCodes?.map((item) => item.name) || [] ].filter(Boolean), root: client.file.path, path: type.file.path, isTypeOnly: true } ), /* @__PURE__ */ jsx( Url, { name: url.name, baseURL: options.baseURL, pathParamsType: options.pathParamsType, paramsCasing: options.paramsCasing, paramsType: options.paramsType, typeSchemas: type.schemas, operation, isIndexable: urlType === "export", isExportable: urlType === "export" } ), /* @__PURE__ */ jsx( Client, { name: client.name, urlName: url.name, baseURL: options.baseURL, dataReturnType: options.dataReturnType, pathParamsType: options.pathParamsType, paramsCasing: options.paramsCasing, paramsType: options.paramsType, typeSchemas: type.schemas, operation, parser: options.parser, zodSchemas: zod.schemas } ) ] } ); } }); var operationsGenerator = createReactGenerator({ name: "client", Operations({ operations }) { const { pluginManager, plugin: { key: pluginKey, options: { output } } } = useApp(); const oas = useOas(); const name = "operations"; const file = pluginManager.getFile({ name, extname: ".ts", pluginKey }); return /* @__PURE__ */ jsx( File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: getBanner({ oas, output, config: pluginManager.config }), footer: getFooter({ oas, output }), children: /* @__PURE__ */ jsx(Operations, { name, operations }) } ); } }); var groupedClientGenerator = createReactGenerator({ name: "groupedClient", Operations({ operations }) { const { pluginManager, plugin: { options, key: pluginKey } } = useApp(); const oas = useOas(); const { getName, getFile, getGroup } = useOperationManager(); const controllers = operations.reduce( (acc, operation) => { if (options.group?.type === "tag") { const group = getGroup(operation); const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : void 0; if (!group?.tag || !name) { return acc; } const file = pluginManager.getFile({ name, extname: ".ts", pluginKey, options: { group } }); const client = { name: getName(operation, { type: "function" }), file: getFile(operation) }; const previousFile = acc.find((item) => item.file.path === file.path); if (previousFile) { previousFile.clients.push(client); } else { acc.push({ name, file, clients: [client] }); } } return acc; }, [] ); return controllers.map(({ name, file, clients }) => { return /* @__PURE__ */ jsxs( File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: getBanner({ oas, output: options.output, config: pluginManager.config }), footer: getFooter({ oas, output: options.output }), children: [ clients.map((client) => /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: file.path, path: client.file.path }, client.name)), /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { export: true, name, children: `return { ${clients.map((client) => client.name).join(", ")} }` }) }) ] }, file.path ); }); } }); // ../plugin-client/src/plugin.ts var pluginClientName = "plugin-client"; createPlugin((options) => { const { output = { path: "clients", barrelType: "named" }, group, urlType = false, exclude = [], include, override = [], transformers = {}, dataReturnType = "data", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", operations = false, baseURL, paramsCasing, generators = [clientGenerator, group ? groupedClientGenerator : void 0, operations ? operationsGenerator : void 0].filter(Boolean), parser = "client", client = "axios", importPath = client === "fetch" ? "@kubb/plugin-client/clients/fetch" : "@kubb/plugin-client/clients/axios", contentType } = options; return { name: pluginClientName, options: { output, group, parser, dataReturnType, importPath, paramsType, paramsCasing, pathParamsType, baseURL, urlType }, pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean), resolvePath(baseName, pathMode, options2) { const root = path.resolve(this.config.root, this.config.output.path); const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)); if (mode === "single") { return path.resolve(root, output.path); } if (group && (options2?.group?.path || options2?.group?.tag)) { const groupName = group?.name ? group.name : (ctx) => { if (group?.type === "path") { return `${ctx.group.split("/")[1]}`; } return `${camelCase(ctx.group)}Controller`; }; return path.resolve( root, output.path, groupName({ group: group.type === "path" ? options2.group.path : options2.group.tag }), baseName ); } return path.resolve(root, output.path, baseName); }, resolveName(name, type) { const resolvedName = camelCase(name, { isFile: type === "file" }); if (type) { return transformers?.name?.(resolvedName, type) || resolvedName; } return resolvedName; }, async buildStart() { const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]); const oas = await swaggerPlugin.context.getOas(); const root = path.resolve(this.config.root, this.config.output.path); const mode = FileManager.getMode(path.resolve(root, output.path)); const baseURL2 = await swaggerPlugin.context.getBaseURL(); const operationGenerator = new OperationGenerator( baseURL2 ? { ...this.plugin.options, baseURL: baseURL2 } : this.plugin.options, { oas, pluginManager: this.pluginManager, plugin: this.plugin, contentType, exclude, include, override, mode } ); const files = await operationGenerator.build(...generators); await this.addFile(...files); const barrelFiles = await this.fileManager.getBarrelFiles({ type: output.barrelType ?? "named", root, output, files: this.fileManager.files, meta: { pluginKey: this.plugin.key }, logger: this.logger }); await this.addFile(...barrelFiles); } }; }); var queryGenerator = createReactGenerator({ name: "react-query", Operation({ options, operation }) { const { plugin: { options: { output } }, pluginManager } = useApp(); const oas = useOas(); const { getSchemas, getName, getFile } = useOperationManager(); const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method); const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some( (method) => operation.method === method ); const importPath = options.query ? options.query.importPath : "@tanstack/react-query"; const query = { name: getName(operation, { type: "function", prefix: "use" }), typeName: getName(operation, { type: "type" }), file: getFile(operation, { prefix: "use" }) }; const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]); const client = { name: hasClientPlugin ? getName(operation, { type: "function", pluginKey: [pluginClientName] }) : getName(operation, { type: "function" }), file: getFile(operation, { pluginKey: [pluginClientName] }) }; const queryOptions = { name: getName(operation, { type: "function", suffix: "QueryOptions" }) }; const queryKey = { name: getName(operation, { type: "const", suffix: "QueryKey" }), typeName: getName(operation, { type: "type", suffix: "QueryKey" }) }; const type = { file: getFile(operation, { pluginKey: [pluginTsName] }), //todo remove type? schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" }) }; const zod = { // grouping is coming from react-query instead of zod option, we need to pass the options of zod instead file: getFile(operation, { pluginKey: [pluginZodName] }), schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" }) }; if (!isQuery || isMutation) { return null; } return /* @__PURE__ */ jsxs( File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: getBanner({ oas, output, config: pluginManager.config }), footer: getFooter({ oas, output }), children: [ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }), /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }), hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }), /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }), options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }), /* @__PURE__ */ jsx( File.Import, { name: [ type.schemas.request?.name, type.schemas.response.name, type.schemas.pathParams?.name, type.schemas.queryParams?.name, type.schemas.headerParams?.name, ...type.schemas.statusCodes?.map((item) => item.name) || [] ].filter(Boolean), root: query.file.path, path: type.file.path, isTypeOnly: true } ), /* @__PURE__ */ jsx( QueryKey, { name: queryKey.name, typeName: queryKey.typeName, operation, pathParamsType: options.pathParamsType, typeSchemas: type.schemas, paramsCasing: options.paramsCasing, transformer: options.queryKey } ), !hasClientPlugin && /* @__PURE__ */ jsx( Client, { name: client.name, baseURL: options.client.baseURL, operation, typeSchemas: type.schemas, zodSchemas: zod.schemas, dataReturnType: options.client.dataReturnType, paramsType: options.paramsType, paramsCasing: options.paramsCasing, pathParamsType: options.pathParamsType, parser: options.parser } ), /* @__PURE__ */ jsx(File.Import, { name: ["queryOptions"], path: importPath }), /* @__PURE__ */ jsx( QueryOptions, { name: queryOptions.name, clientName: client.name, queryKeyName: queryKey.name, typeSchemas: type.schemas, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, dataReturnType: options.client.dataReturnType } ), options.query && /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(File.Import, { name: ["useQuery"], path: importPath }), /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryClient", "QueryObserverOptions", "UseQueryResult", "QueryClient"], path: importPath, isTypeOnly: true }), /* @__PURE__ */ jsx( Query, { name: query.name, queryOptionsName: queryOptions.name, typeSchemas: type.schemas, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, operation, dataReturnType: options.client.dataReturnType, queryKeyName: queryKey.name, queryKeyTypeName: queryKey.typeName } ) ] }) ] } ); } }); var mutationGenerator = createReactGenerator({ name: "react-query", Operation({ options, operation }) { const { plugin: { options: { output } }, pluginManager } = useApp(); const oas = useOas(); const { getSchemas, getName, getFile } = useOperationManager(); const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method); const isMutation = !isQuery && difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method); const importPath = options.mutation ? options.mutation.importPath : "@tanstack/react-query"; const mutation = { name: getName(operation, { type: "function", prefix: "use" }), typeName: getName(operation, { type: "type" }), file: getFile(operation, { prefix: "use" }) }; const type = { file: getFile(operation, { pluginKey: [pluginTsName] }), //todo remove type? schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" }) }; const zod = { file: getFile(operation, { pluginKey: [pluginZodName] }), schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" }) }; const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]); const client = { name: hasClientPlugin ? getName(operation, { type: "function", pluginKey: [pluginClientName] }) : getName(operation, { type: "function" }), file: getFile(operation, { pluginKey: [pluginClientName] }) }; const mutationKey = { name: getName(operation, { type: "const", suffix: "MutationKey" }), typeName: getName(operation, { type: "type", suffix: "MutationKey" }) }; if (!isMutation) { return null; } return /* @__PURE__ */ jsxs( File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, banner: getBanner({ oas, output, config: pluginManager.config }), footer: getFooter({ oas, output }), children: [ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: mutation.file.path, path: zod.file.path }), /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }), !!hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: mutation.file.path, path: client.file.path }), /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }), /* @__PURE__ */ jsx( File.Import, { name: [ type.schemas.request?.name, type.schemas.response.name, type.schemas.pathParams?.name, type.schemas.queryParams?.name, type.schemas.headerParams?.name, ...type.schemas.statusCodes?.map((item) => item.name) || [] ].filter(Boolean), root: mutation.file.path, path: type.file.path, isTypeOnly: true } ), /* @__PURE__ */ jsx( MutationKey, { name: mutationKey.name, typeName: mutationKey.typeName, operation, pathParamsType: options.pathParamsType, typeSchemas: type.schemas, paramsCasing: options.paramsCasing, transformer: options.mutationKey } ), !hasClientPlugin && /* @__PURE__ */ jsx( Client, { name: client.name, baseURL: options.client.baseURL, operation, typeSchemas: type.schemas, zodSchemas: zod.schemas, dataReturnType: options.client.dataReturnType, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, parser: options.parser } ), options.mutation && /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(File.Import, { name: ["useMutation"], path: importPath }), /* @__PURE__ */ jsx(File.Import, { name: ["UseMutationOptions", "QueryClient"], path: importPath, isTypeOnly: true }), /* @__PURE__ */ jsx( Mutation, { name: mutation.name, clientName: client.name, typeName: mutation.typeName, typeSchemas: type.schemas, operation, dataReturnType: options.client.dataReturnType, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, mutationKeyName: mutationKey.name } ) ] }) ] } ); } }); var infiniteQueryGenerator = createReactGenerator({ name: "react-infinite-query", Operation({ options, operation }) { const { plugin: { options: { output } }, pluginManager } = useApp(); const oas = useOas(); const { getSchemas, getName, getFile } = useOperationManager(); const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method); const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some( (method) => operation.method === method ); const isInfinite = !!options.infinite; const importPath = options.query ? options.query.importPath : "@tanstack/react-query"; const query = { name: getName(operation, { type: "function", prefix: "use", suffix: "infinite" }), typeName: getName(operation, { type: "type" }), file: getFile(operation, { prefix: "use", suffix: "infinite" }) }; const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]); const client = { name: hasClientPlugin ? getName(operation, { type: "function", pluginKey: [pluginClientName] }) : getName(operation, { type: "function", suffix: "infinite" }), file: getFile(operation, { pluginKey: [pluginClientName] }) }; const queryOptions = { name: getName(operation, { type: "function", suffix: "InfiniteQueryOptions" }) }; const queryKey = { name: getName(operation, { type: "const", suffix: "InfiniteQueryKey" }), typeName: getName(operation, { type: "type", suffix: "InfiniteQueryKey" }) }; const type = { file: getFile(operation, { pluginKey: [pluginTsName] }), //todo remove type? schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" }) }; const zod = { file: getFile(operation, { pluginKey: [pluginZodName] }), schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" }) }; if (!isQuery || isMutation || !isInfinite) { return null; } return /* @__PURE__ */ jsxs( File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: getBanner({ oas, output, config: pluginManager.config }), footer: getFooter({ oas, output }), children: [ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }), /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }), hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }), /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }), options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }), /* @__PURE__ */ jsx( File.Import, { name: [ type.schemas.request?.name, type.schemas.response.name, type.schemas.pathParams?.name, type.schemas.queryParams?.name, type.schemas.headerParams?.name, ...type.schemas.statusCodes?.map((item) => item.name) || [] ].filter(Boolean), root: query.file.path, path: type.file.path, isTypeOnly: true } ), /* @__PURE__ */ jsx( QueryKey, { name: queryKey.name, typeName: queryKey.typeName, operation, paramsCasing: options.paramsCasing, pathParamsType: options.pathParamsType, typeSchemas: type.schemas, transformer: options.queryKey } ), !hasClientPlugin && /* @__PURE__ */ jsx( Client, { name: client.name, baseURL: options.client.baseURL, operation, typeSchemas: type.schemas, zodSchemas: zod.schemas, dataReturnType: options.client.dataReturnType, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, parser: options.parser } ), options.infinite && /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(File.Import, { name: ["InfiniteData"], isTypeOnly: true, path: importPath }), /* @__PURE__ */ jsx(File.Import, { name: ["infiniteQueryOptions"], path: importPath }), /* @__PURE__ */ jsx( InfiniteQueryOptions, { name: queryOptions.name, clientName: client.name, queryKeyName: queryKey.name, typeSchemas: type.schemas, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, dataReturnType: options.client.dataReturnType, cursorParam: options.infinite.cursorParam, initialPageParam: options.infinite.initialPageParam, queryParam: options.infinite.queryParam } ) ] }), options.infinite && /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(File.Import, { name: ["useInfiniteQuery"], path: importPath }), /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryClient", "InfiniteQueryObserverOptions", "UseInfiniteQueryResult"], path: importPath, isTypeOnly: true }), /* @__PURE__ */ jsx( InfiniteQuery, { name: query.name, queryOptionsName: queryOptions.name, typeSchemas: type.schemas, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, operation, dataReturnType: options.client.dataReturnType, queryKeyName: queryKey.name, queryKeyTypeName: queryKey.typeName } ) ] }) ] } ); } }); var suspenseQueryGenerator = createReactGenerator({ name: "react-suspense-query", Operation({ options, operation }) { const { plugin: { options: { output } }, pluginManager } = useApp(); const oas = useOas(); const { getSchemas, getName, getFile } = useOperationManager(); const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method); const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some( (method) => operation.method === method ); const isSuspense = !!options.suspense; const importPath = options.query ? options.query.importPath : "@tanstack/react-query"; const query = { name: getName(operation, { type: "function", prefix: "use", suffix: "suspense" }), typeName: getName(operation, { type: "type" }), file: getFile(operation, { prefix: "use", suffix: "suspense" }) }; const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]); const client = { name: hasClientPlugin ? getName(operation, { type: "function", pluginKey: [pluginClientName] }) : getName(operation, { type: "function", suffix: "suspense" }), file: getFile(operation, { pluginKey: [pluginClientName] }) }; const queryOptions = { name: getName(operation, { type: "function", suffix: "SuspenseQueryOptions" }) }; const queryKey = { name: getName(operation, { type: "const", suffix: "SuspenseQueryKey" }), typeName: getName(operation, { type: "type", suffix: "SuspenseQueryKey" }) }; const type = { file: getFile(operation, { pluginKey: [pluginTsName] }), //todo remove type? schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" }) }; const zod = { file: getFile(operation, { pluginKey: [pluginZodName] }), schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" }) }; if (!isQuery || isMutation || !isSuspense) { return null; } return /* @__PURE__ */ jsxs( File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: getBanner({ oas, output, config: pluginManager.config }), footer: getFooter({ oas, output }), children: [ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }), /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }), hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }), /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }), options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }), /* @__PURE__ */ jsx( File.Import, { name: [ type.schemas.request?.name, type.schemas.response.name, type.schemas.pathParams?.name, type.schemas.queryParams?.name, type.schemas.headerParams?.name, ...type.schemas.statusCodes?.map((item) => item.name) || [] ].filter(Boolean), root: query.file.path, path: type.file.path, isTypeOnly: true } ), /* @__PURE__ */ jsx( QueryKey, { name: queryKey.name, typeName: queryKey.typeName, operation, paramsCasing: options.paramsCasing, pathParamsType: options.pathParamsType, typeSchemas: type.schemas, transformer: options.queryKey } ), !hasClientPlugin && /* @__PURE__ */ jsx( Client, { name: client.name, baseURL: options.client.baseURL, operation, typeSchemas: type.schemas, zodSchemas: zod.schemas, dataReturnType: options.client.dataReturnType, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, parser: options.parser } ), /* @__PURE__ */ jsx(File.Import, { name: ["queryOptions"], path: importPath }), /* @__PURE__ */ jsx( QueryOptions, { name: queryOptions.name, clientName: client.name, queryKeyName: queryKey.name, typeSchemas: type.schemas, paramsCasing: options.paramsCasing, paramsType: options.paramsType, pathParamsType: options.pathParamsType, dataReturnType: options.client.dataReturnType } ), options.suspense && /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(File.Import, { name: ["useSuspenseQuery"], path: importPath }), /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryClient", "UseSuspenseQueryOptions", "UseSuspenseQueryResult"], path: importPath, isTypeOnly: true }), options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }), /* @__PURE__ */ jsx( SuspenseQuery, { name: query.name, queryOptionsName: queryOptions.name, typeSchemas: type.schemas, paramsType: options.paramsType, paramsCasing: options.paramsCasing, pathParamsType: options.pathParamsType, operation, dataReturnType: options.client.dataReturnType, queryKeyName: queryKey.name, queryKeyTypeName: queryKey.typeName } ) ] }) ] } ); } }); export { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator }; //# sourceMappingURL=chunk-YQ5JSTRG.js.map //# sourceMappingURL=chunk-YQ5JSTRG.js.map